diff options
Diffstat (limited to '')
39 files changed, 34943 insertions, 32994 deletions
diff --git a/docs/sqlglot/_version.html b/docs/sqlglot/_version.html index 6988e7d..8cf9948 100644 --- a/docs/sqlglot/_version.html +++ b/docs/sqlglot/_version.html @@ -51,8 +51,8 @@ <div class="pdoc-code codehilite"><pre><span></span><span id="L-1"><a href="#L-1"><span class="linenos">1</span></a><span class="c1"># file generated by setuptools_scm</span> </span><span id="L-2"><a href="#L-2"><span class="linenos">2</span></a><span class="c1"># don't change, don't track in version control</span> -</span><span id="L-3"><a href="#L-3"><span class="linenos">3</span></a><span class="n">__version__</span> <span class="o">=</span> <span class="n">version</span> <span class="o">=</span> <span class="s1">'16.2.0'</span> -</span><span id="L-4"><a href="#L-4"><span class="linenos">4</span></a><span class="n">__version_tuple__</span> <span class="o">=</span> <span class="n">version_tuple</span> <span class="o">=</span> <span class="p">(</span><span class="mi">16</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="L-3"><a href="#L-3"><span class="linenos">3</span></a><span class="n">__version__</span> <span class="o">=</span> <span class="n">version</span> <span class="o">=</span> <span class="s1">'16.3.1'</span> +</span><span id="L-4"><a href="#L-4"><span class="linenos">4</span></a><span class="n">__version_tuple__</span> <span class="o">=</span> <span class="n">version_tuple</span> <span class="o">=</span> <span class="p">(</span><span class="mi">16</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></pre></div> diff --git a/docs/sqlglot/dataframe.html b/docs/sqlglot/dataframe.html index d86d6ff..85028ca 100644 --- a/docs/sqlglot/dataframe.html +++ b/docs/sqlglot/dataframe.html @@ -72,7 +72,7 @@ <ul> <li><a href="https://github.com/tobymao/sqlglot/blob/main/README.md#install">Install SQLGlot</a> and that is all that is required to just generate SQL. <a href="#examples">The examples</a> show generating SQL and then executing that SQL on a specific engine and that will require that engine's client library.</li> <li>Find/replace all <code>from pyspark.sql</code> with <code>from <a href="">sqlglot.dataframe</a></code>.</li> -<li>Prior to any <code>spark.read.table</code> or <code>spark.table</code> run <code>sqlglot.schema.add_table('<table_name>', <column_structure>)</code>. +<li>Prior to any <code>spark.read.table</code> or <code>spark.table</code> run <code>sqlglot.schema.add_table('<table_name>', <column_structure>, dialect="spark")</code>. <ul> <li>The column structure can be defined the following ways: <ul> @@ -111,12 +111,16 @@ <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.session</span> <span class="kn">import</span> <span class="n">SparkSession</span> <span class="kn">from</span> <span class="nn"><a href="dataframe/sql.html">sqlglot.dataframe.sql</a></span> <span class="kn">import</span> <span class="n">functions</span> <span class="k">as</span> <span class="n">F</span> -<span class="n">sqlglot</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">add_table</span><span class="p">(</span><span class="s1">'employee'</span><span class="p">,</span> <span class="p">{</span> - <span class="s1">'employee_id'</span><span class="p">:</span> <span class="s1">'INT'</span><span class="p">,</span> - <span class="s1">'fname'</span><span class="p">:</span> <span class="s1">'STRING'</span><span class="p">,</span> - <span class="s1">'lname'</span><span class="p">:</span> <span class="s1">'STRING'</span><span class="p">,</span> - <span class="s1">'age'</span><span class="p">:</span> <span class="s1">'INT'</span><span class="p">,</span> -<span class="p">})</span> <span class="c1"># Register the table structure prior to reading from the table</span> +<span class="n">sqlglot</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">add_table</span><span class="p">(</span> + <span class="s1">'employee'</span><span class="p">,</span> + <span class="p">{</span> + <span class="s1">'employee_id'</span><span class="p">:</span> <span class="s1">'INT'</span><span class="p">,</span> + <span class="s1">'fname'</span><span class="p">:</span> <span class="s1">'STRING'</span><span class="p">,</span> + <span class="s1">'lname'</span><span class="p">:</span> <span class="s1">'STRING'</span><span class="p">,</span> + <span class="s1">'age'</span><span class="p">:</span> <span class="s1">'INT'</span><span class="p">,</span> + <span class="p">},</span> + <span class="n">dialect</span><span class="o">=</span><span class="s2">"spark"</span><span class="p">,</span> +<span class="p">)</span> <span class="c1"># Register the table structure prior to reading from the table</span> <span class="n">spark</span> <span class="o">=</span> <span class="n">SparkSession</span><span class="p">()</span> diff --git a/docs/sqlglot/dataframe/sql.html b/docs/sqlglot/dataframe/sql.html index 5e41262..98a954c 100644 --- a/docs/sqlglot/dataframe/sql.html +++ b/docs/sqlglot/dataframe/sql.html @@ -602,7 +602,7 @@ <div class="attr function"> <span class="def">def</span> - <span class="name">createDataFrame</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="n">data</span><span class="p">:</span> <span class="n">Sequence</span><span class="p">[</span><span class="n">Union</span><span class="p">[</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043311982688'</span><span class="o">></span><span class="p">],</span> <span class="n">List</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043311982688'</span><span class="o">></span><span class="p">],</span> <span class="n">Tuple</span><span class="p">]]</span>,</span><span class="param"> <span class="n">schema</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043311598608'</span><span class="o">></span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>,</span><span class="param"> <span class="n">samplingRatio</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">float</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>,</span><span class="param"> <span class="n">verifySchema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span></span><span class="return-annotation">) -> <span class="n"><a href="#DataFrame">sqlglot.dataframe.sql.DataFrame</a></span>:</span></span> + <span class="name">createDataFrame</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="n">data</span><span class="p">:</span> <span class="n">Sequence</span><span class="p">[</span><span class="n">Union</span><span class="p">[</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135091336672'</span><span class="o">></span><span class="p">],</span> <span class="n">List</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135091336672'</span><span class="o">></span><span class="p">],</span> <span class="n">Tuple</span><span class="p">]]</span>,</span><span class="param"> <span class="n">schema</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135091187344'</span><span class="o">></span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>,</span><span class="param"> <span class="n">samplingRatio</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">float</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>,</span><span class="param"> <span class="n">verifySchema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span></span><span class="return-annotation">) -> <span class="n"><a href="#DataFrame">sqlglot.dataframe.sql.DataFrame</a></span>:</span></span> <label class="view-source-button" for="SparkSession.createDataFrame-view-source"><span>View Source</span></label> @@ -997,505 +997,506 @@ </span><span id="DataFrame-317"><a href="#DataFrame-317"><span class="linenos">317</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="n">expression</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="s2">"spark"</span><span class="p">)</span> </span><span id="DataFrame-318"><a href="#DataFrame-318"><span class="linenos">318</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">select_expression</span><span class="o">.</span><span class="n">expressions</span> </span><span id="DataFrame-319"><a href="#DataFrame-319"><span class="linenos">319</span></a> <span class="p">},</span> -</span><span id="DataFrame-320"><a href="#DataFrame-320"><span class="linenos">320</span></a> <span class="p">)</span> -</span><span id="DataFrame-321"><a href="#DataFrame-321"><span class="linenos">321</span></a> <span class="n">cache_storage_level</span> <span class="o">=</span> <span class="n">select_expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"cache_storage_level"</span><span class="p">]</span> -</span><span id="DataFrame-322"><a href="#DataFrame-322"><span class="linenos">322</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame-323"><a href="#DataFrame-323"><span class="linenos">323</span></a> <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">"storageLevel"</span><span class="p">),</span> -</span><span id="DataFrame-324"><a href="#DataFrame-324"><span class="linenos">324</span></a> <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">cache_storage_level</span><span class="p">),</span> -</span><span id="DataFrame-325"><a href="#DataFrame-325"><span class="linenos">325</span></a> <span class="p">]</span> -</span><span id="DataFrame-326"><a href="#DataFrame-326"><span class="linenos">326</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">(</span> -</span><span id="DataFrame-327"><a href="#DataFrame-327"><span class="linenos">327</span></a> <span class="n">this</span><span class="o">=</span><span class="n">cache_table</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">select_expression</span><span class="p">,</span> <span class="n">lazy</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="n">options</span> -</span><span id="DataFrame-328"><a href="#DataFrame-328"><span class="linenos">328</span></a> <span class="p">)</span> -</span><span id="DataFrame-329"><a href="#DataFrame-329"><span class="linenos">329</span></a> <span class="c1"># We will drop the "view" if it exists before running the cache table</span> -</span><span id="DataFrame-330"><a href="#DataFrame-330"><span class="linenos">330</span></a> <span class="n">output_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">cache_table</span><span class="p">,</span> <span class="n">exists</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="s2">"VIEW"</span><span class="p">))</span> -</span><span id="DataFrame-331"><a href="#DataFrame-331"><span class="linenos">331</span></a> <span class="k">elif</span> <span class="n">expression_type</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> -</span><span id="DataFrame-332"><a href="#DataFrame-332"><span class="linenos">332</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">output_expression_container</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame-333"><a href="#DataFrame-333"><span class="linenos">333</span></a> <span class="n">expression</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">select_expression</span><span class="p">)</span> -</span><span id="DataFrame-334"><a href="#DataFrame-334"><span class="linenos">334</span></a> <span class="k">elif</span> <span class="n">expression_type</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">:</span> -</span><span id="DataFrame-335"><a href="#DataFrame-335"><span class="linenos">335</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">output_expression_container</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame-336"><a href="#DataFrame-336"><span class="linenos">336</span></a> <span class="n">select_without_ctes</span> <span class="o">=</span> <span class="n">select_expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame-337"><a href="#DataFrame-337"><span class="linenos">337</span></a> <span class="n">select_without_ctes</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"with"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="DataFrame-338"><a href="#DataFrame-338"><span class="linenos">338</span></a> <span class="n">expression</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">select_without_ctes</span><span class="p">)</span> -</span><span id="DataFrame-339"><a href="#DataFrame-339"><span class="linenos">339</span></a> <span class="k">if</span> <span class="n">select_expression</span><span class="o">.</span><span class="n">ctes</span><span class="p">:</span> -</span><span id="DataFrame-340"><a href="#DataFrame-340"><span class="linenos">340</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"with"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">select_expression</span><span class="o">.</span><span class="n">ctes</span><span class="p">))</span> -</span><span id="DataFrame-341"><a href="#DataFrame-341"><span class="linenos">341</span></a> <span class="k">elif</span> <span class="n">expression_type</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> -</span><span id="DataFrame-342"><a href="#DataFrame-342"><span class="linenos">342</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">select_expression</span> -</span><span id="DataFrame-343"><a href="#DataFrame-343"><span class="linenos">343</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame-344"><a href="#DataFrame-344"><span class="linenos">344</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid expression type: </span><span class="si">{</span><span class="n">expression_type</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="DataFrame-345"><a href="#DataFrame-345"><span class="linenos">345</span></a> <span class="n">output_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DataFrame-346"><a href="#DataFrame-346"><span class="linenos">346</span></a> -</span><span id="DataFrame-347"><a href="#DataFrame-347"><span class="linenos">347</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="DataFrame-348"><a href="#DataFrame-348"><span class="linenos">348</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="s2">"dialect"</span><span class="p">:</span> <span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">})</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">output_expressions</span> -</span><span id="DataFrame-349"><a href="#DataFrame-349"><span class="linenos">349</span></a> <span class="p">]</span> -</span><span id="DataFrame-350"><a href="#DataFrame-350"><span class="linenos">350</span></a> -</span><span id="DataFrame-351"><a href="#DataFrame-351"><span class="linenos">351</span></a> <span class="k">def</span> <span class="nf">copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-352"><a href="#DataFrame-352"><span class="linenos">352</span></a> <span class="k">return</span> <span class="n">DataFrame</span><span class="p">(</span><span class="o">**</span><span class="n">object_to_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">))</span> -</span><span id="DataFrame-353"><a href="#DataFrame-353"><span class="linenos">353</span></a> -</span><span id="DataFrame-354"><a href="#DataFrame-354"><span class="linenos">354</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> -</span><span id="DataFrame-355"><a href="#DataFrame-355"><span class="linenos">355</span></a> <span class="k">def</span> <span class="nf">select</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">cols</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-356"><a href="#DataFrame-356"><span class="linenos">356</span></a> <span class="n">cols</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> -</span><span id="DataFrame-357"><a href="#DataFrame-357"><span class="linenos">357</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"append"</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"append"</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> -</span><span id="DataFrame-358"><a href="#DataFrame-358"><span class="linenos">358</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">):</span> -</span><span id="DataFrame-359"><a href="#DataFrame-359"><span class="linenos">359</span></a> <span class="n">ambiguous_cols</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame-360"><a href="#DataFrame-360"><span class="linenos">360</span></a> <span class="n">col</span> -</span><span id="DataFrame-361"><a href="#DataFrame-361"><span class="linenos">361</span></a> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">cols</span> -</span><span id="DataFrame-362"><a href="#DataFrame-362"><span class="linenos">362</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">col</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">col</span><span class="o">.</span><span class="n">column_expression</span><span class="o">.</span><span class="n">table</span> -</span><span id="DataFrame-363"><a href="#DataFrame-363"><span class="linenos">363</span></a> <span class="p">]</span> -</span><span id="DataFrame-364"><a href="#DataFrame-364"><span class="linenos">364</span></a> <span class="k">if</span> <span class="n">ambiguous_cols</span><span class="p">:</span> -</span><span id="DataFrame-365"><a href="#DataFrame-365"><span class="linenos">365</span></a> <span class="n">join_table_identifiers</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame-366"><a href="#DataFrame-366"><span class="linenos">366</span></a> <span class="n">x</span><span class="o">.</span><span class="n">this</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">get_tables_from_expression_with_join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DataFrame-367"><a href="#DataFrame-367"><span class="linenos">367</span></a> <span class="p">]</span> -</span><span id="DataFrame-368"><a href="#DataFrame-368"><span class="linenos">368</span></a> <span class="n">cte_names_in_join</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">this</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">join_table_identifiers</span><span class="p">]</span> -</span><span id="DataFrame-369"><a href="#DataFrame-369"><span class="linenos">369</span></a> <span class="c1"># If we have columns that resolve to multiple CTE expressions then we want to use each CTE left-to-right</span> -</span><span id="DataFrame-370"><a href="#DataFrame-370"><span class="linenos">370</span></a> <span class="c1"># and therefore we allow multiple columns with the same name in the result. This matches the behavior</span> -</span><span id="DataFrame-371"><a href="#DataFrame-371"><span class="linenos">371</span></a> <span class="c1"># of Spark.</span> -</span><span id="DataFrame-372"><a href="#DataFrame-372"><span class="linenos">372</span></a> <span class="n">resolved_column_position</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">Column</span><span class="p">,</span> <span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="n">col</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">ambiguous_cols</span><span class="p">}</span> -</span><span id="DataFrame-373"><a href="#DataFrame-373"><span class="linenos">373</span></a> <span class="k">for</span> <span class="n">ambiguous_col</span> <span class="ow">in</span> <span class="n">ambiguous_cols</span><span class="p">:</span> -</span><span id="DataFrame-374"><a href="#DataFrame-374"><span class="linenos">374</span></a> <span class="n">ctes_with_column</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame-375"><a href="#DataFrame-375"><span class="linenos">375</span></a> <span class="n">cte</span> -</span><span id="DataFrame-376"><a href="#DataFrame-376"><span class="linenos">376</span></a> <span class="k">for</span> <span class="n">cte</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">ctes</span> -</span><span id="DataFrame-377"><a href="#DataFrame-377"><span class="linenos">377</span></a> <span class="k">if</span> <span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">in</span> <span class="n">cte_names_in_join</span> -</span><span id="DataFrame-378"><a href="#DataFrame-378"><span class="linenos">378</span></a> <span class="ow">and</span> <span class="n">ambiguous_col</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">in</span> <span class="n">cte</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">named_selects</span> -</span><span id="DataFrame-379"><a href="#DataFrame-379"><span class="linenos">379</span></a> <span class="p">]</span> -</span><span id="DataFrame-380"><a href="#DataFrame-380"><span class="linenos">380</span></a> <span class="c1"># Check if there is a CTE with this column that we haven't used before. If so, use it. Otherwise,</span> -</span><span id="DataFrame-381"><a href="#DataFrame-381"><span class="linenos">381</span></a> <span class="c1"># use the same CTE we used before</span> -</span><span id="DataFrame-382"><a href="#DataFrame-382"><span class="linenos">382</span></a> <span class="n">cte</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">ctes_with_column</span><span class="p">,</span> <span class="n">resolved_column_position</span><span class="p">[</span><span class="n">ambiguous_col</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="DataFrame-383"><a href="#DataFrame-383"><span class="linenos">383</span></a> <span class="k">if</span> <span class="n">cte</span><span class="p">:</span> -</span><span id="DataFrame-384"><a href="#DataFrame-384"><span class="linenos">384</span></a> <span class="n">resolved_column_position</span><span class="p">[</span><span class="n">ambiguous_col</span><span class="p">]</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="DataFrame-385"><a href="#DataFrame-385"><span class="linenos">385</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame-386"><a href="#DataFrame-386"><span class="linenos">386</span></a> <span class="n">cte</span> <span class="o">=</span> <span class="n">ctes_with_column</span><span class="p">[</span><span class="n">resolved_column_position</span><span class="p">[</span><span class="n">ambiguous_col</span><span class="p">]]</span> -</span><span id="DataFrame-387"><a href="#DataFrame-387"><span class="linenos">387</span></a> <span class="n">ambiguous_col</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"table"</span><span class="p">,</span> <span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">)</span> -</span><span id="DataFrame-388"><a href="#DataFrame-388"><span class="linenos">388</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span> -</span><span id="DataFrame-389"><a href="#DataFrame-389"><span class="linenos">389</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">expression</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">cols</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span> -</span><span id="DataFrame-390"><a href="#DataFrame-390"><span class="linenos">390</span></a> <span class="p">)</span> -</span><span id="DataFrame-391"><a href="#DataFrame-391"><span class="linenos">391</span></a> -</span><span id="DataFrame-392"><a href="#DataFrame-392"><span class="linenos">392</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> -</span><span id="DataFrame-393"><a href="#DataFrame-393"><span class="linenos">393</span></a> <span class="k">def</span> <span class="nf">alias</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-394"><a href="#DataFrame-394"><span class="linenos">394</span></a> <span class="n">new_sequence_id</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">spark</span><span class="o">.</span><span class="n">_random_sequence_id</span> -</span><span id="DataFrame-395"><a href="#DataFrame-395"><span class="linenos">395</span></a> <span class="n">df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame-396"><a href="#DataFrame-396"><span class="linenos">396</span></a> <span class="k">for</span> <span class="n">join_hint</span> <span class="ow">in</span> <span class="n">df</span><span class="o">.</span><span class="n">pending_join_hints</span><span class="p">:</span> -</span><span id="DataFrame-397"><a href="#DataFrame-397"><span class="linenos">397</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">join_hint</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="DataFrame-398"><a href="#DataFrame-398"><span class="linenos">398</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">sequence_id</span><span class="p">:</span> -</span><span id="DataFrame-399"><a href="#DataFrame-399"><span class="linenos">399</span></a> <span class="n">expression</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">Column</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">new_sequence_id</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DataFrame-400"><a href="#DataFrame-400"><span class="linenos">400</span></a> <span class="n">df</span><span class="o">.</span><span class="n">spark</span><span class="o">.</span><span class="n">_add_alias_to_mapping</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">new_sequence_id</span><span class="p">)</span> -</span><span id="DataFrame-401"><a href="#DataFrame-401"><span class="linenos">401</span></a> <span class="k">return</span> <span class="n">df</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">(</span><span class="n">sequence_id</span><span class="o">=</span><span class="n">new_sequence_id</span><span class="p">)</span> -</span><span id="DataFrame-402"><a href="#DataFrame-402"><span class="linenos">402</span></a> -</span><span id="DataFrame-403"><a href="#DataFrame-403"><span class="linenos">403</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">WHERE</span><span class="p">)</span> -</span><span id="DataFrame-404"><a href="#DataFrame-404"><span class="linenos">404</span></a> <span class="k">def</span> <span class="nf">where</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">column</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">Column</span><span class="p">,</span> <span class="nb">bool</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-405"><a href="#DataFrame-405"><span class="linenos">405</span></a> <span class="n">col</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_col</span><span class="p">(</span><span class="n">column</span><span class="p">)</span> -</span><span id="DataFrame-406"><a href="#DataFrame-406"><span class="linenos">406</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">col</span><span class="o">.</span><span class="n">expression</span><span class="p">))</span> -</span><span id="DataFrame-407"><a href="#DataFrame-407"><span class="linenos">407</span></a> -</span><span id="DataFrame-408"><a href="#DataFrame-408"><span class="linenos">408</span></a> <span class="nb">filter</span> <span class="o">=</span> <span class="n">where</span> -</span><span id="DataFrame-409"><a href="#DataFrame-409"><span class="linenos">409</span></a> -</span><span id="DataFrame-410"><a href="#DataFrame-410"><span class="linenos">410</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">GROUP_BY</span><span class="p">)</span> -</span><span id="DataFrame-411"><a href="#DataFrame-411"><span class="linenos">411</span></a> <span class="k">def</span> <span class="nf">groupBy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">cols</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">GroupedData</span><span class="p">:</span> -</span><span id="DataFrame-412"><a href="#DataFrame-412"><span class="linenos">412</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> -</span><span id="DataFrame-413"><a href="#DataFrame-413"><span class="linenos">413</span></a> <span class="k">return</span> <span class="n">GroupedData</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">columns</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">last_op</span><span class="p">)</span> -</span><span id="DataFrame-414"><a href="#DataFrame-414"><span class="linenos">414</span></a> -</span><span id="DataFrame-415"><a href="#DataFrame-415"><span class="linenos">415</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> -</span><span id="DataFrame-416"><a href="#DataFrame-416"><span class="linenos">416</span></a> <span class="k">def</span> <span class="nf">agg</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">exprs</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-417"><a href="#DataFrame-417"><span class="linenos">417</span></a> <span class="n">cols</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">exprs</span><span class="p">)</span> -</span><span id="DataFrame-418"><a href="#DataFrame-418"><span class="linenos">418</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">groupBy</span><span class="p">()</span><span class="o">.</span><span class="n">agg</span><span class="p">(</span><span class="o">*</span><span class="n">cols</span><span class="p">)</span> -</span><span id="DataFrame-419"><a href="#DataFrame-419"><span class="linenos">419</span></a> -</span><span id="DataFrame-420"><a href="#DataFrame-420"><span class="linenos">420</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> -</span><span id="DataFrame-421"><a href="#DataFrame-421"><span class="linenos">421</span></a> <span class="k">def</span> <span class="nf">join</span><span class="p">(</span> -</span><span id="DataFrame-422"><a href="#DataFrame-422"><span class="linenos">422</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DataFrame-423"><a href="#DataFrame-423"><span class="linenos">423</span></a> <span class="n">other_df</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> -</span><span id="DataFrame-424"><a href="#DataFrame-424"><span class="linenos">424</span></a> <span class="n">on</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">Column</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">Column</span><span class="p">]],</span> -</span><span id="DataFrame-425"><a href="#DataFrame-425"><span class="linenos">425</span></a> <span class="n">how</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"inner"</span><span class="p">,</span> -</span><span id="DataFrame-426"><a href="#DataFrame-426"><span class="linenos">426</span></a> <span class="o">**</span><span class="n">kwargs</span><span class="p">,</span> -</span><span id="DataFrame-427"><a href="#DataFrame-427"><span class="linenos">427</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-428"><a href="#DataFrame-428"><span class="linenos">428</span></a> <span class="n">other_df</span> <span class="o">=</span> <span class="n">other_df</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">()</span> -</span><span id="DataFrame-429"><a href="#DataFrame-429"><span class="linenos">429</span></a> <span class="n">join_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">on</span><span class="p">)</span> -</span><span id="DataFrame-430"><a href="#DataFrame-430"><span class="linenos">430</span></a> <span class="c1"># We will determine actual "join on" expression later so we don't provide it at first</span> -</span><span id="DataFrame-431"><a href="#DataFrame-431"><span class="linenos">431</span></a> <span class="n">join_expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="DataFrame-432"><a href="#DataFrame-432"><span class="linenos">432</span></a> <span class="n">other_df</span><span class="o">.</span><span class="n">latest_cte_name</span><span class="p">,</span> <span class="n">join_type</span><span class="o">=</span><span class="n">how</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"_"</span><span class="p">,</span> <span class="s2">" "</span><span class="p">)</span> -</span><span id="DataFrame-433"><a href="#DataFrame-433"><span class="linenos">433</span></a> <span class="p">)</span> -</span><span id="DataFrame-434"><a href="#DataFrame-434"><span class="linenos">434</span></a> <span class="n">join_expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add_ctes_to_expression</span><span class="p">(</span><span class="n">join_expression</span><span class="p">,</span> <span class="n">other_df</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">ctes</span><span class="p">)</span> -</span><span id="DataFrame-435"><a href="#DataFrame-435"><span class="linenos">435</span></a> <span class="n">self_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">join_expression</span><span class="p">)</span> -</span><span id="DataFrame-436"><a href="#DataFrame-436"><span class="linenos">436</span></a> <span class="n">other_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">other_df</span><span class="p">)</span> -</span><span id="DataFrame-437"><a href="#DataFrame-437"><span class="linenos">437</span></a> <span class="c1"># Determines the join clause and select columns to be used passed on what type of columns were provided for</span> -</span><span id="DataFrame-438"><a href="#DataFrame-438"><span class="linenos">438</span></a> <span class="c1"># the join. The columns returned changes based on how the on expression is provided.</span> -</span><span id="DataFrame-439"><a href="#DataFrame-439"><span class="linenos">439</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">join_columns</span><span class="p">[</span><span class="mi">0</span><span class="p">]</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">Column</span><span class="p">):</span> -</span><span id="DataFrame-440"><a href="#DataFrame-440"><span class="linenos">440</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="DataFrame-441"><a href="#DataFrame-441"><span class="linenos">441</span></a><span class="sd"> Unique characteristics of join on column names only:</span> -</span><span id="DataFrame-442"><a href="#DataFrame-442"><span class="linenos">442</span></a><span class="sd"> * The column names are put at the front of the select list</span> -</span><span id="DataFrame-443"><a href="#DataFrame-443"><span class="linenos">443</span></a><span class="sd"> * The column names are deduplicated across the entire select list and only the column names (other dups are allowed)</span> -</span><span id="DataFrame-444"><a href="#DataFrame-444"><span class="linenos">444</span></a><span class="sd"> """</span> -</span><span id="DataFrame-445"><a href="#DataFrame-445"><span class="linenos">445</span></a> <span class="n">table_names</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame-446"><a href="#DataFrame-446"><span class="linenos">446</span></a> <span class="n">table</span><span class="o">.</span><span class="n">alias_or_name</span> -</span><span id="DataFrame-447"><a href="#DataFrame-447"><span class="linenos">447</span></a> <span class="k">for</span> <span class="n">table</span> <span class="ow">in</span> <span class="n">get_tables_from_expression_with_join</span><span class="p">(</span><span class="n">join_expression</span><span class="p">)</span> -</span><span id="DataFrame-448"><a href="#DataFrame-448"><span class="linenos">448</span></a> <span class="p">]</span> -</span><span id="DataFrame-449"><a href="#DataFrame-449"><span class="linenos">449</span></a> <span class="n">potential_ctes</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame-450"><a href="#DataFrame-450"><span class="linenos">450</span></a> <span class="n">cte</span> -</span><span id="DataFrame-451"><a href="#DataFrame-451"><span class="linenos">451</span></a> <span class="k">for</span> <span class="n">cte</span> <span class="ow">in</span> <span class="n">join_expression</span><span class="o">.</span><span class="n">ctes</span> -</span><span id="DataFrame-452"><a href="#DataFrame-452"><span class="linenos">452</span></a> <span class="k">if</span> <span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">in</span> <span class="n">table_names</span> -</span><span id="DataFrame-453"><a href="#DataFrame-453"><span class="linenos">453</span></a> <span class="ow">and</span> <span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="o">!=</span> <span class="n">other_df</span><span class="o">.</span><span class="n">latest_cte_name</span> -</span><span id="DataFrame-454"><a href="#DataFrame-454"><span class="linenos">454</span></a> <span class="p">]</span> -</span><span id="DataFrame-455"><a href="#DataFrame-455"><span class="linenos">455</span></a> <span class="c1"># Determine the table to reference for the left side of the join by checking each of the left side</span> -</span><span id="DataFrame-456"><a href="#DataFrame-456"><span class="linenos">456</span></a> <span class="c1"># tables and see if they have the column being referenced.</span> -</span><span id="DataFrame-457"><a href="#DataFrame-457"><span class="linenos">457</span></a> <span class="n">join_column_pairs</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="DataFrame-458"><a href="#DataFrame-458"><span class="linenos">458</span></a> <span class="k">for</span> <span class="n">join_column</span> <span class="ow">in</span> <span class="n">join_columns</span><span class="p">:</span> -</span><span id="DataFrame-459"><a href="#DataFrame-459"><span class="linenos">459</span></a> <span class="n">num_matching_ctes</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="DataFrame-460"><a href="#DataFrame-460"><span class="linenos">460</span></a> <span class="k">for</span> <span class="n">cte</span> <span class="ow">in</span> <span class="n">potential_ctes</span><span class="p">:</span> -</span><span id="DataFrame-461"><a href="#DataFrame-461"><span class="linenos">461</span></a> <span class="k">if</span> <span class="n">join_column</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">in</span> <span class="n">cte</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">named_selects</span><span class="p">:</span> -</span><span id="DataFrame-462"><a href="#DataFrame-462"><span class="linenos">462</span></a> <span class="n">left_column</span> <span class="o">=</span> <span class="n">join_column</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">set_table_name</span><span class="p">(</span><span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">)</span> -</span><span id="DataFrame-463"><a href="#DataFrame-463"><span class="linenos">463</span></a> <span class="n">right_column</span> <span class="o">=</span> <span class="n">join_column</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">set_table_name</span><span class="p">(</span><span class="n">other_df</span><span class="o">.</span><span class="n">latest_cte_name</span><span class="p">)</span> -</span><span id="DataFrame-464"><a href="#DataFrame-464"><span class="linenos">464</span></a> <span class="n">join_column_pairs</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">left_column</span><span class="p">,</span> <span class="n">right_column</span><span class="p">))</span> -</span><span id="DataFrame-465"><a href="#DataFrame-465"><span class="linenos">465</span></a> <span class="n">num_matching_ctes</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="DataFrame-466"><a href="#DataFrame-466"><span class="linenos">466</span></a> <span class="k">if</span> <span class="n">num_matching_ctes</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="DataFrame-467"><a href="#DataFrame-467"><span class="linenos">467</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span> -</span><span id="DataFrame-468"><a href="#DataFrame-468"><span class="linenos">468</span></a> <span class="sa">f</span><span class="s2">"Column </span><span class="si">{</span><span class="n">join_column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="si">}</span><span class="s2"> is ambiguous. Please specify the table name."</span> -</span><span id="DataFrame-469"><a href="#DataFrame-469"><span class="linenos">469</span></a> <span class="p">)</span> -</span><span id="DataFrame-470"><a href="#DataFrame-470"><span class="linenos">470</span></a> <span class="k">elif</span> <span class="n">num_matching_ctes</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> -</span><span id="DataFrame-471"><a href="#DataFrame-471"><span class="linenos">471</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span> -</span><span id="DataFrame-472"><a href="#DataFrame-472"><span class="linenos">472</span></a> <span class="sa">f</span><span class="s2">"Column </span><span class="si">{</span><span class="n">join_column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="si">}</span><span class="s2"> does not exist in any of the tables."</span> -</span><span id="DataFrame-473"><a href="#DataFrame-473"><span class="linenos">473</span></a> <span class="p">)</span> -</span><span id="DataFrame-474"><a href="#DataFrame-474"><span class="linenos">474</span></a> <span class="n">join_clause</span> <span class="o">=</span> <span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span> -</span><span id="DataFrame-475"><a href="#DataFrame-475"><span class="linenos">475</span></a> <span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span> <span class="o">&</span> <span class="n">y</span><span class="p">,</span> -</span><span id="DataFrame-476"><a href="#DataFrame-476"><span class="linenos">476</span></a> <span class="p">[</span><span class="n">left_column</span> <span class="o">==</span> <span class="n">right_column</span> <span class="k">for</span> <span class="n">left_column</span><span class="p">,</span> <span class="n">right_column</span> <span class="ow">in</span> <span class="n">join_column_pairs</span><span class="p">],</span> -</span><span id="DataFrame-477"><a href="#DataFrame-477"><span class="linenos">477</span></a> <span class="p">)</span> -</span><span id="DataFrame-478"><a href="#DataFrame-478"><span class="linenos">478</span></a> <span class="n">join_column_names</span> <span class="o">=</span> <span class="p">[</span><span class="n">left_col</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="k">for</span> <span class="n">left_col</span><span class="p">,</span> <span class="n">_</span> <span class="ow">in</span> <span class="n">join_column_pairs</span><span class="p">]</span> -</span><span id="DataFrame-479"><a href="#DataFrame-479"><span class="linenos">479</span></a> <span class="c1"># To match spark behavior only the join clause gets deduplicated and it gets put in the front of the column list</span> -</span><span id="DataFrame-480"><a href="#DataFrame-480"><span class="linenos">480</span></a> <span class="n">select_column_names</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame-481"><a href="#DataFrame-481"><span class="linenos">481</span></a> <span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span> -</span><span id="DataFrame-482"><a href="#DataFrame-482"><span class="linenos">482</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">)</span> -</span><span id="DataFrame-483"><a href="#DataFrame-483"><span class="linenos">483</span></a> <span class="k">else</span> <span class="n">column</span><span class="o">.</span><span class="n">sql</span><span class="p">()</span> -</span><span id="DataFrame-484"><a href="#DataFrame-484"><span class="linenos">484</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">self_columns</span> <span class="o">+</span> <span class="n">other_columns</span> -</span><span id="DataFrame-485"><a href="#DataFrame-485"><span class="linenos">485</span></a> <span class="p">]</span> -</span><span id="DataFrame-486"><a href="#DataFrame-486"><span class="linenos">486</span></a> <span class="n">select_column_names</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame-487"><a href="#DataFrame-487"><span class="linenos">487</span></a> <span class="n">column_name</span> -</span><span id="DataFrame-488"><a href="#DataFrame-488"><span class="linenos">488</span></a> <span class="k">for</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="n">select_column_names</span> -</span><span id="DataFrame-489"><a href="#DataFrame-489"><span class="linenos">489</span></a> <span class="k">if</span> <span class="n">column_name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">join_column_names</span> -</span><span id="DataFrame-490"><a href="#DataFrame-490"><span class="linenos">490</span></a> <span class="p">]</span> -</span><span id="DataFrame-491"><a href="#DataFrame-491"><span class="linenos">491</span></a> <span class="n">select_column_names</span> <span class="o">=</span> <span class="n">join_column_names</span> <span class="o">+</span> <span class="n">select_column_names</span> -</span><span id="DataFrame-492"><a href="#DataFrame-492"><span class="linenos">492</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame-493"><a href="#DataFrame-493"><span class="linenos">493</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="DataFrame-494"><a href="#DataFrame-494"><span class="linenos">494</span></a><span class="sd"> Unique characteristics of join on expressions:</span> -</span><span id="DataFrame-495"><a href="#DataFrame-495"><span class="linenos">495</span></a><span class="sd"> * There is no deduplication of the results.</span> -</span><span id="DataFrame-496"><a href="#DataFrame-496"><span class="linenos">496</span></a><span class="sd"> * The left join dataframe columns go first and right come after. No sort preference is given to join columns</span> -</span><span id="DataFrame-497"><a href="#DataFrame-497"><span class="linenos">497</span></a><span class="sd"> """</span> -</span><span id="DataFrame-498"><a href="#DataFrame-498"><span class="linenos">498</span></a> <span class="n">join_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">join_columns</span><span class="p">,</span> <span class="n">join_expression</span><span class="p">)</span> -</span><span id="DataFrame-499"><a href="#DataFrame-499"><span class="linenos">499</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">join_columns</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="DataFrame-500"><a href="#DataFrame-500"><span class="linenos">500</span></a> <span class="n">join_columns</span> <span class="o">=</span> <span class="p">[</span><span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span> <span class="o">&</span> <span class="n">y</span><span class="p">,</span> <span class="n">join_columns</span><span class="p">)]</span> -</span><span id="DataFrame-501"><a href="#DataFrame-501"><span class="linenos">501</span></a> <span class="n">join_clause</span> <span class="o">=</span> <span class="n">join_columns</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="DataFrame-502"><a href="#DataFrame-502"><span class="linenos">502</span></a> <span class="n">select_column_names</span> <span class="o">=</span> <span class="p">[</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">self_columns</span> <span class="o">+</span> <span class="n">other_columns</span><span class="p">]</span> -</span><span id="DataFrame-503"><a href="#DataFrame-503"><span class="linenos">503</span></a> -</span><span id="DataFrame-504"><a href="#DataFrame-504"><span class="linenos">504</span></a> <span class="c1"># Update the on expression with the actual join clause to replace the dummy one from before</span> -</span><span id="DataFrame-505"><a href="#DataFrame-505"><span class="linenos">505</span></a> <span class="n">join_expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"joins"</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"on"</span><span class="p">,</span> <span class="n">join_clause</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DataFrame-506"><a href="#DataFrame-506"><span class="linenos">506</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">join_expression</span><span class="p">)</span> -</span><span id="DataFrame-507"><a href="#DataFrame-507"><span class="linenos">507</span></a> <span class="n">new_df</span><span class="o">.</span><span class="n">pending_join_hints</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">pending_join_hints</span><span class="p">)</span> -</span><span id="DataFrame-508"><a href="#DataFrame-508"><span class="linenos">508</span></a> <span class="n">new_df</span><span class="o">.</span><span class="n">pending_hints</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">other_df</span><span class="o">.</span><span class="n">pending_hints</span><span class="p">)</span> -</span><span id="DataFrame-509"><a href="#DataFrame-509"><span class="linenos">509</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">select</span><span class="o">.</span><span class="n">__wrapped__</span><span class="p">(</span><span class="n">new_df</span><span class="p">,</span> <span class="o">*</span><span class="n">select_column_names</span><span class="p">)</span> -</span><span id="DataFrame-510"><a href="#DataFrame-510"><span class="linenos">510</span></a> <span class="k">return</span> <span class="n">new_df</span> -</span><span id="DataFrame-511"><a href="#DataFrame-511"><span class="linenos">511</span></a> -</span><span id="DataFrame-512"><a href="#DataFrame-512"><span class="linenos">512</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">ORDER_BY</span><span class="p">)</span> -</span><span id="DataFrame-513"><a href="#DataFrame-513"><span class="linenos">513</span></a> <span class="k">def</span> <span class="nf">orderBy</span><span class="p">(</span> -</span><span id="DataFrame-514"><a href="#DataFrame-514"><span class="linenos">514</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DataFrame-515"><a href="#DataFrame-515"><span class="linenos">515</span></a> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Column</span><span class="p">],</span> -</span><span id="DataFrame-516"><a href="#DataFrame-516"><span class="linenos">516</span></a> <span class="n">ascending</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Any</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">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrame-517"><a href="#DataFrame-517"><span class="linenos">517</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-518"><a href="#DataFrame-518"><span class="linenos">518</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="DataFrame-519"><a href="#DataFrame-519"><span class="linenos">519</span></a><span class="sd"> This implementation lets any ordered columns take priority over whatever is provided in `ascending`. Spark</span> -</span><span id="DataFrame-520"><a href="#DataFrame-520"><span class="linenos">520</span></a><span class="sd"> has irregular behavior and can result in runtime errors. Users shouldn't be mixing the two anyways so this</span> -</span><span id="DataFrame-521"><a href="#DataFrame-521"><span class="linenos">521</span></a><span class="sd"> is unlikely to come up.</span> -</span><span id="DataFrame-522"><a href="#DataFrame-522"><span class="linenos">522</span></a><span class="sd"> """</span> -</span><span id="DataFrame-523"><a href="#DataFrame-523"><span class="linenos">523</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> -</span><span id="DataFrame-524"><a href="#DataFrame-524"><span class="linenos">524</span></a> <span class="n">pre_ordered_col_indexes</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame-525"><a href="#DataFrame-525"><span class="linenos">525</span></a> <span class="n">x</span> -</span><span id="DataFrame-526"><a href="#DataFrame-526"><span class="linenos">526</span></a> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span> -</span><span id="DataFrame-527"><a href="#DataFrame-527"><span class="linenos">527</span></a> <span class="n">i</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">col</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">Ordered</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="DataFrame-528"><a href="#DataFrame-528"><span class="linenos">528</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">col</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> -</span><span id="DataFrame-529"><a href="#DataFrame-529"><span class="linenos">529</span></a> <span class="p">]</span> -</span><span id="DataFrame-530"><a href="#DataFrame-530"><span class="linenos">530</span></a> <span class="k">if</span> <span class="n">x</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> -</span><span id="DataFrame-531"><a href="#DataFrame-531"><span class="linenos">531</span></a> <span class="p">]</span> -</span><span id="DataFrame-532"><a href="#DataFrame-532"><span class="linenos">532</span></a> <span class="k">if</span> <span class="n">ascending</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="DataFrame-533"><a href="#DataFrame-533"><span class="linenos">533</span></a> <span class="n">ascending</span> <span class="o">=</span> <span class="p">[</span><span class="kc">True</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> -</span><span id="DataFrame-534"><a href="#DataFrame-534"><span class="linenos">534</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">ascending</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="DataFrame-535"><a href="#DataFrame-535"><span class="linenos">535</span></a> <span class="n">ascending</span> <span class="o">=</span> <span class="p">[</span><span class="n">ascending</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> -</span><span id="DataFrame-536"><a href="#DataFrame-536"><span class="linenos">536</span></a> <span class="n">ascending</span> <span class="o">=</span> <span class="p">[</span><span class="nb">bool</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">ascending</span><span class="p">)]</span> -</span><span id="DataFrame-537"><a href="#DataFrame-537"><span class="linenos">537</span></a> <span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span> -</span><span id="DataFrame-538"><a href="#DataFrame-538"><span class="linenos">538</span></a> <span class="n">ascending</span> -</span><span id="DataFrame-539"><a href="#DataFrame-539"><span class="linenos">539</span></a> <span class="p">),</span> <span class="s2">"The length of items in ascending must equal the number of columns provided"</span> -</span><span id="DataFrame-540"><a href="#DataFrame-540"><span class="linenos">540</span></a> <span class="n">col_and_ascending</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">columns</span><span class="p">,</span> <span class="n">ascending</span><span class="p">))</span> -</span><span id="DataFrame-541"><a href="#DataFrame-541"><span class="linenos">541</span></a> <span class="n">order_by_columns</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame-542"><a href="#DataFrame-542"><span class="linenos">542</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">col</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="ow">not</span> <span class="n">asc</span><span class="p">)</span> -</span><span id="DataFrame-543"><a href="#DataFrame-543"><span class="linenos">543</span></a> <span class="k">if</span> <span class="n">i</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">pre_ordered_col_indexes</span> -</span><span id="DataFrame-544"><a href="#DataFrame-544"><span class="linenos">544</span></a> <span class="k">else</span> <span class="n">columns</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">column_expression</span> -</span><span id="DataFrame-545"><a href="#DataFrame-545"><span class="linenos">545</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="p">(</span><span class="n">col</span><span class="p">,</span> <span class="n">asc</span><span class="p">)</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">col_and_ascending</span><span class="p">)</span> -</span><span id="DataFrame-546"><a href="#DataFrame-546"><span class="linenos">546</span></a> <span class="p">]</span> -</span><span id="DataFrame-547"><a href="#DataFrame-547"><span class="linenos">547</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">order_by</span><span class="p">(</span><span class="o">*</span><span class="n">order_by_columns</span><span class="p">))</span> -</span><span id="DataFrame-548"><a href="#DataFrame-548"><span class="linenos">548</span></a> -</span><span id="DataFrame-549"><a href="#DataFrame-549"><span class="linenos">549</span></a> <span class="n">sort</span> <span class="o">=</span> <span class="n">orderBy</span> -</span><span id="DataFrame-550"><a href="#DataFrame-550"><span class="linenos">550</span></a> -</span><span id="DataFrame-551"><a href="#DataFrame-551"><span class="linenos">551</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> -</span><span id="DataFrame-552"><a href="#DataFrame-552"><span class="linenos">552</span></a> <span class="k">def</span> <span class="nf">union</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-553"><a href="#DataFrame-553"><span class="linenos">553</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">,</span> <span class="n">other</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> -</span><span id="DataFrame-554"><a href="#DataFrame-554"><span class="linenos">554</span></a> -</span><span id="DataFrame-555"><a href="#DataFrame-555"><span class="linenos">555</span></a> <span class="n">unionAll</span> <span class="o">=</span> <span class="n">union</span> -</span><span id="DataFrame-556"><a href="#DataFrame-556"><span class="linenos">556</span></a> -</span><span id="DataFrame-557"><a href="#DataFrame-557"><span class="linenos">557</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> -</span><span id="DataFrame-558"><a href="#DataFrame-558"><span class="linenos">558</span></a> <span class="k">def</span> <span class="nf">unionByName</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> <span class="n">allowMissingColumns</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">):</span> -</span><span id="DataFrame-559"><a href="#DataFrame-559"><span class="linenos">559</span></a> <span class="n">l_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">columns</span> -</span><span id="DataFrame-560"><a href="#DataFrame-560"><span class="linenos">560</span></a> <span class="n">r_columns</span> <span class="o">=</span> <span class="n">other</span><span class="o">.</span><span class="n">columns</span> -</span><span id="DataFrame-561"><a href="#DataFrame-561"><span class="linenos">561</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">allowMissingColumns</span><span class="p">:</span> -</span><span id="DataFrame-562"><a href="#DataFrame-562"><span class="linenos">562</span></a> <span class="n">l_expressions</span> <span class="o">=</span> <span class="n">l_columns</span> -</span><span id="DataFrame-563"><a href="#DataFrame-563"><span class="linenos">563</span></a> <span class="n">r_expressions</span> <span class="o">=</span> <span class="n">l_columns</span> -</span><span id="DataFrame-564"><a href="#DataFrame-564"><span class="linenos">564</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame-565"><a href="#DataFrame-565"><span class="linenos">565</span></a> <span class="n">l_expressions</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="DataFrame-566"><a href="#DataFrame-566"><span class="linenos">566</span></a> <span class="n">r_expressions</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="DataFrame-567"><a href="#DataFrame-567"><span class="linenos">567</span></a> <span class="n">r_columns_unused</span> <span class="o">=</span> <span class="n">copy</span><span class="p">(</span><span class="n">r_columns</span><span class="p">)</span> -</span><span id="DataFrame-568"><a href="#DataFrame-568"><span class="linenos">568</span></a> <span class="k">for</span> <span class="n">l_column</span> <span class="ow">in</span> <span class="n">l_columns</span><span class="p">:</span> -</span><span id="DataFrame-569"><a href="#DataFrame-569"><span class="linenos">569</span></a> <span class="n">l_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">l_column</span><span class="p">)</span> -</span><span id="DataFrame-570"><a href="#DataFrame-570"><span class="linenos">570</span></a> <span class="k">if</span> <span class="n">l_column</span> <span class="ow">in</span> <span class="n">r_columns</span><span class="p">:</span> -</span><span id="DataFrame-571"><a href="#DataFrame-571"><span class="linenos">571</span></a> <span class="n">r_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">l_column</span><span class="p">)</span> -</span><span id="DataFrame-572"><a href="#DataFrame-572"><span class="linenos">572</span></a> <span class="n">r_columns_unused</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">l_column</span><span class="p">)</span> -</span><span id="DataFrame-573"><a href="#DataFrame-573"><span class="linenos">573</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame-574"><a href="#DataFrame-574"><span class="linenos">574</span></a> <span class="n">r_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">(),</span> <span class="n">l_column</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> -</span><span id="DataFrame-575"><a href="#DataFrame-575"><span class="linenos">575</span></a> <span class="k">for</span> <span class="n">r_column</span> <span class="ow">in</span> <span class="n">r_columns_unused</span><span class="p">:</span> -</span><span id="DataFrame-576"><a href="#DataFrame-576"><span class="linenos">576</span></a> <span class="n">l_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">(),</span> <span class="n">r_column</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> -</span><span id="DataFrame-577"><a href="#DataFrame-577"><span class="linenos">577</span></a> <span class="n">r_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">r_column</span><span class="p">)</span> -</span><span id="DataFrame-578"><a href="#DataFrame-578"><span class="linenos">578</span></a> <span class="n">r_df</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="DataFrame-579"><a href="#DataFrame-579"><span class="linenos">579</span></a> <span class="n">other</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">r_expressions</span><span class="p">))</span> -</span><span id="DataFrame-580"><a href="#DataFrame-580"><span class="linenos">580</span></a> <span class="p">)</span> -</span><span id="DataFrame-581"><a href="#DataFrame-581"><span class="linenos">581</span></a> <span class="n">l_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame-582"><a href="#DataFrame-582"><span class="linenos">582</span></a> <span class="k">if</span> <span class="n">allowMissingColumns</span><span class="p">:</span> -</span><span id="DataFrame-583"><a href="#DataFrame-583"><span class="linenos">583</span></a> <span class="n">l_df</span> <span class="o">=</span> <span class="n">l_df</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">l_expressions</span><span class="p">))</span> -</span><span id="DataFrame-584"><a href="#DataFrame-584"><span class="linenos">584</span></a> <span class="k">return</span> <span class="n">l_df</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">,</span> <span class="n">r_df</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> -</span><span id="DataFrame-585"><a href="#DataFrame-585"><span class="linenos">585</span></a> -</span><span id="DataFrame-586"><a href="#DataFrame-586"><span class="linenos">586</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> -</span><span id="DataFrame-587"><a href="#DataFrame-587"><span class="linenos">587</span></a> <span class="k">def</span> <span class="nf">intersect</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-588"><a href="#DataFrame-588"><span class="linenos">588</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="n">other</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> -</span><span id="DataFrame-589"><a href="#DataFrame-589"><span class="linenos">589</span></a> -</span><span id="DataFrame-590"><a href="#DataFrame-590"><span class="linenos">590</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> -</span><span id="DataFrame-591"><a href="#DataFrame-591"><span class="linenos">591</span></a> <span class="k">def</span> <span class="nf">intersectAll</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-592"><a href="#DataFrame-592"><span class="linenos">592</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="n">other</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> -</span><span id="DataFrame-593"><a href="#DataFrame-593"><span class="linenos">593</span></a> -</span><span id="DataFrame-594"><a href="#DataFrame-594"><span class="linenos">594</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> -</span><span id="DataFrame-595"><a href="#DataFrame-595"><span class="linenos">595</span></a> <span class="k">def</span> <span class="nf">exceptAll</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-596"><a href="#DataFrame-596"><span class="linenos">596</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">,</span> <span class="n">other</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> -</span><span id="DataFrame-597"><a href="#DataFrame-597"><span class="linenos">597</span></a> -</span><span id="DataFrame-598"><a href="#DataFrame-598"><span class="linenos">598</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> -</span><span id="DataFrame-599"><a href="#DataFrame-599"><span class="linenos">599</span></a> <span class="k">def</span> <span class="nf">distinct</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-600"><a href="#DataFrame-600"><span class="linenos">600</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">distinct</span><span class="p">())</span> -</span><span id="DataFrame-601"><a href="#DataFrame-601"><span class="linenos">601</span></a> -</span><span id="DataFrame-602"><a href="#DataFrame-602"><span class="linenos">602</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> -</span><span id="DataFrame-603"><a href="#DataFrame-603"><span class="linenos">603</span></a> <span class="k">def</span> <span class="nf">dropDuplicates</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">):</span> -</span><span id="DataFrame-604"><a href="#DataFrame-604"><span class="linenos">604</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">subset</span><span class="p">:</span> -</span><span id="DataFrame-605"><a href="#DataFrame-605"><span class="linenos">605</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">distinct</span><span class="p">()</span> -</span><span id="DataFrame-606"><a href="#DataFrame-606"><span class="linenos">606</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">subset</span><span class="p">)</span> -</span><span id="DataFrame-607"><a href="#DataFrame-607"><span class="linenos">607</span></a> <span class="n">window</span> <span class="o">=</span> <span class="n">Window</span><span class="o">.</span><span class="n">partitionBy</span><span class="p">(</span><span class="o">*</span><span class="n">column_names</span><span class="p">)</span><span class="o">.</span><span class="n">orderBy</span><span class="p">(</span><span class="o">*</span><span class="n">column_names</span><span class="p">)</span> -</span><span id="DataFrame-608"><a href="#DataFrame-608"><span class="linenos">608</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="DataFrame-609"><a href="#DataFrame-609"><span class="linenos">609</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame-610"><a href="#DataFrame-610"><span class="linenos">610</span></a> <span class="o">.</span><span class="n">withColumn</span><span class="p">(</span><span class="s2">"row_num"</span><span class="p">,</span> <span class="n">F</span><span class="o">.</span><span class="n">row_number</span><span class="p">()</span><span class="o">.</span><span class="n">over</span><span class="p">(</span><span class="n">window</span><span class="p">))</span> -</span><span id="DataFrame-611"><a href="#DataFrame-611"><span class="linenos">611</span></a> <span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">F</span><span class="o">.</span><span class="n">col</span><span class="p">(</span><span class="s2">"row_num"</span><span class="p">)</span> <span class="o">==</span> <span class="n">F</span><span class="o">.</span><span class="n">lit</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span> -</span><span id="DataFrame-612"><a href="#DataFrame-612"><span class="linenos">612</span></a> <span class="o">.</span><span class="n">drop</span><span class="p">(</span><span class="s2">"row_num"</span><span class="p">)</span> -</span><span id="DataFrame-613"><a href="#DataFrame-613"><span class="linenos">613</span></a> <span class="p">)</span> -</span><span id="DataFrame-614"><a href="#DataFrame-614"><span class="linenos">614</span></a> -</span><span id="DataFrame-615"><a href="#DataFrame-615"><span class="linenos">615</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> -</span><span id="DataFrame-616"><a href="#DataFrame-616"><span class="linenos">616</span></a> <span class="k">def</span> <span class="nf">dropna</span><span class="p">(</span> -</span><span id="DataFrame-617"><a href="#DataFrame-617"><span class="linenos">617</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DataFrame-618"><a href="#DataFrame-618"><span class="linenos">618</span></a> <span class="n">how</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"any"</span><span class="p">,</span> -</span><span id="DataFrame-619"><a href="#DataFrame-619"><span class="linenos">619</span></a> <span class="n">thresh</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrame-620"><a href="#DataFrame-620"><span class="linenos">620</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrame-621"><a href="#DataFrame-621"><span class="linenos">621</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-622"><a href="#DataFrame-622"><span class="linenos">622</span></a> <span class="n">minimum_non_null</span> <span class="o">=</span> <span class="n">thresh</span> <span class="ow">or</span> <span class="mi">0</span> <span class="c1"># will be determined later if thresh is null</span> -</span><span id="DataFrame-623"><a href="#DataFrame-623"><span class="linenos">623</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame-624"><a href="#DataFrame-624"><span class="linenos">624</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">new_df</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DataFrame-625"><a href="#DataFrame-625"><span class="linenos">625</span></a> <span class="k">if</span> <span class="n">subset</span><span class="p">:</span> -</span><span id="DataFrame-626"><a href="#DataFrame-626"><span class="linenos">626</span></a> <span class="n">null_check_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">subset</span><span class="p">)</span> -</span><span id="DataFrame-627"><a href="#DataFrame-627"><span class="linenos">627</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame-628"><a href="#DataFrame-628"><span class="linenos">628</span></a> <span class="n">null_check_columns</span> <span class="o">=</span> <span class="n">all_columns</span> -</span><span id="DataFrame-629"><a href="#DataFrame-629"><span class="linenos">629</span></a> <span class="k">if</span> <span class="n">thresh</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="DataFrame-630"><a href="#DataFrame-630"><span class="linenos">630</span></a> <span class="n">minimum_num_nulls</span> <span class="o">=</span> <span class="mi">1</span> <span class="k">if</span> <span class="n">how</span> <span class="o">==</span> <span class="s2">"any"</span> <span class="k">else</span> <span class="nb">len</span><span class="p">(</span><span class="n">null_check_columns</span><span class="p">)</span> -</span><span id="DataFrame-631"><a href="#DataFrame-631"><span class="linenos">631</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame-632"><a href="#DataFrame-632"><span class="linenos">632</span></a> <span class="n">minimum_num_nulls</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">null_check_columns</span><span class="p">)</span> <span class="o">-</span> <span class="n">minimum_non_null</span> <span class="o">+</span> <span class="mi">1</span> -</span><span id="DataFrame-633"><a href="#DataFrame-633"><span class="linenos">633</span></a> <span class="k">if</span> <span class="n">minimum_num_nulls</span> <span class="o">></span> <span class="nb">len</span><span class="p">(</span><span class="n">null_check_columns</span><span class="p">):</span> -</span><span id="DataFrame-634"><a href="#DataFrame-634"><span class="linenos">634</span></a> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span> -</span><span id="DataFrame-635"><a href="#DataFrame-635"><span class="linenos">635</span></a> <span class="sa">f</span><span class="s2">"The minimum num nulls for dropna must be less than or equal to the number of columns. "</span> -</span><span id="DataFrame-636"><a href="#DataFrame-636"><span class="linenos">636</span></a> <span class="sa">f</span><span class="s2">"Minimum num nulls: </span><span class="si">{</span><span class="n">minimum_num_nulls</span><span class="si">}</span><span class="s2">, Num Columns: </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">null_check_columns</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="DataFrame-637"><a href="#DataFrame-637"><span class="linenos">637</span></a> <span class="p">)</span> -</span><span id="DataFrame-638"><a href="#DataFrame-638"><span class="linenos">638</span></a> <span class="n">if_null_checks</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame-639"><a href="#DataFrame-639"><span class="linenos">639</span></a> <span class="n">F</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">isNull</span><span class="p">(),</span> <span class="n">F</span><span class="o">.</span><span class="n">lit</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span><span class="o">.</span><span class="n">otherwise</span><span class="p">(</span><span class="n">F</span><span class="o">.</span><span class="n">lit</span><span class="p">(</span><span class="mi">0</span><span class="p">))</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">null_check_columns</span> -</span><span id="DataFrame-640"><a href="#DataFrame-640"><span class="linenos">640</span></a> <span class="p">]</span> -</span><span id="DataFrame-641"><a href="#DataFrame-641"><span class="linenos">641</span></a> <span class="n">nulls_added_together</span> <span class="o">=</span> <span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">if_null_checks</span><span class="p">)</span> -</span><span id="DataFrame-642"><a href="#DataFrame-642"><span class="linenos">642</span></a> <span class="n">num_nulls</span> <span class="o">=</span> <span class="n">nulls_added_together</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span><span class="s2">"num_nulls"</span><span class="p">)</span> -</span><span id="DataFrame-643"><a href="#DataFrame-643"><span class="linenos">643</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="n">num_nulls</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="DataFrame-644"><a href="#DataFrame-644"><span class="linenos">644</span></a> <span class="n">filtered_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">F</span><span class="o">.</span><span class="n">col</span><span class="p">(</span><span class="s2">"num_nulls"</span><span class="p">)</span> <span class="o"><</span> <span class="n">F</span><span class="o">.</span><span class="n">lit</span><span class="p">(</span><span class="n">minimum_num_nulls</span><span class="p">))</span> -</span><span id="DataFrame-645"><a href="#DataFrame-645"><span class="linenos">645</span></a> <span class="n">final_df</span> <span class="o">=</span> <span class="n">filtered_df</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">all_columns</span><span class="p">)</span> -</span><span id="DataFrame-646"><a href="#DataFrame-646"><span class="linenos">646</span></a> <span class="k">return</span> <span class="n">final_df</span> -</span><span id="DataFrame-647"><a href="#DataFrame-647"><span class="linenos">647</span></a> -</span><span id="DataFrame-648"><a href="#DataFrame-648"><span class="linenos">648</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> -</span><span id="DataFrame-649"><a href="#DataFrame-649"><span class="linenos">649</span></a> <span class="k">def</span> <span class="nf">fillna</span><span class="p">(</span> -</span><span id="DataFrame-650"><a href="#DataFrame-650"><span class="linenos">650</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DataFrame-651"><a href="#DataFrame-651"><span class="linenos">651</span></a> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnLiterals</span><span class="p">],</span> -</span><span id="DataFrame-652"><a href="#DataFrame-652"><span class="linenos">652</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrame-653"><a href="#DataFrame-653"><span class="linenos">653</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-654"><a href="#DataFrame-654"><span class="linenos">654</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="DataFrame-655"><a href="#DataFrame-655"><span class="linenos">655</span></a><span class="sd"> Functionality Difference: If you provide a value to replace a null and that type conflicts</span> -</span><span id="DataFrame-656"><a href="#DataFrame-656"><span class="linenos">656</span></a><span class="sd"> with the type of the column then PySpark will just ignore your replacement.</span> -</span><span id="DataFrame-657"><a href="#DataFrame-657"><span class="linenos">657</span></a><span class="sd"> This will try to cast them to be the same in some cases. So they won't always match.</span> -</span><span id="DataFrame-658"><a href="#DataFrame-658"><span class="linenos">658</span></a><span class="sd"> Best to not mix types so make sure replacement is the same type as the column</span> -</span><span id="DataFrame-659"><a href="#DataFrame-659"><span class="linenos">659</span></a> -</span><span id="DataFrame-660"><a href="#DataFrame-660"><span class="linenos">660</span></a><span class="sd"> Possibility for improvement: Use `typeof` function to get the type of the column</span> -</span><span id="DataFrame-661"><a href="#DataFrame-661"><span class="linenos">661</span></a><span class="sd"> and check if it matches the type of the value provided. If not then make it null.</span> -</span><span id="DataFrame-662"><a href="#DataFrame-662"><span class="linenos">662</span></a><span class="sd"> """</span> -</span><span id="DataFrame-663"><a href="#DataFrame-663"><span class="linenos">663</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">lit</span> -</span><span id="DataFrame-664"><a href="#DataFrame-664"><span class="linenos">664</span></a> -</span><span id="DataFrame-665"><a href="#DataFrame-665"><span class="linenos">665</span></a> <span class="n">values</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="DataFrame-666"><a href="#DataFrame-666"><span class="linenos">666</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="DataFrame-667"><a href="#DataFrame-667"><span class="linenos">667</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame-668"><a href="#DataFrame-668"><span class="linenos">668</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">new_df</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DataFrame-669"><a href="#DataFrame-669"><span class="linenos">669</span></a> <span class="n">all_column_mapping</span> <span class="o">=</span> <span class="p">{</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="n">column</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">all_columns</span><span class="p">}</span> -</span><span id="DataFrame-670"><a href="#DataFrame-670"><span class="linenos">670</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span> -</span><span id="DataFrame-671"><a href="#DataFrame-671"><span class="linenos">671</span></a> <span class="n">values</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">value</span><span class="o">.</span><span class="n">values</span><span class="p">())</span> -</span><span id="DataFrame-672"><a href="#DataFrame-672"><span class="linenos">672</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">value</span><span class="p">))</span> -</span><span id="DataFrame-673"><a href="#DataFrame-673"><span class="linenos">673</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">columns</span><span class="p">:</span> -</span><span id="DataFrame-674"><a href="#DataFrame-674"><span class="linenos">674</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">subset</span><span class="p">)</span> <span class="k">if</span> <span class="n">subset</span> <span class="k">else</span> <span class="n">all_columns</span> -</span><span id="DataFrame-675"><a href="#DataFrame-675"><span class="linenos">675</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">values</span><span class="p">:</span> -</span><span id="DataFrame-676"><a href="#DataFrame-676"><span class="linenos">676</span></a> <span class="n">values</span> <span class="o">=</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> -</span><span id="DataFrame-677"><a href="#DataFrame-677"><span class="linenos">677</span></a> <span class="n">value_columns</span> <span class="o">=</span> <span class="p">[</span><span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">values</span><span class="p">]</span> -</span><span id="DataFrame-678"><a href="#DataFrame-678"><span class="linenos">678</span></a> -</span><span id="DataFrame-679"><a href="#DataFrame-679"><span class="linenos">679</span></a> <span class="n">null_replacement_mapping</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DataFrame-680"><a href="#DataFrame-680"><span class="linenos">680</span></a> <span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="p">(</span> -</span><span id="DataFrame-681"><a href="#DataFrame-681"><span class="linenos">681</span></a> <span class="n">F</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">isNull</span><span class="p">(),</span> <span class="n">value</span><span class="p">)</span><span class="o">.</span><span class="n">otherwise</span><span class="p">(</span><span class="n">column</span><span class="p">)</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">)</span> -</span><span id="DataFrame-682"><a href="#DataFrame-682"><span class="linenos">682</span></a> <span class="p">)</span> -</span><span id="DataFrame-683"><a href="#DataFrame-683"><span class="linenos">683</span></a> <span class="k">for</span> <span class="n">column</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">columns</span><span class="p">,</span> <span class="n">value_columns</span><span class="p">)</span> -</span><span id="DataFrame-684"><a href="#DataFrame-684"><span class="linenos">684</span></a> <span class="p">}</span> -</span><span id="DataFrame-685"><a href="#DataFrame-685"><span class="linenos">685</span></a> <span class="n">null_replacement_mapping</span> <span class="o">=</span> <span class="p">{</span><span class="o">**</span><span class="n">all_column_mapping</span><span class="p">,</span> <span class="o">**</span><span class="n">null_replacement_mapping</span><span class="p">}</span> -</span><span id="DataFrame-686"><a href="#DataFrame-686"><span class="linenos">686</span></a> <span class="n">null_replacement_columns</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame-687"><a href="#DataFrame-687"><span class="linenos">687</span></a> <span class="n">null_replacement_mapping</span><span class="p">[</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">all_columns</span> -</span><span id="DataFrame-688"><a href="#DataFrame-688"><span class="linenos">688</span></a> <span class="p">]</span> -</span><span id="DataFrame-689"><a href="#DataFrame-689"><span class="linenos">689</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">null_replacement_columns</span><span class="p">)</span> -</span><span id="DataFrame-690"><a href="#DataFrame-690"><span class="linenos">690</span></a> <span class="k">return</span> <span class="n">new_df</span> -</span><span id="DataFrame-691"><a href="#DataFrame-691"><span class="linenos">691</span></a> -</span><span id="DataFrame-692"><a href="#DataFrame-692"><span class="linenos">692</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> -</span><span id="DataFrame-693"><a href="#DataFrame-693"><span class="linenos">693</span></a> <span class="k">def</span> <span class="nf">replace</span><span class="p">(</span> -</span><span id="DataFrame-694"><a href="#DataFrame-694"><span class="linenos">694</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DataFrame-695"><a href="#DataFrame-695"><span class="linenos">695</span></a> <span class="n">to_replace</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</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">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">],</span> -</span><span id="DataFrame-696"><a href="#DataFrame-696"><span class="linenos">696</span></a> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrame-697"><a href="#DataFrame-697"><span class="linenos">697</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">ColumnOrName</span><span class="p">]</span> <span class="o">|</span> <span class="n">ColumnOrName</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrame-698"><a href="#DataFrame-698"><span class="linenos">698</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-699"><a href="#DataFrame-699"><span class="linenos">699</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">lit</span> -</span><span id="DataFrame-700"><a href="#DataFrame-700"><span class="linenos">700</span></a> -</span><span id="DataFrame-701"><a href="#DataFrame-701"><span class="linenos">701</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="DataFrame-702"><a href="#DataFrame-702"><span class="linenos">702</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame-703"><a href="#DataFrame-703"><span class="linenos">703</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">new_df</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DataFrame-704"><a href="#DataFrame-704"><span class="linenos">704</span></a> <span class="n">all_column_mapping</span> <span class="o">=</span> <span class="p">{</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="n">column</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">all_columns</span><span class="p">}</span> -</span><span id="DataFrame-705"><a href="#DataFrame-705"><span class="linenos">705</span></a> -</span><span id="DataFrame-706"><a href="#DataFrame-706"><span class="linenos">706</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">subset</span><span class="p">)</span> <span class="k">if</span> <span class="n">subset</span> <span class="k">else</span> <span class="n">all_columns</span> -</span><span id="DataFrame-707"><a href="#DataFrame-707"><span class="linenos">707</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">to_replace</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span> -</span><span id="DataFrame-708"><a href="#DataFrame-708"><span class="linenos">708</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">to_replace</span><span class="p">)</span> -</span><span id="DataFrame-709"><a href="#DataFrame-709"><span class="linenos">709</span></a> <span class="n">new_values</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">to_replace</span><span class="o">.</span><span class="n">values</span><span class="p">())</span> -</span><span id="DataFrame-710"><a href="#DataFrame-710"><span class="linenos">710</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">old_values</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">to_replace</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="DataFrame-711"><a href="#DataFrame-711"><span class="linenos">711</span></a> <span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">list</span><span class="p">),</span> <span class="s2">"value must be a list since the replacements are a list"</span> -</span><span id="DataFrame-712"><a href="#DataFrame-712"><span class="linenos">712</span></a> <span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">to_replace</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span> -</span><span id="DataFrame-713"><a href="#DataFrame-713"><span class="linenos">713</span></a> <span class="n">value</span> -</span><span id="DataFrame-714"><a href="#DataFrame-714"><span class="linenos">714</span></a> <span class="p">),</span> <span class="s2">"the replacements and values must be the same length"</span> -</span><span id="DataFrame-715"><a href="#DataFrame-715"><span class="linenos">715</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="n">to_replace</span> -</span><span id="DataFrame-716"><a href="#DataFrame-716"><span class="linenos">716</span></a> <span class="n">new_values</span> <span class="o">=</span> <span class="n">value</span> -</span><span id="DataFrame-717"><a href="#DataFrame-717"><span class="linenos">717</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame-718"><a href="#DataFrame-718"><span class="linenos">718</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="p">[</span><span class="n">to_replace</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> -</span><span id="DataFrame-719"><a href="#DataFrame-719"><span class="linenos">719</span></a> <span class="n">new_values</span> <span class="o">=</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> -</span><span id="DataFrame-720"><a href="#DataFrame-720"><span class="linenos">720</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="p">[</span><span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">old_values</span><span class="p">]</span> -</span><span id="DataFrame-721"><a href="#DataFrame-721"><span class="linenos">721</span></a> <span class="n">new_values</span> <span class="o">=</span> <span class="p">[</span><span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">new_values</span><span class="p">]</span> -</span><span id="DataFrame-722"><a href="#DataFrame-722"><span class="linenos">722</span></a> -</span><span id="DataFrame-723"><a href="#DataFrame-723"><span class="linenos">723</span></a> <span class="n">replacement_mapping</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="DataFrame-724"><a href="#DataFrame-724"><span class="linenos">724</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">columns</span><span class="p">:</span> -</span><span id="DataFrame-725"><a href="#DataFrame-725"><span class="linenos">725</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">Column</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span> -</span><span id="DataFrame-726"><a href="#DataFrame-726"><span class="linenos">726</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="p">(</span><span class="n">old_value</span><span class="p">,</span> <span class="n">new_value</span><span class="p">)</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">old_values</span><span class="p">,</span> <span class="n">new_values</span><span class="p">)):</span> -</span><span id="DataFrame-727"><a href="#DataFrame-727"><span class="linenos">727</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> -</span><span id="DataFrame-728"><a href="#DataFrame-728"><span class="linenos">728</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">F</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">column</span> <span class="o">==</span> <span class="n">old_value</span><span class="p">,</span> <span class="n">new_value</span><span class="p">)</span> -</span><span id="DataFrame-729"><a href="#DataFrame-729"><span class="linenos">729</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame-730"><a href="#DataFrame-730"><span class="linenos">730</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">column</span> <span class="o">==</span> <span class="n">old_value</span><span class="p">,</span> <span class="n">new_value</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="DataFrame-731"><a href="#DataFrame-731"><span class="linenos">731</span></a> <span class="n">replacement_mapping</span><span class="p">[</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">otherwise</span><span class="p">(</span><span class="n">column</span><span class="p">)</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span> -</span><span id="DataFrame-732"><a href="#DataFrame-732"><span class="linenos">732</span></a> <span class="n">column</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">alias_or_name</span> -</span><span id="DataFrame-733"><a href="#DataFrame-733"><span class="linenos">733</span></a> <span class="p">)</span> -</span><span id="DataFrame-734"><a href="#DataFrame-734"><span class="linenos">734</span></a> -</span><span id="DataFrame-735"><a href="#DataFrame-735"><span class="linenos">735</span></a> <span class="n">replacement_mapping</span> <span class="o">=</span> <span class="p">{</span><span class="o">**</span><span class="n">all_column_mapping</span><span class="p">,</span> <span class="o">**</span><span class="n">replacement_mapping</span><span class="p">}</span> -</span><span id="DataFrame-736"><a href="#DataFrame-736"><span class="linenos">736</span></a> <span class="n">replacement_columns</span> <span class="o">=</span> <span class="p">[</span><span class="n">replacement_mapping</span><span class="p">[</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">all_columns</span><span class="p">]</span> -</span><span id="DataFrame-737"><a href="#DataFrame-737"><span class="linenos">737</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">replacement_columns</span><span class="p">)</span> -</span><span id="DataFrame-738"><a href="#DataFrame-738"><span class="linenos">738</span></a> <span class="k">return</span> <span class="n">new_df</span> -</span><span id="DataFrame-739"><a href="#DataFrame-739"><span class="linenos">739</span></a> -</span><span id="DataFrame-740"><a href="#DataFrame-740"><span class="linenos">740</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> -</span><span id="DataFrame-741"><a href="#DataFrame-741"><span class="linenos">741</span></a> <span class="k">def</span> <span class="nf">withColumn</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">colName</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">col</span><span class="p">:</span> <span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-742"><a href="#DataFrame-742"><span class="linenos">742</span></a> <span class="n">col</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_col</span><span class="p">(</span><span class="n">col</span><span class="p">)</span> -</span><span id="DataFrame-743"><a href="#DataFrame-743"><span class="linenos">743</span></a> <span class="n">existing_col_names</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">named_selects</span> -</span><span id="DataFrame-744"><a href="#DataFrame-744"><span class="linenos">744</span></a> <span class="n">existing_col_index</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="DataFrame-745"><a href="#DataFrame-745"><span class="linenos">745</span></a> <span class="n">existing_col_names</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">colName</span><span class="p">)</span> <span class="k">if</span> <span class="n">colName</span> <span class="ow">in</span> <span class="n">existing_col_names</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="DataFrame-746"><a href="#DataFrame-746"><span class="linenos">746</span></a> <span class="p">)</span> -</span><span id="DataFrame-747"><a href="#DataFrame-747"><span class="linenos">747</span></a> <span class="k">if</span> <span class="n">existing_col_index</span><span class="p">:</span> -</span><span id="DataFrame-748"><a href="#DataFrame-748"><span class="linenos">748</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame-749"><a href="#DataFrame-749"><span class="linenos">749</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="n">existing_col_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">col</span><span class="o">.</span><span class="n">expression</span> -</span><span id="DataFrame-750"><a href="#DataFrame-750"><span class="linenos">750</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DataFrame-751"><a href="#DataFrame-751"><span class="linenos">751</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="n">col</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span><span class="n">colName</span><span class="p">),</span> <span class="n">append</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="DataFrame-752"><a href="#DataFrame-752"><span class="linenos">752</span></a> -</span><span id="DataFrame-753"><a href="#DataFrame-753"><span class="linenos">753</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> -</span><span id="DataFrame-754"><a href="#DataFrame-754"><span class="linenos">754</span></a> <span class="k">def</span> <span class="nf">withColumnRenamed</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">existing</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">new</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="DataFrame-755"><a href="#DataFrame-755"><span class="linenos">755</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame-756"><a href="#DataFrame-756"><span class="linenos">756</span></a> <span class="n">existing_columns</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame-757"><a href="#DataFrame-757"><span class="linenos">757</span></a> <span class="n">expression</span> -</span><span id="DataFrame-758"><a href="#DataFrame-758"><span class="linenos">758</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="DataFrame-759"><a href="#DataFrame-759"><span class="linenos">759</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="o">==</span> <span class="n">existing</span> -</span><span id="DataFrame-760"><a href="#DataFrame-760"><span class="linenos">760</span></a> <span class="p">]</span> -</span><span id="DataFrame-761"><a href="#DataFrame-761"><span class="linenos">761</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">existing_columns</span><span class="p">:</span> -</span><span id="DataFrame-762"><a href="#DataFrame-762"><span class="linenos">762</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Tried to rename a column that doesn't exist"</span><span class="p">)</span> -</span><span id="DataFrame-763"><a href="#DataFrame-763"><span class="linenos">763</span></a> <span class="k">for</span> <span class="n">existing_column</span> <span class="ow">in</span> <span class="n">existing_columns</span><span class="p">:</span> -</span><span id="DataFrame-764"><a href="#DataFrame-764"><span class="linenos">764</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">existing_column</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> -</span><span id="DataFrame-765"><a href="#DataFrame-765"><span class="linenos">765</span></a> <span class="n">existing_column</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">alias_</span><span class="p">(</span><span class="n">existing_column</span><span class="p">,</span> <span class="n">new</span><span class="p">))</span> -</span><span id="DataFrame-766"><a href="#DataFrame-766"><span class="linenos">766</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame-767"><a href="#DataFrame-767"><span class="linenos">767</span></a> <span class="n">existing_column</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">new</span><span class="p">))</span> -</span><span id="DataFrame-768"><a href="#DataFrame-768"><span class="linenos">768</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DataFrame-769"><a href="#DataFrame-769"><span class="linenos">769</span></a> -</span><span id="DataFrame-770"><a href="#DataFrame-770"><span class="linenos">770</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> -</span><span id="DataFrame-771"><a href="#DataFrame-771"><span class="linenos">771</span></a> <span class="k">def</span> <span class="nf">drop</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Column</span><span class="p">])</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-772"><a href="#DataFrame-772"><span class="linenos">772</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DataFrame-773"><a href="#DataFrame-773"><span class="linenos">773</span></a> <span class="n">drop_cols</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> -</span><span id="DataFrame-774"><a href="#DataFrame-774"><span class="linenos">774</span></a> <span class="n">new_columns</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame-775"><a href="#DataFrame-775"><span class="linenos">775</span></a> <span class="n">col</span> -</span><span id="DataFrame-776"><a href="#DataFrame-776"><span class="linenos">776</span></a> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">all_columns</span> -</span><span id="DataFrame-777"><a href="#DataFrame-777"><span class="linenos">777</span></a> <span class="k">if</span> <span class="n">col</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="n">drop_column</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="k">for</span> <span class="n">drop_column</span> <span class="ow">in</span> <span class="n">drop_cols</span><span class="p">]</span> -</span><span id="DataFrame-778"><a href="#DataFrame-778"><span class="linenos">778</span></a> <span class="p">]</span> -</span><span id="DataFrame-779"><a href="#DataFrame-779"><span class="linenos">779</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">new_columns</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="DataFrame-780"><a href="#DataFrame-780"><span class="linenos">780</span></a> -</span><span id="DataFrame-781"><a href="#DataFrame-781"><span class="linenos">781</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">LIMIT</span><span class="p">)</span> -</span><span id="DataFrame-782"><a href="#DataFrame-782"><span class="linenos">782</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">num</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-783"><a href="#DataFrame-783"><span class="linenos">783</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">limit</span><span class="p">(</span><span class="n">num</span><span class="p">))</span> -</span><span id="DataFrame-784"><a href="#DataFrame-784"><span class="linenos">784</span></a> -</span><span id="DataFrame-785"><a href="#DataFrame-785"><span class="linenos">785</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> -</span><span id="DataFrame-786"><a href="#DataFrame-786"><span class="linenos">786</span></a> <span class="k">def</span> <span class="nf">hint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">*</span><span class="n">parameters</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">int</span><span class="p">]])</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-787"><a href="#DataFrame-787"><span class="linenos">787</span></a> <span class="n">parameter_list</span> <span class="o">=</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">parameters</span><span class="p">)</span> -</span><span id="DataFrame-788"><a href="#DataFrame-788"><span class="linenos">788</span></a> <span class="n">parameter_columns</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="DataFrame-789"><a href="#DataFrame-789"><span class="linenos">789</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">parameter_list</span><span class="p">)</span> -</span><span id="DataFrame-790"><a href="#DataFrame-790"><span class="linenos">790</span></a> <span class="k">if</span> <span class="n">parameters</span> -</span><span id="DataFrame-791"><a href="#DataFrame-791"><span class="linenos">791</span></a> <span class="k">else</span> <span class="n">Column</span><span class="o">.</span><span class="n">ensure_cols</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">sequence_id</span><span class="p">])</span> -</span><span id="DataFrame-792"><a href="#DataFrame-792"><span class="linenos">792</span></a> <span class="p">)</span> -</span><span id="DataFrame-793"><a href="#DataFrame-793"><span class="linenos">793</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hint</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">parameter_columns</span><span class="p">)</span> -</span><span id="DataFrame-794"><a href="#DataFrame-794"><span class="linenos">794</span></a> -</span><span id="DataFrame-795"><a href="#DataFrame-795"><span class="linenos">795</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> -</span><span id="DataFrame-796"><a href="#DataFrame-796"><span class="linenos">796</span></a> <span class="k">def</span> <span class="nf">repartition</span><span class="p">(</span> -</span><span id="DataFrame-797"><a href="#DataFrame-797"><span class="linenos">797</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">numPartitions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="n">ColumnOrName</span><span class="p">],</span> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">ColumnOrName</span> -</span><span id="DataFrame-798"><a href="#DataFrame-798"><span class="linenos">798</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-799"><a href="#DataFrame-799"><span class="linenos">799</span></a> <span class="n">num_partition_cols</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">numPartitions</span><span class="p">)</span> -</span><span id="DataFrame-800"><a href="#DataFrame-800"><span class="linenos">800</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> -</span><span id="DataFrame-801"><a href="#DataFrame-801"><span class="linenos">801</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">num_partition_cols</span> <span class="o">+</span> <span class="n">columns</span> -</span><span id="DataFrame-802"><a href="#DataFrame-802"><span class="linenos">802</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hint</span><span class="p">(</span><span class="s2">"repartition"</span><span class="p">,</span> <span class="n">args</span><span class="p">)</span> -</span><span id="DataFrame-803"><a href="#DataFrame-803"><span class="linenos">803</span></a> -</span><span id="DataFrame-804"><a href="#DataFrame-804"><span class="linenos">804</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> -</span><span id="DataFrame-805"><a href="#DataFrame-805"><span class="linenos">805</span></a> <span class="k">def</span> <span class="nf">coalesce</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">numPartitions</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-806"><a href="#DataFrame-806"><span class="linenos">806</span></a> <span class="n">num_partitions</span> <span class="o">=</span> <span class="n">Column</span><span class="o">.</span><span class="n">ensure_cols</span><span class="p">([</span><span class="n">numPartitions</span><span class="p">])</span> -</span><span id="DataFrame-807"><a href="#DataFrame-807"><span class="linenos">807</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hint</span><span class="p">(</span><span class="s2">"coalesce"</span><span class="p">,</span> <span class="n">num_partitions</span><span class="p">)</span> -</span><span id="DataFrame-808"><a href="#DataFrame-808"><span class="linenos">808</span></a> -</span><span id="DataFrame-809"><a href="#DataFrame-809"><span class="linenos">809</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> -</span><span id="DataFrame-810"><a href="#DataFrame-810"><span class="linenos">810</span></a> <span class="k">def</span> <span class="nf">cache</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-811"><a href="#DataFrame-811"><span class="linenos">811</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">(</span><span class="n">storage_level</span><span class="o">=</span><span class="s2">"MEMORY_AND_DISK"</span><span class="p">)</span> -</span><span id="DataFrame-812"><a href="#DataFrame-812"><span class="linenos">812</span></a> -</span><span id="DataFrame-813"><a href="#DataFrame-813"><span class="linenos">813</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> -</span><span id="DataFrame-814"><a href="#DataFrame-814"><span class="linenos">814</span></a> <span class="k">def</span> <span class="nf">persist</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">storageLevel</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"MEMORY_AND_DISK_SER"</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame-815"><a href="#DataFrame-815"><span class="linenos">815</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="DataFrame-816"><a href="#DataFrame-816"><span class="linenos">816</span></a><span class="sd"> Storage Level Options: https://spark.apache.org/docs/3.0.0-preview/sql-ref-syntax-aux-cache-cache-table.html</span> -</span><span id="DataFrame-817"><a href="#DataFrame-817"><span class="linenos">817</span></a><span class="sd"> """</span> -</span><span id="DataFrame-818"><a href="#DataFrame-818"><span class="linenos">818</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">(</span><span class="n">storageLevel</span><span class="p">)</span> +</span><span id="DataFrame-320"><a href="#DataFrame-320"><span class="linenos">320</span></a> <span class="n">dialect</span><span class="o">=</span><span class="s2">"spark"</span><span class="p">,</span> +</span><span id="DataFrame-321"><a href="#DataFrame-321"><span class="linenos">321</span></a> <span class="p">)</span> +</span><span id="DataFrame-322"><a href="#DataFrame-322"><span class="linenos">322</span></a> <span class="n">cache_storage_level</span> <span class="o">=</span> <span class="n">select_expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"cache_storage_level"</span><span class="p">]</span> +</span><span id="DataFrame-323"><a href="#DataFrame-323"><span class="linenos">323</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame-324"><a href="#DataFrame-324"><span class="linenos">324</span></a> <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">"storageLevel"</span><span class="p">),</span> +</span><span id="DataFrame-325"><a href="#DataFrame-325"><span class="linenos">325</span></a> <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">cache_storage_level</span><span class="p">),</span> +</span><span id="DataFrame-326"><a href="#DataFrame-326"><span class="linenos">326</span></a> <span class="p">]</span> +</span><span id="DataFrame-327"><a href="#DataFrame-327"><span class="linenos">327</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">(</span> +</span><span id="DataFrame-328"><a href="#DataFrame-328"><span class="linenos">328</span></a> <span class="n">this</span><span class="o">=</span><span class="n">cache_table</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">select_expression</span><span class="p">,</span> <span class="n">lazy</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="n">options</span> +</span><span id="DataFrame-329"><a href="#DataFrame-329"><span class="linenos">329</span></a> <span class="p">)</span> +</span><span id="DataFrame-330"><a href="#DataFrame-330"><span class="linenos">330</span></a> <span class="c1"># We will drop the "view" if it exists before running the cache table</span> +</span><span id="DataFrame-331"><a href="#DataFrame-331"><span class="linenos">331</span></a> <span class="n">output_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">cache_table</span><span class="p">,</span> <span class="n">exists</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="s2">"VIEW"</span><span class="p">))</span> +</span><span id="DataFrame-332"><a href="#DataFrame-332"><span class="linenos">332</span></a> <span class="k">elif</span> <span class="n">expression_type</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> +</span><span id="DataFrame-333"><a href="#DataFrame-333"><span class="linenos">333</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">output_expression_container</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame-334"><a href="#DataFrame-334"><span class="linenos">334</span></a> <span class="n">expression</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">select_expression</span><span class="p">)</span> +</span><span id="DataFrame-335"><a href="#DataFrame-335"><span class="linenos">335</span></a> <span class="k">elif</span> <span class="n">expression_type</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">:</span> +</span><span id="DataFrame-336"><a href="#DataFrame-336"><span class="linenos">336</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">output_expression_container</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame-337"><a href="#DataFrame-337"><span class="linenos">337</span></a> <span class="n">select_without_ctes</span> <span class="o">=</span> <span class="n">select_expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame-338"><a href="#DataFrame-338"><span class="linenos">338</span></a> <span class="n">select_without_ctes</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"with"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="DataFrame-339"><a href="#DataFrame-339"><span class="linenos">339</span></a> <span class="n">expression</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">select_without_ctes</span><span class="p">)</span> +</span><span id="DataFrame-340"><a href="#DataFrame-340"><span class="linenos">340</span></a> <span class="k">if</span> <span class="n">select_expression</span><span class="o">.</span><span class="n">ctes</span><span class="p">:</span> +</span><span id="DataFrame-341"><a href="#DataFrame-341"><span class="linenos">341</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"with"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">select_expression</span><span class="o">.</span><span class="n">ctes</span><span class="p">))</span> +</span><span id="DataFrame-342"><a href="#DataFrame-342"><span class="linenos">342</span></a> <span class="k">elif</span> <span class="n">expression_type</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> +</span><span id="DataFrame-343"><a href="#DataFrame-343"><span class="linenos">343</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">select_expression</span> +</span><span id="DataFrame-344"><a href="#DataFrame-344"><span class="linenos">344</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame-345"><a href="#DataFrame-345"><span class="linenos">345</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid expression type: </span><span class="si">{</span><span class="n">expression_type</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="DataFrame-346"><a href="#DataFrame-346"><span class="linenos">346</span></a> <span class="n">output_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DataFrame-347"><a href="#DataFrame-347"><span class="linenos">347</span></a> +</span><span id="DataFrame-348"><a href="#DataFrame-348"><span class="linenos">348</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="DataFrame-349"><a href="#DataFrame-349"><span class="linenos">349</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="s2">"dialect"</span><span class="p">:</span> <span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">})</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">output_expressions</span> +</span><span id="DataFrame-350"><a href="#DataFrame-350"><span class="linenos">350</span></a> <span class="p">]</span> +</span><span id="DataFrame-351"><a href="#DataFrame-351"><span class="linenos">351</span></a> +</span><span id="DataFrame-352"><a href="#DataFrame-352"><span class="linenos">352</span></a> <span class="k">def</span> <span class="nf">copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-353"><a href="#DataFrame-353"><span class="linenos">353</span></a> <span class="k">return</span> <span class="n">DataFrame</span><span class="p">(</span><span class="o">**</span><span class="n">object_to_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">))</span> +</span><span id="DataFrame-354"><a href="#DataFrame-354"><span class="linenos">354</span></a> +</span><span id="DataFrame-355"><a href="#DataFrame-355"><span class="linenos">355</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> +</span><span id="DataFrame-356"><a href="#DataFrame-356"><span class="linenos">356</span></a> <span class="k">def</span> <span class="nf">select</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">cols</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-357"><a href="#DataFrame-357"><span class="linenos">357</span></a> <span class="n">cols</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> +</span><span id="DataFrame-358"><a href="#DataFrame-358"><span class="linenos">358</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"append"</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"append"</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> +</span><span id="DataFrame-359"><a href="#DataFrame-359"><span class="linenos">359</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">):</span> +</span><span id="DataFrame-360"><a href="#DataFrame-360"><span class="linenos">360</span></a> <span class="n">ambiguous_cols</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame-361"><a href="#DataFrame-361"><span class="linenos">361</span></a> <span class="n">col</span> +</span><span id="DataFrame-362"><a href="#DataFrame-362"><span class="linenos">362</span></a> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">cols</span> +</span><span id="DataFrame-363"><a href="#DataFrame-363"><span class="linenos">363</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">col</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">col</span><span class="o">.</span><span class="n">column_expression</span><span class="o">.</span><span class="n">table</span> +</span><span id="DataFrame-364"><a href="#DataFrame-364"><span class="linenos">364</span></a> <span class="p">]</span> +</span><span id="DataFrame-365"><a href="#DataFrame-365"><span class="linenos">365</span></a> <span class="k">if</span> <span class="n">ambiguous_cols</span><span class="p">:</span> +</span><span id="DataFrame-366"><a href="#DataFrame-366"><span class="linenos">366</span></a> <span class="n">join_table_identifiers</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame-367"><a href="#DataFrame-367"><span class="linenos">367</span></a> <span class="n">x</span><span class="o">.</span><span class="n">this</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">get_tables_from_expression_with_join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DataFrame-368"><a href="#DataFrame-368"><span class="linenos">368</span></a> <span class="p">]</span> +</span><span id="DataFrame-369"><a href="#DataFrame-369"><span class="linenos">369</span></a> <span class="n">cte_names_in_join</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">this</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">join_table_identifiers</span><span class="p">]</span> +</span><span id="DataFrame-370"><a href="#DataFrame-370"><span class="linenos">370</span></a> <span class="c1"># If we have columns that resolve to multiple CTE expressions then we want to use each CTE left-to-right</span> +</span><span id="DataFrame-371"><a href="#DataFrame-371"><span class="linenos">371</span></a> <span class="c1"># and therefore we allow multiple columns with the same name in the result. This matches the behavior</span> +</span><span id="DataFrame-372"><a href="#DataFrame-372"><span class="linenos">372</span></a> <span class="c1"># of Spark.</span> +</span><span id="DataFrame-373"><a href="#DataFrame-373"><span class="linenos">373</span></a> <span class="n">resolved_column_position</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">Column</span><span class="p">,</span> <span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="n">col</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">ambiguous_cols</span><span class="p">}</span> +</span><span id="DataFrame-374"><a href="#DataFrame-374"><span class="linenos">374</span></a> <span class="k">for</span> <span class="n">ambiguous_col</span> <span class="ow">in</span> <span class="n">ambiguous_cols</span><span class="p">:</span> +</span><span id="DataFrame-375"><a href="#DataFrame-375"><span class="linenos">375</span></a> <span class="n">ctes_with_column</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame-376"><a href="#DataFrame-376"><span class="linenos">376</span></a> <span class="n">cte</span> +</span><span id="DataFrame-377"><a href="#DataFrame-377"><span class="linenos">377</span></a> <span class="k">for</span> <span class="n">cte</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">ctes</span> +</span><span id="DataFrame-378"><a href="#DataFrame-378"><span class="linenos">378</span></a> <span class="k">if</span> <span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">in</span> <span class="n">cte_names_in_join</span> +</span><span id="DataFrame-379"><a href="#DataFrame-379"><span class="linenos">379</span></a> <span class="ow">and</span> <span class="n">ambiguous_col</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">in</span> <span class="n">cte</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">named_selects</span> +</span><span id="DataFrame-380"><a href="#DataFrame-380"><span class="linenos">380</span></a> <span class="p">]</span> +</span><span id="DataFrame-381"><a href="#DataFrame-381"><span class="linenos">381</span></a> <span class="c1"># Check if there is a CTE with this column that we haven't used before. If so, use it. Otherwise,</span> +</span><span id="DataFrame-382"><a href="#DataFrame-382"><span class="linenos">382</span></a> <span class="c1"># use the same CTE we used before</span> +</span><span id="DataFrame-383"><a href="#DataFrame-383"><span class="linenos">383</span></a> <span class="n">cte</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">ctes_with_column</span><span class="p">,</span> <span class="n">resolved_column_position</span><span class="p">[</span><span class="n">ambiguous_col</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="DataFrame-384"><a href="#DataFrame-384"><span class="linenos">384</span></a> <span class="k">if</span> <span class="n">cte</span><span class="p">:</span> +</span><span id="DataFrame-385"><a href="#DataFrame-385"><span class="linenos">385</span></a> <span class="n">resolved_column_position</span><span class="p">[</span><span class="n">ambiguous_col</span><span class="p">]</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="DataFrame-386"><a href="#DataFrame-386"><span class="linenos">386</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame-387"><a href="#DataFrame-387"><span class="linenos">387</span></a> <span class="n">cte</span> <span class="o">=</span> <span class="n">ctes_with_column</span><span class="p">[</span><span class="n">resolved_column_position</span><span class="p">[</span><span class="n">ambiguous_col</span><span class="p">]]</span> +</span><span id="DataFrame-388"><a href="#DataFrame-388"><span class="linenos">388</span></a> <span class="n">ambiguous_col</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"table"</span><span class="p">,</span> <span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">)</span> +</span><span id="DataFrame-389"><a href="#DataFrame-389"><span class="linenos">389</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span> +</span><span id="DataFrame-390"><a href="#DataFrame-390"><span class="linenos">390</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">expression</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">cols</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span> +</span><span id="DataFrame-391"><a href="#DataFrame-391"><span class="linenos">391</span></a> <span class="p">)</span> +</span><span id="DataFrame-392"><a href="#DataFrame-392"><span class="linenos">392</span></a> +</span><span id="DataFrame-393"><a href="#DataFrame-393"><span class="linenos">393</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> +</span><span id="DataFrame-394"><a href="#DataFrame-394"><span class="linenos">394</span></a> <span class="k">def</span> <span class="nf">alias</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-395"><a href="#DataFrame-395"><span class="linenos">395</span></a> <span class="n">new_sequence_id</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">spark</span><span class="o">.</span><span class="n">_random_sequence_id</span> +</span><span id="DataFrame-396"><a href="#DataFrame-396"><span class="linenos">396</span></a> <span class="n">df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame-397"><a href="#DataFrame-397"><span class="linenos">397</span></a> <span class="k">for</span> <span class="n">join_hint</span> <span class="ow">in</span> <span class="n">df</span><span class="o">.</span><span class="n">pending_join_hints</span><span class="p">:</span> +</span><span id="DataFrame-398"><a href="#DataFrame-398"><span class="linenos">398</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">join_hint</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="DataFrame-399"><a href="#DataFrame-399"><span class="linenos">399</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">sequence_id</span><span class="p">:</span> +</span><span id="DataFrame-400"><a href="#DataFrame-400"><span class="linenos">400</span></a> <span class="n">expression</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">Column</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">new_sequence_id</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DataFrame-401"><a href="#DataFrame-401"><span class="linenos">401</span></a> <span class="n">df</span><span class="o">.</span><span class="n">spark</span><span class="o">.</span><span class="n">_add_alias_to_mapping</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">new_sequence_id</span><span class="p">)</span> +</span><span id="DataFrame-402"><a href="#DataFrame-402"><span class="linenos">402</span></a> <span class="k">return</span> <span class="n">df</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">(</span><span class="n">sequence_id</span><span class="o">=</span><span class="n">new_sequence_id</span><span class="p">)</span> +</span><span id="DataFrame-403"><a href="#DataFrame-403"><span class="linenos">403</span></a> +</span><span id="DataFrame-404"><a href="#DataFrame-404"><span class="linenos">404</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">WHERE</span><span class="p">)</span> +</span><span id="DataFrame-405"><a href="#DataFrame-405"><span class="linenos">405</span></a> <span class="k">def</span> <span class="nf">where</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">column</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">Column</span><span class="p">,</span> <span class="nb">bool</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-406"><a href="#DataFrame-406"><span class="linenos">406</span></a> <span class="n">col</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_col</span><span class="p">(</span><span class="n">column</span><span class="p">)</span> +</span><span id="DataFrame-407"><a href="#DataFrame-407"><span class="linenos">407</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">col</span><span class="o">.</span><span class="n">expression</span><span class="p">))</span> +</span><span id="DataFrame-408"><a href="#DataFrame-408"><span class="linenos">408</span></a> +</span><span id="DataFrame-409"><a href="#DataFrame-409"><span class="linenos">409</span></a> <span class="nb">filter</span> <span class="o">=</span> <span class="n">where</span> +</span><span id="DataFrame-410"><a href="#DataFrame-410"><span class="linenos">410</span></a> +</span><span id="DataFrame-411"><a href="#DataFrame-411"><span class="linenos">411</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">GROUP_BY</span><span class="p">)</span> +</span><span id="DataFrame-412"><a href="#DataFrame-412"><span class="linenos">412</span></a> <span class="k">def</span> <span class="nf">groupBy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">cols</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">GroupedData</span><span class="p">:</span> +</span><span id="DataFrame-413"><a href="#DataFrame-413"><span class="linenos">413</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> +</span><span id="DataFrame-414"><a href="#DataFrame-414"><span class="linenos">414</span></a> <span class="k">return</span> <span class="n">GroupedData</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">columns</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">last_op</span><span class="p">)</span> +</span><span id="DataFrame-415"><a href="#DataFrame-415"><span class="linenos">415</span></a> +</span><span id="DataFrame-416"><a href="#DataFrame-416"><span class="linenos">416</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> +</span><span id="DataFrame-417"><a href="#DataFrame-417"><span class="linenos">417</span></a> <span class="k">def</span> <span class="nf">agg</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">exprs</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-418"><a href="#DataFrame-418"><span class="linenos">418</span></a> <span class="n">cols</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">exprs</span><span class="p">)</span> +</span><span id="DataFrame-419"><a href="#DataFrame-419"><span class="linenos">419</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">groupBy</span><span class="p">()</span><span class="o">.</span><span class="n">agg</span><span class="p">(</span><span class="o">*</span><span class="n">cols</span><span class="p">)</span> +</span><span id="DataFrame-420"><a href="#DataFrame-420"><span class="linenos">420</span></a> +</span><span id="DataFrame-421"><a href="#DataFrame-421"><span class="linenos">421</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> +</span><span id="DataFrame-422"><a href="#DataFrame-422"><span class="linenos">422</span></a> <span class="k">def</span> <span class="nf">join</span><span class="p">(</span> +</span><span id="DataFrame-423"><a href="#DataFrame-423"><span class="linenos">423</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DataFrame-424"><a href="#DataFrame-424"><span class="linenos">424</span></a> <span class="n">other_df</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> +</span><span id="DataFrame-425"><a href="#DataFrame-425"><span class="linenos">425</span></a> <span class="n">on</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">Column</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">Column</span><span class="p">]],</span> +</span><span id="DataFrame-426"><a href="#DataFrame-426"><span class="linenos">426</span></a> <span class="n">how</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"inner"</span><span class="p">,</span> +</span><span id="DataFrame-427"><a href="#DataFrame-427"><span class="linenos">427</span></a> <span class="o">**</span><span class="n">kwargs</span><span class="p">,</span> +</span><span id="DataFrame-428"><a href="#DataFrame-428"><span class="linenos">428</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-429"><a href="#DataFrame-429"><span class="linenos">429</span></a> <span class="n">other_df</span> <span class="o">=</span> <span class="n">other_df</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">()</span> +</span><span id="DataFrame-430"><a href="#DataFrame-430"><span class="linenos">430</span></a> <span class="n">join_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">on</span><span class="p">)</span> +</span><span id="DataFrame-431"><a href="#DataFrame-431"><span class="linenos">431</span></a> <span class="c1"># We will determine actual "join on" expression later so we don't provide it at first</span> +</span><span id="DataFrame-432"><a href="#DataFrame-432"><span class="linenos">432</span></a> <span class="n">join_expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="DataFrame-433"><a href="#DataFrame-433"><span class="linenos">433</span></a> <span class="n">other_df</span><span class="o">.</span><span class="n">latest_cte_name</span><span class="p">,</span> <span class="n">join_type</span><span class="o">=</span><span class="n">how</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"_"</span><span class="p">,</span> <span class="s2">" "</span><span class="p">)</span> +</span><span id="DataFrame-434"><a href="#DataFrame-434"><span class="linenos">434</span></a> <span class="p">)</span> +</span><span id="DataFrame-435"><a href="#DataFrame-435"><span class="linenos">435</span></a> <span class="n">join_expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add_ctes_to_expression</span><span class="p">(</span><span class="n">join_expression</span><span class="p">,</span> <span class="n">other_df</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">ctes</span><span class="p">)</span> +</span><span id="DataFrame-436"><a href="#DataFrame-436"><span class="linenos">436</span></a> <span class="n">self_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">join_expression</span><span class="p">)</span> +</span><span id="DataFrame-437"><a href="#DataFrame-437"><span class="linenos">437</span></a> <span class="n">other_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">other_df</span><span class="p">)</span> +</span><span id="DataFrame-438"><a href="#DataFrame-438"><span class="linenos">438</span></a> <span class="c1"># Determines the join clause and select columns to be used passed on what type of columns were provided for</span> +</span><span id="DataFrame-439"><a href="#DataFrame-439"><span class="linenos">439</span></a> <span class="c1"># the join. The columns returned changes based on how the on expression is provided.</span> +</span><span id="DataFrame-440"><a href="#DataFrame-440"><span class="linenos">440</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">join_columns</span><span class="p">[</span><span class="mi">0</span><span class="p">]</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">Column</span><span class="p">):</span> +</span><span id="DataFrame-441"><a href="#DataFrame-441"><span class="linenos">441</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="DataFrame-442"><a href="#DataFrame-442"><span class="linenos">442</span></a><span class="sd"> Unique characteristics of join on column names only:</span> +</span><span id="DataFrame-443"><a href="#DataFrame-443"><span class="linenos">443</span></a><span class="sd"> * The column names are put at the front of the select list</span> +</span><span id="DataFrame-444"><a href="#DataFrame-444"><span class="linenos">444</span></a><span class="sd"> * The column names are deduplicated across the entire select list and only the column names (other dups are allowed)</span> +</span><span id="DataFrame-445"><a href="#DataFrame-445"><span class="linenos">445</span></a><span class="sd"> """</span> +</span><span id="DataFrame-446"><a href="#DataFrame-446"><span class="linenos">446</span></a> <span class="n">table_names</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame-447"><a href="#DataFrame-447"><span class="linenos">447</span></a> <span class="n">table</span><span class="o">.</span><span class="n">alias_or_name</span> +</span><span id="DataFrame-448"><a href="#DataFrame-448"><span class="linenos">448</span></a> <span class="k">for</span> <span class="n">table</span> <span class="ow">in</span> <span class="n">get_tables_from_expression_with_join</span><span class="p">(</span><span class="n">join_expression</span><span class="p">)</span> +</span><span id="DataFrame-449"><a href="#DataFrame-449"><span class="linenos">449</span></a> <span class="p">]</span> +</span><span id="DataFrame-450"><a href="#DataFrame-450"><span class="linenos">450</span></a> <span class="n">potential_ctes</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame-451"><a href="#DataFrame-451"><span class="linenos">451</span></a> <span class="n">cte</span> +</span><span id="DataFrame-452"><a href="#DataFrame-452"><span class="linenos">452</span></a> <span class="k">for</span> <span class="n">cte</span> <span class="ow">in</span> <span class="n">join_expression</span><span class="o">.</span><span class="n">ctes</span> +</span><span id="DataFrame-453"><a href="#DataFrame-453"><span class="linenos">453</span></a> <span class="k">if</span> <span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">in</span> <span class="n">table_names</span> +</span><span id="DataFrame-454"><a href="#DataFrame-454"><span class="linenos">454</span></a> <span class="ow">and</span> <span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="o">!=</span> <span class="n">other_df</span><span class="o">.</span><span class="n">latest_cte_name</span> +</span><span id="DataFrame-455"><a href="#DataFrame-455"><span class="linenos">455</span></a> <span class="p">]</span> +</span><span id="DataFrame-456"><a href="#DataFrame-456"><span class="linenos">456</span></a> <span class="c1"># Determine the table to reference for the left side of the join by checking each of the left side</span> +</span><span id="DataFrame-457"><a href="#DataFrame-457"><span class="linenos">457</span></a> <span class="c1"># tables and see if they have the column being referenced.</span> +</span><span id="DataFrame-458"><a href="#DataFrame-458"><span class="linenos">458</span></a> <span class="n">join_column_pairs</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="DataFrame-459"><a href="#DataFrame-459"><span class="linenos">459</span></a> <span class="k">for</span> <span class="n">join_column</span> <span class="ow">in</span> <span class="n">join_columns</span><span class="p">:</span> +</span><span id="DataFrame-460"><a href="#DataFrame-460"><span class="linenos">460</span></a> <span class="n">num_matching_ctes</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="DataFrame-461"><a href="#DataFrame-461"><span class="linenos">461</span></a> <span class="k">for</span> <span class="n">cte</span> <span class="ow">in</span> <span class="n">potential_ctes</span><span class="p">:</span> +</span><span id="DataFrame-462"><a href="#DataFrame-462"><span class="linenos">462</span></a> <span class="k">if</span> <span class="n">join_column</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">in</span> <span class="n">cte</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">named_selects</span><span class="p">:</span> +</span><span id="DataFrame-463"><a href="#DataFrame-463"><span class="linenos">463</span></a> <span class="n">left_column</span> <span class="o">=</span> <span class="n">join_column</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">set_table_name</span><span class="p">(</span><span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">)</span> +</span><span id="DataFrame-464"><a href="#DataFrame-464"><span class="linenos">464</span></a> <span class="n">right_column</span> <span class="o">=</span> <span class="n">join_column</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">set_table_name</span><span class="p">(</span><span class="n">other_df</span><span class="o">.</span><span class="n">latest_cte_name</span><span class="p">)</span> +</span><span id="DataFrame-465"><a href="#DataFrame-465"><span class="linenos">465</span></a> <span class="n">join_column_pairs</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">left_column</span><span class="p">,</span> <span class="n">right_column</span><span class="p">))</span> +</span><span id="DataFrame-466"><a href="#DataFrame-466"><span class="linenos">466</span></a> <span class="n">num_matching_ctes</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="DataFrame-467"><a href="#DataFrame-467"><span class="linenos">467</span></a> <span class="k">if</span> <span class="n">num_matching_ctes</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="DataFrame-468"><a href="#DataFrame-468"><span class="linenos">468</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span> +</span><span id="DataFrame-469"><a href="#DataFrame-469"><span class="linenos">469</span></a> <span class="sa">f</span><span class="s2">"Column </span><span class="si">{</span><span class="n">join_column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="si">}</span><span class="s2"> is ambiguous. Please specify the table name."</span> +</span><span id="DataFrame-470"><a href="#DataFrame-470"><span class="linenos">470</span></a> <span class="p">)</span> +</span><span id="DataFrame-471"><a href="#DataFrame-471"><span class="linenos">471</span></a> <span class="k">elif</span> <span class="n">num_matching_ctes</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> +</span><span id="DataFrame-472"><a href="#DataFrame-472"><span class="linenos">472</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span> +</span><span id="DataFrame-473"><a href="#DataFrame-473"><span class="linenos">473</span></a> <span class="sa">f</span><span class="s2">"Column </span><span class="si">{</span><span class="n">join_column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="si">}</span><span class="s2"> does not exist in any of the tables."</span> +</span><span id="DataFrame-474"><a href="#DataFrame-474"><span class="linenos">474</span></a> <span class="p">)</span> +</span><span id="DataFrame-475"><a href="#DataFrame-475"><span class="linenos">475</span></a> <span class="n">join_clause</span> <span class="o">=</span> <span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span> +</span><span id="DataFrame-476"><a href="#DataFrame-476"><span class="linenos">476</span></a> <span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span> <span class="o">&</span> <span class="n">y</span><span class="p">,</span> +</span><span id="DataFrame-477"><a href="#DataFrame-477"><span class="linenos">477</span></a> <span class="p">[</span><span class="n">left_column</span> <span class="o">==</span> <span class="n">right_column</span> <span class="k">for</span> <span class="n">left_column</span><span class="p">,</span> <span class="n">right_column</span> <span class="ow">in</span> <span class="n">join_column_pairs</span><span class="p">],</span> +</span><span id="DataFrame-478"><a href="#DataFrame-478"><span class="linenos">478</span></a> <span class="p">)</span> +</span><span id="DataFrame-479"><a href="#DataFrame-479"><span class="linenos">479</span></a> <span class="n">join_column_names</span> <span class="o">=</span> <span class="p">[</span><span class="n">left_col</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="k">for</span> <span class="n">left_col</span><span class="p">,</span> <span class="n">_</span> <span class="ow">in</span> <span class="n">join_column_pairs</span><span class="p">]</span> +</span><span id="DataFrame-480"><a href="#DataFrame-480"><span class="linenos">480</span></a> <span class="c1"># To match spark behavior only the join clause gets deduplicated and it gets put in the front of the column list</span> +</span><span id="DataFrame-481"><a href="#DataFrame-481"><span class="linenos">481</span></a> <span class="n">select_column_names</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame-482"><a href="#DataFrame-482"><span class="linenos">482</span></a> <span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span> +</span><span id="DataFrame-483"><a href="#DataFrame-483"><span class="linenos">483</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">)</span> +</span><span id="DataFrame-484"><a href="#DataFrame-484"><span class="linenos">484</span></a> <span class="k">else</span> <span class="n">column</span><span class="o">.</span><span class="n">sql</span><span class="p">()</span> +</span><span id="DataFrame-485"><a href="#DataFrame-485"><span class="linenos">485</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">self_columns</span> <span class="o">+</span> <span class="n">other_columns</span> +</span><span id="DataFrame-486"><a href="#DataFrame-486"><span class="linenos">486</span></a> <span class="p">]</span> +</span><span id="DataFrame-487"><a href="#DataFrame-487"><span class="linenos">487</span></a> <span class="n">select_column_names</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame-488"><a href="#DataFrame-488"><span class="linenos">488</span></a> <span class="n">column_name</span> +</span><span id="DataFrame-489"><a href="#DataFrame-489"><span class="linenos">489</span></a> <span class="k">for</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="n">select_column_names</span> +</span><span id="DataFrame-490"><a href="#DataFrame-490"><span class="linenos">490</span></a> <span class="k">if</span> <span class="n">column_name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">join_column_names</span> +</span><span id="DataFrame-491"><a href="#DataFrame-491"><span class="linenos">491</span></a> <span class="p">]</span> +</span><span id="DataFrame-492"><a href="#DataFrame-492"><span class="linenos">492</span></a> <span class="n">select_column_names</span> <span class="o">=</span> <span class="n">join_column_names</span> <span class="o">+</span> <span class="n">select_column_names</span> +</span><span id="DataFrame-493"><a href="#DataFrame-493"><span class="linenos">493</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame-494"><a href="#DataFrame-494"><span class="linenos">494</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="DataFrame-495"><a href="#DataFrame-495"><span class="linenos">495</span></a><span class="sd"> Unique characteristics of join on expressions:</span> +</span><span id="DataFrame-496"><a href="#DataFrame-496"><span class="linenos">496</span></a><span class="sd"> * There is no deduplication of the results.</span> +</span><span id="DataFrame-497"><a href="#DataFrame-497"><span class="linenos">497</span></a><span class="sd"> * The left join dataframe columns go first and right come after. No sort preference is given to join columns</span> +</span><span id="DataFrame-498"><a href="#DataFrame-498"><span class="linenos">498</span></a><span class="sd"> """</span> +</span><span id="DataFrame-499"><a href="#DataFrame-499"><span class="linenos">499</span></a> <span class="n">join_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">join_columns</span><span class="p">,</span> <span class="n">join_expression</span><span class="p">)</span> +</span><span id="DataFrame-500"><a href="#DataFrame-500"><span class="linenos">500</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">join_columns</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="DataFrame-501"><a href="#DataFrame-501"><span class="linenos">501</span></a> <span class="n">join_columns</span> <span class="o">=</span> <span class="p">[</span><span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span> <span class="o">&</span> <span class="n">y</span><span class="p">,</span> <span class="n">join_columns</span><span class="p">)]</span> +</span><span id="DataFrame-502"><a href="#DataFrame-502"><span class="linenos">502</span></a> <span class="n">join_clause</span> <span class="o">=</span> <span class="n">join_columns</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="DataFrame-503"><a href="#DataFrame-503"><span class="linenos">503</span></a> <span class="n">select_column_names</span> <span class="o">=</span> <span class="p">[</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">self_columns</span> <span class="o">+</span> <span class="n">other_columns</span><span class="p">]</span> +</span><span id="DataFrame-504"><a href="#DataFrame-504"><span class="linenos">504</span></a> +</span><span id="DataFrame-505"><a href="#DataFrame-505"><span class="linenos">505</span></a> <span class="c1"># Update the on expression with the actual join clause to replace the dummy one from before</span> +</span><span id="DataFrame-506"><a href="#DataFrame-506"><span class="linenos">506</span></a> <span class="n">join_expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"joins"</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"on"</span><span class="p">,</span> <span class="n">join_clause</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DataFrame-507"><a href="#DataFrame-507"><span class="linenos">507</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">join_expression</span><span class="p">)</span> +</span><span id="DataFrame-508"><a href="#DataFrame-508"><span class="linenos">508</span></a> <span class="n">new_df</span><span class="o">.</span><span class="n">pending_join_hints</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">pending_join_hints</span><span class="p">)</span> +</span><span id="DataFrame-509"><a href="#DataFrame-509"><span class="linenos">509</span></a> <span class="n">new_df</span><span class="o">.</span><span class="n">pending_hints</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">other_df</span><span class="o">.</span><span class="n">pending_hints</span><span class="p">)</span> +</span><span id="DataFrame-510"><a href="#DataFrame-510"><span class="linenos">510</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">select</span><span class="o">.</span><span class="n">__wrapped__</span><span class="p">(</span><span class="n">new_df</span><span class="p">,</span> <span class="o">*</span><span class="n">select_column_names</span><span class="p">)</span> +</span><span id="DataFrame-511"><a href="#DataFrame-511"><span class="linenos">511</span></a> <span class="k">return</span> <span class="n">new_df</span> +</span><span id="DataFrame-512"><a href="#DataFrame-512"><span class="linenos">512</span></a> +</span><span id="DataFrame-513"><a href="#DataFrame-513"><span class="linenos">513</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">ORDER_BY</span><span class="p">)</span> +</span><span id="DataFrame-514"><a href="#DataFrame-514"><span class="linenos">514</span></a> <span class="k">def</span> <span class="nf">orderBy</span><span class="p">(</span> +</span><span id="DataFrame-515"><a href="#DataFrame-515"><span class="linenos">515</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DataFrame-516"><a href="#DataFrame-516"><span class="linenos">516</span></a> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Column</span><span class="p">],</span> +</span><span id="DataFrame-517"><a href="#DataFrame-517"><span class="linenos">517</span></a> <span class="n">ascending</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Any</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">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrame-518"><a href="#DataFrame-518"><span class="linenos">518</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-519"><a href="#DataFrame-519"><span class="linenos">519</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="DataFrame-520"><a href="#DataFrame-520"><span class="linenos">520</span></a><span class="sd"> This implementation lets any ordered columns take priority over whatever is provided in `ascending`. Spark</span> +</span><span id="DataFrame-521"><a href="#DataFrame-521"><span class="linenos">521</span></a><span class="sd"> has irregular behavior and can result in runtime errors. Users shouldn't be mixing the two anyways so this</span> +</span><span id="DataFrame-522"><a href="#DataFrame-522"><span class="linenos">522</span></a><span class="sd"> is unlikely to come up.</span> +</span><span id="DataFrame-523"><a href="#DataFrame-523"><span class="linenos">523</span></a><span class="sd"> """</span> +</span><span id="DataFrame-524"><a href="#DataFrame-524"><span class="linenos">524</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> +</span><span id="DataFrame-525"><a href="#DataFrame-525"><span class="linenos">525</span></a> <span class="n">pre_ordered_col_indexes</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame-526"><a href="#DataFrame-526"><span class="linenos">526</span></a> <span class="n">x</span> +</span><span id="DataFrame-527"><a href="#DataFrame-527"><span class="linenos">527</span></a> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span> +</span><span id="DataFrame-528"><a href="#DataFrame-528"><span class="linenos">528</span></a> <span class="n">i</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">col</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">Ordered</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="DataFrame-529"><a href="#DataFrame-529"><span class="linenos">529</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">col</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> +</span><span id="DataFrame-530"><a href="#DataFrame-530"><span class="linenos">530</span></a> <span class="p">]</span> +</span><span id="DataFrame-531"><a href="#DataFrame-531"><span class="linenos">531</span></a> <span class="k">if</span> <span class="n">x</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> +</span><span id="DataFrame-532"><a href="#DataFrame-532"><span class="linenos">532</span></a> <span class="p">]</span> +</span><span id="DataFrame-533"><a href="#DataFrame-533"><span class="linenos">533</span></a> <span class="k">if</span> <span class="n">ascending</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="DataFrame-534"><a href="#DataFrame-534"><span class="linenos">534</span></a> <span class="n">ascending</span> <span class="o">=</span> <span class="p">[</span><span class="kc">True</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> +</span><span id="DataFrame-535"><a href="#DataFrame-535"><span class="linenos">535</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">ascending</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="DataFrame-536"><a href="#DataFrame-536"><span class="linenos">536</span></a> <span class="n">ascending</span> <span class="o">=</span> <span class="p">[</span><span class="n">ascending</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> +</span><span id="DataFrame-537"><a href="#DataFrame-537"><span class="linenos">537</span></a> <span class="n">ascending</span> <span class="o">=</span> <span class="p">[</span><span class="nb">bool</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">ascending</span><span class="p">)]</span> +</span><span id="DataFrame-538"><a href="#DataFrame-538"><span class="linenos">538</span></a> <span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span> +</span><span id="DataFrame-539"><a href="#DataFrame-539"><span class="linenos">539</span></a> <span class="n">ascending</span> +</span><span id="DataFrame-540"><a href="#DataFrame-540"><span class="linenos">540</span></a> <span class="p">),</span> <span class="s2">"The length of items in ascending must equal the number of columns provided"</span> +</span><span id="DataFrame-541"><a href="#DataFrame-541"><span class="linenos">541</span></a> <span class="n">col_and_ascending</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">columns</span><span class="p">,</span> <span class="n">ascending</span><span class="p">))</span> +</span><span id="DataFrame-542"><a href="#DataFrame-542"><span class="linenos">542</span></a> <span class="n">order_by_columns</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame-543"><a href="#DataFrame-543"><span class="linenos">543</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">col</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="ow">not</span> <span class="n">asc</span><span class="p">)</span> +</span><span id="DataFrame-544"><a href="#DataFrame-544"><span class="linenos">544</span></a> <span class="k">if</span> <span class="n">i</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">pre_ordered_col_indexes</span> +</span><span id="DataFrame-545"><a href="#DataFrame-545"><span class="linenos">545</span></a> <span class="k">else</span> <span class="n">columns</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">column_expression</span> +</span><span id="DataFrame-546"><a href="#DataFrame-546"><span class="linenos">546</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="p">(</span><span class="n">col</span><span class="p">,</span> <span class="n">asc</span><span class="p">)</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">col_and_ascending</span><span class="p">)</span> +</span><span id="DataFrame-547"><a href="#DataFrame-547"><span class="linenos">547</span></a> <span class="p">]</span> +</span><span id="DataFrame-548"><a href="#DataFrame-548"><span class="linenos">548</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">order_by</span><span class="p">(</span><span class="o">*</span><span class="n">order_by_columns</span><span class="p">))</span> +</span><span id="DataFrame-549"><a href="#DataFrame-549"><span class="linenos">549</span></a> +</span><span id="DataFrame-550"><a href="#DataFrame-550"><span class="linenos">550</span></a> <span class="n">sort</span> <span class="o">=</span> <span class="n">orderBy</span> +</span><span id="DataFrame-551"><a href="#DataFrame-551"><span class="linenos">551</span></a> +</span><span id="DataFrame-552"><a href="#DataFrame-552"><span class="linenos">552</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> +</span><span id="DataFrame-553"><a href="#DataFrame-553"><span class="linenos">553</span></a> <span class="k">def</span> <span class="nf">union</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-554"><a href="#DataFrame-554"><span class="linenos">554</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">,</span> <span class="n">other</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> +</span><span id="DataFrame-555"><a href="#DataFrame-555"><span class="linenos">555</span></a> +</span><span id="DataFrame-556"><a href="#DataFrame-556"><span class="linenos">556</span></a> <span class="n">unionAll</span> <span class="o">=</span> <span class="n">union</span> +</span><span id="DataFrame-557"><a href="#DataFrame-557"><span class="linenos">557</span></a> +</span><span id="DataFrame-558"><a href="#DataFrame-558"><span class="linenos">558</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> +</span><span id="DataFrame-559"><a href="#DataFrame-559"><span class="linenos">559</span></a> <span class="k">def</span> <span class="nf">unionByName</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> <span class="n">allowMissingColumns</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">):</span> +</span><span id="DataFrame-560"><a href="#DataFrame-560"><span class="linenos">560</span></a> <span class="n">l_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">columns</span> +</span><span id="DataFrame-561"><a href="#DataFrame-561"><span class="linenos">561</span></a> <span class="n">r_columns</span> <span class="o">=</span> <span class="n">other</span><span class="o">.</span><span class="n">columns</span> +</span><span id="DataFrame-562"><a href="#DataFrame-562"><span class="linenos">562</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">allowMissingColumns</span><span class="p">:</span> +</span><span id="DataFrame-563"><a href="#DataFrame-563"><span class="linenos">563</span></a> <span class="n">l_expressions</span> <span class="o">=</span> <span class="n">l_columns</span> +</span><span id="DataFrame-564"><a href="#DataFrame-564"><span class="linenos">564</span></a> <span class="n">r_expressions</span> <span class="o">=</span> <span class="n">l_columns</span> +</span><span id="DataFrame-565"><a href="#DataFrame-565"><span class="linenos">565</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame-566"><a href="#DataFrame-566"><span class="linenos">566</span></a> <span class="n">l_expressions</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="DataFrame-567"><a href="#DataFrame-567"><span class="linenos">567</span></a> <span class="n">r_expressions</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="DataFrame-568"><a href="#DataFrame-568"><span class="linenos">568</span></a> <span class="n">r_columns_unused</span> <span class="o">=</span> <span class="n">copy</span><span class="p">(</span><span class="n">r_columns</span><span class="p">)</span> +</span><span id="DataFrame-569"><a href="#DataFrame-569"><span class="linenos">569</span></a> <span class="k">for</span> <span class="n">l_column</span> <span class="ow">in</span> <span class="n">l_columns</span><span class="p">:</span> +</span><span id="DataFrame-570"><a href="#DataFrame-570"><span class="linenos">570</span></a> <span class="n">l_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">l_column</span><span class="p">)</span> +</span><span id="DataFrame-571"><a href="#DataFrame-571"><span class="linenos">571</span></a> <span class="k">if</span> <span class="n">l_column</span> <span class="ow">in</span> <span class="n">r_columns</span><span class="p">:</span> +</span><span id="DataFrame-572"><a href="#DataFrame-572"><span class="linenos">572</span></a> <span class="n">r_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">l_column</span><span class="p">)</span> +</span><span id="DataFrame-573"><a href="#DataFrame-573"><span class="linenos">573</span></a> <span class="n">r_columns_unused</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">l_column</span><span class="p">)</span> +</span><span id="DataFrame-574"><a href="#DataFrame-574"><span class="linenos">574</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame-575"><a href="#DataFrame-575"><span class="linenos">575</span></a> <span class="n">r_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">(),</span> <span class="n">l_column</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> +</span><span id="DataFrame-576"><a href="#DataFrame-576"><span class="linenos">576</span></a> <span class="k">for</span> <span class="n">r_column</span> <span class="ow">in</span> <span class="n">r_columns_unused</span><span class="p">:</span> +</span><span id="DataFrame-577"><a href="#DataFrame-577"><span class="linenos">577</span></a> <span class="n">l_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">(),</span> <span class="n">r_column</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> +</span><span id="DataFrame-578"><a href="#DataFrame-578"><span class="linenos">578</span></a> <span class="n">r_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">r_column</span><span class="p">)</span> +</span><span id="DataFrame-579"><a href="#DataFrame-579"><span class="linenos">579</span></a> <span class="n">r_df</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="DataFrame-580"><a href="#DataFrame-580"><span class="linenos">580</span></a> <span class="n">other</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">r_expressions</span><span class="p">))</span> +</span><span id="DataFrame-581"><a href="#DataFrame-581"><span class="linenos">581</span></a> <span class="p">)</span> +</span><span id="DataFrame-582"><a href="#DataFrame-582"><span class="linenos">582</span></a> <span class="n">l_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame-583"><a href="#DataFrame-583"><span class="linenos">583</span></a> <span class="k">if</span> <span class="n">allowMissingColumns</span><span class="p">:</span> +</span><span id="DataFrame-584"><a href="#DataFrame-584"><span class="linenos">584</span></a> <span class="n">l_df</span> <span class="o">=</span> <span class="n">l_df</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">l_expressions</span><span class="p">))</span> +</span><span id="DataFrame-585"><a href="#DataFrame-585"><span class="linenos">585</span></a> <span class="k">return</span> <span class="n">l_df</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">,</span> <span class="n">r_df</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> +</span><span id="DataFrame-586"><a href="#DataFrame-586"><span class="linenos">586</span></a> +</span><span id="DataFrame-587"><a href="#DataFrame-587"><span class="linenos">587</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> +</span><span id="DataFrame-588"><a href="#DataFrame-588"><span class="linenos">588</span></a> <span class="k">def</span> <span class="nf">intersect</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-589"><a href="#DataFrame-589"><span class="linenos">589</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="n">other</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> +</span><span id="DataFrame-590"><a href="#DataFrame-590"><span class="linenos">590</span></a> +</span><span id="DataFrame-591"><a href="#DataFrame-591"><span class="linenos">591</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> +</span><span id="DataFrame-592"><a href="#DataFrame-592"><span class="linenos">592</span></a> <span class="k">def</span> <span class="nf">intersectAll</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-593"><a href="#DataFrame-593"><span class="linenos">593</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="n">other</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> +</span><span id="DataFrame-594"><a href="#DataFrame-594"><span class="linenos">594</span></a> +</span><span id="DataFrame-595"><a href="#DataFrame-595"><span class="linenos">595</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> +</span><span id="DataFrame-596"><a href="#DataFrame-596"><span class="linenos">596</span></a> <span class="k">def</span> <span class="nf">exceptAll</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-597"><a href="#DataFrame-597"><span class="linenos">597</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">,</span> <span class="n">other</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> +</span><span id="DataFrame-598"><a href="#DataFrame-598"><span class="linenos">598</span></a> +</span><span id="DataFrame-599"><a href="#DataFrame-599"><span class="linenos">599</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> +</span><span id="DataFrame-600"><a href="#DataFrame-600"><span class="linenos">600</span></a> <span class="k">def</span> <span class="nf">distinct</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-601"><a href="#DataFrame-601"><span class="linenos">601</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">distinct</span><span class="p">())</span> +</span><span id="DataFrame-602"><a href="#DataFrame-602"><span class="linenos">602</span></a> +</span><span id="DataFrame-603"><a href="#DataFrame-603"><span class="linenos">603</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> +</span><span id="DataFrame-604"><a href="#DataFrame-604"><span class="linenos">604</span></a> <span class="k">def</span> <span class="nf">dropDuplicates</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">):</span> +</span><span id="DataFrame-605"><a href="#DataFrame-605"><span class="linenos">605</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">subset</span><span class="p">:</span> +</span><span id="DataFrame-606"><a href="#DataFrame-606"><span class="linenos">606</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">distinct</span><span class="p">()</span> +</span><span id="DataFrame-607"><a href="#DataFrame-607"><span class="linenos">607</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">subset</span><span class="p">)</span> +</span><span id="DataFrame-608"><a href="#DataFrame-608"><span class="linenos">608</span></a> <span class="n">window</span> <span class="o">=</span> <span class="n">Window</span><span class="o">.</span><span class="n">partitionBy</span><span class="p">(</span><span class="o">*</span><span class="n">column_names</span><span class="p">)</span><span class="o">.</span><span class="n">orderBy</span><span class="p">(</span><span class="o">*</span><span class="n">column_names</span><span class="p">)</span> +</span><span id="DataFrame-609"><a href="#DataFrame-609"><span class="linenos">609</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="DataFrame-610"><a href="#DataFrame-610"><span class="linenos">610</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame-611"><a href="#DataFrame-611"><span class="linenos">611</span></a> <span class="o">.</span><span class="n">withColumn</span><span class="p">(</span><span class="s2">"row_num"</span><span class="p">,</span> <span class="n">F</span><span class="o">.</span><span class="n">row_number</span><span class="p">()</span><span class="o">.</span><span class="n">over</span><span class="p">(</span><span class="n">window</span><span class="p">))</span> +</span><span id="DataFrame-612"><a href="#DataFrame-612"><span class="linenos">612</span></a> <span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">F</span><span class="o">.</span><span class="n">col</span><span class="p">(</span><span class="s2">"row_num"</span><span class="p">)</span> <span class="o">==</span> <span class="n">F</span><span class="o">.</span><span class="n">lit</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span> +</span><span id="DataFrame-613"><a href="#DataFrame-613"><span class="linenos">613</span></a> <span class="o">.</span><span class="n">drop</span><span class="p">(</span><span class="s2">"row_num"</span><span class="p">)</span> +</span><span id="DataFrame-614"><a href="#DataFrame-614"><span class="linenos">614</span></a> <span class="p">)</span> +</span><span id="DataFrame-615"><a href="#DataFrame-615"><span class="linenos">615</span></a> +</span><span id="DataFrame-616"><a href="#DataFrame-616"><span class="linenos">616</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> +</span><span id="DataFrame-617"><a href="#DataFrame-617"><span class="linenos">617</span></a> <span class="k">def</span> <span class="nf">dropna</span><span class="p">(</span> +</span><span id="DataFrame-618"><a href="#DataFrame-618"><span class="linenos">618</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DataFrame-619"><a href="#DataFrame-619"><span class="linenos">619</span></a> <span class="n">how</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"any"</span><span class="p">,</span> +</span><span id="DataFrame-620"><a href="#DataFrame-620"><span class="linenos">620</span></a> <span class="n">thresh</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrame-621"><a href="#DataFrame-621"><span class="linenos">621</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrame-622"><a href="#DataFrame-622"><span class="linenos">622</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-623"><a href="#DataFrame-623"><span class="linenos">623</span></a> <span class="n">minimum_non_null</span> <span class="o">=</span> <span class="n">thresh</span> <span class="ow">or</span> <span class="mi">0</span> <span class="c1"># will be determined later if thresh is null</span> +</span><span id="DataFrame-624"><a href="#DataFrame-624"><span class="linenos">624</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame-625"><a href="#DataFrame-625"><span class="linenos">625</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">new_df</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DataFrame-626"><a href="#DataFrame-626"><span class="linenos">626</span></a> <span class="k">if</span> <span class="n">subset</span><span class="p">:</span> +</span><span id="DataFrame-627"><a href="#DataFrame-627"><span class="linenos">627</span></a> <span class="n">null_check_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">subset</span><span class="p">)</span> +</span><span id="DataFrame-628"><a href="#DataFrame-628"><span class="linenos">628</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame-629"><a href="#DataFrame-629"><span class="linenos">629</span></a> <span class="n">null_check_columns</span> <span class="o">=</span> <span class="n">all_columns</span> +</span><span id="DataFrame-630"><a href="#DataFrame-630"><span class="linenos">630</span></a> <span class="k">if</span> <span class="n">thresh</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="DataFrame-631"><a href="#DataFrame-631"><span class="linenos">631</span></a> <span class="n">minimum_num_nulls</span> <span class="o">=</span> <span class="mi">1</span> <span class="k">if</span> <span class="n">how</span> <span class="o">==</span> <span class="s2">"any"</span> <span class="k">else</span> <span class="nb">len</span><span class="p">(</span><span class="n">null_check_columns</span><span class="p">)</span> +</span><span id="DataFrame-632"><a href="#DataFrame-632"><span class="linenos">632</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame-633"><a href="#DataFrame-633"><span class="linenos">633</span></a> <span class="n">minimum_num_nulls</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">null_check_columns</span><span class="p">)</span> <span class="o">-</span> <span class="n">minimum_non_null</span> <span class="o">+</span> <span class="mi">1</span> +</span><span id="DataFrame-634"><a href="#DataFrame-634"><span class="linenos">634</span></a> <span class="k">if</span> <span class="n">minimum_num_nulls</span> <span class="o">></span> <span class="nb">len</span><span class="p">(</span><span class="n">null_check_columns</span><span class="p">):</span> +</span><span id="DataFrame-635"><a href="#DataFrame-635"><span class="linenos">635</span></a> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span> +</span><span id="DataFrame-636"><a href="#DataFrame-636"><span class="linenos">636</span></a> <span class="sa">f</span><span class="s2">"The minimum num nulls for dropna must be less than or equal to the number of columns. "</span> +</span><span id="DataFrame-637"><a href="#DataFrame-637"><span class="linenos">637</span></a> <span class="sa">f</span><span class="s2">"Minimum num nulls: </span><span class="si">{</span><span class="n">minimum_num_nulls</span><span class="si">}</span><span class="s2">, Num Columns: </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">null_check_columns</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="DataFrame-638"><a href="#DataFrame-638"><span class="linenos">638</span></a> <span class="p">)</span> +</span><span id="DataFrame-639"><a href="#DataFrame-639"><span class="linenos">639</span></a> <span class="n">if_null_checks</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame-640"><a href="#DataFrame-640"><span class="linenos">640</span></a> <span class="n">F</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">isNull</span><span class="p">(),</span> <span class="n">F</span><span class="o">.</span><span class="n">lit</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span><span class="o">.</span><span class="n">otherwise</span><span class="p">(</span><span class="n">F</span><span class="o">.</span><span class="n">lit</span><span class="p">(</span><span class="mi">0</span><span class="p">))</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">null_check_columns</span> +</span><span id="DataFrame-641"><a href="#DataFrame-641"><span class="linenos">641</span></a> <span class="p">]</span> +</span><span id="DataFrame-642"><a href="#DataFrame-642"><span class="linenos">642</span></a> <span class="n">nulls_added_together</span> <span class="o">=</span> <span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">if_null_checks</span><span class="p">)</span> +</span><span id="DataFrame-643"><a href="#DataFrame-643"><span class="linenos">643</span></a> <span class="n">num_nulls</span> <span class="o">=</span> <span class="n">nulls_added_together</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span><span class="s2">"num_nulls"</span><span class="p">)</span> +</span><span id="DataFrame-644"><a href="#DataFrame-644"><span class="linenos">644</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="n">num_nulls</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="DataFrame-645"><a href="#DataFrame-645"><span class="linenos">645</span></a> <span class="n">filtered_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">F</span><span class="o">.</span><span class="n">col</span><span class="p">(</span><span class="s2">"num_nulls"</span><span class="p">)</span> <span class="o"><</span> <span class="n">F</span><span class="o">.</span><span class="n">lit</span><span class="p">(</span><span class="n">minimum_num_nulls</span><span class="p">))</span> +</span><span id="DataFrame-646"><a href="#DataFrame-646"><span class="linenos">646</span></a> <span class="n">final_df</span> <span class="o">=</span> <span class="n">filtered_df</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">all_columns</span><span class="p">)</span> +</span><span id="DataFrame-647"><a href="#DataFrame-647"><span class="linenos">647</span></a> <span class="k">return</span> <span class="n">final_df</span> +</span><span id="DataFrame-648"><a href="#DataFrame-648"><span class="linenos">648</span></a> +</span><span id="DataFrame-649"><a href="#DataFrame-649"><span class="linenos">649</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> +</span><span id="DataFrame-650"><a href="#DataFrame-650"><span class="linenos">650</span></a> <span class="k">def</span> <span class="nf">fillna</span><span class="p">(</span> +</span><span id="DataFrame-651"><a href="#DataFrame-651"><span class="linenos">651</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DataFrame-652"><a href="#DataFrame-652"><span class="linenos">652</span></a> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnLiterals</span><span class="p">],</span> +</span><span id="DataFrame-653"><a href="#DataFrame-653"><span class="linenos">653</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrame-654"><a href="#DataFrame-654"><span class="linenos">654</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-655"><a href="#DataFrame-655"><span class="linenos">655</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="DataFrame-656"><a href="#DataFrame-656"><span class="linenos">656</span></a><span class="sd"> Functionality Difference: If you provide a value to replace a null and that type conflicts</span> +</span><span id="DataFrame-657"><a href="#DataFrame-657"><span class="linenos">657</span></a><span class="sd"> with the type of the column then PySpark will just ignore your replacement.</span> +</span><span id="DataFrame-658"><a href="#DataFrame-658"><span class="linenos">658</span></a><span class="sd"> This will try to cast them to be the same in some cases. So they won't always match.</span> +</span><span id="DataFrame-659"><a href="#DataFrame-659"><span class="linenos">659</span></a><span class="sd"> Best to not mix types so make sure replacement is the same type as the column</span> +</span><span id="DataFrame-660"><a href="#DataFrame-660"><span class="linenos">660</span></a> +</span><span id="DataFrame-661"><a href="#DataFrame-661"><span class="linenos">661</span></a><span class="sd"> Possibility for improvement: Use `typeof` function to get the type of the column</span> +</span><span id="DataFrame-662"><a href="#DataFrame-662"><span class="linenos">662</span></a><span class="sd"> and check if it matches the type of the value provided. If not then make it null.</span> +</span><span id="DataFrame-663"><a href="#DataFrame-663"><span class="linenos">663</span></a><span class="sd"> """</span> +</span><span id="DataFrame-664"><a href="#DataFrame-664"><span class="linenos">664</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">lit</span> +</span><span id="DataFrame-665"><a href="#DataFrame-665"><span class="linenos">665</span></a> +</span><span id="DataFrame-666"><a href="#DataFrame-666"><span class="linenos">666</span></a> <span class="n">values</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="DataFrame-667"><a href="#DataFrame-667"><span class="linenos">667</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="DataFrame-668"><a href="#DataFrame-668"><span class="linenos">668</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame-669"><a href="#DataFrame-669"><span class="linenos">669</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">new_df</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DataFrame-670"><a href="#DataFrame-670"><span class="linenos">670</span></a> <span class="n">all_column_mapping</span> <span class="o">=</span> <span class="p">{</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="n">column</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">all_columns</span><span class="p">}</span> +</span><span id="DataFrame-671"><a href="#DataFrame-671"><span class="linenos">671</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span> +</span><span id="DataFrame-672"><a href="#DataFrame-672"><span class="linenos">672</span></a> <span class="n">values</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">value</span><span class="o">.</span><span class="n">values</span><span class="p">())</span> +</span><span id="DataFrame-673"><a href="#DataFrame-673"><span class="linenos">673</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">value</span><span class="p">))</span> +</span><span id="DataFrame-674"><a href="#DataFrame-674"><span class="linenos">674</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">columns</span><span class="p">:</span> +</span><span id="DataFrame-675"><a href="#DataFrame-675"><span class="linenos">675</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">subset</span><span class="p">)</span> <span class="k">if</span> <span class="n">subset</span> <span class="k">else</span> <span class="n">all_columns</span> +</span><span id="DataFrame-676"><a href="#DataFrame-676"><span class="linenos">676</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">values</span><span class="p">:</span> +</span><span id="DataFrame-677"><a href="#DataFrame-677"><span class="linenos">677</span></a> <span class="n">values</span> <span class="o">=</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> +</span><span id="DataFrame-678"><a href="#DataFrame-678"><span class="linenos">678</span></a> <span class="n">value_columns</span> <span class="o">=</span> <span class="p">[</span><span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">values</span><span class="p">]</span> +</span><span id="DataFrame-679"><a href="#DataFrame-679"><span class="linenos">679</span></a> +</span><span id="DataFrame-680"><a href="#DataFrame-680"><span class="linenos">680</span></a> <span class="n">null_replacement_mapping</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DataFrame-681"><a href="#DataFrame-681"><span class="linenos">681</span></a> <span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="p">(</span> +</span><span id="DataFrame-682"><a href="#DataFrame-682"><span class="linenos">682</span></a> <span class="n">F</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">isNull</span><span class="p">(),</span> <span class="n">value</span><span class="p">)</span><span class="o">.</span><span class="n">otherwise</span><span class="p">(</span><span class="n">column</span><span class="p">)</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">)</span> +</span><span id="DataFrame-683"><a href="#DataFrame-683"><span class="linenos">683</span></a> <span class="p">)</span> +</span><span id="DataFrame-684"><a href="#DataFrame-684"><span class="linenos">684</span></a> <span class="k">for</span> <span class="n">column</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">columns</span><span class="p">,</span> <span class="n">value_columns</span><span class="p">)</span> +</span><span id="DataFrame-685"><a href="#DataFrame-685"><span class="linenos">685</span></a> <span class="p">}</span> +</span><span id="DataFrame-686"><a href="#DataFrame-686"><span class="linenos">686</span></a> <span class="n">null_replacement_mapping</span> <span class="o">=</span> <span class="p">{</span><span class="o">**</span><span class="n">all_column_mapping</span><span class="p">,</span> <span class="o">**</span><span class="n">null_replacement_mapping</span><span class="p">}</span> +</span><span id="DataFrame-687"><a href="#DataFrame-687"><span class="linenos">687</span></a> <span class="n">null_replacement_columns</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame-688"><a href="#DataFrame-688"><span class="linenos">688</span></a> <span class="n">null_replacement_mapping</span><span class="p">[</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">all_columns</span> +</span><span id="DataFrame-689"><a href="#DataFrame-689"><span class="linenos">689</span></a> <span class="p">]</span> +</span><span id="DataFrame-690"><a href="#DataFrame-690"><span class="linenos">690</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">null_replacement_columns</span><span class="p">)</span> +</span><span id="DataFrame-691"><a href="#DataFrame-691"><span class="linenos">691</span></a> <span class="k">return</span> <span class="n">new_df</span> +</span><span id="DataFrame-692"><a href="#DataFrame-692"><span class="linenos">692</span></a> +</span><span id="DataFrame-693"><a href="#DataFrame-693"><span class="linenos">693</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> +</span><span id="DataFrame-694"><a href="#DataFrame-694"><span class="linenos">694</span></a> <span class="k">def</span> <span class="nf">replace</span><span class="p">(</span> +</span><span id="DataFrame-695"><a href="#DataFrame-695"><span class="linenos">695</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DataFrame-696"><a href="#DataFrame-696"><span class="linenos">696</span></a> <span class="n">to_replace</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</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">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">],</span> +</span><span id="DataFrame-697"><a href="#DataFrame-697"><span class="linenos">697</span></a> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrame-698"><a href="#DataFrame-698"><span class="linenos">698</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">ColumnOrName</span><span class="p">]</span> <span class="o">|</span> <span class="n">ColumnOrName</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrame-699"><a href="#DataFrame-699"><span class="linenos">699</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-700"><a href="#DataFrame-700"><span class="linenos">700</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">lit</span> +</span><span id="DataFrame-701"><a href="#DataFrame-701"><span class="linenos">701</span></a> +</span><span id="DataFrame-702"><a href="#DataFrame-702"><span class="linenos">702</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="DataFrame-703"><a href="#DataFrame-703"><span class="linenos">703</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame-704"><a href="#DataFrame-704"><span class="linenos">704</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">new_df</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DataFrame-705"><a href="#DataFrame-705"><span class="linenos">705</span></a> <span class="n">all_column_mapping</span> <span class="o">=</span> <span class="p">{</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="n">column</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">all_columns</span><span class="p">}</span> +</span><span id="DataFrame-706"><a href="#DataFrame-706"><span class="linenos">706</span></a> +</span><span id="DataFrame-707"><a href="#DataFrame-707"><span class="linenos">707</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">subset</span><span class="p">)</span> <span class="k">if</span> <span class="n">subset</span> <span class="k">else</span> <span class="n">all_columns</span> +</span><span id="DataFrame-708"><a href="#DataFrame-708"><span class="linenos">708</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">to_replace</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span> +</span><span id="DataFrame-709"><a href="#DataFrame-709"><span class="linenos">709</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">to_replace</span><span class="p">)</span> +</span><span id="DataFrame-710"><a href="#DataFrame-710"><span class="linenos">710</span></a> <span class="n">new_values</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">to_replace</span><span class="o">.</span><span class="n">values</span><span class="p">())</span> +</span><span id="DataFrame-711"><a href="#DataFrame-711"><span class="linenos">711</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">old_values</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">to_replace</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="DataFrame-712"><a href="#DataFrame-712"><span class="linenos">712</span></a> <span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">list</span><span class="p">),</span> <span class="s2">"value must be a list since the replacements are a list"</span> +</span><span id="DataFrame-713"><a href="#DataFrame-713"><span class="linenos">713</span></a> <span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">to_replace</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span> +</span><span id="DataFrame-714"><a href="#DataFrame-714"><span class="linenos">714</span></a> <span class="n">value</span> +</span><span id="DataFrame-715"><a href="#DataFrame-715"><span class="linenos">715</span></a> <span class="p">),</span> <span class="s2">"the replacements and values must be the same length"</span> +</span><span id="DataFrame-716"><a href="#DataFrame-716"><span class="linenos">716</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="n">to_replace</span> +</span><span id="DataFrame-717"><a href="#DataFrame-717"><span class="linenos">717</span></a> <span class="n">new_values</span> <span class="o">=</span> <span class="n">value</span> +</span><span id="DataFrame-718"><a href="#DataFrame-718"><span class="linenos">718</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame-719"><a href="#DataFrame-719"><span class="linenos">719</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="p">[</span><span class="n">to_replace</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> +</span><span id="DataFrame-720"><a href="#DataFrame-720"><span class="linenos">720</span></a> <span class="n">new_values</span> <span class="o">=</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> +</span><span id="DataFrame-721"><a href="#DataFrame-721"><span class="linenos">721</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="p">[</span><span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">old_values</span><span class="p">]</span> +</span><span id="DataFrame-722"><a href="#DataFrame-722"><span class="linenos">722</span></a> <span class="n">new_values</span> <span class="o">=</span> <span class="p">[</span><span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">new_values</span><span class="p">]</span> +</span><span id="DataFrame-723"><a href="#DataFrame-723"><span class="linenos">723</span></a> +</span><span id="DataFrame-724"><a href="#DataFrame-724"><span class="linenos">724</span></a> <span class="n">replacement_mapping</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="DataFrame-725"><a href="#DataFrame-725"><span class="linenos">725</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">columns</span><span class="p">:</span> +</span><span id="DataFrame-726"><a href="#DataFrame-726"><span class="linenos">726</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">Column</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span> +</span><span id="DataFrame-727"><a href="#DataFrame-727"><span class="linenos">727</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="p">(</span><span class="n">old_value</span><span class="p">,</span> <span class="n">new_value</span><span class="p">)</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">old_values</span><span class="p">,</span> <span class="n">new_values</span><span class="p">)):</span> +</span><span id="DataFrame-728"><a href="#DataFrame-728"><span class="linenos">728</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> +</span><span id="DataFrame-729"><a href="#DataFrame-729"><span class="linenos">729</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">F</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">column</span> <span class="o">==</span> <span class="n">old_value</span><span class="p">,</span> <span class="n">new_value</span><span class="p">)</span> +</span><span id="DataFrame-730"><a href="#DataFrame-730"><span class="linenos">730</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame-731"><a href="#DataFrame-731"><span class="linenos">731</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">column</span> <span class="o">==</span> <span class="n">old_value</span><span class="p">,</span> <span class="n">new_value</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="DataFrame-732"><a href="#DataFrame-732"><span class="linenos">732</span></a> <span class="n">replacement_mapping</span><span class="p">[</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">otherwise</span><span class="p">(</span><span class="n">column</span><span class="p">)</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span> +</span><span id="DataFrame-733"><a href="#DataFrame-733"><span class="linenos">733</span></a> <span class="n">column</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">alias_or_name</span> +</span><span id="DataFrame-734"><a href="#DataFrame-734"><span class="linenos">734</span></a> <span class="p">)</span> +</span><span id="DataFrame-735"><a href="#DataFrame-735"><span class="linenos">735</span></a> +</span><span id="DataFrame-736"><a href="#DataFrame-736"><span class="linenos">736</span></a> <span class="n">replacement_mapping</span> <span class="o">=</span> <span class="p">{</span><span class="o">**</span><span class="n">all_column_mapping</span><span class="p">,</span> <span class="o">**</span><span class="n">replacement_mapping</span><span class="p">}</span> +</span><span id="DataFrame-737"><a href="#DataFrame-737"><span class="linenos">737</span></a> <span class="n">replacement_columns</span> <span class="o">=</span> <span class="p">[</span><span class="n">replacement_mapping</span><span class="p">[</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">all_columns</span><span class="p">]</span> +</span><span id="DataFrame-738"><a href="#DataFrame-738"><span class="linenos">738</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">replacement_columns</span><span class="p">)</span> +</span><span id="DataFrame-739"><a href="#DataFrame-739"><span class="linenos">739</span></a> <span class="k">return</span> <span class="n">new_df</span> +</span><span id="DataFrame-740"><a href="#DataFrame-740"><span class="linenos">740</span></a> +</span><span id="DataFrame-741"><a href="#DataFrame-741"><span class="linenos">741</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> +</span><span id="DataFrame-742"><a href="#DataFrame-742"><span class="linenos">742</span></a> <span class="k">def</span> <span class="nf">withColumn</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">colName</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">col</span><span class="p">:</span> <span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-743"><a href="#DataFrame-743"><span class="linenos">743</span></a> <span class="n">col</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_col</span><span class="p">(</span><span class="n">col</span><span class="p">)</span> +</span><span id="DataFrame-744"><a href="#DataFrame-744"><span class="linenos">744</span></a> <span class="n">existing_col_names</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">named_selects</span> +</span><span id="DataFrame-745"><a href="#DataFrame-745"><span class="linenos">745</span></a> <span class="n">existing_col_index</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="DataFrame-746"><a href="#DataFrame-746"><span class="linenos">746</span></a> <span class="n">existing_col_names</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">colName</span><span class="p">)</span> <span class="k">if</span> <span class="n">colName</span> <span class="ow">in</span> <span class="n">existing_col_names</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="DataFrame-747"><a href="#DataFrame-747"><span class="linenos">747</span></a> <span class="p">)</span> +</span><span id="DataFrame-748"><a href="#DataFrame-748"><span class="linenos">748</span></a> <span class="k">if</span> <span class="n">existing_col_index</span><span class="p">:</span> +</span><span id="DataFrame-749"><a href="#DataFrame-749"><span class="linenos">749</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame-750"><a href="#DataFrame-750"><span class="linenos">750</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="n">existing_col_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">col</span><span class="o">.</span><span class="n">expression</span> +</span><span id="DataFrame-751"><a href="#DataFrame-751"><span class="linenos">751</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DataFrame-752"><a href="#DataFrame-752"><span class="linenos">752</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="n">col</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span><span class="n">colName</span><span class="p">),</span> <span class="n">append</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="DataFrame-753"><a href="#DataFrame-753"><span class="linenos">753</span></a> +</span><span id="DataFrame-754"><a href="#DataFrame-754"><span class="linenos">754</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> +</span><span id="DataFrame-755"><a href="#DataFrame-755"><span class="linenos">755</span></a> <span class="k">def</span> <span class="nf">withColumnRenamed</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">existing</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">new</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="DataFrame-756"><a href="#DataFrame-756"><span class="linenos">756</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame-757"><a href="#DataFrame-757"><span class="linenos">757</span></a> <span class="n">existing_columns</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame-758"><a href="#DataFrame-758"><span class="linenos">758</span></a> <span class="n">expression</span> +</span><span id="DataFrame-759"><a href="#DataFrame-759"><span class="linenos">759</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="DataFrame-760"><a href="#DataFrame-760"><span class="linenos">760</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="o">==</span> <span class="n">existing</span> +</span><span id="DataFrame-761"><a href="#DataFrame-761"><span class="linenos">761</span></a> <span class="p">]</span> +</span><span id="DataFrame-762"><a href="#DataFrame-762"><span class="linenos">762</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">existing_columns</span><span class="p">:</span> +</span><span id="DataFrame-763"><a href="#DataFrame-763"><span class="linenos">763</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Tried to rename a column that doesn't exist"</span><span class="p">)</span> +</span><span id="DataFrame-764"><a href="#DataFrame-764"><span class="linenos">764</span></a> <span class="k">for</span> <span class="n">existing_column</span> <span class="ow">in</span> <span class="n">existing_columns</span><span class="p">:</span> +</span><span id="DataFrame-765"><a href="#DataFrame-765"><span class="linenos">765</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">existing_column</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> +</span><span id="DataFrame-766"><a href="#DataFrame-766"><span class="linenos">766</span></a> <span class="n">existing_column</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">alias_</span><span class="p">(</span><span class="n">existing_column</span><span class="p">,</span> <span class="n">new</span><span class="p">))</span> +</span><span id="DataFrame-767"><a href="#DataFrame-767"><span class="linenos">767</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame-768"><a href="#DataFrame-768"><span class="linenos">768</span></a> <span class="n">existing_column</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">new</span><span class="p">))</span> +</span><span id="DataFrame-769"><a href="#DataFrame-769"><span class="linenos">769</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DataFrame-770"><a href="#DataFrame-770"><span class="linenos">770</span></a> +</span><span id="DataFrame-771"><a href="#DataFrame-771"><span class="linenos">771</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> +</span><span id="DataFrame-772"><a href="#DataFrame-772"><span class="linenos">772</span></a> <span class="k">def</span> <span class="nf">drop</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Column</span><span class="p">])</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-773"><a href="#DataFrame-773"><span class="linenos">773</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DataFrame-774"><a href="#DataFrame-774"><span class="linenos">774</span></a> <span class="n">drop_cols</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> +</span><span id="DataFrame-775"><a href="#DataFrame-775"><span class="linenos">775</span></a> <span class="n">new_columns</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame-776"><a href="#DataFrame-776"><span class="linenos">776</span></a> <span class="n">col</span> +</span><span id="DataFrame-777"><a href="#DataFrame-777"><span class="linenos">777</span></a> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">all_columns</span> +</span><span id="DataFrame-778"><a href="#DataFrame-778"><span class="linenos">778</span></a> <span class="k">if</span> <span class="n">col</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="n">drop_column</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="k">for</span> <span class="n">drop_column</span> <span class="ow">in</span> <span class="n">drop_cols</span><span class="p">]</span> +</span><span id="DataFrame-779"><a href="#DataFrame-779"><span class="linenos">779</span></a> <span class="p">]</span> +</span><span id="DataFrame-780"><a href="#DataFrame-780"><span class="linenos">780</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">new_columns</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="DataFrame-781"><a href="#DataFrame-781"><span class="linenos">781</span></a> +</span><span id="DataFrame-782"><a href="#DataFrame-782"><span class="linenos">782</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">LIMIT</span><span class="p">)</span> +</span><span id="DataFrame-783"><a href="#DataFrame-783"><span class="linenos">783</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">num</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-784"><a href="#DataFrame-784"><span class="linenos">784</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">limit</span><span class="p">(</span><span class="n">num</span><span class="p">))</span> +</span><span id="DataFrame-785"><a href="#DataFrame-785"><span class="linenos">785</span></a> +</span><span id="DataFrame-786"><a href="#DataFrame-786"><span class="linenos">786</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> +</span><span id="DataFrame-787"><a href="#DataFrame-787"><span class="linenos">787</span></a> <span class="k">def</span> <span class="nf">hint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">*</span><span class="n">parameters</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">int</span><span class="p">]])</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-788"><a href="#DataFrame-788"><span class="linenos">788</span></a> <span class="n">parameter_list</span> <span class="o">=</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">parameters</span><span class="p">)</span> +</span><span id="DataFrame-789"><a href="#DataFrame-789"><span class="linenos">789</span></a> <span class="n">parameter_columns</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="DataFrame-790"><a href="#DataFrame-790"><span class="linenos">790</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">parameter_list</span><span class="p">)</span> +</span><span id="DataFrame-791"><a href="#DataFrame-791"><span class="linenos">791</span></a> <span class="k">if</span> <span class="n">parameters</span> +</span><span id="DataFrame-792"><a href="#DataFrame-792"><span class="linenos">792</span></a> <span class="k">else</span> <span class="n">Column</span><span class="o">.</span><span class="n">ensure_cols</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">sequence_id</span><span class="p">])</span> +</span><span id="DataFrame-793"><a href="#DataFrame-793"><span class="linenos">793</span></a> <span class="p">)</span> +</span><span id="DataFrame-794"><a href="#DataFrame-794"><span class="linenos">794</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hint</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">parameter_columns</span><span class="p">)</span> +</span><span id="DataFrame-795"><a href="#DataFrame-795"><span class="linenos">795</span></a> +</span><span id="DataFrame-796"><a href="#DataFrame-796"><span class="linenos">796</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> +</span><span id="DataFrame-797"><a href="#DataFrame-797"><span class="linenos">797</span></a> <span class="k">def</span> <span class="nf">repartition</span><span class="p">(</span> +</span><span id="DataFrame-798"><a href="#DataFrame-798"><span class="linenos">798</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">numPartitions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="n">ColumnOrName</span><span class="p">],</span> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">ColumnOrName</span> +</span><span id="DataFrame-799"><a href="#DataFrame-799"><span class="linenos">799</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-800"><a href="#DataFrame-800"><span class="linenos">800</span></a> <span class="n">num_partition_cols</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">numPartitions</span><span class="p">)</span> +</span><span id="DataFrame-801"><a href="#DataFrame-801"><span class="linenos">801</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> +</span><span id="DataFrame-802"><a href="#DataFrame-802"><span class="linenos">802</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">num_partition_cols</span> <span class="o">+</span> <span class="n">columns</span> +</span><span id="DataFrame-803"><a href="#DataFrame-803"><span class="linenos">803</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hint</span><span class="p">(</span><span class="s2">"repartition"</span><span class="p">,</span> <span class="n">args</span><span class="p">)</span> +</span><span id="DataFrame-804"><a href="#DataFrame-804"><span class="linenos">804</span></a> +</span><span id="DataFrame-805"><a href="#DataFrame-805"><span class="linenos">805</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> +</span><span id="DataFrame-806"><a href="#DataFrame-806"><span class="linenos">806</span></a> <span class="k">def</span> <span class="nf">coalesce</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">numPartitions</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-807"><a href="#DataFrame-807"><span class="linenos">807</span></a> <span class="n">num_partitions</span> <span class="o">=</span> <span class="n">Column</span><span class="o">.</span><span class="n">ensure_cols</span><span class="p">([</span><span class="n">numPartitions</span><span class="p">])</span> +</span><span id="DataFrame-808"><a href="#DataFrame-808"><span class="linenos">808</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hint</span><span class="p">(</span><span class="s2">"coalesce"</span><span class="p">,</span> <span class="n">num_partitions</span><span class="p">)</span> +</span><span id="DataFrame-809"><a href="#DataFrame-809"><span class="linenos">809</span></a> +</span><span id="DataFrame-810"><a href="#DataFrame-810"><span class="linenos">810</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> +</span><span id="DataFrame-811"><a href="#DataFrame-811"><span class="linenos">811</span></a> <span class="k">def</span> <span class="nf">cache</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-812"><a href="#DataFrame-812"><span class="linenos">812</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">(</span><span class="n">storage_level</span><span class="o">=</span><span class="s2">"MEMORY_AND_DISK"</span><span class="p">)</span> +</span><span id="DataFrame-813"><a href="#DataFrame-813"><span class="linenos">813</span></a> +</span><span id="DataFrame-814"><a href="#DataFrame-814"><span class="linenos">814</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> +</span><span id="DataFrame-815"><a href="#DataFrame-815"><span class="linenos">815</span></a> <span class="k">def</span> <span class="nf">persist</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">storageLevel</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"MEMORY_AND_DISK_SER"</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame-816"><a href="#DataFrame-816"><span class="linenos">816</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="DataFrame-817"><a href="#DataFrame-817"><span class="linenos">817</span></a><span class="sd"> Storage Level Options: https://spark.apache.org/docs/3.0.0-preview/sql-ref-syntax-aux-cache-cache-table.html</span> +</span><span id="DataFrame-818"><a href="#DataFrame-818"><span class="linenos">818</span></a><span class="sd"> """</span> +</span><span id="DataFrame-819"><a href="#DataFrame-819"><span class="linenos">819</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">(</span><span class="n">storageLevel</span><span class="p">)</span> </span></pre></div> @@ -1505,7 +1506,7 @@ <input id="DataFrame.__init__-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> <div class="attr function"> - <span class="name">DataFrame</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="n">spark</span><span class="p">:</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043314786224'</span><span class="o">></span>,</span><span class="param"> <span class="n">expression</span><span class="p">:</span> <span class="n"><a href="../expressions.html#Select">sqlglot.expressions.Select</a></span>,</span><span class="param"> <span class="n">branch_id</span><span class="p">:</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><span class="param"> <span class="n">sequence_id</span><span class="p">:</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><span class="param"> <span class="n">last_op</span><span class="p">:</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">dataframe</span><span class="o">.</span><span class="n">sql</span><span class="o">.</span><span class="n">operations</span><span class="o">.</span><span class="n">Operation</span> <span class="o">=</span> <span class="o"><</span><span class="n">Operation</span><span class="o">.</span><span class="n">INIT</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="o">></span>,</span><span class="param"> <span class="n">pending_hints</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="n"><a href="../expressions.html#Expression">sqlglot.expressions.Expression</a></span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span>,</span><span class="param"> <span class="n">output_expression_container</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043314972080'</span><span class="o">></span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>,</span><span class="param"> <span class="o">**</span><span class="n">kwargs</span></span>)</span> + <span class="name">DataFrame</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="n">spark</span><span class="p">:</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135093941152'</span><span class="o">></span>,</span><span class="param"> <span class="n">expression</span><span class="p">:</span> <span class="n"><a href="../expressions.html#Select">sqlglot.expressions.Select</a></span>,</span><span class="param"> <span class="n">branch_id</span><span class="p">:</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><span class="param"> <span class="n">sequence_id</span><span class="p">:</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><span class="param"> <span class="n">last_op</span><span class="p">:</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">dataframe</span><span class="o">.</span><span class="n">sql</span><span class="o">.</span><span class="n">operations</span><span class="o">.</span><span class="n">Operation</span> <span class="o">=</span> <span class="o"><</span><span class="n">Operation</span><span class="o">.</span><span class="n">INIT</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="o">></span>,</span><span class="param"> <span class="n">pending_hints</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="n"><a href="../expressions.html#Expression">sqlglot.expressions.Expression</a></span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span>,</span><span class="param"> <span class="n">output_expression_container</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135094093856'</span><span class="o">></span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>,</span><span class="param"> <span class="o">**</span><span class="n">kwargs</span></span>)</span> <label class="view-source-button" for="DataFrame.__init__-view-source"><span>View Source</span></label> @@ -1571,36 +1572,37 @@ </span><span id="DataFrame.sql-317"><a href="#DataFrame.sql-317"><span class="linenos">317</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="n">expression</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="s2">"spark"</span><span class="p">)</span> </span><span id="DataFrame.sql-318"><a href="#DataFrame.sql-318"><span class="linenos">318</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">select_expression</span><span class="o">.</span><span class="n">expressions</span> </span><span id="DataFrame.sql-319"><a href="#DataFrame.sql-319"><span class="linenos">319</span></a> <span class="p">},</span> -</span><span id="DataFrame.sql-320"><a href="#DataFrame.sql-320"><span class="linenos">320</span></a> <span class="p">)</span> -</span><span id="DataFrame.sql-321"><a href="#DataFrame.sql-321"><span class="linenos">321</span></a> <span class="n">cache_storage_level</span> <span class="o">=</span> <span class="n">select_expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"cache_storage_level"</span><span class="p">]</span> -</span><span id="DataFrame.sql-322"><a href="#DataFrame.sql-322"><span class="linenos">322</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame.sql-323"><a href="#DataFrame.sql-323"><span class="linenos">323</span></a> <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">"storageLevel"</span><span class="p">),</span> -</span><span id="DataFrame.sql-324"><a href="#DataFrame.sql-324"><span class="linenos">324</span></a> <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">cache_storage_level</span><span class="p">),</span> -</span><span id="DataFrame.sql-325"><a href="#DataFrame.sql-325"><span class="linenos">325</span></a> <span class="p">]</span> -</span><span id="DataFrame.sql-326"><a href="#DataFrame.sql-326"><span class="linenos">326</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">(</span> -</span><span id="DataFrame.sql-327"><a href="#DataFrame.sql-327"><span class="linenos">327</span></a> <span class="n">this</span><span class="o">=</span><span class="n">cache_table</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">select_expression</span><span class="p">,</span> <span class="n">lazy</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="n">options</span> -</span><span id="DataFrame.sql-328"><a href="#DataFrame.sql-328"><span class="linenos">328</span></a> <span class="p">)</span> -</span><span id="DataFrame.sql-329"><a href="#DataFrame.sql-329"><span class="linenos">329</span></a> <span class="c1"># We will drop the "view" if it exists before running the cache table</span> -</span><span id="DataFrame.sql-330"><a href="#DataFrame.sql-330"><span class="linenos">330</span></a> <span class="n">output_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">cache_table</span><span class="p">,</span> <span class="n">exists</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="s2">"VIEW"</span><span class="p">))</span> -</span><span id="DataFrame.sql-331"><a href="#DataFrame.sql-331"><span class="linenos">331</span></a> <span class="k">elif</span> <span class="n">expression_type</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> -</span><span id="DataFrame.sql-332"><a href="#DataFrame.sql-332"><span class="linenos">332</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">output_expression_container</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame.sql-333"><a href="#DataFrame.sql-333"><span class="linenos">333</span></a> <span class="n">expression</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">select_expression</span><span class="p">)</span> -</span><span id="DataFrame.sql-334"><a href="#DataFrame.sql-334"><span class="linenos">334</span></a> <span class="k">elif</span> <span class="n">expression_type</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">:</span> -</span><span id="DataFrame.sql-335"><a href="#DataFrame.sql-335"><span class="linenos">335</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">output_expression_container</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame.sql-336"><a href="#DataFrame.sql-336"><span class="linenos">336</span></a> <span class="n">select_without_ctes</span> <span class="o">=</span> <span class="n">select_expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame.sql-337"><a href="#DataFrame.sql-337"><span class="linenos">337</span></a> <span class="n">select_without_ctes</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"with"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="DataFrame.sql-338"><a href="#DataFrame.sql-338"><span class="linenos">338</span></a> <span class="n">expression</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">select_without_ctes</span><span class="p">)</span> -</span><span id="DataFrame.sql-339"><a href="#DataFrame.sql-339"><span class="linenos">339</span></a> <span class="k">if</span> <span class="n">select_expression</span><span class="o">.</span><span class="n">ctes</span><span class="p">:</span> -</span><span id="DataFrame.sql-340"><a href="#DataFrame.sql-340"><span class="linenos">340</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"with"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">select_expression</span><span class="o">.</span><span class="n">ctes</span><span class="p">))</span> -</span><span id="DataFrame.sql-341"><a href="#DataFrame.sql-341"><span class="linenos">341</span></a> <span class="k">elif</span> <span class="n">expression_type</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> -</span><span id="DataFrame.sql-342"><a href="#DataFrame.sql-342"><span class="linenos">342</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">select_expression</span> -</span><span id="DataFrame.sql-343"><a href="#DataFrame.sql-343"><span class="linenos">343</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame.sql-344"><a href="#DataFrame.sql-344"><span class="linenos">344</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid expression type: </span><span class="si">{</span><span class="n">expression_type</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="DataFrame.sql-345"><a href="#DataFrame.sql-345"><span class="linenos">345</span></a> <span class="n">output_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DataFrame.sql-346"><a href="#DataFrame.sql-346"><span class="linenos">346</span></a> -</span><span id="DataFrame.sql-347"><a href="#DataFrame.sql-347"><span class="linenos">347</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="DataFrame.sql-348"><a href="#DataFrame.sql-348"><span class="linenos">348</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="s2">"dialect"</span><span class="p">:</span> <span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">})</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">output_expressions</span> -</span><span id="DataFrame.sql-349"><a href="#DataFrame.sql-349"><span class="linenos">349</span></a> <span class="p">]</span> +</span><span id="DataFrame.sql-320"><a href="#DataFrame.sql-320"><span class="linenos">320</span></a> <span class="n">dialect</span><span class="o">=</span><span class="s2">"spark"</span><span class="p">,</span> +</span><span id="DataFrame.sql-321"><a href="#DataFrame.sql-321"><span class="linenos">321</span></a> <span class="p">)</span> +</span><span id="DataFrame.sql-322"><a href="#DataFrame.sql-322"><span class="linenos">322</span></a> <span class="n">cache_storage_level</span> <span class="o">=</span> <span class="n">select_expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"cache_storage_level"</span><span class="p">]</span> +</span><span id="DataFrame.sql-323"><a href="#DataFrame.sql-323"><span class="linenos">323</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame.sql-324"><a href="#DataFrame.sql-324"><span class="linenos">324</span></a> <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">"storageLevel"</span><span class="p">),</span> +</span><span id="DataFrame.sql-325"><a href="#DataFrame.sql-325"><span class="linenos">325</span></a> <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">cache_storage_level</span><span class="p">),</span> +</span><span id="DataFrame.sql-326"><a href="#DataFrame.sql-326"><span class="linenos">326</span></a> <span class="p">]</span> +</span><span id="DataFrame.sql-327"><a href="#DataFrame.sql-327"><span class="linenos">327</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">(</span> +</span><span id="DataFrame.sql-328"><a href="#DataFrame.sql-328"><span class="linenos">328</span></a> <span class="n">this</span><span class="o">=</span><span class="n">cache_table</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">select_expression</span><span class="p">,</span> <span class="n">lazy</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="n">options</span> +</span><span id="DataFrame.sql-329"><a href="#DataFrame.sql-329"><span class="linenos">329</span></a> <span class="p">)</span> +</span><span id="DataFrame.sql-330"><a href="#DataFrame.sql-330"><span class="linenos">330</span></a> <span class="c1"># We will drop the "view" if it exists before running the cache table</span> +</span><span id="DataFrame.sql-331"><a href="#DataFrame.sql-331"><span class="linenos">331</span></a> <span class="n">output_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">cache_table</span><span class="p">,</span> <span class="n">exists</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="s2">"VIEW"</span><span class="p">))</span> +</span><span id="DataFrame.sql-332"><a href="#DataFrame.sql-332"><span class="linenos">332</span></a> <span class="k">elif</span> <span class="n">expression_type</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> +</span><span id="DataFrame.sql-333"><a href="#DataFrame.sql-333"><span class="linenos">333</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">output_expression_container</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame.sql-334"><a href="#DataFrame.sql-334"><span class="linenos">334</span></a> <span class="n">expression</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">select_expression</span><span class="p">)</span> +</span><span id="DataFrame.sql-335"><a href="#DataFrame.sql-335"><span class="linenos">335</span></a> <span class="k">elif</span> <span class="n">expression_type</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">:</span> +</span><span id="DataFrame.sql-336"><a href="#DataFrame.sql-336"><span class="linenos">336</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">output_expression_container</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame.sql-337"><a href="#DataFrame.sql-337"><span class="linenos">337</span></a> <span class="n">select_without_ctes</span> <span class="o">=</span> <span class="n">select_expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame.sql-338"><a href="#DataFrame.sql-338"><span class="linenos">338</span></a> <span class="n">select_without_ctes</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"with"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="DataFrame.sql-339"><a href="#DataFrame.sql-339"><span class="linenos">339</span></a> <span class="n">expression</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">select_without_ctes</span><span class="p">)</span> +</span><span id="DataFrame.sql-340"><a href="#DataFrame.sql-340"><span class="linenos">340</span></a> <span class="k">if</span> <span class="n">select_expression</span><span class="o">.</span><span class="n">ctes</span><span class="p">:</span> +</span><span id="DataFrame.sql-341"><a href="#DataFrame.sql-341"><span class="linenos">341</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"with"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">select_expression</span><span class="o">.</span><span class="n">ctes</span><span class="p">))</span> +</span><span id="DataFrame.sql-342"><a href="#DataFrame.sql-342"><span class="linenos">342</span></a> <span class="k">elif</span> <span class="n">expression_type</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> +</span><span id="DataFrame.sql-343"><a href="#DataFrame.sql-343"><span class="linenos">343</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">select_expression</span> +</span><span id="DataFrame.sql-344"><a href="#DataFrame.sql-344"><span class="linenos">344</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame.sql-345"><a href="#DataFrame.sql-345"><span class="linenos">345</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid expression type: </span><span class="si">{</span><span class="n">expression_type</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="DataFrame.sql-346"><a href="#DataFrame.sql-346"><span class="linenos">346</span></a> <span class="n">output_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DataFrame.sql-347"><a href="#DataFrame.sql-347"><span class="linenos">347</span></a> +</span><span id="DataFrame.sql-348"><a href="#DataFrame.sql-348"><span class="linenos">348</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="DataFrame.sql-349"><a href="#DataFrame.sql-349"><span class="linenos">349</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="s2">"dialect"</span><span class="p">:</span> <span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">})</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">output_expressions</span> +</span><span id="DataFrame.sql-350"><a href="#DataFrame.sql-350"><span class="linenos">350</span></a> <span class="p">]</span> </span></pre></div> @@ -1618,8 +1620,8 @@ </div> <a class="headerlink" href="#DataFrame.copy"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.copy-351"><a href="#DataFrame.copy-351"><span class="linenos">351</span></a> <span class="k">def</span> <span class="nf">copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.copy-352"><a href="#DataFrame.copy-352"><span class="linenos">352</span></a> <span class="k">return</span> <span class="n">DataFrame</span><span class="p">(</span><span class="o">**</span><span class="n">object_to_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.copy-352"><a href="#DataFrame.copy-352"><span class="linenos">352</span></a> <span class="k">def</span> <span class="nf">copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.copy-353"><a href="#DataFrame.copy-353"><span class="linenos">353</span></a> <span class="k">return</span> <span class="n">DataFrame</span><span class="p">(</span><span class="o">**</span><span class="n">object_to_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">))</span> </span></pre></div> @@ -1638,43 +1640,43 @@ </div> <a class="headerlink" href="#DataFrame.select"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.select-354"><a href="#DataFrame.select-354"><span class="linenos">354</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> -</span><span id="DataFrame.select-355"><a href="#DataFrame.select-355"><span class="linenos">355</span></a> <span class="k">def</span> <span class="nf">select</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">cols</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.select-356"><a href="#DataFrame.select-356"><span class="linenos">356</span></a> <span class="n">cols</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> -</span><span id="DataFrame.select-357"><a href="#DataFrame.select-357"><span class="linenos">357</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"append"</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"append"</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> -</span><span id="DataFrame.select-358"><a href="#DataFrame.select-358"><span class="linenos">358</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">):</span> -</span><span id="DataFrame.select-359"><a href="#DataFrame.select-359"><span class="linenos">359</span></a> <span class="n">ambiguous_cols</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame.select-360"><a href="#DataFrame.select-360"><span class="linenos">360</span></a> <span class="n">col</span> -</span><span id="DataFrame.select-361"><a href="#DataFrame.select-361"><span class="linenos">361</span></a> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">cols</span> -</span><span id="DataFrame.select-362"><a href="#DataFrame.select-362"><span class="linenos">362</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">col</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">col</span><span class="o">.</span><span class="n">column_expression</span><span class="o">.</span><span class="n">table</span> -</span><span id="DataFrame.select-363"><a href="#DataFrame.select-363"><span class="linenos">363</span></a> <span class="p">]</span> -</span><span id="DataFrame.select-364"><a href="#DataFrame.select-364"><span class="linenos">364</span></a> <span class="k">if</span> <span class="n">ambiguous_cols</span><span class="p">:</span> -</span><span id="DataFrame.select-365"><a href="#DataFrame.select-365"><span class="linenos">365</span></a> <span class="n">join_table_identifiers</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame.select-366"><a href="#DataFrame.select-366"><span class="linenos">366</span></a> <span class="n">x</span><span class="o">.</span><span class="n">this</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">get_tables_from_expression_with_join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DataFrame.select-367"><a href="#DataFrame.select-367"><span class="linenos">367</span></a> <span class="p">]</span> -</span><span id="DataFrame.select-368"><a href="#DataFrame.select-368"><span class="linenos">368</span></a> <span class="n">cte_names_in_join</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">this</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">join_table_identifiers</span><span class="p">]</span> -</span><span id="DataFrame.select-369"><a href="#DataFrame.select-369"><span class="linenos">369</span></a> <span class="c1"># If we have columns that resolve to multiple CTE expressions then we want to use each CTE left-to-right</span> -</span><span id="DataFrame.select-370"><a href="#DataFrame.select-370"><span class="linenos">370</span></a> <span class="c1"># and therefore we allow multiple columns with the same name in the result. This matches the behavior</span> -</span><span id="DataFrame.select-371"><a href="#DataFrame.select-371"><span class="linenos">371</span></a> <span class="c1"># of Spark.</span> -</span><span id="DataFrame.select-372"><a href="#DataFrame.select-372"><span class="linenos">372</span></a> <span class="n">resolved_column_position</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">Column</span><span class="p">,</span> <span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="n">col</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">ambiguous_cols</span><span class="p">}</span> -</span><span id="DataFrame.select-373"><a href="#DataFrame.select-373"><span class="linenos">373</span></a> <span class="k">for</span> <span class="n">ambiguous_col</span> <span class="ow">in</span> <span class="n">ambiguous_cols</span><span class="p">:</span> -</span><span id="DataFrame.select-374"><a href="#DataFrame.select-374"><span class="linenos">374</span></a> <span class="n">ctes_with_column</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame.select-375"><a href="#DataFrame.select-375"><span class="linenos">375</span></a> <span class="n">cte</span> -</span><span id="DataFrame.select-376"><a href="#DataFrame.select-376"><span class="linenos">376</span></a> <span class="k">for</span> <span class="n">cte</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">ctes</span> -</span><span id="DataFrame.select-377"><a href="#DataFrame.select-377"><span class="linenos">377</span></a> <span class="k">if</span> <span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">in</span> <span class="n">cte_names_in_join</span> -</span><span id="DataFrame.select-378"><a href="#DataFrame.select-378"><span class="linenos">378</span></a> <span class="ow">and</span> <span class="n">ambiguous_col</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">in</span> <span class="n">cte</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">named_selects</span> -</span><span id="DataFrame.select-379"><a href="#DataFrame.select-379"><span class="linenos">379</span></a> <span class="p">]</span> -</span><span id="DataFrame.select-380"><a href="#DataFrame.select-380"><span class="linenos">380</span></a> <span class="c1"># Check if there is a CTE with this column that we haven't used before. If so, use it. Otherwise,</span> -</span><span id="DataFrame.select-381"><a href="#DataFrame.select-381"><span class="linenos">381</span></a> <span class="c1"># use the same CTE we used before</span> -</span><span id="DataFrame.select-382"><a href="#DataFrame.select-382"><span class="linenos">382</span></a> <span class="n">cte</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">ctes_with_column</span><span class="p">,</span> <span class="n">resolved_column_position</span><span class="p">[</span><span class="n">ambiguous_col</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="DataFrame.select-383"><a href="#DataFrame.select-383"><span class="linenos">383</span></a> <span class="k">if</span> <span class="n">cte</span><span class="p">:</span> -</span><span id="DataFrame.select-384"><a href="#DataFrame.select-384"><span class="linenos">384</span></a> <span class="n">resolved_column_position</span><span class="p">[</span><span class="n">ambiguous_col</span><span class="p">]</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="DataFrame.select-385"><a href="#DataFrame.select-385"><span class="linenos">385</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame.select-386"><a href="#DataFrame.select-386"><span class="linenos">386</span></a> <span class="n">cte</span> <span class="o">=</span> <span class="n">ctes_with_column</span><span class="p">[</span><span class="n">resolved_column_position</span><span class="p">[</span><span class="n">ambiguous_col</span><span class="p">]]</span> -</span><span id="DataFrame.select-387"><a href="#DataFrame.select-387"><span class="linenos">387</span></a> <span class="n">ambiguous_col</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"table"</span><span class="p">,</span> <span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">)</span> -</span><span id="DataFrame.select-388"><a href="#DataFrame.select-388"><span class="linenos">388</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span> -</span><span id="DataFrame.select-389"><a href="#DataFrame.select-389"><span class="linenos">389</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">expression</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">cols</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span> -</span><span id="DataFrame.select-390"><a href="#DataFrame.select-390"><span class="linenos">390</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.select-355"><a href="#DataFrame.select-355"><span class="linenos">355</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> +</span><span id="DataFrame.select-356"><a href="#DataFrame.select-356"><span class="linenos">356</span></a> <span class="k">def</span> <span class="nf">select</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">cols</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.select-357"><a href="#DataFrame.select-357"><span class="linenos">357</span></a> <span class="n">cols</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> +</span><span id="DataFrame.select-358"><a href="#DataFrame.select-358"><span class="linenos">358</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"append"</span><span class="p">]</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"append"</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> +</span><span id="DataFrame.select-359"><a href="#DataFrame.select-359"><span class="linenos">359</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">):</span> +</span><span id="DataFrame.select-360"><a href="#DataFrame.select-360"><span class="linenos">360</span></a> <span class="n">ambiguous_cols</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame.select-361"><a href="#DataFrame.select-361"><span class="linenos">361</span></a> <span class="n">col</span> +</span><span id="DataFrame.select-362"><a href="#DataFrame.select-362"><span class="linenos">362</span></a> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">cols</span> +</span><span id="DataFrame.select-363"><a href="#DataFrame.select-363"><span class="linenos">363</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">col</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">col</span><span class="o">.</span><span class="n">column_expression</span><span class="o">.</span><span class="n">table</span> +</span><span id="DataFrame.select-364"><a href="#DataFrame.select-364"><span class="linenos">364</span></a> <span class="p">]</span> +</span><span id="DataFrame.select-365"><a href="#DataFrame.select-365"><span class="linenos">365</span></a> <span class="k">if</span> <span class="n">ambiguous_cols</span><span class="p">:</span> +</span><span id="DataFrame.select-366"><a href="#DataFrame.select-366"><span class="linenos">366</span></a> <span class="n">join_table_identifiers</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame.select-367"><a href="#DataFrame.select-367"><span class="linenos">367</span></a> <span class="n">x</span><span class="o">.</span><span class="n">this</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">get_tables_from_expression_with_join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DataFrame.select-368"><a href="#DataFrame.select-368"><span class="linenos">368</span></a> <span class="p">]</span> +</span><span id="DataFrame.select-369"><a href="#DataFrame.select-369"><span class="linenos">369</span></a> <span class="n">cte_names_in_join</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">this</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">join_table_identifiers</span><span class="p">]</span> +</span><span id="DataFrame.select-370"><a href="#DataFrame.select-370"><span class="linenos">370</span></a> <span class="c1"># If we have columns that resolve to multiple CTE expressions then we want to use each CTE left-to-right</span> +</span><span id="DataFrame.select-371"><a href="#DataFrame.select-371"><span class="linenos">371</span></a> <span class="c1"># and therefore we allow multiple columns with the same name in the result. This matches the behavior</span> +</span><span id="DataFrame.select-372"><a href="#DataFrame.select-372"><span class="linenos">372</span></a> <span class="c1"># of Spark.</span> +</span><span id="DataFrame.select-373"><a href="#DataFrame.select-373"><span class="linenos">373</span></a> <span class="n">resolved_column_position</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">Column</span><span class="p">,</span> <span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="n">col</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">ambiguous_cols</span><span class="p">}</span> +</span><span id="DataFrame.select-374"><a href="#DataFrame.select-374"><span class="linenos">374</span></a> <span class="k">for</span> <span class="n">ambiguous_col</span> <span class="ow">in</span> <span class="n">ambiguous_cols</span><span class="p">:</span> +</span><span id="DataFrame.select-375"><a href="#DataFrame.select-375"><span class="linenos">375</span></a> <span class="n">ctes_with_column</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame.select-376"><a href="#DataFrame.select-376"><span class="linenos">376</span></a> <span class="n">cte</span> +</span><span id="DataFrame.select-377"><a href="#DataFrame.select-377"><span class="linenos">377</span></a> <span class="k">for</span> <span class="n">cte</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">ctes</span> +</span><span id="DataFrame.select-378"><a href="#DataFrame.select-378"><span class="linenos">378</span></a> <span class="k">if</span> <span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">in</span> <span class="n">cte_names_in_join</span> +</span><span id="DataFrame.select-379"><a href="#DataFrame.select-379"><span class="linenos">379</span></a> <span class="ow">and</span> <span class="n">ambiguous_col</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">in</span> <span class="n">cte</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">named_selects</span> +</span><span id="DataFrame.select-380"><a href="#DataFrame.select-380"><span class="linenos">380</span></a> <span class="p">]</span> +</span><span id="DataFrame.select-381"><a href="#DataFrame.select-381"><span class="linenos">381</span></a> <span class="c1"># Check if there is a CTE with this column that we haven't used before. If so, use it. Otherwise,</span> +</span><span id="DataFrame.select-382"><a href="#DataFrame.select-382"><span class="linenos">382</span></a> <span class="c1"># use the same CTE we used before</span> +</span><span id="DataFrame.select-383"><a href="#DataFrame.select-383"><span class="linenos">383</span></a> <span class="n">cte</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">ctes_with_column</span><span class="p">,</span> <span class="n">resolved_column_position</span><span class="p">[</span><span class="n">ambiguous_col</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="DataFrame.select-384"><a href="#DataFrame.select-384"><span class="linenos">384</span></a> <span class="k">if</span> <span class="n">cte</span><span class="p">:</span> +</span><span id="DataFrame.select-385"><a href="#DataFrame.select-385"><span class="linenos">385</span></a> <span class="n">resolved_column_position</span><span class="p">[</span><span class="n">ambiguous_col</span><span class="p">]</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="DataFrame.select-386"><a href="#DataFrame.select-386"><span class="linenos">386</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame.select-387"><a href="#DataFrame.select-387"><span class="linenos">387</span></a> <span class="n">cte</span> <span class="o">=</span> <span class="n">ctes_with_column</span><span class="p">[</span><span class="n">resolved_column_position</span><span class="p">[</span><span class="n">ambiguous_col</span><span class="p">]]</span> +</span><span id="DataFrame.select-388"><a href="#DataFrame.select-388"><span class="linenos">388</span></a> <span class="n">ambiguous_col</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"table"</span><span class="p">,</span> <span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">)</span> +</span><span id="DataFrame.select-389"><a href="#DataFrame.select-389"><span class="linenos">389</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span> +</span><span id="DataFrame.select-390"><a href="#DataFrame.select-390"><span class="linenos">390</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">expression</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">cols</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span> +</span><span id="DataFrame.select-391"><a href="#DataFrame.select-391"><span class="linenos">391</span></a> <span class="p">)</span> </span></pre></div> @@ -1693,16 +1695,16 @@ </div> <a class="headerlink" href="#DataFrame.alias"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.alias-392"><a href="#DataFrame.alias-392"><span class="linenos">392</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> -</span><span id="DataFrame.alias-393"><a href="#DataFrame.alias-393"><span class="linenos">393</span></a> <span class="k">def</span> <span class="nf">alias</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.alias-394"><a href="#DataFrame.alias-394"><span class="linenos">394</span></a> <span class="n">new_sequence_id</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">spark</span><span class="o">.</span><span class="n">_random_sequence_id</span> -</span><span id="DataFrame.alias-395"><a href="#DataFrame.alias-395"><span class="linenos">395</span></a> <span class="n">df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame.alias-396"><a href="#DataFrame.alias-396"><span class="linenos">396</span></a> <span class="k">for</span> <span class="n">join_hint</span> <span class="ow">in</span> <span class="n">df</span><span class="o">.</span><span class="n">pending_join_hints</span><span class="p">:</span> -</span><span id="DataFrame.alias-397"><a href="#DataFrame.alias-397"><span class="linenos">397</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">join_hint</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="DataFrame.alias-398"><a href="#DataFrame.alias-398"><span class="linenos">398</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">sequence_id</span><span class="p">:</span> -</span><span id="DataFrame.alias-399"><a href="#DataFrame.alias-399"><span class="linenos">399</span></a> <span class="n">expression</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">Column</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">new_sequence_id</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DataFrame.alias-400"><a href="#DataFrame.alias-400"><span class="linenos">400</span></a> <span class="n">df</span><span class="o">.</span><span class="n">spark</span><span class="o">.</span><span class="n">_add_alias_to_mapping</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">new_sequence_id</span><span class="p">)</span> -</span><span id="DataFrame.alias-401"><a href="#DataFrame.alias-401"><span class="linenos">401</span></a> <span class="k">return</span> <span class="n">df</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">(</span><span class="n">sequence_id</span><span class="o">=</span><span class="n">new_sequence_id</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.alias-393"><a href="#DataFrame.alias-393"><span class="linenos">393</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> +</span><span id="DataFrame.alias-394"><a href="#DataFrame.alias-394"><span class="linenos">394</span></a> <span class="k">def</span> <span class="nf">alias</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.alias-395"><a href="#DataFrame.alias-395"><span class="linenos">395</span></a> <span class="n">new_sequence_id</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">spark</span><span class="o">.</span><span class="n">_random_sequence_id</span> +</span><span id="DataFrame.alias-396"><a href="#DataFrame.alias-396"><span class="linenos">396</span></a> <span class="n">df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame.alias-397"><a href="#DataFrame.alias-397"><span class="linenos">397</span></a> <span class="k">for</span> <span class="n">join_hint</span> <span class="ow">in</span> <span class="n">df</span><span class="o">.</span><span class="n">pending_join_hints</span><span class="p">:</span> +</span><span id="DataFrame.alias-398"><a href="#DataFrame.alias-398"><span class="linenos">398</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">join_hint</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="DataFrame.alias-399"><a href="#DataFrame.alias-399"><span class="linenos">399</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">sequence_id</span><span class="p">:</span> +</span><span id="DataFrame.alias-400"><a href="#DataFrame.alias-400"><span class="linenos">400</span></a> <span class="n">expression</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">Column</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">new_sequence_id</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DataFrame.alias-401"><a href="#DataFrame.alias-401"><span class="linenos">401</span></a> <span class="n">df</span><span class="o">.</span><span class="n">spark</span><span class="o">.</span><span class="n">_add_alias_to_mapping</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">new_sequence_id</span><span class="p">)</span> +</span><span id="DataFrame.alias-402"><a href="#DataFrame.alias-402"><span class="linenos">402</span></a> <span class="k">return</span> <span class="n">df</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">(</span><span class="n">sequence_id</span><span class="o">=</span><span class="n">new_sequence_id</span><span class="p">)</span> </span></pre></div> @@ -1721,10 +1723,10 @@ </div> <a class="headerlink" href="#DataFrame.where"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.where-403"><a href="#DataFrame.where-403"><span class="linenos">403</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">WHERE</span><span class="p">)</span> -</span><span id="DataFrame.where-404"><a href="#DataFrame.where-404"><span class="linenos">404</span></a> <span class="k">def</span> <span class="nf">where</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">column</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">Column</span><span class="p">,</span> <span class="nb">bool</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.where-405"><a href="#DataFrame.where-405"><span class="linenos">405</span></a> <span class="n">col</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_col</span><span class="p">(</span><span class="n">column</span><span class="p">)</span> -</span><span id="DataFrame.where-406"><a href="#DataFrame.where-406"><span class="linenos">406</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">col</span><span class="o">.</span><span class="n">expression</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.where-404"><a href="#DataFrame.where-404"><span class="linenos">404</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">WHERE</span><span class="p">)</span> +</span><span id="DataFrame.where-405"><a href="#DataFrame.where-405"><span class="linenos">405</span></a> <span class="k">def</span> <span class="nf">where</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">column</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">Column</span><span class="p">,</span> <span class="nb">bool</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.where-406"><a href="#DataFrame.where-406"><span class="linenos">406</span></a> <span class="n">col</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_col</span><span class="p">(</span><span class="n">column</span><span class="p">)</span> +</span><span id="DataFrame.where-407"><a href="#DataFrame.where-407"><span class="linenos">407</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">col</span><span class="o">.</span><span class="n">expression</span><span class="p">))</span> </span></pre></div> @@ -1743,10 +1745,10 @@ </div> <a class="headerlink" href="#DataFrame.filter"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.filter-403"><a href="#DataFrame.filter-403"><span class="linenos">403</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">WHERE</span><span class="p">)</span> -</span><span id="DataFrame.filter-404"><a href="#DataFrame.filter-404"><span class="linenos">404</span></a> <span class="k">def</span> <span class="nf">where</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">column</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">Column</span><span class="p">,</span> <span class="nb">bool</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.filter-405"><a href="#DataFrame.filter-405"><span class="linenos">405</span></a> <span class="n">col</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_col</span><span class="p">(</span><span class="n">column</span><span class="p">)</span> -</span><span id="DataFrame.filter-406"><a href="#DataFrame.filter-406"><span class="linenos">406</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">col</span><span class="o">.</span><span class="n">expression</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.filter-404"><a href="#DataFrame.filter-404"><span class="linenos">404</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">WHERE</span><span class="p">)</span> +</span><span id="DataFrame.filter-405"><a href="#DataFrame.filter-405"><span class="linenos">405</span></a> <span class="k">def</span> <span class="nf">where</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">column</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">Column</span><span class="p">,</span> <span class="nb">bool</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.filter-406"><a href="#DataFrame.filter-406"><span class="linenos">406</span></a> <span class="n">col</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_col</span><span class="p">(</span><span class="n">column</span><span class="p">)</span> +</span><span id="DataFrame.filter-407"><a href="#DataFrame.filter-407"><span class="linenos">407</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">col</span><span class="o">.</span><span class="n">expression</span><span class="p">))</span> </span></pre></div> @@ -1765,10 +1767,10 @@ </div> <a class="headerlink" href="#DataFrame.groupBy"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.groupBy-410"><a href="#DataFrame.groupBy-410"><span class="linenos">410</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">GROUP_BY</span><span class="p">)</span> -</span><span id="DataFrame.groupBy-411"><a href="#DataFrame.groupBy-411"><span class="linenos">411</span></a> <span class="k">def</span> <span class="nf">groupBy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">cols</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">GroupedData</span><span class="p">:</span> -</span><span id="DataFrame.groupBy-412"><a href="#DataFrame.groupBy-412"><span class="linenos">412</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> -</span><span id="DataFrame.groupBy-413"><a href="#DataFrame.groupBy-413"><span class="linenos">413</span></a> <span class="k">return</span> <span class="n">GroupedData</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">columns</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">last_op</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.groupBy-411"><a href="#DataFrame.groupBy-411"><span class="linenos">411</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">GROUP_BY</span><span class="p">)</span> +</span><span id="DataFrame.groupBy-412"><a href="#DataFrame.groupBy-412"><span class="linenos">412</span></a> <span class="k">def</span> <span class="nf">groupBy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">cols</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">GroupedData</span><span class="p">:</span> +</span><span id="DataFrame.groupBy-413"><a href="#DataFrame.groupBy-413"><span class="linenos">413</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> +</span><span id="DataFrame.groupBy-414"><a href="#DataFrame.groupBy-414"><span class="linenos">414</span></a> <span class="k">return</span> <span class="n">GroupedData</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">columns</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">last_op</span><span class="p">)</span> </span></pre></div> @@ -1787,10 +1789,10 @@ </div> <a class="headerlink" href="#DataFrame.agg"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.agg-415"><a href="#DataFrame.agg-415"><span class="linenos">415</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> -</span><span id="DataFrame.agg-416"><a href="#DataFrame.agg-416"><span class="linenos">416</span></a> <span class="k">def</span> <span class="nf">agg</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">exprs</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.agg-417"><a href="#DataFrame.agg-417"><span class="linenos">417</span></a> <span class="n">cols</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">exprs</span><span class="p">)</span> -</span><span id="DataFrame.agg-418"><a href="#DataFrame.agg-418"><span class="linenos">418</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">groupBy</span><span class="p">()</span><span class="o">.</span><span class="n">agg</span><span class="p">(</span><span class="o">*</span><span class="n">cols</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.agg-416"><a href="#DataFrame.agg-416"><span class="linenos">416</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> +</span><span id="DataFrame.agg-417"><a href="#DataFrame.agg-417"><span class="linenos">417</span></a> <span class="k">def</span> <span class="nf">agg</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">exprs</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.agg-418"><a href="#DataFrame.agg-418"><span class="linenos">418</span></a> <span class="n">cols</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">exprs</span><span class="p">)</span> +</span><span id="DataFrame.agg-419"><a href="#DataFrame.agg-419"><span class="linenos">419</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">groupBy</span><span class="p">()</span><span class="o">.</span><span class="n">agg</span><span class="p">(</span><span class="o">*</span><span class="n">cols</span><span class="p">)</span> </span></pre></div> @@ -1809,97 +1811,97 @@ </div> <a class="headerlink" href="#DataFrame.join"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.join-420"><a href="#DataFrame.join-420"><span class="linenos">420</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> -</span><span id="DataFrame.join-421"><a href="#DataFrame.join-421"><span class="linenos">421</span></a> <span class="k">def</span> <span class="nf">join</span><span class="p">(</span> -</span><span id="DataFrame.join-422"><a href="#DataFrame.join-422"><span class="linenos">422</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DataFrame.join-423"><a href="#DataFrame.join-423"><span class="linenos">423</span></a> <span class="n">other_df</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> -</span><span id="DataFrame.join-424"><a href="#DataFrame.join-424"><span class="linenos">424</span></a> <span class="n">on</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">Column</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">Column</span><span class="p">]],</span> -</span><span id="DataFrame.join-425"><a href="#DataFrame.join-425"><span class="linenos">425</span></a> <span class="n">how</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"inner"</span><span class="p">,</span> -</span><span id="DataFrame.join-426"><a href="#DataFrame.join-426"><span class="linenos">426</span></a> <span class="o">**</span><span class="n">kwargs</span><span class="p">,</span> -</span><span id="DataFrame.join-427"><a href="#DataFrame.join-427"><span class="linenos">427</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.join-428"><a href="#DataFrame.join-428"><span class="linenos">428</span></a> <span class="n">other_df</span> <span class="o">=</span> <span class="n">other_df</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">()</span> -</span><span id="DataFrame.join-429"><a href="#DataFrame.join-429"><span class="linenos">429</span></a> <span class="n">join_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">on</span><span class="p">)</span> -</span><span id="DataFrame.join-430"><a href="#DataFrame.join-430"><span class="linenos">430</span></a> <span class="c1"># We will determine actual "join on" expression later so we don't provide it at first</span> -</span><span id="DataFrame.join-431"><a href="#DataFrame.join-431"><span class="linenos">431</span></a> <span class="n">join_expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="DataFrame.join-432"><a href="#DataFrame.join-432"><span class="linenos">432</span></a> <span class="n">other_df</span><span class="o">.</span><span class="n">latest_cte_name</span><span class="p">,</span> <span class="n">join_type</span><span class="o">=</span><span class="n">how</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"_"</span><span class="p">,</span> <span class="s2">" "</span><span class="p">)</span> -</span><span id="DataFrame.join-433"><a href="#DataFrame.join-433"><span class="linenos">433</span></a> <span class="p">)</span> -</span><span id="DataFrame.join-434"><a href="#DataFrame.join-434"><span class="linenos">434</span></a> <span class="n">join_expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add_ctes_to_expression</span><span class="p">(</span><span class="n">join_expression</span><span class="p">,</span> <span class="n">other_df</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">ctes</span><span class="p">)</span> -</span><span id="DataFrame.join-435"><a href="#DataFrame.join-435"><span class="linenos">435</span></a> <span class="n">self_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">join_expression</span><span class="p">)</span> -</span><span id="DataFrame.join-436"><a href="#DataFrame.join-436"><span class="linenos">436</span></a> <span class="n">other_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">other_df</span><span class="p">)</span> -</span><span id="DataFrame.join-437"><a href="#DataFrame.join-437"><span class="linenos">437</span></a> <span class="c1"># Determines the join clause and select columns to be used passed on what type of columns were provided for</span> -</span><span id="DataFrame.join-438"><a href="#DataFrame.join-438"><span class="linenos">438</span></a> <span class="c1"># the join. The columns returned changes based on how the on expression is provided.</span> -</span><span id="DataFrame.join-439"><a href="#DataFrame.join-439"><span class="linenos">439</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">join_columns</span><span class="p">[</span><span class="mi">0</span><span class="p">]</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">Column</span><span class="p">):</span> -</span><span id="DataFrame.join-440"><a href="#DataFrame.join-440"><span class="linenos">440</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="DataFrame.join-441"><a href="#DataFrame.join-441"><span class="linenos">441</span></a><span class="sd"> Unique characteristics of join on column names only:</span> -</span><span id="DataFrame.join-442"><a href="#DataFrame.join-442"><span class="linenos">442</span></a><span class="sd"> * The column names are put at the front of the select list</span> -</span><span id="DataFrame.join-443"><a href="#DataFrame.join-443"><span class="linenos">443</span></a><span class="sd"> * The column names are deduplicated across the entire select list and only the column names (other dups are allowed)</span> -</span><span id="DataFrame.join-444"><a href="#DataFrame.join-444"><span class="linenos">444</span></a><span class="sd"> """</span> -</span><span id="DataFrame.join-445"><a href="#DataFrame.join-445"><span class="linenos">445</span></a> <span class="n">table_names</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame.join-446"><a href="#DataFrame.join-446"><span class="linenos">446</span></a> <span class="n">table</span><span class="o">.</span><span class="n">alias_or_name</span> -</span><span id="DataFrame.join-447"><a href="#DataFrame.join-447"><span class="linenos">447</span></a> <span class="k">for</span> <span class="n">table</span> <span class="ow">in</span> <span class="n">get_tables_from_expression_with_join</span><span class="p">(</span><span class="n">join_expression</span><span class="p">)</span> -</span><span id="DataFrame.join-448"><a href="#DataFrame.join-448"><span class="linenos">448</span></a> <span class="p">]</span> -</span><span id="DataFrame.join-449"><a href="#DataFrame.join-449"><span class="linenos">449</span></a> <span class="n">potential_ctes</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame.join-450"><a href="#DataFrame.join-450"><span class="linenos">450</span></a> <span class="n">cte</span> -</span><span id="DataFrame.join-451"><a href="#DataFrame.join-451"><span class="linenos">451</span></a> <span class="k">for</span> <span class="n">cte</span> <span class="ow">in</span> <span class="n">join_expression</span><span class="o">.</span><span class="n">ctes</span> -</span><span id="DataFrame.join-452"><a href="#DataFrame.join-452"><span class="linenos">452</span></a> <span class="k">if</span> <span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">in</span> <span class="n">table_names</span> -</span><span id="DataFrame.join-453"><a href="#DataFrame.join-453"><span class="linenos">453</span></a> <span class="ow">and</span> <span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="o">!=</span> <span class="n">other_df</span><span class="o">.</span><span class="n">latest_cte_name</span> -</span><span id="DataFrame.join-454"><a href="#DataFrame.join-454"><span class="linenos">454</span></a> <span class="p">]</span> -</span><span id="DataFrame.join-455"><a href="#DataFrame.join-455"><span class="linenos">455</span></a> <span class="c1"># Determine the table to reference for the left side of the join by checking each of the left side</span> -</span><span id="DataFrame.join-456"><a href="#DataFrame.join-456"><span class="linenos">456</span></a> <span class="c1"># tables and see if they have the column being referenced.</span> -</span><span id="DataFrame.join-457"><a href="#DataFrame.join-457"><span class="linenos">457</span></a> <span class="n">join_column_pairs</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="DataFrame.join-458"><a href="#DataFrame.join-458"><span class="linenos">458</span></a> <span class="k">for</span> <span class="n">join_column</span> <span class="ow">in</span> <span class="n">join_columns</span><span class="p">:</span> -</span><span id="DataFrame.join-459"><a href="#DataFrame.join-459"><span class="linenos">459</span></a> <span class="n">num_matching_ctes</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="DataFrame.join-460"><a href="#DataFrame.join-460"><span class="linenos">460</span></a> <span class="k">for</span> <span class="n">cte</span> <span class="ow">in</span> <span class="n">potential_ctes</span><span class="p">:</span> -</span><span id="DataFrame.join-461"><a href="#DataFrame.join-461"><span class="linenos">461</span></a> <span class="k">if</span> <span class="n">join_column</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">in</span> <span class="n">cte</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">named_selects</span><span class="p">:</span> -</span><span id="DataFrame.join-462"><a href="#DataFrame.join-462"><span class="linenos">462</span></a> <span class="n">left_column</span> <span class="o">=</span> <span class="n">join_column</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">set_table_name</span><span class="p">(</span><span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">)</span> -</span><span id="DataFrame.join-463"><a href="#DataFrame.join-463"><span class="linenos">463</span></a> <span class="n">right_column</span> <span class="o">=</span> <span class="n">join_column</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">set_table_name</span><span class="p">(</span><span class="n">other_df</span><span class="o">.</span><span class="n">latest_cte_name</span><span class="p">)</span> -</span><span id="DataFrame.join-464"><a href="#DataFrame.join-464"><span class="linenos">464</span></a> <span class="n">join_column_pairs</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">left_column</span><span class="p">,</span> <span class="n">right_column</span><span class="p">))</span> -</span><span id="DataFrame.join-465"><a href="#DataFrame.join-465"><span class="linenos">465</span></a> <span class="n">num_matching_ctes</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="DataFrame.join-466"><a href="#DataFrame.join-466"><span class="linenos">466</span></a> <span class="k">if</span> <span class="n">num_matching_ctes</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="DataFrame.join-467"><a href="#DataFrame.join-467"><span class="linenos">467</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span> -</span><span id="DataFrame.join-468"><a href="#DataFrame.join-468"><span class="linenos">468</span></a> <span class="sa">f</span><span class="s2">"Column </span><span class="si">{</span><span class="n">join_column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="si">}</span><span class="s2"> is ambiguous. Please specify the table name."</span> -</span><span id="DataFrame.join-469"><a href="#DataFrame.join-469"><span class="linenos">469</span></a> <span class="p">)</span> -</span><span id="DataFrame.join-470"><a href="#DataFrame.join-470"><span class="linenos">470</span></a> <span class="k">elif</span> <span class="n">num_matching_ctes</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> -</span><span id="DataFrame.join-471"><a href="#DataFrame.join-471"><span class="linenos">471</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span> -</span><span id="DataFrame.join-472"><a href="#DataFrame.join-472"><span class="linenos">472</span></a> <span class="sa">f</span><span class="s2">"Column </span><span class="si">{</span><span class="n">join_column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="si">}</span><span class="s2"> does not exist in any of the tables."</span> -</span><span id="DataFrame.join-473"><a href="#DataFrame.join-473"><span class="linenos">473</span></a> <span class="p">)</span> -</span><span id="DataFrame.join-474"><a href="#DataFrame.join-474"><span class="linenos">474</span></a> <span class="n">join_clause</span> <span class="o">=</span> <span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span> -</span><span id="DataFrame.join-475"><a href="#DataFrame.join-475"><span class="linenos">475</span></a> <span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span> <span class="o">&</span> <span class="n">y</span><span class="p">,</span> -</span><span id="DataFrame.join-476"><a href="#DataFrame.join-476"><span class="linenos">476</span></a> <span class="p">[</span><span class="n">left_column</span> <span class="o">==</span> <span class="n">right_column</span> <span class="k">for</span> <span class="n">left_column</span><span class="p">,</span> <span class="n">right_column</span> <span class="ow">in</span> <span class="n">join_column_pairs</span><span class="p">],</span> -</span><span id="DataFrame.join-477"><a href="#DataFrame.join-477"><span class="linenos">477</span></a> <span class="p">)</span> -</span><span id="DataFrame.join-478"><a href="#DataFrame.join-478"><span class="linenos">478</span></a> <span class="n">join_column_names</span> <span class="o">=</span> <span class="p">[</span><span class="n">left_col</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="k">for</span> <span class="n">left_col</span><span class="p">,</span> <span class="n">_</span> <span class="ow">in</span> <span class="n">join_column_pairs</span><span class="p">]</span> -</span><span id="DataFrame.join-479"><a href="#DataFrame.join-479"><span class="linenos">479</span></a> <span class="c1"># To match spark behavior only the join clause gets deduplicated and it gets put in the front of the column list</span> -</span><span id="DataFrame.join-480"><a href="#DataFrame.join-480"><span class="linenos">480</span></a> <span class="n">select_column_names</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame.join-481"><a href="#DataFrame.join-481"><span class="linenos">481</span></a> <span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span> -</span><span id="DataFrame.join-482"><a href="#DataFrame.join-482"><span class="linenos">482</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">)</span> -</span><span id="DataFrame.join-483"><a href="#DataFrame.join-483"><span class="linenos">483</span></a> <span class="k">else</span> <span class="n">column</span><span class="o">.</span><span class="n">sql</span><span class="p">()</span> -</span><span id="DataFrame.join-484"><a href="#DataFrame.join-484"><span class="linenos">484</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">self_columns</span> <span class="o">+</span> <span class="n">other_columns</span> -</span><span id="DataFrame.join-485"><a href="#DataFrame.join-485"><span class="linenos">485</span></a> <span class="p">]</span> -</span><span id="DataFrame.join-486"><a href="#DataFrame.join-486"><span class="linenos">486</span></a> <span class="n">select_column_names</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame.join-487"><a href="#DataFrame.join-487"><span class="linenos">487</span></a> <span class="n">column_name</span> -</span><span id="DataFrame.join-488"><a href="#DataFrame.join-488"><span class="linenos">488</span></a> <span class="k">for</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="n">select_column_names</span> -</span><span id="DataFrame.join-489"><a href="#DataFrame.join-489"><span class="linenos">489</span></a> <span class="k">if</span> <span class="n">column_name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">join_column_names</span> -</span><span id="DataFrame.join-490"><a href="#DataFrame.join-490"><span class="linenos">490</span></a> <span class="p">]</span> -</span><span id="DataFrame.join-491"><a href="#DataFrame.join-491"><span class="linenos">491</span></a> <span class="n">select_column_names</span> <span class="o">=</span> <span class="n">join_column_names</span> <span class="o">+</span> <span class="n">select_column_names</span> -</span><span id="DataFrame.join-492"><a href="#DataFrame.join-492"><span class="linenos">492</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame.join-493"><a href="#DataFrame.join-493"><span class="linenos">493</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="DataFrame.join-494"><a href="#DataFrame.join-494"><span class="linenos">494</span></a><span class="sd"> Unique characteristics of join on expressions:</span> -</span><span id="DataFrame.join-495"><a href="#DataFrame.join-495"><span class="linenos">495</span></a><span class="sd"> * There is no deduplication of the results.</span> -</span><span id="DataFrame.join-496"><a href="#DataFrame.join-496"><span class="linenos">496</span></a><span class="sd"> * The left join dataframe columns go first and right come after. No sort preference is given to join columns</span> -</span><span id="DataFrame.join-497"><a href="#DataFrame.join-497"><span class="linenos">497</span></a><span class="sd"> """</span> -</span><span id="DataFrame.join-498"><a href="#DataFrame.join-498"><span class="linenos">498</span></a> <span class="n">join_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">join_columns</span><span class="p">,</span> <span class="n">join_expression</span><span class="p">)</span> -</span><span id="DataFrame.join-499"><a href="#DataFrame.join-499"><span class="linenos">499</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">join_columns</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="DataFrame.join-500"><a href="#DataFrame.join-500"><span class="linenos">500</span></a> <span class="n">join_columns</span> <span class="o">=</span> <span class="p">[</span><span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span> <span class="o">&</span> <span class="n">y</span><span class="p">,</span> <span class="n">join_columns</span><span class="p">)]</span> -</span><span id="DataFrame.join-501"><a href="#DataFrame.join-501"><span class="linenos">501</span></a> <span class="n">join_clause</span> <span class="o">=</span> <span class="n">join_columns</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="DataFrame.join-502"><a href="#DataFrame.join-502"><span class="linenos">502</span></a> <span class="n">select_column_names</span> <span class="o">=</span> <span class="p">[</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">self_columns</span> <span class="o">+</span> <span class="n">other_columns</span><span class="p">]</span> -</span><span id="DataFrame.join-503"><a href="#DataFrame.join-503"><span class="linenos">503</span></a> -</span><span id="DataFrame.join-504"><a href="#DataFrame.join-504"><span class="linenos">504</span></a> <span class="c1"># Update the on expression with the actual join clause to replace the dummy one from before</span> -</span><span id="DataFrame.join-505"><a href="#DataFrame.join-505"><span class="linenos">505</span></a> <span class="n">join_expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"joins"</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"on"</span><span class="p">,</span> <span class="n">join_clause</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DataFrame.join-506"><a href="#DataFrame.join-506"><span class="linenos">506</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">join_expression</span><span class="p">)</span> -</span><span id="DataFrame.join-507"><a href="#DataFrame.join-507"><span class="linenos">507</span></a> <span class="n">new_df</span><span class="o">.</span><span class="n">pending_join_hints</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">pending_join_hints</span><span class="p">)</span> -</span><span id="DataFrame.join-508"><a href="#DataFrame.join-508"><span class="linenos">508</span></a> <span class="n">new_df</span><span class="o">.</span><span class="n">pending_hints</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">other_df</span><span class="o">.</span><span class="n">pending_hints</span><span class="p">)</span> -</span><span id="DataFrame.join-509"><a href="#DataFrame.join-509"><span class="linenos">509</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">select</span><span class="o">.</span><span class="n">__wrapped__</span><span class="p">(</span><span class="n">new_df</span><span class="p">,</span> <span class="o">*</span><span class="n">select_column_names</span><span class="p">)</span> -</span><span id="DataFrame.join-510"><a href="#DataFrame.join-510"><span class="linenos">510</span></a> <span class="k">return</span> <span class="n">new_df</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.join-421"><a href="#DataFrame.join-421"><span class="linenos">421</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> +</span><span id="DataFrame.join-422"><a href="#DataFrame.join-422"><span class="linenos">422</span></a> <span class="k">def</span> <span class="nf">join</span><span class="p">(</span> +</span><span id="DataFrame.join-423"><a href="#DataFrame.join-423"><span class="linenos">423</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DataFrame.join-424"><a href="#DataFrame.join-424"><span class="linenos">424</span></a> <span class="n">other_df</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> +</span><span id="DataFrame.join-425"><a href="#DataFrame.join-425"><span class="linenos">425</span></a> <span class="n">on</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">Column</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">Column</span><span class="p">]],</span> +</span><span id="DataFrame.join-426"><a href="#DataFrame.join-426"><span class="linenos">426</span></a> <span class="n">how</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"inner"</span><span class="p">,</span> +</span><span id="DataFrame.join-427"><a href="#DataFrame.join-427"><span class="linenos">427</span></a> <span class="o">**</span><span class="n">kwargs</span><span class="p">,</span> +</span><span id="DataFrame.join-428"><a href="#DataFrame.join-428"><span class="linenos">428</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.join-429"><a href="#DataFrame.join-429"><span class="linenos">429</span></a> <span class="n">other_df</span> <span class="o">=</span> <span class="n">other_df</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">()</span> +</span><span id="DataFrame.join-430"><a href="#DataFrame.join-430"><span class="linenos">430</span></a> <span class="n">join_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">on</span><span class="p">)</span> +</span><span id="DataFrame.join-431"><a href="#DataFrame.join-431"><span class="linenos">431</span></a> <span class="c1"># We will determine actual "join on" expression later so we don't provide it at first</span> +</span><span id="DataFrame.join-432"><a href="#DataFrame.join-432"><span class="linenos">432</span></a> <span class="n">join_expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="DataFrame.join-433"><a href="#DataFrame.join-433"><span class="linenos">433</span></a> <span class="n">other_df</span><span class="o">.</span><span class="n">latest_cte_name</span><span class="p">,</span> <span class="n">join_type</span><span class="o">=</span><span class="n">how</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"_"</span><span class="p">,</span> <span class="s2">" "</span><span class="p">)</span> +</span><span id="DataFrame.join-434"><a href="#DataFrame.join-434"><span class="linenos">434</span></a> <span class="p">)</span> +</span><span id="DataFrame.join-435"><a href="#DataFrame.join-435"><span class="linenos">435</span></a> <span class="n">join_expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add_ctes_to_expression</span><span class="p">(</span><span class="n">join_expression</span><span class="p">,</span> <span class="n">other_df</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">ctes</span><span class="p">)</span> +</span><span id="DataFrame.join-436"><a href="#DataFrame.join-436"><span class="linenos">436</span></a> <span class="n">self_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">join_expression</span><span class="p">)</span> +</span><span id="DataFrame.join-437"><a href="#DataFrame.join-437"><span class="linenos">437</span></a> <span class="n">other_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">other_df</span><span class="p">)</span> +</span><span id="DataFrame.join-438"><a href="#DataFrame.join-438"><span class="linenos">438</span></a> <span class="c1"># Determines the join clause and select columns to be used passed on what type of columns were provided for</span> +</span><span id="DataFrame.join-439"><a href="#DataFrame.join-439"><span class="linenos">439</span></a> <span class="c1"># the join. The columns returned changes based on how the on expression is provided.</span> +</span><span id="DataFrame.join-440"><a href="#DataFrame.join-440"><span class="linenos">440</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">join_columns</span><span class="p">[</span><span class="mi">0</span><span class="p">]</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">Column</span><span class="p">):</span> +</span><span id="DataFrame.join-441"><a href="#DataFrame.join-441"><span class="linenos">441</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="DataFrame.join-442"><a href="#DataFrame.join-442"><span class="linenos">442</span></a><span class="sd"> Unique characteristics of join on column names only:</span> +</span><span id="DataFrame.join-443"><a href="#DataFrame.join-443"><span class="linenos">443</span></a><span class="sd"> * The column names are put at the front of the select list</span> +</span><span id="DataFrame.join-444"><a href="#DataFrame.join-444"><span class="linenos">444</span></a><span class="sd"> * The column names are deduplicated across the entire select list and only the column names (other dups are allowed)</span> +</span><span id="DataFrame.join-445"><a href="#DataFrame.join-445"><span class="linenos">445</span></a><span class="sd"> """</span> +</span><span id="DataFrame.join-446"><a href="#DataFrame.join-446"><span class="linenos">446</span></a> <span class="n">table_names</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame.join-447"><a href="#DataFrame.join-447"><span class="linenos">447</span></a> <span class="n">table</span><span class="o">.</span><span class="n">alias_or_name</span> +</span><span id="DataFrame.join-448"><a href="#DataFrame.join-448"><span class="linenos">448</span></a> <span class="k">for</span> <span class="n">table</span> <span class="ow">in</span> <span class="n">get_tables_from_expression_with_join</span><span class="p">(</span><span class="n">join_expression</span><span class="p">)</span> +</span><span id="DataFrame.join-449"><a href="#DataFrame.join-449"><span class="linenos">449</span></a> <span class="p">]</span> +</span><span id="DataFrame.join-450"><a href="#DataFrame.join-450"><span class="linenos">450</span></a> <span class="n">potential_ctes</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame.join-451"><a href="#DataFrame.join-451"><span class="linenos">451</span></a> <span class="n">cte</span> +</span><span id="DataFrame.join-452"><a href="#DataFrame.join-452"><span class="linenos">452</span></a> <span class="k">for</span> <span class="n">cte</span> <span class="ow">in</span> <span class="n">join_expression</span><span class="o">.</span><span class="n">ctes</span> +</span><span id="DataFrame.join-453"><a href="#DataFrame.join-453"><span class="linenos">453</span></a> <span class="k">if</span> <span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">in</span> <span class="n">table_names</span> +</span><span id="DataFrame.join-454"><a href="#DataFrame.join-454"><span class="linenos">454</span></a> <span class="ow">and</span> <span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="o">!=</span> <span class="n">other_df</span><span class="o">.</span><span class="n">latest_cte_name</span> +</span><span id="DataFrame.join-455"><a href="#DataFrame.join-455"><span class="linenos">455</span></a> <span class="p">]</span> +</span><span id="DataFrame.join-456"><a href="#DataFrame.join-456"><span class="linenos">456</span></a> <span class="c1"># Determine the table to reference for the left side of the join by checking each of the left side</span> +</span><span id="DataFrame.join-457"><a href="#DataFrame.join-457"><span class="linenos">457</span></a> <span class="c1"># tables and see if they have the column being referenced.</span> +</span><span id="DataFrame.join-458"><a href="#DataFrame.join-458"><span class="linenos">458</span></a> <span class="n">join_column_pairs</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="DataFrame.join-459"><a href="#DataFrame.join-459"><span class="linenos">459</span></a> <span class="k">for</span> <span class="n">join_column</span> <span class="ow">in</span> <span class="n">join_columns</span><span class="p">:</span> +</span><span id="DataFrame.join-460"><a href="#DataFrame.join-460"><span class="linenos">460</span></a> <span class="n">num_matching_ctes</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="DataFrame.join-461"><a href="#DataFrame.join-461"><span class="linenos">461</span></a> <span class="k">for</span> <span class="n">cte</span> <span class="ow">in</span> <span class="n">potential_ctes</span><span class="p">:</span> +</span><span id="DataFrame.join-462"><a href="#DataFrame.join-462"><span class="linenos">462</span></a> <span class="k">if</span> <span class="n">join_column</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">in</span> <span class="n">cte</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">named_selects</span><span class="p">:</span> +</span><span id="DataFrame.join-463"><a href="#DataFrame.join-463"><span class="linenos">463</span></a> <span class="n">left_column</span> <span class="o">=</span> <span class="n">join_column</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">set_table_name</span><span class="p">(</span><span class="n">cte</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">)</span> +</span><span id="DataFrame.join-464"><a href="#DataFrame.join-464"><span class="linenos">464</span></a> <span class="n">right_column</span> <span class="o">=</span> <span class="n">join_column</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">set_table_name</span><span class="p">(</span><span class="n">other_df</span><span class="o">.</span><span class="n">latest_cte_name</span><span class="p">)</span> +</span><span id="DataFrame.join-465"><a href="#DataFrame.join-465"><span class="linenos">465</span></a> <span class="n">join_column_pairs</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">left_column</span><span class="p">,</span> <span class="n">right_column</span><span class="p">))</span> +</span><span id="DataFrame.join-466"><a href="#DataFrame.join-466"><span class="linenos">466</span></a> <span class="n">num_matching_ctes</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="DataFrame.join-467"><a href="#DataFrame.join-467"><span class="linenos">467</span></a> <span class="k">if</span> <span class="n">num_matching_ctes</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="DataFrame.join-468"><a href="#DataFrame.join-468"><span class="linenos">468</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span> +</span><span id="DataFrame.join-469"><a href="#DataFrame.join-469"><span class="linenos">469</span></a> <span class="sa">f</span><span class="s2">"Column </span><span class="si">{</span><span class="n">join_column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="si">}</span><span class="s2"> is ambiguous. Please specify the table name."</span> +</span><span id="DataFrame.join-470"><a href="#DataFrame.join-470"><span class="linenos">470</span></a> <span class="p">)</span> +</span><span id="DataFrame.join-471"><a href="#DataFrame.join-471"><span class="linenos">471</span></a> <span class="k">elif</span> <span class="n">num_matching_ctes</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> +</span><span id="DataFrame.join-472"><a href="#DataFrame.join-472"><span class="linenos">472</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span> +</span><span id="DataFrame.join-473"><a href="#DataFrame.join-473"><span class="linenos">473</span></a> <span class="sa">f</span><span class="s2">"Column </span><span class="si">{</span><span class="n">join_column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="si">}</span><span class="s2"> does not exist in any of the tables."</span> +</span><span id="DataFrame.join-474"><a href="#DataFrame.join-474"><span class="linenos">474</span></a> <span class="p">)</span> +</span><span id="DataFrame.join-475"><a href="#DataFrame.join-475"><span class="linenos">475</span></a> <span class="n">join_clause</span> <span class="o">=</span> <span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span> +</span><span id="DataFrame.join-476"><a href="#DataFrame.join-476"><span class="linenos">476</span></a> <span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span> <span class="o">&</span> <span class="n">y</span><span class="p">,</span> +</span><span id="DataFrame.join-477"><a href="#DataFrame.join-477"><span class="linenos">477</span></a> <span class="p">[</span><span class="n">left_column</span> <span class="o">==</span> <span class="n">right_column</span> <span class="k">for</span> <span class="n">left_column</span><span class="p">,</span> <span class="n">right_column</span> <span class="ow">in</span> <span class="n">join_column_pairs</span><span class="p">],</span> +</span><span id="DataFrame.join-478"><a href="#DataFrame.join-478"><span class="linenos">478</span></a> <span class="p">)</span> +</span><span id="DataFrame.join-479"><a href="#DataFrame.join-479"><span class="linenos">479</span></a> <span class="n">join_column_names</span> <span class="o">=</span> <span class="p">[</span><span class="n">left_col</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="k">for</span> <span class="n">left_col</span><span class="p">,</span> <span class="n">_</span> <span class="ow">in</span> <span class="n">join_column_pairs</span><span class="p">]</span> +</span><span id="DataFrame.join-480"><a href="#DataFrame.join-480"><span class="linenos">480</span></a> <span class="c1"># To match spark behavior only the join clause gets deduplicated and it gets put in the front of the column list</span> +</span><span id="DataFrame.join-481"><a href="#DataFrame.join-481"><span class="linenos">481</span></a> <span class="n">select_column_names</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame.join-482"><a href="#DataFrame.join-482"><span class="linenos">482</span></a> <span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span> +</span><span id="DataFrame.join-483"><a href="#DataFrame.join-483"><span class="linenos">483</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">)</span> +</span><span id="DataFrame.join-484"><a href="#DataFrame.join-484"><span class="linenos">484</span></a> <span class="k">else</span> <span class="n">column</span><span class="o">.</span><span class="n">sql</span><span class="p">()</span> +</span><span id="DataFrame.join-485"><a href="#DataFrame.join-485"><span class="linenos">485</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">self_columns</span> <span class="o">+</span> <span class="n">other_columns</span> +</span><span id="DataFrame.join-486"><a href="#DataFrame.join-486"><span class="linenos">486</span></a> <span class="p">]</span> +</span><span id="DataFrame.join-487"><a href="#DataFrame.join-487"><span class="linenos">487</span></a> <span class="n">select_column_names</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame.join-488"><a href="#DataFrame.join-488"><span class="linenos">488</span></a> <span class="n">column_name</span> +</span><span id="DataFrame.join-489"><a href="#DataFrame.join-489"><span class="linenos">489</span></a> <span class="k">for</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="n">select_column_names</span> +</span><span id="DataFrame.join-490"><a href="#DataFrame.join-490"><span class="linenos">490</span></a> <span class="k">if</span> <span class="n">column_name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">join_column_names</span> +</span><span id="DataFrame.join-491"><a href="#DataFrame.join-491"><span class="linenos">491</span></a> <span class="p">]</span> +</span><span id="DataFrame.join-492"><a href="#DataFrame.join-492"><span class="linenos">492</span></a> <span class="n">select_column_names</span> <span class="o">=</span> <span class="n">join_column_names</span> <span class="o">+</span> <span class="n">select_column_names</span> +</span><span id="DataFrame.join-493"><a href="#DataFrame.join-493"><span class="linenos">493</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame.join-494"><a href="#DataFrame.join-494"><span class="linenos">494</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="DataFrame.join-495"><a href="#DataFrame.join-495"><span class="linenos">495</span></a><span class="sd"> Unique characteristics of join on expressions:</span> +</span><span id="DataFrame.join-496"><a href="#DataFrame.join-496"><span class="linenos">496</span></a><span class="sd"> * There is no deduplication of the results.</span> +</span><span id="DataFrame.join-497"><a href="#DataFrame.join-497"><span class="linenos">497</span></a><span class="sd"> * The left join dataframe columns go first and right come after. No sort preference is given to join columns</span> +</span><span id="DataFrame.join-498"><a href="#DataFrame.join-498"><span class="linenos">498</span></a><span class="sd"> """</span> +</span><span id="DataFrame.join-499"><a href="#DataFrame.join-499"><span class="linenos">499</span></a> <span class="n">join_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">join_columns</span><span class="p">,</span> <span class="n">join_expression</span><span class="p">)</span> +</span><span id="DataFrame.join-500"><a href="#DataFrame.join-500"><span class="linenos">500</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">join_columns</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="DataFrame.join-501"><a href="#DataFrame.join-501"><span class="linenos">501</span></a> <span class="n">join_columns</span> <span class="o">=</span> <span class="p">[</span><span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span> <span class="o">&</span> <span class="n">y</span><span class="p">,</span> <span class="n">join_columns</span><span class="p">)]</span> +</span><span id="DataFrame.join-502"><a href="#DataFrame.join-502"><span class="linenos">502</span></a> <span class="n">join_clause</span> <span class="o">=</span> <span class="n">join_columns</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="DataFrame.join-503"><a href="#DataFrame.join-503"><span class="linenos">503</span></a> <span class="n">select_column_names</span> <span class="o">=</span> <span class="p">[</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">self_columns</span> <span class="o">+</span> <span class="n">other_columns</span><span class="p">]</span> +</span><span id="DataFrame.join-504"><a href="#DataFrame.join-504"><span class="linenos">504</span></a> +</span><span id="DataFrame.join-505"><a href="#DataFrame.join-505"><span class="linenos">505</span></a> <span class="c1"># Update the on expression with the actual join clause to replace the dummy one from before</span> +</span><span id="DataFrame.join-506"><a href="#DataFrame.join-506"><span class="linenos">506</span></a> <span class="n">join_expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"joins"</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"on"</span><span class="p">,</span> <span class="n">join_clause</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DataFrame.join-507"><a href="#DataFrame.join-507"><span class="linenos">507</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">join_expression</span><span class="p">)</span> +</span><span id="DataFrame.join-508"><a href="#DataFrame.join-508"><span class="linenos">508</span></a> <span class="n">new_df</span><span class="o">.</span><span class="n">pending_join_hints</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">pending_join_hints</span><span class="p">)</span> +</span><span id="DataFrame.join-509"><a href="#DataFrame.join-509"><span class="linenos">509</span></a> <span class="n">new_df</span><span class="o">.</span><span class="n">pending_hints</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">other_df</span><span class="o">.</span><span class="n">pending_hints</span><span class="p">)</span> +</span><span id="DataFrame.join-510"><a href="#DataFrame.join-510"><span class="linenos">510</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">select</span><span class="o">.</span><span class="n">__wrapped__</span><span class="p">(</span><span class="n">new_df</span><span class="p">,</span> <span class="o">*</span><span class="n">select_column_names</span><span class="p">)</span> +</span><span id="DataFrame.join-511"><a href="#DataFrame.join-511"><span class="linenos">511</span></a> <span class="k">return</span> <span class="n">new_df</span> </span></pre></div> @@ -1918,42 +1920,42 @@ </div> <a class="headerlink" href="#DataFrame.orderBy"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.orderBy-512"><a href="#DataFrame.orderBy-512"><span class="linenos">512</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">ORDER_BY</span><span class="p">)</span> -</span><span id="DataFrame.orderBy-513"><a href="#DataFrame.orderBy-513"><span class="linenos">513</span></a> <span class="k">def</span> <span class="nf">orderBy</span><span class="p">(</span> -</span><span id="DataFrame.orderBy-514"><a href="#DataFrame.orderBy-514"><span class="linenos">514</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DataFrame.orderBy-515"><a href="#DataFrame.orderBy-515"><span class="linenos">515</span></a> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Column</span><span class="p">],</span> -</span><span id="DataFrame.orderBy-516"><a href="#DataFrame.orderBy-516"><span class="linenos">516</span></a> <span class="n">ascending</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Any</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">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrame.orderBy-517"><a href="#DataFrame.orderBy-517"><span class="linenos">517</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.orderBy-518"><a href="#DataFrame.orderBy-518"><span class="linenos">518</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="DataFrame.orderBy-519"><a href="#DataFrame.orderBy-519"><span class="linenos">519</span></a><span class="sd"> This implementation lets any ordered columns take priority over whatever is provided in `ascending`. Spark</span> -</span><span id="DataFrame.orderBy-520"><a href="#DataFrame.orderBy-520"><span class="linenos">520</span></a><span class="sd"> has irregular behavior and can result in runtime errors. Users shouldn't be mixing the two anyways so this</span> -</span><span id="DataFrame.orderBy-521"><a href="#DataFrame.orderBy-521"><span class="linenos">521</span></a><span class="sd"> is unlikely to come up.</span> -</span><span id="DataFrame.orderBy-522"><a href="#DataFrame.orderBy-522"><span class="linenos">522</span></a><span class="sd"> """</span> -</span><span id="DataFrame.orderBy-523"><a href="#DataFrame.orderBy-523"><span class="linenos">523</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> -</span><span id="DataFrame.orderBy-524"><a href="#DataFrame.orderBy-524"><span class="linenos">524</span></a> <span class="n">pre_ordered_col_indexes</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame.orderBy-525"><a href="#DataFrame.orderBy-525"><span class="linenos">525</span></a> <span class="n">x</span> -</span><span id="DataFrame.orderBy-526"><a href="#DataFrame.orderBy-526"><span class="linenos">526</span></a> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span> -</span><span id="DataFrame.orderBy-527"><a href="#DataFrame.orderBy-527"><span class="linenos">527</span></a> <span class="n">i</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">col</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">Ordered</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="DataFrame.orderBy-528"><a href="#DataFrame.orderBy-528"><span class="linenos">528</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">col</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> -</span><span id="DataFrame.orderBy-529"><a href="#DataFrame.orderBy-529"><span class="linenos">529</span></a> <span class="p">]</span> -</span><span id="DataFrame.orderBy-530"><a href="#DataFrame.orderBy-530"><span class="linenos">530</span></a> <span class="k">if</span> <span class="n">x</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> -</span><span id="DataFrame.orderBy-531"><a href="#DataFrame.orderBy-531"><span class="linenos">531</span></a> <span class="p">]</span> -</span><span id="DataFrame.orderBy-532"><a href="#DataFrame.orderBy-532"><span class="linenos">532</span></a> <span class="k">if</span> <span class="n">ascending</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="DataFrame.orderBy-533"><a href="#DataFrame.orderBy-533"><span class="linenos">533</span></a> <span class="n">ascending</span> <span class="o">=</span> <span class="p">[</span><span class="kc">True</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> -</span><span id="DataFrame.orderBy-534"><a href="#DataFrame.orderBy-534"><span class="linenos">534</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">ascending</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="DataFrame.orderBy-535"><a href="#DataFrame.orderBy-535"><span class="linenos">535</span></a> <span class="n">ascending</span> <span class="o">=</span> <span class="p">[</span><span class="n">ascending</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> -</span><span id="DataFrame.orderBy-536"><a href="#DataFrame.orderBy-536"><span class="linenos">536</span></a> <span class="n">ascending</span> <span class="o">=</span> <span class="p">[</span><span class="nb">bool</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">ascending</span><span class="p">)]</span> -</span><span id="DataFrame.orderBy-537"><a href="#DataFrame.orderBy-537"><span class="linenos">537</span></a> <span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span> -</span><span id="DataFrame.orderBy-538"><a href="#DataFrame.orderBy-538"><span class="linenos">538</span></a> <span class="n">ascending</span> -</span><span id="DataFrame.orderBy-539"><a href="#DataFrame.orderBy-539"><span class="linenos">539</span></a> <span class="p">),</span> <span class="s2">"The length of items in ascending must equal the number of columns provided"</span> -</span><span id="DataFrame.orderBy-540"><a href="#DataFrame.orderBy-540"><span class="linenos">540</span></a> <span class="n">col_and_ascending</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">columns</span><span class="p">,</span> <span class="n">ascending</span><span class="p">))</span> -</span><span id="DataFrame.orderBy-541"><a href="#DataFrame.orderBy-541"><span class="linenos">541</span></a> <span class="n">order_by_columns</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame.orderBy-542"><a href="#DataFrame.orderBy-542"><span class="linenos">542</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">col</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="ow">not</span> <span class="n">asc</span><span class="p">)</span> -</span><span id="DataFrame.orderBy-543"><a href="#DataFrame.orderBy-543"><span class="linenos">543</span></a> <span class="k">if</span> <span class="n">i</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">pre_ordered_col_indexes</span> -</span><span id="DataFrame.orderBy-544"><a href="#DataFrame.orderBy-544"><span class="linenos">544</span></a> <span class="k">else</span> <span class="n">columns</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">column_expression</span> -</span><span id="DataFrame.orderBy-545"><a href="#DataFrame.orderBy-545"><span class="linenos">545</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="p">(</span><span class="n">col</span><span class="p">,</span> <span class="n">asc</span><span class="p">)</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">col_and_ascending</span><span class="p">)</span> -</span><span id="DataFrame.orderBy-546"><a href="#DataFrame.orderBy-546"><span class="linenos">546</span></a> <span class="p">]</span> -</span><span id="DataFrame.orderBy-547"><a href="#DataFrame.orderBy-547"><span class="linenos">547</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">order_by</span><span class="p">(</span><span class="o">*</span><span class="n">order_by_columns</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.orderBy-513"><a href="#DataFrame.orderBy-513"><span class="linenos">513</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">ORDER_BY</span><span class="p">)</span> +</span><span id="DataFrame.orderBy-514"><a href="#DataFrame.orderBy-514"><span class="linenos">514</span></a> <span class="k">def</span> <span class="nf">orderBy</span><span class="p">(</span> +</span><span id="DataFrame.orderBy-515"><a href="#DataFrame.orderBy-515"><span class="linenos">515</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DataFrame.orderBy-516"><a href="#DataFrame.orderBy-516"><span class="linenos">516</span></a> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Column</span><span class="p">],</span> +</span><span id="DataFrame.orderBy-517"><a href="#DataFrame.orderBy-517"><span class="linenos">517</span></a> <span class="n">ascending</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Any</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">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrame.orderBy-518"><a href="#DataFrame.orderBy-518"><span class="linenos">518</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.orderBy-519"><a href="#DataFrame.orderBy-519"><span class="linenos">519</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="DataFrame.orderBy-520"><a href="#DataFrame.orderBy-520"><span class="linenos">520</span></a><span class="sd"> This implementation lets any ordered columns take priority over whatever is provided in `ascending`. Spark</span> +</span><span id="DataFrame.orderBy-521"><a href="#DataFrame.orderBy-521"><span class="linenos">521</span></a><span class="sd"> has irregular behavior and can result in runtime errors. Users shouldn't be mixing the two anyways so this</span> +</span><span id="DataFrame.orderBy-522"><a href="#DataFrame.orderBy-522"><span class="linenos">522</span></a><span class="sd"> is unlikely to come up.</span> +</span><span id="DataFrame.orderBy-523"><a href="#DataFrame.orderBy-523"><span class="linenos">523</span></a><span class="sd"> """</span> +</span><span id="DataFrame.orderBy-524"><a href="#DataFrame.orderBy-524"><span class="linenos">524</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> +</span><span id="DataFrame.orderBy-525"><a href="#DataFrame.orderBy-525"><span class="linenos">525</span></a> <span class="n">pre_ordered_col_indexes</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame.orderBy-526"><a href="#DataFrame.orderBy-526"><span class="linenos">526</span></a> <span class="n">x</span> +</span><span id="DataFrame.orderBy-527"><a href="#DataFrame.orderBy-527"><span class="linenos">527</span></a> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span> +</span><span id="DataFrame.orderBy-528"><a href="#DataFrame.orderBy-528"><span class="linenos">528</span></a> <span class="n">i</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">col</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">Ordered</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="DataFrame.orderBy-529"><a href="#DataFrame.orderBy-529"><span class="linenos">529</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">col</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> +</span><span id="DataFrame.orderBy-530"><a href="#DataFrame.orderBy-530"><span class="linenos">530</span></a> <span class="p">]</span> +</span><span id="DataFrame.orderBy-531"><a href="#DataFrame.orderBy-531"><span class="linenos">531</span></a> <span class="k">if</span> <span class="n">x</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> +</span><span id="DataFrame.orderBy-532"><a href="#DataFrame.orderBy-532"><span class="linenos">532</span></a> <span class="p">]</span> +</span><span id="DataFrame.orderBy-533"><a href="#DataFrame.orderBy-533"><span class="linenos">533</span></a> <span class="k">if</span> <span class="n">ascending</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="DataFrame.orderBy-534"><a href="#DataFrame.orderBy-534"><span class="linenos">534</span></a> <span class="n">ascending</span> <span class="o">=</span> <span class="p">[</span><span class="kc">True</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> +</span><span id="DataFrame.orderBy-535"><a href="#DataFrame.orderBy-535"><span class="linenos">535</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">ascending</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="DataFrame.orderBy-536"><a href="#DataFrame.orderBy-536"><span class="linenos">536</span></a> <span class="n">ascending</span> <span class="o">=</span> <span class="p">[</span><span class="n">ascending</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> +</span><span id="DataFrame.orderBy-537"><a href="#DataFrame.orderBy-537"><span class="linenos">537</span></a> <span class="n">ascending</span> <span class="o">=</span> <span class="p">[</span><span class="nb">bool</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">ascending</span><span class="p">)]</span> +</span><span id="DataFrame.orderBy-538"><a href="#DataFrame.orderBy-538"><span class="linenos">538</span></a> <span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span> +</span><span id="DataFrame.orderBy-539"><a href="#DataFrame.orderBy-539"><span class="linenos">539</span></a> <span class="n">ascending</span> +</span><span id="DataFrame.orderBy-540"><a href="#DataFrame.orderBy-540"><span class="linenos">540</span></a> <span class="p">),</span> <span class="s2">"The length of items in ascending must equal the number of columns provided"</span> +</span><span id="DataFrame.orderBy-541"><a href="#DataFrame.orderBy-541"><span class="linenos">541</span></a> <span class="n">col_and_ascending</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">columns</span><span class="p">,</span> <span class="n">ascending</span><span class="p">))</span> +</span><span id="DataFrame.orderBy-542"><a href="#DataFrame.orderBy-542"><span class="linenos">542</span></a> <span class="n">order_by_columns</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame.orderBy-543"><a href="#DataFrame.orderBy-543"><span class="linenos">543</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">col</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="ow">not</span> <span class="n">asc</span><span class="p">)</span> +</span><span id="DataFrame.orderBy-544"><a href="#DataFrame.orderBy-544"><span class="linenos">544</span></a> <span class="k">if</span> <span class="n">i</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">pre_ordered_col_indexes</span> +</span><span id="DataFrame.orderBy-545"><a href="#DataFrame.orderBy-545"><span class="linenos">545</span></a> <span class="k">else</span> <span class="n">columns</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">column_expression</span> +</span><span id="DataFrame.orderBy-546"><a href="#DataFrame.orderBy-546"><span class="linenos">546</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="p">(</span><span class="n">col</span><span class="p">,</span> <span class="n">asc</span><span class="p">)</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">col_and_ascending</span><span class="p">)</span> +</span><span id="DataFrame.orderBy-547"><a href="#DataFrame.orderBy-547"><span class="linenos">547</span></a> <span class="p">]</span> +</span><span id="DataFrame.orderBy-548"><a href="#DataFrame.orderBy-548"><span class="linenos">548</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">order_by</span><span class="p">(</span><span class="o">*</span><span class="n">order_by_columns</span><span class="p">))</span> </span></pre></div> @@ -1976,42 +1978,42 @@ is unlikely to come up.</p> </div> <a class="headerlink" href="#DataFrame.sort"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.sort-512"><a href="#DataFrame.sort-512"><span class="linenos">512</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">ORDER_BY</span><span class="p">)</span> -</span><span id="DataFrame.sort-513"><a href="#DataFrame.sort-513"><span class="linenos">513</span></a> <span class="k">def</span> <span class="nf">orderBy</span><span class="p">(</span> -</span><span id="DataFrame.sort-514"><a href="#DataFrame.sort-514"><span class="linenos">514</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DataFrame.sort-515"><a href="#DataFrame.sort-515"><span class="linenos">515</span></a> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Column</span><span class="p">],</span> -</span><span id="DataFrame.sort-516"><a href="#DataFrame.sort-516"><span class="linenos">516</span></a> <span class="n">ascending</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Any</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">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrame.sort-517"><a href="#DataFrame.sort-517"><span class="linenos">517</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.sort-518"><a href="#DataFrame.sort-518"><span class="linenos">518</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="DataFrame.sort-519"><a href="#DataFrame.sort-519"><span class="linenos">519</span></a><span class="sd"> This implementation lets any ordered columns take priority over whatever is provided in `ascending`. Spark</span> -</span><span id="DataFrame.sort-520"><a href="#DataFrame.sort-520"><span class="linenos">520</span></a><span class="sd"> has irregular behavior and can result in runtime errors. Users shouldn't be mixing the two anyways so this</span> -</span><span id="DataFrame.sort-521"><a href="#DataFrame.sort-521"><span class="linenos">521</span></a><span class="sd"> is unlikely to come up.</span> -</span><span id="DataFrame.sort-522"><a href="#DataFrame.sort-522"><span class="linenos">522</span></a><span class="sd"> """</span> -</span><span id="DataFrame.sort-523"><a href="#DataFrame.sort-523"><span class="linenos">523</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> -</span><span id="DataFrame.sort-524"><a href="#DataFrame.sort-524"><span class="linenos">524</span></a> <span class="n">pre_ordered_col_indexes</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame.sort-525"><a href="#DataFrame.sort-525"><span class="linenos">525</span></a> <span class="n">x</span> -</span><span id="DataFrame.sort-526"><a href="#DataFrame.sort-526"><span class="linenos">526</span></a> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span> -</span><span id="DataFrame.sort-527"><a href="#DataFrame.sort-527"><span class="linenos">527</span></a> <span class="n">i</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">col</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">Ordered</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="DataFrame.sort-528"><a href="#DataFrame.sort-528"><span class="linenos">528</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">col</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> -</span><span id="DataFrame.sort-529"><a href="#DataFrame.sort-529"><span class="linenos">529</span></a> <span class="p">]</span> -</span><span id="DataFrame.sort-530"><a href="#DataFrame.sort-530"><span class="linenos">530</span></a> <span class="k">if</span> <span class="n">x</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> -</span><span id="DataFrame.sort-531"><a href="#DataFrame.sort-531"><span class="linenos">531</span></a> <span class="p">]</span> -</span><span id="DataFrame.sort-532"><a href="#DataFrame.sort-532"><span class="linenos">532</span></a> <span class="k">if</span> <span class="n">ascending</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="DataFrame.sort-533"><a href="#DataFrame.sort-533"><span class="linenos">533</span></a> <span class="n">ascending</span> <span class="o">=</span> <span class="p">[</span><span class="kc">True</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> -</span><span id="DataFrame.sort-534"><a href="#DataFrame.sort-534"><span class="linenos">534</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">ascending</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="DataFrame.sort-535"><a href="#DataFrame.sort-535"><span class="linenos">535</span></a> <span class="n">ascending</span> <span class="o">=</span> <span class="p">[</span><span class="n">ascending</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> -</span><span id="DataFrame.sort-536"><a href="#DataFrame.sort-536"><span class="linenos">536</span></a> <span class="n">ascending</span> <span class="o">=</span> <span class="p">[</span><span class="nb">bool</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">ascending</span><span class="p">)]</span> -</span><span id="DataFrame.sort-537"><a href="#DataFrame.sort-537"><span class="linenos">537</span></a> <span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span> -</span><span id="DataFrame.sort-538"><a href="#DataFrame.sort-538"><span class="linenos">538</span></a> <span class="n">ascending</span> -</span><span id="DataFrame.sort-539"><a href="#DataFrame.sort-539"><span class="linenos">539</span></a> <span class="p">),</span> <span class="s2">"The length of items in ascending must equal the number of columns provided"</span> -</span><span id="DataFrame.sort-540"><a href="#DataFrame.sort-540"><span class="linenos">540</span></a> <span class="n">col_and_ascending</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">columns</span><span class="p">,</span> <span class="n">ascending</span><span class="p">))</span> -</span><span id="DataFrame.sort-541"><a href="#DataFrame.sort-541"><span class="linenos">541</span></a> <span class="n">order_by_columns</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame.sort-542"><a href="#DataFrame.sort-542"><span class="linenos">542</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">col</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="ow">not</span> <span class="n">asc</span><span class="p">)</span> -</span><span id="DataFrame.sort-543"><a href="#DataFrame.sort-543"><span class="linenos">543</span></a> <span class="k">if</span> <span class="n">i</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">pre_ordered_col_indexes</span> -</span><span id="DataFrame.sort-544"><a href="#DataFrame.sort-544"><span class="linenos">544</span></a> <span class="k">else</span> <span class="n">columns</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">column_expression</span> -</span><span id="DataFrame.sort-545"><a href="#DataFrame.sort-545"><span class="linenos">545</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="p">(</span><span class="n">col</span><span class="p">,</span> <span class="n">asc</span><span class="p">)</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">col_and_ascending</span><span class="p">)</span> -</span><span id="DataFrame.sort-546"><a href="#DataFrame.sort-546"><span class="linenos">546</span></a> <span class="p">]</span> -</span><span id="DataFrame.sort-547"><a href="#DataFrame.sort-547"><span class="linenos">547</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">order_by</span><span class="p">(</span><span class="o">*</span><span class="n">order_by_columns</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.sort-513"><a href="#DataFrame.sort-513"><span class="linenos">513</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">ORDER_BY</span><span class="p">)</span> +</span><span id="DataFrame.sort-514"><a href="#DataFrame.sort-514"><span class="linenos">514</span></a> <span class="k">def</span> <span class="nf">orderBy</span><span class="p">(</span> +</span><span id="DataFrame.sort-515"><a href="#DataFrame.sort-515"><span class="linenos">515</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DataFrame.sort-516"><a href="#DataFrame.sort-516"><span class="linenos">516</span></a> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Column</span><span class="p">],</span> +</span><span id="DataFrame.sort-517"><a href="#DataFrame.sort-517"><span class="linenos">517</span></a> <span class="n">ascending</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Any</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">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrame.sort-518"><a href="#DataFrame.sort-518"><span class="linenos">518</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.sort-519"><a href="#DataFrame.sort-519"><span class="linenos">519</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="DataFrame.sort-520"><a href="#DataFrame.sort-520"><span class="linenos">520</span></a><span class="sd"> This implementation lets any ordered columns take priority over whatever is provided in `ascending`. Spark</span> +</span><span id="DataFrame.sort-521"><a href="#DataFrame.sort-521"><span class="linenos">521</span></a><span class="sd"> has irregular behavior and can result in runtime errors. Users shouldn't be mixing the two anyways so this</span> +</span><span id="DataFrame.sort-522"><a href="#DataFrame.sort-522"><span class="linenos">522</span></a><span class="sd"> is unlikely to come up.</span> +</span><span id="DataFrame.sort-523"><a href="#DataFrame.sort-523"><span class="linenos">523</span></a><span class="sd"> """</span> +</span><span id="DataFrame.sort-524"><a href="#DataFrame.sort-524"><span class="linenos">524</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> +</span><span id="DataFrame.sort-525"><a href="#DataFrame.sort-525"><span class="linenos">525</span></a> <span class="n">pre_ordered_col_indexes</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame.sort-526"><a href="#DataFrame.sort-526"><span class="linenos">526</span></a> <span class="n">x</span> +</span><span id="DataFrame.sort-527"><a href="#DataFrame.sort-527"><span class="linenos">527</span></a> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span> +</span><span id="DataFrame.sort-528"><a href="#DataFrame.sort-528"><span class="linenos">528</span></a> <span class="n">i</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">col</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">Ordered</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="DataFrame.sort-529"><a href="#DataFrame.sort-529"><span class="linenos">529</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">col</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> +</span><span id="DataFrame.sort-530"><a href="#DataFrame.sort-530"><span class="linenos">530</span></a> <span class="p">]</span> +</span><span id="DataFrame.sort-531"><a href="#DataFrame.sort-531"><span class="linenos">531</span></a> <span class="k">if</span> <span class="n">x</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> +</span><span id="DataFrame.sort-532"><a href="#DataFrame.sort-532"><span class="linenos">532</span></a> <span class="p">]</span> +</span><span id="DataFrame.sort-533"><a href="#DataFrame.sort-533"><span class="linenos">533</span></a> <span class="k">if</span> <span class="n">ascending</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="DataFrame.sort-534"><a href="#DataFrame.sort-534"><span class="linenos">534</span></a> <span class="n">ascending</span> <span class="o">=</span> <span class="p">[</span><span class="kc">True</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> +</span><span id="DataFrame.sort-535"><a href="#DataFrame.sort-535"><span class="linenos">535</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">ascending</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="DataFrame.sort-536"><a href="#DataFrame.sort-536"><span class="linenos">536</span></a> <span class="n">ascending</span> <span class="o">=</span> <span class="p">[</span><span class="n">ascending</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> +</span><span id="DataFrame.sort-537"><a href="#DataFrame.sort-537"><span class="linenos">537</span></a> <span class="n">ascending</span> <span class="o">=</span> <span class="p">[</span><span class="nb">bool</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">ascending</span><span class="p">)]</span> +</span><span id="DataFrame.sort-538"><a href="#DataFrame.sort-538"><span class="linenos">538</span></a> <span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span> +</span><span id="DataFrame.sort-539"><a href="#DataFrame.sort-539"><span class="linenos">539</span></a> <span class="n">ascending</span> +</span><span id="DataFrame.sort-540"><a href="#DataFrame.sort-540"><span class="linenos">540</span></a> <span class="p">),</span> <span class="s2">"The length of items in ascending must equal the number of columns provided"</span> +</span><span id="DataFrame.sort-541"><a href="#DataFrame.sort-541"><span class="linenos">541</span></a> <span class="n">col_and_ascending</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">columns</span><span class="p">,</span> <span class="n">ascending</span><span class="p">))</span> +</span><span id="DataFrame.sort-542"><a href="#DataFrame.sort-542"><span class="linenos">542</span></a> <span class="n">order_by_columns</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame.sort-543"><a href="#DataFrame.sort-543"><span class="linenos">543</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">col</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="ow">not</span> <span class="n">asc</span><span class="p">)</span> +</span><span id="DataFrame.sort-544"><a href="#DataFrame.sort-544"><span class="linenos">544</span></a> <span class="k">if</span> <span class="n">i</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">pre_ordered_col_indexes</span> +</span><span id="DataFrame.sort-545"><a href="#DataFrame.sort-545"><span class="linenos">545</span></a> <span class="k">else</span> <span class="n">columns</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">column_expression</span> +</span><span id="DataFrame.sort-546"><a href="#DataFrame.sort-546"><span class="linenos">546</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="p">(</span><span class="n">col</span><span class="p">,</span> <span class="n">asc</span><span class="p">)</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">col_and_ascending</span><span class="p">)</span> +</span><span id="DataFrame.sort-547"><a href="#DataFrame.sort-547"><span class="linenos">547</span></a> <span class="p">]</span> +</span><span id="DataFrame.sort-548"><a href="#DataFrame.sort-548"><span class="linenos">548</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">order_by</span><span class="p">(</span><span class="o">*</span><span class="n">order_by_columns</span><span class="p">))</span> </span></pre></div> @@ -2034,9 +2036,9 @@ is unlikely to come up.</p> </div> <a class="headerlink" href="#DataFrame.union"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.union-551"><a href="#DataFrame.union-551"><span class="linenos">551</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> -</span><span id="DataFrame.union-552"><a href="#DataFrame.union-552"><span class="linenos">552</span></a> <span class="k">def</span> <span class="nf">union</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.union-553"><a href="#DataFrame.union-553"><span class="linenos">553</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">,</span> <span class="n">other</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.union-552"><a href="#DataFrame.union-552"><span class="linenos">552</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> +</span><span id="DataFrame.union-553"><a href="#DataFrame.union-553"><span class="linenos">553</span></a> <span class="k">def</span> <span class="nf">union</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.union-554"><a href="#DataFrame.union-554"><span class="linenos">554</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">,</span> <span class="n">other</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> </span></pre></div> @@ -2055,9 +2057,9 @@ is unlikely to come up.</p> </div> <a class="headerlink" href="#DataFrame.unionAll"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.unionAll-551"><a href="#DataFrame.unionAll-551"><span class="linenos">551</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> -</span><span id="DataFrame.unionAll-552"><a href="#DataFrame.unionAll-552"><span class="linenos">552</span></a> <span class="k">def</span> <span class="nf">union</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.unionAll-553"><a href="#DataFrame.unionAll-553"><span class="linenos">553</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">,</span> <span class="n">other</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.unionAll-552"><a href="#DataFrame.unionAll-552"><span class="linenos">552</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> +</span><span id="DataFrame.unionAll-553"><a href="#DataFrame.unionAll-553"><span class="linenos">553</span></a> <span class="k">def</span> <span class="nf">union</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.unionAll-554"><a href="#DataFrame.unionAll-554"><span class="linenos">554</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">,</span> <span class="n">other</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> </span></pre></div> @@ -2076,34 +2078,34 @@ is unlikely to come up.</p> </div> <a class="headerlink" href="#DataFrame.unionByName"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.unionByName-557"><a href="#DataFrame.unionByName-557"><span class="linenos">557</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> -</span><span id="DataFrame.unionByName-558"><a href="#DataFrame.unionByName-558"><span class="linenos">558</span></a> <span class="k">def</span> <span class="nf">unionByName</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> <span class="n">allowMissingColumns</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">):</span> -</span><span id="DataFrame.unionByName-559"><a href="#DataFrame.unionByName-559"><span class="linenos">559</span></a> <span class="n">l_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">columns</span> -</span><span id="DataFrame.unionByName-560"><a href="#DataFrame.unionByName-560"><span class="linenos">560</span></a> <span class="n">r_columns</span> <span class="o">=</span> <span class="n">other</span><span class="o">.</span><span class="n">columns</span> -</span><span id="DataFrame.unionByName-561"><a href="#DataFrame.unionByName-561"><span class="linenos">561</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">allowMissingColumns</span><span class="p">:</span> -</span><span id="DataFrame.unionByName-562"><a href="#DataFrame.unionByName-562"><span class="linenos">562</span></a> <span class="n">l_expressions</span> <span class="o">=</span> <span class="n">l_columns</span> -</span><span id="DataFrame.unionByName-563"><a href="#DataFrame.unionByName-563"><span class="linenos">563</span></a> <span class="n">r_expressions</span> <span class="o">=</span> <span class="n">l_columns</span> -</span><span id="DataFrame.unionByName-564"><a href="#DataFrame.unionByName-564"><span class="linenos">564</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame.unionByName-565"><a href="#DataFrame.unionByName-565"><span class="linenos">565</span></a> <span class="n">l_expressions</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="DataFrame.unionByName-566"><a href="#DataFrame.unionByName-566"><span class="linenos">566</span></a> <span class="n">r_expressions</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="DataFrame.unionByName-567"><a href="#DataFrame.unionByName-567"><span class="linenos">567</span></a> <span class="n">r_columns_unused</span> <span class="o">=</span> <span class="n">copy</span><span class="p">(</span><span class="n">r_columns</span><span class="p">)</span> -</span><span id="DataFrame.unionByName-568"><a href="#DataFrame.unionByName-568"><span class="linenos">568</span></a> <span class="k">for</span> <span class="n">l_column</span> <span class="ow">in</span> <span class="n">l_columns</span><span class="p">:</span> -</span><span id="DataFrame.unionByName-569"><a href="#DataFrame.unionByName-569"><span class="linenos">569</span></a> <span class="n">l_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">l_column</span><span class="p">)</span> -</span><span id="DataFrame.unionByName-570"><a href="#DataFrame.unionByName-570"><span class="linenos">570</span></a> <span class="k">if</span> <span class="n">l_column</span> <span class="ow">in</span> <span class="n">r_columns</span><span class="p">:</span> -</span><span id="DataFrame.unionByName-571"><a href="#DataFrame.unionByName-571"><span class="linenos">571</span></a> <span class="n">r_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">l_column</span><span class="p">)</span> -</span><span id="DataFrame.unionByName-572"><a href="#DataFrame.unionByName-572"><span class="linenos">572</span></a> <span class="n">r_columns_unused</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">l_column</span><span class="p">)</span> -</span><span id="DataFrame.unionByName-573"><a href="#DataFrame.unionByName-573"><span class="linenos">573</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame.unionByName-574"><a href="#DataFrame.unionByName-574"><span class="linenos">574</span></a> <span class="n">r_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">(),</span> <span class="n">l_column</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> -</span><span id="DataFrame.unionByName-575"><a href="#DataFrame.unionByName-575"><span class="linenos">575</span></a> <span class="k">for</span> <span class="n">r_column</span> <span class="ow">in</span> <span class="n">r_columns_unused</span><span class="p">:</span> -</span><span id="DataFrame.unionByName-576"><a href="#DataFrame.unionByName-576"><span class="linenos">576</span></a> <span class="n">l_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">(),</span> <span class="n">r_column</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> -</span><span id="DataFrame.unionByName-577"><a href="#DataFrame.unionByName-577"><span class="linenos">577</span></a> <span class="n">r_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">r_column</span><span class="p">)</span> -</span><span id="DataFrame.unionByName-578"><a href="#DataFrame.unionByName-578"><span class="linenos">578</span></a> <span class="n">r_df</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="DataFrame.unionByName-579"><a href="#DataFrame.unionByName-579"><span class="linenos">579</span></a> <span class="n">other</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">r_expressions</span><span class="p">))</span> -</span><span id="DataFrame.unionByName-580"><a href="#DataFrame.unionByName-580"><span class="linenos">580</span></a> <span class="p">)</span> -</span><span id="DataFrame.unionByName-581"><a href="#DataFrame.unionByName-581"><span class="linenos">581</span></a> <span class="n">l_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame.unionByName-582"><a href="#DataFrame.unionByName-582"><span class="linenos">582</span></a> <span class="k">if</span> <span class="n">allowMissingColumns</span><span class="p">:</span> -</span><span id="DataFrame.unionByName-583"><a href="#DataFrame.unionByName-583"><span class="linenos">583</span></a> <span class="n">l_df</span> <span class="o">=</span> <span class="n">l_df</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">l_expressions</span><span class="p">))</span> -</span><span id="DataFrame.unionByName-584"><a href="#DataFrame.unionByName-584"><span class="linenos">584</span></a> <span class="k">return</span> <span class="n">l_df</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">,</span> <span class="n">r_df</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.unionByName-558"><a href="#DataFrame.unionByName-558"><span class="linenos">558</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> +</span><span id="DataFrame.unionByName-559"><a href="#DataFrame.unionByName-559"><span class="linenos">559</span></a> <span class="k">def</span> <span class="nf">unionByName</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> <span class="n">allowMissingColumns</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">):</span> +</span><span id="DataFrame.unionByName-560"><a href="#DataFrame.unionByName-560"><span class="linenos">560</span></a> <span class="n">l_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">columns</span> +</span><span id="DataFrame.unionByName-561"><a href="#DataFrame.unionByName-561"><span class="linenos">561</span></a> <span class="n">r_columns</span> <span class="o">=</span> <span class="n">other</span><span class="o">.</span><span class="n">columns</span> +</span><span id="DataFrame.unionByName-562"><a href="#DataFrame.unionByName-562"><span class="linenos">562</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">allowMissingColumns</span><span class="p">:</span> +</span><span id="DataFrame.unionByName-563"><a href="#DataFrame.unionByName-563"><span class="linenos">563</span></a> <span class="n">l_expressions</span> <span class="o">=</span> <span class="n">l_columns</span> +</span><span id="DataFrame.unionByName-564"><a href="#DataFrame.unionByName-564"><span class="linenos">564</span></a> <span class="n">r_expressions</span> <span class="o">=</span> <span class="n">l_columns</span> +</span><span id="DataFrame.unionByName-565"><a href="#DataFrame.unionByName-565"><span class="linenos">565</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame.unionByName-566"><a href="#DataFrame.unionByName-566"><span class="linenos">566</span></a> <span class="n">l_expressions</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="DataFrame.unionByName-567"><a href="#DataFrame.unionByName-567"><span class="linenos">567</span></a> <span class="n">r_expressions</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="DataFrame.unionByName-568"><a href="#DataFrame.unionByName-568"><span class="linenos">568</span></a> <span class="n">r_columns_unused</span> <span class="o">=</span> <span class="n">copy</span><span class="p">(</span><span class="n">r_columns</span><span class="p">)</span> +</span><span id="DataFrame.unionByName-569"><a href="#DataFrame.unionByName-569"><span class="linenos">569</span></a> <span class="k">for</span> <span class="n">l_column</span> <span class="ow">in</span> <span class="n">l_columns</span><span class="p">:</span> +</span><span id="DataFrame.unionByName-570"><a href="#DataFrame.unionByName-570"><span class="linenos">570</span></a> <span class="n">l_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">l_column</span><span class="p">)</span> +</span><span id="DataFrame.unionByName-571"><a href="#DataFrame.unionByName-571"><span class="linenos">571</span></a> <span class="k">if</span> <span class="n">l_column</span> <span class="ow">in</span> <span class="n">r_columns</span><span class="p">:</span> +</span><span id="DataFrame.unionByName-572"><a href="#DataFrame.unionByName-572"><span class="linenos">572</span></a> <span class="n">r_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">l_column</span><span class="p">)</span> +</span><span id="DataFrame.unionByName-573"><a href="#DataFrame.unionByName-573"><span class="linenos">573</span></a> <span class="n">r_columns_unused</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">l_column</span><span class="p">)</span> +</span><span id="DataFrame.unionByName-574"><a href="#DataFrame.unionByName-574"><span class="linenos">574</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame.unionByName-575"><a href="#DataFrame.unionByName-575"><span class="linenos">575</span></a> <span class="n">r_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">(),</span> <span class="n">l_column</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> +</span><span id="DataFrame.unionByName-576"><a href="#DataFrame.unionByName-576"><span class="linenos">576</span></a> <span class="k">for</span> <span class="n">r_column</span> <span class="ow">in</span> <span class="n">r_columns_unused</span><span class="p">:</span> +</span><span id="DataFrame.unionByName-577"><a href="#DataFrame.unionByName-577"><span class="linenos">577</span></a> <span class="n">l_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">(),</span> <span class="n">r_column</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> +</span><span id="DataFrame.unionByName-578"><a href="#DataFrame.unionByName-578"><span class="linenos">578</span></a> <span class="n">r_expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">r_column</span><span class="p">)</span> +</span><span id="DataFrame.unionByName-579"><a href="#DataFrame.unionByName-579"><span class="linenos">579</span></a> <span class="n">r_df</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="DataFrame.unionByName-580"><a href="#DataFrame.unionByName-580"><span class="linenos">580</span></a> <span class="n">other</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">r_expressions</span><span class="p">))</span> +</span><span id="DataFrame.unionByName-581"><a href="#DataFrame.unionByName-581"><span class="linenos">581</span></a> <span class="p">)</span> +</span><span id="DataFrame.unionByName-582"><a href="#DataFrame.unionByName-582"><span class="linenos">582</span></a> <span class="n">l_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame.unionByName-583"><a href="#DataFrame.unionByName-583"><span class="linenos">583</span></a> <span class="k">if</span> <span class="n">allowMissingColumns</span><span class="p">:</span> +</span><span id="DataFrame.unionByName-584"><a href="#DataFrame.unionByName-584"><span class="linenos">584</span></a> <span class="n">l_df</span> <span class="o">=</span> <span class="n">l_df</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">l_expressions</span><span class="p">))</span> +</span><span id="DataFrame.unionByName-585"><a href="#DataFrame.unionByName-585"><span class="linenos">585</span></a> <span class="k">return</span> <span class="n">l_df</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">,</span> <span class="n">r_df</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> </span></pre></div> @@ -2122,9 +2124,9 @@ is unlikely to come up.</p> </div> <a class="headerlink" href="#DataFrame.intersect"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.intersect-586"><a href="#DataFrame.intersect-586"><span class="linenos">586</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> -</span><span id="DataFrame.intersect-587"><a href="#DataFrame.intersect-587"><span class="linenos">587</span></a> <span class="k">def</span> <span class="nf">intersect</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.intersect-588"><a href="#DataFrame.intersect-588"><span class="linenos">588</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="n">other</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.intersect-587"><a href="#DataFrame.intersect-587"><span class="linenos">587</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> +</span><span id="DataFrame.intersect-588"><a href="#DataFrame.intersect-588"><span class="linenos">588</span></a> <span class="k">def</span> <span class="nf">intersect</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.intersect-589"><a href="#DataFrame.intersect-589"><span class="linenos">589</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="n">other</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> </span></pre></div> @@ -2143,9 +2145,9 @@ is unlikely to come up.</p> </div> <a class="headerlink" href="#DataFrame.intersectAll"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.intersectAll-590"><a href="#DataFrame.intersectAll-590"><span class="linenos">590</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> -</span><span id="DataFrame.intersectAll-591"><a href="#DataFrame.intersectAll-591"><span class="linenos">591</span></a> <span class="k">def</span> <span class="nf">intersectAll</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.intersectAll-592"><a href="#DataFrame.intersectAll-592"><span class="linenos">592</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="n">other</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.intersectAll-591"><a href="#DataFrame.intersectAll-591"><span class="linenos">591</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> +</span><span id="DataFrame.intersectAll-592"><a href="#DataFrame.intersectAll-592"><span class="linenos">592</span></a> <span class="k">def</span> <span class="nf">intersectAll</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.intersectAll-593"><a href="#DataFrame.intersectAll-593"><span class="linenos">593</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">,</span> <span class="n">other</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> </span></pre></div> @@ -2164,9 +2166,9 @@ is unlikely to come up.</p> </div> <a class="headerlink" href="#DataFrame.exceptAll"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.exceptAll-594"><a href="#DataFrame.exceptAll-594"><span class="linenos">594</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> -</span><span id="DataFrame.exceptAll-595"><a href="#DataFrame.exceptAll-595"><span class="linenos">595</span></a> <span class="k">def</span> <span class="nf">exceptAll</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.exceptAll-596"><a href="#DataFrame.exceptAll-596"><span class="linenos">596</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">,</span> <span class="n">other</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.exceptAll-595"><a href="#DataFrame.exceptAll-595"><span class="linenos">595</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> +</span><span id="DataFrame.exceptAll-596"><a href="#DataFrame.exceptAll-596"><span class="linenos">596</span></a> <span class="k">def</span> <span class="nf">exceptAll</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.exceptAll-597"><a href="#DataFrame.exceptAll-597"><span class="linenos">597</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_set_operation</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">,</span> <span class="n">other</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> </span></pre></div> @@ -2185,9 +2187,9 @@ is unlikely to come up.</p> </div> <a class="headerlink" href="#DataFrame.distinct"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.distinct-598"><a href="#DataFrame.distinct-598"><span class="linenos">598</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> -</span><span id="DataFrame.distinct-599"><a href="#DataFrame.distinct-599"><span class="linenos">599</span></a> <span class="k">def</span> <span class="nf">distinct</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.distinct-600"><a href="#DataFrame.distinct-600"><span class="linenos">600</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">distinct</span><span class="p">())</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.distinct-599"><a href="#DataFrame.distinct-599"><span class="linenos">599</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> +</span><span id="DataFrame.distinct-600"><a href="#DataFrame.distinct-600"><span class="linenos">600</span></a> <span class="k">def</span> <span class="nf">distinct</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.distinct-601"><a href="#DataFrame.distinct-601"><span class="linenos">601</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">distinct</span><span class="p">())</span> </span></pre></div> @@ -2206,18 +2208,18 @@ is unlikely to come up.</p> </div> <a class="headerlink" href="#DataFrame.dropDuplicates"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.dropDuplicates-602"><a href="#DataFrame.dropDuplicates-602"><span class="linenos">602</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> -</span><span id="DataFrame.dropDuplicates-603"><a href="#DataFrame.dropDuplicates-603"><span class="linenos">603</span></a> <span class="k">def</span> <span class="nf">dropDuplicates</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">):</span> -</span><span id="DataFrame.dropDuplicates-604"><a href="#DataFrame.dropDuplicates-604"><span class="linenos">604</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">subset</span><span class="p">:</span> -</span><span id="DataFrame.dropDuplicates-605"><a href="#DataFrame.dropDuplicates-605"><span class="linenos">605</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">distinct</span><span class="p">()</span> -</span><span id="DataFrame.dropDuplicates-606"><a href="#DataFrame.dropDuplicates-606"><span class="linenos">606</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">subset</span><span class="p">)</span> -</span><span id="DataFrame.dropDuplicates-607"><a href="#DataFrame.dropDuplicates-607"><span class="linenos">607</span></a> <span class="n">window</span> <span class="o">=</span> <span class="n">Window</span><span class="o">.</span><span class="n">partitionBy</span><span class="p">(</span><span class="o">*</span><span class="n">column_names</span><span class="p">)</span><span class="o">.</span><span class="n">orderBy</span><span class="p">(</span><span class="o">*</span><span class="n">column_names</span><span class="p">)</span> -</span><span id="DataFrame.dropDuplicates-608"><a href="#DataFrame.dropDuplicates-608"><span class="linenos">608</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="DataFrame.dropDuplicates-609"><a href="#DataFrame.dropDuplicates-609"><span class="linenos">609</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame.dropDuplicates-610"><a href="#DataFrame.dropDuplicates-610"><span class="linenos">610</span></a> <span class="o">.</span><span class="n">withColumn</span><span class="p">(</span><span class="s2">"row_num"</span><span class="p">,</span> <span class="n">F</span><span class="o">.</span><span class="n">row_number</span><span class="p">()</span><span class="o">.</span><span class="n">over</span><span class="p">(</span><span class="n">window</span><span class="p">))</span> -</span><span id="DataFrame.dropDuplicates-611"><a href="#DataFrame.dropDuplicates-611"><span class="linenos">611</span></a> <span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">F</span><span class="o">.</span><span class="n">col</span><span class="p">(</span><span class="s2">"row_num"</span><span class="p">)</span> <span class="o">==</span> <span class="n">F</span><span class="o">.</span><span class="n">lit</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span> -</span><span id="DataFrame.dropDuplicates-612"><a href="#DataFrame.dropDuplicates-612"><span class="linenos">612</span></a> <span class="o">.</span><span class="n">drop</span><span class="p">(</span><span class="s2">"row_num"</span><span class="p">)</span> -</span><span id="DataFrame.dropDuplicates-613"><a href="#DataFrame.dropDuplicates-613"><span class="linenos">613</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.dropDuplicates-603"><a href="#DataFrame.dropDuplicates-603"><span class="linenos">603</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> +</span><span id="DataFrame.dropDuplicates-604"><a href="#DataFrame.dropDuplicates-604"><span class="linenos">604</span></a> <span class="k">def</span> <span class="nf">dropDuplicates</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">):</span> +</span><span id="DataFrame.dropDuplicates-605"><a href="#DataFrame.dropDuplicates-605"><span class="linenos">605</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">subset</span><span class="p">:</span> +</span><span id="DataFrame.dropDuplicates-606"><a href="#DataFrame.dropDuplicates-606"><span class="linenos">606</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">distinct</span><span class="p">()</span> +</span><span id="DataFrame.dropDuplicates-607"><a href="#DataFrame.dropDuplicates-607"><span class="linenos">607</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">subset</span><span class="p">)</span> +</span><span id="DataFrame.dropDuplicates-608"><a href="#DataFrame.dropDuplicates-608"><span class="linenos">608</span></a> <span class="n">window</span> <span class="o">=</span> <span class="n">Window</span><span class="o">.</span><span class="n">partitionBy</span><span class="p">(</span><span class="o">*</span><span class="n">column_names</span><span class="p">)</span><span class="o">.</span><span class="n">orderBy</span><span class="p">(</span><span class="o">*</span><span class="n">column_names</span><span class="p">)</span> +</span><span id="DataFrame.dropDuplicates-609"><a href="#DataFrame.dropDuplicates-609"><span class="linenos">609</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="DataFrame.dropDuplicates-610"><a href="#DataFrame.dropDuplicates-610"><span class="linenos">610</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame.dropDuplicates-611"><a href="#DataFrame.dropDuplicates-611"><span class="linenos">611</span></a> <span class="o">.</span><span class="n">withColumn</span><span class="p">(</span><span class="s2">"row_num"</span><span class="p">,</span> <span class="n">F</span><span class="o">.</span><span class="n">row_number</span><span class="p">()</span><span class="o">.</span><span class="n">over</span><span class="p">(</span><span class="n">window</span><span class="p">))</span> +</span><span id="DataFrame.dropDuplicates-612"><a href="#DataFrame.dropDuplicates-612"><span class="linenos">612</span></a> <span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">F</span><span class="o">.</span><span class="n">col</span><span class="p">(</span><span class="s2">"row_num"</span><span class="p">)</span> <span class="o">==</span> <span class="n">F</span><span class="o">.</span><span class="n">lit</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span> +</span><span id="DataFrame.dropDuplicates-613"><a href="#DataFrame.dropDuplicates-613"><span class="linenos">613</span></a> <span class="o">.</span><span class="n">drop</span><span class="p">(</span><span class="s2">"row_num"</span><span class="p">)</span> +</span><span id="DataFrame.dropDuplicates-614"><a href="#DataFrame.dropDuplicates-614"><span class="linenos">614</span></a> <span class="p">)</span> </span></pre></div> @@ -2236,38 +2238,38 @@ is unlikely to come up.</p> </div> <a class="headerlink" href="#DataFrame.dropna"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.dropna-615"><a href="#DataFrame.dropna-615"><span class="linenos">615</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> -</span><span id="DataFrame.dropna-616"><a href="#DataFrame.dropna-616"><span class="linenos">616</span></a> <span class="k">def</span> <span class="nf">dropna</span><span class="p">(</span> -</span><span id="DataFrame.dropna-617"><a href="#DataFrame.dropna-617"><span class="linenos">617</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DataFrame.dropna-618"><a href="#DataFrame.dropna-618"><span class="linenos">618</span></a> <span class="n">how</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"any"</span><span class="p">,</span> -</span><span id="DataFrame.dropna-619"><a href="#DataFrame.dropna-619"><span class="linenos">619</span></a> <span class="n">thresh</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrame.dropna-620"><a href="#DataFrame.dropna-620"><span class="linenos">620</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrame.dropna-621"><a href="#DataFrame.dropna-621"><span class="linenos">621</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.dropna-622"><a href="#DataFrame.dropna-622"><span class="linenos">622</span></a> <span class="n">minimum_non_null</span> <span class="o">=</span> <span class="n">thresh</span> <span class="ow">or</span> <span class="mi">0</span> <span class="c1"># will be determined later if thresh is null</span> -</span><span id="DataFrame.dropna-623"><a href="#DataFrame.dropna-623"><span class="linenos">623</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame.dropna-624"><a href="#DataFrame.dropna-624"><span class="linenos">624</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">new_df</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DataFrame.dropna-625"><a href="#DataFrame.dropna-625"><span class="linenos">625</span></a> <span class="k">if</span> <span class="n">subset</span><span class="p">:</span> -</span><span id="DataFrame.dropna-626"><a href="#DataFrame.dropna-626"><span class="linenos">626</span></a> <span class="n">null_check_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">subset</span><span class="p">)</span> -</span><span id="DataFrame.dropna-627"><a href="#DataFrame.dropna-627"><span class="linenos">627</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame.dropna-628"><a href="#DataFrame.dropna-628"><span class="linenos">628</span></a> <span class="n">null_check_columns</span> <span class="o">=</span> <span class="n">all_columns</span> -</span><span id="DataFrame.dropna-629"><a href="#DataFrame.dropna-629"><span class="linenos">629</span></a> <span class="k">if</span> <span class="n">thresh</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="DataFrame.dropna-630"><a href="#DataFrame.dropna-630"><span class="linenos">630</span></a> <span class="n">minimum_num_nulls</span> <span class="o">=</span> <span class="mi">1</span> <span class="k">if</span> <span class="n">how</span> <span class="o">==</span> <span class="s2">"any"</span> <span class="k">else</span> <span class="nb">len</span><span class="p">(</span><span class="n">null_check_columns</span><span class="p">)</span> -</span><span id="DataFrame.dropna-631"><a href="#DataFrame.dropna-631"><span class="linenos">631</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame.dropna-632"><a href="#DataFrame.dropna-632"><span class="linenos">632</span></a> <span class="n">minimum_num_nulls</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">null_check_columns</span><span class="p">)</span> <span class="o">-</span> <span class="n">minimum_non_null</span> <span class="o">+</span> <span class="mi">1</span> -</span><span id="DataFrame.dropna-633"><a href="#DataFrame.dropna-633"><span class="linenos">633</span></a> <span class="k">if</span> <span class="n">minimum_num_nulls</span> <span class="o">></span> <span class="nb">len</span><span class="p">(</span><span class="n">null_check_columns</span><span class="p">):</span> -</span><span id="DataFrame.dropna-634"><a href="#DataFrame.dropna-634"><span class="linenos">634</span></a> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span> -</span><span id="DataFrame.dropna-635"><a href="#DataFrame.dropna-635"><span class="linenos">635</span></a> <span class="sa">f</span><span class="s2">"The minimum num nulls for dropna must be less than or equal to the number of columns. "</span> -</span><span id="DataFrame.dropna-636"><a href="#DataFrame.dropna-636"><span class="linenos">636</span></a> <span class="sa">f</span><span class="s2">"Minimum num nulls: </span><span class="si">{</span><span class="n">minimum_num_nulls</span><span class="si">}</span><span class="s2">, Num Columns: </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">null_check_columns</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="DataFrame.dropna-637"><a href="#DataFrame.dropna-637"><span class="linenos">637</span></a> <span class="p">)</span> -</span><span id="DataFrame.dropna-638"><a href="#DataFrame.dropna-638"><span class="linenos">638</span></a> <span class="n">if_null_checks</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame.dropna-639"><a href="#DataFrame.dropna-639"><span class="linenos">639</span></a> <span class="n">F</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">isNull</span><span class="p">(),</span> <span class="n">F</span><span class="o">.</span><span class="n">lit</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span><span class="o">.</span><span class="n">otherwise</span><span class="p">(</span><span class="n">F</span><span class="o">.</span><span class="n">lit</span><span class="p">(</span><span class="mi">0</span><span class="p">))</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">null_check_columns</span> -</span><span id="DataFrame.dropna-640"><a href="#DataFrame.dropna-640"><span class="linenos">640</span></a> <span class="p">]</span> -</span><span id="DataFrame.dropna-641"><a href="#DataFrame.dropna-641"><span class="linenos">641</span></a> <span class="n">nulls_added_together</span> <span class="o">=</span> <span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">if_null_checks</span><span class="p">)</span> -</span><span id="DataFrame.dropna-642"><a href="#DataFrame.dropna-642"><span class="linenos">642</span></a> <span class="n">num_nulls</span> <span class="o">=</span> <span class="n">nulls_added_together</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span><span class="s2">"num_nulls"</span><span class="p">)</span> -</span><span id="DataFrame.dropna-643"><a href="#DataFrame.dropna-643"><span class="linenos">643</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="n">num_nulls</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="DataFrame.dropna-644"><a href="#DataFrame.dropna-644"><span class="linenos">644</span></a> <span class="n">filtered_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">F</span><span class="o">.</span><span class="n">col</span><span class="p">(</span><span class="s2">"num_nulls"</span><span class="p">)</span> <span class="o"><</span> <span class="n">F</span><span class="o">.</span><span class="n">lit</span><span class="p">(</span><span class="n">minimum_num_nulls</span><span class="p">))</span> -</span><span id="DataFrame.dropna-645"><a href="#DataFrame.dropna-645"><span class="linenos">645</span></a> <span class="n">final_df</span> <span class="o">=</span> <span class="n">filtered_df</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">all_columns</span><span class="p">)</span> -</span><span id="DataFrame.dropna-646"><a href="#DataFrame.dropna-646"><span class="linenos">646</span></a> <span class="k">return</span> <span class="n">final_df</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.dropna-616"><a href="#DataFrame.dropna-616"><span class="linenos">616</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> +</span><span id="DataFrame.dropna-617"><a href="#DataFrame.dropna-617"><span class="linenos">617</span></a> <span class="k">def</span> <span class="nf">dropna</span><span class="p">(</span> +</span><span id="DataFrame.dropna-618"><a href="#DataFrame.dropna-618"><span class="linenos">618</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DataFrame.dropna-619"><a href="#DataFrame.dropna-619"><span class="linenos">619</span></a> <span class="n">how</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"any"</span><span class="p">,</span> +</span><span id="DataFrame.dropna-620"><a href="#DataFrame.dropna-620"><span class="linenos">620</span></a> <span class="n">thresh</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrame.dropna-621"><a href="#DataFrame.dropna-621"><span class="linenos">621</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrame.dropna-622"><a href="#DataFrame.dropna-622"><span class="linenos">622</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.dropna-623"><a href="#DataFrame.dropna-623"><span class="linenos">623</span></a> <span class="n">minimum_non_null</span> <span class="o">=</span> <span class="n">thresh</span> <span class="ow">or</span> <span class="mi">0</span> <span class="c1"># will be determined later if thresh is null</span> +</span><span id="DataFrame.dropna-624"><a href="#DataFrame.dropna-624"><span class="linenos">624</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame.dropna-625"><a href="#DataFrame.dropna-625"><span class="linenos">625</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">new_df</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DataFrame.dropna-626"><a href="#DataFrame.dropna-626"><span class="linenos">626</span></a> <span class="k">if</span> <span class="n">subset</span><span class="p">:</span> +</span><span id="DataFrame.dropna-627"><a href="#DataFrame.dropna-627"><span class="linenos">627</span></a> <span class="n">null_check_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">subset</span><span class="p">)</span> +</span><span id="DataFrame.dropna-628"><a href="#DataFrame.dropna-628"><span class="linenos">628</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame.dropna-629"><a href="#DataFrame.dropna-629"><span class="linenos">629</span></a> <span class="n">null_check_columns</span> <span class="o">=</span> <span class="n">all_columns</span> +</span><span id="DataFrame.dropna-630"><a href="#DataFrame.dropna-630"><span class="linenos">630</span></a> <span class="k">if</span> <span class="n">thresh</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="DataFrame.dropna-631"><a href="#DataFrame.dropna-631"><span class="linenos">631</span></a> <span class="n">minimum_num_nulls</span> <span class="o">=</span> <span class="mi">1</span> <span class="k">if</span> <span class="n">how</span> <span class="o">==</span> <span class="s2">"any"</span> <span class="k">else</span> <span class="nb">len</span><span class="p">(</span><span class="n">null_check_columns</span><span class="p">)</span> +</span><span id="DataFrame.dropna-632"><a href="#DataFrame.dropna-632"><span class="linenos">632</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame.dropna-633"><a href="#DataFrame.dropna-633"><span class="linenos">633</span></a> <span class="n">minimum_num_nulls</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">null_check_columns</span><span class="p">)</span> <span class="o">-</span> <span class="n">minimum_non_null</span> <span class="o">+</span> <span class="mi">1</span> +</span><span id="DataFrame.dropna-634"><a href="#DataFrame.dropna-634"><span class="linenos">634</span></a> <span class="k">if</span> <span class="n">minimum_num_nulls</span> <span class="o">></span> <span class="nb">len</span><span class="p">(</span><span class="n">null_check_columns</span><span class="p">):</span> +</span><span id="DataFrame.dropna-635"><a href="#DataFrame.dropna-635"><span class="linenos">635</span></a> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span> +</span><span id="DataFrame.dropna-636"><a href="#DataFrame.dropna-636"><span class="linenos">636</span></a> <span class="sa">f</span><span class="s2">"The minimum num nulls for dropna must be less than or equal to the number of columns. "</span> +</span><span id="DataFrame.dropna-637"><a href="#DataFrame.dropna-637"><span class="linenos">637</span></a> <span class="sa">f</span><span class="s2">"Minimum num nulls: </span><span class="si">{</span><span class="n">minimum_num_nulls</span><span class="si">}</span><span class="s2">, Num Columns: </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">null_check_columns</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="DataFrame.dropna-638"><a href="#DataFrame.dropna-638"><span class="linenos">638</span></a> <span class="p">)</span> +</span><span id="DataFrame.dropna-639"><a href="#DataFrame.dropna-639"><span class="linenos">639</span></a> <span class="n">if_null_checks</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame.dropna-640"><a href="#DataFrame.dropna-640"><span class="linenos">640</span></a> <span class="n">F</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">isNull</span><span class="p">(),</span> <span class="n">F</span><span class="o">.</span><span class="n">lit</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span><span class="o">.</span><span class="n">otherwise</span><span class="p">(</span><span class="n">F</span><span class="o">.</span><span class="n">lit</span><span class="p">(</span><span class="mi">0</span><span class="p">))</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">null_check_columns</span> +</span><span id="DataFrame.dropna-641"><a href="#DataFrame.dropna-641"><span class="linenos">641</span></a> <span class="p">]</span> +</span><span id="DataFrame.dropna-642"><a href="#DataFrame.dropna-642"><span class="linenos">642</span></a> <span class="n">nulls_added_together</span> <span class="o">=</span> <span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span> <span class="o">+</span> <span class="n">y</span><span class="p">,</span> <span class="n">if_null_checks</span><span class="p">)</span> +</span><span id="DataFrame.dropna-643"><a href="#DataFrame.dropna-643"><span class="linenos">643</span></a> <span class="n">num_nulls</span> <span class="o">=</span> <span class="n">nulls_added_together</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span><span class="s2">"num_nulls"</span><span class="p">)</span> +</span><span id="DataFrame.dropna-644"><a href="#DataFrame.dropna-644"><span class="linenos">644</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="n">num_nulls</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="DataFrame.dropna-645"><a href="#DataFrame.dropna-645"><span class="linenos">645</span></a> <span class="n">filtered_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">F</span><span class="o">.</span><span class="n">col</span><span class="p">(</span><span class="s2">"num_nulls"</span><span class="p">)</span> <span class="o"><</span> <span class="n">F</span><span class="o">.</span><span class="n">lit</span><span class="p">(</span><span class="n">minimum_num_nulls</span><span class="p">))</span> +</span><span id="DataFrame.dropna-646"><a href="#DataFrame.dropna-646"><span class="linenos">646</span></a> <span class="n">final_df</span> <span class="o">=</span> <span class="n">filtered_df</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">all_columns</span><span class="p">)</span> +</span><span id="DataFrame.dropna-647"><a href="#DataFrame.dropna-647"><span class="linenos">647</span></a> <span class="k">return</span> <span class="n">final_df</span> </span></pre></div> @@ -2280,55 +2282,55 @@ is unlikely to come up.</p> <div class="decorator">@operation(Operation.FROM)</div> <span class="def">def</span> - <span class="name">fillna</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="n">value</span><span class="p">:</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043310407712'</span><span class="o">></span>,</span><span class="param"> <span class="n">subset</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">NoneType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span></span><span class="return-annotation">) -> <span class="n"><a href="#DataFrame">sqlglot.dataframe.sql.DataFrame</a></span>:</span></span> + <span class="name">fillna</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="n">value</span><span class="p">:</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135089923520'</span><span class="o">></span>,</span><span class="param"> <span class="n">subset</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">NoneType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span></span><span class="return-annotation">) -> <span class="n"><a href="#DataFrame">sqlglot.dataframe.sql.DataFrame</a></span>:</span></span> <label class="view-source-button" for="DataFrame.fillna-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#DataFrame.fillna"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.fillna-648"><a href="#DataFrame.fillna-648"><span class="linenos">648</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> -</span><span id="DataFrame.fillna-649"><a href="#DataFrame.fillna-649"><span class="linenos">649</span></a> <span class="k">def</span> <span class="nf">fillna</span><span class="p">(</span> -</span><span id="DataFrame.fillna-650"><a href="#DataFrame.fillna-650"><span class="linenos">650</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DataFrame.fillna-651"><a href="#DataFrame.fillna-651"><span class="linenos">651</span></a> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnLiterals</span><span class="p">],</span> -</span><span id="DataFrame.fillna-652"><a href="#DataFrame.fillna-652"><span class="linenos">652</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrame.fillna-653"><a href="#DataFrame.fillna-653"><span class="linenos">653</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.fillna-654"><a href="#DataFrame.fillna-654"><span class="linenos">654</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="DataFrame.fillna-655"><a href="#DataFrame.fillna-655"><span class="linenos">655</span></a><span class="sd"> Functionality Difference: If you provide a value to replace a null and that type conflicts</span> -</span><span id="DataFrame.fillna-656"><a href="#DataFrame.fillna-656"><span class="linenos">656</span></a><span class="sd"> with the type of the column then PySpark will just ignore your replacement.</span> -</span><span id="DataFrame.fillna-657"><a href="#DataFrame.fillna-657"><span class="linenos">657</span></a><span class="sd"> This will try to cast them to be the same in some cases. So they won't always match.</span> -</span><span id="DataFrame.fillna-658"><a href="#DataFrame.fillna-658"><span class="linenos">658</span></a><span class="sd"> Best to not mix types so make sure replacement is the same type as the column</span> -</span><span id="DataFrame.fillna-659"><a href="#DataFrame.fillna-659"><span class="linenos">659</span></a> -</span><span id="DataFrame.fillna-660"><a href="#DataFrame.fillna-660"><span class="linenos">660</span></a><span class="sd"> Possibility for improvement: Use `typeof` function to get the type of the column</span> -</span><span id="DataFrame.fillna-661"><a href="#DataFrame.fillna-661"><span class="linenos">661</span></a><span class="sd"> and check if it matches the type of the value provided. If not then make it null.</span> -</span><span id="DataFrame.fillna-662"><a href="#DataFrame.fillna-662"><span class="linenos">662</span></a><span class="sd"> """</span> -</span><span id="DataFrame.fillna-663"><a href="#DataFrame.fillna-663"><span class="linenos">663</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">lit</span> -</span><span id="DataFrame.fillna-664"><a href="#DataFrame.fillna-664"><span class="linenos">664</span></a> -</span><span id="DataFrame.fillna-665"><a href="#DataFrame.fillna-665"><span class="linenos">665</span></a> <span class="n">values</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="DataFrame.fillna-666"><a href="#DataFrame.fillna-666"><span class="linenos">666</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="DataFrame.fillna-667"><a href="#DataFrame.fillna-667"><span class="linenos">667</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame.fillna-668"><a href="#DataFrame.fillna-668"><span class="linenos">668</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">new_df</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DataFrame.fillna-669"><a href="#DataFrame.fillna-669"><span class="linenos">669</span></a> <span class="n">all_column_mapping</span> <span class="o">=</span> <span class="p">{</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="n">column</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">all_columns</span><span class="p">}</span> -</span><span id="DataFrame.fillna-670"><a href="#DataFrame.fillna-670"><span class="linenos">670</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span> -</span><span id="DataFrame.fillna-671"><a href="#DataFrame.fillna-671"><span class="linenos">671</span></a> <span class="n">values</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">value</span><span class="o">.</span><span class="n">values</span><span class="p">())</span> -</span><span id="DataFrame.fillna-672"><a href="#DataFrame.fillna-672"><span class="linenos">672</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">value</span><span class="p">))</span> -</span><span id="DataFrame.fillna-673"><a href="#DataFrame.fillna-673"><span class="linenos">673</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">columns</span><span class="p">:</span> -</span><span id="DataFrame.fillna-674"><a href="#DataFrame.fillna-674"><span class="linenos">674</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">subset</span><span class="p">)</span> <span class="k">if</span> <span class="n">subset</span> <span class="k">else</span> <span class="n">all_columns</span> -</span><span id="DataFrame.fillna-675"><a href="#DataFrame.fillna-675"><span class="linenos">675</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">values</span><span class="p">:</span> -</span><span id="DataFrame.fillna-676"><a href="#DataFrame.fillna-676"><span class="linenos">676</span></a> <span class="n">values</span> <span class="o">=</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> -</span><span id="DataFrame.fillna-677"><a href="#DataFrame.fillna-677"><span class="linenos">677</span></a> <span class="n">value_columns</span> <span class="o">=</span> <span class="p">[</span><span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">values</span><span class="p">]</span> -</span><span id="DataFrame.fillna-678"><a href="#DataFrame.fillna-678"><span class="linenos">678</span></a> -</span><span id="DataFrame.fillna-679"><a href="#DataFrame.fillna-679"><span class="linenos">679</span></a> <span class="n">null_replacement_mapping</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DataFrame.fillna-680"><a href="#DataFrame.fillna-680"><span class="linenos">680</span></a> <span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="p">(</span> -</span><span id="DataFrame.fillna-681"><a href="#DataFrame.fillna-681"><span class="linenos">681</span></a> <span class="n">F</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">isNull</span><span class="p">(),</span> <span class="n">value</span><span class="p">)</span><span class="o">.</span><span class="n">otherwise</span><span class="p">(</span><span class="n">column</span><span class="p">)</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">)</span> -</span><span id="DataFrame.fillna-682"><a href="#DataFrame.fillna-682"><span class="linenos">682</span></a> <span class="p">)</span> -</span><span id="DataFrame.fillna-683"><a href="#DataFrame.fillna-683"><span class="linenos">683</span></a> <span class="k">for</span> <span class="n">column</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">columns</span><span class="p">,</span> <span class="n">value_columns</span><span class="p">)</span> -</span><span id="DataFrame.fillna-684"><a href="#DataFrame.fillna-684"><span class="linenos">684</span></a> <span class="p">}</span> -</span><span id="DataFrame.fillna-685"><a href="#DataFrame.fillna-685"><span class="linenos">685</span></a> <span class="n">null_replacement_mapping</span> <span class="o">=</span> <span class="p">{</span><span class="o">**</span><span class="n">all_column_mapping</span><span class="p">,</span> <span class="o">**</span><span class="n">null_replacement_mapping</span><span class="p">}</span> -</span><span id="DataFrame.fillna-686"><a href="#DataFrame.fillna-686"><span class="linenos">686</span></a> <span class="n">null_replacement_columns</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame.fillna-687"><a href="#DataFrame.fillna-687"><span class="linenos">687</span></a> <span class="n">null_replacement_mapping</span><span class="p">[</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">all_columns</span> -</span><span id="DataFrame.fillna-688"><a href="#DataFrame.fillna-688"><span class="linenos">688</span></a> <span class="p">]</span> -</span><span id="DataFrame.fillna-689"><a href="#DataFrame.fillna-689"><span class="linenos">689</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">null_replacement_columns</span><span class="p">)</span> -</span><span id="DataFrame.fillna-690"><a href="#DataFrame.fillna-690"><span class="linenos">690</span></a> <span class="k">return</span> <span class="n">new_df</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.fillna-649"><a href="#DataFrame.fillna-649"><span class="linenos">649</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> +</span><span id="DataFrame.fillna-650"><a href="#DataFrame.fillna-650"><span class="linenos">650</span></a> <span class="k">def</span> <span class="nf">fillna</span><span class="p">(</span> +</span><span id="DataFrame.fillna-651"><a href="#DataFrame.fillna-651"><span class="linenos">651</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DataFrame.fillna-652"><a href="#DataFrame.fillna-652"><span class="linenos">652</span></a> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnLiterals</span><span class="p">],</span> +</span><span id="DataFrame.fillna-653"><a href="#DataFrame.fillna-653"><span class="linenos">653</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrame.fillna-654"><a href="#DataFrame.fillna-654"><span class="linenos">654</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.fillna-655"><a href="#DataFrame.fillna-655"><span class="linenos">655</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="DataFrame.fillna-656"><a href="#DataFrame.fillna-656"><span class="linenos">656</span></a><span class="sd"> Functionality Difference: If you provide a value to replace a null and that type conflicts</span> +</span><span id="DataFrame.fillna-657"><a href="#DataFrame.fillna-657"><span class="linenos">657</span></a><span class="sd"> with the type of the column then PySpark will just ignore your replacement.</span> +</span><span id="DataFrame.fillna-658"><a href="#DataFrame.fillna-658"><span class="linenos">658</span></a><span class="sd"> This will try to cast them to be the same in some cases. So they won't always match.</span> +</span><span id="DataFrame.fillna-659"><a href="#DataFrame.fillna-659"><span class="linenos">659</span></a><span class="sd"> Best to not mix types so make sure replacement is the same type as the column</span> +</span><span id="DataFrame.fillna-660"><a href="#DataFrame.fillna-660"><span class="linenos">660</span></a> +</span><span id="DataFrame.fillna-661"><a href="#DataFrame.fillna-661"><span class="linenos">661</span></a><span class="sd"> Possibility for improvement: Use `typeof` function to get the type of the column</span> +</span><span id="DataFrame.fillna-662"><a href="#DataFrame.fillna-662"><span class="linenos">662</span></a><span class="sd"> and check if it matches the type of the value provided. If not then make it null.</span> +</span><span id="DataFrame.fillna-663"><a href="#DataFrame.fillna-663"><span class="linenos">663</span></a><span class="sd"> """</span> +</span><span id="DataFrame.fillna-664"><a href="#DataFrame.fillna-664"><span class="linenos">664</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">lit</span> +</span><span id="DataFrame.fillna-665"><a href="#DataFrame.fillna-665"><span class="linenos">665</span></a> +</span><span id="DataFrame.fillna-666"><a href="#DataFrame.fillna-666"><span class="linenos">666</span></a> <span class="n">values</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="DataFrame.fillna-667"><a href="#DataFrame.fillna-667"><span class="linenos">667</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="DataFrame.fillna-668"><a href="#DataFrame.fillna-668"><span class="linenos">668</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame.fillna-669"><a href="#DataFrame.fillna-669"><span class="linenos">669</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">new_df</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DataFrame.fillna-670"><a href="#DataFrame.fillna-670"><span class="linenos">670</span></a> <span class="n">all_column_mapping</span> <span class="o">=</span> <span class="p">{</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="n">column</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">all_columns</span><span class="p">}</span> +</span><span id="DataFrame.fillna-671"><a href="#DataFrame.fillna-671"><span class="linenos">671</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span> +</span><span id="DataFrame.fillna-672"><a href="#DataFrame.fillna-672"><span class="linenos">672</span></a> <span class="n">values</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">value</span><span class="o">.</span><span class="n">values</span><span class="p">())</span> +</span><span id="DataFrame.fillna-673"><a href="#DataFrame.fillna-673"><span class="linenos">673</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">value</span><span class="p">))</span> +</span><span id="DataFrame.fillna-674"><a href="#DataFrame.fillna-674"><span class="linenos">674</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">columns</span><span class="p">:</span> +</span><span id="DataFrame.fillna-675"><a href="#DataFrame.fillna-675"><span class="linenos">675</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">subset</span><span class="p">)</span> <span class="k">if</span> <span class="n">subset</span> <span class="k">else</span> <span class="n">all_columns</span> +</span><span id="DataFrame.fillna-676"><a href="#DataFrame.fillna-676"><span class="linenos">676</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">values</span><span class="p">:</span> +</span><span id="DataFrame.fillna-677"><a href="#DataFrame.fillna-677"><span class="linenos">677</span></a> <span class="n">values</span> <span class="o">=</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> +</span><span id="DataFrame.fillna-678"><a href="#DataFrame.fillna-678"><span class="linenos">678</span></a> <span class="n">value_columns</span> <span class="o">=</span> <span class="p">[</span><span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">values</span><span class="p">]</span> +</span><span id="DataFrame.fillna-679"><a href="#DataFrame.fillna-679"><span class="linenos">679</span></a> +</span><span id="DataFrame.fillna-680"><a href="#DataFrame.fillna-680"><span class="linenos">680</span></a> <span class="n">null_replacement_mapping</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DataFrame.fillna-681"><a href="#DataFrame.fillna-681"><span class="linenos">681</span></a> <span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="p">(</span> +</span><span id="DataFrame.fillna-682"><a href="#DataFrame.fillna-682"><span class="linenos">682</span></a> <span class="n">F</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">isNull</span><span class="p">(),</span> <span class="n">value</span><span class="p">)</span><span class="o">.</span><span class="n">otherwise</span><span class="p">(</span><span class="n">column</span><span class="p">)</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">)</span> +</span><span id="DataFrame.fillna-683"><a href="#DataFrame.fillna-683"><span class="linenos">683</span></a> <span class="p">)</span> +</span><span id="DataFrame.fillna-684"><a href="#DataFrame.fillna-684"><span class="linenos">684</span></a> <span class="k">for</span> <span class="n">column</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">columns</span><span class="p">,</span> <span class="n">value_columns</span><span class="p">)</span> +</span><span id="DataFrame.fillna-685"><a href="#DataFrame.fillna-685"><span class="linenos">685</span></a> <span class="p">}</span> +</span><span id="DataFrame.fillna-686"><a href="#DataFrame.fillna-686"><span class="linenos">686</span></a> <span class="n">null_replacement_mapping</span> <span class="o">=</span> <span class="p">{</span><span class="o">**</span><span class="n">all_column_mapping</span><span class="p">,</span> <span class="o">**</span><span class="n">null_replacement_mapping</span><span class="p">}</span> +</span><span id="DataFrame.fillna-687"><a href="#DataFrame.fillna-687"><span class="linenos">687</span></a> <span class="n">null_replacement_columns</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame.fillna-688"><a href="#DataFrame.fillna-688"><span class="linenos">688</span></a> <span class="n">null_replacement_mapping</span><span class="p">[</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">all_columns</span> +</span><span id="DataFrame.fillna-689"><a href="#DataFrame.fillna-689"><span class="linenos">689</span></a> <span class="p">]</span> +</span><span id="DataFrame.fillna-690"><a href="#DataFrame.fillna-690"><span class="linenos">690</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">null_replacement_columns</span><span class="p">)</span> +</span><span id="DataFrame.fillna-691"><a href="#DataFrame.fillna-691"><span class="linenos">691</span></a> <span class="k">return</span> <span class="n">new_df</span> </span></pre></div> @@ -2349,59 +2351,59 @@ and check if it matches the type of the value provided. If not then make it null <div class="decorator">@operation(Operation.FROM)</div> <span class="def">def</span> - <span class="name">replace</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="n">to_replace</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">List</span><span class="p">,</span> <span class="n">Dict</span><span class="p">]</span>,</span><span class="param"> <span class="n">value</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">List</span><span class="p">,</span> <span class="n">NoneType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>,</span><span class="param"> <span class="n">subset</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="n">Collection</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043310703920'</span><span class="o">></span><span class="p">],</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043310703920'</span><span class="o">></span><span class="p">,</span> <span class="n">NoneType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span></span><span class="return-annotation">) -> <span class="n"><a href="#DataFrame">sqlglot.dataframe.sql.DataFrame</a></span>:</span></span> + <span class="name">replace</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="n">to_replace</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">List</span><span class="p">,</span> <span class="n">Dict</span><span class="p">]</span>,</span><span class="param"> <span class="n">value</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">List</span><span class="p">,</span> <span class="n">NoneType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>,</span><span class="param"> <span class="n">subset</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="n">Collection</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135090028608'</span><span class="o">></span><span class="p">],</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135090028608'</span><span class="o">></span><span class="p">,</span> <span class="n">NoneType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span></span><span class="return-annotation">) -> <span class="n"><a href="#DataFrame">sqlglot.dataframe.sql.DataFrame</a></span>:</span></span> <label class="view-source-button" for="DataFrame.replace-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#DataFrame.replace"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.replace-692"><a href="#DataFrame.replace-692"><span class="linenos">692</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> -</span><span id="DataFrame.replace-693"><a href="#DataFrame.replace-693"><span class="linenos">693</span></a> <span class="k">def</span> <span class="nf">replace</span><span class="p">(</span> -</span><span id="DataFrame.replace-694"><a href="#DataFrame.replace-694"><span class="linenos">694</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DataFrame.replace-695"><a href="#DataFrame.replace-695"><span class="linenos">695</span></a> <span class="n">to_replace</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</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">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">],</span> -</span><span id="DataFrame.replace-696"><a href="#DataFrame.replace-696"><span class="linenos">696</span></a> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrame.replace-697"><a href="#DataFrame.replace-697"><span class="linenos">697</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">ColumnOrName</span><span class="p">]</span> <span class="o">|</span> <span class="n">ColumnOrName</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrame.replace-698"><a href="#DataFrame.replace-698"><span class="linenos">698</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.replace-699"><a href="#DataFrame.replace-699"><span class="linenos">699</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">lit</span> -</span><span id="DataFrame.replace-700"><a href="#DataFrame.replace-700"><span class="linenos">700</span></a> -</span><span id="DataFrame.replace-701"><a href="#DataFrame.replace-701"><span class="linenos">701</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="DataFrame.replace-702"><a href="#DataFrame.replace-702"><span class="linenos">702</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame.replace-703"><a href="#DataFrame.replace-703"><span class="linenos">703</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">new_df</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DataFrame.replace-704"><a href="#DataFrame.replace-704"><span class="linenos">704</span></a> <span class="n">all_column_mapping</span> <span class="o">=</span> <span class="p">{</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="n">column</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">all_columns</span><span class="p">}</span> -</span><span id="DataFrame.replace-705"><a href="#DataFrame.replace-705"><span class="linenos">705</span></a> -</span><span id="DataFrame.replace-706"><a href="#DataFrame.replace-706"><span class="linenos">706</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">subset</span><span class="p">)</span> <span class="k">if</span> <span class="n">subset</span> <span class="k">else</span> <span class="n">all_columns</span> -</span><span id="DataFrame.replace-707"><a href="#DataFrame.replace-707"><span class="linenos">707</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">to_replace</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span> -</span><span id="DataFrame.replace-708"><a href="#DataFrame.replace-708"><span class="linenos">708</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">to_replace</span><span class="p">)</span> -</span><span id="DataFrame.replace-709"><a href="#DataFrame.replace-709"><span class="linenos">709</span></a> <span class="n">new_values</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">to_replace</span><span class="o">.</span><span class="n">values</span><span class="p">())</span> -</span><span id="DataFrame.replace-710"><a href="#DataFrame.replace-710"><span class="linenos">710</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">old_values</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">to_replace</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="DataFrame.replace-711"><a href="#DataFrame.replace-711"><span class="linenos">711</span></a> <span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">list</span><span class="p">),</span> <span class="s2">"value must be a list since the replacements are a list"</span> -</span><span id="DataFrame.replace-712"><a href="#DataFrame.replace-712"><span class="linenos">712</span></a> <span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">to_replace</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span> -</span><span id="DataFrame.replace-713"><a href="#DataFrame.replace-713"><span class="linenos">713</span></a> <span class="n">value</span> -</span><span id="DataFrame.replace-714"><a href="#DataFrame.replace-714"><span class="linenos">714</span></a> <span class="p">),</span> <span class="s2">"the replacements and values must be the same length"</span> -</span><span id="DataFrame.replace-715"><a href="#DataFrame.replace-715"><span class="linenos">715</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="n">to_replace</span> -</span><span id="DataFrame.replace-716"><a href="#DataFrame.replace-716"><span class="linenos">716</span></a> <span class="n">new_values</span> <span class="o">=</span> <span class="n">value</span> -</span><span id="DataFrame.replace-717"><a href="#DataFrame.replace-717"><span class="linenos">717</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame.replace-718"><a href="#DataFrame.replace-718"><span class="linenos">718</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="p">[</span><span class="n">to_replace</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> -</span><span id="DataFrame.replace-719"><a href="#DataFrame.replace-719"><span class="linenos">719</span></a> <span class="n">new_values</span> <span class="o">=</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> -</span><span id="DataFrame.replace-720"><a href="#DataFrame.replace-720"><span class="linenos">720</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="p">[</span><span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">old_values</span><span class="p">]</span> -</span><span id="DataFrame.replace-721"><a href="#DataFrame.replace-721"><span class="linenos">721</span></a> <span class="n">new_values</span> <span class="o">=</span> <span class="p">[</span><span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">new_values</span><span class="p">]</span> -</span><span id="DataFrame.replace-722"><a href="#DataFrame.replace-722"><span class="linenos">722</span></a> -</span><span id="DataFrame.replace-723"><a href="#DataFrame.replace-723"><span class="linenos">723</span></a> <span class="n">replacement_mapping</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="DataFrame.replace-724"><a href="#DataFrame.replace-724"><span class="linenos">724</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">columns</span><span class="p">:</span> -</span><span id="DataFrame.replace-725"><a href="#DataFrame.replace-725"><span class="linenos">725</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">Column</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span> -</span><span id="DataFrame.replace-726"><a href="#DataFrame.replace-726"><span class="linenos">726</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="p">(</span><span class="n">old_value</span><span class="p">,</span> <span class="n">new_value</span><span class="p">)</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">old_values</span><span class="p">,</span> <span class="n">new_values</span><span class="p">)):</span> -</span><span id="DataFrame.replace-727"><a href="#DataFrame.replace-727"><span class="linenos">727</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> -</span><span id="DataFrame.replace-728"><a href="#DataFrame.replace-728"><span class="linenos">728</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">F</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">column</span> <span class="o">==</span> <span class="n">old_value</span><span class="p">,</span> <span class="n">new_value</span><span class="p">)</span> -</span><span id="DataFrame.replace-729"><a href="#DataFrame.replace-729"><span class="linenos">729</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame.replace-730"><a href="#DataFrame.replace-730"><span class="linenos">730</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">column</span> <span class="o">==</span> <span class="n">old_value</span><span class="p">,</span> <span class="n">new_value</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="DataFrame.replace-731"><a href="#DataFrame.replace-731"><span class="linenos">731</span></a> <span class="n">replacement_mapping</span><span class="p">[</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">otherwise</span><span class="p">(</span><span class="n">column</span><span class="p">)</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span> -</span><span id="DataFrame.replace-732"><a href="#DataFrame.replace-732"><span class="linenos">732</span></a> <span class="n">column</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">alias_or_name</span> -</span><span id="DataFrame.replace-733"><a href="#DataFrame.replace-733"><span class="linenos">733</span></a> <span class="p">)</span> -</span><span id="DataFrame.replace-734"><a href="#DataFrame.replace-734"><span class="linenos">734</span></a> -</span><span id="DataFrame.replace-735"><a href="#DataFrame.replace-735"><span class="linenos">735</span></a> <span class="n">replacement_mapping</span> <span class="o">=</span> <span class="p">{</span><span class="o">**</span><span class="n">all_column_mapping</span><span class="p">,</span> <span class="o">**</span><span class="n">replacement_mapping</span><span class="p">}</span> -</span><span id="DataFrame.replace-736"><a href="#DataFrame.replace-736"><span class="linenos">736</span></a> <span class="n">replacement_columns</span> <span class="o">=</span> <span class="p">[</span><span class="n">replacement_mapping</span><span class="p">[</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">all_columns</span><span class="p">]</span> -</span><span id="DataFrame.replace-737"><a href="#DataFrame.replace-737"><span class="linenos">737</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">replacement_columns</span><span class="p">)</span> -</span><span id="DataFrame.replace-738"><a href="#DataFrame.replace-738"><span class="linenos">738</span></a> <span class="k">return</span> <span class="n">new_df</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.replace-693"><a href="#DataFrame.replace-693"><span class="linenos">693</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">FROM</span><span class="p">)</span> +</span><span id="DataFrame.replace-694"><a href="#DataFrame.replace-694"><span class="linenos">694</span></a> <span class="k">def</span> <span class="nf">replace</span><span class="p">(</span> +</span><span id="DataFrame.replace-695"><a href="#DataFrame.replace-695"><span class="linenos">695</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DataFrame.replace-696"><a href="#DataFrame.replace-696"><span class="linenos">696</span></a> <span class="n">to_replace</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</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">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">],</span> +</span><span id="DataFrame.replace-697"><a href="#DataFrame.replace-697"><span class="linenos">697</span></a> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrame.replace-698"><a href="#DataFrame.replace-698"><span class="linenos">698</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">ColumnOrName</span><span class="p">]</span> <span class="o">|</span> <span class="n">ColumnOrName</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrame.replace-699"><a href="#DataFrame.replace-699"><span class="linenos">699</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.replace-700"><a href="#DataFrame.replace-700"><span class="linenos">700</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">lit</span> +</span><span id="DataFrame.replace-701"><a href="#DataFrame.replace-701"><span class="linenos">701</span></a> +</span><span id="DataFrame.replace-702"><a href="#DataFrame.replace-702"><span class="linenos">702</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="DataFrame.replace-703"><a href="#DataFrame.replace-703"><span class="linenos">703</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame.replace-704"><a href="#DataFrame.replace-704"><span class="linenos">704</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="n">new_df</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DataFrame.replace-705"><a href="#DataFrame.replace-705"><span class="linenos">705</span></a> <span class="n">all_column_mapping</span> <span class="o">=</span> <span class="p">{</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="n">column</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">all_columns</span><span class="p">}</span> +</span><span id="DataFrame.replace-706"><a href="#DataFrame.replace-706"><span class="linenos">706</span></a> +</span><span id="DataFrame.replace-707"><a href="#DataFrame.replace-707"><span class="linenos">707</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">subset</span><span class="p">)</span> <span class="k">if</span> <span class="n">subset</span> <span class="k">else</span> <span class="n">all_columns</span> +</span><span id="DataFrame.replace-708"><a href="#DataFrame.replace-708"><span class="linenos">708</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">to_replace</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span> +</span><span id="DataFrame.replace-709"><a href="#DataFrame.replace-709"><span class="linenos">709</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">to_replace</span><span class="p">)</span> +</span><span id="DataFrame.replace-710"><a href="#DataFrame.replace-710"><span class="linenos">710</span></a> <span class="n">new_values</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">to_replace</span><span class="o">.</span><span class="n">values</span><span class="p">())</span> +</span><span id="DataFrame.replace-711"><a href="#DataFrame.replace-711"><span class="linenos">711</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">old_values</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">to_replace</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="DataFrame.replace-712"><a href="#DataFrame.replace-712"><span class="linenos">712</span></a> <span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">list</span><span class="p">),</span> <span class="s2">"value must be a list since the replacements are a list"</span> +</span><span id="DataFrame.replace-713"><a href="#DataFrame.replace-713"><span class="linenos">713</span></a> <span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">to_replace</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span> +</span><span id="DataFrame.replace-714"><a href="#DataFrame.replace-714"><span class="linenos">714</span></a> <span class="n">value</span> +</span><span id="DataFrame.replace-715"><a href="#DataFrame.replace-715"><span class="linenos">715</span></a> <span class="p">),</span> <span class="s2">"the replacements and values must be the same length"</span> +</span><span id="DataFrame.replace-716"><a href="#DataFrame.replace-716"><span class="linenos">716</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="n">to_replace</span> +</span><span id="DataFrame.replace-717"><a href="#DataFrame.replace-717"><span class="linenos">717</span></a> <span class="n">new_values</span> <span class="o">=</span> <span class="n">value</span> +</span><span id="DataFrame.replace-718"><a href="#DataFrame.replace-718"><span class="linenos">718</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame.replace-719"><a href="#DataFrame.replace-719"><span class="linenos">719</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="p">[</span><span class="n">to_replace</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> +</span><span id="DataFrame.replace-720"><a href="#DataFrame.replace-720"><span class="linenos">720</span></a> <span class="n">new_values</span> <span class="o">=</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> +</span><span id="DataFrame.replace-721"><a href="#DataFrame.replace-721"><span class="linenos">721</span></a> <span class="n">old_values</span> <span class="o">=</span> <span class="p">[</span><span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">old_values</span><span class="p">]</span> +</span><span id="DataFrame.replace-722"><a href="#DataFrame.replace-722"><span class="linenos">722</span></a> <span class="n">new_values</span> <span class="o">=</span> <span class="p">[</span><span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">new_values</span><span class="p">]</span> +</span><span id="DataFrame.replace-723"><a href="#DataFrame.replace-723"><span class="linenos">723</span></a> +</span><span id="DataFrame.replace-724"><a href="#DataFrame.replace-724"><span class="linenos">724</span></a> <span class="n">replacement_mapping</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="DataFrame.replace-725"><a href="#DataFrame.replace-725"><span class="linenos">725</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">columns</span><span class="p">:</span> +</span><span id="DataFrame.replace-726"><a href="#DataFrame.replace-726"><span class="linenos">726</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">Column</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span> +</span><span id="DataFrame.replace-727"><a href="#DataFrame.replace-727"><span class="linenos">727</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="p">(</span><span class="n">old_value</span><span class="p">,</span> <span class="n">new_value</span><span class="p">)</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">old_values</span><span class="p">,</span> <span class="n">new_values</span><span class="p">)):</span> +</span><span id="DataFrame.replace-728"><a href="#DataFrame.replace-728"><span class="linenos">728</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> +</span><span id="DataFrame.replace-729"><a href="#DataFrame.replace-729"><span class="linenos">729</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">F</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">column</span> <span class="o">==</span> <span class="n">old_value</span><span class="p">,</span> <span class="n">new_value</span><span class="p">)</span> +</span><span id="DataFrame.replace-730"><a href="#DataFrame.replace-730"><span class="linenos">730</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame.replace-731"><a href="#DataFrame.replace-731"><span class="linenos">731</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">when</span><span class="p">(</span><span class="n">column</span> <span class="o">==</span> <span class="n">old_value</span><span class="p">,</span> <span class="n">new_value</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="DataFrame.replace-732"><a href="#DataFrame.replace-732"><span class="linenos">732</span></a> <span class="n">replacement_mapping</span><span class="p">[</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">otherwise</span><span class="p">(</span><span class="n">column</span><span class="p">)</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span> +</span><span id="DataFrame.replace-733"><a href="#DataFrame.replace-733"><span class="linenos">733</span></a> <span class="n">column</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">alias_or_name</span> +</span><span id="DataFrame.replace-734"><a href="#DataFrame.replace-734"><span class="linenos">734</span></a> <span class="p">)</span> +</span><span id="DataFrame.replace-735"><a href="#DataFrame.replace-735"><span class="linenos">735</span></a> +</span><span id="DataFrame.replace-736"><a href="#DataFrame.replace-736"><span class="linenos">736</span></a> <span class="n">replacement_mapping</span> <span class="o">=</span> <span class="p">{</span><span class="o">**</span><span class="n">all_column_mapping</span><span class="p">,</span> <span class="o">**</span><span class="n">replacement_mapping</span><span class="p">}</span> +</span><span id="DataFrame.replace-737"><a href="#DataFrame.replace-737"><span class="linenos">737</span></a> <span class="n">replacement_columns</span> <span class="o">=</span> <span class="p">[</span><span class="n">replacement_mapping</span><span class="p">[</span><span class="n">column</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">all_columns</span><span class="p">]</span> +</span><span id="DataFrame.replace-738"><a href="#DataFrame.replace-738"><span class="linenos">738</span></a> <span class="n">new_df</span> <span class="o">=</span> <span class="n">new_df</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">replacement_columns</span><span class="p">)</span> +</span><span id="DataFrame.replace-739"><a href="#DataFrame.replace-739"><span class="linenos">739</span></a> <span class="k">return</span> <span class="n">new_df</span> </span></pre></div> @@ -2420,18 +2422,18 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#DataFrame.withColumn"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.withColumn-740"><a href="#DataFrame.withColumn-740"><span class="linenos">740</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> -</span><span id="DataFrame.withColumn-741"><a href="#DataFrame.withColumn-741"><span class="linenos">741</span></a> <span class="k">def</span> <span class="nf">withColumn</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">colName</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">col</span><span class="p">:</span> <span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.withColumn-742"><a href="#DataFrame.withColumn-742"><span class="linenos">742</span></a> <span class="n">col</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_col</span><span class="p">(</span><span class="n">col</span><span class="p">)</span> -</span><span id="DataFrame.withColumn-743"><a href="#DataFrame.withColumn-743"><span class="linenos">743</span></a> <span class="n">existing_col_names</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">named_selects</span> -</span><span id="DataFrame.withColumn-744"><a href="#DataFrame.withColumn-744"><span class="linenos">744</span></a> <span class="n">existing_col_index</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="DataFrame.withColumn-745"><a href="#DataFrame.withColumn-745"><span class="linenos">745</span></a> <span class="n">existing_col_names</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">colName</span><span class="p">)</span> <span class="k">if</span> <span class="n">colName</span> <span class="ow">in</span> <span class="n">existing_col_names</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="DataFrame.withColumn-746"><a href="#DataFrame.withColumn-746"><span class="linenos">746</span></a> <span class="p">)</span> -</span><span id="DataFrame.withColumn-747"><a href="#DataFrame.withColumn-747"><span class="linenos">747</span></a> <span class="k">if</span> <span class="n">existing_col_index</span><span class="p">:</span> -</span><span id="DataFrame.withColumn-748"><a href="#DataFrame.withColumn-748"><span class="linenos">748</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame.withColumn-749"><a href="#DataFrame.withColumn-749"><span class="linenos">749</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="n">existing_col_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">col</span><span class="o">.</span><span class="n">expression</span> -</span><span id="DataFrame.withColumn-750"><a href="#DataFrame.withColumn-750"><span class="linenos">750</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DataFrame.withColumn-751"><a href="#DataFrame.withColumn-751"><span class="linenos">751</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="n">col</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span><span class="n">colName</span><span class="p">),</span> <span class="n">append</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.withColumn-741"><a href="#DataFrame.withColumn-741"><span class="linenos">741</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> +</span><span id="DataFrame.withColumn-742"><a href="#DataFrame.withColumn-742"><span class="linenos">742</span></a> <span class="k">def</span> <span class="nf">withColumn</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">colName</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">col</span><span class="p">:</span> <span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.withColumn-743"><a href="#DataFrame.withColumn-743"><span class="linenos">743</span></a> <span class="n">col</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_col</span><span class="p">(</span><span class="n">col</span><span class="p">)</span> +</span><span id="DataFrame.withColumn-744"><a href="#DataFrame.withColumn-744"><span class="linenos">744</span></a> <span class="n">existing_col_names</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">named_selects</span> +</span><span id="DataFrame.withColumn-745"><a href="#DataFrame.withColumn-745"><span class="linenos">745</span></a> <span class="n">existing_col_index</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="DataFrame.withColumn-746"><a href="#DataFrame.withColumn-746"><span class="linenos">746</span></a> <span class="n">existing_col_names</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">colName</span><span class="p">)</span> <span class="k">if</span> <span class="n">colName</span> <span class="ow">in</span> <span class="n">existing_col_names</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="DataFrame.withColumn-747"><a href="#DataFrame.withColumn-747"><span class="linenos">747</span></a> <span class="p">)</span> +</span><span id="DataFrame.withColumn-748"><a href="#DataFrame.withColumn-748"><span class="linenos">748</span></a> <span class="k">if</span> <span class="n">existing_col_index</span><span class="p">:</span> +</span><span id="DataFrame.withColumn-749"><a href="#DataFrame.withColumn-749"><span class="linenos">749</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame.withColumn-750"><a href="#DataFrame.withColumn-750"><span class="linenos">750</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="n">existing_col_index</span><span class="p">]</span> <span class="o">=</span> <span class="n">col</span><span class="o">.</span><span class="n">expression</span> +</span><span id="DataFrame.withColumn-751"><a href="#DataFrame.withColumn-751"><span class="linenos">751</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DataFrame.withColumn-752"><a href="#DataFrame.withColumn-752"><span class="linenos">752</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="n">col</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span><span class="n">colName</span><span class="p">),</span> <span class="n">append</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></pre></div> @@ -2450,22 +2452,22 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#DataFrame.withColumnRenamed"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.withColumnRenamed-753"><a href="#DataFrame.withColumnRenamed-753"><span class="linenos">753</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> -</span><span id="DataFrame.withColumnRenamed-754"><a href="#DataFrame.withColumnRenamed-754"><span class="linenos">754</span></a> <span class="k">def</span> <span class="nf">withColumnRenamed</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">existing</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">new</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="DataFrame.withColumnRenamed-755"><a href="#DataFrame.withColumnRenamed-755"><span class="linenos">755</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="DataFrame.withColumnRenamed-756"><a href="#DataFrame.withColumnRenamed-756"><span class="linenos">756</span></a> <span class="n">existing_columns</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame.withColumnRenamed-757"><a href="#DataFrame.withColumnRenamed-757"><span class="linenos">757</span></a> <span class="n">expression</span> -</span><span id="DataFrame.withColumnRenamed-758"><a href="#DataFrame.withColumnRenamed-758"><span class="linenos">758</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="DataFrame.withColumnRenamed-759"><a href="#DataFrame.withColumnRenamed-759"><span class="linenos">759</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="o">==</span> <span class="n">existing</span> -</span><span id="DataFrame.withColumnRenamed-760"><a href="#DataFrame.withColumnRenamed-760"><span class="linenos">760</span></a> <span class="p">]</span> -</span><span id="DataFrame.withColumnRenamed-761"><a href="#DataFrame.withColumnRenamed-761"><span class="linenos">761</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">existing_columns</span><span class="p">:</span> -</span><span id="DataFrame.withColumnRenamed-762"><a href="#DataFrame.withColumnRenamed-762"><span class="linenos">762</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Tried to rename a column that doesn't exist"</span><span class="p">)</span> -</span><span id="DataFrame.withColumnRenamed-763"><a href="#DataFrame.withColumnRenamed-763"><span class="linenos">763</span></a> <span class="k">for</span> <span class="n">existing_column</span> <span class="ow">in</span> <span class="n">existing_columns</span><span class="p">:</span> -</span><span id="DataFrame.withColumnRenamed-764"><a href="#DataFrame.withColumnRenamed-764"><span class="linenos">764</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">existing_column</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> -</span><span id="DataFrame.withColumnRenamed-765"><a href="#DataFrame.withColumnRenamed-765"><span class="linenos">765</span></a> <span class="n">existing_column</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">alias_</span><span class="p">(</span><span class="n">existing_column</span><span class="p">,</span> <span class="n">new</span><span class="p">))</span> -</span><span id="DataFrame.withColumnRenamed-766"><a href="#DataFrame.withColumnRenamed-766"><span class="linenos">766</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataFrame.withColumnRenamed-767"><a href="#DataFrame.withColumnRenamed-767"><span class="linenos">767</span></a> <span class="n">existing_column</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">new</span><span class="p">))</span> -</span><span id="DataFrame.withColumnRenamed-768"><a href="#DataFrame.withColumnRenamed-768"><span class="linenos">768</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.withColumnRenamed-754"><a href="#DataFrame.withColumnRenamed-754"><span class="linenos">754</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> +</span><span id="DataFrame.withColumnRenamed-755"><a href="#DataFrame.withColumnRenamed-755"><span class="linenos">755</span></a> <span class="k">def</span> <span class="nf">withColumnRenamed</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">existing</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">new</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="DataFrame.withColumnRenamed-756"><a href="#DataFrame.withColumnRenamed-756"><span class="linenos">756</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="DataFrame.withColumnRenamed-757"><a href="#DataFrame.withColumnRenamed-757"><span class="linenos">757</span></a> <span class="n">existing_columns</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame.withColumnRenamed-758"><a href="#DataFrame.withColumnRenamed-758"><span class="linenos">758</span></a> <span class="n">expression</span> +</span><span id="DataFrame.withColumnRenamed-759"><a href="#DataFrame.withColumnRenamed-759"><span class="linenos">759</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="DataFrame.withColumnRenamed-760"><a href="#DataFrame.withColumnRenamed-760"><span class="linenos">760</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="o">==</span> <span class="n">existing</span> +</span><span id="DataFrame.withColumnRenamed-761"><a href="#DataFrame.withColumnRenamed-761"><span class="linenos">761</span></a> <span class="p">]</span> +</span><span id="DataFrame.withColumnRenamed-762"><a href="#DataFrame.withColumnRenamed-762"><span class="linenos">762</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">existing_columns</span><span class="p">:</span> +</span><span id="DataFrame.withColumnRenamed-763"><a href="#DataFrame.withColumnRenamed-763"><span class="linenos">763</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Tried to rename a column that doesn't exist"</span><span class="p">)</span> +</span><span id="DataFrame.withColumnRenamed-764"><a href="#DataFrame.withColumnRenamed-764"><span class="linenos">764</span></a> <span class="k">for</span> <span class="n">existing_column</span> <span class="ow">in</span> <span class="n">existing_columns</span><span class="p">:</span> +</span><span id="DataFrame.withColumnRenamed-765"><a href="#DataFrame.withColumnRenamed-765"><span class="linenos">765</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">existing_column</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> +</span><span id="DataFrame.withColumnRenamed-766"><a href="#DataFrame.withColumnRenamed-766"><span class="linenos">766</span></a> <span class="n">existing_column</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">alias_</span><span class="p">(</span><span class="n">existing_column</span><span class="p">,</span> <span class="n">new</span><span class="p">))</span> +</span><span id="DataFrame.withColumnRenamed-767"><a href="#DataFrame.withColumnRenamed-767"><span class="linenos">767</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataFrame.withColumnRenamed-768"><a href="#DataFrame.withColumnRenamed-768"><span class="linenos">768</span></a> <span class="n">existing_column</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">new</span><span class="p">))</span> +</span><span id="DataFrame.withColumnRenamed-769"><a href="#DataFrame.withColumnRenamed-769"><span class="linenos">769</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -2484,16 +2486,16 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#DataFrame.drop"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.drop-770"><a href="#DataFrame.drop-770"><span class="linenos">770</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> -</span><span id="DataFrame.drop-771"><a href="#DataFrame.drop-771"><span class="linenos">771</span></a> <span class="k">def</span> <span class="nf">drop</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Column</span><span class="p">])</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.drop-772"><a href="#DataFrame.drop-772"><span class="linenos">772</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="DataFrame.drop-773"><a href="#DataFrame.drop-773"><span class="linenos">773</span></a> <span class="n">drop_cols</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> -</span><span id="DataFrame.drop-774"><a href="#DataFrame.drop-774"><span class="linenos">774</span></a> <span class="n">new_columns</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="DataFrame.drop-775"><a href="#DataFrame.drop-775"><span class="linenos">775</span></a> <span class="n">col</span> -</span><span id="DataFrame.drop-776"><a href="#DataFrame.drop-776"><span class="linenos">776</span></a> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">all_columns</span> -</span><span id="DataFrame.drop-777"><a href="#DataFrame.drop-777"><span class="linenos">777</span></a> <span class="k">if</span> <span class="n">col</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="n">drop_column</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="k">for</span> <span class="n">drop_column</span> <span class="ow">in</span> <span class="n">drop_cols</span><span class="p">]</span> -</span><span id="DataFrame.drop-778"><a href="#DataFrame.drop-778"><span class="linenos">778</span></a> <span class="p">]</span> -</span><span id="DataFrame.drop-779"><a href="#DataFrame.drop-779"><span class="linenos">779</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">new_columns</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.drop-771"><a href="#DataFrame.drop-771"><span class="linenos">771</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">SELECT</span><span class="p">)</span> +</span><span id="DataFrame.drop-772"><a href="#DataFrame.drop-772"><span class="linenos">772</span></a> <span class="k">def</span> <span class="nf">drop</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Column</span><span class="p">])</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.drop-773"><a href="#DataFrame.drop-773"><span class="linenos">773</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_outer_select_columns</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="DataFrame.drop-774"><a href="#DataFrame.drop-774"><span class="linenos">774</span></a> <span class="n">drop_cols</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> +</span><span id="DataFrame.drop-775"><a href="#DataFrame.drop-775"><span class="linenos">775</span></a> <span class="n">new_columns</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="DataFrame.drop-776"><a href="#DataFrame.drop-776"><span class="linenos">776</span></a> <span class="n">col</span> +</span><span id="DataFrame.drop-777"><a href="#DataFrame.drop-777"><span class="linenos">777</span></a> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">all_columns</span> +</span><span id="DataFrame.drop-778"><a href="#DataFrame.drop-778"><span class="linenos">778</span></a> <span class="k">if</span> <span class="n">col</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="n">drop_column</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="k">for</span> <span class="n">drop_column</span> <span class="ow">in</span> <span class="n">drop_cols</span><span class="p">]</span> +</span><span id="DataFrame.drop-779"><a href="#DataFrame.drop-779"><span class="linenos">779</span></a> <span class="p">]</span> +</span><span id="DataFrame.drop-780"><a href="#DataFrame.drop-780"><span class="linenos">780</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">new_columns</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> </span></pre></div> @@ -2512,9 +2514,9 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#DataFrame.limit"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.limit-781"><a href="#DataFrame.limit-781"><span class="linenos">781</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">LIMIT</span><span class="p">)</span> -</span><span id="DataFrame.limit-782"><a href="#DataFrame.limit-782"><span class="linenos">782</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">num</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.limit-783"><a href="#DataFrame.limit-783"><span class="linenos">783</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">limit</span><span class="p">(</span><span class="n">num</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.limit-782"><a href="#DataFrame.limit-782"><span class="linenos">782</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">LIMIT</span><span class="p">)</span> +</span><span id="DataFrame.limit-783"><a href="#DataFrame.limit-783"><span class="linenos">783</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">num</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.limit-784"><a href="#DataFrame.limit-784"><span class="linenos">784</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">limit</span><span class="p">(</span><span class="n">num</span><span class="p">))</span> </span></pre></div> @@ -2533,15 +2535,15 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#DataFrame.hint"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.hint-785"><a href="#DataFrame.hint-785"><span class="linenos">785</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> -</span><span id="DataFrame.hint-786"><a href="#DataFrame.hint-786"><span class="linenos">786</span></a> <span class="k">def</span> <span class="nf">hint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">*</span><span class="n">parameters</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">int</span><span class="p">]])</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.hint-787"><a href="#DataFrame.hint-787"><span class="linenos">787</span></a> <span class="n">parameter_list</span> <span class="o">=</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">parameters</span><span class="p">)</span> -</span><span id="DataFrame.hint-788"><a href="#DataFrame.hint-788"><span class="linenos">788</span></a> <span class="n">parameter_columns</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="DataFrame.hint-789"><a href="#DataFrame.hint-789"><span class="linenos">789</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">parameter_list</span><span class="p">)</span> -</span><span id="DataFrame.hint-790"><a href="#DataFrame.hint-790"><span class="linenos">790</span></a> <span class="k">if</span> <span class="n">parameters</span> -</span><span id="DataFrame.hint-791"><a href="#DataFrame.hint-791"><span class="linenos">791</span></a> <span class="k">else</span> <span class="n">Column</span><span class="o">.</span><span class="n">ensure_cols</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">sequence_id</span><span class="p">])</span> -</span><span id="DataFrame.hint-792"><a href="#DataFrame.hint-792"><span class="linenos">792</span></a> <span class="p">)</span> -</span><span id="DataFrame.hint-793"><a href="#DataFrame.hint-793"><span class="linenos">793</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hint</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">parameter_columns</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.hint-786"><a href="#DataFrame.hint-786"><span class="linenos">786</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> +</span><span id="DataFrame.hint-787"><a href="#DataFrame.hint-787"><span class="linenos">787</span></a> <span class="k">def</span> <span class="nf">hint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">*</span><span class="n">parameters</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">int</span><span class="p">]])</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.hint-788"><a href="#DataFrame.hint-788"><span class="linenos">788</span></a> <span class="n">parameter_list</span> <span class="o">=</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">parameters</span><span class="p">)</span> +</span><span id="DataFrame.hint-789"><a href="#DataFrame.hint-789"><span class="linenos">789</span></a> <span class="n">parameter_columns</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="DataFrame.hint-790"><a href="#DataFrame.hint-790"><span class="linenos">790</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">parameter_list</span><span class="p">)</span> +</span><span id="DataFrame.hint-791"><a href="#DataFrame.hint-791"><span class="linenos">791</span></a> <span class="k">if</span> <span class="n">parameters</span> +</span><span id="DataFrame.hint-792"><a href="#DataFrame.hint-792"><span class="linenos">792</span></a> <span class="k">else</span> <span class="n">Column</span><span class="o">.</span><span class="n">ensure_cols</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">sequence_id</span><span class="p">])</span> +</span><span id="DataFrame.hint-793"><a href="#DataFrame.hint-793"><span class="linenos">793</span></a> <span class="p">)</span> +</span><span id="DataFrame.hint-794"><a href="#DataFrame.hint-794"><span class="linenos">794</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hint</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">parameter_columns</span><span class="p">)</span> </span></pre></div> @@ -2554,20 +2556,20 @@ and check if it matches the type of the value provided. If not then make it null <div class="decorator">@operation(Operation.NO_OP)</div> <span class="def">def</span> - <span class="name">repartition</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="n">numPartitions</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043310895632'</span><span class="o">></span><span class="p">]</span>,</span><span class="param"> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043310935312'</span><span class="o">></span></span><span class="return-annotation">) -> <span class="n"><a href="#DataFrame">sqlglot.dataframe.sql.DataFrame</a></span>:</span></span> + <span class="name">repartition</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="n">numPartitions</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135090130800'</span><span class="o">></span><span class="p">]</span>,</span><span class="param"> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135090191136'</span><span class="o">></span></span><span class="return-annotation">) -> <span class="n"><a href="#DataFrame">sqlglot.dataframe.sql.DataFrame</a></span>:</span></span> <label class="view-source-button" for="DataFrame.repartition-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#DataFrame.repartition"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.repartition-795"><a href="#DataFrame.repartition-795"><span class="linenos">795</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> -</span><span id="DataFrame.repartition-796"><a href="#DataFrame.repartition-796"><span class="linenos">796</span></a> <span class="k">def</span> <span class="nf">repartition</span><span class="p">(</span> -</span><span id="DataFrame.repartition-797"><a href="#DataFrame.repartition-797"><span class="linenos">797</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">numPartitions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="n">ColumnOrName</span><span class="p">],</span> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">ColumnOrName</span> -</span><span id="DataFrame.repartition-798"><a href="#DataFrame.repartition-798"><span class="linenos">798</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.repartition-799"><a href="#DataFrame.repartition-799"><span class="linenos">799</span></a> <span class="n">num_partition_cols</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">numPartitions</span><span class="p">)</span> -</span><span id="DataFrame.repartition-800"><a href="#DataFrame.repartition-800"><span class="linenos">800</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> -</span><span id="DataFrame.repartition-801"><a href="#DataFrame.repartition-801"><span class="linenos">801</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">num_partition_cols</span> <span class="o">+</span> <span class="n">columns</span> -</span><span id="DataFrame.repartition-802"><a href="#DataFrame.repartition-802"><span class="linenos">802</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hint</span><span class="p">(</span><span class="s2">"repartition"</span><span class="p">,</span> <span class="n">args</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.repartition-796"><a href="#DataFrame.repartition-796"><span class="linenos">796</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> +</span><span id="DataFrame.repartition-797"><a href="#DataFrame.repartition-797"><span class="linenos">797</span></a> <span class="k">def</span> <span class="nf">repartition</span><span class="p">(</span> +</span><span id="DataFrame.repartition-798"><a href="#DataFrame.repartition-798"><span class="linenos">798</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">numPartitions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="n">ColumnOrName</span><span class="p">],</span> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">ColumnOrName</span> +</span><span id="DataFrame.repartition-799"><a href="#DataFrame.repartition-799"><span class="linenos">799</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.repartition-800"><a href="#DataFrame.repartition-800"><span class="linenos">800</span></a> <span class="n">num_partition_cols</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_list_of_columns</span><span class="p">(</span><span class="n">numPartitions</span><span class="p">)</span> +</span><span id="DataFrame.repartition-801"><a href="#DataFrame.repartition-801"><span class="linenos">801</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ensure_and_normalize_cols</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> +</span><span id="DataFrame.repartition-802"><a href="#DataFrame.repartition-802"><span class="linenos">802</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">num_partition_cols</span> <span class="o">+</span> <span class="n">columns</span> +</span><span id="DataFrame.repartition-803"><a href="#DataFrame.repartition-803"><span class="linenos">803</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hint</span><span class="p">(</span><span class="s2">"repartition"</span><span class="p">,</span> <span class="n">args</span><span class="p">)</span> </span></pre></div> @@ -2586,10 +2588,10 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#DataFrame.coalesce"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.coalesce-804"><a href="#DataFrame.coalesce-804"><span class="linenos">804</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> -</span><span id="DataFrame.coalesce-805"><a href="#DataFrame.coalesce-805"><span class="linenos">805</span></a> <span class="k">def</span> <span class="nf">coalesce</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">numPartitions</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.coalesce-806"><a href="#DataFrame.coalesce-806"><span class="linenos">806</span></a> <span class="n">num_partitions</span> <span class="o">=</span> <span class="n">Column</span><span class="o">.</span><span class="n">ensure_cols</span><span class="p">([</span><span class="n">numPartitions</span><span class="p">])</span> -</span><span id="DataFrame.coalesce-807"><a href="#DataFrame.coalesce-807"><span class="linenos">807</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hint</span><span class="p">(</span><span class="s2">"coalesce"</span><span class="p">,</span> <span class="n">num_partitions</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.coalesce-805"><a href="#DataFrame.coalesce-805"><span class="linenos">805</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> +</span><span id="DataFrame.coalesce-806"><a href="#DataFrame.coalesce-806"><span class="linenos">806</span></a> <span class="k">def</span> <span class="nf">coalesce</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">numPartitions</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.coalesce-807"><a href="#DataFrame.coalesce-807"><span class="linenos">807</span></a> <span class="n">num_partitions</span> <span class="o">=</span> <span class="n">Column</span><span class="o">.</span><span class="n">ensure_cols</span><span class="p">([</span><span class="n">numPartitions</span><span class="p">])</span> +</span><span id="DataFrame.coalesce-808"><a href="#DataFrame.coalesce-808"><span class="linenos">808</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hint</span><span class="p">(</span><span class="s2">"coalesce"</span><span class="p">,</span> <span class="n">num_partitions</span><span class="p">)</span> </span></pre></div> @@ -2608,9 +2610,9 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#DataFrame.cache"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.cache-809"><a href="#DataFrame.cache-809"><span class="linenos">809</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> -</span><span id="DataFrame.cache-810"><a href="#DataFrame.cache-810"><span class="linenos">810</span></a> <span class="k">def</span> <span class="nf">cache</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.cache-811"><a href="#DataFrame.cache-811"><span class="linenos">811</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">(</span><span class="n">storage_level</span><span class="o">=</span><span class="s2">"MEMORY_AND_DISK"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.cache-810"><a href="#DataFrame.cache-810"><span class="linenos">810</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> +</span><span id="DataFrame.cache-811"><a href="#DataFrame.cache-811"><span class="linenos">811</span></a> <span class="k">def</span> <span class="nf">cache</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.cache-812"><a href="#DataFrame.cache-812"><span class="linenos">812</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">(</span><span class="n">storage_level</span><span class="o">=</span><span class="s2">"MEMORY_AND_DISK"</span><span class="p">)</span> </span></pre></div> @@ -2629,12 +2631,12 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#DataFrame.persist"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.persist-813"><a href="#DataFrame.persist-813"><span class="linenos">813</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> -</span><span id="DataFrame.persist-814"><a href="#DataFrame.persist-814"><span class="linenos">814</span></a> <span class="k">def</span> <span class="nf">persist</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">storageLevel</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"MEMORY_AND_DISK_SER"</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrame.persist-815"><a href="#DataFrame.persist-815"><span class="linenos">815</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="DataFrame.persist-816"><a href="#DataFrame.persist-816"><span class="linenos">816</span></a><span class="sd"> Storage Level Options: https://spark.apache.org/docs/3.0.0-preview/sql-ref-syntax-aux-cache-cache-table.html</span> -</span><span id="DataFrame.persist-817"><a href="#DataFrame.persist-817"><span class="linenos">817</span></a><span class="sd"> """</span> -</span><span id="DataFrame.persist-818"><a href="#DataFrame.persist-818"><span class="linenos">818</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">(</span><span class="n">storageLevel</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrame.persist-814"><a href="#DataFrame.persist-814"><span class="linenos">814</span></a> <span class="nd">@operation</span><span class="p">(</span><span class="n">Operation</span><span class="o">.</span><span class="n">NO_OP</span><span class="p">)</span> +</span><span id="DataFrame.persist-815"><a href="#DataFrame.persist-815"><span class="linenos">815</span></a> <span class="k">def</span> <span class="nf">persist</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">storageLevel</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"MEMORY_AND_DISK_SER"</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrame.persist-816"><a href="#DataFrame.persist-816"><span class="linenos">816</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="DataFrame.persist-817"><a href="#DataFrame.persist-817"><span class="linenos">817</span></a><span class="sd"> Storage Level Options: https://spark.apache.org/docs/3.0.0-preview/sql-ref-syntax-aux-cache-cache-table.html</span> +</span><span id="DataFrame.persist-818"><a href="#DataFrame.persist-818"><span class="linenos">818</span></a><span class="sd"> """</span> +</span><span id="DataFrame.persist-819"><a href="#DataFrame.persist-819"><span class="linenos">819</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">(</span><span class="n">storageLevel</span><span class="p">)</span> </span></pre></div> @@ -2904,315 +2906,319 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#Column"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column-16"><a href="#Column-16"><span class="linenos"> 16</span></a><span class="k">class</span> <span class="nc">Column</span><span class="p">:</span> -</span><span id="Column-17"><a href="#Column-17"><span class="linenos"> 17</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</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="Column-18"><a href="#Column-18"><span class="linenos"> 18</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Column</span><span class="p">):</span> -</span><span id="Column-19"><a href="#Column-19"><span class="linenos"> 19</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> <span class="c1"># type: ignore</span> -</span><span id="Column-20"><a href="#Column-20"><span class="linenos"> 20</span></a> <span class="k">elif</span> <span class="n">expression</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="p">(</span><span class="nb">str</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="Column-21"><a href="#Column-21"><span class="linenos"> 21</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> <span class="c1"># type: ignore</span> -</span><span id="Column-22"><a href="#Column-22"><span class="linenos"> 22</span></a> -</span><span id="Column-23"><a href="#Column-23"><span class="linenos"> 23</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"spark"</span><span class="p">)</span> -</span><span id="Column-24"><a href="#Column-24"><span class="linenos"> 24</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Column-25"><a href="#Column-25"><span class="linenos"> 25</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Could not parse </span><span class="si">{</span><span class="n">expression</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Column-26"><a href="#Column-26"><span class="linenos"> 26</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">Expression</span> <span class="o">=</span> <span class="n">expression</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column-17"><a href="#Column-17"><span class="linenos"> 17</span></a><span class="k">class</span> <span class="nc">Column</span><span class="p">:</span> +</span><span id="Column-18"><a href="#Column-18"><span class="linenos"> 18</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</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="Column-19"><a href="#Column-19"><span class="linenos"> 19</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Column</span><span class="p">):</span> +</span><span id="Column-20"><a href="#Column-20"><span class="linenos"> 20</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> <span class="c1"># type: ignore</span> +</span><span id="Column-21"><a href="#Column-21"><span class="linenos"> 21</span></a> <span class="k">elif</span> <span class="n">expression</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="p">(</span><span class="nb">str</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="Column-22"><a href="#Column-22"><span class="linenos"> 22</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> <span class="c1"># type: ignore</span> +</span><span id="Column-23"><a href="#Column-23"><span class="linenos"> 23</span></a> +</span><span id="Column-24"><a href="#Column-24"><span class="linenos"> 24</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"spark"</span><span class="p">)</span> +</span><span id="Column-25"><a href="#Column-25"><span class="linenos"> 25</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Column-26"><a href="#Column-26"><span class="linenos"> 26</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Could not parse </span><span class="si">{</span><span class="n">expression</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> </span><span id="Column-27"><a href="#Column-27"><span class="linenos"> 27</span></a> -</span><span id="Column-28"><a href="#Column-28"><span class="linenos"> 28</span></a> <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Column-29"><a href="#Column-29"><span class="linenos"> 29</span></a> <span class="k">return</span> <span class="nb">repr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Column-28"><a href="#Column-28"><span class="linenos"> 28</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> +</span><span id="Column-29"><a href="#Column-29"><span class="linenos"> 29</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">Spark</span><span class="o">.</span><span class="n">normalize_identifier</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> </span><span id="Column-30"><a href="#Column-30"><span class="linenos"> 30</span></a> -</span><span id="Column-31"><a href="#Column-31"><span class="linenos"> 31</span></a> <span class="k">def</span> <span class="fm">__hash__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Column-32"><a href="#Column-32"><span class="linenos"> 32</span></a> <span class="k">return</span> <span class="nb">hash</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Column-33"><a href="#Column-33"><span class="linenos"> 33</span></a> -</span><span id="Column-34"><a href="#Column-34"><span class="linenos"> 34</span></a> <span class="k">def</span> <span class="fm">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> <span class="c1"># type: ignore</span> -</span><span id="Column-35"><a href="#Column-35"><span class="linenos"> 35</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> -</span><span id="Column-36"><a href="#Column-36"><span class="linenos"> 36</span></a> -</span><span id="Column-37"><a href="#Column-37"><span class="linenos"> 37</span></a> <span class="k">def</span> <span class="fm">__ne__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> <span class="c1"># type: ignore</span> -</span><span id="Column-38"><a href="#Column-38"><span class="linenos"> 38</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> -</span><span id="Column-39"><a href="#Column-39"><span class="linenos"> 39</span></a> -</span><span id="Column-40"><a href="#Column-40"><span class="linenos"> 40</span></a> <span class="k">def</span> <span class="fm">__gt__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-41"><a href="#Column-41"><span class="linenos"> 41</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">GT</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> -</span><span id="Column-42"><a href="#Column-42"><span class="linenos"> 42</span></a> -</span><span id="Column-43"><a href="#Column-43"><span class="linenos"> 43</span></a> <span class="k">def</span> <span class="fm">__ge__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-44"><a href="#Column-44"><span class="linenos"> 44</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">GTE</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> -</span><span id="Column-45"><a href="#Column-45"><span class="linenos"> 45</span></a> -</span><span id="Column-46"><a href="#Column-46"><span class="linenos"> 46</span></a> <span class="k">def</span> <span class="fm">__lt__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-47"><a href="#Column-47"><span class="linenos"> 47</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LT</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> -</span><span id="Column-48"><a href="#Column-48"><span class="linenos"> 48</span></a> -</span><span id="Column-49"><a href="#Column-49"><span class="linenos"> 49</span></a> <span class="k">def</span> <span class="fm">__le__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-50"><a href="#Column-50"><span class="linenos"> 50</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LTE</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> -</span><span id="Column-51"><a href="#Column-51"><span class="linenos"> 51</span></a> -</span><span id="Column-52"><a href="#Column-52"><span class="linenos"> 52</span></a> <span class="k">def</span> <span class="fm">__and__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-53"><a href="#Column-53"><span class="linenos"> 53</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">And</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> -</span><span id="Column-54"><a href="#Column-54"><span class="linenos"> 54</span></a> -</span><span id="Column-55"><a href="#Column-55"><span class="linenos"> 55</span></a> <span class="k">def</span> <span class="fm">__or__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-56"><a href="#Column-56"><span class="linenos"> 56</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Or</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> -</span><span id="Column-57"><a href="#Column-57"><span class="linenos"> 57</span></a> -</span><span id="Column-58"><a href="#Column-58"><span class="linenos"> 58</span></a> <span class="k">def</span> <span class="fm">__mod__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-59"><a href="#Column-59"><span class="linenos"> 59</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> -</span><span id="Column-60"><a href="#Column-60"><span class="linenos"> 60</span></a> -</span><span id="Column-61"><a href="#Column-61"><span class="linenos"> 61</span></a> <span class="k">def</span> <span class="fm">__add__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-62"><a href="#Column-62"><span class="linenos"> 62</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Add</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> -</span><span id="Column-63"><a href="#Column-63"><span class="linenos"> 63</span></a> -</span><span id="Column-64"><a href="#Column-64"><span class="linenos"> 64</span></a> <span class="k">def</span> <span class="fm">__sub__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-65"><a href="#Column-65"><span class="linenos"> 65</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Sub</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> -</span><span id="Column-66"><a href="#Column-66"><span class="linenos"> 66</span></a> -</span><span id="Column-67"><a href="#Column-67"><span class="linenos"> 67</span></a> <span class="k">def</span> <span class="fm">__mul__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-68"><a href="#Column-68"><span class="linenos"> 68</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Mul</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> -</span><span id="Column-69"><a href="#Column-69"><span class="linenos"> 69</span></a> -</span><span id="Column-70"><a href="#Column-70"><span class="linenos"> 70</span></a> <span class="k">def</span> <span class="fm">__truediv__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-71"><a href="#Column-71"><span class="linenos"> 71</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</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">other</span><span class="p">)</span> -</span><span id="Column-72"><a href="#Column-72"><span class="linenos"> 72</span></a> -</span><span id="Column-73"><a href="#Column-73"><span class="linenos"> 73</span></a> <span class="k">def</span> <span class="nf">__div__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-74"><a href="#Column-74"><span class="linenos"> 74</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</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">other</span><span class="p">)</span> -</span><span id="Column-75"><a href="#Column-75"><span class="linenos"> 75</span></a> -</span><span id="Column-76"><a href="#Column-76"><span class="linenos"> 76</span></a> <span class="k">def</span> <span class="fm">__neg__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-77"><a href="#Column-77"><span class="linenos"> 77</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">unary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Neg</span><span class="p">)</span> -</span><span id="Column-78"><a href="#Column-78"><span class="linenos"> 78</span></a> -</span><span id="Column-79"><a href="#Column-79"><span class="linenos"> 79</span></a> <span class="k">def</span> <span class="fm">__radd__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-80"><a href="#Column-80"><span class="linenos"> 80</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">inverse_binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Add</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> -</span><span id="Column-81"><a href="#Column-81"><span class="linenos"> 81</span></a> -</span><span id="Column-82"><a href="#Column-82"><span class="linenos"> 82</span></a> <span class="k">def</span> <span class="fm">__rsub__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-83"><a href="#Column-83"><span class="linenos"> 83</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">inverse_binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Sub</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> -</span><span id="Column-84"><a href="#Column-84"><span class="linenos"> 84</span></a> -</span><span id="Column-85"><a href="#Column-85"><span class="linenos"> 85</span></a> <span class="k">def</span> <span class="fm">__rmul__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-86"><a href="#Column-86"><span class="linenos"> 86</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">inverse_binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Mul</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> -</span><span id="Column-87"><a href="#Column-87"><span class="linenos"> 87</span></a> -</span><span id="Column-88"><a href="#Column-88"><span class="linenos"> 88</span></a> <span class="k">def</span> <span class="nf">__rdiv__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-89"><a href="#Column-89"><span class="linenos"> 89</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">inverse_binary_op</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">other</span><span class="p">)</span> -</span><span id="Column-90"><a href="#Column-90"><span class="linenos"> 90</span></a> -</span><span id="Column-91"><a href="#Column-91"><span class="linenos"> 91</span></a> <span class="k">def</span> <span class="fm">__rtruediv__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-92"><a href="#Column-92"><span class="linenos"> 92</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">inverse_binary_op</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">other</span><span class="p">)</span> -</span><span id="Column-93"><a href="#Column-93"><span class="linenos"> 93</span></a> -</span><span id="Column-94"><a href="#Column-94"><span class="linenos"> 94</span></a> <span class="k">def</span> <span class="fm">__rmod__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-95"><a href="#Column-95"><span class="linenos"> 95</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">inverse_binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> -</span><span id="Column-96"><a href="#Column-96"><span class="linenos"> 96</span></a> -</span><span id="Column-97"><a href="#Column-97"><span class="linenos"> 97</span></a> <span class="k">def</span> <span class="fm">__pow__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">power</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">,</span> <span class="n">modulo</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> -</span><span id="Column-98"><a href="#Column-98"><span class="linenos"> 98</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</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">expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">power</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span><span class="p">))</span> -</span><span id="Column-99"><a href="#Column-99"><span class="linenos"> 99</span></a> -</span><span id="Column-100"><a href="#Column-100"><span class="linenos">100</span></a> <span class="k">def</span> <span class="fm">__rpow__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">power</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">):</span> -</span><span id="Column-101"><a href="#Column-101"><span class="linenos">101</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">power</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">))</span> -</span><span id="Column-102"><a href="#Column-102"><span class="linenos">102</span></a> -</span><span id="Column-103"><a href="#Column-103"><span class="linenos">103</span></a> <span class="k">def</span> <span class="fm">__invert__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Column-104"><a href="#Column-104"><span class="linenos">104</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">unary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Not</span><span class="p">)</span> -</span><span id="Column-105"><a href="#Column-105"><span class="linenos">105</span></a> -</span><span id="Column-106"><a href="#Column-106"><span class="linenos">106</span></a> <span class="k">def</span> <span class="fm">__rand__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-107"><a href="#Column-107"><span class="linenos">107</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">inverse_binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">And</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> -</span><span id="Column-108"><a href="#Column-108"><span class="linenos">108</span></a> -</span><span id="Column-109"><a href="#Column-109"><span class="linenos">109</span></a> <span class="k">def</span> <span class="fm">__ror__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-110"><a href="#Column-110"><span class="linenos">110</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">inverse_binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Or</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> -</span><span id="Column-111"><a href="#Column-111"><span class="linenos">111</span></a> -</span><span id="Column-112"><a href="#Column-112"><span class="linenos">112</span></a> <span class="nd">@classmethod</span> -</span><span id="Column-113"><a href="#Column-113"><span class="linenos">113</span></a> <span class="k">def</span> <span class="nf">ensure_col</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</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="Column-114"><a href="#Column-114"><span class="linenos">114</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="Column-115"><a href="#Column-115"><span class="linenos">115</span></a> -</span><span id="Column-116"><a href="#Column-116"><span class="linenos">116</span></a> <span class="nd">@classmethod</span> -</span><span id="Column-117"><a href="#Column-117"><span class="linenos">117</span></a> <span class="k">def</span> <span class="nf">ensure_cols</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Column</span><span class="p">]:</span> -</span><span id="Column-118"><a href="#Column-118"><span class="linenos">118</span></a> <span class="k">return</span> <span class="p">[</span><span class="bp">cls</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">x</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">args</span><span class="p">]</span> -</span><span id="Column-119"><a href="#Column-119"><span class="linenos">119</span></a> -</span><span id="Column-120"><a href="#Column-120"><span class="linenos">120</span></a> <span class="nd">@classmethod</span> -</span><span id="Column-121"><a href="#Column-121"><span class="linenos">121</span></a> <span class="k">def</span> <span class="nf">_lit</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-122"><a href="#Column-122"><span class="linenos">122</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span> -</span><span id="Column-123"><a href="#Column-123"><span class="linenos">123</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="p">[</span><span class="bp">cls</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span><span class="n">k</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">value</span><span class="o">.</span><span class="n">items</span><span class="p">()]</span> -</span><span id="Column-124"><a href="#Column-124"><span class="linenos">124</span></a> <span class="k">return</span> <span class="bp">cls</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="n">expressions</span><span class="o">=</span><span class="n">columns</span><span class="p">))</span> -</span><span id="Column-125"><a href="#Column-125"><span class="linenos">125</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">convert</span><span class="p">(</span><span class="n">value</span><span class="p">))</span> -</span><span id="Column-126"><a href="#Column-126"><span class="linenos">126</span></a> -</span><span id="Column-127"><a href="#Column-127"><span class="linenos">127</span></a> <span class="nd">@classmethod</span> -</span><span id="Column-128"><a href="#Column-128"><span class="linenos">128</span></a> <span class="k">def</span> <span class="nf">invoke_anonymous_function</span><span class="p">(</span> -</span><span id="Column-129"><a href="#Column-129"><span class="linenos">129</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">column</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">ColumnOrLiteral</span><span class="p">],</span> <span class="n">func_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">]</span> -</span><span id="Column-130"><a href="#Column-130"><span class="linenos">130</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-131"><a href="#Column-131"><span class="linenos">131</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="p">[]</span> <span class="k">if</span> <span class="n">column</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="p">[</span><span class="bp">cls</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">column</span><span class="p">)]</span> -</span><span id="Column-132"><a href="#Column-132"><span class="linenos">132</span></a> <span class="n">column_args</span> <span class="o">=</span> <span class="p">[</span><span class="bp">cls</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">]</span> -</span><span id="Column-133"><a href="#Column-133"><span class="linenos">133</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">expression</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">columns</span> <span class="o">+</span> <span class="n">column_args</span><span class="p">]</span> -</span><span id="Column-134"><a href="#Column-134"><span class="linenos">134</span></a> <span class="n">new_expression</span> <span class="o">=</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="n">func_name</span><span class="o">.</span><span class="n">upper</span><span class="p">(),</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Column-135"><a href="#Column-135"><span class="linenos">135</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> -</span><span id="Column-136"><a href="#Column-136"><span class="linenos">136</span></a> -</span><span id="Column-137"><a href="#Column-137"><span class="linenos">137</span></a> <span class="nd">@classmethod</span> -</span><span id="Column-138"><a href="#Column-138"><span class="linenos">138</span></a> <span class="k">def</span> <span class="nf">invoke_expression_over_column</span><span class="p">(</span> -</span><span id="Column-139"><a href="#Column-139"><span class="linenos">139</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">column</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">ColumnOrLiteral</span><span class="p">],</span> <span class="n">callable_expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> -</span><span id="Column-140"><a href="#Column-140"><span class="linenos">140</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-141"><a href="#Column-141"><span class="linenos">141</span></a> <span class="n">ensured_column</span> <span class="o">=</span> <span class="kc">None</span> <span class="k">if</span> <span class="n">column</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="bp">cls</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">column</span><span class="p">)</span> -</span><span id="Column-142"><a href="#Column-142"><span class="linenos">142</span></a> <span class="n">ensure_expression_values</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Column-143"><a href="#Column-143"><span class="linenos">143</span></a> <span class="n">k</span><span class="p">:</span> <span class="p">[</span><span class="n">Column</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">v</span><span class="p">]</span> -</span><span id="Column-144"><a href="#Column-144"><span class="linenos">144</span></a> <span class="k">if</span> <span class="n">is_iterable</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> -</span><span id="Column-145"><a href="#Column-145"><span class="linenos">145</span></a> <span class="k">else</span> <span class="n">Column</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> -</span><span id="Column-146"><a href="#Column-146"><span class="linenos">146</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> -</span><span id="Column-147"><a href="#Column-147"><span class="linenos">147</span></a> <span class="k">if</span> <span class="n">v</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> -</span><span id="Column-148"><a href="#Column-148"><span class="linenos">148</span></a> <span class="p">}</span> -</span><span id="Column-149"><a href="#Column-149"><span class="linenos">149</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Column-150"><a href="#Column-150"><span class="linenos">150</span></a> <span class="n">callable_expression</span><span class="p">(</span><span class="o">**</span><span class="n">ensure_expression_values</span><span class="p">)</span> -</span><span id="Column-151"><a href="#Column-151"><span class="linenos">151</span></a> <span class="k">if</span> <span class="n">ensured_column</span> <span class="ow">is</span> <span class="kc">None</span> -</span><span id="Column-152"><a href="#Column-152"><span class="linenos">152</span></a> <span class="k">else</span> <span class="n">callable_expression</span><span class="p">(</span> -</span><span id="Column-153"><a href="#Column-153"><span class="linenos">153</span></a> <span class="n">this</span><span class="o">=</span><span class="n">ensured_column</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="o">**</span><span class="n">ensure_expression_values</span> -</span><span id="Column-154"><a href="#Column-154"><span class="linenos">154</span></a> <span class="p">)</span> -</span><span id="Column-155"><a href="#Column-155"><span class="linenos">155</span></a> <span class="p">)</span> -</span><span id="Column-156"><a href="#Column-156"><span class="linenos">156</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> -</span><span id="Column-157"><a href="#Column-157"><span class="linenos">157</span></a> -</span><span id="Column-158"><a href="#Column-158"><span class="linenos">158</span></a> <span class="k">def</span> <span class="nf">binary_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">klass</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-159"><a href="#Column-159"><span class="linenos">159</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span> -</span><span id="Column-160"><a href="#Column-160"><span class="linenos">160</span></a> <span class="n">klass</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">column_expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">other</span><span class="p">)</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="Column-161"><a href="#Column-161"><span class="linenos">161</span></a> <span class="p">)</span> +</span><span id="Column-31"><a href="#Column-31"><span class="linenos"> 31</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">Expression</span> <span class="o">=</span> <span class="n">expression</span> +</span><span id="Column-32"><a href="#Column-32"><span class="linenos"> 32</span></a> +</span><span id="Column-33"><a href="#Column-33"><span class="linenos"> 33</span></a> <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Column-34"><a href="#Column-34"><span class="linenos"> 34</span></a> <span class="k">return</span> <span class="nb">repr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Column-35"><a href="#Column-35"><span class="linenos"> 35</span></a> +</span><span id="Column-36"><a href="#Column-36"><span class="linenos"> 36</span></a> <span class="k">def</span> <span class="fm">__hash__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Column-37"><a href="#Column-37"><span class="linenos"> 37</span></a> <span class="k">return</span> <span class="nb">hash</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Column-38"><a href="#Column-38"><span class="linenos"> 38</span></a> +</span><span id="Column-39"><a href="#Column-39"><span class="linenos"> 39</span></a> <span class="k">def</span> <span class="fm">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> <span class="c1"># type: ignore</span> +</span><span id="Column-40"><a href="#Column-40"><span class="linenos"> 40</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> +</span><span id="Column-41"><a href="#Column-41"><span class="linenos"> 41</span></a> +</span><span id="Column-42"><a href="#Column-42"><span class="linenos"> 42</span></a> <span class="k">def</span> <span class="fm">__ne__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> <span class="c1"># type: ignore</span> +</span><span id="Column-43"><a href="#Column-43"><span class="linenos"> 43</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> +</span><span id="Column-44"><a href="#Column-44"><span class="linenos"> 44</span></a> +</span><span id="Column-45"><a href="#Column-45"><span class="linenos"> 45</span></a> <span class="k">def</span> <span class="fm">__gt__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-46"><a href="#Column-46"><span class="linenos"> 46</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">GT</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> +</span><span id="Column-47"><a href="#Column-47"><span class="linenos"> 47</span></a> +</span><span id="Column-48"><a href="#Column-48"><span class="linenos"> 48</span></a> <span class="k">def</span> <span class="fm">__ge__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-49"><a href="#Column-49"><span class="linenos"> 49</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">GTE</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> +</span><span id="Column-50"><a href="#Column-50"><span class="linenos"> 50</span></a> +</span><span id="Column-51"><a href="#Column-51"><span class="linenos"> 51</span></a> <span class="k">def</span> <span class="fm">__lt__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-52"><a href="#Column-52"><span class="linenos"> 52</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LT</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> +</span><span id="Column-53"><a href="#Column-53"><span class="linenos"> 53</span></a> +</span><span id="Column-54"><a href="#Column-54"><span class="linenos"> 54</span></a> <span class="k">def</span> <span class="fm">__le__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-55"><a href="#Column-55"><span class="linenos"> 55</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LTE</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> +</span><span id="Column-56"><a href="#Column-56"><span class="linenos"> 56</span></a> +</span><span id="Column-57"><a href="#Column-57"><span class="linenos"> 57</span></a> <span class="k">def</span> <span class="fm">__and__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-58"><a href="#Column-58"><span class="linenos"> 58</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">And</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> +</span><span id="Column-59"><a href="#Column-59"><span class="linenos"> 59</span></a> +</span><span id="Column-60"><a href="#Column-60"><span class="linenos"> 60</span></a> <span class="k">def</span> <span class="fm">__or__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-61"><a href="#Column-61"><span class="linenos"> 61</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Or</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> +</span><span id="Column-62"><a href="#Column-62"><span class="linenos"> 62</span></a> +</span><span id="Column-63"><a href="#Column-63"><span class="linenos"> 63</span></a> <span class="k">def</span> <span class="fm">__mod__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-64"><a href="#Column-64"><span class="linenos"> 64</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> +</span><span id="Column-65"><a href="#Column-65"><span class="linenos"> 65</span></a> +</span><span id="Column-66"><a href="#Column-66"><span class="linenos"> 66</span></a> <span class="k">def</span> <span class="fm">__add__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-67"><a href="#Column-67"><span class="linenos"> 67</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Add</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> +</span><span id="Column-68"><a href="#Column-68"><span class="linenos"> 68</span></a> +</span><span id="Column-69"><a href="#Column-69"><span class="linenos"> 69</span></a> <span class="k">def</span> <span class="fm">__sub__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-70"><a href="#Column-70"><span class="linenos"> 70</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Sub</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> +</span><span id="Column-71"><a href="#Column-71"><span class="linenos"> 71</span></a> +</span><span id="Column-72"><a href="#Column-72"><span class="linenos"> 72</span></a> <span class="k">def</span> <span class="fm">__mul__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-73"><a href="#Column-73"><span class="linenos"> 73</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Mul</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> +</span><span id="Column-74"><a href="#Column-74"><span class="linenos"> 74</span></a> +</span><span id="Column-75"><a href="#Column-75"><span class="linenos"> 75</span></a> <span class="k">def</span> <span class="fm">__truediv__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-76"><a href="#Column-76"><span class="linenos"> 76</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</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">other</span><span class="p">)</span> +</span><span id="Column-77"><a href="#Column-77"><span class="linenos"> 77</span></a> +</span><span id="Column-78"><a href="#Column-78"><span class="linenos"> 78</span></a> <span class="k">def</span> <span class="nf">__div__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-79"><a href="#Column-79"><span class="linenos"> 79</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary_op</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">other</span><span class="p">)</span> +</span><span id="Column-80"><a href="#Column-80"><span class="linenos"> 80</span></a> +</span><span id="Column-81"><a href="#Column-81"><span class="linenos"> 81</span></a> <span class="k">def</span> <span class="fm">__neg__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-82"><a href="#Column-82"><span class="linenos"> 82</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">unary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Neg</span><span class="p">)</span> +</span><span id="Column-83"><a href="#Column-83"><span class="linenos"> 83</span></a> +</span><span id="Column-84"><a href="#Column-84"><span class="linenos"> 84</span></a> <span class="k">def</span> <span class="fm">__radd__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-85"><a href="#Column-85"><span class="linenos"> 85</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">inverse_binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Add</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> +</span><span id="Column-86"><a href="#Column-86"><span class="linenos"> 86</span></a> +</span><span id="Column-87"><a href="#Column-87"><span class="linenos"> 87</span></a> <span class="k">def</span> <span class="fm">__rsub__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-88"><a href="#Column-88"><span class="linenos"> 88</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">inverse_binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Sub</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> +</span><span id="Column-89"><a href="#Column-89"><span class="linenos"> 89</span></a> +</span><span id="Column-90"><a href="#Column-90"><span class="linenos"> 90</span></a> <span class="k">def</span> <span class="fm">__rmul__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-91"><a href="#Column-91"><span class="linenos"> 91</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">inverse_binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Mul</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> +</span><span id="Column-92"><a href="#Column-92"><span class="linenos"> 92</span></a> +</span><span id="Column-93"><a href="#Column-93"><span class="linenos"> 93</span></a> <span class="k">def</span> <span class="nf">__rdiv__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-94"><a href="#Column-94"><span class="linenos"> 94</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">inverse_binary_op</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">other</span><span class="p">)</span> +</span><span id="Column-95"><a href="#Column-95"><span class="linenos"> 95</span></a> +</span><span id="Column-96"><a href="#Column-96"><span class="linenos"> 96</span></a> <span class="k">def</span> <span class="fm">__rtruediv__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-97"><a href="#Column-97"><span class="linenos"> 97</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">inverse_binary_op</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">other</span><span class="p">)</span> +</span><span id="Column-98"><a href="#Column-98"><span class="linenos"> 98</span></a> +</span><span id="Column-99"><a href="#Column-99"><span class="linenos"> 99</span></a> <span class="k">def</span> <span class="fm">__rmod__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-100"><a href="#Column-100"><span class="linenos">100</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">inverse_binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> +</span><span id="Column-101"><a href="#Column-101"><span class="linenos">101</span></a> +</span><span id="Column-102"><a href="#Column-102"><span class="linenos">102</span></a> <span class="k">def</span> <span class="fm">__pow__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">power</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">,</span> <span class="n">modulo</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> +</span><span id="Column-103"><a href="#Column-103"><span class="linenos">103</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</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">expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">power</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span><span class="p">))</span> +</span><span id="Column-104"><a href="#Column-104"><span class="linenos">104</span></a> +</span><span id="Column-105"><a href="#Column-105"><span class="linenos">105</span></a> <span class="k">def</span> <span class="fm">__rpow__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">power</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">):</span> +</span><span id="Column-106"><a href="#Column-106"><span class="linenos">106</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">power</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">))</span> +</span><span id="Column-107"><a href="#Column-107"><span class="linenos">107</span></a> +</span><span id="Column-108"><a href="#Column-108"><span class="linenos">108</span></a> <span class="k">def</span> <span class="fm">__invert__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Column-109"><a href="#Column-109"><span class="linenos">109</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">unary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Not</span><span class="p">)</span> +</span><span id="Column-110"><a href="#Column-110"><span class="linenos">110</span></a> +</span><span id="Column-111"><a href="#Column-111"><span class="linenos">111</span></a> <span class="k">def</span> <span class="fm">__rand__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-112"><a href="#Column-112"><span class="linenos">112</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">inverse_binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">And</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> +</span><span id="Column-113"><a href="#Column-113"><span class="linenos">113</span></a> +</span><span id="Column-114"><a href="#Column-114"><span class="linenos">114</span></a> <span class="k">def</span> <span class="fm">__ror__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-115"><a href="#Column-115"><span class="linenos">115</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">inverse_binary_op</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Or</span><span class="p">,</span> <span class="n">other</span><span class="p">)</span> +</span><span id="Column-116"><a href="#Column-116"><span class="linenos">116</span></a> +</span><span id="Column-117"><a href="#Column-117"><span class="linenos">117</span></a> <span class="nd">@classmethod</span> +</span><span id="Column-118"><a href="#Column-118"><span class="linenos">118</span></a> <span class="k">def</span> <span class="nf">ensure_col</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</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="Column-119"><a href="#Column-119"><span class="linenos">119</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="Column-120"><a href="#Column-120"><span class="linenos">120</span></a> +</span><span id="Column-121"><a href="#Column-121"><span class="linenos">121</span></a> <span class="nd">@classmethod</span> +</span><span id="Column-122"><a href="#Column-122"><span class="linenos">122</span></a> <span class="k">def</span> <span class="nf">ensure_cols</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Column</span><span class="p">]:</span> +</span><span id="Column-123"><a href="#Column-123"><span class="linenos">123</span></a> <span class="k">return</span> <span class="p">[</span><span class="bp">cls</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">x</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">args</span><span class="p">]</span> +</span><span id="Column-124"><a href="#Column-124"><span class="linenos">124</span></a> +</span><span id="Column-125"><a href="#Column-125"><span class="linenos">125</span></a> <span class="nd">@classmethod</span> +</span><span id="Column-126"><a href="#Column-126"><span class="linenos">126</span></a> <span class="k">def</span> <span class="nf">_lit</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-127"><a href="#Column-127"><span class="linenos">127</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span> +</span><span id="Column-128"><a href="#Column-128"><span class="linenos">128</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="p">[</span><span class="bp">cls</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span><span class="n">k</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">value</span><span class="o">.</span><span class="n">items</span><span class="p">()]</span> +</span><span id="Column-129"><a href="#Column-129"><span class="linenos">129</span></a> <span class="k">return</span> <span class="bp">cls</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="n">expressions</span><span class="o">=</span><span class="n">columns</span><span class="p">))</span> +</span><span id="Column-130"><a href="#Column-130"><span class="linenos">130</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">convert</span><span class="p">(</span><span class="n">value</span><span class="p">))</span> +</span><span id="Column-131"><a href="#Column-131"><span class="linenos">131</span></a> +</span><span id="Column-132"><a href="#Column-132"><span class="linenos">132</span></a> <span class="nd">@classmethod</span> +</span><span id="Column-133"><a href="#Column-133"><span class="linenos">133</span></a> <span class="k">def</span> <span class="nf">invoke_anonymous_function</span><span class="p">(</span> +</span><span id="Column-134"><a href="#Column-134"><span class="linenos">134</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">column</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">ColumnOrLiteral</span><span class="p">],</span> <span class="n">func_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">]</span> +</span><span id="Column-135"><a href="#Column-135"><span class="linenos">135</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-136"><a href="#Column-136"><span class="linenos">136</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="p">[]</span> <span class="k">if</span> <span class="n">column</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="p">[</span><span class="bp">cls</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">column</span><span class="p">)]</span> +</span><span id="Column-137"><a href="#Column-137"><span class="linenos">137</span></a> <span class="n">column_args</span> <span class="o">=</span> <span class="p">[</span><span class="bp">cls</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">]</span> +</span><span id="Column-138"><a href="#Column-138"><span class="linenos">138</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">expression</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">columns</span> <span class="o">+</span> <span class="n">column_args</span><span class="p">]</span> +</span><span id="Column-139"><a href="#Column-139"><span class="linenos">139</span></a> <span class="n">new_expression</span> <span class="o">=</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="n">func_name</span><span class="o">.</span><span class="n">upper</span><span class="p">(),</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Column-140"><a href="#Column-140"><span class="linenos">140</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> +</span><span id="Column-141"><a href="#Column-141"><span class="linenos">141</span></a> +</span><span id="Column-142"><a href="#Column-142"><span class="linenos">142</span></a> <span class="nd">@classmethod</span> +</span><span id="Column-143"><a href="#Column-143"><span class="linenos">143</span></a> <span class="k">def</span> <span class="nf">invoke_expression_over_column</span><span class="p">(</span> +</span><span id="Column-144"><a href="#Column-144"><span class="linenos">144</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">column</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">ColumnOrLiteral</span><span class="p">],</span> <span class="n">callable_expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> +</span><span id="Column-145"><a href="#Column-145"><span class="linenos">145</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-146"><a href="#Column-146"><span class="linenos">146</span></a> <span class="n">ensured_column</span> <span class="o">=</span> <span class="kc">None</span> <span class="k">if</span> <span class="n">column</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="bp">cls</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">column</span><span class="p">)</span> +</span><span id="Column-147"><a href="#Column-147"><span class="linenos">147</span></a> <span class="n">ensure_expression_values</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Column-148"><a href="#Column-148"><span class="linenos">148</span></a> <span class="n">k</span><span class="p">:</span> <span class="p">[</span><span class="n">Column</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">v</span><span class="p">]</span> +</span><span id="Column-149"><a href="#Column-149"><span class="linenos">149</span></a> <span class="k">if</span> <span class="n">is_iterable</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> +</span><span id="Column-150"><a href="#Column-150"><span class="linenos">150</span></a> <span class="k">else</span> <span class="n">Column</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Column-151"><a href="#Column-151"><span class="linenos">151</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> +</span><span id="Column-152"><a href="#Column-152"><span class="linenos">152</span></a> <span class="k">if</span> <span class="n">v</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> +</span><span id="Column-153"><a href="#Column-153"><span class="linenos">153</span></a> <span class="p">}</span> +</span><span id="Column-154"><a href="#Column-154"><span class="linenos">154</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Column-155"><a href="#Column-155"><span class="linenos">155</span></a> <span class="n">callable_expression</span><span class="p">(</span><span class="o">**</span><span class="n">ensure_expression_values</span><span class="p">)</span> +</span><span id="Column-156"><a href="#Column-156"><span class="linenos">156</span></a> <span class="k">if</span> <span class="n">ensured_column</span> <span class="ow">is</span> <span class="kc">None</span> +</span><span id="Column-157"><a href="#Column-157"><span class="linenos">157</span></a> <span class="k">else</span> <span class="n">callable_expression</span><span class="p">(</span> +</span><span id="Column-158"><a href="#Column-158"><span class="linenos">158</span></a> <span class="n">this</span><span class="o">=</span><span class="n">ensured_column</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="o">**</span><span class="n">ensure_expression_values</span> +</span><span id="Column-159"><a href="#Column-159"><span class="linenos">159</span></a> <span class="p">)</span> +</span><span id="Column-160"><a href="#Column-160"><span class="linenos">160</span></a> <span class="p">)</span> +</span><span id="Column-161"><a href="#Column-161"><span class="linenos">161</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> </span><span id="Column-162"><a href="#Column-162"><span class="linenos">162</span></a> -</span><span id="Column-163"><a href="#Column-163"><span class="linenos">163</span></a> <span class="k">def</span> <span class="nf">inverse_binary_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">klass</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-163"><a href="#Column-163"><span class="linenos">163</span></a> <span class="k">def</span> <span class="nf">binary_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">klass</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> </span><span id="Column-164"><a href="#Column-164"><span class="linenos">164</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span> -</span><span id="Column-165"><a href="#Column-165"><span class="linenos">165</span></a> <span class="n">klass</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">other</span><span class="p">)</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="Column-165"><a href="#Column-165"><span class="linenos">165</span></a> <span class="n">klass</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">column_expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">other</span><span class="p">)</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> </span><span id="Column-166"><a href="#Column-166"><span class="linenos">166</span></a> <span class="p">)</span> </span><span id="Column-167"><a href="#Column-167"><span class="linenos">167</span></a> -</span><span id="Column-168"><a href="#Column-168"><span class="linenos">168</span></a> <span class="k">def</span> <span class="nf">unary_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">klass</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-169"><a href="#Column-169"><span class="linenos">169</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">klass</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">column_expression</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">))</span> -</span><span id="Column-170"><a href="#Column-170"><span class="linenos">170</span></a> -</span><span id="Column-171"><a href="#Column-171"><span class="linenos">171</span></a> <span class="nd">@property</span> -</span><span id="Column-172"><a href="#Column-172"><span class="linenos">172</span></a> <span class="k">def</span> <span class="nf">is_alias</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Column-173"><a href="#Column-173"><span class="linenos">173</span></a> <span class="k">return</span> <span class="nb">isinstance</span><span class="p">(</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">Alias</span><span class="p">)</span> -</span><span id="Column-174"><a href="#Column-174"><span class="linenos">174</span></a> -</span><span id="Column-175"><a href="#Column-175"><span class="linenos">175</span></a> <span class="nd">@property</span> -</span><span id="Column-176"><a href="#Column-176"><span class="linenos">176</span></a> <span class="k">def</span> <span class="nf">is_column</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Column-177"><a href="#Column-177"><span class="linenos">177</span></a> <span class="k">return</span> <span class="nb">isinstance</span><span class="p">(</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">Column</span><span class="p">)</span> -</span><span id="Column-178"><a href="#Column-178"><span class="linenos">178</span></a> -</span><span id="Column-179"><a href="#Column-179"><span class="linenos">179</span></a> <span class="nd">@property</span> -</span><span id="Column-180"><a href="#Column-180"><span class="linenos">180</span></a> <span class="k">def</span> <span class="nf">column_expression</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">]:</span> -</span><span id="Column-181"><a href="#Column-181"><span class="linenos">181</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">unalias</span><span class="p">()</span> -</span><span id="Column-182"><a href="#Column-182"><span class="linenos">182</span></a> -</span><span id="Column-183"><a href="#Column-183"><span class="linenos">183</span></a> <span class="nd">@property</span> -</span><span id="Column-184"><a href="#Column-184"><span class="linenos">184</span></a> <span class="k">def</span> <span class="nf">alias_or_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Column-185"><a href="#Column-185"><span class="linenos">185</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">alias_or_name</span> -</span><span id="Column-186"><a href="#Column-186"><span class="linenos">186</span></a> -</span><span id="Column-187"><a href="#Column-187"><span class="linenos">187</span></a> <span class="nd">@classmethod</span> -</span><span id="Column-188"><a href="#Column-188"><span class="linenos">188</span></a> <span class="k">def</span> <span class="nf">ensure_literal</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-189"><a href="#Column-189"><span class="linenos">189</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">lit</span> -</span><span id="Column-190"><a href="#Column-190"><span class="linenos">190</span></a> -</span><span id="Column-191"><a href="#Column-191"><span class="linenos">191</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="bp">cls</span><span class="p">):</span> -</span><span id="Column-192"><a href="#Column-192"><span class="linenos">192</span></a> <span class="n">value</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">expression</span> -</span><span id="Column-193"><a href="#Column-193"><span class="linenos">193</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</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="Column-194"><a href="#Column-194"><span class="linenos">194</span></a> <span class="k">return</span> <span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="Column-195"><a href="#Column-195"><span class="linenos">195</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="Column-196"><a href="#Column-196"><span class="linenos">196</span></a> -</span><span id="Column-197"><a href="#Column-197"><span class="linenos">197</span></a> <span class="k">def</span> <span class="nf">copy</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-198"><a href="#Column-198"><span class="linenos">198</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">())</span> -</span><span id="Column-199"><a href="#Column-199"><span class="linenos">199</span></a> -</span><span id="Column-200"><a href="#Column-200"><span class="linenos">200</span></a> <span class="k">def</span> <span class="nf">set_table_name</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">table_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-201"><a href="#Column-201"><span class="linenos">201</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="k">if</span> <span class="n">copy</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span> -</span><span id="Column-202"><a href="#Column-202"><span class="linenos">202</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"table"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table_name</span><span class="p">))</span> -</span><span id="Column-203"><a href="#Column-203"><span class="linenos">203</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Column-168"><a href="#Column-168"><span class="linenos">168</span></a> <span class="k">def</span> <span class="nf">inverse_binary_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">klass</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-169"><a href="#Column-169"><span class="linenos">169</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span> +</span><span id="Column-170"><a href="#Column-170"><span class="linenos">170</span></a> <span class="n">klass</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">other</span><span class="p">)</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="Column-171"><a href="#Column-171"><span class="linenos">171</span></a> <span class="p">)</span> +</span><span id="Column-172"><a href="#Column-172"><span class="linenos">172</span></a> +</span><span id="Column-173"><a href="#Column-173"><span class="linenos">173</span></a> <span class="k">def</span> <span class="nf">unary_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">klass</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-174"><a href="#Column-174"><span class="linenos">174</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">klass</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">column_expression</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">))</span> +</span><span id="Column-175"><a href="#Column-175"><span class="linenos">175</span></a> +</span><span id="Column-176"><a href="#Column-176"><span class="linenos">176</span></a> <span class="nd">@property</span> +</span><span id="Column-177"><a href="#Column-177"><span class="linenos">177</span></a> <span class="k">def</span> <span class="nf">is_alias</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Column-178"><a href="#Column-178"><span class="linenos">178</span></a> <span class="k">return</span> <span class="nb">isinstance</span><span class="p">(</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">Alias</span><span class="p">)</span> +</span><span id="Column-179"><a href="#Column-179"><span class="linenos">179</span></a> +</span><span id="Column-180"><a href="#Column-180"><span class="linenos">180</span></a> <span class="nd">@property</span> +</span><span id="Column-181"><a href="#Column-181"><span class="linenos">181</span></a> <span class="k">def</span> <span class="nf">is_column</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Column-182"><a href="#Column-182"><span class="linenos">182</span></a> <span class="k">return</span> <span class="nb">isinstance</span><span class="p">(</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">Column</span><span class="p">)</span> +</span><span id="Column-183"><a href="#Column-183"><span class="linenos">183</span></a> +</span><span id="Column-184"><a href="#Column-184"><span class="linenos">184</span></a> <span class="nd">@property</span> +</span><span id="Column-185"><a href="#Column-185"><span class="linenos">185</span></a> <span class="k">def</span> <span class="nf">column_expression</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">]:</span> +</span><span id="Column-186"><a href="#Column-186"><span class="linenos">186</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">unalias</span><span class="p">()</span> +</span><span id="Column-187"><a href="#Column-187"><span class="linenos">187</span></a> +</span><span id="Column-188"><a href="#Column-188"><span class="linenos">188</span></a> <span class="nd">@property</span> +</span><span id="Column-189"><a href="#Column-189"><span class="linenos">189</span></a> <span class="k">def</span> <span class="nf">alias_or_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Column-190"><a href="#Column-190"><span class="linenos">190</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">alias_or_name</span> +</span><span id="Column-191"><a href="#Column-191"><span class="linenos">191</span></a> +</span><span id="Column-192"><a href="#Column-192"><span class="linenos">192</span></a> <span class="nd">@classmethod</span> +</span><span id="Column-193"><a href="#Column-193"><span class="linenos">193</span></a> <span class="k">def</span> <span class="nf">ensure_literal</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-194"><a href="#Column-194"><span class="linenos">194</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">lit</span> +</span><span id="Column-195"><a href="#Column-195"><span class="linenos">195</span></a> +</span><span id="Column-196"><a href="#Column-196"><span class="linenos">196</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="bp">cls</span><span class="p">):</span> +</span><span id="Column-197"><a href="#Column-197"><span class="linenos">197</span></a> <span class="n">value</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Column-198"><a href="#Column-198"><span class="linenos">198</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</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="Column-199"><a href="#Column-199"><span class="linenos">199</span></a> <span class="k">return</span> <span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="Column-200"><a href="#Column-200"><span class="linenos">200</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="Column-201"><a href="#Column-201"><span class="linenos">201</span></a> +</span><span id="Column-202"><a href="#Column-202"><span class="linenos">202</span></a> <span class="k">def</span> <span class="nf">copy</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-203"><a href="#Column-203"><span class="linenos">203</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">())</span> </span><span id="Column-204"><a href="#Column-204"><span class="linenos">204</span></a> -</span><span id="Column-205"><a href="#Column-205"><span class="linenos">205</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Column-206"><a href="#Column-206"><span class="linenos">206</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="s2">"dialect"</span><span class="p">:</span> <span class="s2">"spark"</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">})</span> -</span><span id="Column-207"><a href="#Column-207"><span class="linenos">207</span></a> -</span><span id="Column-208"><a href="#Column-208"><span class="linenos">208</span></a> <span class="k">def</span> <span class="nf">alias</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-209"><a href="#Column-209"><span class="linenos">209</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span> -</span><span id="Column-210"><a href="#Column-210"><span class="linenos">210</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> -</span><span id="Column-211"><a href="#Column-211"><span class="linenos">211</span></a> -</span><span id="Column-212"><a href="#Column-212"><span class="linenos">212</span></a> <span class="k">def</span> <span class="nf">asc</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-213"><a href="#Column-213"><span class="linenos">213</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Column-214"><a href="#Column-214"><span class="linenos">214</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> -</span><span id="Column-215"><a href="#Column-215"><span class="linenos">215</span></a> -</span><span id="Column-216"><a href="#Column-216"><span class="linenos">216</span></a> <span class="k">def</span> <span class="nf">desc</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-217"><a href="#Column-217"><span class="linenos">217</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Column-218"><a href="#Column-218"><span class="linenos">218</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> -</span><span id="Column-219"><a href="#Column-219"><span class="linenos">219</span></a> -</span><span id="Column-220"><a href="#Column-220"><span class="linenos">220</span></a> <span class="n">asc_nulls_first</span> <span class="o">=</span> <span class="n">asc</span> -</span><span id="Column-221"><a href="#Column-221"><span class="linenos">221</span></a> -</span><span id="Column-222"><a href="#Column-222"><span class="linenos">222</span></a> <span class="k">def</span> <span class="nf">asc_nulls_last</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-223"><a href="#Column-223"><span class="linenos">223</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Column-224"><a href="#Column-224"><span class="linenos">224</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> -</span><span id="Column-225"><a href="#Column-225"><span class="linenos">225</span></a> -</span><span id="Column-226"><a href="#Column-226"><span class="linenos">226</span></a> <span class="k">def</span> <span class="nf">desc_nulls_first</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-227"><a href="#Column-227"><span class="linenos">227</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Column-228"><a href="#Column-228"><span class="linenos">228</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> -</span><span id="Column-229"><a href="#Column-229"><span class="linenos">229</span></a> -</span><span id="Column-230"><a href="#Column-230"><span class="linenos">230</span></a> <span class="n">desc_nulls_last</span> <span class="o">=</span> <span class="n">desc</span> -</span><span id="Column-231"><a href="#Column-231"><span class="linenos">231</span></a> -</span><span id="Column-232"><a href="#Column-232"><span class="linenos">232</span></a> <span class="k">def</span> <span class="nf">when</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">condition</span><span class="p">:</span> <span class="n">Column</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-233"><a href="#Column-233"><span class="linenos">233</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">when</span> +</span><span id="Column-205"><a href="#Column-205"><span class="linenos">205</span></a> <span class="k">def</span> <span class="nf">set_table_name</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">table_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-206"><a href="#Column-206"><span class="linenos">206</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="k">if</span> <span class="n">copy</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Column-207"><a href="#Column-207"><span class="linenos">207</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"table"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table_name</span><span class="p">))</span> +</span><span id="Column-208"><a href="#Column-208"><span class="linenos">208</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Column-209"><a href="#Column-209"><span class="linenos">209</span></a> +</span><span id="Column-210"><a href="#Column-210"><span class="linenos">210</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Column-211"><a href="#Column-211"><span class="linenos">211</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="s2">"dialect"</span><span class="p">:</span> <span class="s2">"spark"</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">})</span> +</span><span id="Column-212"><a href="#Column-212"><span class="linenos">212</span></a> +</span><span id="Column-213"><a href="#Column-213"><span class="linenos">213</span></a> <span class="k">def</span> <span class="nf">alias</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-214"><a href="#Column-214"><span class="linenos">214</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span> +</span><span id="Column-215"><a href="#Column-215"><span class="linenos">215</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> +</span><span id="Column-216"><a href="#Column-216"><span class="linenos">216</span></a> +</span><span id="Column-217"><a href="#Column-217"><span class="linenos">217</span></a> <span class="k">def</span> <span class="nf">asc</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-218"><a href="#Column-218"><span class="linenos">218</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Column-219"><a href="#Column-219"><span class="linenos">219</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> +</span><span id="Column-220"><a href="#Column-220"><span class="linenos">220</span></a> +</span><span id="Column-221"><a href="#Column-221"><span class="linenos">221</span></a> <span class="k">def</span> <span class="nf">desc</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-222"><a href="#Column-222"><span class="linenos">222</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Column-223"><a href="#Column-223"><span class="linenos">223</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> +</span><span id="Column-224"><a href="#Column-224"><span class="linenos">224</span></a> +</span><span id="Column-225"><a href="#Column-225"><span class="linenos">225</span></a> <span class="n">asc_nulls_first</span> <span class="o">=</span> <span class="n">asc</span> +</span><span id="Column-226"><a href="#Column-226"><span class="linenos">226</span></a> +</span><span id="Column-227"><a href="#Column-227"><span class="linenos">227</span></a> <span class="k">def</span> <span class="nf">asc_nulls_last</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-228"><a href="#Column-228"><span class="linenos">228</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Column-229"><a href="#Column-229"><span class="linenos">229</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> +</span><span id="Column-230"><a href="#Column-230"><span class="linenos">230</span></a> +</span><span id="Column-231"><a href="#Column-231"><span class="linenos">231</span></a> <span class="k">def</span> <span class="nf">desc_nulls_first</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-232"><a href="#Column-232"><span class="linenos">232</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Column-233"><a href="#Column-233"><span class="linenos">233</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> </span><span id="Column-234"><a href="#Column-234"><span class="linenos">234</span></a> -</span><span id="Column-235"><a href="#Column-235"><span class="linenos">235</span></a> <span class="n">column_with_if</span> <span class="o">=</span> <span class="n">when</span><span class="p">(</span><span class="n">condition</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> -</span><span id="Column-236"><a href="#Column-236"><span class="linenos">236</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</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">Case</span><span class="p">):</span> -</span><span id="Column-237"><a href="#Column-237"><span class="linenos">237</span></a> <span class="k">return</span> <span class="n">column_with_if</span> -</span><span id="Column-238"><a href="#Column-238"><span class="linenos">238</span></a> <span class="n">new_column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Column-239"><a href="#Column-239"><span class="linenos">239</span></a> <span class="n">new_column</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">"ifs"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">column_with_if</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">"ifs"</span><span class="p">])</span> -</span><span id="Column-240"><a href="#Column-240"><span class="linenos">240</span></a> <span class="k">return</span> <span class="n">new_column</span> -</span><span id="Column-241"><a href="#Column-241"><span class="linenos">241</span></a> -</span><span id="Column-242"><a href="#Column-242"><span class="linenos">242</span></a> <span class="k">def</span> <span class="nf">otherwise</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-243"><a href="#Column-243"><span class="linenos">243</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">lit</span> -</span><span id="Column-244"><a href="#Column-244"><span class="linenos">244</span></a> -</span><span id="Column-245"><a href="#Column-245"><span class="linenos">245</span></a> <span class="n">true_value</span> <span class="o">=</span> <span class="n">value</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="Column-246"><a href="#Column-246"><span class="linenos">246</span></a> <span class="n">new_column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Column-247"><a href="#Column-247"><span class="linenos">247</span></a> <span class="n">new_column</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"default"</span><span class="p">,</span> <span class="n">true_value</span><span class="o">.</span><span class="n">column_expression</span><span class="p">)</span> -</span><span id="Column-248"><a href="#Column-248"><span class="linenos">248</span></a> <span class="k">return</span> <span class="n">new_column</span> +</span><span id="Column-235"><a href="#Column-235"><span class="linenos">235</span></a> <span class="n">desc_nulls_last</span> <span class="o">=</span> <span class="n">desc</span> +</span><span id="Column-236"><a href="#Column-236"><span class="linenos">236</span></a> +</span><span id="Column-237"><a href="#Column-237"><span class="linenos">237</span></a> <span class="k">def</span> <span class="nf">when</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">condition</span><span class="p">:</span> <span class="n">Column</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-238"><a href="#Column-238"><span class="linenos">238</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">when</span> +</span><span id="Column-239"><a href="#Column-239"><span class="linenos">239</span></a> +</span><span id="Column-240"><a href="#Column-240"><span class="linenos">240</span></a> <span class="n">column_with_if</span> <span class="o">=</span> <span class="n">when</span><span class="p">(</span><span class="n">condition</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> +</span><span id="Column-241"><a href="#Column-241"><span class="linenos">241</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</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">Case</span><span class="p">):</span> +</span><span id="Column-242"><a href="#Column-242"><span class="linenos">242</span></a> <span class="k">return</span> <span class="n">column_with_if</span> +</span><span id="Column-243"><a href="#Column-243"><span class="linenos">243</span></a> <span class="n">new_column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Column-244"><a href="#Column-244"><span class="linenos">244</span></a> <span class="n">new_column</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">"ifs"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">column_with_if</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">"ifs"</span><span class="p">])</span> +</span><span id="Column-245"><a href="#Column-245"><span class="linenos">245</span></a> <span class="k">return</span> <span class="n">new_column</span> +</span><span id="Column-246"><a href="#Column-246"><span class="linenos">246</span></a> +</span><span id="Column-247"><a href="#Column-247"><span class="linenos">247</span></a> <span class="k">def</span> <span class="nf">otherwise</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-248"><a href="#Column-248"><span class="linenos">248</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">lit</span> </span><span id="Column-249"><a href="#Column-249"><span class="linenos">249</span></a> -</span><span id="Column-250"><a href="#Column-250"><span class="linenos">250</span></a> <span class="k">def</span> <span class="nf">isNull</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-251"><a href="#Column-251"><span class="linenos">251</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">())</span> -</span><span id="Column-252"><a href="#Column-252"><span class="linenos">252</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> -</span><span id="Column-253"><a href="#Column-253"><span class="linenos">253</span></a> -</span><span id="Column-254"><a href="#Column-254"><span class="linenos">254</span></a> <span class="k">def</span> <span class="nf">isNotNull</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-255"><a href="#Column-255"><span class="linenos">255</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Not</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">()))</span> -</span><span id="Column-256"><a href="#Column-256"><span class="linenos">256</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> -</span><span id="Column-257"><a href="#Column-257"><span class="linenos">257</span></a> -</span><span id="Column-258"><a href="#Column-258"><span class="linenos">258</span></a> <span class="k">def</span> <span class="nf">cast</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataType</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">DataType</span><span class="p">]):</span> -</span><span id="Column-259"><a href="#Column-259"><span class="linenos">259</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Column-260"><a href="#Column-260"><span class="linenos">260</span></a><span class="sd"> Functionality Difference: PySpark cast accepts a datatype instance of the datatype class</span> -</span><span id="Column-261"><a href="#Column-261"><span class="linenos">261</span></a><span class="sd"> Sqlglot doesn't currently replicate this class so it only accepts a string</span> -</span><span id="Column-262"><a href="#Column-262"><span class="linenos">262</span></a><span class="sd"> """</span> -</span><span id="Column-263"><a href="#Column-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dataType</span><span class="p">,</span> <span class="n">DataType</span><span class="p">):</span> -</span><span id="Column-264"><a href="#Column-264"><span class="linenos">264</span></a> <span class="n">dataType</span> <span class="o">=</span> <span class="n">dataType</span><span class="o">.</span><span class="n">simpleString</span><span class="p">()</span> -</span><span id="Column-265"><a href="#Column-265"><span class="linenos">265</span></a> <span class="k">return</span> <span class="n">Column</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="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">dataType</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"spark"</span><span class="p">))</span> -</span><span id="Column-266"><a href="#Column-266"><span class="linenos">266</span></a> -</span><span id="Column-267"><a href="#Column-267"><span class="linenos">267</span></a> <span class="k">def</span> <span class="nf">startswith</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Column</span><span class="p">])</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-268"><a href="#Column-268"><span class="linenos">268</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">value</span> -</span><span id="Column-269"><a href="#Column-269"><span class="linenos">269</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">invoke_anonymous_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s2">"STARTSWITH"</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> -</span><span id="Column-270"><a href="#Column-270"><span class="linenos">270</span></a> -</span><span id="Column-271"><a href="#Column-271"><span class="linenos">271</span></a> <span class="k">def</span> <span class="nf">endswith</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Column</span><span class="p">])</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-272"><a href="#Column-272"><span class="linenos">272</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">value</span> -</span><span id="Column-273"><a href="#Column-273"><span class="linenos">273</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">invoke_anonymous_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s2">"ENDSWITH"</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> -</span><span id="Column-274"><a href="#Column-274"><span class="linenos">274</span></a> -</span><span id="Column-275"><a href="#Column-275"><span class="linenos">275</span></a> <span class="k">def</span> <span class="nf">rlike</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">regexp</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-276"><a href="#Column-276"><span class="linenos">276</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">invoke_expression_over_column</span><span class="p">(</span> -</span><span id="Column-277"><a href="#Column-277"><span class="linenos">277</span></a> <span class="n">column</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="n">callable_expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">regexp</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> -</span><span id="Column-278"><a href="#Column-278"><span class="linenos">278</span></a> <span class="p">)</span> +</span><span id="Column-250"><a href="#Column-250"><span class="linenos">250</span></a> <span class="n">true_value</span> <span class="o">=</span> <span class="n">value</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="Column-251"><a href="#Column-251"><span class="linenos">251</span></a> <span class="n">new_column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Column-252"><a href="#Column-252"><span class="linenos">252</span></a> <span class="n">new_column</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"default"</span><span class="p">,</span> <span class="n">true_value</span><span class="o">.</span><span class="n">column_expression</span><span class="p">)</span> +</span><span id="Column-253"><a href="#Column-253"><span class="linenos">253</span></a> <span class="k">return</span> <span class="n">new_column</span> +</span><span id="Column-254"><a href="#Column-254"><span class="linenos">254</span></a> +</span><span id="Column-255"><a href="#Column-255"><span class="linenos">255</span></a> <span class="k">def</span> <span class="nf">isNull</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-256"><a href="#Column-256"><span class="linenos">256</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">())</span> +</span><span id="Column-257"><a href="#Column-257"><span class="linenos">257</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> +</span><span id="Column-258"><a href="#Column-258"><span class="linenos">258</span></a> +</span><span id="Column-259"><a href="#Column-259"><span class="linenos">259</span></a> <span class="k">def</span> <span class="nf">isNotNull</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-260"><a href="#Column-260"><span class="linenos">260</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Not</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">()))</span> +</span><span id="Column-261"><a href="#Column-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> +</span><span id="Column-262"><a href="#Column-262"><span class="linenos">262</span></a> +</span><span id="Column-263"><a href="#Column-263"><span class="linenos">263</span></a> <span class="k">def</span> <span class="nf">cast</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataType</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">DataType</span><span class="p">]):</span> +</span><span id="Column-264"><a href="#Column-264"><span class="linenos">264</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Column-265"><a href="#Column-265"><span class="linenos">265</span></a><span class="sd"> Functionality Difference: PySpark cast accepts a datatype instance of the datatype class</span> +</span><span id="Column-266"><a href="#Column-266"><span class="linenos">266</span></a><span class="sd"> Sqlglot doesn't currently replicate this class so it only accepts a string</span> +</span><span id="Column-267"><a href="#Column-267"><span class="linenos">267</span></a><span class="sd"> """</span> +</span><span id="Column-268"><a href="#Column-268"><span class="linenos">268</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dataType</span><span class="p">,</span> <span class="n">DataType</span><span class="p">):</span> +</span><span id="Column-269"><a href="#Column-269"><span class="linenos">269</span></a> <span class="n">dataType</span> <span class="o">=</span> <span class="n">dataType</span><span class="o">.</span><span class="n">simpleString</span><span class="p">()</span> +</span><span id="Column-270"><a href="#Column-270"><span class="linenos">270</span></a> <span class="k">return</span> <span class="n">Column</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="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">dataType</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"spark"</span><span class="p">))</span> +</span><span id="Column-271"><a href="#Column-271"><span class="linenos">271</span></a> +</span><span id="Column-272"><a href="#Column-272"><span class="linenos">272</span></a> <span class="k">def</span> <span class="nf">startswith</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Column</span><span class="p">])</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-273"><a href="#Column-273"><span class="linenos">273</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">value</span> +</span><span id="Column-274"><a href="#Column-274"><span class="linenos">274</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">invoke_anonymous_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s2">"STARTSWITH"</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> +</span><span id="Column-275"><a href="#Column-275"><span class="linenos">275</span></a> +</span><span id="Column-276"><a href="#Column-276"><span class="linenos">276</span></a> <span class="k">def</span> <span class="nf">endswith</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Column</span><span class="p">])</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-277"><a href="#Column-277"><span class="linenos">277</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">value</span> +</span><span id="Column-278"><a href="#Column-278"><span class="linenos">278</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">invoke_anonymous_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s2">"ENDSWITH"</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> </span><span id="Column-279"><a href="#Column-279"><span class="linenos">279</span></a> -</span><span id="Column-280"><a href="#Column-280"><span class="linenos">280</span></a> <span class="k">def</span> <span class="nf">like</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="Column-280"><a href="#Column-280"><span class="linenos">280</span></a> <span class="k">def</span> <span class="nf">rlike</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">regexp</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> </span><span id="Column-281"><a href="#Column-281"><span class="linenos">281</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">invoke_expression_over_column</span><span class="p">(</span> -</span><span id="Column-282"><a href="#Column-282"><span class="linenos">282</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Like</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">other</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Column-282"><a href="#Column-282"><span class="linenos">282</span></a> <span class="n">column</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="n">callable_expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">regexp</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> </span><span id="Column-283"><a href="#Column-283"><span class="linenos">283</span></a> <span class="p">)</span> </span><span id="Column-284"><a href="#Column-284"><span class="linenos">284</span></a> -</span><span id="Column-285"><a href="#Column-285"><span class="linenos">285</span></a> <span class="k">def</span> <span class="nf">ilike</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="Column-285"><a href="#Column-285"><span class="linenos">285</span></a> <span class="k">def</span> <span class="nf">like</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span> </span><span id="Column-286"><a href="#Column-286"><span class="linenos">286</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">invoke_expression_over_column</span><span class="p">(</span> -</span><span id="Column-287"><a href="#Column-287"><span class="linenos">287</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">other</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Column-287"><a href="#Column-287"><span class="linenos">287</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Like</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">other</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> </span><span id="Column-288"><a href="#Column-288"><span class="linenos">288</span></a> <span class="p">)</span> </span><span id="Column-289"><a href="#Column-289"><span class="linenos">289</span></a> -</span><span id="Column-290"><a href="#Column-290"><span class="linenos">290</span></a> <span class="k">def</span> <span class="nf">substr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">startPos</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="n">Column</span><span class="p">],</span> <span class="n">length</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="n">Column</span><span class="p">])</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-291"><a href="#Column-291"><span class="linenos">291</span></a> <span class="n">startPos</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">startPos</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">startPos</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">startPos</span> -</span><span id="Column-292"><a href="#Column-292"><span class="linenos">292</span></a> <span class="n">length</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">length</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">length</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">length</span> -</span><span id="Column-293"><a href="#Column-293"><span class="linenos">293</span></a> <span class="k">return</span> <span class="n">Column</span><span class="o">.</span><span class="n">invoke_expression_over_column</span><span class="p">(</span> -</span><span id="Column-294"><a href="#Column-294"><span class="linenos">294</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Substring</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="n">startPos</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">length</span><span class="o">=</span><span class="n">length</span><span class="o">.</span><span class="n">expression</span> -</span><span id="Column-295"><a href="#Column-295"><span class="linenos">295</span></a> <span class="p">)</span> -</span><span id="Column-296"><a href="#Column-296"><span class="linenos">296</span></a> -</span><span id="Column-297"><a href="#Column-297"><span class="linenos">297</span></a> <span class="k">def</span> <span class="nf">isin</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">]]):</span> -</span><span id="Column-298"><a href="#Column-298"><span class="linenos">298</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">flatten</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">cols</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">set</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">))</span> <span class="k">else</span> <span class="n">cols</span> <span class="c1"># type: ignore</span> -</span><span id="Column-299"><a href="#Column-299"><span class="linenos">299</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">columns</span><span class="p">]</span> -</span><span id="Column-300"><a href="#Column-300"><span class="linenos">300</span></a> <span class="k">return</span> <span class="n">Column</span><span class="o">.</span><span class="n">invoke_expression_over_column</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">In</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="Column-290"><a href="#Column-290"><span class="linenos">290</span></a> <span class="k">def</span> <span class="nf">ilike</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="Column-291"><a href="#Column-291"><span class="linenos">291</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">invoke_expression_over_column</span><span class="p">(</span> +</span><span id="Column-292"><a href="#Column-292"><span class="linenos">292</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">other</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Column-293"><a href="#Column-293"><span class="linenos">293</span></a> <span class="p">)</span> +</span><span id="Column-294"><a href="#Column-294"><span class="linenos">294</span></a> +</span><span id="Column-295"><a href="#Column-295"><span class="linenos">295</span></a> <span class="k">def</span> <span class="nf">substr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">startPos</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="n">Column</span><span class="p">],</span> <span class="n">length</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="n">Column</span><span class="p">])</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-296"><a href="#Column-296"><span class="linenos">296</span></a> <span class="n">startPos</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">startPos</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">startPos</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">startPos</span> +</span><span id="Column-297"><a href="#Column-297"><span class="linenos">297</span></a> <span class="n">length</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">length</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">length</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">length</span> +</span><span id="Column-298"><a href="#Column-298"><span class="linenos">298</span></a> <span class="k">return</span> <span class="n">Column</span><span class="o">.</span><span class="n">invoke_expression_over_column</span><span class="p">(</span> +</span><span id="Column-299"><a href="#Column-299"><span class="linenos">299</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Substring</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="n">startPos</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">length</span><span class="o">=</span><span class="n">length</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Column-300"><a href="#Column-300"><span class="linenos">300</span></a> <span class="p">)</span> </span><span id="Column-301"><a href="#Column-301"><span class="linenos">301</span></a> -</span><span id="Column-302"><a href="#Column-302"><span class="linenos">302</span></a> <span class="k">def</span> <span class="nf">between</span><span class="p">(</span> -</span><span id="Column-303"><a href="#Column-303"><span class="linenos">303</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Column-304"><a href="#Column-304"><span class="linenos">304</span></a> <span class="n">lowerBound</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">],</span> -</span><span id="Column-305"><a href="#Column-305"><span class="linenos">305</span></a> <span class="n">upperBound</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">],</span> -</span><span id="Column-306"><a href="#Column-306"><span class="linenos">306</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-307"><a href="#Column-307"><span class="linenos">307</span></a> <span class="n">lower_bound_exp</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Column-308"><a href="#Column-308"><span class="linenos">308</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">lowerBound</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">lowerBound</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">lowerBound</span> -</span><span id="Column-309"><a href="#Column-309"><span class="linenos">309</span></a> <span class="p">)</span> -</span><span id="Column-310"><a href="#Column-310"><span class="linenos">310</span></a> <span class="n">upper_bound_exp</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Column-311"><a href="#Column-311"><span class="linenos">311</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">upperBound</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">upperBound</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">upperBound</span> -</span><span id="Column-312"><a href="#Column-312"><span class="linenos">312</span></a> <span class="p">)</span> -</span><span id="Column-313"><a href="#Column-313"><span class="linenos">313</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span> -</span><span id="Column-314"><a href="#Column-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">(</span> -</span><span id="Column-315"><a href="#Column-315"><span class="linenos">315</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> -</span><span id="Column-316"><a href="#Column-316"><span class="linenos">316</span></a> <span class="n">low</span><span class="o">=</span><span class="n">lower_bound_exp</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="Column-317"><a href="#Column-317"><span class="linenos">317</span></a> <span class="n">high</span><span class="o">=</span><span class="n">upper_bound_exp</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="Column-318"><a href="#Column-318"><span class="linenos">318</span></a> <span class="p">)</span> -</span><span id="Column-319"><a href="#Column-319"><span class="linenos">319</span></a> <span class="p">)</span> -</span><span id="Column-320"><a href="#Column-320"><span class="linenos">320</span></a> -</span><span id="Column-321"><a href="#Column-321"><span class="linenos">321</span></a> <span class="k">def</span> <span class="nf">over</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">window</span><span class="p">:</span> <span class="n">WindowSpec</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column-322"><a href="#Column-322"><span class="linenos">322</span></a> <span class="n">window_expression</span> <span class="o">=</span> <span class="n">window</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Column-323"><a href="#Column-323"><span class="linenos">323</span></a> <span class="n">window_expression</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="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">)</span> -</span><span id="Column-324"><a href="#Column-324"><span class="linenos">324</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">window_expression</span><span class="p">)</span> +</span><span id="Column-302"><a href="#Column-302"><span class="linenos">302</span></a> <span class="k">def</span> <span class="nf">isin</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">]]):</span> +</span><span id="Column-303"><a href="#Column-303"><span class="linenos">303</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">flatten</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">cols</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">set</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">))</span> <span class="k">else</span> <span class="n">cols</span> <span class="c1"># type: ignore</span> +</span><span id="Column-304"><a href="#Column-304"><span class="linenos">304</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">columns</span><span class="p">]</span> +</span><span id="Column-305"><a href="#Column-305"><span class="linenos">305</span></a> <span class="k">return</span> <span class="n">Column</span><span class="o">.</span><span class="n">invoke_expression_over_column</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">In</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="Column-306"><a href="#Column-306"><span class="linenos">306</span></a> +</span><span id="Column-307"><a href="#Column-307"><span class="linenos">307</span></a> <span class="k">def</span> <span class="nf">between</span><span class="p">(</span> +</span><span id="Column-308"><a href="#Column-308"><span class="linenos">308</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Column-309"><a href="#Column-309"><span class="linenos">309</span></a> <span class="n">lowerBound</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">],</span> +</span><span id="Column-310"><a href="#Column-310"><span class="linenos">310</span></a> <span class="n">upperBound</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">],</span> +</span><span id="Column-311"><a href="#Column-311"><span class="linenos">311</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-312"><a href="#Column-312"><span class="linenos">312</span></a> <span class="n">lower_bound_exp</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Column-313"><a href="#Column-313"><span class="linenos">313</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">lowerBound</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">lowerBound</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">lowerBound</span> +</span><span id="Column-314"><a href="#Column-314"><span class="linenos">314</span></a> <span class="p">)</span> +</span><span id="Column-315"><a href="#Column-315"><span class="linenos">315</span></a> <span class="n">upper_bound_exp</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Column-316"><a href="#Column-316"><span class="linenos">316</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">upperBound</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">upperBound</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">upperBound</span> +</span><span id="Column-317"><a href="#Column-317"><span class="linenos">317</span></a> <span class="p">)</span> +</span><span id="Column-318"><a href="#Column-318"><span class="linenos">318</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span> +</span><span id="Column-319"><a href="#Column-319"><span class="linenos">319</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">(</span> +</span><span id="Column-320"><a href="#Column-320"><span class="linenos">320</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> +</span><span id="Column-321"><a href="#Column-321"><span class="linenos">321</span></a> <span class="n">low</span><span class="o">=</span><span class="n">lower_bound_exp</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="Column-322"><a href="#Column-322"><span class="linenos">322</span></a> <span class="n">high</span><span class="o">=</span><span class="n">upper_bound_exp</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="Column-323"><a href="#Column-323"><span class="linenos">323</span></a> <span class="p">)</span> +</span><span id="Column-324"><a href="#Column-324"><span class="linenos">324</span></a> <span class="p">)</span> +</span><span id="Column-325"><a href="#Column-325"><span class="linenos">325</span></a> +</span><span id="Column-326"><a href="#Column-326"><span class="linenos">326</span></a> <span class="k">def</span> <span class="nf">over</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">window</span><span class="p">:</span> <span class="n">WindowSpec</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column-327"><a href="#Column-327"><span class="linenos">327</span></a> <span class="n">window_expression</span> <span class="o">=</span> <span class="n">window</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Column-328"><a href="#Column-328"><span class="linenos">328</span></a> <span class="n">window_expression</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="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">)</span> +</span><span id="Column-329"><a href="#Column-329"><span class="linenos">329</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">window_expression</span><span class="p">)</span> </span></pre></div> @@ -3222,22 +3228,26 @@ and check if it matches the type of the value provided. If not then make it null <input id="Column.__init__-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> <div class="attr function"> - <span class="name">Column</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="n">expression</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043312805776'</span><span class="o">></span><span class="p">,</span> <span class="n"><a href="../expressions.html#Expression">sqlglot.expressions.Expression</a></span><span class="p">,</span> <span class="n">NoneType</span><span class="p">]</span></span>)</span> + <span class="name">Column</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="n">expression</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135092193312'</span><span class="o">></span><span class="p">,</span> <span class="n"><a href="../expressions.html#Expression">sqlglot.expressions.Expression</a></span><span class="p">,</span> <span class="n">NoneType</span><span class="p">]</span></span>)</span> <label class="view-source-button" for="Column.__init__-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#Column.__init__"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.__init__-17"><a href="#Column.__init__-17"><span class="linenos">17</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</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="Column.__init__-18"><a href="#Column.__init__-18"><span class="linenos">18</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Column</span><span class="p">):</span> -</span><span id="Column.__init__-19"><a href="#Column.__init__-19"><span class="linenos">19</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> <span class="c1"># type: ignore</span> -</span><span id="Column.__init__-20"><a href="#Column.__init__-20"><span class="linenos">20</span></a> <span class="k">elif</span> <span class="n">expression</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="p">(</span><span class="nb">str</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="Column.__init__-21"><a href="#Column.__init__-21"><span class="linenos">21</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> <span class="c1"># type: ignore</span> -</span><span id="Column.__init__-22"><a href="#Column.__init__-22"><span class="linenos">22</span></a> -</span><span id="Column.__init__-23"><a href="#Column.__init__-23"><span class="linenos">23</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"spark"</span><span class="p">)</span> -</span><span id="Column.__init__-24"><a href="#Column.__init__-24"><span class="linenos">24</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Column.__init__-25"><a href="#Column.__init__-25"><span class="linenos">25</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Could not parse </span><span class="si">{</span><span class="n">expression</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Column.__init__-26"><a href="#Column.__init__-26"><span class="linenos">26</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">Expression</span> <span class="o">=</span> <span class="n">expression</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.__init__-18"><a href="#Column.__init__-18"><span class="linenos">18</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</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="Column.__init__-19"><a href="#Column.__init__-19"><span class="linenos">19</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Column</span><span class="p">):</span> +</span><span id="Column.__init__-20"><a href="#Column.__init__-20"><span class="linenos">20</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span> <span class="c1"># type: ignore</span> +</span><span id="Column.__init__-21"><a href="#Column.__init__-21"><span class="linenos">21</span></a> <span class="k">elif</span> <span class="n">expression</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="p">(</span><span class="nb">str</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="Column.__init__-22"><a href="#Column.__init__-22"><span class="linenos">22</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> <span class="c1"># type: ignore</span> +</span><span id="Column.__init__-23"><a href="#Column.__init__-23"><span class="linenos">23</span></a> +</span><span id="Column.__init__-24"><a href="#Column.__init__-24"><span class="linenos">24</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"spark"</span><span class="p">)</span> +</span><span id="Column.__init__-25"><a href="#Column.__init__-25"><span class="linenos">25</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Column.__init__-26"><a href="#Column.__init__-26"><span class="linenos">26</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Could not parse </span><span class="si">{</span><span class="n">expression</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Column.__init__-27"><a href="#Column.__init__-27"><span class="linenos">27</span></a> +</span><span id="Column.__init__-28"><a href="#Column.__init__-28"><span class="linenos">28</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> +</span><span id="Column.__init__-29"><a href="#Column.__init__-29"><span class="linenos">29</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">Spark</span><span class="o">.</span><span class="n">normalize_identifier</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Column.__init__-30"><a href="#Column.__init__-30"><span class="linenos">30</span></a> +</span><span id="Column.__init__-31"><a href="#Column.__init__-31"><span class="linenos">31</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">Expression</span> <span class="o">=</span> <span class="n">expression</span> </span></pre></div> @@ -3250,15 +3260,15 @@ and check if it matches the type of the value provided. If not then make it null <div class="decorator">@classmethod</div> <span class="def">def</span> - <span class="name">ensure_col</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">cls</span>,</span><span class="param"> <span class="n">value</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043311007728'</span><span class="o">></span><span class="p">,</span> <span class="n"><a href="../expressions.html#Expression">sqlglot.expressions.Expression</a></span><span class="p">,</span> <span class="n">NoneType</span><span class="p">]</span></span><span class="return-annotation">):</span></span> + <span class="name">ensure_col</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">cls</span>,</span><span class="param"> <span class="n">value</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135090317456'</span><span class="o">></span><span class="p">,</span> <span class="n"><a href="../expressions.html#Expression">sqlglot.expressions.Expression</a></span><span class="p">,</span> <span class="n">NoneType</span><span class="p">]</span></span><span class="return-annotation">):</span></span> <label class="view-source-button" for="Column.ensure_col-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#Column.ensure_col"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.ensure_col-112"><a href="#Column.ensure_col-112"><span class="linenos">112</span></a> <span class="nd">@classmethod</span> -</span><span id="Column.ensure_col-113"><a href="#Column.ensure_col-113"><span class="linenos">113</span></a> <span class="k">def</span> <span class="nf">ensure_col</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</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="Column.ensure_col-114"><a href="#Column.ensure_col-114"><span class="linenos">114</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.ensure_col-117"><a href="#Column.ensure_col-117"><span class="linenos">117</span></a> <span class="nd">@classmethod</span> +</span><span id="Column.ensure_col-118"><a href="#Column.ensure_col-118"><span class="linenos">118</span></a> <span class="k">def</span> <span class="nf">ensure_col</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</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="Column.ensure_col-119"><a href="#Column.ensure_col-119"><span class="linenos">119</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> </span></pre></div> @@ -3271,15 +3281,15 @@ and check if it matches the type of the value provided. If not then make it null <div class="decorator">@classmethod</div> <span class="def">def</span> - <span class="name">ensure_cols</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">cls</span>,</span><span class="param"> <span class="n">args</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">Union</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043311137744'</span><span class="o">></span><span class="p">,</span> <span class="n"><a href="../expressions.html#Expression">sqlglot.expressions.Expression</a></span><span class="p">]]</span></span><span class="return-annotation">) -> <span class="n">List</span><span class="p">[</span><span class="n"><a href="#Column">sqlglot.dataframe.sql.Column</a></span><span class="p">]</span>:</span></span> + <span class="name">ensure_cols</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">cls</span>,</span><span class="param"> <span class="n">args</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">Union</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135089983680'</span><span class="o">></span><span class="p">,</span> <span class="n"><a href="../expressions.html#Expression">sqlglot.expressions.Expression</a></span><span class="p">]]</span></span><span class="return-annotation">) -> <span class="n">List</span><span class="p">[</span><span class="n"><a href="#Column">sqlglot.dataframe.sql.Column</a></span><span class="p">]</span>:</span></span> <label class="view-source-button" for="Column.ensure_cols-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#Column.ensure_cols"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.ensure_cols-116"><a href="#Column.ensure_cols-116"><span class="linenos">116</span></a> <span class="nd">@classmethod</span> -</span><span id="Column.ensure_cols-117"><a href="#Column.ensure_cols-117"><span class="linenos">117</span></a> <span class="k">def</span> <span class="nf">ensure_cols</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Column</span><span class="p">]:</span> -</span><span id="Column.ensure_cols-118"><a href="#Column.ensure_cols-118"><span class="linenos">118</span></a> <span class="k">return</span> <span class="p">[</span><span class="bp">cls</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">x</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">args</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.ensure_cols-121"><a href="#Column.ensure_cols-121"><span class="linenos">121</span></a> <span class="nd">@classmethod</span> +</span><span id="Column.ensure_cols-122"><a href="#Column.ensure_cols-122"><span class="linenos">122</span></a> <span class="k">def</span> <span class="nf">ensure_cols</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Column</span><span class="p">]:</span> +</span><span id="Column.ensure_cols-123"><a href="#Column.ensure_cols-123"><span class="linenos">123</span></a> <span class="k">return</span> <span class="p">[</span><span class="bp">cls</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">x</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">args</span><span class="p">]</span> </span></pre></div> @@ -3292,21 +3302,21 @@ and check if it matches the type of the value provided. If not then make it null <div class="decorator">@classmethod</div> <span class="def">def</span> - <span class="name">invoke_anonymous_function</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">cls</span>,</span><span class="param"> <span class="n">column</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043310280000'</span><span class="o">></span><span class="p">]</span>,</span><span class="param"> <span class="n">func_name</span><span class="p">:</span> <span class="nb">str</span>,</span><span class="param"> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043311061728'</span><span class="o">></span><span class="p">]</span></span><span class="return-annotation">) -> <span class="n"><a href="#Column">sqlglot.dataframe.sql.Column</a></span>:</span></span> + <span class="name">invoke_anonymous_function</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">cls</span>,</span><span class="param"> <span class="n">column</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135090558560'</span><span class="o">></span><span class="p">]</span>,</span><span class="param"> <span class="n">func_name</span><span class="p">:</span> <span class="nb">str</span>,</span><span class="param"> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135090631344'</span><span class="o">></span><span class="p">]</span></span><span class="return-annotation">) -> <span class="n"><a href="#Column">sqlglot.dataframe.sql.Column</a></span>:</span></span> <label class="view-source-button" for="Column.invoke_anonymous_function-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#Column.invoke_anonymous_function"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.invoke_anonymous_function-127"><a href="#Column.invoke_anonymous_function-127"><span class="linenos">127</span></a> <span class="nd">@classmethod</span> -</span><span id="Column.invoke_anonymous_function-128"><a href="#Column.invoke_anonymous_function-128"><span class="linenos">128</span></a> <span class="k">def</span> <span class="nf">invoke_anonymous_function</span><span class="p">(</span> -</span><span id="Column.invoke_anonymous_function-129"><a href="#Column.invoke_anonymous_function-129"><span class="linenos">129</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">column</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">ColumnOrLiteral</span><span class="p">],</span> <span class="n">func_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">]</span> -</span><span id="Column.invoke_anonymous_function-130"><a href="#Column.invoke_anonymous_function-130"><span class="linenos">130</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.invoke_anonymous_function-131"><a href="#Column.invoke_anonymous_function-131"><span class="linenos">131</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="p">[]</span> <span class="k">if</span> <span class="n">column</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="p">[</span><span class="bp">cls</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">column</span><span class="p">)]</span> -</span><span id="Column.invoke_anonymous_function-132"><a href="#Column.invoke_anonymous_function-132"><span class="linenos">132</span></a> <span class="n">column_args</span> <span class="o">=</span> <span class="p">[</span><span class="bp">cls</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">]</span> -</span><span id="Column.invoke_anonymous_function-133"><a href="#Column.invoke_anonymous_function-133"><span class="linenos">133</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">expression</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">columns</span> <span class="o">+</span> <span class="n">column_args</span><span class="p">]</span> -</span><span id="Column.invoke_anonymous_function-134"><a href="#Column.invoke_anonymous_function-134"><span class="linenos">134</span></a> <span class="n">new_expression</span> <span class="o">=</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="n">func_name</span><span class="o">.</span><span class="n">upper</span><span class="p">(),</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Column.invoke_anonymous_function-135"><a href="#Column.invoke_anonymous_function-135"><span class="linenos">135</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.invoke_anonymous_function-132"><a href="#Column.invoke_anonymous_function-132"><span class="linenos">132</span></a> <span class="nd">@classmethod</span> +</span><span id="Column.invoke_anonymous_function-133"><a href="#Column.invoke_anonymous_function-133"><span class="linenos">133</span></a> <span class="k">def</span> <span class="nf">invoke_anonymous_function</span><span class="p">(</span> +</span><span id="Column.invoke_anonymous_function-134"><a href="#Column.invoke_anonymous_function-134"><span class="linenos">134</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">column</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">ColumnOrLiteral</span><span class="p">],</span> <span class="n">func_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">]</span> +</span><span id="Column.invoke_anonymous_function-135"><a href="#Column.invoke_anonymous_function-135"><span class="linenos">135</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.invoke_anonymous_function-136"><a href="#Column.invoke_anonymous_function-136"><span class="linenos">136</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="p">[]</span> <span class="k">if</span> <span class="n">column</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="p">[</span><span class="bp">cls</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">column</span><span class="p">)]</span> +</span><span id="Column.invoke_anonymous_function-137"><a href="#Column.invoke_anonymous_function-137"><span class="linenos">137</span></a> <span class="n">column_args</span> <span class="o">=</span> <span class="p">[</span><span class="bp">cls</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">]</span> +</span><span id="Column.invoke_anonymous_function-138"><a href="#Column.invoke_anonymous_function-138"><span class="linenos">138</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">expression</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">columns</span> <span class="o">+</span> <span class="n">column_args</span><span class="p">]</span> +</span><span id="Column.invoke_anonymous_function-139"><a href="#Column.invoke_anonymous_function-139"><span class="linenos">139</span></a> <span class="n">new_expression</span> <span class="o">=</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="n">func_name</span><span class="o">.</span><span class="n">upper</span><span class="p">(),</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Column.invoke_anonymous_function-140"><a href="#Column.invoke_anonymous_function-140"><span class="linenos">140</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> </span></pre></div> @@ -3319,32 +3329,32 @@ and check if it matches the type of the value provided. If not then make it null <div class="decorator">@classmethod</div> <span class="def">def</span> - <span class="name">invoke_expression_over_column</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">cls</span>,</span><span class="param"> <span class="n">column</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043309080992'</span><span class="o">></span><span class="p">]</span>,</span><span class="param"> <span class="n">callable_expression</span><span class="p">:</span> <span class="n">Callable</span>,</span><span class="param"> <span class="o">**</span><span class="n">kwargs</span></span><span class="return-annotation">) -> <span class="n"><a href="#Column">sqlglot.dataframe.sql.Column</a></span>:</span></span> + <span class="name">invoke_expression_over_column</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">cls</span>,</span><span class="param"> <span class="n">column</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135090394432'</span><span class="o">></span><span class="p">]</span>,</span><span class="param"> <span class="n">callable_expression</span><span class="p">:</span> <span class="n">Callable</span>,</span><span class="param"> <span class="o">**</span><span class="n">kwargs</span></span><span class="return-annotation">) -> <span class="n"><a href="#Column">sqlglot.dataframe.sql.Column</a></span>:</span></span> <label class="view-source-button" for="Column.invoke_expression_over_column-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#Column.invoke_expression_over_column"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.invoke_expression_over_column-137"><a href="#Column.invoke_expression_over_column-137"><span class="linenos">137</span></a> <span class="nd">@classmethod</span> -</span><span id="Column.invoke_expression_over_column-138"><a href="#Column.invoke_expression_over_column-138"><span class="linenos">138</span></a> <span class="k">def</span> <span class="nf">invoke_expression_over_column</span><span class="p">(</span> -</span><span id="Column.invoke_expression_over_column-139"><a href="#Column.invoke_expression_over_column-139"><span class="linenos">139</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">column</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">ColumnOrLiteral</span><span class="p">],</span> <span class="n">callable_expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> -</span><span id="Column.invoke_expression_over_column-140"><a href="#Column.invoke_expression_over_column-140"><span class="linenos">140</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.invoke_expression_over_column-141"><a href="#Column.invoke_expression_over_column-141"><span class="linenos">141</span></a> <span class="n">ensured_column</span> <span class="o">=</span> <span class="kc">None</span> <span class="k">if</span> <span class="n">column</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="bp">cls</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">column</span><span class="p">)</span> -</span><span id="Column.invoke_expression_over_column-142"><a href="#Column.invoke_expression_over_column-142"><span class="linenos">142</span></a> <span class="n">ensure_expression_values</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Column.invoke_expression_over_column-143"><a href="#Column.invoke_expression_over_column-143"><span class="linenos">143</span></a> <span class="n">k</span><span class="p">:</span> <span class="p">[</span><span class="n">Column</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">v</span><span class="p">]</span> -</span><span id="Column.invoke_expression_over_column-144"><a href="#Column.invoke_expression_over_column-144"><span class="linenos">144</span></a> <span class="k">if</span> <span class="n">is_iterable</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> -</span><span id="Column.invoke_expression_over_column-145"><a href="#Column.invoke_expression_over_column-145"><span class="linenos">145</span></a> <span class="k">else</span> <span class="n">Column</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> -</span><span id="Column.invoke_expression_over_column-146"><a href="#Column.invoke_expression_over_column-146"><span class="linenos">146</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> -</span><span id="Column.invoke_expression_over_column-147"><a href="#Column.invoke_expression_over_column-147"><span class="linenos">147</span></a> <span class="k">if</span> <span class="n">v</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> -</span><span id="Column.invoke_expression_over_column-148"><a href="#Column.invoke_expression_over_column-148"><span class="linenos">148</span></a> <span class="p">}</span> -</span><span id="Column.invoke_expression_over_column-149"><a href="#Column.invoke_expression_over_column-149"><span class="linenos">149</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Column.invoke_expression_over_column-150"><a href="#Column.invoke_expression_over_column-150"><span class="linenos">150</span></a> <span class="n">callable_expression</span><span class="p">(</span><span class="o">**</span><span class="n">ensure_expression_values</span><span class="p">)</span> -</span><span id="Column.invoke_expression_over_column-151"><a href="#Column.invoke_expression_over_column-151"><span class="linenos">151</span></a> <span class="k">if</span> <span class="n">ensured_column</span> <span class="ow">is</span> <span class="kc">None</span> -</span><span id="Column.invoke_expression_over_column-152"><a href="#Column.invoke_expression_over_column-152"><span class="linenos">152</span></a> <span class="k">else</span> <span class="n">callable_expression</span><span class="p">(</span> -</span><span id="Column.invoke_expression_over_column-153"><a href="#Column.invoke_expression_over_column-153"><span class="linenos">153</span></a> <span class="n">this</span><span class="o">=</span><span class="n">ensured_column</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="o">**</span><span class="n">ensure_expression_values</span> -</span><span id="Column.invoke_expression_over_column-154"><a href="#Column.invoke_expression_over_column-154"><span class="linenos">154</span></a> <span class="p">)</span> -</span><span id="Column.invoke_expression_over_column-155"><a href="#Column.invoke_expression_over_column-155"><span class="linenos">155</span></a> <span class="p">)</span> -</span><span id="Column.invoke_expression_over_column-156"><a href="#Column.invoke_expression_over_column-156"><span class="linenos">156</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.invoke_expression_over_column-142"><a href="#Column.invoke_expression_over_column-142"><span class="linenos">142</span></a> <span class="nd">@classmethod</span> +</span><span id="Column.invoke_expression_over_column-143"><a href="#Column.invoke_expression_over_column-143"><span class="linenos">143</span></a> <span class="k">def</span> <span class="nf">invoke_expression_over_column</span><span class="p">(</span> +</span><span id="Column.invoke_expression_over_column-144"><a href="#Column.invoke_expression_over_column-144"><span class="linenos">144</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">column</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">ColumnOrLiteral</span><span class="p">],</span> <span class="n">callable_expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> +</span><span id="Column.invoke_expression_over_column-145"><a href="#Column.invoke_expression_over_column-145"><span class="linenos">145</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.invoke_expression_over_column-146"><a href="#Column.invoke_expression_over_column-146"><span class="linenos">146</span></a> <span class="n">ensured_column</span> <span class="o">=</span> <span class="kc">None</span> <span class="k">if</span> <span class="n">column</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="bp">cls</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">column</span><span class="p">)</span> +</span><span id="Column.invoke_expression_over_column-147"><a href="#Column.invoke_expression_over_column-147"><span class="linenos">147</span></a> <span class="n">ensure_expression_values</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Column.invoke_expression_over_column-148"><a href="#Column.invoke_expression_over_column-148"><span class="linenos">148</span></a> <span class="n">k</span><span class="p">:</span> <span class="p">[</span><span class="n">Column</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">v</span><span class="p">]</span> +</span><span id="Column.invoke_expression_over_column-149"><a href="#Column.invoke_expression_over_column-149"><span class="linenos">149</span></a> <span class="k">if</span> <span class="n">is_iterable</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> +</span><span id="Column.invoke_expression_over_column-150"><a href="#Column.invoke_expression_over_column-150"><span class="linenos">150</span></a> <span class="k">else</span> <span class="n">Column</span><span class="o">.</span><span class="n">ensure_col</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Column.invoke_expression_over_column-151"><a href="#Column.invoke_expression_over_column-151"><span class="linenos">151</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> +</span><span id="Column.invoke_expression_over_column-152"><a href="#Column.invoke_expression_over_column-152"><span class="linenos">152</span></a> <span class="k">if</span> <span class="n">v</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> +</span><span id="Column.invoke_expression_over_column-153"><a href="#Column.invoke_expression_over_column-153"><span class="linenos">153</span></a> <span class="p">}</span> +</span><span id="Column.invoke_expression_over_column-154"><a href="#Column.invoke_expression_over_column-154"><span class="linenos">154</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Column.invoke_expression_over_column-155"><a href="#Column.invoke_expression_over_column-155"><span class="linenos">155</span></a> <span class="n">callable_expression</span><span class="p">(</span><span class="o">**</span><span class="n">ensure_expression_values</span><span class="p">)</span> +</span><span id="Column.invoke_expression_over_column-156"><a href="#Column.invoke_expression_over_column-156"><span class="linenos">156</span></a> <span class="k">if</span> <span class="n">ensured_column</span> <span class="ow">is</span> <span class="kc">None</span> +</span><span id="Column.invoke_expression_over_column-157"><a href="#Column.invoke_expression_over_column-157"><span class="linenos">157</span></a> <span class="k">else</span> <span class="n">callable_expression</span><span class="p">(</span> +</span><span id="Column.invoke_expression_over_column-158"><a href="#Column.invoke_expression_over_column-158"><span class="linenos">158</span></a> <span class="n">this</span><span class="o">=</span><span class="n">ensured_column</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="o">**</span><span class="n">ensure_expression_values</span> +</span><span id="Column.invoke_expression_over_column-159"><a href="#Column.invoke_expression_over_column-159"><span class="linenos">159</span></a> <span class="p">)</span> +</span><span id="Column.invoke_expression_over_column-160"><a href="#Column.invoke_expression_over_column-160"><span class="linenos">160</span></a> <span class="p">)</span> +</span><span id="Column.invoke_expression_over_column-161"><a href="#Column.invoke_expression_over_column-161"><span class="linenos">161</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> </span></pre></div> @@ -3356,16 +3366,16 @@ and check if it matches the type of the value provided. If not then make it null <div class="attr function"> <span class="def">def</span> - <span class="name">binary_op</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="n">klass</span><span class="p">:</span> <span class="n">Callable</span>,</span><span class="param"> <span class="n">other</span><span class="p">:</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043309221248'</span><span class="o">></span>,</span><span class="param"> <span class="o">**</span><span class="n">kwargs</span></span><span class="return-annotation">) -> <span class="n"><a href="#Column">sqlglot.dataframe.sql.Column</a></span>:</span></span> + <span class="name">binary_op</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="n">klass</span><span class="p">:</span> <span class="n">Callable</span>,</span><span class="param"> <span class="n">other</span><span class="p">:</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135088576720'</span><span class="o">></span>,</span><span class="param"> <span class="o">**</span><span class="n">kwargs</span></span><span class="return-annotation">) -> <span class="n"><a href="#Column">sqlglot.dataframe.sql.Column</a></span>:</span></span> <label class="view-source-button" for="Column.binary_op-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#Column.binary_op"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.binary_op-158"><a href="#Column.binary_op-158"><span class="linenos">158</span></a> <span class="k">def</span> <span class="nf">binary_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">klass</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.binary_op-159"><a href="#Column.binary_op-159"><span class="linenos">159</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span> -</span><span id="Column.binary_op-160"><a href="#Column.binary_op-160"><span class="linenos">160</span></a> <span class="n">klass</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">column_expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">other</span><span class="p">)</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="Column.binary_op-161"><a href="#Column.binary_op-161"><span class="linenos">161</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.binary_op-163"><a href="#Column.binary_op-163"><span class="linenos">163</span></a> <span class="k">def</span> <span class="nf">binary_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">klass</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.binary_op-164"><a href="#Column.binary_op-164"><span class="linenos">164</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span> +</span><span id="Column.binary_op-165"><a href="#Column.binary_op-165"><span class="linenos">165</span></a> <span class="n">klass</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">column_expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">other</span><span class="p">)</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="Column.binary_op-166"><a href="#Column.binary_op-166"><span class="linenos">166</span></a> <span class="p">)</span> </span></pre></div> @@ -3377,16 +3387,16 @@ and check if it matches the type of the value provided. If not then make it null <div class="attr function"> <span class="def">def</span> - <span class="name">inverse_binary_op</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="n">klass</span><span class="p">:</span> <span class="n">Callable</span>,</span><span class="param"> <span class="n">other</span><span class="p">:</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043309230512'</span><span class="o">></span>,</span><span class="param"> <span class="o">**</span><span class="n">kwargs</span></span><span class="return-annotation">) -> <span class="n"><a href="#Column">sqlglot.dataframe.sql.Column</a></span>:</span></span> + <span class="name">inverse_binary_op</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="n">klass</span><span class="p">:</span> <span class="n">Callable</span>,</span><span class="param"> <span class="n">other</span><span class="p">:</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135088584400'</span><span class="o">></span>,</span><span class="param"> <span class="o">**</span><span class="n">kwargs</span></span><span class="return-annotation">) -> <span class="n"><a href="#Column">sqlglot.dataframe.sql.Column</a></span>:</span></span> <label class="view-source-button" for="Column.inverse_binary_op-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#Column.inverse_binary_op"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.inverse_binary_op-163"><a href="#Column.inverse_binary_op-163"><span class="linenos">163</span></a> <span class="k">def</span> <span class="nf">inverse_binary_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">klass</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.inverse_binary_op-164"><a href="#Column.inverse_binary_op-164"><span class="linenos">164</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span> -</span><span id="Column.inverse_binary_op-165"><a href="#Column.inverse_binary_op-165"><span class="linenos">165</span></a> <span class="n">klass</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">other</span><span class="p">)</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="Column.inverse_binary_op-166"><a href="#Column.inverse_binary_op-166"><span class="linenos">166</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.inverse_binary_op-168"><a href="#Column.inverse_binary_op-168"><span class="linenos">168</span></a> <span class="k">def</span> <span class="nf">inverse_binary_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">klass</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">ColumnOrLiteral</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.inverse_binary_op-169"><a href="#Column.inverse_binary_op-169"><span class="linenos">169</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span> +</span><span id="Column.inverse_binary_op-170"><a href="#Column.inverse_binary_op-170"><span class="linenos">170</span></a> <span class="n">klass</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">other</span><span class="p">)</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="Column.inverse_binary_op-171"><a href="#Column.inverse_binary_op-171"><span class="linenos">171</span></a> <span class="p">)</span> </span></pre></div> @@ -3404,8 +3414,8 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#Column.unary_op"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.unary_op-168"><a href="#Column.unary_op-168"><span class="linenos">168</span></a> <span class="k">def</span> <span class="nf">unary_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">klass</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.unary_op-169"><a href="#Column.unary_op-169"><span class="linenos">169</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">klass</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">column_expression</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.unary_op-173"><a href="#Column.unary_op-173"><span class="linenos">173</span></a> <span class="k">def</span> <span class="nf">unary_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">klass</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.unary_op-174"><a href="#Column.unary_op-174"><span class="linenos">174</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">klass</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">column_expression</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">))</span> </span></pre></div> @@ -3424,15 +3434,15 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#Column.ensure_literal"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.ensure_literal-187"><a href="#Column.ensure_literal-187"><span class="linenos">187</span></a> <span class="nd">@classmethod</span> -</span><span id="Column.ensure_literal-188"><a href="#Column.ensure_literal-188"><span class="linenos">188</span></a> <span class="k">def</span> <span class="nf">ensure_literal</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.ensure_literal-189"><a href="#Column.ensure_literal-189"><span class="linenos">189</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">lit</span> -</span><span id="Column.ensure_literal-190"><a href="#Column.ensure_literal-190"><span class="linenos">190</span></a> -</span><span id="Column.ensure_literal-191"><a href="#Column.ensure_literal-191"><span class="linenos">191</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="bp">cls</span><span class="p">):</span> -</span><span id="Column.ensure_literal-192"><a href="#Column.ensure_literal-192"><span class="linenos">192</span></a> <span class="n">value</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">expression</span> -</span><span id="Column.ensure_literal-193"><a href="#Column.ensure_literal-193"><span class="linenos">193</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</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="Column.ensure_literal-194"><a href="#Column.ensure_literal-194"><span class="linenos">194</span></a> <span class="k">return</span> <span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="Column.ensure_literal-195"><a href="#Column.ensure_literal-195"><span class="linenos">195</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.ensure_literal-192"><a href="#Column.ensure_literal-192"><span class="linenos">192</span></a> <span class="nd">@classmethod</span> +</span><span id="Column.ensure_literal-193"><a href="#Column.ensure_literal-193"><span class="linenos">193</span></a> <span class="k">def</span> <span class="nf">ensure_literal</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.ensure_literal-194"><a href="#Column.ensure_literal-194"><span class="linenos">194</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">lit</span> +</span><span id="Column.ensure_literal-195"><a href="#Column.ensure_literal-195"><span class="linenos">195</span></a> +</span><span id="Column.ensure_literal-196"><a href="#Column.ensure_literal-196"><span class="linenos">196</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="bp">cls</span><span class="p">):</span> +</span><span id="Column.ensure_literal-197"><a href="#Column.ensure_literal-197"><span class="linenos">197</span></a> <span class="n">value</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Column.ensure_literal-198"><a href="#Column.ensure_literal-198"><span class="linenos">198</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</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="Column.ensure_literal-199"><a href="#Column.ensure_literal-199"><span class="linenos">199</span></a> <span class="k">return</span> <span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="Column.ensure_literal-200"><a href="#Column.ensure_literal-200"><span class="linenos">200</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> </span></pre></div> @@ -3450,8 +3460,8 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#Column.copy"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.copy-197"><a href="#Column.copy-197"><span class="linenos">197</span></a> <span class="k">def</span> <span class="nf">copy</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.copy-198"><a href="#Column.copy-198"><span class="linenos">198</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">())</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.copy-202"><a href="#Column.copy-202"><span class="linenos">202</span></a> <span class="k">def</span> <span class="nf">copy</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.copy-203"><a href="#Column.copy-203"><span class="linenos">203</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">())</span> </span></pre></div> @@ -3469,10 +3479,10 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#Column.set_table_name"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.set_table_name-200"><a href="#Column.set_table_name-200"><span class="linenos">200</span></a> <span class="k">def</span> <span class="nf">set_table_name</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">table_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.set_table_name-201"><a href="#Column.set_table_name-201"><span class="linenos">201</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="k">if</span> <span class="n">copy</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span> -</span><span id="Column.set_table_name-202"><a href="#Column.set_table_name-202"><span class="linenos">202</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"table"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table_name</span><span class="p">))</span> -</span><span id="Column.set_table_name-203"><a href="#Column.set_table_name-203"><span class="linenos">203</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.set_table_name-205"><a href="#Column.set_table_name-205"><span class="linenos">205</span></a> <span class="k">def</span> <span class="nf">set_table_name</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">table_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.set_table_name-206"><a href="#Column.set_table_name-206"><span class="linenos">206</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="k">if</span> <span class="n">copy</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Column.set_table_name-207"><a href="#Column.set_table_name-207"><span class="linenos">207</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"table"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table_name</span><span class="p">))</span> +</span><span id="Column.set_table_name-208"><a href="#Column.set_table_name-208"><span class="linenos">208</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -3490,8 +3500,8 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#Column.sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.sql-205"><a href="#Column.sql-205"><span class="linenos">205</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Column.sql-206"><a href="#Column.sql-206"><span class="linenos">206</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="s2">"dialect"</span><span class="p">:</span> <span class="s2">"spark"</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">})</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.sql-210"><a href="#Column.sql-210"><span class="linenos">210</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Column.sql-211"><a href="#Column.sql-211"><span class="linenos">211</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="s2">"dialect"</span><span class="p">:</span> <span class="s2">"spark"</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">})</span> </span></pre></div> @@ -3509,9 +3519,9 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#Column.alias"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.alias-208"><a href="#Column.alias-208"><span class="linenos">208</span></a> <span class="k">def</span> <span class="nf">alias</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.alias-209"><a href="#Column.alias-209"><span class="linenos">209</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span> -</span><span id="Column.alias-210"><a href="#Column.alias-210"><span class="linenos">210</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.alias-213"><a href="#Column.alias-213"><span class="linenos">213</span></a> <span class="k">def</span> <span class="nf">alias</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.alias-214"><a href="#Column.alias-214"><span class="linenos">214</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span> +</span><span id="Column.alias-215"><a href="#Column.alias-215"><span class="linenos">215</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> </span></pre></div> @@ -3529,9 +3539,9 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#Column.asc"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.asc-212"><a href="#Column.asc-212"><span class="linenos">212</span></a> <span class="k">def</span> <span class="nf">asc</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.asc-213"><a href="#Column.asc-213"><span class="linenos">213</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Column.asc-214"><a href="#Column.asc-214"><span class="linenos">214</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.asc-217"><a href="#Column.asc-217"><span class="linenos">217</span></a> <span class="k">def</span> <span class="nf">asc</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.asc-218"><a href="#Column.asc-218"><span class="linenos">218</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Column.asc-219"><a href="#Column.asc-219"><span class="linenos">219</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> </span></pre></div> @@ -3549,9 +3559,9 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#Column.desc"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.desc-216"><a href="#Column.desc-216"><span class="linenos">216</span></a> <span class="k">def</span> <span class="nf">desc</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.desc-217"><a href="#Column.desc-217"><span class="linenos">217</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Column.desc-218"><a href="#Column.desc-218"><span class="linenos">218</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.desc-221"><a href="#Column.desc-221"><span class="linenos">221</span></a> <span class="k">def</span> <span class="nf">desc</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.desc-222"><a href="#Column.desc-222"><span class="linenos">222</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Column.desc-223"><a href="#Column.desc-223"><span class="linenos">223</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> </span></pre></div> @@ -3569,9 +3579,9 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#Column.asc_nulls_first"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.asc_nulls_first-212"><a href="#Column.asc_nulls_first-212"><span class="linenos">212</span></a> <span class="k">def</span> <span class="nf">asc</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.asc_nulls_first-213"><a href="#Column.asc_nulls_first-213"><span class="linenos">213</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Column.asc_nulls_first-214"><a href="#Column.asc_nulls_first-214"><span class="linenos">214</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.asc_nulls_first-217"><a href="#Column.asc_nulls_first-217"><span class="linenos">217</span></a> <span class="k">def</span> <span class="nf">asc</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.asc_nulls_first-218"><a href="#Column.asc_nulls_first-218"><span class="linenos">218</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Column.asc_nulls_first-219"><a href="#Column.asc_nulls_first-219"><span class="linenos">219</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> </span></pre></div> @@ -3589,9 +3599,9 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#Column.asc_nulls_last"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.asc_nulls_last-222"><a href="#Column.asc_nulls_last-222"><span class="linenos">222</span></a> <span class="k">def</span> <span class="nf">asc_nulls_last</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.asc_nulls_last-223"><a href="#Column.asc_nulls_last-223"><span class="linenos">223</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Column.asc_nulls_last-224"><a href="#Column.asc_nulls_last-224"><span class="linenos">224</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.asc_nulls_last-227"><a href="#Column.asc_nulls_last-227"><span class="linenos">227</span></a> <span class="k">def</span> <span class="nf">asc_nulls_last</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.asc_nulls_last-228"><a href="#Column.asc_nulls_last-228"><span class="linenos">228</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Column.asc_nulls_last-229"><a href="#Column.asc_nulls_last-229"><span class="linenos">229</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> </span></pre></div> @@ -3609,9 +3619,9 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#Column.desc_nulls_first"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.desc_nulls_first-226"><a href="#Column.desc_nulls_first-226"><span class="linenos">226</span></a> <span class="k">def</span> <span class="nf">desc_nulls_first</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.desc_nulls_first-227"><a href="#Column.desc_nulls_first-227"><span class="linenos">227</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Column.desc_nulls_first-228"><a href="#Column.desc_nulls_first-228"><span class="linenos">228</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.desc_nulls_first-231"><a href="#Column.desc_nulls_first-231"><span class="linenos">231</span></a> <span class="k">def</span> <span class="nf">desc_nulls_first</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.desc_nulls_first-232"><a href="#Column.desc_nulls_first-232"><span class="linenos">232</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Column.desc_nulls_first-233"><a href="#Column.desc_nulls_first-233"><span class="linenos">233</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> </span></pre></div> @@ -3629,9 +3639,9 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#Column.desc_nulls_last"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.desc_nulls_last-216"><a href="#Column.desc_nulls_last-216"><span class="linenos">216</span></a> <span class="k">def</span> <span class="nf">desc</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.desc_nulls_last-217"><a href="#Column.desc_nulls_last-217"><span class="linenos">217</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Column.desc_nulls_last-218"><a href="#Column.desc_nulls_last-218"><span class="linenos">218</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.desc_nulls_last-221"><a href="#Column.desc_nulls_last-221"><span class="linenos">221</span></a> <span class="k">def</span> <span class="nf">desc</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.desc_nulls_last-222"><a href="#Column.desc_nulls_last-222"><span class="linenos">222</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</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">column_expression</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Column.desc_nulls_last-223"><a href="#Column.desc_nulls_last-223"><span class="linenos">223</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> </span></pre></div> @@ -3649,15 +3659,15 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#Column.when"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.when-232"><a href="#Column.when-232"><span class="linenos">232</span></a> <span class="k">def</span> <span class="nf">when</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">condition</span><span class="p">:</span> <span class="n">Column</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.when-233"><a href="#Column.when-233"><span class="linenos">233</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">when</span> -</span><span id="Column.when-234"><a href="#Column.when-234"><span class="linenos">234</span></a> -</span><span id="Column.when-235"><a href="#Column.when-235"><span class="linenos">235</span></a> <span class="n">column_with_if</span> <span class="o">=</span> <span class="n">when</span><span class="p">(</span><span class="n">condition</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> -</span><span id="Column.when-236"><a href="#Column.when-236"><span class="linenos">236</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</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">Case</span><span class="p">):</span> -</span><span id="Column.when-237"><a href="#Column.when-237"><span class="linenos">237</span></a> <span class="k">return</span> <span class="n">column_with_if</span> -</span><span id="Column.when-238"><a href="#Column.when-238"><span class="linenos">238</span></a> <span class="n">new_column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Column.when-239"><a href="#Column.when-239"><span class="linenos">239</span></a> <span class="n">new_column</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">"ifs"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">column_with_if</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">"ifs"</span><span class="p">])</span> -</span><span id="Column.when-240"><a href="#Column.when-240"><span class="linenos">240</span></a> <span class="k">return</span> <span class="n">new_column</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.when-237"><a href="#Column.when-237"><span class="linenos">237</span></a> <span class="k">def</span> <span class="nf">when</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">condition</span><span class="p">:</span> <span class="n">Column</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.when-238"><a href="#Column.when-238"><span class="linenos">238</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">when</span> +</span><span id="Column.when-239"><a href="#Column.when-239"><span class="linenos">239</span></a> +</span><span id="Column.when-240"><a href="#Column.when-240"><span class="linenos">240</span></a> <span class="n">column_with_if</span> <span class="o">=</span> <span class="n">when</span><span class="p">(</span><span class="n">condition</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> +</span><span id="Column.when-241"><a href="#Column.when-241"><span class="linenos">241</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</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">Case</span><span class="p">):</span> +</span><span id="Column.when-242"><a href="#Column.when-242"><span class="linenos">242</span></a> <span class="k">return</span> <span class="n">column_with_if</span> +</span><span id="Column.when-243"><a href="#Column.when-243"><span class="linenos">243</span></a> <span class="n">new_column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Column.when-244"><a href="#Column.when-244"><span class="linenos">244</span></a> <span class="n">new_column</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">"ifs"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">column_with_if</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">"ifs"</span><span class="p">])</span> +</span><span id="Column.when-245"><a href="#Column.when-245"><span class="linenos">245</span></a> <span class="k">return</span> <span class="n">new_column</span> </span></pre></div> @@ -3675,13 +3685,13 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#Column.otherwise"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.otherwise-242"><a href="#Column.otherwise-242"><span class="linenos">242</span></a> <span class="k">def</span> <span class="nf">otherwise</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.otherwise-243"><a href="#Column.otherwise-243"><span class="linenos">243</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">lit</span> -</span><span id="Column.otherwise-244"><a href="#Column.otherwise-244"><span class="linenos">244</span></a> -</span><span id="Column.otherwise-245"><a href="#Column.otherwise-245"><span class="linenos">245</span></a> <span class="n">true_value</span> <span class="o">=</span> <span class="n">value</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="Column.otherwise-246"><a href="#Column.otherwise-246"><span class="linenos">246</span></a> <span class="n">new_column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Column.otherwise-247"><a href="#Column.otherwise-247"><span class="linenos">247</span></a> <span class="n">new_column</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"default"</span><span class="p">,</span> <span class="n">true_value</span><span class="o">.</span><span class="n">column_expression</span><span class="p">)</span> -</span><span id="Column.otherwise-248"><a href="#Column.otherwise-248"><span class="linenos">248</span></a> <span class="k">return</span> <span class="n">new_column</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.otherwise-247"><a href="#Column.otherwise-247"><span class="linenos">247</span></a> <span class="k">def</span> <span class="nf">otherwise</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.otherwise-248"><a href="#Column.otherwise-248"><span class="linenos">248</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.functions</span> <span class="kn">import</span> <span class="n">lit</span> +</span><span id="Column.otherwise-249"><a href="#Column.otherwise-249"><span class="linenos">249</span></a> +</span><span id="Column.otherwise-250"><a href="#Column.otherwise-250"><span class="linenos">250</span></a> <span class="n">true_value</span> <span class="o">=</span> <span class="n">value</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="Column.otherwise-251"><a href="#Column.otherwise-251"><span class="linenos">251</span></a> <span class="n">new_column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Column.otherwise-252"><a href="#Column.otherwise-252"><span class="linenos">252</span></a> <span class="n">new_column</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"default"</span><span class="p">,</span> <span class="n">true_value</span><span class="o">.</span><span class="n">column_expression</span><span class="p">)</span> +</span><span id="Column.otherwise-253"><a href="#Column.otherwise-253"><span class="linenos">253</span></a> <span class="k">return</span> <span class="n">new_column</span> </span></pre></div> @@ -3699,9 +3709,9 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#Column.isNull"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.isNull-250"><a href="#Column.isNull-250"><span class="linenos">250</span></a> <span class="k">def</span> <span class="nf">isNull</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.isNull-251"><a href="#Column.isNull-251"><span class="linenos">251</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">())</span> -</span><span id="Column.isNull-252"><a href="#Column.isNull-252"><span class="linenos">252</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.isNull-255"><a href="#Column.isNull-255"><span class="linenos">255</span></a> <span class="k">def</span> <span class="nf">isNull</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.isNull-256"><a href="#Column.isNull-256"><span class="linenos">256</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">())</span> +</span><span id="Column.isNull-257"><a href="#Column.isNull-257"><span class="linenos">257</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> </span></pre></div> @@ -3719,9 +3729,9 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#Column.isNotNull"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.isNotNull-254"><a href="#Column.isNotNull-254"><span class="linenos">254</span></a> <span class="k">def</span> <span class="nf">isNotNull</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.isNotNull-255"><a href="#Column.isNotNull-255"><span class="linenos">255</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Not</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">()))</span> -</span><span id="Column.isNotNull-256"><a href="#Column.isNotNull-256"><span class="linenos">256</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.isNotNull-259"><a href="#Column.isNotNull-259"><span class="linenos">259</span></a> <span class="k">def</span> <span class="nf">isNotNull</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.isNotNull-260"><a href="#Column.isNotNull-260"><span class="linenos">260</span></a> <span class="n">new_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Not</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">()))</span> +</span><span id="Column.isNotNull-261"><a href="#Column.isNotNull-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">new_expression</span><span class="p">)</span> </span></pre></div> @@ -3739,14 +3749,14 @@ and check if it matches the type of the value provided. If not then make it null </div> <a class="headerlink" href="#Column.cast"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.cast-258"><a href="#Column.cast-258"><span class="linenos">258</span></a> <span class="k">def</span> <span class="nf">cast</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataType</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">DataType</span><span class="p">]):</span> -</span><span id="Column.cast-259"><a href="#Column.cast-259"><span class="linenos">259</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Column.cast-260"><a href="#Column.cast-260"><span class="linenos">260</span></a><span class="sd"> Functionality Difference: PySpark cast accepts a datatype instance of the datatype class</span> -</span><span id="Column.cast-261"><a href="#Column.cast-261"><span class="linenos">261</span></a><span class="sd"> Sqlglot doesn't currently replicate this class so it only accepts a string</span> -</span><span id="Column.cast-262"><a href="#Column.cast-262"><span class="linenos">262</span></a><span class="sd"> """</span> -</span><span id="Column.cast-263"><a href="#Column.cast-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dataType</span><span class="p">,</span> <span class="n">DataType</span><span class="p">):</span> -</span><span id="Column.cast-264"><a href="#Column.cast-264"><span class="linenos">264</span></a> <span class="n">dataType</span> <span class="o">=</span> <span class="n">dataType</span><span class="o">.</span><span class="n">simpleString</span><span class="p">()</span> -</span><span id="Column.cast-265"><a href="#Column.cast-265"><span class="linenos">265</span></a> <span class="k">return</span> <span class="n">Column</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="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">dataType</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"spark"</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.cast-263"><a href="#Column.cast-263"><span class="linenos">263</span></a> <span class="k">def</span> <span class="nf">cast</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataType</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">DataType</span><span class="p">]):</span> +</span><span id="Column.cast-264"><a href="#Column.cast-264"><span class="linenos">264</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Column.cast-265"><a href="#Column.cast-265"><span class="linenos">265</span></a><span class="sd"> Functionality Difference: PySpark cast accepts a datatype instance of the datatype class</span> +</span><span id="Column.cast-266"><a href="#Column.cast-266"><span class="linenos">266</span></a><span class="sd"> Sqlglot doesn't currently replicate this class so it only accepts a string</span> +</span><span id="Column.cast-267"><a href="#Column.cast-267"><span class="linenos">267</span></a><span class="sd"> """</span> +</span><span id="Column.cast-268"><a href="#Column.cast-268"><span class="linenos">268</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dataType</span><span class="p">,</span> <span class="n">DataType</span><span class="p">):</span> +</span><span id="Column.cast-269"><a href="#Column.cast-269"><span class="linenos">269</span></a> <span class="n">dataType</span> <span class="o">=</span> <span class="n">dataType</span><span class="o">.</span><span class="n">simpleString</span><span class="p">()</span> +</span><span id="Column.cast-270"><a href="#Column.cast-270"><span class="linenos">270</span></a> <span class="k">return</span> <span class="n">Column</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="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> <span class="n">dataType</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"spark"</span><span class="p">))</span> </span></pre></div> @@ -3767,9 +3777,9 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#Column.startswith"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.startswith-267"><a href="#Column.startswith-267"><span class="linenos">267</span></a> <span class="k">def</span> <span class="nf">startswith</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Column</span><span class="p">])</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.startswith-268"><a href="#Column.startswith-268"><span class="linenos">268</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">value</span> -</span><span id="Column.startswith-269"><a href="#Column.startswith-269"><span class="linenos">269</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">invoke_anonymous_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s2">"STARTSWITH"</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.startswith-272"><a href="#Column.startswith-272"><span class="linenos">272</span></a> <span class="k">def</span> <span class="nf">startswith</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Column</span><span class="p">])</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.startswith-273"><a href="#Column.startswith-273"><span class="linenos">273</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">value</span> +</span><span id="Column.startswith-274"><a href="#Column.startswith-274"><span class="linenos">274</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">invoke_anonymous_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s2">"STARTSWITH"</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> </span></pre></div> @@ -3787,9 +3797,9 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#Column.endswith"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.endswith-271"><a href="#Column.endswith-271"><span class="linenos">271</span></a> <span class="k">def</span> <span class="nf">endswith</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Column</span><span class="p">])</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.endswith-272"><a href="#Column.endswith-272"><span class="linenos">272</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">value</span> -</span><span id="Column.endswith-273"><a href="#Column.endswith-273"><span class="linenos">273</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">invoke_anonymous_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s2">"ENDSWITH"</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.endswith-276"><a href="#Column.endswith-276"><span class="linenos">276</span></a> <span class="k">def</span> <span class="nf">endswith</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Column</span><span class="p">])</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.endswith-277"><a href="#Column.endswith-277"><span class="linenos">277</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">value</span> +</span><span id="Column.endswith-278"><a href="#Column.endswith-278"><span class="linenos">278</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">invoke_anonymous_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s2">"ENDSWITH"</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> </span></pre></div> @@ -3807,10 +3817,10 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#Column.rlike"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.rlike-275"><a href="#Column.rlike-275"><span class="linenos">275</span></a> <span class="k">def</span> <span class="nf">rlike</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">regexp</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.rlike-276"><a href="#Column.rlike-276"><span class="linenos">276</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">invoke_expression_over_column</span><span class="p">(</span> -</span><span id="Column.rlike-277"><a href="#Column.rlike-277"><span class="linenos">277</span></a> <span class="n">column</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="n">callable_expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">regexp</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> -</span><span id="Column.rlike-278"><a href="#Column.rlike-278"><span class="linenos">278</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.rlike-280"><a href="#Column.rlike-280"><span class="linenos">280</span></a> <span class="k">def</span> <span class="nf">rlike</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">regexp</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.rlike-281"><a href="#Column.rlike-281"><span class="linenos">281</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">invoke_expression_over_column</span><span class="p">(</span> +</span><span id="Column.rlike-282"><a href="#Column.rlike-282"><span class="linenos">282</span></a> <span class="n">column</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="n">callable_expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">regexp</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Column.rlike-283"><a href="#Column.rlike-283"><span class="linenos">283</span></a> <span class="p">)</span> </span></pre></div> @@ -3828,10 +3838,10 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#Column.like"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.like-280"><a href="#Column.like-280"><span class="linenos">280</span></a> <span class="k">def</span> <span class="nf">like</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="Column.like-281"><a href="#Column.like-281"><span class="linenos">281</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">invoke_expression_over_column</span><span class="p">(</span> -</span><span id="Column.like-282"><a href="#Column.like-282"><span class="linenos">282</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Like</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">other</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> -</span><span id="Column.like-283"><a href="#Column.like-283"><span class="linenos">283</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.like-285"><a href="#Column.like-285"><span class="linenos">285</span></a> <span class="k">def</span> <span class="nf">like</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="Column.like-286"><a href="#Column.like-286"><span class="linenos">286</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">invoke_expression_over_column</span><span class="p">(</span> +</span><span id="Column.like-287"><a href="#Column.like-287"><span class="linenos">287</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Like</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">other</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Column.like-288"><a href="#Column.like-288"><span class="linenos">288</span></a> <span class="p">)</span> </span></pre></div> @@ -3849,10 +3859,10 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#Column.ilike"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.ilike-285"><a href="#Column.ilike-285"><span class="linenos">285</span></a> <span class="k">def</span> <span class="nf">ilike</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="Column.ilike-286"><a href="#Column.ilike-286"><span class="linenos">286</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">invoke_expression_over_column</span><span class="p">(</span> -</span><span id="Column.ilike-287"><a href="#Column.ilike-287"><span class="linenos">287</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">other</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> -</span><span id="Column.ilike-288"><a href="#Column.ilike-288"><span class="linenos">288</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.ilike-290"><a href="#Column.ilike-290"><span class="linenos">290</span></a> <span class="k">def</span> <span class="nf">ilike</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="Column.ilike-291"><a href="#Column.ilike-291"><span class="linenos">291</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">invoke_expression_over_column</span><span class="p">(</span> +</span><span id="Column.ilike-292"><a href="#Column.ilike-292"><span class="linenos">292</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">other</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Column.ilike-293"><a href="#Column.ilike-293"><span class="linenos">293</span></a> <span class="p">)</span> </span></pre></div> @@ -3870,12 +3880,12 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#Column.substr"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.substr-290"><a href="#Column.substr-290"><span class="linenos">290</span></a> <span class="k">def</span> <span class="nf">substr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">startPos</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="n">Column</span><span class="p">],</span> <span class="n">length</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="n">Column</span><span class="p">])</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.substr-291"><a href="#Column.substr-291"><span class="linenos">291</span></a> <span class="n">startPos</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">startPos</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">startPos</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">startPos</span> -</span><span id="Column.substr-292"><a href="#Column.substr-292"><span class="linenos">292</span></a> <span class="n">length</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">length</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">length</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">length</span> -</span><span id="Column.substr-293"><a href="#Column.substr-293"><span class="linenos">293</span></a> <span class="k">return</span> <span class="n">Column</span><span class="o">.</span><span class="n">invoke_expression_over_column</span><span class="p">(</span> -</span><span id="Column.substr-294"><a href="#Column.substr-294"><span class="linenos">294</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Substring</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="n">startPos</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">length</span><span class="o">=</span><span class="n">length</span><span class="o">.</span><span class="n">expression</span> -</span><span id="Column.substr-295"><a href="#Column.substr-295"><span class="linenos">295</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.substr-295"><a href="#Column.substr-295"><span class="linenos">295</span></a> <span class="k">def</span> <span class="nf">substr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">startPos</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="n">Column</span><span class="p">],</span> <span class="n">length</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="n">Column</span><span class="p">])</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.substr-296"><a href="#Column.substr-296"><span class="linenos">296</span></a> <span class="n">startPos</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">startPos</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">startPos</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">startPos</span> +</span><span id="Column.substr-297"><a href="#Column.substr-297"><span class="linenos">297</span></a> <span class="n">length</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">length</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">length</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">length</span> +</span><span id="Column.substr-298"><a href="#Column.substr-298"><span class="linenos">298</span></a> <span class="k">return</span> <span class="n">Column</span><span class="o">.</span><span class="n">invoke_expression_over_column</span><span class="p">(</span> +</span><span id="Column.substr-299"><a href="#Column.substr-299"><span class="linenos">299</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Substring</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="n">startPos</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">length</span><span class="o">=</span><span class="n">length</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Column.substr-300"><a href="#Column.substr-300"><span class="linenos">300</span></a> <span class="p">)</span> </span></pre></div> @@ -3887,16 +3897,16 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> <div class="attr function"> <span class="def">def</span> - <span class="name">isin</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043309453744'</span><span class="o">></span><span class="p">,</span> <span class="n">Iterable</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043309453744'</span><span class="o">></span><span class="p">]]</span></span><span class="return-annotation">):</span></span> + <span class="name">isin</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135088834880'</span><span class="o">></span><span class="p">,</span> <span class="n">Iterable</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135088834880'</span><span class="o">></span><span class="p">]]</span></span><span class="return-annotation">):</span></span> <label class="view-source-button" for="Column.isin-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#Column.isin"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.isin-297"><a href="#Column.isin-297"><span class="linenos">297</span></a> <span class="k">def</span> <span class="nf">isin</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">]]):</span> -</span><span id="Column.isin-298"><a href="#Column.isin-298"><span class="linenos">298</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">flatten</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">cols</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">set</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">))</span> <span class="k">else</span> <span class="n">cols</span> <span class="c1"># type: ignore</span> -</span><span id="Column.isin-299"><a href="#Column.isin-299"><span class="linenos">299</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">columns</span><span class="p">]</span> -</span><span id="Column.isin-300"><a href="#Column.isin-300"><span class="linenos">300</span></a> <span class="k">return</span> <span class="n">Column</span><span class="o">.</span><span class="n">invoke_expression_over_column</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">In</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> <span class="c1"># type: ignore</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.isin-302"><a href="#Column.isin-302"><span class="linenos">302</span></a> <span class="k">def</span> <span class="nf">isin</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">]]):</span> +</span><span id="Column.isin-303"><a href="#Column.isin-303"><span class="linenos">303</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">flatten</span><span class="p">(</span><span class="n">cols</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">cols</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">set</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">))</span> <span class="k">else</span> <span class="n">cols</span> <span class="c1"># type: ignore</span> +</span><span id="Column.isin-304"><a href="#Column.isin-304"><span class="linenos">304</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">expression</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">columns</span><span class="p">]</span> +</span><span id="Column.isin-305"><a href="#Column.isin-305"><span class="linenos">305</span></a> <span class="k">return</span> <span class="n">Column</span><span class="o">.</span><span class="n">invoke_expression_over_column</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">In</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> <span class="c1"># type: ignore</span> </span></pre></div> @@ -3908,30 +3918,30 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> <div class="attr function"> <span class="def">def</span> - <span class="name">between</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="n">lowerBound</span><span class="p">:</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043309563968'</span><span class="o">></span>,</span><span class="param"> <span class="n">upperBound</span><span class="p">:</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043309589040'</span><span class="o">></span></span><span class="return-annotation">) -> <span class="n"><a href="#Column">sqlglot.dataframe.sql.Column</a></span>:</span></span> + <span class="name">between</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="n">lowerBound</span><span class="p">:</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135088905840'</span><span class="o">></span>,</span><span class="param"> <span class="n">upperBound</span><span class="p">:</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135088943936'</span><span class="o">></span></span><span class="return-annotation">) -> <span class="n"><a href="#Column">sqlglot.dataframe.sql.Column</a></span>:</span></span> <label class="view-source-button" for="Column.between-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#Column.between"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.between-302"><a href="#Column.between-302"><span class="linenos">302</span></a> <span class="k">def</span> <span class="nf">between</span><span class="p">(</span> -</span><span id="Column.between-303"><a href="#Column.between-303"><span class="linenos">303</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Column.between-304"><a href="#Column.between-304"><span class="linenos">304</span></a> <span class="n">lowerBound</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">],</span> -</span><span id="Column.between-305"><a href="#Column.between-305"><span class="linenos">305</span></a> <span class="n">upperBound</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">],</span> -</span><span id="Column.between-306"><a href="#Column.between-306"><span class="linenos">306</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.between-307"><a href="#Column.between-307"><span class="linenos">307</span></a> <span class="n">lower_bound_exp</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Column.between-308"><a href="#Column.between-308"><span class="linenos">308</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">lowerBound</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">lowerBound</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">lowerBound</span> -</span><span id="Column.between-309"><a href="#Column.between-309"><span class="linenos">309</span></a> <span class="p">)</span> -</span><span id="Column.between-310"><a href="#Column.between-310"><span class="linenos">310</span></a> <span class="n">upper_bound_exp</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Column.between-311"><a href="#Column.between-311"><span class="linenos">311</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">upperBound</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">upperBound</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">upperBound</span> -</span><span id="Column.between-312"><a href="#Column.between-312"><span class="linenos">312</span></a> <span class="p">)</span> -</span><span id="Column.between-313"><a href="#Column.between-313"><span class="linenos">313</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span> -</span><span id="Column.between-314"><a href="#Column.between-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">(</span> -</span><span id="Column.between-315"><a href="#Column.between-315"><span class="linenos">315</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> -</span><span id="Column.between-316"><a href="#Column.between-316"><span class="linenos">316</span></a> <span class="n">low</span><span class="o">=</span><span class="n">lower_bound_exp</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="Column.between-317"><a href="#Column.between-317"><span class="linenos">317</span></a> <span class="n">high</span><span class="o">=</span><span class="n">upper_bound_exp</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="Column.between-318"><a href="#Column.between-318"><span class="linenos">318</span></a> <span class="p">)</span> -</span><span id="Column.between-319"><a href="#Column.between-319"><span class="linenos">319</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.between-307"><a href="#Column.between-307"><span class="linenos">307</span></a> <span class="k">def</span> <span class="nf">between</span><span class="p">(</span> +</span><span id="Column.between-308"><a href="#Column.between-308"><span class="linenos">308</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Column.between-309"><a href="#Column.between-309"><span class="linenos">309</span></a> <span class="n">lowerBound</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">],</span> +</span><span id="Column.between-310"><a href="#Column.between-310"><span class="linenos">310</span></a> <span class="n">upperBound</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ColumnOrLiteral</span><span class="p">],</span> +</span><span id="Column.between-311"><a href="#Column.between-311"><span class="linenos">311</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.between-312"><a href="#Column.between-312"><span class="linenos">312</span></a> <span class="n">lower_bound_exp</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Column.between-313"><a href="#Column.between-313"><span class="linenos">313</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">lowerBound</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">lowerBound</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">lowerBound</span> +</span><span id="Column.between-314"><a href="#Column.between-314"><span class="linenos">314</span></a> <span class="p">)</span> +</span><span id="Column.between-315"><a href="#Column.between-315"><span class="linenos">315</span></a> <span class="n">upper_bound_exp</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Column.between-316"><a href="#Column.between-316"><span class="linenos">316</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_lit</span><span class="p">(</span><span class="n">upperBound</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">upperBound</span><span class="p">,</span> <span class="n">Column</span><span class="p">)</span> <span class="k">else</span> <span class="n">upperBound</span> +</span><span id="Column.between-317"><a href="#Column.between-317"><span class="linenos">317</span></a> <span class="p">)</span> +</span><span id="Column.between-318"><a href="#Column.between-318"><span class="linenos">318</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span> +</span><span id="Column.between-319"><a href="#Column.between-319"><span class="linenos">319</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">(</span> +</span><span id="Column.between-320"><a href="#Column.between-320"><span class="linenos">320</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">,</span> +</span><span id="Column.between-321"><a href="#Column.between-321"><span class="linenos">321</span></a> <span class="n">low</span><span class="o">=</span><span class="n">lower_bound_exp</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="Column.between-322"><a href="#Column.between-322"><span class="linenos">322</span></a> <span class="n">high</span><span class="o">=</span><span class="n">upper_bound_exp</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="Column.between-323"><a href="#Column.between-323"><span class="linenos">323</span></a> <span class="p">)</span> +</span><span id="Column.between-324"><a href="#Column.between-324"><span class="linenos">324</span></a> <span class="p">)</span> </span></pre></div> @@ -3943,16 +3953,16 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> <div class="attr function"> <span class="def">def</span> - <span class="name">over</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="n">window</span><span class="p">:</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043309646896'</span><span class="o">></span></span><span class="return-annotation">) -> <span class="n"><a href="#Column">sqlglot.dataframe.sql.Column</a></span>:</span></span> + <span class="name">over</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="n">window</span><span class="p">:</span> <span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135089001648'</span><span class="o">></span></span><span class="return-annotation">) -> <span class="n"><a href="#Column">sqlglot.dataframe.sql.Column</a></span>:</span></span> <label class="view-source-button" for="Column.over-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#Column.over"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Column.over-321"><a href="#Column.over-321"><span class="linenos">321</span></a> <span class="k">def</span> <span class="nf">over</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">window</span><span class="p">:</span> <span class="n">WindowSpec</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="Column.over-322"><a href="#Column.over-322"><span class="linenos">322</span></a> <span class="n">window_expression</span> <span class="o">=</span> <span class="n">window</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Column.over-323"><a href="#Column.over-323"><span class="linenos">323</span></a> <span class="n">window_expression</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="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">)</span> -</span><span id="Column.over-324"><a href="#Column.over-324"><span class="linenos">324</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">window_expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Column.over-326"><a href="#Column.over-326"><span class="linenos">326</span></a> <span class="k">def</span> <span class="nf">over</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">window</span><span class="p">:</span> <span class="n">WindowSpec</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="Column.over-327"><a href="#Column.over-327"><span class="linenos">327</span></a> <span class="n">window_expression</span> <span class="o">=</span> <span class="n">window</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Column.over-328"><a href="#Column.over-328"><span class="linenos">328</span></a> <span class="n">window_expression</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="bp">self</span><span class="o">.</span><span class="n">column_expression</span><span class="p">)</span> +</span><span id="Column.over-329"><a href="#Column.over-329"><span class="linenos">329</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span><span class="n">window_expression</span><span class="p">)</span> </span></pre></div> @@ -3971,32 +3981,32 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#DataFrameNaFunctions"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameNaFunctions-821"><a href="#DataFrameNaFunctions-821"><span class="linenos">821</span></a><span class="k">class</span> <span class="nc">DataFrameNaFunctions</span><span class="p">:</span> -</span><span id="DataFrameNaFunctions-822"><a href="#DataFrameNaFunctions-822"><span class="linenos">822</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">df</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">):</span> -</span><span id="DataFrameNaFunctions-823"><a href="#DataFrameNaFunctions-823"><span class="linenos">823</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">df</span> <span class="o">=</span> <span class="n">df</span> -</span><span id="DataFrameNaFunctions-824"><a href="#DataFrameNaFunctions-824"><span class="linenos">824</span></a> -</span><span id="DataFrameNaFunctions-825"><a href="#DataFrameNaFunctions-825"><span class="linenos">825</span></a> <span class="k">def</span> <span class="nf">drop</span><span class="p">(</span> -</span><span id="DataFrameNaFunctions-826"><a href="#DataFrameNaFunctions-826"><span class="linenos">826</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DataFrameNaFunctions-827"><a href="#DataFrameNaFunctions-827"><span class="linenos">827</span></a> <span class="n">how</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"any"</span><span class="p">,</span> -</span><span id="DataFrameNaFunctions-828"><a href="#DataFrameNaFunctions-828"><span class="linenos">828</span></a> <span class="n">thresh</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrameNaFunctions-829"><a href="#DataFrameNaFunctions-829"><span class="linenos">829</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrameNaFunctions-830"><a href="#DataFrameNaFunctions-830"><span class="linenos">830</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrameNaFunctions-831"><a href="#DataFrameNaFunctions-831"><span class="linenos">831</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">df</span><span class="o">.</span><span class="n">dropna</span><span class="p">(</span><span class="n">how</span><span class="o">=</span><span class="n">how</span><span class="p">,</span> <span class="n">thresh</span><span class="o">=</span><span class="n">thresh</span><span class="p">,</span> <span class="n">subset</span><span class="o">=</span><span class="n">subset</span><span class="p">)</span> -</span><span id="DataFrameNaFunctions-832"><a href="#DataFrameNaFunctions-832"><span class="linenos">832</span></a> -</span><span id="DataFrameNaFunctions-833"><a href="#DataFrameNaFunctions-833"><span class="linenos">833</span></a> <span class="k">def</span> <span class="nf">fill</span><span class="p">(</span> -</span><span id="DataFrameNaFunctions-834"><a href="#DataFrameNaFunctions-834"><span class="linenos">834</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DataFrameNaFunctions-835"><a href="#DataFrameNaFunctions-835"><span class="linenos">835</span></a> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">bool</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]],</span> -</span><span id="DataFrameNaFunctions-836"><a href="#DataFrameNaFunctions-836"><span class="linenos">836</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrameNaFunctions-837"><a href="#DataFrameNaFunctions-837"><span class="linenos">837</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrameNaFunctions-838"><a href="#DataFrameNaFunctions-838"><span class="linenos">838</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">df</span><span class="o">.</span><span class="n">fillna</span><span class="p">(</span><span class="n">value</span><span class="o">=</span><span class="n">value</span><span class="p">,</span> <span class="n">subset</span><span class="o">=</span><span class="n">subset</span><span class="p">)</span> -</span><span id="DataFrameNaFunctions-839"><a href="#DataFrameNaFunctions-839"><span class="linenos">839</span></a> -</span><span id="DataFrameNaFunctions-840"><a href="#DataFrameNaFunctions-840"><span class="linenos">840</span></a> <span class="k">def</span> <span class="nf">replace</span><span class="p">(</span> -</span><span id="DataFrameNaFunctions-841"><a href="#DataFrameNaFunctions-841"><span class="linenos">841</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DataFrameNaFunctions-842"><a href="#DataFrameNaFunctions-842"><span class="linenos">842</span></a> <span class="n">to_replace</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</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">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">],</span> -</span><span id="DataFrameNaFunctions-843"><a href="#DataFrameNaFunctions-843"><span class="linenos">843</span></a> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrameNaFunctions-844"><a href="#DataFrameNaFunctions-844"><span class="linenos">844</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrameNaFunctions-845"><a href="#DataFrameNaFunctions-845"><span class="linenos">845</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrameNaFunctions-846"><a href="#DataFrameNaFunctions-846"><span class="linenos">846</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">df</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">to_replace</span><span class="o">=</span><span class="n">to_replace</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="n">value</span><span class="p">,</span> <span class="n">subset</span><span class="o">=</span><span class="n">subset</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameNaFunctions-822"><a href="#DataFrameNaFunctions-822"><span class="linenos">822</span></a><span class="k">class</span> <span class="nc">DataFrameNaFunctions</span><span class="p">:</span> +</span><span id="DataFrameNaFunctions-823"><a href="#DataFrameNaFunctions-823"><span class="linenos">823</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">df</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">):</span> +</span><span id="DataFrameNaFunctions-824"><a href="#DataFrameNaFunctions-824"><span class="linenos">824</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">df</span> <span class="o">=</span> <span class="n">df</span> +</span><span id="DataFrameNaFunctions-825"><a href="#DataFrameNaFunctions-825"><span class="linenos">825</span></a> +</span><span id="DataFrameNaFunctions-826"><a href="#DataFrameNaFunctions-826"><span class="linenos">826</span></a> <span class="k">def</span> <span class="nf">drop</span><span class="p">(</span> +</span><span id="DataFrameNaFunctions-827"><a href="#DataFrameNaFunctions-827"><span class="linenos">827</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DataFrameNaFunctions-828"><a href="#DataFrameNaFunctions-828"><span class="linenos">828</span></a> <span class="n">how</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"any"</span><span class="p">,</span> +</span><span id="DataFrameNaFunctions-829"><a href="#DataFrameNaFunctions-829"><span class="linenos">829</span></a> <span class="n">thresh</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrameNaFunctions-830"><a href="#DataFrameNaFunctions-830"><span class="linenos">830</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrameNaFunctions-831"><a href="#DataFrameNaFunctions-831"><span class="linenos">831</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrameNaFunctions-832"><a href="#DataFrameNaFunctions-832"><span class="linenos">832</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">df</span><span class="o">.</span><span class="n">dropna</span><span class="p">(</span><span class="n">how</span><span class="o">=</span><span class="n">how</span><span class="p">,</span> <span class="n">thresh</span><span class="o">=</span><span class="n">thresh</span><span class="p">,</span> <span class="n">subset</span><span class="o">=</span><span class="n">subset</span><span class="p">)</span> +</span><span id="DataFrameNaFunctions-833"><a href="#DataFrameNaFunctions-833"><span class="linenos">833</span></a> +</span><span id="DataFrameNaFunctions-834"><a href="#DataFrameNaFunctions-834"><span class="linenos">834</span></a> <span class="k">def</span> <span class="nf">fill</span><span class="p">(</span> +</span><span id="DataFrameNaFunctions-835"><a href="#DataFrameNaFunctions-835"><span class="linenos">835</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DataFrameNaFunctions-836"><a href="#DataFrameNaFunctions-836"><span class="linenos">836</span></a> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">bool</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]],</span> +</span><span id="DataFrameNaFunctions-837"><a href="#DataFrameNaFunctions-837"><span class="linenos">837</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrameNaFunctions-838"><a href="#DataFrameNaFunctions-838"><span class="linenos">838</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrameNaFunctions-839"><a href="#DataFrameNaFunctions-839"><span class="linenos">839</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">df</span><span class="o">.</span><span class="n">fillna</span><span class="p">(</span><span class="n">value</span><span class="o">=</span><span class="n">value</span><span class="p">,</span> <span class="n">subset</span><span class="o">=</span><span class="n">subset</span><span class="p">)</span> +</span><span id="DataFrameNaFunctions-840"><a href="#DataFrameNaFunctions-840"><span class="linenos">840</span></a> +</span><span id="DataFrameNaFunctions-841"><a href="#DataFrameNaFunctions-841"><span class="linenos">841</span></a> <span class="k">def</span> <span class="nf">replace</span><span class="p">(</span> +</span><span id="DataFrameNaFunctions-842"><a href="#DataFrameNaFunctions-842"><span class="linenos">842</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DataFrameNaFunctions-843"><a href="#DataFrameNaFunctions-843"><span class="linenos">843</span></a> <span class="n">to_replace</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</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">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">],</span> +</span><span id="DataFrameNaFunctions-844"><a href="#DataFrameNaFunctions-844"><span class="linenos">844</span></a> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrameNaFunctions-845"><a href="#DataFrameNaFunctions-845"><span class="linenos">845</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrameNaFunctions-846"><a href="#DataFrameNaFunctions-846"><span class="linenos">846</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrameNaFunctions-847"><a href="#DataFrameNaFunctions-847"><span class="linenos">847</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">df</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">to_replace</span><span class="o">=</span><span class="n">to_replace</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="n">value</span><span class="p">,</span> <span class="n">subset</span><span class="o">=</span><span class="n">subset</span><span class="p">)</span> </span></pre></div> @@ -4012,8 +4022,8 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#DataFrameNaFunctions.__init__"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameNaFunctions.__init__-822"><a href="#DataFrameNaFunctions.__init__-822"><span class="linenos">822</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">df</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">):</span> -</span><span id="DataFrameNaFunctions.__init__-823"><a href="#DataFrameNaFunctions.__init__-823"><span class="linenos">823</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">df</span> <span class="o">=</span> <span class="n">df</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameNaFunctions.__init__-823"><a href="#DataFrameNaFunctions.__init__-823"><span class="linenos">823</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">df</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">):</span> +</span><span id="DataFrameNaFunctions.__init__-824"><a href="#DataFrameNaFunctions.__init__-824"><span class="linenos">824</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">df</span> <span class="o">=</span> <span class="n">df</span> </span></pre></div> @@ -4031,13 +4041,13 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#DataFrameNaFunctions.drop"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameNaFunctions.drop-825"><a href="#DataFrameNaFunctions.drop-825"><span class="linenos">825</span></a> <span class="k">def</span> <span class="nf">drop</span><span class="p">(</span> -</span><span id="DataFrameNaFunctions.drop-826"><a href="#DataFrameNaFunctions.drop-826"><span class="linenos">826</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DataFrameNaFunctions.drop-827"><a href="#DataFrameNaFunctions.drop-827"><span class="linenos">827</span></a> <span class="n">how</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"any"</span><span class="p">,</span> -</span><span id="DataFrameNaFunctions.drop-828"><a href="#DataFrameNaFunctions.drop-828"><span class="linenos">828</span></a> <span class="n">thresh</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrameNaFunctions.drop-829"><a href="#DataFrameNaFunctions.drop-829"><span class="linenos">829</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrameNaFunctions.drop-830"><a href="#DataFrameNaFunctions.drop-830"><span class="linenos">830</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrameNaFunctions.drop-831"><a href="#DataFrameNaFunctions.drop-831"><span class="linenos">831</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">df</span><span class="o">.</span><span class="n">dropna</span><span class="p">(</span><span class="n">how</span><span class="o">=</span><span class="n">how</span><span class="p">,</span> <span class="n">thresh</span><span class="o">=</span><span class="n">thresh</span><span class="p">,</span> <span class="n">subset</span><span class="o">=</span><span class="n">subset</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameNaFunctions.drop-826"><a href="#DataFrameNaFunctions.drop-826"><span class="linenos">826</span></a> <span class="k">def</span> <span class="nf">drop</span><span class="p">(</span> +</span><span id="DataFrameNaFunctions.drop-827"><a href="#DataFrameNaFunctions.drop-827"><span class="linenos">827</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DataFrameNaFunctions.drop-828"><a href="#DataFrameNaFunctions.drop-828"><span class="linenos">828</span></a> <span class="n">how</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"any"</span><span class="p">,</span> +</span><span id="DataFrameNaFunctions.drop-829"><a href="#DataFrameNaFunctions.drop-829"><span class="linenos">829</span></a> <span class="n">thresh</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrameNaFunctions.drop-830"><a href="#DataFrameNaFunctions.drop-830"><span class="linenos">830</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrameNaFunctions.drop-831"><a href="#DataFrameNaFunctions.drop-831"><span class="linenos">831</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrameNaFunctions.drop-832"><a href="#DataFrameNaFunctions.drop-832"><span class="linenos">832</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">df</span><span class="o">.</span><span class="n">dropna</span><span class="p">(</span><span class="n">how</span><span class="o">=</span><span class="n">how</span><span class="p">,</span> <span class="n">thresh</span><span class="o">=</span><span class="n">thresh</span><span class="p">,</span> <span class="n">subset</span><span class="o">=</span><span class="n">subset</span><span class="p">)</span> </span></pre></div> @@ -4055,12 +4065,12 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#DataFrameNaFunctions.fill"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameNaFunctions.fill-833"><a href="#DataFrameNaFunctions.fill-833"><span class="linenos">833</span></a> <span class="k">def</span> <span class="nf">fill</span><span class="p">(</span> -</span><span id="DataFrameNaFunctions.fill-834"><a href="#DataFrameNaFunctions.fill-834"><span class="linenos">834</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DataFrameNaFunctions.fill-835"><a href="#DataFrameNaFunctions.fill-835"><span class="linenos">835</span></a> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">bool</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]],</span> -</span><span id="DataFrameNaFunctions.fill-836"><a href="#DataFrameNaFunctions.fill-836"><span class="linenos">836</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrameNaFunctions.fill-837"><a href="#DataFrameNaFunctions.fill-837"><span class="linenos">837</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrameNaFunctions.fill-838"><a href="#DataFrameNaFunctions.fill-838"><span class="linenos">838</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">df</span><span class="o">.</span><span class="n">fillna</span><span class="p">(</span><span class="n">value</span><span class="o">=</span><span class="n">value</span><span class="p">,</span> <span class="n">subset</span><span class="o">=</span><span class="n">subset</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameNaFunctions.fill-834"><a href="#DataFrameNaFunctions.fill-834"><span class="linenos">834</span></a> <span class="k">def</span> <span class="nf">fill</span><span class="p">(</span> +</span><span id="DataFrameNaFunctions.fill-835"><a href="#DataFrameNaFunctions.fill-835"><span class="linenos">835</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DataFrameNaFunctions.fill-836"><a href="#DataFrameNaFunctions.fill-836"><span class="linenos">836</span></a> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">bool</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]],</span> +</span><span id="DataFrameNaFunctions.fill-837"><a href="#DataFrameNaFunctions.fill-837"><span class="linenos">837</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrameNaFunctions.fill-838"><a href="#DataFrameNaFunctions.fill-838"><span class="linenos">838</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrameNaFunctions.fill-839"><a href="#DataFrameNaFunctions.fill-839"><span class="linenos">839</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">df</span><span class="o">.</span><span class="n">fillna</span><span class="p">(</span><span class="n">value</span><span class="o">=</span><span class="n">value</span><span class="p">,</span> <span class="n">subset</span><span class="o">=</span><span class="n">subset</span><span class="p">)</span> </span></pre></div> @@ -4078,13 +4088,13 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#DataFrameNaFunctions.replace"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameNaFunctions.replace-840"><a href="#DataFrameNaFunctions.replace-840"><span class="linenos">840</span></a> <span class="k">def</span> <span class="nf">replace</span><span class="p">(</span> -</span><span id="DataFrameNaFunctions.replace-841"><a href="#DataFrameNaFunctions.replace-841"><span class="linenos">841</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DataFrameNaFunctions.replace-842"><a href="#DataFrameNaFunctions.replace-842"><span class="linenos">842</span></a> <span class="n">to_replace</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</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">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">],</span> -</span><span id="DataFrameNaFunctions.replace-843"><a href="#DataFrameNaFunctions.replace-843"><span class="linenos">843</span></a> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrameNaFunctions.replace-844"><a href="#DataFrameNaFunctions.replace-844"><span class="linenos">844</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrameNaFunctions.replace-845"><a href="#DataFrameNaFunctions.replace-845"><span class="linenos">845</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrameNaFunctions.replace-846"><a href="#DataFrameNaFunctions.replace-846"><span class="linenos">846</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">df</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">to_replace</span><span class="o">=</span><span class="n">to_replace</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="n">value</span><span class="p">,</span> <span class="n">subset</span><span class="o">=</span><span class="n">subset</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameNaFunctions.replace-841"><a href="#DataFrameNaFunctions.replace-841"><span class="linenos">841</span></a> <span class="k">def</span> <span class="nf">replace</span><span class="p">(</span> +</span><span id="DataFrameNaFunctions.replace-842"><a href="#DataFrameNaFunctions.replace-842"><span class="linenos">842</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DataFrameNaFunctions.replace-843"><a href="#DataFrameNaFunctions.replace-843"><span class="linenos">843</span></a> <span class="n">to_replace</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</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">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">],</span> +</span><span id="DataFrameNaFunctions.replace-844"><a href="#DataFrameNaFunctions.replace-844"><span class="linenos">844</span></a> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">bool</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrameNaFunctions.replace-845"><a href="#DataFrameNaFunctions.replace-845"><span class="linenos">845</span></a> <span class="n">subset</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrameNaFunctions.replace-846"><a href="#DataFrameNaFunctions.replace-846"><span class="linenos">846</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrameNaFunctions.replace-847"><a href="#DataFrameNaFunctions.replace-847"><span class="linenos">847</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">df</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">to_replace</span><span class="o">=</span><span class="n">to_replace</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="n">value</span><span class="p">,</span> <span class="n">subset</span><span class="o">=</span><span class="n">subset</span><span class="p">)</span> </span></pre></div> @@ -4141,7 +4151,7 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> <div class="decorator">@classmethod</div> <span class="def">def</span> - <span class="name">partitionBy</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">cls</span>,</span><span class="param"> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043310053360'</span><span class="o">></span><span class="p">,</span> <span class="n">List</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043310053360'</span><span class="o">></span><span class="p">]]</span></span><span class="return-annotation">) -> <span class="n"><a href="#WindowSpec">sqlglot.dataframe.sql.WindowSpec</a></span>:</span></span> + <span class="name">partitionBy</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">cls</span>,</span><span class="param"> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135089315008'</span><span class="o">></span><span class="p">,</span> <span class="n">List</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135089315008'</span><span class="o">></span><span class="p">]]</span></span><span class="return-annotation">) -> <span class="n"><a href="#WindowSpec">sqlglot.dataframe.sql.WindowSpec</a></span>:</span></span> <label class="view-source-button" for="Window.partitionBy-view-source"><span>View Source</span></label> @@ -4162,7 +4172,7 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> <div class="decorator">@classmethod</div> <span class="def">def</span> - <span class="name">orderBy</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">cls</span>,</span><span class="param"> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043309956208'</span><span class="o">></span><span class="p">,</span> <span class="n">List</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043309956208'</span><span class="o">></span><span class="p">]]</span></span><span class="return-annotation">) -> <span class="n"><a href="#WindowSpec">sqlglot.dataframe.sql.WindowSpec</a></span>:</span></span> + <span class="name">orderBy</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">cls</span>,</span><span class="param"> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135089098032'</span><span class="o">></span><span class="p">,</span> <span class="n">List</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135089098032'</span><span class="o">></span><span class="p">]]</span></span><span class="return-annotation">) -> <span class="n"><a href="#WindowSpec">sqlglot.dataframe.sql.WindowSpec</a></span>:</span></span> <label class="view-source-button" for="Window.orderBy-view-source"><span>View Source</span></label> @@ -4387,7 +4397,7 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> <div class="attr function"> <span class="def">def</span> - <span class="name">partitionBy</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043309879920'</span><span class="o">></span><span class="p">,</span> <span class="n">List</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043309879920'</span><span class="o">></span><span class="p">]]</span></span><span class="return-annotation">) -> <span class="n"><a href="#WindowSpec">sqlglot.dataframe.sql.WindowSpec</a></span>:</span></span> + <span class="name">partitionBy</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135089209696'</span><span class="o">></span><span class="p">,</span> <span class="n">List</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135089209696'</span><span class="o">></span><span class="p">]]</span></span><span class="return-annotation">) -> <span class="n"><a href="#WindowSpec">sqlglot.dataframe.sql.WindowSpec</a></span>:</span></span> <label class="view-source-button" for="WindowSpec.partitionBy-view-source"><span>View Source</span></label> @@ -4414,7 +4424,7 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> <div class="attr function"> <span class="def">def</span> - <span class="name">orderBy</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043309740432'</span><span class="o">></span><span class="p">,</span> <span class="n">List</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140043309740432'</span><span class="o">></span><span class="p">]]</span></span><span class="return-annotation">) -> <span class="n"><a href="#WindowSpec">sqlglot.dataframe.sql.WindowSpec</a></span>:</span></span> + <span class="name">orderBy</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="bp">self</span>,</span><span class="param"> <span class="o">*</span><span class="n">cols</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135089202912'</span><span class="o">></span><span class="p">,</span> <span class="n">List</span><span class="p">[</span><span class="o"><</span><span class="n">MagicMock</span> <span class="nb">id</span><span class="o">=</span><span class="s1">'140135089202912'</span><span class="o">></span><span class="p">]]</span></span><span class="return-annotation">) -> <span class="n"><a href="#WindowSpec">sqlglot.dataframe.sql.WindowSpec</a></span>:</span></span> <label class="view-source-button" for="WindowSpec.orderBy-view-source"><span>View Source</span></label> @@ -4506,26 +4516,23 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#DataFrameReader"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameReader-15"><a href="#DataFrameReader-15"><span class="linenos">15</span></a><span class="k">class</span> <span class="nc">DataFrameReader</span><span class="p">:</span> -</span><span id="DataFrameReader-16"><a href="#DataFrameReader-16"><span class="linenos">16</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">spark</span><span class="p">:</span> <span class="n">SparkSession</span><span class="p">):</span> -</span><span id="DataFrameReader-17"><a href="#DataFrameReader-17"><span class="linenos">17</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">spark</span> <span class="o">=</span> <span class="n">spark</span> -</span><span id="DataFrameReader-18"><a href="#DataFrameReader-18"><span class="linenos">18</span></a> -</span><span id="DataFrameReader-19"><a href="#DataFrameReader-19"><span class="linenos">19</span></a> <span class="k">def</span> <span class="nf">table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">tableName</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrameReader-20"><a href="#DataFrameReader-20"><span class="linenos">20</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.dataframe</span> <span class="kn">import</span> <span class="n">DataFrame</span> -</span><span id="DataFrameReader-21"><a href="#DataFrameReader-21"><span class="linenos">21</span></a> -</span><span id="DataFrameReader-22"><a href="#DataFrameReader-22"><span class="linenos">22</span></a> <span class="n">sqlglot</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">add_table</span><span class="p">(</span><span class="n">tableName</span><span class="p">)</span> -</span><span id="DataFrameReader-23"><a href="#DataFrameReader-23"><span class="linenos">23</span></a> -</span><span id="DataFrameReader-24"><a href="#DataFrameReader-24"><span class="linenos">24</span></a> <span class="k">return</span> <span class="n">DataFrame</span><span class="p">(</span> -</span><span id="DataFrameReader-25"><a href="#DataFrameReader-25"><span class="linenos">25</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">spark</span><span class="p">,</span> -</span><span id="DataFrameReader-26"><a href="#DataFrameReader-26"><span class="linenos">26</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">()</span> -</span><span id="DataFrameReader-27"><a href="#DataFrameReader-27"><span class="linenos">27</span></a> <span class="o">.</span><span class="n">from_</span><span class="p">(</span><span class="n">tableName</span><span class="p">)</span> -</span><span id="DataFrameReader-28"><a href="#DataFrameReader-28"><span class="linenos">28</span></a> <span class="o">.</span><span class="n">select</span><span class="p">(</span> -</span><span id="DataFrameReader-29"><a href="#DataFrameReader-29"><span class="linenos">29</span></a> <span class="o">*</span><span class="p">(</span> -</span><span id="DataFrameReader-30"><a href="#DataFrameReader-30"><span class="linenos">30</span></a> <span class="n">column</span> <span class="k">if</span> <span class="n">should_identify</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s1">'"</span><span class="si">{</span><span class="n">column</span><span class="si">}</span><span class="s1">"'</span> -</span><span id="DataFrameReader-31"><a href="#DataFrameReader-31"><span class="linenos">31</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">column_names</span><span class="p">(</span><span class="n">tableName</span><span class="p">)</span> -</span><span id="DataFrameReader-32"><a href="#DataFrameReader-32"><span class="linenos">32</span></a> <span class="p">)</span> -</span><span id="DataFrameReader-33"><a href="#DataFrameReader-33"><span class="linenos">33</span></a> <span class="p">),</span> -</span><span id="DataFrameReader-34"><a href="#DataFrameReader-34"><span class="linenos">34</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameReader-16"><a href="#DataFrameReader-16"><span class="linenos">16</span></a><span class="k">class</span> <span class="nc">DataFrameReader</span><span class="p">:</span> +</span><span id="DataFrameReader-17"><a href="#DataFrameReader-17"><span class="linenos">17</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">spark</span><span class="p">:</span> <span class="n">SparkSession</span><span class="p">):</span> +</span><span id="DataFrameReader-18"><a href="#DataFrameReader-18"><span class="linenos">18</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">spark</span> <span class="o">=</span> <span class="n">spark</span> +</span><span id="DataFrameReader-19"><a href="#DataFrameReader-19"><span class="linenos">19</span></a> +</span><span id="DataFrameReader-20"><a href="#DataFrameReader-20"><span class="linenos">20</span></a> <span class="k">def</span> <span class="nf">table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">tableName</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrameReader-21"><a href="#DataFrameReader-21"><span class="linenos">21</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.dataframe</span> <span class="kn">import</span> <span class="n">DataFrame</span> +</span><span id="DataFrameReader-22"><a href="#DataFrameReader-22"><span class="linenos">22</span></a> +</span><span id="DataFrameReader-23"><a href="#DataFrameReader-23"><span class="linenos">23</span></a> <span class="n">sqlglot</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">add_table</span><span class="p">(</span><span class="n">tableName</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"spark"</span><span class="p">)</span> +</span><span id="DataFrameReader-24"><a href="#DataFrameReader-24"><span class="linenos">24</span></a> +</span><span id="DataFrameReader-25"><a href="#DataFrameReader-25"><span class="linenos">25</span></a> <span class="k">return</span> <span class="n">DataFrame</span><span class="p">(</span> +</span><span id="DataFrameReader-26"><a href="#DataFrameReader-26"><span class="linenos">26</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">spark</span><span class="p">,</span> +</span><span id="DataFrameReader-27"><a href="#DataFrameReader-27"><span class="linenos">27</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">()</span> +</span><span id="DataFrameReader-28"><a href="#DataFrameReader-28"><span class="linenos">28</span></a> <span class="o">.</span><span class="n">from_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">to_table</span><span class="p">(</span><span class="n">tableName</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"spark"</span><span class="p">)</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">Spark</span><span class="o">.</span><span class="n">normalize_identifier</span><span class="p">))</span> +</span><span id="DataFrameReader-29"><a href="#DataFrameReader-29"><span class="linenos">29</span></a> <span class="o">.</span><span class="n">select</span><span class="p">(</span> +</span><span id="DataFrameReader-30"><a href="#DataFrameReader-30"><span class="linenos">30</span></a> <span class="o">*</span><span class="p">(</span><span class="n">column</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">column_names</span><span class="p">(</span><span class="n">tableName</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"spark"</span><span class="p">))</span> +</span><span id="DataFrameReader-31"><a href="#DataFrameReader-31"><span class="linenos">31</span></a> <span class="p">),</span> +</span><span id="DataFrameReader-32"><a href="#DataFrameReader-32"><span class="linenos">32</span></a> <span class="p">)</span> </span></pre></div> @@ -4541,8 +4548,8 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#DataFrameReader.__init__"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameReader.__init__-16"><a href="#DataFrameReader.__init__-16"><span class="linenos">16</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">spark</span><span class="p">:</span> <span class="n">SparkSession</span><span class="p">):</span> -</span><span id="DataFrameReader.__init__-17"><a href="#DataFrameReader.__init__-17"><span class="linenos">17</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">spark</span> <span class="o">=</span> <span class="n">spark</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameReader.__init__-17"><a href="#DataFrameReader.__init__-17"><span class="linenos">17</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">spark</span><span class="p">:</span> <span class="n">SparkSession</span><span class="p">):</span> +</span><span id="DataFrameReader.__init__-18"><a href="#DataFrameReader.__init__-18"><span class="linenos">18</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">spark</span> <span class="o">=</span> <span class="n">spark</span> </span></pre></div> @@ -4560,22 +4567,19 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#DataFrameReader.table"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameReader.table-19"><a href="#DataFrameReader.table-19"><span class="linenos">19</span></a> <span class="k">def</span> <span class="nf">table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">tableName</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> -</span><span id="DataFrameReader.table-20"><a href="#DataFrameReader.table-20"><span class="linenos">20</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.dataframe</span> <span class="kn">import</span> <span class="n">DataFrame</span> -</span><span id="DataFrameReader.table-21"><a href="#DataFrameReader.table-21"><span class="linenos">21</span></a> -</span><span id="DataFrameReader.table-22"><a href="#DataFrameReader.table-22"><span class="linenos">22</span></a> <span class="n">sqlglot</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">add_table</span><span class="p">(</span><span class="n">tableName</span><span class="p">)</span> -</span><span id="DataFrameReader.table-23"><a href="#DataFrameReader.table-23"><span class="linenos">23</span></a> -</span><span id="DataFrameReader.table-24"><a href="#DataFrameReader.table-24"><span class="linenos">24</span></a> <span class="k">return</span> <span class="n">DataFrame</span><span class="p">(</span> -</span><span id="DataFrameReader.table-25"><a href="#DataFrameReader.table-25"><span class="linenos">25</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">spark</span><span class="p">,</span> -</span><span id="DataFrameReader.table-26"><a href="#DataFrameReader.table-26"><span class="linenos">26</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">()</span> -</span><span id="DataFrameReader.table-27"><a href="#DataFrameReader.table-27"><span class="linenos">27</span></a> <span class="o">.</span><span class="n">from_</span><span class="p">(</span><span class="n">tableName</span><span class="p">)</span> -</span><span id="DataFrameReader.table-28"><a href="#DataFrameReader.table-28"><span class="linenos">28</span></a> <span class="o">.</span><span class="n">select</span><span class="p">(</span> -</span><span id="DataFrameReader.table-29"><a href="#DataFrameReader.table-29"><span class="linenos">29</span></a> <span class="o">*</span><span class="p">(</span> -</span><span id="DataFrameReader.table-30"><a href="#DataFrameReader.table-30"><span class="linenos">30</span></a> <span class="n">column</span> <span class="k">if</span> <span class="n">should_identify</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s1">'"</span><span class="si">{</span><span class="n">column</span><span class="si">}</span><span class="s1">"'</span> -</span><span id="DataFrameReader.table-31"><a href="#DataFrameReader.table-31"><span class="linenos">31</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">column_names</span><span class="p">(</span><span class="n">tableName</span><span class="p">)</span> -</span><span id="DataFrameReader.table-32"><a href="#DataFrameReader.table-32"><span class="linenos">32</span></a> <span class="p">)</span> -</span><span id="DataFrameReader.table-33"><a href="#DataFrameReader.table-33"><span class="linenos">33</span></a> <span class="p">),</span> -</span><span id="DataFrameReader.table-34"><a href="#DataFrameReader.table-34"><span class="linenos">34</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameReader.table-20"><a href="#DataFrameReader.table-20"><span class="linenos">20</span></a> <span class="k">def</span> <span class="nf">table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">tableName</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrame</span><span class="p">:</span> +</span><span id="DataFrameReader.table-21"><a href="#DataFrameReader.table-21"><span class="linenos">21</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dataframe.sql.dataframe</span> <span class="kn">import</span> <span class="n">DataFrame</span> +</span><span id="DataFrameReader.table-22"><a href="#DataFrameReader.table-22"><span class="linenos">22</span></a> +</span><span id="DataFrameReader.table-23"><a href="#DataFrameReader.table-23"><span class="linenos">23</span></a> <span class="n">sqlglot</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">add_table</span><span class="p">(</span><span class="n">tableName</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"spark"</span><span class="p">)</span> +</span><span id="DataFrameReader.table-24"><a href="#DataFrameReader.table-24"><span class="linenos">24</span></a> +</span><span id="DataFrameReader.table-25"><a href="#DataFrameReader.table-25"><span class="linenos">25</span></a> <span class="k">return</span> <span class="n">DataFrame</span><span class="p">(</span> +</span><span id="DataFrameReader.table-26"><a href="#DataFrameReader.table-26"><span class="linenos">26</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">spark</span><span class="p">,</span> +</span><span id="DataFrameReader.table-27"><a href="#DataFrameReader.table-27"><span class="linenos">27</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">()</span> +</span><span id="DataFrameReader.table-28"><a href="#DataFrameReader.table-28"><span class="linenos">28</span></a> <span class="o">.</span><span class="n">from_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">to_table</span><span class="p">(</span><span class="n">tableName</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"spark"</span><span class="p">)</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">Spark</span><span class="o">.</span><span class="n">normalize_identifier</span><span class="p">))</span> +</span><span id="DataFrameReader.table-29"><a href="#DataFrameReader.table-29"><span class="linenos">29</span></a> <span class="o">.</span><span class="n">select</span><span class="p">(</span> +</span><span id="DataFrameReader.table-30"><a href="#DataFrameReader.table-30"><span class="linenos">30</span></a> <span class="o">*</span><span class="p">(</span><span class="n">column</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">column_names</span><span class="p">(</span><span class="n">tableName</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"spark"</span><span class="p">))</span> +</span><span id="DataFrameReader.table-31"><a href="#DataFrameReader.table-31"><span class="linenos">31</span></a> <span class="p">),</span> +</span><span id="DataFrameReader.table-32"><a href="#DataFrameReader.table-32"><span class="linenos">32</span></a> <span class="p">)</span> </span></pre></div> @@ -4594,68 +4598,68 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#DataFrameWriter"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameWriter-37"><a href="#DataFrameWriter-37"><span class="linenos">37</span></a><span class="k">class</span> <span class="nc">DataFrameWriter</span><span class="p">:</span> -</span><span id="DataFrameWriter-38"><a href="#DataFrameWriter-38"><span class="linenos">38</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> -</span><span id="DataFrameWriter-39"><a href="#DataFrameWriter-39"><span class="linenos">39</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DataFrameWriter-40"><a href="#DataFrameWriter-40"><span class="linenos">40</span></a> <span class="n">df</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> -</span><span id="DataFrameWriter-41"><a href="#DataFrameWriter-41"><span class="linenos">41</span></a> <span class="n">spark</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">SparkSession</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrameWriter-42"><a href="#DataFrameWriter-42"><span class="linenos">42</span></a> <span class="n">mode</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="DataFrameWriter-43"><a href="#DataFrameWriter-43"><span class="linenos">43</span></a> <span class="n">by_name</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="DataFrameWriter-44"><a href="#DataFrameWriter-44"><span class="linenos">44</span></a> <span class="p">):</span> -</span><span id="DataFrameWriter-45"><a href="#DataFrameWriter-45"><span class="linenos">45</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_df</span> <span class="o">=</span> <span class="n">df</span> -</span><span id="DataFrameWriter-46"><a href="#DataFrameWriter-46"><span class="linenos">46</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_spark</span> <span class="o">=</span> <span class="n">spark</span> <span class="ow">or</span> <span class="n">df</span><span class="o">.</span><span class="n">spark</span> -</span><span id="DataFrameWriter-47"><a href="#DataFrameWriter-47"><span class="linenos">47</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_mode</span> <span class="o">=</span> <span class="n">mode</span> -</span><span id="DataFrameWriter-48"><a href="#DataFrameWriter-48"><span class="linenos">48</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_by_name</span> <span class="o">=</span> <span class="n">by_name</span> -</span><span id="DataFrameWriter-49"><a href="#DataFrameWriter-49"><span class="linenos">49</span></a> -</span><span id="DataFrameWriter-50"><a href="#DataFrameWriter-50"><span class="linenos">50</span></a> <span class="k">def</span> <span class="nf">copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrameWriter</span><span class="p">:</span> -</span><span id="DataFrameWriter-51"><a href="#DataFrameWriter-51"><span class="linenos">51</span></a> <span class="k">return</span> <span class="n">DataFrameWriter</span><span class="p">(</span> -</span><span id="DataFrameWriter-52"><a href="#DataFrameWriter-52"><span class="linenos">52</span></a> <span class="o">**</span><span class="p">{</span> -</span><span id="DataFrameWriter-53"><a href="#DataFrameWriter-53"><span class="linenos">53</span></a> <span class="n">k</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span> <span class="k">if</span> <span class="n">k</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"_"</span><span class="p">)</span> <span class="k">else</span> <span class="n">k</span><span class="p">:</span> <span class="n">v</span> -</span><span id="DataFrameWriter-54"><a href="#DataFrameWriter-54"><span class="linenos">54</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">object_to_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> -</span><span id="DataFrameWriter-55"><a href="#DataFrameWriter-55"><span class="linenos">55</span></a> <span class="p">}</span> -</span><span id="DataFrameWriter-56"><a href="#DataFrameWriter-56"><span class="linenos">56</span></a> <span class="p">)</span> -</span><span id="DataFrameWriter-57"><a href="#DataFrameWriter-57"><span class="linenos">57</span></a> -</span><span id="DataFrameWriter-58"><a href="#DataFrameWriter-58"><span class="linenos">58</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</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="DataFrameWriter-59"><a href="#DataFrameWriter-59"><span class="linenos">59</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_df</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="DataFrameWriter-60"><a href="#DataFrameWriter-60"><span class="linenos">60</span></a> -</span><span id="DataFrameWriter-61"><a href="#DataFrameWriter-61"><span class="linenos">61</span></a> <span class="k">def</span> <span class="nf">mode</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">saveMode</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="n">DataFrameWriter</span><span class="p">:</span> -</span><span id="DataFrameWriter-62"><a href="#DataFrameWriter-62"><span class="linenos">62</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">_mode</span><span class="o">=</span><span class="n">saveMode</span><span class="p">)</span> -</span><span id="DataFrameWriter-63"><a href="#DataFrameWriter-63"><span class="linenos">63</span></a> -</span><span id="DataFrameWriter-64"><a href="#DataFrameWriter-64"><span class="linenos">64</span></a> <span class="nd">@property</span> -</span><span id="DataFrameWriter-65"><a href="#DataFrameWriter-65"><span class="linenos">65</span></a> <span class="k">def</span> <span class="nf">byName</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="DataFrameWriter-66"><a href="#DataFrameWriter-66"><span class="linenos">66</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">by_name</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="DataFrameWriter-67"><a href="#DataFrameWriter-67"><span class="linenos">67</span></a> -</span><span id="DataFrameWriter-68"><a href="#DataFrameWriter-68"><span class="linenos">68</span></a> <span class="k">def</span> <span class="nf">insertInto</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">tableName</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">overwrite</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrameWriter</span><span class="p">:</span> -</span><span id="DataFrameWriter-69"><a href="#DataFrameWriter-69"><span class="linenos">69</span></a> <span class="n">output_expression_container</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">(</span> -</span><span id="DataFrameWriter-70"><a href="#DataFrameWriter-70"><span class="linenos">70</span></a> <span class="o">**</span><span class="p">{</span> -</span><span id="DataFrameWriter-71"><a href="#DataFrameWriter-71"><span class="linenos">71</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_table</span><span class="p">(</span><span class="n">tableName</span><span class="p">),</span> -</span><span id="DataFrameWriter-72"><a href="#DataFrameWriter-72"><span class="linenos">72</span></a> <span class="s2">"overwrite"</span><span class="p">:</span> <span class="n">overwrite</span><span class="p">,</span> -</span><span id="DataFrameWriter-73"><a href="#DataFrameWriter-73"><span class="linenos">73</span></a> <span class="p">}</span> -</span><span id="DataFrameWriter-74"><a href="#DataFrameWriter-74"><span class="linenos">74</span></a> <span class="p">)</span> -</span><span id="DataFrameWriter-75"><a href="#DataFrameWriter-75"><span class="linenos">75</span></a> <span class="n">df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_df</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">output_expression_container</span><span class="o">=</span><span class="n">output_expression_container</span><span class="p">)</span> -</span><span id="DataFrameWriter-76"><a href="#DataFrameWriter-76"><span class="linenos">76</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_by_name</span><span class="p">:</span> -</span><span id="DataFrameWriter-77"><a href="#DataFrameWriter-77"><span class="linenos">77</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">column_names</span><span class="p">(</span><span class="n">tableName</span><span class="p">,</span> <span class="n">only_visible</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="DataFrameWriter-78"><a href="#DataFrameWriter-78"><span class="linenos">78</span></a> <span class="n">df</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">columns</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameWriter-35"><a href="#DataFrameWriter-35"><span class="linenos">35</span></a><span class="k">class</span> <span class="nc">DataFrameWriter</span><span class="p">:</span> +</span><span id="DataFrameWriter-36"><a href="#DataFrameWriter-36"><span class="linenos">36</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> +</span><span id="DataFrameWriter-37"><a href="#DataFrameWriter-37"><span class="linenos">37</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DataFrameWriter-38"><a href="#DataFrameWriter-38"><span class="linenos">38</span></a> <span class="n">df</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> +</span><span id="DataFrameWriter-39"><a href="#DataFrameWriter-39"><span class="linenos">39</span></a> <span class="n">spark</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">SparkSession</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrameWriter-40"><a href="#DataFrameWriter-40"><span class="linenos">40</span></a> <span class="n">mode</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="DataFrameWriter-41"><a href="#DataFrameWriter-41"><span class="linenos">41</span></a> <span class="n">by_name</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="DataFrameWriter-42"><a href="#DataFrameWriter-42"><span class="linenos">42</span></a> <span class="p">):</span> +</span><span id="DataFrameWriter-43"><a href="#DataFrameWriter-43"><span class="linenos">43</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_df</span> <span class="o">=</span> <span class="n">df</span> +</span><span id="DataFrameWriter-44"><a href="#DataFrameWriter-44"><span class="linenos">44</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_spark</span> <span class="o">=</span> <span class="n">spark</span> <span class="ow">or</span> <span class="n">df</span><span class="o">.</span><span class="n">spark</span> +</span><span id="DataFrameWriter-45"><a href="#DataFrameWriter-45"><span class="linenos">45</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_mode</span> <span class="o">=</span> <span class="n">mode</span> +</span><span id="DataFrameWriter-46"><a href="#DataFrameWriter-46"><span class="linenos">46</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_by_name</span> <span class="o">=</span> <span class="n">by_name</span> +</span><span id="DataFrameWriter-47"><a href="#DataFrameWriter-47"><span class="linenos">47</span></a> +</span><span id="DataFrameWriter-48"><a href="#DataFrameWriter-48"><span class="linenos">48</span></a> <span class="k">def</span> <span class="nf">copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrameWriter</span><span class="p">:</span> +</span><span id="DataFrameWriter-49"><a href="#DataFrameWriter-49"><span class="linenos">49</span></a> <span class="k">return</span> <span class="n">DataFrameWriter</span><span class="p">(</span> +</span><span id="DataFrameWriter-50"><a href="#DataFrameWriter-50"><span class="linenos">50</span></a> <span class="o">**</span><span class="p">{</span> +</span><span id="DataFrameWriter-51"><a href="#DataFrameWriter-51"><span class="linenos">51</span></a> <span class="n">k</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span> <span class="k">if</span> <span class="n">k</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"_"</span><span class="p">)</span> <span class="k">else</span> <span class="n">k</span><span class="p">:</span> <span class="n">v</span> +</span><span id="DataFrameWriter-52"><a href="#DataFrameWriter-52"><span class="linenos">52</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">object_to_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> +</span><span id="DataFrameWriter-53"><a href="#DataFrameWriter-53"><span class="linenos">53</span></a> <span class="p">}</span> +</span><span id="DataFrameWriter-54"><a href="#DataFrameWriter-54"><span class="linenos">54</span></a> <span class="p">)</span> +</span><span id="DataFrameWriter-55"><a href="#DataFrameWriter-55"><span class="linenos">55</span></a> +</span><span id="DataFrameWriter-56"><a href="#DataFrameWriter-56"><span class="linenos">56</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</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="DataFrameWriter-57"><a href="#DataFrameWriter-57"><span class="linenos">57</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_df</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="DataFrameWriter-58"><a href="#DataFrameWriter-58"><span class="linenos">58</span></a> +</span><span id="DataFrameWriter-59"><a href="#DataFrameWriter-59"><span class="linenos">59</span></a> <span class="k">def</span> <span class="nf">mode</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">saveMode</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="n">DataFrameWriter</span><span class="p">:</span> +</span><span id="DataFrameWriter-60"><a href="#DataFrameWriter-60"><span class="linenos">60</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">_mode</span><span class="o">=</span><span class="n">saveMode</span><span class="p">)</span> +</span><span id="DataFrameWriter-61"><a href="#DataFrameWriter-61"><span class="linenos">61</span></a> +</span><span id="DataFrameWriter-62"><a href="#DataFrameWriter-62"><span class="linenos">62</span></a> <span class="nd">@property</span> +</span><span id="DataFrameWriter-63"><a href="#DataFrameWriter-63"><span class="linenos">63</span></a> <span class="k">def</span> <span class="nf">byName</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="DataFrameWriter-64"><a href="#DataFrameWriter-64"><span class="linenos">64</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">by_name</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="DataFrameWriter-65"><a href="#DataFrameWriter-65"><span class="linenos">65</span></a> +</span><span id="DataFrameWriter-66"><a href="#DataFrameWriter-66"><span class="linenos">66</span></a> <span class="k">def</span> <span class="nf">insertInto</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">tableName</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">overwrite</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrameWriter</span><span class="p">:</span> +</span><span id="DataFrameWriter-67"><a href="#DataFrameWriter-67"><span class="linenos">67</span></a> <span class="n">output_expression_container</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">(</span> +</span><span id="DataFrameWriter-68"><a href="#DataFrameWriter-68"><span class="linenos">68</span></a> <span class="o">**</span><span class="p">{</span> +</span><span id="DataFrameWriter-69"><a href="#DataFrameWriter-69"><span class="linenos">69</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_table</span><span class="p">(</span><span class="n">tableName</span><span class="p">),</span> +</span><span id="DataFrameWriter-70"><a href="#DataFrameWriter-70"><span class="linenos">70</span></a> <span class="s2">"overwrite"</span><span class="p">:</span> <span class="n">overwrite</span><span class="p">,</span> +</span><span id="DataFrameWriter-71"><a href="#DataFrameWriter-71"><span class="linenos">71</span></a> <span class="p">}</span> +</span><span id="DataFrameWriter-72"><a href="#DataFrameWriter-72"><span class="linenos">72</span></a> <span class="p">)</span> +</span><span id="DataFrameWriter-73"><a href="#DataFrameWriter-73"><span class="linenos">73</span></a> <span class="n">df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_df</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">output_expression_container</span><span class="o">=</span><span class="n">output_expression_container</span><span class="p">)</span> +</span><span id="DataFrameWriter-74"><a href="#DataFrameWriter-74"><span class="linenos">74</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_by_name</span><span class="p">:</span> +</span><span id="DataFrameWriter-75"><a href="#DataFrameWriter-75"><span class="linenos">75</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">column_names</span><span class="p">(</span><span class="n">tableName</span><span class="p">,</span> <span class="n">only_visible</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"spark"</span><span class="p">)</span> +</span><span id="DataFrameWriter-76"><a href="#DataFrameWriter-76"><span class="linenos">76</span></a> <span class="n">df</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">columns</span><span class="p">)</span> +</span><span id="DataFrameWriter-77"><a href="#DataFrameWriter-77"><span class="linenos">77</span></a> +</span><span id="DataFrameWriter-78"><a href="#DataFrameWriter-78"><span class="linenos">78</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">_df</span><span class="o">=</span><span class="n">df</span><span class="p">)</span> </span><span id="DataFrameWriter-79"><a href="#DataFrameWriter-79"><span class="linenos">79</span></a> -</span><span id="DataFrameWriter-80"><a href="#DataFrameWriter-80"><span class="linenos">80</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">_df</span><span class="o">=</span><span class="n">df</span><span class="p">)</span> -</span><span id="DataFrameWriter-81"><a href="#DataFrameWriter-81"><span class="linenos">81</span></a> -</span><span id="DataFrameWriter-82"><a href="#DataFrameWriter-82"><span class="linenos">82</span></a> <span class="k">def</span> <span class="nf">saveAsTable</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="nb">format</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">mode</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="DataFrameWriter-83"><a href="#DataFrameWriter-83"><span class="linenos">83</span></a> <span class="k">if</span> <span class="nb">format</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="DataFrameWriter-84"><a href="#DataFrameWriter-84"><span class="linenos">84</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s2">"Providing Format in the save as table is not supported"</span><span class="p">)</span> -</span><span id="DataFrameWriter-85"><a href="#DataFrameWriter-85"><span class="linenos">85</span></a> <span class="n">exists</span><span class="p">,</span> <span class="n">replace</span><span class="p">,</span> <span class="n">mode</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="n">mode</span> <span class="ow">or</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_mode</span><span class="p">)</span> -</span><span id="DataFrameWriter-86"><a href="#DataFrameWriter-86"><span class="linenos">86</span></a> <span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s2">"append"</span><span class="p">:</span> -</span><span id="DataFrameWriter-87"><a href="#DataFrameWriter-87"><span class="linenos">87</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">insertInto</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> -</span><span id="DataFrameWriter-88"><a href="#DataFrameWriter-88"><span class="linenos">88</span></a> <span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s2">"ignore"</span><span class="p">:</span> -</span><span id="DataFrameWriter-89"><a href="#DataFrameWriter-89"><span class="linenos">89</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="DataFrameWriter-90"><a href="#DataFrameWriter-90"><span class="linenos">90</span></a> <span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s2">"overwrite"</span><span class="p">:</span> -</span><span id="DataFrameWriter-91"><a href="#DataFrameWriter-91"><span class="linenos">91</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="DataFrameWriter-92"><a href="#DataFrameWriter-92"><span class="linenos">92</span></a> <span class="n">output_expression_container</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">(</span> -</span><span id="DataFrameWriter-93"><a href="#DataFrameWriter-93"><span class="linenos">93</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">to_table</span><span class="p">(</span><span class="n">name</span><span class="p">),</span> -</span><span id="DataFrameWriter-94"><a href="#DataFrameWriter-94"><span class="linenos">94</span></a> <span class="n">kind</span><span class="o">=</span><span class="s2">"TABLE"</span><span class="p">,</span> -</span><span id="DataFrameWriter-95"><a href="#DataFrameWriter-95"><span class="linenos">95</span></a> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span><span class="p">,</span> -</span><span id="DataFrameWriter-96"><a href="#DataFrameWriter-96"><span class="linenos">96</span></a> <span class="n">replace</span><span class="o">=</span><span class="n">replace</span><span class="p">,</span> -</span><span id="DataFrameWriter-97"><a href="#DataFrameWriter-97"><span class="linenos">97</span></a> <span class="p">)</span> -</span><span id="DataFrameWriter-98"><a href="#DataFrameWriter-98"><span class="linenos">98</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">_df</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_df</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">output_expression_container</span><span class="o">=</span><span class="n">output_expression_container</span><span class="p">))</span> +</span><span id="DataFrameWriter-80"><a href="#DataFrameWriter-80"><span class="linenos">80</span></a> <span class="k">def</span> <span class="nf">saveAsTable</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="nb">format</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">mode</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="DataFrameWriter-81"><a href="#DataFrameWriter-81"><span class="linenos">81</span></a> <span class="k">if</span> <span class="nb">format</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="DataFrameWriter-82"><a href="#DataFrameWriter-82"><span class="linenos">82</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s2">"Providing Format in the save as table is not supported"</span><span class="p">)</span> +</span><span id="DataFrameWriter-83"><a href="#DataFrameWriter-83"><span class="linenos">83</span></a> <span class="n">exists</span><span class="p">,</span> <span class="n">replace</span><span class="p">,</span> <span class="n">mode</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="n">mode</span> <span class="ow">or</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_mode</span><span class="p">)</span> +</span><span id="DataFrameWriter-84"><a href="#DataFrameWriter-84"><span class="linenos">84</span></a> <span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s2">"append"</span><span class="p">:</span> +</span><span id="DataFrameWriter-85"><a href="#DataFrameWriter-85"><span class="linenos">85</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">insertInto</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> +</span><span id="DataFrameWriter-86"><a href="#DataFrameWriter-86"><span class="linenos">86</span></a> <span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s2">"ignore"</span><span class="p">:</span> +</span><span id="DataFrameWriter-87"><a href="#DataFrameWriter-87"><span class="linenos">87</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="DataFrameWriter-88"><a href="#DataFrameWriter-88"><span class="linenos">88</span></a> <span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s2">"overwrite"</span><span class="p">:</span> +</span><span id="DataFrameWriter-89"><a href="#DataFrameWriter-89"><span class="linenos">89</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="DataFrameWriter-90"><a href="#DataFrameWriter-90"><span class="linenos">90</span></a> <span class="n">output_expression_container</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">(</span> +</span><span id="DataFrameWriter-91"><a href="#DataFrameWriter-91"><span class="linenos">91</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">to_table</span><span class="p">(</span><span class="n">name</span><span class="p">),</span> +</span><span id="DataFrameWriter-92"><a href="#DataFrameWriter-92"><span class="linenos">92</span></a> <span class="n">kind</span><span class="o">=</span><span class="s2">"TABLE"</span><span class="p">,</span> +</span><span id="DataFrameWriter-93"><a href="#DataFrameWriter-93"><span class="linenos">93</span></a> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span><span class="p">,</span> +</span><span id="DataFrameWriter-94"><a href="#DataFrameWriter-94"><span class="linenos">94</span></a> <span class="n">replace</span><span class="o">=</span><span class="n">replace</span><span class="p">,</span> +</span><span id="DataFrameWriter-95"><a href="#DataFrameWriter-95"><span class="linenos">95</span></a> <span class="p">)</span> +</span><span id="DataFrameWriter-96"><a href="#DataFrameWriter-96"><span class="linenos">96</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">_df</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_df</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">output_expression_container</span><span class="o">=</span><span class="n">output_expression_container</span><span class="p">))</span> </span></pre></div> @@ -4671,17 +4675,17 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#DataFrameWriter.__init__"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameWriter.__init__-38"><a href="#DataFrameWriter.__init__-38"><span class="linenos">38</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> -</span><span id="DataFrameWriter.__init__-39"><a href="#DataFrameWriter.__init__-39"><span class="linenos">39</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="DataFrameWriter.__init__-40"><a href="#DataFrameWriter.__init__-40"><span class="linenos">40</span></a> <span class="n">df</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> -</span><span id="DataFrameWriter.__init__-41"><a href="#DataFrameWriter.__init__-41"><span class="linenos">41</span></a> <span class="n">spark</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">SparkSession</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="DataFrameWriter.__init__-42"><a href="#DataFrameWriter.__init__-42"><span class="linenos">42</span></a> <span class="n">mode</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="DataFrameWriter.__init__-43"><a href="#DataFrameWriter.__init__-43"><span class="linenos">43</span></a> <span class="n">by_name</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="DataFrameWriter.__init__-44"><a href="#DataFrameWriter.__init__-44"><span class="linenos">44</span></a> <span class="p">):</span> -</span><span id="DataFrameWriter.__init__-45"><a href="#DataFrameWriter.__init__-45"><span class="linenos">45</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_df</span> <span class="o">=</span> <span class="n">df</span> -</span><span id="DataFrameWriter.__init__-46"><a href="#DataFrameWriter.__init__-46"><span class="linenos">46</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_spark</span> <span class="o">=</span> <span class="n">spark</span> <span class="ow">or</span> <span class="n">df</span><span class="o">.</span><span class="n">spark</span> -</span><span id="DataFrameWriter.__init__-47"><a href="#DataFrameWriter.__init__-47"><span class="linenos">47</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_mode</span> <span class="o">=</span> <span class="n">mode</span> -</span><span id="DataFrameWriter.__init__-48"><a href="#DataFrameWriter.__init__-48"><span class="linenos">48</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_by_name</span> <span class="o">=</span> <span class="n">by_name</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameWriter.__init__-36"><a href="#DataFrameWriter.__init__-36"><span class="linenos">36</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> +</span><span id="DataFrameWriter.__init__-37"><a href="#DataFrameWriter.__init__-37"><span class="linenos">37</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="DataFrameWriter.__init__-38"><a href="#DataFrameWriter.__init__-38"><span class="linenos">38</span></a> <span class="n">df</span><span class="p">:</span> <span class="n">DataFrame</span><span class="p">,</span> +</span><span id="DataFrameWriter.__init__-39"><a href="#DataFrameWriter.__init__-39"><span class="linenos">39</span></a> <span class="n">spark</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">SparkSession</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="DataFrameWriter.__init__-40"><a href="#DataFrameWriter.__init__-40"><span class="linenos">40</span></a> <span class="n">mode</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="DataFrameWriter.__init__-41"><a href="#DataFrameWriter.__init__-41"><span class="linenos">41</span></a> <span class="n">by_name</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="DataFrameWriter.__init__-42"><a href="#DataFrameWriter.__init__-42"><span class="linenos">42</span></a> <span class="p">):</span> +</span><span id="DataFrameWriter.__init__-43"><a href="#DataFrameWriter.__init__-43"><span class="linenos">43</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_df</span> <span class="o">=</span> <span class="n">df</span> +</span><span id="DataFrameWriter.__init__-44"><a href="#DataFrameWriter.__init__-44"><span class="linenos">44</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_spark</span> <span class="o">=</span> <span class="n">spark</span> <span class="ow">or</span> <span class="n">df</span><span class="o">.</span><span class="n">spark</span> +</span><span id="DataFrameWriter.__init__-45"><a href="#DataFrameWriter.__init__-45"><span class="linenos">45</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_mode</span> <span class="o">=</span> <span class="n">mode</span> +</span><span id="DataFrameWriter.__init__-46"><a href="#DataFrameWriter.__init__-46"><span class="linenos">46</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_by_name</span> <span class="o">=</span> <span class="n">by_name</span> </span></pre></div> @@ -4699,13 +4703,13 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#DataFrameWriter.copy"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameWriter.copy-50"><a href="#DataFrameWriter.copy-50"><span class="linenos">50</span></a> <span class="k">def</span> <span class="nf">copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrameWriter</span><span class="p">:</span> -</span><span id="DataFrameWriter.copy-51"><a href="#DataFrameWriter.copy-51"><span class="linenos">51</span></a> <span class="k">return</span> <span class="n">DataFrameWriter</span><span class="p">(</span> -</span><span id="DataFrameWriter.copy-52"><a href="#DataFrameWriter.copy-52"><span class="linenos">52</span></a> <span class="o">**</span><span class="p">{</span> -</span><span id="DataFrameWriter.copy-53"><a href="#DataFrameWriter.copy-53"><span class="linenos">53</span></a> <span class="n">k</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span> <span class="k">if</span> <span class="n">k</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"_"</span><span class="p">)</span> <span class="k">else</span> <span class="n">k</span><span class="p">:</span> <span class="n">v</span> -</span><span id="DataFrameWriter.copy-54"><a href="#DataFrameWriter.copy-54"><span class="linenos">54</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">object_to_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> -</span><span id="DataFrameWriter.copy-55"><a href="#DataFrameWriter.copy-55"><span class="linenos">55</span></a> <span class="p">}</span> -</span><span id="DataFrameWriter.copy-56"><a href="#DataFrameWriter.copy-56"><span class="linenos">56</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameWriter.copy-48"><a href="#DataFrameWriter.copy-48"><span class="linenos">48</span></a> <span class="k">def</span> <span class="nf">copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrameWriter</span><span class="p">:</span> +</span><span id="DataFrameWriter.copy-49"><a href="#DataFrameWriter.copy-49"><span class="linenos">49</span></a> <span class="k">return</span> <span class="n">DataFrameWriter</span><span class="p">(</span> +</span><span id="DataFrameWriter.copy-50"><a href="#DataFrameWriter.copy-50"><span class="linenos">50</span></a> <span class="o">**</span><span class="p">{</span> +</span><span id="DataFrameWriter.copy-51"><a href="#DataFrameWriter.copy-51"><span class="linenos">51</span></a> <span class="n">k</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span> <span class="k">if</span> <span class="n">k</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"_"</span><span class="p">)</span> <span class="k">else</span> <span class="n">k</span><span class="p">:</span> <span class="n">v</span> +</span><span id="DataFrameWriter.copy-52"><a href="#DataFrameWriter.copy-52"><span class="linenos">52</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">object_to_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> +</span><span id="DataFrameWriter.copy-53"><a href="#DataFrameWriter.copy-53"><span class="linenos">53</span></a> <span class="p">}</span> +</span><span id="DataFrameWriter.copy-54"><a href="#DataFrameWriter.copy-54"><span class="linenos">54</span></a> <span class="p">)</span> </span></pre></div> @@ -4723,8 +4727,8 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#DataFrameWriter.sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameWriter.sql-58"><a href="#DataFrameWriter.sql-58"><span class="linenos">58</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</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="DataFrameWriter.sql-59"><a href="#DataFrameWriter.sql-59"><span class="linenos">59</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_df</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameWriter.sql-56"><a href="#DataFrameWriter.sql-56"><span class="linenos">56</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</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="DataFrameWriter.sql-57"><a href="#DataFrameWriter.sql-57"><span class="linenos">57</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_df</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> </span></pre></div> @@ -4742,8 +4746,8 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#DataFrameWriter.mode"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameWriter.mode-61"><a href="#DataFrameWriter.mode-61"><span class="linenos">61</span></a> <span class="k">def</span> <span class="nf">mode</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">saveMode</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="n">DataFrameWriter</span><span class="p">:</span> -</span><span id="DataFrameWriter.mode-62"><a href="#DataFrameWriter.mode-62"><span class="linenos">62</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">_mode</span><span class="o">=</span><span class="n">saveMode</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameWriter.mode-59"><a href="#DataFrameWriter.mode-59"><span class="linenos">59</span></a> <span class="k">def</span> <span class="nf">mode</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">saveMode</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="n">DataFrameWriter</span><span class="p">:</span> +</span><span id="DataFrameWriter.mode-60"><a href="#DataFrameWriter.mode-60"><span class="linenos">60</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">_mode</span><span class="o">=</span><span class="n">saveMode</span><span class="p">)</span> </span></pre></div> @@ -4761,19 +4765,19 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#DataFrameWriter.insertInto"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameWriter.insertInto-68"><a href="#DataFrameWriter.insertInto-68"><span class="linenos">68</span></a> <span class="k">def</span> <span class="nf">insertInto</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">tableName</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">overwrite</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrameWriter</span><span class="p">:</span> -</span><span id="DataFrameWriter.insertInto-69"><a href="#DataFrameWriter.insertInto-69"><span class="linenos">69</span></a> <span class="n">output_expression_container</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">(</span> -</span><span id="DataFrameWriter.insertInto-70"><a href="#DataFrameWriter.insertInto-70"><span class="linenos">70</span></a> <span class="o">**</span><span class="p">{</span> -</span><span id="DataFrameWriter.insertInto-71"><a href="#DataFrameWriter.insertInto-71"><span class="linenos">71</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_table</span><span class="p">(</span><span class="n">tableName</span><span class="p">),</span> -</span><span id="DataFrameWriter.insertInto-72"><a href="#DataFrameWriter.insertInto-72"><span class="linenos">72</span></a> <span class="s2">"overwrite"</span><span class="p">:</span> <span class="n">overwrite</span><span class="p">,</span> -</span><span id="DataFrameWriter.insertInto-73"><a href="#DataFrameWriter.insertInto-73"><span class="linenos">73</span></a> <span class="p">}</span> -</span><span id="DataFrameWriter.insertInto-74"><a href="#DataFrameWriter.insertInto-74"><span class="linenos">74</span></a> <span class="p">)</span> -</span><span id="DataFrameWriter.insertInto-75"><a href="#DataFrameWriter.insertInto-75"><span class="linenos">75</span></a> <span class="n">df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_df</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">output_expression_container</span><span class="o">=</span><span class="n">output_expression_container</span><span class="p">)</span> -</span><span id="DataFrameWriter.insertInto-76"><a href="#DataFrameWriter.insertInto-76"><span class="linenos">76</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_by_name</span><span class="p">:</span> -</span><span id="DataFrameWriter.insertInto-77"><a href="#DataFrameWriter.insertInto-77"><span class="linenos">77</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">column_names</span><span class="p">(</span><span class="n">tableName</span><span class="p">,</span> <span class="n">only_visible</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="DataFrameWriter.insertInto-78"><a href="#DataFrameWriter.insertInto-78"><span class="linenos">78</span></a> <span class="n">df</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">columns</span><span class="p">)</span> -</span><span id="DataFrameWriter.insertInto-79"><a href="#DataFrameWriter.insertInto-79"><span class="linenos">79</span></a> -</span><span id="DataFrameWriter.insertInto-80"><a href="#DataFrameWriter.insertInto-80"><span class="linenos">80</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">_df</span><span class="o">=</span><span class="n">df</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameWriter.insertInto-66"><a href="#DataFrameWriter.insertInto-66"><span class="linenos">66</span></a> <span class="k">def</span> <span class="nf">insertInto</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">tableName</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">overwrite</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataFrameWriter</span><span class="p">:</span> +</span><span id="DataFrameWriter.insertInto-67"><a href="#DataFrameWriter.insertInto-67"><span class="linenos">67</span></a> <span class="n">output_expression_container</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">(</span> +</span><span id="DataFrameWriter.insertInto-68"><a href="#DataFrameWriter.insertInto-68"><span class="linenos">68</span></a> <span class="o">**</span><span class="p">{</span> +</span><span id="DataFrameWriter.insertInto-69"><a href="#DataFrameWriter.insertInto-69"><span class="linenos">69</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_table</span><span class="p">(</span><span class="n">tableName</span><span class="p">),</span> +</span><span id="DataFrameWriter.insertInto-70"><a href="#DataFrameWriter.insertInto-70"><span class="linenos">70</span></a> <span class="s2">"overwrite"</span><span class="p">:</span> <span class="n">overwrite</span><span class="p">,</span> +</span><span id="DataFrameWriter.insertInto-71"><a href="#DataFrameWriter.insertInto-71"><span class="linenos">71</span></a> <span class="p">}</span> +</span><span id="DataFrameWriter.insertInto-72"><a href="#DataFrameWriter.insertInto-72"><span class="linenos">72</span></a> <span class="p">)</span> +</span><span id="DataFrameWriter.insertInto-73"><a href="#DataFrameWriter.insertInto-73"><span class="linenos">73</span></a> <span class="n">df</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_df</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">output_expression_container</span><span class="o">=</span><span class="n">output_expression_container</span><span class="p">)</span> +</span><span id="DataFrameWriter.insertInto-74"><a href="#DataFrameWriter.insertInto-74"><span class="linenos">74</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_by_name</span><span class="p">:</span> +</span><span id="DataFrameWriter.insertInto-75"><a href="#DataFrameWriter.insertInto-75"><span class="linenos">75</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">column_names</span><span class="p">(</span><span class="n">tableName</span><span class="p">,</span> <span class="n">only_visible</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="s2">"spark"</span><span class="p">)</span> +</span><span id="DataFrameWriter.insertInto-76"><a href="#DataFrameWriter.insertInto-76"><span class="linenos">76</span></a> <span class="n">df</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">_convert_leaf_to_cte</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">columns</span><span class="p">)</span> +</span><span id="DataFrameWriter.insertInto-77"><a href="#DataFrameWriter.insertInto-77"><span class="linenos">77</span></a> +</span><span id="DataFrameWriter.insertInto-78"><a href="#DataFrameWriter.insertInto-78"><span class="linenos">78</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">_df</span><span class="o">=</span><span class="n">df</span><span class="p">)</span> </span></pre></div> @@ -4791,23 +4795,23 @@ Sqlglot doesn't currently replicate this class so it only accepts a string</p> </div> <a class="headerlink" href="#DataFrameWriter.saveAsTable"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameWriter.saveAsTable-82"><a href="#DataFrameWriter.saveAsTable-82"><span class="linenos">82</span></a> <span class="k">def</span> <span class="nf">saveAsTable</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="nb">format</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">mode</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="DataFrameWriter.saveAsTable-83"><a href="#DataFrameWriter.saveAsTable-83"><span class="linenos">83</span></a> <span class="k">if</span> <span class="nb">format</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="DataFrameWriter.saveAsTable-84"><a href="#DataFrameWriter.saveAsTable-84"><span class="linenos">84</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s2">"Providing Format in the save as table is not supported"</span><span class="p">)</span> -</span><span id="DataFrameWriter.saveAsTable-85"><a href="#DataFrameWriter.saveAsTable-85"><span class="linenos">85</span></a> <span class="n">exists</span><span class="p">,</span> <span class="n">replace</span><span class="p">,</span> <span class="n">mode</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="n">mode</span> <span class="ow">or</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_mode</span><span class="p">)</span> -</span><span id="DataFrameWriter.saveAsTable-86"><a href="#DataFrameWriter.saveAsTable-86"><span class="linenos">86</span></a> <span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s2">"append"</span><span class="p">:</span> -</span><span id="DataFrameWriter.saveAsTable-87"><a href="#DataFrameWriter.saveAsTable-87"><span class="linenos">87</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">insertInto</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> -</span><span id="DataFrameWriter.saveAsTable-88"><a href="#DataFrameWriter.saveAsTable-88"><span class="linenos">88</span></a> <span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s2">"ignore"</span><span class="p">:</span> -</span><span id="DataFrameWriter.saveAsTable-89"><a href="#DataFrameWriter.saveAsTable-89"><span class="linenos">89</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="DataFrameWriter.saveAsTable-90"><a href="#DataFrameWriter.saveAsTable-90"><span class="linenos">90</span></a> <span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s2">"overwrite"</span><span class="p">:</span> -</span><span id="DataFrameWriter.saveAsTable-91"><a href="#DataFrameWriter.saveAsTable-91"><span class="linenos">91</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="DataFrameWriter.saveAsTable-92"><a href="#DataFrameWriter.saveAsTable-92"><span class="linenos">92</span></a> <span class="n">output_expression_container</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">(</span> -</span><span id="DataFrameWriter.saveAsTable-93"><a href="#DataFrameWriter.saveAsTable-93"><span class="linenos">93</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">to_table</span><span class="p">(</span><span class="n">name</span><span class="p">),</span> -</span><span id="DataFrameWriter.saveAsTable-94"><a href="#DataFrameWriter.saveAsTable-94"><span class="linenos">94</span></a> <span class="n">kind</span><span class="o">=</span><span class="s2">"TABLE"</span><span class="p">,</span> -</span><span id="DataFrameWriter.saveAsTable-95"><a href="#DataFrameWriter.saveAsTable-95"><span class="linenos">95</span></a> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span><span class="p">,</span> -</span><span id="DataFrameWriter.saveAsTable-96"><a href="#DataFrameWriter.saveAsTable-96"><span class="linenos">96</span></a> <span class="n">replace</span><span class="o">=</span><span class="n">replace</span><span class="p">,</span> -</span><span id="DataFrameWriter.saveAsTable-97"><a href="#DataFrameWriter.saveAsTable-97"><span class="linenos">97</span></a> <span class="p">)</span> -</span><span id="DataFrameWriter.saveAsTable-98"><a href="#DataFrameWriter.saveAsTable-98"><span class="linenos">98</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">_df</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_df</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">output_expression_container</span><span class="o">=</span><span class="n">output_expression_container</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataFrameWriter.saveAsTable-80"><a href="#DataFrameWriter.saveAsTable-80"><span class="linenos">80</span></a> <span class="k">def</span> <span class="nf">saveAsTable</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="nb">format</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">mode</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="DataFrameWriter.saveAsTable-81"><a href="#DataFrameWriter.saveAsTable-81"><span class="linenos">81</span></a> <span class="k">if</span> <span class="nb">format</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="DataFrameWriter.saveAsTable-82"><a href="#DataFrameWriter.saveAsTable-82"><span class="linenos">82</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s2">"Providing Format in the save as table is not supported"</span><span class="p">)</span> +</span><span id="DataFrameWriter.saveAsTable-83"><a href="#DataFrameWriter.saveAsTable-83"><span class="linenos">83</span></a> <span class="n">exists</span><span class="p">,</span> <span class="n">replace</span><span class="p">,</span> <span class="n">mode</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="n">mode</span> <span class="ow">or</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_mode</span><span class="p">)</span> +</span><span id="DataFrameWriter.saveAsTable-84"><a href="#DataFrameWriter.saveAsTable-84"><span class="linenos">84</span></a> <span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s2">"append"</span><span class="p">:</span> +</span><span id="DataFrameWriter.saveAsTable-85"><a href="#DataFrameWriter.saveAsTable-85"><span class="linenos">85</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">insertInto</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> +</span><span id="DataFrameWriter.saveAsTable-86"><a href="#DataFrameWriter.saveAsTable-86"><span class="linenos">86</span></a> <span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s2">"ignore"</span><span class="p">:</span> +</span><span id="DataFrameWriter.saveAsTable-87"><a href="#DataFrameWriter.saveAsTable-87"><span class="linenos">87</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="DataFrameWriter.saveAsTable-88"><a href="#DataFrameWriter.saveAsTable-88"><span class="linenos">88</span></a> <span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s2">"overwrite"</span><span class="p">:</span> +</span><span id="DataFrameWriter.saveAsTable-89"><a href="#DataFrameWriter.saveAsTable-89"><span class="linenos">89</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="DataFrameWriter.saveAsTable-90"><a href="#DataFrameWriter.saveAsTable-90"><span class="linenos">90</span></a> <span class="n">output_expression_container</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">(</span> +</span><span id="DataFrameWriter.saveAsTable-91"><a href="#DataFrameWriter.saveAsTable-91"><span class="linenos">91</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">to_table</span><span class="p">(</span><span class="n">name</span><span class="p">),</span> +</span><span id="DataFrameWriter.saveAsTable-92"><a href="#DataFrameWriter.saveAsTable-92"><span class="linenos">92</span></a> <span class="n">kind</span><span class="o">=</span><span class="s2">"TABLE"</span><span class="p">,</span> +</span><span id="DataFrameWriter.saveAsTable-93"><a href="#DataFrameWriter.saveAsTable-93"><span class="linenos">93</span></a> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span><span class="p">,</span> +</span><span id="DataFrameWriter.saveAsTable-94"><a href="#DataFrameWriter.saveAsTable-94"><span class="linenos">94</span></a> <span class="n">replace</span><span class="o">=</span><span class="n">replace</span><span class="p">,</span> +</span><span id="DataFrameWriter.saveAsTable-95"><a href="#DataFrameWriter.saveAsTable-95"><span class="linenos">95</span></a> <span class="p">)</span> +</span><span id="DataFrameWriter.saveAsTable-96"><a href="#DataFrameWriter.saveAsTable-96"><span class="linenos">96</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">_df</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_df</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">output_expression_container</span><span class="o">=</span><span class="n">output_expression_container</span><span class="p">))</span> </span></pre></div> diff --git a/docs/sqlglot/dialects/bigquery.html b/docs/sqlglot/dialects/bigquery.html index 7edabe1..c4957b8 100644 --- a/docs/sqlglot/dialects/bigquery.html +++ b/docs/sqlglot/dialects/bigquery.html @@ -34,6 +34,9 @@ <a class="class" href="#BigQuery">BigQuery</a> <ul class="memberlist"> <li> + <a class="function" href="#BigQuery.normalize_identifier">normalize_identifier</a> + </li> + <li> <a class="class" href="#BigQuery.Tokenizer">BigQuery.Tokenizer</a> <ul class="memberlist"> </ul> @@ -72,6 +75,9 @@ <li> <a class="function" href="#BigQuery.Generator.with_properties">with_properties</a> </li> + <li> + <a class="function" href="#BigQuery.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -107,391 +113,409 @@ </span><span id="L-4"><a href="#L-4"><span class="linenos"> 4</span></a><span class="kn">import</span> <span class="nn">typing</span> <span class="k">as</span> <span class="nn">t</span> </span><span id="L-5"><a href="#L-5"><span class="linenos"> 5</span></a> </span><span id="L-6"><a href="#L-6"><span class="linenos"> 6</span></a><span class="kn">from</span> <span class="nn">sqlglot</span> <span class="kn">import</span> <span class="n">exp</span><span class="p">,</span> <span class="n">generator</span><span class="p">,</span> <span class="n">parser</span><span class="p">,</span> <span class="n">tokens</span><span class="p">,</span> <span class="n">transforms</span> -</span><span id="L-7"><a href="#L-7"><span class="linenos"> 7</span></a><span class="kn">from</span> <span class="nn">sqlglot.dialects.dialect</span> <span class="kn">import</span> <span class="p">(</span> -</span><span id="L-8"><a href="#L-8"><span class="linenos"> 8</span></a> <span class="n">Dialect</span><span class="p">,</span> -</span><span id="L-9"><a href="#L-9"><span class="linenos"> 9</span></a> <span class="n">datestrtodate_sql</span><span class="p">,</span> -</span><span id="L-10"><a href="#L-10"><span class="linenos"> 10</span></a> <span class="n">format_time_lambda</span><span class="p">,</span> -</span><span id="L-11"><a href="#L-11"><span class="linenos"> 11</span></a> <span class="n">inline_array_sql</span><span class="p">,</span> -</span><span id="L-12"><a href="#L-12"><span class="linenos"> 12</span></a> <span class="n">max_or_greatest</span><span class="p">,</span> -</span><span id="L-13"><a href="#L-13"><span class="linenos"> 13</span></a> <span class="n">min_or_least</span><span class="p">,</span> -</span><span id="L-14"><a href="#L-14"><span class="linenos"> 14</span></a> <span class="n">no_ilike_sql</span><span class="p">,</span> -</span><span id="L-15"><a href="#L-15"><span class="linenos"> 15</span></a> <span class="n">parse_date_delta_with_interval</span><span class="p">,</span> -</span><span id="L-16"><a href="#L-16"><span class="linenos"> 16</span></a> <span class="n">rename_func</span><span class="p">,</span> -</span><span id="L-17"><a href="#L-17"><span class="linenos"> 17</span></a> <span class="n">timestrtotime_sql</span><span class="p">,</span> -</span><span id="L-18"><a href="#L-18"><span class="linenos"> 18</span></a> <span class="n">ts_or_ds_to_date_sql</span><span class="p">,</span> -</span><span id="L-19"><a href="#L-19"><span class="linenos"> 19</span></a><span class="p">)</span> -</span><span id="L-20"><a href="#L-20"><span class="linenos"> 20</span></a><span class="kn">from</span> <span class="nn">sqlglot.helper</span> <span class="kn">import</span> <span class="n">seq_get</span><span class="p">,</span> <span class="n">split_num_words</span> -</span><span id="L-21"><a href="#L-21"><span class="linenos"> 21</span></a><span class="kn">from</span> <span class="nn">sqlglot.tokens</span> <span class="kn">import</span> <span class="n">TokenType</span> -</span><span id="L-22"><a href="#L-22"><span class="linenos"> 22</span></a> +</span><span id="L-7"><a href="#L-7"><span class="linenos"> 7</span></a><span class="kn">from</span> <span class="nn">sqlglot._typing</span> <span class="kn">import</span> <span class="n">E</span> +</span><span id="L-8"><a href="#L-8"><span class="linenos"> 8</span></a><span class="kn">from</span> <span class="nn">sqlglot.dialects.dialect</span> <span class="kn">import</span> <span class="p">(</span> +</span><span id="L-9"><a href="#L-9"><span class="linenos"> 9</span></a> <span class="n">Dialect</span><span class="p">,</span> +</span><span id="L-10"><a href="#L-10"><span class="linenos"> 10</span></a> <span class="n">datestrtodate_sql</span><span class="p">,</span> +</span><span id="L-11"><a href="#L-11"><span class="linenos"> 11</span></a> <span class="n">format_time_lambda</span><span class="p">,</span> +</span><span id="L-12"><a href="#L-12"><span class="linenos"> 12</span></a> <span class="n">inline_array_sql</span><span class="p">,</span> +</span><span id="L-13"><a href="#L-13"><span class="linenos"> 13</span></a> <span class="n">max_or_greatest</span><span class="p">,</span> +</span><span id="L-14"><a href="#L-14"><span class="linenos"> 14</span></a> <span class="n">min_or_least</span><span class="p">,</span> +</span><span id="L-15"><a href="#L-15"><span class="linenos"> 15</span></a> <span class="n">no_ilike_sql</span><span class="p">,</span> +</span><span id="L-16"><a href="#L-16"><span class="linenos"> 16</span></a> <span class="n">parse_date_delta_with_interval</span><span class="p">,</span> +</span><span id="L-17"><a href="#L-17"><span class="linenos"> 17</span></a> <span class="n">rename_func</span><span class="p">,</span> +</span><span id="L-18"><a href="#L-18"><span class="linenos"> 18</span></a> <span class="n">timestrtotime_sql</span><span class="p">,</span> +</span><span id="L-19"><a href="#L-19"><span class="linenos"> 19</span></a> <span class="n">ts_or_ds_to_date_sql</span><span class="p">,</span> +</span><span id="L-20"><a href="#L-20"><span class="linenos"> 20</span></a><span class="p">)</span> +</span><span id="L-21"><a href="#L-21"><span class="linenos"> 21</span></a><span class="kn">from</span> <span class="nn">sqlglot.helper</span> <span class="kn">import</span> <span class="n">seq_get</span><span class="p">,</span> <span class="n">split_num_words</span> +</span><span id="L-22"><a href="#L-22"><span class="linenos"> 22</span></a><span class="kn">from</span> <span class="nn">sqlglot.tokens</span> <span class="kn">import</span> <span class="n">TokenType</span> </span><span id="L-23"><a href="#L-23"><span class="linenos"> 23</span></a> -</span><span id="L-24"><a href="#L-24"><span class="linenos"> 24</span></a><span class="k">def</span> <span class="nf">_date_add_sql</span><span class="p">(</span> -</span><span id="L-25"><a href="#L-25"><span class="linenos"> 25</span></a> <span class="n">data_type</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">kind</span><span class="p">:</span> <span class="nb">str</span> -</span><span id="L-26"><a href="#L-26"><span class="linenos"> 26</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> -</span><span id="L-27"><a href="#L-27"><span class="linenos"> 27</span></a> <span class="k">def</span> <span class="nf">func</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-28"><a href="#L-28"><span class="linenos"> 28</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-29"><a href="#L-29"><span class="linenos"> 29</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> -</span><span id="L-30"><a href="#L-30"><span class="linenos"> 30</span></a> <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="n">unit</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="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">"DAY"</span><span class="p">)</span> -</span><span id="L-31"><a href="#L-31"><span class="linenos"> 31</span></a> <span class="n">interval</span> <span class="o">=</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">expression</span><span class="p">,</span> <span class="n">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">)</span> -</span><span id="L-32"><a href="#L-32"><span class="linenos"> 32</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">data_type</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">interval</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-33"><a href="#L-33"><span class="linenos"> 33</span></a> -</span><span id="L-34"><a href="#L-34"><span class="linenos"> 34</span></a> <span class="k">return</span> <span class="n">func</span> -</span><span id="L-35"><a href="#L-35"><span class="linenos"> 35</span></a> +</span><span id="L-24"><a href="#L-24"><span class="linenos"> 24</span></a> +</span><span id="L-25"><a href="#L-25"><span class="linenos"> 25</span></a><span class="k">def</span> <span class="nf">_date_add_sql</span><span class="p">(</span> +</span><span id="L-26"><a href="#L-26"><span class="linenos"> 26</span></a> <span class="n">data_type</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">kind</span><span class="p">:</span> <span class="nb">str</span> +</span><span id="L-27"><a href="#L-27"><span class="linenos"> 27</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">generator</span><span class="o">.</span><span class="n">Generator</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> +</span><span id="L-28"><a href="#L-28"><span class="linenos"> 28</span></a> <span class="k">def</span> <span class="nf">func</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-29"><a href="#L-29"><span class="linenos"> 29</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-30"><a href="#L-30"><span class="linenos"> 30</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> +</span><span id="L-31"><a href="#L-31"><span class="linenos"> 31</span></a> <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="n">unit</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="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">"DAY"</span><span class="p">)</span> +</span><span id="L-32"><a href="#L-32"><span class="linenos"> 32</span></a> <span class="n">interval</span> <span class="o">=</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">expression</span><span class="p">,</span> <span class="n">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">)</span> +</span><span id="L-33"><a href="#L-33"><span class="linenos"> 33</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">data_type</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">interval</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-34"><a href="#L-34"><span class="linenos"> 34</span></a> +</span><span id="L-35"><a href="#L-35"><span class="linenos"> 35</span></a> <span class="k">return</span> <span class="n">func</span> </span><span id="L-36"><a href="#L-36"><span class="linenos"> 36</span></a> -</span><span id="L-37"><a href="#L-37"><span class="linenos"> 37</span></a><span class="k">def</span> <span class="nf">_derived_table_values_to_unnest</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">generator</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">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-38"><a href="#L-38"><span class="linenos"> 38</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">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">):</span> -</span><span id="L-39"><a href="#L-39"><span class="linenos"> 39</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">values_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-40"><a href="#L-40"><span class="linenos"> 40</span></a> -</span><span id="L-41"><a href="#L-41"><span class="linenos"> 41</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">)</span> -</span><span id="L-42"><a href="#L-42"><span class="linenos"> 42</span></a> -</span><span id="L-43"><a href="#L-43"><span class="linenos"> 43</span></a> <span class="n">structs</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="L-44"><a href="#L-44"><span class="linenos"> 44</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">(</span> -</span><span id="L-45"><a href="#L-45"><span class="linenos"> 45</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> -</span><span id="L-46"><a href="#L-46"><span class="linenos"> 46</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span> -</span><span id="L-47"><a href="#L-47"><span class="linenos"> 47</span></a> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span> -</span><span id="L-48"><a href="#L-48"><span class="linenos"> 48</span></a> <span class="n">t</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-49"><a href="#L-49"><span class="linenos"> 49</span></a> <span class="n">alias</span><span class="o">.</span><span class="n">columns</span> -</span><span id="L-50"><a href="#L-50"><span class="linenos"> 50</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="n">alias</span><span class="o">.</span><span class="n">columns</span> -</span><span id="L-51"><a href="#L-51"><span class="linenos"> 51</span></a> <span class="k">else</span> <span class="p">(</span><span class="sa">f</span><span class="s2">"_c</span><span class="si">{</span><span class="n">i</span><span class="si">}</span><span class="s2">"</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">expressions</span><span class="p">))),</span> -</span><span id="L-52"><a href="#L-52"><span class="linenos"> 52</span></a> <span class="p">)</span> -</span><span id="L-53"><a href="#L-53"><span class="linenos"> 53</span></a> <span class="p">]</span> -</span><span id="L-54"><a href="#L-54"><span class="linenos"> 54</span></a> <span class="p">)</span> -</span><span id="L-55"><a href="#L-55"><span class="linenos"> 55</span></a> <span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Tuple</span><span class="p">)</span> -</span><span id="L-56"><a href="#L-56"><span class="linenos"> 56</span></a> <span class="p">]</span> -</span><span id="L-57"><a href="#L-57"><span class="linenos"> 57</span></a> -</span><span id="L-58"><a href="#L-58"><span class="linenos"> 58</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">unnest_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">structs</span><span class="p">)]))</span> -</span><span id="L-59"><a href="#L-59"><span class="linenos"> 59</span></a> +</span><span id="L-37"><a href="#L-37"><span class="linenos"> 37</span></a> +</span><span id="L-38"><a href="#L-38"><span class="linenos"> 38</span></a><span class="k">def</span> <span class="nf">_derived_table_values_to_unnest</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">generator</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">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-39"><a href="#L-39"><span class="linenos"> 39</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">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">):</span> +</span><span id="L-40"><a href="#L-40"><span class="linenos"> 40</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">values_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-41"><a href="#L-41"><span class="linenos"> 41</span></a> +</span><span id="L-42"><a href="#L-42"><span class="linenos"> 42</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">)</span> +</span><span id="L-43"><a href="#L-43"><span class="linenos"> 43</span></a> +</span><span id="L-44"><a href="#L-44"><span class="linenos"> 44</span></a> <span class="n">structs</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="L-45"><a href="#L-45"><span class="linenos"> 45</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">(</span> +</span><span id="L-46"><a href="#L-46"><span class="linenos"> 46</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> +</span><span id="L-47"><a href="#L-47"><span class="linenos"> 47</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span> +</span><span id="L-48"><a href="#L-48"><span class="linenos"> 48</span></a> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span> +</span><span id="L-49"><a href="#L-49"><span class="linenos"> 49</span></a> <span class="n">t</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-50"><a href="#L-50"><span class="linenos"> 50</span></a> <span class="n">alias</span><span class="o">.</span><span class="n">columns</span> +</span><span id="L-51"><a href="#L-51"><span class="linenos"> 51</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="n">alias</span><span class="o">.</span><span class="n">columns</span> +</span><span id="L-52"><a href="#L-52"><span class="linenos"> 52</span></a> <span class="k">else</span> <span class="p">(</span><span class="sa">f</span><span class="s2">"_c</span><span class="si">{</span><span class="n">i</span><span class="si">}</span><span class="s2">"</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">expressions</span><span class="p">))),</span> +</span><span id="L-53"><a href="#L-53"><span class="linenos"> 53</span></a> <span class="p">)</span> +</span><span id="L-54"><a href="#L-54"><span class="linenos"> 54</span></a> <span class="p">]</span> +</span><span id="L-55"><a href="#L-55"><span class="linenos"> 55</span></a> <span class="p">)</span> +</span><span id="L-56"><a href="#L-56"><span class="linenos"> 56</span></a> <span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Tuple</span><span class="p">)</span> +</span><span id="L-57"><a href="#L-57"><span class="linenos"> 57</span></a> <span class="p">]</span> +</span><span id="L-58"><a href="#L-58"><span class="linenos"> 58</span></a> +</span><span id="L-59"><a href="#L-59"><span class="linenos"> 59</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">unnest_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">structs</span><span class="p">)]))</span> </span><span id="L-60"><a href="#L-60"><span class="linenos"> 60</span></a> -</span><span id="L-61"><a href="#L-61"><span class="linenos"> 61</span></a><span class="k">def</span> <span class="nf">_returnsproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">generator</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">ReturnsProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-62"><a href="#L-62"><span class="linenos"> 62</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-63"><a href="#L-63"><span class="linenos"> 63</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">Schema</span><span class="p">):</span> -</span><span id="L-64"><a href="#L-64"><span class="linenos"> 64</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="o">.</span><span class="n">this</span><span class="si">}</span><span class="s2"> <</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">>"</span> -</span><span id="L-65"><a href="#L-65"><span class="linenos"> 65</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-66"><a href="#L-66"><span class="linenos"> 66</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-67"><a href="#L-67"><span class="linenos"> 67</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RETURNS </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-68"><a href="#L-68"><span class="linenos"> 68</span></a> +</span><span id="L-61"><a href="#L-61"><span class="linenos"> 61</span></a> +</span><span id="L-62"><a href="#L-62"><span class="linenos"> 62</span></a><span class="k">def</span> <span class="nf">_returnsproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">generator</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">ReturnsProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-63"><a href="#L-63"><span class="linenos"> 63</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-64"><a href="#L-64"><span class="linenos"> 64</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">Schema</span><span class="p">):</span> +</span><span id="L-65"><a href="#L-65"><span class="linenos"> 65</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="o">.</span><span class="n">this</span><span class="si">}</span><span class="s2"> <</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">>"</span> +</span><span id="L-66"><a href="#L-66"><span class="linenos"> 66</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-67"><a href="#L-67"><span class="linenos"> 67</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-68"><a href="#L-68"><span class="linenos"> 68</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RETURNS </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-69"><a href="#L-69"><span class="linenos"> 69</span></a> -</span><span id="L-70"><a href="#L-70"><span class="linenos"> 70</span></a><span class="k">def</span> <span class="nf">_create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">generator</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">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-71"><a href="#L-71"><span class="linenos"> 71</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> -</span><span id="L-72"><a href="#L-72"><span class="linenos"> 72</span></a> <span class="n">returns</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">ReturnsProperty</span><span class="p">)</span> -</span><span id="L-73"><a href="#L-73"><span class="linenos"> 73</span></a> <span class="k">if</span> <span class="n">kind</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"FUNCTION"</span> <span class="ow">and</span> <span class="n">returns</span> <span class="ow">and</span> <span class="n">returns</span><span 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_table"</span><span class="p">):</span> -</span><span id="L-74"><a href="#L-74"><span class="linenos"> 74</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="L-75"><a href="#L-75"><span class="linenos"> 75</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"TABLE FUNCTION"</span><span class="p">)</span> -</span><span id="L-76"><a href="#L-76"><span class="linenos"> 76</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span> -</span><span id="L-77"><a href="#L-77"><span class="linenos"> 77</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="L-78"><a href="#L-78"><span class="linenos"> 78</span></a> <span class="p">(</span> -</span><span id="L-79"><a href="#L-79"><span class="linenos"> 79</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">,</span> -</span><span id="L-80"><a href="#L-80"><span class="linenos"> 80</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">,</span> -</span><span id="L-81"><a href="#L-81"><span class="linenos"> 81</span></a> <span class="p">),</span> -</span><span id="L-82"><a href="#L-82"><span class="linenos"> 82</span></a> <span class="p">):</span> -</span><span id="L-83"><a href="#L-83"><span class="linenos"> 83</span></a> <span class="n">expression</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">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-84"><a href="#L-84"><span class="linenos"> 84</span></a> -</span><span id="L-85"><a href="#L-85"><span class="linenos"> 85</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-86"><a href="#L-86"><span class="linenos"> 86</span></a> -</span><span id="L-87"><a href="#L-87"><span class="linenos"> 87</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-88"><a href="#L-88"><span class="linenos"> 88</span></a> +</span><span id="L-70"><a href="#L-70"><span class="linenos"> 70</span></a> +</span><span id="L-71"><a href="#L-71"><span class="linenos"> 71</span></a><span class="k">def</span> <span class="nf">_create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">generator</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">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-72"><a href="#L-72"><span class="linenos"> 72</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> +</span><span id="L-73"><a href="#L-73"><span class="linenos"> 73</span></a> <span class="n">returns</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">ReturnsProperty</span><span class="p">)</span> +</span><span id="L-74"><a href="#L-74"><span class="linenos"> 74</span></a> <span class="k">if</span> <span class="n">kind</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"FUNCTION"</span> <span class="ow">and</span> <span class="n">returns</span> <span class="ow">and</span> <span class="n">returns</span><span 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_table"</span><span class="p">):</span> +</span><span id="L-75"><a href="#L-75"><span class="linenos"> 75</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="L-76"><a href="#L-76"><span class="linenos"> 76</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"TABLE FUNCTION"</span><span class="p">)</span> +</span><span id="L-77"><a href="#L-77"><span class="linenos"> 77</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span> +</span><span id="L-78"><a href="#L-78"><span class="linenos"> 78</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="L-79"><a href="#L-79"><span class="linenos"> 79</span></a> <span class="p">(</span> +</span><span id="L-80"><a href="#L-80"><span class="linenos"> 80</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">,</span> +</span><span id="L-81"><a href="#L-81"><span class="linenos"> 81</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">,</span> +</span><span id="L-82"><a href="#L-82"><span class="linenos"> 82</span></a> <span class="p">),</span> +</span><span id="L-83"><a href="#L-83"><span class="linenos"> 83</span></a> <span class="p">):</span> +</span><span id="L-84"><a href="#L-84"><span class="linenos"> 84</span></a> <span class="n">expression</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">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-85"><a href="#L-85"><span class="linenos"> 85</span></a> +</span><span id="L-86"><a href="#L-86"><span class="linenos"> 86</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-87"><a href="#L-87"><span class="linenos"> 87</span></a> +</span><span id="L-88"><a href="#L-88"><span class="linenos"> 88</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="L-89"><a href="#L-89"><span class="linenos"> 89</span></a> -</span><span id="L-90"><a href="#L-90"><span class="linenos"> 90</span></a><span class="k">def</span> <span class="nf">_unqualify_unnest</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="L-91"><a href="#L-91"><span class="linenos"> 91</span></a><span class="w"> </span><span class="sd">"""Remove references to unnest table aliases since bigquery doesn't allow them.</span> -</span><span id="L-92"><a href="#L-92"><span class="linenos"> 92</span></a> -</span><span id="L-93"><a href="#L-93"><span class="linenos"> 93</span></a><span class="sd"> These are added by the optimizer's qualify_column step.</span> -</span><span id="L-94"><a href="#L-94"><span class="linenos"> 94</span></a><span class="sd"> """</span> -</span><span id="L-95"><a href="#L-95"><span class="linenos"> 95</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> -</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> <span class="k">for</span> <span class="n">unnest</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">):</span> -</span><span id="L-97"><a href="#L-97"><span class="linenos"> 97</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">unnest</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">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">))</span> <span class="ow">and</span> <span class="n">unnest</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> -</span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">selects</span><span class="p">:</span> -</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">select</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> -</span><span id="L-100"><a href="#L-100"><span class="linenos">100</span></a> <span class="k">if</span> <span class="n">column</span><span class="o">.</span><span class="n">table</span> <span class="o">==</span> <span class="n">unnest</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> -</span><span id="L-101"><a href="#L-101"><span class="linenos">101</span></a> <span class="n">column</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"table"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="L-102"><a href="#L-102"><span class="linenos">102</span></a> -</span><span id="L-103"><a href="#L-103"><span class="linenos">103</span></a> <span class="k">return</span> <span class="n">expression</span> -</span><span id="L-104"><a href="#L-104"><span class="linenos">104</span></a> +</span><span id="L-90"><a href="#L-90"><span class="linenos"> 90</span></a> +</span><span id="L-91"><a href="#L-91"><span class="linenos"> 91</span></a><span class="k">def</span> <span class="nf">_unqualify_unnest</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="L-92"><a href="#L-92"><span class="linenos"> 92</span></a><span class="w"> </span><span class="sd">"""Remove references to unnest table aliases since bigquery doesn't allow them.</span> +</span><span id="L-93"><a href="#L-93"><span class="linenos"> 93</span></a> +</span><span id="L-94"><a href="#L-94"><span class="linenos"> 94</span></a><span class="sd"> These are added by the optimizer's qualify_column step.</span> +</span><span id="L-95"><a href="#L-95"><span class="linenos"> 95</span></a><span class="sd"> """</span> +</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> +</span><span id="L-97"><a href="#L-97"><span class="linenos"> 97</span></a> <span class="k">for</span> <span class="n">unnest</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">):</span> +</span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">unnest</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">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">))</span> <span class="ow">and</span> <span class="n">unnest</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> +</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">selects</span><span class="p">:</span> +</span><span id="L-100"><a href="#L-100"><span class="linenos">100</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">select</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> +</span><span id="L-101"><a href="#L-101"><span class="linenos">101</span></a> <span class="k">if</span> <span class="n">column</span><span class="o">.</span><span class="n">table</span> <span class="o">==</span> <span class="n">unnest</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> +</span><span id="L-102"><a href="#L-102"><span class="linenos">102</span></a> <span class="n">column</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"table"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="L-103"><a href="#L-103"><span class="linenos">103</span></a> +</span><span id="L-104"><a href="#L-104"><span class="linenos">104</span></a> <span class="k">return</span> <span class="n">expression</span> </span><span id="L-105"><a href="#L-105"><span class="linenos">105</span></a> -</span><span id="L-106"><a href="#L-106"><span class="linenos">106</span></a><span class="k">class</span> <span class="nc">BigQuery</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> -</span><span id="L-107"><a href="#L-107"><span class="linenos">107</span></a> <span class="n">UNNEST_COLUMN_ONLY</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-108"><a href="#L-108"><span class="linenos">108</span></a> -</span><span id="L-109"><a href="#L-109"><span class="linenos">109</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-110"><a href="#L-110"><span class="linenos">110</span></a> <span class="s2">"%D"</span><span class="p">:</span> <span class="s2">"%m/</span><span class="si">%d</span><span class="s2">/%y"</span><span class="p">,</span> -</span><span id="L-111"><a href="#L-111"><span class="linenos">111</span></a> <span class="p">}</span> +</span><span id="L-106"><a href="#L-106"><span class="linenos">106</span></a> +</span><span id="L-107"><a href="#L-107"><span class="linenos">107</span></a><span class="k">class</span> <span class="nc">BigQuery</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> +</span><span id="L-108"><a href="#L-108"><span class="linenos">108</span></a> <span class="n">UNNEST_COLUMN_ONLY</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-109"><a href="#L-109"><span class="linenos">109</span></a> +</span><span id="L-110"><a href="#L-110"><span class="linenos">110</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#case_sensitivity</span> +</span><span id="L-111"><a href="#L-111"><span class="linenos">111</span></a> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="o">=</span> <span class="kc">None</span> </span><span id="L-112"><a href="#L-112"><span class="linenos">112</span></a> -</span><span id="L-113"><a href="#L-113"><span class="linenos">113</span></a> <span class="n">FORMAT_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-114"><a href="#L-114"><span class="linenos">114</span></a> <span class="s2">"DD"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%d</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-115"><a href="#L-115"><span class="linenos">115</span></a> <span class="s2">"MM"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> -</span><span id="L-116"><a href="#L-116"><span class="linenos">116</span></a> <span class="s2">"MON"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> -</span><span id="L-117"><a href="#L-117"><span class="linenos">117</span></a> <span class="s2">"MONTH"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> -</span><span id="L-118"><a href="#L-118"><span class="linenos">118</span></a> <span class="s2">"YYYY"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> -</span><span id="L-119"><a href="#L-119"><span class="linenos">119</span></a> <span class="s2">"YY"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> -</span><span id="L-120"><a href="#L-120"><span class="linenos">120</span></a> <span class="s2">"HH"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> -</span><span id="L-121"><a href="#L-121"><span class="linenos">121</span></a> <span class="s2">"HH12"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> -</span><span id="L-122"><a href="#L-122"><span class="linenos">122</span></a> <span class="s2">"HH24"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> -</span><span id="L-123"><a href="#L-123"><span class="linenos">123</span></a> <span class="s2">"MI"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> -</span><span id="L-124"><a href="#L-124"><span class="linenos">124</span></a> <span class="s2">"SS"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> -</span><span id="L-125"><a href="#L-125"><span class="linenos">125</span></a> <span class="s2">"SSSSS"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-126"><a href="#L-126"><span class="linenos">126</span></a> <span class="s2">"TZH"</span><span class="p">:</span> <span class="s2">"%z"</span><span class="p">,</span> -</span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a> <span class="p">}</span> -</span><span id="L-128"><a href="#L-128"><span class="linenos">128</span></a> -</span><span id="L-129"><a href="#L-129"><span class="linenos">129</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-130"><a href="#L-130"><span class="linenos">130</span></a> <span class="n">QUOTES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">,</span> <span class="s1">'"'</span><span class="p">,</span> <span class="s1">'"""'</span><span class="p">,</span> <span class="s2">"'''"</span><span class="p">]</span> -</span><span id="L-131"><a href="#L-131"><span class="linenos">131</span></a> <span class="n">COMMENTS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--"</span><span class="p">,</span> <span class="s2">"#"</span><span class="p">,</span> <span class="p">(</span><span class="s2">"/*"</span><span class="p">,</span> <span class="s2">"*/"</span><span class="p">)]</span> -</span><span id="L-132"><a href="#L-132"><span class="linenos">132</span></a> <span class="n">IDENTIFIERS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"`"</span><span class="p">]</span> -</span><span id="L-133"><a href="#L-133"><span class="linenos">133</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">]</span> -</span><span id="L-134"><a href="#L-134"><span class="linenos">134</span></a> -</span><span id="L-135"><a href="#L-135"><span class="linenos">135</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"0x"</span><span class="p">,</span> <span class="s2">""</span><span class="p">),</span> <span class="p">(</span><span class="s2">"0X"</span><span class="p">,</span> <span class="s2">""</span><span class="p">)]</span> -</span><span id="L-136"><a href="#L-136"><span class="linenos">136</span></a> -</span><span id="L-137"><a href="#L-137"><span class="linenos">137</span></a> <span class="n">BYTE_STRINGS</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="L-138"><a href="#L-138"><span class="linenos">138</span></a> <span class="p">(</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">q</span><span class="p">,</span> <span class="n">q</span><span class="p">)</span> <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">QUOTES</span><span class="p">)</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"b"</span><span class="p">,</span> <span class="s2">"B"</span><span class="p">)</span> -</span><span id="L-139"><a href="#L-139"><span class="linenos">139</span></a> <span class="p">]</span> -</span><span id="L-140"><a href="#L-140"><span class="linenos">140</span></a> -</span><span id="L-141"><a href="#L-141"><span class="linenos">141</span></a> <span class="n">RAW_STRINGS</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="L-142"><a href="#L-142"><span class="linenos">142</span></a> <span class="p">(</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">q</span><span class="p">,</span> <span class="n">q</span><span class="p">)</span> <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">QUOTES</span><span class="p">)</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"r"</span><span class="p">,</span> <span class="s2">"R"</span><span class="p">)</span> -</span><span id="L-143"><a href="#L-143"><span class="linenos">143</span></a> <span class="p">]</span> +</span><span id="L-113"><a href="#L-113"><span class="linenos">113</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-114"><a href="#L-114"><span class="linenos">114</span></a> <span class="s2">"%D"</span><span class="p">:</span> <span class="s2">"%m/</span><span class="si">%d</span><span class="s2">/%y"</span><span class="p">,</span> +</span><span id="L-115"><a href="#L-115"><span class="linenos">115</span></a> <span class="p">}</span> +</span><span id="L-116"><a href="#L-116"><span class="linenos">116</span></a> +</span><span id="L-117"><a href="#L-117"><span class="linenos">117</span></a> <span class="n">FORMAT_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-118"><a href="#L-118"><span class="linenos">118</span></a> <span class="s2">"DD"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%d</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-119"><a href="#L-119"><span class="linenos">119</span></a> <span class="s2">"MM"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> +</span><span id="L-120"><a href="#L-120"><span class="linenos">120</span></a> <span class="s2">"MON"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> +</span><span id="L-121"><a href="#L-121"><span class="linenos">121</span></a> <span class="s2">"MONTH"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> +</span><span id="L-122"><a href="#L-122"><span class="linenos">122</span></a> <span class="s2">"YYYY"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> +</span><span id="L-123"><a href="#L-123"><span class="linenos">123</span></a> <span class="s2">"YY"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> +</span><span id="L-124"><a href="#L-124"><span class="linenos">124</span></a> <span class="s2">"HH"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> +</span><span id="L-125"><a href="#L-125"><span class="linenos">125</span></a> <span class="s2">"HH12"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> +</span><span id="L-126"><a href="#L-126"><span class="linenos">126</span></a> <span class="s2">"HH24"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> +</span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a> <span class="s2">"MI"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> +</span><span id="L-128"><a href="#L-128"><span class="linenos">128</span></a> <span class="s2">"SS"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> +</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a> <span class="s2">"SSSSS"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a> <span class="s2">"TZH"</span><span class="p">:</span> <span class="s2">"%z"</span><span class="p">,</span> +</span><span id="L-131"><a href="#L-131"><span class="linenos">131</span></a> <span class="p">}</span> +</span><span id="L-132"><a href="#L-132"><span class="linenos">132</span></a> +</span><span id="L-133"><a href="#L-133"><span class="linenos">133</span></a> <span class="nd">@classmethod</span> +</span><span id="L-134"><a href="#L-134"><span class="linenos">134</span></a> <span class="k">def</span> <span class="nf">normalize_identifier</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="L-135"><a href="#L-135"><span class="linenos">135</span></a> <span class="c1"># In BigQuery, CTEs aren't case-sensitive, but table names are (by default, at least).</span> +</span><span id="L-136"><a href="#L-136"><span class="linenos">136</span></a> <span class="c1"># The following check is essentially a heuristic to detect tables based on whether or</span> +</span><span id="L-137"><a href="#L-137"><span class="linenos">137</span></a> <span class="c1"># not they're qualified.</span> +</span><span id="L-138"><a href="#L-138"><span class="linenos">138</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="L-139"><a href="#L-139"><span class="linenos">139</span></a> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> +</span><span id="L-140"><a href="#L-140"><span class="linenos">140</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="p">(</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">Table</span><span class="p">)</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">db</span><span class="p">)</span> +</span><span id="L-141"><a href="#L-141"><span class="linenos">141</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"is_table"</span><span class="p">)</span> +</span><span id="L-142"><a href="#L-142"><span class="linenos">142</span></a> <span class="p">):</span> +</span><span id="L-143"><a href="#L-143"><span class="linenos">143</span></a> <span class="n">expression</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">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">lower</span><span class="p">())</span> </span><span id="L-144"><a href="#L-144"><span class="linenos">144</span></a> -</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-146"><a href="#L-146"><span class="linenos">146</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-147"><a href="#L-147"><span class="linenos">147</span></a> <span class="s2">"ANY TYPE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARIANT</span><span class="p">,</span> -</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a> <span class="s2">"BEGIN"</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-149"><a href="#L-149"><span class="linenos">149</span></a> <span class="s2">"BEGIN TRANSACTION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">,</span> -</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="s2">"CURRENT_DATETIME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_DATETIME</span><span class="p">,</span> -</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> <span class="s2">"BYTES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BINARY</span><span class="p">,</span> -</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="s2">"DECLARE"</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-153"><a href="#L-153"><span class="linenos">153</span></a> <span class="s2">"FLOAT64"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> -</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> <span class="s2">"INT64"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> -</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> <span class="s2">"RECORD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">,</span> -</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> <span class="s2">"TIMESTAMP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> -</span><span id="L-157"><a href="#L-157"><span class="linenos">157</span></a> <span class="s2">"NOT DETERMINISTIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VOLATILE</span><span class="p">,</span> -</span><span id="L-158"><a href="#L-158"><span class="linenos">158</span></a> <span class="s2">"UNKNOWN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">,</span> -</span><span id="L-159"><a href="#L-159"><span class="linenos">159</span></a> <span class="p">}</span> -</span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="n">KEYWORDS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"DIV"</span><span class="p">)</span> -</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> -</span><span id="L-162"><a href="#L-162"><span class="linenos">162</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-163"><a href="#L-163"><span class="linenos">163</span></a> <span class="n">PREFIXED_PIVOT_COLUMNS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-164"><a href="#L-164"><span class="linenos">164</span></a> -</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> <span class="n">LOG_BASE_FIRST</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a> <span class="n">LOG_DEFAULTS_TO_LN</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a> -</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-169"><a href="#L-169"><span class="linenos">169</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-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="s2">"DATE_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">),</span> -</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="s2">"DATE_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">),</span> -</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="s2">"DATE_TRUNC"</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">DateTrunc</span><span class="p">(</span> -</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="n">unit</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="nb">str</span><span class="p">(</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-174"><a href="#L-174"><span class="linenos">174</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-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="p">),</span> -</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> <span class="s2">"DATETIME_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">),</span> -</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="s2">"DATETIME_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">),</span> -</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> <span class="s2">"DIV"</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">IntDiv</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">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-179"><a href="#L-179"><span class="linenos">179</span></a> <span class="s2">"PARSE_DATE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">format_time_lambda</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="s2">"bigquery"</span><span class="p">)(</span> -</span><span id="L-180"><a href="#L-180"><span class="linenos">180</span></a> <span class="p">[</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">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-181"><a href="#L-181"><span class="linenos">181</span></a> <span class="p">),</span> -</span><span id="L-182"><a href="#L-182"><span class="linenos">182</span></a> <span class="s2">"PARSE_TIMESTAMP"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">format_time_lambda</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">"bigquery"</span><span class="p">)(</span> -</span><span id="L-183"><a href="#L-183"><span class="linenos">183</span></a> <span class="p">[</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">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-184"><a href="#L-184"><span class="linenos">184</span></a> <span class="p">),</span> -</span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> <span class="s2">"REGEXP_CONTAINS"</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-186"><a href="#L-186"><span class="linenos">186</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-187"><a href="#L-187"><span class="linenos">187</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-188"><a href="#L-188"><span class="linenos">188</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-189"><a href="#L-189"><span class="linenos">189</span></a> <span class="n">position</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-190"><a href="#L-190"><span class="linenos">190</span></a> <span class="n">occurrence</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-191"><a href="#L-191"><span class="linenos">191</span></a> <span class="n">group</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> -</span><span id="L-192"><a href="#L-192"><span class="linenos">192</span></a> <span class="k">if</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="nb">str</span><span class="p">(</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="o">.</span><span class="n">groups</span> <span class="o">==</span> <span class="mi">1</span> -</span><span id="L-193"><a href="#L-193"><span class="linenos">193</span></a> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-194"><a href="#L-194"><span class="linenos">194</span></a> <span class="p">),</span> -</span><span id="L-195"><a href="#L-195"><span class="linenos">195</span></a> <span class="s2">"SPLIT"</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">Split</span><span class="p">(</span> -</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#split</span> -</span><span id="L-197"><a href="#L-197"><span class="linenos">197</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-198"><a href="#L-198"><span class="linenos">198</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 class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">","</span><span class="p">),</span> +</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> +</span><span id="L-147"><a href="#L-147"><span class="linenos">147</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-148"><a href="#L-148"><span class="linenos">148</span></a> <span class="n">QUOTES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">,</span> <span class="s1">'"'</span><span class="p">,</span> <span class="s1">'"""'</span><span class="p">,</span> <span class="s2">"'''"</span><span class="p">]</span> +</span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a> <span class="n">COMMENTS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--"</span><span class="p">,</span> <span class="s2">"#"</span><span class="p">,</span> <span class="p">(</span><span class="s2">"/*"</span><span class="p">,</span> <span class="s2">"*/"</span><span class="p">)]</span> +</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="n">IDENTIFIERS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"`"</span><span class="p">]</span> +</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">]</span> +</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> +</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"0x"</span><span class="p">,</span> <span class="s2">""</span><span class="p">),</span> <span class="p">(</span><span class="s2">"0X"</span><span class="p">,</span> <span class="s2">""</span><span class="p">)]</span> +</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> +</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> <span class="n">BYTE_STRINGS</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> <span class="p">(</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">q</span><span class="p">,</span> <span class="n">q</span><span class="p">)</span> <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">QUOTES</span><span class="p">)</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"b"</span><span class="p">,</span> <span class="s2">"B"</span><span class="p">)</span> +</span><span id="L-157"><a href="#L-157"><span class="linenos">157</span></a> <span class="p">]</span> +</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="n">RAW_STRINGS</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="p">(</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">q</span><span class="p">,</span> <span class="n">q</span><span class="p">)</span> <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">QUOTES</span><span class="p">)</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"r"</span><span class="p">,</span> <span class="s2">"R"</span><span class="p">)</span> +</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="p">]</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="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-164"><a href="#L-164"><span class="linenos">164</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-165"><a href="#L-165"><span class="linenos">165</span></a> <span class="s2">"ANY TYPE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARIANT</span><span class="p">,</span> +</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a> <span class="s2">"BEGIN"</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-167"><a href="#L-167"><span class="linenos">167</span></a> <span class="s2">"BEGIN TRANSACTION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">,</span> +</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a> <span class="s2">"CURRENT_DATETIME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_DATETIME</span><span class="p">,</span> +</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a> <span class="s2">"BYTES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BINARY</span><span class="p">,</span> +</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="s2">"DECLARE"</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-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="s2">"FLOAT64"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> +</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="s2">"INT64"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> +</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="s2">"RECORD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">,</span> +</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="s2">"TIMESTAMP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> +</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="s2">"NOT DETERMINISTIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VOLATILE</span><span class="p">,</span> +</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> <span class="s2">"UNKNOWN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">,</span> +</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="p">}</span> +</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> <span class="n">KEYWORDS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"DIV"</span><span class="p">)</span> +</span><span id="L-179"><a href="#L-179"><span class="linenos">179</span></a> +</span><span id="L-180"><a href="#L-180"><span class="linenos">180</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-181"><a href="#L-181"><span class="linenos">181</span></a> <span class="n">PREFIXED_PIVOT_COLUMNS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-182"><a href="#L-182"><span class="linenos">182</span></a> +</span><span id="L-183"><a href="#L-183"><span class="linenos">183</span></a> <span class="n">LOG_BASE_FIRST</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-184"><a href="#L-184"><span class="linenos">184</span></a> <span class="n">LOG_DEFAULTS_TO_LN</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> +</span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-187"><a href="#L-187"><span class="linenos">187</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-188"><a href="#L-188"><span class="linenos">188</span></a> <span class="s2">"DATE_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">),</span> +</span><span id="L-189"><a href="#L-189"><span class="linenos">189</span></a> <span class="s2">"DATE_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">),</span> +</span><span id="L-190"><a href="#L-190"><span class="linenos">190</span></a> <span class="s2">"DATE_TRUNC"</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">DateTrunc</span><span class="p">(</span> +</span><span id="L-191"><a href="#L-191"><span class="linenos">191</span></a> <span class="n">unit</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="nb">str</span><span class="p">(</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-192"><a href="#L-192"><span class="linenos">192</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-193"><a href="#L-193"><span class="linenos">193</span></a> <span class="p">),</span> +</span><span id="L-194"><a href="#L-194"><span class="linenos">194</span></a> <span class="s2">"DATETIME_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">),</span> +</span><span id="L-195"><a href="#L-195"><span class="linenos">195</span></a> <span class="s2">"DATETIME_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">),</span> +</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a> <span class="s2">"DIV"</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">IntDiv</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">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-197"><a href="#L-197"><span class="linenos">197</span></a> <span class="s2">"PARSE_DATE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">format_time_lambda</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="s2">"bigquery"</span><span class="p">)(</span> +</span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> <span class="p">[</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">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-199"><a href="#L-199"><span class="linenos">199</span></a> <span class="p">),</span> -</span><span id="L-200"><a href="#L-200"><span class="linenos">200</span></a> <span class="s2">"TIME_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">),</span> -</span><span id="L-201"><a href="#L-201"><span class="linenos">201</span></a> <span class="s2">"TIME_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeSub</span><span class="p">),</span> -</span><span id="L-202"><a href="#L-202"><span class="linenos">202</span></a> <span class="s2">"TIMESTAMP_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimestampAdd</span><span class="p">),</span> -</span><span id="L-203"><a href="#L-203"><span class="linenos">203</span></a> <span class="s2">"TIMESTAMP_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimestampSub</span><span class="p">),</span> -</span><span id="L-204"><a href="#L-204"><span class="linenos">204</span></a> <span class="p">}</span> -</span><span id="L-205"><a href="#L-205"><span class="linenos">205</span></a> -</span><span id="L-206"><a href="#L-206"><span class="linenos">206</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-207"><a href="#L-207"><span class="linenos">207</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">FUNCTION_PARSERS</span><span class="p">,</span> -</span><span id="L-208"><a href="#L-208"><span class="linenos">208</span></a> <span class="s2">"ARRAY"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">()]),</span> -</span><span id="L-209"><a href="#L-209"><span class="linenos">209</span></a> <span class="p">}</span> -</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</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="n">NO_PAREN_FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-213"><a href="#L-213"><span class="linenos">213</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_FUNCTIONS</span><span class="p">,</span> -</span><span id="L-214"><a href="#L-214"><span class="linenos">214</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_DATETIME</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDatetime</span><span class="p">,</span> -</span><span id="L-215"><a href="#L-215"><span class="linenos">215</span></a> <span class="p">}</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="n">NESTED_TYPE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-218"><a href="#L-218"><span class="linenos">218</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">NESTED_TYPE_TOKENS</span><span class="p">,</span> -</span><span id="L-219"><a href="#L-219"><span class="linenos">219</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> -</span><span id="L-220"><a href="#L-220"><span class="linenos">220</span></a> <span class="p">}</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">ID_VAR_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-223"><a href="#L-223"><span class="linenos">223</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">ID_VAR_TOKENS</span><span class="p">,</span> -</span><span id="L-224"><a href="#L-224"><span class="linenos">224</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">VALUES</span><span class="p">,</span> -</span><span id="L-225"><a href="#L-225"><span class="linenos">225</span></a> <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">PROPERTY_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-228"><a href="#L-228"><span class="linenos">228</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">PROPERTY_PARSERS</span><span class="p">,</span> -</span><span id="L-229"><a href="#L-229"><span class="linenos">229</span></a> <span class="s2">"NOT DETERMINISTIC"</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">expression</span><span class="p">(</span> -</span><span id="L-230"><a href="#L-230"><span class="linenos">230</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"VOLATILE"</span><span class="p">)</span> -</span><span id="L-231"><a href="#L-231"><span class="linenos">231</span></a> <span class="p">),</span> -</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="s2">"OPTIONS"</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_with_property</span><span class="p">(),</span> +</span><span id="L-200"><a href="#L-200"><span class="linenos">200</span></a> <span class="s2">"PARSE_TIMESTAMP"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">format_time_lambda</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">"bigquery"</span><span class="p">)(</span> +</span><span id="L-201"><a href="#L-201"><span class="linenos">201</span></a> <span class="p">[</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">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-202"><a href="#L-202"><span class="linenos">202</span></a> <span class="p">),</span> +</span><span id="L-203"><a href="#L-203"><span class="linenos">203</span></a> <span class="s2">"REGEXP_CONTAINS"</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-204"><a href="#L-204"><span class="linenos">204</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-205"><a href="#L-205"><span class="linenos">205</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-206"><a href="#L-206"><span class="linenos">206</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-207"><a href="#L-207"><span class="linenos">207</span></a> <span class="n">position</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-208"><a href="#L-208"><span class="linenos">208</span></a> <span class="n">occurrence</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-209"><a href="#L-209"><span class="linenos">209</span></a> <span class="n">group</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> +</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> <span class="k">if</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="nb">str</span><span class="p">(</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="o">.</span><span class="n">groups</span> <span class="o">==</span> <span class="mi">1</span> +</span><span id="L-211"><a href="#L-211"><span class="linenos">211</span></a> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-212"><a href="#L-212"><span class="linenos">212</span></a> <span class="p">),</span> +</span><span id="L-213"><a href="#L-213"><span class="linenos">213</span></a> <span class="s2">"SPLIT"</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">Split</span><span class="p">(</span> +</span><span id="L-214"><a href="#L-214"><span class="linenos">214</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#split</span> +</span><span id="L-215"><a href="#L-215"><span class="linenos">215</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-216"><a href="#L-216"><span class="linenos">216</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 class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">","</span><span class="p">),</span> +</span><span id="L-217"><a href="#L-217"><span class="linenos">217</span></a> <span class="p">),</span> +</span><span id="L-218"><a href="#L-218"><span class="linenos">218</span></a> <span class="s2">"TIME_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">),</span> +</span><span id="L-219"><a href="#L-219"><span class="linenos">219</span></a> <span class="s2">"TIME_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeSub</span><span class="p">),</span> +</span><span id="L-220"><a href="#L-220"><span class="linenos">220</span></a> <span class="s2">"TIMESTAMP_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimestampAdd</span><span class="p">),</span> +</span><span id="L-221"><a href="#L-221"><span class="linenos">221</span></a> <span class="s2">"TIMESTAMP_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimestampSub</span><span class="p">),</span> +</span><span id="L-222"><a href="#L-222"><span class="linenos">222</span></a> <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="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-225"><a href="#L-225"><span class="linenos">225</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">FUNCTION_PARSERS</span><span class="p">,</span> +</span><span id="L-226"><a href="#L-226"><span class="linenos">226</span></a> <span class="s2">"ARRAY"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">()]),</span> +</span><span id="L-227"><a href="#L-227"><span class="linenos">227</span></a> <span class="p">}</span> +</span><span id="L-228"><a href="#L-228"><span class="linenos">228</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</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">NO_PAREN_FUNCTIONS</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">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">NO_PAREN_FUNCTIONS</span><span class="p">,</span> +</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_DATETIME</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDatetime</span><span class="p">,</span> </span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="p">}</span> </span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> -</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="n">CONSTRAINT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-236"><a href="#L-236"><span class="linenos">236</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">CONSTRAINT_PARSERS</span><span class="p">,</span> -</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> <span class="s2">"OPTIONS"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_with_property</span><span class="p">()),</span> +</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="n">NESTED_TYPE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-236"><a href="#L-236"><span class="linenos">236</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">NESTED_TYPE_TOKENS</span><span class="p">,</span> +</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> </span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="p">}</span> </span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> -</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="k">def</span> <span class="nf">_parse_table_part</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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-241"><a href="#L-241"><span class="linenos">241</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> -</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#table_names</span> -</span><span id="L-244"><a href="#L-244"><span class="linenos">244</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">Identifier</span><span class="p">):</span> -</span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> -</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="k">while</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">DASH</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> -</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> -</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> <span class="n">table_name</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">"-</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">text</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> -</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted"</span><span class="p">))</span> -</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> -</span><span id="L-252"><a href="#L-252"><span class="linenos">252</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-253"><a href="#L-253"><span class="linenos">253</span></a> -</span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a> <span class="k">def</span> <span class="nf">_parse_table_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> -</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="n">table</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">table</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">Identifier</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"."</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">name</span><span class="p">:</span> -</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a> <span class="n">catalog</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-258"><a href="#L-258"><span class="linenos">258</span></a> <span class="n">t</span><span class="o">.</span><span class="n">cast</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="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">x</span><span class="p">))</span> -</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">split_num_words</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="s2">"."</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> -</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> <span class="p">)</span> -</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> -</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="k">if</span> <span class="n">rest</span> <span class="ow">and</span> <span class="n">this</span><span class="p">:</span> -</span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="o">.</span><span class="n">build</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">cast</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="p">[</span><span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="p">]))</span> -</span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> -</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="n">db</span><span class="p">,</span> <span class="n">catalog</span><span class="o">=</span><span class="n">catalog</span><span class="p">)</span> -</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a> -</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> <span class="k">return</span> <span class="n">table</span> -</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> -</span><span id="L-269"><a href="#L-269"><span class="linenos">269</span></a> <span class="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-270"><a href="#L-270"><span class="linenos">270</span></a> <span class="n">EXPLICIT_UNION</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-271"><a href="#L-271"><span class="linenos">271</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> -</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a> -</span><span id="L-277"><a href="#L-277"><span class="linenos">277</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-278"><a href="#L-278"><span class="linenos">278</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-279"><a href="#L-279"><span class="linenos">279</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_COUNT_DISTINCT"</span><span class="p">),</span> -</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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-281"><a href="#L-281"><span class="linenos">281</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</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-282"><a href="#L-282"><span class="linenos">282</span></a> <span class="s2">"TIMESTAMP"</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">"DATETIME"</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">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">"zone"</span><span class="p">))</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="n">exp</span><span class="o">.</span><span class="n">Cast</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">remove_precision_parameterized_types</span><span class="p">]),</span> -</span><span id="L-285"><a href="#L-285"><span class="linenos">285</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="L-288"><a href="#L-288"><span class="linenos">288</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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="sa">f</span><span class="s2">"DATE_DIFF(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">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="s1">'DAY'</span><span class="p">))</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">datestrtodate_sql</span><span class="p">,</span> -</span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</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">"DATE_TRUNC"</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">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)),</span> -</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRING_AGG"</span><span class="p">),</span> -</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> -</span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DIV"</span><span class="p">),</span> -</span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> -</span><span id="L-296"><a href="#L-296"><span class="linenos">296</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> -</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</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-298"><a href="#L-298"><span class="linenos">298</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">,</span> -</span><span id="L-299"><a href="#L-299"><span class="linenos">299</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-300"><a href="#L-300"><span class="linenos">300</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="L-301"><a href="#L-301"><span class="linenos">301</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">"position"</span><span class="p">),</span> -</span><span id="L-302"><a href="#L-302"><span class="linenos">302</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">"occurrence"</span><span class="p">),</span> -</span><span id="L-303"><a href="#L-303"><span class="linenos">303</span></a> <span class="p">),</span> -</span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"REGEXP_CONTAINS"</span><span class="p">),</span> -</span><span id="L-305"><a href="#L-305"><span class="linenos">305</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</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 class="n">_unqualify_unnest</span><span class="p">,</span> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</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="n">exp</span><span class="o">.</span><span class="n">StrToDate</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">"PARSE_DATE(</span><span class="si">{</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 class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</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">"PARSE_TIMESTAMP(</span><span class="si">{</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 class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="L-313"><a href="#L-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> -</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</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">"SAFE_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 </span><span 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">'to'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="s2">"bigquery"</span><span class="p">),</span> -</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="L-318"><a href="#L-318"><span class="linenos">318</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</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">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-319"><a href="#L-319"><span class="linenos">319</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-320"><a href="#L-320"><span class="linenos">320</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">:</span> <span class="n">_derived_table_values_to_unnest</span><span class="p">,</span> -</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">_returnsproperty_sql</span><span class="p">,</span> -</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> <span class="n">_create_sql</span><span class="p">,</span> -</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</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="sa">f</span><span class="s2">"TRIM"</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">e</span><span class="o">.</span><span class="n">expression</span><span class="p">),</span> -</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> <span class="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">"DETERMINISTIC"</span> -</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"IMMUTABLE"</span> -</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> <span class="k">else</span> <span class="s2">"NOT DETERMINISTIC"</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">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-330"><a href="#L-330"><span class="linenos">330</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-331"><a href="#L-331"><span class="linenos">331</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">BIGDECIMAL</span><span class="p">:</span> <span class="s2">"BIGNUMERIC"</span><span class="p">,</span> -</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="L-333"><a href="#L-333"><span class="linenos">333</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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">"BYTES"</span><span class="p">,</span> -</span><span id="L-334"><a href="#L-334"><span class="linenos">334</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">BOOLEAN</span><span class="p">:</span> <span class="s2">"BOOL"</span><span class="p">,</span> -</span><span id="L-335"><a href="#L-335"><span class="linenos">335</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">"STRING"</span><span class="p">,</span> -</span><span id="L-336"><a href="#L-336"><span class="linenos">336</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="s2">"NUMERIC"</span><span class="p">,</span> -</span><span id="L-337"><a href="#L-337"><span class="linenos">337</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">DOUBLE</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> -</span><span id="L-338"><a href="#L-338"><span class="linenos">338</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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">"FLOAT64"</span><span class="p">,</span> -</span><span id="L-339"><a href="#L-339"><span class="linenos">339</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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">"STRING"</span><span class="p">,</span> -</span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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">"STRING"</span><span class="p">,</span> -</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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="s2">"STRING"</span><span class="p">,</span> -</span><span id="L-344"><a href="#L-344"><span class="linenos">344</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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="s2">"DATETIME"</span><span class="p">,</span> -</span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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">"BYTES"</span><span class="p">,</span> -</span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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">"STRING"</span><span class="p">,</span> -</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARIANT</span><span class="p">:</span> <span class="s2">"ANY TYPE"</span><span class="p">,</span> -</span><span id="L-351"><a href="#L-351"><span class="linenos">351</span></a> <span class="p">}</span> -</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a> -</span><span id="L-353"><a href="#L-353"><span class="linenos">353</span></a> <span class="n">PROPERTIES_LOCATION</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="o">**</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 class="p">,</span> -</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="L-357"><a href="#L-357"><span class="linenos">357</span></a> <span class="p">}</span> -</span><span id="L-358"><a href="#L-358"><span class="linenos">358</span></a> -</span><span id="L-359"><a href="#L-359"><span class="linenos">359</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span><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">RESERVED_KEYWORDS</span><span class="p">,</span> <span class="s2">"hash"</span><span class="p">}</span> -</span><span id="L-360"><a href="#L-360"><span class="linenos">360</span></a> -</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a> <span class="k">def</span> <span class="nf">array_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a> <span class="n">first_arg</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> -</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">first_arg</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="L-364"><a href="#L-364"><span class="linenos">364</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ARRAY</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">first_arg</span><span class="p">))</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-365"><a href="#L-365"><span class="linenos">365</span></a> -</span><span id="L-366"><a href="#L-366"><span class="linenos">366</span></a> <span class="k">return</span> <span class="n">inline_array_sql</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-367"><a href="#L-367"><span class="linenos">367</span></a> -</span><span id="L-368"><a href="#L-368"><span class="linenos">368</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-369"><a href="#L-369"><span class="linenos">369</span></a> <span class="k">return</span> <span class="s2">"BEGIN TRANSACTION"</span> +</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="n">ID_VAR_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-241"><a href="#L-241"><span class="linenos">241</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">ID_VAR_TOKENS</span><span class="p">,</span> +</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">VALUES</span><span class="p">,</span> +</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> <span class="p">}</span> +</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> +</span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="n">PROPERTY_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-246"><a href="#L-246"><span class="linenos">246</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">PROPERTY_PARSERS</span><span class="p">,</span> +</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> <span class="s2">"NOT DETERMINISTIC"</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">expression</span><span class="p">(</span> +</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"VOLATILE"</span><span class="p">)</span> +</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> <span class="p">),</span> +</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> <span class="s2">"OPTIONS"</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_with_property</span><span class="p">(),</span> +</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> <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">CONSTRAINT_PARSERS</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">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">,</span> +</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="s2">"OPTIONS"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_with_property</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">def</span> <span class="nf">_parse_table_part</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> +</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#table_names</span> +</span><span id="L-262"><a href="#L-262"><span class="linenos">262</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">Identifier</span><span class="p">):</span> +</span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> <span class="k">while</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">DASH</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> +</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> +</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a> <span class="n">table_name</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">"-</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">text</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> +</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted"</span><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="k">return</span> <span class="n">this</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="k">def</span> <span class="nf">_parse_table_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> +</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="n">table</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">table</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">Identifier</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"."</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">name</span><span class="p">:</span> +</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a> <span class="n">catalog</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a> <span class="n">t</span><span class="o">.</span><span class="n">cast</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="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">x</span><span class="p">))</span> +</span><span id="L-277"><a href="#L-277"><span class="linenos">277</span></a> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">split_num_words</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="s2">"."</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> +</span><span id="L-278"><a href="#L-278"><span class="linenos">278</span></a> <span class="p">)</span> +</span><span id="L-279"><a href="#L-279"><span class="linenos">279</span></a> +</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a> <span class="k">if</span> <span class="n">rest</span> <span class="ow">and</span> <span class="n">this</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">exp</span><span class="o">.</span><span class="n">Dot</span><span class="o">.</span><span class="n">build</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">cast</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="p">[</span><span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="p">]))</span> +</span><span id="L-282"><a href="#L-282"><span class="linenos">282</span></a> +</span><span id="L-283"><a href="#L-283"><span class="linenos">283</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="n">db</span><span class="p">,</span> <span class="n">catalog</span><span class="o">=</span><span class="n">catalog</span><span class="p">)</span> +</span><span id="L-284"><a href="#L-284"><span class="linenos">284</span></a> +</span><span id="L-285"><a href="#L-285"><span class="linenos">285</span></a> <span class="k">return</span> <span class="n">table</span> +</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a> +</span><span id="L-287"><a href="#L-287"><span class="linenos">287</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-288"><a href="#L-288"><span class="linenos">288</span></a> <span class="n">EXPLICIT_UNION</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> +</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a> +</span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-296"><a href="#L-296"><span class="linenos">296</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-297"><a href="#L-297"><span class="linenos">297</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_COUNT_DISTINCT"</span><span class="p">),</span> +</span><span id="L-298"><a href="#L-298"><span class="linenos">298</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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-299"><a href="#L-299"><span class="linenos">299</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</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-300"><a href="#L-300"><span class="linenos">300</span></a> <span class="s2">"TIMESTAMP"</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">"DATETIME"</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">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">"zone"</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="n">exp</span><span class="o">.</span><span class="n">Cast</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">remove_precision_parameterized_types</span><span class="p">]),</span> +</span><span id="L-303"><a href="#L-303"><span class="linenos">303</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="L-305"><a href="#L-305"><span class="linenos">305</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="L-306"><a href="#L-306"><span class="linenos">306</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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="sa">f</span><span class="s2">"DATE_DIFF(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">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="s1">'DAY'</span><span class="p">))</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">datestrtodate_sql</span><span class="p">,</span> +</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</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">"DATE_TRUNC"</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">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)),</span> +</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRING_AGG"</span><span class="p">),</span> +</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> +</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DIV"</span><span class="p">),</span> +</span><span id="L-313"><a href="#L-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> +</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> +</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</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-316"><a href="#L-316"><span class="linenos">316</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">,</span> +</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-318"><a href="#L-318"><span class="linenos">318</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="L-319"><a href="#L-319"><span class="linenos">319</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">"position"</span><span class="p">),</span> +</span><span id="L-320"><a href="#L-320"><span class="linenos">320</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">"occurrence"</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 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_CONTAINS"</span><span class="p">),</span> +</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a> <span class="p">[</span><span class="n">_unqualify_unnest</span><span class="p">,</span> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">]</span> +</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a> <span class="p">),</span> +</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</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">"PARSE_DATE(</span><span class="si">{</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 class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-327"><a href="#L-327"><span class="linenos">327</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</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">"PARSE_TIMESTAMP(</span><span class="si">{</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 class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-328"><a href="#L-328"><span class="linenos">328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="L-329"><a href="#L-329"><span class="linenos">329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="L-330"><a href="#L-330"><span class="linenos">330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="L-331"><a href="#L-331"><span class="linenos">331</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> +</span><span id="L-333"><a href="#L-333"><span class="linenos">333</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</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">"SAFE_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 </span><span 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">'to'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-334"><a href="#L-334"><span class="linenos">334</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="s2">"bigquery"</span><span class="p">),</span> +</span><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="L-336"><a href="#L-336"><span class="linenos">336</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</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">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-337"><a href="#L-337"><span class="linenos">337</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-338"><a href="#L-338"><span class="linenos">338</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">:</span> <span class="n">_derived_table_values_to_unnest</span><span class="p">,</span> +</span><span id="L-339"><a href="#L-339"><span class="linenos">339</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">_returnsproperty_sql</span><span class="p">,</span> +</span><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> <span class="n">_create_sql</span><span class="p">,</span> +</span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</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="sa">f</span><span class="s2">"TRIM"</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">e</span><span class="o">.</span><span class="n">expression</span><span class="p">),</span> +</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</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">"DETERMINISTIC"</span> +</span><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"IMMUTABLE"</span> +</span><span id="L-344"><a href="#L-344"><span class="linenos">344</span></a> <span class="k">else</span> <span class="s2">"NOT DETERMINISTIC"</span><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_MAPPING</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="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-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">BIGDECIMAL</span><span class="p">:</span> <span class="s2">"BIGNUMERIC"</span><span class="p">,</span> +</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</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">BINARY</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> +</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BOOLEAN</span><span class="p">:</span> <span class="s2">"BOOL"</span><span class="p">,</span> +</span><span id="L-353"><a href="#L-353"><span class="linenos">353</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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">"STRING"</span><span class="p">,</span> +</span><span id="L-354"><a href="#L-354"><span class="linenos">354</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="s2">"NUMERIC"</span><span class="p">,</span> +</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> +</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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">"FLOAT64"</span><span class="p">,</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">INT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="L-358"><a href="#L-358"><span class="linenos">358</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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">"STRING"</span><span class="p">,</span> +</span><span id="L-359"><a href="#L-359"><span class="linenos">359</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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">"STRING"</span><span class="p">,</span> +</span><span id="L-360"><a href="#L-360"><span class="linenos">360</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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="s2">"STRING"</span><span class="p">,</span> +</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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="s2">"DATETIME"</span><span class="p">,</span> +</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="L-364"><a href="#L-364"><span class="linenos">364</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="L-365"><a href="#L-365"><span class="linenos">365</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">TINYINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="L-366"><a href="#L-366"><span class="linenos">366</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">"BYTES"</span><span class="p">,</span> +</span><span id="L-367"><a href="#L-367"><span class="linenos">367</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">"STRING"</span><span class="p">,</span> +</span><span id="L-368"><a href="#L-368"><span class="linenos">368</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">VARIANT</span><span class="p">:</span> <span class="s2">"ANY TYPE"</span><span class="p">,</span> +</span><span id="L-369"><a href="#L-369"><span class="linenos">369</span></a> <span class="p">}</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">commit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-372"><a href="#L-372"><span class="linenos">372</span></a> <span class="k">return</span> <span class="s2">"COMMIT TRANSACTION"</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">rollback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-375"><a href="#L-375"><span class="linenos">375</span></a> <span class="k">return</span> <span class="s2">"ROLLBACK TRANSACTION"</span> +</span><span id="L-371"><a href="#L-371"><span class="linenos">371</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-372"><a href="#L-372"><span class="linenos">372</span></a> <span class="o">**</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 class="p">,</span> +</span><span id="L-373"><a href="#L-373"><span class="linenos">373</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-374"><a href="#L-374"><span class="linenos">374</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="L-375"><a href="#L-375"><span class="linenos">375</span></a> <span class="p">}</span> </span><span id="L-376"><a href="#L-376"><span class="linenos">376</span></a> -</span><span id="L-377"><a href="#L-377"><span class="linenos">377</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-378"><a href="#L-378"><span class="linenos">378</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><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">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-381"><a href="#L-381"><span class="linenos">381</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">"distinct"</span><span class="p">,</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="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"EXCEPT without DISTINCT is not supported in BigQuery"</span><span class="p">)</span> -</span><span id="L-383"><a href="#L-383"><span class="linenos">383</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">' DISTINCT'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-384"><a href="#L-384"><span class="linenos">384</span></a> -</span><span id="L-385"><a href="#L-385"><span class="linenos">385</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-386"><a href="#L-386"><span class="linenos">386</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> -</span><span id="L-387"><a href="#L-387"><span class="linenos">387</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"INTERSECT without DISTINCT is not supported in BigQuery"</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="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">' DISTINCT'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-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">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-391"><a href="#L-391"><span class="linenos">391</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"OPTIONS"</span><span class="p">))</span> +</span><span id="L-377"><a href="#L-377"><span class="linenos">377</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span><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">RESERVED_KEYWORDS</span><span class="p">,</span> <span class="s2">"hash"</span><span class="p">}</span> +</span><span id="L-378"><a href="#L-378"><span class="linenos">378</span></a> +</span><span id="L-379"><a href="#L-379"><span class="linenos">379</span></a> <span class="k">def</span> <span class="nf">array_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-380"><a href="#L-380"><span class="linenos">380</span></a> <span class="n">first_arg</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="L-381"><a href="#L-381"><span class="linenos">381</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">first_arg</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="L-382"><a href="#L-382"><span class="linenos">382</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ARRAY</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">first_arg</span><span class="p">))</span><span class="si">}</span><span class="s2">"</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">return</span> <span class="n">inline_array_sql</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-385"><a href="#L-385"><span class="linenos">385</span></a> +</span><span id="L-386"><a href="#L-386"><span class="linenos">386</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-387"><a href="#L-387"><span class="linenos">387</span></a> <span class="k">return</span> <span class="s2">"BEGIN TRANSACTION"</span> +</span><span id="L-388"><a href="#L-388"><span class="linenos">388</span></a> +</span><span id="L-389"><a href="#L-389"><span class="linenos">389</span></a> <span class="k">def</span> <span class="nf">commit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-390"><a href="#L-390"><span class="linenos">390</span></a> <span class="k">return</span> <span class="s2">"COMMIT TRANSACTION"</span> +</span><span id="L-391"><a href="#L-391"><span class="linenos">391</span></a> +</span><span id="L-392"><a href="#L-392"><span class="linenos">392</span></a> <span class="k">def</span> <span class="nf">rollback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-393"><a href="#L-393"><span class="linenos">393</span></a> <span class="k">return</span> <span class="s2">"ROLLBACK TRANSACTION"</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">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-396"><a href="#L-396"><span class="linenos">396</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><span id="L-397"><a href="#L-397"><span class="linenos">397</span></a> +</span><span id="L-398"><a href="#L-398"><span class="linenos">398</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-399"><a href="#L-399"><span class="linenos">399</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> +</span><span id="L-400"><a href="#L-400"><span class="linenos">400</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"EXCEPT without DISTINCT is not supported in BigQuery"</span><span class="p">)</span> +</span><span id="L-401"><a href="#L-401"><span class="linenos">401</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">' DISTINCT'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-402"><a href="#L-402"><span class="linenos">402</span></a> +</span><span id="L-403"><a href="#L-403"><span class="linenos">403</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-404"><a href="#L-404"><span class="linenos">404</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> +</span><span id="L-405"><a href="#L-405"><span class="linenos">405</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"INTERSECT without DISTINCT is not supported in BigQuery"</span><span class="p">)</span> +</span><span id="L-406"><a href="#L-406"><span class="linenos">406</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">' DISTINCT'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-407"><a href="#L-407"><span class="linenos">407</span></a> +</span><span id="L-408"><a href="#L-408"><span class="linenos">408</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-409"><a href="#L-409"><span class="linenos">409</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"OPTIONS"</span><span class="p">))</span> </span></pre></div> @@ -507,303 +531,358 @@ </div> <a class="headerlink" href="#BigQuery"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery-107"><a href="#BigQuery-107"><span class="linenos">107</span></a><span class="k">class</span> <span class="nc">BigQuery</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> -</span><span id="BigQuery-108"><a href="#BigQuery-108"><span class="linenos">108</span></a> <span class="n">UNNEST_COLUMN_ONLY</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery-109"><a href="#BigQuery-109"><span class="linenos">109</span></a> -</span><span id="BigQuery-110"><a href="#BigQuery-110"><span class="linenos">110</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-111"><a href="#BigQuery-111"><span class="linenos">111</span></a> <span class="s2">"%D"</span><span class="p">:</span> <span class="s2">"%m/</span><span class="si">%d</span><span class="s2">/%y"</span><span class="p">,</span> -</span><span id="BigQuery-112"><a href="#BigQuery-112"><span class="linenos">112</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery-108"><a href="#BigQuery-108"><span class="linenos">108</span></a><span class="k">class</span> <span class="nc">BigQuery</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> +</span><span id="BigQuery-109"><a href="#BigQuery-109"><span class="linenos">109</span></a> <span class="n">UNNEST_COLUMN_ONLY</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery-110"><a href="#BigQuery-110"><span class="linenos">110</span></a> +</span><span id="BigQuery-111"><a href="#BigQuery-111"><span class="linenos">111</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#case_sensitivity</span> +</span><span id="BigQuery-112"><a href="#BigQuery-112"><span class="linenos">112</span></a> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="o">=</span> <span class="kc">None</span> </span><span id="BigQuery-113"><a href="#BigQuery-113"><span class="linenos">113</span></a> -</span><span id="BigQuery-114"><a href="#BigQuery-114"><span class="linenos">114</span></a> <span class="n">FORMAT_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-115"><a href="#BigQuery-115"><span class="linenos">115</span></a> <span class="s2">"DD"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%d</span><span class="s2">"</span><span class="p">,</span> -</span><span id="BigQuery-116"><a href="#BigQuery-116"><span class="linenos">116</span></a> <span class="s2">"MM"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> -</span><span id="BigQuery-117"><a href="#BigQuery-117"><span class="linenos">117</span></a> <span class="s2">"MON"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> -</span><span id="BigQuery-118"><a href="#BigQuery-118"><span class="linenos">118</span></a> <span class="s2">"MONTH"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> -</span><span id="BigQuery-119"><a href="#BigQuery-119"><span class="linenos">119</span></a> <span class="s2">"YYYY"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> -</span><span id="BigQuery-120"><a href="#BigQuery-120"><span class="linenos">120</span></a> <span class="s2">"YY"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> -</span><span id="BigQuery-121"><a href="#BigQuery-121"><span class="linenos">121</span></a> <span class="s2">"HH"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> -</span><span id="BigQuery-122"><a href="#BigQuery-122"><span class="linenos">122</span></a> <span class="s2">"HH12"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> -</span><span id="BigQuery-123"><a href="#BigQuery-123"><span class="linenos">123</span></a> <span class="s2">"HH24"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> -</span><span id="BigQuery-124"><a href="#BigQuery-124"><span class="linenos">124</span></a> <span class="s2">"MI"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> -</span><span id="BigQuery-125"><a href="#BigQuery-125"><span class="linenos">125</span></a> <span class="s2">"SS"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> -</span><span id="BigQuery-126"><a href="#BigQuery-126"><span class="linenos">126</span></a> <span class="s2">"SSSSS"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> -</span><span id="BigQuery-127"><a href="#BigQuery-127"><span class="linenos">127</span></a> <span class="s2">"TZH"</span><span class="p">:</span> <span class="s2">"%z"</span><span class="p">,</span> -</span><span id="BigQuery-128"><a href="#BigQuery-128"><span class="linenos">128</span></a> <span class="p">}</span> -</span><span id="BigQuery-129"><a href="#BigQuery-129"><span class="linenos">129</span></a> -</span><span id="BigQuery-130"><a href="#BigQuery-130"><span class="linenos">130</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="BigQuery-131"><a href="#BigQuery-131"><span class="linenos">131</span></a> <span class="n">QUOTES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">,</span> <span class="s1">'"'</span><span class="p">,</span> <span class="s1">'"""'</span><span class="p">,</span> <span class="s2">"'''"</span><span class="p">]</span> -</span><span id="BigQuery-132"><a href="#BigQuery-132"><span class="linenos">132</span></a> <span class="n">COMMENTS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--"</span><span class="p">,</span> <span class="s2">"#"</span><span class="p">,</span> <span class="p">(</span><span class="s2">"/*"</span><span class="p">,</span> <span class="s2">"*/"</span><span class="p">)]</span> -</span><span id="BigQuery-133"><a href="#BigQuery-133"><span class="linenos">133</span></a> <span class="n">IDENTIFIERS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"`"</span><span class="p">]</span> -</span><span id="BigQuery-134"><a href="#BigQuery-134"><span class="linenos">134</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">]</span> -</span><span id="BigQuery-135"><a href="#BigQuery-135"><span class="linenos">135</span></a> -</span><span id="BigQuery-136"><a href="#BigQuery-136"><span class="linenos">136</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"0x"</span><span class="p">,</span> <span class="s2">""</span><span class="p">),</span> <span class="p">(</span><span class="s2">"0X"</span><span class="p">,</span> <span class="s2">""</span><span class="p">)]</span> -</span><span id="BigQuery-137"><a href="#BigQuery-137"><span class="linenos">137</span></a> -</span><span id="BigQuery-138"><a href="#BigQuery-138"><span class="linenos">138</span></a> <span class="n">BYTE_STRINGS</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="BigQuery-139"><a href="#BigQuery-139"><span class="linenos">139</span></a> <span class="p">(</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">q</span><span class="p">,</span> <span class="n">q</span><span class="p">)</span> <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">QUOTES</span><span class="p">)</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"b"</span><span class="p">,</span> <span class="s2">"B"</span><span class="p">)</span> -</span><span id="BigQuery-140"><a href="#BigQuery-140"><span class="linenos">140</span></a> <span class="p">]</span> -</span><span id="BigQuery-141"><a href="#BigQuery-141"><span class="linenos">141</span></a> -</span><span id="BigQuery-142"><a href="#BigQuery-142"><span class="linenos">142</span></a> <span class="n">RAW_STRINGS</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="BigQuery-143"><a href="#BigQuery-143"><span class="linenos">143</span></a> <span class="p">(</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">q</span><span class="p">,</span> <span class="n">q</span><span class="p">)</span> <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">QUOTES</span><span class="p">)</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"r"</span><span class="p">,</span> <span class="s2">"R"</span><span class="p">)</span> -</span><span id="BigQuery-144"><a href="#BigQuery-144"><span class="linenos">144</span></a> <span class="p">]</span> +</span><span id="BigQuery-114"><a href="#BigQuery-114"><span class="linenos">114</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-115"><a href="#BigQuery-115"><span class="linenos">115</span></a> <span class="s2">"%D"</span><span class="p">:</span> <span class="s2">"%m/</span><span class="si">%d</span><span class="s2">/%y"</span><span class="p">,</span> +</span><span id="BigQuery-116"><a href="#BigQuery-116"><span class="linenos">116</span></a> <span class="p">}</span> +</span><span id="BigQuery-117"><a href="#BigQuery-117"><span class="linenos">117</span></a> +</span><span id="BigQuery-118"><a href="#BigQuery-118"><span class="linenos">118</span></a> <span class="n">FORMAT_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-119"><a href="#BigQuery-119"><span class="linenos">119</span></a> <span class="s2">"DD"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%d</span><span class="s2">"</span><span class="p">,</span> +</span><span id="BigQuery-120"><a href="#BigQuery-120"><span class="linenos">120</span></a> <span class="s2">"MM"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> +</span><span id="BigQuery-121"><a href="#BigQuery-121"><span class="linenos">121</span></a> <span class="s2">"MON"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> +</span><span id="BigQuery-122"><a href="#BigQuery-122"><span class="linenos">122</span></a> <span class="s2">"MONTH"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> +</span><span id="BigQuery-123"><a href="#BigQuery-123"><span class="linenos">123</span></a> <span class="s2">"YYYY"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> +</span><span id="BigQuery-124"><a href="#BigQuery-124"><span class="linenos">124</span></a> <span class="s2">"YY"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> +</span><span id="BigQuery-125"><a href="#BigQuery-125"><span class="linenos">125</span></a> <span class="s2">"HH"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> +</span><span id="BigQuery-126"><a href="#BigQuery-126"><span class="linenos">126</span></a> <span class="s2">"HH12"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> +</span><span id="BigQuery-127"><a href="#BigQuery-127"><span class="linenos">127</span></a> <span class="s2">"HH24"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> +</span><span id="BigQuery-128"><a href="#BigQuery-128"><span class="linenos">128</span></a> <span class="s2">"MI"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> +</span><span id="BigQuery-129"><a href="#BigQuery-129"><span class="linenos">129</span></a> <span class="s2">"SS"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> +</span><span id="BigQuery-130"><a href="#BigQuery-130"><span class="linenos">130</span></a> <span class="s2">"SSSSS"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> +</span><span id="BigQuery-131"><a href="#BigQuery-131"><span class="linenos">131</span></a> <span class="s2">"TZH"</span><span class="p">:</span> <span class="s2">"%z"</span><span class="p">,</span> +</span><span id="BigQuery-132"><a href="#BigQuery-132"><span class="linenos">132</span></a> <span class="p">}</span> +</span><span id="BigQuery-133"><a href="#BigQuery-133"><span class="linenos">133</span></a> +</span><span id="BigQuery-134"><a href="#BigQuery-134"><span class="linenos">134</span></a> <span class="nd">@classmethod</span> +</span><span id="BigQuery-135"><a href="#BigQuery-135"><span class="linenos">135</span></a> <span class="k">def</span> <span class="nf">normalize_identifier</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="BigQuery-136"><a href="#BigQuery-136"><span class="linenos">136</span></a> <span class="c1"># In BigQuery, CTEs aren't case-sensitive, but table names are (by default, at least).</span> +</span><span id="BigQuery-137"><a href="#BigQuery-137"><span class="linenos">137</span></a> <span class="c1"># The following check is essentially a heuristic to detect tables based on whether or</span> +</span><span id="BigQuery-138"><a href="#BigQuery-138"><span class="linenos">138</span></a> <span class="c1"># not they're qualified.</span> +</span><span id="BigQuery-139"><a href="#BigQuery-139"><span class="linenos">139</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="BigQuery-140"><a href="#BigQuery-140"><span class="linenos">140</span></a> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> +</span><span id="BigQuery-141"><a href="#BigQuery-141"><span class="linenos">141</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="p">(</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">Table</span><span class="p">)</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">db</span><span class="p">)</span> +</span><span id="BigQuery-142"><a href="#BigQuery-142"><span class="linenos">142</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"is_table"</span><span class="p">)</span> +</span><span id="BigQuery-143"><a href="#BigQuery-143"><span class="linenos">143</span></a> <span class="p">):</span> +</span><span id="BigQuery-144"><a href="#BigQuery-144"><span class="linenos">144</span></a> <span class="n">expression</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">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">lower</span><span class="p">())</span> </span><span id="BigQuery-145"><a href="#BigQuery-145"><span class="linenos">145</span></a> -</span><span id="BigQuery-146"><a href="#BigQuery-146"><span class="linenos">146</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-147"><a href="#BigQuery-147"><span class="linenos">147</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="BigQuery-148"><a href="#BigQuery-148"><span class="linenos">148</span></a> <span class="s2">"ANY TYPE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARIANT</span><span class="p">,</span> -</span><span id="BigQuery-149"><a href="#BigQuery-149"><span class="linenos">149</span></a> <span class="s2">"BEGIN"</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="BigQuery-150"><a href="#BigQuery-150"><span class="linenos">150</span></a> <span class="s2">"BEGIN TRANSACTION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">,</span> -</span><span id="BigQuery-151"><a href="#BigQuery-151"><span class="linenos">151</span></a> <span class="s2">"CURRENT_DATETIME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_DATETIME</span><span class="p">,</span> -</span><span id="BigQuery-152"><a href="#BigQuery-152"><span class="linenos">152</span></a> <span class="s2">"BYTES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BINARY</span><span class="p">,</span> -</span><span id="BigQuery-153"><a href="#BigQuery-153"><span class="linenos">153</span></a> <span class="s2">"DECLARE"</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="BigQuery-154"><a href="#BigQuery-154"><span class="linenos">154</span></a> <span class="s2">"FLOAT64"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> -</span><span id="BigQuery-155"><a href="#BigQuery-155"><span class="linenos">155</span></a> <span class="s2">"INT64"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> -</span><span id="BigQuery-156"><a href="#BigQuery-156"><span class="linenos">156</span></a> <span class="s2">"RECORD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">,</span> -</span><span id="BigQuery-157"><a href="#BigQuery-157"><span class="linenos">157</span></a> <span class="s2">"TIMESTAMP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> -</span><span id="BigQuery-158"><a href="#BigQuery-158"><span class="linenos">158</span></a> <span class="s2">"NOT DETERMINISTIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VOLATILE</span><span class="p">,</span> -</span><span id="BigQuery-159"><a href="#BigQuery-159"><span class="linenos">159</span></a> <span class="s2">"UNKNOWN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">,</span> -</span><span id="BigQuery-160"><a href="#BigQuery-160"><span class="linenos">160</span></a> <span class="p">}</span> -</span><span id="BigQuery-161"><a href="#BigQuery-161"><span class="linenos">161</span></a> <span class="n">KEYWORDS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"DIV"</span><span class="p">)</span> -</span><span id="BigQuery-162"><a href="#BigQuery-162"><span class="linenos">162</span></a> -</span><span id="BigQuery-163"><a href="#BigQuery-163"><span class="linenos">163</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="BigQuery-164"><a href="#BigQuery-164"><span class="linenos">164</span></a> <span class="n">PREFIXED_PIVOT_COLUMNS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery-165"><a href="#BigQuery-165"><span class="linenos">165</span></a> -</span><span id="BigQuery-166"><a href="#BigQuery-166"><span class="linenos">166</span></a> <span class="n">LOG_BASE_FIRST</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery-167"><a href="#BigQuery-167"><span class="linenos">167</span></a> <span class="n">LOG_DEFAULTS_TO_LN</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery-168"><a href="#BigQuery-168"><span class="linenos">168</span></a> -</span><span id="BigQuery-169"><a href="#BigQuery-169"><span class="linenos">169</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-170"><a href="#BigQuery-170"><span class="linenos">170</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="BigQuery-171"><a href="#BigQuery-171"><span class="linenos">171</span></a> <span class="s2">"DATE_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">),</span> -</span><span id="BigQuery-172"><a href="#BigQuery-172"><span class="linenos">172</span></a> <span class="s2">"DATE_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">),</span> -</span><span id="BigQuery-173"><a href="#BigQuery-173"><span class="linenos">173</span></a> <span class="s2">"DATE_TRUNC"</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">DateTrunc</span><span class="p">(</span> -</span><span id="BigQuery-174"><a href="#BigQuery-174"><span class="linenos">174</span></a> <span class="n">unit</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="nb">str</span><span class="p">(</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="BigQuery-175"><a href="#BigQuery-175"><span class="linenos">175</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="BigQuery-176"><a href="#BigQuery-176"><span class="linenos">176</span></a> <span class="p">),</span> -</span><span id="BigQuery-177"><a href="#BigQuery-177"><span class="linenos">177</span></a> <span class="s2">"DATETIME_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">),</span> -</span><span id="BigQuery-178"><a href="#BigQuery-178"><span class="linenos">178</span></a> <span class="s2">"DATETIME_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">),</span> -</span><span id="BigQuery-179"><a href="#BigQuery-179"><span class="linenos">179</span></a> <span class="s2">"DIV"</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">IntDiv</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">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="BigQuery-180"><a href="#BigQuery-180"><span class="linenos">180</span></a> <span class="s2">"PARSE_DATE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">format_time_lambda</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="s2">"bigquery"</span><span class="p">)(</span> -</span><span id="BigQuery-181"><a href="#BigQuery-181"><span class="linenos">181</span></a> <span class="p">[</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">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="BigQuery-182"><a href="#BigQuery-182"><span class="linenos">182</span></a> <span class="p">),</span> -</span><span id="BigQuery-183"><a href="#BigQuery-183"><span class="linenos">183</span></a> <span class="s2">"PARSE_TIMESTAMP"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">format_time_lambda</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">"bigquery"</span><span class="p">)(</span> -</span><span id="BigQuery-184"><a href="#BigQuery-184"><span class="linenos">184</span></a> <span class="p">[</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">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="BigQuery-185"><a href="#BigQuery-185"><span class="linenos">185</span></a> <span class="p">),</span> -</span><span id="BigQuery-186"><a href="#BigQuery-186"><span class="linenos">186</span></a> <span class="s2">"REGEXP_CONTAINS"</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="BigQuery-187"><a href="#BigQuery-187"><span class="linenos">187</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="BigQuery-188"><a href="#BigQuery-188"><span class="linenos">188</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="BigQuery-189"><a href="#BigQuery-189"><span class="linenos">189</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="BigQuery-190"><a href="#BigQuery-190"><span class="linenos">190</span></a> <span class="n">position</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="BigQuery-191"><a href="#BigQuery-191"><span class="linenos">191</span></a> <span class="n">occurrence</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="BigQuery-192"><a href="#BigQuery-192"><span class="linenos">192</span></a> <span class="n">group</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> -</span><span id="BigQuery-193"><a href="#BigQuery-193"><span class="linenos">193</span></a> <span class="k">if</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="nb">str</span><span class="p">(</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="o">.</span><span class="n">groups</span> <span class="o">==</span> <span class="mi">1</span> -</span><span id="BigQuery-194"><a href="#BigQuery-194"><span class="linenos">194</span></a> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="BigQuery-195"><a href="#BigQuery-195"><span class="linenos">195</span></a> <span class="p">),</span> -</span><span id="BigQuery-196"><a href="#BigQuery-196"><span class="linenos">196</span></a> <span class="s2">"SPLIT"</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">Split</span><span class="p">(</span> -</span><span id="BigQuery-197"><a href="#BigQuery-197"><span class="linenos">197</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#split</span> -</span><span id="BigQuery-198"><a href="#BigQuery-198"><span class="linenos">198</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="BigQuery-199"><a href="#BigQuery-199"><span class="linenos">199</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 class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">","</span><span class="p">),</span> +</span><span id="BigQuery-146"><a href="#BigQuery-146"><span class="linenos">146</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="BigQuery-147"><a href="#BigQuery-147"><span class="linenos">147</span></a> +</span><span id="BigQuery-148"><a href="#BigQuery-148"><span class="linenos">148</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="BigQuery-149"><a href="#BigQuery-149"><span class="linenos">149</span></a> <span class="n">QUOTES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">,</span> <span class="s1">'"'</span><span class="p">,</span> <span class="s1">'"""'</span><span class="p">,</span> <span class="s2">"'''"</span><span class="p">]</span> +</span><span id="BigQuery-150"><a href="#BigQuery-150"><span class="linenos">150</span></a> <span class="n">COMMENTS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--"</span><span class="p">,</span> <span class="s2">"#"</span><span class="p">,</span> <span class="p">(</span><span class="s2">"/*"</span><span class="p">,</span> <span class="s2">"*/"</span><span class="p">)]</span> +</span><span id="BigQuery-151"><a href="#BigQuery-151"><span class="linenos">151</span></a> <span class="n">IDENTIFIERS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"`"</span><span class="p">]</span> +</span><span id="BigQuery-152"><a href="#BigQuery-152"><span class="linenos">152</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">]</span> +</span><span id="BigQuery-153"><a href="#BigQuery-153"><span class="linenos">153</span></a> +</span><span id="BigQuery-154"><a href="#BigQuery-154"><span class="linenos">154</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"0x"</span><span class="p">,</span> <span class="s2">""</span><span class="p">),</span> <span class="p">(</span><span class="s2">"0X"</span><span class="p">,</span> <span class="s2">""</span><span class="p">)]</span> +</span><span id="BigQuery-155"><a href="#BigQuery-155"><span class="linenos">155</span></a> +</span><span id="BigQuery-156"><a href="#BigQuery-156"><span class="linenos">156</span></a> <span class="n">BYTE_STRINGS</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="BigQuery-157"><a href="#BigQuery-157"><span class="linenos">157</span></a> <span class="p">(</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">q</span><span class="p">,</span> <span class="n">q</span><span class="p">)</span> <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">QUOTES</span><span class="p">)</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"b"</span><span class="p">,</span> <span class="s2">"B"</span><span class="p">)</span> +</span><span id="BigQuery-158"><a href="#BigQuery-158"><span class="linenos">158</span></a> <span class="p">]</span> +</span><span id="BigQuery-159"><a href="#BigQuery-159"><span class="linenos">159</span></a> +</span><span id="BigQuery-160"><a href="#BigQuery-160"><span class="linenos">160</span></a> <span class="n">RAW_STRINGS</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="BigQuery-161"><a href="#BigQuery-161"><span class="linenos">161</span></a> <span class="p">(</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">q</span><span class="p">,</span> <span class="n">q</span><span class="p">)</span> <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">QUOTES</span><span class="p">)</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"r"</span><span class="p">,</span> <span class="s2">"R"</span><span class="p">)</span> +</span><span id="BigQuery-162"><a href="#BigQuery-162"><span class="linenos">162</span></a> <span class="p">]</span> +</span><span id="BigQuery-163"><a href="#BigQuery-163"><span class="linenos">163</span></a> +</span><span id="BigQuery-164"><a href="#BigQuery-164"><span class="linenos">164</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-165"><a href="#BigQuery-165"><span class="linenos">165</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="BigQuery-166"><a href="#BigQuery-166"><span class="linenos">166</span></a> <span class="s2">"ANY TYPE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARIANT</span><span class="p">,</span> +</span><span id="BigQuery-167"><a href="#BigQuery-167"><span class="linenos">167</span></a> <span class="s2">"BEGIN"</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="BigQuery-168"><a href="#BigQuery-168"><span class="linenos">168</span></a> <span class="s2">"BEGIN TRANSACTION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">,</span> +</span><span id="BigQuery-169"><a href="#BigQuery-169"><span class="linenos">169</span></a> <span class="s2">"CURRENT_DATETIME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_DATETIME</span><span class="p">,</span> +</span><span id="BigQuery-170"><a href="#BigQuery-170"><span class="linenos">170</span></a> <span class="s2">"BYTES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BINARY</span><span class="p">,</span> +</span><span id="BigQuery-171"><a href="#BigQuery-171"><span class="linenos">171</span></a> <span class="s2">"DECLARE"</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="BigQuery-172"><a href="#BigQuery-172"><span class="linenos">172</span></a> <span class="s2">"FLOAT64"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> +</span><span id="BigQuery-173"><a href="#BigQuery-173"><span class="linenos">173</span></a> <span class="s2">"INT64"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> +</span><span id="BigQuery-174"><a href="#BigQuery-174"><span class="linenos">174</span></a> <span class="s2">"RECORD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">,</span> +</span><span id="BigQuery-175"><a href="#BigQuery-175"><span class="linenos">175</span></a> <span class="s2">"TIMESTAMP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> +</span><span id="BigQuery-176"><a href="#BigQuery-176"><span class="linenos">176</span></a> <span class="s2">"NOT DETERMINISTIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VOLATILE</span><span class="p">,</span> +</span><span id="BigQuery-177"><a href="#BigQuery-177"><span class="linenos">177</span></a> <span class="s2">"UNKNOWN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">,</span> +</span><span id="BigQuery-178"><a href="#BigQuery-178"><span class="linenos">178</span></a> <span class="p">}</span> +</span><span id="BigQuery-179"><a href="#BigQuery-179"><span class="linenos">179</span></a> <span class="n">KEYWORDS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"DIV"</span><span class="p">)</span> +</span><span id="BigQuery-180"><a href="#BigQuery-180"><span class="linenos">180</span></a> +</span><span id="BigQuery-181"><a href="#BigQuery-181"><span class="linenos">181</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="BigQuery-182"><a href="#BigQuery-182"><span class="linenos">182</span></a> <span class="n">PREFIXED_PIVOT_COLUMNS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery-183"><a href="#BigQuery-183"><span class="linenos">183</span></a> +</span><span id="BigQuery-184"><a href="#BigQuery-184"><span class="linenos">184</span></a> <span class="n">LOG_BASE_FIRST</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery-185"><a href="#BigQuery-185"><span class="linenos">185</span></a> <span class="n">LOG_DEFAULTS_TO_LN</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery-186"><a href="#BigQuery-186"><span class="linenos">186</span></a> +</span><span id="BigQuery-187"><a href="#BigQuery-187"><span class="linenos">187</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-188"><a href="#BigQuery-188"><span class="linenos">188</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="BigQuery-189"><a href="#BigQuery-189"><span class="linenos">189</span></a> <span class="s2">"DATE_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">),</span> +</span><span id="BigQuery-190"><a href="#BigQuery-190"><span class="linenos">190</span></a> <span class="s2">"DATE_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">),</span> +</span><span id="BigQuery-191"><a href="#BigQuery-191"><span class="linenos">191</span></a> <span class="s2">"DATE_TRUNC"</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">DateTrunc</span><span class="p">(</span> +</span><span id="BigQuery-192"><a href="#BigQuery-192"><span class="linenos">192</span></a> <span class="n">unit</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="nb">str</span><span class="p">(</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="BigQuery-193"><a href="#BigQuery-193"><span class="linenos">193</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="BigQuery-194"><a href="#BigQuery-194"><span class="linenos">194</span></a> <span class="p">),</span> +</span><span id="BigQuery-195"><a href="#BigQuery-195"><span class="linenos">195</span></a> <span class="s2">"DATETIME_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">),</span> +</span><span id="BigQuery-196"><a href="#BigQuery-196"><span class="linenos">196</span></a> <span class="s2">"DATETIME_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">),</span> +</span><span id="BigQuery-197"><a href="#BigQuery-197"><span class="linenos">197</span></a> <span class="s2">"DIV"</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">IntDiv</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">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="BigQuery-198"><a href="#BigQuery-198"><span class="linenos">198</span></a> <span class="s2">"PARSE_DATE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">format_time_lambda</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="s2">"bigquery"</span><span class="p">)(</span> +</span><span id="BigQuery-199"><a href="#BigQuery-199"><span class="linenos">199</span></a> <span class="p">[</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">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="BigQuery-200"><a href="#BigQuery-200"><span class="linenos">200</span></a> <span class="p">),</span> -</span><span id="BigQuery-201"><a href="#BigQuery-201"><span class="linenos">201</span></a> <span class="s2">"TIME_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">),</span> -</span><span id="BigQuery-202"><a href="#BigQuery-202"><span class="linenos">202</span></a> <span class="s2">"TIME_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeSub</span><span class="p">),</span> -</span><span id="BigQuery-203"><a href="#BigQuery-203"><span class="linenos">203</span></a> <span class="s2">"TIMESTAMP_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimestampAdd</span><span class="p">),</span> -</span><span id="BigQuery-204"><a href="#BigQuery-204"><span class="linenos">204</span></a> <span class="s2">"TIMESTAMP_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimestampSub</span><span class="p">),</span> -</span><span id="BigQuery-205"><a href="#BigQuery-205"><span class="linenos">205</span></a> <span class="p">}</span> -</span><span id="BigQuery-206"><a href="#BigQuery-206"><span class="linenos">206</span></a> -</span><span id="BigQuery-207"><a href="#BigQuery-207"><span class="linenos">207</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-208"><a href="#BigQuery-208"><span class="linenos">208</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">FUNCTION_PARSERS</span><span class="p">,</span> -</span><span id="BigQuery-209"><a href="#BigQuery-209"><span class="linenos">209</span></a> <span class="s2">"ARRAY"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">()]),</span> -</span><span id="BigQuery-210"><a href="#BigQuery-210"><span class="linenos">210</span></a> <span class="p">}</span> -</span><span id="BigQuery-211"><a href="#BigQuery-211"><span class="linenos">211</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> -</span><span id="BigQuery-212"><a href="#BigQuery-212"><span class="linenos">212</span></a> -</span><span id="BigQuery-213"><a href="#BigQuery-213"><span class="linenos">213</span></a> <span class="n">NO_PAREN_FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-214"><a href="#BigQuery-214"><span class="linenos">214</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_FUNCTIONS</span><span class="p">,</span> -</span><span id="BigQuery-215"><a href="#BigQuery-215"><span class="linenos">215</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_DATETIME</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDatetime</span><span class="p">,</span> -</span><span id="BigQuery-216"><a href="#BigQuery-216"><span class="linenos">216</span></a> <span class="p">}</span> -</span><span id="BigQuery-217"><a href="#BigQuery-217"><span class="linenos">217</span></a> -</span><span id="BigQuery-218"><a href="#BigQuery-218"><span class="linenos">218</span></a> <span class="n">NESTED_TYPE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-219"><a href="#BigQuery-219"><span class="linenos">219</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">NESTED_TYPE_TOKENS</span><span class="p">,</span> -</span><span id="BigQuery-220"><a href="#BigQuery-220"><span class="linenos">220</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> -</span><span id="BigQuery-221"><a href="#BigQuery-221"><span class="linenos">221</span></a> <span class="p">}</span> -</span><span id="BigQuery-222"><a href="#BigQuery-222"><span class="linenos">222</span></a> -</span><span id="BigQuery-223"><a href="#BigQuery-223"><span class="linenos">223</span></a> <span class="n">ID_VAR_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-224"><a href="#BigQuery-224"><span class="linenos">224</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">ID_VAR_TOKENS</span><span class="p">,</span> -</span><span id="BigQuery-225"><a href="#BigQuery-225"><span class="linenos">225</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">VALUES</span><span class="p">,</span> -</span><span id="BigQuery-226"><a href="#BigQuery-226"><span class="linenos">226</span></a> <span class="p">}</span> -</span><span id="BigQuery-227"><a href="#BigQuery-227"><span class="linenos">227</span></a> -</span><span id="BigQuery-228"><a href="#BigQuery-228"><span class="linenos">228</span></a> <span class="n">PROPERTY_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-229"><a href="#BigQuery-229"><span class="linenos">229</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">PROPERTY_PARSERS</span><span class="p">,</span> -</span><span id="BigQuery-230"><a href="#BigQuery-230"><span class="linenos">230</span></a> <span class="s2">"NOT DETERMINISTIC"</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">expression</span><span class="p">(</span> -</span><span id="BigQuery-231"><a href="#BigQuery-231"><span class="linenos">231</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"VOLATILE"</span><span class="p">)</span> -</span><span id="BigQuery-232"><a href="#BigQuery-232"><span class="linenos">232</span></a> <span class="p">),</span> -</span><span id="BigQuery-233"><a href="#BigQuery-233"><span class="linenos">233</span></a> <span class="s2">"OPTIONS"</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_with_property</span><span class="p">(),</span> +</span><span id="BigQuery-201"><a href="#BigQuery-201"><span class="linenos">201</span></a> <span class="s2">"PARSE_TIMESTAMP"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">format_time_lambda</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">"bigquery"</span><span class="p">)(</span> +</span><span id="BigQuery-202"><a href="#BigQuery-202"><span class="linenos">202</span></a> <span class="p">[</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">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="BigQuery-203"><a href="#BigQuery-203"><span class="linenos">203</span></a> <span class="p">),</span> +</span><span id="BigQuery-204"><a href="#BigQuery-204"><span class="linenos">204</span></a> <span class="s2">"REGEXP_CONTAINS"</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="BigQuery-205"><a href="#BigQuery-205"><span class="linenos">205</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="BigQuery-206"><a href="#BigQuery-206"><span class="linenos">206</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="BigQuery-207"><a href="#BigQuery-207"><span class="linenos">207</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="BigQuery-208"><a href="#BigQuery-208"><span class="linenos">208</span></a> <span class="n">position</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="BigQuery-209"><a href="#BigQuery-209"><span class="linenos">209</span></a> <span class="n">occurrence</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="BigQuery-210"><a href="#BigQuery-210"><span class="linenos">210</span></a> <span class="n">group</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> +</span><span id="BigQuery-211"><a href="#BigQuery-211"><span class="linenos">211</span></a> <span class="k">if</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="nb">str</span><span class="p">(</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="o">.</span><span class="n">groups</span> <span class="o">==</span> <span class="mi">1</span> +</span><span id="BigQuery-212"><a href="#BigQuery-212"><span class="linenos">212</span></a> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="BigQuery-213"><a href="#BigQuery-213"><span class="linenos">213</span></a> <span class="p">),</span> +</span><span id="BigQuery-214"><a href="#BigQuery-214"><span class="linenos">214</span></a> <span class="s2">"SPLIT"</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">Split</span><span class="p">(</span> +</span><span id="BigQuery-215"><a href="#BigQuery-215"><span class="linenos">215</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#split</span> +</span><span id="BigQuery-216"><a href="#BigQuery-216"><span class="linenos">216</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="BigQuery-217"><a href="#BigQuery-217"><span class="linenos">217</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 class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">","</span><span class="p">),</span> +</span><span id="BigQuery-218"><a href="#BigQuery-218"><span class="linenos">218</span></a> <span class="p">),</span> +</span><span id="BigQuery-219"><a href="#BigQuery-219"><span class="linenos">219</span></a> <span class="s2">"TIME_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">),</span> +</span><span id="BigQuery-220"><a href="#BigQuery-220"><span class="linenos">220</span></a> <span class="s2">"TIME_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeSub</span><span class="p">),</span> +</span><span id="BigQuery-221"><a href="#BigQuery-221"><span class="linenos">221</span></a> <span class="s2">"TIMESTAMP_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimestampAdd</span><span class="p">),</span> +</span><span id="BigQuery-222"><a href="#BigQuery-222"><span class="linenos">222</span></a> <span class="s2">"TIMESTAMP_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimestampSub</span><span class="p">),</span> +</span><span id="BigQuery-223"><a href="#BigQuery-223"><span class="linenos">223</span></a> <span class="p">}</span> +</span><span id="BigQuery-224"><a href="#BigQuery-224"><span class="linenos">224</span></a> +</span><span id="BigQuery-225"><a href="#BigQuery-225"><span class="linenos">225</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-226"><a href="#BigQuery-226"><span class="linenos">226</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">FUNCTION_PARSERS</span><span class="p">,</span> +</span><span id="BigQuery-227"><a href="#BigQuery-227"><span class="linenos">227</span></a> <span class="s2">"ARRAY"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">()]),</span> +</span><span id="BigQuery-228"><a href="#BigQuery-228"><span class="linenos">228</span></a> <span class="p">}</span> +</span><span id="BigQuery-229"><a href="#BigQuery-229"><span class="linenos">229</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> +</span><span id="BigQuery-230"><a href="#BigQuery-230"><span class="linenos">230</span></a> +</span><span id="BigQuery-231"><a href="#BigQuery-231"><span class="linenos">231</span></a> <span class="n">NO_PAREN_FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-232"><a href="#BigQuery-232"><span class="linenos">232</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_FUNCTIONS</span><span class="p">,</span> +</span><span id="BigQuery-233"><a href="#BigQuery-233"><span class="linenos">233</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_DATETIME</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDatetime</span><span class="p">,</span> </span><span id="BigQuery-234"><a href="#BigQuery-234"><span class="linenos">234</span></a> <span class="p">}</span> </span><span id="BigQuery-235"><a href="#BigQuery-235"><span class="linenos">235</span></a> -</span><span id="BigQuery-236"><a href="#BigQuery-236"><span class="linenos">236</span></a> <span class="n">CONSTRAINT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-237"><a href="#BigQuery-237"><span class="linenos">237</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">CONSTRAINT_PARSERS</span><span class="p">,</span> -</span><span id="BigQuery-238"><a href="#BigQuery-238"><span class="linenos">238</span></a> <span class="s2">"OPTIONS"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_with_property</span><span class="p">()),</span> +</span><span id="BigQuery-236"><a href="#BigQuery-236"><span class="linenos">236</span></a> <span class="n">NESTED_TYPE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-237"><a href="#BigQuery-237"><span class="linenos">237</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">NESTED_TYPE_TOKENS</span><span class="p">,</span> +</span><span id="BigQuery-238"><a href="#BigQuery-238"><span class="linenos">238</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> </span><span id="BigQuery-239"><a href="#BigQuery-239"><span class="linenos">239</span></a> <span class="p">}</span> </span><span id="BigQuery-240"><a href="#BigQuery-240"><span class="linenos">240</span></a> -</span><span id="BigQuery-241"><a href="#BigQuery-241"><span class="linenos">241</span></a> <span class="k">def</span> <span class="nf">_parse_table_part</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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="BigQuery-242"><a href="#BigQuery-242"><span class="linenos">242</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="BigQuery-243"><a href="#BigQuery-243"><span class="linenos">243</span></a> -</span><span id="BigQuery-244"><a href="#BigQuery-244"><span class="linenos">244</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#table_names</span> -</span><span id="BigQuery-245"><a href="#BigQuery-245"><span class="linenos">245</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">Identifier</span><span class="p">):</span> -</span><span id="BigQuery-246"><a href="#BigQuery-246"><span class="linenos">246</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> -</span><span id="BigQuery-247"><a href="#BigQuery-247"><span class="linenos">247</span></a> <span class="k">while</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">DASH</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> -</span><span id="BigQuery-248"><a href="#BigQuery-248"><span class="linenos">248</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> -</span><span id="BigQuery-249"><a href="#BigQuery-249"><span class="linenos">249</span></a> <span class="n">table_name</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">"-</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">text</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery-250"><a href="#BigQuery-250"><span class="linenos">250</span></a> -</span><span id="BigQuery-251"><a href="#BigQuery-251"><span class="linenos">251</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted"</span><span class="p">))</span> -</span><span id="BigQuery-252"><a href="#BigQuery-252"><span class="linenos">252</span></a> -</span><span id="BigQuery-253"><a href="#BigQuery-253"><span class="linenos">253</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="BigQuery-254"><a href="#BigQuery-254"><span class="linenos">254</span></a> -</span><span id="BigQuery-255"><a href="#BigQuery-255"><span class="linenos">255</span></a> <span class="k">def</span> <span class="nf">_parse_table_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> -</span><span id="BigQuery-256"><a href="#BigQuery-256"><span class="linenos">256</span></a> <span class="n">table</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="BigQuery-257"><a href="#BigQuery-257"><span class="linenos">257</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">table</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">Identifier</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"."</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">name</span><span class="p">:</span> -</span><span id="BigQuery-258"><a href="#BigQuery-258"><span class="linenos">258</span></a> <span class="n">catalog</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="BigQuery-259"><a href="#BigQuery-259"><span class="linenos">259</span></a> <span class="n">t</span><span class="o">.</span><span class="n">cast</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="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">x</span><span class="p">))</span> -</span><span id="BigQuery-260"><a href="#BigQuery-260"><span class="linenos">260</span></a> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">split_num_words</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="s2">"."</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> -</span><span id="BigQuery-261"><a href="#BigQuery-261"><span class="linenos">261</span></a> <span class="p">)</span> -</span><span id="BigQuery-262"><a href="#BigQuery-262"><span class="linenos">262</span></a> -</span><span id="BigQuery-263"><a href="#BigQuery-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">rest</span> <span class="ow">and</span> <span class="n">this</span><span class="p">:</span> -</span><span id="BigQuery-264"><a href="#BigQuery-264"><span class="linenos">264</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="o">.</span><span class="n">build</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">cast</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="p">[</span><span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="p">]))</span> -</span><span id="BigQuery-265"><a href="#BigQuery-265"><span class="linenos">265</span></a> -</span><span id="BigQuery-266"><a href="#BigQuery-266"><span class="linenos">266</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="n">db</span><span class="p">,</span> <span class="n">catalog</span><span class="o">=</span><span class="n">catalog</span><span class="p">)</span> -</span><span id="BigQuery-267"><a href="#BigQuery-267"><span class="linenos">267</span></a> -</span><span id="BigQuery-268"><a href="#BigQuery-268"><span class="linenos">268</span></a> <span class="k">return</span> <span class="n">table</span> -</span><span id="BigQuery-269"><a href="#BigQuery-269"><span class="linenos">269</span></a> -</span><span id="BigQuery-270"><a href="#BigQuery-270"><span class="linenos">270</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="BigQuery-271"><a href="#BigQuery-271"><span class="linenos">271</span></a> <span class="n">EXPLICIT_UNION</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery-272"><a href="#BigQuery-272"><span class="linenos">272</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery-273"><a href="#BigQuery-273"><span class="linenos">273</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery-274"><a href="#BigQuery-274"><span class="linenos">274</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery-275"><a href="#BigQuery-275"><span class="linenos">275</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> -</span><span id="BigQuery-276"><a href="#BigQuery-276"><span class="linenos">276</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery-277"><a href="#BigQuery-277"><span class="linenos">277</span></a> -</span><span id="BigQuery-278"><a href="#BigQuery-278"><span class="linenos">278</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-279"><a href="#BigQuery-279"><span class="linenos">279</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="BigQuery-280"><a href="#BigQuery-280"><span class="linenos">280</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_COUNT_DISTINCT"</span><span class="p">),</span> -</span><span id="BigQuery-281"><a href="#BigQuery-281"><span class="linenos">281</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="BigQuery-282"><a href="#BigQuery-282"><span class="linenos">282</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</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="BigQuery-283"><a href="#BigQuery-283"><span class="linenos">283</span></a> <span class="s2">"TIMESTAMP"</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">"DATETIME"</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">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">"zone"</span><span class="p">))</span> -</span><span id="BigQuery-284"><a href="#BigQuery-284"><span class="linenos">284</span></a> <span class="p">),</span> -</span><span id="BigQuery-285"><a href="#BigQuery-285"><span class="linenos">285</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</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">remove_precision_parameterized_types</span><span class="p">]),</span> -</span><span id="BigQuery-286"><a href="#BigQuery-286"><span class="linenos">286</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="BigQuery-287"><a href="#BigQuery-287"><span class="linenos">287</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="BigQuery-288"><a href="#BigQuery-288"><span class="linenos">288</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="BigQuery-289"><a href="#BigQuery-289"><span class="linenos">289</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="BigQuery-290"><a href="#BigQuery-290"><span class="linenos">290</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="sa">f</span><span class="s2">"DATE_DIFF(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">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="s1">'DAY'</span><span class="p">))</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="BigQuery-291"><a href="#BigQuery-291"><span class="linenos">291</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="BigQuery-292"><a href="#BigQuery-292"><span class="linenos">292</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</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">"DATE_TRUNC"</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">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)),</span> -</span><span id="BigQuery-293"><a href="#BigQuery-293"><span class="linenos">293</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRING_AGG"</span><span class="p">),</span> -</span><span id="BigQuery-294"><a href="#BigQuery-294"><span class="linenos">294</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> -</span><span id="BigQuery-295"><a href="#BigQuery-295"><span class="linenos">295</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DIV"</span><span class="p">),</span> -</span><span id="BigQuery-296"><a href="#BigQuery-296"><span class="linenos">296</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> -</span><span id="BigQuery-297"><a href="#BigQuery-297"><span class="linenos">297</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> -</span><span id="BigQuery-298"><a href="#BigQuery-298"><span class="linenos">298</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</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="BigQuery-299"><a href="#BigQuery-299"><span class="linenos">299</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">,</span> -</span><span id="BigQuery-300"><a href="#BigQuery-300"><span class="linenos">300</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="BigQuery-301"><a href="#BigQuery-301"><span class="linenos">301</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="BigQuery-302"><a href="#BigQuery-302"><span class="linenos">302</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">"position"</span><span class="p">),</span> -</span><span id="BigQuery-303"><a href="#BigQuery-303"><span class="linenos">303</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">"occurrence"</span><span class="p">),</span> -</span><span id="BigQuery-304"><a href="#BigQuery-304"><span class="linenos">304</span></a> <span class="p">),</span> -</span><span id="BigQuery-305"><a href="#BigQuery-305"><span class="linenos">305</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_CONTAINS"</span><span class="p">),</span> -</span><span id="BigQuery-306"><a href="#BigQuery-306"><span class="linenos">306</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="BigQuery-307"><a href="#BigQuery-307"><span class="linenos">307</span></a> <span class="p">[</span><span class="n">_unqualify_unnest</span><span class="p">,</span> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">]</span> -</span><span id="BigQuery-308"><a href="#BigQuery-308"><span class="linenos">308</span></a> <span class="p">),</span> -</span><span id="BigQuery-309"><a href="#BigQuery-309"><span class="linenos">309</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</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">"PARSE_DATE(</span><span class="si">{</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 class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="BigQuery-310"><a href="#BigQuery-310"><span class="linenos">310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</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">"PARSE_TIMESTAMP(</span><span class="si">{</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 class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="BigQuery-311"><a href="#BigQuery-311"><span class="linenos">311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="BigQuery-312"><a href="#BigQuery-312"><span class="linenos">312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="BigQuery-313"><a href="#BigQuery-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="BigQuery-314"><a href="#BigQuery-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="BigQuery-315"><a href="#BigQuery-315"><span class="linenos">315</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="BigQuery-316"><a href="#BigQuery-316"><span class="linenos">316</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</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">"SAFE_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 </span><span 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">'to'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="BigQuery-317"><a href="#BigQuery-317"><span class="linenos">317</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="s2">"bigquery"</span><span class="p">),</span> -</span><span id="BigQuery-318"><a href="#BigQuery-318"><span class="linenos">318</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="BigQuery-319"><a href="#BigQuery-319"><span class="linenos">319</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</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">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="BigQuery-320"><a href="#BigQuery-320"><span class="linenos">320</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="BigQuery-321"><a href="#BigQuery-321"><span class="linenos">321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">:</span> <span class="n">_derived_table_values_to_unnest</span><span class="p">,</span> -</span><span id="BigQuery-322"><a href="#BigQuery-322"><span class="linenos">322</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">_returnsproperty_sql</span><span class="p">,</span> -</span><span id="BigQuery-323"><a href="#BigQuery-323"><span class="linenos">323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> <span class="n">_create_sql</span><span class="p">,</span> -</span><span id="BigQuery-324"><a href="#BigQuery-324"><span class="linenos">324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</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="sa">f</span><span class="s2">"TRIM"</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">e</span><span class="o">.</span><span class="n">expression</span><span class="p">),</span> -</span><span id="BigQuery-325"><a href="#BigQuery-325"><span class="linenos">325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> <span class="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">"DETERMINISTIC"</span> -</span><span id="BigQuery-326"><a href="#BigQuery-326"><span class="linenos">326</span></a> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"IMMUTABLE"</span> -</span><span id="BigQuery-327"><a href="#BigQuery-327"><span class="linenos">327</span></a> <span class="k">else</span> <span class="s2">"NOT DETERMINISTIC"</span><span class="p">,</span> -</span><span id="BigQuery-328"><a href="#BigQuery-328"><span class="linenos">328</span></a> <span class="p">}</span> -</span><span id="BigQuery-329"><a href="#BigQuery-329"><span class="linenos">329</span></a> -</span><span id="BigQuery-330"><a href="#BigQuery-330"><span class="linenos">330</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-331"><a href="#BigQuery-331"><span class="linenos">331</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="BigQuery-332"><a href="#BigQuery-332"><span class="linenos">332</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">BIGDECIMAL</span><span class="p">:</span> <span class="s2">"BIGNUMERIC"</span><span class="p">,</span> -</span><span id="BigQuery-333"><a href="#BigQuery-333"><span class="linenos">333</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">BIGINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="BigQuery-334"><a href="#BigQuery-334"><span class="linenos">334</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">"BYTES"</span><span class="p">,</span> -</span><span id="BigQuery-335"><a href="#BigQuery-335"><span class="linenos">335</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">BOOLEAN</span><span class="p">:</span> <span class="s2">"BOOL"</span><span class="p">,</span> -</span><span id="BigQuery-336"><a href="#BigQuery-336"><span class="linenos">336</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">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery-337"><a href="#BigQuery-337"><span class="linenos">337</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="s2">"NUMERIC"</span><span class="p">,</span> -</span><span id="BigQuery-338"><a href="#BigQuery-338"><span class="linenos">338</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">DOUBLE</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> -</span><span id="BigQuery-339"><a href="#BigQuery-339"><span class="linenos">339</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">"FLOAT64"</span><span class="p">,</span> -</span><span id="BigQuery-340"><a href="#BigQuery-340"><span class="linenos">340</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">INT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="BigQuery-341"><a href="#BigQuery-341"><span class="linenos">341</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">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery-342"><a href="#BigQuery-342"><span class="linenos">342</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">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery-343"><a href="#BigQuery-343"><span class="linenos">343</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">SMALLINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="BigQuery-344"><a href="#BigQuery-344"><span class="linenos">344</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="s2">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery-345"><a href="#BigQuery-345"><span class="linenos">345</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</span><span class="p">:</span> <span class="s2">"DATETIME"</span><span class="p">,</span> -</span><span id="BigQuery-346"><a href="#BigQuery-346"><span class="linenos">346</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="BigQuery-347"><a href="#BigQuery-347"><span class="linenos">347</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">TIMESTAMPLTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="BigQuery-348"><a href="#BigQuery-348"><span class="linenos">348</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">TINYINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="BigQuery-349"><a href="#BigQuery-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">VARBINARY</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> -</span><span id="BigQuery-350"><a href="#BigQuery-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">VARCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery-351"><a href="#BigQuery-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">VARIANT</span><span class="p">:</span> <span class="s2">"ANY TYPE"</span><span class="p">,</span> -</span><span id="BigQuery-352"><a href="#BigQuery-352"><span class="linenos">352</span></a> <span class="p">}</span> -</span><span id="BigQuery-353"><a href="#BigQuery-353"><span class="linenos">353</span></a> -</span><span id="BigQuery-354"><a href="#BigQuery-354"><span class="linenos">354</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery-355"><a href="#BigQuery-355"><span class="linenos">355</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">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="BigQuery-356"><a href="#BigQuery-356"><span class="linenos">356</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="BigQuery-357"><a href="#BigQuery-357"><span class="linenos">357</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="BigQuery-358"><a href="#BigQuery-358"><span class="linenos">358</span></a> <span class="p">}</span> -</span><span id="BigQuery-359"><a href="#BigQuery-359"><span class="linenos">359</span></a> -</span><span id="BigQuery-360"><a href="#BigQuery-360"><span class="linenos">360</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span><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">RESERVED_KEYWORDS</span><span class="p">,</span> <span class="s2">"hash"</span><span class="p">}</span> -</span><span id="BigQuery-361"><a href="#BigQuery-361"><span class="linenos">361</span></a> -</span><span id="BigQuery-362"><a href="#BigQuery-362"><span class="linenos">362</span></a> <span class="k">def</span> <span class="nf">array_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery-363"><a href="#BigQuery-363"><span class="linenos">363</span></a> <span class="n">first_arg</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> -</span><span id="BigQuery-364"><a href="#BigQuery-364"><span class="linenos">364</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">first_arg</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="BigQuery-365"><a href="#BigQuery-365"><span class="linenos">365</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ARRAY</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">first_arg</span><span class="p">))</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery-366"><a href="#BigQuery-366"><span class="linenos">366</span></a> -</span><span id="BigQuery-367"><a href="#BigQuery-367"><span class="linenos">367</span></a> <span class="k">return</span> <span class="n">inline_array_sql</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="BigQuery-368"><a href="#BigQuery-368"><span class="linenos">368</span></a> -</span><span id="BigQuery-369"><a href="#BigQuery-369"><span class="linenos">369</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery-370"><a href="#BigQuery-370"><span class="linenos">370</span></a> <span class="k">return</span> <span class="s2">"BEGIN TRANSACTION"</span> +</span><span id="BigQuery-241"><a href="#BigQuery-241"><span class="linenos">241</span></a> <span class="n">ID_VAR_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-242"><a href="#BigQuery-242"><span class="linenos">242</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">ID_VAR_TOKENS</span><span class="p">,</span> +</span><span id="BigQuery-243"><a href="#BigQuery-243"><span class="linenos">243</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">VALUES</span><span class="p">,</span> +</span><span id="BigQuery-244"><a href="#BigQuery-244"><span class="linenos">244</span></a> <span class="p">}</span> +</span><span id="BigQuery-245"><a href="#BigQuery-245"><span class="linenos">245</span></a> +</span><span id="BigQuery-246"><a href="#BigQuery-246"><span class="linenos">246</span></a> <span class="n">PROPERTY_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-247"><a href="#BigQuery-247"><span class="linenos">247</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">PROPERTY_PARSERS</span><span class="p">,</span> +</span><span id="BigQuery-248"><a href="#BigQuery-248"><span class="linenos">248</span></a> <span class="s2">"NOT DETERMINISTIC"</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">expression</span><span class="p">(</span> +</span><span id="BigQuery-249"><a href="#BigQuery-249"><span class="linenos">249</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"VOLATILE"</span><span class="p">)</span> +</span><span id="BigQuery-250"><a href="#BigQuery-250"><span class="linenos">250</span></a> <span class="p">),</span> +</span><span id="BigQuery-251"><a href="#BigQuery-251"><span class="linenos">251</span></a> <span class="s2">"OPTIONS"</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_with_property</span><span class="p">(),</span> +</span><span id="BigQuery-252"><a href="#BigQuery-252"><span class="linenos">252</span></a> <span class="p">}</span> +</span><span id="BigQuery-253"><a href="#BigQuery-253"><span class="linenos">253</span></a> +</span><span id="BigQuery-254"><a href="#BigQuery-254"><span class="linenos">254</span></a> <span class="n">CONSTRAINT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-255"><a href="#BigQuery-255"><span class="linenos">255</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">CONSTRAINT_PARSERS</span><span class="p">,</span> +</span><span id="BigQuery-256"><a href="#BigQuery-256"><span class="linenos">256</span></a> <span class="s2">"OPTIONS"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_with_property</span><span class="p">()),</span> +</span><span id="BigQuery-257"><a href="#BigQuery-257"><span class="linenos">257</span></a> <span class="p">}</span> +</span><span id="BigQuery-258"><a href="#BigQuery-258"><span class="linenos">258</span></a> +</span><span id="BigQuery-259"><a href="#BigQuery-259"><span class="linenos">259</span></a> <span class="k">def</span> <span class="nf">_parse_table_part</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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="BigQuery-260"><a href="#BigQuery-260"><span class="linenos">260</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="BigQuery-261"><a href="#BigQuery-261"><span class="linenos">261</span></a> +</span><span id="BigQuery-262"><a href="#BigQuery-262"><span class="linenos">262</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#table_names</span> +</span><span id="BigQuery-263"><a href="#BigQuery-263"><span class="linenos">263</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">Identifier</span><span class="p">):</span> +</span><span id="BigQuery-264"><a href="#BigQuery-264"><span class="linenos">264</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> +</span><span id="BigQuery-265"><a href="#BigQuery-265"><span class="linenos">265</span></a> <span class="k">while</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">DASH</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> +</span><span id="BigQuery-266"><a href="#BigQuery-266"><span class="linenos">266</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> +</span><span id="BigQuery-267"><a href="#BigQuery-267"><span class="linenos">267</span></a> <span class="n">table_name</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">"-</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">text</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery-268"><a href="#BigQuery-268"><span class="linenos">268</span></a> +</span><span id="BigQuery-269"><a href="#BigQuery-269"><span class="linenos">269</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted"</span><span class="p">))</span> +</span><span id="BigQuery-270"><a href="#BigQuery-270"><span class="linenos">270</span></a> +</span><span id="BigQuery-271"><a href="#BigQuery-271"><span class="linenos">271</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="BigQuery-272"><a href="#BigQuery-272"><span class="linenos">272</span></a> +</span><span id="BigQuery-273"><a href="#BigQuery-273"><span class="linenos">273</span></a> <span class="k">def</span> <span class="nf">_parse_table_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> +</span><span id="BigQuery-274"><a href="#BigQuery-274"><span class="linenos">274</span></a> <span class="n">table</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="BigQuery-275"><a href="#BigQuery-275"><span class="linenos">275</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">table</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">Identifier</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"."</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">name</span><span class="p">:</span> +</span><span id="BigQuery-276"><a href="#BigQuery-276"><span class="linenos">276</span></a> <span class="n">catalog</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="BigQuery-277"><a href="#BigQuery-277"><span class="linenos">277</span></a> <span class="n">t</span><span class="o">.</span><span class="n">cast</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="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">x</span><span class="p">))</span> +</span><span id="BigQuery-278"><a href="#BigQuery-278"><span class="linenos">278</span></a> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">split_num_words</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="s2">"."</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> +</span><span id="BigQuery-279"><a href="#BigQuery-279"><span class="linenos">279</span></a> <span class="p">)</span> +</span><span id="BigQuery-280"><a href="#BigQuery-280"><span class="linenos">280</span></a> +</span><span id="BigQuery-281"><a href="#BigQuery-281"><span class="linenos">281</span></a> <span class="k">if</span> <span class="n">rest</span> <span class="ow">and</span> <span class="n">this</span><span class="p">:</span> +</span><span id="BigQuery-282"><a href="#BigQuery-282"><span class="linenos">282</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="o">.</span><span class="n">build</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">cast</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="p">[</span><span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="p">]))</span> +</span><span id="BigQuery-283"><a href="#BigQuery-283"><span class="linenos">283</span></a> +</span><span id="BigQuery-284"><a href="#BigQuery-284"><span class="linenos">284</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="n">db</span><span class="p">,</span> <span class="n">catalog</span><span class="o">=</span><span class="n">catalog</span><span class="p">)</span> +</span><span id="BigQuery-285"><a href="#BigQuery-285"><span class="linenos">285</span></a> +</span><span id="BigQuery-286"><a href="#BigQuery-286"><span class="linenos">286</span></a> <span class="k">return</span> <span class="n">table</span> +</span><span id="BigQuery-287"><a href="#BigQuery-287"><span class="linenos">287</span></a> +</span><span id="BigQuery-288"><a href="#BigQuery-288"><span class="linenos">288</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="BigQuery-289"><a href="#BigQuery-289"><span class="linenos">289</span></a> <span class="n">EXPLICIT_UNION</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery-290"><a href="#BigQuery-290"><span class="linenos">290</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery-291"><a href="#BigQuery-291"><span class="linenos">291</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery-292"><a href="#BigQuery-292"><span class="linenos">292</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery-293"><a href="#BigQuery-293"><span class="linenos">293</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> +</span><span id="BigQuery-294"><a href="#BigQuery-294"><span class="linenos">294</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery-295"><a href="#BigQuery-295"><span class="linenos">295</span></a> +</span><span id="BigQuery-296"><a href="#BigQuery-296"><span class="linenos">296</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-297"><a href="#BigQuery-297"><span class="linenos">297</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="BigQuery-298"><a href="#BigQuery-298"><span class="linenos">298</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_COUNT_DISTINCT"</span><span class="p">),</span> +</span><span id="BigQuery-299"><a href="#BigQuery-299"><span class="linenos">299</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="BigQuery-300"><a href="#BigQuery-300"><span class="linenos">300</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</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="BigQuery-301"><a href="#BigQuery-301"><span class="linenos">301</span></a> <span class="s2">"TIMESTAMP"</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">"DATETIME"</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">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">"zone"</span><span class="p">))</span> +</span><span id="BigQuery-302"><a href="#BigQuery-302"><span class="linenos">302</span></a> <span class="p">),</span> +</span><span id="BigQuery-303"><a href="#BigQuery-303"><span class="linenos">303</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</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">remove_precision_parameterized_types</span><span class="p">]),</span> +</span><span id="BigQuery-304"><a href="#BigQuery-304"><span class="linenos">304</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="BigQuery-305"><a href="#BigQuery-305"><span class="linenos">305</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="BigQuery-306"><a href="#BigQuery-306"><span class="linenos">306</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="BigQuery-307"><a href="#BigQuery-307"><span class="linenos">307</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="BigQuery-308"><a href="#BigQuery-308"><span class="linenos">308</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="sa">f</span><span class="s2">"DATE_DIFF(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">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="s1">'DAY'</span><span class="p">))</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="BigQuery-309"><a href="#BigQuery-309"><span class="linenos">309</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="BigQuery-310"><a href="#BigQuery-310"><span class="linenos">310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</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">"DATE_TRUNC"</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">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)),</span> +</span><span id="BigQuery-311"><a href="#BigQuery-311"><span class="linenos">311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRING_AGG"</span><span class="p">),</span> +</span><span id="BigQuery-312"><a href="#BigQuery-312"><span class="linenos">312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> +</span><span id="BigQuery-313"><a href="#BigQuery-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DIV"</span><span class="p">),</span> +</span><span id="BigQuery-314"><a href="#BigQuery-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> +</span><span id="BigQuery-315"><a href="#BigQuery-315"><span class="linenos">315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> +</span><span id="BigQuery-316"><a href="#BigQuery-316"><span class="linenos">316</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</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="BigQuery-317"><a href="#BigQuery-317"><span class="linenos">317</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">,</span> +</span><span id="BigQuery-318"><a href="#BigQuery-318"><span class="linenos">318</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="BigQuery-319"><a href="#BigQuery-319"><span class="linenos">319</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="BigQuery-320"><a href="#BigQuery-320"><span class="linenos">320</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">"position"</span><span class="p">),</span> +</span><span id="BigQuery-321"><a href="#BigQuery-321"><span class="linenos">321</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">"occurrence"</span><span class="p">),</span> +</span><span id="BigQuery-322"><a href="#BigQuery-322"><span class="linenos">322</span></a> <span class="p">),</span> +</span><span id="BigQuery-323"><a href="#BigQuery-323"><span class="linenos">323</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_CONTAINS"</span><span class="p">),</span> +</span><span id="BigQuery-324"><a href="#BigQuery-324"><span class="linenos">324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="BigQuery-325"><a href="#BigQuery-325"><span class="linenos">325</span></a> <span class="p">[</span><span class="n">_unqualify_unnest</span><span class="p">,</span> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">]</span> +</span><span id="BigQuery-326"><a href="#BigQuery-326"><span class="linenos">326</span></a> <span class="p">),</span> +</span><span id="BigQuery-327"><a href="#BigQuery-327"><span class="linenos">327</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</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">"PARSE_DATE(</span><span class="si">{</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 class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="BigQuery-328"><a href="#BigQuery-328"><span class="linenos">328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</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">"PARSE_TIMESTAMP(</span><span class="si">{</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 class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="BigQuery-329"><a href="#BigQuery-329"><span class="linenos">329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="BigQuery-330"><a href="#BigQuery-330"><span class="linenos">330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="BigQuery-331"><a href="#BigQuery-331"><span class="linenos">331</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="BigQuery-332"><a href="#BigQuery-332"><span class="linenos">332</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="BigQuery-333"><a href="#BigQuery-333"><span class="linenos">333</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="BigQuery-334"><a href="#BigQuery-334"><span class="linenos">334</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</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">"SAFE_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 </span><span 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">'to'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="BigQuery-335"><a href="#BigQuery-335"><span class="linenos">335</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="s2">"bigquery"</span><span class="p">),</span> +</span><span id="BigQuery-336"><a href="#BigQuery-336"><span class="linenos">336</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="BigQuery-337"><a href="#BigQuery-337"><span class="linenos">337</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</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">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="BigQuery-338"><a href="#BigQuery-338"><span class="linenos">338</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="BigQuery-339"><a href="#BigQuery-339"><span class="linenos">339</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">:</span> <span class="n">_derived_table_values_to_unnest</span><span class="p">,</span> +</span><span id="BigQuery-340"><a href="#BigQuery-340"><span class="linenos">340</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">_returnsproperty_sql</span><span class="p">,</span> +</span><span id="BigQuery-341"><a href="#BigQuery-341"><span class="linenos">341</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> <span class="n">_create_sql</span><span class="p">,</span> +</span><span id="BigQuery-342"><a href="#BigQuery-342"><span class="linenos">342</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</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="sa">f</span><span class="s2">"TRIM"</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">e</span><span class="o">.</span><span class="n">expression</span><span class="p">),</span> +</span><span id="BigQuery-343"><a href="#BigQuery-343"><span class="linenos">343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</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">"DETERMINISTIC"</span> +</span><span id="BigQuery-344"><a href="#BigQuery-344"><span class="linenos">344</span></a> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"IMMUTABLE"</span> +</span><span id="BigQuery-345"><a href="#BigQuery-345"><span class="linenos">345</span></a> <span class="k">else</span> <span class="s2">"NOT DETERMINISTIC"</span><span class="p">,</span> +</span><span id="BigQuery-346"><a href="#BigQuery-346"><span class="linenos">346</span></a> <span class="p">}</span> +</span><span id="BigQuery-347"><a href="#BigQuery-347"><span class="linenos">347</span></a> +</span><span id="BigQuery-348"><a href="#BigQuery-348"><span class="linenos">348</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-349"><a href="#BigQuery-349"><span class="linenos">349</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="BigQuery-350"><a href="#BigQuery-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">BIGDECIMAL</span><span class="p">:</span> <span class="s2">"BIGNUMERIC"</span><span class="p">,</span> +</span><span id="BigQuery-351"><a href="#BigQuery-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">BIGINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="BigQuery-352"><a href="#BigQuery-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">BINARY</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> +</span><span id="BigQuery-353"><a href="#BigQuery-353"><span class="linenos">353</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">BOOLEAN</span><span class="p">:</span> <span class="s2">"BOOL"</span><span class="p">,</span> +</span><span id="BigQuery-354"><a href="#BigQuery-354"><span class="linenos">354</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">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery-355"><a href="#BigQuery-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="s2">"NUMERIC"</span><span class="p">,</span> +</span><span id="BigQuery-356"><a href="#BigQuery-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">DOUBLE</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> +</span><span id="BigQuery-357"><a href="#BigQuery-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">FLOAT</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> +</span><span id="BigQuery-358"><a href="#BigQuery-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">INT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="BigQuery-359"><a href="#BigQuery-359"><span class="linenos">359</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">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery-360"><a href="#BigQuery-360"><span class="linenos">360</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">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery-361"><a href="#BigQuery-361"><span class="linenos">361</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">SMALLINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="BigQuery-362"><a href="#BigQuery-362"><span class="linenos">362</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="s2">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery-363"><a href="#BigQuery-363"><span class="linenos">363</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</span><span class="p">:</span> <span class="s2">"DATETIME"</span><span class="p">,</span> +</span><span id="BigQuery-364"><a href="#BigQuery-364"><span class="linenos">364</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="BigQuery-365"><a href="#BigQuery-365"><span class="linenos">365</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">TIMESTAMPLTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="BigQuery-366"><a href="#BigQuery-366"><span class="linenos">366</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">TINYINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="BigQuery-367"><a href="#BigQuery-367"><span class="linenos">367</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">"BYTES"</span><span class="p">,</span> +</span><span id="BigQuery-368"><a href="#BigQuery-368"><span class="linenos">368</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">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery-369"><a href="#BigQuery-369"><span class="linenos">369</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">VARIANT</span><span class="p">:</span> <span class="s2">"ANY TYPE"</span><span class="p">,</span> +</span><span id="BigQuery-370"><a href="#BigQuery-370"><span class="linenos">370</span></a> <span class="p">}</span> </span><span id="BigQuery-371"><a href="#BigQuery-371"><span class="linenos">371</span></a> -</span><span id="BigQuery-372"><a href="#BigQuery-372"><span class="linenos">372</span></a> <span class="k">def</span> <span class="nf">commit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery-373"><a href="#BigQuery-373"><span class="linenos">373</span></a> <span class="k">return</span> <span class="s2">"COMMIT TRANSACTION"</span> -</span><span id="BigQuery-374"><a href="#BigQuery-374"><span class="linenos">374</span></a> -</span><span id="BigQuery-375"><a href="#BigQuery-375"><span class="linenos">375</span></a> <span class="k">def</span> <span class="nf">rollback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery-376"><a href="#BigQuery-376"><span class="linenos">376</span></a> <span class="k">return</span> <span class="s2">"ROLLBACK TRANSACTION"</span> +</span><span id="BigQuery-372"><a href="#BigQuery-372"><span class="linenos">372</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery-373"><a href="#BigQuery-373"><span class="linenos">373</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">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="BigQuery-374"><a href="#BigQuery-374"><span class="linenos">374</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="BigQuery-375"><a href="#BigQuery-375"><span class="linenos">375</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="BigQuery-376"><a href="#BigQuery-376"><span class="linenos">376</span></a> <span class="p">}</span> </span><span id="BigQuery-377"><a href="#BigQuery-377"><span class="linenos">377</span></a> -</span><span id="BigQuery-378"><a href="#BigQuery-378"><span class="linenos">378</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery-379"><a href="#BigQuery-379"><span class="linenos">379</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><span id="BigQuery-380"><a href="#BigQuery-380"><span class="linenos">380</span></a> -</span><span id="BigQuery-381"><a href="#BigQuery-381"><span class="linenos">381</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery-382"><a href="#BigQuery-382"><span class="linenos">382</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> -</span><span id="BigQuery-383"><a href="#BigQuery-383"><span class="linenos">383</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"EXCEPT without DISTINCT is not supported in BigQuery"</span><span class="p">)</span> -</span><span id="BigQuery-384"><a href="#BigQuery-384"><span class="linenos">384</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">' DISTINCT'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery-385"><a href="#BigQuery-385"><span class="linenos">385</span></a> -</span><span id="BigQuery-386"><a href="#BigQuery-386"><span class="linenos">386</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery-387"><a href="#BigQuery-387"><span class="linenos">387</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> -</span><span id="BigQuery-388"><a href="#BigQuery-388"><span class="linenos">388</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"INTERSECT without DISTINCT is not supported in BigQuery"</span><span class="p">)</span> -</span><span id="BigQuery-389"><a href="#BigQuery-389"><span class="linenos">389</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">' DISTINCT'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery-390"><a href="#BigQuery-390"><span class="linenos">390</span></a> -</span><span id="BigQuery-391"><a href="#BigQuery-391"><span class="linenos">391</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery-392"><a href="#BigQuery-392"><span class="linenos">392</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"OPTIONS"</span><span class="p">))</span> +</span><span id="BigQuery-378"><a href="#BigQuery-378"><span class="linenos">378</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span><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">RESERVED_KEYWORDS</span><span class="p">,</span> <span class="s2">"hash"</span><span class="p">}</span> +</span><span id="BigQuery-379"><a href="#BigQuery-379"><span class="linenos">379</span></a> +</span><span id="BigQuery-380"><a href="#BigQuery-380"><span class="linenos">380</span></a> <span class="k">def</span> <span class="nf">array_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery-381"><a href="#BigQuery-381"><span class="linenos">381</span></a> <span class="n">first_arg</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="BigQuery-382"><a href="#BigQuery-382"><span class="linenos">382</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">first_arg</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="BigQuery-383"><a href="#BigQuery-383"><span class="linenos">383</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ARRAY</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">first_arg</span><span class="p">))</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery-384"><a href="#BigQuery-384"><span class="linenos">384</span></a> +</span><span id="BigQuery-385"><a href="#BigQuery-385"><span class="linenos">385</span></a> <span class="k">return</span> <span class="n">inline_array_sql</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="BigQuery-386"><a href="#BigQuery-386"><span class="linenos">386</span></a> +</span><span id="BigQuery-387"><a href="#BigQuery-387"><span class="linenos">387</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery-388"><a href="#BigQuery-388"><span class="linenos">388</span></a> <span class="k">return</span> <span class="s2">"BEGIN TRANSACTION"</span> +</span><span id="BigQuery-389"><a href="#BigQuery-389"><span class="linenos">389</span></a> +</span><span id="BigQuery-390"><a href="#BigQuery-390"><span class="linenos">390</span></a> <span class="k">def</span> <span class="nf">commit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery-391"><a href="#BigQuery-391"><span class="linenos">391</span></a> <span class="k">return</span> <span class="s2">"COMMIT TRANSACTION"</span> +</span><span id="BigQuery-392"><a href="#BigQuery-392"><span class="linenos">392</span></a> +</span><span id="BigQuery-393"><a href="#BigQuery-393"><span class="linenos">393</span></a> <span class="k">def</span> <span class="nf">rollback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery-394"><a href="#BigQuery-394"><span class="linenos">394</span></a> <span class="k">return</span> <span class="s2">"ROLLBACK TRANSACTION"</span> +</span><span id="BigQuery-395"><a href="#BigQuery-395"><span class="linenos">395</span></a> +</span><span id="BigQuery-396"><a href="#BigQuery-396"><span class="linenos">396</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery-397"><a href="#BigQuery-397"><span class="linenos">397</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><span id="BigQuery-398"><a href="#BigQuery-398"><span class="linenos">398</span></a> +</span><span id="BigQuery-399"><a href="#BigQuery-399"><span class="linenos">399</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery-400"><a href="#BigQuery-400"><span class="linenos">400</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> +</span><span id="BigQuery-401"><a href="#BigQuery-401"><span class="linenos">401</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"EXCEPT without DISTINCT is not supported in BigQuery"</span><span class="p">)</span> +</span><span id="BigQuery-402"><a href="#BigQuery-402"><span class="linenos">402</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">' DISTINCT'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery-403"><a href="#BigQuery-403"><span class="linenos">403</span></a> +</span><span id="BigQuery-404"><a href="#BigQuery-404"><span class="linenos">404</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery-405"><a href="#BigQuery-405"><span class="linenos">405</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> +</span><span id="BigQuery-406"><a href="#BigQuery-406"><span class="linenos">406</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"INTERSECT without DISTINCT is not supported in BigQuery"</span><span class="p">)</span> +</span><span id="BigQuery-407"><a href="#BigQuery-407"><span class="linenos">407</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">' DISTINCT'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery-408"><a href="#BigQuery-408"><span class="linenos">408</span></a> +</span><span id="BigQuery-409"><a href="#BigQuery-409"><span class="linenos">409</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery-410"><a href="#BigQuery-410"><span class="linenos">410</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"OPTIONS"</span><span class="p">))</span> </span></pre></div> + <div id="BigQuery.normalize_identifier" class="classattr"> + <input id="BigQuery.normalize_identifier-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">normalize_identifier</span><span class="signature pdoc-code condensed">(<span class="param"><span class="bp">cls</span>, </span><span class="param"><span class="n">expression</span><span class="p">:</span> <span class="o">~</span><span class="n">E</span></span><span class="return-annotation">) -> <span class="o">~</span><span class="n">E</span>:</span></span> + + <label class="view-source-button" for="BigQuery.normalize_identifier-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#BigQuery.normalize_identifier"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.normalize_identifier-134"><a href="#BigQuery.normalize_identifier-134"><span class="linenos">134</span></a> <span class="nd">@classmethod</span> +</span><span id="BigQuery.normalize_identifier-135"><a href="#BigQuery.normalize_identifier-135"><span class="linenos">135</span></a> <span class="k">def</span> <span class="nf">normalize_identifier</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="BigQuery.normalize_identifier-136"><a href="#BigQuery.normalize_identifier-136"><span class="linenos">136</span></a> <span class="c1"># In BigQuery, CTEs aren't case-sensitive, but table names are (by default, at least).</span> +</span><span id="BigQuery.normalize_identifier-137"><a href="#BigQuery.normalize_identifier-137"><span class="linenos">137</span></a> <span class="c1"># The following check is essentially a heuristic to detect tables based on whether or</span> +</span><span id="BigQuery.normalize_identifier-138"><a href="#BigQuery.normalize_identifier-138"><span class="linenos">138</span></a> <span class="c1"># not they're qualified.</span> +</span><span id="BigQuery.normalize_identifier-139"><a href="#BigQuery.normalize_identifier-139"><span class="linenos">139</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="BigQuery.normalize_identifier-140"><a href="#BigQuery.normalize_identifier-140"><span class="linenos">140</span></a> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> +</span><span id="BigQuery.normalize_identifier-141"><a href="#BigQuery.normalize_identifier-141"><span class="linenos">141</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="p">(</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">Table</span><span class="p">)</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">db</span><span class="p">)</span> +</span><span id="BigQuery.normalize_identifier-142"><a href="#BigQuery.normalize_identifier-142"><span class="linenos">142</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"is_table"</span><span class="p">)</span> +</span><span id="BigQuery.normalize_identifier-143"><a href="#BigQuery.normalize_identifier-143"><span class="linenos">143</span></a> <span class="p">):</span> +</span><span id="BigQuery.normalize_identifier-144"><a href="#BigQuery.normalize_identifier-144"><span class="linenos">144</span></a> <span class="n">expression</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">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">lower</span><span class="p">())</span> +</span><span id="BigQuery.normalize_identifier-145"><a href="#BigQuery.normalize_identifier-145"><span class="linenos">145</span></a> +</span><span id="BigQuery.normalize_identifier-146"><a href="#BigQuery.normalize_identifier-146"><span class="linenos">146</span></a> <span class="k">return</span> <span class="n">expression</span> +</span></pre></div> + + + <div class="docstring"><p>Normalizes an unquoted identifier to either lower or upper case, thus essentially +making it case-insensitive. If a dialect treats all identifiers as case-insensitive, +they will be normalized regardless of being quoted or not.</p> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="BigQuery.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="BigQuery.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="BigQuery.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="BigQuery.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="BigQuery.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="BigQuery.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="BigQuery.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="BigQuery.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -827,38 +906,38 @@ </div> <a class="headerlink" href="#BigQuery.Tokenizer"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Tokenizer-130"><a href="#BigQuery.Tokenizer-130"><span class="linenos">130</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="BigQuery.Tokenizer-131"><a href="#BigQuery.Tokenizer-131"><span class="linenos">131</span></a> <span class="n">QUOTES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">,</span> <span class="s1">'"'</span><span class="p">,</span> <span class="s1">'"""'</span><span class="p">,</span> <span class="s2">"'''"</span><span class="p">]</span> -</span><span id="BigQuery.Tokenizer-132"><a href="#BigQuery.Tokenizer-132"><span class="linenos">132</span></a> <span class="n">COMMENTS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--"</span><span class="p">,</span> <span class="s2">"#"</span><span class="p">,</span> <span class="p">(</span><span class="s2">"/*"</span><span class="p">,</span> <span class="s2">"*/"</span><span class="p">)]</span> -</span><span id="BigQuery.Tokenizer-133"><a href="#BigQuery.Tokenizer-133"><span class="linenos">133</span></a> <span class="n">IDENTIFIERS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"`"</span><span class="p">]</span> -</span><span id="BigQuery.Tokenizer-134"><a href="#BigQuery.Tokenizer-134"><span class="linenos">134</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">]</span> -</span><span id="BigQuery.Tokenizer-135"><a href="#BigQuery.Tokenizer-135"><span class="linenos">135</span></a> -</span><span id="BigQuery.Tokenizer-136"><a href="#BigQuery.Tokenizer-136"><span class="linenos">136</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"0x"</span><span class="p">,</span> <span class="s2">""</span><span class="p">),</span> <span class="p">(</span><span class="s2">"0X"</span><span class="p">,</span> <span class="s2">""</span><span class="p">)]</span> -</span><span id="BigQuery.Tokenizer-137"><a href="#BigQuery.Tokenizer-137"><span class="linenos">137</span></a> -</span><span id="BigQuery.Tokenizer-138"><a href="#BigQuery.Tokenizer-138"><span class="linenos">138</span></a> <span class="n">BYTE_STRINGS</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="BigQuery.Tokenizer-139"><a href="#BigQuery.Tokenizer-139"><span class="linenos">139</span></a> <span class="p">(</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">q</span><span class="p">,</span> <span class="n">q</span><span class="p">)</span> <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">QUOTES</span><span class="p">)</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"b"</span><span class="p">,</span> <span class="s2">"B"</span><span class="p">)</span> -</span><span id="BigQuery.Tokenizer-140"><a href="#BigQuery.Tokenizer-140"><span class="linenos">140</span></a> <span class="p">]</span> -</span><span id="BigQuery.Tokenizer-141"><a href="#BigQuery.Tokenizer-141"><span class="linenos">141</span></a> -</span><span id="BigQuery.Tokenizer-142"><a href="#BigQuery.Tokenizer-142"><span class="linenos">142</span></a> <span class="n">RAW_STRINGS</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="BigQuery.Tokenizer-143"><a href="#BigQuery.Tokenizer-143"><span class="linenos">143</span></a> <span class="p">(</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">q</span><span class="p">,</span> <span class="n">q</span><span class="p">)</span> <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">QUOTES</span><span class="p">)</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"r"</span><span class="p">,</span> <span class="s2">"R"</span><span class="p">)</span> -</span><span id="BigQuery.Tokenizer-144"><a href="#BigQuery.Tokenizer-144"><span class="linenos">144</span></a> <span class="p">]</span> -</span><span id="BigQuery.Tokenizer-145"><a href="#BigQuery.Tokenizer-145"><span class="linenos">145</span></a> -</span><span id="BigQuery.Tokenizer-146"><a href="#BigQuery.Tokenizer-146"><span class="linenos">146</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery.Tokenizer-147"><a href="#BigQuery.Tokenizer-147"><span class="linenos">147</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="BigQuery.Tokenizer-148"><a href="#BigQuery.Tokenizer-148"><span class="linenos">148</span></a> <span class="s2">"ANY TYPE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARIANT</span><span class="p">,</span> -</span><span id="BigQuery.Tokenizer-149"><a href="#BigQuery.Tokenizer-149"><span class="linenos">149</span></a> <span class="s2">"BEGIN"</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="BigQuery.Tokenizer-150"><a href="#BigQuery.Tokenizer-150"><span class="linenos">150</span></a> <span class="s2">"BEGIN TRANSACTION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">,</span> -</span><span id="BigQuery.Tokenizer-151"><a href="#BigQuery.Tokenizer-151"><span class="linenos">151</span></a> <span class="s2">"CURRENT_DATETIME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_DATETIME</span><span class="p">,</span> -</span><span id="BigQuery.Tokenizer-152"><a href="#BigQuery.Tokenizer-152"><span class="linenos">152</span></a> <span class="s2">"BYTES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BINARY</span><span class="p">,</span> -</span><span id="BigQuery.Tokenizer-153"><a href="#BigQuery.Tokenizer-153"><span class="linenos">153</span></a> <span class="s2">"DECLARE"</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="BigQuery.Tokenizer-154"><a href="#BigQuery.Tokenizer-154"><span class="linenos">154</span></a> <span class="s2">"FLOAT64"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> -</span><span id="BigQuery.Tokenizer-155"><a href="#BigQuery.Tokenizer-155"><span class="linenos">155</span></a> <span class="s2">"INT64"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> -</span><span id="BigQuery.Tokenizer-156"><a href="#BigQuery.Tokenizer-156"><span class="linenos">156</span></a> <span class="s2">"RECORD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">,</span> -</span><span id="BigQuery.Tokenizer-157"><a href="#BigQuery.Tokenizer-157"><span class="linenos">157</span></a> <span class="s2">"TIMESTAMP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> -</span><span id="BigQuery.Tokenizer-158"><a href="#BigQuery.Tokenizer-158"><span class="linenos">158</span></a> <span class="s2">"NOT DETERMINISTIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VOLATILE</span><span class="p">,</span> -</span><span id="BigQuery.Tokenizer-159"><a href="#BigQuery.Tokenizer-159"><span class="linenos">159</span></a> <span class="s2">"UNKNOWN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">,</span> -</span><span id="BigQuery.Tokenizer-160"><a href="#BigQuery.Tokenizer-160"><span class="linenos">160</span></a> <span class="p">}</span> -</span><span id="BigQuery.Tokenizer-161"><a href="#BigQuery.Tokenizer-161"><span class="linenos">161</span></a> <span class="n">KEYWORDS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"DIV"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Tokenizer-148"><a href="#BigQuery.Tokenizer-148"><span class="linenos">148</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="BigQuery.Tokenizer-149"><a href="#BigQuery.Tokenizer-149"><span class="linenos">149</span></a> <span class="n">QUOTES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">,</span> <span class="s1">'"'</span><span class="p">,</span> <span class="s1">'"""'</span><span class="p">,</span> <span class="s2">"'''"</span><span class="p">]</span> +</span><span id="BigQuery.Tokenizer-150"><a href="#BigQuery.Tokenizer-150"><span class="linenos">150</span></a> <span class="n">COMMENTS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--"</span><span class="p">,</span> <span class="s2">"#"</span><span class="p">,</span> <span class="p">(</span><span class="s2">"/*"</span><span class="p">,</span> <span class="s2">"*/"</span><span class="p">)]</span> +</span><span id="BigQuery.Tokenizer-151"><a href="#BigQuery.Tokenizer-151"><span class="linenos">151</span></a> <span class="n">IDENTIFIERS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"`"</span><span class="p">]</span> +</span><span id="BigQuery.Tokenizer-152"><a href="#BigQuery.Tokenizer-152"><span class="linenos">152</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">]</span> +</span><span id="BigQuery.Tokenizer-153"><a href="#BigQuery.Tokenizer-153"><span class="linenos">153</span></a> +</span><span id="BigQuery.Tokenizer-154"><a href="#BigQuery.Tokenizer-154"><span class="linenos">154</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"0x"</span><span class="p">,</span> <span class="s2">""</span><span class="p">),</span> <span class="p">(</span><span class="s2">"0X"</span><span class="p">,</span> <span class="s2">""</span><span class="p">)]</span> +</span><span id="BigQuery.Tokenizer-155"><a href="#BigQuery.Tokenizer-155"><span class="linenos">155</span></a> +</span><span id="BigQuery.Tokenizer-156"><a href="#BigQuery.Tokenizer-156"><span class="linenos">156</span></a> <span class="n">BYTE_STRINGS</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="BigQuery.Tokenizer-157"><a href="#BigQuery.Tokenizer-157"><span class="linenos">157</span></a> <span class="p">(</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">q</span><span class="p">,</span> <span class="n">q</span><span class="p">)</span> <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">QUOTES</span><span class="p">)</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"b"</span><span class="p">,</span> <span class="s2">"B"</span><span class="p">)</span> +</span><span id="BigQuery.Tokenizer-158"><a href="#BigQuery.Tokenizer-158"><span class="linenos">158</span></a> <span class="p">]</span> +</span><span id="BigQuery.Tokenizer-159"><a href="#BigQuery.Tokenizer-159"><span class="linenos">159</span></a> +</span><span id="BigQuery.Tokenizer-160"><a href="#BigQuery.Tokenizer-160"><span class="linenos">160</span></a> <span class="n">RAW_STRINGS</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="BigQuery.Tokenizer-161"><a href="#BigQuery.Tokenizer-161"><span class="linenos">161</span></a> <span class="p">(</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">q</span><span class="p">,</span> <span class="n">q</span><span class="p">)</span> <span class="k">for</span> <span class="n">q</span> <span class="ow">in</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">QUOTES</span><span class="p">)</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"r"</span><span class="p">,</span> <span class="s2">"R"</span><span class="p">)</span> +</span><span id="BigQuery.Tokenizer-162"><a href="#BigQuery.Tokenizer-162"><span class="linenos">162</span></a> <span class="p">]</span> +</span><span id="BigQuery.Tokenizer-163"><a href="#BigQuery.Tokenizer-163"><span class="linenos">163</span></a> +</span><span id="BigQuery.Tokenizer-164"><a href="#BigQuery.Tokenizer-164"><span class="linenos">164</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery.Tokenizer-165"><a href="#BigQuery.Tokenizer-165"><span class="linenos">165</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="BigQuery.Tokenizer-166"><a href="#BigQuery.Tokenizer-166"><span class="linenos">166</span></a> <span class="s2">"ANY TYPE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARIANT</span><span class="p">,</span> +</span><span id="BigQuery.Tokenizer-167"><a href="#BigQuery.Tokenizer-167"><span class="linenos">167</span></a> <span class="s2">"BEGIN"</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="BigQuery.Tokenizer-168"><a href="#BigQuery.Tokenizer-168"><span class="linenos">168</span></a> <span class="s2">"BEGIN TRANSACTION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">,</span> +</span><span id="BigQuery.Tokenizer-169"><a href="#BigQuery.Tokenizer-169"><span class="linenos">169</span></a> <span class="s2">"CURRENT_DATETIME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_DATETIME</span><span class="p">,</span> +</span><span id="BigQuery.Tokenizer-170"><a href="#BigQuery.Tokenizer-170"><span class="linenos">170</span></a> <span class="s2">"BYTES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BINARY</span><span class="p">,</span> +</span><span id="BigQuery.Tokenizer-171"><a href="#BigQuery.Tokenizer-171"><span class="linenos">171</span></a> <span class="s2">"DECLARE"</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="BigQuery.Tokenizer-172"><a href="#BigQuery.Tokenizer-172"><span class="linenos">172</span></a> <span class="s2">"FLOAT64"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> +</span><span id="BigQuery.Tokenizer-173"><a href="#BigQuery.Tokenizer-173"><span class="linenos">173</span></a> <span class="s2">"INT64"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> +</span><span id="BigQuery.Tokenizer-174"><a href="#BigQuery.Tokenizer-174"><span class="linenos">174</span></a> <span class="s2">"RECORD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">,</span> +</span><span id="BigQuery.Tokenizer-175"><a href="#BigQuery.Tokenizer-175"><span class="linenos">175</span></a> <span class="s2">"TIMESTAMP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> +</span><span id="BigQuery.Tokenizer-176"><a href="#BigQuery.Tokenizer-176"><span class="linenos">176</span></a> <span class="s2">"NOT DETERMINISTIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VOLATILE</span><span class="p">,</span> +</span><span id="BigQuery.Tokenizer-177"><a href="#BigQuery.Tokenizer-177"><span class="linenos">177</span></a> <span class="s2">"UNKNOWN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">,</span> +</span><span id="BigQuery.Tokenizer-178"><a href="#BigQuery.Tokenizer-178"><span class="linenos">178</span></a> <span class="p">}</span> +</span><span id="BigQuery.Tokenizer-179"><a href="#BigQuery.Tokenizer-179"><span class="linenos">179</span></a> <span class="n">KEYWORDS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"DIV"</span><span class="p">)</span> </span></pre></div> @@ -887,112 +966,112 @@ </div> <a class="headerlink" href="#BigQuery.Parser"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Parser-163"><a href="#BigQuery.Parser-163"><span class="linenos">163</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="BigQuery.Parser-164"><a href="#BigQuery.Parser-164"><span class="linenos">164</span></a> <span class="n">PREFIXED_PIVOT_COLUMNS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery.Parser-165"><a href="#BigQuery.Parser-165"><span class="linenos">165</span></a> -</span><span id="BigQuery.Parser-166"><a href="#BigQuery.Parser-166"><span class="linenos">166</span></a> <span class="n">LOG_BASE_FIRST</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery.Parser-167"><a href="#BigQuery.Parser-167"><span class="linenos">167</span></a> <span class="n">LOG_DEFAULTS_TO_LN</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery.Parser-168"><a href="#BigQuery.Parser-168"><span class="linenos">168</span></a> -</span><span id="BigQuery.Parser-169"><a href="#BigQuery.Parser-169"><span class="linenos">169</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery.Parser-170"><a href="#BigQuery.Parser-170"><span class="linenos">170</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="BigQuery.Parser-171"><a href="#BigQuery.Parser-171"><span class="linenos">171</span></a> <span class="s2">"DATE_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">),</span> -</span><span id="BigQuery.Parser-172"><a href="#BigQuery.Parser-172"><span class="linenos">172</span></a> <span class="s2">"DATE_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">),</span> -</span><span id="BigQuery.Parser-173"><a href="#BigQuery.Parser-173"><span class="linenos">173</span></a> <span class="s2">"DATE_TRUNC"</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">DateTrunc</span><span class="p">(</span> -</span><span id="BigQuery.Parser-174"><a href="#BigQuery.Parser-174"><span class="linenos">174</span></a> <span class="n">unit</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="nb">str</span><span class="p">(</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="BigQuery.Parser-175"><a href="#BigQuery.Parser-175"><span class="linenos">175</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="BigQuery.Parser-176"><a href="#BigQuery.Parser-176"><span class="linenos">176</span></a> <span class="p">),</span> -</span><span id="BigQuery.Parser-177"><a href="#BigQuery.Parser-177"><span class="linenos">177</span></a> <span class="s2">"DATETIME_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">),</span> -</span><span id="BigQuery.Parser-178"><a href="#BigQuery.Parser-178"><span class="linenos">178</span></a> <span class="s2">"DATETIME_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">),</span> -</span><span id="BigQuery.Parser-179"><a href="#BigQuery.Parser-179"><span class="linenos">179</span></a> <span class="s2">"DIV"</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">IntDiv</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">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="BigQuery.Parser-180"><a href="#BigQuery.Parser-180"><span class="linenos">180</span></a> <span class="s2">"PARSE_DATE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">format_time_lambda</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="s2">"bigquery"</span><span class="p">)(</span> -</span><span id="BigQuery.Parser-181"><a href="#BigQuery.Parser-181"><span class="linenos">181</span></a> <span class="p">[</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">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="BigQuery.Parser-182"><a href="#BigQuery.Parser-182"><span class="linenos">182</span></a> <span class="p">),</span> -</span><span id="BigQuery.Parser-183"><a href="#BigQuery.Parser-183"><span class="linenos">183</span></a> <span class="s2">"PARSE_TIMESTAMP"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">format_time_lambda</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">"bigquery"</span><span class="p">)(</span> -</span><span id="BigQuery.Parser-184"><a href="#BigQuery.Parser-184"><span class="linenos">184</span></a> <span class="p">[</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">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="BigQuery.Parser-185"><a href="#BigQuery.Parser-185"><span class="linenos">185</span></a> <span class="p">),</span> -</span><span id="BigQuery.Parser-186"><a href="#BigQuery.Parser-186"><span class="linenos">186</span></a> <span class="s2">"REGEXP_CONTAINS"</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="BigQuery.Parser-187"><a href="#BigQuery.Parser-187"><span class="linenos">187</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="BigQuery.Parser-188"><a href="#BigQuery.Parser-188"><span class="linenos">188</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="BigQuery.Parser-189"><a href="#BigQuery.Parser-189"><span class="linenos">189</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="BigQuery.Parser-190"><a href="#BigQuery.Parser-190"><span class="linenos">190</span></a> <span class="n">position</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="BigQuery.Parser-191"><a href="#BigQuery.Parser-191"><span class="linenos">191</span></a> <span class="n">occurrence</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="BigQuery.Parser-192"><a href="#BigQuery.Parser-192"><span class="linenos">192</span></a> <span class="n">group</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> -</span><span id="BigQuery.Parser-193"><a href="#BigQuery.Parser-193"><span class="linenos">193</span></a> <span class="k">if</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="nb">str</span><span class="p">(</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="o">.</span><span class="n">groups</span> <span class="o">==</span> <span class="mi">1</span> -</span><span id="BigQuery.Parser-194"><a href="#BigQuery.Parser-194"><span class="linenos">194</span></a> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="BigQuery.Parser-195"><a href="#BigQuery.Parser-195"><span class="linenos">195</span></a> <span class="p">),</span> -</span><span id="BigQuery.Parser-196"><a href="#BigQuery.Parser-196"><span class="linenos">196</span></a> <span class="s2">"SPLIT"</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">Split</span><span class="p">(</span> -</span><span id="BigQuery.Parser-197"><a href="#BigQuery.Parser-197"><span class="linenos">197</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#split</span> -</span><span id="BigQuery.Parser-198"><a href="#BigQuery.Parser-198"><span class="linenos">198</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="BigQuery.Parser-199"><a href="#BigQuery.Parser-199"><span class="linenos">199</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 class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">","</span><span class="p">),</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Parser-181"><a href="#BigQuery.Parser-181"><span class="linenos">181</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="BigQuery.Parser-182"><a href="#BigQuery.Parser-182"><span class="linenos">182</span></a> <span class="n">PREFIXED_PIVOT_COLUMNS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery.Parser-183"><a href="#BigQuery.Parser-183"><span class="linenos">183</span></a> +</span><span id="BigQuery.Parser-184"><a href="#BigQuery.Parser-184"><span class="linenos">184</span></a> <span class="n">LOG_BASE_FIRST</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery.Parser-185"><a href="#BigQuery.Parser-185"><span class="linenos">185</span></a> <span class="n">LOG_DEFAULTS_TO_LN</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery.Parser-186"><a href="#BigQuery.Parser-186"><span class="linenos">186</span></a> +</span><span id="BigQuery.Parser-187"><a href="#BigQuery.Parser-187"><span class="linenos">187</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery.Parser-188"><a href="#BigQuery.Parser-188"><span class="linenos">188</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="BigQuery.Parser-189"><a href="#BigQuery.Parser-189"><span class="linenos">189</span></a> <span class="s2">"DATE_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">),</span> +</span><span id="BigQuery.Parser-190"><a href="#BigQuery.Parser-190"><span class="linenos">190</span></a> <span class="s2">"DATE_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">),</span> +</span><span id="BigQuery.Parser-191"><a href="#BigQuery.Parser-191"><span class="linenos">191</span></a> <span class="s2">"DATE_TRUNC"</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">DateTrunc</span><span class="p">(</span> +</span><span id="BigQuery.Parser-192"><a href="#BigQuery.Parser-192"><span class="linenos">192</span></a> <span class="n">unit</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="nb">str</span><span class="p">(</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="BigQuery.Parser-193"><a href="#BigQuery.Parser-193"><span class="linenos">193</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="BigQuery.Parser-194"><a href="#BigQuery.Parser-194"><span class="linenos">194</span></a> <span class="p">),</span> +</span><span id="BigQuery.Parser-195"><a href="#BigQuery.Parser-195"><span class="linenos">195</span></a> <span class="s2">"DATETIME_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">),</span> +</span><span id="BigQuery.Parser-196"><a href="#BigQuery.Parser-196"><span class="linenos">196</span></a> <span class="s2">"DATETIME_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">),</span> +</span><span id="BigQuery.Parser-197"><a href="#BigQuery.Parser-197"><span class="linenos">197</span></a> <span class="s2">"DIV"</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">IntDiv</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">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="BigQuery.Parser-198"><a href="#BigQuery.Parser-198"><span class="linenos">198</span></a> <span class="s2">"PARSE_DATE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">format_time_lambda</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="s2">"bigquery"</span><span class="p">)(</span> +</span><span id="BigQuery.Parser-199"><a href="#BigQuery.Parser-199"><span class="linenos">199</span></a> <span class="p">[</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">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="BigQuery.Parser-200"><a href="#BigQuery.Parser-200"><span class="linenos">200</span></a> <span class="p">),</span> -</span><span id="BigQuery.Parser-201"><a href="#BigQuery.Parser-201"><span class="linenos">201</span></a> <span class="s2">"TIME_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">),</span> -</span><span id="BigQuery.Parser-202"><a href="#BigQuery.Parser-202"><span class="linenos">202</span></a> <span class="s2">"TIME_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeSub</span><span class="p">),</span> -</span><span id="BigQuery.Parser-203"><a href="#BigQuery.Parser-203"><span class="linenos">203</span></a> <span class="s2">"TIMESTAMP_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimestampAdd</span><span class="p">),</span> -</span><span id="BigQuery.Parser-204"><a href="#BigQuery.Parser-204"><span class="linenos">204</span></a> <span class="s2">"TIMESTAMP_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimestampSub</span><span class="p">),</span> -</span><span id="BigQuery.Parser-205"><a href="#BigQuery.Parser-205"><span class="linenos">205</span></a> <span class="p">}</span> -</span><span id="BigQuery.Parser-206"><a href="#BigQuery.Parser-206"><span class="linenos">206</span></a> -</span><span id="BigQuery.Parser-207"><a href="#BigQuery.Parser-207"><span class="linenos">207</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery.Parser-208"><a href="#BigQuery.Parser-208"><span class="linenos">208</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">FUNCTION_PARSERS</span><span class="p">,</span> -</span><span id="BigQuery.Parser-209"><a href="#BigQuery.Parser-209"><span class="linenos">209</span></a> <span class="s2">"ARRAY"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">()]),</span> -</span><span id="BigQuery.Parser-210"><a href="#BigQuery.Parser-210"><span class="linenos">210</span></a> <span class="p">}</span> -</span><span id="BigQuery.Parser-211"><a href="#BigQuery.Parser-211"><span class="linenos">211</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> -</span><span id="BigQuery.Parser-212"><a href="#BigQuery.Parser-212"><span class="linenos">212</span></a> -</span><span id="BigQuery.Parser-213"><a href="#BigQuery.Parser-213"><span class="linenos">213</span></a> <span class="n">NO_PAREN_FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery.Parser-214"><a href="#BigQuery.Parser-214"><span class="linenos">214</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_FUNCTIONS</span><span class="p">,</span> -</span><span id="BigQuery.Parser-215"><a href="#BigQuery.Parser-215"><span class="linenos">215</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_DATETIME</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDatetime</span><span class="p">,</span> -</span><span id="BigQuery.Parser-216"><a href="#BigQuery.Parser-216"><span class="linenos">216</span></a> <span class="p">}</span> -</span><span id="BigQuery.Parser-217"><a href="#BigQuery.Parser-217"><span class="linenos">217</span></a> -</span><span id="BigQuery.Parser-218"><a href="#BigQuery.Parser-218"><span class="linenos">218</span></a> <span class="n">NESTED_TYPE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery.Parser-219"><a href="#BigQuery.Parser-219"><span class="linenos">219</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">NESTED_TYPE_TOKENS</span><span class="p">,</span> -</span><span id="BigQuery.Parser-220"><a href="#BigQuery.Parser-220"><span class="linenos">220</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> -</span><span id="BigQuery.Parser-221"><a href="#BigQuery.Parser-221"><span class="linenos">221</span></a> <span class="p">}</span> -</span><span id="BigQuery.Parser-222"><a href="#BigQuery.Parser-222"><span class="linenos">222</span></a> -</span><span id="BigQuery.Parser-223"><a href="#BigQuery.Parser-223"><span class="linenos">223</span></a> <span class="n">ID_VAR_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery.Parser-224"><a href="#BigQuery.Parser-224"><span class="linenos">224</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">ID_VAR_TOKENS</span><span class="p">,</span> -</span><span id="BigQuery.Parser-225"><a href="#BigQuery.Parser-225"><span class="linenos">225</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">VALUES</span><span class="p">,</span> -</span><span id="BigQuery.Parser-226"><a href="#BigQuery.Parser-226"><span class="linenos">226</span></a> <span class="p">}</span> -</span><span id="BigQuery.Parser-227"><a href="#BigQuery.Parser-227"><span class="linenos">227</span></a> -</span><span id="BigQuery.Parser-228"><a href="#BigQuery.Parser-228"><span class="linenos">228</span></a> <span class="n">PROPERTY_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery.Parser-229"><a href="#BigQuery.Parser-229"><span class="linenos">229</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">PROPERTY_PARSERS</span><span class="p">,</span> -</span><span id="BigQuery.Parser-230"><a href="#BigQuery.Parser-230"><span class="linenos">230</span></a> <span class="s2">"NOT DETERMINISTIC"</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">expression</span><span class="p">(</span> -</span><span id="BigQuery.Parser-231"><a href="#BigQuery.Parser-231"><span class="linenos">231</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"VOLATILE"</span><span class="p">)</span> -</span><span id="BigQuery.Parser-232"><a href="#BigQuery.Parser-232"><span class="linenos">232</span></a> <span class="p">),</span> -</span><span id="BigQuery.Parser-233"><a href="#BigQuery.Parser-233"><span class="linenos">233</span></a> <span class="s2">"OPTIONS"</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_with_property</span><span class="p">(),</span> +</span><span id="BigQuery.Parser-201"><a href="#BigQuery.Parser-201"><span class="linenos">201</span></a> <span class="s2">"PARSE_TIMESTAMP"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">format_time_lambda</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">"bigquery"</span><span class="p">)(</span> +</span><span id="BigQuery.Parser-202"><a href="#BigQuery.Parser-202"><span class="linenos">202</span></a> <span class="p">[</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">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="BigQuery.Parser-203"><a href="#BigQuery.Parser-203"><span class="linenos">203</span></a> <span class="p">),</span> +</span><span id="BigQuery.Parser-204"><a href="#BigQuery.Parser-204"><span class="linenos">204</span></a> <span class="s2">"REGEXP_CONTAINS"</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="BigQuery.Parser-205"><a href="#BigQuery.Parser-205"><span class="linenos">205</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="BigQuery.Parser-206"><a href="#BigQuery.Parser-206"><span class="linenos">206</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="BigQuery.Parser-207"><a href="#BigQuery.Parser-207"><span class="linenos">207</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="BigQuery.Parser-208"><a href="#BigQuery.Parser-208"><span class="linenos">208</span></a> <span class="n">position</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="BigQuery.Parser-209"><a href="#BigQuery.Parser-209"><span class="linenos">209</span></a> <span class="n">occurrence</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="BigQuery.Parser-210"><a href="#BigQuery.Parser-210"><span class="linenos">210</span></a> <span class="n">group</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> +</span><span id="BigQuery.Parser-211"><a href="#BigQuery.Parser-211"><span class="linenos">211</span></a> <span class="k">if</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="nb">str</span><span class="p">(</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="o">.</span><span class="n">groups</span> <span class="o">==</span> <span class="mi">1</span> +</span><span id="BigQuery.Parser-212"><a href="#BigQuery.Parser-212"><span class="linenos">212</span></a> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="BigQuery.Parser-213"><a href="#BigQuery.Parser-213"><span class="linenos">213</span></a> <span class="p">),</span> +</span><span id="BigQuery.Parser-214"><a href="#BigQuery.Parser-214"><span class="linenos">214</span></a> <span class="s2">"SPLIT"</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">Split</span><span class="p">(</span> +</span><span id="BigQuery.Parser-215"><a href="#BigQuery.Parser-215"><span class="linenos">215</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#split</span> +</span><span id="BigQuery.Parser-216"><a href="#BigQuery.Parser-216"><span class="linenos">216</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="BigQuery.Parser-217"><a href="#BigQuery.Parser-217"><span class="linenos">217</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 class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">","</span><span class="p">),</span> +</span><span id="BigQuery.Parser-218"><a href="#BigQuery.Parser-218"><span class="linenos">218</span></a> <span class="p">),</span> +</span><span id="BigQuery.Parser-219"><a href="#BigQuery.Parser-219"><span class="linenos">219</span></a> <span class="s2">"TIME_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">),</span> +</span><span id="BigQuery.Parser-220"><a href="#BigQuery.Parser-220"><span class="linenos">220</span></a> <span class="s2">"TIME_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimeSub</span><span class="p">),</span> +</span><span id="BigQuery.Parser-221"><a href="#BigQuery.Parser-221"><span class="linenos">221</span></a> <span class="s2">"TIMESTAMP_ADD"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimestampAdd</span><span class="p">),</span> +</span><span id="BigQuery.Parser-222"><a href="#BigQuery.Parser-222"><span class="linenos">222</span></a> <span class="s2">"TIMESTAMP_SUB"</span><span class="p">:</span> <span class="n">parse_date_delta_with_interval</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TimestampSub</span><span class="p">),</span> +</span><span id="BigQuery.Parser-223"><a href="#BigQuery.Parser-223"><span class="linenos">223</span></a> <span class="p">}</span> +</span><span id="BigQuery.Parser-224"><a href="#BigQuery.Parser-224"><span class="linenos">224</span></a> +</span><span id="BigQuery.Parser-225"><a href="#BigQuery.Parser-225"><span class="linenos">225</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery.Parser-226"><a href="#BigQuery.Parser-226"><span class="linenos">226</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">FUNCTION_PARSERS</span><span class="p">,</span> +</span><span id="BigQuery.Parser-227"><a href="#BigQuery.Parser-227"><span class="linenos">227</span></a> <span class="s2">"ARRAY"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">()]),</span> +</span><span id="BigQuery.Parser-228"><a href="#BigQuery.Parser-228"><span class="linenos">228</span></a> <span class="p">}</span> +</span><span id="BigQuery.Parser-229"><a href="#BigQuery.Parser-229"><span class="linenos">229</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> +</span><span id="BigQuery.Parser-230"><a href="#BigQuery.Parser-230"><span class="linenos">230</span></a> +</span><span id="BigQuery.Parser-231"><a href="#BigQuery.Parser-231"><span class="linenos">231</span></a> <span class="n">NO_PAREN_FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery.Parser-232"><a href="#BigQuery.Parser-232"><span class="linenos">232</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_FUNCTIONS</span><span class="p">,</span> +</span><span id="BigQuery.Parser-233"><a href="#BigQuery.Parser-233"><span class="linenos">233</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_DATETIME</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDatetime</span><span class="p">,</span> </span><span id="BigQuery.Parser-234"><a href="#BigQuery.Parser-234"><span class="linenos">234</span></a> <span class="p">}</span> </span><span id="BigQuery.Parser-235"><a href="#BigQuery.Parser-235"><span class="linenos">235</span></a> -</span><span id="BigQuery.Parser-236"><a href="#BigQuery.Parser-236"><span class="linenos">236</span></a> <span class="n">CONSTRAINT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery.Parser-237"><a href="#BigQuery.Parser-237"><span class="linenos">237</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">CONSTRAINT_PARSERS</span><span class="p">,</span> -</span><span id="BigQuery.Parser-238"><a href="#BigQuery.Parser-238"><span class="linenos">238</span></a> <span class="s2">"OPTIONS"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_with_property</span><span class="p">()),</span> +</span><span id="BigQuery.Parser-236"><a href="#BigQuery.Parser-236"><span class="linenos">236</span></a> <span class="n">NESTED_TYPE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery.Parser-237"><a href="#BigQuery.Parser-237"><span class="linenos">237</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">NESTED_TYPE_TOKENS</span><span class="p">,</span> +</span><span id="BigQuery.Parser-238"><a href="#BigQuery.Parser-238"><span class="linenos">238</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> </span><span id="BigQuery.Parser-239"><a href="#BigQuery.Parser-239"><span class="linenos">239</span></a> <span class="p">}</span> </span><span id="BigQuery.Parser-240"><a href="#BigQuery.Parser-240"><span class="linenos">240</span></a> -</span><span id="BigQuery.Parser-241"><a href="#BigQuery.Parser-241"><span class="linenos">241</span></a> <span class="k">def</span> <span class="nf">_parse_table_part</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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="BigQuery.Parser-242"><a href="#BigQuery.Parser-242"><span class="linenos">242</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="BigQuery.Parser-243"><a href="#BigQuery.Parser-243"><span class="linenos">243</span></a> -</span><span id="BigQuery.Parser-244"><a href="#BigQuery.Parser-244"><span class="linenos">244</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#table_names</span> -</span><span id="BigQuery.Parser-245"><a href="#BigQuery.Parser-245"><span class="linenos">245</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">Identifier</span><span class="p">):</span> -</span><span id="BigQuery.Parser-246"><a href="#BigQuery.Parser-246"><span class="linenos">246</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> -</span><span id="BigQuery.Parser-247"><a href="#BigQuery.Parser-247"><span class="linenos">247</span></a> <span class="k">while</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">DASH</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> -</span><span id="BigQuery.Parser-248"><a href="#BigQuery.Parser-248"><span class="linenos">248</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> -</span><span id="BigQuery.Parser-249"><a href="#BigQuery.Parser-249"><span class="linenos">249</span></a> <span class="n">table_name</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">"-</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">text</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery.Parser-250"><a href="#BigQuery.Parser-250"><span class="linenos">250</span></a> -</span><span id="BigQuery.Parser-251"><a href="#BigQuery.Parser-251"><span class="linenos">251</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted"</span><span class="p">))</span> -</span><span id="BigQuery.Parser-252"><a href="#BigQuery.Parser-252"><span class="linenos">252</span></a> -</span><span id="BigQuery.Parser-253"><a href="#BigQuery.Parser-253"><span class="linenos">253</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="BigQuery.Parser-254"><a href="#BigQuery.Parser-254"><span class="linenos">254</span></a> -</span><span id="BigQuery.Parser-255"><a href="#BigQuery.Parser-255"><span class="linenos">255</span></a> <span class="k">def</span> <span class="nf">_parse_table_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> -</span><span id="BigQuery.Parser-256"><a href="#BigQuery.Parser-256"><span class="linenos">256</span></a> <span class="n">table</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="BigQuery.Parser-257"><a href="#BigQuery.Parser-257"><span class="linenos">257</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">table</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">Identifier</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"."</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">name</span><span class="p">:</span> -</span><span id="BigQuery.Parser-258"><a href="#BigQuery.Parser-258"><span class="linenos">258</span></a> <span class="n">catalog</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="BigQuery.Parser-259"><a href="#BigQuery.Parser-259"><span class="linenos">259</span></a> <span class="n">t</span><span class="o">.</span><span class="n">cast</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="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">x</span><span class="p">))</span> -</span><span id="BigQuery.Parser-260"><a href="#BigQuery.Parser-260"><span class="linenos">260</span></a> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">split_num_words</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="s2">"."</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> -</span><span id="BigQuery.Parser-261"><a href="#BigQuery.Parser-261"><span class="linenos">261</span></a> <span class="p">)</span> -</span><span id="BigQuery.Parser-262"><a href="#BigQuery.Parser-262"><span class="linenos">262</span></a> -</span><span id="BigQuery.Parser-263"><a href="#BigQuery.Parser-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">rest</span> <span class="ow">and</span> <span class="n">this</span><span class="p">:</span> -</span><span id="BigQuery.Parser-264"><a href="#BigQuery.Parser-264"><span class="linenos">264</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="o">.</span><span class="n">build</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">cast</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="p">[</span><span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="p">]))</span> -</span><span id="BigQuery.Parser-265"><a href="#BigQuery.Parser-265"><span class="linenos">265</span></a> -</span><span id="BigQuery.Parser-266"><a href="#BigQuery.Parser-266"><span class="linenos">266</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="n">db</span><span class="p">,</span> <span class="n">catalog</span><span class="o">=</span><span class="n">catalog</span><span class="p">)</span> -</span><span id="BigQuery.Parser-267"><a href="#BigQuery.Parser-267"><span class="linenos">267</span></a> -</span><span id="BigQuery.Parser-268"><a href="#BigQuery.Parser-268"><span class="linenos">268</span></a> <span class="k">return</span> <span class="n">table</span> +</span><span id="BigQuery.Parser-241"><a href="#BigQuery.Parser-241"><span class="linenos">241</span></a> <span class="n">ID_VAR_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery.Parser-242"><a href="#BigQuery.Parser-242"><span class="linenos">242</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">ID_VAR_TOKENS</span><span class="p">,</span> +</span><span id="BigQuery.Parser-243"><a href="#BigQuery.Parser-243"><span class="linenos">243</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">VALUES</span><span class="p">,</span> +</span><span id="BigQuery.Parser-244"><a href="#BigQuery.Parser-244"><span class="linenos">244</span></a> <span class="p">}</span> +</span><span id="BigQuery.Parser-245"><a href="#BigQuery.Parser-245"><span class="linenos">245</span></a> +</span><span id="BigQuery.Parser-246"><a href="#BigQuery.Parser-246"><span class="linenos">246</span></a> <span class="n">PROPERTY_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery.Parser-247"><a href="#BigQuery.Parser-247"><span class="linenos">247</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">PROPERTY_PARSERS</span><span class="p">,</span> +</span><span id="BigQuery.Parser-248"><a href="#BigQuery.Parser-248"><span class="linenos">248</span></a> <span class="s2">"NOT DETERMINISTIC"</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">expression</span><span class="p">(</span> +</span><span id="BigQuery.Parser-249"><a href="#BigQuery.Parser-249"><span class="linenos">249</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"VOLATILE"</span><span class="p">)</span> +</span><span id="BigQuery.Parser-250"><a href="#BigQuery.Parser-250"><span class="linenos">250</span></a> <span class="p">),</span> +</span><span id="BigQuery.Parser-251"><a href="#BigQuery.Parser-251"><span class="linenos">251</span></a> <span class="s2">"OPTIONS"</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_with_property</span><span class="p">(),</span> +</span><span id="BigQuery.Parser-252"><a href="#BigQuery.Parser-252"><span class="linenos">252</span></a> <span class="p">}</span> +</span><span id="BigQuery.Parser-253"><a href="#BigQuery.Parser-253"><span class="linenos">253</span></a> +</span><span id="BigQuery.Parser-254"><a href="#BigQuery.Parser-254"><span class="linenos">254</span></a> <span class="n">CONSTRAINT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery.Parser-255"><a href="#BigQuery.Parser-255"><span class="linenos">255</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">CONSTRAINT_PARSERS</span><span class="p">,</span> +</span><span id="BigQuery.Parser-256"><a href="#BigQuery.Parser-256"><span class="linenos">256</span></a> <span class="s2">"OPTIONS"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_with_property</span><span class="p">()),</span> +</span><span id="BigQuery.Parser-257"><a href="#BigQuery.Parser-257"><span class="linenos">257</span></a> <span class="p">}</span> +</span><span id="BigQuery.Parser-258"><a href="#BigQuery.Parser-258"><span class="linenos">258</span></a> +</span><span id="BigQuery.Parser-259"><a href="#BigQuery.Parser-259"><span class="linenos">259</span></a> <span class="k">def</span> <span class="nf">_parse_table_part</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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="BigQuery.Parser-260"><a href="#BigQuery.Parser-260"><span class="linenos">260</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="BigQuery.Parser-261"><a href="#BigQuery.Parser-261"><span class="linenos">261</span></a> +</span><span id="BigQuery.Parser-262"><a href="#BigQuery.Parser-262"><span class="linenos">262</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#table_names</span> +</span><span id="BigQuery.Parser-263"><a href="#BigQuery.Parser-263"><span class="linenos">263</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">Identifier</span><span class="p">):</span> +</span><span id="BigQuery.Parser-264"><a href="#BigQuery.Parser-264"><span class="linenos">264</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> +</span><span id="BigQuery.Parser-265"><a href="#BigQuery.Parser-265"><span class="linenos">265</span></a> <span class="k">while</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">DASH</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> +</span><span id="BigQuery.Parser-266"><a href="#BigQuery.Parser-266"><span class="linenos">266</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> +</span><span id="BigQuery.Parser-267"><a href="#BigQuery.Parser-267"><span class="linenos">267</span></a> <span class="n">table_name</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">"-</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">text</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery.Parser-268"><a href="#BigQuery.Parser-268"><span class="linenos">268</span></a> +</span><span id="BigQuery.Parser-269"><a href="#BigQuery.Parser-269"><span class="linenos">269</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"quoted"</span><span class="p">))</span> +</span><span id="BigQuery.Parser-270"><a href="#BigQuery.Parser-270"><span class="linenos">270</span></a> +</span><span id="BigQuery.Parser-271"><a href="#BigQuery.Parser-271"><span class="linenos">271</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="BigQuery.Parser-272"><a href="#BigQuery.Parser-272"><span class="linenos">272</span></a> +</span><span id="BigQuery.Parser-273"><a href="#BigQuery.Parser-273"><span class="linenos">273</span></a> <span class="k">def</span> <span class="nf">_parse_table_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> +</span><span id="BigQuery.Parser-274"><a href="#BigQuery.Parser-274"><span class="linenos">274</span></a> <span class="n">table</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="BigQuery.Parser-275"><a href="#BigQuery.Parser-275"><span class="linenos">275</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">table</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">Identifier</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"."</span> <span class="ow">in</span> <span class="n">table</span><span class="o">.</span><span class="n">name</span><span class="p">:</span> +</span><span id="BigQuery.Parser-276"><a href="#BigQuery.Parser-276"><span class="linenos">276</span></a> <span class="n">catalog</span><span class="p">,</span> <span class="n">db</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="BigQuery.Parser-277"><a href="#BigQuery.Parser-277"><span class="linenos">277</span></a> <span class="n">t</span><span class="o">.</span><span class="n">cast</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="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">x</span><span class="p">))</span> +</span><span id="BigQuery.Parser-278"><a href="#BigQuery.Parser-278"><span class="linenos">278</span></a> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">split_num_words</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="s2">"."</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> +</span><span id="BigQuery.Parser-279"><a href="#BigQuery.Parser-279"><span class="linenos">279</span></a> <span class="p">)</span> +</span><span id="BigQuery.Parser-280"><a href="#BigQuery.Parser-280"><span class="linenos">280</span></a> +</span><span id="BigQuery.Parser-281"><a href="#BigQuery.Parser-281"><span class="linenos">281</span></a> <span class="k">if</span> <span class="n">rest</span> <span class="ow">and</span> <span class="n">this</span><span class="p">:</span> +</span><span id="BigQuery.Parser-282"><a href="#BigQuery.Parser-282"><span class="linenos">282</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="o">.</span><span class="n">build</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">cast</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="p">[</span><span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span><span class="p">]))</span> +</span><span id="BigQuery.Parser-283"><a href="#BigQuery.Parser-283"><span class="linenos">283</span></a> +</span><span id="BigQuery.Parser-284"><a href="#BigQuery.Parser-284"><span class="linenos">284</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="n">db</span><span class="p">,</span> <span class="n">catalog</span><span class="o">=</span><span class="n">catalog</span><span class="p">)</span> +</span><span id="BigQuery.Parser-285"><a href="#BigQuery.Parser-285"><span class="linenos">285</span></a> +</span><span id="BigQuery.Parser-286"><a href="#BigQuery.Parser-286"><span class="linenos">286</span></a> <span class="k">return</span> <span class="n">table</span> </span></pre></div> @@ -1041,129 +1120,129 @@ Default: 3</li> </div> <a class="headerlink" href="#BigQuery.Generator"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator-270"><a href="#BigQuery.Generator-270"><span class="linenos">270</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="BigQuery.Generator-271"><a href="#BigQuery.Generator-271"><span class="linenos">271</span></a> <span class="n">EXPLICIT_UNION</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="BigQuery.Generator-272"><a href="#BigQuery.Generator-272"><span class="linenos">272</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery.Generator-273"><a href="#BigQuery.Generator-273"><span class="linenos">273</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery.Generator-274"><a href="#BigQuery.Generator-274"><span class="linenos">274</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery.Generator-275"><a href="#BigQuery.Generator-275"><span class="linenos">275</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> -</span><span id="BigQuery.Generator-276"><a href="#BigQuery.Generator-276"><span class="linenos">276</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="BigQuery.Generator-277"><a href="#BigQuery.Generator-277"><span class="linenos">277</span></a> -</span><span id="BigQuery.Generator-278"><a href="#BigQuery.Generator-278"><span class="linenos">278</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery.Generator-279"><a href="#BigQuery.Generator-279"><span class="linenos">279</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="BigQuery.Generator-280"><a href="#BigQuery.Generator-280"><span class="linenos">280</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_COUNT_DISTINCT"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-281"><a href="#BigQuery.Generator-281"><span class="linenos">281</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="BigQuery.Generator-282"><a href="#BigQuery.Generator-282"><span class="linenos">282</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</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="BigQuery.Generator-283"><a href="#BigQuery.Generator-283"><span class="linenos">283</span></a> <span class="s2">"TIMESTAMP"</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">"DATETIME"</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">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">"zone"</span><span class="p">))</span> -</span><span id="BigQuery.Generator-284"><a href="#BigQuery.Generator-284"><span class="linenos">284</span></a> <span class="p">),</span> -</span><span id="BigQuery.Generator-285"><a href="#BigQuery.Generator-285"><span class="linenos">285</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</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">remove_precision_parameterized_types</span><span class="p">]),</span> -</span><span id="BigQuery.Generator-286"><a href="#BigQuery.Generator-286"><span class="linenos">286</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-287"><a href="#BigQuery.Generator-287"><span class="linenos">287</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-288"><a href="#BigQuery.Generator-288"><span class="linenos">288</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-289"><a href="#BigQuery.Generator-289"><span class="linenos">289</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-290"><a href="#BigQuery.Generator-290"><span class="linenos">290</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="sa">f</span><span class="s2">"DATE_DIFF(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">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="s1">'DAY'</span><span class="p">))</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-291"><a href="#BigQuery.Generator-291"><span class="linenos">291</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="BigQuery.Generator-292"><a href="#BigQuery.Generator-292"><span class="linenos">292</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</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">"DATE_TRUNC"</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">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)),</span> -</span><span id="BigQuery.Generator-293"><a href="#BigQuery.Generator-293"><span class="linenos">293</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRING_AGG"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-294"><a href="#BigQuery.Generator-294"><span class="linenos">294</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-295"><a href="#BigQuery.Generator-295"><span class="linenos">295</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DIV"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-296"><a href="#BigQuery.Generator-296"><span class="linenos">296</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> -</span><span id="BigQuery.Generator-297"><a href="#BigQuery.Generator-297"><span class="linenos">297</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> -</span><span id="BigQuery.Generator-298"><a href="#BigQuery.Generator-298"><span class="linenos">298</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</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="BigQuery.Generator-299"><a href="#BigQuery.Generator-299"><span class="linenos">299</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-300"><a href="#BigQuery.Generator-300"><span class="linenos">300</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="BigQuery.Generator-301"><a href="#BigQuery.Generator-301"><span class="linenos">301</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="BigQuery.Generator-302"><a href="#BigQuery.Generator-302"><span class="linenos">302</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">"position"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-303"><a href="#BigQuery.Generator-303"><span class="linenos">303</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">"occurrence"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-304"><a href="#BigQuery.Generator-304"><span class="linenos">304</span></a> <span class="p">),</span> -</span><span id="BigQuery.Generator-305"><a href="#BigQuery.Generator-305"><span class="linenos">305</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_CONTAINS"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-306"><a href="#BigQuery.Generator-306"><span class="linenos">306</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="BigQuery.Generator-307"><a href="#BigQuery.Generator-307"><span class="linenos">307</span></a> <span class="p">[</span><span class="n">_unqualify_unnest</span><span class="p">,</span> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">]</span> -</span><span id="BigQuery.Generator-308"><a href="#BigQuery.Generator-308"><span class="linenos">308</span></a> <span class="p">),</span> -</span><span id="BigQuery.Generator-309"><a href="#BigQuery.Generator-309"><span class="linenos">309</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</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">"PARSE_DATE(</span><span class="si">{</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 class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-310"><a href="#BigQuery.Generator-310"><span class="linenos">310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</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">"PARSE_TIMESTAMP(</span><span class="si">{</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 class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-311"><a href="#BigQuery.Generator-311"><span class="linenos">311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-312"><a href="#BigQuery.Generator-312"><span class="linenos">312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-313"><a href="#BigQuery.Generator-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-314"><a href="#BigQuery.Generator-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-315"><a href="#BigQuery.Generator-315"><span class="linenos">315</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="BigQuery.Generator-316"><a href="#BigQuery.Generator-316"><span class="linenos">316</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</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">"SAFE_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 </span><span 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">'to'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-317"><a href="#BigQuery.Generator-317"><span class="linenos">317</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="s2">"bigquery"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-318"><a href="#BigQuery.Generator-318"><span class="linenos">318</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> -</span><span id="BigQuery.Generator-319"><a href="#BigQuery.Generator-319"><span class="linenos">319</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</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">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-320"><a href="#BigQuery.Generator-320"><span class="linenos">320</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="BigQuery.Generator-321"><a href="#BigQuery.Generator-321"><span class="linenos">321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">:</span> <span class="n">_derived_table_values_to_unnest</span><span class="p">,</span> -</span><span id="BigQuery.Generator-322"><a href="#BigQuery.Generator-322"><span class="linenos">322</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">_returnsproperty_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-323"><a href="#BigQuery.Generator-323"><span class="linenos">323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> <span class="n">_create_sql</span><span class="p">,</span> -</span><span id="BigQuery.Generator-324"><a href="#BigQuery.Generator-324"><span class="linenos">324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</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="sa">f</span><span class="s2">"TRIM"</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">e</span><span class="o">.</span><span class="n">expression</span><span class="p">),</span> -</span><span id="BigQuery.Generator-325"><a href="#BigQuery.Generator-325"><span class="linenos">325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> <span class="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">"DETERMINISTIC"</span> -</span><span id="BigQuery.Generator-326"><a href="#BigQuery.Generator-326"><span class="linenos">326</span></a> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"IMMUTABLE"</span> -</span><span id="BigQuery.Generator-327"><a href="#BigQuery.Generator-327"><span class="linenos">327</span></a> <span class="k">else</span> <span class="s2">"NOT DETERMINISTIC"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-328"><a href="#BigQuery.Generator-328"><span class="linenos">328</span></a> <span class="p">}</span> -</span><span id="BigQuery.Generator-329"><a href="#BigQuery.Generator-329"><span class="linenos">329</span></a> -</span><span id="BigQuery.Generator-330"><a href="#BigQuery.Generator-330"><span class="linenos">330</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery.Generator-331"><a href="#BigQuery.Generator-331"><span class="linenos">331</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="BigQuery.Generator-332"><a href="#BigQuery.Generator-332"><span class="linenos">332</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">BIGDECIMAL</span><span class="p">:</span> <span class="s2">"BIGNUMERIC"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-333"><a href="#BigQuery.Generator-333"><span class="linenos">333</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">BIGINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-334"><a href="#BigQuery.Generator-334"><span class="linenos">334</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">"BYTES"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-335"><a href="#BigQuery.Generator-335"><span class="linenos">335</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">BOOLEAN</span><span class="p">:</span> <span class="s2">"BOOL"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-336"><a href="#BigQuery.Generator-336"><span class="linenos">336</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">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-337"><a href="#BigQuery.Generator-337"><span class="linenos">337</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="s2">"NUMERIC"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-338"><a href="#BigQuery.Generator-338"><span class="linenos">338</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">DOUBLE</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-339"><a href="#BigQuery.Generator-339"><span class="linenos">339</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">"FLOAT64"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-340"><a href="#BigQuery.Generator-340"><span class="linenos">340</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">INT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-341"><a href="#BigQuery.Generator-341"><span class="linenos">341</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">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-342"><a href="#BigQuery.Generator-342"><span class="linenos">342</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">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-343"><a href="#BigQuery.Generator-343"><span class="linenos">343</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">SMALLINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-344"><a href="#BigQuery.Generator-344"><span class="linenos">344</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="s2">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-345"><a href="#BigQuery.Generator-345"><span class="linenos">345</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</span><span class="p">:</span> <span class="s2">"DATETIME"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-346"><a href="#BigQuery.Generator-346"><span class="linenos">346</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-347"><a href="#BigQuery.Generator-347"><span class="linenos">347</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">TIMESTAMPLTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-348"><a href="#BigQuery.Generator-348"><span class="linenos">348</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">TINYINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-349"><a href="#BigQuery.Generator-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">VARBINARY</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-350"><a href="#BigQuery.Generator-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">VARCHAR</span><span class="p">:</span> <span class="s2">"STRING"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-351"><a href="#BigQuery.Generator-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">VARIANT</span><span class="p">:</span> <span class="s2">"ANY TYPE"</span><span class="p">,</span> -</span><span id="BigQuery.Generator-352"><a href="#BigQuery.Generator-352"><span class="linenos">352</span></a> <span class="p">}</span> -</span><span id="BigQuery.Generator-353"><a href="#BigQuery.Generator-353"><span class="linenos">353</span></a> -</span><span id="BigQuery.Generator-354"><a href="#BigQuery.Generator-354"><span class="linenos">354</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="BigQuery.Generator-355"><a href="#BigQuery.Generator-355"><span class="linenos">355</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">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="BigQuery.Generator-356"><a href="#BigQuery.Generator-356"><span class="linenos">356</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="BigQuery.Generator-357"><a href="#BigQuery.Generator-357"><span class="linenos">357</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="BigQuery.Generator-358"><a href="#BigQuery.Generator-358"><span class="linenos">358</span></a> <span class="p">}</span> -</span><span id="BigQuery.Generator-359"><a href="#BigQuery.Generator-359"><span class="linenos">359</span></a> -</span><span id="BigQuery.Generator-360"><a href="#BigQuery.Generator-360"><span class="linenos">360</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span><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">RESERVED_KEYWORDS</span><span class="p">,</span> <span class="s2">"hash"</span><span class="p">}</span> -</span><span id="BigQuery.Generator-361"><a href="#BigQuery.Generator-361"><span class="linenos">361</span></a> -</span><span id="BigQuery.Generator-362"><a href="#BigQuery.Generator-362"><span class="linenos">362</span></a> <span class="k">def</span> <span class="nf">array_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator-363"><a href="#BigQuery.Generator-363"><span class="linenos">363</span></a> <span class="n">first_arg</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> -</span><span id="BigQuery.Generator-364"><a href="#BigQuery.Generator-364"><span class="linenos">364</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">first_arg</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="BigQuery.Generator-365"><a href="#BigQuery.Generator-365"><span class="linenos">365</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ARRAY</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">first_arg</span><span class="p">))</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery.Generator-366"><a href="#BigQuery.Generator-366"><span class="linenos">366</span></a> -</span><span id="BigQuery.Generator-367"><a href="#BigQuery.Generator-367"><span class="linenos">367</span></a> <span class="k">return</span> <span class="n">inline_array_sql</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="BigQuery.Generator-368"><a href="#BigQuery.Generator-368"><span class="linenos">368</span></a> -</span><span id="BigQuery.Generator-369"><a href="#BigQuery.Generator-369"><span class="linenos">369</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator-370"><a href="#BigQuery.Generator-370"><span class="linenos">370</span></a> <span class="k">return</span> <span class="s2">"BEGIN TRANSACTION"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator-288"><a href="#BigQuery.Generator-288"><span class="linenos">288</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="BigQuery.Generator-289"><a href="#BigQuery.Generator-289"><span class="linenos">289</span></a> <span class="n">EXPLICIT_UNION</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="BigQuery.Generator-290"><a href="#BigQuery.Generator-290"><span class="linenos">290</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery.Generator-291"><a href="#BigQuery.Generator-291"><span class="linenos">291</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery.Generator-292"><a href="#BigQuery.Generator-292"><span class="linenos">292</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery.Generator-293"><a href="#BigQuery.Generator-293"><span class="linenos">293</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> +</span><span id="BigQuery.Generator-294"><a href="#BigQuery.Generator-294"><span class="linenos">294</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="BigQuery.Generator-295"><a href="#BigQuery.Generator-295"><span class="linenos">295</span></a> +</span><span id="BigQuery.Generator-296"><a href="#BigQuery.Generator-296"><span class="linenos">296</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery.Generator-297"><a href="#BigQuery.Generator-297"><span class="linenos">297</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="BigQuery.Generator-298"><a href="#BigQuery.Generator-298"><span class="linenos">298</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_COUNT_DISTINCT"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-299"><a href="#BigQuery.Generator-299"><span class="linenos">299</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="BigQuery.Generator-300"><a href="#BigQuery.Generator-300"><span class="linenos">300</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</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="BigQuery.Generator-301"><a href="#BigQuery.Generator-301"><span class="linenos">301</span></a> <span class="s2">"TIMESTAMP"</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">"DATETIME"</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">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">"zone"</span><span class="p">))</span> +</span><span id="BigQuery.Generator-302"><a href="#BigQuery.Generator-302"><span class="linenos">302</span></a> <span class="p">),</span> +</span><span id="BigQuery.Generator-303"><a href="#BigQuery.Generator-303"><span class="linenos">303</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</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">remove_precision_parameterized_types</span><span class="p">]),</span> +</span><span id="BigQuery.Generator-304"><a href="#BigQuery.Generator-304"><span class="linenos">304</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-305"><a href="#BigQuery.Generator-305"><span class="linenos">305</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-306"><a href="#BigQuery.Generator-306"><span class="linenos">306</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-307"><a href="#BigQuery.Generator-307"><span class="linenos">307</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DatetimeSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATETIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-308"><a href="#BigQuery.Generator-308"><span class="linenos">308</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="sa">f</span><span class="s2">"DATE_DIFF(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">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="s1">'DAY'</span><span class="p">))</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-309"><a href="#BigQuery.Generator-309"><span class="linenos">309</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="BigQuery.Generator-310"><a href="#BigQuery.Generator-310"><span class="linenos">310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</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">"DATE_TRUNC"</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">e</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)),</span> +</span><span id="BigQuery.Generator-311"><a href="#BigQuery.Generator-311"><span class="linenos">311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRING_AGG"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-312"><a href="#BigQuery.Generator-312"><span class="linenos">312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-313"><a href="#BigQuery.Generator-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DIV"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-314"><a href="#BigQuery.Generator-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> +</span><span id="BigQuery.Generator-315"><a href="#BigQuery.Generator-315"><span class="linenos">315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> +</span><span id="BigQuery.Generator-316"><a href="#BigQuery.Generator-316"><span class="linenos">316</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpExtract</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="BigQuery.Generator-317"><a href="#BigQuery.Generator-317"><span class="linenos">317</span></a> <span class="s2">"REGEXP_EXTRACT"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-318"><a href="#BigQuery.Generator-318"><span class="linenos">318</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="BigQuery.Generator-319"><a href="#BigQuery.Generator-319"><span class="linenos">319</span></a> <span class="n">e</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="BigQuery.Generator-320"><a href="#BigQuery.Generator-320"><span class="linenos">320</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">"position"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-321"><a href="#BigQuery.Generator-321"><span class="linenos">321</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">"occurrence"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-322"><a href="#BigQuery.Generator-322"><span class="linenos">322</span></a> <span class="p">),</span> +</span><span id="BigQuery.Generator-323"><a href="#BigQuery.Generator-323"><span class="linenos">323</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_CONTAINS"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-324"><a href="#BigQuery.Generator-324"><span class="linenos">324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="BigQuery.Generator-325"><a href="#BigQuery.Generator-325"><span class="linenos">325</span></a> <span class="p">[</span><span class="n">_unqualify_unnest</span><span class="p">,</span> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">]</span> +</span><span id="BigQuery.Generator-326"><a href="#BigQuery.Generator-326"><span class="linenos">326</span></a> <span class="p">),</span> +</span><span id="BigQuery.Generator-327"><a href="#BigQuery.Generator-327"><span class="linenos">327</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</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">"PARSE_DATE(</span><span class="si">{</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 class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-328"><a href="#BigQuery.Generator-328"><span class="linenos">328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</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">"PARSE_TIMESTAMP(</span><span class="si">{</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 class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-329"><a href="#BigQuery.Generator-329"><span class="linenos">329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-330"><a href="#BigQuery.Generator-330"><span class="linenos">330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-331"><a href="#BigQuery.Generator-331"><span class="linenos">331</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-332"><a href="#BigQuery.Generator-332"><span class="linenos">332</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampSub</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"SUB"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-333"><a href="#BigQuery.Generator-333"><span class="linenos">333</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="BigQuery.Generator-334"><a href="#BigQuery.Generator-334"><span class="linenos">334</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</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">"SAFE_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 </span><span 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">'to'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-335"><a href="#BigQuery.Generator-335"><span class="linenos">335</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="s2">"bigquery"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-336"><a href="#BigQuery.Generator-336"><span class="linenos">336</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">(</span><span class="s2">"DATE"</span><span class="p">,</span> <span class="s2">"ADD"</span><span class="p">),</span> +</span><span id="BigQuery.Generator-337"><a href="#BigQuery.Generator-337"><span class="linenos">337</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</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">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-338"><a href="#BigQuery.Generator-338"><span class="linenos">338</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="BigQuery.Generator-339"><a href="#BigQuery.Generator-339"><span class="linenos">339</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">:</span> <span class="n">_derived_table_values_to_unnest</span><span class="p">,</span> +</span><span id="BigQuery.Generator-340"><a href="#BigQuery.Generator-340"><span class="linenos">340</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">_returnsproperty_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-341"><a href="#BigQuery.Generator-341"><span class="linenos">341</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> <span class="n">_create_sql</span><span class="p">,</span> +</span><span id="BigQuery.Generator-342"><a href="#BigQuery.Generator-342"><span class="linenos">342</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</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="sa">f</span><span class="s2">"TRIM"</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">e</span><span class="o">.</span><span class="n">expression</span><span class="p">),</span> +</span><span id="BigQuery.Generator-343"><a href="#BigQuery.Generator-343"><span class="linenos">343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</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">"DETERMINISTIC"</span> +</span><span id="BigQuery.Generator-344"><a href="#BigQuery.Generator-344"><span class="linenos">344</span></a> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"IMMUTABLE"</span> +</span><span id="BigQuery.Generator-345"><a href="#BigQuery.Generator-345"><span class="linenos">345</span></a> <span class="k">else</span> <span class="s2">"NOT DETERMINISTIC"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-346"><a href="#BigQuery.Generator-346"><span class="linenos">346</span></a> <span class="p">}</span> +</span><span id="BigQuery.Generator-347"><a href="#BigQuery.Generator-347"><span class="linenos">347</span></a> +</span><span id="BigQuery.Generator-348"><a href="#BigQuery.Generator-348"><span class="linenos">348</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery.Generator-349"><a href="#BigQuery.Generator-349"><span class="linenos">349</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="BigQuery.Generator-350"><a href="#BigQuery.Generator-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">BIGDECIMAL</span><span class="p">:</span> <span class="s2">"BIGNUMERIC"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-351"><a href="#BigQuery.Generator-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">BIGINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-352"><a href="#BigQuery.Generator-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">BINARY</span><span class="p">:</span> <span class="s2">"BYTES"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-353"><a href="#BigQuery.Generator-353"><span class="linenos">353</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">BOOLEAN</span><span class="p">:</span> <span class="s2">"BOOL"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-354"><a href="#BigQuery.Generator-354"><span class="linenos">354</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">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-355"><a href="#BigQuery.Generator-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="s2">"NUMERIC"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-356"><a href="#BigQuery.Generator-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">DOUBLE</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-357"><a href="#BigQuery.Generator-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">FLOAT</span><span class="p">:</span> <span class="s2">"FLOAT64"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-358"><a href="#BigQuery.Generator-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">INT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-359"><a href="#BigQuery.Generator-359"><span class="linenos">359</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">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-360"><a href="#BigQuery.Generator-360"><span class="linenos">360</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">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-361"><a href="#BigQuery.Generator-361"><span class="linenos">361</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">SMALLINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-362"><a href="#BigQuery.Generator-362"><span class="linenos">362</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="s2">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-363"><a href="#BigQuery.Generator-363"><span class="linenos">363</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</span><span class="p">:</span> <span class="s2">"DATETIME"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-364"><a href="#BigQuery.Generator-364"><span class="linenos">364</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-365"><a href="#BigQuery.Generator-365"><span class="linenos">365</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">TIMESTAMPLTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-366"><a href="#BigQuery.Generator-366"><span class="linenos">366</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">TINYINT</span><span class="p">:</span> <span class="s2">"INT64"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-367"><a href="#BigQuery.Generator-367"><span class="linenos">367</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">"BYTES"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-368"><a href="#BigQuery.Generator-368"><span class="linenos">368</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">"STRING"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-369"><a href="#BigQuery.Generator-369"><span class="linenos">369</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">VARIANT</span><span class="p">:</span> <span class="s2">"ANY TYPE"</span><span class="p">,</span> +</span><span id="BigQuery.Generator-370"><a href="#BigQuery.Generator-370"><span class="linenos">370</span></a> <span class="p">}</span> </span><span id="BigQuery.Generator-371"><a href="#BigQuery.Generator-371"><span class="linenos">371</span></a> -</span><span id="BigQuery.Generator-372"><a href="#BigQuery.Generator-372"><span class="linenos">372</span></a> <span class="k">def</span> <span class="nf">commit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator-373"><a href="#BigQuery.Generator-373"><span class="linenos">373</span></a> <span class="k">return</span> <span class="s2">"COMMIT TRANSACTION"</span> -</span><span id="BigQuery.Generator-374"><a href="#BigQuery.Generator-374"><span class="linenos">374</span></a> -</span><span id="BigQuery.Generator-375"><a href="#BigQuery.Generator-375"><span class="linenos">375</span></a> <span class="k">def</span> <span class="nf">rollback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator-376"><a href="#BigQuery.Generator-376"><span class="linenos">376</span></a> <span class="k">return</span> <span class="s2">"ROLLBACK TRANSACTION"</span> +</span><span id="BigQuery.Generator-372"><a href="#BigQuery.Generator-372"><span class="linenos">372</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="BigQuery.Generator-373"><a href="#BigQuery.Generator-373"><span class="linenos">373</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">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="BigQuery.Generator-374"><a href="#BigQuery.Generator-374"><span class="linenos">374</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="BigQuery.Generator-375"><a href="#BigQuery.Generator-375"><span class="linenos">375</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="BigQuery.Generator-376"><a href="#BigQuery.Generator-376"><span class="linenos">376</span></a> <span class="p">}</span> </span><span id="BigQuery.Generator-377"><a href="#BigQuery.Generator-377"><span class="linenos">377</span></a> -</span><span id="BigQuery.Generator-378"><a href="#BigQuery.Generator-378"><span class="linenos">378</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator-379"><a href="#BigQuery.Generator-379"><span class="linenos">379</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><span id="BigQuery.Generator-380"><a href="#BigQuery.Generator-380"><span class="linenos">380</span></a> -</span><span id="BigQuery.Generator-381"><a href="#BigQuery.Generator-381"><span class="linenos">381</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator-382"><a href="#BigQuery.Generator-382"><span class="linenos">382</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> -</span><span id="BigQuery.Generator-383"><a href="#BigQuery.Generator-383"><span class="linenos">383</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"EXCEPT without DISTINCT is not supported in BigQuery"</span><span class="p">)</span> -</span><span id="BigQuery.Generator-384"><a href="#BigQuery.Generator-384"><span class="linenos">384</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">' DISTINCT'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery.Generator-385"><a href="#BigQuery.Generator-385"><span class="linenos">385</span></a> -</span><span id="BigQuery.Generator-386"><a href="#BigQuery.Generator-386"><span class="linenos">386</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator-387"><a href="#BigQuery.Generator-387"><span class="linenos">387</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> -</span><span id="BigQuery.Generator-388"><a href="#BigQuery.Generator-388"><span class="linenos">388</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"INTERSECT without DISTINCT is not supported in BigQuery"</span><span class="p">)</span> -</span><span id="BigQuery.Generator-389"><a href="#BigQuery.Generator-389"><span class="linenos">389</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">' DISTINCT'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery.Generator-390"><a href="#BigQuery.Generator-390"><span class="linenos">390</span></a> -</span><span id="BigQuery.Generator-391"><a href="#BigQuery.Generator-391"><span class="linenos">391</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator-392"><a href="#BigQuery.Generator-392"><span class="linenos">392</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"OPTIONS"</span><span class="p">))</span> +</span><span id="BigQuery.Generator-378"><a href="#BigQuery.Generator-378"><span class="linenos">378</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span><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">RESERVED_KEYWORDS</span><span class="p">,</span> <span class="s2">"hash"</span><span class="p">}</span> +</span><span id="BigQuery.Generator-379"><a href="#BigQuery.Generator-379"><span class="linenos">379</span></a> +</span><span id="BigQuery.Generator-380"><a href="#BigQuery.Generator-380"><span class="linenos">380</span></a> <span class="k">def</span> <span class="nf">array_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator-381"><a href="#BigQuery.Generator-381"><span class="linenos">381</span></a> <span class="n">first_arg</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="BigQuery.Generator-382"><a href="#BigQuery.Generator-382"><span class="linenos">382</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">first_arg</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="BigQuery.Generator-383"><a href="#BigQuery.Generator-383"><span class="linenos">383</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ARRAY</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">first_arg</span><span class="p">))</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery.Generator-384"><a href="#BigQuery.Generator-384"><span class="linenos">384</span></a> +</span><span id="BigQuery.Generator-385"><a href="#BigQuery.Generator-385"><span class="linenos">385</span></a> <span class="k">return</span> <span class="n">inline_array_sql</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="BigQuery.Generator-386"><a href="#BigQuery.Generator-386"><span class="linenos">386</span></a> +</span><span id="BigQuery.Generator-387"><a href="#BigQuery.Generator-387"><span class="linenos">387</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator-388"><a href="#BigQuery.Generator-388"><span class="linenos">388</span></a> <span class="k">return</span> <span class="s2">"BEGIN TRANSACTION"</span> +</span><span id="BigQuery.Generator-389"><a href="#BigQuery.Generator-389"><span class="linenos">389</span></a> +</span><span id="BigQuery.Generator-390"><a href="#BigQuery.Generator-390"><span class="linenos">390</span></a> <span class="k">def</span> <span class="nf">commit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator-391"><a href="#BigQuery.Generator-391"><span class="linenos">391</span></a> <span class="k">return</span> <span class="s2">"COMMIT TRANSACTION"</span> +</span><span id="BigQuery.Generator-392"><a href="#BigQuery.Generator-392"><span class="linenos">392</span></a> +</span><span id="BigQuery.Generator-393"><a href="#BigQuery.Generator-393"><span class="linenos">393</span></a> <span class="k">def</span> <span class="nf">rollback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator-394"><a href="#BigQuery.Generator-394"><span class="linenos">394</span></a> <span class="k">return</span> <span class="s2">"ROLLBACK TRANSACTION"</span> +</span><span id="BigQuery.Generator-395"><a href="#BigQuery.Generator-395"><span class="linenos">395</span></a> +</span><span id="BigQuery.Generator-396"><a href="#BigQuery.Generator-396"><span class="linenos">396</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator-397"><a href="#BigQuery.Generator-397"><span class="linenos">397</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><span id="BigQuery.Generator-398"><a href="#BigQuery.Generator-398"><span class="linenos">398</span></a> +</span><span id="BigQuery.Generator-399"><a href="#BigQuery.Generator-399"><span class="linenos">399</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator-400"><a href="#BigQuery.Generator-400"><span class="linenos">400</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> +</span><span id="BigQuery.Generator-401"><a href="#BigQuery.Generator-401"><span class="linenos">401</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"EXCEPT without DISTINCT is not supported in BigQuery"</span><span class="p">)</span> +</span><span id="BigQuery.Generator-402"><a href="#BigQuery.Generator-402"><span class="linenos">402</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">' DISTINCT'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery.Generator-403"><a href="#BigQuery.Generator-403"><span class="linenos">403</span></a> +</span><span id="BigQuery.Generator-404"><a href="#BigQuery.Generator-404"><span class="linenos">404</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator-405"><a href="#BigQuery.Generator-405"><span class="linenos">405</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> +</span><span id="BigQuery.Generator-406"><a href="#BigQuery.Generator-406"><span class="linenos">406</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"INTERSECT without DISTINCT is not supported in BigQuery"</span><span class="p">)</span> +</span><span id="BigQuery.Generator-407"><a href="#BigQuery.Generator-407"><span class="linenos">407</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">' DISTINCT'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery.Generator-408"><a href="#BigQuery.Generator-408"><span class="linenos">408</span></a> +</span><span id="BigQuery.Generator-409"><a href="#BigQuery.Generator-409"><span class="linenos">409</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator-410"><a href="#BigQuery.Generator-410"><span class="linenos">410</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"OPTIONS"</span><span class="p">))</span> </span></pre></div> @@ -1217,12 +1296,12 @@ Default: True</li> </div> <a class="headerlink" href="#BigQuery.Generator.array_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.array_sql-362"><a href="#BigQuery.Generator.array_sql-362"><span class="linenos">362</span></a> <span class="k">def</span> <span class="nf">array_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator.array_sql-363"><a href="#BigQuery.Generator.array_sql-363"><span class="linenos">363</span></a> <span class="n">first_arg</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> -</span><span id="BigQuery.Generator.array_sql-364"><a href="#BigQuery.Generator.array_sql-364"><span class="linenos">364</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">first_arg</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="BigQuery.Generator.array_sql-365"><a href="#BigQuery.Generator.array_sql-365"><span class="linenos">365</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ARRAY</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">first_arg</span><span class="p">))</span><span class="si">}</span><span class="s2">"</span> -</span><span id="BigQuery.Generator.array_sql-366"><a href="#BigQuery.Generator.array_sql-366"><span class="linenos">366</span></a> -</span><span id="BigQuery.Generator.array_sql-367"><a href="#BigQuery.Generator.array_sql-367"><span class="linenos">367</span></a> <span class="k">return</span> <span class="n">inline_array_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="BigQuery.Generator.array_sql-380"><a href="#BigQuery.Generator.array_sql-380"><span class="linenos">380</span></a> <span class="k">def</span> <span class="nf">array_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator.array_sql-381"><a href="#BigQuery.Generator.array_sql-381"><span class="linenos">381</span></a> <span class="n">first_arg</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="BigQuery.Generator.array_sql-382"><a href="#BigQuery.Generator.array_sql-382"><span class="linenos">382</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">first_arg</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="BigQuery.Generator.array_sql-383"><a href="#BigQuery.Generator.array_sql-383"><span class="linenos">383</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ARRAY</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">first_arg</span><span class="p">))</span><span class="si">}</span><span class="s2">"</span> +</span><span id="BigQuery.Generator.array_sql-384"><a href="#BigQuery.Generator.array_sql-384"><span class="linenos">384</span></a> +</span><span id="BigQuery.Generator.array_sql-385"><a href="#BigQuery.Generator.array_sql-385"><span class="linenos">385</span></a> <span class="k">return</span> <span class="n">inline_array_sql</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> @@ -1240,8 +1319,8 @@ Default: True</li> </div> <a class="headerlink" href="#BigQuery.Generator.transaction_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.transaction_sql-369"><a href="#BigQuery.Generator.transaction_sql-369"><span class="linenos">369</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator.transaction_sql-370"><a href="#BigQuery.Generator.transaction_sql-370"><span class="linenos">370</span></a> <span class="k">return</span> <span class="s2">"BEGIN TRANSACTION"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.transaction_sql-387"><a href="#BigQuery.Generator.transaction_sql-387"><span class="linenos">387</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator.transaction_sql-388"><a href="#BigQuery.Generator.transaction_sql-388"><span class="linenos">388</span></a> <span class="k">return</span> <span class="s2">"BEGIN TRANSACTION"</span> </span></pre></div> @@ -1259,8 +1338,8 @@ Default: True</li> </div> <a class="headerlink" href="#BigQuery.Generator.commit_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.commit_sql-372"><a href="#BigQuery.Generator.commit_sql-372"><span class="linenos">372</span></a> <span class="k">def</span> <span class="nf">commit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator.commit_sql-373"><a href="#BigQuery.Generator.commit_sql-373"><span class="linenos">373</span></a> <span class="k">return</span> <span class="s2">"COMMIT TRANSACTION"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.commit_sql-390"><a href="#BigQuery.Generator.commit_sql-390"><span class="linenos">390</span></a> <span class="k">def</span> <span class="nf">commit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator.commit_sql-391"><a href="#BigQuery.Generator.commit_sql-391"><span class="linenos">391</span></a> <span class="k">return</span> <span class="s2">"COMMIT TRANSACTION"</span> </span></pre></div> @@ -1278,8 +1357,8 @@ Default: True</li> </div> <a class="headerlink" href="#BigQuery.Generator.rollback_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.rollback_sql-375"><a href="#BigQuery.Generator.rollback_sql-375"><span class="linenos">375</span></a> <span class="k">def</span> <span class="nf">rollback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator.rollback_sql-376"><a href="#BigQuery.Generator.rollback_sql-376"><span class="linenos">376</span></a> <span class="k">return</span> <span class="s2">"ROLLBACK TRANSACTION"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.rollback_sql-393"><a href="#BigQuery.Generator.rollback_sql-393"><span class="linenos">393</span></a> <span class="k">def</span> <span class="nf">rollback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator.rollback_sql-394"><a href="#BigQuery.Generator.rollback_sql-394"><span class="linenos">394</span></a> <span class="k">return</span> <span class="s2">"ROLLBACK TRANSACTION"</span> </span></pre></div> @@ -1297,8 +1376,8 @@ Default: True</li> </div> <a class="headerlink" href="#BigQuery.Generator.in_unnest_op"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.in_unnest_op-378"><a href="#BigQuery.Generator.in_unnest_op-378"><span class="linenos">378</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator.in_unnest_op-379"><a href="#BigQuery.Generator.in_unnest_op-379"><span class="linenos">379</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> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.in_unnest_op-396"><a href="#BigQuery.Generator.in_unnest_op-396"><span class="linenos">396</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator.in_unnest_op-397"><a href="#BigQuery.Generator.in_unnest_op-397"><span class="linenos">397</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></pre></div> @@ -1316,10 +1395,10 @@ Default: True</li> </div> <a class="headerlink" href="#BigQuery.Generator.except_op"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.except_op-381"><a href="#BigQuery.Generator.except_op-381"><span class="linenos">381</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator.except_op-382"><a href="#BigQuery.Generator.except_op-382"><span class="linenos">382</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> -</span><span id="BigQuery.Generator.except_op-383"><a href="#BigQuery.Generator.except_op-383"><span class="linenos">383</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"EXCEPT without DISTINCT is not supported in BigQuery"</span><span class="p">)</span> -</span><span id="BigQuery.Generator.except_op-384"><a href="#BigQuery.Generator.except_op-384"><span class="linenos">384</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">' DISTINCT'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.except_op-399"><a href="#BigQuery.Generator.except_op-399"><span class="linenos">399</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator.except_op-400"><a href="#BigQuery.Generator.except_op-400"><span class="linenos">400</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> +</span><span id="BigQuery.Generator.except_op-401"><a href="#BigQuery.Generator.except_op-401"><span class="linenos">401</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"EXCEPT without DISTINCT is not supported in BigQuery"</span><span class="p">)</span> +</span><span id="BigQuery.Generator.except_op-402"><a href="#BigQuery.Generator.except_op-402"><span class="linenos">402</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">' DISTINCT'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -1337,10 +1416,10 @@ Default: True</li> </div> <a class="headerlink" href="#BigQuery.Generator.intersect_op"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.intersect_op-386"><a href="#BigQuery.Generator.intersect_op-386"><span class="linenos">386</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator.intersect_op-387"><a href="#BigQuery.Generator.intersect_op-387"><span class="linenos">387</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> -</span><span id="BigQuery.Generator.intersect_op-388"><a href="#BigQuery.Generator.intersect_op-388"><span class="linenos">388</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"INTERSECT without DISTINCT is not supported in BigQuery"</span><span class="p">)</span> -</span><span id="BigQuery.Generator.intersect_op-389"><a href="#BigQuery.Generator.intersect_op-389"><span class="linenos">389</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">' DISTINCT'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.intersect_op-404"><a href="#BigQuery.Generator.intersect_op-404"><span class="linenos">404</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator.intersect_op-405"><a href="#BigQuery.Generator.intersect_op-405"><span class="linenos">405</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> +</span><span id="BigQuery.Generator.intersect_op-406"><a href="#BigQuery.Generator.intersect_op-406"><span class="linenos">406</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"INTERSECT without DISTINCT is not supported in BigQuery"</span><span class="p">)</span> +</span><span id="BigQuery.Generator.intersect_op-407"><a href="#BigQuery.Generator.intersect_op-407"><span class="linenos">407</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">' DISTINCT'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -1358,14 +1437,68 @@ Default: True</li> </div> <a class="headerlink" href="#BigQuery.Generator.with_properties"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.with_properties-391"><a href="#BigQuery.Generator.with_properties-391"><span class="linenos">391</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="BigQuery.Generator.with_properties-392"><a href="#BigQuery.Generator.with_properties-392"><span class="linenos">392</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"OPTIONS"</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.with_properties-409"><a href="#BigQuery.Generator.with_properties-409"><span class="linenos">409</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="BigQuery.Generator.with_properties-410"><a href="#BigQuery.Generator.with_properties-410"><span class="linenos">410</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"OPTIONS"</span><span class="p">))</span> </span></pre></div> </div> + <div id="BigQuery.Generator.can_identify" class="classattr"> + <input id="BigQuery.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="BigQuery.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#BigQuery.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="BigQuery.Generator.can_identify-247"><a href="#BigQuery.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="BigQuery.Generator.can_identify-248"><a href="#BigQuery.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="BigQuery.Generator.can_identify-249"><a href="#BigQuery.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="BigQuery.Generator.can_identify-250"><a href="#BigQuery.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="BigQuery.Generator.can_identify-251"><a href="#BigQuery.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="BigQuery.Generator.can_identify-252"><a href="#BigQuery.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="BigQuery.Generator.can_identify-253"><a href="#BigQuery.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="BigQuery.Generator.can_identify-254"><a href="#BigQuery.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="BigQuery.Generator.can_identify-255"><a href="#BigQuery.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="BigQuery.Generator.can_identify-256"><a href="#BigQuery.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="BigQuery.Generator.can_identify-257"><a href="#BigQuery.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="BigQuery.Generator.can_identify-258"><a href="#BigQuery.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="BigQuery.Generator.can_identify-259"><a href="#BigQuery.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="BigQuery.Generator.can_identify-260"><a href="#BigQuery.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="BigQuery.Generator.can_identify-261"><a href="#BigQuery.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="BigQuery.Generator.can_identify-262"><a href="#BigQuery.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="BigQuery.Generator.can_identify-263"><a href="#BigQuery.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="BigQuery.Generator.can_identify-264"><a href="#BigQuery.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="BigQuery.Generator.can_identify-265"><a href="#BigQuery.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="BigQuery.Generator.can_identify-266"><a href="#BigQuery.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -1465,6 +1598,7 @@ Default: True</li> <dd id="BigQuery.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="BigQuery.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="BigQuery.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="BigQuery.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="BigQuery.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="BigQuery.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="BigQuery.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/dialects/clickhouse.html b/docs/sqlglot/dialects/clickhouse.html index e0d93dd..eee0b0d 100644 --- a/docs/sqlglot/dialects/clickhouse.html +++ b/docs/sqlglot/dialects/clickhouse.html @@ -69,6 +69,9 @@ <li> <a class="function" href="#ClickHouse.Generator.createable_sql">createable_sql</a> </li> + <li> + <a class="function" href="#ClickHouse.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -445,7 +448,7 @@ </span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> <span class="s2">"CONCAT"</span><span class="p">,</span> </span><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a> <span class="o">*</span><span class="p">[</span> </span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"if"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">is_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">null</span><span class="p">()),</span> <span class="n">e</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">))</span> -</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</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">Condition</span><span class="p">],</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> </span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> <span class="p">],</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> @@ -829,7 +832,7 @@ </span><span id="ClickHouse-346"><a href="#ClickHouse-346"><span class="linenos">346</span></a> <span class="s2">"CONCAT"</span><span class="p">,</span> </span><span id="ClickHouse-347"><a href="#ClickHouse-347"><span class="linenos">347</span></a> <span class="o">*</span><span class="p">[</span> </span><span id="ClickHouse-348"><a href="#ClickHouse-348"><span class="linenos">348</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"if"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">is_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">null</span><span class="p">()),</span> <span class="n">e</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">))</span> -</span><span id="ClickHouse-349"><a href="#ClickHouse-349"><span class="linenos">349</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="ClickHouse-349"><a href="#ClickHouse-349"><span class="linenos">349</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</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">Condition</span><span class="p">],</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> </span><span id="ClickHouse-350"><a href="#ClickHouse-350"><span class="linenos">350</span></a> <span class="p">],</span> </span><span id="ClickHouse-351"><a href="#ClickHouse-351"><span class="linenos">351</span></a> <span class="p">)</span> </span><span id="ClickHouse-352"><a href="#ClickHouse-352"><span class="linenos">352</span></a> @@ -884,6 +887,10 @@ <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="ClickHouse.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="ClickHouse.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="ClickHouse.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="ClickHouse.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="ClickHouse.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="ClickHouse.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="ClickHouse.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="ClickHouse.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="ClickHouse.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -1301,7 +1308,7 @@ Default: 3</li> </span><span id="ClickHouse.Generator-346"><a href="#ClickHouse.Generator-346"><span class="linenos">346</span></a> <span class="s2">"CONCAT"</span><span class="p">,</span> </span><span id="ClickHouse.Generator-347"><a href="#ClickHouse.Generator-347"><span class="linenos">347</span></a> <span class="o">*</span><span class="p">[</span> </span><span id="ClickHouse.Generator-348"><a href="#ClickHouse.Generator-348"><span class="linenos">348</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"if"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">is_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">null</span><span class="p">()),</span> <span class="n">e</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">))</span> -</span><span id="ClickHouse.Generator-349"><a href="#ClickHouse.Generator-349"><span class="linenos">349</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="ClickHouse.Generator-349"><a href="#ClickHouse.Generator-349"><span class="linenos">349</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</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">Condition</span><span class="p">],</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> </span><span id="ClickHouse.Generator-350"><a href="#ClickHouse.Generator-350"><span class="linenos">350</span></a> <span class="p">],</span> </span><span id="ClickHouse.Generator-351"><a href="#ClickHouse.Generator-351"><span class="linenos">351</span></a> <span class="p">)</span> </span><span id="ClickHouse.Generator-352"><a href="#ClickHouse.Generator-352"><span class="linenos">352</span></a> @@ -1404,7 +1411,7 @@ Default: True</li> </span><span id="ClickHouse.Generator.safeconcat_sql-346"><a href="#ClickHouse.Generator.safeconcat_sql-346"><span class="linenos">346</span></a> <span class="s2">"CONCAT"</span><span class="p">,</span> </span><span id="ClickHouse.Generator.safeconcat_sql-347"><a href="#ClickHouse.Generator.safeconcat_sql-347"><span class="linenos">347</span></a> <span class="o">*</span><span class="p">[</span> </span><span id="ClickHouse.Generator.safeconcat_sql-348"><a href="#ClickHouse.Generator.safeconcat_sql-348"><span class="linenos">348</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"if"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">is_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">null</span><span class="p">()),</span> <span class="n">e</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">))</span> -</span><span id="ClickHouse.Generator.safeconcat_sql-349"><a href="#ClickHouse.Generator.safeconcat_sql-349"><span class="linenos">349</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="ClickHouse.Generator.safeconcat_sql-349"><a href="#ClickHouse.Generator.safeconcat_sql-349"><span class="linenos">349</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</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">Condition</span><span class="p">],</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> </span><span id="ClickHouse.Generator.safeconcat_sql-350"><a href="#ClickHouse.Generator.safeconcat_sql-350"><span class="linenos">350</span></a> <span class="p">],</span> </span><span id="ClickHouse.Generator.safeconcat_sql-351"><a href="#ClickHouse.Generator.safeconcat_sql-351"><span class="linenos">351</span></a> <span class="p">)</span> </span></pre></div> @@ -1550,6 +1557,60 @@ Default: True</li> </div> + <div id="ClickHouse.Generator.can_identify" class="classattr"> + <input id="ClickHouse.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="ClickHouse.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#ClickHouse.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="ClickHouse.Generator.can_identify-247"><a href="#ClickHouse.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="ClickHouse.Generator.can_identify-248"><a href="#ClickHouse.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="ClickHouse.Generator.can_identify-249"><a href="#ClickHouse.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="ClickHouse.Generator.can_identify-250"><a href="#ClickHouse.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="ClickHouse.Generator.can_identify-251"><a href="#ClickHouse.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="ClickHouse.Generator.can_identify-252"><a href="#ClickHouse.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="ClickHouse.Generator.can_identify-253"><a href="#ClickHouse.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="ClickHouse.Generator.can_identify-254"><a href="#ClickHouse.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="ClickHouse.Generator.can_identify-255"><a href="#ClickHouse.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="ClickHouse.Generator.can_identify-256"><a href="#ClickHouse.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="ClickHouse.Generator.can_identify-257"><a href="#ClickHouse.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="ClickHouse.Generator.can_identify-258"><a href="#ClickHouse.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="ClickHouse.Generator.can_identify-259"><a href="#ClickHouse.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="ClickHouse.Generator.can_identify-260"><a href="#ClickHouse.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="ClickHouse.Generator.can_identify-261"><a href="#ClickHouse.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="ClickHouse.Generator.can_identify-262"><a href="#ClickHouse.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="ClickHouse.Generator.can_identify-263"><a href="#ClickHouse.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="ClickHouse.Generator.can_identify-264"><a href="#ClickHouse.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="ClickHouse.Generator.can_identify-265"><a href="#ClickHouse.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="ClickHouse.Generator.can_identify-266"><a href="#ClickHouse.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -1650,6 +1711,7 @@ Default: True</li> <dd id="ClickHouse.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="ClickHouse.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="ClickHouse.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="ClickHouse.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="ClickHouse.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="ClickHouse.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="ClickHouse.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/dialects/databricks.html b/docs/sqlglot/dialects/databricks.html index 3cd45cf..3e8906e 100644 --- a/docs/sqlglot/dialects/databricks.html +++ b/docs/sqlglot/dialects/databricks.html @@ -42,6 +42,9 @@ <li> <a class="class" href="#Databricks.Generator">Databricks.Generator</a> <ul class="memberlist"> + <li> + <a class="function" href="#Databricks.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -192,6 +195,10 @@ <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="Databricks.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="Databricks.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="Databricks.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="Databricks.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="Databricks.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="Databricks.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="Databricks.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="Databricks.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="Databricks.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -335,6 +342,60 @@ Default: True</li> </div> + <div id="Databricks.Generator.can_identify" class="classattr"> + <input id="Databricks.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="Databricks.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Databricks.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Databricks.Generator.can_identify-247"><a href="#Databricks.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="Databricks.Generator.can_identify-248"><a href="#Databricks.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Databricks.Generator.can_identify-249"><a href="#Databricks.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="Databricks.Generator.can_identify-250"><a href="#Databricks.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="Databricks.Generator.can_identify-251"><a href="#Databricks.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="Databricks.Generator.can_identify-252"><a href="#Databricks.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="Databricks.Generator.can_identify-253"><a href="#Databricks.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="Databricks.Generator.can_identify-254"><a href="#Databricks.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="Databricks.Generator.can_identify-255"><a href="#Databricks.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="Databricks.Generator.can_identify-256"><a href="#Databricks.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="Databricks.Generator.can_identify-257"><a href="#Databricks.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="Databricks.Generator.can_identify-258"><a href="#Databricks.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="Databricks.Generator.can_identify-259"><a href="#Databricks.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="Databricks.Generator.can_identify-260"><a href="#Databricks.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="Databricks.Generator.can_identify-261"><a href="#Databricks.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Databricks.Generator.can_identify-262"><a href="#Databricks.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="Databricks.Generator.can_identify-263"><a href="#Databricks.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="Databricks.Generator.can_identify-264"><a href="#Databricks.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="Databricks.Generator.can_identify-265"><a href="#Databricks.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="Databricks.Generator.can_identify-266"><a href="#Databricks.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -434,6 +495,7 @@ Default: True</li> <dd id="Databricks.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="Databricks.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="Databricks.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="Databricks.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="Databricks.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="Databricks.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="Databricks.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/dialects/dialect.html b/docs/sqlglot/dialects/dialect.html index e8e002d..74a0d0a 100644 --- a/docs/sqlglot/dialects/dialect.html +++ b/docs/sqlglot/dialects/dialect.html @@ -109,6 +109,18 @@ <a class="function" href="#Dialect.format_time">format_time</a> </li> <li> + <a class="function" href="#Dialect.normalize_identifier">normalize_identifier</a> + </li> + <li> + <a class="function" href="#Dialect.case_sensitive">case_sensitive</a> + </li> + <li> + <a class="function" href="#Dialect.can_identify">can_identify</a> + </li> + <li> + <a class="function" href="#Dialect.quote_identifier">quote_identifier</a> + </li> + <li> <a class="function" href="#Dialect.parse">parse</a> </li> <li> @@ -275,577 +287,639 @@ </span><span id="L-4"><a href="#L-4"><span class="linenos"> 4</span></a><span class="kn">from</span> <span class="nn">enum</span> <span class="kn">import</span> <span class="n">Enum</span> </span><span id="L-5"><a href="#L-5"><span class="linenos"> 5</span></a> </span><span id="L-6"><a href="#L-6"><span class="linenos"> 6</span></a><span class="kn">from</span> <span class="nn">sqlglot</span> <span class="kn">import</span> <span class="n">exp</span> -</span><span id="L-7"><a href="#L-7"><span class="linenos"> 7</span></a><span class="kn">from</span> <span class="nn">sqlglot.generator</span> <span class="kn">import</span> <span class="n">Generator</span> -</span><span id="L-8"><a href="#L-8"><span class="linenos"> 8</span></a><span class="kn">from</span> <span class="nn">sqlglot.helper</span> <span class="kn">import</span> <span class="n">flatten</span><span class="p">,</span> <span class="n">seq_get</span> -</span><span id="L-9"><a href="#L-9"><span class="linenos"> 9</span></a><span class="kn">from</span> <span class="nn">sqlglot.parser</span> <span class="kn">import</span> <span class="n">Parser</span> -</span><span id="L-10"><a href="#L-10"><span class="linenos"> 10</span></a><span class="kn">from</span> <span class="nn">sqlglot.time</span> <span class="kn">import</span> <span class="n">format_time</span> -</span><span id="L-11"><a href="#L-11"><span class="linenos"> 11</span></a><span class="kn">from</span> <span class="nn">sqlglot.tokens</span> <span class="kn">import</span> <span class="n">Token</span><span class="p">,</span> <span class="n">Tokenizer</span><span class="p">,</span> <span class="n">TokenType</span> -</span><span id="L-12"><a href="#L-12"><span class="linenos"> 12</span></a><span class="kn">from</span> <span class="nn">sqlglot.trie</span> <span class="kn">import</span> <span class="n">new_trie</span> -</span><span id="L-13"><a href="#L-13"><span class="linenos"> 13</span></a> -</span><span id="L-14"><a href="#L-14"><span class="linenos"> 14</span></a><span class="k">if</span> <span class="n">t</span><span class="o">.</span><span class="n">TYPE_CHECKING</span><span class="p">:</span> -</span><span id="L-15"><a href="#L-15"><span class="linenos"> 15</span></a> <span class="kn">from</span> <span class="nn">sqlglot._typing</span> <span class="kn">import</span> <span class="n">E</span> -</span><span id="L-16"><a href="#L-16"><span class="linenos"> 16</span></a> -</span><span id="L-17"><a href="#L-17"><span class="linenos"> 17</span></a> -</span><span id="L-18"><a href="#L-18"><span class="linenos"> 18</span></a><span class="c1"># Only Snowflake is currently known to resolve unquoted identifiers as uppercase.</span> -</span><span id="L-19"><a href="#L-19"><span class="linenos"> 19</span></a><span class="c1"># https://docs.snowflake.com/en/sql-reference/identifiers-syntax</span> -</span><span id="L-20"><a href="#L-20"><span class="linenos"> 20</span></a><span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"snowflake"</span><span class="p">}</span> -</span><span id="L-21"><a href="#L-21"><span class="linenos"> 21</span></a> -</span><span id="L-22"><a href="#L-22"><span class="linenos"> 22</span></a> -</span><span id="L-23"><a href="#L-23"><span class="linenos"> 23</span></a><span class="k">class</span> <span class="nc">Dialects</span><span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="n">Enum</span><span class="p">):</span> -</span><span id="L-24"><a href="#L-24"><span class="linenos"> 24</span></a> <span class="n">DIALECT</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-25"><a href="#L-25"><span class="linenos"> 25</span></a> -</span><span id="L-26"><a href="#L-26"><span class="linenos"> 26</span></a> <span class="n">BIGQUERY</span> <span class="o">=</span> <span class="s2">"bigquery"</span> -</span><span id="L-27"><a href="#L-27"><span class="linenos"> 27</span></a> <span class="n">CLICKHOUSE</span> <span class="o">=</span> <span class="s2">"clickhouse"</span> -</span><span id="L-28"><a href="#L-28"><span class="linenos"> 28</span></a> <span class="n">DATABRICKS</span> <span class="o">=</span> <span class="s2">"databricks"</span> -</span><span id="L-29"><a href="#L-29"><span class="linenos"> 29</span></a> <span class="n">DRILL</span> <span class="o">=</span> <span class="s2">"drill"</span> -</span><span id="L-30"><a href="#L-30"><span class="linenos"> 30</span></a> <span class="n">DUCKDB</span> <span class="o">=</span> <span class="s2">"duckdb"</span> -</span><span id="L-31"><a href="#L-31"><span class="linenos"> 31</span></a> <span class="n">HIVE</span> <span class="o">=</span> <span class="s2">"hive"</span> -</span><span id="L-32"><a href="#L-32"><span class="linenos"> 32</span></a> <span class="n">MYSQL</span> <span class="o">=</span> <span class="s2">"mysql"</span> -</span><span id="L-33"><a href="#L-33"><span class="linenos"> 33</span></a> <span class="n">ORACLE</span> <span class="o">=</span> <span class="s2">"oracle"</span> -</span><span id="L-34"><a href="#L-34"><span class="linenos"> 34</span></a> <span class="n">POSTGRES</span> <span class="o">=</span> <span class="s2">"postgres"</span> -</span><span id="L-35"><a href="#L-35"><span class="linenos"> 35</span></a> <span class="n">PRESTO</span> <span class="o">=</span> <span class="s2">"presto"</span> -</span><span id="L-36"><a href="#L-36"><span class="linenos"> 36</span></a> <span class="n">REDSHIFT</span> <span class="o">=</span> <span class="s2">"redshift"</span> -</span><span id="L-37"><a href="#L-37"><span class="linenos"> 37</span></a> <span class="n">SNOWFLAKE</span> <span class="o">=</span> <span class="s2">"snowflake"</span> -</span><span id="L-38"><a href="#L-38"><span class="linenos"> 38</span></a> <span class="n">SPARK</span> <span class="o">=</span> <span class="s2">"spark"</span> -</span><span id="L-39"><a href="#L-39"><span class="linenos"> 39</span></a> <span class="n">SPARK2</span> <span class="o">=</span> <span class="s2">"spark2"</span> -</span><span id="L-40"><a href="#L-40"><span class="linenos"> 40</span></a> <span class="n">SQLITE</span> <span class="o">=</span> <span class="s2">"sqlite"</span> -</span><span id="L-41"><a href="#L-41"><span class="linenos"> 41</span></a> <span class="n">STARROCKS</span> <span class="o">=</span> <span class="s2">"starrocks"</span> -</span><span id="L-42"><a href="#L-42"><span class="linenos"> 42</span></a> <span class="n">TABLEAU</span> <span class="o">=</span> <span class="s2">"tableau"</span> -</span><span id="L-43"><a href="#L-43"><span class="linenos"> 43</span></a> <span class="n">TERADATA</span> <span class="o">=</span> <span class="s2">"teradata"</span> -</span><span id="L-44"><a href="#L-44"><span class="linenos"> 44</span></a> <span class="n">TRINO</span> <span class="o">=</span> <span class="s2">"trino"</span> -</span><span id="L-45"><a href="#L-45"><span class="linenos"> 45</span></a> <span class="n">TSQL</span> <span class="o">=</span> <span class="s2">"tsql"</span> -</span><span id="L-46"><a href="#L-46"><span class="linenos"> 46</span></a> -</span><span id="L-47"><a href="#L-47"><span class="linenos"> 47</span></a> -</span><span id="L-48"><a href="#L-48"><span class="linenos"> 48</span></a><span class="k">class</span> <span class="nc">_Dialect</span><span class="p">(</span><span class="nb">type</span><span class="p">):</span> -</span><span id="L-49"><a href="#L-49"><span class="linenos"> 49</span></a> <span class="n">classes</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Dialect</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-50"><a href="#L-50"><span class="linenos"> 50</span></a> -</span><span id="L-51"><a href="#L-51"><span class="linenos"> 51</span></a> <span class="k">def</span> <span class="fm">__eq__</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="L-52"><a href="#L-52"><span class="linenos"> 52</span></a> <span class="k">if</span> <span class="bp">cls</span> <span class="ow">is</span> <span class="n">other</span><span class="p">:</span> -</span><span id="L-53"><a href="#L-53"><span class="linenos"> 53</span></a> <span class="k">return</span> <span class="kc">True</span> -</span><span id="L-54"><a href="#L-54"><span class="linenos"> 54</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">other</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="L-55"><a href="#L-55"><span class="linenos"> 55</span></a> <span class="k">return</span> <span class="bp">cls</span> <span class="ow">is</span> <span class="bp">cls</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">other</span><span class="p">)</span> -</span><span id="L-56"><a href="#L-56"><span class="linenos"> 56</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">other</span><span class="p">,</span> <span class="n">Dialect</span><span class="p">):</span> -</span><span id="L-57"><a href="#L-57"><span class="linenos"> 57</span></a> <span class="k">return</span> <span class="bp">cls</span> <span class="ow">is</span> <span class="nb">type</span><span class="p">(</span><span class="n">other</span><span class="p">)</span> -</span><span id="L-58"><a href="#L-58"><span class="linenos"> 58</span></a> -</span><span id="L-59"><a href="#L-59"><span class="linenos"> 59</span></a> <span class="k">return</span> <span class="kc">False</span> +</span><span id="L-7"><a href="#L-7"><span class="linenos"> 7</span></a><span class="kn">from</span> <span class="nn">sqlglot._typing</span> <span class="kn">import</span> <span class="n">E</span> +</span><span id="L-8"><a href="#L-8"><span class="linenos"> 8</span></a><span class="kn">from</span> <span class="nn">sqlglot.generator</span> <span class="kn">import</span> <span class="n">Generator</span> +</span><span id="L-9"><a href="#L-9"><span class="linenos"> 9</span></a><span class="kn">from</span> <span class="nn">sqlglot.helper</span> <span class="kn">import</span> <span class="n">flatten</span><span class="p">,</span> <span class="n">seq_get</span> +</span><span id="L-10"><a href="#L-10"><span class="linenos"> 10</span></a><span class="kn">from</span> <span class="nn">sqlglot.parser</span> <span class="kn">import</span> <span class="n">Parser</span> +</span><span id="L-11"><a href="#L-11"><span class="linenos"> 11</span></a><span class="kn">from</span> <span class="nn">sqlglot.time</span> <span class="kn">import</span> <span class="n">format_time</span> +</span><span id="L-12"><a href="#L-12"><span class="linenos"> 12</span></a><span class="kn">from</span> <span class="nn">sqlglot.tokens</span> <span class="kn">import</span> <span class="n">Token</span><span class="p">,</span> <span class="n">Tokenizer</span><span class="p">,</span> <span class="n">TokenType</span> +</span><span id="L-13"><a href="#L-13"><span class="linenos"> 13</span></a><span class="kn">from</span> <span class="nn">sqlglot.trie</span> <span class="kn">import</span> <span class="n">new_trie</span> +</span><span id="L-14"><a href="#L-14"><span class="linenos"> 14</span></a> +</span><span id="L-15"><a href="#L-15"><span class="linenos"> 15</span></a> +</span><span id="L-16"><a href="#L-16"><span class="linenos"> 16</span></a><span class="k">class</span> <span class="nc">Dialects</span><span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="n">Enum</span><span class="p">):</span> +</span><span id="L-17"><a href="#L-17"><span class="linenos"> 17</span></a> <span class="n">DIALECT</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-18"><a href="#L-18"><span class="linenos"> 18</span></a> +</span><span id="L-19"><a href="#L-19"><span class="linenos"> 19</span></a> <span class="n">BIGQUERY</span> <span class="o">=</span> <span class="s2">"bigquery"</span> +</span><span id="L-20"><a href="#L-20"><span class="linenos"> 20</span></a> <span class="n">CLICKHOUSE</span> <span class="o">=</span> <span class="s2">"clickhouse"</span> +</span><span id="L-21"><a href="#L-21"><span class="linenos"> 21</span></a> <span class="n">DATABRICKS</span> <span class="o">=</span> <span class="s2">"databricks"</span> +</span><span id="L-22"><a href="#L-22"><span class="linenos"> 22</span></a> <span class="n">DRILL</span> <span class="o">=</span> <span class="s2">"drill"</span> +</span><span id="L-23"><a href="#L-23"><span class="linenos"> 23</span></a> <span class="n">DUCKDB</span> <span class="o">=</span> <span class="s2">"duckdb"</span> +</span><span id="L-24"><a href="#L-24"><span class="linenos"> 24</span></a> <span class="n">HIVE</span> <span class="o">=</span> <span class="s2">"hive"</span> +</span><span id="L-25"><a href="#L-25"><span class="linenos"> 25</span></a> <span class="n">MYSQL</span> <span class="o">=</span> <span class="s2">"mysql"</span> +</span><span id="L-26"><a href="#L-26"><span class="linenos"> 26</span></a> <span class="n">ORACLE</span> <span class="o">=</span> <span class="s2">"oracle"</span> +</span><span id="L-27"><a href="#L-27"><span class="linenos"> 27</span></a> <span class="n">POSTGRES</span> <span class="o">=</span> <span class="s2">"postgres"</span> +</span><span id="L-28"><a href="#L-28"><span class="linenos"> 28</span></a> <span class="n">PRESTO</span> <span class="o">=</span> <span class="s2">"presto"</span> +</span><span id="L-29"><a href="#L-29"><span class="linenos"> 29</span></a> <span class="n">REDSHIFT</span> <span class="o">=</span> <span class="s2">"redshift"</span> +</span><span id="L-30"><a href="#L-30"><span class="linenos"> 30</span></a> <span class="n">SNOWFLAKE</span> <span class="o">=</span> <span class="s2">"snowflake"</span> +</span><span id="L-31"><a href="#L-31"><span class="linenos"> 31</span></a> <span class="n">SPARK</span> <span class="o">=</span> <span class="s2">"spark"</span> +</span><span id="L-32"><a href="#L-32"><span class="linenos"> 32</span></a> <span class="n">SPARK2</span> <span class="o">=</span> <span class="s2">"spark2"</span> +</span><span id="L-33"><a href="#L-33"><span class="linenos"> 33</span></a> <span class="n">SQLITE</span> <span class="o">=</span> <span class="s2">"sqlite"</span> +</span><span id="L-34"><a href="#L-34"><span class="linenos"> 34</span></a> <span class="n">STARROCKS</span> <span class="o">=</span> <span class="s2">"starrocks"</span> +</span><span id="L-35"><a href="#L-35"><span class="linenos"> 35</span></a> <span class="n">TABLEAU</span> <span class="o">=</span> <span class="s2">"tableau"</span> +</span><span id="L-36"><a href="#L-36"><span class="linenos"> 36</span></a> <span class="n">TERADATA</span> <span class="o">=</span> <span class="s2">"teradata"</span> +</span><span id="L-37"><a href="#L-37"><span class="linenos"> 37</span></a> <span class="n">TRINO</span> <span class="o">=</span> <span class="s2">"trino"</span> +</span><span id="L-38"><a href="#L-38"><span class="linenos"> 38</span></a> <span class="n">TSQL</span> <span class="o">=</span> <span class="s2">"tsql"</span> +</span><span id="L-39"><a href="#L-39"><span class="linenos"> 39</span></a> +</span><span id="L-40"><a href="#L-40"><span class="linenos"> 40</span></a> +</span><span id="L-41"><a href="#L-41"><span class="linenos"> 41</span></a><span class="k">class</span> <span class="nc">_Dialect</span><span class="p">(</span><span class="nb">type</span><span class="p">):</span> +</span><span id="L-42"><a href="#L-42"><span class="linenos"> 42</span></a> <span class="n">classes</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Dialect</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-43"><a href="#L-43"><span class="linenos"> 43</span></a> +</span><span id="L-44"><a href="#L-44"><span class="linenos"> 44</span></a> <span class="k">def</span> <span class="fm">__eq__</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="L-45"><a href="#L-45"><span class="linenos"> 45</span></a> <span class="k">if</span> <span class="bp">cls</span> <span class="ow">is</span> <span class="n">other</span><span class="p">:</span> +</span><span id="L-46"><a href="#L-46"><span class="linenos"> 46</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="L-47"><a href="#L-47"><span class="linenos"> 47</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">other</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="L-48"><a href="#L-48"><span class="linenos"> 48</span></a> <span class="k">return</span> <span class="bp">cls</span> <span class="ow">is</span> <span class="bp">cls</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">other</span><span class="p">)</span> +</span><span id="L-49"><a href="#L-49"><span class="linenos"> 49</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">other</span><span class="p">,</span> <span class="n">Dialect</span><span class="p">):</span> +</span><span id="L-50"><a href="#L-50"><span class="linenos"> 50</span></a> <span class="k">return</span> <span class="bp">cls</span> <span class="ow">is</span> <span class="nb">type</span><span class="p">(</span><span class="n">other</span><span class="p">)</span> +</span><span id="L-51"><a href="#L-51"><span class="linenos"> 51</span></a> +</span><span id="L-52"><a href="#L-52"><span class="linenos"> 52</span></a> <span class="k">return</span> <span class="kc">False</span> +</span><span id="L-53"><a href="#L-53"><span class="linenos"> 53</span></a> +</span><span id="L-54"><a href="#L-54"><span class="linenos"> 54</span></a> <span class="k">def</span> <span class="fm">__hash__</span><span class="p">(</span><span class="bp">cls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> +</span><span id="L-55"><a href="#L-55"><span class="linenos"> 55</span></a> <span class="k">return</span> <span class="nb">hash</span><span class="p">(</span><span class="bp">cls</span><span class="o">.</span><span class="vm">__name__</span><span class="o">.</span><span class="n">lower</span><span class="p">())</span> +</span><span id="L-56"><a href="#L-56"><span class="linenos"> 56</span></a> +</span><span id="L-57"><a href="#L-57"><span class="linenos"> 57</span></a> <span class="nd">@classmethod</span> +</span><span id="L-58"><a href="#L-58"><span class="linenos"> 58</span></a> <span class="k">def</span> <span class="fm">__getitem__</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">key</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Dialect</span><span class="p">]:</span> +</span><span id="L-59"><a href="#L-59"><span class="linenos"> 59</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">classes</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> </span><span id="L-60"><a href="#L-60"><span class="linenos"> 60</span></a> -</span><span id="L-61"><a href="#L-61"><span class="linenos"> 61</span></a> <span class="k">def</span> <span class="fm">__hash__</span><span class="p">(</span><span class="bp">cls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> -</span><span id="L-62"><a href="#L-62"><span class="linenos"> 62</span></a> <span class="k">return</span> <span class="nb">hash</span><span class="p">(</span><span class="bp">cls</span><span class="o">.</span><span class="vm">__name__</span><span class="o">.</span><span class="n">lower</span><span class="p">())</span> -</span><span id="L-63"><a href="#L-63"><span class="linenos"> 63</span></a> -</span><span id="L-64"><a href="#L-64"><span class="linenos"> 64</span></a> <span class="nd">@classmethod</span> -</span><span id="L-65"><a href="#L-65"><span class="linenos"> 65</span></a> <span class="k">def</span> <span class="fm">__getitem__</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">key</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Dialect</span><span class="p">]:</span> -</span><span id="L-66"><a href="#L-66"><span class="linenos"> 66</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">classes</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> -</span><span id="L-67"><a href="#L-67"><span class="linenos"> 67</span></a> -</span><span id="L-68"><a href="#L-68"><span class="linenos"> 68</span></a> <span class="nd">@classmethod</span> -</span><span id="L-69"><a href="#L-69"><span class="linenos"> 69</span></a> <span class="k">def</span> <span class="nf">get</span><span class="p">(</span> -</span><span id="L-70"><a href="#L-70"><span class="linenos"> 70</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">key</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">default</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Dialect</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-71"><a href="#L-71"><span class="linenos"> 71</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">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Dialect</span><span class="p">]]:</span> -</span><span id="L-72"><a href="#L-72"><span class="linenos"> 72</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">classes</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">default</span><span class="p">)</span> -</span><span id="L-73"><a href="#L-73"><span class="linenos"> 73</span></a> -</span><span id="L-74"><a href="#L-74"><span class="linenos"> 74</span></a> <span class="k">def</span> <span class="fm">__new__</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">clsname</span><span class="p">,</span> <span class="n">bases</span><span class="p">,</span> <span class="n">attrs</span><span class="p">):</span> -</span><span id="L-75"><a href="#L-75"><span class="linenos"> 75</span></a> <span class="n">klass</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__new__</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">clsname</span><span class="p">,</span> <span class="n">bases</span><span class="p">,</span> <span class="n">attrs</span><span class="p">)</span> -</span><span id="L-76"><a href="#L-76"><span class="linenos"> 76</span></a> <span class="n">enum</span> <span class="o">=</span> <span class="n">Dialects</span><span class="o">.</span><span class="n">__members__</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">clsname</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span> -</span><span id="L-77"><a href="#L-77"><span class="linenos"> 77</span></a> <span class="bp">cls</span><span class="o">.</span><span class="n">classes</span><span class="p">[</span><span class="n">enum</span><span class="o">.</span><span class="n">value</span> <span class="k">if</span> <span class="n">enum</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">clsname</span><span class="o">.</span><span class="n">lower</span><span class="p">()]</span> <span class="o">=</span> <span class="n">klass</span> +</span><span id="L-61"><a href="#L-61"><span class="linenos"> 61</span></a> <span class="nd">@classmethod</span> +</span><span id="L-62"><a href="#L-62"><span class="linenos"> 62</span></a> <span class="k">def</span> <span class="nf">get</span><span class="p">(</span> +</span><span id="L-63"><a href="#L-63"><span class="linenos"> 63</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">key</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">default</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Dialect</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-64"><a href="#L-64"><span class="linenos"> 64</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">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Dialect</span><span class="p">]]:</span> +</span><span id="L-65"><a href="#L-65"><span class="linenos"> 65</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">classes</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">default</span><span class="p">)</span> +</span><span id="L-66"><a href="#L-66"><span class="linenos"> 66</span></a> +</span><span id="L-67"><a href="#L-67"><span class="linenos"> 67</span></a> <span class="k">def</span> <span class="fm">__new__</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">clsname</span><span class="p">,</span> <span class="n">bases</span><span class="p">,</span> <span class="n">attrs</span><span class="p">):</span> +</span><span id="L-68"><a href="#L-68"><span class="linenos"> 68</span></a> <span class="n">klass</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__new__</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">clsname</span><span class="p">,</span> <span class="n">bases</span><span class="p">,</span> <span class="n">attrs</span><span class="p">)</span> +</span><span id="L-69"><a href="#L-69"><span class="linenos"> 69</span></a> <span class="n">enum</span> <span class="o">=</span> <span class="n">Dialects</span><span class="o">.</span><span class="n">__members__</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">clsname</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span> +</span><span id="L-70"><a href="#L-70"><span class="linenos"> 70</span></a> <span class="bp">cls</span><span class="o">.</span><span class="n">classes</span><span class="p">[</span><span class="n">enum</span><span class="o">.</span><span class="n">value</span> <span class="k">if</span> <span class="n">enum</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">clsname</span><span class="o">.</span><span class="n">lower</span><span class="p">()]</span> <span class="o">=</span> <span class="n">klass</span> +</span><span id="L-71"><a href="#L-71"><span class="linenos"> 71</span></a> +</span><span id="L-72"><a href="#L-72"><span class="linenos"> 72</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">TIME_TRIE</span> <span class="o">=</span> <span class="n">new_trie</span><span class="p">(</span><span class="n">klass</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">)</span> +</span><span id="L-73"><a href="#L-73"><span class="linenos"> 73</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">FORMAT_TRIE</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-74"><a href="#L-74"><span class="linenos"> 74</span></a> <span class="n">new_trie</span><span class="p">(</span><span class="n">klass</span><span class="o">.</span><span class="n">FORMAT_MAPPING</span><span class="p">)</span> <span class="k">if</span> <span class="n">klass</span><span class="o">.</span><span class="n">FORMAT_MAPPING</span> <span class="k">else</span> <span class="n">klass</span><span class="o">.</span><span class="n">TIME_TRIE</span> +</span><span id="L-75"><a href="#L-75"><span class="linenos"> 75</span></a> <span class="p">)</span> +</span><span id="L-76"><a href="#L-76"><span class="linenos"> 76</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span><span class="n">v</span><span class="p">:</span> <span class="n">k</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">klass</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span> +</span><span id="L-77"><a href="#L-77"><span class="linenos"> 77</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span> <span class="o">=</span> <span class="n">new_trie</span><span class="p">(</span><span class="n">klass</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">)</span> </span><span id="L-78"><a href="#L-78"><span class="linenos"> 78</span></a> -</span><span id="L-79"><a href="#L-79"><span class="linenos"> 79</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">TIME_TRIE</span> <span class="o">=</span> <span class="n">new_trie</span><span class="p">(</span><span class="n">klass</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">)</span> -</span><span id="L-80"><a href="#L-80"><span class="linenos"> 80</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">FORMAT_TRIE</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-81"><a href="#L-81"><span class="linenos"> 81</span></a> <span class="n">new_trie</span><span class="p">(</span><span class="n">klass</span><span class="o">.</span><span class="n">FORMAT_MAPPING</span><span class="p">)</span> <span class="k">if</span> <span class="n">klass</span><span class="o">.</span><span class="n">FORMAT_MAPPING</span> <span class="k">else</span> <span class="n">klass</span><span class="o">.</span><span class="n">TIME_TRIE</span> -</span><span id="L-82"><a href="#L-82"><span class="linenos"> 82</span></a> <span class="p">)</span> -</span><span id="L-83"><a href="#L-83"><span class="linenos"> 83</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span><span class="n">v</span><span class="p">:</span> <span class="n">k</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">klass</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span> -</span><span id="L-84"><a href="#L-84"><span class="linenos"> 84</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span> <span class="o">=</span> <span class="n">new_trie</span><span class="p">(</span><span class="n">klass</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">)</span> -</span><span id="L-85"><a href="#L-85"><span class="linenos"> 85</span></a> -</span><span id="L-86"><a href="#L-86"><span class="linenos"> 86</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">tokenizer_class</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">klass</span><span class="p">,</span> <span class="s2">"Tokenizer"</span><span class="p">,</span> <span class="n">Tokenizer</span><span class="p">)</span> -</span><span id="L-87"><a href="#L-87"><span class="linenos"> 87</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">parser_class</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">klass</span><span class="p">,</span> <span class="s2">"Parser"</span><span class="p">,</span> <span class="n">Parser</span><span class="p">)</span> -</span><span id="L-88"><a href="#L-88"><span class="linenos"> 88</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">generator_class</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">klass</span><span class="p">,</span> <span class="s2">"Generator"</span><span class="p">,</span> <span class="n">Generator</span><span class="p">)</span> -</span><span id="L-89"><a href="#L-89"><span class="linenos"> 89</span></a> -</span><span id="L-90"><a href="#L-90"><span class="linenos"> 90</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">QUOTE_END</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">klass</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">_QUOTES</span><span class="o">.</span><span class="n">items</span><span class="p">())[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="L-91"><a href="#L-91"><span class="linenos"> 91</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">IDENTIFIER_START</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">IDENTIFIER_END</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span> -</span><span id="L-92"><a href="#L-92"><span class="linenos"> 92</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">_IDENTIFIERS</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> -</span><span id="L-93"><a href="#L-93"><span class="linenos"> 93</span></a> <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="L-94"><a href="#L-94"><span class="linenos"> 94</span></a> -</span><span id="L-95"><a href="#L-95"><span class="linenos"> 95</span></a> <span class="k">def</span> <span class="nf">get_start_end</span><span class="p">(</span><span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</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><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> <span class="k">return</span> <span class="nb">next</span><span class="p">(</span> -</span><span id="L-97"><a href="#L-97"><span class="linenos"> 97</span></a> <span class="p">(</span> -</span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a> <span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> -</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a> <span class="k">for</span> <span class="n">s</span><span class="p">,</span> <span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">t</span><span class="p">)</span> <span class="ow">in</span> <span class="n">klass</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">_FORMAT_STRINGS</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> -</span><span id="L-100"><a href="#L-100"><span class="linenos">100</span></a> <span class="k">if</span> <span class="n">t</span> <span class="o">==</span> <span class="n">token_type</span> -</span><span id="L-101"><a href="#L-101"><span class="linenos">101</span></a> <span class="p">),</span> -</span><span id="L-102"><a href="#L-102"><span class="linenos">102</span></a> <span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">),</span> -</span><span id="L-103"><a href="#L-103"><span class="linenos">103</span></a> <span class="p">)</span> -</span><span id="L-104"><a href="#L-104"><span class="linenos">104</span></a> -</span><span id="L-105"><a href="#L-105"><span class="linenos">105</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">BIT_START</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">BIT_END</span> <span class="o">=</span> <span class="n">get_start_end</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">BIT_STRING</span><span class="p">)</span> -</span><span id="L-106"><a href="#L-106"><span class="linenos">106</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">HEX_START</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">HEX_END</span> <span class="o">=</span> <span class="n">get_start_end</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">HEX_STRING</span><span class="p">)</span> -</span><span id="L-107"><a href="#L-107"><span class="linenos">107</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">BYTE_START</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">BYTE_END</span> <span class="o">=</span> <span class="n">get_start_end</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">BYTE_STRING</span><span class="p">)</span> -</span><span id="L-108"><a href="#L-108"><span class="linenos">108</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">RAW_START</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">RAW_END</span> <span class="o">=</span> <span class="n">get_start_end</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">RAW_STRING</span><span class="p">)</span> -</span><span id="L-109"><a href="#L-109"><span class="linenos">109</span></a> -</span><span id="L-110"><a href="#L-110"><span class="linenos">110</span></a> <span class="n">dialect_properties</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-111"><a href="#L-111"><span class="linenos">111</span></a> <span class="o">**</span><span class="p">{</span> -</span><span id="L-112"><a href="#L-112"><span class="linenos">112</span></a> <span class="n">k</span><span class="p">:</span> <span class="n">v</span> -</span><span id="L-113"><a href="#L-113"><span class="linenos">113</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">vars</span><span class="p">(</span><span class="n">klass</span><span class="p">)</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> -</span><span id="L-114"><a href="#L-114"><span class="linenos">114</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">callable</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="nb">classmethod</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">k</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"__"</span><span class="p">)</span> -</span><span id="L-115"><a href="#L-115"><span class="linenos">115</span></a> <span class="p">},</span> -</span><span id="L-116"><a href="#L-116"><span class="linenos">116</span></a> <span class="s2">"STRING_ESCAPE"</span><span class="p">:</span> <span class="n">klass</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">STRING_ESCAPES</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> -</span><span id="L-117"><a href="#L-117"><span class="linenos">117</span></a> <span class="s2">"IDENTIFIER_ESCAPE"</span><span class="p">:</span> <span class="n">klass</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">IDENTIFIER_ESCAPES</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> -</span><span id="L-118"><a href="#L-118"><span class="linenos">118</span></a> <span class="p">}</span> -</span><span id="L-119"><a href="#L-119"><span class="linenos">119</span></a> -</span><span id="L-120"><a href="#L-120"><span class="linenos">120</span></a> <span class="c1"># Pass required dialect properties to the tokenizer, parser and generator classes</span> -</span><span id="L-121"><a href="#L-121"><span class="linenos">121</span></a> <span class="k">for</span> <span class="n">subclass</span> <span class="ow">in</span> <span class="p">(</span><span class="n">klass</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">parser_class</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">generator_class</span><span class="p">):</span> -</span><span id="L-122"><a href="#L-122"><span class="linenos">122</span></a> <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">dialect_properties</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> -</span><span id="L-123"><a href="#L-123"><span class="linenos">123</span></a> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">subclass</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span> -</span><span id="L-124"><a href="#L-124"><span class="linenos">124</span></a> <span class="nb">setattr</span><span class="p">(</span><span class="n">subclass</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> -</span><span id="L-125"><a href="#L-125"><span class="linenos">125</span></a> -</span><span id="L-126"><a href="#L-126"><span class="linenos">126</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">klass</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> -</span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">parser_class</span><span class="o">.</span><span class="n">BITWISE</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DPIPE</span><span class="p">]</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDPipe</span> +</span><span id="L-79"><a href="#L-79"><span class="linenos"> 79</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">tokenizer_class</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">klass</span><span class="p">,</span> <span class="s2">"Tokenizer"</span><span class="p">,</span> <span class="n">Tokenizer</span><span class="p">)</span> +</span><span id="L-80"><a href="#L-80"><span class="linenos"> 80</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">parser_class</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">klass</span><span class="p">,</span> <span class="s2">"Parser"</span><span class="p">,</span> <span class="n">Parser</span><span class="p">)</span> +</span><span id="L-81"><a href="#L-81"><span class="linenos"> 81</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">generator_class</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">klass</span><span class="p">,</span> <span class="s2">"Generator"</span><span class="p">,</span> <span class="n">Generator</span><span class="p">)</span> +</span><span id="L-82"><a href="#L-82"><span class="linenos"> 82</span></a> +</span><span id="L-83"><a href="#L-83"><span class="linenos"> 83</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">QUOTE_END</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">klass</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">_QUOTES</span><span class="o">.</span><span class="n">items</span><span class="p">())[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="L-84"><a href="#L-84"><span class="linenos"> 84</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">IDENTIFIER_START</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">IDENTIFIER_END</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span> +</span><span id="L-85"><a href="#L-85"><span class="linenos"> 85</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">_IDENTIFIERS</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> +</span><span id="L-86"><a href="#L-86"><span class="linenos"> 86</span></a> <span class="p">)[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="L-87"><a href="#L-87"><span class="linenos"> 87</span></a> +</span><span id="L-88"><a href="#L-88"><span class="linenos"> 88</span></a> <span class="k">def</span> <span class="nf">get_start_end</span><span class="p">(</span><span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</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><span id="L-89"><a href="#L-89"><span class="linenos"> 89</span></a> <span class="k">return</span> <span class="nb">next</span><span class="p">(</span> +</span><span id="L-90"><a href="#L-90"><span class="linenos"> 90</span></a> <span class="p">(</span> +</span><span id="L-91"><a href="#L-91"><span class="linenos"> 91</span></a> <span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> +</span><span id="L-92"><a href="#L-92"><span class="linenos"> 92</span></a> <span class="k">for</span> <span class="n">s</span><span class="p">,</span> <span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">t</span><span class="p">)</span> <span class="ow">in</span> <span class="n">klass</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">_FORMAT_STRINGS</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> +</span><span id="L-93"><a href="#L-93"><span class="linenos"> 93</span></a> <span class="k">if</span> <span class="n">t</span> <span class="o">==</span> <span class="n">token_type</span> +</span><span id="L-94"><a href="#L-94"><span class="linenos"> 94</span></a> <span class="p">),</span> +</span><span id="L-95"><a href="#L-95"><span class="linenos"> 95</span></a> <span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">),</span> +</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> <span class="p">)</span> +</span><span id="L-97"><a href="#L-97"><span class="linenos"> 97</span></a> +</span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">BIT_START</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">BIT_END</span> <span class="o">=</span> <span class="n">get_start_end</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">BIT_STRING</span><span class="p">)</span> +</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">HEX_START</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">HEX_END</span> <span class="o">=</span> <span class="n">get_start_end</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">HEX_STRING</span><span class="p">)</span> +</span><span id="L-100"><a href="#L-100"><span class="linenos">100</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">BYTE_START</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">BYTE_END</span> <span class="o">=</span> <span class="n">get_start_end</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">BYTE_STRING</span><span class="p">)</span> +</span><span id="L-101"><a href="#L-101"><span class="linenos">101</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">RAW_START</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">RAW_END</span> <span class="o">=</span> <span class="n">get_start_end</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">RAW_STRING</span><span class="p">)</span> +</span><span id="L-102"><a href="#L-102"><span class="linenos">102</span></a> +</span><span id="L-103"><a href="#L-103"><span class="linenos">103</span></a> <span class="n">dialect_properties</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-104"><a href="#L-104"><span class="linenos">104</span></a> <span class="o">**</span><span class="p">{</span> +</span><span id="L-105"><a href="#L-105"><span class="linenos">105</span></a> <span class="n">k</span><span class="p">:</span> <span class="n">v</span> +</span><span id="L-106"><a href="#L-106"><span class="linenos">106</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">vars</span><span class="p">(</span><span class="n">klass</span><span class="p">)</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> +</span><span id="L-107"><a href="#L-107"><span class="linenos">107</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">callable</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="nb">classmethod</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">k</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"__"</span><span class="p">)</span> +</span><span id="L-108"><a href="#L-108"><span class="linenos">108</span></a> <span class="p">},</span> +</span><span id="L-109"><a href="#L-109"><span class="linenos">109</span></a> <span class="s2">"STRING_ESCAPE"</span><span class="p">:</span> <span class="n">klass</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">STRING_ESCAPES</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> +</span><span id="L-110"><a href="#L-110"><span class="linenos">110</span></a> <span class="s2">"IDENTIFIER_ESCAPE"</span><span class="p">:</span> <span class="n">klass</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="o">.</span><span class="n">IDENTIFIER_ESCAPES</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> +</span><span id="L-111"><a href="#L-111"><span class="linenos">111</span></a> <span class="p">}</span> +</span><span id="L-112"><a href="#L-112"><span class="linenos">112</span></a> +</span><span id="L-113"><a href="#L-113"><span class="linenos">113</span></a> <span class="k">if</span> <span class="n">enum</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="s2">"bigquery"</span><span class="p">):</span> +</span><span id="L-114"><a href="#L-114"><span class="linenos">114</span></a> <span class="n">dialect_properties</span><span class="p">[</span><span class="s2">"SELECT_KINDS"</span><span class="p">]</span> <span class="o">=</span> <span class="p">()</span> +</span><span id="L-115"><a href="#L-115"><span class="linenos">115</span></a> +</span><span id="L-116"><a href="#L-116"><span class="linenos">116</span></a> <span class="c1"># Pass required dialect properties to the tokenizer, parser and generator classes</span> +</span><span id="L-117"><a href="#L-117"><span class="linenos">117</span></a> <span class="k">for</span> <span class="n">subclass</span> <span class="ow">in</span> <span class="p">(</span><span class="n">klass</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">parser_class</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">generator_class</span><span class="p">):</span> +</span><span id="L-118"><a href="#L-118"><span class="linenos">118</span></a> <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">dialect_properties</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> +</span><span id="L-119"><a href="#L-119"><span class="linenos">119</span></a> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">subclass</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span> +</span><span id="L-120"><a href="#L-120"><span class="linenos">120</span></a> <span class="nb">setattr</span><span class="p">(</span><span class="n">subclass</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> +</span><span id="L-121"><a href="#L-121"><span class="linenos">121</span></a> +</span><span id="L-122"><a href="#L-122"><span class="linenos">122</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">klass</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> +</span><span id="L-123"><a href="#L-123"><span class="linenos">123</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">parser_class</span><span class="o">.</span><span class="n">BITWISE</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DPIPE</span><span class="p">]</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDPipe</span> +</span><span id="L-124"><a href="#L-124"><span class="linenos">124</span></a> +</span><span id="L-125"><a href="#L-125"><span class="linenos">125</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">generator_class</span><span class="o">.</span><span class="n">can_identify</span> <span class="o">=</span> <span class="n">klass</span><span class="o">.</span><span class="n">can_identify</span> +</span><span id="L-126"><a href="#L-126"><span class="linenos">126</span></a> +</span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a> <span class="k">return</span> <span class="n">klass</span> </span><span id="L-128"><a href="#L-128"><span class="linenos">128</span></a> -</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a> <span class="k">return</span> <span class="n">klass</span> -</span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a> -</span><span id="L-131"><a href="#L-131"><span class="linenos">131</span></a> -</span><span id="L-132"><a href="#L-132"><span class="linenos">132</span></a><span class="k">class</span> <span class="nc">Dialect</span><span class="p">(</span><span class="n">metaclass</span><span class="o">=</span><span class="n">_Dialect</span><span class="p">):</span> -</span><span id="L-133"><a href="#L-133"><span class="linenos">133</span></a> <span class="c1"># Determines the base index offset for arrays</span> -</span><span id="L-134"><a href="#L-134"><span class="linenos">134</span></a> <span class="n">INDEX_OFFSET</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="L-135"><a href="#L-135"><span class="linenos">135</span></a> -</span><span id="L-136"><a href="#L-136"><span class="linenos">136</span></a> <span class="c1"># If true unnest table aliases are considered only as column aliases</span> -</span><span id="L-137"><a href="#L-137"><span class="linenos">137</span></a> <span class="n">UNNEST_COLUMN_ONLY</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-138"><a href="#L-138"><span class="linenos">138</span></a> -</span><span id="L-139"><a href="#L-139"><span class="linenos">139</span></a> <span class="c1"># Determines whether or not the table alias comes after tablesample</span> -</span><span id="L-140"><a href="#L-140"><span class="linenos">140</span></a> <span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-141"><a href="#L-141"><span class="linenos">141</span></a> -</span><span id="L-142"><a href="#L-142"><span class="linenos">142</span></a> <span class="c1"># Determines whether or not an unquoted identifier can start with a digit</span> -</span><span id="L-143"><a href="#L-143"><span class="linenos">143</span></a> <span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-144"><a href="#L-144"><span class="linenos">144</span></a> -</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> <span class="c1"># Determines whether or not CONCAT's arguments must be strings</span> -</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> <span class="n">STRICT_STRING_CONCAT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a> -</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a> <span class="c1"># Determines how function names are going to be normalized</span> -</span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a> <span class="n">NORMALIZE_FUNCTIONS</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">|</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"upper"</span> -</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> -</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> <span class="c1"># Indicates the default null ordering method to use if not explicitly set</span> -</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="c1"># Options are: "nulls_are_small", "nulls_are_large", "nulls_are_last"</span> -</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_small"</span> -</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> -</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> <span class="n">DATE_FORMAT</span> <span class="o">=</span> <span class="s2">"'%Y-%m-</span><span class="si">%d</span><span class="s2">'"</span> -</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> <span class="n">DATEINT_FORMAT</span> <span class="o">=</span> <span class="s2">"'%Y%m</span><span class="si">%d</span><span class="s2">'"</span> -</span><span id="L-157"><a href="#L-157"><span class="linenos">157</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">"'%Y-%m-</span><span class="si">%d</span><span class="s2"> %H:%M:%S'"</span> -</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="c1"># Custom time mappings in which the key represents dialect time format</span> -</span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="c1"># and the value represents a python time format</span> -</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="n">TIME_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-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"># https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_model_rules_date_time</span> -</span><span id="L-164"><a href="#L-164"><span class="linenos">164</span></a> <span class="c1"># https://docs.teradata.com/r/Teradata-Database-SQL-Functions-Operators-Expressions-and-Predicates/March-2017/Data-Type-Conversions/Character-to-DATE-Conversion/Forcing-a-FORMAT-on-CAST-for-Converting-Character-to-DATE</span> -</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> <span class="c1"># special syntax cast(x as date format 'yyyy') defaults to time_mapping</span> -</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a> <span class="n">FORMAT_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a> -</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a> <span class="c1"># Autofilled</span> -</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a> <span class="n">tokenizer_class</span> <span class="o">=</span> <span class="n">Tokenizer</span> -</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="n">parser_class</span> <span class="o">=</span> <span class="n">Parser</span> -</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="n">generator_class</span> <span class="o">=</span> <span class="n">Generator</span> -</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> -</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="c1"># A trie of the time_mapping keys</span> -</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="n">TIME_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="n">FORMAT_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> -</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="n">INVERSE_TIME_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> <span class="n">INVERSE_TIME_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-179"><a href="#L-179"><span class="linenos">179</span></a> -</span><span id="L-180"><a href="#L-180"><span class="linenos">180</span></a> <span class="k">def</span> <span class="fm">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="L-181"><a href="#L-181"><span class="linenos">181</span></a> <span class="k">return</span> <span class="nb">type</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">==</span> <span class="n">other</span> -</span><span id="L-182"><a href="#L-182"><span class="linenos">182</span></a> -</span><span id="L-183"><a href="#L-183"><span class="linenos">183</span></a> <span class="k">def</span> <span class="fm">__hash__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> -</span><span id="L-184"><a href="#L-184"><span class="linenos">184</span></a> <span class="k">return</span> <span class="nb">hash</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span> -</span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> -</span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a> <span class="nd">@classmethod</span> -</span><span id="L-187"><a href="#L-187"><span class="linenos">187</span></a> <span class="k">def</span> <span class="nf">get_or_raise</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Dialect</span><span class="p">]:</span> -</span><span id="L-188"><a href="#L-188"><span class="linenos">188</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">dialect</span><span class="p">:</span> -</span><span id="L-189"><a href="#L-189"><span class="linenos">189</span></a> <span class="k">return</span> <span class="bp">cls</span> -</span><span id="L-190"><a href="#L-190"><span class="linenos">190</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dialect</span><span class="p">,</span> <span class="n">_Dialect</span><span class="p">):</span> -</span><span id="L-191"><a href="#L-191"><span class="linenos">191</span></a> <span class="k">return</span> <span class="n">dialect</span> -</span><span id="L-192"><a href="#L-192"><span class="linenos">192</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dialect</span><span class="p">,</span> <span class="n">Dialect</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">dialect</span><span class="o">.</span><span class="vm">__class__</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 class="n">result</span> <span class="o">=</span> <span class="bp">cls</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span> -</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">result</span><span class="p">:</span> -</span><span id="L-197"><a href="#L-197"><span class="linenos">197</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unknown dialect '</span><span class="si">{</span><span class="n">dialect</span><span class="si">}</span><span class="s2">'"</span><span class="p">)</span> -</span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> -</span><span id="L-199"><a href="#L-199"><span class="linenos">199</span></a> <span class="k">return</span> <span class="n">result</span> +</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a> +</span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a><span class="k">class</span> <span class="nc">Dialect</span><span class="p">(</span><span class="n">metaclass</span><span class="o">=</span><span class="n">_Dialect</span><span class="p">):</span> +</span><span id="L-131"><a href="#L-131"><span class="linenos">131</span></a> <span class="c1"># Determines the base index offset for arrays</span> +</span><span id="L-132"><a href="#L-132"><span class="linenos">132</span></a> <span class="n">INDEX_OFFSET</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="L-133"><a href="#L-133"><span class="linenos">133</span></a> +</span><span id="L-134"><a href="#L-134"><span class="linenos">134</span></a> <span class="c1"># If true unnest table aliases are considered only as column aliases</span> +</span><span id="L-135"><a href="#L-135"><span class="linenos">135</span></a> <span class="n">UNNEST_COLUMN_ONLY</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-136"><a href="#L-136"><span class="linenos">136</span></a> +</span><span id="L-137"><a href="#L-137"><span class="linenos">137</span></a> <span class="c1"># Determines whether or not the table alias comes after tablesample</span> +</span><span id="L-138"><a href="#L-138"><span class="linenos">138</span></a> <span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-139"><a href="#L-139"><span class="linenos">139</span></a> +</span><span id="L-140"><a href="#L-140"><span class="linenos">140</span></a> <span class="c1"># Determines whether or not unquoted identifiers are resolved as uppercase</span> +</span><span id="L-141"><a href="#L-141"><span class="linenos">141</span></a> <span class="c1"># When set to None, it means that the dialect treats all identifiers as case-insensitive</span> +</span><span id="L-142"><a href="#L-142"><span class="linenos">142</span></a> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-143"><a href="#L-143"><span class="linenos">143</span></a> +</span><span id="L-144"><a href="#L-144"><span class="linenos">144</span></a> <span class="c1"># Determines whether or not an unquoted identifier can start with a digit</span> +</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> <span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> +</span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a> <span class="c1"># Determines whether or not CONCAT's arguments must be strings</span> +</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a> <span class="n">STRICT_STRING_CONCAT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a> +</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="c1"># Determines how function names are going to be normalized</span> +</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> <span class="n">NORMALIZE_FUNCTIONS</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">|</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"upper"</span> +</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> +</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> <span class="c1"># Indicates the default null ordering method to use if not explicitly set</span> +</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> <span class="c1"># Options are: "nulls_are_small", "nulls_are_large", "nulls_are_last"</span> +</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_small"</span> +</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> +</span><span id="L-157"><a href="#L-157"><span class="linenos">157</span></a> <span class="n">DATE_FORMAT</span> <span class="o">=</span> <span class="s2">"'%Y-%m-</span><span class="si">%d</span><span class="s2">'"</span> +</span><span id="L-158"><a href="#L-158"><span class="linenos">158</span></a> <span class="n">DATEINT_FORMAT</span> <span class="o">=</span> <span class="s2">"'%Y%m</span><span class="si">%d</span><span class="s2">'"</span> +</span><span id="L-159"><a href="#L-159"><span class="linenos">159</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">"'%Y-%m-</span><span class="si">%d</span><span class="s2"> %H:%M:%S'"</span> +</span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a> +</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="c1"># Custom time mappings in which the key represents dialect time format</span> +</span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a> <span class="c1"># and the value represents a python time format</span> +</span><span id="L-163"><a href="#L-163"><span class="linenos">163</span></a> <span class="n">TIME_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-164"><a href="#L-164"><span class="linenos">164</span></a> +</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_model_rules_date_time</span> +</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a> <span class="c1"># https://docs.teradata.com/r/Teradata-Database-SQL-Functions-Operators-Expressions-and-Predicates/March-2017/Data-Type-Conversions/Character-to-DATE-Conversion/Forcing-a-FORMAT-on-CAST-for-Converting-Character-to-DATE</span> +</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a> <span class="c1"># special syntax cast(x as date format 'yyyy') defaults to time_mapping</span> +</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a> <span class="n">FORMAT_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a> +</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="c1"># Autofilled</span> +</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="n">tokenizer_class</span> <span class="o">=</span> <span class="n">Tokenizer</span> +</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="n">parser_class</span> <span class="o">=</span> <span class="n">Parser</span> +</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="n">generator_class</span> <span class="o">=</span> <span class="n">Generator</span> +</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> +</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="c1"># A trie of the time_mapping keys</span> +</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> <span class="n">TIME_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="n">FORMAT_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> +</span><span id="L-179"><a href="#L-179"><span class="linenos">179</span></a> <span class="n">INVERSE_TIME_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-180"><a href="#L-180"><span class="linenos">180</span></a> <span class="n">INVERSE_TIME_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-181"><a href="#L-181"><span class="linenos">181</span></a> +</span><span id="L-182"><a href="#L-182"><span class="linenos">182</span></a> <span class="k">def</span> <span class="fm">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="L-183"><a href="#L-183"><span class="linenos">183</span></a> <span class="k">return</span> <span class="nb">type</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">==</span> <span class="n">other</span> +</span><span id="L-184"><a href="#L-184"><span class="linenos">184</span></a> +</span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> <span class="k">def</span> <span class="fm">__hash__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> +</span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a> <span class="k">return</span> <span class="nb">hash</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="bp">self</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 class="nd">@classmethod</span> +</span><span id="L-189"><a href="#L-189"><span class="linenos">189</span></a> <span class="k">def</span> <span class="nf">get_or_raise</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Dialect</span><span class="p">]:</span> +</span><span id="L-190"><a href="#L-190"><span class="linenos">190</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">dialect</span><span class="p">:</span> +</span><span id="L-191"><a href="#L-191"><span class="linenos">191</span></a> <span class="k">return</span> <span class="bp">cls</span> +</span><span id="L-192"><a href="#L-192"><span class="linenos">192</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dialect</span><span class="p">,</span> <span class="n">_Dialect</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">dialect</span> +</span><span id="L-194"><a href="#L-194"><span class="linenos">194</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dialect</span><span class="p">,</span> <span class="n">Dialect</span><span class="p">):</span> +</span><span id="L-195"><a href="#L-195"><span class="linenos">195</span></a> <span class="k">return</span> <span class="n">dialect</span><span class="o">.</span><span class="vm">__class__</span> +</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a> +</span><span id="L-197"><a href="#L-197"><span class="linenos">197</span></a> <span class="n">result</span> <span class="o">=</span> <span class="bp">cls</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span> +</span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">result</span><span class="p">:</span> +</span><span id="L-199"><a href="#L-199"><span class="linenos">199</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unknown dialect '</span><span class="si">{</span><span class="n">dialect</span><span class="si">}</span><span class="s2">'"</span><span class="p">)</span> </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="nd">@classmethod</span> -</span><span id="L-202"><a href="#L-202"><span class="linenos">202</span></a> <span class="k">def</span> <span class="nf">format_time</span><span class="p">(</span> -</span><span id="L-203"><a href="#L-203"><span class="linenos">203</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> -</span><span id="L-204"><a href="#L-204"><span class="linenos">204</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-205"><a href="#L-205"><span class="linenos">205</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="L-206"><a href="#L-206"><span class="linenos">206</span></a> <span class="k">return</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><span id="L-207"><a href="#L-207"><span class="linenos">207</span></a> <span class="c1"># the time formats are quoted</span> -</span><span id="L-208"><a href="#L-208"><span class="linenos">208</span></a> <span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">[</span><span class="mi">1</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_TRIE</span><span class="p">)</span> -</span><span id="L-209"><a href="#L-209"><span class="linenos">209</span></a> <span class="p">)</span> -</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> -</span><span id="L-211"><a href="#L-211"><span class="linenos">211</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> -</span><span id="L-212"><a href="#L-212"><span class="linenos">212</span></a> <span class="k">return</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">format_time</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_TRIE</span><span class="p">))</span> -</span><span id="L-213"><a href="#L-213"><span class="linenos">213</span></a> -</span><span id="L-214"><a href="#L-214"><span class="linenos">214</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-201"><a href="#L-201"><span class="linenos">201</span></a> <span class="k">return</span> <span class="n">result</span> +</span><span id="L-202"><a href="#L-202"><span class="linenos">202</span></a> +</span><span id="L-203"><a href="#L-203"><span class="linenos">203</span></a> <span class="nd">@classmethod</span> +</span><span id="L-204"><a href="#L-204"><span class="linenos">204</span></a> <span class="k">def</span> <span class="nf">format_time</span><span class="p">(</span> +</span><span id="L-205"><a href="#L-205"><span class="linenos">205</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> +</span><span id="L-206"><a href="#L-206"><span class="linenos">206</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-207"><a href="#L-207"><span class="linenos">207</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="L-208"><a href="#L-208"><span class="linenos">208</span></a> <span class="k">return</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><span id="L-209"><a href="#L-209"><span class="linenos">209</span></a> <span class="c1"># the time formats are quoted</span> +</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> <span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">[</span><span class="mi">1</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_TRIE</span><span class="p">)</span> +</span><span id="L-211"><a href="#L-211"><span class="linenos">211</span></a> <span class="p">)</span> +</span><span id="L-212"><a href="#L-212"><span class="linenos">212</span></a> +</span><span id="L-213"><a href="#L-213"><span class="linenos">213</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> +</span><span id="L-214"><a href="#L-214"><span class="linenos">214</span></a> <span class="k">return</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">format_time</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_TRIE</span><span class="p">))</span> </span><span id="L-215"><a href="#L-215"><span class="linenos">215</span></a> -</span><span id="L-216"><a href="#L-216"><span class="linenos">216</span></a> <span class="k">def</span> <span class="nf">parse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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-217"><a href="#L-217"><span class="linenos">217</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">parser</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tokenize</span><span class="p">(</span><span class="n">sql</span><span class="p">),</span> <span class="n">sql</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">def</span> <span class="nf">parse_into</span><span class="p">(</span> -</span><span id="L-220"><a href="#L-220"><span class="linenos">220</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression_type</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IntoType</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="L-221"><a href="#L-221"><span class="linenos">221</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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-222"><a href="#L-222"><span class="linenos">222</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">parser</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">parse_into</span><span class="p">(</span><span class="n">expression_type</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokenize</span><span class="p">(</span><span class="n">sql</span><span class="p">),</span> <span class="n">sql</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">def</span> <span class="nf">generate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">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">opts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-225"><a href="#L-225"><span class="linenos">225</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">generator</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">expression</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="k">def</span> <span class="nf">transpile</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</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-228"><a href="#L-228"><span class="linenos">228</span></a> <span class="k">return</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">sql</span><span class="p">)]</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="k">def</span> <span class="nf">tokenize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Token</span><span class="p">]:</span> -</span><span id="L-231"><a href="#L-231"><span class="linenos">231</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokenizer</span><span class="o">.</span><span class="n">tokenize</span><span class="p">(</span><span class="n">sql</span><span class="p">)</span> -</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> -</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="nd">@property</span> -</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="k">def</span> <span class="nf">tokenizer</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Tokenizer</span><span class="p">:</span> -</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s2">"_tokenizer"</span><span class="p">):</span> -</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_tokenizer</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="p">()</span> -</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tokenizer</span> -</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> -</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> <span class="k">def</span> <span class="nf">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Parser</span><span class="p">:</span> -</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">parser_class</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> -</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="k">def</span> <span class="nf">generator</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Generator</span><span class="p">:</span> -</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">generator_class</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> +</span><span id="L-216"><a href="#L-216"><span class="linenos">216</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-217"><a href="#L-217"><span class="linenos">217</span></a> +</span><span id="L-218"><a href="#L-218"><span class="linenos">218</span></a> <span class="nd">@classmethod</span> +</span><span id="L-219"><a href="#L-219"><span class="linenos">219</span></a> <span class="k">def</span> <span class="nf">normalize_identifier</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="L-220"><a href="#L-220"><span class="linenos">220</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-221"><a href="#L-221"><span class="linenos">221</span></a><span class="sd"> Normalizes an unquoted identifier to either lower or upper case, thus essentially</span> +</span><span id="L-222"><a href="#L-222"><span class="linenos">222</span></a><span class="sd"> making it case-insensitive. If a dialect treats all identifiers as case-insensitive,</span> +</span><span id="L-223"><a href="#L-223"><span class="linenos">223</span></a><span class="sd"> they will be normalized regardless of being quoted or not.</span> +</span><span id="L-224"><a href="#L-224"><span class="linenos">224</span></a><span class="sd"> """</span> +</span><span id="L-225"><a href="#L-225"><span class="linenos">225</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span> +</span><span id="L-226"><a href="#L-226"><span class="linenos">226</span></a> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> <span class="ow">or</span> <span class="bp">cls</span><span class="o">.</span><span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="ow">is</span> <span class="kc">None</span> +</span><span id="L-227"><a href="#L-227"><span class="linenos">227</span></a> <span class="p">):</span> +</span><span id="L-228"><a href="#L-228"><span class="linenos">228</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="L-229"><a href="#L-229"><span class="linenos">229</span></a> <span class="s2">"this"</span><span class="p">,</span> +</span><span id="L-230"><a href="#L-230"><span class="linenos">230</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-231"><a href="#L-231"><span class="linenos">231</span></a> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> +</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="k">else</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> +</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="p">)</span> +</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> +</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> +</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> <span class="nd">@classmethod</span> +</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="k">def</span> <span class="nf">case_sensitive</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a><span class="w"> </span><span class="sd">"""Checks if text contains any case sensitive characters, based on the dialect's rules."""</span> +</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> <span class="k">return</span> <span class="kc">False</span> +</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> +</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> <span class="n">unsafe</span> <span class="o">=</span> <span class="nb">str</span><span class="o">.</span><span class="n">islower</span> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="k">else</span> <span class="nb">str</span><span class="o">.</span><span class="n">isupper</span> +</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <span class="k">return</span> <span class="nb">any</span><span class="p">(</span><span class="n">unsafe</span><span class="p">(</span><span class="n">char</span><span class="p">)</span> <span class="k">for</span> <span class="n">char</span> <span class="ow">in</span> <span class="n">text</span><span class="p">)</span> </span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> -</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a><span class="n">DialectType</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Dialect</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Dialect</span><span class="p">],</span> <span class="kc">None</span><span class="p">]</span> -</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> -</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> -</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a><span class="k">def</span> <span class="nf">rename_func</span><span class="p">(</span><span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Generator</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> -</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> <span class="k">return</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">flatten</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">values</span><span class="p">()))</span> -</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> -</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="k">def</span> <span class="nf">approx_count_distinct_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-254"><a href="#L-254"><span class="linenos">254</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">"accuracy"</span><span class="p">):</span> -</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"APPROX_COUNT_DISTINCT does not support accuracy"</span><span class="p">)</span> -</span><span id="L-256"><a href="#L-256"><span class="linenos">256</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">"APPROX_COUNT_DISTINCT"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-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><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a><span class="k">def</span> <span class="nf">if_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">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">If</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> <span class="s2">"IF"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"true"</span><span class="p">),</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"false"</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-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="nd">@classmethod</span> +</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> +</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a><span class="sd"> Args:</span> +</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a><span class="sd"> text: The text to check.</span> +</span><span id="L-252"><a href="#L-252"><span class="linenos">252</span></a><span class="sd"> identify:</span> +</span><span id="L-253"><a href="#L-253"><span class="linenos">253</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> +</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a><span class="sd"> Returns:</span> +</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="L-258"><a href="#L-258"><span class="linenos">258</span></a><span class="sd"> """</span> +</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> +</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> </span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> -</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a><span class="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">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">JSONExtract</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"->"</span><span class="p">)</span> -</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> -</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> -</span><span id="L-269"><a href="#L-269"><span class="linenos">269</span></a><span class="k">def</span> <span class="nf">arrow_json_extract_scalar_sql</span><span class="p">(</span> -</span><span id="L-270"><a href="#L-270"><span class="linenos">270</span></a> <span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtractScalar</span> -</span><span id="L-271"><a href="#L-271"><span class="linenos">271</span></a><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"->>"</span><span class="p">)</span> -</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> -</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> -</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a><span class="k">def</span> <span class="nf">inline_array_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a> <span class="k">return</span> <span 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="si">}</span><span class="s2">]"</span> +</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a> <span class="k">return</span> <span class="kc">False</span> +</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a> +</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> <span class="nd">@classmethod</span> +</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> <span class="k">def</span> <span class="nf">quote_identifier</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="L-269"><a href="#L-269"><span class="linenos">269</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">):</span> +</span><span id="L-270"><a href="#L-270"><span class="linenos">270</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-271"><a href="#L-271"><span class="linenos">271</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="L-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="s2">"quoted"</span><span class="p">,</span> +</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="n">identify</span> <span class="ow">or</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">exp</span><span class="o">.</span><span class="n">SAFE_IDENTIFIER_RE</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">name</span><span class="p">),</span> +</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="p">)</span> +</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a> +</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a> <span class="k">return</span> <span class="n">expression</span> </span><span id="L-277"><a href="#L-277"><span class="linenos">277</span></a> -</span><span id="L-278"><a href="#L-278"><span class="linenos">278</span></a> -</span><span id="L-279"><a href="#L-279"><span class="linenos">279</span></a><span class="k">def</span> <span class="nf">no_ilike_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">like_sql</span><span class="p">(</span> -</span><span id="L-281"><a href="#L-281"><span class="linenos">281</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Like</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Lower</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-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><span id="L-284"><a href="#L-284"><span class="linenos">284</span></a> -</span><span id="L-285"><a href="#L-285"><span class="linenos">285</span></a><span class="k">def</span> <span class="nf">no_paren_current_date_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CURRENT_DATE AT TIME ZONE </span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">zone</span> <span class="k">else</span> <span class="s2">"CURRENT_DATE"</span> +</span><span id="L-278"><a href="#L-278"><span class="linenos">278</span></a> <span class="k">def</span> <span class="nf">parse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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-279"><a href="#L-279"><span class="linenos">279</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">parser</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tokenize</span><span class="p">(</span><span class="n">sql</span><span class="p">),</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a> +</span><span id="L-281"><a href="#L-281"><span class="linenos">281</span></a> <span class="k">def</span> <span class="nf">parse_into</span><span class="p">(</span> +</span><span id="L-282"><a href="#L-282"><span class="linenos">282</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression_type</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IntoType</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="L-283"><a href="#L-283"><span class="linenos">283</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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-284"><a href="#L-284"><span class="linenos">284</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">parser</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">parse_into</span><span class="p">(</span><span class="n">expression_type</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokenize</span><span class="p">(</span><span class="n">sql</span><span class="p">),</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="L-285"><a href="#L-285"><span class="linenos">285</span></a> +</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a> <span class="k">def</span> <span class="nf">generate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">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">opts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">generator</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="L-288"><a href="#L-288"><span class="linenos">288</span></a> -</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a> -</span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a><span class="k">def</span> <span class="nf">no_recursive_cte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-291"><a href="#L-291"><span class="linenos">291</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">"recursive"</span><span class="p">):</span> -</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Recursive CTEs are unsupported"</span><span class="p">)</span> -</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"recursive"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">with_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a> -</span><span id="L-296"><a href="#L-296"><span class="linenos">296</span></a> -</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a><span class="k">def</span> <span class="nf">no_safe_divide_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-298"><a href="#L-298"><span class="linenos">298</span></a> <span class="n">n</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-299"><a href="#L-299"><span class="linenos">299</span></a> <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="L-300"><a href="#L-300"><span class="linenos">300</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"IF(</span><span class="si">{</span><span class="n">d</span><span class="si">}</span><span class="s2"> <> 0, </span><span class="si">{</span><span class="n">n</span><span class="si">}</span><span class="s2"> / </span><span class="si">{</span><span class="n">d</span><span class="si">}</span><span class="s2">, NULL)"</span> -</span><span id="L-301"><a href="#L-301"><span class="linenos">301</span></a> -</span><span id="L-302"><a href="#L-302"><span class="linenos">302</span></a> -</span><span id="L-303"><a href="#L-303"><span class="linenos">303</span></a><span class="k">def</span> <span class="nf">no_tablesample_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"TABLESAMPLE unsupported"</span><span class="p">)</span> -</span><span id="L-305"><a href="#L-305"><span class="linenos">305</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="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a> <span class="k">def</span> <span class="nf">transpile</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</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-290"><a href="#L-290"><span class="linenos">290</span></a> <span class="k">return</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">sql</span><span class="p">)]</span> +</span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a> +</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a> <span class="k">def</span> <span class="nf">tokenize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Token</span><span class="p">]:</span> +</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokenizer</span><span class="o">.</span><span class="n">tokenize</span><span class="p">(</span><span class="n">sql</span><span class="p">)</span> +</span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a> +</span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a> <span class="nd">@property</span> +</span><span id="L-296"><a href="#L-296"><span class="linenos">296</span></a> <span class="k">def</span> <span class="nf">tokenizer</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Tokenizer</span><span class="p">:</span> +</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s2">"_tokenizer"</span><span class="p">):</span> +</span><span id="L-298"><a href="#L-298"><span class="linenos">298</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_tokenizer</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="p">()</span> +</span><span id="L-299"><a href="#L-299"><span class="linenos">299</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tokenizer</span> +</span><span id="L-300"><a href="#L-300"><span class="linenos">300</span></a> +</span><span id="L-301"><a href="#L-301"><span class="linenos">301</span></a> <span class="k">def</span> <span class="nf">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Parser</span><span class="p">:</span> +</span><span id="L-302"><a href="#L-302"><span class="linenos">302</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">parser_class</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-303"><a href="#L-303"><span class="linenos">303</span></a> +</span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a> <span class="k">def</span> <span class="nf">generator</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Generator</span><span class="p">:</span> +</span><span id="L-305"><a href="#L-305"><span class="linenos">305</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">generator_class</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span> </span><span id="L-306"><a href="#L-306"><span class="linenos">306</span></a> </span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a> -</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a><span class="k">def</span> <span class="nf">no_pivot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"PIVOT unsupported"</span><span class="p">)</span> -</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a> -</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> -</span><span id="L-313"><a href="#L-313"><span class="linenos">313</span></a><span class="k">def</span> <span class="nf">no_trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> -</span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> -</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a><span class="k">def</span> <span class="nf">no_properties_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-318"><a href="#L-318"><span class="linenos">318</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Properties unsupported"</span><span class="p">)</span> -</span><span id="L-319"><a href="#L-319"><span class="linenos">319</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a><span class="n">DialectType</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Dialect</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Dialect</span><span class="p">],</span> <span class="kc">None</span><span class="p">]</span> +</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a> +</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a> +</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a><span class="k">def</span> <span class="nf">rename_func</span><span class="p">(</span><span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Generator</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> +</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> <span class="k">return</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">flatten</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">values</span><span class="p">()))</span> +</span><span id="L-313"><a href="#L-313"><span class="linenos">313</span></a> +</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> +</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a><span class="k">def</span> <span class="nf">approx_count_distinct_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-316"><a href="#L-316"><span class="linenos">316</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">"accuracy"</span><span class="p">):</span> +</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"APPROX_COUNT_DISTINCT does not support accuracy"</span><span class="p">)</span> +</span><span id="L-318"><a href="#L-318"><span class="linenos">318</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">"APPROX_COUNT_DISTINCT"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-319"><a href="#L-319"><span class="linenos">319</span></a> </span><span id="L-320"><a href="#L-320"><span class="linenos">320</span></a> -</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a> -</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a><span class="k">def</span> <span class="nf">no_comment_column_constraint_sql</span><span class="p">(</span> -</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CommentColumnConstraint</span> -</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"CommentColumnConstraint unsupported"</span><span class="p">)</span> -</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> <span class="k">return</span> <span class="s2">""</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><span id="L-329"><a href="#L-329"><span class="linenos">329</span></a><span class="k">def</span> <span class="nf">str_position_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-330"><a href="#L-330"><span class="linenos">330</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-331"><a href="#L-331"><span class="linenos">331</span></a> <span class="n">substr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"substr"</span><span class="p">)</span> -</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> -</span><span id="L-333"><a href="#L-333"><span class="linenos">333</span></a> <span class="k">if</span> <span class="n">position</span><span class="p">:</span> -</span><span id="L-334"><a href="#L-334"><span class="linenos">334</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"STRPOS(SUBSTR(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2">), </span><span class="si">{</span><span class="n">substr</span><span class="si">}</span><span class="s2">) + </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2"> - 1"</span> -</span><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"STRPOS(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">substr</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a><span class="k">def</span> <span class="nf">if_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">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">If</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="s2">"IF"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"true"</span><span class="p">),</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"false"</span><span class="p">)</span> +</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a> <span class="p">)</span> +</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a> +</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> +</span><span id="L-327"><a href="#L-327"><span class="linenos">327</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">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">JSONExtract</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-328"><a href="#L-328"><span class="linenos">328</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"->"</span><span class="p">)</span> +</span><span id="L-329"><a href="#L-329"><span class="linenos">329</span></a> +</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="k">def</span> <span class="nf">arrow_json_extract_scalar_sql</span><span class="p">(</span> +</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a> <span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtractScalar</span> +</span><span id="L-333"><a href="#L-333"><span class="linenos">333</span></a><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-334"><a href="#L-334"><span class="linenos">334</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"->>"</span><span class="p">)</span> +</span><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a> </span><span id="L-336"><a href="#L-336"><span class="linenos">336</span></a> -</span><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="k">def</span> <span class="nf">struct_extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-339"><a href="#L-339"><span class="linenos">339</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-340"><a href="#L-340"><span class="linenos">340</span></a> <span class="n">struct_key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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">expression</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> -</span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">struct_key</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a> -</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="k">def</span> <span class="nf">var_map_sql</span><span class="p">(</span> -</span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> <span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Map</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</span><span class="p">,</span> <span class="n">map_func_name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"MAP"</span> -</span><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"keys"</span><span class="p">]</span> -</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="n">values</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">"values"</span><span class="p">]</span> -</span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> -</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">keys</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">values</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-351"><a href="#L-351"><span class="linenos">351</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Cannot convert array columns into map."</span><span class="p">)</span> -</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">map_func_name</span><span class="p">,</span> <span class="n">keys</span><span class="p">,</span> <span class="n">values</span><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="n">args</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">keys</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="n">values</span><span class="o">.</span><span class="n">expressions</span><span class="p">):</span> -</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</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">key</span><span class="p">))</span> -</span><span id="L-357"><a href="#L-357"><span class="linenos">357</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</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">value</span><span class="p">))</span> +</span><span id="L-337"><a href="#L-337"><span class="linenos">337</span></a><span class="k">def</span> <span class="nf">inline_array_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-338"><a href="#L-338"><span class="linenos">338</span></a> <span class="k">return</span> <span 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="si">}</span><span class="s2">]"</span> +</span><span id="L-339"><a href="#L-339"><span class="linenos">339</span></a> +</span><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a> +</span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a><span class="k">def</span> <span class="nf">no_ilike_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">like_sql</span><span class="p">(</span> +</span><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Like</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Lower</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-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><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a> +</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a><span class="k">def</span> <span class="nf">no_paren_current_date_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CURRENT_DATE AT TIME ZONE </span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">zone</span> <span class="k">else</span> <span class="s2">"CURRENT_DATE"</span> +</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> +</span><span id="L-351"><a href="#L-351"><span class="linenos">351</span></a> +</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a><span class="k">def</span> <span class="nf">no_recursive_cte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-353"><a href="#L-353"><span class="linenos">353</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">"recursive"</span><span class="p">):</span> +</span><span id="L-354"><a href="#L-354"><span class="linenos">354</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Recursive CTEs are unsupported"</span><span class="p">)</span> +</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"recursive"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">with_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-357"><a href="#L-357"><span class="linenos">357</span></a> </span><span id="L-358"><a href="#L-358"><span class="linenos">358</span></a> -</span><span id="L-359"><a href="#L-359"><span class="linenos">359</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">map_func_name</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> -</span><span id="L-360"><a href="#L-360"><span class="linenos">360</span></a> -</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a> -</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a><span class="k">def</span> <span class="nf">format_time_lambda</span><span class="p">(</span> -</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> <span class="n">dialect</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">default</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span> <span class="o">|</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-364"><a href="#L-364"><span class="linenos">364</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">],</span> <span class="n">E</span><span class="p">]:</span> -</span><span id="L-365"><a href="#L-365"><span class="linenos">365</span></a><span class="w"> </span><span class="sd">"""Helper used for time expressions.</span> -</span><span id="L-366"><a href="#L-366"><span class="linenos">366</span></a> -</span><span id="L-367"><a href="#L-367"><span class="linenos">367</span></a><span class="sd"> Args:</span> -</span><span id="L-368"><a href="#L-368"><span class="linenos">368</span></a><span class="sd"> exp_class: the expression class to instantiate.</span> -</span><span id="L-369"><a href="#L-369"><span class="linenos">369</span></a><span class="sd"> dialect: target sql dialect.</span> -</span><span id="L-370"><a href="#L-370"><span class="linenos">370</span></a><span class="sd"> default: the default format, True being time.</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="sd"> Returns:</span> -</span><span id="L-373"><a href="#L-373"><span class="linenos">373</span></a><span class="sd"> A callable that can be used to return the appropriately formatted time expression.</span> -</span><span id="L-374"><a href="#L-374"><span class="linenos">374</span></a><span class="sd"> """</span> -</span><span id="L-375"><a href="#L-375"><span class="linenos">375</span></a> -</span><span id="L-376"><a href="#L-376"><span class="linenos">376</span></a> <span class="k">def</span> <span class="nf">_format_time</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">):</span> -</span><span id="L-377"><a href="#L-377"><span class="linenos">377</span></a> <span class="k">return</span> <span class="n">exp_class</span><span class="p">(</span> -</span><span id="L-378"><a href="#L-378"><span class="linenos">378</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-379"><a href="#L-379"><span class="linenos">379</span></a> <span class="nb">format</span><span class="o">=</span><span class="n">Dialect</span><span class="p">[</span><span class="n">dialect</span><span class="p">]</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span> -</span><span id="L-380"><a href="#L-380"><span class="linenos">380</span></a> <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-381"><a href="#L-381"><span class="linenos">381</span></a> <span class="ow">or</span> <span class="p">(</span><span class="n">Dialect</span><span class="p">[</span><span class="n">dialect</span><span class="p">]</span><span class="o">.</span><span class="n">TIME_FORMAT</span> <span class="k">if</span> <span class="n">default</span> <span class="ow">is</span> <span class="kc">True</span> <span class="k">else</span> <span class="n">default</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="L-382"><a href="#L-382"><span class="linenos">382</span></a> <span class="p">),</span> -</span><span id="L-383"><a href="#L-383"><span class="linenos">383</span></a> <span class="p">)</span> -</span><span id="L-384"><a href="#L-384"><span class="linenos">384</span></a> -</span><span id="L-385"><a href="#L-385"><span class="linenos">385</span></a> <span class="k">return</span> <span class="n">_format_time</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><span id="L-388"><a href="#L-388"><span class="linenos">388</span></a><span class="k">def</span> <span class="nf">create_with_partitions_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-389"><a href="#L-389"><span class="linenos">389</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-390"><a href="#L-390"><span class="linenos">390</span></a><span class="sd"> In Hive and Spark, the PARTITIONED BY property acts as an extension of a table's schema. When the</span> -</span><span id="L-391"><a href="#L-391"><span class="linenos">391</span></a><span class="sd"> PARTITIONED BY value is an array of column names, they are transformed into a schema. The corresponding</span> -</span><span id="L-392"><a href="#L-392"><span class="linenos">392</span></a><span class="sd"> columns are removed from the create statement.</span> -</span><span id="L-393"><a href="#L-393"><span class="linenos">393</span></a><span class="sd"> """</span> -</span><span id="L-394"><a href="#L-394"><span class="linenos">394</span></a> <span class="n">has_schema</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> -</span><span id="L-395"><a href="#L-395"><span class="linenos">395</span></a> <span class="n">is_partitionable</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"TABLE"</span><span class="p">,</span> <span class="s2">"VIEW"</span><span class="p">)</span> -</span><span id="L-396"><a href="#L-396"><span class="linenos">396</span></a> -</span><span id="L-397"><a href="#L-397"><span class="linenos">397</span></a> <span class="k">if</span> <span class="n">has_schema</span> <span class="ow">and</span> <span class="n">is_partitionable</span><span class="p">:</span> -</span><span id="L-398"><a href="#L-398"><span class="linenos">398</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="L-399"><a href="#L-399"><span class="linenos">399</span></a> <span class="n">prop</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">PartitionedByProperty</span><span class="p">)</span> -</span><span id="L-400"><a href="#L-400"><span class="linenos">400</span></a> <span class="k">if</span> <span class="n">prop</span> <span class="ow">and</span> <span class="n">prop</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">prop</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><span id="L-401"><a href="#L-401"><span class="linenos">401</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-402"><a href="#L-402"><span class="linenos">402</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="p">{</span><span class="n">v</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="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">prop</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">}</span> -</span><span id="L-403"><a href="#L-403"><span class="linenos">403</span></a> <span class="n">partitions</span> <span class="o">=</span> <span class="p">[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">schema</span><span class="o">.</span><span class="n">expressions</span> <span class="k">if</span> <span class="n">col</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="ow">in</span> <span class="n">columns</span><span class="p">]</span> -</span><span id="L-404"><a href="#L-404"><span class="linenos">404</span></a> <span class="n">schema</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="p">[</span><span class="n">e</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">schema</span><span class="o">.</span><span class="n">expressions</span> <span class="k">if</span> <span class="n">e</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">partitions</span><span class="p">])</span> -</span><span id="L-405"><a href="#L-405"><span class="linenos">405</span></a> <span class="n">prop</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">PartitionedByProperty</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">partitions</span><span class="p">)))</span> -</span><span id="L-406"><a href="#L-406"><span class="linenos">406</span></a> <span class="n">expression</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">schema</span><span class="p">)</span> -</span><span id="L-407"><a href="#L-407"><span class="linenos">407</span></a> -</span><span id="L-408"><a href="#L-408"><span class="linenos">408</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-409"><a href="#L-409"><span class="linenos">409</span></a> -</span><span id="L-410"><a href="#L-410"><span class="linenos">410</span></a> -</span><span id="L-411"><a href="#L-411"><span class="linenos">411</span></a><span class="k">def</span> <span class="nf">parse_date_delta</span><span class="p">(</span> -</span><span id="L-412"><a href="#L-412"><span class="linenos">412</span></a> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> <span class="n">unit_mapping</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-413"><a href="#L-413"><span class="linenos">413</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">],</span> <span class="n">E</span><span class="p">]:</span> -</span><span id="L-414"><a href="#L-414"><span class="linenos">414</span></a> <span class="k">def</span> <span class="nf">inner_func</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="L-415"><a href="#L-415"><span class="linenos">415</span></a> <span class="n">unit_based</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span> -</span><span id="L-416"><a href="#L-416"><span class="linenos">416</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="k">if</span> <span class="n">unit_based</span> <span class="k">else</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-417"><a href="#L-417"><span class="linenos">417</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">if</span> <span class="n">unit_based</span> <span class="k">else</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">"DAY"</span><span class="p">)</span> -</span><span id="L-418"><a href="#L-418"><span class="linenos">418</span></a> <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="n">unit_mapping</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">unit</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> <span class="n">unit</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> <span class="k">if</span> <span class="n">unit_mapping</span> <span class="k">else</span> <span class="n">unit</span> -</span><span id="L-419"><a href="#L-419"><span class="linenos">419</span></a> <span class="k">return</span> <span class="n">exp_class</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">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">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">)</span> +</span><span id="L-359"><a href="#L-359"><span class="linenos">359</span></a><span class="k">def</span> <span class="nf">no_safe_divide_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-360"><a href="#L-360"><span class="linenos">360</span></a> <span class="n">n</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a> <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"IF(</span><span class="si">{</span><span class="n">d</span><span class="si">}</span><span class="s2"> <> 0, </span><span class="si">{</span><span class="n">n</span><span class="si">}</span><span class="s2"> / </span><span class="si">{</span><span class="n">d</span><span class="si">}</span><span class="s2">, NULL)"</span> +</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a> +</span><span id="L-364"><a href="#L-364"><span class="linenos">364</span></a> +</span><span id="L-365"><a href="#L-365"><span class="linenos">365</span></a><span class="k">def</span> <span class="nf">no_tablesample_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-366"><a href="#L-366"><span class="linenos">366</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"TABLESAMPLE unsupported"</span><span class="p">)</span> +</span><span id="L-367"><a href="#L-367"><span class="linenos">367</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="o">.</span><span class="n">this</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><span id="L-370"><a href="#L-370"><span class="linenos">370</span></a><span class="k">def</span> <span class="nf">no_pivot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-371"><a href="#L-371"><span class="linenos">371</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"PIVOT unsupported"</span><span class="p">)</span> +</span><span id="L-372"><a href="#L-372"><span class="linenos">372</span></a> <span class="k">return</span> <span class="s2">""</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><span id="L-375"><a href="#L-375"><span class="linenos">375</span></a><span class="k">def</span> <span class="nf">no_trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</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">cast_sql</span><span class="p">(</span><span class="n">expression</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><span id="L-379"><a href="#L-379"><span class="linenos">379</span></a><span class="k">def</span> <span class="nf">no_properties_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-380"><a href="#L-380"><span class="linenos">380</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Properties unsupported"</span><span class="p">)</span> +</span><span id="L-381"><a href="#L-381"><span class="linenos">381</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-382"><a href="#L-382"><span class="linenos">382</span></a> +</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">no_comment_column_constraint_sql</span><span class="p">(</span> +</span><span id="L-385"><a href="#L-385"><span class="linenos">385</span></a> <span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CommentColumnConstraint</span> +</span><span id="L-386"><a href="#L-386"><span class="linenos">386</span></a><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-387"><a href="#L-387"><span class="linenos">387</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"CommentColumnConstraint unsupported"</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="s2">""</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><span id="L-391"><a href="#L-391"><span class="linenos">391</span></a><span class="k">def</span> <span class="nf">str_position_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-392"><a href="#L-392"><span class="linenos">392</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-393"><a href="#L-393"><span class="linenos">393</span></a> <span class="n">substr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"substr"</span><span class="p">)</span> +</span><span id="L-394"><a href="#L-394"><span class="linenos">394</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> +</span><span id="L-395"><a href="#L-395"><span class="linenos">395</span></a> <span class="k">if</span> <span class="n">position</span><span class="p">:</span> +</span><span id="L-396"><a href="#L-396"><span class="linenos">396</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"STRPOS(SUBSTR(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2">), </span><span class="si">{</span><span class="n">substr</span><span class="si">}</span><span class="s2">) + </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2"> - 1"</span> +</span><span id="L-397"><a href="#L-397"><span class="linenos">397</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"STRPOS(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">substr</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-398"><a href="#L-398"><span class="linenos">398</span></a> +</span><span id="L-399"><a href="#L-399"><span class="linenos">399</span></a> +</span><span id="L-400"><a href="#L-400"><span class="linenos">400</span></a><span class="k">def</span> <span class="nf">struct_extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-401"><a href="#L-401"><span class="linenos">401</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-402"><a href="#L-402"><span class="linenos">402</span></a> <span class="n">struct_key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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">expression</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="L-403"><a href="#L-403"><span class="linenos">403</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">struct_key</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-404"><a href="#L-404"><span class="linenos">404</span></a> +</span><span id="L-405"><a href="#L-405"><span class="linenos">405</span></a> +</span><span id="L-406"><a href="#L-406"><span class="linenos">406</span></a><span class="k">def</span> <span class="nf">var_map_sql</span><span class="p">(</span> +</span><span id="L-407"><a href="#L-407"><span class="linenos">407</span></a> <span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Map</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</span><span class="p">,</span> <span class="n">map_func_name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"MAP"</span> +</span><span id="L-408"><a href="#L-408"><span class="linenos">408</span></a><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-409"><a href="#L-409"><span class="linenos">409</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"keys"</span><span class="p">]</span> +</span><span id="L-410"><a href="#L-410"><span class="linenos">410</span></a> <span class="n">values</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">"values"</span><span class="p">]</span> +</span><span id="L-411"><a href="#L-411"><span class="linenos">411</span></a> +</span><span id="L-412"><a href="#L-412"><span class="linenos">412</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">keys</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">values</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-413"><a href="#L-413"><span class="linenos">413</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Cannot convert array columns into map."</span><span class="p">)</span> +</span><span id="L-414"><a href="#L-414"><span class="linenos">414</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">map_func_name</span><span class="p">,</span> <span class="n">keys</span><span class="p">,</span> <span class="n">values</span><span class="p">)</span> +</span><span id="L-415"><a href="#L-415"><span class="linenos">415</span></a> +</span><span id="L-416"><a href="#L-416"><span class="linenos">416</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-417"><a href="#L-417"><span class="linenos">417</span></a> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">keys</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="n">values</span><span class="o">.</span><span class="n">expressions</span><span class="p">):</span> +</span><span id="L-418"><a href="#L-418"><span class="linenos">418</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</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">key</span><span class="p">))</span> +</span><span id="L-419"><a href="#L-419"><span class="linenos">419</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</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">value</span><span class="p">))</span> </span><span id="L-420"><a href="#L-420"><span class="linenos">420</span></a> -</span><span id="L-421"><a href="#L-421"><span class="linenos">421</span></a> <span class="k">return</span> <span class="n">inner_func</span> +</span><span id="L-421"><a href="#L-421"><span class="linenos">421</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">map_func_name</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> </span><span id="L-422"><a href="#L-422"><span class="linenos">422</span></a> </span><span id="L-423"><a href="#L-423"><span class="linenos">423</span></a> -</span><span id="L-424"><a href="#L-424"><span class="linenos">424</span></a><span class="k">def</span> <span class="nf">parse_date_delta_with_interval</span><span class="p">(</span> -</span><span id="L-425"><a href="#L-425"><span class="linenos">425</span></a> <span class="n">expression_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> -</span><span id="L-426"><a href="#L-426"><span class="linenos">426</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">t</span><span class="o">.</span><span class="n">List</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">E</span><span class="p">]]:</span> -</span><span id="L-427"><a href="#L-427"><span class="linenos">427</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">E</span><span class="p">]:</span> -</span><span id="L-428"><a href="#L-428"><span class="linenos">428</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o"><</span> <span class="mi">2</span><span class="p">:</span> -</span><span id="L-429"><a href="#L-429"><span class="linenos">429</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-430"><a href="#L-430"><span class="linenos">430</span></a> -</span><span id="L-431"><a href="#L-431"><span class="linenos">431</span></a> <span class="n">interval</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> -</span><span id="L-432"><a href="#L-432"><span class="linenos">432</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">interval</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-433"><a href="#L-433"><span class="linenos">433</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> -</span><span id="L-434"><a href="#L-434"><span class="linenos">434</span></a> <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="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-435"><a href="#L-435"><span class="linenos">435</span></a> -</span><span id="L-436"><a href="#L-436"><span class="linenos">436</span></a> <span class="k">return</span> <span class="n">expression_class</span><span class="p">(</span> -</span><span id="L-437"><a href="#L-437"><span class="linenos">437</span></a> <span class="n">this</span><span class="o">=</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">expression</span><span class="p">,</span> <span class="n">unit</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="n">interval</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">))</span> -</span><span id="L-438"><a href="#L-438"><span class="linenos">438</span></a> <span class="p">)</span> -</span><span id="L-439"><a href="#L-439"><span class="linenos">439</span></a> -</span><span id="L-440"><a href="#L-440"><span class="linenos">440</span></a> <span class="k">return</span> <span class="n">func</span> -</span><span id="L-441"><a href="#L-441"><span class="linenos">441</span></a> -</span><span id="L-442"><a href="#L-442"><span class="linenos">442</span></a> -</span><span id="L-443"><a href="#L-443"><span class="linenos">443</span></a><span class="k">def</span> <span class="nf">date_trunc_to_time</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">:</span> -</span><span id="L-444"><a href="#L-444"><span class="linenos">444</span></a> <span class="n">unit</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-445"><a href="#L-445"><span class="linenos">445</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">1</span><span class="p">)</span> +</span><span id="L-424"><a href="#L-424"><span class="linenos">424</span></a><span class="k">def</span> <span class="nf">format_time_lambda</span><span class="p">(</span> +</span><span id="L-425"><a href="#L-425"><span class="linenos">425</span></a> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> <span class="n">dialect</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">default</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span> <span class="o">|</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-426"><a href="#L-426"><span class="linenos">426</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">],</span> <span class="n">E</span><span class="p">]:</span> +</span><span id="L-427"><a href="#L-427"><span class="linenos">427</span></a><span class="w"> </span><span class="sd">"""Helper used for time expressions.</span> +</span><span id="L-428"><a href="#L-428"><span class="linenos">428</span></a> +</span><span id="L-429"><a href="#L-429"><span class="linenos">429</span></a><span class="sd"> Args:</span> +</span><span id="L-430"><a href="#L-430"><span class="linenos">430</span></a><span class="sd"> exp_class: the expression class to instantiate.</span> +</span><span id="L-431"><a href="#L-431"><span class="linenos">431</span></a><span class="sd"> dialect: target sql dialect.</span> +</span><span id="L-432"><a href="#L-432"><span class="linenos">432</span></a><span class="sd"> default: the default format, True being time.</span> +</span><span id="L-433"><a href="#L-433"><span class="linenos">433</span></a> +</span><span id="L-434"><a href="#L-434"><span class="linenos">434</span></a><span class="sd"> Returns:</span> +</span><span id="L-435"><a href="#L-435"><span class="linenos">435</span></a><span class="sd"> A callable that can be used to return the appropriately formatted time expression.</span> +</span><span id="L-436"><a href="#L-436"><span class="linenos">436</span></a><span class="sd"> """</span> +</span><span id="L-437"><a href="#L-437"><span class="linenos">437</span></a> +</span><span id="L-438"><a href="#L-438"><span class="linenos">438</span></a> <span class="k">def</span> <span class="nf">_format_time</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">):</span> +</span><span id="L-439"><a href="#L-439"><span class="linenos">439</span></a> <span class="k">return</span> <span class="n">exp_class</span><span class="p">(</span> +</span><span id="L-440"><a href="#L-440"><span class="linenos">440</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-441"><a href="#L-441"><span class="linenos">441</span></a> <span class="nb">format</span><span class="o">=</span><span class="n">Dialect</span><span class="p">[</span><span class="n">dialect</span><span class="p">]</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span> +</span><span id="L-442"><a href="#L-442"><span class="linenos">442</span></a> <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-443"><a href="#L-443"><span class="linenos">443</span></a> <span class="ow">or</span> <span class="p">(</span><span class="n">Dialect</span><span class="p">[</span><span class="n">dialect</span><span class="p">]</span><span class="o">.</span><span class="n">TIME_FORMAT</span> <span class="k">if</span> <span class="n">default</span> <span class="ow">is</span> <span class="kc">True</span> <span class="k">else</span> <span class="n">default</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="L-444"><a href="#L-444"><span class="linenos">444</span></a> <span class="p">),</span> +</span><span id="L-445"><a href="#L-445"><span class="linenos">445</span></a> <span class="p">)</span> </span><span id="L-446"><a href="#L-446"><span class="linenos">446</span></a> -</span><span id="L-447"><a href="#L-447"><span class="linenos">447</span></a> <span class="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">Cast</span><span class="p">)</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"date"</span><span class="p">):</span> -</span><span id="L-448"><a href="#L-448"><span class="linenos">448</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</span><span class="p">(</span><span class="n">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-449"><a href="#L-449"><span class="linenos">449</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">)</span> -</span><span id="L-450"><a href="#L-450"><span class="linenos">450</span></a> -</span><span id="L-451"><a href="#L-451"><span class="linenos">451</span></a> -</span><span id="L-452"><a href="#L-452"><span class="linenos">452</span></a><span class="k">def</span> <span class="nf">timestamptrunc_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-453"><a href="#L-453"><span class="linenos">453</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-454"><a href="#L-454"><span class="linenos">454</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"day"</span><span class="p">),</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-455"><a href="#L-455"><span class="linenos">455</span></a> <span class="p">)</span> -</span><span id="L-456"><a href="#L-456"><span class="linenos">456</span></a> -</span><span id="L-457"><a href="#L-457"><span class="linenos">457</span></a> -</span><span id="L-458"><a href="#L-458"><span class="linenos">458</span></a><span class="k">def</span> <span class="nf">locate_to_strposition</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="L-459"><a href="#L-459"><span class="linenos">459</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">(</span> -</span><span id="L-460"><a href="#L-460"><span class="linenos">460</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">1</span><span class="p">),</span> <span class="n">substr</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">position</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-461"><a href="#L-461"><span class="linenos">461</span></a> <span class="p">)</span> -</span><span id="L-462"><a href="#L-462"><span class="linenos">462</span></a> -</span><span id="L-463"><a href="#L-463"><span class="linenos">463</span></a> -</span><span id="L-464"><a href="#L-464"><span class="linenos">464</span></a><span class="k">def</span> <span class="nf">strposition_to_locate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-465"><a href="#L-465"><span class="linenos">465</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-466"><a href="#L-466"><span class="linenos">466</span></a> <span class="s2">"LOCATE"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"substr"</span><span class="p">),</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"position"</span><span class="p">)</span> -</span><span id="L-467"><a href="#L-467"><span class="linenos">467</span></a> <span class="p">)</span> -</span><span id="L-468"><a href="#L-468"><span class="linenos">468</span></a> +</span><span id="L-447"><a href="#L-447"><span class="linenos">447</span></a> <span class="k">return</span> <span class="n">_format_time</span> +</span><span id="L-448"><a href="#L-448"><span class="linenos">448</span></a> +</span><span id="L-449"><a href="#L-449"><span class="linenos">449</span></a> +</span><span id="L-450"><a href="#L-450"><span class="linenos">450</span></a><span class="k">def</span> <span class="nf">create_with_partitions_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-451"><a href="#L-451"><span class="linenos">451</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-452"><a href="#L-452"><span class="linenos">452</span></a><span class="sd"> In Hive and Spark, the PARTITIONED BY property acts as an extension of a table's schema. When the</span> +</span><span id="L-453"><a href="#L-453"><span class="linenos">453</span></a><span class="sd"> PARTITIONED BY value is an array of column names, they are transformed into a schema. The corresponding</span> +</span><span id="L-454"><a href="#L-454"><span class="linenos">454</span></a><span class="sd"> columns are removed from the create statement.</span> +</span><span id="L-455"><a href="#L-455"><span class="linenos">455</span></a><span class="sd"> """</span> +</span><span id="L-456"><a href="#L-456"><span class="linenos">456</span></a> <span class="n">has_schema</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> +</span><span id="L-457"><a href="#L-457"><span class="linenos">457</span></a> <span class="n">is_partitionable</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"TABLE"</span><span class="p">,</span> <span class="s2">"VIEW"</span><span class="p">)</span> +</span><span id="L-458"><a href="#L-458"><span class="linenos">458</span></a> +</span><span id="L-459"><a href="#L-459"><span class="linenos">459</span></a> <span class="k">if</span> <span class="n">has_schema</span> <span class="ow">and</span> <span class="n">is_partitionable</span><span class="p">:</span> +</span><span id="L-460"><a href="#L-460"><span class="linenos">460</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="L-461"><a href="#L-461"><span class="linenos">461</span></a> <span class="n">prop</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">PartitionedByProperty</span><span class="p">)</span> +</span><span id="L-462"><a href="#L-462"><span class="linenos">462</span></a> <span class="k">if</span> <span class="n">prop</span> <span class="ow">and</span> <span class="n">prop</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">prop</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><span id="L-463"><a href="#L-463"><span class="linenos">463</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-464"><a href="#L-464"><span class="linenos">464</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="p">{</span><span class="n">v</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="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">prop</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">}</span> +</span><span id="L-465"><a href="#L-465"><span class="linenos">465</span></a> <span class="n">partitions</span> <span class="o">=</span> <span class="p">[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">schema</span><span class="o">.</span><span class="n">expressions</span> <span class="k">if</span> <span class="n">col</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="ow">in</span> <span class="n">columns</span><span class="p">]</span> +</span><span id="L-466"><a href="#L-466"><span class="linenos">466</span></a> <span class="n">schema</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="p">[</span><span class="n">e</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">schema</span><span class="o">.</span><span class="n">expressions</span> <span class="k">if</span> <span class="n">e</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">partitions</span><span class="p">])</span> +</span><span id="L-467"><a href="#L-467"><span class="linenos">467</span></a> <span class="n">prop</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">PartitionedByProperty</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">partitions</span><span class="p">)))</span> +</span><span id="L-468"><a href="#L-468"><span class="linenos">468</span></a> <span class="n">expression</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">schema</span><span class="p">)</span> </span><span id="L-469"><a href="#L-469"><span class="linenos">469</span></a> -</span><span id="L-470"><a href="#L-470"><span class="linenos">470</span></a><span class="k">def</span> <span class="nf">left_to_substring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-471"><a href="#L-471"><span class="linenos">471</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="L-472"><a href="#L-472"><span class="linenos">472</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="L-473"><a href="#L-473"><span class="linenos">473</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Substring</span><span class="p">(</span> -</span><span id="L-474"><a href="#L-474"><span class="linenos">474</span></a> <span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">length</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span> -</span><span id="L-475"><a href="#L-475"><span class="linenos">475</span></a> <span class="p">)</span> -</span><span id="L-476"><a href="#L-476"><span class="linenos">476</span></a> <span class="p">)</span> -</span><span id="L-477"><a href="#L-477"><span class="linenos">477</span></a> -</span><span id="L-478"><a href="#L-478"><span class="linenos">478</span></a> -</span><span id="L-479"><a href="#L-479"><span class="linenos">479</span></a><span class="k">def</span> <span class="nf">right_to_substring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-480"><a href="#L-480"><span class="linenos">480</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="L-481"><a href="#L-481"><span class="linenos">481</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="L-482"><a href="#L-482"><span class="linenos">482</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Substring</span><span class="p">(</span> -</span><span id="L-483"><a href="#L-483"><span class="linenos">483</span></a> <span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-484"><a href="#L-484"><span class="linenos">484</span></a> <span class="n">start</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Length</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="o">-</span> <span class="n">exp</span><span class="o">.</span><span class="n">paren</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span> <span class="o">-</span> <span class="mi">1</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="p">)</span> -</span><span id="L-487"><a href="#L-487"><span class="linenos">487</span></a> -</span><span id="L-488"><a href="#L-488"><span class="linenos">488</span></a> -</span><span id="L-489"><a href="#L-489"><span class="linenos">489</span></a><span class="k">def</span> <span class="nf">timestrtotime_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-490"><a href="#L-490"><span class="linenos">490</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS TIMESTAMP)"</span> -</span><span id="L-491"><a href="#L-491"><span class="linenos">491</span></a> +</span><span id="L-470"><a href="#L-470"><span class="linenos">470</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-471"><a href="#L-471"><span class="linenos">471</span></a> +</span><span id="L-472"><a href="#L-472"><span class="linenos">472</span></a> +</span><span id="L-473"><a href="#L-473"><span class="linenos">473</span></a><span class="k">def</span> <span class="nf">parse_date_delta</span><span class="p">(</span> +</span><span id="L-474"><a href="#L-474"><span class="linenos">474</span></a> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> <span class="n">unit_mapping</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-475"><a href="#L-475"><span class="linenos">475</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">],</span> <span class="n">E</span><span class="p">]:</span> +</span><span id="L-476"><a href="#L-476"><span class="linenos">476</span></a> <span class="k">def</span> <span class="nf">inner_func</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="L-477"><a href="#L-477"><span class="linenos">477</span></a> <span class="n">unit_based</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span> +</span><span id="L-478"><a href="#L-478"><span class="linenos">478</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="k">if</span> <span class="n">unit_based</span> <span class="k">else</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-479"><a href="#L-479"><span class="linenos">479</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">if</span> <span class="n">unit_based</span> <span class="k">else</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">"DAY"</span><span class="p">)</span> +</span><span id="L-480"><a href="#L-480"><span class="linenos">480</span></a> <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="n">unit_mapping</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">unit</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> <span class="n">unit</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> <span class="k">if</span> <span class="n">unit_mapping</span> <span class="k">else</span> <span class="n">unit</span> +</span><span id="L-481"><a href="#L-481"><span class="linenos">481</span></a> <span class="k">return</span> <span class="n">exp_class</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">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">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">)</span> +</span><span id="L-482"><a href="#L-482"><span class="linenos">482</span></a> +</span><span id="L-483"><a href="#L-483"><span class="linenos">483</span></a> <span class="k">return</span> <span class="n">inner_func</span> +</span><span id="L-484"><a href="#L-484"><span class="linenos">484</span></a> +</span><span id="L-485"><a href="#L-485"><span class="linenos">485</span></a> +</span><span id="L-486"><a href="#L-486"><span class="linenos">486</span></a><span class="k">def</span> <span class="nf">parse_date_delta_with_interval</span><span class="p">(</span> +</span><span id="L-487"><a href="#L-487"><span class="linenos">487</span></a> <span class="n">expression_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> +</span><span id="L-488"><a href="#L-488"><span class="linenos">488</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">t</span><span class="o">.</span><span class="n">List</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">E</span><span class="p">]]:</span> +</span><span id="L-489"><a href="#L-489"><span class="linenos">489</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">E</span><span class="p">]:</span> +</span><span id="L-490"><a href="#L-490"><span class="linenos">490</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o"><</span> <span class="mi">2</span><span class="p">:</span> +</span><span id="L-491"><a href="#L-491"><span class="linenos">491</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="L-492"><a href="#L-492"><span class="linenos">492</span></a> -</span><span id="L-493"><a href="#L-493"><span class="linenos">493</span></a><span class="k">def</span> <span class="nf">datestrtodate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-494"><a href="#L-494"><span class="linenos">494</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">sql</span><span class="p">(</span><span class="n">expression</span><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 DATE)"</span> -</span><span id="L-495"><a href="#L-495"><span class="linenos">495</span></a> -</span><span id="L-496"><a href="#L-496"><span class="linenos">496</span></a> -</span><span id="L-497"><a href="#L-497"><span class="linenos">497</span></a><span class="k">def</span> <span class="nf">min_or_least</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-498"><a href="#L-498"><span class="linenos">498</span></a> <span class="n">name</span> <span class="o">=</span> <span class="s2">"LEAST"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">"MIN"</span> -</span><span id="L-499"><a href="#L-499"><span class="linenos">499</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="n">name</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-500"><a href="#L-500"><span class="linenos">500</span></a> +</span><span id="L-493"><a href="#L-493"><span class="linenos">493</span></a> <span class="n">interval</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> +</span><span id="L-494"><a href="#L-494"><span class="linenos">494</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">interval</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-495"><a href="#L-495"><span class="linenos">495</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> +</span><span id="L-496"><a href="#L-496"><span class="linenos">496</span></a> <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="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-497"><a href="#L-497"><span class="linenos">497</span></a> +</span><span id="L-498"><a href="#L-498"><span class="linenos">498</span></a> <span class="k">return</span> <span class="n">expression_class</span><span class="p">(</span> +</span><span id="L-499"><a href="#L-499"><span class="linenos">499</span></a> <span class="n">this</span><span class="o">=</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">expression</span><span class="p">,</span> <span class="n">unit</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="n">interval</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">))</span> +</span><span id="L-500"><a href="#L-500"><span class="linenos">500</span></a> <span class="p">)</span> </span><span id="L-501"><a href="#L-501"><span class="linenos">501</span></a> -</span><span id="L-502"><a href="#L-502"><span class="linenos">502</span></a><span class="k">def</span> <span class="nf">max_or_greatest</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-503"><a href="#L-503"><span class="linenos">503</span></a> <span class="n">name</span> <span class="o">=</span> <span class="s2">"GREATEST"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">"MAX"</span> -</span><span id="L-504"><a href="#L-504"><span class="linenos">504</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="n">name</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-505"><a href="#L-505"><span class="linenos">505</span></a> -</span><span id="L-506"><a href="#L-506"><span class="linenos">506</span></a> -</span><span id="L-507"><a href="#L-507"><span class="linenos">507</span></a><span class="k">def</span> <span class="nf">count_if_to_sum</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CountIf</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-508"><a href="#L-508"><span class="linenos">508</span></a> <span class="n">cond</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-509"><a href="#L-509"><span class="linenos">509</span></a> -</span><span id="L-510"><a href="#L-510"><span class="linenos">510</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distinct</span><span class="p">):</span> -</span><span id="L-511"><a href="#L-511"><span class="linenos">511</span></a> <span class="n">cond</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="L-512"><a href="#L-512"><span class="linenos">512</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"DISTINCT is not supported when converting COUNT_IF to SUM"</span><span class="p">)</span> +</span><span id="L-502"><a href="#L-502"><span class="linenos">502</span></a> <span class="k">return</span> <span class="n">func</span> +</span><span id="L-503"><a href="#L-503"><span class="linenos">503</span></a> +</span><span id="L-504"><a href="#L-504"><span class="linenos">504</span></a> +</span><span id="L-505"><a href="#L-505"><span class="linenos">505</span></a><span class="k">def</span> <span class="nf">date_trunc_to_time</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">:</span> +</span><span id="L-506"><a href="#L-506"><span class="linenos">506</span></a> <span class="n">unit</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-507"><a href="#L-507"><span class="linenos">507</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">1</span><span class="p">)</span> +</span><span id="L-508"><a href="#L-508"><span class="linenos">508</span></a> +</span><span id="L-509"><a href="#L-509"><span class="linenos">509</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">Cast</span><span class="p">)</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"date"</span><span class="p">):</span> +</span><span id="L-510"><a href="#L-510"><span class="linenos">510</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</span><span class="p">(</span><span class="n">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-511"><a href="#L-511"><span class="linenos">511</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">)</span> +</span><span id="L-512"><a href="#L-512"><span class="linenos">512</span></a> </span><span id="L-513"><a href="#L-513"><span class="linenos">513</span></a> -</span><span id="L-514"><a href="#L-514"><span class="linenos">514</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">"sum"</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">"if"</span><span class="p">,</span> <span class="n">cond</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span> -</span><span id="L-515"><a href="#L-515"><span class="linenos">515</span></a> -</span><span id="L-516"><a href="#L-516"><span class="linenos">516</span></a> -</span><span id="L-517"><a href="#L-517"><span class="linenos">517</span></a><span class="k">def</span> <span class="nf">trim_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">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">Trim</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-518"><a href="#L-518"><span class="linenos">518</span></a> <span class="n">target</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-519"><a href="#L-519"><span class="linenos">519</span></a> <span class="n">trim_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> -</span><span id="L-520"><a href="#L-520"><span class="linenos">520</span></a> <span class="n">remove_chars</span> <span class="o">=</span> <span class="bp">self</span><span 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-521"><a href="#L-521"><span class="linenos">521</span></a> <span class="n">collation</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collation"</span><span class="p">)</span> -</span><span id="L-522"><a href="#L-522"><span class="linenos">522</span></a> -</span><span id="L-523"><a href="#L-523"><span class="linenos">523</span></a> <span class="c1"># Use TRIM/LTRIM/RTRIM syntax if the expression isn't database-specific</span> -</span><span id="L-524"><a href="#L-524"><span class="linenos">524</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">remove_chars</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">collation</span><span class="p">:</span> -</span><span id="L-525"><a href="#L-525"><span class="linenos">525</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">trim_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-526"><a href="#L-526"><span class="linenos">526</span></a> -</span><span id="L-527"><a href="#L-527"><span class="linenos">527</span></a> <span class="n">trim_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">trim_type</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">trim_type</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-528"><a href="#L-528"><span class="linenos">528</span></a> <span class="n">remove_chars</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">remove_chars</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">remove_chars</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-529"><a href="#L-529"><span class="linenos">529</span></a> <span class="n">from_part</span> <span class="o">=</span> <span class="s2">"FROM "</span> <span class="k">if</span> <span class="n">trim_type</span> <span class="ow">or</span> <span class="n">remove_chars</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-530"><a href="#L-530"><span class="linenos">530</span></a> <span class="n">collation</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collation</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collation</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-531"><a href="#L-531"><span class="linenos">531</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TRIM(</span><span class="si">{</span><span class="n">trim_type</span><span class="si">}{</span><span class="n">remove_chars</span><span class="si">}{</span><span class="n">from_part</span><span class="si">}{</span><span class="n">target</span><span class="si">}{</span><span class="n">collation</span><span class="si">}</span><span class="s2">)"</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><span id="L-534"><a href="#L-534"><span class="linenos">534</span></a><span class="k">def</span> <span class="nf">str_to_time_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-535"><a href="#L-535"><span class="linenos">535</span></a> <span class="k">return</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">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">))</span> -</span><span id="L-536"><a href="#L-536"><span class="linenos">536</span></a> -</span><span id="L-537"><a href="#L-537"><span class="linenos">537</span></a> -</span><span id="L-538"><a href="#L-538"><span class="linenos">538</span></a><span class="k">def</span> <span class="nf">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="n">dialect</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">:</span> -</span><span id="L-539"><a href="#L-539"><span class="linenos">539</span></a> <span class="k">def</span> <span class="nf">_ts_or_ds_to_date_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-540"><a href="#L-540"><span class="linenos">540</span></a> <span class="n">_dialect</span> <span class="o">=</span> <span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span> -</span><span id="L-541"><a href="#L-541"><span class="linenos">541</span></a> <span class="n">time_format</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-542"><a href="#L-542"><span class="linenos">542</span></a> <span class="k">if</span> <span class="n">time_format</span> <span class="ow">and</span> <span class="n">time_format</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span><span class="n">_dialect</span><span class="o">.</span><span class="n">TIME_FORMAT</span><span class="p">,</span> <span class="n">_dialect</span><span class="o">.</span><span class="n">DATE_FORMAT</span><span class="p">):</span> -</span><span id="L-543"><a href="#L-543"><span class="linenos">543</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-544"><a href="#L-544"><span class="linenos">544</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">sql</span><span class="p">(</span><span class="n">expression</span><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 DATE)"</span> -</span><span id="L-545"><a href="#L-545"><span class="linenos">545</span></a> -</span><span id="L-546"><a href="#L-546"><span class="linenos">546</span></a> <span class="k">return</span> <span class="n">_ts_or_ds_to_date_sql</span> -</span><span id="L-547"><a href="#L-547"><span class="linenos">547</span></a> -</span><span id="L-548"><a href="#L-548"><span class="linenos">548</span></a> -</span><span id="L-549"><a href="#L-549"><span class="linenos">549</span></a><span class="k">def</span> <span class="nf">concat_to_dpipe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-550"><a href="#L-550"><span class="linenos">550</span></a> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest_args</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="L-551"><a href="#L-551"><span class="linenos">551</span></a> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">rest_args</span><span class="p">:</span> -</span><span id="L-552"><a href="#L-552"><span class="linenos">552</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DPipe</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">arg</span><span class="p">)</span> +</span><span id="L-514"><a href="#L-514"><span class="linenos">514</span></a><span class="k">def</span> <span class="nf">timestamptrunc_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-515"><a href="#L-515"><span class="linenos">515</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-516"><a href="#L-516"><span class="linenos">516</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"day"</span><span class="p">),</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-517"><a href="#L-517"><span class="linenos">517</span></a> <span class="p">)</span> +</span><span id="L-518"><a href="#L-518"><span class="linenos">518</span></a> +</span><span id="L-519"><a href="#L-519"><span class="linenos">519</span></a> +</span><span id="L-520"><a href="#L-520"><span class="linenos">520</span></a><span class="k">def</span> <span class="nf">locate_to_strposition</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="L-521"><a href="#L-521"><span class="linenos">521</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">(</span> +</span><span id="L-522"><a href="#L-522"><span class="linenos">522</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">1</span><span class="p">),</span> <span class="n">substr</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">position</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-523"><a href="#L-523"><span class="linenos">523</span></a> <span class="p">)</span> +</span><span id="L-524"><a href="#L-524"><span class="linenos">524</span></a> +</span><span id="L-525"><a href="#L-525"><span class="linenos">525</span></a> +</span><span id="L-526"><a href="#L-526"><span class="linenos">526</span></a><span class="k">def</span> <span class="nf">strposition_to_locate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-527"><a href="#L-527"><span class="linenos">527</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-528"><a href="#L-528"><span class="linenos">528</span></a> <span class="s2">"LOCATE"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"substr"</span><span class="p">),</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"position"</span><span class="p">)</span> +</span><span id="L-529"><a href="#L-529"><span class="linenos">529</span></a> <span class="p">)</span> +</span><span id="L-530"><a href="#L-530"><span class="linenos">530</span></a> +</span><span id="L-531"><a href="#L-531"><span class="linenos">531</span></a> +</span><span id="L-532"><a href="#L-532"><span class="linenos">532</span></a><span class="k">def</span> <span class="nf">left_to_substring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-533"><a href="#L-533"><span class="linenos">533</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="L-534"><a href="#L-534"><span class="linenos">534</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="L-535"><a href="#L-535"><span class="linenos">535</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Substring</span><span class="p">(</span> +</span><span id="L-536"><a href="#L-536"><span class="linenos">536</span></a> <span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">length</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</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 class="p">)</span> +</span><span id="L-539"><a href="#L-539"><span class="linenos">539</span></a> +</span><span id="L-540"><a href="#L-540"><span class="linenos">540</span></a> +</span><span id="L-541"><a href="#L-541"><span class="linenos">541</span></a><span class="k">def</span> <span class="nf">right_to_substring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-542"><a href="#L-542"><span class="linenos">542</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="L-543"><a href="#L-543"><span class="linenos">543</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="L-544"><a href="#L-544"><span class="linenos">544</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Substring</span><span class="p">(</span> +</span><span id="L-545"><a href="#L-545"><span class="linenos">545</span></a> <span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-546"><a href="#L-546"><span class="linenos">546</span></a> <span class="n">start</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Length</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="o">-</span> <span class="n">exp</span><span class="o">.</span><span class="n">paren</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> +</span><span id="L-547"><a href="#L-547"><span class="linenos">547</span></a> <span class="p">)</span> +</span><span id="L-548"><a href="#L-548"><span class="linenos">548</span></a> <span class="p">)</span> +</span><span id="L-549"><a href="#L-549"><span class="linenos">549</span></a> +</span><span id="L-550"><a href="#L-550"><span class="linenos">550</span></a> +</span><span id="L-551"><a href="#L-551"><span class="linenos">551</span></a><span class="k">def</span> <span class="nf">timestrtotime_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-552"><a href="#L-552"><span class="linenos">552</span></a> <span class="k">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">sql</span><span class="p">(</span><span class="n">expression</span><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 TIMESTAMP)"</span> </span><span id="L-553"><a href="#L-553"><span class="linenos">553</span></a> -</span><span id="L-554"><a href="#L-554"><span class="linenos">554</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">this</span><span class="p">)</span> -</span><span id="L-555"><a href="#L-555"><span class="linenos">555</span></a> -</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"># Spark, DuckDB use (almost) the same naming scheme for the output columns of the PIVOT operator</span> -</span><span id="L-558"><a href="#L-558"><span class="linenos">558</span></a><span class="k">def</span> <span class="nf">pivot_column_names</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="n">dialect</span><span class="p">:</span> <span class="n">DialectType</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-559"><a href="#L-559"><span class="linenos">559</span></a> <span class="n">names</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-560"><a href="#L-560"><span class="linenos">560</span></a> <span class="k">for</span> <span class="n">agg</span> <span class="ow">in</span> <span class="n">aggregations</span><span class="p">:</span> -</span><span id="L-561"><a href="#L-561"><span class="linenos">561</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">agg</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">):</span> -</span><span id="L-562"><a href="#L-562"><span class="linenos">562</span></a> <span class="n">names</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">agg</span><span class="o">.</span><span class="n">alias</span><span class="p">)</span> -</span><span id="L-563"><a href="#L-563"><span class="linenos">563</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-564"><a href="#L-564"><span class="linenos">564</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-565"><a href="#L-565"><span class="linenos">565</span></a><span class="sd"> This case corresponds to aggregations without aliases being used as suffixes</span> -</span><span id="L-566"><a href="#L-566"><span class="linenos">566</span></a><span class="sd"> (e.g. col_avg(foo)). We need to unquote identifiers because they're going to</span> -</span><span id="L-567"><a href="#L-567"><span class="linenos">567</span></a><span class="sd"> be quoted in the base parser's `_parse_pivot` method, due to `to_identifier`.</span> -</span><span id="L-568"><a href="#L-568"><span class="linenos">568</span></a><span class="sd"> Otherwise, we'd end up with `col_avg(`foo`)` (notice the double quotes).</span> -</span><span id="L-569"><a href="#L-569"><span class="linenos">569</span></a><span class="sd"> """</span> -</span><span id="L-570"><a href="#L-570"><span class="linenos">570</span></a> <span class="n">agg_all_unquoted</span> <span class="o">=</span> <span class="n">agg</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> -</span><span id="L-571"><a href="#L-571"><span class="linenos">571</span></a> <span class="k">lambda</span> <span class="n">node</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">node</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-572"><a href="#L-572"><span class="linenos">572</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> -</span><span id="L-573"><a href="#L-573"><span class="linenos">573</span></a> <span class="k">else</span> <span class="n">node</span> -</span><span id="L-574"><a href="#L-574"><span class="linenos">574</span></a> <span class="p">)</span> -</span><span id="L-575"><a href="#L-575"><span class="linenos">575</span></a> <span class="n">names</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">agg_all_unquoted</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">normalize_functions</span><span class="o">=</span><span class="s2">"lower"</span><span class="p">))</span> -</span><span id="L-576"><a href="#L-576"><span class="linenos">576</span></a> -</span><span id="L-577"><a href="#L-577"><span class="linenos">577</span></a> <span class="k">return</span> <span class="n">names</span> +</span><span id="L-554"><a href="#L-554"><span class="linenos">554</span></a> +</span><span id="L-555"><a href="#L-555"><span class="linenos">555</span></a><span class="k">def</span> <span class="nf">datestrtodate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-556"><a href="#L-556"><span class="linenos">556</span></a> <span class="k">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">sql</span><span class="p">(</span><span class="n">expression</span><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 DATE)"</span> +</span><span id="L-557"><a href="#L-557"><span class="linenos">557</span></a> +</span><span id="L-558"><a href="#L-558"><span class="linenos">558</span></a> +</span><span id="L-559"><a href="#L-559"><span class="linenos">559</span></a><span class="k">def</span> <span class="nf">min_or_least</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-560"><a href="#L-560"><span class="linenos">560</span></a> <span class="n">name</span> <span class="o">=</span> <span class="s2">"LEAST"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">"MIN"</span> +</span><span id="L-561"><a href="#L-561"><span class="linenos">561</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="n">name</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-562"><a href="#L-562"><span class="linenos">562</span></a> +</span><span id="L-563"><a href="#L-563"><span class="linenos">563</span></a> +</span><span id="L-564"><a href="#L-564"><span class="linenos">564</span></a><span class="k">def</span> <span class="nf">max_or_greatest</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-565"><a href="#L-565"><span class="linenos">565</span></a> <span class="n">name</span> <span class="o">=</span> <span class="s2">"GREATEST"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">"MAX"</span> +</span><span id="L-566"><a href="#L-566"><span class="linenos">566</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="n">name</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-567"><a href="#L-567"><span class="linenos">567</span></a> +</span><span id="L-568"><a href="#L-568"><span class="linenos">568</span></a> +</span><span id="L-569"><a href="#L-569"><span class="linenos">569</span></a><span class="k">def</span> <span class="nf">count_if_to_sum</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CountIf</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-570"><a href="#L-570"><span class="linenos">570</span></a> <span class="n">cond</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-571"><a href="#L-571"><span class="linenos">571</span></a> +</span><span id="L-572"><a href="#L-572"><span class="linenos">572</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distinct</span><span class="p">):</span> +</span><span id="L-573"><a href="#L-573"><span class="linenos">573</span></a> <span class="n">cond</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="L-574"><a href="#L-574"><span class="linenos">574</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"DISTINCT is not supported when converting COUNT_IF to SUM"</span><span class="p">)</span> +</span><span id="L-575"><a href="#L-575"><span class="linenos">575</span></a> +</span><span id="L-576"><a href="#L-576"><span class="linenos">576</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"sum"</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">"if"</span><span class="p">,</span> <span class="n">cond</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span> +</span><span id="L-577"><a href="#L-577"><span class="linenos">577</span></a> +</span><span id="L-578"><a href="#L-578"><span class="linenos">578</span></a> +</span><span id="L-579"><a href="#L-579"><span class="linenos">579</span></a><span class="k">def</span> <span class="nf">trim_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-580"><a href="#L-580"><span class="linenos">580</span></a> <span class="n">target</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-581"><a href="#L-581"><span class="linenos">581</span></a> <span class="n">trim_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> +</span><span id="L-582"><a href="#L-582"><span class="linenos">582</span></a> <span class="n">remove_chars</span> <span class="o">=</span> <span class="bp">self</span><span 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-583"><a href="#L-583"><span class="linenos">583</span></a> <span class="n">collation</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collation"</span><span class="p">)</span> +</span><span id="L-584"><a href="#L-584"><span class="linenos">584</span></a> +</span><span id="L-585"><a href="#L-585"><span class="linenos">585</span></a> <span class="c1"># Use TRIM/LTRIM/RTRIM syntax if the expression isn't database-specific</span> +</span><span id="L-586"><a href="#L-586"><span class="linenos">586</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">remove_chars</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">collation</span><span class="p">:</span> +</span><span id="L-587"><a href="#L-587"><span class="linenos">587</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">trim_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-588"><a href="#L-588"><span class="linenos">588</span></a> +</span><span id="L-589"><a href="#L-589"><span class="linenos">589</span></a> <span class="n">trim_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">trim_type</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">trim_type</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-590"><a href="#L-590"><span class="linenos">590</span></a> <span class="n">remove_chars</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">remove_chars</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">remove_chars</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-591"><a href="#L-591"><span class="linenos">591</span></a> <span class="n">from_part</span> <span class="o">=</span> <span class="s2">"FROM "</span> <span class="k">if</span> <span class="n">trim_type</span> <span class="ow">or</span> <span class="n">remove_chars</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-592"><a href="#L-592"><span class="linenos">592</span></a> <span class="n">collation</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collation</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collation</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-593"><a href="#L-593"><span class="linenos">593</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TRIM(</span><span class="si">{</span><span class="n">trim_type</span><span class="si">}{</span><span class="n">remove_chars</span><span class="si">}{</span><span class="n">from_part</span><span class="si">}{</span><span class="n">target</span><span class="si">}{</span><span class="n">collation</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-594"><a href="#L-594"><span class="linenos">594</span></a> +</span><span id="L-595"><a href="#L-595"><span class="linenos">595</span></a> +</span><span id="L-596"><a href="#L-596"><span class="linenos">596</span></a><span class="k">def</span> <span class="nf">str_to_time_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-597"><a href="#L-597"><span class="linenos">597</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">"STRPTIME"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">))</span> +</span><span id="L-598"><a href="#L-598"><span class="linenos">598</span></a> +</span><span id="L-599"><a href="#L-599"><span class="linenos">599</span></a> +</span><span id="L-600"><a href="#L-600"><span class="linenos">600</span></a><span class="k">def</span> <span class="nf">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="n">dialect</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">:</span> +</span><span id="L-601"><a href="#L-601"><span class="linenos">601</span></a> <span class="k">def</span> <span class="nf">_ts_or_ds_to_date_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-602"><a href="#L-602"><span class="linenos">602</span></a> <span class="n">_dialect</span> <span class="o">=</span> <span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span> +</span><span id="L-603"><a href="#L-603"><span class="linenos">603</span></a> <span class="n">time_format</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-604"><a href="#L-604"><span class="linenos">604</span></a> <span class="k">if</span> <span class="n">time_format</span> <span class="ow">and</span> <span class="n">time_format</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span><span class="n">_dialect</span><span class="o">.</span><span class="n">TIME_FORMAT</span><span class="p">,</span> <span class="n">_dialect</span><span class="o">.</span><span class="n">DATE_FORMAT</span><span class="p">):</span> +</span><span id="L-605"><a href="#L-605"><span class="linenos">605</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-606"><a href="#L-606"><span class="linenos">606</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">sql</span><span class="p">(</span><span class="n">expression</span><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 DATE)"</span> +</span><span id="L-607"><a href="#L-607"><span class="linenos">607</span></a> +</span><span id="L-608"><a href="#L-608"><span class="linenos">608</span></a> <span class="k">return</span> <span class="n">_ts_or_ds_to_date_sql</span> +</span><span id="L-609"><a href="#L-609"><span class="linenos">609</span></a> +</span><span id="L-610"><a href="#L-610"><span class="linenos">610</span></a> +</span><span id="L-611"><a href="#L-611"><span class="linenos">611</span></a><span class="k">def</span> <span class="nf">concat_to_dpipe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-612"><a href="#L-612"><span class="linenos">612</span></a> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest_args</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="L-613"><a href="#L-613"><span class="linenos">613</span></a> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">rest_args</span><span class="p">:</span> +</span><span id="L-614"><a href="#L-614"><span class="linenos">614</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DPipe</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">arg</span><span class="p">)</span> +</span><span id="L-615"><a href="#L-615"><span class="linenos">615</span></a> +</span><span id="L-616"><a href="#L-616"><span class="linenos">616</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-617"><a href="#L-617"><span class="linenos">617</span></a> +</span><span id="L-618"><a href="#L-618"><span class="linenos">618</span></a> +</span><span id="L-619"><a href="#L-619"><span class="linenos">619</span></a><span class="c1"># Spark, DuckDB use (almost) the same naming scheme for the output columns of the PIVOT operator</span> +</span><span id="L-620"><a href="#L-620"><span class="linenos">620</span></a><span class="k">def</span> <span class="nf">pivot_column_names</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="n">dialect</span><span class="p">:</span> <span class="n">DialectType</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-621"><a href="#L-621"><span class="linenos">621</span></a> <span class="n">names</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-622"><a href="#L-622"><span class="linenos">622</span></a> <span class="k">for</span> <span class="n">agg</span> <span class="ow">in</span> <span class="n">aggregations</span><span class="p">:</span> +</span><span id="L-623"><a href="#L-623"><span class="linenos">623</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">agg</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">):</span> +</span><span id="L-624"><a href="#L-624"><span class="linenos">624</span></a> <span class="n">names</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">agg</span><span class="o">.</span><span class="n">alias</span><span class="p">)</span> +</span><span id="L-625"><a href="#L-625"><span class="linenos">625</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-626"><a href="#L-626"><span class="linenos">626</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-627"><a href="#L-627"><span class="linenos">627</span></a><span class="sd"> This case corresponds to aggregations without aliases being used as suffixes</span> +</span><span id="L-628"><a href="#L-628"><span class="linenos">628</span></a><span class="sd"> (e.g. col_avg(foo)). We need to unquote identifiers because they're going to</span> +</span><span id="L-629"><a href="#L-629"><span class="linenos">629</span></a><span class="sd"> be quoted in the base parser's `_parse_pivot` method, due to `to_identifier`.</span> +</span><span id="L-630"><a href="#L-630"><span class="linenos">630</span></a><span class="sd"> Otherwise, we'd end up with `col_avg(`foo`)` (notice the double quotes).</span> +</span><span id="L-631"><a href="#L-631"><span class="linenos">631</span></a><span class="sd"> """</span> +</span><span id="L-632"><a href="#L-632"><span class="linenos">632</span></a> <span class="n">agg_all_unquoted</span> <span class="o">=</span> <span class="n">agg</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> +</span><span id="L-633"><a href="#L-633"><span class="linenos">633</span></a> <span class="k">lambda</span> <span class="n">node</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">node</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-634"><a href="#L-634"><span class="linenos">634</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> +</span><span id="L-635"><a href="#L-635"><span class="linenos">635</span></a> <span class="k">else</span> <span class="n">node</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 class="n">names</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">agg_all_unquoted</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">normalize_functions</span><span class="o">=</span><span class="s2">"lower"</span><span class="p">))</span> +</span><span id="L-638"><a href="#L-638"><span class="linenos">638</span></a> +</span><span id="L-639"><a href="#L-639"><span class="linenos">639</span></a> <span class="k">return</span> <span class="n">names</span> </span></pre></div> @@ -861,29 +935,29 @@ </div> <a class="headerlink" href="#Dialects"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Dialects-24"><a href="#Dialects-24"><span class="linenos">24</span></a><span class="k">class</span> <span class="nc">Dialects</span><span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="n">Enum</span><span class="p">):</span> -</span><span id="Dialects-25"><a href="#Dialects-25"><span class="linenos">25</span></a> <span class="n">DIALECT</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Dialects-26"><a href="#Dialects-26"><span class="linenos">26</span></a> -</span><span id="Dialects-27"><a href="#Dialects-27"><span class="linenos">27</span></a> <span class="n">BIGQUERY</span> <span class="o">=</span> <span class="s2">"bigquery"</span> -</span><span id="Dialects-28"><a href="#Dialects-28"><span class="linenos">28</span></a> <span class="n">CLICKHOUSE</span> <span class="o">=</span> <span class="s2">"clickhouse"</span> -</span><span id="Dialects-29"><a href="#Dialects-29"><span class="linenos">29</span></a> <span class="n">DATABRICKS</span> <span class="o">=</span> <span class="s2">"databricks"</span> -</span><span id="Dialects-30"><a href="#Dialects-30"><span class="linenos">30</span></a> <span class="n">DRILL</span> <span class="o">=</span> <span class="s2">"drill"</span> -</span><span id="Dialects-31"><a href="#Dialects-31"><span class="linenos">31</span></a> <span class="n">DUCKDB</span> <span class="o">=</span> <span class="s2">"duckdb"</span> -</span><span id="Dialects-32"><a href="#Dialects-32"><span class="linenos">32</span></a> <span class="n">HIVE</span> <span class="o">=</span> <span class="s2">"hive"</span> -</span><span id="Dialects-33"><a href="#Dialects-33"><span class="linenos">33</span></a> <span class="n">MYSQL</span> <span class="o">=</span> <span class="s2">"mysql"</span> -</span><span id="Dialects-34"><a href="#Dialects-34"><span class="linenos">34</span></a> <span class="n">ORACLE</span> <span class="o">=</span> <span class="s2">"oracle"</span> -</span><span id="Dialects-35"><a href="#Dialects-35"><span class="linenos">35</span></a> <span class="n">POSTGRES</span> <span class="o">=</span> <span class="s2">"postgres"</span> -</span><span id="Dialects-36"><a href="#Dialects-36"><span class="linenos">36</span></a> <span class="n">PRESTO</span> <span class="o">=</span> <span class="s2">"presto"</span> -</span><span id="Dialects-37"><a href="#Dialects-37"><span class="linenos">37</span></a> <span class="n">REDSHIFT</span> <span class="o">=</span> <span class="s2">"redshift"</span> -</span><span id="Dialects-38"><a href="#Dialects-38"><span class="linenos">38</span></a> <span class="n">SNOWFLAKE</span> <span class="o">=</span> <span class="s2">"snowflake"</span> -</span><span id="Dialects-39"><a href="#Dialects-39"><span class="linenos">39</span></a> <span class="n">SPARK</span> <span class="o">=</span> <span class="s2">"spark"</span> -</span><span id="Dialects-40"><a href="#Dialects-40"><span class="linenos">40</span></a> <span class="n">SPARK2</span> <span class="o">=</span> <span class="s2">"spark2"</span> -</span><span id="Dialects-41"><a href="#Dialects-41"><span class="linenos">41</span></a> <span class="n">SQLITE</span> <span class="o">=</span> <span class="s2">"sqlite"</span> -</span><span id="Dialects-42"><a href="#Dialects-42"><span class="linenos">42</span></a> <span class="n">STARROCKS</span> <span class="o">=</span> <span class="s2">"starrocks"</span> -</span><span id="Dialects-43"><a href="#Dialects-43"><span class="linenos">43</span></a> <span class="n">TABLEAU</span> <span class="o">=</span> <span class="s2">"tableau"</span> -</span><span id="Dialects-44"><a href="#Dialects-44"><span class="linenos">44</span></a> <span class="n">TERADATA</span> <span class="o">=</span> <span class="s2">"teradata"</span> -</span><span id="Dialects-45"><a href="#Dialects-45"><span class="linenos">45</span></a> <span class="n">TRINO</span> <span class="o">=</span> <span class="s2">"trino"</span> -</span><span id="Dialects-46"><a href="#Dialects-46"><span class="linenos">46</span></a> <span class="n">TSQL</span> <span class="o">=</span> <span class="s2">"tsql"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Dialects-17"><a href="#Dialects-17"><span class="linenos">17</span></a><span class="k">class</span> <span class="nc">Dialects</span><span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="n">Enum</span><span class="p">):</span> +</span><span id="Dialects-18"><a href="#Dialects-18"><span class="linenos">18</span></a> <span class="n">DIALECT</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Dialects-19"><a href="#Dialects-19"><span class="linenos">19</span></a> +</span><span id="Dialects-20"><a href="#Dialects-20"><span class="linenos">20</span></a> <span class="n">BIGQUERY</span> <span class="o">=</span> <span class="s2">"bigquery"</span> +</span><span id="Dialects-21"><a href="#Dialects-21"><span class="linenos">21</span></a> <span class="n">CLICKHOUSE</span> <span class="o">=</span> <span class="s2">"clickhouse"</span> +</span><span id="Dialects-22"><a href="#Dialects-22"><span class="linenos">22</span></a> <span class="n">DATABRICKS</span> <span class="o">=</span> <span class="s2">"databricks"</span> +</span><span id="Dialects-23"><a href="#Dialects-23"><span class="linenos">23</span></a> <span class="n">DRILL</span> <span class="o">=</span> <span class="s2">"drill"</span> +</span><span id="Dialects-24"><a href="#Dialects-24"><span class="linenos">24</span></a> <span class="n">DUCKDB</span> <span class="o">=</span> <span class="s2">"duckdb"</span> +</span><span id="Dialects-25"><a href="#Dialects-25"><span class="linenos">25</span></a> <span class="n">HIVE</span> <span class="o">=</span> <span class="s2">"hive"</span> +</span><span id="Dialects-26"><a href="#Dialects-26"><span class="linenos">26</span></a> <span class="n">MYSQL</span> <span class="o">=</span> <span class="s2">"mysql"</span> +</span><span id="Dialects-27"><a href="#Dialects-27"><span class="linenos">27</span></a> <span class="n">ORACLE</span> <span class="o">=</span> <span class="s2">"oracle"</span> +</span><span id="Dialects-28"><a href="#Dialects-28"><span class="linenos">28</span></a> <span class="n">POSTGRES</span> <span class="o">=</span> <span class="s2">"postgres"</span> +</span><span id="Dialects-29"><a href="#Dialects-29"><span class="linenos">29</span></a> <span class="n">PRESTO</span> <span class="o">=</span> <span class="s2">"presto"</span> +</span><span id="Dialects-30"><a href="#Dialects-30"><span class="linenos">30</span></a> <span class="n">REDSHIFT</span> <span class="o">=</span> <span class="s2">"redshift"</span> +</span><span id="Dialects-31"><a href="#Dialects-31"><span class="linenos">31</span></a> <span class="n">SNOWFLAKE</span> <span class="o">=</span> <span class="s2">"snowflake"</span> +</span><span id="Dialects-32"><a href="#Dialects-32"><span class="linenos">32</span></a> <span class="n">SPARK</span> <span class="o">=</span> <span class="s2">"spark"</span> +</span><span id="Dialects-33"><a href="#Dialects-33"><span class="linenos">33</span></a> <span class="n">SPARK2</span> <span class="o">=</span> <span class="s2">"spark2"</span> +</span><span id="Dialects-34"><a href="#Dialects-34"><span class="linenos">34</span></a> <span class="n">SQLITE</span> <span class="o">=</span> <span class="s2">"sqlite"</span> +</span><span id="Dialects-35"><a href="#Dialects-35"><span class="linenos">35</span></a> <span class="n">STARROCKS</span> <span class="o">=</span> <span class="s2">"starrocks"</span> +</span><span id="Dialects-36"><a href="#Dialects-36"><span class="linenos">36</span></a> <span class="n">TABLEAU</span> <span class="o">=</span> <span class="s2">"tableau"</span> +</span><span id="Dialects-37"><a href="#Dialects-37"><span class="linenos">37</span></a> <span class="n">TERADATA</span> <span class="o">=</span> <span class="s2">"teradata"</span> +</span><span id="Dialects-38"><a href="#Dialects-38"><span class="linenos">38</span></a> <span class="n">TRINO</span> <span class="o">=</span> <span class="s2">"trino"</span> +</span><span id="Dialects-39"><a href="#Dialects-39"><span class="linenos">39</span></a> <span class="n">TSQL</span> <span class="o">=</span> <span class="s2">"tsql"</span> </span></pre></div> @@ -1215,118 +1289,182 @@ </div> <a class="headerlink" href="#Dialect"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect-133"><a href="#Dialect-133"><span class="linenos">133</span></a><span class="k">class</span> <span class="nc">Dialect</span><span class="p">(</span><span class="n">metaclass</span><span class="o">=</span><span class="n">_Dialect</span><span class="p">):</span> -</span><span id="Dialect-134"><a href="#Dialect-134"><span class="linenos">134</span></a> <span class="c1"># Determines the base index offset for arrays</span> -</span><span id="Dialect-135"><a href="#Dialect-135"><span class="linenos">135</span></a> <span class="n">INDEX_OFFSET</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="Dialect-136"><a href="#Dialect-136"><span class="linenos">136</span></a> -</span><span id="Dialect-137"><a href="#Dialect-137"><span class="linenos">137</span></a> <span class="c1"># If true unnest table aliases are considered only as column aliases</span> -</span><span id="Dialect-138"><a href="#Dialect-138"><span class="linenos">138</span></a> <span class="n">UNNEST_COLUMN_ONLY</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Dialect-139"><a href="#Dialect-139"><span class="linenos">139</span></a> -</span><span id="Dialect-140"><a href="#Dialect-140"><span class="linenos">140</span></a> <span class="c1"># Determines whether or not the table alias comes after tablesample</span> -</span><span id="Dialect-141"><a href="#Dialect-141"><span class="linenos">141</span></a> <span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Dialect-142"><a href="#Dialect-142"><span class="linenos">142</span></a> -</span><span id="Dialect-143"><a href="#Dialect-143"><span class="linenos">143</span></a> <span class="c1"># Determines whether or not an unquoted identifier can start with a digit</span> -</span><span id="Dialect-144"><a href="#Dialect-144"><span class="linenos">144</span></a> <span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Dialect-145"><a href="#Dialect-145"><span class="linenos">145</span></a> -</span><span id="Dialect-146"><a href="#Dialect-146"><span class="linenos">146</span></a> <span class="c1"># Determines whether or not CONCAT's arguments must be strings</span> -</span><span id="Dialect-147"><a href="#Dialect-147"><span class="linenos">147</span></a> <span class="n">STRICT_STRING_CONCAT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Dialect-148"><a href="#Dialect-148"><span class="linenos">148</span></a> -</span><span id="Dialect-149"><a href="#Dialect-149"><span class="linenos">149</span></a> <span class="c1"># Determines how function names are going to be normalized</span> -</span><span id="Dialect-150"><a href="#Dialect-150"><span class="linenos">150</span></a> <span class="n">NORMALIZE_FUNCTIONS</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">|</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"upper"</span> -</span><span id="Dialect-151"><a href="#Dialect-151"><span class="linenos">151</span></a> -</span><span id="Dialect-152"><a href="#Dialect-152"><span class="linenos">152</span></a> <span class="c1"># Indicates the default null ordering method to use if not explicitly set</span> -</span><span id="Dialect-153"><a href="#Dialect-153"><span class="linenos">153</span></a> <span class="c1"># Options are: "nulls_are_small", "nulls_are_large", "nulls_are_last"</span> -</span><span id="Dialect-154"><a href="#Dialect-154"><span class="linenos">154</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_small"</span> -</span><span id="Dialect-155"><a href="#Dialect-155"><span class="linenos">155</span></a> -</span><span id="Dialect-156"><a href="#Dialect-156"><span class="linenos">156</span></a> <span class="n">DATE_FORMAT</span> <span class="o">=</span> <span class="s2">"'%Y-%m-</span><span class="si">%d</span><span class="s2">'"</span> -</span><span id="Dialect-157"><a href="#Dialect-157"><span class="linenos">157</span></a> <span class="n">DATEINT_FORMAT</span> <span class="o">=</span> <span class="s2">"'%Y%m</span><span class="si">%d</span><span class="s2">'"</span> -</span><span id="Dialect-158"><a href="#Dialect-158"><span class="linenos">158</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">"'%Y-%m-</span><span class="si">%d</span><span class="s2"> %H:%M:%S'"</span> -</span><span id="Dialect-159"><a href="#Dialect-159"><span class="linenos">159</span></a> -</span><span id="Dialect-160"><a href="#Dialect-160"><span class="linenos">160</span></a> <span class="c1"># Custom time mappings in which the key represents dialect time format</span> -</span><span id="Dialect-161"><a href="#Dialect-161"><span class="linenos">161</span></a> <span class="c1"># and the value represents a python time format</span> -</span><span id="Dialect-162"><a href="#Dialect-162"><span class="linenos">162</span></a> <span class="n">TIME_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Dialect-163"><a href="#Dialect-163"><span class="linenos">163</span></a> -</span><span id="Dialect-164"><a href="#Dialect-164"><span class="linenos">164</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_model_rules_date_time</span> -</span><span id="Dialect-165"><a href="#Dialect-165"><span class="linenos">165</span></a> <span class="c1"># https://docs.teradata.com/r/Teradata-Database-SQL-Functions-Operators-Expressions-and-Predicates/March-2017/Data-Type-Conversions/Character-to-DATE-Conversion/Forcing-a-FORMAT-on-CAST-for-Converting-Character-to-DATE</span> -</span><span id="Dialect-166"><a href="#Dialect-166"><span class="linenos">166</span></a> <span class="c1"># special syntax cast(x as date format 'yyyy') defaults to time_mapping</span> -</span><span id="Dialect-167"><a href="#Dialect-167"><span class="linenos">167</span></a> <span class="n">FORMAT_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Dialect-168"><a href="#Dialect-168"><span class="linenos">168</span></a> -</span><span id="Dialect-169"><a href="#Dialect-169"><span class="linenos">169</span></a> <span class="c1"># Autofilled</span> -</span><span id="Dialect-170"><a href="#Dialect-170"><span class="linenos">170</span></a> <span class="n">tokenizer_class</span> <span class="o">=</span> <span class="n">Tokenizer</span> -</span><span id="Dialect-171"><a href="#Dialect-171"><span class="linenos">171</span></a> <span class="n">parser_class</span> <span class="o">=</span> <span class="n">Parser</span> -</span><span id="Dialect-172"><a href="#Dialect-172"><span class="linenos">172</span></a> <span class="n">generator_class</span> <span class="o">=</span> <span class="n">Generator</span> -</span><span id="Dialect-173"><a href="#Dialect-173"><span class="linenos">173</span></a> -</span><span id="Dialect-174"><a href="#Dialect-174"><span class="linenos">174</span></a> <span class="c1"># A trie of the time_mapping keys</span> -</span><span id="Dialect-175"><a href="#Dialect-175"><span class="linenos">175</span></a> <span class="n">TIME_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Dialect-176"><a href="#Dialect-176"><span class="linenos">176</span></a> <span class="n">FORMAT_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Dialect-177"><a href="#Dialect-177"><span class="linenos">177</span></a> -</span><span id="Dialect-178"><a href="#Dialect-178"><span class="linenos">178</span></a> <span class="n">INVERSE_TIME_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Dialect-179"><a href="#Dialect-179"><span class="linenos">179</span></a> <span class="n">INVERSE_TIME_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Dialect-180"><a href="#Dialect-180"><span class="linenos">180</span></a> -</span><span id="Dialect-181"><a href="#Dialect-181"><span class="linenos">181</span></a> <span class="k">def</span> <span class="fm">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="Dialect-182"><a href="#Dialect-182"><span class="linenos">182</span></a> <span class="k">return</span> <span class="nb">type</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">==</span> <span class="n">other</span> -</span><span id="Dialect-183"><a href="#Dialect-183"><span class="linenos">183</span></a> -</span><span id="Dialect-184"><a href="#Dialect-184"><span class="linenos">184</span></a> <span class="k">def</span> <span class="fm">__hash__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> -</span><span id="Dialect-185"><a href="#Dialect-185"><span class="linenos">185</span></a> <span class="k">return</span> <span class="nb">hash</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span> -</span><span id="Dialect-186"><a href="#Dialect-186"><span class="linenos">186</span></a> -</span><span id="Dialect-187"><a href="#Dialect-187"><span class="linenos">187</span></a> <span class="nd">@classmethod</span> -</span><span id="Dialect-188"><a href="#Dialect-188"><span class="linenos">188</span></a> <span class="k">def</span> <span class="nf">get_or_raise</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Dialect</span><span class="p">]:</span> -</span><span id="Dialect-189"><a href="#Dialect-189"><span class="linenos">189</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">dialect</span><span class="p">:</span> -</span><span id="Dialect-190"><a href="#Dialect-190"><span class="linenos">190</span></a> <span class="k">return</span> <span class="bp">cls</span> -</span><span id="Dialect-191"><a href="#Dialect-191"><span class="linenos">191</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dialect</span><span class="p">,</span> <span class="n">_Dialect</span><span class="p">):</span> -</span><span id="Dialect-192"><a href="#Dialect-192"><span class="linenos">192</span></a> <span class="k">return</span> <span class="n">dialect</span> -</span><span id="Dialect-193"><a href="#Dialect-193"><span class="linenos">193</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dialect</span><span class="p">,</span> <span class="n">Dialect</span><span class="p">):</span> -</span><span id="Dialect-194"><a href="#Dialect-194"><span class="linenos">194</span></a> <span class="k">return</span> <span class="n">dialect</span><span class="o">.</span><span class="vm">__class__</span> -</span><span id="Dialect-195"><a href="#Dialect-195"><span class="linenos">195</span></a> -</span><span id="Dialect-196"><a href="#Dialect-196"><span class="linenos">196</span></a> <span class="n">result</span> <span class="o">=</span> <span class="bp">cls</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span> -</span><span id="Dialect-197"><a href="#Dialect-197"><span class="linenos">197</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">result</span><span class="p">:</span> -</span><span id="Dialect-198"><a href="#Dialect-198"><span class="linenos">198</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unknown dialect '</span><span class="si">{</span><span class="n">dialect</span><span class="si">}</span><span class="s2">'"</span><span class="p">)</span> -</span><span id="Dialect-199"><a href="#Dialect-199"><span class="linenos">199</span></a> -</span><span id="Dialect-200"><a href="#Dialect-200"><span class="linenos">200</span></a> <span class="k">return</span> <span class="n">result</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect-131"><a href="#Dialect-131"><span class="linenos">131</span></a><span class="k">class</span> <span class="nc">Dialect</span><span class="p">(</span><span class="n">metaclass</span><span class="o">=</span><span class="n">_Dialect</span><span class="p">):</span> +</span><span id="Dialect-132"><a href="#Dialect-132"><span class="linenos">132</span></a> <span class="c1"># Determines the base index offset for arrays</span> +</span><span id="Dialect-133"><a href="#Dialect-133"><span class="linenos">133</span></a> <span class="n">INDEX_OFFSET</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="Dialect-134"><a href="#Dialect-134"><span class="linenos">134</span></a> +</span><span id="Dialect-135"><a href="#Dialect-135"><span class="linenos">135</span></a> <span class="c1"># If true unnest table aliases are considered only as column aliases</span> +</span><span id="Dialect-136"><a href="#Dialect-136"><span class="linenos">136</span></a> <span class="n">UNNEST_COLUMN_ONLY</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Dialect-137"><a href="#Dialect-137"><span class="linenos">137</span></a> +</span><span id="Dialect-138"><a href="#Dialect-138"><span class="linenos">138</span></a> <span class="c1"># Determines whether or not the table alias comes after tablesample</span> +</span><span id="Dialect-139"><a href="#Dialect-139"><span class="linenos">139</span></a> <span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Dialect-140"><a href="#Dialect-140"><span class="linenos">140</span></a> +</span><span id="Dialect-141"><a href="#Dialect-141"><span class="linenos">141</span></a> <span class="c1"># Determines whether or not unquoted identifiers are resolved as uppercase</span> +</span><span id="Dialect-142"><a href="#Dialect-142"><span class="linenos">142</span></a> <span class="c1"># When set to None, it means that the dialect treats all identifiers as case-insensitive</span> +</span><span id="Dialect-143"><a href="#Dialect-143"><span class="linenos">143</span></a> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Dialect-144"><a href="#Dialect-144"><span class="linenos">144</span></a> +</span><span id="Dialect-145"><a href="#Dialect-145"><span class="linenos">145</span></a> <span class="c1"># Determines whether or not an unquoted identifier can start with a digit</span> +</span><span id="Dialect-146"><a href="#Dialect-146"><span class="linenos">146</span></a> <span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Dialect-147"><a href="#Dialect-147"><span class="linenos">147</span></a> +</span><span id="Dialect-148"><a href="#Dialect-148"><span class="linenos">148</span></a> <span class="c1"># Determines whether or not CONCAT's arguments must be strings</span> +</span><span id="Dialect-149"><a href="#Dialect-149"><span class="linenos">149</span></a> <span class="n">STRICT_STRING_CONCAT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Dialect-150"><a href="#Dialect-150"><span class="linenos">150</span></a> +</span><span id="Dialect-151"><a href="#Dialect-151"><span class="linenos">151</span></a> <span class="c1"># Determines how function names are going to be normalized</span> +</span><span id="Dialect-152"><a href="#Dialect-152"><span class="linenos">152</span></a> <span class="n">NORMALIZE_FUNCTIONS</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">|</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"upper"</span> +</span><span id="Dialect-153"><a href="#Dialect-153"><span class="linenos">153</span></a> +</span><span id="Dialect-154"><a href="#Dialect-154"><span class="linenos">154</span></a> <span class="c1"># Indicates the default null ordering method to use if not explicitly set</span> +</span><span id="Dialect-155"><a href="#Dialect-155"><span class="linenos">155</span></a> <span class="c1"># Options are: "nulls_are_small", "nulls_are_large", "nulls_are_last"</span> +</span><span id="Dialect-156"><a href="#Dialect-156"><span class="linenos">156</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_small"</span> +</span><span id="Dialect-157"><a href="#Dialect-157"><span class="linenos">157</span></a> +</span><span id="Dialect-158"><a href="#Dialect-158"><span class="linenos">158</span></a> <span class="n">DATE_FORMAT</span> <span class="o">=</span> <span class="s2">"'%Y-%m-</span><span class="si">%d</span><span class="s2">'"</span> +</span><span id="Dialect-159"><a href="#Dialect-159"><span class="linenos">159</span></a> <span class="n">DATEINT_FORMAT</span> <span class="o">=</span> <span class="s2">"'%Y%m</span><span class="si">%d</span><span class="s2">'"</span> +</span><span id="Dialect-160"><a href="#Dialect-160"><span class="linenos">160</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">"'%Y-%m-</span><span class="si">%d</span><span class="s2"> %H:%M:%S'"</span> +</span><span id="Dialect-161"><a href="#Dialect-161"><span class="linenos">161</span></a> +</span><span id="Dialect-162"><a href="#Dialect-162"><span class="linenos">162</span></a> <span class="c1"># Custom time mappings in which the key represents dialect time format</span> +</span><span id="Dialect-163"><a href="#Dialect-163"><span class="linenos">163</span></a> <span class="c1"># and the value represents a python time format</span> +</span><span id="Dialect-164"><a href="#Dialect-164"><span class="linenos">164</span></a> <span class="n">TIME_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Dialect-165"><a href="#Dialect-165"><span class="linenos">165</span></a> +</span><span id="Dialect-166"><a href="#Dialect-166"><span class="linenos">166</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_model_rules_date_time</span> +</span><span id="Dialect-167"><a href="#Dialect-167"><span class="linenos">167</span></a> <span class="c1"># https://docs.teradata.com/r/Teradata-Database-SQL-Functions-Operators-Expressions-and-Predicates/March-2017/Data-Type-Conversions/Character-to-DATE-Conversion/Forcing-a-FORMAT-on-CAST-for-Converting-Character-to-DATE</span> +</span><span id="Dialect-168"><a href="#Dialect-168"><span class="linenos">168</span></a> <span class="c1"># special syntax cast(x as date format 'yyyy') defaults to time_mapping</span> +</span><span id="Dialect-169"><a href="#Dialect-169"><span class="linenos">169</span></a> <span class="n">FORMAT_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Dialect-170"><a href="#Dialect-170"><span class="linenos">170</span></a> +</span><span id="Dialect-171"><a href="#Dialect-171"><span class="linenos">171</span></a> <span class="c1"># Autofilled</span> +</span><span id="Dialect-172"><a href="#Dialect-172"><span class="linenos">172</span></a> <span class="n">tokenizer_class</span> <span class="o">=</span> <span class="n">Tokenizer</span> +</span><span id="Dialect-173"><a href="#Dialect-173"><span class="linenos">173</span></a> <span class="n">parser_class</span> <span class="o">=</span> <span class="n">Parser</span> +</span><span id="Dialect-174"><a href="#Dialect-174"><span class="linenos">174</span></a> <span class="n">generator_class</span> <span class="o">=</span> <span class="n">Generator</span> +</span><span id="Dialect-175"><a href="#Dialect-175"><span class="linenos">175</span></a> +</span><span id="Dialect-176"><a href="#Dialect-176"><span class="linenos">176</span></a> <span class="c1"># A trie of the time_mapping keys</span> +</span><span id="Dialect-177"><a href="#Dialect-177"><span class="linenos">177</span></a> <span class="n">TIME_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Dialect-178"><a href="#Dialect-178"><span class="linenos">178</span></a> <span class="n">FORMAT_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Dialect-179"><a href="#Dialect-179"><span class="linenos">179</span></a> +</span><span id="Dialect-180"><a href="#Dialect-180"><span class="linenos">180</span></a> <span class="n">INVERSE_TIME_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Dialect-181"><a href="#Dialect-181"><span class="linenos">181</span></a> <span class="n">INVERSE_TIME_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Dialect-182"><a href="#Dialect-182"><span class="linenos">182</span></a> +</span><span id="Dialect-183"><a href="#Dialect-183"><span class="linenos">183</span></a> <span class="k">def</span> <span class="fm">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Dialect-184"><a href="#Dialect-184"><span class="linenos">184</span></a> <span class="k">return</span> <span class="nb">type</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">==</span> <span class="n">other</span> +</span><span id="Dialect-185"><a href="#Dialect-185"><span class="linenos">185</span></a> +</span><span id="Dialect-186"><a href="#Dialect-186"><span class="linenos">186</span></a> <span class="k">def</span> <span class="fm">__hash__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> +</span><span id="Dialect-187"><a href="#Dialect-187"><span class="linenos">187</span></a> <span class="k">return</span> <span class="nb">hash</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span> +</span><span id="Dialect-188"><a href="#Dialect-188"><span class="linenos">188</span></a> +</span><span id="Dialect-189"><a href="#Dialect-189"><span class="linenos">189</span></a> <span class="nd">@classmethod</span> +</span><span id="Dialect-190"><a href="#Dialect-190"><span class="linenos">190</span></a> <span class="k">def</span> <span class="nf">get_or_raise</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Dialect</span><span class="p">]:</span> +</span><span id="Dialect-191"><a href="#Dialect-191"><span class="linenos">191</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">dialect</span><span class="p">:</span> +</span><span id="Dialect-192"><a href="#Dialect-192"><span class="linenos">192</span></a> <span class="k">return</span> <span class="bp">cls</span> +</span><span id="Dialect-193"><a href="#Dialect-193"><span class="linenos">193</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dialect</span><span class="p">,</span> <span class="n">_Dialect</span><span class="p">):</span> +</span><span id="Dialect-194"><a href="#Dialect-194"><span class="linenos">194</span></a> <span class="k">return</span> <span class="n">dialect</span> +</span><span id="Dialect-195"><a href="#Dialect-195"><span class="linenos">195</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dialect</span><span class="p">,</span> <span class="n">Dialect</span><span class="p">):</span> +</span><span id="Dialect-196"><a href="#Dialect-196"><span class="linenos">196</span></a> <span class="k">return</span> <span class="n">dialect</span><span class="o">.</span><span class="vm">__class__</span> +</span><span id="Dialect-197"><a href="#Dialect-197"><span class="linenos">197</span></a> +</span><span id="Dialect-198"><a href="#Dialect-198"><span class="linenos">198</span></a> <span class="n">result</span> <span class="o">=</span> <span class="bp">cls</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span> +</span><span id="Dialect-199"><a href="#Dialect-199"><span class="linenos">199</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">result</span><span class="p">:</span> +</span><span id="Dialect-200"><a href="#Dialect-200"><span class="linenos">200</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unknown dialect '</span><span class="si">{</span><span class="n">dialect</span><span class="si">}</span><span class="s2">'"</span><span class="p">)</span> </span><span id="Dialect-201"><a href="#Dialect-201"><span class="linenos">201</span></a> -</span><span id="Dialect-202"><a href="#Dialect-202"><span class="linenos">202</span></a> <span class="nd">@classmethod</span> -</span><span id="Dialect-203"><a href="#Dialect-203"><span class="linenos">203</span></a> <span class="k">def</span> <span class="nf">format_time</span><span class="p">(</span> -</span><span id="Dialect-204"><a href="#Dialect-204"><span class="linenos">204</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> -</span><span id="Dialect-205"><a href="#Dialect-205"><span class="linenos">205</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="Dialect-206"><a href="#Dialect-206"><span class="linenos">206</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="Dialect-207"><a href="#Dialect-207"><span class="linenos">207</span></a> <span class="k">return</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><span id="Dialect-208"><a href="#Dialect-208"><span class="linenos">208</span></a> <span class="c1"># the time formats are quoted</span> -</span><span id="Dialect-209"><a href="#Dialect-209"><span class="linenos">209</span></a> <span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">[</span><span class="mi">1</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_TRIE</span><span class="p">)</span> -</span><span id="Dialect-210"><a href="#Dialect-210"><span class="linenos">210</span></a> <span class="p">)</span> -</span><span id="Dialect-211"><a href="#Dialect-211"><span class="linenos">211</span></a> -</span><span id="Dialect-212"><a href="#Dialect-212"><span class="linenos">212</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> -</span><span id="Dialect-213"><a href="#Dialect-213"><span class="linenos">213</span></a> <span class="k">return</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">format_time</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_TRIE</span><span class="p">))</span> -</span><span id="Dialect-214"><a href="#Dialect-214"><span class="linenos">214</span></a> -</span><span id="Dialect-215"><a href="#Dialect-215"><span class="linenos">215</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="Dialect-202"><a href="#Dialect-202"><span class="linenos">202</span></a> <span class="k">return</span> <span class="n">result</span> +</span><span id="Dialect-203"><a href="#Dialect-203"><span class="linenos">203</span></a> +</span><span id="Dialect-204"><a href="#Dialect-204"><span class="linenos">204</span></a> <span class="nd">@classmethod</span> +</span><span id="Dialect-205"><a href="#Dialect-205"><span class="linenos">205</span></a> <span class="k">def</span> <span class="nf">format_time</span><span class="p">(</span> +</span><span id="Dialect-206"><a href="#Dialect-206"><span class="linenos">206</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> +</span><span id="Dialect-207"><a href="#Dialect-207"><span class="linenos">207</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="Dialect-208"><a href="#Dialect-208"><span class="linenos">208</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="Dialect-209"><a href="#Dialect-209"><span class="linenos">209</span></a> <span class="k">return</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><span id="Dialect-210"><a href="#Dialect-210"><span class="linenos">210</span></a> <span class="c1"># the time formats are quoted</span> +</span><span id="Dialect-211"><a href="#Dialect-211"><span class="linenos">211</span></a> <span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">[</span><span class="mi">1</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_TRIE</span><span class="p">)</span> +</span><span id="Dialect-212"><a href="#Dialect-212"><span class="linenos">212</span></a> <span class="p">)</span> +</span><span id="Dialect-213"><a href="#Dialect-213"><span class="linenos">213</span></a> +</span><span id="Dialect-214"><a href="#Dialect-214"><span class="linenos">214</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> +</span><span id="Dialect-215"><a href="#Dialect-215"><span class="linenos">215</span></a> <span class="k">return</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">format_time</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_TRIE</span><span class="p">))</span> </span><span id="Dialect-216"><a href="#Dialect-216"><span class="linenos">216</span></a> -</span><span id="Dialect-217"><a href="#Dialect-217"><span class="linenos">217</span></a> <span class="k">def</span> <span class="nf">parse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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="Dialect-218"><a href="#Dialect-218"><span class="linenos">218</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">parser</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tokenize</span><span class="p">(</span><span class="n">sql</span><span class="p">),</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="Dialect-219"><a href="#Dialect-219"><span class="linenos">219</span></a> -</span><span id="Dialect-220"><a href="#Dialect-220"><span class="linenos">220</span></a> <span class="k">def</span> <span class="nf">parse_into</span><span class="p">(</span> -</span><span id="Dialect-221"><a href="#Dialect-221"><span class="linenos">221</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression_type</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IntoType</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="Dialect-222"><a href="#Dialect-222"><span class="linenos">222</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Dialect-223"><a href="#Dialect-223"><span class="linenos">223</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">parser</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">parse_into</span><span class="p">(</span><span class="n">expression_type</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokenize</span><span class="p">(</span><span class="n">sql</span><span class="p">),</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="Dialect-224"><a href="#Dialect-224"><span class="linenos">224</span></a> -</span><span id="Dialect-225"><a href="#Dialect-225"><span class="linenos">225</span></a> <span class="k">def</span> <span class="nf">generate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">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">opts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Dialect-226"><a href="#Dialect-226"><span class="linenos">226</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">generator</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Dialect-227"><a href="#Dialect-227"><span class="linenos">227</span></a> -</span><span id="Dialect-228"><a href="#Dialect-228"><span class="linenos">228</span></a> <span class="k">def</span> <span class="nf">transpile</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</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="Dialect-229"><a href="#Dialect-229"><span class="linenos">229</span></a> <span class="k">return</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">sql</span><span class="p">)]</span> -</span><span id="Dialect-230"><a href="#Dialect-230"><span class="linenos">230</span></a> -</span><span id="Dialect-231"><a href="#Dialect-231"><span class="linenos">231</span></a> <span class="k">def</span> <span class="nf">tokenize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Token</span><span class="p">]:</span> -</span><span id="Dialect-232"><a href="#Dialect-232"><span class="linenos">232</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokenizer</span><span class="o">.</span><span class="n">tokenize</span><span class="p">(</span><span class="n">sql</span><span class="p">)</span> -</span><span id="Dialect-233"><a href="#Dialect-233"><span class="linenos">233</span></a> -</span><span id="Dialect-234"><a href="#Dialect-234"><span class="linenos">234</span></a> <span class="nd">@property</span> -</span><span id="Dialect-235"><a href="#Dialect-235"><span class="linenos">235</span></a> <span class="k">def</span> <span class="nf">tokenizer</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Tokenizer</span><span class="p">:</span> -</span><span id="Dialect-236"><a href="#Dialect-236"><span class="linenos">236</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s2">"_tokenizer"</span><span class="p">):</span> -</span><span id="Dialect-237"><a href="#Dialect-237"><span class="linenos">237</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_tokenizer</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="p">()</span> -</span><span id="Dialect-238"><a href="#Dialect-238"><span class="linenos">238</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tokenizer</span> -</span><span id="Dialect-239"><a href="#Dialect-239"><span class="linenos">239</span></a> -</span><span id="Dialect-240"><a href="#Dialect-240"><span class="linenos">240</span></a> <span class="k">def</span> <span class="nf">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Parser</span><span class="p">:</span> -</span><span id="Dialect-241"><a href="#Dialect-241"><span class="linenos">241</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">parser_class</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="Dialect-242"><a href="#Dialect-242"><span class="linenos">242</span></a> -</span><span id="Dialect-243"><a href="#Dialect-243"><span class="linenos">243</span></a> <span class="k">def</span> <span class="nf">generator</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Generator</span><span class="p">:</span> -</span><span id="Dialect-244"><a href="#Dialect-244"><span class="linenos">244</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">generator_class</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="Dialect-217"><a href="#Dialect-217"><span class="linenos">217</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="Dialect-218"><a href="#Dialect-218"><span class="linenos">218</span></a> +</span><span id="Dialect-219"><a href="#Dialect-219"><span class="linenos">219</span></a> <span class="nd">@classmethod</span> +</span><span id="Dialect-220"><a href="#Dialect-220"><span class="linenos">220</span></a> <span class="k">def</span> <span class="nf">normalize_identifier</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="Dialect-221"><a href="#Dialect-221"><span class="linenos">221</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Dialect-222"><a href="#Dialect-222"><span class="linenos">222</span></a><span class="sd"> Normalizes an unquoted identifier to either lower or upper case, thus essentially</span> +</span><span id="Dialect-223"><a href="#Dialect-223"><span class="linenos">223</span></a><span class="sd"> making it case-insensitive. If a dialect treats all identifiers as case-insensitive,</span> +</span><span id="Dialect-224"><a href="#Dialect-224"><span class="linenos">224</span></a><span class="sd"> they will be normalized regardless of being quoted or not.</span> +</span><span id="Dialect-225"><a href="#Dialect-225"><span class="linenos">225</span></a><span class="sd"> """</span> +</span><span id="Dialect-226"><a href="#Dialect-226"><span class="linenos">226</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span> +</span><span id="Dialect-227"><a href="#Dialect-227"><span class="linenos">227</span></a> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> <span class="ow">or</span> <span class="bp">cls</span><span class="o">.</span><span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="ow">is</span> <span class="kc">None</span> +</span><span id="Dialect-228"><a href="#Dialect-228"><span class="linenos">228</span></a> <span class="p">):</span> +</span><span id="Dialect-229"><a href="#Dialect-229"><span class="linenos">229</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="Dialect-230"><a href="#Dialect-230"><span class="linenos">230</span></a> <span class="s2">"this"</span><span class="p">,</span> +</span><span id="Dialect-231"><a href="#Dialect-231"><span class="linenos">231</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Dialect-232"><a href="#Dialect-232"><span class="linenos">232</span></a> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> +</span><span id="Dialect-233"><a href="#Dialect-233"><span class="linenos">233</span></a> <span class="k">else</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> +</span><span id="Dialect-234"><a href="#Dialect-234"><span class="linenos">234</span></a> <span class="p">)</span> +</span><span id="Dialect-235"><a href="#Dialect-235"><span class="linenos">235</span></a> +</span><span id="Dialect-236"><a href="#Dialect-236"><span class="linenos">236</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="Dialect-237"><a href="#Dialect-237"><span class="linenos">237</span></a> +</span><span id="Dialect-238"><a href="#Dialect-238"><span class="linenos">238</span></a> <span class="nd">@classmethod</span> +</span><span id="Dialect-239"><a href="#Dialect-239"><span class="linenos">239</span></a> <span class="k">def</span> <span class="nf">case_sensitive</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Dialect-240"><a href="#Dialect-240"><span class="linenos">240</span></a><span class="w"> </span><span class="sd">"""Checks if text contains any case sensitive characters, based on the dialect's rules."""</span> +</span><span id="Dialect-241"><a href="#Dialect-241"><span class="linenos">241</span></a> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Dialect-242"><a href="#Dialect-242"><span class="linenos">242</span></a> <span class="k">return</span> <span class="kc">False</span> +</span><span id="Dialect-243"><a href="#Dialect-243"><span class="linenos">243</span></a> +</span><span id="Dialect-244"><a href="#Dialect-244"><span class="linenos">244</span></a> <span class="n">unsafe</span> <span class="o">=</span> <span class="nb">str</span><span class="o">.</span><span class="n">islower</span> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="k">else</span> <span class="nb">str</span><span class="o">.</span><span class="n">isupper</span> +</span><span id="Dialect-245"><a href="#Dialect-245"><span class="linenos">245</span></a> <span class="k">return</span> <span class="nb">any</span><span class="p">(</span><span class="n">unsafe</span><span class="p">(</span><span class="n">char</span><span class="p">)</span> <span class="k">for</span> <span class="n">char</span> <span class="ow">in</span> <span class="n">text</span><span class="p">)</span> +</span><span id="Dialect-246"><a href="#Dialect-246"><span class="linenos">246</span></a> +</span><span id="Dialect-247"><a href="#Dialect-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="Dialect-248"><a href="#Dialect-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Dialect-249"><a href="#Dialect-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="Dialect-250"><a href="#Dialect-250"><span class="linenos">250</span></a> +</span><span id="Dialect-251"><a href="#Dialect-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="Dialect-252"><a href="#Dialect-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="Dialect-253"><a href="#Dialect-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="Dialect-254"><a href="#Dialect-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="Dialect-255"><a href="#Dialect-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="Dialect-256"><a href="#Dialect-256"><span class="linenos">256</span></a> +</span><span id="Dialect-257"><a href="#Dialect-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="Dialect-258"><a href="#Dialect-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="Dialect-259"><a href="#Dialect-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="Dialect-260"><a href="#Dialect-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="Dialect-261"><a href="#Dialect-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Dialect-262"><a href="#Dialect-262"><span class="linenos">262</span></a> +</span><span id="Dialect-263"><a href="#Dialect-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="Dialect-264"><a href="#Dialect-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="Dialect-265"><a href="#Dialect-265"><span class="linenos">265</span></a> +</span><span id="Dialect-266"><a href="#Dialect-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span><span id="Dialect-267"><a href="#Dialect-267"><span class="linenos">267</span></a> +</span><span id="Dialect-268"><a href="#Dialect-268"><span class="linenos">268</span></a> <span class="nd">@classmethod</span> +</span><span id="Dialect-269"><a href="#Dialect-269"><span class="linenos">269</span></a> <span class="k">def</span> <span class="nf">quote_identifier</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="Dialect-270"><a href="#Dialect-270"><span class="linenos">270</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">):</span> +</span><span id="Dialect-271"><a href="#Dialect-271"><span class="linenos">271</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="Dialect-272"><a href="#Dialect-272"><span class="linenos">272</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="Dialect-273"><a href="#Dialect-273"><span class="linenos">273</span></a> <span class="s2">"quoted"</span><span class="p">,</span> +</span><span id="Dialect-274"><a href="#Dialect-274"><span class="linenos">274</span></a> <span class="n">identify</span> <span class="ow">or</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">exp</span><span class="o">.</span><span class="n">SAFE_IDENTIFIER_RE</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">name</span><span class="p">),</span> +</span><span id="Dialect-275"><a href="#Dialect-275"><span class="linenos">275</span></a> <span class="p">)</span> +</span><span id="Dialect-276"><a href="#Dialect-276"><span class="linenos">276</span></a> +</span><span id="Dialect-277"><a href="#Dialect-277"><span class="linenos">277</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="Dialect-278"><a href="#Dialect-278"><span class="linenos">278</span></a> +</span><span id="Dialect-279"><a href="#Dialect-279"><span class="linenos">279</span></a> <span class="k">def</span> <span class="nf">parse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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="Dialect-280"><a href="#Dialect-280"><span class="linenos">280</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">parser</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tokenize</span><span class="p">(</span><span class="n">sql</span><span class="p">),</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="Dialect-281"><a href="#Dialect-281"><span class="linenos">281</span></a> +</span><span id="Dialect-282"><a href="#Dialect-282"><span class="linenos">282</span></a> <span class="k">def</span> <span class="nf">parse_into</span><span class="p">(</span> +</span><span id="Dialect-283"><a href="#Dialect-283"><span class="linenos">283</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression_type</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IntoType</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="Dialect-284"><a href="#Dialect-284"><span class="linenos">284</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Dialect-285"><a href="#Dialect-285"><span class="linenos">285</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">parser</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">parse_into</span><span class="p">(</span><span class="n">expression_type</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokenize</span><span class="p">(</span><span class="n">sql</span><span class="p">),</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="Dialect-286"><a href="#Dialect-286"><span class="linenos">286</span></a> +</span><span id="Dialect-287"><a href="#Dialect-287"><span class="linenos">287</span></a> <span class="k">def</span> <span class="nf">generate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">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">opts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Dialect-288"><a href="#Dialect-288"><span class="linenos">288</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">generator</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Dialect-289"><a href="#Dialect-289"><span class="linenos">289</span></a> +</span><span id="Dialect-290"><a href="#Dialect-290"><span class="linenos">290</span></a> <span class="k">def</span> <span class="nf">transpile</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</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="Dialect-291"><a href="#Dialect-291"><span class="linenos">291</span></a> <span class="k">return</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">sql</span><span class="p">)]</span> +</span><span id="Dialect-292"><a href="#Dialect-292"><span class="linenos">292</span></a> +</span><span id="Dialect-293"><a href="#Dialect-293"><span class="linenos">293</span></a> <span class="k">def</span> <span class="nf">tokenize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Token</span><span class="p">]:</span> +</span><span id="Dialect-294"><a href="#Dialect-294"><span class="linenos">294</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokenizer</span><span class="o">.</span><span class="n">tokenize</span><span class="p">(</span><span class="n">sql</span><span class="p">)</span> +</span><span id="Dialect-295"><a href="#Dialect-295"><span class="linenos">295</span></a> +</span><span id="Dialect-296"><a href="#Dialect-296"><span class="linenos">296</span></a> <span class="nd">@property</span> +</span><span id="Dialect-297"><a href="#Dialect-297"><span class="linenos">297</span></a> <span class="k">def</span> <span class="nf">tokenizer</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">Tokenizer</span><span class="p">:</span> +</span><span id="Dialect-298"><a href="#Dialect-298"><span class="linenos">298</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s2">"_tokenizer"</span><span class="p">):</span> +</span><span id="Dialect-299"><a href="#Dialect-299"><span class="linenos">299</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_tokenizer</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokenizer_class</span><span class="p">()</span> +</span><span id="Dialect-300"><a href="#Dialect-300"><span class="linenos">300</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tokenizer</span> +</span><span id="Dialect-301"><a href="#Dialect-301"><span class="linenos">301</span></a> +</span><span id="Dialect-302"><a href="#Dialect-302"><span class="linenos">302</span></a> <span class="k">def</span> <span class="nf">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Parser</span><span class="p">:</span> +</span><span id="Dialect-303"><a href="#Dialect-303"><span class="linenos">303</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">parser_class</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="Dialect-304"><a href="#Dialect-304"><span class="linenos">304</span></a> +</span><span id="Dialect-305"><a href="#Dialect-305"><span class="linenos">305</span></a> <span class="k">def</span> <span class="nf">generator</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Generator</span><span class="p">:</span> +</span><span id="Dialect-306"><a href="#Dialect-306"><span class="linenos">306</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">generator_class</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span> </span></pre></div> @@ -1344,20 +1482,20 @@ </div> <a class="headerlink" href="#Dialect.get_or_raise"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.get_or_raise-187"><a href="#Dialect.get_or_raise-187"><span class="linenos">187</span></a> <span class="nd">@classmethod</span> -</span><span id="Dialect.get_or_raise-188"><a href="#Dialect.get_or_raise-188"><span class="linenos">188</span></a> <span class="k">def</span> <span class="nf">get_or_raise</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Dialect</span><span class="p">]:</span> -</span><span id="Dialect.get_or_raise-189"><a href="#Dialect.get_or_raise-189"><span class="linenos">189</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">dialect</span><span class="p">:</span> -</span><span id="Dialect.get_or_raise-190"><a href="#Dialect.get_or_raise-190"><span class="linenos">190</span></a> <span class="k">return</span> <span class="bp">cls</span> -</span><span id="Dialect.get_or_raise-191"><a href="#Dialect.get_or_raise-191"><span class="linenos">191</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dialect</span><span class="p">,</span> <span class="n">_Dialect</span><span class="p">):</span> -</span><span id="Dialect.get_or_raise-192"><a href="#Dialect.get_or_raise-192"><span class="linenos">192</span></a> <span class="k">return</span> <span class="n">dialect</span> -</span><span id="Dialect.get_or_raise-193"><a href="#Dialect.get_or_raise-193"><span class="linenos">193</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dialect</span><span class="p">,</span> <span class="n">Dialect</span><span class="p">):</span> -</span><span id="Dialect.get_or_raise-194"><a href="#Dialect.get_or_raise-194"><span class="linenos">194</span></a> <span class="k">return</span> <span class="n">dialect</span><span class="o">.</span><span class="vm">__class__</span> -</span><span id="Dialect.get_or_raise-195"><a href="#Dialect.get_or_raise-195"><span class="linenos">195</span></a> -</span><span id="Dialect.get_or_raise-196"><a href="#Dialect.get_or_raise-196"><span class="linenos">196</span></a> <span class="n">result</span> <span class="o">=</span> <span class="bp">cls</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span> -</span><span id="Dialect.get_or_raise-197"><a href="#Dialect.get_or_raise-197"><span class="linenos">197</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">result</span><span class="p">:</span> -</span><span id="Dialect.get_or_raise-198"><a href="#Dialect.get_or_raise-198"><span class="linenos">198</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unknown dialect '</span><span class="si">{</span><span class="n">dialect</span><span class="si">}</span><span class="s2">'"</span><span class="p">)</span> -</span><span id="Dialect.get_or_raise-199"><a href="#Dialect.get_or_raise-199"><span class="linenos">199</span></a> -</span><span id="Dialect.get_or_raise-200"><a href="#Dialect.get_or_raise-200"><span class="linenos">200</span></a> <span class="k">return</span> <span class="n">result</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.get_or_raise-189"><a href="#Dialect.get_or_raise-189"><span class="linenos">189</span></a> <span class="nd">@classmethod</span> +</span><span id="Dialect.get_or_raise-190"><a href="#Dialect.get_or_raise-190"><span class="linenos">190</span></a> <span class="k">def</span> <span class="nf">get_or_raise</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Dialect</span><span class="p">]:</span> +</span><span id="Dialect.get_or_raise-191"><a href="#Dialect.get_or_raise-191"><span class="linenos">191</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">dialect</span><span class="p">:</span> +</span><span id="Dialect.get_or_raise-192"><a href="#Dialect.get_or_raise-192"><span class="linenos">192</span></a> <span class="k">return</span> <span class="bp">cls</span> +</span><span id="Dialect.get_or_raise-193"><a href="#Dialect.get_or_raise-193"><span class="linenos">193</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dialect</span><span class="p">,</span> <span class="n">_Dialect</span><span class="p">):</span> +</span><span id="Dialect.get_or_raise-194"><a href="#Dialect.get_or_raise-194"><span class="linenos">194</span></a> <span class="k">return</span> <span class="n">dialect</span> +</span><span id="Dialect.get_or_raise-195"><a href="#Dialect.get_or_raise-195"><span class="linenos">195</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dialect</span><span class="p">,</span> <span class="n">Dialect</span><span class="p">):</span> +</span><span id="Dialect.get_or_raise-196"><a href="#Dialect.get_or_raise-196"><span class="linenos">196</span></a> <span class="k">return</span> <span class="n">dialect</span><span class="o">.</span><span class="vm">__class__</span> +</span><span id="Dialect.get_or_raise-197"><a href="#Dialect.get_or_raise-197"><span class="linenos">197</span></a> +</span><span id="Dialect.get_or_raise-198"><a href="#Dialect.get_or_raise-198"><span class="linenos">198</span></a> <span class="n">result</span> <span class="o">=</span> <span class="bp">cls</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span> +</span><span id="Dialect.get_or_raise-199"><a href="#Dialect.get_or_raise-199"><span class="linenos">199</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">result</span><span class="p">:</span> +</span><span id="Dialect.get_or_raise-200"><a href="#Dialect.get_or_raise-200"><span class="linenos">200</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unknown dialect '</span><span class="si">{</span><span class="n">dialect</span><span class="si">}</span><span class="s2">'"</span><span class="p">)</span> +</span><span id="Dialect.get_or_raise-201"><a href="#Dialect.get_or_raise-201"><span class="linenos">201</span></a> +</span><span id="Dialect.get_or_raise-202"><a href="#Dialect.get_or_raise-202"><span class="linenos">202</span></a> <span class="k">return</span> <span class="n">result</span> </span></pre></div> @@ -1376,20 +1514,170 @@ </div> <a class="headerlink" href="#Dialect.format_time"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.format_time-202"><a href="#Dialect.format_time-202"><span class="linenos">202</span></a> <span class="nd">@classmethod</span> -</span><span id="Dialect.format_time-203"><a href="#Dialect.format_time-203"><span class="linenos">203</span></a> <span class="k">def</span> <span class="nf">format_time</span><span class="p">(</span> -</span><span id="Dialect.format_time-204"><a href="#Dialect.format_time-204"><span class="linenos">204</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> -</span><span id="Dialect.format_time-205"><a href="#Dialect.format_time-205"><span class="linenos">205</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="Dialect.format_time-206"><a href="#Dialect.format_time-206"><span class="linenos">206</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="Dialect.format_time-207"><a href="#Dialect.format_time-207"><span class="linenos">207</span></a> <span class="k">return</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><span id="Dialect.format_time-208"><a href="#Dialect.format_time-208"><span class="linenos">208</span></a> <span class="c1"># the time formats are quoted</span> -</span><span id="Dialect.format_time-209"><a href="#Dialect.format_time-209"><span class="linenos">209</span></a> <span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">[</span><span class="mi">1</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_TRIE</span><span class="p">)</span> -</span><span id="Dialect.format_time-210"><a href="#Dialect.format_time-210"><span class="linenos">210</span></a> <span class="p">)</span> -</span><span id="Dialect.format_time-211"><a href="#Dialect.format_time-211"><span class="linenos">211</span></a> -</span><span id="Dialect.format_time-212"><a href="#Dialect.format_time-212"><span class="linenos">212</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> -</span><span id="Dialect.format_time-213"><a href="#Dialect.format_time-213"><span class="linenos">213</span></a> <span class="k">return</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">format_time</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_TRIE</span><span class="p">))</span> -</span><span id="Dialect.format_time-214"><a href="#Dialect.format_time-214"><span class="linenos">214</span></a> -</span><span id="Dialect.format_time-215"><a href="#Dialect.format_time-215"><span class="linenos">215</span></a> <span class="k">return</span> <span class="n">expression</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.format_time-204"><a href="#Dialect.format_time-204"><span class="linenos">204</span></a> <span class="nd">@classmethod</span> +</span><span id="Dialect.format_time-205"><a href="#Dialect.format_time-205"><span class="linenos">205</span></a> <span class="k">def</span> <span class="nf">format_time</span><span class="p">(</span> +</span><span id="Dialect.format_time-206"><a href="#Dialect.format_time-206"><span class="linenos">206</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> +</span><span id="Dialect.format_time-207"><a href="#Dialect.format_time-207"><span class="linenos">207</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="Dialect.format_time-208"><a href="#Dialect.format_time-208"><span class="linenos">208</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="Dialect.format_time-209"><a href="#Dialect.format_time-209"><span class="linenos">209</span></a> <span class="k">return</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><span id="Dialect.format_time-210"><a href="#Dialect.format_time-210"><span class="linenos">210</span></a> <span class="c1"># the time formats are quoted</span> +</span><span id="Dialect.format_time-211"><a href="#Dialect.format_time-211"><span class="linenos">211</span></a> <span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">[</span><span class="mi">1</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_TRIE</span><span class="p">)</span> +</span><span id="Dialect.format_time-212"><a href="#Dialect.format_time-212"><span class="linenos">212</span></a> <span class="p">)</span> +</span><span id="Dialect.format_time-213"><a href="#Dialect.format_time-213"><span class="linenos">213</span></a> +</span><span id="Dialect.format_time-214"><a href="#Dialect.format_time-214"><span class="linenos">214</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> +</span><span id="Dialect.format_time-215"><a href="#Dialect.format_time-215"><span class="linenos">215</span></a> <span class="k">return</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">format_time</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">TIME_TRIE</span><span class="p">))</span> +</span><span id="Dialect.format_time-216"><a href="#Dialect.format_time-216"><span class="linenos">216</span></a> +</span><span id="Dialect.format_time-217"><a href="#Dialect.format_time-217"><span class="linenos">217</span></a> <span class="k">return</span> <span class="n">expression</span> +</span></pre></div> + + + + + </div> + <div id="Dialect.normalize_identifier" class="classattr"> + <input id="Dialect.normalize_identifier-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">normalize_identifier</span><span class="signature pdoc-code condensed">(<span class="param"><span class="bp">cls</span>, </span><span class="param"><span class="n">expression</span><span class="p">:</span> <span class="o">~</span><span class="n">E</span></span><span class="return-annotation">) -> <span class="o">~</span><span class="n">E</span>:</span></span> + + <label class="view-source-button" for="Dialect.normalize_identifier-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Dialect.normalize_identifier"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.normalize_identifier-219"><a href="#Dialect.normalize_identifier-219"><span class="linenos">219</span></a> <span class="nd">@classmethod</span> +</span><span id="Dialect.normalize_identifier-220"><a href="#Dialect.normalize_identifier-220"><span class="linenos">220</span></a> <span class="k">def</span> <span class="nf">normalize_identifier</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="Dialect.normalize_identifier-221"><a href="#Dialect.normalize_identifier-221"><span class="linenos">221</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Dialect.normalize_identifier-222"><a href="#Dialect.normalize_identifier-222"><span class="linenos">222</span></a><span class="sd"> Normalizes an unquoted identifier to either lower or upper case, thus essentially</span> +</span><span id="Dialect.normalize_identifier-223"><a href="#Dialect.normalize_identifier-223"><span class="linenos">223</span></a><span class="sd"> making it case-insensitive. If a dialect treats all identifiers as case-insensitive,</span> +</span><span id="Dialect.normalize_identifier-224"><a href="#Dialect.normalize_identifier-224"><span class="linenos">224</span></a><span class="sd"> they will be normalized regardless of being quoted or not.</span> +</span><span id="Dialect.normalize_identifier-225"><a href="#Dialect.normalize_identifier-225"><span class="linenos">225</span></a><span class="sd"> """</span> +</span><span id="Dialect.normalize_identifier-226"><a href="#Dialect.normalize_identifier-226"><span class="linenos">226</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span> +</span><span id="Dialect.normalize_identifier-227"><a href="#Dialect.normalize_identifier-227"><span class="linenos">227</span></a> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> <span class="ow">or</span> <span class="bp">cls</span><span class="o">.</span><span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="ow">is</span> <span class="kc">None</span> +</span><span id="Dialect.normalize_identifier-228"><a href="#Dialect.normalize_identifier-228"><span class="linenos">228</span></a> <span class="p">):</span> +</span><span id="Dialect.normalize_identifier-229"><a href="#Dialect.normalize_identifier-229"><span class="linenos">229</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="Dialect.normalize_identifier-230"><a href="#Dialect.normalize_identifier-230"><span class="linenos">230</span></a> <span class="s2">"this"</span><span class="p">,</span> +</span><span id="Dialect.normalize_identifier-231"><a href="#Dialect.normalize_identifier-231"><span class="linenos">231</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Dialect.normalize_identifier-232"><a href="#Dialect.normalize_identifier-232"><span class="linenos">232</span></a> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> +</span><span id="Dialect.normalize_identifier-233"><a href="#Dialect.normalize_identifier-233"><span class="linenos">233</span></a> <span class="k">else</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> +</span><span id="Dialect.normalize_identifier-234"><a href="#Dialect.normalize_identifier-234"><span class="linenos">234</span></a> <span class="p">)</span> +</span><span id="Dialect.normalize_identifier-235"><a href="#Dialect.normalize_identifier-235"><span class="linenos">235</span></a> +</span><span id="Dialect.normalize_identifier-236"><a href="#Dialect.normalize_identifier-236"><span class="linenos">236</span></a> <span class="k">return</span> <span class="n">expression</span> +</span></pre></div> + + + <div class="docstring"><p>Normalizes an unquoted identifier to either lower or upper case, thus essentially +making it case-insensitive. If a dialect treats all identifiers as case-insensitive, +they will be normalized regardless of being quoted or not.</p> +</div> + + + </div> + <div id="Dialect.case_sensitive" class="classattr"> + <input id="Dialect.case_sensitive-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">case_sensitive</span><span class="signature pdoc-code condensed">(<span class="param"><span class="bp">cls</span>, </span><span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="Dialect.case_sensitive-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Dialect.case_sensitive"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.case_sensitive-238"><a href="#Dialect.case_sensitive-238"><span class="linenos">238</span></a> <span class="nd">@classmethod</span> +</span><span id="Dialect.case_sensitive-239"><a href="#Dialect.case_sensitive-239"><span class="linenos">239</span></a> <span class="k">def</span> <span class="nf">case_sensitive</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Dialect.case_sensitive-240"><a href="#Dialect.case_sensitive-240"><span class="linenos">240</span></a><span class="w"> </span><span class="sd">"""Checks if text contains any case sensitive characters, based on the dialect's rules."""</span> +</span><span id="Dialect.case_sensitive-241"><a href="#Dialect.case_sensitive-241"><span class="linenos">241</span></a> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Dialect.case_sensitive-242"><a href="#Dialect.case_sensitive-242"><span class="linenos">242</span></a> <span class="k">return</span> <span class="kc">False</span> +</span><span id="Dialect.case_sensitive-243"><a href="#Dialect.case_sensitive-243"><span class="linenos">243</span></a> +</span><span id="Dialect.case_sensitive-244"><a href="#Dialect.case_sensitive-244"><span class="linenos">244</span></a> <span class="n">unsafe</span> <span class="o">=</span> <span class="nb">str</span><span class="o">.</span><span class="n">islower</span> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="k">else</span> <span class="nb">str</span><span class="o">.</span><span class="n">isupper</span> +</span><span id="Dialect.case_sensitive-245"><a href="#Dialect.case_sensitive-245"><span class="linenos">245</span></a> <span class="k">return</span> <span class="nb">any</span><span class="p">(</span><span class="n">unsafe</span><span class="p">(</span><span class="n">char</span><span class="p">)</span> <span class="k">for</span> <span class="n">char</span> <span class="ow">in</span> <span class="n">text</span><span class="p">)</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text contains any case sensitive characters, based on the dialect's rules.</p> +</div> + + + </div> + <div id="Dialect.can_identify" class="classattr"> + <input id="Dialect.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="bp">cls</span>, </span><span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="Dialect.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Dialect.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.can_identify-247"><a href="#Dialect.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="Dialect.can_identify-248"><a href="#Dialect.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Dialect.can_identify-249"><a href="#Dialect.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="Dialect.can_identify-250"><a href="#Dialect.can_identify-250"><span class="linenos">250</span></a> +</span><span id="Dialect.can_identify-251"><a href="#Dialect.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="Dialect.can_identify-252"><a href="#Dialect.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="Dialect.can_identify-253"><a href="#Dialect.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="Dialect.can_identify-254"><a href="#Dialect.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="Dialect.can_identify-255"><a href="#Dialect.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="Dialect.can_identify-256"><a href="#Dialect.can_identify-256"><span class="linenos">256</span></a> +</span><span id="Dialect.can_identify-257"><a href="#Dialect.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="Dialect.can_identify-258"><a href="#Dialect.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="Dialect.can_identify-259"><a href="#Dialect.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="Dialect.can_identify-260"><a href="#Dialect.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="Dialect.can_identify-261"><a href="#Dialect.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Dialect.can_identify-262"><a href="#Dialect.can_identify-262"><span class="linenos">262</span></a> +</span><span id="Dialect.can_identify-263"><a href="#Dialect.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="Dialect.can_identify-264"><a href="#Dialect.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="Dialect.can_identify-265"><a href="#Dialect.can_identify-265"><span class="linenos">265</span></a> +</span><span id="Dialect.can_identify-266"><a href="#Dialect.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> + <div id="Dialect.quote_identifier" class="classattr"> + <input id="Dialect.quote_identifier-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">quote_identifier</span><span class="signature pdoc-code condensed">(<span class="param"><span class="bp">cls</span>, </span><span class="param"><span class="n">expression</span><span class="p">:</span> <span class="o">~</span><span class="n">E</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span></span><span class="return-annotation">) -> <span class="o">~</span><span class="n">E</span>:</span></span> + + <label class="view-source-button" for="Dialect.quote_identifier-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Dialect.quote_identifier"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.quote_identifier-268"><a href="#Dialect.quote_identifier-268"><span class="linenos">268</span></a> <span class="nd">@classmethod</span> +</span><span id="Dialect.quote_identifier-269"><a href="#Dialect.quote_identifier-269"><span class="linenos">269</span></a> <span class="k">def</span> <span class="nf">quote_identifier</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="Dialect.quote_identifier-270"><a href="#Dialect.quote_identifier-270"><span class="linenos">270</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">):</span> +</span><span id="Dialect.quote_identifier-271"><a href="#Dialect.quote_identifier-271"><span class="linenos">271</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="Dialect.quote_identifier-272"><a href="#Dialect.quote_identifier-272"><span class="linenos">272</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="Dialect.quote_identifier-273"><a href="#Dialect.quote_identifier-273"><span class="linenos">273</span></a> <span class="s2">"quoted"</span><span class="p">,</span> +</span><span id="Dialect.quote_identifier-274"><a href="#Dialect.quote_identifier-274"><span class="linenos">274</span></a> <span class="n">identify</span> <span class="ow">or</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">exp</span><span class="o">.</span><span class="n">SAFE_IDENTIFIER_RE</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">name</span><span class="p">),</span> +</span><span id="Dialect.quote_identifier-275"><a href="#Dialect.quote_identifier-275"><span class="linenos">275</span></a> <span class="p">)</span> +</span><span id="Dialect.quote_identifier-276"><a href="#Dialect.quote_identifier-276"><span class="linenos">276</span></a> +</span><span id="Dialect.quote_identifier-277"><a href="#Dialect.quote_identifier-277"><span class="linenos">277</span></a> <span class="k">return</span> <span class="n">expression</span> </span></pre></div> @@ -1407,8 +1695,8 @@ </div> <a class="headerlink" href="#Dialect.parse"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.parse-217"><a href="#Dialect.parse-217"><span class="linenos">217</span></a> <span class="k">def</span> <span class="nf">parse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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="Dialect.parse-218"><a href="#Dialect.parse-218"><span class="linenos">218</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">parser</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tokenize</span><span class="p">(</span><span class="n">sql</span><span class="p">),</span> <span class="n">sql</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.parse-279"><a href="#Dialect.parse-279"><span class="linenos">279</span></a> <span class="k">def</span> <span class="nf">parse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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="Dialect.parse-280"><a href="#Dialect.parse-280"><span class="linenos">280</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">parser</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tokenize</span><span class="p">(</span><span class="n">sql</span><span class="p">),</span> <span class="n">sql</span><span class="p">)</span> </span></pre></div> @@ -1426,10 +1714,10 @@ </div> <a class="headerlink" href="#Dialect.parse_into"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.parse_into-220"><a href="#Dialect.parse_into-220"><span class="linenos">220</span></a> <span class="k">def</span> <span class="nf">parse_into</span><span class="p">(</span> -</span><span id="Dialect.parse_into-221"><a href="#Dialect.parse_into-221"><span class="linenos">221</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression_type</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IntoType</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="Dialect.parse_into-222"><a href="#Dialect.parse_into-222"><span class="linenos">222</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Dialect.parse_into-223"><a href="#Dialect.parse_into-223"><span class="linenos">223</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">parser</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">parse_into</span><span class="p">(</span><span class="n">expression_type</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokenize</span><span class="p">(</span><span class="n">sql</span><span class="p">),</span> <span class="n">sql</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.parse_into-282"><a href="#Dialect.parse_into-282"><span class="linenos">282</span></a> <span class="k">def</span> <span class="nf">parse_into</span><span class="p">(</span> +</span><span id="Dialect.parse_into-283"><a href="#Dialect.parse_into-283"><span class="linenos">283</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression_type</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IntoType</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="Dialect.parse_into-284"><a href="#Dialect.parse_into-284"><span class="linenos">284</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Dialect.parse_into-285"><a href="#Dialect.parse_into-285"><span class="linenos">285</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">parser</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">parse_into</span><span class="p">(</span><span class="n">expression_type</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokenize</span><span class="p">(</span><span class="n">sql</span><span class="p">),</span> <span class="n">sql</span><span class="p">)</span> </span></pre></div> @@ -1447,8 +1735,8 @@ </div> <a class="headerlink" href="#Dialect.generate"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.generate-225"><a href="#Dialect.generate-225"><span class="linenos">225</span></a> <span class="k">def</span> <span class="nf">generate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">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">opts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Dialect.generate-226"><a href="#Dialect.generate-226"><span class="linenos">226</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">generator</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.generate-287"><a href="#Dialect.generate-287"><span class="linenos">287</span></a> <span class="k">def</span> <span class="nf">generate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">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">opts</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Dialect.generate-288"><a href="#Dialect.generate-288"><span class="linenos">288</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">generator</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -1466,8 +1754,8 @@ </div> <a class="headerlink" href="#Dialect.transpile"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.transpile-228"><a href="#Dialect.transpile-228"><span class="linenos">228</span></a> <span class="k">def</span> <span class="nf">transpile</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</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="Dialect.transpile-229"><a href="#Dialect.transpile-229"><span class="linenos">229</span></a> <span class="k">return</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">sql</span><span class="p">)]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.transpile-290"><a href="#Dialect.transpile-290"><span class="linenos">290</span></a> <span class="k">def</span> <span class="nf">transpile</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</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="Dialect.transpile-291"><a href="#Dialect.transpile-291"><span class="linenos">291</span></a> <span class="k">return</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">sql</span><span class="p">)]</span> </span></pre></div> @@ -1485,8 +1773,8 @@ </div> <a class="headerlink" href="#Dialect.tokenize"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.tokenize-231"><a href="#Dialect.tokenize-231"><span class="linenos">231</span></a> <span class="k">def</span> <span class="nf">tokenize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Token</span><span class="p">]:</span> -</span><span id="Dialect.tokenize-232"><a href="#Dialect.tokenize-232"><span class="linenos">232</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokenizer</span><span class="o">.</span><span class="n">tokenize</span><span class="p">(</span><span class="n">sql</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.tokenize-293"><a href="#Dialect.tokenize-293"><span class="linenos">293</span></a> <span class="k">def</span> <span class="nf">tokenize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Token</span><span class="p">]:</span> +</span><span id="Dialect.tokenize-294"><a href="#Dialect.tokenize-294"><span class="linenos">294</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokenizer</span><span class="o">.</span><span class="n">tokenize</span><span class="p">(</span><span class="n">sql</span><span class="p">)</span> </span></pre></div> @@ -1504,8 +1792,8 @@ </div> <a class="headerlink" href="#Dialect.parser"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.parser-240"><a href="#Dialect.parser-240"><span class="linenos">240</span></a> <span class="k">def</span> <span class="nf">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Parser</span><span class="p">:</span> -</span><span id="Dialect.parser-241"><a href="#Dialect.parser-241"><span class="linenos">241</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">parser_class</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.parser-302"><a href="#Dialect.parser-302"><span class="linenos">302</span></a> <span class="k">def</span> <span class="nf">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Parser</span><span class="p">:</span> +</span><span id="Dialect.parser-303"><a href="#Dialect.parser-303"><span class="linenos">303</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">parser_class</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span> </span></pre></div> @@ -1523,8 +1811,8 @@ </div> <a class="headerlink" href="#Dialect.generator"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.generator-243"><a href="#Dialect.generator-243"><span class="linenos">243</span></a> <span class="k">def</span> <span class="nf">generator</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Generator</span><span class="p">:</span> -</span><span id="Dialect.generator-244"><a href="#Dialect.generator-244"><span class="linenos">244</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">generator_class</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Dialect.generator-305"><a href="#Dialect.generator-305"><span class="linenos">305</span></a> <span class="k">def</span> <span class="nf">generator</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Generator</span><span class="p">:</span> +</span><span id="Dialect.generator-306"><a href="#Dialect.generator-306"><span class="linenos">306</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">generator_class</span><span class="p">(</span><span class="o">**</span><span class="n">opts</span><span class="p">)</span> </span></pre></div> @@ -1543,8 +1831,8 @@ </div> <a class="headerlink" href="#rename_func"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="rename_func-250"><a href="#rename_func-250"><span class="linenos">250</span></a><span class="k">def</span> <span class="nf">rename_func</span><span class="p">(</span><span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Generator</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> -</span><span id="rename_func-251"><a href="#rename_func-251"><span class="linenos">251</span></a> <span class="k">return</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">flatten</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">values</span><span class="p">()))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="rename_func-312"><a href="#rename_func-312"><span class="linenos">312</span></a><span class="k">def</span> <span class="nf">rename_func</span><span class="p">(</span><span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Generator</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> +</span><span id="rename_func-313"><a href="#rename_func-313"><span class="linenos">313</span></a> <span class="k">return</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">flatten</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">values</span><span class="p">()))</span> </span></pre></div> @@ -1562,10 +1850,10 @@ </div> <a class="headerlink" href="#approx_count_distinct_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="approx_count_distinct_sql-254"><a href="#approx_count_distinct_sql-254"><span class="linenos">254</span></a><span class="k">def</span> <span class="nf">approx_count_distinct_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="approx_count_distinct_sql-255"><a href="#approx_count_distinct_sql-255"><span class="linenos">255</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">"accuracy"</span><span class="p">):</span> -</span><span id="approx_count_distinct_sql-256"><a href="#approx_count_distinct_sql-256"><span class="linenos">256</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"APPROX_COUNT_DISTINCT does not support accuracy"</span><span class="p">)</span> -</span><span id="approx_count_distinct_sql-257"><a href="#approx_count_distinct_sql-257"><span class="linenos">257</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">"APPROX_COUNT_DISTINCT"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="approx_count_distinct_sql-316"><a href="#approx_count_distinct_sql-316"><span class="linenos">316</span></a><span class="k">def</span> <span class="nf">approx_count_distinct_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="approx_count_distinct_sql-317"><a href="#approx_count_distinct_sql-317"><span class="linenos">317</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">"accuracy"</span><span class="p">):</span> +</span><span id="approx_count_distinct_sql-318"><a href="#approx_count_distinct_sql-318"><span class="linenos">318</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"APPROX_COUNT_DISTINCT does not support accuracy"</span><span class="p">)</span> +</span><span id="approx_count_distinct_sql-319"><a href="#approx_count_distinct_sql-319"><span class="linenos">319</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">"APPROX_COUNT_DISTINCT"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> </span></pre></div> @@ -1583,10 +1871,10 @@ </div> <a class="headerlink" href="#if_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="if_sql-260"><a href="#if_sql-260"><span class="linenos">260</span></a><span class="k">def</span> <span class="nf">if_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">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">If</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="if_sql-261"><a href="#if_sql-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="if_sql-262"><a href="#if_sql-262"><span class="linenos">262</span></a> <span class="s2">"IF"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"true"</span><span class="p">),</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"false"</span><span class="p">)</span> -</span><span id="if_sql-263"><a href="#if_sql-263"><span class="linenos">263</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="if_sql-322"><a href="#if_sql-322"><span class="linenos">322</span></a><span class="k">def</span> <span class="nf">if_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">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">If</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="if_sql-323"><a href="#if_sql-323"><span class="linenos">323</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="if_sql-324"><a href="#if_sql-324"><span class="linenos">324</span></a> <span class="s2">"IF"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"true"</span><span class="p">),</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"false"</span><span class="p">)</span> +</span><span id="if_sql-325"><a href="#if_sql-325"><span class="linenos">325</span></a> <span class="p">)</span> </span></pre></div> @@ -1604,8 +1892,8 @@ </div> <a class="headerlink" href="#arrow_json_extract_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="arrow_json_extract_sql-266"><a href="#arrow_json_extract_sql-266"><span class="linenos">266</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">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">JSONExtract</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="arrow_json_extract_sql-267"><a href="#arrow_json_extract_sql-267"><span class="linenos">267</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"->"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="arrow_json_extract_sql-328"><a href="#arrow_json_extract_sql-328"><span class="linenos">328</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">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">JSONExtract</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="arrow_json_extract_sql-329"><a href="#arrow_json_extract_sql-329"><span class="linenos">329</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"->"</span><span class="p">)</span> </span></pre></div> @@ -1623,10 +1911,10 @@ </div> <a class="headerlink" href="#arrow_json_extract_scalar_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="arrow_json_extract_scalar_sql-270"><a href="#arrow_json_extract_scalar_sql-270"><span class="linenos">270</span></a><span class="k">def</span> <span class="nf">arrow_json_extract_scalar_sql</span><span class="p">(</span> -</span><span id="arrow_json_extract_scalar_sql-271"><a href="#arrow_json_extract_scalar_sql-271"><span class="linenos">271</span></a> <span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtractScalar</span> -</span><span id="arrow_json_extract_scalar_sql-272"><a href="#arrow_json_extract_scalar_sql-272"><span class="linenos">272</span></a><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="arrow_json_extract_scalar_sql-273"><a href="#arrow_json_extract_scalar_sql-273"><span class="linenos">273</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"->>"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="arrow_json_extract_scalar_sql-332"><a href="#arrow_json_extract_scalar_sql-332"><span class="linenos">332</span></a><span class="k">def</span> <span class="nf">arrow_json_extract_scalar_sql</span><span class="p">(</span> +</span><span id="arrow_json_extract_scalar_sql-333"><a href="#arrow_json_extract_scalar_sql-333"><span class="linenos">333</span></a> <span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtractScalar</span> +</span><span id="arrow_json_extract_scalar_sql-334"><a href="#arrow_json_extract_scalar_sql-334"><span class="linenos">334</span></a><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="arrow_json_extract_scalar_sql-335"><a href="#arrow_json_extract_scalar_sql-335"><span class="linenos">335</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"->>"</span><span class="p">)</span> </span></pre></div> @@ -1644,8 +1932,8 @@ </div> <a class="headerlink" href="#inline_array_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="inline_array_sql-276"><a href="#inline_array_sql-276"><span class="linenos">276</span></a><span class="k">def</span> <span class="nf">inline_array_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="inline_array_sql-277"><a href="#inline_array_sql-277"><span class="linenos">277</span></a> <span class="k">return</span> <span 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="si">}</span><span class="s2">]"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="inline_array_sql-338"><a href="#inline_array_sql-338"><span class="linenos">338</span></a><span class="k">def</span> <span class="nf">inline_array_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="inline_array_sql-339"><a href="#inline_array_sql-339"><span class="linenos">339</span></a> <span class="k">return</span> <span 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="si">}</span><span class="s2">]"</span> </span></pre></div> @@ -1663,10 +1951,10 @@ </div> <a class="headerlink" href="#no_ilike_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="no_ilike_sql-280"><a href="#no_ilike_sql-280"><span class="linenos">280</span></a><span class="k">def</span> <span class="nf">no_ilike_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="no_ilike_sql-281"><a href="#no_ilike_sql-281"><span class="linenos">281</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">like_sql</span><span class="p">(</span> -</span><span id="no_ilike_sql-282"><a href="#no_ilike_sql-282"><span class="linenos">282</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Like</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Lower</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="no_ilike_sql-283"><a href="#no_ilike_sql-283"><span class="linenos">283</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="no_ilike_sql-342"><a href="#no_ilike_sql-342"><span class="linenos">342</span></a><span class="k">def</span> <span class="nf">no_ilike_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="no_ilike_sql-343"><a href="#no_ilike_sql-343"><span class="linenos">343</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">like_sql</span><span class="p">(</span> +</span><span id="no_ilike_sql-344"><a href="#no_ilike_sql-344"><span class="linenos">344</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Like</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Lower</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="no_ilike_sql-345"><a href="#no_ilike_sql-345"><span class="linenos">345</span></a> <span class="p">)</span> </span></pre></div> @@ -1684,9 +1972,9 @@ </div> <a class="headerlink" href="#no_paren_current_date_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="no_paren_current_date_sql-286"><a href="#no_paren_current_date_sql-286"><span class="linenos">286</span></a><span class="k">def</span> <span class="nf">no_paren_current_date_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="no_paren_current_date_sql-287"><a href="#no_paren_current_date_sql-287"><span class="linenos">287</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="no_paren_current_date_sql-288"><a href="#no_paren_current_date_sql-288"><span class="linenos">288</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CURRENT_DATE AT TIME ZONE </span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">zone</span> <span class="k">else</span> <span class="s2">"CURRENT_DATE"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="no_paren_current_date_sql-348"><a href="#no_paren_current_date_sql-348"><span class="linenos">348</span></a><span class="k">def</span> <span class="nf">no_paren_current_date_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="no_paren_current_date_sql-349"><a href="#no_paren_current_date_sql-349"><span class="linenos">349</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="no_paren_current_date_sql-350"><a href="#no_paren_current_date_sql-350"><span class="linenos">350</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CURRENT_DATE AT TIME ZONE </span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">zone</span> <span class="k">else</span> <span class="s2">"CURRENT_DATE"</span> </span></pre></div> @@ -1704,11 +1992,11 @@ </div> <a class="headerlink" href="#no_recursive_cte_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="no_recursive_cte_sql-291"><a href="#no_recursive_cte_sql-291"><span class="linenos">291</span></a><span class="k">def</span> <span class="nf">no_recursive_cte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="no_recursive_cte_sql-292"><a href="#no_recursive_cte_sql-292"><span class="linenos">292</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">"recursive"</span><span class="p">):</span> -</span><span id="no_recursive_cte_sql-293"><a href="#no_recursive_cte_sql-293"><span class="linenos">293</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Recursive CTEs are unsupported"</span><span class="p">)</span> -</span><span id="no_recursive_cte_sql-294"><a href="#no_recursive_cte_sql-294"><span class="linenos">294</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"recursive"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="no_recursive_cte_sql-295"><a href="#no_recursive_cte_sql-295"><span class="linenos">295</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">with_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="no_recursive_cte_sql-353"><a href="#no_recursive_cte_sql-353"><span class="linenos">353</span></a><span class="k">def</span> <span class="nf">no_recursive_cte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="no_recursive_cte_sql-354"><a href="#no_recursive_cte_sql-354"><span class="linenos">354</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">"recursive"</span><span class="p">):</span> +</span><span id="no_recursive_cte_sql-355"><a href="#no_recursive_cte_sql-355"><span class="linenos">355</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Recursive CTEs are unsupported"</span><span class="p">)</span> +</span><span id="no_recursive_cte_sql-356"><a href="#no_recursive_cte_sql-356"><span class="linenos">356</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"recursive"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="no_recursive_cte_sql-357"><a href="#no_recursive_cte_sql-357"><span class="linenos">357</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">with_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -1726,10 +2014,10 @@ </div> <a class="headerlink" href="#no_safe_divide_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="no_safe_divide_sql-298"><a href="#no_safe_divide_sql-298"><span class="linenos">298</span></a><span class="k">def</span> <span class="nf">no_safe_divide_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="no_safe_divide_sql-299"><a href="#no_safe_divide_sql-299"><span class="linenos">299</span></a> <span class="n">n</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="no_safe_divide_sql-300"><a href="#no_safe_divide_sql-300"><span class="linenos">300</span></a> <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="no_safe_divide_sql-301"><a href="#no_safe_divide_sql-301"><span class="linenos">301</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"IF(</span><span class="si">{</span><span class="n">d</span><span class="si">}</span><span class="s2"> <> 0, </span><span class="si">{</span><span class="n">n</span><span class="si">}</span><span class="s2"> / </span><span class="si">{</span><span class="n">d</span><span class="si">}</span><span class="s2">, NULL)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="no_safe_divide_sql-360"><a href="#no_safe_divide_sql-360"><span class="linenos">360</span></a><span class="k">def</span> <span class="nf">no_safe_divide_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="no_safe_divide_sql-361"><a href="#no_safe_divide_sql-361"><span class="linenos">361</span></a> <span class="n">n</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="no_safe_divide_sql-362"><a href="#no_safe_divide_sql-362"><span class="linenos">362</span></a> <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="no_safe_divide_sql-363"><a href="#no_safe_divide_sql-363"><span class="linenos">363</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"IF(</span><span class="si">{</span><span class="n">d</span><span class="si">}</span><span class="s2"> <> 0, </span><span class="si">{</span><span class="n">n</span><span class="si">}</span><span class="s2"> / </span><span class="si">{</span><span class="n">d</span><span class="si">}</span><span class="s2">, NULL)"</span> </span></pre></div> @@ -1747,9 +2035,9 @@ </div> <a class="headerlink" href="#no_tablesample_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="no_tablesample_sql-304"><a href="#no_tablesample_sql-304"><span class="linenos">304</span></a><span class="k">def</span> <span class="nf">no_tablesample_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="no_tablesample_sql-305"><a href="#no_tablesample_sql-305"><span class="linenos">305</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"TABLESAMPLE unsupported"</span><span class="p">)</span> -</span><span id="no_tablesample_sql-306"><a href="#no_tablesample_sql-306"><span class="linenos">306</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="o">.</span><span class="n">this</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="no_tablesample_sql-366"><a href="#no_tablesample_sql-366"><span class="linenos">366</span></a><span class="k">def</span> <span class="nf">no_tablesample_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="no_tablesample_sql-367"><a href="#no_tablesample_sql-367"><span class="linenos">367</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"TABLESAMPLE unsupported"</span><span class="p">)</span> +</span><span id="no_tablesample_sql-368"><a href="#no_tablesample_sql-368"><span class="linenos">368</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="o">.</span><span class="n">this</span><span class="p">)</span> </span></pre></div> @@ -1767,9 +2055,9 @@ </div> <a class="headerlink" href="#no_pivot_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="no_pivot_sql-309"><a href="#no_pivot_sql-309"><span class="linenos">309</span></a><span class="k">def</span> <span class="nf">no_pivot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="no_pivot_sql-310"><a href="#no_pivot_sql-310"><span class="linenos">310</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"PIVOT unsupported"</span><span class="p">)</span> -</span><span id="no_pivot_sql-311"><a href="#no_pivot_sql-311"><span class="linenos">311</span></a> <span class="k">return</span> <span class="s2">""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="no_pivot_sql-371"><a href="#no_pivot_sql-371"><span class="linenos">371</span></a><span class="k">def</span> <span class="nf">no_pivot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="no_pivot_sql-372"><a href="#no_pivot_sql-372"><span class="linenos">372</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"PIVOT unsupported"</span><span class="p">)</span> +</span><span id="no_pivot_sql-373"><a href="#no_pivot_sql-373"><span class="linenos">373</span></a> <span class="k">return</span> <span class="s2">""</span> </span></pre></div> @@ -1787,8 +2075,8 @@ </div> <a class="headerlink" href="#no_trycast_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="no_trycast_sql-314"><a href="#no_trycast_sql-314"><span class="linenos">314</span></a><span class="k">def</span> <span class="nf">no_trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="no_trycast_sql-315"><a href="#no_trycast_sql-315"><span class="linenos">315</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="no_trycast_sql-376"><a href="#no_trycast_sql-376"><span class="linenos">376</span></a><span class="k">def</span> <span class="nf">no_trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="no_trycast_sql-377"><a href="#no_trycast_sql-377"><span class="linenos">377</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -1806,9 +2094,9 @@ </div> <a class="headerlink" href="#no_properties_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="no_properties_sql-318"><a href="#no_properties_sql-318"><span class="linenos">318</span></a><span class="k">def</span> <span class="nf">no_properties_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="no_properties_sql-319"><a href="#no_properties_sql-319"><span class="linenos">319</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Properties unsupported"</span><span class="p">)</span> -</span><span id="no_properties_sql-320"><a href="#no_properties_sql-320"><span class="linenos">320</span></a> <span class="k">return</span> <span class="s2">""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="no_properties_sql-380"><a href="#no_properties_sql-380"><span class="linenos">380</span></a><span class="k">def</span> <span class="nf">no_properties_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="no_properties_sql-381"><a href="#no_properties_sql-381"><span class="linenos">381</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Properties unsupported"</span><span class="p">)</span> +</span><span id="no_properties_sql-382"><a href="#no_properties_sql-382"><span class="linenos">382</span></a> <span class="k">return</span> <span class="s2">""</span> </span></pre></div> @@ -1826,11 +2114,11 @@ </div> <a class="headerlink" href="#no_comment_column_constraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="no_comment_column_constraint_sql-323"><a href="#no_comment_column_constraint_sql-323"><span class="linenos">323</span></a><span class="k">def</span> <span class="nf">no_comment_column_constraint_sql</span><span class="p">(</span> -</span><span id="no_comment_column_constraint_sql-324"><a href="#no_comment_column_constraint_sql-324"><span class="linenos">324</span></a> <span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CommentColumnConstraint</span> -</span><span id="no_comment_column_constraint_sql-325"><a href="#no_comment_column_constraint_sql-325"><span class="linenos">325</span></a><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="no_comment_column_constraint_sql-326"><a href="#no_comment_column_constraint_sql-326"><span class="linenos">326</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"CommentColumnConstraint unsupported"</span><span class="p">)</span> -</span><span id="no_comment_column_constraint_sql-327"><a href="#no_comment_column_constraint_sql-327"><span class="linenos">327</span></a> <span class="k">return</span> <span class="s2">""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="no_comment_column_constraint_sql-385"><a href="#no_comment_column_constraint_sql-385"><span class="linenos">385</span></a><span class="k">def</span> <span class="nf">no_comment_column_constraint_sql</span><span class="p">(</span> +</span><span id="no_comment_column_constraint_sql-386"><a href="#no_comment_column_constraint_sql-386"><span class="linenos">386</span></a> <span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CommentColumnConstraint</span> +</span><span id="no_comment_column_constraint_sql-387"><a href="#no_comment_column_constraint_sql-387"><span class="linenos">387</span></a><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="no_comment_column_constraint_sql-388"><a href="#no_comment_column_constraint_sql-388"><span class="linenos">388</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"CommentColumnConstraint unsupported"</span><span class="p">)</span> +</span><span id="no_comment_column_constraint_sql-389"><a href="#no_comment_column_constraint_sql-389"><span class="linenos">389</span></a> <span class="k">return</span> <span class="s2">""</span> </span></pre></div> @@ -1848,13 +2136,13 @@ </div> <a class="headerlink" href="#str_position_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="str_position_sql-330"><a href="#str_position_sql-330"><span class="linenos">330</span></a><span class="k">def</span> <span class="nf">str_position_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="str_position_sql-331"><a href="#str_position_sql-331"><span class="linenos">331</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="str_position_sql-332"><a href="#str_position_sql-332"><span class="linenos">332</span></a> <span class="n">substr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"substr"</span><span class="p">)</span> -</span><span id="str_position_sql-333"><a href="#str_position_sql-333"><span class="linenos">333</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> -</span><span id="str_position_sql-334"><a href="#str_position_sql-334"><span class="linenos">334</span></a> <span class="k">if</span> <span class="n">position</span><span class="p">:</span> -</span><span id="str_position_sql-335"><a href="#str_position_sql-335"><span class="linenos">335</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"STRPOS(SUBSTR(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2">), </span><span class="si">{</span><span class="n">substr</span><span class="si">}</span><span class="s2">) + </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2"> - 1"</span> -</span><span id="str_position_sql-336"><a href="#str_position_sql-336"><span class="linenos">336</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"STRPOS(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">substr</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="str_position_sql-392"><a href="#str_position_sql-392"><span class="linenos">392</span></a><span class="k">def</span> <span class="nf">str_position_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="str_position_sql-393"><a href="#str_position_sql-393"><span class="linenos">393</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="str_position_sql-394"><a href="#str_position_sql-394"><span class="linenos">394</span></a> <span class="n">substr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"substr"</span><span class="p">)</span> +</span><span id="str_position_sql-395"><a href="#str_position_sql-395"><span class="linenos">395</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> +</span><span id="str_position_sql-396"><a href="#str_position_sql-396"><span class="linenos">396</span></a> <span class="k">if</span> <span class="n">position</span><span class="p">:</span> +</span><span id="str_position_sql-397"><a href="#str_position_sql-397"><span class="linenos">397</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"STRPOS(SUBSTR(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2">), </span><span class="si">{</span><span class="n">substr</span><span class="si">}</span><span class="s2">) + </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2"> - 1"</span> +</span><span id="str_position_sql-398"><a href="#str_position_sql-398"><span class="linenos">398</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"STRPOS(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">, </span><span class="si">{</span><span class="n">substr</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -1872,10 +2160,10 @@ </div> <a class="headerlink" href="#struct_extract_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="struct_extract_sql-339"><a href="#struct_extract_sql-339"><span class="linenos">339</span></a><span class="k">def</span> <span class="nf">struct_extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="struct_extract_sql-340"><a href="#struct_extract_sql-340"><span class="linenos">340</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="struct_extract_sql-341"><a href="#struct_extract_sql-341"><span class="linenos">341</span></a> <span class="n">struct_key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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">expression</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> -</span><span id="struct_extract_sql-342"><a href="#struct_extract_sql-342"><span class="linenos">342</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">struct_key</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="struct_extract_sql-401"><a href="#struct_extract_sql-401"><span class="linenos">401</span></a><span class="k">def</span> <span class="nf">struct_extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="struct_extract_sql-402"><a href="#struct_extract_sql-402"><span class="linenos">402</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="struct_extract_sql-403"><a href="#struct_extract_sql-403"><span class="linenos">403</span></a> <span class="n">struct_key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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">expression</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="struct_extract_sql-404"><a href="#struct_extract_sql-404"><span class="linenos">404</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">struct_key</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -1893,22 +2181,22 @@ </div> <a class="headerlink" href="#var_map_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="var_map_sql-345"><a href="#var_map_sql-345"><span class="linenos">345</span></a><span class="k">def</span> <span class="nf">var_map_sql</span><span class="p">(</span> -</span><span id="var_map_sql-346"><a href="#var_map_sql-346"><span class="linenos">346</span></a> <span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Map</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</span><span class="p">,</span> <span class="n">map_func_name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"MAP"</span> -</span><span id="var_map_sql-347"><a href="#var_map_sql-347"><span class="linenos">347</span></a><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="var_map_sql-348"><a href="#var_map_sql-348"><span class="linenos">348</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"keys"</span><span class="p">]</span> -</span><span id="var_map_sql-349"><a href="#var_map_sql-349"><span class="linenos">349</span></a> <span class="n">values</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">"values"</span><span class="p">]</span> -</span><span id="var_map_sql-350"><a href="#var_map_sql-350"><span class="linenos">350</span></a> -</span><span id="var_map_sql-351"><a href="#var_map_sql-351"><span class="linenos">351</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">keys</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">values</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="var_map_sql-352"><a href="#var_map_sql-352"><span class="linenos">352</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Cannot convert array columns into map."</span><span class="p">)</span> -</span><span id="var_map_sql-353"><a href="#var_map_sql-353"><span class="linenos">353</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">map_func_name</span><span class="p">,</span> <span class="n">keys</span><span class="p">,</span> <span class="n">values</span><span class="p">)</span> -</span><span id="var_map_sql-354"><a href="#var_map_sql-354"><span class="linenos">354</span></a> -</span><span id="var_map_sql-355"><a href="#var_map_sql-355"><span class="linenos">355</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="var_map_sql-356"><a href="#var_map_sql-356"><span class="linenos">356</span></a> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">keys</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="n">values</span><span class="o">.</span><span class="n">expressions</span><span class="p">):</span> -</span><span id="var_map_sql-357"><a href="#var_map_sql-357"><span class="linenos">357</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</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">key</span><span class="p">))</span> -</span><span id="var_map_sql-358"><a href="#var_map_sql-358"><span class="linenos">358</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</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">value</span><span class="p">))</span> -</span><span id="var_map_sql-359"><a href="#var_map_sql-359"><span class="linenos">359</span></a> -</span><span id="var_map_sql-360"><a href="#var_map_sql-360"><span class="linenos">360</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">map_func_name</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="var_map_sql-407"><a href="#var_map_sql-407"><span class="linenos">407</span></a><span class="k">def</span> <span class="nf">var_map_sql</span><span class="p">(</span> +</span><span id="var_map_sql-408"><a href="#var_map_sql-408"><span class="linenos">408</span></a> <span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Map</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</span><span class="p">,</span> <span class="n">map_func_name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"MAP"</span> +</span><span id="var_map_sql-409"><a href="#var_map_sql-409"><span class="linenos">409</span></a><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="var_map_sql-410"><a href="#var_map_sql-410"><span class="linenos">410</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"keys"</span><span class="p">]</span> +</span><span id="var_map_sql-411"><a href="#var_map_sql-411"><span class="linenos">411</span></a> <span class="n">values</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">"values"</span><span class="p">]</span> +</span><span id="var_map_sql-412"><a href="#var_map_sql-412"><span class="linenos">412</span></a> +</span><span id="var_map_sql-413"><a href="#var_map_sql-413"><span class="linenos">413</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">keys</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Array</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">values</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="var_map_sql-414"><a href="#var_map_sql-414"><span class="linenos">414</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Cannot convert array columns into map."</span><span class="p">)</span> +</span><span id="var_map_sql-415"><a href="#var_map_sql-415"><span class="linenos">415</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">map_func_name</span><span class="p">,</span> <span class="n">keys</span><span class="p">,</span> <span class="n">values</span><span class="p">)</span> +</span><span id="var_map_sql-416"><a href="#var_map_sql-416"><span class="linenos">416</span></a> +</span><span id="var_map_sql-417"><a href="#var_map_sql-417"><span class="linenos">417</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="var_map_sql-418"><a href="#var_map_sql-418"><span class="linenos">418</span></a> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">keys</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="n">values</span><span class="o">.</span><span class="n">expressions</span><span class="p">):</span> +</span><span id="var_map_sql-419"><a href="#var_map_sql-419"><span class="linenos">419</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</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">key</span><span class="p">))</span> +</span><span id="var_map_sql-420"><a href="#var_map_sql-420"><span class="linenos">420</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</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">value</span><span class="p">))</span> +</span><span id="var_map_sql-421"><a href="#var_map_sql-421"><span class="linenos">421</span></a> +</span><span id="var_map_sql-422"><a href="#var_map_sql-422"><span class="linenos">422</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">map_func_name</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> </span></pre></div> @@ -1926,30 +2214,30 @@ </div> <a class="headerlink" href="#format_time_lambda"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="format_time_lambda-363"><a href="#format_time_lambda-363"><span class="linenos">363</span></a><span class="k">def</span> <span class="nf">format_time_lambda</span><span class="p">(</span> -</span><span id="format_time_lambda-364"><a href="#format_time_lambda-364"><span class="linenos">364</span></a> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> <span class="n">dialect</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">default</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span> <span class="o">|</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="format_time_lambda-365"><a href="#format_time_lambda-365"><span class="linenos">365</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">],</span> <span class="n">E</span><span class="p">]:</span> -</span><span id="format_time_lambda-366"><a href="#format_time_lambda-366"><span class="linenos">366</span></a><span class="w"> </span><span class="sd">"""Helper used for time expressions.</span> -</span><span id="format_time_lambda-367"><a href="#format_time_lambda-367"><span class="linenos">367</span></a> -</span><span id="format_time_lambda-368"><a href="#format_time_lambda-368"><span class="linenos">368</span></a><span class="sd"> Args:</span> -</span><span id="format_time_lambda-369"><a href="#format_time_lambda-369"><span class="linenos">369</span></a><span class="sd"> exp_class: the expression class to instantiate.</span> -</span><span id="format_time_lambda-370"><a href="#format_time_lambda-370"><span class="linenos">370</span></a><span class="sd"> dialect: target sql dialect.</span> -</span><span id="format_time_lambda-371"><a href="#format_time_lambda-371"><span class="linenos">371</span></a><span class="sd"> default: the default format, True being time.</span> -</span><span id="format_time_lambda-372"><a href="#format_time_lambda-372"><span class="linenos">372</span></a> -</span><span id="format_time_lambda-373"><a href="#format_time_lambda-373"><span class="linenos">373</span></a><span class="sd"> Returns:</span> -</span><span id="format_time_lambda-374"><a href="#format_time_lambda-374"><span class="linenos">374</span></a><span class="sd"> A callable that can be used to return the appropriately formatted time expression.</span> -</span><span id="format_time_lambda-375"><a href="#format_time_lambda-375"><span class="linenos">375</span></a><span class="sd"> """</span> -</span><span id="format_time_lambda-376"><a href="#format_time_lambda-376"><span class="linenos">376</span></a> -</span><span id="format_time_lambda-377"><a href="#format_time_lambda-377"><span class="linenos">377</span></a> <span class="k">def</span> <span class="nf">_format_time</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">):</span> -</span><span id="format_time_lambda-378"><a href="#format_time_lambda-378"><span class="linenos">378</span></a> <span class="k">return</span> <span class="n">exp_class</span><span class="p">(</span> -</span><span id="format_time_lambda-379"><a href="#format_time_lambda-379"><span class="linenos">379</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="format_time_lambda-380"><a href="#format_time_lambda-380"><span class="linenos">380</span></a> <span class="nb">format</span><span class="o">=</span><span class="n">Dialect</span><span class="p">[</span><span class="n">dialect</span><span class="p">]</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span> -</span><span id="format_time_lambda-381"><a href="#format_time_lambda-381"><span class="linenos">381</span></a> <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="format_time_lambda-382"><a href="#format_time_lambda-382"><span class="linenos">382</span></a> <span class="ow">or</span> <span class="p">(</span><span class="n">Dialect</span><span class="p">[</span><span class="n">dialect</span><span class="p">]</span><span class="o">.</span><span class="n">TIME_FORMAT</span> <span class="k">if</span> <span class="n">default</span> <span class="ow">is</span> <span class="kc">True</span> <span class="k">else</span> <span class="n">default</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="format_time_lambda-383"><a href="#format_time_lambda-383"><span class="linenos">383</span></a> <span class="p">),</span> -</span><span id="format_time_lambda-384"><a href="#format_time_lambda-384"><span class="linenos">384</span></a> <span class="p">)</span> -</span><span id="format_time_lambda-385"><a href="#format_time_lambda-385"><span class="linenos">385</span></a> -</span><span id="format_time_lambda-386"><a href="#format_time_lambda-386"><span class="linenos">386</span></a> <span class="k">return</span> <span class="n">_format_time</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="format_time_lambda-425"><a href="#format_time_lambda-425"><span class="linenos">425</span></a><span class="k">def</span> <span class="nf">format_time_lambda</span><span class="p">(</span> +</span><span id="format_time_lambda-426"><a href="#format_time_lambda-426"><span class="linenos">426</span></a> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> <span class="n">dialect</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">default</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span> <span class="o">|</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="format_time_lambda-427"><a href="#format_time_lambda-427"><span class="linenos">427</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">],</span> <span class="n">E</span><span class="p">]:</span> +</span><span id="format_time_lambda-428"><a href="#format_time_lambda-428"><span class="linenos">428</span></a><span class="w"> </span><span class="sd">"""Helper used for time expressions.</span> +</span><span id="format_time_lambda-429"><a href="#format_time_lambda-429"><span class="linenos">429</span></a> +</span><span id="format_time_lambda-430"><a href="#format_time_lambda-430"><span class="linenos">430</span></a><span class="sd"> Args:</span> +</span><span id="format_time_lambda-431"><a href="#format_time_lambda-431"><span class="linenos">431</span></a><span class="sd"> exp_class: the expression class to instantiate.</span> +</span><span id="format_time_lambda-432"><a href="#format_time_lambda-432"><span class="linenos">432</span></a><span class="sd"> dialect: target sql dialect.</span> +</span><span id="format_time_lambda-433"><a href="#format_time_lambda-433"><span class="linenos">433</span></a><span class="sd"> default: the default format, True being time.</span> +</span><span id="format_time_lambda-434"><a href="#format_time_lambda-434"><span class="linenos">434</span></a> +</span><span id="format_time_lambda-435"><a href="#format_time_lambda-435"><span class="linenos">435</span></a><span class="sd"> Returns:</span> +</span><span id="format_time_lambda-436"><a href="#format_time_lambda-436"><span class="linenos">436</span></a><span class="sd"> A callable that can be used to return the appropriately formatted time expression.</span> +</span><span id="format_time_lambda-437"><a href="#format_time_lambda-437"><span class="linenos">437</span></a><span class="sd"> """</span> +</span><span id="format_time_lambda-438"><a href="#format_time_lambda-438"><span class="linenos">438</span></a> +</span><span id="format_time_lambda-439"><a href="#format_time_lambda-439"><span class="linenos">439</span></a> <span class="k">def</span> <span class="nf">_format_time</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">):</span> +</span><span id="format_time_lambda-440"><a href="#format_time_lambda-440"><span class="linenos">440</span></a> <span class="k">return</span> <span class="n">exp_class</span><span class="p">(</span> +</span><span id="format_time_lambda-441"><a href="#format_time_lambda-441"><span class="linenos">441</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="format_time_lambda-442"><a href="#format_time_lambda-442"><span class="linenos">442</span></a> <span class="nb">format</span><span class="o">=</span><span class="n">Dialect</span><span class="p">[</span><span class="n">dialect</span><span class="p">]</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span> +</span><span id="format_time_lambda-443"><a href="#format_time_lambda-443"><span class="linenos">443</span></a> <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="format_time_lambda-444"><a href="#format_time_lambda-444"><span class="linenos">444</span></a> <span class="ow">or</span> <span class="p">(</span><span class="n">Dialect</span><span class="p">[</span><span class="n">dialect</span><span class="p">]</span><span class="o">.</span><span class="n">TIME_FORMAT</span> <span class="k">if</span> <span class="n">default</span> <span class="ow">is</span> <span class="kc">True</span> <span class="k">else</span> <span class="n">default</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="format_time_lambda-445"><a href="#format_time_lambda-445"><span class="linenos">445</span></a> <span class="p">),</span> +</span><span id="format_time_lambda-446"><a href="#format_time_lambda-446"><span class="linenos">446</span></a> <span class="p">)</span> +</span><span id="format_time_lambda-447"><a href="#format_time_lambda-447"><span class="linenos">447</span></a> +</span><span id="format_time_lambda-448"><a href="#format_time_lambda-448"><span class="linenos">448</span></a> <span class="k">return</span> <span class="n">_format_time</span> </span></pre></div> @@ -1983,27 +2271,27 @@ </div> <a class="headerlink" href="#create_with_partitions_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="create_with_partitions_sql-389"><a href="#create_with_partitions_sql-389"><span class="linenos">389</span></a><span class="k">def</span> <span class="nf">create_with_partitions_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="create_with_partitions_sql-390"><a href="#create_with_partitions_sql-390"><span class="linenos">390</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="create_with_partitions_sql-391"><a href="#create_with_partitions_sql-391"><span class="linenos">391</span></a><span class="sd"> In Hive and Spark, the PARTITIONED BY property acts as an extension of a table's schema. When the</span> -</span><span id="create_with_partitions_sql-392"><a href="#create_with_partitions_sql-392"><span class="linenos">392</span></a><span class="sd"> PARTITIONED BY value is an array of column names, they are transformed into a schema. The corresponding</span> -</span><span id="create_with_partitions_sql-393"><a href="#create_with_partitions_sql-393"><span class="linenos">393</span></a><span class="sd"> columns are removed from the create statement.</span> -</span><span id="create_with_partitions_sql-394"><a href="#create_with_partitions_sql-394"><span class="linenos">394</span></a><span class="sd"> """</span> -</span><span id="create_with_partitions_sql-395"><a href="#create_with_partitions_sql-395"><span class="linenos">395</span></a> <span class="n">has_schema</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> -</span><span id="create_with_partitions_sql-396"><a href="#create_with_partitions_sql-396"><span class="linenos">396</span></a> <span class="n">is_partitionable</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"TABLE"</span><span class="p">,</span> <span class="s2">"VIEW"</span><span class="p">)</span> -</span><span id="create_with_partitions_sql-397"><a href="#create_with_partitions_sql-397"><span class="linenos">397</span></a> -</span><span id="create_with_partitions_sql-398"><a href="#create_with_partitions_sql-398"><span class="linenos">398</span></a> <span class="k">if</span> <span class="n">has_schema</span> <span class="ow">and</span> <span class="n">is_partitionable</span><span class="p">:</span> -</span><span id="create_with_partitions_sql-399"><a href="#create_with_partitions_sql-399"><span class="linenos">399</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="create_with_partitions_sql-400"><a href="#create_with_partitions_sql-400"><span class="linenos">400</span></a> <span class="n">prop</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">PartitionedByProperty</span><span class="p">)</span> -</span><span id="create_with_partitions_sql-401"><a href="#create_with_partitions_sql-401"><span class="linenos">401</span></a> <span class="k">if</span> <span class="n">prop</span> <span class="ow">and</span> <span class="n">prop</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">prop</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><span id="create_with_partitions_sql-402"><a href="#create_with_partitions_sql-402"><span class="linenos">402</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="create_with_partitions_sql-403"><a href="#create_with_partitions_sql-403"><span class="linenos">403</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="p">{</span><span class="n">v</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="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">prop</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">}</span> -</span><span id="create_with_partitions_sql-404"><a href="#create_with_partitions_sql-404"><span class="linenos">404</span></a> <span class="n">partitions</span> <span class="o">=</span> <span class="p">[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">schema</span><span class="o">.</span><span class="n">expressions</span> <span class="k">if</span> <span class="n">col</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="ow">in</span> <span class="n">columns</span><span class="p">]</span> -</span><span id="create_with_partitions_sql-405"><a href="#create_with_partitions_sql-405"><span class="linenos">405</span></a> <span class="n">schema</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="p">[</span><span class="n">e</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">schema</span><span class="o">.</span><span class="n">expressions</span> <span class="k">if</span> <span class="n">e</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">partitions</span><span class="p">])</span> -</span><span id="create_with_partitions_sql-406"><a href="#create_with_partitions_sql-406"><span class="linenos">406</span></a> <span class="n">prop</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">PartitionedByProperty</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">partitions</span><span class="p">)))</span> -</span><span id="create_with_partitions_sql-407"><a href="#create_with_partitions_sql-407"><span class="linenos">407</span></a> <span class="n">expression</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">schema</span><span class="p">)</span> -</span><span id="create_with_partitions_sql-408"><a href="#create_with_partitions_sql-408"><span class="linenos">408</span></a> -</span><span id="create_with_partitions_sql-409"><a href="#create_with_partitions_sql-409"><span class="linenos">409</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_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="create_with_partitions_sql-451"><a href="#create_with_partitions_sql-451"><span class="linenos">451</span></a><span class="k">def</span> <span class="nf">create_with_partitions_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="create_with_partitions_sql-452"><a href="#create_with_partitions_sql-452"><span class="linenos">452</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="create_with_partitions_sql-453"><a href="#create_with_partitions_sql-453"><span class="linenos">453</span></a><span class="sd"> In Hive and Spark, the PARTITIONED BY property acts as an extension of a table's schema. When the</span> +</span><span id="create_with_partitions_sql-454"><a href="#create_with_partitions_sql-454"><span class="linenos">454</span></a><span class="sd"> PARTITIONED BY value is an array of column names, they are transformed into a schema. The corresponding</span> +</span><span id="create_with_partitions_sql-455"><a href="#create_with_partitions_sql-455"><span class="linenos">455</span></a><span class="sd"> columns are removed from the create statement.</span> +</span><span id="create_with_partitions_sql-456"><a href="#create_with_partitions_sql-456"><span class="linenos">456</span></a><span class="sd"> """</span> +</span><span id="create_with_partitions_sql-457"><a href="#create_with_partitions_sql-457"><span class="linenos">457</span></a> <span class="n">has_schema</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> +</span><span id="create_with_partitions_sql-458"><a href="#create_with_partitions_sql-458"><span class="linenos">458</span></a> <span class="n">is_partitionable</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"TABLE"</span><span class="p">,</span> <span class="s2">"VIEW"</span><span class="p">)</span> +</span><span id="create_with_partitions_sql-459"><a href="#create_with_partitions_sql-459"><span class="linenos">459</span></a> +</span><span id="create_with_partitions_sql-460"><a href="#create_with_partitions_sql-460"><span class="linenos">460</span></a> <span class="k">if</span> <span class="n">has_schema</span> <span class="ow">and</span> <span class="n">is_partitionable</span><span class="p">:</span> +</span><span id="create_with_partitions_sql-461"><a href="#create_with_partitions_sql-461"><span class="linenos">461</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="create_with_partitions_sql-462"><a href="#create_with_partitions_sql-462"><span class="linenos">462</span></a> <span class="n">prop</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">PartitionedByProperty</span><span class="p">)</span> +</span><span id="create_with_partitions_sql-463"><a href="#create_with_partitions_sql-463"><span class="linenos">463</span></a> <span class="k">if</span> <span class="n">prop</span> <span class="ow">and</span> <span class="n">prop</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">prop</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><span id="create_with_partitions_sql-464"><a href="#create_with_partitions_sql-464"><span class="linenos">464</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="create_with_partitions_sql-465"><a href="#create_with_partitions_sql-465"><span class="linenos">465</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="p">{</span><span class="n">v</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="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">prop</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">}</span> +</span><span id="create_with_partitions_sql-466"><a href="#create_with_partitions_sql-466"><span class="linenos">466</span></a> <span class="n">partitions</span> <span class="o">=</span> <span class="p">[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">schema</span><span class="o">.</span><span class="n">expressions</span> <span class="k">if</span> <span class="n">col</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="ow">in</span> <span class="n">columns</span><span class="p">]</span> +</span><span id="create_with_partitions_sql-467"><a href="#create_with_partitions_sql-467"><span class="linenos">467</span></a> <span class="n">schema</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="p">[</span><span class="n">e</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">schema</span><span class="o">.</span><span class="n">expressions</span> <span class="k">if</span> <span class="n">e</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">partitions</span><span class="p">])</span> +</span><span id="create_with_partitions_sql-468"><a href="#create_with_partitions_sql-468"><span class="linenos">468</span></a> <span class="n">prop</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">PartitionedByProperty</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">partitions</span><span class="p">)))</span> +</span><span id="create_with_partitions_sql-469"><a href="#create_with_partitions_sql-469"><span class="linenos">469</span></a> <span class="n">expression</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">schema</span><span class="p">)</span> +</span><span id="create_with_partitions_sql-470"><a href="#create_with_partitions_sql-470"><span class="linenos">470</span></a> +</span><span id="create_with_partitions_sql-471"><a href="#create_with_partitions_sql-471"><span class="linenos">471</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -2025,17 +2313,17 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#parse_date_delta"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="parse_date_delta-412"><a href="#parse_date_delta-412"><span class="linenos">412</span></a><span class="k">def</span> <span class="nf">parse_date_delta</span><span class="p">(</span> -</span><span id="parse_date_delta-413"><a href="#parse_date_delta-413"><span class="linenos">413</span></a> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> <span class="n">unit_mapping</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="parse_date_delta-414"><a href="#parse_date_delta-414"><span class="linenos">414</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">],</span> <span class="n">E</span><span class="p">]:</span> -</span><span id="parse_date_delta-415"><a href="#parse_date_delta-415"><span class="linenos">415</span></a> <span class="k">def</span> <span class="nf">inner_func</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="parse_date_delta-416"><a href="#parse_date_delta-416"><span class="linenos">416</span></a> <span class="n">unit_based</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span> -</span><span id="parse_date_delta-417"><a href="#parse_date_delta-417"><span class="linenos">417</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="k">if</span> <span class="n">unit_based</span> <span class="k">else</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="parse_date_delta-418"><a href="#parse_date_delta-418"><span class="linenos">418</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">if</span> <span class="n">unit_based</span> <span class="k">else</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">"DAY"</span><span class="p">)</span> -</span><span id="parse_date_delta-419"><a href="#parse_date_delta-419"><span class="linenos">419</span></a> <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="n">unit_mapping</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">unit</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> <span class="n">unit</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> <span class="k">if</span> <span class="n">unit_mapping</span> <span class="k">else</span> <span class="n">unit</span> -</span><span id="parse_date_delta-420"><a href="#parse_date_delta-420"><span class="linenos">420</span></a> <span class="k">return</span> <span class="n">exp_class</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">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">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">)</span> -</span><span id="parse_date_delta-421"><a href="#parse_date_delta-421"><span class="linenos">421</span></a> -</span><span id="parse_date_delta-422"><a href="#parse_date_delta-422"><span class="linenos">422</span></a> <span class="k">return</span> <span class="n">inner_func</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="parse_date_delta-474"><a href="#parse_date_delta-474"><span class="linenos">474</span></a><span class="k">def</span> <span class="nf">parse_date_delta</span><span class="p">(</span> +</span><span id="parse_date_delta-475"><a href="#parse_date_delta-475"><span class="linenos">475</span></a> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> <span class="n">unit_mapping</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="parse_date_delta-476"><a href="#parse_date_delta-476"><span class="linenos">476</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">],</span> <span class="n">E</span><span class="p">]:</span> +</span><span id="parse_date_delta-477"><a href="#parse_date_delta-477"><span class="linenos">477</span></a> <span class="k">def</span> <span class="nf">inner_func</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="parse_date_delta-478"><a href="#parse_date_delta-478"><span class="linenos">478</span></a> <span class="n">unit_based</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span> +</span><span id="parse_date_delta-479"><a href="#parse_date_delta-479"><span class="linenos">479</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="k">if</span> <span class="n">unit_based</span> <span class="k">else</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="parse_date_delta-480"><a href="#parse_date_delta-480"><span class="linenos">480</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">if</span> <span class="n">unit_based</span> <span class="k">else</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">"DAY"</span><span class="p">)</span> +</span><span id="parse_date_delta-481"><a href="#parse_date_delta-481"><span class="linenos">481</span></a> <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="n">unit_mapping</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">unit</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> <span class="n">unit</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> <span class="k">if</span> <span class="n">unit_mapping</span> <span class="k">else</span> <span class="n">unit</span> +</span><span id="parse_date_delta-482"><a href="#parse_date_delta-482"><span class="linenos">482</span></a> <span class="k">return</span> <span class="n">exp_class</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">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">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">)</span> +</span><span id="parse_date_delta-483"><a href="#parse_date_delta-483"><span class="linenos">483</span></a> +</span><span id="parse_date_delta-484"><a href="#parse_date_delta-484"><span class="linenos">484</span></a> <span class="k">return</span> <span class="n">inner_func</span> </span></pre></div> @@ -2053,23 +2341,23 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#parse_date_delta_with_interval"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="parse_date_delta_with_interval-425"><a href="#parse_date_delta_with_interval-425"><span class="linenos">425</span></a><span class="k">def</span> <span class="nf">parse_date_delta_with_interval</span><span class="p">(</span> -</span><span id="parse_date_delta_with_interval-426"><a href="#parse_date_delta_with_interval-426"><span class="linenos">426</span></a> <span class="n">expression_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> -</span><span id="parse_date_delta_with_interval-427"><a href="#parse_date_delta_with_interval-427"><span class="linenos">427</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">t</span><span class="o">.</span><span class="n">List</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">E</span><span class="p">]]:</span> -</span><span id="parse_date_delta_with_interval-428"><a href="#parse_date_delta_with_interval-428"><span class="linenos">428</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">E</span><span class="p">]:</span> -</span><span id="parse_date_delta_with_interval-429"><a href="#parse_date_delta_with_interval-429"><span class="linenos">429</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o"><</span> <span class="mi">2</span><span class="p">:</span> -</span><span id="parse_date_delta_with_interval-430"><a href="#parse_date_delta_with_interval-430"><span class="linenos">430</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="parse_date_delta_with_interval-431"><a href="#parse_date_delta_with_interval-431"><span class="linenos">431</span></a> -</span><span id="parse_date_delta_with_interval-432"><a href="#parse_date_delta_with_interval-432"><span class="linenos">432</span></a> <span class="n">interval</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> -</span><span id="parse_date_delta_with_interval-433"><a href="#parse_date_delta_with_interval-433"><span class="linenos">433</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">interval</span><span class="o">.</span><span class="n">this</span> -</span><span id="parse_date_delta_with_interval-434"><a href="#parse_date_delta_with_interval-434"><span class="linenos">434</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> -</span><span id="parse_date_delta_with_interval-435"><a href="#parse_date_delta_with_interval-435"><span class="linenos">435</span></a> <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="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="parse_date_delta_with_interval-436"><a href="#parse_date_delta_with_interval-436"><span class="linenos">436</span></a> -</span><span id="parse_date_delta_with_interval-437"><a href="#parse_date_delta_with_interval-437"><span class="linenos">437</span></a> <span class="k">return</span> <span class="n">expression_class</span><span class="p">(</span> -</span><span id="parse_date_delta_with_interval-438"><a href="#parse_date_delta_with_interval-438"><span class="linenos">438</span></a> <span class="n">this</span><span class="o">=</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">expression</span><span class="p">,</span> <span class="n">unit</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="n">interval</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">))</span> -</span><span id="parse_date_delta_with_interval-439"><a href="#parse_date_delta_with_interval-439"><span class="linenos">439</span></a> <span class="p">)</span> -</span><span id="parse_date_delta_with_interval-440"><a href="#parse_date_delta_with_interval-440"><span class="linenos">440</span></a> -</span><span id="parse_date_delta_with_interval-441"><a href="#parse_date_delta_with_interval-441"><span class="linenos">441</span></a> <span class="k">return</span> <span class="n">func</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="parse_date_delta_with_interval-487"><a href="#parse_date_delta_with_interval-487"><span class="linenos">487</span></a><span class="k">def</span> <span class="nf">parse_date_delta_with_interval</span><span class="p">(</span> +</span><span id="parse_date_delta_with_interval-488"><a href="#parse_date_delta_with_interval-488"><span class="linenos">488</span></a> <span class="n">expression_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> +</span><span id="parse_date_delta_with_interval-489"><a href="#parse_date_delta_with_interval-489"><span class="linenos">489</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">t</span><span class="o">.</span><span class="n">List</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">E</span><span class="p">]]:</span> +</span><span id="parse_date_delta_with_interval-490"><a href="#parse_date_delta_with_interval-490"><span class="linenos">490</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">E</span><span class="p">]:</span> +</span><span id="parse_date_delta_with_interval-491"><a href="#parse_date_delta_with_interval-491"><span class="linenos">491</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o"><</span> <span class="mi">2</span><span class="p">:</span> +</span><span id="parse_date_delta_with_interval-492"><a href="#parse_date_delta_with_interval-492"><span class="linenos">492</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="parse_date_delta_with_interval-493"><a href="#parse_date_delta_with_interval-493"><span class="linenos">493</span></a> +</span><span id="parse_date_delta_with_interval-494"><a href="#parse_date_delta_with_interval-494"><span class="linenos">494</span></a> <span class="n">interval</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> +</span><span id="parse_date_delta_with_interval-495"><a href="#parse_date_delta_with_interval-495"><span class="linenos">495</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">interval</span><span class="o">.</span><span class="n">this</span> +</span><span id="parse_date_delta_with_interval-496"><a href="#parse_date_delta_with_interval-496"><span class="linenos">496</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> +</span><span id="parse_date_delta_with_interval-497"><a href="#parse_date_delta_with_interval-497"><span class="linenos">497</span></a> <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="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="parse_date_delta_with_interval-498"><a href="#parse_date_delta_with_interval-498"><span class="linenos">498</span></a> +</span><span id="parse_date_delta_with_interval-499"><a href="#parse_date_delta_with_interval-499"><span class="linenos">499</span></a> <span class="k">return</span> <span class="n">expression_class</span><span class="p">(</span> +</span><span id="parse_date_delta_with_interval-500"><a href="#parse_date_delta_with_interval-500"><span class="linenos">500</span></a> <span class="n">this</span><span class="o">=</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">expression</span><span class="p">,</span> <span class="n">unit</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="n">interval</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">))</span> +</span><span id="parse_date_delta_with_interval-501"><a href="#parse_date_delta_with_interval-501"><span class="linenos">501</span></a> <span class="p">)</span> +</span><span id="parse_date_delta_with_interval-502"><a href="#parse_date_delta_with_interval-502"><span class="linenos">502</span></a> +</span><span id="parse_date_delta_with_interval-503"><a href="#parse_date_delta_with_interval-503"><span class="linenos">503</span></a> <span class="k">return</span> <span class="n">func</span> </span></pre></div> @@ -2087,13 +2375,13 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#date_trunc_to_time"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="date_trunc_to_time-444"><a href="#date_trunc_to_time-444"><span class="linenos">444</span></a><span class="k">def</span> <span class="nf">date_trunc_to_time</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">:</span> -</span><span id="date_trunc_to_time-445"><a href="#date_trunc_to_time-445"><span class="linenos">445</span></a> <span class="n">unit</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="date_trunc_to_time-446"><a href="#date_trunc_to_time-446"><span class="linenos">446</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">1</span><span class="p">)</span> -</span><span id="date_trunc_to_time-447"><a href="#date_trunc_to_time-447"><span class="linenos">447</span></a> -</span><span id="date_trunc_to_time-448"><a href="#date_trunc_to_time-448"><span class="linenos">448</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">Cast</span><span class="p">)</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"date"</span><span class="p">):</span> -</span><span id="date_trunc_to_time-449"><a href="#date_trunc_to_time-449"><span class="linenos">449</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</span><span class="p">(</span><span class="n">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> -</span><span id="date_trunc_to_time-450"><a href="#date_trunc_to_time-450"><span class="linenos">450</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="date_trunc_to_time-506"><a href="#date_trunc_to_time-506"><span class="linenos">506</span></a><span class="k">def</span> <span class="nf">date_trunc_to_time</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">:</span> +</span><span id="date_trunc_to_time-507"><a href="#date_trunc_to_time-507"><span class="linenos">507</span></a> <span class="n">unit</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="date_trunc_to_time-508"><a href="#date_trunc_to_time-508"><span class="linenos">508</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">1</span><span class="p">)</span> +</span><span id="date_trunc_to_time-509"><a href="#date_trunc_to_time-509"><span class="linenos">509</span></a> +</span><span id="date_trunc_to_time-510"><a href="#date_trunc_to_time-510"><span class="linenos">510</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">Cast</span><span class="p">)</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"date"</span><span class="p">):</span> +</span><span id="date_trunc_to_time-511"><a href="#date_trunc_to_time-511"><span class="linenos">511</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateTrunc</span><span class="p">(</span><span class="n">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> +</span><span id="date_trunc_to_time-512"><a href="#date_trunc_to_time-512"><span class="linenos">512</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">)</span> </span></pre></div> @@ -2111,10 +2399,10 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#timestamptrunc_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="timestamptrunc_sql-453"><a href="#timestamptrunc_sql-453"><span class="linenos">453</span></a><span class="k">def</span> <span class="nf">timestamptrunc_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="timestamptrunc_sql-454"><a href="#timestamptrunc_sql-454"><span class="linenos">454</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="timestamptrunc_sql-455"><a href="#timestamptrunc_sql-455"><span class="linenos">455</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"day"</span><span class="p">),</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="timestamptrunc_sql-456"><a href="#timestamptrunc_sql-456"><span class="linenos">456</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="timestamptrunc_sql-515"><a href="#timestamptrunc_sql-515"><span class="linenos">515</span></a><span class="k">def</span> <span class="nf">timestamptrunc_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="timestamptrunc_sql-516"><a href="#timestamptrunc_sql-516"><span class="linenos">516</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="timestamptrunc_sql-517"><a href="#timestamptrunc_sql-517"><span class="linenos">517</span></a> <span class="s2">"DATE_TRUNC"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"day"</span><span class="p">),</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="timestamptrunc_sql-518"><a href="#timestamptrunc_sql-518"><span class="linenos">518</span></a> <span class="p">)</span> </span></pre></div> @@ -2132,10 +2420,10 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#locate_to_strposition"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="locate_to_strposition-459"><a href="#locate_to_strposition-459"><span class="linenos">459</span></a><span class="k">def</span> <span class="nf">locate_to_strposition</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="locate_to_strposition-460"><a href="#locate_to_strposition-460"><span class="linenos">460</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">(</span> -</span><span id="locate_to_strposition-461"><a href="#locate_to_strposition-461"><span class="linenos">461</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">1</span><span class="p">),</span> <span class="n">substr</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">position</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="locate_to_strposition-462"><a href="#locate_to_strposition-462"><span class="linenos">462</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="locate_to_strposition-521"><a href="#locate_to_strposition-521"><span class="linenos">521</span></a><span class="k">def</span> <span class="nf">locate_to_strposition</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="locate_to_strposition-522"><a href="#locate_to_strposition-522"><span class="linenos">522</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">(</span> +</span><span id="locate_to_strposition-523"><a href="#locate_to_strposition-523"><span class="linenos">523</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">1</span><span class="p">),</span> <span class="n">substr</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">position</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="locate_to_strposition-524"><a href="#locate_to_strposition-524"><span class="linenos">524</span></a> <span class="p">)</span> </span></pre></div> @@ -2153,10 +2441,10 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#strposition_to_locate_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="strposition_to_locate_sql-465"><a href="#strposition_to_locate_sql-465"><span class="linenos">465</span></a><span class="k">def</span> <span class="nf">strposition_to_locate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="strposition_to_locate_sql-466"><a href="#strposition_to_locate_sql-466"><span class="linenos">466</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="strposition_to_locate_sql-467"><a href="#strposition_to_locate_sql-467"><span class="linenos">467</span></a> <span class="s2">"LOCATE"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"substr"</span><span class="p">),</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"position"</span><span class="p">)</span> -</span><span id="strposition_to_locate_sql-468"><a href="#strposition_to_locate_sql-468"><span class="linenos">468</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="strposition_to_locate_sql-527"><a href="#strposition_to_locate_sql-527"><span class="linenos">527</span></a><span class="k">def</span> <span class="nf">strposition_to_locate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="strposition_to_locate_sql-528"><a href="#strposition_to_locate_sql-528"><span class="linenos">528</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="strposition_to_locate_sql-529"><a href="#strposition_to_locate_sql-529"><span class="linenos">529</span></a> <span class="s2">"LOCATE"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"substr"</span><span class="p">),</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"position"</span><span class="p">)</span> +</span><span id="strposition_to_locate_sql-530"><a href="#strposition_to_locate_sql-530"><span class="linenos">530</span></a> <span class="p">)</span> </span></pre></div> @@ -2174,13 +2462,13 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#left_to_substring_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="left_to_substring_sql-471"><a href="#left_to_substring_sql-471"><span class="linenos">471</span></a><span class="k">def</span> <span class="nf">left_to_substring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="left_to_substring_sql-472"><a href="#left_to_substring_sql-472"><span class="linenos">472</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="left_to_substring_sql-473"><a href="#left_to_substring_sql-473"><span class="linenos">473</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="left_to_substring_sql-474"><a href="#left_to_substring_sql-474"><span class="linenos">474</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Substring</span><span class="p">(</span> -</span><span id="left_to_substring_sql-475"><a href="#left_to_substring_sql-475"><span class="linenos">475</span></a> <span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">length</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span> -</span><span id="left_to_substring_sql-476"><a href="#left_to_substring_sql-476"><span class="linenos">476</span></a> <span class="p">)</span> -</span><span id="left_to_substring_sql-477"><a href="#left_to_substring_sql-477"><span class="linenos">477</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="left_to_substring_sql-533"><a href="#left_to_substring_sql-533"><span class="linenos">533</span></a><span class="k">def</span> <span class="nf">left_to_substring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="left_to_substring_sql-534"><a href="#left_to_substring_sql-534"><span class="linenos">534</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="left_to_substring_sql-535"><a href="#left_to_substring_sql-535"><span class="linenos">535</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="left_to_substring_sql-536"><a href="#left_to_substring_sql-536"><span class="linenos">536</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Substring</span><span class="p">(</span> +</span><span id="left_to_substring_sql-537"><a href="#left_to_substring_sql-537"><span class="linenos">537</span></a> <span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">length</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span> +</span><span id="left_to_substring_sql-538"><a href="#left_to_substring_sql-538"><span class="linenos">538</span></a> <span class="p">)</span> +</span><span id="left_to_substring_sql-539"><a href="#left_to_substring_sql-539"><span class="linenos">539</span></a> <span class="p">)</span> </span></pre></div> @@ -2198,14 +2486,14 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#right_to_substring_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="right_to_substring_sql-480"><a href="#right_to_substring_sql-480"><span class="linenos">480</span></a><span class="k">def</span> <span class="nf">right_to_substring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="right_to_substring_sql-481"><a href="#right_to_substring_sql-481"><span class="linenos">481</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="right_to_substring_sql-482"><a href="#right_to_substring_sql-482"><span class="linenos">482</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="right_to_substring_sql-483"><a href="#right_to_substring_sql-483"><span class="linenos">483</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Substring</span><span class="p">(</span> -</span><span id="right_to_substring_sql-484"><a href="#right_to_substring_sql-484"><span class="linenos">484</span></a> <span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="right_to_substring_sql-485"><a href="#right_to_substring_sql-485"><span class="linenos">485</span></a> <span class="n">start</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Length</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="o">-</span> <span class="n">exp</span><span class="o">.</span><span class="n">paren</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> -</span><span id="right_to_substring_sql-486"><a href="#right_to_substring_sql-486"><span class="linenos">486</span></a> <span class="p">)</span> -</span><span id="right_to_substring_sql-487"><a href="#right_to_substring_sql-487"><span class="linenos">487</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="right_to_substring_sql-542"><a href="#right_to_substring_sql-542"><span class="linenos">542</span></a><span class="k">def</span> <span class="nf">right_to_substring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="right_to_substring_sql-543"><a href="#right_to_substring_sql-543"><span class="linenos">543</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="right_to_substring_sql-544"><a href="#right_to_substring_sql-544"><span class="linenos">544</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="right_to_substring_sql-545"><a href="#right_to_substring_sql-545"><span class="linenos">545</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Substring</span><span class="p">(</span> +</span><span id="right_to_substring_sql-546"><a href="#right_to_substring_sql-546"><span class="linenos">546</span></a> <span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="right_to_substring_sql-547"><a href="#right_to_substring_sql-547"><span class="linenos">547</span></a> <span class="n">start</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Length</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="o">-</span> <span class="n">exp</span><span class="o">.</span><span class="n">paren</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span> <span class="o">-</span> <span class="mi">1</span><span class="p">),</span> +</span><span id="right_to_substring_sql-548"><a href="#right_to_substring_sql-548"><span class="linenos">548</span></a> <span class="p">)</span> +</span><span id="right_to_substring_sql-549"><a href="#right_to_substring_sql-549"><span class="linenos">549</span></a> <span class="p">)</span> </span></pre></div> @@ -2223,8 +2511,8 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#timestrtotime_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="timestrtotime_sql-490"><a href="#timestrtotime_sql-490"><span class="linenos">490</span></a><span class="k">def</span> <span class="nf">timestrtotime_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="timestrtotime_sql-491"><a href="#timestrtotime_sql-491"><span class="linenos">491</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">sql</span><span class="p">(</span><span class="n">expression</span><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 TIMESTAMP)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="timestrtotime_sql-552"><a href="#timestrtotime_sql-552"><span class="linenos">552</span></a><span class="k">def</span> <span class="nf">timestrtotime_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="timestrtotime_sql-553"><a href="#timestrtotime_sql-553"><span class="linenos">553</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">sql</span><span class="p">(</span><span class="n">expression</span><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 TIMESTAMP)"</span> </span></pre></div> @@ -2242,8 +2530,8 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#datestrtodate_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="datestrtodate_sql-494"><a href="#datestrtodate_sql-494"><span class="linenos">494</span></a><span class="k">def</span> <span class="nf">datestrtodate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="datestrtodate_sql-495"><a href="#datestrtodate_sql-495"><span class="linenos">495</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">sql</span><span class="p">(</span><span class="n">expression</span><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 DATE)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="datestrtodate_sql-556"><a href="#datestrtodate_sql-556"><span class="linenos">556</span></a><span class="k">def</span> <span class="nf">datestrtodate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="datestrtodate_sql-557"><a href="#datestrtodate_sql-557"><span class="linenos">557</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">sql</span><span class="p">(</span><span class="n">expression</span><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 DATE)"</span> </span></pre></div> @@ -2261,9 +2549,9 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#min_or_least"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="min_or_least-498"><a href="#min_or_least-498"><span class="linenos">498</span></a><span class="k">def</span> <span class="nf">min_or_least</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="min_or_least-499"><a href="#min_or_least-499"><span class="linenos">499</span></a> <span class="n">name</span> <span class="o">=</span> <span class="s2">"LEAST"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">"MIN"</span> -</span><span id="min_or_least-500"><a href="#min_or_least-500"><span class="linenos">500</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="n">name</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="min_or_least-560"><a href="#min_or_least-560"><span class="linenos">560</span></a><span class="k">def</span> <span class="nf">min_or_least</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="min_or_least-561"><a href="#min_or_least-561"><span class="linenos">561</span></a> <span class="n">name</span> <span class="o">=</span> <span class="s2">"LEAST"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">"MIN"</span> +</span><span id="min_or_least-562"><a href="#min_or_least-562"><span class="linenos">562</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="n">name</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -2281,9 +2569,9 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#max_or_greatest"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="max_or_greatest-503"><a href="#max_or_greatest-503"><span class="linenos">503</span></a><span class="k">def</span> <span class="nf">max_or_greatest</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="max_or_greatest-504"><a href="#max_or_greatest-504"><span class="linenos">504</span></a> <span class="n">name</span> <span class="o">=</span> <span class="s2">"GREATEST"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">"MAX"</span> -</span><span id="max_or_greatest-505"><a href="#max_or_greatest-505"><span class="linenos">505</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="n">name</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="max_or_greatest-565"><a href="#max_or_greatest-565"><span class="linenos">565</span></a><span class="k">def</span> <span class="nf">max_or_greatest</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="max_or_greatest-566"><a href="#max_or_greatest-566"><span class="linenos">566</span></a> <span class="n">name</span> <span class="o">=</span> <span class="s2">"GREATEST"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">"MAX"</span> +</span><span id="max_or_greatest-567"><a href="#max_or_greatest-567"><span class="linenos">567</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="n">name</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -2301,14 +2589,14 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#count_if_to_sum"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="count_if_to_sum-508"><a href="#count_if_to_sum-508"><span class="linenos">508</span></a><span class="k">def</span> <span class="nf">count_if_to_sum</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CountIf</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="count_if_to_sum-509"><a href="#count_if_to_sum-509"><span class="linenos">509</span></a> <span class="n">cond</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="count_if_to_sum-510"><a href="#count_if_to_sum-510"><span class="linenos">510</span></a> -</span><span id="count_if_to_sum-511"><a href="#count_if_to_sum-511"><span class="linenos">511</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distinct</span><span class="p">):</span> -</span><span id="count_if_to_sum-512"><a href="#count_if_to_sum-512"><span class="linenos">512</span></a> <span class="n">cond</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="count_if_to_sum-513"><a href="#count_if_to_sum-513"><span class="linenos">513</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"DISTINCT is not supported when converting COUNT_IF to SUM"</span><span class="p">)</span> -</span><span id="count_if_to_sum-514"><a href="#count_if_to_sum-514"><span class="linenos">514</span></a> -</span><span id="count_if_to_sum-515"><a href="#count_if_to_sum-515"><span class="linenos">515</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">"sum"</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">"if"</span><span class="p">,</span> <span class="n">cond</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="count_if_to_sum-570"><a href="#count_if_to_sum-570"><span class="linenos">570</span></a><span class="k">def</span> <span class="nf">count_if_to_sum</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CountIf</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="count_if_to_sum-571"><a href="#count_if_to_sum-571"><span class="linenos">571</span></a> <span class="n">cond</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="count_if_to_sum-572"><a href="#count_if_to_sum-572"><span class="linenos">572</span></a> +</span><span id="count_if_to_sum-573"><a href="#count_if_to_sum-573"><span class="linenos">573</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distinct</span><span class="p">):</span> +</span><span id="count_if_to_sum-574"><a href="#count_if_to_sum-574"><span class="linenos">574</span></a> <span class="n">cond</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="count_if_to_sum-575"><a href="#count_if_to_sum-575"><span class="linenos">575</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"DISTINCT is not supported when converting COUNT_IF to SUM"</span><span class="p">)</span> +</span><span id="count_if_to_sum-576"><a href="#count_if_to_sum-576"><span class="linenos">576</span></a> +</span><span id="count_if_to_sum-577"><a href="#count_if_to_sum-577"><span class="linenos">577</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">"sum"</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">"if"</span><span class="p">,</span> <span class="n">cond</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span> </span></pre></div> @@ -2326,21 +2614,21 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#trim_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="trim_sql-518"><a href="#trim_sql-518"><span class="linenos">518</span></a><span class="k">def</span> <span class="nf">trim_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">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">Trim</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="trim_sql-519"><a href="#trim_sql-519"><span class="linenos">519</span></a> <span class="n">target</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="trim_sql-520"><a href="#trim_sql-520"><span class="linenos">520</span></a> <span class="n">trim_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> -</span><span id="trim_sql-521"><a href="#trim_sql-521"><span class="linenos">521</span></a> <span class="n">remove_chars</span> <span class="o">=</span> <span class="bp">self</span><span 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="trim_sql-522"><a href="#trim_sql-522"><span class="linenos">522</span></a> <span class="n">collation</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collation"</span><span class="p">)</span> -</span><span id="trim_sql-523"><a href="#trim_sql-523"><span class="linenos">523</span></a> -</span><span id="trim_sql-524"><a href="#trim_sql-524"><span class="linenos">524</span></a> <span class="c1"># Use TRIM/LTRIM/RTRIM syntax if the expression isn't database-specific</span> -</span><span id="trim_sql-525"><a href="#trim_sql-525"><span class="linenos">525</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">remove_chars</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">collation</span><span class="p">:</span> -</span><span id="trim_sql-526"><a href="#trim_sql-526"><span class="linenos">526</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">trim_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="trim_sql-527"><a href="#trim_sql-527"><span class="linenos">527</span></a> -</span><span id="trim_sql-528"><a href="#trim_sql-528"><span class="linenos">528</span></a> <span class="n">trim_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">trim_type</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">trim_type</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="trim_sql-529"><a href="#trim_sql-529"><span class="linenos">529</span></a> <span class="n">remove_chars</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">remove_chars</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">remove_chars</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="trim_sql-530"><a href="#trim_sql-530"><span class="linenos">530</span></a> <span class="n">from_part</span> <span class="o">=</span> <span class="s2">"FROM "</span> <span class="k">if</span> <span class="n">trim_type</span> <span class="ow">or</span> <span class="n">remove_chars</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="trim_sql-531"><a href="#trim_sql-531"><span class="linenos">531</span></a> <span class="n">collation</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collation</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collation</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="trim_sql-532"><a href="#trim_sql-532"><span class="linenos">532</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TRIM(</span><span class="si">{</span><span class="n">trim_type</span><span class="si">}{</span><span class="n">remove_chars</span><span class="si">}{</span><span class="n">from_part</span><span class="si">}{</span><span class="n">target</span><span class="si">}{</span><span class="n">collation</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="trim_sql-580"><a href="#trim_sql-580"><span class="linenos">580</span></a><span class="k">def</span> <span class="nf">trim_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">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">Trim</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="trim_sql-581"><a href="#trim_sql-581"><span class="linenos">581</span></a> <span class="n">target</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="trim_sql-582"><a href="#trim_sql-582"><span class="linenos">582</span></a> <span class="n">trim_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> +</span><span id="trim_sql-583"><a href="#trim_sql-583"><span class="linenos">583</span></a> <span class="n">remove_chars</span> <span class="o">=</span> <span class="bp">self</span><span 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="trim_sql-584"><a href="#trim_sql-584"><span class="linenos">584</span></a> <span class="n">collation</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collation"</span><span class="p">)</span> +</span><span id="trim_sql-585"><a href="#trim_sql-585"><span class="linenos">585</span></a> +</span><span id="trim_sql-586"><a href="#trim_sql-586"><span class="linenos">586</span></a> <span class="c1"># Use TRIM/LTRIM/RTRIM syntax if the expression isn't database-specific</span> +</span><span id="trim_sql-587"><a href="#trim_sql-587"><span class="linenos">587</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">remove_chars</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">collation</span><span class="p">:</span> +</span><span id="trim_sql-588"><a href="#trim_sql-588"><span class="linenos">588</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">trim_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="trim_sql-589"><a href="#trim_sql-589"><span class="linenos">589</span></a> +</span><span id="trim_sql-590"><a href="#trim_sql-590"><span class="linenos">590</span></a> <span class="n">trim_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">trim_type</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">trim_type</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="trim_sql-591"><a href="#trim_sql-591"><span class="linenos">591</span></a> <span class="n">remove_chars</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">remove_chars</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">remove_chars</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="trim_sql-592"><a href="#trim_sql-592"><span class="linenos">592</span></a> <span class="n">from_part</span> <span class="o">=</span> <span class="s2">"FROM "</span> <span class="k">if</span> <span class="n">trim_type</span> <span class="ow">or</span> <span class="n">remove_chars</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="trim_sql-593"><a href="#trim_sql-593"><span class="linenos">593</span></a> <span class="n">collation</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collation</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collation</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="trim_sql-594"><a href="#trim_sql-594"><span class="linenos">594</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TRIM(</span><span class="si">{</span><span class="n">trim_type</span><span class="si">}{</span><span class="n">remove_chars</span><span class="si">}{</span><span class="n">from_part</span><span class="si">}{</span><span class="n">target</span><span class="si">}{</span><span class="n">collation</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -2358,8 +2646,8 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#str_to_time_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="str_to_time_sql-535"><a href="#str_to_time_sql-535"><span class="linenos">535</span></a><span class="k">def</span> <span class="nf">str_to_time_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="str_to_time_sql-536"><a href="#str_to_time_sql-536"><span class="linenos">536</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">"STRPTIME"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="str_to_time_sql-597"><a href="#str_to_time_sql-597"><span class="linenos">597</span></a><span class="k">def</span> <span class="nf">str_to_time_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="str_to_time_sql-598"><a href="#str_to_time_sql-598"><span class="linenos">598</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">"STRPTIME"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_time</span><span class="p">(</span><span class="n">expression</span><span class="p">))</span> </span></pre></div> @@ -2377,15 +2665,15 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#ts_or_ds_to_date_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ts_or_ds_to_date_sql-539"><a href="#ts_or_ds_to_date_sql-539"><span class="linenos">539</span></a><span class="k">def</span> <span class="nf">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="n">dialect</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">:</span> -</span><span id="ts_or_ds_to_date_sql-540"><a href="#ts_or_ds_to_date_sql-540"><span class="linenos">540</span></a> <span class="k">def</span> <span class="nf">_ts_or_ds_to_date_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="ts_or_ds_to_date_sql-541"><a href="#ts_or_ds_to_date_sql-541"><span class="linenos">541</span></a> <span class="n">_dialect</span> <span class="o">=</span> <span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span> -</span><span id="ts_or_ds_to_date_sql-542"><a href="#ts_or_ds_to_date_sql-542"><span class="linenos">542</span></a> <span class="n">time_format</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="ts_or_ds_to_date_sql-543"><a href="#ts_or_ds_to_date_sql-543"><span class="linenos">543</span></a> <span class="k">if</span> <span class="n">time_format</span> <span class="ow">and</span> <span class="n">time_format</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span><span class="n">_dialect</span><span class="o">.</span><span class="n">TIME_FORMAT</span><span class="p">,</span> <span class="n">_dialect</span><span class="o">.</span><span class="n">DATE_FORMAT</span><span class="p">):</span> -</span><span id="ts_or_ds_to_date_sql-544"><a href="#ts_or_ds_to_date_sql-544"><span class="linenos">544</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="ts_or_ds_to_date_sql-545"><a href="#ts_or_ds_to_date_sql-545"><span class="linenos">545</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">sql</span><span class="p">(</span><span class="n">expression</span><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 DATE)"</span> -</span><span id="ts_or_ds_to_date_sql-546"><a href="#ts_or_ds_to_date_sql-546"><span class="linenos">546</span></a> -</span><span id="ts_or_ds_to_date_sql-547"><a href="#ts_or_ds_to_date_sql-547"><span class="linenos">547</span></a> <span class="k">return</span> <span class="n">_ts_or_ds_to_date_sql</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ts_or_ds_to_date_sql-601"><a href="#ts_or_ds_to_date_sql-601"><span class="linenos">601</span></a><span class="k">def</span> <span class="nf">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="n">dialect</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">:</span> +</span><span id="ts_or_ds_to_date_sql-602"><a href="#ts_or_ds_to_date_sql-602"><span class="linenos">602</span></a> <span class="k">def</span> <span class="nf">_ts_or_ds_to_date_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="ts_or_ds_to_date_sql-603"><a href="#ts_or_ds_to_date_sql-603"><span class="linenos">603</span></a> <span class="n">_dialect</span> <span class="o">=</span> <span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span> +</span><span id="ts_or_ds_to_date_sql-604"><a href="#ts_or_ds_to_date_sql-604"><span class="linenos">604</span></a> <span class="n">time_format</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="ts_or_ds_to_date_sql-605"><a href="#ts_or_ds_to_date_sql-605"><span class="linenos">605</span></a> <span class="k">if</span> <span class="n">time_format</span> <span class="ow">and</span> <span class="n">time_format</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span><span class="n">_dialect</span><span class="o">.</span><span class="n">TIME_FORMAT</span><span class="p">,</span> <span class="n">_dialect</span><span class="o">.</span><span class="n">DATE_FORMAT</span><span class="p">):</span> +</span><span id="ts_or_ds_to_date_sql-606"><a href="#ts_or_ds_to_date_sql-606"><span class="linenos">606</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="ts_or_ds_to_date_sql-607"><a href="#ts_or_ds_to_date_sql-607"><span class="linenos">607</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">sql</span><span class="p">(</span><span class="n">expression</span><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 DATE)"</span> +</span><span id="ts_or_ds_to_date_sql-608"><a href="#ts_or_ds_to_date_sql-608"><span class="linenos">608</span></a> +</span><span id="ts_or_ds_to_date_sql-609"><a href="#ts_or_ds_to_date_sql-609"><span class="linenos">609</span></a> <span class="k">return</span> <span class="n">_ts_or_ds_to_date_sql</span> </span></pre></div> @@ -2403,12 +2691,12 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#concat_to_dpipe_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="concat_to_dpipe_sql-550"><a href="#concat_to_dpipe_sql-550"><span class="linenos">550</span></a><span class="k">def</span> <span class="nf">concat_to_dpipe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="concat_to_dpipe_sql-551"><a href="#concat_to_dpipe_sql-551"><span class="linenos">551</span></a> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest_args</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="concat_to_dpipe_sql-552"><a href="#concat_to_dpipe_sql-552"><span class="linenos">552</span></a> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">rest_args</span><span class="p">:</span> -</span><span id="concat_to_dpipe_sql-553"><a href="#concat_to_dpipe_sql-553"><span class="linenos">553</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DPipe</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">arg</span><span class="p">)</span> -</span><span id="concat_to_dpipe_sql-554"><a href="#concat_to_dpipe_sql-554"><span class="linenos">554</span></a> -</span><span id="concat_to_dpipe_sql-555"><a href="#concat_to_dpipe_sql-555"><span class="linenos">555</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">this</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="concat_to_dpipe_sql-612"><a href="#concat_to_dpipe_sql-612"><span class="linenos">612</span></a><span class="k">def</span> <span class="nf">concat_to_dpipe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="concat_to_dpipe_sql-613"><a href="#concat_to_dpipe_sql-613"><span class="linenos">613</span></a> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest_args</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="concat_to_dpipe_sql-614"><a href="#concat_to_dpipe_sql-614"><span class="linenos">614</span></a> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">rest_args</span><span class="p">:</span> +</span><span id="concat_to_dpipe_sql-615"><a href="#concat_to_dpipe_sql-615"><span class="linenos">615</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DPipe</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">arg</span><span class="p">)</span> +</span><span id="concat_to_dpipe_sql-616"><a href="#concat_to_dpipe_sql-616"><span class="linenos">616</span></a> +</span><span id="concat_to_dpipe_sql-617"><a href="#concat_to_dpipe_sql-617"><span class="linenos">617</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">this</span><span class="p">)</span> </span></pre></div> @@ -2426,26 +2714,26 @@ columns are removed from the create statement.</p> </div> <a class="headerlink" href="#pivot_column_names"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="pivot_column_names-559"><a href="#pivot_column_names-559"><span class="linenos">559</span></a><span class="k">def</span> <span class="nf">pivot_column_names</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="n">dialect</span><span class="p">:</span> <span class="n">DialectType</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="pivot_column_names-560"><a href="#pivot_column_names-560"><span class="linenos">560</span></a> <span class="n">names</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="pivot_column_names-561"><a href="#pivot_column_names-561"><span class="linenos">561</span></a> <span class="k">for</span> <span class="n">agg</span> <span class="ow">in</span> <span class="n">aggregations</span><span class="p">:</span> -</span><span id="pivot_column_names-562"><a href="#pivot_column_names-562"><span class="linenos">562</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">agg</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">):</span> -</span><span id="pivot_column_names-563"><a href="#pivot_column_names-563"><span class="linenos">563</span></a> <span class="n">names</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">agg</span><span class="o">.</span><span class="n">alias</span><span class="p">)</span> -</span><span id="pivot_column_names-564"><a href="#pivot_column_names-564"><span class="linenos">564</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="pivot_column_names-565"><a href="#pivot_column_names-565"><span class="linenos">565</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="pivot_column_names-566"><a href="#pivot_column_names-566"><span class="linenos">566</span></a><span class="sd"> This case corresponds to aggregations without aliases being used as suffixes</span> -</span><span id="pivot_column_names-567"><a href="#pivot_column_names-567"><span class="linenos">567</span></a><span class="sd"> (e.g. col_avg(foo)). We need to unquote identifiers because they're going to</span> -</span><span id="pivot_column_names-568"><a href="#pivot_column_names-568"><span class="linenos">568</span></a><span class="sd"> be quoted in the base parser's `_parse_pivot` method, due to `to_identifier`.</span> -</span><span id="pivot_column_names-569"><a href="#pivot_column_names-569"><span class="linenos">569</span></a><span class="sd"> Otherwise, we'd end up with `col_avg(`foo`)` (notice the double quotes).</span> -</span><span id="pivot_column_names-570"><a href="#pivot_column_names-570"><span class="linenos">570</span></a><span class="sd"> """</span> -</span><span id="pivot_column_names-571"><a href="#pivot_column_names-571"><span class="linenos">571</span></a> <span class="n">agg_all_unquoted</span> <span class="o">=</span> <span class="n">agg</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> -</span><span id="pivot_column_names-572"><a href="#pivot_column_names-572"><span class="linenos">572</span></a> <span class="k">lambda</span> <span class="n">node</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">node</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="pivot_column_names-573"><a href="#pivot_column_names-573"><span class="linenos">573</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> -</span><span id="pivot_column_names-574"><a href="#pivot_column_names-574"><span class="linenos">574</span></a> <span class="k">else</span> <span class="n">node</span> -</span><span id="pivot_column_names-575"><a href="#pivot_column_names-575"><span class="linenos">575</span></a> <span class="p">)</span> -</span><span id="pivot_column_names-576"><a href="#pivot_column_names-576"><span class="linenos">576</span></a> <span class="n">names</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">agg_all_unquoted</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">normalize_functions</span><span class="o">=</span><span class="s2">"lower"</span><span class="p">))</span> -</span><span id="pivot_column_names-577"><a href="#pivot_column_names-577"><span class="linenos">577</span></a> -</span><span id="pivot_column_names-578"><a href="#pivot_column_names-578"><span class="linenos">578</span></a> <span class="k">return</span> <span class="n">names</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="pivot_column_names-621"><a href="#pivot_column_names-621"><span class="linenos">621</span></a><span class="k">def</span> <span class="nf">pivot_column_names</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="n">dialect</span><span class="p">:</span> <span class="n">DialectType</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="pivot_column_names-622"><a href="#pivot_column_names-622"><span class="linenos">622</span></a> <span class="n">names</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="pivot_column_names-623"><a href="#pivot_column_names-623"><span class="linenos">623</span></a> <span class="k">for</span> <span class="n">agg</span> <span class="ow">in</span> <span class="n">aggregations</span><span class="p">:</span> +</span><span id="pivot_column_names-624"><a href="#pivot_column_names-624"><span class="linenos">624</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">agg</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">):</span> +</span><span id="pivot_column_names-625"><a href="#pivot_column_names-625"><span class="linenos">625</span></a> <span class="n">names</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">agg</span><span class="o">.</span><span class="n">alias</span><span class="p">)</span> +</span><span id="pivot_column_names-626"><a href="#pivot_column_names-626"><span class="linenos">626</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="pivot_column_names-627"><a href="#pivot_column_names-627"><span class="linenos">627</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="pivot_column_names-628"><a href="#pivot_column_names-628"><span class="linenos">628</span></a><span class="sd"> This case corresponds to aggregations without aliases being used as suffixes</span> +</span><span id="pivot_column_names-629"><a href="#pivot_column_names-629"><span class="linenos">629</span></a><span class="sd"> (e.g. col_avg(foo)). We need to unquote identifiers because they're going to</span> +</span><span id="pivot_column_names-630"><a href="#pivot_column_names-630"><span class="linenos">630</span></a><span class="sd"> be quoted in the base parser's `_parse_pivot` method, due to `to_identifier`.</span> +</span><span id="pivot_column_names-631"><a href="#pivot_column_names-631"><span class="linenos">631</span></a><span class="sd"> Otherwise, we'd end up with `col_avg(`foo`)` (notice the double quotes).</span> +</span><span id="pivot_column_names-632"><a href="#pivot_column_names-632"><span class="linenos">632</span></a><span class="sd"> """</span> +</span><span id="pivot_column_names-633"><a href="#pivot_column_names-633"><span class="linenos">633</span></a> <span class="n">agg_all_unquoted</span> <span class="o">=</span> <span class="n">agg</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> +</span><span id="pivot_column_names-634"><a href="#pivot_column_names-634"><span class="linenos">634</span></a> <span class="k">lambda</span> <span class="n">node</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">node</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="pivot_column_names-635"><a href="#pivot_column_names-635"><span class="linenos">635</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> +</span><span id="pivot_column_names-636"><a href="#pivot_column_names-636"><span class="linenos">636</span></a> <span class="k">else</span> <span class="n">node</span> +</span><span id="pivot_column_names-637"><a href="#pivot_column_names-637"><span class="linenos">637</span></a> <span class="p">)</span> +</span><span id="pivot_column_names-638"><a href="#pivot_column_names-638"><span class="linenos">638</span></a> <span class="n">names</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">agg_all_unquoted</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">normalize_functions</span><span class="o">=</span><span class="s2">"lower"</span><span class="p">))</span> +</span><span id="pivot_column_names-639"><a href="#pivot_column_names-639"><span class="linenos">639</span></a> +</span><span id="pivot_column_names-640"><a href="#pivot_column_names-640"><span class="linenos">640</span></a> <span class="k">return</span> <span class="n">names</span> </span></pre></div> diff --git a/docs/sqlglot/dialects/drill.html b/docs/sqlglot/dialects/drill.html index dc9d709..f56558d 100644 --- a/docs/sqlglot/dialects/drill.html +++ b/docs/sqlglot/dialects/drill.html @@ -51,6 +51,9 @@ <li> <a class="function" href="#Drill.Generator.normalize_func">normalize_func</a> </li> + <li> + <a class="function" href="#Drill.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -375,6 +378,10 @@ <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="Drill.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="Drill.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="Drill.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="Drill.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="Drill.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="Drill.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="Drill.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="Drill.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="Drill.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -610,6 +617,60 @@ Default: True</li> </div> + <div id="Drill.Generator.can_identify" class="classattr"> + <input id="Drill.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="Drill.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Drill.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Drill.Generator.can_identify-247"><a href="#Drill.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="Drill.Generator.can_identify-248"><a href="#Drill.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Drill.Generator.can_identify-249"><a href="#Drill.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="Drill.Generator.can_identify-250"><a href="#Drill.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="Drill.Generator.can_identify-251"><a href="#Drill.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="Drill.Generator.can_identify-252"><a href="#Drill.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="Drill.Generator.can_identify-253"><a href="#Drill.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="Drill.Generator.can_identify-254"><a href="#Drill.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="Drill.Generator.can_identify-255"><a href="#Drill.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="Drill.Generator.can_identify-256"><a href="#Drill.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="Drill.Generator.can_identify-257"><a href="#Drill.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="Drill.Generator.can_identify-258"><a href="#Drill.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="Drill.Generator.can_identify-259"><a href="#Drill.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="Drill.Generator.can_identify-260"><a href="#Drill.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="Drill.Generator.can_identify-261"><a href="#Drill.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Drill.Generator.can_identify-262"><a href="#Drill.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="Drill.Generator.can_identify-263"><a href="#Drill.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="Drill.Generator.can_identify-264"><a href="#Drill.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="Drill.Generator.can_identify-265"><a href="#Drill.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="Drill.Generator.can_identify-266"><a href="#Drill.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -711,6 +772,7 @@ Default: True</li> <dd id="Drill.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="Drill.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="Drill.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="Drill.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="Drill.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="Drill.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="Drill.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/dialects/duckdb.html b/docs/sqlglot/dialects/duckdb.html index 62dfecc..87c568d 100644 --- a/docs/sqlglot/dialects/duckdb.html +++ b/docs/sqlglot/dialects/duckdb.html @@ -54,6 +54,9 @@ <li> <a class="function" href="#DuckDB.Generator.tablesample_sql">tablesample_sql</a> </li> + <li> + <a class="function" href="#DuckDB.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -173,180 +176,183 @@ </span><span id="L-88"><a href="#L-88"><span class="linenos"> 88</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-89"><a href="#L-89"><span class="linenos"> 89</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_last"</span> </span><span id="L-90"><a href="#L-90"><span class="linenos"> 90</span></a> -</span><span id="L-91"><a href="#L-91"><span class="linenos"> 91</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-92"><a href="#L-92"><span class="linenos"> 92</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-93"><a href="#L-93"><span class="linenos"> 93</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-94"><a href="#L-94"><span class="linenos"> 94</span></a> <span class="s2">"~"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> -</span><span id="L-95"><a href="#L-95"><span class="linenos"> 95</span></a> <span class="s2">":="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> -</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</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-97"><a href="#L-97"><span class="linenos"> 97</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-98"><a href="#L-98"><span class="linenos"> 98</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-99"><a href="#L-99"><span class="linenos"> 99</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-100"><a href="#L-100"><span class="linenos">100</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-101"><a href="#L-101"><span class="linenos">101</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-102"><a href="#L-102"><span class="linenos">102</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-103"><a href="#L-103"><span class="linenos">103</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-104"><a href="#L-104"><span class="linenos">104</span></a> <span class="s2">"INT1"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">,</span> -</span><span id="L-105"><a href="#L-105"><span class="linenos">105</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-106"><a href="#L-106"><span class="linenos">106</span></a> <span class="s2">"NUMERIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> -</span><span id="L-107"><a href="#L-107"><span class="linenos">107</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-108"><a href="#L-108"><span class="linenos">108</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-109"><a href="#L-109"><span class="linenos">109</span></a> <span class="s2">"STRING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> -</span><span id="L-110"><a href="#L-110"><span class="linenos">110</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-111"><a href="#L-111"><span class="linenos">111</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-112"><a href="#L-112"><span class="linenos">112</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-113"><a href="#L-113"><span class="linenos">113</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-114"><a href="#L-114"><span class="linenos">114</span></a> <span class="p">}</span> -</span><span id="L-115"><a href="#L-115"><span class="linenos">115</span></a> -</span><span id="L-116"><a href="#L-116"><span class="linenos">116</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-117"><a href="#L-117"><span class="linenos">117</span></a> <span class="n">CONCAT_NULL_OUTPUTS_STRING</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-91"><a href="#L-91"><span class="linenos"> 91</span></a> <span class="c1"># https://duckdb.org/docs/sql/introduction.html#creating-a-new-table</span> +</span><span id="L-92"><a href="#L-92"><span class="linenos"> 92</span></a> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-93"><a href="#L-93"><span class="linenos"> 93</span></a> +</span><span id="L-94"><a href="#L-94"><span class="linenos"> 94</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-95"><a href="#L-95"><span class="linenos"> 95</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</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-97"><a href="#L-97"><span class="linenos"> 97</span></a> <span class="s2">"~"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> +</span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a> <span class="s2">":="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> +</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</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-100"><a href="#L-100"><span class="linenos">100</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-101"><a href="#L-101"><span class="linenos">101</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-102"><a href="#L-102"><span class="linenos">102</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-103"><a href="#L-103"><span class="linenos">103</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-104"><a href="#L-104"><span class="linenos">104</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-105"><a href="#L-105"><span class="linenos">105</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-106"><a href="#L-106"><span class="linenos">106</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-107"><a href="#L-107"><span class="linenos">107</span></a> <span class="s2">"INT1"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">,</span> +</span><span id="L-108"><a href="#L-108"><span class="linenos">108</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-109"><a href="#L-109"><span class="linenos">109</span></a> <span class="s2">"NUMERIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> +</span><span id="L-110"><a href="#L-110"><span class="linenos">110</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-111"><a href="#L-111"><span class="linenos">111</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-112"><a href="#L-112"><span class="linenos">112</span></a> <span class="s2">"STRING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> +</span><span id="L-113"><a href="#L-113"><span class="linenos">113</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-114"><a href="#L-114"><span class="linenos">114</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-115"><a href="#L-115"><span class="linenos">115</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-116"><a href="#L-116"><span class="linenos">116</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-117"><a href="#L-117"><span class="linenos">117</span></a> <span class="p">}</span> </span><span id="L-118"><a href="#L-118"><span class="linenos">118</span></a> -</span><span id="L-119"><a href="#L-119"><span class="linenos">119</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-120"><a href="#L-120"><span class="linenos">120</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-121"><a href="#L-121"><span class="linenos">121</span></a> <span class="s2">"ARRAY_LENGTH"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-122"><a href="#L-122"><span class="linenos">122</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-123"><a href="#L-123"><span class="linenos">123</span></a> <span class="s2">"ARRAY_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_sort_array_reverse</span><span class="p">,</span> -</span><span id="L-124"><a href="#L-124"><span class="linenos">124</span></a> <span class="s2">"DATEDIFF"</span><span class="p">:</span> <span class="n">_parse_date_diff</span><span class="p">,</span> -</span><span id="L-125"><a href="#L-125"><span class="linenos">125</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">:</span> <span class="n">_parse_date_diff</span><span class="p">,</span> -</span><span id="L-126"><a href="#L-126"><span class="linenos">126</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-127"><a href="#L-127"><span class="linenos">127</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-128"><a href="#L-128"><span class="linenos">128</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">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="mi">1000</span><span class="p">))</span> -</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a> <span class="p">),</span> -</span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a> <span class="s2">"LIST_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_sort_array_reverse</span><span class="p">,</span> -</span><span id="L-131"><a href="#L-131"><span class="linenos">131</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-132"><a href="#L-132"><span class="linenos">132</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-133"><a href="#L-133"><span class="linenos">133</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-134"><a href="#L-134"><span class="linenos">134</span></a> <span class="s2">"STRFTIME"</span><span class="p">:</span> <span class="n">format_time_lambda</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-135"><a href="#L-135"><span class="linenos">135</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-136"><a href="#L-136"><span class="linenos">136</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-137"><a href="#L-137"><span class="linenos">137</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-138"><a href="#L-138"><span class="linenos">138</span></a> <span class="s2">"STRPTIME"</span><span class="p">:</span> <span class="n">format_time_lambda</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-139"><a href="#L-139"><span class="linenos">139</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-140"><a href="#L-140"><span class="linenos">140</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-141"><a href="#L-141"><span class="linenos">141</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-142"><a href="#L-142"><span class="linenos">142</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-143"><a href="#L-143"><span class="linenos">143</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-144"><a href="#L-144"><span class="linenos">144</span></a> <span class="p">}</span> -</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> -</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> <span class="n">TYPE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-147"><a href="#L-147"><span class="linenos">147</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">TYPE_TOKENS</span><span class="p">,</span> -</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">UBIGINT</span><span class="p">,</span> -</span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">UINT</span><span class="p">,</span> -</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">USMALLINT</span><span class="p">,</span> -</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">UTINYINT</span><span class="p">,</span> -</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="p">}</span> -</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> -</span><span id="L-154"><a href="#L-154"><span class="linenos">154</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-155"><a href="#L-155"><span class="linenos">155</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-156"><a href="#L-156"><span class="linenos">156</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-157"><a href="#L-157"><span class="linenos">157</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-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">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-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> -</span><span id="L-163"><a href="#L-163"><span class="linenos">163</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-164"><a href="#L-164"><span class="linenos">164</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> -</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-167"><a href="#L-167"><span class="linenos">167</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-168"><a href="#L-168"><span class="linenos">168</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-169"><a href="#L-169"><span class="linenos">169</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</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">"ARRAY"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> -</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">seq_get</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">)</span> -</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="k">else</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LIST_VALUE"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">),</span> -</span><span id="L-172"><a href="#L-172"><span class="linenos">172</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-173"><a href="#L-173"><span class="linenos">173</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-174"><a href="#L-174"><span class="linenos">174</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-175"><a href="#L-175"><span class="linenos">175</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-176"><a href="#L-176"><span class="linenos">176</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"CURRENT_DATE"</span><span class="p">,</span> -</span><span id="L-177"><a href="#L-177"><span class="linenos">177</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"CURRENT_TIME"</span><span class="p">,</span> -</span><span id="L-178"><a href="#L-178"><span class="linenos">178</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> -</span><span id="L-179"><a href="#L-179"><span class="linenos">179</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-180"><a href="#L-180"><span class="linenos">180</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-181"><a href="#L-181"><span class="linenos">181</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-182"><a href="#L-182"><span class="linenos">182</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-183"><a href="#L-183"><span class="linenos">183</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-184"><a href="#L-184"><span class="linenos">184</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-185"><a href="#L-185"><span class="linenos">185</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-186"><a href="#L-186"><span class="linenos">186</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="s1">'day'</span><span class="p">)</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-187"><a href="#L-187"><span class="linenos">187</span></a> <span class="p">),</span> -</span><span id="L-188"><a href="#L-188"><span class="linenos">188</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-189"><a href="#L-189"><span class="linenos">189</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 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-190"><a href="#L-190"><span class="linenos">190</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 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-191"><a href="#L-191"><span class="linenos">191</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-192"><a href="#L-192"><span class="linenos">192</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-193"><a href="#L-193"><span class="linenos">193</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-194"><a href="#L-194"><span class="linenos">194</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_scalar_sql</span><span class="p">,</span> -</span><span id="L-195"><a href="#L-195"><span class="linenos">195</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtract</span><span class="p">:</span> <span class="n">arrow_json_extract_sql</span><span class="p">,</span> -</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtractScalar</span><span class="p">:</span> <span class="n">arrow_json_extract_scalar_sql</span><span class="p">,</span> -</span><span id="L-197"><a href="#L-197"><span class="linenos">197</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-198"><a href="#L-198"><span class="linenos">198</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-199"><a href="#L-199"><span class="linenos">199</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">:</span> <span class="n">no_properties_sql</span><span class="p">,</span> -</span><span id="L-200"><a href="#L-200"><span class="linenos">200</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-201"><a href="#L-201"><span class="linenos">201</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-202"><a href="#L-202"><span class="linenos">202</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-203"><a href="#L-203"><span class="linenos">203</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-204"><a href="#L-204"><span class="linenos">204</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-205"><a href="#L-205"><span class="linenos">205</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-206"><a href="#L-206"><span class="linenos">206</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-207"><a href="#L-207"><span class="linenos">207</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</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(</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">e</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span><span class="p">,</span> -</span><span id="L-208"><a href="#L-208"><span class="linenos">208</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">str_to_time_sql</span><span class="p">,</span> -</span><span id="L-209"><a href="#L-209"><span class="linenos">209</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="sa">f</span><span class="s2">"EPOCH(STRPTIME(</span><span 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="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 class="si">}</span><span class="s2">))"</span><span class="p">,</span> -</span><span id="L-210"><a href="#L-210"><span class="linenos">210</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-211"><a href="#L-211"><span class="linenos">211</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-212"><a href="#L-212"><span class="linenos">212</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="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">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 DATE)"</span><span class="p">,</span> -</span><span id="L-213"><a href="#L-213"><span class="linenos">213</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-214"><a href="#L-214"><span class="linenos">214</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="sa">f</span><span class="s2">"EPOCH(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 TIMESTAMP))"</span><span class="p">,</span> -</span><span id="L-215"><a href="#L-215"><span class="linenos">215</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="sa">f</span><span class="s2">"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="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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-216"><a href="#L-216"><span class="linenos">216</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-217"><a href="#L-217"><span class="linenos">217</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 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-218"><a href="#L-218"><span class="linenos">218</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> -</span><span id="L-219"><a href="#L-219"><span class="linenos">219</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="s2">"duckdb"</span><span class="p">),</span> -</span><span id="L-220"><a href="#L-220"><span class="linenos">220</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="sa">f</span><span class="s2">"STRFTIME(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">), </span><span class="si">{</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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-221"><a href="#L-221"><span class="linenos">221</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_TIMESTAMP"</span><span class="p">),</span> -</span><span id="L-222"><a href="#L-222"><span class="linenos">222</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-223"><a href="#L-223"><span class="linenos">223</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-224"><a href="#L-224"><span class="linenos">224</span></a> <span class="p">}</span> -</span><span id="L-225"><a href="#L-225"><span class="linenos">225</span></a> -</span><span id="L-226"><a href="#L-226"><span class="linenos">226</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-227"><a href="#L-227"><span class="linenos">227</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-228"><a href="#L-228"><span class="linenos">228</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-229"><a href="#L-229"><span class="linenos">229</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-230"><a href="#L-230"><span class="linenos">230</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-231"><a href="#L-231"><span class="linenos">231</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-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UINT</span><span class="p">:</span> <span class="s2">"UINTEGER"</span><span class="p">,</span> -</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> -</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> <span class="p">}</span> -</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> -</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span><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">STAR_MAPPING</span><span class="p">,</span> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCLUDE"</span><span class="p">}</span> -</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> -</span><span id="L-240"><a href="#L-240"><span class="linenos">240</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">Column</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-241"><a href="#L-241"><span class="linenos">241</span></a> -</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-243"><a href="#L-243"><span class="linenos">243</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">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="p">}</span> -</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> -</span><span id="L-247"><a href="#L-247"><span class="linenos">247</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-248"><a href="#L-248"><span class="linenos">248</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-249"><a href="#L-249"><span class="linenos">249</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-250"><a href="#L-250"><span class="linenos">250</span></a> -</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> <span class="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-252"><a href="#L-252"><span class="linenos">252</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> -</span><span id="L-253"><a href="#L-253"><span class="linenos">253</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-254"><a href="#L-254"><span class="linenos">254</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> -</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> -</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> -</span><span id="L-257"><a href="#L-257"><span class="linenos">257</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-119"><a href="#L-119"><span class="linenos">119</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-120"><a href="#L-120"><span class="linenos">120</span></a> <span class="n">CONCAT_NULL_OUTPUTS_STRING</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-121"><a href="#L-121"><span class="linenos">121</span></a> +</span><span id="L-122"><a href="#L-122"><span class="linenos">122</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-123"><a href="#L-123"><span class="linenos">123</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-124"><a href="#L-124"><span class="linenos">124</span></a> <span class="s2">"ARRAY_LENGTH"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-125"><a href="#L-125"><span class="linenos">125</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-126"><a href="#L-126"><span class="linenos">126</span></a> <span class="s2">"ARRAY_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_sort_array_reverse</span><span class="p">,</span> +</span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a> <span class="s2">"DATEDIFF"</span><span class="p">:</span> <span class="n">_parse_date_diff</span><span class="p">,</span> +</span><span id="L-128"><a href="#L-128"><span class="linenos">128</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">:</span> <span class="n">_parse_date_diff</span><span class="p">,</span> +</span><span id="L-129"><a href="#L-129"><span class="linenos">129</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-130"><a href="#L-130"><span class="linenos">130</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-131"><a href="#L-131"><span class="linenos">131</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">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="mi">1000</span><span class="p">))</span> +</span><span id="L-132"><a href="#L-132"><span class="linenos">132</span></a> <span class="p">),</span> +</span><span id="L-133"><a href="#L-133"><span class="linenos">133</span></a> <span class="s2">"LIST_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_sort_array_reverse</span><span class="p">,</span> +</span><span id="L-134"><a href="#L-134"><span class="linenos">134</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-135"><a href="#L-135"><span class="linenos">135</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-136"><a href="#L-136"><span class="linenos">136</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-137"><a href="#L-137"><span class="linenos">137</span></a> <span class="s2">"STRFTIME"</span><span class="p">:</span> <span class="n">format_time_lambda</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-138"><a href="#L-138"><span class="linenos">138</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-139"><a href="#L-139"><span class="linenos">139</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-140"><a href="#L-140"><span class="linenos">140</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-141"><a href="#L-141"><span class="linenos">141</span></a> <span class="s2">"STRPTIME"</span><span class="p">:</span> <span class="n">format_time_lambda</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-142"><a href="#L-142"><span class="linenos">142</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-143"><a href="#L-143"><span class="linenos">143</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-144"><a href="#L-144"><span class="linenos">144</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-145"><a href="#L-145"><span class="linenos">145</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-146"><a href="#L-146"><span class="linenos">146</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-147"><a href="#L-147"><span class="linenos">147</span></a> <span class="p">}</span> +</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a> +</span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a> <span class="n">TYPE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-150"><a href="#L-150"><span class="linenos">150</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">TYPE_TOKENS</span><span class="p">,</span> +</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">UBIGINT</span><span class="p">,</span> +</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">UINT</span><span class="p">,</span> +</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">USMALLINT</span><span class="p">,</span> +</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">UTINYINT</span><span class="p">,</span> +</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> <span class="p">}</span> +</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> +</span><span id="L-157"><a href="#L-157"><span class="linenos">157</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-158"><a href="#L-158"><span class="linenos">158</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-159"><a href="#L-159"><span class="linenos">159</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-160"><a href="#L-160"><span class="linenos">160</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-161"><a href="#L-161"><span class="linenos">161</span></a> +</span><span id="L-162"><a href="#L-162"><span class="linenos">162</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-163"><a href="#L-163"><span class="linenos">163</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-164"><a href="#L-164"><span class="linenos">164</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> +</span><span id="L-166"><a href="#L-166"><span class="linenos">166</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-167"><a href="#L-167"><span class="linenos">167</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a> +</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-170"><a href="#L-170"><span class="linenos">170</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-171"><a href="#L-171"><span class="linenos">171</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-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</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">"ARRAY"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> +</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">expressions</span> <span class="ow">and</span> <span class="n">e</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">find</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-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="k">else</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LIST_VALUE"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">),</span> +</span><span id="L-175"><a href="#L-175"><span class="linenos">175</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-176"><a href="#L-176"><span class="linenos">176</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-177"><a href="#L-177"><span class="linenos">177</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-178"><a href="#L-178"><span class="linenos">178</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-179"><a href="#L-179"><span class="linenos">179</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"CURRENT_DATE"</span><span class="p">,</span> +</span><span id="L-180"><a href="#L-180"><span class="linenos">180</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"CURRENT_TIME"</span><span class="p">,</span> +</span><span id="L-181"><a href="#L-181"><span class="linenos">181</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> +</span><span id="L-182"><a href="#L-182"><span class="linenos">182</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-183"><a href="#L-183"><span class="linenos">183</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-184"><a href="#L-184"><span class="linenos">184</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-185"><a href="#L-185"><span class="linenos">185</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-186"><a href="#L-186"><span class="linenos">186</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-187"><a href="#L-187"><span class="linenos">187</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-188"><a href="#L-188"><span class="linenos">188</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-189"><a href="#L-189"><span class="linenos">189</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="s1">'day'</span><span class="p">)</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-190"><a href="#L-190"><span class="linenos">190</span></a> <span class="p">),</span> +</span><span id="L-191"><a href="#L-191"><span class="linenos">191</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-192"><a href="#L-192"><span class="linenos">192</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 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-193"><a href="#L-193"><span class="linenos">193</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 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-194"><a href="#L-194"><span class="linenos">194</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-195"><a href="#L-195"><span class="linenos">195</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-196"><a href="#L-196"><span class="linenos">196</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-197"><a href="#L-197"><span class="linenos">197</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_scalar_sql</span><span class="p">,</span> +</span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtract</span><span class="p">:</span> <span class="n">arrow_json_extract_sql</span><span class="p">,</span> +</span><span id="L-199"><a href="#L-199"><span class="linenos">199</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtractScalar</span><span class="p">:</span> <span class="n">arrow_json_extract_scalar_sql</span><span class="p">,</span> +</span><span id="L-200"><a href="#L-200"><span class="linenos">200</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-201"><a href="#L-201"><span class="linenos">201</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-202"><a href="#L-202"><span class="linenos">202</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">:</span> <span class="n">no_properties_sql</span><span class="p">,</span> +</span><span id="L-203"><a href="#L-203"><span class="linenos">203</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-204"><a href="#L-204"><span class="linenos">204</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-205"><a href="#L-205"><span class="linenos">205</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-206"><a href="#L-206"><span class="linenos">206</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-207"><a href="#L-207"><span class="linenos">207</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-208"><a href="#L-208"><span class="linenos">208</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-209"><a href="#L-209"><span class="linenos">209</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-210"><a href="#L-210"><span class="linenos">210</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</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(</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">e</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span><span class="p">,</span> +</span><span id="L-211"><a href="#L-211"><span class="linenos">211</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">str_to_time_sql</span><span class="p">,</span> +</span><span id="L-212"><a href="#L-212"><span class="linenos">212</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="sa">f</span><span class="s2">"EPOCH(STRPTIME(</span><span 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="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 class="si">}</span><span class="s2">))"</span><span class="p">,</span> +</span><span id="L-213"><a href="#L-213"><span class="linenos">213</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-214"><a href="#L-214"><span class="linenos">214</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-215"><a href="#L-215"><span class="linenos">215</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="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">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 DATE)"</span><span class="p">,</span> +</span><span id="L-216"><a href="#L-216"><span class="linenos">216</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-217"><a href="#L-217"><span class="linenos">217</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="sa">f</span><span class="s2">"EPOCH(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 TIMESTAMP))"</span><span class="p">,</span> +</span><span id="L-218"><a href="#L-218"><span class="linenos">218</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="sa">f</span><span class="s2">"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="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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-219"><a href="#L-219"><span class="linenos">219</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-220"><a href="#L-220"><span class="linenos">220</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 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-221"><a href="#L-221"><span class="linenos">221</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> +</span><span id="L-222"><a href="#L-222"><span class="linenos">222</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="s2">"duckdb"</span><span class="p">),</span> +</span><span id="L-223"><a href="#L-223"><span class="linenos">223</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="sa">f</span><span class="s2">"STRFTIME(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">), </span><span class="si">{</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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-224"><a href="#L-224"><span class="linenos">224</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_TIMESTAMP"</span><span class="p">),</span> +</span><span id="L-225"><a href="#L-225"><span class="linenos">225</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-226"><a href="#L-226"><span class="linenos">226</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-227"><a href="#L-227"><span class="linenos">227</span></a> <span class="p">}</span> +</span><span id="L-228"><a href="#L-228"><span class="linenos">228</span></a> +</span><span id="L-229"><a href="#L-229"><span class="linenos">229</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-230"><a href="#L-230"><span class="linenos">230</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-231"><a href="#L-231"><span class="linenos">231</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-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">CHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> +</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UINT</span><span class="p">:</span> <span class="s2">"UINTEGER"</span><span class="p">,</span> +</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> +</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> <span class="p">}</span> +</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> +</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> <span class="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span><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">STAR_MAPPING</span><span class="p">,</span> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCLUDE"</span><span class="p">}</span> +</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> +</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> <span class="n">UNWRAPPED_INTERVAL_VALUES</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">,</span> <span class="n">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-244"><a href="#L-244"><span class="linenos">244</span></a> +</span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-246"><a href="#L-246"><span class="linenos">246</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">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> <span class="p">}</span> +</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> +</span><span id="L-250"><a href="#L-250"><span class="linenos">250</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-251"><a href="#L-251"><span class="linenos">251</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-252"><a href="#L-252"><span class="linenos">252</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-253"><a href="#L-253"><span class="linenos">253</span></a> +</span><span id="L-254"><a href="#L-254"><span class="linenos">254</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-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> +</span><span id="L-256"><a href="#L-256"><span class="linenos">256</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-257"><a href="#L-257"><span class="linenos">257</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</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="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-260"><a href="#L-260"><span class="linenos">260</span></a> -</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span> -</span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-264"><a href="#L-264"><span class="linenos">264</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 class="n">expression</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="o">=</span><span class="s2">"REPEATABLE"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">)</span> +</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> +</span><span id="L-260"><a href="#L-260"><span class="linenos">260</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-261"><a href="#L-261"><span class="linenos">261</span></a> +</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="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-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="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span> +</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-267"><a href="#L-267"><span class="linenos">267</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 class="n">expression</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="o">=</span><span class="s2">"REPEATABLE"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">)</span> </span></pre></div> @@ -365,180 +371,183 @@ <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB-89"><a href="#DuckDB-89"><span class="linenos"> 89</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-90"><a href="#DuckDB-90"><span class="linenos"> 90</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_last"</span> </span><span id="DuckDB-91"><a href="#DuckDB-91"><span class="linenos"> 91</span></a> -</span><span id="DuckDB-92"><a href="#DuckDB-92"><span class="linenos"> 92</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-93"><a href="#DuckDB-93"><span class="linenos"> 93</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB-94"><a href="#DuckDB-94"><span class="linenos"> 94</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-95"><a href="#DuckDB-95"><span class="linenos"> 95</span></a> <span class="s2">"~"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> -</span><span id="DuckDB-96"><a href="#DuckDB-96"><span class="linenos"> 96</span></a> <span class="s2">":="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> -</span><span id="DuckDB-97"><a href="#DuckDB-97"><span class="linenos"> 97</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-98"><a href="#DuckDB-98"><span class="linenos"> 98</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-99"><a href="#DuckDB-99"><span class="linenos"> 99</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-100"><a href="#DuckDB-100"><span class="linenos">100</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-101"><a href="#DuckDB-101"><span class="linenos">101</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-102"><a href="#DuckDB-102"><span class="linenos">102</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-103"><a href="#DuckDB-103"><span class="linenos">103</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-104"><a href="#DuckDB-104"><span class="linenos">104</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-105"><a href="#DuckDB-105"><span class="linenos">105</span></a> <span class="s2">"INT1"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">,</span> -</span><span id="DuckDB-106"><a href="#DuckDB-106"><span class="linenos">106</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-107"><a href="#DuckDB-107"><span class="linenos">107</span></a> <span class="s2">"NUMERIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> -</span><span id="DuckDB-108"><a href="#DuckDB-108"><span class="linenos">108</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-109"><a href="#DuckDB-109"><span class="linenos">109</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-110"><a href="#DuckDB-110"><span class="linenos">110</span></a> <span class="s2">"STRING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> -</span><span id="DuckDB-111"><a href="#DuckDB-111"><span class="linenos">111</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-112"><a href="#DuckDB-112"><span class="linenos">112</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-113"><a href="#DuckDB-113"><span class="linenos">113</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-114"><a href="#DuckDB-114"><span class="linenos">114</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-115"><a href="#DuckDB-115"><span class="linenos">115</span></a> <span class="p">}</span> -</span><span id="DuckDB-116"><a href="#DuckDB-116"><span class="linenos">116</span></a> -</span><span id="DuckDB-117"><a href="#DuckDB-117"><span class="linenos">117</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-118"><a href="#DuckDB-118"><span class="linenos">118</span></a> <span class="n">CONCAT_NULL_OUTPUTS_STRING</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="DuckDB-92"><a href="#DuckDB-92"><span class="linenos"> 92</span></a> <span class="c1"># https://duckdb.org/docs/sql/introduction.html#creating-a-new-table</span> +</span><span id="DuckDB-93"><a href="#DuckDB-93"><span class="linenos"> 93</span></a> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="DuckDB-94"><a href="#DuckDB-94"><span class="linenos"> 94</span></a> +</span><span id="DuckDB-95"><a href="#DuckDB-95"><span class="linenos"> 95</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-96"><a href="#DuckDB-96"><span class="linenos"> 96</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-97"><a href="#DuckDB-97"><span class="linenos"> 97</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-98"><a href="#DuckDB-98"><span class="linenos"> 98</span></a> <span class="s2">"~"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> +</span><span id="DuckDB-99"><a href="#DuckDB-99"><span class="linenos"> 99</span></a> <span class="s2">":="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> +</span><span id="DuckDB-100"><a href="#DuckDB-100"><span class="linenos">100</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-101"><a href="#DuckDB-101"><span class="linenos">101</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-102"><a href="#DuckDB-102"><span class="linenos">102</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-103"><a href="#DuckDB-103"><span class="linenos">103</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-104"><a href="#DuckDB-104"><span class="linenos">104</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-105"><a href="#DuckDB-105"><span class="linenos">105</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-106"><a href="#DuckDB-106"><span class="linenos">106</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-107"><a href="#DuckDB-107"><span class="linenos">107</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-108"><a href="#DuckDB-108"><span class="linenos">108</span></a> <span class="s2">"INT1"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">,</span> +</span><span id="DuckDB-109"><a href="#DuckDB-109"><span class="linenos">109</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-110"><a href="#DuckDB-110"><span class="linenos">110</span></a> <span class="s2">"NUMERIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> +</span><span id="DuckDB-111"><a href="#DuckDB-111"><span class="linenos">111</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-112"><a href="#DuckDB-112"><span class="linenos">112</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-113"><a href="#DuckDB-113"><span class="linenos">113</span></a> <span class="s2">"STRING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> +</span><span id="DuckDB-114"><a href="#DuckDB-114"><span class="linenos">114</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-115"><a href="#DuckDB-115"><span class="linenos">115</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-116"><a href="#DuckDB-116"><span class="linenos">116</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-117"><a href="#DuckDB-117"><span class="linenos">117</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-118"><a href="#DuckDB-118"><span class="linenos">118</span></a> <span class="p">}</span> </span><span id="DuckDB-119"><a href="#DuckDB-119"><span class="linenos">119</span></a> -</span><span id="DuckDB-120"><a href="#DuckDB-120"><span class="linenos">120</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB-121"><a href="#DuckDB-121"><span class="linenos">121</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-122"><a href="#DuckDB-122"><span class="linenos">122</span></a> <span class="s2">"ARRAY_LENGTH"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB-123"><a href="#DuckDB-123"><span class="linenos">123</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-124"><a href="#DuckDB-124"><span class="linenos">124</span></a> <span class="s2">"ARRAY_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_sort_array_reverse</span><span class="p">,</span> -</span><span id="DuckDB-125"><a href="#DuckDB-125"><span class="linenos">125</span></a> <span class="s2">"DATEDIFF"</span><span class="p">:</span> <span class="n">_parse_date_diff</span><span class="p">,</span> -</span><span id="DuckDB-126"><a href="#DuckDB-126"><span class="linenos">126</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">:</span> <span class="n">_parse_date_diff</span><span class="p">,</span> -</span><span id="DuckDB-127"><a href="#DuckDB-127"><span class="linenos">127</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-128"><a href="#DuckDB-128"><span class="linenos">128</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-129"><a href="#DuckDB-129"><span class="linenos">129</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">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="mi">1000</span><span class="p">))</span> -</span><span id="DuckDB-130"><a href="#DuckDB-130"><span class="linenos">130</span></a> <span class="p">),</span> -</span><span id="DuckDB-131"><a href="#DuckDB-131"><span class="linenos">131</span></a> <span class="s2">"LIST_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_sort_array_reverse</span><span class="p">,</span> -</span><span id="DuckDB-132"><a href="#DuckDB-132"><span class="linenos">132</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-133"><a href="#DuckDB-133"><span class="linenos">133</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-134"><a href="#DuckDB-134"><span class="linenos">134</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-135"><a href="#DuckDB-135"><span class="linenos">135</span></a> <span class="s2">"STRFTIME"</span><span class="p">:</span> <span class="n">format_time_lambda</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-136"><a href="#DuckDB-136"><span class="linenos">136</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-137"><a href="#DuckDB-137"><span class="linenos">137</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-138"><a href="#DuckDB-138"><span class="linenos">138</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-139"><a href="#DuckDB-139"><span class="linenos">139</span></a> <span class="s2">"STRPTIME"</span><span class="p">:</span> <span class="n">format_time_lambda</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-140"><a href="#DuckDB-140"><span class="linenos">140</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-141"><a href="#DuckDB-141"><span class="linenos">141</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-142"><a href="#DuckDB-142"><span class="linenos">142</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-143"><a href="#DuckDB-143"><span class="linenos">143</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-144"><a href="#DuckDB-144"><span class="linenos">144</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-145"><a href="#DuckDB-145"><span class="linenos">145</span></a> <span class="p">}</span> -</span><span id="DuckDB-146"><a href="#DuckDB-146"><span class="linenos">146</span></a> -</span><span id="DuckDB-147"><a href="#DuckDB-147"><span class="linenos">147</span></a> <span class="n">TYPE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB-148"><a href="#DuckDB-148"><span class="linenos">148</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">TYPE_TOKENS</span><span class="p">,</span> -</span><span id="DuckDB-149"><a href="#DuckDB-149"><span class="linenos">149</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">UBIGINT</span><span class="p">,</span> -</span><span id="DuckDB-150"><a href="#DuckDB-150"><span class="linenos">150</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">UINT</span><span class="p">,</span> -</span><span id="DuckDB-151"><a href="#DuckDB-151"><span class="linenos">151</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">USMALLINT</span><span class="p">,</span> -</span><span id="DuckDB-152"><a href="#DuckDB-152"><span class="linenos">152</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">UTINYINT</span><span class="p">,</span> -</span><span id="DuckDB-153"><a href="#DuckDB-153"><span class="linenos">153</span></a> <span class="p">}</span> -</span><span id="DuckDB-154"><a href="#DuckDB-154"><span class="linenos">154</span></a> -</span><span id="DuckDB-155"><a href="#DuckDB-155"><span class="linenos">155</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-156"><a href="#DuckDB-156"><span class="linenos">156</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-157"><a href="#DuckDB-157"><span class="linenos">157</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-158"><a href="#DuckDB-158"><span class="linenos">158</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-159"><a href="#DuckDB-159"><span class="linenos">159</span></a> -</span><span id="DuckDB-160"><a href="#DuckDB-160"><span class="linenos">160</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-161"><a href="#DuckDB-161"><span class="linenos">161</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB-162"><a href="#DuckDB-162"><span class="linenos">162</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB-163"><a href="#DuckDB-163"><span class="linenos">163</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> -</span><span id="DuckDB-164"><a href="#DuckDB-164"><span class="linenos">164</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-165"><a href="#DuckDB-165"><span class="linenos">165</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB-166"><a href="#DuckDB-166"><span class="linenos">166</span></a> -</span><span id="DuckDB-167"><a href="#DuckDB-167"><span class="linenos">167</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB-168"><a href="#DuckDB-168"><span class="linenos">168</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-169"><a href="#DuckDB-169"><span class="linenos">169</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-170"><a href="#DuckDB-170"><span class="linenos">170</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</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">"ARRAY"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> -</span><span id="DuckDB-171"><a href="#DuckDB-171"><span class="linenos">171</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">seq_get</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">)</span> -</span><span id="DuckDB-172"><a href="#DuckDB-172"><span class="linenos">172</span></a> <span class="k">else</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LIST_VALUE"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">),</span> -</span><span id="DuckDB-173"><a href="#DuckDB-173"><span class="linenos">173</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-174"><a href="#DuckDB-174"><span class="linenos">174</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-175"><a href="#DuckDB-175"><span class="linenos">175</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-176"><a href="#DuckDB-176"><span class="linenos">176</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-177"><a href="#DuckDB-177"><span class="linenos">177</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"CURRENT_DATE"</span><span class="p">,</span> -</span><span id="DuckDB-178"><a href="#DuckDB-178"><span class="linenos">178</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"CURRENT_TIME"</span><span class="p">,</span> -</span><span id="DuckDB-179"><a href="#DuckDB-179"><span class="linenos">179</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> -</span><span id="DuckDB-180"><a href="#DuckDB-180"><span class="linenos">180</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-181"><a href="#DuckDB-181"><span class="linenos">181</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-182"><a href="#DuckDB-182"><span class="linenos">182</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-183"><a href="#DuckDB-183"><span class="linenos">183</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-184"><a href="#DuckDB-184"><span class="linenos">184</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-185"><a href="#DuckDB-185"><span class="linenos">185</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-186"><a href="#DuckDB-186"><span class="linenos">186</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-187"><a href="#DuckDB-187"><span class="linenos">187</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="s1">'day'</span><span class="p">)</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-188"><a href="#DuckDB-188"><span class="linenos">188</span></a> <span class="p">),</span> -</span><span id="DuckDB-189"><a href="#DuckDB-189"><span class="linenos">189</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-190"><a href="#DuckDB-190"><span class="linenos">190</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 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-191"><a href="#DuckDB-191"><span class="linenos">191</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 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-192"><a href="#DuckDB-192"><span class="linenos">192</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-193"><a href="#DuckDB-193"><span class="linenos">193</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-194"><a href="#DuckDB-194"><span class="linenos">194</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-195"><a href="#DuckDB-195"><span class="linenos">195</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_scalar_sql</span><span class="p">,</span> -</span><span id="DuckDB-196"><a href="#DuckDB-196"><span class="linenos">196</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtract</span><span class="p">:</span> <span class="n">arrow_json_extract_sql</span><span class="p">,</span> -</span><span id="DuckDB-197"><a href="#DuckDB-197"><span class="linenos">197</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtractScalar</span><span class="p">:</span> <span class="n">arrow_json_extract_scalar_sql</span><span class="p">,</span> -</span><span id="DuckDB-198"><a href="#DuckDB-198"><span class="linenos">198</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-199"><a href="#DuckDB-199"><span class="linenos">199</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-200"><a href="#DuckDB-200"><span class="linenos">200</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">:</span> <span class="n">no_properties_sql</span><span class="p">,</span> -</span><span id="DuckDB-201"><a href="#DuckDB-201"><span class="linenos">201</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-202"><a href="#DuckDB-202"><span class="linenos">202</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-203"><a href="#DuckDB-203"><span class="linenos">203</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-204"><a href="#DuckDB-204"><span class="linenos">204</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-205"><a href="#DuckDB-205"><span class="linenos">205</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-206"><a href="#DuckDB-206"><span class="linenos">206</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-207"><a href="#DuckDB-207"><span class="linenos">207</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-208"><a href="#DuckDB-208"><span class="linenos">208</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</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(</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">e</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span><span class="p">,</span> -</span><span id="DuckDB-209"><a href="#DuckDB-209"><span class="linenos">209</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">str_to_time_sql</span><span class="p">,</span> -</span><span id="DuckDB-210"><a href="#DuckDB-210"><span class="linenos">210</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="sa">f</span><span class="s2">"EPOCH(STRPTIME(</span><span 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="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 class="si">}</span><span class="s2">))"</span><span class="p">,</span> -</span><span id="DuckDB-211"><a href="#DuckDB-211"><span class="linenos">211</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-212"><a href="#DuckDB-212"><span class="linenos">212</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-213"><a href="#DuckDB-213"><span class="linenos">213</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="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">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 DATE)"</span><span class="p">,</span> -</span><span id="DuckDB-214"><a href="#DuckDB-214"><span class="linenos">214</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-215"><a href="#DuckDB-215"><span class="linenos">215</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="sa">f</span><span class="s2">"EPOCH(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 TIMESTAMP))"</span><span class="p">,</span> -</span><span id="DuckDB-216"><a href="#DuckDB-216"><span class="linenos">216</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="sa">f</span><span class="s2">"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="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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="DuckDB-217"><a href="#DuckDB-217"><span class="linenos">217</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-218"><a href="#DuckDB-218"><span class="linenos">218</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 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-219"><a href="#DuckDB-219"><span class="linenos">219</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> -</span><span id="DuckDB-220"><a href="#DuckDB-220"><span class="linenos">220</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="s2">"duckdb"</span><span class="p">),</span> -</span><span id="DuckDB-221"><a href="#DuckDB-221"><span class="linenos">221</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="sa">f</span><span class="s2">"STRFTIME(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">), </span><span class="si">{</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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="DuckDB-222"><a href="#DuckDB-222"><span class="linenos">222</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_TIMESTAMP"</span><span class="p">),</span> -</span><span id="DuckDB-223"><a href="#DuckDB-223"><span class="linenos">223</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-224"><a href="#DuckDB-224"><span class="linenos">224</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-225"><a href="#DuckDB-225"><span class="linenos">225</span></a> <span class="p">}</span> -</span><span id="DuckDB-226"><a href="#DuckDB-226"><span class="linenos">226</span></a> -</span><span id="DuckDB-227"><a href="#DuckDB-227"><span class="linenos">227</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB-228"><a href="#DuckDB-228"><span class="linenos">228</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-229"><a href="#DuckDB-229"><span class="linenos">229</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-230"><a href="#DuckDB-230"><span class="linenos">230</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-231"><a href="#DuckDB-231"><span class="linenos">231</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-232"><a href="#DuckDB-232"><span class="linenos">232</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="DuckDB-233"><a href="#DuckDB-233"><span class="linenos">233</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="DuckDB-234"><a href="#DuckDB-234"><span class="linenos">234</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UINT</span><span class="p">:</span> <span class="s2">"UINTEGER"</span><span class="p">,</span> -</span><span id="DuckDB-235"><a href="#DuckDB-235"><span class="linenos">235</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> -</span><span id="DuckDB-236"><a href="#DuckDB-236"><span class="linenos">236</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="DuckDB-237"><a href="#DuckDB-237"><span class="linenos">237</span></a> <span class="p">}</span> -</span><span id="DuckDB-238"><a href="#DuckDB-238"><span class="linenos">238</span></a> -</span><span id="DuckDB-239"><a href="#DuckDB-239"><span class="linenos">239</span></a> <span class="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span><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">STAR_MAPPING</span><span class="p">,</span> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCLUDE"</span><span class="p">}</span> -</span><span id="DuckDB-240"><a href="#DuckDB-240"><span class="linenos">240</span></a> -</span><span id="DuckDB-241"><a href="#DuckDB-241"><span class="linenos">241</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">Column</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-242"><a href="#DuckDB-242"><span class="linenos">242</span></a> -</span><span id="DuckDB-243"><a href="#DuckDB-243"><span class="linenos">243</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB-244"><a href="#DuckDB-244"><span class="linenos">244</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">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="DuckDB-245"><a href="#DuckDB-245"><span class="linenos">245</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="DuckDB-246"><a href="#DuckDB-246"><span class="linenos">246</span></a> <span class="p">}</span> -</span><span id="DuckDB-247"><a href="#DuckDB-247"><span class="linenos">247</span></a> -</span><span id="DuckDB-248"><a href="#DuckDB-248"><span class="linenos">248</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-249"><a href="#DuckDB-249"><span class="linenos">249</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-250"><a href="#DuckDB-250"><span class="linenos">250</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-251"><a href="#DuckDB-251"><span class="linenos">251</span></a> -</span><span id="DuckDB-252"><a href="#DuckDB-252"><span class="linenos">252</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-253"><a href="#DuckDB-253"><span class="linenos">253</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> -</span><span id="DuckDB-254"><a href="#DuckDB-254"><span class="linenos">254</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-255"><a href="#DuckDB-255"><span class="linenos">255</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> -</span><span id="DuckDB-256"><a href="#DuckDB-256"><span class="linenos">256</span></a> -</span><span id="DuckDB-257"><a href="#DuckDB-257"><span class="linenos">257</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> -</span><span id="DuckDB-258"><a href="#DuckDB-258"><span class="linenos">258</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-120"><a href="#DuckDB-120"><span class="linenos">120</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-121"><a href="#DuckDB-121"><span class="linenos">121</span></a> <span class="n">CONCAT_NULL_OUTPUTS_STRING</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="DuckDB-122"><a href="#DuckDB-122"><span class="linenos">122</span></a> +</span><span id="DuckDB-123"><a href="#DuckDB-123"><span class="linenos">123</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-124"><a href="#DuckDB-124"><span class="linenos">124</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-125"><a href="#DuckDB-125"><span class="linenos">125</span></a> <span class="s2">"ARRAY_LENGTH"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB-126"><a href="#DuckDB-126"><span class="linenos">126</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-127"><a href="#DuckDB-127"><span class="linenos">127</span></a> <span class="s2">"ARRAY_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_sort_array_reverse</span><span class="p">,</span> +</span><span id="DuckDB-128"><a href="#DuckDB-128"><span class="linenos">128</span></a> <span class="s2">"DATEDIFF"</span><span class="p">:</span> <span class="n">_parse_date_diff</span><span class="p">,</span> +</span><span id="DuckDB-129"><a href="#DuckDB-129"><span class="linenos">129</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">:</span> <span class="n">_parse_date_diff</span><span class="p">,</span> +</span><span id="DuckDB-130"><a href="#DuckDB-130"><span class="linenos">130</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-131"><a href="#DuckDB-131"><span class="linenos">131</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-132"><a href="#DuckDB-132"><span class="linenos">132</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">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="mi">1000</span><span class="p">))</span> +</span><span id="DuckDB-133"><a href="#DuckDB-133"><span class="linenos">133</span></a> <span class="p">),</span> +</span><span id="DuckDB-134"><a href="#DuckDB-134"><span class="linenos">134</span></a> <span class="s2">"LIST_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_sort_array_reverse</span><span class="p">,</span> +</span><span id="DuckDB-135"><a href="#DuckDB-135"><span class="linenos">135</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-136"><a href="#DuckDB-136"><span class="linenos">136</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-137"><a href="#DuckDB-137"><span class="linenos">137</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-138"><a href="#DuckDB-138"><span class="linenos">138</span></a> <span class="s2">"STRFTIME"</span><span class="p">:</span> <span class="n">format_time_lambda</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-139"><a href="#DuckDB-139"><span class="linenos">139</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-140"><a href="#DuckDB-140"><span class="linenos">140</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-141"><a href="#DuckDB-141"><span class="linenos">141</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-142"><a href="#DuckDB-142"><span class="linenos">142</span></a> <span class="s2">"STRPTIME"</span><span class="p">:</span> <span class="n">format_time_lambda</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-143"><a href="#DuckDB-143"><span class="linenos">143</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-144"><a href="#DuckDB-144"><span class="linenos">144</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-145"><a href="#DuckDB-145"><span class="linenos">145</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-146"><a href="#DuckDB-146"><span class="linenos">146</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-147"><a href="#DuckDB-147"><span class="linenos">147</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-148"><a href="#DuckDB-148"><span class="linenos">148</span></a> <span class="p">}</span> +</span><span id="DuckDB-149"><a href="#DuckDB-149"><span class="linenos">149</span></a> +</span><span id="DuckDB-150"><a href="#DuckDB-150"><span class="linenos">150</span></a> <span class="n">TYPE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-151"><a href="#DuckDB-151"><span class="linenos">151</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">TYPE_TOKENS</span><span class="p">,</span> +</span><span id="DuckDB-152"><a href="#DuckDB-152"><span class="linenos">152</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">UBIGINT</span><span class="p">,</span> +</span><span id="DuckDB-153"><a href="#DuckDB-153"><span class="linenos">153</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">UINT</span><span class="p">,</span> +</span><span id="DuckDB-154"><a href="#DuckDB-154"><span class="linenos">154</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">USMALLINT</span><span class="p">,</span> +</span><span id="DuckDB-155"><a href="#DuckDB-155"><span class="linenos">155</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">UTINYINT</span><span class="p">,</span> +</span><span id="DuckDB-156"><a href="#DuckDB-156"><span class="linenos">156</span></a> <span class="p">}</span> +</span><span id="DuckDB-157"><a href="#DuckDB-157"><span class="linenos">157</span></a> +</span><span id="DuckDB-158"><a href="#DuckDB-158"><span class="linenos">158</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-159"><a href="#DuckDB-159"><span class="linenos">159</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-160"><a href="#DuckDB-160"><span class="linenos">160</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-161"><a href="#DuckDB-161"><span class="linenos">161</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-162"><a href="#DuckDB-162"><span class="linenos">162</span></a> +</span><span id="DuckDB-163"><a href="#DuckDB-163"><span class="linenos">163</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-164"><a href="#DuckDB-164"><span class="linenos">164</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB-165"><a href="#DuckDB-165"><span class="linenos">165</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB-166"><a href="#DuckDB-166"><span class="linenos">166</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> +</span><span id="DuckDB-167"><a href="#DuckDB-167"><span class="linenos">167</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-168"><a href="#DuckDB-168"><span class="linenos">168</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB-169"><a href="#DuckDB-169"><span class="linenos">169</span></a> +</span><span id="DuckDB-170"><a href="#DuckDB-170"><span class="linenos">170</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-171"><a href="#DuckDB-171"><span class="linenos">171</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-172"><a href="#DuckDB-172"><span class="linenos">172</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-173"><a href="#DuckDB-173"><span class="linenos">173</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</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">"ARRAY"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> +</span><span id="DuckDB-174"><a href="#DuckDB-174"><span class="linenos">174</span></a> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">expressions</span> <span class="ow">and</span> <span class="n">e</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">find</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-175"><a href="#DuckDB-175"><span class="linenos">175</span></a> <span class="k">else</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LIST_VALUE"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">),</span> +</span><span id="DuckDB-176"><a href="#DuckDB-176"><span class="linenos">176</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-177"><a href="#DuckDB-177"><span class="linenos">177</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-178"><a href="#DuckDB-178"><span class="linenos">178</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-179"><a href="#DuckDB-179"><span class="linenos">179</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-180"><a href="#DuckDB-180"><span class="linenos">180</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"CURRENT_DATE"</span><span class="p">,</span> +</span><span id="DuckDB-181"><a href="#DuckDB-181"><span class="linenos">181</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"CURRENT_TIME"</span><span class="p">,</span> +</span><span id="DuckDB-182"><a href="#DuckDB-182"><span class="linenos">182</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> +</span><span id="DuckDB-183"><a href="#DuckDB-183"><span class="linenos">183</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-184"><a href="#DuckDB-184"><span class="linenos">184</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-185"><a href="#DuckDB-185"><span class="linenos">185</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-186"><a href="#DuckDB-186"><span class="linenos">186</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-187"><a href="#DuckDB-187"><span class="linenos">187</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-188"><a href="#DuckDB-188"><span class="linenos">188</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-189"><a href="#DuckDB-189"><span class="linenos">189</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-190"><a href="#DuckDB-190"><span class="linenos">190</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="s1">'day'</span><span class="p">)</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-191"><a href="#DuckDB-191"><span class="linenos">191</span></a> <span class="p">),</span> +</span><span id="DuckDB-192"><a href="#DuckDB-192"><span class="linenos">192</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-193"><a href="#DuckDB-193"><span class="linenos">193</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 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-194"><a href="#DuckDB-194"><span class="linenos">194</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 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-195"><a href="#DuckDB-195"><span class="linenos">195</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-196"><a href="#DuckDB-196"><span class="linenos">196</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-197"><a href="#DuckDB-197"><span class="linenos">197</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-198"><a href="#DuckDB-198"><span class="linenos">198</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_scalar_sql</span><span class="p">,</span> +</span><span id="DuckDB-199"><a href="#DuckDB-199"><span class="linenos">199</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtract</span><span class="p">:</span> <span class="n">arrow_json_extract_sql</span><span class="p">,</span> +</span><span id="DuckDB-200"><a href="#DuckDB-200"><span class="linenos">200</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtractScalar</span><span class="p">:</span> <span class="n">arrow_json_extract_scalar_sql</span><span class="p">,</span> +</span><span id="DuckDB-201"><a href="#DuckDB-201"><span class="linenos">201</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-202"><a href="#DuckDB-202"><span class="linenos">202</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-203"><a href="#DuckDB-203"><span class="linenos">203</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">:</span> <span class="n">no_properties_sql</span><span class="p">,</span> +</span><span id="DuckDB-204"><a href="#DuckDB-204"><span class="linenos">204</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-205"><a href="#DuckDB-205"><span class="linenos">205</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-206"><a href="#DuckDB-206"><span class="linenos">206</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-207"><a href="#DuckDB-207"><span class="linenos">207</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-208"><a href="#DuckDB-208"><span class="linenos">208</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-209"><a href="#DuckDB-209"><span class="linenos">209</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-210"><a href="#DuckDB-210"><span class="linenos">210</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-211"><a href="#DuckDB-211"><span class="linenos">211</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</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(</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">e</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span><span class="p">,</span> +</span><span id="DuckDB-212"><a href="#DuckDB-212"><span class="linenos">212</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">str_to_time_sql</span><span class="p">,</span> +</span><span id="DuckDB-213"><a href="#DuckDB-213"><span class="linenos">213</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="sa">f</span><span class="s2">"EPOCH(STRPTIME(</span><span 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="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 class="si">}</span><span class="s2">))"</span><span class="p">,</span> +</span><span id="DuckDB-214"><a href="#DuckDB-214"><span class="linenos">214</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-215"><a href="#DuckDB-215"><span class="linenos">215</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-216"><a href="#DuckDB-216"><span class="linenos">216</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="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">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 DATE)"</span><span class="p">,</span> +</span><span id="DuckDB-217"><a href="#DuckDB-217"><span class="linenos">217</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-218"><a href="#DuckDB-218"><span class="linenos">218</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="sa">f</span><span class="s2">"EPOCH(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 TIMESTAMP))"</span><span class="p">,</span> +</span><span id="DuckDB-219"><a href="#DuckDB-219"><span class="linenos">219</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="sa">f</span><span class="s2">"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="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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="DuckDB-220"><a href="#DuckDB-220"><span class="linenos">220</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-221"><a href="#DuckDB-221"><span class="linenos">221</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 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-222"><a href="#DuckDB-222"><span class="linenos">222</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> +</span><span id="DuckDB-223"><a href="#DuckDB-223"><span class="linenos">223</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="s2">"duckdb"</span><span class="p">),</span> +</span><span id="DuckDB-224"><a href="#DuckDB-224"><span class="linenos">224</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="sa">f</span><span class="s2">"STRFTIME(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">), </span><span class="si">{</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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="DuckDB-225"><a href="#DuckDB-225"><span class="linenos">225</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_TIMESTAMP"</span><span class="p">),</span> +</span><span id="DuckDB-226"><a href="#DuckDB-226"><span class="linenos">226</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-227"><a href="#DuckDB-227"><span class="linenos">227</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-228"><a href="#DuckDB-228"><span class="linenos">228</span></a> <span class="p">}</span> +</span><span id="DuckDB-229"><a href="#DuckDB-229"><span class="linenos">229</span></a> +</span><span id="DuckDB-230"><a href="#DuckDB-230"><span class="linenos">230</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-231"><a href="#DuckDB-231"><span class="linenos">231</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-232"><a href="#DuckDB-232"><span class="linenos">232</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> +</span><span id="DuckDB-233"><a href="#DuckDB-233"><span class="linenos">233</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">CHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="DuckDB-234"><a href="#DuckDB-234"><span class="linenos">234</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> +</span><span id="DuckDB-235"><a href="#DuckDB-235"><span class="linenos">235</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="DuckDB-236"><a href="#DuckDB-236"><span class="linenos">236</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="DuckDB-237"><a href="#DuckDB-237"><span class="linenos">237</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UINT</span><span class="p">:</span> <span class="s2">"UINTEGER"</span><span class="p">,</span> +</span><span id="DuckDB-238"><a href="#DuckDB-238"><span class="linenos">238</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> +</span><span id="DuckDB-239"><a href="#DuckDB-239"><span class="linenos">239</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="DuckDB-240"><a href="#DuckDB-240"><span class="linenos">240</span></a> <span class="p">}</span> +</span><span id="DuckDB-241"><a href="#DuckDB-241"><span class="linenos">241</span></a> +</span><span id="DuckDB-242"><a href="#DuckDB-242"><span class="linenos">242</span></a> <span class="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span><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">STAR_MAPPING</span><span class="p">,</span> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCLUDE"</span><span class="p">}</span> +</span><span id="DuckDB-243"><a href="#DuckDB-243"><span class="linenos">243</span></a> +</span><span id="DuckDB-244"><a href="#DuckDB-244"><span class="linenos">244</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">Column</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-245"><a href="#DuckDB-245"><span class="linenos">245</span></a> +</span><span id="DuckDB-246"><a href="#DuckDB-246"><span class="linenos">246</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB-247"><a href="#DuckDB-247"><span class="linenos">247</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">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="DuckDB-248"><a href="#DuckDB-248"><span class="linenos">248</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="DuckDB-249"><a href="#DuckDB-249"><span class="linenos">249</span></a> <span class="p">}</span> +</span><span id="DuckDB-250"><a href="#DuckDB-250"><span class="linenos">250</span></a> +</span><span id="DuckDB-251"><a href="#DuckDB-251"><span class="linenos">251</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-252"><a href="#DuckDB-252"><span class="linenos">252</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-253"><a href="#DuckDB-253"><span class="linenos">253</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-254"><a href="#DuckDB-254"><span class="linenos">254</span></a> +</span><span id="DuckDB-255"><a href="#DuckDB-255"><span class="linenos">255</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-256"><a href="#DuckDB-256"><span class="linenos">256</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> +</span><span id="DuckDB-257"><a href="#DuckDB-257"><span class="linenos">257</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-258"><a href="#DuckDB-258"><span class="linenos">258</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</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="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-261"><a href="#DuckDB-261"><span class="linenos">261</span></a> -</span><span id="DuckDB-262"><a href="#DuckDB-262"><span class="linenos">262</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="DuckDB-263"><a href="#DuckDB-263"><span class="linenos">263</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span> -</span><span id="DuckDB-264"><a href="#DuckDB-264"><span class="linenos">264</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB-265"><a href="#DuckDB-265"><span class="linenos">265</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 class="n">expression</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="o">=</span><span class="s2">"REPEATABLE"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">)</span> +</span><span id="DuckDB-260"><a href="#DuckDB-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> +</span><span id="DuckDB-261"><a href="#DuckDB-261"><span class="linenos">261</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-262"><a href="#DuckDB-262"><span class="linenos">262</span></a> +</span><span id="DuckDB-263"><a href="#DuckDB-263"><span class="linenos">263</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-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="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="DuckDB-266"><a href="#DuckDB-266"><span class="linenos">266</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span> +</span><span id="DuckDB-267"><a href="#DuckDB-267"><span class="linenos">267</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB-268"><a href="#DuckDB-268"><span class="linenos">268</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 class="n">expression</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="o">=</span><span class="s2">"REPEATABLE"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">)</span> </span></pre></div> @@ -550,6 +559,10 @@ <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="DuckDB.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="DuckDB.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="DuckDB.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="DuckDB.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="DuckDB.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="DuckDB.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="DuckDB.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="DuckDB.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="DuckDB.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -573,30 +586,30 @@ </div> <a class="headerlink" href="#DuckDB.Tokenizer"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Tokenizer-92"><a href="#DuckDB.Tokenizer-92"><span class="linenos"> 92</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-93"><a href="#DuckDB.Tokenizer-93"><span class="linenos"> 93</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB.Tokenizer-94"><a href="#DuckDB.Tokenizer-94"><span class="linenos"> 94</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-95"><a href="#DuckDB.Tokenizer-95"><span class="linenos"> 95</span></a> <span class="s2">"~"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-96"><a href="#DuckDB.Tokenizer-96"><span class="linenos"> 96</span></a> <span class="s2">":="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-97"><a href="#DuckDB.Tokenizer-97"><span class="linenos"> 97</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-98"><a href="#DuckDB.Tokenizer-98"><span class="linenos"> 98</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-99"><a href="#DuckDB.Tokenizer-99"><span class="linenos"> 99</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-100"><a href="#DuckDB.Tokenizer-100"><span class="linenos">100</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-101"><a href="#DuckDB.Tokenizer-101"><span class="linenos">101</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-102"><a href="#DuckDB.Tokenizer-102"><span class="linenos">102</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-103"><a href="#DuckDB.Tokenizer-103"><span class="linenos">103</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-104"><a href="#DuckDB.Tokenizer-104"><span class="linenos">104</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-105"><a href="#DuckDB.Tokenizer-105"><span class="linenos">105</span></a> <span class="s2">"INT1"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-106"><a href="#DuckDB.Tokenizer-106"><span class="linenos">106</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-107"><a href="#DuckDB.Tokenizer-107"><span class="linenos">107</span></a> <span class="s2">"NUMERIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-108"><a href="#DuckDB.Tokenizer-108"><span class="linenos">108</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-109"><a href="#DuckDB.Tokenizer-109"><span class="linenos">109</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-110"><a href="#DuckDB.Tokenizer-110"><span class="linenos">110</span></a> <span class="s2">"STRING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> -</span><span id="DuckDB.Tokenizer-111"><a href="#DuckDB.Tokenizer-111"><span class="linenos">111</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-112"><a href="#DuckDB.Tokenizer-112"><span class="linenos">112</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-113"><a href="#DuckDB.Tokenizer-113"><span class="linenos">113</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-114"><a href="#DuckDB.Tokenizer-114"><span class="linenos">114</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-115"><a href="#DuckDB.Tokenizer-115"><span class="linenos">115</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Tokenizer-95"><a href="#DuckDB.Tokenizer-95"><span class="linenos"> 95</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-96"><a href="#DuckDB.Tokenizer-96"><span class="linenos"> 96</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB.Tokenizer-97"><a href="#DuckDB.Tokenizer-97"><span class="linenos"> 97</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-98"><a href="#DuckDB.Tokenizer-98"><span class="linenos"> 98</span></a> <span class="s2">"~"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-99"><a href="#DuckDB.Tokenizer-99"><span class="linenos"> 99</span></a> <span class="s2">":="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-100"><a href="#DuckDB.Tokenizer-100"><span class="linenos">100</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-101"><a href="#DuckDB.Tokenizer-101"><span class="linenos">101</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-102"><a href="#DuckDB.Tokenizer-102"><span class="linenos">102</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-103"><a href="#DuckDB.Tokenizer-103"><span class="linenos">103</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-104"><a href="#DuckDB.Tokenizer-104"><span class="linenos">104</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-105"><a href="#DuckDB.Tokenizer-105"><span class="linenos">105</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-106"><a href="#DuckDB.Tokenizer-106"><span class="linenos">106</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-107"><a href="#DuckDB.Tokenizer-107"><span class="linenos">107</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-108"><a href="#DuckDB.Tokenizer-108"><span class="linenos">108</span></a> <span class="s2">"INT1"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-109"><a href="#DuckDB.Tokenizer-109"><span class="linenos">109</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-110"><a href="#DuckDB.Tokenizer-110"><span class="linenos">110</span></a> <span class="s2">"NUMERIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-111"><a href="#DuckDB.Tokenizer-111"><span class="linenos">111</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-112"><a href="#DuckDB.Tokenizer-112"><span class="linenos">112</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-113"><a href="#DuckDB.Tokenizer-113"><span class="linenos">113</span></a> <span class="s2">"STRING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> +</span><span id="DuckDB.Tokenizer-114"><a href="#DuckDB.Tokenizer-114"><span class="linenos">114</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-115"><a href="#DuckDB.Tokenizer-115"><span class="linenos">115</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-116"><a href="#DuckDB.Tokenizer-116"><span class="linenos">116</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-117"><a href="#DuckDB.Tokenizer-117"><span class="linenos">117</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-118"><a href="#DuckDB.Tokenizer-118"><span class="linenos">118</span></a> <span class="p">}</span> </span></pre></div> @@ -625,48 +638,48 @@ </div> <a class="headerlink" href="#DuckDB.Parser"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Parser-117"><a href="#DuckDB.Parser-117"><span class="linenos">117</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-118"><a href="#DuckDB.Parser-118"><span class="linenos">118</span></a> <span class="n">CONCAT_NULL_OUTPUTS_STRING</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="DuckDB.Parser-119"><a href="#DuckDB.Parser-119"><span class="linenos">119</span></a> -</span><span id="DuckDB.Parser-120"><a href="#DuckDB.Parser-120"><span class="linenos">120</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB.Parser-121"><a href="#DuckDB.Parser-121"><span class="linenos">121</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-122"><a href="#DuckDB.Parser-122"><span class="linenos">122</span></a> <span class="s2">"ARRAY_LENGTH"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="DuckDB.Parser-123"><a href="#DuckDB.Parser-123"><span class="linenos">123</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-124"><a href="#DuckDB.Parser-124"><span class="linenos">124</span></a> <span class="s2">"ARRAY_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_sort_array_reverse</span><span class="p">,</span> -</span><span id="DuckDB.Parser-125"><a href="#DuckDB.Parser-125"><span class="linenos">125</span></a> <span class="s2">"DATEDIFF"</span><span class="p">:</span> <span class="n">_parse_date_diff</span><span class="p">,</span> -</span><span id="DuckDB.Parser-126"><a href="#DuckDB.Parser-126"><span class="linenos">126</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">:</span> <span class="n">_parse_date_diff</span><span class="p">,</span> -</span><span id="DuckDB.Parser-127"><a href="#DuckDB.Parser-127"><span class="linenos">127</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-128"><a href="#DuckDB.Parser-128"><span class="linenos">128</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-129"><a href="#DuckDB.Parser-129"><span class="linenos">129</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">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="mi">1000</span><span class="p">))</span> -</span><span id="DuckDB.Parser-130"><a href="#DuckDB.Parser-130"><span class="linenos">130</span></a> <span class="p">),</span> -</span><span id="DuckDB.Parser-131"><a href="#DuckDB.Parser-131"><span class="linenos">131</span></a> <span class="s2">"LIST_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_sort_array_reverse</span><span class="p">,</span> -</span><span id="DuckDB.Parser-132"><a href="#DuckDB.Parser-132"><span class="linenos">132</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-133"><a href="#DuckDB.Parser-133"><span class="linenos">133</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-134"><a href="#DuckDB.Parser-134"><span class="linenos">134</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-135"><a href="#DuckDB.Parser-135"><span class="linenos">135</span></a> <span class="s2">"STRFTIME"</span><span class="p">:</span> <span class="n">format_time_lambda</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-136"><a href="#DuckDB.Parser-136"><span class="linenos">136</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-137"><a href="#DuckDB.Parser-137"><span class="linenos">137</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-138"><a href="#DuckDB.Parser-138"><span class="linenos">138</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-139"><a href="#DuckDB.Parser-139"><span class="linenos">139</span></a> <span class="s2">"STRPTIME"</span><span class="p">:</span> <span class="n">format_time_lambda</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-140"><a href="#DuckDB.Parser-140"><span class="linenos">140</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-141"><a href="#DuckDB.Parser-141"><span class="linenos">141</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-142"><a href="#DuckDB.Parser-142"><span class="linenos">142</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-143"><a href="#DuckDB.Parser-143"><span class="linenos">143</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-144"><a href="#DuckDB.Parser-144"><span class="linenos">144</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-145"><a href="#DuckDB.Parser-145"><span class="linenos">145</span></a> <span class="p">}</span> -</span><span id="DuckDB.Parser-146"><a href="#DuckDB.Parser-146"><span class="linenos">146</span></a> -</span><span id="DuckDB.Parser-147"><a href="#DuckDB.Parser-147"><span class="linenos">147</span></a> <span class="n">TYPE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB.Parser-148"><a href="#DuckDB.Parser-148"><span class="linenos">148</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">TYPE_TOKENS</span><span class="p">,</span> -</span><span id="DuckDB.Parser-149"><a href="#DuckDB.Parser-149"><span class="linenos">149</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">UBIGINT</span><span class="p">,</span> -</span><span id="DuckDB.Parser-150"><a href="#DuckDB.Parser-150"><span class="linenos">150</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">UINT</span><span class="p">,</span> -</span><span id="DuckDB.Parser-151"><a href="#DuckDB.Parser-151"><span class="linenos">151</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">USMALLINT</span><span class="p">,</span> -</span><span id="DuckDB.Parser-152"><a href="#DuckDB.Parser-152"><span class="linenos">152</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">UTINYINT</span><span class="p">,</span> -</span><span id="DuckDB.Parser-153"><a href="#DuckDB.Parser-153"><span class="linenos">153</span></a> <span class="p">}</span> -</span><span id="DuckDB.Parser-154"><a href="#DuckDB.Parser-154"><span class="linenos">154</span></a> -</span><span id="DuckDB.Parser-155"><a href="#DuckDB.Parser-155"><span class="linenos">155</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-156"><a href="#DuckDB.Parser-156"><span class="linenos">156</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-157"><a href="#DuckDB.Parser-157"><span class="linenos">157</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-158"><a href="#DuckDB.Parser-158"><span class="linenos">158</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> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Parser-120"><a href="#DuckDB.Parser-120"><span class="linenos">120</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-121"><a href="#DuckDB.Parser-121"><span class="linenos">121</span></a> <span class="n">CONCAT_NULL_OUTPUTS_STRING</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="DuckDB.Parser-122"><a href="#DuckDB.Parser-122"><span class="linenos">122</span></a> +</span><span id="DuckDB.Parser-123"><a href="#DuckDB.Parser-123"><span class="linenos">123</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB.Parser-124"><a href="#DuckDB.Parser-124"><span class="linenos">124</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-125"><a href="#DuckDB.Parser-125"><span class="linenos">125</span></a> <span class="s2">"ARRAY_LENGTH"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="DuckDB.Parser-126"><a href="#DuckDB.Parser-126"><span class="linenos">126</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-127"><a href="#DuckDB.Parser-127"><span class="linenos">127</span></a> <span class="s2">"ARRAY_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_sort_array_reverse</span><span class="p">,</span> +</span><span id="DuckDB.Parser-128"><a href="#DuckDB.Parser-128"><span class="linenos">128</span></a> <span class="s2">"DATEDIFF"</span><span class="p">:</span> <span class="n">_parse_date_diff</span><span class="p">,</span> +</span><span id="DuckDB.Parser-129"><a href="#DuckDB.Parser-129"><span class="linenos">129</span></a> <span class="s2">"DATE_DIFF"</span><span class="p">:</span> <span class="n">_parse_date_diff</span><span class="p">,</span> +</span><span id="DuckDB.Parser-130"><a href="#DuckDB.Parser-130"><span class="linenos">130</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-131"><a href="#DuckDB.Parser-131"><span class="linenos">131</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-132"><a href="#DuckDB.Parser-132"><span class="linenos">132</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">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="mi">1000</span><span class="p">))</span> +</span><span id="DuckDB.Parser-133"><a href="#DuckDB.Parser-133"><span class="linenos">133</span></a> <span class="p">),</span> +</span><span id="DuckDB.Parser-134"><a href="#DuckDB.Parser-134"><span class="linenos">134</span></a> <span class="s2">"LIST_REVERSE_SORT"</span><span class="p">:</span> <span class="n">_sort_array_reverse</span><span class="p">,</span> +</span><span id="DuckDB.Parser-135"><a href="#DuckDB.Parser-135"><span class="linenos">135</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-136"><a href="#DuckDB.Parser-136"><span class="linenos">136</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-137"><a href="#DuckDB.Parser-137"><span class="linenos">137</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-138"><a href="#DuckDB.Parser-138"><span class="linenos">138</span></a> <span class="s2">"STRFTIME"</span><span class="p">:</span> <span class="n">format_time_lambda</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-139"><a href="#DuckDB.Parser-139"><span class="linenos">139</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-140"><a href="#DuckDB.Parser-140"><span class="linenos">140</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-141"><a href="#DuckDB.Parser-141"><span class="linenos">141</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-142"><a href="#DuckDB.Parser-142"><span class="linenos">142</span></a> <span class="s2">"STRPTIME"</span><span class="p">:</span> <span class="n">format_time_lambda</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-143"><a href="#DuckDB.Parser-143"><span class="linenos">143</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-144"><a href="#DuckDB.Parser-144"><span class="linenos">144</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-145"><a href="#DuckDB.Parser-145"><span class="linenos">145</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-146"><a href="#DuckDB.Parser-146"><span class="linenos">146</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-147"><a href="#DuckDB.Parser-147"><span class="linenos">147</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-148"><a href="#DuckDB.Parser-148"><span class="linenos">148</span></a> <span class="p">}</span> +</span><span id="DuckDB.Parser-149"><a href="#DuckDB.Parser-149"><span class="linenos">149</span></a> +</span><span id="DuckDB.Parser-150"><a href="#DuckDB.Parser-150"><span class="linenos">150</span></a> <span class="n">TYPE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB.Parser-151"><a href="#DuckDB.Parser-151"><span class="linenos">151</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">TYPE_TOKENS</span><span class="p">,</span> +</span><span id="DuckDB.Parser-152"><a href="#DuckDB.Parser-152"><span class="linenos">152</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">UBIGINT</span><span class="p">,</span> +</span><span id="DuckDB.Parser-153"><a href="#DuckDB.Parser-153"><span class="linenos">153</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">UINT</span><span class="p">,</span> +</span><span id="DuckDB.Parser-154"><a href="#DuckDB.Parser-154"><span class="linenos">154</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">USMALLINT</span><span class="p">,</span> +</span><span id="DuckDB.Parser-155"><a href="#DuckDB.Parser-155"><span class="linenos">155</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">UTINYINT</span><span class="p">,</span> +</span><span id="DuckDB.Parser-156"><a href="#DuckDB.Parser-156"><span class="linenos">156</span></a> <span class="p">}</span> +</span><span id="DuckDB.Parser-157"><a href="#DuckDB.Parser-157"><span class="linenos">157</span></a> +</span><span id="DuckDB.Parser-158"><a href="#DuckDB.Parser-158"><span class="linenos">158</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-159"><a href="#DuckDB.Parser-159"><span class="linenos">159</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-160"><a href="#DuckDB.Parser-160"><span class="linenos">160</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-161"><a href="#DuckDB.Parser-161"><span class="linenos">161</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> @@ -715,112 +728,112 @@ Default: 3</li> </div> <a class="headerlink" href="#DuckDB.Generator"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator-160"><a href="#DuckDB.Generator-160"><span class="linenos">160</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-161"><a href="#DuckDB.Generator-161"><span class="linenos">161</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB.Generator-162"><a href="#DuckDB.Generator-162"><span class="linenos">162</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB.Generator-163"><a href="#DuckDB.Generator-163"><span class="linenos">163</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> -</span><span id="DuckDB.Generator-164"><a href="#DuckDB.Generator-164"><span class="linenos">164</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-165"><a href="#DuckDB.Generator-165"><span class="linenos">165</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="DuckDB.Generator-166"><a href="#DuckDB.Generator-166"><span class="linenos">166</span></a> -</span><span id="DuckDB.Generator-167"><a href="#DuckDB.Generator-167"><span class="linenos">167</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB.Generator-168"><a href="#DuckDB.Generator-168"><span class="linenos">168</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-169"><a href="#DuckDB.Generator-169"><span class="linenos">169</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-170"><a href="#DuckDB.Generator-170"><span class="linenos">170</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</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">"ARRAY"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> -</span><span id="DuckDB.Generator-171"><a href="#DuckDB.Generator-171"><span class="linenos">171</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">seq_get</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">)</span> -</span><span id="DuckDB.Generator-172"><a href="#DuckDB.Generator-172"><span class="linenos">172</span></a> <span class="k">else</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LIST_VALUE"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">),</span> -</span><span id="DuckDB.Generator-173"><a href="#DuckDB.Generator-173"><span class="linenos">173</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-174"><a href="#DuckDB.Generator-174"><span class="linenos">174</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-175"><a href="#DuckDB.Generator-175"><span class="linenos">175</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-176"><a href="#DuckDB.Generator-176"><span class="linenos">176</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-177"><a href="#DuckDB.Generator-177"><span class="linenos">177</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"CURRENT_DATE"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-178"><a href="#DuckDB.Generator-178"><span class="linenos">178</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"CURRENT_TIME"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-179"><a href="#DuckDB.Generator-179"><span class="linenos">179</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-180"><a href="#DuckDB.Generator-180"><span class="linenos">180</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-181"><a href="#DuckDB.Generator-181"><span class="linenos">181</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-182"><a href="#DuckDB.Generator-182"><span class="linenos">182</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-183"><a href="#DuckDB.Generator-183"><span class="linenos">183</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-184"><a href="#DuckDB.Generator-184"><span class="linenos">184</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-185"><a href="#DuckDB.Generator-185"><span class="linenos">185</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-186"><a href="#DuckDB.Generator-186"><span class="linenos">186</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-187"><a href="#DuckDB.Generator-187"><span class="linenos">187</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="s1">'day'</span><span class="p">)</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-188"><a href="#DuckDB.Generator-188"><span class="linenos">188</span></a> <span class="p">),</span> -</span><span id="DuckDB.Generator-189"><a href="#DuckDB.Generator-189"><span class="linenos">189</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-190"><a href="#DuckDB.Generator-190"><span class="linenos">190</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 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-191"><a href="#DuckDB.Generator-191"><span class="linenos">191</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 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-192"><a href="#DuckDB.Generator-192"><span class="linenos">192</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-193"><a href="#DuckDB.Generator-193"><span class="linenos">193</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-194"><a href="#DuckDB.Generator-194"><span class="linenos">194</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-195"><a href="#DuckDB.Generator-195"><span class="linenos">195</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_scalar_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-196"><a href="#DuckDB.Generator-196"><span class="linenos">196</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtract</span><span class="p">:</span> <span class="n">arrow_json_extract_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-197"><a href="#DuckDB.Generator-197"><span class="linenos">197</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtractScalar</span><span class="p">:</span> <span class="n">arrow_json_extract_scalar_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-198"><a href="#DuckDB.Generator-198"><span class="linenos">198</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-199"><a href="#DuckDB.Generator-199"><span class="linenos">199</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-200"><a href="#DuckDB.Generator-200"><span class="linenos">200</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">:</span> <span class="n">no_properties_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-201"><a href="#DuckDB.Generator-201"><span class="linenos">201</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-202"><a href="#DuckDB.Generator-202"><span class="linenos">202</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-203"><a href="#DuckDB.Generator-203"><span class="linenos">203</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-204"><a href="#DuckDB.Generator-204"><span class="linenos">204</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-205"><a href="#DuckDB.Generator-205"><span class="linenos">205</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-206"><a href="#DuckDB.Generator-206"><span class="linenos">206</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-207"><a href="#DuckDB.Generator-207"><span class="linenos">207</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-208"><a href="#DuckDB.Generator-208"><span class="linenos">208</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</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(</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">e</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-209"><a href="#DuckDB.Generator-209"><span class="linenos">209</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">str_to_time_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-210"><a href="#DuckDB.Generator-210"><span class="linenos">210</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="sa">f</span><span class="s2">"EPOCH(STRPTIME(</span><span 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="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 class="si">}</span><span class="s2">))"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-211"><a href="#DuckDB.Generator-211"><span class="linenos">211</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-212"><a href="#DuckDB.Generator-212"><span class="linenos">212</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-213"><a href="#DuckDB.Generator-213"><span class="linenos">213</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="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">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 DATE)"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-214"><a href="#DuckDB.Generator-214"><span class="linenos">214</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-215"><a href="#DuckDB.Generator-215"><span class="linenos">215</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="sa">f</span><span class="s2">"EPOCH(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 TIMESTAMP))"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-216"><a href="#DuckDB.Generator-216"><span class="linenos">216</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="sa">f</span><span class="s2">"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="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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-217"><a href="#DuckDB.Generator-217"><span class="linenos">217</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-218"><a href="#DuckDB.Generator-218"><span class="linenos">218</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 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-219"><a href="#DuckDB.Generator-219"><span class="linenos">219</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> -</span><span id="DuckDB.Generator-220"><a href="#DuckDB.Generator-220"><span class="linenos">220</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="s2">"duckdb"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-221"><a href="#DuckDB.Generator-221"><span class="linenos">221</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="sa">f</span><span class="s2">"STRFTIME(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">), </span><span class="si">{</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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-222"><a href="#DuckDB.Generator-222"><span class="linenos">222</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_TIMESTAMP"</span><span class="p">),</span> -</span><span id="DuckDB.Generator-223"><a href="#DuckDB.Generator-223"><span class="linenos">223</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-224"><a href="#DuckDB.Generator-224"><span class="linenos">224</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-225"><a href="#DuckDB.Generator-225"><span class="linenos">225</span></a> <span class="p">}</span> -</span><span id="DuckDB.Generator-226"><a href="#DuckDB.Generator-226"><span class="linenos">226</span></a> -</span><span id="DuckDB.Generator-227"><a href="#DuckDB.Generator-227"><span class="linenos">227</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB.Generator-228"><a href="#DuckDB.Generator-228"><span class="linenos">228</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-229"><a href="#DuckDB.Generator-229"><span class="linenos">229</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-230"><a href="#DuckDB.Generator-230"><span class="linenos">230</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-231"><a href="#DuckDB.Generator-231"><span class="linenos">231</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-232"><a href="#DuckDB.Generator-232"><span class="linenos">232</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-233"><a href="#DuckDB.Generator-233"><span class="linenos">233</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-234"><a href="#DuckDB.Generator-234"><span class="linenos">234</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UINT</span><span class="p">:</span> <span class="s2">"UINTEGER"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-235"><a href="#DuckDB.Generator-235"><span class="linenos">235</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-236"><a href="#DuckDB.Generator-236"><span class="linenos">236</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="DuckDB.Generator-237"><a href="#DuckDB.Generator-237"><span class="linenos">237</span></a> <span class="p">}</span> -</span><span id="DuckDB.Generator-238"><a href="#DuckDB.Generator-238"><span class="linenos">238</span></a> -</span><span id="DuckDB.Generator-239"><a href="#DuckDB.Generator-239"><span class="linenos">239</span></a> <span class="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span><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">STAR_MAPPING</span><span class="p">,</span> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCLUDE"</span><span class="p">}</span> -</span><span id="DuckDB.Generator-240"><a href="#DuckDB.Generator-240"><span class="linenos">240</span></a> -</span><span id="DuckDB.Generator-241"><a href="#DuckDB.Generator-241"><span class="linenos">241</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">Column</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-242"><a href="#DuckDB.Generator-242"><span class="linenos">242</span></a> -</span><span id="DuckDB.Generator-243"><a href="#DuckDB.Generator-243"><span class="linenos">243</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DuckDB.Generator-244"><a href="#DuckDB.Generator-244"><span class="linenos">244</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">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="DuckDB.Generator-245"><a href="#DuckDB.Generator-245"><span class="linenos">245</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="DuckDB.Generator-246"><a href="#DuckDB.Generator-246"><span class="linenos">246</span></a> <span class="p">}</span> -</span><span id="DuckDB.Generator-247"><a href="#DuckDB.Generator-247"><span class="linenos">247</span></a> -</span><span id="DuckDB.Generator-248"><a href="#DuckDB.Generator-248"><span class="linenos">248</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-249"><a href="#DuckDB.Generator-249"><span class="linenos">249</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-250"><a href="#DuckDB.Generator-250"><span class="linenos">250</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-251"><a href="#DuckDB.Generator-251"><span class="linenos">251</span></a> -</span><span id="DuckDB.Generator-252"><a href="#DuckDB.Generator-252"><span class="linenos">252</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-253"><a href="#DuckDB.Generator-253"><span class="linenos">253</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> -</span><span id="DuckDB.Generator-254"><a href="#DuckDB.Generator-254"><span class="linenos">254</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-255"><a href="#DuckDB.Generator-255"><span class="linenos">255</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> -</span><span id="DuckDB.Generator-256"><a href="#DuckDB.Generator-256"><span class="linenos">256</span></a> -</span><span id="DuckDB.Generator-257"><a href="#DuckDB.Generator-257"><span class="linenos">257</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> -</span><span id="DuckDB.Generator-258"><a href="#DuckDB.Generator-258"><span class="linenos">258</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> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator-163"><a href="#DuckDB.Generator-163"><span class="linenos">163</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-164"><a href="#DuckDB.Generator-164"><span class="linenos">164</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB.Generator-165"><a href="#DuckDB.Generator-165"><span class="linenos">165</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB.Generator-166"><a href="#DuckDB.Generator-166"><span class="linenos">166</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> +</span><span id="DuckDB.Generator-167"><a href="#DuckDB.Generator-167"><span class="linenos">167</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-168"><a href="#DuckDB.Generator-168"><span class="linenos">168</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="DuckDB.Generator-169"><a href="#DuckDB.Generator-169"><span class="linenos">169</span></a> +</span><span id="DuckDB.Generator-170"><a href="#DuckDB.Generator-170"><span class="linenos">170</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB.Generator-171"><a href="#DuckDB.Generator-171"><span class="linenos">171</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-172"><a href="#DuckDB.Generator-172"><span class="linenos">172</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-173"><a href="#DuckDB.Generator-173"><span class="linenos">173</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</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">"ARRAY"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> +</span><span id="DuckDB.Generator-174"><a href="#DuckDB.Generator-174"><span class="linenos">174</span></a> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">expressions</span> <span class="ow">and</span> <span class="n">e</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">find</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-175"><a href="#DuckDB.Generator-175"><span class="linenos">175</span></a> <span class="k">else</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LIST_VALUE"</span><span class="p">)(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">),</span> +</span><span id="DuckDB.Generator-176"><a href="#DuckDB.Generator-176"><span class="linenos">176</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-177"><a href="#DuckDB.Generator-177"><span class="linenos">177</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-178"><a href="#DuckDB.Generator-178"><span class="linenos">178</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-179"><a href="#DuckDB.Generator-179"><span class="linenos">179</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-180"><a href="#DuckDB.Generator-180"><span class="linenos">180</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"CURRENT_DATE"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-181"><a href="#DuckDB.Generator-181"><span class="linenos">181</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"CURRENT_TIME"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-182"><a href="#DuckDB.Generator-182"><span class="linenos">182</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-183"><a href="#DuckDB.Generator-183"><span class="linenos">183</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-184"><a href="#DuckDB.Generator-184"><span class="linenos">184</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-185"><a href="#DuckDB.Generator-185"><span class="linenos">185</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-186"><a href="#DuckDB.Generator-186"><span class="linenos">186</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-187"><a href="#DuckDB.Generator-187"><span class="linenos">187</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-188"><a href="#DuckDB.Generator-188"><span class="linenos">188</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-189"><a href="#DuckDB.Generator-189"><span class="linenos">189</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-190"><a href="#DuckDB.Generator-190"><span class="linenos">190</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="s1">'day'</span><span class="p">)</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-191"><a href="#DuckDB.Generator-191"><span class="linenos">191</span></a> <span class="p">),</span> +</span><span id="DuckDB.Generator-192"><a href="#DuckDB.Generator-192"><span class="linenos">192</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-193"><a href="#DuckDB.Generator-193"><span class="linenos">193</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 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-194"><a href="#DuckDB.Generator-194"><span class="linenos">194</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 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-195"><a href="#DuckDB.Generator-195"><span class="linenos">195</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-196"><a href="#DuckDB.Generator-196"><span class="linenos">196</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-197"><a href="#DuckDB.Generator-197"><span class="linenos">197</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-198"><a href="#DuckDB.Generator-198"><span class="linenos">198</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_scalar_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-199"><a href="#DuckDB.Generator-199"><span class="linenos">199</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtract</span><span class="p">:</span> <span class="n">arrow_json_extract_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-200"><a href="#DuckDB.Generator-200"><span class="linenos">200</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtractScalar</span><span class="p">:</span> <span class="n">arrow_json_extract_scalar_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-201"><a href="#DuckDB.Generator-201"><span class="linenos">201</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-202"><a href="#DuckDB.Generator-202"><span class="linenos">202</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-203"><a href="#DuckDB.Generator-203"><span class="linenos">203</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">:</span> <span class="n">no_properties_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-204"><a href="#DuckDB.Generator-204"><span class="linenos">204</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-205"><a href="#DuckDB.Generator-205"><span class="linenos">205</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-206"><a href="#DuckDB.Generator-206"><span class="linenos">206</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-207"><a href="#DuckDB.Generator-207"><span class="linenos">207</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-208"><a href="#DuckDB.Generator-208"><span class="linenos">208</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-209"><a href="#DuckDB.Generator-209"><span class="linenos">209</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-210"><a href="#DuckDB.Generator-210"><span class="linenos">210</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-211"><a href="#DuckDB.Generator-211"><span class="linenos">211</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</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(</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">e</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-212"><a href="#DuckDB.Generator-212"><span class="linenos">212</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">str_to_time_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-213"><a href="#DuckDB.Generator-213"><span class="linenos">213</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="sa">f</span><span class="s2">"EPOCH(STRPTIME(</span><span 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="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 class="si">}</span><span class="s2">))"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-214"><a href="#DuckDB.Generator-214"><span class="linenos">214</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-215"><a href="#DuckDB.Generator-215"><span class="linenos">215</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-216"><a href="#DuckDB.Generator-216"><span class="linenos">216</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="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">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 DATE)"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-217"><a href="#DuckDB.Generator-217"><span class="linenos">217</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-218"><a href="#DuckDB.Generator-218"><span class="linenos">218</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="sa">f</span><span class="s2">"EPOCH(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 TIMESTAMP))"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-219"><a href="#DuckDB.Generator-219"><span class="linenos">219</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="sa">f</span><span class="s2">"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="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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-220"><a href="#DuckDB.Generator-220"><span class="linenos">220</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-221"><a href="#DuckDB.Generator-221"><span class="linenos">221</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 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-222"><a href="#DuckDB.Generator-222"><span class="linenos">222</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> +</span><span id="DuckDB.Generator-223"><a href="#DuckDB.Generator-223"><span class="linenos">223</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="s2">"duckdb"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-224"><a href="#DuckDB.Generator-224"><span class="linenos">224</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="sa">f</span><span class="s2">"STRFTIME(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">), </span><span class="si">{</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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-225"><a href="#DuckDB.Generator-225"><span class="linenos">225</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_TIMESTAMP"</span><span class="p">),</span> +</span><span id="DuckDB.Generator-226"><a href="#DuckDB.Generator-226"><span class="linenos">226</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-227"><a href="#DuckDB.Generator-227"><span class="linenos">227</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-228"><a href="#DuckDB.Generator-228"><span class="linenos">228</span></a> <span class="p">}</span> +</span><span id="DuckDB.Generator-229"><a href="#DuckDB.Generator-229"><span class="linenos">229</span></a> +</span><span id="DuckDB.Generator-230"><a href="#DuckDB.Generator-230"><span class="linenos">230</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB.Generator-231"><a href="#DuckDB.Generator-231"><span class="linenos">231</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-232"><a href="#DuckDB.Generator-232"><span class="linenos">232</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-233"><a href="#DuckDB.Generator-233"><span class="linenos">233</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">CHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-234"><a href="#DuckDB.Generator-234"><span class="linenos">234</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-235"><a href="#DuckDB.Generator-235"><span class="linenos">235</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-236"><a href="#DuckDB.Generator-236"><span class="linenos">236</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-237"><a href="#DuckDB.Generator-237"><span class="linenos">237</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UINT</span><span class="p">:</span> <span class="s2">"UINTEGER"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-238"><a href="#DuckDB.Generator-238"><span class="linenos">238</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARBINARY</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-239"><a href="#DuckDB.Generator-239"><span class="linenos">239</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="DuckDB.Generator-240"><a href="#DuckDB.Generator-240"><span class="linenos">240</span></a> <span class="p">}</span> +</span><span id="DuckDB.Generator-241"><a href="#DuckDB.Generator-241"><span class="linenos">241</span></a> +</span><span id="DuckDB.Generator-242"><a href="#DuckDB.Generator-242"><span class="linenos">242</span></a> <span class="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span><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">STAR_MAPPING</span><span class="p">,</span> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCLUDE"</span><span class="p">}</span> +</span><span id="DuckDB.Generator-243"><a href="#DuckDB.Generator-243"><span class="linenos">243</span></a> +</span><span id="DuckDB.Generator-244"><a href="#DuckDB.Generator-244"><span class="linenos">244</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">Column</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-245"><a href="#DuckDB.Generator-245"><span class="linenos">245</span></a> +</span><span id="DuckDB.Generator-246"><a href="#DuckDB.Generator-246"><span class="linenos">246</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DuckDB.Generator-247"><a href="#DuckDB.Generator-247"><span class="linenos">247</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">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="DuckDB.Generator-248"><a href="#DuckDB.Generator-248"><span class="linenos">248</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="DuckDB.Generator-249"><a href="#DuckDB.Generator-249"><span class="linenos">249</span></a> <span class="p">}</span> +</span><span id="DuckDB.Generator-250"><a href="#DuckDB.Generator-250"><span class="linenos">250</span></a> +</span><span id="DuckDB.Generator-251"><a href="#DuckDB.Generator-251"><span class="linenos">251</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-252"><a href="#DuckDB.Generator-252"><span class="linenos">252</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-253"><a href="#DuckDB.Generator-253"><span class="linenos">253</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-254"><a href="#DuckDB.Generator-254"><span class="linenos">254</span></a> +</span><span id="DuckDB.Generator-255"><a href="#DuckDB.Generator-255"><span class="linenos">255</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-256"><a href="#DuckDB.Generator-256"><span class="linenos">256</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> +</span><span id="DuckDB.Generator-257"><a href="#DuckDB.Generator-257"><span class="linenos">257</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-258"><a href="#DuckDB.Generator-258"><span class="linenos">258</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> </span><span id="DuckDB.Generator-259"><a href="#DuckDB.Generator-259"><span class="linenos">259</span></a> -</span><span id="DuckDB.Generator-260"><a href="#DuckDB.Generator-260"><span class="linenos">260</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-261"><a href="#DuckDB.Generator-261"><span class="linenos">261</span></a> -</span><span id="DuckDB.Generator-262"><a href="#DuckDB.Generator-262"><span class="linenos">262</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="DuckDB.Generator-263"><a href="#DuckDB.Generator-263"><span class="linenos">263</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span> -</span><span id="DuckDB.Generator-264"><a href="#DuckDB.Generator-264"><span class="linenos">264</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="DuckDB.Generator-265"><a href="#DuckDB.Generator-265"><span class="linenos">265</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 class="n">expression</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="o">=</span><span class="s2">"REPEATABLE"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">)</span> +</span><span id="DuckDB.Generator-260"><a href="#DuckDB.Generator-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> +</span><span id="DuckDB.Generator-261"><a href="#DuckDB.Generator-261"><span class="linenos">261</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-262"><a href="#DuckDB.Generator-262"><span class="linenos">262</span></a> +</span><span id="DuckDB.Generator-263"><a href="#DuckDB.Generator-263"><span class="linenos">263</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-264"><a href="#DuckDB.Generator-264"><span class="linenos">264</span></a> +</span><span id="DuckDB.Generator-265"><a href="#DuckDB.Generator-265"><span class="linenos">265</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="DuckDB.Generator-266"><a href="#DuckDB.Generator-266"><span class="linenos">266</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span> +</span><span id="DuckDB.Generator-267"><a href="#DuckDB.Generator-267"><span class="linenos">267</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="DuckDB.Generator-268"><a href="#DuckDB.Generator-268"><span class="linenos">268</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 class="n">expression</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="o">=</span><span class="s2">"REPEATABLE"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">)</span> </span></pre></div> @@ -874,19 +887,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-248"><a href="#DuckDB.Generator.interval_sql-248"><span class="linenos">248</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-249"><a href="#DuckDB.Generator.interval_sql-249"><span class="linenos">249</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-250"><a href="#DuckDB.Generator.interval_sql-250"><span class="linenos">250</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-251"><a href="#DuckDB.Generator.interval_sql-251"><span class="linenos">251</span></a> -</span><span id="DuckDB.Generator.interval_sql-252"><a href="#DuckDB.Generator.interval_sql-252"><span class="linenos">252</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-253"><a href="#DuckDB.Generator.interval_sql-253"><span class="linenos">253</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> -</span><span id="DuckDB.Generator.interval_sql-254"><a href="#DuckDB.Generator.interval_sql-254"><span class="linenos">254</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-255"><a href="#DuckDB.Generator.interval_sql-255"><span class="linenos">255</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> -</span><span id="DuckDB.Generator.interval_sql-256"><a href="#DuckDB.Generator.interval_sql-256"><span class="linenos">256</span></a> -</span><span id="DuckDB.Generator.interval_sql-257"><a href="#DuckDB.Generator.interval_sql-257"><span class="linenos">257</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> -</span><span id="DuckDB.Generator.interval_sql-258"><a href="#DuckDB.Generator.interval_sql-258"><span class="linenos">258</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> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.interval_sql-251"><a href="#DuckDB.Generator.interval_sql-251"><span class="linenos">251</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-252"><a href="#DuckDB.Generator.interval_sql-252"><span class="linenos">252</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-253"><a href="#DuckDB.Generator.interval_sql-253"><span class="linenos">253</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-254"><a href="#DuckDB.Generator.interval_sql-254"><span class="linenos">254</span></a> +</span><span id="DuckDB.Generator.interval_sql-255"><a href="#DuckDB.Generator.interval_sql-255"><span class="linenos">255</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-256"><a href="#DuckDB.Generator.interval_sql-256"><span class="linenos">256</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">7</span> +</span><span id="DuckDB.Generator.interval_sql-257"><a href="#DuckDB.Generator.interval_sql-257"><span class="linenos">257</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-258"><a href="#DuckDB.Generator.interval_sql-258"><span class="linenos">258</span></a> <span class="n">multiplier</span> <span class="o">=</span> <span class="mi">90</span> </span><span id="DuckDB.Generator.interval_sql-259"><a href="#DuckDB.Generator.interval_sql-259"><span class="linenos">259</span></a> -</span><span id="DuckDB.Generator.interval_sql-260"><a href="#DuckDB.Generator.interval_sql-260"><span class="linenos">260</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.interval_sql-260"><a href="#DuckDB.Generator.interval_sql-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">multiplier</span><span class="p">:</span> +</span><span id="DuckDB.Generator.interval_sql-261"><a href="#DuckDB.Generator.interval_sql-261"><span class="linenos">261</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-262"><a href="#DuckDB.Generator.interval_sql-262"><span class="linenos">262</span></a> +</span><span id="DuckDB.Generator.interval_sql-263"><a href="#DuckDB.Generator.interval_sql-263"><span class="linenos">263</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> @@ -904,16 +917,70 @@ 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-262"><a href="#DuckDB.Generator.tablesample_sql-262"><span class="linenos">262</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="DuckDB.Generator.tablesample_sql-263"><a href="#DuckDB.Generator.tablesample_sql-263"><span class="linenos">263</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span> -</span><span id="DuckDB.Generator.tablesample_sql-264"><a href="#DuckDB.Generator.tablesample_sql-264"><span class="linenos">264</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-265"><a href="#DuckDB.Generator.tablesample_sql-265"><span class="linenos">265</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 class="n">expression</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="o">=</span><span class="s2">"REPEATABLE"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.tablesample_sql-265"><a href="#DuckDB.Generator.tablesample_sql-265"><span class="linenos">265</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="DuckDB.Generator.tablesample_sql-266"><a href="#DuckDB.Generator.tablesample_sql-266"><span class="linenos">266</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span> +</span><span id="DuckDB.Generator.tablesample_sql-267"><a href="#DuckDB.Generator.tablesample_sql-267"><span class="linenos">267</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-268"><a href="#DuckDB.Generator.tablesample_sql-268"><span class="linenos">268</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 class="n">expression</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="o">=</span><span class="s2">"REPEATABLE"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">)</span> </span></pre></div> </div> + <div id="DuckDB.Generator.can_identify" class="classattr"> + <input id="DuckDB.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="DuckDB.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#DuckDB.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="DuckDB.Generator.can_identify-247"><a href="#DuckDB.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="DuckDB.Generator.can_identify-248"><a href="#DuckDB.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="DuckDB.Generator.can_identify-249"><a href="#DuckDB.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="DuckDB.Generator.can_identify-250"><a href="#DuckDB.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="DuckDB.Generator.can_identify-251"><a href="#DuckDB.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="DuckDB.Generator.can_identify-252"><a href="#DuckDB.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="DuckDB.Generator.can_identify-253"><a href="#DuckDB.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="DuckDB.Generator.can_identify-254"><a href="#DuckDB.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="DuckDB.Generator.can_identify-255"><a href="#DuckDB.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="DuckDB.Generator.can_identify-256"><a href="#DuckDB.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="DuckDB.Generator.can_identify-257"><a href="#DuckDB.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="DuckDB.Generator.can_identify-258"><a href="#DuckDB.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="DuckDB.Generator.can_identify-259"><a href="#DuckDB.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="DuckDB.Generator.can_identify-260"><a href="#DuckDB.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="DuckDB.Generator.can_identify-261"><a href="#DuckDB.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="DuckDB.Generator.can_identify-262"><a href="#DuckDB.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="DuckDB.Generator.can_identify-263"><a href="#DuckDB.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="DuckDB.Generator.can_identify-264"><a href="#DuckDB.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="DuckDB.Generator.can_identify-265"><a href="#DuckDB.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="DuckDB.Generator.can_identify-266"><a href="#DuckDB.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -1015,6 +1082,7 @@ Default: True</li> <dd id="DuckDB.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="DuckDB.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="DuckDB.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="DuckDB.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="DuckDB.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="DuckDB.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="DuckDB.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/dialects/hive.html b/docs/sqlglot/dialects/hive.html index d5f7b16..dd35e9b 100644 --- a/docs/sqlglot/dialects/hive.html +++ b/docs/sqlglot/dialects/hive.html @@ -60,6 +60,9 @@ <li> <a class="function" href="#Hive.Generator.after_having_modifiers">after_having_modifiers</a> </li> + <li> + <a class="function" href="#Hive.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -244,282 +247,285 @@ </span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> <span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> <span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> -</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-157"><a href="#L-157"><span class="linenos">157</span></a> <span class="s2">"y"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> -</span><span id="L-158"><a href="#L-158"><span class="linenos">158</span></a> <span class="s2">"Y"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> -</span><span id="L-159"><a href="#L-159"><span class="linenos">159</span></a> <span class="s2">"YYYY"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> -</span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="s2">"yyyy"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> -</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="s2">"YY"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> -</span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a> <span class="s2">"yy"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> -</span><span id="L-163"><a href="#L-163"><span class="linenos">163</span></a> <span class="s2">"MMMM"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> -</span><span id="L-164"><a href="#L-164"><span class="linenos">164</span></a> <span class="s2">"MMM"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> -</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> <span class="s2">"MM"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> -</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a> <span class="s2">"M"</span><span class="p">:</span> <span class="s2">"%-m"</span><span class="p">,</span> -</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a> <span class="s2">"dd"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%d</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a> <span class="s2">"d"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%-d</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a> <span class="s2">"HH"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> -</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="s2">"H"</span><span class="p">:</span> <span class="s2">"%-H"</span><span class="p">,</span> -</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="s2">"hh"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> -</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="s2">"h"</span><span class="p">:</span> <span class="s2">"%-I"</span><span class="p">,</span> -</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="s2">"mm"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> -</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="s2">"m"</span><span class="p">:</span> <span class="s2">"%-M"</span><span class="p">,</span> -</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="s2">"ss"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> -</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> <span class="s2">"s"</span><span class="p">:</span> <span class="s2">"%-S"</span><span class="p">,</span> -</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="s2">"SSSSSS"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> <span class="s2">"a"</span><span class="p">:</span> <span class="s2">"%p"</span><span class="p">,</span> -</span><span id="L-179"><a href="#L-179"><span class="linenos">179</span></a> <span class="s2">"DD"</span><span class="p">:</span> <span class="s2">"%j"</span><span class="p">,</span> -</span><span id="L-180"><a href="#L-180"><span class="linenos">180</span></a> <span class="s2">"D"</span><span class="p">:</span> <span class="s2">"%-j"</span><span class="p">,</span> -</span><span id="L-181"><a href="#L-181"><span class="linenos">181</span></a> <span class="s2">"E"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-182"><a href="#L-182"><span class="linenos">182</span></a> <span class="s2">"EE"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-183"><a href="#L-183"><span class="linenos">183</span></a> <span class="s2">"EEE"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-184"><a href="#L-184"><span class="linenos">184</span></a> <span class="s2">"EEEE"</span><span class="p">:</span> <span class="s2">"%A"</span><span class="p">,</span> -</span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> <span class="p">}</span> -</span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a> -</span><span id="L-187"><a href="#L-187"><span class="linenos">187</span></a> <span class="n">DATE_FORMAT</span> <span class="o">=</span> <span class="s2">"'yyyy-MM-dd'"</span> -</span><span id="L-188"><a href="#L-188"><span class="linenos">188</span></a> <span class="n">DATEINT_FORMAT</span> <span class="o">=</span> <span class="s2">"'yyyyMMdd'"</span> -</span><span id="L-189"><a href="#L-189"><span class="linenos">189</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">"'yyyy-MM-dd HH:mm:ss'"</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 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-192"><a href="#L-192"><span class="linenos">192</span></a> <span class="n">QUOTES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">,</span> <span class="s1">'"'</span><span class="p">]</span> -</span><span id="L-193"><a href="#L-193"><span class="linenos">193</span></a> <span class="n">IDENTIFIERS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"`"</span><span class="p">]</span> -</span><span id="L-194"><a href="#L-194"><span class="linenos">194</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">]</span> -</span><span id="L-195"><a href="#L-195"><span class="linenos">195</span></a> <span class="n">ENCODE</span> <span class="o">=</span> <span class="s2">"utf-8"</span> -</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a> -</span><span id="L-197"><a href="#L-197"><span class="linenos">197</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-198"><a href="#L-198"><span class="linenos">198</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-199"><a href="#L-199"><span class="linenos">199</span></a> <span class="s2">"ADD ARCHIVE"</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-200"><a href="#L-200"><span class="linenos">200</span></a> <span class="s2">"ADD ARCHIVES"</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-201"><a href="#L-201"><span class="linenos">201</span></a> <span class="s2">"ADD FILE"</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-202"><a href="#L-202"><span class="linenos">202</span></a> <span class="s2">"ADD FILES"</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-203"><a href="#L-203"><span class="linenos">203</span></a> <span class="s2">"ADD JAR"</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-204"><a href="#L-204"><span class="linenos">204</span></a> <span class="s2">"ADD JARS"</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-205"><a href="#L-205"><span class="linenos">205</span></a> <span class="s2">"MSCK REPAIR"</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-206"><a href="#L-206"><span class="linenos">206</span></a> <span class="s2">"WITH SERDEPROPERTIES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SERDE_PROPERTIES</span><span class="p">,</span> -</span><span id="L-207"><a href="#L-207"><span class="linenos">207</span></a> <span class="p">}</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="n">NUMERIC_LITERALS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> <span class="s2">"L"</span><span class="p">:</span> <span class="s2">"BIGINT"</span><span class="p">,</span> -</span><span id="L-211"><a href="#L-211"><span class="linenos">211</span></a> <span class="s2">"S"</span><span class="p">:</span> <span class="s2">"SMALLINT"</span><span class="p">,</span> -</span><span id="L-212"><a href="#L-212"><span class="linenos">212</span></a> <span class="s2">"Y"</span><span class="p">:</span> <span class="s2">"TINYINT"</span><span class="p">,</span> -</span><span id="L-213"><a href="#L-213"><span class="linenos">213</span></a> <span class="s2">"D"</span><span class="p">:</span> <span class="s2">"DOUBLE"</span><span class="p">,</span> -</span><span id="L-214"><a href="#L-214"><span class="linenos">214</span></a> <span class="s2">"F"</span><span class="p">:</span> <span class="s2">"FLOAT"</span><span class="p">,</span> -</span><span id="L-215"><a href="#L-215"><span class="linenos">215</span></a> <span class="s2">"BD"</span><span class="p">:</span> <span class="s2">"DECIMAL"</span><span class="p">,</span> -</span><span id="L-216"><a href="#L-216"><span class="linenos">216</span></a> <span class="p">}</span> -</span><span id="L-217"><a href="#L-217"><span class="linenos">217</span></a> -</span><span id="L-218"><a href="#L-218"><span class="linenos">218</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-219"><a href="#L-219"><span class="linenos">219</span></a> <span class="n">LOG_DEFAULTS_TO_LN</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-220"><a href="#L-220"><span class="linenos">220</span></a> <span class="n">STRICT_CAST</span> <span class="o">=</span> <span class="kc">False</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">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-223"><a href="#L-223"><span class="linenos">223</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-224"><a href="#L-224"><span class="linenos">224</span></a> <span class="s2">"BASE64"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ToBase64</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-225"><a href="#L-225"><span class="linenos">225</span></a> <span class="s2">"COLLECT_LIST"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-226"><a href="#L-226"><span class="linenos">226</span></a> <span class="s2">"DATE_ADD"</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">TsOrDsAdd</span><span class="p">(</span> -</span><span id="L-227"><a href="#L-227"><span class="linenos">227</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">unit</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">"DAY"</span><span class="p">)</span> -</span><span id="L-228"><a href="#L-228"><span class="linenos">228</span></a> <span class="p">),</span> -</span><span id="L-229"><a href="#L-229"><span class="linenos">229</span></a> <span class="s2">"DATEDIFF"</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">DateDiff</span><span class="p">(</span> -</span><span id="L-230"><a href="#L-230"><span class="linenos">230</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)),</span> -</span><span id="L-231"><a href="#L-231"><span class="linenos">231</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span> -</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="p">),</span> -</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="s2">"DATE_SUB"</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">TsOrDsAdd</span><span class="p">(</span> -</span><span id="L-234"><a href="#L-234"><span class="linenos">234</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-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Mul</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</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="o">-</span><span class="mi">1</span><span class="p">)),</span> -</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> <span class="n">unit</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">"DAY"</span><span class="p">),</span> -</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> <span class="p">),</span> -</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="s2">"DATE_FORMAT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">format_time_lambda</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">"hive"</span><span class="p">)(</span> -</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> <span class="p">[</span> -</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)),</span> -</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> <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-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="p">]</span> -</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> <span class="p">),</span> -</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <span class="s2">"DAY"</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">Day</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">))),</span> -</span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="s2">"FROM_UNIXTIME"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">UnixToStr</span><span class="p">,</span> <span class="s2">"hive"</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> -</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="s2">"GET_JSON_OBJECT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> <span class="s2">"LOCATE"</span><span class="p">:</span> <span class="n">locate_to_strposition</span><span class="p">,</span> -</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> <span class="s2">"MAP"</span><span class="p">:</span> <span class="n">parse_var_map</span><span class="p">,</span> -</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> <span class="s2">"MONTH"</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">Month</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">)),</span> -</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> <span class="s2">"PERCENTILE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> <span class="s2">"PERCENTILE_APPROX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-252"><a href="#L-252"><span class="linenos">252</span></a> <span class="s2">"COLLECT_SET"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-253"><a href="#L-253"><span class="linenos">253</span></a> <span class="s2">"SIZE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a> <span class="s2">"SPLIT"</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-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="s2">"TO_DATE"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">,</span> <span class="s2">"hive"</span><span class="p">),</span> -</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> <span class="s2">"TO_JSON"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a> <span class="s2">"UNBASE64"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase64</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-258"><a href="#L-258"><span class="linenos">258</span></a> <span class="s2">"UNIX_TIMESTAMP"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">,</span> <span class="s2">"hive"</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> -</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="s2">"YEAR"</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">Year</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">)),</span> -</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> <span class="p">}</span> -</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> -</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="n">PROPERTY_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-263"><a href="#L-263"><span class="linenos">263</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">PROPERTY_PARSERS</span><span class="p">,</span> -</span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> <span class="s2">"WITH SERDEPROPERTIES"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</span><span class="p">(</span> -</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a> <span class="n">expressions</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_property</span><span class="p">)</span> -</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a> <span class="p">),</span> -</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> <span class="p">}</span> -</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> -</span><span id="L-269"><a href="#L-269"><span class="linenos">269</span></a> <span class="n">QUERY_MODIFIER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-270"><a href="#L-270"><span class="linenos">270</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">QUERY_MODIFIER_PARSERS</span><span class="p">,</span> -</span><span id="L-271"><a href="#L-271"><span class="linenos">271</span></a> <span class="s2">"distribute"</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Distribute</span><span class="p">,</span> <span class="s2">"DISTRIBUTE"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">),</span> -</span><span id="L-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="s2">"sort"</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">,</span> <span class="s2">"SORT"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">),</span> -</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="s2">"cluster"</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">,</span> <span class="s2">"CLUSTER"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">),</span> -</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="p">}</span> -</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a> -</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span> -</span><span id="L-277"><a href="#L-277"><span class="linenos">277</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</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="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-278"><a href="#L-278"><span class="linenos">278</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-279"><a href="#L-279"><span class="linenos">279</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a><span class="sd"> Spark (and most likely Hive) treats casts to CHAR(length) and VARCHAR(length) as casts to</span> -</span><span id="L-281"><a href="#L-281"><span class="linenos">281</span></a><span class="sd"> STRING in all contexts except for schema definitions. For example, this is in Spark v3.4.0:</span> -</span><span id="L-282"><a href="#L-282"><span class="linenos">282</span></a> -</span><span id="L-283"><a href="#L-283"><span class="linenos">283</span></a><span class="sd"> spark-sql (default)> select cast(1234 as varchar(2));</span> -</span><span id="L-284"><a href="#L-284"><span class="linenos">284</span></a><span class="sd"> 23/06/06 15:51:18 WARN CharVarcharUtils: The Spark cast operator does not support</span> -</span><span id="L-285"><a href="#L-285"><span class="linenos">285</span></a><span class="sd"> char/varchar type and simply treats them as string type. Please use string type</span> -</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a><span class="sd"> directly to avoid confusion. Otherwise, you can set spark.sql.legacy.charVarcharAsString</span> -</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a><span class="sd"> to true, so that Spark treat them as string type as same as Spark 3.0 and earlier</span> -</span><span id="L-288"><a href="#L-288"><span class="linenos">288</span></a> -</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a><span class="sd"> 1234</span> -</span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a><span class="sd"> Time taken: 4.265 seconds, Fetched 1 row(s)</span> +</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> <span class="c1"># https://spark.apache.org/docs/latest/sql-ref-identifier.html#description</span> +</span><span id="L-157"><a href="#L-157"><span class="linenos">157</span></a> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="o">=</span> <span class="kc">None</span> +</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="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="s2">"y"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> +</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="s2">"Y"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> +</span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a> <span class="s2">"YYYY"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> +</span><span id="L-163"><a href="#L-163"><span class="linenos">163</span></a> <span class="s2">"yyyy"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> +</span><span id="L-164"><a href="#L-164"><span class="linenos">164</span></a> <span class="s2">"YY"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> +</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> <span class="s2">"yy"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> +</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a> <span class="s2">"MMMM"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> +</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a> <span class="s2">"MMM"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> +</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a> <span class="s2">"MM"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> +</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a> <span class="s2">"M"</span><span class="p">:</span> <span class="s2">"%-m"</span><span class="p">,</span> +</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="s2">"dd"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%d</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="s2">"d"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%-d</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="s2">"HH"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> +</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="s2">"H"</span><span class="p">:</span> <span class="s2">"%-H"</span><span class="p">,</span> +</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="s2">"hh"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> +</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="s2">"h"</span><span class="p">:</span> <span class="s2">"%-I"</span><span class="p">,</span> +</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> <span class="s2">"mm"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> +</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="s2">"m"</span><span class="p">:</span> <span class="s2">"%-M"</span><span class="p">,</span> +</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> <span class="s2">"ss"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> +</span><span id="L-179"><a href="#L-179"><span class="linenos">179</span></a> <span class="s2">"s"</span><span class="p">:</span> <span class="s2">"%-S"</span><span class="p">,</span> +</span><span id="L-180"><a href="#L-180"><span class="linenos">180</span></a> <span class="s2">"SSSSSS"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-181"><a href="#L-181"><span class="linenos">181</span></a> <span class="s2">"a"</span><span class="p">:</span> <span class="s2">"%p"</span><span class="p">,</span> +</span><span id="L-182"><a href="#L-182"><span class="linenos">182</span></a> <span class="s2">"DD"</span><span class="p">:</span> <span class="s2">"%j"</span><span class="p">,</span> +</span><span id="L-183"><a href="#L-183"><span class="linenos">183</span></a> <span class="s2">"D"</span><span class="p">:</span> <span class="s2">"%-j"</span><span class="p">,</span> +</span><span id="L-184"><a href="#L-184"><span class="linenos">184</span></a> <span class="s2">"E"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> <span class="s2">"EE"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a> <span class="s2">"EEE"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-187"><a href="#L-187"><span class="linenos">187</span></a> <span class="s2">"EEEE"</span><span class="p">:</span> <span class="s2">"%A"</span><span class="p">,</span> +</span><span id="L-188"><a href="#L-188"><span class="linenos">188</span></a> <span class="p">}</span> +</span><span id="L-189"><a href="#L-189"><span class="linenos">189</span></a> +</span><span id="L-190"><a href="#L-190"><span class="linenos">190</span></a> <span class="n">DATE_FORMAT</span> <span class="o">=</span> <span class="s2">"'yyyy-MM-dd'"</span> +</span><span id="L-191"><a href="#L-191"><span class="linenos">191</span></a> <span class="n">DATEINT_FORMAT</span> <span class="o">=</span> <span class="s2">"'yyyyMMdd'"</span> +</span><span id="L-192"><a href="#L-192"><span class="linenos">192</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">"'yyyy-MM-dd HH:mm:ss'"</span> +</span><span id="L-193"><a href="#L-193"><span class="linenos">193</span></a> +</span><span id="L-194"><a href="#L-194"><span class="linenos">194</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-195"><a href="#L-195"><span class="linenos">195</span></a> <span class="n">QUOTES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">,</span> <span class="s1">'"'</span><span class="p">]</span> +</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a> <span class="n">IDENTIFIERS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"`"</span><span class="p">]</span> +</span><span id="L-197"><a href="#L-197"><span class="linenos">197</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">]</span> +</span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> <span class="n">ENCODE</span> <span class="o">=</span> <span class="s2">"utf-8"</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 class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-201"><a href="#L-201"><span class="linenos">201</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-202"><a href="#L-202"><span class="linenos">202</span></a> <span class="s2">"ADD ARCHIVE"</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-203"><a href="#L-203"><span class="linenos">203</span></a> <span class="s2">"ADD ARCHIVES"</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-204"><a href="#L-204"><span class="linenos">204</span></a> <span class="s2">"ADD FILE"</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-205"><a href="#L-205"><span class="linenos">205</span></a> <span class="s2">"ADD FILES"</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-206"><a href="#L-206"><span class="linenos">206</span></a> <span class="s2">"ADD JAR"</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-207"><a href="#L-207"><span class="linenos">207</span></a> <span class="s2">"ADD JARS"</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-208"><a href="#L-208"><span class="linenos">208</span></a> <span class="s2">"MSCK REPAIR"</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-209"><a href="#L-209"><span class="linenos">209</span></a> <span class="s2">"WITH SERDEPROPERTIES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SERDE_PROPERTIES</span><span class="p">,</span> +</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> <span class="p">}</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="n">NUMERIC_LITERALS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-213"><a href="#L-213"><span class="linenos">213</span></a> <span class="s2">"L"</span><span class="p">:</span> <span class="s2">"BIGINT"</span><span class="p">,</span> +</span><span id="L-214"><a href="#L-214"><span class="linenos">214</span></a> <span class="s2">"S"</span><span class="p">:</span> <span class="s2">"SMALLINT"</span><span class="p">,</span> +</span><span id="L-215"><a href="#L-215"><span class="linenos">215</span></a> <span class="s2">"Y"</span><span class="p">:</span> <span class="s2">"TINYINT"</span><span class="p">,</span> +</span><span id="L-216"><a href="#L-216"><span class="linenos">216</span></a> <span class="s2">"D"</span><span class="p">:</span> <span class="s2">"DOUBLE"</span><span class="p">,</span> +</span><span id="L-217"><a href="#L-217"><span class="linenos">217</span></a> <span class="s2">"F"</span><span class="p">:</span> <span class="s2">"FLOAT"</span><span class="p">,</span> +</span><span id="L-218"><a href="#L-218"><span class="linenos">218</span></a> <span class="s2">"BD"</span><span class="p">:</span> <span class="s2">"DECIMAL"</span><span class="p">,</span> +</span><span id="L-219"><a href="#L-219"><span class="linenos">219</span></a> <span class="p">}</span> +</span><span id="L-220"><a href="#L-220"><span class="linenos">220</span></a> +</span><span id="L-221"><a href="#L-221"><span class="linenos">221</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-222"><a href="#L-222"><span class="linenos">222</span></a> <span class="n">LOG_DEFAULTS_TO_LN</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">STRICT_CAST</span> <span class="o">=</span> <span class="kc">False</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">FUNCTIONS</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">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-227"><a href="#L-227"><span class="linenos">227</span></a> <span class="s2">"BASE64"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ToBase64</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-228"><a href="#L-228"><span class="linenos">228</span></a> <span class="s2">"COLLECT_LIST"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-229"><a href="#L-229"><span class="linenos">229</span></a> <span class="s2">"DATE_ADD"</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">TsOrDsAdd</span><span class="p">(</span> +</span><span id="L-230"><a href="#L-230"><span class="linenos">230</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">unit</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">"DAY"</span><span class="p">)</span> +</span><span id="L-231"><a href="#L-231"><span class="linenos">231</span></a> <span class="p">),</span> +</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="s2">"DATEDIFF"</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">DateDiff</span><span class="p">(</span> +</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)),</span> +</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span> +</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="p">),</span> +</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> <span class="s2">"DATE_SUB"</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">TsOrDsAdd</span><span class="p">(</span> +</span><span id="L-237"><a href="#L-237"><span class="linenos">237</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-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Mul</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</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="o">-</span><span class="mi">1</span><span class="p">)),</span> +</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> <span class="n">unit</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">"DAY"</span><span class="p">),</span> +</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="p">),</span> +</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> <span class="s2">"DATE_FORMAT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">format_time_lambda</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">"hive"</span><span class="p">)(</span> +</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="p">[</span> +</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)),</span> +</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <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-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="p">]</span> +</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="p">),</span> +</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> <span class="s2">"DAY"</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">Day</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">))),</span> +</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> <span class="s2">"FROM_UNIXTIME"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">UnixToStr</span><span class="p">,</span> <span class="s2">"hive"</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> +</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> <span class="s2">"GET_JSON_OBJECT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> <span class="s2">"LOCATE"</span><span class="p">:</span> <span class="n">locate_to_strposition</span><span class="p">,</span> +</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> <span class="s2">"MAP"</span><span class="p">:</span> <span class="n">parse_var_map</span><span class="p">,</span> +</span><span id="L-252"><a href="#L-252"><span class="linenos">252</span></a> <span class="s2">"MONTH"</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">Month</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">)),</span> +</span><span id="L-253"><a href="#L-253"><span class="linenos">253</span></a> <span class="s2">"PERCENTILE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a> <span class="s2">"PERCENTILE_APPROX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="s2">"COLLECT_SET"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> <span class="s2">"SIZE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a> <span class="s2">"SPLIT"</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-258"><a href="#L-258"><span class="linenos">258</span></a> <span class="s2">"TO_DATE"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">,</span> <span class="s2">"hive"</span><span class="p">),</span> +</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="s2">"TO_JSON"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> <span class="s2">"UNBASE64"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase64</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> <span class="s2">"UNIX_TIMESTAMP"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">,</span> <span class="s2">"hive"</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> +</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="s2">"YEAR"</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">Year</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">)),</span> +</span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a> <span class="p">}</span> +</span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> +</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a> <span class="n">PROPERTY_PARSERS</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">PROPERTY_PARSERS</span><span class="p">,</span> +</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> <span class="s2">"WITH SERDEPROPERTIES"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</span><span class="p">(</span> +</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> <span class="n">expressions</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_property</span><span class="p">)</span> +</span><span id="L-269"><a href="#L-269"><span class="linenos">269</span></a> <span class="p">),</span> +</span><span id="L-270"><a href="#L-270"><span class="linenos">270</span></a> <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">QUERY_MODIFIER_PARSERS</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">QUERY_MODIFIER_PARSERS</span><span class="p">,</span> +</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="s2">"cluster"</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CLUSTER_BY</span><span class="p">),</span> +</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a> <span class="s2">"distribute"</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Distribute</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DISTRIBUTE_BY</span><span class="p">),</span> +</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a> <span class="s2">"sort"</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SORT_BY</span><span class="p">),</span> +</span><span id="L-277"><a href="#L-277"><span class="linenos">277</span></a> <span class="p">}</span> +</span><span id="L-278"><a href="#L-278"><span class="linenos">278</span></a> +</span><span id="L-279"><a href="#L-279"><span class="linenos">279</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span> +</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</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="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-281"><a href="#L-281"><span class="linenos">281</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-282"><a href="#L-282"><span class="linenos">282</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-283"><a href="#L-283"><span class="linenos">283</span></a><span class="sd"> Spark (and most likely Hive) treats casts to CHAR(length) and VARCHAR(length) as casts to</span> +</span><span id="L-284"><a href="#L-284"><span class="linenos">284</span></a><span class="sd"> STRING in all contexts except for schema definitions. For example, this is in Spark v3.4.0:</span> +</span><span id="L-285"><a href="#L-285"><span class="linenos">285</span></a> +</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a><span class="sd"> spark-sql (default)> select cast(1234 as varchar(2));</span> +</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a><span class="sd"> 23/06/06 15:51:18 WARN CharVarcharUtils: The Spark cast operator does not support</span> +</span><span id="L-288"><a href="#L-288"><span class="linenos">288</span></a><span class="sd"> char/varchar type and simply treats them as string type. Please use string type</span> +</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a><span class="sd"> directly to avoid confusion. Otherwise, you can set spark.sql.legacy.charVarcharAsString</span> +</span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a><span class="sd"> to true, so that Spark treat them as string type as same as Spark 3.0 and earlier</span> </span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a> -</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a><span class="sd"> This shows that Spark doesn't truncate the value into '12', which is inconsistent with</span> -</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a><span class="sd"> what other dialects (e.g. postgres) do, so we need to drop the length to transpile correctly.</span> +</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a><span class="sd"> 1234</span> +</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a><span class="sd"> Time taken: 4.265 seconds, Fetched 1 row(s)</span> </span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a> -</span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a><span class="sd"> Reference: https://spark.apache.org/docs/latest/sql-ref-datatypes.html</span> -</span><span id="L-296"><a href="#L-296"><span class="linenos">296</span></a><span class="sd"> """</span> -</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="L-298"><a href="#L-298"><span class="linenos">298</span></a> -</span><span id="L-299"><a href="#L-299"><span class="linenos">299</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">schema</span><span class="p">:</span> -</span><span id="L-300"><a href="#L-300"><span class="linenos">300</span></a> <span class="k">return</span> <span class="n">this</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> -</span><span id="L-301"><a href="#L-301"><span class="linenos">301</span></a> <span class="k">lambda</span> <span class="n">node</span><span class="p">:</span> <span class="n">node</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">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-302"><a href="#L-302"><span class="linenos">302</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="ow">and</span> <span class="n">node</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"char"</span><span class="p">,</span> <span class="s2">"varchar"</span><span class="p">)</span> -</span><span id="L-303"><a href="#L-303"><span class="linenos">303</span></a> <span class="k">else</span> <span class="n">node</span><span class="p">,</span> -</span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="L-305"><a href="#L-305"><span class="linenos">305</span></a> <span class="p">)</span> -</span><span id="L-306"><a href="#L-306"><span class="linenos">306</span></a> -</span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a> -</span><span id="L-309"><a href="#L-309"><span class="linenos">309</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-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> -</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a> <span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> <span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-313"><a href="#L-313"><span class="linenos">313</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> <span class="n">INDEX_ON</span> <span class="o">=</span> <span class="s2">"ON TABLE"</span> -</span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> -</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-318"><a href="#L-318"><span class="linenos">318</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-319"><a href="#L-319"><span class="linenos">319</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="s2">"STRING"</span><span class="p">,</span> -</span><span id="L-320"><a href="#L-320"><span class="linenos">320</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATETIME</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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">"BINARY"</span><span class="p">,</span> -</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIT</span><span class="p">:</span> <span class="s2">"BOOLEAN"</span><span class="p">,</span> -</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a> <span class="p">}</span> -</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a> -</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-327"><a href="#L-327"><span class="linenos">327</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-328"><a href="#L-328"><span class="linenos">328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Group</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">unalias_group</span><span class="p">]),</span> -</span><span id="L-329"><a href="#L-329"><span class="linenos">329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="L-330"><a href="#L-330"><span class="linenos">330</span></a> <span class="p">[</span> -</span><span id="L-331"><a href="#L-331"><span class="linenos">331</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">,</span> -</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> -</span><span id="L-333"><a href="#L-333"><span class="linenos">333</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">unnest_to_explode</span><span class="p">,</span> -</span><span id="L-334"><a href="#L-334"><span class="linenos">334</span></a> <span class="p">]</span> -</span><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a> <span class="p">),</span> -</span><span id="L-336"><a href="#L-336"><span class="linenos">336</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> <span class="n">_property_sql</span><span class="p">,</span> -</span><span id="L-337"><a href="#L-337"><span class="linenos">337</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-338"><a href="#L-338"><span class="linenos">338</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">),</span> -</span><span id="L-339"><a href="#L-339"><span class="linenos">339</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayJoin</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">"CONCAT_WS"</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 class="p">),</span> -</span><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SIZE"</span><span class="p">),</span> -</span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySort</span><span class="p">:</span> <span class="n">_array_sort_sql</span><span class="p">,</span> -</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">:</span> <span class="n">no_recursive_cte_sql</span><span class="p">,</span> -</span><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_add_date_sql</span><span class="p">,</span> -</span><span id="L-344"><a href="#L-344"><span class="linenos">344</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="n">_date_diff_sql</span><span class="p">,</span> -</span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_DATE"</span><span class="p">),</span> -</span><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_add_date_sql</span><span class="p">,</span> -</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateToDi</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(DATE_FORMAT(</span><span 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">Hive</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-348"><a href="#L-348"><span class="linenos">348</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 class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"TO_DATE(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 STRING), </span><span class="si">{</span><span class="n">Hive</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</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">"STORED AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="w"> </span><span class="k">if</span><span class="w"> </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="w"> </span><span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">e</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="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase64</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNBASE64"</span><span class="p">),</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">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">,</span> -</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> -</span><span id="L-353"><a href="#L-353"><span class="linenos">353</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"GET_JSON_OBJECT"</span><span class="p">),</span> -</span><span id="L-354"><a href="#L-354"><span class="linenos">354</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"GET_JSON_OBJECT"</span><span class="p">),</span> -</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="p">:</span> <span class="n">_json_format_sql</span><span class="p">,</span> -</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">:</span> <span class="n">left_to_substring_sql</span><span class="p">,</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">Map</span><span class="p">:</span> <span class="n">var_map_sql</span><span class="p">,</span> -</span><span id="L-358"><a href="#L-358"><span class="linenos">358</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> -</span><span id="L-359"><a href="#L-359"><span class="linenos">359</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> -</span><span id="L-360"><a href="#L-360"><span class="linenos">360</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</span><span class="p">:</span> <span class="n">var_map_sql</span><span class="p">,</span> -</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> <span class="n">create_with_partitions_sql</span><span class="p">,</span> -</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"PERCENTILE"</span><span class="p">),</span> -</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"PERCENTILE_APPROX"</span><span class="p">),</span> -</span><span id="L-364"><a href="#L-364"><span class="linenos">364</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</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">"RLIKE"</span><span class="p">),</span> -</span><span id="L-365"><a href="#L-365"><span class="linenos">365</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">"SPLIT"</span><span class="p">),</span> -</span><span id="L-366"><a href="#L-366"><span class="linenos">366</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Right</span><span class="p">:</span> <span class="n">right_to_substring_sql</span><span class="p">,</span> -</span><span id="L-367"><a href="#L-367"><span class="linenos">367</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-368"><a href="#L-368"><span class="linenos">368</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="L-369"><a href="#L-369"><span class="linenos">369</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetAgg</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"COLLECT_SET"</span><span class="p">),</span> -</span><span id="L-370"><a href="#L-370"><span class="linenos">370</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Split</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">"SPLIT(</span><span 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">, CONCAT('</span><span class="se">\\\\</span><span class="s2">Q', </span><span 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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> -</span><span id="L-371"><a href="#L-371"><span class="linenos">371</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">strposition_to_locate_sql</span><span class="p">,</span> -</span><span id="L-372"><a href="#L-372"><span class="linenos">372</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="n">_str_to_date_sql</span><span class="p">,</span> -</span><span id="L-373"><a href="#L-373"><span class="linenos">373</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_time_sql</span><span class="p">,</span> -</span><span id="L-374"><a href="#L-374"><span class="linenos">374</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">:</span> <span class="n">_str_to_unix_sql</span><span class="p">,</span> -</span><span id="L-375"><a href="#L-375"><span class="linenos">375</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">:</span> <span class="n">struct_extract_sql</span><span class="p">,</span> -</span><span id="L-376"><a href="#L-376"><span class="linenos">376</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_DATE"</span><span class="p">),</span> -</span><span id="L-377"><a href="#L-377"><span class="linenos">377</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-378"><a href="#L-378"><span class="linenos">378</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNIX_TIMESTAMP"</span><span class="p">),</span> -</span><span id="L-379"><a href="#L-379"><span class="linenos">379</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">:</span> <span class="n">_time_to_str</span><span class="p">,</span> -</span><span id="L-380"><a href="#L-380"><span class="linenos">380</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">"UNIX_TIMESTAMP"</span><span class="p">),</span> -</span><span id="L-381"><a href="#L-381"><span class="linenos">381</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToBase64</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BASE64"</span><span class="p">),</span> -</span><span id="L-382"><a href="#L-382"><span class="linenos">382</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 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 STRING), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> -</span><span id="L-383"><a href="#L-383"><span class="linenos">383</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</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">"DATE_ADD(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-384"><a href="#L-384"><span class="linenos">384</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">_to_date_sql</span><span class="p">,</span> -</span><span id="L-385"><a href="#L-385"><span class="linenos">385</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">:</span> <span class="n">no_trycast_sql</span><span class="p">,</span> -</span><span id="L-386"><a href="#L-386"><span class="linenos">386</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-387"><a href="#L-387"><span class="linenos">387</span></a> <span class="s2">"FROM_UNIXTIME"</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">_time_format</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> -</span><span id="L-388"><a href="#L-388"><span class="linenos">388</span></a> <span class="p">),</span> -</span><span id="L-389"><a href="#L-389"><span class="linenos">389</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_UNIXTIME"</span><span class="p">),</span> -</span><span id="L-390"><a href="#L-390"><span class="linenos">390</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTimeStr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_UNIXTIME"</span><span class="p">),</span> -</span><span id="L-391"><a href="#L-391"><span class="linenos">391</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</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">"PARTITIONED BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-392"><a href="#L-392"><span class="linenos">392</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatSerdeProperty</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">"ROW FORMAT SERDE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-393"><a href="#L-393"><span class="linenos">393</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</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">properties</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"WITH SERDEPROPERTIES"</span><span class="p">),</span> -</span><span id="L-394"><a href="#L-394"><span class="linenos">394</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NumberToStr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FORMAT_NUMBER"</span><span class="p">),</span> -</span><span id="L-395"><a href="#L-395"><span class="linenos">395</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LastDateOfMonth</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LAST_DAY"</span><span class="p">),</span> -</span><span id="L-396"><a href="#L-396"><span class="linenos">396</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">National</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">national_sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</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="p">}</span> -</span><span id="L-398"><a href="#L-398"><span class="linenos">398</span></a> -</span><span id="L-399"><a href="#L-399"><span class="linenos">399</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-400"><a href="#L-400"><span class="linenos">400</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">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="L-401"><a href="#L-401"><span class="linenos">401</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-402"><a href="#L-402"><span class="linenos">402</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-403"><a href="#L-403"><span class="linenos">403</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="L-404"><a href="#L-404"><span class="linenos">404</span></a> <span class="p">}</span> -</span><span id="L-405"><a href="#L-405"><span class="linenos">405</span></a> -</span><span id="L-406"><a href="#L-406"><span class="linenos">406</span></a> <span class="k">def</span> <span class="nf">arrayagg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-407"><a href="#L-407"><span class="linenos">407</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-408"><a href="#L-408"><span class="linenos">408</span></a> <span class="s2">"COLLECT_LIST"</span><span class="p">,</span> -</span><span id="L-409"><a href="#L-409"><span class="linenos">409</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">)</span> <span class="k">else</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-410"><a href="#L-410"><span class="linenos">410</span></a> <span class="p">)</span> -</span><span id="L-411"><a href="#L-411"><span class="linenos">411</span></a> -</span><span id="L-412"><a href="#L-412"><span class="linenos">412</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-413"><a href="#L-413"><span class="linenos">413</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"TBLPROPERTIES"</span><span class="p">))</span> +</span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a><span class="sd"> This shows that Spark doesn't truncate the value into '12', which is inconsistent with</span> +</span><span id="L-296"><a href="#L-296"><span class="linenos">296</span></a><span class="sd"> what other dialects (e.g. postgres) do, so we need to drop the length to transpile correctly.</span> +</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a> +</span><span id="L-298"><a href="#L-298"><span class="linenos">298</span></a><span class="sd"> Reference: https://spark.apache.org/docs/latest/sql-ref-datatypes.html</span> +</span><span id="L-299"><a href="#L-299"><span class="linenos">299</span></a><span class="sd"> """</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="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="L-301"><a href="#L-301"><span class="linenos">301</span></a> +</span><span id="L-302"><a href="#L-302"><span class="linenos">302</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">schema</span><span class="p">:</span> +</span><span id="L-303"><a href="#L-303"><span class="linenos">303</span></a> <span class="k">return</span> <span class="n">this</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> +</span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a> <span class="k">lambda</span> <span class="n">node</span><span class="p">:</span> <span class="n">node</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">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-305"><a href="#L-305"><span class="linenos">305</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="ow">and</span> <span class="n">node</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"char"</span><span class="p">,</span> <span class="s2">"varchar"</span><span class="p">)</span> +</span><span id="L-306"><a href="#L-306"><span class="linenos">306</span></a> <span class="k">else</span> <span class="n">node</span><span class="p">,</span> +</span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a> <span class="p">)</span> +</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a> +</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a> +</span><span id="L-312"><a href="#L-312"><span class="linenos">312</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-313"><a href="#L-313"><span class="linenos">313</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> +</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> <span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> <span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-318"><a href="#L-318"><span class="linenos">318</span></a> <span class="n">INDEX_ON</span> <span class="o">=</span> <span class="s2">"ON TABLE"</span> +</span><span id="L-319"><a href="#L-319"><span class="linenos">319</span></a> +</span><span id="L-320"><a href="#L-320"><span class="linenos">320</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-321"><a href="#L-321"><span class="linenos">321</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-322"><a href="#L-322"><span class="linenos">322</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="s2">"STRING"</span><span class="p">,</span> +</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATETIME</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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">"BINARY"</span><span class="p">,</span> +</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BIT</span><span class="p">:</span> <span class="s2">"BOOLEAN"</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">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-330"><a href="#L-330"><span class="linenos">330</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-331"><a href="#L-331"><span class="linenos">331</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Group</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">unalias_group</span><span class="p">]),</span> +</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="L-333"><a href="#L-333"><span class="linenos">333</span></a> <span class="p">[</span> +</span><span id="L-334"><a href="#L-334"><span class="linenos">334</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">,</span> +</span><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> +</span><span id="L-336"><a href="#L-336"><span class="linenos">336</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">unnest_to_explode</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 class="p">),</span> +</span><span id="L-339"><a href="#L-339"><span class="linenos">339</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> <span class="n">_property_sql</span><span class="p">,</span> +</span><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">approx_count_distinct_sql</span><span class="p">,</span> +</span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">),</span> +</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayJoin</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">"CONCAT_WS"</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 class="p">),</span> +</span><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"SIZE"</span><span class="p">),</span> +</span><span id="L-344"><a href="#L-344"><span class="linenos">344</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySort</span><span class="p">:</span> <span class="n">_array_sort_sql</span><span class="p">,</span> +</span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">:</span> <span class="n">no_recursive_cte_sql</span><span class="p">,</span> +</span><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_add_date_sql</span><span class="p">,</span> +</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="n">_date_diff_sql</span><span class="p">,</span> +</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_DATE"</span><span class="p">),</span> +</span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_add_date_sql</span><span class="p">,</span> +</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateToDi</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(DATE_FORMAT(</span><span 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">Hive</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-351"><a href="#L-351"><span class="linenos">351</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 class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"TO_DATE(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 STRING), </span><span class="si">{</span><span class="n">Hive</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</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">"STORED AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="w"> </span><span class="k">if</span><span class="w"> </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="w"> </span><span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">e</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="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-353"><a href="#L-353"><span class="linenos">353</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase64</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNBASE64"</span><span class="p">),</span> +</span><span id="L-354"><a href="#L-354"><span class="linenos">354</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">,</span> +</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> +</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"GET_JSON_OBJECT"</span><span class="p">),</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">JSONExtractScalar</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"GET_JSON_OBJECT"</span><span class="p">),</span> +</span><span id="L-358"><a href="#L-358"><span class="linenos">358</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="p">:</span> <span class="n">_json_format_sql</span><span class="p">,</span> +</span><span id="L-359"><a href="#L-359"><span class="linenos">359</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">:</span> <span class="n">left_to_substring_sql</span><span class="p">,</span> +</span><span id="L-360"><a href="#L-360"><span class="linenos">360</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Map</span><span class="p">:</span> <span class="n">var_map_sql</span><span class="p">,</span> +</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> +</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> +</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</span><span class="p">:</span> <span class="n">var_map_sql</span><span class="p">,</span> +</span><span id="L-364"><a href="#L-364"><span class="linenos">364</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> <span class="n">create_with_partitions_sql</span><span class="p">,</span> +</span><span id="L-365"><a href="#L-365"><span class="linenos">365</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"PERCENTILE"</span><span class="p">),</span> +</span><span id="L-366"><a href="#L-366"><span class="linenos">366</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"PERCENTILE_APPROX"</span><span class="p">),</span> +</span><span id="L-367"><a href="#L-367"><span class="linenos">367</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</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">"RLIKE"</span><span class="p">),</span> +</span><span id="L-368"><a href="#L-368"><span class="linenos">368</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">"SPLIT"</span><span class="p">),</span> +</span><span id="L-369"><a href="#L-369"><span class="linenos">369</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Right</span><span class="p">:</span> <span class="n">right_to_substring_sql</span><span class="p">,</span> +</span><span id="L-370"><a href="#L-370"><span class="linenos">370</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-371"><a href="#L-371"><span class="linenos">371</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="L-372"><a href="#L-372"><span class="linenos">372</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetAgg</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"COLLECT_SET"</span><span class="p">),</span> +</span><span id="L-373"><a href="#L-373"><span class="linenos">373</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Split</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">"SPLIT(</span><span 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">, CONCAT('</span><span class="se">\\\\</span><span class="s2">Q', </span><span 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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> +</span><span id="L-374"><a href="#L-374"><span class="linenos">374</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">strposition_to_locate_sql</span><span class="p">,</span> +</span><span id="L-375"><a href="#L-375"><span class="linenos">375</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="n">_str_to_date_sql</span><span class="p">,</span> +</span><span id="L-376"><a href="#L-376"><span class="linenos">376</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_time_sql</span><span class="p">,</span> +</span><span id="L-377"><a href="#L-377"><span class="linenos">377</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">:</span> <span class="n">_str_to_unix_sql</span><span class="p">,</span> +</span><span id="L-378"><a href="#L-378"><span class="linenos">378</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">:</span> <span class="n">struct_extract_sql</span><span class="p">,</span> +</span><span id="L-379"><a href="#L-379"><span class="linenos">379</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_DATE"</span><span class="p">),</span> +</span><span id="L-380"><a href="#L-380"><span class="linenos">380</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-381"><a href="#L-381"><span class="linenos">381</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNIX_TIMESTAMP"</span><span class="p">),</span> +</span><span id="L-382"><a href="#L-382"><span class="linenos">382</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">:</span> <span class="n">_time_to_str</span><span class="p">,</span> +</span><span id="L-383"><a href="#L-383"><span class="linenos">383</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">"UNIX_TIMESTAMP"</span><span class="p">),</span> +</span><span id="L-384"><a href="#L-384"><span class="linenos">384</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToBase64</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BASE64"</span><span class="p">),</span> +</span><span id="L-385"><a href="#L-385"><span class="linenos">385</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 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 STRING), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> +</span><span id="L-386"><a href="#L-386"><span class="linenos">386</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</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">"DATE_ADD(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-387"><a href="#L-387"><span class="linenos">387</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">_to_date_sql</span><span class="p">,</span> +</span><span id="L-388"><a href="#L-388"><span class="linenos">388</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">:</span> <span class="n">no_trycast_sql</span><span class="p">,</span> +</span><span id="L-389"><a href="#L-389"><span class="linenos">389</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-390"><a href="#L-390"><span class="linenos">390</span></a> <span class="s2">"FROM_UNIXTIME"</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">_time_format</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> +</span><span id="L-391"><a href="#L-391"><span class="linenos">391</span></a> <span class="p">),</span> +</span><span id="L-392"><a href="#L-392"><span class="linenos">392</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_UNIXTIME"</span><span class="p">),</span> +</span><span id="L-393"><a href="#L-393"><span class="linenos">393</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTimeStr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_UNIXTIME"</span><span class="p">),</span> +</span><span id="L-394"><a href="#L-394"><span class="linenos">394</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</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">"PARTITIONED BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-395"><a href="#L-395"><span class="linenos">395</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatSerdeProperty</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">"ROW FORMAT SERDE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-396"><a href="#L-396"><span class="linenos">396</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</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">properties</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"WITH SERDEPROPERTIES"</span><span class="p">),</span> +</span><span id="L-397"><a href="#L-397"><span class="linenos">397</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NumberToStr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FORMAT_NUMBER"</span><span class="p">),</span> +</span><span id="L-398"><a href="#L-398"><span class="linenos">398</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LastDateOfMonth</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LAST_DAY"</span><span class="p">),</span> +</span><span id="L-399"><a href="#L-399"><span class="linenos">399</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">National</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">national_sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">""</span><span class="p">),</span> +</span><span id="L-400"><a href="#L-400"><span class="linenos">400</span></a> <span class="p">}</span> +</span><span id="L-401"><a href="#L-401"><span class="linenos">401</span></a> +</span><span id="L-402"><a href="#L-402"><span class="linenos">402</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-403"><a href="#L-403"><span class="linenos">403</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">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="L-404"><a href="#L-404"><span class="linenos">404</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-405"><a href="#L-405"><span class="linenos">405</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-406"><a href="#L-406"><span class="linenos">406</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="L-407"><a href="#L-407"><span class="linenos">407</span></a> <span class="p">}</span> +</span><span id="L-408"><a href="#L-408"><span class="linenos">408</span></a> +</span><span id="L-409"><a href="#L-409"><span class="linenos">409</span></a> <span class="k">def</span> <span class="nf">arrayagg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-410"><a href="#L-410"><span class="linenos">410</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-411"><a href="#L-411"><span class="linenos">411</span></a> <span class="s2">"COLLECT_LIST"</span><span class="p">,</span> +</span><span id="L-412"><a href="#L-412"><span class="linenos">412</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">)</span> <span class="k">else</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-413"><a href="#L-413"><span class="linenos">413</span></a> <span class="p">)</span> </span><span id="L-414"><a href="#L-414"><span class="linenos">414</span></a> -</span><span id="L-415"><a href="#L-415"><span class="linenos">415</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-416"><a href="#L-416"><span class="linenos">416</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="L-417"><a href="#L-417"><span class="linenos">417</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</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 class="n">exp</span><span 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><span id="L-418"><a href="#L-418"><span class="linenos">418</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="L-419"><a href="#L-419"><span class="linenos">419</span></a> <span class="p">):</span> -</span><span id="L-420"><a href="#L-420"><span class="linenos">420</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="s2">"text"</span><span class="p">)</span> -</span><span id="L-421"><a href="#L-421"><span class="linenos">421</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEMPORAL_TYPES</span><span class="p">:</span> -</span><span id="L-422"><a href="#L-422"><span class="linenos">422</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-423"><a href="#L-423"><span class="linenos">423</span></a> -</span><span id="L-424"><a href="#L-424"><span class="linenos">424</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-425"><a href="#L-425"><span class="linenos">425</span></a> -</span><span id="L-426"><a href="#L-426"><span class="linenos">426</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="L-427"><a href="#L-427"><span class="linenos">427</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="o">+</span> <span class="p">[</span> -</span><span id="L-428"><a href="#L-428"><span class="linenos">428</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distribute"</span><span class="p">),</span> -</span><span id="L-429"><a href="#L-429"><span class="linenos">429</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"sort"</span><span class="p">),</span> -</span><span id="L-430"><a href="#L-430"><span class="linenos">430</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"cluster"</span><span class="p">),</span> -</span><span id="L-431"><a href="#L-431"><span class="linenos">431</span></a> <span class="p">]</span> +</span><span id="L-415"><a href="#L-415"><span class="linenos">415</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-416"><a href="#L-416"><span class="linenos">416</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"TBLPROPERTIES"</span><span class="p">))</span> +</span><span id="L-417"><a href="#L-417"><span class="linenos">417</span></a> +</span><span id="L-418"><a href="#L-418"><span class="linenos">418</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-419"><a href="#L-419"><span class="linenos">419</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="L-420"><a href="#L-420"><span class="linenos">420</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</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 class="n">exp</span><span 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><span id="L-421"><a href="#L-421"><span class="linenos">421</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="L-422"><a href="#L-422"><span class="linenos">422</span></a> <span class="p">):</span> +</span><span id="L-423"><a href="#L-423"><span class="linenos">423</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="s2">"text"</span><span class="p">)</span> +</span><span id="L-424"><a href="#L-424"><span class="linenos">424</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEMPORAL_TYPES</span><span class="p">:</span> +</span><span id="L-425"><a href="#L-425"><span class="linenos">425</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-426"><a href="#L-426"><span class="linenos">426</span></a> +</span><span id="L-427"><a href="#L-427"><span class="linenos">427</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-428"><a href="#L-428"><span class="linenos">428</span></a> +</span><span id="L-429"><a href="#L-429"><span class="linenos">429</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="L-430"><a href="#L-430"><span class="linenos">430</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="o">+</span> <span class="p">[</span> +</span><span id="L-431"><a href="#L-431"><span class="linenos">431</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distribute"</span><span class="p">),</span> +</span><span id="L-432"><a href="#L-432"><span class="linenos">432</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"sort"</span><span class="p">),</span> +</span><span id="L-433"><a href="#L-433"><span class="linenos">433</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"cluster"</span><span class="p">),</span> +</span><span id="L-434"><a href="#L-434"><span class="linenos">434</span></a> <span class="p">]</span> </span></pre></div> @@ -539,282 +545,285 @@ </span><span id="Hive-154"><a href="#Hive-154"><span class="linenos">154</span></a> <span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="Hive-155"><a href="#Hive-155"><span class="linenos">155</span></a> <span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="Hive-156"><a href="#Hive-156"><span class="linenos">156</span></a> -</span><span id="Hive-157"><a href="#Hive-157"><span class="linenos">157</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Hive-158"><a href="#Hive-158"><span class="linenos">158</span></a> <span class="s2">"y"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> -</span><span id="Hive-159"><a href="#Hive-159"><span class="linenos">159</span></a> <span class="s2">"Y"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> -</span><span id="Hive-160"><a href="#Hive-160"><span class="linenos">160</span></a> <span class="s2">"YYYY"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> -</span><span id="Hive-161"><a href="#Hive-161"><span class="linenos">161</span></a> <span class="s2">"yyyy"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> -</span><span id="Hive-162"><a href="#Hive-162"><span class="linenos">162</span></a> <span class="s2">"YY"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> -</span><span id="Hive-163"><a href="#Hive-163"><span class="linenos">163</span></a> <span class="s2">"yy"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> -</span><span id="Hive-164"><a href="#Hive-164"><span class="linenos">164</span></a> <span class="s2">"MMMM"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> -</span><span id="Hive-165"><a href="#Hive-165"><span class="linenos">165</span></a> <span class="s2">"MMM"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> -</span><span id="Hive-166"><a href="#Hive-166"><span class="linenos">166</span></a> <span class="s2">"MM"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> -</span><span id="Hive-167"><a href="#Hive-167"><span class="linenos">167</span></a> <span class="s2">"M"</span><span class="p">:</span> <span class="s2">"%-m"</span><span class="p">,</span> -</span><span id="Hive-168"><a href="#Hive-168"><span class="linenos">168</span></a> <span class="s2">"dd"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%d</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Hive-169"><a href="#Hive-169"><span class="linenos">169</span></a> <span class="s2">"d"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%-d</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Hive-170"><a href="#Hive-170"><span class="linenos">170</span></a> <span class="s2">"HH"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> -</span><span id="Hive-171"><a href="#Hive-171"><span class="linenos">171</span></a> <span class="s2">"H"</span><span class="p">:</span> <span class="s2">"%-H"</span><span class="p">,</span> -</span><span id="Hive-172"><a href="#Hive-172"><span class="linenos">172</span></a> <span class="s2">"hh"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> -</span><span id="Hive-173"><a href="#Hive-173"><span class="linenos">173</span></a> <span class="s2">"h"</span><span class="p">:</span> <span class="s2">"%-I"</span><span class="p">,</span> -</span><span id="Hive-174"><a href="#Hive-174"><span class="linenos">174</span></a> <span class="s2">"mm"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> -</span><span id="Hive-175"><a href="#Hive-175"><span class="linenos">175</span></a> <span class="s2">"m"</span><span class="p">:</span> <span class="s2">"%-M"</span><span class="p">,</span> -</span><span id="Hive-176"><a href="#Hive-176"><span class="linenos">176</span></a> <span class="s2">"ss"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> -</span><span id="Hive-177"><a href="#Hive-177"><span class="linenos">177</span></a> <span class="s2">"s"</span><span class="p">:</span> <span class="s2">"%-S"</span><span class="p">,</span> -</span><span id="Hive-178"><a href="#Hive-178"><span class="linenos">178</span></a> <span class="s2">"SSSSSS"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Hive-179"><a href="#Hive-179"><span class="linenos">179</span></a> <span class="s2">"a"</span><span class="p">:</span> <span class="s2">"%p"</span><span class="p">,</span> -</span><span id="Hive-180"><a href="#Hive-180"><span class="linenos">180</span></a> <span class="s2">"DD"</span><span class="p">:</span> <span class="s2">"%j"</span><span class="p">,</span> -</span><span id="Hive-181"><a href="#Hive-181"><span class="linenos">181</span></a> <span class="s2">"D"</span><span class="p">:</span> <span class="s2">"%-j"</span><span class="p">,</span> -</span><span id="Hive-182"><a href="#Hive-182"><span class="linenos">182</span></a> <span class="s2">"E"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Hive-183"><a href="#Hive-183"><span class="linenos">183</span></a> <span class="s2">"EE"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Hive-184"><a href="#Hive-184"><span class="linenos">184</span></a> <span class="s2">"EEE"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Hive-185"><a href="#Hive-185"><span class="linenos">185</span></a> <span class="s2">"EEEE"</span><span class="p">:</span> <span class="s2">"%A"</span><span class="p">,</span> -</span><span id="Hive-186"><a href="#Hive-186"><span class="linenos">186</span></a> <span class="p">}</span> -</span><span id="Hive-187"><a href="#Hive-187"><span class="linenos">187</span></a> -</span><span id="Hive-188"><a href="#Hive-188"><span class="linenos">188</span></a> <span class="n">DATE_FORMAT</span> <span class="o">=</span> <span class="s2">"'yyyy-MM-dd'"</span> -</span><span id="Hive-189"><a href="#Hive-189"><span class="linenos">189</span></a> <span class="n">DATEINT_FORMAT</span> <span class="o">=</span> <span class="s2">"'yyyyMMdd'"</span> -</span><span id="Hive-190"><a href="#Hive-190"><span class="linenos">190</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">"'yyyy-MM-dd HH:mm:ss'"</span> -</span><span id="Hive-191"><a href="#Hive-191"><span class="linenos">191</span></a> -</span><span id="Hive-192"><a href="#Hive-192"><span class="linenos">192</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="Hive-193"><a href="#Hive-193"><span class="linenos">193</span></a> <span class="n">QUOTES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">,</span> <span class="s1">'"'</span><span class="p">]</span> -</span><span id="Hive-194"><a href="#Hive-194"><span class="linenos">194</span></a> <span class="n">IDENTIFIERS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"`"</span><span class="p">]</span> -</span><span id="Hive-195"><a href="#Hive-195"><span class="linenos">195</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">]</span> -</span><span id="Hive-196"><a href="#Hive-196"><span class="linenos">196</span></a> <span class="n">ENCODE</span> <span class="o">=</span> <span class="s2">"utf-8"</span> -</span><span id="Hive-197"><a href="#Hive-197"><span class="linenos">197</span></a> -</span><span id="Hive-198"><a href="#Hive-198"><span class="linenos">198</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Hive-199"><a href="#Hive-199"><span class="linenos">199</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="Hive-200"><a href="#Hive-200"><span class="linenos">200</span></a> <span class="s2">"ADD ARCHIVE"</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="Hive-201"><a href="#Hive-201"><span class="linenos">201</span></a> <span class="s2">"ADD ARCHIVES"</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="Hive-202"><a href="#Hive-202"><span class="linenos">202</span></a> <span class="s2">"ADD FILE"</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="Hive-203"><a href="#Hive-203"><span class="linenos">203</span></a> <span class="s2">"ADD FILES"</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="Hive-204"><a href="#Hive-204"><span class="linenos">204</span></a> <span class="s2">"ADD JAR"</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="Hive-205"><a href="#Hive-205"><span class="linenos">205</span></a> <span class="s2">"ADD JARS"</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="Hive-206"><a href="#Hive-206"><span class="linenos">206</span></a> <span class="s2">"MSCK REPAIR"</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="Hive-207"><a href="#Hive-207"><span class="linenos">207</span></a> <span class="s2">"WITH SERDEPROPERTIES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SERDE_PROPERTIES</span><span class="p">,</span> -</span><span id="Hive-208"><a href="#Hive-208"><span class="linenos">208</span></a> <span class="p">}</span> -</span><span id="Hive-209"><a href="#Hive-209"><span class="linenos">209</span></a> -</span><span id="Hive-210"><a href="#Hive-210"><span class="linenos">210</span></a> <span class="n">NUMERIC_LITERALS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Hive-211"><a href="#Hive-211"><span class="linenos">211</span></a> <span class="s2">"L"</span><span class="p">:</span> <span class="s2">"BIGINT"</span><span class="p">,</span> -</span><span id="Hive-212"><a href="#Hive-212"><span class="linenos">212</span></a> <span class="s2">"S"</span><span class="p">:</span> <span class="s2">"SMALLINT"</span><span class="p">,</span> -</span><span id="Hive-213"><a href="#Hive-213"><span class="linenos">213</span></a> <span class="s2">"Y"</span><span class="p">:</span> <span class="s2">"TINYINT"</span><span class="p">,</span> -</span><span id="Hive-214"><a href="#Hive-214"><span class="linenos">214</span></a> <span class="s2">"D"</span><span class="p">:</span> <span class="s2">"DOUBLE"</span><span class="p">,</span> -</span><span id="Hive-215"><a href="#Hive-215"><span class="linenos">215</span></a> <span class="s2">"F"</span><span class="p">:</span> <span class="s2">"FLOAT"</span><span class="p">,</span> -</span><span id="Hive-216"><a href="#Hive-216"><span class="linenos">216</span></a> <span class="s2">"BD"</span><span class="p">:</span> <span class="s2">"DECIMAL"</span><span class="p">,</span> -</span><span id="Hive-217"><a href="#Hive-217"><span class="linenos">217</span></a> <span class="p">}</span> -</span><span id="Hive-218"><a href="#Hive-218"><span class="linenos">218</span></a> -</span><span id="Hive-219"><a href="#Hive-219"><span class="linenos">219</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="Hive-220"><a href="#Hive-220"><span class="linenos">220</span></a> <span class="n">LOG_DEFAULTS_TO_LN</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Hive-221"><a href="#Hive-221"><span class="linenos">221</span></a> <span class="n">STRICT_CAST</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Hive-222"><a href="#Hive-222"><span class="linenos">222</span></a> -</span><span id="Hive-223"><a href="#Hive-223"><span class="linenos">223</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Hive-224"><a href="#Hive-224"><span class="linenos">224</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="Hive-225"><a href="#Hive-225"><span class="linenos">225</span></a> <span class="s2">"BASE64"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ToBase64</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Hive-226"><a href="#Hive-226"><span class="linenos">226</span></a> <span class="s2">"COLLECT_LIST"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Hive-227"><a href="#Hive-227"><span class="linenos">227</span></a> <span class="s2">"DATE_ADD"</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">TsOrDsAdd</span><span class="p">(</span> -</span><span id="Hive-228"><a href="#Hive-228"><span class="linenos">228</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">unit</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">"DAY"</span><span class="p">)</span> -</span><span id="Hive-229"><a href="#Hive-229"><span class="linenos">229</span></a> <span class="p">),</span> -</span><span id="Hive-230"><a href="#Hive-230"><span class="linenos">230</span></a> <span class="s2">"DATEDIFF"</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">DateDiff</span><span class="p">(</span> -</span><span id="Hive-231"><a href="#Hive-231"><span class="linenos">231</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)),</span> -</span><span id="Hive-232"><a href="#Hive-232"><span class="linenos">232</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span> -</span><span id="Hive-233"><a href="#Hive-233"><span class="linenos">233</span></a> <span class="p">),</span> -</span><span id="Hive-234"><a href="#Hive-234"><span class="linenos">234</span></a> <span class="s2">"DATE_SUB"</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">TsOrDsAdd</span><span class="p">(</span> -</span><span id="Hive-235"><a href="#Hive-235"><span class="linenos">235</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="Hive-236"><a href="#Hive-236"><span class="linenos">236</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Mul</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</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="o">-</span><span class="mi">1</span><span class="p">)),</span> -</span><span id="Hive-237"><a href="#Hive-237"><span class="linenos">237</span></a> <span class="n">unit</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">"DAY"</span><span class="p">),</span> -</span><span id="Hive-238"><a href="#Hive-238"><span class="linenos">238</span></a> <span class="p">),</span> -</span><span id="Hive-239"><a href="#Hive-239"><span class="linenos">239</span></a> <span class="s2">"DATE_FORMAT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">format_time_lambda</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">"hive"</span><span class="p">)(</span> -</span><span id="Hive-240"><a href="#Hive-240"><span class="linenos">240</span></a> <span class="p">[</span> -</span><span id="Hive-241"><a href="#Hive-241"><span class="linenos">241</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)),</span> -</span><span id="Hive-242"><a href="#Hive-242"><span class="linenos">242</span></a> <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="Hive-243"><a href="#Hive-243"><span class="linenos">243</span></a> <span class="p">]</span> -</span><span id="Hive-244"><a href="#Hive-244"><span class="linenos">244</span></a> <span class="p">),</span> -</span><span id="Hive-245"><a href="#Hive-245"><span class="linenos">245</span></a> <span class="s2">"DAY"</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">Day</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">))),</span> -</span><span id="Hive-246"><a href="#Hive-246"><span class="linenos">246</span></a> <span class="s2">"FROM_UNIXTIME"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">UnixToStr</span><span class="p">,</span> <span class="s2">"hive"</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> -</span><span id="Hive-247"><a href="#Hive-247"><span class="linenos">247</span></a> <span class="s2">"GET_JSON_OBJECT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Hive-248"><a href="#Hive-248"><span class="linenos">248</span></a> <span class="s2">"LOCATE"</span><span class="p">:</span> <span class="n">locate_to_strposition</span><span class="p">,</span> -</span><span id="Hive-249"><a href="#Hive-249"><span class="linenos">249</span></a> <span class="s2">"MAP"</span><span class="p">:</span> <span class="n">parse_var_map</span><span class="p">,</span> -</span><span id="Hive-250"><a href="#Hive-250"><span class="linenos">250</span></a> <span class="s2">"MONTH"</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">Month</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">)),</span> -</span><span id="Hive-251"><a href="#Hive-251"><span class="linenos">251</span></a> <span class="s2">"PERCENTILE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Hive-252"><a href="#Hive-252"><span class="linenos">252</span></a> <span class="s2">"PERCENTILE_APPROX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Hive-253"><a href="#Hive-253"><span class="linenos">253</span></a> <span class="s2">"COLLECT_SET"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Hive-254"><a href="#Hive-254"><span class="linenos">254</span></a> <span class="s2">"SIZE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Hive-255"><a href="#Hive-255"><span class="linenos">255</span></a> <span class="s2">"SPLIT"</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="Hive-256"><a href="#Hive-256"><span class="linenos">256</span></a> <span class="s2">"TO_DATE"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">,</span> <span class="s2">"hive"</span><span class="p">),</span> -</span><span id="Hive-257"><a href="#Hive-257"><span class="linenos">257</span></a> <span class="s2">"TO_JSON"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Hive-258"><a href="#Hive-258"><span class="linenos">258</span></a> <span class="s2">"UNBASE64"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase64</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Hive-259"><a href="#Hive-259"><span class="linenos">259</span></a> <span class="s2">"UNIX_TIMESTAMP"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">,</span> <span class="s2">"hive"</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> -</span><span id="Hive-260"><a href="#Hive-260"><span class="linenos">260</span></a> <span class="s2">"YEAR"</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">Year</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">)),</span> -</span><span id="Hive-261"><a href="#Hive-261"><span class="linenos">261</span></a> <span class="p">}</span> -</span><span id="Hive-262"><a href="#Hive-262"><span class="linenos">262</span></a> -</span><span id="Hive-263"><a href="#Hive-263"><span class="linenos">263</span></a> <span class="n">PROPERTY_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Hive-264"><a href="#Hive-264"><span class="linenos">264</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">PROPERTY_PARSERS</span><span class="p">,</span> -</span><span id="Hive-265"><a href="#Hive-265"><span class="linenos">265</span></a> <span class="s2">"WITH SERDEPROPERTIES"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</span><span class="p">(</span> -</span><span id="Hive-266"><a href="#Hive-266"><span class="linenos">266</span></a> <span class="n">expressions</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_property</span><span class="p">)</span> -</span><span id="Hive-267"><a href="#Hive-267"><span class="linenos">267</span></a> <span class="p">),</span> -</span><span id="Hive-268"><a href="#Hive-268"><span class="linenos">268</span></a> <span class="p">}</span> -</span><span id="Hive-269"><a href="#Hive-269"><span class="linenos">269</span></a> -</span><span id="Hive-270"><a href="#Hive-270"><span class="linenos">270</span></a> <span class="n">QUERY_MODIFIER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Hive-271"><a href="#Hive-271"><span class="linenos">271</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">QUERY_MODIFIER_PARSERS</span><span class="p">,</span> -</span><span id="Hive-272"><a href="#Hive-272"><span class="linenos">272</span></a> <span class="s2">"distribute"</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Distribute</span><span class="p">,</span> <span class="s2">"DISTRIBUTE"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">),</span> -</span><span id="Hive-273"><a href="#Hive-273"><span class="linenos">273</span></a> <span class="s2">"sort"</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">,</span> <span class="s2">"SORT"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">),</span> -</span><span id="Hive-274"><a href="#Hive-274"><span class="linenos">274</span></a> <span class="s2">"cluster"</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">,</span> <span class="s2">"CLUSTER"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">),</span> -</span><span id="Hive-275"><a href="#Hive-275"><span class="linenos">275</span></a> <span class="p">}</span> -</span><span id="Hive-276"><a href="#Hive-276"><span class="linenos">276</span></a> -</span><span id="Hive-277"><a href="#Hive-277"><span class="linenos">277</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span> -</span><span id="Hive-278"><a href="#Hive-278"><span class="linenos">278</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</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="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Hive-279"><a href="#Hive-279"><span class="linenos">279</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="Hive-280"><a href="#Hive-280"><span class="linenos">280</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Hive-281"><a href="#Hive-281"><span class="linenos">281</span></a><span class="sd"> Spark (and most likely Hive) treats casts to CHAR(length) and VARCHAR(length) as casts to</span> -</span><span id="Hive-282"><a href="#Hive-282"><span class="linenos">282</span></a><span class="sd"> STRING in all contexts except for schema definitions. For example, this is in Spark v3.4.0:</span> -</span><span id="Hive-283"><a href="#Hive-283"><span class="linenos">283</span></a> -</span><span id="Hive-284"><a href="#Hive-284"><span class="linenos">284</span></a><span class="sd"> spark-sql (default)> select cast(1234 as varchar(2));</span> -</span><span id="Hive-285"><a href="#Hive-285"><span class="linenos">285</span></a><span class="sd"> 23/06/06 15:51:18 WARN CharVarcharUtils: The Spark cast operator does not support</span> -</span><span id="Hive-286"><a href="#Hive-286"><span class="linenos">286</span></a><span class="sd"> char/varchar type and simply treats them as string type. Please use string type</span> -</span><span id="Hive-287"><a href="#Hive-287"><span class="linenos">287</span></a><span class="sd"> directly to avoid confusion. Otherwise, you can set spark.sql.legacy.charVarcharAsString</span> -</span><span id="Hive-288"><a href="#Hive-288"><span class="linenos">288</span></a><span class="sd"> to true, so that Spark treat them as string type as same as Spark 3.0 and earlier</span> -</span><span id="Hive-289"><a href="#Hive-289"><span class="linenos">289</span></a> -</span><span id="Hive-290"><a href="#Hive-290"><span class="linenos">290</span></a><span class="sd"> 1234</span> -</span><span id="Hive-291"><a href="#Hive-291"><span class="linenos">291</span></a><span class="sd"> Time taken: 4.265 seconds, Fetched 1 row(s)</span> +</span><span id="Hive-157"><a href="#Hive-157"><span class="linenos">157</span></a> <span class="c1"># https://spark.apache.org/docs/latest/sql-ref-identifier.html#description</span> +</span><span id="Hive-158"><a href="#Hive-158"><span class="linenos">158</span></a> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Hive-159"><a href="#Hive-159"><span class="linenos">159</span></a> +</span><span id="Hive-160"><a href="#Hive-160"><span class="linenos">160</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Hive-161"><a href="#Hive-161"><span class="linenos">161</span></a> <span class="s2">"y"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> +</span><span id="Hive-162"><a href="#Hive-162"><span class="linenos">162</span></a> <span class="s2">"Y"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> +</span><span id="Hive-163"><a href="#Hive-163"><span class="linenos">163</span></a> <span class="s2">"YYYY"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> +</span><span id="Hive-164"><a href="#Hive-164"><span class="linenos">164</span></a> <span class="s2">"yyyy"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> +</span><span id="Hive-165"><a href="#Hive-165"><span class="linenos">165</span></a> <span class="s2">"YY"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> +</span><span id="Hive-166"><a href="#Hive-166"><span class="linenos">166</span></a> <span class="s2">"yy"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> +</span><span id="Hive-167"><a href="#Hive-167"><span class="linenos">167</span></a> <span class="s2">"MMMM"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> +</span><span id="Hive-168"><a href="#Hive-168"><span class="linenos">168</span></a> <span class="s2">"MMM"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> +</span><span id="Hive-169"><a href="#Hive-169"><span class="linenos">169</span></a> <span class="s2">"MM"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> +</span><span id="Hive-170"><a href="#Hive-170"><span class="linenos">170</span></a> <span class="s2">"M"</span><span class="p">:</span> <span class="s2">"%-m"</span><span class="p">,</span> +</span><span id="Hive-171"><a href="#Hive-171"><span class="linenos">171</span></a> <span class="s2">"dd"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%d</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Hive-172"><a href="#Hive-172"><span class="linenos">172</span></a> <span class="s2">"d"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%-d</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Hive-173"><a href="#Hive-173"><span class="linenos">173</span></a> <span class="s2">"HH"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> +</span><span id="Hive-174"><a href="#Hive-174"><span class="linenos">174</span></a> <span class="s2">"H"</span><span class="p">:</span> <span class="s2">"%-H"</span><span class="p">,</span> +</span><span id="Hive-175"><a href="#Hive-175"><span class="linenos">175</span></a> <span class="s2">"hh"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> +</span><span id="Hive-176"><a href="#Hive-176"><span class="linenos">176</span></a> <span class="s2">"h"</span><span class="p">:</span> <span class="s2">"%-I"</span><span class="p">,</span> +</span><span id="Hive-177"><a href="#Hive-177"><span class="linenos">177</span></a> <span class="s2">"mm"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> +</span><span id="Hive-178"><a href="#Hive-178"><span class="linenos">178</span></a> <span class="s2">"m"</span><span class="p">:</span> <span class="s2">"%-M"</span><span class="p">,</span> +</span><span id="Hive-179"><a href="#Hive-179"><span class="linenos">179</span></a> <span class="s2">"ss"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> +</span><span id="Hive-180"><a href="#Hive-180"><span class="linenos">180</span></a> <span class="s2">"s"</span><span class="p">:</span> <span class="s2">"%-S"</span><span class="p">,</span> +</span><span id="Hive-181"><a href="#Hive-181"><span class="linenos">181</span></a> <span class="s2">"SSSSSS"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Hive-182"><a href="#Hive-182"><span class="linenos">182</span></a> <span class="s2">"a"</span><span class="p">:</span> <span class="s2">"%p"</span><span class="p">,</span> +</span><span id="Hive-183"><a href="#Hive-183"><span class="linenos">183</span></a> <span class="s2">"DD"</span><span class="p">:</span> <span class="s2">"%j"</span><span class="p">,</span> +</span><span id="Hive-184"><a href="#Hive-184"><span class="linenos">184</span></a> <span class="s2">"D"</span><span class="p">:</span> <span class="s2">"%-j"</span><span class="p">,</span> +</span><span id="Hive-185"><a href="#Hive-185"><span class="linenos">185</span></a> <span class="s2">"E"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Hive-186"><a href="#Hive-186"><span class="linenos">186</span></a> <span class="s2">"EE"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Hive-187"><a href="#Hive-187"><span class="linenos">187</span></a> <span class="s2">"EEE"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Hive-188"><a href="#Hive-188"><span class="linenos">188</span></a> <span class="s2">"EEEE"</span><span class="p">:</span> <span class="s2">"%A"</span><span class="p">,</span> +</span><span id="Hive-189"><a href="#Hive-189"><span class="linenos">189</span></a> <span class="p">}</span> +</span><span id="Hive-190"><a href="#Hive-190"><span class="linenos">190</span></a> +</span><span id="Hive-191"><a href="#Hive-191"><span class="linenos">191</span></a> <span class="n">DATE_FORMAT</span> <span class="o">=</span> <span class="s2">"'yyyy-MM-dd'"</span> +</span><span id="Hive-192"><a href="#Hive-192"><span class="linenos">192</span></a> <span class="n">DATEINT_FORMAT</span> <span class="o">=</span> <span class="s2">"'yyyyMMdd'"</span> +</span><span id="Hive-193"><a href="#Hive-193"><span class="linenos">193</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">"'yyyy-MM-dd HH:mm:ss'"</span> +</span><span id="Hive-194"><a href="#Hive-194"><span class="linenos">194</span></a> +</span><span id="Hive-195"><a href="#Hive-195"><span class="linenos">195</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="Hive-196"><a href="#Hive-196"><span class="linenos">196</span></a> <span class="n">QUOTES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">,</span> <span class="s1">'"'</span><span class="p">]</span> +</span><span id="Hive-197"><a href="#Hive-197"><span class="linenos">197</span></a> <span class="n">IDENTIFIERS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"`"</span><span class="p">]</span> +</span><span id="Hive-198"><a href="#Hive-198"><span class="linenos">198</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">]</span> +</span><span id="Hive-199"><a href="#Hive-199"><span class="linenos">199</span></a> <span class="n">ENCODE</span> <span class="o">=</span> <span class="s2">"utf-8"</span> +</span><span id="Hive-200"><a href="#Hive-200"><span class="linenos">200</span></a> +</span><span id="Hive-201"><a href="#Hive-201"><span class="linenos">201</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Hive-202"><a href="#Hive-202"><span class="linenos">202</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="Hive-203"><a href="#Hive-203"><span class="linenos">203</span></a> <span class="s2">"ADD ARCHIVE"</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="Hive-204"><a href="#Hive-204"><span class="linenos">204</span></a> <span class="s2">"ADD ARCHIVES"</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="Hive-205"><a href="#Hive-205"><span class="linenos">205</span></a> <span class="s2">"ADD FILE"</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="Hive-206"><a href="#Hive-206"><span class="linenos">206</span></a> <span class="s2">"ADD FILES"</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="Hive-207"><a href="#Hive-207"><span class="linenos">207</span></a> <span class="s2">"ADD JAR"</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="Hive-208"><a href="#Hive-208"><span class="linenos">208</span></a> <span class="s2">"ADD JARS"</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="Hive-209"><a href="#Hive-209"><span class="linenos">209</span></a> <span class="s2">"MSCK REPAIR"</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="Hive-210"><a href="#Hive-210"><span class="linenos">210</span></a> <span class="s2">"WITH SERDEPROPERTIES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SERDE_PROPERTIES</span><span class="p">,</span> +</span><span id="Hive-211"><a href="#Hive-211"><span class="linenos">211</span></a> <span class="p">}</span> +</span><span id="Hive-212"><a href="#Hive-212"><span class="linenos">212</span></a> +</span><span id="Hive-213"><a href="#Hive-213"><span class="linenos">213</span></a> <span class="n">NUMERIC_LITERALS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Hive-214"><a href="#Hive-214"><span class="linenos">214</span></a> <span class="s2">"L"</span><span class="p">:</span> <span class="s2">"BIGINT"</span><span class="p">,</span> +</span><span id="Hive-215"><a href="#Hive-215"><span class="linenos">215</span></a> <span class="s2">"S"</span><span class="p">:</span> <span class="s2">"SMALLINT"</span><span class="p">,</span> +</span><span id="Hive-216"><a href="#Hive-216"><span class="linenos">216</span></a> <span class="s2">"Y"</span><span class="p">:</span> <span class="s2">"TINYINT"</span><span class="p">,</span> +</span><span id="Hive-217"><a href="#Hive-217"><span class="linenos">217</span></a> <span class="s2">"D"</span><span class="p">:</span> <span class="s2">"DOUBLE"</span><span class="p">,</span> +</span><span id="Hive-218"><a href="#Hive-218"><span class="linenos">218</span></a> <span class="s2">"F"</span><span class="p">:</span> <span class="s2">"FLOAT"</span><span class="p">,</span> +</span><span id="Hive-219"><a href="#Hive-219"><span class="linenos">219</span></a> <span class="s2">"BD"</span><span class="p">:</span> <span class="s2">"DECIMAL"</span><span class="p">,</span> +</span><span id="Hive-220"><a href="#Hive-220"><span class="linenos">220</span></a> <span class="p">}</span> +</span><span id="Hive-221"><a href="#Hive-221"><span class="linenos">221</span></a> +</span><span id="Hive-222"><a href="#Hive-222"><span class="linenos">222</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="Hive-223"><a href="#Hive-223"><span class="linenos">223</span></a> <span class="n">LOG_DEFAULTS_TO_LN</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Hive-224"><a href="#Hive-224"><span class="linenos">224</span></a> <span class="n">STRICT_CAST</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Hive-225"><a href="#Hive-225"><span class="linenos">225</span></a> +</span><span id="Hive-226"><a href="#Hive-226"><span class="linenos">226</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Hive-227"><a href="#Hive-227"><span class="linenos">227</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="Hive-228"><a href="#Hive-228"><span class="linenos">228</span></a> <span class="s2">"BASE64"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ToBase64</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Hive-229"><a href="#Hive-229"><span class="linenos">229</span></a> <span class="s2">"COLLECT_LIST"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Hive-230"><a href="#Hive-230"><span class="linenos">230</span></a> <span class="s2">"DATE_ADD"</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">TsOrDsAdd</span><span class="p">(</span> +</span><span id="Hive-231"><a href="#Hive-231"><span class="linenos">231</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">unit</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">"DAY"</span><span class="p">)</span> +</span><span id="Hive-232"><a href="#Hive-232"><span class="linenos">232</span></a> <span class="p">),</span> +</span><span id="Hive-233"><a href="#Hive-233"><span class="linenos">233</span></a> <span class="s2">"DATEDIFF"</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">DateDiff</span><span class="p">(</span> +</span><span id="Hive-234"><a href="#Hive-234"><span class="linenos">234</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)),</span> +</span><span id="Hive-235"><a href="#Hive-235"><span class="linenos">235</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span> +</span><span id="Hive-236"><a href="#Hive-236"><span class="linenos">236</span></a> <span class="p">),</span> +</span><span id="Hive-237"><a href="#Hive-237"><span class="linenos">237</span></a> <span class="s2">"DATE_SUB"</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">TsOrDsAdd</span><span class="p">(</span> +</span><span id="Hive-238"><a href="#Hive-238"><span class="linenos">238</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="Hive-239"><a href="#Hive-239"><span class="linenos">239</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Mul</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</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="o">-</span><span class="mi">1</span><span class="p">)),</span> +</span><span id="Hive-240"><a href="#Hive-240"><span class="linenos">240</span></a> <span class="n">unit</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">"DAY"</span><span class="p">),</span> +</span><span id="Hive-241"><a href="#Hive-241"><span class="linenos">241</span></a> <span class="p">),</span> +</span><span id="Hive-242"><a href="#Hive-242"><span class="linenos">242</span></a> <span class="s2">"DATE_FORMAT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">format_time_lambda</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">"hive"</span><span class="p">)(</span> +</span><span id="Hive-243"><a href="#Hive-243"><span class="linenos">243</span></a> <span class="p">[</span> +</span><span id="Hive-244"><a href="#Hive-244"><span class="linenos">244</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)),</span> +</span><span id="Hive-245"><a href="#Hive-245"><span class="linenos">245</span></a> <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="Hive-246"><a href="#Hive-246"><span class="linenos">246</span></a> <span class="p">]</span> +</span><span id="Hive-247"><a href="#Hive-247"><span class="linenos">247</span></a> <span class="p">),</span> +</span><span id="Hive-248"><a href="#Hive-248"><span class="linenos">248</span></a> <span class="s2">"DAY"</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">Day</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">))),</span> +</span><span id="Hive-249"><a href="#Hive-249"><span class="linenos">249</span></a> <span class="s2">"FROM_UNIXTIME"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">UnixToStr</span><span class="p">,</span> <span class="s2">"hive"</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> +</span><span id="Hive-250"><a href="#Hive-250"><span class="linenos">250</span></a> <span class="s2">"GET_JSON_OBJECT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Hive-251"><a href="#Hive-251"><span class="linenos">251</span></a> <span class="s2">"LOCATE"</span><span class="p">:</span> <span class="n">locate_to_strposition</span><span class="p">,</span> +</span><span id="Hive-252"><a href="#Hive-252"><span class="linenos">252</span></a> <span class="s2">"MAP"</span><span class="p">:</span> <span class="n">parse_var_map</span><span class="p">,</span> +</span><span id="Hive-253"><a href="#Hive-253"><span class="linenos">253</span></a> <span class="s2">"MONTH"</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">Month</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">)),</span> +</span><span id="Hive-254"><a href="#Hive-254"><span class="linenos">254</span></a> <span class="s2">"PERCENTILE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Hive-255"><a href="#Hive-255"><span class="linenos">255</span></a> <span class="s2">"PERCENTILE_APPROX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Hive-256"><a href="#Hive-256"><span class="linenos">256</span></a> <span class="s2">"COLLECT_SET"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Hive-257"><a href="#Hive-257"><span class="linenos">257</span></a> <span class="s2">"SIZE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Hive-258"><a href="#Hive-258"><span class="linenos">258</span></a> <span class="s2">"SPLIT"</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="Hive-259"><a href="#Hive-259"><span class="linenos">259</span></a> <span class="s2">"TO_DATE"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">,</span> <span class="s2">"hive"</span><span class="p">),</span> +</span><span id="Hive-260"><a href="#Hive-260"><span class="linenos">260</span></a> <span class="s2">"TO_JSON"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Hive-261"><a href="#Hive-261"><span class="linenos">261</span></a> <span class="s2">"UNBASE64"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase64</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Hive-262"><a href="#Hive-262"><span class="linenos">262</span></a> <span class="s2">"UNIX_TIMESTAMP"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">,</span> <span class="s2">"hive"</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> +</span><span id="Hive-263"><a href="#Hive-263"><span class="linenos">263</span></a> <span class="s2">"YEAR"</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">Year</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">)),</span> +</span><span id="Hive-264"><a href="#Hive-264"><span class="linenos">264</span></a> <span class="p">}</span> +</span><span id="Hive-265"><a href="#Hive-265"><span class="linenos">265</span></a> +</span><span id="Hive-266"><a href="#Hive-266"><span class="linenos">266</span></a> <span class="n">PROPERTY_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Hive-267"><a href="#Hive-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">PROPERTY_PARSERS</span><span class="p">,</span> +</span><span id="Hive-268"><a href="#Hive-268"><span class="linenos">268</span></a> <span class="s2">"WITH SERDEPROPERTIES"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</span><span class="p">(</span> +</span><span id="Hive-269"><a href="#Hive-269"><span class="linenos">269</span></a> <span class="n">expressions</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_property</span><span class="p">)</span> +</span><span id="Hive-270"><a href="#Hive-270"><span class="linenos">270</span></a> <span class="p">),</span> +</span><span id="Hive-271"><a href="#Hive-271"><span class="linenos">271</span></a> <span class="p">}</span> +</span><span id="Hive-272"><a href="#Hive-272"><span class="linenos">272</span></a> +</span><span id="Hive-273"><a href="#Hive-273"><span class="linenos">273</span></a> <span class="n">QUERY_MODIFIER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Hive-274"><a href="#Hive-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">QUERY_MODIFIER_PARSERS</span><span class="p">,</span> +</span><span id="Hive-275"><a href="#Hive-275"><span class="linenos">275</span></a> <span class="s2">"cluster"</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CLUSTER_BY</span><span class="p">),</span> +</span><span id="Hive-276"><a href="#Hive-276"><span class="linenos">276</span></a> <span class="s2">"distribute"</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Distribute</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DISTRIBUTE_BY</span><span class="p">),</span> +</span><span id="Hive-277"><a href="#Hive-277"><span class="linenos">277</span></a> <span class="s2">"sort"</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SORT_BY</span><span class="p">),</span> +</span><span id="Hive-278"><a href="#Hive-278"><span class="linenos">278</span></a> <span class="p">}</span> +</span><span id="Hive-279"><a href="#Hive-279"><span class="linenos">279</span></a> +</span><span id="Hive-280"><a href="#Hive-280"><span class="linenos">280</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span> +</span><span id="Hive-281"><a href="#Hive-281"><span class="linenos">281</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</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="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Hive-282"><a href="#Hive-282"><span class="linenos">282</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="Hive-283"><a href="#Hive-283"><span class="linenos">283</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Hive-284"><a href="#Hive-284"><span class="linenos">284</span></a><span class="sd"> Spark (and most likely Hive) treats casts to CHAR(length) and VARCHAR(length) as casts to</span> +</span><span id="Hive-285"><a href="#Hive-285"><span class="linenos">285</span></a><span class="sd"> STRING in all contexts except for schema definitions. For example, this is in Spark v3.4.0:</span> +</span><span id="Hive-286"><a href="#Hive-286"><span class="linenos">286</span></a> +</span><span id="Hive-287"><a href="#Hive-287"><span class="linenos">287</span></a><span class="sd"> spark-sql (default)> select cast(1234 as varchar(2));</span> +</span><span id="Hive-288"><a href="#Hive-288"><span class="linenos">288</span></a><span class="sd"> 23/06/06 15:51:18 WARN CharVarcharUtils: The Spark cast operator does not support</span> +</span><span id="Hive-289"><a href="#Hive-289"><span class="linenos">289</span></a><span class="sd"> char/varchar type and simply treats them as string type. Please use string type</span> +</span><span id="Hive-290"><a href="#Hive-290"><span class="linenos">290</span></a><span class="sd"> directly to avoid confusion. Otherwise, you can set spark.sql.legacy.charVarcharAsString</span> +</span><span id="Hive-291"><a href="#Hive-291"><span class="linenos">291</span></a><span class="sd"> to true, so that Spark treat them as string type as same as Spark 3.0 and earlier</span> </span><span id="Hive-292"><a href="#Hive-292"><span class="linenos">292</span></a> -</span><span id="Hive-293"><a href="#Hive-293"><span class="linenos">293</span></a><span class="sd"> This shows that Spark doesn't truncate the value into '12', which is inconsistent with</span> -</span><span id="Hive-294"><a href="#Hive-294"><span class="linenos">294</span></a><span class="sd"> what other dialects (e.g. postgres) do, so we need to drop the length to transpile correctly.</span> +</span><span id="Hive-293"><a href="#Hive-293"><span class="linenos">293</span></a><span class="sd"> 1234</span> +</span><span id="Hive-294"><a href="#Hive-294"><span class="linenos">294</span></a><span class="sd"> Time taken: 4.265 seconds, Fetched 1 row(s)</span> </span><span id="Hive-295"><a href="#Hive-295"><span class="linenos">295</span></a> -</span><span id="Hive-296"><a href="#Hive-296"><span class="linenos">296</span></a><span class="sd"> Reference: https://spark.apache.org/docs/latest/sql-ref-datatypes.html</span> -</span><span id="Hive-297"><a href="#Hive-297"><span class="linenos">297</span></a><span class="sd"> """</span> -</span><span id="Hive-298"><a href="#Hive-298"><span class="linenos">298</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="Hive-299"><a href="#Hive-299"><span class="linenos">299</span></a> -</span><span id="Hive-300"><a href="#Hive-300"><span class="linenos">300</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">schema</span><span class="p">:</span> -</span><span id="Hive-301"><a href="#Hive-301"><span class="linenos">301</span></a> <span class="k">return</span> <span class="n">this</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> -</span><span id="Hive-302"><a href="#Hive-302"><span class="linenos">302</span></a> <span class="k">lambda</span> <span class="n">node</span><span class="p">:</span> <span class="n">node</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">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="Hive-303"><a href="#Hive-303"><span class="linenos">303</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="ow">and</span> <span class="n">node</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"char"</span><span class="p">,</span> <span class="s2">"varchar"</span><span class="p">)</span> -</span><span id="Hive-304"><a href="#Hive-304"><span class="linenos">304</span></a> <span class="k">else</span> <span class="n">node</span><span class="p">,</span> -</span><span id="Hive-305"><a href="#Hive-305"><span class="linenos">305</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Hive-306"><a href="#Hive-306"><span class="linenos">306</span></a> <span class="p">)</span> -</span><span id="Hive-307"><a href="#Hive-307"><span class="linenos">307</span></a> -</span><span id="Hive-308"><a href="#Hive-308"><span class="linenos">308</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Hive-309"><a href="#Hive-309"><span class="linenos">309</span></a> -</span><span id="Hive-310"><a href="#Hive-310"><span class="linenos">310</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="Hive-311"><a href="#Hive-311"><span class="linenos">311</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> -</span><span id="Hive-312"><a href="#Hive-312"><span class="linenos">312</span></a> <span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Hive-313"><a href="#Hive-313"><span class="linenos">313</span></a> <span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Hive-314"><a href="#Hive-314"><span class="linenos">314</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Hive-315"><a href="#Hive-315"><span class="linenos">315</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Hive-316"><a href="#Hive-316"><span class="linenos">316</span></a> <span class="n">INDEX_ON</span> <span class="o">=</span> <span class="s2">"ON TABLE"</span> -</span><span id="Hive-317"><a href="#Hive-317"><span class="linenos">317</span></a> -</span><span id="Hive-318"><a href="#Hive-318"><span class="linenos">318</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Hive-319"><a href="#Hive-319"><span class="linenos">319</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="Hive-320"><a href="#Hive-320"><span class="linenos">320</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="s2">"STRING"</span><span class="p">,</span> -</span><span id="Hive-321"><a href="#Hive-321"><span class="linenos">321</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">DATETIME</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="Hive-322"><a href="#Hive-322"><span class="linenos">322</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">"BINARY"</span><span class="p">,</span> -</span><span id="Hive-323"><a href="#Hive-323"><span class="linenos">323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="Hive-324"><a href="#Hive-324"><span class="linenos">324</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">BIT</span><span class="p">:</span> <span class="s2">"BOOLEAN"</span><span class="p">,</span> -</span><span id="Hive-325"><a href="#Hive-325"><span class="linenos">325</span></a> <span class="p">}</span> -</span><span id="Hive-326"><a href="#Hive-326"><span class="linenos">326</span></a> -</span><span id="Hive-327"><a href="#Hive-327"><span class="linenos">327</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Hive-328"><a href="#Hive-328"><span class="linenos">328</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="Hive-329"><a href="#Hive-329"><span class="linenos">329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Group</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">unalias_group</span><span class="p">]),</span> -</span><span id="Hive-330"><a href="#Hive-330"><span class="linenos">330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="Hive-331"><a href="#Hive-331"><span class="linenos">331</span></a> <span class="p">[</span> -</span><span id="Hive-332"><a href="#Hive-332"><span class="linenos">332</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">,</span> -</span><span id="Hive-333"><a href="#Hive-333"><span class="linenos">333</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> -</span><span id="Hive-334"><a href="#Hive-334"><span class="linenos">334</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">unnest_to_explode</span><span class="p">,</span> -</span><span id="Hive-335"><a href="#Hive-335"><span class="linenos">335</span></a> <span class="p">]</span> -</span><span id="Hive-336"><a href="#Hive-336"><span class="linenos">336</span></a> <span class="p">),</span> -</span><span id="Hive-337"><a href="#Hive-337"><span class="linenos">337</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> <span class="n">_property_sql</span><span class="p">,</span> -</span><span id="Hive-338"><a href="#Hive-338"><span class="linenos">338</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="Hive-339"><a href="#Hive-339"><span class="linenos">339</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">),</span> -</span><span id="Hive-340"><a href="#Hive-340"><span class="linenos">340</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayJoin</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">"CONCAT_WS"</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 class="p">),</span> -</span><span id="Hive-341"><a href="#Hive-341"><span class="linenos">341</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">"SIZE"</span><span class="p">),</span> -</span><span id="Hive-342"><a href="#Hive-342"><span class="linenos">342</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="Hive-343"><a href="#Hive-343"><span class="linenos">343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">:</span> <span class="n">no_recursive_cte_sql</span><span class="p">,</span> -</span><span id="Hive-344"><a href="#Hive-344"><span class="linenos">344</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_add_date_sql</span><span class="p">,</span> -</span><span id="Hive-345"><a href="#Hive-345"><span class="linenos">345</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="n">_date_diff_sql</span><span class="p">,</span> -</span><span id="Hive-346"><a href="#Hive-346"><span class="linenos">346</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_DATE"</span><span class="p">),</span> -</span><span id="Hive-347"><a href="#Hive-347"><span class="linenos">347</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_add_date_sql</span><span class="p">,</span> -</span><span id="Hive-348"><a href="#Hive-348"><span class="linenos">348</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 class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_FORMAT(</span><span 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">Hive</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="Hive-349"><a href="#Hive-349"><span class="linenos">349</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 class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"TO_DATE(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 STRING), </span><span class="si">{</span><span class="n">Hive</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Hive-350"><a href="#Hive-350"><span class="linenos">350</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</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">"STORED AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="w"> </span><span class="k">if</span><span class="w"> </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="w"> </span><span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">e</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="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Hive-351"><a href="#Hive-351"><span class="linenos">351</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase64</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNBASE64"</span><span class="p">),</span> -</span><span id="Hive-352"><a href="#Hive-352"><span class="linenos">352</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">,</span> -</span><span id="Hive-353"><a href="#Hive-353"><span class="linenos">353</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> -</span><span id="Hive-354"><a href="#Hive-354"><span class="linenos">354</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"GET_JSON_OBJECT"</span><span class="p">),</span> -</span><span id="Hive-355"><a href="#Hive-355"><span class="linenos">355</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"GET_JSON_OBJECT"</span><span class="p">),</span> -</span><span id="Hive-356"><a href="#Hive-356"><span class="linenos">356</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="Hive-357"><a href="#Hive-357"><span class="linenos">357</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">:</span> <span class="n">left_to_substring_sql</span><span class="p">,</span> -</span><span id="Hive-358"><a href="#Hive-358"><span class="linenos">358</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Map</span><span class="p">:</span> <span class="n">var_map_sql</span><span class="p">,</span> -</span><span id="Hive-359"><a href="#Hive-359"><span class="linenos">359</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> -</span><span id="Hive-360"><a href="#Hive-360"><span class="linenos">360</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> -</span><span id="Hive-361"><a href="#Hive-361"><span class="linenos">361</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</span><span class="p">:</span> <span class="n">var_map_sql</span><span class="p">,</span> -</span><span id="Hive-362"><a href="#Hive-362"><span class="linenos">362</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> <span class="n">create_with_partitions_sql</span><span class="p">,</span> -</span><span id="Hive-363"><a href="#Hive-363"><span class="linenos">363</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"PERCENTILE"</span><span class="p">),</span> -</span><span id="Hive-364"><a href="#Hive-364"><span class="linenos">364</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"PERCENTILE_APPROX"</span><span class="p">),</span> -</span><span id="Hive-365"><a href="#Hive-365"><span class="linenos">365</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</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">"RLIKE"</span><span class="p">),</span> -</span><span id="Hive-366"><a href="#Hive-366"><span class="linenos">366</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">"SPLIT"</span><span class="p">),</span> -</span><span id="Hive-367"><a href="#Hive-367"><span class="linenos">367</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Right</span><span class="p">:</span> <span class="n">right_to_substring_sql</span><span class="p">,</span> -</span><span id="Hive-368"><a href="#Hive-368"><span class="linenos">368</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="Hive-369"><a href="#Hive-369"><span class="linenos">369</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="Hive-370"><a href="#Hive-370"><span class="linenos">370</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetAgg</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"COLLECT_SET"</span><span class="p">),</span> -</span><span id="Hive-371"><a href="#Hive-371"><span class="linenos">371</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Split</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">"SPLIT(</span><span 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">, CONCAT('</span><span class="se">\\\\</span><span class="s2">Q', </span><span 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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> -</span><span id="Hive-372"><a href="#Hive-372"><span class="linenos">372</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">strposition_to_locate_sql</span><span class="p">,</span> -</span><span id="Hive-373"><a href="#Hive-373"><span class="linenos">373</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="n">_str_to_date_sql</span><span class="p">,</span> -</span><span id="Hive-374"><a href="#Hive-374"><span class="linenos">374</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_time_sql</span><span class="p">,</span> -</span><span id="Hive-375"><a href="#Hive-375"><span class="linenos">375</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">:</span> <span class="n">_str_to_unix_sql</span><span class="p">,</span> -</span><span id="Hive-376"><a href="#Hive-376"><span class="linenos">376</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">:</span> <span class="n">struct_extract_sql</span><span class="p">,</span> -</span><span id="Hive-377"><a href="#Hive-377"><span class="linenos">377</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_DATE"</span><span class="p">),</span> -</span><span id="Hive-378"><a href="#Hive-378"><span class="linenos">378</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="Hive-379"><a href="#Hive-379"><span class="linenos">379</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNIX_TIMESTAMP"</span><span class="p">),</span> -</span><span id="Hive-380"><a href="#Hive-380"><span class="linenos">380</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">:</span> <span class="n">_time_to_str</span><span class="p">,</span> -</span><span id="Hive-381"><a href="#Hive-381"><span class="linenos">381</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">"UNIX_TIMESTAMP"</span><span class="p">),</span> -</span><span id="Hive-382"><a href="#Hive-382"><span class="linenos">382</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToBase64</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BASE64"</span><span class="p">),</span> -</span><span id="Hive-383"><a href="#Hive-383"><span class="linenos">383</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 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 STRING), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> -</span><span id="Hive-384"><a href="#Hive-384"><span class="linenos">384</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</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">"DATE_ADD(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Hive-385"><a href="#Hive-385"><span class="linenos">385</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">_to_date_sql</span><span class="p">,</span> -</span><span id="Hive-386"><a href="#Hive-386"><span class="linenos">386</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">:</span> <span class="n">no_trycast_sql</span><span class="p">,</span> -</span><span id="Hive-387"><a href="#Hive-387"><span class="linenos">387</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="Hive-388"><a href="#Hive-388"><span class="linenos">388</span></a> <span class="s2">"FROM_UNIXTIME"</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">_time_format</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> -</span><span id="Hive-389"><a href="#Hive-389"><span class="linenos">389</span></a> <span class="p">),</span> -</span><span id="Hive-390"><a href="#Hive-390"><span class="linenos">390</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_UNIXTIME"</span><span class="p">),</span> -</span><span id="Hive-391"><a href="#Hive-391"><span class="linenos">391</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTimeStr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_UNIXTIME"</span><span class="p">),</span> -</span><span id="Hive-392"><a href="#Hive-392"><span class="linenos">392</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</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">"PARTITIONED BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Hive-393"><a href="#Hive-393"><span class="linenos">393</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatSerdeProperty</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">"ROW FORMAT SERDE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Hive-394"><a href="#Hive-394"><span class="linenos">394</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</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">properties</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"WITH SERDEPROPERTIES"</span><span class="p">),</span> -</span><span id="Hive-395"><a href="#Hive-395"><span class="linenos">395</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NumberToStr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FORMAT_NUMBER"</span><span class="p">),</span> -</span><span id="Hive-396"><a href="#Hive-396"><span class="linenos">396</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LastDateOfMonth</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LAST_DAY"</span><span class="p">),</span> -</span><span id="Hive-397"><a href="#Hive-397"><span class="linenos">397</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">National</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">national_sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">""</span><span class="p">),</span> -</span><span id="Hive-398"><a href="#Hive-398"><span class="linenos">398</span></a> <span class="p">}</span> -</span><span id="Hive-399"><a href="#Hive-399"><span class="linenos">399</span></a> -</span><span id="Hive-400"><a href="#Hive-400"><span class="linenos">400</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Hive-401"><a href="#Hive-401"><span class="linenos">401</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">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="Hive-402"><a href="#Hive-402"><span class="linenos">402</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Hive-403"><a href="#Hive-403"><span class="linenos">403</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Hive-404"><a href="#Hive-404"><span class="linenos">404</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="Hive-405"><a href="#Hive-405"><span class="linenos">405</span></a> <span class="p">}</span> -</span><span id="Hive-406"><a href="#Hive-406"><span class="linenos">406</span></a> -</span><span id="Hive-407"><a href="#Hive-407"><span class="linenos">407</span></a> <span class="k">def</span> <span class="nf">arrayagg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Hive-408"><a href="#Hive-408"><span class="linenos">408</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="Hive-409"><a href="#Hive-409"><span class="linenos">409</span></a> <span class="s2">"COLLECT_LIST"</span><span class="p">,</span> -</span><span id="Hive-410"><a href="#Hive-410"><span class="linenos">410</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">)</span> <span class="k">else</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="Hive-411"><a href="#Hive-411"><span class="linenos">411</span></a> <span class="p">)</span> -</span><span id="Hive-412"><a href="#Hive-412"><span class="linenos">412</span></a> -</span><span id="Hive-413"><a href="#Hive-413"><span class="linenos">413</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Hive-414"><a href="#Hive-414"><span class="linenos">414</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"TBLPROPERTIES"</span><span class="p">))</span> +</span><span id="Hive-296"><a href="#Hive-296"><span class="linenos">296</span></a><span class="sd"> This shows that Spark doesn't truncate the value into '12', which is inconsistent with</span> +</span><span id="Hive-297"><a href="#Hive-297"><span class="linenos">297</span></a><span class="sd"> what other dialects (e.g. postgres) do, so we need to drop the length to transpile correctly.</span> +</span><span id="Hive-298"><a href="#Hive-298"><span class="linenos">298</span></a> +</span><span id="Hive-299"><a href="#Hive-299"><span class="linenos">299</span></a><span class="sd"> Reference: https://spark.apache.org/docs/latest/sql-ref-datatypes.html</span> +</span><span id="Hive-300"><a href="#Hive-300"><span class="linenos">300</span></a><span class="sd"> """</span> +</span><span id="Hive-301"><a href="#Hive-301"><span class="linenos">301</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="Hive-302"><a href="#Hive-302"><span class="linenos">302</span></a> +</span><span id="Hive-303"><a href="#Hive-303"><span class="linenos">303</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">schema</span><span class="p">:</span> +</span><span id="Hive-304"><a href="#Hive-304"><span class="linenos">304</span></a> <span class="k">return</span> <span class="n">this</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> +</span><span id="Hive-305"><a href="#Hive-305"><span class="linenos">305</span></a> <span class="k">lambda</span> <span class="n">node</span><span class="p">:</span> <span class="n">node</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">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="Hive-306"><a href="#Hive-306"><span class="linenos">306</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="ow">and</span> <span class="n">node</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"char"</span><span class="p">,</span> <span class="s2">"varchar"</span><span class="p">)</span> +</span><span id="Hive-307"><a href="#Hive-307"><span class="linenos">307</span></a> <span class="k">else</span> <span class="n">node</span><span class="p">,</span> +</span><span id="Hive-308"><a href="#Hive-308"><span class="linenos">308</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Hive-309"><a href="#Hive-309"><span class="linenos">309</span></a> <span class="p">)</span> +</span><span id="Hive-310"><a href="#Hive-310"><span class="linenos">310</span></a> +</span><span id="Hive-311"><a href="#Hive-311"><span class="linenos">311</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Hive-312"><a href="#Hive-312"><span class="linenos">312</span></a> +</span><span id="Hive-313"><a href="#Hive-313"><span class="linenos">313</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="Hive-314"><a href="#Hive-314"><span class="linenos">314</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> +</span><span id="Hive-315"><a href="#Hive-315"><span class="linenos">315</span></a> <span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Hive-316"><a href="#Hive-316"><span class="linenos">316</span></a> <span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Hive-317"><a href="#Hive-317"><span class="linenos">317</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Hive-318"><a href="#Hive-318"><span class="linenos">318</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Hive-319"><a href="#Hive-319"><span class="linenos">319</span></a> <span class="n">INDEX_ON</span> <span class="o">=</span> <span class="s2">"ON TABLE"</span> +</span><span id="Hive-320"><a href="#Hive-320"><span class="linenos">320</span></a> +</span><span id="Hive-321"><a href="#Hive-321"><span class="linenos">321</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Hive-322"><a href="#Hive-322"><span class="linenos">322</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="Hive-323"><a href="#Hive-323"><span class="linenos">323</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="s2">"STRING"</span><span class="p">,</span> +</span><span id="Hive-324"><a href="#Hive-324"><span class="linenos">324</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">DATETIME</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="Hive-325"><a href="#Hive-325"><span class="linenos">325</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">"BINARY"</span><span class="p">,</span> +</span><span id="Hive-326"><a href="#Hive-326"><span class="linenos">326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="Hive-327"><a href="#Hive-327"><span class="linenos">327</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">BIT</span><span class="p">:</span> <span class="s2">"BOOLEAN"</span><span class="p">,</span> +</span><span id="Hive-328"><a href="#Hive-328"><span class="linenos">328</span></a> <span class="p">}</span> +</span><span id="Hive-329"><a href="#Hive-329"><span class="linenos">329</span></a> +</span><span id="Hive-330"><a href="#Hive-330"><span class="linenos">330</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Hive-331"><a href="#Hive-331"><span class="linenos">331</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="Hive-332"><a href="#Hive-332"><span class="linenos">332</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Group</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">unalias_group</span><span class="p">]),</span> +</span><span id="Hive-333"><a href="#Hive-333"><span class="linenos">333</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="Hive-334"><a href="#Hive-334"><span class="linenos">334</span></a> <span class="p">[</span> +</span><span id="Hive-335"><a href="#Hive-335"><span class="linenos">335</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">,</span> +</span><span id="Hive-336"><a href="#Hive-336"><span class="linenos">336</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> +</span><span id="Hive-337"><a href="#Hive-337"><span class="linenos">337</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">unnest_to_explode</span><span class="p">,</span> +</span><span id="Hive-338"><a href="#Hive-338"><span class="linenos">338</span></a> <span class="p">]</span> +</span><span id="Hive-339"><a href="#Hive-339"><span class="linenos">339</span></a> <span class="p">),</span> +</span><span id="Hive-340"><a href="#Hive-340"><span class="linenos">340</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> <span class="n">_property_sql</span><span class="p">,</span> +</span><span id="Hive-341"><a href="#Hive-341"><span class="linenos">341</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="Hive-342"><a href="#Hive-342"><span class="linenos">342</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">),</span> +</span><span id="Hive-343"><a href="#Hive-343"><span class="linenos">343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayJoin</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">"CONCAT_WS"</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 class="p">),</span> +</span><span id="Hive-344"><a href="#Hive-344"><span class="linenos">344</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">"SIZE"</span><span class="p">),</span> +</span><span id="Hive-345"><a href="#Hive-345"><span class="linenos">345</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="Hive-346"><a href="#Hive-346"><span class="linenos">346</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">:</span> <span class="n">no_recursive_cte_sql</span><span class="p">,</span> +</span><span id="Hive-347"><a href="#Hive-347"><span class="linenos">347</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_add_date_sql</span><span class="p">,</span> +</span><span id="Hive-348"><a href="#Hive-348"><span class="linenos">348</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="n">_date_diff_sql</span><span class="p">,</span> +</span><span id="Hive-349"><a href="#Hive-349"><span class="linenos">349</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_DATE"</span><span class="p">),</span> +</span><span id="Hive-350"><a href="#Hive-350"><span class="linenos">350</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_add_date_sql</span><span class="p">,</span> +</span><span id="Hive-351"><a href="#Hive-351"><span class="linenos">351</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 class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_FORMAT(</span><span 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">Hive</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="Hive-352"><a href="#Hive-352"><span class="linenos">352</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 class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"TO_DATE(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 STRING), </span><span class="si">{</span><span class="n">Hive</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Hive-353"><a href="#Hive-353"><span class="linenos">353</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</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">"STORED AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="w"> </span><span class="k">if</span><span class="w"> </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="w"> </span><span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">e</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="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Hive-354"><a href="#Hive-354"><span class="linenos">354</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase64</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNBASE64"</span><span class="p">),</span> +</span><span id="Hive-355"><a href="#Hive-355"><span class="linenos">355</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">,</span> +</span><span id="Hive-356"><a href="#Hive-356"><span class="linenos">356</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> +</span><span id="Hive-357"><a href="#Hive-357"><span class="linenos">357</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"GET_JSON_OBJECT"</span><span class="p">),</span> +</span><span id="Hive-358"><a href="#Hive-358"><span class="linenos">358</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"GET_JSON_OBJECT"</span><span class="p">),</span> +</span><span id="Hive-359"><a href="#Hive-359"><span class="linenos">359</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="Hive-360"><a href="#Hive-360"><span class="linenos">360</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">:</span> <span class="n">left_to_substring_sql</span><span class="p">,</span> +</span><span id="Hive-361"><a href="#Hive-361"><span class="linenos">361</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Map</span><span class="p">:</span> <span class="n">var_map_sql</span><span class="p">,</span> +</span><span id="Hive-362"><a href="#Hive-362"><span class="linenos">362</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> +</span><span id="Hive-363"><a href="#Hive-363"><span class="linenos">363</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> +</span><span id="Hive-364"><a href="#Hive-364"><span class="linenos">364</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</span><span class="p">:</span> <span class="n">var_map_sql</span><span class="p">,</span> +</span><span id="Hive-365"><a href="#Hive-365"><span class="linenos">365</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> <span class="n">create_with_partitions_sql</span><span class="p">,</span> +</span><span id="Hive-366"><a href="#Hive-366"><span class="linenos">366</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"PERCENTILE"</span><span class="p">),</span> +</span><span id="Hive-367"><a href="#Hive-367"><span class="linenos">367</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"PERCENTILE_APPROX"</span><span class="p">),</span> +</span><span id="Hive-368"><a href="#Hive-368"><span class="linenos">368</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</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">"RLIKE"</span><span class="p">),</span> +</span><span id="Hive-369"><a href="#Hive-369"><span class="linenos">369</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">"SPLIT"</span><span class="p">),</span> +</span><span id="Hive-370"><a href="#Hive-370"><span class="linenos">370</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Right</span><span class="p">:</span> <span class="n">right_to_substring_sql</span><span class="p">,</span> +</span><span id="Hive-371"><a href="#Hive-371"><span class="linenos">371</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="Hive-372"><a href="#Hive-372"><span class="linenos">372</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="Hive-373"><a href="#Hive-373"><span class="linenos">373</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetAgg</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"COLLECT_SET"</span><span class="p">),</span> +</span><span id="Hive-374"><a href="#Hive-374"><span class="linenos">374</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Split</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">"SPLIT(</span><span 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">, CONCAT('</span><span class="se">\\\\</span><span class="s2">Q', </span><span 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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> +</span><span id="Hive-375"><a href="#Hive-375"><span class="linenos">375</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">strposition_to_locate_sql</span><span class="p">,</span> +</span><span id="Hive-376"><a href="#Hive-376"><span class="linenos">376</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="n">_str_to_date_sql</span><span class="p">,</span> +</span><span id="Hive-377"><a href="#Hive-377"><span class="linenos">377</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_time_sql</span><span class="p">,</span> +</span><span id="Hive-378"><a href="#Hive-378"><span class="linenos">378</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">:</span> <span class="n">_str_to_unix_sql</span><span class="p">,</span> +</span><span id="Hive-379"><a href="#Hive-379"><span class="linenos">379</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">:</span> <span class="n">struct_extract_sql</span><span class="p">,</span> +</span><span id="Hive-380"><a href="#Hive-380"><span class="linenos">380</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_DATE"</span><span class="p">),</span> +</span><span id="Hive-381"><a href="#Hive-381"><span class="linenos">381</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="Hive-382"><a href="#Hive-382"><span class="linenos">382</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNIX_TIMESTAMP"</span><span class="p">),</span> +</span><span id="Hive-383"><a href="#Hive-383"><span class="linenos">383</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">:</span> <span class="n">_time_to_str</span><span class="p">,</span> +</span><span id="Hive-384"><a href="#Hive-384"><span class="linenos">384</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">"UNIX_TIMESTAMP"</span><span class="p">),</span> +</span><span id="Hive-385"><a href="#Hive-385"><span class="linenos">385</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToBase64</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BASE64"</span><span class="p">),</span> +</span><span id="Hive-386"><a href="#Hive-386"><span class="linenos">386</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 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 STRING), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> +</span><span id="Hive-387"><a href="#Hive-387"><span class="linenos">387</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</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">"DATE_ADD(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Hive-388"><a href="#Hive-388"><span class="linenos">388</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">_to_date_sql</span><span class="p">,</span> +</span><span id="Hive-389"><a href="#Hive-389"><span class="linenos">389</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">:</span> <span class="n">no_trycast_sql</span><span class="p">,</span> +</span><span id="Hive-390"><a href="#Hive-390"><span class="linenos">390</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="Hive-391"><a href="#Hive-391"><span class="linenos">391</span></a> <span class="s2">"FROM_UNIXTIME"</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">_time_format</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> +</span><span id="Hive-392"><a href="#Hive-392"><span class="linenos">392</span></a> <span class="p">),</span> +</span><span id="Hive-393"><a href="#Hive-393"><span class="linenos">393</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_UNIXTIME"</span><span class="p">),</span> +</span><span id="Hive-394"><a href="#Hive-394"><span class="linenos">394</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTimeStr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_UNIXTIME"</span><span class="p">),</span> +</span><span id="Hive-395"><a href="#Hive-395"><span class="linenos">395</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</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">"PARTITIONED BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Hive-396"><a href="#Hive-396"><span class="linenos">396</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatSerdeProperty</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">"ROW FORMAT SERDE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Hive-397"><a href="#Hive-397"><span class="linenos">397</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</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">properties</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"WITH SERDEPROPERTIES"</span><span class="p">),</span> +</span><span id="Hive-398"><a href="#Hive-398"><span class="linenos">398</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NumberToStr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FORMAT_NUMBER"</span><span class="p">),</span> +</span><span id="Hive-399"><a href="#Hive-399"><span class="linenos">399</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LastDateOfMonth</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LAST_DAY"</span><span class="p">),</span> +</span><span id="Hive-400"><a href="#Hive-400"><span class="linenos">400</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">National</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">national_sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">""</span><span class="p">),</span> +</span><span id="Hive-401"><a href="#Hive-401"><span class="linenos">401</span></a> <span class="p">}</span> +</span><span id="Hive-402"><a href="#Hive-402"><span class="linenos">402</span></a> +</span><span id="Hive-403"><a href="#Hive-403"><span class="linenos">403</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Hive-404"><a href="#Hive-404"><span class="linenos">404</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">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="Hive-405"><a href="#Hive-405"><span class="linenos">405</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Hive-406"><a href="#Hive-406"><span class="linenos">406</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Hive-407"><a href="#Hive-407"><span class="linenos">407</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="Hive-408"><a href="#Hive-408"><span class="linenos">408</span></a> <span class="p">}</span> +</span><span id="Hive-409"><a href="#Hive-409"><span class="linenos">409</span></a> +</span><span id="Hive-410"><a href="#Hive-410"><span class="linenos">410</span></a> <span class="k">def</span> <span class="nf">arrayagg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Hive-411"><a href="#Hive-411"><span class="linenos">411</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="Hive-412"><a href="#Hive-412"><span class="linenos">412</span></a> <span class="s2">"COLLECT_LIST"</span><span class="p">,</span> +</span><span id="Hive-413"><a href="#Hive-413"><span class="linenos">413</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">)</span> <span class="k">else</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="Hive-414"><a href="#Hive-414"><span class="linenos">414</span></a> <span class="p">)</span> </span><span id="Hive-415"><a href="#Hive-415"><span class="linenos">415</span></a> -</span><span id="Hive-416"><a href="#Hive-416"><span class="linenos">416</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Hive-417"><a href="#Hive-417"><span class="linenos">417</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="Hive-418"><a href="#Hive-418"><span class="linenos">418</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</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 class="n">exp</span><span 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><span id="Hive-419"><a href="#Hive-419"><span class="linenos">419</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="Hive-420"><a href="#Hive-420"><span class="linenos">420</span></a> <span class="p">):</span> -</span><span id="Hive-421"><a href="#Hive-421"><span class="linenos">421</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="s2">"text"</span><span class="p">)</span> -</span><span id="Hive-422"><a href="#Hive-422"><span class="linenos">422</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEMPORAL_TYPES</span><span class="p">:</span> -</span><span id="Hive-423"><a href="#Hive-423"><span class="linenos">423</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="Hive-424"><a href="#Hive-424"><span class="linenos">424</span></a> -</span><span id="Hive-425"><a href="#Hive-425"><span class="linenos">425</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Hive-426"><a href="#Hive-426"><span class="linenos">426</span></a> -</span><span id="Hive-427"><a href="#Hive-427"><span class="linenos">427</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Hive-428"><a href="#Hive-428"><span class="linenos">428</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="o">+</span> <span class="p">[</span> -</span><span id="Hive-429"><a href="#Hive-429"><span class="linenos">429</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distribute"</span><span class="p">),</span> -</span><span id="Hive-430"><a href="#Hive-430"><span class="linenos">430</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"sort"</span><span class="p">),</span> -</span><span id="Hive-431"><a href="#Hive-431"><span class="linenos">431</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"cluster"</span><span class="p">),</span> -</span><span id="Hive-432"><a href="#Hive-432"><span class="linenos">432</span></a> <span class="p">]</span> +</span><span id="Hive-416"><a href="#Hive-416"><span class="linenos">416</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Hive-417"><a href="#Hive-417"><span class="linenos">417</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"TBLPROPERTIES"</span><span class="p">))</span> +</span><span id="Hive-418"><a href="#Hive-418"><span class="linenos">418</span></a> +</span><span id="Hive-419"><a href="#Hive-419"><span class="linenos">419</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Hive-420"><a href="#Hive-420"><span class="linenos">420</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="Hive-421"><a href="#Hive-421"><span class="linenos">421</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</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 class="n">exp</span><span 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><span id="Hive-422"><a href="#Hive-422"><span class="linenos">422</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="Hive-423"><a href="#Hive-423"><span class="linenos">423</span></a> <span class="p">):</span> +</span><span id="Hive-424"><a href="#Hive-424"><span class="linenos">424</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="s2">"text"</span><span class="p">)</span> +</span><span id="Hive-425"><a href="#Hive-425"><span class="linenos">425</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEMPORAL_TYPES</span><span class="p">:</span> +</span><span id="Hive-426"><a href="#Hive-426"><span class="linenos">426</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="Hive-427"><a href="#Hive-427"><span class="linenos">427</span></a> +</span><span id="Hive-428"><a href="#Hive-428"><span class="linenos">428</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Hive-429"><a href="#Hive-429"><span class="linenos">429</span></a> +</span><span id="Hive-430"><a href="#Hive-430"><span class="linenos">430</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Hive-431"><a href="#Hive-431"><span class="linenos">431</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="o">+</span> <span class="p">[</span> +</span><span id="Hive-432"><a href="#Hive-432"><span class="linenos">432</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distribute"</span><span class="p">),</span> +</span><span id="Hive-433"><a href="#Hive-433"><span class="linenos">433</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"sort"</span><span class="p">),</span> +</span><span id="Hive-434"><a href="#Hive-434"><span class="linenos">434</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"cluster"</span><span class="p">),</span> +</span><span id="Hive-435"><a href="#Hive-435"><span class="linenos">435</span></a> <span class="p">]</span> </span></pre></div> @@ -826,6 +835,10 @@ <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="Hive.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="Hive.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="Hive.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="Hive.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="Hive.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="Hive.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="Hive.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="Hive.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="Hive.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -849,32 +862,32 @@ </div> <a class="headerlink" href="#Hive.Tokenizer"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Hive.Tokenizer-192"><a href="#Hive.Tokenizer-192"><span class="linenos">192</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="Hive.Tokenizer-193"><a href="#Hive.Tokenizer-193"><span class="linenos">193</span></a> <span class="n">QUOTES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">,</span> <span class="s1">'"'</span><span class="p">]</span> -</span><span id="Hive.Tokenizer-194"><a href="#Hive.Tokenizer-194"><span class="linenos">194</span></a> <span class="n">IDENTIFIERS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"`"</span><span class="p">]</span> -</span><span id="Hive.Tokenizer-195"><a href="#Hive.Tokenizer-195"><span class="linenos">195</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">]</span> -</span><span id="Hive.Tokenizer-196"><a href="#Hive.Tokenizer-196"><span class="linenos">196</span></a> <span class="n">ENCODE</span> <span class="o">=</span> <span class="s2">"utf-8"</span> -</span><span id="Hive.Tokenizer-197"><a href="#Hive.Tokenizer-197"><span class="linenos">197</span></a> -</span><span id="Hive.Tokenizer-198"><a href="#Hive.Tokenizer-198"><span class="linenos">198</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Hive.Tokenizer-199"><a href="#Hive.Tokenizer-199"><span class="linenos">199</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="Hive.Tokenizer-200"><a href="#Hive.Tokenizer-200"><span class="linenos">200</span></a> <span class="s2">"ADD ARCHIVE"</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="Hive.Tokenizer-201"><a href="#Hive.Tokenizer-201"><span class="linenos">201</span></a> <span class="s2">"ADD ARCHIVES"</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="Hive.Tokenizer-202"><a href="#Hive.Tokenizer-202"><span class="linenos">202</span></a> <span class="s2">"ADD FILE"</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="Hive.Tokenizer-203"><a href="#Hive.Tokenizer-203"><span class="linenos">203</span></a> <span class="s2">"ADD FILES"</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="Hive.Tokenizer-204"><a href="#Hive.Tokenizer-204"><span class="linenos">204</span></a> <span class="s2">"ADD JAR"</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="Hive.Tokenizer-205"><a href="#Hive.Tokenizer-205"><span class="linenos">205</span></a> <span class="s2">"ADD JARS"</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="Hive.Tokenizer-206"><a href="#Hive.Tokenizer-206"><span class="linenos">206</span></a> <span class="s2">"MSCK REPAIR"</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="Hive.Tokenizer-207"><a href="#Hive.Tokenizer-207"><span class="linenos">207</span></a> <span class="s2">"WITH SERDEPROPERTIES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SERDE_PROPERTIES</span><span class="p">,</span> -</span><span id="Hive.Tokenizer-208"><a href="#Hive.Tokenizer-208"><span class="linenos">208</span></a> <span class="p">}</span> -</span><span id="Hive.Tokenizer-209"><a href="#Hive.Tokenizer-209"><span class="linenos">209</span></a> -</span><span id="Hive.Tokenizer-210"><a href="#Hive.Tokenizer-210"><span class="linenos">210</span></a> <span class="n">NUMERIC_LITERALS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Hive.Tokenizer-211"><a href="#Hive.Tokenizer-211"><span class="linenos">211</span></a> <span class="s2">"L"</span><span class="p">:</span> <span class="s2">"BIGINT"</span><span class="p">,</span> -</span><span id="Hive.Tokenizer-212"><a href="#Hive.Tokenizer-212"><span class="linenos">212</span></a> <span class="s2">"S"</span><span class="p">:</span> <span class="s2">"SMALLINT"</span><span class="p">,</span> -</span><span id="Hive.Tokenizer-213"><a href="#Hive.Tokenizer-213"><span class="linenos">213</span></a> <span class="s2">"Y"</span><span class="p">:</span> <span class="s2">"TINYINT"</span><span class="p">,</span> -</span><span id="Hive.Tokenizer-214"><a href="#Hive.Tokenizer-214"><span class="linenos">214</span></a> <span class="s2">"D"</span><span class="p">:</span> <span class="s2">"DOUBLE"</span><span class="p">,</span> -</span><span id="Hive.Tokenizer-215"><a href="#Hive.Tokenizer-215"><span class="linenos">215</span></a> <span class="s2">"F"</span><span class="p">:</span> <span class="s2">"FLOAT"</span><span class="p">,</span> -</span><span id="Hive.Tokenizer-216"><a href="#Hive.Tokenizer-216"><span class="linenos">216</span></a> <span class="s2">"BD"</span><span class="p">:</span> <span class="s2">"DECIMAL"</span><span class="p">,</span> -</span><span id="Hive.Tokenizer-217"><a href="#Hive.Tokenizer-217"><span class="linenos">217</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Hive.Tokenizer-195"><a href="#Hive.Tokenizer-195"><span class="linenos">195</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="Hive.Tokenizer-196"><a href="#Hive.Tokenizer-196"><span class="linenos">196</span></a> <span class="n">QUOTES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">,</span> <span class="s1">'"'</span><span class="p">]</span> +</span><span id="Hive.Tokenizer-197"><a href="#Hive.Tokenizer-197"><span class="linenos">197</span></a> <span class="n">IDENTIFIERS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"`"</span><span class="p">]</span> +</span><span id="Hive.Tokenizer-198"><a href="#Hive.Tokenizer-198"><span class="linenos">198</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">]</span> +</span><span id="Hive.Tokenizer-199"><a href="#Hive.Tokenizer-199"><span class="linenos">199</span></a> <span class="n">ENCODE</span> <span class="o">=</span> <span class="s2">"utf-8"</span> +</span><span id="Hive.Tokenizer-200"><a href="#Hive.Tokenizer-200"><span class="linenos">200</span></a> +</span><span id="Hive.Tokenizer-201"><a href="#Hive.Tokenizer-201"><span class="linenos">201</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Hive.Tokenizer-202"><a href="#Hive.Tokenizer-202"><span class="linenos">202</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="Hive.Tokenizer-203"><a href="#Hive.Tokenizer-203"><span class="linenos">203</span></a> <span class="s2">"ADD ARCHIVE"</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="Hive.Tokenizer-204"><a href="#Hive.Tokenizer-204"><span class="linenos">204</span></a> <span class="s2">"ADD ARCHIVES"</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="Hive.Tokenizer-205"><a href="#Hive.Tokenizer-205"><span class="linenos">205</span></a> <span class="s2">"ADD FILE"</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="Hive.Tokenizer-206"><a href="#Hive.Tokenizer-206"><span class="linenos">206</span></a> <span class="s2">"ADD FILES"</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="Hive.Tokenizer-207"><a href="#Hive.Tokenizer-207"><span class="linenos">207</span></a> <span class="s2">"ADD JAR"</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="Hive.Tokenizer-208"><a href="#Hive.Tokenizer-208"><span class="linenos">208</span></a> <span class="s2">"ADD JARS"</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="Hive.Tokenizer-209"><a href="#Hive.Tokenizer-209"><span class="linenos">209</span></a> <span class="s2">"MSCK REPAIR"</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="Hive.Tokenizer-210"><a href="#Hive.Tokenizer-210"><span class="linenos">210</span></a> <span class="s2">"WITH SERDEPROPERTIES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SERDE_PROPERTIES</span><span class="p">,</span> +</span><span id="Hive.Tokenizer-211"><a href="#Hive.Tokenizer-211"><span class="linenos">211</span></a> <span class="p">}</span> +</span><span id="Hive.Tokenizer-212"><a href="#Hive.Tokenizer-212"><span class="linenos">212</span></a> +</span><span id="Hive.Tokenizer-213"><a href="#Hive.Tokenizer-213"><span class="linenos">213</span></a> <span class="n">NUMERIC_LITERALS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Hive.Tokenizer-214"><a href="#Hive.Tokenizer-214"><span class="linenos">214</span></a> <span class="s2">"L"</span><span class="p">:</span> <span class="s2">"BIGINT"</span><span class="p">,</span> +</span><span id="Hive.Tokenizer-215"><a href="#Hive.Tokenizer-215"><span class="linenos">215</span></a> <span class="s2">"S"</span><span class="p">:</span> <span class="s2">"SMALLINT"</span><span class="p">,</span> +</span><span id="Hive.Tokenizer-216"><a href="#Hive.Tokenizer-216"><span class="linenos">216</span></a> <span class="s2">"Y"</span><span class="p">:</span> <span class="s2">"TINYINT"</span><span class="p">,</span> +</span><span id="Hive.Tokenizer-217"><a href="#Hive.Tokenizer-217"><span class="linenos">217</span></a> <span class="s2">"D"</span><span class="p">:</span> <span class="s2">"DOUBLE"</span><span class="p">,</span> +</span><span id="Hive.Tokenizer-218"><a href="#Hive.Tokenizer-218"><span class="linenos">218</span></a> <span class="s2">"F"</span><span class="p">:</span> <span class="s2">"FLOAT"</span><span class="p">,</span> +</span><span id="Hive.Tokenizer-219"><a href="#Hive.Tokenizer-219"><span class="linenos">219</span></a> <span class="s2">"BD"</span><span class="p">:</span> <span class="s2">"DECIMAL"</span><span class="p">,</span> +</span><span id="Hive.Tokenizer-220"><a href="#Hive.Tokenizer-220"><span class="linenos">220</span></a> <span class="p">}</span> </span></pre></div> @@ -903,96 +916,96 @@ </div> <a class="headerlink" href="#Hive.Parser"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Hive.Parser-219"><a href="#Hive.Parser-219"><span class="linenos">219</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="Hive.Parser-220"><a href="#Hive.Parser-220"><span class="linenos">220</span></a> <span class="n">LOG_DEFAULTS_TO_LN</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Hive.Parser-221"><a href="#Hive.Parser-221"><span class="linenos">221</span></a> <span class="n">STRICT_CAST</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Hive.Parser-222"><a href="#Hive.Parser-222"><span class="linenos">222</span></a> -</span><span id="Hive.Parser-223"><a href="#Hive.Parser-223"><span class="linenos">223</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Hive.Parser-224"><a href="#Hive.Parser-224"><span class="linenos">224</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="Hive.Parser-225"><a href="#Hive.Parser-225"><span class="linenos">225</span></a> <span class="s2">"BASE64"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ToBase64</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Hive.Parser-226"><a href="#Hive.Parser-226"><span class="linenos">226</span></a> <span class="s2">"COLLECT_LIST"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Hive.Parser-227"><a href="#Hive.Parser-227"><span class="linenos">227</span></a> <span class="s2">"DATE_ADD"</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">TsOrDsAdd</span><span class="p">(</span> -</span><span id="Hive.Parser-228"><a href="#Hive.Parser-228"><span class="linenos">228</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">unit</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">"DAY"</span><span class="p">)</span> -</span><span id="Hive.Parser-229"><a href="#Hive.Parser-229"><span class="linenos">229</span></a> <span class="p">),</span> -</span><span id="Hive.Parser-230"><a href="#Hive.Parser-230"><span class="linenos">230</span></a> <span class="s2">"DATEDIFF"</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">DateDiff</span><span class="p">(</span> -</span><span id="Hive.Parser-231"><a href="#Hive.Parser-231"><span class="linenos">231</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)),</span> -</span><span id="Hive.Parser-232"><a href="#Hive.Parser-232"><span class="linenos">232</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span> -</span><span id="Hive.Parser-233"><a href="#Hive.Parser-233"><span class="linenos">233</span></a> <span class="p">),</span> -</span><span id="Hive.Parser-234"><a href="#Hive.Parser-234"><span class="linenos">234</span></a> <span class="s2">"DATE_SUB"</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">TsOrDsAdd</span><span class="p">(</span> -</span><span id="Hive.Parser-235"><a href="#Hive.Parser-235"><span class="linenos">235</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="Hive.Parser-236"><a href="#Hive.Parser-236"><span class="linenos">236</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Mul</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</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="o">-</span><span class="mi">1</span><span class="p">)),</span> -</span><span id="Hive.Parser-237"><a href="#Hive.Parser-237"><span class="linenos">237</span></a> <span class="n">unit</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">"DAY"</span><span class="p">),</span> -</span><span id="Hive.Parser-238"><a href="#Hive.Parser-238"><span class="linenos">238</span></a> <span class="p">),</span> -</span><span id="Hive.Parser-239"><a href="#Hive.Parser-239"><span class="linenos">239</span></a> <span class="s2">"DATE_FORMAT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">format_time_lambda</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">"hive"</span><span class="p">)(</span> -</span><span id="Hive.Parser-240"><a href="#Hive.Parser-240"><span class="linenos">240</span></a> <span class="p">[</span> -</span><span id="Hive.Parser-241"><a href="#Hive.Parser-241"><span class="linenos">241</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)),</span> -</span><span id="Hive.Parser-242"><a href="#Hive.Parser-242"><span class="linenos">242</span></a> <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="Hive.Parser-243"><a href="#Hive.Parser-243"><span class="linenos">243</span></a> <span class="p">]</span> -</span><span id="Hive.Parser-244"><a href="#Hive.Parser-244"><span class="linenos">244</span></a> <span class="p">),</span> -</span><span id="Hive.Parser-245"><a href="#Hive.Parser-245"><span class="linenos">245</span></a> <span class="s2">"DAY"</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">Day</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">))),</span> -</span><span id="Hive.Parser-246"><a href="#Hive.Parser-246"><span class="linenos">246</span></a> <span class="s2">"FROM_UNIXTIME"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">UnixToStr</span><span class="p">,</span> <span class="s2">"hive"</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> -</span><span id="Hive.Parser-247"><a href="#Hive.Parser-247"><span class="linenos">247</span></a> <span class="s2">"GET_JSON_OBJECT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Hive.Parser-248"><a href="#Hive.Parser-248"><span class="linenos">248</span></a> <span class="s2">"LOCATE"</span><span class="p">:</span> <span class="n">locate_to_strposition</span><span class="p">,</span> -</span><span id="Hive.Parser-249"><a href="#Hive.Parser-249"><span class="linenos">249</span></a> <span class="s2">"MAP"</span><span class="p">:</span> <span class="n">parse_var_map</span><span class="p">,</span> -</span><span id="Hive.Parser-250"><a href="#Hive.Parser-250"><span class="linenos">250</span></a> <span class="s2">"MONTH"</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">Month</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">)),</span> -</span><span id="Hive.Parser-251"><a href="#Hive.Parser-251"><span class="linenos">251</span></a> <span class="s2">"PERCENTILE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Hive.Parser-252"><a href="#Hive.Parser-252"><span class="linenos">252</span></a> <span class="s2">"PERCENTILE_APPROX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Hive.Parser-253"><a href="#Hive.Parser-253"><span class="linenos">253</span></a> <span class="s2">"COLLECT_SET"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Hive.Parser-254"><a href="#Hive.Parser-254"><span class="linenos">254</span></a> <span class="s2">"SIZE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Hive.Parser-255"><a href="#Hive.Parser-255"><span class="linenos">255</span></a> <span class="s2">"SPLIT"</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="Hive.Parser-256"><a href="#Hive.Parser-256"><span class="linenos">256</span></a> <span class="s2">"TO_DATE"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">,</span> <span class="s2">"hive"</span><span class="p">),</span> -</span><span id="Hive.Parser-257"><a href="#Hive.Parser-257"><span class="linenos">257</span></a> <span class="s2">"TO_JSON"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Hive.Parser-258"><a href="#Hive.Parser-258"><span class="linenos">258</span></a> <span class="s2">"UNBASE64"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase64</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Hive.Parser-259"><a href="#Hive.Parser-259"><span class="linenos">259</span></a> <span class="s2">"UNIX_TIMESTAMP"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">,</span> <span class="s2">"hive"</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> -</span><span id="Hive.Parser-260"><a href="#Hive.Parser-260"><span class="linenos">260</span></a> <span class="s2">"YEAR"</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">Year</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">)),</span> -</span><span id="Hive.Parser-261"><a href="#Hive.Parser-261"><span class="linenos">261</span></a> <span class="p">}</span> -</span><span id="Hive.Parser-262"><a href="#Hive.Parser-262"><span class="linenos">262</span></a> -</span><span id="Hive.Parser-263"><a href="#Hive.Parser-263"><span class="linenos">263</span></a> <span class="n">PROPERTY_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Hive.Parser-264"><a href="#Hive.Parser-264"><span class="linenos">264</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">PROPERTY_PARSERS</span><span class="p">,</span> -</span><span id="Hive.Parser-265"><a href="#Hive.Parser-265"><span class="linenos">265</span></a> <span class="s2">"WITH SERDEPROPERTIES"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</span><span class="p">(</span> -</span><span id="Hive.Parser-266"><a href="#Hive.Parser-266"><span class="linenos">266</span></a> <span class="n">expressions</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_property</span><span class="p">)</span> -</span><span id="Hive.Parser-267"><a href="#Hive.Parser-267"><span class="linenos">267</span></a> <span class="p">),</span> -</span><span id="Hive.Parser-268"><a href="#Hive.Parser-268"><span class="linenos">268</span></a> <span class="p">}</span> -</span><span id="Hive.Parser-269"><a href="#Hive.Parser-269"><span class="linenos">269</span></a> -</span><span id="Hive.Parser-270"><a href="#Hive.Parser-270"><span class="linenos">270</span></a> <span class="n">QUERY_MODIFIER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Hive.Parser-271"><a href="#Hive.Parser-271"><span class="linenos">271</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">QUERY_MODIFIER_PARSERS</span><span class="p">,</span> -</span><span id="Hive.Parser-272"><a href="#Hive.Parser-272"><span class="linenos">272</span></a> <span class="s2">"distribute"</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Distribute</span><span class="p">,</span> <span class="s2">"DISTRIBUTE"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">),</span> -</span><span id="Hive.Parser-273"><a href="#Hive.Parser-273"><span class="linenos">273</span></a> <span class="s2">"sort"</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">,</span> <span class="s2">"SORT"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">),</span> -</span><span id="Hive.Parser-274"><a href="#Hive.Parser-274"><span class="linenos">274</span></a> <span class="s2">"cluster"</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">,</span> <span class="s2">"CLUSTER"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">),</span> -</span><span id="Hive.Parser-275"><a href="#Hive.Parser-275"><span class="linenos">275</span></a> <span class="p">}</span> -</span><span id="Hive.Parser-276"><a href="#Hive.Parser-276"><span class="linenos">276</span></a> -</span><span id="Hive.Parser-277"><a href="#Hive.Parser-277"><span class="linenos">277</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span> -</span><span id="Hive.Parser-278"><a href="#Hive.Parser-278"><span class="linenos">278</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</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="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Hive.Parser-279"><a href="#Hive.Parser-279"><span class="linenos">279</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="Hive.Parser-280"><a href="#Hive.Parser-280"><span class="linenos">280</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Hive.Parser-281"><a href="#Hive.Parser-281"><span class="linenos">281</span></a><span class="sd"> Spark (and most likely Hive) treats casts to CHAR(length) and VARCHAR(length) as casts to</span> -</span><span id="Hive.Parser-282"><a href="#Hive.Parser-282"><span class="linenos">282</span></a><span class="sd"> STRING in all contexts except for schema definitions. For example, this is in Spark v3.4.0:</span> -</span><span id="Hive.Parser-283"><a href="#Hive.Parser-283"><span class="linenos">283</span></a> -</span><span id="Hive.Parser-284"><a href="#Hive.Parser-284"><span class="linenos">284</span></a><span class="sd"> spark-sql (default)> select cast(1234 as varchar(2));</span> -</span><span id="Hive.Parser-285"><a href="#Hive.Parser-285"><span class="linenos">285</span></a><span class="sd"> 23/06/06 15:51:18 WARN CharVarcharUtils: The Spark cast operator does not support</span> -</span><span id="Hive.Parser-286"><a href="#Hive.Parser-286"><span class="linenos">286</span></a><span class="sd"> char/varchar type and simply treats them as string type. Please use string type</span> -</span><span id="Hive.Parser-287"><a href="#Hive.Parser-287"><span class="linenos">287</span></a><span class="sd"> directly to avoid confusion. Otherwise, you can set spark.sql.legacy.charVarcharAsString</span> -</span><span id="Hive.Parser-288"><a href="#Hive.Parser-288"><span class="linenos">288</span></a><span class="sd"> to true, so that Spark treat them as string type as same as Spark 3.0 and earlier</span> -</span><span id="Hive.Parser-289"><a href="#Hive.Parser-289"><span class="linenos">289</span></a> -</span><span id="Hive.Parser-290"><a href="#Hive.Parser-290"><span class="linenos">290</span></a><span class="sd"> 1234</span> -</span><span id="Hive.Parser-291"><a href="#Hive.Parser-291"><span class="linenos">291</span></a><span class="sd"> Time taken: 4.265 seconds, Fetched 1 row(s)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Hive.Parser-222"><a href="#Hive.Parser-222"><span class="linenos">222</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="Hive.Parser-223"><a href="#Hive.Parser-223"><span class="linenos">223</span></a> <span class="n">LOG_DEFAULTS_TO_LN</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Hive.Parser-224"><a href="#Hive.Parser-224"><span class="linenos">224</span></a> <span class="n">STRICT_CAST</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Hive.Parser-225"><a href="#Hive.Parser-225"><span class="linenos">225</span></a> +</span><span id="Hive.Parser-226"><a href="#Hive.Parser-226"><span class="linenos">226</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Hive.Parser-227"><a href="#Hive.Parser-227"><span class="linenos">227</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="Hive.Parser-228"><a href="#Hive.Parser-228"><span class="linenos">228</span></a> <span class="s2">"BASE64"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ToBase64</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Hive.Parser-229"><a href="#Hive.Parser-229"><span class="linenos">229</span></a> <span class="s2">"COLLECT_LIST"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Hive.Parser-230"><a href="#Hive.Parser-230"><span class="linenos">230</span></a> <span class="s2">"DATE_ADD"</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">TsOrDsAdd</span><span class="p">(</span> +</span><span id="Hive.Parser-231"><a href="#Hive.Parser-231"><span class="linenos">231</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">unit</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">"DAY"</span><span class="p">)</span> +</span><span id="Hive.Parser-232"><a href="#Hive.Parser-232"><span class="linenos">232</span></a> <span class="p">),</span> +</span><span id="Hive.Parser-233"><a href="#Hive.Parser-233"><span class="linenos">233</span></a> <span class="s2">"DATEDIFF"</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">DateDiff</span><span class="p">(</span> +</span><span id="Hive.Parser-234"><a href="#Hive.Parser-234"><span class="linenos">234</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)),</span> +</span><span id="Hive.Parser-235"><a href="#Hive.Parser-235"><span class="linenos">235</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span> +</span><span id="Hive.Parser-236"><a href="#Hive.Parser-236"><span class="linenos">236</span></a> <span class="p">),</span> +</span><span id="Hive.Parser-237"><a href="#Hive.Parser-237"><span class="linenos">237</span></a> <span class="s2">"DATE_SUB"</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">TsOrDsAdd</span><span class="p">(</span> +</span><span id="Hive.Parser-238"><a href="#Hive.Parser-238"><span class="linenos">238</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="Hive.Parser-239"><a href="#Hive.Parser-239"><span class="linenos">239</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Mul</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</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="o">-</span><span class="mi">1</span><span class="p">)),</span> +</span><span id="Hive.Parser-240"><a href="#Hive.Parser-240"><span class="linenos">240</span></a> <span class="n">unit</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">"DAY"</span><span class="p">),</span> +</span><span id="Hive.Parser-241"><a href="#Hive.Parser-241"><span class="linenos">241</span></a> <span class="p">),</span> +</span><span id="Hive.Parser-242"><a href="#Hive.Parser-242"><span class="linenos">242</span></a> <span class="s2">"DATE_FORMAT"</span><span class="p">:</span> <span class="k">lambda</span> <span class="n">args</span><span class="p">:</span> <span class="n">format_time_lambda</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">"hive"</span><span class="p">)(</span> +</span><span id="Hive.Parser-243"><a href="#Hive.Parser-243"><span class="linenos">243</span></a> <span class="p">[</span> +</span><span id="Hive.Parser-244"><a href="#Hive.Parser-244"><span class="linenos">244</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)),</span> +</span><span id="Hive.Parser-245"><a href="#Hive.Parser-245"><span class="linenos">245</span></a> <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="Hive.Parser-246"><a href="#Hive.Parser-246"><span class="linenos">246</span></a> <span class="p">]</span> +</span><span id="Hive.Parser-247"><a href="#Hive.Parser-247"><span class="linenos">247</span></a> <span class="p">),</span> +</span><span id="Hive.Parser-248"><a href="#Hive.Parser-248"><span class="linenos">248</span></a> <span class="s2">"DAY"</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">Day</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">))),</span> +</span><span id="Hive.Parser-249"><a href="#Hive.Parser-249"><span class="linenos">249</span></a> <span class="s2">"FROM_UNIXTIME"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">UnixToStr</span><span class="p">,</span> <span class="s2">"hive"</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> +</span><span id="Hive.Parser-250"><a href="#Hive.Parser-250"><span class="linenos">250</span></a> <span class="s2">"GET_JSON_OBJECT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Hive.Parser-251"><a href="#Hive.Parser-251"><span class="linenos">251</span></a> <span class="s2">"LOCATE"</span><span class="p">:</span> <span class="n">locate_to_strposition</span><span class="p">,</span> +</span><span id="Hive.Parser-252"><a href="#Hive.Parser-252"><span class="linenos">252</span></a> <span class="s2">"MAP"</span><span class="p">:</span> <span class="n">parse_var_map</span><span class="p">,</span> +</span><span id="Hive.Parser-253"><a href="#Hive.Parser-253"><span class="linenos">253</span></a> <span class="s2">"MONTH"</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">Month</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">)),</span> +</span><span id="Hive.Parser-254"><a href="#Hive.Parser-254"><span class="linenos">254</span></a> <span class="s2">"PERCENTILE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Hive.Parser-255"><a href="#Hive.Parser-255"><span class="linenos">255</span></a> <span class="s2">"PERCENTILE_APPROX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Hive.Parser-256"><a href="#Hive.Parser-256"><span class="linenos">256</span></a> <span class="s2">"COLLECT_SET"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Hive.Parser-257"><a href="#Hive.Parser-257"><span class="linenos">257</span></a> <span class="s2">"SIZE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Hive.Parser-258"><a href="#Hive.Parser-258"><span class="linenos">258</span></a> <span class="s2">"SPLIT"</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="Hive.Parser-259"><a href="#Hive.Parser-259"><span class="linenos">259</span></a> <span class="s2">"TO_DATE"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">,</span> <span class="s2">"hive"</span><span class="p">),</span> +</span><span id="Hive.Parser-260"><a href="#Hive.Parser-260"><span class="linenos">260</span></a> <span class="s2">"TO_JSON"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONFormat</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Hive.Parser-261"><a href="#Hive.Parser-261"><span class="linenos">261</span></a> <span class="s2">"UNBASE64"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase64</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Hive.Parser-262"><a href="#Hive.Parser-262"><span class="linenos">262</span></a> <span class="s2">"UNIX_TIMESTAMP"</span><span class="p">:</span> <span class="n">format_time_lambda</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">,</span> <span class="s2">"hive"</span><span class="p">,</span> <span class="kc">True</span><span class="p">),</span> +</span><span id="Hive.Parser-263"><a href="#Hive.Parser-263"><span class="linenos">263</span></a> <span class="s2">"YEAR"</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">Year</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">)),</span> +</span><span id="Hive.Parser-264"><a href="#Hive.Parser-264"><span class="linenos">264</span></a> <span class="p">}</span> +</span><span id="Hive.Parser-265"><a href="#Hive.Parser-265"><span class="linenos">265</span></a> +</span><span id="Hive.Parser-266"><a href="#Hive.Parser-266"><span class="linenos">266</span></a> <span class="n">PROPERTY_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Hive.Parser-267"><a href="#Hive.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">PROPERTY_PARSERS</span><span class="p">,</span> +</span><span id="Hive.Parser-268"><a href="#Hive.Parser-268"><span class="linenos">268</span></a> <span class="s2">"WITH SERDEPROPERTIES"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</span><span class="p">(</span> +</span><span id="Hive.Parser-269"><a href="#Hive.Parser-269"><span class="linenos">269</span></a> <span class="n">expressions</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_property</span><span class="p">)</span> +</span><span id="Hive.Parser-270"><a href="#Hive.Parser-270"><span class="linenos">270</span></a> <span class="p">),</span> +</span><span id="Hive.Parser-271"><a href="#Hive.Parser-271"><span class="linenos">271</span></a> <span class="p">}</span> +</span><span id="Hive.Parser-272"><a href="#Hive.Parser-272"><span class="linenos">272</span></a> +</span><span id="Hive.Parser-273"><a href="#Hive.Parser-273"><span class="linenos">273</span></a> <span class="n">QUERY_MODIFIER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Hive.Parser-274"><a href="#Hive.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">QUERY_MODIFIER_PARSERS</span><span class="p">,</span> +</span><span id="Hive.Parser-275"><a href="#Hive.Parser-275"><span class="linenos">275</span></a> <span class="s2">"cluster"</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CLUSTER_BY</span><span class="p">),</span> +</span><span id="Hive.Parser-276"><a href="#Hive.Parser-276"><span class="linenos">276</span></a> <span class="s2">"distribute"</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Distribute</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DISTRIBUTE_BY</span><span class="p">),</span> +</span><span id="Hive.Parser-277"><a href="#Hive.Parser-277"><span class="linenos">277</span></a> <span class="s2">"sort"</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SORT_BY</span><span class="p">),</span> +</span><span id="Hive.Parser-278"><a href="#Hive.Parser-278"><span class="linenos">278</span></a> <span class="p">}</span> +</span><span id="Hive.Parser-279"><a href="#Hive.Parser-279"><span class="linenos">279</span></a> +</span><span id="Hive.Parser-280"><a href="#Hive.Parser-280"><span class="linenos">280</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span> +</span><span id="Hive.Parser-281"><a href="#Hive.Parser-281"><span class="linenos">281</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</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="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Hive.Parser-282"><a href="#Hive.Parser-282"><span class="linenos">282</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="Hive.Parser-283"><a href="#Hive.Parser-283"><span class="linenos">283</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Hive.Parser-284"><a href="#Hive.Parser-284"><span class="linenos">284</span></a><span class="sd"> Spark (and most likely Hive) treats casts to CHAR(length) and VARCHAR(length) as casts to</span> +</span><span id="Hive.Parser-285"><a href="#Hive.Parser-285"><span class="linenos">285</span></a><span class="sd"> STRING in all contexts except for schema definitions. For example, this is in Spark v3.4.0:</span> +</span><span id="Hive.Parser-286"><a href="#Hive.Parser-286"><span class="linenos">286</span></a> +</span><span id="Hive.Parser-287"><a href="#Hive.Parser-287"><span class="linenos">287</span></a><span class="sd"> spark-sql (default)> select cast(1234 as varchar(2));</span> +</span><span id="Hive.Parser-288"><a href="#Hive.Parser-288"><span class="linenos">288</span></a><span class="sd"> 23/06/06 15:51:18 WARN CharVarcharUtils: The Spark cast operator does not support</span> +</span><span id="Hive.Parser-289"><a href="#Hive.Parser-289"><span class="linenos">289</span></a><span class="sd"> char/varchar type and simply treats them as string type. Please use string type</span> +</span><span id="Hive.Parser-290"><a href="#Hive.Parser-290"><span class="linenos">290</span></a><span class="sd"> directly to avoid confusion. Otherwise, you can set spark.sql.legacy.charVarcharAsString</span> +</span><span id="Hive.Parser-291"><a href="#Hive.Parser-291"><span class="linenos">291</span></a><span class="sd"> to true, so that Spark treat them as string type as same as Spark 3.0 and earlier</span> </span><span id="Hive.Parser-292"><a href="#Hive.Parser-292"><span class="linenos">292</span></a> -</span><span id="Hive.Parser-293"><a href="#Hive.Parser-293"><span class="linenos">293</span></a><span class="sd"> This shows that Spark doesn't truncate the value into '12', which is inconsistent with</span> -</span><span id="Hive.Parser-294"><a href="#Hive.Parser-294"><span class="linenos">294</span></a><span class="sd"> what other dialects (e.g. postgres) do, so we need to drop the length to transpile correctly.</span> +</span><span id="Hive.Parser-293"><a href="#Hive.Parser-293"><span class="linenos">293</span></a><span class="sd"> 1234</span> +</span><span id="Hive.Parser-294"><a href="#Hive.Parser-294"><span class="linenos">294</span></a><span class="sd"> Time taken: 4.265 seconds, Fetched 1 row(s)</span> </span><span id="Hive.Parser-295"><a href="#Hive.Parser-295"><span class="linenos">295</span></a> -</span><span id="Hive.Parser-296"><a href="#Hive.Parser-296"><span class="linenos">296</span></a><span class="sd"> Reference: https://spark.apache.org/docs/latest/sql-ref-datatypes.html</span> -</span><span id="Hive.Parser-297"><a href="#Hive.Parser-297"><span class="linenos">297</span></a><span class="sd"> """</span> -</span><span id="Hive.Parser-298"><a href="#Hive.Parser-298"><span class="linenos">298</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="Hive.Parser-299"><a href="#Hive.Parser-299"><span class="linenos">299</span></a> -</span><span id="Hive.Parser-300"><a href="#Hive.Parser-300"><span class="linenos">300</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">schema</span><span class="p">:</span> -</span><span id="Hive.Parser-301"><a href="#Hive.Parser-301"><span class="linenos">301</span></a> <span class="k">return</span> <span class="n">this</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> -</span><span id="Hive.Parser-302"><a href="#Hive.Parser-302"><span class="linenos">302</span></a> <span class="k">lambda</span> <span class="n">node</span><span class="p">:</span> <span class="n">node</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">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="Hive.Parser-303"><a href="#Hive.Parser-303"><span class="linenos">303</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="ow">and</span> <span class="n">node</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"char"</span><span class="p">,</span> <span class="s2">"varchar"</span><span class="p">)</span> -</span><span id="Hive.Parser-304"><a href="#Hive.Parser-304"><span class="linenos">304</span></a> <span class="k">else</span> <span class="n">node</span><span class="p">,</span> -</span><span id="Hive.Parser-305"><a href="#Hive.Parser-305"><span class="linenos">305</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Hive.Parser-306"><a href="#Hive.Parser-306"><span class="linenos">306</span></a> <span class="p">)</span> -</span><span id="Hive.Parser-307"><a href="#Hive.Parser-307"><span class="linenos">307</span></a> -</span><span id="Hive.Parser-308"><a href="#Hive.Parser-308"><span class="linenos">308</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Hive.Parser-296"><a href="#Hive.Parser-296"><span class="linenos">296</span></a><span class="sd"> This shows that Spark doesn't truncate the value into '12', which is inconsistent with</span> +</span><span id="Hive.Parser-297"><a href="#Hive.Parser-297"><span class="linenos">297</span></a><span class="sd"> what other dialects (e.g. postgres) do, so we need to drop the length to transpile correctly.</span> +</span><span id="Hive.Parser-298"><a href="#Hive.Parser-298"><span class="linenos">298</span></a> +</span><span id="Hive.Parser-299"><a href="#Hive.Parser-299"><span class="linenos">299</span></a><span class="sd"> Reference: https://spark.apache.org/docs/latest/sql-ref-datatypes.html</span> +</span><span id="Hive.Parser-300"><a href="#Hive.Parser-300"><span class="linenos">300</span></a><span class="sd"> """</span> +</span><span id="Hive.Parser-301"><a href="#Hive.Parser-301"><span class="linenos">301</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="Hive.Parser-302"><a href="#Hive.Parser-302"><span class="linenos">302</span></a> +</span><span id="Hive.Parser-303"><a href="#Hive.Parser-303"><span class="linenos">303</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">schema</span><span class="p">:</span> +</span><span id="Hive.Parser-304"><a href="#Hive.Parser-304"><span class="linenos">304</span></a> <span class="k">return</span> <span class="n">this</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> +</span><span id="Hive.Parser-305"><a href="#Hive.Parser-305"><span class="linenos">305</span></a> <span class="k">lambda</span> <span class="n">node</span><span class="p">:</span> <span class="n">node</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">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="Hive.Parser-306"><a href="#Hive.Parser-306"><span class="linenos">306</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="ow">and</span> <span class="n">node</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"char"</span><span class="p">,</span> <span class="s2">"varchar"</span><span class="p">)</span> +</span><span id="Hive.Parser-307"><a href="#Hive.Parser-307"><span class="linenos">307</span></a> <span class="k">else</span> <span class="n">node</span><span class="p">,</span> +</span><span id="Hive.Parser-308"><a href="#Hive.Parser-308"><span class="linenos">308</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Hive.Parser-309"><a href="#Hive.Parser-309"><span class="linenos">309</span></a> <span class="p">)</span> +</span><span id="Hive.Parser-310"><a href="#Hive.Parser-310"><span class="linenos">310</span></a> +</span><span id="Hive.Parser-311"><a href="#Hive.Parser-311"><span class="linenos">311</span></a> <span class="k">return</span> <span class="n">this</span> </span></pre></div> @@ -1041,129 +1054,129 @@ Default: 3</li> </div> <a class="headerlink" href="#Hive.Generator"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Hive.Generator-310"><a href="#Hive.Generator-310"><span class="linenos">310</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="Hive.Generator-311"><a href="#Hive.Generator-311"><span class="linenos">311</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> -</span><span id="Hive.Generator-312"><a href="#Hive.Generator-312"><span class="linenos">312</span></a> <span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Hive.Generator-313"><a href="#Hive.Generator-313"><span class="linenos">313</span></a> <span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Hive.Generator-314"><a href="#Hive.Generator-314"><span class="linenos">314</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Hive.Generator-315"><a href="#Hive.Generator-315"><span class="linenos">315</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Hive.Generator-316"><a href="#Hive.Generator-316"><span class="linenos">316</span></a> <span class="n">INDEX_ON</span> <span class="o">=</span> <span class="s2">"ON TABLE"</span> -</span><span id="Hive.Generator-317"><a href="#Hive.Generator-317"><span class="linenos">317</span></a> -</span><span id="Hive.Generator-318"><a href="#Hive.Generator-318"><span class="linenos">318</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Hive.Generator-319"><a href="#Hive.Generator-319"><span class="linenos">319</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="Hive.Generator-320"><a href="#Hive.Generator-320"><span class="linenos">320</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="s2">"STRING"</span><span class="p">,</span> -</span><span id="Hive.Generator-321"><a href="#Hive.Generator-321"><span class="linenos">321</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">DATETIME</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="Hive.Generator-322"><a href="#Hive.Generator-322"><span class="linenos">322</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">"BINARY"</span><span class="p">,</span> -</span><span id="Hive.Generator-323"><a href="#Hive.Generator-323"><span class="linenos">323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="Hive.Generator-324"><a href="#Hive.Generator-324"><span class="linenos">324</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">BIT</span><span class="p">:</span> <span class="s2">"BOOLEAN"</span><span class="p">,</span> -</span><span id="Hive.Generator-325"><a href="#Hive.Generator-325"><span class="linenos">325</span></a> <span class="p">}</span> -</span><span id="Hive.Generator-326"><a href="#Hive.Generator-326"><span class="linenos">326</span></a> -</span><span id="Hive.Generator-327"><a href="#Hive.Generator-327"><span class="linenos">327</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Hive.Generator-328"><a href="#Hive.Generator-328"><span class="linenos">328</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="Hive.Generator-329"><a href="#Hive.Generator-329"><span class="linenos">329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Group</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">unalias_group</span><span class="p">]),</span> -</span><span id="Hive.Generator-330"><a href="#Hive.Generator-330"><span class="linenos">330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="Hive.Generator-331"><a href="#Hive.Generator-331"><span class="linenos">331</span></a> <span class="p">[</span> -</span><span id="Hive.Generator-332"><a href="#Hive.Generator-332"><span class="linenos">332</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">,</span> -</span><span id="Hive.Generator-333"><a href="#Hive.Generator-333"><span class="linenos">333</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> -</span><span id="Hive.Generator-334"><a href="#Hive.Generator-334"><span class="linenos">334</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">unnest_to_explode</span><span class="p">,</span> -</span><span id="Hive.Generator-335"><a href="#Hive.Generator-335"><span class="linenos">335</span></a> <span class="p">]</span> -</span><span id="Hive.Generator-336"><a href="#Hive.Generator-336"><span class="linenos">336</span></a> <span class="p">),</span> -</span><span id="Hive.Generator-337"><a href="#Hive.Generator-337"><span class="linenos">337</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> <span class="n">_property_sql</span><span class="p">,</span> -</span><span id="Hive.Generator-338"><a href="#Hive.Generator-338"><span class="linenos">338</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="Hive.Generator-339"><a href="#Hive.Generator-339"><span class="linenos">339</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">),</span> -</span><span id="Hive.Generator-340"><a href="#Hive.Generator-340"><span class="linenos">340</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayJoin</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">"CONCAT_WS"</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 class="p">),</span> -</span><span id="Hive.Generator-341"><a href="#Hive.Generator-341"><span class="linenos">341</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">"SIZE"</span><span class="p">),</span> -</span><span id="Hive.Generator-342"><a href="#Hive.Generator-342"><span class="linenos">342</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="Hive.Generator-343"><a href="#Hive.Generator-343"><span class="linenos">343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">:</span> <span class="n">no_recursive_cte_sql</span><span class="p">,</span> -</span><span id="Hive.Generator-344"><a href="#Hive.Generator-344"><span class="linenos">344</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_add_date_sql</span><span class="p">,</span> -</span><span id="Hive.Generator-345"><a href="#Hive.Generator-345"><span class="linenos">345</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="n">_date_diff_sql</span><span class="p">,</span> -</span><span id="Hive.Generator-346"><a href="#Hive.Generator-346"><span class="linenos">346</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_DATE"</span><span class="p">),</span> -</span><span id="Hive.Generator-347"><a href="#Hive.Generator-347"><span class="linenos">347</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_add_date_sql</span><span class="p">,</span> -</span><span id="Hive.Generator-348"><a href="#Hive.Generator-348"><span class="linenos">348</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 class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_FORMAT(</span><span 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">Hive</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="Hive.Generator-349"><a href="#Hive.Generator-349"><span class="linenos">349</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 class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"TO_DATE(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 STRING), </span><span class="si">{</span><span class="n">Hive</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Hive.Generator-350"><a href="#Hive.Generator-350"><span class="linenos">350</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</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">"STORED AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="w"> </span><span class="k">if</span><span class="w"> </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="w"> </span><span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">e</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="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Hive.Generator-351"><a href="#Hive.Generator-351"><span class="linenos">351</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase64</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNBASE64"</span><span class="p">),</span> -</span><span id="Hive.Generator-352"><a href="#Hive.Generator-352"><span class="linenos">352</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">,</span> -</span><span id="Hive.Generator-353"><a href="#Hive.Generator-353"><span class="linenos">353</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> -</span><span id="Hive.Generator-354"><a href="#Hive.Generator-354"><span class="linenos">354</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"GET_JSON_OBJECT"</span><span class="p">),</span> -</span><span id="Hive.Generator-355"><a href="#Hive.Generator-355"><span class="linenos">355</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"GET_JSON_OBJECT"</span><span class="p">),</span> -</span><span id="Hive.Generator-356"><a href="#Hive.Generator-356"><span class="linenos">356</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="Hive.Generator-357"><a href="#Hive.Generator-357"><span class="linenos">357</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">:</span> <span class="n">left_to_substring_sql</span><span class="p">,</span> -</span><span id="Hive.Generator-358"><a href="#Hive.Generator-358"><span class="linenos">358</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Map</span><span class="p">:</span> <span class="n">var_map_sql</span><span class="p">,</span> -</span><span id="Hive.Generator-359"><a href="#Hive.Generator-359"><span class="linenos">359</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> -</span><span id="Hive.Generator-360"><a href="#Hive.Generator-360"><span class="linenos">360</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> -</span><span id="Hive.Generator-361"><a href="#Hive.Generator-361"><span class="linenos">361</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</span><span class="p">:</span> <span class="n">var_map_sql</span><span class="p">,</span> -</span><span id="Hive.Generator-362"><a href="#Hive.Generator-362"><span class="linenos">362</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> <span class="n">create_with_partitions_sql</span><span class="p">,</span> -</span><span id="Hive.Generator-363"><a href="#Hive.Generator-363"><span class="linenos">363</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"PERCENTILE"</span><span class="p">),</span> -</span><span id="Hive.Generator-364"><a href="#Hive.Generator-364"><span class="linenos">364</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"PERCENTILE_APPROX"</span><span class="p">),</span> -</span><span id="Hive.Generator-365"><a href="#Hive.Generator-365"><span class="linenos">365</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</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">"RLIKE"</span><span class="p">),</span> -</span><span id="Hive.Generator-366"><a href="#Hive.Generator-366"><span class="linenos">366</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">"SPLIT"</span><span class="p">),</span> -</span><span id="Hive.Generator-367"><a href="#Hive.Generator-367"><span class="linenos">367</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Right</span><span class="p">:</span> <span class="n">right_to_substring_sql</span><span class="p">,</span> -</span><span id="Hive.Generator-368"><a href="#Hive.Generator-368"><span class="linenos">368</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="Hive.Generator-369"><a href="#Hive.Generator-369"><span class="linenos">369</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="Hive.Generator-370"><a href="#Hive.Generator-370"><span class="linenos">370</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetAgg</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"COLLECT_SET"</span><span class="p">),</span> -</span><span id="Hive.Generator-371"><a href="#Hive.Generator-371"><span class="linenos">371</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Split</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">"SPLIT(</span><span 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">, CONCAT('</span><span class="se">\\\\</span><span class="s2">Q', </span><span 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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> -</span><span id="Hive.Generator-372"><a href="#Hive.Generator-372"><span class="linenos">372</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">strposition_to_locate_sql</span><span class="p">,</span> -</span><span id="Hive.Generator-373"><a href="#Hive.Generator-373"><span class="linenos">373</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="n">_str_to_date_sql</span><span class="p">,</span> -</span><span id="Hive.Generator-374"><a href="#Hive.Generator-374"><span class="linenos">374</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_time_sql</span><span class="p">,</span> -</span><span id="Hive.Generator-375"><a href="#Hive.Generator-375"><span class="linenos">375</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">:</span> <span class="n">_str_to_unix_sql</span><span class="p">,</span> -</span><span id="Hive.Generator-376"><a href="#Hive.Generator-376"><span class="linenos">376</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">:</span> <span class="n">struct_extract_sql</span><span class="p">,</span> -</span><span id="Hive.Generator-377"><a href="#Hive.Generator-377"><span class="linenos">377</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_DATE"</span><span class="p">),</span> -</span><span id="Hive.Generator-378"><a href="#Hive.Generator-378"><span class="linenos">378</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="Hive.Generator-379"><a href="#Hive.Generator-379"><span class="linenos">379</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNIX_TIMESTAMP"</span><span class="p">),</span> -</span><span id="Hive.Generator-380"><a href="#Hive.Generator-380"><span class="linenos">380</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">:</span> <span class="n">_time_to_str</span><span class="p">,</span> -</span><span id="Hive.Generator-381"><a href="#Hive.Generator-381"><span class="linenos">381</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">"UNIX_TIMESTAMP"</span><span class="p">),</span> -</span><span id="Hive.Generator-382"><a href="#Hive.Generator-382"><span class="linenos">382</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToBase64</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BASE64"</span><span class="p">),</span> -</span><span id="Hive.Generator-383"><a href="#Hive.Generator-383"><span class="linenos">383</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 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 STRING), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> -</span><span id="Hive.Generator-384"><a href="#Hive.Generator-384"><span class="linenos">384</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</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">"DATE_ADD(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Hive.Generator-385"><a href="#Hive.Generator-385"><span class="linenos">385</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">_to_date_sql</span><span class="p">,</span> -</span><span id="Hive.Generator-386"><a href="#Hive.Generator-386"><span class="linenos">386</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">:</span> <span class="n">no_trycast_sql</span><span class="p">,</span> -</span><span id="Hive.Generator-387"><a href="#Hive.Generator-387"><span class="linenos">387</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="Hive.Generator-388"><a href="#Hive.Generator-388"><span class="linenos">388</span></a> <span class="s2">"FROM_UNIXTIME"</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">_time_format</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> -</span><span id="Hive.Generator-389"><a href="#Hive.Generator-389"><span class="linenos">389</span></a> <span class="p">),</span> -</span><span id="Hive.Generator-390"><a href="#Hive.Generator-390"><span class="linenos">390</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_UNIXTIME"</span><span class="p">),</span> -</span><span id="Hive.Generator-391"><a href="#Hive.Generator-391"><span class="linenos">391</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTimeStr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_UNIXTIME"</span><span class="p">),</span> -</span><span id="Hive.Generator-392"><a href="#Hive.Generator-392"><span class="linenos">392</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</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">"PARTITIONED BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Hive.Generator-393"><a href="#Hive.Generator-393"><span class="linenos">393</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatSerdeProperty</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">"ROW FORMAT SERDE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Hive.Generator-394"><a href="#Hive.Generator-394"><span class="linenos">394</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</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">properties</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"WITH SERDEPROPERTIES"</span><span class="p">),</span> -</span><span id="Hive.Generator-395"><a href="#Hive.Generator-395"><span class="linenos">395</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NumberToStr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FORMAT_NUMBER"</span><span class="p">),</span> -</span><span id="Hive.Generator-396"><a href="#Hive.Generator-396"><span class="linenos">396</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LastDateOfMonth</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LAST_DAY"</span><span class="p">),</span> -</span><span id="Hive.Generator-397"><a href="#Hive.Generator-397"><span class="linenos">397</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">National</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">national_sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">""</span><span class="p">),</span> -</span><span id="Hive.Generator-398"><a href="#Hive.Generator-398"><span class="linenos">398</span></a> <span class="p">}</span> -</span><span id="Hive.Generator-399"><a href="#Hive.Generator-399"><span class="linenos">399</span></a> -</span><span id="Hive.Generator-400"><a href="#Hive.Generator-400"><span class="linenos">400</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Hive.Generator-401"><a href="#Hive.Generator-401"><span class="linenos">401</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">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="Hive.Generator-402"><a href="#Hive.Generator-402"><span class="linenos">402</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Hive.Generator-403"><a href="#Hive.Generator-403"><span class="linenos">403</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Hive.Generator-404"><a href="#Hive.Generator-404"><span class="linenos">404</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="Hive.Generator-405"><a href="#Hive.Generator-405"><span class="linenos">405</span></a> <span class="p">}</span> -</span><span id="Hive.Generator-406"><a href="#Hive.Generator-406"><span class="linenos">406</span></a> -</span><span id="Hive.Generator-407"><a href="#Hive.Generator-407"><span class="linenos">407</span></a> <span class="k">def</span> <span class="nf">arrayagg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Hive.Generator-408"><a href="#Hive.Generator-408"><span class="linenos">408</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="Hive.Generator-409"><a href="#Hive.Generator-409"><span class="linenos">409</span></a> <span class="s2">"COLLECT_LIST"</span><span class="p">,</span> -</span><span id="Hive.Generator-410"><a href="#Hive.Generator-410"><span class="linenos">410</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">)</span> <span class="k">else</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="Hive.Generator-411"><a href="#Hive.Generator-411"><span class="linenos">411</span></a> <span class="p">)</span> -</span><span id="Hive.Generator-412"><a href="#Hive.Generator-412"><span class="linenos">412</span></a> -</span><span id="Hive.Generator-413"><a href="#Hive.Generator-413"><span class="linenos">413</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Hive.Generator-414"><a href="#Hive.Generator-414"><span class="linenos">414</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"TBLPROPERTIES"</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Hive.Generator-313"><a href="#Hive.Generator-313"><span class="linenos">313</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="Hive.Generator-314"><a href="#Hive.Generator-314"><span class="linenos">314</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> +</span><span id="Hive.Generator-315"><a href="#Hive.Generator-315"><span class="linenos">315</span></a> <span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Hive.Generator-316"><a href="#Hive.Generator-316"><span class="linenos">316</span></a> <span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Hive.Generator-317"><a href="#Hive.Generator-317"><span class="linenos">317</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Hive.Generator-318"><a href="#Hive.Generator-318"><span class="linenos">318</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Hive.Generator-319"><a href="#Hive.Generator-319"><span class="linenos">319</span></a> <span class="n">INDEX_ON</span> <span class="o">=</span> <span class="s2">"ON TABLE"</span> +</span><span id="Hive.Generator-320"><a href="#Hive.Generator-320"><span class="linenos">320</span></a> +</span><span id="Hive.Generator-321"><a href="#Hive.Generator-321"><span class="linenos">321</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Hive.Generator-322"><a href="#Hive.Generator-322"><span class="linenos">322</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="Hive.Generator-323"><a href="#Hive.Generator-323"><span class="linenos">323</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="s2">"STRING"</span><span class="p">,</span> +</span><span id="Hive.Generator-324"><a href="#Hive.Generator-324"><span class="linenos">324</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">DATETIME</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="Hive.Generator-325"><a href="#Hive.Generator-325"><span class="linenos">325</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">"BINARY"</span><span class="p">,</span> +</span><span id="Hive.Generator-326"><a href="#Hive.Generator-326"><span class="linenos">326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="Hive.Generator-327"><a href="#Hive.Generator-327"><span class="linenos">327</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">BIT</span><span class="p">:</span> <span class="s2">"BOOLEAN"</span><span class="p">,</span> +</span><span id="Hive.Generator-328"><a href="#Hive.Generator-328"><span class="linenos">328</span></a> <span class="p">}</span> +</span><span id="Hive.Generator-329"><a href="#Hive.Generator-329"><span class="linenos">329</span></a> +</span><span id="Hive.Generator-330"><a href="#Hive.Generator-330"><span class="linenos">330</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Hive.Generator-331"><a href="#Hive.Generator-331"><span class="linenos">331</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="Hive.Generator-332"><a href="#Hive.Generator-332"><span class="linenos">332</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Group</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">unalias_group</span><span class="p">]),</span> +</span><span id="Hive.Generator-333"><a href="#Hive.Generator-333"><span class="linenos">333</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="Hive.Generator-334"><a href="#Hive.Generator-334"><span class="linenos">334</span></a> <span class="p">[</span> +</span><span id="Hive.Generator-335"><a href="#Hive.Generator-335"><span class="linenos">335</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">,</span> +</span><span id="Hive.Generator-336"><a href="#Hive.Generator-336"><span class="linenos">336</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> +</span><span id="Hive.Generator-337"><a href="#Hive.Generator-337"><span class="linenos">337</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">unnest_to_explode</span><span class="p">,</span> +</span><span id="Hive.Generator-338"><a href="#Hive.Generator-338"><span class="linenos">338</span></a> <span class="p">]</span> +</span><span id="Hive.Generator-339"><a href="#Hive.Generator-339"><span class="linenos">339</span></a> <span class="p">),</span> +</span><span id="Hive.Generator-340"><a href="#Hive.Generator-340"><span class="linenos">340</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> <span class="n">_property_sql</span><span class="p">,</span> +</span><span id="Hive.Generator-341"><a href="#Hive.Generator-341"><span class="linenos">341</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="Hive.Generator-342"><a href="#Hive.Generator-342"><span class="linenos">342</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">),</span> +</span><span id="Hive.Generator-343"><a href="#Hive.Generator-343"><span class="linenos">343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayJoin</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">"CONCAT_WS"</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 class="p">),</span> +</span><span id="Hive.Generator-344"><a href="#Hive.Generator-344"><span class="linenos">344</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">"SIZE"</span><span class="p">),</span> +</span><span id="Hive.Generator-345"><a href="#Hive.Generator-345"><span class="linenos">345</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="Hive.Generator-346"><a href="#Hive.Generator-346"><span class="linenos">346</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">:</span> <span class="n">no_recursive_cte_sql</span><span class="p">,</span> +</span><span id="Hive.Generator-347"><a href="#Hive.Generator-347"><span class="linenos">347</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_add_date_sql</span><span class="p">,</span> +</span><span id="Hive.Generator-348"><a href="#Hive.Generator-348"><span class="linenos">348</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">:</span> <span class="n">_date_diff_sql</span><span class="p">,</span> +</span><span id="Hive.Generator-349"><a href="#Hive.Generator-349"><span class="linenos">349</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_DATE"</span><span class="p">),</span> +</span><span id="Hive.Generator-350"><a href="#Hive.Generator-350"><span class="linenos">350</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateSub</span><span class="p">:</span> <span class="n">_add_date_sql</span><span class="p">,</span> +</span><span id="Hive.Generator-351"><a href="#Hive.Generator-351"><span class="linenos">351</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 class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_FORMAT(</span><span 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">Hive</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="Hive.Generator-352"><a href="#Hive.Generator-352"><span class="linenos">352</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 class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"TO_DATE(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 STRING), </span><span class="si">{</span><span class="n">Hive</span><span class="o">.</span><span class="n">DATEINT_FORMAT</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Hive.Generator-353"><a href="#Hive.Generator-353"><span class="linenos">353</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</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">"STORED AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="w"> </span><span class="k">if</span><span class="w"> </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="w"> </span><span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">e</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="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Hive.Generator-354"><a href="#Hive.Generator-354"><span class="linenos">354</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase64</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNBASE64"</span><span class="p">),</span> +</span><span id="Hive.Generator-355"><a href="#Hive.Generator-355"><span class="linenos">355</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">,</span> +</span><span id="Hive.Generator-356"><a href="#Hive.Generator-356"><span class="linenos">356</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> +</span><span id="Hive.Generator-357"><a href="#Hive.Generator-357"><span class="linenos">357</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"GET_JSON_OBJECT"</span><span class="p">),</span> +</span><span id="Hive.Generator-358"><a href="#Hive.Generator-358"><span class="linenos">358</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"GET_JSON_OBJECT"</span><span class="p">),</span> +</span><span id="Hive.Generator-359"><a href="#Hive.Generator-359"><span class="linenos">359</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="Hive.Generator-360"><a href="#Hive.Generator-360"><span class="linenos">360</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">:</span> <span class="n">left_to_substring_sql</span><span class="p">,</span> +</span><span id="Hive.Generator-361"><a href="#Hive.Generator-361"><span class="linenos">361</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Map</span><span class="p">:</span> <span class="n">var_map_sql</span><span class="p">,</span> +</span><span id="Hive.Generator-362"><a href="#Hive.Generator-362"><span class="linenos">362</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> +</span><span id="Hive.Generator-363"><a href="#Hive.Generator-363"><span class="linenos">363</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> +</span><span id="Hive.Generator-364"><a href="#Hive.Generator-364"><span class="linenos">364</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</span><span class="p">:</span> <span class="n">var_map_sql</span><span class="p">,</span> +</span><span id="Hive.Generator-365"><a href="#Hive.Generator-365"><span class="linenos">365</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">:</span> <span class="n">create_with_partitions_sql</span><span class="p">,</span> +</span><span id="Hive.Generator-366"><a href="#Hive.Generator-366"><span class="linenos">366</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"PERCENTILE"</span><span class="p">),</span> +</span><span id="Hive.Generator-367"><a href="#Hive.Generator-367"><span class="linenos">367</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"PERCENTILE_APPROX"</span><span class="p">),</span> +</span><span id="Hive.Generator-368"><a href="#Hive.Generator-368"><span class="linenos">368</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RegexpLike</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">"RLIKE"</span><span class="p">),</span> +</span><span id="Hive.Generator-369"><a href="#Hive.Generator-369"><span class="linenos">369</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">"SPLIT"</span><span class="p">),</span> +</span><span id="Hive.Generator-370"><a href="#Hive.Generator-370"><span class="linenos">370</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Right</span><span class="p">:</span> <span class="n">right_to_substring_sql</span><span class="p">,</span> +</span><span id="Hive.Generator-371"><a href="#Hive.Generator-371"><span class="linenos">371</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="Hive.Generator-372"><a href="#Hive.Generator-372"><span class="linenos">372</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="Hive.Generator-373"><a href="#Hive.Generator-373"><span class="linenos">373</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetAgg</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"COLLECT_SET"</span><span class="p">),</span> +</span><span id="Hive.Generator-374"><a href="#Hive.Generator-374"><span class="linenos">374</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Split</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">"SPLIT(</span><span 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">, CONCAT('</span><span class="se">\\\\</span><span class="s2">Q', </span><span 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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> +</span><span id="Hive.Generator-375"><a href="#Hive.Generator-375"><span class="linenos">375</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">strposition_to_locate_sql</span><span class="p">,</span> +</span><span id="Hive.Generator-376"><a href="#Hive.Generator-376"><span class="linenos">376</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span><span class="p">:</span> <span class="n">_str_to_date_sql</span><span class="p">,</span> +</span><span id="Hive.Generator-377"><a href="#Hive.Generator-377"><span class="linenos">377</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_time_sql</span><span class="p">,</span> +</span><span id="Hive.Generator-378"><a href="#Hive.Generator-378"><span class="linenos">378</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToUnix</span><span class="p">:</span> <span class="n">_str_to_unix_sql</span><span class="p">,</span> +</span><span id="Hive.Generator-379"><a href="#Hive.Generator-379"><span class="linenos">379</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">:</span> <span class="n">struct_extract_sql</span><span class="p">,</span> +</span><span id="Hive.Generator-380"><a href="#Hive.Generator-380"><span class="linenos">380</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_DATE"</span><span class="p">),</span> +</span><span id="Hive.Generator-381"><a href="#Hive.Generator-381"><span class="linenos">381</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="Hive.Generator-382"><a href="#Hive.Generator-382"><span class="linenos">382</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"UNIX_TIMESTAMP"</span><span class="p">),</span> +</span><span id="Hive.Generator-383"><a href="#Hive.Generator-383"><span class="linenos">383</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToStr</span><span class="p">:</span> <span class="n">_time_to_str</span><span class="p">,</span> +</span><span id="Hive.Generator-384"><a href="#Hive.Generator-384"><span class="linenos">384</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">"UNIX_TIMESTAMP"</span><span class="p">),</span> +</span><span id="Hive.Generator-385"><a href="#Hive.Generator-385"><span class="linenos">385</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToBase64</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BASE64"</span><span class="p">),</span> +</span><span id="Hive.Generator-386"><a href="#Hive.Generator-386"><span class="linenos">386</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 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 STRING), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> +</span><span id="Hive.Generator-387"><a href="#Hive.Generator-387"><span class="linenos">387</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</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">"DATE_ADD(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Hive.Generator-388"><a href="#Hive.Generator-388"><span class="linenos">388</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">_to_date_sql</span><span class="p">,</span> +</span><span id="Hive.Generator-389"><a href="#Hive.Generator-389"><span class="linenos">389</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">:</span> <span class="n">no_trycast_sql</span><span class="p">,</span> +</span><span id="Hive.Generator-390"><a href="#Hive.Generator-390"><span class="linenos">390</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="Hive.Generator-391"><a href="#Hive.Generator-391"><span class="linenos">391</span></a> <span class="s2">"FROM_UNIXTIME"</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">_time_format</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> +</span><span id="Hive.Generator-392"><a href="#Hive.Generator-392"><span class="linenos">392</span></a> <span class="p">),</span> +</span><span id="Hive.Generator-393"><a href="#Hive.Generator-393"><span class="linenos">393</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_UNIXTIME"</span><span class="p">),</span> +</span><span id="Hive.Generator-394"><a href="#Hive.Generator-394"><span class="linenos">394</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTimeStr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_UNIXTIME"</span><span class="p">),</span> +</span><span id="Hive.Generator-395"><a href="#Hive.Generator-395"><span class="linenos">395</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</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">"PARTITIONED BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Hive.Generator-396"><a href="#Hive.Generator-396"><span class="linenos">396</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatSerdeProperty</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">"ROW FORMAT SERDE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Hive.Generator-397"><a href="#Hive.Generator-397"><span class="linenos">397</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</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">properties</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"WITH SERDEPROPERTIES"</span><span class="p">),</span> +</span><span id="Hive.Generator-398"><a href="#Hive.Generator-398"><span class="linenos">398</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NumberToStr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FORMAT_NUMBER"</span><span class="p">),</span> +</span><span id="Hive.Generator-399"><a href="#Hive.Generator-399"><span class="linenos">399</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LastDateOfMonth</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LAST_DAY"</span><span class="p">),</span> +</span><span id="Hive.Generator-400"><a href="#Hive.Generator-400"><span class="linenos">400</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">National</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">national_sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">""</span><span class="p">),</span> +</span><span id="Hive.Generator-401"><a href="#Hive.Generator-401"><span class="linenos">401</span></a> <span class="p">}</span> +</span><span id="Hive.Generator-402"><a href="#Hive.Generator-402"><span class="linenos">402</span></a> +</span><span id="Hive.Generator-403"><a href="#Hive.Generator-403"><span class="linenos">403</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Hive.Generator-404"><a href="#Hive.Generator-404"><span class="linenos">404</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">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="Hive.Generator-405"><a href="#Hive.Generator-405"><span class="linenos">405</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Hive.Generator-406"><a href="#Hive.Generator-406"><span class="linenos">406</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Hive.Generator-407"><a href="#Hive.Generator-407"><span class="linenos">407</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="Hive.Generator-408"><a href="#Hive.Generator-408"><span class="linenos">408</span></a> <span class="p">}</span> +</span><span id="Hive.Generator-409"><a href="#Hive.Generator-409"><span class="linenos">409</span></a> +</span><span id="Hive.Generator-410"><a href="#Hive.Generator-410"><span class="linenos">410</span></a> <span class="k">def</span> <span class="nf">arrayagg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Hive.Generator-411"><a href="#Hive.Generator-411"><span class="linenos">411</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="Hive.Generator-412"><a href="#Hive.Generator-412"><span class="linenos">412</span></a> <span class="s2">"COLLECT_LIST"</span><span class="p">,</span> +</span><span id="Hive.Generator-413"><a href="#Hive.Generator-413"><span class="linenos">413</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">)</span> <span class="k">else</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="Hive.Generator-414"><a href="#Hive.Generator-414"><span class="linenos">414</span></a> <span class="p">)</span> </span><span id="Hive.Generator-415"><a href="#Hive.Generator-415"><span class="linenos">415</span></a> -</span><span id="Hive.Generator-416"><a href="#Hive.Generator-416"><span class="linenos">416</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Hive.Generator-417"><a href="#Hive.Generator-417"><span class="linenos">417</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="Hive.Generator-418"><a href="#Hive.Generator-418"><span class="linenos">418</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</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 class="n">exp</span><span 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><span id="Hive.Generator-419"><a href="#Hive.Generator-419"><span class="linenos">419</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="Hive.Generator-420"><a href="#Hive.Generator-420"><span class="linenos">420</span></a> <span class="p">):</span> -</span><span id="Hive.Generator-421"><a href="#Hive.Generator-421"><span class="linenos">421</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="s2">"text"</span><span class="p">)</span> -</span><span id="Hive.Generator-422"><a href="#Hive.Generator-422"><span class="linenos">422</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEMPORAL_TYPES</span><span class="p">:</span> -</span><span id="Hive.Generator-423"><a href="#Hive.Generator-423"><span class="linenos">423</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="Hive.Generator-424"><a href="#Hive.Generator-424"><span class="linenos">424</span></a> -</span><span id="Hive.Generator-425"><a href="#Hive.Generator-425"><span class="linenos">425</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Hive.Generator-426"><a href="#Hive.Generator-426"><span class="linenos">426</span></a> -</span><span id="Hive.Generator-427"><a href="#Hive.Generator-427"><span class="linenos">427</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Hive.Generator-428"><a href="#Hive.Generator-428"><span class="linenos">428</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="o">+</span> <span class="p">[</span> -</span><span id="Hive.Generator-429"><a href="#Hive.Generator-429"><span class="linenos">429</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distribute"</span><span class="p">),</span> -</span><span id="Hive.Generator-430"><a href="#Hive.Generator-430"><span class="linenos">430</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"sort"</span><span class="p">),</span> -</span><span id="Hive.Generator-431"><a href="#Hive.Generator-431"><span class="linenos">431</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"cluster"</span><span class="p">),</span> -</span><span id="Hive.Generator-432"><a href="#Hive.Generator-432"><span class="linenos">432</span></a> <span class="p">]</span> +</span><span id="Hive.Generator-416"><a href="#Hive.Generator-416"><span class="linenos">416</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Hive.Generator-417"><a href="#Hive.Generator-417"><span class="linenos">417</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"TBLPROPERTIES"</span><span class="p">))</span> +</span><span id="Hive.Generator-418"><a href="#Hive.Generator-418"><span class="linenos">418</span></a> +</span><span id="Hive.Generator-419"><a href="#Hive.Generator-419"><span class="linenos">419</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Hive.Generator-420"><a href="#Hive.Generator-420"><span class="linenos">420</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="Hive.Generator-421"><a href="#Hive.Generator-421"><span class="linenos">421</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</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 class="n">exp</span><span 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><span id="Hive.Generator-422"><a href="#Hive.Generator-422"><span class="linenos">422</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="Hive.Generator-423"><a href="#Hive.Generator-423"><span class="linenos">423</span></a> <span class="p">):</span> +</span><span id="Hive.Generator-424"><a href="#Hive.Generator-424"><span class="linenos">424</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="s2">"text"</span><span class="p">)</span> +</span><span id="Hive.Generator-425"><a href="#Hive.Generator-425"><span class="linenos">425</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEMPORAL_TYPES</span><span class="p">:</span> +</span><span id="Hive.Generator-426"><a href="#Hive.Generator-426"><span class="linenos">426</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="Hive.Generator-427"><a href="#Hive.Generator-427"><span class="linenos">427</span></a> +</span><span id="Hive.Generator-428"><a href="#Hive.Generator-428"><span class="linenos">428</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Hive.Generator-429"><a href="#Hive.Generator-429"><span class="linenos">429</span></a> +</span><span id="Hive.Generator-430"><a href="#Hive.Generator-430"><span class="linenos">430</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Hive.Generator-431"><a href="#Hive.Generator-431"><span class="linenos">431</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="o">+</span> <span class="p">[</span> +</span><span id="Hive.Generator-432"><a href="#Hive.Generator-432"><span class="linenos">432</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distribute"</span><span class="p">),</span> +</span><span id="Hive.Generator-433"><a href="#Hive.Generator-433"><span class="linenos">433</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"sort"</span><span class="p">),</span> +</span><span id="Hive.Generator-434"><a href="#Hive.Generator-434"><span class="linenos">434</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"cluster"</span><span class="p">),</span> +</span><span id="Hive.Generator-435"><a href="#Hive.Generator-435"><span class="linenos">435</span></a> <span class="p">]</span> </span></pre></div> @@ -1217,11 +1230,11 @@ Default: True</li> </div> <a class="headerlink" href="#Hive.Generator.arrayagg_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Hive.Generator.arrayagg_sql-407"><a href="#Hive.Generator.arrayagg_sql-407"><span class="linenos">407</span></a> <span class="k">def</span> <span class="nf">arrayagg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Hive.Generator.arrayagg_sql-408"><a href="#Hive.Generator.arrayagg_sql-408"><span class="linenos">408</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="Hive.Generator.arrayagg_sql-409"><a href="#Hive.Generator.arrayagg_sql-409"><span class="linenos">409</span></a> <span class="s2">"COLLECT_LIST"</span><span class="p">,</span> -</span><span id="Hive.Generator.arrayagg_sql-410"><a href="#Hive.Generator.arrayagg_sql-410"><span class="linenos">410</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">)</span> <span class="k">else</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="Hive.Generator.arrayagg_sql-411"><a href="#Hive.Generator.arrayagg_sql-411"><span class="linenos">411</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Hive.Generator.arrayagg_sql-410"><a href="#Hive.Generator.arrayagg_sql-410"><span class="linenos">410</span></a> <span class="k">def</span> <span class="nf">arrayagg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Hive.Generator.arrayagg_sql-411"><a href="#Hive.Generator.arrayagg_sql-411"><span class="linenos">411</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="Hive.Generator.arrayagg_sql-412"><a href="#Hive.Generator.arrayagg_sql-412"><span class="linenos">412</span></a> <span class="s2">"COLLECT_LIST"</span><span class="p">,</span> +</span><span id="Hive.Generator.arrayagg_sql-413"><a href="#Hive.Generator.arrayagg_sql-413"><span class="linenos">413</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">)</span> <span class="k">else</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="Hive.Generator.arrayagg_sql-414"><a href="#Hive.Generator.arrayagg_sql-414"><span class="linenos">414</span></a> <span class="p">)</span> </span></pre></div> @@ -1239,8 +1252,8 @@ Default: True</li> </div> <a class="headerlink" href="#Hive.Generator.with_properties"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Hive.Generator.with_properties-413"><a href="#Hive.Generator.with_properties-413"><span class="linenos">413</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Hive.Generator.with_properties-414"><a href="#Hive.Generator.with_properties-414"><span class="linenos">414</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"TBLPROPERTIES"</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Hive.Generator.with_properties-416"><a href="#Hive.Generator.with_properties-416"><span class="linenos">416</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Hive.Generator.with_properties-417"><a href="#Hive.Generator.with_properties-417"><span class="linenos">417</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"TBLPROPERTIES"</span><span class="p">))</span> </span></pre></div> @@ -1258,16 +1271,16 @@ Default: True</li> </div> <a class="headerlink" href="#Hive.Generator.datatype_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Hive.Generator.datatype_sql-416"><a href="#Hive.Generator.datatype_sql-416"><span class="linenos">416</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Hive.Generator.datatype_sql-417"><a href="#Hive.Generator.datatype_sql-417"><span class="linenos">417</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="Hive.Generator.datatype_sql-418"><a href="#Hive.Generator.datatype_sql-418"><span class="linenos">418</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</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 class="n">exp</span><span 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><span id="Hive.Generator.datatype_sql-419"><a href="#Hive.Generator.datatype_sql-419"><span class="linenos">419</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="Hive.Generator.datatype_sql-420"><a href="#Hive.Generator.datatype_sql-420"><span class="linenos">420</span></a> <span class="p">):</span> -</span><span id="Hive.Generator.datatype_sql-421"><a href="#Hive.Generator.datatype_sql-421"><span class="linenos">421</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="s2">"text"</span><span class="p">)</span> -</span><span id="Hive.Generator.datatype_sql-422"><a href="#Hive.Generator.datatype_sql-422"><span class="linenos">422</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEMPORAL_TYPES</span><span class="p">:</span> -</span><span id="Hive.Generator.datatype_sql-423"><a href="#Hive.Generator.datatype_sql-423"><span class="linenos">423</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="Hive.Generator.datatype_sql-424"><a href="#Hive.Generator.datatype_sql-424"><span class="linenos">424</span></a> -</span><span id="Hive.Generator.datatype_sql-425"><a href="#Hive.Generator.datatype_sql-425"><span class="linenos">425</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_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="Hive.Generator.datatype_sql-419"><a href="#Hive.Generator.datatype_sql-419"><span class="linenos">419</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Hive.Generator.datatype_sql-420"><a href="#Hive.Generator.datatype_sql-420"><span class="linenos">420</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="Hive.Generator.datatype_sql-421"><a href="#Hive.Generator.datatype_sql-421"><span class="linenos">421</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</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 class="n">exp</span><span 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><span id="Hive.Generator.datatype_sql-422"><a href="#Hive.Generator.datatype_sql-422"><span class="linenos">422</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="Hive.Generator.datatype_sql-423"><a href="#Hive.Generator.datatype_sql-423"><span class="linenos">423</span></a> <span class="p">):</span> +</span><span id="Hive.Generator.datatype_sql-424"><a href="#Hive.Generator.datatype_sql-424"><span class="linenos">424</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="s2">"text"</span><span class="p">)</span> +</span><span id="Hive.Generator.datatype_sql-425"><a href="#Hive.Generator.datatype_sql-425"><span class="linenos">425</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEMPORAL_TYPES</span><span class="p">:</span> +</span><span id="Hive.Generator.datatype_sql-426"><a href="#Hive.Generator.datatype_sql-426"><span class="linenos">426</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="Hive.Generator.datatype_sql-427"><a href="#Hive.Generator.datatype_sql-427"><span class="linenos">427</span></a> +</span><span id="Hive.Generator.datatype_sql-428"><a href="#Hive.Generator.datatype_sql-428"><span class="linenos">428</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -1285,18 +1298,72 @@ Default: True</li> </div> <a class="headerlink" href="#Hive.Generator.after_having_modifiers"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Hive.Generator.after_having_modifiers-427"><a href="#Hive.Generator.after_having_modifiers-427"><span class="linenos">427</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Hive.Generator.after_having_modifiers-428"><a href="#Hive.Generator.after_having_modifiers-428"><span class="linenos">428</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="o">+</span> <span class="p">[</span> -</span><span id="Hive.Generator.after_having_modifiers-429"><a href="#Hive.Generator.after_having_modifiers-429"><span class="linenos">429</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distribute"</span><span class="p">),</span> -</span><span id="Hive.Generator.after_having_modifiers-430"><a href="#Hive.Generator.after_having_modifiers-430"><span class="linenos">430</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"sort"</span><span class="p">),</span> -</span><span id="Hive.Generator.after_having_modifiers-431"><a href="#Hive.Generator.after_having_modifiers-431"><span class="linenos">431</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"cluster"</span><span class="p">),</span> -</span><span id="Hive.Generator.after_having_modifiers-432"><a href="#Hive.Generator.after_having_modifiers-432"><span class="linenos">432</span></a> <span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Hive.Generator.after_having_modifiers-430"><a href="#Hive.Generator.after_having_modifiers-430"><span class="linenos">430</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Hive.Generator.after_having_modifiers-431"><a href="#Hive.Generator.after_having_modifiers-431"><span class="linenos">431</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="o">+</span> <span class="p">[</span> +</span><span id="Hive.Generator.after_having_modifiers-432"><a href="#Hive.Generator.after_having_modifiers-432"><span class="linenos">432</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distribute"</span><span class="p">),</span> +</span><span id="Hive.Generator.after_having_modifiers-433"><a href="#Hive.Generator.after_having_modifiers-433"><span class="linenos">433</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"sort"</span><span class="p">),</span> +</span><span id="Hive.Generator.after_having_modifiers-434"><a href="#Hive.Generator.after_having_modifiers-434"><span class="linenos">434</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"cluster"</span><span class="p">),</span> +</span><span id="Hive.Generator.after_having_modifiers-435"><a href="#Hive.Generator.after_having_modifiers-435"><span class="linenos">435</span></a> <span class="p">]</span> </span></pre></div> </div> + <div id="Hive.Generator.can_identify" class="classattr"> + <input id="Hive.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="Hive.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Hive.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Hive.Generator.can_identify-247"><a href="#Hive.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="Hive.Generator.can_identify-248"><a href="#Hive.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Hive.Generator.can_identify-249"><a href="#Hive.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="Hive.Generator.can_identify-250"><a href="#Hive.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="Hive.Generator.can_identify-251"><a href="#Hive.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="Hive.Generator.can_identify-252"><a href="#Hive.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="Hive.Generator.can_identify-253"><a href="#Hive.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="Hive.Generator.can_identify-254"><a href="#Hive.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="Hive.Generator.can_identify-255"><a href="#Hive.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="Hive.Generator.can_identify-256"><a href="#Hive.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="Hive.Generator.can_identify-257"><a href="#Hive.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="Hive.Generator.can_identify-258"><a href="#Hive.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="Hive.Generator.can_identify-259"><a href="#Hive.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="Hive.Generator.can_identify-260"><a href="#Hive.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="Hive.Generator.can_identify-261"><a href="#Hive.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Hive.Generator.can_identify-262"><a href="#Hive.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="Hive.Generator.can_identify-263"><a href="#Hive.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="Hive.Generator.can_identify-264"><a href="#Hive.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="Hive.Generator.can_identify-265"><a href="#Hive.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="Hive.Generator.can_identify-266"><a href="#Hive.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -1397,6 +1464,7 @@ Default: True</li> <dd id="Hive.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="Hive.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="Hive.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="Hive.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="Hive.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="Hive.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="Hive.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/dialects/mysql.html b/docs/sqlglot/dialects/mysql.html index 489aa39..6106976 100644 --- a/docs/sqlglot/dialects/mysql.html +++ b/docs/sqlglot/dialects/mysql.html @@ -51,6 +51,9 @@ <li> <a class="function" href="#MySQL.Generator.show_sql">show_sql</a> </li> + <li> + <a class="function" href="#MySQL.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -989,6 +992,10 @@ <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="MySQL.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="MySQL.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="MySQL.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="MySQL.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="MySQL.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="MySQL.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="MySQL.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="MySQL.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="MySQL.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -1559,6 +1566,60 @@ Default: True</li> </div> + <div id="MySQL.Generator.can_identify" class="classattr"> + <input id="MySQL.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="MySQL.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#MySQL.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="MySQL.Generator.can_identify-247"><a href="#MySQL.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="MySQL.Generator.can_identify-248"><a href="#MySQL.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="MySQL.Generator.can_identify-249"><a href="#MySQL.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="MySQL.Generator.can_identify-250"><a href="#MySQL.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="MySQL.Generator.can_identify-251"><a href="#MySQL.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="MySQL.Generator.can_identify-252"><a href="#MySQL.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="MySQL.Generator.can_identify-253"><a href="#MySQL.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="MySQL.Generator.can_identify-254"><a href="#MySQL.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="MySQL.Generator.can_identify-255"><a href="#MySQL.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="MySQL.Generator.can_identify-256"><a href="#MySQL.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="MySQL.Generator.can_identify-257"><a href="#MySQL.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="MySQL.Generator.can_identify-258"><a href="#MySQL.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="MySQL.Generator.can_identify-259"><a href="#MySQL.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="MySQL.Generator.can_identify-260"><a href="#MySQL.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="MySQL.Generator.can_identify-261"><a href="#MySQL.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="MySQL.Generator.can_identify-262"><a href="#MySQL.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="MySQL.Generator.can_identify-263"><a href="#MySQL.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="MySQL.Generator.can_identify-264"><a href="#MySQL.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="MySQL.Generator.can_identify-265"><a href="#MySQL.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="MySQL.Generator.can_identify-266"><a href="#MySQL.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -1661,6 +1722,7 @@ Default: True</li> <dd id="MySQL.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="MySQL.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="MySQL.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="MySQL.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="MySQL.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="MySQL.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="MySQL.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/dialects/oracle.html b/docs/sqlglot/dialects/oracle.html index 7258af1..79151f8 100644 --- a/docs/sqlglot/dialects/oracle.html +++ b/docs/sqlglot/dialects/oracle.html @@ -51,6 +51,9 @@ <li> <a class="function" href="#Oracle.Generator.xmltable_sql">xmltable_sql</a> </li> + <li> + <a class="function" href="#Oracle.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -443,6 +446,10 @@ <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="Oracle.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="Oracle.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="Oracle.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="Oracle.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="Oracle.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="Oracle.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="Oracle.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="Oracle.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="Oracle.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -725,6 +732,60 @@ Default: True</li> </div> + <div id="Oracle.Generator.can_identify" class="classattr"> + <input id="Oracle.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="Oracle.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Oracle.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Oracle.Generator.can_identify-247"><a href="#Oracle.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="Oracle.Generator.can_identify-248"><a href="#Oracle.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Oracle.Generator.can_identify-249"><a href="#Oracle.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="Oracle.Generator.can_identify-250"><a href="#Oracle.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="Oracle.Generator.can_identify-251"><a href="#Oracle.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="Oracle.Generator.can_identify-252"><a href="#Oracle.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="Oracle.Generator.can_identify-253"><a href="#Oracle.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="Oracle.Generator.can_identify-254"><a href="#Oracle.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="Oracle.Generator.can_identify-255"><a href="#Oracle.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="Oracle.Generator.can_identify-256"><a href="#Oracle.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="Oracle.Generator.can_identify-257"><a href="#Oracle.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="Oracle.Generator.can_identify-258"><a href="#Oracle.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="Oracle.Generator.can_identify-259"><a href="#Oracle.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="Oracle.Generator.can_identify-260"><a href="#Oracle.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="Oracle.Generator.can_identify-261"><a href="#Oracle.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Oracle.Generator.can_identify-262"><a href="#Oracle.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="Oracle.Generator.can_identify-263"><a href="#Oracle.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="Oracle.Generator.can_identify-264"><a href="#Oracle.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="Oracle.Generator.can_identify-265"><a href="#Oracle.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="Oracle.Generator.can_identify-266"><a href="#Oracle.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -825,6 +886,7 @@ Default: True</li> <dd id="Oracle.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="Oracle.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="Oracle.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="Oracle.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="Oracle.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="Oracle.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="Oracle.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/dialects/postgres.html b/docs/sqlglot/dialects/postgres.html index 2f6dc67..784dafe 100644 --- a/docs/sqlglot/dialects/postgres.html +++ b/docs/sqlglot/dialects/postgres.html @@ -48,6 +48,9 @@ <li> <a class="class" href="#Postgres.Generator">Postgres.Generator</a> <ul class="memberlist"> + <li> + <a class="function" href="#Postgres.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -679,6 +682,10 @@ <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="Postgres.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="Postgres.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="Postgres.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="Postgres.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="Postgres.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="Postgres.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="Postgres.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="Postgres.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="Postgres.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -980,6 +987,60 @@ Default: True</li> </div> + <div id="Postgres.Generator.can_identify" class="classattr"> + <input id="Postgres.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="Postgres.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Postgres.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Postgres.Generator.can_identify-247"><a href="#Postgres.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="Postgres.Generator.can_identify-248"><a href="#Postgres.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Postgres.Generator.can_identify-249"><a href="#Postgres.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="Postgres.Generator.can_identify-250"><a href="#Postgres.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="Postgres.Generator.can_identify-251"><a href="#Postgres.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="Postgres.Generator.can_identify-252"><a href="#Postgres.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="Postgres.Generator.can_identify-253"><a href="#Postgres.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="Postgres.Generator.can_identify-254"><a href="#Postgres.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="Postgres.Generator.can_identify-255"><a href="#Postgres.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="Postgres.Generator.can_identify-256"><a href="#Postgres.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="Postgres.Generator.can_identify-257"><a href="#Postgres.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="Postgres.Generator.can_identify-258"><a href="#Postgres.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="Postgres.Generator.can_identify-259"><a href="#Postgres.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="Postgres.Generator.can_identify-260"><a href="#Postgres.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="Postgres.Generator.can_identify-261"><a href="#Postgres.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Postgres.Generator.can_identify-262"><a href="#Postgres.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="Postgres.Generator.can_identify-263"><a href="#Postgres.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="Postgres.Generator.can_identify-264"><a href="#Postgres.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="Postgres.Generator.can_identify-265"><a href="#Postgres.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="Postgres.Generator.can_identify-266"><a href="#Postgres.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -1082,6 +1143,7 @@ Default: True</li> <dd id="Postgres.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="Postgres.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="Postgres.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="Postgres.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="Postgres.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="Postgres.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="Postgres.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/dialects/presto.html b/docs/sqlglot/dialects/presto.html index d48e50f..125f31e 100644 --- a/docs/sqlglot/dialects/presto.html +++ b/docs/sqlglot/dialects/presto.html @@ -60,6 +60,9 @@ <li> <a class="function" href="#Presto.Generator.offset_limit_modifiers">offset_limit_modifiers</a> </li> + <li> + <a class="function" href="#Presto.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -194,269 +197,265 @@ </span><span id="L-103"><a href="#L-103"><span class="linenos">103</span></a><span class="k">def</span> <span class="nf">_ts_or_ds_to_date_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">generator</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">TsOrDsToDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> </span><span id="L-104"><a href="#L-104"><span class="linenos">104</span></a> <span class="n">time_format</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-105"><a href="#L-105"><span class="linenos">105</span></a> <span class="k">if</span> <span class="n">time_format</span> <span class="ow">and</span> <span class="n">time_format</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span><span class="n">Presto</span><span class="o">.</span><span class="n">TIME_FORMAT</span><span class="p">,</span> <span class="n">Presto</span><span class="o">.</span><span class="n">DATE_FORMAT</span><span class="p">):</span> -</span><span id="L-106"><a href="#L-106"><span class="linenos">106</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-107"><a href="#L-107"><span class="linenos">107</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(SUBSTR(CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS VARCHAR), 1, 10) AS DATE)"</span> +</span><span id="L-106"><a href="#L-106"><span class="linenos">106</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</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 class="s2">"DATE"</span><span class="p">)</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">dialect</span><span class="o">=</span><span class="s2">"presto"</span><span class="p">)</span> +</span><span id="L-107"><a href="#L-107"><span class="linenos">107</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"TIMESTAMP"</span><span class="p">),</span> <span class="s2">"DATE"</span><span class="p">)</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">dialect</span><span class="o">=</span><span class="s2">"presto"</span><span class="p">)</span> </span><span id="L-108"><a href="#L-108"><span class="linenos">108</span></a> </span><span id="L-109"><a href="#L-109"><span class="linenos">109</span></a> </span><span id="L-110"><a href="#L-110"><span class="linenos">110</span></a><span class="k">def</span> <span class="nf">_ts_or_ds_add_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">:</span> <span class="n">generator</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">TsOrDsAdd</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> </span><span id="L-111"><a href="#L-111"><span class="linenos">111</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-112"><a href="#L-112"><span class="linenos">112</span></a> </span><span id="L-113"><a href="#L-113"><span class="linenos">113</span></a> <span class="k">if</span> <span class="ow">not</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">CurrentDate</span><span class="p">):</span> -</span><span id="L-114"><a href="#L-114"><span class="linenos">114</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-115"><a href="#L-115"><span class="linenos">115</span></a> <span class="s2">"DATE_PARSE"</span><span class="p">,</span> -</span><span id="L-116"><a href="#L-116"><span class="linenos">116</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-117"><a href="#L-117"><span class="linenos">117</span></a> <span class="s2">"SUBSTR"</span><span class="p">,</span> -</span><span id="L-118"><a href="#L-118"><span class="linenos">118</span></a> <span class="n">this</span> <span class="k">if</span> <span class="n">this</span><span class="o">.</span><span class="n">is_string</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="s2">"VARCHAR"</span><span class="p">),</span> -</span><span id="L-119"><a href="#L-119"><span class="linenos">119</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> -</span><span id="L-120"><a href="#L-120"><span class="linenos">120</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">10</span><span class="p">),</span> -</span><span id="L-121"><a href="#L-121"><span class="linenos">121</span></a> <span class="p">),</span> -</span><span id="L-122"><a href="#L-122"><span class="linenos">122</span></a> <span class="n">Presto</span><span class="o">.</span><span class="n">DATE_FORMAT</span><span class="p">,</span> -</span><span id="L-123"><a href="#L-123"><span class="linenos">123</span></a> <span class="p">)</span> -</span><span id="L-124"><a href="#L-124"><span class="linenos">124</span></a> -</span><span id="L-125"><a href="#L-125"><span class="linenos">125</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-126"><a href="#L-126"><span class="linenos">126</span></a> <span class="s2">"DATE_ADD"</span><span class="p">,</span> -</span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"day"</span><span class="p">),</span> -</span><span id="L-128"><a href="#L-128"><span class="linenos">128</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> -</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a> <span class="n">this</span><span class="p">,</span> -</span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a> <span class="p">)</span> -</span><span id="L-131"><a href="#L-131"><span class="linenos">131</span></a> -</span><span id="L-132"><a href="#L-132"><span class="linenos">132</span></a> -</span><span id="L-133"><a href="#L-133"><span class="linenos">133</span></a><span class="k">def</span> <span class="nf">_ensure_utf8</span><span class="p">(</span><span class="n">charset</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-134"><a href="#L-134"><span class="linenos">134</span></a> <span class="k">if</span> <span class="n">charset</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">"utf-8"</span><span class="p">:</span> -</span><span id="L-135"><a href="#L-135"><span class="linenos">135</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported charset </span><span class="si">{</span><span class="n">charset</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-136"><a href="#L-136"><span class="linenos">136</span></a> -</span><span id="L-137"><a href="#L-137"><span class="linenos">137</span></a> -</span><span id="L-138"><a href="#L-138"><span class="linenos">138</span></a><span class="k">def</span> <span class="nf">_approx_percentile</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="L-139"><a href="#L-139"><span class="linenos">139</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">4</span><span class="p">:</span> -</span><span id="L-140"><a href="#L-140"><span class="linenos">140</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">(</span> -</span><span id="L-141"><a href="#L-141"><span class="linenos">141</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-142"><a href="#L-142"><span class="linenos">142</span></a> <span class="n">weight</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-143"><a href="#L-143"><span class="linenos">143</span></a> <span class="n">quantile</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-144"><a href="#L-144"><span class="linenos">144</span></a> <span class="n">accuracy</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-145"><a href="#L-145"><span class="linenos">145</span></a> <span class="p">)</span> -</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span> -</span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">(</span> -</span><span id="L-148"><a href="#L-148"><span class="linenos">148</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">quantile</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">accuracy</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-149"><a href="#L-149"><span class="linenos">149</span></a> <span class="p">)</span> -</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> -</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> -</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> -</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a><span class="k">def</span> <span class="nf">_from_unixtime</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span> -</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">(</span> -</span><span id="L-156"><a href="#L-156"><span class="linenos">156</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-157"><a href="#L-157"><span class="linenos">157</span></a> <span class="n">hours</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-158"><a href="#L-158"><span class="linenos">158</span></a> <span class="n">minutes</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-159"><a href="#L-159"><span class="linenos">159</span></a> <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="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</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="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">zone</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-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="k">return</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 class="n">args</span><span class="p">)</span> -</span><span id="L-164"><a href="#L-164"><span class="linenos">164</span></a> -</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> -</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a><span class="k">def</span> <span class="nf">_unnest_sequence</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">):</span> -</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">):</span> -</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">])</span> -</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> -</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> -</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">unnest</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="s2">"_u"</span><span class="p">,</span> <span class="n">table</span><span class="o">=</span><span class="p">[</span><span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">],</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="k">return</span> <span class="n">unnest</span> -</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="k">return</span> <span class="n">expression</span> -</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> -</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> -</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a><span class="k">class</span> <span class="nc">Presto</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> -</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> <span class="n">INDEX_OFFSET</span> <span class="o">=</span> <span class="mi">1</span> -</span><span id="L-179"><a href="#L-179"><span class="linenos">179</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_last"</span> -</span><span id="L-180"><a href="#L-180"><span class="linenos">180</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="n">MySQL</span><span class="o">.</span><span class="n">TIME_FORMAT</span> -</span><span id="L-181"><a href="#L-181"><span class="linenos">181</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="n">MySQL</span><span class="o">.</span><span class="n">TIME_MAPPING</span> -</span><span id="L-182"><a href="#L-182"><span class="linenos">182</span></a> <span class="n">STRICT_STRING_CONCAT</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-183"><a href="#L-183"><span class="linenos">183</span></a> -</span><span id="L-184"><a href="#L-184"><span class="linenos">184</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-185"><a href="#L-185"><span class="linenos">185</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-186"><a href="#L-186"><span class="linenos">186</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-187"><a href="#L-187"><span class="linenos">187</span></a> <span class="s2">"START"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">,</span> -</span><span id="L-188"><a href="#L-188"><span class="linenos">188</span></a> <span class="s2">"MATCH_RECOGNIZE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MATCH_RECOGNIZE</span><span class="p">,</span> -</span><span id="L-189"><a href="#L-189"><span class="linenos">189</span></a> <span class="s2">"ROW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">,</span> -</span><span id="L-190"><a href="#L-190"><span class="linenos">190</span></a> <span class="p">}</span> -</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">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-193"><a href="#L-193"><span class="linenos">193</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-194"><a href="#L-194"><span class="linenos">194</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-195"><a href="#L-195"><span class="linenos">195</span></a> <span class="s2">"APPROX_DISTINCT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a> <span class="s2">"APPROX_PERCENTILE"</span><span class="p">:</span> <span class="n">_approx_percentile</span><span class="p">,</span> -</span><span id="L-197"><a href="#L-197"><span class="linenos">197</span></a> <span class="s2">"CARDINALITY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> <span class="s2">"CONTAINS"</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-199"><a href="#L-199"><span class="linenos">199</span></a> <span class="s2">"DATE_ADD"</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">DateAdd</span><span class="p">(</span> -</span><span id="L-200"><a href="#L-200"><span class="linenos">200</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">2</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">unit</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-201"><a href="#L-201"><span class="linenos">201</span></a> <span class="p">),</span> -</span><span id="L-202"><a href="#L-202"><span class="linenos">202</span></a> <span class="s2">"DATE_DIFF"</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">DateDiff</span><span class="p">(</span> -</span><span id="L-203"><a href="#L-203"><span class="linenos">203</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">2</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">unit</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-204"><a href="#L-204"><span class="linenos">204</span></a> <span class="p">),</span> -</span><span id="L-205"><a href="#L-205"><span class="linenos">205</span></a> <span class="s2">"DATE_FORMAT"</span><span class="p">:</span> <span class="n">format_time_lambda</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">"presto"</span><span class="p">),</span> -</span><span id="L-206"><a href="#L-206"><span class="linenos">206</span></a> <span class="s2">"DATE_PARSE"</span><span class="p">:</span> <span class="n">format_time_lambda</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">"presto"</span><span class="p">),</span> -</span><span id="L-207"><a href="#L-207"><span class="linenos">207</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-208"><a href="#L-208"><span class="linenos">208</span></a> <span class="s2">"FROM_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-209"><a href="#L-209"><span class="linenos">209</span></a> <span class="s2">"FROM_UNIXTIME"</span><span class="p">:</span> <span class="n">_from_unixtime</span><span class="p">,</span> -</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> <span class="s2">"FROM_UTF8"</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-211"><a href="#L-211"><span class="linenos">211</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">replace</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">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-212"><a href="#L-212"><span class="linenos">212</span></a> <span class="p">),</span> -</span><span id="L-213"><a href="#L-213"><span class="linenos">213</span></a> <span class="s2">"NOW"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-214"><a href="#L-214"><span class="linenos">214</span></a> <span class="s2">"SEQUENCE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-215"><a href="#L-215"><span class="linenos">215</span></a> <span class="s2">"STRPOS"</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">StrPosition</span><span class="p">(</span> -</span><span id="L-216"><a href="#L-216"><span class="linenos">216</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">substr</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">instance</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-217"><a href="#L-217"><span class="linenos">217</span></a> <span class="p">),</span> -</span><span id="L-218"><a href="#L-218"><span class="linenos">218</span></a> <span class="s2">"TO_UNIXTIME"</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-219"><a href="#L-219"><span class="linenos">219</span></a> <span class="s2">"TO_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-220"><a href="#L-220"><span class="linenos">220</span></a> <span class="s2">"TO_UTF8"</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-221"><a href="#L-221"><span class="linenos">221</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-222"><a href="#L-222"><span class="linenos">222</span></a> <span class="p">),</span> -</span><span id="L-223"><a href="#L-223"><span class="linenos">223</span></a> <span class="p">}</span> -</span><span id="L-224"><a href="#L-224"><span class="linenos">224</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-225"><a href="#L-225"><span class="linenos">225</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</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="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-228"><a href="#L-228"><span class="linenos">228</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-229"><a href="#L-229"><span class="linenos">229</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-230"><a href="#L-230"><span class="linenos">230</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-231"><a href="#L-231"><span class="linenos">231</span></a> <span class="n">IS_BOOL_ALLOWED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-232"><a href="#L-232"><span class="linenos">232</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-233"><a href="#L-233"><span class="linenos">233</span></a> -</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="o">**</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 class="p">,</span> -</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="p">}</span> -</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> -</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-241"><a href="#L-241"><span class="linenos">241</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-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> -</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"VARBINARY"</span><span class="p">,</span> -</span><span id="L-245"><a href="#L-245"><span class="linenos">245</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="s2">"VARCHAR"</span><span class="p">,</span> -</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="L-247"><a href="#L-247"><span class="linenos">247</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">STRUCT</span><span class="p">:</span> <span class="s2">"ROW"</span><span class="p">,</span> -</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> <span class="p">}</span> -</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> -</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-251"><a href="#L-251"><span class="linenos">251</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-252"><a href="#L-252"><span class="linenos">252</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">_approx_distinct_sql</span><span class="p">,</span> -</span><span id="L-253"><a href="#L-253"><span class="linenos">253</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_PERCENTILE"</span><span class="p">),</span> -</span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</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">"ARRAY[</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">e</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="p">,</span> -</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">),</span> -</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONTAINS"</span><span class="p">),</span> -</span><span id="L-257"><a href="#L-257"><span class="linenos">257</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">"CARDINALITY"</span><span class="p">),</span> -</span><span id="L-258"><a href="#L-258"><span class="linenos">258</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</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">"BITWISE_AND(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</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">"BITWISE_ARITHMETIC_SHIFT_LEFT(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</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">"BITWISE_NOT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</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">"BITWISE_OR(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</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">"BITWISE_ARITHMETIC_SHIFT_RIGHT(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</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">"BITWISE_XOR(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</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">epoch_cast_to_ts</span><span class="p">]),</span> -</span><span id="L-265"><a href="#L-265"><span class="linenos">265</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-266"><a href="#L-266"><span class="linenos">266</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-267"><a href="#L-267"><span class="linenos">267</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</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-268"><a href="#L-268"><span class="linenos">268</span></a> <span class="s2">"DATE_ADD"</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">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"day"</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-269"><a href="#L-269"><span class="linenos">269</span></a> <span class="p">),</span> -</span><span id="L-270"><a href="#L-270"><span class="linenos">270</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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-271"><a href="#L-271"><span class="linenos">271</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">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"day"</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-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="p">),</span> -</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</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(DATE_PARSE(</span><span 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">Presto</span><span class="o">.</span><span class="n">DATE_FORMAT</span><span class="si">}</span><span class="s2">) AS DATE)"</span><span class="p">,</span> -</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateToDi</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(DATE_FORMAT(</span><span 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">Presto</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-275"><a href="#L-275"><span class="linenos">275</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">:</span> <span class="n">_decode_sql</span><span class="p">,</span> -</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DiToDate</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(DATE_PARSE(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 VARCHAR), </span><span class="si">{</span><span class="n">Presto</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-277"><a href="#L-277"><span class="linenos">277</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">:</span> <span class="n">_encode_sql</span><span class="p">,</span> -</span><span id="L-278"><a href="#L-278"><span class="linenos">278</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</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">"FORMAT='</span><span class="si">{</span><span class="n">e</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="si">}</span><span class="s2">'"</span><span class="p">,</span> -</span><span id="L-279"><a href="#L-279"><span class="linenos">279</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Group</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">unalias_group</span><span class="p">]),</span> -</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">),</span> -</span><span id="L-281"><a href="#L-281"><span class="linenos">281</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">,</span> -</span><span id="L-282"><a href="#L-282"><span class="linenos">282</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> -</span><span id="L-283"><a href="#L-283"><span class="linenos">283</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Initcap</span><span class="p">:</span> <span class="n">_initcap_sql</span><span class="p">,</span> -</span><span id="L-284"><a href="#L-284"><span class="linenos">284</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">:</span> <span class="n">_explode_to_unnest_sql</span><span class="p">,</span> -</span><span id="L-285"><a href="#L-285"><span class="linenos">285</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">:</span> <span class="n">left_to_substring_sql</span><span class="p">,</span> -</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LEVENSHTEIN_DISTANCE"</span><span class="p">),</span> -</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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-288"><a href="#L-288"><span class="linenos">288</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-289"><a href="#L-289"><span class="linenos">289</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">no_pivot_sql</span><span class="p">,</span> -</span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="p">:</span> <span class="n">_quantile_sql</span><span class="p">,</span> -</span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Right</span><span class="p">:</span> <span class="n">right_to_substring_sql</span><span class="p">,</span> -</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">:</span> <span class="n">no_safe_divide_sql</span><span class="p">,</span> -</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">:</span> <span class="n">_schema_sql</span><span class="p">,</span> -</span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</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="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">,</span> -</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> -</span><span id="L-298"><a href="#L-298"><span class="linenos">298</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">explode_to_unnest</span><span class="p">,</span> -</span><span id="L-299"><a href="#L-299"><span class="linenos">299</span></a> <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="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="p">:</span> <span class="n">_no_sort_array</span><span class="p">,</span> -</span><span id="L-302"><a href="#L-302"><span class="linenos">302</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRPOS"</span><span class="p">),</span> -</span><span id="L-303"><a href="#L-303"><span class="linenos">303</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</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(</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">e</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span><span class="p">,</span> -</span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_time_sql</span><span class="p">,</span> -</span><span id="L-305"><a href="#L-305"><span class="linenos">305</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span 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="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 class="si">}</span><span class="s2">))"</span><span class="p">,</span> -</span><span id="L-306"><a href="#L-306"><span class="linenos">306</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">:</span> <span class="n">struct_extract_sql</span><span class="p">,</span> -</span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Table</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">_unnest_sequence</span><span class="p">]),</span> -</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">:</span> <span class="n">timestamptrunc_sql</span><span class="p">,</span> -</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> -</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> -</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span 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">Presto</span><span class="o">.</span><span class="n">TIME_FORMAT</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> -</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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="sa">f</span><span class="s2">"DATE_FORMAT(</span><span 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="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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-313"><a href="#L-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_UNIXTIME"</span><span class="p">),</span> -</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</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">epoch_cast_to_ts</span><span class="p">]),</span> -</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDiToDi</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(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 VARCHAR), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> -</span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> -</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">_ts_or_ds_to_date_sql</span><span class="p">,</span> -</span><span id="L-318"><a href="#L-318"><span class="linenos">318</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_HEX"</span><span class="p">),</span> -</span><span id="L-319"><a href="#L-319"><span class="linenos">319</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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="sa">f</span><span class="s2">"DATE_FORMAT(FROM_UNIXTIME(</span><span 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="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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-320"><a href="#L-320"><span class="linenos">320</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_UNIXTIME"</span><span class="p">),</span> -</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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(FROM_UNIXTIME(</span><span 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 VARCHAR)"</span><span class="p">,</span> -</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</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">add_recursive_cte_column_names</span><span class="p">]),</span> -</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a> <span class="p">[</span><span class="n">transforms</span><span class="o">.</span><span class="n">remove_within_group_for_percentiles</span><span class="p">]</span> -</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> <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="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-330"><a href="#L-330"><span class="linenos">330</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> -</span><span id="L-331"><a href="#L-331"><span class="linenos">331</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">()</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-332"><a href="#L-332"><span class="linenos">332</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> * INTERVAL '7' day)"</span> -</span><span id="L-333"><a href="#L-333"><span class="linenos">333</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-334"><a href="#L-334"><span class="linenos">334</span></a> -</span><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-336"><a href="#L-336"><span class="linenos">336</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modes"</span><span class="p">)</span> -</span><span id="L-337"><a href="#L-337"><span class="linenos">337</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">modes</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modes</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-338"><a href="#L-338"><span class="linenos">338</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"START TRANSACTION</span><span class="si">{</span><span class="n">modes</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-339"><a href="#L-339"><span class="linenos">339</span></a> -</span><span id="L-340"><a href="#L-340"><span class="linenos">340</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-341"><a href="#L-341"><span class="linenos">341</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"start"</span><span class="p">]</span> -</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a> <span class="n">end</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">"end"</span><span class="p">]</span> -</span><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a> <span class="n">step</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"step"</span><span class="p">)</span> -</span><span id="L-344"><a href="#L-344"><span class="linenos">344</span></a> -</span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span> -</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">end</span><span class="o">.</span><span class="n">to</span> -</span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-351"><a href="#L-351"><span class="linenos">351</span></a> -</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">and</span> <span class="n">target_type</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"timestamp"</span><span class="p">):</span> -</span><span id="L-353"><a href="#L-353"><span class="linenos">353</span></a> <span class="n">to</span> <span class="o">=</span> <span class="n">target_type</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="L-354"><a href="#L-354"><span class="linenos">354</span></a> -</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">is</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span><span class="p">:</span> -</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a> <span class="n">end</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">end</span><span class="p">,</span> <span class="n">to</span><span class="p">)</span> -</span><span id="L-357"><a href="#L-357"><span class="linenos">357</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-358"><a href="#L-358"><span class="linenos">358</span></a> <span class="n">start</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">start</span><span class="p">,</span> <span class="n">to</span><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">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"SEQUENCE"</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span> -</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a> -</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> -</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> -</span><span id="L-364"><a href="#L-364"><span class="linenos">364</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="L-365"><a href="#L-365"><span class="linenos">365</span></a> <span class="k">return</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="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> -</span><span id="L-367"><a href="#L-367"><span class="linenos">367</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> -</span><span id="L-368"><a href="#L-368"><span class="linenos">368</span></a> <span class="p">]</span> +</span><span id="L-114"><a href="#L-114"><span class="linenos">114</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"TIMESTAMP"</span><span class="p">),</span> <span class="s2">"DATE"</span><span class="p">)</span> +</span><span id="L-115"><a href="#L-115"><span class="linenos">115</span></a> +</span><span id="L-116"><a href="#L-116"><span class="linenos">116</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-117"><a href="#L-117"><span class="linenos">117</span></a> <span class="s2">"DATE_ADD"</span><span class="p">,</span> +</span><span id="L-118"><a href="#L-118"><span class="linenos">118</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"day"</span><span class="p">),</span> +</span><span id="L-119"><a href="#L-119"><span class="linenos">119</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> +</span><span id="L-120"><a href="#L-120"><span class="linenos">120</span></a> <span class="n">this</span><span class="p">,</span> +</span><span id="L-121"><a href="#L-121"><span class="linenos">121</span></a> <span class="p">)</span> +</span><span id="L-122"><a href="#L-122"><span class="linenos">122</span></a> +</span><span id="L-123"><a href="#L-123"><span class="linenos">123</span></a> +</span><span id="L-124"><a href="#L-124"><span class="linenos">124</span></a><span class="k">def</span> <span class="nf">_ensure_utf8</span><span class="p">(</span><span class="n">charset</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-125"><a href="#L-125"><span class="linenos">125</span></a> <span class="k">if</span> <span class="n">charset</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">"utf-8"</span><span class="p">:</span> +</span><span id="L-126"><a href="#L-126"><span class="linenos">126</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported charset </span><span class="si">{</span><span class="n">charset</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a> +</span><span id="L-128"><a href="#L-128"><span class="linenos">128</span></a> +</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a><span class="k">def</span> <span class="nf">_approx_percentile</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">4</span><span class="p">:</span> +</span><span id="L-131"><a href="#L-131"><span class="linenos">131</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">(</span> +</span><span id="L-132"><a href="#L-132"><span class="linenos">132</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-133"><a href="#L-133"><span class="linenos">133</span></a> <span class="n">weight</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-134"><a href="#L-134"><span class="linenos">134</span></a> <span class="n">quantile</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-135"><a href="#L-135"><span class="linenos">135</span></a> <span class="n">accuracy</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-136"><a href="#L-136"><span class="linenos">136</span></a> <span class="p">)</span> +</span><span id="L-137"><a href="#L-137"><span class="linenos">137</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span> +</span><span id="L-138"><a href="#L-138"><span class="linenos">138</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">(</span> +</span><span id="L-139"><a href="#L-139"><span class="linenos">139</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">quantile</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">accuracy</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-140"><a href="#L-140"><span class="linenos">140</span></a> <span class="p">)</span> +</span><span id="L-141"><a href="#L-141"><span class="linenos">141</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> +</span><span id="L-142"><a href="#L-142"><span class="linenos">142</span></a> +</span><span id="L-143"><a href="#L-143"><span class="linenos">143</span></a> +</span><span id="L-144"><a href="#L-144"><span class="linenos">144</span></a><span class="k">def</span> <span class="nf">_from_unixtime</span><span class="p">(</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span> +</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">(</span> +</span><span id="L-147"><a href="#L-147"><span class="linenos">147</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-148"><a href="#L-148"><span class="linenos">148</span></a> <span class="n">hours</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-149"><a href="#L-149"><span class="linenos">149</span></a> <span class="n">minutes</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-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="p">)</span> +</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> +</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">zone</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-153"><a href="#L-153"><span class="linenos">153</span></a> +</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> <span class="k">return</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 class="n">args</span><span class="p">)</span> +</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> +</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> +</span><span id="L-157"><a href="#L-157"><span class="linenos">157</span></a><span class="k">def</span> <span class="nf">_unnest_sequence</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="L-158"><a href="#L-158"><span class="linenos">158</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">):</span> +</span><span id="L-159"><a href="#L-159"><span class="linenos">159</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="p">):</span> +</span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">])</span> +</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> +</span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> +</span><span id="L-163"><a href="#L-163"><span class="linenos">163</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">unnest</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="s2">"_u"</span><span class="p">,</span> <span class="n">table</span><span class="o">=</span><span class="p">[</span><span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">],</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-164"><a href="#L-164"><span class="linenos">164</span></a> <span class="k">return</span> <span class="n">unnest</span> +</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a> +</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a> +</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a><span class="k">class</span> <span class="nc">Presto</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> +</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a> <span class="n">INDEX_OFFSET</span> <span class="o">=</span> <span class="mi">1</span> +</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_last"</span> +</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="n">MySQL</span><span class="o">.</span><span class="n">TIME_FORMAT</span> +</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="n">MySQL</span><span class="o">.</span><span class="n">TIME_MAPPING</span> +</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="n">STRICT_STRING_CONCAT</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> +</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="c1"># https://github.com/trinodb/trino/issues/17</span> +</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> <span class="c1"># https://github.com/trinodb/trino/issues/12289</span> +</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="c1"># https://github.com/prestodb/presto/issues/2863</span> +</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-179"><a href="#L-179"><span class="linenos">179</span></a> +</span><span id="L-180"><a href="#L-180"><span class="linenos">180</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-181"><a href="#L-181"><span class="linenos">181</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-182"><a href="#L-182"><span class="linenos">182</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-183"><a href="#L-183"><span class="linenos">183</span></a> <span class="s2">"START"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">,</span> +</span><span id="L-184"><a href="#L-184"><span class="linenos">184</span></a> <span class="s2">"MATCH_RECOGNIZE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MATCH_RECOGNIZE</span><span class="p">,</span> +</span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> <span class="s2">"ROW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">,</span> +</span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a> <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 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-189"><a href="#L-189"><span class="linenos">189</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-190"><a href="#L-190"><span class="linenos">190</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-191"><a href="#L-191"><span class="linenos">191</span></a> <span class="s2">"APPROX_DISTINCT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-192"><a href="#L-192"><span class="linenos">192</span></a> <span class="s2">"APPROX_PERCENTILE"</span><span class="p">:</span> <span class="n">_approx_percentile</span><span class="p">,</span> +</span><span id="L-193"><a href="#L-193"><span class="linenos">193</span></a> <span class="s2">"CARDINALITY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-194"><a href="#L-194"><span class="linenos">194</span></a> <span class="s2">"CONTAINS"</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-195"><a href="#L-195"><span class="linenos">195</span></a> <span class="s2">"DATE_ADD"</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">DateAdd</span><span class="p">(</span> +</span><span id="L-196"><a href="#L-196"><span class="linenos">196</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">2</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">unit</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-197"><a href="#L-197"><span class="linenos">197</span></a> <span class="p">),</span> +</span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> <span class="s2">"DATE_DIFF"</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">DateDiff</span><span class="p">(</span> +</span><span id="L-199"><a href="#L-199"><span class="linenos">199</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">2</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">unit</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-200"><a href="#L-200"><span class="linenos">200</span></a> <span class="p">),</span> +</span><span id="L-201"><a href="#L-201"><span class="linenos">201</span></a> <span class="s2">"DATE_FORMAT"</span><span class="p">:</span> <span class="n">format_time_lambda</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">"presto"</span><span class="p">),</span> +</span><span id="L-202"><a href="#L-202"><span class="linenos">202</span></a> <span class="s2">"DATE_PARSE"</span><span class="p">:</span> <span class="n">format_time_lambda</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">"presto"</span><span class="p">),</span> +</span><span id="L-203"><a href="#L-203"><span class="linenos">203</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-204"><a href="#L-204"><span class="linenos">204</span></a> <span class="s2">"FROM_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-205"><a href="#L-205"><span class="linenos">205</span></a> <span class="s2">"FROM_UNIXTIME"</span><span class="p">:</span> <span class="n">_from_unixtime</span><span class="p">,</span> +</span><span id="L-206"><a href="#L-206"><span class="linenos">206</span></a> <span class="s2">"FROM_UTF8"</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-207"><a href="#L-207"><span class="linenos">207</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">replace</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">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-208"><a href="#L-208"><span class="linenos">208</span></a> <span class="p">),</span> +</span><span id="L-209"><a href="#L-209"><span class="linenos">209</span></a> <span class="s2">"NOW"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> <span class="s2">"SEQUENCE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-211"><a href="#L-211"><span class="linenos">211</span></a> <span class="s2">"STRPOS"</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">StrPosition</span><span class="p">(</span> +</span><span id="L-212"><a href="#L-212"><span class="linenos">212</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">substr</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">instance</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-213"><a href="#L-213"><span class="linenos">213</span></a> <span class="p">),</span> +</span><span id="L-214"><a href="#L-214"><span class="linenos">214</span></a> <span class="s2">"TO_UNIXTIME"</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-215"><a href="#L-215"><span class="linenos">215</span></a> <span class="s2">"TO_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-216"><a href="#L-216"><span class="linenos">216</span></a> <span class="s2">"TO_UTF8"</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-217"><a href="#L-217"><span class="linenos">217</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-218"><a href="#L-218"><span class="linenos">218</span></a> <span class="p">),</span> +</span><span id="L-219"><a href="#L-219"><span class="linenos">219</span></a> <span class="p">}</span> +</span><span id="L-220"><a href="#L-220"><span class="linenos">220</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-221"><a href="#L-221"><span class="linenos">221</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> +</span><span id="L-222"><a href="#L-222"><span class="linenos">222</span></a> +</span><span id="L-223"><a href="#L-223"><span class="linenos">223</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-224"><a href="#L-224"><span class="linenos">224</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-225"><a href="#L-225"><span class="linenos">225</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-226"><a href="#L-226"><span class="linenos">226</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-227"><a href="#L-227"><span class="linenos">227</span></a> <span class="n">IS_BOOL_ALLOWED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-228"><a href="#L-228"><span class="linenos">228</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-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">PROPERTIES_LOCATION</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">generator</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="p">}</span> +</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> +</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-237"><a href="#L-237"><span class="linenos">237</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-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> +</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"VARBINARY"</span><span class="p">,</span> +</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TEXT</span><span class="p">:</span> <span class="s2">"VARCHAR"</span><span class="p">,</span> +</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">:</span> <span class="s2">"ROW"</span><span class="p">,</span> +</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <span class="p">}</span> +</span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> +</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> <span class="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-248"><a href="#L-248"><span class="linenos">248</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">_approx_distinct_sql</span><span class="p">,</span> +</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_PERCENTILE"</span><span class="p">),</span> +</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</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">"ARRAY[</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">e</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="p">,</span> +</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">),</span> +</span><span id="L-252"><a href="#L-252"><span class="linenos">252</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONTAINS"</span><span class="p">),</span> +</span><span id="L-253"><a href="#L-253"><span class="linenos">253</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">"CARDINALITY"</span><span class="p">),</span> +</span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</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">"BITWISE_AND(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</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">"BITWISE_ARITHMETIC_SHIFT_LEFT(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</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">"BITWISE_NOT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</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">"BITWISE_OR(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</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 class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</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">"BITWISE_ARITHMETIC_SHIFT_RIGHT(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</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">"BITWISE_XOR(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</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">epoch_cast_to_ts</span><span class="p">]),</span> +</span><span id="L-261"><a href="#L-261"><span class="linenos">261</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-262"><a href="#L-262"><span class="linenos">262</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-263"><a href="#L-263"><span class="linenos">263</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</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-264"><a href="#L-264"><span class="linenos">264</span></a> <span class="s2">"DATE_ADD"</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">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"day"</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-265"><a href="#L-265"><span class="linenos">265</span></a> <span class="p">),</span> +</span><span id="L-266"><a href="#L-266"><span class="linenos">266</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-267"><a href="#L-267"><span class="linenos">267</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">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"day"</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-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 class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</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(DATE_PARSE(</span><span 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">Presto</span><span class="o">.</span><span class="n">DATE_FORMAT</span><span class="si">}</span><span class="s2">) AS DATE)"</span><span class="p">,</span> +</span><span id="L-270"><a href="#L-270"><span class="linenos">270</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateToDi</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(DATE_FORMAT(</span><span 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">Presto</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-271"><a href="#L-271"><span class="linenos">271</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">:</span> <span class="n">_decode_sql</span><span class="p">,</span> +</span><span id="L-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DiToDate</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(DATE_PARSE(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 VARCHAR), </span><span class="si">{</span><span class="n">Presto</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-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">:</span> <span class="n">_encode_sql</span><span class="p">,</span> +</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</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">"FORMAT='</span><span class="si">{</span><span class="n">e</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="si">}</span><span class="s2">'"</span><span class="p">,</span> +</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Group</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">unalias_group</span><span class="p">]),</span> +</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">),</span> +</span><span id="L-277"><a href="#L-277"><span class="linenos">277</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">,</span> +</span><span id="L-278"><a href="#L-278"><span class="linenos">278</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> +</span><span id="L-279"><a href="#L-279"><span class="linenos">279</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Initcap</span><span class="p">:</span> <span class="n">_initcap_sql</span><span class="p">,</span> +</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">:</span> <span class="n">_explode_to_unnest_sql</span><span class="p">,</span> +</span><span id="L-281"><a href="#L-281"><span class="linenos">281</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">:</span> <span class="n">left_to_substring_sql</span><span class="p">,</span> +</span><span id="L-282"><a href="#L-282"><span class="linenos">282</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LEVENSHTEIN_DISTANCE"</span><span class="p">),</span> +</span><span id="L-283"><a href="#L-283"><span class="linenos">283</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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-284"><a href="#L-284"><span class="linenos">284</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-285"><a href="#L-285"><span class="linenos">285</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">no_pivot_sql</span><span class="p">,</span> +</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="p">:</span> <span class="n">_quantile_sql</span><span class="p">,</span> +</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Right</span><span class="p">:</span> <span class="n">right_to_substring_sql</span><span class="p">,</span> +</span><span id="L-288"><a href="#L-288"><span class="linenos">288</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDivide</span><span class="p">:</span> <span class="n">no_safe_divide_sql</span><span class="p">,</span> +</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">:</span> <span class="n">_schema_sql</span><span class="p">,</span> +</span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a> <span class="p">[</span> +</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">,</span> +</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> +</span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">explode_to_unnest</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="p">),</span> +</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="p">:</span> <span class="n">_no_sort_array</span><span class="p">,</span> +</span><span id="L-298"><a href="#L-298"><span class="linenos">298</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRPOS"</span><span class="p">),</span> +</span><span id="L-299"><a href="#L-299"><span class="linenos">299</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</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(</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">e</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span><span class="p">,</span> +</span><span id="L-300"><a href="#L-300"><span class="linenos">300</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_time_sql</span><span class="p">,</span> +</span><span id="L-301"><a href="#L-301"><span class="linenos">301</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span 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="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 class="si">}</span><span class="s2">))"</span><span class="p">,</span> +</span><span id="L-302"><a href="#L-302"><span class="linenos">302</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">:</span> <span class="n">struct_extract_sql</span><span class="p">,</span> +</span><span id="L-303"><a href="#L-303"><span class="linenos">303</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Table</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">_unnest_sequence</span><span class="p">]),</span> +</span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">:</span> <span class="n">timestamptrunc_sql</span><span class="p">,</span> +</span><span id="L-305"><a href="#L-305"><span class="linenos">305</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> +</span><span id="L-306"><a href="#L-306"><span class="linenos">306</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> +</span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span 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">Presto</span><span class="o">.</span><span class="n">TIME_FORMAT</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> +</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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="sa">f</span><span class="s2">"DATE_FORMAT(</span><span 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="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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_UNIXTIME"</span><span class="p">),</span> +</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</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">epoch_cast_to_ts</span><span class="p">]),</span> +</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDiToDi</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(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 VARCHAR), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> +</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> +</span><span id="L-313"><a href="#L-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">_ts_or_ds_to_date_sql</span><span class="p">,</span> +</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_HEX"</span><span class="p">),</span> +</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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="sa">f</span><span class="s2">"DATE_FORMAT(FROM_UNIXTIME(</span><span 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="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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_UNIXTIME"</span><span class="p">),</span> +</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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(FROM_UNIXTIME(</span><span 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 VARCHAR)"</span><span class="p">,</span> +</span><span id="L-318"><a href="#L-318"><span class="linenos">318</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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-319"><a href="#L-319"><span class="linenos">319</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</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">add_recursive_cte_column_names</span><span class="p">]),</span> +</span><span id="L-320"><a href="#L-320"><span class="linenos">320</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</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 class="n">transforms</span><span class="o">.</span><span class="n">remove_within_group_for_percentiles</span><span class="p">]</span> +</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a> <span class="p">),</span> +</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <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="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-326"><a href="#L-326"><span class="linenos">326</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> +</span><span id="L-327"><a href="#L-327"><span class="linenos">327</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">()</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-328"><a href="#L-328"><span class="linenos">328</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> * INTERVAL '7' day)"</span> +</span><span id="L-329"><a href="#L-329"><span class="linenos">329</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-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="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modes"</span><span class="p">)</span> +</span><span id="L-333"><a href="#L-333"><span class="linenos">333</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">modes</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modes</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-334"><a href="#L-334"><span class="linenos">334</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"START TRANSACTION</span><span class="si">{</span><span class="n">modes</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a> +</span><span id="L-336"><a href="#L-336"><span class="linenos">336</span></a> <span class="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-337"><a href="#L-337"><span class="linenos">337</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"start"</span><span class="p">]</span> +</span><span id="L-338"><a href="#L-338"><span class="linenos">338</span></a> <span class="n">end</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">"end"</span><span class="p">]</span> +</span><span id="L-339"><a href="#L-339"><span class="linenos">339</span></a> <span class="n">step</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"step"</span><span class="p">)</span> +</span><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a> +</span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span> +</span><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="L-344"><a href="#L-344"><span class="linenos">344</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">end</span><span class="o">.</span><span class="n">to</span> +</span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> +</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">and</span> <span class="n">target_type</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"timestamp"</span><span class="p">):</span> +</span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> <span class="n">to</span> <span class="o">=</span> <span class="n">target_type</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> +</span><span id="L-351"><a href="#L-351"><span class="linenos">351</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">is</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span><span class="p">:</span> +</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a> <span class="n">end</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">end</span><span class="p">,</span> <span class="n">to</span><span class="p">)</span> +</span><span id="L-353"><a href="#L-353"><span class="linenos">353</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-354"><a href="#L-354"><span class="linenos">354</span></a> <span class="n">start</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">start</span><span class="p">,</span> <span class="n">to</span><span class="p">)</span> +</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a> +</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"SEQUENCE"</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span> +</span><span id="L-357"><a href="#L-357"><span class="linenos">357</span></a> +</span><span id="L-358"><a href="#L-358"><span class="linenos">358</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> +</span><span id="L-359"><a href="#L-359"><span class="linenos">359</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> +</span><span id="L-360"><a href="#L-360"><span class="linenos">360</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> +</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> +</span><span id="L-364"><a href="#L-364"><span class="linenos">364</span></a> <span class="p">]</span> </span></pre></div> @@ -472,198 +471,203 @@ </div> <a class="headerlink" href="#Presto"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Presto-178"><a href="#Presto-178"><span class="linenos">178</span></a><span class="k">class</span> <span class="nc">Presto</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> -</span><span id="Presto-179"><a href="#Presto-179"><span class="linenos">179</span></a> <span class="n">INDEX_OFFSET</span> <span class="o">=</span> <span class="mi">1</span> -</span><span id="Presto-180"><a href="#Presto-180"><span class="linenos">180</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_last"</span> -</span><span id="Presto-181"><a href="#Presto-181"><span class="linenos">181</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="n">MySQL</span><span class="o">.</span><span class="n">TIME_FORMAT</span> -</span><span id="Presto-182"><a href="#Presto-182"><span class="linenos">182</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="n">MySQL</span><span class="o">.</span><span class="n">TIME_MAPPING</span> -</span><span id="Presto-183"><a href="#Presto-183"><span class="linenos">183</span></a> <span class="n">STRICT_STRING_CONCAT</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Presto-184"><a href="#Presto-184"><span class="linenos">184</span></a> -</span><span id="Presto-185"><a href="#Presto-185"><span class="linenos">185</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="Presto-186"><a href="#Presto-186"><span class="linenos">186</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Presto-187"><a href="#Presto-187"><span class="linenos">187</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="Presto-188"><a href="#Presto-188"><span class="linenos">188</span></a> <span class="s2">"START"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">,</span> -</span><span id="Presto-189"><a href="#Presto-189"><span class="linenos">189</span></a> <span class="s2">"MATCH_RECOGNIZE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MATCH_RECOGNIZE</span><span class="p">,</span> -</span><span id="Presto-190"><a href="#Presto-190"><span class="linenos">190</span></a> <span class="s2">"ROW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">,</span> -</span><span id="Presto-191"><a href="#Presto-191"><span class="linenos">191</span></a> <span class="p">}</span> -</span><span id="Presto-192"><a href="#Presto-192"><span class="linenos">192</span></a> -</span><span id="Presto-193"><a href="#Presto-193"><span class="linenos">193</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="Presto-194"><a href="#Presto-194"><span class="linenos">194</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Presto-195"><a href="#Presto-195"><span class="linenos">195</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="Presto-196"><a href="#Presto-196"><span class="linenos">196</span></a> <span class="s2">"APPROX_DISTINCT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto-197"><a href="#Presto-197"><span class="linenos">197</span></a> <span class="s2">"APPROX_PERCENTILE"</span><span class="p">:</span> <span class="n">_approx_percentile</span><span class="p">,</span> -</span><span id="Presto-198"><a href="#Presto-198"><span class="linenos">198</span></a> <span class="s2">"CARDINALITY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto-199"><a href="#Presto-199"><span class="linenos">199</span></a> <span class="s2">"CONTAINS"</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="Presto-200"><a href="#Presto-200"><span class="linenos">200</span></a> <span class="s2">"DATE_ADD"</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">DateAdd</span><span class="p">(</span> -</span><span id="Presto-201"><a href="#Presto-201"><span class="linenos">201</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">2</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">unit</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="Presto-202"><a href="#Presto-202"><span class="linenos">202</span></a> <span class="p">),</span> -</span><span id="Presto-203"><a href="#Presto-203"><span class="linenos">203</span></a> <span class="s2">"DATE_DIFF"</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">DateDiff</span><span class="p">(</span> -</span><span id="Presto-204"><a href="#Presto-204"><span class="linenos">204</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">2</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">unit</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="Presto-205"><a href="#Presto-205"><span class="linenos">205</span></a> <span class="p">),</span> -</span><span id="Presto-206"><a href="#Presto-206"><span class="linenos">206</span></a> <span class="s2">"DATE_FORMAT"</span><span class="p">:</span> <span class="n">format_time_lambda</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">"presto"</span><span class="p">),</span> -</span><span id="Presto-207"><a href="#Presto-207"><span class="linenos">207</span></a> <span class="s2">"DATE_PARSE"</span><span class="p">:</span> <span class="n">format_time_lambda</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">"presto"</span><span class="p">),</span> -</span><span id="Presto-208"><a href="#Presto-208"><span class="linenos">208</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="Presto-209"><a href="#Presto-209"><span class="linenos">209</span></a> <span class="s2">"FROM_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto-210"><a href="#Presto-210"><span class="linenos">210</span></a> <span class="s2">"FROM_UNIXTIME"</span><span class="p">:</span> <span class="n">_from_unixtime</span><span class="p">,</span> -</span><span id="Presto-211"><a href="#Presto-211"><span class="linenos">211</span></a> <span class="s2">"FROM_UTF8"</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="Presto-212"><a href="#Presto-212"><span class="linenos">212</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">replace</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">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="Presto-213"><a href="#Presto-213"><span class="linenos">213</span></a> <span class="p">),</span> -</span><span id="Presto-214"><a href="#Presto-214"><span class="linenos">214</span></a> <span class="s2">"NOW"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto-215"><a href="#Presto-215"><span class="linenos">215</span></a> <span class="s2">"SEQUENCE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto-216"><a href="#Presto-216"><span class="linenos">216</span></a> <span class="s2">"STRPOS"</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">StrPosition</span><span class="p">(</span> -</span><span id="Presto-217"><a href="#Presto-217"><span class="linenos">217</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">substr</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">instance</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="Presto-218"><a href="#Presto-218"><span class="linenos">218</span></a> <span class="p">),</span> -</span><span id="Presto-219"><a href="#Presto-219"><span class="linenos">219</span></a> <span class="s2">"TO_UNIXTIME"</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="Presto-220"><a href="#Presto-220"><span class="linenos">220</span></a> <span class="s2">"TO_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto-221"><a href="#Presto-221"><span class="linenos">221</span></a> <span class="s2">"TO_UTF8"</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="Presto-222"><a href="#Presto-222"><span class="linenos">222</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="Presto-223"><a href="#Presto-223"><span class="linenos">223</span></a> <span class="p">),</span> -</span><span id="Presto-224"><a href="#Presto-224"><span class="linenos">224</span></a> <span class="p">}</span> -</span><span id="Presto-225"><a href="#Presto-225"><span class="linenos">225</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="Presto-226"><a href="#Presto-226"><span class="linenos">226</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> -</span><span id="Presto-227"><a href="#Presto-227"><span class="linenos">227</span></a> -</span><span id="Presto-228"><a href="#Presto-228"><span class="linenos">228</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="Presto-229"><a href="#Presto-229"><span class="linenos">229</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto-230"><a href="#Presto-230"><span class="linenos">230</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto-231"><a href="#Presto-231"><span class="linenos">231</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto-232"><a href="#Presto-232"><span class="linenos">232</span></a> <span class="n">IS_BOOL_ALLOWED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto-233"><a href="#Presto-233"><span class="linenos">233</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="Presto-234"><a href="#Presto-234"><span class="linenos">234</span></a> -</span><span id="Presto-235"><a href="#Presto-235"><span class="linenos">235</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Presto-236"><a href="#Presto-236"><span class="linenos">236</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">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="Presto-237"><a href="#Presto-237"><span class="linenos">237</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="Presto-238"><a href="#Presto-238"><span class="linenos">238</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="Presto-239"><a href="#Presto-239"><span class="linenos">239</span></a> <span class="p">}</span> -</span><span id="Presto-240"><a href="#Presto-240"><span class="linenos">240</span></a> -</span><span id="Presto-241"><a href="#Presto-241"><span class="linenos">241</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Presto-242"><a href="#Presto-242"><span class="linenos">242</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="Presto-243"><a href="#Presto-243"><span class="linenos">243</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="Presto-244"><a href="#Presto-244"><span class="linenos">244</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> -</span><span id="Presto-245"><a href="#Presto-245"><span class="linenos">245</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">"VARBINARY"</span><span class="p">,</span> -</span><span id="Presto-246"><a href="#Presto-246"><span class="linenos">246</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="s2">"VARCHAR"</span><span class="p">,</span> -</span><span id="Presto-247"><a href="#Presto-247"><span class="linenos">247</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="Presto-248"><a href="#Presto-248"><span class="linenos">248</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">STRUCT</span><span class="p">:</span> <span class="s2">"ROW"</span><span class="p">,</span> -</span><span id="Presto-249"><a href="#Presto-249"><span class="linenos">249</span></a> <span class="p">}</span> -</span><span id="Presto-250"><a href="#Presto-250"><span class="linenos">250</span></a> -</span><span id="Presto-251"><a href="#Presto-251"><span class="linenos">251</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Presto-252"><a href="#Presto-252"><span class="linenos">252</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="Presto-253"><a href="#Presto-253"><span class="linenos">253</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">_approx_distinct_sql</span><span class="p">,</span> -</span><span id="Presto-254"><a href="#Presto-254"><span class="linenos">254</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_PERCENTILE"</span><span class="p">),</span> -</span><span id="Presto-255"><a href="#Presto-255"><span class="linenos">255</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</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">"ARRAY[</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">e</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="p">,</span> -</span><span id="Presto-256"><a href="#Presto-256"><span class="linenos">256</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">),</span> -</span><span id="Presto-257"><a href="#Presto-257"><span class="linenos">257</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONTAINS"</span><span class="p">),</span> -</span><span id="Presto-258"><a href="#Presto-258"><span class="linenos">258</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">"CARDINALITY"</span><span class="p">),</span> -</span><span id="Presto-259"><a href="#Presto-259"><span class="linenos">259</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</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">"BITWISE_AND(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto-260"><a href="#Presto-260"><span class="linenos">260</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</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">"BITWISE_ARITHMETIC_SHIFT_LEFT(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto-261"><a href="#Presto-261"><span class="linenos">261</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</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">"BITWISE_NOT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto-262"><a href="#Presto-262"><span class="linenos">262</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</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">"BITWISE_OR(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto-263"><a href="#Presto-263"><span class="linenos">263</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</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">"BITWISE_ARITHMETIC_SHIFT_RIGHT(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto-264"><a href="#Presto-264"><span class="linenos">264</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</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">"BITWISE_XOR(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto-265"><a href="#Presto-265"><span class="linenos">265</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</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">epoch_cast_to_ts</span><span class="p">]),</span> -</span><span id="Presto-266"><a href="#Presto-266"><span class="linenos">266</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="Presto-267"><a href="#Presto-267"><span class="linenos">267</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="Presto-268"><a href="#Presto-268"><span class="linenos">268</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</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="Presto-269"><a href="#Presto-269"><span class="linenos">269</span></a> <span class="s2">"DATE_ADD"</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">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"day"</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="Presto-270"><a href="#Presto-270"><span class="linenos">270</span></a> <span class="p">),</span> -</span><span id="Presto-271"><a href="#Presto-271"><span class="linenos">271</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="Presto-272"><a href="#Presto-272"><span class="linenos">272</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">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"day"</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="Presto-273"><a href="#Presto-273"><span class="linenos">273</span></a> <span class="p">),</span> -</span><span id="Presto-274"><a href="#Presto-274"><span class="linenos">274</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</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(DATE_PARSE(</span><span 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">Presto</span><span class="o">.</span><span class="n">DATE_FORMAT</span><span class="si">}</span><span class="s2">) AS DATE)"</span><span class="p">,</span> -</span><span id="Presto-275"><a href="#Presto-275"><span class="linenos">275</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 class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_FORMAT(</span><span 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">Presto</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="Presto-276"><a href="#Presto-276"><span class="linenos">276</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">:</span> <span class="n">_decode_sql</span><span class="p">,</span> -</span><span id="Presto-277"><a href="#Presto-277"><span class="linenos">277</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 class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_PARSE(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 VARCHAR), </span><span class="si">{</span><span class="n">Presto</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="Presto-278"><a href="#Presto-278"><span class="linenos">278</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">:</span> <span class="n">_encode_sql</span><span class="p">,</span> -</span><span id="Presto-279"><a href="#Presto-279"><span class="linenos">279</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</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">"FORMAT='</span><span class="si">{</span><span class="n">e</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="si">}</span><span class="s2">'"</span><span class="p">,</span> -</span><span id="Presto-280"><a href="#Presto-280"><span class="linenos">280</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Group</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">unalias_group</span><span class="p">]),</span> -</span><span id="Presto-281"><a href="#Presto-281"><span class="linenos">281</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">),</span> -</span><span id="Presto-282"><a href="#Presto-282"><span class="linenos">282</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">,</span> -</span><span id="Presto-283"><a href="#Presto-283"><span class="linenos">283</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> -</span><span id="Presto-284"><a href="#Presto-284"><span class="linenos">284</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Initcap</span><span class="p">:</span> <span class="n">_initcap_sql</span><span class="p">,</span> -</span><span id="Presto-285"><a href="#Presto-285"><span class="linenos">285</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">:</span> <span class="n">_explode_to_unnest_sql</span><span class="p">,</span> -</span><span id="Presto-286"><a href="#Presto-286"><span class="linenos">286</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">:</span> <span class="n">left_to_substring_sql</span><span class="p">,</span> -</span><span id="Presto-287"><a href="#Presto-287"><span class="linenos">287</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LEVENSHTEIN_DISTANCE"</span><span class="p">),</span> -</span><span id="Presto-288"><a href="#Presto-288"><span class="linenos">288</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="Presto-289"><a href="#Presto-289"><span class="linenos">289</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="Presto-290"><a href="#Presto-290"><span class="linenos">290</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">no_pivot_sql</span><span class="p">,</span> -</span><span id="Presto-291"><a href="#Presto-291"><span class="linenos">291</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="p">:</span> <span class="n">_quantile_sql</span><span class="p">,</span> -</span><span id="Presto-292"><a href="#Presto-292"><span class="linenos">292</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Right</span><span class="p">:</span> <span class="n">right_to_substring_sql</span><span class="p">,</span> -</span><span id="Presto-293"><a href="#Presto-293"><span class="linenos">293</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="Presto-294"><a href="#Presto-294"><span class="linenos">294</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">:</span> <span class="n">_schema_sql</span><span class="p">,</span> -</span><span id="Presto-295"><a href="#Presto-295"><span class="linenos">295</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="Presto-296"><a href="#Presto-296"><span class="linenos">296</span></a> <span class="p">[</span> -</span><span id="Presto-297"><a href="#Presto-297"><span class="linenos">297</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">,</span> -</span><span id="Presto-298"><a href="#Presto-298"><span class="linenos">298</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> -</span><span id="Presto-299"><a href="#Presto-299"><span class="linenos">299</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">explode_to_unnest</span><span class="p">,</span> -</span><span id="Presto-300"><a href="#Presto-300"><span class="linenos">300</span></a> <span class="p">]</span> -</span><span id="Presto-301"><a href="#Presto-301"><span class="linenos">301</span></a> <span class="p">),</span> -</span><span id="Presto-302"><a href="#Presto-302"><span class="linenos">302</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="p">:</span> <span class="n">_no_sort_array</span><span class="p">,</span> -</span><span id="Presto-303"><a href="#Presto-303"><span class="linenos">303</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRPOS"</span><span class="p">),</span> -</span><span id="Presto-304"><a href="#Presto-304"><span class="linenos">304</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</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(</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">e</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span><span class="p">,</span> -</span><span id="Presto-305"><a href="#Presto-305"><span class="linenos">305</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_time_sql</span><span class="p">,</span> -</span><span id="Presto-306"><a href="#Presto-306"><span class="linenos">306</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="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span 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="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 class="si">}</span><span class="s2">))"</span><span class="p">,</span> -</span><span id="Presto-307"><a href="#Presto-307"><span class="linenos">307</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">:</span> <span class="n">struct_extract_sql</span><span class="p">,</span> -</span><span id="Presto-308"><a href="#Presto-308"><span class="linenos">308</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Table</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">_unnest_sequence</span><span class="p">]),</span> -</span><span id="Presto-309"><a href="#Presto-309"><span class="linenos">309</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="Presto-310"><a href="#Presto-310"><span class="linenos">310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> -</span><span id="Presto-311"><a href="#Presto-311"><span class="linenos">311</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="Presto-312"><a href="#Presto-312"><span class="linenos">312</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="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span 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">Presto</span><span class="o">.</span><span class="n">TIME_FORMAT</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> -</span><span id="Presto-313"><a href="#Presto-313"><span class="linenos">313</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="sa">f</span><span class="s2">"DATE_FORMAT(</span><span 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="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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto-314"><a href="#Presto-314"><span class="linenos">314</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">"TO_UNIXTIME"</span><span class="p">),</span> -</span><span id="Presto-315"><a href="#Presto-315"><span class="linenos">315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</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">epoch_cast_to_ts</span><span class="p">]),</span> -</span><span id="Presto-316"><a href="#Presto-316"><span class="linenos">316</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 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 VARCHAR), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> -</span><span id="Presto-317"><a href="#Presto-317"><span class="linenos">317</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> -</span><span id="Presto-318"><a href="#Presto-318"><span class="linenos">318</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">_ts_or_ds_to_date_sql</span><span class="p">,</span> -</span><span id="Presto-319"><a href="#Presto-319"><span class="linenos">319</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_HEX"</span><span class="p">),</span> -</span><span id="Presto-320"><a href="#Presto-320"><span class="linenos">320</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="sa">f</span><span class="s2">"DATE_FORMAT(FROM_UNIXTIME(</span><span 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="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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto-321"><a href="#Presto-321"><span class="linenos">321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_UNIXTIME"</span><span class="p">),</span> -</span><span id="Presto-322"><a href="#Presto-322"><span class="linenos">322</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(FROM_UNIXTIME(</span><span 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 VARCHAR)"</span><span class="p">,</span> -</span><span id="Presto-323"><a href="#Presto-323"><span class="linenos">323</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="Presto-324"><a href="#Presto-324"><span class="linenos">324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</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">add_recursive_cte_column_names</span><span class="p">]),</span> -</span><span id="Presto-325"><a href="#Presto-325"><span class="linenos">325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="Presto-326"><a href="#Presto-326"><span class="linenos">326</span></a> <span class="p">[</span><span class="n">transforms</span><span class="o">.</span><span class="n">remove_within_group_for_percentiles</span><span class="p">]</span> -</span><span id="Presto-327"><a href="#Presto-327"><span class="linenos">327</span></a> <span class="p">),</span> -</span><span id="Presto-328"><a href="#Presto-328"><span class="linenos">328</span></a> <span class="p">}</span> -</span><span id="Presto-329"><a href="#Presto-329"><span class="linenos">329</span></a> -</span><span id="Presto-330"><a href="#Presto-330"><span class="linenos">330</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="Presto-331"><a href="#Presto-331"><span class="linenos">331</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> -</span><span id="Presto-332"><a href="#Presto-332"><span class="linenos">332</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">()</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="Presto-333"><a href="#Presto-333"><span class="linenos">333</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> * INTERVAL '7' day)"</span> -</span><span id="Presto-334"><a href="#Presto-334"><span class="linenos">334</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="Presto-335"><a href="#Presto-335"><span class="linenos">335</span></a> -</span><span id="Presto-336"><a href="#Presto-336"><span class="linenos">336</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Presto-337"><a href="#Presto-337"><span class="linenos">337</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modes"</span><span class="p">)</span> -</span><span id="Presto-338"><a href="#Presto-338"><span class="linenos">338</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">modes</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modes</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Presto-339"><a href="#Presto-339"><span class="linenos">339</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"START TRANSACTION</span><span class="si">{</span><span class="n">modes</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Presto-340"><a href="#Presto-340"><span class="linenos">340</span></a> -</span><span id="Presto-341"><a href="#Presto-341"><span class="linenos">341</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="Presto-342"><a href="#Presto-342"><span class="linenos">342</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"start"</span><span class="p">]</span> -</span><span id="Presto-343"><a href="#Presto-343"><span class="linenos">343</span></a> <span class="n">end</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">"end"</span><span class="p">]</span> -</span><span id="Presto-344"><a href="#Presto-344"><span class="linenos">344</span></a> <span class="n">step</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"step"</span><span class="p">)</span> -</span><span id="Presto-345"><a href="#Presto-345"><span class="linenos">345</span></a> -</span><span id="Presto-346"><a href="#Presto-346"><span class="linenos">346</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="Presto-347"><a href="#Presto-347"><span class="linenos">347</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span> -</span><span id="Presto-348"><a href="#Presto-348"><span class="linenos">348</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="Presto-349"><a href="#Presto-349"><span class="linenos">349</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">end</span><span class="o">.</span><span class="n">to</span> -</span><span id="Presto-350"><a href="#Presto-350"><span class="linenos">350</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Presto-351"><a href="#Presto-351"><span class="linenos">351</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Presto-352"><a href="#Presto-352"><span class="linenos">352</span></a> -</span><span id="Presto-353"><a href="#Presto-353"><span class="linenos">353</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">and</span> <span class="n">target_type</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"timestamp"</span><span class="p">):</span> -</span><span id="Presto-354"><a href="#Presto-354"><span class="linenos">354</span></a> <span class="n">to</span> <span class="o">=</span> <span class="n">target_type</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Presto-355"><a href="#Presto-355"><span class="linenos">355</span></a> -</span><span id="Presto-356"><a href="#Presto-356"><span class="linenos">356</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">is</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span><span class="p">:</span> -</span><span id="Presto-357"><a href="#Presto-357"><span class="linenos">357</span></a> <span class="n">end</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">end</span><span class="p">,</span> <span class="n">to</span><span class="p">)</span> -</span><span id="Presto-358"><a href="#Presto-358"><span class="linenos">358</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Presto-359"><a href="#Presto-359"><span class="linenos">359</span></a> <span class="n">start</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">start</span><span class="p">,</span> <span class="n">to</span><span class="p">)</span> -</span><span id="Presto-360"><a href="#Presto-360"><span class="linenos">360</span></a> -</span><span id="Presto-361"><a href="#Presto-361"><span class="linenos">361</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">"SEQUENCE"</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span> -</span><span id="Presto-362"><a href="#Presto-362"><span class="linenos">362</span></a> -</span><span id="Presto-363"><a href="#Presto-363"><span class="linenos">363</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> -</span><span id="Presto-364"><a href="#Presto-364"><span class="linenos">364</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> -</span><span id="Presto-365"><a href="#Presto-365"><span class="linenos">365</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Presto-366"><a href="#Presto-366"><span class="linenos">366</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="Presto-367"><a href="#Presto-367"><span class="linenos">367</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> -</span><span id="Presto-368"><a href="#Presto-368"><span class="linenos">368</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> -</span><span id="Presto-369"><a href="#Presto-369"><span class="linenos">369</span></a> <span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Presto-169"><a href="#Presto-169"><span class="linenos">169</span></a><span class="k">class</span> <span class="nc">Presto</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> +</span><span id="Presto-170"><a href="#Presto-170"><span class="linenos">170</span></a> <span class="n">INDEX_OFFSET</span> <span class="o">=</span> <span class="mi">1</span> +</span><span id="Presto-171"><a href="#Presto-171"><span class="linenos">171</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_last"</span> +</span><span id="Presto-172"><a href="#Presto-172"><span class="linenos">172</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="n">MySQL</span><span class="o">.</span><span class="n">TIME_FORMAT</span> +</span><span id="Presto-173"><a href="#Presto-173"><span class="linenos">173</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="n">MySQL</span><span class="o">.</span><span class="n">TIME_MAPPING</span> +</span><span id="Presto-174"><a href="#Presto-174"><span class="linenos">174</span></a> <span class="n">STRICT_STRING_CONCAT</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Presto-175"><a href="#Presto-175"><span class="linenos">175</span></a> +</span><span id="Presto-176"><a href="#Presto-176"><span class="linenos">176</span></a> <span class="c1"># https://github.com/trinodb/trino/issues/17</span> +</span><span id="Presto-177"><a href="#Presto-177"><span class="linenos">177</span></a> <span class="c1"># https://github.com/trinodb/trino/issues/12289</span> +</span><span id="Presto-178"><a href="#Presto-178"><span class="linenos">178</span></a> <span class="c1"># https://github.com/prestodb/presto/issues/2863</span> +</span><span id="Presto-179"><a href="#Presto-179"><span class="linenos">179</span></a> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Presto-180"><a href="#Presto-180"><span class="linenos">180</span></a> +</span><span id="Presto-181"><a href="#Presto-181"><span class="linenos">181</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="Presto-182"><a href="#Presto-182"><span class="linenos">182</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Presto-183"><a href="#Presto-183"><span class="linenos">183</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="Presto-184"><a href="#Presto-184"><span class="linenos">184</span></a> <span class="s2">"START"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">,</span> +</span><span id="Presto-185"><a href="#Presto-185"><span class="linenos">185</span></a> <span class="s2">"MATCH_RECOGNIZE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MATCH_RECOGNIZE</span><span class="p">,</span> +</span><span id="Presto-186"><a href="#Presto-186"><span class="linenos">186</span></a> <span class="s2">"ROW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">,</span> +</span><span id="Presto-187"><a href="#Presto-187"><span class="linenos">187</span></a> <span class="p">}</span> +</span><span id="Presto-188"><a href="#Presto-188"><span class="linenos">188</span></a> +</span><span id="Presto-189"><a href="#Presto-189"><span class="linenos">189</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="Presto-190"><a href="#Presto-190"><span class="linenos">190</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Presto-191"><a href="#Presto-191"><span class="linenos">191</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="Presto-192"><a href="#Presto-192"><span class="linenos">192</span></a> <span class="s2">"APPROX_DISTINCT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto-193"><a href="#Presto-193"><span class="linenos">193</span></a> <span class="s2">"APPROX_PERCENTILE"</span><span class="p">:</span> <span class="n">_approx_percentile</span><span class="p">,</span> +</span><span id="Presto-194"><a href="#Presto-194"><span class="linenos">194</span></a> <span class="s2">"CARDINALITY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto-195"><a href="#Presto-195"><span class="linenos">195</span></a> <span class="s2">"CONTAINS"</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="Presto-196"><a href="#Presto-196"><span class="linenos">196</span></a> <span class="s2">"DATE_ADD"</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">DateAdd</span><span class="p">(</span> +</span><span id="Presto-197"><a href="#Presto-197"><span class="linenos">197</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">2</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">unit</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="Presto-198"><a href="#Presto-198"><span class="linenos">198</span></a> <span class="p">),</span> +</span><span id="Presto-199"><a href="#Presto-199"><span class="linenos">199</span></a> <span class="s2">"DATE_DIFF"</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">DateDiff</span><span class="p">(</span> +</span><span id="Presto-200"><a href="#Presto-200"><span class="linenos">200</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">2</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">unit</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="Presto-201"><a href="#Presto-201"><span class="linenos">201</span></a> <span class="p">),</span> +</span><span id="Presto-202"><a href="#Presto-202"><span class="linenos">202</span></a> <span class="s2">"DATE_FORMAT"</span><span class="p">:</span> <span class="n">format_time_lambda</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">"presto"</span><span class="p">),</span> +</span><span id="Presto-203"><a href="#Presto-203"><span class="linenos">203</span></a> <span class="s2">"DATE_PARSE"</span><span class="p">:</span> <span class="n">format_time_lambda</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">"presto"</span><span class="p">),</span> +</span><span id="Presto-204"><a href="#Presto-204"><span class="linenos">204</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="Presto-205"><a href="#Presto-205"><span class="linenos">205</span></a> <span class="s2">"FROM_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto-206"><a href="#Presto-206"><span class="linenos">206</span></a> <span class="s2">"FROM_UNIXTIME"</span><span class="p">:</span> <span class="n">_from_unixtime</span><span class="p">,</span> +</span><span id="Presto-207"><a href="#Presto-207"><span class="linenos">207</span></a> <span class="s2">"FROM_UTF8"</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="Presto-208"><a href="#Presto-208"><span class="linenos">208</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">replace</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">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="Presto-209"><a href="#Presto-209"><span class="linenos">209</span></a> <span class="p">),</span> +</span><span id="Presto-210"><a href="#Presto-210"><span class="linenos">210</span></a> <span class="s2">"NOW"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto-211"><a href="#Presto-211"><span class="linenos">211</span></a> <span class="s2">"SEQUENCE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto-212"><a href="#Presto-212"><span class="linenos">212</span></a> <span class="s2">"STRPOS"</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">StrPosition</span><span class="p">(</span> +</span><span id="Presto-213"><a href="#Presto-213"><span class="linenos">213</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">substr</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">instance</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="Presto-214"><a href="#Presto-214"><span class="linenos">214</span></a> <span class="p">),</span> +</span><span id="Presto-215"><a href="#Presto-215"><span class="linenos">215</span></a> <span class="s2">"TO_UNIXTIME"</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="Presto-216"><a href="#Presto-216"><span class="linenos">216</span></a> <span class="s2">"TO_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto-217"><a href="#Presto-217"><span class="linenos">217</span></a> <span class="s2">"TO_UTF8"</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="Presto-218"><a href="#Presto-218"><span class="linenos">218</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="Presto-219"><a href="#Presto-219"><span class="linenos">219</span></a> <span class="p">),</span> +</span><span id="Presto-220"><a href="#Presto-220"><span class="linenos">220</span></a> <span class="p">}</span> +</span><span id="Presto-221"><a href="#Presto-221"><span class="linenos">221</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="Presto-222"><a href="#Presto-222"><span class="linenos">222</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> +</span><span id="Presto-223"><a href="#Presto-223"><span class="linenos">223</span></a> +</span><span id="Presto-224"><a href="#Presto-224"><span class="linenos">224</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="Presto-225"><a href="#Presto-225"><span class="linenos">225</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto-226"><a href="#Presto-226"><span class="linenos">226</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto-227"><a href="#Presto-227"><span class="linenos">227</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto-228"><a href="#Presto-228"><span class="linenos">228</span></a> <span class="n">IS_BOOL_ALLOWED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto-229"><a href="#Presto-229"><span class="linenos">229</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="Presto-230"><a href="#Presto-230"><span class="linenos">230</span></a> +</span><span id="Presto-231"><a href="#Presto-231"><span class="linenos">231</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Presto-232"><a href="#Presto-232"><span class="linenos">232</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">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="Presto-233"><a href="#Presto-233"><span class="linenos">233</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="Presto-234"><a href="#Presto-234"><span class="linenos">234</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="Presto-235"><a href="#Presto-235"><span class="linenos">235</span></a> <span class="p">}</span> +</span><span id="Presto-236"><a href="#Presto-236"><span class="linenos">236</span></a> +</span><span id="Presto-237"><a href="#Presto-237"><span class="linenos">237</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Presto-238"><a href="#Presto-238"><span class="linenos">238</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="Presto-239"><a href="#Presto-239"><span class="linenos">239</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="Presto-240"><a href="#Presto-240"><span class="linenos">240</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> +</span><span id="Presto-241"><a href="#Presto-241"><span class="linenos">241</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"VARBINARY"</span><span class="p">,</span> +</span><span id="Presto-242"><a href="#Presto-242"><span class="linenos">242</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TEXT</span><span class="p">:</span> <span class="s2">"VARCHAR"</span><span class="p">,</span> +</span><span id="Presto-243"><a href="#Presto-243"><span class="linenos">243</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="Presto-244"><a href="#Presto-244"><span class="linenos">244</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">:</span> <span class="s2">"ROW"</span><span class="p">,</span> +</span><span id="Presto-245"><a href="#Presto-245"><span class="linenos">245</span></a> <span class="p">}</span> +</span><span id="Presto-246"><a href="#Presto-246"><span class="linenos">246</span></a> +</span><span id="Presto-247"><a href="#Presto-247"><span class="linenos">247</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Presto-248"><a href="#Presto-248"><span class="linenos">248</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="Presto-249"><a href="#Presto-249"><span class="linenos">249</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">_approx_distinct_sql</span><span class="p">,</span> +</span><span id="Presto-250"><a href="#Presto-250"><span class="linenos">250</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_PERCENTILE"</span><span class="p">),</span> +</span><span id="Presto-251"><a href="#Presto-251"><span class="linenos">251</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</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">"ARRAY[</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">e</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="p">,</span> +</span><span id="Presto-252"><a href="#Presto-252"><span class="linenos">252</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">),</span> +</span><span id="Presto-253"><a href="#Presto-253"><span class="linenos">253</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONTAINS"</span><span class="p">),</span> +</span><span id="Presto-254"><a href="#Presto-254"><span class="linenos">254</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">"CARDINALITY"</span><span class="p">),</span> +</span><span id="Presto-255"><a href="#Presto-255"><span class="linenos">255</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</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">"BITWISE_AND(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto-256"><a href="#Presto-256"><span class="linenos">256</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</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">"BITWISE_ARITHMETIC_SHIFT_LEFT(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto-257"><a href="#Presto-257"><span class="linenos">257</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</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">"BITWISE_NOT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto-258"><a href="#Presto-258"><span class="linenos">258</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</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">"BITWISE_OR(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto-259"><a href="#Presto-259"><span class="linenos">259</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</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">"BITWISE_ARITHMETIC_SHIFT_RIGHT(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto-260"><a href="#Presto-260"><span class="linenos">260</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</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">"BITWISE_XOR(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto-261"><a href="#Presto-261"><span class="linenos">261</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</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">epoch_cast_to_ts</span><span class="p">]),</span> +</span><span id="Presto-262"><a href="#Presto-262"><span class="linenos">262</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="Presto-263"><a href="#Presto-263"><span class="linenos">263</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="Presto-264"><a href="#Presto-264"><span class="linenos">264</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</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="Presto-265"><a href="#Presto-265"><span class="linenos">265</span></a> <span class="s2">"DATE_ADD"</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">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"day"</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="Presto-266"><a href="#Presto-266"><span class="linenos">266</span></a> <span class="p">),</span> +</span><span id="Presto-267"><a href="#Presto-267"><span class="linenos">267</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="Presto-268"><a href="#Presto-268"><span class="linenos">268</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">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"day"</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="Presto-269"><a href="#Presto-269"><span class="linenos">269</span></a> <span class="p">),</span> +</span><span id="Presto-270"><a href="#Presto-270"><span class="linenos">270</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</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(DATE_PARSE(</span><span 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">Presto</span><span class="o">.</span><span class="n">DATE_FORMAT</span><span class="si">}</span><span class="s2">) AS DATE)"</span><span class="p">,</span> +</span><span id="Presto-271"><a href="#Presto-271"><span class="linenos">271</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 class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_FORMAT(</span><span 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">Presto</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="Presto-272"><a href="#Presto-272"><span class="linenos">272</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">:</span> <span class="n">_decode_sql</span><span class="p">,</span> +</span><span id="Presto-273"><a href="#Presto-273"><span class="linenos">273</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 class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_PARSE(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 VARCHAR), </span><span class="si">{</span><span class="n">Presto</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="Presto-274"><a href="#Presto-274"><span class="linenos">274</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">:</span> <span class="n">_encode_sql</span><span class="p">,</span> +</span><span id="Presto-275"><a href="#Presto-275"><span class="linenos">275</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</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">"FORMAT='</span><span class="si">{</span><span class="n">e</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="si">}</span><span class="s2">'"</span><span class="p">,</span> +</span><span id="Presto-276"><a href="#Presto-276"><span class="linenos">276</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Group</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">unalias_group</span><span class="p">]),</span> +</span><span id="Presto-277"><a href="#Presto-277"><span class="linenos">277</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">),</span> +</span><span id="Presto-278"><a href="#Presto-278"><span class="linenos">278</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">,</span> +</span><span id="Presto-279"><a href="#Presto-279"><span class="linenos">279</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> +</span><span id="Presto-280"><a href="#Presto-280"><span class="linenos">280</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Initcap</span><span class="p">:</span> <span class="n">_initcap_sql</span><span class="p">,</span> +</span><span id="Presto-281"><a href="#Presto-281"><span class="linenos">281</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">:</span> <span class="n">_explode_to_unnest_sql</span><span class="p">,</span> +</span><span id="Presto-282"><a href="#Presto-282"><span class="linenos">282</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">:</span> <span class="n">left_to_substring_sql</span><span class="p">,</span> +</span><span id="Presto-283"><a href="#Presto-283"><span class="linenos">283</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LEVENSHTEIN_DISTANCE"</span><span class="p">),</span> +</span><span id="Presto-284"><a href="#Presto-284"><span class="linenos">284</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="Presto-285"><a href="#Presto-285"><span class="linenos">285</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="Presto-286"><a href="#Presto-286"><span class="linenos">286</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">no_pivot_sql</span><span class="p">,</span> +</span><span id="Presto-287"><a href="#Presto-287"><span class="linenos">287</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="p">:</span> <span class="n">_quantile_sql</span><span class="p">,</span> +</span><span id="Presto-288"><a href="#Presto-288"><span class="linenos">288</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Right</span><span class="p">:</span> <span class="n">right_to_substring_sql</span><span class="p">,</span> +</span><span id="Presto-289"><a href="#Presto-289"><span class="linenos">289</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="Presto-290"><a href="#Presto-290"><span class="linenos">290</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">:</span> <span class="n">_schema_sql</span><span class="p">,</span> +</span><span id="Presto-291"><a href="#Presto-291"><span class="linenos">291</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="Presto-292"><a href="#Presto-292"><span class="linenos">292</span></a> <span class="p">[</span> +</span><span id="Presto-293"><a href="#Presto-293"><span class="linenos">293</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">,</span> +</span><span id="Presto-294"><a href="#Presto-294"><span class="linenos">294</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> +</span><span id="Presto-295"><a href="#Presto-295"><span class="linenos">295</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">explode_to_unnest</span><span class="p">,</span> +</span><span id="Presto-296"><a href="#Presto-296"><span class="linenos">296</span></a> <span class="p">]</span> +</span><span id="Presto-297"><a href="#Presto-297"><span class="linenos">297</span></a> <span class="p">),</span> +</span><span id="Presto-298"><a href="#Presto-298"><span class="linenos">298</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="p">:</span> <span class="n">_no_sort_array</span><span class="p">,</span> +</span><span id="Presto-299"><a href="#Presto-299"><span class="linenos">299</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRPOS"</span><span class="p">),</span> +</span><span id="Presto-300"><a href="#Presto-300"><span class="linenos">300</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</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(</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">e</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span><span class="p">,</span> +</span><span id="Presto-301"><a href="#Presto-301"><span class="linenos">301</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_time_sql</span><span class="p">,</span> +</span><span id="Presto-302"><a href="#Presto-302"><span class="linenos">302</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="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span 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="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 class="si">}</span><span class="s2">))"</span><span class="p">,</span> +</span><span id="Presto-303"><a href="#Presto-303"><span class="linenos">303</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">:</span> <span class="n">struct_extract_sql</span><span class="p">,</span> +</span><span id="Presto-304"><a href="#Presto-304"><span class="linenos">304</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Table</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">_unnest_sequence</span><span class="p">]),</span> +</span><span id="Presto-305"><a href="#Presto-305"><span class="linenos">305</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="Presto-306"><a href="#Presto-306"><span class="linenos">306</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> +</span><span id="Presto-307"><a href="#Presto-307"><span class="linenos">307</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="Presto-308"><a href="#Presto-308"><span class="linenos">308</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="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span 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">Presto</span><span class="o">.</span><span class="n">TIME_FORMAT</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> +</span><span id="Presto-309"><a href="#Presto-309"><span class="linenos">309</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="sa">f</span><span class="s2">"DATE_FORMAT(</span><span 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="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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto-310"><a href="#Presto-310"><span class="linenos">310</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">"TO_UNIXTIME"</span><span class="p">),</span> +</span><span id="Presto-311"><a href="#Presto-311"><span class="linenos">311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</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">epoch_cast_to_ts</span><span class="p">]),</span> +</span><span id="Presto-312"><a href="#Presto-312"><span class="linenos">312</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 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 VARCHAR), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> +</span><span id="Presto-313"><a href="#Presto-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> +</span><span id="Presto-314"><a href="#Presto-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">_ts_or_ds_to_date_sql</span><span class="p">,</span> +</span><span id="Presto-315"><a href="#Presto-315"><span class="linenos">315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_HEX"</span><span class="p">),</span> +</span><span id="Presto-316"><a href="#Presto-316"><span class="linenos">316</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="sa">f</span><span class="s2">"DATE_FORMAT(FROM_UNIXTIME(</span><span 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="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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto-317"><a href="#Presto-317"><span class="linenos">317</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_UNIXTIME"</span><span class="p">),</span> +</span><span id="Presto-318"><a href="#Presto-318"><span class="linenos">318</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(FROM_UNIXTIME(</span><span 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 VARCHAR)"</span><span class="p">,</span> +</span><span id="Presto-319"><a href="#Presto-319"><span class="linenos">319</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="Presto-320"><a href="#Presto-320"><span class="linenos">320</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</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">add_recursive_cte_column_names</span><span class="p">]),</span> +</span><span id="Presto-321"><a href="#Presto-321"><span class="linenos">321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="Presto-322"><a href="#Presto-322"><span class="linenos">322</span></a> <span class="p">[</span><span class="n">transforms</span><span class="o">.</span><span class="n">remove_within_group_for_percentiles</span><span class="p">]</span> +</span><span id="Presto-323"><a href="#Presto-323"><span class="linenos">323</span></a> <span class="p">),</span> +</span><span id="Presto-324"><a href="#Presto-324"><span class="linenos">324</span></a> <span class="p">}</span> +</span><span id="Presto-325"><a href="#Presto-325"><span class="linenos">325</span></a> +</span><span id="Presto-326"><a href="#Presto-326"><span class="linenos">326</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="Presto-327"><a href="#Presto-327"><span class="linenos">327</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> +</span><span id="Presto-328"><a href="#Presto-328"><span class="linenos">328</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">()</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="Presto-329"><a href="#Presto-329"><span class="linenos">329</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> * INTERVAL '7' day)"</span> +</span><span id="Presto-330"><a href="#Presto-330"><span class="linenos">330</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="Presto-331"><a href="#Presto-331"><span class="linenos">331</span></a> +</span><span id="Presto-332"><a href="#Presto-332"><span class="linenos">332</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Presto-333"><a href="#Presto-333"><span class="linenos">333</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modes"</span><span class="p">)</span> +</span><span id="Presto-334"><a href="#Presto-334"><span class="linenos">334</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">modes</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modes</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Presto-335"><a href="#Presto-335"><span class="linenos">335</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"START TRANSACTION</span><span class="si">{</span><span class="n">modes</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Presto-336"><a href="#Presto-336"><span class="linenos">336</span></a> +</span><span id="Presto-337"><a href="#Presto-337"><span class="linenos">337</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="Presto-338"><a href="#Presto-338"><span class="linenos">338</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"start"</span><span class="p">]</span> +</span><span id="Presto-339"><a href="#Presto-339"><span class="linenos">339</span></a> <span class="n">end</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">"end"</span><span class="p">]</span> +</span><span id="Presto-340"><a href="#Presto-340"><span class="linenos">340</span></a> <span class="n">step</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"step"</span><span class="p">)</span> +</span><span id="Presto-341"><a href="#Presto-341"><span class="linenos">341</span></a> +</span><span id="Presto-342"><a href="#Presto-342"><span class="linenos">342</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="Presto-343"><a href="#Presto-343"><span class="linenos">343</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span> +</span><span id="Presto-344"><a href="#Presto-344"><span class="linenos">344</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="Presto-345"><a href="#Presto-345"><span class="linenos">345</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">end</span><span class="o">.</span><span class="n">to</span> +</span><span id="Presto-346"><a href="#Presto-346"><span class="linenos">346</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Presto-347"><a href="#Presto-347"><span class="linenos">347</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Presto-348"><a href="#Presto-348"><span class="linenos">348</span></a> +</span><span id="Presto-349"><a href="#Presto-349"><span class="linenos">349</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">and</span> <span class="n">target_type</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"timestamp"</span><span class="p">):</span> +</span><span id="Presto-350"><a href="#Presto-350"><span class="linenos">350</span></a> <span class="n">to</span> <span class="o">=</span> <span class="n">target_type</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Presto-351"><a href="#Presto-351"><span class="linenos">351</span></a> +</span><span id="Presto-352"><a href="#Presto-352"><span class="linenos">352</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">is</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span><span class="p">:</span> +</span><span id="Presto-353"><a href="#Presto-353"><span class="linenos">353</span></a> <span class="n">end</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">end</span><span class="p">,</span> <span class="n">to</span><span class="p">)</span> +</span><span id="Presto-354"><a href="#Presto-354"><span class="linenos">354</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Presto-355"><a href="#Presto-355"><span class="linenos">355</span></a> <span class="n">start</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">start</span><span class="p">,</span> <span class="n">to</span><span class="p">)</span> +</span><span id="Presto-356"><a href="#Presto-356"><span class="linenos">356</span></a> +</span><span id="Presto-357"><a href="#Presto-357"><span class="linenos">357</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">"SEQUENCE"</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span> +</span><span id="Presto-358"><a href="#Presto-358"><span class="linenos">358</span></a> +</span><span id="Presto-359"><a href="#Presto-359"><span class="linenos">359</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> +</span><span id="Presto-360"><a href="#Presto-360"><span class="linenos">360</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> +</span><span id="Presto-361"><a href="#Presto-361"><span class="linenos">361</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Presto-362"><a href="#Presto-362"><span class="linenos">362</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="Presto-363"><a href="#Presto-363"><span class="linenos">363</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> +</span><span id="Presto-364"><a href="#Presto-364"><span class="linenos">364</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> +</span><span id="Presto-365"><a href="#Presto-365"><span class="linenos">365</span></a> <span class="p">]</span> </span></pre></div> @@ -675,6 +679,10 @@ <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="Presto.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="Presto.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="Presto.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="Presto.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="Presto.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="Presto.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="Presto.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="Presto.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="Presto.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -698,13 +706,13 @@ </div> <a class="headerlink" href="#Presto.Tokenizer"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Tokenizer-185"><a href="#Presto.Tokenizer-185"><span class="linenos">185</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="Presto.Tokenizer-186"><a href="#Presto.Tokenizer-186"><span class="linenos">186</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Presto.Tokenizer-187"><a href="#Presto.Tokenizer-187"><span class="linenos">187</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="Presto.Tokenizer-188"><a href="#Presto.Tokenizer-188"><span class="linenos">188</span></a> <span class="s2">"START"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">,</span> -</span><span id="Presto.Tokenizer-189"><a href="#Presto.Tokenizer-189"><span class="linenos">189</span></a> <span class="s2">"MATCH_RECOGNIZE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MATCH_RECOGNIZE</span><span class="p">,</span> -</span><span id="Presto.Tokenizer-190"><a href="#Presto.Tokenizer-190"><span class="linenos">190</span></a> <span class="s2">"ROW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">,</span> -</span><span id="Presto.Tokenizer-191"><a href="#Presto.Tokenizer-191"><span class="linenos">191</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Tokenizer-181"><a href="#Presto.Tokenizer-181"><span class="linenos">181</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="Presto.Tokenizer-182"><a href="#Presto.Tokenizer-182"><span class="linenos">182</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Presto.Tokenizer-183"><a href="#Presto.Tokenizer-183"><span class="linenos">183</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="Presto.Tokenizer-184"><a href="#Presto.Tokenizer-184"><span class="linenos">184</span></a> <span class="s2">"START"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">,</span> +</span><span id="Presto.Tokenizer-185"><a href="#Presto.Tokenizer-185"><span class="linenos">185</span></a> <span class="s2">"MATCH_RECOGNIZE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MATCH_RECOGNIZE</span><span class="p">,</span> +</span><span id="Presto.Tokenizer-186"><a href="#Presto.Tokenizer-186"><span class="linenos">186</span></a> <span class="s2">"ROW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">,</span> +</span><span id="Presto.Tokenizer-187"><a href="#Presto.Tokenizer-187"><span class="linenos">187</span></a> <span class="p">}</span> </span></pre></div> @@ -733,40 +741,40 @@ </div> <a class="headerlink" href="#Presto.Parser"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Parser-193"><a href="#Presto.Parser-193"><span class="linenos">193</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="Presto.Parser-194"><a href="#Presto.Parser-194"><span class="linenos">194</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Presto.Parser-195"><a href="#Presto.Parser-195"><span class="linenos">195</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="Presto.Parser-196"><a href="#Presto.Parser-196"><span class="linenos">196</span></a> <span class="s2">"APPROX_DISTINCT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto.Parser-197"><a href="#Presto.Parser-197"><span class="linenos">197</span></a> <span class="s2">"APPROX_PERCENTILE"</span><span class="p">:</span> <span class="n">_approx_percentile</span><span class="p">,</span> -</span><span id="Presto.Parser-198"><a href="#Presto.Parser-198"><span class="linenos">198</span></a> <span class="s2">"CARDINALITY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto.Parser-199"><a href="#Presto.Parser-199"><span class="linenos">199</span></a> <span class="s2">"CONTAINS"</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="Presto.Parser-200"><a href="#Presto.Parser-200"><span class="linenos">200</span></a> <span class="s2">"DATE_ADD"</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">DateAdd</span><span class="p">(</span> -</span><span id="Presto.Parser-201"><a href="#Presto.Parser-201"><span class="linenos">201</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">2</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">unit</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="Presto.Parser-202"><a href="#Presto.Parser-202"><span class="linenos">202</span></a> <span class="p">),</span> -</span><span id="Presto.Parser-203"><a href="#Presto.Parser-203"><span class="linenos">203</span></a> <span class="s2">"DATE_DIFF"</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">DateDiff</span><span class="p">(</span> -</span><span id="Presto.Parser-204"><a href="#Presto.Parser-204"><span class="linenos">204</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">2</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">unit</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="Presto.Parser-205"><a href="#Presto.Parser-205"><span class="linenos">205</span></a> <span class="p">),</span> -</span><span id="Presto.Parser-206"><a href="#Presto.Parser-206"><span class="linenos">206</span></a> <span class="s2">"DATE_FORMAT"</span><span class="p">:</span> <span class="n">format_time_lambda</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">"presto"</span><span class="p">),</span> -</span><span id="Presto.Parser-207"><a href="#Presto.Parser-207"><span class="linenos">207</span></a> <span class="s2">"DATE_PARSE"</span><span class="p">:</span> <span class="n">format_time_lambda</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">"presto"</span><span class="p">),</span> -</span><span id="Presto.Parser-208"><a href="#Presto.Parser-208"><span class="linenos">208</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="Presto.Parser-209"><a href="#Presto.Parser-209"><span class="linenos">209</span></a> <span class="s2">"FROM_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto.Parser-210"><a href="#Presto.Parser-210"><span class="linenos">210</span></a> <span class="s2">"FROM_UNIXTIME"</span><span class="p">:</span> <span class="n">_from_unixtime</span><span class="p">,</span> -</span><span id="Presto.Parser-211"><a href="#Presto.Parser-211"><span class="linenos">211</span></a> <span class="s2">"FROM_UTF8"</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="Presto.Parser-212"><a href="#Presto.Parser-212"><span class="linenos">212</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">replace</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">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="Presto.Parser-213"><a href="#Presto.Parser-213"><span class="linenos">213</span></a> <span class="p">),</span> -</span><span id="Presto.Parser-214"><a href="#Presto.Parser-214"><span class="linenos">214</span></a> <span class="s2">"NOW"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto.Parser-215"><a href="#Presto.Parser-215"><span class="linenos">215</span></a> <span class="s2">"SEQUENCE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto.Parser-216"><a href="#Presto.Parser-216"><span class="linenos">216</span></a> <span class="s2">"STRPOS"</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">StrPosition</span><span class="p">(</span> -</span><span id="Presto.Parser-217"><a href="#Presto.Parser-217"><span class="linenos">217</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">substr</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">instance</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="Presto.Parser-218"><a href="#Presto.Parser-218"><span class="linenos">218</span></a> <span class="p">),</span> -</span><span id="Presto.Parser-219"><a href="#Presto.Parser-219"><span class="linenos">219</span></a> <span class="s2">"TO_UNIXTIME"</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="Presto.Parser-220"><a href="#Presto.Parser-220"><span class="linenos">220</span></a> <span class="s2">"TO_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Presto.Parser-221"><a href="#Presto.Parser-221"><span class="linenos">221</span></a> <span class="s2">"TO_UTF8"</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="Presto.Parser-222"><a href="#Presto.Parser-222"><span class="linenos">222</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="Presto.Parser-223"><a href="#Presto.Parser-223"><span class="linenos">223</span></a> <span class="p">),</span> -</span><span id="Presto.Parser-224"><a href="#Presto.Parser-224"><span class="linenos">224</span></a> <span class="p">}</span> -</span><span id="Presto.Parser-225"><a href="#Presto.Parser-225"><span class="linenos">225</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="Presto.Parser-226"><a href="#Presto.Parser-226"><span class="linenos">226</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Parser-189"><a href="#Presto.Parser-189"><span class="linenos">189</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="Presto.Parser-190"><a href="#Presto.Parser-190"><span class="linenos">190</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Presto.Parser-191"><a href="#Presto.Parser-191"><span class="linenos">191</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="Presto.Parser-192"><a href="#Presto.Parser-192"><span class="linenos">192</span></a> <span class="s2">"APPROX_DISTINCT"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto.Parser-193"><a href="#Presto.Parser-193"><span class="linenos">193</span></a> <span class="s2">"APPROX_PERCENTILE"</span><span class="p">:</span> <span class="n">_approx_percentile</span><span class="p">,</span> +</span><span id="Presto.Parser-194"><a href="#Presto.Parser-194"><span class="linenos">194</span></a> <span class="s2">"CARDINALITY"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArraySize</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto.Parser-195"><a href="#Presto.Parser-195"><span class="linenos">195</span></a> <span class="s2">"CONTAINS"</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="Presto.Parser-196"><a href="#Presto.Parser-196"><span class="linenos">196</span></a> <span class="s2">"DATE_ADD"</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">DateAdd</span><span class="p">(</span> +</span><span id="Presto.Parser-197"><a href="#Presto.Parser-197"><span class="linenos">197</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">2</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">unit</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="Presto.Parser-198"><a href="#Presto.Parser-198"><span class="linenos">198</span></a> <span class="p">),</span> +</span><span id="Presto.Parser-199"><a href="#Presto.Parser-199"><span class="linenos">199</span></a> <span class="s2">"DATE_DIFF"</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">DateDiff</span><span class="p">(</span> +</span><span id="Presto.Parser-200"><a href="#Presto.Parser-200"><span class="linenos">200</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">2</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">unit</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="Presto.Parser-201"><a href="#Presto.Parser-201"><span class="linenos">201</span></a> <span class="p">),</span> +</span><span id="Presto.Parser-202"><a href="#Presto.Parser-202"><span class="linenos">202</span></a> <span class="s2">"DATE_FORMAT"</span><span class="p">:</span> <span class="n">format_time_lambda</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">"presto"</span><span class="p">),</span> +</span><span id="Presto.Parser-203"><a href="#Presto.Parser-203"><span class="linenos">203</span></a> <span class="s2">"DATE_PARSE"</span><span class="p">:</span> <span class="n">format_time_lambda</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">"presto"</span><span class="p">),</span> +</span><span id="Presto.Parser-204"><a href="#Presto.Parser-204"><span class="linenos">204</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="Presto.Parser-205"><a href="#Presto.Parser-205"><span class="linenos">205</span></a> <span class="s2">"FROM_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto.Parser-206"><a href="#Presto.Parser-206"><span class="linenos">206</span></a> <span class="s2">"FROM_UNIXTIME"</span><span class="p">:</span> <span class="n">_from_unixtime</span><span class="p">,</span> +</span><span id="Presto.Parser-207"><a href="#Presto.Parser-207"><span class="linenos">207</span></a> <span class="s2">"FROM_UTF8"</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="Presto.Parser-208"><a href="#Presto.Parser-208"><span class="linenos">208</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">replace</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">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="Presto.Parser-209"><a href="#Presto.Parser-209"><span class="linenos">209</span></a> <span class="p">),</span> +</span><span id="Presto.Parser-210"><a href="#Presto.Parser-210"><span class="linenos">210</span></a> <span class="s2">"NOW"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentTimestamp</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto.Parser-211"><a href="#Presto.Parser-211"><span class="linenos">211</span></a> <span class="s2">"SEQUENCE"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GenerateSeries</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto.Parser-212"><a href="#Presto.Parser-212"><span class="linenos">212</span></a> <span class="s2">"STRPOS"</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">StrPosition</span><span class="p">(</span> +</span><span id="Presto.Parser-213"><a href="#Presto.Parser-213"><span class="linenos">213</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">substr</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">instance</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="Presto.Parser-214"><a href="#Presto.Parser-214"><span class="linenos">214</span></a> <span class="p">),</span> +</span><span id="Presto.Parser-215"><a href="#Presto.Parser-215"><span class="linenos">215</span></a> <span class="s2">"TO_UNIXTIME"</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="Presto.Parser-216"><a href="#Presto.Parser-216"><span class="linenos">216</span></a> <span class="s2">"TO_HEX"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Presto.Parser-217"><a href="#Presto.Parser-217"><span class="linenos">217</span></a> <span class="s2">"TO_UTF8"</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="Presto.Parser-218"><a href="#Presto.Parser-218"><span class="linenos">218</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="Presto.Parser-219"><a href="#Presto.Parser-219"><span class="linenos">219</span></a> <span class="p">),</span> +</span><span id="Presto.Parser-220"><a href="#Presto.Parser-220"><span class="linenos">220</span></a> <span class="p">}</span> +</span><span id="Presto.Parser-221"><a href="#Presto.Parser-221"><span class="linenos">221</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="Presto.Parser-222"><a href="#Presto.Parser-222"><span class="linenos">222</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> </span></pre></div> @@ -815,148 +823,148 @@ Default: 3</li> </div> <a class="headerlink" href="#Presto.Generator"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator-228"><a href="#Presto.Generator-228"><span class="linenos">228</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="Presto.Generator-229"><a href="#Presto.Generator-229"><span class="linenos">229</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto.Generator-230"><a href="#Presto.Generator-230"><span class="linenos">230</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto.Generator-231"><a href="#Presto.Generator-231"><span class="linenos">231</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto.Generator-232"><a href="#Presto.Generator-232"><span class="linenos">232</span></a> <span class="n">IS_BOOL_ALLOWED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Presto.Generator-233"><a href="#Presto.Generator-233"><span class="linenos">233</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="Presto.Generator-234"><a href="#Presto.Generator-234"><span class="linenos">234</span></a> -</span><span id="Presto.Generator-235"><a href="#Presto.Generator-235"><span class="linenos">235</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Presto.Generator-236"><a href="#Presto.Generator-236"><span class="linenos">236</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">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="Presto.Generator-237"><a href="#Presto.Generator-237"><span class="linenos">237</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="Presto.Generator-238"><a href="#Presto.Generator-238"><span class="linenos">238</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="Presto.Generator-239"><a href="#Presto.Generator-239"><span class="linenos">239</span></a> <span class="p">}</span> -</span><span id="Presto.Generator-240"><a href="#Presto.Generator-240"><span class="linenos">240</span></a> -</span><span id="Presto.Generator-241"><a href="#Presto.Generator-241"><span class="linenos">241</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Presto.Generator-242"><a href="#Presto.Generator-242"><span class="linenos">242</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="Presto.Generator-243"><a href="#Presto.Generator-243"><span class="linenos">243</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="Presto.Generator-244"><a href="#Presto.Generator-244"><span class="linenos">244</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> -</span><span id="Presto.Generator-245"><a href="#Presto.Generator-245"><span class="linenos">245</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">"VARBINARY"</span><span class="p">,</span> -</span><span id="Presto.Generator-246"><a href="#Presto.Generator-246"><span class="linenos">246</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="s2">"VARCHAR"</span><span class="p">,</span> -</span><span id="Presto.Generator-247"><a href="#Presto.Generator-247"><span class="linenos">247</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> -</span><span id="Presto.Generator-248"><a href="#Presto.Generator-248"><span class="linenos">248</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">STRUCT</span><span class="p">:</span> <span class="s2">"ROW"</span><span class="p">,</span> -</span><span id="Presto.Generator-249"><a href="#Presto.Generator-249"><span class="linenos">249</span></a> <span class="p">}</span> -</span><span id="Presto.Generator-250"><a href="#Presto.Generator-250"><span class="linenos">250</span></a> -</span><span id="Presto.Generator-251"><a href="#Presto.Generator-251"><span class="linenos">251</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Presto.Generator-252"><a href="#Presto.Generator-252"><span class="linenos">252</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="Presto.Generator-253"><a href="#Presto.Generator-253"><span class="linenos">253</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">_approx_distinct_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-254"><a href="#Presto.Generator-254"><span class="linenos">254</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_PERCENTILE"</span><span class="p">),</span> -</span><span id="Presto.Generator-255"><a href="#Presto.Generator-255"><span class="linenos">255</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</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">"ARRAY[</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">e</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="p">,</span> -</span><span id="Presto.Generator-256"><a href="#Presto.Generator-256"><span class="linenos">256</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">),</span> -</span><span id="Presto.Generator-257"><a href="#Presto.Generator-257"><span class="linenos">257</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONTAINS"</span><span class="p">),</span> -</span><span id="Presto.Generator-258"><a href="#Presto.Generator-258"><span class="linenos">258</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">"CARDINALITY"</span><span class="p">),</span> -</span><span id="Presto.Generator-259"><a href="#Presto.Generator-259"><span class="linenos">259</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</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">"BITWISE_AND(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto.Generator-260"><a href="#Presto.Generator-260"><span class="linenos">260</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</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">"BITWISE_ARITHMETIC_SHIFT_LEFT(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto.Generator-261"><a href="#Presto.Generator-261"><span class="linenos">261</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</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">"BITWISE_NOT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto.Generator-262"><a href="#Presto.Generator-262"><span class="linenos">262</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</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">"BITWISE_OR(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto.Generator-263"><a href="#Presto.Generator-263"><span class="linenos">263</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</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">"BITWISE_ARITHMETIC_SHIFT_RIGHT(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto.Generator-264"><a href="#Presto.Generator-264"><span class="linenos">264</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</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">"BITWISE_XOR(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto.Generator-265"><a href="#Presto.Generator-265"><span class="linenos">265</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</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">epoch_cast_to_ts</span><span class="p">]),</span> -</span><span id="Presto.Generator-266"><a href="#Presto.Generator-266"><span class="linenos">266</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="Presto.Generator-267"><a href="#Presto.Generator-267"><span class="linenos">267</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="Presto.Generator-268"><a href="#Presto.Generator-268"><span class="linenos">268</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</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="Presto.Generator-269"><a href="#Presto.Generator-269"><span class="linenos">269</span></a> <span class="s2">"DATE_ADD"</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">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"day"</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="Presto.Generator-270"><a href="#Presto.Generator-270"><span class="linenos">270</span></a> <span class="p">),</span> -</span><span id="Presto.Generator-271"><a href="#Presto.Generator-271"><span class="linenos">271</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="Presto.Generator-272"><a href="#Presto.Generator-272"><span class="linenos">272</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">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"day"</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="Presto.Generator-273"><a href="#Presto.Generator-273"><span class="linenos">273</span></a> <span class="p">),</span> -</span><span id="Presto.Generator-274"><a href="#Presto.Generator-274"><span class="linenos">274</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</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(DATE_PARSE(</span><span 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">Presto</span><span class="o">.</span><span class="n">DATE_FORMAT</span><span class="si">}</span><span class="s2">) AS DATE)"</span><span class="p">,</span> -</span><span id="Presto.Generator-275"><a href="#Presto.Generator-275"><span class="linenos">275</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 class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_FORMAT(</span><span 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">Presto</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="Presto.Generator-276"><a href="#Presto.Generator-276"><span class="linenos">276</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">:</span> <span class="n">_decode_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-277"><a href="#Presto.Generator-277"><span class="linenos">277</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 class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_PARSE(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 VARCHAR), </span><span class="si">{</span><span class="n">Presto</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="Presto.Generator-278"><a href="#Presto.Generator-278"><span class="linenos">278</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">:</span> <span class="n">_encode_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-279"><a href="#Presto.Generator-279"><span class="linenos">279</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</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">"FORMAT='</span><span class="si">{</span><span class="n">e</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="si">}</span><span class="s2">'"</span><span class="p">,</span> -</span><span id="Presto.Generator-280"><a href="#Presto.Generator-280"><span class="linenos">280</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Group</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">unalias_group</span><span class="p">]),</span> -</span><span id="Presto.Generator-281"><a href="#Presto.Generator-281"><span class="linenos">281</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">),</span> -</span><span id="Presto.Generator-282"><a href="#Presto.Generator-282"><span class="linenos">282</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-283"><a href="#Presto.Generator-283"><span class="linenos">283</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-284"><a href="#Presto.Generator-284"><span class="linenos">284</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Initcap</span><span class="p">:</span> <span class="n">_initcap_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-285"><a href="#Presto.Generator-285"><span class="linenos">285</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">:</span> <span class="n">_explode_to_unnest_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-286"><a href="#Presto.Generator-286"><span class="linenos">286</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">:</span> <span class="n">left_to_substring_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-287"><a href="#Presto.Generator-287"><span class="linenos">287</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LEVENSHTEIN_DISTANCE"</span><span class="p">),</span> -</span><span id="Presto.Generator-288"><a href="#Presto.Generator-288"><span class="linenos">288</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="Presto.Generator-289"><a href="#Presto.Generator-289"><span class="linenos">289</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="Presto.Generator-290"><a href="#Presto.Generator-290"><span class="linenos">290</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">no_pivot_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-291"><a href="#Presto.Generator-291"><span class="linenos">291</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="p">:</span> <span class="n">_quantile_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-292"><a href="#Presto.Generator-292"><span class="linenos">292</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Right</span><span class="p">:</span> <span class="n">right_to_substring_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-293"><a href="#Presto.Generator-293"><span class="linenos">293</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="Presto.Generator-294"><a href="#Presto.Generator-294"><span class="linenos">294</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">:</span> <span class="n">_schema_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-295"><a href="#Presto.Generator-295"><span class="linenos">295</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="Presto.Generator-296"><a href="#Presto.Generator-296"><span class="linenos">296</span></a> <span class="p">[</span> -</span><span id="Presto.Generator-297"><a href="#Presto.Generator-297"><span class="linenos">297</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">,</span> -</span><span id="Presto.Generator-298"><a href="#Presto.Generator-298"><span class="linenos">298</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> -</span><span id="Presto.Generator-299"><a href="#Presto.Generator-299"><span class="linenos">299</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">explode_to_unnest</span><span class="p">,</span> -</span><span id="Presto.Generator-300"><a href="#Presto.Generator-300"><span class="linenos">300</span></a> <span class="p">]</span> -</span><span id="Presto.Generator-301"><a href="#Presto.Generator-301"><span class="linenos">301</span></a> <span class="p">),</span> -</span><span id="Presto.Generator-302"><a href="#Presto.Generator-302"><span class="linenos">302</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="p">:</span> <span class="n">_no_sort_array</span><span class="p">,</span> -</span><span id="Presto.Generator-303"><a href="#Presto.Generator-303"><span class="linenos">303</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRPOS"</span><span class="p">),</span> -</span><span id="Presto.Generator-304"><a href="#Presto.Generator-304"><span class="linenos">304</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</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(</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">e</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span><span class="p">,</span> -</span><span id="Presto.Generator-305"><a href="#Presto.Generator-305"><span class="linenos">305</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_time_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-306"><a href="#Presto.Generator-306"><span class="linenos">306</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="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span 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="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 class="si">}</span><span class="s2">))"</span><span class="p">,</span> -</span><span id="Presto.Generator-307"><a href="#Presto.Generator-307"><span class="linenos">307</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">:</span> <span class="n">struct_extract_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-308"><a href="#Presto.Generator-308"><span class="linenos">308</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Table</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">_unnest_sequence</span><span class="p">]),</span> -</span><span id="Presto.Generator-309"><a href="#Presto.Generator-309"><span class="linenos">309</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="Presto.Generator-310"><a href="#Presto.Generator-310"><span class="linenos">310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-311"><a href="#Presto.Generator-311"><span class="linenos">311</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="Presto.Generator-312"><a href="#Presto.Generator-312"><span class="linenos">312</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="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span 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">Presto</span><span class="o">.</span><span class="n">TIME_FORMAT</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> -</span><span id="Presto.Generator-313"><a href="#Presto.Generator-313"><span class="linenos">313</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="sa">f</span><span class="s2">"DATE_FORMAT(</span><span 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="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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto.Generator-314"><a href="#Presto.Generator-314"><span class="linenos">314</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">"TO_UNIXTIME"</span><span class="p">),</span> -</span><span id="Presto.Generator-315"><a href="#Presto.Generator-315"><span class="linenos">315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</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">epoch_cast_to_ts</span><span class="p">]),</span> -</span><span id="Presto.Generator-316"><a href="#Presto.Generator-316"><span class="linenos">316</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 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 VARCHAR), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> -</span><span id="Presto.Generator-317"><a href="#Presto.Generator-317"><span class="linenos">317</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-318"><a href="#Presto.Generator-318"><span class="linenos">318</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">_ts_or_ds_to_date_sql</span><span class="p">,</span> -</span><span id="Presto.Generator-319"><a href="#Presto.Generator-319"><span class="linenos">319</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_HEX"</span><span class="p">),</span> -</span><span id="Presto.Generator-320"><a href="#Presto.Generator-320"><span class="linenos">320</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="sa">f</span><span class="s2">"DATE_FORMAT(FROM_UNIXTIME(</span><span 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="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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Presto.Generator-321"><a href="#Presto.Generator-321"><span class="linenos">321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_UNIXTIME"</span><span class="p">),</span> -</span><span id="Presto.Generator-322"><a href="#Presto.Generator-322"><span class="linenos">322</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(FROM_UNIXTIME(</span><span 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 VARCHAR)"</span><span class="p">,</span> -</span><span id="Presto.Generator-323"><a href="#Presto.Generator-323"><span class="linenos">323</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="Presto.Generator-324"><a href="#Presto.Generator-324"><span class="linenos">324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</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">add_recursive_cte_column_names</span><span class="p">]),</span> -</span><span id="Presto.Generator-325"><a href="#Presto.Generator-325"><span class="linenos">325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="Presto.Generator-326"><a href="#Presto.Generator-326"><span class="linenos">326</span></a> <span class="p">[</span><span class="n">transforms</span><span class="o">.</span><span class="n">remove_within_group_for_percentiles</span><span class="p">]</span> -</span><span id="Presto.Generator-327"><a href="#Presto.Generator-327"><span class="linenos">327</span></a> <span class="p">),</span> -</span><span id="Presto.Generator-328"><a href="#Presto.Generator-328"><span class="linenos">328</span></a> <span class="p">}</span> -</span><span id="Presto.Generator-329"><a href="#Presto.Generator-329"><span class="linenos">329</span></a> -</span><span id="Presto.Generator-330"><a href="#Presto.Generator-330"><span class="linenos">330</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="Presto.Generator-331"><a href="#Presto.Generator-331"><span class="linenos">331</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> -</span><span id="Presto.Generator-332"><a href="#Presto.Generator-332"><span class="linenos">332</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">()</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="Presto.Generator-333"><a href="#Presto.Generator-333"><span class="linenos">333</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> * INTERVAL '7' day)"</span> -</span><span id="Presto.Generator-334"><a href="#Presto.Generator-334"><span class="linenos">334</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="Presto.Generator-335"><a href="#Presto.Generator-335"><span class="linenos">335</span></a> -</span><span id="Presto.Generator-336"><a href="#Presto.Generator-336"><span class="linenos">336</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Presto.Generator-337"><a href="#Presto.Generator-337"><span class="linenos">337</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modes"</span><span class="p">)</span> -</span><span id="Presto.Generator-338"><a href="#Presto.Generator-338"><span class="linenos">338</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">modes</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modes</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Presto.Generator-339"><a href="#Presto.Generator-339"><span class="linenos">339</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"START TRANSACTION</span><span class="si">{</span><span class="n">modes</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Presto.Generator-340"><a href="#Presto.Generator-340"><span class="linenos">340</span></a> -</span><span id="Presto.Generator-341"><a href="#Presto.Generator-341"><span class="linenos">341</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="Presto.Generator-342"><a href="#Presto.Generator-342"><span class="linenos">342</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"start"</span><span class="p">]</span> -</span><span id="Presto.Generator-343"><a href="#Presto.Generator-343"><span class="linenos">343</span></a> <span class="n">end</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">"end"</span><span class="p">]</span> -</span><span id="Presto.Generator-344"><a href="#Presto.Generator-344"><span class="linenos">344</span></a> <span class="n">step</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"step"</span><span class="p">)</span> -</span><span id="Presto.Generator-345"><a href="#Presto.Generator-345"><span class="linenos">345</span></a> -</span><span id="Presto.Generator-346"><a href="#Presto.Generator-346"><span class="linenos">346</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="Presto.Generator-347"><a href="#Presto.Generator-347"><span class="linenos">347</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span> -</span><span id="Presto.Generator-348"><a href="#Presto.Generator-348"><span class="linenos">348</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="Presto.Generator-349"><a href="#Presto.Generator-349"><span class="linenos">349</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">end</span><span class="o">.</span><span class="n">to</span> -</span><span id="Presto.Generator-350"><a href="#Presto.Generator-350"><span class="linenos">350</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Presto.Generator-351"><a href="#Presto.Generator-351"><span class="linenos">351</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Presto.Generator-352"><a href="#Presto.Generator-352"><span class="linenos">352</span></a> -</span><span id="Presto.Generator-353"><a href="#Presto.Generator-353"><span class="linenos">353</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">and</span> <span class="n">target_type</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"timestamp"</span><span class="p">):</span> -</span><span id="Presto.Generator-354"><a href="#Presto.Generator-354"><span class="linenos">354</span></a> <span class="n">to</span> <span class="o">=</span> <span class="n">target_type</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Presto.Generator-355"><a href="#Presto.Generator-355"><span class="linenos">355</span></a> -</span><span id="Presto.Generator-356"><a href="#Presto.Generator-356"><span class="linenos">356</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">is</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span><span class="p">:</span> -</span><span id="Presto.Generator-357"><a href="#Presto.Generator-357"><span class="linenos">357</span></a> <span class="n">end</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">end</span><span class="p">,</span> <span class="n">to</span><span class="p">)</span> -</span><span id="Presto.Generator-358"><a href="#Presto.Generator-358"><span class="linenos">358</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Presto.Generator-359"><a href="#Presto.Generator-359"><span class="linenos">359</span></a> <span class="n">start</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">start</span><span class="p">,</span> <span class="n">to</span><span class="p">)</span> -</span><span id="Presto.Generator-360"><a href="#Presto.Generator-360"><span class="linenos">360</span></a> -</span><span id="Presto.Generator-361"><a href="#Presto.Generator-361"><span class="linenos">361</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">"SEQUENCE"</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span> -</span><span id="Presto.Generator-362"><a href="#Presto.Generator-362"><span class="linenos">362</span></a> -</span><span id="Presto.Generator-363"><a href="#Presto.Generator-363"><span class="linenos">363</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> -</span><span id="Presto.Generator-364"><a href="#Presto.Generator-364"><span class="linenos">364</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> -</span><span id="Presto.Generator-365"><a href="#Presto.Generator-365"><span class="linenos">365</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Presto.Generator-366"><a href="#Presto.Generator-366"><span class="linenos">366</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="Presto.Generator-367"><a href="#Presto.Generator-367"><span class="linenos">367</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> -</span><span id="Presto.Generator-368"><a href="#Presto.Generator-368"><span class="linenos">368</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> -</span><span id="Presto.Generator-369"><a href="#Presto.Generator-369"><span class="linenos">369</span></a> <span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator-224"><a href="#Presto.Generator-224"><span class="linenos">224</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="Presto.Generator-225"><a href="#Presto.Generator-225"><span class="linenos">225</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto.Generator-226"><a href="#Presto.Generator-226"><span class="linenos">226</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto.Generator-227"><a href="#Presto.Generator-227"><span class="linenos">227</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto.Generator-228"><a href="#Presto.Generator-228"><span class="linenos">228</span></a> <span class="n">IS_BOOL_ALLOWED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Presto.Generator-229"><a href="#Presto.Generator-229"><span class="linenos">229</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="Presto.Generator-230"><a href="#Presto.Generator-230"><span class="linenos">230</span></a> +</span><span id="Presto.Generator-231"><a href="#Presto.Generator-231"><span class="linenos">231</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Presto.Generator-232"><a href="#Presto.Generator-232"><span class="linenos">232</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">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="Presto.Generator-233"><a href="#Presto.Generator-233"><span class="linenos">233</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="Presto.Generator-234"><a href="#Presto.Generator-234"><span class="linenos">234</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="Presto.Generator-235"><a href="#Presto.Generator-235"><span class="linenos">235</span></a> <span class="p">}</span> +</span><span id="Presto.Generator-236"><a href="#Presto.Generator-236"><span class="linenos">236</span></a> +</span><span id="Presto.Generator-237"><a href="#Presto.Generator-237"><span class="linenos">237</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Presto.Generator-238"><a href="#Presto.Generator-238"><span class="linenos">238</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="Presto.Generator-239"><a href="#Presto.Generator-239"><span class="linenos">239</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="Presto.Generator-240"><a href="#Presto.Generator-240"><span class="linenos">240</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> +</span><span id="Presto.Generator-241"><a href="#Presto.Generator-241"><span class="linenos">241</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">BINARY</span><span class="p">:</span> <span class="s2">"VARBINARY"</span><span class="p">,</span> +</span><span id="Presto.Generator-242"><a href="#Presto.Generator-242"><span class="linenos">242</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TEXT</span><span class="p">:</span> <span class="s2">"VARCHAR"</span><span class="p">,</span> +</span><span id="Presto.Generator-243"><a href="#Presto.Generator-243"><span class="linenos">243</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">:</span> <span class="s2">"TIMESTAMP"</span><span class="p">,</span> +</span><span id="Presto.Generator-244"><a href="#Presto.Generator-244"><span class="linenos">244</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">:</span> <span class="s2">"ROW"</span><span class="p">,</span> +</span><span id="Presto.Generator-245"><a href="#Presto.Generator-245"><span class="linenos">245</span></a> <span class="p">}</span> +</span><span id="Presto.Generator-246"><a href="#Presto.Generator-246"><span class="linenos">246</span></a> +</span><span id="Presto.Generator-247"><a href="#Presto.Generator-247"><span class="linenos">247</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Presto.Generator-248"><a href="#Presto.Generator-248"><span class="linenos">248</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="Presto.Generator-249"><a href="#Presto.Generator-249"><span class="linenos">249</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxDistinct</span><span class="p">:</span> <span class="n">_approx_distinct_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-250"><a href="#Presto.Generator-250"><span class="linenos">250</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ApproxQuantile</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"APPROX_PERCENTILE"</span><span class="p">),</span> +</span><span id="Presto.Generator-251"><a href="#Presto.Generator-251"><span class="linenos">251</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Array</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">"ARRAY[</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">e</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="p">,</span> +</span><span id="Presto.Generator-252"><a href="#Presto.Generator-252"><span class="linenos">252</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">),</span> +</span><span id="Presto.Generator-253"><a href="#Presto.Generator-253"><span class="linenos">253</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayContains</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"CONTAINS"</span><span class="p">),</span> +</span><span id="Presto.Generator-254"><a href="#Presto.Generator-254"><span class="linenos">254</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">"CARDINALITY"</span><span class="p">),</span> +</span><span id="Presto.Generator-255"><a href="#Presto.Generator-255"><span class="linenos">255</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</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">"BITWISE_AND(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto.Generator-256"><a href="#Presto.Generator-256"><span class="linenos">256</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</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">"BITWISE_ARITHMETIC_SHIFT_LEFT(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto.Generator-257"><a href="#Presto.Generator-257"><span class="linenos">257</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</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">"BITWISE_NOT(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto.Generator-258"><a href="#Presto.Generator-258"><span class="linenos">258</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</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">"BITWISE_OR(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto.Generator-259"><a href="#Presto.Generator-259"><span class="linenos">259</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</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">"BITWISE_ARITHMETIC_SHIFT_RIGHT(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto.Generator-260"><a href="#Presto.Generator-260"><span class="linenos">260</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</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">"BITWISE_XOR(</span><span 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="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">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto.Generator-261"><a href="#Presto.Generator-261"><span class="linenos">261</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</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">epoch_cast_to_ts</span><span class="p">]),</span> +</span><span id="Presto.Generator-262"><a href="#Presto.Generator-262"><span class="linenos">262</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="Presto.Generator-263"><a href="#Presto.Generator-263"><span class="linenos">263</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="Presto.Generator-264"><a href="#Presto.Generator-264"><span class="linenos">264</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</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="Presto.Generator-265"><a href="#Presto.Generator-265"><span class="linenos">265</span></a> <span class="s2">"DATE_ADD"</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">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"day"</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="Presto.Generator-266"><a href="#Presto.Generator-266"><span class="linenos">266</span></a> <span class="p">),</span> +</span><span id="Presto.Generator-267"><a href="#Presto.Generator-267"><span class="linenos">267</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="Presto.Generator-268"><a href="#Presto.Generator-268"><span class="linenos">268</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">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"day"</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="Presto.Generator-269"><a href="#Presto.Generator-269"><span class="linenos">269</span></a> <span class="p">),</span> +</span><span id="Presto.Generator-270"><a href="#Presto.Generator-270"><span class="linenos">270</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</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(DATE_PARSE(</span><span 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">Presto</span><span class="o">.</span><span class="n">DATE_FORMAT</span><span class="si">}</span><span class="s2">) AS DATE)"</span><span class="p">,</span> +</span><span id="Presto.Generator-271"><a href="#Presto.Generator-271"><span class="linenos">271</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 class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_FORMAT(</span><span 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">Presto</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="Presto.Generator-272"><a href="#Presto.Generator-272"><span class="linenos">272</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Decode</span><span class="p">:</span> <span class="n">_decode_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-273"><a href="#Presto.Generator-273"><span class="linenos">273</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 class="n">e</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"CAST(DATE_PARSE(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 VARCHAR), </span><span class="si">{</span><span class="n">Presto</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="Presto.Generator-274"><a href="#Presto.Generator-274"><span class="linenos">274</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Encode</span><span class="p">:</span> <span class="n">_encode_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-275"><a href="#Presto.Generator-275"><span class="linenos">275</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</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">"FORMAT='</span><span class="si">{</span><span class="n">e</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="si">}</span><span class="s2">'"</span><span class="p">,</span> +</span><span id="Presto.Generator-276"><a href="#Presto.Generator-276"><span class="linenos">276</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Group</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">unalias_group</span><span class="p">]),</span> +</span><span id="Presto.Generator-277"><a href="#Presto.Generator-277"><span class="linenos">277</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Hex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"TO_HEX"</span><span class="p">),</span> +</span><span id="Presto.Generator-278"><a href="#Presto.Generator-278"><span class="linenos">278</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">if_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-279"><a href="#Presto.Generator-279"><span class="linenos">279</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-280"><a href="#Presto.Generator-280"><span class="linenos">280</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Initcap</span><span class="p">:</span> <span class="n">_initcap_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-281"><a href="#Presto.Generator-281"><span class="linenos">281</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">:</span> <span class="n">_explode_to_unnest_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-282"><a href="#Presto.Generator-282"><span class="linenos">282</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Left</span><span class="p">:</span> <span class="n">left_to_substring_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-283"><a href="#Presto.Generator-283"><span class="linenos">283</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"LEVENSHTEIN_DISTANCE"</span><span class="p">),</span> +</span><span id="Presto.Generator-284"><a href="#Presto.Generator-284"><span class="linenos">284</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="Presto.Generator-285"><a href="#Presto.Generator-285"><span class="linenos">285</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="Presto.Generator-286"><a href="#Presto.Generator-286"><span class="linenos">286</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">no_pivot_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-287"><a href="#Presto.Generator-287"><span class="linenos">287</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Quantile</span><span class="p">:</span> <span class="n">_quantile_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-288"><a href="#Presto.Generator-288"><span class="linenos">288</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Right</span><span class="p">:</span> <span class="n">right_to_substring_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-289"><a href="#Presto.Generator-289"><span class="linenos">289</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="Presto.Generator-290"><a href="#Presto.Generator-290"><span class="linenos">290</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">:</span> <span class="n">_schema_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-291"><a href="#Presto.Generator-291"><span class="linenos">291</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="Presto.Generator-292"><a href="#Presto.Generator-292"><span class="linenos">292</span></a> <span class="p">[</span> +</span><span id="Presto.Generator-293"><a href="#Presto.Generator-293"><span class="linenos">293</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">,</span> +</span><span id="Presto.Generator-294"><a href="#Presto.Generator-294"><span class="linenos">294</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> +</span><span id="Presto.Generator-295"><a href="#Presto.Generator-295"><span class="linenos">295</span></a> <span class="n">transforms</span><span class="o">.</span><span class="n">explode_to_unnest</span><span class="p">,</span> +</span><span id="Presto.Generator-296"><a href="#Presto.Generator-296"><span class="linenos">296</span></a> <span class="p">]</span> +</span><span id="Presto.Generator-297"><a href="#Presto.Generator-297"><span class="linenos">297</span></a> <span class="p">),</span> +</span><span id="Presto.Generator-298"><a href="#Presto.Generator-298"><span class="linenos">298</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortArray</span><span class="p">:</span> <span class="n">_no_sort_array</span><span class="p">,</span> +</span><span id="Presto.Generator-299"><a href="#Presto.Generator-299"><span class="linenos">299</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRPOS"</span><span class="p">),</span> +</span><span id="Presto.Generator-300"><a href="#Presto.Generator-300"><span class="linenos">300</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</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(</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">e</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS DATE)"</span><span class="p">,</span> +</span><span id="Presto.Generator-301"><a href="#Presto.Generator-301"><span class="linenos">301</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">:</span> <span class="n">_str_to_time_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-302"><a href="#Presto.Generator-302"><span class="linenos">302</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="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span 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="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 class="si">}</span><span class="s2">))"</span><span class="p">,</span> +</span><span id="Presto.Generator-303"><a href="#Presto.Generator-303"><span class="linenos">303</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StructExtract</span><span class="p">:</span> <span class="n">struct_extract_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-304"><a href="#Presto.Generator-304"><span class="linenos">304</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Table</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">_unnest_sequence</span><span class="p">]),</span> +</span><span id="Presto.Generator-305"><a href="#Presto.Generator-305"><span class="linenos">305</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="Presto.Generator-306"><a href="#Presto.Generator-306"><span class="linenos">306</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToDate</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-307"><a href="#Presto.Generator-307"><span class="linenos">307</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="Presto.Generator-308"><a href="#Presto.Generator-308"><span class="linenos">308</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="sa">f</span><span class="s2">"TO_UNIXTIME(DATE_PARSE(</span><span 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">Presto</span><span class="o">.</span><span class="n">TIME_FORMAT</span><span class="si">}</span><span class="s2">))"</span><span class="p">,</span> +</span><span id="Presto.Generator-309"><a href="#Presto.Generator-309"><span class="linenos">309</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="sa">f</span><span class="s2">"DATE_FORMAT(</span><span 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="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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto.Generator-310"><a href="#Presto.Generator-310"><span class="linenos">310</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">"TO_UNIXTIME"</span><span class="p">),</span> +</span><span id="Presto.Generator-311"><a href="#Presto.Generator-311"><span class="linenos">311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</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">epoch_cast_to_ts</span><span class="p">]),</span> +</span><span id="Presto.Generator-312"><a href="#Presto.Generator-312"><span class="linenos">312</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 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 VARCHAR), '-', ''), 1, 8) AS INT)"</span><span class="p">,</span> +</span><span id="Presto.Generator-313"><a href="#Presto.Generator-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</span><span class="p">:</span> <span class="n">_ts_or_ds_add_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-314"><a href="#Presto.Generator-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">_ts_or_ds_to_date_sql</span><span class="p">,</span> +</span><span id="Presto.Generator-315"><a href="#Presto.Generator-315"><span class="linenos">315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unhex</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_HEX"</span><span class="p">),</span> +</span><span id="Presto.Generator-316"><a href="#Presto.Generator-316"><span class="linenos">316</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="sa">f</span><span class="s2">"DATE_FORMAT(FROM_UNIXTIME(</span><span 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="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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Presto.Generator-317"><a href="#Presto.Generator-317"><span class="linenos">317</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"FROM_UNIXTIME"</span><span class="p">),</span> +</span><span id="Presto.Generator-318"><a href="#Presto.Generator-318"><span class="linenos">318</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(FROM_UNIXTIME(</span><span 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 VARCHAR)"</span><span class="p">,</span> +</span><span id="Presto.Generator-319"><a href="#Presto.Generator-319"><span class="linenos">319</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="Presto.Generator-320"><a href="#Presto.Generator-320"><span class="linenos">320</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</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">add_recursive_cte_column_names</span><span class="p">]),</span> +</span><span id="Presto.Generator-321"><a href="#Presto.Generator-321"><span class="linenos">321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="Presto.Generator-322"><a href="#Presto.Generator-322"><span class="linenos">322</span></a> <span class="p">[</span><span class="n">transforms</span><span class="o">.</span><span class="n">remove_within_group_for_percentiles</span><span class="p">]</span> +</span><span id="Presto.Generator-323"><a href="#Presto.Generator-323"><span class="linenos">323</span></a> <span class="p">),</span> +</span><span id="Presto.Generator-324"><a href="#Presto.Generator-324"><span class="linenos">324</span></a> <span class="p">}</span> +</span><span id="Presto.Generator-325"><a href="#Presto.Generator-325"><span class="linenos">325</span></a> +</span><span id="Presto.Generator-326"><a href="#Presto.Generator-326"><span class="linenos">326</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="Presto.Generator-327"><a href="#Presto.Generator-327"><span class="linenos">327</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> +</span><span id="Presto.Generator-328"><a href="#Presto.Generator-328"><span class="linenos">328</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">()</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="Presto.Generator-329"><a href="#Presto.Generator-329"><span class="linenos">329</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> * INTERVAL '7' day)"</span> +</span><span id="Presto.Generator-330"><a href="#Presto.Generator-330"><span class="linenos">330</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="Presto.Generator-331"><a href="#Presto.Generator-331"><span class="linenos">331</span></a> +</span><span id="Presto.Generator-332"><a href="#Presto.Generator-332"><span class="linenos">332</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Presto.Generator-333"><a href="#Presto.Generator-333"><span class="linenos">333</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modes"</span><span class="p">)</span> +</span><span id="Presto.Generator-334"><a href="#Presto.Generator-334"><span class="linenos">334</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">modes</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modes</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Presto.Generator-335"><a href="#Presto.Generator-335"><span class="linenos">335</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"START TRANSACTION</span><span class="si">{</span><span class="n">modes</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Presto.Generator-336"><a href="#Presto.Generator-336"><span class="linenos">336</span></a> +</span><span id="Presto.Generator-337"><a href="#Presto.Generator-337"><span class="linenos">337</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="Presto.Generator-338"><a href="#Presto.Generator-338"><span class="linenos">338</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"start"</span><span class="p">]</span> +</span><span id="Presto.Generator-339"><a href="#Presto.Generator-339"><span class="linenos">339</span></a> <span class="n">end</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">"end"</span><span class="p">]</span> +</span><span id="Presto.Generator-340"><a href="#Presto.Generator-340"><span class="linenos">340</span></a> <span class="n">step</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"step"</span><span class="p">)</span> +</span><span id="Presto.Generator-341"><a href="#Presto.Generator-341"><span class="linenos">341</span></a> +</span><span id="Presto.Generator-342"><a href="#Presto.Generator-342"><span class="linenos">342</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="Presto.Generator-343"><a href="#Presto.Generator-343"><span class="linenos">343</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span> +</span><span id="Presto.Generator-344"><a href="#Presto.Generator-344"><span class="linenos">344</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="Presto.Generator-345"><a href="#Presto.Generator-345"><span class="linenos">345</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">end</span><span class="o">.</span><span class="n">to</span> +</span><span id="Presto.Generator-346"><a href="#Presto.Generator-346"><span class="linenos">346</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Presto.Generator-347"><a href="#Presto.Generator-347"><span class="linenos">347</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Presto.Generator-348"><a href="#Presto.Generator-348"><span class="linenos">348</span></a> +</span><span id="Presto.Generator-349"><a href="#Presto.Generator-349"><span class="linenos">349</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">and</span> <span class="n">target_type</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"timestamp"</span><span class="p">):</span> +</span><span id="Presto.Generator-350"><a href="#Presto.Generator-350"><span class="linenos">350</span></a> <span class="n">to</span> <span class="o">=</span> <span class="n">target_type</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Presto.Generator-351"><a href="#Presto.Generator-351"><span class="linenos">351</span></a> +</span><span id="Presto.Generator-352"><a href="#Presto.Generator-352"><span class="linenos">352</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">is</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span><span class="p">:</span> +</span><span id="Presto.Generator-353"><a href="#Presto.Generator-353"><span class="linenos">353</span></a> <span class="n">end</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">end</span><span class="p">,</span> <span class="n">to</span><span class="p">)</span> +</span><span id="Presto.Generator-354"><a href="#Presto.Generator-354"><span class="linenos">354</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Presto.Generator-355"><a href="#Presto.Generator-355"><span class="linenos">355</span></a> <span class="n">start</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">start</span><span class="p">,</span> <span class="n">to</span><span class="p">)</span> +</span><span id="Presto.Generator-356"><a href="#Presto.Generator-356"><span class="linenos">356</span></a> +</span><span id="Presto.Generator-357"><a href="#Presto.Generator-357"><span class="linenos">357</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">"SEQUENCE"</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span> +</span><span id="Presto.Generator-358"><a href="#Presto.Generator-358"><span class="linenos">358</span></a> +</span><span id="Presto.Generator-359"><a href="#Presto.Generator-359"><span class="linenos">359</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> +</span><span id="Presto.Generator-360"><a href="#Presto.Generator-360"><span class="linenos">360</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> +</span><span id="Presto.Generator-361"><a href="#Presto.Generator-361"><span class="linenos">361</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Presto.Generator-362"><a href="#Presto.Generator-362"><span class="linenos">362</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="Presto.Generator-363"><a href="#Presto.Generator-363"><span class="linenos">363</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> +</span><span id="Presto.Generator-364"><a href="#Presto.Generator-364"><span class="linenos">364</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> +</span><span id="Presto.Generator-365"><a href="#Presto.Generator-365"><span class="linenos">365</span></a> <span class="p">]</span> </span></pre></div> @@ -1010,11 +1018,11 @@ Default: True</li> </div> <a class="headerlink" href="#Presto.Generator.interval_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.interval_sql-330"><a href="#Presto.Generator.interval_sql-330"><span class="linenos">330</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="Presto.Generator.interval_sql-331"><a href="#Presto.Generator.interval_sql-331"><span class="linenos">331</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> -</span><span id="Presto.Generator.interval_sql-332"><a href="#Presto.Generator.interval_sql-332"><span class="linenos">332</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">()</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="Presto.Generator.interval_sql-333"><a href="#Presto.Generator.interval_sql-333"><span class="linenos">333</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> * INTERVAL '7' day)"</span> -</span><span id="Presto.Generator.interval_sql-334"><a href="#Presto.Generator.interval_sql-334"><span class="linenos">334</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="Presto.Generator.interval_sql-326"><a href="#Presto.Generator.interval_sql-326"><span class="linenos">326</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="Presto.Generator.interval_sql-327"><a href="#Presto.Generator.interval_sql-327"><span class="linenos">327</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> +</span><span id="Presto.Generator.interval_sql-328"><a href="#Presto.Generator.interval_sql-328"><span class="linenos">328</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">()</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="Presto.Generator.interval_sql-329"><a href="#Presto.Generator.interval_sql-329"><span class="linenos">329</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> * INTERVAL '7' day)"</span> +</span><span id="Presto.Generator.interval_sql-330"><a href="#Presto.Generator.interval_sql-330"><span class="linenos">330</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> @@ -1032,10 +1040,10 @@ Default: True</li> </div> <a class="headerlink" href="#Presto.Generator.transaction_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.transaction_sql-336"><a href="#Presto.Generator.transaction_sql-336"><span class="linenos">336</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Presto.Generator.transaction_sql-337"><a href="#Presto.Generator.transaction_sql-337"><span class="linenos">337</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modes"</span><span class="p">)</span> -</span><span id="Presto.Generator.transaction_sql-338"><a href="#Presto.Generator.transaction_sql-338"><span class="linenos">338</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">modes</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modes</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Presto.Generator.transaction_sql-339"><a href="#Presto.Generator.transaction_sql-339"><span class="linenos">339</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"START TRANSACTION</span><span class="si">{</span><span class="n">modes</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.transaction_sql-332"><a href="#Presto.Generator.transaction_sql-332"><span class="linenos">332</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Presto.Generator.transaction_sql-333"><a href="#Presto.Generator.transaction_sql-333"><span class="linenos">333</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modes"</span><span class="p">)</span> +</span><span id="Presto.Generator.transaction_sql-334"><a href="#Presto.Generator.transaction_sql-334"><span class="linenos">334</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">modes</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modes</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Presto.Generator.transaction_sql-335"><a href="#Presto.Generator.transaction_sql-335"><span class="linenos">335</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"START TRANSACTION</span><span class="si">{</span><span class="n">modes</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -1053,27 +1061,27 @@ Default: True</li> </div> <a class="headerlink" href="#Presto.Generator.generateseries_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.generateseries_sql-341"><a href="#Presto.Generator.generateseries_sql-341"><span class="linenos">341</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="Presto.Generator.generateseries_sql-342"><a href="#Presto.Generator.generateseries_sql-342"><span class="linenos">342</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"start"</span><span class="p">]</span> -</span><span id="Presto.Generator.generateseries_sql-343"><a href="#Presto.Generator.generateseries_sql-343"><span class="linenos">343</span></a> <span class="n">end</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">"end"</span><span class="p">]</span> -</span><span id="Presto.Generator.generateseries_sql-344"><a href="#Presto.Generator.generateseries_sql-344"><span class="linenos">344</span></a> <span class="n">step</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"step"</span><span class="p">)</span> -</span><span id="Presto.Generator.generateseries_sql-345"><a href="#Presto.Generator.generateseries_sql-345"><span class="linenos">345</span></a> -</span><span id="Presto.Generator.generateseries_sql-346"><a href="#Presto.Generator.generateseries_sql-346"><span class="linenos">346</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="Presto.Generator.generateseries_sql-347"><a href="#Presto.Generator.generateseries_sql-347"><span class="linenos">347</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span> -</span><span id="Presto.Generator.generateseries_sql-348"><a href="#Presto.Generator.generateseries_sql-348"><span class="linenos">348</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="Presto.Generator.generateseries_sql-349"><a href="#Presto.Generator.generateseries_sql-349"><span class="linenos">349</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">end</span><span class="o">.</span><span class="n">to</span> -</span><span id="Presto.Generator.generateseries_sql-350"><a href="#Presto.Generator.generateseries_sql-350"><span class="linenos">350</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Presto.Generator.generateseries_sql-351"><a href="#Presto.Generator.generateseries_sql-351"><span class="linenos">351</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Presto.Generator.generateseries_sql-352"><a href="#Presto.Generator.generateseries_sql-352"><span class="linenos">352</span></a> -</span><span id="Presto.Generator.generateseries_sql-353"><a href="#Presto.Generator.generateseries_sql-353"><span class="linenos">353</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">and</span> <span class="n">target_type</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"timestamp"</span><span class="p">):</span> -</span><span id="Presto.Generator.generateseries_sql-354"><a href="#Presto.Generator.generateseries_sql-354"><span class="linenos">354</span></a> <span class="n">to</span> <span class="o">=</span> <span class="n">target_type</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Presto.Generator.generateseries_sql-355"><a href="#Presto.Generator.generateseries_sql-355"><span class="linenos">355</span></a> -</span><span id="Presto.Generator.generateseries_sql-356"><a href="#Presto.Generator.generateseries_sql-356"><span class="linenos">356</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">is</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span><span class="p">:</span> -</span><span id="Presto.Generator.generateseries_sql-357"><a href="#Presto.Generator.generateseries_sql-357"><span class="linenos">357</span></a> <span class="n">end</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">end</span><span class="p">,</span> <span class="n">to</span><span class="p">)</span> -</span><span id="Presto.Generator.generateseries_sql-358"><a href="#Presto.Generator.generateseries_sql-358"><span class="linenos">358</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Presto.Generator.generateseries_sql-359"><a href="#Presto.Generator.generateseries_sql-359"><span class="linenos">359</span></a> <span class="n">start</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">start</span><span class="p">,</span> <span class="n">to</span><span class="p">)</span> -</span><span id="Presto.Generator.generateseries_sql-360"><a href="#Presto.Generator.generateseries_sql-360"><span class="linenos">360</span></a> -</span><span id="Presto.Generator.generateseries_sql-361"><a href="#Presto.Generator.generateseries_sql-361"><span class="linenos">361</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">"SEQUENCE"</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.generateseries_sql-337"><a href="#Presto.Generator.generateseries_sql-337"><span class="linenos">337</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="Presto.Generator.generateseries_sql-338"><a href="#Presto.Generator.generateseries_sql-338"><span class="linenos">338</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"start"</span><span class="p">]</span> +</span><span id="Presto.Generator.generateseries_sql-339"><a href="#Presto.Generator.generateseries_sql-339"><span class="linenos">339</span></a> <span class="n">end</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">"end"</span><span class="p">]</span> +</span><span id="Presto.Generator.generateseries_sql-340"><a href="#Presto.Generator.generateseries_sql-340"><span class="linenos">340</span></a> <span class="n">step</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"step"</span><span class="p">)</span> +</span><span id="Presto.Generator.generateseries_sql-341"><a href="#Presto.Generator.generateseries_sql-341"><span class="linenos">341</span></a> +</span><span id="Presto.Generator.generateseries_sql-342"><a href="#Presto.Generator.generateseries_sql-342"><span class="linenos">342</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="Presto.Generator.generateseries_sql-343"><a href="#Presto.Generator.generateseries_sql-343"><span class="linenos">343</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span> +</span><span id="Presto.Generator.generateseries_sql-344"><a href="#Presto.Generator.generateseries_sql-344"><span class="linenos">344</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">end</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="Presto.Generator.generateseries_sql-345"><a href="#Presto.Generator.generateseries_sql-345"><span class="linenos">345</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="n">end</span><span class="o">.</span><span class="n">to</span> +</span><span id="Presto.Generator.generateseries_sql-346"><a href="#Presto.Generator.generateseries_sql-346"><span class="linenos">346</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Presto.Generator.generateseries_sql-347"><a href="#Presto.Generator.generateseries_sql-347"><span class="linenos">347</span></a> <span class="n">target_type</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Presto.Generator.generateseries_sql-348"><a href="#Presto.Generator.generateseries_sql-348"><span class="linenos">348</span></a> +</span><span id="Presto.Generator.generateseries_sql-349"><a href="#Presto.Generator.generateseries_sql-349"><span class="linenos">349</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">and</span> <span class="n">target_type</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"timestamp"</span><span class="p">):</span> +</span><span id="Presto.Generator.generateseries_sql-350"><a href="#Presto.Generator.generateseries_sql-350"><span class="linenos">350</span></a> <span class="n">to</span> <span class="o">=</span> <span class="n">target_type</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Presto.Generator.generateseries_sql-351"><a href="#Presto.Generator.generateseries_sql-351"><span class="linenos">351</span></a> +</span><span id="Presto.Generator.generateseries_sql-352"><a href="#Presto.Generator.generateseries_sql-352"><span class="linenos">352</span></a> <span class="k">if</span> <span class="n">target_type</span> <span class="ow">is</span> <span class="n">start</span><span class="o">.</span><span class="n">to</span><span class="p">:</span> +</span><span id="Presto.Generator.generateseries_sql-353"><a href="#Presto.Generator.generateseries_sql-353"><span class="linenos">353</span></a> <span class="n">end</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">end</span><span class="p">,</span> <span class="n">to</span><span class="p">)</span> +</span><span id="Presto.Generator.generateseries_sql-354"><a href="#Presto.Generator.generateseries_sql-354"><span class="linenos">354</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Presto.Generator.generateseries_sql-355"><a href="#Presto.Generator.generateseries_sql-355"><span class="linenos">355</span></a> <span class="n">start</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">start</span><span class="p">,</span> <span class="n">to</span><span class="p">)</span> +</span><span id="Presto.Generator.generateseries_sql-356"><a href="#Presto.Generator.generateseries_sql-356"><span class="linenos">356</span></a> +</span><span id="Presto.Generator.generateseries_sql-357"><a href="#Presto.Generator.generateseries_sql-357"><span class="linenos">357</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">"SEQUENCE"</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span> </span></pre></div> @@ -1091,19 +1099,73 @@ Default: True</li> </div> <a class="headerlink" href="#Presto.Generator.offset_limit_modifiers"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.offset_limit_modifiers-363"><a href="#Presto.Generator.offset_limit_modifiers-363"><span class="linenos">363</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> -</span><span id="Presto.Generator.offset_limit_modifiers-364"><a href="#Presto.Generator.offset_limit_modifiers-364"><span class="linenos">364</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> -</span><span id="Presto.Generator.offset_limit_modifiers-365"><a href="#Presto.Generator.offset_limit_modifiers-365"><span class="linenos">365</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Presto.Generator.offset_limit_modifiers-366"><a href="#Presto.Generator.offset_limit_modifiers-366"><span class="linenos">366</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="Presto.Generator.offset_limit_modifiers-367"><a href="#Presto.Generator.offset_limit_modifiers-367"><span class="linenos">367</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> -</span><span id="Presto.Generator.offset_limit_modifiers-368"><a href="#Presto.Generator.offset_limit_modifiers-368"><span class="linenos">368</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> -</span><span id="Presto.Generator.offset_limit_modifiers-369"><a href="#Presto.Generator.offset_limit_modifiers-369"><span class="linenos">369</span></a> <span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.offset_limit_modifiers-359"><a href="#Presto.Generator.offset_limit_modifiers-359"><span class="linenos">359</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> +</span><span id="Presto.Generator.offset_limit_modifiers-360"><a href="#Presto.Generator.offset_limit_modifiers-360"><span class="linenos">360</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> +</span><span id="Presto.Generator.offset_limit_modifiers-361"><a href="#Presto.Generator.offset_limit_modifiers-361"><span class="linenos">361</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Presto.Generator.offset_limit_modifiers-362"><a href="#Presto.Generator.offset_limit_modifiers-362"><span class="linenos">362</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="Presto.Generator.offset_limit_modifiers-363"><a href="#Presto.Generator.offset_limit_modifiers-363"><span class="linenos">363</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> +</span><span id="Presto.Generator.offset_limit_modifiers-364"><a href="#Presto.Generator.offset_limit_modifiers-364"><span class="linenos">364</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> +</span><span id="Presto.Generator.offset_limit_modifiers-365"><a href="#Presto.Generator.offset_limit_modifiers-365"><span class="linenos">365</span></a> <span class="p">]</span> </span></pre></div> </div> + <div id="Presto.Generator.can_identify" class="classattr"> + <input id="Presto.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="Presto.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Presto.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Presto.Generator.can_identify-247"><a href="#Presto.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="Presto.Generator.can_identify-248"><a href="#Presto.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Presto.Generator.can_identify-249"><a href="#Presto.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="Presto.Generator.can_identify-250"><a href="#Presto.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="Presto.Generator.can_identify-251"><a href="#Presto.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="Presto.Generator.can_identify-252"><a href="#Presto.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="Presto.Generator.can_identify-253"><a href="#Presto.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="Presto.Generator.can_identify-254"><a href="#Presto.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="Presto.Generator.can_identify-255"><a href="#Presto.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="Presto.Generator.can_identify-256"><a href="#Presto.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="Presto.Generator.can_identify-257"><a href="#Presto.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="Presto.Generator.can_identify-258"><a href="#Presto.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="Presto.Generator.can_identify-259"><a href="#Presto.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="Presto.Generator.can_identify-260"><a href="#Presto.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="Presto.Generator.can_identify-261"><a href="#Presto.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Presto.Generator.can_identify-262"><a href="#Presto.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="Presto.Generator.can_identify-263"><a href="#Presto.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="Presto.Generator.can_identify-264"><a href="#Presto.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="Presto.Generator.can_identify-265"><a href="#Presto.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="Presto.Generator.can_identify-266"><a href="#Presto.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -1206,6 +1268,7 @@ Default: True</li> <dd id="Presto.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="Presto.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="Presto.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="Presto.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="Presto.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="Presto.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="Presto.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/dialects/redshift.html b/docs/sqlglot/dialects/redshift.html index dfee18f..4224fdb 100644 --- a/docs/sqlglot/dialects/redshift.html +++ b/docs/sqlglot/dialects/redshift.html @@ -57,6 +57,9 @@ <li> <a class="function" href="#Redshift.Generator.datatype_sql">datatype_sql</a> </li> + <li> + <a class="function" href="#Redshift.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -102,167 +105,170 @@ </span><span id="L-14"><a href="#L-14"><span class="linenos"> 14</span></a> </span><span id="L-15"><a href="#L-15"><span class="linenos"> 15</span></a> </span><span id="L-16"><a href="#L-16"><span class="linenos"> 16</span></a><span class="k">class</span> <span class="nc">Redshift</span><span class="p">(</span><span class="n">Postgres</span><span class="p">):</span> -</span><span id="L-17"><a href="#L-17"><span class="linenos"> 17</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">"'YYYY-MM-DD HH:MI:SS'"</span> -</span><span id="L-18"><a href="#L-18"><span class="linenos"> 18</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-19"><a href="#L-19"><span class="linenos"> 19</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> -</span><span id="L-20"><a href="#L-20"><span class="linenos"> 20</span></a> <span class="s2">"MON"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> -</span><span id="L-21"><a href="#L-21"><span class="linenos"> 21</span></a> <span class="s2">"HH"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> -</span><span id="L-22"><a href="#L-22"><span class="linenos"> 22</span></a> <span class="p">}</span> -</span><span id="L-23"><a href="#L-23"><span class="linenos"> 23</span></a> -</span><span id="L-24"><a href="#L-24"><span class="linenos"> 24</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span> -</span><span id="L-25"><a href="#L-25"><span class="linenos"> 25</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-26"><a href="#L-26"><span class="linenos"> 26</span></a> <span class="o">**</span><span class="n">Postgres</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-27"><a href="#L-27"><span class="linenos"> 27</span></a> <span class="s2">"DATEADD"</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">DateAdd</span><span class="p">(</span> -</span><span id="L-28"><a href="#L-28"><span class="linenos"> 28</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span> -</span><span id="L-29"><a href="#L-29"><span class="linenos"> 29</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-30"><a href="#L-30"><span class="linenos"> 30</span></a> <span class="n">unit</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-31"><a href="#L-31"><span class="linenos"> 31</span></a> <span class="p">),</span> -</span><span id="L-32"><a href="#L-32"><span class="linenos"> 32</span></a> <span class="s2">"DATEDIFF"</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">DateDiff</span><span class="p">(</span> -</span><span id="L-33"><a href="#L-33"><span class="linenos"> 33</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span> -</span><span id="L-34"><a href="#L-34"><span class="linenos"> 34</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span> -</span><span id="L-35"><a href="#L-35"><span class="linenos"> 35</span></a> <span class="n">unit</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-36"><a href="#L-36"><span class="linenos"> 36</span></a> <span class="p">),</span> -</span><span id="L-37"><a href="#L-37"><span class="linenos"> 37</span></a> <span class="s2">"NVL"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Coalesce</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-38"><a href="#L-38"><span class="linenos"> 38</span></a> <span class="s2">"STRTOL"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-39"><a href="#L-39"><span class="linenos"> 39</span></a> <span class="p">}</span> -</span><span id="L-40"><a href="#L-40"><span class="linenos"> 40</span></a> -</span><span id="L-41"><a href="#L-41"><span class="linenos"> 41</span></a> <span class="n">CONVERT_TYPE_FIRST</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-42"><a href="#L-42"><span class="linenos"> 42</span></a> -</span><span id="L-43"><a href="#L-43"><span class="linenos"> 43</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span> -</span><span id="L-44"><a href="#L-44"><span class="linenos"> 44</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</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="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-45"><a href="#L-45"><span class="linenos"> 45</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-46"><a href="#L-46"><span class="linenos"> 46</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="L-47"><a href="#L-47"><span class="linenos"> 47</span></a> -</span><span id="L-48"><a href="#L-48"><span class="linenos"> 48</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="L-49"><a href="#L-49"><span class="linenos"> 49</span></a> <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">DataType</span><span class="p">)</span> -</span><span id="L-50"><a href="#L-50"><span class="linenos"> 50</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"varchar"</span><span class="p">)</span> -</span><span id="L-51"><a href="#L-51"><span class="linenos"> 51</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="L-52"><a href="#L-52"><span class="linenos"> 52</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">)</span> -</span><span id="L-53"><a href="#L-53"><span class="linenos"> 53</span></a> <span class="p">):</span> -</span><span id="L-54"><a href="#L-54"><span class="linenos"> 54</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</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">"MAX"</span><span class="p">)])</span> -</span><span id="L-55"><a href="#L-55"><span class="linenos"> 55</span></a> -</span><span id="L-56"><a href="#L-56"><span class="linenos"> 56</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-57"><a href="#L-57"><span class="linenos"> 57</span></a> -</span><span id="L-58"><a href="#L-58"><span class="linenos"> 58</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span> -</span><span id="L-59"><a href="#L-59"><span class="linenos"> 59</span></a> <span class="n">BIT_STRINGS</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-60"><a href="#L-60"><span class="linenos"> 60</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-61"><a href="#L-61"><span class="linenos"> 61</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">]</span> -</span><span id="L-62"><a href="#L-62"><span class="linenos"> 62</span></a> -</span><span id="L-63"><a href="#L-63"><span class="linenos"> 63</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-64"><a href="#L-64"><span class="linenos"> 64</span></a> <span class="o">**</span><span class="n">Postgres</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-65"><a href="#L-65"><span class="linenos"> 65</span></a> <span class="s2">"HLLSKETCH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HLLSKETCH</span><span class="p">,</span> -</span><span id="L-66"><a href="#L-66"><span class="linenos"> 66</span></a> <span class="s2">"SUPER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SUPER</span><span class="p">,</span> -</span><span id="L-67"><a href="#L-67"><span class="linenos"> 67</span></a> <span class="s2">"SYSDATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIMESTAMP</span><span class="p">,</span> -</span><span id="L-68"><a href="#L-68"><span class="linenos"> 68</span></a> <span class="s2">"TIME"</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-69"><a href="#L-69"><span class="linenos"> 69</span></a> <span class="s2">"TIMETZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> -</span><span id="L-70"><a href="#L-70"><span class="linenos"> 70</span></a> <span class="s2">"TOP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TOP</span><span class="p">,</span> -</span><span id="L-71"><a href="#L-71"><span class="linenos"> 71</span></a> <span class="s2">"UNLOAD"</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-72"><a href="#L-72"><span class="linenos"> 72</span></a> <span class="s2">"VARBYTE"</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-73"><a href="#L-73"><span class="linenos"> 73</span></a> <span class="p">}</span> -</span><span id="L-74"><a href="#L-74"><span class="linenos"> 74</span></a> -</span><span id="L-75"><a href="#L-75"><span class="linenos"> 75</span></a> <span class="c1"># Redshift allows # to appear as a table identifier prefix</span> -</span><span id="L-76"><a href="#L-76"><span class="linenos"> 76</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="L-77"><a href="#L-77"><span class="linenos"> 77</span></a> <span class="n">SINGLE_TOKENS</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-78"><a href="#L-78"><span class="linenos"> 78</span></a> -</span><span id="L-79"><a href="#L-79"><span class="linenos"> 79</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> -</span><span id="L-80"><a href="#L-80"><span class="linenos"> 80</span></a> <span class="n">LOCKING_READS_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-81"><a href="#L-81"><span class="linenos"> 81</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-82"><a href="#L-82"><span class="linenos"> 82</span></a> -</span><span id="L-83"><a href="#L-83"><span class="linenos"> 83</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-84"><a href="#L-84"><span class="linenos"> 84</span></a> <span class="o">**</span><span class="n">Postgres</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-85"><a href="#L-85"><span class="linenos"> 85</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">"VARBYTE"</span><span class="p">,</span> -</span><span id="L-86"><a href="#L-86"><span class="linenos"> 86</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">"VARBYTE"</span><span class="p">,</span> -</span><span id="L-87"><a href="#L-87"><span class="linenos"> 87</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">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="L-88"><a href="#L-88"><span class="linenos"> 88</span></a> <span class="p">}</span> -</span><span id="L-89"><a href="#L-89"><span class="linenos"> 89</span></a> -</span><span id="L-90"><a href="#L-90"><span class="linenos"> 90</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-91"><a href="#L-91"><span class="linenos"> 91</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="L-92"><a href="#L-92"><span class="linenos"> 92</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> -</span><span id="L-93"><a href="#L-93"><span class="linenos"> 93</span></a> <span class="p">}</span> -</span><span id="L-94"><a href="#L-94"><span class="linenos"> 94</span></a> -</span><span id="L-95"><a href="#L-95"><span class="linenos"> 95</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> <span class="o">**</span><span class="n">Postgres</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-97"><a href="#L-97"><span class="linenos"> 97</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> -</span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"SYSDATE"</span><span class="p">,</span> -</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</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-100"><a href="#L-100"><span class="linenos">100</span></a> <span class="s2">"DATEADD"</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="n">e</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="ow">or</span> <span class="s2">"day"</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-101"><a href="#L-101"><span class="linenos">101</span></a> <span class="p">),</span> -</span><span id="L-102"><a href="#L-102"><span class="linenos">102</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-103"><a href="#L-103"><span class="linenos">103</span></a> <span class="s2">"DATEDIFF"</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="n">e</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="ow">or</span> <span class="s2">"day"</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-17"><a href="#L-17"><span class="linenos"> 17</span></a> <span class="c1"># https://docs.aws.amazon.com/redshift/latest/dg/r_names.html</span> +</span><span id="L-18"><a href="#L-18"><span class="linenos"> 18</span></a> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-19"><a href="#L-19"><span class="linenos"> 19</span></a> +</span><span id="L-20"><a href="#L-20"><span class="linenos"> 20</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">"'YYYY-MM-DD HH:MI:SS'"</span> +</span><span id="L-21"><a href="#L-21"><span class="linenos"> 21</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-22"><a href="#L-22"><span class="linenos"> 22</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> +</span><span id="L-23"><a href="#L-23"><span class="linenos"> 23</span></a> <span class="s2">"MON"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> +</span><span id="L-24"><a href="#L-24"><span class="linenos"> 24</span></a> <span class="s2">"HH"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> +</span><span id="L-25"><a href="#L-25"><span class="linenos"> 25</span></a> <span class="p">}</span> +</span><span id="L-26"><a href="#L-26"><span class="linenos"> 26</span></a> +</span><span id="L-27"><a href="#L-27"><span class="linenos"> 27</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span> +</span><span id="L-28"><a href="#L-28"><span class="linenos"> 28</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-29"><a href="#L-29"><span class="linenos"> 29</span></a> <span class="o">**</span><span class="n">Postgres</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-30"><a href="#L-30"><span class="linenos"> 30</span></a> <span class="s2">"DATEADD"</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">DateAdd</span><span class="p">(</span> +</span><span id="L-31"><a href="#L-31"><span class="linenos"> 31</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span> +</span><span id="L-32"><a href="#L-32"><span class="linenos"> 32</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-33"><a href="#L-33"><span class="linenos"> 33</span></a> <span class="n">unit</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-34"><a href="#L-34"><span class="linenos"> 34</span></a> <span class="p">),</span> +</span><span id="L-35"><a href="#L-35"><span class="linenos"> 35</span></a> <span class="s2">"DATEDIFF"</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">DateDiff</span><span class="p">(</span> +</span><span id="L-36"><a href="#L-36"><span class="linenos"> 36</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span> +</span><span id="L-37"><a href="#L-37"><span class="linenos"> 37</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span> +</span><span id="L-38"><a href="#L-38"><span class="linenos"> 38</span></a> <span class="n">unit</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-39"><a href="#L-39"><span class="linenos"> 39</span></a> <span class="p">),</span> +</span><span id="L-40"><a href="#L-40"><span class="linenos"> 40</span></a> <span class="s2">"NVL"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Coalesce</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-41"><a href="#L-41"><span class="linenos"> 41</span></a> <span class="s2">"STRTOL"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-42"><a href="#L-42"><span class="linenos"> 42</span></a> <span class="p">}</span> +</span><span id="L-43"><a href="#L-43"><span class="linenos"> 43</span></a> +</span><span id="L-44"><a href="#L-44"><span class="linenos"> 44</span></a> <span class="n">CONVERT_TYPE_FIRST</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-45"><a href="#L-45"><span class="linenos"> 45</span></a> +</span><span id="L-46"><a href="#L-46"><span class="linenos"> 46</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span> +</span><span id="L-47"><a href="#L-47"><span class="linenos"> 47</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</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="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-48"><a href="#L-48"><span class="linenos"> 48</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-49"><a href="#L-49"><span class="linenos"> 49</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="L-50"><a href="#L-50"><span class="linenos"> 50</span></a> +</span><span id="L-51"><a href="#L-51"><span class="linenos"> 51</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="L-52"><a href="#L-52"><span class="linenos"> 52</span></a> <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">DataType</span><span class="p">)</span> +</span><span id="L-53"><a href="#L-53"><span class="linenos"> 53</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"varchar"</span><span class="p">)</span> +</span><span id="L-54"><a href="#L-54"><span class="linenos"> 54</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="L-55"><a href="#L-55"><span class="linenos"> 55</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">)</span> +</span><span id="L-56"><a href="#L-56"><span class="linenos"> 56</span></a> <span class="p">):</span> +</span><span id="L-57"><a href="#L-57"><span class="linenos"> 57</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</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">"MAX"</span><span class="p">)])</span> +</span><span id="L-58"><a href="#L-58"><span class="linenos"> 58</span></a> +</span><span id="L-59"><a href="#L-59"><span class="linenos"> 59</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-60"><a href="#L-60"><span class="linenos"> 60</span></a> +</span><span id="L-61"><a href="#L-61"><span class="linenos"> 61</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span> +</span><span id="L-62"><a href="#L-62"><span class="linenos"> 62</span></a> <span class="n">BIT_STRINGS</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-63"><a href="#L-63"><span class="linenos"> 63</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-64"><a href="#L-64"><span class="linenos"> 64</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">]</span> +</span><span id="L-65"><a href="#L-65"><span class="linenos"> 65</span></a> +</span><span id="L-66"><a href="#L-66"><span class="linenos"> 66</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-67"><a href="#L-67"><span class="linenos"> 67</span></a> <span class="o">**</span><span class="n">Postgres</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-68"><a href="#L-68"><span class="linenos"> 68</span></a> <span class="s2">"HLLSKETCH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HLLSKETCH</span><span class="p">,</span> +</span><span id="L-69"><a href="#L-69"><span class="linenos"> 69</span></a> <span class="s2">"SUPER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SUPER</span><span class="p">,</span> +</span><span id="L-70"><a href="#L-70"><span class="linenos"> 70</span></a> <span class="s2">"SYSDATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIMESTAMP</span><span class="p">,</span> +</span><span id="L-71"><a href="#L-71"><span class="linenos"> 71</span></a> <span class="s2">"TIME"</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-72"><a href="#L-72"><span class="linenos"> 72</span></a> <span class="s2">"TIMETZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> +</span><span id="L-73"><a href="#L-73"><span class="linenos"> 73</span></a> <span class="s2">"TOP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TOP</span><span class="p">,</span> +</span><span id="L-74"><a href="#L-74"><span class="linenos"> 74</span></a> <span class="s2">"UNLOAD"</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-75"><a href="#L-75"><span class="linenos"> 75</span></a> <span class="s2">"VARBYTE"</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-76"><a href="#L-76"><span class="linenos"> 76</span></a> <span class="p">}</span> +</span><span id="L-77"><a href="#L-77"><span class="linenos"> 77</span></a> +</span><span id="L-78"><a href="#L-78"><span class="linenos"> 78</span></a> <span class="c1"># Redshift allows # to appear as a table identifier prefix</span> +</span><span id="L-79"><a href="#L-79"><span class="linenos"> 79</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="L-80"><a href="#L-80"><span class="linenos"> 80</span></a> <span class="n">SINGLE_TOKENS</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-81"><a href="#L-81"><span class="linenos"> 81</span></a> +</span><span id="L-82"><a href="#L-82"><span class="linenos"> 82</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> +</span><span id="L-83"><a href="#L-83"><span class="linenos"> 83</span></a> <span class="n">LOCKING_READS_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-84"><a href="#L-84"><span class="linenos"> 84</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-85"><a href="#L-85"><span class="linenos"> 85</span></a> +</span><span id="L-86"><a href="#L-86"><span class="linenos"> 86</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-87"><a href="#L-87"><span class="linenos"> 87</span></a> <span class="o">**</span><span class="n">Postgres</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-88"><a href="#L-88"><span class="linenos"> 88</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">"VARBYTE"</span><span class="p">,</span> +</span><span id="L-89"><a href="#L-89"><span class="linenos"> 89</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">"VARBYTE"</span><span class="p">,</span> +</span><span id="L-90"><a href="#L-90"><span class="linenos"> 90</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">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="L-91"><a href="#L-91"><span class="linenos"> 91</span></a> <span class="p">}</span> +</span><span id="L-92"><a href="#L-92"><span class="linenos"> 92</span></a> +</span><span id="L-93"><a href="#L-93"><span class="linenos"> 93</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-94"><a href="#L-94"><span class="linenos"> 94</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="L-95"><a href="#L-95"><span class="linenos"> 95</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> +</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> <span class="p">}</span> +</span><span id="L-97"><a href="#L-97"><span class="linenos"> 97</span></a> +</span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a> <span class="o">**</span><span class="n">Postgres</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-100"><a href="#L-100"><span class="linenos">100</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> +</span><span id="L-101"><a href="#L-101"><span class="linenos">101</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"SYSDATE"</span><span class="p">,</span> +</span><span id="L-102"><a href="#L-102"><span class="linenos">102</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</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-103"><a href="#L-103"><span class="linenos">103</span></a> <span class="s2">"DATEADD"</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="n">e</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="ow">or</span> <span class="s2">"day"</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-104"><a href="#L-104"><span class="linenos">104</span></a> <span class="p">),</span> -</span><span id="L-105"><a href="#L-105"><span class="linenos">105</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</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">"DISTKEY(</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-106"><a href="#L-106"><span class="linenos">106</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="L-107"><a href="#L-107"><span class="linenos">107</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRTOL"</span><span class="p">),</span> -</span><span id="L-108"><a href="#L-108"><span class="linenos">108</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span> -</span><span id="L-109"><a href="#L-109"><span class="linenos">109</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span> -</span><span id="L-110"><a href="#L-110"><span class="linenos">110</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> -</span><span id="L-111"><a href="#L-111"><span class="linenos">111</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</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">eliminate_distinct_on</span><span class="p">]),</span> -</span><span id="L-112"><a href="#L-112"><span class="linenos">112</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</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">"</span><span class="si">{</span><span class="s1">'COMPOUND '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">'compound'</span><span class="p">]</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">SORTKEY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-113"><a href="#L-113"><span class="linenos">113</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</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="o">.</span><span class="n">this</span><span class="p">),</span> -</span><span id="L-114"><a href="#L-114"><span class="linenos">114</span></a> <span class="p">}</span> -</span><span id="L-115"><a href="#L-115"><span class="linenos">115</span></a> -</span><span id="L-116"><a href="#L-116"><span class="linenos">116</span></a> <span class="c1"># Postgres maps exp.Pivot to no_pivot_sql, but Redshift support pivots</span> -</span><span id="L-117"><a href="#L-117"><span class="linenos">117</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> +</span><span id="L-105"><a href="#L-105"><span class="linenos">105</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-106"><a href="#L-106"><span class="linenos">106</span></a> <span class="s2">"DATEDIFF"</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="n">e</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="ow">or</span> <span class="s2">"day"</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-107"><a href="#L-107"><span class="linenos">107</span></a> <span class="p">),</span> +</span><span id="L-108"><a href="#L-108"><span class="linenos">108</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</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">"DISTKEY(</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-109"><a href="#L-109"><span class="linenos">109</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="L-110"><a href="#L-110"><span class="linenos">110</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRTOL"</span><span class="p">),</span> +</span><span id="L-111"><a href="#L-111"><span class="linenos">111</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span> +</span><span id="L-112"><a href="#L-112"><span class="linenos">112</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span> +</span><span id="L-113"><a href="#L-113"><span class="linenos">113</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> +</span><span id="L-114"><a href="#L-114"><span class="linenos">114</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</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">eliminate_distinct_on</span><span class="p">]),</span> +</span><span id="L-115"><a href="#L-115"><span class="linenos">115</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</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">"</span><span class="si">{</span><span class="s1">'COMPOUND '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">'compound'</span><span class="p">]</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">SORTKEY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-116"><a href="#L-116"><span class="linenos">116</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</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="o">.</span><span class="n">this</span><span class="p">),</span> +</span><span id="L-117"><a href="#L-117"><span class="linenos">117</span></a> <span class="p">}</span> </span><span id="L-118"><a href="#L-118"><span class="linenos">118</span></a> -</span><span id="L-119"><a href="#L-119"><span class="linenos">119</span></a> <span class="c1"># Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)</span> -</span><span id="L-120"><a href="#L-120"><span class="linenos">120</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">)</span> +</span><span id="L-119"><a href="#L-119"><span class="linenos">119</span></a> <span class="c1"># Postgres maps exp.Pivot to no_pivot_sql, but Redshift support pivots</span> +</span><span id="L-120"><a href="#L-120"><span class="linenos">120</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> </span><span id="L-121"><a href="#L-121"><span class="linenos">121</span></a> -</span><span id="L-122"><a href="#L-122"><span class="linenos">122</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span><span class="p">,</span> <span class="s2">"snapshot"</span><span class="p">,</span> <span class="s2">"type"</span><span class="p">}</span> -</span><span id="L-123"><a href="#L-123"><span class="linenos">123</span></a> -</span><span id="L-124"><a href="#L-124"><span class="linenos">124</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-125"><a href="#L-125"><span class="linenos">125</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-126"><a href="#L-126"><span class="linenos">126</span></a><span class="sd"> Converts `VALUES...` expression into a series of unions.</span> -</span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a> -</span><span id="L-128"><a href="#L-128"><span class="linenos">128</span></a><span class="sd"> Note: If you have a lot of unions then this will result in a large number of recursive statements to</span> -</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a><span class="sd"> evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be</span> -</span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a><span class="sd"> very slow.</span> -</span><span id="L-131"><a href="#L-131"><span class="linenos">131</span></a><span class="sd"> """</span> -</span><span id="L-132"><a href="#L-132"><span class="linenos">132</span></a> -</span><span id="L-133"><a href="#L-133"><span class="linenos">133</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span> -</span><span id="L-134"><a href="#L-134"><span class="linenos">134</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> -</span><span id="L-135"><a href="#L-135"><span class="linenos">135</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">values_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-136"><a href="#L-136"><span class="linenos">136</span></a> -</span><span id="L-137"><a href="#L-137"><span class="linenos">137</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"alias"</span><span class="p">]</span><span class="o">.</span><span class="n">columns</span> -</span><span id="L-138"><a href="#L-138"><span class="linenos">138</span></a> -</span><span id="L-139"><a href="#L-139"><span class="linenos">139</span></a> <span class="n">selects</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-140"><a href="#L-140"><span class="linenos">140</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="p">[</span><span class="n">tuple_exp</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">tuple_exp</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">]</span> +</span><span id="L-122"><a href="#L-122"><span class="linenos">122</span></a> <span class="c1"># Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)</span> +</span><span id="L-123"><a href="#L-123"><span class="linenos">123</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">)</span> +</span><span id="L-124"><a href="#L-124"><span class="linenos">124</span></a> +</span><span id="L-125"><a href="#L-125"><span class="linenos">125</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span><span class="p">,</span> <span class="s2">"snapshot"</span><span class="p">,</span> <span class="s2">"type"</span><span class="p">}</span> +</span><span id="L-126"><a href="#L-126"><span class="linenos">126</span></a> +</span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-128"><a href="#L-128"><span class="linenos">128</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a><span class="sd"> Converts `VALUES...` expression into a series of unions.</span> +</span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a> +</span><span id="L-131"><a href="#L-131"><span class="linenos">131</span></a><span class="sd"> Note: If you have a lot of unions then this will result in a large number of recursive statements to</span> +</span><span id="L-132"><a href="#L-132"><span class="linenos">132</span></a><span class="sd"> evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be</span> +</span><span id="L-133"><a href="#L-133"><span class="linenos">133</span></a><span class="sd"> very slow.</span> +</span><span id="L-134"><a href="#L-134"><span class="linenos">134</span></a><span class="sd"> """</span> +</span><span id="L-135"><a href="#L-135"><span class="linenos">135</span></a> +</span><span id="L-136"><a href="#L-136"><span class="linenos">136</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span> +</span><span id="L-137"><a href="#L-137"><span class="linenos">137</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> +</span><span id="L-138"><a href="#L-138"><span class="linenos">138</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">values_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-139"><a href="#L-139"><span class="linenos">139</span></a> +</span><span id="L-140"><a href="#L-140"><span class="linenos">140</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"alias"</span><span class="p">]</span><span class="o">.</span><span class="n">columns</span> </span><span id="L-141"><a href="#L-141"><span class="linenos">141</span></a> -</span><span id="L-142"><a href="#L-142"><span class="linenos">142</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">row</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">rows</span><span class="p">):</span> -</span><span id="L-143"><a href="#L-143"><span class="linenos">143</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span> -</span><span id="L-144"><a href="#L-144"><span class="linenos">144</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span> -</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span> -</span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a> <span class="p">]</span> -</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a> -</span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span> -</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> -</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> <span class="n">subquery_expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> <span class="o">=</span> <span class="n">selects</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">selects</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span> -</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> <span class="n">subquery_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">subquery_expression</span><span class="p">,</span> <span class="n">select</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> -</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span><span class="n">subquery_expression</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">))</span> -</span><span id="L-157"><a href="#L-157"><span class="linenos">157</span></a> -</span><span id="L-158"><a href="#L-158"><span class="linenos">158</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-159"><a href="#L-159"><span class="linenos">159</span></a><span class="w"> </span><span class="sd">"""Redshift doesn't have `WITH` as part of their with_properties so we remove it"""</span> -</span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> -</span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-163"><a href="#L-163"><span class="linenos">163</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-164"><a href="#L-164"><span class="linenos">164</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span> -</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span> -</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span> -</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span> -</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a><span class="sd"> """</span> -</span><span id="L-169"><a href="#L-169"><span class="linenos">169</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">"text"</span><span class="p">):</span> -</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="n">expression</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">exp</span><span 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-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> -</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> -</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span> -</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">))</span> +</span><span id="L-142"><a href="#L-142"><span class="linenos">142</span></a> <span class="n">selects</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-143"><a href="#L-143"><span class="linenos">143</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="p">[</span><span class="n">tuple_exp</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">tuple_exp</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">]</span> +</span><span id="L-144"><a href="#L-144"><span class="linenos">144</span></a> +</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">row</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">rows</span><span class="p">):</span> +</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span> +</span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span> +</span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span> +</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="p">]</span> +</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> +</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span> +</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> +</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> <span class="n">subquery_expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> <span class="o">=</span> <span class="n">selects</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">selects</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span> +</span><span id="L-157"><a href="#L-157"><span class="linenos">157</span></a> <span class="n">subquery_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">subquery_expression</span><span class="p">,</span> <span class="n">select</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</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">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span><span class="n">subquery_expression</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">))</span> +</span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a> +</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a><span class="w"> </span><span class="sd">"""Redshift doesn't have `WITH` as part of their with_properties so we remove it"""</span> +</span><span id="L-163"><a href="#L-163"><span class="linenos">163</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> +</span><span id="L-164"><a href="#L-164"><span class="linenos">164</span></a> +</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span> +</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span> +</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span> +</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span> +</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a><span class="sd"> """</span> +</span><span id="L-172"><a href="#L-172"><span class="linenos">172</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">"text"</span><span class="p">):</span> +</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="n">expression</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">exp</span><span 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-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> </span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> -</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span> +</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">))</span> +</span><span id="L-179"><a href="#L-179"><span class="linenos">179</span></a> +</span><span id="L-180"><a href="#L-180"><span class="linenos">180</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -279,167 +285,170 @@ </div> <a class="headerlink" href="#Redshift"></a> <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift-17"><a href="#Redshift-17"><span class="linenos"> 17</span></a><span class="k">class</span> <span class="nc">Redshift</span><span class="p">(</span><span class="n">Postgres</span><span class="p">):</span> -</span><span id="Redshift-18"><a href="#Redshift-18"><span class="linenos"> 18</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">"'YYYY-MM-DD HH:MI:SS'"</span> -</span><span id="Redshift-19"><a href="#Redshift-19"><span class="linenos"> 19</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Redshift-20"><a href="#Redshift-20"><span class="linenos"> 20</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> -</span><span id="Redshift-21"><a href="#Redshift-21"><span class="linenos"> 21</span></a> <span class="s2">"MON"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> -</span><span id="Redshift-22"><a href="#Redshift-22"><span class="linenos"> 22</span></a> <span class="s2">"HH"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> -</span><span id="Redshift-23"><a href="#Redshift-23"><span class="linenos"> 23</span></a> <span class="p">}</span> -</span><span id="Redshift-24"><a href="#Redshift-24"><span class="linenos"> 24</span></a> -</span><span id="Redshift-25"><a href="#Redshift-25"><span class="linenos"> 25</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span> -</span><span id="Redshift-26"><a href="#Redshift-26"><span class="linenos"> 26</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Redshift-27"><a href="#Redshift-27"><span class="linenos"> 27</span></a> <span class="o">**</span><span class="n">Postgres</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="Redshift-28"><a href="#Redshift-28"><span class="linenos"> 28</span></a> <span class="s2">"DATEADD"</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">DateAdd</span><span class="p">(</span> -</span><span id="Redshift-29"><a href="#Redshift-29"><span class="linenos"> 29</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span> -</span><span id="Redshift-30"><a href="#Redshift-30"><span class="linenos"> 30</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="Redshift-31"><a href="#Redshift-31"><span class="linenos"> 31</span></a> <span class="n">unit</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="Redshift-32"><a href="#Redshift-32"><span class="linenos"> 32</span></a> <span class="p">),</span> -</span><span id="Redshift-33"><a href="#Redshift-33"><span class="linenos"> 33</span></a> <span class="s2">"DATEDIFF"</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">DateDiff</span><span class="p">(</span> -</span><span id="Redshift-34"><a href="#Redshift-34"><span class="linenos"> 34</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span> -</span><span id="Redshift-35"><a href="#Redshift-35"><span class="linenos"> 35</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span> -</span><span id="Redshift-36"><a href="#Redshift-36"><span class="linenos"> 36</span></a> <span class="n">unit</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="Redshift-37"><a href="#Redshift-37"><span class="linenos"> 37</span></a> <span class="p">),</span> -</span><span id="Redshift-38"><a href="#Redshift-38"><span class="linenos"> 38</span></a> <span class="s2">"NVL"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Coalesce</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Redshift-39"><a href="#Redshift-39"><span class="linenos"> 39</span></a> <span class="s2">"STRTOL"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Redshift-40"><a href="#Redshift-40"><span class="linenos"> 40</span></a> <span class="p">}</span> -</span><span id="Redshift-41"><a href="#Redshift-41"><span class="linenos"> 41</span></a> -</span><span id="Redshift-42"><a href="#Redshift-42"><span class="linenos"> 42</span></a> <span class="n">CONVERT_TYPE_FIRST</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Redshift-43"><a href="#Redshift-43"><span class="linenos"> 43</span></a> -</span><span id="Redshift-44"><a href="#Redshift-44"><span class="linenos"> 44</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span> -</span><span id="Redshift-45"><a href="#Redshift-45"><span class="linenos"> 45</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</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="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Redshift-46"><a href="#Redshift-46"><span class="linenos"> 46</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="Redshift-47"><a href="#Redshift-47"><span class="linenos"> 47</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="Redshift-48"><a href="#Redshift-48"><span class="linenos"> 48</span></a> -</span><span id="Redshift-49"><a href="#Redshift-49"><span class="linenos"> 49</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="Redshift-50"><a href="#Redshift-50"><span class="linenos"> 50</span></a> <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">DataType</span><span class="p">)</span> -</span><span id="Redshift-51"><a href="#Redshift-51"><span class="linenos"> 51</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"varchar"</span><span class="p">)</span> -</span><span id="Redshift-52"><a href="#Redshift-52"><span class="linenos"> 52</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="Redshift-53"><a href="#Redshift-53"><span class="linenos"> 53</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">)</span> -</span><span id="Redshift-54"><a href="#Redshift-54"><span class="linenos"> 54</span></a> <span class="p">):</span> -</span><span id="Redshift-55"><a href="#Redshift-55"><span class="linenos"> 55</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</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">"MAX"</span><span class="p">)])</span> -</span><span id="Redshift-56"><a href="#Redshift-56"><span class="linenos"> 56</span></a> -</span><span id="Redshift-57"><a href="#Redshift-57"><span class="linenos"> 57</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Redshift-58"><a href="#Redshift-58"><span class="linenos"> 58</span></a> -</span><span id="Redshift-59"><a href="#Redshift-59"><span class="linenos"> 59</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span> -</span><span id="Redshift-60"><a href="#Redshift-60"><span class="linenos"> 60</span></a> <span class="n">BIT_STRINGS</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Redshift-61"><a href="#Redshift-61"><span class="linenos"> 61</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Redshift-62"><a href="#Redshift-62"><span class="linenos"> 62</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">]</span> -</span><span id="Redshift-63"><a href="#Redshift-63"><span class="linenos"> 63</span></a> -</span><span id="Redshift-64"><a href="#Redshift-64"><span class="linenos"> 64</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Redshift-65"><a href="#Redshift-65"><span class="linenos"> 65</span></a> <span class="o">**</span><span class="n">Postgres</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="Redshift-66"><a href="#Redshift-66"><span class="linenos"> 66</span></a> <span class="s2">"HLLSKETCH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HLLSKETCH</span><span class="p">,</span> -</span><span id="Redshift-67"><a href="#Redshift-67"><span class="linenos"> 67</span></a> <span class="s2">"SUPER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SUPER</span><span class="p">,</span> -</span><span id="Redshift-68"><a href="#Redshift-68"><span class="linenos"> 68</span></a> <span class="s2">"SYSDATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIMESTAMP</span><span class="p">,</span> -</span><span id="Redshift-69"><a href="#Redshift-69"><span class="linenos"> 69</span></a> <span class="s2">"TIME"</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="Redshift-70"><a href="#Redshift-70"><span class="linenos"> 70</span></a> <span class="s2">"TIMETZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> -</span><span id="Redshift-71"><a href="#Redshift-71"><span class="linenos"> 71</span></a> <span class="s2">"TOP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TOP</span><span class="p">,</span> -</span><span id="Redshift-72"><a href="#Redshift-72"><span class="linenos"> 72</span></a> <span class="s2">"UNLOAD"</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="Redshift-73"><a href="#Redshift-73"><span class="linenos"> 73</span></a> <span class="s2">"VARBYTE"</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="Redshift-74"><a href="#Redshift-74"><span class="linenos"> 74</span></a> <span class="p">}</span> -</span><span id="Redshift-75"><a href="#Redshift-75"><span class="linenos"> 75</span></a> -</span><span id="Redshift-76"><a href="#Redshift-76"><span class="linenos"> 76</span></a> <span class="c1"># Redshift allows # to appear as a table identifier prefix</span> -</span><span id="Redshift-77"><a href="#Redshift-77"><span class="linenos"> 77</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Redshift-78"><a href="#Redshift-78"><span class="linenos"> 78</span></a> <span class="n">SINGLE_TOKENS</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="Redshift-79"><a href="#Redshift-79"><span class="linenos"> 79</span></a> -</span><span id="Redshift-80"><a href="#Redshift-80"><span class="linenos"> 80</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> -</span><span id="Redshift-81"><a href="#Redshift-81"><span class="linenos"> 81</span></a> <span class="n">LOCKING_READS_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Redshift-82"><a href="#Redshift-82"><span class="linenos"> 82</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Redshift-83"><a href="#Redshift-83"><span class="linenos"> 83</span></a> -</span><span id="Redshift-84"><a href="#Redshift-84"><span class="linenos"> 84</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Redshift-85"><a href="#Redshift-85"><span class="linenos"> 85</span></a> <span class="o">**</span><span class="n">Postgres</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="Redshift-86"><a href="#Redshift-86"><span class="linenos"> 86</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">"VARBYTE"</span><span class="p">,</span> -</span><span id="Redshift-87"><a href="#Redshift-87"><span class="linenos"> 87</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">"VARBYTE"</span><span class="p">,</span> -</span><span id="Redshift-88"><a href="#Redshift-88"><span class="linenos"> 88</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">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="Redshift-89"><a href="#Redshift-89"><span class="linenos"> 89</span></a> <span class="p">}</span> -</span><span id="Redshift-90"><a href="#Redshift-90"><span class="linenos"> 90</span></a> -</span><span id="Redshift-91"><a href="#Redshift-91"><span class="linenos"> 91</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Redshift-92"><a href="#Redshift-92"><span class="linenos"> 92</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="Redshift-93"><a href="#Redshift-93"><span class="linenos"> 93</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> -</span><span id="Redshift-94"><a href="#Redshift-94"><span class="linenos"> 94</span></a> <span class="p">}</span> -</span><span id="Redshift-95"><a href="#Redshift-95"><span class="linenos"> 95</span></a> -</span><span id="Redshift-96"><a href="#Redshift-96"><span class="linenos"> 96</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Redshift-97"><a href="#Redshift-97"><span class="linenos"> 97</span></a> <span class="o">**</span><span class="n">Postgres</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="Redshift-98"><a href="#Redshift-98"><span class="linenos"> 98</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> -</span><span id="Redshift-99"><a href="#Redshift-99"><span class="linenos"> 99</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"SYSDATE"</span><span class="p">,</span> -</span><span id="Redshift-100"><a href="#Redshift-100"><span class="linenos">100</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</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="Redshift-101"><a href="#Redshift-101"><span class="linenos">101</span></a> <span class="s2">"DATEADD"</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="n">e</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="ow">or</span> <span class="s2">"day"</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="Redshift-102"><a href="#Redshift-102"><span class="linenos">102</span></a> <span class="p">),</span> -</span><span id="Redshift-103"><a href="#Redshift-103"><span class="linenos">103</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="Redshift-104"><a href="#Redshift-104"><span class="linenos">104</span></a> <span class="s2">"DATEDIFF"</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="n">e</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="ow">or</span> <span class="s2">"day"</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="Redshift-18"><a href="#Redshift-18"><span class="linenos"> 18</span></a> <span class="c1"># https://docs.aws.amazon.com/redshift/latest/dg/r_names.html</span> +</span><span id="Redshift-19"><a href="#Redshift-19"><span class="linenos"> 19</span></a> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Redshift-20"><a href="#Redshift-20"><span class="linenos"> 20</span></a> +</span><span id="Redshift-21"><a href="#Redshift-21"><span class="linenos"> 21</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">"'YYYY-MM-DD HH:MI:SS'"</span> +</span><span id="Redshift-22"><a href="#Redshift-22"><span class="linenos"> 22</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Redshift-23"><a href="#Redshift-23"><span class="linenos"> 23</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> +</span><span id="Redshift-24"><a href="#Redshift-24"><span class="linenos"> 24</span></a> <span class="s2">"MON"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> +</span><span id="Redshift-25"><a href="#Redshift-25"><span class="linenos"> 25</span></a> <span class="s2">"HH"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> +</span><span id="Redshift-26"><a href="#Redshift-26"><span class="linenos"> 26</span></a> <span class="p">}</span> +</span><span id="Redshift-27"><a href="#Redshift-27"><span class="linenos"> 27</span></a> +</span><span id="Redshift-28"><a href="#Redshift-28"><span class="linenos"> 28</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span> +</span><span id="Redshift-29"><a href="#Redshift-29"><span class="linenos"> 29</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Redshift-30"><a href="#Redshift-30"><span class="linenos"> 30</span></a> <span class="o">**</span><span class="n">Postgres</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="Redshift-31"><a href="#Redshift-31"><span class="linenos"> 31</span></a> <span class="s2">"DATEADD"</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">DateAdd</span><span class="p">(</span> +</span><span id="Redshift-32"><a href="#Redshift-32"><span class="linenos"> 32</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span> +</span><span id="Redshift-33"><a href="#Redshift-33"><span class="linenos"> 33</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="Redshift-34"><a href="#Redshift-34"><span class="linenos"> 34</span></a> <span class="n">unit</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="Redshift-35"><a href="#Redshift-35"><span class="linenos"> 35</span></a> <span class="p">),</span> +</span><span id="Redshift-36"><a href="#Redshift-36"><span class="linenos"> 36</span></a> <span class="s2">"DATEDIFF"</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">DateDiff</span><span class="p">(</span> +</span><span id="Redshift-37"><a href="#Redshift-37"><span class="linenos"> 37</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span> +</span><span id="Redshift-38"><a href="#Redshift-38"><span class="linenos"> 38</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span> +</span><span id="Redshift-39"><a href="#Redshift-39"><span class="linenos"> 39</span></a> <span class="n">unit</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="Redshift-40"><a href="#Redshift-40"><span class="linenos"> 40</span></a> <span class="p">),</span> +</span><span id="Redshift-41"><a href="#Redshift-41"><span class="linenos"> 41</span></a> <span class="s2">"NVL"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Coalesce</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Redshift-42"><a href="#Redshift-42"><span class="linenos"> 42</span></a> <span class="s2">"STRTOL"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Redshift-43"><a href="#Redshift-43"><span class="linenos"> 43</span></a> <span class="p">}</span> +</span><span id="Redshift-44"><a href="#Redshift-44"><span class="linenos"> 44</span></a> +</span><span id="Redshift-45"><a href="#Redshift-45"><span class="linenos"> 45</span></a> <span class="n">CONVERT_TYPE_FIRST</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Redshift-46"><a href="#Redshift-46"><span class="linenos"> 46</span></a> +</span><span id="Redshift-47"><a href="#Redshift-47"><span class="linenos"> 47</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span> +</span><span id="Redshift-48"><a href="#Redshift-48"><span class="linenos"> 48</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</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="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Redshift-49"><a href="#Redshift-49"><span class="linenos"> 49</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="Redshift-50"><a href="#Redshift-50"><span class="linenos"> 50</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="Redshift-51"><a href="#Redshift-51"><span class="linenos"> 51</span></a> +</span><span id="Redshift-52"><a href="#Redshift-52"><span class="linenos"> 52</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="Redshift-53"><a href="#Redshift-53"><span class="linenos"> 53</span></a> <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">DataType</span><span class="p">)</span> +</span><span id="Redshift-54"><a href="#Redshift-54"><span class="linenos"> 54</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"varchar"</span><span class="p">)</span> +</span><span id="Redshift-55"><a href="#Redshift-55"><span class="linenos"> 55</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="Redshift-56"><a href="#Redshift-56"><span class="linenos"> 56</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">)</span> +</span><span id="Redshift-57"><a href="#Redshift-57"><span class="linenos"> 57</span></a> <span class="p">):</span> +</span><span id="Redshift-58"><a href="#Redshift-58"><span class="linenos"> 58</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</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">"MAX"</span><span class="p">)])</span> +</span><span id="Redshift-59"><a href="#Redshift-59"><span class="linenos"> 59</span></a> +</span><span id="Redshift-60"><a href="#Redshift-60"><span class="linenos"> 60</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Redshift-61"><a href="#Redshift-61"><span class="linenos"> 61</span></a> +</span><span id="Redshift-62"><a href="#Redshift-62"><span class="linenos"> 62</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span> +</span><span id="Redshift-63"><a href="#Redshift-63"><span class="linenos"> 63</span></a> <span class="n">BIT_STRINGS</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Redshift-64"><a href="#Redshift-64"><span class="linenos"> 64</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Redshift-65"><a href="#Redshift-65"><span class="linenos"> 65</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">]</span> +</span><span id="Redshift-66"><a href="#Redshift-66"><span class="linenos"> 66</span></a> +</span><span id="Redshift-67"><a href="#Redshift-67"><span class="linenos"> 67</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Redshift-68"><a href="#Redshift-68"><span class="linenos"> 68</span></a> <span class="o">**</span><span class="n">Postgres</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="Redshift-69"><a href="#Redshift-69"><span class="linenos"> 69</span></a> <span class="s2">"HLLSKETCH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HLLSKETCH</span><span class="p">,</span> +</span><span id="Redshift-70"><a href="#Redshift-70"><span class="linenos"> 70</span></a> <span class="s2">"SUPER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SUPER</span><span class="p">,</span> +</span><span id="Redshift-71"><a href="#Redshift-71"><span class="linenos"> 71</span></a> <span class="s2">"SYSDATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIMESTAMP</span><span class="p">,</span> +</span><span id="Redshift-72"><a href="#Redshift-72"><span class="linenos"> 72</span></a> <span class="s2">"TIME"</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="Redshift-73"><a href="#Redshift-73"><span class="linenos"> 73</span></a> <span class="s2">"TIMETZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> +</span><span id="Redshift-74"><a href="#Redshift-74"><span class="linenos"> 74</span></a> <span class="s2">"TOP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TOP</span><span class="p">,</span> +</span><span id="Redshift-75"><a href="#Redshift-75"><span class="linenos"> 75</span></a> <span class="s2">"UNLOAD"</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="Redshift-76"><a href="#Redshift-76"><span class="linenos"> 76</span></a> <span class="s2">"VARBYTE"</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="Redshift-77"><a href="#Redshift-77"><span class="linenos"> 77</span></a> <span class="p">}</span> +</span><span id="Redshift-78"><a href="#Redshift-78"><span class="linenos"> 78</span></a> +</span><span id="Redshift-79"><a href="#Redshift-79"><span class="linenos"> 79</span></a> <span class="c1"># Redshift allows # to appear as a table identifier prefix</span> +</span><span id="Redshift-80"><a href="#Redshift-80"><span class="linenos"> 80</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Redshift-81"><a href="#Redshift-81"><span class="linenos"> 81</span></a> <span class="n">SINGLE_TOKENS</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="Redshift-82"><a href="#Redshift-82"><span class="linenos"> 82</span></a> +</span><span id="Redshift-83"><a href="#Redshift-83"><span class="linenos"> 83</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> +</span><span id="Redshift-84"><a href="#Redshift-84"><span class="linenos"> 84</span></a> <span class="n">LOCKING_READS_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Redshift-85"><a href="#Redshift-85"><span class="linenos"> 85</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Redshift-86"><a href="#Redshift-86"><span class="linenos"> 86</span></a> +</span><span id="Redshift-87"><a href="#Redshift-87"><span class="linenos"> 87</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Redshift-88"><a href="#Redshift-88"><span class="linenos"> 88</span></a> <span class="o">**</span><span class="n">Postgres</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="Redshift-89"><a href="#Redshift-89"><span class="linenos"> 89</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">"VARBYTE"</span><span class="p">,</span> +</span><span id="Redshift-90"><a href="#Redshift-90"><span class="linenos"> 90</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">"VARBYTE"</span><span class="p">,</span> +</span><span id="Redshift-91"><a href="#Redshift-91"><span class="linenos"> 91</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">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="Redshift-92"><a href="#Redshift-92"><span class="linenos"> 92</span></a> <span class="p">}</span> +</span><span id="Redshift-93"><a href="#Redshift-93"><span class="linenos"> 93</span></a> +</span><span id="Redshift-94"><a href="#Redshift-94"><span class="linenos"> 94</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Redshift-95"><a href="#Redshift-95"><span class="linenos"> 95</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="Redshift-96"><a href="#Redshift-96"><span class="linenos"> 96</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> +</span><span id="Redshift-97"><a href="#Redshift-97"><span class="linenos"> 97</span></a> <span class="p">}</span> +</span><span id="Redshift-98"><a href="#Redshift-98"><span class="linenos"> 98</span></a> +</span><span id="Redshift-99"><a href="#Redshift-99"><span class="linenos"> 99</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Redshift-100"><a href="#Redshift-100"><span class="linenos">100</span></a> <span class="o">**</span><span class="n">Postgres</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="Redshift-101"><a href="#Redshift-101"><span class="linenos">101</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> +</span><span id="Redshift-102"><a href="#Redshift-102"><span class="linenos">102</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"SYSDATE"</span><span class="p">,</span> +</span><span id="Redshift-103"><a href="#Redshift-103"><span class="linenos">103</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</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="Redshift-104"><a href="#Redshift-104"><span class="linenos">104</span></a> <span class="s2">"DATEADD"</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="n">e</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="ow">or</span> <span class="s2">"day"</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="Redshift-105"><a href="#Redshift-105"><span class="linenos">105</span></a> <span class="p">),</span> -</span><span id="Redshift-106"><a href="#Redshift-106"><span class="linenos">106</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</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">"DISTKEY(</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Redshift-107"><a href="#Redshift-107"><span class="linenos">107</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="Redshift-108"><a href="#Redshift-108"><span class="linenos">108</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRTOL"</span><span class="p">),</span> -</span><span id="Redshift-109"><a href="#Redshift-109"><span class="linenos">109</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span> -</span><span id="Redshift-110"><a href="#Redshift-110"><span class="linenos">110</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span> -</span><span id="Redshift-111"><a href="#Redshift-111"><span class="linenos">111</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> -</span><span id="Redshift-112"><a href="#Redshift-112"><span class="linenos">112</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</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">eliminate_distinct_on</span><span class="p">]),</span> -</span><span id="Redshift-113"><a href="#Redshift-113"><span class="linenos">113</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</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">"</span><span class="si">{</span><span class="s1">'COMPOUND '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">'compound'</span><span class="p">]</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">SORTKEY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Redshift-114"><a href="#Redshift-114"><span class="linenos">114</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</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="o">.</span><span class="n">this</span><span class="p">),</span> -</span><span id="Redshift-115"><a href="#Redshift-115"><span class="linenos">115</span></a> <span class="p">}</span> -</span><span id="Redshift-116"><a href="#Redshift-116"><span class="linenos">116</span></a> -</span><span id="Redshift-117"><a href="#Redshift-117"><span class="linenos">117</span></a> <span class="c1"># Postgres maps exp.Pivot to no_pivot_sql, but Redshift support pivots</span> -</span><span id="Redshift-118"><a href="#Redshift-118"><span class="linenos">118</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> +</span><span id="Redshift-106"><a href="#Redshift-106"><span class="linenos">106</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="Redshift-107"><a href="#Redshift-107"><span class="linenos">107</span></a> <span class="s2">"DATEDIFF"</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="n">e</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="ow">or</span> <span class="s2">"day"</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="Redshift-108"><a href="#Redshift-108"><span class="linenos">108</span></a> <span class="p">),</span> +</span><span id="Redshift-109"><a href="#Redshift-109"><span class="linenos">109</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</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">"DISTKEY(</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Redshift-110"><a href="#Redshift-110"><span class="linenos">110</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="Redshift-111"><a href="#Redshift-111"><span class="linenos">111</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRTOL"</span><span class="p">),</span> +</span><span id="Redshift-112"><a href="#Redshift-112"><span class="linenos">112</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span> +</span><span id="Redshift-113"><a href="#Redshift-113"><span class="linenos">113</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span> +</span><span id="Redshift-114"><a href="#Redshift-114"><span class="linenos">114</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> +</span><span id="Redshift-115"><a href="#Redshift-115"><span class="linenos">115</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</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">eliminate_distinct_on</span><span class="p">]),</span> +</span><span id="Redshift-116"><a href="#Redshift-116"><span class="linenos">116</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</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">"</span><span class="si">{</span><span class="s1">'COMPOUND '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">'compound'</span><span class="p">]</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">SORTKEY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Redshift-117"><a href="#Redshift-117"><span class="linenos">117</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</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="o">.</span><span class="n">this</span><span class="p">),</span> +</span><span id="Redshift-118"><a href="#Redshift-118"><span class="linenos">118</span></a> <span class="p">}</span> </span><span id="Redshift-119"><a href="#Redshift-119"><span class="linenos">119</span></a> -</span><span id="Redshift-120"><a href="#Redshift-120"><span class="linenos">120</span></a> <span class="c1"># Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)</span> -</span><span id="Redshift-121"><a href="#Redshift-121"><span class="linenos">121</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">)</span> +</span><span id="Redshift-120"><a href="#Redshift-120"><span class="linenos">120</span></a> <span class="c1"># Postgres maps exp.Pivot to no_pivot_sql, but Redshift support pivots</span> +</span><span id="Redshift-121"><a href="#Redshift-121"><span class="linenos">121</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> </span><span id="Redshift-122"><a href="#Redshift-122"><span class="linenos">122</span></a> -</span><span id="Redshift-123"><a href="#Redshift-123"><span class="linenos">123</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span><span class="p">,</span> <span class="s2">"snapshot"</span><span class="p">,</span> <span class="s2">"type"</span><span class="p">}</span> -</span><span id="Redshift-124"><a href="#Redshift-124"><span class="linenos">124</span></a> -</span><span id="Redshift-125"><a href="#Redshift-125"><span class="linenos">125</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift-126"><a href="#Redshift-126"><span class="linenos">126</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Redshift-127"><a href="#Redshift-127"><span class="linenos">127</span></a><span class="sd"> Converts `VALUES...` expression into a series of unions.</span> -</span><span id="Redshift-128"><a href="#Redshift-128"><span class="linenos">128</span></a> -</span><span id="Redshift-129"><a href="#Redshift-129"><span class="linenos">129</span></a><span class="sd"> Note: If you have a lot of unions then this will result in a large number of recursive statements to</span> -</span><span id="Redshift-130"><a href="#Redshift-130"><span class="linenos">130</span></a><span class="sd"> evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be</span> -</span><span id="Redshift-131"><a href="#Redshift-131"><span class="linenos">131</span></a><span class="sd"> very slow.</span> -</span><span id="Redshift-132"><a href="#Redshift-132"><span class="linenos">132</span></a><span class="sd"> """</span> -</span><span id="Redshift-133"><a href="#Redshift-133"><span class="linenos">133</span></a> -</span><span id="Redshift-134"><a href="#Redshift-134"><span class="linenos">134</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span> -</span><span id="Redshift-135"><a href="#Redshift-135"><span class="linenos">135</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> -</span><span id="Redshift-136"><a href="#Redshift-136"><span class="linenos">136</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">values_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Redshift-137"><a href="#Redshift-137"><span class="linenos">137</span></a> -</span><span id="Redshift-138"><a href="#Redshift-138"><span class="linenos">138</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"alias"</span><span class="p">]</span><span class="o">.</span><span class="n">columns</span> -</span><span id="Redshift-139"><a href="#Redshift-139"><span class="linenos">139</span></a> -</span><span id="Redshift-140"><a href="#Redshift-140"><span class="linenos">140</span></a> <span class="n">selects</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Redshift-141"><a href="#Redshift-141"><span class="linenos">141</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="p">[</span><span class="n">tuple_exp</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">tuple_exp</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">]</span> +</span><span id="Redshift-123"><a href="#Redshift-123"><span class="linenos">123</span></a> <span class="c1"># Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)</span> +</span><span id="Redshift-124"><a href="#Redshift-124"><span class="linenos">124</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">)</span> +</span><span id="Redshift-125"><a href="#Redshift-125"><span class="linenos">125</span></a> +</span><span id="Redshift-126"><a href="#Redshift-126"><span class="linenos">126</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span><span class="p">,</span> <span class="s2">"snapshot"</span><span class="p">,</span> <span class="s2">"type"</span><span class="p">}</span> +</span><span id="Redshift-127"><a href="#Redshift-127"><span class="linenos">127</span></a> +</span><span id="Redshift-128"><a href="#Redshift-128"><span class="linenos">128</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift-129"><a href="#Redshift-129"><span class="linenos">129</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Redshift-130"><a href="#Redshift-130"><span class="linenos">130</span></a><span class="sd"> Converts `VALUES...` expression into a series of unions.</span> +</span><span id="Redshift-131"><a href="#Redshift-131"><span class="linenos">131</span></a> +</span><span id="Redshift-132"><a href="#Redshift-132"><span class="linenos">132</span></a><span class="sd"> Note: If you have a lot of unions then this will result in a large number of recursive statements to</span> +</span><span id="Redshift-133"><a href="#Redshift-133"><span class="linenos">133</span></a><span class="sd"> evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be</span> +</span><span id="Redshift-134"><a href="#Redshift-134"><span class="linenos">134</span></a><span class="sd"> very slow.</span> +</span><span id="Redshift-135"><a href="#Redshift-135"><span class="linenos">135</span></a><span class="sd"> """</span> +</span><span id="Redshift-136"><a href="#Redshift-136"><span class="linenos">136</span></a> +</span><span id="Redshift-137"><a href="#Redshift-137"><span class="linenos">137</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span> +</span><span id="Redshift-138"><a href="#Redshift-138"><span class="linenos">138</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> +</span><span id="Redshift-139"><a href="#Redshift-139"><span class="linenos">139</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">values_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Redshift-140"><a href="#Redshift-140"><span class="linenos">140</span></a> +</span><span id="Redshift-141"><a href="#Redshift-141"><span class="linenos">141</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"alias"</span><span class="p">]</span><span class="o">.</span><span class="n">columns</span> </span><span id="Redshift-142"><a href="#Redshift-142"><span class="linenos">142</span></a> -</span><span id="Redshift-143"><a href="#Redshift-143"><span class="linenos">143</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">row</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">rows</span><span class="p">):</span> -</span><span id="Redshift-144"><a href="#Redshift-144"><span class="linenos">144</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span> -</span><span id="Redshift-145"><a href="#Redshift-145"><span class="linenos">145</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="Redshift-146"><a href="#Redshift-146"><span class="linenos">146</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span> -</span><span id="Redshift-147"><a href="#Redshift-147"><span class="linenos">147</span></a> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span> -</span><span id="Redshift-148"><a href="#Redshift-148"><span class="linenos">148</span></a> <span class="p">]</span> -</span><span id="Redshift-149"><a href="#Redshift-149"><span class="linenos">149</span></a> -</span><span id="Redshift-150"><a href="#Redshift-150"><span class="linenos">150</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span> -</span><span id="Redshift-151"><a href="#Redshift-151"><span class="linenos">151</span></a> -</span><span id="Redshift-152"><a href="#Redshift-152"><span class="linenos">152</span></a> <span class="n">subquery_expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> <span class="o">=</span> <span class="n">selects</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="Redshift-153"><a href="#Redshift-153"><span class="linenos">153</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">selects</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Redshift-154"><a href="#Redshift-154"><span class="linenos">154</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span> -</span><span id="Redshift-155"><a href="#Redshift-155"><span class="linenos">155</span></a> <span class="n">subquery_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">subquery_expression</span><span class="p">,</span> <span class="n">select</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Redshift-156"><a href="#Redshift-156"><span class="linenos">156</span></a> -</span><span id="Redshift-157"><a href="#Redshift-157"><span class="linenos">157</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span><span class="n">subquery_expression</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">))</span> -</span><span id="Redshift-158"><a href="#Redshift-158"><span class="linenos">158</span></a> -</span><span id="Redshift-159"><a href="#Redshift-159"><span class="linenos">159</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift-160"><a href="#Redshift-160"><span class="linenos">160</span></a><span class="w"> </span><span class="sd">"""Redshift doesn't have `WITH` as part of their with_properties so we remove it"""</span> -</span><span id="Redshift-161"><a href="#Redshift-161"><span class="linenos">161</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="Redshift-162"><a href="#Redshift-162"><span class="linenos">162</span></a> -</span><span id="Redshift-163"><a href="#Redshift-163"><span class="linenos">163</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift-164"><a href="#Redshift-164"><span class="linenos">164</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Redshift-165"><a href="#Redshift-165"><span class="linenos">165</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span> -</span><span id="Redshift-166"><a href="#Redshift-166"><span class="linenos">166</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span> -</span><span id="Redshift-167"><a href="#Redshift-167"><span class="linenos">167</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span> -</span><span id="Redshift-168"><a href="#Redshift-168"><span class="linenos">168</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span> -</span><span id="Redshift-169"><a href="#Redshift-169"><span class="linenos">169</span></a><span class="sd"> """</span> -</span><span id="Redshift-170"><a href="#Redshift-170"><span class="linenos">170</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">"text"</span><span class="p">):</span> -</span><span id="Redshift-171"><a href="#Redshift-171"><span class="linenos">171</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Redshift-172"><a href="#Redshift-172"><span class="linenos">172</span></a> <span class="n">expression</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">exp</span><span 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="Redshift-173"><a href="#Redshift-173"><span class="linenos">173</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> -</span><span id="Redshift-174"><a href="#Redshift-174"><span class="linenos">174</span></a> -</span><span id="Redshift-175"><a href="#Redshift-175"><span class="linenos">175</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span> -</span><span id="Redshift-176"><a href="#Redshift-176"><span class="linenos">176</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">))</span> +</span><span id="Redshift-143"><a href="#Redshift-143"><span class="linenos">143</span></a> <span class="n">selects</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Redshift-144"><a href="#Redshift-144"><span class="linenos">144</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="p">[</span><span class="n">tuple_exp</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">tuple_exp</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">]</span> +</span><span id="Redshift-145"><a href="#Redshift-145"><span class="linenos">145</span></a> +</span><span id="Redshift-146"><a href="#Redshift-146"><span class="linenos">146</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">row</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">rows</span><span class="p">):</span> +</span><span id="Redshift-147"><a href="#Redshift-147"><span class="linenos">147</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span> +</span><span id="Redshift-148"><a href="#Redshift-148"><span class="linenos">148</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="Redshift-149"><a href="#Redshift-149"><span class="linenos">149</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span> +</span><span id="Redshift-150"><a href="#Redshift-150"><span class="linenos">150</span></a> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span> +</span><span id="Redshift-151"><a href="#Redshift-151"><span class="linenos">151</span></a> <span class="p">]</span> +</span><span id="Redshift-152"><a href="#Redshift-152"><span class="linenos">152</span></a> +</span><span id="Redshift-153"><a href="#Redshift-153"><span class="linenos">153</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span> +</span><span id="Redshift-154"><a href="#Redshift-154"><span class="linenos">154</span></a> +</span><span id="Redshift-155"><a href="#Redshift-155"><span class="linenos">155</span></a> <span class="n">subquery_expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> <span class="o">=</span> <span class="n">selects</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="Redshift-156"><a href="#Redshift-156"><span class="linenos">156</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">selects</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Redshift-157"><a href="#Redshift-157"><span class="linenos">157</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span> +</span><span id="Redshift-158"><a href="#Redshift-158"><span class="linenos">158</span></a> <span class="n">subquery_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">subquery_expression</span><span class="p">,</span> <span class="n">select</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Redshift-159"><a href="#Redshift-159"><span class="linenos">159</span></a> +</span><span id="Redshift-160"><a href="#Redshift-160"><span class="linenos">160</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span><span class="n">subquery_expression</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">))</span> +</span><span id="Redshift-161"><a href="#Redshift-161"><span class="linenos">161</span></a> +</span><span id="Redshift-162"><a href="#Redshift-162"><span class="linenos">162</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift-163"><a href="#Redshift-163"><span class="linenos">163</span></a><span class="w"> </span><span class="sd">"""Redshift doesn't have `WITH` as part of their with_properties so we remove it"""</span> +</span><span id="Redshift-164"><a href="#Redshift-164"><span class="linenos">164</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> +</span><span id="Redshift-165"><a href="#Redshift-165"><span class="linenos">165</span></a> +</span><span id="Redshift-166"><a href="#Redshift-166"><span class="linenos">166</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift-167"><a href="#Redshift-167"><span class="linenos">167</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Redshift-168"><a href="#Redshift-168"><span class="linenos">168</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span> +</span><span id="Redshift-169"><a href="#Redshift-169"><span class="linenos">169</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span> +</span><span id="Redshift-170"><a href="#Redshift-170"><span class="linenos">170</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span> +</span><span id="Redshift-171"><a href="#Redshift-171"><span class="linenos">171</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span> +</span><span id="Redshift-172"><a href="#Redshift-172"><span class="linenos">172</span></a><span class="sd"> """</span> +</span><span id="Redshift-173"><a href="#Redshift-173"><span class="linenos">173</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">"text"</span><span class="p">):</span> +</span><span id="Redshift-174"><a href="#Redshift-174"><span class="linenos">174</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Redshift-175"><a href="#Redshift-175"><span class="linenos">175</span></a> <span class="n">expression</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">exp</span><span 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="Redshift-176"><a href="#Redshift-176"><span class="linenos">176</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> </span><span id="Redshift-177"><a href="#Redshift-177"><span class="linenos">177</span></a> -</span><span id="Redshift-178"><a href="#Redshift-178"><span class="linenos">178</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Redshift-178"><a href="#Redshift-178"><span class="linenos">178</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span> +</span><span id="Redshift-179"><a href="#Redshift-179"><span class="linenos">179</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">))</span> +</span><span id="Redshift-180"><a href="#Redshift-180"><span class="linenos">180</span></a> +</span><span id="Redshift-181"><a href="#Redshift-181"><span class="linenos">181</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -451,6 +460,10 @@ <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="Redshift.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="Redshift.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="Redshift.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="Redshift.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="Redshift.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="Redshift.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="Redshift.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="Redshift.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="Redshift.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -474,39 +487,39 @@ </div> <a class="headerlink" href="#Redshift.Parser"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Parser-25"><a href="#Redshift.Parser-25"><span class="linenos">25</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span> -</span><span id="Redshift.Parser-26"><a href="#Redshift.Parser-26"><span class="linenos">26</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Redshift.Parser-27"><a href="#Redshift.Parser-27"><span class="linenos">27</span></a> <span class="o">**</span><span class="n">Postgres</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="Redshift.Parser-28"><a href="#Redshift.Parser-28"><span class="linenos">28</span></a> <span class="s2">"DATEADD"</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">DateAdd</span><span class="p">(</span> -</span><span id="Redshift.Parser-29"><a href="#Redshift.Parser-29"><span class="linenos">29</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span> -</span><span id="Redshift.Parser-30"><a href="#Redshift.Parser-30"><span class="linenos">30</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="Redshift.Parser-31"><a href="#Redshift.Parser-31"><span class="linenos">31</span></a> <span class="n">unit</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="Redshift.Parser-32"><a href="#Redshift.Parser-32"><span class="linenos">32</span></a> <span class="p">),</span> -</span><span id="Redshift.Parser-33"><a href="#Redshift.Parser-33"><span class="linenos">33</span></a> <span class="s2">"DATEDIFF"</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">DateDiff</span><span class="p">(</span> -</span><span id="Redshift.Parser-34"><a href="#Redshift.Parser-34"><span class="linenos">34</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span> -</span><span id="Redshift.Parser-35"><a href="#Redshift.Parser-35"><span class="linenos">35</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span> -</span><span id="Redshift.Parser-36"><a href="#Redshift.Parser-36"><span class="linenos">36</span></a> <span class="n">unit</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="Redshift.Parser-37"><a href="#Redshift.Parser-37"><span class="linenos">37</span></a> <span class="p">),</span> -</span><span id="Redshift.Parser-38"><a href="#Redshift.Parser-38"><span class="linenos">38</span></a> <span class="s2">"NVL"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Coalesce</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Redshift.Parser-39"><a href="#Redshift.Parser-39"><span class="linenos">39</span></a> <span class="s2">"STRTOL"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Redshift.Parser-40"><a href="#Redshift.Parser-40"><span class="linenos">40</span></a> <span class="p">}</span> -</span><span id="Redshift.Parser-41"><a href="#Redshift.Parser-41"><span class="linenos">41</span></a> -</span><span id="Redshift.Parser-42"><a href="#Redshift.Parser-42"><span class="linenos">42</span></a> <span class="n">CONVERT_TYPE_FIRST</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Redshift.Parser-43"><a href="#Redshift.Parser-43"><span class="linenos">43</span></a> -</span><span id="Redshift.Parser-44"><a href="#Redshift.Parser-44"><span class="linenos">44</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span> -</span><span id="Redshift.Parser-45"><a href="#Redshift.Parser-45"><span class="linenos">45</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</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="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Redshift.Parser-46"><a href="#Redshift.Parser-46"><span class="linenos">46</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="Redshift.Parser-47"><a href="#Redshift.Parser-47"><span class="linenos">47</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="Redshift.Parser-48"><a href="#Redshift.Parser-48"><span class="linenos">48</span></a> -</span><span id="Redshift.Parser-49"><a href="#Redshift.Parser-49"><span class="linenos">49</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="Redshift.Parser-50"><a href="#Redshift.Parser-50"><span class="linenos">50</span></a> <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">DataType</span><span class="p">)</span> -</span><span id="Redshift.Parser-51"><a href="#Redshift.Parser-51"><span class="linenos">51</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"varchar"</span><span class="p">)</span> -</span><span id="Redshift.Parser-52"><a href="#Redshift.Parser-52"><span class="linenos">52</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="Redshift.Parser-53"><a href="#Redshift.Parser-53"><span class="linenos">53</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">)</span> -</span><span id="Redshift.Parser-54"><a href="#Redshift.Parser-54"><span class="linenos">54</span></a> <span class="p">):</span> -</span><span id="Redshift.Parser-55"><a href="#Redshift.Parser-55"><span class="linenos">55</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</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">"MAX"</span><span class="p">)])</span> -</span><span id="Redshift.Parser-56"><a href="#Redshift.Parser-56"><span class="linenos">56</span></a> -</span><span id="Redshift.Parser-57"><a href="#Redshift.Parser-57"><span class="linenos">57</span></a> <span class="k">return</span> <span class="n">this</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Parser-28"><a href="#Redshift.Parser-28"><span class="linenos">28</span></a> <span class="k">class</span> <span class="nc">Parser</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Parser</span><span class="p">):</span> +</span><span id="Redshift.Parser-29"><a href="#Redshift.Parser-29"><span class="linenos">29</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Redshift.Parser-30"><a href="#Redshift.Parser-30"><span class="linenos">30</span></a> <span class="o">**</span><span class="n">Postgres</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="Redshift.Parser-31"><a href="#Redshift.Parser-31"><span class="linenos">31</span></a> <span class="s2">"DATEADD"</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">DateAdd</span><span class="p">(</span> +</span><span id="Redshift.Parser-32"><a href="#Redshift.Parser-32"><span class="linenos">32</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span> +</span><span id="Redshift.Parser-33"><a href="#Redshift.Parser-33"><span class="linenos">33</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="Redshift.Parser-34"><a href="#Redshift.Parser-34"><span class="linenos">34</span></a> <span class="n">unit</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="Redshift.Parser-35"><a href="#Redshift.Parser-35"><span class="linenos">35</span></a> <span class="p">),</span> +</span><span id="Redshift.Parser-36"><a href="#Redshift.Parser-36"><span class="linenos">36</span></a> <span class="s2">"DATEDIFF"</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">DateDiff</span><span class="p">(</span> +</span><span id="Redshift.Parser-37"><a href="#Redshift.Parser-37"><span class="linenos">37</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span> +</span><span id="Redshift.Parser-38"><a href="#Redshift.Parser-38"><span class="linenos">38</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span> +</span><span id="Redshift.Parser-39"><a href="#Redshift.Parser-39"><span class="linenos">39</span></a> <span class="n">unit</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="Redshift.Parser-40"><a href="#Redshift.Parser-40"><span class="linenos">40</span></a> <span class="p">),</span> +</span><span id="Redshift.Parser-41"><a href="#Redshift.Parser-41"><span class="linenos">41</span></a> <span class="s2">"NVL"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Coalesce</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Redshift.Parser-42"><a href="#Redshift.Parser-42"><span class="linenos">42</span></a> <span class="s2">"STRTOL"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Redshift.Parser-43"><a href="#Redshift.Parser-43"><span class="linenos">43</span></a> <span class="p">}</span> +</span><span id="Redshift.Parser-44"><a href="#Redshift.Parser-44"><span class="linenos">44</span></a> +</span><span id="Redshift.Parser-45"><a href="#Redshift.Parser-45"><span class="linenos">45</span></a> <span class="n">CONVERT_TYPE_FIRST</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Redshift.Parser-46"><a href="#Redshift.Parser-46"><span class="linenos">46</span></a> +</span><span id="Redshift.Parser-47"><a href="#Redshift.Parser-47"><span class="linenos">47</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span> +</span><span id="Redshift.Parser-48"><a href="#Redshift.Parser-48"><span class="linenos">48</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</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="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Redshift.Parser-49"><a href="#Redshift.Parser-49"><span class="linenos">49</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="Redshift.Parser-50"><a href="#Redshift.Parser-50"><span class="linenos">50</span></a> <span class="n">this</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="Redshift.Parser-51"><a href="#Redshift.Parser-51"><span class="linenos">51</span></a> +</span><span id="Redshift.Parser-52"><a href="#Redshift.Parser-52"><span class="linenos">52</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="Redshift.Parser-53"><a href="#Redshift.Parser-53"><span class="linenos">53</span></a> <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">DataType</span><span class="p">)</span> +</span><span id="Redshift.Parser-54"><a href="#Redshift.Parser-54"><span class="linenos">54</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="s2">"varchar"</span><span class="p">)</span> +</span><span id="Redshift.Parser-55"><a href="#Redshift.Parser-55"><span class="linenos">55</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="Redshift.Parser-56"><a href="#Redshift.Parser-56"><span class="linenos">56</span></a> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">)</span> +</span><span id="Redshift.Parser-57"><a href="#Redshift.Parser-57"><span class="linenos">57</span></a> <span class="p">):</span> +</span><span id="Redshift.Parser-58"><a href="#Redshift.Parser-58"><span class="linenos">58</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</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">"MAX"</span><span class="p">)])</span> +</span><span id="Redshift.Parser-59"><a href="#Redshift.Parser-59"><span class="linenos">59</span></a> +</span><span id="Redshift.Parser-60"><a href="#Redshift.Parser-60"><span class="linenos">60</span></a> <span class="k">return</span> <span class="n">this</span> </span></pre></div> @@ -555,26 +568,26 @@ Default: 3</li> </div> <a class="headerlink" href="#Redshift.Tokenizer"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Tokenizer-59"><a href="#Redshift.Tokenizer-59"><span class="linenos">59</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span> -</span><span id="Redshift.Tokenizer-60"><a href="#Redshift.Tokenizer-60"><span class="linenos">60</span></a> <span class="n">BIT_STRINGS</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Redshift.Tokenizer-61"><a href="#Redshift.Tokenizer-61"><span class="linenos">61</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Redshift.Tokenizer-62"><a href="#Redshift.Tokenizer-62"><span class="linenos">62</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">]</span> -</span><span id="Redshift.Tokenizer-63"><a href="#Redshift.Tokenizer-63"><span class="linenos">63</span></a> -</span><span id="Redshift.Tokenizer-64"><a href="#Redshift.Tokenizer-64"><span class="linenos">64</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Redshift.Tokenizer-65"><a href="#Redshift.Tokenizer-65"><span class="linenos">65</span></a> <span class="o">**</span><span class="n">Postgres</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="Redshift.Tokenizer-66"><a href="#Redshift.Tokenizer-66"><span class="linenos">66</span></a> <span class="s2">"HLLSKETCH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HLLSKETCH</span><span class="p">,</span> -</span><span id="Redshift.Tokenizer-67"><a href="#Redshift.Tokenizer-67"><span class="linenos">67</span></a> <span class="s2">"SUPER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SUPER</span><span class="p">,</span> -</span><span id="Redshift.Tokenizer-68"><a href="#Redshift.Tokenizer-68"><span class="linenos">68</span></a> <span class="s2">"SYSDATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIMESTAMP</span><span class="p">,</span> -</span><span id="Redshift.Tokenizer-69"><a href="#Redshift.Tokenizer-69"><span class="linenos">69</span></a> <span class="s2">"TIME"</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="Redshift.Tokenizer-70"><a href="#Redshift.Tokenizer-70"><span class="linenos">70</span></a> <span class="s2">"TIMETZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> -</span><span id="Redshift.Tokenizer-71"><a href="#Redshift.Tokenizer-71"><span class="linenos">71</span></a> <span class="s2">"TOP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TOP</span><span class="p">,</span> -</span><span id="Redshift.Tokenizer-72"><a href="#Redshift.Tokenizer-72"><span class="linenos">72</span></a> <span class="s2">"UNLOAD"</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="Redshift.Tokenizer-73"><a href="#Redshift.Tokenizer-73"><span class="linenos">73</span></a> <span class="s2">"VARBYTE"</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="Redshift.Tokenizer-74"><a href="#Redshift.Tokenizer-74"><span class="linenos">74</span></a> <span class="p">}</span> -</span><span id="Redshift.Tokenizer-75"><a href="#Redshift.Tokenizer-75"><span class="linenos">75</span></a> -</span><span id="Redshift.Tokenizer-76"><a href="#Redshift.Tokenizer-76"><span class="linenos">76</span></a> <span class="c1"># Redshift allows # to appear as a table identifier prefix</span> -</span><span id="Redshift.Tokenizer-77"><a href="#Redshift.Tokenizer-77"><span class="linenos">77</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Redshift.Tokenizer-78"><a href="#Redshift.Tokenizer-78"><span class="linenos">78</span></a> <span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"#"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Tokenizer-62"><a href="#Redshift.Tokenizer-62"><span class="linenos">62</span></a> <span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="p">):</span> +</span><span id="Redshift.Tokenizer-63"><a href="#Redshift.Tokenizer-63"><span class="linenos">63</span></a> <span class="n">BIT_STRINGS</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Redshift.Tokenizer-64"><a href="#Redshift.Tokenizer-64"><span class="linenos">64</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Redshift.Tokenizer-65"><a href="#Redshift.Tokenizer-65"><span class="linenos">65</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">]</span> +</span><span id="Redshift.Tokenizer-66"><a href="#Redshift.Tokenizer-66"><span class="linenos">66</span></a> +</span><span id="Redshift.Tokenizer-67"><a href="#Redshift.Tokenizer-67"><span class="linenos">67</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Redshift.Tokenizer-68"><a href="#Redshift.Tokenizer-68"><span class="linenos">68</span></a> <span class="o">**</span><span class="n">Postgres</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="Redshift.Tokenizer-69"><a href="#Redshift.Tokenizer-69"><span class="linenos">69</span></a> <span class="s2">"HLLSKETCH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HLLSKETCH</span><span class="p">,</span> +</span><span id="Redshift.Tokenizer-70"><a href="#Redshift.Tokenizer-70"><span class="linenos">70</span></a> <span class="s2">"SUPER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SUPER</span><span class="p">,</span> +</span><span id="Redshift.Tokenizer-71"><a href="#Redshift.Tokenizer-71"><span class="linenos">71</span></a> <span class="s2">"SYSDATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIMESTAMP</span><span class="p">,</span> +</span><span id="Redshift.Tokenizer-72"><a href="#Redshift.Tokenizer-72"><span class="linenos">72</span></a> <span class="s2">"TIME"</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="Redshift.Tokenizer-73"><a href="#Redshift.Tokenizer-73"><span class="linenos">73</span></a> <span class="s2">"TIMETZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> +</span><span id="Redshift.Tokenizer-74"><a href="#Redshift.Tokenizer-74"><span class="linenos">74</span></a> <span class="s2">"TOP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TOP</span><span class="p">,</span> +</span><span id="Redshift.Tokenizer-75"><a href="#Redshift.Tokenizer-75"><span class="linenos">75</span></a> <span class="s2">"UNLOAD"</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="Redshift.Tokenizer-76"><a href="#Redshift.Tokenizer-76"><span class="linenos">76</span></a> <span class="s2">"VARBYTE"</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="Redshift.Tokenizer-77"><a href="#Redshift.Tokenizer-77"><span class="linenos">77</span></a> <span class="p">}</span> +</span><span id="Redshift.Tokenizer-78"><a href="#Redshift.Tokenizer-78"><span class="linenos">78</span></a> +</span><span id="Redshift.Tokenizer-79"><a href="#Redshift.Tokenizer-79"><span class="linenos">79</span></a> <span class="c1"># Redshift allows # to appear as a table identifier prefix</span> +</span><span id="Redshift.Tokenizer-80"><a href="#Redshift.Tokenizer-80"><span class="linenos">80</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="n">Postgres</span><span class="o">.</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Redshift.Tokenizer-81"><a href="#Redshift.Tokenizer-81"><span class="linenos">81</span></a> <span class="n">SINGLE_TOKENS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"#"</span><span class="p">)</span> </span></pre></div> @@ -603,105 +616,105 @@ Default: 3</li> </div> <a class="headerlink" href="#Redshift.Generator"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator-80"><a href="#Redshift.Generator-80"><span class="linenos"> 80</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> -</span><span id="Redshift.Generator-81"><a href="#Redshift.Generator-81"><span class="linenos"> 81</span></a> <span class="n">LOCKING_READS_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Redshift.Generator-82"><a href="#Redshift.Generator-82"><span class="linenos"> 82</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Redshift.Generator-83"><a href="#Redshift.Generator-83"><span class="linenos"> 83</span></a> -</span><span id="Redshift.Generator-84"><a href="#Redshift.Generator-84"><span class="linenos"> 84</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Redshift.Generator-85"><a href="#Redshift.Generator-85"><span class="linenos"> 85</span></a> <span class="o">**</span><span class="n">Postgres</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="Redshift.Generator-86"><a href="#Redshift.Generator-86"><span class="linenos"> 86</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">"VARBYTE"</span><span class="p">,</span> -</span><span id="Redshift.Generator-87"><a href="#Redshift.Generator-87"><span class="linenos"> 87</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">"VARBYTE"</span><span class="p">,</span> -</span><span id="Redshift.Generator-88"><a href="#Redshift.Generator-88"><span class="linenos"> 88</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">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="Redshift.Generator-89"><a href="#Redshift.Generator-89"><span class="linenos"> 89</span></a> <span class="p">}</span> -</span><span id="Redshift.Generator-90"><a href="#Redshift.Generator-90"><span class="linenos"> 90</span></a> -</span><span id="Redshift.Generator-91"><a href="#Redshift.Generator-91"><span class="linenos"> 91</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Redshift.Generator-92"><a href="#Redshift.Generator-92"><span class="linenos"> 92</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="Redshift.Generator-93"><a href="#Redshift.Generator-93"><span class="linenos"> 93</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> -</span><span id="Redshift.Generator-94"><a href="#Redshift.Generator-94"><span class="linenos"> 94</span></a> <span class="p">}</span> -</span><span id="Redshift.Generator-95"><a href="#Redshift.Generator-95"><span class="linenos"> 95</span></a> -</span><span id="Redshift.Generator-96"><a href="#Redshift.Generator-96"><span class="linenos"> 96</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Redshift.Generator-97"><a href="#Redshift.Generator-97"><span class="linenos"> 97</span></a> <span class="o">**</span><span class="n">Postgres</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="Redshift.Generator-98"><a href="#Redshift.Generator-98"><span class="linenos"> 98</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> -</span><span id="Redshift.Generator-99"><a href="#Redshift.Generator-99"><span class="linenos"> 99</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"SYSDATE"</span><span class="p">,</span> -</span><span id="Redshift.Generator-100"><a href="#Redshift.Generator-100"><span class="linenos">100</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</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="Redshift.Generator-101"><a href="#Redshift.Generator-101"><span class="linenos">101</span></a> <span class="s2">"DATEADD"</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="n">e</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="ow">or</span> <span class="s2">"day"</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="Redshift.Generator-102"><a href="#Redshift.Generator-102"><span class="linenos">102</span></a> <span class="p">),</span> -</span><span id="Redshift.Generator-103"><a href="#Redshift.Generator-103"><span class="linenos">103</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="Redshift.Generator-104"><a href="#Redshift.Generator-104"><span class="linenos">104</span></a> <span class="s2">"DATEDIFF"</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="n">e</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="ow">or</span> <span class="s2">"day"</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> + <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator-83"><a href="#Redshift.Generator-83"><span class="linenos"> 83</span></a> <span class="k">class</span> <span class="nc">Generator</span><span class="p">(</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="p">):</span> +</span><span id="Redshift.Generator-84"><a href="#Redshift.Generator-84"><span class="linenos"> 84</span></a> <span class="n">LOCKING_READS_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Redshift.Generator-85"><a href="#Redshift.Generator-85"><span class="linenos"> 85</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Redshift.Generator-86"><a href="#Redshift.Generator-86"><span class="linenos"> 86</span></a> +</span><span id="Redshift.Generator-87"><a href="#Redshift.Generator-87"><span class="linenos"> 87</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Redshift.Generator-88"><a href="#Redshift.Generator-88"><span class="linenos"> 88</span></a> <span class="o">**</span><span class="n">Postgres</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="Redshift.Generator-89"><a href="#Redshift.Generator-89"><span class="linenos"> 89</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">"VARBYTE"</span><span class="p">,</span> +</span><span id="Redshift.Generator-90"><a href="#Redshift.Generator-90"><span class="linenos"> 90</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">"VARBYTE"</span><span class="p">,</span> +</span><span id="Redshift.Generator-91"><a href="#Redshift.Generator-91"><span class="linenos"> 91</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">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="Redshift.Generator-92"><a href="#Redshift.Generator-92"><span class="linenos"> 92</span></a> <span class="p">}</span> +</span><span id="Redshift.Generator-93"><a href="#Redshift.Generator-93"><span class="linenos"> 93</span></a> +</span><span id="Redshift.Generator-94"><a href="#Redshift.Generator-94"><span class="linenos"> 94</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Redshift.Generator-95"><a href="#Redshift.Generator-95"><span class="linenos"> 95</span></a> <span class="o">**</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="Redshift.Generator-96"><a href="#Redshift.Generator-96"><span class="linenos"> 96</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> +</span><span id="Redshift.Generator-97"><a href="#Redshift.Generator-97"><span class="linenos"> 97</span></a> <span class="p">}</span> +</span><span id="Redshift.Generator-98"><a href="#Redshift.Generator-98"><span class="linenos"> 98</span></a> +</span><span id="Redshift.Generator-99"><a href="#Redshift.Generator-99"><span class="linenos"> 99</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Redshift.Generator-100"><a href="#Redshift.Generator-100"><span class="linenos">100</span></a> <span class="o">**</span><span class="n">Postgres</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="Redshift.Generator-101"><a href="#Redshift.Generator-101"><span class="linenos">101</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> +</span><span id="Redshift.Generator-102"><a href="#Redshift.Generator-102"><span class="linenos">102</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="bp">self</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span> <span class="s2">"SYSDATE"</span><span class="p">,</span> +</span><span id="Redshift.Generator-103"><a href="#Redshift.Generator-103"><span class="linenos">103</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</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="Redshift.Generator-104"><a href="#Redshift.Generator-104"><span class="linenos">104</span></a> <span class="s2">"DATEADD"</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="n">e</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="ow">or</span> <span class="s2">"day"</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="Redshift.Generator-105"><a href="#Redshift.Generator-105"><span class="linenos">105</span></a> <span class="p">),</span> -</span><span id="Redshift.Generator-106"><a href="#Redshift.Generator-106"><span class="linenos">106</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</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">"DISTKEY(</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Redshift.Generator-107"><a href="#Redshift.Generator-107"><span class="linenos">107</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="Redshift.Generator-108"><a href="#Redshift.Generator-108"><span class="linenos">108</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRTOL"</span><span class="p">),</span> -</span><span id="Redshift.Generator-109"><a href="#Redshift.Generator-109"><span class="linenos">109</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span> -</span><span id="Redshift.Generator-110"><a href="#Redshift.Generator-110"><span class="linenos">110</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span> -</span><span id="Redshift.Generator-111"><a href="#Redshift.Generator-111"><span class="linenos">111</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> -</span><span id="Redshift.Generator-112"><a href="#Redshift.Generator-112"><span class="linenos">112</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</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">eliminate_distinct_on</span><span class="p">]),</span> -</span><span id="Redshift.Generator-113"><a href="#Redshift.Generator-113"><span class="linenos">113</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</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">"</span><span class="si">{</span><span class="s1">'COMPOUND '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">'compound'</span><span class="p">]</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">SORTKEY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Redshift.Generator-114"><a href="#Redshift.Generator-114"><span class="linenos">114</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</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="o">.</span><span class="n">this</span><span class="p">),</span> -</span><span id="Redshift.Generator-115"><a href="#Redshift.Generator-115"><span class="linenos">115</span></a> <span class="p">}</span> -</span><span id="Redshift.Generator-116"><a href="#Redshift.Generator-116"><span class="linenos">116</span></a> -</span><span id="Redshift.Generator-117"><a href="#Redshift.Generator-117"><span class="linenos">117</span></a> <span class="c1"># Postgres maps exp.Pivot to no_pivot_sql, but Redshift support pivots</span> -</span><span id="Redshift.Generator-118"><a href="#Redshift.Generator-118"><span class="linenos">118</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> +</span><span id="Redshift.Generator-106"><a href="#Redshift.Generator-106"><span class="linenos">106</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="Redshift.Generator-107"><a href="#Redshift.Generator-107"><span class="linenos">107</span></a> <span class="s2">"DATEDIFF"</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="n">e</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="ow">or</span> <span class="s2">"day"</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="Redshift.Generator-108"><a href="#Redshift.Generator-108"><span class="linenos">108</span></a> <span class="p">),</span> +</span><span id="Redshift.Generator-109"><a href="#Redshift.Generator-109"><span class="linenos">109</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</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">"DISTKEY(</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Redshift.Generator-110"><a href="#Redshift.Generator-110"><span class="linenos">110</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="Redshift.Generator-111"><a href="#Redshift.Generator-111"><span class="linenos">111</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FromBase</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"STRTOL"</span><span class="p">),</span> +</span><span id="Redshift.Generator-112"><a href="#Redshift.Generator-112"><span class="linenos">112</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtract</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span> +</span><span id="Redshift.Generator-113"><a href="#Redshift.Generator-113"><span class="linenos">113</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONExtractScalar</span><span class="p">:</span> <span class="n">_json_sql</span><span class="p">,</span> +</span><span id="Redshift.Generator-114"><a href="#Redshift.Generator-114"><span class="linenos">114</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> +</span><span id="Redshift.Generator-115"><a href="#Redshift.Generator-115"><span class="linenos">115</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</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">eliminate_distinct_on</span><span class="p">]),</span> +</span><span id="Redshift.Generator-116"><a href="#Redshift.Generator-116"><span class="linenos">116</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</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">"</span><span class="si">{</span><span class="s1">'COMPOUND '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">'compound'</span><span class="p">]</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">SORTKEY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">e</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Redshift.Generator-117"><a href="#Redshift.Generator-117"><span class="linenos">117</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</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="o">.</span><span class="n">this</span><span class="p">),</span> +</span><span id="Redshift.Generator-118"><a href="#Redshift.Generator-118"><span class="linenos">118</span></a> <span class="p">}</span> </span><span id="Redshift.Generator-119"><a href="#Redshift.Generator-119"><span class="linenos">119</span></a> -</span><span id="Redshift.Generator-120"><a href="#Redshift.Generator-120"><span class="linenos">120</span></a> <span class="c1"># Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)</span> -</span><span id="Redshift.Generator-121"><a href="#Redshift.Generator-121"><span class="linenos">121</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">)</span> +</span><span id="Redshift.Generator-120"><a href="#Redshift.Generator-120"><span class="linenos">120</span></a> <span class="c1"># Postgres maps exp.Pivot to no_pivot_sql, but Redshift support pivots</span> +</span><span id="Redshift.Generator-121"><a href="#Redshift.Generator-121"><span class="linenos">121</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> </span><span id="Redshift.Generator-122"><a href="#Redshift.Generator-122"><span class="linenos">122</span></a> -</span><span id="Redshift.Generator-123"><a href="#Redshift.Generator-123"><span class="linenos">123</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span><span class="p">,</span> <span class="s2">"snapshot"</span><span class="p">,</span> <span class="s2">"type"</span><span class="p">}</span> -</span><span id="Redshift.Generator-124"><a href="#Redshift.Generator-124"><span class="linenos">124</span></a> -</span><span id="Redshift.Generator-125"><a href="#Redshift.Generator-125"><span class="linenos">125</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift.Generator-126"><a href="#Redshift.Generator-126"><span class="linenos">126</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Redshift.Generator-127"><a href="#Redshift.Generator-127"><span class="linenos">127</span></a><span class="sd"> Converts `VALUES...` expression into a series of unions.</span> -</span><span id="Redshift.Generator-128"><a href="#Redshift.Generator-128"><span class="linenos">128</span></a> -</span><span id="Redshift.Generator-129"><a href="#Redshift.Generator-129"><span class="linenos">129</span></a><span class="sd"> Note: If you have a lot of unions then this will result in a large number of recursive statements to</span> -</span><span id="Redshift.Generator-130"><a href="#Redshift.Generator-130"><span class="linenos">130</span></a><span class="sd"> evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be</span> -</span><span id="Redshift.Generator-131"><a href="#Redshift.Generator-131"><span class="linenos">131</span></a><span class="sd"> very slow.</span> -</span><span id="Redshift.Generator-132"><a href="#Redshift.Generator-132"><span class="linenos">132</span></a><span class="sd"> """</span> -</span><span id="Redshift.Generator-133"><a href="#Redshift.Generator-133"><span class="linenos">133</span></a> -</span><span id="Redshift.Generator-134"><a href="#Redshift.Generator-134"><span class="linenos">134</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span> -</span><span id="Redshift.Generator-135"><a href="#Redshift.Generator-135"><span class="linenos">135</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> -</span><span id="Redshift.Generator-136"><a href="#Redshift.Generator-136"><span class="linenos">136</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">values_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Redshift.Generator-137"><a href="#Redshift.Generator-137"><span class="linenos">137</span></a> -</span><span id="Redshift.Generator-138"><a href="#Redshift.Generator-138"><span class="linenos">138</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"alias"</span><span class="p">]</span><span class="o">.</span><span class="n">columns</span> -</span><span id="Redshift.Generator-139"><a href="#Redshift.Generator-139"><span class="linenos">139</span></a> -</span><span id="Redshift.Generator-140"><a href="#Redshift.Generator-140"><span class="linenos">140</span></a> <span class="n">selects</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Redshift.Generator-141"><a href="#Redshift.Generator-141"><span class="linenos">141</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="p">[</span><span class="n">tuple_exp</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">tuple_exp</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">]</span> +</span><span id="Redshift.Generator-123"><a href="#Redshift.Generator-123"><span class="linenos">123</span></a> <span class="c1"># Redshift uses the POW | POWER (expr1, expr2) syntax instead of expr1 ^ expr2 (postgres)</span> +</span><span id="Redshift.Generator-124"><a href="#Redshift.Generator-124"><span class="linenos">124</span></a> <span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Pow</span><span class="p">)</span> +</span><span id="Redshift.Generator-125"><a href="#Redshift.Generator-125"><span class="linenos">125</span></a> +</span><span id="Redshift.Generator-126"><a href="#Redshift.Generator-126"><span class="linenos">126</span></a> <span class="n">RESERVED_KEYWORDS</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">Postgres</span><span class="o">.</span><span class="n">Generator</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span><span class="p">,</span> <span class="s2">"snapshot"</span><span class="p">,</span> <span class="s2">"type"</span><span class="p">}</span> +</span><span id="Redshift.Generator-127"><a href="#Redshift.Generator-127"><span class="linenos">127</span></a> +</span><span id="Redshift.Generator-128"><a href="#Redshift.Generator-128"><span class="linenos">128</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift.Generator-129"><a href="#Redshift.Generator-129"><span class="linenos">129</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Redshift.Generator-130"><a href="#Redshift.Generator-130"><span class="linenos">130</span></a><span class="sd"> Converts `VALUES...` expression into a series of unions.</span> +</span><span id="Redshift.Generator-131"><a href="#Redshift.Generator-131"><span class="linenos">131</span></a> +</span><span id="Redshift.Generator-132"><a href="#Redshift.Generator-132"><span class="linenos">132</span></a><span class="sd"> Note: If you have a lot of unions then this will result in a large number of recursive statements to</span> +</span><span id="Redshift.Generator-133"><a href="#Redshift.Generator-133"><span class="linenos">133</span></a><span class="sd"> evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be</span> +</span><span id="Redshift.Generator-134"><a href="#Redshift.Generator-134"><span class="linenos">134</span></a><span class="sd"> very slow.</span> +</span><span id="Redshift.Generator-135"><a href="#Redshift.Generator-135"><span class="linenos">135</span></a><span class="sd"> """</span> +</span><span id="Redshift.Generator-136"><a href="#Redshift.Generator-136"><span class="linenos">136</span></a> +</span><span id="Redshift.Generator-137"><a href="#Redshift.Generator-137"><span class="linenos">137</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span> +</span><span id="Redshift.Generator-138"><a href="#Redshift.Generator-138"><span class="linenos">138</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> +</span><span id="Redshift.Generator-139"><a href="#Redshift.Generator-139"><span class="linenos">139</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">values_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Redshift.Generator-140"><a href="#Redshift.Generator-140"><span class="linenos">140</span></a> +</span><span id="Redshift.Generator-141"><a href="#Redshift.Generator-141"><span class="linenos">141</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"alias"</span><span class="p">]</span><span class="o">.</span><span class="n">columns</span> </span><span id="Redshift.Generator-142"><a href="#Redshift.Generator-142"><span class="linenos">142</span></a> -</span><span id="Redshift.Generator-143"><a href="#Redshift.Generator-143"><span class="linenos">143</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">row</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">rows</span><span class="p">):</span> -</span><span id="Redshift.Generator-144"><a href="#Redshift.Generator-144"><span class="linenos">144</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span> -</span><span id="Redshift.Generator-145"><a href="#Redshift.Generator-145"><span class="linenos">145</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="Redshift.Generator-146"><a href="#Redshift.Generator-146"><span class="linenos">146</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span> -</span><span id="Redshift.Generator-147"><a href="#Redshift.Generator-147"><span class="linenos">147</span></a> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span> -</span><span id="Redshift.Generator-148"><a href="#Redshift.Generator-148"><span class="linenos">148</span></a> <span class="p">]</span> -</span><span id="Redshift.Generator-149"><a href="#Redshift.Generator-149"><span class="linenos">149</span></a> -</span><span id="Redshift.Generator-150"><a href="#Redshift.Generator-150"><span class="linenos">150</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span> -</span><span id="Redshift.Generator-151"><a href="#Redshift.Generator-151"><span class="linenos">151</span></a> -</span><span id="Redshift.Generator-152"><a href="#Redshift.Generator-152"><span class="linenos">152</span></a> <span class="n">subquery_expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> <span class="o">=</span> <span class="n">selects</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="Redshift.Generator-153"><a href="#Redshift.Generator-153"><span class="linenos">153</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">selects</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Redshift.Generator-154"><a href="#Redshift.Generator-154"><span class="linenos">154</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span> -</span><span id="Redshift.Generator-155"><a href="#Redshift.Generator-155"><span class="linenos">155</span></a> <span class="n">subquery_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">subquery_expression</span><span class="p">,</span> <span class="n">select</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Redshift.Generator-156"><a href="#Redshift.Generator-156"><span class="linenos">156</span></a> -</span><span id="Redshift.Generator-157"><a href="#Redshift.Generator-157"><span class="linenos">157</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span><span class="n">subquery_expression</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">))</span> -</span><span id="Redshift.Generator-158"><a href="#Redshift.Generator-158"><span class="linenos">158</span></a> -</span><span id="Redshift.Generator-159"><a href="#Redshift.Generator-159"><span class="linenos">159</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift.Generator-160"><a href="#Redshift.Generator-160"><span class="linenos">160</span></a><span class="w"> </span><span class="sd">"""Redshift doesn't have `WITH` as part of their with_properties so we remove it"""</span> -</span><span id="Redshift.Generator-161"><a href="#Redshift.Generator-161"><span class="linenos">161</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="Redshift.Generator-162"><a href="#Redshift.Generator-162"><span class="linenos">162</span></a> -</span><span id="Redshift.Generator-163"><a href="#Redshift.Generator-163"><span class="linenos">163</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift.Generator-164"><a href="#Redshift.Generator-164"><span class="linenos">164</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Redshift.Generator-165"><a href="#Redshift.Generator-165"><span class="linenos">165</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span> -</span><span id="Redshift.Generator-166"><a href="#Redshift.Generator-166"><span class="linenos">166</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span> -</span><span id="Redshift.Generator-167"><a href="#Redshift.Generator-167"><span class="linenos">167</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span> -</span><span id="Redshift.Generator-168"><a href="#Redshift.Generator-168"><span class="linenos">168</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span> -</span><span id="Redshift.Generator-169"><a href="#Redshift.Generator-169"><span class="linenos">169</span></a><span class="sd"> """</span> -</span><span id="Redshift.Generator-170"><a href="#Redshift.Generator-170"><span class="linenos">170</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">"text"</span><span class="p">):</span> -</span><span id="Redshift.Generator-171"><a href="#Redshift.Generator-171"><span class="linenos">171</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Redshift.Generator-172"><a href="#Redshift.Generator-172"><span class="linenos">172</span></a> <span class="n">expression</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">exp</span><span 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="Redshift.Generator-173"><a href="#Redshift.Generator-173"><span class="linenos">173</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> -</span><span id="Redshift.Generator-174"><a href="#Redshift.Generator-174"><span class="linenos">174</span></a> -</span><span id="Redshift.Generator-175"><a href="#Redshift.Generator-175"><span class="linenos">175</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span> -</span><span id="Redshift.Generator-176"><a href="#Redshift.Generator-176"><span class="linenos">176</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">))</span> +</span><span id="Redshift.Generator-143"><a href="#Redshift.Generator-143"><span class="linenos">143</span></a> <span class="n">selects</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Redshift.Generator-144"><a href="#Redshift.Generator-144"><span class="linenos">144</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="p">[</span><span class="n">tuple_exp</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">tuple_exp</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">]</span> +</span><span id="Redshift.Generator-145"><a href="#Redshift.Generator-145"><span class="linenos">145</span></a> +</span><span id="Redshift.Generator-146"><a href="#Redshift.Generator-146"><span class="linenos">146</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">row</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">rows</span><span class="p">):</span> +</span><span id="Redshift.Generator-147"><a href="#Redshift.Generator-147"><span class="linenos">147</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span> +</span><span id="Redshift.Generator-148"><a href="#Redshift.Generator-148"><span class="linenos">148</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="Redshift.Generator-149"><a href="#Redshift.Generator-149"><span class="linenos">149</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span> +</span><span id="Redshift.Generator-150"><a href="#Redshift.Generator-150"><span class="linenos">150</span></a> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span> +</span><span id="Redshift.Generator-151"><a href="#Redshift.Generator-151"><span class="linenos">151</span></a> <span class="p">]</span> +</span><span id="Redshift.Generator-152"><a href="#Redshift.Generator-152"><span class="linenos">152</span></a> +</span><span id="Redshift.Generator-153"><a href="#Redshift.Generator-153"><span class="linenos">153</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span> +</span><span id="Redshift.Generator-154"><a href="#Redshift.Generator-154"><span class="linenos">154</span></a> +</span><span id="Redshift.Generator-155"><a href="#Redshift.Generator-155"><span class="linenos">155</span></a> <span class="n">subquery_expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> <span class="o">=</span> <span class="n">selects</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="Redshift.Generator-156"><a href="#Redshift.Generator-156"><span class="linenos">156</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">selects</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Redshift.Generator-157"><a href="#Redshift.Generator-157"><span class="linenos">157</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span> +</span><span id="Redshift.Generator-158"><a href="#Redshift.Generator-158"><span class="linenos">158</span></a> <span class="n">subquery_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">subquery_expression</span><span class="p">,</span> <span class="n">select</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Redshift.Generator-159"><a href="#Redshift.Generator-159"><span class="linenos">159</span></a> +</span><span id="Redshift.Generator-160"><a href="#Redshift.Generator-160"><span class="linenos">160</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span><span class="n">subquery_expression</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">))</span> +</span><span id="Redshift.Generator-161"><a href="#Redshift.Generator-161"><span class="linenos">161</span></a> +</span><span id="Redshift.Generator-162"><a href="#Redshift.Generator-162"><span class="linenos">162</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift.Generator-163"><a href="#Redshift.Generator-163"><span class="linenos">163</span></a><span class="w"> </span><span class="sd">"""Redshift doesn't have `WITH` as part of their with_properties so we remove it"""</span> +</span><span id="Redshift.Generator-164"><a href="#Redshift.Generator-164"><span class="linenos">164</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> +</span><span id="Redshift.Generator-165"><a href="#Redshift.Generator-165"><span class="linenos">165</span></a> +</span><span id="Redshift.Generator-166"><a href="#Redshift.Generator-166"><span class="linenos">166</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift.Generator-167"><a href="#Redshift.Generator-167"><span class="linenos">167</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Redshift.Generator-168"><a href="#Redshift.Generator-168"><span class="linenos">168</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span> +</span><span id="Redshift.Generator-169"><a href="#Redshift.Generator-169"><span class="linenos">169</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span> +</span><span id="Redshift.Generator-170"><a href="#Redshift.Generator-170"><span class="linenos">170</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span> +</span><span id="Redshift.Generator-171"><a href="#Redshift.Generator-171"><span class="linenos">171</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span> +</span><span id="Redshift.Generator-172"><a href="#Redshift.Generator-172"><span class="linenos">172</span></a><span class="sd"> """</span> +</span><span id="Redshift.Generator-173"><a href="#Redshift.Generator-173"><span class="linenos">173</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">"text"</span><span class="p">):</span> +</span><span id="Redshift.Generator-174"><a href="#Redshift.Generator-174"><span class="linenos">174</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Redshift.Generator-175"><a href="#Redshift.Generator-175"><span class="linenos">175</span></a> <span class="n">expression</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">exp</span><span 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="Redshift.Generator-176"><a href="#Redshift.Generator-176"><span class="linenos">176</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> </span><span id="Redshift.Generator-177"><a href="#Redshift.Generator-177"><span class="linenos">177</span></a> -</span><span id="Redshift.Generator-178"><a href="#Redshift.Generator-178"><span class="linenos">178</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Redshift.Generator-178"><a href="#Redshift.Generator-178"><span class="linenos">178</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span> +</span><span id="Redshift.Generator-179"><a href="#Redshift.Generator-179"><span class="linenos">179</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">))</span> +</span><span id="Redshift.Generator-180"><a href="#Redshift.Generator-180"><span class="linenos">180</span></a> +</span><span id="Redshift.Generator-181"><a href="#Redshift.Generator-181"><span class="linenos">181</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -755,39 +768,39 @@ Default: True</li> </div> <a class="headerlink" href="#Redshift.Generator.values_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.values_sql-125"><a href="#Redshift.Generator.values_sql-125"><span class="linenos">125</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift.Generator.values_sql-126"><a href="#Redshift.Generator.values_sql-126"><span class="linenos">126</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Redshift.Generator.values_sql-127"><a href="#Redshift.Generator.values_sql-127"><span class="linenos">127</span></a><span class="sd"> Converts `VALUES...` expression into a series of unions.</span> -</span><span id="Redshift.Generator.values_sql-128"><a href="#Redshift.Generator.values_sql-128"><span class="linenos">128</span></a> -</span><span id="Redshift.Generator.values_sql-129"><a href="#Redshift.Generator.values_sql-129"><span class="linenos">129</span></a><span class="sd"> Note: If you have a lot of unions then this will result in a large number of recursive statements to</span> -</span><span id="Redshift.Generator.values_sql-130"><a href="#Redshift.Generator.values_sql-130"><span class="linenos">130</span></a><span class="sd"> evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be</span> -</span><span id="Redshift.Generator.values_sql-131"><a href="#Redshift.Generator.values_sql-131"><span class="linenos">131</span></a><span class="sd"> very slow.</span> -</span><span id="Redshift.Generator.values_sql-132"><a href="#Redshift.Generator.values_sql-132"><span class="linenos">132</span></a><span class="sd"> """</span> -</span><span id="Redshift.Generator.values_sql-133"><a href="#Redshift.Generator.values_sql-133"><span class="linenos">133</span></a> -</span><span id="Redshift.Generator.values_sql-134"><a href="#Redshift.Generator.values_sql-134"><span class="linenos">134</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span> -</span><span id="Redshift.Generator.values_sql-135"><a href="#Redshift.Generator.values_sql-135"><span class="linenos">135</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> -</span><span id="Redshift.Generator.values_sql-136"><a href="#Redshift.Generator.values_sql-136"><span class="linenos">136</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">values_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Redshift.Generator.values_sql-137"><a href="#Redshift.Generator.values_sql-137"><span class="linenos">137</span></a> -</span><span id="Redshift.Generator.values_sql-138"><a href="#Redshift.Generator.values_sql-138"><span class="linenos">138</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"alias"</span><span class="p">]</span><span class="o">.</span><span class="n">columns</span> -</span><span id="Redshift.Generator.values_sql-139"><a href="#Redshift.Generator.values_sql-139"><span class="linenos">139</span></a> -</span><span id="Redshift.Generator.values_sql-140"><a href="#Redshift.Generator.values_sql-140"><span class="linenos">140</span></a> <span class="n">selects</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Redshift.Generator.values_sql-141"><a href="#Redshift.Generator.values_sql-141"><span class="linenos">141</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="p">[</span><span class="n">tuple_exp</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">tuple_exp</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.values_sql-128"><a href="#Redshift.Generator.values_sql-128"><span class="linenos">128</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift.Generator.values_sql-129"><a href="#Redshift.Generator.values_sql-129"><span class="linenos">129</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Redshift.Generator.values_sql-130"><a href="#Redshift.Generator.values_sql-130"><span class="linenos">130</span></a><span class="sd"> Converts `VALUES...` expression into a series of unions.</span> +</span><span id="Redshift.Generator.values_sql-131"><a href="#Redshift.Generator.values_sql-131"><span class="linenos">131</span></a> +</span><span id="Redshift.Generator.values_sql-132"><a href="#Redshift.Generator.values_sql-132"><span class="linenos">132</span></a><span class="sd"> Note: If you have a lot of unions then this will result in a large number of recursive statements to</span> +</span><span id="Redshift.Generator.values_sql-133"><a href="#Redshift.Generator.values_sql-133"><span class="linenos">133</span></a><span class="sd"> evaluate the expression. You may need to increase `sys.setrecursionlimit` to run and it can also be</span> +</span><span id="Redshift.Generator.values_sql-134"><a href="#Redshift.Generator.values_sql-134"><span class="linenos">134</span></a><span class="sd"> very slow.</span> +</span><span id="Redshift.Generator.values_sql-135"><a href="#Redshift.Generator.values_sql-135"><span class="linenos">135</span></a><span class="sd"> """</span> +</span><span id="Redshift.Generator.values_sql-136"><a href="#Redshift.Generator.values_sql-136"><span class="linenos">136</span></a> +</span><span id="Redshift.Generator.values_sql-137"><a href="#Redshift.Generator.values_sql-137"><span class="linenos">137</span></a> <span class="c1"># The VALUES clause is still valid in an `INSERT INTO ..` statement, for example</span> +</span><span id="Redshift.Generator.values_sql-138"><a href="#Redshift.Generator.values_sql-138"><span class="linenos">138</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> +</span><span id="Redshift.Generator.values_sql-139"><a href="#Redshift.Generator.values_sql-139"><span class="linenos">139</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">values_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Redshift.Generator.values_sql-140"><a href="#Redshift.Generator.values_sql-140"><span class="linenos">140</span></a> +</span><span id="Redshift.Generator.values_sql-141"><a href="#Redshift.Generator.values_sql-141"><span class="linenos">141</span></a> <span class="n">column_names</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"alias"</span><span class="p">]</span><span class="o">.</span><span class="n">columns</span> </span><span id="Redshift.Generator.values_sql-142"><a href="#Redshift.Generator.values_sql-142"><span class="linenos">142</span></a> -</span><span id="Redshift.Generator.values_sql-143"><a href="#Redshift.Generator.values_sql-143"><span class="linenos">143</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">row</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">rows</span><span class="p">):</span> -</span><span id="Redshift.Generator.values_sql-144"><a href="#Redshift.Generator.values_sql-144"><span class="linenos">144</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span> -</span><span id="Redshift.Generator.values_sql-145"><a href="#Redshift.Generator.values_sql-145"><span class="linenos">145</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="Redshift.Generator.values_sql-146"><a href="#Redshift.Generator.values_sql-146"><span class="linenos">146</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span> -</span><span id="Redshift.Generator.values_sql-147"><a href="#Redshift.Generator.values_sql-147"><span class="linenos">147</span></a> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span> -</span><span id="Redshift.Generator.values_sql-148"><a href="#Redshift.Generator.values_sql-148"><span class="linenos">148</span></a> <span class="p">]</span> -</span><span id="Redshift.Generator.values_sql-149"><a href="#Redshift.Generator.values_sql-149"><span class="linenos">149</span></a> -</span><span id="Redshift.Generator.values_sql-150"><a href="#Redshift.Generator.values_sql-150"><span class="linenos">150</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span> -</span><span id="Redshift.Generator.values_sql-151"><a href="#Redshift.Generator.values_sql-151"><span class="linenos">151</span></a> -</span><span id="Redshift.Generator.values_sql-152"><a href="#Redshift.Generator.values_sql-152"><span class="linenos">152</span></a> <span class="n">subquery_expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> <span class="o">=</span> <span class="n">selects</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="Redshift.Generator.values_sql-153"><a href="#Redshift.Generator.values_sql-153"><span class="linenos">153</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">selects</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Redshift.Generator.values_sql-154"><a href="#Redshift.Generator.values_sql-154"><span class="linenos">154</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span> -</span><span id="Redshift.Generator.values_sql-155"><a href="#Redshift.Generator.values_sql-155"><span class="linenos">155</span></a> <span class="n">subquery_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">subquery_expression</span><span class="p">,</span> <span class="n">select</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Redshift.Generator.values_sql-156"><a href="#Redshift.Generator.values_sql-156"><span class="linenos">156</span></a> -</span><span id="Redshift.Generator.values_sql-157"><a href="#Redshift.Generator.values_sql-157"><span class="linenos">157</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span><span class="n">subquery_expression</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">))</span> +</span><span id="Redshift.Generator.values_sql-143"><a href="#Redshift.Generator.values_sql-143"><span class="linenos">143</span></a> <span class="n">selects</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Redshift.Generator.values_sql-144"><a href="#Redshift.Generator.values_sql-144"><span class="linenos">144</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="p">[</span><span class="n">tuple_exp</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">tuple_exp</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">]</span> +</span><span id="Redshift.Generator.values_sql-145"><a href="#Redshift.Generator.values_sql-145"><span class="linenos">145</span></a> +</span><span id="Redshift.Generator.values_sql-146"><a href="#Redshift.Generator.values_sql-146"><span class="linenos">146</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">row</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">rows</span><span class="p">):</span> +</span><span id="Redshift.Generator.values_sql-147"><a href="#Redshift.Generator.values_sql-147"><span class="linenos">147</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">column_names</span><span class="p">:</span> +</span><span id="Redshift.Generator.values_sql-148"><a href="#Redshift.Generator.values_sql-148"><span class="linenos">148</span></a> <span class="n">row</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="Redshift.Generator.values_sql-149"><a href="#Redshift.Generator.values_sql-149"><span class="linenos">149</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">alias_</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">column_name</span><span class="p">)</span> +</span><span id="Redshift.Generator.values_sql-150"><a href="#Redshift.Generator.values_sql-150"><span class="linenos">150</span></a> <span class="k">for</span> <span class="n">value</span><span class="p">,</span> <span class="n">column_name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">column_names</span><span class="p">)</span> +</span><span id="Redshift.Generator.values_sql-151"><a href="#Redshift.Generator.values_sql-151"><span class="linenos">151</span></a> <span class="p">]</span> +</span><span id="Redshift.Generator.values_sql-152"><a href="#Redshift.Generator.values_sql-152"><span class="linenos">152</span></a> +</span><span id="Redshift.Generator.values_sql-153"><a href="#Redshift.Generator.values_sql-153"><span class="linenos">153</span></a> <span class="n">selects</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">row</span><span class="p">))</span> +</span><span id="Redshift.Generator.values_sql-154"><a href="#Redshift.Generator.values_sql-154"><span class="linenos">154</span></a> +</span><span id="Redshift.Generator.values_sql-155"><a href="#Redshift.Generator.values_sql-155"><span class="linenos">155</span></a> <span class="n">subquery_expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> <span class="o">=</span> <span class="n">selects</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="Redshift.Generator.values_sql-156"><a href="#Redshift.Generator.values_sql-156"><span class="linenos">156</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">selects</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Redshift.Generator.values_sql-157"><a href="#Redshift.Generator.values_sql-157"><span class="linenos">157</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">selects</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span> +</span><span id="Redshift.Generator.values_sql-158"><a href="#Redshift.Generator.values_sql-158"><span class="linenos">158</span></a> <span class="n">subquery_expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">union</span><span class="p">(</span><span class="n">subquery_expression</span><span class="p">,</span> <span class="n">select</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Redshift.Generator.values_sql-159"><a href="#Redshift.Generator.values_sql-159"><span class="linenos">159</span></a> +</span><span id="Redshift.Generator.values_sql-160"><a href="#Redshift.Generator.values_sql-160"><span class="linenos">160</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">subquery_sql</span><span class="p">(</span><span class="n">subquery_expression</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">alias</span><span class="p">))</span> </span></pre></div> @@ -811,9 +824,9 @@ very slow.</p> </div> <a class="headerlink" href="#Redshift.Generator.with_properties"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.with_properties-159"><a href="#Redshift.Generator.with_properties-159"><span class="linenos">159</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift.Generator.with_properties-160"><a href="#Redshift.Generator.with_properties-160"><span class="linenos">160</span></a><span class="w"> </span><span class="sd">"""Redshift doesn't have `WITH` as part of their with_properties so we remove it"""</span> -</span><span id="Redshift.Generator.with_properties-161"><a href="#Redshift.Generator.with_properties-161"><span class="linenos">161</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.with_properties-162"><a href="#Redshift.Generator.with_properties-162"><span class="linenos">162</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift.Generator.with_properties-163"><a href="#Redshift.Generator.with_properties-163"><span class="linenos">163</span></a><span class="w"> </span><span class="sd">"""Redshift doesn't have `WITH` as part of their with_properties so we remove it"""</span> +</span><span id="Redshift.Generator.with_properties-164"><a href="#Redshift.Generator.with_properties-164"><span class="linenos">164</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> </span></pre></div> @@ -833,22 +846,22 @@ very slow.</p> </div> <a class="headerlink" href="#Redshift.Generator.datatype_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.datatype_sql-163"><a href="#Redshift.Generator.datatype_sql-163"><span class="linenos">163</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Redshift.Generator.datatype_sql-164"><a href="#Redshift.Generator.datatype_sql-164"><span class="linenos">164</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Redshift.Generator.datatype_sql-165"><a href="#Redshift.Generator.datatype_sql-165"><span class="linenos">165</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span> -</span><span id="Redshift.Generator.datatype_sql-166"><a href="#Redshift.Generator.datatype_sql-166"><span class="linenos">166</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span> -</span><span id="Redshift.Generator.datatype_sql-167"><a href="#Redshift.Generator.datatype_sql-167"><span class="linenos">167</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span> -</span><span id="Redshift.Generator.datatype_sql-168"><a href="#Redshift.Generator.datatype_sql-168"><span class="linenos">168</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span> -</span><span id="Redshift.Generator.datatype_sql-169"><a href="#Redshift.Generator.datatype_sql-169"><span class="linenos">169</span></a><span class="sd"> """</span> -</span><span id="Redshift.Generator.datatype_sql-170"><a href="#Redshift.Generator.datatype_sql-170"><span class="linenos">170</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">"text"</span><span class="p">):</span> -</span><span id="Redshift.Generator.datatype_sql-171"><a href="#Redshift.Generator.datatype_sql-171"><span class="linenos">171</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Redshift.Generator.datatype_sql-172"><a href="#Redshift.Generator.datatype_sql-172"><span class="linenos">172</span></a> <span class="n">expression</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">exp</span><span 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="Redshift.Generator.datatype_sql-173"><a href="#Redshift.Generator.datatype_sql-173"><span class="linenos">173</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> -</span><span id="Redshift.Generator.datatype_sql-174"><a href="#Redshift.Generator.datatype_sql-174"><span class="linenos">174</span></a> -</span><span id="Redshift.Generator.datatype_sql-175"><a href="#Redshift.Generator.datatype_sql-175"><span class="linenos">175</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span> -</span><span id="Redshift.Generator.datatype_sql-176"><a href="#Redshift.Generator.datatype_sql-176"><span class="linenos">176</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.datatype_sql-166"><a href="#Redshift.Generator.datatype_sql-166"><span class="linenos">166</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Redshift.Generator.datatype_sql-167"><a href="#Redshift.Generator.datatype_sql-167"><span class="linenos">167</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Redshift.Generator.datatype_sql-168"><a href="#Redshift.Generator.datatype_sql-168"><span class="linenos">168</span></a><span class="sd"> Redshift converts the `TEXT` data type to `VARCHAR(255)` by default when people more generally mean</span> +</span><span id="Redshift.Generator.datatype_sql-169"><a href="#Redshift.Generator.datatype_sql-169"><span class="linenos">169</span></a><span class="sd"> VARCHAR of max length which is `VARCHAR(max)` in Redshift. Therefore if we get a `TEXT` data type</span> +</span><span id="Redshift.Generator.datatype_sql-170"><a href="#Redshift.Generator.datatype_sql-170"><span class="linenos">170</span></a><span class="sd"> without precision we convert it to `VARCHAR(max)` and if it does have precision then we just convert</span> +</span><span id="Redshift.Generator.datatype_sql-171"><a href="#Redshift.Generator.datatype_sql-171"><span class="linenos">171</span></a><span class="sd"> `TEXT` to `VARCHAR`.</span> +</span><span id="Redshift.Generator.datatype_sql-172"><a href="#Redshift.Generator.datatype_sql-172"><span class="linenos">172</span></a><span class="sd"> """</span> +</span><span id="Redshift.Generator.datatype_sql-173"><a href="#Redshift.Generator.datatype_sql-173"><span class="linenos">173</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">"text"</span><span class="p">):</span> +</span><span id="Redshift.Generator.datatype_sql-174"><a href="#Redshift.Generator.datatype_sql-174"><span class="linenos">174</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Redshift.Generator.datatype_sql-175"><a href="#Redshift.Generator.datatype_sql-175"><span class="linenos">175</span></a> <span class="n">expression</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">exp</span><span 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="Redshift.Generator.datatype_sql-176"><a href="#Redshift.Generator.datatype_sql-176"><span class="linenos">176</span></a> <span class="n">precision</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> </span><span id="Redshift.Generator.datatype_sql-177"><a href="#Redshift.Generator.datatype_sql-177"><span class="linenos">177</span></a> -</span><span id="Redshift.Generator.datatype_sql-178"><a href="#Redshift.Generator.datatype_sql-178"><span class="linenos">178</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Redshift.Generator.datatype_sql-178"><a href="#Redshift.Generator.datatype_sql-178"><span class="linenos">178</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">precision</span><span class="p">:</span> +</span><span id="Redshift.Generator.datatype_sql-179"><a href="#Redshift.Generator.datatype_sql-179"><span class="linenos">179</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">))</span> +</span><span id="Redshift.Generator.datatype_sql-180"><a href="#Redshift.Generator.datatype_sql-180"><span class="linenos">180</span></a> +</span><span id="Redshift.Generator.datatype_sql-181"><a href="#Redshift.Generator.datatype_sql-181"><span class="linenos">181</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">datatype_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -860,6 +873,60 @@ without precision we convert it to <code>VARCHAR(max)</code> and if it does have </div> + <div id="Redshift.Generator.can_identify" class="classattr"> + <input id="Redshift.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="Redshift.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Redshift.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Redshift.Generator.can_identify-247"><a href="#Redshift.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="Redshift.Generator.can_identify-248"><a href="#Redshift.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Redshift.Generator.can_identify-249"><a href="#Redshift.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="Redshift.Generator.can_identify-250"><a href="#Redshift.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="Redshift.Generator.can_identify-251"><a href="#Redshift.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="Redshift.Generator.can_identify-252"><a href="#Redshift.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="Redshift.Generator.can_identify-253"><a href="#Redshift.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="Redshift.Generator.can_identify-254"><a href="#Redshift.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="Redshift.Generator.can_identify-255"><a href="#Redshift.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="Redshift.Generator.can_identify-256"><a href="#Redshift.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="Redshift.Generator.can_identify-257"><a href="#Redshift.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="Redshift.Generator.can_identify-258"><a href="#Redshift.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="Redshift.Generator.can_identify-259"><a href="#Redshift.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="Redshift.Generator.can_identify-260"><a href="#Redshift.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="Redshift.Generator.can_identify-261"><a href="#Redshift.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Redshift.Generator.can_identify-262"><a href="#Redshift.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="Redshift.Generator.can_identify-263"><a href="#Redshift.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="Redshift.Generator.can_identify-264"><a href="#Redshift.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="Redshift.Generator.can_identify-265"><a href="#Redshift.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="Redshift.Generator.can_identify-266"><a href="#Redshift.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -959,6 +1026,7 @@ without precision we convert it to <code>VARCHAR(max)</code> and if it does have <dd id="Redshift.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="Redshift.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="Redshift.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="Redshift.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="Redshift.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="Redshift.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="Redshift.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/dialects/snowflake.html b/docs/sqlglot/dialects/snowflake.html index 323b478..9329f53 100644 --- a/docs/sqlglot/dialects/snowflake.html +++ b/docs/sqlglot/dialects/snowflake.html @@ -63,6 +63,9 @@ <li> <a class="function" href="#Snowflake.Generator.generatedasidentitycolumnconstraint_sql">generatedasidentitycolumnconstraint_sql</a> </li> + <li> + <a class="function" href="#Snowflake.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -261,234 +264,236 @@ </span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a> </span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a> </span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a><span class="k">class</span> <span class="nc">Snowflake</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> -</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_large"</span> -</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">"'YYYY-MM-DD HH24:MI:SS'"</span> -</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> -</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="s2">"YYYY"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> -</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="s2">"yyyy"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> -</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> <span class="s2">"YY"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> -</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="s2">"yy"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> -</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> <span class="s2">"MMMM"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> -</span><span id="L-179"><a href="#L-179"><span class="linenos">179</span></a> <span class="s2">"mmmm"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> -</span><span id="L-180"><a href="#L-180"><span class="linenos">180</span></a> <span class="s2">"MON"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> -</span><span id="L-181"><a href="#L-181"><span class="linenos">181</span></a> <span class="s2">"mon"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> -</span><span id="L-182"><a href="#L-182"><span class="linenos">182</span></a> <span class="s2">"MM"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> -</span><span id="L-183"><a href="#L-183"><span class="linenos">183</span></a> <span class="s2">"mm"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> -</span><span id="L-184"><a href="#L-184"><span class="linenos">184</span></a> <span class="s2">"DD"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%d</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> <span class="s2">"dd"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%-d</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a> <span class="s2">"DY"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-187"><a href="#L-187"><span class="linenos">187</span></a> <span class="s2">"dy"</span><span class="p">:</span> <span class="s2">"%w"</span><span class="p">,</span> -</span><span id="L-188"><a href="#L-188"><span class="linenos">188</span></a> <span class="s2">"HH24"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> -</span><span id="L-189"><a href="#L-189"><span class="linenos">189</span></a> <span class="s2">"hh24"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> -</span><span id="L-190"><a href="#L-190"><span class="linenos">190</span></a> <span class="s2">"HH12"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> -</span><span id="L-191"><a href="#L-191"><span class="linenos">191</span></a> <span class="s2">"hh12"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> -</span><span id="L-192"><a href="#L-192"><span class="linenos">192</span></a> <span class="s2">"MI"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> -</span><span id="L-193"><a href="#L-193"><span class="linenos">193</span></a> <span class="s2">"mi"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> -</span><span id="L-194"><a href="#L-194"><span class="linenos">194</span></a> <span class="s2">"SS"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> -</span><span id="L-195"><a href="#L-195"><span class="linenos">195</span></a> <span class="s2">"ss"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> -</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a> <span class="s2">"FF"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-197"><a href="#L-197"><span class="linenos">197</span></a> <span class="s2">"ff"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> <span class="s2">"FF6"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-199"><a href="#L-199"><span class="linenos">199</span></a> <span class="s2">"ff6"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-200"><a href="#L-200"><span class="linenos">200</span></a> <span class="p">}</span> -</span><span id="L-201"><a href="#L-201"><span class="linenos">201</span></a> -</span><span id="L-202"><a href="#L-202"><span class="linenos">202</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-203"><a href="#L-203"><span class="linenos">203</span></a> <span class="n">IDENTIFY_PIVOT_STRINGS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-204"><a href="#L-204"><span class="linenos">204</span></a> -</span><span id="L-205"><a href="#L-205"><span class="linenos">205</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-206"><a href="#L-206"><span class="linenos">206</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-207"><a href="#L-207"><span class="linenos">207</span></a> <span class="s2">"ARRAYAGG"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-208"><a href="#L-208"><span class="linenos">208</span></a> <span class="s2">"ARRAY_CONSTRUCT"</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-209"><a href="#L-209"><span class="linenos">209</span></a> <span class="s2">"ARRAY_TO_STRING"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayJoin</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> <span class="s2">"CONVERT_TIMEZONE"</span><span class="p">:</span> <span class="n">_parse_convert_timezone</span><span class="p">,</span> -</span><span id="L-211"><a href="#L-211"><span class="linenos">211</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-212"><a href="#L-212"><span class="linenos">212</span></a> <span class="s2">"DATEADD"</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">DateAdd</span><span class="p">(</span> -</span><span id="L-213"><a href="#L-213"><span class="linenos">213</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">2</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">unit</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-214"><a href="#L-214"><span class="linenos">214</span></a> <span class="p">),</span> -</span><span id="L-215"><a href="#L-215"><span class="linenos">215</span></a> <span class="s2">"DATEDIFF"</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">DateDiff</span><span class="p">(</span> -</span><span id="L-216"><a href="#L-216"><span class="linenos">216</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">2</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">unit</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-217"><a href="#L-217"><span class="linenos">217</span></a> <span class="p">),</span> -</span><span id="L-218"><a href="#L-218"><span class="linenos">218</span></a> <span class="s2">"DIV0"</span><span class="p">:</span> <span class="n">_div0_to_if</span><span class="p">,</span> -</span><span id="L-219"><a href="#L-219"><span class="linenos">219</span></a> <span class="s2">"IFF"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-220"><a href="#L-220"><span class="linenos">220</span></a> <span class="s2">"NULLIFZERO"</span><span class="p">:</span> <span class="n">_nullifzero_to_if</span><span class="p">,</span> -</span><span id="L-221"><a href="#L-221"><span class="linenos">221</span></a> <span class="s2">"OBJECT_CONSTRUCT"</span><span class="p">:</span> <span class="n">_parse_object_construct</span><span class="p">,</span> -</span><span id="L-222"><a href="#L-222"><span class="linenos">222</span></a> <span class="s2">"RLIKE"</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-223"><a href="#L-223"><span class="linenos">223</span></a> <span class="s2">"SQUARE"</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">Pow</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">2</span><span class="p">)),</span> -</span><span id="L-224"><a href="#L-224"><span class="linenos">224</span></a> <span class="s2">"TO_ARRAY"</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-225"><a href="#L-225"><span class="linenos">225</span></a> <span class="s2">"TO_VARCHAR"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-226"><a href="#L-226"><span class="linenos">226</span></a> <span class="s2">"TO_TIMESTAMP"</span><span class="p">:</span> <span class="n">_snowflake_to_timestamp</span><span class="p">,</span> -</span><span id="L-227"><a href="#L-227"><span class="linenos">227</span></a> <span class="s2">"ZEROIFNULL"</span><span class="p">:</span> <span class="n">_zeroifnull_to_if</span><span class="p">,</span> -</span><span id="L-228"><a href="#L-228"><span class="linenos">228</span></a> <span class="p">}</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">FUNCTION_PARSERS</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">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="p">,</span> -</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="s2">"DATE_PART"</span><span class="p">:</span> <span class="n">_parse_date_part</span><span class="p">,</span> -</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="p">}</span> -</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> -</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> -</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> <span class="n">FUNC_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-237"><a href="#L-237"><span class="linenos">237</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">FUNC_TOKENS</span><span class="p">,</span> -</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> -</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> -</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="p">}</span> -</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> -</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="n">COLUMN_OPERATORS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-243"><a href="#L-243"><span class="linenos">243</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">COLUMN_OPERATORS</span><span class="p">,</span> -</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLON</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">path</span><span class="p">]</span> -</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="p">),</span> -</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> <span class="p">}</span> -</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> -</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> <span class="n">TIMESTAMPS</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">TIMESTAMPS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="o">-</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">TIME</span><span class="p">}</span> +</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="c1"># https://docs.snowflake.com/en/sql-reference/identifiers-syntax</span> +</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_large"</span> +</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">"'YYYY-MM-DD HH24:MI:SS'"</span> +</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> +</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> <span class="s2">"YYYY"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> +</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="s2">"yyyy"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> +</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> <span class="s2">"YY"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> +</span><span id="L-179"><a href="#L-179"><span class="linenos">179</span></a> <span class="s2">"yy"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> +</span><span id="L-180"><a href="#L-180"><span class="linenos">180</span></a> <span class="s2">"MMMM"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> +</span><span id="L-181"><a href="#L-181"><span class="linenos">181</span></a> <span class="s2">"mmmm"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> +</span><span id="L-182"><a href="#L-182"><span class="linenos">182</span></a> <span class="s2">"MON"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> +</span><span id="L-183"><a href="#L-183"><span class="linenos">183</span></a> <span class="s2">"mon"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> +</span><span id="L-184"><a href="#L-184"><span class="linenos">184</span></a> <span class="s2">"MM"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> +</span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> <span class="s2">"mm"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> +</span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a> <span class="s2">"DD"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%d</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-187"><a href="#L-187"><span class="linenos">187</span></a> <span class="s2">"dd"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%-d</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-188"><a href="#L-188"><span class="linenos">188</span></a> <span class="s2">"DY"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</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="s2">"dy"</span><span class="p">:</span> <span class="s2">"%w"</span><span class="p">,</span> +</span><span id="L-190"><a href="#L-190"><span class="linenos">190</span></a> <span class="s2">"HH24"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> +</span><span id="L-191"><a href="#L-191"><span class="linenos">191</span></a> <span class="s2">"hh24"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> +</span><span id="L-192"><a href="#L-192"><span class="linenos">192</span></a> <span class="s2">"HH12"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> +</span><span id="L-193"><a href="#L-193"><span class="linenos">193</span></a> <span class="s2">"hh12"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> +</span><span id="L-194"><a href="#L-194"><span class="linenos">194</span></a> <span class="s2">"MI"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> +</span><span id="L-195"><a href="#L-195"><span class="linenos">195</span></a> <span class="s2">"mi"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> +</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a> <span class="s2">"SS"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> +</span><span id="L-197"><a href="#L-197"><span class="linenos">197</span></a> <span class="s2">"ss"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> +</span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> <span class="s2">"FF"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-199"><a href="#L-199"><span class="linenos">199</span></a> <span class="s2">"ff"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-200"><a href="#L-200"><span class="linenos">200</span></a> <span class="s2">"FF6"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-201"><a href="#L-201"><span class="linenos">201</span></a> <span class="s2">"ff6"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-202"><a href="#L-202"><span class="linenos">202</span></a> <span class="p">}</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="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-205"><a href="#L-205"><span class="linenos">205</span></a> <span class="n">IDENTIFY_PIVOT_STRINGS</span> <span class="o">=</span> <span class="kc">True</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="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-208"><a href="#L-208"><span class="linenos">208</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-209"><a href="#L-209"><span class="linenos">209</span></a> <span class="s2">"ARRAYAGG"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> <span class="s2">"ARRAY_CONSTRUCT"</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-211"><a href="#L-211"><span class="linenos">211</span></a> <span class="s2">"ARRAY_TO_STRING"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayJoin</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-212"><a href="#L-212"><span class="linenos">212</span></a> <span class="s2">"CONVERT_TIMEZONE"</span><span class="p">:</span> <span class="n">_parse_convert_timezone</span><span class="p">,</span> +</span><span id="L-213"><a href="#L-213"><span class="linenos">213</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-214"><a href="#L-214"><span class="linenos">214</span></a> <span class="s2">"DATEADD"</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">DateAdd</span><span class="p">(</span> +</span><span id="L-215"><a href="#L-215"><span class="linenos">215</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">2</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">unit</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-216"><a href="#L-216"><span class="linenos">216</span></a> <span class="p">),</span> +</span><span id="L-217"><a href="#L-217"><span class="linenos">217</span></a> <span class="s2">"DATEDIFF"</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">DateDiff</span><span class="p">(</span> +</span><span id="L-218"><a href="#L-218"><span class="linenos">218</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">2</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">unit</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-219"><a href="#L-219"><span class="linenos">219</span></a> <span class="p">),</span> +</span><span id="L-220"><a href="#L-220"><span class="linenos">220</span></a> <span class="s2">"DIV0"</span><span class="p">:</span> <span class="n">_div0_to_if</span><span class="p">,</span> +</span><span id="L-221"><a href="#L-221"><span class="linenos">221</span></a> <span class="s2">"IFF"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-222"><a href="#L-222"><span class="linenos">222</span></a> <span class="s2">"NULLIFZERO"</span><span class="p">:</span> <span class="n">_nullifzero_to_if</span><span class="p">,</span> +</span><span id="L-223"><a href="#L-223"><span class="linenos">223</span></a> <span class="s2">"OBJECT_CONSTRUCT"</span><span class="p">:</span> <span class="n">_parse_object_construct</span><span class="p">,</span> +</span><span id="L-224"><a href="#L-224"><span class="linenos">224</span></a> <span class="s2">"RLIKE"</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-225"><a href="#L-225"><span class="linenos">225</span></a> <span class="s2">"SQUARE"</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">Pow</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">2</span><span class="p">)),</span> +</span><span id="L-226"><a href="#L-226"><span class="linenos">226</span></a> <span class="s2">"TO_ARRAY"</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-227"><a href="#L-227"><span class="linenos">227</span></a> <span class="s2">"TO_VARCHAR"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-228"><a href="#L-228"><span class="linenos">228</span></a> <span class="s2">"TO_TIMESTAMP"</span><span class="p">:</span> <span class="n">_snowflake_to_timestamp</span><span class="p">,</span> +</span><span id="L-229"><a href="#L-229"><span class="linenos">229</span></a> <span class="s2">"ZEROIFNULL"</span><span class="p">:</span> <span class="n">_zeroifnull_to_if</span><span class="p">,</span> +</span><span id="L-230"><a href="#L-230"><span class="linenos">230</span></a> <span class="p">}</span> +</span><span id="L-231"><a href="#L-231"><span class="linenos">231</span></a> +</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-233"><a href="#L-233"><span class="linenos">233</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">FUNCTION_PARSERS</span><span class="p">,</span> +</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="s2">"DATE_PART"</span><span class="p">:</span> <span class="n">_parse_date_part</span><span class="p">,</span> +</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="p">}</span> +</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> +</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> +</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="n">FUNC_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-239"><a href="#L-239"><span class="linenos">239</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">FUNC_TOKENS</span><span class="p">,</span> +</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> +</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> +</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="p">}</span> +</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> +</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <span class="n">COLUMN_OPERATORS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-245"><a href="#L-245"><span class="linenos">245</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">COLUMN_OPERATORS</span><span class="p">,</span> +</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLON</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">path</span><span class="p">]</span> +</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> <span class="p">),</span> +</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> <span class="p">}</span> </span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> -</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> <span class="n">RANGE_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-252"><a href="#L-252"><span class="linenos">252</span></a> <span class="o">**</span><span class="n">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">RANGE_PARSERS</span><span class="p">,</span> -</span><span id="L-253"><a href="#L-253"><span class="linenos">253</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIKE_ANY</span><span class="p">:</span> <span class="n">binary_range_parser</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LikeAny</span><span class="p">),</span> -</span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ILIKE_ANY</span><span class="p">:</span> <span class="n">binary_range_parser</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ILikeAny</span><span class="p">),</span> -</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="p">}</span> -</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> -</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a> <span class="n">ALTER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-258"><a href="#L-258"><span class="linenos">258</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">ALTER_PARSERS</span><span class="p">,</span> -</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="s2">"UNSET"</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_alter_table_set_tag</span><span class="p">(</span><span class="n">unset</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> <span class="s2">"SET"</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_alter_table_set_tag</span><span class="p">(),</span> -</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> <span class="p">}</span> -</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> -</span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_set_tag</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">unset</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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TAG"</span><span class="p">)</span> -</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span> <span class="k">if</span> <span class="n">unset</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="L-266"><a href="#L-266"><span class="linenos">266</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">SetTag</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">parser</span><span class="p">),</span> <span class="n">unset</span><span class="o">=</span><span class="n">unset</span><span class="p">)</span> -</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> -</span><span id="L-268"><a href="#L-268"><span class="linenos">268</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-269"><a href="#L-269"><span class="linenos">269</span></a> <span class="n">QUOTES</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-270"><a href="#L-270"><span class="linenos">270</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">]</span> -</span><span id="L-271"><a href="#L-271"><span class="linenos">271</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"x'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"X'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">)]</span> -</span><span id="L-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="n">COMMENTS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--"</span><span class="p">,</span> <span class="s2">"//"</span><span class="p">,</span> <span class="p">(</span><span class="s2">"/*"</span><span class="p">,</span> <span class="s2">"*/"</span><span class="p">)]</span> -</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> -</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-275"><a href="#L-275"><span class="linenos">275</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-276"><a href="#L-276"><span class="linenos">276</span></a> <span class="s2">"CHAR VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> -</span><span id="L-277"><a href="#L-277"><span class="linenos">277</span></a> <span class="s2">"CHARACTER VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> -</span><span id="L-278"><a href="#L-278"><span class="linenos">278</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-279"><a href="#L-279"><span class="linenos">279</span></a> <span class="s2">"ILIKE ANY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ILIKE_ANY</span><span class="p">,</span> -</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a> <span class="s2">"LIKE ANY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIKE_ANY</span><span class="p">,</span> -</span><span id="L-281"><a href="#L-281"><span class="linenos">281</span></a> <span class="s2">"MATCH_RECOGNIZE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MATCH_RECOGNIZE</span><span class="p">,</span> -</span><span id="L-282"><a href="#L-282"><span class="linenos">282</span></a> <span class="s2">"MINUS"</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-283"><a href="#L-283"><span class="linenos">283</span></a> <span class="s2">"NCHAR VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> -</span><span id="L-284"><a href="#L-284"><span class="linenos">284</span></a> <span class="s2">"PUT"</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-285"><a href="#L-285"><span class="linenos">285</span></a> <span class="s2">"RENAME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">,</span> -</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a> <span class="s2">"TIMESTAMP_LTZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">,</span> -</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a> <span class="s2">"TIMESTAMP_NTZ"</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-288"><a href="#L-288"><span class="linenos">288</span></a> <span class="s2">"TIMESTAMP_TZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> -</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a> <span class="s2">"TIMESTAMPNTZ"</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-290"><a href="#L-290"><span class="linenos">290</span></a> <span class="s2">"SAMPLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span><span class="p">,</span> -</span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a> <span class="p">}</span> -</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a> -</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-294"><a href="#L-294"><span class="linenos">294</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-295"><a href="#L-295"><span class="linenos">295</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-296"><a href="#L-296"><span class="linenos">296</span></a> <span class="p">}</span> -</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a> -</span><span id="L-298"><a href="#L-298"><span class="linenos">298</span></a> <span class="n">VAR_SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"$"</span><span class="p">}</span> +</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> <span class="n">TIMESTAMPS</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">TIMESTAMPS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="o">-</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">TIME</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">RANGE_PARSERS</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">parser</span><span class="o">.</span><span class="n">Parser</span><span class="o">.</span><span class="n">RANGE_PARSERS</span><span class="p">,</span> +</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIKE_ANY</span><span class="p">:</span> <span class="n">binary_range_parser</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LikeAny</span><span class="p">),</span> +</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ILIKE_ANY</span><span class="p">:</span> <span class="n">binary_range_parser</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ILikeAny</span><span class="p">),</span> +</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a> <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">ALTER_PARSERS</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">ALTER_PARSERS</span><span class="p">,</span> +</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> <span class="s2">"UNSET"</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_alter_table_set_tag</span><span class="p">(</span><span class="n">unset</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="s2">"SET"</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_alter_table_set_tag</span><span class="p">(),</span> +</span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a> <span class="p">}</span> +</span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> +</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_set_tag</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">unset</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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TAG"</span><span class="p">)</span> +</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span> <span class="k">if</span> <span class="n">unset</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="L-268"><a href="#L-268"><span class="linenos">268</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">SetTag</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">parser</span><span class="p">),</span> <span class="n">unset</span><span class="o">=</span><span class="n">unset</span><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="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-271"><a href="#L-271"><span class="linenos">271</span></a> <span class="n">QUOTES</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-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">]</span> +</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"x'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"X'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">)]</span> +</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="n">COMMENTS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--"</span><span class="p">,</span> <span class="s2">"//"</span><span class="p">,</span> <span class="p">(</span><span class="s2">"/*"</span><span class="p">,</span> <span class="s2">"*/"</span><span class="p">)]</span> +</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a> +</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-277"><a href="#L-277"><span class="linenos">277</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-278"><a href="#L-278"><span class="linenos">278</span></a> <span class="s2">"CHAR VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> +</span><span id="L-279"><a href="#L-279"><span class="linenos">279</span></a> <span class="s2">"CHARACTER VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> +</span><span id="L-280"><a href="#L-280"><span class="linenos">280</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-281"><a href="#L-281"><span class="linenos">281</span></a> <span class="s2">"ILIKE ANY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ILIKE_ANY</span><span class="p">,</span> +</span><span id="L-282"><a href="#L-282"><span class="linenos">282</span></a> <span class="s2">"LIKE ANY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIKE_ANY</span><span class="p">,</span> +</span><span id="L-283"><a href="#L-283"><span class="linenos">283</span></a> <span class="s2">"MATCH_RECOGNIZE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MATCH_RECOGNIZE</span><span class="p">,</span> +</span><span id="L-284"><a href="#L-284"><span class="linenos">284</span></a> <span class="s2">"MINUS"</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-285"><a href="#L-285"><span class="linenos">285</span></a> <span class="s2">"NCHAR VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> +</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a> <span class="s2">"PUT"</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-287"><a href="#L-287"><span class="linenos">287</span></a> <span class="s2">"RENAME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">,</span> +</span><span id="L-288"><a href="#L-288"><span class="linenos">288</span></a> <span class="s2">"TIMESTAMP_LTZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">,</span> +</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a> <span class="s2">"TIMESTAMP_NTZ"</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-290"><a href="#L-290"><span class="linenos">290</span></a> <span class="s2">"TIMESTAMP_TZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> +</span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a> <span class="s2">"TIMESTAMPNTZ"</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-292"><a href="#L-292"><span class="linenos">292</span></a> <span class="s2">"SAMPLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span><span class="p">,</span> +</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a> <span class="p">}</span> +</span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a> +</span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-296"><a href="#L-296"><span class="linenos">296</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-297"><a href="#L-297"><span class="linenos">297</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-298"><a href="#L-298"><span class="linenos">298</span></a> <span class="p">}</span> </span><span id="L-299"><a href="#L-299"><span class="linenos">299</span></a> -</span><span id="L-300"><a href="#L-300"><span class="linenos">300</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-301"><a href="#L-301"><span class="linenos">301</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"$"</span> -</span><span id="L-302"><a href="#L-302"><span class="linenos">302</span></a> <span class="n">MATCHED_BY_SOURCE</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-303"><a href="#L-303"><span class="linenos">303</span></a> <span class="n">SINGLE_STRING_INTERVAL</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-305"><a href="#L-305"><span class="linenos">305</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-306"><a href="#L-306"><span class="linenos">306</span></a> -</span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-308"><a href="#L-308"><span class="linenos">308</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-309"><a href="#L-309"><span class="linenos">309</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_sql</span><span class="p">,</span> -</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_CAT"</span><span class="p">),</span> -</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayJoin</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_TO_STRING"</span><span class="p">),</span> -</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</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-313"><a href="#L-313"><span class="linenos">313</span></a> <span class="s2">"CONVERT_TIMEZONE"</span><span class="p">,</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="s2">"zone"</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> <span class="p">),</span> -</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</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">"DATEADD"</span><span class="p">,</span> <span class="n">e</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="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 class="p">),</span> -</span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="s2">"DATEDIFF"</span><span class="p">,</span> <span class="n">e</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="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-318"><a href="#L-318"><span class="linenos">318</span></a> <span class="p">),</span> -</span><span id="L-319"><a href="#L-319"><span class="linenos">319</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">datestrtodate_sql</span><span class="p">,</span> -</span><span id="L-320"><a href="#L-320"><span class="linenos">320</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">:</span> <span class="n">_datatype_sql</span><span class="p">,</span> -</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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-322"><a href="#L-322"><span class="linenos">322</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATE_PART"</span><span class="p">),</span> -</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"IFF"</span><span class="p">),</span> -</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalAnd</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOLAND_AGG"</span><span class="p">),</span> -</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalOr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOLOR_AGG"</span><span class="p">),</span> -</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Map</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">var_map_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">"OBJECT_CONSTRUCT"</span><span class="p">),</span> -</span><span id="L-327"><a href="#L-327"><span class="linenos">327</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> -</span><span id="L-328"><a href="#L-328"><span class="linenos">328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> -</span><span id="L-329"><a href="#L-329"><span class="linenos">329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</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">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-330"><a href="#L-330"><span class="linenos">330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</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">eliminate_distinct_on</span><span class="p">]),</span> -</span><span id="L-331"><a href="#L-331"><span class="linenos">331</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StarMap</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"OBJECT_CONSTRUCT"</span><span class="p">),</span> -</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</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-333"><a href="#L-333"><span class="linenos">333</span></a> <span class="s2">"POSITION"</span><span class="p">,</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="s2">"substr"</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">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">"position"</span><span class="p">)</span> -</span><span id="L-334"><a href="#L-334"><span class="linenos">334</span></a> <span class="p">),</span> -</span><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</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">"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">, </span><span class="si">{</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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-336"><a href="#L-336"><span class="linenos">336</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</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-337"><a href="#L-337"><span class="linenos">337</span></a> <span class="s2">"OBJECT_CONSTRUCT"</span><span class="p">,</span> -</span><span id="L-338"><a href="#L-338"><span class="linenos">338</span></a> <span class="o">*</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">e</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">()),</span> -</span><span id="L-339"><a href="#L-339"><span class="linenos">339</span></a> <span class="p">),</span> -</span><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> -</span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</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">"EXTRACT(epoch_second FROM </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-342"><a href="#L-342"><span class="linenos">342</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><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a> <span class="s2">"TO_CHAR"</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="s2">"timestamp"</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-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="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-346"><a href="#L-346"><span class="linenos">346</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</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">function_fallback_sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</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">"TRIM"</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">e</span><span class="o">.</span><span class="n">expression</span><span class="p">),</span> -</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="s2">"snowflake"</span><span class="p">),</span> -</span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UnixToTime</span><span class="p">:</span> <span class="n">_unix_to_time_sql</span><span class="p">,</span> -</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</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">var_map_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">"OBJECT_CONSTRUCT"</span><span class="p">),</span> -</span><span id="L-351"><a href="#L-351"><span class="linenos">351</span></a> <span class="p">}</span> -</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a> -</span><span id="L-353"><a href="#L-353"><span class="linenos">353</span></a> <span class="n">TYPE_MAPPING</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="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-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">TIMESTAMP</span><span class="p">:</span> <span class="s2">"TIMESTAMPNTZ"</span><span class="p">,</span> -</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a> <span class="p">}</span> -</span><span id="L-357"><a href="#L-357"><span class="linenos">357</span></a> -</span><span id="L-358"><a href="#L-358"><span class="linenos">358</span></a> <span class="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-359"><a href="#L-359"><span class="linenos">359</span></a> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCLUDE"</span><span class="p">,</span> -</span><span id="L-360"><a href="#L-360"><span class="linenos">360</span></a> <span class="s2">"replace"</span><span class="p">:</span> <span class="s2">"RENAME"</span><span class="p">,</span> -</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a> <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="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-364"><a href="#L-364"><span class="linenos">364</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">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="L-365"><a href="#L-365"><span class="linenos">365</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="L-366"><a href="#L-366"><span class="linenos">366</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="L-367"><a href="#L-367"><span class="linenos">367</span></a> <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">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-370"><a href="#L-370"><span class="linenos">370</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> -</span><span id="L-371"><a href="#L-371"><span class="linenos">371</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"EXCEPT with All is not supported in Snowflake"</span><span class="p">)</span> -</span><span id="L-372"><a href="#L-372"><span class="linenos">372</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-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">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-375"><a href="#L-375"><span class="linenos">375</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">"distinct"</span><span class="p">,</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="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"INTERSECT with All is not supported in Snowflake"</span><span class="p">)</span> -</span><span id="L-377"><a href="#L-377"><span class="linenos">377</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-378"><a href="#L-378"><span class="linenos">378</span></a> -</span><span id="L-379"><a href="#L-379"><span class="linenos">379</span></a> <span class="k">def</span> <span class="nf">settag_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetTag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-380"><a href="#L-380"><span class="linenos">380</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"UNSET"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unset"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"SET"</span> -</span><span id="L-381"><a href="#L-381"><span class="linenos">381</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">action</span><span class="si">}</span><span class="s2"> TAG </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-382"><a href="#L-382"><span class="linenos">382</span></a> -</span><span id="L-383"><a href="#L-383"><span class="linenos">383</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-384"><a href="#L-384"><span class="linenos">384</span></a> <span class="c1"># Default to table if kind is unknown</span> -</span><span id="L-385"><a href="#L-385"><span class="linenos">385</span></a> <span class="n">kind_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"TABLE"</span> -</span><span id="L-386"><a href="#L-386"><span class="linenos">386</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind_value</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind_value</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-387"><a href="#L-387"><span class="linenos">387</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-388"><a href="#L-388"><span class="linenos">388</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-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">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> -</span><span id="L-391"><a href="#L-391"><span class="linenos">391</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> -</span><span id="L-392"><a href="#L-392"><span class="linenos">392</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-393"><a href="#L-393"><span class="linenos">393</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"start"</span><span class="p">)</span> -</span><span id="L-394"><a href="#L-394"><span class="linenos">394</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" START </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-395"><a href="#L-395"><span class="linenos">395</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"increment"</span><span class="p">)</span> -</span><span id="L-396"><a href="#L-396"><span class="linenos">396</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-397"><a href="#L-397"><span class="linenos">397</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"AUTOINCREMENT</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-300"><a href="#L-300"><span class="linenos">300</span></a> <span class="n">VAR_SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"$"</span><span class="p">}</span> +</span><span id="L-301"><a href="#L-301"><span class="linenos">301</span></a> +</span><span id="L-302"><a href="#L-302"><span class="linenos">302</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-303"><a href="#L-303"><span class="linenos">303</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"$"</span> +</span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a> <span class="n">MATCHED_BY_SOURCE</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-305"><a href="#L-305"><span class="linenos">305</span></a> <span class="n">SINGLE_STRING_INTERVAL</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-306"><a href="#L-306"><span class="linenos">306</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a> +</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-310"><a href="#L-310"><span class="linenos">310</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-311"><a href="#L-311"><span class="linenos">311</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_sql</span><span class="p">,</span> +</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_CAT"</span><span class="p">),</span> +</span><span id="L-313"><a href="#L-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayJoin</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_TO_STRING"</span><span class="p">),</span> +</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</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-315"><a href="#L-315"><span class="linenos">315</span></a> <span class="s2">"CONVERT_TIMEZONE"</span><span class="p">,</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="s2">"zone"</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> <span class="p">),</span> +</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</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">"DATEADD"</span><span class="p">,</span> <span class="n">e</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="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 class="p">),</span> +</span><span id="L-318"><a href="#L-318"><span class="linenos">318</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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-319"><a href="#L-319"><span class="linenos">319</span></a> <span class="s2">"DATEDIFF"</span><span class="p">,</span> <span class="n">e</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="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-320"><a href="#L-320"><span class="linenos">320</span></a> <span class="p">),</span> +</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</span><span class="p">:</span> <span class="n">datestrtodate_sql</span><span class="p">,</span> +</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">:</span> <span class="n">_datatype_sql</span><span class="p">,</span> +</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">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-324"><a href="#L-324"><span class="linenos">324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATE_PART"</span><span class="p">),</span> +</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"IFF"</span><span class="p">),</span> +</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalAnd</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOLAND_AGG"</span><span class="p">),</span> +</span><span id="L-327"><a href="#L-327"><span class="linenos">327</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogicalOr</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"BOOLOR_AGG"</span><span class="p">),</span> +</span><span id="L-328"><a href="#L-328"><span class="linenos">328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Map</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">var_map_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">"OBJECT_CONSTRUCT"</span><span class="p">),</span> +</span><span id="L-329"><a href="#L-329"><span class="linenos">329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> +</span><span id="L-330"><a href="#L-330"><span class="linenos">330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> +</span><span id="L-331"><a href="#L-331"><span class="linenos">331</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</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">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</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">eliminate_distinct_on</span><span class="p">]),</span> +</span><span id="L-333"><a href="#L-333"><span class="linenos">333</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StarMap</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"OBJECT_CONSTRUCT"</span><span class="p">),</span> +</span><span id="L-334"><a href="#L-334"><span class="linenos">334</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</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-335"><a href="#L-335"><span class="linenos">335</span></a> <span class="s2">"POSITION"</span><span class="p">,</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="s2">"substr"</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">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">"position"</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 class="n">exp</span><span class="o">.</span><span class="n">StrToTime</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">"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">, </span><span class="si">{</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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-338"><a href="#L-338"><span class="linenos">338</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</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-339"><a href="#L-339"><span class="linenos">339</span></a> <span class="s2">"OBJECT_CONSTRUCT"</span><span class="p">,</span> +</span><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a> <span class="o">*</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">e</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">()),</span> +</span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a> <span class="p">),</span> +</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</span><span class="p">:</span> <span class="n">timestrtotime_sql</span><span class="p">,</span> +</span><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</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">"EXTRACT(epoch_second FROM </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-344"><a href="#L-344"><span class="linenos">344</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><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> <span class="s2">"TO_CHAR"</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="s2">"timestamp"</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-346"><a href="#L-346"><span class="linenos">346</span></a> <span class="p">),</span> +</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimestampTrunc</span><span class="p">:</span> <span class="n">timestamptrunc_sql</span><span class="p">,</span> +</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</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">function_fallback_sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</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">"TRIM"</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">e</span><span class="o">.</span><span class="n">expression</span><span class="p">),</span> +</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="s2">"snowflake"</span><span class="p">),</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">UnixToTime</span><span class="p">:</span> <span class="n">_unix_to_time_sql</span><span class="p">,</span> +</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</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">var_map_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">"OBJECT_CONSTRUCT"</span><span class="p">),</span> +</span><span id="L-353"><a href="#L-353"><span class="linenos">353</span></a> <span class="p">}</span> +</span><span id="L-354"><a href="#L-354"><span class="linenos">354</span></a> +</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-356"><a href="#L-356"><span class="linenos">356</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-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">TIMESTAMP</span><span class="p">:</span> <span class="s2">"TIMESTAMPNTZ"</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="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCLUDE"</span><span class="p">,</span> +</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a> <span class="s2">"replace"</span><span class="p">:</span> <span class="s2">"RENAME"</span><span class="p">,</span> +</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a> <span class="p">}</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="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-366"><a href="#L-366"><span class="linenos">366</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">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="L-367"><a href="#L-367"><span class="linenos">367</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="L-368"><a href="#L-368"><span class="linenos">368</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="L-369"><a href="#L-369"><span class="linenos">369</span></a> <span class="p">}</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">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-372"><a href="#L-372"><span class="linenos">372</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> +</span><span id="L-373"><a href="#L-373"><span class="linenos">373</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"EXCEPT with All is not supported in Snowflake"</span><span class="p">)</span> +</span><span id="L-374"><a href="#L-374"><span class="linenos">374</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-375"><a href="#L-375"><span class="linenos">375</span></a> +</span><span id="L-376"><a href="#L-376"><span class="linenos">376</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-377"><a href="#L-377"><span class="linenos">377</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> +</span><span id="L-378"><a href="#L-378"><span class="linenos">378</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"INTERSECT with All is not supported in Snowflake"</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="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-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">settag_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetTag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-382"><a href="#L-382"><span class="linenos">382</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"UNSET"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unset"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"SET"</span> +</span><span id="L-383"><a href="#L-383"><span class="linenos">383</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">action</span><span class="si">}</span><span class="s2"> TAG </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-384"><a href="#L-384"><span class="linenos">384</span></a> +</span><span id="L-385"><a href="#L-385"><span class="linenos">385</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-386"><a href="#L-386"><span class="linenos">386</span></a> <span class="c1"># Default to table if kind is unknown</span> +</span><span id="L-387"><a href="#L-387"><span class="linenos">387</span></a> <span class="n">kind_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"TABLE"</span> +</span><span id="L-388"><a href="#L-388"><span class="linenos">388</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind_value</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind_value</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-389"><a href="#L-389"><span class="linenos">389</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-390"><a href="#L-390"><span class="linenos">390</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-391"><a href="#L-391"><span class="linenos">391</span></a> +</span><span id="L-392"><a href="#L-392"><span class="linenos">392</span></a> <span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> +</span><span id="L-393"><a href="#L-393"><span class="linenos">393</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> +</span><span id="L-394"><a href="#L-394"><span class="linenos">394</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-395"><a href="#L-395"><span class="linenos">395</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"start"</span><span class="p">)</span> +</span><span id="L-396"><a href="#L-396"><span class="linenos">396</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" START </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-397"><a href="#L-397"><span class="linenos">397</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"increment"</span><span class="p">)</span> +</span><span id="L-398"><a href="#L-398"><span class="linenos">398</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-399"><a href="#L-399"><span class="linenos">399</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"AUTOINCREMENT</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -505,234 +510,236 @@ </div> <a class="headerlink" href="#Snowflake"></a> <div class="pdoc-code codehilite"><pre><span></span><span id="Snowflake-170"><a href="#Snowflake-170"><span class="linenos">170</span></a><span class="k">class</span> <span class="nc">Snowflake</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> -</span><span id="Snowflake-171"><a href="#Snowflake-171"><span class="linenos">171</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_large"</span> -</span><span id="Snowflake-172"><a href="#Snowflake-172"><span class="linenos">172</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">"'YYYY-MM-DD HH24:MI:SS'"</span> -</span><span id="Snowflake-173"><a href="#Snowflake-173"><span class="linenos">173</span></a> -</span><span id="Snowflake-174"><a href="#Snowflake-174"><span class="linenos">174</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake-175"><a href="#Snowflake-175"><span class="linenos">175</span></a> <span class="s2">"YYYY"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> -</span><span id="Snowflake-176"><a href="#Snowflake-176"><span class="linenos">176</span></a> <span class="s2">"yyyy"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> -</span><span id="Snowflake-177"><a href="#Snowflake-177"><span class="linenos">177</span></a> <span class="s2">"YY"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> -</span><span id="Snowflake-178"><a href="#Snowflake-178"><span class="linenos">178</span></a> <span class="s2">"yy"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> -</span><span id="Snowflake-179"><a href="#Snowflake-179"><span class="linenos">179</span></a> <span class="s2">"MMMM"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> -</span><span id="Snowflake-180"><a href="#Snowflake-180"><span class="linenos">180</span></a> <span class="s2">"mmmm"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> -</span><span id="Snowflake-181"><a href="#Snowflake-181"><span class="linenos">181</span></a> <span class="s2">"MON"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> -</span><span id="Snowflake-182"><a href="#Snowflake-182"><span class="linenos">182</span></a> <span class="s2">"mon"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> -</span><span id="Snowflake-183"><a href="#Snowflake-183"><span class="linenos">183</span></a> <span class="s2">"MM"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> -</span><span id="Snowflake-184"><a href="#Snowflake-184"><span class="linenos">184</span></a> <span class="s2">"mm"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> -</span><span id="Snowflake-185"><a href="#Snowflake-185"><span class="linenos">185</span></a> <span class="s2">"DD"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%d</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Snowflake-186"><a href="#Snowflake-186"><span class="linenos">186</span></a> <span class="s2">"dd"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%-d</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Snowflake-187"><a href="#Snowflake-187"><span class="linenos">187</span></a> <span class="s2">"DY"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Snowflake-188"><a href="#Snowflake-188"><span class="linenos">188</span></a> <span class="s2">"dy"</span><span class="p">:</span> <span class="s2">"%w"</span><span class="p">,</span> -</span><span id="Snowflake-189"><a href="#Snowflake-189"><span class="linenos">189</span></a> <span class="s2">"HH24"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> -</span><span id="Snowflake-190"><a href="#Snowflake-190"><span class="linenos">190</span></a> <span class="s2">"hh24"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> -</span><span id="Snowflake-191"><a href="#Snowflake-191"><span class="linenos">191</span></a> <span class="s2">"HH12"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> -</span><span id="Snowflake-192"><a href="#Snowflake-192"><span class="linenos">192</span></a> <span class="s2">"hh12"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> -</span><span id="Snowflake-193"><a href="#Snowflake-193"><span class="linenos">193</span></a> <span class="s2">"MI"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> -</span><span id="Snowflake-194"><a href="#Snowflake-194"><span class="linenos">194</span></a> <span class="s2">"mi"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> -</span><span id="Snowflake-195"><a href="#Snowflake-195"><span class="linenos">195</span></a> <span class="s2">"SS"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> -</span><span id="Snowflake-196"><a href="#Snowflake-196"><span class="linenos">196</span></a> <span class="s2">"ss"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> -</span><span id="Snowflake-197"><a href="#Snowflake-197"><span class="linenos">197</span></a> <span class="s2">"FF"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Snowflake-198"><a href="#Snowflake-198"><span class="linenos">198</span></a> <span class="s2">"ff"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Snowflake-199"><a href="#Snowflake-199"><span class="linenos">199</span></a> <span class="s2">"FF6"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Snowflake-200"><a href="#Snowflake-200"><span class="linenos">200</span></a> <span class="s2">"ff6"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Snowflake-201"><a href="#Snowflake-201"><span class="linenos">201</span></a> <span class="p">}</span> -</span><span id="Snowflake-202"><a href="#Snowflake-202"><span class="linenos">202</span></a> -</span><span id="Snowflake-203"><a href="#Snowflake-203"><span class="linenos">203</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="Snowflake-204"><a href="#Snowflake-204"><span class="linenos">204</span></a> <span class="n">IDENTIFY_PIVOT_STRINGS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Snowflake-205"><a href="#Snowflake-205"><span class="linenos">205</span></a> -</span><span id="Snowflake-206"><a href="#Snowflake-206"><span class="linenos">206</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake-207"><a href="#Snowflake-207"><span class="linenos">207</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="Snowflake-208"><a href="#Snowflake-208"><span class="linenos">208</span></a> <span class="s2">"ARRAYAGG"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Snowflake-209"><a href="#Snowflake-209"><span class="linenos">209</span></a> <span class="s2">"ARRAY_CONSTRUCT"</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="Snowflake-210"><a href="#Snowflake-210"><span class="linenos">210</span></a> <span class="s2">"ARRAY_TO_STRING"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayJoin</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Snowflake-211"><a href="#Snowflake-211"><span class="linenos">211</span></a> <span class="s2">"CONVERT_TIMEZONE"</span><span class="p">:</span> <span class="n">_parse_convert_timezone</span><span class="p">,</span> -</span><span id="Snowflake-212"><a href="#Snowflake-212"><span class="linenos">212</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="Snowflake-213"><a href="#Snowflake-213"><span class="linenos">213</span></a> <span class="s2">"DATEADD"</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">DateAdd</span><span class="p">(</span> -</span><span id="Snowflake-214"><a href="#Snowflake-214"><span class="linenos">214</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">2</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">unit</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="Snowflake-215"><a href="#Snowflake-215"><span class="linenos">215</span></a> <span class="p">),</span> -</span><span id="Snowflake-216"><a href="#Snowflake-216"><span class="linenos">216</span></a> <span class="s2">"DATEDIFF"</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">DateDiff</span><span class="p">(</span> -</span><span id="Snowflake-217"><a href="#Snowflake-217"><span class="linenos">217</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">2</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">unit</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="Snowflake-218"><a href="#Snowflake-218"><span class="linenos">218</span></a> <span class="p">),</span> -</span><span id="Snowflake-219"><a href="#Snowflake-219"><span class="linenos">219</span></a> <span class="s2">"DIV0"</span><span class="p">:</span> <span class="n">_div0_to_if</span><span class="p">,</span> -</span><span id="Snowflake-220"><a href="#Snowflake-220"><span class="linenos">220</span></a> <span class="s2">"IFF"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Snowflake-221"><a href="#Snowflake-221"><span class="linenos">221</span></a> <span class="s2">"NULLIFZERO"</span><span class="p">:</span> <span class="n">_nullifzero_to_if</span><span class="p">,</span> -</span><span id="Snowflake-222"><a href="#Snowflake-222"><span class="linenos">222</span></a> <span class="s2">"OBJECT_CONSTRUCT"</span><span class="p">:</span> <span class="n">_parse_object_construct</span><span class="p">,</span> -</span><span id="Snowflake-223"><a href="#Snowflake-223"><span class="linenos">223</span></a> <span class="s2">"RLIKE"</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="Snowflake-224"><a href="#Snowflake-224"><span class="linenos">224</span></a> <span class="s2">"SQUARE"</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">Pow</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">2</span><span class="p">)),</span> -</span><span id="Snowflake-225"><a href="#Snowflake-225"><span class="linenos">225</span></a> <span class="s2">"TO_ARRAY"</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="Snowflake-226"><a href="#Snowflake-226"><span class="linenos">226</span></a> <span class="s2">"TO_VARCHAR"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Snowflake-227"><a href="#Snowflake-227"><span class="linenos">227</span></a> <span class="s2">"TO_TIMESTAMP"</span><span class="p">:</span> <span class="n">_snowflake_to_timestamp</span><span class="p">,</span> -</span><span id="Snowflake-228"><a href="#Snowflake-228"><span class="linenos">228</span></a> <span class="s2">"ZEROIFNULL"</span><span class="p">:</span> <span class="n">_zeroifnull_to_if</span><span class="p">,</span> -</span><span id="Snowflake-229"><a href="#Snowflake-229"><span class="linenos">229</span></a> <span class="p">}</span> -</span><span id="Snowflake-230"><a href="#Snowflake-230"><span class="linenos">230</span></a> -</span><span id="Snowflake-231"><a href="#Snowflake-231"><span class="linenos">231</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake-232"><a href="#Snowflake-232"><span class="linenos">232</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">FUNCTION_PARSERS</span><span class="p">,</span> -</span><span id="Snowflake-233"><a href="#Snowflake-233"><span class="linenos">233</span></a> <span class="s2">"DATE_PART"</span><span class="p">:</span> <span class="n">_parse_date_part</span><span class="p">,</span> -</span><span id="Snowflake-234"><a href="#Snowflake-234"><span class="linenos">234</span></a> <span class="p">}</span> -</span><span id="Snowflake-235"><a href="#Snowflake-235"><span class="linenos">235</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> -</span><span id="Snowflake-236"><a href="#Snowflake-236"><span class="linenos">236</span></a> -</span><span id="Snowflake-237"><a href="#Snowflake-237"><span class="linenos">237</span></a> <span class="n">FUNC_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake-238"><a href="#Snowflake-238"><span class="linenos">238</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">FUNC_TOKENS</span><span class="p">,</span> -</span><span id="Snowflake-239"><a href="#Snowflake-239"><span class="linenos">239</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> -</span><span id="Snowflake-240"><a href="#Snowflake-240"><span class="linenos">240</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> -</span><span id="Snowflake-241"><a href="#Snowflake-241"><span class="linenos">241</span></a> <span class="p">}</span> -</span><span id="Snowflake-242"><a href="#Snowflake-242"><span class="linenos">242</span></a> -</span><span id="Snowflake-243"><a href="#Snowflake-243"><span class="linenos">243</span></a> <span class="n">COLUMN_OPERATORS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake-244"><a href="#Snowflake-244"><span class="linenos">244</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">COLUMN_OPERATORS</span><span class="p">,</span> -</span><span id="Snowflake-245"><a href="#Snowflake-245"><span class="linenos">245</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLON</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Snowflake-246"><a href="#Snowflake-246"><span class="linenos">246</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">path</span><span class="p">]</span> -</span><span id="Snowflake-247"><a href="#Snowflake-247"><span class="linenos">247</span></a> <span class="p">),</span> -</span><span id="Snowflake-248"><a href="#Snowflake-248"><span class="linenos">248</span></a> <span class="p">}</span> -</span><span id="Snowflake-249"><a href="#Snowflake-249"><span class="linenos">249</span></a> -</span><span id="Snowflake-250"><a href="#Snowflake-250"><span class="linenos">250</span></a> <span class="n">TIMESTAMPS</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">TIMESTAMPS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="o">-</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">TIME</span><span class="p">}</span> +</span><span id="Snowflake-171"><a href="#Snowflake-171"><span class="linenos">171</span></a> <span class="c1"># https://docs.snowflake.com/en/sql-reference/identifiers-syntax</span> +</span><span id="Snowflake-172"><a href="#Snowflake-172"><span class="linenos">172</span></a> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Snowflake-173"><a href="#Snowflake-173"><span class="linenos">173</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_large"</span> +</span><span id="Snowflake-174"><a href="#Snowflake-174"><span class="linenos">174</span></a> <span class="n">TIME_FORMAT</span> <span class="o">=</span> <span class="s2">"'YYYY-MM-DD HH24:MI:SS'"</span> +</span><span id="Snowflake-175"><a href="#Snowflake-175"><span class="linenos">175</span></a> +</span><span id="Snowflake-176"><a href="#Snowflake-176"><span class="linenos">176</span></a> <span class="n">TIME_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake-177"><a href="#Snowflake-177"><span class="linenos">177</span></a> <span class="s2">"YYYY"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> +</span><span id="Snowflake-178"><a href="#Snowflake-178"><span class="linenos">178</span></a> <span class="s2">"yyyy"</span><span class="p">:</span> <span class="s2">"%Y"</span><span class="p">,</span> +</span><span id="Snowflake-179"><a href="#Snowflake-179"><span class="linenos">179</span></a> <span class="s2">"YY"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> +</span><span id="Snowflake-180"><a href="#Snowflake-180"><span class="linenos">180</span></a> <span class="s2">"yy"</span><span class="p">:</span> <span class="s2">"%y"</span><span class="p">,</span> +</span><span id="Snowflake-181"><a href="#Snowflake-181"><span class="linenos">181</span></a> <span class="s2">"MMMM"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> +</span><span id="Snowflake-182"><a href="#Snowflake-182"><span class="linenos">182</span></a> <span class="s2">"mmmm"</span><span class="p">:</span> <span class="s2">"%B"</span><span class="p">,</span> +</span><span id="Snowflake-183"><a href="#Snowflake-183"><span class="linenos">183</span></a> <span class="s2">"MON"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> +</span><span id="Snowflake-184"><a href="#Snowflake-184"><span class="linenos">184</span></a> <span class="s2">"mon"</span><span class="p">:</span> <span class="s2">"%b"</span><span class="p">,</span> +</span><span id="Snowflake-185"><a href="#Snowflake-185"><span class="linenos">185</span></a> <span class="s2">"MM"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> +</span><span id="Snowflake-186"><a href="#Snowflake-186"><span class="linenos">186</span></a> <span class="s2">"mm"</span><span class="p">:</span> <span class="s2">"%m"</span><span class="p">,</span> +</span><span id="Snowflake-187"><a href="#Snowflake-187"><span class="linenos">187</span></a> <span class="s2">"DD"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%d</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Snowflake-188"><a href="#Snowflake-188"><span class="linenos">188</span></a> <span class="s2">"dd"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%-d</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Snowflake-189"><a href="#Snowflake-189"><span class="linenos">189</span></a> <span class="s2">"DY"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%a</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Snowflake-190"><a href="#Snowflake-190"><span class="linenos">190</span></a> <span class="s2">"dy"</span><span class="p">:</span> <span class="s2">"%w"</span><span class="p">,</span> +</span><span id="Snowflake-191"><a href="#Snowflake-191"><span class="linenos">191</span></a> <span class="s2">"HH24"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> +</span><span id="Snowflake-192"><a href="#Snowflake-192"><span class="linenos">192</span></a> <span class="s2">"hh24"</span><span class="p">:</span> <span class="s2">"%H"</span><span class="p">,</span> +</span><span id="Snowflake-193"><a href="#Snowflake-193"><span class="linenos">193</span></a> <span class="s2">"HH12"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> +</span><span id="Snowflake-194"><a href="#Snowflake-194"><span class="linenos">194</span></a> <span class="s2">"hh12"</span><span class="p">:</span> <span class="s2">"%I"</span><span class="p">,</span> +</span><span id="Snowflake-195"><a href="#Snowflake-195"><span class="linenos">195</span></a> <span class="s2">"MI"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> +</span><span id="Snowflake-196"><a href="#Snowflake-196"><span class="linenos">196</span></a> <span class="s2">"mi"</span><span class="p">:</span> <span class="s2">"%M"</span><span class="p">,</span> +</span><span id="Snowflake-197"><a href="#Snowflake-197"><span class="linenos">197</span></a> <span class="s2">"SS"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> +</span><span id="Snowflake-198"><a href="#Snowflake-198"><span class="linenos">198</span></a> <span class="s2">"ss"</span><span class="p">:</span> <span class="s2">"%S"</span><span class="p">,</span> +</span><span id="Snowflake-199"><a href="#Snowflake-199"><span class="linenos">199</span></a> <span class="s2">"FF"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Snowflake-200"><a href="#Snowflake-200"><span class="linenos">200</span></a> <span class="s2">"ff"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Snowflake-201"><a href="#Snowflake-201"><span class="linenos">201</span></a> <span class="s2">"FF6"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Snowflake-202"><a href="#Snowflake-202"><span class="linenos">202</span></a> <span class="s2">"ff6"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%f</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Snowflake-203"><a href="#Snowflake-203"><span class="linenos">203</span></a> <span class="p">}</span> +</span><span id="Snowflake-204"><a href="#Snowflake-204"><span class="linenos">204</span></a> +</span><span id="Snowflake-205"><a href="#Snowflake-205"><span class="linenos">205</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="Snowflake-206"><a href="#Snowflake-206"><span class="linenos">206</span></a> <span class="n">IDENTIFY_PIVOT_STRINGS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Snowflake-207"><a href="#Snowflake-207"><span class="linenos">207</span></a> +</span><span id="Snowflake-208"><a href="#Snowflake-208"><span class="linenos">208</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake-209"><a href="#Snowflake-209"><span class="linenos">209</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="Snowflake-210"><a href="#Snowflake-210"><span class="linenos">210</span></a> <span class="s2">"ARRAYAGG"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Snowflake-211"><a href="#Snowflake-211"><span class="linenos">211</span></a> <span class="s2">"ARRAY_CONSTRUCT"</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="Snowflake-212"><a href="#Snowflake-212"><span class="linenos">212</span></a> <span class="s2">"ARRAY_TO_STRING"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayJoin</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Snowflake-213"><a href="#Snowflake-213"><span class="linenos">213</span></a> <span class="s2">"CONVERT_TIMEZONE"</span><span class="p">:</span> <span class="n">_parse_convert_timezone</span><span class="p">,</span> +</span><span id="Snowflake-214"><a href="#Snowflake-214"><span class="linenos">214</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="Snowflake-215"><a href="#Snowflake-215"><span class="linenos">215</span></a> <span class="s2">"DATEADD"</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">DateAdd</span><span class="p">(</span> +</span><span id="Snowflake-216"><a href="#Snowflake-216"><span class="linenos">216</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">2</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">unit</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="Snowflake-217"><a href="#Snowflake-217"><span class="linenos">217</span></a> <span class="p">),</span> +</span><span id="Snowflake-218"><a href="#Snowflake-218"><span class="linenos">218</span></a> <span class="s2">"DATEDIFF"</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">DateDiff</span><span class="p">(</span> +</span><span id="Snowflake-219"><a href="#Snowflake-219"><span class="linenos">219</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">2</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">unit</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="Snowflake-220"><a href="#Snowflake-220"><span class="linenos">220</span></a> <span class="p">),</span> +</span><span id="Snowflake-221"><a href="#Snowflake-221"><span class="linenos">221</span></a> <span class="s2">"DIV0"</span><span class="p">:</span> <span class="n">_div0_to_if</span><span class="p">,</span> +</span><span id="Snowflake-222"><a href="#Snowflake-222"><span class="linenos">222</span></a> <span class="s2">"IFF"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Snowflake-223"><a href="#Snowflake-223"><span class="linenos">223</span></a> <span class="s2">"NULLIFZERO"</span><span class="p">:</span> <span class="n">_nullifzero_to_if</span><span class="p">,</span> +</span><span id="Snowflake-224"><a href="#Snowflake-224"><span class="linenos">224</span></a> <span class="s2">"OBJECT_CONSTRUCT"</span><span class="p">:</span> <span class="n">_parse_object_construct</span><span class="p">,</span> +</span><span id="Snowflake-225"><a href="#Snowflake-225"><span class="linenos">225</span></a> <span class="s2">"RLIKE"</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="Snowflake-226"><a href="#Snowflake-226"><span class="linenos">226</span></a> <span class="s2">"SQUARE"</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">Pow</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">2</span><span class="p">)),</span> +</span><span id="Snowflake-227"><a href="#Snowflake-227"><span class="linenos">227</span></a> <span class="s2">"TO_ARRAY"</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="Snowflake-228"><a href="#Snowflake-228"><span class="linenos">228</span></a> <span class="s2">"TO_VARCHAR"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Snowflake-229"><a href="#Snowflake-229"><span class="linenos">229</span></a> <span class="s2">"TO_TIMESTAMP"</span><span class="p">:</span> <span class="n">_snowflake_to_timestamp</span><span class="p">,</span> +</span><span id="Snowflake-230"><a href="#Snowflake-230"><span class="linenos">230</span></a> <span class="s2">"ZEROIFNULL"</span><span class="p">:</span> <span class="n">_zeroifnull_to_if</span><span class="p">,</span> +</span><span id="Snowflake-231"><a href="#Snowflake-231"><span class="linenos">231</span></a> <span class="p">}</span> +</span><span id="Snowflake-232"><a href="#Snowflake-232"><span class="linenos">232</span></a> +</span><span id="Snowflake-233"><a href="#Snowflake-233"><span class="linenos">233</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake-234"><a href="#Snowflake-234"><span class="linenos">234</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">FUNCTION_PARSERS</span><span class="p">,</span> +</span><span id="Snowflake-235"><a href="#Snowflake-235"><span class="linenos">235</span></a> <span class="s2">"DATE_PART"</span><span class="p">:</span> <span class="n">_parse_date_part</span><span class="p">,</span> +</span><span id="Snowflake-236"><a href="#Snowflake-236"><span class="linenos">236</span></a> <span class="p">}</span> +</span><span id="Snowflake-237"><a href="#Snowflake-237"><span class="linenos">237</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> +</span><span id="Snowflake-238"><a href="#Snowflake-238"><span class="linenos">238</span></a> +</span><span id="Snowflake-239"><a href="#Snowflake-239"><span class="linenos">239</span></a> <span class="n">FUNC_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake-240"><a href="#Snowflake-240"><span class="linenos">240</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">FUNC_TOKENS</span><span class="p">,</span> +</span><span id="Snowflake-241"><a href="#Snowflake-241"><span class="linenos">241</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> +</span><span id="Snowflake-242"><a href="#Snowflake-242"><span class="linenos">242</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> +</span><span id="Snowflake-243"><a href="#Snowflake-243"><span class="linenos">243</span></a> <span class="p">}</span> +</span><span id="Snowflake-244"><a href="#Snowflake-244"><span class="linenos">244</span></a> +</span><span id="Snowflake-245"><a href="#Snowflake-245"><span class="linenos">245</span></a> <span class="n">COLUMN_OPERATORS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake-246"><a href="#Snowflake-246"><span class="linenos">246</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">COLUMN_OPERATORS</span><span class="p">,</span> +</span><span id="Snowflake-247"><a href="#Snowflake-247"><span class="linenos">247</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLON</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Snowflake-248"><a href="#Snowflake-248"><span class="linenos">248</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">path</span><span class="p">]</span> +</span><span id="Snowflake-249"><a href="#Snowflake-249"><span class="linenos">249</span></a> <span class="p">),</span> +</span><span id="Snowflake-250"><a href="#Snowflake-250"><span class="linenos">250</span></a> <span class="p">}</span> </span><span id="Snowflake-251"><a href="#Snowflake-251"><span class="linenos">251</span></a> -</span><span id="Snowflake-252"><a href="#Snowflake-252"><span class="linenos">252</span></a> <span class="n">RANGE_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake-253"><a href="#Snowflake-253"><span class="linenos">253</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">RANGE_PARSERS</span><span class="p">,</span> -</span><span id="Snowflake-254"><a href="#Snowflake-254"><span class="linenos">254</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIKE_ANY</span><span class="p">:</span> <span class="n">binary_range_parser</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LikeAny</span><span class="p">),</span> -</span><span id="Snowflake-255"><a href="#Snowflake-255"><span class="linenos">255</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ILIKE_ANY</span><span class="p">:</span> <span class="n">binary_range_parser</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ILikeAny</span><span class="p">),</span> -</span><span id="Snowflake-256"><a href="#Snowflake-256"><span class="linenos">256</span></a> <span class="p">}</span> -</span><span id="Snowflake-257"><a href="#Snowflake-257"><span class="linenos">257</span></a> -</span><span id="Snowflake-258"><a href="#Snowflake-258"><span class="linenos">258</span></a> <span class="n">ALTER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake-259"><a href="#Snowflake-259"><span class="linenos">259</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">ALTER_PARSERS</span><span class="p">,</span> -</span><span id="Snowflake-260"><a href="#Snowflake-260"><span class="linenos">260</span></a> <span class="s2">"UNSET"</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_alter_table_set_tag</span><span class="p">(</span><span class="n">unset</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="Snowflake-261"><a href="#Snowflake-261"><span class="linenos">261</span></a> <span class="s2">"SET"</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_alter_table_set_tag</span><span class="p">(),</span> -</span><span id="Snowflake-262"><a href="#Snowflake-262"><span class="linenos">262</span></a> <span class="p">}</span> -</span><span id="Snowflake-263"><a href="#Snowflake-263"><span class="linenos">263</span></a> -</span><span id="Snowflake-264"><a href="#Snowflake-264"><span class="linenos">264</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_set_tag</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">unset</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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="Snowflake-265"><a href="#Snowflake-265"><span class="linenos">265</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TAG"</span><span class="p">)</span> -</span><span id="Snowflake-266"><a href="#Snowflake-266"><span class="linenos">266</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span> <span class="k">if</span> <span class="n">unset</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="Snowflake-267"><a href="#Snowflake-267"><span class="linenos">267</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">SetTag</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">parser</span><span class="p">),</span> <span class="n">unset</span><span class="o">=</span><span class="n">unset</span><span class="p">)</span> -</span><span id="Snowflake-268"><a href="#Snowflake-268"><span class="linenos">268</span></a> -</span><span id="Snowflake-269"><a href="#Snowflake-269"><span class="linenos">269</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="Snowflake-270"><a href="#Snowflake-270"><span class="linenos">270</span></a> <span class="n">QUOTES</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="Snowflake-271"><a href="#Snowflake-271"><span class="linenos">271</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">]</span> -</span><span id="Snowflake-272"><a href="#Snowflake-272"><span class="linenos">272</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"x'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"X'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">)]</span> -</span><span id="Snowflake-273"><a href="#Snowflake-273"><span class="linenos">273</span></a> <span class="n">COMMENTS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--"</span><span class="p">,</span> <span class="s2">"//"</span><span class="p">,</span> <span class="p">(</span><span class="s2">"/*"</span><span class="p">,</span> <span class="s2">"*/"</span><span class="p">)]</span> -</span><span id="Snowflake-274"><a href="#Snowflake-274"><span class="linenos">274</span></a> -</span><span id="Snowflake-275"><a href="#Snowflake-275"><span class="linenos">275</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake-276"><a href="#Snowflake-276"><span class="linenos">276</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="Snowflake-277"><a href="#Snowflake-277"><span class="linenos">277</span></a> <span class="s2">"CHAR VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> -</span><span id="Snowflake-278"><a href="#Snowflake-278"><span class="linenos">278</span></a> <span class="s2">"CHARACTER VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> -</span><span id="Snowflake-279"><a href="#Snowflake-279"><span class="linenos">279</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="Snowflake-280"><a href="#Snowflake-280"><span class="linenos">280</span></a> <span class="s2">"ILIKE ANY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ILIKE_ANY</span><span class="p">,</span> -</span><span id="Snowflake-281"><a href="#Snowflake-281"><span class="linenos">281</span></a> <span class="s2">"LIKE ANY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIKE_ANY</span><span class="p">,</span> -</span><span id="Snowflake-282"><a href="#Snowflake-282"><span class="linenos">282</span></a> <span class="s2">"MATCH_RECOGNIZE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MATCH_RECOGNIZE</span><span class="p">,</span> -</span><span id="Snowflake-283"><a href="#Snowflake-283"><span class="linenos">283</span></a> <span class="s2">"MINUS"</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="Snowflake-284"><a href="#Snowflake-284"><span class="linenos">284</span></a> <span class="s2">"NCHAR VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> -</span><span id="Snowflake-285"><a href="#Snowflake-285"><span class="linenos">285</span></a> <span class="s2">"PUT"</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="Snowflake-286"><a href="#Snowflake-286"><span class="linenos">286</span></a> <span class="s2">"RENAME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">,</span> -</span><span id="Snowflake-287"><a href="#Snowflake-287"><span class="linenos">287</span></a> <span class="s2">"TIMESTAMP_LTZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">,</span> -</span><span id="Snowflake-288"><a href="#Snowflake-288"><span class="linenos">288</span></a> <span class="s2">"TIMESTAMP_NTZ"</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="Snowflake-289"><a href="#Snowflake-289"><span class="linenos">289</span></a> <span class="s2">"TIMESTAMP_TZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> -</span><span id="Snowflake-290"><a href="#Snowflake-290"><span class="linenos">290</span></a> <span class="s2">"TIMESTAMPNTZ"</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="Snowflake-291"><a href="#Snowflake-291"><span class="linenos">291</span></a> <span class="s2">"SAMPLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span><span class="p">,</span> -</span><span id="Snowflake-292"><a href="#Snowflake-292"><span class="linenos">292</span></a> <span class="p">}</span> -</span><span id="Snowflake-293"><a href="#Snowflake-293"><span class="linenos">293</span></a> -</span><span id="Snowflake-294"><a href="#Snowflake-294"><span class="linenos">294</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake-295"><a href="#Snowflake-295"><span class="linenos">295</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="Snowflake-296"><a href="#Snowflake-296"><span class="linenos">296</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="Snowflake-297"><a href="#Snowflake-297"><span class="linenos">297</span></a> <span class="p">}</span> -</span><span id="Snowflake-298"><a href="#Snowflake-298"><span class="linenos">298</span></a> -</span><span id="Snowflake-299"><a href="#Snowflake-299"><span class="linenos">299</span></a> <span class="n">VAR_SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"$"</span><span class="p">}</span> +</span><span id="Snowflake-252"><a href="#Snowflake-252"><span class="linenos">252</span></a> <span class="n">TIMESTAMPS</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">TIMESTAMPS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="o">-</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">TIME</span><span class="p">}</span> +</span><span id="Snowflake-253"><a href="#Snowflake-253"><span class="linenos">253</span></a> +</span><span id="Snowflake-254"><a href="#Snowflake-254"><span class="linenos">254</span></a> <span class="n">RANGE_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake-255"><a href="#Snowflake-255"><span class="linenos">255</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">RANGE_PARSERS</span><span class="p">,</span> +</span><span id="Snowflake-256"><a href="#Snowflake-256"><span class="linenos">256</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIKE_ANY</span><span class="p">:</span> <span class="n">binary_range_parser</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LikeAny</span><span class="p">),</span> +</span><span id="Snowflake-257"><a href="#Snowflake-257"><span class="linenos">257</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ILIKE_ANY</span><span class="p">:</span> <span class="n">binary_range_parser</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ILikeAny</span><span class="p">),</span> +</span><span id="Snowflake-258"><a href="#Snowflake-258"><span class="linenos">258</span></a> <span class="p">}</span> +</span><span id="Snowflake-259"><a href="#Snowflake-259"><span class="linenos">259</span></a> +</span><span id="Snowflake-260"><a href="#Snowflake-260"><span class="linenos">260</span></a> <span class="n">ALTER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake-261"><a href="#Snowflake-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">ALTER_PARSERS</span><span class="p">,</span> +</span><span id="Snowflake-262"><a href="#Snowflake-262"><span class="linenos">262</span></a> <span class="s2">"UNSET"</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_alter_table_set_tag</span><span class="p">(</span><span class="n">unset</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="Snowflake-263"><a href="#Snowflake-263"><span class="linenos">263</span></a> <span class="s2">"SET"</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_alter_table_set_tag</span><span class="p">(),</span> +</span><span id="Snowflake-264"><a href="#Snowflake-264"><span class="linenos">264</span></a> <span class="p">}</span> +</span><span id="Snowflake-265"><a href="#Snowflake-265"><span class="linenos">265</span></a> +</span><span id="Snowflake-266"><a href="#Snowflake-266"><span class="linenos">266</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_set_tag</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">unset</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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="Snowflake-267"><a href="#Snowflake-267"><span class="linenos">267</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TAG"</span><span class="p">)</span> +</span><span id="Snowflake-268"><a href="#Snowflake-268"><span class="linenos">268</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span> <span class="k">if</span> <span class="n">unset</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="Snowflake-269"><a href="#Snowflake-269"><span class="linenos">269</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">SetTag</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">parser</span><span class="p">),</span> <span class="n">unset</span><span class="o">=</span><span class="n">unset</span><span class="p">)</span> +</span><span id="Snowflake-270"><a href="#Snowflake-270"><span class="linenos">270</span></a> +</span><span id="Snowflake-271"><a href="#Snowflake-271"><span class="linenos">271</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="Snowflake-272"><a href="#Snowflake-272"><span class="linenos">272</span></a> <span class="n">QUOTES</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="Snowflake-273"><a href="#Snowflake-273"><span class="linenos">273</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">]</span> +</span><span id="Snowflake-274"><a href="#Snowflake-274"><span class="linenos">274</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"x'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"X'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">)]</span> +</span><span id="Snowflake-275"><a href="#Snowflake-275"><span class="linenos">275</span></a> <span class="n">COMMENTS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--"</span><span class="p">,</span> <span class="s2">"//"</span><span class="p">,</span> <span class="p">(</span><span class="s2">"/*"</span><span class="p">,</span> <span class="s2">"*/"</span><span class="p">)]</span> +</span><span id="Snowflake-276"><a href="#Snowflake-276"><span class="linenos">276</span></a> +</span><span id="Snowflake-277"><a href="#Snowflake-277"><span class="linenos">277</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake-278"><a href="#Snowflake-278"><span class="linenos">278</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="Snowflake-279"><a href="#Snowflake-279"><span class="linenos">279</span></a> <span class="s2">"CHAR VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> +</span><span id="Snowflake-280"><a href="#Snowflake-280"><span class="linenos">280</span></a> <span class="s2">"CHARACTER VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> +</span><span id="Snowflake-281"><a href="#Snowflake-281"><span class="linenos">281</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="Snowflake-282"><a href="#Snowflake-282"><span class="linenos">282</span></a> <span class="s2">"ILIKE ANY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ILIKE_ANY</span><span class="p">,</span> +</span><span id="Snowflake-283"><a href="#Snowflake-283"><span class="linenos">283</span></a> <span class="s2">"LIKE ANY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIKE_ANY</span><span class="p">,</span> +</span><span id="Snowflake-284"><a href="#Snowflake-284"><span class="linenos">284</span></a> <span class="s2">"MATCH_RECOGNIZE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MATCH_RECOGNIZE</span><span class="p">,</span> +</span><span id="Snowflake-285"><a href="#Snowflake-285"><span class="linenos">285</span></a> <span class="s2">"MINUS"</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="Snowflake-286"><a href="#Snowflake-286"><span class="linenos">286</span></a> <span class="s2">"NCHAR VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> +</span><span id="Snowflake-287"><a href="#Snowflake-287"><span class="linenos">287</span></a> <span class="s2">"PUT"</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="Snowflake-288"><a href="#Snowflake-288"><span class="linenos">288</span></a> <span class="s2">"RENAME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">,</span> +</span><span id="Snowflake-289"><a href="#Snowflake-289"><span class="linenos">289</span></a> <span class="s2">"TIMESTAMP_LTZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">,</span> +</span><span id="Snowflake-290"><a href="#Snowflake-290"><span class="linenos">290</span></a> <span class="s2">"TIMESTAMP_NTZ"</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="Snowflake-291"><a href="#Snowflake-291"><span class="linenos">291</span></a> <span class="s2">"TIMESTAMP_TZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> +</span><span id="Snowflake-292"><a href="#Snowflake-292"><span class="linenos">292</span></a> <span class="s2">"TIMESTAMPNTZ"</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="Snowflake-293"><a href="#Snowflake-293"><span class="linenos">293</span></a> <span class="s2">"SAMPLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span><span class="p">,</span> +</span><span id="Snowflake-294"><a href="#Snowflake-294"><span class="linenos">294</span></a> <span class="p">}</span> +</span><span id="Snowflake-295"><a href="#Snowflake-295"><span class="linenos">295</span></a> +</span><span id="Snowflake-296"><a href="#Snowflake-296"><span class="linenos">296</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake-297"><a href="#Snowflake-297"><span class="linenos">297</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="Snowflake-298"><a href="#Snowflake-298"><span class="linenos">298</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="Snowflake-299"><a href="#Snowflake-299"><span class="linenos">299</span></a> <span class="p">}</span> </span><span id="Snowflake-300"><a href="#Snowflake-300"><span class="linenos">300</span></a> -</span><span id="Snowflake-301"><a href="#Snowflake-301"><span class="linenos">301</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="Snowflake-302"><a href="#Snowflake-302"><span class="linenos">302</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"$"</span> -</span><span id="Snowflake-303"><a href="#Snowflake-303"><span class="linenos">303</span></a> <span class="n">MATCHED_BY_SOURCE</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Snowflake-304"><a href="#Snowflake-304"><span class="linenos">304</span></a> <span class="n">SINGLE_STRING_INTERVAL</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Snowflake-305"><a href="#Snowflake-305"><span class="linenos">305</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Snowflake-306"><a href="#Snowflake-306"><span class="linenos">306</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Snowflake-307"><a href="#Snowflake-307"><span class="linenos">307</span></a> -</span><span id="Snowflake-308"><a href="#Snowflake-308"><span class="linenos">308</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake-309"><a href="#Snowflake-309"><span class="linenos">309</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="Snowflake-310"><a href="#Snowflake-310"><span class="linenos">310</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_sql</span><span class="p">,</span> -</span><span id="Snowflake-311"><a href="#Snowflake-311"><span class="linenos">311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_CAT"</span><span class="p">),</span> -</span><span id="Snowflake-312"><a href="#Snowflake-312"><span class="linenos">312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayJoin</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_TO_STRING"</span><span class="p">),</span> -</span><span id="Snowflake-313"><a href="#Snowflake-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</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="Snowflake-314"><a href="#Snowflake-314"><span class="linenos">314</span></a> <span class="s2">"CONVERT_TIMEZONE"</span><span class="p">,</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="s2">"zone"</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> -</span><span id="Snowflake-315"><a href="#Snowflake-315"><span class="linenos">315</span></a> <span class="p">),</span> -</span><span id="Snowflake-316"><a href="#Snowflake-316"><span class="linenos">316</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</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">"DATEADD"</span><span class="p">,</span> <span class="n">e</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="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 class="p">),</span> -</span><span id="Snowflake-317"><a href="#Snowflake-317"><span class="linenos">317</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="Snowflake-318"><a href="#Snowflake-318"><span class="linenos">318</span></a> <span class="s2">"DATEDIFF"</span><span class="p">,</span> <span class="n">e</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="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="Snowflake-319"><a href="#Snowflake-319"><span class="linenos">319</span></a> <span class="p">),</span> -</span><span id="Snowflake-320"><a href="#Snowflake-320"><span class="linenos">320</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="Snowflake-321"><a href="#Snowflake-321"><span class="linenos">321</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="Snowflake-322"><a href="#Snowflake-322"><span class="linenos">322</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="Snowflake-323"><a href="#Snowflake-323"><span class="linenos">323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATE_PART"</span><span class="p">),</span> -</span><span id="Snowflake-324"><a href="#Snowflake-324"><span class="linenos">324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"IFF"</span><span class="p">),</span> -</span><span id="Snowflake-325"><a href="#Snowflake-325"><span class="linenos">325</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">"BOOLAND_AGG"</span><span class="p">),</span> -</span><span id="Snowflake-326"><a href="#Snowflake-326"><span class="linenos">326</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">"BOOLOR_AGG"</span><span class="p">),</span> -</span><span id="Snowflake-327"><a href="#Snowflake-327"><span class="linenos">327</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Map</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">var_map_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">"OBJECT_CONSTRUCT"</span><span class="p">),</span> -</span><span id="Snowflake-328"><a href="#Snowflake-328"><span class="linenos">328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> -</span><span id="Snowflake-329"><a href="#Snowflake-329"><span class="linenos">329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> -</span><span id="Snowflake-330"><a href="#Snowflake-330"><span class="linenos">330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</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">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Snowflake-331"><a href="#Snowflake-331"><span class="linenos">331</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</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">eliminate_distinct_on</span><span class="p">]),</span> -</span><span id="Snowflake-332"><a href="#Snowflake-332"><span class="linenos">332</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StarMap</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"OBJECT_CONSTRUCT"</span><span class="p">),</span> -</span><span id="Snowflake-333"><a href="#Snowflake-333"><span class="linenos">333</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</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="Snowflake-334"><a href="#Snowflake-334"><span class="linenos">334</span></a> <span class="s2">"POSITION"</span><span class="p">,</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="s2">"substr"</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">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">"position"</span><span class="p">)</span> -</span><span id="Snowflake-335"><a href="#Snowflake-335"><span class="linenos">335</span></a> <span class="p">),</span> -</span><span id="Snowflake-336"><a href="#Snowflake-336"><span class="linenos">336</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</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">"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">, </span><span class="si">{</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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Snowflake-337"><a href="#Snowflake-337"><span class="linenos">337</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</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="Snowflake-338"><a href="#Snowflake-338"><span class="linenos">338</span></a> <span class="s2">"OBJECT_CONSTRUCT"</span><span class="p">,</span> -</span><span id="Snowflake-339"><a href="#Snowflake-339"><span class="linenos">339</span></a> <span class="o">*</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">e</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">()),</span> -</span><span id="Snowflake-340"><a href="#Snowflake-340"><span class="linenos">340</span></a> <span class="p">),</span> -</span><span id="Snowflake-341"><a href="#Snowflake-341"><span class="linenos">341</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="Snowflake-342"><a href="#Snowflake-342"><span class="linenos">342</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</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">"EXTRACT(epoch_second FROM </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Snowflake-343"><a href="#Snowflake-343"><span class="linenos">343</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><span id="Snowflake-344"><a href="#Snowflake-344"><span class="linenos">344</span></a> <span class="s2">"TO_CHAR"</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="s2">"timestamp"</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="Snowflake-345"><a href="#Snowflake-345"><span class="linenos">345</span></a> <span class="p">),</span> -</span><span id="Snowflake-346"><a href="#Snowflake-346"><span class="linenos">346</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="Snowflake-347"><a href="#Snowflake-347"><span class="linenos">347</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</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">function_fallback_sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="Snowflake-348"><a href="#Snowflake-348"><span class="linenos">348</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</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">"TRIM"</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">e</span><span class="o">.</span><span class="n">expression</span><span class="p">),</span> -</span><span id="Snowflake-349"><a href="#Snowflake-349"><span class="linenos">349</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="s2">"snowflake"</span><span class="p">),</span> -</span><span id="Snowflake-350"><a href="#Snowflake-350"><span class="linenos">350</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="Snowflake-351"><a href="#Snowflake-351"><span class="linenos">351</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</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">var_map_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">"OBJECT_CONSTRUCT"</span><span class="p">),</span> -</span><span id="Snowflake-352"><a href="#Snowflake-352"><span class="linenos">352</span></a> <span class="p">}</span> -</span><span id="Snowflake-353"><a href="#Snowflake-353"><span class="linenos">353</span></a> -</span><span id="Snowflake-354"><a href="#Snowflake-354"><span class="linenos">354</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake-355"><a href="#Snowflake-355"><span class="linenos">355</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="Snowflake-356"><a href="#Snowflake-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">TIMESTAMP</span><span class="p">:</span> <span class="s2">"TIMESTAMPNTZ"</span><span class="p">,</span> -</span><span id="Snowflake-357"><a href="#Snowflake-357"><span class="linenos">357</span></a> <span class="p">}</span> -</span><span id="Snowflake-358"><a href="#Snowflake-358"><span class="linenos">358</span></a> -</span><span id="Snowflake-359"><a href="#Snowflake-359"><span class="linenos">359</span></a> <span class="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake-360"><a href="#Snowflake-360"><span class="linenos">360</span></a> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCLUDE"</span><span class="p">,</span> -</span><span id="Snowflake-361"><a href="#Snowflake-361"><span class="linenos">361</span></a> <span class="s2">"replace"</span><span class="p">:</span> <span class="s2">"RENAME"</span><span class="p">,</span> -</span><span id="Snowflake-362"><a href="#Snowflake-362"><span class="linenos">362</span></a> <span class="p">}</span> -</span><span id="Snowflake-363"><a href="#Snowflake-363"><span class="linenos">363</span></a> -</span><span id="Snowflake-364"><a href="#Snowflake-364"><span class="linenos">364</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake-365"><a href="#Snowflake-365"><span class="linenos">365</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">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="Snowflake-366"><a href="#Snowflake-366"><span class="linenos">366</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="Snowflake-367"><a href="#Snowflake-367"><span class="linenos">367</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="Snowflake-368"><a href="#Snowflake-368"><span class="linenos">368</span></a> <span class="p">}</span> -</span><span id="Snowflake-369"><a href="#Snowflake-369"><span class="linenos">369</span></a> -</span><span id="Snowflake-370"><a href="#Snowflake-370"><span class="linenos">370</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Snowflake-371"><a href="#Snowflake-371"><span class="linenos">371</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> -</span><span id="Snowflake-372"><a href="#Snowflake-372"><span class="linenos">372</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"EXCEPT with All is not supported in Snowflake"</span><span class="p">)</span> -</span><span id="Snowflake-373"><a href="#Snowflake-373"><span class="linenos">373</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Snowflake-374"><a href="#Snowflake-374"><span class="linenos">374</span></a> -</span><span id="Snowflake-375"><a href="#Snowflake-375"><span class="linenos">375</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Snowflake-376"><a href="#Snowflake-376"><span class="linenos">376</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> -</span><span id="Snowflake-377"><a href="#Snowflake-377"><span class="linenos">377</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"INTERSECT with All is not supported in Snowflake"</span><span class="p">)</span> -</span><span id="Snowflake-378"><a href="#Snowflake-378"><span class="linenos">378</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Snowflake-379"><a href="#Snowflake-379"><span class="linenos">379</span></a> -</span><span id="Snowflake-380"><a href="#Snowflake-380"><span class="linenos">380</span></a> <span class="k">def</span> <span class="nf">settag_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetTag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Snowflake-381"><a href="#Snowflake-381"><span class="linenos">381</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"UNSET"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unset"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"SET"</span> -</span><span id="Snowflake-382"><a href="#Snowflake-382"><span class="linenos">382</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">action</span><span class="si">}</span><span class="s2"> TAG </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Snowflake-383"><a href="#Snowflake-383"><span class="linenos">383</span></a> -</span><span id="Snowflake-384"><a href="#Snowflake-384"><span class="linenos">384</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Snowflake-385"><a href="#Snowflake-385"><span class="linenos">385</span></a> <span class="c1"># Default to table if kind is unknown</span> -</span><span id="Snowflake-386"><a href="#Snowflake-386"><span class="linenos">386</span></a> <span class="n">kind_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"TABLE"</span> -</span><span id="Snowflake-387"><a href="#Snowflake-387"><span class="linenos">387</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind_value</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind_value</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Snowflake-388"><a href="#Snowflake-388"><span class="linenos">388</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Snowflake-389"><a href="#Snowflake-389"><span class="linenos">389</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Snowflake-390"><a href="#Snowflake-390"><span class="linenos">390</span></a> -</span><span id="Snowflake-391"><a href="#Snowflake-391"><span class="linenos">391</span></a> <span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> -</span><span id="Snowflake-392"><a href="#Snowflake-392"><span class="linenos">392</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> -</span><span id="Snowflake-393"><a href="#Snowflake-393"><span class="linenos">393</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Snowflake-394"><a href="#Snowflake-394"><span class="linenos">394</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"start"</span><span class="p">)</span> -</span><span id="Snowflake-395"><a href="#Snowflake-395"><span class="linenos">395</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" START </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Snowflake-396"><a href="#Snowflake-396"><span class="linenos">396</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"increment"</span><span class="p">)</span> -</span><span id="Snowflake-397"><a href="#Snowflake-397"><span class="linenos">397</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Snowflake-398"><a href="#Snowflake-398"><span class="linenos">398</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"AUTOINCREMENT</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Snowflake-301"><a href="#Snowflake-301"><span class="linenos">301</span></a> <span class="n">VAR_SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"$"</span><span class="p">}</span> +</span><span id="Snowflake-302"><a href="#Snowflake-302"><span class="linenos">302</span></a> +</span><span id="Snowflake-303"><a href="#Snowflake-303"><span class="linenos">303</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="Snowflake-304"><a href="#Snowflake-304"><span class="linenos">304</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"$"</span> +</span><span id="Snowflake-305"><a href="#Snowflake-305"><span class="linenos">305</span></a> <span class="n">MATCHED_BY_SOURCE</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Snowflake-306"><a href="#Snowflake-306"><span class="linenos">306</span></a> <span class="n">SINGLE_STRING_INTERVAL</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Snowflake-307"><a href="#Snowflake-307"><span class="linenos">307</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Snowflake-308"><a href="#Snowflake-308"><span class="linenos">308</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Snowflake-309"><a href="#Snowflake-309"><span class="linenos">309</span></a> +</span><span id="Snowflake-310"><a href="#Snowflake-310"><span class="linenos">310</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake-311"><a href="#Snowflake-311"><span class="linenos">311</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="Snowflake-312"><a href="#Snowflake-312"><span class="linenos">312</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_sql</span><span class="p">,</span> +</span><span id="Snowflake-313"><a href="#Snowflake-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_CAT"</span><span class="p">),</span> +</span><span id="Snowflake-314"><a href="#Snowflake-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayJoin</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_TO_STRING"</span><span class="p">),</span> +</span><span id="Snowflake-315"><a href="#Snowflake-315"><span class="linenos">315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</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="Snowflake-316"><a href="#Snowflake-316"><span class="linenos">316</span></a> <span class="s2">"CONVERT_TIMEZONE"</span><span class="p">,</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="s2">"zone"</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> +</span><span id="Snowflake-317"><a href="#Snowflake-317"><span class="linenos">317</span></a> <span class="p">),</span> +</span><span id="Snowflake-318"><a href="#Snowflake-318"><span class="linenos">318</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</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">"DATEADD"</span><span class="p">,</span> <span class="n">e</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="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 class="p">),</span> +</span><span id="Snowflake-319"><a href="#Snowflake-319"><span class="linenos">319</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="Snowflake-320"><a href="#Snowflake-320"><span class="linenos">320</span></a> <span class="s2">"DATEDIFF"</span><span class="p">,</span> <span class="n">e</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="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="Snowflake-321"><a href="#Snowflake-321"><span class="linenos">321</span></a> <span class="p">),</span> +</span><span id="Snowflake-322"><a href="#Snowflake-322"><span class="linenos">322</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="Snowflake-323"><a href="#Snowflake-323"><span class="linenos">323</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="Snowflake-324"><a href="#Snowflake-324"><span class="linenos">324</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="Snowflake-325"><a href="#Snowflake-325"><span class="linenos">325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATE_PART"</span><span class="p">),</span> +</span><span id="Snowflake-326"><a href="#Snowflake-326"><span class="linenos">326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"IFF"</span><span class="p">),</span> +</span><span id="Snowflake-327"><a href="#Snowflake-327"><span class="linenos">327</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">"BOOLAND_AGG"</span><span class="p">),</span> +</span><span id="Snowflake-328"><a href="#Snowflake-328"><span class="linenos">328</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">"BOOLOR_AGG"</span><span class="p">),</span> +</span><span id="Snowflake-329"><a href="#Snowflake-329"><span class="linenos">329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Map</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">var_map_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">"OBJECT_CONSTRUCT"</span><span class="p">),</span> +</span><span id="Snowflake-330"><a href="#Snowflake-330"><span class="linenos">330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> +</span><span id="Snowflake-331"><a href="#Snowflake-331"><span class="linenos">331</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> +</span><span id="Snowflake-332"><a href="#Snowflake-332"><span class="linenos">332</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</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">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Snowflake-333"><a href="#Snowflake-333"><span class="linenos">333</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</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">eliminate_distinct_on</span><span class="p">]),</span> +</span><span id="Snowflake-334"><a href="#Snowflake-334"><span class="linenos">334</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StarMap</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"OBJECT_CONSTRUCT"</span><span class="p">),</span> +</span><span id="Snowflake-335"><a href="#Snowflake-335"><span class="linenos">335</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</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="Snowflake-336"><a href="#Snowflake-336"><span class="linenos">336</span></a> <span class="s2">"POSITION"</span><span class="p">,</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="s2">"substr"</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">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">"position"</span><span class="p">)</span> +</span><span id="Snowflake-337"><a href="#Snowflake-337"><span class="linenos">337</span></a> <span class="p">),</span> +</span><span id="Snowflake-338"><a href="#Snowflake-338"><span class="linenos">338</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</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">"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">, </span><span class="si">{</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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Snowflake-339"><a href="#Snowflake-339"><span class="linenos">339</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</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="Snowflake-340"><a href="#Snowflake-340"><span class="linenos">340</span></a> <span class="s2">"OBJECT_CONSTRUCT"</span><span class="p">,</span> +</span><span id="Snowflake-341"><a href="#Snowflake-341"><span class="linenos">341</span></a> <span class="o">*</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">e</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">()),</span> +</span><span id="Snowflake-342"><a href="#Snowflake-342"><span class="linenos">342</span></a> <span class="p">),</span> +</span><span id="Snowflake-343"><a href="#Snowflake-343"><span class="linenos">343</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="Snowflake-344"><a href="#Snowflake-344"><span class="linenos">344</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</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">"EXTRACT(epoch_second FROM </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Snowflake-345"><a href="#Snowflake-345"><span class="linenos">345</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><span id="Snowflake-346"><a href="#Snowflake-346"><span class="linenos">346</span></a> <span class="s2">"TO_CHAR"</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="s2">"timestamp"</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="Snowflake-347"><a href="#Snowflake-347"><span class="linenos">347</span></a> <span class="p">),</span> +</span><span id="Snowflake-348"><a href="#Snowflake-348"><span class="linenos">348</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="Snowflake-349"><a href="#Snowflake-349"><span class="linenos">349</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</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">function_fallback_sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="Snowflake-350"><a href="#Snowflake-350"><span class="linenos">350</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</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">"TRIM"</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">e</span><span class="o">.</span><span class="n">expression</span><span class="p">),</span> +</span><span id="Snowflake-351"><a href="#Snowflake-351"><span class="linenos">351</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="s2">"snowflake"</span><span class="p">),</span> +</span><span id="Snowflake-352"><a href="#Snowflake-352"><span class="linenos">352</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="Snowflake-353"><a href="#Snowflake-353"><span class="linenos">353</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</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">var_map_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">"OBJECT_CONSTRUCT"</span><span class="p">),</span> +</span><span id="Snowflake-354"><a href="#Snowflake-354"><span class="linenos">354</span></a> <span class="p">}</span> +</span><span id="Snowflake-355"><a href="#Snowflake-355"><span class="linenos">355</span></a> +</span><span id="Snowflake-356"><a href="#Snowflake-356"><span class="linenos">356</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake-357"><a href="#Snowflake-357"><span class="linenos">357</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="Snowflake-358"><a href="#Snowflake-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">TIMESTAMP</span><span class="p">:</span> <span class="s2">"TIMESTAMPNTZ"</span><span class="p">,</span> +</span><span id="Snowflake-359"><a href="#Snowflake-359"><span class="linenos">359</span></a> <span class="p">}</span> +</span><span id="Snowflake-360"><a href="#Snowflake-360"><span class="linenos">360</span></a> +</span><span id="Snowflake-361"><a href="#Snowflake-361"><span class="linenos">361</span></a> <span class="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake-362"><a href="#Snowflake-362"><span class="linenos">362</span></a> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCLUDE"</span><span class="p">,</span> +</span><span id="Snowflake-363"><a href="#Snowflake-363"><span class="linenos">363</span></a> <span class="s2">"replace"</span><span class="p">:</span> <span class="s2">"RENAME"</span><span class="p">,</span> +</span><span id="Snowflake-364"><a href="#Snowflake-364"><span class="linenos">364</span></a> <span class="p">}</span> +</span><span id="Snowflake-365"><a href="#Snowflake-365"><span class="linenos">365</span></a> +</span><span id="Snowflake-366"><a href="#Snowflake-366"><span class="linenos">366</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake-367"><a href="#Snowflake-367"><span class="linenos">367</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">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="Snowflake-368"><a href="#Snowflake-368"><span class="linenos">368</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="Snowflake-369"><a href="#Snowflake-369"><span class="linenos">369</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="Snowflake-370"><a href="#Snowflake-370"><span class="linenos">370</span></a> <span class="p">}</span> +</span><span id="Snowflake-371"><a href="#Snowflake-371"><span class="linenos">371</span></a> +</span><span id="Snowflake-372"><a href="#Snowflake-372"><span class="linenos">372</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Snowflake-373"><a href="#Snowflake-373"><span class="linenos">373</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> +</span><span id="Snowflake-374"><a href="#Snowflake-374"><span class="linenos">374</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"EXCEPT with All is not supported in Snowflake"</span><span class="p">)</span> +</span><span id="Snowflake-375"><a href="#Snowflake-375"><span class="linenos">375</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Snowflake-376"><a href="#Snowflake-376"><span class="linenos">376</span></a> +</span><span id="Snowflake-377"><a href="#Snowflake-377"><span class="linenos">377</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Snowflake-378"><a href="#Snowflake-378"><span class="linenos">378</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> +</span><span id="Snowflake-379"><a href="#Snowflake-379"><span class="linenos">379</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"INTERSECT with All is not supported in Snowflake"</span><span class="p">)</span> +</span><span id="Snowflake-380"><a href="#Snowflake-380"><span class="linenos">380</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Snowflake-381"><a href="#Snowflake-381"><span class="linenos">381</span></a> +</span><span id="Snowflake-382"><a href="#Snowflake-382"><span class="linenos">382</span></a> <span class="k">def</span> <span class="nf">settag_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetTag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Snowflake-383"><a href="#Snowflake-383"><span class="linenos">383</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"UNSET"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unset"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"SET"</span> +</span><span id="Snowflake-384"><a href="#Snowflake-384"><span class="linenos">384</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">action</span><span class="si">}</span><span class="s2"> TAG </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Snowflake-385"><a href="#Snowflake-385"><span class="linenos">385</span></a> +</span><span id="Snowflake-386"><a href="#Snowflake-386"><span class="linenos">386</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Snowflake-387"><a href="#Snowflake-387"><span class="linenos">387</span></a> <span class="c1"># Default to table if kind is unknown</span> +</span><span id="Snowflake-388"><a href="#Snowflake-388"><span class="linenos">388</span></a> <span class="n">kind_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"TABLE"</span> +</span><span id="Snowflake-389"><a href="#Snowflake-389"><span class="linenos">389</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind_value</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind_value</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Snowflake-390"><a href="#Snowflake-390"><span class="linenos">390</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Snowflake-391"><a href="#Snowflake-391"><span class="linenos">391</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Snowflake-392"><a href="#Snowflake-392"><span class="linenos">392</span></a> +</span><span id="Snowflake-393"><a href="#Snowflake-393"><span class="linenos">393</span></a> <span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> +</span><span id="Snowflake-394"><a href="#Snowflake-394"><span class="linenos">394</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> +</span><span id="Snowflake-395"><a href="#Snowflake-395"><span class="linenos">395</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Snowflake-396"><a href="#Snowflake-396"><span class="linenos">396</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"start"</span><span class="p">)</span> +</span><span id="Snowflake-397"><a href="#Snowflake-397"><span class="linenos">397</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" START </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Snowflake-398"><a href="#Snowflake-398"><span class="linenos">398</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"increment"</span><span class="p">)</span> +</span><span id="Snowflake-399"><a href="#Snowflake-399"><span class="linenos">399</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Snowflake-400"><a href="#Snowflake-400"><span class="linenos">400</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"AUTOINCREMENT</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -744,6 +751,10 @@ <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="Snowflake.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="Snowflake.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="Snowflake.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="Snowflake.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="Snowflake.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="Snowflake.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="Snowflake.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="Snowflake.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="Snowflake.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -767,71 +778,71 @@ </div> <a class="headerlink" href="#Snowflake.Parser"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Snowflake.Parser-203"><a href="#Snowflake.Parser-203"><span class="linenos">203</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="Snowflake.Parser-204"><a href="#Snowflake.Parser-204"><span class="linenos">204</span></a> <span class="n">IDENTIFY_PIVOT_STRINGS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Snowflake.Parser-205"><a href="#Snowflake.Parser-205"><span class="linenos">205</span></a> -</span><span id="Snowflake.Parser-206"><a href="#Snowflake.Parser-206"><span class="linenos">206</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake.Parser-207"><a href="#Snowflake.Parser-207"><span class="linenos">207</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="Snowflake.Parser-208"><a href="#Snowflake.Parser-208"><span class="linenos">208</span></a> <span class="s2">"ARRAYAGG"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Snowflake.Parser-209"><a href="#Snowflake.Parser-209"><span class="linenos">209</span></a> <span class="s2">"ARRAY_CONSTRUCT"</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="Snowflake.Parser-210"><a href="#Snowflake.Parser-210"><span class="linenos">210</span></a> <span class="s2">"ARRAY_TO_STRING"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayJoin</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Snowflake.Parser-211"><a href="#Snowflake.Parser-211"><span class="linenos">211</span></a> <span class="s2">"CONVERT_TIMEZONE"</span><span class="p">:</span> <span class="n">_parse_convert_timezone</span><span class="p">,</span> -</span><span id="Snowflake.Parser-212"><a href="#Snowflake.Parser-212"><span class="linenos">212</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="Snowflake.Parser-213"><a href="#Snowflake.Parser-213"><span class="linenos">213</span></a> <span class="s2">"DATEADD"</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">DateAdd</span><span class="p">(</span> -</span><span id="Snowflake.Parser-214"><a href="#Snowflake.Parser-214"><span class="linenos">214</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">2</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">unit</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="Snowflake.Parser-215"><a href="#Snowflake.Parser-215"><span class="linenos">215</span></a> <span class="p">),</span> -</span><span id="Snowflake.Parser-216"><a href="#Snowflake.Parser-216"><span class="linenos">216</span></a> <span class="s2">"DATEDIFF"</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">DateDiff</span><span class="p">(</span> -</span><span id="Snowflake.Parser-217"><a href="#Snowflake.Parser-217"><span class="linenos">217</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">2</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">unit</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="Snowflake.Parser-218"><a href="#Snowflake.Parser-218"><span class="linenos">218</span></a> <span class="p">),</span> -</span><span id="Snowflake.Parser-219"><a href="#Snowflake.Parser-219"><span class="linenos">219</span></a> <span class="s2">"DIV0"</span><span class="p">:</span> <span class="n">_div0_to_if</span><span class="p">,</span> -</span><span id="Snowflake.Parser-220"><a href="#Snowflake.Parser-220"><span class="linenos">220</span></a> <span class="s2">"IFF"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Snowflake.Parser-221"><a href="#Snowflake.Parser-221"><span class="linenos">221</span></a> <span class="s2">"NULLIFZERO"</span><span class="p">:</span> <span class="n">_nullifzero_to_if</span><span class="p">,</span> -</span><span id="Snowflake.Parser-222"><a href="#Snowflake.Parser-222"><span class="linenos">222</span></a> <span class="s2">"OBJECT_CONSTRUCT"</span><span class="p">:</span> <span class="n">_parse_object_construct</span><span class="p">,</span> -</span><span id="Snowflake.Parser-223"><a href="#Snowflake.Parser-223"><span class="linenos">223</span></a> <span class="s2">"RLIKE"</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="Snowflake.Parser-224"><a href="#Snowflake.Parser-224"><span class="linenos">224</span></a> <span class="s2">"SQUARE"</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">Pow</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">2</span><span class="p">)),</span> -</span><span id="Snowflake.Parser-225"><a href="#Snowflake.Parser-225"><span class="linenos">225</span></a> <span class="s2">"TO_ARRAY"</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="Snowflake.Parser-226"><a href="#Snowflake.Parser-226"><span class="linenos">226</span></a> <span class="s2">"TO_VARCHAR"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="Snowflake.Parser-227"><a href="#Snowflake.Parser-227"><span class="linenos">227</span></a> <span class="s2">"TO_TIMESTAMP"</span><span class="p">:</span> <span class="n">_snowflake_to_timestamp</span><span class="p">,</span> -</span><span id="Snowflake.Parser-228"><a href="#Snowflake.Parser-228"><span class="linenos">228</span></a> <span class="s2">"ZEROIFNULL"</span><span class="p">:</span> <span class="n">_zeroifnull_to_if</span><span class="p">,</span> -</span><span id="Snowflake.Parser-229"><a href="#Snowflake.Parser-229"><span class="linenos">229</span></a> <span class="p">}</span> -</span><span id="Snowflake.Parser-230"><a href="#Snowflake.Parser-230"><span class="linenos">230</span></a> -</span><span id="Snowflake.Parser-231"><a href="#Snowflake.Parser-231"><span class="linenos">231</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake.Parser-232"><a href="#Snowflake.Parser-232"><span class="linenos">232</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">FUNCTION_PARSERS</span><span class="p">,</span> -</span><span id="Snowflake.Parser-233"><a href="#Snowflake.Parser-233"><span class="linenos">233</span></a> <span class="s2">"DATE_PART"</span><span class="p">:</span> <span class="n">_parse_date_part</span><span class="p">,</span> -</span><span id="Snowflake.Parser-234"><a href="#Snowflake.Parser-234"><span class="linenos">234</span></a> <span class="p">}</span> -</span><span id="Snowflake.Parser-235"><a href="#Snowflake.Parser-235"><span class="linenos">235</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> -</span><span id="Snowflake.Parser-236"><a href="#Snowflake.Parser-236"><span class="linenos">236</span></a> -</span><span id="Snowflake.Parser-237"><a href="#Snowflake.Parser-237"><span class="linenos">237</span></a> <span class="n">FUNC_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake.Parser-238"><a href="#Snowflake.Parser-238"><span class="linenos">238</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">FUNC_TOKENS</span><span class="p">,</span> -</span><span id="Snowflake.Parser-239"><a href="#Snowflake.Parser-239"><span class="linenos">239</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> -</span><span id="Snowflake.Parser-240"><a href="#Snowflake.Parser-240"><span class="linenos">240</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> -</span><span id="Snowflake.Parser-241"><a href="#Snowflake.Parser-241"><span class="linenos">241</span></a> <span class="p">}</span> -</span><span id="Snowflake.Parser-242"><a href="#Snowflake.Parser-242"><span class="linenos">242</span></a> -</span><span id="Snowflake.Parser-243"><a href="#Snowflake.Parser-243"><span class="linenos">243</span></a> <span class="n">COLUMN_OPERATORS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake.Parser-244"><a href="#Snowflake.Parser-244"><span class="linenos">244</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">COLUMN_OPERATORS</span><span class="p">,</span> -</span><span id="Snowflake.Parser-245"><a href="#Snowflake.Parser-245"><span class="linenos">245</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLON</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Snowflake.Parser-246"><a href="#Snowflake.Parser-246"><span class="linenos">246</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">path</span><span class="p">]</span> -</span><span id="Snowflake.Parser-247"><a href="#Snowflake.Parser-247"><span class="linenos">247</span></a> <span class="p">),</span> -</span><span id="Snowflake.Parser-248"><a href="#Snowflake.Parser-248"><span class="linenos">248</span></a> <span class="p">}</span> -</span><span id="Snowflake.Parser-249"><a href="#Snowflake.Parser-249"><span class="linenos">249</span></a> -</span><span id="Snowflake.Parser-250"><a href="#Snowflake.Parser-250"><span class="linenos">250</span></a> <span class="n">TIMESTAMPS</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">TIMESTAMPS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="o">-</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">TIME</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Snowflake.Parser-205"><a href="#Snowflake.Parser-205"><span class="linenos">205</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="Snowflake.Parser-206"><a href="#Snowflake.Parser-206"><span class="linenos">206</span></a> <span class="n">IDENTIFY_PIVOT_STRINGS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Snowflake.Parser-207"><a href="#Snowflake.Parser-207"><span class="linenos">207</span></a> +</span><span id="Snowflake.Parser-208"><a href="#Snowflake.Parser-208"><span class="linenos">208</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake.Parser-209"><a href="#Snowflake.Parser-209"><span class="linenos">209</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="Snowflake.Parser-210"><a href="#Snowflake.Parser-210"><span class="linenos">210</span></a> <span class="s2">"ARRAYAGG"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayAgg</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Snowflake.Parser-211"><a href="#Snowflake.Parser-211"><span class="linenos">211</span></a> <span class="s2">"ARRAY_CONSTRUCT"</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="Snowflake.Parser-212"><a href="#Snowflake.Parser-212"><span class="linenos">212</span></a> <span class="s2">"ARRAY_TO_STRING"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayJoin</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Snowflake.Parser-213"><a href="#Snowflake.Parser-213"><span class="linenos">213</span></a> <span class="s2">"CONVERT_TIMEZONE"</span><span class="p">:</span> <span class="n">_parse_convert_timezone</span><span class="p">,</span> +</span><span id="Snowflake.Parser-214"><a href="#Snowflake.Parser-214"><span class="linenos">214</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="Snowflake.Parser-215"><a href="#Snowflake.Parser-215"><span class="linenos">215</span></a> <span class="s2">"DATEADD"</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">DateAdd</span><span class="p">(</span> +</span><span id="Snowflake.Parser-216"><a href="#Snowflake.Parser-216"><span class="linenos">216</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">2</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">unit</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="Snowflake.Parser-217"><a href="#Snowflake.Parser-217"><span class="linenos">217</span></a> <span class="p">),</span> +</span><span id="Snowflake.Parser-218"><a href="#Snowflake.Parser-218"><span class="linenos">218</span></a> <span class="s2">"DATEDIFF"</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">DateDiff</span><span class="p">(</span> +</span><span id="Snowflake.Parser-219"><a href="#Snowflake.Parser-219"><span class="linenos">219</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">2</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">unit</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="Snowflake.Parser-220"><a href="#Snowflake.Parser-220"><span class="linenos">220</span></a> <span class="p">),</span> +</span><span id="Snowflake.Parser-221"><a href="#Snowflake.Parser-221"><span class="linenos">221</span></a> <span class="s2">"DIV0"</span><span class="p">:</span> <span class="n">_div0_to_if</span><span class="p">,</span> +</span><span id="Snowflake.Parser-222"><a href="#Snowflake.Parser-222"><span class="linenos">222</span></a> <span class="s2">"IFF"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Snowflake.Parser-223"><a href="#Snowflake.Parser-223"><span class="linenos">223</span></a> <span class="s2">"NULLIFZERO"</span><span class="p">:</span> <span class="n">_nullifzero_to_if</span><span class="p">,</span> +</span><span id="Snowflake.Parser-224"><a href="#Snowflake.Parser-224"><span class="linenos">224</span></a> <span class="s2">"OBJECT_CONSTRUCT"</span><span class="p">:</span> <span class="n">_parse_object_construct</span><span class="p">,</span> +</span><span id="Snowflake.Parser-225"><a href="#Snowflake.Parser-225"><span class="linenos">225</span></a> <span class="s2">"RLIKE"</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="Snowflake.Parser-226"><a href="#Snowflake.Parser-226"><span class="linenos">226</span></a> <span class="s2">"SQUARE"</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">Pow</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">2</span><span class="p">)),</span> +</span><span id="Snowflake.Parser-227"><a href="#Snowflake.Parser-227"><span class="linenos">227</span></a> <span class="s2">"TO_ARRAY"</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="Snowflake.Parser-228"><a href="#Snowflake.Parser-228"><span class="linenos">228</span></a> <span class="s2">"TO_VARCHAR"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="Snowflake.Parser-229"><a href="#Snowflake.Parser-229"><span class="linenos">229</span></a> <span class="s2">"TO_TIMESTAMP"</span><span class="p">:</span> <span class="n">_snowflake_to_timestamp</span><span class="p">,</span> +</span><span id="Snowflake.Parser-230"><a href="#Snowflake.Parser-230"><span class="linenos">230</span></a> <span class="s2">"ZEROIFNULL"</span><span class="p">:</span> <span class="n">_zeroifnull_to_if</span><span class="p">,</span> +</span><span id="Snowflake.Parser-231"><a href="#Snowflake.Parser-231"><span class="linenos">231</span></a> <span class="p">}</span> +</span><span id="Snowflake.Parser-232"><a href="#Snowflake.Parser-232"><span class="linenos">232</span></a> +</span><span id="Snowflake.Parser-233"><a href="#Snowflake.Parser-233"><span class="linenos">233</span></a> <span class="n">FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake.Parser-234"><a href="#Snowflake.Parser-234"><span class="linenos">234</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">FUNCTION_PARSERS</span><span class="p">,</span> +</span><span id="Snowflake.Parser-235"><a href="#Snowflake.Parser-235"><span class="linenos">235</span></a> <span class="s2">"DATE_PART"</span><span class="p">:</span> <span class="n">_parse_date_part</span><span class="p">,</span> +</span><span id="Snowflake.Parser-236"><a href="#Snowflake.Parser-236"><span class="linenos">236</span></a> <span class="p">}</span> +</span><span id="Snowflake.Parser-237"><a href="#Snowflake.Parser-237"><span class="linenos">237</span></a> <span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">)</span> +</span><span id="Snowflake.Parser-238"><a href="#Snowflake.Parser-238"><span class="linenos">238</span></a> +</span><span id="Snowflake.Parser-239"><a href="#Snowflake.Parser-239"><span class="linenos">239</span></a> <span class="n">FUNC_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake.Parser-240"><a href="#Snowflake.Parser-240"><span class="linenos">240</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">FUNC_TOKENS</span><span class="p">,</span> +</span><span id="Snowflake.Parser-241"><a href="#Snowflake.Parser-241"><span class="linenos">241</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> +</span><span id="Snowflake.Parser-242"><a href="#Snowflake.Parser-242"><span class="linenos">242</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> +</span><span id="Snowflake.Parser-243"><a href="#Snowflake.Parser-243"><span class="linenos">243</span></a> <span class="p">}</span> +</span><span id="Snowflake.Parser-244"><a href="#Snowflake.Parser-244"><span class="linenos">244</span></a> +</span><span id="Snowflake.Parser-245"><a href="#Snowflake.Parser-245"><span class="linenos">245</span></a> <span class="n">COLUMN_OPERATORS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake.Parser-246"><a href="#Snowflake.Parser-246"><span class="linenos">246</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">COLUMN_OPERATORS</span><span class="p">,</span> +</span><span id="Snowflake.Parser-247"><a href="#Snowflake.Parser-247"><span class="linenos">247</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLON</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Snowflake.Parser-248"><a href="#Snowflake.Parser-248"><span class="linenos">248</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">path</span><span class="p">]</span> +</span><span id="Snowflake.Parser-249"><a href="#Snowflake.Parser-249"><span class="linenos">249</span></a> <span class="p">),</span> +</span><span id="Snowflake.Parser-250"><a href="#Snowflake.Parser-250"><span class="linenos">250</span></a> <span class="p">}</span> </span><span id="Snowflake.Parser-251"><a href="#Snowflake.Parser-251"><span class="linenos">251</span></a> -</span><span id="Snowflake.Parser-252"><a href="#Snowflake.Parser-252"><span class="linenos">252</span></a> <span class="n">RANGE_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake.Parser-253"><a href="#Snowflake.Parser-253"><span class="linenos">253</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">RANGE_PARSERS</span><span class="p">,</span> -</span><span id="Snowflake.Parser-254"><a href="#Snowflake.Parser-254"><span class="linenos">254</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIKE_ANY</span><span class="p">:</span> <span class="n">binary_range_parser</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LikeAny</span><span class="p">),</span> -</span><span id="Snowflake.Parser-255"><a href="#Snowflake.Parser-255"><span class="linenos">255</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ILIKE_ANY</span><span class="p">:</span> <span class="n">binary_range_parser</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ILikeAny</span><span class="p">),</span> -</span><span id="Snowflake.Parser-256"><a href="#Snowflake.Parser-256"><span class="linenos">256</span></a> <span class="p">}</span> -</span><span id="Snowflake.Parser-257"><a href="#Snowflake.Parser-257"><span class="linenos">257</span></a> -</span><span id="Snowflake.Parser-258"><a href="#Snowflake.Parser-258"><span class="linenos">258</span></a> <span class="n">ALTER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake.Parser-259"><a href="#Snowflake.Parser-259"><span class="linenos">259</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">ALTER_PARSERS</span><span class="p">,</span> -</span><span id="Snowflake.Parser-260"><a href="#Snowflake.Parser-260"><span class="linenos">260</span></a> <span class="s2">"UNSET"</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_alter_table_set_tag</span><span class="p">(</span><span class="n">unset</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="Snowflake.Parser-261"><a href="#Snowflake.Parser-261"><span class="linenos">261</span></a> <span class="s2">"SET"</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_alter_table_set_tag</span><span class="p">(),</span> -</span><span id="Snowflake.Parser-262"><a href="#Snowflake.Parser-262"><span class="linenos">262</span></a> <span class="p">}</span> -</span><span id="Snowflake.Parser-263"><a href="#Snowflake.Parser-263"><span class="linenos">263</span></a> -</span><span id="Snowflake.Parser-264"><a href="#Snowflake.Parser-264"><span class="linenos">264</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_set_tag</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">unset</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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="Snowflake.Parser-265"><a href="#Snowflake.Parser-265"><span class="linenos">265</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TAG"</span><span class="p">)</span> -</span><span id="Snowflake.Parser-266"><a href="#Snowflake.Parser-266"><span class="linenos">266</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span> <span class="k">if</span> <span class="n">unset</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="Snowflake.Parser-267"><a href="#Snowflake.Parser-267"><span class="linenos">267</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">SetTag</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">parser</span><span class="p">),</span> <span class="n">unset</span><span class="o">=</span><span class="n">unset</span><span class="p">)</span> +</span><span id="Snowflake.Parser-252"><a href="#Snowflake.Parser-252"><span class="linenos">252</span></a> <span class="n">TIMESTAMPS</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">TIMESTAMPS</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="o">-</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">TIME</span><span class="p">}</span> +</span><span id="Snowflake.Parser-253"><a href="#Snowflake.Parser-253"><span class="linenos">253</span></a> +</span><span id="Snowflake.Parser-254"><a href="#Snowflake.Parser-254"><span class="linenos">254</span></a> <span class="n">RANGE_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake.Parser-255"><a href="#Snowflake.Parser-255"><span class="linenos">255</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">RANGE_PARSERS</span><span class="p">,</span> +</span><span id="Snowflake.Parser-256"><a href="#Snowflake.Parser-256"><span class="linenos">256</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIKE_ANY</span><span class="p">:</span> <span class="n">binary_range_parser</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LikeAny</span><span class="p">),</span> +</span><span id="Snowflake.Parser-257"><a href="#Snowflake.Parser-257"><span class="linenos">257</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ILIKE_ANY</span><span class="p">:</span> <span class="n">binary_range_parser</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ILikeAny</span><span class="p">),</span> +</span><span id="Snowflake.Parser-258"><a href="#Snowflake.Parser-258"><span class="linenos">258</span></a> <span class="p">}</span> +</span><span id="Snowflake.Parser-259"><a href="#Snowflake.Parser-259"><span class="linenos">259</span></a> +</span><span id="Snowflake.Parser-260"><a href="#Snowflake.Parser-260"><span class="linenos">260</span></a> <span class="n">ALTER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake.Parser-261"><a href="#Snowflake.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">ALTER_PARSERS</span><span class="p">,</span> +</span><span id="Snowflake.Parser-262"><a href="#Snowflake.Parser-262"><span class="linenos">262</span></a> <span class="s2">"UNSET"</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_alter_table_set_tag</span><span class="p">(</span><span class="n">unset</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="Snowflake.Parser-263"><a href="#Snowflake.Parser-263"><span class="linenos">263</span></a> <span class="s2">"SET"</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_alter_table_set_tag</span><span class="p">(),</span> +</span><span id="Snowflake.Parser-264"><a href="#Snowflake.Parser-264"><span class="linenos">264</span></a> <span class="p">}</span> +</span><span id="Snowflake.Parser-265"><a href="#Snowflake.Parser-265"><span class="linenos">265</span></a> +</span><span id="Snowflake.Parser-266"><a href="#Snowflake.Parser-266"><span class="linenos">266</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_set_tag</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">unset</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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="Snowflake.Parser-267"><a href="#Snowflake.Parser-267"><span class="linenos">267</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TAG"</span><span class="p">)</span> +</span><span id="Snowflake.Parser-268"><a href="#Snowflake.Parser-268"><span class="linenos">268</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span> <span class="k">if</span> <span class="n">unset</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="Snowflake.Parser-269"><a href="#Snowflake.Parser-269"><span class="linenos">269</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">SetTag</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">parser</span><span class="p">),</span> <span class="n">unset</span><span class="o">=</span><span class="n">unset</span><span class="p">)</span> </span></pre></div> @@ -880,37 +891,37 @@ Default: 3</li> </div> <a class="headerlink" href="#Snowflake.Tokenizer"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Snowflake.Tokenizer-269"><a href="#Snowflake.Tokenizer-269"><span class="linenos">269</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="Snowflake.Tokenizer-270"><a href="#Snowflake.Tokenizer-270"><span class="linenos">270</span></a> <span class="n">QUOTES</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="Snowflake.Tokenizer-271"><a href="#Snowflake.Tokenizer-271"><span class="linenos">271</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">]</span> -</span><span id="Snowflake.Tokenizer-272"><a href="#Snowflake.Tokenizer-272"><span class="linenos">272</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"x'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"X'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">)]</span> -</span><span id="Snowflake.Tokenizer-273"><a href="#Snowflake.Tokenizer-273"><span class="linenos">273</span></a> <span class="n">COMMENTS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--"</span><span class="p">,</span> <span class="s2">"//"</span><span class="p">,</span> <span class="p">(</span><span class="s2">"/*"</span><span class="p">,</span> <span class="s2">"*/"</span><span class="p">)]</span> -</span><span id="Snowflake.Tokenizer-274"><a href="#Snowflake.Tokenizer-274"><span class="linenos">274</span></a> -</span><span id="Snowflake.Tokenizer-275"><a href="#Snowflake.Tokenizer-275"><span class="linenos">275</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake.Tokenizer-276"><a href="#Snowflake.Tokenizer-276"><span class="linenos">276</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="Snowflake.Tokenizer-277"><a href="#Snowflake.Tokenizer-277"><span class="linenos">277</span></a> <span class="s2">"CHAR VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> -</span><span id="Snowflake.Tokenizer-278"><a href="#Snowflake.Tokenizer-278"><span class="linenos">278</span></a> <span class="s2">"CHARACTER VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> -</span><span id="Snowflake.Tokenizer-279"><a href="#Snowflake.Tokenizer-279"><span class="linenos">279</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="Snowflake.Tokenizer-280"><a href="#Snowflake.Tokenizer-280"><span class="linenos">280</span></a> <span class="s2">"ILIKE ANY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ILIKE_ANY</span><span class="p">,</span> -</span><span id="Snowflake.Tokenizer-281"><a href="#Snowflake.Tokenizer-281"><span class="linenos">281</span></a> <span class="s2">"LIKE ANY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIKE_ANY</span><span class="p">,</span> -</span><span id="Snowflake.Tokenizer-282"><a href="#Snowflake.Tokenizer-282"><span class="linenos">282</span></a> <span class="s2">"MATCH_RECOGNIZE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MATCH_RECOGNIZE</span><span class="p">,</span> -</span><span id="Snowflake.Tokenizer-283"><a href="#Snowflake.Tokenizer-283"><span class="linenos">283</span></a> <span class="s2">"MINUS"</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="Snowflake.Tokenizer-284"><a href="#Snowflake.Tokenizer-284"><span class="linenos">284</span></a> <span class="s2">"NCHAR VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> -</span><span id="Snowflake.Tokenizer-285"><a href="#Snowflake.Tokenizer-285"><span class="linenos">285</span></a> <span class="s2">"PUT"</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="Snowflake.Tokenizer-286"><a href="#Snowflake.Tokenizer-286"><span class="linenos">286</span></a> <span class="s2">"RENAME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">,</span> -</span><span id="Snowflake.Tokenizer-287"><a href="#Snowflake.Tokenizer-287"><span class="linenos">287</span></a> <span class="s2">"TIMESTAMP_LTZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">,</span> -</span><span id="Snowflake.Tokenizer-288"><a href="#Snowflake.Tokenizer-288"><span class="linenos">288</span></a> <span class="s2">"TIMESTAMP_NTZ"</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="Snowflake.Tokenizer-289"><a href="#Snowflake.Tokenizer-289"><span class="linenos">289</span></a> <span class="s2">"TIMESTAMP_TZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> -</span><span id="Snowflake.Tokenizer-290"><a href="#Snowflake.Tokenizer-290"><span class="linenos">290</span></a> <span class="s2">"TIMESTAMPNTZ"</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="Snowflake.Tokenizer-291"><a href="#Snowflake.Tokenizer-291"><span class="linenos">291</span></a> <span class="s2">"SAMPLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span><span class="p">,</span> -</span><span id="Snowflake.Tokenizer-292"><a href="#Snowflake.Tokenizer-292"><span class="linenos">292</span></a> <span class="p">}</span> -</span><span id="Snowflake.Tokenizer-293"><a href="#Snowflake.Tokenizer-293"><span class="linenos">293</span></a> -</span><span id="Snowflake.Tokenizer-294"><a href="#Snowflake.Tokenizer-294"><span class="linenos">294</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake.Tokenizer-295"><a href="#Snowflake.Tokenizer-295"><span class="linenos">295</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="Snowflake.Tokenizer-296"><a href="#Snowflake.Tokenizer-296"><span class="linenos">296</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="Snowflake.Tokenizer-297"><a href="#Snowflake.Tokenizer-297"><span class="linenos">297</span></a> <span class="p">}</span> -</span><span id="Snowflake.Tokenizer-298"><a href="#Snowflake.Tokenizer-298"><span class="linenos">298</span></a> -</span><span id="Snowflake.Tokenizer-299"><a href="#Snowflake.Tokenizer-299"><span class="linenos">299</span></a> <span class="n">VAR_SINGLE_TOKENS</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="Snowflake.Tokenizer-271"><a href="#Snowflake.Tokenizer-271"><span class="linenos">271</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="Snowflake.Tokenizer-272"><a href="#Snowflake.Tokenizer-272"><span class="linenos">272</span></a> <span class="n">QUOTES</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="Snowflake.Tokenizer-273"><a href="#Snowflake.Tokenizer-273"><span class="linenos">273</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">]</span> +</span><span id="Snowflake.Tokenizer-274"><a href="#Snowflake.Tokenizer-274"><span class="linenos">274</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"x'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"X'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">)]</span> +</span><span id="Snowflake.Tokenizer-275"><a href="#Snowflake.Tokenizer-275"><span class="linenos">275</span></a> <span class="n">COMMENTS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--"</span><span class="p">,</span> <span class="s2">"//"</span><span class="p">,</span> <span class="p">(</span><span class="s2">"/*"</span><span class="p">,</span> <span class="s2">"*/"</span><span class="p">)]</span> +</span><span id="Snowflake.Tokenizer-276"><a href="#Snowflake.Tokenizer-276"><span class="linenos">276</span></a> +</span><span id="Snowflake.Tokenizer-277"><a href="#Snowflake.Tokenizer-277"><span class="linenos">277</span></a> <span class="n">KEYWORDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake.Tokenizer-278"><a href="#Snowflake.Tokenizer-278"><span class="linenos">278</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="Snowflake.Tokenizer-279"><a href="#Snowflake.Tokenizer-279"><span class="linenos">279</span></a> <span class="s2">"CHAR VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> +</span><span id="Snowflake.Tokenizer-280"><a href="#Snowflake.Tokenizer-280"><span class="linenos">280</span></a> <span class="s2">"CHARACTER VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> +</span><span id="Snowflake.Tokenizer-281"><a href="#Snowflake.Tokenizer-281"><span class="linenos">281</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="Snowflake.Tokenizer-282"><a href="#Snowflake.Tokenizer-282"><span class="linenos">282</span></a> <span class="s2">"ILIKE ANY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ILIKE_ANY</span><span class="p">,</span> +</span><span id="Snowflake.Tokenizer-283"><a href="#Snowflake.Tokenizer-283"><span class="linenos">283</span></a> <span class="s2">"LIKE ANY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIKE_ANY</span><span class="p">,</span> +</span><span id="Snowflake.Tokenizer-284"><a href="#Snowflake.Tokenizer-284"><span class="linenos">284</span></a> <span class="s2">"MATCH_RECOGNIZE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MATCH_RECOGNIZE</span><span class="p">,</span> +</span><span id="Snowflake.Tokenizer-285"><a href="#Snowflake.Tokenizer-285"><span class="linenos">285</span></a> <span class="s2">"MINUS"</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="Snowflake.Tokenizer-286"><a href="#Snowflake.Tokenizer-286"><span class="linenos">286</span></a> <span class="s2">"NCHAR VARYING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> +</span><span id="Snowflake.Tokenizer-287"><a href="#Snowflake.Tokenizer-287"><span class="linenos">287</span></a> <span class="s2">"PUT"</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="Snowflake.Tokenizer-288"><a href="#Snowflake.Tokenizer-288"><span class="linenos">288</span></a> <span class="s2">"RENAME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">,</span> +</span><span id="Snowflake.Tokenizer-289"><a href="#Snowflake.Tokenizer-289"><span class="linenos">289</span></a> <span class="s2">"TIMESTAMP_LTZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">,</span> +</span><span id="Snowflake.Tokenizer-290"><a href="#Snowflake.Tokenizer-290"><span class="linenos">290</span></a> <span class="s2">"TIMESTAMP_NTZ"</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="Snowflake.Tokenizer-291"><a href="#Snowflake.Tokenizer-291"><span class="linenos">291</span></a> <span class="s2">"TIMESTAMP_TZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> +</span><span id="Snowflake.Tokenizer-292"><a href="#Snowflake.Tokenizer-292"><span class="linenos">292</span></a> <span class="s2">"TIMESTAMPNTZ"</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="Snowflake.Tokenizer-293"><a href="#Snowflake.Tokenizer-293"><span class="linenos">293</span></a> <span class="s2">"SAMPLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span><span class="p">,</span> +</span><span id="Snowflake.Tokenizer-294"><a href="#Snowflake.Tokenizer-294"><span class="linenos">294</span></a> <span class="p">}</span> +</span><span id="Snowflake.Tokenizer-295"><a href="#Snowflake.Tokenizer-295"><span class="linenos">295</span></a> +</span><span id="Snowflake.Tokenizer-296"><a href="#Snowflake.Tokenizer-296"><span class="linenos">296</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake.Tokenizer-297"><a href="#Snowflake.Tokenizer-297"><span class="linenos">297</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="Snowflake.Tokenizer-298"><a href="#Snowflake.Tokenizer-298"><span class="linenos">298</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="Snowflake.Tokenizer-299"><a href="#Snowflake.Tokenizer-299"><span class="linenos">299</span></a> <span class="p">}</span> +</span><span id="Snowflake.Tokenizer-300"><a href="#Snowflake.Tokenizer-300"><span class="linenos">300</span></a> +</span><span id="Snowflake.Tokenizer-301"><a href="#Snowflake.Tokenizer-301"><span class="linenos">301</span></a> <span class="n">VAR_SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"$"</span><span class="p">}</span> </span></pre></div> @@ -939,104 +950,104 @@ Default: 3</li> </div> <a class="headerlink" href="#Snowflake.Generator"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Snowflake.Generator-301"><a href="#Snowflake.Generator-301"><span class="linenos">301</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="Snowflake.Generator-302"><a href="#Snowflake.Generator-302"><span class="linenos">302</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"$"</span> -</span><span id="Snowflake.Generator-303"><a href="#Snowflake.Generator-303"><span class="linenos">303</span></a> <span class="n">MATCHED_BY_SOURCE</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Snowflake.Generator-304"><a href="#Snowflake.Generator-304"><span class="linenos">304</span></a> <span class="n">SINGLE_STRING_INTERVAL</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Snowflake.Generator-305"><a href="#Snowflake.Generator-305"><span class="linenos">305</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Snowflake.Generator-306"><a href="#Snowflake.Generator-306"><span class="linenos">306</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Snowflake.Generator-307"><a href="#Snowflake.Generator-307"><span class="linenos">307</span></a> -</span><span id="Snowflake.Generator-308"><a href="#Snowflake.Generator-308"><span class="linenos">308</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake.Generator-309"><a href="#Snowflake.Generator-309"><span class="linenos">309</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="Snowflake.Generator-310"><a href="#Snowflake.Generator-310"><span class="linenos">310</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_sql</span><span class="p">,</span> -</span><span id="Snowflake.Generator-311"><a href="#Snowflake.Generator-311"><span class="linenos">311</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_CAT"</span><span class="p">),</span> -</span><span id="Snowflake.Generator-312"><a href="#Snowflake.Generator-312"><span class="linenos">312</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayJoin</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_TO_STRING"</span><span class="p">),</span> -</span><span id="Snowflake.Generator-313"><a href="#Snowflake.Generator-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</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="Snowflake.Generator-314"><a href="#Snowflake.Generator-314"><span class="linenos">314</span></a> <span class="s2">"CONVERT_TIMEZONE"</span><span class="p">,</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="s2">"zone"</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> -</span><span id="Snowflake.Generator-315"><a href="#Snowflake.Generator-315"><span class="linenos">315</span></a> <span class="p">),</span> -</span><span id="Snowflake.Generator-316"><a href="#Snowflake.Generator-316"><span class="linenos">316</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</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">"DATEADD"</span><span class="p">,</span> <span class="n">e</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="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 class="p">),</span> -</span><span id="Snowflake.Generator-317"><a href="#Snowflake.Generator-317"><span class="linenos">317</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="Snowflake.Generator-318"><a href="#Snowflake.Generator-318"><span class="linenos">318</span></a> <span class="s2">"DATEDIFF"</span><span class="p">,</span> <span class="n">e</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="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="Snowflake.Generator-319"><a href="#Snowflake.Generator-319"><span class="linenos">319</span></a> <span class="p">),</span> -</span><span id="Snowflake.Generator-320"><a href="#Snowflake.Generator-320"><span class="linenos">320</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="Snowflake.Generator-321"><a href="#Snowflake.Generator-321"><span class="linenos">321</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="Snowflake.Generator-322"><a href="#Snowflake.Generator-322"><span class="linenos">322</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="Snowflake.Generator-323"><a href="#Snowflake.Generator-323"><span class="linenos">323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATE_PART"</span><span class="p">),</span> -</span><span id="Snowflake.Generator-324"><a href="#Snowflake.Generator-324"><span class="linenos">324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"IFF"</span><span class="p">),</span> -</span><span id="Snowflake.Generator-325"><a href="#Snowflake.Generator-325"><span class="linenos">325</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">"BOOLAND_AGG"</span><span class="p">),</span> -</span><span id="Snowflake.Generator-326"><a href="#Snowflake.Generator-326"><span class="linenos">326</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">"BOOLOR_AGG"</span><span class="p">),</span> -</span><span id="Snowflake.Generator-327"><a href="#Snowflake.Generator-327"><span class="linenos">327</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Map</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">var_map_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">"OBJECT_CONSTRUCT"</span><span class="p">),</span> -</span><span id="Snowflake.Generator-328"><a href="#Snowflake.Generator-328"><span class="linenos">328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> -</span><span id="Snowflake.Generator-329"><a href="#Snowflake.Generator-329"><span class="linenos">329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> -</span><span id="Snowflake.Generator-330"><a href="#Snowflake.Generator-330"><span class="linenos">330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</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">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Snowflake.Generator-331"><a href="#Snowflake.Generator-331"><span class="linenos">331</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</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">eliminate_distinct_on</span><span class="p">]),</span> -</span><span id="Snowflake.Generator-332"><a href="#Snowflake.Generator-332"><span class="linenos">332</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StarMap</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"OBJECT_CONSTRUCT"</span><span class="p">),</span> -</span><span id="Snowflake.Generator-333"><a href="#Snowflake.Generator-333"><span class="linenos">333</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</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="Snowflake.Generator-334"><a href="#Snowflake.Generator-334"><span class="linenos">334</span></a> <span class="s2">"POSITION"</span><span class="p">,</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="s2">"substr"</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">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">"position"</span><span class="p">)</span> -</span><span id="Snowflake.Generator-335"><a href="#Snowflake.Generator-335"><span class="linenos">335</span></a> <span class="p">),</span> -</span><span id="Snowflake.Generator-336"><a href="#Snowflake.Generator-336"><span class="linenos">336</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</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">"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">, </span><span class="si">{</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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Snowflake.Generator-337"><a href="#Snowflake.Generator-337"><span class="linenos">337</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</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="Snowflake.Generator-338"><a href="#Snowflake.Generator-338"><span class="linenos">338</span></a> <span class="s2">"OBJECT_CONSTRUCT"</span><span class="p">,</span> -</span><span id="Snowflake.Generator-339"><a href="#Snowflake.Generator-339"><span class="linenos">339</span></a> <span class="o">*</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">e</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">()),</span> -</span><span id="Snowflake.Generator-340"><a href="#Snowflake.Generator-340"><span class="linenos">340</span></a> <span class="p">),</span> -</span><span id="Snowflake.Generator-341"><a href="#Snowflake.Generator-341"><span class="linenos">341</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="Snowflake.Generator-342"><a href="#Snowflake.Generator-342"><span class="linenos">342</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</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">"EXTRACT(epoch_second FROM </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Snowflake.Generator-343"><a href="#Snowflake.Generator-343"><span class="linenos">343</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><span id="Snowflake.Generator-344"><a href="#Snowflake.Generator-344"><span class="linenos">344</span></a> <span class="s2">"TO_CHAR"</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="s2">"timestamp"</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="Snowflake.Generator-345"><a href="#Snowflake.Generator-345"><span class="linenos">345</span></a> <span class="p">),</span> -</span><span id="Snowflake.Generator-346"><a href="#Snowflake.Generator-346"><span class="linenos">346</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="Snowflake.Generator-347"><a href="#Snowflake.Generator-347"><span class="linenos">347</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</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">function_fallback_sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="Snowflake.Generator-348"><a href="#Snowflake.Generator-348"><span class="linenos">348</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</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">"TRIM"</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">e</span><span class="o">.</span><span class="n">expression</span><span class="p">),</span> -</span><span id="Snowflake.Generator-349"><a href="#Snowflake.Generator-349"><span class="linenos">349</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="s2">"snowflake"</span><span class="p">),</span> -</span><span id="Snowflake.Generator-350"><a href="#Snowflake.Generator-350"><span class="linenos">350</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="Snowflake.Generator-351"><a href="#Snowflake.Generator-351"><span class="linenos">351</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</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">var_map_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">"OBJECT_CONSTRUCT"</span><span class="p">),</span> -</span><span id="Snowflake.Generator-352"><a href="#Snowflake.Generator-352"><span class="linenos">352</span></a> <span class="p">}</span> -</span><span id="Snowflake.Generator-353"><a href="#Snowflake.Generator-353"><span class="linenos">353</span></a> -</span><span id="Snowflake.Generator-354"><a href="#Snowflake.Generator-354"><span class="linenos">354</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake.Generator-355"><a href="#Snowflake.Generator-355"><span class="linenos">355</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="Snowflake.Generator-356"><a href="#Snowflake.Generator-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">TIMESTAMP</span><span class="p">:</span> <span class="s2">"TIMESTAMPNTZ"</span><span class="p">,</span> -</span><span id="Snowflake.Generator-357"><a href="#Snowflake.Generator-357"><span class="linenos">357</span></a> <span class="p">}</span> -</span><span id="Snowflake.Generator-358"><a href="#Snowflake.Generator-358"><span class="linenos">358</span></a> -</span><span id="Snowflake.Generator-359"><a href="#Snowflake.Generator-359"><span class="linenos">359</span></a> <span class="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake.Generator-360"><a href="#Snowflake.Generator-360"><span class="linenos">360</span></a> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCLUDE"</span><span class="p">,</span> -</span><span id="Snowflake.Generator-361"><a href="#Snowflake.Generator-361"><span class="linenos">361</span></a> <span class="s2">"replace"</span><span class="p">:</span> <span class="s2">"RENAME"</span><span class="p">,</span> -</span><span id="Snowflake.Generator-362"><a href="#Snowflake.Generator-362"><span class="linenos">362</span></a> <span class="p">}</span> -</span><span id="Snowflake.Generator-363"><a href="#Snowflake.Generator-363"><span class="linenos">363</span></a> -</span><span id="Snowflake.Generator-364"><a href="#Snowflake.Generator-364"><span class="linenos">364</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Snowflake.Generator-365"><a href="#Snowflake.Generator-365"><span class="linenos">365</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">PROPERTIES_LOCATION</span><span class="p">,</span> -</span><span id="Snowflake.Generator-366"><a href="#Snowflake.Generator-366"><span class="linenos">366</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="Snowflake.Generator-367"><a href="#Snowflake.Generator-367"><span class="linenos">367</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> -</span><span id="Snowflake.Generator-368"><a href="#Snowflake.Generator-368"><span class="linenos">368</span></a> <span class="p">}</span> -</span><span id="Snowflake.Generator-369"><a href="#Snowflake.Generator-369"><span class="linenos">369</span></a> -</span><span id="Snowflake.Generator-370"><a href="#Snowflake.Generator-370"><span class="linenos">370</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Snowflake.Generator-371"><a href="#Snowflake.Generator-371"><span class="linenos">371</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> -</span><span id="Snowflake.Generator-372"><a href="#Snowflake.Generator-372"><span class="linenos">372</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"EXCEPT with All is not supported in Snowflake"</span><span class="p">)</span> -</span><span id="Snowflake.Generator-373"><a href="#Snowflake.Generator-373"><span class="linenos">373</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Snowflake.Generator-374"><a href="#Snowflake.Generator-374"><span class="linenos">374</span></a> -</span><span id="Snowflake.Generator-375"><a href="#Snowflake.Generator-375"><span class="linenos">375</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Snowflake.Generator-376"><a href="#Snowflake.Generator-376"><span class="linenos">376</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> -</span><span id="Snowflake.Generator-377"><a href="#Snowflake.Generator-377"><span class="linenos">377</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"INTERSECT with All is not supported in Snowflake"</span><span class="p">)</span> -</span><span id="Snowflake.Generator-378"><a href="#Snowflake.Generator-378"><span class="linenos">378</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Snowflake.Generator-379"><a href="#Snowflake.Generator-379"><span class="linenos">379</span></a> -</span><span id="Snowflake.Generator-380"><a href="#Snowflake.Generator-380"><span class="linenos">380</span></a> <span class="k">def</span> <span class="nf">settag_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetTag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Snowflake.Generator-381"><a href="#Snowflake.Generator-381"><span class="linenos">381</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"UNSET"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unset"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"SET"</span> -</span><span id="Snowflake.Generator-382"><a href="#Snowflake.Generator-382"><span class="linenos">382</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">action</span><span class="si">}</span><span class="s2"> TAG </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Snowflake.Generator-383"><a href="#Snowflake.Generator-383"><span class="linenos">383</span></a> -</span><span id="Snowflake.Generator-384"><a href="#Snowflake.Generator-384"><span class="linenos">384</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Snowflake.Generator-385"><a href="#Snowflake.Generator-385"><span class="linenos">385</span></a> <span class="c1"># Default to table if kind is unknown</span> -</span><span id="Snowflake.Generator-386"><a href="#Snowflake.Generator-386"><span class="linenos">386</span></a> <span class="n">kind_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"TABLE"</span> -</span><span id="Snowflake.Generator-387"><a href="#Snowflake.Generator-387"><span class="linenos">387</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind_value</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind_value</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Snowflake.Generator-388"><a href="#Snowflake.Generator-388"><span class="linenos">388</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Snowflake.Generator-389"><a href="#Snowflake.Generator-389"><span class="linenos">389</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Snowflake.Generator-390"><a href="#Snowflake.Generator-390"><span class="linenos">390</span></a> -</span><span id="Snowflake.Generator-391"><a href="#Snowflake.Generator-391"><span class="linenos">391</span></a> <span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> -</span><span id="Snowflake.Generator-392"><a href="#Snowflake.Generator-392"><span class="linenos">392</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> -</span><span id="Snowflake.Generator-393"><a href="#Snowflake.Generator-393"><span class="linenos">393</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Snowflake.Generator-394"><a href="#Snowflake.Generator-394"><span class="linenos">394</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"start"</span><span class="p">)</span> -</span><span id="Snowflake.Generator-395"><a href="#Snowflake.Generator-395"><span class="linenos">395</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" START </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Snowflake.Generator-396"><a href="#Snowflake.Generator-396"><span class="linenos">396</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"increment"</span><span class="p">)</span> -</span><span id="Snowflake.Generator-397"><a href="#Snowflake.Generator-397"><span class="linenos">397</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Snowflake.Generator-398"><a href="#Snowflake.Generator-398"><span class="linenos">398</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"AUTOINCREMENT</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Snowflake.Generator-303"><a href="#Snowflake.Generator-303"><span class="linenos">303</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="Snowflake.Generator-304"><a href="#Snowflake.Generator-304"><span class="linenos">304</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"$"</span> +</span><span id="Snowflake.Generator-305"><a href="#Snowflake.Generator-305"><span class="linenos">305</span></a> <span class="n">MATCHED_BY_SOURCE</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Snowflake.Generator-306"><a href="#Snowflake.Generator-306"><span class="linenos">306</span></a> <span class="n">SINGLE_STRING_INTERVAL</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Snowflake.Generator-307"><a href="#Snowflake.Generator-307"><span class="linenos">307</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Snowflake.Generator-308"><a href="#Snowflake.Generator-308"><span class="linenos">308</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Snowflake.Generator-309"><a href="#Snowflake.Generator-309"><span class="linenos">309</span></a> +</span><span id="Snowflake.Generator-310"><a href="#Snowflake.Generator-310"><span class="linenos">310</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake.Generator-311"><a href="#Snowflake.Generator-311"><span class="linenos">311</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="Snowflake.Generator-312"><a href="#Snowflake.Generator-312"><span class="linenos">312</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_sql</span><span class="p">,</span> +</span><span id="Snowflake.Generator-313"><a href="#Snowflake.Generator-313"><span class="linenos">313</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayConcat</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_CAT"</span><span class="p">),</span> +</span><span id="Snowflake.Generator-314"><a href="#Snowflake.Generator-314"><span class="linenos">314</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ArrayJoin</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"ARRAY_TO_STRING"</span><span class="p">),</span> +</span><span id="Snowflake.Generator-315"><a href="#Snowflake.Generator-315"><span class="linenos">315</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</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="Snowflake.Generator-316"><a href="#Snowflake.Generator-316"><span class="linenos">316</span></a> <span class="s2">"CONVERT_TIMEZONE"</span><span class="p">,</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="s2">"zone"</span><span class="p">),</span> <span class="n">e</span><span class="o">.</span><span class="n">this</span> +</span><span id="Snowflake.Generator-317"><a href="#Snowflake.Generator-317"><span class="linenos">317</span></a> <span class="p">),</span> +</span><span id="Snowflake.Generator-318"><a href="#Snowflake.Generator-318"><span class="linenos">318</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</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">"DATEADD"</span><span class="p">,</span> <span class="n">e</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="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 class="p">),</span> +</span><span id="Snowflake.Generator-319"><a href="#Snowflake.Generator-319"><span class="linenos">319</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="Snowflake.Generator-320"><a href="#Snowflake.Generator-320"><span class="linenos">320</span></a> <span class="s2">"DATEDIFF"</span><span class="p">,</span> <span class="n">e</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="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="Snowflake.Generator-321"><a href="#Snowflake.Generator-321"><span class="linenos">321</span></a> <span class="p">),</span> +</span><span id="Snowflake.Generator-322"><a href="#Snowflake.Generator-322"><span class="linenos">322</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="Snowflake.Generator-323"><a href="#Snowflake.Generator-323"><span class="linenos">323</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="Snowflake.Generator-324"><a href="#Snowflake.Generator-324"><span class="linenos">324</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="Snowflake.Generator-325"><a href="#Snowflake.Generator-325"><span class="linenos">325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"DATE_PART"</span><span class="p">),</span> +</span><span id="Snowflake.Generator-326"><a href="#Snowflake.Generator-326"><span class="linenos">326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"IFF"</span><span class="p">),</span> +</span><span id="Snowflake.Generator-327"><a href="#Snowflake.Generator-327"><span class="linenos">327</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">"BOOLAND_AGG"</span><span class="p">),</span> +</span><span id="Snowflake.Generator-328"><a href="#Snowflake.Generator-328"><span class="linenos">328</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">"BOOLOR_AGG"</span><span class="p">),</span> +</span><span id="Snowflake.Generator-329"><a href="#Snowflake.Generator-329"><span class="linenos">329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Map</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">var_map_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">"OBJECT_CONSTRUCT"</span><span class="p">),</span> +</span><span id="Snowflake.Generator-330"><a href="#Snowflake.Generator-330"><span class="linenos">330</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Max</span><span class="p">:</span> <span class="n">max_or_greatest</span><span class="p">,</span> +</span><span id="Snowflake.Generator-331"><a href="#Snowflake.Generator-331"><span class="linenos">331</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Min</span><span class="p">:</span> <span class="n">min_or_least</span><span class="p">,</span> +</span><span id="Snowflake.Generator-332"><a href="#Snowflake.Generator-332"><span class="linenos">332</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</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">"PARTITION BY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Snowflake.Generator-333"><a href="#Snowflake.Generator-333"><span class="linenos">333</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</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">eliminate_distinct_on</span><span class="p">]),</span> +</span><span id="Snowflake.Generator-334"><a href="#Snowflake.Generator-334"><span class="linenos">334</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StarMap</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"OBJECT_CONSTRUCT"</span><span class="p">),</span> +</span><span id="Snowflake.Generator-335"><a href="#Snowflake.Generator-335"><span class="linenos">335</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</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="Snowflake.Generator-336"><a href="#Snowflake.Generator-336"><span class="linenos">336</span></a> <span class="s2">"POSITION"</span><span class="p">,</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="s2">"substr"</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">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">"position"</span><span class="p">)</span> +</span><span id="Snowflake.Generator-337"><a href="#Snowflake.Generator-337"><span class="linenos">337</span></a> <span class="p">),</span> +</span><span id="Snowflake.Generator-338"><a href="#Snowflake.Generator-338"><span class="linenos">338</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</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">"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">, </span><span class="si">{</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 class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Snowflake.Generator-339"><a href="#Snowflake.Generator-339"><span class="linenos">339</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</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="Snowflake.Generator-340"><a href="#Snowflake.Generator-340"><span class="linenos">340</span></a> <span class="s2">"OBJECT_CONSTRUCT"</span><span class="p">,</span> +</span><span id="Snowflake.Generator-341"><a href="#Snowflake.Generator-341"><span class="linenos">341</span></a> <span class="o">*</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">e</span><span class="o">.</span><span class="n">expressions</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">()),</span> +</span><span id="Snowflake.Generator-342"><a href="#Snowflake.Generator-342"><span class="linenos">342</span></a> <span class="p">),</span> +</span><span id="Snowflake.Generator-343"><a href="#Snowflake.Generator-343"><span class="linenos">343</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="Snowflake.Generator-344"><a href="#Snowflake.Generator-344"><span class="linenos">344</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeToUnix</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">"EXTRACT(epoch_second FROM </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Snowflake.Generator-345"><a href="#Snowflake.Generator-345"><span class="linenos">345</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><span id="Snowflake.Generator-346"><a href="#Snowflake.Generator-346"><span class="linenos">346</span></a> <span class="s2">"TO_CHAR"</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="s2">"timestamp"</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="Snowflake.Generator-347"><a href="#Snowflake.Generator-347"><span class="linenos">347</span></a> <span class="p">),</span> +</span><span id="Snowflake.Generator-348"><a href="#Snowflake.Generator-348"><span class="linenos">348</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="Snowflake.Generator-349"><a href="#Snowflake.Generator-349"><span class="linenos">349</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</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">function_fallback_sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="Snowflake.Generator-350"><a href="#Snowflake.Generator-350"><span class="linenos">350</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</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">"TRIM"</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">e</span><span class="o">.</span><span class="n">expression</span><span class="p">),</span> +</span><span id="Snowflake.Generator-351"><a href="#Snowflake.Generator-351"><span class="linenos">351</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsToDate</span><span class="p">:</span> <span class="n">ts_or_ds_to_date_sql</span><span class="p">(</span><span class="s2">"snowflake"</span><span class="p">),</span> +</span><span id="Snowflake.Generator-352"><a href="#Snowflake.Generator-352"><span class="linenos">352</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="Snowflake.Generator-353"><a href="#Snowflake.Generator-353"><span class="linenos">353</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</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">var_map_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">"OBJECT_CONSTRUCT"</span><span class="p">),</span> +</span><span id="Snowflake.Generator-354"><a href="#Snowflake.Generator-354"><span class="linenos">354</span></a> <span class="p">}</span> +</span><span id="Snowflake.Generator-355"><a href="#Snowflake.Generator-355"><span class="linenos">355</span></a> +</span><span id="Snowflake.Generator-356"><a href="#Snowflake.Generator-356"><span class="linenos">356</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake.Generator-357"><a href="#Snowflake.Generator-357"><span class="linenos">357</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="Snowflake.Generator-358"><a href="#Snowflake.Generator-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">TIMESTAMP</span><span class="p">:</span> <span class="s2">"TIMESTAMPNTZ"</span><span class="p">,</span> +</span><span id="Snowflake.Generator-359"><a href="#Snowflake.Generator-359"><span class="linenos">359</span></a> <span class="p">}</span> +</span><span id="Snowflake.Generator-360"><a href="#Snowflake.Generator-360"><span class="linenos">360</span></a> +</span><span id="Snowflake.Generator-361"><a href="#Snowflake.Generator-361"><span class="linenos">361</span></a> <span class="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake.Generator-362"><a href="#Snowflake.Generator-362"><span class="linenos">362</span></a> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCLUDE"</span><span class="p">,</span> +</span><span id="Snowflake.Generator-363"><a href="#Snowflake.Generator-363"><span class="linenos">363</span></a> <span class="s2">"replace"</span><span class="p">:</span> <span class="s2">"RENAME"</span><span class="p">,</span> +</span><span id="Snowflake.Generator-364"><a href="#Snowflake.Generator-364"><span class="linenos">364</span></a> <span class="p">}</span> +</span><span id="Snowflake.Generator-365"><a href="#Snowflake.Generator-365"><span class="linenos">365</span></a> +</span><span id="Snowflake.Generator-366"><a href="#Snowflake.Generator-366"><span class="linenos">366</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Snowflake.Generator-367"><a href="#Snowflake.Generator-367"><span class="linenos">367</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">PROPERTIES_LOCATION</span><span class="p">,</span> +</span><span id="Snowflake.Generator-368"><a href="#Snowflake.Generator-368"><span class="linenos">368</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="Snowflake.Generator-369"><a href="#Snowflake.Generator-369"><span class="linenos">369</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">,</span> +</span><span id="Snowflake.Generator-370"><a href="#Snowflake.Generator-370"><span class="linenos">370</span></a> <span class="p">}</span> +</span><span id="Snowflake.Generator-371"><a href="#Snowflake.Generator-371"><span class="linenos">371</span></a> +</span><span id="Snowflake.Generator-372"><a href="#Snowflake.Generator-372"><span class="linenos">372</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Snowflake.Generator-373"><a href="#Snowflake.Generator-373"><span class="linenos">373</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> +</span><span id="Snowflake.Generator-374"><a href="#Snowflake.Generator-374"><span class="linenos">374</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"EXCEPT with All is not supported in Snowflake"</span><span class="p">)</span> +</span><span id="Snowflake.Generator-375"><a href="#Snowflake.Generator-375"><span class="linenos">375</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Snowflake.Generator-376"><a href="#Snowflake.Generator-376"><span class="linenos">376</span></a> +</span><span id="Snowflake.Generator-377"><a href="#Snowflake.Generator-377"><span class="linenos">377</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Snowflake.Generator-378"><a href="#Snowflake.Generator-378"><span class="linenos">378</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> +</span><span id="Snowflake.Generator-379"><a href="#Snowflake.Generator-379"><span class="linenos">379</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"INTERSECT with All is not supported in Snowflake"</span><span class="p">)</span> +</span><span id="Snowflake.Generator-380"><a href="#Snowflake.Generator-380"><span class="linenos">380</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Snowflake.Generator-381"><a href="#Snowflake.Generator-381"><span class="linenos">381</span></a> +</span><span id="Snowflake.Generator-382"><a href="#Snowflake.Generator-382"><span class="linenos">382</span></a> <span class="k">def</span> <span class="nf">settag_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetTag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Snowflake.Generator-383"><a href="#Snowflake.Generator-383"><span class="linenos">383</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"UNSET"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unset"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"SET"</span> +</span><span id="Snowflake.Generator-384"><a href="#Snowflake.Generator-384"><span class="linenos">384</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">action</span><span class="si">}</span><span class="s2"> TAG </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Snowflake.Generator-385"><a href="#Snowflake.Generator-385"><span class="linenos">385</span></a> +</span><span id="Snowflake.Generator-386"><a href="#Snowflake.Generator-386"><span class="linenos">386</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Snowflake.Generator-387"><a href="#Snowflake.Generator-387"><span class="linenos">387</span></a> <span class="c1"># Default to table if kind is unknown</span> +</span><span id="Snowflake.Generator-388"><a href="#Snowflake.Generator-388"><span class="linenos">388</span></a> <span class="n">kind_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"TABLE"</span> +</span><span id="Snowflake.Generator-389"><a href="#Snowflake.Generator-389"><span class="linenos">389</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind_value</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind_value</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Snowflake.Generator-390"><a href="#Snowflake.Generator-390"><span class="linenos">390</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Snowflake.Generator-391"><a href="#Snowflake.Generator-391"><span class="linenos">391</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Snowflake.Generator-392"><a href="#Snowflake.Generator-392"><span class="linenos">392</span></a> +</span><span id="Snowflake.Generator-393"><a href="#Snowflake.Generator-393"><span class="linenos">393</span></a> <span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> +</span><span id="Snowflake.Generator-394"><a href="#Snowflake.Generator-394"><span class="linenos">394</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> +</span><span id="Snowflake.Generator-395"><a href="#Snowflake.Generator-395"><span class="linenos">395</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Snowflake.Generator-396"><a href="#Snowflake.Generator-396"><span class="linenos">396</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"start"</span><span class="p">)</span> +</span><span id="Snowflake.Generator-397"><a href="#Snowflake.Generator-397"><span class="linenos">397</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" START </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Snowflake.Generator-398"><a href="#Snowflake.Generator-398"><span class="linenos">398</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"increment"</span><span class="p">)</span> +</span><span id="Snowflake.Generator-399"><a href="#Snowflake.Generator-399"><span class="linenos">399</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Snowflake.Generator-400"><a href="#Snowflake.Generator-400"><span class="linenos">400</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"AUTOINCREMENT</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -1090,10 +1101,10 @@ Default: True</li> </div> <a class="headerlink" href="#Snowflake.Generator.except_op"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Snowflake.Generator.except_op-370"><a href="#Snowflake.Generator.except_op-370"><span class="linenos">370</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Snowflake.Generator.except_op-371"><a href="#Snowflake.Generator.except_op-371"><span class="linenos">371</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> -</span><span id="Snowflake.Generator.except_op-372"><a href="#Snowflake.Generator.except_op-372"><span class="linenos">372</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"EXCEPT with All is not supported in Snowflake"</span><span class="p">)</span> -</span><span id="Snowflake.Generator.except_op-373"><a href="#Snowflake.Generator.except_op-373"><span class="linenos">373</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Snowflake.Generator.except_op-372"><a href="#Snowflake.Generator.except_op-372"><span class="linenos">372</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Snowflake.Generator.except_op-373"><a href="#Snowflake.Generator.except_op-373"><span class="linenos">373</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> +</span><span id="Snowflake.Generator.except_op-374"><a href="#Snowflake.Generator.except_op-374"><span class="linenos">374</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"EXCEPT with All is not supported in Snowflake"</span><span class="p">)</span> +</span><span id="Snowflake.Generator.except_op-375"><a href="#Snowflake.Generator.except_op-375"><span class="linenos">375</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -1111,10 +1122,10 @@ Default: True</li> </div> <a class="headerlink" href="#Snowflake.Generator.intersect_op"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Snowflake.Generator.intersect_op-375"><a href="#Snowflake.Generator.intersect_op-375"><span class="linenos">375</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Snowflake.Generator.intersect_op-376"><a href="#Snowflake.Generator.intersect_op-376"><span class="linenos">376</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> -</span><span id="Snowflake.Generator.intersect_op-377"><a href="#Snowflake.Generator.intersect_op-377"><span class="linenos">377</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"INTERSECT with All is not supported in Snowflake"</span><span class="p">)</span> -</span><span id="Snowflake.Generator.intersect_op-378"><a href="#Snowflake.Generator.intersect_op-378"><span class="linenos">378</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Snowflake.Generator.intersect_op-377"><a href="#Snowflake.Generator.intersect_op-377"><span class="linenos">377</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Snowflake.Generator.intersect_op-378"><a href="#Snowflake.Generator.intersect_op-378"><span class="linenos">378</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">"distinct"</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span> +</span><span id="Snowflake.Generator.intersect_op-379"><a href="#Snowflake.Generator.intersect_op-379"><span class="linenos">379</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"INTERSECT with All is not supported in Snowflake"</span><span class="p">)</span> +</span><span id="Snowflake.Generator.intersect_op-380"><a href="#Snowflake.Generator.intersect_op-380"><span class="linenos">380</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -1132,9 +1143,9 @@ Default: True</li> </div> <a class="headerlink" href="#Snowflake.Generator.settag_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Snowflake.Generator.settag_sql-380"><a href="#Snowflake.Generator.settag_sql-380"><span class="linenos">380</span></a> <span class="k">def</span> <span class="nf">settag_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetTag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Snowflake.Generator.settag_sql-381"><a href="#Snowflake.Generator.settag_sql-381"><span class="linenos">381</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"UNSET"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unset"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"SET"</span> -</span><span id="Snowflake.Generator.settag_sql-382"><a href="#Snowflake.Generator.settag_sql-382"><span class="linenos">382</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">action</span><span class="si">}</span><span class="s2"> TAG </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Snowflake.Generator.settag_sql-382"><a href="#Snowflake.Generator.settag_sql-382"><span class="linenos">382</span></a> <span class="k">def</span> <span class="nf">settag_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetTag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Snowflake.Generator.settag_sql-383"><a href="#Snowflake.Generator.settag_sql-383"><span class="linenos">383</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"UNSET"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unset"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"SET"</span> +</span><span id="Snowflake.Generator.settag_sql-384"><a href="#Snowflake.Generator.settag_sql-384"><span class="linenos">384</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">action</span><span class="si">}</span><span class="s2"> TAG </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -1152,12 +1163,12 @@ Default: True</li> </div> <a class="headerlink" href="#Snowflake.Generator.describe_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Snowflake.Generator.describe_sql-384"><a href="#Snowflake.Generator.describe_sql-384"><span class="linenos">384</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Snowflake.Generator.describe_sql-385"><a href="#Snowflake.Generator.describe_sql-385"><span class="linenos">385</span></a> <span class="c1"># Default to table if kind is unknown</span> -</span><span id="Snowflake.Generator.describe_sql-386"><a href="#Snowflake.Generator.describe_sql-386"><span class="linenos">386</span></a> <span class="n">kind_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"TABLE"</span> -</span><span id="Snowflake.Generator.describe_sql-387"><a href="#Snowflake.Generator.describe_sql-387"><span class="linenos">387</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind_value</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind_value</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Snowflake.Generator.describe_sql-388"><a href="#Snowflake.Generator.describe_sql-388"><span class="linenos">388</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Snowflake.Generator.describe_sql-389"><a href="#Snowflake.Generator.describe_sql-389"><span class="linenos">389</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Snowflake.Generator.describe_sql-386"><a href="#Snowflake.Generator.describe_sql-386"><span class="linenos">386</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Snowflake.Generator.describe_sql-387"><a href="#Snowflake.Generator.describe_sql-387"><span class="linenos">387</span></a> <span class="c1"># Default to table if kind is unknown</span> +</span><span id="Snowflake.Generator.describe_sql-388"><a href="#Snowflake.Generator.describe_sql-388"><span class="linenos">388</span></a> <span class="n">kind_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"TABLE"</span> +</span><span id="Snowflake.Generator.describe_sql-389"><a href="#Snowflake.Generator.describe_sql-389"><span class="linenos">389</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind_value</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind_value</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Snowflake.Generator.describe_sql-390"><a href="#Snowflake.Generator.describe_sql-390"><span class="linenos">390</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Snowflake.Generator.describe_sql-391"><a href="#Snowflake.Generator.describe_sql-391"><span class="linenos">391</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -1175,20 +1186,74 @@ Default: True</li> </div> <a class="headerlink" href="#Snowflake.Generator.generatedasidentitycolumnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Snowflake.Generator.generatedasidentitycolumnconstraint_sql-391"><a href="#Snowflake.Generator.generatedasidentitycolumnconstraint_sql-391"><span class="linenos">391</span></a> <span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> -</span><span id="Snowflake.Generator.generatedasidentitycolumnconstraint_sql-392"><a href="#Snowflake.Generator.generatedasidentitycolumnconstraint_sql-392"><span class="linenos">392</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> -</span><span id="Snowflake.Generator.generatedasidentitycolumnconstraint_sql-393"><a href="#Snowflake.Generator.generatedasidentitycolumnconstraint_sql-393"><span class="linenos">393</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Snowflake.Generator.generatedasidentitycolumnconstraint_sql-394"><a href="#Snowflake.Generator.generatedasidentitycolumnconstraint_sql-394"><span class="linenos">394</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"start"</span><span class="p">)</span> -</span><span id="Snowflake.Generator.generatedasidentitycolumnconstraint_sql-395"><a href="#Snowflake.Generator.generatedasidentitycolumnconstraint_sql-395"><span class="linenos">395</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" START </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Snowflake.Generator.generatedasidentitycolumnconstraint_sql-396"><a href="#Snowflake.Generator.generatedasidentitycolumnconstraint_sql-396"><span class="linenos">396</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"increment"</span><span class="p">)</span> -</span><span id="Snowflake.Generator.generatedasidentitycolumnconstraint_sql-397"><a href="#Snowflake.Generator.generatedasidentitycolumnconstraint_sql-397"><span class="linenos">397</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Snowflake.Generator.generatedasidentitycolumnconstraint_sql-398"><a href="#Snowflake.Generator.generatedasidentitycolumnconstraint_sql-398"><span class="linenos">398</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"AUTOINCREMENT</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Snowflake.Generator.generatedasidentitycolumnconstraint_sql-393"><a href="#Snowflake.Generator.generatedasidentitycolumnconstraint_sql-393"><span class="linenos">393</span></a> <span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> +</span><span id="Snowflake.Generator.generatedasidentitycolumnconstraint_sql-394"><a href="#Snowflake.Generator.generatedasidentitycolumnconstraint_sql-394"><span class="linenos">394</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> +</span><span id="Snowflake.Generator.generatedasidentitycolumnconstraint_sql-395"><a href="#Snowflake.Generator.generatedasidentitycolumnconstraint_sql-395"><span class="linenos">395</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Snowflake.Generator.generatedasidentitycolumnconstraint_sql-396"><a href="#Snowflake.Generator.generatedasidentitycolumnconstraint_sql-396"><span class="linenos">396</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"start"</span><span class="p">)</span> +</span><span id="Snowflake.Generator.generatedasidentitycolumnconstraint_sql-397"><a href="#Snowflake.Generator.generatedasidentitycolumnconstraint_sql-397"><span class="linenos">397</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" START </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Snowflake.Generator.generatedasidentitycolumnconstraint_sql-398"><a href="#Snowflake.Generator.generatedasidentitycolumnconstraint_sql-398"><span class="linenos">398</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"increment"</span><span class="p">)</span> +</span><span id="Snowflake.Generator.generatedasidentitycolumnconstraint_sql-399"><a href="#Snowflake.Generator.generatedasidentitycolumnconstraint_sql-399"><span class="linenos">399</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Snowflake.Generator.generatedasidentitycolumnconstraint_sql-400"><a href="#Snowflake.Generator.generatedasidentitycolumnconstraint_sql-400"><span class="linenos">400</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"AUTOINCREMENT</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> </div> + <div id="Snowflake.Generator.can_identify" class="classattr"> + <input id="Snowflake.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="Snowflake.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Snowflake.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Snowflake.Generator.can_identify-247"><a href="#Snowflake.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="Snowflake.Generator.can_identify-248"><a href="#Snowflake.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Snowflake.Generator.can_identify-249"><a href="#Snowflake.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="Snowflake.Generator.can_identify-250"><a href="#Snowflake.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="Snowflake.Generator.can_identify-251"><a href="#Snowflake.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="Snowflake.Generator.can_identify-252"><a href="#Snowflake.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="Snowflake.Generator.can_identify-253"><a href="#Snowflake.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="Snowflake.Generator.can_identify-254"><a href="#Snowflake.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="Snowflake.Generator.can_identify-255"><a href="#Snowflake.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="Snowflake.Generator.can_identify-256"><a href="#Snowflake.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="Snowflake.Generator.can_identify-257"><a href="#Snowflake.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="Snowflake.Generator.can_identify-258"><a href="#Snowflake.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="Snowflake.Generator.can_identify-259"><a href="#Snowflake.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="Snowflake.Generator.can_identify-260"><a href="#Snowflake.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="Snowflake.Generator.can_identify-261"><a href="#Snowflake.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Snowflake.Generator.can_identify-262"><a href="#Snowflake.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="Snowflake.Generator.can_identify-263"><a href="#Snowflake.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="Snowflake.Generator.can_identify-264"><a href="#Snowflake.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="Snowflake.Generator.can_identify-265"><a href="#Snowflake.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="Snowflake.Generator.can_identify-266"><a href="#Snowflake.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -1287,6 +1352,7 @@ Default: True</li> <dd id="Snowflake.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="Snowflake.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="Snowflake.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="Snowflake.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="Snowflake.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="Snowflake.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="Snowflake.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/dialects/spark.html b/docs/sqlglot/dialects/spark.html index 761a94b..fadd619 100644 --- a/docs/sqlglot/dialects/spark.html +++ b/docs/sqlglot/dialects/spark.html @@ -45,6 +45,9 @@ <li> <a class="function" href="#Spark.Generator.datediff_sql">datediff_sql</a> </li> + <li> + <a class="function" href="#Spark.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -179,6 +182,10 @@ <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="Spark.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="Spark.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="Spark.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="Spark.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="Spark.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="Spark.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="Spark.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="Spark.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="Spark.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -336,6 +343,60 @@ Default: True</li> </div> + <div id="Spark.Generator.can_identify" class="classattr"> + <input id="Spark.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="Spark.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Spark.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Spark.Generator.can_identify-247"><a href="#Spark.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="Spark.Generator.can_identify-248"><a href="#Spark.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Spark.Generator.can_identify-249"><a href="#Spark.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="Spark.Generator.can_identify-250"><a href="#Spark.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="Spark.Generator.can_identify-251"><a href="#Spark.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="Spark.Generator.can_identify-252"><a href="#Spark.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="Spark.Generator.can_identify-253"><a href="#Spark.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="Spark.Generator.can_identify-254"><a href="#Spark.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="Spark.Generator.can_identify-255"><a href="#Spark.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="Spark.Generator.can_identify-256"><a href="#Spark.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="Spark.Generator.can_identify-257"><a href="#Spark.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="Spark.Generator.can_identify-258"><a href="#Spark.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="Spark.Generator.can_identify-259"><a href="#Spark.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="Spark.Generator.can_identify-260"><a href="#Spark.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="Spark.Generator.can_identify-261"><a href="#Spark.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Spark.Generator.can_identify-262"><a href="#Spark.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="Spark.Generator.can_identify-263"><a href="#Spark.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="Spark.Generator.can_identify-264"><a href="#Spark.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="Spark.Generator.can_identify-265"><a href="#Spark.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="Spark.Generator.can_identify-266"><a href="#Spark.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -435,6 +496,7 @@ Default: True</li> <dd id="Spark.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="Spark.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="Spark.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="Spark.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="Spark.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="Spark.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="Spark.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/dialects/spark2.html b/docs/sqlglot/dialects/spark2.html index 5e87bc5..0a6a1e4 100644 --- a/docs/sqlglot/dialects/spark2.html +++ b/docs/sqlglot/dialects/spark2.html @@ -48,6 +48,9 @@ <li> <a class="function" href="#Spark2.Generator.columndef_sql">columndef_sql</a> </li> + <li> + <a class="function" href="#Spark2.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -509,6 +512,10 @@ <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="Spark2.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="Spark2.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="Spark2.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="Spark2.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="Spark2.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="Spark2.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="Spark2.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="Spark2.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="Spark2.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -814,6 +821,60 @@ Default: True</li> </div> + <div id="Spark2.Generator.can_identify" class="classattr"> + <input id="Spark2.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="Spark2.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Spark2.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Spark2.Generator.can_identify-247"><a href="#Spark2.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="Spark2.Generator.can_identify-248"><a href="#Spark2.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Spark2.Generator.can_identify-249"><a href="#Spark2.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="Spark2.Generator.can_identify-250"><a href="#Spark2.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="Spark2.Generator.can_identify-251"><a href="#Spark2.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="Spark2.Generator.can_identify-252"><a href="#Spark2.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="Spark2.Generator.can_identify-253"><a href="#Spark2.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="Spark2.Generator.can_identify-254"><a href="#Spark2.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="Spark2.Generator.can_identify-255"><a href="#Spark2.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="Spark2.Generator.can_identify-256"><a href="#Spark2.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="Spark2.Generator.can_identify-257"><a href="#Spark2.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="Spark2.Generator.can_identify-258"><a href="#Spark2.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="Spark2.Generator.can_identify-259"><a href="#Spark2.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="Spark2.Generator.can_identify-260"><a href="#Spark2.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="Spark2.Generator.can_identify-261"><a href="#Spark2.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Spark2.Generator.can_identify-262"><a href="#Spark2.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="Spark2.Generator.can_identify-263"><a href="#Spark2.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="Spark2.Generator.can_identify-264"><a href="#Spark2.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="Spark2.Generator.can_identify-265"><a href="#Spark2.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="Spark2.Generator.can_identify-266"><a href="#Spark2.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -913,6 +974,7 @@ Default: True</li> <dd id="Spark2.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="Spark2.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="Spark2.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="Spark2.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="Spark2.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="Spark2.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="Spark2.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/dialects/sqlite.html b/docs/sqlglot/dialects/sqlite.html index 353cc6d..95628bd 100644 --- a/docs/sqlglot/dialects/sqlite.html +++ b/docs/sqlglot/dialects/sqlite.html @@ -63,6 +63,9 @@ <li> <a class="function" href="#SQLite.Generator.transaction_sql">transaction_sql</a> </li> + <li> + <a class="function" href="#SQLite.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -153,139 +156,142 @@ </span><span id="L-59"><a href="#L-59"><span class="linenos"> 59</span></a> </span><span id="L-60"><a href="#L-60"><span class="linenos"> 60</span></a> </span><span id="L-61"><a href="#L-61"><span class="linenos"> 61</span></a><span class="k">class</span> <span class="nc">SQLite</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> -</span><span id="L-62"><a href="#L-62"><span class="linenos"> 62</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-63"><a href="#L-63"><span class="linenos"> 63</span></a> <span class="n">IDENTIFIERS</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'"'</span><span class="p">,</span> <span class="p">(</span><span class="s2">"["</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-64"><a href="#L-64"><span class="linenos"> 64</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"x'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"X'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"0x"</span><span class="p">,</span> <span class="s2">""</span><span class="p">),</span> <span class="p">(</span><span class="s2">"0X"</span><span class="p">,</span> <span class="s2">""</span><span class="p">)]</span> -</span><span id="L-65"><a href="#L-65"><span class="linenos"> 65</span></a> -</span><span id="L-66"><a href="#L-66"><span class="linenos"> 66</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-67"><a href="#L-67"><span class="linenos"> 67</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-68"><a href="#L-68"><span class="linenos"> 68</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-69"><a href="#L-69"><span class="linenos"> 69</span></a> <span class="s2">"EDITDIST3"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="L-70"><a href="#L-70"><span class="linenos"> 70</span></a> <span class="p">}</span> -</span><span id="L-71"><a href="#L-71"><span class="linenos"> 71</span></a> -</span><span id="L-72"><a href="#L-72"><span class="linenos"> 72</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-73"><a href="#L-73"><span class="linenos"> 73</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-74"><a href="#L-74"><span class="linenos"> 74</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-75"><a href="#L-75"><span class="linenos"> 75</span></a> -</span><span id="L-76"><a href="#L-76"><span class="linenos"> 76</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-77"><a href="#L-77"><span class="linenos"> 77</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-78"><a href="#L-78"><span class="linenos"> 78</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">BOOLEAN</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="L-79"><a href="#L-79"><span class="linenos"> 79</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">TINYINT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="L-80"><a href="#L-80"><span class="linenos"> 80</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">SMALLINT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="L-81"><a href="#L-81"><span class="linenos"> 81</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">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="L-82"><a href="#L-82"><span class="linenos"> 82</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">BIGINT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="L-83"><a href="#L-83"><span class="linenos"> 83</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-84"><a href="#L-84"><span class="linenos"> 84</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">DOUBLE</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> -</span><span id="L-85"><a href="#L-85"><span class="linenos"> 85</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="s2">"REAL"</span><span class="p">,</span> -</span><span id="L-86"><a href="#L-86"><span class="linenos"> 86</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-87"><a href="#L-87"><span class="linenos"> 87</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-88"><a href="#L-88"><span class="linenos"> 88</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-89"><a href="#L-89"><span class="linenos"> 89</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-90"><a href="#L-90"><span class="linenos"> 90</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-91"><a href="#L-91"><span class="linenos"> 91</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-92"><a href="#L-92"><span class="linenos"> 92</span></a> <span class="p">}</span> -</span><span id="L-93"><a href="#L-93"><span class="linenos"> 93</span></a> -</span><span id="L-94"><a href="#L-94"><span class="linenos"> 94</span></a> <span class="n">TOKEN_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-95"><a href="#L-95"><span class="linenos"> 95</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">:</span> <span class="s2">"AUTOINCREMENT"</span><span class="p">,</span> -</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> <span class="p">}</span> -</span><span id="L-97"><a href="#L-97"><span class="linenos"> 97</span></a> -</span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</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-100"><a href="#L-100"><span class="linenos">100</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> -</span><span id="L-101"><a href="#L-101"><span class="linenos">101</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CountIf</span><span class="p">:</span> <span class="n">count_if_to_sum</span><span class="p">,</span> -</span><span id="L-102"><a href="#L-102"><span class="linenos">102</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</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">_transform_create</span><span class="p">]),</span> -</span><span id="L-103"><a href="#L-103"><span class="linenos">103</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-104"><a href="#L-104"><span class="linenos">104</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-105"><a href="#L-105"><span class="linenos">105</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-106"><a href="#L-106"><span class="linenos">106</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">,</span> -</span><span id="L-107"><a href="#L-107"><span class="linenos">107</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</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-108"><a href="#L-108"><span class="linenos">108</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> -</span><span id="L-109"><a href="#L-109"><span class="linenos">109</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-110"><a href="#L-110"><span class="linenos">110</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_scalar_sql</span><span class="p">,</span> -</span><span id="L-111"><a href="#L-111"><span class="linenos">111</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtract</span><span class="p">:</span> <span class="n">arrow_json_extract_sql</span><span class="p">,</span> -</span><span id="L-112"><a href="#L-112"><span class="linenos">112</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtractScalar</span><span class="p">:</span> <span class="n">arrow_json_extract_scalar_sql</span><span class="p">,</span> -</span><span id="L-113"><a href="#L-113"><span class="linenos">113</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"EDITDIST3"</span><span class="p">),</span> -</span><span id="L-114"><a href="#L-114"><span class="linenos">114</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">"MAX"</span><span class="p">),</span> -</span><span id="L-115"><a href="#L-115"><span class="linenos">115</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">"MIN"</span><span class="p">),</span> -</span><span id="L-116"><a href="#L-116"><span class="linenos">116</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">no_pivot_sql</span><span class="p">,</span> -</span><span id="L-117"><a href="#L-117"><span class="linenos">117</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> -</span><span id="L-118"><a href="#L-118"><span class="linenos">118</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="L-119"><a href="#L-119"><span class="linenos">119</span></a> <span class="p">[</span><span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">]</span> -</span><span id="L-120"><a href="#L-120"><span class="linenos">120</span></a> <span class="p">),</span> -</span><span id="L-121"><a href="#L-121"><span class="linenos">121</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">:</span> <span class="n">no_tablesample_sql</span><span class="p">,</span> -</span><span id="L-122"><a href="#L-122"><span class="linenos">122</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</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-123"><a href="#L-123"><span class="linenos">123</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">:</span> <span class="n">no_trycast_sql</span><span class="p">,</span> -</span><span id="L-124"><a href="#L-124"><span class="linenos">124</span></a> <span class="p">}</span> -</span><span id="L-125"><a href="#L-125"><span class="linenos">125</span></a> -</span><span id="L-126"><a href="#L-126"><span class="linenos">126</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a> <span class="n">k</span><span class="p">:</span> <span class="n">exp</span><span 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-128"><a href="#L-128"><span class="linenos">128</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</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 class="o">.</span><span class="n">items</span><span class="p">()</span> -</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a> <span class="p">}</span> -</span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a> -</span><span id="L-131"><a href="#L-131"><span class="linenos">131</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> -</span><span id="L-132"><a href="#L-132"><span class="linenos">132</span></a> -</span><span id="L-133"><a href="#L-133"><span class="linenos">133</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-134"><a href="#L-134"><span class="linenos">134</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">"date"</span><span class="p">):</span> -</span><span id="L-135"><a href="#L-135"><span class="linenos">135</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">"DATE"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-136"><a href="#L-136"><span class="linenos">136</span></a> -</span><span id="L-137"><a href="#L-137"><span class="linenos">137</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-138"><a href="#L-138"><span class="linenos">138</span></a> -</span><span id="L-139"><a href="#L-139"><span class="linenos">139</span></a> <span class="k">def</span> <span class="nf">datediff_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-140"><a href="#L-140"><span class="linenos">140</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> -</span><span id="L-141"><a href="#L-141"><span class="linenos">141</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">unit</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="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">"DAY"</span> -</span><span id="L-142"><a href="#L-142"><span class="linenos">142</span></a> -</span><span id="L-143"><a href="#L-143"><span class="linenos">143</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(JULIANDAY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) - JULIANDAY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span> -</span><span id="L-144"><a href="#L-144"><span class="linenos">144</span></a> -</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> <span class="k">if</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MONTH"</span><span class="p">:</span> -</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> / 30.0"</span> -</span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"YEAR"</span><span class="p">:</span> -</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> / 365.0"</span> -</span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"HOUR"</span><span class="p">:</span> -</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 24.0"</span> -</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MINUTE"</span><span class="p">:</span> -</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 1440.0"</span> -</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"SECOND"</span><span class="p">:</span> -</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400.0"</span> -</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MILLISECOND"</span><span class="p">:</span> -</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400000.0"</span> -</span><span id="L-157"><a href="#L-157"><span class="linenos">157</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MICROSECOND"</span><span class="p">:</span> -</span><span id="L-158"><a href="#L-158"><span class="linenos">158</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400000000.0"</span> -</span><span id="L-159"><a href="#L-159"><span class="linenos">159</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"NANOSECOND"</span><span class="p">:</span> -</span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 8640000000000.0"</span> -</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"DATEDIFF unsupported for '</span><span class="si">{unit}</span><span class="s2">'."</span><span class="p">)</span> -</span><span id="L-163"><a href="#L-163"><span class="linenos">163</span></a> -</span><span id="L-164"><a href="#L-164"><span class="linenos">164</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> AS INTEGER)"</span> -</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> -</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a> <span class="c1"># https://www.sqlite.org/lang_aggfunc.html#group_concat</span> -</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a> <span class="k">def</span> <span class="nf">groupconcat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-168"><a href="#L-168"><span class="linenos">168</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-169"><a href="#L-169"><span class="linenos">169</span></a> <span class="n">distinct</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">Distinct</span><span class="p">)</span> -</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> -</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="k">if</span> <span class="n">distinct</span><span class="p">:</span> -</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">distinct</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="n">distinct_sql</span> <span class="o">=</span> <span class="s2">"DISTINCT "</span> -</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="n">distinct_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> -</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">):</span> -</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"SQLite GROUP_CONCAT doesn't support ORDER BY."</span><span class="p">)</span> -</span><span id="L-179"><a href="#L-179"><span class="linenos">179</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">distinct</span><span class="p">:</span> -</span><span id="L-180"><a href="#L-180"><span class="linenos">180</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-181"><a href="#L-181"><span class="linenos">181</span></a> -</span><span id="L-182"><a href="#L-182"><span class="linenos">182</span></a> <span class="n">separator</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"separator"</span><span class="p">)</span> -</span><span id="L-183"><a href="#L-183"><span class="linenos">183</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GROUP_CONCAT(</span><span class="si">{</span><span class="n">distinct_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">separator</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-62"><a href="#L-62"><span class="linenos"> 62</span></a> <span class="c1"># https://sqlite.org/forum/forumpost/5e575586ac5c711b?raw</span> +</span><span id="L-63"><a href="#L-63"><span class="linenos"> 63</span></a> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-64"><a href="#L-64"><span class="linenos"> 64</span></a> +</span><span id="L-65"><a href="#L-65"><span class="linenos"> 65</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-66"><a href="#L-66"><span class="linenos"> 66</span></a> <span class="n">IDENTIFIERS</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'"'</span><span class="p">,</span> <span class="p">(</span><span class="s2">"["</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-67"><a href="#L-67"><span class="linenos"> 67</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"x'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"X'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"0x"</span><span class="p">,</span> <span class="s2">""</span><span class="p">),</span> <span class="p">(</span><span class="s2">"0X"</span><span class="p">,</span> <span class="s2">""</span><span class="p">)]</span> +</span><span id="L-68"><a href="#L-68"><span class="linenos"> 68</span></a> +</span><span id="L-69"><a href="#L-69"><span class="linenos"> 69</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-70"><a href="#L-70"><span class="linenos"> 70</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-71"><a href="#L-71"><span class="linenos"> 71</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-72"><a href="#L-72"><span class="linenos"> 72</span></a> <span class="s2">"EDITDIST3"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="L-73"><a href="#L-73"><span class="linenos"> 73</span></a> <span class="p">}</span> +</span><span id="L-74"><a href="#L-74"><span class="linenos"> 74</span></a> +</span><span id="L-75"><a href="#L-75"><span class="linenos"> 75</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-76"><a href="#L-76"><span class="linenos"> 76</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-77"><a href="#L-77"><span class="linenos"> 77</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-78"><a href="#L-78"><span class="linenos"> 78</span></a> +</span><span id="L-79"><a href="#L-79"><span class="linenos"> 79</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-80"><a href="#L-80"><span class="linenos"> 80</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-81"><a href="#L-81"><span class="linenos"> 81</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">BOOLEAN</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="L-82"><a href="#L-82"><span class="linenos"> 82</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">TINYINT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="L-83"><a href="#L-83"><span class="linenos"> 83</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">SMALLINT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="L-84"><a href="#L-84"><span class="linenos"> 84</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">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="L-85"><a href="#L-85"><span class="linenos"> 85</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">BIGINT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="L-86"><a href="#L-86"><span class="linenos"> 86</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-87"><a href="#L-87"><span class="linenos"> 87</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">DOUBLE</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> +</span><span id="L-88"><a href="#L-88"><span class="linenos"> 88</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="s2">"REAL"</span><span class="p">,</span> +</span><span id="L-89"><a href="#L-89"><span class="linenos"> 89</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-90"><a href="#L-90"><span class="linenos"> 90</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-91"><a href="#L-91"><span class="linenos"> 91</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-92"><a href="#L-92"><span class="linenos"> 92</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-93"><a href="#L-93"><span class="linenos"> 93</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-94"><a href="#L-94"><span class="linenos"> 94</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-95"><a href="#L-95"><span class="linenos"> 95</span></a> <span class="p">}</span> +</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> +</span><span id="L-97"><a href="#L-97"><span class="linenos"> 97</span></a> <span class="n">TOKEN_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">:</span> <span class="s2">"AUTOINCREMENT"</span><span class="p">,</span> +</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a> <span class="p">}</span> +</span><span id="L-100"><a href="#L-100"><span class="linenos">100</span></a> +</span><span id="L-101"><a href="#L-101"><span class="linenos">101</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-102"><a href="#L-102"><span class="linenos">102</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-103"><a href="#L-103"><span class="linenos">103</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> +</span><span id="L-104"><a href="#L-104"><span class="linenos">104</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CountIf</span><span class="p">:</span> <span class="n">count_if_to_sum</span><span class="p">,</span> +</span><span id="L-105"><a href="#L-105"><span class="linenos">105</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</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">_transform_create</span><span class="p">]),</span> +</span><span id="L-106"><a href="#L-106"><span class="linenos">106</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-107"><a href="#L-107"><span class="linenos">107</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-108"><a href="#L-108"><span class="linenos">108</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-109"><a href="#L-109"><span class="linenos">109</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">,</span> +</span><span id="L-110"><a href="#L-110"><span class="linenos">110</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</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-111"><a href="#L-111"><span class="linenos">111</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> +</span><span id="L-112"><a href="#L-112"><span class="linenos">112</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-113"><a href="#L-113"><span class="linenos">113</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_scalar_sql</span><span class="p">,</span> +</span><span id="L-114"><a href="#L-114"><span class="linenos">114</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtract</span><span class="p">:</span> <span class="n">arrow_json_extract_sql</span><span class="p">,</span> +</span><span id="L-115"><a href="#L-115"><span class="linenos">115</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtractScalar</span><span class="p">:</span> <span class="n">arrow_json_extract_scalar_sql</span><span class="p">,</span> +</span><span id="L-116"><a href="#L-116"><span class="linenos">116</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"EDITDIST3"</span><span class="p">),</span> +</span><span id="L-117"><a href="#L-117"><span class="linenos">117</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">"MAX"</span><span class="p">),</span> +</span><span id="L-118"><a href="#L-118"><span class="linenos">118</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">"MIN"</span><span class="p">),</span> +</span><span id="L-119"><a href="#L-119"><span class="linenos">119</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">no_pivot_sql</span><span class="p">,</span> +</span><span id="L-120"><a href="#L-120"><span class="linenos">120</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> +</span><span id="L-121"><a href="#L-121"><span class="linenos">121</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="L-122"><a href="#L-122"><span class="linenos">122</span></a> <span class="p">[</span><span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">]</span> +</span><span id="L-123"><a href="#L-123"><span class="linenos">123</span></a> <span class="p">),</span> +</span><span id="L-124"><a href="#L-124"><span class="linenos">124</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">:</span> <span class="n">no_tablesample_sql</span><span class="p">,</span> +</span><span id="L-125"><a href="#L-125"><span class="linenos">125</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</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-126"><a href="#L-126"><span class="linenos">126</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">:</span> <span class="n">no_trycast_sql</span><span class="p">,</span> +</span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a> <span class="p">}</span> +</span><span id="L-128"><a href="#L-128"><span class="linenos">128</span></a> +</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a> <span class="n">k</span><span class="p">:</span> <span class="n">exp</span><span 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-131"><a href="#L-131"><span class="linenos">131</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</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 class="o">.</span><span class="n">items</span><span class="p">()</span> +</span><span id="L-132"><a href="#L-132"><span class="linenos">132</span></a> <span class="p">}</span> +</span><span id="L-133"><a href="#L-133"><span class="linenos">133</span></a> +</span><span id="L-134"><a href="#L-134"><span class="linenos">134</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> +</span><span id="L-135"><a href="#L-135"><span class="linenos">135</span></a> +</span><span id="L-136"><a href="#L-136"><span class="linenos">136</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-137"><a href="#L-137"><span class="linenos">137</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">"date"</span><span class="p">):</span> +</span><span id="L-138"><a href="#L-138"><span class="linenos">138</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">"DATE"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-139"><a href="#L-139"><span class="linenos">139</span></a> +</span><span id="L-140"><a href="#L-140"><span class="linenos">140</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-141"><a href="#L-141"><span class="linenos">141</span></a> +</span><span id="L-142"><a href="#L-142"><span class="linenos">142</span></a> <span class="k">def</span> <span class="nf">datediff_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-143"><a href="#L-143"><span class="linenos">143</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> +</span><span id="L-144"><a href="#L-144"><span class="linenos">144</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">unit</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="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">"DAY"</span> +</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> +</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(JULIANDAY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) - JULIANDAY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span> +</span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a> +</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a> <span class="k">if</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MONTH"</span><span class="p">:</span> +</span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> / 30.0"</span> +</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"YEAR"</span><span class="p">:</span> +</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> / 365.0"</span> +</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"HOUR"</span><span class="p">:</span> +</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 24.0"</span> +</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MINUTE"</span><span class="p">:</span> +</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 1440.0"</span> +</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"SECOND"</span><span class="p">:</span> +</span><span id="L-157"><a href="#L-157"><span class="linenos">157</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400.0"</span> +</span><span id="L-158"><a href="#L-158"><span class="linenos">158</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MILLISECOND"</span><span class="p">:</span> +</span><span id="L-159"><a href="#L-159"><span class="linenos">159</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400000.0"</span> +</span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MICROSECOND"</span><span class="p">:</span> +</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400000000.0"</span> +</span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"NANOSECOND"</span><span class="p">:</span> +</span><span id="L-163"><a href="#L-163"><span class="linenos">163</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 8640000000000.0"</span> +</span><span id="L-164"><a href="#L-164"><span class="linenos">164</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"DATEDIFF unsupported for '</span><span class="si">{unit}</span><span class="s2">'."</span><span class="p">)</span> +</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a> +</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> AS INTEGER)"</span> +</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a> +</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a> <span class="c1"># https://www.sqlite.org/lang_aggfunc.html#group_concat</span> +</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="k">def</span> <span class="nf">groupconcat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-171"><a href="#L-171"><span class="linenos">171</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-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="n">distinct</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">Distinct</span><span class="p">)</span> +</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> +</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="k">if</span> <span class="n">distinct</span><span class="p">:</span> +</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">distinct</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> <span class="n">distinct_sql</span> <span class="o">=</span> <span class="s2">"DISTINCT "</span> +</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> <span class="n">distinct_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-179"><a href="#L-179"><span class="linenos">179</span></a> +</span><span id="L-180"><a href="#L-180"><span class="linenos">180</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">):</span> +</span><span id="L-181"><a href="#L-181"><span class="linenos">181</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"SQLite GROUP_CONCAT doesn't support ORDER BY."</span><span class="p">)</span> +</span><span id="L-182"><a href="#L-182"><span class="linenos">182</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">distinct</span><span class="p">:</span> +</span><span id="L-183"><a href="#L-183"><span class="linenos">183</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> </span><span id="L-184"><a href="#L-184"><span class="linenos">184</span></a> -</span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> <span class="k">def</span> <span class="nf">least_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Least</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-187"><a href="#L-187"><span class="linenos">187</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN"</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-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">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-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 class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-192"><a href="#L-192"><span class="linenos">192</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-193"><a href="#L-193"><span class="linenos">193</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-194"><a href="#L-194"><span class="linenos">194</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BEGIN</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> TRANSACTION"</span> +</span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> <span class="n">separator</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"separator"</span><span class="p">)</span> +</span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GROUP_CONCAT(</span><span class="si">{</span><span class="n">distinct_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">separator</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</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 class="k">def</span> <span class="nf">least_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Least</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-189"><a href="#L-189"><span class="linenos">189</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-190"><a href="#L-190"><span class="linenos">190</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN"</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><span id="L-192"><a href="#L-192"><span class="linenos">192</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-193"><a href="#L-193"><span class="linenos">193</span></a> +</span><span id="L-194"><a href="#L-194"><span class="linenos">194</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-195"><a href="#L-195"><span class="linenos">195</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-196"><a href="#L-196"><span class="linenos">196</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-197"><a href="#L-197"><span class="linenos">197</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BEGIN</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> TRANSACTION"</span> </span></pre></div> @@ -302,139 +308,142 @@ </div> <a class="headerlink" href="#SQLite"></a> <div class="pdoc-code codehilite"><pre><span></span><span id="SQLite-62"><a href="#SQLite-62"><span class="linenos"> 62</span></a><span class="k">class</span> <span class="nc">SQLite</span><span class="p">(</span><span class="n">Dialect</span><span class="p">):</span> -</span><span id="SQLite-63"><a href="#SQLite-63"><span class="linenos"> 63</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="SQLite-64"><a href="#SQLite-64"><span class="linenos"> 64</span></a> <span class="n">IDENTIFIERS</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'"'</span><span class="p">,</span> <span class="p">(</span><span class="s2">"["</span><span class="p">,</span> <span class="s2">"]"</span><span class="p">),</span> <span class="s2">"`"</span><span class="p">]</span> -</span><span id="SQLite-65"><a href="#SQLite-65"><span class="linenos"> 65</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"x'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"X'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"0x"</span><span class="p">,</span> <span class="s2">""</span><span class="p">),</span> <span class="p">(</span><span class="s2">"0X"</span><span class="p">,</span> <span class="s2">""</span><span class="p">)]</span> -</span><span id="SQLite-66"><a href="#SQLite-66"><span class="linenos"> 66</span></a> -</span><span id="SQLite-67"><a href="#SQLite-67"><span class="linenos"> 67</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="SQLite-68"><a href="#SQLite-68"><span class="linenos"> 68</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="SQLite-69"><a href="#SQLite-69"><span class="linenos"> 69</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="SQLite-70"><a href="#SQLite-70"><span class="linenos"> 70</span></a> <span class="s2">"EDITDIST3"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="SQLite-71"><a href="#SQLite-71"><span class="linenos"> 71</span></a> <span class="p">}</span> -</span><span id="SQLite-72"><a href="#SQLite-72"><span class="linenos"> 72</span></a> -</span><span id="SQLite-73"><a href="#SQLite-73"><span class="linenos"> 73</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="SQLite-74"><a href="#SQLite-74"><span class="linenos"> 74</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="SQLite-75"><a href="#SQLite-75"><span class="linenos"> 75</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="SQLite-76"><a href="#SQLite-76"><span class="linenos"> 76</span></a> -</span><span id="SQLite-77"><a href="#SQLite-77"><span class="linenos"> 77</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="SQLite-78"><a href="#SQLite-78"><span class="linenos"> 78</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="SQLite-79"><a href="#SQLite-79"><span class="linenos"> 79</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">BOOLEAN</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="SQLite-80"><a href="#SQLite-80"><span class="linenos"> 80</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">TINYINT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="SQLite-81"><a href="#SQLite-81"><span class="linenos"> 81</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">SMALLINT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="SQLite-82"><a href="#SQLite-82"><span class="linenos"> 82</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">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="SQLite-83"><a href="#SQLite-83"><span class="linenos"> 83</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">BIGINT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="SQLite-84"><a href="#SQLite-84"><span class="linenos"> 84</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="SQLite-85"><a href="#SQLite-85"><span class="linenos"> 85</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">DOUBLE</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> -</span><span id="SQLite-86"><a href="#SQLite-86"><span class="linenos"> 86</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="s2">"REAL"</span><span class="p">,</span> -</span><span id="SQLite-87"><a href="#SQLite-87"><span class="linenos"> 87</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="SQLite-88"><a href="#SQLite-88"><span class="linenos"> 88</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="SQLite-89"><a href="#SQLite-89"><span class="linenos"> 89</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="SQLite-90"><a href="#SQLite-90"><span class="linenos"> 90</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="SQLite-91"><a href="#SQLite-91"><span class="linenos"> 91</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="SQLite-92"><a href="#SQLite-92"><span class="linenos"> 92</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="SQLite-93"><a href="#SQLite-93"><span class="linenos"> 93</span></a> <span class="p">}</span> -</span><span id="SQLite-94"><a href="#SQLite-94"><span class="linenos"> 94</span></a> -</span><span id="SQLite-95"><a href="#SQLite-95"><span class="linenos"> 95</span></a> <span class="n">TOKEN_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="SQLite-96"><a href="#SQLite-96"><span class="linenos"> 96</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">:</span> <span class="s2">"AUTOINCREMENT"</span><span class="p">,</span> -</span><span id="SQLite-97"><a href="#SQLite-97"><span class="linenos"> 97</span></a> <span class="p">}</span> -</span><span id="SQLite-98"><a href="#SQLite-98"><span class="linenos"> 98</span></a> -</span><span id="SQLite-99"><a href="#SQLite-99"><span class="linenos"> 99</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="SQLite-100"><a href="#SQLite-100"><span class="linenos">100</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="SQLite-101"><a href="#SQLite-101"><span class="linenos">101</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> -</span><span id="SQLite-102"><a href="#SQLite-102"><span class="linenos">102</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CountIf</span><span class="p">:</span> <span class="n">count_if_to_sum</span><span class="p">,</span> -</span><span id="SQLite-103"><a href="#SQLite-103"><span class="linenos">103</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</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">_transform_create</span><span class="p">]),</span> -</span><span id="SQLite-104"><a href="#SQLite-104"><span class="linenos">104</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="SQLite-105"><a href="#SQLite-105"><span class="linenos">105</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="SQLite-106"><a href="#SQLite-106"><span class="linenos">106</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="SQLite-107"><a href="#SQLite-107"><span class="linenos">107</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">,</span> -</span><span id="SQLite-108"><a href="#SQLite-108"><span class="linenos">108</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</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="SQLite-109"><a href="#SQLite-109"><span class="linenos">109</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> -</span><span id="SQLite-110"><a href="#SQLite-110"><span class="linenos">110</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="SQLite-111"><a href="#SQLite-111"><span class="linenos">111</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_scalar_sql</span><span class="p">,</span> -</span><span id="SQLite-112"><a href="#SQLite-112"><span class="linenos">112</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtract</span><span class="p">:</span> <span class="n">arrow_json_extract_sql</span><span class="p">,</span> -</span><span id="SQLite-113"><a href="#SQLite-113"><span class="linenos">113</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtractScalar</span><span class="p">:</span> <span class="n">arrow_json_extract_scalar_sql</span><span class="p">,</span> -</span><span id="SQLite-114"><a href="#SQLite-114"><span class="linenos">114</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"EDITDIST3"</span><span class="p">),</span> -</span><span id="SQLite-115"><a href="#SQLite-115"><span class="linenos">115</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">"MAX"</span><span class="p">),</span> -</span><span id="SQLite-116"><a href="#SQLite-116"><span class="linenos">116</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">"MIN"</span><span class="p">),</span> -</span><span id="SQLite-117"><a href="#SQLite-117"><span class="linenos">117</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">no_pivot_sql</span><span class="p">,</span> -</span><span id="SQLite-118"><a href="#SQLite-118"><span class="linenos">118</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> -</span><span id="SQLite-119"><a href="#SQLite-119"><span class="linenos">119</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="SQLite-120"><a href="#SQLite-120"><span class="linenos">120</span></a> <span class="p">[</span><span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">]</span> -</span><span id="SQLite-121"><a href="#SQLite-121"><span class="linenos">121</span></a> <span class="p">),</span> -</span><span id="SQLite-122"><a href="#SQLite-122"><span class="linenos">122</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">:</span> <span class="n">no_tablesample_sql</span><span class="p">,</span> -</span><span id="SQLite-123"><a href="#SQLite-123"><span class="linenos">123</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</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="SQLite-124"><a href="#SQLite-124"><span class="linenos">124</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">:</span> <span class="n">no_trycast_sql</span><span class="p">,</span> -</span><span id="SQLite-125"><a href="#SQLite-125"><span class="linenos">125</span></a> <span class="p">}</span> -</span><span id="SQLite-126"><a href="#SQLite-126"><span class="linenos">126</span></a> -</span><span id="SQLite-127"><a href="#SQLite-127"><span class="linenos">127</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="SQLite-128"><a href="#SQLite-128"><span class="linenos">128</span></a> <span class="n">k</span><span class="p">:</span> <span class="n">exp</span><span 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="SQLite-129"><a href="#SQLite-129"><span class="linenos">129</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</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 class="o">.</span><span class="n">items</span><span class="p">()</span> -</span><span id="SQLite-130"><a href="#SQLite-130"><span class="linenos">130</span></a> <span class="p">}</span> -</span><span id="SQLite-131"><a href="#SQLite-131"><span class="linenos">131</span></a> -</span><span id="SQLite-132"><a href="#SQLite-132"><span class="linenos">132</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> -</span><span id="SQLite-133"><a href="#SQLite-133"><span class="linenos">133</span></a> -</span><span id="SQLite-134"><a href="#SQLite-134"><span class="linenos">134</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="SQLite-135"><a href="#SQLite-135"><span class="linenos">135</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">"date"</span><span class="p">):</span> -</span><span id="SQLite-136"><a href="#SQLite-136"><span class="linenos">136</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">"DATE"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="SQLite-137"><a href="#SQLite-137"><span class="linenos">137</span></a> -</span><span id="SQLite-138"><a href="#SQLite-138"><span class="linenos">138</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="SQLite-139"><a href="#SQLite-139"><span class="linenos">139</span></a> -</span><span id="SQLite-140"><a href="#SQLite-140"><span class="linenos">140</span></a> <span class="k">def</span> <span class="nf">datediff_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="SQLite-141"><a href="#SQLite-141"><span class="linenos">141</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> -</span><span id="SQLite-142"><a href="#SQLite-142"><span class="linenos">142</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">unit</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="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">"DAY"</span> -</span><span id="SQLite-143"><a href="#SQLite-143"><span class="linenos">143</span></a> -</span><span id="SQLite-144"><a href="#SQLite-144"><span class="linenos">144</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(JULIANDAY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) - JULIANDAY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span> -</span><span id="SQLite-145"><a href="#SQLite-145"><span class="linenos">145</span></a> -</span><span id="SQLite-146"><a href="#SQLite-146"><span class="linenos">146</span></a> <span class="k">if</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MONTH"</span><span class="p">:</span> -</span><span id="SQLite-147"><a href="#SQLite-147"><span class="linenos">147</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> / 30.0"</span> -</span><span id="SQLite-148"><a href="#SQLite-148"><span class="linenos">148</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"YEAR"</span><span class="p">:</span> -</span><span id="SQLite-149"><a href="#SQLite-149"><span class="linenos">149</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> / 365.0"</span> -</span><span id="SQLite-150"><a href="#SQLite-150"><span class="linenos">150</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"HOUR"</span><span class="p">:</span> -</span><span id="SQLite-151"><a href="#SQLite-151"><span class="linenos">151</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 24.0"</span> -</span><span id="SQLite-152"><a href="#SQLite-152"><span class="linenos">152</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MINUTE"</span><span class="p">:</span> -</span><span id="SQLite-153"><a href="#SQLite-153"><span class="linenos">153</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 1440.0"</span> -</span><span id="SQLite-154"><a href="#SQLite-154"><span class="linenos">154</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"SECOND"</span><span class="p">:</span> -</span><span id="SQLite-155"><a href="#SQLite-155"><span class="linenos">155</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400.0"</span> -</span><span id="SQLite-156"><a href="#SQLite-156"><span class="linenos">156</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MILLISECOND"</span><span class="p">:</span> -</span><span id="SQLite-157"><a href="#SQLite-157"><span class="linenos">157</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400000.0"</span> -</span><span id="SQLite-158"><a href="#SQLite-158"><span class="linenos">158</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MICROSECOND"</span><span class="p">:</span> -</span><span id="SQLite-159"><a href="#SQLite-159"><span class="linenos">159</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400000000.0"</span> -</span><span id="SQLite-160"><a href="#SQLite-160"><span class="linenos">160</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"NANOSECOND"</span><span class="p">:</span> -</span><span id="SQLite-161"><a href="#SQLite-161"><span class="linenos">161</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 8640000000000.0"</span> -</span><span id="SQLite-162"><a href="#SQLite-162"><span class="linenos">162</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="SQLite-163"><a href="#SQLite-163"><span class="linenos">163</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"DATEDIFF unsupported for '</span><span class="si">{unit}</span><span class="s2">'."</span><span class="p">)</span> -</span><span id="SQLite-164"><a href="#SQLite-164"><span class="linenos">164</span></a> -</span><span id="SQLite-165"><a href="#SQLite-165"><span class="linenos">165</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> AS INTEGER)"</span> -</span><span id="SQLite-166"><a href="#SQLite-166"><span class="linenos">166</span></a> -</span><span id="SQLite-167"><a href="#SQLite-167"><span class="linenos">167</span></a> <span class="c1"># https://www.sqlite.org/lang_aggfunc.html#group_concat</span> -</span><span id="SQLite-168"><a href="#SQLite-168"><span class="linenos">168</span></a> <span class="k">def</span> <span class="nf">groupconcat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="SQLite-169"><a href="#SQLite-169"><span class="linenos">169</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="SQLite-170"><a href="#SQLite-170"><span class="linenos">170</span></a> <span class="n">distinct</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">Distinct</span><span class="p">)</span> -</span><span id="SQLite-171"><a href="#SQLite-171"><span class="linenos">171</span></a> -</span><span id="SQLite-172"><a href="#SQLite-172"><span class="linenos">172</span></a> <span class="k">if</span> <span class="n">distinct</span><span class="p">:</span> -</span><span id="SQLite-173"><a href="#SQLite-173"><span class="linenos">173</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">distinct</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="SQLite-174"><a href="#SQLite-174"><span class="linenos">174</span></a> <span class="n">distinct_sql</span> <span class="o">=</span> <span class="s2">"DISTINCT "</span> -</span><span id="SQLite-175"><a href="#SQLite-175"><span class="linenos">175</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="SQLite-176"><a href="#SQLite-176"><span class="linenos">176</span></a> <span class="n">distinct_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="SQLite-177"><a href="#SQLite-177"><span class="linenos">177</span></a> -</span><span id="SQLite-178"><a href="#SQLite-178"><span class="linenos">178</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">):</span> -</span><span id="SQLite-179"><a href="#SQLite-179"><span class="linenos">179</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"SQLite GROUP_CONCAT doesn't support ORDER BY."</span><span class="p">)</span> -</span><span id="SQLite-180"><a href="#SQLite-180"><span class="linenos">180</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">distinct</span><span class="p">:</span> -</span><span id="SQLite-181"><a href="#SQLite-181"><span class="linenos">181</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> -</span><span id="SQLite-182"><a href="#SQLite-182"><span class="linenos">182</span></a> -</span><span id="SQLite-183"><a href="#SQLite-183"><span class="linenos">183</span></a> <span class="n">separator</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"separator"</span><span class="p">)</span> -</span><span id="SQLite-184"><a href="#SQLite-184"><span class="linenos">184</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GROUP_CONCAT(</span><span class="si">{</span><span class="n">distinct_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">separator</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="SQLite-63"><a href="#SQLite-63"><span class="linenos"> 63</span></a> <span class="c1"># https://sqlite.org/forum/forumpost/5e575586ac5c711b?raw</span> +</span><span id="SQLite-64"><a href="#SQLite-64"><span class="linenos"> 64</span></a> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="SQLite-65"><a href="#SQLite-65"><span class="linenos"> 65</span></a> +</span><span id="SQLite-66"><a href="#SQLite-66"><span class="linenos"> 66</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="SQLite-67"><a href="#SQLite-67"><span class="linenos"> 67</span></a> <span class="n">IDENTIFIERS</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'"'</span><span class="p">,</span> <span class="p">(</span><span class="s2">"["</span><span class="p">,</span> <span class="s2">"]"</span><span class="p">),</span> <span class="s2">"`"</span><span class="p">]</span> +</span><span id="SQLite-68"><a href="#SQLite-68"><span class="linenos"> 68</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"x'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"X'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"0x"</span><span class="p">,</span> <span class="s2">""</span><span class="p">),</span> <span class="p">(</span><span class="s2">"0X"</span><span class="p">,</span> <span class="s2">""</span><span class="p">)]</span> +</span><span id="SQLite-69"><a href="#SQLite-69"><span class="linenos"> 69</span></a> +</span><span id="SQLite-70"><a href="#SQLite-70"><span class="linenos"> 70</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="SQLite-71"><a href="#SQLite-71"><span class="linenos"> 71</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="SQLite-72"><a href="#SQLite-72"><span class="linenos"> 72</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="SQLite-73"><a href="#SQLite-73"><span class="linenos"> 73</span></a> <span class="s2">"EDITDIST3"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="SQLite-74"><a href="#SQLite-74"><span class="linenos"> 74</span></a> <span class="p">}</span> +</span><span id="SQLite-75"><a href="#SQLite-75"><span class="linenos"> 75</span></a> +</span><span id="SQLite-76"><a href="#SQLite-76"><span class="linenos"> 76</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="SQLite-77"><a href="#SQLite-77"><span class="linenos"> 77</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="SQLite-78"><a href="#SQLite-78"><span class="linenos"> 78</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="SQLite-79"><a href="#SQLite-79"><span class="linenos"> 79</span></a> +</span><span id="SQLite-80"><a href="#SQLite-80"><span class="linenos"> 80</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="SQLite-81"><a href="#SQLite-81"><span class="linenos"> 81</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="SQLite-82"><a href="#SQLite-82"><span class="linenos"> 82</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">BOOLEAN</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="SQLite-83"><a href="#SQLite-83"><span class="linenos"> 83</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">TINYINT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="SQLite-84"><a href="#SQLite-84"><span class="linenos"> 84</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">SMALLINT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="SQLite-85"><a href="#SQLite-85"><span class="linenos"> 85</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">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="SQLite-86"><a href="#SQLite-86"><span class="linenos"> 86</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">BIGINT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="SQLite-87"><a href="#SQLite-87"><span class="linenos"> 87</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="SQLite-88"><a href="#SQLite-88"><span class="linenos"> 88</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">DOUBLE</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> +</span><span id="SQLite-89"><a href="#SQLite-89"><span class="linenos"> 89</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="s2">"REAL"</span><span class="p">,</span> +</span><span id="SQLite-90"><a href="#SQLite-90"><span class="linenos"> 90</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="SQLite-91"><a href="#SQLite-91"><span class="linenos"> 91</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="SQLite-92"><a href="#SQLite-92"><span class="linenos"> 92</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="SQLite-93"><a href="#SQLite-93"><span class="linenos"> 93</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="SQLite-94"><a href="#SQLite-94"><span class="linenos"> 94</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="SQLite-95"><a href="#SQLite-95"><span class="linenos"> 95</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="SQLite-96"><a href="#SQLite-96"><span class="linenos"> 96</span></a> <span class="p">}</span> +</span><span id="SQLite-97"><a href="#SQLite-97"><span class="linenos"> 97</span></a> +</span><span id="SQLite-98"><a href="#SQLite-98"><span class="linenos"> 98</span></a> <span class="n">TOKEN_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="SQLite-99"><a href="#SQLite-99"><span class="linenos"> 99</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">:</span> <span class="s2">"AUTOINCREMENT"</span><span class="p">,</span> +</span><span id="SQLite-100"><a href="#SQLite-100"><span class="linenos">100</span></a> <span class="p">}</span> +</span><span id="SQLite-101"><a href="#SQLite-101"><span class="linenos">101</span></a> +</span><span id="SQLite-102"><a href="#SQLite-102"><span class="linenos">102</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="SQLite-103"><a href="#SQLite-103"><span class="linenos">103</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="SQLite-104"><a href="#SQLite-104"><span class="linenos">104</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> +</span><span id="SQLite-105"><a href="#SQLite-105"><span class="linenos">105</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CountIf</span><span class="p">:</span> <span class="n">count_if_to_sum</span><span class="p">,</span> +</span><span id="SQLite-106"><a href="#SQLite-106"><span class="linenos">106</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</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">_transform_create</span><span class="p">]),</span> +</span><span id="SQLite-107"><a href="#SQLite-107"><span class="linenos">107</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="SQLite-108"><a href="#SQLite-108"><span class="linenos">108</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="SQLite-109"><a href="#SQLite-109"><span class="linenos">109</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="SQLite-110"><a href="#SQLite-110"><span class="linenos">110</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">,</span> +</span><span id="SQLite-111"><a href="#SQLite-111"><span class="linenos">111</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</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="SQLite-112"><a href="#SQLite-112"><span class="linenos">112</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> +</span><span id="SQLite-113"><a href="#SQLite-113"><span class="linenos">113</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="SQLite-114"><a href="#SQLite-114"><span class="linenos">114</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_scalar_sql</span><span class="p">,</span> +</span><span id="SQLite-115"><a href="#SQLite-115"><span class="linenos">115</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtract</span><span class="p">:</span> <span class="n">arrow_json_extract_sql</span><span class="p">,</span> +</span><span id="SQLite-116"><a href="#SQLite-116"><span class="linenos">116</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtractScalar</span><span class="p">:</span> <span class="n">arrow_json_extract_scalar_sql</span><span class="p">,</span> +</span><span id="SQLite-117"><a href="#SQLite-117"><span class="linenos">117</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"EDITDIST3"</span><span class="p">),</span> +</span><span id="SQLite-118"><a href="#SQLite-118"><span class="linenos">118</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">"MAX"</span><span class="p">),</span> +</span><span id="SQLite-119"><a href="#SQLite-119"><span class="linenos">119</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">"MIN"</span><span class="p">),</span> +</span><span id="SQLite-120"><a href="#SQLite-120"><span class="linenos">120</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">no_pivot_sql</span><span class="p">,</span> +</span><span id="SQLite-121"><a href="#SQLite-121"><span class="linenos">121</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> +</span><span id="SQLite-122"><a href="#SQLite-122"><span class="linenos">122</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="SQLite-123"><a href="#SQLite-123"><span class="linenos">123</span></a> <span class="p">[</span><span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">]</span> +</span><span id="SQLite-124"><a href="#SQLite-124"><span class="linenos">124</span></a> <span class="p">),</span> +</span><span id="SQLite-125"><a href="#SQLite-125"><span class="linenos">125</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">:</span> <span class="n">no_tablesample_sql</span><span class="p">,</span> +</span><span id="SQLite-126"><a href="#SQLite-126"><span class="linenos">126</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</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="SQLite-127"><a href="#SQLite-127"><span class="linenos">127</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">:</span> <span class="n">no_trycast_sql</span><span class="p">,</span> +</span><span id="SQLite-128"><a href="#SQLite-128"><span class="linenos">128</span></a> <span class="p">}</span> +</span><span id="SQLite-129"><a href="#SQLite-129"><span class="linenos">129</span></a> +</span><span id="SQLite-130"><a href="#SQLite-130"><span class="linenos">130</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="SQLite-131"><a href="#SQLite-131"><span class="linenos">131</span></a> <span class="n">k</span><span class="p">:</span> <span class="n">exp</span><span 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="SQLite-132"><a href="#SQLite-132"><span class="linenos">132</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</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 class="o">.</span><span class="n">items</span><span class="p">()</span> +</span><span id="SQLite-133"><a href="#SQLite-133"><span class="linenos">133</span></a> <span class="p">}</span> +</span><span id="SQLite-134"><a href="#SQLite-134"><span class="linenos">134</span></a> +</span><span id="SQLite-135"><a href="#SQLite-135"><span class="linenos">135</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> +</span><span id="SQLite-136"><a href="#SQLite-136"><span class="linenos">136</span></a> +</span><span id="SQLite-137"><a href="#SQLite-137"><span class="linenos">137</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="SQLite-138"><a href="#SQLite-138"><span class="linenos">138</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">"date"</span><span class="p">):</span> +</span><span id="SQLite-139"><a href="#SQLite-139"><span class="linenos">139</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">"DATE"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="SQLite-140"><a href="#SQLite-140"><span class="linenos">140</span></a> +</span><span id="SQLite-141"><a href="#SQLite-141"><span class="linenos">141</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="SQLite-142"><a href="#SQLite-142"><span class="linenos">142</span></a> +</span><span id="SQLite-143"><a href="#SQLite-143"><span class="linenos">143</span></a> <span class="k">def</span> <span class="nf">datediff_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="SQLite-144"><a href="#SQLite-144"><span class="linenos">144</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> +</span><span id="SQLite-145"><a href="#SQLite-145"><span class="linenos">145</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">unit</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="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">"DAY"</span> +</span><span id="SQLite-146"><a href="#SQLite-146"><span class="linenos">146</span></a> +</span><span id="SQLite-147"><a href="#SQLite-147"><span class="linenos">147</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(JULIANDAY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) - JULIANDAY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span> +</span><span id="SQLite-148"><a href="#SQLite-148"><span class="linenos">148</span></a> +</span><span id="SQLite-149"><a href="#SQLite-149"><span class="linenos">149</span></a> <span class="k">if</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MONTH"</span><span class="p">:</span> +</span><span id="SQLite-150"><a href="#SQLite-150"><span class="linenos">150</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> / 30.0"</span> +</span><span id="SQLite-151"><a href="#SQLite-151"><span class="linenos">151</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"YEAR"</span><span class="p">:</span> +</span><span id="SQLite-152"><a href="#SQLite-152"><span class="linenos">152</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> / 365.0"</span> +</span><span id="SQLite-153"><a href="#SQLite-153"><span class="linenos">153</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"HOUR"</span><span class="p">:</span> +</span><span id="SQLite-154"><a href="#SQLite-154"><span class="linenos">154</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 24.0"</span> +</span><span id="SQLite-155"><a href="#SQLite-155"><span class="linenos">155</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MINUTE"</span><span class="p">:</span> +</span><span id="SQLite-156"><a href="#SQLite-156"><span class="linenos">156</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 1440.0"</span> +</span><span id="SQLite-157"><a href="#SQLite-157"><span class="linenos">157</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"SECOND"</span><span class="p">:</span> +</span><span id="SQLite-158"><a href="#SQLite-158"><span class="linenos">158</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400.0"</span> +</span><span id="SQLite-159"><a href="#SQLite-159"><span class="linenos">159</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MILLISECOND"</span><span class="p">:</span> +</span><span id="SQLite-160"><a href="#SQLite-160"><span class="linenos">160</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400000.0"</span> +</span><span id="SQLite-161"><a href="#SQLite-161"><span class="linenos">161</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MICROSECOND"</span><span class="p">:</span> +</span><span id="SQLite-162"><a href="#SQLite-162"><span class="linenos">162</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400000000.0"</span> +</span><span id="SQLite-163"><a href="#SQLite-163"><span class="linenos">163</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"NANOSECOND"</span><span class="p">:</span> +</span><span id="SQLite-164"><a href="#SQLite-164"><span class="linenos">164</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 8640000000000.0"</span> +</span><span id="SQLite-165"><a href="#SQLite-165"><span class="linenos">165</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="SQLite-166"><a href="#SQLite-166"><span class="linenos">166</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"DATEDIFF unsupported for '</span><span class="si">{unit}</span><span class="s2">'."</span><span class="p">)</span> +</span><span id="SQLite-167"><a href="#SQLite-167"><span class="linenos">167</span></a> +</span><span id="SQLite-168"><a href="#SQLite-168"><span class="linenos">168</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> AS INTEGER)"</span> +</span><span id="SQLite-169"><a href="#SQLite-169"><span class="linenos">169</span></a> +</span><span id="SQLite-170"><a href="#SQLite-170"><span class="linenos">170</span></a> <span class="c1"># https://www.sqlite.org/lang_aggfunc.html#group_concat</span> +</span><span id="SQLite-171"><a href="#SQLite-171"><span class="linenos">171</span></a> <span class="k">def</span> <span class="nf">groupconcat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="SQLite-172"><a href="#SQLite-172"><span class="linenos">172</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="SQLite-173"><a href="#SQLite-173"><span class="linenos">173</span></a> <span class="n">distinct</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">Distinct</span><span class="p">)</span> +</span><span id="SQLite-174"><a href="#SQLite-174"><span class="linenos">174</span></a> +</span><span id="SQLite-175"><a href="#SQLite-175"><span class="linenos">175</span></a> <span class="k">if</span> <span class="n">distinct</span><span class="p">:</span> +</span><span id="SQLite-176"><a href="#SQLite-176"><span class="linenos">176</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">distinct</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="SQLite-177"><a href="#SQLite-177"><span class="linenos">177</span></a> <span class="n">distinct_sql</span> <span class="o">=</span> <span class="s2">"DISTINCT "</span> +</span><span id="SQLite-178"><a href="#SQLite-178"><span class="linenos">178</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="SQLite-179"><a href="#SQLite-179"><span class="linenos">179</span></a> <span class="n">distinct_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="SQLite-180"><a href="#SQLite-180"><span class="linenos">180</span></a> +</span><span id="SQLite-181"><a href="#SQLite-181"><span class="linenos">181</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">):</span> +</span><span id="SQLite-182"><a href="#SQLite-182"><span class="linenos">182</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"SQLite GROUP_CONCAT doesn't support ORDER BY."</span><span class="p">)</span> +</span><span id="SQLite-183"><a href="#SQLite-183"><span class="linenos">183</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">distinct</span><span class="p">:</span> +</span><span id="SQLite-184"><a href="#SQLite-184"><span class="linenos">184</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> </span><span id="SQLite-185"><a href="#SQLite-185"><span class="linenos">185</span></a> -</span><span id="SQLite-186"><a href="#SQLite-186"><span class="linenos">186</span></a> <span class="k">def</span> <span class="nf">least_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Least</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="SQLite-187"><a href="#SQLite-187"><span class="linenos">187</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="SQLite-188"><a href="#SQLite-188"><span class="linenos">188</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN"</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="SQLite-189"><a href="#SQLite-189"><span class="linenos">189</span></a> -</span><span id="SQLite-190"><a href="#SQLite-190"><span class="linenos">190</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="SQLite-191"><a href="#SQLite-191"><span class="linenos">191</span></a> -</span><span id="SQLite-192"><a href="#SQLite-192"><span class="linenos">192</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="SQLite-193"><a href="#SQLite-193"><span class="linenos">193</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="SQLite-194"><a href="#SQLite-194"><span class="linenos">194</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="SQLite-195"><a href="#SQLite-195"><span class="linenos">195</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BEGIN</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> TRANSACTION"</span> +</span><span id="SQLite-186"><a href="#SQLite-186"><span class="linenos">186</span></a> <span class="n">separator</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"separator"</span><span class="p">)</span> +</span><span id="SQLite-187"><a href="#SQLite-187"><span class="linenos">187</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GROUP_CONCAT(</span><span class="si">{</span><span class="n">distinct_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">separator</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="SQLite-188"><a href="#SQLite-188"><span class="linenos">188</span></a> +</span><span id="SQLite-189"><a href="#SQLite-189"><span class="linenos">189</span></a> <span class="k">def</span> <span class="nf">least_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Least</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="SQLite-190"><a href="#SQLite-190"><span class="linenos">190</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="SQLite-191"><a href="#SQLite-191"><span class="linenos">191</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN"</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="SQLite-192"><a href="#SQLite-192"><span class="linenos">192</span></a> +</span><span id="SQLite-193"><a href="#SQLite-193"><span class="linenos">193</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="SQLite-194"><a href="#SQLite-194"><span class="linenos">194</span></a> +</span><span id="SQLite-195"><a href="#SQLite-195"><span class="linenos">195</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="SQLite-196"><a href="#SQLite-196"><span class="linenos">196</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="SQLite-197"><a href="#SQLite-197"><span class="linenos">197</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="SQLite-198"><a href="#SQLite-198"><span class="linenos">198</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BEGIN</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> TRANSACTION"</span> </span></pre></div> @@ -446,6 +455,10 @@ <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="SQLite.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="SQLite.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="SQLite.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="SQLite.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="SQLite.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="SQLite.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="SQLite.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="SQLite.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="SQLite.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -469,9 +482,9 @@ </div> <a class="headerlink" href="#SQLite.Tokenizer"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SQLite.Tokenizer-63"><a href="#SQLite.Tokenizer-63"><span class="linenos">63</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="SQLite.Tokenizer-64"><a href="#SQLite.Tokenizer-64"><span class="linenos">64</span></a> <span class="n">IDENTIFIERS</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'"'</span><span class="p">,</span> <span class="p">(</span><span class="s2">"["</span><span class="p">,</span> <span class="s2">"]"</span><span class="p">),</span> <span class="s2">"`"</span><span class="p">]</span> -</span><span id="SQLite.Tokenizer-65"><a href="#SQLite.Tokenizer-65"><span class="linenos">65</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"x'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"X'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"0x"</span><span class="p">,</span> <span class="s2">""</span><span class="p">),</span> <span class="p">(</span><span class="s2">"0X"</span><span class="p">,</span> <span class="s2">""</span><span class="p">)]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SQLite.Tokenizer-66"><a href="#SQLite.Tokenizer-66"><span class="linenos">66</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="SQLite.Tokenizer-67"><a href="#SQLite.Tokenizer-67"><span class="linenos">67</span></a> <span class="n">IDENTIFIERS</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'"'</span><span class="p">,</span> <span class="p">(</span><span class="s2">"["</span><span class="p">,</span> <span class="s2">"]"</span><span class="p">),</span> <span class="s2">"`"</span><span class="p">]</span> +</span><span id="SQLite.Tokenizer-68"><a href="#SQLite.Tokenizer-68"><span class="linenos">68</span></a> <span class="n">HEX_STRINGS</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"x'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"X'"</span><span class="p">,</span> <span class="s2">"'"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"0x"</span><span class="p">,</span> <span class="s2">""</span><span class="p">),</span> <span class="p">(</span><span class="s2">"0X"</span><span class="p">,</span> <span class="s2">""</span><span class="p">)]</span> </span></pre></div> @@ -500,11 +513,11 @@ </div> <a class="headerlink" href="#SQLite.Parser"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SQLite.Parser-67"><a href="#SQLite.Parser-67"><span class="linenos">67</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="SQLite.Parser-68"><a href="#SQLite.Parser-68"><span class="linenos">68</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="SQLite.Parser-69"><a href="#SQLite.Parser-69"><span class="linenos">69</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="SQLite.Parser-70"><a href="#SQLite.Parser-70"><span class="linenos">70</span></a> <span class="s2">"EDITDIST3"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> -</span><span id="SQLite.Parser-71"><a href="#SQLite.Parser-71"><span class="linenos">71</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SQLite.Parser-70"><a href="#SQLite.Parser-70"><span class="linenos">70</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="SQLite.Parser-71"><a href="#SQLite.Parser-71"><span class="linenos">71</span></a> <span class="n">FUNCTIONS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="SQLite.Parser-72"><a href="#SQLite.Parser-72"><span class="linenos">72</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="SQLite.Parser-73"><a href="#SQLite.Parser-73"><span class="linenos">73</span></a> <span class="s2">"EDITDIST3"</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">,</span> +</span><span id="SQLite.Parser-74"><a href="#SQLite.Parser-74"><span class="linenos">74</span></a> <span class="p">}</span> </span></pre></div> @@ -553,129 +566,129 @@ Default: 3</li> </div> <a class="headerlink" href="#SQLite.Generator"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SQLite.Generator-73"><a href="#SQLite.Generator-73"><span class="linenos"> 73</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="SQLite.Generator-74"><a href="#SQLite.Generator-74"><span class="linenos"> 74</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="SQLite.Generator-75"><a href="#SQLite.Generator-75"><span class="linenos"> 75</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="SQLite.Generator-76"><a href="#SQLite.Generator-76"><span class="linenos"> 76</span></a> -</span><span id="SQLite.Generator-77"><a href="#SQLite.Generator-77"><span class="linenos"> 77</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="SQLite.Generator-78"><a href="#SQLite.Generator-78"><span class="linenos"> 78</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="SQLite.Generator-79"><a href="#SQLite.Generator-79"><span class="linenos"> 79</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">BOOLEAN</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="SQLite.Generator-80"><a href="#SQLite.Generator-80"><span class="linenos"> 80</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">TINYINT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="SQLite.Generator-81"><a href="#SQLite.Generator-81"><span class="linenos"> 81</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">SMALLINT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="SQLite.Generator-82"><a href="#SQLite.Generator-82"><span class="linenos"> 82</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">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="SQLite.Generator-83"><a href="#SQLite.Generator-83"><span class="linenos"> 83</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">BIGINT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> -</span><span id="SQLite.Generator-84"><a href="#SQLite.Generator-84"><span class="linenos"> 84</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="SQLite.Generator-85"><a href="#SQLite.Generator-85"><span class="linenos"> 85</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">DOUBLE</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> -</span><span id="SQLite.Generator-86"><a href="#SQLite.Generator-86"><span class="linenos"> 86</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="s2">"REAL"</span><span class="p">,</span> -</span><span id="SQLite.Generator-87"><a href="#SQLite.Generator-87"><span class="linenos"> 87</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="SQLite.Generator-88"><a href="#SQLite.Generator-88"><span class="linenos"> 88</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="SQLite.Generator-89"><a href="#SQLite.Generator-89"><span class="linenos"> 89</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="SQLite.Generator-90"><a href="#SQLite.Generator-90"><span class="linenos"> 90</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="SQLite.Generator-91"><a href="#SQLite.Generator-91"><span class="linenos"> 91</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="SQLite.Generator-92"><a href="#SQLite.Generator-92"><span class="linenos"> 92</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="SQLite.Generator-93"><a href="#SQLite.Generator-93"><span class="linenos"> 93</span></a> <span class="p">}</span> -</span><span id="SQLite.Generator-94"><a href="#SQLite.Generator-94"><span class="linenos"> 94</span></a> -</span><span id="SQLite.Generator-95"><a href="#SQLite.Generator-95"><span class="linenos"> 95</span></a> <span class="n">TOKEN_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="SQLite.Generator-96"><a href="#SQLite.Generator-96"><span class="linenos"> 96</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">:</span> <span class="s2">"AUTOINCREMENT"</span><span class="p">,</span> -</span><span id="SQLite.Generator-97"><a href="#SQLite.Generator-97"><span class="linenos"> 97</span></a> <span class="p">}</span> -</span><span id="SQLite.Generator-98"><a href="#SQLite.Generator-98"><span class="linenos"> 98</span></a> -</span><span id="SQLite.Generator-99"><a href="#SQLite.Generator-99"><span class="linenos"> 99</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="SQLite.Generator-100"><a href="#SQLite.Generator-100"><span class="linenos">100</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="SQLite.Generator-101"><a href="#SQLite.Generator-101"><span class="linenos">101</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> -</span><span id="SQLite.Generator-102"><a href="#SQLite.Generator-102"><span class="linenos">102</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CountIf</span><span class="p">:</span> <span class="n">count_if_to_sum</span><span class="p">,</span> -</span><span id="SQLite.Generator-103"><a href="#SQLite.Generator-103"><span class="linenos">103</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</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">_transform_create</span><span class="p">]),</span> -</span><span id="SQLite.Generator-104"><a href="#SQLite.Generator-104"><span class="linenos">104</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="SQLite.Generator-105"><a href="#SQLite.Generator-105"><span class="linenos">105</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="SQLite.Generator-106"><a href="#SQLite.Generator-106"><span class="linenos">106</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="SQLite.Generator-107"><a href="#SQLite.Generator-107"><span class="linenos">107</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">,</span> -</span><span id="SQLite.Generator-108"><a href="#SQLite.Generator-108"><span class="linenos">108</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</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="SQLite.Generator-109"><a href="#SQLite.Generator-109"><span class="linenos">109</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> -</span><span id="SQLite.Generator-110"><a href="#SQLite.Generator-110"><span class="linenos">110</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="SQLite.Generator-111"><a href="#SQLite.Generator-111"><span class="linenos">111</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_scalar_sql</span><span class="p">,</span> -</span><span id="SQLite.Generator-112"><a href="#SQLite.Generator-112"><span class="linenos">112</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtract</span><span class="p">:</span> <span class="n">arrow_json_extract_sql</span><span class="p">,</span> -</span><span id="SQLite.Generator-113"><a href="#SQLite.Generator-113"><span class="linenos">113</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtractScalar</span><span class="p">:</span> <span class="n">arrow_json_extract_scalar_sql</span><span class="p">,</span> -</span><span id="SQLite.Generator-114"><a href="#SQLite.Generator-114"><span class="linenos">114</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"EDITDIST3"</span><span class="p">),</span> -</span><span id="SQLite.Generator-115"><a href="#SQLite.Generator-115"><span class="linenos">115</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">"MAX"</span><span class="p">),</span> -</span><span id="SQLite.Generator-116"><a href="#SQLite.Generator-116"><span class="linenos">116</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">"MIN"</span><span class="p">),</span> -</span><span id="SQLite.Generator-117"><a href="#SQLite.Generator-117"><span class="linenos">117</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">no_pivot_sql</span><span class="p">,</span> -</span><span id="SQLite.Generator-118"><a href="#SQLite.Generator-118"><span class="linenos">118</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> -</span><span id="SQLite.Generator-119"><a href="#SQLite.Generator-119"><span class="linenos">119</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> -</span><span id="SQLite.Generator-120"><a href="#SQLite.Generator-120"><span class="linenos">120</span></a> <span class="p">[</span><span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">]</span> -</span><span id="SQLite.Generator-121"><a href="#SQLite.Generator-121"><span class="linenos">121</span></a> <span class="p">),</span> -</span><span id="SQLite.Generator-122"><a href="#SQLite.Generator-122"><span class="linenos">122</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">:</span> <span class="n">no_tablesample_sql</span><span class="p">,</span> -</span><span id="SQLite.Generator-123"><a href="#SQLite.Generator-123"><span class="linenos">123</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</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="SQLite.Generator-124"><a href="#SQLite.Generator-124"><span class="linenos">124</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">:</span> <span class="n">no_trycast_sql</span><span class="p">,</span> -</span><span id="SQLite.Generator-125"><a href="#SQLite.Generator-125"><span class="linenos">125</span></a> <span class="p">}</span> -</span><span id="SQLite.Generator-126"><a href="#SQLite.Generator-126"><span class="linenos">126</span></a> -</span><span id="SQLite.Generator-127"><a href="#SQLite.Generator-127"><span class="linenos">127</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="SQLite.Generator-128"><a href="#SQLite.Generator-128"><span class="linenos">128</span></a> <span class="n">k</span><span class="p">:</span> <span class="n">exp</span><span 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="SQLite.Generator-129"><a href="#SQLite.Generator-129"><span class="linenos">129</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</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 class="o">.</span><span class="n">items</span><span class="p">()</span> -</span><span id="SQLite.Generator-130"><a href="#SQLite.Generator-130"><span class="linenos">130</span></a> <span class="p">}</span> -</span><span id="SQLite.Generator-131"><a href="#SQLite.Generator-131"><span class="linenos">131</span></a> -</span><span id="SQLite.Generator-132"><a href="#SQLite.Generator-132"><span class="linenos">132</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> -</span><span id="SQLite.Generator-133"><a href="#SQLite.Generator-133"><span class="linenos">133</span></a> -</span><span id="SQLite.Generator-134"><a href="#SQLite.Generator-134"><span class="linenos">134</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="SQLite.Generator-135"><a href="#SQLite.Generator-135"><span class="linenos">135</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">"date"</span><span class="p">):</span> -</span><span id="SQLite.Generator-136"><a href="#SQLite.Generator-136"><span class="linenos">136</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">"DATE"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="SQLite.Generator-137"><a href="#SQLite.Generator-137"><span class="linenos">137</span></a> -</span><span id="SQLite.Generator-138"><a href="#SQLite.Generator-138"><span class="linenos">138</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="SQLite.Generator-139"><a href="#SQLite.Generator-139"><span class="linenos">139</span></a> -</span><span id="SQLite.Generator-140"><a href="#SQLite.Generator-140"><span class="linenos">140</span></a> <span class="k">def</span> <span class="nf">datediff_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="SQLite.Generator-141"><a href="#SQLite.Generator-141"><span class="linenos">141</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> -</span><span id="SQLite.Generator-142"><a href="#SQLite.Generator-142"><span class="linenos">142</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">unit</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="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">"DAY"</span> -</span><span id="SQLite.Generator-143"><a href="#SQLite.Generator-143"><span class="linenos">143</span></a> -</span><span id="SQLite.Generator-144"><a href="#SQLite.Generator-144"><span class="linenos">144</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(JULIANDAY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) - JULIANDAY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span> -</span><span id="SQLite.Generator-145"><a href="#SQLite.Generator-145"><span class="linenos">145</span></a> -</span><span id="SQLite.Generator-146"><a href="#SQLite.Generator-146"><span class="linenos">146</span></a> <span class="k">if</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MONTH"</span><span class="p">:</span> -</span><span id="SQLite.Generator-147"><a href="#SQLite.Generator-147"><span class="linenos">147</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> / 30.0"</span> -</span><span id="SQLite.Generator-148"><a href="#SQLite.Generator-148"><span class="linenos">148</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"YEAR"</span><span class="p">:</span> -</span><span id="SQLite.Generator-149"><a href="#SQLite.Generator-149"><span class="linenos">149</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> / 365.0"</span> -</span><span id="SQLite.Generator-150"><a href="#SQLite.Generator-150"><span class="linenos">150</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"HOUR"</span><span class="p">:</span> -</span><span id="SQLite.Generator-151"><a href="#SQLite.Generator-151"><span class="linenos">151</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 24.0"</span> -</span><span id="SQLite.Generator-152"><a href="#SQLite.Generator-152"><span class="linenos">152</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MINUTE"</span><span class="p">:</span> -</span><span id="SQLite.Generator-153"><a href="#SQLite.Generator-153"><span class="linenos">153</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 1440.0"</span> -</span><span id="SQLite.Generator-154"><a href="#SQLite.Generator-154"><span class="linenos">154</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"SECOND"</span><span class="p">:</span> -</span><span id="SQLite.Generator-155"><a href="#SQLite.Generator-155"><span class="linenos">155</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400.0"</span> -</span><span id="SQLite.Generator-156"><a href="#SQLite.Generator-156"><span class="linenos">156</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MILLISECOND"</span><span class="p">:</span> -</span><span id="SQLite.Generator-157"><a href="#SQLite.Generator-157"><span class="linenos">157</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400000.0"</span> -</span><span id="SQLite.Generator-158"><a href="#SQLite.Generator-158"><span class="linenos">158</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MICROSECOND"</span><span class="p">:</span> -</span><span id="SQLite.Generator-159"><a href="#SQLite.Generator-159"><span class="linenos">159</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400000000.0"</span> -</span><span id="SQLite.Generator-160"><a href="#SQLite.Generator-160"><span class="linenos">160</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"NANOSECOND"</span><span class="p">:</span> -</span><span id="SQLite.Generator-161"><a href="#SQLite.Generator-161"><span class="linenos">161</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 8640000000000.0"</span> -</span><span id="SQLite.Generator-162"><a href="#SQLite.Generator-162"><span class="linenos">162</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="SQLite.Generator-163"><a href="#SQLite.Generator-163"><span class="linenos">163</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"DATEDIFF unsupported for '</span><span class="si">{unit}</span><span class="s2">'."</span><span class="p">)</span> -</span><span id="SQLite.Generator-164"><a href="#SQLite.Generator-164"><span class="linenos">164</span></a> -</span><span id="SQLite.Generator-165"><a href="#SQLite.Generator-165"><span class="linenos">165</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> AS INTEGER)"</span> -</span><span id="SQLite.Generator-166"><a href="#SQLite.Generator-166"><span class="linenos">166</span></a> -</span><span id="SQLite.Generator-167"><a href="#SQLite.Generator-167"><span class="linenos">167</span></a> <span class="c1"># https://www.sqlite.org/lang_aggfunc.html#group_concat</span> -</span><span id="SQLite.Generator-168"><a href="#SQLite.Generator-168"><span class="linenos">168</span></a> <span class="k">def</span> <span class="nf">groupconcat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="SQLite.Generator-169"><a href="#SQLite.Generator-169"><span class="linenos">169</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="SQLite.Generator-170"><a href="#SQLite.Generator-170"><span class="linenos">170</span></a> <span class="n">distinct</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">Distinct</span><span class="p">)</span> -</span><span id="SQLite.Generator-171"><a href="#SQLite.Generator-171"><span class="linenos">171</span></a> -</span><span id="SQLite.Generator-172"><a href="#SQLite.Generator-172"><span class="linenos">172</span></a> <span class="k">if</span> <span class="n">distinct</span><span class="p">:</span> -</span><span id="SQLite.Generator-173"><a href="#SQLite.Generator-173"><span class="linenos">173</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">distinct</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="SQLite.Generator-174"><a href="#SQLite.Generator-174"><span class="linenos">174</span></a> <span class="n">distinct_sql</span> <span class="o">=</span> <span class="s2">"DISTINCT "</span> -</span><span id="SQLite.Generator-175"><a href="#SQLite.Generator-175"><span class="linenos">175</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="SQLite.Generator-176"><a href="#SQLite.Generator-176"><span class="linenos">176</span></a> <span class="n">distinct_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="SQLite.Generator-177"><a href="#SQLite.Generator-177"><span class="linenos">177</span></a> -</span><span id="SQLite.Generator-178"><a href="#SQLite.Generator-178"><span class="linenos">178</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">):</span> -</span><span id="SQLite.Generator-179"><a href="#SQLite.Generator-179"><span class="linenos">179</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"SQLite GROUP_CONCAT doesn't support ORDER BY."</span><span class="p">)</span> -</span><span id="SQLite.Generator-180"><a href="#SQLite.Generator-180"><span class="linenos">180</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">distinct</span><span class="p">:</span> -</span><span id="SQLite.Generator-181"><a href="#SQLite.Generator-181"><span class="linenos">181</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> -</span><span id="SQLite.Generator-182"><a href="#SQLite.Generator-182"><span class="linenos">182</span></a> -</span><span id="SQLite.Generator-183"><a href="#SQLite.Generator-183"><span class="linenos">183</span></a> <span class="n">separator</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"separator"</span><span class="p">)</span> -</span><span id="SQLite.Generator-184"><a href="#SQLite.Generator-184"><span class="linenos">184</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GROUP_CONCAT(</span><span class="si">{</span><span class="n">distinct_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">separator</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SQLite.Generator-76"><a href="#SQLite.Generator-76"><span class="linenos"> 76</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="SQLite.Generator-77"><a href="#SQLite.Generator-77"><span class="linenos"> 77</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="SQLite.Generator-78"><a href="#SQLite.Generator-78"><span class="linenos"> 78</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="SQLite.Generator-79"><a href="#SQLite.Generator-79"><span class="linenos"> 79</span></a> +</span><span id="SQLite.Generator-80"><a href="#SQLite.Generator-80"><span class="linenos"> 80</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="SQLite.Generator-81"><a href="#SQLite.Generator-81"><span class="linenos"> 81</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="SQLite.Generator-82"><a href="#SQLite.Generator-82"><span class="linenos"> 82</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">BOOLEAN</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="SQLite.Generator-83"><a href="#SQLite.Generator-83"><span class="linenos"> 83</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">TINYINT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="SQLite.Generator-84"><a href="#SQLite.Generator-84"><span class="linenos"> 84</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">SMALLINT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="SQLite.Generator-85"><a href="#SQLite.Generator-85"><span class="linenos"> 85</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">INT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="SQLite.Generator-86"><a href="#SQLite.Generator-86"><span class="linenos"> 86</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">BIGINT</span><span class="p">:</span> <span class="s2">"INTEGER"</span><span class="p">,</span> +</span><span id="SQLite.Generator-87"><a href="#SQLite.Generator-87"><span class="linenos"> 87</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="SQLite.Generator-88"><a href="#SQLite.Generator-88"><span class="linenos"> 88</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">DOUBLE</span><span class="p">:</span> <span class="s2">"REAL"</span><span class="p">,</span> +</span><span id="SQLite.Generator-89"><a href="#SQLite.Generator-89"><span class="linenos"> 89</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="s2">"REAL"</span><span class="p">,</span> +</span><span id="SQLite.Generator-90"><a href="#SQLite.Generator-90"><span class="linenos"> 90</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="SQLite.Generator-91"><a href="#SQLite.Generator-91"><span class="linenos"> 91</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="SQLite.Generator-92"><a href="#SQLite.Generator-92"><span class="linenos"> 92</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="SQLite.Generator-93"><a href="#SQLite.Generator-93"><span class="linenos"> 93</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="SQLite.Generator-94"><a href="#SQLite.Generator-94"><span class="linenos"> 94</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="SQLite.Generator-95"><a href="#SQLite.Generator-95"><span class="linenos"> 95</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="SQLite.Generator-96"><a href="#SQLite.Generator-96"><span class="linenos"> 96</span></a> <span class="p">}</span> +</span><span id="SQLite.Generator-97"><a href="#SQLite.Generator-97"><span class="linenos"> 97</span></a> +</span><span id="SQLite.Generator-98"><a href="#SQLite.Generator-98"><span class="linenos"> 98</span></a> <span class="n">TOKEN_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="SQLite.Generator-99"><a href="#SQLite.Generator-99"><span class="linenos"> 99</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">:</span> <span class="s2">"AUTOINCREMENT"</span><span class="p">,</span> +</span><span id="SQLite.Generator-100"><a href="#SQLite.Generator-100"><span class="linenos">100</span></a> <span class="p">}</span> +</span><span id="SQLite.Generator-101"><a href="#SQLite.Generator-101"><span class="linenos">101</span></a> +</span><span id="SQLite.Generator-102"><a href="#SQLite.Generator-102"><span class="linenos">102</span></a> <span class="n">TRANSFORMS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="SQLite.Generator-103"><a href="#SQLite.Generator-103"><span class="linenos">103</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="SQLite.Generator-104"><a href="#SQLite.Generator-104"><span class="linenos">104</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> +</span><span id="SQLite.Generator-105"><a href="#SQLite.Generator-105"><span class="linenos">105</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CountIf</span><span class="p">:</span> <span class="n">count_if_to_sum</span><span class="p">,</span> +</span><span id="SQLite.Generator-106"><a href="#SQLite.Generator-106"><span class="linenos">106</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</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">_transform_create</span><span class="p">]),</span> +</span><span id="SQLite.Generator-107"><a href="#SQLite.Generator-107"><span class="linenos">107</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="SQLite.Generator-108"><a href="#SQLite.Generator-108"><span class="linenos">108</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="SQLite.Generator-109"><a href="#SQLite.Generator-109"><span class="linenos">109</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="SQLite.Generator-110"><a href="#SQLite.Generator-110"><span class="linenos">110</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateAdd</span><span class="p">:</span> <span class="n">_date_add_sql</span><span class="p">,</span> +</span><span id="SQLite.Generator-111"><a href="#SQLite.Generator-111"><span class="linenos">111</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateStrToDate</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="SQLite.Generator-112"><a href="#SQLite.Generator-112"><span class="linenos">112</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">:</span> <span class="n">no_ilike_sql</span><span class="p">,</span> +</span><span id="SQLite.Generator-113"><a href="#SQLite.Generator-113"><span class="linenos">113</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="SQLite.Generator-114"><a href="#SQLite.Generator-114"><span class="linenos">114</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_scalar_sql</span><span class="p">,</span> +</span><span id="SQLite.Generator-115"><a href="#SQLite.Generator-115"><span class="linenos">115</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtract</span><span class="p">:</span> <span class="n">arrow_json_extract_sql</span><span class="p">,</span> +</span><span id="SQLite.Generator-116"><a href="#SQLite.Generator-116"><span class="linenos">116</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONBExtractScalar</span><span class="p">:</span> <span class="n">arrow_json_extract_scalar_sql</span><span class="p">,</span> +</span><span id="SQLite.Generator-117"><a href="#SQLite.Generator-117"><span class="linenos">117</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Levenshtein</span><span class="p">:</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"EDITDIST3"</span><span class="p">),</span> +</span><span id="SQLite.Generator-118"><a href="#SQLite.Generator-118"><span class="linenos">118</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">"MAX"</span><span class="p">),</span> +</span><span id="SQLite.Generator-119"><a href="#SQLite.Generator-119"><span class="linenos">119</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">"MIN"</span><span class="p">),</span> +</span><span id="SQLite.Generator-120"><a href="#SQLite.Generator-120"><span class="linenos">120</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">:</span> <span class="n">no_pivot_sql</span><span class="p">,</span> +</span><span id="SQLite.Generator-121"><a href="#SQLite.Generator-121"><span class="linenos">121</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">:</span> <span class="n">concat_to_dpipe_sql</span><span class="p">,</span> +</span><span id="SQLite.Generator-122"><a href="#SQLite.Generator-122"><span class="linenos">122</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">:</span> <span class="n">transforms</span><span class="o">.</span><span class="n">preprocess</span><span class="p">(</span> +</span><span id="SQLite.Generator-123"><a href="#SQLite.Generator-123"><span class="linenos">123</span></a> <span class="p">[</span><span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_distinct_on</span><span class="p">,</span> <span class="n">transforms</span><span class="o">.</span><span class="n">eliminate_qualify</span><span class="p">]</span> +</span><span id="SQLite.Generator-124"><a href="#SQLite.Generator-124"><span class="linenos">124</span></a> <span class="p">),</span> +</span><span id="SQLite.Generator-125"><a href="#SQLite.Generator-125"><span class="linenos">125</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">:</span> <span class="n">no_tablesample_sql</span><span class="p">,</span> +</span><span id="SQLite.Generator-126"><a href="#SQLite.Generator-126"><span class="linenos">126</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TimeStrToTime</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="SQLite.Generator-127"><a href="#SQLite.Generator-127"><span class="linenos">127</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">:</span> <span class="n">no_trycast_sql</span><span class="p">,</span> +</span><span id="SQLite.Generator-128"><a href="#SQLite.Generator-128"><span class="linenos">128</span></a> <span class="p">}</span> +</span><span id="SQLite.Generator-129"><a href="#SQLite.Generator-129"><span class="linenos">129</span></a> +</span><span id="SQLite.Generator-130"><a href="#SQLite.Generator-130"><span class="linenos">130</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="SQLite.Generator-131"><a href="#SQLite.Generator-131"><span class="linenos">131</span></a> <span class="n">k</span><span class="p">:</span> <span class="n">exp</span><span 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="SQLite.Generator-132"><a href="#SQLite.Generator-132"><span class="linenos">132</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</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 class="o">.</span><span class="n">items</span><span class="p">()</span> +</span><span id="SQLite.Generator-133"><a href="#SQLite.Generator-133"><span class="linenos">133</span></a> <span class="p">}</span> +</span><span id="SQLite.Generator-134"><a href="#SQLite.Generator-134"><span class="linenos">134</span></a> +</span><span id="SQLite.Generator-135"><a href="#SQLite.Generator-135"><span class="linenos">135</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"LIMIT"</span> +</span><span id="SQLite.Generator-136"><a href="#SQLite.Generator-136"><span class="linenos">136</span></a> +</span><span id="SQLite.Generator-137"><a href="#SQLite.Generator-137"><span class="linenos">137</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="SQLite.Generator-138"><a href="#SQLite.Generator-138"><span class="linenos">138</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">"date"</span><span class="p">):</span> +</span><span id="SQLite.Generator-139"><a href="#SQLite.Generator-139"><span class="linenos">139</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">"DATE"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="SQLite.Generator-140"><a href="#SQLite.Generator-140"><span class="linenos">140</span></a> +</span><span id="SQLite.Generator-141"><a href="#SQLite.Generator-141"><span class="linenos">141</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="SQLite.Generator-142"><a href="#SQLite.Generator-142"><span class="linenos">142</span></a> +</span><span id="SQLite.Generator-143"><a href="#SQLite.Generator-143"><span class="linenos">143</span></a> <span class="k">def</span> <span class="nf">datediff_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="SQLite.Generator-144"><a href="#SQLite.Generator-144"><span class="linenos">144</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> +</span><span id="SQLite.Generator-145"><a href="#SQLite.Generator-145"><span class="linenos">145</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">unit</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="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">"DAY"</span> +</span><span id="SQLite.Generator-146"><a href="#SQLite.Generator-146"><span class="linenos">146</span></a> +</span><span id="SQLite.Generator-147"><a href="#SQLite.Generator-147"><span class="linenos">147</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(JULIANDAY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) - JULIANDAY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span> +</span><span id="SQLite.Generator-148"><a href="#SQLite.Generator-148"><span class="linenos">148</span></a> +</span><span id="SQLite.Generator-149"><a href="#SQLite.Generator-149"><span class="linenos">149</span></a> <span class="k">if</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MONTH"</span><span class="p">:</span> +</span><span id="SQLite.Generator-150"><a href="#SQLite.Generator-150"><span class="linenos">150</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> / 30.0"</span> +</span><span id="SQLite.Generator-151"><a href="#SQLite.Generator-151"><span class="linenos">151</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"YEAR"</span><span class="p">:</span> +</span><span id="SQLite.Generator-152"><a href="#SQLite.Generator-152"><span class="linenos">152</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> / 365.0"</span> +</span><span id="SQLite.Generator-153"><a href="#SQLite.Generator-153"><span class="linenos">153</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"HOUR"</span><span class="p">:</span> +</span><span id="SQLite.Generator-154"><a href="#SQLite.Generator-154"><span class="linenos">154</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 24.0"</span> +</span><span id="SQLite.Generator-155"><a href="#SQLite.Generator-155"><span class="linenos">155</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MINUTE"</span><span class="p">:</span> +</span><span id="SQLite.Generator-156"><a href="#SQLite.Generator-156"><span class="linenos">156</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 1440.0"</span> +</span><span id="SQLite.Generator-157"><a href="#SQLite.Generator-157"><span class="linenos">157</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"SECOND"</span><span class="p">:</span> +</span><span id="SQLite.Generator-158"><a href="#SQLite.Generator-158"><span class="linenos">158</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400.0"</span> +</span><span id="SQLite.Generator-159"><a href="#SQLite.Generator-159"><span class="linenos">159</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MILLISECOND"</span><span class="p">:</span> +</span><span id="SQLite.Generator-160"><a href="#SQLite.Generator-160"><span class="linenos">160</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400000.0"</span> +</span><span id="SQLite.Generator-161"><a href="#SQLite.Generator-161"><span class="linenos">161</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MICROSECOND"</span><span class="p">:</span> +</span><span id="SQLite.Generator-162"><a href="#SQLite.Generator-162"><span class="linenos">162</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400000000.0"</span> +</span><span id="SQLite.Generator-163"><a href="#SQLite.Generator-163"><span class="linenos">163</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"NANOSECOND"</span><span class="p">:</span> +</span><span id="SQLite.Generator-164"><a href="#SQLite.Generator-164"><span class="linenos">164</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 8640000000000.0"</span> +</span><span id="SQLite.Generator-165"><a href="#SQLite.Generator-165"><span class="linenos">165</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="SQLite.Generator-166"><a href="#SQLite.Generator-166"><span class="linenos">166</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"DATEDIFF unsupported for '</span><span class="si">{unit}</span><span class="s2">'."</span><span class="p">)</span> +</span><span id="SQLite.Generator-167"><a href="#SQLite.Generator-167"><span class="linenos">167</span></a> +</span><span id="SQLite.Generator-168"><a href="#SQLite.Generator-168"><span class="linenos">168</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> AS INTEGER)"</span> +</span><span id="SQLite.Generator-169"><a href="#SQLite.Generator-169"><span class="linenos">169</span></a> +</span><span id="SQLite.Generator-170"><a href="#SQLite.Generator-170"><span class="linenos">170</span></a> <span class="c1"># https://www.sqlite.org/lang_aggfunc.html#group_concat</span> +</span><span id="SQLite.Generator-171"><a href="#SQLite.Generator-171"><span class="linenos">171</span></a> <span class="k">def</span> <span class="nf">groupconcat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="SQLite.Generator-172"><a href="#SQLite.Generator-172"><span class="linenos">172</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="SQLite.Generator-173"><a href="#SQLite.Generator-173"><span class="linenos">173</span></a> <span class="n">distinct</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">Distinct</span><span class="p">)</span> +</span><span id="SQLite.Generator-174"><a href="#SQLite.Generator-174"><span class="linenos">174</span></a> +</span><span id="SQLite.Generator-175"><a href="#SQLite.Generator-175"><span class="linenos">175</span></a> <span class="k">if</span> <span class="n">distinct</span><span class="p">:</span> +</span><span id="SQLite.Generator-176"><a href="#SQLite.Generator-176"><span class="linenos">176</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">distinct</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="SQLite.Generator-177"><a href="#SQLite.Generator-177"><span class="linenos">177</span></a> <span class="n">distinct_sql</span> <span class="o">=</span> <span class="s2">"DISTINCT "</span> +</span><span id="SQLite.Generator-178"><a href="#SQLite.Generator-178"><span class="linenos">178</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="SQLite.Generator-179"><a href="#SQLite.Generator-179"><span class="linenos">179</span></a> <span class="n">distinct_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="SQLite.Generator-180"><a href="#SQLite.Generator-180"><span class="linenos">180</span></a> +</span><span id="SQLite.Generator-181"><a href="#SQLite.Generator-181"><span class="linenos">181</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">):</span> +</span><span id="SQLite.Generator-182"><a href="#SQLite.Generator-182"><span class="linenos">182</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"SQLite GROUP_CONCAT doesn't support ORDER BY."</span><span class="p">)</span> +</span><span id="SQLite.Generator-183"><a href="#SQLite.Generator-183"><span class="linenos">183</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">distinct</span><span class="p">:</span> +</span><span id="SQLite.Generator-184"><a href="#SQLite.Generator-184"><span class="linenos">184</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> </span><span id="SQLite.Generator-185"><a href="#SQLite.Generator-185"><span class="linenos">185</span></a> -</span><span id="SQLite.Generator-186"><a href="#SQLite.Generator-186"><span class="linenos">186</span></a> <span class="k">def</span> <span class="nf">least_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Least</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="SQLite.Generator-187"><a href="#SQLite.Generator-187"><span class="linenos">187</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="SQLite.Generator-188"><a href="#SQLite.Generator-188"><span class="linenos">188</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN"</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="SQLite.Generator-189"><a href="#SQLite.Generator-189"><span class="linenos">189</span></a> -</span><span id="SQLite.Generator-190"><a href="#SQLite.Generator-190"><span class="linenos">190</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="SQLite.Generator-191"><a href="#SQLite.Generator-191"><span class="linenos">191</span></a> -</span><span id="SQLite.Generator-192"><a href="#SQLite.Generator-192"><span class="linenos">192</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="SQLite.Generator-193"><a href="#SQLite.Generator-193"><span class="linenos">193</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="SQLite.Generator-194"><a href="#SQLite.Generator-194"><span class="linenos">194</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="SQLite.Generator-195"><a href="#SQLite.Generator-195"><span class="linenos">195</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BEGIN</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> TRANSACTION"</span> +</span><span id="SQLite.Generator-186"><a href="#SQLite.Generator-186"><span class="linenos">186</span></a> <span class="n">separator</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"separator"</span><span class="p">)</span> +</span><span id="SQLite.Generator-187"><a href="#SQLite.Generator-187"><span class="linenos">187</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GROUP_CONCAT(</span><span class="si">{</span><span class="n">distinct_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">separator</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="SQLite.Generator-188"><a href="#SQLite.Generator-188"><span class="linenos">188</span></a> +</span><span id="SQLite.Generator-189"><a href="#SQLite.Generator-189"><span class="linenos">189</span></a> <span class="k">def</span> <span class="nf">least_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Least</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="SQLite.Generator-190"><a href="#SQLite.Generator-190"><span class="linenos">190</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="SQLite.Generator-191"><a href="#SQLite.Generator-191"><span class="linenos">191</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN"</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="SQLite.Generator-192"><a href="#SQLite.Generator-192"><span class="linenos">192</span></a> +</span><span id="SQLite.Generator-193"><a href="#SQLite.Generator-193"><span class="linenos">193</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="SQLite.Generator-194"><a href="#SQLite.Generator-194"><span class="linenos">194</span></a> +</span><span id="SQLite.Generator-195"><a href="#SQLite.Generator-195"><span class="linenos">195</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="SQLite.Generator-196"><a href="#SQLite.Generator-196"><span class="linenos">196</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="SQLite.Generator-197"><a href="#SQLite.Generator-197"><span class="linenos">197</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="SQLite.Generator-198"><a href="#SQLite.Generator-198"><span class="linenos">198</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BEGIN</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> TRANSACTION"</span> </span></pre></div> @@ -729,11 +742,11 @@ Default: True</li> </div> <a class="headerlink" href="#SQLite.Generator.cast_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SQLite.Generator.cast_sql-134"><a href="#SQLite.Generator.cast_sql-134"><span class="linenos">134</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="SQLite.Generator.cast_sql-135"><a href="#SQLite.Generator.cast_sql-135"><span class="linenos">135</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">"date"</span><span class="p">):</span> -</span><span id="SQLite.Generator.cast_sql-136"><a href="#SQLite.Generator.cast_sql-136"><span class="linenos">136</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">"DATE"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="SQLite.Generator.cast_sql-137"><a href="#SQLite.Generator.cast_sql-137"><span class="linenos">137</span></a> -</span><span id="SQLite.Generator.cast_sql-138"><a href="#SQLite.Generator.cast_sql-138"><span class="linenos">138</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_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="SQLite.Generator.cast_sql-137"><a href="#SQLite.Generator.cast_sql-137"><span class="linenos">137</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="SQLite.Generator.cast_sql-138"><a href="#SQLite.Generator.cast_sql-138"><span class="linenos">138</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">"date"</span><span class="p">):</span> +</span><span id="SQLite.Generator.cast_sql-139"><a href="#SQLite.Generator.cast_sql-139"><span class="linenos">139</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">"DATE"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="SQLite.Generator.cast_sql-140"><a href="#SQLite.Generator.cast_sql-140"><span class="linenos">140</span></a> +</span><span id="SQLite.Generator.cast_sql-141"><a href="#SQLite.Generator.cast_sql-141"><span class="linenos">141</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -751,32 +764,32 @@ Default: True</li> </div> <a class="headerlink" href="#SQLite.Generator.datediff_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SQLite.Generator.datediff_sql-140"><a href="#SQLite.Generator.datediff_sql-140"><span class="linenos">140</span></a> <span class="k">def</span> <span class="nf">datediff_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="SQLite.Generator.datediff_sql-141"><a href="#SQLite.Generator.datediff_sql-141"><span class="linenos">141</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> -</span><span id="SQLite.Generator.datediff_sql-142"><a href="#SQLite.Generator.datediff_sql-142"><span class="linenos">142</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">unit</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="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">"DAY"</span> -</span><span id="SQLite.Generator.datediff_sql-143"><a href="#SQLite.Generator.datediff_sql-143"><span class="linenos">143</span></a> -</span><span id="SQLite.Generator.datediff_sql-144"><a href="#SQLite.Generator.datediff_sql-144"><span class="linenos">144</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(JULIANDAY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) - JULIANDAY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span> -</span><span id="SQLite.Generator.datediff_sql-145"><a href="#SQLite.Generator.datediff_sql-145"><span class="linenos">145</span></a> -</span><span id="SQLite.Generator.datediff_sql-146"><a href="#SQLite.Generator.datediff_sql-146"><span class="linenos">146</span></a> <span class="k">if</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MONTH"</span><span class="p">:</span> -</span><span id="SQLite.Generator.datediff_sql-147"><a href="#SQLite.Generator.datediff_sql-147"><span class="linenos">147</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> / 30.0"</span> -</span><span id="SQLite.Generator.datediff_sql-148"><a href="#SQLite.Generator.datediff_sql-148"><span class="linenos">148</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"YEAR"</span><span class="p">:</span> -</span><span id="SQLite.Generator.datediff_sql-149"><a href="#SQLite.Generator.datediff_sql-149"><span class="linenos">149</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> / 365.0"</span> -</span><span id="SQLite.Generator.datediff_sql-150"><a href="#SQLite.Generator.datediff_sql-150"><span class="linenos">150</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"HOUR"</span><span class="p">:</span> -</span><span id="SQLite.Generator.datediff_sql-151"><a href="#SQLite.Generator.datediff_sql-151"><span class="linenos">151</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 24.0"</span> -</span><span id="SQLite.Generator.datediff_sql-152"><a href="#SQLite.Generator.datediff_sql-152"><span class="linenos">152</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MINUTE"</span><span class="p">:</span> -</span><span id="SQLite.Generator.datediff_sql-153"><a href="#SQLite.Generator.datediff_sql-153"><span class="linenos">153</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 1440.0"</span> -</span><span id="SQLite.Generator.datediff_sql-154"><a href="#SQLite.Generator.datediff_sql-154"><span class="linenos">154</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"SECOND"</span><span class="p">:</span> -</span><span id="SQLite.Generator.datediff_sql-155"><a href="#SQLite.Generator.datediff_sql-155"><span class="linenos">155</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400.0"</span> -</span><span id="SQLite.Generator.datediff_sql-156"><a href="#SQLite.Generator.datediff_sql-156"><span class="linenos">156</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MILLISECOND"</span><span class="p">:</span> -</span><span id="SQLite.Generator.datediff_sql-157"><a href="#SQLite.Generator.datediff_sql-157"><span class="linenos">157</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400000.0"</span> -</span><span id="SQLite.Generator.datediff_sql-158"><a href="#SQLite.Generator.datediff_sql-158"><span class="linenos">158</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MICROSECOND"</span><span class="p">:</span> -</span><span id="SQLite.Generator.datediff_sql-159"><a href="#SQLite.Generator.datediff_sql-159"><span class="linenos">159</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400000000.0"</span> -</span><span id="SQLite.Generator.datediff_sql-160"><a href="#SQLite.Generator.datediff_sql-160"><span class="linenos">160</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"NANOSECOND"</span><span class="p">:</span> -</span><span id="SQLite.Generator.datediff_sql-161"><a href="#SQLite.Generator.datediff_sql-161"><span class="linenos">161</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 8640000000000.0"</span> -</span><span id="SQLite.Generator.datediff_sql-162"><a href="#SQLite.Generator.datediff_sql-162"><span class="linenos">162</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="SQLite.Generator.datediff_sql-163"><a href="#SQLite.Generator.datediff_sql-163"><span class="linenos">163</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"DATEDIFF unsupported for '</span><span class="si">{unit}</span><span class="s2">'."</span><span class="p">)</span> -</span><span id="SQLite.Generator.datediff_sql-164"><a href="#SQLite.Generator.datediff_sql-164"><span class="linenos">164</span></a> -</span><span id="SQLite.Generator.datediff_sql-165"><a href="#SQLite.Generator.datediff_sql-165"><span class="linenos">165</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> AS INTEGER)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SQLite.Generator.datediff_sql-143"><a href="#SQLite.Generator.datediff_sql-143"><span class="linenos">143</span></a> <span class="k">def</span> <span class="nf">datediff_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DateDiff</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="SQLite.Generator.datediff_sql-144"><a href="#SQLite.Generator.datediff_sql-144"><span class="linenos">144</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> +</span><span id="SQLite.Generator.datediff_sql-145"><a href="#SQLite.Generator.datediff_sql-145"><span class="linenos">145</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">unit</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="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">"DAY"</span> +</span><span id="SQLite.Generator.datediff_sql-146"><a href="#SQLite.Generator.datediff_sql-146"><span class="linenos">146</span></a> +</span><span id="SQLite.Generator.datediff_sql-147"><a href="#SQLite.Generator.datediff_sql-147"><span class="linenos">147</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(JULIANDAY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">) - JULIANDAY(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">))"</span> +</span><span id="SQLite.Generator.datediff_sql-148"><a href="#SQLite.Generator.datediff_sql-148"><span class="linenos">148</span></a> +</span><span id="SQLite.Generator.datediff_sql-149"><a href="#SQLite.Generator.datediff_sql-149"><span class="linenos">149</span></a> <span class="k">if</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MONTH"</span><span class="p">:</span> +</span><span id="SQLite.Generator.datediff_sql-150"><a href="#SQLite.Generator.datediff_sql-150"><span class="linenos">150</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> / 30.0"</span> +</span><span id="SQLite.Generator.datediff_sql-151"><a href="#SQLite.Generator.datediff_sql-151"><span class="linenos">151</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"YEAR"</span><span class="p">:</span> +</span><span id="SQLite.Generator.datediff_sql-152"><a href="#SQLite.Generator.datediff_sql-152"><span class="linenos">152</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> / 365.0"</span> +</span><span id="SQLite.Generator.datediff_sql-153"><a href="#SQLite.Generator.datediff_sql-153"><span class="linenos">153</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"HOUR"</span><span class="p">:</span> +</span><span id="SQLite.Generator.datediff_sql-154"><a href="#SQLite.Generator.datediff_sql-154"><span class="linenos">154</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 24.0"</span> +</span><span id="SQLite.Generator.datediff_sql-155"><a href="#SQLite.Generator.datediff_sql-155"><span class="linenos">155</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MINUTE"</span><span class="p">:</span> +</span><span id="SQLite.Generator.datediff_sql-156"><a href="#SQLite.Generator.datediff_sql-156"><span class="linenos">156</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 1440.0"</span> +</span><span id="SQLite.Generator.datediff_sql-157"><a href="#SQLite.Generator.datediff_sql-157"><span class="linenos">157</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"SECOND"</span><span class="p">:</span> +</span><span id="SQLite.Generator.datediff_sql-158"><a href="#SQLite.Generator.datediff_sql-158"><span class="linenos">158</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400.0"</span> +</span><span id="SQLite.Generator.datediff_sql-159"><a href="#SQLite.Generator.datediff_sql-159"><span class="linenos">159</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MILLISECOND"</span><span class="p">:</span> +</span><span id="SQLite.Generator.datediff_sql-160"><a href="#SQLite.Generator.datediff_sql-160"><span class="linenos">160</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400000.0"</span> +</span><span id="SQLite.Generator.datediff_sql-161"><a href="#SQLite.Generator.datediff_sql-161"><span class="linenos">161</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"MICROSECOND"</span><span class="p">:</span> +</span><span id="SQLite.Generator.datediff_sql-162"><a href="#SQLite.Generator.datediff_sql-162"><span class="linenos">162</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 86400000000.0"</span> +</span><span id="SQLite.Generator.datediff_sql-163"><a href="#SQLite.Generator.datediff_sql-163"><span class="linenos">163</span></a> <span class="k">elif</span> <span class="n">unit</span> <span class="o">==</span> <span class="s2">"NANOSECOND"</span><span class="p">:</span> +</span><span id="SQLite.Generator.datediff_sql-164"><a href="#SQLite.Generator.datediff_sql-164"><span class="linenos">164</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> * 8640000000000.0"</span> +</span><span id="SQLite.Generator.datediff_sql-165"><a href="#SQLite.Generator.datediff_sql-165"><span class="linenos">165</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="SQLite.Generator.datediff_sql-166"><a href="#SQLite.Generator.datediff_sql-166"><span class="linenos">166</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"DATEDIFF unsupported for '</span><span class="si">{unit}</span><span class="s2">'."</span><span class="p">)</span> +</span><span id="SQLite.Generator.datediff_sql-167"><a href="#SQLite.Generator.datediff_sql-167"><span class="linenos">167</span></a> +</span><span id="SQLite.Generator.datediff_sql-168"><a href="#SQLite.Generator.datediff_sql-168"><span class="linenos">168</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> AS INTEGER)"</span> </span></pre></div> @@ -794,23 +807,23 @@ Default: True</li> </div> <a class="headerlink" href="#SQLite.Generator.groupconcat_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SQLite.Generator.groupconcat_sql-168"><a href="#SQLite.Generator.groupconcat_sql-168"><span class="linenos">168</span></a> <span class="k">def</span> <span class="nf">groupconcat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="SQLite.Generator.groupconcat_sql-169"><a href="#SQLite.Generator.groupconcat_sql-169"><span class="linenos">169</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="SQLite.Generator.groupconcat_sql-170"><a href="#SQLite.Generator.groupconcat_sql-170"><span class="linenos">170</span></a> <span class="n">distinct</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">Distinct</span><span class="p">)</span> -</span><span id="SQLite.Generator.groupconcat_sql-171"><a href="#SQLite.Generator.groupconcat_sql-171"><span class="linenos">171</span></a> -</span><span id="SQLite.Generator.groupconcat_sql-172"><a href="#SQLite.Generator.groupconcat_sql-172"><span class="linenos">172</span></a> <span class="k">if</span> <span class="n">distinct</span><span class="p">:</span> -</span><span id="SQLite.Generator.groupconcat_sql-173"><a href="#SQLite.Generator.groupconcat_sql-173"><span class="linenos">173</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">distinct</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="SQLite.Generator.groupconcat_sql-174"><a href="#SQLite.Generator.groupconcat_sql-174"><span class="linenos">174</span></a> <span class="n">distinct_sql</span> <span class="o">=</span> <span class="s2">"DISTINCT "</span> -</span><span id="SQLite.Generator.groupconcat_sql-175"><a href="#SQLite.Generator.groupconcat_sql-175"><span class="linenos">175</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="SQLite.Generator.groupconcat_sql-176"><a href="#SQLite.Generator.groupconcat_sql-176"><span class="linenos">176</span></a> <span class="n">distinct_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="SQLite.Generator.groupconcat_sql-177"><a href="#SQLite.Generator.groupconcat_sql-177"><span class="linenos">177</span></a> -</span><span id="SQLite.Generator.groupconcat_sql-178"><a href="#SQLite.Generator.groupconcat_sql-178"><span class="linenos">178</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">):</span> -</span><span id="SQLite.Generator.groupconcat_sql-179"><a href="#SQLite.Generator.groupconcat_sql-179"><span class="linenos">179</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"SQLite GROUP_CONCAT doesn't support ORDER BY."</span><span class="p">)</span> -</span><span id="SQLite.Generator.groupconcat_sql-180"><a href="#SQLite.Generator.groupconcat_sql-180"><span class="linenos">180</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">distinct</span><span class="p">:</span> -</span><span id="SQLite.Generator.groupconcat_sql-181"><a href="#SQLite.Generator.groupconcat_sql-181"><span class="linenos">181</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> -</span><span id="SQLite.Generator.groupconcat_sql-182"><a href="#SQLite.Generator.groupconcat_sql-182"><span class="linenos">182</span></a> -</span><span id="SQLite.Generator.groupconcat_sql-183"><a href="#SQLite.Generator.groupconcat_sql-183"><span class="linenos">183</span></a> <span class="n">separator</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"separator"</span><span class="p">)</span> -</span><span id="SQLite.Generator.groupconcat_sql-184"><a href="#SQLite.Generator.groupconcat_sql-184"><span class="linenos">184</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GROUP_CONCAT(</span><span class="si">{</span><span class="n">distinct_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">separator</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SQLite.Generator.groupconcat_sql-171"><a href="#SQLite.Generator.groupconcat_sql-171"><span class="linenos">171</span></a> <span class="k">def</span> <span class="nf">groupconcat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="SQLite.Generator.groupconcat_sql-172"><a href="#SQLite.Generator.groupconcat_sql-172"><span class="linenos">172</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="SQLite.Generator.groupconcat_sql-173"><a href="#SQLite.Generator.groupconcat_sql-173"><span class="linenos">173</span></a> <span class="n">distinct</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">Distinct</span><span class="p">)</span> +</span><span id="SQLite.Generator.groupconcat_sql-174"><a href="#SQLite.Generator.groupconcat_sql-174"><span class="linenos">174</span></a> +</span><span id="SQLite.Generator.groupconcat_sql-175"><a href="#SQLite.Generator.groupconcat_sql-175"><span class="linenos">175</span></a> <span class="k">if</span> <span class="n">distinct</span><span class="p">:</span> +</span><span id="SQLite.Generator.groupconcat_sql-176"><a href="#SQLite.Generator.groupconcat_sql-176"><span class="linenos">176</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">distinct</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="SQLite.Generator.groupconcat_sql-177"><a href="#SQLite.Generator.groupconcat_sql-177"><span class="linenos">177</span></a> <span class="n">distinct_sql</span> <span class="o">=</span> <span class="s2">"DISTINCT "</span> +</span><span id="SQLite.Generator.groupconcat_sql-178"><a href="#SQLite.Generator.groupconcat_sql-178"><span class="linenos">178</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="SQLite.Generator.groupconcat_sql-179"><a href="#SQLite.Generator.groupconcat_sql-179"><span class="linenos">179</span></a> <span class="n">distinct_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="SQLite.Generator.groupconcat_sql-180"><a href="#SQLite.Generator.groupconcat_sql-180"><span class="linenos">180</span></a> +</span><span id="SQLite.Generator.groupconcat_sql-181"><a href="#SQLite.Generator.groupconcat_sql-181"><span class="linenos">181</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">):</span> +</span><span id="SQLite.Generator.groupconcat_sql-182"><a href="#SQLite.Generator.groupconcat_sql-182"><span class="linenos">182</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"SQLite GROUP_CONCAT doesn't support ORDER BY."</span><span class="p">)</span> +</span><span id="SQLite.Generator.groupconcat_sql-183"><a href="#SQLite.Generator.groupconcat_sql-183"><span class="linenos">183</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">distinct</span><span class="p">:</span> +</span><span id="SQLite.Generator.groupconcat_sql-184"><a href="#SQLite.Generator.groupconcat_sql-184"><span class="linenos">184</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">this</span> +</span><span id="SQLite.Generator.groupconcat_sql-185"><a href="#SQLite.Generator.groupconcat_sql-185"><span class="linenos">185</span></a> +</span><span id="SQLite.Generator.groupconcat_sql-186"><a href="#SQLite.Generator.groupconcat_sql-186"><span class="linenos">186</span></a> <span class="n">separator</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"separator"</span><span class="p">)</span> +</span><span id="SQLite.Generator.groupconcat_sql-187"><a href="#SQLite.Generator.groupconcat_sql-187"><span class="linenos">187</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GROUP_CONCAT(</span><span class="si">{</span><span class="n">distinct_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="n">separator</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -828,11 +841,11 @@ Default: True</li> </div> <a class="headerlink" href="#SQLite.Generator.least_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SQLite.Generator.least_sql-186"><a href="#SQLite.Generator.least_sql-186"><span class="linenos">186</span></a> <span class="k">def</span> <span class="nf">least_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Least</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="SQLite.Generator.least_sql-187"><a href="#SQLite.Generator.least_sql-187"><span class="linenos">187</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="SQLite.Generator.least_sql-188"><a href="#SQLite.Generator.least_sql-188"><span class="linenos">188</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN"</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="SQLite.Generator.least_sql-189"><a href="#SQLite.Generator.least_sql-189"><span class="linenos">189</span></a> -</span><span id="SQLite.Generator.least_sql-190"><a href="#SQLite.Generator.least_sql-190"><span class="linenos">190</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SQLite.Generator.least_sql-189"><a href="#SQLite.Generator.least_sql-189"><span class="linenos">189</span></a> <span class="k">def</span> <span class="nf">least_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Least</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="SQLite.Generator.least_sql-190"><a href="#SQLite.Generator.least_sql-190"><span class="linenos">190</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="SQLite.Generator.least_sql-191"><a href="#SQLite.Generator.least_sql-191"><span class="linenos">191</span></a> <span class="k">return</span> <span class="n">rename_func</span><span class="p">(</span><span class="s2">"MIN"</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="SQLite.Generator.least_sql-192"><a href="#SQLite.Generator.least_sql-192"><span class="linenos">192</span></a> +</span><span id="SQLite.Generator.least_sql-193"><a href="#SQLite.Generator.least_sql-193"><span class="linenos">193</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -850,16 +863,70 @@ Default: True</li> </div> <a class="headerlink" href="#SQLite.Generator.transaction_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SQLite.Generator.transaction_sql-192"><a href="#SQLite.Generator.transaction_sql-192"><span class="linenos">192</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="SQLite.Generator.transaction_sql-193"><a href="#SQLite.Generator.transaction_sql-193"><span class="linenos">193</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="SQLite.Generator.transaction_sql-194"><a href="#SQLite.Generator.transaction_sql-194"><span class="linenos">194</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="SQLite.Generator.transaction_sql-195"><a href="#SQLite.Generator.transaction_sql-195"><span class="linenos">195</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BEGIN</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> TRANSACTION"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SQLite.Generator.transaction_sql-195"><a href="#SQLite.Generator.transaction_sql-195"><span class="linenos">195</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="SQLite.Generator.transaction_sql-196"><a href="#SQLite.Generator.transaction_sql-196"><span class="linenos">196</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="SQLite.Generator.transaction_sql-197"><a href="#SQLite.Generator.transaction_sql-197"><span class="linenos">197</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="SQLite.Generator.transaction_sql-198"><a href="#SQLite.Generator.transaction_sql-198"><span class="linenos">198</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BEGIN</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> TRANSACTION"</span> </span></pre></div> </div> + <div id="SQLite.Generator.can_identify" class="classattr"> + <input id="SQLite.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="SQLite.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#SQLite.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="SQLite.Generator.can_identify-247"><a href="#SQLite.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="SQLite.Generator.can_identify-248"><a href="#SQLite.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="SQLite.Generator.can_identify-249"><a href="#SQLite.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="SQLite.Generator.can_identify-250"><a href="#SQLite.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="SQLite.Generator.can_identify-251"><a href="#SQLite.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="SQLite.Generator.can_identify-252"><a href="#SQLite.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="SQLite.Generator.can_identify-253"><a href="#SQLite.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="SQLite.Generator.can_identify-254"><a href="#SQLite.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="SQLite.Generator.can_identify-255"><a href="#SQLite.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="SQLite.Generator.can_identify-256"><a href="#SQLite.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="SQLite.Generator.can_identify-257"><a href="#SQLite.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="SQLite.Generator.can_identify-258"><a href="#SQLite.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="SQLite.Generator.can_identify-259"><a href="#SQLite.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="SQLite.Generator.can_identify-260"><a href="#SQLite.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="SQLite.Generator.can_identify-261"><a href="#SQLite.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="SQLite.Generator.can_identify-262"><a href="#SQLite.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="SQLite.Generator.can_identify-263"><a href="#SQLite.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="SQLite.Generator.can_identify-264"><a href="#SQLite.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="SQLite.Generator.can_identify-265"><a href="#SQLite.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="SQLite.Generator.can_identify-266"><a href="#SQLite.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -962,6 +1029,7 @@ Default: True</li> <dd id="SQLite.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="SQLite.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="SQLite.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="SQLite.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="SQLite.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="SQLite.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="SQLite.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/dialects/starrocks.html b/docs/sqlglot/dialects/starrocks.html index a6c391d..aaf1d4d 100644 --- a/docs/sqlglot/dialects/starrocks.html +++ b/docs/sqlglot/dialects/starrocks.html @@ -42,6 +42,9 @@ <li> <a class="class" href="#StarRocks.Generator">StarRocks.Generator</a> <ul class="memberlist"> + <li> + <a class="function" href="#StarRocks.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -181,6 +184,10 @@ <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="StarRocks.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="StarRocks.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="StarRocks.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="StarRocks.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="StarRocks.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="StarRocks.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="StarRocks.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="StarRocks.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="StarRocks.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -326,6 +333,60 @@ Default: True</li> </div> + <div id="StarRocks.Generator.can_identify" class="classattr"> + <input id="StarRocks.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="StarRocks.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#StarRocks.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="StarRocks.Generator.can_identify-247"><a href="#StarRocks.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="StarRocks.Generator.can_identify-248"><a href="#StarRocks.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="StarRocks.Generator.can_identify-249"><a href="#StarRocks.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="StarRocks.Generator.can_identify-250"><a href="#StarRocks.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="StarRocks.Generator.can_identify-251"><a href="#StarRocks.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="StarRocks.Generator.can_identify-252"><a href="#StarRocks.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="StarRocks.Generator.can_identify-253"><a href="#StarRocks.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="StarRocks.Generator.can_identify-254"><a href="#StarRocks.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="StarRocks.Generator.can_identify-255"><a href="#StarRocks.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="StarRocks.Generator.can_identify-256"><a href="#StarRocks.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="StarRocks.Generator.can_identify-257"><a href="#StarRocks.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="StarRocks.Generator.can_identify-258"><a href="#StarRocks.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="StarRocks.Generator.can_identify-259"><a href="#StarRocks.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="StarRocks.Generator.can_identify-260"><a href="#StarRocks.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="StarRocks.Generator.can_identify-261"><a href="#StarRocks.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="StarRocks.Generator.can_identify-262"><a href="#StarRocks.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="StarRocks.Generator.can_identify-263"><a href="#StarRocks.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="StarRocks.Generator.can_identify-264"><a href="#StarRocks.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="StarRocks.Generator.can_identify-265"><a href="#StarRocks.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="StarRocks.Generator.can_identify-266"><a href="#StarRocks.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -428,6 +489,7 @@ Default: True</li> <dd id="StarRocks.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="StarRocks.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="StarRocks.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="StarRocks.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="StarRocks.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="StarRocks.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="StarRocks.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/dialects/tableau.html b/docs/sqlglot/dialects/tableau.html index b30f96d..a704093 100644 --- a/docs/sqlglot/dialects/tableau.html +++ b/docs/sqlglot/dialects/tableau.html @@ -42,6 +42,9 @@ <li> <a class="function" href="#Tableau.Generator.count_sql">count_sql</a> </li> + <li> + <a class="function" href="#Tableau.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -175,6 +178,10 @@ <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="Tableau.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="Tableau.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="Tableau.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="Tableau.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="Tableau.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="Tableau.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="Tableau.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="Tableau.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="Tableau.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -310,6 +317,60 @@ Default: True</li> </div> + <div id="Tableau.Generator.can_identify" class="classattr"> + <input id="Tableau.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="Tableau.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Tableau.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Tableau.Generator.can_identify-247"><a href="#Tableau.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="Tableau.Generator.can_identify-248"><a href="#Tableau.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Tableau.Generator.can_identify-249"><a href="#Tableau.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="Tableau.Generator.can_identify-250"><a href="#Tableau.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="Tableau.Generator.can_identify-251"><a href="#Tableau.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="Tableau.Generator.can_identify-252"><a href="#Tableau.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="Tableau.Generator.can_identify-253"><a href="#Tableau.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="Tableau.Generator.can_identify-254"><a href="#Tableau.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="Tableau.Generator.can_identify-255"><a href="#Tableau.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="Tableau.Generator.can_identify-256"><a href="#Tableau.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="Tableau.Generator.can_identify-257"><a href="#Tableau.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="Tableau.Generator.can_identify-258"><a href="#Tableau.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="Tableau.Generator.can_identify-259"><a href="#Tableau.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="Tableau.Generator.can_identify-260"><a href="#Tableau.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="Tableau.Generator.can_identify-261"><a href="#Tableau.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Tableau.Generator.can_identify-262"><a href="#Tableau.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="Tableau.Generator.can_identify-263"><a href="#Tableau.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="Tableau.Generator.can_identify-264"><a href="#Tableau.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="Tableau.Generator.can_identify-265"><a href="#Tableau.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="Tableau.Generator.can_identify-266"><a href="#Tableau.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -412,6 +473,7 @@ Default: True</li> <dd id="Tableau.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="Tableau.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="Tableau.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="Tableau.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="Tableau.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="Tableau.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="Tableau.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/dialects/teradata.html b/docs/sqlglot/dialects/teradata.html index 3d0f933..914329b 100644 --- a/docs/sqlglot/dialects/teradata.html +++ b/docs/sqlglot/dialects/teradata.html @@ -66,6 +66,9 @@ <li> <a class="function" href="#Teradata.Generator.createable_sql">createable_sql</a> </li> + <li> + <a class="function" href="#Teradata.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -530,6 +533,10 @@ <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="Teradata.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="Teradata.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="Teradata.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="Teradata.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="Teradata.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="Teradata.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="Teradata.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="Teradata.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="Teradata.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -988,6 +995,60 @@ Default: True</li> </div> + <div id="Teradata.Generator.can_identify" class="classattr"> + <input id="Teradata.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="Teradata.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Teradata.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Teradata.Generator.can_identify-247"><a href="#Teradata.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="Teradata.Generator.can_identify-248"><a href="#Teradata.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Teradata.Generator.can_identify-249"><a href="#Teradata.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="Teradata.Generator.can_identify-250"><a href="#Teradata.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="Teradata.Generator.can_identify-251"><a href="#Teradata.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="Teradata.Generator.can_identify-252"><a href="#Teradata.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="Teradata.Generator.can_identify-253"><a href="#Teradata.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="Teradata.Generator.can_identify-254"><a href="#Teradata.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="Teradata.Generator.can_identify-255"><a href="#Teradata.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="Teradata.Generator.can_identify-256"><a href="#Teradata.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="Teradata.Generator.can_identify-257"><a href="#Teradata.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="Teradata.Generator.can_identify-258"><a href="#Teradata.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="Teradata.Generator.can_identify-259"><a href="#Teradata.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="Teradata.Generator.can_identify-260"><a href="#Teradata.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="Teradata.Generator.can_identify-261"><a href="#Teradata.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Teradata.Generator.can_identify-262"><a href="#Teradata.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="Teradata.Generator.can_identify-263"><a href="#Teradata.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="Teradata.Generator.can_identify-264"><a href="#Teradata.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="Teradata.Generator.can_identify-265"><a href="#Teradata.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="Teradata.Generator.can_identify-266"><a href="#Teradata.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -1087,6 +1148,7 @@ Default: True</li> <dd id="Teradata.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="Teradata.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="Teradata.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="Teradata.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="Teradata.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="Teradata.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="Teradata.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/dialects/trino.html b/docs/sqlglot/dialects/trino.html index ac73d6a..e3a35a4 100644 --- a/docs/sqlglot/dialects/trino.html +++ b/docs/sqlglot/dialects/trino.html @@ -36,6 +36,9 @@ <li> <a class="class" href="#Trino.Generator">Trino.Generator</a> <ul class="memberlist"> + <li> + <a class="function" href="#Trino.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -125,6 +128,10 @@ <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="Trino.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="Trino.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="Trino.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="Trino.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="Trino.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="Trino.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="Trino.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="Trino.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="Trino.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -195,6 +202,60 @@ Default: True</li> </div> + <div id="Trino.Generator.can_identify" class="classattr"> + <input id="Trino.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="Trino.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Trino.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Trino.Generator.can_identify-247"><a href="#Trino.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="Trino.Generator.can_identify-248"><a href="#Trino.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Trino.Generator.can_identify-249"><a href="#Trino.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="Trino.Generator.can_identify-250"><a href="#Trino.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="Trino.Generator.can_identify-251"><a href="#Trino.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="Trino.Generator.can_identify-252"><a href="#Trino.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="Trino.Generator.can_identify-253"><a href="#Trino.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="Trino.Generator.can_identify-254"><a href="#Trino.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="Trino.Generator.can_identify-255"><a href="#Trino.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="Trino.Generator.can_identify-256"><a href="#Trino.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="Trino.Generator.can_identify-257"><a href="#Trino.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="Trino.Generator.can_identify-258"><a href="#Trino.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="Trino.Generator.can_identify-259"><a href="#Trino.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="Trino.Generator.can_identify-260"><a href="#Trino.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="Trino.Generator.can_identify-261"><a href="#Trino.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Trino.Generator.can_identify-262"><a href="#Trino.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="Trino.Generator.can_identify-263"><a href="#Trino.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="Trino.Generator.can_identify-264"><a href="#Trino.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="Trino.Generator.can_identify-265"><a href="#Trino.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="Trino.Generator.can_identify-266"><a href="#Trino.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -297,6 +358,7 @@ Default: True</li> <dd id="Trino.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="Trino.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="Trino.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="Trino.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="Trino.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="Trino.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="Trino.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/dialects/tsql.html b/docs/sqlglot/dialects/tsql.html index ff7988f..ccac1f4 100644 --- a/docs/sqlglot/dialects/tsql.html +++ b/docs/sqlglot/dialects/tsql.html @@ -60,6 +60,9 @@ <li> <a class="function" href="#TSQL.Generator.returnsproperty_sql">returnsproperty_sql</a> </li> + <li> + <a class="function" href="#TSQL.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -1030,6 +1033,10 @@ <div><dt><a href="dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="TSQL.get_or_raise" class="function"><a href="dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="TSQL.format_time" class="function"><a href="dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="TSQL.normalize_identifier" class="function"><a href="dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="TSQL.case_sensitive" class="function"><a href="dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="TSQL.can_identify" class="function"><a href="dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="TSQL.quote_identifier" class="function"><a href="dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="TSQL.parse" class="function"><a href="dialect.html#Dialect.parse">parse</a></dd> <dd id="TSQL.parse_into" class="function"><a href="dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="TSQL.generate" class="function"><a href="dialect.html#Dialect.generate">generate</a></dd> @@ -1495,6 +1502,60 @@ Default: True</li> </div> + <div id="TSQL.Generator.can_identify" class="classattr"> + <input id="TSQL.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="TSQL.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#TSQL.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="TSQL.Generator.can_identify-247"><a href="#TSQL.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="TSQL.Generator.can_identify-248"><a href="#TSQL.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="TSQL.Generator.can_identify-249"><a href="#TSQL.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="TSQL.Generator.can_identify-250"><a href="#TSQL.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="TSQL.Generator.can_identify-251"><a href="#TSQL.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="TSQL.Generator.can_identify-252"><a href="#TSQL.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="TSQL.Generator.can_identify-253"><a href="#TSQL.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="TSQL.Generator.can_identify-254"><a href="#TSQL.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="TSQL.Generator.can_identify-255"><a href="#TSQL.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="TSQL.Generator.can_identify-256"><a href="#TSQL.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="TSQL.Generator.can_identify-257"><a href="#TSQL.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="TSQL.Generator.can_identify-258"><a href="#TSQL.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="TSQL.Generator.can_identify-259"><a href="#TSQL.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="TSQL.Generator.can_identify-260"><a href="#TSQL.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="TSQL.Generator.can_identify-261"><a href="#TSQL.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="TSQL.Generator.can_identify-262"><a href="#TSQL.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="TSQL.Generator.can_identify-263"><a href="#TSQL.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="TSQL.Generator.can_identify-264"><a href="#TSQL.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="TSQL.Generator.can_identify-265"><a href="#TSQL.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="TSQL.Generator.can_identify-266"><a href="#TSQL.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -1596,6 +1657,7 @@ Default: True</li> <dd id="TSQL.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="TSQL.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="TSQL.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="TSQL.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="TSQL.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="TSQL.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="TSQL.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/executor/python.html b/docs/sqlglot/executor/python.html index d54561d..796fce7 100644 --- a/docs/sqlglot/executor/python.html +++ b/docs/sqlglot/executor/python.html @@ -96,6 +96,9 @@ <li> <a class="class" href="#Python.Generator">Python.Generator</a> <ul class="memberlist"> + <li> + <a class="function" href="#Python.Generator.can_identify">can_identify</a> + </li> </ul> </li> @@ -1542,6 +1545,10 @@ <div><dt><a href="../dialects/dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></dt> <dd id="Python.get_or_raise" class="function"><a href="../dialects/dialect.html#Dialect.get_or_raise">get_or_raise</a></dd> <dd id="Python.format_time" class="function"><a href="../dialects/dialect.html#Dialect.format_time">format_time</a></dd> + <dd id="Python.normalize_identifier" class="function"><a href="../dialects/dialect.html#Dialect.normalize_identifier">normalize_identifier</a></dd> + <dd id="Python.case_sensitive" class="function"><a href="../dialects/dialect.html#Dialect.case_sensitive">case_sensitive</a></dd> + <dd id="Python.can_identify" class="function"><a href="../dialects/dialect.html#Dialect.can_identify">can_identify</a></dd> + <dd id="Python.quote_identifier" class="function"><a href="../dialects/dialect.html#Dialect.quote_identifier">quote_identifier</a></dd> <dd id="Python.parse" class="function"><a href="../dialects/dialect.html#Dialect.parse">parse</a></dd> <dd id="Python.parse_into" class="function"><a href="../dialects/dialect.html#Dialect.parse_into">parse_into</a></dd> <dd id="Python.generate" class="function"><a href="../dialects/dialect.html#Dialect.generate">generate</a></dd> @@ -1661,6 +1668,60 @@ Default: True</li> </div> + <div id="Python.Generator.can_identify" class="classattr"> + <input id="Python.Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="Python.Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Python.Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Python.Generator.can_identify-247"><a href="#Python.Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="Python.Generator.can_identify-248"><a href="#Python.Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Python.Generator.can_identify-249"><a href="#Python.Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="Python.Generator.can_identify-250"><a href="#Python.Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="Python.Generator.can_identify-251"><a href="#Python.Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="Python.Generator.can_identify-252"><a href="#Python.Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="Python.Generator.can_identify-253"><a href="#Python.Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="Python.Generator.can_identify-254"><a href="#Python.Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="Python.Generator.can_identify-255"><a href="#Python.Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="Python.Generator.can_identify-256"><a href="#Python.Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="Python.Generator.can_identify-257"><a href="#Python.Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="Python.Generator.can_identify-258"><a href="#Python.Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="Python.Generator.can_identify-259"><a href="#Python.Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="Python.Generator.can_identify-260"><a href="#Python.Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="Python.Generator.can_identify-261"><a href="#Python.Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Python.Generator.can_identify-262"><a href="#Python.Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="Python.Generator.can_identify-263"><a href="#Python.Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="Python.Generator.can_identify-264"><a href="#Python.Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="Python.Generator.can_identify-265"><a href="#Python.Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="Python.Generator.can_identify-266"><a href="#Python.Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> + +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> + + + </div> <div class="inherited"> <h5>Inherited Members</h5> <dl> @@ -1763,6 +1824,7 @@ Default: True</li> <dd id="Python.Generator.pragma_sql" class="function"><a href="../generator.html#Generator.pragma_sql">pragma_sql</a></dd> <dd id="Python.Generator.lock_sql" class="function"><a href="../generator.html#Generator.lock_sql">lock_sql</a></dd> <dd id="Python.Generator.literal_sql" class="function"><a href="../generator.html#Generator.literal_sql">literal_sql</a></dd> + <dd id="Python.Generator.escape_str" class="function"><a href="../generator.html#Generator.escape_str">escape_str</a></dd> <dd id="Python.Generator.loaddata_sql" class="function"><a href="../generator.html#Generator.loaddata_sql">loaddata_sql</a></dd> <dd id="Python.Generator.null_sql" class="function"><a href="../generator.html#Generator.null_sql">null_sql</a></dd> <dd id="Python.Generator.boolean_sql" class="function"><a href="../generator.html#Generator.boolean_sql">boolean_sql</a></dd> diff --git a/docs/sqlglot/expressions.html b/docs/sqlglot/expressions.html index 82b8c21..138c7fc 100644 --- a/docs/sqlglot/expressions.html +++ b/docs/sqlglot/expressions.html @@ -828,6 +828,12 @@ </li> <li> + <a class="class" href="#CopyGrantsProperty">CopyGrantsProperty</a> + <ul class="memberlist"> + </ul> + + </li> + <li> <a class="class" href="#DataBlocksizeProperty">DataBlocksizeProperty</a> <ul class="memberlist"> </ul> @@ -5137,4033 +5143,4043 @@ SQL expressions, such as <code><a href="#select">sqlglot.expressions.select</a>< </span><span id="L-1844"><a href="#L-1844"><span class="linenos">1844</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-1845"><a href="#L-1845"><span class="linenos">1845</span></a> </span><span id="L-1846"><a href="#L-1846"><span class="linenos">1846</span></a> -</span><span id="L-1847"><a href="#L-1847"><span class="linenos">1847</span></a><span class="k">class</span> <span class="nc">DataBlocksizeProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1848"><a href="#L-1848"><span class="linenos">1848</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-1849"><a href="#L-1849"><span class="linenos">1849</span></a> <span class="s2">"size"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-1850"><a href="#L-1850"><span class="linenos">1850</span></a> <span class="s2">"units"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-1851"><a href="#L-1851"><span class="linenos">1851</span></a> <span class="s2">"minimum"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-1852"><a href="#L-1852"><span class="linenos">1852</span></a> <span class="s2">"maximum"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-1853"><a href="#L-1853"><span class="linenos">1853</span></a> <span class="s2">"default"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-1854"><a href="#L-1854"><span class="linenos">1854</span></a> <span class="p">}</span> -</span><span id="L-1855"><a href="#L-1855"><span class="linenos">1855</span></a> -</span><span id="L-1856"><a href="#L-1856"><span class="linenos">1856</span></a> -</span><span id="L-1857"><a href="#L-1857"><span class="linenos">1857</span></a><span class="k">class</span> <span class="nc">DefinerProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1858"><a href="#L-1858"><span class="linenos">1858</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-1847"><a href="#L-1847"><span class="linenos">1847</span></a><span class="k">class</span> <span class="nc">CopyGrantsProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1848"><a href="#L-1848"><span class="linenos">1848</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-1849"><a href="#L-1849"><span class="linenos">1849</span></a> +</span><span id="L-1850"><a href="#L-1850"><span class="linenos">1850</span></a> +</span><span id="L-1851"><a href="#L-1851"><span class="linenos">1851</span></a><span class="k">class</span> <span class="nc">DataBlocksizeProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1852"><a href="#L-1852"><span class="linenos">1852</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-1853"><a href="#L-1853"><span class="linenos">1853</span></a> <span class="s2">"size"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-1854"><a href="#L-1854"><span class="linenos">1854</span></a> <span class="s2">"units"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-1855"><a href="#L-1855"><span class="linenos">1855</span></a> <span class="s2">"minimum"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-1856"><a href="#L-1856"><span class="linenos">1856</span></a> <span class="s2">"maximum"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-1857"><a href="#L-1857"><span class="linenos">1857</span></a> <span class="s2">"default"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-1858"><a href="#L-1858"><span class="linenos">1858</span></a> <span class="p">}</span> </span><span id="L-1859"><a href="#L-1859"><span class="linenos">1859</span></a> </span><span id="L-1860"><a href="#L-1860"><span class="linenos">1860</span></a> -</span><span id="L-1861"><a href="#L-1861"><span class="linenos">1861</span></a><span class="k">class</span> <span class="nc">DistKeyProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1861"><a href="#L-1861"><span class="linenos">1861</span></a><span class="k">class</span> <span class="nc">DefinerProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> </span><span id="L-1862"><a href="#L-1862"><span class="linenos">1862</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-1863"><a href="#L-1863"><span class="linenos">1863</span></a> </span><span id="L-1864"><a href="#L-1864"><span class="linenos">1864</span></a> -</span><span id="L-1865"><a href="#L-1865"><span class="linenos">1865</span></a><span class="k">class</span> <span class="nc">DistStyleProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1865"><a href="#L-1865"><span class="linenos">1865</span></a><span class="k">class</span> <span class="nc">DistKeyProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> </span><span id="L-1866"><a href="#L-1866"><span class="linenos">1866</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-1867"><a href="#L-1867"><span class="linenos">1867</span></a> </span><span id="L-1868"><a href="#L-1868"><span class="linenos">1868</span></a> -</span><span id="L-1869"><a href="#L-1869"><span class="linenos">1869</span></a><span class="k">class</span> <span class="nc">EngineProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1869"><a href="#L-1869"><span class="linenos">1869</span></a><span class="k">class</span> <span class="nc">DistStyleProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> </span><span id="L-1870"><a href="#L-1870"><span class="linenos">1870</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-1871"><a href="#L-1871"><span class="linenos">1871</span></a> </span><span id="L-1872"><a href="#L-1872"><span class="linenos">1872</span></a> -</span><span id="L-1873"><a href="#L-1873"><span class="linenos">1873</span></a><span class="k">class</span> <span class="nc">ToTableProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1873"><a href="#L-1873"><span class="linenos">1873</span></a><span class="k">class</span> <span class="nc">EngineProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> </span><span id="L-1874"><a href="#L-1874"><span class="linenos">1874</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-1875"><a href="#L-1875"><span class="linenos">1875</span></a> </span><span id="L-1876"><a href="#L-1876"><span class="linenos">1876</span></a> -</span><span id="L-1877"><a href="#L-1877"><span class="linenos">1877</span></a><span class="k">class</span> <span class="nc">ExecuteAsProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1877"><a href="#L-1877"><span class="linenos">1877</span></a><span class="k">class</span> <span class="nc">ToTableProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> </span><span id="L-1878"><a href="#L-1878"><span class="linenos">1878</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-1879"><a href="#L-1879"><span class="linenos">1879</span></a> </span><span id="L-1880"><a href="#L-1880"><span class="linenos">1880</span></a> -</span><span id="L-1881"><a href="#L-1881"><span class="linenos">1881</span></a><span class="k">class</span> <span class="nc">ExternalProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1882"><a href="#L-1882"><span class="linenos">1882</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-1881"><a href="#L-1881"><span class="linenos">1881</span></a><span class="k">class</span> <span class="nc">ExecuteAsProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1882"><a href="#L-1882"><span class="linenos">1882</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-1883"><a href="#L-1883"><span class="linenos">1883</span></a> </span><span id="L-1884"><a href="#L-1884"><span class="linenos">1884</span></a> -</span><span id="L-1885"><a href="#L-1885"><span class="linenos">1885</span></a><span class="k">class</span> <span class="nc">FallbackProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1886"><a href="#L-1886"><span class="linenos">1886</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"no"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"protection"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-1885"><a href="#L-1885"><span class="linenos">1885</span></a><span class="k">class</span> <span class="nc">ExternalProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1886"><a href="#L-1886"><span class="linenos">1886</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-1887"><a href="#L-1887"><span class="linenos">1887</span></a> </span><span id="L-1888"><a href="#L-1888"><span class="linenos">1888</span></a> -</span><span id="L-1889"><a href="#L-1889"><span class="linenos">1889</span></a><span class="k">class</span> <span class="nc">FileFormatProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1890"><a href="#L-1890"><span class="linenos">1890</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-1889"><a href="#L-1889"><span class="linenos">1889</span></a><span class="k">class</span> <span class="nc">FallbackProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1890"><a href="#L-1890"><span class="linenos">1890</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"no"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"protection"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-1891"><a href="#L-1891"><span class="linenos">1891</span></a> </span><span id="L-1892"><a href="#L-1892"><span class="linenos">1892</span></a> -</span><span id="L-1893"><a href="#L-1893"><span class="linenos">1893</span></a><span class="k">class</span> <span class="nc">FreespaceProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1894"><a href="#L-1894"><span class="linenos">1894</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-1893"><a href="#L-1893"><span class="linenos">1893</span></a><span class="k">class</span> <span class="nc">FileFormatProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1894"><a href="#L-1894"><span class="linenos">1894</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-1895"><a href="#L-1895"><span class="linenos">1895</span></a> </span><span id="L-1896"><a href="#L-1896"><span class="linenos">1896</span></a> -</span><span id="L-1897"><a href="#L-1897"><span class="linenos">1897</span></a><span class="k">class</span> <span class="nc">InputOutputFormat</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-1898"><a href="#L-1898"><span class="linenos">1898</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"input_format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"output_format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-1897"><a href="#L-1897"><span class="linenos">1897</span></a><span class="k">class</span> <span class="nc">FreespaceProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1898"><a href="#L-1898"><span class="linenos">1898</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-1899"><a href="#L-1899"><span class="linenos">1899</span></a> </span><span id="L-1900"><a href="#L-1900"><span class="linenos">1900</span></a> -</span><span id="L-1901"><a href="#L-1901"><span class="linenos">1901</span></a><span class="k">class</span> <span class="nc">IsolatedLoadingProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1902"><a href="#L-1902"><span class="linenos">1902</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-1903"><a href="#L-1903"><span class="linenos">1903</span></a> <span class="s2">"no"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-1904"><a href="#L-1904"><span class="linenos">1904</span></a> <span class="s2">"concurrent"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-1905"><a href="#L-1905"><span class="linenos">1905</span></a> <span class="s2">"for_all"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-1906"><a href="#L-1906"><span class="linenos">1906</span></a> <span class="s2">"for_insert"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-1907"><a href="#L-1907"><span class="linenos">1907</span></a> <span class="s2">"for_none"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-1908"><a href="#L-1908"><span class="linenos">1908</span></a> <span class="p">}</span> -</span><span id="L-1909"><a href="#L-1909"><span class="linenos">1909</span></a> -</span><span id="L-1910"><a href="#L-1910"><span class="linenos">1910</span></a> -</span><span id="L-1911"><a href="#L-1911"><span class="linenos">1911</span></a><span class="k">class</span> <span class="nc">JournalProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1912"><a href="#L-1912"><span class="linenos">1912</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-1913"><a href="#L-1913"><span class="linenos">1913</span></a> <span class="s2">"no"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-1914"><a href="#L-1914"><span class="linenos">1914</span></a> <span class="s2">"dual"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-1915"><a href="#L-1915"><span class="linenos">1915</span></a> <span class="s2">"before"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-1916"><a href="#L-1916"><span class="linenos">1916</span></a> <span class="s2">"local"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-1917"><a href="#L-1917"><span class="linenos">1917</span></a> <span class="s2">"after"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-1918"><a href="#L-1918"><span class="linenos">1918</span></a> <span class="p">}</span> -</span><span id="L-1919"><a href="#L-1919"><span class="linenos">1919</span></a> -</span><span id="L-1920"><a href="#L-1920"><span class="linenos">1920</span></a> -</span><span id="L-1921"><a href="#L-1921"><span class="linenos">1921</span></a><span class="k">class</span> <span class="nc">LanguageProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1922"><a href="#L-1922"><span class="linenos">1922</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-1901"><a href="#L-1901"><span class="linenos">1901</span></a><span class="k">class</span> <span class="nc">InputOutputFormat</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-1902"><a href="#L-1902"><span class="linenos">1902</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"input_format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"output_format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-1903"><a href="#L-1903"><span class="linenos">1903</span></a> +</span><span id="L-1904"><a href="#L-1904"><span class="linenos">1904</span></a> +</span><span id="L-1905"><a href="#L-1905"><span class="linenos">1905</span></a><span class="k">class</span> <span class="nc">IsolatedLoadingProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1906"><a href="#L-1906"><span class="linenos">1906</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-1907"><a href="#L-1907"><span class="linenos">1907</span></a> <span class="s2">"no"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-1908"><a href="#L-1908"><span class="linenos">1908</span></a> <span class="s2">"concurrent"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-1909"><a href="#L-1909"><span class="linenos">1909</span></a> <span class="s2">"for_all"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-1910"><a href="#L-1910"><span class="linenos">1910</span></a> <span class="s2">"for_insert"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-1911"><a href="#L-1911"><span class="linenos">1911</span></a> <span class="s2">"for_none"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-1912"><a href="#L-1912"><span class="linenos">1912</span></a> <span class="p">}</span> +</span><span id="L-1913"><a href="#L-1913"><span class="linenos">1913</span></a> +</span><span id="L-1914"><a href="#L-1914"><span class="linenos">1914</span></a> +</span><span id="L-1915"><a href="#L-1915"><span class="linenos">1915</span></a><span class="k">class</span> <span class="nc">JournalProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1916"><a href="#L-1916"><span class="linenos">1916</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-1917"><a href="#L-1917"><span class="linenos">1917</span></a> <span class="s2">"no"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-1918"><a href="#L-1918"><span class="linenos">1918</span></a> <span class="s2">"dual"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-1919"><a href="#L-1919"><span class="linenos">1919</span></a> <span class="s2">"before"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-1920"><a href="#L-1920"><span class="linenos">1920</span></a> <span class="s2">"local"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-1921"><a href="#L-1921"><span class="linenos">1921</span></a> <span class="s2">"after"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-1922"><a href="#L-1922"><span class="linenos">1922</span></a> <span class="p">}</span> </span><span id="L-1923"><a href="#L-1923"><span class="linenos">1923</span></a> </span><span id="L-1924"><a href="#L-1924"><span class="linenos">1924</span></a> -</span><span id="L-1925"><a href="#L-1925"><span class="linenos">1925</span></a><span class="k">class</span> <span class="nc">DictProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1926"><a href="#L-1926"><span class="linenos">1926</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"settings"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-1925"><a href="#L-1925"><span class="linenos">1925</span></a><span class="k">class</span> <span class="nc">LanguageProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1926"><a href="#L-1926"><span class="linenos">1926</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-1927"><a href="#L-1927"><span class="linenos">1927</span></a> </span><span id="L-1928"><a href="#L-1928"><span class="linenos">1928</span></a> -</span><span id="L-1929"><a href="#L-1929"><span class="linenos">1929</span></a><span class="k">class</span> <span class="nc">DictSubProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1930"><a href="#L-1930"><span class="linenos">1930</span></a> <span class="k">pass</span> +</span><span id="L-1929"><a href="#L-1929"><span class="linenos">1929</span></a><span class="k">class</span> <span class="nc">DictProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1930"><a href="#L-1930"><span class="linenos">1930</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"settings"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-1931"><a href="#L-1931"><span class="linenos">1931</span></a> </span><span id="L-1932"><a href="#L-1932"><span class="linenos">1932</span></a> -</span><span id="L-1933"><a href="#L-1933"><span class="linenos">1933</span></a><span class="k">class</span> <span class="nc">DictRange</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1934"><a href="#L-1934"><span class="linenos">1934</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"min"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"max"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-1933"><a href="#L-1933"><span class="linenos">1933</span></a><span class="k">class</span> <span class="nc">DictSubProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1934"><a href="#L-1934"><span class="linenos">1934</span></a> <span class="k">pass</span> </span><span id="L-1935"><a href="#L-1935"><span class="linenos">1935</span></a> </span><span id="L-1936"><a href="#L-1936"><span class="linenos">1936</span></a> -</span><span id="L-1937"><a href="#L-1937"><span class="linenos">1937</span></a><span class="c1"># Clickhouse CREATE ... ON CLUSTER modifier</span> -</span><span id="L-1938"><a href="#L-1938"><span class="linenos">1938</span></a><span class="c1"># https://clickhouse.com/docs/en/sql-reference/distributed-ddl</span> -</span><span id="L-1939"><a href="#L-1939"><span class="linenos">1939</span></a><span class="k">class</span> <span class="nc">OnCluster</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1940"><a href="#L-1940"><span class="linenos">1940</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-1941"><a href="#L-1941"><span class="linenos">1941</span></a> -</span><span id="L-1942"><a href="#L-1942"><span class="linenos">1942</span></a> -</span><span id="L-1943"><a href="#L-1943"><span class="linenos">1943</span></a><span class="k">class</span> <span class="nc">LikeProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1944"><a href="#L-1944"><span class="linenos">1944</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-1937"><a href="#L-1937"><span class="linenos">1937</span></a><span class="k">class</span> <span class="nc">DictRange</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1938"><a href="#L-1938"><span class="linenos">1938</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"min"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"max"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-1939"><a href="#L-1939"><span class="linenos">1939</span></a> +</span><span id="L-1940"><a href="#L-1940"><span class="linenos">1940</span></a> +</span><span id="L-1941"><a href="#L-1941"><span class="linenos">1941</span></a><span class="c1"># Clickhouse CREATE ... ON CLUSTER modifier</span> +</span><span id="L-1942"><a href="#L-1942"><span class="linenos">1942</span></a><span class="c1"># https://clickhouse.com/docs/en/sql-reference/distributed-ddl</span> +</span><span id="L-1943"><a href="#L-1943"><span class="linenos">1943</span></a><span class="k">class</span> <span class="nc">OnCluster</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1944"><a href="#L-1944"><span class="linenos">1944</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-1945"><a href="#L-1945"><span class="linenos">1945</span></a> </span><span id="L-1946"><a href="#L-1946"><span class="linenos">1946</span></a> -</span><span id="L-1947"><a href="#L-1947"><span class="linenos">1947</span></a><span class="k">class</span> <span class="nc">LocationProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1948"><a href="#L-1948"><span class="linenos">1948</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-1947"><a href="#L-1947"><span class="linenos">1947</span></a><span class="k">class</span> <span class="nc">LikeProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1948"><a href="#L-1948"><span class="linenos">1948</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-1949"><a href="#L-1949"><span class="linenos">1949</span></a> </span><span id="L-1950"><a href="#L-1950"><span class="linenos">1950</span></a> -</span><span id="L-1951"><a href="#L-1951"><span class="linenos">1951</span></a><span class="k">class</span> <span class="nc">LockingProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1952"><a href="#L-1952"><span class="linenos">1952</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-1953"><a href="#L-1953"><span class="linenos">1953</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-1954"><a href="#L-1954"><span class="linenos">1954</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-1955"><a href="#L-1955"><span class="linenos">1955</span></a> <span class="s2">"for_or_in"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-1956"><a href="#L-1956"><span class="linenos">1956</span></a> <span class="s2">"lock_type"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-1957"><a href="#L-1957"><span class="linenos">1957</span></a> <span class="s2">"override"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-1958"><a href="#L-1958"><span class="linenos">1958</span></a> <span class="p">}</span> -</span><span id="L-1959"><a href="#L-1959"><span class="linenos">1959</span></a> -</span><span id="L-1960"><a href="#L-1960"><span class="linenos">1960</span></a> -</span><span id="L-1961"><a href="#L-1961"><span class="linenos">1961</span></a><span class="k">class</span> <span class="nc">LogProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1962"><a href="#L-1962"><span class="linenos">1962</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"no"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-1951"><a href="#L-1951"><span class="linenos">1951</span></a><span class="k">class</span> <span class="nc">LocationProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1952"><a href="#L-1952"><span class="linenos">1952</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-1953"><a href="#L-1953"><span class="linenos">1953</span></a> +</span><span id="L-1954"><a href="#L-1954"><span class="linenos">1954</span></a> +</span><span id="L-1955"><a href="#L-1955"><span class="linenos">1955</span></a><span class="k">class</span> <span class="nc">LockingProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1956"><a href="#L-1956"><span class="linenos">1956</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-1957"><a href="#L-1957"><span class="linenos">1957</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-1958"><a href="#L-1958"><span class="linenos">1958</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-1959"><a href="#L-1959"><span class="linenos">1959</span></a> <span class="s2">"for_or_in"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-1960"><a href="#L-1960"><span class="linenos">1960</span></a> <span class="s2">"lock_type"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-1961"><a href="#L-1961"><span class="linenos">1961</span></a> <span class="s2">"override"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-1962"><a href="#L-1962"><span class="linenos">1962</span></a> <span class="p">}</span> </span><span id="L-1963"><a href="#L-1963"><span class="linenos">1963</span></a> </span><span id="L-1964"><a href="#L-1964"><span class="linenos">1964</span></a> -</span><span id="L-1965"><a href="#L-1965"><span class="linenos">1965</span></a><span class="k">class</span> <span class="nc">MaterializedProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1966"><a href="#L-1966"><span class="linenos">1966</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-1965"><a href="#L-1965"><span class="linenos">1965</span></a><span class="k">class</span> <span class="nc">LogProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1966"><a href="#L-1966"><span class="linenos">1966</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"no"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-1967"><a href="#L-1967"><span class="linenos">1967</span></a> </span><span id="L-1968"><a href="#L-1968"><span class="linenos">1968</span></a> -</span><span id="L-1969"><a href="#L-1969"><span class="linenos">1969</span></a><span class="k">class</span> <span class="nc">MergeBlockRatioProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1970"><a href="#L-1970"><span class="linenos">1970</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"no"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-1969"><a href="#L-1969"><span class="linenos">1969</span></a><span class="k">class</span> <span class="nc">MaterializedProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1970"><a href="#L-1970"><span class="linenos">1970</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-1971"><a href="#L-1971"><span class="linenos">1971</span></a> </span><span id="L-1972"><a href="#L-1972"><span class="linenos">1972</span></a> -</span><span id="L-1973"><a href="#L-1973"><span class="linenos">1973</span></a><span class="k">class</span> <span class="nc">NoPrimaryIndexProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1974"><a href="#L-1974"><span class="linenos">1974</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-1973"><a href="#L-1973"><span class="linenos">1973</span></a><span class="k">class</span> <span class="nc">MergeBlockRatioProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1974"><a href="#L-1974"><span class="linenos">1974</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"no"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-1975"><a href="#L-1975"><span class="linenos">1975</span></a> </span><span id="L-1976"><a href="#L-1976"><span class="linenos">1976</span></a> -</span><span id="L-1977"><a href="#L-1977"><span class="linenos">1977</span></a><span class="k">class</span> <span class="nc">OnCommitProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1978"><a href="#L-1978"><span class="linenos">1978</span></a> <span class="n">arg_type</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"delete"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-1977"><a href="#L-1977"><span class="linenos">1977</span></a><span class="k">class</span> <span class="nc">NoPrimaryIndexProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1978"><a href="#L-1978"><span class="linenos">1978</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{}</span> </span><span id="L-1979"><a href="#L-1979"><span class="linenos">1979</span></a> </span><span id="L-1980"><a href="#L-1980"><span class="linenos">1980</span></a> -</span><span id="L-1981"><a href="#L-1981"><span class="linenos">1981</span></a><span class="k">class</span> <span class="nc">PartitionedByProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1982"><a href="#L-1982"><span class="linenos">1982</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-1981"><a href="#L-1981"><span class="linenos">1981</span></a><span class="k">class</span> <span class="nc">OnCommitProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1982"><a href="#L-1982"><span class="linenos">1982</span></a> <span class="n">arg_type</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"delete"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-1983"><a href="#L-1983"><span class="linenos">1983</span></a> </span><span id="L-1984"><a href="#L-1984"><span class="linenos">1984</span></a> -</span><span id="L-1985"><a href="#L-1985"><span class="linenos">1985</span></a><span class="k">class</span> <span class="nc">ReturnsProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1986"><a href="#L-1986"><span class="linenos">1986</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"is_table"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"table"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-1985"><a href="#L-1985"><span class="linenos">1985</span></a><span class="k">class</span> <span class="nc">PartitionedByProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1986"><a href="#L-1986"><span class="linenos">1986</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-1987"><a href="#L-1987"><span class="linenos">1987</span></a> </span><span id="L-1988"><a href="#L-1988"><span class="linenos">1988</span></a> -</span><span id="L-1989"><a href="#L-1989"><span class="linenos">1989</span></a><span class="k">class</span> <span class="nc">RowFormatProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1990"><a href="#L-1990"><span class="linenos">1990</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-1989"><a href="#L-1989"><span class="linenos">1989</span></a><span class="k">class</span> <span class="nc">ReturnsProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1990"><a href="#L-1990"><span class="linenos">1990</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"is_table"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"table"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-1991"><a href="#L-1991"><span class="linenos">1991</span></a> </span><span id="L-1992"><a href="#L-1992"><span class="linenos">1992</span></a> -</span><span id="L-1993"><a href="#L-1993"><span class="linenos">1993</span></a><span class="k">class</span> <span class="nc">RowFormatDelimitedProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-1994"><a href="#L-1994"><span class="linenos">1994</span></a> <span class="c1"># https://cwiki.apache.org/confluence/display/hive/languagemanual+dml</span> -</span><span id="L-1995"><a href="#L-1995"><span class="linenos">1995</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-1996"><a href="#L-1996"><span class="linenos">1996</span></a> <span class="s2">"fields"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-1997"><a href="#L-1997"><span class="linenos">1997</span></a> <span class="s2">"escaped"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-1998"><a href="#L-1998"><span class="linenos">1998</span></a> <span class="s2">"collection_items"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-1999"><a href="#L-1999"><span class="linenos">1999</span></a> <span class="s2">"map_keys"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2000"><a href="#L-2000"><span class="linenos">2000</span></a> <span class="s2">"lines"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2001"><a href="#L-2001"><span class="linenos">2001</span></a> <span class="s2">"null"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2002"><a href="#L-2002"><span class="linenos">2002</span></a> <span class="s2">"serde"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2003"><a href="#L-2003"><span class="linenos">2003</span></a> <span class="p">}</span> -</span><span id="L-2004"><a href="#L-2004"><span class="linenos">2004</span></a> -</span><span id="L-2005"><a href="#L-2005"><span class="linenos">2005</span></a> -</span><span id="L-2006"><a href="#L-2006"><span class="linenos">2006</span></a><span class="k">class</span> <span class="nc">RowFormatSerdeProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-2007"><a href="#L-2007"><span class="linenos">2007</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-1993"><a href="#L-1993"><span class="linenos">1993</span></a><span class="k">class</span> <span class="nc">RowFormatProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1994"><a href="#L-1994"><span class="linenos">1994</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-1995"><a href="#L-1995"><span class="linenos">1995</span></a> +</span><span id="L-1996"><a href="#L-1996"><span class="linenos">1996</span></a> +</span><span id="L-1997"><a href="#L-1997"><span class="linenos">1997</span></a><span class="k">class</span> <span class="nc">RowFormatDelimitedProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-1998"><a href="#L-1998"><span class="linenos">1998</span></a> <span class="c1"># https://cwiki.apache.org/confluence/display/hive/languagemanual+dml</span> +</span><span id="L-1999"><a href="#L-1999"><span class="linenos">1999</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-2000"><a href="#L-2000"><span class="linenos">2000</span></a> <span class="s2">"fields"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2001"><a href="#L-2001"><span class="linenos">2001</span></a> <span class="s2">"escaped"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2002"><a href="#L-2002"><span class="linenos">2002</span></a> <span class="s2">"collection_items"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2003"><a href="#L-2003"><span class="linenos">2003</span></a> <span class="s2">"map_keys"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2004"><a href="#L-2004"><span class="linenos">2004</span></a> <span class="s2">"lines"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2005"><a href="#L-2005"><span class="linenos">2005</span></a> <span class="s2">"null"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2006"><a href="#L-2006"><span class="linenos">2006</span></a> <span class="s2">"serde"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2007"><a href="#L-2007"><span class="linenos">2007</span></a> <span class="p">}</span> </span><span id="L-2008"><a href="#L-2008"><span class="linenos">2008</span></a> </span><span id="L-2009"><a href="#L-2009"><span class="linenos">2009</span></a> -</span><span id="L-2010"><a href="#L-2010"><span class="linenos">2010</span></a><span class="k">class</span> <span class="nc">SchemaCommentProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-2010"><a href="#L-2010"><span class="linenos">2010</span></a><span class="k">class</span> <span class="nc">RowFormatSerdeProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> </span><span id="L-2011"><a href="#L-2011"><span class="linenos">2011</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-2012"><a href="#L-2012"><span class="linenos">2012</span></a> </span><span id="L-2013"><a href="#L-2013"><span class="linenos">2013</span></a> -</span><span id="L-2014"><a href="#L-2014"><span class="linenos">2014</span></a><span class="k">class</span> <span class="nc">SerdeProperties</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-2015"><a href="#L-2015"><span class="linenos">2015</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-2014"><a href="#L-2014"><span class="linenos">2014</span></a><span class="k">class</span> <span class="nc">SchemaCommentProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-2015"><a href="#L-2015"><span class="linenos">2015</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-2016"><a href="#L-2016"><span class="linenos">2016</span></a> </span><span id="L-2017"><a href="#L-2017"><span class="linenos">2017</span></a> -</span><span id="L-2018"><a href="#L-2018"><span class="linenos">2018</span></a><span class="k">class</span> <span class="nc">SetProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-2019"><a href="#L-2019"><span class="linenos">2019</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"multi"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-2018"><a href="#L-2018"><span class="linenos">2018</span></a><span class="k">class</span> <span class="nc">SerdeProperties</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-2019"><a href="#L-2019"><span class="linenos">2019</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-2020"><a href="#L-2020"><span class="linenos">2020</span></a> </span><span id="L-2021"><a href="#L-2021"><span class="linenos">2021</span></a> -</span><span id="L-2022"><a href="#L-2022"><span class="linenos">2022</span></a><span class="k">class</span> <span class="nc">SettingsProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-2023"><a href="#L-2023"><span class="linenos">2023</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-2022"><a href="#L-2022"><span class="linenos">2022</span></a><span class="k">class</span> <span class="nc">SetProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-2023"><a href="#L-2023"><span class="linenos">2023</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"multi"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-2024"><a href="#L-2024"><span class="linenos">2024</span></a> </span><span id="L-2025"><a href="#L-2025"><span class="linenos">2025</span></a> -</span><span id="L-2026"><a href="#L-2026"><span class="linenos">2026</span></a><span class="k">class</span> <span class="nc">SortKeyProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-2027"><a href="#L-2027"><span class="linenos">2027</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"compound"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-2026"><a href="#L-2026"><span class="linenos">2026</span></a><span class="k">class</span> <span class="nc">SettingsProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-2027"><a href="#L-2027"><span class="linenos">2027</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-2028"><a href="#L-2028"><span class="linenos">2028</span></a> </span><span id="L-2029"><a href="#L-2029"><span class="linenos">2029</span></a> -</span><span id="L-2030"><a href="#L-2030"><span class="linenos">2030</span></a><span class="k">class</span> <span class="nc">SqlSecurityProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-2031"><a href="#L-2031"><span class="linenos">2031</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"definer"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-2030"><a href="#L-2030"><span class="linenos">2030</span></a><span class="k">class</span> <span class="nc">SortKeyProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-2031"><a href="#L-2031"><span class="linenos">2031</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"compound"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-2032"><a href="#L-2032"><span class="linenos">2032</span></a> </span><span id="L-2033"><a href="#L-2033"><span class="linenos">2033</span></a> -</span><span id="L-2034"><a href="#L-2034"><span class="linenos">2034</span></a><span class="k">class</span> <span class="nc">StabilityProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-2035"><a href="#L-2035"><span class="linenos">2035</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-2034"><a href="#L-2034"><span class="linenos">2034</span></a><span class="k">class</span> <span class="nc">SqlSecurityProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-2035"><a href="#L-2035"><span class="linenos">2035</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"definer"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-2036"><a href="#L-2036"><span class="linenos">2036</span></a> </span><span id="L-2037"><a href="#L-2037"><span class="linenos">2037</span></a> -</span><span id="L-2038"><a href="#L-2038"><span class="linenos">2038</span></a><span class="k">class</span> <span class="nc">TemporaryProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-2039"><a href="#L-2039"><span class="linenos">2039</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-2038"><a href="#L-2038"><span class="linenos">2038</span></a><span class="k">class</span> <span class="nc">StabilityProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-2039"><a href="#L-2039"><span class="linenos">2039</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-2040"><a href="#L-2040"><span class="linenos">2040</span></a> </span><span id="L-2041"><a href="#L-2041"><span class="linenos">2041</span></a> -</span><span id="L-2042"><a href="#L-2042"><span class="linenos">2042</span></a><span class="k">class</span> <span class="nc">TransientProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-2043"><a href="#L-2043"><span class="linenos">2043</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-2042"><a href="#L-2042"><span class="linenos">2042</span></a><span class="k">class</span> <span class="nc">TemporaryProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-2043"><a href="#L-2043"><span class="linenos">2043</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{}</span> </span><span id="L-2044"><a href="#L-2044"><span class="linenos">2044</span></a> </span><span id="L-2045"><a href="#L-2045"><span class="linenos">2045</span></a> -</span><span id="L-2046"><a href="#L-2046"><span class="linenos">2046</span></a><span class="k">class</span> <span class="nc">VolatileProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-2046"><a href="#L-2046"><span class="linenos">2046</span></a><span class="k">class</span> <span class="nc">TransientProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> </span><span id="L-2047"><a href="#L-2047"><span class="linenos">2047</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-2048"><a href="#L-2048"><span class="linenos">2048</span></a> </span><span id="L-2049"><a href="#L-2049"><span class="linenos">2049</span></a> -</span><span id="L-2050"><a href="#L-2050"><span class="linenos">2050</span></a><span class="k">class</span> <span class="nc">WithDataProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-2051"><a href="#L-2051"><span class="linenos">2051</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"no"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"statistics"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-2050"><a href="#L-2050"><span class="linenos">2050</span></a><span class="k">class</span> <span class="nc">VolatileProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-2051"><a href="#L-2051"><span class="linenos">2051</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-2052"><a href="#L-2052"><span class="linenos">2052</span></a> </span><span id="L-2053"><a href="#L-2053"><span class="linenos">2053</span></a> -</span><span id="L-2054"><a href="#L-2054"><span class="linenos">2054</span></a><span class="k">class</span> <span class="nc">WithJournalTableProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-2055"><a href="#L-2055"><span class="linenos">2055</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-2054"><a href="#L-2054"><span class="linenos">2054</span></a><span class="k">class</span> <span class="nc">WithDataProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-2055"><a href="#L-2055"><span class="linenos">2055</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"no"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"statistics"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-2056"><a href="#L-2056"><span class="linenos">2056</span></a> </span><span id="L-2057"><a href="#L-2057"><span class="linenos">2057</span></a> -</span><span id="L-2058"><a href="#L-2058"><span class="linenos">2058</span></a><span class="k">class</span> <span class="nc">Properties</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-2059"><a href="#L-2059"><span class="linenos">2059</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-2058"><a href="#L-2058"><span class="linenos">2058</span></a><span class="k">class</span> <span class="nc">WithJournalTableProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-2059"><a href="#L-2059"><span class="linenos">2059</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-2060"><a href="#L-2060"><span class="linenos">2060</span></a> -</span><span id="L-2061"><a href="#L-2061"><span class="linenos">2061</span></a> <span class="n">NAME_TO_PROPERTY</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-2062"><a href="#L-2062"><span class="linenos">2062</span></a> <span class="s2">"ALGORITHM"</span><span class="p">:</span> <span class="n">AlgorithmProperty</span><span class="p">,</span> -</span><span id="L-2063"><a href="#L-2063"><span class="linenos">2063</span></a> <span class="s2">"AUTO_INCREMENT"</span><span class="p">:</span> <span class="n">AutoIncrementProperty</span><span class="p">,</span> -</span><span id="L-2064"><a href="#L-2064"><span class="linenos">2064</span></a> <span class="s2">"CHARACTER SET"</span><span class="p">:</span> <span class="n">CharacterSetProperty</span><span class="p">,</span> -</span><span id="L-2065"><a href="#L-2065"><span class="linenos">2065</span></a> <span class="s2">"COLLATE"</span><span class="p">:</span> <span class="n">CollateProperty</span><span class="p">,</span> -</span><span id="L-2066"><a href="#L-2066"><span class="linenos">2066</span></a> <span class="s2">"COMMENT"</span><span class="p">:</span> <span class="n">SchemaCommentProperty</span><span class="p">,</span> -</span><span id="L-2067"><a href="#L-2067"><span class="linenos">2067</span></a> <span class="s2">"DEFINER"</span><span class="p">:</span> <span class="n">DefinerProperty</span><span class="p">,</span> -</span><span id="L-2068"><a href="#L-2068"><span class="linenos">2068</span></a> <span class="s2">"DISTKEY"</span><span class="p">:</span> <span class="n">DistKeyProperty</span><span class="p">,</span> -</span><span id="L-2069"><a href="#L-2069"><span class="linenos">2069</span></a> <span class="s2">"DISTSTYLE"</span><span class="p">:</span> <span class="n">DistStyleProperty</span><span class="p">,</span> -</span><span id="L-2070"><a href="#L-2070"><span class="linenos">2070</span></a> <span class="s2">"ENGINE"</span><span class="p">:</span> <span class="n">EngineProperty</span><span class="p">,</span> -</span><span id="L-2071"><a href="#L-2071"><span class="linenos">2071</span></a> <span class="s2">"EXECUTE AS"</span><span class="p">:</span> <span class="n">ExecuteAsProperty</span><span class="p">,</span> -</span><span id="L-2072"><a href="#L-2072"><span class="linenos">2072</span></a> <span class="s2">"FORMAT"</span><span class="p">:</span> <span class="n">FileFormatProperty</span><span class="p">,</span> -</span><span id="L-2073"><a href="#L-2073"><span class="linenos">2073</span></a> <span class="s2">"LANGUAGE"</span><span class="p">:</span> <span class="n">LanguageProperty</span><span class="p">,</span> -</span><span id="L-2074"><a href="#L-2074"><span class="linenos">2074</span></a> <span class="s2">"LOCATION"</span><span class="p">:</span> <span class="n">LocationProperty</span><span class="p">,</span> -</span><span id="L-2075"><a href="#L-2075"><span class="linenos">2075</span></a> <span class="s2">"PARTITIONED_BY"</span><span class="p">:</span> <span class="n">PartitionedByProperty</span><span class="p">,</span> -</span><span id="L-2076"><a href="#L-2076"><span class="linenos">2076</span></a> <span class="s2">"RETURNS"</span><span class="p">:</span> <span class="n">ReturnsProperty</span><span class="p">,</span> -</span><span id="L-2077"><a href="#L-2077"><span class="linenos">2077</span></a> <span class="s2">"ROW_FORMAT"</span><span class="p">:</span> <span class="n">RowFormatProperty</span><span class="p">,</span> -</span><span id="L-2078"><a href="#L-2078"><span class="linenos">2078</span></a> <span class="s2">"SORTKEY"</span><span class="p">:</span> <span class="n">SortKeyProperty</span><span class="p">,</span> -</span><span id="L-2079"><a href="#L-2079"><span class="linenos">2079</span></a> <span class="p">}</span> -</span><span id="L-2080"><a href="#L-2080"><span class="linenos">2080</span></a> -</span><span id="L-2081"><a href="#L-2081"><span class="linenos">2081</span></a> <span class="n">PROPERTY_TO_NAME</span> <span class="o">=</span> <span class="p">{</span><span class="n">v</span><span class="p">:</span> <span class="n">k</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">NAME_TO_PROPERTY</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span> -</span><span id="L-2082"><a href="#L-2082"><span class="linenos">2082</span></a> -</span><span id="L-2083"><a href="#L-2083"><span class="linenos">2083</span></a> <span class="c1"># CREATE property locations</span> -</span><span id="L-2084"><a href="#L-2084"><span class="linenos">2084</span></a> <span class="c1"># Form: schema specified</span> -</span><span id="L-2085"><a href="#L-2085"><span class="linenos">2085</span></a> <span class="c1"># create [POST_CREATE]</span> -</span><span id="L-2086"><a href="#L-2086"><span class="linenos">2086</span></a> <span class="c1"># table a [POST_NAME]</span> -</span><span id="L-2087"><a href="#L-2087"><span class="linenos">2087</span></a> <span class="c1"># (b int) [POST_SCHEMA]</span> -</span><span id="L-2088"><a href="#L-2088"><span class="linenos">2088</span></a> <span class="c1"># with ([POST_WITH])</span> -</span><span id="L-2089"><a href="#L-2089"><span class="linenos">2089</span></a> <span class="c1"># index (b) [POST_INDEX]</span> -</span><span id="L-2090"><a href="#L-2090"><span class="linenos">2090</span></a> <span class="c1">#</span> -</span><span id="L-2091"><a href="#L-2091"><span class="linenos">2091</span></a> <span class="c1"># Form: alias selection</span> -</span><span id="L-2092"><a href="#L-2092"><span class="linenos">2092</span></a> <span class="c1"># create [POST_CREATE]</span> -</span><span id="L-2093"><a href="#L-2093"><span class="linenos">2093</span></a> <span class="c1"># table a [POST_NAME]</span> -</span><span id="L-2094"><a href="#L-2094"><span class="linenos">2094</span></a> <span class="c1"># as [POST_ALIAS] (select * from b) [POST_EXPRESSION]</span> -</span><span id="L-2095"><a href="#L-2095"><span class="linenos">2095</span></a> <span class="c1"># index (c) [POST_INDEX]</span> -</span><span id="L-2096"><a href="#L-2096"><span class="linenos">2096</span></a> <span class="k">class</span> <span class="nc">Location</span><span class="p">(</span><span class="n">AutoName</span><span class="p">):</span> -</span><span id="L-2097"><a href="#L-2097"><span class="linenos">2097</span></a> <span class="n">POST_CREATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-2098"><a href="#L-2098"><span class="linenos">2098</span></a> <span class="n">POST_NAME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-2099"><a href="#L-2099"><span class="linenos">2099</span></a> <span class="n">POST_SCHEMA</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-2100"><a href="#L-2100"><span class="linenos">2100</span></a> <span class="n">POST_WITH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-2101"><a href="#L-2101"><span class="linenos">2101</span></a> <span class="n">POST_ALIAS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-2102"><a href="#L-2102"><span class="linenos">2102</span></a> <span class="n">POST_EXPRESSION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-2103"><a href="#L-2103"><span class="linenos">2103</span></a> <span class="n">POST_INDEX</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-2104"><a href="#L-2104"><span class="linenos">2104</span></a> <span class="n">UNSUPPORTED</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-2105"><a href="#L-2105"><span class="linenos">2105</span></a> -</span><span id="L-2106"><a href="#L-2106"><span class="linenos">2106</span></a> <span class="nd">@classmethod</span> -</span><span id="L-2107"><a href="#L-2107"><span class="linenos">2107</span></a> <span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">properties_dict</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">)</span> <span class="o">-></span> <span class="n">Properties</span><span class="p">:</span> -</span><span id="L-2108"><a href="#L-2108"><span class="linenos">2108</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-2109"><a href="#L-2109"><span class="linenos">2109</span></a> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">properties_dict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> -</span><span id="L-2110"><a href="#L-2110"><span class="linenos">2110</span></a> <span class="n">property_cls</span> <span class="o">=</span> <span class="bp">cls</span><span class="o">.</span><span class="n">NAME_TO_PROPERTY</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span> -</span><span id="L-2111"><a href="#L-2111"><span class="linenos">2111</span></a> <span class="k">if</span> <span class="n">property_cls</span><span class="p">:</span> -</span><span id="L-2112"><a href="#L-2112"><span class="linenos">2112</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">property_cls</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">convert</span><span class="p">(</span><span class="n">value</span><span class="p">)))</span> -</span><span id="L-2113"><a href="#L-2113"><span class="linenos">2113</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2114"><a href="#L-2114"><span class="linenos">2114</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Property</span><span class="p">(</span><span class="n">this</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">key</span><span class="p">),</span> <span class="n">value</span><span class="o">=</span><span class="n">convert</span><span class="p">(</span><span class="n">value</span><span class="p">)))</span> -</span><span id="L-2115"><a href="#L-2115"><span class="linenos">2115</span></a> -</span><span id="L-2116"><a href="#L-2116"><span class="linenos">2116</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-2117"><a href="#L-2117"><span class="linenos">2117</span></a> -</span><span id="L-2118"><a href="#L-2118"><span class="linenos">2118</span></a> -</span><span id="L-2119"><a href="#L-2119"><span class="linenos">2119</span></a><span class="k">class</span> <span class="nc">Qualify</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-2120"><a href="#L-2120"><span class="linenos">2120</span></a> <span class="k">pass</span> +</span><span id="L-2061"><a href="#L-2061"><span class="linenos">2061</span></a> +</span><span id="L-2062"><a href="#L-2062"><span class="linenos">2062</span></a><span class="k">class</span> <span class="nc">Properties</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-2063"><a href="#L-2063"><span class="linenos">2063</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-2064"><a href="#L-2064"><span class="linenos">2064</span></a> +</span><span id="L-2065"><a href="#L-2065"><span class="linenos">2065</span></a> <span class="n">NAME_TO_PROPERTY</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-2066"><a href="#L-2066"><span class="linenos">2066</span></a> <span class="s2">"ALGORITHM"</span><span class="p">:</span> <span class="n">AlgorithmProperty</span><span class="p">,</span> +</span><span id="L-2067"><a href="#L-2067"><span class="linenos">2067</span></a> <span class="s2">"AUTO_INCREMENT"</span><span class="p">:</span> <span class="n">AutoIncrementProperty</span><span class="p">,</span> +</span><span id="L-2068"><a href="#L-2068"><span class="linenos">2068</span></a> <span class="s2">"CHARACTER SET"</span><span class="p">:</span> <span class="n">CharacterSetProperty</span><span class="p">,</span> +</span><span id="L-2069"><a href="#L-2069"><span class="linenos">2069</span></a> <span class="s2">"COLLATE"</span><span class="p">:</span> <span class="n">CollateProperty</span><span class="p">,</span> +</span><span id="L-2070"><a href="#L-2070"><span class="linenos">2070</span></a> <span class="s2">"COMMENT"</span><span class="p">:</span> <span class="n">SchemaCommentProperty</span><span class="p">,</span> +</span><span id="L-2071"><a href="#L-2071"><span class="linenos">2071</span></a> <span class="s2">"DEFINER"</span><span class="p">:</span> <span class="n">DefinerProperty</span><span class="p">,</span> +</span><span id="L-2072"><a href="#L-2072"><span class="linenos">2072</span></a> <span class="s2">"DISTKEY"</span><span class="p">:</span> <span class="n">DistKeyProperty</span><span class="p">,</span> +</span><span id="L-2073"><a href="#L-2073"><span class="linenos">2073</span></a> <span class="s2">"DISTSTYLE"</span><span class="p">:</span> <span class="n">DistStyleProperty</span><span class="p">,</span> +</span><span id="L-2074"><a href="#L-2074"><span class="linenos">2074</span></a> <span class="s2">"ENGINE"</span><span class="p">:</span> <span class="n">EngineProperty</span><span class="p">,</span> +</span><span id="L-2075"><a href="#L-2075"><span class="linenos">2075</span></a> <span class="s2">"EXECUTE AS"</span><span class="p">:</span> <span class="n">ExecuteAsProperty</span><span class="p">,</span> +</span><span id="L-2076"><a href="#L-2076"><span class="linenos">2076</span></a> <span class="s2">"FORMAT"</span><span class="p">:</span> <span class="n">FileFormatProperty</span><span class="p">,</span> +</span><span id="L-2077"><a href="#L-2077"><span class="linenos">2077</span></a> <span class="s2">"LANGUAGE"</span><span class="p">:</span> <span class="n">LanguageProperty</span><span class="p">,</span> +</span><span id="L-2078"><a href="#L-2078"><span class="linenos">2078</span></a> <span class="s2">"LOCATION"</span><span class="p">:</span> <span class="n">LocationProperty</span><span class="p">,</span> +</span><span id="L-2079"><a href="#L-2079"><span class="linenos">2079</span></a> <span class="s2">"PARTITIONED_BY"</span><span class="p">:</span> <span class="n">PartitionedByProperty</span><span class="p">,</span> +</span><span id="L-2080"><a href="#L-2080"><span class="linenos">2080</span></a> <span class="s2">"RETURNS"</span><span class="p">:</span> <span class="n">ReturnsProperty</span><span class="p">,</span> +</span><span id="L-2081"><a href="#L-2081"><span class="linenos">2081</span></a> <span class="s2">"ROW_FORMAT"</span><span class="p">:</span> <span class="n">RowFormatProperty</span><span class="p">,</span> +</span><span id="L-2082"><a href="#L-2082"><span class="linenos">2082</span></a> <span class="s2">"SORTKEY"</span><span class="p">:</span> <span class="n">SortKeyProperty</span><span class="p">,</span> +</span><span id="L-2083"><a href="#L-2083"><span class="linenos">2083</span></a> <span class="p">}</span> +</span><span id="L-2084"><a href="#L-2084"><span class="linenos">2084</span></a> +</span><span id="L-2085"><a href="#L-2085"><span class="linenos">2085</span></a> <span class="n">PROPERTY_TO_NAME</span> <span class="o">=</span> <span class="p">{</span><span class="n">v</span><span class="p">:</span> <span class="n">k</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">NAME_TO_PROPERTY</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span> +</span><span id="L-2086"><a href="#L-2086"><span class="linenos">2086</span></a> +</span><span id="L-2087"><a href="#L-2087"><span class="linenos">2087</span></a> <span class="c1"># CREATE property locations</span> +</span><span id="L-2088"><a href="#L-2088"><span class="linenos">2088</span></a> <span class="c1"># Form: schema specified</span> +</span><span id="L-2089"><a href="#L-2089"><span class="linenos">2089</span></a> <span class="c1"># create [POST_CREATE]</span> +</span><span id="L-2090"><a href="#L-2090"><span class="linenos">2090</span></a> <span class="c1"># table a [POST_NAME]</span> +</span><span id="L-2091"><a href="#L-2091"><span class="linenos">2091</span></a> <span class="c1"># (b int) [POST_SCHEMA]</span> +</span><span id="L-2092"><a href="#L-2092"><span class="linenos">2092</span></a> <span class="c1"># with ([POST_WITH])</span> +</span><span id="L-2093"><a href="#L-2093"><span class="linenos">2093</span></a> <span class="c1"># index (b) [POST_INDEX]</span> +</span><span id="L-2094"><a href="#L-2094"><span class="linenos">2094</span></a> <span class="c1">#</span> +</span><span id="L-2095"><a href="#L-2095"><span class="linenos">2095</span></a> <span class="c1"># Form: alias selection</span> +</span><span id="L-2096"><a href="#L-2096"><span class="linenos">2096</span></a> <span class="c1"># create [POST_CREATE]</span> +</span><span id="L-2097"><a href="#L-2097"><span class="linenos">2097</span></a> <span class="c1"># table a [POST_NAME]</span> +</span><span id="L-2098"><a href="#L-2098"><span class="linenos">2098</span></a> <span class="c1"># as [POST_ALIAS] (select * from b) [POST_EXPRESSION]</span> +</span><span id="L-2099"><a href="#L-2099"><span class="linenos">2099</span></a> <span class="c1"># index (c) [POST_INDEX]</span> +</span><span id="L-2100"><a href="#L-2100"><span class="linenos">2100</span></a> <span class="k">class</span> <span class="nc">Location</span><span class="p">(</span><span class="n">AutoName</span><span class="p">):</span> +</span><span id="L-2101"><a href="#L-2101"><span class="linenos">2101</span></a> <span class="n">POST_CREATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-2102"><a href="#L-2102"><span class="linenos">2102</span></a> <span class="n">POST_NAME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-2103"><a href="#L-2103"><span class="linenos">2103</span></a> <span class="n">POST_SCHEMA</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-2104"><a href="#L-2104"><span class="linenos">2104</span></a> <span class="n">POST_WITH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-2105"><a href="#L-2105"><span class="linenos">2105</span></a> <span class="n">POST_ALIAS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-2106"><a href="#L-2106"><span class="linenos">2106</span></a> <span class="n">POST_EXPRESSION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-2107"><a href="#L-2107"><span class="linenos">2107</span></a> <span class="n">POST_INDEX</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-2108"><a href="#L-2108"><span class="linenos">2108</span></a> <span class="n">UNSUPPORTED</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-2109"><a href="#L-2109"><span class="linenos">2109</span></a> +</span><span id="L-2110"><a href="#L-2110"><span class="linenos">2110</span></a> <span class="nd">@classmethod</span> +</span><span id="L-2111"><a href="#L-2111"><span class="linenos">2111</span></a> <span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">properties_dict</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">)</span> <span class="o">-></span> <span class="n">Properties</span><span class="p">:</span> +</span><span id="L-2112"><a href="#L-2112"><span class="linenos">2112</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-2113"><a href="#L-2113"><span class="linenos">2113</span></a> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">properties_dict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> +</span><span id="L-2114"><a href="#L-2114"><span class="linenos">2114</span></a> <span class="n">property_cls</span> <span class="o">=</span> <span class="bp">cls</span><span class="o">.</span><span class="n">NAME_TO_PROPERTY</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span> +</span><span id="L-2115"><a href="#L-2115"><span class="linenos">2115</span></a> <span class="k">if</span> <span class="n">property_cls</span><span class="p">:</span> +</span><span id="L-2116"><a href="#L-2116"><span class="linenos">2116</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">property_cls</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">convert</span><span class="p">(</span><span class="n">value</span><span class="p">)))</span> +</span><span id="L-2117"><a href="#L-2117"><span class="linenos">2117</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2118"><a href="#L-2118"><span class="linenos">2118</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Property</span><span class="p">(</span><span class="n">this</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">key</span><span class="p">),</span> <span class="n">value</span><span class="o">=</span><span class="n">convert</span><span class="p">(</span><span class="n">value</span><span class="p">)))</span> +</span><span id="L-2119"><a href="#L-2119"><span class="linenos">2119</span></a> +</span><span id="L-2120"><a href="#L-2120"><span class="linenos">2120</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> </span><span id="L-2121"><a href="#L-2121"><span class="linenos">2121</span></a> </span><span id="L-2122"><a href="#L-2122"><span class="linenos">2122</span></a> -</span><span id="L-2123"><a href="#L-2123"><span class="linenos">2123</span></a><span class="c1"># https://www.ibm.com/docs/en/ias?topic=procedures-return-statement-in-sql</span> -</span><span id="L-2124"><a href="#L-2124"><span class="linenos">2124</span></a><span class="k">class</span> <span class="nc">Return</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-2125"><a href="#L-2125"><span class="linenos">2125</span></a> <span class="k">pass</span> +</span><span id="L-2123"><a href="#L-2123"><span class="linenos">2123</span></a><span class="k">class</span> <span class="nc">Qualify</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-2124"><a href="#L-2124"><span class="linenos">2124</span></a> <span class="k">pass</span> +</span><span id="L-2125"><a href="#L-2125"><span class="linenos">2125</span></a> </span><span id="L-2126"><a href="#L-2126"><span class="linenos">2126</span></a> -</span><span id="L-2127"><a href="#L-2127"><span class="linenos">2127</span></a> -</span><span id="L-2128"><a href="#L-2128"><span class="linenos">2128</span></a><span class="k">class</span> <span class="nc">Reference</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-2129"><a href="#L-2129"><span class="linenos">2129</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"options"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-2127"><a href="#L-2127"><span class="linenos">2127</span></a><span class="c1"># https://www.ibm.com/docs/en/ias?topic=procedures-return-statement-in-sql</span> +</span><span id="L-2128"><a href="#L-2128"><span class="linenos">2128</span></a><span class="k">class</span> <span class="nc">Return</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-2129"><a href="#L-2129"><span class="linenos">2129</span></a> <span class="k">pass</span> </span><span id="L-2130"><a href="#L-2130"><span class="linenos">2130</span></a> </span><span id="L-2131"><a href="#L-2131"><span class="linenos">2131</span></a> -</span><span id="L-2132"><a href="#L-2132"><span class="linenos">2132</span></a><span class="k">class</span> <span class="nc">Tuple</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-2133"><a href="#L-2133"><span class="linenos">2133</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-2132"><a href="#L-2132"><span class="linenos">2132</span></a><span class="k">class</span> <span class="nc">Reference</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-2133"><a href="#L-2133"><span class="linenos">2133</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"options"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-2134"><a href="#L-2134"><span class="linenos">2134</span></a> -</span><span id="L-2135"><a href="#L-2135"><span class="linenos">2135</span></a> <span class="k">def</span> <span class="nf">isin</span><span class="p">(</span> -</span><span id="L-2136"><a href="#L-2136"><span class="linenos">2136</span></a> <span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="n">query</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="L-2137"><a href="#L-2137"><span class="linenos">2137</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">In</span><span class="p">:</span> -</span><span id="L-2138"><a href="#L-2138"><span class="linenos">2138</span></a> <span class="k">return</span> <span class="n">In</span><span class="p">(</span> -</span><span id="L-2139"><a href="#L-2139"><span class="linenos">2139</span></a> <span class="n">this</span><span class="o">=</span><span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">),</span> -</span><span id="L-2140"><a href="#L-2140"><span class="linenos">2140</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">],</span> -</span><span id="L-2141"><a href="#L-2141"><span class="linenos">2141</span></a> <span class="n">query</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">query</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="k">if</span> <span class="n">query</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2142"><a href="#L-2142"><span class="linenos">2142</span></a> <span class="p">)</span> -</span><span id="L-2143"><a href="#L-2143"><span class="linenos">2143</span></a> -</span><span id="L-2144"><a href="#L-2144"><span class="linenos">2144</span></a> -</span><span id="L-2145"><a href="#L-2145"><span class="linenos">2145</span></a><span class="k">class</span> <span class="nc">Subqueryable</span><span class="p">(</span><span class="n">Unionable</span><span class="p">):</span> -</span><span id="L-2146"><a href="#L-2146"><span class="linenos">2146</span></a> <span class="k">def</span> <span class="nf">subquery</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">alias</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Subquery</span><span class="p">:</span> -</span><span id="L-2147"><a href="#L-2147"><span class="linenos">2147</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-2148"><a href="#L-2148"><span class="linenos">2148</span></a><span class="sd"> Convert this expression to an aliased expression that can be used as a Subquery.</span> -</span><span id="L-2149"><a href="#L-2149"><span class="linenos">2149</span></a> -</span><span id="L-2150"><a href="#L-2150"><span class="linenos">2150</span></a><span class="sd"> Example:</span> -</span><span id="L-2151"><a href="#L-2151"><span class="linenos">2151</span></a><span class="sd"> >>> subquery = Select().select("x").from_("tbl").subquery()</span> -</span><span id="L-2152"><a href="#L-2152"><span class="linenos">2152</span></a><span class="sd"> >>> Select().select("x").from_(subquery).sql()</span> -</span><span id="L-2153"><a href="#L-2153"><span class="linenos">2153</span></a><span class="sd"> 'SELECT x FROM (SELECT x FROM tbl)'</span> -</span><span id="L-2154"><a href="#L-2154"><span class="linenos">2154</span></a> -</span><span id="L-2155"><a href="#L-2155"><span class="linenos">2155</span></a><span class="sd"> Args:</span> -</span><span id="L-2156"><a href="#L-2156"><span class="linenos">2156</span></a><span class="sd"> alias (str | Identifier): an optional alias for the subquery</span> -</span><span id="L-2157"><a href="#L-2157"><span class="linenos">2157</span></a><span class="sd"> copy (bool): if `False`, modify this expression instance in-place.</span> +</span><span id="L-2135"><a href="#L-2135"><span class="linenos">2135</span></a> +</span><span id="L-2136"><a href="#L-2136"><span class="linenos">2136</span></a><span class="k">class</span> <span class="nc">Tuple</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-2137"><a href="#L-2137"><span class="linenos">2137</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-2138"><a href="#L-2138"><span class="linenos">2138</span></a> +</span><span id="L-2139"><a href="#L-2139"><span class="linenos">2139</span></a> <span class="k">def</span> <span class="nf">isin</span><span class="p">(</span> +</span><span id="L-2140"><a href="#L-2140"><span class="linenos">2140</span></a> <span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="n">query</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="L-2141"><a href="#L-2141"><span class="linenos">2141</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">In</span><span class="p">:</span> +</span><span id="L-2142"><a href="#L-2142"><span class="linenos">2142</span></a> <span class="k">return</span> <span class="n">In</span><span class="p">(</span> +</span><span id="L-2143"><a href="#L-2143"><span class="linenos">2143</span></a> <span class="n">this</span><span class="o">=</span><span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">),</span> +</span><span id="L-2144"><a href="#L-2144"><span class="linenos">2144</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">],</span> +</span><span id="L-2145"><a href="#L-2145"><span class="linenos">2145</span></a> <span class="n">query</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">query</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="k">if</span> <span class="n">query</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2146"><a href="#L-2146"><span class="linenos">2146</span></a> <span class="p">)</span> +</span><span id="L-2147"><a href="#L-2147"><span class="linenos">2147</span></a> +</span><span id="L-2148"><a href="#L-2148"><span class="linenos">2148</span></a> +</span><span id="L-2149"><a href="#L-2149"><span class="linenos">2149</span></a><span class="k">class</span> <span class="nc">Subqueryable</span><span class="p">(</span><span class="n">Unionable</span><span class="p">):</span> +</span><span id="L-2150"><a href="#L-2150"><span class="linenos">2150</span></a> <span class="k">def</span> <span class="nf">subquery</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">alias</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Subquery</span><span class="p">:</span> +</span><span id="L-2151"><a href="#L-2151"><span class="linenos">2151</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-2152"><a href="#L-2152"><span class="linenos">2152</span></a><span class="sd"> Convert this expression to an aliased expression that can be used as a Subquery.</span> +</span><span id="L-2153"><a href="#L-2153"><span class="linenos">2153</span></a> +</span><span id="L-2154"><a href="#L-2154"><span class="linenos">2154</span></a><span class="sd"> Example:</span> +</span><span id="L-2155"><a href="#L-2155"><span class="linenos">2155</span></a><span class="sd"> >>> subquery = Select().select("x").from_("tbl").subquery()</span> +</span><span id="L-2156"><a href="#L-2156"><span class="linenos">2156</span></a><span class="sd"> >>> Select().select("x").from_(subquery).sql()</span> +</span><span id="L-2157"><a href="#L-2157"><span class="linenos">2157</span></a><span class="sd"> 'SELECT x FROM (SELECT x FROM tbl)'</span> </span><span id="L-2158"><a href="#L-2158"><span class="linenos">2158</span></a> -</span><span id="L-2159"><a href="#L-2159"><span class="linenos">2159</span></a><span class="sd"> Returns:</span> -</span><span id="L-2160"><a href="#L-2160"><span class="linenos">2160</span></a><span class="sd"> Alias: the subquery</span> -</span><span id="L-2161"><a href="#L-2161"><span class="linenos">2161</span></a><span class="sd"> """</span> -</span><span id="L-2162"><a href="#L-2162"><span class="linenos">2162</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="L-2163"><a href="#L-2163"><span class="linenos">2163</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> -</span><span id="L-2164"><a href="#L-2164"><span class="linenos">2164</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">))</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="L-2165"><a href="#L-2165"><span class="linenos">2165</span></a> -</span><span id="L-2166"><a href="#L-2166"><span class="linenos">2166</span></a> <span class="k">return</span> <span class="n">Subquery</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">instance</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> -</span><span id="L-2167"><a href="#L-2167"><span class="linenos">2167</span></a> -</span><span id="L-2168"><a href="#L-2168"><span class="linenos">2168</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span> -</span><span id="L-2169"><a href="#L-2169"><span class="linenos">2169</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="L-2170"><a href="#L-2170"><span class="linenos">2170</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-2171"><a href="#L-2171"><span class="linenos">2171</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span> -</span><span id="L-2172"><a href="#L-2172"><span class="linenos">2172</span></a> -</span><span id="L-2173"><a href="#L-2173"><span class="linenos">2173</span></a> <span class="nd">@property</span> -</span><span id="L-2174"><a href="#L-2174"><span class="linenos">2174</span></a> <span class="k">def</span> <span class="nf">ctes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="L-2175"><a href="#L-2175"><span class="linenos">2175</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"with"</span><span class="p">)</span> -</span><span id="L-2176"><a href="#L-2176"><span class="linenos">2176</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">with_</span><span class="p">:</span> -</span><span id="L-2177"><a href="#L-2177"><span class="linenos">2177</span></a> <span class="k">return</span> <span class="p">[]</span> -</span><span id="L-2178"><a href="#L-2178"><span class="linenos">2178</span></a> <span class="k">return</span> <span class="n">with_</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="L-2179"><a href="#L-2179"><span class="linenos">2179</span></a> -</span><span id="L-2180"><a href="#L-2180"><span class="linenos">2180</span></a> <span class="nd">@property</span> -</span><span id="L-2181"><a href="#L-2181"><span class="linenos">2181</span></a> <span class="k">def</span> <span class="nf">selects</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="L-2182"><a href="#L-2182"><span class="linenos">2182</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s2">"Subqueryable objects must implement `selects`"</span><span class="p">)</span> +</span><span id="L-2159"><a href="#L-2159"><span class="linenos">2159</span></a><span class="sd"> Args:</span> +</span><span id="L-2160"><a href="#L-2160"><span class="linenos">2160</span></a><span class="sd"> alias (str | Identifier): an optional alias for the subquery</span> +</span><span id="L-2161"><a href="#L-2161"><span class="linenos">2161</span></a><span class="sd"> copy (bool): if `False`, modify this expression instance in-place.</span> +</span><span id="L-2162"><a href="#L-2162"><span class="linenos">2162</span></a> +</span><span id="L-2163"><a href="#L-2163"><span class="linenos">2163</span></a><span class="sd"> Returns:</span> +</span><span id="L-2164"><a href="#L-2164"><span class="linenos">2164</span></a><span class="sd"> Alias: the subquery</span> +</span><span id="L-2165"><a href="#L-2165"><span class="linenos">2165</span></a><span class="sd"> """</span> +</span><span id="L-2166"><a href="#L-2166"><span class="linenos">2166</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="L-2167"><a href="#L-2167"><span class="linenos">2167</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> +</span><span id="L-2168"><a href="#L-2168"><span class="linenos">2168</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">))</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="L-2169"><a href="#L-2169"><span class="linenos">2169</span></a> +</span><span id="L-2170"><a href="#L-2170"><span class="linenos">2170</span></a> <span class="k">return</span> <span class="n">Subquery</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">instance</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> +</span><span id="L-2171"><a href="#L-2171"><span class="linenos">2171</span></a> +</span><span id="L-2172"><a href="#L-2172"><span class="linenos">2172</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span> +</span><span id="L-2173"><a href="#L-2173"><span class="linenos">2173</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="L-2174"><a href="#L-2174"><span class="linenos">2174</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-2175"><a href="#L-2175"><span class="linenos">2175</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span> +</span><span id="L-2176"><a href="#L-2176"><span class="linenos">2176</span></a> +</span><span id="L-2177"><a href="#L-2177"><span class="linenos">2177</span></a> <span class="nd">@property</span> +</span><span id="L-2178"><a href="#L-2178"><span class="linenos">2178</span></a> <span class="k">def</span> <span class="nf">ctes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="L-2179"><a href="#L-2179"><span class="linenos">2179</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"with"</span><span class="p">)</span> +</span><span id="L-2180"><a href="#L-2180"><span class="linenos">2180</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">with_</span><span class="p">:</span> +</span><span id="L-2181"><a href="#L-2181"><span class="linenos">2181</span></a> <span class="k">return</span> <span class="p">[]</span> +</span><span id="L-2182"><a href="#L-2182"><span class="linenos">2182</span></a> <span class="k">return</span> <span class="n">with_</span><span class="o">.</span><span class="n">expressions</span> </span><span id="L-2183"><a href="#L-2183"><span class="linenos">2183</span></a> </span><span id="L-2184"><a href="#L-2184"><span class="linenos">2184</span></a> <span class="nd">@property</span> -</span><span id="L-2185"><a href="#L-2185"><span class="linenos">2185</span></a> <span class="k">def</span> <span class="nf">named_selects</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="L-2186"><a href="#L-2186"><span class="linenos">2186</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s2">"Subqueryable objects must implement `named_selects`"</span><span class="p">)</span> +</span><span id="L-2185"><a href="#L-2185"><span class="linenos">2185</span></a> <span class="k">def</span> <span class="nf">selects</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="L-2186"><a href="#L-2186"><span class="linenos">2186</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s2">"Subqueryable objects must implement `selects`"</span><span class="p">)</span> </span><span id="L-2187"><a href="#L-2187"><span class="linenos">2187</span></a> -</span><span id="L-2188"><a href="#L-2188"><span class="linenos">2188</span></a> <span class="k">def</span> <span class="nf">with_</span><span class="p">(</span> -</span><span id="L-2189"><a href="#L-2189"><span class="linenos">2189</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2190"><a href="#L-2190"><span class="linenos">2190</span></a> <span class="n">alias</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="L-2191"><a href="#L-2191"><span class="linenos">2191</span></a> <span class="n">as_</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="L-2192"><a href="#L-2192"><span class="linenos">2192</span></a> <span class="n">recursive</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2193"><a href="#L-2193"><span class="linenos">2193</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2194"><a href="#L-2194"><span class="linenos">2194</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2195"><a href="#L-2195"><span class="linenos">2195</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2196"><a href="#L-2196"><span class="linenos">2196</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2197"><a href="#L-2197"><span class="linenos">2197</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Subqueryable</span><span class="p">:</span> -</span><span id="L-2198"><a href="#L-2198"><span class="linenos">2198</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-2199"><a href="#L-2199"><span class="linenos">2199</span></a><span class="sd"> Append to or set the common table expressions.</span> -</span><span id="L-2200"><a href="#L-2200"><span class="linenos">2200</span></a> -</span><span id="L-2201"><a href="#L-2201"><span class="linenos">2201</span></a><span class="sd"> Example:</span> -</span><span id="L-2202"><a href="#L-2202"><span class="linenos">2202</span></a><span class="sd"> >>> Select().with_("tbl2", as_="SELECT * FROM tbl").select("x").from_("tbl2").sql()</span> -</span><span id="L-2203"><a href="#L-2203"><span class="linenos">2203</span></a><span class="sd"> 'WITH tbl2 AS (SELECT * FROM tbl) SELECT x FROM tbl2'</span> +</span><span id="L-2188"><a href="#L-2188"><span class="linenos">2188</span></a> <span class="nd">@property</span> +</span><span id="L-2189"><a href="#L-2189"><span class="linenos">2189</span></a> <span class="k">def</span> <span class="nf">named_selects</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="L-2190"><a href="#L-2190"><span class="linenos">2190</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s2">"Subqueryable objects must implement `named_selects`"</span><span class="p">)</span> +</span><span id="L-2191"><a href="#L-2191"><span class="linenos">2191</span></a> +</span><span id="L-2192"><a href="#L-2192"><span class="linenos">2192</span></a> <span class="k">def</span> <span class="nf">with_</span><span class="p">(</span> +</span><span id="L-2193"><a href="#L-2193"><span class="linenos">2193</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2194"><a href="#L-2194"><span class="linenos">2194</span></a> <span class="n">alias</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="L-2195"><a href="#L-2195"><span class="linenos">2195</span></a> <span class="n">as_</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="L-2196"><a href="#L-2196"><span class="linenos">2196</span></a> <span class="n">recursive</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2197"><a href="#L-2197"><span class="linenos">2197</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2198"><a href="#L-2198"><span class="linenos">2198</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2199"><a href="#L-2199"><span class="linenos">2199</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2200"><a href="#L-2200"><span class="linenos">2200</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2201"><a href="#L-2201"><span class="linenos">2201</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Subqueryable</span><span class="p">:</span> +</span><span id="L-2202"><a href="#L-2202"><span class="linenos">2202</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-2203"><a href="#L-2203"><span class="linenos">2203</span></a><span class="sd"> Append to or set the common table expressions.</span> </span><span id="L-2204"><a href="#L-2204"><span class="linenos">2204</span></a> -</span><span id="L-2205"><a href="#L-2205"><span class="linenos">2205</span></a><span class="sd"> Args:</span> -</span><span id="L-2206"><a href="#L-2206"><span class="linenos">2206</span></a><span class="sd"> alias: the SQL code string to parse as the table name.</span> -</span><span id="L-2207"><a href="#L-2207"><span class="linenos">2207</span></a><span class="sd"> If an `Expression` instance is passed, this is used as-is.</span> -</span><span id="L-2208"><a href="#L-2208"><span class="linenos">2208</span></a><span class="sd"> as_: the SQL code string to parse as the table expression.</span> -</span><span id="L-2209"><a href="#L-2209"><span class="linenos">2209</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="L-2210"><a href="#L-2210"><span class="linenos">2210</span></a><span class="sd"> recursive: set the RECURSIVE part of the expression. Defaults to `False`.</span> -</span><span id="L-2211"><a href="#L-2211"><span class="linenos">2211</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="L-2212"><a href="#L-2212"><span class="linenos">2212</span></a><span class="sd"> Otherwise, this resets the expressions.</span> -</span><span id="L-2213"><a href="#L-2213"><span class="linenos">2213</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="L-2214"><a href="#L-2214"><span class="linenos">2214</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="L-2215"><a href="#L-2215"><span class="linenos">2215</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="L-2216"><a href="#L-2216"><span class="linenos">2216</span></a> -</span><span id="L-2217"><a href="#L-2217"><span class="linenos">2217</span></a><span class="sd"> Returns:</span> -</span><span id="L-2218"><a href="#L-2218"><span class="linenos">2218</span></a><span class="sd"> The modified expression.</span> -</span><span id="L-2219"><a href="#L-2219"><span class="linenos">2219</span></a><span class="sd"> """</span> -</span><span id="L-2220"><a href="#L-2220"><span class="linenos">2220</span></a> <span class="k">return</span> <span class="n">_apply_cte_builder</span><span class="p">(</span> -</span><span id="L-2221"><a href="#L-2221"><span class="linenos">2221</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">alias</span><span class="p">,</span> <span class="n">as_</span><span class="p">,</span> <span class="n">recursive</span><span class="o">=</span><span class="n">recursive</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="L-2222"><a href="#L-2222"><span class="linenos">2222</span></a> <span class="p">)</span> -</span><span id="L-2223"><a href="#L-2223"><span class="linenos">2223</span></a> -</span><span id="L-2224"><a href="#L-2224"><span class="linenos">2224</span></a> -</span><span id="L-2225"><a href="#L-2225"><span class="linenos">2225</span></a><span class="n">QUERY_MODIFIERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-2226"><a href="#L-2226"><span class="linenos">2226</span></a> <span class="s2">"match"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2227"><a href="#L-2227"><span class="linenos">2227</span></a> <span class="s2">"laterals"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2228"><a href="#L-2228"><span class="linenos">2228</span></a> <span class="s2">"joins"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2229"><a href="#L-2229"><span class="linenos">2229</span></a> <span class="s2">"pivots"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2230"><a href="#L-2230"><span class="linenos">2230</span></a> <span class="s2">"where"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2231"><a href="#L-2231"><span class="linenos">2231</span></a> <span class="s2">"group"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2232"><a href="#L-2232"><span class="linenos">2232</span></a> <span class="s2">"having"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2233"><a href="#L-2233"><span class="linenos">2233</span></a> <span class="s2">"qualify"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2234"><a href="#L-2234"><span class="linenos">2234</span></a> <span class="s2">"windows"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2235"><a href="#L-2235"><span class="linenos">2235</span></a> <span class="s2">"distribute"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2236"><a href="#L-2236"><span class="linenos">2236</span></a> <span class="s2">"sort"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2237"><a href="#L-2237"><span class="linenos">2237</span></a> <span class="s2">"cluster"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2238"><a href="#L-2238"><span class="linenos">2238</span></a> <span class="s2">"order"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2239"><a href="#L-2239"><span class="linenos">2239</span></a> <span class="s2">"limit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2240"><a href="#L-2240"><span class="linenos">2240</span></a> <span class="s2">"offset"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2241"><a href="#L-2241"><span class="linenos">2241</span></a> <span class="s2">"locks"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2242"><a href="#L-2242"><span class="linenos">2242</span></a> <span class="s2">"sample"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2243"><a href="#L-2243"><span class="linenos">2243</span></a> <span class="s2">"settings"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2244"><a href="#L-2244"><span class="linenos">2244</span></a> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2245"><a href="#L-2245"><span class="linenos">2245</span></a><span class="p">}</span> -</span><span id="L-2246"><a href="#L-2246"><span class="linenos">2246</span></a> -</span><span id="L-2247"><a href="#L-2247"><span class="linenos">2247</span></a> -</span><span id="L-2248"><a href="#L-2248"><span class="linenos">2248</span></a><span class="k">class</span> <span class="nc">Table</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-2249"><a href="#L-2249"><span class="linenos">2249</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-2250"><a href="#L-2250"><span class="linenos">2250</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2251"><a href="#L-2251"><span class="linenos">2251</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2252"><a href="#L-2252"><span class="linenos">2252</span></a> <span class="s2">"db"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2253"><a href="#L-2253"><span class="linenos">2253</span></a> <span class="s2">"catalog"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2254"><a href="#L-2254"><span class="linenos">2254</span></a> <span class="s2">"laterals"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2255"><a href="#L-2255"><span class="linenos">2255</span></a> <span class="s2">"joins"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2256"><a href="#L-2256"><span class="linenos">2256</span></a> <span class="s2">"pivots"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2257"><a href="#L-2257"><span class="linenos">2257</span></a> <span class="s2">"hints"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2258"><a href="#L-2258"><span class="linenos">2258</span></a> <span class="s2">"system_time"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2259"><a href="#L-2259"><span class="linenos">2259</span></a> <span class="p">}</span> -</span><span id="L-2260"><a href="#L-2260"><span class="linenos">2260</span></a> -</span><span id="L-2261"><a href="#L-2261"><span class="linenos">2261</span></a> <span class="nd">@property</span> -</span><span id="L-2262"><a href="#L-2262"><span class="linenos">2262</span></a> <span class="k">def</span> <span class="nf">db</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2263"><a href="#L-2263"><span class="linenos">2263</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"db"</span><span class="p">)</span> +</span><span id="L-2205"><a href="#L-2205"><span class="linenos">2205</span></a><span class="sd"> Example:</span> +</span><span id="L-2206"><a href="#L-2206"><span class="linenos">2206</span></a><span class="sd"> >>> Select().with_("tbl2", as_="SELECT * FROM tbl").select("x").from_("tbl2").sql()</span> +</span><span id="L-2207"><a href="#L-2207"><span class="linenos">2207</span></a><span class="sd"> 'WITH tbl2 AS (SELECT * FROM tbl) SELECT x FROM tbl2'</span> +</span><span id="L-2208"><a href="#L-2208"><span class="linenos">2208</span></a> +</span><span id="L-2209"><a href="#L-2209"><span class="linenos">2209</span></a><span class="sd"> Args:</span> +</span><span id="L-2210"><a href="#L-2210"><span class="linenos">2210</span></a><span class="sd"> alias: the SQL code string to parse as the table name.</span> +</span><span id="L-2211"><a href="#L-2211"><span class="linenos">2211</span></a><span class="sd"> If an `Expression` instance is passed, this is used as-is.</span> +</span><span id="L-2212"><a href="#L-2212"><span class="linenos">2212</span></a><span class="sd"> as_: the SQL code string to parse as the table expression.</span> +</span><span id="L-2213"><a href="#L-2213"><span class="linenos">2213</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="L-2214"><a href="#L-2214"><span class="linenos">2214</span></a><span class="sd"> recursive: set the RECURSIVE part of the expression. Defaults to `False`.</span> +</span><span id="L-2215"><a href="#L-2215"><span class="linenos">2215</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="L-2216"><a href="#L-2216"><span class="linenos">2216</span></a><span class="sd"> Otherwise, this resets the expressions.</span> +</span><span id="L-2217"><a href="#L-2217"><span class="linenos">2217</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="L-2218"><a href="#L-2218"><span class="linenos">2218</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="L-2219"><a href="#L-2219"><span class="linenos">2219</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="L-2220"><a href="#L-2220"><span class="linenos">2220</span></a> +</span><span id="L-2221"><a href="#L-2221"><span class="linenos">2221</span></a><span class="sd"> Returns:</span> +</span><span id="L-2222"><a href="#L-2222"><span class="linenos">2222</span></a><span class="sd"> The modified expression.</span> +</span><span id="L-2223"><a href="#L-2223"><span class="linenos">2223</span></a><span class="sd"> """</span> +</span><span id="L-2224"><a href="#L-2224"><span class="linenos">2224</span></a> <span class="k">return</span> <span class="n">_apply_cte_builder</span><span class="p">(</span> +</span><span id="L-2225"><a href="#L-2225"><span class="linenos">2225</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">alias</span><span class="p">,</span> <span class="n">as_</span><span class="p">,</span> <span class="n">recursive</span><span class="o">=</span><span class="n">recursive</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="L-2226"><a href="#L-2226"><span class="linenos">2226</span></a> <span class="p">)</span> +</span><span id="L-2227"><a href="#L-2227"><span class="linenos">2227</span></a> +</span><span id="L-2228"><a href="#L-2228"><span class="linenos">2228</span></a> +</span><span id="L-2229"><a href="#L-2229"><span class="linenos">2229</span></a><span class="n">QUERY_MODIFIERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-2230"><a href="#L-2230"><span class="linenos">2230</span></a> <span class="s2">"match"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2231"><a href="#L-2231"><span class="linenos">2231</span></a> <span class="s2">"laterals"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2232"><a href="#L-2232"><span class="linenos">2232</span></a> <span class="s2">"joins"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2233"><a href="#L-2233"><span class="linenos">2233</span></a> <span class="s2">"pivots"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2234"><a href="#L-2234"><span class="linenos">2234</span></a> <span class="s2">"where"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2235"><a href="#L-2235"><span class="linenos">2235</span></a> <span class="s2">"group"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2236"><a href="#L-2236"><span class="linenos">2236</span></a> <span class="s2">"having"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2237"><a href="#L-2237"><span class="linenos">2237</span></a> <span class="s2">"qualify"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2238"><a href="#L-2238"><span class="linenos">2238</span></a> <span class="s2">"windows"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2239"><a href="#L-2239"><span class="linenos">2239</span></a> <span class="s2">"distribute"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2240"><a href="#L-2240"><span class="linenos">2240</span></a> <span class="s2">"sort"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2241"><a href="#L-2241"><span class="linenos">2241</span></a> <span class="s2">"cluster"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2242"><a href="#L-2242"><span class="linenos">2242</span></a> <span class="s2">"order"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2243"><a href="#L-2243"><span class="linenos">2243</span></a> <span class="s2">"limit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2244"><a href="#L-2244"><span class="linenos">2244</span></a> <span class="s2">"offset"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2245"><a href="#L-2245"><span class="linenos">2245</span></a> <span class="s2">"locks"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2246"><a href="#L-2246"><span class="linenos">2246</span></a> <span class="s2">"sample"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2247"><a href="#L-2247"><span class="linenos">2247</span></a> <span class="s2">"settings"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2248"><a href="#L-2248"><span class="linenos">2248</span></a> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2249"><a href="#L-2249"><span class="linenos">2249</span></a><span class="p">}</span> +</span><span id="L-2250"><a href="#L-2250"><span class="linenos">2250</span></a> +</span><span id="L-2251"><a href="#L-2251"><span class="linenos">2251</span></a> +</span><span id="L-2252"><a href="#L-2252"><span class="linenos">2252</span></a><span class="k">class</span> <span class="nc">Table</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-2253"><a href="#L-2253"><span class="linenos">2253</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-2254"><a href="#L-2254"><span class="linenos">2254</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2255"><a href="#L-2255"><span class="linenos">2255</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2256"><a href="#L-2256"><span class="linenos">2256</span></a> <span class="s2">"db"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2257"><a href="#L-2257"><span class="linenos">2257</span></a> <span class="s2">"catalog"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2258"><a href="#L-2258"><span class="linenos">2258</span></a> <span class="s2">"laterals"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2259"><a href="#L-2259"><span class="linenos">2259</span></a> <span class="s2">"joins"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2260"><a href="#L-2260"><span class="linenos">2260</span></a> <span class="s2">"pivots"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2261"><a href="#L-2261"><span class="linenos">2261</span></a> <span class="s2">"hints"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2262"><a href="#L-2262"><span class="linenos">2262</span></a> <span class="s2">"system_time"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2263"><a href="#L-2263"><span class="linenos">2263</span></a> <span class="p">}</span> </span><span id="L-2264"><a href="#L-2264"><span class="linenos">2264</span></a> </span><span id="L-2265"><a href="#L-2265"><span class="linenos">2265</span></a> <span class="nd">@property</span> -</span><span id="L-2266"><a href="#L-2266"><span class="linenos">2266</span></a> <span class="k">def</span> <span class="nf">catalog</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2267"><a href="#L-2267"><span class="linenos">2267</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">)</span> +</span><span id="L-2266"><a href="#L-2266"><span class="linenos">2266</span></a> <span class="k">def</span> <span class="nf">db</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2267"><a href="#L-2267"><span class="linenos">2267</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"db"</span><span class="p">)</span> </span><span id="L-2268"><a href="#L-2268"><span class="linenos">2268</span></a> </span><span id="L-2269"><a href="#L-2269"><span class="linenos">2269</span></a> <span class="nd">@property</span> -</span><span id="L-2270"><a href="#L-2270"><span class="linenos">2270</span></a> <span class="k">def</span> <span class="nf">parts</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Identifier</span><span class="p">]:</span> -</span><span id="L-2271"><a href="#L-2271"><span class="linenos">2271</span></a><span class="w"> </span><span class="sd">"""Return the parts of a table in order catalog, db, table."""</span> -</span><span id="L-2272"><a href="#L-2272"><span class="linenos">2272</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="L-2273"><a href="#L-2273"><span class="linenos">2273</span></a> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">Identifier</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="n">part</span><span class="p">])</span> -</span><span id="L-2274"><a href="#L-2274"><span class="linenos">2274</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"catalog"</span><span class="p">,</span> <span class="s2">"db"</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2275"><a href="#L-2275"><span class="linenos">2275</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> -</span><span id="L-2276"><a href="#L-2276"><span class="linenos">2276</span></a> <span class="p">]</span> -</span><span id="L-2277"><a href="#L-2277"><span class="linenos">2277</span></a> -</span><span id="L-2278"><a href="#L-2278"><span class="linenos">2278</span></a> -</span><span id="L-2279"><a href="#L-2279"><span class="linenos">2279</span></a><span class="c1"># See the TSQL "Querying data in a system-versioned temporal table" page</span> -</span><span id="L-2280"><a href="#L-2280"><span class="linenos">2280</span></a><span class="k">class</span> <span class="nc">SystemTime</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-2281"><a href="#L-2281"><span class="linenos">2281</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-2282"><a href="#L-2282"><span class="linenos">2282</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2283"><a href="#L-2283"><span class="linenos">2283</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2284"><a href="#L-2284"><span class="linenos">2284</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2285"><a href="#L-2285"><span class="linenos">2285</span></a> <span class="p">}</span> -</span><span id="L-2286"><a href="#L-2286"><span class="linenos">2286</span></a> -</span><span id="L-2287"><a href="#L-2287"><span class="linenos">2287</span></a> -</span><span id="L-2288"><a href="#L-2288"><span class="linenos">2288</span></a><span class="k">class</span> <span class="nc">Union</span><span class="p">(</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="L-2289"><a href="#L-2289"><span class="linenos">2289</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-2290"><a href="#L-2290"><span class="linenos">2290</span></a> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2291"><a href="#L-2291"><span class="linenos">2291</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2292"><a href="#L-2292"><span class="linenos">2292</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2293"><a href="#L-2293"><span class="linenos">2293</span></a> <span class="s2">"distinct"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2294"><a href="#L-2294"><span class="linenos">2294</span></a> <span class="o">**</span><span class="n">QUERY_MODIFIERS</span><span class="p">,</span> -</span><span id="L-2295"><a href="#L-2295"><span class="linenos">2295</span></a> <span class="p">}</span> -</span><span id="L-2296"><a href="#L-2296"><span class="linenos">2296</span></a> -</span><span id="L-2297"><a href="#L-2297"><span class="linenos">2297</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span> -</span><span id="L-2298"><a href="#L-2298"><span class="linenos">2298</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="L-2299"><a href="#L-2299"><span class="linenos">2299</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-2300"><a href="#L-2300"><span class="linenos">2300</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-2301"><a href="#L-2301"><span class="linenos">2301</span></a><span class="sd"> Set the LIMIT expression.</span> -</span><span id="L-2302"><a href="#L-2302"><span class="linenos">2302</span></a> -</span><span id="L-2303"><a href="#L-2303"><span class="linenos">2303</span></a><span class="sd"> Example:</span> -</span><span id="L-2304"><a href="#L-2304"><span class="linenos">2304</span></a><span class="sd"> >>> select("1").union(select("1")).limit(1).sql()</span> -</span><span id="L-2305"><a href="#L-2305"><span class="linenos">2305</span></a><span class="sd"> 'SELECT * FROM (SELECT 1 UNION SELECT 1) AS _l_0 LIMIT 1'</span> +</span><span id="L-2270"><a href="#L-2270"><span class="linenos">2270</span></a> <span class="k">def</span> <span class="nf">catalog</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2271"><a href="#L-2271"><span class="linenos">2271</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">)</span> +</span><span id="L-2272"><a href="#L-2272"><span class="linenos">2272</span></a> +</span><span id="L-2273"><a href="#L-2273"><span class="linenos">2273</span></a> <span class="nd">@property</span> +</span><span id="L-2274"><a href="#L-2274"><span class="linenos">2274</span></a> <span class="k">def</span> <span class="nf">parts</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Identifier</span><span class="p">]:</span> +</span><span id="L-2275"><a href="#L-2275"><span class="linenos">2275</span></a><span class="w"> </span><span class="sd">"""Return the parts of a table in order catalog, db, table."""</span> +</span><span id="L-2276"><a href="#L-2276"><span class="linenos">2276</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="L-2277"><a href="#L-2277"><span class="linenos">2277</span></a> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">Identifier</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="n">part</span><span class="p">])</span> +</span><span id="L-2278"><a href="#L-2278"><span class="linenos">2278</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"catalog"</span><span class="p">,</span> <span class="s2">"db"</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2279"><a href="#L-2279"><span class="linenos">2279</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> +</span><span id="L-2280"><a href="#L-2280"><span class="linenos">2280</span></a> <span class="p">]</span> +</span><span id="L-2281"><a href="#L-2281"><span class="linenos">2281</span></a> +</span><span id="L-2282"><a href="#L-2282"><span class="linenos">2282</span></a> +</span><span id="L-2283"><a href="#L-2283"><span class="linenos">2283</span></a><span class="c1"># See the TSQL "Querying data in a system-versioned temporal table" page</span> +</span><span id="L-2284"><a href="#L-2284"><span class="linenos">2284</span></a><span class="k">class</span> <span class="nc">SystemTime</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-2285"><a href="#L-2285"><span class="linenos">2285</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-2286"><a href="#L-2286"><span class="linenos">2286</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2287"><a href="#L-2287"><span class="linenos">2287</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2288"><a href="#L-2288"><span class="linenos">2288</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2289"><a href="#L-2289"><span class="linenos">2289</span></a> <span class="p">}</span> +</span><span id="L-2290"><a href="#L-2290"><span class="linenos">2290</span></a> +</span><span id="L-2291"><a href="#L-2291"><span class="linenos">2291</span></a> +</span><span id="L-2292"><a href="#L-2292"><span class="linenos">2292</span></a><span class="k">class</span> <span class="nc">Union</span><span class="p">(</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="L-2293"><a href="#L-2293"><span class="linenos">2293</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-2294"><a href="#L-2294"><span class="linenos">2294</span></a> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2295"><a href="#L-2295"><span class="linenos">2295</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2296"><a href="#L-2296"><span class="linenos">2296</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2297"><a href="#L-2297"><span class="linenos">2297</span></a> <span class="s2">"distinct"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2298"><a href="#L-2298"><span class="linenos">2298</span></a> <span class="o">**</span><span class="n">QUERY_MODIFIERS</span><span class="p">,</span> +</span><span id="L-2299"><a href="#L-2299"><span class="linenos">2299</span></a> <span class="p">}</span> +</span><span id="L-2300"><a href="#L-2300"><span class="linenos">2300</span></a> +</span><span id="L-2301"><a href="#L-2301"><span class="linenos">2301</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span> +</span><span id="L-2302"><a href="#L-2302"><span class="linenos">2302</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="L-2303"><a href="#L-2303"><span class="linenos">2303</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-2304"><a href="#L-2304"><span class="linenos">2304</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-2305"><a href="#L-2305"><span class="linenos">2305</span></a><span class="sd"> Set the LIMIT expression.</span> </span><span id="L-2306"><a href="#L-2306"><span class="linenos">2306</span></a> -</span><span id="L-2307"><a href="#L-2307"><span class="linenos">2307</span></a><span class="sd"> Args:</span> -</span><span id="L-2308"><a href="#L-2308"><span class="linenos">2308</span></a><span class="sd"> expression: the SQL code string to parse.</span> -</span><span id="L-2309"><a href="#L-2309"><span class="linenos">2309</span></a><span class="sd"> This can also be an integer.</span> -</span><span id="L-2310"><a href="#L-2310"><span class="linenos">2310</span></a><span class="sd"> If a `Limit` instance is passed, this is used as-is.</span> -</span><span id="L-2311"><a href="#L-2311"><span class="linenos">2311</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Limit`.</span> -</span><span id="L-2312"><a href="#L-2312"><span class="linenos">2312</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="L-2313"><a href="#L-2313"><span class="linenos">2313</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="L-2314"><a href="#L-2314"><span class="linenos">2314</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="L-2315"><a href="#L-2315"><span class="linenos">2315</span></a> -</span><span id="L-2316"><a href="#L-2316"><span class="linenos">2316</span></a><span class="sd"> Returns:</span> -</span><span id="L-2317"><a href="#L-2317"><span class="linenos">2317</span></a><span class="sd"> The limited subqueryable.</span> -</span><span id="L-2318"><a href="#L-2318"><span class="linenos">2318</span></a><span class="sd"> """</span> -</span><span id="L-2319"><a href="#L-2319"><span class="linenos">2319</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="L-2320"><a href="#L-2320"><span class="linenos">2320</span></a> <span class="n">select</span><span class="p">(</span><span class="s2">"*"</span><span class="p">)</span> -</span><span id="L-2321"><a href="#L-2321"><span class="linenos">2321</span></a> <span class="o">.</span><span class="n">from_</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">alias</span><span class="o">=</span><span class="s2">"_l_0"</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">))</span> -</span><span id="L-2322"><a href="#L-2322"><span class="linenos">2322</span></a> <span class="o">.</span><span class="n">limit</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-2323"><a href="#L-2323"><span class="linenos">2323</span></a> <span class="p">)</span> -</span><span id="L-2324"><a href="#L-2324"><span class="linenos">2324</span></a> -</span><span id="L-2325"><a href="#L-2325"><span class="linenos">2325</span></a> <span class="k">def</span> <span class="nf">select</span><span class="p">(</span> -</span><span id="L-2326"><a href="#L-2326"><span class="linenos">2326</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2327"><a href="#L-2327"><span class="linenos">2327</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="L-2328"><a href="#L-2328"><span class="linenos">2328</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2329"><a href="#L-2329"><span class="linenos">2329</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2330"><a href="#L-2330"><span class="linenos">2330</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2331"><a href="#L-2331"><span class="linenos">2331</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2332"><a href="#L-2332"><span class="linenos">2332</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">:</span> -</span><span id="L-2333"><a href="#L-2333"><span class="linenos">2333</span></a><span class="w"> </span><span class="sd">"""Append to or set the SELECT of the union recursively.</span> -</span><span id="L-2334"><a href="#L-2334"><span class="linenos">2334</span></a> -</span><span id="L-2335"><a href="#L-2335"><span class="linenos">2335</span></a><span class="sd"> Example:</span> -</span><span id="L-2336"><a href="#L-2336"><span class="linenos">2336</span></a><span class="sd"> >>> from sqlglot import parse_one</span> -</span><span id="L-2337"><a href="#L-2337"><span class="linenos">2337</span></a><span class="sd"> >>> parse_one("select a from x union select a from y union select a from z").select("b").sql()</span> -</span><span id="L-2338"><a href="#L-2338"><span class="linenos">2338</span></a><span class="sd"> 'SELECT a, b FROM x UNION SELECT a, b FROM y UNION SELECT a, b FROM z'</span> -</span><span id="L-2339"><a href="#L-2339"><span class="linenos">2339</span></a> -</span><span id="L-2340"><a href="#L-2340"><span class="linenos">2340</span></a><span class="sd"> Args:</span> -</span><span id="L-2341"><a href="#L-2341"><span class="linenos">2341</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="L-2342"><a href="#L-2342"><span class="linenos">2342</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="L-2343"><a href="#L-2343"><span class="linenos">2343</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="L-2344"><a href="#L-2344"><span class="linenos">2344</span></a><span class="sd"> Otherwise, this resets the expressions.</span> -</span><span id="L-2345"><a href="#L-2345"><span class="linenos">2345</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="L-2346"><a href="#L-2346"><span class="linenos">2346</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="L-2347"><a href="#L-2347"><span class="linenos">2347</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="L-2348"><a href="#L-2348"><span class="linenos">2348</span></a> -</span><span id="L-2349"><a href="#L-2349"><span class="linenos">2349</span></a><span class="sd"> Returns:</span> -</span><span id="L-2350"><a href="#L-2350"><span class="linenos">2350</span></a><span class="sd"> Union: the modified expression.</span> -</span><span id="L-2351"><a href="#L-2351"><span class="linenos">2351</span></a><span class="sd"> """</span> -</span><span id="L-2352"><a href="#L-2352"><span class="linenos">2352</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="k">if</span> <span class="n">copy</span> <span class="k">else</span> <span class="bp">self</span> -</span><span id="L-2353"><a href="#L-2353"><span class="linenos">2353</span></a> <span class="n">this</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">expressions</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-2354"><a href="#L-2354"><span class="linenos">2354</span></a> <span class="n">this</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span> -</span><span id="L-2355"><a href="#L-2355"><span class="linenos">2355</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="L-2356"><a href="#L-2356"><span class="linenos">2356</span></a> <span class="p">)</span> -</span><span id="L-2357"><a href="#L-2357"><span class="linenos">2357</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-2358"><a href="#L-2358"><span class="linenos">2358</span></a> -</span><span id="L-2359"><a href="#L-2359"><span class="linenos">2359</span></a> <span class="nd">@property</span> -</span><span id="L-2360"><a href="#L-2360"><span class="linenos">2360</span></a> <span class="k">def</span> <span class="nf">named_selects</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="L-2361"><a href="#L-2361"><span class="linenos">2361</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">named_selects</span> +</span><span id="L-2307"><a href="#L-2307"><span class="linenos">2307</span></a><span class="sd"> Example:</span> +</span><span id="L-2308"><a href="#L-2308"><span class="linenos">2308</span></a><span class="sd"> >>> select("1").union(select("1")).limit(1).sql()</span> +</span><span id="L-2309"><a href="#L-2309"><span class="linenos">2309</span></a><span class="sd"> 'SELECT * FROM (SELECT 1 UNION SELECT 1) AS _l_0 LIMIT 1'</span> +</span><span id="L-2310"><a href="#L-2310"><span class="linenos">2310</span></a> +</span><span id="L-2311"><a href="#L-2311"><span class="linenos">2311</span></a><span class="sd"> Args:</span> +</span><span id="L-2312"><a href="#L-2312"><span class="linenos">2312</span></a><span class="sd"> expression: the SQL code string to parse.</span> +</span><span id="L-2313"><a href="#L-2313"><span class="linenos">2313</span></a><span class="sd"> This can also be an integer.</span> +</span><span id="L-2314"><a href="#L-2314"><span class="linenos">2314</span></a><span class="sd"> If a `Limit` instance is passed, this is used as-is.</span> +</span><span id="L-2315"><a href="#L-2315"><span class="linenos">2315</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Limit`.</span> +</span><span id="L-2316"><a href="#L-2316"><span class="linenos">2316</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="L-2317"><a href="#L-2317"><span class="linenos">2317</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="L-2318"><a href="#L-2318"><span class="linenos">2318</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="L-2319"><a href="#L-2319"><span class="linenos">2319</span></a> +</span><span id="L-2320"><a href="#L-2320"><span class="linenos">2320</span></a><span class="sd"> Returns:</span> +</span><span id="L-2321"><a href="#L-2321"><span class="linenos">2321</span></a><span class="sd"> The limited subqueryable.</span> +</span><span id="L-2322"><a href="#L-2322"><span class="linenos">2322</span></a><span class="sd"> """</span> +</span><span id="L-2323"><a href="#L-2323"><span class="linenos">2323</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="L-2324"><a href="#L-2324"><span class="linenos">2324</span></a> <span class="n">select</span><span class="p">(</span><span class="s2">"*"</span><span class="p">)</span> +</span><span id="L-2325"><a href="#L-2325"><span class="linenos">2325</span></a> <span class="o">.</span><span class="n">from_</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">alias</span><span class="o">=</span><span class="s2">"_l_0"</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">))</span> +</span><span id="L-2326"><a href="#L-2326"><span class="linenos">2326</span></a> <span class="o">.</span><span class="n">limit</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-2327"><a href="#L-2327"><span class="linenos">2327</span></a> <span class="p">)</span> +</span><span id="L-2328"><a href="#L-2328"><span class="linenos">2328</span></a> +</span><span id="L-2329"><a href="#L-2329"><span class="linenos">2329</span></a> <span class="k">def</span> <span class="nf">select</span><span class="p">(</span> +</span><span id="L-2330"><a href="#L-2330"><span class="linenos">2330</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2331"><a href="#L-2331"><span class="linenos">2331</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="L-2332"><a href="#L-2332"><span class="linenos">2332</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2333"><a href="#L-2333"><span class="linenos">2333</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2334"><a href="#L-2334"><span class="linenos">2334</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2335"><a href="#L-2335"><span class="linenos">2335</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2336"><a href="#L-2336"><span class="linenos">2336</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">:</span> +</span><span id="L-2337"><a href="#L-2337"><span class="linenos">2337</span></a><span class="w"> </span><span class="sd">"""Append to or set the SELECT of the union recursively.</span> +</span><span id="L-2338"><a href="#L-2338"><span class="linenos">2338</span></a> +</span><span id="L-2339"><a href="#L-2339"><span class="linenos">2339</span></a><span class="sd"> Example:</span> +</span><span id="L-2340"><a href="#L-2340"><span class="linenos">2340</span></a><span class="sd"> >>> from sqlglot import parse_one</span> +</span><span id="L-2341"><a href="#L-2341"><span class="linenos">2341</span></a><span class="sd"> >>> parse_one("select a from x union select a from y union select a from z").select("b").sql()</span> +</span><span id="L-2342"><a href="#L-2342"><span class="linenos">2342</span></a><span class="sd"> 'SELECT a, b FROM x UNION SELECT a, b FROM y UNION SELECT a, b FROM z'</span> +</span><span id="L-2343"><a href="#L-2343"><span class="linenos">2343</span></a> +</span><span id="L-2344"><a href="#L-2344"><span class="linenos">2344</span></a><span class="sd"> Args:</span> +</span><span id="L-2345"><a href="#L-2345"><span class="linenos">2345</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="L-2346"><a href="#L-2346"><span class="linenos">2346</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="L-2347"><a href="#L-2347"><span class="linenos">2347</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="L-2348"><a href="#L-2348"><span class="linenos">2348</span></a><span class="sd"> Otherwise, this resets the expressions.</span> +</span><span id="L-2349"><a href="#L-2349"><span class="linenos">2349</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="L-2350"><a href="#L-2350"><span class="linenos">2350</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="L-2351"><a href="#L-2351"><span class="linenos">2351</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="L-2352"><a href="#L-2352"><span class="linenos">2352</span></a> +</span><span id="L-2353"><a href="#L-2353"><span class="linenos">2353</span></a><span class="sd"> Returns:</span> +</span><span id="L-2354"><a href="#L-2354"><span class="linenos">2354</span></a><span class="sd"> Union: the modified expression.</span> +</span><span id="L-2355"><a href="#L-2355"><span class="linenos">2355</span></a><span class="sd"> """</span> +</span><span id="L-2356"><a href="#L-2356"><span class="linenos">2356</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="k">if</span> <span class="n">copy</span> <span class="k">else</span> <span class="bp">self</span> +</span><span id="L-2357"><a href="#L-2357"><span class="linenos">2357</span></a> <span class="n">this</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">expressions</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-2358"><a href="#L-2358"><span class="linenos">2358</span></a> <span class="n">this</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span> +</span><span id="L-2359"><a href="#L-2359"><span class="linenos">2359</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="L-2360"><a href="#L-2360"><span class="linenos">2360</span></a> <span class="p">)</span> +</span><span id="L-2361"><a href="#L-2361"><span class="linenos">2361</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="L-2362"><a href="#L-2362"><span class="linenos">2362</span></a> </span><span id="L-2363"><a href="#L-2363"><span class="linenos">2363</span></a> <span class="nd">@property</span> -</span><span id="L-2364"><a href="#L-2364"><span class="linenos">2364</span></a> <span class="k">def</span> <span class="nf">is_star</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="L-2365"><a href="#L-2365"><span class="linenos">2365</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">is_star</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">is_star</span> +</span><span id="L-2364"><a href="#L-2364"><span class="linenos">2364</span></a> <span class="k">def</span> <span class="nf">named_selects</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="L-2365"><a href="#L-2365"><span class="linenos">2365</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">named_selects</span> </span><span id="L-2366"><a href="#L-2366"><span class="linenos">2366</span></a> </span><span id="L-2367"><a href="#L-2367"><span class="linenos">2367</span></a> <span class="nd">@property</span> -</span><span id="L-2368"><a href="#L-2368"><span class="linenos">2368</span></a> <span class="k">def</span> <span class="nf">selects</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="L-2369"><a href="#L-2369"><span class="linenos">2369</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">selects</span> +</span><span id="L-2368"><a href="#L-2368"><span class="linenos">2368</span></a> <span class="k">def</span> <span class="nf">is_star</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="L-2369"><a href="#L-2369"><span class="linenos">2369</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">is_star</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">is_star</span> </span><span id="L-2370"><a href="#L-2370"><span class="linenos">2370</span></a> </span><span id="L-2371"><a href="#L-2371"><span class="linenos">2371</span></a> <span class="nd">@property</span> -</span><span id="L-2372"><a href="#L-2372"><span class="linenos">2372</span></a> <span class="k">def</span> <span class="nf">left</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="L-2373"><a href="#L-2373"><span class="linenos">2373</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-2372"><a href="#L-2372"><span class="linenos">2372</span></a> <span class="k">def</span> <span class="nf">selects</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="L-2373"><a href="#L-2373"><span class="linenos">2373</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">selects</span> </span><span id="L-2374"><a href="#L-2374"><span class="linenos">2374</span></a> </span><span id="L-2375"><a href="#L-2375"><span class="linenos">2375</span></a> <span class="nd">@property</span> -</span><span id="L-2376"><a href="#L-2376"><span class="linenos">2376</span></a> <span class="k">def</span> <span class="nf">right</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="L-2377"><a href="#L-2377"><span class="linenos">2377</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span> +</span><span id="L-2376"><a href="#L-2376"><span class="linenos">2376</span></a> <span class="k">def</span> <span class="nf">left</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="L-2377"><a href="#L-2377"><span class="linenos">2377</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span> </span><span id="L-2378"><a href="#L-2378"><span class="linenos">2378</span></a> -</span><span id="L-2379"><a href="#L-2379"><span class="linenos">2379</span></a> -</span><span id="L-2380"><a href="#L-2380"><span class="linenos">2380</span></a><span class="k">class</span> <span class="nc">Except</span><span class="p">(</span><span class="n">Union</span><span class="p">):</span> -</span><span id="L-2381"><a href="#L-2381"><span class="linenos">2381</span></a> <span class="k">pass</span> +</span><span id="L-2379"><a href="#L-2379"><span class="linenos">2379</span></a> <span class="nd">@property</span> +</span><span id="L-2380"><a href="#L-2380"><span class="linenos">2380</span></a> <span class="k">def</span> <span class="nf">right</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="L-2381"><a href="#L-2381"><span class="linenos">2381</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span> </span><span id="L-2382"><a href="#L-2382"><span class="linenos">2382</span></a> </span><span id="L-2383"><a href="#L-2383"><span class="linenos">2383</span></a> -</span><span id="L-2384"><a href="#L-2384"><span class="linenos">2384</span></a><span class="k">class</span> <span class="nc">Intersect</span><span class="p">(</span><span class="n">Union</span><span class="p">):</span> +</span><span id="L-2384"><a href="#L-2384"><span class="linenos">2384</span></a><span class="k">class</span> <span class="nc">Except</span><span class="p">(</span><span class="n">Union</span><span class="p">):</span> </span><span id="L-2385"><a href="#L-2385"><span class="linenos">2385</span></a> <span class="k">pass</span> </span><span id="L-2386"><a href="#L-2386"><span class="linenos">2386</span></a> </span><span id="L-2387"><a href="#L-2387"><span class="linenos">2387</span></a> -</span><span id="L-2388"><a href="#L-2388"><span class="linenos">2388</span></a><span class="k">class</span> <span class="nc">Unnest</span><span class="p">(</span><span class="n">UDTF</span><span class="p">):</span> -</span><span id="L-2389"><a href="#L-2389"><span class="linenos">2389</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-2390"><a href="#L-2390"><span class="linenos">2390</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2391"><a href="#L-2391"><span class="linenos">2391</span></a> <span class="s2">"ordinality"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2392"><a href="#L-2392"><span class="linenos">2392</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2393"><a href="#L-2393"><span class="linenos">2393</span></a> <span class="s2">"offset"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2394"><a href="#L-2394"><span class="linenos">2394</span></a> <span class="p">}</span> -</span><span id="L-2395"><a href="#L-2395"><span class="linenos">2395</span></a> -</span><span id="L-2396"><a href="#L-2396"><span class="linenos">2396</span></a> -</span><span id="L-2397"><a href="#L-2397"><span class="linenos">2397</span></a><span class="k">class</span> <span class="nc">Update</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-2398"><a href="#L-2398"><span class="linenos">2398</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-2399"><a href="#L-2399"><span class="linenos">2399</span></a> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2400"><a href="#L-2400"><span class="linenos">2400</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2401"><a href="#L-2401"><span class="linenos">2401</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2402"><a href="#L-2402"><span class="linenos">2402</span></a> <span class="s2">"from"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2403"><a href="#L-2403"><span class="linenos">2403</span></a> <span class="s2">"where"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2404"><a href="#L-2404"><span class="linenos">2404</span></a> <span class="s2">"returning"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2405"><a href="#L-2405"><span class="linenos">2405</span></a> <span class="p">}</span> -</span><span id="L-2406"><a href="#L-2406"><span class="linenos">2406</span></a> -</span><span id="L-2407"><a href="#L-2407"><span class="linenos">2407</span></a> -</span><span id="L-2408"><a href="#L-2408"><span class="linenos">2408</span></a><span class="k">class</span> <span class="nc">Values</span><span class="p">(</span><span class="n">UDTF</span><span class="p">):</span> -</span><span id="L-2409"><a href="#L-2409"><span class="linenos">2409</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-2410"><a href="#L-2410"><span class="linenos">2410</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2411"><a href="#L-2411"><span class="linenos">2411</span></a> <span class="s2">"ordinality"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2412"><a href="#L-2412"><span class="linenos">2412</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2413"><a href="#L-2413"><span class="linenos">2413</span></a> <span class="p">}</span> -</span><span id="L-2414"><a href="#L-2414"><span class="linenos">2414</span></a> -</span><span id="L-2415"><a href="#L-2415"><span class="linenos">2415</span></a> -</span><span id="L-2416"><a href="#L-2416"><span class="linenos">2416</span></a><span class="k">class</span> <span class="nc">Var</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-2417"><a href="#L-2417"><span class="linenos">2417</span></a> <span class="k">pass</span> +</span><span id="L-2388"><a href="#L-2388"><span class="linenos">2388</span></a><span class="k">class</span> <span class="nc">Intersect</span><span class="p">(</span><span class="n">Union</span><span class="p">):</span> +</span><span id="L-2389"><a href="#L-2389"><span class="linenos">2389</span></a> <span class="k">pass</span> +</span><span id="L-2390"><a href="#L-2390"><span class="linenos">2390</span></a> +</span><span id="L-2391"><a href="#L-2391"><span class="linenos">2391</span></a> +</span><span id="L-2392"><a href="#L-2392"><span class="linenos">2392</span></a><span class="k">class</span> <span class="nc">Unnest</span><span class="p">(</span><span class="n">UDTF</span><span class="p">):</span> +</span><span id="L-2393"><a href="#L-2393"><span class="linenos">2393</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-2394"><a href="#L-2394"><span class="linenos">2394</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2395"><a href="#L-2395"><span class="linenos">2395</span></a> <span class="s2">"ordinality"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2396"><a href="#L-2396"><span class="linenos">2396</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2397"><a href="#L-2397"><span class="linenos">2397</span></a> <span class="s2">"offset"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2398"><a href="#L-2398"><span class="linenos">2398</span></a> <span class="p">}</span> +</span><span id="L-2399"><a href="#L-2399"><span class="linenos">2399</span></a> +</span><span id="L-2400"><a href="#L-2400"><span class="linenos">2400</span></a> +</span><span id="L-2401"><a href="#L-2401"><span class="linenos">2401</span></a><span class="k">class</span> <span class="nc">Update</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-2402"><a href="#L-2402"><span class="linenos">2402</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-2403"><a href="#L-2403"><span class="linenos">2403</span></a> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2404"><a href="#L-2404"><span class="linenos">2404</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2405"><a href="#L-2405"><span class="linenos">2405</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2406"><a href="#L-2406"><span class="linenos">2406</span></a> <span class="s2">"from"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2407"><a href="#L-2407"><span class="linenos">2407</span></a> <span class="s2">"where"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2408"><a href="#L-2408"><span class="linenos">2408</span></a> <span class="s2">"returning"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2409"><a href="#L-2409"><span class="linenos">2409</span></a> <span class="p">}</span> +</span><span id="L-2410"><a href="#L-2410"><span class="linenos">2410</span></a> +</span><span id="L-2411"><a href="#L-2411"><span class="linenos">2411</span></a> +</span><span id="L-2412"><a href="#L-2412"><span class="linenos">2412</span></a><span class="k">class</span> <span class="nc">Values</span><span class="p">(</span><span class="n">UDTF</span><span class="p">):</span> +</span><span id="L-2413"><a href="#L-2413"><span class="linenos">2413</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-2414"><a href="#L-2414"><span class="linenos">2414</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2415"><a href="#L-2415"><span class="linenos">2415</span></a> <span class="s2">"ordinality"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2416"><a href="#L-2416"><span class="linenos">2416</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2417"><a href="#L-2417"><span class="linenos">2417</span></a> <span class="p">}</span> </span><span id="L-2418"><a href="#L-2418"><span class="linenos">2418</span></a> </span><span id="L-2419"><a href="#L-2419"><span class="linenos">2419</span></a> -</span><span id="L-2420"><a href="#L-2420"><span class="linenos">2420</span></a><span class="k">class</span> <span class="nc">Schema</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-2421"><a href="#L-2421"><span class="linenos">2421</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-2420"><a href="#L-2420"><span class="linenos">2420</span></a><span class="k">class</span> <span class="nc">Var</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-2421"><a href="#L-2421"><span class="linenos">2421</span></a> <span class="k">pass</span> </span><span id="L-2422"><a href="#L-2422"><span class="linenos">2422</span></a> </span><span id="L-2423"><a href="#L-2423"><span class="linenos">2423</span></a> -</span><span id="L-2424"><a href="#L-2424"><span class="linenos">2424</span></a><span class="c1"># https://dev.mysql.com/doc/refman/8.0/en/select.html</span> -</span><span id="L-2425"><a href="#L-2425"><span class="linenos">2425</span></a><span class="c1"># https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/SELECT.html</span> -</span><span id="L-2426"><a href="#L-2426"><span class="linenos">2426</span></a><span class="k">class</span> <span class="nc">Lock</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-2427"><a href="#L-2427"><span class="linenos">2427</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"update"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"wait"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-2428"><a href="#L-2428"><span class="linenos">2428</span></a> -</span><span id="L-2429"><a href="#L-2429"><span class="linenos">2429</span></a> -</span><span id="L-2430"><a href="#L-2430"><span class="linenos">2430</span></a><span class="k">class</span> <span class="nc">Select</span><span class="p">(</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="L-2431"><a href="#L-2431"><span class="linenos">2431</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-2432"><a href="#L-2432"><span class="linenos">2432</span></a> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2433"><a href="#L-2433"><span class="linenos">2433</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2434"><a href="#L-2434"><span class="linenos">2434</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2435"><a href="#L-2435"><span class="linenos">2435</span></a> <span class="s2">"hint"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2436"><a href="#L-2436"><span class="linenos">2436</span></a> <span class="s2">"distinct"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2437"><a href="#L-2437"><span class="linenos">2437</span></a> <span class="s2">"struct"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#return_query_results_as_a_value_table</span> -</span><span id="L-2438"><a href="#L-2438"><span class="linenos">2438</span></a> <span class="s2">"value"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2439"><a href="#L-2439"><span class="linenos">2439</span></a> <span class="s2">"into"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2440"><a href="#L-2440"><span class="linenos">2440</span></a> <span class="s2">"from"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2441"><a href="#L-2441"><span class="linenos">2441</span></a> <span class="o">**</span><span class="n">QUERY_MODIFIERS</span><span class="p">,</span> -</span><span id="L-2442"><a href="#L-2442"><span class="linenos">2442</span></a> <span class="p">}</span> -</span><span id="L-2443"><a href="#L-2443"><span class="linenos">2443</span></a> -</span><span id="L-2444"><a href="#L-2444"><span class="linenos">2444</span></a> <span class="k">def</span> <span class="nf">from_</span><span class="p">(</span> -</span><span id="L-2445"><a href="#L-2445"><span class="linenos">2445</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="L-2446"><a href="#L-2446"><span class="linenos">2446</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-2447"><a href="#L-2447"><span class="linenos">2447</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-2448"><a href="#L-2448"><span class="linenos">2448</span></a><span class="sd"> Set the FROM expression.</span> -</span><span id="L-2449"><a href="#L-2449"><span class="linenos">2449</span></a> -</span><span id="L-2450"><a href="#L-2450"><span class="linenos">2450</span></a><span class="sd"> Example:</span> -</span><span id="L-2451"><a href="#L-2451"><span class="linenos">2451</span></a><span class="sd"> >>> Select().from_("tbl").select("x").sql()</span> -</span><span id="L-2452"><a href="#L-2452"><span class="linenos">2452</span></a><span class="sd"> 'SELECT x FROM tbl'</span> -</span><span id="L-2453"><a href="#L-2453"><span class="linenos">2453</span></a> -</span><span id="L-2454"><a href="#L-2454"><span class="linenos">2454</span></a><span class="sd"> Args:</span> -</span><span id="L-2455"><a href="#L-2455"><span class="linenos">2455</span></a><span class="sd"> expression : the SQL code strings to parse.</span> -</span><span id="L-2456"><a href="#L-2456"><span class="linenos">2456</span></a><span class="sd"> If a `From` instance is passed, this is used as-is.</span> -</span><span id="L-2457"><a href="#L-2457"><span class="linenos">2457</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `From`.</span> -</span><span id="L-2458"><a href="#L-2458"><span class="linenos">2458</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="L-2459"><a href="#L-2459"><span class="linenos">2459</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="L-2460"><a href="#L-2460"><span class="linenos">2460</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="L-2461"><a href="#L-2461"><span class="linenos">2461</span></a> -</span><span id="L-2462"><a href="#L-2462"><span class="linenos">2462</span></a><span class="sd"> Returns:</span> -</span><span id="L-2463"><a href="#L-2463"><span class="linenos">2463</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="L-2464"><a href="#L-2464"><span class="linenos">2464</span></a><span class="sd"> """</span> -</span><span id="L-2465"><a href="#L-2465"><span class="linenos">2465</span></a> <span class="k">return</span> <span class="n">_apply_builder</span><span class="p">(</span> -</span><span id="L-2466"><a href="#L-2466"><span class="linenos">2466</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> -</span><span id="L-2467"><a href="#L-2467"><span class="linenos">2467</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="L-2468"><a href="#L-2468"><span class="linenos">2468</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"from"</span><span class="p">,</span> -</span><span id="L-2469"><a href="#L-2469"><span class="linenos">2469</span></a> <span class="n">into</span><span class="o">=</span><span class="n">From</span><span class="p">,</span> -</span><span id="L-2470"><a href="#L-2470"><span class="linenos">2470</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"FROM"</span><span class="p">,</span> -</span><span id="L-2471"><a href="#L-2471"><span class="linenos">2471</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-2472"><a href="#L-2472"><span class="linenos">2472</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="L-2473"><a href="#L-2473"><span class="linenos">2473</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2474"><a href="#L-2474"><span class="linenos">2474</span></a> <span class="p">)</span> -</span><span id="L-2475"><a href="#L-2475"><span class="linenos">2475</span></a> -</span><span id="L-2476"><a href="#L-2476"><span class="linenos">2476</span></a> <span class="k">def</span> <span class="nf">group_by</span><span class="p">(</span> -</span><span id="L-2477"><a href="#L-2477"><span class="linenos">2477</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2478"><a href="#L-2478"><span class="linenos">2478</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="L-2479"><a href="#L-2479"><span class="linenos">2479</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2480"><a href="#L-2480"><span class="linenos">2480</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2481"><a href="#L-2481"><span class="linenos">2481</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2482"><a href="#L-2482"><span class="linenos">2482</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2483"><a href="#L-2483"><span class="linenos">2483</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-2484"><a href="#L-2484"><span class="linenos">2484</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-2485"><a href="#L-2485"><span class="linenos">2485</span></a><span class="sd"> Set the GROUP BY expression.</span> -</span><span id="L-2486"><a href="#L-2486"><span class="linenos">2486</span></a> -</span><span id="L-2487"><a href="#L-2487"><span class="linenos">2487</span></a><span class="sd"> Example:</span> -</span><span id="L-2488"><a href="#L-2488"><span class="linenos">2488</span></a><span class="sd"> >>> Select().from_("tbl").select("x", "COUNT(1)").group_by("x").sql()</span> -</span><span id="L-2489"><a href="#L-2489"><span class="linenos">2489</span></a><span class="sd"> 'SELECT x, COUNT(1) FROM tbl GROUP BY x'</span> -</span><span id="L-2490"><a href="#L-2490"><span class="linenos">2490</span></a> -</span><span id="L-2491"><a href="#L-2491"><span class="linenos">2491</span></a><span class="sd"> Args:</span> -</span><span id="L-2492"><a href="#L-2492"><span class="linenos">2492</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="L-2493"><a href="#L-2493"><span class="linenos">2493</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> -</span><span id="L-2494"><a href="#L-2494"><span class="linenos">2494</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Group`.</span> -</span><span id="L-2495"><a href="#L-2495"><span class="linenos">2495</span></a><span class="sd"> If nothing is passed in then a group by is not applied to the expression</span> -</span><span id="L-2496"><a href="#L-2496"><span class="linenos">2496</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="L-2497"><a href="#L-2497"><span class="linenos">2497</span></a><span class="sd"> Otherwise, this flattens all the `Group` expression into a single expression.</span> -</span><span id="L-2498"><a href="#L-2498"><span class="linenos">2498</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="L-2499"><a href="#L-2499"><span class="linenos">2499</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="L-2500"><a href="#L-2500"><span class="linenos">2500</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="L-2501"><a href="#L-2501"><span class="linenos">2501</span></a> -</span><span id="L-2502"><a href="#L-2502"><span class="linenos">2502</span></a><span class="sd"> Returns:</span> -</span><span id="L-2503"><a href="#L-2503"><span class="linenos">2503</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="L-2504"><a href="#L-2504"><span class="linenos">2504</span></a><span class="sd"> """</span> -</span><span id="L-2505"><a href="#L-2505"><span class="linenos">2505</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="L-2506"><a href="#L-2506"><span class="linenos">2506</span></a> <span class="k">return</span> <span class="bp">self</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">copy</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="L-2507"><a href="#L-2507"><span class="linenos">2507</span></a> -</span><span id="L-2508"><a href="#L-2508"><span class="linenos">2508</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> -</span><span id="L-2509"><a href="#L-2509"><span class="linenos">2509</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-2510"><a href="#L-2510"><span class="linenos">2510</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="L-2511"><a href="#L-2511"><span class="linenos">2511</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"group"</span><span class="p">,</span> -</span><span id="L-2512"><a href="#L-2512"><span class="linenos">2512</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="L-2513"><a href="#L-2513"><span class="linenos">2513</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="L-2514"><a href="#L-2514"><span class="linenos">2514</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"GROUP BY"</span><span class="p">,</span> -</span><span id="L-2515"><a href="#L-2515"><span class="linenos">2515</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Group</span><span class="p">,</span> -</span><span id="L-2516"><a href="#L-2516"><span class="linenos">2516</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-2517"><a href="#L-2517"><span class="linenos">2517</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2518"><a href="#L-2518"><span class="linenos">2518</span></a> <span class="p">)</span> -</span><span id="L-2519"><a href="#L-2519"><span class="linenos">2519</span></a> -</span><span id="L-2520"><a href="#L-2520"><span class="linenos">2520</span></a> <span class="k">def</span> <span class="nf">order_by</span><span class="p">(</span> -</span><span id="L-2521"><a href="#L-2521"><span class="linenos">2521</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2522"><a href="#L-2522"><span class="linenos">2522</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="L-2523"><a href="#L-2523"><span class="linenos">2523</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2524"><a href="#L-2524"><span class="linenos">2524</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2525"><a href="#L-2525"><span class="linenos">2525</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2526"><a href="#L-2526"><span class="linenos">2526</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2527"><a href="#L-2527"><span class="linenos">2527</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-2528"><a href="#L-2528"><span class="linenos">2528</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-2529"><a href="#L-2529"><span class="linenos">2529</span></a><span class="sd"> Set the ORDER BY expression.</span> -</span><span id="L-2530"><a href="#L-2530"><span class="linenos">2530</span></a> -</span><span id="L-2531"><a href="#L-2531"><span class="linenos">2531</span></a><span class="sd"> Example:</span> -</span><span id="L-2532"><a href="#L-2532"><span class="linenos">2532</span></a><span class="sd"> >>> Select().from_("tbl").select("x").order_by("x DESC").sql()</span> -</span><span id="L-2533"><a href="#L-2533"><span class="linenos">2533</span></a><span class="sd"> 'SELECT x FROM tbl ORDER BY x DESC'</span> -</span><span id="L-2534"><a href="#L-2534"><span class="linenos">2534</span></a> -</span><span id="L-2535"><a href="#L-2535"><span class="linenos">2535</span></a><span class="sd"> Args:</span> -</span><span id="L-2536"><a href="#L-2536"><span class="linenos">2536</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="L-2537"><a href="#L-2537"><span class="linenos">2537</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> -</span><span id="L-2538"><a href="#L-2538"><span class="linenos">2538</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Order`.</span> -</span><span id="L-2539"><a href="#L-2539"><span class="linenos">2539</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="L-2540"><a href="#L-2540"><span class="linenos">2540</span></a><span class="sd"> Otherwise, this flattens all the `Order` expression into a single expression.</span> -</span><span id="L-2541"><a href="#L-2541"><span class="linenos">2541</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="L-2542"><a href="#L-2542"><span class="linenos">2542</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="L-2543"><a href="#L-2543"><span class="linenos">2543</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="L-2544"><a href="#L-2544"><span class="linenos">2544</span></a> -</span><span id="L-2545"><a href="#L-2545"><span class="linenos">2545</span></a><span class="sd"> Returns:</span> -</span><span id="L-2546"><a href="#L-2546"><span class="linenos">2546</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="L-2547"><a href="#L-2547"><span class="linenos">2547</span></a><span class="sd"> """</span> -</span><span id="L-2548"><a href="#L-2548"><span class="linenos">2548</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> -</span><span id="L-2549"><a href="#L-2549"><span class="linenos">2549</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-2550"><a href="#L-2550"><span class="linenos">2550</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="L-2551"><a href="#L-2551"><span class="linenos">2551</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"order"</span><span class="p">,</span> -</span><span id="L-2552"><a href="#L-2552"><span class="linenos">2552</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="L-2553"><a href="#L-2553"><span class="linenos">2553</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="L-2554"><a href="#L-2554"><span class="linenos">2554</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ORDER BY"</span><span class="p">,</span> -</span><span id="L-2555"><a href="#L-2555"><span class="linenos">2555</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Order</span><span class="p">,</span> -</span><span id="L-2556"><a href="#L-2556"><span class="linenos">2556</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-2557"><a href="#L-2557"><span class="linenos">2557</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2558"><a href="#L-2558"><span class="linenos">2558</span></a> <span class="p">)</span> -</span><span id="L-2559"><a href="#L-2559"><span class="linenos">2559</span></a> -</span><span id="L-2560"><a href="#L-2560"><span class="linenos">2560</span></a> <span class="k">def</span> <span class="nf">sort_by</span><span class="p">(</span> -</span><span id="L-2561"><a href="#L-2561"><span class="linenos">2561</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2562"><a href="#L-2562"><span class="linenos">2562</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="L-2563"><a href="#L-2563"><span class="linenos">2563</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2564"><a href="#L-2564"><span class="linenos">2564</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2565"><a href="#L-2565"><span class="linenos">2565</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2566"><a href="#L-2566"><span class="linenos">2566</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2567"><a href="#L-2567"><span class="linenos">2567</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-2568"><a href="#L-2568"><span class="linenos">2568</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-2569"><a href="#L-2569"><span class="linenos">2569</span></a><span class="sd"> Set the SORT BY expression.</span> -</span><span id="L-2570"><a href="#L-2570"><span class="linenos">2570</span></a> -</span><span id="L-2571"><a href="#L-2571"><span class="linenos">2571</span></a><span class="sd"> Example:</span> -</span><span id="L-2572"><a href="#L-2572"><span class="linenos">2572</span></a><span class="sd"> >>> Select().from_("tbl").select("x").sort_by("x DESC").sql(dialect="hive")</span> -</span><span id="L-2573"><a href="#L-2573"><span class="linenos">2573</span></a><span class="sd"> 'SELECT x FROM tbl SORT BY x DESC'</span> -</span><span id="L-2574"><a href="#L-2574"><span class="linenos">2574</span></a> -</span><span id="L-2575"><a href="#L-2575"><span class="linenos">2575</span></a><span class="sd"> Args:</span> -</span><span id="L-2576"><a href="#L-2576"><span class="linenos">2576</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="L-2577"><a href="#L-2577"><span class="linenos">2577</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> -</span><span id="L-2578"><a href="#L-2578"><span class="linenos">2578</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `SORT`.</span> -</span><span id="L-2579"><a href="#L-2579"><span class="linenos">2579</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="L-2580"><a href="#L-2580"><span class="linenos">2580</span></a><span class="sd"> Otherwise, this flattens all the `Order` expression into a single expression.</span> -</span><span id="L-2581"><a href="#L-2581"><span class="linenos">2581</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="L-2582"><a href="#L-2582"><span class="linenos">2582</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="L-2583"><a href="#L-2583"><span class="linenos">2583</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="L-2584"><a href="#L-2584"><span class="linenos">2584</span></a> -</span><span id="L-2585"><a href="#L-2585"><span class="linenos">2585</span></a><span class="sd"> Returns:</span> -</span><span id="L-2586"><a href="#L-2586"><span class="linenos">2586</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="L-2587"><a href="#L-2587"><span class="linenos">2587</span></a><span class="sd"> """</span> -</span><span id="L-2588"><a href="#L-2588"><span class="linenos">2588</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> -</span><span id="L-2589"><a href="#L-2589"><span class="linenos">2589</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-2590"><a href="#L-2590"><span class="linenos">2590</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="L-2591"><a href="#L-2591"><span class="linenos">2591</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"sort"</span><span class="p">,</span> -</span><span id="L-2592"><a href="#L-2592"><span class="linenos">2592</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="L-2593"><a href="#L-2593"><span class="linenos">2593</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="L-2594"><a href="#L-2594"><span class="linenos">2594</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"SORT BY"</span><span class="p">,</span> -</span><span id="L-2595"><a href="#L-2595"><span class="linenos">2595</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Sort</span><span class="p">,</span> -</span><span id="L-2596"><a href="#L-2596"><span class="linenos">2596</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-2597"><a href="#L-2597"><span class="linenos">2597</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2598"><a href="#L-2598"><span class="linenos">2598</span></a> <span class="p">)</span> -</span><span id="L-2599"><a href="#L-2599"><span class="linenos">2599</span></a> -</span><span id="L-2600"><a href="#L-2600"><span class="linenos">2600</span></a> <span class="k">def</span> <span class="nf">cluster_by</span><span class="p">(</span> -</span><span id="L-2601"><a href="#L-2601"><span class="linenos">2601</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2602"><a href="#L-2602"><span class="linenos">2602</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="L-2603"><a href="#L-2603"><span class="linenos">2603</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2604"><a href="#L-2604"><span class="linenos">2604</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2605"><a href="#L-2605"><span class="linenos">2605</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2606"><a href="#L-2606"><span class="linenos">2606</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2607"><a href="#L-2607"><span class="linenos">2607</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-2608"><a href="#L-2608"><span class="linenos">2608</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-2609"><a href="#L-2609"><span class="linenos">2609</span></a><span class="sd"> Set the CLUSTER BY expression.</span> -</span><span id="L-2610"><a href="#L-2610"><span class="linenos">2610</span></a> -</span><span id="L-2611"><a href="#L-2611"><span class="linenos">2611</span></a><span class="sd"> Example:</span> -</span><span id="L-2612"><a href="#L-2612"><span class="linenos">2612</span></a><span class="sd"> >>> Select().from_("tbl").select("x").cluster_by("x DESC").sql(dialect="hive")</span> -</span><span id="L-2613"><a href="#L-2613"><span class="linenos">2613</span></a><span class="sd"> 'SELECT x FROM tbl CLUSTER BY x DESC'</span> -</span><span id="L-2614"><a href="#L-2614"><span class="linenos">2614</span></a> -</span><span id="L-2615"><a href="#L-2615"><span class="linenos">2615</span></a><span class="sd"> Args:</span> -</span><span id="L-2616"><a href="#L-2616"><span class="linenos">2616</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="L-2617"><a href="#L-2617"><span class="linenos">2617</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> -</span><span id="L-2618"><a href="#L-2618"><span class="linenos">2618</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Cluster`.</span> -</span><span id="L-2619"><a href="#L-2619"><span class="linenos">2619</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="L-2620"><a href="#L-2620"><span class="linenos">2620</span></a><span class="sd"> Otherwise, this flattens all the `Order` expression into a single expression.</span> -</span><span id="L-2621"><a href="#L-2621"><span class="linenos">2621</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="L-2622"><a href="#L-2622"><span class="linenos">2622</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="L-2623"><a href="#L-2623"><span class="linenos">2623</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="L-2624"><a href="#L-2624"><span class="linenos">2624</span></a> -</span><span id="L-2625"><a href="#L-2625"><span class="linenos">2625</span></a><span class="sd"> Returns:</span> -</span><span id="L-2626"><a href="#L-2626"><span class="linenos">2626</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="L-2627"><a href="#L-2627"><span class="linenos">2627</span></a><span class="sd"> """</span> -</span><span id="L-2628"><a href="#L-2628"><span class="linenos">2628</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> -</span><span id="L-2629"><a href="#L-2629"><span class="linenos">2629</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-2630"><a href="#L-2630"><span class="linenos">2630</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="L-2631"><a href="#L-2631"><span class="linenos">2631</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"cluster"</span><span class="p">,</span> -</span><span id="L-2632"><a href="#L-2632"><span class="linenos">2632</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="L-2633"><a href="#L-2633"><span class="linenos">2633</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="L-2634"><a href="#L-2634"><span class="linenos">2634</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"CLUSTER BY"</span><span class="p">,</span> -</span><span id="L-2635"><a href="#L-2635"><span class="linenos">2635</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Cluster</span><span class="p">,</span> -</span><span id="L-2636"><a href="#L-2636"><span class="linenos">2636</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-2637"><a href="#L-2637"><span class="linenos">2637</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2638"><a href="#L-2638"><span class="linenos">2638</span></a> <span class="p">)</span> -</span><span id="L-2639"><a href="#L-2639"><span class="linenos">2639</span></a> -</span><span id="L-2640"><a href="#L-2640"><span class="linenos">2640</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span> -</span><span id="L-2641"><a href="#L-2641"><span class="linenos">2641</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="L-2642"><a href="#L-2642"><span class="linenos">2642</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-2643"><a href="#L-2643"><span class="linenos">2643</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-2644"><a href="#L-2644"><span class="linenos">2644</span></a><span class="sd"> Set the LIMIT expression.</span> -</span><span id="L-2645"><a href="#L-2645"><span class="linenos">2645</span></a> -</span><span id="L-2646"><a href="#L-2646"><span class="linenos">2646</span></a><span class="sd"> Example:</span> -</span><span id="L-2647"><a href="#L-2647"><span class="linenos">2647</span></a><span class="sd"> >>> Select().from_("tbl").select("x").limit(10).sql()</span> -</span><span id="L-2648"><a href="#L-2648"><span class="linenos">2648</span></a><span class="sd"> 'SELECT x FROM tbl LIMIT 10'</span> -</span><span id="L-2649"><a href="#L-2649"><span class="linenos">2649</span></a> -</span><span id="L-2650"><a href="#L-2650"><span class="linenos">2650</span></a><span class="sd"> Args:</span> -</span><span id="L-2651"><a href="#L-2651"><span class="linenos">2651</span></a><span class="sd"> expression: the SQL code string to parse.</span> -</span><span id="L-2652"><a href="#L-2652"><span class="linenos">2652</span></a><span class="sd"> This can also be an integer.</span> -</span><span id="L-2653"><a href="#L-2653"><span class="linenos">2653</span></a><span class="sd"> If a `Limit` instance is passed, this is used as-is.</span> -</span><span id="L-2654"><a href="#L-2654"><span class="linenos">2654</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Limit`.</span> -</span><span id="L-2655"><a href="#L-2655"><span class="linenos">2655</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="L-2656"><a href="#L-2656"><span class="linenos">2656</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="L-2657"><a href="#L-2657"><span class="linenos">2657</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="L-2658"><a href="#L-2658"><span class="linenos">2658</span></a> -</span><span id="L-2659"><a href="#L-2659"><span class="linenos">2659</span></a><span class="sd"> Returns:</span> -</span><span id="L-2660"><a href="#L-2660"><span class="linenos">2660</span></a><span class="sd"> Select: the modified expression.</span> -</span><span id="L-2661"><a href="#L-2661"><span class="linenos">2661</span></a><span class="sd"> """</span> -</span><span id="L-2662"><a href="#L-2662"><span class="linenos">2662</span></a> <span class="k">return</span> <span class="n">_apply_builder</span><span class="p">(</span> -</span><span id="L-2663"><a href="#L-2663"><span class="linenos">2663</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> -</span><span id="L-2664"><a href="#L-2664"><span class="linenos">2664</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="L-2665"><a href="#L-2665"><span class="linenos">2665</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"limit"</span><span class="p">,</span> -</span><span id="L-2666"><a href="#L-2666"><span class="linenos">2666</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Limit</span><span class="p">,</span> -</span><span id="L-2667"><a href="#L-2667"><span class="linenos">2667</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"LIMIT"</span><span class="p">,</span> -</span><span id="L-2668"><a href="#L-2668"><span class="linenos">2668</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-2669"><a href="#L-2669"><span class="linenos">2669</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="L-2670"><a href="#L-2670"><span class="linenos">2670</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2671"><a href="#L-2671"><span class="linenos">2671</span></a> <span class="p">)</span> -</span><span id="L-2672"><a href="#L-2672"><span class="linenos">2672</span></a> -</span><span id="L-2673"><a href="#L-2673"><span class="linenos">2673</span></a> <span class="k">def</span> <span class="nf">offset</span><span class="p">(</span> -</span><span id="L-2674"><a href="#L-2674"><span class="linenos">2674</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="L-2675"><a href="#L-2675"><span class="linenos">2675</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-2676"><a href="#L-2676"><span class="linenos">2676</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-2677"><a href="#L-2677"><span class="linenos">2677</span></a><span class="sd"> Set the OFFSET expression.</span> -</span><span id="L-2678"><a href="#L-2678"><span class="linenos">2678</span></a> -</span><span id="L-2679"><a href="#L-2679"><span class="linenos">2679</span></a><span class="sd"> Example:</span> -</span><span id="L-2680"><a href="#L-2680"><span class="linenos">2680</span></a><span class="sd"> >>> Select().from_("tbl").select("x").offset(10).sql()</span> -</span><span id="L-2681"><a href="#L-2681"><span class="linenos">2681</span></a><span class="sd"> 'SELECT x FROM tbl OFFSET 10'</span> -</span><span id="L-2682"><a href="#L-2682"><span class="linenos">2682</span></a> -</span><span id="L-2683"><a href="#L-2683"><span class="linenos">2683</span></a><span class="sd"> Args:</span> -</span><span id="L-2684"><a href="#L-2684"><span class="linenos">2684</span></a><span class="sd"> expression: the SQL code string to parse.</span> -</span><span id="L-2685"><a href="#L-2685"><span class="linenos">2685</span></a><span class="sd"> This can also be an integer.</span> -</span><span id="L-2686"><a href="#L-2686"><span class="linenos">2686</span></a><span class="sd"> If a `Offset` instance is passed, this is used as-is.</span> -</span><span id="L-2687"><a href="#L-2687"><span class="linenos">2687</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Offset`.</span> -</span><span id="L-2688"><a href="#L-2688"><span class="linenos">2688</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="L-2689"><a href="#L-2689"><span class="linenos">2689</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="L-2690"><a href="#L-2690"><span class="linenos">2690</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="L-2691"><a href="#L-2691"><span class="linenos">2691</span></a> -</span><span id="L-2692"><a href="#L-2692"><span class="linenos">2692</span></a><span class="sd"> Returns:</span> -</span><span id="L-2693"><a href="#L-2693"><span class="linenos">2693</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="L-2694"><a href="#L-2694"><span class="linenos">2694</span></a><span class="sd"> """</span> -</span><span id="L-2695"><a href="#L-2695"><span class="linenos">2695</span></a> <span class="k">return</span> <span class="n">_apply_builder</span><span class="p">(</span> -</span><span id="L-2696"><a href="#L-2696"><span class="linenos">2696</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> -</span><span id="L-2697"><a href="#L-2697"><span class="linenos">2697</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="L-2698"><a href="#L-2698"><span class="linenos">2698</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"offset"</span><span class="p">,</span> -</span><span id="L-2699"><a href="#L-2699"><span class="linenos">2699</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Offset</span><span class="p">,</span> -</span><span id="L-2700"><a href="#L-2700"><span class="linenos">2700</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"OFFSET"</span><span class="p">,</span> -</span><span id="L-2701"><a href="#L-2701"><span class="linenos">2701</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-2702"><a href="#L-2702"><span class="linenos">2702</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="L-2703"><a href="#L-2703"><span class="linenos">2703</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2704"><a href="#L-2704"><span class="linenos">2704</span></a> <span class="p">)</span> -</span><span id="L-2705"><a href="#L-2705"><span class="linenos">2705</span></a> -</span><span id="L-2706"><a href="#L-2706"><span class="linenos">2706</span></a> <span class="k">def</span> <span class="nf">select</span><span class="p">(</span> -</span><span id="L-2707"><a href="#L-2707"><span class="linenos">2707</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2708"><a href="#L-2708"><span class="linenos">2708</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="L-2709"><a href="#L-2709"><span class="linenos">2709</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2710"><a href="#L-2710"><span class="linenos">2710</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2711"><a href="#L-2711"><span class="linenos">2711</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2712"><a href="#L-2712"><span class="linenos">2712</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2713"><a href="#L-2713"><span class="linenos">2713</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-2714"><a href="#L-2714"><span class="linenos">2714</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-2715"><a href="#L-2715"><span class="linenos">2715</span></a><span class="sd"> Append to or set the SELECT expressions.</span> -</span><span id="L-2716"><a href="#L-2716"><span class="linenos">2716</span></a> -</span><span id="L-2717"><a href="#L-2717"><span class="linenos">2717</span></a><span class="sd"> Example:</span> -</span><span id="L-2718"><a href="#L-2718"><span class="linenos">2718</span></a><span class="sd"> >>> Select().select("x", "y").sql()</span> -</span><span id="L-2719"><a href="#L-2719"><span class="linenos">2719</span></a><span class="sd"> 'SELECT x, y'</span> -</span><span id="L-2720"><a href="#L-2720"><span class="linenos">2720</span></a> -</span><span id="L-2721"><a href="#L-2721"><span class="linenos">2721</span></a><span class="sd"> Args:</span> -</span><span id="L-2722"><a href="#L-2722"><span class="linenos">2722</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="L-2723"><a href="#L-2723"><span class="linenos">2723</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="L-2724"><a href="#L-2724"><span class="linenos">2724</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="L-2725"><a href="#L-2725"><span class="linenos">2725</span></a><span class="sd"> Otherwise, this resets the expressions.</span> -</span><span id="L-2726"><a href="#L-2726"><span class="linenos">2726</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="L-2727"><a href="#L-2727"><span class="linenos">2727</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="L-2728"><a href="#L-2728"><span class="linenos">2728</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="L-2729"><a href="#L-2729"><span class="linenos">2729</span></a> -</span><span id="L-2730"><a href="#L-2730"><span class="linenos">2730</span></a><span class="sd"> Returns:</span> -</span><span id="L-2731"><a href="#L-2731"><span class="linenos">2731</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="L-2732"><a href="#L-2732"><span class="linenos">2732</span></a><span class="sd"> """</span> -</span><span id="L-2733"><a href="#L-2733"><span class="linenos">2733</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> -</span><span id="L-2734"><a href="#L-2734"><span class="linenos">2734</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-2735"><a href="#L-2735"><span class="linenos">2735</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="L-2736"><a href="#L-2736"><span class="linenos">2736</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"expressions"</span><span class="p">,</span> -</span><span id="L-2737"><a href="#L-2737"><span class="linenos">2737</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="L-2738"><a href="#L-2738"><span class="linenos">2738</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-2739"><a href="#L-2739"><span class="linenos">2739</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="L-2740"><a href="#L-2740"><span class="linenos">2740</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2741"><a href="#L-2741"><span class="linenos">2741</span></a> <span class="p">)</span> -</span><span id="L-2742"><a href="#L-2742"><span class="linenos">2742</span></a> -</span><span id="L-2743"><a href="#L-2743"><span class="linenos">2743</span></a> <span class="k">def</span> <span class="nf">lateral</span><span class="p">(</span> -</span><span id="L-2744"><a href="#L-2744"><span class="linenos">2744</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2745"><a href="#L-2745"><span class="linenos">2745</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="L-2746"><a href="#L-2746"><span class="linenos">2746</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2747"><a href="#L-2747"><span class="linenos">2747</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2748"><a href="#L-2748"><span class="linenos">2748</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2749"><a href="#L-2749"><span class="linenos">2749</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2750"><a href="#L-2750"><span class="linenos">2750</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-2751"><a href="#L-2751"><span class="linenos">2751</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-2752"><a href="#L-2752"><span class="linenos">2752</span></a><span class="sd"> Append to or set the LATERAL expressions.</span> -</span><span id="L-2753"><a href="#L-2753"><span class="linenos">2753</span></a> -</span><span id="L-2754"><a href="#L-2754"><span class="linenos">2754</span></a><span class="sd"> Example:</span> -</span><span id="L-2755"><a href="#L-2755"><span class="linenos">2755</span></a><span class="sd"> >>> Select().select("x").lateral("OUTER explode(y) tbl2 AS z").from_("tbl").sql()</span> -</span><span id="L-2756"><a href="#L-2756"><span class="linenos">2756</span></a><span class="sd"> 'SELECT x FROM tbl LATERAL VIEW OUTER EXPLODE(y) tbl2 AS z'</span> -</span><span id="L-2757"><a href="#L-2757"><span class="linenos">2757</span></a> -</span><span id="L-2758"><a href="#L-2758"><span class="linenos">2758</span></a><span class="sd"> Args:</span> -</span><span id="L-2759"><a href="#L-2759"><span class="linenos">2759</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="L-2760"><a href="#L-2760"><span class="linenos">2760</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="L-2761"><a href="#L-2761"><span class="linenos">2761</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="L-2762"><a href="#L-2762"><span class="linenos">2762</span></a><span class="sd"> Otherwise, this resets the expressions.</span> -</span><span id="L-2763"><a href="#L-2763"><span class="linenos">2763</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="L-2764"><a href="#L-2764"><span class="linenos">2764</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="L-2765"><a href="#L-2765"><span class="linenos">2765</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="L-2766"><a href="#L-2766"><span class="linenos">2766</span></a> -</span><span id="L-2767"><a href="#L-2767"><span class="linenos">2767</span></a><span class="sd"> Returns:</span> -</span><span id="L-2768"><a href="#L-2768"><span class="linenos">2768</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="L-2769"><a href="#L-2769"><span class="linenos">2769</span></a><span class="sd"> """</span> -</span><span id="L-2770"><a href="#L-2770"><span class="linenos">2770</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> -</span><span id="L-2771"><a href="#L-2771"><span class="linenos">2771</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-2772"><a href="#L-2772"><span class="linenos">2772</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="L-2773"><a href="#L-2773"><span class="linenos">2773</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"laterals"</span><span class="p">,</span> -</span><span id="L-2774"><a href="#L-2774"><span class="linenos">2774</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="L-2775"><a href="#L-2775"><span class="linenos">2775</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Lateral</span><span class="p">,</span> -</span><span id="L-2776"><a href="#L-2776"><span class="linenos">2776</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"LATERAL VIEW"</span><span class="p">,</span> -</span><span id="L-2777"><a href="#L-2777"><span class="linenos">2777</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-2778"><a href="#L-2778"><span class="linenos">2778</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="L-2779"><a href="#L-2779"><span class="linenos">2779</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2780"><a href="#L-2780"><span class="linenos">2780</span></a> <span class="p">)</span> -</span><span id="L-2781"><a href="#L-2781"><span class="linenos">2781</span></a> -</span><span id="L-2782"><a href="#L-2782"><span class="linenos">2782</span></a> <span class="k">def</span> <span class="nf">join</span><span class="p">(</span> -</span><span id="L-2783"><a href="#L-2783"><span class="linenos">2783</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2784"><a href="#L-2784"><span class="linenos">2784</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="L-2785"><a href="#L-2785"><span class="linenos">2785</span></a> <span class="n">on</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2786"><a href="#L-2786"><span class="linenos">2786</span></a> <span class="n">using</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">ExpOrStr</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">ExpOrStr</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2787"><a href="#L-2787"><span class="linenos">2787</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2788"><a href="#L-2788"><span class="linenos">2788</span></a> <span class="n">join_type</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-2789"><a href="#L-2789"><span class="linenos">2789</span></a> <span class="n">join_alias</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">Identifier</span> <span class="o">|</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-2790"><a href="#L-2790"><span class="linenos">2790</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2791"><a href="#L-2791"><span class="linenos">2791</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2792"><a href="#L-2792"><span class="linenos">2792</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2793"><a href="#L-2793"><span class="linenos">2793</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-2794"><a href="#L-2794"><span class="linenos">2794</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-2795"><a href="#L-2795"><span class="linenos">2795</span></a><span class="sd"> Append to or set the JOIN expressions.</span> -</span><span id="L-2796"><a href="#L-2796"><span class="linenos">2796</span></a> -</span><span id="L-2797"><a href="#L-2797"><span class="linenos">2797</span></a><span class="sd"> Example:</span> -</span><span id="L-2798"><a href="#L-2798"><span class="linenos">2798</span></a><span class="sd"> >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y").sql()</span> -</span><span id="L-2799"><a href="#L-2799"><span class="linenos">2799</span></a><span class="sd"> 'SELECT * FROM tbl JOIN tbl2 ON tbl1.y = tbl2.y'</span> -</span><span id="L-2800"><a href="#L-2800"><span class="linenos">2800</span></a> -</span><span id="L-2801"><a href="#L-2801"><span class="linenos">2801</span></a><span class="sd"> >>> Select().select("1").from_("a").join("b", using=["x", "y", "z"]).sql()</span> -</span><span id="L-2802"><a href="#L-2802"><span class="linenos">2802</span></a><span class="sd"> 'SELECT 1 FROM a JOIN b USING (x, y, z)'</span> -</span><span id="L-2803"><a href="#L-2803"><span class="linenos">2803</span></a> -</span><span id="L-2804"><a href="#L-2804"><span class="linenos">2804</span></a><span class="sd"> Use `join_type` to change the type of join:</span> +</span><span id="L-2424"><a href="#L-2424"><span class="linenos">2424</span></a><span class="k">class</span> <span class="nc">Schema</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-2425"><a href="#L-2425"><span class="linenos">2425</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-2426"><a href="#L-2426"><span class="linenos">2426</span></a> +</span><span id="L-2427"><a href="#L-2427"><span class="linenos">2427</span></a> +</span><span id="L-2428"><a href="#L-2428"><span class="linenos">2428</span></a><span class="c1"># https://dev.mysql.com/doc/refman/8.0/en/select.html</span> +</span><span id="L-2429"><a href="#L-2429"><span class="linenos">2429</span></a><span class="c1"># https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/SELECT.html</span> +</span><span id="L-2430"><a href="#L-2430"><span class="linenos">2430</span></a><span class="k">class</span> <span class="nc">Lock</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-2431"><a href="#L-2431"><span class="linenos">2431</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"update"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"wait"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-2432"><a href="#L-2432"><span class="linenos">2432</span></a> +</span><span id="L-2433"><a href="#L-2433"><span class="linenos">2433</span></a> +</span><span id="L-2434"><a href="#L-2434"><span class="linenos">2434</span></a><span class="k">class</span> <span class="nc">Select</span><span class="p">(</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="L-2435"><a href="#L-2435"><span class="linenos">2435</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-2436"><a href="#L-2436"><span class="linenos">2436</span></a> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2437"><a href="#L-2437"><span class="linenos">2437</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2438"><a href="#L-2438"><span class="linenos">2438</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2439"><a href="#L-2439"><span class="linenos">2439</span></a> <span class="s2">"hint"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2440"><a href="#L-2440"><span class="linenos">2440</span></a> <span class="s2">"distinct"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2441"><a href="#L-2441"><span class="linenos">2441</span></a> <span class="s2">"into"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2442"><a href="#L-2442"><span class="linenos">2442</span></a> <span class="s2">"from"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2443"><a href="#L-2443"><span class="linenos">2443</span></a> <span class="o">**</span><span class="n">QUERY_MODIFIERS</span><span class="p">,</span> +</span><span id="L-2444"><a href="#L-2444"><span class="linenos">2444</span></a> <span class="p">}</span> +</span><span id="L-2445"><a href="#L-2445"><span class="linenos">2445</span></a> +</span><span id="L-2446"><a href="#L-2446"><span class="linenos">2446</span></a> <span class="k">def</span> <span class="nf">from_</span><span class="p">(</span> +</span><span id="L-2447"><a href="#L-2447"><span class="linenos">2447</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="L-2448"><a href="#L-2448"><span class="linenos">2448</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-2449"><a href="#L-2449"><span class="linenos">2449</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-2450"><a href="#L-2450"><span class="linenos">2450</span></a><span class="sd"> Set the FROM expression.</span> +</span><span id="L-2451"><a href="#L-2451"><span class="linenos">2451</span></a> +</span><span id="L-2452"><a href="#L-2452"><span class="linenos">2452</span></a><span class="sd"> Example:</span> +</span><span id="L-2453"><a href="#L-2453"><span class="linenos">2453</span></a><span class="sd"> >>> Select().from_("tbl").select("x").sql()</span> +</span><span id="L-2454"><a href="#L-2454"><span class="linenos">2454</span></a><span class="sd"> 'SELECT x FROM tbl'</span> +</span><span id="L-2455"><a href="#L-2455"><span class="linenos">2455</span></a> +</span><span id="L-2456"><a href="#L-2456"><span class="linenos">2456</span></a><span class="sd"> Args:</span> +</span><span id="L-2457"><a href="#L-2457"><span class="linenos">2457</span></a><span class="sd"> expression : the SQL code strings to parse.</span> +</span><span id="L-2458"><a href="#L-2458"><span class="linenos">2458</span></a><span class="sd"> If a `From` instance is passed, this is used as-is.</span> +</span><span id="L-2459"><a href="#L-2459"><span class="linenos">2459</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `From`.</span> +</span><span id="L-2460"><a href="#L-2460"><span class="linenos">2460</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="L-2461"><a href="#L-2461"><span class="linenos">2461</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="L-2462"><a href="#L-2462"><span class="linenos">2462</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="L-2463"><a href="#L-2463"><span class="linenos">2463</span></a> +</span><span id="L-2464"><a href="#L-2464"><span class="linenos">2464</span></a><span class="sd"> Returns:</span> +</span><span id="L-2465"><a href="#L-2465"><span class="linenos">2465</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="L-2466"><a href="#L-2466"><span class="linenos">2466</span></a><span class="sd"> """</span> +</span><span id="L-2467"><a href="#L-2467"><span class="linenos">2467</span></a> <span class="k">return</span> <span class="n">_apply_builder</span><span class="p">(</span> +</span><span id="L-2468"><a href="#L-2468"><span class="linenos">2468</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> +</span><span id="L-2469"><a href="#L-2469"><span class="linenos">2469</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="L-2470"><a href="#L-2470"><span class="linenos">2470</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"from"</span><span class="p">,</span> +</span><span id="L-2471"><a href="#L-2471"><span class="linenos">2471</span></a> <span class="n">into</span><span class="o">=</span><span class="n">From</span><span class="p">,</span> +</span><span id="L-2472"><a href="#L-2472"><span class="linenos">2472</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"FROM"</span><span class="p">,</span> +</span><span id="L-2473"><a href="#L-2473"><span class="linenos">2473</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-2474"><a href="#L-2474"><span class="linenos">2474</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="L-2475"><a href="#L-2475"><span class="linenos">2475</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2476"><a href="#L-2476"><span class="linenos">2476</span></a> <span class="p">)</span> +</span><span id="L-2477"><a href="#L-2477"><span class="linenos">2477</span></a> +</span><span id="L-2478"><a href="#L-2478"><span class="linenos">2478</span></a> <span class="k">def</span> <span class="nf">group_by</span><span class="p">(</span> +</span><span id="L-2479"><a href="#L-2479"><span class="linenos">2479</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2480"><a href="#L-2480"><span class="linenos">2480</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="L-2481"><a href="#L-2481"><span class="linenos">2481</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2482"><a href="#L-2482"><span class="linenos">2482</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2483"><a href="#L-2483"><span class="linenos">2483</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2484"><a href="#L-2484"><span class="linenos">2484</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2485"><a href="#L-2485"><span class="linenos">2485</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-2486"><a href="#L-2486"><span class="linenos">2486</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-2487"><a href="#L-2487"><span class="linenos">2487</span></a><span class="sd"> Set the GROUP BY expression.</span> +</span><span id="L-2488"><a href="#L-2488"><span class="linenos">2488</span></a> +</span><span id="L-2489"><a href="#L-2489"><span class="linenos">2489</span></a><span class="sd"> Example:</span> +</span><span id="L-2490"><a href="#L-2490"><span class="linenos">2490</span></a><span class="sd"> >>> Select().from_("tbl").select("x", "COUNT(1)").group_by("x").sql()</span> +</span><span id="L-2491"><a href="#L-2491"><span class="linenos">2491</span></a><span class="sd"> 'SELECT x, COUNT(1) FROM tbl GROUP BY x'</span> +</span><span id="L-2492"><a href="#L-2492"><span class="linenos">2492</span></a> +</span><span id="L-2493"><a href="#L-2493"><span class="linenos">2493</span></a><span class="sd"> Args:</span> +</span><span id="L-2494"><a href="#L-2494"><span class="linenos">2494</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="L-2495"><a href="#L-2495"><span class="linenos">2495</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> +</span><span id="L-2496"><a href="#L-2496"><span class="linenos">2496</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Group`.</span> +</span><span id="L-2497"><a href="#L-2497"><span class="linenos">2497</span></a><span class="sd"> If nothing is passed in then a group by is not applied to the expression</span> +</span><span id="L-2498"><a href="#L-2498"><span class="linenos">2498</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="L-2499"><a href="#L-2499"><span class="linenos">2499</span></a><span class="sd"> Otherwise, this flattens all the `Group` expression into a single expression.</span> +</span><span id="L-2500"><a href="#L-2500"><span class="linenos">2500</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="L-2501"><a href="#L-2501"><span class="linenos">2501</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="L-2502"><a href="#L-2502"><span class="linenos">2502</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="L-2503"><a href="#L-2503"><span class="linenos">2503</span></a> +</span><span id="L-2504"><a href="#L-2504"><span class="linenos">2504</span></a><span class="sd"> Returns:</span> +</span><span id="L-2505"><a href="#L-2505"><span class="linenos">2505</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="L-2506"><a href="#L-2506"><span class="linenos">2506</span></a><span class="sd"> """</span> +</span><span id="L-2507"><a href="#L-2507"><span class="linenos">2507</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="L-2508"><a href="#L-2508"><span class="linenos">2508</span></a> <span class="k">return</span> <span class="bp">self</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">copy</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="L-2509"><a href="#L-2509"><span class="linenos">2509</span></a> +</span><span id="L-2510"><a href="#L-2510"><span class="linenos">2510</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> +</span><span id="L-2511"><a href="#L-2511"><span class="linenos">2511</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-2512"><a href="#L-2512"><span class="linenos">2512</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="L-2513"><a href="#L-2513"><span class="linenos">2513</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"group"</span><span class="p">,</span> +</span><span id="L-2514"><a href="#L-2514"><span class="linenos">2514</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="L-2515"><a href="#L-2515"><span class="linenos">2515</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="L-2516"><a href="#L-2516"><span class="linenos">2516</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"GROUP BY"</span><span class="p">,</span> +</span><span id="L-2517"><a href="#L-2517"><span class="linenos">2517</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Group</span><span class="p">,</span> +</span><span id="L-2518"><a href="#L-2518"><span class="linenos">2518</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-2519"><a href="#L-2519"><span class="linenos">2519</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2520"><a href="#L-2520"><span class="linenos">2520</span></a> <span class="p">)</span> +</span><span id="L-2521"><a href="#L-2521"><span class="linenos">2521</span></a> +</span><span id="L-2522"><a href="#L-2522"><span class="linenos">2522</span></a> <span class="k">def</span> <span class="nf">order_by</span><span class="p">(</span> +</span><span id="L-2523"><a href="#L-2523"><span class="linenos">2523</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2524"><a href="#L-2524"><span class="linenos">2524</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="L-2525"><a href="#L-2525"><span class="linenos">2525</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2526"><a href="#L-2526"><span class="linenos">2526</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2527"><a href="#L-2527"><span class="linenos">2527</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2528"><a href="#L-2528"><span class="linenos">2528</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2529"><a href="#L-2529"><span class="linenos">2529</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-2530"><a href="#L-2530"><span class="linenos">2530</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-2531"><a href="#L-2531"><span class="linenos">2531</span></a><span class="sd"> Set the ORDER BY expression.</span> +</span><span id="L-2532"><a href="#L-2532"><span class="linenos">2532</span></a> +</span><span id="L-2533"><a href="#L-2533"><span class="linenos">2533</span></a><span class="sd"> Example:</span> +</span><span id="L-2534"><a href="#L-2534"><span class="linenos">2534</span></a><span class="sd"> >>> Select().from_("tbl").select("x").order_by("x DESC").sql()</span> +</span><span id="L-2535"><a href="#L-2535"><span class="linenos">2535</span></a><span class="sd"> 'SELECT x FROM tbl ORDER BY x DESC'</span> +</span><span id="L-2536"><a href="#L-2536"><span class="linenos">2536</span></a> +</span><span id="L-2537"><a href="#L-2537"><span class="linenos">2537</span></a><span class="sd"> Args:</span> +</span><span id="L-2538"><a href="#L-2538"><span class="linenos">2538</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="L-2539"><a href="#L-2539"><span class="linenos">2539</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> +</span><span id="L-2540"><a href="#L-2540"><span class="linenos">2540</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Order`.</span> +</span><span id="L-2541"><a href="#L-2541"><span class="linenos">2541</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="L-2542"><a href="#L-2542"><span class="linenos">2542</span></a><span class="sd"> Otherwise, this flattens all the `Order` expression into a single expression.</span> +</span><span id="L-2543"><a href="#L-2543"><span class="linenos">2543</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="L-2544"><a href="#L-2544"><span class="linenos">2544</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="L-2545"><a href="#L-2545"><span class="linenos">2545</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="L-2546"><a href="#L-2546"><span class="linenos">2546</span></a> +</span><span id="L-2547"><a href="#L-2547"><span class="linenos">2547</span></a><span class="sd"> Returns:</span> +</span><span id="L-2548"><a href="#L-2548"><span class="linenos">2548</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="L-2549"><a href="#L-2549"><span class="linenos">2549</span></a><span class="sd"> """</span> +</span><span id="L-2550"><a href="#L-2550"><span class="linenos">2550</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> +</span><span id="L-2551"><a href="#L-2551"><span class="linenos">2551</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-2552"><a href="#L-2552"><span class="linenos">2552</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="L-2553"><a href="#L-2553"><span class="linenos">2553</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"order"</span><span class="p">,</span> +</span><span id="L-2554"><a href="#L-2554"><span class="linenos">2554</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="L-2555"><a href="#L-2555"><span class="linenos">2555</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="L-2556"><a href="#L-2556"><span class="linenos">2556</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ORDER BY"</span><span class="p">,</span> +</span><span id="L-2557"><a href="#L-2557"><span class="linenos">2557</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Order</span><span class="p">,</span> +</span><span id="L-2558"><a href="#L-2558"><span class="linenos">2558</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-2559"><a href="#L-2559"><span class="linenos">2559</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2560"><a href="#L-2560"><span class="linenos">2560</span></a> <span class="p">)</span> +</span><span id="L-2561"><a href="#L-2561"><span class="linenos">2561</span></a> +</span><span id="L-2562"><a href="#L-2562"><span class="linenos">2562</span></a> <span class="k">def</span> <span class="nf">sort_by</span><span class="p">(</span> +</span><span id="L-2563"><a href="#L-2563"><span class="linenos">2563</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2564"><a href="#L-2564"><span class="linenos">2564</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="L-2565"><a href="#L-2565"><span class="linenos">2565</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2566"><a href="#L-2566"><span class="linenos">2566</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2567"><a href="#L-2567"><span class="linenos">2567</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2568"><a href="#L-2568"><span class="linenos">2568</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2569"><a href="#L-2569"><span class="linenos">2569</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-2570"><a href="#L-2570"><span class="linenos">2570</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-2571"><a href="#L-2571"><span class="linenos">2571</span></a><span class="sd"> Set the SORT BY expression.</span> +</span><span id="L-2572"><a href="#L-2572"><span class="linenos">2572</span></a> +</span><span id="L-2573"><a href="#L-2573"><span class="linenos">2573</span></a><span class="sd"> Example:</span> +</span><span id="L-2574"><a href="#L-2574"><span class="linenos">2574</span></a><span class="sd"> >>> Select().from_("tbl").select("x").sort_by("x DESC").sql(dialect="hive")</span> +</span><span id="L-2575"><a href="#L-2575"><span class="linenos">2575</span></a><span class="sd"> 'SELECT x FROM tbl SORT BY x DESC'</span> +</span><span id="L-2576"><a href="#L-2576"><span class="linenos">2576</span></a> +</span><span id="L-2577"><a href="#L-2577"><span class="linenos">2577</span></a><span class="sd"> Args:</span> +</span><span id="L-2578"><a href="#L-2578"><span class="linenos">2578</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="L-2579"><a href="#L-2579"><span class="linenos">2579</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> +</span><span id="L-2580"><a href="#L-2580"><span class="linenos">2580</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `SORT`.</span> +</span><span id="L-2581"><a href="#L-2581"><span class="linenos">2581</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="L-2582"><a href="#L-2582"><span class="linenos">2582</span></a><span class="sd"> Otherwise, this flattens all the `Order` expression into a single expression.</span> +</span><span id="L-2583"><a href="#L-2583"><span class="linenos">2583</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="L-2584"><a href="#L-2584"><span class="linenos">2584</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="L-2585"><a href="#L-2585"><span class="linenos">2585</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="L-2586"><a href="#L-2586"><span class="linenos">2586</span></a> +</span><span id="L-2587"><a href="#L-2587"><span class="linenos">2587</span></a><span class="sd"> Returns:</span> +</span><span id="L-2588"><a href="#L-2588"><span class="linenos">2588</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="L-2589"><a href="#L-2589"><span class="linenos">2589</span></a><span class="sd"> """</span> +</span><span id="L-2590"><a href="#L-2590"><span class="linenos">2590</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> +</span><span id="L-2591"><a href="#L-2591"><span class="linenos">2591</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-2592"><a href="#L-2592"><span class="linenos">2592</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="L-2593"><a href="#L-2593"><span class="linenos">2593</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"sort"</span><span class="p">,</span> +</span><span id="L-2594"><a href="#L-2594"><span class="linenos">2594</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="L-2595"><a href="#L-2595"><span class="linenos">2595</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="L-2596"><a href="#L-2596"><span class="linenos">2596</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"SORT BY"</span><span class="p">,</span> +</span><span id="L-2597"><a href="#L-2597"><span class="linenos">2597</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Sort</span><span class="p">,</span> +</span><span id="L-2598"><a href="#L-2598"><span class="linenos">2598</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-2599"><a href="#L-2599"><span class="linenos">2599</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2600"><a href="#L-2600"><span class="linenos">2600</span></a> <span class="p">)</span> +</span><span id="L-2601"><a href="#L-2601"><span class="linenos">2601</span></a> +</span><span id="L-2602"><a href="#L-2602"><span class="linenos">2602</span></a> <span class="k">def</span> <span class="nf">cluster_by</span><span class="p">(</span> +</span><span id="L-2603"><a href="#L-2603"><span class="linenos">2603</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2604"><a href="#L-2604"><span class="linenos">2604</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="L-2605"><a href="#L-2605"><span class="linenos">2605</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2606"><a href="#L-2606"><span class="linenos">2606</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2607"><a href="#L-2607"><span class="linenos">2607</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2608"><a href="#L-2608"><span class="linenos">2608</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2609"><a href="#L-2609"><span class="linenos">2609</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-2610"><a href="#L-2610"><span class="linenos">2610</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-2611"><a href="#L-2611"><span class="linenos">2611</span></a><span class="sd"> Set the CLUSTER BY expression.</span> +</span><span id="L-2612"><a href="#L-2612"><span class="linenos">2612</span></a> +</span><span id="L-2613"><a href="#L-2613"><span class="linenos">2613</span></a><span class="sd"> Example:</span> +</span><span id="L-2614"><a href="#L-2614"><span class="linenos">2614</span></a><span class="sd"> >>> Select().from_("tbl").select("x").cluster_by("x DESC").sql(dialect="hive")</span> +</span><span id="L-2615"><a href="#L-2615"><span class="linenos">2615</span></a><span class="sd"> 'SELECT x FROM tbl CLUSTER BY x DESC'</span> +</span><span id="L-2616"><a href="#L-2616"><span class="linenos">2616</span></a> +</span><span id="L-2617"><a href="#L-2617"><span class="linenos">2617</span></a><span class="sd"> Args:</span> +</span><span id="L-2618"><a href="#L-2618"><span class="linenos">2618</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="L-2619"><a href="#L-2619"><span class="linenos">2619</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> +</span><span id="L-2620"><a href="#L-2620"><span class="linenos">2620</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Cluster`.</span> +</span><span id="L-2621"><a href="#L-2621"><span class="linenos">2621</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="L-2622"><a href="#L-2622"><span class="linenos">2622</span></a><span class="sd"> Otherwise, this flattens all the `Order` expression into a single expression.</span> +</span><span id="L-2623"><a href="#L-2623"><span class="linenos">2623</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="L-2624"><a href="#L-2624"><span class="linenos">2624</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="L-2625"><a href="#L-2625"><span class="linenos">2625</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="L-2626"><a href="#L-2626"><span class="linenos">2626</span></a> +</span><span id="L-2627"><a href="#L-2627"><span class="linenos">2627</span></a><span class="sd"> Returns:</span> +</span><span id="L-2628"><a href="#L-2628"><span class="linenos">2628</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="L-2629"><a href="#L-2629"><span class="linenos">2629</span></a><span class="sd"> """</span> +</span><span id="L-2630"><a href="#L-2630"><span class="linenos">2630</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> +</span><span id="L-2631"><a href="#L-2631"><span class="linenos">2631</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-2632"><a href="#L-2632"><span class="linenos">2632</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="L-2633"><a href="#L-2633"><span class="linenos">2633</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"cluster"</span><span class="p">,</span> +</span><span id="L-2634"><a href="#L-2634"><span class="linenos">2634</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="L-2635"><a href="#L-2635"><span class="linenos">2635</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="L-2636"><a href="#L-2636"><span class="linenos">2636</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"CLUSTER BY"</span><span class="p">,</span> +</span><span id="L-2637"><a href="#L-2637"><span class="linenos">2637</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Cluster</span><span class="p">,</span> +</span><span id="L-2638"><a href="#L-2638"><span class="linenos">2638</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-2639"><a href="#L-2639"><span class="linenos">2639</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2640"><a href="#L-2640"><span class="linenos">2640</span></a> <span class="p">)</span> +</span><span id="L-2641"><a href="#L-2641"><span class="linenos">2641</span></a> +</span><span id="L-2642"><a href="#L-2642"><span class="linenos">2642</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span> +</span><span id="L-2643"><a href="#L-2643"><span class="linenos">2643</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="L-2644"><a href="#L-2644"><span class="linenos">2644</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-2645"><a href="#L-2645"><span class="linenos">2645</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-2646"><a href="#L-2646"><span class="linenos">2646</span></a><span class="sd"> Set the LIMIT expression.</span> +</span><span id="L-2647"><a href="#L-2647"><span class="linenos">2647</span></a> +</span><span id="L-2648"><a href="#L-2648"><span class="linenos">2648</span></a><span class="sd"> Example:</span> +</span><span id="L-2649"><a href="#L-2649"><span class="linenos">2649</span></a><span class="sd"> >>> Select().from_("tbl").select("x").limit(10).sql()</span> +</span><span id="L-2650"><a href="#L-2650"><span class="linenos">2650</span></a><span class="sd"> 'SELECT x FROM tbl LIMIT 10'</span> +</span><span id="L-2651"><a href="#L-2651"><span class="linenos">2651</span></a> +</span><span id="L-2652"><a href="#L-2652"><span class="linenos">2652</span></a><span class="sd"> Args:</span> +</span><span id="L-2653"><a href="#L-2653"><span class="linenos">2653</span></a><span class="sd"> expression: the SQL code string to parse.</span> +</span><span id="L-2654"><a href="#L-2654"><span class="linenos">2654</span></a><span class="sd"> This can also be an integer.</span> +</span><span id="L-2655"><a href="#L-2655"><span class="linenos">2655</span></a><span class="sd"> If a `Limit` instance is passed, this is used as-is.</span> +</span><span id="L-2656"><a href="#L-2656"><span class="linenos">2656</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Limit`.</span> +</span><span id="L-2657"><a href="#L-2657"><span class="linenos">2657</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="L-2658"><a href="#L-2658"><span class="linenos">2658</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="L-2659"><a href="#L-2659"><span class="linenos">2659</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="L-2660"><a href="#L-2660"><span class="linenos">2660</span></a> +</span><span id="L-2661"><a href="#L-2661"><span class="linenos">2661</span></a><span class="sd"> Returns:</span> +</span><span id="L-2662"><a href="#L-2662"><span class="linenos">2662</span></a><span class="sd"> Select: the modified expression.</span> +</span><span id="L-2663"><a href="#L-2663"><span class="linenos">2663</span></a><span class="sd"> """</span> +</span><span id="L-2664"><a href="#L-2664"><span class="linenos">2664</span></a> <span class="k">return</span> <span class="n">_apply_builder</span><span class="p">(</span> +</span><span id="L-2665"><a href="#L-2665"><span class="linenos">2665</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> +</span><span id="L-2666"><a href="#L-2666"><span class="linenos">2666</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="L-2667"><a href="#L-2667"><span class="linenos">2667</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"limit"</span><span class="p">,</span> +</span><span id="L-2668"><a href="#L-2668"><span class="linenos">2668</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Limit</span><span class="p">,</span> +</span><span id="L-2669"><a href="#L-2669"><span class="linenos">2669</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"LIMIT"</span><span class="p">,</span> +</span><span id="L-2670"><a href="#L-2670"><span class="linenos">2670</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-2671"><a href="#L-2671"><span class="linenos">2671</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="L-2672"><a href="#L-2672"><span class="linenos">2672</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2673"><a href="#L-2673"><span class="linenos">2673</span></a> <span class="p">)</span> +</span><span id="L-2674"><a href="#L-2674"><span class="linenos">2674</span></a> +</span><span id="L-2675"><a href="#L-2675"><span class="linenos">2675</span></a> <span class="k">def</span> <span class="nf">offset</span><span class="p">(</span> +</span><span id="L-2676"><a href="#L-2676"><span class="linenos">2676</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="L-2677"><a href="#L-2677"><span class="linenos">2677</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-2678"><a href="#L-2678"><span class="linenos">2678</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-2679"><a href="#L-2679"><span class="linenos">2679</span></a><span class="sd"> Set the OFFSET expression.</span> +</span><span id="L-2680"><a href="#L-2680"><span class="linenos">2680</span></a> +</span><span id="L-2681"><a href="#L-2681"><span class="linenos">2681</span></a><span class="sd"> Example:</span> +</span><span id="L-2682"><a href="#L-2682"><span class="linenos">2682</span></a><span class="sd"> >>> Select().from_("tbl").select("x").offset(10).sql()</span> +</span><span id="L-2683"><a href="#L-2683"><span class="linenos">2683</span></a><span class="sd"> 'SELECT x FROM tbl OFFSET 10'</span> +</span><span id="L-2684"><a href="#L-2684"><span class="linenos">2684</span></a> +</span><span id="L-2685"><a href="#L-2685"><span class="linenos">2685</span></a><span class="sd"> Args:</span> +</span><span id="L-2686"><a href="#L-2686"><span class="linenos">2686</span></a><span class="sd"> expression: the SQL code string to parse.</span> +</span><span id="L-2687"><a href="#L-2687"><span class="linenos">2687</span></a><span class="sd"> This can also be an integer.</span> +</span><span id="L-2688"><a href="#L-2688"><span class="linenos">2688</span></a><span class="sd"> If a `Offset` instance is passed, this is used as-is.</span> +</span><span id="L-2689"><a href="#L-2689"><span class="linenos">2689</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Offset`.</span> +</span><span id="L-2690"><a href="#L-2690"><span class="linenos">2690</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="L-2691"><a href="#L-2691"><span class="linenos">2691</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="L-2692"><a href="#L-2692"><span class="linenos">2692</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="L-2693"><a href="#L-2693"><span class="linenos">2693</span></a> +</span><span id="L-2694"><a href="#L-2694"><span class="linenos">2694</span></a><span class="sd"> Returns:</span> +</span><span id="L-2695"><a href="#L-2695"><span class="linenos">2695</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="L-2696"><a href="#L-2696"><span class="linenos">2696</span></a><span class="sd"> """</span> +</span><span id="L-2697"><a href="#L-2697"><span class="linenos">2697</span></a> <span class="k">return</span> <span class="n">_apply_builder</span><span class="p">(</span> +</span><span id="L-2698"><a href="#L-2698"><span class="linenos">2698</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> +</span><span id="L-2699"><a href="#L-2699"><span class="linenos">2699</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="L-2700"><a href="#L-2700"><span class="linenos">2700</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"offset"</span><span class="p">,</span> +</span><span id="L-2701"><a href="#L-2701"><span class="linenos">2701</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Offset</span><span class="p">,</span> +</span><span id="L-2702"><a href="#L-2702"><span class="linenos">2702</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"OFFSET"</span><span class="p">,</span> +</span><span id="L-2703"><a href="#L-2703"><span class="linenos">2703</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-2704"><a href="#L-2704"><span class="linenos">2704</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="L-2705"><a href="#L-2705"><span class="linenos">2705</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2706"><a href="#L-2706"><span class="linenos">2706</span></a> <span class="p">)</span> +</span><span id="L-2707"><a href="#L-2707"><span class="linenos">2707</span></a> +</span><span id="L-2708"><a href="#L-2708"><span class="linenos">2708</span></a> <span class="k">def</span> <span class="nf">select</span><span class="p">(</span> +</span><span id="L-2709"><a href="#L-2709"><span class="linenos">2709</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2710"><a href="#L-2710"><span class="linenos">2710</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="L-2711"><a href="#L-2711"><span class="linenos">2711</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2712"><a href="#L-2712"><span class="linenos">2712</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2713"><a href="#L-2713"><span class="linenos">2713</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2714"><a href="#L-2714"><span class="linenos">2714</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2715"><a href="#L-2715"><span class="linenos">2715</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-2716"><a href="#L-2716"><span class="linenos">2716</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-2717"><a href="#L-2717"><span class="linenos">2717</span></a><span class="sd"> Append to or set the SELECT expressions.</span> +</span><span id="L-2718"><a href="#L-2718"><span class="linenos">2718</span></a> +</span><span id="L-2719"><a href="#L-2719"><span class="linenos">2719</span></a><span class="sd"> Example:</span> +</span><span id="L-2720"><a href="#L-2720"><span class="linenos">2720</span></a><span class="sd"> >>> Select().select("x", "y").sql()</span> +</span><span id="L-2721"><a href="#L-2721"><span class="linenos">2721</span></a><span class="sd"> 'SELECT x, y'</span> +</span><span id="L-2722"><a href="#L-2722"><span class="linenos">2722</span></a> +</span><span id="L-2723"><a href="#L-2723"><span class="linenos">2723</span></a><span class="sd"> Args:</span> +</span><span id="L-2724"><a href="#L-2724"><span class="linenos">2724</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="L-2725"><a href="#L-2725"><span class="linenos">2725</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="L-2726"><a href="#L-2726"><span class="linenos">2726</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="L-2727"><a href="#L-2727"><span class="linenos">2727</span></a><span class="sd"> Otherwise, this resets the expressions.</span> +</span><span id="L-2728"><a href="#L-2728"><span class="linenos">2728</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="L-2729"><a href="#L-2729"><span class="linenos">2729</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="L-2730"><a href="#L-2730"><span class="linenos">2730</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="L-2731"><a href="#L-2731"><span class="linenos">2731</span></a> +</span><span id="L-2732"><a href="#L-2732"><span class="linenos">2732</span></a><span class="sd"> Returns:</span> +</span><span id="L-2733"><a href="#L-2733"><span class="linenos">2733</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="L-2734"><a href="#L-2734"><span class="linenos">2734</span></a><span class="sd"> """</span> +</span><span id="L-2735"><a href="#L-2735"><span class="linenos">2735</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> +</span><span id="L-2736"><a href="#L-2736"><span class="linenos">2736</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-2737"><a href="#L-2737"><span class="linenos">2737</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="L-2738"><a href="#L-2738"><span class="linenos">2738</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"expressions"</span><span class="p">,</span> +</span><span id="L-2739"><a href="#L-2739"><span class="linenos">2739</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="L-2740"><a href="#L-2740"><span class="linenos">2740</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-2741"><a href="#L-2741"><span class="linenos">2741</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="L-2742"><a href="#L-2742"><span class="linenos">2742</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2743"><a href="#L-2743"><span class="linenos">2743</span></a> <span class="p">)</span> +</span><span id="L-2744"><a href="#L-2744"><span class="linenos">2744</span></a> +</span><span id="L-2745"><a href="#L-2745"><span class="linenos">2745</span></a> <span class="k">def</span> <span class="nf">lateral</span><span class="p">(</span> +</span><span id="L-2746"><a href="#L-2746"><span class="linenos">2746</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2747"><a href="#L-2747"><span class="linenos">2747</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="L-2748"><a href="#L-2748"><span class="linenos">2748</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2749"><a href="#L-2749"><span class="linenos">2749</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2750"><a href="#L-2750"><span class="linenos">2750</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2751"><a href="#L-2751"><span class="linenos">2751</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2752"><a href="#L-2752"><span class="linenos">2752</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-2753"><a href="#L-2753"><span class="linenos">2753</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-2754"><a href="#L-2754"><span class="linenos">2754</span></a><span class="sd"> Append to or set the LATERAL expressions.</span> +</span><span id="L-2755"><a href="#L-2755"><span class="linenos">2755</span></a> +</span><span id="L-2756"><a href="#L-2756"><span class="linenos">2756</span></a><span class="sd"> Example:</span> +</span><span id="L-2757"><a href="#L-2757"><span class="linenos">2757</span></a><span class="sd"> >>> Select().select("x").lateral("OUTER explode(y) tbl2 AS z").from_("tbl").sql()</span> +</span><span id="L-2758"><a href="#L-2758"><span class="linenos">2758</span></a><span class="sd"> 'SELECT x FROM tbl LATERAL VIEW OUTER EXPLODE(y) tbl2 AS z'</span> +</span><span id="L-2759"><a href="#L-2759"><span class="linenos">2759</span></a> +</span><span id="L-2760"><a href="#L-2760"><span class="linenos">2760</span></a><span class="sd"> Args:</span> +</span><span id="L-2761"><a href="#L-2761"><span class="linenos">2761</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="L-2762"><a href="#L-2762"><span class="linenos">2762</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="L-2763"><a href="#L-2763"><span class="linenos">2763</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="L-2764"><a href="#L-2764"><span class="linenos">2764</span></a><span class="sd"> Otherwise, this resets the expressions.</span> +</span><span id="L-2765"><a href="#L-2765"><span class="linenos">2765</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="L-2766"><a href="#L-2766"><span class="linenos">2766</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="L-2767"><a href="#L-2767"><span class="linenos">2767</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="L-2768"><a href="#L-2768"><span class="linenos">2768</span></a> +</span><span id="L-2769"><a href="#L-2769"><span class="linenos">2769</span></a><span class="sd"> Returns:</span> +</span><span id="L-2770"><a href="#L-2770"><span class="linenos">2770</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="L-2771"><a href="#L-2771"><span class="linenos">2771</span></a><span class="sd"> """</span> +</span><span id="L-2772"><a href="#L-2772"><span class="linenos">2772</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> +</span><span id="L-2773"><a href="#L-2773"><span class="linenos">2773</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-2774"><a href="#L-2774"><span class="linenos">2774</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="L-2775"><a href="#L-2775"><span class="linenos">2775</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"laterals"</span><span class="p">,</span> +</span><span id="L-2776"><a href="#L-2776"><span class="linenos">2776</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="L-2777"><a href="#L-2777"><span class="linenos">2777</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Lateral</span><span class="p">,</span> +</span><span id="L-2778"><a href="#L-2778"><span class="linenos">2778</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"LATERAL VIEW"</span><span class="p">,</span> +</span><span id="L-2779"><a href="#L-2779"><span class="linenos">2779</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-2780"><a href="#L-2780"><span class="linenos">2780</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="L-2781"><a href="#L-2781"><span class="linenos">2781</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2782"><a href="#L-2782"><span class="linenos">2782</span></a> <span class="p">)</span> +</span><span id="L-2783"><a href="#L-2783"><span class="linenos">2783</span></a> +</span><span id="L-2784"><a href="#L-2784"><span class="linenos">2784</span></a> <span class="k">def</span> <span class="nf">join</span><span class="p">(</span> +</span><span id="L-2785"><a href="#L-2785"><span class="linenos">2785</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2786"><a href="#L-2786"><span class="linenos">2786</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="L-2787"><a href="#L-2787"><span class="linenos">2787</span></a> <span class="n">on</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2788"><a href="#L-2788"><span class="linenos">2788</span></a> <span class="n">using</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">ExpOrStr</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">ExpOrStr</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2789"><a href="#L-2789"><span class="linenos">2789</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2790"><a href="#L-2790"><span class="linenos">2790</span></a> <span class="n">join_type</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-2791"><a href="#L-2791"><span class="linenos">2791</span></a> <span class="n">join_alias</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">Identifier</span> <span class="o">|</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-2792"><a href="#L-2792"><span class="linenos">2792</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2793"><a href="#L-2793"><span class="linenos">2793</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2794"><a href="#L-2794"><span class="linenos">2794</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2795"><a href="#L-2795"><span class="linenos">2795</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-2796"><a href="#L-2796"><span class="linenos">2796</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-2797"><a href="#L-2797"><span class="linenos">2797</span></a><span class="sd"> Append to or set the JOIN expressions.</span> +</span><span id="L-2798"><a href="#L-2798"><span class="linenos">2798</span></a> +</span><span id="L-2799"><a href="#L-2799"><span class="linenos">2799</span></a><span class="sd"> Example:</span> +</span><span id="L-2800"><a href="#L-2800"><span class="linenos">2800</span></a><span class="sd"> >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y").sql()</span> +</span><span id="L-2801"><a href="#L-2801"><span class="linenos">2801</span></a><span class="sd"> 'SELECT * FROM tbl JOIN tbl2 ON tbl1.y = tbl2.y'</span> +</span><span id="L-2802"><a href="#L-2802"><span class="linenos">2802</span></a> +</span><span id="L-2803"><a href="#L-2803"><span class="linenos">2803</span></a><span class="sd"> >>> Select().select("1").from_("a").join("b", using=["x", "y", "z"]).sql()</span> +</span><span id="L-2804"><a href="#L-2804"><span class="linenos">2804</span></a><span class="sd"> 'SELECT 1 FROM a JOIN b USING (x, y, z)'</span> </span><span id="L-2805"><a href="#L-2805"><span class="linenos">2805</span></a> -</span><span id="L-2806"><a href="#L-2806"><span class="linenos">2806</span></a><span class="sd"> >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y", join_type="left outer").sql()</span> -</span><span id="L-2807"><a href="#L-2807"><span class="linenos">2807</span></a><span class="sd"> 'SELECT * FROM tbl LEFT OUTER JOIN tbl2 ON tbl1.y = tbl2.y'</span> -</span><span id="L-2808"><a href="#L-2808"><span class="linenos">2808</span></a> -</span><span id="L-2809"><a href="#L-2809"><span class="linenos">2809</span></a><span class="sd"> Args:</span> -</span><span id="L-2810"><a href="#L-2810"><span class="linenos">2810</span></a><span class="sd"> expression: the SQL code string to parse.</span> -</span><span id="L-2811"><a href="#L-2811"><span class="linenos">2811</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="L-2812"><a href="#L-2812"><span class="linenos">2812</span></a><span class="sd"> on: optionally specify the join "on" criteria as a SQL string.</span> +</span><span id="L-2806"><a href="#L-2806"><span class="linenos">2806</span></a><span class="sd"> Use `join_type` to change the type of join:</span> +</span><span id="L-2807"><a href="#L-2807"><span class="linenos">2807</span></a> +</span><span id="L-2808"><a href="#L-2808"><span class="linenos">2808</span></a><span class="sd"> >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y", join_type="left outer").sql()</span> +</span><span id="L-2809"><a href="#L-2809"><span class="linenos">2809</span></a><span class="sd"> 'SELECT * FROM tbl LEFT OUTER JOIN tbl2 ON tbl1.y = tbl2.y'</span> +</span><span id="L-2810"><a href="#L-2810"><span class="linenos">2810</span></a> +</span><span id="L-2811"><a href="#L-2811"><span class="linenos">2811</span></a><span class="sd"> Args:</span> +</span><span id="L-2812"><a href="#L-2812"><span class="linenos">2812</span></a><span class="sd"> expression: the SQL code string to parse.</span> </span><span id="L-2813"><a href="#L-2813"><span class="linenos">2813</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="L-2814"><a href="#L-2814"><span class="linenos">2814</span></a><span class="sd"> using: optionally specify the join "using" criteria as a SQL string.</span> +</span><span id="L-2814"><a href="#L-2814"><span class="linenos">2814</span></a><span class="sd"> on: optionally specify the join "on" criteria as a SQL string.</span> </span><span id="L-2815"><a href="#L-2815"><span class="linenos">2815</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="L-2816"><a href="#L-2816"><span class="linenos">2816</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="L-2817"><a href="#L-2817"><span class="linenos">2817</span></a><span class="sd"> Otherwise, this resets the expressions.</span> -</span><span id="L-2818"><a href="#L-2818"><span class="linenos">2818</span></a><span class="sd"> join_type: if set, alter the parsed join type.</span> -</span><span id="L-2819"><a href="#L-2819"><span class="linenos">2819</span></a><span class="sd"> join_alias: an optional alias for the joined source.</span> -</span><span id="L-2820"><a href="#L-2820"><span class="linenos">2820</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="L-2821"><a href="#L-2821"><span class="linenos">2821</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="L-2822"><a href="#L-2822"><span class="linenos">2822</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="L-2823"><a href="#L-2823"><span class="linenos">2823</span></a> -</span><span id="L-2824"><a href="#L-2824"><span class="linenos">2824</span></a><span class="sd"> Returns:</span> -</span><span id="L-2825"><a href="#L-2825"><span class="linenos">2825</span></a><span class="sd"> Select: the modified expression.</span> -</span><span id="L-2826"><a href="#L-2826"><span class="linenos">2826</span></a><span class="sd"> """</span> -</span><span id="L-2827"><a href="#L-2827"><span class="linenos">2827</span></a> <span class="n">parse_args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"dialect"</span><span class="p">:</span> <span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">}</span> -</span><span id="L-2828"><a href="#L-2828"><span class="linenos">2828</span></a> -</span><span id="L-2829"><a href="#L-2829"><span class="linenos">2829</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="L-2830"><a href="#L-2830"><span class="linenos">2830</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Join</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"JOIN"</span><span class="p">,</span> <span class="o">**</span><span class="n">parse_args</span><span class="p">)</span> -</span><span id="L-2831"><a href="#L-2831"><span class="linenos">2831</span></a> <span class="k">except</span> <span class="n">ParseError</span><span class="p">:</span> -</span><span id="L-2832"><a href="#L-2832"><span class="linenos">2832</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="p">(</span><span class="n">Join</span><span class="p">,</span> <span class="n">Expression</span><span class="p">),</span> <span class="o">**</span><span class="n">parse_args</span><span class="p">)</span> -</span><span id="L-2833"><a href="#L-2833"><span class="linenos">2833</span></a> -</span><span id="L-2834"><a href="#L-2834"><span class="linenos">2834</span></a> <span class="n">join</span> <span class="o">=</span> <span class="n">expression</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Join</span><span class="p">)</span> <span class="k">else</span> <span class="n">Join</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-2816"><a href="#L-2816"><span class="linenos">2816</span></a><span class="sd"> using: optionally specify the join "using" criteria as a SQL string.</span> +</span><span id="L-2817"><a href="#L-2817"><span class="linenos">2817</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="L-2818"><a href="#L-2818"><span class="linenos">2818</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="L-2819"><a href="#L-2819"><span class="linenos">2819</span></a><span class="sd"> Otherwise, this resets the expressions.</span> +</span><span id="L-2820"><a href="#L-2820"><span class="linenos">2820</span></a><span class="sd"> join_type: if set, alter the parsed join type.</span> +</span><span id="L-2821"><a href="#L-2821"><span class="linenos">2821</span></a><span class="sd"> join_alias: an optional alias for the joined source.</span> +</span><span id="L-2822"><a href="#L-2822"><span class="linenos">2822</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="L-2823"><a href="#L-2823"><span class="linenos">2823</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="L-2824"><a href="#L-2824"><span class="linenos">2824</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="L-2825"><a href="#L-2825"><span class="linenos">2825</span></a> +</span><span id="L-2826"><a href="#L-2826"><span class="linenos">2826</span></a><span class="sd"> Returns:</span> +</span><span id="L-2827"><a href="#L-2827"><span class="linenos">2827</span></a><span class="sd"> Select: the modified expression.</span> +</span><span id="L-2828"><a href="#L-2828"><span class="linenos">2828</span></a><span class="sd"> """</span> +</span><span id="L-2829"><a href="#L-2829"><span class="linenos">2829</span></a> <span class="n">parse_args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"dialect"</span><span class="p">:</span> <span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">}</span> +</span><span id="L-2830"><a href="#L-2830"><span class="linenos">2830</span></a> +</span><span id="L-2831"><a href="#L-2831"><span class="linenos">2831</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="L-2832"><a href="#L-2832"><span class="linenos">2832</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Join</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"JOIN"</span><span class="p">,</span> <span class="o">**</span><span class="n">parse_args</span><span class="p">)</span> +</span><span id="L-2833"><a href="#L-2833"><span class="linenos">2833</span></a> <span class="k">except</span> <span class="n">ParseError</span><span class="p">:</span> +</span><span id="L-2834"><a href="#L-2834"><span class="linenos">2834</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="p">(</span><span class="n">Join</span><span class="p">,</span> <span class="n">Expression</span><span class="p">),</span> <span class="o">**</span><span class="n">parse_args</span><span class="p">)</span> </span><span id="L-2835"><a href="#L-2835"><span class="linenos">2835</span></a> -</span><span id="L-2836"><a href="#L-2836"><span class="linenos">2836</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">Select</span><span class="p">):</span> -</span><span id="L-2837"><a href="#L-2837"><span class="linenos">2837</span></a> <span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">subquery</span><span class="p">())</span> -</span><span id="L-2838"><a href="#L-2838"><span class="linenos">2838</span></a> -</span><span id="L-2839"><a href="#L-2839"><span class="linenos">2839</span></a> <span class="k">if</span> <span class="n">join_type</span><span class="p">:</span> -</span><span id="L-2840"><a href="#L-2840"><span class="linenos">2840</span></a> <span class="n">method</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">Token</span><span class="p">]</span> -</span><span id="L-2841"><a href="#L-2841"><span class="linenos">2841</span></a> <span class="n">side</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">Token</span><span class="p">]</span> -</span><span id="L-2842"><a href="#L-2842"><span class="linenos">2842</span></a> <span class="n">kind</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">Token</span><span class="p">]</span> -</span><span id="L-2843"><a href="#L-2843"><span class="linenos">2843</span></a> -</span><span id="L-2844"><a href="#L-2844"><span class="linenos">2844</span></a> <span class="n">method</span><span class="p">,</span> <span class="n">side</span><span class="p">,</span> <span class="n">kind</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">join_type</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="s2">"JOIN_TYPE"</span><span class="p">,</span> <span class="o">**</span><span class="n">parse_args</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="L-2836"><a href="#L-2836"><span class="linenos">2836</span></a> <span class="n">join</span> <span class="o">=</span> <span class="n">expression</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Join</span><span class="p">)</span> <span class="k">else</span> <span class="n">Join</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-2837"><a href="#L-2837"><span class="linenos">2837</span></a> +</span><span id="L-2838"><a href="#L-2838"><span class="linenos">2838</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">Select</span><span class="p">):</span> +</span><span id="L-2839"><a href="#L-2839"><span class="linenos">2839</span></a> <span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">subquery</span><span class="p">())</span> +</span><span id="L-2840"><a href="#L-2840"><span class="linenos">2840</span></a> +</span><span id="L-2841"><a href="#L-2841"><span class="linenos">2841</span></a> <span class="k">if</span> <span class="n">join_type</span><span class="p">:</span> +</span><span id="L-2842"><a href="#L-2842"><span class="linenos">2842</span></a> <span class="n">method</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">Token</span><span class="p">]</span> +</span><span id="L-2843"><a href="#L-2843"><span class="linenos">2843</span></a> <span class="n">side</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">Token</span><span class="p">]</span> +</span><span id="L-2844"><a href="#L-2844"><span class="linenos">2844</span></a> <span class="n">kind</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">Token</span><span class="p">]</span> </span><span id="L-2845"><a href="#L-2845"><span class="linenos">2845</span></a> -</span><span id="L-2846"><a href="#L-2846"><span class="linenos">2846</span></a> <span class="k">if</span> <span class="n">method</span><span class="p">:</span> -</span><span id="L-2847"><a href="#L-2847"><span class="linenos">2847</span></a> <span class="n">join</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">method</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> -</span><span id="L-2848"><a href="#L-2848"><span class="linenos">2848</span></a> <span class="k">if</span> <span class="n">side</span><span class="p">:</span> -</span><span id="L-2849"><a href="#L-2849"><span class="linenos">2849</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"side"</span><span class="p">,</span> <span class="n">side</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> -</span><span id="L-2850"><a href="#L-2850"><span class="linenos">2850</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="L-2851"><a href="#L-2851"><span class="linenos">2851</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="n">kind</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> -</span><span id="L-2852"><a href="#L-2852"><span class="linenos">2852</span></a> -</span><span id="L-2853"><a href="#L-2853"><span class="linenos">2853</span></a> <span class="k">if</span> <span class="n">on</span><span class="p">:</span> -</span><span id="L-2854"><a href="#L-2854"><span class="linenos">2854</span></a> <span class="n">on</span> <span class="o">=</span> <span class="n">and_</span><span class="p">(</span><span class="o">*</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">on</span><span class="p">),</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-2855"><a href="#L-2855"><span class="linenos">2855</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"on"</span><span class="p">,</span> <span class="n">on</span><span class="p">)</span> -</span><span id="L-2856"><a href="#L-2856"><span class="linenos">2856</span></a> -</span><span id="L-2857"><a href="#L-2857"><span class="linenos">2857</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> -</span><span id="L-2858"><a href="#L-2858"><span class="linenos">2858</span></a> <span class="n">join</span> <span class="o">=</span> <span class="n">_apply_list_builder</span><span class="p">(</span> -</span><span id="L-2859"><a href="#L-2859"><span class="linenos">2859</span></a> <span class="o">*</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">using</span><span class="p">),</span> -</span><span id="L-2860"><a href="#L-2860"><span class="linenos">2860</span></a> <span class="n">instance</span><span class="o">=</span><span class="n">join</span><span class="p">,</span> -</span><span id="L-2861"><a href="#L-2861"><span class="linenos">2861</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"using"</span><span class="p">,</span> -</span><span id="L-2862"><a href="#L-2862"><span class="linenos">2862</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="L-2863"><a href="#L-2863"><span class="linenos">2863</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="L-2864"><a href="#L-2864"><span class="linenos">2864</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2865"><a href="#L-2865"><span class="linenos">2865</span></a> <span class="p">)</span> -</span><span id="L-2866"><a href="#L-2866"><span class="linenos">2866</span></a> -</span><span id="L-2867"><a href="#L-2867"><span class="linenos">2867</span></a> <span class="k">if</span> <span class="n">join_alias</span><span class="p">:</span> -</span><span id="L-2868"><a href="#L-2868"><span class="linenos">2868</span></a> <span class="n">join</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">alias_</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">join_alias</span><span class="p">,</span> <span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> -</span><span id="L-2869"><a href="#L-2869"><span class="linenos">2869</span></a> -</span><span id="L-2870"><a href="#L-2870"><span class="linenos">2870</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> -</span><span id="L-2871"><a href="#L-2871"><span class="linenos">2871</span></a> <span class="n">join</span><span class="p">,</span> -</span><span id="L-2872"><a href="#L-2872"><span class="linenos">2872</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="L-2873"><a href="#L-2873"><span class="linenos">2873</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"joins"</span><span class="p">,</span> -</span><span id="L-2874"><a href="#L-2874"><span class="linenos">2874</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="L-2875"><a href="#L-2875"><span class="linenos">2875</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="L-2876"><a href="#L-2876"><span class="linenos">2876</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2877"><a href="#L-2877"><span class="linenos">2877</span></a> <span class="p">)</span> -</span><span id="L-2878"><a href="#L-2878"><span class="linenos">2878</span></a> -</span><span id="L-2879"><a href="#L-2879"><span class="linenos">2879</span></a> <span class="k">def</span> <span class="nf">where</span><span class="p">(</span> -</span><span id="L-2880"><a href="#L-2880"><span class="linenos">2880</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2881"><a href="#L-2881"><span class="linenos">2881</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="L-2882"><a href="#L-2882"><span class="linenos">2882</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2883"><a href="#L-2883"><span class="linenos">2883</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2884"><a href="#L-2884"><span class="linenos">2884</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2885"><a href="#L-2885"><span class="linenos">2885</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2886"><a href="#L-2886"><span class="linenos">2886</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-2887"><a href="#L-2887"><span class="linenos">2887</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-2888"><a href="#L-2888"><span class="linenos">2888</span></a><span class="sd"> Append to or set the WHERE expressions.</span> -</span><span id="L-2889"><a href="#L-2889"><span class="linenos">2889</span></a> -</span><span id="L-2890"><a href="#L-2890"><span class="linenos">2890</span></a><span class="sd"> Example:</span> -</span><span id="L-2891"><a href="#L-2891"><span class="linenos">2891</span></a><span class="sd"> >>> Select().select("x").from_("tbl").where("x = 'a' OR x < 'b'").sql()</span> -</span><span id="L-2892"><a href="#L-2892"><span class="linenos">2892</span></a><span class="sd"> "SELECT x FROM tbl WHERE x = 'a' OR x < 'b'"</span> -</span><span id="L-2893"><a href="#L-2893"><span class="linenos">2893</span></a> -</span><span id="L-2894"><a href="#L-2894"><span class="linenos">2894</span></a><span class="sd"> Args:</span> -</span><span id="L-2895"><a href="#L-2895"><span class="linenos">2895</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="L-2896"><a href="#L-2896"><span class="linenos">2896</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="L-2897"><a href="#L-2897"><span class="linenos">2897</span></a><span class="sd"> Multiple expressions are combined with an AND operator.</span> -</span><span id="L-2898"><a href="#L-2898"><span class="linenos">2898</span></a><span class="sd"> append: if `True`, AND the new expressions to any existing expression.</span> -</span><span id="L-2899"><a href="#L-2899"><span class="linenos">2899</span></a><span class="sd"> Otherwise, this resets the expression.</span> -</span><span id="L-2900"><a href="#L-2900"><span class="linenos">2900</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="L-2901"><a href="#L-2901"><span class="linenos">2901</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="L-2902"><a href="#L-2902"><span class="linenos">2902</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="L-2903"><a href="#L-2903"><span class="linenos">2903</span></a> -</span><span id="L-2904"><a href="#L-2904"><span class="linenos">2904</span></a><span class="sd"> Returns:</span> -</span><span id="L-2905"><a href="#L-2905"><span class="linenos">2905</span></a><span class="sd"> Select: the modified expression.</span> -</span><span id="L-2906"><a href="#L-2906"><span class="linenos">2906</span></a><span class="sd"> """</span> -</span><span id="L-2907"><a href="#L-2907"><span class="linenos">2907</span></a> <span class="k">return</span> <span class="n">_apply_conjunction_builder</span><span class="p">(</span> -</span><span id="L-2908"><a href="#L-2908"><span class="linenos">2908</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-2909"><a href="#L-2909"><span class="linenos">2909</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="L-2910"><a href="#L-2910"><span class="linenos">2910</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"where"</span><span class="p">,</span> -</span><span id="L-2911"><a href="#L-2911"><span class="linenos">2911</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="L-2912"><a href="#L-2912"><span class="linenos">2912</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Where</span><span class="p">,</span> -</span><span id="L-2913"><a href="#L-2913"><span class="linenos">2913</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-2914"><a href="#L-2914"><span class="linenos">2914</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="L-2915"><a href="#L-2915"><span class="linenos">2915</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2916"><a href="#L-2916"><span class="linenos">2916</span></a> <span class="p">)</span> -</span><span id="L-2917"><a href="#L-2917"><span class="linenos">2917</span></a> -</span><span id="L-2918"><a href="#L-2918"><span class="linenos">2918</span></a> <span class="k">def</span> <span class="nf">having</span><span class="p">(</span> -</span><span id="L-2919"><a href="#L-2919"><span class="linenos">2919</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2920"><a href="#L-2920"><span class="linenos">2920</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="L-2921"><a href="#L-2921"><span class="linenos">2921</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2922"><a href="#L-2922"><span class="linenos">2922</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2923"><a href="#L-2923"><span class="linenos">2923</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2924"><a href="#L-2924"><span class="linenos">2924</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2925"><a href="#L-2925"><span class="linenos">2925</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-2926"><a href="#L-2926"><span class="linenos">2926</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-2927"><a href="#L-2927"><span class="linenos">2927</span></a><span class="sd"> Append to or set the HAVING expressions.</span> -</span><span id="L-2928"><a href="#L-2928"><span class="linenos">2928</span></a> -</span><span id="L-2929"><a href="#L-2929"><span class="linenos">2929</span></a><span class="sd"> Example:</span> -</span><span id="L-2930"><a href="#L-2930"><span class="linenos">2930</span></a><span class="sd"> >>> Select().select("x", "COUNT(y)").from_("tbl").group_by("x").having("COUNT(y) > 3").sql()</span> -</span><span id="L-2931"><a href="#L-2931"><span class="linenos">2931</span></a><span class="sd"> 'SELECT x, COUNT(y) FROM tbl GROUP BY x HAVING COUNT(y) > 3'</span> -</span><span id="L-2932"><a href="#L-2932"><span class="linenos">2932</span></a> -</span><span id="L-2933"><a href="#L-2933"><span class="linenos">2933</span></a><span class="sd"> Args:</span> -</span><span id="L-2934"><a href="#L-2934"><span class="linenos">2934</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="L-2935"><a href="#L-2935"><span class="linenos">2935</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="L-2936"><a href="#L-2936"><span class="linenos">2936</span></a><span class="sd"> Multiple expressions are combined with an AND operator.</span> -</span><span id="L-2937"><a href="#L-2937"><span class="linenos">2937</span></a><span class="sd"> append: if `True`, AND the new expressions to any existing expression.</span> -</span><span id="L-2938"><a href="#L-2938"><span class="linenos">2938</span></a><span class="sd"> Otherwise, this resets the expression.</span> -</span><span id="L-2939"><a href="#L-2939"><span class="linenos">2939</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="L-2940"><a href="#L-2940"><span class="linenos">2940</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="L-2941"><a href="#L-2941"><span class="linenos">2941</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="L-2942"><a href="#L-2942"><span class="linenos">2942</span></a> -</span><span id="L-2943"><a href="#L-2943"><span class="linenos">2943</span></a><span class="sd"> Returns:</span> -</span><span id="L-2944"><a href="#L-2944"><span class="linenos">2944</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="L-2945"><a href="#L-2945"><span class="linenos">2945</span></a><span class="sd"> """</span> -</span><span id="L-2946"><a href="#L-2946"><span class="linenos">2946</span></a> <span class="k">return</span> <span class="n">_apply_conjunction_builder</span><span class="p">(</span> -</span><span id="L-2947"><a href="#L-2947"><span class="linenos">2947</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-2948"><a href="#L-2948"><span class="linenos">2948</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="L-2949"><a href="#L-2949"><span class="linenos">2949</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"having"</span><span class="p">,</span> -</span><span id="L-2950"><a href="#L-2950"><span class="linenos">2950</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="L-2951"><a href="#L-2951"><span class="linenos">2951</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Having</span><span class="p">,</span> -</span><span id="L-2952"><a href="#L-2952"><span class="linenos">2952</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-2953"><a href="#L-2953"><span class="linenos">2953</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="L-2954"><a href="#L-2954"><span class="linenos">2954</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2955"><a href="#L-2955"><span class="linenos">2955</span></a> <span class="p">)</span> -</span><span id="L-2956"><a href="#L-2956"><span class="linenos">2956</span></a> -</span><span id="L-2957"><a href="#L-2957"><span class="linenos">2957</span></a> <span class="k">def</span> <span class="nf">window</span><span class="p">(</span> -</span><span id="L-2958"><a href="#L-2958"><span class="linenos">2958</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2959"><a href="#L-2959"><span class="linenos">2959</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="L-2960"><a href="#L-2960"><span class="linenos">2960</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2961"><a href="#L-2961"><span class="linenos">2961</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2962"><a href="#L-2962"><span class="linenos">2962</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2963"><a href="#L-2963"><span class="linenos">2963</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2964"><a href="#L-2964"><span class="linenos">2964</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-2965"><a href="#L-2965"><span class="linenos">2965</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> -</span><span id="L-2966"><a href="#L-2966"><span class="linenos">2966</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-2967"><a href="#L-2967"><span class="linenos">2967</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="L-2968"><a href="#L-2968"><span class="linenos">2968</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"windows"</span><span class="p">,</span> -</span><span id="L-2969"><a href="#L-2969"><span class="linenos">2969</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="L-2970"><a href="#L-2970"><span class="linenos">2970</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Window</span><span class="p">,</span> -</span><span id="L-2971"><a href="#L-2971"><span class="linenos">2971</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-2972"><a href="#L-2972"><span class="linenos">2972</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="L-2973"><a href="#L-2973"><span class="linenos">2973</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2974"><a href="#L-2974"><span class="linenos">2974</span></a> <span class="p">)</span> -</span><span id="L-2975"><a href="#L-2975"><span class="linenos">2975</span></a> -</span><span id="L-2976"><a href="#L-2976"><span class="linenos">2976</span></a> <span class="k">def</span> <span class="nf">qualify</span><span class="p">(</span> -</span><span id="L-2977"><a href="#L-2977"><span class="linenos">2977</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2978"><a href="#L-2978"><span class="linenos">2978</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="L-2979"><a href="#L-2979"><span class="linenos">2979</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2980"><a href="#L-2980"><span class="linenos">2980</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2981"><a href="#L-2981"><span class="linenos">2981</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2982"><a href="#L-2982"><span class="linenos">2982</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2983"><a href="#L-2983"><span class="linenos">2983</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-2984"><a href="#L-2984"><span class="linenos">2984</span></a> <span class="k">return</span> <span class="n">_apply_conjunction_builder</span><span class="p">(</span> -</span><span id="L-2985"><a href="#L-2985"><span class="linenos">2985</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-2986"><a href="#L-2986"><span class="linenos">2986</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="L-2987"><a href="#L-2987"><span class="linenos">2987</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"qualify"</span><span class="p">,</span> -</span><span id="L-2988"><a href="#L-2988"><span class="linenos">2988</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="L-2989"><a href="#L-2989"><span class="linenos">2989</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Qualify</span><span class="p">,</span> -</span><span id="L-2990"><a href="#L-2990"><span class="linenos">2990</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-2991"><a href="#L-2991"><span class="linenos">2991</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="L-2992"><a href="#L-2992"><span class="linenos">2992</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-2993"><a href="#L-2993"><span class="linenos">2993</span></a> <span class="p">)</span> -</span><span id="L-2994"><a href="#L-2994"><span class="linenos">2994</span></a> -</span><span id="L-2995"><a href="#L-2995"><span class="linenos">2995</span></a> <span class="k">def</span> <span class="nf">distinct</span><span class="p">(</span> -</span><span id="L-2996"><a href="#L-2996"><span class="linenos">2996</span></a> <span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">ons</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">ExpOrStr</span><span class="p">],</span> <span class="n">distinct</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-2997"><a href="#L-2997"><span class="linenos">2997</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-2998"><a href="#L-2998"><span class="linenos">2998</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-2999"><a href="#L-2999"><span class="linenos">2999</span></a><span class="sd"> Set the OFFSET expression.</span> -</span><span id="L-3000"><a href="#L-3000"><span class="linenos">3000</span></a> -</span><span id="L-3001"><a href="#L-3001"><span class="linenos">3001</span></a><span class="sd"> Example:</span> -</span><span id="L-3002"><a href="#L-3002"><span class="linenos">3002</span></a><span class="sd"> >>> Select().from_("tbl").select("x").distinct().sql()</span> -</span><span id="L-3003"><a href="#L-3003"><span class="linenos">3003</span></a><span class="sd"> 'SELECT DISTINCT x FROM tbl'</span> -</span><span id="L-3004"><a href="#L-3004"><span class="linenos">3004</span></a> -</span><span id="L-3005"><a href="#L-3005"><span class="linenos">3005</span></a><span class="sd"> Args:</span> -</span><span id="L-3006"><a href="#L-3006"><span class="linenos">3006</span></a><span class="sd"> ons: the expressions to distinct on</span> -</span><span id="L-3007"><a href="#L-3007"><span class="linenos">3007</span></a><span class="sd"> distinct: whether the Select should be distinct</span> -</span><span id="L-3008"><a href="#L-3008"><span class="linenos">3008</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="L-3009"><a href="#L-3009"><span class="linenos">3009</span></a> -</span><span id="L-3010"><a href="#L-3010"><span class="linenos">3010</span></a><span class="sd"> Returns:</span> -</span><span id="L-3011"><a href="#L-3011"><span class="linenos">3011</span></a><span class="sd"> Select: the modified expression.</span> -</span><span id="L-3012"><a href="#L-3012"><span class="linenos">3012</span></a><span class="sd"> """</span> -</span><span id="L-3013"><a href="#L-3013"><span class="linenos">3013</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="L-3014"><a href="#L-3014"><span class="linenos">3014</span></a> <span class="n">on</span> <span class="o">=</span> <span class="n">Tuple</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">on</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">on</span> <span class="ow">in</span> <span class="n">ons</span> <span class="k">if</span> <span class="n">on</span><span class="p">])</span> <span class="k">if</span> <span class="n">ons</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="L-3015"><a href="#L-3015"><span class="linenos">3015</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"distinct"</span><span class="p">,</span> <span class="n">Distinct</span><span class="p">(</span><span class="n">on</span><span class="o">=</span><span class="n">on</span><span class="p">)</span> <span class="k">if</span> <span class="n">distinct</span> <span class="k">else</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="L-3016"><a href="#L-3016"><span class="linenos">3016</span></a> <span class="k">return</span> <span class="n">instance</span> -</span><span id="L-3017"><a href="#L-3017"><span class="linenos">3017</span></a> -</span><span id="L-3018"><a href="#L-3018"><span class="linenos">3018</span></a> <span class="k">def</span> <span class="nf">ctas</span><span class="p">(</span> -</span><span id="L-3019"><a href="#L-3019"><span class="linenos">3019</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-3020"><a href="#L-3020"><span class="linenos">3020</span></a> <span class="n">table</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="L-3021"><a href="#L-3021"><span class="linenos">3021</span></a> <span class="n">properties</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-3022"><a href="#L-3022"><span class="linenos">3022</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-3023"><a href="#L-3023"><span class="linenos">3023</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-3024"><a href="#L-3024"><span class="linenos">3024</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-3025"><a href="#L-3025"><span class="linenos">3025</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Create</span><span class="p">:</span> -</span><span id="L-3026"><a href="#L-3026"><span class="linenos">3026</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-3027"><a href="#L-3027"><span class="linenos">3027</span></a><span class="sd"> Convert this expression to a CREATE TABLE AS statement.</span> -</span><span id="L-3028"><a href="#L-3028"><span class="linenos">3028</span></a> -</span><span id="L-3029"><a href="#L-3029"><span class="linenos">3029</span></a><span class="sd"> Example:</span> -</span><span id="L-3030"><a href="#L-3030"><span class="linenos">3030</span></a><span class="sd"> >>> Select().select("*").from_("tbl").ctas("x").sql()</span> -</span><span id="L-3031"><a href="#L-3031"><span class="linenos">3031</span></a><span class="sd"> 'CREATE TABLE x AS SELECT * FROM tbl'</span> -</span><span id="L-3032"><a href="#L-3032"><span class="linenos">3032</span></a> -</span><span id="L-3033"><a href="#L-3033"><span class="linenos">3033</span></a><span class="sd"> Args:</span> -</span><span id="L-3034"><a href="#L-3034"><span class="linenos">3034</span></a><span class="sd"> table: the SQL code string to parse as the table name.</span> -</span><span id="L-3035"><a href="#L-3035"><span class="linenos">3035</span></a><span class="sd"> If another `Expression` instance is passed, it will be used as-is.</span> -</span><span id="L-3036"><a href="#L-3036"><span class="linenos">3036</span></a><span class="sd"> properties: an optional mapping of table properties</span> -</span><span id="L-3037"><a href="#L-3037"><span class="linenos">3037</span></a><span class="sd"> dialect: the dialect used to parse the input table.</span> -</span><span id="L-3038"><a href="#L-3038"><span class="linenos">3038</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="L-3039"><a href="#L-3039"><span class="linenos">3039</span></a><span class="sd"> opts: other options to use to parse the input table.</span> -</span><span id="L-3040"><a href="#L-3040"><span class="linenos">3040</span></a> -</span><span id="L-3041"><a href="#L-3041"><span class="linenos">3041</span></a><span class="sd"> Returns:</span> -</span><span id="L-3042"><a href="#L-3042"><span class="linenos">3042</span></a><span class="sd"> The new Create expression.</span> -</span><span id="L-3043"><a href="#L-3043"><span class="linenos">3043</span></a><span class="sd"> """</span> -</span><span id="L-3044"><a href="#L-3044"><span class="linenos">3044</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="L-3045"><a href="#L-3045"><span class="linenos">3045</span></a> <span class="n">table_expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span> -</span><span id="L-3046"><a href="#L-3046"><span class="linenos">3046</span></a> <span class="n">table</span><span class="p">,</span> -</span><span id="L-3047"><a href="#L-3047"><span class="linenos">3047</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">,</span> -</span><span id="L-3048"><a href="#L-3048"><span class="linenos">3048</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-3049"><a href="#L-3049"><span class="linenos">3049</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-3050"><a href="#L-3050"><span class="linenos">3050</span></a> <span class="p">)</span> -</span><span id="L-3051"><a href="#L-3051"><span class="linenos">3051</span></a> <span class="n">properties_expression</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-3052"><a href="#L-3052"><span class="linenos">3052</span></a> <span class="k">if</span> <span class="n">properties</span><span class="p">:</span> -</span><span id="L-3053"><a href="#L-3053"><span class="linenos">3053</span></a> <span class="n">properties_expression</span> <span class="o">=</span> <span class="n">Properties</span><span class="o">.</span><span class="n">from_dict</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span> -</span><span id="L-3054"><a href="#L-3054"><span class="linenos">3054</span></a> -</span><span id="L-3055"><a href="#L-3055"><span class="linenos">3055</span></a> <span class="k">return</span> <span class="n">Create</span><span class="p">(</span> -</span><span id="L-3056"><a href="#L-3056"><span class="linenos">3056</span></a> <span class="n">this</span><span class="o">=</span><span class="n">table_expression</span><span class="p">,</span> -</span><span id="L-3057"><a href="#L-3057"><span class="linenos">3057</span></a> <span class="n">kind</span><span class="o">=</span><span class="s2">"table"</span><span class="p">,</span> -</span><span id="L-3058"><a href="#L-3058"><span class="linenos">3058</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">instance</span><span class="p">,</span> -</span><span id="L-3059"><a href="#L-3059"><span class="linenos">3059</span></a> <span class="n">properties</span><span class="o">=</span><span class="n">properties_expression</span><span class="p">,</span> -</span><span id="L-3060"><a href="#L-3060"><span class="linenos">3060</span></a> <span class="p">)</span> -</span><span id="L-3061"><a href="#L-3061"><span class="linenos">3061</span></a> -</span><span id="L-3062"><a href="#L-3062"><span class="linenos">3062</span></a> <span class="k">def</span> <span class="nf">lock</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">update</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-3063"><a href="#L-3063"><span class="linenos">3063</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-3064"><a href="#L-3064"><span class="linenos">3064</span></a><span class="sd"> Set the locking read mode for this expression.</span> -</span><span id="L-3065"><a href="#L-3065"><span class="linenos">3065</span></a> -</span><span id="L-3066"><a href="#L-3066"><span class="linenos">3066</span></a><span class="sd"> Examples:</span> -</span><span id="L-3067"><a href="#L-3067"><span class="linenos">3067</span></a><span class="sd"> >>> Select().select("x").from_("tbl").where("x = 'a'").lock().sql("mysql")</span> -</span><span id="L-3068"><a href="#L-3068"><span class="linenos">3068</span></a><span class="sd"> "SELECT x FROM tbl WHERE x = 'a' FOR UPDATE"</span> -</span><span id="L-3069"><a href="#L-3069"><span class="linenos">3069</span></a> -</span><span id="L-3070"><a href="#L-3070"><span class="linenos">3070</span></a><span class="sd"> >>> Select().select("x").from_("tbl").where("x = 'a'").lock(update=False).sql("mysql")</span> -</span><span id="L-3071"><a href="#L-3071"><span class="linenos">3071</span></a><span class="sd"> "SELECT x FROM tbl WHERE x = 'a' FOR SHARE"</span> -</span><span id="L-3072"><a href="#L-3072"><span class="linenos">3072</span></a> -</span><span id="L-3073"><a href="#L-3073"><span class="linenos">3073</span></a><span class="sd"> Args:</span> -</span><span id="L-3074"><a href="#L-3074"><span class="linenos">3074</span></a><span class="sd"> update: if `True`, the locking type will be `FOR UPDATE`, else it will be `FOR SHARE`.</span> -</span><span id="L-3075"><a href="#L-3075"><span class="linenos">3075</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="L-3076"><a href="#L-3076"><span class="linenos">3076</span></a> -</span><span id="L-3077"><a href="#L-3077"><span class="linenos">3077</span></a><span class="sd"> Returns:</span> -</span><span id="L-3078"><a href="#L-3078"><span class="linenos">3078</span></a><span class="sd"> The modified expression.</span> -</span><span id="L-3079"><a href="#L-3079"><span class="linenos">3079</span></a><span class="sd"> """</span> -</span><span id="L-3080"><a href="#L-3080"><span class="linenos">3080</span></a> <span class="n">inst</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="L-3081"><a href="#L-3081"><span class="linenos">3081</span></a> <span class="n">inst</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"locks"</span><span class="p">,</span> <span class="p">[</span><span class="n">Lock</span><span class="p">(</span><span class="n">update</span><span class="o">=</span><span class="n">update</span><span class="p">)])</span> -</span><span id="L-3082"><a href="#L-3082"><span class="linenos">3082</span></a> -</span><span id="L-3083"><a href="#L-3083"><span class="linenos">3083</span></a> <span class="k">return</span> <span class="n">inst</span> +</span><span id="L-2846"><a href="#L-2846"><span class="linenos">2846</span></a> <span class="n">method</span><span class="p">,</span> <span class="n">side</span><span class="p">,</span> <span class="n">kind</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">join_type</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="s2">"JOIN_TYPE"</span><span class="p">,</span> <span class="o">**</span><span class="n">parse_args</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="L-2847"><a href="#L-2847"><span class="linenos">2847</span></a> +</span><span id="L-2848"><a href="#L-2848"><span class="linenos">2848</span></a> <span class="k">if</span> <span class="n">method</span><span class="p">:</span> +</span><span id="L-2849"><a href="#L-2849"><span class="linenos">2849</span></a> <span class="n">join</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">method</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> +</span><span id="L-2850"><a href="#L-2850"><span class="linenos">2850</span></a> <span class="k">if</span> <span class="n">side</span><span class="p">:</span> +</span><span id="L-2851"><a href="#L-2851"><span class="linenos">2851</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"side"</span><span class="p">,</span> <span class="n">side</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> +</span><span id="L-2852"><a href="#L-2852"><span class="linenos">2852</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="L-2853"><a href="#L-2853"><span class="linenos">2853</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="n">kind</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> +</span><span id="L-2854"><a href="#L-2854"><span class="linenos">2854</span></a> +</span><span id="L-2855"><a href="#L-2855"><span class="linenos">2855</span></a> <span class="k">if</span> <span class="n">on</span><span class="p">:</span> +</span><span id="L-2856"><a href="#L-2856"><span class="linenos">2856</span></a> <span class="n">on</span> <span class="o">=</span> <span class="n">and_</span><span class="p">(</span><span class="o">*</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">on</span><span class="p">),</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-2857"><a href="#L-2857"><span class="linenos">2857</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"on"</span><span class="p">,</span> <span class="n">on</span><span class="p">)</span> +</span><span id="L-2858"><a href="#L-2858"><span class="linenos">2858</span></a> +</span><span id="L-2859"><a href="#L-2859"><span class="linenos">2859</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> +</span><span id="L-2860"><a href="#L-2860"><span class="linenos">2860</span></a> <span class="n">join</span> <span class="o">=</span> <span class="n">_apply_list_builder</span><span class="p">(</span> +</span><span id="L-2861"><a href="#L-2861"><span class="linenos">2861</span></a> <span class="o">*</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">using</span><span class="p">),</span> +</span><span id="L-2862"><a href="#L-2862"><span class="linenos">2862</span></a> <span class="n">instance</span><span class="o">=</span><span class="n">join</span><span class="p">,</span> +</span><span id="L-2863"><a href="#L-2863"><span class="linenos">2863</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"using"</span><span class="p">,</span> +</span><span id="L-2864"><a href="#L-2864"><span class="linenos">2864</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="L-2865"><a href="#L-2865"><span class="linenos">2865</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="L-2866"><a href="#L-2866"><span class="linenos">2866</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2867"><a href="#L-2867"><span class="linenos">2867</span></a> <span class="p">)</span> +</span><span id="L-2868"><a href="#L-2868"><span class="linenos">2868</span></a> +</span><span id="L-2869"><a href="#L-2869"><span class="linenos">2869</span></a> <span class="k">if</span> <span class="n">join_alias</span><span class="p">:</span> +</span><span id="L-2870"><a href="#L-2870"><span class="linenos">2870</span></a> <span class="n">join</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">alias_</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">join_alias</span><span class="p">,</span> <span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="L-2871"><a href="#L-2871"><span class="linenos">2871</span></a> +</span><span id="L-2872"><a href="#L-2872"><span class="linenos">2872</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> +</span><span id="L-2873"><a href="#L-2873"><span class="linenos">2873</span></a> <span class="n">join</span><span class="p">,</span> +</span><span id="L-2874"><a href="#L-2874"><span class="linenos">2874</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="L-2875"><a href="#L-2875"><span class="linenos">2875</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"joins"</span><span class="p">,</span> +</span><span id="L-2876"><a href="#L-2876"><span class="linenos">2876</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="L-2877"><a href="#L-2877"><span class="linenos">2877</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="L-2878"><a href="#L-2878"><span class="linenos">2878</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2879"><a href="#L-2879"><span class="linenos">2879</span></a> <span class="p">)</span> +</span><span id="L-2880"><a href="#L-2880"><span class="linenos">2880</span></a> +</span><span id="L-2881"><a href="#L-2881"><span class="linenos">2881</span></a> <span class="k">def</span> <span class="nf">where</span><span class="p">(</span> +</span><span id="L-2882"><a href="#L-2882"><span class="linenos">2882</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2883"><a href="#L-2883"><span class="linenos">2883</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="L-2884"><a href="#L-2884"><span class="linenos">2884</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2885"><a href="#L-2885"><span class="linenos">2885</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2886"><a href="#L-2886"><span class="linenos">2886</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2887"><a href="#L-2887"><span class="linenos">2887</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2888"><a href="#L-2888"><span class="linenos">2888</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-2889"><a href="#L-2889"><span class="linenos">2889</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-2890"><a href="#L-2890"><span class="linenos">2890</span></a><span class="sd"> Append to or set the WHERE expressions.</span> +</span><span id="L-2891"><a href="#L-2891"><span class="linenos">2891</span></a> +</span><span id="L-2892"><a href="#L-2892"><span class="linenos">2892</span></a><span class="sd"> Example:</span> +</span><span id="L-2893"><a href="#L-2893"><span class="linenos">2893</span></a><span class="sd"> >>> Select().select("x").from_("tbl").where("x = 'a' OR x < 'b'").sql()</span> +</span><span id="L-2894"><a href="#L-2894"><span class="linenos">2894</span></a><span class="sd"> "SELECT x FROM tbl WHERE x = 'a' OR x < 'b'"</span> +</span><span id="L-2895"><a href="#L-2895"><span class="linenos">2895</span></a> +</span><span id="L-2896"><a href="#L-2896"><span class="linenos">2896</span></a><span class="sd"> Args:</span> +</span><span id="L-2897"><a href="#L-2897"><span class="linenos">2897</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="L-2898"><a href="#L-2898"><span class="linenos">2898</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="L-2899"><a href="#L-2899"><span class="linenos">2899</span></a><span class="sd"> Multiple expressions are combined with an AND operator.</span> +</span><span id="L-2900"><a href="#L-2900"><span class="linenos">2900</span></a><span class="sd"> append: if `True`, AND the new expressions to any existing expression.</span> +</span><span id="L-2901"><a href="#L-2901"><span class="linenos">2901</span></a><span class="sd"> Otherwise, this resets the expression.</span> +</span><span id="L-2902"><a href="#L-2902"><span class="linenos">2902</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="L-2903"><a href="#L-2903"><span class="linenos">2903</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="L-2904"><a href="#L-2904"><span class="linenos">2904</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="L-2905"><a href="#L-2905"><span class="linenos">2905</span></a> +</span><span id="L-2906"><a href="#L-2906"><span class="linenos">2906</span></a><span class="sd"> Returns:</span> +</span><span id="L-2907"><a href="#L-2907"><span class="linenos">2907</span></a><span class="sd"> Select: the modified expression.</span> +</span><span id="L-2908"><a href="#L-2908"><span class="linenos">2908</span></a><span class="sd"> """</span> +</span><span id="L-2909"><a href="#L-2909"><span class="linenos">2909</span></a> <span class="k">return</span> <span class="n">_apply_conjunction_builder</span><span class="p">(</span> +</span><span id="L-2910"><a href="#L-2910"><span class="linenos">2910</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-2911"><a href="#L-2911"><span class="linenos">2911</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="L-2912"><a href="#L-2912"><span class="linenos">2912</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"where"</span><span class="p">,</span> +</span><span id="L-2913"><a href="#L-2913"><span class="linenos">2913</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="L-2914"><a href="#L-2914"><span class="linenos">2914</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Where</span><span class="p">,</span> +</span><span id="L-2915"><a href="#L-2915"><span class="linenos">2915</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-2916"><a href="#L-2916"><span class="linenos">2916</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="L-2917"><a href="#L-2917"><span class="linenos">2917</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2918"><a href="#L-2918"><span class="linenos">2918</span></a> <span class="p">)</span> +</span><span id="L-2919"><a href="#L-2919"><span class="linenos">2919</span></a> +</span><span id="L-2920"><a href="#L-2920"><span class="linenos">2920</span></a> <span class="k">def</span> <span class="nf">having</span><span class="p">(</span> +</span><span id="L-2921"><a href="#L-2921"><span class="linenos">2921</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2922"><a href="#L-2922"><span class="linenos">2922</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="L-2923"><a href="#L-2923"><span class="linenos">2923</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2924"><a href="#L-2924"><span class="linenos">2924</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2925"><a href="#L-2925"><span class="linenos">2925</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2926"><a href="#L-2926"><span class="linenos">2926</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2927"><a href="#L-2927"><span class="linenos">2927</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-2928"><a href="#L-2928"><span class="linenos">2928</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-2929"><a href="#L-2929"><span class="linenos">2929</span></a><span class="sd"> Append to or set the HAVING expressions.</span> +</span><span id="L-2930"><a href="#L-2930"><span class="linenos">2930</span></a> +</span><span id="L-2931"><a href="#L-2931"><span class="linenos">2931</span></a><span class="sd"> Example:</span> +</span><span id="L-2932"><a href="#L-2932"><span class="linenos">2932</span></a><span class="sd"> >>> Select().select("x", "COUNT(y)").from_("tbl").group_by("x").having("COUNT(y) > 3").sql()</span> +</span><span id="L-2933"><a href="#L-2933"><span class="linenos">2933</span></a><span class="sd"> 'SELECT x, COUNT(y) FROM tbl GROUP BY x HAVING COUNT(y) > 3'</span> +</span><span id="L-2934"><a href="#L-2934"><span class="linenos">2934</span></a> +</span><span id="L-2935"><a href="#L-2935"><span class="linenos">2935</span></a><span class="sd"> Args:</span> +</span><span id="L-2936"><a href="#L-2936"><span class="linenos">2936</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="L-2937"><a href="#L-2937"><span class="linenos">2937</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="L-2938"><a href="#L-2938"><span class="linenos">2938</span></a><span class="sd"> Multiple expressions are combined with an AND operator.</span> +</span><span id="L-2939"><a href="#L-2939"><span class="linenos">2939</span></a><span class="sd"> append: if `True`, AND the new expressions to any existing expression.</span> +</span><span id="L-2940"><a href="#L-2940"><span class="linenos">2940</span></a><span class="sd"> Otherwise, this resets the expression.</span> +</span><span id="L-2941"><a href="#L-2941"><span class="linenos">2941</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="L-2942"><a href="#L-2942"><span class="linenos">2942</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="L-2943"><a href="#L-2943"><span class="linenos">2943</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="L-2944"><a href="#L-2944"><span class="linenos">2944</span></a> +</span><span id="L-2945"><a href="#L-2945"><span class="linenos">2945</span></a><span class="sd"> Returns:</span> +</span><span id="L-2946"><a href="#L-2946"><span class="linenos">2946</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="L-2947"><a href="#L-2947"><span class="linenos">2947</span></a><span class="sd"> """</span> +</span><span id="L-2948"><a href="#L-2948"><span class="linenos">2948</span></a> <span class="k">return</span> <span class="n">_apply_conjunction_builder</span><span class="p">(</span> +</span><span id="L-2949"><a href="#L-2949"><span class="linenos">2949</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-2950"><a href="#L-2950"><span class="linenos">2950</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="L-2951"><a href="#L-2951"><span class="linenos">2951</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"having"</span><span class="p">,</span> +</span><span id="L-2952"><a href="#L-2952"><span class="linenos">2952</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="L-2953"><a href="#L-2953"><span class="linenos">2953</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Having</span><span class="p">,</span> +</span><span id="L-2954"><a href="#L-2954"><span class="linenos">2954</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-2955"><a href="#L-2955"><span class="linenos">2955</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="L-2956"><a href="#L-2956"><span class="linenos">2956</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2957"><a href="#L-2957"><span class="linenos">2957</span></a> <span class="p">)</span> +</span><span id="L-2958"><a href="#L-2958"><span class="linenos">2958</span></a> +</span><span id="L-2959"><a href="#L-2959"><span class="linenos">2959</span></a> <span class="k">def</span> <span class="nf">window</span><span class="p">(</span> +</span><span id="L-2960"><a href="#L-2960"><span class="linenos">2960</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2961"><a href="#L-2961"><span class="linenos">2961</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="L-2962"><a href="#L-2962"><span class="linenos">2962</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2963"><a href="#L-2963"><span class="linenos">2963</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2964"><a href="#L-2964"><span class="linenos">2964</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2965"><a href="#L-2965"><span class="linenos">2965</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2966"><a href="#L-2966"><span class="linenos">2966</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-2967"><a href="#L-2967"><span class="linenos">2967</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> +</span><span id="L-2968"><a href="#L-2968"><span class="linenos">2968</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-2969"><a href="#L-2969"><span class="linenos">2969</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="L-2970"><a href="#L-2970"><span class="linenos">2970</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"windows"</span><span class="p">,</span> +</span><span id="L-2971"><a href="#L-2971"><span class="linenos">2971</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="L-2972"><a href="#L-2972"><span class="linenos">2972</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Window</span><span class="p">,</span> +</span><span id="L-2973"><a href="#L-2973"><span class="linenos">2973</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-2974"><a href="#L-2974"><span class="linenos">2974</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="L-2975"><a href="#L-2975"><span class="linenos">2975</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2976"><a href="#L-2976"><span class="linenos">2976</span></a> <span class="p">)</span> +</span><span id="L-2977"><a href="#L-2977"><span class="linenos">2977</span></a> +</span><span id="L-2978"><a href="#L-2978"><span class="linenos">2978</span></a> <span class="k">def</span> <span class="nf">qualify</span><span class="p">(</span> +</span><span id="L-2979"><a href="#L-2979"><span class="linenos">2979</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2980"><a href="#L-2980"><span class="linenos">2980</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="L-2981"><a href="#L-2981"><span class="linenos">2981</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2982"><a href="#L-2982"><span class="linenos">2982</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2983"><a href="#L-2983"><span class="linenos">2983</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2984"><a href="#L-2984"><span class="linenos">2984</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2985"><a href="#L-2985"><span class="linenos">2985</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-2986"><a href="#L-2986"><span class="linenos">2986</span></a> <span class="k">return</span> <span class="n">_apply_conjunction_builder</span><span class="p">(</span> +</span><span id="L-2987"><a href="#L-2987"><span class="linenos">2987</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-2988"><a href="#L-2988"><span class="linenos">2988</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="L-2989"><a href="#L-2989"><span class="linenos">2989</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"qualify"</span><span class="p">,</span> +</span><span id="L-2990"><a href="#L-2990"><span class="linenos">2990</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="L-2991"><a href="#L-2991"><span class="linenos">2991</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Qualify</span><span class="p">,</span> +</span><span id="L-2992"><a href="#L-2992"><span class="linenos">2992</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-2993"><a href="#L-2993"><span class="linenos">2993</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="L-2994"><a href="#L-2994"><span class="linenos">2994</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-2995"><a href="#L-2995"><span class="linenos">2995</span></a> <span class="p">)</span> +</span><span id="L-2996"><a href="#L-2996"><span class="linenos">2996</span></a> +</span><span id="L-2997"><a href="#L-2997"><span class="linenos">2997</span></a> <span class="k">def</span> <span class="nf">distinct</span><span class="p">(</span> +</span><span id="L-2998"><a href="#L-2998"><span class="linenos">2998</span></a> <span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">ons</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">ExpOrStr</span><span class="p">],</span> <span class="n">distinct</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-2999"><a href="#L-2999"><span class="linenos">2999</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-3000"><a href="#L-3000"><span class="linenos">3000</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-3001"><a href="#L-3001"><span class="linenos">3001</span></a><span class="sd"> Set the OFFSET expression.</span> +</span><span id="L-3002"><a href="#L-3002"><span class="linenos">3002</span></a> +</span><span id="L-3003"><a href="#L-3003"><span class="linenos">3003</span></a><span class="sd"> Example:</span> +</span><span id="L-3004"><a href="#L-3004"><span class="linenos">3004</span></a><span class="sd"> >>> Select().from_("tbl").select("x").distinct().sql()</span> +</span><span id="L-3005"><a href="#L-3005"><span class="linenos">3005</span></a><span class="sd"> 'SELECT DISTINCT x FROM tbl'</span> +</span><span id="L-3006"><a href="#L-3006"><span class="linenos">3006</span></a> +</span><span id="L-3007"><a href="#L-3007"><span class="linenos">3007</span></a><span class="sd"> Args:</span> +</span><span id="L-3008"><a href="#L-3008"><span class="linenos">3008</span></a><span class="sd"> ons: the expressions to distinct on</span> +</span><span id="L-3009"><a href="#L-3009"><span class="linenos">3009</span></a><span class="sd"> distinct: whether the Select should be distinct</span> +</span><span id="L-3010"><a href="#L-3010"><span class="linenos">3010</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="L-3011"><a href="#L-3011"><span class="linenos">3011</span></a> +</span><span id="L-3012"><a href="#L-3012"><span class="linenos">3012</span></a><span class="sd"> Returns:</span> +</span><span id="L-3013"><a href="#L-3013"><span class="linenos">3013</span></a><span class="sd"> Select: the modified expression.</span> +</span><span id="L-3014"><a href="#L-3014"><span class="linenos">3014</span></a><span class="sd"> """</span> +</span><span id="L-3015"><a href="#L-3015"><span class="linenos">3015</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="L-3016"><a href="#L-3016"><span class="linenos">3016</span></a> <span class="n">on</span> <span class="o">=</span> <span class="n">Tuple</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">on</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">on</span> <span class="ow">in</span> <span class="n">ons</span> <span class="k">if</span> <span class="n">on</span><span class="p">])</span> <span class="k">if</span> <span class="n">ons</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="L-3017"><a href="#L-3017"><span class="linenos">3017</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"distinct"</span><span class="p">,</span> <span class="n">Distinct</span><span class="p">(</span><span class="n">on</span><span class="o">=</span><span class="n">on</span><span class="p">)</span> <span class="k">if</span> <span class="n">distinct</span> <span class="k">else</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="L-3018"><a href="#L-3018"><span class="linenos">3018</span></a> <span class="k">return</span> <span class="n">instance</span> +</span><span id="L-3019"><a href="#L-3019"><span class="linenos">3019</span></a> +</span><span id="L-3020"><a href="#L-3020"><span class="linenos">3020</span></a> <span class="k">def</span> <span class="nf">ctas</span><span class="p">(</span> +</span><span id="L-3021"><a href="#L-3021"><span class="linenos">3021</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-3022"><a href="#L-3022"><span class="linenos">3022</span></a> <span class="n">table</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="L-3023"><a href="#L-3023"><span class="linenos">3023</span></a> <span class="n">properties</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-3024"><a href="#L-3024"><span class="linenos">3024</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-3025"><a href="#L-3025"><span class="linenos">3025</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-3026"><a href="#L-3026"><span class="linenos">3026</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-3027"><a href="#L-3027"><span class="linenos">3027</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Create</span><span class="p">:</span> +</span><span id="L-3028"><a href="#L-3028"><span class="linenos">3028</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-3029"><a href="#L-3029"><span class="linenos">3029</span></a><span class="sd"> Convert this expression to a CREATE TABLE AS statement.</span> +</span><span id="L-3030"><a href="#L-3030"><span class="linenos">3030</span></a> +</span><span id="L-3031"><a href="#L-3031"><span class="linenos">3031</span></a><span class="sd"> Example:</span> +</span><span id="L-3032"><a href="#L-3032"><span class="linenos">3032</span></a><span class="sd"> >>> Select().select("*").from_("tbl").ctas("x").sql()</span> +</span><span id="L-3033"><a href="#L-3033"><span class="linenos">3033</span></a><span class="sd"> 'CREATE TABLE x AS SELECT * FROM tbl'</span> +</span><span id="L-3034"><a href="#L-3034"><span class="linenos">3034</span></a> +</span><span id="L-3035"><a href="#L-3035"><span class="linenos">3035</span></a><span class="sd"> Args:</span> +</span><span id="L-3036"><a href="#L-3036"><span class="linenos">3036</span></a><span class="sd"> table: the SQL code string to parse as the table name.</span> +</span><span id="L-3037"><a href="#L-3037"><span class="linenos">3037</span></a><span class="sd"> If another `Expression` instance is passed, it will be used as-is.</span> +</span><span id="L-3038"><a href="#L-3038"><span class="linenos">3038</span></a><span class="sd"> properties: an optional mapping of table properties</span> +</span><span id="L-3039"><a href="#L-3039"><span class="linenos">3039</span></a><span class="sd"> dialect: the dialect used to parse the input table.</span> +</span><span id="L-3040"><a href="#L-3040"><span class="linenos">3040</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="L-3041"><a href="#L-3041"><span class="linenos">3041</span></a><span class="sd"> opts: other options to use to parse the input table.</span> +</span><span id="L-3042"><a href="#L-3042"><span class="linenos">3042</span></a> +</span><span id="L-3043"><a href="#L-3043"><span class="linenos">3043</span></a><span class="sd"> Returns:</span> +</span><span id="L-3044"><a href="#L-3044"><span class="linenos">3044</span></a><span class="sd"> The new Create expression.</span> +</span><span id="L-3045"><a href="#L-3045"><span class="linenos">3045</span></a><span class="sd"> """</span> +</span><span id="L-3046"><a href="#L-3046"><span class="linenos">3046</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="L-3047"><a href="#L-3047"><span class="linenos">3047</span></a> <span class="n">table_expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span> +</span><span id="L-3048"><a href="#L-3048"><span class="linenos">3048</span></a> <span class="n">table</span><span class="p">,</span> +</span><span id="L-3049"><a href="#L-3049"><span class="linenos">3049</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">,</span> +</span><span id="L-3050"><a href="#L-3050"><span class="linenos">3050</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-3051"><a href="#L-3051"><span class="linenos">3051</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-3052"><a href="#L-3052"><span class="linenos">3052</span></a> <span class="p">)</span> +</span><span id="L-3053"><a href="#L-3053"><span class="linenos">3053</span></a> <span class="n">properties_expression</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3054"><a href="#L-3054"><span class="linenos">3054</span></a> <span class="k">if</span> <span class="n">properties</span><span class="p">:</span> +</span><span id="L-3055"><a href="#L-3055"><span class="linenos">3055</span></a> <span class="n">properties_expression</span> <span class="o">=</span> <span class="n">Properties</span><span class="o">.</span><span class="n">from_dict</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span> +</span><span id="L-3056"><a href="#L-3056"><span class="linenos">3056</span></a> +</span><span id="L-3057"><a href="#L-3057"><span class="linenos">3057</span></a> <span class="k">return</span> <span class="n">Create</span><span class="p">(</span> +</span><span id="L-3058"><a href="#L-3058"><span class="linenos">3058</span></a> <span class="n">this</span><span class="o">=</span><span class="n">table_expression</span><span class="p">,</span> +</span><span id="L-3059"><a href="#L-3059"><span class="linenos">3059</span></a> <span class="n">kind</span><span class="o">=</span><span class="s2">"table"</span><span class="p">,</span> +</span><span id="L-3060"><a href="#L-3060"><span class="linenos">3060</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">instance</span><span class="p">,</span> +</span><span id="L-3061"><a href="#L-3061"><span class="linenos">3061</span></a> <span class="n">properties</span><span class="o">=</span><span class="n">properties_expression</span><span class="p">,</span> +</span><span id="L-3062"><a href="#L-3062"><span class="linenos">3062</span></a> <span class="p">)</span> +</span><span id="L-3063"><a href="#L-3063"><span class="linenos">3063</span></a> +</span><span id="L-3064"><a href="#L-3064"><span class="linenos">3064</span></a> <span class="k">def</span> <span class="nf">lock</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">update</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-3065"><a href="#L-3065"><span class="linenos">3065</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-3066"><a href="#L-3066"><span class="linenos">3066</span></a><span class="sd"> Set the locking read mode for this expression.</span> +</span><span id="L-3067"><a href="#L-3067"><span class="linenos">3067</span></a> +</span><span id="L-3068"><a href="#L-3068"><span class="linenos">3068</span></a><span class="sd"> Examples:</span> +</span><span id="L-3069"><a href="#L-3069"><span class="linenos">3069</span></a><span class="sd"> >>> Select().select("x").from_("tbl").where("x = 'a'").lock().sql("mysql")</span> +</span><span id="L-3070"><a href="#L-3070"><span class="linenos">3070</span></a><span class="sd"> "SELECT x FROM tbl WHERE x = 'a' FOR UPDATE"</span> +</span><span id="L-3071"><a href="#L-3071"><span class="linenos">3071</span></a> +</span><span id="L-3072"><a href="#L-3072"><span class="linenos">3072</span></a><span class="sd"> >>> Select().select("x").from_("tbl").where("x = 'a'").lock(update=False).sql("mysql")</span> +</span><span id="L-3073"><a href="#L-3073"><span class="linenos">3073</span></a><span class="sd"> "SELECT x FROM tbl WHERE x = 'a' FOR SHARE"</span> +</span><span id="L-3074"><a href="#L-3074"><span class="linenos">3074</span></a> +</span><span id="L-3075"><a href="#L-3075"><span class="linenos">3075</span></a><span class="sd"> Args:</span> +</span><span id="L-3076"><a href="#L-3076"><span class="linenos">3076</span></a><span class="sd"> update: if `True`, the locking type will be `FOR UPDATE`, else it will be `FOR SHARE`.</span> +</span><span id="L-3077"><a href="#L-3077"><span class="linenos">3077</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="L-3078"><a href="#L-3078"><span class="linenos">3078</span></a> +</span><span id="L-3079"><a href="#L-3079"><span class="linenos">3079</span></a><span class="sd"> Returns:</span> +</span><span id="L-3080"><a href="#L-3080"><span class="linenos">3080</span></a><span class="sd"> The modified expression.</span> +</span><span id="L-3081"><a href="#L-3081"><span class="linenos">3081</span></a><span class="sd"> """</span> +</span><span id="L-3082"><a href="#L-3082"><span class="linenos">3082</span></a> <span class="n">inst</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="L-3083"><a href="#L-3083"><span class="linenos">3083</span></a> <span class="n">inst</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"locks"</span><span class="p">,</span> <span class="p">[</span><span class="n">Lock</span><span class="p">(</span><span class="n">update</span><span class="o">=</span><span class="n">update</span><span class="p">)])</span> </span><span id="L-3084"><a href="#L-3084"><span class="linenos">3084</span></a> -</span><span id="L-3085"><a href="#L-3085"><span class="linenos">3085</span></a> <span class="k">def</span> <span class="nf">hint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">hints</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-3086"><a href="#L-3086"><span class="linenos">3086</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-3087"><a href="#L-3087"><span class="linenos">3087</span></a><span class="sd"> Set hints for this expression.</span> -</span><span id="L-3088"><a href="#L-3088"><span class="linenos">3088</span></a> -</span><span id="L-3089"><a href="#L-3089"><span class="linenos">3089</span></a><span class="sd"> Examples:</span> -</span><span id="L-3090"><a href="#L-3090"><span class="linenos">3090</span></a><span class="sd"> >>> Select().select("x").from_("tbl").hint("BROADCAST(y)").sql(dialect="spark")</span> -</span><span id="L-3091"><a href="#L-3091"><span class="linenos">3091</span></a><span class="sd"> 'SELECT /*+ BROADCAST(y) */ x FROM tbl'</span> -</span><span id="L-3092"><a href="#L-3092"><span class="linenos">3092</span></a> -</span><span id="L-3093"><a href="#L-3093"><span class="linenos">3093</span></a><span class="sd"> Args:</span> -</span><span id="L-3094"><a href="#L-3094"><span class="linenos">3094</span></a><span class="sd"> hints: The SQL code strings to parse as the hints.</span> -</span><span id="L-3095"><a href="#L-3095"><span class="linenos">3095</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="L-3096"><a href="#L-3096"><span class="linenos">3096</span></a><span class="sd"> dialect: The dialect used to parse the hints.</span> -</span><span id="L-3097"><a href="#L-3097"><span class="linenos">3097</span></a><span class="sd"> copy: If `False`, modify this expression instance in-place.</span> -</span><span id="L-3098"><a href="#L-3098"><span class="linenos">3098</span></a> -</span><span id="L-3099"><a href="#L-3099"><span class="linenos">3099</span></a><span class="sd"> Returns:</span> -</span><span id="L-3100"><a href="#L-3100"><span class="linenos">3100</span></a><span class="sd"> The modified expression.</span> -</span><span id="L-3101"><a href="#L-3101"><span class="linenos">3101</span></a><span class="sd"> """</span> -</span><span id="L-3102"><a href="#L-3102"><span class="linenos">3102</span></a> <span class="n">inst</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="L-3103"><a href="#L-3103"><span class="linenos">3103</span></a> <span class="n">inst</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="L-3104"><a href="#L-3104"><span class="linenos">3104</span></a> <span class="s2">"hint"</span><span class="p">,</span> <span class="n">Hint</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> <span class="k">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">hints</span><span class="p">])</span> -</span><span id="L-3105"><a href="#L-3105"><span class="linenos">3105</span></a> <span class="p">)</span> -</span><span id="L-3106"><a href="#L-3106"><span class="linenos">3106</span></a> -</span><span id="L-3107"><a href="#L-3107"><span class="linenos">3107</span></a> <span class="k">return</span> <span class="n">inst</span> +</span><span id="L-3085"><a href="#L-3085"><span class="linenos">3085</span></a> <span class="k">return</span> <span class="n">inst</span> +</span><span id="L-3086"><a href="#L-3086"><span class="linenos">3086</span></a> +</span><span id="L-3087"><a href="#L-3087"><span class="linenos">3087</span></a> <span class="k">def</span> <span class="nf">hint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">hints</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-3088"><a href="#L-3088"><span class="linenos">3088</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-3089"><a href="#L-3089"><span class="linenos">3089</span></a><span class="sd"> Set hints for this expression.</span> +</span><span id="L-3090"><a href="#L-3090"><span class="linenos">3090</span></a> +</span><span id="L-3091"><a href="#L-3091"><span class="linenos">3091</span></a><span class="sd"> Examples:</span> +</span><span id="L-3092"><a href="#L-3092"><span class="linenos">3092</span></a><span class="sd"> >>> Select().select("x").from_("tbl").hint("BROADCAST(y)").sql(dialect="spark")</span> +</span><span id="L-3093"><a href="#L-3093"><span class="linenos">3093</span></a><span class="sd"> 'SELECT /*+ BROADCAST(y) */ x FROM tbl'</span> +</span><span id="L-3094"><a href="#L-3094"><span class="linenos">3094</span></a> +</span><span id="L-3095"><a href="#L-3095"><span class="linenos">3095</span></a><span class="sd"> Args:</span> +</span><span id="L-3096"><a href="#L-3096"><span class="linenos">3096</span></a><span class="sd"> hints: The SQL code strings to parse as the hints.</span> +</span><span id="L-3097"><a href="#L-3097"><span class="linenos">3097</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="L-3098"><a href="#L-3098"><span class="linenos">3098</span></a><span class="sd"> dialect: The dialect used to parse the hints.</span> +</span><span id="L-3099"><a href="#L-3099"><span class="linenos">3099</span></a><span class="sd"> copy: If `False`, modify this expression instance in-place.</span> +</span><span id="L-3100"><a href="#L-3100"><span class="linenos">3100</span></a> +</span><span id="L-3101"><a href="#L-3101"><span class="linenos">3101</span></a><span class="sd"> Returns:</span> +</span><span id="L-3102"><a href="#L-3102"><span class="linenos">3102</span></a><span class="sd"> The modified expression.</span> +</span><span id="L-3103"><a href="#L-3103"><span class="linenos">3103</span></a><span class="sd"> """</span> +</span><span id="L-3104"><a href="#L-3104"><span class="linenos">3104</span></a> <span class="n">inst</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="L-3105"><a href="#L-3105"><span class="linenos">3105</span></a> <span class="n">inst</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="L-3106"><a href="#L-3106"><span class="linenos">3106</span></a> <span class="s2">"hint"</span><span class="p">,</span> <span class="n">Hint</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> <span class="k">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">hints</span><span class="p">])</span> +</span><span id="L-3107"><a href="#L-3107"><span class="linenos">3107</span></a> <span class="p">)</span> </span><span id="L-3108"><a href="#L-3108"><span class="linenos">3108</span></a> -</span><span id="L-3109"><a href="#L-3109"><span class="linenos">3109</span></a> <span class="nd">@property</span> -</span><span id="L-3110"><a href="#L-3110"><span class="linenos">3110</span></a> <span class="k">def</span> <span class="nf">named_selects</span><span class="p">(</span><span class="bp">self</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-3111"><a href="#L-3111"><span class="linenos">3111</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">e</span><span class="o">.</span><span class="n">output_name</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> -</span><span id="L-3112"><a href="#L-3112"><span class="linenos">3112</span></a> -</span><span id="L-3113"><a href="#L-3113"><span class="linenos">3113</span></a> <span class="nd">@property</span> -</span><span id="L-3114"><a href="#L-3114"><span class="linenos">3114</span></a> <span class="k">def</span> <span class="nf">is_star</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="L-3115"><a href="#L-3115"><span class="linenos">3115</span></a> <span class="k">return</span> <span class="nb">any</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">is_star</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-3116"><a href="#L-3116"><span class="linenos">3116</span></a> -</span><span id="L-3117"><a href="#L-3117"><span class="linenos">3117</span></a> <span class="nd">@property</span> -</span><span id="L-3118"><a href="#L-3118"><span class="linenos">3118</span></a> <span class="k">def</span> <span class="nf">selects</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Expression</span><span class="p">]:</span> -</span><span id="L-3119"><a href="#L-3119"><span class="linenos">3119</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="L-3120"><a href="#L-3120"><span class="linenos">3120</span></a> -</span><span id="L-3121"><a href="#L-3121"><span class="linenos">3121</span></a> -</span><span id="L-3122"><a href="#L-3122"><span class="linenos">3122</span></a><span class="k">class</span> <span class="nc">Subquery</span><span class="p">(</span><span class="n">DerivedTable</span><span class="p">,</span> <span class="n">Unionable</span><span class="p">):</span> -</span><span id="L-3123"><a href="#L-3123"><span class="linenos">3123</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-3124"><a href="#L-3124"><span class="linenos">3124</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-3125"><a href="#L-3125"><span class="linenos">3125</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3126"><a href="#L-3126"><span class="linenos">3126</span></a> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3127"><a href="#L-3127"><span class="linenos">3127</span></a> <span class="o">**</span><span class="n">QUERY_MODIFIERS</span><span class="p">,</span> -</span><span id="L-3128"><a href="#L-3128"><span class="linenos">3128</span></a> <span class="p">}</span> -</span><span id="L-3129"><a href="#L-3129"><span class="linenos">3129</span></a> -</span><span id="L-3130"><a href="#L-3130"><span class="linenos">3130</span></a> <span class="k">def</span> <span class="nf">unnest</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="L-3131"><a href="#L-3131"><span class="linenos">3131</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-3132"><a href="#L-3132"><span class="linenos">3132</span></a><span class="sd"> Returns the first non subquery.</span> -</span><span id="L-3133"><a href="#L-3133"><span class="linenos">3133</span></a><span class="sd"> """</span> -</span><span id="L-3134"><a href="#L-3134"><span class="linenos">3134</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span> -</span><span id="L-3135"><a href="#L-3135"><span class="linenos">3135</span></a> <span class="k">while</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Subquery</span><span class="p">):</span> -</span><span id="L-3136"><a href="#L-3136"><span class="linenos">3136</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-3137"><a href="#L-3137"><span class="linenos">3137</span></a> <span class="k">return</span> <span class="n">expression</span> -</span><span id="L-3138"><a href="#L-3138"><span class="linenos">3138</span></a> -</span><span id="L-3139"><a href="#L-3139"><span class="linenos">3139</span></a> <span class="nd">@property</span> -</span><span id="L-3140"><a href="#L-3140"><span class="linenos">3140</span></a> <span class="k">def</span> <span class="nf">is_star</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="L-3141"><a href="#L-3141"><span class="linenos">3141</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">is_star</span> -</span><span id="L-3142"><a href="#L-3142"><span class="linenos">3142</span></a> -</span><span id="L-3143"><a href="#L-3143"><span class="linenos">3143</span></a> <span class="nd">@property</span> -</span><span id="L-3144"><a href="#L-3144"><span class="linenos">3144</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-3145"><a href="#L-3145"><span class="linenos">3145</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">alias</span> -</span><span id="L-3146"><a href="#L-3146"><span class="linenos">3146</span></a> -</span><span id="L-3147"><a href="#L-3147"><span class="linenos">3147</span></a> -</span><span id="L-3148"><a href="#L-3148"><span class="linenos">3148</span></a><span class="k">class</span> <span class="nc">TableSample</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3149"><a href="#L-3149"><span class="linenos">3149</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-3150"><a href="#L-3150"><span class="linenos">3150</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3151"><a href="#L-3151"><span class="linenos">3151</span></a> <span class="s2">"method"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3152"><a href="#L-3152"><span class="linenos">3152</span></a> <span class="s2">"bucket_numerator"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3153"><a href="#L-3153"><span class="linenos">3153</span></a> <span class="s2">"bucket_denominator"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3154"><a href="#L-3154"><span class="linenos">3154</span></a> <span class="s2">"bucket_field"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3155"><a href="#L-3155"><span class="linenos">3155</span></a> <span class="s2">"percent"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3156"><a href="#L-3156"><span class="linenos">3156</span></a> <span class="s2">"rows"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3157"><a href="#L-3157"><span class="linenos">3157</span></a> <span class="s2">"size"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3158"><a href="#L-3158"><span class="linenos">3158</span></a> <span class="s2">"seed"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3159"><a href="#L-3159"><span class="linenos">3159</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3160"><a href="#L-3160"><span class="linenos">3160</span></a> <span class="p">}</span> -</span><span id="L-3161"><a href="#L-3161"><span class="linenos">3161</span></a> -</span><span id="L-3162"><a href="#L-3162"><span class="linenos">3162</span></a> -</span><span id="L-3163"><a href="#L-3163"><span class="linenos">3163</span></a><span class="k">class</span> <span class="nc">Tag</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3164"><a href="#L-3164"><span class="linenos">3164</span></a><span class="w"> </span><span class="sd">"""Tags are used for generating arbitrary sql like SELECT <span>x</span>."""</span> -</span><span id="L-3165"><a href="#L-3165"><span class="linenos">3165</span></a> -</span><span id="L-3166"><a href="#L-3166"><span class="linenos">3166</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-3167"><a href="#L-3167"><span class="linenos">3167</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3168"><a href="#L-3168"><span class="linenos">3168</span></a> <span class="s2">"prefix"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3169"><a href="#L-3169"><span class="linenos">3169</span></a> <span class="s2">"postfix"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3170"><a href="#L-3170"><span class="linenos">3170</span></a> <span class="p">}</span> -</span><span id="L-3171"><a href="#L-3171"><span class="linenos">3171</span></a> -</span><span id="L-3172"><a href="#L-3172"><span class="linenos">3172</span></a> -</span><span id="L-3173"><a href="#L-3173"><span class="linenos">3173</span></a><span class="c1"># Represents both the standard SQL PIVOT operator and DuckDB's "simplified" PIVOT syntax</span> -</span><span id="L-3174"><a href="#L-3174"><span class="linenos">3174</span></a><span class="c1"># https://duckdb.org/docs/sql/statements/pivot</span> -</span><span id="L-3175"><a href="#L-3175"><span class="linenos">3175</span></a><span class="k">class</span> <span class="nc">Pivot</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3176"><a href="#L-3176"><span class="linenos">3176</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-3177"><a href="#L-3177"><span class="linenos">3177</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3178"><a href="#L-3178"><span class="linenos">3178</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3179"><a href="#L-3179"><span class="linenos">3179</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-3180"><a href="#L-3180"><span class="linenos">3180</span></a> <span class="s2">"field"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3181"><a href="#L-3181"><span class="linenos">3181</span></a> <span class="s2">"unpivot"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3182"><a href="#L-3182"><span class="linenos">3182</span></a> <span class="s2">"using"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3183"><a href="#L-3183"><span class="linenos">3183</span></a> <span class="s2">"group"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3184"><a href="#L-3184"><span class="linenos">3184</span></a> <span class="s2">"columns"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3185"><a href="#L-3185"><span class="linenos">3185</span></a> <span class="p">}</span> -</span><span id="L-3186"><a href="#L-3186"><span class="linenos">3186</span></a> -</span><span id="L-3187"><a href="#L-3187"><span class="linenos">3187</span></a> -</span><span id="L-3188"><a href="#L-3188"><span class="linenos">3188</span></a><span class="k">class</span> <span class="nc">Window</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3189"><a href="#L-3189"><span class="linenos">3189</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-3190"><a href="#L-3190"><span class="linenos">3190</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-3191"><a href="#L-3191"><span class="linenos">3191</span></a> <span class="s2">"partition_by"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3192"><a href="#L-3192"><span class="linenos">3192</span></a> <span class="s2">"order"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3193"><a href="#L-3193"><span class="linenos">3193</span></a> <span class="s2">"spec"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3194"><a href="#L-3194"><span class="linenos">3194</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3195"><a href="#L-3195"><span class="linenos">3195</span></a> <span class="s2">"over"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3196"><a href="#L-3196"><span class="linenos">3196</span></a> <span class="s2">"first"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3197"><a href="#L-3197"><span class="linenos">3197</span></a> <span class="p">}</span> -</span><span id="L-3198"><a href="#L-3198"><span class="linenos">3198</span></a> -</span><span id="L-3199"><a href="#L-3199"><span class="linenos">3199</span></a> -</span><span id="L-3200"><a href="#L-3200"><span class="linenos">3200</span></a><span class="k">class</span> <span class="nc">WindowSpec</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3201"><a href="#L-3201"><span class="linenos">3201</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-3202"><a href="#L-3202"><span class="linenos">3202</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3203"><a href="#L-3203"><span class="linenos">3203</span></a> <span class="s2">"start"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3204"><a href="#L-3204"><span class="linenos">3204</span></a> <span class="s2">"start_side"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3205"><a href="#L-3205"><span class="linenos">3205</span></a> <span class="s2">"end"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3206"><a href="#L-3206"><span class="linenos">3206</span></a> <span class="s2">"end_side"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3207"><a href="#L-3207"><span class="linenos">3207</span></a> <span class="p">}</span> -</span><span id="L-3208"><a href="#L-3208"><span class="linenos">3208</span></a> -</span><span id="L-3209"><a href="#L-3209"><span class="linenos">3209</span></a> -</span><span id="L-3210"><a href="#L-3210"><span class="linenos">3210</span></a><span class="k">class</span> <span class="nc">Where</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3211"><a href="#L-3211"><span class="linenos">3211</span></a> <span class="k">pass</span> -</span><span id="L-3212"><a href="#L-3212"><span class="linenos">3212</span></a> -</span><span id="L-3213"><a href="#L-3213"><span class="linenos">3213</span></a> -</span><span id="L-3214"><a href="#L-3214"><span class="linenos">3214</span></a><span class="k">class</span> <span class="nc">Star</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3215"><a href="#L-3215"><span class="linenos">3215</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"except"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"replace"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3216"><a href="#L-3216"><span class="linenos">3216</span></a> -</span><span id="L-3217"><a href="#L-3217"><span class="linenos">3217</span></a> <span class="nd">@property</span> -</span><span id="L-3218"><a href="#L-3218"><span class="linenos">3218</span></a> <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-3219"><a href="#L-3219"><span class="linenos">3219</span></a> <span class="k">return</span> <span class="s2">"*"</span> -</span><span id="L-3220"><a href="#L-3220"><span class="linenos">3220</span></a> -</span><span id="L-3221"><a href="#L-3221"><span class="linenos">3221</span></a> <span class="nd">@property</span> -</span><span id="L-3222"><a href="#L-3222"><span class="linenos">3222</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-3223"><a href="#L-3223"><span class="linenos">3223</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> -</span><span id="L-3224"><a href="#L-3224"><span class="linenos">3224</span></a> -</span><span id="L-3225"><a href="#L-3225"><span class="linenos">3225</span></a> -</span><span id="L-3226"><a href="#L-3226"><span class="linenos">3226</span></a><span class="k">class</span> <span class="nc">Parameter</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3227"><a href="#L-3227"><span class="linenos">3227</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"wrapped"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3228"><a href="#L-3228"><span class="linenos">3228</span></a> -</span><span id="L-3229"><a href="#L-3229"><span class="linenos">3229</span></a> -</span><span id="L-3230"><a href="#L-3230"><span class="linenos">3230</span></a><span class="k">class</span> <span class="nc">SessionParameter</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3231"><a href="#L-3231"><span class="linenos">3231</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3232"><a href="#L-3232"><span class="linenos">3232</span></a> -</span><span id="L-3233"><a href="#L-3233"><span class="linenos">3233</span></a> -</span><span id="L-3234"><a href="#L-3234"><span class="linenos">3234</span></a><span class="k">class</span> <span class="nc">Placeholder</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3235"><a href="#L-3235"><span class="linenos">3235</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3236"><a href="#L-3236"><span class="linenos">3236</span></a> -</span><span id="L-3237"><a href="#L-3237"><span class="linenos">3237</span></a> -</span><span id="L-3238"><a href="#L-3238"><span class="linenos">3238</span></a><span class="k">class</span> <span class="nc">Null</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> -</span><span id="L-3239"><a href="#L-3239"><span class="linenos">3239</span></a> <span class="n">arg_types</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-3240"><a href="#L-3240"><span class="linenos">3240</span></a> -</span><span id="L-3241"><a href="#L-3241"><span class="linenos">3241</span></a> <span class="nd">@property</span> -</span><span id="L-3242"><a href="#L-3242"><span class="linenos">3242</span></a> <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-3243"><a href="#L-3243"><span class="linenos">3243</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> -</span><span id="L-3244"><a href="#L-3244"><span class="linenos">3244</span></a> -</span><span id="L-3245"><a href="#L-3245"><span class="linenos">3245</span></a> -</span><span id="L-3246"><a href="#L-3246"><span class="linenos">3246</span></a><span class="k">class</span> <span class="nc">Boolean</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> -</span><span id="L-3247"><a href="#L-3247"><span class="linenos">3247</span></a> <span class="k">pass</span> -</span><span id="L-3248"><a href="#L-3248"><span class="linenos">3248</span></a> -</span><span id="L-3249"><a href="#L-3249"><span class="linenos">3249</span></a> -</span><span id="L-3250"><a href="#L-3250"><span class="linenos">3250</span></a><span class="k">class</span> <span class="nc">DataTypeSize</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3251"><a href="#L-3251"><span class="linenos">3251</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3252"><a href="#L-3252"><span class="linenos">3252</span></a> -</span><span id="L-3253"><a href="#L-3253"><span class="linenos">3253</span></a> -</span><span id="L-3254"><a href="#L-3254"><span class="linenos">3254</span></a><span class="k">class</span> <span class="nc">DataType</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3255"><a href="#L-3255"><span class="linenos">3255</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-3256"><a href="#L-3256"><span class="linenos">3256</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-3257"><a href="#L-3257"><span class="linenos">3257</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3258"><a href="#L-3258"><span class="linenos">3258</span></a> <span class="s2">"nested"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3259"><a href="#L-3259"><span class="linenos">3259</span></a> <span class="s2">"values"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3260"><a href="#L-3260"><span class="linenos">3260</span></a> <span class="s2">"prefix"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3261"><a href="#L-3261"><span class="linenos">3261</span></a> <span class="p">}</span> -</span><span id="L-3262"><a href="#L-3262"><span class="linenos">3262</span></a> -</span><span id="L-3263"><a href="#L-3263"><span class="linenos">3263</span></a> <span class="k">class</span> <span class="nc">Type</span><span class="p">(</span><span class="n">AutoName</span><span class="p">):</span> -</span><span id="L-3264"><a href="#L-3264"><span class="linenos">3264</span></a> <span class="n">ARRAY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3265"><a href="#L-3265"><span class="linenos">3265</span></a> <span class="n">BIGDECIMAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3266"><a href="#L-3266"><span class="linenos">3266</span></a> <span class="n">BIGINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3267"><a href="#L-3267"><span class="linenos">3267</span></a> <span class="n">BIGSERIAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3268"><a href="#L-3268"><span class="linenos">3268</span></a> <span class="n">BINARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3269"><a href="#L-3269"><span class="linenos">3269</span></a> <span class="n">BIT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3270"><a href="#L-3270"><span class="linenos">3270</span></a> <span class="n">BOOLEAN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3271"><a href="#L-3271"><span class="linenos">3271</span></a> <span class="n">CHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3272"><a href="#L-3272"><span class="linenos">3272</span></a> <span class="n">DATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3273"><a href="#L-3273"><span class="linenos">3273</span></a> <span class="n">DATETIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3274"><a href="#L-3274"><span class="linenos">3274</span></a> <span class="n">DATETIME64</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3275"><a href="#L-3275"><span class="linenos">3275</span></a> <span class="n">ENUM</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3276"><a href="#L-3276"><span class="linenos">3276</span></a> <span class="n">INT4RANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3277"><a href="#L-3277"><span class="linenos">3277</span></a> <span class="n">INT4MULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3278"><a href="#L-3278"><span class="linenos">3278</span></a> <span class="n">INT8RANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3279"><a href="#L-3279"><span class="linenos">3279</span></a> <span class="n">INT8MULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3280"><a href="#L-3280"><span class="linenos">3280</span></a> <span class="n">NUMRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3281"><a href="#L-3281"><span class="linenos">3281</span></a> <span class="n">NUMMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3282"><a href="#L-3282"><span class="linenos">3282</span></a> <span class="n">TSRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3283"><a href="#L-3283"><span class="linenos">3283</span></a> <span class="n">TSMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3284"><a href="#L-3284"><span class="linenos">3284</span></a> <span class="n">TSTZRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3285"><a href="#L-3285"><span class="linenos">3285</span></a> <span class="n">TSTZMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3286"><a href="#L-3286"><span class="linenos">3286</span></a> <span class="n">DATERANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3287"><a href="#L-3287"><span class="linenos">3287</span></a> <span class="n">DATEMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3288"><a href="#L-3288"><span class="linenos">3288</span></a> <span class="n">DECIMAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3289"><a href="#L-3289"><span class="linenos">3289</span></a> <span class="n">DOUBLE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3290"><a href="#L-3290"><span class="linenos">3290</span></a> <span class="n">FLOAT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3291"><a href="#L-3291"><span class="linenos">3291</span></a> <span class="n">GEOGRAPHY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3292"><a href="#L-3292"><span class="linenos">3292</span></a> <span class="n">GEOMETRY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3293"><a href="#L-3293"><span class="linenos">3293</span></a> <span class="n">HLLSKETCH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3294"><a href="#L-3294"><span class="linenos">3294</span></a> <span class="n">HSTORE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3295"><a href="#L-3295"><span class="linenos">3295</span></a> <span class="n">IMAGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3296"><a href="#L-3296"><span class="linenos">3296</span></a> <span class="n">INET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3297"><a href="#L-3297"><span class="linenos">3297</span></a> <span class="n">INT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3298"><a href="#L-3298"><span class="linenos">3298</span></a> <span class="n">INT128</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3299"><a href="#L-3299"><span class="linenos">3299</span></a> <span class="n">INT256</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3300"><a href="#L-3300"><span class="linenos">3300</span></a> <span class="n">INTERVAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3301"><a href="#L-3301"><span class="linenos">3301</span></a> <span class="n">JSON</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3302"><a href="#L-3302"><span class="linenos">3302</span></a> <span class="n">JSONB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3303"><a href="#L-3303"><span class="linenos">3303</span></a> <span class="n">LONGBLOB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3304"><a href="#L-3304"><span class="linenos">3304</span></a> <span class="n">LONGTEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3305"><a href="#L-3305"><span class="linenos">3305</span></a> <span class="n">MAP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3306"><a href="#L-3306"><span class="linenos">3306</span></a> <span class="n">MEDIUMBLOB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3307"><a href="#L-3307"><span class="linenos">3307</span></a> <span class="n">MEDIUMTEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3308"><a href="#L-3308"><span class="linenos">3308</span></a> <span class="n">MONEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3309"><a href="#L-3309"><span class="linenos">3309</span></a> <span class="n">NCHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3310"><a href="#L-3310"><span class="linenos">3310</span></a> <span class="n">NULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3311"><a href="#L-3311"><span class="linenos">3311</span></a> <span class="n">NULLABLE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3312"><a href="#L-3312"><span class="linenos">3312</span></a> <span class="n">NVARCHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3313"><a href="#L-3313"><span class="linenos">3313</span></a> <span class="n">OBJECT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3314"><a href="#L-3314"><span class="linenos">3314</span></a> <span class="n">ROWVERSION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3315"><a href="#L-3315"><span class="linenos">3315</span></a> <span class="n">SERIAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3316"><a href="#L-3316"><span class="linenos">3316</span></a> <span class="n">SET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3317"><a href="#L-3317"><span class="linenos">3317</span></a> <span class="n">SMALLINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3318"><a href="#L-3318"><span class="linenos">3318</span></a> <span class="n">SMALLMONEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3319"><a href="#L-3319"><span class="linenos">3319</span></a> <span class="n">SMALLSERIAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3320"><a href="#L-3320"><span class="linenos">3320</span></a> <span class="n">STRUCT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3321"><a href="#L-3321"><span class="linenos">3321</span></a> <span class="n">SUPER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3322"><a href="#L-3322"><span class="linenos">3322</span></a> <span class="n">TEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3323"><a href="#L-3323"><span class="linenos">3323</span></a> <span class="n">TIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3324"><a href="#L-3324"><span class="linenos">3324</span></a> <span class="n">TIMESTAMP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3325"><a href="#L-3325"><span class="linenos">3325</span></a> <span class="n">TIMESTAMPTZ</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3326"><a href="#L-3326"><span class="linenos">3326</span></a> <span class="n">TIMESTAMPLTZ</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3327"><a href="#L-3327"><span class="linenos">3327</span></a> <span class="n">TINYINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3328"><a href="#L-3328"><span class="linenos">3328</span></a> <span class="n">UBIGINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3329"><a href="#L-3329"><span class="linenos">3329</span></a> <span class="n">UINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3330"><a href="#L-3330"><span class="linenos">3330</span></a> <span class="n">USMALLINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3331"><a href="#L-3331"><span class="linenos">3331</span></a> <span class="n">UTINYINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3332"><a href="#L-3332"><span class="linenos">3332</span></a> <span class="n">UNKNOWN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> <span class="c1"># Sentinel value, useful for type annotation</span> -</span><span id="L-3333"><a href="#L-3333"><span class="linenos">3333</span></a> <span class="n">UINT128</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3334"><a href="#L-3334"><span class="linenos">3334</span></a> <span class="n">UINT256</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3335"><a href="#L-3335"><span class="linenos">3335</span></a> <span class="n">UNIQUEIDENTIFIER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3336"><a href="#L-3336"><span class="linenos">3336</span></a> <span class="n">UUID</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3337"><a href="#L-3337"><span class="linenos">3337</span></a> <span class="n">VARBINARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3338"><a href="#L-3338"><span class="linenos">3338</span></a> <span class="n">VARCHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3339"><a href="#L-3339"><span class="linenos">3339</span></a> <span class="n">VARIANT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3340"><a href="#L-3340"><span class="linenos">3340</span></a> <span class="n">XML</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-3341"><a href="#L-3341"><span class="linenos">3341</span></a> -</span><span id="L-3342"><a href="#L-3342"><span class="linenos">3342</span></a> <span class="n">TEXT_TYPES</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-3343"><a href="#L-3343"><span class="linenos">3343</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span> -</span><span id="L-3344"><a href="#L-3344"><span class="linenos">3344</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">,</span> -</span><span id="L-3345"><a href="#L-3345"><span class="linenos">3345</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> -</span><span id="L-3346"><a href="#L-3346"><span class="linenos">3346</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">,</span> -</span><span id="L-3347"><a href="#L-3347"><span class="linenos">3347</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> -</span><span id="L-3348"><a href="#L-3348"><span class="linenos">3348</span></a> <span class="p">}</span> -</span><span id="L-3349"><a href="#L-3349"><span class="linenos">3349</span></a> -</span><span id="L-3350"><a href="#L-3350"><span class="linenos">3350</span></a> <span class="n">INTEGER_TYPES</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-3351"><a href="#L-3351"><span class="linenos">3351</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">,</span> -</span><span id="L-3352"><a href="#L-3352"><span class="linenos">3352</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">,</span> -</span><span id="L-3353"><a href="#L-3353"><span class="linenos">3353</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> -</span><span id="L-3354"><a href="#L-3354"><span class="linenos">3354</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> -</span><span id="L-3355"><a href="#L-3355"><span class="linenos">3355</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">INT128</span><span class="p">,</span> -</span><span id="L-3356"><a href="#L-3356"><span class="linenos">3356</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">INT256</span><span class="p">,</span> -</span><span id="L-3357"><a href="#L-3357"><span class="linenos">3357</span></a> <span class="p">}</span> -</span><span id="L-3358"><a href="#L-3358"><span class="linenos">3358</span></a> -</span><span id="L-3359"><a href="#L-3359"><span class="linenos">3359</span></a> <span class="n">FLOAT_TYPES</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-3360"><a href="#L-3360"><span class="linenos">3360</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span> -</span><span id="L-3361"><a href="#L-3361"><span class="linenos">3361</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> -</span><span id="L-3362"><a href="#L-3362"><span class="linenos">3362</span></a> <span class="p">}</span> -</span><span id="L-3363"><a href="#L-3363"><span class="linenos">3363</span></a> -</span><span id="L-3364"><a href="#L-3364"><span class="linenos">3364</span></a> <span class="n">NUMERIC_TYPES</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">INTEGER_TYPES</span><span class="p">,</span> <span class="o">*</span><span class="n">FLOAT_TYPES</span><span class="p">}</span> +</span><span id="L-3109"><a href="#L-3109"><span class="linenos">3109</span></a> <span class="k">return</span> <span class="n">inst</span> +</span><span id="L-3110"><a href="#L-3110"><span class="linenos">3110</span></a> +</span><span id="L-3111"><a href="#L-3111"><span class="linenos">3111</span></a> <span class="nd">@property</span> +</span><span id="L-3112"><a href="#L-3112"><span class="linenos">3112</span></a> <span class="k">def</span> <span class="nf">named_selects</span><span class="p">(</span><span class="bp">self</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-3113"><a href="#L-3113"><span class="linenos">3113</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">e</span><span class="o">.</span><span class="n">output_name</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> +</span><span id="L-3114"><a href="#L-3114"><span class="linenos">3114</span></a> +</span><span id="L-3115"><a href="#L-3115"><span class="linenos">3115</span></a> <span class="nd">@property</span> +</span><span id="L-3116"><a href="#L-3116"><span class="linenos">3116</span></a> <span class="k">def</span> <span class="nf">is_star</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="L-3117"><a href="#L-3117"><span class="linenos">3117</span></a> <span class="k">return</span> <span class="nb">any</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">is_star</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-3118"><a href="#L-3118"><span class="linenos">3118</span></a> +</span><span id="L-3119"><a href="#L-3119"><span class="linenos">3119</span></a> <span class="nd">@property</span> +</span><span id="L-3120"><a href="#L-3120"><span class="linenos">3120</span></a> <span class="k">def</span> <span class="nf">selects</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Expression</span><span class="p">]:</span> +</span><span id="L-3121"><a href="#L-3121"><span class="linenos">3121</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="L-3122"><a href="#L-3122"><span class="linenos">3122</span></a> +</span><span id="L-3123"><a href="#L-3123"><span class="linenos">3123</span></a> +</span><span id="L-3124"><a href="#L-3124"><span class="linenos">3124</span></a><span class="k">class</span> <span class="nc">Subquery</span><span class="p">(</span><span class="n">DerivedTable</span><span class="p">,</span> <span class="n">Unionable</span><span class="p">):</span> +</span><span id="L-3125"><a href="#L-3125"><span class="linenos">3125</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-3126"><a href="#L-3126"><span class="linenos">3126</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-3127"><a href="#L-3127"><span class="linenos">3127</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3128"><a href="#L-3128"><span class="linenos">3128</span></a> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3129"><a href="#L-3129"><span class="linenos">3129</span></a> <span class="o">**</span><span class="n">QUERY_MODIFIERS</span><span class="p">,</span> +</span><span id="L-3130"><a href="#L-3130"><span class="linenos">3130</span></a> <span class="p">}</span> +</span><span id="L-3131"><a href="#L-3131"><span class="linenos">3131</span></a> +</span><span id="L-3132"><a href="#L-3132"><span class="linenos">3132</span></a> <span class="k">def</span> <span class="nf">unnest</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="L-3133"><a href="#L-3133"><span class="linenos">3133</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-3134"><a href="#L-3134"><span class="linenos">3134</span></a><span class="sd"> Returns the first non subquery.</span> +</span><span id="L-3135"><a href="#L-3135"><span class="linenos">3135</span></a><span class="sd"> """</span> +</span><span id="L-3136"><a href="#L-3136"><span class="linenos">3136</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span> +</span><span id="L-3137"><a href="#L-3137"><span class="linenos">3137</span></a> <span class="k">while</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Subquery</span><span class="p">):</span> +</span><span id="L-3138"><a href="#L-3138"><span class="linenos">3138</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-3139"><a href="#L-3139"><span class="linenos">3139</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-3140"><a href="#L-3140"><span class="linenos">3140</span></a> +</span><span id="L-3141"><a href="#L-3141"><span class="linenos">3141</span></a> <span class="nd">@property</span> +</span><span id="L-3142"><a href="#L-3142"><span class="linenos">3142</span></a> <span class="k">def</span> <span class="nf">is_star</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="L-3143"><a href="#L-3143"><span class="linenos">3143</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">is_star</span> +</span><span id="L-3144"><a href="#L-3144"><span class="linenos">3144</span></a> +</span><span id="L-3145"><a href="#L-3145"><span class="linenos">3145</span></a> <span class="nd">@property</span> +</span><span id="L-3146"><a href="#L-3146"><span class="linenos">3146</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-3147"><a href="#L-3147"><span class="linenos">3147</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">alias</span> +</span><span id="L-3148"><a href="#L-3148"><span class="linenos">3148</span></a> +</span><span id="L-3149"><a href="#L-3149"><span class="linenos">3149</span></a> +</span><span id="L-3150"><a href="#L-3150"><span class="linenos">3150</span></a><span class="k">class</span> <span class="nc">TableSample</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3151"><a href="#L-3151"><span class="linenos">3151</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-3152"><a href="#L-3152"><span class="linenos">3152</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3153"><a href="#L-3153"><span class="linenos">3153</span></a> <span class="s2">"method"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3154"><a href="#L-3154"><span class="linenos">3154</span></a> <span class="s2">"bucket_numerator"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3155"><a href="#L-3155"><span class="linenos">3155</span></a> <span class="s2">"bucket_denominator"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3156"><a href="#L-3156"><span class="linenos">3156</span></a> <span class="s2">"bucket_field"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3157"><a href="#L-3157"><span class="linenos">3157</span></a> <span class="s2">"percent"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3158"><a href="#L-3158"><span class="linenos">3158</span></a> <span class="s2">"rows"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3159"><a href="#L-3159"><span class="linenos">3159</span></a> <span class="s2">"size"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3160"><a href="#L-3160"><span class="linenos">3160</span></a> <span class="s2">"seed"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3161"><a href="#L-3161"><span class="linenos">3161</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3162"><a href="#L-3162"><span class="linenos">3162</span></a> <span class="p">}</span> +</span><span id="L-3163"><a href="#L-3163"><span class="linenos">3163</span></a> +</span><span id="L-3164"><a href="#L-3164"><span class="linenos">3164</span></a> +</span><span id="L-3165"><a href="#L-3165"><span class="linenos">3165</span></a><span class="k">class</span> <span class="nc">Tag</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3166"><a href="#L-3166"><span class="linenos">3166</span></a><span class="w"> </span><span class="sd">"""Tags are used for generating arbitrary sql like SELECT <span>x</span>."""</span> +</span><span id="L-3167"><a href="#L-3167"><span class="linenos">3167</span></a> +</span><span id="L-3168"><a href="#L-3168"><span class="linenos">3168</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-3169"><a href="#L-3169"><span class="linenos">3169</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3170"><a href="#L-3170"><span class="linenos">3170</span></a> <span class="s2">"prefix"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3171"><a href="#L-3171"><span class="linenos">3171</span></a> <span class="s2">"postfix"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3172"><a href="#L-3172"><span class="linenos">3172</span></a> <span class="p">}</span> +</span><span id="L-3173"><a href="#L-3173"><span class="linenos">3173</span></a> +</span><span id="L-3174"><a href="#L-3174"><span class="linenos">3174</span></a> +</span><span id="L-3175"><a href="#L-3175"><span class="linenos">3175</span></a><span class="c1"># Represents both the standard SQL PIVOT operator and DuckDB's "simplified" PIVOT syntax</span> +</span><span id="L-3176"><a href="#L-3176"><span class="linenos">3176</span></a><span class="c1"># https://duckdb.org/docs/sql/statements/pivot</span> +</span><span id="L-3177"><a href="#L-3177"><span class="linenos">3177</span></a><span class="k">class</span> <span class="nc">Pivot</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3178"><a href="#L-3178"><span class="linenos">3178</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-3179"><a href="#L-3179"><span class="linenos">3179</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3180"><a href="#L-3180"><span class="linenos">3180</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3181"><a href="#L-3181"><span class="linenos">3181</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-3182"><a href="#L-3182"><span class="linenos">3182</span></a> <span class="s2">"field"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3183"><a href="#L-3183"><span class="linenos">3183</span></a> <span class="s2">"unpivot"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3184"><a href="#L-3184"><span class="linenos">3184</span></a> <span class="s2">"using"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3185"><a href="#L-3185"><span class="linenos">3185</span></a> <span class="s2">"group"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3186"><a href="#L-3186"><span class="linenos">3186</span></a> <span class="s2">"columns"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3187"><a href="#L-3187"><span class="linenos">3187</span></a> <span class="p">}</span> +</span><span id="L-3188"><a href="#L-3188"><span class="linenos">3188</span></a> +</span><span id="L-3189"><a href="#L-3189"><span class="linenos">3189</span></a> +</span><span id="L-3190"><a href="#L-3190"><span class="linenos">3190</span></a><span class="k">class</span> <span class="nc">Window</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3191"><a href="#L-3191"><span class="linenos">3191</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-3192"><a href="#L-3192"><span class="linenos">3192</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-3193"><a href="#L-3193"><span class="linenos">3193</span></a> <span class="s2">"partition_by"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3194"><a href="#L-3194"><span class="linenos">3194</span></a> <span class="s2">"order"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3195"><a href="#L-3195"><span class="linenos">3195</span></a> <span class="s2">"spec"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3196"><a href="#L-3196"><span class="linenos">3196</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3197"><a href="#L-3197"><span class="linenos">3197</span></a> <span class="s2">"over"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3198"><a href="#L-3198"><span class="linenos">3198</span></a> <span class="s2">"first"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3199"><a href="#L-3199"><span class="linenos">3199</span></a> <span class="p">}</span> +</span><span id="L-3200"><a href="#L-3200"><span class="linenos">3200</span></a> +</span><span id="L-3201"><a href="#L-3201"><span class="linenos">3201</span></a> +</span><span id="L-3202"><a href="#L-3202"><span class="linenos">3202</span></a><span class="k">class</span> <span class="nc">WindowSpec</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3203"><a href="#L-3203"><span class="linenos">3203</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-3204"><a href="#L-3204"><span class="linenos">3204</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3205"><a href="#L-3205"><span class="linenos">3205</span></a> <span class="s2">"start"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3206"><a href="#L-3206"><span class="linenos">3206</span></a> <span class="s2">"start_side"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3207"><a href="#L-3207"><span class="linenos">3207</span></a> <span class="s2">"end"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3208"><a href="#L-3208"><span class="linenos">3208</span></a> <span class="s2">"end_side"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3209"><a href="#L-3209"><span class="linenos">3209</span></a> <span class="p">}</span> +</span><span id="L-3210"><a href="#L-3210"><span class="linenos">3210</span></a> +</span><span id="L-3211"><a href="#L-3211"><span class="linenos">3211</span></a> +</span><span id="L-3212"><a href="#L-3212"><span class="linenos">3212</span></a><span class="k">class</span> <span class="nc">Where</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3213"><a href="#L-3213"><span class="linenos">3213</span></a> <span class="k">pass</span> +</span><span id="L-3214"><a href="#L-3214"><span class="linenos">3214</span></a> +</span><span id="L-3215"><a href="#L-3215"><span class="linenos">3215</span></a> +</span><span id="L-3216"><a href="#L-3216"><span class="linenos">3216</span></a><span class="k">class</span> <span class="nc">Star</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3217"><a href="#L-3217"><span class="linenos">3217</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"except"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"replace"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-3218"><a href="#L-3218"><span class="linenos">3218</span></a> +</span><span id="L-3219"><a href="#L-3219"><span class="linenos">3219</span></a> <span class="nd">@property</span> +</span><span id="L-3220"><a href="#L-3220"><span class="linenos">3220</span></a> <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-3221"><a href="#L-3221"><span class="linenos">3221</span></a> <span class="k">return</span> <span class="s2">"*"</span> +</span><span id="L-3222"><a href="#L-3222"><span class="linenos">3222</span></a> +</span><span id="L-3223"><a href="#L-3223"><span class="linenos">3223</span></a> <span class="nd">@property</span> +</span><span id="L-3224"><a href="#L-3224"><span class="linenos">3224</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-3225"><a href="#L-3225"><span class="linenos">3225</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-3226"><a href="#L-3226"><span class="linenos">3226</span></a> +</span><span id="L-3227"><a href="#L-3227"><span class="linenos">3227</span></a> +</span><span id="L-3228"><a href="#L-3228"><span class="linenos">3228</span></a><span class="k">class</span> <span class="nc">Parameter</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> +</span><span id="L-3229"><a href="#L-3229"><span class="linenos">3229</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"wrapped"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-3230"><a href="#L-3230"><span class="linenos">3230</span></a> +</span><span id="L-3231"><a href="#L-3231"><span class="linenos">3231</span></a> +</span><span id="L-3232"><a href="#L-3232"><span class="linenos">3232</span></a><span class="k">class</span> <span class="nc">SessionParameter</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> +</span><span id="L-3233"><a href="#L-3233"><span class="linenos">3233</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-3234"><a href="#L-3234"><span class="linenos">3234</span></a> +</span><span id="L-3235"><a href="#L-3235"><span class="linenos">3235</span></a> +</span><span id="L-3236"><a href="#L-3236"><span class="linenos">3236</span></a><span class="k">class</span> <span class="nc">Placeholder</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> +</span><span id="L-3237"><a href="#L-3237"><span class="linenos">3237</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-3238"><a href="#L-3238"><span class="linenos">3238</span></a> +</span><span id="L-3239"><a href="#L-3239"><span class="linenos">3239</span></a> +</span><span id="L-3240"><a href="#L-3240"><span class="linenos">3240</span></a><span class="k">class</span> <span class="nc">Null</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> +</span><span id="L-3241"><a href="#L-3241"><span class="linenos">3241</span></a> <span class="n">arg_types</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-3242"><a href="#L-3242"><span class="linenos">3242</span></a> +</span><span id="L-3243"><a href="#L-3243"><span class="linenos">3243</span></a> <span class="nd">@property</span> +</span><span id="L-3244"><a href="#L-3244"><span class="linenos">3244</span></a> <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-3245"><a href="#L-3245"><span class="linenos">3245</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> +</span><span id="L-3246"><a href="#L-3246"><span class="linenos">3246</span></a> +</span><span id="L-3247"><a href="#L-3247"><span class="linenos">3247</span></a> +</span><span id="L-3248"><a href="#L-3248"><span class="linenos">3248</span></a><span class="k">class</span> <span class="nc">Boolean</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> +</span><span id="L-3249"><a href="#L-3249"><span class="linenos">3249</span></a> <span class="k">pass</span> +</span><span id="L-3250"><a href="#L-3250"><span class="linenos">3250</span></a> +</span><span id="L-3251"><a href="#L-3251"><span class="linenos">3251</span></a> +</span><span id="L-3252"><a href="#L-3252"><span class="linenos">3252</span></a><span class="k">class</span> <span class="nc">DataTypeSize</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3253"><a href="#L-3253"><span class="linenos">3253</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-3254"><a href="#L-3254"><span class="linenos">3254</span></a> +</span><span id="L-3255"><a href="#L-3255"><span class="linenos">3255</span></a> +</span><span id="L-3256"><a href="#L-3256"><span class="linenos">3256</span></a><span class="k">class</span> <span class="nc">DataType</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3257"><a href="#L-3257"><span class="linenos">3257</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-3258"><a href="#L-3258"><span class="linenos">3258</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-3259"><a href="#L-3259"><span class="linenos">3259</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3260"><a href="#L-3260"><span class="linenos">3260</span></a> <span class="s2">"nested"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3261"><a href="#L-3261"><span class="linenos">3261</span></a> <span class="s2">"values"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3262"><a href="#L-3262"><span class="linenos">3262</span></a> <span class="s2">"prefix"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3263"><a href="#L-3263"><span class="linenos">3263</span></a> <span class="p">}</span> +</span><span id="L-3264"><a href="#L-3264"><span class="linenos">3264</span></a> +</span><span id="L-3265"><a href="#L-3265"><span class="linenos">3265</span></a> <span class="k">class</span> <span class="nc">Type</span><span class="p">(</span><span class="n">AutoName</span><span class="p">):</span> +</span><span id="L-3266"><a href="#L-3266"><span class="linenos">3266</span></a> <span class="n">ARRAY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3267"><a href="#L-3267"><span class="linenos">3267</span></a> <span class="n">BIGDECIMAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3268"><a href="#L-3268"><span class="linenos">3268</span></a> <span class="n">BIGINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3269"><a href="#L-3269"><span class="linenos">3269</span></a> <span class="n">BIGSERIAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3270"><a href="#L-3270"><span class="linenos">3270</span></a> <span class="n">BINARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3271"><a href="#L-3271"><span class="linenos">3271</span></a> <span class="n">BIT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3272"><a href="#L-3272"><span class="linenos">3272</span></a> <span class="n">BOOLEAN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3273"><a href="#L-3273"><span class="linenos">3273</span></a> <span class="n">CHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3274"><a href="#L-3274"><span class="linenos">3274</span></a> <span class="n">DATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3275"><a href="#L-3275"><span class="linenos">3275</span></a> <span class="n">DATETIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3276"><a href="#L-3276"><span class="linenos">3276</span></a> <span class="n">DATETIME64</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3277"><a href="#L-3277"><span class="linenos">3277</span></a> <span class="n">ENUM</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3278"><a href="#L-3278"><span class="linenos">3278</span></a> <span class="n">INT4RANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3279"><a href="#L-3279"><span class="linenos">3279</span></a> <span class="n">INT4MULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3280"><a href="#L-3280"><span class="linenos">3280</span></a> <span class="n">INT8RANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3281"><a href="#L-3281"><span class="linenos">3281</span></a> <span class="n">INT8MULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3282"><a href="#L-3282"><span class="linenos">3282</span></a> <span class="n">NUMRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3283"><a href="#L-3283"><span class="linenos">3283</span></a> <span class="n">NUMMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3284"><a href="#L-3284"><span class="linenos">3284</span></a> <span class="n">TSRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3285"><a href="#L-3285"><span class="linenos">3285</span></a> <span class="n">TSMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3286"><a href="#L-3286"><span class="linenos">3286</span></a> <span class="n">TSTZRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3287"><a href="#L-3287"><span class="linenos">3287</span></a> <span class="n">TSTZMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3288"><a href="#L-3288"><span class="linenos">3288</span></a> <span class="n">DATERANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3289"><a href="#L-3289"><span class="linenos">3289</span></a> <span class="n">DATEMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3290"><a href="#L-3290"><span class="linenos">3290</span></a> <span class="n">DECIMAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3291"><a href="#L-3291"><span class="linenos">3291</span></a> <span class="n">DOUBLE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3292"><a href="#L-3292"><span class="linenos">3292</span></a> <span class="n">FLOAT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3293"><a href="#L-3293"><span class="linenos">3293</span></a> <span class="n">GEOGRAPHY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3294"><a href="#L-3294"><span class="linenos">3294</span></a> <span class="n">GEOMETRY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3295"><a href="#L-3295"><span class="linenos">3295</span></a> <span class="n">HLLSKETCH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3296"><a href="#L-3296"><span class="linenos">3296</span></a> <span class="n">HSTORE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3297"><a href="#L-3297"><span class="linenos">3297</span></a> <span class="n">IMAGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3298"><a href="#L-3298"><span class="linenos">3298</span></a> <span class="n">INET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3299"><a href="#L-3299"><span class="linenos">3299</span></a> <span class="n">INT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3300"><a href="#L-3300"><span class="linenos">3300</span></a> <span class="n">INT128</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3301"><a href="#L-3301"><span class="linenos">3301</span></a> <span class="n">INT256</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3302"><a href="#L-3302"><span class="linenos">3302</span></a> <span class="n">INTERVAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3303"><a href="#L-3303"><span class="linenos">3303</span></a> <span class="n">JSON</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3304"><a href="#L-3304"><span class="linenos">3304</span></a> <span class="n">JSONB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3305"><a href="#L-3305"><span class="linenos">3305</span></a> <span class="n">LONGBLOB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3306"><a href="#L-3306"><span class="linenos">3306</span></a> <span class="n">LONGTEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3307"><a href="#L-3307"><span class="linenos">3307</span></a> <span class="n">MAP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3308"><a href="#L-3308"><span class="linenos">3308</span></a> <span class="n">MEDIUMBLOB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3309"><a href="#L-3309"><span class="linenos">3309</span></a> <span class="n">MEDIUMTEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3310"><a href="#L-3310"><span class="linenos">3310</span></a> <span class="n">MONEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3311"><a href="#L-3311"><span class="linenos">3311</span></a> <span class="n">NCHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3312"><a href="#L-3312"><span class="linenos">3312</span></a> <span class="n">NULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3313"><a href="#L-3313"><span class="linenos">3313</span></a> <span class="n">NULLABLE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3314"><a href="#L-3314"><span class="linenos">3314</span></a> <span class="n">NVARCHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3315"><a href="#L-3315"><span class="linenos">3315</span></a> <span class="n">OBJECT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3316"><a href="#L-3316"><span class="linenos">3316</span></a> <span class="n">ROWVERSION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3317"><a href="#L-3317"><span class="linenos">3317</span></a> <span class="n">SERIAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3318"><a href="#L-3318"><span class="linenos">3318</span></a> <span class="n">SET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3319"><a href="#L-3319"><span class="linenos">3319</span></a> <span class="n">SMALLINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3320"><a href="#L-3320"><span class="linenos">3320</span></a> <span class="n">SMALLMONEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3321"><a href="#L-3321"><span class="linenos">3321</span></a> <span class="n">SMALLSERIAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3322"><a href="#L-3322"><span class="linenos">3322</span></a> <span class="n">STRUCT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3323"><a href="#L-3323"><span class="linenos">3323</span></a> <span class="n">SUPER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3324"><a href="#L-3324"><span class="linenos">3324</span></a> <span class="n">TEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3325"><a href="#L-3325"><span class="linenos">3325</span></a> <span class="n">TIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3326"><a href="#L-3326"><span class="linenos">3326</span></a> <span class="n">TIMESTAMP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3327"><a href="#L-3327"><span class="linenos">3327</span></a> <span class="n">TIMESTAMPTZ</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3328"><a href="#L-3328"><span class="linenos">3328</span></a> <span class="n">TIMESTAMPLTZ</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3329"><a href="#L-3329"><span class="linenos">3329</span></a> <span class="n">TINYINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3330"><a href="#L-3330"><span class="linenos">3330</span></a> <span class="n">UBIGINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3331"><a href="#L-3331"><span class="linenos">3331</span></a> <span class="n">UINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3332"><a href="#L-3332"><span class="linenos">3332</span></a> <span class="n">USMALLINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3333"><a href="#L-3333"><span class="linenos">3333</span></a> <span class="n">UTINYINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3334"><a href="#L-3334"><span class="linenos">3334</span></a> <span class="n">UNKNOWN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> <span class="c1"># Sentinel value, useful for type annotation</span> +</span><span id="L-3335"><a href="#L-3335"><span class="linenos">3335</span></a> <span class="n">UINT128</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3336"><a href="#L-3336"><span class="linenos">3336</span></a> <span class="n">UINT256</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3337"><a href="#L-3337"><span class="linenos">3337</span></a> <span class="n">UNIQUEIDENTIFIER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3338"><a href="#L-3338"><span class="linenos">3338</span></a> <span class="n">UUID</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3339"><a href="#L-3339"><span class="linenos">3339</span></a> <span class="n">VARBINARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3340"><a href="#L-3340"><span class="linenos">3340</span></a> <span class="n">VARCHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3341"><a href="#L-3341"><span class="linenos">3341</span></a> <span class="n">VARIANT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3342"><a href="#L-3342"><span class="linenos">3342</span></a> <span class="n">XML</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-3343"><a href="#L-3343"><span class="linenos">3343</span></a> +</span><span id="L-3344"><a href="#L-3344"><span class="linenos">3344</span></a> <span class="n">TEXT_TYPES</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-3345"><a href="#L-3345"><span class="linenos">3345</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span> +</span><span id="L-3346"><a href="#L-3346"><span class="linenos">3346</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">,</span> +</span><span id="L-3347"><a href="#L-3347"><span class="linenos">3347</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> +</span><span id="L-3348"><a href="#L-3348"><span class="linenos">3348</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">,</span> +</span><span id="L-3349"><a href="#L-3349"><span class="linenos">3349</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> +</span><span id="L-3350"><a href="#L-3350"><span class="linenos">3350</span></a> <span class="p">}</span> +</span><span id="L-3351"><a href="#L-3351"><span class="linenos">3351</span></a> +</span><span id="L-3352"><a href="#L-3352"><span class="linenos">3352</span></a> <span class="n">INTEGER_TYPES</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-3353"><a href="#L-3353"><span class="linenos">3353</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">,</span> +</span><span id="L-3354"><a href="#L-3354"><span class="linenos">3354</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">,</span> +</span><span id="L-3355"><a href="#L-3355"><span class="linenos">3355</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> +</span><span id="L-3356"><a href="#L-3356"><span class="linenos">3356</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> +</span><span id="L-3357"><a href="#L-3357"><span class="linenos">3357</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">INT128</span><span class="p">,</span> +</span><span id="L-3358"><a href="#L-3358"><span class="linenos">3358</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">INT256</span><span class="p">,</span> +</span><span id="L-3359"><a href="#L-3359"><span class="linenos">3359</span></a> <span class="p">}</span> +</span><span id="L-3360"><a href="#L-3360"><span class="linenos">3360</span></a> +</span><span id="L-3361"><a href="#L-3361"><span class="linenos">3361</span></a> <span class="n">FLOAT_TYPES</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-3362"><a href="#L-3362"><span class="linenos">3362</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span> +</span><span id="L-3363"><a href="#L-3363"><span class="linenos">3363</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> +</span><span id="L-3364"><a href="#L-3364"><span class="linenos">3364</span></a> <span class="p">}</span> </span><span id="L-3365"><a href="#L-3365"><span class="linenos">3365</span></a> -</span><span id="L-3366"><a href="#L-3366"><span class="linenos">3366</span></a> <span class="n">TEMPORAL_TYPES</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-3367"><a href="#L-3367"><span class="linenos">3367</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TIME</span><span class="p">,</span> -</span><span id="L-3368"><a href="#L-3368"><span class="linenos">3368</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> -</span><span id="L-3369"><a href="#L-3369"><span class="linenos">3369</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> -</span><span id="L-3370"><a href="#L-3370"><span class="linenos">3370</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">,</span> -</span><span id="L-3371"><a href="#L-3371"><span class="linenos">3371</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">DATE</span><span class="p">,</span> -</span><span id="L-3372"><a href="#L-3372"><span class="linenos">3372</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">DATETIME</span><span class="p">,</span> -</span><span id="L-3373"><a href="#L-3373"><span class="linenos">3373</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">DATETIME64</span><span class="p">,</span> -</span><span id="L-3374"><a href="#L-3374"><span class="linenos">3374</span></a> <span class="p">}</span> -</span><span id="L-3375"><a href="#L-3375"><span class="linenos">3375</span></a> -</span><span id="L-3376"><a href="#L-3376"><span class="linenos">3376</span></a> <span class="nd">@classmethod</span> -</span><span id="L-3377"><a href="#L-3377"><span class="linenos">3377</span></a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span> -</span><span id="L-3378"><a href="#L-3378"><span class="linenos">3378</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">dtype</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> -</span><span id="L-3379"><a href="#L-3379"><span class="linenos">3379</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataType</span><span class="p">:</span> -</span><span id="L-3380"><a href="#L-3380"><span class="linenos">3380</span></a> <span class="kn">from</span> <span class="nn">sqlglot</span> <span class="kn">import</span> <span class="n">parse_one</span> -</span><span id="L-3381"><a href="#L-3381"><span class="linenos">3381</span></a> -</span><span id="L-3382"><a href="#L-3382"><span class="linenos">3382</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="L-3383"><a href="#L-3383"><span class="linenos">3383</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"UNKNOWN"</span><span class="p">:</span> -</span><span id="L-3384"><a href="#L-3384"><span class="linenos">3384</span></a> <span class="n">data_type_exp</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">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UNKNOWN</span><span class="p">)</span> -</span><span id="L-3385"><a href="#L-3385"><span class="linenos">3385</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3386"><a href="#L-3386"><span class="linenos">3386</span></a> <span class="n">data_type_exp</span> <span class="o">=</span> <span class="n">parse_one</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">read</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">DataType</span><span class="p">)</span> -</span><span id="L-3387"><a href="#L-3387"><span class="linenos">3387</span></a> -</span><span id="L-3388"><a href="#L-3388"><span class="linenos">3388</span></a> <span class="k">if</span> <span class="n">data_type_exp</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-3389"><a href="#L-3389"><span class="linenos">3389</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unparsable data type value: </span><span class="si">{</span><span class="n">dtype</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-3390"><a href="#L-3390"><span class="linenos">3390</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">):</span> -</span><span id="L-3391"><a href="#L-3391"><span class="linenos">3391</span></a> <span class="n">data_type_exp</span> <span class="o">=</span> <span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">dtype</span><span class="p">)</span> -</span><span id="L-3392"><a href="#L-3392"><span class="linenos">3392</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">DataType</span><span class="p">):</span> -</span><span id="L-3393"><a href="#L-3393"><span class="linenos">3393</span></a> <span class="k">return</span> <span class="n">dtype</span> -</span><span id="L-3394"><a href="#L-3394"><span class="linenos">3394</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3395"><a href="#L-3395"><span class="linenos">3395</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid data type: </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span><span class="si">}</span><span class="s2">. Expected str or DataType.Type"</span><span class="p">)</span> -</span><span id="L-3396"><a href="#L-3396"><span class="linenos">3396</span></a> -</span><span id="L-3397"><a href="#L-3397"><span class="linenos">3397</span></a> <span class="k">return</span> <span class="n">DataType</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="o">**</span><span class="n">data_type_exp</span><span class="o">.</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">})</span> -</span><span id="L-3398"><a href="#L-3398"><span class="linenos">3398</span></a> -</span><span id="L-3399"><a href="#L-3399"><span class="linenos">3399</span></a> <span class="k">def</span> <span class="nf">is_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">dtypes</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="L-3400"><a href="#L-3400"><span class="linenos">3400</span></a> <span class="k">return</span> <span class="nb">any</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">this</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="n">dtype</span><span class="p">)</span><span class="o">.</span><span class="n">this</span> <span class="k">for</span> <span class="n">dtype</span> <span class="ow">in</span> <span class="n">dtypes</span><span class="p">)</span> +</span><span id="L-3366"><a href="#L-3366"><span class="linenos">3366</span></a> <span class="n">NUMERIC_TYPES</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">INTEGER_TYPES</span><span class="p">,</span> <span class="o">*</span><span class="n">FLOAT_TYPES</span><span class="p">}</span> +</span><span id="L-3367"><a href="#L-3367"><span class="linenos">3367</span></a> +</span><span id="L-3368"><a href="#L-3368"><span class="linenos">3368</span></a> <span class="n">TEMPORAL_TYPES</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-3369"><a href="#L-3369"><span class="linenos">3369</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TIME</span><span class="p">,</span> +</span><span id="L-3370"><a href="#L-3370"><span class="linenos">3370</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> +</span><span id="L-3371"><a href="#L-3371"><span class="linenos">3371</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> +</span><span id="L-3372"><a href="#L-3372"><span class="linenos">3372</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">,</span> +</span><span id="L-3373"><a href="#L-3373"><span class="linenos">3373</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">DATE</span><span class="p">,</span> +</span><span id="L-3374"><a href="#L-3374"><span class="linenos">3374</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">DATETIME</span><span class="p">,</span> +</span><span id="L-3375"><a href="#L-3375"><span class="linenos">3375</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">DATETIME64</span><span class="p">,</span> +</span><span id="L-3376"><a href="#L-3376"><span class="linenos">3376</span></a> <span class="p">}</span> +</span><span id="L-3377"><a href="#L-3377"><span class="linenos">3377</span></a> +</span><span id="L-3378"><a href="#L-3378"><span class="linenos">3378</span></a> <span class="n">META_TYPES</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"UNKNOWN"</span><span class="p">,</span> <span class="s2">"NULL"</span><span class="p">}</span> +</span><span id="L-3379"><a href="#L-3379"><span class="linenos">3379</span></a> +</span><span id="L-3380"><a href="#L-3380"><span class="linenos">3380</span></a> <span class="nd">@classmethod</span> +</span><span id="L-3381"><a href="#L-3381"><span class="linenos">3381</span></a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span> +</span><span id="L-3382"><a href="#L-3382"><span class="linenos">3382</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">dtype</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> +</span><span id="L-3383"><a href="#L-3383"><span class="linenos">3383</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataType</span><span class="p">:</span> +</span><span id="L-3384"><a href="#L-3384"><span class="linenos">3384</span></a> <span class="kn">from</span> <span class="nn">sqlglot</span> <span class="kn">import</span> <span class="n">parse_one</span> +</span><span id="L-3385"><a href="#L-3385"><span class="linenos">3385</span></a> +</span><span id="L-3386"><a href="#L-3386"><span class="linenos">3386</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="L-3387"><a href="#L-3387"><span class="linenos">3387</span></a> <span class="n">upper</span> <span class="o">=</span> <span class="n">dtype</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-3388"><a href="#L-3388"><span class="linenos">3388</span></a> <span class="k">if</span> <span class="n">upper</span> <span class="ow">in</span> <span class="n">DataType</span><span class="o">.</span><span class="n">META_TYPES</span><span class="p">:</span> +</span><span id="L-3389"><a href="#L-3389"><span class="linenos">3389</span></a> <span class="n">data_type_exp</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">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">upper</span><span class="p">])</span> +</span><span id="L-3390"><a href="#L-3390"><span class="linenos">3390</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3391"><a href="#L-3391"><span class="linenos">3391</span></a> <span class="n">data_type_exp</span> <span class="o">=</span> <span class="n">parse_one</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">read</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">DataType</span><span class="p">)</span> +</span><span id="L-3392"><a href="#L-3392"><span class="linenos">3392</span></a> +</span><span id="L-3393"><a href="#L-3393"><span class="linenos">3393</span></a> <span class="k">if</span> <span class="n">data_type_exp</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-3394"><a href="#L-3394"><span class="linenos">3394</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unparsable data type value: </span><span class="si">{</span><span class="n">dtype</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-3395"><a href="#L-3395"><span class="linenos">3395</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">):</span> +</span><span id="L-3396"><a href="#L-3396"><span class="linenos">3396</span></a> <span class="n">data_type_exp</span> <span class="o">=</span> <span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">dtype</span><span class="p">)</span> +</span><span id="L-3397"><a href="#L-3397"><span class="linenos">3397</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">DataType</span><span class="p">):</span> +</span><span id="L-3398"><a href="#L-3398"><span class="linenos">3398</span></a> <span class="k">return</span> <span class="n">dtype</span> +</span><span id="L-3399"><a href="#L-3399"><span class="linenos">3399</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3400"><a href="#L-3400"><span class="linenos">3400</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid data type: </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span><span class="si">}</span><span class="s2">. Expected str or DataType.Type"</span><span class="p">)</span> </span><span id="L-3401"><a href="#L-3401"><span class="linenos">3401</span></a> -</span><span id="L-3402"><a href="#L-3402"><span class="linenos">3402</span></a> -</span><span id="L-3403"><a href="#L-3403"><span class="linenos">3403</span></a><span class="c1"># https://www.postgresql.org/docs/15/datatype-pseudo.html</span> -</span><span id="L-3404"><a href="#L-3404"><span class="linenos">3404</span></a><span class="k">class</span> <span class="nc">PseudoType</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3405"><a href="#L-3405"><span class="linenos">3405</span></a> <span class="k">pass</span> +</span><span id="L-3402"><a href="#L-3402"><span class="linenos">3402</span></a> <span class="k">return</span> <span class="n">DataType</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="o">**</span><span class="n">data_type_exp</span><span class="o">.</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">})</span> +</span><span id="L-3403"><a href="#L-3403"><span class="linenos">3403</span></a> +</span><span id="L-3404"><a href="#L-3404"><span class="linenos">3404</span></a> <span class="k">def</span> <span class="nf">is_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">dtypes</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="L-3405"><a href="#L-3405"><span class="linenos">3405</span></a> <span class="k">return</span> <span class="nb">any</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">this</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="n">dtype</span><span class="p">)</span><span class="o">.</span><span class="n">this</span> <span class="k">for</span> <span class="n">dtype</span> <span class="ow">in</span> <span class="n">dtypes</span><span class="p">)</span> </span><span id="L-3406"><a href="#L-3406"><span class="linenos">3406</span></a> </span><span id="L-3407"><a href="#L-3407"><span class="linenos">3407</span></a> -</span><span id="L-3408"><a href="#L-3408"><span class="linenos">3408</span></a><span class="c1"># WHERE x <OP> EXISTS|ALL|ANY|SOME(SELECT ...)</span> -</span><span id="L-3409"><a href="#L-3409"><span class="linenos">3409</span></a><span class="k">class</span> <span class="nc">SubqueryPredicate</span><span class="p">(</span><span class="n">Predicate</span><span class="p">):</span> +</span><span id="L-3408"><a href="#L-3408"><span class="linenos">3408</span></a><span class="c1"># https://www.postgresql.org/docs/15/datatype-pseudo.html</span> +</span><span id="L-3409"><a href="#L-3409"><span class="linenos">3409</span></a><span class="k">class</span> <span class="nc">PseudoType</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> </span><span id="L-3410"><a href="#L-3410"><span class="linenos">3410</span></a> <span class="k">pass</span> </span><span id="L-3411"><a href="#L-3411"><span class="linenos">3411</span></a> </span><span id="L-3412"><a href="#L-3412"><span class="linenos">3412</span></a> -</span><span id="L-3413"><a href="#L-3413"><span class="linenos">3413</span></a><span class="k">class</span> <span class="nc">All</span><span class="p">(</span><span class="n">SubqueryPredicate</span><span class="p">):</span> -</span><span id="L-3414"><a href="#L-3414"><span class="linenos">3414</span></a> <span class="k">pass</span> -</span><span id="L-3415"><a href="#L-3415"><span class="linenos">3415</span></a> +</span><span id="L-3413"><a href="#L-3413"><span class="linenos">3413</span></a><span class="c1"># WHERE x <OP> EXISTS|ALL|ANY|SOME(SELECT ...)</span> +</span><span id="L-3414"><a href="#L-3414"><span class="linenos">3414</span></a><span class="k">class</span> <span class="nc">SubqueryPredicate</span><span class="p">(</span><span class="n">Predicate</span><span class="p">):</span> +</span><span id="L-3415"><a href="#L-3415"><span class="linenos">3415</span></a> <span class="k">pass</span> </span><span id="L-3416"><a href="#L-3416"><span class="linenos">3416</span></a> -</span><span id="L-3417"><a href="#L-3417"><span class="linenos">3417</span></a><span class="k">class</span> <span class="nc">Any</span><span class="p">(</span><span class="n">SubqueryPredicate</span><span class="p">):</span> -</span><span id="L-3418"><a href="#L-3418"><span class="linenos">3418</span></a> <span class="k">pass</span> -</span><span id="L-3419"><a href="#L-3419"><span class="linenos">3419</span></a> +</span><span id="L-3417"><a href="#L-3417"><span class="linenos">3417</span></a> +</span><span id="L-3418"><a href="#L-3418"><span class="linenos">3418</span></a><span class="k">class</span> <span class="nc">All</span><span class="p">(</span><span class="n">SubqueryPredicate</span><span class="p">):</span> +</span><span id="L-3419"><a href="#L-3419"><span class="linenos">3419</span></a> <span class="k">pass</span> </span><span id="L-3420"><a href="#L-3420"><span class="linenos">3420</span></a> -</span><span id="L-3421"><a href="#L-3421"><span class="linenos">3421</span></a><span class="k">class</span> <span class="nc">Exists</span><span class="p">(</span><span class="n">SubqueryPredicate</span><span class="p">):</span> -</span><span id="L-3422"><a href="#L-3422"><span class="linenos">3422</span></a> <span class="k">pass</span> -</span><span id="L-3423"><a href="#L-3423"><span class="linenos">3423</span></a> +</span><span id="L-3421"><a href="#L-3421"><span class="linenos">3421</span></a> +</span><span id="L-3422"><a href="#L-3422"><span class="linenos">3422</span></a><span class="k">class</span> <span class="nc">Any</span><span class="p">(</span><span class="n">SubqueryPredicate</span><span class="p">):</span> +</span><span id="L-3423"><a href="#L-3423"><span class="linenos">3423</span></a> <span class="k">pass</span> </span><span id="L-3424"><a href="#L-3424"><span class="linenos">3424</span></a> -</span><span id="L-3425"><a href="#L-3425"><span class="linenos">3425</span></a><span class="c1"># Commands to interact with the databases or engines. For most of the command</span> -</span><span id="L-3426"><a href="#L-3426"><span class="linenos">3426</span></a><span class="c1"># expressions we parse whatever comes after the command's name as a string.</span> -</span><span id="L-3427"><a href="#L-3427"><span class="linenos">3427</span></a><span class="k">class</span> <span class="nc">Command</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3428"><a href="#L-3428"><span class="linenos">3428</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-3425"><a href="#L-3425"><span class="linenos">3425</span></a> +</span><span id="L-3426"><a href="#L-3426"><span class="linenos">3426</span></a><span class="k">class</span> <span class="nc">Exists</span><span class="p">(</span><span class="n">SubqueryPredicate</span><span class="p">):</span> +</span><span id="L-3427"><a href="#L-3427"><span class="linenos">3427</span></a> <span class="k">pass</span> +</span><span id="L-3428"><a href="#L-3428"><span class="linenos">3428</span></a> </span><span id="L-3429"><a href="#L-3429"><span class="linenos">3429</span></a> -</span><span id="L-3430"><a href="#L-3430"><span class="linenos">3430</span></a> -</span><span id="L-3431"><a href="#L-3431"><span class="linenos">3431</span></a><span class="k">class</span> <span class="nc">Transaction</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3432"><a href="#L-3432"><span class="linenos">3432</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"modes"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3433"><a href="#L-3433"><span class="linenos">3433</span></a> +</span><span id="L-3430"><a href="#L-3430"><span class="linenos">3430</span></a><span class="c1"># Commands to interact with the databases or engines. For most of the command</span> +</span><span id="L-3431"><a href="#L-3431"><span class="linenos">3431</span></a><span class="c1"># expressions we parse whatever comes after the command's name as a string.</span> +</span><span id="L-3432"><a href="#L-3432"><span class="linenos">3432</span></a><span class="k">class</span> <span class="nc">Command</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3433"><a href="#L-3433"><span class="linenos">3433</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3434"><a href="#L-3434"><span class="linenos">3434</span></a> -</span><span id="L-3435"><a href="#L-3435"><span class="linenos">3435</span></a><span class="k">class</span> <span class="nc">Commit</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3436"><a href="#L-3436"><span class="linenos">3436</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"chain"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3437"><a href="#L-3437"><span class="linenos">3437</span></a> +</span><span id="L-3435"><a href="#L-3435"><span class="linenos">3435</span></a> +</span><span id="L-3436"><a href="#L-3436"><span class="linenos">3436</span></a><span class="k">class</span> <span class="nc">Transaction</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3437"><a href="#L-3437"><span class="linenos">3437</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"modes"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3438"><a href="#L-3438"><span class="linenos">3438</span></a> -</span><span id="L-3439"><a href="#L-3439"><span class="linenos">3439</span></a><span class="k">class</span> <span class="nc">Rollback</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3440"><a href="#L-3440"><span class="linenos">3440</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"savepoint"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3441"><a href="#L-3441"><span class="linenos">3441</span></a> +</span><span id="L-3439"><a href="#L-3439"><span class="linenos">3439</span></a> +</span><span id="L-3440"><a href="#L-3440"><span class="linenos">3440</span></a><span class="k">class</span> <span class="nc">Commit</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3441"><a href="#L-3441"><span class="linenos">3441</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"chain"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3442"><a href="#L-3442"><span class="linenos">3442</span></a> -</span><span id="L-3443"><a href="#L-3443"><span class="linenos">3443</span></a><span class="k">class</span> <span class="nc">AlterTable</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3444"><a href="#L-3444"><span class="linenos">3444</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"actions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"exists"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3445"><a href="#L-3445"><span class="linenos">3445</span></a> +</span><span id="L-3443"><a href="#L-3443"><span class="linenos">3443</span></a> +</span><span id="L-3444"><a href="#L-3444"><span class="linenos">3444</span></a><span class="k">class</span> <span class="nc">Rollback</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3445"><a href="#L-3445"><span class="linenos">3445</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"savepoint"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3446"><a href="#L-3446"><span class="linenos">3446</span></a> -</span><span id="L-3447"><a href="#L-3447"><span class="linenos">3447</span></a><span class="k">class</span> <span class="nc">AddConstraint</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3448"><a href="#L-3448"><span class="linenos">3448</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"enforced"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3449"><a href="#L-3449"><span class="linenos">3449</span></a> +</span><span id="L-3447"><a href="#L-3447"><span class="linenos">3447</span></a> +</span><span id="L-3448"><a href="#L-3448"><span class="linenos">3448</span></a><span class="k">class</span> <span class="nc">AlterTable</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3449"><a href="#L-3449"><span class="linenos">3449</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"actions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"exists"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3450"><a href="#L-3450"><span class="linenos">3450</span></a> -</span><span id="L-3451"><a href="#L-3451"><span class="linenos">3451</span></a><span class="k">class</span> <span class="nc">DropPartition</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3452"><a href="#L-3452"><span class="linenos">3452</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"exists"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3453"><a href="#L-3453"><span class="linenos">3453</span></a> +</span><span id="L-3451"><a href="#L-3451"><span class="linenos">3451</span></a> +</span><span id="L-3452"><a href="#L-3452"><span class="linenos">3452</span></a><span class="k">class</span> <span class="nc">AddConstraint</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3453"><a href="#L-3453"><span class="linenos">3453</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"enforced"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3454"><a href="#L-3454"><span class="linenos">3454</span></a> -</span><span id="L-3455"><a href="#L-3455"><span class="linenos">3455</span></a><span class="c1"># Binary expressions like (ADD a b)</span> -</span><span id="L-3456"><a href="#L-3456"><span class="linenos">3456</span></a><span class="k">class</span> <span class="nc">Binary</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> -</span><span id="L-3457"><a href="#L-3457"><span class="linenos">3457</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-3455"><a href="#L-3455"><span class="linenos">3455</span></a> +</span><span id="L-3456"><a href="#L-3456"><span class="linenos">3456</span></a><span class="k">class</span> <span class="nc">DropPartition</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3457"><a href="#L-3457"><span class="linenos">3457</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"exists"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3458"><a href="#L-3458"><span class="linenos">3458</span></a> -</span><span id="L-3459"><a href="#L-3459"><span class="linenos">3459</span></a> <span class="nd">@property</span> -</span><span id="L-3460"><a href="#L-3460"><span class="linenos">3460</span></a> <span class="k">def</span> <span class="nf">left</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="L-3461"><a href="#L-3461"><span class="linenos">3461</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-3462"><a href="#L-3462"><span class="linenos">3462</span></a> -</span><span id="L-3463"><a href="#L-3463"><span class="linenos">3463</span></a> <span class="nd">@property</span> -</span><span id="L-3464"><a href="#L-3464"><span class="linenos">3464</span></a> <span class="k">def</span> <span class="nf">right</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="L-3465"><a href="#L-3465"><span class="linenos">3465</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span> -</span><span id="L-3466"><a href="#L-3466"><span class="linenos">3466</span></a> +</span><span id="L-3459"><a href="#L-3459"><span class="linenos">3459</span></a> +</span><span id="L-3460"><a href="#L-3460"><span class="linenos">3460</span></a><span class="c1"># Binary expressions like (ADD a b)</span> +</span><span id="L-3461"><a href="#L-3461"><span class="linenos">3461</span></a><span class="k">class</span> <span class="nc">Binary</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> +</span><span id="L-3462"><a href="#L-3462"><span class="linenos">3462</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-3463"><a href="#L-3463"><span class="linenos">3463</span></a> +</span><span id="L-3464"><a href="#L-3464"><span class="linenos">3464</span></a> <span class="nd">@property</span> +</span><span id="L-3465"><a href="#L-3465"><span class="linenos">3465</span></a> <span class="k">def</span> <span class="nf">left</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="L-3466"><a href="#L-3466"><span class="linenos">3466</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span> </span><span id="L-3467"><a href="#L-3467"><span class="linenos">3467</span></a> -</span><span id="L-3468"><a href="#L-3468"><span class="linenos">3468</span></a><span class="k">class</span> <span class="nc">Add</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3469"><a href="#L-3469"><span class="linenos">3469</span></a> <span class="k">pass</span> -</span><span id="L-3470"><a href="#L-3470"><span class="linenos">3470</span></a> +</span><span id="L-3468"><a href="#L-3468"><span class="linenos">3468</span></a> <span class="nd">@property</span> +</span><span id="L-3469"><a href="#L-3469"><span class="linenos">3469</span></a> <span class="k">def</span> <span class="nf">right</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="L-3470"><a href="#L-3470"><span class="linenos">3470</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span> </span><span id="L-3471"><a href="#L-3471"><span class="linenos">3471</span></a> -</span><span id="L-3472"><a href="#L-3472"><span class="linenos">3472</span></a><span class="k">class</span> <span class="nc">Connector</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3473"><a href="#L-3473"><span class="linenos">3473</span></a> <span class="k">pass</span> -</span><span id="L-3474"><a href="#L-3474"><span class="linenos">3474</span></a> +</span><span id="L-3472"><a href="#L-3472"><span class="linenos">3472</span></a> +</span><span id="L-3473"><a href="#L-3473"><span class="linenos">3473</span></a><span class="k">class</span> <span class="nc">Add</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3474"><a href="#L-3474"><span class="linenos">3474</span></a> <span class="k">pass</span> </span><span id="L-3475"><a href="#L-3475"><span class="linenos">3475</span></a> -</span><span id="L-3476"><a href="#L-3476"><span class="linenos">3476</span></a><span class="k">class</span> <span class="nc">And</span><span class="p">(</span><span class="n">Connector</span><span class="p">):</span> -</span><span id="L-3477"><a href="#L-3477"><span class="linenos">3477</span></a> <span class="k">pass</span> -</span><span id="L-3478"><a href="#L-3478"><span class="linenos">3478</span></a> +</span><span id="L-3476"><a href="#L-3476"><span class="linenos">3476</span></a> +</span><span id="L-3477"><a href="#L-3477"><span class="linenos">3477</span></a><span class="k">class</span> <span class="nc">Connector</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3478"><a href="#L-3478"><span class="linenos">3478</span></a> <span class="k">pass</span> </span><span id="L-3479"><a href="#L-3479"><span class="linenos">3479</span></a> -</span><span id="L-3480"><a href="#L-3480"><span class="linenos">3480</span></a><span class="k">class</span> <span class="nc">Or</span><span class="p">(</span><span class="n">Connector</span><span class="p">):</span> -</span><span id="L-3481"><a href="#L-3481"><span class="linenos">3481</span></a> <span class="k">pass</span> -</span><span id="L-3482"><a href="#L-3482"><span class="linenos">3482</span></a> +</span><span id="L-3480"><a href="#L-3480"><span class="linenos">3480</span></a> +</span><span id="L-3481"><a href="#L-3481"><span class="linenos">3481</span></a><span class="k">class</span> <span class="nc">And</span><span class="p">(</span><span class="n">Connector</span><span class="p">):</span> +</span><span id="L-3482"><a href="#L-3482"><span class="linenos">3482</span></a> <span class="k">pass</span> </span><span id="L-3483"><a href="#L-3483"><span class="linenos">3483</span></a> -</span><span id="L-3484"><a href="#L-3484"><span class="linenos">3484</span></a><span class="k">class</span> <span class="nc">BitwiseAnd</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3485"><a href="#L-3485"><span class="linenos">3485</span></a> <span class="k">pass</span> -</span><span id="L-3486"><a href="#L-3486"><span class="linenos">3486</span></a> +</span><span id="L-3484"><a href="#L-3484"><span class="linenos">3484</span></a> +</span><span id="L-3485"><a href="#L-3485"><span class="linenos">3485</span></a><span class="k">class</span> <span class="nc">Or</span><span class="p">(</span><span class="n">Connector</span><span class="p">):</span> +</span><span id="L-3486"><a href="#L-3486"><span class="linenos">3486</span></a> <span class="k">pass</span> </span><span id="L-3487"><a href="#L-3487"><span class="linenos">3487</span></a> -</span><span id="L-3488"><a href="#L-3488"><span class="linenos">3488</span></a><span class="k">class</span> <span class="nc">BitwiseLeftShift</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3489"><a href="#L-3489"><span class="linenos">3489</span></a> <span class="k">pass</span> -</span><span id="L-3490"><a href="#L-3490"><span class="linenos">3490</span></a> +</span><span id="L-3488"><a href="#L-3488"><span class="linenos">3488</span></a> +</span><span id="L-3489"><a href="#L-3489"><span class="linenos">3489</span></a><span class="k">class</span> <span class="nc">BitwiseAnd</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3490"><a href="#L-3490"><span class="linenos">3490</span></a> <span class="k">pass</span> </span><span id="L-3491"><a href="#L-3491"><span class="linenos">3491</span></a> -</span><span id="L-3492"><a href="#L-3492"><span class="linenos">3492</span></a><span class="k">class</span> <span class="nc">BitwiseOr</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3493"><a href="#L-3493"><span class="linenos">3493</span></a> <span class="k">pass</span> -</span><span id="L-3494"><a href="#L-3494"><span class="linenos">3494</span></a> +</span><span id="L-3492"><a href="#L-3492"><span class="linenos">3492</span></a> +</span><span id="L-3493"><a href="#L-3493"><span class="linenos">3493</span></a><span class="k">class</span> <span class="nc">BitwiseLeftShift</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3494"><a href="#L-3494"><span class="linenos">3494</span></a> <span class="k">pass</span> </span><span id="L-3495"><a href="#L-3495"><span class="linenos">3495</span></a> -</span><span id="L-3496"><a href="#L-3496"><span class="linenos">3496</span></a><span class="k">class</span> <span class="nc">BitwiseRightShift</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3497"><a href="#L-3497"><span class="linenos">3497</span></a> <span class="k">pass</span> -</span><span id="L-3498"><a href="#L-3498"><span class="linenos">3498</span></a> +</span><span id="L-3496"><a href="#L-3496"><span class="linenos">3496</span></a> +</span><span id="L-3497"><a href="#L-3497"><span class="linenos">3497</span></a><span class="k">class</span> <span class="nc">BitwiseOr</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3498"><a href="#L-3498"><span class="linenos">3498</span></a> <span class="k">pass</span> </span><span id="L-3499"><a href="#L-3499"><span class="linenos">3499</span></a> -</span><span id="L-3500"><a href="#L-3500"><span class="linenos">3500</span></a><span class="k">class</span> <span class="nc">BitwiseXor</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3501"><a href="#L-3501"><span class="linenos">3501</span></a> <span class="k">pass</span> -</span><span id="L-3502"><a href="#L-3502"><span class="linenos">3502</span></a> +</span><span id="L-3500"><a href="#L-3500"><span class="linenos">3500</span></a> +</span><span id="L-3501"><a href="#L-3501"><span class="linenos">3501</span></a><span class="k">class</span> <span class="nc">BitwiseRightShift</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3502"><a href="#L-3502"><span class="linenos">3502</span></a> <span class="k">pass</span> </span><span id="L-3503"><a href="#L-3503"><span class="linenos">3503</span></a> -</span><span id="L-3504"><a href="#L-3504"><span class="linenos">3504</span></a><span class="k">class</span> <span class="nc">Div</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3505"><a href="#L-3505"><span class="linenos">3505</span></a> <span class="k">pass</span> -</span><span id="L-3506"><a href="#L-3506"><span class="linenos">3506</span></a> +</span><span id="L-3504"><a href="#L-3504"><span class="linenos">3504</span></a> +</span><span id="L-3505"><a href="#L-3505"><span class="linenos">3505</span></a><span class="k">class</span> <span class="nc">BitwiseXor</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3506"><a href="#L-3506"><span class="linenos">3506</span></a> <span class="k">pass</span> </span><span id="L-3507"><a href="#L-3507"><span class="linenos">3507</span></a> -</span><span id="L-3508"><a href="#L-3508"><span class="linenos">3508</span></a><span class="k">class</span> <span class="nc">Overlaps</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3509"><a href="#L-3509"><span class="linenos">3509</span></a> <span class="k">pass</span> -</span><span id="L-3510"><a href="#L-3510"><span class="linenos">3510</span></a> +</span><span id="L-3508"><a href="#L-3508"><span class="linenos">3508</span></a> +</span><span id="L-3509"><a href="#L-3509"><span class="linenos">3509</span></a><span class="k">class</span> <span class="nc">Div</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3510"><a href="#L-3510"><span class="linenos">3510</span></a> <span class="k">pass</span> </span><span id="L-3511"><a href="#L-3511"><span class="linenos">3511</span></a> -</span><span id="L-3512"><a href="#L-3512"><span class="linenos">3512</span></a><span class="k">class</span> <span class="nc">Dot</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3513"><a href="#L-3513"><span class="linenos">3513</span></a> <span class="nd">@property</span> -</span><span id="L-3514"><a href="#L-3514"><span class="linenos">3514</span></a> <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-3515"><a href="#L-3515"><span class="linenos">3515</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-3512"><a href="#L-3512"><span class="linenos">3512</span></a> +</span><span id="L-3513"><a href="#L-3513"><span class="linenos">3513</span></a><span class="k">class</span> <span class="nc">Overlaps</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3514"><a href="#L-3514"><span class="linenos">3514</span></a> <span class="k">pass</span> +</span><span id="L-3515"><a href="#L-3515"><span class="linenos">3515</span></a> </span><span id="L-3516"><a href="#L-3516"><span class="linenos">3516</span></a> -</span><span id="L-3517"><a href="#L-3517"><span class="linenos">3517</span></a> <span class="nd">@property</span> -</span><span id="L-3518"><a href="#L-3518"><span class="linenos">3518</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-3519"><a href="#L-3519"><span class="linenos">3519</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> -</span><span id="L-3520"><a href="#L-3520"><span class="linenos">3520</span></a> -</span><span id="L-3521"><a href="#L-3521"><span class="linenos">3521</span></a> <span class="nd">@classmethod</span> -</span><span id="L-3522"><a href="#L-3522"><span class="linenos">3522</span></a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expressions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">Dot</span><span class="p">:</span> -</span><span id="L-3523"><a href="#L-3523"><span class="linenos">3523</span></a><span class="w"> </span><span class="sd">"""Build a Dot object with a sequence of expressions."""</span> -</span><span id="L-3524"><a href="#L-3524"><span class="linenos">3524</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o"><</span> <span class="mi">2</span><span class="p">:</span> -</span><span id="L-3525"><a href="#L-3525"><span class="linenos">3525</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Dot requires >= 2 expressions."</span><span class="p">)</span> -</span><span id="L-3526"><a href="#L-3526"><span class="linenos">3526</span></a> -</span><span id="L-3527"><a href="#L-3527"><span class="linenos">3527</span></a> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span> <span class="o">=</span> <span class="n">expressions</span> -</span><span id="L-3528"><a href="#L-3528"><span class="linenos">3528</span></a> <span class="n">dot</span> <span class="o">=</span> <span class="n">Dot</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">a</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">b</span><span class="p">)</span> -</span><span id="L-3529"><a href="#L-3529"><span class="linenos">3529</span></a> -</span><span id="L-3530"><a href="#L-3530"><span class="linenos">3530</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="L-3531"><a href="#L-3531"><span class="linenos">3531</span></a> <span class="n">dot</span> <span class="o">=</span> <span class="n">Dot</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">dot</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-3532"><a href="#L-3532"><span class="linenos">3532</span></a> -</span><span id="L-3533"><a href="#L-3533"><span class="linenos">3533</span></a> <span class="k">return</span> <span class="n">dot</span> +</span><span id="L-3517"><a href="#L-3517"><span class="linenos">3517</span></a><span class="k">class</span> <span class="nc">Dot</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3518"><a href="#L-3518"><span class="linenos">3518</span></a> <span class="nd">@property</span> +</span><span id="L-3519"><a href="#L-3519"><span class="linenos">3519</span></a> <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-3520"><a href="#L-3520"><span class="linenos">3520</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-3521"><a href="#L-3521"><span class="linenos">3521</span></a> +</span><span id="L-3522"><a href="#L-3522"><span class="linenos">3522</span></a> <span class="nd">@property</span> +</span><span id="L-3523"><a href="#L-3523"><span class="linenos">3523</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-3524"><a href="#L-3524"><span class="linenos">3524</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-3525"><a href="#L-3525"><span class="linenos">3525</span></a> +</span><span id="L-3526"><a href="#L-3526"><span class="linenos">3526</span></a> <span class="nd">@classmethod</span> +</span><span id="L-3527"><a href="#L-3527"><span class="linenos">3527</span></a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expressions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">Dot</span><span class="p">:</span> +</span><span id="L-3528"><a href="#L-3528"><span class="linenos">3528</span></a><span class="w"> </span><span class="sd">"""Build a Dot object with a sequence of expressions."""</span> +</span><span id="L-3529"><a href="#L-3529"><span class="linenos">3529</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o"><</span> <span class="mi">2</span><span class="p">:</span> +</span><span id="L-3530"><a href="#L-3530"><span class="linenos">3530</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Dot requires >= 2 expressions."</span><span class="p">)</span> +</span><span id="L-3531"><a href="#L-3531"><span class="linenos">3531</span></a> +</span><span id="L-3532"><a href="#L-3532"><span class="linenos">3532</span></a> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span> <span class="o">=</span> <span class="n">expressions</span> +</span><span id="L-3533"><a href="#L-3533"><span class="linenos">3533</span></a> <span class="n">dot</span> <span class="o">=</span> <span class="n">Dot</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">a</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">b</span><span class="p">)</span> </span><span id="L-3534"><a href="#L-3534"><span class="linenos">3534</span></a> -</span><span id="L-3535"><a href="#L-3535"><span class="linenos">3535</span></a> -</span><span id="L-3536"><a href="#L-3536"><span class="linenos">3536</span></a><span class="k">class</span> <span class="nc">DPipe</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3537"><a href="#L-3537"><span class="linenos">3537</span></a> <span class="k">pass</span> -</span><span id="L-3538"><a href="#L-3538"><span class="linenos">3538</span></a> +</span><span id="L-3535"><a href="#L-3535"><span class="linenos">3535</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="L-3536"><a href="#L-3536"><span class="linenos">3536</span></a> <span class="n">dot</span> <span class="o">=</span> <span class="n">Dot</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">dot</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-3537"><a href="#L-3537"><span class="linenos">3537</span></a> +</span><span id="L-3538"><a href="#L-3538"><span class="linenos">3538</span></a> <span class="k">return</span> <span class="n">dot</span> </span><span id="L-3539"><a href="#L-3539"><span class="linenos">3539</span></a> -</span><span id="L-3540"><a href="#L-3540"><span class="linenos">3540</span></a><span class="k">class</span> <span class="nc">SafeDPipe</span><span class="p">(</span><span class="n">DPipe</span><span class="p">):</span> -</span><span id="L-3541"><a href="#L-3541"><span class="linenos">3541</span></a> <span class="k">pass</span> -</span><span id="L-3542"><a href="#L-3542"><span class="linenos">3542</span></a> +</span><span id="L-3540"><a href="#L-3540"><span class="linenos">3540</span></a> +</span><span id="L-3541"><a href="#L-3541"><span class="linenos">3541</span></a><span class="k">class</span> <span class="nc">DPipe</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3542"><a href="#L-3542"><span class="linenos">3542</span></a> <span class="k">pass</span> </span><span id="L-3543"><a href="#L-3543"><span class="linenos">3543</span></a> -</span><span id="L-3544"><a href="#L-3544"><span class="linenos">3544</span></a><span class="k">class</span> <span class="nc">EQ</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="L-3545"><a href="#L-3545"><span class="linenos">3545</span></a> <span class="k">pass</span> -</span><span id="L-3546"><a href="#L-3546"><span class="linenos">3546</span></a> +</span><span id="L-3544"><a href="#L-3544"><span class="linenos">3544</span></a> +</span><span id="L-3545"><a href="#L-3545"><span class="linenos">3545</span></a><span class="k">class</span> <span class="nc">SafeDPipe</span><span class="p">(</span><span class="n">DPipe</span><span class="p">):</span> +</span><span id="L-3546"><a href="#L-3546"><span class="linenos">3546</span></a> <span class="k">pass</span> </span><span id="L-3547"><a href="#L-3547"><span class="linenos">3547</span></a> -</span><span id="L-3548"><a href="#L-3548"><span class="linenos">3548</span></a><span class="k">class</span> <span class="nc">NullSafeEQ</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="L-3549"><a href="#L-3549"><span class="linenos">3549</span></a> <span class="k">pass</span> -</span><span id="L-3550"><a href="#L-3550"><span class="linenos">3550</span></a> +</span><span id="L-3548"><a href="#L-3548"><span class="linenos">3548</span></a> +</span><span id="L-3549"><a href="#L-3549"><span class="linenos">3549</span></a><span class="k">class</span> <span class="nc">EQ</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="L-3550"><a href="#L-3550"><span class="linenos">3550</span></a> <span class="k">pass</span> </span><span id="L-3551"><a href="#L-3551"><span class="linenos">3551</span></a> -</span><span id="L-3552"><a href="#L-3552"><span class="linenos">3552</span></a><span class="k">class</span> <span class="nc">NullSafeNEQ</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="L-3553"><a href="#L-3553"><span class="linenos">3553</span></a> <span class="k">pass</span> -</span><span id="L-3554"><a href="#L-3554"><span class="linenos">3554</span></a> +</span><span id="L-3552"><a href="#L-3552"><span class="linenos">3552</span></a> +</span><span id="L-3553"><a href="#L-3553"><span class="linenos">3553</span></a><span class="k">class</span> <span class="nc">NullSafeEQ</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="L-3554"><a href="#L-3554"><span class="linenos">3554</span></a> <span class="k">pass</span> </span><span id="L-3555"><a href="#L-3555"><span class="linenos">3555</span></a> -</span><span id="L-3556"><a href="#L-3556"><span class="linenos">3556</span></a><span class="k">class</span> <span class="nc">Distance</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3557"><a href="#L-3557"><span class="linenos">3557</span></a> <span class="k">pass</span> -</span><span id="L-3558"><a href="#L-3558"><span class="linenos">3558</span></a> +</span><span id="L-3556"><a href="#L-3556"><span class="linenos">3556</span></a> +</span><span id="L-3557"><a href="#L-3557"><span class="linenos">3557</span></a><span class="k">class</span> <span class="nc">NullSafeNEQ</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="L-3558"><a href="#L-3558"><span class="linenos">3558</span></a> <span class="k">pass</span> </span><span id="L-3559"><a href="#L-3559"><span class="linenos">3559</span></a> -</span><span id="L-3560"><a href="#L-3560"><span class="linenos">3560</span></a><span class="k">class</span> <span class="nc">Escape</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3561"><a href="#L-3561"><span class="linenos">3561</span></a> <span class="k">pass</span> -</span><span id="L-3562"><a href="#L-3562"><span class="linenos">3562</span></a> +</span><span id="L-3560"><a href="#L-3560"><span class="linenos">3560</span></a> +</span><span id="L-3561"><a href="#L-3561"><span class="linenos">3561</span></a><span class="k">class</span> <span class="nc">Distance</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3562"><a href="#L-3562"><span class="linenos">3562</span></a> <span class="k">pass</span> </span><span id="L-3563"><a href="#L-3563"><span class="linenos">3563</span></a> -</span><span id="L-3564"><a href="#L-3564"><span class="linenos">3564</span></a><span class="k">class</span> <span class="nc">Glob</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="L-3565"><a href="#L-3565"><span class="linenos">3565</span></a> <span class="k">pass</span> -</span><span id="L-3566"><a href="#L-3566"><span class="linenos">3566</span></a> +</span><span id="L-3564"><a href="#L-3564"><span class="linenos">3564</span></a> +</span><span id="L-3565"><a href="#L-3565"><span class="linenos">3565</span></a><span class="k">class</span> <span class="nc">Escape</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3566"><a href="#L-3566"><span class="linenos">3566</span></a> <span class="k">pass</span> </span><span id="L-3567"><a href="#L-3567"><span class="linenos">3567</span></a> -</span><span id="L-3568"><a href="#L-3568"><span class="linenos">3568</span></a><span class="k">class</span> <span class="nc">GT</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="L-3569"><a href="#L-3569"><span class="linenos">3569</span></a> <span class="k">pass</span> -</span><span id="L-3570"><a href="#L-3570"><span class="linenos">3570</span></a> +</span><span id="L-3568"><a href="#L-3568"><span class="linenos">3568</span></a> +</span><span id="L-3569"><a href="#L-3569"><span class="linenos">3569</span></a><span class="k">class</span> <span class="nc">Glob</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="L-3570"><a href="#L-3570"><span class="linenos">3570</span></a> <span class="k">pass</span> </span><span id="L-3571"><a href="#L-3571"><span class="linenos">3571</span></a> -</span><span id="L-3572"><a href="#L-3572"><span class="linenos">3572</span></a><span class="k">class</span> <span class="nc">GTE</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="L-3573"><a href="#L-3573"><span class="linenos">3573</span></a> <span class="k">pass</span> -</span><span id="L-3574"><a href="#L-3574"><span class="linenos">3574</span></a> +</span><span id="L-3572"><a href="#L-3572"><span class="linenos">3572</span></a> +</span><span id="L-3573"><a href="#L-3573"><span class="linenos">3573</span></a><span class="k">class</span> <span class="nc">GT</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="L-3574"><a href="#L-3574"><span class="linenos">3574</span></a> <span class="k">pass</span> </span><span id="L-3575"><a href="#L-3575"><span class="linenos">3575</span></a> -</span><span id="L-3576"><a href="#L-3576"><span class="linenos">3576</span></a><span class="k">class</span> <span class="nc">ILike</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="L-3577"><a href="#L-3577"><span class="linenos">3577</span></a> <span class="k">pass</span> -</span><span id="L-3578"><a href="#L-3578"><span class="linenos">3578</span></a> +</span><span id="L-3576"><a href="#L-3576"><span class="linenos">3576</span></a> +</span><span id="L-3577"><a href="#L-3577"><span class="linenos">3577</span></a><span class="k">class</span> <span class="nc">GTE</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="L-3578"><a href="#L-3578"><span class="linenos">3578</span></a> <span class="k">pass</span> </span><span id="L-3579"><a href="#L-3579"><span class="linenos">3579</span></a> -</span><span id="L-3580"><a href="#L-3580"><span class="linenos">3580</span></a><span class="k">class</span> <span class="nc">ILikeAny</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="L-3581"><a href="#L-3581"><span class="linenos">3581</span></a> <span class="k">pass</span> -</span><span id="L-3582"><a href="#L-3582"><span class="linenos">3582</span></a> +</span><span id="L-3580"><a href="#L-3580"><span class="linenos">3580</span></a> +</span><span id="L-3581"><a href="#L-3581"><span class="linenos">3581</span></a><span class="k">class</span> <span class="nc">ILike</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="L-3582"><a href="#L-3582"><span class="linenos">3582</span></a> <span class="k">pass</span> </span><span id="L-3583"><a href="#L-3583"><span class="linenos">3583</span></a> -</span><span id="L-3584"><a href="#L-3584"><span class="linenos">3584</span></a><span class="k">class</span> <span class="nc">IntDiv</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3585"><a href="#L-3585"><span class="linenos">3585</span></a> <span class="k">pass</span> -</span><span id="L-3586"><a href="#L-3586"><span class="linenos">3586</span></a> +</span><span id="L-3584"><a href="#L-3584"><span class="linenos">3584</span></a> +</span><span id="L-3585"><a href="#L-3585"><span class="linenos">3585</span></a><span class="k">class</span> <span class="nc">ILikeAny</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="L-3586"><a href="#L-3586"><span class="linenos">3586</span></a> <span class="k">pass</span> </span><span id="L-3587"><a href="#L-3587"><span class="linenos">3587</span></a> -</span><span id="L-3588"><a href="#L-3588"><span class="linenos">3588</span></a><span class="k">class</span> <span class="nc">Is</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="L-3589"><a href="#L-3589"><span class="linenos">3589</span></a> <span class="k">pass</span> -</span><span id="L-3590"><a href="#L-3590"><span class="linenos">3590</span></a> +</span><span id="L-3588"><a href="#L-3588"><span class="linenos">3588</span></a> +</span><span id="L-3589"><a href="#L-3589"><span class="linenos">3589</span></a><span class="k">class</span> <span class="nc">IntDiv</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3590"><a href="#L-3590"><span class="linenos">3590</span></a> <span class="k">pass</span> </span><span id="L-3591"><a href="#L-3591"><span class="linenos">3591</span></a> -</span><span id="L-3592"><a href="#L-3592"><span class="linenos">3592</span></a><span class="k">class</span> <span class="nc">Kwarg</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3593"><a href="#L-3593"><span class="linenos">3593</span></a><span class="w"> </span><span class="sd">"""Kwarg in special functions like func(kwarg => y)."""</span> -</span><span id="L-3594"><a href="#L-3594"><span class="linenos">3594</span></a> +</span><span id="L-3592"><a href="#L-3592"><span class="linenos">3592</span></a> +</span><span id="L-3593"><a href="#L-3593"><span class="linenos">3593</span></a><span class="k">class</span> <span class="nc">Is</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="L-3594"><a href="#L-3594"><span class="linenos">3594</span></a> <span class="k">pass</span> </span><span id="L-3595"><a href="#L-3595"><span class="linenos">3595</span></a> -</span><span id="L-3596"><a href="#L-3596"><span class="linenos">3596</span></a><span class="k">class</span> <span class="nc">Like</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="L-3597"><a href="#L-3597"><span class="linenos">3597</span></a> <span class="k">pass</span> -</span><span id="L-3598"><a href="#L-3598"><span class="linenos">3598</span></a> +</span><span id="L-3596"><a href="#L-3596"><span class="linenos">3596</span></a> +</span><span id="L-3597"><a href="#L-3597"><span class="linenos">3597</span></a><span class="k">class</span> <span class="nc">Kwarg</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3598"><a href="#L-3598"><span class="linenos">3598</span></a><span class="w"> </span><span class="sd">"""Kwarg in special functions like func(kwarg => y)."""</span> </span><span id="L-3599"><a href="#L-3599"><span class="linenos">3599</span></a> -</span><span id="L-3600"><a href="#L-3600"><span class="linenos">3600</span></a><span class="k">class</span> <span class="nc">LikeAny</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="L-3601"><a href="#L-3601"><span class="linenos">3601</span></a> <span class="k">pass</span> -</span><span id="L-3602"><a href="#L-3602"><span class="linenos">3602</span></a> +</span><span id="L-3600"><a href="#L-3600"><span class="linenos">3600</span></a> +</span><span id="L-3601"><a href="#L-3601"><span class="linenos">3601</span></a><span class="k">class</span> <span class="nc">Like</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="L-3602"><a href="#L-3602"><span class="linenos">3602</span></a> <span class="k">pass</span> </span><span id="L-3603"><a href="#L-3603"><span class="linenos">3603</span></a> -</span><span id="L-3604"><a href="#L-3604"><span class="linenos">3604</span></a><span class="k">class</span> <span class="nc">LT</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="L-3605"><a href="#L-3605"><span class="linenos">3605</span></a> <span class="k">pass</span> -</span><span id="L-3606"><a href="#L-3606"><span class="linenos">3606</span></a> +</span><span id="L-3604"><a href="#L-3604"><span class="linenos">3604</span></a> +</span><span id="L-3605"><a href="#L-3605"><span class="linenos">3605</span></a><span class="k">class</span> <span class="nc">LikeAny</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="L-3606"><a href="#L-3606"><span class="linenos">3606</span></a> <span class="k">pass</span> </span><span id="L-3607"><a href="#L-3607"><span class="linenos">3607</span></a> -</span><span id="L-3608"><a href="#L-3608"><span class="linenos">3608</span></a><span class="k">class</span> <span class="nc">LTE</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="L-3609"><a href="#L-3609"><span class="linenos">3609</span></a> <span class="k">pass</span> -</span><span id="L-3610"><a href="#L-3610"><span class="linenos">3610</span></a> +</span><span id="L-3608"><a href="#L-3608"><span class="linenos">3608</span></a> +</span><span id="L-3609"><a href="#L-3609"><span class="linenos">3609</span></a><span class="k">class</span> <span class="nc">LT</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="L-3610"><a href="#L-3610"><span class="linenos">3610</span></a> <span class="k">pass</span> </span><span id="L-3611"><a href="#L-3611"><span class="linenos">3611</span></a> -</span><span id="L-3612"><a href="#L-3612"><span class="linenos">3612</span></a><span class="k">class</span> <span class="nc">Mod</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3613"><a href="#L-3613"><span class="linenos">3613</span></a> <span class="k">pass</span> -</span><span id="L-3614"><a href="#L-3614"><span class="linenos">3614</span></a> +</span><span id="L-3612"><a href="#L-3612"><span class="linenos">3612</span></a> +</span><span id="L-3613"><a href="#L-3613"><span class="linenos">3613</span></a><span class="k">class</span> <span class="nc">LTE</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="L-3614"><a href="#L-3614"><span class="linenos">3614</span></a> <span class="k">pass</span> </span><span id="L-3615"><a href="#L-3615"><span class="linenos">3615</span></a> -</span><span id="L-3616"><a href="#L-3616"><span class="linenos">3616</span></a><span class="k">class</span> <span class="nc">Mul</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3617"><a href="#L-3617"><span class="linenos">3617</span></a> <span class="k">pass</span> -</span><span id="L-3618"><a href="#L-3618"><span class="linenos">3618</span></a> +</span><span id="L-3616"><a href="#L-3616"><span class="linenos">3616</span></a> +</span><span id="L-3617"><a href="#L-3617"><span class="linenos">3617</span></a><span class="k">class</span> <span class="nc">Mod</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3618"><a href="#L-3618"><span class="linenos">3618</span></a> <span class="k">pass</span> </span><span id="L-3619"><a href="#L-3619"><span class="linenos">3619</span></a> -</span><span id="L-3620"><a href="#L-3620"><span class="linenos">3620</span></a><span class="k">class</span> <span class="nc">NEQ</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="L-3621"><a href="#L-3621"><span class="linenos">3621</span></a> <span class="k">pass</span> -</span><span id="L-3622"><a href="#L-3622"><span class="linenos">3622</span></a> +</span><span id="L-3620"><a href="#L-3620"><span class="linenos">3620</span></a> +</span><span id="L-3621"><a href="#L-3621"><span class="linenos">3621</span></a><span class="k">class</span> <span class="nc">Mul</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3622"><a href="#L-3622"><span class="linenos">3622</span></a> <span class="k">pass</span> </span><span id="L-3623"><a href="#L-3623"><span class="linenos">3623</span></a> -</span><span id="L-3624"><a href="#L-3624"><span class="linenos">3624</span></a><span class="k">class</span> <span class="nc">SimilarTo</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="L-3625"><a href="#L-3625"><span class="linenos">3625</span></a> <span class="k">pass</span> -</span><span id="L-3626"><a href="#L-3626"><span class="linenos">3626</span></a> +</span><span id="L-3624"><a href="#L-3624"><span class="linenos">3624</span></a> +</span><span id="L-3625"><a href="#L-3625"><span class="linenos">3625</span></a><span class="k">class</span> <span class="nc">NEQ</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="L-3626"><a href="#L-3626"><span class="linenos">3626</span></a> <span class="k">pass</span> </span><span id="L-3627"><a href="#L-3627"><span class="linenos">3627</span></a> -</span><span id="L-3628"><a href="#L-3628"><span class="linenos">3628</span></a><span class="k">class</span> <span class="nc">Slice</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3629"><a href="#L-3629"><span class="linenos">3629</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3630"><a href="#L-3630"><span class="linenos">3630</span></a> +</span><span id="L-3628"><a href="#L-3628"><span class="linenos">3628</span></a> +</span><span id="L-3629"><a href="#L-3629"><span class="linenos">3629</span></a><span class="k">class</span> <span class="nc">SimilarTo</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="L-3630"><a href="#L-3630"><span class="linenos">3630</span></a> <span class="k">pass</span> </span><span id="L-3631"><a href="#L-3631"><span class="linenos">3631</span></a> -</span><span id="L-3632"><a href="#L-3632"><span class="linenos">3632</span></a><span class="k">class</span> <span class="nc">Sub</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3633"><a href="#L-3633"><span class="linenos">3633</span></a> <span class="k">pass</span> -</span><span id="L-3634"><a href="#L-3634"><span class="linenos">3634</span></a> +</span><span id="L-3632"><a href="#L-3632"><span class="linenos">3632</span></a> +</span><span id="L-3633"><a href="#L-3633"><span class="linenos">3633</span></a><span class="k">class</span> <span class="nc">Slice</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3634"><a href="#L-3634"><span class="linenos">3634</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3635"><a href="#L-3635"><span class="linenos">3635</span></a> -</span><span id="L-3636"><a href="#L-3636"><span class="linenos">3636</span></a><span class="k">class</span> <span class="nc">ArrayOverlaps</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3637"><a href="#L-3637"><span class="linenos">3637</span></a> <span class="k">pass</span> -</span><span id="L-3638"><a href="#L-3638"><span class="linenos">3638</span></a> +</span><span id="L-3636"><a href="#L-3636"><span class="linenos">3636</span></a> +</span><span id="L-3637"><a href="#L-3637"><span class="linenos">3637</span></a><span class="k">class</span> <span class="nc">Sub</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3638"><a href="#L-3638"><span class="linenos">3638</span></a> <span class="k">pass</span> </span><span id="L-3639"><a href="#L-3639"><span class="linenos">3639</span></a> -</span><span id="L-3640"><a href="#L-3640"><span class="linenos">3640</span></a><span class="c1"># Unary Expressions</span> -</span><span id="L-3641"><a href="#L-3641"><span class="linenos">3641</span></a><span class="c1"># (NOT a)</span> -</span><span id="L-3642"><a href="#L-3642"><span class="linenos">3642</span></a><span class="k">class</span> <span class="nc">Unary</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> -</span><span id="L-3643"><a href="#L-3643"><span class="linenos">3643</span></a> <span class="k">pass</span> +</span><span id="L-3640"><a href="#L-3640"><span class="linenos">3640</span></a> +</span><span id="L-3641"><a href="#L-3641"><span class="linenos">3641</span></a><span class="k">class</span> <span class="nc">ArrayOverlaps</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3642"><a href="#L-3642"><span class="linenos">3642</span></a> <span class="k">pass</span> +</span><span id="L-3643"><a href="#L-3643"><span class="linenos">3643</span></a> </span><span id="L-3644"><a href="#L-3644"><span class="linenos">3644</span></a> -</span><span id="L-3645"><a href="#L-3645"><span class="linenos">3645</span></a> -</span><span id="L-3646"><a href="#L-3646"><span class="linenos">3646</span></a><span class="k">class</span> <span class="nc">BitwiseNot</span><span class="p">(</span><span class="n">Unary</span><span class="p">):</span> -</span><span id="L-3647"><a href="#L-3647"><span class="linenos">3647</span></a> <span class="k">pass</span> -</span><span id="L-3648"><a href="#L-3648"><span class="linenos">3648</span></a> +</span><span id="L-3645"><a href="#L-3645"><span class="linenos">3645</span></a><span class="c1"># Unary Expressions</span> +</span><span id="L-3646"><a href="#L-3646"><span class="linenos">3646</span></a><span class="c1"># (NOT a)</span> +</span><span id="L-3647"><a href="#L-3647"><span class="linenos">3647</span></a><span class="k">class</span> <span class="nc">Unary</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> +</span><span id="L-3648"><a href="#L-3648"><span class="linenos">3648</span></a> <span class="k">pass</span> </span><span id="L-3649"><a href="#L-3649"><span class="linenos">3649</span></a> -</span><span id="L-3650"><a href="#L-3650"><span class="linenos">3650</span></a><span class="k">class</span> <span class="nc">Not</span><span class="p">(</span><span class="n">Unary</span><span class="p">):</span> -</span><span id="L-3651"><a href="#L-3651"><span class="linenos">3651</span></a> <span class="k">pass</span> -</span><span id="L-3652"><a href="#L-3652"><span class="linenos">3652</span></a> +</span><span id="L-3650"><a href="#L-3650"><span class="linenos">3650</span></a> +</span><span id="L-3651"><a href="#L-3651"><span class="linenos">3651</span></a><span class="k">class</span> <span class="nc">BitwiseNot</span><span class="p">(</span><span class="n">Unary</span><span class="p">):</span> +</span><span id="L-3652"><a href="#L-3652"><span class="linenos">3652</span></a> <span class="k">pass</span> </span><span id="L-3653"><a href="#L-3653"><span class="linenos">3653</span></a> -</span><span id="L-3654"><a href="#L-3654"><span class="linenos">3654</span></a><span class="k">class</span> <span class="nc">Paren</span><span class="p">(</span><span class="n">Unary</span><span class="p">):</span> -</span><span id="L-3655"><a href="#L-3655"><span class="linenos">3655</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3656"><a href="#L-3656"><span class="linenos">3656</span></a> -</span><span id="L-3657"><a href="#L-3657"><span class="linenos">3657</span></a> <span class="nd">@property</span> -</span><span id="L-3658"><a href="#L-3658"><span class="linenos">3658</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-3659"><a href="#L-3659"><span class="linenos">3659</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> -</span><span id="L-3660"><a href="#L-3660"><span class="linenos">3660</span></a> +</span><span id="L-3654"><a href="#L-3654"><span class="linenos">3654</span></a> +</span><span id="L-3655"><a href="#L-3655"><span class="linenos">3655</span></a><span class="k">class</span> <span class="nc">Not</span><span class="p">(</span><span class="n">Unary</span><span class="p">):</span> +</span><span id="L-3656"><a href="#L-3656"><span class="linenos">3656</span></a> <span class="k">pass</span> +</span><span id="L-3657"><a href="#L-3657"><span class="linenos">3657</span></a> +</span><span id="L-3658"><a href="#L-3658"><span class="linenos">3658</span></a> +</span><span id="L-3659"><a href="#L-3659"><span class="linenos">3659</span></a><span class="k">class</span> <span class="nc">Paren</span><span class="p">(</span><span class="n">Unary</span><span class="p">):</span> +</span><span id="L-3660"><a href="#L-3660"><span class="linenos">3660</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3661"><a href="#L-3661"><span class="linenos">3661</span></a> -</span><span id="L-3662"><a href="#L-3662"><span class="linenos">3662</span></a><span class="k">class</span> <span class="nc">Neg</span><span class="p">(</span><span class="n">Unary</span><span class="p">):</span> -</span><span id="L-3663"><a href="#L-3663"><span class="linenos">3663</span></a> <span class="k">pass</span> -</span><span id="L-3664"><a href="#L-3664"><span class="linenos">3664</span></a> +</span><span id="L-3662"><a href="#L-3662"><span class="linenos">3662</span></a> <span class="nd">@property</span> +</span><span id="L-3663"><a href="#L-3663"><span class="linenos">3663</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-3664"><a href="#L-3664"><span class="linenos">3664</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> </span><span id="L-3665"><a href="#L-3665"><span class="linenos">3665</span></a> -</span><span id="L-3666"><a href="#L-3666"><span class="linenos">3666</span></a><span class="k">class</span> <span class="nc">Alias</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3667"><a href="#L-3667"><span class="linenos">3667</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3668"><a href="#L-3668"><span class="linenos">3668</span></a> -</span><span id="L-3669"><a href="#L-3669"><span class="linenos">3669</span></a> <span class="nd">@property</span> -</span><span id="L-3670"><a href="#L-3670"><span class="linenos">3670</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-3671"><a href="#L-3671"><span class="linenos">3671</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">alias</span> -</span><span id="L-3672"><a href="#L-3672"><span class="linenos">3672</span></a> +</span><span id="L-3666"><a href="#L-3666"><span class="linenos">3666</span></a> +</span><span id="L-3667"><a href="#L-3667"><span class="linenos">3667</span></a><span class="k">class</span> <span class="nc">Neg</span><span class="p">(</span><span class="n">Unary</span><span class="p">):</span> +</span><span id="L-3668"><a href="#L-3668"><span class="linenos">3668</span></a> <span class="k">pass</span> +</span><span id="L-3669"><a href="#L-3669"><span class="linenos">3669</span></a> +</span><span id="L-3670"><a href="#L-3670"><span class="linenos">3670</span></a> +</span><span id="L-3671"><a href="#L-3671"><span class="linenos">3671</span></a><span class="k">class</span> <span class="nc">Alias</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3672"><a href="#L-3672"><span class="linenos">3672</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3673"><a href="#L-3673"><span class="linenos">3673</span></a> -</span><span id="L-3674"><a href="#L-3674"><span class="linenos">3674</span></a><span class="k">class</span> <span class="nc">Aliases</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3675"><a href="#L-3675"><span class="linenos">3675</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-3676"><a href="#L-3676"><span class="linenos">3676</span></a> -</span><span id="L-3677"><a href="#L-3677"><span class="linenos">3677</span></a> <span class="nd">@property</span> -</span><span id="L-3678"><a href="#L-3678"><span class="linenos">3678</span></a> <span class="k">def</span> <span class="nf">aliases</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="L-3679"><a href="#L-3679"><span class="linenos">3679</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="L-3680"><a href="#L-3680"><span class="linenos">3680</span></a> +</span><span id="L-3674"><a href="#L-3674"><span class="linenos">3674</span></a> <span class="nd">@property</span> +</span><span id="L-3675"><a href="#L-3675"><span class="linenos">3675</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-3676"><a href="#L-3676"><span class="linenos">3676</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">alias</span> +</span><span id="L-3677"><a href="#L-3677"><span class="linenos">3677</span></a> +</span><span id="L-3678"><a href="#L-3678"><span class="linenos">3678</span></a> +</span><span id="L-3679"><a href="#L-3679"><span class="linenos">3679</span></a><span class="k">class</span> <span class="nc">Aliases</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3680"><a href="#L-3680"><span class="linenos">3680</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-3681"><a href="#L-3681"><span class="linenos">3681</span></a> -</span><span id="L-3682"><a href="#L-3682"><span class="linenos">3682</span></a><span class="k">class</span> <span class="nc">AtTimeZone</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3683"><a href="#L-3683"><span class="linenos">3683</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-3684"><a href="#L-3684"><span class="linenos">3684</span></a> +</span><span id="L-3682"><a href="#L-3682"><span class="linenos">3682</span></a> <span class="nd">@property</span> +</span><span id="L-3683"><a href="#L-3683"><span class="linenos">3683</span></a> <span class="k">def</span> <span class="nf">aliases</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="L-3684"><a href="#L-3684"><span class="linenos">3684</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span> </span><span id="L-3685"><a href="#L-3685"><span class="linenos">3685</span></a> -</span><span id="L-3686"><a href="#L-3686"><span class="linenos">3686</span></a><span class="k">class</span> <span class="nc">Between</span><span class="p">(</span><span class="n">Predicate</span><span class="p">):</span> -</span><span id="L-3687"><a href="#L-3687"><span class="linenos">3687</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"low"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"high"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-3688"><a href="#L-3688"><span class="linenos">3688</span></a> +</span><span id="L-3686"><a href="#L-3686"><span class="linenos">3686</span></a> +</span><span id="L-3687"><a href="#L-3687"><span class="linenos">3687</span></a><span class="k">class</span> <span class="nc">AtTimeZone</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3688"><a href="#L-3688"><span class="linenos">3688</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-3689"><a href="#L-3689"><span class="linenos">3689</span></a> -</span><span id="L-3690"><a href="#L-3690"><span class="linenos">3690</span></a><span class="k">class</span> <span class="nc">Bracket</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> -</span><span id="L-3691"><a href="#L-3691"><span class="linenos">3691</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-3692"><a href="#L-3692"><span class="linenos">3692</span></a> +</span><span id="L-3690"><a href="#L-3690"><span class="linenos">3690</span></a> +</span><span id="L-3691"><a href="#L-3691"><span class="linenos">3691</span></a><span class="k">class</span> <span class="nc">Between</span><span class="p">(</span><span class="n">Predicate</span><span class="p">):</span> +</span><span id="L-3692"><a href="#L-3692"><span class="linenos">3692</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"low"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"high"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-3693"><a href="#L-3693"><span class="linenos">3693</span></a> -</span><span id="L-3694"><a href="#L-3694"><span class="linenos">3694</span></a><span class="k">class</span> <span class="nc">Distinct</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3695"><a href="#L-3695"><span class="linenos">3695</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3696"><a href="#L-3696"><span class="linenos">3696</span></a> +</span><span id="L-3694"><a href="#L-3694"><span class="linenos">3694</span></a> +</span><span id="L-3695"><a href="#L-3695"><span class="linenos">3695</span></a><span class="k">class</span> <span class="nc">Bracket</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> +</span><span id="L-3696"><a href="#L-3696"><span class="linenos">3696</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-3697"><a href="#L-3697"><span class="linenos">3697</span></a> -</span><span id="L-3698"><a href="#L-3698"><span class="linenos">3698</span></a><span class="k">class</span> <span class="nc">In</span><span class="p">(</span><span class="n">Predicate</span><span class="p">):</span> -</span><span id="L-3699"><a href="#L-3699"><span class="linenos">3699</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-3700"><a href="#L-3700"><span class="linenos">3700</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-3701"><a href="#L-3701"><span class="linenos">3701</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3702"><a href="#L-3702"><span class="linenos">3702</span></a> <span class="s2">"query"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3703"><a href="#L-3703"><span class="linenos">3703</span></a> <span class="s2">"unnest"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3704"><a href="#L-3704"><span class="linenos">3704</span></a> <span class="s2">"field"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3705"><a href="#L-3705"><span class="linenos">3705</span></a> <span class="s2">"is_global"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3706"><a href="#L-3706"><span class="linenos">3706</span></a> <span class="p">}</span> -</span><span id="L-3707"><a href="#L-3707"><span class="linenos">3707</span></a> -</span><span id="L-3708"><a href="#L-3708"><span class="linenos">3708</span></a> -</span><span id="L-3709"><a href="#L-3709"><span class="linenos">3709</span></a><span class="k">class</span> <span class="nc">TimeUnit</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3710"><a href="#L-3710"><span class="linenos">3710</span></a><span class="w"> </span><span class="sd">"""Automatically converts unit arg into a var."""</span> -</span><span id="L-3711"><a href="#L-3711"><span class="linenos">3711</span></a> -</span><span id="L-3712"><a href="#L-3712"><span class="linenos">3712</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-3698"><a href="#L-3698"><span class="linenos">3698</span></a> +</span><span id="L-3699"><a href="#L-3699"><span class="linenos">3699</span></a><span class="k">class</span> <span class="nc">Distinct</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3700"><a href="#L-3700"><span class="linenos">3700</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-3701"><a href="#L-3701"><span class="linenos">3701</span></a> +</span><span id="L-3702"><a href="#L-3702"><span class="linenos">3702</span></a> +</span><span id="L-3703"><a href="#L-3703"><span class="linenos">3703</span></a><span class="k">class</span> <span class="nc">In</span><span class="p">(</span><span class="n">Predicate</span><span class="p">):</span> +</span><span id="L-3704"><a href="#L-3704"><span class="linenos">3704</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-3705"><a href="#L-3705"><span class="linenos">3705</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-3706"><a href="#L-3706"><span class="linenos">3706</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3707"><a href="#L-3707"><span class="linenos">3707</span></a> <span class="s2">"query"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3708"><a href="#L-3708"><span class="linenos">3708</span></a> <span class="s2">"unnest"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3709"><a href="#L-3709"><span class="linenos">3709</span></a> <span class="s2">"field"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3710"><a href="#L-3710"><span class="linenos">3710</span></a> <span class="s2">"is_global"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3711"><a href="#L-3711"><span class="linenos">3711</span></a> <span class="p">}</span> +</span><span id="L-3712"><a href="#L-3712"><span class="linenos">3712</span></a> </span><span id="L-3713"><a href="#L-3713"><span class="linenos">3713</span></a> -</span><span id="L-3714"><a href="#L-3714"><span class="linenos">3714</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">args</span><span class="p">):</span> -</span><span id="L-3715"><a href="#L-3715"><span class="linenos">3715</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> -</span><span id="L-3716"><a href="#L-3716"><span class="linenos">3716</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">unit</span><span class="p">,</span> <span class="p">(</span><span class="n">Column</span><span class="p">,</span> <span class="n">Literal</span><span class="p">)):</span> -</span><span id="L-3717"><a href="#L-3717"><span class="linenos">3717</span></a> <span class="n">args</span><span class="p">[</span><span class="s2">"unit"</span><span class="p">]</span> <span class="o">=</span> <span class="n">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">unit</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> -</span><span id="L-3718"><a href="#L-3718"><span class="linenos">3718</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">unit</span><span class="p">,</span> <span class="n">Week</span><span class="p">):</span> -</span><span id="L-3719"><a href="#L-3719"><span class="linenos">3719</span></a> <span class="n">unit</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">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">unit</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> -</span><span id="L-3720"><a href="#L-3720"><span class="linenos">3720</span></a> -</span><span id="L-3721"><a href="#L-3721"><span class="linenos">3721</span></a> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">**</span><span class="n">args</span><span class="p">)</span> -</span><span id="L-3722"><a href="#L-3722"><span class="linenos">3722</span></a> -</span><span id="L-3723"><a href="#L-3723"><span class="linenos">3723</span></a> -</span><span id="L-3724"><a href="#L-3724"><span class="linenos">3724</span></a><span class="k">class</span> <span class="nc">Interval</span><span class="p">(</span><span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="L-3725"><a href="#L-3725"><span class="linenos">3725</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3726"><a href="#L-3726"><span class="linenos">3726</span></a> -</span><span id="L-3727"><a href="#L-3727"><span class="linenos">3727</span></a> <span class="nd">@property</span> -</span><span id="L-3728"><a href="#L-3728"><span class="linenos">3728</span></a> <span class="k">def</span> <span class="nf">unit</span><span class="p">(</span><span class="bp">self</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">Var</span><span class="p">]:</span> -</span><span id="L-3729"><a href="#L-3729"><span class="linenos">3729</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> -</span><span id="L-3730"><a href="#L-3730"><span class="linenos">3730</span></a> +</span><span id="L-3714"><a href="#L-3714"><span class="linenos">3714</span></a><span class="k">class</span> <span class="nc">TimeUnit</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3715"><a href="#L-3715"><span class="linenos">3715</span></a><span class="w"> </span><span class="sd">"""Automatically converts unit arg into a var."""</span> +</span><span id="L-3716"><a href="#L-3716"><span class="linenos">3716</span></a> +</span><span id="L-3717"><a href="#L-3717"><span class="linenos">3717</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-3718"><a href="#L-3718"><span class="linenos">3718</span></a> +</span><span id="L-3719"><a href="#L-3719"><span class="linenos">3719</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">args</span><span class="p">):</span> +</span><span id="L-3720"><a href="#L-3720"><span class="linenos">3720</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> +</span><span id="L-3721"><a href="#L-3721"><span class="linenos">3721</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">unit</span><span class="p">,</span> <span class="p">(</span><span class="n">Column</span><span class="p">,</span> <span class="n">Literal</span><span class="p">)):</span> +</span><span id="L-3722"><a href="#L-3722"><span class="linenos">3722</span></a> <span class="n">args</span><span class="p">[</span><span class="s2">"unit"</span><span class="p">]</span> <span class="o">=</span> <span class="n">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">unit</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> +</span><span id="L-3723"><a href="#L-3723"><span class="linenos">3723</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">unit</span><span class="p">,</span> <span class="n">Week</span><span class="p">):</span> +</span><span id="L-3724"><a href="#L-3724"><span class="linenos">3724</span></a> <span class="n">unit</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">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">unit</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> +</span><span id="L-3725"><a href="#L-3725"><span class="linenos">3725</span></a> +</span><span id="L-3726"><a href="#L-3726"><span class="linenos">3726</span></a> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">**</span><span class="n">args</span><span class="p">)</span> +</span><span id="L-3727"><a href="#L-3727"><span class="linenos">3727</span></a> +</span><span id="L-3728"><a href="#L-3728"><span class="linenos">3728</span></a> +</span><span id="L-3729"><a href="#L-3729"><span class="linenos">3729</span></a><span class="k">class</span> <span class="nc">Interval</span><span class="p">(</span><span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="L-3730"><a href="#L-3730"><span class="linenos">3730</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3731"><a href="#L-3731"><span class="linenos">3731</span></a> -</span><span id="L-3732"><a href="#L-3732"><span class="linenos">3732</span></a><span class="k">class</span> <span class="nc">IgnoreNulls</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3733"><a href="#L-3733"><span class="linenos">3733</span></a> <span class="k">pass</span> -</span><span id="L-3734"><a href="#L-3734"><span class="linenos">3734</span></a> +</span><span id="L-3732"><a href="#L-3732"><span class="linenos">3732</span></a> <span class="nd">@property</span> +</span><span id="L-3733"><a href="#L-3733"><span class="linenos">3733</span></a> <span class="k">def</span> <span class="nf">unit</span><span class="p">(</span><span class="bp">self</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">Var</span><span class="p">]:</span> +</span><span id="L-3734"><a href="#L-3734"><span class="linenos">3734</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> </span><span id="L-3735"><a href="#L-3735"><span class="linenos">3735</span></a> -</span><span id="L-3736"><a href="#L-3736"><span class="linenos">3736</span></a><span class="k">class</span> <span class="nc">RespectNulls</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-3737"><a href="#L-3737"><span class="linenos">3737</span></a> <span class="k">pass</span> -</span><span id="L-3738"><a href="#L-3738"><span class="linenos">3738</span></a> +</span><span id="L-3736"><a href="#L-3736"><span class="linenos">3736</span></a> +</span><span id="L-3737"><a href="#L-3737"><span class="linenos">3737</span></a><span class="k">class</span> <span class="nc">IgnoreNulls</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3738"><a href="#L-3738"><span class="linenos">3738</span></a> <span class="k">pass</span> </span><span id="L-3739"><a href="#L-3739"><span class="linenos">3739</span></a> -</span><span id="L-3740"><a href="#L-3740"><span class="linenos">3740</span></a><span class="c1"># Functions</span> -</span><span id="L-3741"><a href="#L-3741"><span class="linenos">3741</span></a><span class="k">class</span> <span class="nc">Func</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> -</span><span id="L-3742"><a href="#L-3742"><span class="linenos">3742</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-3743"><a href="#L-3743"><span class="linenos">3743</span></a><span class="sd"> The base class for all function expressions.</span> +</span><span id="L-3740"><a href="#L-3740"><span class="linenos">3740</span></a> +</span><span id="L-3741"><a href="#L-3741"><span class="linenos">3741</span></a><span class="k">class</span> <span class="nc">RespectNulls</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-3742"><a href="#L-3742"><span class="linenos">3742</span></a> <span class="k">pass</span> +</span><span id="L-3743"><a href="#L-3743"><span class="linenos">3743</span></a> </span><span id="L-3744"><a href="#L-3744"><span class="linenos">3744</span></a> -</span><span id="L-3745"><a href="#L-3745"><span class="linenos">3745</span></a><span class="sd"> Attributes:</span> -</span><span id="L-3746"><a href="#L-3746"><span class="linenos">3746</span></a><span class="sd"> is_var_len_args (bool): if set to True the last argument defined in arg_types will be</span> -</span><span id="L-3747"><a href="#L-3747"><span class="linenos">3747</span></a><span class="sd"> treated as a variable length argument and the argument's value will be stored as a list.</span> -</span><span id="L-3748"><a href="#L-3748"><span class="linenos">3748</span></a><span class="sd"> _sql_names (list): determines the SQL name (1st item in the list) and aliases (subsequent items)</span> -</span><span id="L-3749"><a href="#L-3749"><span class="linenos">3749</span></a><span class="sd"> for this function expression. These values are used to map this node to a name during parsing</span> -</span><span id="L-3750"><a href="#L-3750"><span class="linenos">3750</span></a><span class="sd"> as well as to provide the function's name during SQL string generation. By default the SQL</span> -</span><span id="L-3751"><a href="#L-3751"><span class="linenos">3751</span></a><span class="sd"> name is set to the expression's class name transformed to snake case.</span> -</span><span id="L-3752"><a href="#L-3752"><span class="linenos">3752</span></a><span class="sd"> """</span> -</span><span id="L-3753"><a href="#L-3753"><span class="linenos">3753</span></a> -</span><span id="L-3754"><a href="#L-3754"><span class="linenos">3754</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-3755"><a href="#L-3755"><span class="linenos">3755</span></a> -</span><span id="L-3756"><a href="#L-3756"><span class="linenos">3756</span></a> <span class="nd">@classmethod</span> -</span><span id="L-3757"><a href="#L-3757"><span class="linenos">3757</span></a> <span class="k">def</span> <span class="nf">from_arg_list</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">args</span><span class="p">):</span> -</span><span id="L-3758"><a href="#L-3758"><span class="linenos">3758</span></a> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">is_var_len_args</span><span class="p">:</span> -</span><span id="L-3759"><a href="#L-3759"><span class="linenos">3759</span></a> <span class="n">all_arg_keys</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="bp">cls</span><span class="o">.</span><span class="n">arg_types</span><span class="p">)</span> -</span><span id="L-3760"><a href="#L-3760"><span class="linenos">3760</span></a> <span class="c1"># If this function supports variable length argument treat the last argument as such.</span> -</span><span id="L-3761"><a href="#L-3761"><span class="linenos">3761</span></a> <span class="n">non_var_len_arg_keys</span> <span class="o">=</span> <span class="n">all_arg_keys</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">is_var_len_args</span> <span class="k">else</span> <span class="n">all_arg_keys</span> -</span><span id="L-3762"><a href="#L-3762"><span class="linenos">3762</span></a> <span class="n">num_non_var</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">non_var_len_arg_keys</span><span class="p">)</span> -</span><span id="L-3763"><a href="#L-3763"><span class="linenos">3763</span></a> -</span><span id="L-3764"><a href="#L-3764"><span class="linenos">3764</span></a> <span class="n">args_dict</span> <span class="o">=</span> <span class="p">{</span><span class="n">arg_key</span><span class="p">:</span> <span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span><span class="p">,</span> <span class="n">arg_key</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="n">non_var_len_arg_keys</span><span class="p">)}</span> -</span><span id="L-3765"><a href="#L-3765"><span class="linenos">3765</span></a> <span class="n">args_dict</span><span class="p">[</span><span class="n">all_arg_keys</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="n">num_non_var</span><span class="p">:]</span> -</span><span id="L-3766"><a href="#L-3766"><span class="linenos">3766</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3767"><a href="#L-3767"><span class="linenos">3767</span></a> <span class="n">args_dict</span> <span class="o">=</span> <span class="p">{</span><span class="n">arg_key</span><span class="p">:</span> <span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span><span class="p">,</span> <span class="n">arg_key</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">arg_types</span><span class="p">)}</span> +</span><span id="L-3745"><a href="#L-3745"><span class="linenos">3745</span></a><span class="c1"># Functions</span> +</span><span id="L-3746"><a href="#L-3746"><span class="linenos">3746</span></a><span class="k">class</span> <span class="nc">Func</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> +</span><span id="L-3747"><a href="#L-3747"><span class="linenos">3747</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-3748"><a href="#L-3748"><span class="linenos">3748</span></a><span class="sd"> The base class for all function expressions.</span> +</span><span id="L-3749"><a href="#L-3749"><span class="linenos">3749</span></a> +</span><span id="L-3750"><a href="#L-3750"><span class="linenos">3750</span></a><span class="sd"> Attributes:</span> +</span><span id="L-3751"><a href="#L-3751"><span class="linenos">3751</span></a><span class="sd"> is_var_len_args (bool): if set to True the last argument defined in arg_types will be</span> +</span><span id="L-3752"><a href="#L-3752"><span class="linenos">3752</span></a><span class="sd"> treated as a variable length argument and the argument's value will be stored as a list.</span> +</span><span id="L-3753"><a href="#L-3753"><span class="linenos">3753</span></a><span class="sd"> _sql_names (list): determines the SQL name (1st item in the list) and aliases (subsequent items)</span> +</span><span id="L-3754"><a href="#L-3754"><span class="linenos">3754</span></a><span class="sd"> for this function expression. These values are used to map this node to a name during parsing</span> +</span><span id="L-3755"><a href="#L-3755"><span class="linenos">3755</span></a><span class="sd"> as well as to provide the function's name during SQL string generation. By default the SQL</span> +</span><span id="L-3756"><a href="#L-3756"><span class="linenos">3756</span></a><span class="sd"> name is set to the expression's class name transformed to snake case.</span> +</span><span id="L-3757"><a href="#L-3757"><span class="linenos">3757</span></a><span class="sd"> """</span> +</span><span id="L-3758"><a href="#L-3758"><span class="linenos">3758</span></a> +</span><span id="L-3759"><a href="#L-3759"><span class="linenos">3759</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-3760"><a href="#L-3760"><span class="linenos">3760</span></a> +</span><span id="L-3761"><a href="#L-3761"><span class="linenos">3761</span></a> <span class="nd">@classmethod</span> +</span><span id="L-3762"><a href="#L-3762"><span class="linenos">3762</span></a> <span class="k">def</span> <span class="nf">from_arg_list</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">args</span><span class="p">):</span> +</span><span id="L-3763"><a href="#L-3763"><span class="linenos">3763</span></a> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">is_var_len_args</span><span class="p">:</span> +</span><span id="L-3764"><a href="#L-3764"><span class="linenos">3764</span></a> <span class="n">all_arg_keys</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="bp">cls</span><span class="o">.</span><span class="n">arg_types</span><span class="p">)</span> +</span><span id="L-3765"><a href="#L-3765"><span class="linenos">3765</span></a> <span class="c1"># If this function supports variable length argument treat the last argument as such.</span> +</span><span id="L-3766"><a href="#L-3766"><span class="linenos">3766</span></a> <span class="n">non_var_len_arg_keys</span> <span class="o">=</span> <span class="n">all_arg_keys</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">is_var_len_args</span> <span class="k">else</span> <span class="n">all_arg_keys</span> +</span><span id="L-3767"><a href="#L-3767"><span class="linenos">3767</span></a> <span class="n">num_non_var</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">non_var_len_arg_keys</span><span class="p">)</span> </span><span id="L-3768"><a href="#L-3768"><span class="linenos">3768</span></a> -</span><span id="L-3769"><a href="#L-3769"><span class="linenos">3769</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="o">**</span><span class="n">args_dict</span><span class="p">)</span> -</span><span id="L-3770"><a href="#L-3770"><span class="linenos">3770</span></a> -</span><span id="L-3771"><a href="#L-3771"><span class="linenos">3771</span></a> <span class="nd">@classmethod</span> -</span><span id="L-3772"><a href="#L-3772"><span class="linenos">3772</span></a> <span class="k">def</span> <span class="nf">sql_names</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span> -</span><span id="L-3773"><a href="#L-3773"><span class="linenos">3773</span></a> <span class="k">if</span> <span class="bp">cls</span> <span class="ow">is</span> <span class="n">Func</span><span class="p">:</span> -</span><span id="L-3774"><a href="#L-3774"><span class="linenos">3774</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span> -</span><span id="L-3775"><a href="#L-3775"><span class="linenos">3775</span></a> <span class="s2">"SQL name is only supported by concrete function implementations"</span> -</span><span id="L-3776"><a href="#L-3776"><span class="linenos">3776</span></a> <span class="p">)</span> -</span><span id="L-3777"><a href="#L-3777"><span class="linenos">3777</span></a> <span class="k">if</span> <span class="s2">"_sql_names"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">cls</span><span class="o">.</span><span class="vm">__dict__</span><span class="p">:</span> -</span><span id="L-3778"><a href="#L-3778"><span class="linenos">3778</span></a> <span class="bp">cls</span><span class="o">.</span><span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="n">camel_to_snake_case</span><span class="p">(</span><span class="bp">cls</span><span class="o">.</span><span class="vm">__name__</span><span class="p">)]</span> -</span><span id="L-3779"><a href="#L-3779"><span class="linenos">3779</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">_sql_names</span> -</span><span id="L-3780"><a href="#L-3780"><span class="linenos">3780</span></a> -</span><span id="L-3781"><a href="#L-3781"><span class="linenos">3781</span></a> <span class="nd">@classmethod</span> -</span><span id="L-3782"><a href="#L-3782"><span class="linenos">3782</span></a> <span class="k">def</span> <span class="nf">sql_name</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span> -</span><span id="L-3783"><a href="#L-3783"><span class="linenos">3783</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">sql_names</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="L-3784"><a href="#L-3784"><span class="linenos">3784</span></a> -</span><span id="L-3785"><a href="#L-3785"><span class="linenos">3785</span></a> <span class="nd">@classmethod</span> -</span><span id="L-3786"><a href="#L-3786"><span class="linenos">3786</span></a> <span class="k">def</span> <span class="nf">default_parser_mappings</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span> -</span><span id="L-3787"><a href="#L-3787"><span class="linenos">3787</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">name</span><span class="p">:</span> <span class="bp">cls</span><span class="o">.</span><span class="n">from_arg_list</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="bp">cls</span><span class="o">.</span><span class="n">sql_names</span><span class="p">()}</span> -</span><span id="L-3788"><a href="#L-3788"><span class="linenos">3788</span></a> +</span><span id="L-3769"><a href="#L-3769"><span class="linenos">3769</span></a> <span class="n">args_dict</span> <span class="o">=</span> <span class="p">{</span><span class="n">arg_key</span><span class="p">:</span> <span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span><span class="p">,</span> <span class="n">arg_key</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="n">non_var_len_arg_keys</span><span class="p">)}</span> +</span><span id="L-3770"><a href="#L-3770"><span class="linenos">3770</span></a> <span class="n">args_dict</span><span class="p">[</span><span class="n">all_arg_keys</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="n">num_non_var</span><span class="p">:]</span> +</span><span id="L-3771"><a href="#L-3771"><span class="linenos">3771</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3772"><a href="#L-3772"><span class="linenos">3772</span></a> <span class="n">args_dict</span> <span class="o">=</span> <span class="p">{</span><span class="n">arg_key</span><span class="p">:</span> <span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span><span class="p">,</span> <span class="n">arg_key</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">arg_types</span><span class="p">)}</span> +</span><span id="L-3773"><a href="#L-3773"><span class="linenos">3773</span></a> +</span><span id="L-3774"><a href="#L-3774"><span class="linenos">3774</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="o">**</span><span class="n">args_dict</span><span class="p">)</span> +</span><span id="L-3775"><a href="#L-3775"><span class="linenos">3775</span></a> +</span><span id="L-3776"><a href="#L-3776"><span class="linenos">3776</span></a> <span class="nd">@classmethod</span> +</span><span id="L-3777"><a href="#L-3777"><span class="linenos">3777</span></a> <span class="k">def</span> <span class="nf">sql_names</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span> +</span><span id="L-3778"><a href="#L-3778"><span class="linenos">3778</span></a> <span class="k">if</span> <span class="bp">cls</span> <span class="ow">is</span> <span class="n">Func</span><span class="p">:</span> +</span><span id="L-3779"><a href="#L-3779"><span class="linenos">3779</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span> +</span><span id="L-3780"><a href="#L-3780"><span class="linenos">3780</span></a> <span class="s2">"SQL name is only supported by concrete function implementations"</span> +</span><span id="L-3781"><a href="#L-3781"><span class="linenos">3781</span></a> <span class="p">)</span> +</span><span id="L-3782"><a href="#L-3782"><span class="linenos">3782</span></a> <span class="k">if</span> <span class="s2">"_sql_names"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">cls</span><span class="o">.</span><span class="vm">__dict__</span><span class="p">:</span> +</span><span id="L-3783"><a href="#L-3783"><span class="linenos">3783</span></a> <span class="bp">cls</span><span class="o">.</span><span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="n">camel_to_snake_case</span><span class="p">(</span><span class="bp">cls</span><span class="o">.</span><span class="vm">__name__</span><span class="p">)]</span> +</span><span id="L-3784"><a href="#L-3784"><span class="linenos">3784</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">_sql_names</span> +</span><span id="L-3785"><a href="#L-3785"><span class="linenos">3785</span></a> +</span><span id="L-3786"><a href="#L-3786"><span class="linenos">3786</span></a> <span class="nd">@classmethod</span> +</span><span id="L-3787"><a href="#L-3787"><span class="linenos">3787</span></a> <span class="k">def</span> <span class="nf">sql_name</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span> +</span><span id="L-3788"><a href="#L-3788"><span class="linenos">3788</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">sql_names</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> </span><span id="L-3789"><a href="#L-3789"><span class="linenos">3789</span></a> -</span><span id="L-3790"><a href="#L-3790"><span class="linenos">3790</span></a><span class="k">class</span> <span class="nc">AggFunc</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3791"><a href="#L-3791"><span class="linenos">3791</span></a> <span class="k">pass</span> -</span><span id="L-3792"><a href="#L-3792"><span class="linenos">3792</span></a> +</span><span id="L-3790"><a href="#L-3790"><span class="linenos">3790</span></a> <span class="nd">@classmethod</span> +</span><span id="L-3791"><a href="#L-3791"><span class="linenos">3791</span></a> <span class="k">def</span> <span class="nf">default_parser_mappings</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span> +</span><span id="L-3792"><a href="#L-3792"><span class="linenos">3792</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">name</span><span class="p">:</span> <span class="bp">cls</span><span class="o">.</span><span class="n">from_arg_list</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="bp">cls</span><span class="o">.</span><span class="n">sql_names</span><span class="p">()}</span> </span><span id="L-3793"><a href="#L-3793"><span class="linenos">3793</span></a> -</span><span id="L-3794"><a href="#L-3794"><span class="linenos">3794</span></a><span class="k">class</span> <span class="nc">ParameterizedAgg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-3795"><a href="#L-3795"><span class="linenos">3795</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"params"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-3796"><a href="#L-3796"><span class="linenos">3796</span></a> +</span><span id="L-3794"><a href="#L-3794"><span class="linenos">3794</span></a> +</span><span id="L-3795"><a href="#L-3795"><span class="linenos">3795</span></a><span class="k">class</span> <span class="nc">AggFunc</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3796"><a href="#L-3796"><span class="linenos">3796</span></a> <span class="k">pass</span> </span><span id="L-3797"><a href="#L-3797"><span class="linenos">3797</span></a> -</span><span id="L-3798"><a href="#L-3798"><span class="linenos">3798</span></a><span class="k">class</span> <span class="nc">Abs</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3799"><a href="#L-3799"><span class="linenos">3799</span></a> <span class="k">pass</span> -</span><span id="L-3800"><a href="#L-3800"><span class="linenos">3800</span></a> +</span><span id="L-3798"><a href="#L-3798"><span class="linenos">3798</span></a> +</span><span id="L-3799"><a href="#L-3799"><span class="linenos">3799</span></a><span class="k">class</span> <span class="nc">ParameterizedAgg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-3800"><a href="#L-3800"><span class="linenos">3800</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"params"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-3801"><a href="#L-3801"><span class="linenos">3801</span></a> -</span><span id="L-3802"><a href="#L-3802"><span class="linenos">3802</span></a><span class="k">class</span> <span class="nc">Anonymous</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3803"><a href="#L-3803"><span class="linenos">3803</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3804"><a href="#L-3804"><span class="linenos">3804</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-3802"><a href="#L-3802"><span class="linenos">3802</span></a> +</span><span id="L-3803"><a href="#L-3803"><span class="linenos">3803</span></a><span class="k">class</span> <span class="nc">Abs</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3804"><a href="#L-3804"><span class="linenos">3804</span></a> <span class="k">pass</span> </span><span id="L-3805"><a href="#L-3805"><span class="linenos">3805</span></a> </span><span id="L-3806"><a href="#L-3806"><span class="linenos">3806</span></a> -</span><span id="L-3807"><a href="#L-3807"><span class="linenos">3807</span></a><span class="c1"># https://docs.snowflake.com/en/sql-reference/functions/hll</span> -</span><span id="L-3808"><a href="#L-3808"><span class="linenos">3808</span></a><span class="c1"># https://docs.aws.amazon.com/redshift/latest/dg/r_HLL_function.html</span> -</span><span id="L-3809"><a href="#L-3809"><span class="linenos">3809</span></a><span class="k">class</span> <span class="nc">Hll</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-3810"><a href="#L-3810"><span class="linenos">3810</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3811"><a href="#L-3811"><span class="linenos">3811</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-3812"><a href="#L-3812"><span class="linenos">3812</span></a> -</span><span id="L-3813"><a href="#L-3813"><span class="linenos">3813</span></a> -</span><span id="L-3814"><a href="#L-3814"><span class="linenos">3814</span></a><span class="k">class</span> <span class="nc">ApproxDistinct</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-3815"><a href="#L-3815"><span class="linenos">3815</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"accuracy"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3816"><a href="#L-3816"><span class="linenos">3816</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"APPROX_DISTINCT"</span><span class="p">,</span> <span class="s2">"APPROX_COUNT_DISTINCT"</span><span class="p">]</span> +</span><span id="L-3807"><a href="#L-3807"><span class="linenos">3807</span></a><span class="k">class</span> <span class="nc">Anonymous</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3808"><a href="#L-3808"><span class="linenos">3808</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-3809"><a href="#L-3809"><span class="linenos">3809</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-3810"><a href="#L-3810"><span class="linenos">3810</span></a> +</span><span id="L-3811"><a href="#L-3811"><span class="linenos">3811</span></a> +</span><span id="L-3812"><a href="#L-3812"><span class="linenos">3812</span></a><span class="c1"># https://docs.snowflake.com/en/sql-reference/functions/hll</span> +</span><span id="L-3813"><a href="#L-3813"><span class="linenos">3813</span></a><span class="c1"># https://docs.aws.amazon.com/redshift/latest/dg/r_HLL_function.html</span> +</span><span id="L-3814"><a href="#L-3814"><span class="linenos">3814</span></a><span class="k">class</span> <span class="nc">Hll</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-3815"><a href="#L-3815"><span class="linenos">3815</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-3816"><a href="#L-3816"><span class="linenos">3816</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="L-3817"><a href="#L-3817"><span class="linenos">3817</span></a> </span><span id="L-3818"><a href="#L-3818"><span class="linenos">3818</span></a> -</span><span id="L-3819"><a href="#L-3819"><span class="linenos">3819</span></a><span class="k">class</span> <span class="nc">Array</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3820"><a href="#L-3820"><span class="linenos">3820</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3821"><a href="#L-3821"><span class="linenos">3821</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-3819"><a href="#L-3819"><span class="linenos">3819</span></a><span class="k">class</span> <span class="nc">ApproxDistinct</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-3820"><a href="#L-3820"><span class="linenos">3820</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"accuracy"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-3821"><a href="#L-3821"><span class="linenos">3821</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"APPROX_DISTINCT"</span><span class="p">,</span> <span class="s2">"APPROX_COUNT_DISTINCT"</span><span class="p">]</span> </span><span id="L-3822"><a href="#L-3822"><span class="linenos">3822</span></a> </span><span id="L-3823"><a href="#L-3823"><span class="linenos">3823</span></a> -</span><span id="L-3824"><a href="#L-3824"><span class="linenos">3824</span></a><span class="c1"># https://docs.snowflake.com/en/sql-reference/functions/to_char</span> -</span><span id="L-3825"><a href="#L-3825"><span class="linenos">3825</span></a><span class="k">class</span> <span class="nc">ToChar</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3826"><a href="#L-3826"><span class="linenos">3826</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-3824"><a href="#L-3824"><span class="linenos">3824</span></a><span class="k">class</span> <span class="nc">Array</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3825"><a href="#L-3825"><span class="linenos">3825</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-3826"><a href="#L-3826"><span class="linenos">3826</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="L-3827"><a href="#L-3827"><span class="linenos">3827</span></a> </span><span id="L-3828"><a href="#L-3828"><span class="linenos">3828</span></a> -</span><span id="L-3829"><a href="#L-3829"><span class="linenos">3829</span></a><span class="k">class</span> <span class="nc">GenerateSeries</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3830"><a href="#L-3830"><span class="linenos">3830</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"start"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"end"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"step"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3831"><a href="#L-3831"><span class="linenos">3831</span></a> +</span><span id="L-3829"><a href="#L-3829"><span class="linenos">3829</span></a><span class="c1"># https://docs.snowflake.com/en/sql-reference/functions/to_char</span> +</span><span id="L-3830"><a href="#L-3830"><span class="linenos">3830</span></a><span class="k">class</span> <span class="nc">ToChar</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3831"><a href="#L-3831"><span class="linenos">3831</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3832"><a href="#L-3832"><span class="linenos">3832</span></a> -</span><span id="L-3833"><a href="#L-3833"><span class="linenos">3833</span></a><span class="k">class</span> <span class="nc">ArrayAgg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-3834"><a href="#L-3834"><span class="linenos">3834</span></a> <span class="k">pass</span> -</span><span id="L-3835"><a href="#L-3835"><span class="linenos">3835</span></a> +</span><span id="L-3833"><a href="#L-3833"><span class="linenos">3833</span></a> +</span><span id="L-3834"><a href="#L-3834"><span class="linenos">3834</span></a><span class="k">class</span> <span class="nc">GenerateSeries</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3835"><a href="#L-3835"><span class="linenos">3835</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"start"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"end"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"step"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3836"><a href="#L-3836"><span class="linenos">3836</span></a> -</span><span id="L-3837"><a href="#L-3837"><span class="linenos">3837</span></a><span class="k">class</span> <span class="nc">ArrayAll</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3838"><a href="#L-3838"><span class="linenos">3838</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-3839"><a href="#L-3839"><span class="linenos">3839</span></a> +</span><span id="L-3837"><a href="#L-3837"><span class="linenos">3837</span></a> +</span><span id="L-3838"><a href="#L-3838"><span class="linenos">3838</span></a><span class="k">class</span> <span class="nc">ArrayAgg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-3839"><a href="#L-3839"><span class="linenos">3839</span></a> <span class="k">pass</span> </span><span id="L-3840"><a href="#L-3840"><span class="linenos">3840</span></a> -</span><span id="L-3841"><a href="#L-3841"><span class="linenos">3841</span></a><span class="k">class</span> <span class="nc">ArrayAny</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3842"><a href="#L-3842"><span class="linenos">3842</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-3843"><a href="#L-3843"><span class="linenos">3843</span></a> +</span><span id="L-3841"><a href="#L-3841"><span class="linenos">3841</span></a> +</span><span id="L-3842"><a href="#L-3842"><span class="linenos">3842</span></a><span class="k">class</span> <span class="nc">ArrayAll</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3843"><a href="#L-3843"><span class="linenos">3843</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-3844"><a href="#L-3844"><span class="linenos">3844</span></a> -</span><span id="L-3845"><a href="#L-3845"><span class="linenos">3845</span></a><span class="k">class</span> <span class="nc">ArrayConcat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3846"><a href="#L-3846"><span class="linenos">3846</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3847"><a href="#L-3847"><span class="linenos">3847</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-3845"><a href="#L-3845"><span class="linenos">3845</span></a> +</span><span id="L-3846"><a href="#L-3846"><span class="linenos">3846</span></a><span class="k">class</span> <span class="nc">ArrayAny</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3847"><a href="#L-3847"><span class="linenos">3847</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-3848"><a href="#L-3848"><span class="linenos">3848</span></a> </span><span id="L-3849"><a href="#L-3849"><span class="linenos">3849</span></a> -</span><span id="L-3850"><a href="#L-3850"><span class="linenos">3850</span></a><span class="k">class</span> <span class="nc">ArrayContains</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Func</span><span class="p">):</span> -</span><span id="L-3851"><a href="#L-3851"><span class="linenos">3851</span></a> <span class="k">pass</span> -</span><span id="L-3852"><a href="#L-3852"><span class="linenos">3852</span></a> +</span><span id="L-3850"><a href="#L-3850"><span class="linenos">3850</span></a><span class="k">class</span> <span class="nc">ArrayConcat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3851"><a href="#L-3851"><span class="linenos">3851</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-3852"><a href="#L-3852"><span class="linenos">3852</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="L-3853"><a href="#L-3853"><span class="linenos">3853</span></a> -</span><span id="L-3854"><a href="#L-3854"><span class="linenos">3854</span></a><span class="k">class</span> <span class="nc">ArrayContained</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3855"><a href="#L-3855"><span class="linenos">3855</span></a> <span class="k">pass</span> -</span><span id="L-3856"><a href="#L-3856"><span class="linenos">3856</span></a> +</span><span id="L-3854"><a href="#L-3854"><span class="linenos">3854</span></a> +</span><span id="L-3855"><a href="#L-3855"><span class="linenos">3855</span></a><span class="k">class</span> <span class="nc">ArrayContains</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Func</span><span class="p">):</span> +</span><span id="L-3856"><a href="#L-3856"><span class="linenos">3856</span></a> <span class="k">pass</span> </span><span id="L-3857"><a href="#L-3857"><span class="linenos">3857</span></a> -</span><span id="L-3858"><a href="#L-3858"><span class="linenos">3858</span></a><span class="k">class</span> <span class="nc">ArrayFilter</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3859"><a href="#L-3859"><span class="linenos">3859</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-3860"><a href="#L-3860"><span class="linenos">3860</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"FILTER"</span><span class="p">,</span> <span class="s2">"ARRAY_FILTER"</span><span class="p">]</span> +</span><span id="L-3858"><a href="#L-3858"><span class="linenos">3858</span></a> +</span><span id="L-3859"><a href="#L-3859"><span class="linenos">3859</span></a><span class="k">class</span> <span class="nc">ArrayContained</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3860"><a href="#L-3860"><span class="linenos">3860</span></a> <span class="k">pass</span> </span><span id="L-3861"><a href="#L-3861"><span class="linenos">3861</span></a> </span><span id="L-3862"><a href="#L-3862"><span class="linenos">3862</span></a> -</span><span id="L-3863"><a href="#L-3863"><span class="linenos">3863</span></a><span class="k">class</span> <span class="nc">ArrayJoin</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3864"><a href="#L-3864"><span class="linenos">3864</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"null"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3865"><a href="#L-3865"><span class="linenos">3865</span></a> +</span><span id="L-3863"><a href="#L-3863"><span class="linenos">3863</span></a><span class="k">class</span> <span class="nc">ArrayFilter</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3864"><a href="#L-3864"><span class="linenos">3864</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-3865"><a href="#L-3865"><span class="linenos">3865</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"FILTER"</span><span class="p">,</span> <span class="s2">"ARRAY_FILTER"</span><span class="p">]</span> </span><span id="L-3866"><a href="#L-3866"><span class="linenos">3866</span></a> -</span><span id="L-3867"><a href="#L-3867"><span class="linenos">3867</span></a><span class="k">class</span> <span class="nc">ArraySize</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3868"><a href="#L-3868"><span class="linenos">3868</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3869"><a href="#L-3869"><span class="linenos">3869</span></a> +</span><span id="L-3867"><a href="#L-3867"><span class="linenos">3867</span></a> +</span><span id="L-3868"><a href="#L-3868"><span class="linenos">3868</span></a><span class="k">class</span> <span class="nc">ArrayJoin</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3869"><a href="#L-3869"><span class="linenos">3869</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"null"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3870"><a href="#L-3870"><span class="linenos">3870</span></a> -</span><span id="L-3871"><a href="#L-3871"><span class="linenos">3871</span></a><span class="k">class</span> <span class="nc">ArraySort</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3872"><a href="#L-3872"><span class="linenos">3872</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3873"><a href="#L-3873"><span class="linenos">3873</span></a> +</span><span id="L-3871"><a href="#L-3871"><span class="linenos">3871</span></a> +</span><span id="L-3872"><a href="#L-3872"><span class="linenos">3872</span></a><span class="k">class</span> <span class="nc">ArraySize</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3873"><a href="#L-3873"><span class="linenos">3873</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3874"><a href="#L-3874"><span class="linenos">3874</span></a> -</span><span id="L-3875"><a href="#L-3875"><span class="linenos">3875</span></a><span class="k">class</span> <span class="nc">ArraySum</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3876"><a href="#L-3876"><span class="linenos">3876</span></a> <span class="k">pass</span> -</span><span id="L-3877"><a href="#L-3877"><span class="linenos">3877</span></a> +</span><span id="L-3875"><a href="#L-3875"><span class="linenos">3875</span></a> +</span><span id="L-3876"><a href="#L-3876"><span class="linenos">3876</span></a><span class="k">class</span> <span class="nc">ArraySort</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3877"><a href="#L-3877"><span class="linenos">3877</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3878"><a href="#L-3878"><span class="linenos">3878</span></a> -</span><span id="L-3879"><a href="#L-3879"><span class="linenos">3879</span></a><span class="k">class</span> <span class="nc">ArrayUnionAgg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-3880"><a href="#L-3880"><span class="linenos">3880</span></a> <span class="k">pass</span> -</span><span id="L-3881"><a href="#L-3881"><span class="linenos">3881</span></a> +</span><span id="L-3879"><a href="#L-3879"><span class="linenos">3879</span></a> +</span><span id="L-3880"><a href="#L-3880"><span class="linenos">3880</span></a><span class="k">class</span> <span class="nc">ArraySum</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3881"><a href="#L-3881"><span class="linenos">3881</span></a> <span class="k">pass</span> </span><span id="L-3882"><a href="#L-3882"><span class="linenos">3882</span></a> -</span><span id="L-3883"><a href="#L-3883"><span class="linenos">3883</span></a><span class="k">class</span> <span class="nc">Avg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-3884"><a href="#L-3884"><span class="linenos">3884</span></a> <span class="k">pass</span> -</span><span id="L-3885"><a href="#L-3885"><span class="linenos">3885</span></a> +</span><span id="L-3883"><a href="#L-3883"><span class="linenos">3883</span></a> +</span><span id="L-3884"><a href="#L-3884"><span class="linenos">3884</span></a><span class="k">class</span> <span class="nc">ArrayUnionAgg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-3885"><a href="#L-3885"><span class="linenos">3885</span></a> <span class="k">pass</span> </span><span id="L-3886"><a href="#L-3886"><span class="linenos">3886</span></a> -</span><span id="L-3887"><a href="#L-3887"><span class="linenos">3887</span></a><span class="k">class</span> <span class="nc">AnyValue</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-3888"><a href="#L-3888"><span class="linenos">3888</span></a> <span class="k">pass</span> -</span><span id="L-3889"><a href="#L-3889"><span class="linenos">3889</span></a> +</span><span id="L-3887"><a href="#L-3887"><span class="linenos">3887</span></a> +</span><span id="L-3888"><a href="#L-3888"><span class="linenos">3888</span></a><span class="k">class</span> <span class="nc">Avg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-3889"><a href="#L-3889"><span class="linenos">3889</span></a> <span class="k">pass</span> </span><span id="L-3890"><a href="#L-3890"><span class="linenos">3890</span></a> -</span><span id="L-3891"><a href="#L-3891"><span class="linenos">3891</span></a><span class="k">class</span> <span class="nc">Case</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3892"><a href="#L-3892"><span class="linenos">3892</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"ifs"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3893"><a href="#L-3893"><span class="linenos">3893</span></a> -</span><span id="L-3894"><a href="#L-3894"><span class="linenos">3894</span></a> <span class="k">def</span> <span class="nf">when</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">condition</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">then</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Case</span><span class="p">:</span> -</span><span id="L-3895"><a href="#L-3895"><span class="linenos">3895</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="L-3896"><a href="#L-3896"><span class="linenos">3896</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="L-3897"><a href="#L-3897"><span class="linenos">3897</span></a> <span class="s2">"ifs"</span><span class="p">,</span> -</span><span id="L-3898"><a href="#L-3898"><span class="linenos">3898</span></a> <span class="n">If</span><span class="p">(</span> -</span><span id="L-3899"><a href="#L-3899"><span class="linenos">3899</span></a> <span class="n">this</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">condition</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> -</span><span id="L-3900"><a href="#L-3900"><span class="linenos">3900</span></a> <span class="n">true</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">then</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> -</span><span id="L-3901"><a href="#L-3901"><span class="linenos">3901</span></a> <span class="p">),</span> -</span><span id="L-3902"><a href="#L-3902"><span class="linenos">3902</span></a> <span class="p">)</span> -</span><span id="L-3903"><a href="#L-3903"><span class="linenos">3903</span></a> <span class="k">return</span> <span class="n">instance</span> -</span><span id="L-3904"><a href="#L-3904"><span class="linenos">3904</span></a> -</span><span id="L-3905"><a href="#L-3905"><span class="linenos">3905</span></a> <span class="k">def</span> <span class="nf">else_</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">condition</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Case</span><span class="p">:</span> -</span><span id="L-3906"><a href="#L-3906"><span class="linenos">3906</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="L-3907"><a href="#L-3907"><span class="linenos">3907</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"default"</span><span class="p">,</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">condition</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">))</span> +</span><span id="L-3891"><a href="#L-3891"><span class="linenos">3891</span></a> +</span><span id="L-3892"><a href="#L-3892"><span class="linenos">3892</span></a><span class="k">class</span> <span class="nc">AnyValue</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-3893"><a href="#L-3893"><span class="linenos">3893</span></a> <span class="k">pass</span> +</span><span id="L-3894"><a href="#L-3894"><span class="linenos">3894</span></a> +</span><span id="L-3895"><a href="#L-3895"><span class="linenos">3895</span></a> +</span><span id="L-3896"><a href="#L-3896"><span class="linenos">3896</span></a><span class="k">class</span> <span class="nc">Case</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3897"><a href="#L-3897"><span class="linenos">3897</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"ifs"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-3898"><a href="#L-3898"><span class="linenos">3898</span></a> +</span><span id="L-3899"><a href="#L-3899"><span class="linenos">3899</span></a> <span class="k">def</span> <span class="nf">when</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">condition</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">then</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Case</span><span class="p">:</span> +</span><span id="L-3900"><a href="#L-3900"><span class="linenos">3900</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="L-3901"><a href="#L-3901"><span class="linenos">3901</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="L-3902"><a href="#L-3902"><span class="linenos">3902</span></a> <span class="s2">"ifs"</span><span class="p">,</span> +</span><span id="L-3903"><a href="#L-3903"><span class="linenos">3903</span></a> <span class="n">If</span><span class="p">(</span> +</span><span id="L-3904"><a href="#L-3904"><span class="linenos">3904</span></a> <span class="n">this</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">condition</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> +</span><span id="L-3905"><a href="#L-3905"><span class="linenos">3905</span></a> <span class="n">true</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">then</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> +</span><span id="L-3906"><a href="#L-3906"><span class="linenos">3906</span></a> <span class="p">),</span> +</span><span id="L-3907"><a href="#L-3907"><span class="linenos">3907</span></a> <span class="p">)</span> </span><span id="L-3908"><a href="#L-3908"><span class="linenos">3908</span></a> <span class="k">return</span> <span class="n">instance</span> </span><span id="L-3909"><a href="#L-3909"><span class="linenos">3909</span></a> -</span><span id="L-3910"><a href="#L-3910"><span class="linenos">3910</span></a> -</span><span id="L-3911"><a href="#L-3911"><span class="linenos">3911</span></a><span class="k">class</span> <span class="nc">Cast</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3912"><a href="#L-3912"><span class="linenos">3912</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"to"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-3913"><a href="#L-3913"><span class="linenos">3913</span></a> -</span><span id="L-3914"><a href="#L-3914"><span class="linenos">3914</span></a> <span class="nd">@property</span> -</span><span id="L-3915"><a href="#L-3915"><span class="linenos">3915</span></a> <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-3916"><a href="#L-3916"><span class="linenos">3916</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> -</span><span id="L-3917"><a href="#L-3917"><span class="linenos">3917</span></a> -</span><span id="L-3918"><a href="#L-3918"><span class="linenos">3918</span></a> <span class="nd">@property</span> -</span><span id="L-3919"><a href="#L-3919"><span class="linenos">3919</span></a> <span class="k">def</span> <span class="nf">to</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataType</span><span class="p">:</span> -</span><span id="L-3920"><a href="#L-3920"><span class="linenos">3920</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"to"</span><span class="p">]</span> -</span><span id="L-3921"><a href="#L-3921"><span class="linenos">3921</span></a> -</span><span id="L-3922"><a href="#L-3922"><span class="linenos">3922</span></a> <span class="nd">@property</span> -</span><span id="L-3923"><a href="#L-3923"><span class="linenos">3923</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-3924"><a href="#L-3924"><span class="linenos">3924</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> -</span><span id="L-3925"><a href="#L-3925"><span class="linenos">3925</span></a> -</span><span id="L-3926"><a href="#L-3926"><span class="linenos">3926</span></a> <span class="k">def</span> <span class="nf">is_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">dtypes</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="L-3927"><a href="#L-3927"><span class="linenos">3927</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="o">*</span><span class="n">dtypes</span><span class="p">)</span> -</span><span id="L-3928"><a href="#L-3928"><span class="linenos">3928</span></a> -</span><span id="L-3929"><a href="#L-3929"><span class="linenos">3929</span></a> -</span><span id="L-3930"><a href="#L-3930"><span class="linenos">3930</span></a><span class="k">class</span> <span class="nc">CastToStrType</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3931"><a href="#L-3931"><span class="linenos">3931</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-3932"><a href="#L-3932"><span class="linenos">3932</span></a> +</span><span id="L-3910"><a href="#L-3910"><span class="linenos">3910</span></a> <span class="k">def</span> <span class="nf">else_</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">condition</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Case</span><span class="p">:</span> +</span><span id="L-3911"><a href="#L-3911"><span class="linenos">3911</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="L-3912"><a href="#L-3912"><span class="linenos">3912</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"default"</span><span class="p">,</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">condition</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">))</span> +</span><span id="L-3913"><a href="#L-3913"><span class="linenos">3913</span></a> <span class="k">return</span> <span class="n">instance</span> +</span><span id="L-3914"><a href="#L-3914"><span class="linenos">3914</span></a> +</span><span id="L-3915"><a href="#L-3915"><span class="linenos">3915</span></a> +</span><span id="L-3916"><a href="#L-3916"><span class="linenos">3916</span></a><span class="k">class</span> <span class="nc">Cast</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3917"><a href="#L-3917"><span class="linenos">3917</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"to"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-3918"><a href="#L-3918"><span class="linenos">3918</span></a> +</span><span id="L-3919"><a href="#L-3919"><span class="linenos">3919</span></a> <span class="nd">@property</span> +</span><span id="L-3920"><a href="#L-3920"><span class="linenos">3920</span></a> <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-3921"><a href="#L-3921"><span class="linenos">3921</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-3922"><a href="#L-3922"><span class="linenos">3922</span></a> +</span><span id="L-3923"><a href="#L-3923"><span class="linenos">3923</span></a> <span class="nd">@property</span> +</span><span id="L-3924"><a href="#L-3924"><span class="linenos">3924</span></a> <span class="k">def</span> <span class="nf">to</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataType</span><span class="p">:</span> +</span><span id="L-3925"><a href="#L-3925"><span class="linenos">3925</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"to"</span><span class="p">]</span> +</span><span id="L-3926"><a href="#L-3926"><span class="linenos">3926</span></a> +</span><span id="L-3927"><a href="#L-3927"><span class="linenos">3927</span></a> <span class="nd">@property</span> +</span><span id="L-3928"><a href="#L-3928"><span class="linenos">3928</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-3929"><a href="#L-3929"><span class="linenos">3929</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-3930"><a href="#L-3930"><span class="linenos">3930</span></a> +</span><span id="L-3931"><a href="#L-3931"><span class="linenos">3931</span></a> <span class="k">def</span> <span class="nf">is_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">dtypes</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="L-3932"><a href="#L-3932"><span class="linenos">3932</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="o">*</span><span class="n">dtypes</span><span class="p">)</span> </span><span id="L-3933"><a href="#L-3933"><span class="linenos">3933</span></a> -</span><span id="L-3934"><a href="#L-3934"><span class="linenos">3934</span></a><span class="k">class</span> <span class="nc">Collate</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-3935"><a href="#L-3935"><span class="linenos">3935</span></a> <span class="k">pass</span> -</span><span id="L-3936"><a href="#L-3936"><span class="linenos">3936</span></a> +</span><span id="L-3934"><a href="#L-3934"><span class="linenos">3934</span></a> +</span><span id="L-3935"><a href="#L-3935"><span class="linenos">3935</span></a><span class="k">class</span> <span class="nc">CastToStrType</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3936"><a href="#L-3936"><span class="linenos">3936</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-3937"><a href="#L-3937"><span class="linenos">3937</span></a> -</span><span id="L-3938"><a href="#L-3938"><span class="linenos">3938</span></a><span class="k">class</span> <span class="nc">TryCast</span><span class="p">(</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="L-3939"><a href="#L-3939"><span class="linenos">3939</span></a> <span class="k">pass</span> -</span><span id="L-3940"><a href="#L-3940"><span class="linenos">3940</span></a> +</span><span id="L-3938"><a href="#L-3938"><span class="linenos">3938</span></a> +</span><span id="L-3939"><a href="#L-3939"><span class="linenos">3939</span></a><span class="k">class</span> <span class="nc">Collate</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-3940"><a href="#L-3940"><span class="linenos">3940</span></a> <span class="k">pass</span> </span><span id="L-3941"><a href="#L-3941"><span class="linenos">3941</span></a> -</span><span id="L-3942"><a href="#L-3942"><span class="linenos">3942</span></a><span class="k">class</span> <span class="nc">Ceil</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3943"><a href="#L-3943"><span class="linenos">3943</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"decimals"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3944"><a href="#L-3944"><span class="linenos">3944</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"CEIL"</span><span class="p">,</span> <span class="s2">"CEILING"</span><span class="p">]</span> +</span><span id="L-3942"><a href="#L-3942"><span class="linenos">3942</span></a> +</span><span id="L-3943"><a href="#L-3943"><span class="linenos">3943</span></a><span class="k">class</span> <span class="nc">TryCast</span><span class="p">(</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="L-3944"><a href="#L-3944"><span class="linenos">3944</span></a> <span class="k">pass</span> </span><span id="L-3945"><a href="#L-3945"><span class="linenos">3945</span></a> </span><span id="L-3946"><a href="#L-3946"><span class="linenos">3946</span></a> -</span><span id="L-3947"><a href="#L-3947"><span class="linenos">3947</span></a><span class="k">class</span> <span class="nc">Coalesce</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3948"><a href="#L-3948"><span class="linenos">3948</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3949"><a href="#L-3949"><span class="linenos">3949</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-3950"><a href="#L-3950"><span class="linenos">3950</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"COALESCE"</span><span class="p">,</span> <span class="s2">"IFNULL"</span><span class="p">,</span> <span class="s2">"NVL"</span><span class="p">]</span> +</span><span id="L-3947"><a href="#L-3947"><span class="linenos">3947</span></a><span class="k">class</span> <span class="nc">Ceil</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3948"><a href="#L-3948"><span class="linenos">3948</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"decimals"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-3949"><a href="#L-3949"><span class="linenos">3949</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"CEIL"</span><span class="p">,</span> <span class="s2">"CEILING"</span><span class="p">]</span> +</span><span id="L-3950"><a href="#L-3950"><span class="linenos">3950</span></a> </span><span id="L-3951"><a href="#L-3951"><span class="linenos">3951</span></a> -</span><span id="L-3952"><a href="#L-3952"><span class="linenos">3952</span></a> -</span><span id="L-3953"><a href="#L-3953"><span class="linenos">3953</span></a><span class="k">class</span> <span class="nc">Concat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3954"><a href="#L-3954"><span class="linenos">3954</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-3955"><a href="#L-3955"><span class="linenos">3955</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-3952"><a href="#L-3952"><span class="linenos">3952</span></a><span class="k">class</span> <span class="nc">Coalesce</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3953"><a href="#L-3953"><span class="linenos">3953</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-3954"><a href="#L-3954"><span class="linenos">3954</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-3955"><a href="#L-3955"><span class="linenos">3955</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"COALESCE"</span><span class="p">,</span> <span class="s2">"IFNULL"</span><span class="p">,</span> <span class="s2">"NVL"</span><span class="p">]</span> </span><span id="L-3956"><a href="#L-3956"><span class="linenos">3956</span></a> </span><span id="L-3957"><a href="#L-3957"><span class="linenos">3957</span></a> -</span><span id="L-3958"><a href="#L-3958"><span class="linenos">3958</span></a><span class="k">class</span> <span class="nc">SafeConcat</span><span class="p">(</span><span class="n">Concat</span><span class="p">):</span> -</span><span id="L-3959"><a href="#L-3959"><span class="linenos">3959</span></a> <span class="k">pass</span> -</span><span id="L-3960"><a href="#L-3960"><span class="linenos">3960</span></a> +</span><span id="L-3958"><a href="#L-3958"><span class="linenos">3958</span></a><span class="k">class</span> <span class="nc">Concat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3959"><a href="#L-3959"><span class="linenos">3959</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-3960"><a href="#L-3960"><span class="linenos">3960</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="L-3961"><a href="#L-3961"><span class="linenos">3961</span></a> -</span><span id="L-3962"><a href="#L-3962"><span class="linenos">3962</span></a><span class="k">class</span> <span class="nc">ConcatWs</span><span class="p">(</span><span class="n">Concat</span><span class="p">):</span> -</span><span id="L-3963"><a href="#L-3963"><span class="linenos">3963</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"CONCAT_WS"</span><span class="p">]</span> -</span><span id="L-3964"><a href="#L-3964"><span class="linenos">3964</span></a> +</span><span id="L-3962"><a href="#L-3962"><span class="linenos">3962</span></a> +</span><span id="L-3963"><a href="#L-3963"><span class="linenos">3963</span></a><span class="k">class</span> <span class="nc">SafeConcat</span><span class="p">(</span><span class="n">Concat</span><span class="p">):</span> +</span><span id="L-3964"><a href="#L-3964"><span class="linenos">3964</span></a> <span class="k">pass</span> </span><span id="L-3965"><a href="#L-3965"><span class="linenos">3965</span></a> -</span><span id="L-3966"><a href="#L-3966"><span class="linenos">3966</span></a><span class="k">class</span> <span class="nc">Count</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-3967"><a href="#L-3967"><span class="linenos">3967</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3968"><a href="#L-3968"><span class="linenos">3968</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-3966"><a href="#L-3966"><span class="linenos">3966</span></a> +</span><span id="L-3967"><a href="#L-3967"><span class="linenos">3967</span></a><span class="k">class</span> <span class="nc">ConcatWs</span><span class="p">(</span><span class="n">Concat</span><span class="p">):</span> +</span><span id="L-3968"><a href="#L-3968"><span class="linenos">3968</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"CONCAT_WS"</span><span class="p">]</span> </span><span id="L-3969"><a href="#L-3969"><span class="linenos">3969</span></a> </span><span id="L-3970"><a href="#L-3970"><span class="linenos">3970</span></a> -</span><span id="L-3971"><a href="#L-3971"><span class="linenos">3971</span></a><span class="k">class</span> <span class="nc">CountIf</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-3972"><a href="#L-3972"><span class="linenos">3972</span></a> <span class="k">pass</span> -</span><span id="L-3973"><a href="#L-3973"><span class="linenos">3973</span></a> +</span><span id="L-3971"><a href="#L-3971"><span class="linenos">3971</span></a><span class="k">class</span> <span class="nc">Count</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-3972"><a href="#L-3972"><span class="linenos">3972</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-3973"><a href="#L-3973"><span class="linenos">3973</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="L-3974"><a href="#L-3974"><span class="linenos">3974</span></a> -</span><span id="L-3975"><a href="#L-3975"><span class="linenos">3975</span></a><span class="k">class</span> <span class="nc">CurrentDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3976"><a href="#L-3976"><span class="linenos">3976</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3977"><a href="#L-3977"><span class="linenos">3977</span></a> +</span><span id="L-3975"><a href="#L-3975"><span class="linenos">3975</span></a> +</span><span id="L-3976"><a href="#L-3976"><span class="linenos">3976</span></a><span class="k">class</span> <span class="nc">CountIf</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-3977"><a href="#L-3977"><span class="linenos">3977</span></a> <span class="k">pass</span> </span><span id="L-3978"><a href="#L-3978"><span class="linenos">3978</span></a> -</span><span id="L-3979"><a href="#L-3979"><span class="linenos">3979</span></a><span class="k">class</span> <span class="nc">CurrentDatetime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3980"><a href="#L-3980"><span class="linenos">3980</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3981"><a href="#L-3981"><span class="linenos">3981</span></a> +</span><span id="L-3979"><a href="#L-3979"><span class="linenos">3979</span></a> +</span><span id="L-3980"><a href="#L-3980"><span class="linenos">3980</span></a><span class="k">class</span> <span class="nc">CurrentDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3981"><a href="#L-3981"><span class="linenos">3981</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3982"><a href="#L-3982"><span class="linenos">3982</span></a> -</span><span id="L-3983"><a href="#L-3983"><span class="linenos">3983</span></a><span class="k">class</span> <span class="nc">CurrentTime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3984"><a href="#L-3984"><span class="linenos">3984</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3985"><a href="#L-3985"><span class="linenos">3985</span></a> +</span><span id="L-3983"><a href="#L-3983"><span class="linenos">3983</span></a> +</span><span id="L-3984"><a href="#L-3984"><span class="linenos">3984</span></a><span class="k">class</span> <span class="nc">CurrentDatetime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3985"><a href="#L-3985"><span class="linenos">3985</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3986"><a href="#L-3986"><span class="linenos">3986</span></a> -</span><span id="L-3987"><a href="#L-3987"><span class="linenos">3987</span></a><span class="k">class</span> <span class="nc">CurrentTimestamp</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3988"><a href="#L-3988"><span class="linenos">3988</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3989"><a href="#L-3989"><span class="linenos">3989</span></a> +</span><span id="L-3987"><a href="#L-3987"><span class="linenos">3987</span></a> +</span><span id="L-3988"><a href="#L-3988"><span class="linenos">3988</span></a><span class="k">class</span> <span class="nc">CurrentTime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3989"><a href="#L-3989"><span class="linenos">3989</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3990"><a href="#L-3990"><span class="linenos">3990</span></a> -</span><span id="L-3991"><a href="#L-3991"><span class="linenos">3991</span></a><span class="k">class</span> <span class="nc">CurrentUser</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3992"><a href="#L-3992"><span class="linenos">3992</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3993"><a href="#L-3993"><span class="linenos">3993</span></a> +</span><span id="L-3991"><a href="#L-3991"><span class="linenos">3991</span></a> +</span><span id="L-3992"><a href="#L-3992"><span class="linenos">3992</span></a><span class="k">class</span> <span class="nc">CurrentTimestamp</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3993"><a href="#L-3993"><span class="linenos">3993</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3994"><a href="#L-3994"><span class="linenos">3994</span></a> -</span><span id="L-3995"><a href="#L-3995"><span class="linenos">3995</span></a><span class="k">class</span> <span class="nc">DateAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="L-3996"><a href="#L-3996"><span class="linenos">3996</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-3997"><a href="#L-3997"><span class="linenos">3997</span></a> +</span><span id="L-3995"><a href="#L-3995"><span class="linenos">3995</span></a> +</span><span id="L-3996"><a href="#L-3996"><span class="linenos">3996</span></a><span class="k">class</span> <span class="nc">CurrentUser</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3997"><a href="#L-3997"><span class="linenos">3997</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-3998"><a href="#L-3998"><span class="linenos">3998</span></a> -</span><span id="L-3999"><a href="#L-3999"><span class="linenos">3999</span></a><span class="k">class</span> <span class="nc">DateSub</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="L-4000"><a href="#L-4000"><span class="linenos">4000</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4001"><a href="#L-4001"><span class="linenos">4001</span></a> +</span><span id="L-3999"><a href="#L-3999"><span class="linenos">3999</span></a> +</span><span id="L-4000"><a href="#L-4000"><span class="linenos">4000</span></a><span class="k">class</span> <span class="nc">DateAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="L-4001"><a href="#L-4001"><span class="linenos">4001</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4002"><a href="#L-4002"><span class="linenos">4002</span></a> -</span><span id="L-4003"><a href="#L-4003"><span class="linenos">4003</span></a><span class="k">class</span> <span class="nc">DateDiff</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="L-4004"><a href="#L-4004"><span class="linenos">4004</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DATEDIFF"</span><span class="p">,</span> <span class="s2">"DATE_DIFF"</span><span class="p">]</span> +</span><span id="L-4003"><a href="#L-4003"><span class="linenos">4003</span></a> +</span><span id="L-4004"><a href="#L-4004"><span class="linenos">4004</span></a><span class="k">class</span> <span class="nc">DateSub</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> </span><span id="L-4005"><a href="#L-4005"><span class="linenos">4005</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4006"><a href="#L-4006"><span class="linenos">4006</span></a> </span><span id="L-4007"><a href="#L-4007"><span class="linenos">4007</span></a> -</span><span id="L-4008"><a href="#L-4008"><span class="linenos">4008</span></a><span class="k">class</span> <span class="nc">DateTrunc</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4009"><a href="#L-4009"><span class="linenos">4009</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"unit"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4010"><a href="#L-4010"><span class="linenos">4010</span></a> +</span><span id="L-4008"><a href="#L-4008"><span class="linenos">4008</span></a><span class="k">class</span> <span class="nc">DateDiff</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="L-4009"><a href="#L-4009"><span class="linenos">4009</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DATEDIFF"</span><span class="p">,</span> <span class="s2">"DATE_DIFF"</span><span class="p">]</span> +</span><span id="L-4010"><a href="#L-4010"><span class="linenos">4010</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4011"><a href="#L-4011"><span class="linenos">4011</span></a> -</span><span id="L-4012"><a href="#L-4012"><span class="linenos">4012</span></a><span class="k">class</span> <span class="nc">DatetimeAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="L-4013"><a href="#L-4013"><span class="linenos">4013</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4014"><a href="#L-4014"><span class="linenos">4014</span></a> +</span><span id="L-4012"><a href="#L-4012"><span class="linenos">4012</span></a> +</span><span id="L-4013"><a href="#L-4013"><span class="linenos">4013</span></a><span class="k">class</span> <span class="nc">DateTrunc</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4014"><a href="#L-4014"><span class="linenos">4014</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"unit"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4015"><a href="#L-4015"><span class="linenos">4015</span></a> -</span><span id="L-4016"><a href="#L-4016"><span class="linenos">4016</span></a><span class="k">class</span> <span class="nc">DatetimeSub</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="L-4017"><a href="#L-4017"><span class="linenos">4017</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4018"><a href="#L-4018"><span class="linenos">4018</span></a> +</span><span id="L-4016"><a href="#L-4016"><span class="linenos">4016</span></a> +</span><span id="L-4017"><a href="#L-4017"><span class="linenos">4017</span></a><span class="k">class</span> <span class="nc">DatetimeAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="L-4018"><a href="#L-4018"><span class="linenos">4018</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4019"><a href="#L-4019"><span class="linenos">4019</span></a> -</span><span id="L-4020"><a href="#L-4020"><span class="linenos">4020</span></a><span class="k">class</span> <span class="nc">DatetimeDiff</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="L-4021"><a href="#L-4021"><span class="linenos">4021</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4022"><a href="#L-4022"><span class="linenos">4022</span></a> +</span><span id="L-4020"><a href="#L-4020"><span class="linenos">4020</span></a> +</span><span id="L-4021"><a href="#L-4021"><span class="linenos">4021</span></a><span class="k">class</span> <span class="nc">DatetimeSub</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="L-4022"><a href="#L-4022"><span class="linenos">4022</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4023"><a href="#L-4023"><span class="linenos">4023</span></a> -</span><span id="L-4024"><a href="#L-4024"><span class="linenos">4024</span></a><span class="k">class</span> <span class="nc">DatetimeTrunc</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="L-4025"><a href="#L-4025"><span class="linenos">4025</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4026"><a href="#L-4026"><span class="linenos">4026</span></a> +</span><span id="L-4024"><a href="#L-4024"><span class="linenos">4024</span></a> +</span><span id="L-4025"><a href="#L-4025"><span class="linenos">4025</span></a><span class="k">class</span> <span class="nc">DatetimeDiff</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="L-4026"><a href="#L-4026"><span class="linenos">4026</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4027"><a href="#L-4027"><span class="linenos">4027</span></a> -</span><span id="L-4028"><a href="#L-4028"><span class="linenos">4028</span></a><span class="k">class</span> <span class="nc">DayOfWeek</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4029"><a href="#L-4029"><span class="linenos">4029</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DAY_OF_WEEK"</span><span class="p">,</span> <span class="s2">"DAYOFWEEK"</span><span class="p">]</span> -</span><span id="L-4030"><a href="#L-4030"><span class="linenos">4030</span></a> +</span><span id="L-4028"><a href="#L-4028"><span class="linenos">4028</span></a> +</span><span id="L-4029"><a href="#L-4029"><span class="linenos">4029</span></a><span class="k">class</span> <span class="nc">DatetimeTrunc</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="L-4030"><a href="#L-4030"><span class="linenos">4030</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4031"><a href="#L-4031"><span class="linenos">4031</span></a> -</span><span id="L-4032"><a href="#L-4032"><span class="linenos">4032</span></a><span class="k">class</span> <span class="nc">DayOfMonth</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4033"><a href="#L-4033"><span class="linenos">4033</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DAY_OF_MONTH"</span><span class="p">,</span> <span class="s2">"DAYOFMONTH"</span><span class="p">]</span> -</span><span id="L-4034"><a href="#L-4034"><span class="linenos">4034</span></a> +</span><span id="L-4032"><a href="#L-4032"><span class="linenos">4032</span></a> +</span><span id="L-4033"><a href="#L-4033"><span class="linenos">4033</span></a><span class="k">class</span> <span class="nc">DayOfWeek</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4034"><a href="#L-4034"><span class="linenos">4034</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DAY_OF_WEEK"</span><span class="p">,</span> <span class="s2">"DAYOFWEEK"</span><span class="p">]</span> </span><span id="L-4035"><a href="#L-4035"><span class="linenos">4035</span></a> -</span><span id="L-4036"><a href="#L-4036"><span class="linenos">4036</span></a><span class="k">class</span> <span class="nc">DayOfYear</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4037"><a href="#L-4037"><span class="linenos">4037</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DAY_OF_YEAR"</span><span class="p">,</span> <span class="s2">"DAYOFYEAR"</span><span class="p">]</span> -</span><span id="L-4038"><a href="#L-4038"><span class="linenos">4038</span></a> +</span><span id="L-4036"><a href="#L-4036"><span class="linenos">4036</span></a> +</span><span id="L-4037"><a href="#L-4037"><span class="linenos">4037</span></a><span class="k">class</span> <span class="nc">DayOfMonth</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4038"><a href="#L-4038"><span class="linenos">4038</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DAY_OF_MONTH"</span><span class="p">,</span> <span class="s2">"DAYOFMONTH"</span><span class="p">]</span> </span><span id="L-4039"><a href="#L-4039"><span class="linenos">4039</span></a> -</span><span id="L-4040"><a href="#L-4040"><span class="linenos">4040</span></a><span class="k">class</span> <span class="nc">WeekOfYear</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4041"><a href="#L-4041"><span class="linenos">4041</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"WEEK_OF_YEAR"</span><span class="p">,</span> <span class="s2">"WEEKOFYEAR"</span><span class="p">]</span> -</span><span id="L-4042"><a href="#L-4042"><span class="linenos">4042</span></a> +</span><span id="L-4040"><a href="#L-4040"><span class="linenos">4040</span></a> +</span><span id="L-4041"><a href="#L-4041"><span class="linenos">4041</span></a><span class="k">class</span> <span class="nc">DayOfYear</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4042"><a href="#L-4042"><span class="linenos">4042</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DAY_OF_YEAR"</span><span class="p">,</span> <span class="s2">"DAYOFYEAR"</span><span class="p">]</span> </span><span id="L-4043"><a href="#L-4043"><span class="linenos">4043</span></a> -</span><span id="L-4044"><a href="#L-4044"><span class="linenos">4044</span></a><span class="k">class</span> <span class="nc">LastDateOfMonth</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4045"><a href="#L-4045"><span class="linenos">4045</span></a> <span class="k">pass</span> -</span><span id="L-4046"><a href="#L-4046"><span class="linenos">4046</span></a> +</span><span id="L-4044"><a href="#L-4044"><span class="linenos">4044</span></a> +</span><span id="L-4045"><a href="#L-4045"><span class="linenos">4045</span></a><span class="k">class</span> <span class="nc">WeekOfYear</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4046"><a href="#L-4046"><span class="linenos">4046</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"WEEK_OF_YEAR"</span><span class="p">,</span> <span class="s2">"WEEKOFYEAR"</span><span class="p">]</span> </span><span id="L-4047"><a href="#L-4047"><span class="linenos">4047</span></a> -</span><span id="L-4048"><a href="#L-4048"><span class="linenos">4048</span></a><span class="k">class</span> <span class="nc">Extract</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4049"><a href="#L-4049"><span class="linenos">4049</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-4050"><a href="#L-4050"><span class="linenos">4050</span></a> +</span><span id="L-4048"><a href="#L-4048"><span class="linenos">4048</span></a> +</span><span id="L-4049"><a href="#L-4049"><span class="linenos">4049</span></a><span class="k">class</span> <span class="nc">LastDateOfMonth</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4050"><a href="#L-4050"><span class="linenos">4050</span></a> <span class="k">pass</span> </span><span id="L-4051"><a href="#L-4051"><span class="linenos">4051</span></a> -</span><span id="L-4052"><a href="#L-4052"><span class="linenos">4052</span></a><span class="k">class</span> <span class="nc">TimestampAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="L-4053"><a href="#L-4053"><span class="linenos">4053</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4054"><a href="#L-4054"><span class="linenos">4054</span></a> +</span><span id="L-4052"><a href="#L-4052"><span class="linenos">4052</span></a> +</span><span id="L-4053"><a href="#L-4053"><span class="linenos">4053</span></a><span class="k">class</span> <span class="nc">Extract</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4054"><a href="#L-4054"><span class="linenos">4054</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-4055"><a href="#L-4055"><span class="linenos">4055</span></a> -</span><span id="L-4056"><a href="#L-4056"><span class="linenos">4056</span></a><span class="k">class</span> <span class="nc">TimestampSub</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="L-4057"><a href="#L-4057"><span class="linenos">4057</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4058"><a href="#L-4058"><span class="linenos">4058</span></a> +</span><span id="L-4056"><a href="#L-4056"><span class="linenos">4056</span></a> +</span><span id="L-4057"><a href="#L-4057"><span class="linenos">4057</span></a><span class="k">class</span> <span class="nc">TimestampAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="L-4058"><a href="#L-4058"><span class="linenos">4058</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4059"><a href="#L-4059"><span class="linenos">4059</span></a> -</span><span id="L-4060"><a href="#L-4060"><span class="linenos">4060</span></a><span class="k">class</span> <span class="nc">TimestampDiff</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="L-4061"><a href="#L-4061"><span class="linenos">4061</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4062"><a href="#L-4062"><span class="linenos">4062</span></a> +</span><span id="L-4060"><a href="#L-4060"><span class="linenos">4060</span></a> +</span><span id="L-4061"><a href="#L-4061"><span class="linenos">4061</span></a><span class="k">class</span> <span class="nc">TimestampSub</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="L-4062"><a href="#L-4062"><span class="linenos">4062</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4063"><a href="#L-4063"><span class="linenos">4063</span></a> -</span><span id="L-4064"><a href="#L-4064"><span class="linenos">4064</span></a><span class="k">class</span> <span class="nc">TimestampTrunc</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="L-4065"><a href="#L-4065"><span class="linenos">4065</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4066"><a href="#L-4066"><span class="linenos">4066</span></a> +</span><span id="L-4064"><a href="#L-4064"><span class="linenos">4064</span></a> +</span><span id="L-4065"><a href="#L-4065"><span class="linenos">4065</span></a><span class="k">class</span> <span class="nc">TimestampDiff</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="L-4066"><a href="#L-4066"><span class="linenos">4066</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4067"><a href="#L-4067"><span class="linenos">4067</span></a> -</span><span id="L-4068"><a href="#L-4068"><span class="linenos">4068</span></a><span class="k">class</span> <span class="nc">TimeAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="L-4069"><a href="#L-4069"><span class="linenos">4069</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4070"><a href="#L-4070"><span class="linenos">4070</span></a> +</span><span id="L-4068"><a href="#L-4068"><span class="linenos">4068</span></a> +</span><span id="L-4069"><a href="#L-4069"><span class="linenos">4069</span></a><span class="k">class</span> <span class="nc">TimestampTrunc</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="L-4070"><a href="#L-4070"><span class="linenos">4070</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4071"><a href="#L-4071"><span class="linenos">4071</span></a> -</span><span id="L-4072"><a href="#L-4072"><span class="linenos">4072</span></a><span class="k">class</span> <span class="nc">TimeSub</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="L-4073"><a href="#L-4073"><span class="linenos">4073</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4074"><a href="#L-4074"><span class="linenos">4074</span></a> +</span><span id="L-4072"><a href="#L-4072"><span class="linenos">4072</span></a> +</span><span id="L-4073"><a href="#L-4073"><span class="linenos">4073</span></a><span class="k">class</span> <span class="nc">TimeAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="L-4074"><a href="#L-4074"><span class="linenos">4074</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4075"><a href="#L-4075"><span class="linenos">4075</span></a> -</span><span id="L-4076"><a href="#L-4076"><span class="linenos">4076</span></a><span class="k">class</span> <span class="nc">TimeDiff</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="L-4077"><a href="#L-4077"><span class="linenos">4077</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4078"><a href="#L-4078"><span class="linenos">4078</span></a> +</span><span id="L-4076"><a href="#L-4076"><span class="linenos">4076</span></a> +</span><span id="L-4077"><a href="#L-4077"><span class="linenos">4077</span></a><span class="k">class</span> <span class="nc">TimeSub</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="L-4078"><a href="#L-4078"><span class="linenos">4078</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4079"><a href="#L-4079"><span class="linenos">4079</span></a> -</span><span id="L-4080"><a href="#L-4080"><span class="linenos">4080</span></a><span class="k">class</span> <span class="nc">TimeTrunc</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="L-4081"><a href="#L-4081"><span class="linenos">4081</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4082"><a href="#L-4082"><span class="linenos">4082</span></a> +</span><span id="L-4080"><a href="#L-4080"><span class="linenos">4080</span></a> +</span><span id="L-4081"><a href="#L-4081"><span class="linenos">4081</span></a><span class="k">class</span> <span class="nc">TimeDiff</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="L-4082"><a href="#L-4082"><span class="linenos">4082</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4083"><a href="#L-4083"><span class="linenos">4083</span></a> -</span><span id="L-4084"><a href="#L-4084"><span class="linenos">4084</span></a><span class="k">class</span> <span class="nc">DateFromParts</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4085"><a href="#L-4085"><span class="linenos">4085</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DATEFROMPARTS"</span><span class="p">]</span> -</span><span id="L-4086"><a href="#L-4086"><span class="linenos">4086</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"year"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"month"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"day"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-4084"><a href="#L-4084"><span class="linenos">4084</span></a> +</span><span id="L-4085"><a href="#L-4085"><span class="linenos">4085</span></a><span class="k">class</span> <span class="nc">TimeTrunc</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="L-4086"><a href="#L-4086"><span class="linenos">4086</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4087"><a href="#L-4087"><span class="linenos">4087</span></a> </span><span id="L-4088"><a href="#L-4088"><span class="linenos">4088</span></a> -</span><span id="L-4089"><a href="#L-4089"><span class="linenos">4089</span></a><span class="k">class</span> <span class="nc">DateStrToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4090"><a href="#L-4090"><span class="linenos">4090</span></a> <span class="k">pass</span> -</span><span id="L-4091"><a href="#L-4091"><span class="linenos">4091</span></a> +</span><span id="L-4089"><a href="#L-4089"><span class="linenos">4089</span></a><span class="k">class</span> <span class="nc">DateFromParts</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4090"><a href="#L-4090"><span class="linenos">4090</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DATEFROMPARTS"</span><span class="p">]</span> +</span><span id="L-4091"><a href="#L-4091"><span class="linenos">4091</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"year"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"month"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"day"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-4092"><a href="#L-4092"><span class="linenos">4092</span></a> -</span><span id="L-4093"><a href="#L-4093"><span class="linenos">4093</span></a><span class="k">class</span> <span class="nc">DateToDateStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4094"><a href="#L-4094"><span class="linenos">4094</span></a> <span class="k">pass</span> -</span><span id="L-4095"><a href="#L-4095"><span class="linenos">4095</span></a> +</span><span id="L-4093"><a href="#L-4093"><span class="linenos">4093</span></a> +</span><span id="L-4094"><a href="#L-4094"><span class="linenos">4094</span></a><span class="k">class</span> <span class="nc">DateStrToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4095"><a href="#L-4095"><span class="linenos">4095</span></a> <span class="k">pass</span> </span><span id="L-4096"><a href="#L-4096"><span class="linenos">4096</span></a> -</span><span id="L-4097"><a href="#L-4097"><span class="linenos">4097</span></a><span class="k">class</span> <span class="nc">DateToDi</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4098"><a href="#L-4098"><span class="linenos">4098</span></a> <span class="k">pass</span> -</span><span id="L-4099"><a href="#L-4099"><span class="linenos">4099</span></a> +</span><span id="L-4097"><a href="#L-4097"><span class="linenos">4097</span></a> +</span><span id="L-4098"><a href="#L-4098"><span class="linenos">4098</span></a><span class="k">class</span> <span class="nc">DateToDateStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4099"><a href="#L-4099"><span class="linenos">4099</span></a> <span class="k">pass</span> </span><span id="L-4100"><a href="#L-4100"><span class="linenos">4100</span></a> -</span><span id="L-4101"><a href="#L-4101"><span class="linenos">4101</span></a><span class="k">class</span> <span class="nc">Date</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4102"><a href="#L-4102"><span class="linenos">4102</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-4103"><a href="#L-4103"><span class="linenos">4103</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-4101"><a href="#L-4101"><span class="linenos">4101</span></a> +</span><span id="L-4102"><a href="#L-4102"><span class="linenos">4102</span></a><span class="k">class</span> <span class="nc">DateToDi</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4103"><a href="#L-4103"><span class="linenos">4103</span></a> <span class="k">pass</span> </span><span id="L-4104"><a href="#L-4104"><span class="linenos">4104</span></a> </span><span id="L-4105"><a href="#L-4105"><span class="linenos">4105</span></a> -</span><span id="L-4106"><a href="#L-4106"><span class="linenos">4106</span></a><span class="k">class</span> <span class="nc">Day</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4107"><a href="#L-4107"><span class="linenos">4107</span></a> <span class="k">pass</span> -</span><span id="L-4108"><a href="#L-4108"><span class="linenos">4108</span></a> +</span><span id="L-4106"><a href="#L-4106"><span class="linenos">4106</span></a><span class="k">class</span> <span class="nc">Date</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4107"><a href="#L-4107"><span class="linenos">4107</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-4108"><a href="#L-4108"><span class="linenos">4108</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="L-4109"><a href="#L-4109"><span class="linenos">4109</span></a> -</span><span id="L-4110"><a href="#L-4110"><span class="linenos">4110</span></a><span class="k">class</span> <span class="nc">Decode</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4111"><a href="#L-4111"><span class="linenos">4111</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"charset"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"replace"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4112"><a href="#L-4112"><span class="linenos">4112</span></a> +</span><span id="L-4110"><a href="#L-4110"><span class="linenos">4110</span></a> +</span><span id="L-4111"><a href="#L-4111"><span class="linenos">4111</span></a><span class="k">class</span> <span class="nc">Day</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4112"><a href="#L-4112"><span class="linenos">4112</span></a> <span class="k">pass</span> </span><span id="L-4113"><a href="#L-4113"><span class="linenos">4113</span></a> -</span><span id="L-4114"><a href="#L-4114"><span class="linenos">4114</span></a><span class="k">class</span> <span class="nc">DiToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4115"><a href="#L-4115"><span class="linenos">4115</span></a> <span class="k">pass</span> -</span><span id="L-4116"><a href="#L-4116"><span class="linenos">4116</span></a> +</span><span id="L-4114"><a href="#L-4114"><span class="linenos">4114</span></a> +</span><span id="L-4115"><a href="#L-4115"><span class="linenos">4115</span></a><span class="k">class</span> <span class="nc">Decode</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4116"><a href="#L-4116"><span class="linenos">4116</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"charset"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"replace"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4117"><a href="#L-4117"><span class="linenos">4117</span></a> -</span><span id="L-4118"><a href="#L-4118"><span class="linenos">4118</span></a><span class="k">class</span> <span class="nc">Encode</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4119"><a href="#L-4119"><span class="linenos">4119</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"charset"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-4120"><a href="#L-4120"><span class="linenos">4120</span></a> +</span><span id="L-4118"><a href="#L-4118"><span class="linenos">4118</span></a> +</span><span id="L-4119"><a href="#L-4119"><span class="linenos">4119</span></a><span class="k">class</span> <span class="nc">DiToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4120"><a href="#L-4120"><span class="linenos">4120</span></a> <span class="k">pass</span> </span><span id="L-4121"><a href="#L-4121"><span class="linenos">4121</span></a> -</span><span id="L-4122"><a href="#L-4122"><span class="linenos">4122</span></a><span class="k">class</span> <span class="nc">Exp</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4123"><a href="#L-4123"><span class="linenos">4123</span></a> <span class="k">pass</span> -</span><span id="L-4124"><a href="#L-4124"><span class="linenos">4124</span></a> +</span><span id="L-4122"><a href="#L-4122"><span class="linenos">4122</span></a> +</span><span id="L-4123"><a href="#L-4123"><span class="linenos">4123</span></a><span class="k">class</span> <span class="nc">Encode</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4124"><a href="#L-4124"><span class="linenos">4124</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"charset"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-4125"><a href="#L-4125"><span class="linenos">4125</span></a> -</span><span id="L-4126"><a href="#L-4126"><span class="linenos">4126</span></a><span class="k">class</span> <span class="nc">Explode</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4127"><a href="#L-4127"><span class="linenos">4127</span></a> <span class="k">pass</span> -</span><span id="L-4128"><a href="#L-4128"><span class="linenos">4128</span></a> +</span><span id="L-4126"><a href="#L-4126"><span class="linenos">4126</span></a> +</span><span id="L-4127"><a href="#L-4127"><span class="linenos">4127</span></a><span class="k">class</span> <span class="nc">Exp</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4128"><a href="#L-4128"><span class="linenos">4128</span></a> <span class="k">pass</span> </span><span id="L-4129"><a href="#L-4129"><span class="linenos">4129</span></a> -</span><span id="L-4130"><a href="#L-4130"><span class="linenos">4130</span></a><span class="k">class</span> <span class="nc">Floor</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4131"><a href="#L-4131"><span class="linenos">4131</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"decimals"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4132"><a href="#L-4132"><span class="linenos">4132</span></a> +</span><span id="L-4130"><a href="#L-4130"><span class="linenos">4130</span></a> +</span><span id="L-4131"><a href="#L-4131"><span class="linenos">4131</span></a><span class="k">class</span> <span class="nc">Explode</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4132"><a href="#L-4132"><span class="linenos">4132</span></a> <span class="k">pass</span> </span><span id="L-4133"><a href="#L-4133"><span class="linenos">4133</span></a> -</span><span id="L-4134"><a href="#L-4134"><span class="linenos">4134</span></a><span class="k">class</span> <span class="nc">FromBase64</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4135"><a href="#L-4135"><span class="linenos">4135</span></a> <span class="k">pass</span> -</span><span id="L-4136"><a href="#L-4136"><span class="linenos">4136</span></a> +</span><span id="L-4134"><a href="#L-4134"><span class="linenos">4134</span></a> +</span><span id="L-4135"><a href="#L-4135"><span class="linenos">4135</span></a><span class="k">class</span> <span class="nc">Floor</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4136"><a href="#L-4136"><span class="linenos">4136</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"decimals"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4137"><a href="#L-4137"><span class="linenos">4137</span></a> -</span><span id="L-4138"><a href="#L-4138"><span class="linenos">4138</span></a><span class="k">class</span> <span class="nc">ToBase64</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4139"><a href="#L-4139"><span class="linenos">4139</span></a> <span class="k">pass</span> -</span><span id="L-4140"><a href="#L-4140"><span class="linenos">4140</span></a> +</span><span id="L-4138"><a href="#L-4138"><span class="linenos">4138</span></a> +</span><span id="L-4139"><a href="#L-4139"><span class="linenos">4139</span></a><span class="k">class</span> <span class="nc">FromBase64</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4140"><a href="#L-4140"><span class="linenos">4140</span></a> <span class="k">pass</span> </span><span id="L-4141"><a href="#L-4141"><span class="linenos">4141</span></a> -</span><span id="L-4142"><a href="#L-4142"><span class="linenos">4142</span></a><span class="k">class</span> <span class="nc">Greatest</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4143"><a href="#L-4143"><span class="linenos">4143</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4144"><a href="#L-4144"><span class="linenos">4144</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-4142"><a href="#L-4142"><span class="linenos">4142</span></a> +</span><span id="L-4143"><a href="#L-4143"><span class="linenos">4143</span></a><span class="k">class</span> <span class="nc">ToBase64</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4144"><a href="#L-4144"><span class="linenos">4144</span></a> <span class="k">pass</span> </span><span id="L-4145"><a href="#L-4145"><span class="linenos">4145</span></a> </span><span id="L-4146"><a href="#L-4146"><span class="linenos">4146</span></a> -</span><span id="L-4147"><a href="#L-4147"><span class="linenos">4147</span></a><span class="k">class</span> <span class="nc">GroupConcat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4148"><a href="#L-4148"><span class="linenos">4148</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"separator"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4149"><a href="#L-4149"><span class="linenos">4149</span></a> +</span><span id="L-4147"><a href="#L-4147"><span class="linenos">4147</span></a><span class="k">class</span> <span class="nc">Greatest</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4148"><a href="#L-4148"><span class="linenos">4148</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-4149"><a href="#L-4149"><span class="linenos">4149</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="L-4150"><a href="#L-4150"><span class="linenos">4150</span></a> -</span><span id="L-4151"><a href="#L-4151"><span class="linenos">4151</span></a><span class="k">class</span> <span class="nc">Hex</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4152"><a href="#L-4152"><span class="linenos">4152</span></a> <span class="k">pass</span> -</span><span id="L-4153"><a href="#L-4153"><span class="linenos">4153</span></a> +</span><span id="L-4151"><a href="#L-4151"><span class="linenos">4151</span></a> +</span><span id="L-4152"><a href="#L-4152"><span class="linenos">4152</span></a><span class="k">class</span> <span class="nc">GroupConcat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4153"><a href="#L-4153"><span class="linenos">4153</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"separator"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4154"><a href="#L-4154"><span class="linenos">4154</span></a> -</span><span id="L-4155"><a href="#L-4155"><span class="linenos">4155</span></a><span class="k">class</span> <span class="nc">If</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4156"><a href="#L-4156"><span class="linenos">4156</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"true"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"false"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4157"><a href="#L-4157"><span class="linenos">4157</span></a> +</span><span id="L-4155"><a href="#L-4155"><span class="linenos">4155</span></a> +</span><span id="L-4156"><a href="#L-4156"><span class="linenos">4156</span></a><span class="k">class</span> <span class="nc">Hex</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4157"><a href="#L-4157"><span class="linenos">4157</span></a> <span class="k">pass</span> </span><span id="L-4158"><a href="#L-4158"><span class="linenos">4158</span></a> -</span><span id="L-4159"><a href="#L-4159"><span class="linenos">4159</span></a><span class="k">class</span> <span class="nc">Initcap</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4160"><a href="#L-4160"><span class="linenos">4160</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4161"><a href="#L-4161"><span class="linenos">4161</span></a> +</span><span id="L-4159"><a href="#L-4159"><span class="linenos">4159</span></a> +</span><span id="L-4160"><a href="#L-4160"><span class="linenos">4160</span></a><span class="k">class</span> <span class="nc">If</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4161"><a href="#L-4161"><span class="linenos">4161</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"true"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"false"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4162"><a href="#L-4162"><span class="linenos">4162</span></a> -</span><span id="L-4163"><a href="#L-4163"><span class="linenos">4163</span></a><span class="k">class</span> <span class="nc">JSONKeyValue</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-4164"><a href="#L-4164"><span class="linenos">4164</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-4165"><a href="#L-4165"><span class="linenos">4165</span></a> +</span><span id="L-4163"><a href="#L-4163"><span class="linenos">4163</span></a> +</span><span id="L-4164"><a href="#L-4164"><span class="linenos">4164</span></a><span class="k">class</span> <span class="nc">Initcap</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4165"><a href="#L-4165"><span class="linenos">4165</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4166"><a href="#L-4166"><span class="linenos">4166</span></a> -</span><span id="L-4167"><a href="#L-4167"><span class="linenos">4167</span></a><span class="k">class</span> <span class="nc">JSONObject</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4168"><a href="#L-4168"><span class="linenos">4168</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-4169"><a href="#L-4169"><span class="linenos">4169</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4170"><a href="#L-4170"><span class="linenos">4170</span></a> <span class="s2">"null_handling"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4171"><a href="#L-4171"><span class="linenos">4171</span></a> <span class="s2">"unique_keys"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4172"><a href="#L-4172"><span class="linenos">4172</span></a> <span class="s2">"return_type"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4173"><a href="#L-4173"><span class="linenos">4173</span></a> <span class="s2">"format_json"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4174"><a href="#L-4174"><span class="linenos">4174</span></a> <span class="s2">"encoding"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4175"><a href="#L-4175"><span class="linenos">4175</span></a> <span class="p">}</span> -</span><span id="L-4176"><a href="#L-4176"><span class="linenos">4176</span></a> -</span><span id="L-4177"><a href="#L-4177"><span class="linenos">4177</span></a> -</span><span id="L-4178"><a href="#L-4178"><span class="linenos">4178</span></a><span class="k">class</span> <span class="nc">OpenJSONColumnDef</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-4179"><a href="#L-4179"><span class="linenos">4179</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"as_json"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4180"><a href="#L-4180"><span class="linenos">4180</span></a> +</span><span id="L-4167"><a href="#L-4167"><span class="linenos">4167</span></a> +</span><span id="L-4168"><a href="#L-4168"><span class="linenos">4168</span></a><span class="k">class</span> <span class="nc">JSONKeyValue</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-4169"><a href="#L-4169"><span class="linenos">4169</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-4170"><a href="#L-4170"><span class="linenos">4170</span></a> +</span><span id="L-4171"><a href="#L-4171"><span class="linenos">4171</span></a> +</span><span id="L-4172"><a href="#L-4172"><span class="linenos">4172</span></a><span class="k">class</span> <span class="nc">JSONObject</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4173"><a href="#L-4173"><span class="linenos">4173</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-4174"><a href="#L-4174"><span class="linenos">4174</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4175"><a href="#L-4175"><span class="linenos">4175</span></a> <span class="s2">"null_handling"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4176"><a href="#L-4176"><span class="linenos">4176</span></a> <span class="s2">"unique_keys"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4177"><a href="#L-4177"><span class="linenos">4177</span></a> <span class="s2">"return_type"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4178"><a href="#L-4178"><span class="linenos">4178</span></a> <span class="s2">"format_json"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4179"><a href="#L-4179"><span class="linenos">4179</span></a> <span class="s2">"encoding"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4180"><a href="#L-4180"><span class="linenos">4180</span></a> <span class="p">}</span> </span><span id="L-4181"><a href="#L-4181"><span class="linenos">4181</span></a> -</span><span id="L-4182"><a href="#L-4182"><span class="linenos">4182</span></a><span class="k">class</span> <span class="nc">OpenJSON</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4183"><a href="#L-4183"><span class="linenos">4183</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4184"><a href="#L-4184"><span class="linenos">4184</span></a> +</span><span id="L-4182"><a href="#L-4182"><span class="linenos">4182</span></a> +</span><span id="L-4183"><a href="#L-4183"><span class="linenos">4183</span></a><span class="k">class</span> <span class="nc">OpenJSONColumnDef</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-4184"><a href="#L-4184"><span class="linenos">4184</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"as_json"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4185"><a href="#L-4185"><span class="linenos">4185</span></a> -</span><span id="L-4186"><a href="#L-4186"><span class="linenos">4186</span></a><span class="k">class</span> <span class="nc">JSONBContains</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-4187"><a href="#L-4187"><span class="linenos">4187</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSONB_CONTAINS"</span><span class="p">]</span> -</span><span id="L-4188"><a href="#L-4188"><span class="linenos">4188</span></a> +</span><span id="L-4186"><a href="#L-4186"><span class="linenos">4186</span></a> +</span><span id="L-4187"><a href="#L-4187"><span class="linenos">4187</span></a><span class="k">class</span> <span class="nc">OpenJSON</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4188"><a href="#L-4188"><span class="linenos">4188</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4189"><a href="#L-4189"><span class="linenos">4189</span></a> -</span><span id="L-4190"><a href="#L-4190"><span class="linenos">4190</span></a><span class="k">class</span> <span class="nc">JSONExtract</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Func</span><span class="p">):</span> -</span><span id="L-4191"><a href="#L-4191"><span class="linenos">4191</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSON_EXTRACT"</span><span class="p">]</span> -</span><span id="L-4192"><a href="#L-4192"><span class="linenos">4192</span></a> +</span><span id="L-4190"><a href="#L-4190"><span class="linenos">4190</span></a> +</span><span id="L-4191"><a href="#L-4191"><span class="linenos">4191</span></a><span class="k">class</span> <span class="nc">JSONBContains</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-4192"><a href="#L-4192"><span class="linenos">4192</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSONB_CONTAINS"</span><span class="p">]</span> </span><span id="L-4193"><a href="#L-4193"><span class="linenos">4193</span></a> -</span><span id="L-4194"><a href="#L-4194"><span class="linenos">4194</span></a><span class="k">class</span> <span class="nc">JSONExtractScalar</span><span class="p">(</span><span class="n">JSONExtract</span><span class="p">):</span> -</span><span id="L-4195"><a href="#L-4195"><span class="linenos">4195</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSON_EXTRACT_SCALAR"</span><span class="p">]</span> -</span><span id="L-4196"><a href="#L-4196"><span class="linenos">4196</span></a> +</span><span id="L-4194"><a href="#L-4194"><span class="linenos">4194</span></a> +</span><span id="L-4195"><a href="#L-4195"><span class="linenos">4195</span></a><span class="k">class</span> <span class="nc">JSONExtract</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Func</span><span class="p">):</span> +</span><span id="L-4196"><a href="#L-4196"><span class="linenos">4196</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSON_EXTRACT"</span><span class="p">]</span> </span><span id="L-4197"><a href="#L-4197"><span class="linenos">4197</span></a> -</span><span id="L-4198"><a href="#L-4198"><span class="linenos">4198</span></a><span class="k">class</span> <span class="nc">JSONBExtract</span><span class="p">(</span><span class="n">JSONExtract</span><span class="p">):</span> -</span><span id="L-4199"><a href="#L-4199"><span class="linenos">4199</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSONB_EXTRACT"</span><span class="p">]</span> -</span><span id="L-4200"><a href="#L-4200"><span class="linenos">4200</span></a> +</span><span id="L-4198"><a href="#L-4198"><span class="linenos">4198</span></a> +</span><span id="L-4199"><a href="#L-4199"><span class="linenos">4199</span></a><span class="k">class</span> <span class="nc">JSONExtractScalar</span><span class="p">(</span><span class="n">JSONExtract</span><span class="p">):</span> +</span><span id="L-4200"><a href="#L-4200"><span class="linenos">4200</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSON_EXTRACT_SCALAR"</span><span class="p">]</span> </span><span id="L-4201"><a href="#L-4201"><span class="linenos">4201</span></a> -</span><span id="L-4202"><a href="#L-4202"><span class="linenos">4202</span></a><span class="k">class</span> <span class="nc">JSONBExtractScalar</span><span class="p">(</span><span class="n">JSONExtract</span><span class="p">):</span> -</span><span id="L-4203"><a href="#L-4203"><span class="linenos">4203</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSONB_EXTRACT_SCALAR"</span><span class="p">]</span> -</span><span id="L-4204"><a href="#L-4204"><span class="linenos">4204</span></a> +</span><span id="L-4202"><a href="#L-4202"><span class="linenos">4202</span></a> +</span><span id="L-4203"><a href="#L-4203"><span class="linenos">4203</span></a><span class="k">class</span> <span class="nc">JSONBExtract</span><span class="p">(</span><span class="n">JSONExtract</span><span class="p">):</span> +</span><span id="L-4204"><a href="#L-4204"><span class="linenos">4204</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSONB_EXTRACT"</span><span class="p">]</span> </span><span id="L-4205"><a href="#L-4205"><span class="linenos">4205</span></a> -</span><span id="L-4206"><a href="#L-4206"><span class="linenos">4206</span></a><span class="k">class</span> <span class="nc">JSONFormat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4207"><a href="#L-4207"><span class="linenos">4207</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"options"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4208"><a href="#L-4208"><span class="linenos">4208</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSON_FORMAT"</span><span class="p">]</span> +</span><span id="L-4206"><a href="#L-4206"><span class="linenos">4206</span></a> +</span><span id="L-4207"><a href="#L-4207"><span class="linenos">4207</span></a><span class="k">class</span> <span class="nc">JSONBExtractScalar</span><span class="p">(</span><span class="n">JSONExtract</span><span class="p">):</span> +</span><span id="L-4208"><a href="#L-4208"><span class="linenos">4208</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSONB_EXTRACT_SCALAR"</span><span class="p">]</span> </span><span id="L-4209"><a href="#L-4209"><span class="linenos">4209</span></a> </span><span id="L-4210"><a href="#L-4210"><span class="linenos">4210</span></a> -</span><span id="L-4211"><a href="#L-4211"><span class="linenos">4211</span></a><span class="k">class</span> <span class="nc">Least</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4212"><a href="#L-4212"><span class="linenos">4212</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4213"><a href="#L-4213"><span class="linenos">4213</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-4211"><a href="#L-4211"><span class="linenos">4211</span></a><span class="k">class</span> <span class="nc">JSONFormat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4212"><a href="#L-4212"><span class="linenos">4212</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"options"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-4213"><a href="#L-4213"><span class="linenos">4213</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSON_FORMAT"</span><span class="p">]</span> </span><span id="L-4214"><a href="#L-4214"><span class="linenos">4214</span></a> </span><span id="L-4215"><a href="#L-4215"><span class="linenos">4215</span></a> -</span><span id="L-4216"><a href="#L-4216"><span class="linenos">4216</span></a><span class="k">class</span> <span class="nc">Left</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4217"><a href="#L-4217"><span class="linenos">4217</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-4218"><a href="#L-4218"><span class="linenos">4218</span></a> +</span><span id="L-4216"><a href="#L-4216"><span class="linenos">4216</span></a><span class="k">class</span> <span class="nc">Least</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4217"><a href="#L-4217"><span class="linenos">4217</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-4218"><a href="#L-4218"><span class="linenos">4218</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="L-4219"><a href="#L-4219"><span class="linenos">4219</span></a> -</span><span id="L-4220"><a href="#L-4220"><span class="linenos">4220</span></a><span class="k">class</span> <span class="nc">Right</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4221"><a href="#L-4221"><span class="linenos">4221</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-4222"><a href="#L-4222"><span class="linenos">4222</span></a> +</span><span id="L-4220"><a href="#L-4220"><span class="linenos">4220</span></a> +</span><span id="L-4221"><a href="#L-4221"><span class="linenos">4221</span></a><span class="k">class</span> <span class="nc">Left</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4222"><a href="#L-4222"><span class="linenos">4222</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-4223"><a href="#L-4223"><span class="linenos">4223</span></a> -</span><span id="L-4224"><a href="#L-4224"><span class="linenos">4224</span></a><span class="k">class</span> <span class="nc">Length</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4225"><a href="#L-4225"><span class="linenos">4225</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="s2">"LEN"</span><span class="p">]</span> -</span><span id="L-4226"><a href="#L-4226"><span class="linenos">4226</span></a> +</span><span id="L-4224"><a href="#L-4224"><span class="linenos">4224</span></a> +</span><span id="L-4225"><a href="#L-4225"><span class="linenos">4225</span></a><span class="k">class</span> <span class="nc">Right</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4226"><a href="#L-4226"><span class="linenos">4226</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-4227"><a href="#L-4227"><span class="linenos">4227</span></a> -</span><span id="L-4228"><a href="#L-4228"><span class="linenos">4228</span></a><span class="k">class</span> <span class="nc">Levenshtein</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4229"><a href="#L-4229"><span class="linenos">4229</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-4230"><a href="#L-4230"><span class="linenos">4230</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-4231"><a href="#L-4231"><span class="linenos">4231</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4232"><a href="#L-4232"><span class="linenos">4232</span></a> <span class="s2">"ins_cost"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4233"><a href="#L-4233"><span class="linenos">4233</span></a> <span class="s2">"del_cost"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4234"><a href="#L-4234"><span class="linenos">4234</span></a> <span class="s2">"sub_cost"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4235"><a href="#L-4235"><span class="linenos">4235</span></a> <span class="p">}</span> -</span><span id="L-4236"><a href="#L-4236"><span class="linenos">4236</span></a> -</span><span id="L-4237"><a href="#L-4237"><span class="linenos">4237</span></a> -</span><span id="L-4238"><a href="#L-4238"><span class="linenos">4238</span></a><span class="k">class</span> <span class="nc">Ln</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4239"><a href="#L-4239"><span class="linenos">4239</span></a> <span class="k">pass</span> -</span><span id="L-4240"><a href="#L-4240"><span class="linenos">4240</span></a> +</span><span id="L-4228"><a href="#L-4228"><span class="linenos">4228</span></a> +</span><span id="L-4229"><a href="#L-4229"><span class="linenos">4229</span></a><span class="k">class</span> <span class="nc">Length</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4230"><a href="#L-4230"><span class="linenos">4230</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="s2">"LEN"</span><span class="p">]</span> +</span><span id="L-4231"><a href="#L-4231"><span class="linenos">4231</span></a> +</span><span id="L-4232"><a href="#L-4232"><span class="linenos">4232</span></a> +</span><span id="L-4233"><a href="#L-4233"><span class="linenos">4233</span></a><span class="k">class</span> <span class="nc">Levenshtein</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4234"><a href="#L-4234"><span class="linenos">4234</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-4235"><a href="#L-4235"><span class="linenos">4235</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-4236"><a href="#L-4236"><span class="linenos">4236</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4237"><a href="#L-4237"><span class="linenos">4237</span></a> <span class="s2">"ins_cost"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4238"><a href="#L-4238"><span class="linenos">4238</span></a> <span class="s2">"del_cost"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4239"><a href="#L-4239"><span class="linenos">4239</span></a> <span class="s2">"sub_cost"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4240"><a href="#L-4240"><span class="linenos">4240</span></a> <span class="p">}</span> </span><span id="L-4241"><a href="#L-4241"><span class="linenos">4241</span></a> -</span><span id="L-4242"><a href="#L-4242"><span class="linenos">4242</span></a><span class="k">class</span> <span class="nc">Log</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4243"><a href="#L-4243"><span class="linenos">4243</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4244"><a href="#L-4244"><span class="linenos">4244</span></a> +</span><span id="L-4242"><a href="#L-4242"><span class="linenos">4242</span></a> +</span><span id="L-4243"><a href="#L-4243"><span class="linenos">4243</span></a><span class="k">class</span> <span class="nc">Ln</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4244"><a href="#L-4244"><span class="linenos">4244</span></a> <span class="k">pass</span> </span><span id="L-4245"><a href="#L-4245"><span class="linenos">4245</span></a> -</span><span id="L-4246"><a href="#L-4246"><span class="linenos">4246</span></a><span class="k">class</span> <span class="nc">Log2</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4247"><a href="#L-4247"><span class="linenos">4247</span></a> <span class="k">pass</span> -</span><span id="L-4248"><a href="#L-4248"><span class="linenos">4248</span></a> +</span><span id="L-4246"><a href="#L-4246"><span class="linenos">4246</span></a> +</span><span id="L-4247"><a href="#L-4247"><span class="linenos">4247</span></a><span class="k">class</span> <span class="nc">Log</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4248"><a href="#L-4248"><span class="linenos">4248</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4249"><a href="#L-4249"><span class="linenos">4249</span></a> -</span><span id="L-4250"><a href="#L-4250"><span class="linenos">4250</span></a><span class="k">class</span> <span class="nc">Log10</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4251"><a href="#L-4251"><span class="linenos">4251</span></a> <span class="k">pass</span> -</span><span id="L-4252"><a href="#L-4252"><span class="linenos">4252</span></a> +</span><span id="L-4250"><a href="#L-4250"><span class="linenos">4250</span></a> +</span><span id="L-4251"><a href="#L-4251"><span class="linenos">4251</span></a><span class="k">class</span> <span class="nc">Log2</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4252"><a href="#L-4252"><span class="linenos">4252</span></a> <span class="k">pass</span> </span><span id="L-4253"><a href="#L-4253"><span class="linenos">4253</span></a> -</span><span id="L-4254"><a href="#L-4254"><span class="linenos">4254</span></a><span class="k">class</span> <span class="nc">LogicalOr</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-4255"><a href="#L-4255"><span class="linenos">4255</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"LOGICAL_OR"</span><span class="p">,</span> <span class="s2">"BOOL_OR"</span><span class="p">,</span> <span class="s2">"BOOLOR_AGG"</span><span class="p">]</span> -</span><span id="L-4256"><a href="#L-4256"><span class="linenos">4256</span></a> +</span><span id="L-4254"><a href="#L-4254"><span class="linenos">4254</span></a> +</span><span id="L-4255"><a href="#L-4255"><span class="linenos">4255</span></a><span class="k">class</span> <span class="nc">Log10</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4256"><a href="#L-4256"><span class="linenos">4256</span></a> <span class="k">pass</span> </span><span id="L-4257"><a href="#L-4257"><span class="linenos">4257</span></a> -</span><span id="L-4258"><a href="#L-4258"><span class="linenos">4258</span></a><span class="k">class</span> <span class="nc">LogicalAnd</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-4259"><a href="#L-4259"><span class="linenos">4259</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"LOGICAL_AND"</span><span class="p">,</span> <span class="s2">"BOOL_AND"</span><span class="p">,</span> <span class="s2">"BOOLAND_AGG"</span><span class="p">]</span> -</span><span id="L-4260"><a href="#L-4260"><span class="linenos">4260</span></a> +</span><span id="L-4258"><a href="#L-4258"><span class="linenos">4258</span></a> +</span><span id="L-4259"><a href="#L-4259"><span class="linenos">4259</span></a><span class="k">class</span> <span class="nc">LogicalOr</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-4260"><a href="#L-4260"><span class="linenos">4260</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"LOGICAL_OR"</span><span class="p">,</span> <span class="s2">"BOOL_OR"</span><span class="p">,</span> <span class="s2">"BOOLOR_AGG"</span><span class="p">]</span> </span><span id="L-4261"><a href="#L-4261"><span class="linenos">4261</span></a> -</span><span id="L-4262"><a href="#L-4262"><span class="linenos">4262</span></a><span class="k">class</span> <span class="nc">Lower</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4263"><a href="#L-4263"><span class="linenos">4263</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"LOWER"</span><span class="p">,</span> <span class="s2">"LCASE"</span><span class="p">]</span> -</span><span id="L-4264"><a href="#L-4264"><span class="linenos">4264</span></a> +</span><span id="L-4262"><a href="#L-4262"><span class="linenos">4262</span></a> +</span><span id="L-4263"><a href="#L-4263"><span class="linenos">4263</span></a><span class="k">class</span> <span class="nc">LogicalAnd</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-4264"><a href="#L-4264"><span class="linenos">4264</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"LOGICAL_AND"</span><span class="p">,</span> <span class="s2">"BOOL_AND"</span><span class="p">,</span> <span class="s2">"BOOLAND_AGG"</span><span class="p">]</span> </span><span id="L-4265"><a href="#L-4265"><span class="linenos">4265</span></a> -</span><span id="L-4266"><a href="#L-4266"><span class="linenos">4266</span></a><span class="k">class</span> <span class="nc">Map</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4267"><a href="#L-4267"><span class="linenos">4267</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"keys"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"values"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4268"><a href="#L-4268"><span class="linenos">4268</span></a> +</span><span id="L-4266"><a href="#L-4266"><span class="linenos">4266</span></a> +</span><span id="L-4267"><a href="#L-4267"><span class="linenos">4267</span></a><span class="k">class</span> <span class="nc">Lower</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4268"><a href="#L-4268"><span class="linenos">4268</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"LOWER"</span><span class="p">,</span> <span class="s2">"LCASE"</span><span class="p">]</span> </span><span id="L-4269"><a href="#L-4269"><span class="linenos">4269</span></a> -</span><span id="L-4270"><a href="#L-4270"><span class="linenos">4270</span></a><span class="k">class</span> <span class="nc">StarMap</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4271"><a href="#L-4271"><span class="linenos">4271</span></a> <span class="k">pass</span> -</span><span id="L-4272"><a href="#L-4272"><span class="linenos">4272</span></a> +</span><span id="L-4270"><a href="#L-4270"><span class="linenos">4270</span></a> +</span><span id="L-4271"><a href="#L-4271"><span class="linenos">4271</span></a><span class="k">class</span> <span class="nc">Map</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4272"><a href="#L-4272"><span class="linenos">4272</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"keys"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"values"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4273"><a href="#L-4273"><span class="linenos">4273</span></a> -</span><span id="L-4274"><a href="#L-4274"><span class="linenos">4274</span></a><span class="k">class</span> <span class="nc">VarMap</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4275"><a href="#L-4275"><span class="linenos">4275</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"keys"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"values"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-4276"><a href="#L-4276"><span class="linenos">4276</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-4274"><a href="#L-4274"><span class="linenos">4274</span></a> +</span><span id="L-4275"><a href="#L-4275"><span class="linenos">4275</span></a><span class="k">class</span> <span class="nc">StarMap</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4276"><a href="#L-4276"><span class="linenos">4276</span></a> <span class="k">pass</span> </span><span id="L-4277"><a href="#L-4277"><span class="linenos">4277</span></a> -</span><span id="L-4278"><a href="#L-4278"><span class="linenos">4278</span></a> <span class="nd">@property</span> -</span><span id="L-4279"><a href="#L-4279"><span class="linenos">4279</span></a> <span class="k">def</span> <span class="nf">keys</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Expression</span><span class="p">]:</span> -</span><span id="L-4280"><a href="#L-4280"><span class="linenos">4280</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"keys"</span><span class="p">]</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="L-4281"><a href="#L-4281"><span class="linenos">4281</span></a> -</span><span id="L-4282"><a href="#L-4282"><span class="linenos">4282</span></a> <span class="nd">@property</span> -</span><span id="L-4283"><a href="#L-4283"><span class="linenos">4283</span></a> <span class="k">def</span> <span class="nf">values</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Expression</span><span class="p">]:</span> -</span><span id="L-4284"><a href="#L-4284"><span class="linenos">4284</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"values"</span><span class="p">]</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="L-4285"><a href="#L-4285"><span class="linenos">4285</span></a> +</span><span id="L-4278"><a href="#L-4278"><span class="linenos">4278</span></a> +</span><span id="L-4279"><a href="#L-4279"><span class="linenos">4279</span></a><span class="k">class</span> <span class="nc">VarMap</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4280"><a href="#L-4280"><span class="linenos">4280</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"keys"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"values"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-4281"><a href="#L-4281"><span class="linenos">4281</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-4282"><a href="#L-4282"><span class="linenos">4282</span></a> +</span><span id="L-4283"><a href="#L-4283"><span class="linenos">4283</span></a> <span class="nd">@property</span> +</span><span id="L-4284"><a href="#L-4284"><span class="linenos">4284</span></a> <span class="k">def</span> <span class="nf">keys</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Expression</span><span class="p">]:</span> +</span><span id="L-4285"><a href="#L-4285"><span class="linenos">4285</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"keys"</span><span class="p">]</span><span class="o">.</span><span class="n">expressions</span> </span><span id="L-4286"><a href="#L-4286"><span class="linenos">4286</span></a> -</span><span id="L-4287"><a href="#L-4287"><span class="linenos">4287</span></a><span class="c1"># https://dev.mysql.com/doc/refman/8.0/en/fulltext-search.html</span> -</span><span id="L-4288"><a href="#L-4288"><span class="linenos">4288</span></a><span class="k">class</span> <span class="nc">MatchAgainst</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4289"><a href="#L-4289"><span class="linenos">4289</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"modifier"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-4287"><a href="#L-4287"><span class="linenos">4287</span></a> <span class="nd">@property</span> +</span><span id="L-4288"><a href="#L-4288"><span class="linenos">4288</span></a> <span class="k">def</span> <span class="nf">values</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Expression</span><span class="p">]:</span> +</span><span id="L-4289"><a href="#L-4289"><span class="linenos">4289</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"values"</span><span class="p">]</span><span class="o">.</span><span class="n">expressions</span> </span><span id="L-4290"><a href="#L-4290"><span class="linenos">4290</span></a> </span><span id="L-4291"><a href="#L-4291"><span class="linenos">4291</span></a> -</span><span id="L-4292"><a href="#L-4292"><span class="linenos">4292</span></a><span class="k">class</span> <span class="nc">Max</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-4293"><a href="#L-4293"><span class="linenos">4293</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4294"><a href="#L-4294"><span class="linenos">4294</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-4292"><a href="#L-4292"><span class="linenos">4292</span></a><span class="c1"># https://dev.mysql.com/doc/refman/8.0/en/fulltext-search.html</span> +</span><span id="L-4293"><a href="#L-4293"><span class="linenos">4293</span></a><span class="k">class</span> <span class="nc">MatchAgainst</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4294"><a href="#L-4294"><span class="linenos">4294</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"modifier"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4295"><a href="#L-4295"><span class="linenos">4295</span></a> </span><span id="L-4296"><a href="#L-4296"><span class="linenos">4296</span></a> -</span><span id="L-4297"><a href="#L-4297"><span class="linenos">4297</span></a><span class="k">class</span> <span class="nc">MD5</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4298"><a href="#L-4298"><span class="linenos">4298</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"MD5"</span><span class="p">]</span> -</span><span id="L-4299"><a href="#L-4299"><span class="linenos">4299</span></a> +</span><span id="L-4297"><a href="#L-4297"><span class="linenos">4297</span></a><span class="k">class</span> <span class="nc">Max</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-4298"><a href="#L-4298"><span class="linenos">4298</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-4299"><a href="#L-4299"><span class="linenos">4299</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="L-4300"><a href="#L-4300"><span class="linenos">4300</span></a> -</span><span id="L-4301"><a href="#L-4301"><span class="linenos">4301</span></a><span class="k">class</span> <span class="nc">Min</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-4302"><a href="#L-4302"><span class="linenos">4302</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4303"><a href="#L-4303"><span class="linenos">4303</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-4301"><a href="#L-4301"><span class="linenos">4301</span></a> +</span><span id="L-4302"><a href="#L-4302"><span class="linenos">4302</span></a><span class="k">class</span> <span class="nc">MD5</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4303"><a href="#L-4303"><span class="linenos">4303</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"MD5"</span><span class="p">]</span> </span><span id="L-4304"><a href="#L-4304"><span class="linenos">4304</span></a> </span><span id="L-4305"><a href="#L-4305"><span class="linenos">4305</span></a> -</span><span id="L-4306"><a href="#L-4306"><span class="linenos">4306</span></a><span class="k">class</span> <span class="nc">Month</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4307"><a href="#L-4307"><span class="linenos">4307</span></a> <span class="k">pass</span> -</span><span id="L-4308"><a href="#L-4308"><span class="linenos">4308</span></a> +</span><span id="L-4306"><a href="#L-4306"><span class="linenos">4306</span></a><span class="k">class</span> <span class="nc">Min</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-4307"><a href="#L-4307"><span class="linenos">4307</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-4308"><a href="#L-4308"><span class="linenos">4308</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="L-4309"><a href="#L-4309"><span class="linenos">4309</span></a> -</span><span id="L-4310"><a href="#L-4310"><span class="linenos">4310</span></a><span class="k">class</span> <span class="nc">Nvl2</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4311"><a href="#L-4311"><span class="linenos">4311</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"true"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"false"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4312"><a href="#L-4312"><span class="linenos">4312</span></a> +</span><span id="L-4310"><a href="#L-4310"><span class="linenos">4310</span></a> +</span><span id="L-4311"><a href="#L-4311"><span class="linenos">4311</span></a><span class="k">class</span> <span class="nc">Month</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4312"><a href="#L-4312"><span class="linenos">4312</span></a> <span class="k">pass</span> </span><span id="L-4313"><a href="#L-4313"><span class="linenos">4313</span></a> -</span><span id="L-4314"><a href="#L-4314"><span class="linenos">4314</span></a><span class="k">class</span> <span class="nc">Posexplode</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4315"><a href="#L-4315"><span class="linenos">4315</span></a> <span class="k">pass</span> -</span><span id="L-4316"><a href="#L-4316"><span class="linenos">4316</span></a> +</span><span id="L-4314"><a href="#L-4314"><span class="linenos">4314</span></a> +</span><span id="L-4315"><a href="#L-4315"><span class="linenos">4315</span></a><span class="k">class</span> <span class="nc">Nvl2</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4316"><a href="#L-4316"><span class="linenos">4316</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"true"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"false"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4317"><a href="#L-4317"><span class="linenos">4317</span></a> -</span><span id="L-4318"><a href="#L-4318"><span class="linenos">4318</span></a><span class="k">class</span> <span class="nc">Pow</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Func</span><span class="p">):</span> -</span><span id="L-4319"><a href="#L-4319"><span class="linenos">4319</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"POWER"</span><span class="p">,</span> <span class="s2">"POW"</span><span class="p">]</span> -</span><span id="L-4320"><a href="#L-4320"><span class="linenos">4320</span></a> +</span><span id="L-4318"><a href="#L-4318"><span class="linenos">4318</span></a> +</span><span id="L-4319"><a href="#L-4319"><span class="linenos">4319</span></a><span class="k">class</span> <span class="nc">Posexplode</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4320"><a href="#L-4320"><span class="linenos">4320</span></a> <span class="k">pass</span> </span><span id="L-4321"><a href="#L-4321"><span class="linenos">4321</span></a> -</span><span id="L-4322"><a href="#L-4322"><span class="linenos">4322</span></a><span class="k">class</span> <span class="nc">PercentileCont</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-4323"><a href="#L-4323"><span class="linenos">4323</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4324"><a href="#L-4324"><span class="linenos">4324</span></a> +</span><span id="L-4322"><a href="#L-4322"><span class="linenos">4322</span></a> +</span><span id="L-4323"><a href="#L-4323"><span class="linenos">4323</span></a><span class="k">class</span> <span class="nc">Pow</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Func</span><span class="p">):</span> +</span><span id="L-4324"><a href="#L-4324"><span class="linenos">4324</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"POWER"</span><span class="p">,</span> <span class="s2">"POW"</span><span class="p">]</span> </span><span id="L-4325"><a href="#L-4325"><span class="linenos">4325</span></a> -</span><span id="L-4326"><a href="#L-4326"><span class="linenos">4326</span></a><span class="k">class</span> <span class="nc">PercentileDisc</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-4327"><a href="#L-4327"><span class="linenos">4327</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4328"><a href="#L-4328"><span class="linenos">4328</span></a> +</span><span id="L-4326"><a href="#L-4326"><span class="linenos">4326</span></a> +</span><span id="L-4327"><a href="#L-4327"><span class="linenos">4327</span></a><span class="k">class</span> <span class="nc">PercentileCont</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-4328"><a href="#L-4328"><span class="linenos">4328</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4329"><a href="#L-4329"><span class="linenos">4329</span></a> -</span><span id="L-4330"><a href="#L-4330"><span class="linenos">4330</span></a><span class="k">class</span> <span class="nc">Quantile</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-4331"><a href="#L-4331"><span class="linenos">4331</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"quantile"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-4332"><a href="#L-4332"><span class="linenos">4332</span></a> +</span><span id="L-4330"><a href="#L-4330"><span class="linenos">4330</span></a> +</span><span id="L-4331"><a href="#L-4331"><span class="linenos">4331</span></a><span class="k">class</span> <span class="nc">PercentileDisc</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-4332"><a href="#L-4332"><span class="linenos">4332</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4333"><a href="#L-4333"><span class="linenos">4333</span></a> -</span><span id="L-4334"><a href="#L-4334"><span class="linenos">4334</span></a><span class="k">class</span> <span class="nc">ApproxQuantile</span><span class="p">(</span><span class="n">Quantile</span><span class="p">):</span> -</span><span id="L-4335"><a href="#L-4335"><span class="linenos">4335</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"quantile"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"accuracy"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4336"><a href="#L-4336"><span class="linenos">4336</span></a> +</span><span id="L-4334"><a href="#L-4334"><span class="linenos">4334</span></a> +</span><span id="L-4335"><a href="#L-4335"><span class="linenos">4335</span></a><span class="k">class</span> <span class="nc">Quantile</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-4336"><a href="#L-4336"><span class="linenos">4336</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"quantile"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-4337"><a href="#L-4337"><span class="linenos">4337</span></a> -</span><span id="L-4338"><a href="#L-4338"><span class="linenos">4338</span></a><span class="k">class</span> <span class="nc">RangeN</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4339"><a href="#L-4339"><span class="linenos">4339</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"each"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4340"><a href="#L-4340"><span class="linenos">4340</span></a> +</span><span id="L-4338"><a href="#L-4338"><span class="linenos">4338</span></a> +</span><span id="L-4339"><a href="#L-4339"><span class="linenos">4339</span></a><span class="k">class</span> <span class="nc">ApproxQuantile</span><span class="p">(</span><span class="n">Quantile</span><span class="p">):</span> +</span><span id="L-4340"><a href="#L-4340"><span class="linenos">4340</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"quantile"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"accuracy"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4341"><a href="#L-4341"><span class="linenos">4341</span></a> -</span><span id="L-4342"><a href="#L-4342"><span class="linenos">4342</span></a><span class="k">class</span> <span class="nc">ReadCSV</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4343"><a href="#L-4343"><span class="linenos">4343</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"READ_CSV"</span><span class="p">]</span> -</span><span id="L-4344"><a href="#L-4344"><span class="linenos">4344</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-4345"><a href="#L-4345"><span class="linenos">4345</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-4342"><a href="#L-4342"><span class="linenos">4342</span></a> +</span><span id="L-4343"><a href="#L-4343"><span class="linenos">4343</span></a><span class="k">class</span> <span class="nc">RangeN</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4344"><a href="#L-4344"><span class="linenos">4344</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"each"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-4345"><a href="#L-4345"><span class="linenos">4345</span></a> </span><span id="L-4346"><a href="#L-4346"><span class="linenos">4346</span></a> -</span><span id="L-4347"><a href="#L-4347"><span class="linenos">4347</span></a> -</span><span id="L-4348"><a href="#L-4348"><span class="linenos">4348</span></a><span class="k">class</span> <span class="nc">Reduce</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4349"><a href="#L-4349"><span class="linenos">4349</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"initial"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"merge"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"finish"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4350"><a href="#L-4350"><span class="linenos">4350</span></a> +</span><span id="L-4347"><a href="#L-4347"><span class="linenos">4347</span></a><span class="k">class</span> <span class="nc">ReadCSV</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4348"><a href="#L-4348"><span class="linenos">4348</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"READ_CSV"</span><span class="p">]</span> +</span><span id="L-4349"><a href="#L-4349"><span class="linenos">4349</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-4350"><a href="#L-4350"><span class="linenos">4350</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4351"><a href="#L-4351"><span class="linenos">4351</span></a> -</span><span id="L-4352"><a href="#L-4352"><span class="linenos">4352</span></a><span class="k">class</span> <span class="nc">RegexpExtract</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4353"><a href="#L-4353"><span class="linenos">4353</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-4354"><a href="#L-4354"><span class="linenos">4354</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-4355"><a href="#L-4355"><span class="linenos">4355</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-4356"><a href="#L-4356"><span class="linenos">4356</span></a> <span class="s2">"position"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4357"><a href="#L-4357"><span class="linenos">4357</span></a> <span class="s2">"occurrence"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4358"><a href="#L-4358"><span class="linenos">4358</span></a> <span class="s2">"group"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4359"><a href="#L-4359"><span class="linenos">4359</span></a> <span class="p">}</span> -</span><span id="L-4360"><a href="#L-4360"><span class="linenos">4360</span></a> -</span><span id="L-4361"><a href="#L-4361"><span class="linenos">4361</span></a> -</span><span id="L-4362"><a href="#L-4362"><span class="linenos">4362</span></a><span class="k">class</span> <span class="nc">RegexpLike</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4363"><a href="#L-4363"><span class="linenos">4363</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"flag"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4364"><a href="#L-4364"><span class="linenos">4364</span></a> +</span><span id="L-4352"><a href="#L-4352"><span class="linenos">4352</span></a> +</span><span id="L-4353"><a href="#L-4353"><span class="linenos">4353</span></a><span class="k">class</span> <span class="nc">Reduce</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4354"><a href="#L-4354"><span class="linenos">4354</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"initial"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"merge"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"finish"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-4355"><a href="#L-4355"><span class="linenos">4355</span></a> +</span><span id="L-4356"><a href="#L-4356"><span class="linenos">4356</span></a> +</span><span id="L-4357"><a href="#L-4357"><span class="linenos">4357</span></a><span class="k">class</span> <span class="nc">RegexpExtract</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4358"><a href="#L-4358"><span class="linenos">4358</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-4359"><a href="#L-4359"><span class="linenos">4359</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-4360"><a href="#L-4360"><span class="linenos">4360</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-4361"><a href="#L-4361"><span class="linenos">4361</span></a> <span class="s2">"position"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4362"><a href="#L-4362"><span class="linenos">4362</span></a> <span class="s2">"occurrence"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4363"><a href="#L-4363"><span class="linenos">4363</span></a> <span class="s2">"group"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4364"><a href="#L-4364"><span class="linenos">4364</span></a> <span class="p">}</span> </span><span id="L-4365"><a href="#L-4365"><span class="linenos">4365</span></a> -</span><span id="L-4366"><a href="#L-4366"><span class="linenos">4366</span></a><span class="k">class</span> <span class="nc">RegexpILike</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4367"><a href="#L-4367"><span class="linenos">4367</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"flag"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4368"><a href="#L-4368"><span class="linenos">4368</span></a> +</span><span id="L-4366"><a href="#L-4366"><span class="linenos">4366</span></a> +</span><span id="L-4367"><a href="#L-4367"><span class="linenos">4367</span></a><span class="k">class</span> <span class="nc">RegexpLike</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4368"><a href="#L-4368"><span class="linenos">4368</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"flag"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4369"><a href="#L-4369"><span class="linenos">4369</span></a> -</span><span id="L-4370"><a href="#L-4370"><span class="linenos">4370</span></a><span class="c1"># https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.functions.split.html</span> -</span><span id="L-4371"><a href="#L-4371"><span class="linenos">4371</span></a><span class="c1"># limit is the number of times a pattern is applied</span> -</span><span id="L-4372"><a href="#L-4372"><span class="linenos">4372</span></a><span class="k">class</span> <span class="nc">RegexpSplit</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4373"><a href="#L-4373"><span class="linenos">4373</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-4370"><a href="#L-4370"><span class="linenos">4370</span></a> +</span><span id="L-4371"><a href="#L-4371"><span class="linenos">4371</span></a><span class="k">class</span> <span class="nc">RegexpILike</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4372"><a href="#L-4372"><span class="linenos">4372</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"flag"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-4373"><a href="#L-4373"><span class="linenos">4373</span></a> </span><span id="L-4374"><a href="#L-4374"><span class="linenos">4374</span></a> -</span><span id="L-4375"><a href="#L-4375"><span class="linenos">4375</span></a> -</span><span id="L-4376"><a href="#L-4376"><span class="linenos">4376</span></a><span class="k">class</span> <span class="nc">Repeat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4377"><a href="#L-4377"><span class="linenos">4377</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"times"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-4378"><a href="#L-4378"><span class="linenos">4378</span></a> +</span><span id="L-4375"><a href="#L-4375"><span class="linenos">4375</span></a><span class="c1"># https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.functions.split.html</span> +</span><span id="L-4376"><a href="#L-4376"><span class="linenos">4376</span></a><span class="c1"># limit is the number of times a pattern is applied</span> +</span><span id="L-4377"><a href="#L-4377"><span class="linenos">4377</span></a><span class="k">class</span> <span class="nc">RegexpSplit</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4378"><a href="#L-4378"><span class="linenos">4378</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4379"><a href="#L-4379"><span class="linenos">4379</span></a> -</span><span id="L-4380"><a href="#L-4380"><span class="linenos">4380</span></a><span class="k">class</span> <span class="nc">Round</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4381"><a href="#L-4381"><span class="linenos">4381</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"decimals"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4382"><a href="#L-4382"><span class="linenos">4382</span></a> +</span><span id="L-4380"><a href="#L-4380"><span class="linenos">4380</span></a> +</span><span id="L-4381"><a href="#L-4381"><span class="linenos">4381</span></a><span class="k">class</span> <span class="nc">Repeat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4382"><a href="#L-4382"><span class="linenos">4382</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"times"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-4383"><a href="#L-4383"><span class="linenos">4383</span></a> -</span><span id="L-4384"><a href="#L-4384"><span class="linenos">4384</span></a><span class="k">class</span> <span class="nc">RowNumber</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4385"><a href="#L-4385"><span class="linenos">4385</span></a> <span class="n">arg_types</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-4386"><a href="#L-4386"><span class="linenos">4386</span></a> +</span><span id="L-4384"><a href="#L-4384"><span class="linenos">4384</span></a> +</span><span id="L-4385"><a href="#L-4385"><span class="linenos">4385</span></a><span class="k">class</span> <span class="nc">Round</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4386"><a href="#L-4386"><span class="linenos">4386</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"decimals"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4387"><a href="#L-4387"><span class="linenos">4387</span></a> -</span><span id="L-4388"><a href="#L-4388"><span class="linenos">4388</span></a><span class="k">class</span> <span class="nc">SafeDivide</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4389"><a href="#L-4389"><span class="linenos">4389</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-4390"><a href="#L-4390"><span class="linenos">4390</span></a> +</span><span id="L-4388"><a href="#L-4388"><span class="linenos">4388</span></a> +</span><span id="L-4389"><a href="#L-4389"><span class="linenos">4389</span></a><span class="k">class</span> <span class="nc">RowNumber</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4390"><a href="#L-4390"><span class="linenos">4390</span></a> <span class="n">arg_types</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> </span><span id="L-4391"><a href="#L-4391"><span class="linenos">4391</span></a> -</span><span id="L-4392"><a href="#L-4392"><span class="linenos">4392</span></a><span class="k">class</span> <span class="nc">SetAgg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-4393"><a href="#L-4393"><span class="linenos">4393</span></a> <span class="k">pass</span> -</span><span id="L-4394"><a href="#L-4394"><span class="linenos">4394</span></a> +</span><span id="L-4392"><a href="#L-4392"><span class="linenos">4392</span></a> +</span><span id="L-4393"><a href="#L-4393"><span class="linenos">4393</span></a><span class="k">class</span> <span class="nc">SafeDivide</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4394"><a href="#L-4394"><span class="linenos">4394</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-4395"><a href="#L-4395"><span class="linenos">4395</span></a> -</span><span id="L-4396"><a href="#L-4396"><span class="linenos">4396</span></a><span class="k">class</span> <span class="nc">SHA</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4397"><a href="#L-4397"><span class="linenos">4397</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"SHA"</span><span class="p">,</span> <span class="s2">"SHA1"</span><span class="p">]</span> -</span><span id="L-4398"><a href="#L-4398"><span class="linenos">4398</span></a> +</span><span id="L-4396"><a href="#L-4396"><span class="linenos">4396</span></a> +</span><span id="L-4397"><a href="#L-4397"><span class="linenos">4397</span></a><span class="k">class</span> <span class="nc">SetAgg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-4398"><a href="#L-4398"><span class="linenos">4398</span></a> <span class="k">pass</span> </span><span id="L-4399"><a href="#L-4399"><span class="linenos">4399</span></a> -</span><span id="L-4400"><a href="#L-4400"><span class="linenos">4400</span></a><span class="k">class</span> <span class="nc">SHA2</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4401"><a href="#L-4401"><span class="linenos">4401</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"SHA2"</span><span class="p">]</span> -</span><span id="L-4402"><a href="#L-4402"><span class="linenos">4402</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"length"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-4400"><a href="#L-4400"><span class="linenos">4400</span></a> +</span><span id="L-4401"><a href="#L-4401"><span class="linenos">4401</span></a><span class="k">class</span> <span class="nc">SHA</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4402"><a href="#L-4402"><span class="linenos">4402</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"SHA"</span><span class="p">,</span> <span class="s2">"SHA1"</span><span class="p">]</span> </span><span id="L-4403"><a href="#L-4403"><span class="linenos">4403</span></a> </span><span id="L-4404"><a href="#L-4404"><span class="linenos">4404</span></a> -</span><span id="L-4405"><a href="#L-4405"><span class="linenos">4405</span></a><span class="k">class</span> <span class="nc">SortArray</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4406"><a href="#L-4406"><span class="linenos">4406</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"asc"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4407"><a href="#L-4407"><span class="linenos">4407</span></a> +</span><span id="L-4405"><a href="#L-4405"><span class="linenos">4405</span></a><span class="k">class</span> <span class="nc">SHA2</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4406"><a href="#L-4406"><span class="linenos">4406</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"SHA2"</span><span class="p">]</span> +</span><span id="L-4407"><a href="#L-4407"><span class="linenos">4407</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"length"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4408"><a href="#L-4408"><span class="linenos">4408</span></a> -</span><span id="L-4409"><a href="#L-4409"><span class="linenos">4409</span></a><span class="k">class</span> <span class="nc">Split</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4410"><a href="#L-4410"><span class="linenos">4410</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4411"><a href="#L-4411"><span class="linenos">4411</span></a> +</span><span id="L-4409"><a href="#L-4409"><span class="linenos">4409</span></a> +</span><span id="L-4410"><a href="#L-4410"><span class="linenos">4410</span></a><span class="k">class</span> <span class="nc">SortArray</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4411"><a href="#L-4411"><span class="linenos">4411</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"asc"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4412"><a href="#L-4412"><span class="linenos">4412</span></a> -</span><span id="L-4413"><a href="#L-4413"><span class="linenos">4413</span></a><span class="c1"># Start may be omitted in the case of postgres</span> -</span><span id="L-4414"><a href="#L-4414"><span class="linenos">4414</span></a><span class="c1"># https://www.postgresql.org/docs/9.1/functions-string.html @ Table 9-6</span> -</span><span id="L-4415"><a href="#L-4415"><span class="linenos">4415</span></a><span class="k">class</span> <span class="nc">Substring</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4416"><a href="#L-4416"><span class="linenos">4416</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"length"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-4413"><a href="#L-4413"><span class="linenos">4413</span></a> +</span><span id="L-4414"><a href="#L-4414"><span class="linenos">4414</span></a><span class="k">class</span> <span class="nc">Split</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4415"><a href="#L-4415"><span class="linenos">4415</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-4416"><a href="#L-4416"><span class="linenos">4416</span></a> </span><span id="L-4417"><a href="#L-4417"><span class="linenos">4417</span></a> -</span><span id="L-4418"><a href="#L-4418"><span class="linenos">4418</span></a> -</span><span id="L-4419"><a href="#L-4419"><span class="linenos">4419</span></a><span class="k">class</span> <span class="nc">StandardHash</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4420"><a href="#L-4420"><span class="linenos">4420</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4421"><a href="#L-4421"><span class="linenos">4421</span></a> +</span><span id="L-4418"><a href="#L-4418"><span class="linenos">4418</span></a><span class="c1"># Start may be omitted in the case of postgres</span> +</span><span id="L-4419"><a href="#L-4419"><span class="linenos">4419</span></a><span class="c1"># https://www.postgresql.org/docs/9.1/functions-string.html @ Table 9-6</span> +</span><span id="L-4420"><a href="#L-4420"><span class="linenos">4420</span></a><span class="k">class</span> <span class="nc">Substring</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4421"><a href="#L-4421"><span class="linenos">4421</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"length"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4422"><a href="#L-4422"><span class="linenos">4422</span></a> -</span><span id="L-4423"><a href="#L-4423"><span class="linenos">4423</span></a><span class="k">class</span> <span class="nc">StrPosition</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4424"><a href="#L-4424"><span class="linenos">4424</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-4425"><a href="#L-4425"><span class="linenos">4425</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-4426"><a href="#L-4426"><span class="linenos">4426</span></a> <span class="s2">"substr"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-4427"><a href="#L-4427"><span class="linenos">4427</span></a> <span class="s2">"position"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4428"><a href="#L-4428"><span class="linenos">4428</span></a> <span class="s2">"instance"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4429"><a href="#L-4429"><span class="linenos">4429</span></a> <span class="p">}</span> -</span><span id="L-4430"><a href="#L-4430"><span class="linenos">4430</span></a> -</span><span id="L-4431"><a href="#L-4431"><span class="linenos">4431</span></a> -</span><span id="L-4432"><a href="#L-4432"><span class="linenos">4432</span></a><span class="k">class</span> <span class="nc">StrToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4433"><a href="#L-4433"><span class="linenos">4433</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-4434"><a href="#L-4434"><span class="linenos">4434</span></a> +</span><span id="L-4423"><a href="#L-4423"><span class="linenos">4423</span></a> +</span><span id="L-4424"><a href="#L-4424"><span class="linenos">4424</span></a><span class="k">class</span> <span class="nc">StandardHash</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4425"><a href="#L-4425"><span class="linenos">4425</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-4426"><a href="#L-4426"><span class="linenos">4426</span></a> +</span><span id="L-4427"><a href="#L-4427"><span class="linenos">4427</span></a> +</span><span id="L-4428"><a href="#L-4428"><span class="linenos">4428</span></a><span class="k">class</span> <span class="nc">StrPosition</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4429"><a href="#L-4429"><span class="linenos">4429</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-4430"><a href="#L-4430"><span class="linenos">4430</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-4431"><a href="#L-4431"><span class="linenos">4431</span></a> <span class="s2">"substr"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-4432"><a href="#L-4432"><span class="linenos">4432</span></a> <span class="s2">"position"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4433"><a href="#L-4433"><span class="linenos">4433</span></a> <span class="s2">"instance"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4434"><a href="#L-4434"><span class="linenos">4434</span></a> <span class="p">}</span> </span><span id="L-4435"><a href="#L-4435"><span class="linenos">4435</span></a> -</span><span id="L-4436"><a href="#L-4436"><span class="linenos">4436</span></a><span class="k">class</span> <span class="nc">StrToTime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4437"><a href="#L-4437"><span class="linenos">4437</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-4438"><a href="#L-4438"><span class="linenos">4438</span></a> +</span><span id="L-4436"><a href="#L-4436"><span class="linenos">4436</span></a> +</span><span id="L-4437"><a href="#L-4437"><span class="linenos">4437</span></a><span class="k">class</span> <span class="nc">StrToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4438"><a href="#L-4438"><span class="linenos">4438</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-4439"><a href="#L-4439"><span class="linenos">4439</span></a> -</span><span id="L-4440"><a href="#L-4440"><span class="linenos">4440</span></a><span class="c1"># Spark allows unix_timestamp()</span> -</span><span id="L-4441"><a href="#L-4441"><span class="linenos">4441</span></a><span class="c1"># https://spark.apache.org/docs/3.1.3/api/python/reference/api/pyspark.sql.functions.unix_timestamp.html</span> -</span><span id="L-4442"><a href="#L-4442"><span class="linenos">4442</span></a><span class="k">class</span> <span class="nc">StrToUnix</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4443"><a href="#L-4443"><span class="linenos">4443</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-4440"><a href="#L-4440"><span class="linenos">4440</span></a> +</span><span id="L-4441"><a href="#L-4441"><span class="linenos">4441</span></a><span class="k">class</span> <span class="nc">StrToTime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4442"><a href="#L-4442"><span class="linenos">4442</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-4443"><a href="#L-4443"><span class="linenos">4443</span></a> </span><span id="L-4444"><a href="#L-4444"><span class="linenos">4444</span></a> -</span><span id="L-4445"><a href="#L-4445"><span class="linenos">4445</span></a> -</span><span id="L-4446"><a href="#L-4446"><span class="linenos">4446</span></a><span class="k">class</span> <span class="nc">NumberToStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4447"><a href="#L-4447"><span class="linenos">4447</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-4448"><a href="#L-4448"><span class="linenos">4448</span></a> +</span><span id="L-4445"><a href="#L-4445"><span class="linenos">4445</span></a><span class="c1"># Spark allows unix_timestamp()</span> +</span><span id="L-4446"><a href="#L-4446"><span class="linenos">4446</span></a><span class="c1"># https://spark.apache.org/docs/3.1.3/api/python/reference/api/pyspark.sql.functions.unix_timestamp.html</span> +</span><span id="L-4447"><a href="#L-4447"><span class="linenos">4447</span></a><span class="k">class</span> <span class="nc">StrToUnix</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4448"><a href="#L-4448"><span class="linenos">4448</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4449"><a href="#L-4449"><span class="linenos">4449</span></a> -</span><span id="L-4450"><a href="#L-4450"><span class="linenos">4450</span></a><span class="k">class</span> <span class="nc">FromBase</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4451"><a href="#L-4451"><span class="linenos">4451</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-4452"><a href="#L-4452"><span class="linenos">4452</span></a> +</span><span id="L-4450"><a href="#L-4450"><span class="linenos">4450</span></a> +</span><span id="L-4451"><a href="#L-4451"><span class="linenos">4451</span></a><span class="k">class</span> <span class="nc">NumberToStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4452"><a href="#L-4452"><span class="linenos">4452</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-4453"><a href="#L-4453"><span class="linenos">4453</span></a> -</span><span id="L-4454"><a href="#L-4454"><span class="linenos">4454</span></a><span class="k">class</span> <span class="nc">Struct</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4455"><a href="#L-4455"><span class="linenos">4455</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-4456"><a href="#L-4456"><span class="linenos">4456</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-4454"><a href="#L-4454"><span class="linenos">4454</span></a> +</span><span id="L-4455"><a href="#L-4455"><span class="linenos">4455</span></a><span class="k">class</span> <span class="nc">FromBase</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4456"><a href="#L-4456"><span class="linenos">4456</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-4457"><a href="#L-4457"><span class="linenos">4457</span></a> </span><span id="L-4458"><a href="#L-4458"><span class="linenos">4458</span></a> -</span><span id="L-4459"><a href="#L-4459"><span class="linenos">4459</span></a><span class="k">class</span> <span class="nc">StructExtract</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4460"><a href="#L-4460"><span class="linenos">4460</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-4461"><a href="#L-4461"><span class="linenos">4461</span></a> +</span><span id="L-4459"><a href="#L-4459"><span class="linenos">4459</span></a><span class="k">class</span> <span class="nc">Struct</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4460"><a href="#L-4460"><span class="linenos">4460</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-4461"><a href="#L-4461"><span class="linenos">4461</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span><span id="L-4462"><a href="#L-4462"><span class="linenos">4462</span></a> -</span><span id="L-4463"><a href="#L-4463"><span class="linenos">4463</span></a><span class="k">class</span> <span class="nc">Sum</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-4464"><a href="#L-4464"><span class="linenos">4464</span></a> <span class="k">pass</span> -</span><span id="L-4465"><a href="#L-4465"><span class="linenos">4465</span></a> +</span><span id="L-4463"><a href="#L-4463"><span class="linenos">4463</span></a> +</span><span id="L-4464"><a href="#L-4464"><span class="linenos">4464</span></a><span class="k">class</span> <span class="nc">StructExtract</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4465"><a href="#L-4465"><span class="linenos">4465</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-4466"><a href="#L-4466"><span class="linenos">4466</span></a> -</span><span id="L-4467"><a href="#L-4467"><span class="linenos">4467</span></a><span class="k">class</span> <span class="nc">Sqrt</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4468"><a href="#L-4468"><span class="linenos">4468</span></a> <span class="k">pass</span> -</span><span id="L-4469"><a href="#L-4469"><span class="linenos">4469</span></a> +</span><span id="L-4467"><a href="#L-4467"><span class="linenos">4467</span></a> +</span><span id="L-4468"><a href="#L-4468"><span class="linenos">4468</span></a><span class="k">class</span> <span class="nc">Sum</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-4469"><a href="#L-4469"><span class="linenos">4469</span></a> <span class="k">pass</span> </span><span id="L-4470"><a href="#L-4470"><span class="linenos">4470</span></a> -</span><span id="L-4471"><a href="#L-4471"><span class="linenos">4471</span></a><span class="k">class</span> <span class="nc">Stddev</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-4472"><a href="#L-4472"><span class="linenos">4472</span></a> <span class="k">pass</span> -</span><span id="L-4473"><a href="#L-4473"><span class="linenos">4473</span></a> +</span><span id="L-4471"><a href="#L-4471"><span class="linenos">4471</span></a> +</span><span id="L-4472"><a href="#L-4472"><span class="linenos">4472</span></a><span class="k">class</span> <span class="nc">Sqrt</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4473"><a href="#L-4473"><span class="linenos">4473</span></a> <span class="k">pass</span> </span><span id="L-4474"><a href="#L-4474"><span class="linenos">4474</span></a> -</span><span id="L-4475"><a href="#L-4475"><span class="linenos">4475</span></a><span class="k">class</span> <span class="nc">StddevPop</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-4476"><a href="#L-4476"><span class="linenos">4476</span></a> <span class="k">pass</span> -</span><span id="L-4477"><a href="#L-4477"><span class="linenos">4477</span></a> +</span><span id="L-4475"><a href="#L-4475"><span class="linenos">4475</span></a> +</span><span id="L-4476"><a href="#L-4476"><span class="linenos">4476</span></a><span class="k">class</span> <span class="nc">Stddev</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-4477"><a href="#L-4477"><span class="linenos">4477</span></a> <span class="k">pass</span> </span><span id="L-4478"><a href="#L-4478"><span class="linenos">4478</span></a> -</span><span id="L-4479"><a href="#L-4479"><span class="linenos">4479</span></a><span class="k">class</span> <span class="nc">StddevSamp</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-4480"><a href="#L-4480"><span class="linenos">4480</span></a> <span class="k">pass</span> -</span><span id="L-4481"><a href="#L-4481"><span class="linenos">4481</span></a> +</span><span id="L-4479"><a href="#L-4479"><span class="linenos">4479</span></a> +</span><span id="L-4480"><a href="#L-4480"><span class="linenos">4480</span></a><span class="k">class</span> <span class="nc">StddevPop</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-4481"><a href="#L-4481"><span class="linenos">4481</span></a> <span class="k">pass</span> </span><span id="L-4482"><a href="#L-4482"><span class="linenos">4482</span></a> -</span><span id="L-4483"><a href="#L-4483"><span class="linenos">4483</span></a><span class="k">class</span> <span class="nc">TimeToStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4484"><a href="#L-4484"><span class="linenos">4484</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-4485"><a href="#L-4485"><span class="linenos">4485</span></a> +</span><span id="L-4483"><a href="#L-4483"><span class="linenos">4483</span></a> +</span><span id="L-4484"><a href="#L-4484"><span class="linenos">4484</span></a><span class="k">class</span> <span class="nc">StddevSamp</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-4485"><a href="#L-4485"><span class="linenos">4485</span></a> <span class="k">pass</span> </span><span id="L-4486"><a href="#L-4486"><span class="linenos">4486</span></a> -</span><span id="L-4487"><a href="#L-4487"><span class="linenos">4487</span></a><span class="k">class</span> <span class="nc">TimeToTimeStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4488"><a href="#L-4488"><span class="linenos">4488</span></a> <span class="k">pass</span> -</span><span id="L-4489"><a href="#L-4489"><span class="linenos">4489</span></a> +</span><span id="L-4487"><a href="#L-4487"><span class="linenos">4487</span></a> +</span><span id="L-4488"><a href="#L-4488"><span class="linenos">4488</span></a><span class="k">class</span> <span class="nc">TimeToStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4489"><a href="#L-4489"><span class="linenos">4489</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-4490"><a href="#L-4490"><span class="linenos">4490</span></a> -</span><span id="L-4491"><a href="#L-4491"><span class="linenos">4491</span></a><span class="k">class</span> <span class="nc">TimeToUnix</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4492"><a href="#L-4492"><span class="linenos">4492</span></a> <span class="k">pass</span> -</span><span id="L-4493"><a href="#L-4493"><span class="linenos">4493</span></a> +</span><span id="L-4491"><a href="#L-4491"><span class="linenos">4491</span></a> +</span><span id="L-4492"><a href="#L-4492"><span class="linenos">4492</span></a><span class="k">class</span> <span class="nc">TimeToTimeStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4493"><a href="#L-4493"><span class="linenos">4493</span></a> <span class="k">pass</span> </span><span id="L-4494"><a href="#L-4494"><span class="linenos">4494</span></a> -</span><span id="L-4495"><a href="#L-4495"><span class="linenos">4495</span></a><span class="k">class</span> <span class="nc">TimeStrToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4496"><a href="#L-4496"><span class="linenos">4496</span></a> <span class="k">pass</span> -</span><span id="L-4497"><a href="#L-4497"><span class="linenos">4497</span></a> +</span><span id="L-4495"><a href="#L-4495"><span class="linenos">4495</span></a> +</span><span id="L-4496"><a href="#L-4496"><span class="linenos">4496</span></a><span class="k">class</span> <span class="nc">TimeToUnix</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4497"><a href="#L-4497"><span class="linenos">4497</span></a> <span class="k">pass</span> </span><span id="L-4498"><a href="#L-4498"><span class="linenos">4498</span></a> -</span><span id="L-4499"><a href="#L-4499"><span class="linenos">4499</span></a><span class="k">class</span> <span class="nc">TimeStrToTime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4500"><a href="#L-4500"><span class="linenos">4500</span></a> <span class="k">pass</span> -</span><span id="L-4501"><a href="#L-4501"><span class="linenos">4501</span></a> +</span><span id="L-4499"><a href="#L-4499"><span class="linenos">4499</span></a> +</span><span id="L-4500"><a href="#L-4500"><span class="linenos">4500</span></a><span class="k">class</span> <span class="nc">TimeStrToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4501"><a href="#L-4501"><span class="linenos">4501</span></a> <span class="k">pass</span> </span><span id="L-4502"><a href="#L-4502"><span class="linenos">4502</span></a> -</span><span id="L-4503"><a href="#L-4503"><span class="linenos">4503</span></a><span class="k">class</span> <span class="nc">TimeStrToUnix</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4504"><a href="#L-4504"><span class="linenos">4504</span></a> <span class="k">pass</span> -</span><span id="L-4505"><a href="#L-4505"><span class="linenos">4505</span></a> +</span><span id="L-4503"><a href="#L-4503"><span class="linenos">4503</span></a> +</span><span id="L-4504"><a href="#L-4504"><span class="linenos">4504</span></a><span class="k">class</span> <span class="nc">TimeStrToTime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4505"><a href="#L-4505"><span class="linenos">4505</span></a> <span class="k">pass</span> </span><span id="L-4506"><a href="#L-4506"><span class="linenos">4506</span></a> -</span><span id="L-4507"><a href="#L-4507"><span class="linenos">4507</span></a><span class="k">class</span> <span class="nc">Trim</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4508"><a href="#L-4508"><span class="linenos">4508</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-4509"><a href="#L-4509"><span class="linenos">4509</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-4510"><a href="#L-4510"><span class="linenos">4510</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4511"><a href="#L-4511"><span class="linenos">4511</span></a> <span class="s2">"position"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4512"><a href="#L-4512"><span class="linenos">4512</span></a> <span class="s2">"collation"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4513"><a href="#L-4513"><span class="linenos">4513</span></a> <span class="p">}</span> -</span><span id="L-4514"><a href="#L-4514"><span class="linenos">4514</span></a> -</span><span id="L-4515"><a href="#L-4515"><span class="linenos">4515</span></a> -</span><span id="L-4516"><a href="#L-4516"><span class="linenos">4516</span></a><span class="k">class</span> <span class="nc">TsOrDsAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="L-4517"><a href="#L-4517"><span class="linenos">4517</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4518"><a href="#L-4518"><span class="linenos">4518</span></a> +</span><span id="L-4507"><a href="#L-4507"><span class="linenos">4507</span></a> +</span><span id="L-4508"><a href="#L-4508"><span class="linenos">4508</span></a><span class="k">class</span> <span class="nc">TimeStrToUnix</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4509"><a href="#L-4509"><span class="linenos">4509</span></a> <span class="k">pass</span> +</span><span id="L-4510"><a href="#L-4510"><span class="linenos">4510</span></a> +</span><span id="L-4511"><a href="#L-4511"><span class="linenos">4511</span></a> +</span><span id="L-4512"><a href="#L-4512"><span class="linenos">4512</span></a><span class="k">class</span> <span class="nc">Trim</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4513"><a href="#L-4513"><span class="linenos">4513</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-4514"><a href="#L-4514"><span class="linenos">4514</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-4515"><a href="#L-4515"><span class="linenos">4515</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4516"><a href="#L-4516"><span class="linenos">4516</span></a> <span class="s2">"position"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4517"><a href="#L-4517"><span class="linenos">4517</span></a> <span class="s2">"collation"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4518"><a href="#L-4518"><span class="linenos">4518</span></a> <span class="p">}</span> </span><span id="L-4519"><a href="#L-4519"><span class="linenos">4519</span></a> -</span><span id="L-4520"><a href="#L-4520"><span class="linenos">4520</span></a><span class="k">class</span> <span class="nc">TsOrDsToDateStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4521"><a href="#L-4521"><span class="linenos">4521</span></a> <span class="k">pass</span> -</span><span id="L-4522"><a href="#L-4522"><span class="linenos">4522</span></a> +</span><span id="L-4520"><a href="#L-4520"><span class="linenos">4520</span></a> +</span><span id="L-4521"><a href="#L-4521"><span class="linenos">4521</span></a><span class="k">class</span> <span class="nc">TsOrDsAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="L-4522"><a href="#L-4522"><span class="linenos">4522</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4523"><a href="#L-4523"><span class="linenos">4523</span></a> -</span><span id="L-4524"><a href="#L-4524"><span class="linenos">4524</span></a><span class="k">class</span> <span class="nc">TsOrDsToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4525"><a href="#L-4525"><span class="linenos">4525</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4526"><a href="#L-4526"><span class="linenos">4526</span></a> +</span><span id="L-4524"><a href="#L-4524"><span class="linenos">4524</span></a> +</span><span id="L-4525"><a href="#L-4525"><span class="linenos">4525</span></a><span class="k">class</span> <span class="nc">TsOrDsToDateStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4526"><a href="#L-4526"><span class="linenos">4526</span></a> <span class="k">pass</span> </span><span id="L-4527"><a href="#L-4527"><span class="linenos">4527</span></a> -</span><span id="L-4528"><a href="#L-4528"><span class="linenos">4528</span></a><span class="k">class</span> <span class="nc">TsOrDiToDi</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4529"><a href="#L-4529"><span class="linenos">4529</span></a> <span class="k">pass</span> -</span><span id="L-4530"><a href="#L-4530"><span class="linenos">4530</span></a> +</span><span id="L-4528"><a href="#L-4528"><span class="linenos">4528</span></a> +</span><span id="L-4529"><a href="#L-4529"><span class="linenos">4529</span></a><span class="k">class</span> <span class="nc">TsOrDsToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4530"><a href="#L-4530"><span class="linenos">4530</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4531"><a href="#L-4531"><span class="linenos">4531</span></a> -</span><span id="L-4532"><a href="#L-4532"><span class="linenos">4532</span></a><span class="k">class</span> <span class="nc">Unhex</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4533"><a href="#L-4533"><span class="linenos">4533</span></a> <span class="k">pass</span> -</span><span id="L-4534"><a href="#L-4534"><span class="linenos">4534</span></a> +</span><span id="L-4532"><a href="#L-4532"><span class="linenos">4532</span></a> +</span><span id="L-4533"><a href="#L-4533"><span class="linenos">4533</span></a><span class="k">class</span> <span class="nc">TsOrDiToDi</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4534"><a href="#L-4534"><span class="linenos">4534</span></a> <span class="k">pass</span> </span><span id="L-4535"><a href="#L-4535"><span class="linenos">4535</span></a> -</span><span id="L-4536"><a href="#L-4536"><span class="linenos">4536</span></a><span class="k">class</span> <span class="nc">UnixToStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4537"><a href="#L-4537"><span class="linenos">4537</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4538"><a href="#L-4538"><span class="linenos">4538</span></a> +</span><span id="L-4536"><a href="#L-4536"><span class="linenos">4536</span></a> +</span><span id="L-4537"><a href="#L-4537"><span class="linenos">4537</span></a><span class="k">class</span> <span class="nc">Unhex</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4538"><a href="#L-4538"><span class="linenos">4538</span></a> <span class="k">pass</span> </span><span id="L-4539"><a href="#L-4539"><span class="linenos">4539</span></a> -</span><span id="L-4540"><a href="#L-4540"><span class="linenos">4540</span></a><span class="c1"># https://prestodb.io/docs/current/functions/datetime.html</span> -</span><span id="L-4541"><a href="#L-4541"><span class="linenos">4541</span></a><span class="c1"># presto has weird zone/hours/minutes</span> -</span><span id="L-4542"><a href="#L-4542"><span class="linenos">4542</span></a><span class="k">class</span> <span class="nc">UnixToTime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4543"><a href="#L-4543"><span class="linenos">4543</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"scale"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"hours"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"minutes"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-4540"><a href="#L-4540"><span class="linenos">4540</span></a> +</span><span id="L-4541"><a href="#L-4541"><span class="linenos">4541</span></a><span class="k">class</span> <span class="nc">UnixToStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4542"><a href="#L-4542"><span class="linenos">4542</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-4543"><a href="#L-4543"><span class="linenos">4543</span></a> </span><span id="L-4544"><a href="#L-4544"><span class="linenos">4544</span></a> -</span><span id="L-4545"><a href="#L-4545"><span class="linenos">4545</span></a> <span class="n">SECONDS</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">"seconds"</span><span class="p">)</span> -</span><span id="L-4546"><a href="#L-4546"><span class="linenos">4546</span></a> <span class="n">MILLIS</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">"millis"</span><span class="p">)</span> -</span><span id="L-4547"><a href="#L-4547"><span class="linenos">4547</span></a> <span class="n">MICROS</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">"micros"</span><span class="p">)</span> -</span><span id="L-4548"><a href="#L-4548"><span class="linenos">4548</span></a> +</span><span id="L-4545"><a href="#L-4545"><span class="linenos">4545</span></a><span class="c1"># https://prestodb.io/docs/current/functions/datetime.html</span> +</span><span id="L-4546"><a href="#L-4546"><span class="linenos">4546</span></a><span class="c1"># presto has weird zone/hours/minutes</span> +</span><span id="L-4547"><a href="#L-4547"><span class="linenos">4547</span></a><span class="k">class</span> <span class="nc">UnixToTime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4548"><a href="#L-4548"><span class="linenos">4548</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"scale"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"hours"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"minutes"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4549"><a href="#L-4549"><span class="linenos">4549</span></a> -</span><span id="L-4550"><a href="#L-4550"><span class="linenos">4550</span></a><span class="k">class</span> <span class="nc">UnixToTimeStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4551"><a href="#L-4551"><span class="linenos">4551</span></a> <span class="k">pass</span> -</span><span id="L-4552"><a href="#L-4552"><span class="linenos">4552</span></a> +</span><span id="L-4550"><a href="#L-4550"><span class="linenos">4550</span></a> <span class="n">SECONDS</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">"seconds"</span><span class="p">)</span> +</span><span id="L-4551"><a href="#L-4551"><span class="linenos">4551</span></a> <span class="n">MILLIS</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">"millis"</span><span class="p">)</span> +</span><span id="L-4552"><a href="#L-4552"><span class="linenos">4552</span></a> <span class="n">MICROS</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">"micros"</span><span class="p">)</span> </span><span id="L-4553"><a href="#L-4553"><span class="linenos">4553</span></a> -</span><span id="L-4554"><a href="#L-4554"><span class="linenos">4554</span></a><span class="k">class</span> <span class="nc">Upper</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4555"><a href="#L-4555"><span class="linenos">4555</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"UPPER"</span><span class="p">,</span> <span class="s2">"UCASE"</span><span class="p">]</span> -</span><span id="L-4556"><a href="#L-4556"><span class="linenos">4556</span></a> +</span><span id="L-4554"><a href="#L-4554"><span class="linenos">4554</span></a> +</span><span id="L-4555"><a href="#L-4555"><span class="linenos">4555</span></a><span class="k">class</span> <span class="nc">UnixToTimeStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4556"><a href="#L-4556"><span class="linenos">4556</span></a> <span class="k">pass</span> </span><span id="L-4557"><a href="#L-4557"><span class="linenos">4557</span></a> -</span><span id="L-4558"><a href="#L-4558"><span class="linenos">4558</span></a><span class="k">class</span> <span class="nc">Variance</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-4559"><a href="#L-4559"><span class="linenos">4559</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"VARIANCE"</span><span class="p">,</span> <span class="s2">"VARIANCE_SAMP"</span><span class="p">,</span> <span class="s2">"VAR_SAMP"</span><span class="p">]</span> -</span><span id="L-4560"><a href="#L-4560"><span class="linenos">4560</span></a> +</span><span id="L-4558"><a href="#L-4558"><span class="linenos">4558</span></a> +</span><span id="L-4559"><a href="#L-4559"><span class="linenos">4559</span></a><span class="k">class</span> <span class="nc">Upper</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4560"><a href="#L-4560"><span class="linenos">4560</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"UPPER"</span><span class="p">,</span> <span class="s2">"UCASE"</span><span class="p">]</span> </span><span id="L-4561"><a href="#L-4561"><span class="linenos">4561</span></a> -</span><span id="L-4562"><a href="#L-4562"><span class="linenos">4562</span></a><span class="k">class</span> <span class="nc">VariancePop</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="L-4563"><a href="#L-4563"><span class="linenos">4563</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"VARIANCE_POP"</span><span class="p">,</span> <span class="s2">"VAR_POP"</span><span class="p">]</span> -</span><span id="L-4564"><a href="#L-4564"><span class="linenos">4564</span></a> +</span><span id="L-4562"><a href="#L-4562"><span class="linenos">4562</span></a> +</span><span id="L-4563"><a href="#L-4563"><span class="linenos">4563</span></a><span class="k">class</span> <span class="nc">Variance</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-4564"><a href="#L-4564"><span class="linenos">4564</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"VARIANCE"</span><span class="p">,</span> <span class="s2">"VARIANCE_SAMP"</span><span class="p">,</span> <span class="s2">"VAR_SAMP"</span><span class="p">]</span> </span><span id="L-4565"><a href="#L-4565"><span class="linenos">4565</span></a> -</span><span id="L-4566"><a href="#L-4566"><span class="linenos">4566</span></a><span class="k">class</span> <span class="nc">Week</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4567"><a href="#L-4567"><span class="linenos">4567</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"mode"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4568"><a href="#L-4568"><span class="linenos">4568</span></a> +</span><span id="L-4566"><a href="#L-4566"><span class="linenos">4566</span></a> +</span><span id="L-4567"><a href="#L-4567"><span class="linenos">4567</span></a><span class="k">class</span> <span class="nc">VariancePop</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="L-4568"><a href="#L-4568"><span class="linenos">4568</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"VARIANCE_POP"</span><span class="p">,</span> <span class="s2">"VAR_POP"</span><span class="p">]</span> </span><span id="L-4569"><a href="#L-4569"><span class="linenos">4569</span></a> -</span><span id="L-4570"><a href="#L-4570"><span class="linenos">4570</span></a><span class="k">class</span> <span class="nc">XMLTable</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4571"><a href="#L-4571"><span class="linenos">4571</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"passing"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"columns"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"by_ref"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4572"><a href="#L-4572"><span class="linenos">4572</span></a> +</span><span id="L-4570"><a href="#L-4570"><span class="linenos">4570</span></a> +</span><span id="L-4571"><a href="#L-4571"><span class="linenos">4571</span></a><span class="k">class</span> <span class="nc">Week</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4572"><a href="#L-4572"><span class="linenos">4572</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"mode"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4573"><a href="#L-4573"><span class="linenos">4573</span></a> -</span><span id="L-4574"><a href="#L-4574"><span class="linenos">4574</span></a><span class="k">class</span> <span class="nc">Year</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4575"><a href="#L-4575"><span class="linenos">4575</span></a> <span class="k">pass</span> -</span><span id="L-4576"><a href="#L-4576"><span class="linenos">4576</span></a> +</span><span id="L-4574"><a href="#L-4574"><span class="linenos">4574</span></a> +</span><span id="L-4575"><a href="#L-4575"><span class="linenos">4575</span></a><span class="k">class</span> <span class="nc">XMLTable</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4576"><a href="#L-4576"><span class="linenos">4576</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"passing"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"columns"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"by_ref"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4577"><a href="#L-4577"><span class="linenos">4577</span></a> -</span><span id="L-4578"><a href="#L-4578"><span class="linenos">4578</span></a><span class="k">class</span> <span class="nc">Use</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-4579"><a href="#L-4579"><span class="linenos">4579</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="L-4580"><a href="#L-4580"><span class="linenos">4580</span></a> +</span><span id="L-4578"><a href="#L-4578"><span class="linenos">4578</span></a> +</span><span id="L-4579"><a href="#L-4579"><span class="linenos">4579</span></a><span class="k">class</span> <span class="nc">Year</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4580"><a href="#L-4580"><span class="linenos">4580</span></a> <span class="k">pass</span> </span><span id="L-4581"><a href="#L-4581"><span class="linenos">4581</span></a> -</span><span id="L-4582"><a href="#L-4582"><span class="linenos">4582</span></a><span class="k">class</span> <span class="nc">Merge</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-4583"><a href="#L-4583"><span class="linenos">4583</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-4584"><a href="#L-4584"><span class="linenos">4584</span></a> +</span><span id="L-4582"><a href="#L-4582"><span class="linenos">4582</span></a> +</span><span id="L-4583"><a href="#L-4583"><span class="linenos">4583</span></a><span class="k">class</span> <span class="nc">Use</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-4584"><a href="#L-4584"><span class="linenos">4584</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4585"><a href="#L-4585"><span class="linenos">4585</span></a> -</span><span id="L-4586"><a href="#L-4586"><span class="linenos">4586</span></a><span class="k">class</span> <span class="nc">When</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4587"><a href="#L-4587"><span class="linenos">4587</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"matched"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"source"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"then"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="L-4588"><a href="#L-4588"><span class="linenos">4588</span></a> +</span><span id="L-4586"><a href="#L-4586"><span class="linenos">4586</span></a> +</span><span id="L-4587"><a href="#L-4587"><span class="linenos">4587</span></a><span class="k">class</span> <span class="nc">Merge</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-4588"><a href="#L-4588"><span class="linenos">4588</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span><span id="L-4589"><a href="#L-4589"><span class="linenos">4589</span></a> -</span><span id="L-4590"><a href="#L-4590"><span class="linenos">4590</span></a><span class="c1"># https://docs.oracle.com/javadb/10.8.3.0/ref/rrefsqljnextvaluefor.html</span> -</span><span id="L-4591"><a href="#L-4591"><span class="linenos">4591</span></a><span class="c1"># https://learn.microsoft.com/en-us/sql/t-sql/functions/next-value-for-transact-sql?view=sql-server-ver16</span> -</span><span id="L-4592"><a href="#L-4592"><span class="linenos">4592</span></a><span class="k">class</span> <span class="nc">NextValueFor</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-4593"><a href="#L-4593"><span class="linenos">4593</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="L-4590"><a href="#L-4590"><span class="linenos">4590</span></a> +</span><span id="L-4591"><a href="#L-4591"><span class="linenos">4591</span></a><span class="k">class</span> <span class="nc">When</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4592"><a href="#L-4592"><span class="linenos">4592</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"matched"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"source"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"then"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="L-4593"><a href="#L-4593"><span class="linenos">4593</span></a> </span><span id="L-4594"><a href="#L-4594"><span class="linenos">4594</span></a> -</span><span id="L-4595"><a href="#L-4595"><span class="linenos">4595</span></a> -</span><span id="L-4596"><a href="#L-4596"><span class="linenos">4596</span></a><span class="k">def</span> <span class="nf">_norm_arg</span><span class="p">(</span><span class="n">arg</span><span class="p">):</span> -</span><span id="L-4597"><a href="#L-4597"><span class="linenos">4597</span></a> <span class="k">return</span> <span class="n">arg</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="ow">is</span> <span class="nb">str</span> <span class="k">else</span> <span class="n">arg</span> -</span><span id="L-4598"><a href="#L-4598"><span class="linenos">4598</span></a> +</span><span id="L-4595"><a href="#L-4595"><span class="linenos">4595</span></a><span class="c1"># https://docs.oracle.com/javadb/10.8.3.0/ref/rrefsqljnextvaluefor.html</span> +</span><span id="L-4596"><a href="#L-4596"><span class="linenos">4596</span></a><span class="c1"># https://learn.microsoft.com/en-us/sql/t-sql/functions/next-value-for-transact-sql?view=sql-server-ver16</span> +</span><span id="L-4597"><a href="#L-4597"><span class="linenos">4597</span></a><span class="k">class</span> <span class="nc">NextValueFor</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-4598"><a href="#L-4598"><span class="linenos">4598</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span><span id="L-4599"><a href="#L-4599"><span class="linenos">4599</span></a> -</span><span id="L-4600"><a href="#L-4600"><span class="linenos">4600</span></a><span class="n">ALL_FUNCTIONS</span> <span class="o">=</span> <span class="n">subclasses</span><span class="p">(</span><span class="vm">__name__</span><span class="p">,</span> <span class="n">Func</span><span class="p">,</span> <span class="p">(</span><span class="n">AggFunc</span><span class="p">,</span> <span class="n">Anonymous</span><span class="p">,</span> <span class="n">Func</span><span class="p">))</span> -</span><span id="L-4601"><a href="#L-4601"><span class="linenos">4601</span></a> -</span><span id="L-4602"><a href="#L-4602"><span class="linenos">4602</span></a> -</span><span id="L-4603"><a href="#L-4603"><span class="linenos">4603</span></a><span class="c1"># Helpers</span> -</span><span id="L-4604"><a href="#L-4604"><span class="linenos">4604</span></a><span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="L-4605"><a href="#L-4605"><span class="linenos">4605</span></a><span class="k">def</span> <span class="nf">maybe_parse</span><span class="p">(</span> -</span><span id="L-4606"><a href="#L-4606"><span class="linenos">4606</span></a> <span class="n">sql_or_expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="L-4607"><a href="#L-4607"><span class="linenos">4607</span></a> <span class="o">*</span><span class="p">,</span> -</span><span id="L-4608"><a href="#L-4608"><span class="linenos">4608</span></a> <span class="n">into</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> -</span><span id="L-4609"><a href="#L-4609"><span class="linenos">4609</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-4610"><a href="#L-4610"><span class="linenos">4610</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-4611"><a href="#L-4611"><span class="linenos">4611</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4612"><a href="#L-4612"><span class="linenos">4612</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-4613"><a href="#L-4613"><span class="linenos">4613</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="L-4614"><a href="#L-4614"><span class="linenos">4614</span></a> <span class="o">...</span> -</span><span id="L-4615"><a href="#L-4615"><span class="linenos">4615</span></a> -</span><span id="L-4616"><a href="#L-4616"><span class="linenos">4616</span></a> -</span><span id="L-4617"><a href="#L-4617"><span class="linenos">4617</span></a><span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="L-4618"><a href="#L-4618"><span class="linenos">4618</span></a><span class="k">def</span> <span class="nf">maybe_parse</span><span class="p">(</span> -</span><span id="L-4619"><a href="#L-4619"><span class="linenos">4619</span></a> <span class="n">sql_or_expression</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">E</span><span class="p">,</span> -</span><span id="L-4620"><a href="#L-4620"><span class="linenos">4620</span></a> <span class="o">*</span><span class="p">,</span> -</span><span id="L-4621"><a href="#L-4621"><span class="linenos">4621</span></a> <span class="n">into</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">IntoType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-4622"><a href="#L-4622"><span class="linenos">4622</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-4623"><a href="#L-4623"><span class="linenos">4623</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-4624"><a href="#L-4624"><span class="linenos">4624</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4625"><a href="#L-4625"><span class="linenos">4625</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-4626"><a href="#L-4626"><span class="linenos">4626</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="L-4627"><a href="#L-4627"><span class="linenos">4627</span></a> <span class="o">...</span> -</span><span id="L-4628"><a href="#L-4628"><span class="linenos">4628</span></a> -</span><span id="L-4629"><a href="#L-4629"><span class="linenos">4629</span></a> -</span><span id="L-4630"><a href="#L-4630"><span class="linenos">4630</span></a><span class="k">def</span> <span class="nf">maybe_parse</span><span class="p">(</span> -</span><span id="L-4631"><a href="#L-4631"><span class="linenos">4631</span></a> <span class="n">sql_or_expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="L-4632"><a href="#L-4632"><span class="linenos">4632</span></a> <span class="o">*</span><span class="p">,</span> -</span><span id="L-4633"><a href="#L-4633"><span class="linenos">4633</span></a> <span class="n">into</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">IntoType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-4634"><a href="#L-4634"><span class="linenos">4634</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-4635"><a href="#L-4635"><span class="linenos">4635</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-4636"><a href="#L-4636"><span class="linenos">4636</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-4637"><a href="#L-4637"><span class="linenos">4637</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-4638"><a href="#L-4638"><span class="linenos">4638</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> -</span><span id="L-4639"><a href="#L-4639"><span class="linenos">4639</span></a><span class="w"> </span><span class="sd">"""Gracefully handle a possible string or expression.</span> -</span><span id="L-4640"><a href="#L-4640"><span class="linenos">4640</span></a> -</span><span id="L-4641"><a href="#L-4641"><span class="linenos">4641</span></a><span class="sd"> Example:</span> -</span><span id="L-4642"><a href="#L-4642"><span class="linenos">4642</span></a><span class="sd"> >>> maybe_parse("1")</span> -</span><span id="L-4643"><a href="#L-4643"><span class="linenos">4643</span></a><span class="sd"> (LITERAL this: 1, is_string: False)</span> -</span><span id="L-4644"><a href="#L-4644"><span class="linenos">4644</span></a><span class="sd"> >>> maybe_parse(to_identifier("x"))</span> -</span><span id="L-4645"><a href="#L-4645"><span class="linenos">4645</span></a><span class="sd"> (IDENTIFIER this: x, quoted: False)</span> -</span><span id="L-4646"><a href="#L-4646"><span class="linenos">4646</span></a> -</span><span id="L-4647"><a href="#L-4647"><span class="linenos">4647</span></a><span class="sd"> Args:</span> -</span><span id="L-4648"><a href="#L-4648"><span class="linenos">4648</span></a><span class="sd"> sql_or_expression: the SQL code string or an expression</span> -</span><span id="L-4649"><a href="#L-4649"><span class="linenos">4649</span></a><span class="sd"> into: the SQLGlot Expression to parse into</span> -</span><span id="L-4650"><a href="#L-4650"><span class="linenos">4650</span></a><span class="sd"> dialect: the dialect used to parse the input expressions (in the case that an</span> -</span><span id="L-4651"><a href="#L-4651"><span class="linenos">4651</span></a><span class="sd"> input expression is a SQL string).</span> -</span><span id="L-4652"><a href="#L-4652"><span class="linenos">4652</span></a><span class="sd"> prefix: a string to prefix the sql with before it gets parsed</span> -</span><span id="L-4653"><a href="#L-4653"><span class="linenos">4653</span></a><span class="sd"> (automatically includes a space)</span> -</span><span id="L-4654"><a href="#L-4654"><span class="linenos">4654</span></a><span class="sd"> copy: whether or not to copy the expression.</span> -</span><span id="L-4655"><a href="#L-4655"><span class="linenos">4655</span></a><span class="sd"> **opts: other options to use to parse the input expressions (again, in the case</span> -</span><span id="L-4656"><a href="#L-4656"><span class="linenos">4656</span></a><span class="sd"> that an input expression is a SQL string).</span> -</span><span id="L-4657"><a href="#L-4657"><span class="linenos">4657</span></a> -</span><span id="L-4658"><a href="#L-4658"><span class="linenos">4658</span></a><span class="sd"> Returns:</span> -</span><span id="L-4659"><a href="#L-4659"><span class="linenos">4659</span></a><span class="sd"> Expression: the parsed or given expression.</span> -</span><span id="L-4660"><a href="#L-4660"><span class="linenos">4660</span></a><span class="sd"> """</span> -</span><span id="L-4661"><a href="#L-4661"><span class="linenos">4661</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> -</span><span id="L-4662"><a href="#L-4662"><span class="linenos">4662</span></a> <span class="k">if</span> <span class="n">copy</span><span class="p">:</span> -</span><span id="L-4663"><a href="#L-4663"><span class="linenos">4663</span></a> <span class="k">return</span> <span class="n">sql_or_expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="L-4664"><a href="#L-4664"><span class="linenos">4664</span></a> <span class="k">return</span> <span class="n">sql_or_expression</span> -</span><span id="L-4665"><a href="#L-4665"><span class="linenos">4665</span></a> -</span><span id="L-4666"><a href="#L-4666"><span class="linenos">4666</span></a> <span class="k">if</span> <span class="n">sql_or_expression</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-4667"><a href="#L-4667"><span class="linenos">4667</span></a> <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"SQL cannot be None"</span><span class="p">)</span> -</span><span id="L-4668"><a href="#L-4668"><span class="linenos">4668</span></a> -</span><span id="L-4669"><a href="#L-4669"><span class="linenos">4669</span></a> <span class="kn">import</span> <span class="nn">sqlglot</span> +</span><span id="L-4600"><a href="#L-4600"><span class="linenos">4600</span></a> +</span><span id="L-4601"><a href="#L-4601"><span class="linenos">4601</span></a><span class="k">def</span> <span class="nf">_norm_arg</span><span class="p">(</span><span class="n">arg</span><span class="p">):</span> +</span><span id="L-4602"><a href="#L-4602"><span class="linenos">4602</span></a> <span class="k">return</span> <span class="n">arg</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="ow">is</span> <span class="nb">str</span> <span class="k">else</span> <span class="n">arg</span> +</span><span id="L-4603"><a href="#L-4603"><span class="linenos">4603</span></a> +</span><span id="L-4604"><a href="#L-4604"><span class="linenos">4604</span></a> +</span><span id="L-4605"><a href="#L-4605"><span class="linenos">4605</span></a><span class="n">ALL_FUNCTIONS</span> <span class="o">=</span> <span class="n">subclasses</span><span class="p">(</span><span class="vm">__name__</span><span class="p">,</span> <span class="n">Func</span><span class="p">,</span> <span class="p">(</span><span class="n">AggFunc</span><span class="p">,</span> <span class="n">Anonymous</span><span class="p">,</span> <span class="n">Func</span><span class="p">))</span> +</span><span id="L-4606"><a href="#L-4606"><span class="linenos">4606</span></a> +</span><span id="L-4607"><a href="#L-4607"><span class="linenos">4607</span></a> +</span><span id="L-4608"><a href="#L-4608"><span class="linenos">4608</span></a><span class="c1"># Helpers</span> +</span><span id="L-4609"><a href="#L-4609"><span class="linenos">4609</span></a><span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> +</span><span id="L-4610"><a href="#L-4610"><span class="linenos">4610</span></a><span class="k">def</span> <span class="nf">maybe_parse</span><span class="p">(</span> +</span><span id="L-4611"><a href="#L-4611"><span class="linenos">4611</span></a> <span class="n">sql_or_expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="L-4612"><a href="#L-4612"><span class="linenos">4612</span></a> <span class="o">*</span><span class="p">,</span> +</span><span id="L-4613"><a href="#L-4613"><span class="linenos">4613</span></a> <span class="n">into</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> +</span><span id="L-4614"><a href="#L-4614"><span class="linenos">4614</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-4615"><a href="#L-4615"><span class="linenos">4615</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-4616"><a href="#L-4616"><span class="linenos">4616</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4617"><a href="#L-4617"><span class="linenos">4617</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-4618"><a href="#L-4618"><span class="linenos">4618</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="L-4619"><a href="#L-4619"><span class="linenos">4619</span></a> <span class="o">...</span> +</span><span id="L-4620"><a href="#L-4620"><span class="linenos">4620</span></a> +</span><span id="L-4621"><a href="#L-4621"><span class="linenos">4621</span></a> +</span><span id="L-4622"><a href="#L-4622"><span class="linenos">4622</span></a><span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> +</span><span id="L-4623"><a href="#L-4623"><span class="linenos">4623</span></a><span class="k">def</span> <span class="nf">maybe_parse</span><span class="p">(</span> +</span><span id="L-4624"><a href="#L-4624"><span class="linenos">4624</span></a> <span class="n">sql_or_expression</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">E</span><span class="p">,</span> +</span><span id="L-4625"><a href="#L-4625"><span class="linenos">4625</span></a> <span class="o">*</span><span class="p">,</span> +</span><span id="L-4626"><a href="#L-4626"><span class="linenos">4626</span></a> <span class="n">into</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">IntoType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-4627"><a href="#L-4627"><span class="linenos">4627</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-4628"><a href="#L-4628"><span class="linenos">4628</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-4629"><a href="#L-4629"><span class="linenos">4629</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4630"><a href="#L-4630"><span class="linenos">4630</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-4631"><a href="#L-4631"><span class="linenos">4631</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="L-4632"><a href="#L-4632"><span class="linenos">4632</span></a> <span class="o">...</span> +</span><span id="L-4633"><a href="#L-4633"><span class="linenos">4633</span></a> +</span><span id="L-4634"><a href="#L-4634"><span class="linenos">4634</span></a> +</span><span id="L-4635"><a href="#L-4635"><span class="linenos">4635</span></a><span class="k">def</span> <span class="nf">maybe_parse</span><span class="p">(</span> +</span><span id="L-4636"><a href="#L-4636"><span class="linenos">4636</span></a> <span class="n">sql_or_expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="L-4637"><a href="#L-4637"><span class="linenos">4637</span></a> <span class="o">*</span><span class="p">,</span> +</span><span id="L-4638"><a href="#L-4638"><span class="linenos">4638</span></a> <span class="n">into</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">IntoType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-4639"><a href="#L-4639"><span class="linenos">4639</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-4640"><a href="#L-4640"><span class="linenos">4640</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-4641"><a href="#L-4641"><span class="linenos">4641</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-4642"><a href="#L-4642"><span class="linenos">4642</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-4643"><a href="#L-4643"><span class="linenos">4643</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> +</span><span id="L-4644"><a href="#L-4644"><span class="linenos">4644</span></a><span class="w"> </span><span class="sd">"""Gracefully handle a possible string or expression.</span> +</span><span id="L-4645"><a href="#L-4645"><span class="linenos">4645</span></a> +</span><span id="L-4646"><a href="#L-4646"><span class="linenos">4646</span></a><span class="sd"> Example:</span> +</span><span id="L-4647"><a href="#L-4647"><span class="linenos">4647</span></a><span class="sd"> >>> maybe_parse("1")</span> +</span><span id="L-4648"><a href="#L-4648"><span class="linenos">4648</span></a><span class="sd"> (LITERAL this: 1, is_string: False)</span> +</span><span id="L-4649"><a href="#L-4649"><span class="linenos">4649</span></a><span class="sd"> >>> maybe_parse(to_identifier("x"))</span> +</span><span id="L-4650"><a href="#L-4650"><span class="linenos">4650</span></a><span class="sd"> (IDENTIFIER this: x, quoted: False)</span> +</span><span id="L-4651"><a href="#L-4651"><span class="linenos">4651</span></a> +</span><span id="L-4652"><a href="#L-4652"><span class="linenos">4652</span></a><span class="sd"> Args:</span> +</span><span id="L-4653"><a href="#L-4653"><span class="linenos">4653</span></a><span class="sd"> sql_or_expression: the SQL code string or an expression</span> +</span><span id="L-4654"><a href="#L-4654"><span class="linenos">4654</span></a><span class="sd"> into: the SQLGlot Expression to parse into</span> +</span><span id="L-4655"><a href="#L-4655"><span class="linenos">4655</span></a><span class="sd"> dialect: the dialect used to parse the input expressions (in the case that an</span> +</span><span id="L-4656"><a href="#L-4656"><span class="linenos">4656</span></a><span class="sd"> input expression is a SQL string).</span> +</span><span id="L-4657"><a href="#L-4657"><span class="linenos">4657</span></a><span class="sd"> prefix: a string to prefix the sql with before it gets parsed</span> +</span><span id="L-4658"><a href="#L-4658"><span class="linenos">4658</span></a><span class="sd"> (automatically includes a space)</span> +</span><span id="L-4659"><a href="#L-4659"><span class="linenos">4659</span></a><span class="sd"> copy: whether or not to copy the expression.</span> +</span><span id="L-4660"><a href="#L-4660"><span class="linenos">4660</span></a><span class="sd"> **opts: other options to use to parse the input expressions (again, in the case</span> +</span><span id="L-4661"><a href="#L-4661"><span class="linenos">4661</span></a><span class="sd"> that an input expression is a SQL string).</span> +</span><span id="L-4662"><a href="#L-4662"><span class="linenos">4662</span></a> +</span><span id="L-4663"><a href="#L-4663"><span class="linenos">4663</span></a><span class="sd"> Returns:</span> +</span><span id="L-4664"><a href="#L-4664"><span class="linenos">4664</span></a><span class="sd"> Expression: the parsed or given expression.</span> +</span><span id="L-4665"><a href="#L-4665"><span class="linenos">4665</span></a><span class="sd"> """</span> +</span><span id="L-4666"><a href="#L-4666"><span class="linenos">4666</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> +</span><span id="L-4667"><a href="#L-4667"><span class="linenos">4667</span></a> <span class="k">if</span> <span class="n">copy</span><span class="p">:</span> +</span><span id="L-4668"><a href="#L-4668"><span class="linenos">4668</span></a> <span class="k">return</span> <span class="n">sql_or_expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="L-4669"><a href="#L-4669"><span class="linenos">4669</span></a> <span class="k">return</span> <span class="n">sql_or_expression</span> </span><span id="L-4670"><a href="#L-4670"><span class="linenos">4670</span></a> -</span><span id="L-4671"><a href="#L-4671"><span class="linenos">4671</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="p">)</span> -</span><span id="L-4672"><a href="#L-4672"><span class="linenos">4672</span></a> <span class="k">if</span> <span class="n">prefix</span><span class="p">:</span> -</span><span id="L-4673"><a href="#L-4673"><span class="linenos">4673</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-4674"><a href="#L-4674"><span class="linenos">4674</span></a> -</span><span id="L-4675"><a href="#L-4675"><span class="linenos">4675</span></a> <span class="k">return</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">parse_one</span><span class="p">(</span><span class="n">sql</span><span class="p">,</span> <span class="n">read</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">into</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-4676"><a href="#L-4676"><span class="linenos">4676</span></a> -</span><span id="L-4677"><a href="#L-4677"><span class="linenos">4677</span></a> -</span><span id="L-4678"><a href="#L-4678"><span class="linenos">4678</span></a><span class="k">def</span> <span class="nf">_maybe_copy</span><span class="p">(</span><span class="n">instance</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="L-4679"><a href="#L-4679"><span class="linenos">4679</span></a> <span class="k">return</span> <span class="n">instance</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="k">if</span> <span class="n">copy</span> <span class="k">else</span> <span class="n">instance</span> -</span><span id="L-4680"><a href="#L-4680"><span class="linenos">4680</span></a> +</span><span id="L-4671"><a href="#L-4671"><span class="linenos">4671</span></a> <span class="k">if</span> <span class="n">sql_or_expression</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-4672"><a href="#L-4672"><span class="linenos">4672</span></a> <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"SQL cannot be None"</span><span class="p">)</span> +</span><span id="L-4673"><a href="#L-4673"><span class="linenos">4673</span></a> +</span><span id="L-4674"><a href="#L-4674"><span class="linenos">4674</span></a> <span class="kn">import</span> <span class="nn">sqlglot</span> +</span><span id="L-4675"><a href="#L-4675"><span class="linenos">4675</span></a> +</span><span id="L-4676"><a href="#L-4676"><span class="linenos">4676</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="p">)</span> +</span><span id="L-4677"><a href="#L-4677"><span class="linenos">4677</span></a> <span class="k">if</span> <span class="n">prefix</span><span class="p">:</span> +</span><span id="L-4678"><a href="#L-4678"><span class="linenos">4678</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-4679"><a href="#L-4679"><span class="linenos">4679</span></a> +</span><span id="L-4680"><a href="#L-4680"><span class="linenos">4680</span></a> <span class="k">return</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">parse_one</span><span class="p">(</span><span class="n">sql</span><span class="p">,</span> <span class="n">read</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">into</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> </span><span id="L-4681"><a href="#L-4681"><span class="linenos">4681</span></a> -</span><span id="L-4682"><a href="#L-4682"><span class="linenos">4682</span></a><span class="k">def</span> <span class="nf">_is_wrong_expression</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="p">):</span> -</span><span id="L-4683"><a href="#L-4683"><span class="linenos">4683</span></a> <span class="k">return</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Expression</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="p">)</span> -</span><span id="L-4684"><a href="#L-4684"><span class="linenos">4684</span></a> +</span><span id="L-4682"><a href="#L-4682"><span class="linenos">4682</span></a> +</span><span id="L-4683"><a href="#L-4683"><span class="linenos">4683</span></a><span class="k">def</span> <span class="nf">_maybe_copy</span><span class="p">(</span><span class="n">instance</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="L-4684"><a href="#L-4684"><span class="linenos">4684</span></a> <span class="k">return</span> <span class="n">instance</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="k">if</span> <span class="n">copy</span> <span class="k">else</span> <span class="n">instance</span> </span><span id="L-4685"><a href="#L-4685"><span class="linenos">4685</span></a> -</span><span id="L-4686"><a href="#L-4686"><span class="linenos">4686</span></a><span class="k">def</span> <span class="nf">_apply_builder</span><span class="p">(</span> -</span><span id="L-4687"><a href="#L-4687"><span class="linenos">4687</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="L-4688"><a href="#L-4688"><span class="linenos">4688</span></a> <span class="n">instance</span><span class="p">,</span> -</span><span id="L-4689"><a href="#L-4689"><span class="linenos">4689</span></a> <span class="n">arg</span><span class="p">,</span> -</span><span id="L-4690"><a href="#L-4690"><span class="linenos">4690</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> -</span><span id="L-4691"><a href="#L-4691"><span class="linenos">4691</span></a> <span class="n">prefix</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> -</span><span id="L-4692"><a href="#L-4692"><span class="linenos">4692</span></a> <span class="n">into</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> -</span><span id="L-4693"><a href="#L-4693"><span class="linenos">4693</span></a> <span class="n">dialect</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> -</span><span id="L-4694"><a href="#L-4694"><span class="linenos">4694</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-4695"><a href="#L-4695"><span class="linenos">4695</span></a><span class="p">):</span> -</span><span id="L-4696"><a href="#L-4696"><span class="linenos">4696</span></a> <span class="k">if</span> <span class="n">_is_wrong_expression</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="p">):</span> -</span><span id="L-4697"><a href="#L-4697"><span class="linenos">4697</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">into</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-4698"><a href="#L-4698"><span class="linenos">4698</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="n">instance</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="L-4699"><a href="#L-4699"><span class="linenos">4699</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span> -</span><span id="L-4700"><a href="#L-4700"><span class="linenos">4700</span></a> <span class="n">sql_or_expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> -</span><span id="L-4701"><a href="#L-4701"><span class="linenos">4701</span></a> <span class="n">prefix</span><span class="o">=</span><span class="n">prefix</span><span class="p">,</span> -</span><span id="L-4702"><a href="#L-4702"><span class="linenos">4702</span></a> <span class="n">into</span><span class="o">=</span><span class="n">into</span><span class="p">,</span> -</span><span id="L-4703"><a href="#L-4703"><span class="linenos">4703</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-4704"><a href="#L-4704"><span class="linenos">4704</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-4705"><a href="#L-4705"><span class="linenos">4705</span></a> <span class="p">)</span> -</span><span id="L-4706"><a href="#L-4706"><span class="linenos">4706</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-4707"><a href="#L-4707"><span class="linenos">4707</span></a> <span class="k">return</span> <span class="n">instance</span> -</span><span id="L-4708"><a href="#L-4708"><span class="linenos">4708</span></a> -</span><span id="L-4709"><a href="#L-4709"><span class="linenos">4709</span></a> -</span><span id="L-4710"><a href="#L-4710"><span class="linenos">4710</span></a><span class="k">def</span> <span class="nf">_apply_child_list_builder</span><span class="p">(</span> -</span><span id="L-4711"><a href="#L-4711"><span class="linenos">4711</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-4712"><a href="#L-4712"><span class="linenos">4712</span></a> <span class="n">instance</span><span class="p">,</span> -</span><span id="L-4713"><a href="#L-4713"><span class="linenos">4713</span></a> <span class="n">arg</span><span class="p">,</span> -</span><span id="L-4714"><a href="#L-4714"><span class="linenos">4714</span></a> <span class="n">append</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> -</span><span id="L-4715"><a href="#L-4715"><span class="linenos">4715</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> -</span><span id="L-4716"><a href="#L-4716"><span class="linenos">4716</span></a> <span class="n">prefix</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> -</span><span id="L-4717"><a href="#L-4717"><span class="linenos">4717</span></a> <span class="n">into</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> -</span><span id="L-4718"><a href="#L-4718"><span class="linenos">4718</span></a> <span class="n">dialect</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> -</span><span id="L-4719"><a href="#L-4719"><span class="linenos">4719</span></a> <span class="n">properties</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> -</span><span id="L-4720"><a href="#L-4720"><span class="linenos">4720</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-4721"><a href="#L-4721"><span class="linenos">4721</span></a><span class="p">):</span> -</span><span id="L-4722"><a href="#L-4722"><span class="linenos">4722</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="n">instance</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="L-4723"><a href="#L-4723"><span class="linenos">4723</span></a> <span class="n">parsed</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-4724"><a href="#L-4724"><span class="linenos">4724</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="L-4725"><a href="#L-4725"><span class="linenos">4725</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-4726"><a href="#L-4726"><span class="linenos">4726</span></a> <span class="k">if</span> <span class="n">_is_wrong_expression</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="p">):</span> -</span><span id="L-4727"><a href="#L-4727"><span class="linenos">4727</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">into</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">expression</span><span class="p">])</span> -</span><span id="L-4728"><a href="#L-4728"><span class="linenos">4728</span></a> -</span><span id="L-4729"><a href="#L-4729"><span class="linenos">4729</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span> -</span><span id="L-4730"><a href="#L-4730"><span class="linenos">4730</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="L-4731"><a href="#L-4731"><span class="linenos">4731</span></a> <span class="n">into</span><span class="o">=</span><span class="n">into</span><span class="p">,</span> -</span><span id="L-4732"><a href="#L-4732"><span class="linenos">4732</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-4733"><a href="#L-4733"><span class="linenos">4733</span></a> <span class="n">prefix</span><span class="o">=</span><span class="n">prefix</span><span class="p">,</span> -</span><span id="L-4734"><a href="#L-4734"><span class="linenos">4734</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-4735"><a href="#L-4735"><span class="linenos">4735</span></a> <span class="p">)</span> -</span><span id="L-4736"><a href="#L-4736"><span class="linenos">4736</span></a> <span class="n">parsed</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-4737"><a href="#L-4737"><span class="linenos">4737</span></a> -</span><span id="L-4738"><a href="#L-4738"><span class="linenos">4738</span></a> <span class="n">existing</span> <span class="o">=</span> <span class="n">instance</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> -</span><span id="L-4739"><a href="#L-4739"><span class="linenos">4739</span></a> <span class="k">if</span> <span class="n">append</span> <span class="ow">and</span> <span class="n">existing</span><span class="p">:</span> -</span><span id="L-4740"><a href="#L-4740"><span class="linenos">4740</span></a> <span class="n">parsed</span> <span class="o">=</span> <span class="n">existing</span><span class="o">.</span><span class="n">expressions</span> <span class="o">+</span> <span class="n">parsed</span> -</span><span id="L-4741"><a href="#L-4741"><span class="linenos">4741</span></a> -</span><span id="L-4742"><a href="#L-4742"><span class="linenos">4742</span></a> <span class="n">child</span> <span class="o">=</span> <span class="n">into</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">parsed</span><span class="p">)</span> -</span><span id="L-4743"><a href="#L-4743"><span class="linenos">4743</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="p">(</span><span class="n">properties</span> <span class="ow">or</span> <span class="p">{})</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> -</span><span id="L-4744"><a href="#L-4744"><span class="linenos">4744</span></a> <span class="n">child</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> -</span><span id="L-4745"><a href="#L-4745"><span class="linenos">4745</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="n">child</span><span class="p">)</span> +</span><span id="L-4686"><a href="#L-4686"><span class="linenos">4686</span></a> +</span><span id="L-4687"><a href="#L-4687"><span class="linenos">4687</span></a><span class="k">def</span> <span class="nf">_is_wrong_expression</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="p">):</span> +</span><span id="L-4688"><a href="#L-4688"><span class="linenos">4688</span></a> <span class="k">return</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Expression</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="p">)</span> +</span><span id="L-4689"><a href="#L-4689"><span class="linenos">4689</span></a> +</span><span id="L-4690"><a href="#L-4690"><span class="linenos">4690</span></a> +</span><span id="L-4691"><a href="#L-4691"><span class="linenos">4691</span></a><span class="k">def</span> <span class="nf">_apply_builder</span><span class="p">(</span> +</span><span id="L-4692"><a href="#L-4692"><span class="linenos">4692</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="L-4693"><a href="#L-4693"><span class="linenos">4693</span></a> <span class="n">instance</span><span class="p">,</span> +</span><span id="L-4694"><a href="#L-4694"><span class="linenos">4694</span></a> <span class="n">arg</span><span class="p">,</span> +</span><span id="L-4695"><a href="#L-4695"><span class="linenos">4695</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> +</span><span id="L-4696"><a href="#L-4696"><span class="linenos">4696</span></a> <span class="n">prefix</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> +</span><span id="L-4697"><a href="#L-4697"><span class="linenos">4697</span></a> <span class="n">into</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> +</span><span id="L-4698"><a href="#L-4698"><span class="linenos">4698</span></a> <span class="n">dialect</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> +</span><span id="L-4699"><a href="#L-4699"><span class="linenos">4699</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-4700"><a href="#L-4700"><span class="linenos">4700</span></a><span class="p">):</span> +</span><span id="L-4701"><a href="#L-4701"><span class="linenos">4701</span></a> <span class="k">if</span> <span class="n">_is_wrong_expression</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="p">):</span> +</span><span id="L-4702"><a href="#L-4702"><span class="linenos">4702</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">into</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-4703"><a href="#L-4703"><span class="linenos">4703</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="n">instance</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="L-4704"><a href="#L-4704"><span class="linenos">4704</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span> +</span><span id="L-4705"><a href="#L-4705"><span class="linenos">4705</span></a> <span class="n">sql_or_expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> +</span><span id="L-4706"><a href="#L-4706"><span class="linenos">4706</span></a> <span class="n">prefix</span><span class="o">=</span><span class="n">prefix</span><span class="p">,</span> +</span><span id="L-4707"><a href="#L-4707"><span class="linenos">4707</span></a> <span class="n">into</span><span class="o">=</span><span class="n">into</span><span class="p">,</span> +</span><span id="L-4708"><a href="#L-4708"><span class="linenos">4708</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-4709"><a href="#L-4709"><span class="linenos">4709</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-4710"><a href="#L-4710"><span class="linenos">4710</span></a> <span class="p">)</span> +</span><span id="L-4711"><a href="#L-4711"><span class="linenos">4711</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-4712"><a href="#L-4712"><span class="linenos">4712</span></a> <span class="k">return</span> <span class="n">instance</span> +</span><span id="L-4713"><a href="#L-4713"><span class="linenos">4713</span></a> +</span><span id="L-4714"><a href="#L-4714"><span class="linenos">4714</span></a> +</span><span id="L-4715"><a href="#L-4715"><span class="linenos">4715</span></a><span class="k">def</span> <span class="nf">_apply_child_list_builder</span><span class="p">(</span> +</span><span id="L-4716"><a href="#L-4716"><span class="linenos">4716</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-4717"><a href="#L-4717"><span class="linenos">4717</span></a> <span class="n">instance</span><span class="p">,</span> +</span><span id="L-4718"><a href="#L-4718"><span class="linenos">4718</span></a> <span class="n">arg</span><span class="p">,</span> +</span><span id="L-4719"><a href="#L-4719"><span class="linenos">4719</span></a> <span class="n">append</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> +</span><span id="L-4720"><a href="#L-4720"><span class="linenos">4720</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> +</span><span id="L-4721"><a href="#L-4721"><span class="linenos">4721</span></a> <span class="n">prefix</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> +</span><span id="L-4722"><a href="#L-4722"><span class="linenos">4722</span></a> <span class="n">into</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> +</span><span id="L-4723"><a href="#L-4723"><span class="linenos">4723</span></a> <span class="n">dialect</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> +</span><span id="L-4724"><a href="#L-4724"><span class="linenos">4724</span></a> <span class="n">properties</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> +</span><span id="L-4725"><a href="#L-4725"><span class="linenos">4725</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-4726"><a href="#L-4726"><span class="linenos">4726</span></a><span class="p">):</span> +</span><span id="L-4727"><a href="#L-4727"><span class="linenos">4727</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="n">instance</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="L-4728"><a href="#L-4728"><span class="linenos">4728</span></a> <span class="n">parsed</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-4729"><a href="#L-4729"><span class="linenos">4729</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="L-4730"><a href="#L-4730"><span class="linenos">4730</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-4731"><a href="#L-4731"><span class="linenos">4731</span></a> <span class="k">if</span> <span class="n">_is_wrong_expression</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="p">):</span> +</span><span id="L-4732"><a href="#L-4732"><span class="linenos">4732</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">into</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">expression</span><span class="p">])</span> +</span><span id="L-4733"><a href="#L-4733"><span class="linenos">4733</span></a> +</span><span id="L-4734"><a href="#L-4734"><span class="linenos">4734</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span> +</span><span id="L-4735"><a href="#L-4735"><span class="linenos">4735</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="L-4736"><a href="#L-4736"><span class="linenos">4736</span></a> <span class="n">into</span><span class="o">=</span><span class="n">into</span><span class="p">,</span> +</span><span id="L-4737"><a href="#L-4737"><span class="linenos">4737</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-4738"><a href="#L-4738"><span class="linenos">4738</span></a> <span class="n">prefix</span><span class="o">=</span><span class="n">prefix</span><span class="p">,</span> +</span><span id="L-4739"><a href="#L-4739"><span class="linenos">4739</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-4740"><a href="#L-4740"><span class="linenos">4740</span></a> <span class="p">)</span> +</span><span id="L-4741"><a href="#L-4741"><span class="linenos">4741</span></a> <span class="n">parsed</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-4742"><a href="#L-4742"><span class="linenos">4742</span></a> +</span><span id="L-4743"><a href="#L-4743"><span class="linenos">4743</span></a> <span class="n">existing</span> <span class="o">=</span> <span class="n">instance</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> +</span><span id="L-4744"><a href="#L-4744"><span class="linenos">4744</span></a> <span class="k">if</span> <span class="n">append</span> <span class="ow">and</span> <span class="n">existing</span><span class="p">:</span> +</span><span id="L-4745"><a href="#L-4745"><span class="linenos">4745</span></a> <span class="n">parsed</span> <span class="o">=</span> <span class="n">existing</span><span class="o">.</span><span class="n">expressions</span> <span class="o">+</span> <span class="n">parsed</span> </span><span id="L-4746"><a href="#L-4746"><span class="linenos">4746</span></a> -</span><span id="L-4747"><a href="#L-4747"><span class="linenos">4747</span></a> <span class="k">return</span> <span class="n">instance</span> -</span><span id="L-4748"><a href="#L-4748"><span class="linenos">4748</span></a> -</span><span id="L-4749"><a href="#L-4749"><span class="linenos">4749</span></a> -</span><span id="L-4750"><a href="#L-4750"><span class="linenos">4750</span></a><span class="k">def</span> <span class="nf">_apply_list_builder</span><span class="p">(</span> -</span><span id="L-4751"><a href="#L-4751"><span class="linenos">4751</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-4752"><a href="#L-4752"><span class="linenos">4752</span></a> <span class="n">instance</span><span class="p">,</span> -</span><span id="L-4753"><a href="#L-4753"><span class="linenos">4753</span></a> <span class="n">arg</span><span class="p">,</span> -</span><span id="L-4754"><a href="#L-4754"><span class="linenos">4754</span></a> <span class="n">append</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> -</span><span id="L-4755"><a href="#L-4755"><span class="linenos">4755</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> -</span><span id="L-4756"><a href="#L-4756"><span class="linenos">4756</span></a> <span class="n">prefix</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> -</span><span id="L-4757"><a href="#L-4757"><span class="linenos">4757</span></a> <span class="n">into</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> -</span><span id="L-4758"><a href="#L-4758"><span class="linenos">4758</span></a> <span class="n">dialect</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> -</span><span id="L-4759"><a href="#L-4759"><span class="linenos">4759</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-4760"><a href="#L-4760"><span class="linenos">4760</span></a><span class="p">):</span> -</span><span id="L-4761"><a href="#L-4761"><span class="linenos">4761</span></a> <span class="n">inst</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="n">instance</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="L-4762"><a href="#L-4762"><span class="linenos">4762</span></a> -</span><span id="L-4763"><a href="#L-4763"><span class="linenos">4763</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="L-4764"><a href="#L-4764"><span class="linenos">4764</span></a> <span class="n">maybe_parse</span><span class="p">(</span> -</span><span id="L-4765"><a href="#L-4765"><span class="linenos">4765</span></a> <span class="n">sql_or_expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> -</span><span id="L-4766"><a href="#L-4766"><span class="linenos">4766</span></a> <span class="n">into</span><span class="o">=</span><span class="n">into</span><span class="p">,</span> -</span><span id="L-4767"><a href="#L-4767"><span class="linenos">4767</span></a> <span class="n">prefix</span><span class="o">=</span><span class="n">prefix</span><span class="p">,</span> -</span><span id="L-4768"><a href="#L-4768"><span class="linenos">4768</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-4769"><a href="#L-4769"><span class="linenos">4769</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-4770"><a href="#L-4770"><span class="linenos">4770</span></a> <span class="p">)</span> -</span><span id="L-4771"><a href="#L-4771"><span class="linenos">4771</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">expressions</span> -</span><span id="L-4772"><a href="#L-4772"><span class="linenos">4772</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> -</span><span id="L-4773"><a href="#L-4773"><span class="linenos">4773</span></a> <span class="p">]</span> -</span><span id="L-4774"><a href="#L-4774"><span class="linenos">4774</span></a> -</span><span id="L-4775"><a href="#L-4775"><span class="linenos">4775</span></a> <span class="n">existing_expressions</span> <span class="o">=</span> <span class="n">inst</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> -</span><span id="L-4776"><a href="#L-4776"><span class="linenos">4776</span></a> <span class="k">if</span> <span class="n">append</span> <span class="ow">and</span> <span class="n">existing_expressions</span><span class="p">:</span> -</span><span id="L-4777"><a href="#L-4777"><span class="linenos">4777</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">existing_expressions</span> <span class="o">+</span> <span class="n">expressions</span> -</span><span id="L-4778"><a href="#L-4778"><span class="linenos">4778</span></a> -</span><span id="L-4779"><a href="#L-4779"><span class="linenos">4779</span></a> <span class="n">inst</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="n">expressions</span><span class="p">)</span> -</span><span id="L-4780"><a href="#L-4780"><span class="linenos">4780</span></a> <span class="k">return</span> <span class="n">inst</span> -</span><span id="L-4781"><a href="#L-4781"><span class="linenos">4781</span></a> -</span><span id="L-4782"><a href="#L-4782"><span class="linenos">4782</span></a> -</span><span id="L-4783"><a href="#L-4783"><span class="linenos">4783</span></a><span class="k">def</span> <span class="nf">_apply_conjunction_builder</span><span class="p">(</span> -</span><span id="L-4784"><a href="#L-4784"><span class="linenos">4784</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-4785"><a href="#L-4785"><span class="linenos">4785</span></a> <span class="n">instance</span><span class="p">,</span> -</span><span id="L-4786"><a href="#L-4786"><span class="linenos">4786</span></a> <span class="n">arg</span><span class="p">,</span> -</span><span id="L-4787"><a href="#L-4787"><span class="linenos">4787</span></a> <span class="n">into</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> -</span><span id="L-4788"><a href="#L-4788"><span class="linenos">4788</span></a> <span class="n">append</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> -</span><span id="L-4789"><a href="#L-4789"><span class="linenos">4789</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> -</span><span id="L-4790"><a href="#L-4790"><span class="linenos">4790</span></a> <span class="n">dialect</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> -</span><span id="L-4791"><a href="#L-4791"><span class="linenos">4791</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-4792"><a href="#L-4792"><span class="linenos">4792</span></a><span class="p">):</span> -</span><span id="L-4793"><a href="#L-4793"><span class="linenos">4793</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">exp</span> <span class="k">for</span> <span class="n">exp</span> <span class="ow">in</span> <span class="n">expressions</span> <span class="k">if</span> <span class="n">exp</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">exp</span> <span class="o">!=</span> <span class="s2">""</span><span class="p">]</span> -</span><span id="L-4794"><a href="#L-4794"><span class="linenos">4794</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="L-4795"><a href="#L-4795"><span class="linenos">4795</span></a> <span class="k">return</span> <span class="n">instance</span> -</span><span id="L-4796"><a href="#L-4796"><span class="linenos">4796</span></a> -</span><span id="L-4797"><a href="#L-4797"><span class="linenos">4797</span></a> <span class="n">inst</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="n">instance</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="L-4798"><a href="#L-4798"><span class="linenos">4798</span></a> -</span><span id="L-4799"><a href="#L-4799"><span class="linenos">4799</span></a> <span class="n">existing</span> <span class="o">=</span> <span class="n">inst</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> -</span><span id="L-4800"><a href="#L-4800"><span class="linenos">4800</span></a> <span class="k">if</span> <span class="n">append</span> <span class="ow">and</span> <span class="n">existing</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-4801"><a href="#L-4801"><span class="linenos">4801</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">existing</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">into</span> <span class="k">else</span> <span class="n">existing</span><span class="p">]</span> <span class="o">+</span> <span class="nb">list</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-4802"><a href="#L-4802"><span class="linenos">4802</span></a> -</span><span id="L-4803"><a href="#L-4803"><span class="linenos">4803</span></a> <span class="n">node</span> <span class="o">=</span> <span class="n">and_</span><span class="p">(</span><span class="o">*</span><span class="n">expressions</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-4804"><a href="#L-4804"><span class="linenos">4804</span></a> -</span><span id="L-4805"><a href="#L-4805"><span class="linenos">4805</span></a> <span class="n">inst</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="n">into</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">node</span><span class="p">)</span> <span class="k">if</span> <span class="n">into</span> <span class="k">else</span> <span class="n">node</span><span class="p">)</span> -</span><span id="L-4806"><a href="#L-4806"><span class="linenos">4806</span></a> <span class="k">return</span> <span class="n">inst</span> +</span><span id="L-4747"><a href="#L-4747"><span class="linenos">4747</span></a> <span class="n">child</span> <span class="o">=</span> <span class="n">into</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">parsed</span><span class="p">)</span> +</span><span id="L-4748"><a href="#L-4748"><span class="linenos">4748</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="p">(</span><span class="n">properties</span> <span class="ow">or</span> <span class="p">{})</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> +</span><span id="L-4749"><a href="#L-4749"><span class="linenos">4749</span></a> <span class="n">child</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> +</span><span id="L-4750"><a href="#L-4750"><span class="linenos">4750</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="n">child</span><span class="p">)</span> +</span><span id="L-4751"><a href="#L-4751"><span class="linenos">4751</span></a> +</span><span id="L-4752"><a href="#L-4752"><span class="linenos">4752</span></a> <span class="k">return</span> <span class="n">instance</span> +</span><span id="L-4753"><a href="#L-4753"><span class="linenos">4753</span></a> +</span><span id="L-4754"><a href="#L-4754"><span class="linenos">4754</span></a> +</span><span id="L-4755"><a href="#L-4755"><span class="linenos">4755</span></a><span class="k">def</span> <span class="nf">_apply_list_builder</span><span class="p">(</span> +</span><span id="L-4756"><a href="#L-4756"><span class="linenos">4756</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-4757"><a href="#L-4757"><span class="linenos">4757</span></a> <span class="n">instance</span><span class="p">,</span> +</span><span id="L-4758"><a href="#L-4758"><span class="linenos">4758</span></a> <span class="n">arg</span><span class="p">,</span> +</span><span id="L-4759"><a href="#L-4759"><span class="linenos">4759</span></a> <span class="n">append</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> +</span><span id="L-4760"><a href="#L-4760"><span class="linenos">4760</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> +</span><span id="L-4761"><a href="#L-4761"><span class="linenos">4761</span></a> <span class="n">prefix</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> +</span><span id="L-4762"><a href="#L-4762"><span class="linenos">4762</span></a> <span class="n">into</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> +</span><span id="L-4763"><a href="#L-4763"><span class="linenos">4763</span></a> <span class="n">dialect</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> +</span><span id="L-4764"><a href="#L-4764"><span class="linenos">4764</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-4765"><a href="#L-4765"><span class="linenos">4765</span></a><span class="p">):</span> +</span><span id="L-4766"><a href="#L-4766"><span class="linenos">4766</span></a> <span class="n">inst</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="n">instance</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="L-4767"><a href="#L-4767"><span class="linenos">4767</span></a> +</span><span id="L-4768"><a href="#L-4768"><span class="linenos">4768</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="L-4769"><a href="#L-4769"><span class="linenos">4769</span></a> <span class="n">maybe_parse</span><span class="p">(</span> +</span><span id="L-4770"><a href="#L-4770"><span class="linenos">4770</span></a> <span class="n">sql_or_expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> +</span><span id="L-4771"><a href="#L-4771"><span class="linenos">4771</span></a> <span class="n">into</span><span class="o">=</span><span class="n">into</span><span class="p">,</span> +</span><span id="L-4772"><a href="#L-4772"><span class="linenos">4772</span></a> <span class="n">prefix</span><span class="o">=</span><span class="n">prefix</span><span class="p">,</span> +</span><span id="L-4773"><a href="#L-4773"><span class="linenos">4773</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-4774"><a href="#L-4774"><span class="linenos">4774</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-4775"><a href="#L-4775"><span class="linenos">4775</span></a> <span class="p">)</span> +</span><span id="L-4776"><a href="#L-4776"><span class="linenos">4776</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">expressions</span> +</span><span id="L-4777"><a href="#L-4777"><span class="linenos">4777</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> +</span><span id="L-4778"><a href="#L-4778"><span class="linenos">4778</span></a> <span class="p">]</span> +</span><span id="L-4779"><a href="#L-4779"><span class="linenos">4779</span></a> +</span><span id="L-4780"><a href="#L-4780"><span class="linenos">4780</span></a> <span class="n">existing_expressions</span> <span class="o">=</span> <span class="n">inst</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> +</span><span id="L-4781"><a href="#L-4781"><span class="linenos">4781</span></a> <span class="k">if</span> <span class="n">append</span> <span class="ow">and</span> <span class="n">existing_expressions</span><span class="p">:</span> +</span><span id="L-4782"><a href="#L-4782"><span class="linenos">4782</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">existing_expressions</span> <span class="o">+</span> <span class="n">expressions</span> +</span><span id="L-4783"><a href="#L-4783"><span class="linenos">4783</span></a> +</span><span id="L-4784"><a href="#L-4784"><span class="linenos">4784</span></a> <span class="n">inst</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="n">expressions</span><span class="p">)</span> +</span><span id="L-4785"><a href="#L-4785"><span class="linenos">4785</span></a> <span class="k">return</span> <span class="n">inst</span> +</span><span id="L-4786"><a href="#L-4786"><span class="linenos">4786</span></a> +</span><span id="L-4787"><a href="#L-4787"><span class="linenos">4787</span></a> +</span><span id="L-4788"><a href="#L-4788"><span class="linenos">4788</span></a><span class="k">def</span> <span class="nf">_apply_conjunction_builder</span><span class="p">(</span> +</span><span id="L-4789"><a href="#L-4789"><span class="linenos">4789</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-4790"><a href="#L-4790"><span class="linenos">4790</span></a> <span class="n">instance</span><span class="p">,</span> +</span><span id="L-4791"><a href="#L-4791"><span class="linenos">4791</span></a> <span class="n">arg</span><span class="p">,</span> +</span><span id="L-4792"><a href="#L-4792"><span class="linenos">4792</span></a> <span class="n">into</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> +</span><span id="L-4793"><a href="#L-4793"><span class="linenos">4793</span></a> <span class="n">append</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> +</span><span id="L-4794"><a href="#L-4794"><span class="linenos">4794</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> +</span><span id="L-4795"><a href="#L-4795"><span class="linenos">4795</span></a> <span class="n">dialect</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> +</span><span id="L-4796"><a href="#L-4796"><span class="linenos">4796</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-4797"><a href="#L-4797"><span class="linenos">4797</span></a><span class="p">):</span> +</span><span id="L-4798"><a href="#L-4798"><span class="linenos">4798</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">exp</span> <span class="k">for</span> <span class="n">exp</span> <span class="ow">in</span> <span class="n">expressions</span> <span class="k">if</span> <span class="n">exp</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">exp</span> <span class="o">!=</span> <span class="s2">""</span><span class="p">]</span> +</span><span id="L-4799"><a href="#L-4799"><span class="linenos">4799</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="L-4800"><a href="#L-4800"><span class="linenos">4800</span></a> <span class="k">return</span> <span class="n">instance</span> +</span><span id="L-4801"><a href="#L-4801"><span class="linenos">4801</span></a> +</span><span id="L-4802"><a href="#L-4802"><span class="linenos">4802</span></a> <span class="n">inst</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="n">instance</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="L-4803"><a href="#L-4803"><span class="linenos">4803</span></a> +</span><span id="L-4804"><a href="#L-4804"><span class="linenos">4804</span></a> <span class="n">existing</span> <span class="o">=</span> <span class="n">inst</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> +</span><span id="L-4805"><a href="#L-4805"><span class="linenos">4805</span></a> <span class="k">if</span> <span class="n">append</span> <span class="ow">and</span> <span class="n">existing</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-4806"><a href="#L-4806"><span class="linenos">4806</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">existing</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">into</span> <span class="k">else</span> <span class="n">existing</span><span class="p">]</span> <span class="o">+</span> <span class="nb">list</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> </span><span id="L-4807"><a href="#L-4807"><span class="linenos">4807</span></a> -</span><span id="L-4808"><a href="#L-4808"><span class="linenos">4808</span></a> -</span><span id="L-4809"><a href="#L-4809"><span class="linenos">4809</span></a><span class="k">def</span> <span class="nf">_apply_cte_builder</span><span class="p">(</span> -</span><span id="L-4810"><a href="#L-4810"><span class="linenos">4810</span></a> <span class="n">instance</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> -</span><span id="L-4811"><a href="#L-4811"><span class="linenos">4811</span></a> <span class="n">alias</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="L-4812"><a href="#L-4812"><span class="linenos">4812</span></a> <span class="n">as_</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="L-4813"><a href="#L-4813"><span class="linenos">4813</span></a> <span class="n">recursive</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-4814"><a href="#L-4814"><span class="linenos">4814</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-4815"><a href="#L-4815"><span class="linenos">4815</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-4816"><a href="#L-4816"><span class="linenos">4816</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-4817"><a href="#L-4817"><span class="linenos">4817</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-4818"><a href="#L-4818"><span class="linenos">4818</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="L-4819"><a href="#L-4819"><span class="linenos">4819</span></a> <span class="n">alias_expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">TableAlias</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-4820"><a href="#L-4820"><span class="linenos">4820</span></a> <span class="n">as_expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">as_</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-4821"><a href="#L-4821"><span class="linenos">4821</span></a> <span class="n">cte</span> <span class="o">=</span> <span class="n">CTE</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">as_expression</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias_expression</span><span class="p">)</span> -</span><span id="L-4822"><a href="#L-4822"><span class="linenos">4822</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> -</span><span id="L-4823"><a href="#L-4823"><span class="linenos">4823</span></a> <span class="n">cte</span><span class="p">,</span> -</span><span id="L-4824"><a href="#L-4824"><span class="linenos">4824</span></a> <span class="n">instance</span><span class="o">=</span><span class="n">instance</span><span class="p">,</span> -</span><span id="L-4825"><a href="#L-4825"><span class="linenos">4825</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"with"</span><span class="p">,</span> -</span><span id="L-4826"><a href="#L-4826"><span class="linenos">4826</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="L-4827"><a href="#L-4827"><span class="linenos">4827</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="L-4828"><a href="#L-4828"><span class="linenos">4828</span></a> <span class="n">into</span><span class="o">=</span><span class="n">With</span><span class="p">,</span> -</span><span id="L-4829"><a href="#L-4829"><span class="linenos">4829</span></a> <span class="n">properties</span><span class="o">=</span><span class="p">{</span><span class="s2">"recursive"</span><span class="p">:</span> <span class="n">recursive</span> <span class="ow">or</span> <span class="kc">False</span><span class="p">},</span> -</span><span id="L-4830"><a href="#L-4830"><span class="linenos">4830</span></a> <span class="p">)</span> -</span><span id="L-4831"><a href="#L-4831"><span class="linenos">4831</span></a> -</span><span id="L-4832"><a href="#L-4832"><span class="linenos">4832</span></a> -</span><span id="L-4833"><a href="#L-4833"><span class="linenos">4833</span></a><span class="k">def</span> <span class="nf">_combine</span><span class="p">(</span> -</span><span id="L-4834"><a href="#L-4834"><span class="linenos">4834</span></a> <span class="n">expressions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</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">ExpOrStr</span><span class="p">]],</span> -</span><span id="L-4835"><a href="#L-4835"><span class="linenos">4835</span></a> <span class="n">operator</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Connector</span><span class="p">],</span> -</span><span id="L-4836"><a href="#L-4836"><span class="linenos">4836</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-4837"><a href="#L-4837"><span class="linenos">4837</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-4838"><a href="#L-4838"><span class="linenos">4838</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-4839"><a href="#L-4839"><span class="linenos">4839</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> -</span><span id="L-4840"><a href="#L-4840"><span class="linenos">4840</span></a> <span class="n">conditions</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="L-4841"><a href="#L-4841"><span class="linenos">4841</span></a> <span class="n">condition</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-4842"><a href="#L-4842"><span class="linenos">4842</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">expressions</span> -</span><span id="L-4843"><a href="#L-4843"><span class="linenos">4843</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> -</span><span id="L-4844"><a href="#L-4844"><span class="linenos">4844</span></a> <span class="p">]</span> -</span><span id="L-4845"><a href="#L-4845"><span class="linenos">4845</span></a> -</span><span id="L-4846"><a href="#L-4846"><span class="linenos">4846</span></a> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="n">conditions</span> -</span><span id="L-4847"><a href="#L-4847"><span class="linenos">4847</span></a> <span class="k">if</span> <span class="n">rest</span><span class="p">:</span> -</span><span id="L-4848"><a href="#L-4848"><span class="linenos">4848</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">_wrap</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">Connector</span><span class="p">)</span> -</span><span id="L-4849"><a href="#L-4849"><span class="linenos">4849</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">rest</span><span class="p">:</span> -</span><span id="L-4850"><a href="#L-4850"><span class="linenos">4850</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">operator</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">_wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Connector</span><span class="p">))</span> -</span><span id="L-4851"><a href="#L-4851"><span class="linenos">4851</span></a> -</span><span id="L-4852"><a href="#L-4852"><span class="linenos">4852</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-4853"><a href="#L-4853"><span class="linenos">4853</span></a> -</span><span id="L-4854"><a href="#L-4854"><span class="linenos">4854</span></a> -</span><span id="L-4855"><a href="#L-4855"><span class="linenos">4855</span></a><span class="k">def</span> <span class="nf">_wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">kind</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">E</span> <span class="o">|</span> <span class="n">Paren</span><span class="p">:</span> -</span><span id="L-4856"><a href="#L-4856"><span class="linenos">4856</span></a> <span class="k">return</span> <span class="n">Paren</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">kind</span><span class="p">)</span> <span class="k">else</span> <span class="n">expression</span> -</span><span id="L-4857"><a href="#L-4857"><span class="linenos">4857</span></a> +</span><span id="L-4808"><a href="#L-4808"><span class="linenos">4808</span></a> <span class="n">node</span> <span class="o">=</span> <span class="n">and_</span><span class="p">(</span><span class="o">*</span><span class="n">expressions</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-4809"><a href="#L-4809"><span class="linenos">4809</span></a> +</span><span id="L-4810"><a href="#L-4810"><span class="linenos">4810</span></a> <span class="n">inst</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="n">into</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">node</span><span class="p">)</span> <span class="k">if</span> <span class="n">into</span> <span class="k">else</span> <span class="n">node</span><span class="p">)</span> +</span><span id="L-4811"><a href="#L-4811"><span class="linenos">4811</span></a> <span class="k">return</span> <span class="n">inst</span> +</span><span id="L-4812"><a href="#L-4812"><span class="linenos">4812</span></a> +</span><span id="L-4813"><a href="#L-4813"><span class="linenos">4813</span></a> +</span><span id="L-4814"><a href="#L-4814"><span class="linenos">4814</span></a><span class="k">def</span> <span class="nf">_apply_cte_builder</span><span class="p">(</span> +</span><span id="L-4815"><a href="#L-4815"><span class="linenos">4815</span></a> <span class="n">instance</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> +</span><span id="L-4816"><a href="#L-4816"><span class="linenos">4816</span></a> <span class="n">alias</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="L-4817"><a href="#L-4817"><span class="linenos">4817</span></a> <span class="n">as_</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="L-4818"><a href="#L-4818"><span class="linenos">4818</span></a> <span class="n">recursive</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-4819"><a href="#L-4819"><span class="linenos">4819</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-4820"><a href="#L-4820"><span class="linenos">4820</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-4821"><a href="#L-4821"><span class="linenos">4821</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-4822"><a href="#L-4822"><span class="linenos">4822</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-4823"><a href="#L-4823"><span class="linenos">4823</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="L-4824"><a href="#L-4824"><span class="linenos">4824</span></a> <span class="n">alias_expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">TableAlias</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-4825"><a href="#L-4825"><span class="linenos">4825</span></a> <span class="n">as_expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">as_</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-4826"><a href="#L-4826"><span class="linenos">4826</span></a> <span class="n">cte</span> <span class="o">=</span> <span class="n">CTE</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">as_expression</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias_expression</span><span class="p">)</span> +</span><span id="L-4827"><a href="#L-4827"><span class="linenos">4827</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> +</span><span id="L-4828"><a href="#L-4828"><span class="linenos">4828</span></a> <span class="n">cte</span><span class="p">,</span> +</span><span id="L-4829"><a href="#L-4829"><span class="linenos">4829</span></a> <span class="n">instance</span><span class="o">=</span><span class="n">instance</span><span class="p">,</span> +</span><span id="L-4830"><a href="#L-4830"><span class="linenos">4830</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"with"</span><span class="p">,</span> +</span><span id="L-4831"><a href="#L-4831"><span class="linenos">4831</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="L-4832"><a href="#L-4832"><span class="linenos">4832</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="L-4833"><a href="#L-4833"><span class="linenos">4833</span></a> <span class="n">into</span><span class="o">=</span><span class="n">With</span><span class="p">,</span> +</span><span id="L-4834"><a href="#L-4834"><span class="linenos">4834</span></a> <span class="n">properties</span><span class="o">=</span><span class="p">{</span><span class="s2">"recursive"</span><span class="p">:</span> <span class="n">recursive</span> <span class="ow">or</span> <span class="kc">False</span><span class="p">},</span> +</span><span id="L-4835"><a href="#L-4835"><span class="linenos">4835</span></a> <span class="p">)</span> +</span><span id="L-4836"><a href="#L-4836"><span class="linenos">4836</span></a> +</span><span id="L-4837"><a href="#L-4837"><span class="linenos">4837</span></a> +</span><span id="L-4838"><a href="#L-4838"><span class="linenos">4838</span></a><span class="k">def</span> <span class="nf">_combine</span><span class="p">(</span> +</span><span id="L-4839"><a href="#L-4839"><span class="linenos">4839</span></a> <span class="n">expressions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</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">ExpOrStr</span><span class="p">]],</span> +</span><span id="L-4840"><a href="#L-4840"><span class="linenos">4840</span></a> <span class="n">operator</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Connector</span><span class="p">],</span> +</span><span id="L-4841"><a href="#L-4841"><span class="linenos">4841</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-4842"><a href="#L-4842"><span class="linenos">4842</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-4843"><a href="#L-4843"><span class="linenos">4843</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-4844"><a href="#L-4844"><span class="linenos">4844</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> +</span><span id="L-4845"><a href="#L-4845"><span class="linenos">4845</span></a> <span class="n">conditions</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="L-4846"><a href="#L-4846"><span class="linenos">4846</span></a> <span class="n">condition</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-4847"><a href="#L-4847"><span class="linenos">4847</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">expressions</span> +</span><span id="L-4848"><a href="#L-4848"><span class="linenos">4848</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> +</span><span id="L-4849"><a href="#L-4849"><span class="linenos">4849</span></a> <span class="p">]</span> +</span><span id="L-4850"><a href="#L-4850"><span class="linenos">4850</span></a> +</span><span id="L-4851"><a href="#L-4851"><span class="linenos">4851</span></a> <span class="n">this</span><span class="p">,</span> <span class="o">*</span><span class="n">rest</span> <span class="o">=</span> <span class="n">conditions</span> +</span><span id="L-4852"><a href="#L-4852"><span class="linenos">4852</span></a> <span class="k">if</span> <span class="n">rest</span><span class="p">:</span> +</span><span id="L-4853"><a href="#L-4853"><span class="linenos">4853</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">_wrap</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">Connector</span><span class="p">)</span> +</span><span id="L-4854"><a href="#L-4854"><span class="linenos">4854</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">rest</span><span class="p">:</span> +</span><span id="L-4855"><a href="#L-4855"><span class="linenos">4855</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">operator</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">_wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Connector</span><span class="p">))</span> +</span><span id="L-4856"><a href="#L-4856"><span class="linenos">4856</span></a> +</span><span id="L-4857"><a href="#L-4857"><span class="linenos">4857</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="L-4858"><a href="#L-4858"><span class="linenos">4858</span></a> -</span><span id="L-4859"><a href="#L-4859"><span class="linenos">4859</span></a><span class="k">def</span> <span class="nf">union</span><span class="p">(</span> -</span><span id="L-4860"><a href="#L-4860"><span class="linenos">4860</span></a> <span class="n">left</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">right</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">distinct</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="L-4861"><a href="#L-4861"><span class="linenos">4861</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">:</span> -</span><span id="L-4862"><a href="#L-4862"><span class="linenos">4862</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-4863"><a href="#L-4863"><span class="linenos">4863</span></a><span class="sd"> Initializes a syntax tree from one UNION expression.</span> -</span><span id="L-4864"><a href="#L-4864"><span class="linenos">4864</span></a> -</span><span id="L-4865"><a href="#L-4865"><span class="linenos">4865</span></a><span class="sd"> Example:</span> -</span><span id="L-4866"><a href="#L-4866"><span class="linenos">4866</span></a><span class="sd"> >>> union("SELECT * FROM foo", "SELECT * FROM bla").sql()</span> -</span><span id="L-4867"><a href="#L-4867"><span class="linenos">4867</span></a><span class="sd"> 'SELECT * FROM foo UNION SELECT * FROM bla'</span> -</span><span id="L-4868"><a href="#L-4868"><span class="linenos">4868</span></a> -</span><span id="L-4869"><a href="#L-4869"><span class="linenos">4869</span></a><span class="sd"> Args:</span> -</span><span id="L-4870"><a href="#L-4870"><span class="linenos">4870</span></a><span class="sd"> left: the SQL code string corresponding to the left-hand side.</span> -</span><span id="L-4871"><a href="#L-4871"><span class="linenos">4871</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="L-4872"><a href="#L-4872"><span class="linenos">4872</span></a><span class="sd"> right: the SQL code string corresponding to the right-hand side.</span> -</span><span id="L-4873"><a href="#L-4873"><span class="linenos">4873</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="L-4874"><a href="#L-4874"><span class="linenos">4874</span></a><span class="sd"> distinct: set the DISTINCT flag if and only if this is true.</span> -</span><span id="L-4875"><a href="#L-4875"><span class="linenos">4875</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="L-4876"><a href="#L-4876"><span class="linenos">4876</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="L-4877"><a href="#L-4877"><span class="linenos">4877</span></a> -</span><span id="L-4878"><a href="#L-4878"><span class="linenos">4878</span></a><span class="sd"> Returns:</span> -</span><span id="L-4879"><a href="#L-4879"><span class="linenos">4879</span></a><span class="sd"> The new Union instance.</span> -</span><span id="L-4880"><a href="#L-4880"><span class="linenos">4880</span></a><span class="sd"> """</span> -</span><span id="L-4881"><a href="#L-4881"><span class="linenos">4881</span></a> <span class="n">left</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-4882"><a href="#L-4882"><span class="linenos">4882</span></a> <span class="n">right</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-4883"><a href="#L-4883"><span class="linenos">4883</span></a> -</span><span id="L-4884"><a href="#L-4884"><span class="linenos">4884</span></a> <span class="k">return</span> <span class="n">Union</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="n">distinct</span><span class="p">)</span> -</span><span id="L-4885"><a href="#L-4885"><span class="linenos">4885</span></a> -</span><span id="L-4886"><a href="#L-4886"><span class="linenos">4886</span></a> -</span><span id="L-4887"><a href="#L-4887"><span class="linenos">4887</span></a><span class="k">def</span> <span class="nf">intersect</span><span class="p">(</span> -</span><span id="L-4888"><a href="#L-4888"><span class="linenos">4888</span></a> <span class="n">left</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">right</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">distinct</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="L-4889"><a href="#L-4889"><span class="linenos">4889</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Intersect</span><span class="p">:</span> -</span><span id="L-4890"><a href="#L-4890"><span class="linenos">4890</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-4891"><a href="#L-4891"><span class="linenos">4891</span></a><span class="sd"> Initializes a syntax tree from one INTERSECT expression.</span> -</span><span id="L-4892"><a href="#L-4892"><span class="linenos">4892</span></a> -</span><span id="L-4893"><a href="#L-4893"><span class="linenos">4893</span></a><span class="sd"> Example:</span> -</span><span id="L-4894"><a href="#L-4894"><span class="linenos">4894</span></a><span class="sd"> >>> intersect("SELECT * FROM foo", "SELECT * FROM bla").sql()</span> -</span><span id="L-4895"><a href="#L-4895"><span class="linenos">4895</span></a><span class="sd"> 'SELECT * FROM foo INTERSECT SELECT * FROM bla'</span> -</span><span id="L-4896"><a href="#L-4896"><span class="linenos">4896</span></a> -</span><span id="L-4897"><a href="#L-4897"><span class="linenos">4897</span></a><span class="sd"> Args:</span> -</span><span id="L-4898"><a href="#L-4898"><span class="linenos">4898</span></a><span class="sd"> left: the SQL code string corresponding to the left-hand side.</span> -</span><span id="L-4899"><a href="#L-4899"><span class="linenos">4899</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="L-4900"><a href="#L-4900"><span class="linenos">4900</span></a><span class="sd"> right: the SQL code string corresponding to the right-hand side.</span> -</span><span id="L-4901"><a href="#L-4901"><span class="linenos">4901</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="L-4902"><a href="#L-4902"><span class="linenos">4902</span></a><span class="sd"> distinct: set the DISTINCT flag if and only if this is true.</span> -</span><span id="L-4903"><a href="#L-4903"><span class="linenos">4903</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="L-4904"><a href="#L-4904"><span class="linenos">4904</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="L-4905"><a href="#L-4905"><span class="linenos">4905</span></a> -</span><span id="L-4906"><a href="#L-4906"><span class="linenos">4906</span></a><span class="sd"> Returns:</span> -</span><span id="L-4907"><a href="#L-4907"><span class="linenos">4907</span></a><span class="sd"> The new Intersect instance.</span> -</span><span id="L-4908"><a href="#L-4908"><span class="linenos">4908</span></a><span class="sd"> """</span> -</span><span id="L-4909"><a href="#L-4909"><span class="linenos">4909</span></a> <span class="n">left</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-4910"><a href="#L-4910"><span class="linenos">4910</span></a> <span class="n">right</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-4911"><a href="#L-4911"><span class="linenos">4911</span></a> -</span><span id="L-4912"><a href="#L-4912"><span class="linenos">4912</span></a> <span class="k">return</span> <span class="n">Intersect</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="n">distinct</span><span class="p">)</span> -</span><span id="L-4913"><a href="#L-4913"><span class="linenos">4913</span></a> -</span><span id="L-4914"><a href="#L-4914"><span class="linenos">4914</span></a> -</span><span id="L-4915"><a href="#L-4915"><span class="linenos">4915</span></a><span class="k">def</span> <span class="nf">except_</span><span class="p">(</span> -</span><span id="L-4916"><a href="#L-4916"><span class="linenos">4916</span></a> <span class="n">left</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">right</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">distinct</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="L-4917"><a href="#L-4917"><span class="linenos">4917</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Except</span><span class="p">:</span> -</span><span id="L-4918"><a href="#L-4918"><span class="linenos">4918</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-4919"><a href="#L-4919"><span class="linenos">4919</span></a><span class="sd"> Initializes a syntax tree from one EXCEPT expression.</span> -</span><span id="L-4920"><a href="#L-4920"><span class="linenos">4920</span></a> -</span><span id="L-4921"><a href="#L-4921"><span class="linenos">4921</span></a><span class="sd"> Example:</span> -</span><span id="L-4922"><a href="#L-4922"><span class="linenos">4922</span></a><span class="sd"> >>> except_("SELECT * FROM foo", "SELECT * FROM bla").sql()</span> -</span><span id="L-4923"><a href="#L-4923"><span class="linenos">4923</span></a><span class="sd"> 'SELECT * FROM foo EXCEPT SELECT * FROM bla'</span> -</span><span id="L-4924"><a href="#L-4924"><span class="linenos">4924</span></a> -</span><span id="L-4925"><a href="#L-4925"><span class="linenos">4925</span></a><span class="sd"> Args:</span> -</span><span id="L-4926"><a href="#L-4926"><span class="linenos">4926</span></a><span class="sd"> left: the SQL code string corresponding to the left-hand side.</span> -</span><span id="L-4927"><a href="#L-4927"><span class="linenos">4927</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="L-4928"><a href="#L-4928"><span class="linenos">4928</span></a><span class="sd"> right: the SQL code string corresponding to the right-hand side.</span> -</span><span id="L-4929"><a href="#L-4929"><span class="linenos">4929</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="L-4930"><a href="#L-4930"><span class="linenos">4930</span></a><span class="sd"> distinct: set the DISTINCT flag if and only if this is true.</span> -</span><span id="L-4931"><a href="#L-4931"><span class="linenos">4931</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="L-4932"><a href="#L-4932"><span class="linenos">4932</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="L-4933"><a href="#L-4933"><span class="linenos">4933</span></a> -</span><span id="L-4934"><a href="#L-4934"><span class="linenos">4934</span></a><span class="sd"> Returns:</span> -</span><span id="L-4935"><a href="#L-4935"><span class="linenos">4935</span></a><span class="sd"> The new Except instance.</span> -</span><span id="L-4936"><a href="#L-4936"><span class="linenos">4936</span></a><span class="sd"> """</span> -</span><span id="L-4937"><a href="#L-4937"><span class="linenos">4937</span></a> <span class="n">left</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-4938"><a href="#L-4938"><span class="linenos">4938</span></a> <span class="n">right</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-4939"><a href="#L-4939"><span class="linenos">4939</span></a> -</span><span id="L-4940"><a href="#L-4940"><span class="linenos">4940</span></a> <span class="k">return</span> <span class="n">Except</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="n">distinct</span><span class="p">)</span> -</span><span id="L-4941"><a href="#L-4941"><span class="linenos">4941</span></a> -</span><span id="L-4942"><a href="#L-4942"><span class="linenos">4942</span></a> -</span><span id="L-4943"><a href="#L-4943"><span class="linenos">4943</span></a><span class="k">def</span> <span class="nf">select</span><span class="p">(</span><span class="o">*</span><span class="n">expressions</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-4944"><a href="#L-4944"><span class="linenos">4944</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-4945"><a href="#L-4945"><span class="linenos">4945</span></a><span class="sd"> Initializes a syntax tree from one or multiple SELECT expressions.</span> +</span><span id="L-4859"><a href="#L-4859"><span class="linenos">4859</span></a> +</span><span id="L-4860"><a href="#L-4860"><span class="linenos">4860</span></a><span class="k">def</span> <span class="nf">_wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">kind</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">E</span> <span class="o">|</span> <span class="n">Paren</span><span class="p">:</span> +</span><span id="L-4861"><a href="#L-4861"><span class="linenos">4861</span></a> <span class="k">return</span> <span class="n">Paren</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">kind</span><span class="p">)</span> <span class="k">else</span> <span class="n">expression</span> +</span><span id="L-4862"><a href="#L-4862"><span class="linenos">4862</span></a> +</span><span id="L-4863"><a href="#L-4863"><span class="linenos">4863</span></a> +</span><span id="L-4864"><a href="#L-4864"><span class="linenos">4864</span></a><span class="k">def</span> <span class="nf">union</span><span class="p">(</span> +</span><span id="L-4865"><a href="#L-4865"><span class="linenos">4865</span></a> <span class="n">left</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">right</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">distinct</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="L-4866"><a href="#L-4866"><span class="linenos">4866</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">:</span> +</span><span id="L-4867"><a href="#L-4867"><span class="linenos">4867</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-4868"><a href="#L-4868"><span class="linenos">4868</span></a><span class="sd"> Initializes a syntax tree from one UNION expression.</span> +</span><span id="L-4869"><a href="#L-4869"><span class="linenos">4869</span></a> +</span><span id="L-4870"><a href="#L-4870"><span class="linenos">4870</span></a><span class="sd"> Example:</span> +</span><span id="L-4871"><a href="#L-4871"><span class="linenos">4871</span></a><span class="sd"> >>> union("SELECT * FROM foo", "SELECT * FROM bla").sql()</span> +</span><span id="L-4872"><a href="#L-4872"><span class="linenos">4872</span></a><span class="sd"> 'SELECT * FROM foo UNION SELECT * FROM bla'</span> +</span><span id="L-4873"><a href="#L-4873"><span class="linenos">4873</span></a> +</span><span id="L-4874"><a href="#L-4874"><span class="linenos">4874</span></a><span class="sd"> Args:</span> +</span><span id="L-4875"><a href="#L-4875"><span class="linenos">4875</span></a><span class="sd"> left: the SQL code string corresponding to the left-hand side.</span> +</span><span id="L-4876"><a href="#L-4876"><span class="linenos">4876</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="L-4877"><a href="#L-4877"><span class="linenos">4877</span></a><span class="sd"> right: the SQL code string corresponding to the right-hand side.</span> +</span><span id="L-4878"><a href="#L-4878"><span class="linenos">4878</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="L-4879"><a href="#L-4879"><span class="linenos">4879</span></a><span class="sd"> distinct: set the DISTINCT flag if and only if this is true.</span> +</span><span id="L-4880"><a href="#L-4880"><span class="linenos">4880</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="L-4881"><a href="#L-4881"><span class="linenos">4881</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="L-4882"><a href="#L-4882"><span class="linenos">4882</span></a> +</span><span id="L-4883"><a href="#L-4883"><span class="linenos">4883</span></a><span class="sd"> Returns:</span> +</span><span id="L-4884"><a href="#L-4884"><span class="linenos">4884</span></a><span class="sd"> The new Union instance.</span> +</span><span id="L-4885"><a href="#L-4885"><span class="linenos">4885</span></a><span class="sd"> """</span> +</span><span id="L-4886"><a href="#L-4886"><span class="linenos">4886</span></a> <span class="n">left</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-4887"><a href="#L-4887"><span class="linenos">4887</span></a> <span class="n">right</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-4888"><a href="#L-4888"><span class="linenos">4888</span></a> +</span><span id="L-4889"><a href="#L-4889"><span class="linenos">4889</span></a> <span class="k">return</span> <span class="n">Union</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="n">distinct</span><span class="p">)</span> +</span><span id="L-4890"><a href="#L-4890"><span class="linenos">4890</span></a> +</span><span id="L-4891"><a href="#L-4891"><span class="linenos">4891</span></a> +</span><span id="L-4892"><a href="#L-4892"><span class="linenos">4892</span></a><span class="k">def</span> <span class="nf">intersect</span><span class="p">(</span> +</span><span id="L-4893"><a href="#L-4893"><span class="linenos">4893</span></a> <span class="n">left</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">right</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">distinct</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="L-4894"><a href="#L-4894"><span class="linenos">4894</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Intersect</span><span class="p">:</span> +</span><span id="L-4895"><a href="#L-4895"><span class="linenos">4895</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-4896"><a href="#L-4896"><span class="linenos">4896</span></a><span class="sd"> Initializes a syntax tree from one INTERSECT expression.</span> +</span><span id="L-4897"><a href="#L-4897"><span class="linenos">4897</span></a> +</span><span id="L-4898"><a href="#L-4898"><span class="linenos">4898</span></a><span class="sd"> Example:</span> +</span><span id="L-4899"><a href="#L-4899"><span class="linenos">4899</span></a><span class="sd"> >>> intersect("SELECT * FROM foo", "SELECT * FROM bla").sql()</span> +</span><span id="L-4900"><a href="#L-4900"><span class="linenos">4900</span></a><span class="sd"> 'SELECT * FROM foo INTERSECT SELECT * FROM bla'</span> +</span><span id="L-4901"><a href="#L-4901"><span class="linenos">4901</span></a> +</span><span id="L-4902"><a href="#L-4902"><span class="linenos">4902</span></a><span class="sd"> Args:</span> +</span><span id="L-4903"><a href="#L-4903"><span class="linenos">4903</span></a><span class="sd"> left: the SQL code string corresponding to the left-hand side.</span> +</span><span id="L-4904"><a href="#L-4904"><span class="linenos">4904</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="L-4905"><a href="#L-4905"><span class="linenos">4905</span></a><span class="sd"> right: the SQL code string corresponding to the right-hand side.</span> +</span><span id="L-4906"><a href="#L-4906"><span class="linenos">4906</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="L-4907"><a href="#L-4907"><span class="linenos">4907</span></a><span class="sd"> distinct: set the DISTINCT flag if and only if this is true.</span> +</span><span id="L-4908"><a href="#L-4908"><span class="linenos">4908</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="L-4909"><a href="#L-4909"><span class="linenos">4909</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="L-4910"><a href="#L-4910"><span class="linenos">4910</span></a> +</span><span id="L-4911"><a href="#L-4911"><span class="linenos">4911</span></a><span class="sd"> Returns:</span> +</span><span id="L-4912"><a href="#L-4912"><span class="linenos">4912</span></a><span class="sd"> The new Intersect instance.</span> +</span><span id="L-4913"><a href="#L-4913"><span class="linenos">4913</span></a><span class="sd"> """</span> +</span><span id="L-4914"><a href="#L-4914"><span class="linenos">4914</span></a> <span class="n">left</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-4915"><a href="#L-4915"><span class="linenos">4915</span></a> <span class="n">right</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-4916"><a href="#L-4916"><span class="linenos">4916</span></a> +</span><span id="L-4917"><a href="#L-4917"><span class="linenos">4917</span></a> <span class="k">return</span> <span class="n">Intersect</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="n">distinct</span><span class="p">)</span> +</span><span id="L-4918"><a href="#L-4918"><span class="linenos">4918</span></a> +</span><span id="L-4919"><a href="#L-4919"><span class="linenos">4919</span></a> +</span><span id="L-4920"><a href="#L-4920"><span class="linenos">4920</span></a><span class="k">def</span> <span class="nf">except_</span><span class="p">(</span> +</span><span id="L-4921"><a href="#L-4921"><span class="linenos">4921</span></a> <span class="n">left</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">right</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">distinct</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="L-4922"><a href="#L-4922"><span class="linenos">4922</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Except</span><span class="p">:</span> +</span><span id="L-4923"><a href="#L-4923"><span class="linenos">4923</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-4924"><a href="#L-4924"><span class="linenos">4924</span></a><span class="sd"> Initializes a syntax tree from one EXCEPT expression.</span> +</span><span id="L-4925"><a href="#L-4925"><span class="linenos">4925</span></a> +</span><span id="L-4926"><a href="#L-4926"><span class="linenos">4926</span></a><span class="sd"> Example:</span> +</span><span id="L-4927"><a href="#L-4927"><span class="linenos">4927</span></a><span class="sd"> >>> except_("SELECT * FROM foo", "SELECT * FROM bla").sql()</span> +</span><span id="L-4928"><a href="#L-4928"><span class="linenos">4928</span></a><span class="sd"> 'SELECT * FROM foo EXCEPT SELECT * FROM bla'</span> +</span><span id="L-4929"><a href="#L-4929"><span class="linenos">4929</span></a> +</span><span id="L-4930"><a href="#L-4930"><span class="linenos">4930</span></a><span class="sd"> Args:</span> +</span><span id="L-4931"><a href="#L-4931"><span class="linenos">4931</span></a><span class="sd"> left: the SQL code string corresponding to the left-hand side.</span> +</span><span id="L-4932"><a href="#L-4932"><span class="linenos">4932</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="L-4933"><a href="#L-4933"><span class="linenos">4933</span></a><span class="sd"> right: the SQL code string corresponding to the right-hand side.</span> +</span><span id="L-4934"><a href="#L-4934"><span class="linenos">4934</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="L-4935"><a href="#L-4935"><span class="linenos">4935</span></a><span class="sd"> distinct: set the DISTINCT flag if and only if this is true.</span> +</span><span id="L-4936"><a href="#L-4936"><span class="linenos">4936</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="L-4937"><a href="#L-4937"><span class="linenos">4937</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="L-4938"><a href="#L-4938"><span class="linenos">4938</span></a> +</span><span id="L-4939"><a href="#L-4939"><span class="linenos">4939</span></a><span class="sd"> Returns:</span> +</span><span id="L-4940"><a href="#L-4940"><span class="linenos">4940</span></a><span class="sd"> The new Except instance.</span> +</span><span id="L-4941"><a href="#L-4941"><span class="linenos">4941</span></a><span class="sd"> """</span> +</span><span id="L-4942"><a href="#L-4942"><span class="linenos">4942</span></a> <span class="n">left</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-4943"><a href="#L-4943"><span class="linenos">4943</span></a> <span class="n">right</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-4944"><a href="#L-4944"><span class="linenos">4944</span></a> +</span><span id="L-4945"><a href="#L-4945"><span class="linenos">4945</span></a> <span class="k">return</span> <span class="n">Except</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="n">distinct</span><span class="p">)</span> </span><span id="L-4946"><a href="#L-4946"><span class="linenos">4946</span></a> -</span><span id="L-4947"><a href="#L-4947"><span class="linenos">4947</span></a><span class="sd"> Example:</span> -</span><span id="L-4948"><a href="#L-4948"><span class="linenos">4948</span></a><span class="sd"> >>> select("col1", "col2").from_("tbl").sql()</span> -</span><span id="L-4949"><a href="#L-4949"><span class="linenos">4949</span></a><span class="sd"> 'SELECT col1, col2 FROM tbl'</span> -</span><span id="L-4950"><a href="#L-4950"><span class="linenos">4950</span></a> -</span><span id="L-4951"><a href="#L-4951"><span class="linenos">4951</span></a><span class="sd"> Args:</span> -</span><span id="L-4952"><a href="#L-4952"><span class="linenos">4952</span></a><span class="sd"> *expressions: the SQL code string to parse as the expressions of a</span> -</span><span id="L-4953"><a href="#L-4953"><span class="linenos">4953</span></a><span class="sd"> SELECT statement. If an Expression instance is passed, this is used as-is.</span> -</span><span id="L-4954"><a href="#L-4954"><span class="linenos">4954</span></a><span class="sd"> dialect: the dialect used to parse the input expressions (in the case that an</span> -</span><span id="L-4955"><a href="#L-4955"><span class="linenos">4955</span></a><span class="sd"> input expression is a SQL string).</span> -</span><span id="L-4956"><a href="#L-4956"><span class="linenos">4956</span></a><span class="sd"> **opts: other options to use to parse the input expressions (again, in the case</span> -</span><span id="L-4957"><a href="#L-4957"><span class="linenos">4957</span></a><span class="sd"> that an input expression is a SQL string).</span> -</span><span id="L-4958"><a href="#L-4958"><span class="linenos">4958</span></a> -</span><span id="L-4959"><a href="#L-4959"><span class="linenos">4959</span></a><span class="sd"> Returns:</span> -</span><span id="L-4960"><a href="#L-4960"><span class="linenos">4960</span></a><span class="sd"> Select: the syntax tree for the SELECT statement.</span> -</span><span id="L-4961"><a href="#L-4961"><span class="linenos">4961</span></a><span class="sd"> """</span> -</span><span id="L-4962"><a href="#L-4962"><span class="linenos">4962</span></a> <span class="k">return</span> <span class="n">Select</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">expressions</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-4947"><a href="#L-4947"><span class="linenos">4947</span></a> +</span><span id="L-4948"><a href="#L-4948"><span class="linenos">4948</span></a><span class="k">def</span> <span class="nf">select</span><span class="p">(</span><span class="o">*</span><span class="n">expressions</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-4949"><a href="#L-4949"><span class="linenos">4949</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-4950"><a href="#L-4950"><span class="linenos">4950</span></a><span class="sd"> Initializes a syntax tree from one or multiple SELECT expressions.</span> +</span><span id="L-4951"><a href="#L-4951"><span class="linenos">4951</span></a> +</span><span id="L-4952"><a href="#L-4952"><span class="linenos">4952</span></a><span class="sd"> Example:</span> +</span><span id="L-4953"><a href="#L-4953"><span class="linenos">4953</span></a><span class="sd"> >>> select("col1", "col2").from_("tbl").sql()</span> +</span><span id="L-4954"><a href="#L-4954"><span class="linenos">4954</span></a><span class="sd"> 'SELECT col1, col2 FROM tbl'</span> +</span><span id="L-4955"><a href="#L-4955"><span class="linenos">4955</span></a> +</span><span id="L-4956"><a href="#L-4956"><span class="linenos">4956</span></a><span class="sd"> Args:</span> +</span><span id="L-4957"><a href="#L-4957"><span class="linenos">4957</span></a><span class="sd"> *expressions: the SQL code string to parse as the expressions of a</span> +</span><span id="L-4958"><a href="#L-4958"><span class="linenos">4958</span></a><span class="sd"> SELECT statement. If an Expression instance is passed, this is used as-is.</span> +</span><span id="L-4959"><a href="#L-4959"><span class="linenos">4959</span></a><span class="sd"> dialect: the dialect used to parse the input expressions (in the case that an</span> +</span><span id="L-4960"><a href="#L-4960"><span class="linenos">4960</span></a><span class="sd"> input expression is a SQL string).</span> +</span><span id="L-4961"><a href="#L-4961"><span class="linenos">4961</span></a><span class="sd"> **opts: other options to use to parse the input expressions (again, in the case</span> +</span><span id="L-4962"><a href="#L-4962"><span class="linenos">4962</span></a><span class="sd"> that an input expression is a SQL string).</span> </span><span id="L-4963"><a href="#L-4963"><span class="linenos">4963</span></a> -</span><span id="L-4964"><a href="#L-4964"><span class="linenos">4964</span></a> -</span><span id="L-4965"><a href="#L-4965"><span class="linenos">4965</span></a><span class="k">def</span> <span class="nf">from_</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-4966"><a href="#L-4966"><span class="linenos">4966</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-4967"><a href="#L-4967"><span class="linenos">4967</span></a><span class="sd"> Initializes a syntax tree from a FROM expression.</span> +</span><span id="L-4964"><a href="#L-4964"><span class="linenos">4964</span></a><span class="sd"> Returns:</span> +</span><span id="L-4965"><a href="#L-4965"><span class="linenos">4965</span></a><span class="sd"> Select: the syntax tree for the SELECT statement.</span> +</span><span id="L-4966"><a href="#L-4966"><span class="linenos">4966</span></a><span class="sd"> """</span> +</span><span id="L-4967"><a href="#L-4967"><span class="linenos">4967</span></a> <span class="k">return</span> <span class="n">Select</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">expressions</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> </span><span id="L-4968"><a href="#L-4968"><span class="linenos">4968</span></a> -</span><span id="L-4969"><a href="#L-4969"><span class="linenos">4969</span></a><span class="sd"> Example:</span> -</span><span id="L-4970"><a href="#L-4970"><span class="linenos">4970</span></a><span class="sd"> >>> from_("tbl").select("col1", "col2").sql()</span> -</span><span id="L-4971"><a href="#L-4971"><span class="linenos">4971</span></a><span class="sd"> 'SELECT col1, col2 FROM tbl'</span> -</span><span id="L-4972"><a href="#L-4972"><span class="linenos">4972</span></a> -</span><span id="L-4973"><a href="#L-4973"><span class="linenos">4973</span></a><span class="sd"> Args:</span> -</span><span id="L-4974"><a href="#L-4974"><span class="linenos">4974</span></a><span class="sd"> *expression: the SQL code string to parse as the FROM expressions of a</span> -</span><span id="L-4975"><a href="#L-4975"><span class="linenos">4975</span></a><span class="sd"> SELECT statement. If an Expression instance is passed, this is used as-is.</span> -</span><span id="L-4976"><a href="#L-4976"><span class="linenos">4976</span></a><span class="sd"> dialect: the dialect used to parse the input expression (in the case that the</span> -</span><span id="L-4977"><a href="#L-4977"><span class="linenos">4977</span></a><span class="sd"> input expression is a SQL string).</span> -</span><span id="L-4978"><a href="#L-4978"><span class="linenos">4978</span></a><span class="sd"> **opts: other options to use to parse the input expressions (again, in the case</span> -</span><span id="L-4979"><a href="#L-4979"><span class="linenos">4979</span></a><span class="sd"> that the input expression is a SQL string).</span> -</span><span id="L-4980"><a href="#L-4980"><span class="linenos">4980</span></a> -</span><span id="L-4981"><a href="#L-4981"><span class="linenos">4981</span></a><span class="sd"> Returns:</span> -</span><span id="L-4982"><a href="#L-4982"><span class="linenos">4982</span></a><span class="sd"> Select: the syntax tree for the SELECT statement.</span> -</span><span id="L-4983"><a href="#L-4983"><span class="linenos">4983</span></a><span class="sd"> """</span> -</span><span id="L-4984"><a href="#L-4984"><span class="linenos">4984</span></a> <span class="k">return</span> <span class="n">Select</span><span class="p">()</span><span class="o">.</span><span class="n">from_</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-4969"><a href="#L-4969"><span class="linenos">4969</span></a> +</span><span id="L-4970"><a href="#L-4970"><span class="linenos">4970</span></a><span class="k">def</span> <span class="nf">from_</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-4971"><a href="#L-4971"><span class="linenos">4971</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-4972"><a href="#L-4972"><span class="linenos">4972</span></a><span class="sd"> Initializes a syntax tree from a FROM expression.</span> +</span><span id="L-4973"><a href="#L-4973"><span class="linenos">4973</span></a> +</span><span id="L-4974"><a href="#L-4974"><span class="linenos">4974</span></a><span class="sd"> Example:</span> +</span><span id="L-4975"><a href="#L-4975"><span class="linenos">4975</span></a><span class="sd"> >>> from_("tbl").select("col1", "col2").sql()</span> +</span><span id="L-4976"><a href="#L-4976"><span class="linenos">4976</span></a><span class="sd"> 'SELECT col1, col2 FROM tbl'</span> +</span><span id="L-4977"><a href="#L-4977"><span class="linenos">4977</span></a> +</span><span id="L-4978"><a href="#L-4978"><span class="linenos">4978</span></a><span class="sd"> Args:</span> +</span><span id="L-4979"><a href="#L-4979"><span class="linenos">4979</span></a><span class="sd"> *expression: the SQL code string to parse as the FROM expressions of a</span> +</span><span id="L-4980"><a href="#L-4980"><span class="linenos">4980</span></a><span class="sd"> SELECT statement. If an Expression instance is passed, this is used as-is.</span> +</span><span id="L-4981"><a href="#L-4981"><span class="linenos">4981</span></a><span class="sd"> dialect: the dialect used to parse the input expression (in the case that the</span> +</span><span id="L-4982"><a href="#L-4982"><span class="linenos">4982</span></a><span class="sd"> input expression is a SQL string).</span> +</span><span id="L-4983"><a href="#L-4983"><span class="linenos">4983</span></a><span class="sd"> **opts: other options to use to parse the input expressions (again, in the case</span> +</span><span id="L-4984"><a href="#L-4984"><span class="linenos">4984</span></a><span class="sd"> that the input expression is a SQL string).</span> </span><span id="L-4985"><a href="#L-4985"><span class="linenos">4985</span></a> -</span><span id="L-4986"><a href="#L-4986"><span class="linenos">4986</span></a> -</span><span id="L-4987"><a href="#L-4987"><span class="linenos">4987</span></a><span class="k">def</span> <span class="nf">update</span><span class="p">(</span> -</span><span id="L-4988"><a href="#L-4988"><span class="linenos">4988</span></a> <span class="n">table</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Table</span><span class="p">,</span> -</span><span id="L-4989"><a href="#L-4989"><span class="linenos">4989</span></a> <span class="n">properties</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> -</span><span id="L-4990"><a href="#L-4990"><span class="linenos">4990</span></a> <span class="n">where</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-4991"><a href="#L-4991"><span class="linenos">4991</span></a> <span class="n">from_</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-4992"><a href="#L-4992"><span class="linenos">4992</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-4993"><a href="#L-4993"><span class="linenos">4993</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-4994"><a href="#L-4994"><span class="linenos">4994</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Update</span><span class="p">:</span> -</span><span id="L-4995"><a href="#L-4995"><span class="linenos">4995</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-4996"><a href="#L-4996"><span class="linenos">4996</span></a><span class="sd"> Creates an update statement.</span> -</span><span id="L-4997"><a href="#L-4997"><span class="linenos">4997</span></a> -</span><span id="L-4998"><a href="#L-4998"><span class="linenos">4998</span></a><span class="sd"> Example:</span> -</span><span id="L-4999"><a href="#L-4999"><span class="linenos">4999</span></a><span class="sd"> >>> update("my_table", {"x": 1, "y": "2", "z": None}, from_="baz", where="id > 1").sql()</span> -</span><span id="L-5000"><a href="#L-5000"><span class="linenos">5000</span></a><span class="sd"> "UPDATE my_table SET x = 1, y = '2', z = NULL FROM baz WHERE id > 1"</span> -</span><span id="L-5001"><a href="#L-5001"><span class="linenos">5001</span></a> -</span><span id="L-5002"><a href="#L-5002"><span class="linenos">5002</span></a><span class="sd"> Args:</span> -</span><span id="L-5003"><a href="#L-5003"><span class="linenos">5003</span></a><span class="sd"> *properties: dictionary of properties to set which are</span> -</span><span id="L-5004"><a href="#L-5004"><span class="linenos">5004</span></a><span class="sd"> auto converted to sql objects eg None -> NULL</span> -</span><span id="L-5005"><a href="#L-5005"><span class="linenos">5005</span></a><span class="sd"> where: sql conditional parsed into a WHERE statement</span> -</span><span id="L-5006"><a href="#L-5006"><span class="linenos">5006</span></a><span class="sd"> from_: sql statement parsed into a FROM statement</span> -</span><span id="L-5007"><a href="#L-5007"><span class="linenos">5007</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="L-5008"><a href="#L-5008"><span class="linenos">5008</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> -</span><span id="L-5009"><a href="#L-5009"><span class="linenos">5009</span></a> -</span><span id="L-5010"><a href="#L-5010"><span class="linenos">5010</span></a><span class="sd"> Returns:</span> -</span><span id="L-5011"><a href="#L-5011"><span class="linenos">5011</span></a><span class="sd"> Update: the syntax tree for the UPDATE statement.</span> -</span><span id="L-5012"><a href="#L-5012"><span class="linenos">5012</span></a><span class="sd"> """</span> -</span><span id="L-5013"><a href="#L-5013"><span class="linenos">5013</span></a> <span class="n">update_expr</span> <span class="o">=</span> <span class="n">Update</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">))</span> -</span><span id="L-5014"><a href="#L-5014"><span class="linenos">5014</span></a> <span class="n">update_expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="L-5015"><a href="#L-5015"><span class="linenos">5015</span></a> <span class="s2">"expressions"</span><span class="p">,</span> -</span><span id="L-5016"><a href="#L-5016"><span class="linenos">5016</span></a> <span class="p">[</span> -</span><span id="L-5017"><a href="#L-5017"><span class="linenos">5017</span></a> <span class="n">EQ</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">convert</span><span class="p">(</span><span class="n">v</span><span class="p">))</span> -</span><span id="L-5018"><a href="#L-5018"><span class="linenos">5018</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> -</span><span id="L-5019"><a href="#L-5019"><span class="linenos">5019</span></a> <span class="p">],</span> -</span><span id="L-5020"><a href="#L-5020"><span class="linenos">5020</span></a> <span class="p">)</span> -</span><span id="L-5021"><a href="#L-5021"><span class="linenos">5021</span></a> <span class="k">if</span> <span class="n">from_</span><span class="p">:</span> -</span><span id="L-5022"><a href="#L-5022"><span class="linenos">5022</span></a> <span class="n">update_expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="L-5023"><a href="#L-5023"><span class="linenos">5023</span></a> <span class="s2">"from"</span><span class="p">,</span> -</span><span id="L-5024"><a href="#L-5024"><span class="linenos">5024</span></a> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">from_</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">From</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"FROM"</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> -</span><span id="L-5025"><a href="#L-5025"><span class="linenos">5025</span></a> <span class="p">)</span> -</span><span id="L-5026"><a href="#L-5026"><span class="linenos">5026</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">where</span><span class="p">,</span> <span class="n">Condition</span><span class="p">):</span> -</span><span id="L-5027"><a href="#L-5027"><span class="linenos">5027</span></a> <span class="n">where</span> <span class="o">=</span> <span class="n">Where</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">where</span><span class="p">)</span> -</span><span id="L-5028"><a href="#L-5028"><span class="linenos">5028</span></a> <span class="k">if</span> <span class="n">where</span><span class="p">:</span> -</span><span id="L-5029"><a href="#L-5029"><span class="linenos">5029</span></a> <span class="n">update_expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="L-5030"><a href="#L-5030"><span class="linenos">5030</span></a> <span class="s2">"where"</span><span class="p">,</span> -</span><span id="L-5031"><a href="#L-5031"><span class="linenos">5031</span></a> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">where</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Where</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"WHERE"</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> -</span><span id="L-5032"><a href="#L-5032"><span class="linenos">5032</span></a> <span class="p">)</span> -</span><span id="L-5033"><a href="#L-5033"><span class="linenos">5033</span></a> <span class="k">return</span> <span class="n">update_expr</span> -</span><span id="L-5034"><a href="#L-5034"><span class="linenos">5034</span></a> -</span><span id="L-5035"><a href="#L-5035"><span class="linenos">5035</span></a> -</span><span id="L-5036"><a href="#L-5036"><span class="linenos">5036</span></a><span class="k">def</span> <span class="nf">delete</span><span class="p">(</span> -</span><span id="L-5037"><a href="#L-5037"><span class="linenos">5037</span></a> <span class="n">table</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="L-5038"><a href="#L-5038"><span class="linenos">5038</span></a> <span class="n">where</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-5039"><a href="#L-5039"><span class="linenos">5039</span></a> <span class="n">returning</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-5040"><a href="#L-5040"><span class="linenos">5040</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-5041"><a href="#L-5041"><span class="linenos">5041</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-5042"><a href="#L-5042"><span class="linenos">5042</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Delete</span><span class="p">:</span> -</span><span id="L-5043"><a href="#L-5043"><span class="linenos">5043</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-5044"><a href="#L-5044"><span class="linenos">5044</span></a><span class="sd"> Builds a delete statement.</span> -</span><span id="L-5045"><a href="#L-5045"><span class="linenos">5045</span></a> -</span><span id="L-5046"><a href="#L-5046"><span class="linenos">5046</span></a><span class="sd"> Example:</span> -</span><span id="L-5047"><a href="#L-5047"><span class="linenos">5047</span></a><span class="sd"> >>> delete("my_table", where="id > 1").sql()</span> -</span><span id="L-5048"><a href="#L-5048"><span class="linenos">5048</span></a><span class="sd"> 'DELETE FROM my_table WHERE id > 1'</span> -</span><span id="L-5049"><a href="#L-5049"><span class="linenos">5049</span></a> -</span><span id="L-5050"><a href="#L-5050"><span class="linenos">5050</span></a><span class="sd"> Args:</span> -</span><span id="L-5051"><a href="#L-5051"><span class="linenos">5051</span></a><span class="sd"> where: sql conditional parsed into a WHERE statement</span> -</span><span id="L-5052"><a href="#L-5052"><span class="linenos">5052</span></a><span class="sd"> returning: sql conditional parsed into a RETURNING statement</span> -</span><span id="L-5053"><a href="#L-5053"><span class="linenos">5053</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="L-5054"><a href="#L-5054"><span class="linenos">5054</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> -</span><span id="L-5055"><a href="#L-5055"><span class="linenos">5055</span></a> -</span><span id="L-5056"><a href="#L-5056"><span class="linenos">5056</span></a><span class="sd"> Returns:</span> -</span><span id="L-5057"><a href="#L-5057"><span class="linenos">5057</span></a><span class="sd"> Delete: the syntax tree for the DELETE statement.</span> -</span><span id="L-5058"><a href="#L-5058"><span class="linenos">5058</span></a><span class="sd"> """</span> -</span><span id="L-5059"><a href="#L-5059"><span class="linenos">5059</span></a> <span class="n">delete_expr</span> <span class="o">=</span> <span class="n">Delete</span><span class="p">()</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-5060"><a href="#L-5060"><span class="linenos">5060</span></a> <span class="k">if</span> <span class="n">where</span><span class="p">:</span> -</span><span id="L-5061"><a href="#L-5061"><span class="linenos">5061</span></a> <span class="n">delete_expr</span> <span class="o">=</span> <span class="n">delete_expr</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">where</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-5062"><a href="#L-5062"><span class="linenos">5062</span></a> <span class="k">if</span> <span class="n">returning</span><span class="p">:</span> -</span><span id="L-5063"><a href="#L-5063"><span class="linenos">5063</span></a> <span class="n">delete_expr</span> <span class="o">=</span> <span class="n">delete_expr</span><span class="o">.</span><span class="n">returning</span><span class="p">(</span><span class="n">returning</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-5064"><a href="#L-5064"><span class="linenos">5064</span></a> <span class="k">return</span> <span class="n">delete_expr</span> -</span><span id="L-5065"><a href="#L-5065"><span class="linenos">5065</span></a> -</span><span id="L-5066"><a href="#L-5066"><span class="linenos">5066</span></a> -</span><span id="L-5067"><a href="#L-5067"><span class="linenos">5067</span></a><span class="k">def</span> <span class="nf">insert</span><span class="p">(</span> -</span><span id="L-5068"><a href="#L-5068"><span class="linenos">5068</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="L-5069"><a href="#L-5069"><span class="linenos">5069</span></a> <span class="n">into</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="L-5070"><a href="#L-5070"><span class="linenos">5070</span></a> <span class="n">columns</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="n">ExpOrStr</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-5071"><a href="#L-5071"><span class="linenos">5071</span></a> <span class="n">overwrite</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-5072"><a href="#L-5072"><span class="linenos">5072</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-5073"><a href="#L-5073"><span class="linenos">5073</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-5074"><a href="#L-5074"><span class="linenos">5074</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-5075"><a href="#L-5075"><span class="linenos">5075</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Insert</span><span class="p">:</span> -</span><span id="L-5076"><a href="#L-5076"><span class="linenos">5076</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-5077"><a href="#L-5077"><span class="linenos">5077</span></a><span class="sd"> Builds an INSERT statement.</span> -</span><span id="L-5078"><a href="#L-5078"><span class="linenos">5078</span></a> -</span><span id="L-5079"><a href="#L-5079"><span class="linenos">5079</span></a><span class="sd"> Example:</span> -</span><span id="L-5080"><a href="#L-5080"><span class="linenos">5080</span></a><span class="sd"> >>> insert("VALUES (1, 2, 3)", "tbl").sql()</span> -</span><span id="L-5081"><a href="#L-5081"><span class="linenos">5081</span></a><span class="sd"> 'INSERT INTO tbl VALUES (1, 2, 3)'</span> -</span><span id="L-5082"><a href="#L-5082"><span class="linenos">5082</span></a> -</span><span id="L-5083"><a href="#L-5083"><span class="linenos">5083</span></a><span class="sd"> Args:</span> -</span><span id="L-5084"><a href="#L-5084"><span class="linenos">5084</span></a><span class="sd"> expression: the sql string or expression of the INSERT statement</span> -</span><span id="L-5085"><a href="#L-5085"><span class="linenos">5085</span></a><span class="sd"> into: the tbl to insert data to.</span> -</span><span id="L-5086"><a href="#L-5086"><span class="linenos">5086</span></a><span class="sd"> columns: optionally the table's column names.</span> -</span><span id="L-5087"><a href="#L-5087"><span class="linenos">5087</span></a><span class="sd"> overwrite: whether to INSERT OVERWRITE or not.</span> -</span><span id="L-5088"><a href="#L-5088"><span class="linenos">5088</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="L-5089"><a href="#L-5089"><span class="linenos">5089</span></a><span class="sd"> copy: whether or not to copy the expression.</span> -</span><span id="L-5090"><a href="#L-5090"><span class="linenos">5090</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> -</span><span id="L-5091"><a href="#L-5091"><span class="linenos">5091</span></a> -</span><span id="L-5092"><a href="#L-5092"><span class="linenos">5092</span></a><span class="sd"> Returns:</span> -</span><span id="L-5093"><a href="#L-5093"><span class="linenos">5093</span></a><span class="sd"> Insert: the syntax tree for the INSERT statement.</span> -</span><span id="L-5094"><a href="#L-5094"><span class="linenos">5094</span></a><span class="sd"> """</span> -</span><span id="L-5095"><a href="#L-5095"><span class="linenos">5095</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-5096"><a href="#L-5096"><span class="linenos">5096</span></a> <span class="n">this</span><span class="p">:</span> <span class="n">Table</span> <span class="o">|</span> <span class="n">Schema</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">into</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-5097"><a href="#L-5097"><span class="linenos">5097</span></a> -</span><span id="L-5098"><a href="#L-5098"><span class="linenos">5098</span></a> <span class="k">if</span> <span class="n">columns</span><span class="p">:</span> -</span><span id="L-5099"><a href="#L-5099"><span class="linenos">5099</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">_apply_list_builder</span><span class="p">(</span> -</span><span id="L-5100"><a href="#L-5100"><span class="linenos">5100</span></a> <span class="o">*</span><span class="n">columns</span><span class="p">,</span> -</span><span id="L-5101"><a href="#L-5101"><span class="linenos">5101</span></a> <span class="n">instance</span><span class="o">=</span><span class="n">Schema</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">),</span> -</span><span id="L-5102"><a href="#L-5102"><span class="linenos">5102</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"expressions"</span><span class="p">,</span> -</span><span id="L-5103"><a href="#L-5103"><span class="linenos">5103</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Identifier</span><span class="p">,</span> -</span><span id="L-5104"><a href="#L-5104"><span class="linenos">5104</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="L-5105"><a href="#L-5105"><span class="linenos">5105</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-5106"><a href="#L-5106"><span class="linenos">5106</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-5107"><a href="#L-5107"><span class="linenos">5107</span></a> <span class="p">)</span> -</span><span id="L-5108"><a href="#L-5108"><span class="linenos">5108</span></a> -</span><span id="L-5109"><a href="#L-5109"><span class="linenos">5109</span></a> <span class="k">return</span> <span class="n">Insert</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expr</span><span class="p">,</span> <span class="n">overwrite</span><span class="o">=</span><span class="n">overwrite</span><span class="p">)</span> -</span><span id="L-5110"><a href="#L-5110"><span class="linenos">5110</span></a> -</span><span id="L-5111"><a href="#L-5111"><span class="linenos">5111</span></a> -</span><span id="L-5112"><a href="#L-5112"><span class="linenos">5112</span></a><span class="k">def</span> <span class="nf">condition</span><span class="p">(</span> -</span><span id="L-5113"><a href="#L-5113"><span class="linenos">5113</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="L-5114"><a href="#L-5114"><span class="linenos">5114</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Condition</span><span class="p">:</span> -</span><span id="L-5115"><a href="#L-5115"><span class="linenos">5115</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-5116"><a href="#L-5116"><span class="linenos">5116</span></a><span class="sd"> Initialize a logical condition expression.</span> -</span><span id="L-5117"><a href="#L-5117"><span class="linenos">5117</span></a> -</span><span id="L-5118"><a href="#L-5118"><span class="linenos">5118</span></a><span class="sd"> Example:</span> -</span><span id="L-5119"><a href="#L-5119"><span class="linenos">5119</span></a><span class="sd"> >>> condition("x=1").sql()</span> -</span><span id="L-5120"><a href="#L-5120"><span class="linenos">5120</span></a><span class="sd"> 'x = 1'</span> -</span><span id="L-5121"><a href="#L-5121"><span class="linenos">5121</span></a> -</span><span id="L-5122"><a href="#L-5122"><span class="linenos">5122</span></a><span class="sd"> This is helpful for composing larger logical syntax trees:</span> -</span><span id="L-5123"><a href="#L-5123"><span class="linenos">5123</span></a><span class="sd"> >>> where = condition("x=1")</span> -</span><span id="L-5124"><a href="#L-5124"><span class="linenos">5124</span></a><span class="sd"> >>> where = where.and_("y=1")</span> -</span><span id="L-5125"><a href="#L-5125"><span class="linenos">5125</span></a><span class="sd"> >>> Select().from_("tbl").select("*").where(where).sql()</span> -</span><span id="L-5126"><a href="#L-5126"><span class="linenos">5126</span></a><span class="sd"> 'SELECT * FROM tbl WHERE x = 1 AND y = 1'</span> -</span><span id="L-5127"><a href="#L-5127"><span class="linenos">5127</span></a> -</span><span id="L-5128"><a href="#L-5128"><span class="linenos">5128</span></a><span class="sd"> Args:</span> -</span><span id="L-5129"><a href="#L-5129"><span class="linenos">5129</span></a><span class="sd"> *expression: the SQL code string to parse.</span> -</span><span id="L-5130"><a href="#L-5130"><span class="linenos">5130</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> -</span><span id="L-5131"><a href="#L-5131"><span class="linenos">5131</span></a><span class="sd"> dialect: the dialect used to parse the input expression (in the case that the</span> -</span><span id="L-5132"><a href="#L-5132"><span class="linenos">5132</span></a><span class="sd"> input expression is a SQL string).</span> -</span><span id="L-5133"><a href="#L-5133"><span class="linenos">5133</span></a><span class="sd"> copy: Whether or not to copy `expression` (only applies to expressions).</span> -</span><span id="L-5134"><a href="#L-5134"><span class="linenos">5134</span></a><span class="sd"> **opts: other options to use to parse the input expressions (again, in the case</span> -</span><span id="L-5135"><a href="#L-5135"><span class="linenos">5135</span></a><span class="sd"> that the input expression is a SQL string).</span> -</span><span id="L-5136"><a href="#L-5136"><span class="linenos">5136</span></a> -</span><span id="L-5137"><a href="#L-5137"><span class="linenos">5137</span></a><span class="sd"> Returns:</span> -</span><span id="L-5138"><a href="#L-5138"><span class="linenos">5138</span></a><span class="sd"> The new Condition instance</span> -</span><span id="L-5139"><a href="#L-5139"><span class="linenos">5139</span></a><span class="sd"> """</span> -</span><span id="L-5140"><a href="#L-5140"><span class="linenos">5140</span></a> <span class="k">return</span> <span class="n">maybe_parse</span><span class="p">(</span> -</span><span id="L-5141"><a href="#L-5141"><span class="linenos">5141</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="L-5142"><a href="#L-5142"><span class="linenos">5142</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Condition</span><span class="p">,</span> -</span><span id="L-5143"><a href="#L-5143"><span class="linenos">5143</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-5144"><a href="#L-5144"><span class="linenos">5144</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="L-5145"><a href="#L-5145"><span class="linenos">5145</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-5146"><a href="#L-5146"><span class="linenos">5146</span></a> <span class="p">)</span> -</span><span id="L-5147"><a href="#L-5147"><span class="linenos">5147</span></a> -</span><span id="L-5148"><a href="#L-5148"><span class="linenos">5148</span></a> -</span><span id="L-5149"><a href="#L-5149"><span class="linenos">5149</span></a><span class="k">def</span> <span class="nf">and_</span><span class="p">(</span> -</span><span id="L-5150"><a href="#L-5150"><span class="linenos">5150</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="L-5151"><a href="#L-5151"><span class="linenos">5151</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Condition</span><span class="p">:</span> -</span><span id="L-5152"><a href="#L-5152"><span class="linenos">5152</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-5153"><a href="#L-5153"><span class="linenos">5153</span></a><span class="sd"> Combine multiple conditions with an AND logical operator.</span> -</span><span id="L-5154"><a href="#L-5154"><span class="linenos">5154</span></a> -</span><span id="L-5155"><a href="#L-5155"><span class="linenos">5155</span></a><span class="sd"> Example:</span> -</span><span id="L-5156"><a href="#L-5156"><span class="linenos">5156</span></a><span class="sd"> >>> and_("x=1", and_("y=1", "z=1")).sql()</span> -</span><span id="L-5157"><a href="#L-5157"><span class="linenos">5157</span></a><span class="sd"> 'x = 1 AND (y = 1 AND z = 1)'</span> -</span><span id="L-5158"><a href="#L-5158"><span class="linenos">5158</span></a> -</span><span id="L-5159"><a href="#L-5159"><span class="linenos">5159</span></a><span class="sd"> Args:</span> -</span><span id="L-5160"><a href="#L-5160"><span class="linenos">5160</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="L-5161"><a href="#L-5161"><span class="linenos">5161</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> -</span><span id="L-5162"><a href="#L-5162"><span class="linenos">5162</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="L-5163"><a href="#L-5163"><span class="linenos">5163</span></a><span class="sd"> copy: whether or not to copy `expressions` (only applies to Expressions).</span> -</span><span id="L-5164"><a href="#L-5164"><span class="linenos">5164</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> -</span><span id="L-5165"><a href="#L-5165"><span class="linenos">5165</span></a> -</span><span id="L-5166"><a href="#L-5166"><span class="linenos">5166</span></a><span class="sd"> Returns:</span> -</span><span id="L-5167"><a href="#L-5167"><span class="linenos">5167</span></a><span class="sd"> And: the new condition</span> -</span><span id="L-5168"><a href="#L-5168"><span class="linenos">5168</span></a><span class="sd"> """</span> -</span><span id="L-5169"><a href="#L-5169"><span class="linenos">5169</span></a> <span class="k">return</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">Condition</span><span class="p">,</span> <span class="n">_combine</span><span class="p">(</span><span class="n">expressions</span><span class="p">,</span> <span class="n">And</span><span class="p">,</span> <span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">))</span> +</span><span id="L-4986"><a href="#L-4986"><span class="linenos">4986</span></a><span class="sd"> Returns:</span> +</span><span id="L-4987"><a href="#L-4987"><span class="linenos">4987</span></a><span class="sd"> Select: the syntax tree for the SELECT statement.</span> +</span><span id="L-4988"><a href="#L-4988"><span class="linenos">4988</span></a><span class="sd"> """</span> +</span><span id="L-4989"><a href="#L-4989"><span class="linenos">4989</span></a> <span class="k">return</span> <span class="n">Select</span><span class="p">()</span><span class="o">.</span><span class="n">from_</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-4990"><a href="#L-4990"><span class="linenos">4990</span></a> +</span><span id="L-4991"><a href="#L-4991"><span class="linenos">4991</span></a> +</span><span id="L-4992"><a href="#L-4992"><span class="linenos">4992</span></a><span class="k">def</span> <span class="nf">update</span><span class="p">(</span> +</span><span id="L-4993"><a href="#L-4993"><span class="linenos">4993</span></a> <span class="n">table</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Table</span><span class="p">,</span> +</span><span id="L-4994"><a href="#L-4994"><span class="linenos">4994</span></a> <span class="n">properties</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> +</span><span id="L-4995"><a href="#L-4995"><span class="linenos">4995</span></a> <span class="n">where</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-4996"><a href="#L-4996"><span class="linenos">4996</span></a> <span class="n">from_</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-4997"><a href="#L-4997"><span class="linenos">4997</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-4998"><a href="#L-4998"><span class="linenos">4998</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-4999"><a href="#L-4999"><span class="linenos">4999</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Update</span><span class="p">:</span> +</span><span id="L-5000"><a href="#L-5000"><span class="linenos">5000</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-5001"><a href="#L-5001"><span class="linenos">5001</span></a><span class="sd"> Creates an update statement.</span> +</span><span id="L-5002"><a href="#L-5002"><span class="linenos">5002</span></a> +</span><span id="L-5003"><a href="#L-5003"><span class="linenos">5003</span></a><span class="sd"> Example:</span> +</span><span id="L-5004"><a href="#L-5004"><span class="linenos">5004</span></a><span class="sd"> >>> update("my_table", {"x": 1, "y": "2", "z": None}, from_="baz", where="id > 1").sql()</span> +</span><span id="L-5005"><a href="#L-5005"><span class="linenos">5005</span></a><span class="sd"> "UPDATE my_table SET x = 1, y = '2', z = NULL FROM baz WHERE id > 1"</span> +</span><span id="L-5006"><a href="#L-5006"><span class="linenos">5006</span></a> +</span><span id="L-5007"><a href="#L-5007"><span class="linenos">5007</span></a><span class="sd"> Args:</span> +</span><span id="L-5008"><a href="#L-5008"><span class="linenos">5008</span></a><span class="sd"> *properties: dictionary of properties to set which are</span> +</span><span id="L-5009"><a href="#L-5009"><span class="linenos">5009</span></a><span class="sd"> auto converted to sql objects eg None -> NULL</span> +</span><span id="L-5010"><a href="#L-5010"><span class="linenos">5010</span></a><span class="sd"> where: sql conditional parsed into a WHERE statement</span> +</span><span id="L-5011"><a href="#L-5011"><span class="linenos">5011</span></a><span class="sd"> from_: sql statement parsed into a FROM statement</span> +</span><span id="L-5012"><a href="#L-5012"><span class="linenos">5012</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="L-5013"><a href="#L-5013"><span class="linenos">5013</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> +</span><span id="L-5014"><a href="#L-5014"><span class="linenos">5014</span></a> +</span><span id="L-5015"><a href="#L-5015"><span class="linenos">5015</span></a><span class="sd"> Returns:</span> +</span><span id="L-5016"><a href="#L-5016"><span class="linenos">5016</span></a><span class="sd"> Update: the syntax tree for the UPDATE statement.</span> +</span><span id="L-5017"><a href="#L-5017"><span class="linenos">5017</span></a><span class="sd"> """</span> +</span><span id="L-5018"><a href="#L-5018"><span class="linenos">5018</span></a> <span class="n">update_expr</span> <span class="o">=</span> <span class="n">Update</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">))</span> +</span><span id="L-5019"><a href="#L-5019"><span class="linenos">5019</span></a> <span class="n">update_expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="L-5020"><a href="#L-5020"><span class="linenos">5020</span></a> <span class="s2">"expressions"</span><span class="p">,</span> +</span><span id="L-5021"><a href="#L-5021"><span class="linenos">5021</span></a> <span class="p">[</span> +</span><span id="L-5022"><a href="#L-5022"><span class="linenos">5022</span></a> <span class="n">EQ</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">convert</span><span class="p">(</span><span class="n">v</span><span class="p">))</span> +</span><span id="L-5023"><a href="#L-5023"><span class="linenos">5023</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> +</span><span id="L-5024"><a href="#L-5024"><span class="linenos">5024</span></a> <span class="p">],</span> +</span><span id="L-5025"><a href="#L-5025"><span class="linenos">5025</span></a> <span class="p">)</span> +</span><span id="L-5026"><a href="#L-5026"><span class="linenos">5026</span></a> <span class="k">if</span> <span class="n">from_</span><span class="p">:</span> +</span><span id="L-5027"><a href="#L-5027"><span class="linenos">5027</span></a> <span class="n">update_expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="L-5028"><a href="#L-5028"><span class="linenos">5028</span></a> <span class="s2">"from"</span><span class="p">,</span> +</span><span id="L-5029"><a href="#L-5029"><span class="linenos">5029</span></a> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">from_</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">From</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"FROM"</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> +</span><span id="L-5030"><a href="#L-5030"><span class="linenos">5030</span></a> <span class="p">)</span> +</span><span id="L-5031"><a href="#L-5031"><span class="linenos">5031</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">where</span><span class="p">,</span> <span class="n">Condition</span><span class="p">):</span> +</span><span id="L-5032"><a href="#L-5032"><span class="linenos">5032</span></a> <span class="n">where</span> <span class="o">=</span> <span class="n">Where</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">where</span><span class="p">)</span> +</span><span id="L-5033"><a href="#L-5033"><span class="linenos">5033</span></a> <span class="k">if</span> <span class="n">where</span><span class="p">:</span> +</span><span id="L-5034"><a href="#L-5034"><span class="linenos">5034</span></a> <span class="n">update_expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="L-5035"><a href="#L-5035"><span class="linenos">5035</span></a> <span class="s2">"where"</span><span class="p">,</span> +</span><span id="L-5036"><a href="#L-5036"><span class="linenos">5036</span></a> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">where</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Where</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"WHERE"</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> +</span><span id="L-5037"><a href="#L-5037"><span class="linenos">5037</span></a> <span class="p">)</span> +</span><span id="L-5038"><a href="#L-5038"><span class="linenos">5038</span></a> <span class="k">return</span> <span class="n">update_expr</span> +</span><span id="L-5039"><a href="#L-5039"><span class="linenos">5039</span></a> +</span><span id="L-5040"><a href="#L-5040"><span class="linenos">5040</span></a> +</span><span id="L-5041"><a href="#L-5041"><span class="linenos">5041</span></a><span class="k">def</span> <span class="nf">delete</span><span class="p">(</span> +</span><span id="L-5042"><a href="#L-5042"><span class="linenos">5042</span></a> <span class="n">table</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="L-5043"><a href="#L-5043"><span class="linenos">5043</span></a> <span class="n">where</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-5044"><a href="#L-5044"><span class="linenos">5044</span></a> <span class="n">returning</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-5045"><a href="#L-5045"><span class="linenos">5045</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-5046"><a href="#L-5046"><span class="linenos">5046</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-5047"><a href="#L-5047"><span class="linenos">5047</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Delete</span><span class="p">:</span> +</span><span id="L-5048"><a href="#L-5048"><span class="linenos">5048</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-5049"><a href="#L-5049"><span class="linenos">5049</span></a><span class="sd"> Builds a delete statement.</span> +</span><span id="L-5050"><a href="#L-5050"><span class="linenos">5050</span></a> +</span><span id="L-5051"><a href="#L-5051"><span class="linenos">5051</span></a><span class="sd"> Example:</span> +</span><span id="L-5052"><a href="#L-5052"><span class="linenos">5052</span></a><span class="sd"> >>> delete("my_table", where="id > 1").sql()</span> +</span><span id="L-5053"><a href="#L-5053"><span class="linenos">5053</span></a><span class="sd"> 'DELETE FROM my_table WHERE id > 1'</span> +</span><span id="L-5054"><a href="#L-5054"><span class="linenos">5054</span></a> +</span><span id="L-5055"><a href="#L-5055"><span class="linenos">5055</span></a><span class="sd"> Args:</span> +</span><span id="L-5056"><a href="#L-5056"><span class="linenos">5056</span></a><span class="sd"> where: sql conditional parsed into a WHERE statement</span> +</span><span id="L-5057"><a href="#L-5057"><span class="linenos">5057</span></a><span class="sd"> returning: sql conditional parsed into a RETURNING statement</span> +</span><span id="L-5058"><a href="#L-5058"><span class="linenos">5058</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="L-5059"><a href="#L-5059"><span class="linenos">5059</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> +</span><span id="L-5060"><a href="#L-5060"><span class="linenos">5060</span></a> +</span><span id="L-5061"><a href="#L-5061"><span class="linenos">5061</span></a><span class="sd"> Returns:</span> +</span><span id="L-5062"><a href="#L-5062"><span class="linenos">5062</span></a><span class="sd"> Delete: the syntax tree for the DELETE statement.</span> +</span><span id="L-5063"><a href="#L-5063"><span class="linenos">5063</span></a><span class="sd"> """</span> +</span><span id="L-5064"><a href="#L-5064"><span class="linenos">5064</span></a> <span class="n">delete_expr</span> <span class="o">=</span> <span class="n">Delete</span><span class="p">()</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-5065"><a href="#L-5065"><span class="linenos">5065</span></a> <span class="k">if</span> <span class="n">where</span><span class="p">:</span> +</span><span id="L-5066"><a href="#L-5066"><span class="linenos">5066</span></a> <span class="n">delete_expr</span> <span class="o">=</span> <span class="n">delete_expr</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">where</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-5067"><a href="#L-5067"><span class="linenos">5067</span></a> <span class="k">if</span> <span class="n">returning</span><span class="p">:</span> +</span><span id="L-5068"><a href="#L-5068"><span class="linenos">5068</span></a> <span class="n">delete_expr</span> <span class="o">=</span> <span class="n">delete_expr</span><span class="o">.</span><span class="n">returning</span><span class="p">(</span><span class="n">returning</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-5069"><a href="#L-5069"><span class="linenos">5069</span></a> <span class="k">return</span> <span class="n">delete_expr</span> +</span><span id="L-5070"><a href="#L-5070"><span class="linenos">5070</span></a> +</span><span id="L-5071"><a href="#L-5071"><span class="linenos">5071</span></a> +</span><span id="L-5072"><a href="#L-5072"><span class="linenos">5072</span></a><span class="k">def</span> <span class="nf">insert</span><span class="p">(</span> +</span><span id="L-5073"><a href="#L-5073"><span class="linenos">5073</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="L-5074"><a href="#L-5074"><span class="linenos">5074</span></a> <span class="n">into</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="L-5075"><a href="#L-5075"><span class="linenos">5075</span></a> <span class="n">columns</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="n">ExpOrStr</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-5076"><a href="#L-5076"><span class="linenos">5076</span></a> <span class="n">overwrite</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-5077"><a href="#L-5077"><span class="linenos">5077</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-5078"><a href="#L-5078"><span class="linenos">5078</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-5079"><a href="#L-5079"><span class="linenos">5079</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-5080"><a href="#L-5080"><span class="linenos">5080</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Insert</span><span class="p">:</span> +</span><span id="L-5081"><a href="#L-5081"><span class="linenos">5081</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-5082"><a href="#L-5082"><span class="linenos">5082</span></a><span class="sd"> Builds an INSERT statement.</span> +</span><span id="L-5083"><a href="#L-5083"><span class="linenos">5083</span></a> +</span><span id="L-5084"><a href="#L-5084"><span class="linenos">5084</span></a><span class="sd"> Example:</span> +</span><span id="L-5085"><a href="#L-5085"><span class="linenos">5085</span></a><span class="sd"> >>> insert("VALUES (1, 2, 3)", "tbl").sql()</span> +</span><span id="L-5086"><a href="#L-5086"><span class="linenos">5086</span></a><span class="sd"> 'INSERT INTO tbl VALUES (1, 2, 3)'</span> +</span><span id="L-5087"><a href="#L-5087"><span class="linenos">5087</span></a> +</span><span id="L-5088"><a href="#L-5088"><span class="linenos">5088</span></a><span class="sd"> Args:</span> +</span><span id="L-5089"><a href="#L-5089"><span class="linenos">5089</span></a><span class="sd"> expression: the sql string or expression of the INSERT statement</span> +</span><span id="L-5090"><a href="#L-5090"><span class="linenos">5090</span></a><span class="sd"> into: the tbl to insert data to.</span> +</span><span id="L-5091"><a href="#L-5091"><span class="linenos">5091</span></a><span class="sd"> columns: optionally the table's column names.</span> +</span><span id="L-5092"><a href="#L-5092"><span class="linenos">5092</span></a><span class="sd"> overwrite: whether to INSERT OVERWRITE or not.</span> +</span><span id="L-5093"><a href="#L-5093"><span class="linenos">5093</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="L-5094"><a href="#L-5094"><span class="linenos">5094</span></a><span class="sd"> copy: whether or not to copy the expression.</span> +</span><span id="L-5095"><a href="#L-5095"><span class="linenos">5095</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> +</span><span id="L-5096"><a href="#L-5096"><span class="linenos">5096</span></a> +</span><span id="L-5097"><a href="#L-5097"><span class="linenos">5097</span></a><span class="sd"> Returns:</span> +</span><span id="L-5098"><a href="#L-5098"><span class="linenos">5098</span></a><span class="sd"> Insert: the syntax tree for the INSERT statement.</span> +</span><span id="L-5099"><a href="#L-5099"><span class="linenos">5099</span></a><span class="sd"> """</span> +</span><span id="L-5100"><a href="#L-5100"><span class="linenos">5100</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-5101"><a href="#L-5101"><span class="linenos">5101</span></a> <span class="n">this</span><span class="p">:</span> <span class="n">Table</span> <span class="o">|</span> <span class="n">Schema</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">into</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-5102"><a href="#L-5102"><span class="linenos">5102</span></a> +</span><span id="L-5103"><a href="#L-5103"><span class="linenos">5103</span></a> <span class="k">if</span> <span class="n">columns</span><span class="p">:</span> +</span><span id="L-5104"><a href="#L-5104"><span class="linenos">5104</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">_apply_list_builder</span><span class="p">(</span> +</span><span id="L-5105"><a href="#L-5105"><span class="linenos">5105</span></a> <span class="o">*</span><span class="n">columns</span><span class="p">,</span> +</span><span id="L-5106"><a href="#L-5106"><span class="linenos">5106</span></a> <span class="n">instance</span><span class="o">=</span><span class="n">Schema</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">),</span> +</span><span id="L-5107"><a href="#L-5107"><span class="linenos">5107</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"expressions"</span><span class="p">,</span> +</span><span id="L-5108"><a href="#L-5108"><span class="linenos">5108</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Identifier</span><span class="p">,</span> +</span><span id="L-5109"><a href="#L-5109"><span class="linenos">5109</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="L-5110"><a href="#L-5110"><span class="linenos">5110</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-5111"><a href="#L-5111"><span class="linenos">5111</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-5112"><a href="#L-5112"><span class="linenos">5112</span></a> <span class="p">)</span> +</span><span id="L-5113"><a href="#L-5113"><span class="linenos">5113</span></a> +</span><span id="L-5114"><a href="#L-5114"><span class="linenos">5114</span></a> <span class="k">return</span> <span class="n">Insert</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expr</span><span class="p">,</span> <span class="n">overwrite</span><span class="o">=</span><span class="n">overwrite</span><span class="p">)</span> +</span><span id="L-5115"><a href="#L-5115"><span class="linenos">5115</span></a> +</span><span id="L-5116"><a href="#L-5116"><span class="linenos">5116</span></a> +</span><span id="L-5117"><a href="#L-5117"><span class="linenos">5117</span></a><span class="k">def</span> <span class="nf">condition</span><span class="p">(</span> +</span><span id="L-5118"><a href="#L-5118"><span class="linenos">5118</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="L-5119"><a href="#L-5119"><span class="linenos">5119</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Condition</span><span class="p">:</span> +</span><span id="L-5120"><a href="#L-5120"><span class="linenos">5120</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-5121"><a href="#L-5121"><span class="linenos">5121</span></a><span class="sd"> Initialize a logical condition expression.</span> +</span><span id="L-5122"><a href="#L-5122"><span class="linenos">5122</span></a> +</span><span id="L-5123"><a href="#L-5123"><span class="linenos">5123</span></a><span class="sd"> Example:</span> +</span><span id="L-5124"><a href="#L-5124"><span class="linenos">5124</span></a><span class="sd"> >>> condition("x=1").sql()</span> +</span><span id="L-5125"><a href="#L-5125"><span class="linenos">5125</span></a><span class="sd"> 'x = 1'</span> +</span><span id="L-5126"><a href="#L-5126"><span class="linenos">5126</span></a> +</span><span id="L-5127"><a href="#L-5127"><span class="linenos">5127</span></a><span class="sd"> This is helpful for composing larger logical syntax trees:</span> +</span><span id="L-5128"><a href="#L-5128"><span class="linenos">5128</span></a><span class="sd"> >>> where = condition("x=1")</span> +</span><span id="L-5129"><a href="#L-5129"><span class="linenos">5129</span></a><span class="sd"> >>> where = where.and_("y=1")</span> +</span><span id="L-5130"><a href="#L-5130"><span class="linenos">5130</span></a><span class="sd"> >>> Select().from_("tbl").select("*").where(where).sql()</span> +</span><span id="L-5131"><a href="#L-5131"><span class="linenos">5131</span></a><span class="sd"> 'SELECT * FROM tbl WHERE x = 1 AND y = 1'</span> +</span><span id="L-5132"><a href="#L-5132"><span class="linenos">5132</span></a> +</span><span id="L-5133"><a href="#L-5133"><span class="linenos">5133</span></a><span class="sd"> Args:</span> +</span><span id="L-5134"><a href="#L-5134"><span class="linenos">5134</span></a><span class="sd"> *expression: the SQL code string to parse.</span> +</span><span id="L-5135"><a href="#L-5135"><span class="linenos">5135</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> +</span><span id="L-5136"><a href="#L-5136"><span class="linenos">5136</span></a><span class="sd"> dialect: the dialect used to parse the input expression (in the case that the</span> +</span><span id="L-5137"><a href="#L-5137"><span class="linenos">5137</span></a><span class="sd"> input expression is a SQL string).</span> +</span><span id="L-5138"><a href="#L-5138"><span class="linenos">5138</span></a><span class="sd"> copy: Whether or not to copy `expression` (only applies to expressions).</span> +</span><span id="L-5139"><a href="#L-5139"><span class="linenos">5139</span></a><span class="sd"> **opts: other options to use to parse the input expressions (again, in the case</span> +</span><span id="L-5140"><a href="#L-5140"><span class="linenos">5140</span></a><span class="sd"> that the input expression is a SQL string).</span> +</span><span id="L-5141"><a href="#L-5141"><span class="linenos">5141</span></a> +</span><span id="L-5142"><a href="#L-5142"><span class="linenos">5142</span></a><span class="sd"> Returns:</span> +</span><span id="L-5143"><a href="#L-5143"><span class="linenos">5143</span></a><span class="sd"> The new Condition instance</span> +</span><span id="L-5144"><a href="#L-5144"><span class="linenos">5144</span></a><span class="sd"> """</span> +</span><span id="L-5145"><a href="#L-5145"><span class="linenos">5145</span></a> <span class="k">return</span> <span class="n">maybe_parse</span><span class="p">(</span> +</span><span id="L-5146"><a href="#L-5146"><span class="linenos">5146</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="L-5147"><a href="#L-5147"><span class="linenos">5147</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Condition</span><span class="p">,</span> +</span><span id="L-5148"><a href="#L-5148"><span class="linenos">5148</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-5149"><a href="#L-5149"><span class="linenos">5149</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="L-5150"><a href="#L-5150"><span class="linenos">5150</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-5151"><a href="#L-5151"><span class="linenos">5151</span></a> <span class="p">)</span> +</span><span id="L-5152"><a href="#L-5152"><span class="linenos">5152</span></a> +</span><span id="L-5153"><a href="#L-5153"><span class="linenos">5153</span></a> +</span><span id="L-5154"><a href="#L-5154"><span class="linenos">5154</span></a><span class="k">def</span> <span class="nf">and_</span><span class="p">(</span> +</span><span id="L-5155"><a href="#L-5155"><span class="linenos">5155</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="L-5156"><a href="#L-5156"><span class="linenos">5156</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Condition</span><span class="p">:</span> +</span><span id="L-5157"><a href="#L-5157"><span class="linenos">5157</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-5158"><a href="#L-5158"><span class="linenos">5158</span></a><span class="sd"> Combine multiple conditions with an AND logical operator.</span> +</span><span id="L-5159"><a href="#L-5159"><span class="linenos">5159</span></a> +</span><span id="L-5160"><a href="#L-5160"><span class="linenos">5160</span></a><span class="sd"> Example:</span> +</span><span id="L-5161"><a href="#L-5161"><span class="linenos">5161</span></a><span class="sd"> >>> and_("x=1", and_("y=1", "z=1")).sql()</span> +</span><span id="L-5162"><a href="#L-5162"><span class="linenos">5162</span></a><span class="sd"> 'x = 1 AND (y = 1 AND z = 1)'</span> +</span><span id="L-5163"><a href="#L-5163"><span class="linenos">5163</span></a> +</span><span id="L-5164"><a href="#L-5164"><span class="linenos">5164</span></a><span class="sd"> Args:</span> +</span><span id="L-5165"><a href="#L-5165"><span class="linenos">5165</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="L-5166"><a href="#L-5166"><span class="linenos">5166</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> +</span><span id="L-5167"><a href="#L-5167"><span class="linenos">5167</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="L-5168"><a href="#L-5168"><span class="linenos">5168</span></a><span class="sd"> copy: whether or not to copy `expressions` (only applies to Expressions).</span> +</span><span id="L-5169"><a href="#L-5169"><span class="linenos">5169</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> </span><span id="L-5170"><a href="#L-5170"><span class="linenos">5170</span></a> -</span><span id="L-5171"><a href="#L-5171"><span class="linenos">5171</span></a> -</span><span id="L-5172"><a href="#L-5172"><span class="linenos">5172</span></a><span class="k">def</span> <span class="nf">or_</span><span class="p">(</span> -</span><span id="L-5173"><a href="#L-5173"><span class="linenos">5173</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="L-5174"><a href="#L-5174"><span class="linenos">5174</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Condition</span><span class="p">:</span> -</span><span id="L-5175"><a href="#L-5175"><span class="linenos">5175</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-5176"><a href="#L-5176"><span class="linenos">5176</span></a><span class="sd"> Combine multiple conditions with an OR logical operator.</span> -</span><span id="L-5177"><a href="#L-5177"><span class="linenos">5177</span></a> -</span><span id="L-5178"><a href="#L-5178"><span class="linenos">5178</span></a><span class="sd"> Example:</span> -</span><span id="L-5179"><a href="#L-5179"><span class="linenos">5179</span></a><span class="sd"> >>> or_("x=1", or_("y=1", "z=1")).sql()</span> -</span><span id="L-5180"><a href="#L-5180"><span class="linenos">5180</span></a><span class="sd"> 'x = 1 OR (y = 1 OR z = 1)'</span> -</span><span id="L-5181"><a href="#L-5181"><span class="linenos">5181</span></a> -</span><span id="L-5182"><a href="#L-5182"><span class="linenos">5182</span></a><span class="sd"> Args:</span> -</span><span id="L-5183"><a href="#L-5183"><span class="linenos">5183</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="L-5184"><a href="#L-5184"><span class="linenos">5184</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> -</span><span id="L-5185"><a href="#L-5185"><span class="linenos">5185</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="L-5186"><a href="#L-5186"><span class="linenos">5186</span></a><span class="sd"> copy: whether or not to copy `expressions` (only applies to Expressions).</span> -</span><span id="L-5187"><a href="#L-5187"><span class="linenos">5187</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> -</span><span id="L-5188"><a href="#L-5188"><span class="linenos">5188</span></a> -</span><span id="L-5189"><a href="#L-5189"><span class="linenos">5189</span></a><span class="sd"> Returns:</span> -</span><span id="L-5190"><a href="#L-5190"><span class="linenos">5190</span></a><span class="sd"> Or: the new condition</span> -</span><span id="L-5191"><a href="#L-5191"><span class="linenos">5191</span></a><span class="sd"> """</span> -</span><span id="L-5192"><a href="#L-5192"><span class="linenos">5192</span></a> <span class="k">return</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">Condition</span><span class="p">,</span> <span class="n">_combine</span><span class="p">(</span><span class="n">expressions</span><span class="p">,</span> <span class="n">Or</span><span class="p">,</span> <span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">))</span> +</span><span id="L-5171"><a href="#L-5171"><span class="linenos">5171</span></a><span class="sd"> Returns:</span> +</span><span id="L-5172"><a href="#L-5172"><span class="linenos">5172</span></a><span class="sd"> And: the new condition</span> +</span><span id="L-5173"><a href="#L-5173"><span class="linenos">5173</span></a><span class="sd"> """</span> +</span><span id="L-5174"><a href="#L-5174"><span class="linenos">5174</span></a> <span class="k">return</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">Condition</span><span class="p">,</span> <span class="n">_combine</span><span class="p">(</span><span class="n">expressions</span><span class="p">,</span> <span class="n">And</span><span class="p">,</span> <span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">))</span> +</span><span id="L-5175"><a href="#L-5175"><span class="linenos">5175</span></a> +</span><span id="L-5176"><a href="#L-5176"><span class="linenos">5176</span></a> +</span><span id="L-5177"><a href="#L-5177"><span class="linenos">5177</span></a><span class="k">def</span> <span class="nf">or_</span><span class="p">(</span> +</span><span id="L-5178"><a href="#L-5178"><span class="linenos">5178</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="L-5179"><a href="#L-5179"><span class="linenos">5179</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Condition</span><span class="p">:</span> +</span><span id="L-5180"><a href="#L-5180"><span class="linenos">5180</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-5181"><a href="#L-5181"><span class="linenos">5181</span></a><span class="sd"> Combine multiple conditions with an OR logical operator.</span> +</span><span id="L-5182"><a href="#L-5182"><span class="linenos">5182</span></a> +</span><span id="L-5183"><a href="#L-5183"><span class="linenos">5183</span></a><span class="sd"> Example:</span> +</span><span id="L-5184"><a href="#L-5184"><span class="linenos">5184</span></a><span class="sd"> >>> or_("x=1", or_("y=1", "z=1")).sql()</span> +</span><span id="L-5185"><a href="#L-5185"><span class="linenos">5185</span></a><span class="sd"> 'x = 1 OR (y = 1 OR z = 1)'</span> +</span><span id="L-5186"><a href="#L-5186"><span class="linenos">5186</span></a> +</span><span id="L-5187"><a href="#L-5187"><span class="linenos">5187</span></a><span class="sd"> Args:</span> +</span><span id="L-5188"><a href="#L-5188"><span class="linenos">5188</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="L-5189"><a href="#L-5189"><span class="linenos">5189</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> +</span><span id="L-5190"><a href="#L-5190"><span class="linenos">5190</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="L-5191"><a href="#L-5191"><span class="linenos">5191</span></a><span class="sd"> copy: whether or not to copy `expressions` (only applies to Expressions).</span> +</span><span id="L-5192"><a href="#L-5192"><span class="linenos">5192</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> </span><span id="L-5193"><a href="#L-5193"><span class="linenos">5193</span></a> -</span><span id="L-5194"><a href="#L-5194"><span class="linenos">5194</span></a> -</span><span id="L-5195"><a href="#L-5195"><span class="linenos">5195</span></a><span class="k">def</span> <span class="nf">not_</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Not</span><span class="p">:</span> -</span><span id="L-5196"><a href="#L-5196"><span class="linenos">5196</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-5197"><a href="#L-5197"><span class="linenos">5197</span></a><span class="sd"> Wrap a condition with a NOT operator.</span> +</span><span id="L-5194"><a href="#L-5194"><span class="linenos">5194</span></a><span class="sd"> Returns:</span> +</span><span id="L-5195"><a href="#L-5195"><span class="linenos">5195</span></a><span class="sd"> Or: the new condition</span> +</span><span id="L-5196"><a href="#L-5196"><span class="linenos">5196</span></a><span class="sd"> """</span> +</span><span id="L-5197"><a href="#L-5197"><span class="linenos">5197</span></a> <span class="k">return</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">Condition</span><span class="p">,</span> <span class="n">_combine</span><span class="p">(</span><span class="n">expressions</span><span class="p">,</span> <span class="n">Or</span><span class="p">,</span> <span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">))</span> </span><span id="L-5198"><a href="#L-5198"><span class="linenos">5198</span></a> -</span><span id="L-5199"><a href="#L-5199"><span class="linenos">5199</span></a><span class="sd"> Example:</span> -</span><span id="L-5200"><a href="#L-5200"><span class="linenos">5200</span></a><span class="sd"> >>> not_("this_suit='black'").sql()</span> -</span><span id="L-5201"><a href="#L-5201"><span class="linenos">5201</span></a><span class="sd"> "NOT this_suit = 'black'"</span> -</span><span id="L-5202"><a href="#L-5202"><span class="linenos">5202</span></a> -</span><span id="L-5203"><a href="#L-5203"><span class="linenos">5203</span></a><span class="sd"> Args:</span> -</span><span id="L-5204"><a href="#L-5204"><span class="linenos">5204</span></a><span class="sd"> expression: the SQL code string to parse.</span> -</span><span id="L-5205"><a href="#L-5205"><span class="linenos">5205</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> -</span><span id="L-5206"><a href="#L-5206"><span class="linenos">5206</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="L-5207"><a href="#L-5207"><span class="linenos">5207</span></a><span class="sd"> copy: whether to copy the expression or not.</span> -</span><span id="L-5208"><a href="#L-5208"><span class="linenos">5208</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> -</span><span id="L-5209"><a href="#L-5209"><span class="linenos">5209</span></a> -</span><span id="L-5210"><a href="#L-5210"><span class="linenos">5210</span></a><span class="sd"> Returns:</span> -</span><span id="L-5211"><a href="#L-5211"><span class="linenos">5211</span></a><span class="sd"> The new condition.</span> -</span><span id="L-5212"><a href="#L-5212"><span class="linenos">5212</span></a><span class="sd"> """</span> -</span><span id="L-5213"><a href="#L-5213"><span class="linenos">5213</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">condition</span><span class="p">(</span> -</span><span id="L-5214"><a href="#L-5214"><span class="linenos">5214</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="L-5215"><a href="#L-5215"><span class="linenos">5215</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="L-5216"><a href="#L-5216"><span class="linenos">5216</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="L-5217"><a href="#L-5217"><span class="linenos">5217</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-5218"><a href="#L-5218"><span class="linenos">5218</span></a> <span class="p">)</span> -</span><span id="L-5219"><a href="#L-5219"><span class="linenos">5219</span></a> <span class="k">return</span> <span class="n">Not</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">_wrap</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">Connector</span><span class="p">))</span> -</span><span id="L-5220"><a href="#L-5220"><span class="linenos">5220</span></a> -</span><span id="L-5221"><a href="#L-5221"><span class="linenos">5221</span></a> -</span><span id="L-5222"><a href="#L-5222"><span class="linenos">5222</span></a><span class="k">def</span> <span class="nf">paren</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Paren</span><span class="p">:</span> -</span><span id="L-5223"><a href="#L-5223"><span class="linenos">5223</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-5224"><a href="#L-5224"><span class="linenos">5224</span></a><span class="sd"> Wrap an expression in parentheses.</span> +</span><span id="L-5199"><a href="#L-5199"><span class="linenos">5199</span></a> +</span><span id="L-5200"><a href="#L-5200"><span class="linenos">5200</span></a><span class="k">def</span> <span class="nf">not_</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Not</span><span class="p">:</span> +</span><span id="L-5201"><a href="#L-5201"><span class="linenos">5201</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-5202"><a href="#L-5202"><span class="linenos">5202</span></a><span class="sd"> Wrap a condition with a NOT operator.</span> +</span><span id="L-5203"><a href="#L-5203"><span class="linenos">5203</span></a> +</span><span id="L-5204"><a href="#L-5204"><span class="linenos">5204</span></a><span class="sd"> Example:</span> +</span><span id="L-5205"><a href="#L-5205"><span class="linenos">5205</span></a><span class="sd"> >>> not_("this_suit='black'").sql()</span> +</span><span id="L-5206"><a href="#L-5206"><span class="linenos">5206</span></a><span class="sd"> "NOT this_suit = 'black'"</span> +</span><span id="L-5207"><a href="#L-5207"><span class="linenos">5207</span></a> +</span><span id="L-5208"><a href="#L-5208"><span class="linenos">5208</span></a><span class="sd"> Args:</span> +</span><span id="L-5209"><a href="#L-5209"><span class="linenos">5209</span></a><span class="sd"> expression: the SQL code string to parse.</span> +</span><span id="L-5210"><a href="#L-5210"><span class="linenos">5210</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> +</span><span id="L-5211"><a href="#L-5211"><span class="linenos">5211</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="L-5212"><a href="#L-5212"><span class="linenos">5212</span></a><span class="sd"> copy: whether to copy the expression or not.</span> +</span><span id="L-5213"><a href="#L-5213"><span class="linenos">5213</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> +</span><span id="L-5214"><a href="#L-5214"><span class="linenos">5214</span></a> +</span><span id="L-5215"><a href="#L-5215"><span class="linenos">5215</span></a><span class="sd"> Returns:</span> +</span><span id="L-5216"><a href="#L-5216"><span class="linenos">5216</span></a><span class="sd"> The new condition.</span> +</span><span id="L-5217"><a href="#L-5217"><span class="linenos">5217</span></a><span class="sd"> """</span> +</span><span id="L-5218"><a href="#L-5218"><span class="linenos">5218</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">condition</span><span class="p">(</span> +</span><span id="L-5219"><a href="#L-5219"><span class="linenos">5219</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="L-5220"><a href="#L-5220"><span class="linenos">5220</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="L-5221"><a href="#L-5221"><span class="linenos">5221</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="L-5222"><a href="#L-5222"><span class="linenos">5222</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-5223"><a href="#L-5223"><span class="linenos">5223</span></a> <span class="p">)</span> +</span><span id="L-5224"><a href="#L-5224"><span class="linenos">5224</span></a> <span class="k">return</span> <span class="n">Not</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">_wrap</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">Connector</span><span class="p">))</span> </span><span id="L-5225"><a href="#L-5225"><span class="linenos">5225</span></a> -</span><span id="L-5226"><a href="#L-5226"><span class="linenos">5226</span></a><span class="sd"> Example:</span> -</span><span id="L-5227"><a href="#L-5227"><span class="linenos">5227</span></a><span class="sd"> >>> paren("5 + 3").sql()</span> -</span><span id="L-5228"><a href="#L-5228"><span class="linenos">5228</span></a><span class="sd"> '(5 + 3)'</span> -</span><span id="L-5229"><a href="#L-5229"><span class="linenos">5229</span></a> -</span><span id="L-5230"><a href="#L-5230"><span class="linenos">5230</span></a><span class="sd"> Args:</span> -</span><span id="L-5231"><a href="#L-5231"><span class="linenos">5231</span></a><span class="sd"> expression: the SQL code string to parse.</span> -</span><span id="L-5232"><a href="#L-5232"><span class="linenos">5232</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> -</span><span id="L-5233"><a href="#L-5233"><span class="linenos">5233</span></a><span class="sd"> copy: whether to copy the expression or not.</span> +</span><span id="L-5226"><a href="#L-5226"><span class="linenos">5226</span></a> +</span><span id="L-5227"><a href="#L-5227"><span class="linenos">5227</span></a><span class="k">def</span> <span class="nf">paren</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Paren</span><span class="p">:</span> +</span><span id="L-5228"><a href="#L-5228"><span class="linenos">5228</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-5229"><a href="#L-5229"><span class="linenos">5229</span></a><span class="sd"> Wrap an expression in parentheses.</span> +</span><span id="L-5230"><a href="#L-5230"><span class="linenos">5230</span></a> +</span><span id="L-5231"><a href="#L-5231"><span class="linenos">5231</span></a><span class="sd"> Example:</span> +</span><span id="L-5232"><a href="#L-5232"><span class="linenos">5232</span></a><span class="sd"> >>> paren("5 + 3").sql()</span> +</span><span id="L-5233"><a href="#L-5233"><span class="linenos">5233</span></a><span class="sd"> '(5 + 3)'</span> </span><span id="L-5234"><a href="#L-5234"><span class="linenos">5234</span></a> -</span><span id="L-5235"><a href="#L-5235"><span class="linenos">5235</span></a><span class="sd"> Returns:</span> -</span><span id="L-5236"><a href="#L-5236"><span class="linenos">5236</span></a><span class="sd"> The wrapped expression.</span> -</span><span id="L-5237"><a href="#L-5237"><span class="linenos">5237</span></a><span class="sd"> """</span> -</span><span id="L-5238"><a href="#L-5238"><span class="linenos">5238</span></a> <span class="k">return</span> <span class="n">Paren</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">))</span> +</span><span id="L-5235"><a href="#L-5235"><span class="linenos">5235</span></a><span class="sd"> Args:</span> +</span><span id="L-5236"><a href="#L-5236"><span class="linenos">5236</span></a><span class="sd"> expression: the SQL code string to parse.</span> +</span><span id="L-5237"><a href="#L-5237"><span class="linenos">5237</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> +</span><span id="L-5238"><a href="#L-5238"><span class="linenos">5238</span></a><span class="sd"> copy: whether to copy the expression or not.</span> </span><span id="L-5239"><a href="#L-5239"><span class="linenos">5239</span></a> -</span><span id="L-5240"><a href="#L-5240"><span class="linenos">5240</span></a> -</span><span id="L-5241"><a href="#L-5241"><span class="linenos">5241</span></a><span class="n">SAFE_IDENTIFIER_RE</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">"^[_a-zA-Z][\w]*$"</span><span class="p">)</span> -</span><span id="L-5242"><a href="#L-5242"><span class="linenos">5242</span></a> -</span><span id="L-5243"><a href="#L-5243"><span class="linenos">5243</span></a> -</span><span id="L-5244"><a href="#L-5244"><span class="linenos">5244</span></a><span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="L-5245"><a href="#L-5245"><span class="linenos">5245</span></a><span class="k">def</span> <span class="nf">to_identifier</span><span class="p">(</span><span class="n">name</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="n">quoted</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-5246"><a href="#L-5246"><span class="linenos">5246</span></a> <span class="o">...</span> +</span><span id="L-5240"><a href="#L-5240"><span class="linenos">5240</span></a><span class="sd"> Returns:</span> +</span><span id="L-5241"><a href="#L-5241"><span class="linenos">5241</span></a><span class="sd"> The wrapped expression.</span> +</span><span id="L-5242"><a href="#L-5242"><span class="linenos">5242</span></a><span class="sd"> """</span> +</span><span id="L-5243"><a href="#L-5243"><span class="linenos">5243</span></a> <span class="k">return</span> <span class="n">Paren</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">))</span> +</span><span id="L-5244"><a href="#L-5244"><span class="linenos">5244</span></a> +</span><span id="L-5245"><a href="#L-5245"><span class="linenos">5245</span></a> +</span><span id="L-5246"><a href="#L-5246"><span class="linenos">5246</span></a><span class="n">SAFE_IDENTIFIER_RE</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">"^[_a-zA-Z][\w]*$"</span><span class="p">)</span> </span><span id="L-5247"><a href="#L-5247"><span class="linenos">5247</span></a> </span><span id="L-5248"><a href="#L-5248"><span class="linenos">5248</span></a> </span><span id="L-5249"><a href="#L-5249"><span class="linenos">5249</span></a><span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="L-5250"><a href="#L-5250"><span class="linenos">5250</span></a><span class="k">def</span> <span class="nf">to_identifier</span><span class="p">(</span> -</span><span id="L-5251"><a href="#L-5251"><span class="linenos">5251</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">,</span> <span class="n">quoted</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-5252"><a href="#L-5252"><span class="linenos">5252</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Identifier</span><span class="p">:</span> -</span><span id="L-5253"><a href="#L-5253"><span class="linenos">5253</span></a> <span class="o">...</span> -</span><span id="L-5254"><a href="#L-5254"><span class="linenos">5254</span></a> -</span><span id="L-5255"><a href="#L-5255"><span class="linenos">5255</span></a> -</span><span id="L-5256"><a href="#L-5256"><span class="linenos">5256</span></a><span class="k">def</span> <span class="nf">to_identifier</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="kc">None</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-5257"><a href="#L-5257"><span class="linenos">5257</span></a><span class="w"> </span><span class="sd">"""Builds an identifier.</span> -</span><span id="L-5258"><a href="#L-5258"><span class="linenos">5258</span></a> -</span><span id="L-5259"><a href="#L-5259"><span class="linenos">5259</span></a><span class="sd"> Args:</span> -</span><span id="L-5260"><a href="#L-5260"><span class="linenos">5260</span></a><span class="sd"> name: The name to turn into an identifier.</span> -</span><span id="L-5261"><a href="#L-5261"><span class="linenos">5261</span></a><span class="sd"> quoted: Whether or not force quote the identifier.</span> -</span><span id="L-5262"><a href="#L-5262"><span class="linenos">5262</span></a><span class="sd"> copy: Whether or not to copy a passed in Identefier node.</span> +</span><span id="L-5250"><a href="#L-5250"><span class="linenos">5250</span></a><span class="k">def</span> <span class="nf">to_identifier</span><span class="p">(</span><span class="n">name</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="n">quoted</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-5251"><a href="#L-5251"><span class="linenos">5251</span></a> <span class="o">...</span> +</span><span id="L-5252"><a href="#L-5252"><span class="linenos">5252</span></a> +</span><span id="L-5253"><a href="#L-5253"><span class="linenos">5253</span></a> +</span><span id="L-5254"><a href="#L-5254"><span class="linenos">5254</span></a><span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> +</span><span id="L-5255"><a href="#L-5255"><span class="linenos">5255</span></a><span class="k">def</span> <span class="nf">to_identifier</span><span class="p">(</span> +</span><span id="L-5256"><a href="#L-5256"><span class="linenos">5256</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">,</span> <span class="n">quoted</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-5257"><a href="#L-5257"><span class="linenos">5257</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Identifier</span><span class="p">:</span> +</span><span id="L-5258"><a href="#L-5258"><span class="linenos">5258</span></a> <span class="o">...</span> +</span><span id="L-5259"><a href="#L-5259"><span class="linenos">5259</span></a> +</span><span id="L-5260"><a href="#L-5260"><span class="linenos">5260</span></a> +</span><span id="L-5261"><a href="#L-5261"><span class="linenos">5261</span></a><span class="k">def</span> <span class="nf">to_identifier</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="kc">None</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-5262"><a href="#L-5262"><span class="linenos">5262</span></a><span class="w"> </span><span class="sd">"""Builds an identifier.</span> </span><span id="L-5263"><a href="#L-5263"><span class="linenos">5263</span></a> -</span><span id="L-5264"><a href="#L-5264"><span class="linenos">5264</span></a><span class="sd"> Returns:</span> -</span><span id="L-5265"><a href="#L-5265"><span class="linenos">5265</span></a><span class="sd"> The identifier ast node.</span> -</span><span id="L-5266"><a href="#L-5266"><span class="linenos">5266</span></a><span class="sd"> """</span> -</span><span id="L-5267"><a href="#L-5267"><span class="linenos">5267</span></a> -</span><span id="L-5268"><a href="#L-5268"><span class="linenos">5268</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-5269"><a href="#L-5269"><span class="linenos">5269</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-5270"><a href="#L-5270"><span class="linenos">5270</span></a> -</span><span id="L-5271"><a href="#L-5271"><span class="linenos">5271</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">Identifier</span><span class="p">):</span> -</span><span id="L-5272"><a href="#L-5272"><span class="linenos">5272</span></a> <span class="n">identifier</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="L-5273"><a href="#L-5273"><span class="linenos">5273</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="L-5274"><a href="#L-5274"><span class="linenos">5274</span></a> <span class="n">identifier</span> <span class="o">=</span> <span class="n">Identifier</span><span class="p">(</span> -</span><span id="L-5275"><a href="#L-5275"><span class="linenos">5275</span></a> <span class="n">this</span><span class="o">=</span><span class="n">name</span><span class="p">,</span> -</span><span id="L-5276"><a href="#L-5276"><span class="linenos">5276</span></a> <span class="n">quoted</span><span class="o">=</span><span class="ow">not</span> <span class="n">SAFE_IDENTIFIER_RE</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> <span class="k">if</span> <span class="n">quoted</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">quoted</span><span class="p">,</span> -</span><span id="L-5277"><a href="#L-5277"><span class="linenos">5277</span></a> <span class="p">)</span> -</span><span id="L-5278"><a href="#L-5278"><span class="linenos">5278</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-5279"><a href="#L-5279"><span class="linenos">5279</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Name needs to be a string or an Identifier, got: </span><span class="si">{</span><span class="n">name</span><span class="o">.</span><span class="vm">__class__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-5280"><a href="#L-5280"><span class="linenos">5280</span></a> <span class="k">return</span> <span class="n">identifier</span> -</span><span id="L-5281"><a href="#L-5281"><span class="linenos">5281</span></a> -</span><span id="L-5282"><a href="#L-5282"><span class="linenos">5282</span></a> -</span><span id="L-5283"><a href="#L-5283"><span class="linenos">5283</span></a><span class="n">INTERVAL_STRING_RE</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">"\s*([0-9]+)\s*([a-zA-Z]+)\s*"</span><span class="p">)</span> -</span><span id="L-5284"><a href="#L-5284"><span class="linenos">5284</span></a> -</span><span id="L-5285"><a href="#L-5285"><span class="linenos">5285</span></a> -</span><span id="L-5286"><a href="#L-5286"><span class="linenos">5286</span></a><span class="k">def</span> <span class="nf">to_interval</span><span class="p">(</span><span class="n">interval</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Literal</span><span class="p">)</span> <span class="o">-></span> <span class="n">Interval</span><span class="p">:</span> -</span><span id="L-5287"><a href="#L-5287"><span class="linenos">5287</span></a><span class="w"> </span><span class="sd">"""Builds an interval expression from a string like '1 day' or '5 months'."""</span> -</span><span id="L-5288"><a href="#L-5288"><span class="linenos">5288</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">interval</span><span class="p">,</span> <span class="n">Literal</span><span class="p">):</span> -</span><span id="L-5289"><a href="#L-5289"><span class="linenos">5289</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">interval</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> -</span><span id="L-5290"><a href="#L-5290"><span class="linenos">5290</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Invalid interval string."</span><span class="p">)</span> -</span><span id="L-5291"><a href="#L-5291"><span class="linenos">5291</span></a> -</span><span id="L-5292"><a href="#L-5292"><span class="linenos">5292</span></a> <span class="n">interval</span> <span class="o">=</span> <span class="n">interval</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-5293"><a href="#L-5293"><span class="linenos">5293</span></a> -</span><span id="L-5294"><a href="#L-5294"><span class="linenos">5294</span></a> <span class="n">interval_parts</span> <span class="o">=</span> <span class="n">INTERVAL_STRING_RE</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">interval</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="L-5295"><a href="#L-5295"><span class="linenos">5295</span></a> -</span><span id="L-5296"><a href="#L-5296"><span class="linenos">5296</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">interval_parts</span><span class="p">:</span> -</span><span id="L-5297"><a href="#L-5297"><span class="linenos">5297</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Invalid interval string."</span><span class="p">)</span> +</span><span id="L-5264"><a href="#L-5264"><span class="linenos">5264</span></a><span class="sd"> Args:</span> +</span><span id="L-5265"><a href="#L-5265"><span class="linenos">5265</span></a><span class="sd"> name: The name to turn into an identifier.</span> +</span><span id="L-5266"><a href="#L-5266"><span class="linenos">5266</span></a><span class="sd"> quoted: Whether or not force quote the identifier.</span> +</span><span id="L-5267"><a href="#L-5267"><span class="linenos">5267</span></a><span class="sd"> copy: Whether or not to copy a passed in Identefier node.</span> +</span><span id="L-5268"><a href="#L-5268"><span class="linenos">5268</span></a> +</span><span id="L-5269"><a href="#L-5269"><span class="linenos">5269</span></a><span class="sd"> Returns:</span> +</span><span id="L-5270"><a href="#L-5270"><span class="linenos">5270</span></a><span class="sd"> The identifier ast node.</span> +</span><span id="L-5271"><a href="#L-5271"><span class="linenos">5271</span></a><span class="sd"> """</span> +</span><span id="L-5272"><a href="#L-5272"><span class="linenos">5272</span></a> +</span><span id="L-5273"><a href="#L-5273"><span class="linenos">5273</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-5274"><a href="#L-5274"><span class="linenos">5274</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-5275"><a href="#L-5275"><span class="linenos">5275</span></a> +</span><span id="L-5276"><a href="#L-5276"><span class="linenos">5276</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">Identifier</span><span class="p">):</span> +</span><span id="L-5277"><a href="#L-5277"><span class="linenos">5277</span></a> <span class="n">identifier</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="L-5278"><a href="#L-5278"><span class="linenos">5278</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="L-5279"><a href="#L-5279"><span class="linenos">5279</span></a> <span class="n">identifier</span> <span class="o">=</span> <span class="n">Identifier</span><span class="p">(</span> +</span><span id="L-5280"><a href="#L-5280"><span class="linenos">5280</span></a> <span class="n">this</span><span class="o">=</span><span class="n">name</span><span class="p">,</span> +</span><span id="L-5281"><a href="#L-5281"><span class="linenos">5281</span></a> <span class="n">quoted</span><span class="o">=</span><span class="ow">not</span> <span class="n">SAFE_IDENTIFIER_RE</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> <span class="k">if</span> <span class="n">quoted</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">quoted</span><span class="p">,</span> +</span><span id="L-5282"><a href="#L-5282"><span class="linenos">5282</span></a> <span class="p">)</span> +</span><span id="L-5283"><a href="#L-5283"><span class="linenos">5283</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-5284"><a href="#L-5284"><span class="linenos">5284</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Name needs to be a string or an Identifier, got: </span><span class="si">{</span><span class="n">name</span><span class="o">.</span><span class="vm">__class__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-5285"><a href="#L-5285"><span class="linenos">5285</span></a> <span class="k">return</span> <span class="n">identifier</span> +</span><span id="L-5286"><a href="#L-5286"><span class="linenos">5286</span></a> +</span><span id="L-5287"><a href="#L-5287"><span class="linenos">5287</span></a> +</span><span id="L-5288"><a href="#L-5288"><span class="linenos">5288</span></a><span class="n">INTERVAL_STRING_RE</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">"\s*([0-9]+)\s*([a-zA-Z]+)\s*"</span><span class="p">)</span> +</span><span id="L-5289"><a href="#L-5289"><span class="linenos">5289</span></a> +</span><span id="L-5290"><a href="#L-5290"><span class="linenos">5290</span></a> +</span><span id="L-5291"><a href="#L-5291"><span class="linenos">5291</span></a><span class="k">def</span> <span class="nf">to_interval</span><span class="p">(</span><span class="n">interval</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Literal</span><span class="p">)</span> <span class="o">-></span> <span class="n">Interval</span><span class="p">:</span> +</span><span id="L-5292"><a href="#L-5292"><span class="linenos">5292</span></a><span class="w"> </span><span class="sd">"""Builds an interval expression from a string like '1 day' or '5 months'."""</span> +</span><span id="L-5293"><a href="#L-5293"><span class="linenos">5293</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">interval</span><span class="p">,</span> <span class="n">Literal</span><span class="p">):</span> +</span><span id="L-5294"><a href="#L-5294"><span class="linenos">5294</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">interval</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> +</span><span id="L-5295"><a href="#L-5295"><span class="linenos">5295</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Invalid interval string."</span><span class="p">)</span> +</span><span id="L-5296"><a href="#L-5296"><span class="linenos">5296</span></a> +</span><span id="L-5297"><a href="#L-5297"><span class="linenos">5297</span></a> <span class="n">interval</span> <span class="o">=</span> <span class="n">interval</span><span class="o">.</span><span class="n">this</span> </span><span id="L-5298"><a href="#L-5298"><span class="linenos">5298</span></a> -</span><span id="L-5299"><a href="#L-5299"><span class="linenos">5299</span></a> <span class="k">return</span> <span class="n">Interval</span><span class="p">(</span> -</span><span id="L-5300"><a href="#L-5300"><span class="linenos">5300</span></a> <span class="n">this</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">interval_parts</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)),</span> -</span><span id="L-5301"><a href="#L-5301"><span class="linenos">5301</span></a> <span class="n">unit</span><span class="o">=</span><span class="n">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">interval_parts</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">)),</span> -</span><span id="L-5302"><a href="#L-5302"><span class="linenos">5302</span></a> <span class="p">)</span> +</span><span id="L-5299"><a href="#L-5299"><span class="linenos">5299</span></a> <span class="n">interval_parts</span> <span class="o">=</span> <span class="n">INTERVAL_STRING_RE</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">interval</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="L-5300"><a href="#L-5300"><span class="linenos">5300</span></a> +</span><span id="L-5301"><a href="#L-5301"><span class="linenos">5301</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">interval_parts</span><span class="p">:</span> +</span><span id="L-5302"><a href="#L-5302"><span class="linenos">5302</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Invalid interval string."</span><span class="p">)</span> </span><span id="L-5303"><a href="#L-5303"><span class="linenos">5303</span></a> -</span><span id="L-5304"><a href="#L-5304"><span class="linenos">5304</span></a> -</span><span id="L-5305"><a href="#L-5305"><span class="linenos">5305</span></a><span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="L-5306"><a href="#L-5306"><span class="linenos">5306</span></a><span class="k">def</span> <span class="nf">to_table</span><span class="p">(</span><span class="n">sql_path</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Table</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Table</span><span class="p">:</span> -</span><span id="L-5307"><a href="#L-5307"><span class="linenos">5307</span></a> <span class="o">...</span> +</span><span id="L-5304"><a href="#L-5304"><span class="linenos">5304</span></a> <span class="k">return</span> <span class="n">Interval</span><span class="p">(</span> +</span><span id="L-5305"><a href="#L-5305"><span class="linenos">5305</span></a> <span class="n">this</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">interval_parts</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)),</span> +</span><span id="L-5306"><a href="#L-5306"><span class="linenos">5306</span></a> <span class="n">unit</span><span class="o">=</span><span class="n">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">interval_parts</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">)),</span> +</span><span id="L-5307"><a href="#L-5307"><span class="linenos">5307</span></a> <span class="p">)</span> </span><span id="L-5308"><a href="#L-5308"><span class="linenos">5308</span></a> </span><span id="L-5309"><a href="#L-5309"><span class="linenos">5309</span></a> </span><span id="L-5310"><a href="#L-5310"><span class="linenos">5310</span></a><span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="L-5311"><a href="#L-5311"><span class="linenos">5311</span></a><span class="k">def</span> <span class="nf">to_table</span><span class="p">(</span><span class="n">sql_path</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-5311"><a href="#L-5311"><span class="linenos">5311</span></a><span class="k">def</span> <span class="nf">to_table</span><span class="p">(</span><span class="n">sql_path</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Table</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Table</span><span class="p">:</span> </span><span id="L-5312"><a href="#L-5312"><span class="linenos">5312</span></a> <span class="o">...</span> </span><span id="L-5313"><a href="#L-5313"><span class="linenos">5313</span></a> </span><span id="L-5314"><a href="#L-5314"><span class="linenos">5314</span></a> -</span><span id="L-5315"><a href="#L-5315"><span class="linenos">5315</span></a><span class="k">def</span> <span class="nf">to_table</span><span class="p">(</span> -</span><span id="L-5316"><a href="#L-5316"><span class="linenos">5316</span></a> <span class="n">sql_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="nb">str</span> <span class="o">|</span> <span class="n">Table</span><span class="p">],</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> -</span><span id="L-5317"><a href="#L-5317"><span class="linenos">5317</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">Table</span><span class="p">]:</span> -</span><span id="L-5318"><a href="#L-5318"><span class="linenos">5318</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-5319"><a href="#L-5319"><span class="linenos">5319</span></a><span class="sd"> Create a table expression from a `[catalog].[schema].[table]` sql path. Catalog and schema are optional.</span> -</span><span id="L-5320"><a href="#L-5320"><span class="linenos">5320</span></a><span class="sd"> If a table is passed in then that table is returned.</span> -</span><span id="L-5321"><a href="#L-5321"><span class="linenos">5321</span></a> -</span><span id="L-5322"><a href="#L-5322"><span class="linenos">5322</span></a><span class="sd"> Args:</span> -</span><span id="L-5323"><a href="#L-5323"><span class="linenos">5323</span></a><span class="sd"> sql_path: a `[catalog].[schema].[table]` string.</span> -</span><span id="L-5324"><a href="#L-5324"><span class="linenos">5324</span></a><span class="sd"> dialect: the source dialect according to which the table name will be parsed.</span> -</span><span id="L-5325"><a href="#L-5325"><span class="linenos">5325</span></a><span class="sd"> kwargs: the kwargs to instantiate the resulting `Table` expression with.</span> +</span><span id="L-5315"><a href="#L-5315"><span class="linenos">5315</span></a><span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> +</span><span id="L-5316"><a href="#L-5316"><span class="linenos">5316</span></a><span class="k">def</span> <span class="nf">to_table</span><span class="p">(</span><span class="n">sql_path</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-5317"><a href="#L-5317"><span class="linenos">5317</span></a> <span class="o">...</span> +</span><span id="L-5318"><a href="#L-5318"><span class="linenos">5318</span></a> +</span><span id="L-5319"><a href="#L-5319"><span class="linenos">5319</span></a> +</span><span id="L-5320"><a href="#L-5320"><span class="linenos">5320</span></a><span class="k">def</span> <span class="nf">to_table</span><span class="p">(</span> +</span><span id="L-5321"><a href="#L-5321"><span class="linenos">5321</span></a> <span class="n">sql_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="nb">str</span> <span class="o">|</span> <span class="n">Table</span><span class="p">],</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> +</span><span id="L-5322"><a href="#L-5322"><span class="linenos">5322</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">Table</span><span class="p">]:</span> +</span><span id="L-5323"><a href="#L-5323"><span class="linenos">5323</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-5324"><a href="#L-5324"><span class="linenos">5324</span></a><span class="sd"> Create a table expression from a `[catalog].[schema].[table]` sql path. Catalog and schema are optional.</span> +</span><span id="L-5325"><a href="#L-5325"><span class="linenos">5325</span></a><span class="sd"> If a table is passed in then that table is returned.</span> </span><span id="L-5326"><a href="#L-5326"><span class="linenos">5326</span></a> -</span><span id="L-5327"><a href="#L-5327"><span class="linenos">5327</span></a><span class="sd"> Returns:</span> -</span><span id="L-5328"><a href="#L-5328"><span class="linenos">5328</span></a><span class="sd"> A table expression.</span> -</span><span id="L-5329"><a href="#L-5329"><span class="linenos">5329</span></a><span class="sd"> """</span> -</span><span id="L-5330"><a href="#L-5330"><span class="linenos">5330</span></a> <span class="k">if</span> <span class="n">sql_path</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="n">Table</span><span class="p">):</span> -</span><span id="L-5331"><a href="#L-5331"><span class="linenos">5331</span></a> <span class="k">return</span> <span class="n">sql_path</span> -</span><span id="L-5332"><a href="#L-5332"><span class="linenos">5332</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="L-5333"><a href="#L-5333"><span class="linenos">5333</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid type provided for a table: </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">sql_path</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-5334"><a href="#L-5334"><span class="linenos">5334</span></a> -</span><span id="L-5335"><a href="#L-5335"><span class="linenos">5335</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> -</span><span id="L-5336"><a href="#L-5336"><span class="linenos">5336</span></a> <span class="k">if</span> <span class="n">table</span><span class="p">:</span> -</span><span id="L-5337"><a href="#L-5337"><span class="linenos">5337</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> -</span><span id="L-5338"><a href="#L-5338"><span class="linenos">5338</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> +</span><span id="L-5327"><a href="#L-5327"><span class="linenos">5327</span></a><span class="sd"> Args:</span> +</span><span id="L-5328"><a href="#L-5328"><span class="linenos">5328</span></a><span class="sd"> sql_path: a `[catalog].[schema].[table]` string.</span> +</span><span id="L-5329"><a href="#L-5329"><span class="linenos">5329</span></a><span class="sd"> dialect: the source dialect according to which the table name will be parsed.</span> +</span><span id="L-5330"><a href="#L-5330"><span class="linenos">5330</span></a><span class="sd"> kwargs: the kwargs to instantiate the resulting `Table` expression with.</span> +</span><span id="L-5331"><a href="#L-5331"><span class="linenos">5331</span></a> +</span><span id="L-5332"><a href="#L-5332"><span class="linenos">5332</span></a><span class="sd"> Returns:</span> +</span><span id="L-5333"><a href="#L-5333"><span class="linenos">5333</span></a><span class="sd"> A table expression.</span> +</span><span id="L-5334"><a href="#L-5334"><span class="linenos">5334</span></a><span class="sd"> """</span> +</span><span id="L-5335"><a href="#L-5335"><span class="linenos">5335</span></a> <span class="k">if</span> <span class="n">sql_path</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="n">Table</span><span class="p">):</span> +</span><span id="L-5336"><a href="#L-5336"><span class="linenos">5336</span></a> <span class="k">return</span> <span class="n">sql_path</span> +</span><span id="L-5337"><a href="#L-5337"><span class="linenos">5337</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="L-5338"><a href="#L-5338"><span class="linenos">5338</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid type provided for a table: </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">sql_path</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> </span><span id="L-5339"><a href="#L-5339"><span class="linenos">5339</span></a> -</span><span id="L-5340"><a href="#L-5340"><span class="linenos">5340</span></a> <span class="k">return</span> <span class="n">table</span> -</span><span id="L-5341"><a href="#L-5341"><span class="linenos">5341</span></a> -</span><span id="L-5342"><a href="#L-5342"><span class="linenos">5342</span></a> -</span><span id="L-5343"><a href="#L-5343"><span class="linenos">5343</span></a><span class="k">def</span> <span class="nf">to_column</span><span class="p">(</span><span class="n">sql_path</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Column</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="L-5344"><a href="#L-5344"><span class="linenos">5344</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-5345"><a href="#L-5345"><span class="linenos">5345</span></a><span class="sd"> Create a column from a `[table].[column]` sql path. Schema is optional.</span> +</span><span id="L-5340"><a href="#L-5340"><span class="linenos">5340</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> +</span><span id="L-5341"><a href="#L-5341"><span class="linenos">5341</span></a> <span class="k">if</span> <span class="n">table</span><span class="p">:</span> +</span><span id="L-5342"><a href="#L-5342"><span class="linenos">5342</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> +</span><span id="L-5343"><a href="#L-5343"><span class="linenos">5343</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> +</span><span id="L-5344"><a href="#L-5344"><span class="linenos">5344</span></a> +</span><span id="L-5345"><a href="#L-5345"><span class="linenos">5345</span></a> <span class="k">return</span> <span class="n">table</span> </span><span id="L-5346"><a href="#L-5346"><span class="linenos">5346</span></a> -</span><span id="L-5347"><a href="#L-5347"><span class="linenos">5347</span></a><span class="sd"> If a column is passed in then that column is returned.</span> -</span><span id="L-5348"><a href="#L-5348"><span class="linenos">5348</span></a> -</span><span id="L-5349"><a href="#L-5349"><span class="linenos">5349</span></a><span class="sd"> Args:</span> -</span><span id="L-5350"><a href="#L-5350"><span class="linenos">5350</span></a><span class="sd"> sql_path: `[table].[column]` string</span> -</span><span id="L-5351"><a href="#L-5351"><span class="linenos">5351</span></a><span class="sd"> Returns:</span> -</span><span id="L-5352"><a href="#L-5352"><span class="linenos">5352</span></a><span class="sd"> Table: A column expression</span> -</span><span id="L-5353"><a href="#L-5353"><span class="linenos">5353</span></a><span class="sd"> """</span> -</span><span id="L-5354"><a href="#L-5354"><span class="linenos">5354</span></a> <span class="k">if</span> <span class="n">sql_path</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="n">Column</span><span class="p">):</span> -</span><span id="L-5355"><a href="#L-5355"><span class="linenos">5355</span></a> <span class="k">return</span> <span class="n">sql_path</span> -</span><span id="L-5356"><a href="#L-5356"><span class="linenos">5356</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="L-5357"><a href="#L-5357"><span class="linenos">5357</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid type provided for column: </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">sql_path</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-5358"><a href="#L-5358"><span class="linenos">5358</span></a> <span class="k">return</span> <span class="n">column</span><span class="p">(</span><span class="o">*</span><span class="nb">reversed</span><span class="p">(</span><span class="n">sql_path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"."</span><span class="p">)),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="L-5359"><a href="#L-5359"><span class="linenos">5359</span></a> -</span><span id="L-5360"><a href="#L-5360"><span class="linenos">5360</span></a> -</span><span id="L-5361"><a href="#L-5361"><span class="linenos">5361</span></a><span class="k">def</span> <span class="nf">alias_</span><span class="p">(</span> -</span><span id="L-5362"><a href="#L-5362"><span class="linenos">5362</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="L-5363"><a href="#L-5363"><span class="linenos">5363</span></a> <span class="n">alias</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">,</span> -</span><span id="L-5364"><a href="#L-5364"><span class="linenos">5364</span></a> <span class="n">table</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-5365"><a href="#L-5365"><span class="linenos">5365</span></a> <span class="n">quoted</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-5366"><a href="#L-5366"><span class="linenos">5366</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-5367"><a href="#L-5367"><span class="linenos">5367</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-5368"><a href="#L-5368"><span class="linenos">5368</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-5369"><a href="#L-5369"><span class="linenos">5369</span></a><span class="p">):</span> -</span><span id="L-5370"><a href="#L-5370"><span class="linenos">5370</span></a><span class="w"> </span><span class="sd">"""Create an Alias expression.</span> -</span><span id="L-5371"><a href="#L-5371"><span class="linenos">5371</span></a> -</span><span id="L-5372"><a href="#L-5372"><span class="linenos">5372</span></a><span class="sd"> Example:</span> -</span><span id="L-5373"><a href="#L-5373"><span class="linenos">5373</span></a><span class="sd"> >>> alias_('foo', 'bar').sql()</span> -</span><span id="L-5374"><a href="#L-5374"><span class="linenos">5374</span></a><span class="sd"> 'foo AS bar'</span> -</span><span id="L-5375"><a href="#L-5375"><span class="linenos">5375</span></a> -</span><span id="L-5376"><a href="#L-5376"><span class="linenos">5376</span></a><span class="sd"> >>> alias_('(select 1, 2)', 'bar', table=['a', 'b']).sql()</span> -</span><span id="L-5377"><a href="#L-5377"><span class="linenos">5377</span></a><span class="sd"> '(SELECT 1, 2) AS bar(a, b)'</span> -</span><span id="L-5378"><a href="#L-5378"><span class="linenos">5378</span></a> -</span><span id="L-5379"><a href="#L-5379"><span class="linenos">5379</span></a><span class="sd"> Args:</span> -</span><span id="L-5380"><a href="#L-5380"><span class="linenos">5380</span></a><span class="sd"> expression: the SQL code strings to parse.</span> -</span><span id="L-5381"><a href="#L-5381"><span class="linenos">5381</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> -</span><span id="L-5382"><a href="#L-5382"><span class="linenos">5382</span></a><span class="sd"> alias: the alias name to use. If the name has</span> -</span><span id="L-5383"><a href="#L-5383"><span class="linenos">5383</span></a><span class="sd"> special characters it is quoted.</span> -</span><span id="L-5384"><a href="#L-5384"><span class="linenos">5384</span></a><span class="sd"> table: Whether or not to create a table alias, can also be a list of columns.</span> -</span><span id="L-5385"><a href="#L-5385"><span class="linenos">5385</span></a><span class="sd"> quoted: whether or not to quote the alias</span> -</span><span id="L-5386"><a href="#L-5386"><span class="linenos">5386</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="L-5387"><a href="#L-5387"><span class="linenos">5387</span></a><span class="sd"> copy: Whether or not to copy the expression.</span> -</span><span id="L-5388"><a href="#L-5388"><span class="linenos">5388</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> -</span><span id="L-5389"><a href="#L-5389"><span class="linenos">5389</span></a> -</span><span id="L-5390"><a href="#L-5390"><span class="linenos">5390</span></a><span class="sd"> Returns:</span> -</span><span id="L-5391"><a href="#L-5391"><span class="linenos">5391</span></a><span class="sd"> Alias: the aliased expression</span> -</span><span id="L-5392"><a href="#L-5392"><span class="linenos">5392</span></a><span class="sd"> """</span> -</span><span id="L-5393"><a href="#L-5393"><span class="linenos">5393</span></a> <span class="n">exp</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-5394"><a href="#L-5394"><span class="linenos">5394</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">)</span> -</span><span id="L-5395"><a href="#L-5395"><span class="linenos">5395</span></a> -</span><span id="L-5396"><a href="#L-5396"><span class="linenos">5396</span></a> <span class="k">if</span> <span class="n">table</span><span class="p">:</span> -</span><span id="L-5397"><a href="#L-5397"><span class="linenos">5397</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> -</span><span id="L-5398"><a href="#L-5398"><span class="linenos">5398</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="n">table_alias</span><span class="p">)</span> -</span><span id="L-5399"><a href="#L-5399"><span class="linenos">5399</span></a> -</span><span id="L-5400"><a href="#L-5400"><span class="linenos">5400</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="nb">bool</span><span class="p">):</span> -</span><span id="L-5401"><a href="#L-5401"><span class="linenos">5401</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">table</span><span class="p">:</span> -</span><span id="L-5402"><a href="#L-5402"><span class="linenos">5402</span></a> <span class="n">table_alias</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">to_identifier</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">))</span> -</span><span id="L-5403"><a href="#L-5403"><span class="linenos">5403</span></a> -</span><span id="L-5404"><a href="#L-5404"><span class="linenos">5404</span></a> <span class="k">return</span> <span class="n">exp</span> -</span><span id="L-5405"><a href="#L-5405"><span class="linenos">5405</span></a> -</span><span id="L-5406"><a href="#L-5406"><span class="linenos">5406</span></a> <span class="c1"># We don't set the "alias" arg for Window expressions, because that would add an IDENTIFIER node in</span> -</span><span id="L-5407"><a href="#L-5407"><span class="linenos">5407</span></a> <span class="c1"># the AST, representing a "named_window" [1] construct (eg. bigquery). What we want is an ALIAS node</span> -</span><span id="L-5408"><a href="#L-5408"><span class="linenos">5408</span></a> <span class="c1"># for the complete Window expression.</span> -</span><span id="L-5409"><a href="#L-5409"><span class="linenos">5409</span></a> <span class="c1">#</span> -</span><span id="L-5410"><a href="#L-5410"><span class="linenos">5410</span></a> <span class="c1"># [1]: https://cloud.google.com/bigquery/docs/reference/standard-sql/window-function-calls</span> -</span><span id="L-5411"><a href="#L-5411"><span class="linenos">5411</span></a> -</span><span id="L-5412"><a href="#L-5412"><span class="linenos">5412</span></a> <span class="k">if</span> <span class="s2">"alias"</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">arg_types</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">exp</span><span class="p">,</span> <span class="n">Window</span><span class="p">):</span> -</span><span id="L-5413"><a href="#L-5413"><span class="linenos">5413</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="n">alias</span><span class="p">)</span> -</span><span id="L-5414"><a href="#L-5414"><span class="linenos">5414</span></a> <span class="k">return</span> <span class="n">exp</span> -</span><span id="L-5415"><a href="#L-5415"><span class="linenos">5415</span></a> <span class="k">return</span> <span class="n">Alias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> +</span><span id="L-5347"><a href="#L-5347"><span class="linenos">5347</span></a> +</span><span id="L-5348"><a href="#L-5348"><span class="linenos">5348</span></a><span class="k">def</span> <span class="nf">to_column</span><span class="p">(</span><span class="n">sql_path</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Column</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="L-5349"><a href="#L-5349"><span class="linenos">5349</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-5350"><a href="#L-5350"><span class="linenos">5350</span></a><span class="sd"> Create a column from a `[table].[column]` sql path. Schema is optional.</span> +</span><span id="L-5351"><a href="#L-5351"><span class="linenos">5351</span></a> +</span><span id="L-5352"><a href="#L-5352"><span class="linenos">5352</span></a><span class="sd"> If a column is passed in then that column is returned.</span> +</span><span id="L-5353"><a href="#L-5353"><span class="linenos">5353</span></a> +</span><span id="L-5354"><a href="#L-5354"><span class="linenos">5354</span></a><span class="sd"> Args:</span> +</span><span id="L-5355"><a href="#L-5355"><span class="linenos">5355</span></a><span class="sd"> sql_path: `[table].[column]` string</span> +</span><span id="L-5356"><a href="#L-5356"><span class="linenos">5356</span></a><span class="sd"> Returns:</span> +</span><span id="L-5357"><a href="#L-5357"><span class="linenos">5357</span></a><span class="sd"> Table: A column expression</span> +</span><span id="L-5358"><a href="#L-5358"><span class="linenos">5358</span></a><span class="sd"> """</span> +</span><span id="L-5359"><a href="#L-5359"><span class="linenos">5359</span></a> <span class="k">if</span> <span class="n">sql_path</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="n">Column</span><span class="p">):</span> +</span><span id="L-5360"><a href="#L-5360"><span class="linenos">5360</span></a> <span class="k">return</span> <span class="n">sql_path</span> +</span><span id="L-5361"><a href="#L-5361"><span class="linenos">5361</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="L-5362"><a href="#L-5362"><span class="linenos">5362</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid type provided for column: </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">sql_path</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-5363"><a href="#L-5363"><span class="linenos">5363</span></a> <span class="k">return</span> <span class="n">column</span><span class="p">(</span><span class="o">*</span><span class="nb">reversed</span><span class="p">(</span><span class="n">sql_path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"."</span><span class="p">)),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="L-5364"><a href="#L-5364"><span class="linenos">5364</span></a> +</span><span id="L-5365"><a href="#L-5365"><span class="linenos">5365</span></a> +</span><span id="L-5366"><a href="#L-5366"><span class="linenos">5366</span></a><span class="k">def</span> <span class="nf">alias_</span><span class="p">(</span> +</span><span id="L-5367"><a href="#L-5367"><span class="linenos">5367</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="L-5368"><a href="#L-5368"><span class="linenos">5368</span></a> <span class="n">alias</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">,</span> +</span><span id="L-5369"><a href="#L-5369"><span class="linenos">5369</span></a> <span class="n">table</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-5370"><a href="#L-5370"><span class="linenos">5370</span></a> <span class="n">quoted</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-5371"><a href="#L-5371"><span class="linenos">5371</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-5372"><a href="#L-5372"><span class="linenos">5372</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-5373"><a href="#L-5373"><span class="linenos">5373</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-5374"><a href="#L-5374"><span class="linenos">5374</span></a><span class="p">):</span> +</span><span id="L-5375"><a href="#L-5375"><span class="linenos">5375</span></a><span class="w"> </span><span class="sd">"""Create an Alias expression.</span> +</span><span id="L-5376"><a href="#L-5376"><span class="linenos">5376</span></a> +</span><span id="L-5377"><a href="#L-5377"><span class="linenos">5377</span></a><span class="sd"> Example:</span> +</span><span id="L-5378"><a href="#L-5378"><span class="linenos">5378</span></a><span class="sd"> >>> alias_('foo', 'bar').sql()</span> +</span><span id="L-5379"><a href="#L-5379"><span class="linenos">5379</span></a><span class="sd"> 'foo AS bar'</span> +</span><span id="L-5380"><a href="#L-5380"><span class="linenos">5380</span></a> +</span><span id="L-5381"><a href="#L-5381"><span class="linenos">5381</span></a><span class="sd"> >>> alias_('(select 1, 2)', 'bar', table=['a', 'b']).sql()</span> +</span><span id="L-5382"><a href="#L-5382"><span class="linenos">5382</span></a><span class="sd"> '(SELECT 1, 2) AS bar(a, b)'</span> +</span><span id="L-5383"><a href="#L-5383"><span class="linenos">5383</span></a> +</span><span id="L-5384"><a href="#L-5384"><span class="linenos">5384</span></a><span class="sd"> Args:</span> +</span><span id="L-5385"><a href="#L-5385"><span class="linenos">5385</span></a><span class="sd"> expression: the SQL code strings to parse.</span> +</span><span id="L-5386"><a href="#L-5386"><span class="linenos">5386</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> +</span><span id="L-5387"><a href="#L-5387"><span class="linenos">5387</span></a><span class="sd"> alias: the alias name to use. If the name has</span> +</span><span id="L-5388"><a href="#L-5388"><span class="linenos">5388</span></a><span class="sd"> special characters it is quoted.</span> +</span><span id="L-5389"><a href="#L-5389"><span class="linenos">5389</span></a><span class="sd"> table: Whether or not to create a table alias, can also be a list of columns.</span> +</span><span id="L-5390"><a href="#L-5390"><span class="linenos">5390</span></a><span class="sd"> quoted: whether or not to quote the alias</span> +</span><span id="L-5391"><a href="#L-5391"><span class="linenos">5391</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="L-5392"><a href="#L-5392"><span class="linenos">5392</span></a><span class="sd"> copy: Whether or not to copy the expression.</span> +</span><span id="L-5393"><a href="#L-5393"><span class="linenos">5393</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> +</span><span id="L-5394"><a href="#L-5394"><span class="linenos">5394</span></a> +</span><span id="L-5395"><a href="#L-5395"><span class="linenos">5395</span></a><span class="sd"> Returns:</span> +</span><span id="L-5396"><a href="#L-5396"><span class="linenos">5396</span></a><span class="sd"> Alias: the aliased expression</span> +</span><span id="L-5397"><a href="#L-5397"><span class="linenos">5397</span></a><span class="sd"> """</span> +</span><span id="L-5398"><a href="#L-5398"><span class="linenos">5398</span></a> <span class="n">exp</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-5399"><a href="#L-5399"><span class="linenos">5399</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">)</span> +</span><span id="L-5400"><a href="#L-5400"><span class="linenos">5400</span></a> +</span><span id="L-5401"><a href="#L-5401"><span class="linenos">5401</span></a> <span class="k">if</span> <span class="n">table</span><span class="p">:</span> +</span><span id="L-5402"><a href="#L-5402"><span class="linenos">5402</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> +</span><span id="L-5403"><a href="#L-5403"><span class="linenos">5403</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="n">table_alias</span><span class="p">)</span> +</span><span id="L-5404"><a href="#L-5404"><span class="linenos">5404</span></a> +</span><span id="L-5405"><a href="#L-5405"><span class="linenos">5405</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="nb">bool</span><span class="p">):</span> +</span><span id="L-5406"><a href="#L-5406"><span class="linenos">5406</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">table</span><span class="p">:</span> +</span><span id="L-5407"><a href="#L-5407"><span class="linenos">5407</span></a> <span class="n">table_alias</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">to_identifier</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">))</span> +</span><span id="L-5408"><a href="#L-5408"><span class="linenos">5408</span></a> +</span><span id="L-5409"><a href="#L-5409"><span class="linenos">5409</span></a> <span class="k">return</span> <span class="n">exp</span> +</span><span id="L-5410"><a href="#L-5410"><span class="linenos">5410</span></a> +</span><span id="L-5411"><a href="#L-5411"><span class="linenos">5411</span></a> <span class="c1"># We don't set the "alias" arg for Window expressions, because that would add an IDENTIFIER node in</span> +</span><span id="L-5412"><a href="#L-5412"><span class="linenos">5412</span></a> <span class="c1"># the AST, representing a "named_window" [1] construct (eg. bigquery). What we want is an ALIAS node</span> +</span><span id="L-5413"><a href="#L-5413"><span class="linenos">5413</span></a> <span class="c1"># for the complete Window expression.</span> +</span><span id="L-5414"><a href="#L-5414"><span class="linenos">5414</span></a> <span class="c1">#</span> +</span><span id="L-5415"><a href="#L-5415"><span class="linenos">5415</span></a> <span class="c1"># [1]: https://cloud.google.com/bigquery/docs/reference/standard-sql/window-function-calls</span> </span><span id="L-5416"><a href="#L-5416"><span class="linenos">5416</span></a> -</span><span id="L-5417"><a href="#L-5417"><span class="linenos">5417</span></a> -</span><span id="L-5418"><a href="#L-5418"><span class="linenos">5418</span></a><span class="k">def</span> <span class="nf">subquery</span><span class="p">(</span> -</span><span id="L-5419"><a href="#L-5419"><span class="linenos">5419</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="L-5420"><a href="#L-5420"><span class="linenos">5420</span></a> <span class="n">alias</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">Identifier</span> <span class="o">|</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-5421"><a href="#L-5421"><span class="linenos">5421</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-5422"><a href="#L-5422"><span class="linenos">5422</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="L-5423"><a href="#L-5423"><span class="linenos">5423</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="L-5424"><a href="#L-5424"><span class="linenos">5424</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-5425"><a href="#L-5425"><span class="linenos">5425</span></a><span class="sd"> Build a subquery expression.</span> -</span><span id="L-5426"><a href="#L-5426"><span class="linenos">5426</span></a> -</span><span id="L-5427"><a href="#L-5427"><span class="linenos">5427</span></a><span class="sd"> Example:</span> -</span><span id="L-5428"><a href="#L-5428"><span class="linenos">5428</span></a><span class="sd"> >>> subquery('select x from tbl', 'bar').select('x').sql()</span> -</span><span id="L-5429"><a href="#L-5429"><span class="linenos">5429</span></a><span class="sd"> 'SELECT x FROM (SELECT x FROM tbl) AS bar'</span> -</span><span id="L-5430"><a href="#L-5430"><span class="linenos">5430</span></a> -</span><span id="L-5431"><a href="#L-5431"><span class="linenos">5431</span></a><span class="sd"> Args:</span> -</span><span id="L-5432"><a href="#L-5432"><span class="linenos">5432</span></a><span class="sd"> expression: the SQL code strings to parse.</span> -</span><span id="L-5433"><a href="#L-5433"><span class="linenos">5433</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> -</span><span id="L-5434"><a href="#L-5434"><span class="linenos">5434</span></a><span class="sd"> alias: the alias name to use.</span> -</span><span id="L-5435"><a href="#L-5435"><span class="linenos">5435</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="L-5436"><a href="#L-5436"><span class="linenos">5436</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> -</span><span id="L-5437"><a href="#L-5437"><span class="linenos">5437</span></a> -</span><span id="L-5438"><a href="#L-5438"><span class="linenos">5438</span></a><span class="sd"> Returns:</span> -</span><span id="L-5439"><a href="#L-5439"><span class="linenos">5439</span></a><span class="sd"> A new Select instance with the subquery expression included.</span> -</span><span id="L-5440"><a href="#L-5440"><span class="linenos">5440</span></a><span class="sd"> """</span> -</span><span id="L-5441"><a href="#L-5441"><span class="linenos">5441</span></a> -</span><span id="L-5442"><a href="#L-5442"><span class="linenos">5442</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">alias</span><span class="p">)</span> -</span><span id="L-5443"><a href="#L-5443"><span class="linenos">5443</span></a> <span class="k">return</span> <span class="n">Select</span><span class="p">()</span><span class="o">.</span><span class="n">from_</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-5444"><a href="#L-5444"><span class="linenos">5444</span></a> -</span><span id="L-5445"><a href="#L-5445"><span class="linenos">5445</span></a> -</span><span id="L-5446"><a href="#L-5446"><span class="linenos">5446</span></a><span class="k">def</span> <span class="nf">column</span><span class="p">(</span> -</span><span id="L-5447"><a href="#L-5447"><span class="linenos">5447</span></a> <span class="n">col</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">,</span> -</span><span id="L-5448"><a href="#L-5448"><span class="linenos">5448</span></a> <span class="n">table</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-5449"><a href="#L-5449"><span class="linenos">5449</span></a> <span class="n">db</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-5450"><a href="#L-5450"><span class="linenos">5450</span></a> <span class="n">catalog</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-5451"><a href="#L-5451"><span class="linenos">5451</span></a> <span class="n">quoted</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-5452"><a href="#L-5452"><span class="linenos">5452</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="L-5453"><a href="#L-5453"><span class="linenos">5453</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-5454"><a href="#L-5454"><span class="linenos">5454</span></a><span class="sd"> Build a Column.</span> -</span><span id="L-5455"><a href="#L-5455"><span class="linenos">5455</span></a> -</span><span id="L-5456"><a href="#L-5456"><span class="linenos">5456</span></a><span class="sd"> Args:</span> -</span><span id="L-5457"><a href="#L-5457"><span class="linenos">5457</span></a><span class="sd"> col: Column name.</span> -</span><span id="L-5458"><a href="#L-5458"><span class="linenos">5458</span></a><span class="sd"> table: Table name.</span> -</span><span id="L-5459"><a href="#L-5459"><span class="linenos">5459</span></a><span class="sd"> db: Database name.</span> -</span><span id="L-5460"><a href="#L-5460"><span class="linenos">5460</span></a><span class="sd"> catalog: Catalog name.</span> -</span><span id="L-5461"><a href="#L-5461"><span class="linenos">5461</span></a><span class="sd"> quoted: Whether to force quotes on the column's identifiers.</span> -</span><span id="L-5462"><a href="#L-5462"><span class="linenos">5462</span></a> -</span><span id="L-5463"><a href="#L-5463"><span class="linenos">5463</span></a><span class="sd"> Returns:</span> -</span><span id="L-5464"><a href="#L-5464"><span class="linenos">5464</span></a><span class="sd"> The new Column instance.</span> -</span><span id="L-5465"><a href="#L-5465"><span class="linenos">5465</span></a><span class="sd"> """</span> -</span><span id="L-5466"><a href="#L-5466"><span class="linenos">5466</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span> -</span><span id="L-5467"><a href="#L-5467"><span class="linenos">5467</span></a> <span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">col</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> -</span><span id="L-5468"><a href="#L-5468"><span class="linenos">5468</span></a> <span class="n">table</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> -</span><span id="L-5469"><a href="#L-5469"><span class="linenos">5469</span></a> <span class="n">db</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">db</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> -</span><span id="L-5470"><a href="#L-5470"><span class="linenos">5470</span></a> <span class="n">catalog</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">catalog</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> -</span><span id="L-5471"><a href="#L-5471"><span class="linenos">5471</span></a> <span class="p">)</span> -</span><span id="L-5472"><a href="#L-5472"><span class="linenos">5472</span></a> -</span><span id="L-5473"><a href="#L-5473"><span class="linenos">5473</span></a> -</span><span id="L-5474"><a href="#L-5474"><span class="linenos">5474</span></a><span class="k">def</span> <span class="nf">cast</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">to</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Cast</span><span class="p">:</span> -</span><span id="L-5475"><a href="#L-5475"><span class="linenos">5475</span></a><span class="w"> </span><span class="sd">"""Cast an expression to a data type.</span> -</span><span id="L-5476"><a href="#L-5476"><span class="linenos">5476</span></a> -</span><span id="L-5477"><a href="#L-5477"><span class="linenos">5477</span></a><span class="sd"> Example:</span> -</span><span id="L-5478"><a href="#L-5478"><span class="linenos">5478</span></a><span class="sd"> >>> cast('x + 1', 'int').sql()</span> -</span><span id="L-5479"><a href="#L-5479"><span class="linenos">5479</span></a><span class="sd"> 'CAST(x + 1 AS INT)'</span> -</span><span id="L-5480"><a href="#L-5480"><span class="linenos">5480</span></a> -</span><span id="L-5481"><a href="#L-5481"><span class="linenos">5481</span></a><span class="sd"> Args:</span> -</span><span id="L-5482"><a href="#L-5482"><span class="linenos">5482</span></a><span class="sd"> expression: The expression to cast.</span> -</span><span id="L-5483"><a href="#L-5483"><span class="linenos">5483</span></a><span class="sd"> to: The datatype to cast to.</span> -</span><span id="L-5484"><a href="#L-5484"><span class="linenos">5484</span></a> -</span><span id="L-5485"><a href="#L-5485"><span class="linenos">5485</span></a><span class="sd"> Returns:</span> -</span><span id="L-5486"><a href="#L-5486"><span class="linenos">5486</span></a><span class="sd"> The new Cast instance.</span> -</span><span id="L-5487"><a href="#L-5487"><span class="linenos">5487</span></a><span class="sd"> """</span> -</span><span id="L-5488"><a href="#L-5488"><span class="linenos">5488</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="L-5489"><a href="#L-5489"><span class="linenos">5489</span></a> <span class="k">return</span> <span class="n">Cast</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">to</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="n">to</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">))</span> -</span><span id="L-5490"><a href="#L-5490"><span class="linenos">5490</span></a> -</span><span id="L-5491"><a href="#L-5491"><span class="linenos">5491</span></a> -</span><span id="L-5492"><a href="#L-5492"><span class="linenos">5492</span></a><span class="k">def</span> <span class="nf">table_</span><span class="p">(</span> -</span><span id="L-5493"><a href="#L-5493"><span class="linenos">5493</span></a> <span class="n">table</span><span class="p">:</span> <span class="n">Identifier</span> <span class="o">|</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="L-5494"><a href="#L-5494"><span class="linenos">5494</span></a> <span class="n">db</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">Identifier</span> <span class="o">|</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-5495"><a href="#L-5495"><span class="linenos">5495</span></a> <span class="n">catalog</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">Identifier</span> <span class="o">|</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-5496"><a href="#L-5496"><span class="linenos">5496</span></a> <span class="n">quoted</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-5497"><a href="#L-5497"><span class="linenos">5497</span></a> <span class="n">alias</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">Identifier</span> <span class="o">|</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-5498"><a href="#L-5498"><span class="linenos">5498</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Table</span><span class="p">:</span> -</span><span id="L-5499"><a href="#L-5499"><span class="linenos">5499</span></a><span class="w"> </span><span class="sd">"""Build a Table.</span> -</span><span id="L-5500"><a href="#L-5500"><span class="linenos">5500</span></a> -</span><span id="L-5501"><a href="#L-5501"><span class="linenos">5501</span></a><span class="sd"> Args:</span> -</span><span id="L-5502"><a href="#L-5502"><span class="linenos">5502</span></a><span class="sd"> table: Table name.</span> -</span><span id="L-5503"><a href="#L-5503"><span class="linenos">5503</span></a><span class="sd"> db: Database name.</span> -</span><span id="L-5504"><a href="#L-5504"><span class="linenos">5504</span></a><span class="sd"> catalog: Catalog name.</span> -</span><span id="L-5505"><a href="#L-5505"><span class="linenos">5505</span></a><span class="sd"> quote: Whether to force quotes on the table's identifiers.</span> -</span><span id="L-5506"><a href="#L-5506"><span class="linenos">5506</span></a><span class="sd"> alias: Table's alias.</span> -</span><span id="L-5507"><a href="#L-5507"><span class="linenos">5507</span></a> -</span><span id="L-5508"><a href="#L-5508"><span class="linenos">5508</span></a><span class="sd"> Returns:</span> -</span><span id="L-5509"><a href="#L-5509"><span class="linenos">5509</span></a><span class="sd"> The new Table instance.</span> -</span><span id="L-5510"><a href="#L-5510"><span class="linenos">5510</span></a><span class="sd"> """</span> -</span><span id="L-5511"><a href="#L-5511"><span class="linenos">5511</span></a> <span class="k">return</span> <span class="n">Table</span><span class="p">(</span> -</span><span id="L-5512"><a href="#L-5512"><span class="linenos">5512</span></a> <span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> -</span><span id="L-5513"><a href="#L-5513"><span class="linenos">5513</span></a> <span class="n">db</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">db</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> -</span><span id="L-5514"><a href="#L-5514"><span class="linenos">5514</span></a> <span class="n">catalog</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">catalog</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> -</span><span id="L-5515"><a href="#L-5515"><span class="linenos">5515</span></a> <span class="n">alias</span><span class="o">=</span><span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">))</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-5516"><a href="#L-5516"><span class="linenos">5516</span></a> <span class="p">)</span> -</span><span id="L-5517"><a href="#L-5517"><span class="linenos">5517</span></a> -</span><span id="L-5518"><a href="#L-5518"><span class="linenos">5518</span></a> -</span><span id="L-5519"><a href="#L-5519"><span class="linenos">5519</span></a><span class="k">def</span> <span class="nf">values</span><span class="p">(</span> -</span><span id="L-5520"><a href="#L-5520"><span class="linenos">5520</span></a> <span class="n">values</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="o">...</span><span class="p">]],</span> -</span><span id="L-5521"><a href="#L-5521"><span class="linenos">5521</span></a> <span class="n">alias</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-5522"><a href="#L-5522"><span class="linenos">5522</span></a> <span class="n">columns</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">DataType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-5523"><a href="#L-5523"><span class="linenos">5523</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Values</span><span class="p">:</span> -</span><span id="L-5524"><a href="#L-5524"><span class="linenos">5524</span></a><span class="w"> </span><span class="sd">"""Build VALUES statement.</span> -</span><span id="L-5525"><a href="#L-5525"><span class="linenos">5525</span></a> -</span><span id="L-5526"><a href="#L-5526"><span class="linenos">5526</span></a><span class="sd"> Example:</span> -</span><span id="L-5527"><a href="#L-5527"><span class="linenos">5527</span></a><span class="sd"> >>> values([(1, '2')]).sql()</span> -</span><span id="L-5528"><a href="#L-5528"><span class="linenos">5528</span></a><span class="sd"> "VALUES (1, '2')"</span> -</span><span id="L-5529"><a href="#L-5529"><span class="linenos">5529</span></a> -</span><span id="L-5530"><a href="#L-5530"><span class="linenos">5530</span></a><span class="sd"> Args:</span> -</span><span id="L-5531"><a href="#L-5531"><span class="linenos">5531</span></a><span class="sd"> values: values statements that will be converted to SQL</span> -</span><span id="L-5532"><a href="#L-5532"><span class="linenos">5532</span></a><span class="sd"> alias: optional alias</span> -</span><span id="L-5533"><a href="#L-5533"><span class="linenos">5533</span></a><span class="sd"> columns: Optional list of ordered column names or ordered dictionary of column names to types.</span> -</span><span id="L-5534"><a href="#L-5534"><span class="linenos">5534</span></a><span class="sd"> If either are provided then an alias is also required.</span> -</span><span id="L-5535"><a href="#L-5535"><span class="linenos">5535</span></a> -</span><span id="L-5536"><a href="#L-5536"><span class="linenos">5536</span></a><span class="sd"> Returns:</span> -</span><span id="L-5537"><a href="#L-5537"><span class="linenos">5537</span></a><span class="sd"> Values: the Values expression object</span> -</span><span id="L-5538"><a href="#L-5538"><span class="linenos">5538</span></a><span class="sd"> """</span> -</span><span id="L-5539"><a href="#L-5539"><span class="linenos">5539</span></a> <span class="k">if</span> <span class="n">columns</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">alias</span><span class="p">:</span> -</span><span id="L-5540"><a href="#L-5540"><span class="linenos">5540</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Alias is required when providing columns"</span><span class="p">)</span> -</span><span id="L-5541"><a href="#L-5541"><span class="linenos">5541</span></a> -</span><span id="L-5542"><a href="#L-5542"><span class="linenos">5542</span></a> <span class="k">return</span> <span class="n">Values</span><span class="p">(</span> -</span><span id="L-5543"><a href="#L-5543"><span class="linenos">5543</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">tup</span><span class="p">)</span> <span class="k">for</span> <span class="n">tup</span> <span class="ow">in</span> <span class="n">values</span><span class="p">],</span> -</span><span id="L-5544"><a href="#L-5544"><span class="linenos">5544</span></a> <span class="n">alias</span><span class="o">=</span><span class="p">(</span> -</span><span id="L-5545"><a href="#L-5545"><span class="linenos">5545</span></a> <span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">),</span> <span class="n">columns</span><span class="o">=</span><span class="p">[</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">columns</span><span class="p">])</span> -</span><span id="L-5546"><a href="#L-5546"><span class="linenos">5546</span></a> <span class="k">if</span> <span class="n">columns</span> -</span><span id="L-5547"><a href="#L-5547"><span class="linenos">5547</span></a> <span class="k">else</span> <span class="p">(</span><span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">))</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="L-5548"><a href="#L-5548"><span class="linenos">5548</span></a> <span class="p">),</span> -</span><span id="L-5549"><a href="#L-5549"><span class="linenos">5549</span></a> <span class="p">)</span> -</span><span id="L-5550"><a href="#L-5550"><span class="linenos">5550</span></a> -</span><span id="L-5551"><a href="#L-5551"><span class="linenos">5551</span></a> -</span><span id="L-5552"><a href="#L-5552"><span class="linenos">5552</span></a><span class="k">def</span> <span class="nf">var</span><span class="p">(</span><span class="n">name</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">ExpOrStr</span><span class="p">])</span> <span class="o">-></span> <span class="n">Var</span><span class="p">:</span> -</span><span id="L-5553"><a href="#L-5553"><span class="linenos">5553</span></a><span class="w"> </span><span class="sd">"""Build a SQL variable.</span> -</span><span id="L-5554"><a href="#L-5554"><span class="linenos">5554</span></a> -</span><span id="L-5555"><a href="#L-5555"><span class="linenos">5555</span></a><span class="sd"> Example:</span> -</span><span id="L-5556"><a href="#L-5556"><span class="linenos">5556</span></a><span class="sd"> >>> repr(var('x'))</span> -</span><span id="L-5557"><a href="#L-5557"><span class="linenos">5557</span></a><span class="sd"> '(VAR this: x)'</span> -</span><span id="L-5558"><a href="#L-5558"><span class="linenos">5558</span></a> -</span><span id="L-5559"><a href="#L-5559"><span class="linenos">5559</span></a><span class="sd"> >>> repr(var(column('x', table='y')))</span> -</span><span id="L-5560"><a href="#L-5560"><span class="linenos">5560</span></a><span class="sd"> '(VAR this: x)'</span> -</span><span id="L-5561"><a href="#L-5561"><span class="linenos">5561</span></a> -</span><span id="L-5562"><a href="#L-5562"><span class="linenos">5562</span></a><span class="sd"> Args:</span> -</span><span id="L-5563"><a href="#L-5563"><span class="linenos">5563</span></a><span class="sd"> name: The name of the var or an expression who's name will become the var.</span> -</span><span id="L-5564"><a href="#L-5564"><span class="linenos">5564</span></a> -</span><span id="L-5565"><a href="#L-5565"><span class="linenos">5565</span></a><span class="sd"> Returns:</span> -</span><span id="L-5566"><a href="#L-5566"><span class="linenos">5566</span></a><span class="sd"> The new variable node.</span> -</span><span id="L-5567"><a href="#L-5567"><span class="linenos">5567</span></a><span class="sd"> """</span> -</span><span id="L-5568"><a href="#L-5568"><span class="linenos">5568</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">name</span><span class="p">:</span> -</span><span id="L-5569"><a href="#L-5569"><span class="linenos">5569</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Cannot convert empty name into var."</span><span class="p">)</span> -</span><span id="L-5570"><a href="#L-5570"><span class="linenos">5570</span></a> -</span><span id="L-5571"><a href="#L-5571"><span class="linenos">5571</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> -</span><span id="L-5572"><a href="#L-5572"><span class="linenos">5572</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">name</span><span class="o">.</span><span class="n">name</span> -</span><span id="L-5573"><a href="#L-5573"><span class="linenos">5573</span></a> <span class="k">return</span> <span class="n">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">name</span><span class="p">)</span> -</span><span id="L-5574"><a href="#L-5574"><span class="linenos">5574</span></a> +</span><span id="L-5417"><a href="#L-5417"><span class="linenos">5417</span></a> <span class="k">if</span> <span class="s2">"alias"</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">arg_types</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">exp</span><span class="p">,</span> <span class="n">Window</span><span class="p">):</span> +</span><span id="L-5418"><a href="#L-5418"><span class="linenos">5418</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="n">alias</span><span class="p">)</span> +</span><span id="L-5419"><a href="#L-5419"><span class="linenos">5419</span></a> <span class="k">return</span> <span class="n">exp</span> +</span><span id="L-5420"><a href="#L-5420"><span class="linenos">5420</span></a> <span class="k">return</span> <span class="n">Alias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> +</span><span id="L-5421"><a href="#L-5421"><span class="linenos">5421</span></a> +</span><span id="L-5422"><a href="#L-5422"><span class="linenos">5422</span></a> +</span><span id="L-5423"><a href="#L-5423"><span class="linenos">5423</span></a><span class="k">def</span> <span class="nf">subquery</span><span class="p">(</span> +</span><span id="L-5424"><a href="#L-5424"><span class="linenos">5424</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="L-5425"><a href="#L-5425"><span class="linenos">5425</span></a> <span class="n">alias</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">Identifier</span> <span class="o">|</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-5426"><a href="#L-5426"><span class="linenos">5426</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-5427"><a href="#L-5427"><span class="linenos">5427</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="L-5428"><a href="#L-5428"><span class="linenos">5428</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="L-5429"><a href="#L-5429"><span class="linenos">5429</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-5430"><a href="#L-5430"><span class="linenos">5430</span></a><span class="sd"> Build a subquery expression.</span> +</span><span id="L-5431"><a href="#L-5431"><span class="linenos">5431</span></a> +</span><span id="L-5432"><a href="#L-5432"><span class="linenos">5432</span></a><span class="sd"> Example:</span> +</span><span id="L-5433"><a href="#L-5433"><span class="linenos">5433</span></a><span class="sd"> >>> subquery('select x from tbl', 'bar').select('x').sql()</span> +</span><span id="L-5434"><a href="#L-5434"><span class="linenos">5434</span></a><span class="sd"> 'SELECT x FROM (SELECT x FROM tbl) AS bar'</span> +</span><span id="L-5435"><a href="#L-5435"><span class="linenos">5435</span></a> +</span><span id="L-5436"><a href="#L-5436"><span class="linenos">5436</span></a><span class="sd"> Args:</span> +</span><span id="L-5437"><a href="#L-5437"><span class="linenos">5437</span></a><span class="sd"> expression: the SQL code strings to parse.</span> +</span><span id="L-5438"><a href="#L-5438"><span class="linenos">5438</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> +</span><span id="L-5439"><a href="#L-5439"><span class="linenos">5439</span></a><span class="sd"> alias: the alias name to use.</span> +</span><span id="L-5440"><a href="#L-5440"><span class="linenos">5440</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="L-5441"><a href="#L-5441"><span class="linenos">5441</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> +</span><span id="L-5442"><a href="#L-5442"><span class="linenos">5442</span></a> +</span><span id="L-5443"><a href="#L-5443"><span class="linenos">5443</span></a><span class="sd"> Returns:</span> +</span><span id="L-5444"><a href="#L-5444"><span class="linenos">5444</span></a><span class="sd"> A new Select instance with the subquery expression included.</span> +</span><span id="L-5445"><a href="#L-5445"><span class="linenos">5445</span></a><span class="sd"> """</span> +</span><span id="L-5446"><a href="#L-5446"><span class="linenos">5446</span></a> +</span><span id="L-5447"><a href="#L-5447"><span class="linenos">5447</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">alias</span><span class="p">)</span> +</span><span id="L-5448"><a href="#L-5448"><span class="linenos">5448</span></a> <span class="k">return</span> <span class="n">Select</span><span class="p">()</span><span class="o">.</span><span class="n">from_</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-5449"><a href="#L-5449"><span class="linenos">5449</span></a> +</span><span id="L-5450"><a href="#L-5450"><span class="linenos">5450</span></a> +</span><span id="L-5451"><a href="#L-5451"><span class="linenos">5451</span></a><span class="k">def</span> <span class="nf">column</span><span class="p">(</span> +</span><span id="L-5452"><a href="#L-5452"><span class="linenos">5452</span></a> <span class="n">col</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">,</span> +</span><span id="L-5453"><a href="#L-5453"><span class="linenos">5453</span></a> <span class="n">table</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-5454"><a href="#L-5454"><span class="linenos">5454</span></a> <span class="n">db</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-5455"><a href="#L-5455"><span class="linenos">5455</span></a> <span class="n">catalog</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-5456"><a href="#L-5456"><span class="linenos">5456</span></a> <span class="n">quoted</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-5457"><a href="#L-5457"><span class="linenos">5457</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="L-5458"><a href="#L-5458"><span class="linenos">5458</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-5459"><a href="#L-5459"><span class="linenos">5459</span></a><span class="sd"> Build a Column.</span> +</span><span id="L-5460"><a href="#L-5460"><span class="linenos">5460</span></a> +</span><span id="L-5461"><a href="#L-5461"><span class="linenos">5461</span></a><span class="sd"> Args:</span> +</span><span id="L-5462"><a href="#L-5462"><span class="linenos">5462</span></a><span class="sd"> col: Column name.</span> +</span><span id="L-5463"><a href="#L-5463"><span class="linenos">5463</span></a><span class="sd"> table: Table name.</span> +</span><span id="L-5464"><a href="#L-5464"><span class="linenos">5464</span></a><span class="sd"> db: Database name.</span> +</span><span id="L-5465"><a href="#L-5465"><span class="linenos">5465</span></a><span class="sd"> catalog: Catalog name.</span> +</span><span id="L-5466"><a href="#L-5466"><span class="linenos">5466</span></a><span class="sd"> quoted: Whether to force quotes on the column's identifiers.</span> +</span><span id="L-5467"><a href="#L-5467"><span class="linenos">5467</span></a> +</span><span id="L-5468"><a href="#L-5468"><span class="linenos">5468</span></a><span class="sd"> Returns:</span> +</span><span id="L-5469"><a href="#L-5469"><span class="linenos">5469</span></a><span class="sd"> The new Column instance.</span> +</span><span id="L-5470"><a href="#L-5470"><span class="linenos">5470</span></a><span class="sd"> """</span> +</span><span id="L-5471"><a href="#L-5471"><span class="linenos">5471</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span> +</span><span id="L-5472"><a href="#L-5472"><span class="linenos">5472</span></a> <span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">col</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> +</span><span id="L-5473"><a href="#L-5473"><span class="linenos">5473</span></a> <span class="n">table</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> +</span><span id="L-5474"><a href="#L-5474"><span class="linenos">5474</span></a> <span class="n">db</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">db</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> +</span><span id="L-5475"><a href="#L-5475"><span class="linenos">5475</span></a> <span class="n">catalog</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">catalog</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> +</span><span id="L-5476"><a href="#L-5476"><span class="linenos">5476</span></a> <span class="p">)</span> +</span><span id="L-5477"><a href="#L-5477"><span class="linenos">5477</span></a> +</span><span id="L-5478"><a href="#L-5478"><span class="linenos">5478</span></a> +</span><span id="L-5479"><a href="#L-5479"><span class="linenos">5479</span></a><span class="k">def</span> <span class="nf">cast</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">to</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Cast</span><span class="p">:</span> +</span><span id="L-5480"><a href="#L-5480"><span class="linenos">5480</span></a><span class="w"> </span><span class="sd">"""Cast an expression to a data type.</span> +</span><span id="L-5481"><a href="#L-5481"><span class="linenos">5481</span></a> +</span><span id="L-5482"><a href="#L-5482"><span class="linenos">5482</span></a><span class="sd"> Example:</span> +</span><span id="L-5483"><a href="#L-5483"><span class="linenos">5483</span></a><span class="sd"> >>> cast('x + 1', 'int').sql()</span> +</span><span id="L-5484"><a href="#L-5484"><span class="linenos">5484</span></a><span class="sd"> 'CAST(x + 1 AS INT)'</span> +</span><span id="L-5485"><a href="#L-5485"><span class="linenos">5485</span></a> +</span><span id="L-5486"><a href="#L-5486"><span class="linenos">5486</span></a><span class="sd"> Args:</span> +</span><span id="L-5487"><a href="#L-5487"><span class="linenos">5487</span></a><span class="sd"> expression: The expression to cast.</span> +</span><span id="L-5488"><a href="#L-5488"><span class="linenos">5488</span></a><span class="sd"> to: The datatype to cast to.</span> +</span><span id="L-5489"><a href="#L-5489"><span class="linenos">5489</span></a> +</span><span id="L-5490"><a href="#L-5490"><span class="linenos">5490</span></a><span class="sd"> Returns:</span> +</span><span id="L-5491"><a href="#L-5491"><span class="linenos">5491</span></a><span class="sd"> The new Cast instance.</span> +</span><span id="L-5492"><a href="#L-5492"><span class="linenos">5492</span></a><span class="sd"> """</span> +</span><span id="L-5493"><a href="#L-5493"><span class="linenos">5493</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="L-5494"><a href="#L-5494"><span class="linenos">5494</span></a> <span class="k">return</span> <span class="n">Cast</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">to</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="n">to</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">))</span> +</span><span id="L-5495"><a href="#L-5495"><span class="linenos">5495</span></a> +</span><span id="L-5496"><a href="#L-5496"><span class="linenos">5496</span></a> +</span><span id="L-5497"><a href="#L-5497"><span class="linenos">5497</span></a><span class="k">def</span> <span class="nf">table_</span><span class="p">(</span> +</span><span id="L-5498"><a href="#L-5498"><span class="linenos">5498</span></a> <span class="n">table</span><span class="p">:</span> <span class="n">Identifier</span> <span class="o">|</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="L-5499"><a href="#L-5499"><span class="linenos">5499</span></a> <span class="n">db</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">Identifier</span> <span class="o">|</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-5500"><a href="#L-5500"><span class="linenos">5500</span></a> <span class="n">catalog</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">Identifier</span> <span class="o">|</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-5501"><a href="#L-5501"><span class="linenos">5501</span></a> <span class="n">quoted</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-5502"><a href="#L-5502"><span class="linenos">5502</span></a> <span class="n">alias</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">Identifier</span> <span class="o">|</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-5503"><a href="#L-5503"><span class="linenos">5503</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Table</span><span class="p">:</span> +</span><span id="L-5504"><a href="#L-5504"><span class="linenos">5504</span></a><span class="w"> </span><span class="sd">"""Build a Table.</span> +</span><span id="L-5505"><a href="#L-5505"><span class="linenos">5505</span></a> +</span><span id="L-5506"><a href="#L-5506"><span class="linenos">5506</span></a><span class="sd"> Args:</span> +</span><span id="L-5507"><a href="#L-5507"><span class="linenos">5507</span></a><span class="sd"> table: Table name.</span> +</span><span id="L-5508"><a href="#L-5508"><span class="linenos">5508</span></a><span class="sd"> db: Database name.</span> +</span><span id="L-5509"><a href="#L-5509"><span class="linenos">5509</span></a><span class="sd"> catalog: Catalog name.</span> +</span><span id="L-5510"><a href="#L-5510"><span class="linenos">5510</span></a><span class="sd"> quote: Whether to force quotes on the table's identifiers.</span> +</span><span id="L-5511"><a href="#L-5511"><span class="linenos">5511</span></a><span class="sd"> alias: Table's alias.</span> +</span><span id="L-5512"><a href="#L-5512"><span class="linenos">5512</span></a> +</span><span id="L-5513"><a href="#L-5513"><span class="linenos">5513</span></a><span class="sd"> Returns:</span> +</span><span id="L-5514"><a href="#L-5514"><span class="linenos">5514</span></a><span class="sd"> The new Table instance.</span> +</span><span id="L-5515"><a href="#L-5515"><span class="linenos">5515</span></a><span class="sd"> """</span> +</span><span id="L-5516"><a href="#L-5516"><span class="linenos">5516</span></a> <span class="k">return</span> <span class="n">Table</span><span class="p">(</span> +</span><span id="L-5517"><a href="#L-5517"><span class="linenos">5517</span></a> <span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> +</span><span id="L-5518"><a href="#L-5518"><span class="linenos">5518</span></a> <span class="n">db</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">db</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> +</span><span id="L-5519"><a href="#L-5519"><span class="linenos">5519</span></a> <span class="n">catalog</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">catalog</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> +</span><span id="L-5520"><a href="#L-5520"><span class="linenos">5520</span></a> <span class="n">alias</span><span class="o">=</span><span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">))</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-5521"><a href="#L-5521"><span class="linenos">5521</span></a> <span class="p">)</span> +</span><span id="L-5522"><a href="#L-5522"><span class="linenos">5522</span></a> +</span><span id="L-5523"><a href="#L-5523"><span class="linenos">5523</span></a> +</span><span id="L-5524"><a href="#L-5524"><span class="linenos">5524</span></a><span class="k">def</span> <span class="nf">values</span><span class="p">(</span> +</span><span id="L-5525"><a href="#L-5525"><span class="linenos">5525</span></a> <span class="n">values</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="o">...</span><span class="p">]],</span> +</span><span id="L-5526"><a href="#L-5526"><span class="linenos">5526</span></a> <span class="n">alias</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-5527"><a href="#L-5527"><span class="linenos">5527</span></a> <span class="n">columns</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">DataType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-5528"><a href="#L-5528"><span class="linenos">5528</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Values</span><span class="p">:</span> +</span><span id="L-5529"><a href="#L-5529"><span class="linenos">5529</span></a><span class="w"> </span><span class="sd">"""Build VALUES statement.</span> +</span><span id="L-5530"><a href="#L-5530"><span class="linenos">5530</span></a> +</span><span id="L-5531"><a href="#L-5531"><span class="linenos">5531</span></a><span class="sd"> Example:</span> +</span><span id="L-5532"><a href="#L-5532"><span class="linenos">5532</span></a><span class="sd"> >>> values([(1, '2')]).sql()</span> +</span><span id="L-5533"><a href="#L-5533"><span class="linenos">5533</span></a><span class="sd"> "VALUES (1, '2')"</span> +</span><span id="L-5534"><a href="#L-5534"><span class="linenos">5534</span></a> +</span><span id="L-5535"><a href="#L-5535"><span class="linenos">5535</span></a><span class="sd"> Args:</span> +</span><span id="L-5536"><a href="#L-5536"><span class="linenos">5536</span></a><span class="sd"> values: values statements that will be converted to SQL</span> +</span><span id="L-5537"><a href="#L-5537"><span class="linenos">5537</span></a><span class="sd"> alias: optional alias</span> +</span><span id="L-5538"><a href="#L-5538"><span class="linenos">5538</span></a><span class="sd"> columns: Optional list of ordered column names or ordered dictionary of column names to types.</span> +</span><span id="L-5539"><a href="#L-5539"><span class="linenos">5539</span></a><span class="sd"> If either are provided then an alias is also required.</span> +</span><span id="L-5540"><a href="#L-5540"><span class="linenos">5540</span></a> +</span><span id="L-5541"><a href="#L-5541"><span class="linenos">5541</span></a><span class="sd"> Returns:</span> +</span><span id="L-5542"><a href="#L-5542"><span class="linenos">5542</span></a><span class="sd"> Values: the Values expression object</span> +</span><span id="L-5543"><a href="#L-5543"><span class="linenos">5543</span></a><span class="sd"> """</span> +</span><span id="L-5544"><a href="#L-5544"><span class="linenos">5544</span></a> <span class="k">if</span> <span class="n">columns</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">alias</span><span class="p">:</span> +</span><span id="L-5545"><a href="#L-5545"><span class="linenos">5545</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Alias is required when providing columns"</span><span class="p">)</span> +</span><span id="L-5546"><a href="#L-5546"><span class="linenos">5546</span></a> +</span><span id="L-5547"><a href="#L-5547"><span class="linenos">5547</span></a> <span class="k">return</span> <span class="n">Values</span><span class="p">(</span> +</span><span id="L-5548"><a href="#L-5548"><span class="linenos">5548</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">tup</span><span class="p">)</span> <span class="k">for</span> <span class="n">tup</span> <span class="ow">in</span> <span class="n">values</span><span class="p">],</span> +</span><span id="L-5549"><a href="#L-5549"><span class="linenos">5549</span></a> <span class="n">alias</span><span class="o">=</span><span class="p">(</span> +</span><span id="L-5550"><a href="#L-5550"><span class="linenos">5550</span></a> <span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">),</span> <span class="n">columns</span><span class="o">=</span><span class="p">[</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">columns</span><span class="p">])</span> +</span><span id="L-5551"><a href="#L-5551"><span class="linenos">5551</span></a> <span class="k">if</span> <span class="n">columns</span> +</span><span id="L-5552"><a href="#L-5552"><span class="linenos">5552</span></a> <span class="k">else</span> <span class="p">(</span><span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">))</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="L-5553"><a href="#L-5553"><span class="linenos">5553</span></a> <span class="p">),</span> +</span><span id="L-5554"><a href="#L-5554"><span class="linenos">5554</span></a> <span class="p">)</span> +</span><span id="L-5555"><a href="#L-5555"><span class="linenos">5555</span></a> +</span><span id="L-5556"><a href="#L-5556"><span class="linenos">5556</span></a> +</span><span id="L-5557"><a href="#L-5557"><span class="linenos">5557</span></a><span class="k">def</span> <span class="nf">var</span><span class="p">(</span><span class="n">name</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">ExpOrStr</span><span class="p">])</span> <span class="o">-></span> <span class="n">Var</span><span class="p">:</span> +</span><span id="L-5558"><a href="#L-5558"><span class="linenos">5558</span></a><span class="w"> </span><span class="sd">"""Build a SQL variable.</span> +</span><span id="L-5559"><a href="#L-5559"><span class="linenos">5559</span></a> +</span><span id="L-5560"><a href="#L-5560"><span class="linenos">5560</span></a><span class="sd"> Example:</span> +</span><span id="L-5561"><a href="#L-5561"><span class="linenos">5561</span></a><span class="sd"> >>> repr(var('x'))</span> +</span><span id="L-5562"><a href="#L-5562"><span class="linenos">5562</span></a><span class="sd"> '(VAR this: x)'</span> +</span><span id="L-5563"><a href="#L-5563"><span class="linenos">5563</span></a> +</span><span id="L-5564"><a href="#L-5564"><span class="linenos">5564</span></a><span class="sd"> >>> repr(var(column('x', table='y')))</span> +</span><span id="L-5565"><a href="#L-5565"><span class="linenos">5565</span></a><span class="sd"> '(VAR this: x)'</span> +</span><span id="L-5566"><a href="#L-5566"><span class="linenos">5566</span></a> +</span><span id="L-5567"><a href="#L-5567"><span class="linenos">5567</span></a><span class="sd"> Args:</span> +</span><span id="L-5568"><a href="#L-5568"><span class="linenos">5568</span></a><span class="sd"> name: The name of the var or an expression who's name will become the var.</span> +</span><span id="L-5569"><a href="#L-5569"><span class="linenos">5569</span></a> +</span><span id="L-5570"><a href="#L-5570"><span class="linenos">5570</span></a><span class="sd"> Returns:</span> +</span><span id="L-5571"><a href="#L-5571"><span class="linenos">5571</span></a><span class="sd"> The new variable node.</span> +</span><span id="L-5572"><a href="#L-5572"><span class="linenos">5572</span></a><span class="sd"> """</span> +</span><span id="L-5573"><a href="#L-5573"><span class="linenos">5573</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">name</span><span class="p">:</span> +</span><span id="L-5574"><a href="#L-5574"><span class="linenos">5574</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Cannot convert empty name into var."</span><span class="p">)</span> </span><span id="L-5575"><a href="#L-5575"><span class="linenos">5575</span></a> -</span><span id="L-5576"><a href="#L-5576"><span class="linenos">5576</span></a><span class="k">def</span> <span class="nf">rename_table</span><span class="p">(</span><span class="n">old_name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Table</span><span class="p">,</span> <span class="n">new_name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Table</span><span class="p">)</span> <span class="o">-></span> <span class="n">AlterTable</span><span class="p">:</span> -</span><span id="L-5577"><a href="#L-5577"><span class="linenos">5577</span></a><span class="w"> </span><span class="sd">"""Build ALTER TABLE... RENAME... expression</span> -</span><span id="L-5578"><a href="#L-5578"><span class="linenos">5578</span></a> -</span><span id="L-5579"><a href="#L-5579"><span class="linenos">5579</span></a><span class="sd"> Args:</span> -</span><span id="L-5580"><a href="#L-5580"><span class="linenos">5580</span></a><span class="sd"> old_name: The old name of the table</span> -</span><span id="L-5581"><a href="#L-5581"><span class="linenos">5581</span></a><span class="sd"> new_name: The new name of the table</span> -</span><span id="L-5582"><a href="#L-5582"><span class="linenos">5582</span></a> -</span><span id="L-5583"><a href="#L-5583"><span class="linenos">5583</span></a><span class="sd"> Returns:</span> -</span><span id="L-5584"><a href="#L-5584"><span class="linenos">5584</span></a><span class="sd"> Alter table expression</span> -</span><span id="L-5585"><a href="#L-5585"><span class="linenos">5585</span></a><span class="sd"> """</span> -</span><span id="L-5586"><a href="#L-5586"><span class="linenos">5586</span></a> <span class="n">old_table</span> <span class="o">=</span> <span class="n">to_table</span><span class="p">(</span><span class="n">old_name</span><span class="p">)</span> -</span><span id="L-5587"><a href="#L-5587"><span class="linenos">5587</span></a> <span class="n">new_table</span> <span class="o">=</span> <span class="n">to_table</span><span class="p">(</span><span class="n">new_name</span><span class="p">)</span> -</span><span id="L-5588"><a href="#L-5588"><span class="linenos">5588</span></a> <span class="k">return</span> <span class="n">AlterTable</span><span class="p">(</span> -</span><span id="L-5589"><a href="#L-5589"><span class="linenos">5589</span></a> <span class="n">this</span><span class="o">=</span><span class="n">old_table</span><span class="p">,</span> -</span><span id="L-5590"><a href="#L-5590"><span class="linenos">5590</span></a> <span class="n">actions</span><span class="o">=</span><span class="p">[</span> -</span><span id="L-5591"><a href="#L-5591"><span class="linenos">5591</span></a> <span class="n">RenameTable</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">new_table</span><span class="p">),</span> -</span><span id="L-5592"><a href="#L-5592"><span class="linenos">5592</span></a> <span class="p">],</span> -</span><span id="L-5593"><a href="#L-5593"><span class="linenos">5593</span></a> <span class="p">)</span> -</span><span id="L-5594"><a href="#L-5594"><span class="linenos">5594</span></a> -</span><span id="L-5595"><a href="#L-5595"><span class="linenos">5595</span></a> -</span><span id="L-5596"><a href="#L-5596"><span class="linenos">5596</span></a><span class="k">def</span> <span class="nf">convert</span><span class="p">(</span><span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> -</span><span id="L-5597"><a href="#L-5597"><span class="linenos">5597</span></a><span class="w"> </span><span class="sd">"""Convert a python value into an expression object.</span> -</span><span id="L-5598"><a href="#L-5598"><span class="linenos">5598</span></a> -</span><span id="L-5599"><a href="#L-5599"><span class="linenos">5599</span></a><span class="sd"> Raises an error if a conversion is not possible.</span> +</span><span id="L-5576"><a href="#L-5576"><span class="linenos">5576</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> +</span><span id="L-5577"><a href="#L-5577"><span class="linenos">5577</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">name</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-5578"><a href="#L-5578"><span class="linenos">5578</span></a> <span class="k">return</span> <span class="n">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">name</span><span class="p">)</span> +</span><span id="L-5579"><a href="#L-5579"><span class="linenos">5579</span></a> +</span><span id="L-5580"><a href="#L-5580"><span class="linenos">5580</span></a> +</span><span id="L-5581"><a href="#L-5581"><span class="linenos">5581</span></a><span class="k">def</span> <span class="nf">rename_table</span><span class="p">(</span><span class="n">old_name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Table</span><span class="p">,</span> <span class="n">new_name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Table</span><span class="p">)</span> <span class="o">-></span> <span class="n">AlterTable</span><span class="p">:</span> +</span><span id="L-5582"><a href="#L-5582"><span class="linenos">5582</span></a><span class="w"> </span><span class="sd">"""Build ALTER TABLE... RENAME... expression</span> +</span><span id="L-5583"><a href="#L-5583"><span class="linenos">5583</span></a> +</span><span id="L-5584"><a href="#L-5584"><span class="linenos">5584</span></a><span class="sd"> Args:</span> +</span><span id="L-5585"><a href="#L-5585"><span class="linenos">5585</span></a><span class="sd"> old_name: The old name of the table</span> +</span><span id="L-5586"><a href="#L-5586"><span class="linenos">5586</span></a><span class="sd"> new_name: The new name of the table</span> +</span><span id="L-5587"><a href="#L-5587"><span class="linenos">5587</span></a> +</span><span id="L-5588"><a href="#L-5588"><span class="linenos">5588</span></a><span class="sd"> Returns:</span> +</span><span id="L-5589"><a href="#L-5589"><span class="linenos">5589</span></a><span class="sd"> Alter table expression</span> +</span><span id="L-5590"><a href="#L-5590"><span class="linenos">5590</span></a><span class="sd"> """</span> +</span><span id="L-5591"><a href="#L-5591"><span class="linenos">5591</span></a> <span class="n">old_table</span> <span class="o">=</span> <span class="n">to_table</span><span class="p">(</span><span class="n">old_name</span><span class="p">)</span> +</span><span id="L-5592"><a href="#L-5592"><span class="linenos">5592</span></a> <span class="n">new_table</span> <span class="o">=</span> <span class="n">to_table</span><span class="p">(</span><span class="n">new_name</span><span class="p">)</span> +</span><span id="L-5593"><a href="#L-5593"><span class="linenos">5593</span></a> <span class="k">return</span> <span class="n">AlterTable</span><span class="p">(</span> +</span><span id="L-5594"><a href="#L-5594"><span class="linenos">5594</span></a> <span class="n">this</span><span class="o">=</span><span class="n">old_table</span><span class="p">,</span> +</span><span id="L-5595"><a href="#L-5595"><span class="linenos">5595</span></a> <span class="n">actions</span><span class="o">=</span><span class="p">[</span> +</span><span id="L-5596"><a href="#L-5596"><span class="linenos">5596</span></a> <span class="n">RenameTable</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">new_table</span><span class="p">),</span> +</span><span id="L-5597"><a href="#L-5597"><span class="linenos">5597</span></a> <span class="p">],</span> +</span><span id="L-5598"><a href="#L-5598"><span class="linenos">5598</span></a> <span class="p">)</span> +</span><span id="L-5599"><a href="#L-5599"><span class="linenos">5599</span></a> </span><span id="L-5600"><a href="#L-5600"><span class="linenos">5600</span></a> -</span><span id="L-5601"><a href="#L-5601"><span class="linenos">5601</span></a><span class="sd"> Args:</span> -</span><span id="L-5602"><a href="#L-5602"><span class="linenos">5602</span></a><span class="sd"> value: A python object.</span> -</span><span id="L-5603"><a href="#L-5603"><span class="linenos">5603</span></a><span class="sd"> copy: Whether or not to copy `value` (only applies to Expressions and collections).</span> -</span><span id="L-5604"><a href="#L-5604"><span class="linenos">5604</span></a> -</span><span id="L-5605"><a href="#L-5605"><span class="linenos">5605</span></a><span class="sd"> Returns:</span> -</span><span id="L-5606"><a href="#L-5606"><span class="linenos">5606</span></a><span class="sd"> Expression: the equivalent expression object.</span> -</span><span id="L-5607"><a href="#L-5607"><span class="linenos">5607</span></a><span class="sd"> """</span> -</span><span id="L-5608"><a href="#L-5608"><span class="linenos">5608</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> -</span><span id="L-5609"><a href="#L-5609"><span class="linenos">5609</span></a> <span class="k">return</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="L-5610"><a href="#L-5610"><span class="linenos">5610</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="L-5611"><a href="#L-5611"><span class="linenos">5611</span></a> <span class="k">return</span> <span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="L-5612"><a href="#L-5612"><span class="linenos">5612</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">bool</span><span class="p">):</span> -</span><span id="L-5613"><a href="#L-5613"><span class="linenos">5613</span></a> <span class="k">return</span> <span class="n">Boolean</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">value</span><span class="p">)</span> -</span><span id="L-5614"><a href="#L-5614"><span class="linenos">5614</span></a> <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="p">(</span><span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">float</span><span class="p">)</span> <span class="ow">and</span> <span class="n">math</span><span class="o">.</span><span class="n">isnan</span><span class="p">(</span><span class="n">value</span><span class="p">)):</span> -</span><span id="L-5615"><a href="#L-5615"><span class="linenos">5615</span></a> <span class="k">return</span> <span class="n">NULL</span> -</span><span id="L-5616"><a href="#L-5616"><span class="linenos">5616</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">numbers</span><span class="o">.</span><span class="n">Number</span><span class="p">):</span> -</span><span id="L-5617"><a href="#L-5617"><span class="linenos">5617</span></a> <span class="k">return</span> <span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="L-5618"><a href="#L-5618"><span class="linenos">5618</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="p">):</span> -</span><span id="L-5619"><a href="#L-5619"><span class="linenos">5619</span></a> <span class="n">datetime_literal</span> <span class="o">=</span> <span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span> -</span><span id="L-5620"><a href="#L-5620"><span class="linenos">5620</span></a> <span class="p">(</span><span class="n">value</span> <span class="k">if</span> <span class="n">value</span><span class="o">.</span><span class="n">tzinfo</span> <span class="k">else</span> <span class="n">value</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">tzinfo</span><span class="o">=</span><span class="n">datetime</span><span class="o">.</span><span class="n">timezone</span><span class="o">.</span><span class="n">utc</span><span class="p">))</span><span class="o">.</span><span class="n">isoformat</span><span class="p">()</span> -</span><span id="L-5621"><a href="#L-5621"><span class="linenos">5621</span></a> <span class="p">)</span> -</span><span id="L-5622"><a href="#L-5622"><span class="linenos">5622</span></a> <span class="k">return</span> <span class="n">TimeStrToTime</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">datetime_literal</span><span class="p">)</span> -</span><span id="L-5623"><a href="#L-5623"><span class="linenos">5623</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">datetime</span><span class="o">.</span><span class="n">date</span><span class="p">):</span> -</span><span id="L-5624"><a href="#L-5624"><span class="linenos">5624</span></a> <span class="n">date_literal</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">value</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">"%Y-%m-</span><span class="si">%d</span><span class="s2">"</span><span class="p">))</span> -</span><span id="L-5625"><a href="#L-5625"><span class="linenos">5625</span></a> <span class="k">return</span> <span class="n">DateStrToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">date_literal</span><span class="p">)</span> -</span><span id="L-5626"><a href="#L-5626"><span class="linenos">5626</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">):</span> -</span><span id="L-5627"><a href="#L-5627"><span class="linenos">5627</span></a> <span class="k">return</span> <span class="n">Tuple</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">value</span><span class="p">])</span> -</span><span id="L-5628"><a href="#L-5628"><span class="linenos">5628</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="L-5629"><a href="#L-5629"><span class="linenos">5629</span></a> <span class="k">return</span> <span class="n">Array</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">value</span><span class="p">])</span> -</span><span id="L-5630"><a href="#L-5630"><span class="linenos">5630</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span> -</span><span id="L-5631"><a href="#L-5631"><span class="linenos">5631</span></a> <span class="k">return</span> <span class="n">Map</span><span class="p">(</span> -</span><span id="L-5632"><a href="#L-5632"><span class="linenos">5632</span></a> <span class="n">keys</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">value</span><span class="p">],</span> -</span><span id="L-5633"><a href="#L-5633"><span class="linenos">5633</span></a> <span class="n">values</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">value</span><span class="o">.</span><span class="n">values</span><span class="p">()],</span> -</span><span id="L-5634"><a href="#L-5634"><span class="linenos">5634</span></a> <span class="p">)</span> -</span><span id="L-5635"><a href="#L-5635"><span class="linenos">5635</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Cannot convert </span><span class="si">{</span><span class="n">value</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-5636"><a href="#L-5636"><span class="linenos">5636</span></a> -</span><span id="L-5637"><a href="#L-5637"><span class="linenos">5637</span></a> -</span><span id="L-5638"><a href="#L-5638"><span class="linenos">5638</span></a><span class="k">def</span> <span class="nf">replace_children</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="n">fun</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-5639"><a href="#L-5639"><span class="linenos">5639</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-5640"><a href="#L-5640"><span class="linenos">5640</span></a><span class="sd"> Replace children of an expression with the result of a lambda fun(child) -> exp.</span> -</span><span id="L-5641"><a href="#L-5641"><span class="linenos">5641</span></a><span class="sd"> """</span> -</span><span id="L-5642"><a href="#L-5642"><span class="linenos">5642</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> -</span><span id="L-5643"><a href="#L-5643"><span class="linenos">5643</span></a> <span class="n">is_list_arg</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="ow">is</span> <span class="nb">list</span> -</span><span id="L-5644"><a href="#L-5644"><span class="linenos">5644</span></a> -</span><span id="L-5645"><a href="#L-5645"><span class="linenos">5645</span></a> <span class="n">child_nodes</span> <span class="o">=</span> <span class="n">v</span> <span class="k">if</span> <span class="n">is_list_arg</span> <span class="k">else</span> <span class="p">[</span><span class="n">v</span><span class="p">]</span> -</span><span id="L-5646"><a href="#L-5646"><span class="linenos">5646</span></a> <span class="n">new_child_nodes</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-5647"><a href="#L-5647"><span class="linenos">5647</span></a> -</span><span id="L-5648"><a href="#L-5648"><span class="linenos">5648</span></a> <span class="k">for</span> <span class="n">cn</span> <span class="ow">in</span> <span class="n">child_nodes</span><span class="p">:</span> -</span><span id="L-5649"><a href="#L-5649"><span class="linenos">5649</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">cn</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> -</span><span id="L-5650"><a href="#L-5650"><span class="linenos">5650</span></a> <span class="k">for</span> <span class="n">child_node</span> <span class="ow">in</span> <span class="n">ensure_collection</span><span class="p">(</span><span class="n">fun</span><span class="p">(</span><span class="n">cn</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)):</span> -</span><span id="L-5651"><a href="#L-5651"><span class="linenos">5651</span></a> <span class="n">new_child_nodes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">child_node</span><span class="p">)</span> -</span><span id="L-5652"><a href="#L-5652"><span class="linenos">5652</span></a> <span class="n">child_node</span><span class="o">.</span><span class="n">parent</span> <span class="o">=</span> <span class="n">expression</span> -</span><span id="L-5653"><a href="#L-5653"><span class="linenos">5653</span></a> <span class="n">child_node</span><span class="o">.</span><span class="n">arg_key</span> <span class="o">=</span> <span class="n">k</span> -</span><span id="L-5654"><a href="#L-5654"><span class="linenos">5654</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-5655"><a href="#L-5655"><span class="linenos">5655</span></a> <span class="n">new_child_nodes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">cn</span><span class="p">)</span> -</span><span id="L-5656"><a href="#L-5656"><span class="linenos">5656</span></a> -</span><span id="L-5657"><a href="#L-5657"><span class="linenos">5657</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">new_child_nodes</span> <span class="k">if</span> <span class="n">is_list_arg</span> <span class="k">else</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">new_child_nodes</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> -</span><span id="L-5658"><a href="#L-5658"><span class="linenos">5658</span></a> -</span><span id="L-5659"><a href="#L-5659"><span class="linenos">5659</span></a> -</span><span id="L-5660"><a href="#L-5660"><span class="linenos">5660</span></a><span class="k">def</span> <span class="nf">column_table_names</span><span class="p">(</span><span class="n">expression</span><span class="p">:</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-5661"><a href="#L-5661"><span class="linenos">5661</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-5662"><a href="#L-5662"><span class="linenos">5662</span></a><span class="sd"> Return all table names referenced through columns in an expression.</span> +</span><span id="L-5601"><a href="#L-5601"><span class="linenos">5601</span></a><span class="k">def</span> <span class="nf">convert</span><span class="p">(</span><span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> +</span><span id="L-5602"><a href="#L-5602"><span class="linenos">5602</span></a><span class="w"> </span><span class="sd">"""Convert a python value into an expression object.</span> +</span><span id="L-5603"><a href="#L-5603"><span class="linenos">5603</span></a> +</span><span id="L-5604"><a href="#L-5604"><span class="linenos">5604</span></a><span class="sd"> Raises an error if a conversion is not possible.</span> +</span><span id="L-5605"><a href="#L-5605"><span class="linenos">5605</span></a> +</span><span id="L-5606"><a href="#L-5606"><span class="linenos">5606</span></a><span class="sd"> Args:</span> +</span><span id="L-5607"><a href="#L-5607"><span class="linenos">5607</span></a><span class="sd"> value: A python object.</span> +</span><span id="L-5608"><a href="#L-5608"><span class="linenos">5608</span></a><span class="sd"> copy: Whether or not to copy `value` (only applies to Expressions and collections).</span> +</span><span id="L-5609"><a href="#L-5609"><span class="linenos">5609</span></a> +</span><span id="L-5610"><a href="#L-5610"><span class="linenos">5610</span></a><span class="sd"> Returns:</span> +</span><span id="L-5611"><a href="#L-5611"><span class="linenos">5611</span></a><span class="sd"> Expression: the equivalent expression object.</span> +</span><span id="L-5612"><a href="#L-5612"><span class="linenos">5612</span></a><span class="sd"> """</span> +</span><span id="L-5613"><a href="#L-5613"><span class="linenos">5613</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> +</span><span id="L-5614"><a href="#L-5614"><span class="linenos">5614</span></a> <span class="k">return</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="L-5615"><a href="#L-5615"><span class="linenos">5615</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="L-5616"><a href="#L-5616"><span class="linenos">5616</span></a> <span class="k">return</span> <span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="L-5617"><a href="#L-5617"><span class="linenos">5617</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">bool</span><span class="p">):</span> +</span><span id="L-5618"><a href="#L-5618"><span class="linenos">5618</span></a> <span class="k">return</span> <span class="n">Boolean</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">value</span><span class="p">)</span> +</span><span id="L-5619"><a href="#L-5619"><span class="linenos">5619</span></a> <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="p">(</span><span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">float</span><span class="p">)</span> <span class="ow">and</span> <span class="n">math</span><span class="o">.</span><span class="n">isnan</span><span class="p">(</span><span class="n">value</span><span class="p">)):</span> +</span><span id="L-5620"><a href="#L-5620"><span class="linenos">5620</span></a> <span class="k">return</span> <span class="n">NULL</span> +</span><span id="L-5621"><a href="#L-5621"><span class="linenos">5621</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">numbers</span><span class="o">.</span><span class="n">Number</span><span class="p">):</span> +</span><span id="L-5622"><a href="#L-5622"><span class="linenos">5622</span></a> <span class="k">return</span> <span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="L-5623"><a href="#L-5623"><span class="linenos">5623</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="p">):</span> +</span><span id="L-5624"><a href="#L-5624"><span class="linenos">5624</span></a> <span class="n">datetime_literal</span> <span class="o">=</span> <span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span> +</span><span id="L-5625"><a href="#L-5625"><span class="linenos">5625</span></a> <span class="p">(</span><span class="n">value</span> <span class="k">if</span> <span class="n">value</span><span class="o">.</span><span class="n">tzinfo</span> <span class="k">else</span> <span class="n">value</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">tzinfo</span><span class="o">=</span><span class="n">datetime</span><span class="o">.</span><span class="n">timezone</span><span class="o">.</span><span class="n">utc</span><span class="p">))</span><span class="o">.</span><span class="n">isoformat</span><span class="p">()</span> +</span><span id="L-5626"><a href="#L-5626"><span class="linenos">5626</span></a> <span class="p">)</span> +</span><span id="L-5627"><a href="#L-5627"><span class="linenos">5627</span></a> <span class="k">return</span> <span class="n">TimeStrToTime</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">datetime_literal</span><span class="p">)</span> +</span><span id="L-5628"><a href="#L-5628"><span class="linenos">5628</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">datetime</span><span class="o">.</span><span class="n">date</span><span class="p">):</span> +</span><span id="L-5629"><a href="#L-5629"><span class="linenos">5629</span></a> <span class="n">date_literal</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">value</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">"%Y-%m-</span><span class="si">%d</span><span class="s2">"</span><span class="p">))</span> +</span><span id="L-5630"><a href="#L-5630"><span class="linenos">5630</span></a> <span class="k">return</span> <span class="n">DateStrToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">date_literal</span><span class="p">)</span> +</span><span id="L-5631"><a href="#L-5631"><span class="linenos">5631</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">):</span> +</span><span id="L-5632"><a href="#L-5632"><span class="linenos">5632</span></a> <span class="k">return</span> <span class="n">Tuple</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">value</span><span class="p">])</span> +</span><span id="L-5633"><a href="#L-5633"><span class="linenos">5633</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="L-5634"><a href="#L-5634"><span class="linenos">5634</span></a> <span class="k">return</span> <span class="n">Array</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">value</span><span class="p">])</span> +</span><span id="L-5635"><a href="#L-5635"><span class="linenos">5635</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span> +</span><span id="L-5636"><a href="#L-5636"><span class="linenos">5636</span></a> <span class="k">return</span> <span class="n">Map</span><span class="p">(</span> +</span><span id="L-5637"><a href="#L-5637"><span class="linenos">5637</span></a> <span class="n">keys</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">value</span><span class="p">],</span> +</span><span id="L-5638"><a href="#L-5638"><span class="linenos">5638</span></a> <span class="n">values</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">value</span><span class="o">.</span><span class="n">values</span><span class="p">()],</span> +</span><span id="L-5639"><a href="#L-5639"><span class="linenos">5639</span></a> <span class="p">)</span> +</span><span id="L-5640"><a href="#L-5640"><span class="linenos">5640</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Cannot convert </span><span class="si">{</span><span class="n">value</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-5641"><a href="#L-5641"><span class="linenos">5641</span></a> +</span><span id="L-5642"><a href="#L-5642"><span class="linenos">5642</span></a> +</span><span id="L-5643"><a href="#L-5643"><span class="linenos">5643</span></a><span class="k">def</span> <span class="nf">replace_children</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="n">fun</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-5644"><a href="#L-5644"><span class="linenos">5644</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-5645"><a href="#L-5645"><span class="linenos">5645</span></a><span class="sd"> Replace children of an expression with the result of a lambda fun(child) -> exp.</span> +</span><span id="L-5646"><a href="#L-5646"><span class="linenos">5646</span></a><span class="sd"> """</span> +</span><span id="L-5647"><a href="#L-5647"><span class="linenos">5647</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> +</span><span id="L-5648"><a href="#L-5648"><span class="linenos">5648</span></a> <span class="n">is_list_arg</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="ow">is</span> <span class="nb">list</span> +</span><span id="L-5649"><a href="#L-5649"><span class="linenos">5649</span></a> +</span><span id="L-5650"><a href="#L-5650"><span class="linenos">5650</span></a> <span class="n">child_nodes</span> <span class="o">=</span> <span class="n">v</span> <span class="k">if</span> <span class="n">is_list_arg</span> <span class="k">else</span> <span class="p">[</span><span class="n">v</span><span class="p">]</span> +</span><span id="L-5651"><a href="#L-5651"><span class="linenos">5651</span></a> <span class="n">new_child_nodes</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-5652"><a href="#L-5652"><span class="linenos">5652</span></a> +</span><span id="L-5653"><a href="#L-5653"><span class="linenos">5653</span></a> <span class="k">for</span> <span class="n">cn</span> <span class="ow">in</span> <span class="n">child_nodes</span><span class="p">:</span> +</span><span id="L-5654"><a href="#L-5654"><span class="linenos">5654</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">cn</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> +</span><span id="L-5655"><a href="#L-5655"><span class="linenos">5655</span></a> <span class="k">for</span> <span class="n">child_node</span> <span class="ow">in</span> <span class="n">ensure_collection</span><span class="p">(</span><span class="n">fun</span><span class="p">(</span><span class="n">cn</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)):</span> +</span><span id="L-5656"><a href="#L-5656"><span class="linenos">5656</span></a> <span class="n">new_child_nodes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">child_node</span><span class="p">)</span> +</span><span id="L-5657"><a href="#L-5657"><span class="linenos">5657</span></a> <span class="n">child_node</span><span class="o">.</span><span class="n">parent</span> <span class="o">=</span> <span class="n">expression</span> +</span><span id="L-5658"><a href="#L-5658"><span class="linenos">5658</span></a> <span class="n">child_node</span><span class="o">.</span><span class="n">arg_key</span> <span class="o">=</span> <span class="n">k</span> +</span><span id="L-5659"><a href="#L-5659"><span class="linenos">5659</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-5660"><a href="#L-5660"><span class="linenos">5660</span></a> <span class="n">new_child_nodes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">cn</span><span class="p">)</span> +</span><span id="L-5661"><a href="#L-5661"><span class="linenos">5661</span></a> +</span><span id="L-5662"><a href="#L-5662"><span class="linenos">5662</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">new_child_nodes</span> <span class="k">if</span> <span class="n">is_list_arg</span> <span class="k">else</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">new_child_nodes</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> </span><span id="L-5663"><a href="#L-5663"><span class="linenos">5663</span></a> -</span><span id="L-5664"><a href="#L-5664"><span class="linenos">5664</span></a><span class="sd"> Example:</span> -</span><span id="L-5665"><a href="#L-5665"><span class="linenos">5665</span></a><span class="sd"> >>> import sqlglot</span> -</span><span id="L-5666"><a href="#L-5666"><span class="linenos">5666</span></a><span class="sd"> >>> column_table_names(sqlglot.parse_one("a.b AND c.d AND c.e"))</span> -</span><span id="L-5667"><a href="#L-5667"><span class="linenos">5667</span></a><span class="sd"> ['c', 'a']</span> +</span><span id="L-5664"><a href="#L-5664"><span class="linenos">5664</span></a> +</span><span id="L-5665"><a href="#L-5665"><span class="linenos">5665</span></a><span class="k">def</span> <span class="nf">column_table_names</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="n">exclude</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="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="L-5666"><a href="#L-5666"><span class="linenos">5666</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-5667"><a href="#L-5667"><span class="linenos">5667</span></a><span class="sd"> Return all table names referenced through columns in an expression.</span> </span><span id="L-5668"><a href="#L-5668"><span class="linenos">5668</span></a> -</span><span id="L-5669"><a href="#L-5669"><span class="linenos">5669</span></a><span class="sd"> Args:</span> -</span><span id="L-5670"><a href="#L-5670"><span class="linenos">5670</span></a><span class="sd"> expression: expression to find table names.</span> -</span><span id="L-5671"><a href="#L-5671"><span class="linenos">5671</span></a> -</span><span id="L-5672"><a href="#L-5672"><span class="linenos">5672</span></a><span class="sd"> Returns:</span> -</span><span id="L-5673"><a href="#L-5673"><span class="linenos">5673</span></a><span class="sd"> A list of unique names.</span> -</span><span id="L-5674"><a href="#L-5674"><span class="linenos">5674</span></a><span class="sd"> """</span> -</span><span id="L-5675"><a href="#L-5675"><span class="linenos">5675</span></a> <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="nb">dict</span><span class="o">.</span><span class="n">fromkeys</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">table</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">Column</span><span class="p">)))</span> -</span><span id="L-5676"><a href="#L-5676"><span class="linenos">5676</span></a> +</span><span id="L-5669"><a href="#L-5669"><span class="linenos">5669</span></a><span class="sd"> Example:</span> +</span><span id="L-5670"><a href="#L-5670"><span class="linenos">5670</span></a><span class="sd"> >>> import sqlglot</span> +</span><span id="L-5671"><a href="#L-5671"><span class="linenos">5671</span></a><span class="sd"> >>> sorted(column_table_names(sqlglot.parse_one("a.b AND c.d AND c.e")))</span> +</span><span id="L-5672"><a href="#L-5672"><span class="linenos">5672</span></a><span class="sd"> ['a', 'c']</span> +</span><span id="L-5673"><a href="#L-5673"><span class="linenos">5673</span></a> +</span><span id="L-5674"><a href="#L-5674"><span class="linenos">5674</span></a><span class="sd"> Args:</span> +</span><span id="L-5675"><a href="#L-5675"><span class="linenos">5675</span></a><span class="sd"> expression: expression to find table names.</span> +</span><span id="L-5676"><a href="#L-5676"><span class="linenos">5676</span></a><span class="sd"> exclude: a table name to exclude</span> </span><span id="L-5677"><a href="#L-5677"><span class="linenos">5677</span></a> -</span><span id="L-5678"><a href="#L-5678"><span class="linenos">5678</span></a><span class="k">def</span> <span class="nf">table_name</span><span class="p">(</span><span class="n">table</span><span class="p">:</span> <span class="n">Table</span> <span class="o">|</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-5679"><a href="#L-5679"><span class="linenos">5679</span></a><span class="w"> </span><span class="sd">"""Get the full name of a table as a string.</span> -</span><span id="L-5680"><a href="#L-5680"><span class="linenos">5680</span></a> -</span><span id="L-5681"><a href="#L-5681"><span class="linenos">5681</span></a><span class="sd"> Args:</span> -</span><span id="L-5682"><a href="#L-5682"><span class="linenos">5682</span></a><span class="sd"> table: table expression node or string.</span> -</span><span id="L-5683"><a href="#L-5683"><span class="linenos">5683</span></a> -</span><span id="L-5684"><a href="#L-5684"><span class="linenos">5684</span></a><span class="sd"> Examples:</span> -</span><span id="L-5685"><a href="#L-5685"><span class="linenos">5685</span></a><span class="sd"> >>> from sqlglot import exp, parse_one</span> -</span><span id="L-5686"><a href="#L-5686"><span class="linenos">5686</span></a><span class="sd"> >>> table_name(parse_one("select * from a.b.c").find(exp.Table))</span> -</span><span id="L-5687"><a href="#L-5687"><span class="linenos">5687</span></a><span class="sd"> 'a.b.c'</span> -</span><span id="L-5688"><a href="#L-5688"><span class="linenos">5688</span></a> -</span><span id="L-5689"><a href="#L-5689"><span class="linenos">5689</span></a><span class="sd"> Returns:</span> -</span><span id="L-5690"><a href="#L-5690"><span class="linenos">5690</span></a><span class="sd"> The table name.</span> -</span><span id="L-5691"><a href="#L-5691"><span class="linenos">5691</span></a><span class="sd"> """</span> -</span><span id="L-5692"><a href="#L-5692"><span class="linenos">5692</span></a> -</span><span id="L-5693"><a href="#L-5693"><span class="linenos">5693</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">)</span> -</span><span id="L-5694"><a href="#L-5694"><span class="linenos">5694</span></a> -</span><span id="L-5695"><a href="#L-5695"><span class="linenos">5695</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span><span class="p">:</span> -</span><span id="L-5696"><a href="#L-5696"><span class="linenos">5696</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Cannot parse </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-5697"><a href="#L-5697"><span class="linenos">5697</span></a> -</span><span id="L-5698"><a href="#L-5698"><span class="linenos">5698</span></a> <span class="k">return</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">part</span> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">),</span> <span class="n">table</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"db"</span><span class="p">),</span> <span class="n">table</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> <span class="k">if</span> <span class="n">part</span><span class="p">)</span> -</span><span id="L-5699"><a href="#L-5699"><span class="linenos">5699</span></a> -</span><span id="L-5700"><a href="#L-5700"><span class="linenos">5700</span></a> -</span><span id="L-5701"><a href="#L-5701"><span class="linenos">5701</span></a><span class="k">def</span> <span class="nf">replace_tables</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">mapping</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="L-5702"><a href="#L-5702"><span class="linenos">5702</span></a><span class="w"> </span><span class="sd">"""Replace all tables in expression according to the mapping.</span> -</span><span id="L-5703"><a href="#L-5703"><span class="linenos">5703</span></a> -</span><span id="L-5704"><a href="#L-5704"><span class="linenos">5704</span></a><span class="sd"> Args:</span> -</span><span id="L-5705"><a href="#L-5705"><span class="linenos">5705</span></a><span class="sd"> expression: expression node to be transformed and replaced.</span> -</span><span id="L-5706"><a href="#L-5706"><span class="linenos">5706</span></a><span class="sd"> mapping: mapping of table names.</span> -</span><span id="L-5707"><a href="#L-5707"><span class="linenos">5707</span></a><span class="sd"> copy: whether or not to copy the expression.</span> -</span><span id="L-5708"><a href="#L-5708"><span class="linenos">5708</span></a> -</span><span id="L-5709"><a href="#L-5709"><span class="linenos">5709</span></a><span class="sd"> Examples:</span> -</span><span id="L-5710"><a href="#L-5710"><span class="linenos">5710</span></a><span class="sd"> >>> from sqlglot import exp, parse_one</span> -</span><span id="L-5711"><a href="#L-5711"><span class="linenos">5711</span></a><span class="sd"> >>> replace_tables(parse_one("select * from a.b"), {"a.b": "c"}).sql()</span> -</span><span id="L-5712"><a href="#L-5712"><span class="linenos">5712</span></a><span class="sd"> 'SELECT * FROM c'</span> +</span><span id="L-5678"><a href="#L-5678"><span class="linenos">5678</span></a><span class="sd"> Returns:</span> +</span><span id="L-5679"><a href="#L-5679"><span class="linenos">5679</span></a><span class="sd"> A list of unique names.</span> +</span><span id="L-5680"><a href="#L-5680"><span class="linenos">5680</span></a><span class="sd"> """</span> +</span><span id="L-5681"><a href="#L-5681"><span class="linenos">5681</span></a> <span class="k">return</span> <span class="p">{</span> +</span><span id="L-5682"><a href="#L-5682"><span class="linenos">5682</span></a> <span class="n">table</span> +</span><span id="L-5683"><a href="#L-5683"><span class="linenos">5683</span></a> <span class="k">for</span> <span class="n">table</span> <span class="ow">in</span> <span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">table</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">Column</span><span class="p">))</span> +</span><span id="L-5684"><a href="#L-5684"><span class="linenos">5684</span></a> <span class="k">if</span> <span class="n">table</span> <span class="ow">and</span> <span class="n">table</span> <span class="o">!=</span> <span class="n">exclude</span> +</span><span id="L-5685"><a href="#L-5685"><span class="linenos">5685</span></a> <span class="p">}</span> +</span><span id="L-5686"><a href="#L-5686"><span class="linenos">5686</span></a> +</span><span id="L-5687"><a href="#L-5687"><span class="linenos">5687</span></a> +</span><span id="L-5688"><a href="#L-5688"><span class="linenos">5688</span></a><span class="k">def</span> <span class="nf">table_name</span><span class="p">(</span><span class="n">table</span><span class="p">:</span> <span class="n">Table</span> <span class="o">|</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-5689"><a href="#L-5689"><span class="linenos">5689</span></a><span class="w"> </span><span class="sd">"""Get the full name of a table as a string.</span> +</span><span id="L-5690"><a href="#L-5690"><span class="linenos">5690</span></a> +</span><span id="L-5691"><a href="#L-5691"><span class="linenos">5691</span></a><span class="sd"> Args:</span> +</span><span id="L-5692"><a href="#L-5692"><span class="linenos">5692</span></a><span class="sd"> table: table expression node or string.</span> +</span><span id="L-5693"><a href="#L-5693"><span class="linenos">5693</span></a> +</span><span id="L-5694"><a href="#L-5694"><span class="linenos">5694</span></a><span class="sd"> Examples:</span> +</span><span id="L-5695"><a href="#L-5695"><span class="linenos">5695</span></a><span class="sd"> >>> from sqlglot import exp, parse_one</span> +</span><span id="L-5696"><a href="#L-5696"><span class="linenos">5696</span></a><span class="sd"> >>> table_name(parse_one("select * from a.b.c").find(exp.Table))</span> +</span><span id="L-5697"><a href="#L-5697"><span class="linenos">5697</span></a><span class="sd"> 'a.b.c'</span> +</span><span id="L-5698"><a href="#L-5698"><span class="linenos">5698</span></a> +</span><span id="L-5699"><a href="#L-5699"><span class="linenos">5699</span></a><span class="sd"> Returns:</span> +</span><span id="L-5700"><a href="#L-5700"><span class="linenos">5700</span></a><span class="sd"> The table name.</span> +</span><span id="L-5701"><a href="#L-5701"><span class="linenos">5701</span></a><span class="sd"> """</span> +</span><span id="L-5702"><a href="#L-5702"><span class="linenos">5702</span></a> +</span><span id="L-5703"><a href="#L-5703"><span class="linenos">5703</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">)</span> +</span><span id="L-5704"><a href="#L-5704"><span class="linenos">5704</span></a> +</span><span id="L-5705"><a href="#L-5705"><span class="linenos">5705</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span><span class="p">:</span> +</span><span id="L-5706"><a href="#L-5706"><span class="linenos">5706</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Cannot parse </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-5707"><a href="#L-5707"><span class="linenos">5707</span></a> +</span><span id="L-5708"><a href="#L-5708"><span class="linenos">5708</span></a> <span class="k">return</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">part</span> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">),</span> <span class="n">table</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"db"</span><span class="p">),</span> <span class="n">table</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> <span class="k">if</span> <span class="n">part</span><span class="p">)</span> +</span><span id="L-5709"><a href="#L-5709"><span class="linenos">5709</span></a> +</span><span id="L-5710"><a href="#L-5710"><span class="linenos">5710</span></a> +</span><span id="L-5711"><a href="#L-5711"><span class="linenos">5711</span></a><span class="k">def</span> <span class="nf">replace_tables</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">mapping</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="L-5712"><a href="#L-5712"><span class="linenos">5712</span></a><span class="w"> </span><span class="sd">"""Replace all tables in expression according to the mapping.</span> </span><span id="L-5713"><a href="#L-5713"><span class="linenos">5713</span></a> -</span><span id="L-5714"><a href="#L-5714"><span class="linenos">5714</span></a><span class="sd"> Returns:</span> -</span><span id="L-5715"><a href="#L-5715"><span class="linenos">5715</span></a><span class="sd"> The mapped expression.</span> -</span><span id="L-5716"><a href="#L-5716"><span class="linenos">5716</span></a><span class="sd"> """</span> -</span><span id="L-5717"><a href="#L-5717"><span class="linenos">5717</span></a> -</span><span id="L-5718"><a href="#L-5718"><span class="linenos">5718</span></a> <span class="k">def</span> <span class="nf">_replace_tables</span><span class="p">(</span><span class="n">node</span><span class="p">:</span> <span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> -</span><span id="L-5719"><a href="#L-5719"><span class="linenos">5719</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">Table</span><span class="p">):</span> -</span><span id="L-5720"><a href="#L-5720"><span class="linenos">5720</span></a> <span class="n">new_name</span> <span class="o">=</span> <span class="n">mapping</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table_name</span><span class="p">(</span><span class="n">node</span><span class="p">))</span> -</span><span id="L-5721"><a href="#L-5721"><span class="linenos">5721</span></a> <span class="k">if</span> <span class="n">new_name</span><span class="p">:</span> -</span><span id="L-5722"><a href="#L-5722"><span class="linenos">5722</span></a> <span class="k">return</span> <span class="n">to_table</span><span class="p">(</span> -</span><span id="L-5723"><a href="#L-5723"><span class="linenos">5723</span></a> <span class="n">new_name</span><span class="p">,</span> -</span><span id="L-5724"><a href="#L-5724"><span class="linenos">5724</span></a> <span class="o">**</span><span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="n">v</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">node</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="k">if</span> <span class="n">k</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="s2">"db"</span><span class="p">,</span> <span class="s2">"catalog"</span><span class="p">)},</span> -</span><span id="L-5725"><a href="#L-5725"><span class="linenos">5725</span></a> <span class="p">)</span> -</span><span id="L-5726"><a href="#L-5726"><span class="linenos">5726</span></a> <span class="k">return</span> <span class="n">node</span> +</span><span id="L-5714"><a href="#L-5714"><span class="linenos">5714</span></a><span class="sd"> Args:</span> +</span><span id="L-5715"><a href="#L-5715"><span class="linenos">5715</span></a><span class="sd"> expression: expression node to be transformed and replaced.</span> +</span><span id="L-5716"><a href="#L-5716"><span class="linenos">5716</span></a><span class="sd"> mapping: mapping of table names.</span> +</span><span id="L-5717"><a href="#L-5717"><span class="linenos">5717</span></a><span class="sd"> copy: whether or not to copy the expression.</span> +</span><span id="L-5718"><a href="#L-5718"><span class="linenos">5718</span></a> +</span><span id="L-5719"><a href="#L-5719"><span class="linenos">5719</span></a><span class="sd"> Examples:</span> +</span><span id="L-5720"><a href="#L-5720"><span class="linenos">5720</span></a><span class="sd"> >>> from sqlglot import exp, parse_one</span> +</span><span id="L-5721"><a href="#L-5721"><span class="linenos">5721</span></a><span class="sd"> >>> replace_tables(parse_one("select * from a.b"), {"a.b": "c"}).sql()</span> +</span><span id="L-5722"><a href="#L-5722"><span class="linenos">5722</span></a><span class="sd"> 'SELECT * FROM c'</span> +</span><span id="L-5723"><a href="#L-5723"><span class="linenos">5723</span></a> +</span><span id="L-5724"><a href="#L-5724"><span class="linenos">5724</span></a><span class="sd"> Returns:</span> +</span><span id="L-5725"><a href="#L-5725"><span class="linenos">5725</span></a><span class="sd"> The mapped expression.</span> +</span><span id="L-5726"><a href="#L-5726"><span class="linenos">5726</span></a><span class="sd"> """</span> </span><span id="L-5727"><a href="#L-5727"><span class="linenos">5727</span></a> -</span><span id="L-5728"><a href="#L-5728"><span class="linenos">5728</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_replace_tables</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> -</span><span id="L-5729"><a href="#L-5729"><span class="linenos">5729</span></a> -</span><span id="L-5730"><a href="#L-5730"><span class="linenos">5730</span></a> -</span><span id="L-5731"><a href="#L-5731"><span class="linenos">5731</span></a><span class="k">def</span> <span class="nf">replace_placeholders</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> -</span><span id="L-5732"><a href="#L-5732"><span class="linenos">5732</span></a><span class="w"> </span><span class="sd">"""Replace placeholders in an expression.</span> -</span><span id="L-5733"><a href="#L-5733"><span class="linenos">5733</span></a> -</span><span id="L-5734"><a href="#L-5734"><span class="linenos">5734</span></a><span class="sd"> Args:</span> -</span><span id="L-5735"><a href="#L-5735"><span class="linenos">5735</span></a><span class="sd"> expression: expression node to be transformed and replaced.</span> -</span><span id="L-5736"><a href="#L-5736"><span class="linenos">5736</span></a><span class="sd"> args: positional names that will substitute unnamed placeholders in the given order.</span> -</span><span id="L-5737"><a href="#L-5737"><span class="linenos">5737</span></a><span class="sd"> kwargs: keyword arguments that will substitute named placeholders.</span> -</span><span id="L-5738"><a href="#L-5738"><span class="linenos">5738</span></a> -</span><span id="L-5739"><a href="#L-5739"><span class="linenos">5739</span></a><span class="sd"> Examples:</span> -</span><span id="L-5740"><a href="#L-5740"><span class="linenos">5740</span></a><span class="sd"> >>> from sqlglot import exp, parse_one</span> -</span><span id="L-5741"><a href="#L-5741"><span class="linenos">5741</span></a><span class="sd"> >>> replace_placeholders(</span> -</span><span id="L-5742"><a href="#L-5742"><span class="linenos">5742</span></a><span class="sd"> ... parse_one("select * from :tbl where ? = ?"),</span> -</span><span id="L-5743"><a href="#L-5743"><span class="linenos">5743</span></a><span class="sd"> ... exp.to_identifier("str_col"), "b", tbl=exp.to_identifier("foo")</span> -</span><span id="L-5744"><a href="#L-5744"><span class="linenos">5744</span></a><span class="sd"> ... ).sql()</span> -</span><span id="L-5745"><a href="#L-5745"><span class="linenos">5745</span></a><span class="sd"> "SELECT * FROM foo WHERE str_col = 'b'"</span> -</span><span id="L-5746"><a href="#L-5746"><span class="linenos">5746</span></a> -</span><span id="L-5747"><a href="#L-5747"><span class="linenos">5747</span></a><span class="sd"> Returns:</span> -</span><span id="L-5748"><a href="#L-5748"><span class="linenos">5748</span></a><span class="sd"> The mapped expression.</span> -</span><span id="L-5749"><a href="#L-5749"><span class="linenos">5749</span></a><span class="sd"> """</span> -</span><span id="L-5750"><a href="#L-5750"><span class="linenos">5750</span></a> -</span><span id="L-5751"><a href="#L-5751"><span class="linenos">5751</span></a> <span class="k">def</span> <span class="nf">_replace_placeholders</span><span class="p">(</span><span class="n">node</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> -</span><span id="L-5752"><a href="#L-5752"><span class="linenos">5752</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">Placeholder</span><span class="p">):</span> -</span><span id="L-5753"><a href="#L-5753"><span class="linenos">5753</span></a> <span class="k">if</span> <span class="n">node</span><span class="o">.</span><span class="n">name</span><span class="p">:</span> -</span><span id="L-5754"><a href="#L-5754"><span class="linenos">5754</span></a> <span class="n">new_name</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> -</span><span id="L-5755"><a href="#L-5755"><span class="linenos">5755</span></a> <span class="k">if</span> <span class="n">new_name</span><span class="p">:</span> -</span><span id="L-5756"><a href="#L-5756"><span class="linenos">5756</span></a> <span class="k">return</span> <span class="n">convert</span><span class="p">(</span><span class="n">new_name</span><span class="p">)</span> -</span><span id="L-5757"><a href="#L-5757"><span class="linenos">5757</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-5758"><a href="#L-5758"><span class="linenos">5758</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="L-5759"><a href="#L-5759"><span class="linenos">5759</span></a> <span class="k">return</span> <span class="n">convert</span><span class="p">(</span><span class="nb">next</span><span class="p">(</span><span class="n">args</span><span class="p">))</span> -</span><span id="L-5760"><a href="#L-5760"><span class="linenos">5760</span></a> <span class="k">except</span> <span class="ne">StopIteration</span><span class="p">:</span> -</span><span id="L-5761"><a href="#L-5761"><span class="linenos">5761</span></a> <span class="k">pass</span> -</span><span id="L-5762"><a href="#L-5762"><span class="linenos">5762</span></a> <span class="k">return</span> <span class="n">node</span> -</span><span id="L-5763"><a href="#L-5763"><span class="linenos">5763</span></a> -</span><span id="L-5764"><a href="#L-5764"><span class="linenos">5764</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_replace_placeholders</span><span class="p">,</span> <span class="nb">iter</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="L-5765"><a href="#L-5765"><span class="linenos">5765</span></a> -</span><span id="L-5766"><a href="#L-5766"><span class="linenos">5766</span></a> -</span><span id="L-5767"><a href="#L-5767"><span class="linenos">5767</span></a><span class="k">def</span> <span class="nf">expand</span><span class="p">(</span> -</span><span id="L-5768"><a href="#L-5768"><span class="linenos">5768</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="n">sources</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Subqueryable</span><span class="p">],</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-5769"><a href="#L-5769"><span class="linenos">5769</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> -</span><span id="L-5770"><a href="#L-5770"><span class="linenos">5770</span></a><span class="w"> </span><span class="sd">"""Transforms an expression by expanding all referenced sources into subqueries.</span> -</span><span id="L-5771"><a href="#L-5771"><span class="linenos">5771</span></a> -</span><span id="L-5772"><a href="#L-5772"><span class="linenos">5772</span></a><span class="sd"> Examples:</span> -</span><span id="L-5773"><a href="#L-5773"><span class="linenos">5773</span></a><span class="sd"> >>> from sqlglot import parse_one</span> -</span><span id="L-5774"><a href="#L-5774"><span class="linenos">5774</span></a><span class="sd"> >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y")}).sql()</span> -</span><span id="L-5775"><a href="#L-5775"><span class="linenos">5775</span></a><span class="sd"> 'SELECT * FROM (SELECT * FROM y) AS z /* source: x */'</span> +</span><span id="L-5728"><a href="#L-5728"><span class="linenos">5728</span></a> <span class="k">def</span> <span class="nf">_replace_tables</span><span class="p">(</span><span class="n">node</span><span class="p">:</span> <span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> +</span><span id="L-5729"><a href="#L-5729"><span class="linenos">5729</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">Table</span><span class="p">):</span> +</span><span id="L-5730"><a href="#L-5730"><span class="linenos">5730</span></a> <span class="n">new_name</span> <span class="o">=</span> <span class="n">mapping</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table_name</span><span class="p">(</span><span class="n">node</span><span class="p">))</span> +</span><span id="L-5731"><a href="#L-5731"><span class="linenos">5731</span></a> <span class="k">if</span> <span class="n">new_name</span><span class="p">:</span> +</span><span id="L-5732"><a href="#L-5732"><span class="linenos">5732</span></a> <span class="k">return</span> <span class="n">to_table</span><span class="p">(</span> +</span><span id="L-5733"><a href="#L-5733"><span class="linenos">5733</span></a> <span class="n">new_name</span><span class="p">,</span> +</span><span id="L-5734"><a href="#L-5734"><span class="linenos">5734</span></a> <span class="o">**</span><span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="n">v</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">node</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="k">if</span> <span class="n">k</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="s2">"db"</span><span class="p">,</span> <span class="s2">"catalog"</span><span class="p">)},</span> +</span><span id="L-5735"><a href="#L-5735"><span class="linenos">5735</span></a> <span class="p">)</span> +</span><span id="L-5736"><a href="#L-5736"><span class="linenos">5736</span></a> <span class="k">return</span> <span class="n">node</span> +</span><span id="L-5737"><a href="#L-5737"><span class="linenos">5737</span></a> +</span><span id="L-5738"><a href="#L-5738"><span class="linenos">5738</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_replace_tables</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> +</span><span id="L-5739"><a href="#L-5739"><span class="linenos">5739</span></a> +</span><span id="L-5740"><a href="#L-5740"><span class="linenos">5740</span></a> +</span><span id="L-5741"><a href="#L-5741"><span class="linenos">5741</span></a><span class="k">def</span> <span class="nf">replace_placeholders</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> +</span><span id="L-5742"><a href="#L-5742"><span class="linenos">5742</span></a><span class="w"> </span><span class="sd">"""Replace placeholders in an expression.</span> +</span><span id="L-5743"><a href="#L-5743"><span class="linenos">5743</span></a> +</span><span id="L-5744"><a href="#L-5744"><span class="linenos">5744</span></a><span class="sd"> Args:</span> +</span><span id="L-5745"><a href="#L-5745"><span class="linenos">5745</span></a><span class="sd"> expression: expression node to be transformed and replaced.</span> +</span><span id="L-5746"><a href="#L-5746"><span class="linenos">5746</span></a><span class="sd"> args: positional names that will substitute unnamed placeholders in the given order.</span> +</span><span id="L-5747"><a href="#L-5747"><span class="linenos">5747</span></a><span class="sd"> kwargs: keyword arguments that will substitute named placeholders.</span> +</span><span id="L-5748"><a href="#L-5748"><span class="linenos">5748</span></a> +</span><span id="L-5749"><a href="#L-5749"><span class="linenos">5749</span></a><span class="sd"> Examples:</span> +</span><span id="L-5750"><a href="#L-5750"><span class="linenos">5750</span></a><span class="sd"> >>> from sqlglot import exp, parse_one</span> +</span><span id="L-5751"><a href="#L-5751"><span class="linenos">5751</span></a><span class="sd"> >>> replace_placeholders(</span> +</span><span id="L-5752"><a href="#L-5752"><span class="linenos">5752</span></a><span class="sd"> ... parse_one("select * from :tbl where ? = ?"),</span> +</span><span id="L-5753"><a href="#L-5753"><span class="linenos">5753</span></a><span class="sd"> ... exp.to_identifier("str_col"), "b", tbl=exp.to_identifier("foo")</span> +</span><span id="L-5754"><a href="#L-5754"><span class="linenos">5754</span></a><span class="sd"> ... ).sql()</span> +</span><span id="L-5755"><a href="#L-5755"><span class="linenos">5755</span></a><span class="sd"> "SELECT * FROM foo WHERE str_col = 'b'"</span> +</span><span id="L-5756"><a href="#L-5756"><span class="linenos">5756</span></a> +</span><span id="L-5757"><a href="#L-5757"><span class="linenos">5757</span></a><span class="sd"> Returns:</span> +</span><span id="L-5758"><a href="#L-5758"><span class="linenos">5758</span></a><span class="sd"> The mapped expression.</span> +</span><span id="L-5759"><a href="#L-5759"><span class="linenos">5759</span></a><span class="sd"> """</span> +</span><span id="L-5760"><a href="#L-5760"><span class="linenos">5760</span></a> +</span><span id="L-5761"><a href="#L-5761"><span class="linenos">5761</span></a> <span class="k">def</span> <span class="nf">_replace_placeholders</span><span class="p">(</span><span class="n">node</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> +</span><span id="L-5762"><a href="#L-5762"><span class="linenos">5762</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">Placeholder</span><span class="p">):</span> +</span><span id="L-5763"><a href="#L-5763"><span class="linenos">5763</span></a> <span class="k">if</span> <span class="n">node</span><span class="o">.</span><span class="n">name</span><span class="p">:</span> +</span><span id="L-5764"><a href="#L-5764"><span class="linenos">5764</span></a> <span class="n">new_name</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> +</span><span id="L-5765"><a href="#L-5765"><span class="linenos">5765</span></a> <span class="k">if</span> <span class="n">new_name</span><span class="p">:</span> +</span><span id="L-5766"><a href="#L-5766"><span class="linenos">5766</span></a> <span class="k">return</span> <span class="n">convert</span><span class="p">(</span><span class="n">new_name</span><span class="p">)</span> +</span><span id="L-5767"><a href="#L-5767"><span class="linenos">5767</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-5768"><a href="#L-5768"><span class="linenos">5768</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="L-5769"><a href="#L-5769"><span class="linenos">5769</span></a> <span class="k">return</span> <span class="n">convert</span><span class="p">(</span><span class="nb">next</span><span class="p">(</span><span class="n">args</span><span class="p">))</span> +</span><span id="L-5770"><a href="#L-5770"><span class="linenos">5770</span></a> <span class="k">except</span> <span class="ne">StopIteration</span><span class="p">:</span> +</span><span id="L-5771"><a href="#L-5771"><span class="linenos">5771</span></a> <span class="k">pass</span> +</span><span id="L-5772"><a href="#L-5772"><span class="linenos">5772</span></a> <span class="k">return</span> <span class="n">node</span> +</span><span id="L-5773"><a href="#L-5773"><span class="linenos">5773</span></a> +</span><span id="L-5774"><a href="#L-5774"><span class="linenos">5774</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_replace_placeholders</span><span class="p">,</span> <span class="nb">iter</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="L-5775"><a href="#L-5775"><span class="linenos">5775</span></a> </span><span id="L-5776"><a href="#L-5776"><span class="linenos">5776</span></a> -</span><span id="L-5777"><a href="#L-5777"><span class="linenos">5777</span></a><span class="sd"> >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y"), "y": parse_one("select * from z")}).sql()</span> -</span><span id="L-5778"><a href="#L-5778"><span class="linenos">5778</span></a><span class="sd"> 'SELECT * FROM (SELECT * FROM (SELECT * FROM z) AS y /* source: y */) AS z /* source: x */'</span> -</span><span id="L-5779"><a href="#L-5779"><span class="linenos">5779</span></a> -</span><span id="L-5780"><a href="#L-5780"><span class="linenos">5780</span></a><span class="sd"> Args:</span> -</span><span id="L-5781"><a href="#L-5781"><span class="linenos">5781</span></a><span class="sd"> expression: The expression to expand.</span> -</span><span id="L-5782"><a href="#L-5782"><span class="linenos">5782</span></a><span class="sd"> sources: A dictionary of name to Subqueryables.</span> -</span><span id="L-5783"><a href="#L-5783"><span class="linenos">5783</span></a><span class="sd"> copy: Whether or not to copy the expression during transformation. Defaults to True.</span> -</span><span id="L-5784"><a href="#L-5784"><span class="linenos">5784</span></a> -</span><span id="L-5785"><a href="#L-5785"><span class="linenos">5785</span></a><span class="sd"> Returns:</span> -</span><span id="L-5786"><a href="#L-5786"><span class="linenos">5786</span></a><span class="sd"> The transformed expression.</span> -</span><span id="L-5787"><a href="#L-5787"><span class="linenos">5787</span></a><span class="sd"> """</span> -</span><span id="L-5788"><a href="#L-5788"><span class="linenos">5788</span></a> -</span><span id="L-5789"><a href="#L-5789"><span class="linenos">5789</span></a> <span class="k">def</span> <span class="nf">_expand</span><span class="p">(</span><span class="n">node</span><span class="p">:</span> <span class="n">Expression</span><span class="p">):</span> -</span><span id="L-5790"><a href="#L-5790"><span class="linenos">5790</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">Table</span><span class="p">):</span> -</span><span id="L-5791"><a href="#L-5791"><span class="linenos">5791</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">table_name</span><span class="p">(</span><span class="n">node</span><span class="p">)</span> -</span><span id="L-5792"><a href="#L-5792"><span class="linenos">5792</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">sources</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> -</span><span id="L-5793"><a href="#L-5793"><span class="linenos">5793</span></a> <span class="k">if</span> <span class="n">source</span><span class="p">:</span> -</span><span id="L-5794"><a href="#L-5794"><span class="linenos">5794</span></a> <span class="n">subquery</span> <span class="o">=</span> <span class="n">source</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">alias</span> <span class="ow">or</span> <span class="n">name</span><span class="p">)</span> -</span><span id="L-5795"><a href="#L-5795"><span class="linenos">5795</span></a> <span class="n">subquery</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="p">[</span><span class="sa">f</span><span class="s2">"source: </span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span><span class="p">]</span> -</span><span id="L-5796"><a href="#L-5796"><span class="linenos">5796</span></a> <span class="k">return</span> <span class="n">subquery</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_expand</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-5797"><a href="#L-5797"><span class="linenos">5797</span></a> <span class="k">return</span> <span class="n">node</span> +</span><span id="L-5777"><a href="#L-5777"><span class="linenos">5777</span></a><span class="k">def</span> <span class="nf">expand</span><span class="p">(</span> +</span><span id="L-5778"><a href="#L-5778"><span class="linenos">5778</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="n">sources</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Subqueryable</span><span class="p">],</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-5779"><a href="#L-5779"><span class="linenos">5779</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> +</span><span id="L-5780"><a href="#L-5780"><span class="linenos">5780</span></a><span class="w"> </span><span class="sd">"""Transforms an expression by expanding all referenced sources into subqueries.</span> +</span><span id="L-5781"><a href="#L-5781"><span class="linenos">5781</span></a> +</span><span id="L-5782"><a href="#L-5782"><span class="linenos">5782</span></a><span class="sd"> Examples:</span> +</span><span id="L-5783"><a href="#L-5783"><span class="linenos">5783</span></a><span class="sd"> >>> from sqlglot import parse_one</span> +</span><span id="L-5784"><a href="#L-5784"><span class="linenos">5784</span></a><span class="sd"> >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y")}).sql()</span> +</span><span id="L-5785"><a href="#L-5785"><span class="linenos">5785</span></a><span class="sd"> 'SELECT * FROM (SELECT * FROM y) AS z /* source: x */'</span> +</span><span id="L-5786"><a href="#L-5786"><span class="linenos">5786</span></a> +</span><span id="L-5787"><a href="#L-5787"><span class="linenos">5787</span></a><span class="sd"> >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y"), "y": parse_one("select * from z")}).sql()</span> +</span><span id="L-5788"><a href="#L-5788"><span class="linenos">5788</span></a><span class="sd"> 'SELECT * FROM (SELECT * FROM (SELECT * FROM z) AS y /* source: y */) AS z /* source: x */'</span> +</span><span id="L-5789"><a href="#L-5789"><span class="linenos">5789</span></a> +</span><span id="L-5790"><a href="#L-5790"><span class="linenos">5790</span></a><span class="sd"> Args:</span> +</span><span id="L-5791"><a href="#L-5791"><span class="linenos">5791</span></a><span class="sd"> expression: The expression to expand.</span> +</span><span id="L-5792"><a href="#L-5792"><span class="linenos">5792</span></a><span class="sd"> sources: A dictionary of name to Subqueryables.</span> +</span><span id="L-5793"><a href="#L-5793"><span class="linenos">5793</span></a><span class="sd"> copy: Whether or not to copy the expression during transformation. Defaults to True.</span> +</span><span id="L-5794"><a href="#L-5794"><span class="linenos">5794</span></a> +</span><span id="L-5795"><a href="#L-5795"><span class="linenos">5795</span></a><span class="sd"> Returns:</span> +</span><span id="L-5796"><a href="#L-5796"><span class="linenos">5796</span></a><span class="sd"> The transformed expression.</span> +</span><span id="L-5797"><a href="#L-5797"><span class="linenos">5797</span></a><span class="sd"> """</span> </span><span id="L-5798"><a href="#L-5798"><span class="linenos">5798</span></a> -</span><span id="L-5799"><a href="#L-5799"><span class="linenos">5799</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_expand</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> -</span><span id="L-5800"><a href="#L-5800"><span class="linenos">5800</span></a> -</span><span id="L-5801"><a href="#L-5801"><span class="linenos">5801</span></a> -</span><span id="L-5802"><a href="#L-5802"><span class="linenos">5802</span></a><span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Func</span><span class="p">:</span> -</span><span id="L-5803"><a href="#L-5803"><span class="linenos">5803</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-5804"><a href="#L-5804"><span class="linenos">5804</span></a><span class="sd"> Returns a Func expression.</span> -</span><span id="L-5805"><a href="#L-5805"><span class="linenos">5805</span></a> -</span><span id="L-5806"><a href="#L-5806"><span class="linenos">5806</span></a><span class="sd"> Examples:</span> -</span><span id="L-5807"><a href="#L-5807"><span class="linenos">5807</span></a><span class="sd"> >>> func("abs", 5).sql()</span> -</span><span id="L-5808"><a href="#L-5808"><span class="linenos">5808</span></a><span class="sd"> 'ABS(5)'</span> -</span><span id="L-5809"><a href="#L-5809"><span class="linenos">5809</span></a> -</span><span id="L-5810"><a href="#L-5810"><span class="linenos">5810</span></a><span class="sd"> >>> func("cast", this=5, to=DataType.build("DOUBLE")).sql()</span> -</span><span id="L-5811"><a href="#L-5811"><span class="linenos">5811</span></a><span class="sd"> 'CAST(5 AS DOUBLE)'</span> -</span><span id="L-5812"><a href="#L-5812"><span class="linenos">5812</span></a> -</span><span id="L-5813"><a href="#L-5813"><span class="linenos">5813</span></a><span class="sd"> Args:</span> -</span><span id="L-5814"><a href="#L-5814"><span class="linenos">5814</span></a><span class="sd"> name: the name of the function to build.</span> -</span><span id="L-5815"><a href="#L-5815"><span class="linenos">5815</span></a><span class="sd"> args: the args used to instantiate the function of interest.</span> -</span><span id="L-5816"><a href="#L-5816"><span class="linenos">5816</span></a><span class="sd"> dialect: the source dialect.</span> -</span><span id="L-5817"><a href="#L-5817"><span class="linenos">5817</span></a><span class="sd"> kwargs: the kwargs used to instantiate the function of interest.</span> -</span><span id="L-5818"><a href="#L-5818"><span class="linenos">5818</span></a> -</span><span id="L-5819"><a href="#L-5819"><span class="linenos">5819</span></a><span class="sd"> Note:</span> -</span><span id="L-5820"><a href="#L-5820"><span class="linenos">5820</span></a><span class="sd"> The arguments `args` and `kwargs` are mutually exclusive.</span> -</span><span id="L-5821"><a href="#L-5821"><span class="linenos">5821</span></a> -</span><span id="L-5822"><a href="#L-5822"><span class="linenos">5822</span></a><span class="sd"> Returns:</span> -</span><span id="L-5823"><a href="#L-5823"><span class="linenos">5823</span></a><span class="sd"> An instance of the function of interest, or an anonymous function, if `name` doesn't</span> -</span><span id="L-5824"><a href="#L-5824"><span class="linenos">5824</span></a><span class="sd"> correspond to an existing `sqlglot.expressions.Func` class.</span> -</span><span id="L-5825"><a href="#L-5825"><span class="linenos">5825</span></a><span class="sd"> """</span> -</span><span id="L-5826"><a href="#L-5826"><span class="linenos">5826</span></a> <span class="k">if</span> <span class="n">args</span> <span class="ow">and</span> <span class="n">kwargs</span><span class="p">:</span> -</span><span id="L-5827"><a href="#L-5827"><span class="linenos">5827</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Can't use both args and kwargs to instantiate a function."</span><span class="p">)</span> +</span><span id="L-5799"><a href="#L-5799"><span class="linenos">5799</span></a> <span class="k">def</span> <span class="nf">_expand</span><span class="p">(</span><span class="n">node</span><span class="p">:</span> <span class="n">Expression</span><span class="p">):</span> +</span><span id="L-5800"><a href="#L-5800"><span class="linenos">5800</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">Table</span><span class="p">):</span> +</span><span id="L-5801"><a href="#L-5801"><span class="linenos">5801</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">table_name</span><span class="p">(</span><span class="n">node</span><span class="p">)</span> +</span><span id="L-5802"><a href="#L-5802"><span class="linenos">5802</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">sources</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> +</span><span id="L-5803"><a href="#L-5803"><span class="linenos">5803</span></a> <span class="k">if</span> <span class="n">source</span><span class="p">:</span> +</span><span id="L-5804"><a href="#L-5804"><span class="linenos">5804</span></a> <span class="n">subquery</span> <span class="o">=</span> <span class="n">source</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">alias</span> <span class="ow">or</span> <span class="n">name</span><span class="p">)</span> +</span><span id="L-5805"><a href="#L-5805"><span class="linenos">5805</span></a> <span class="n">subquery</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="p">[</span><span class="sa">f</span><span class="s2">"source: </span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span><span class="p">]</span> +</span><span id="L-5806"><a href="#L-5806"><span class="linenos">5806</span></a> <span class="k">return</span> <span class="n">subquery</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_expand</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-5807"><a href="#L-5807"><span class="linenos">5807</span></a> <span class="k">return</span> <span class="n">node</span> +</span><span id="L-5808"><a href="#L-5808"><span class="linenos">5808</span></a> +</span><span id="L-5809"><a href="#L-5809"><span class="linenos">5809</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_expand</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> +</span><span id="L-5810"><a href="#L-5810"><span class="linenos">5810</span></a> +</span><span id="L-5811"><a href="#L-5811"><span class="linenos">5811</span></a> +</span><span id="L-5812"><a href="#L-5812"><span class="linenos">5812</span></a><span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Func</span><span class="p">:</span> +</span><span id="L-5813"><a href="#L-5813"><span class="linenos">5813</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-5814"><a href="#L-5814"><span class="linenos">5814</span></a><span class="sd"> Returns a Func expression.</span> +</span><span id="L-5815"><a href="#L-5815"><span class="linenos">5815</span></a> +</span><span id="L-5816"><a href="#L-5816"><span class="linenos">5816</span></a><span class="sd"> Examples:</span> +</span><span id="L-5817"><a href="#L-5817"><span class="linenos">5817</span></a><span class="sd"> >>> func("abs", 5).sql()</span> +</span><span id="L-5818"><a href="#L-5818"><span class="linenos">5818</span></a><span class="sd"> 'ABS(5)'</span> +</span><span id="L-5819"><a href="#L-5819"><span class="linenos">5819</span></a> +</span><span id="L-5820"><a href="#L-5820"><span class="linenos">5820</span></a><span class="sd"> >>> func("cast", this=5, to=DataType.build("DOUBLE")).sql()</span> +</span><span id="L-5821"><a href="#L-5821"><span class="linenos">5821</span></a><span class="sd"> 'CAST(5 AS DOUBLE)'</span> +</span><span id="L-5822"><a href="#L-5822"><span class="linenos">5822</span></a> +</span><span id="L-5823"><a href="#L-5823"><span class="linenos">5823</span></a><span class="sd"> Args:</span> +</span><span id="L-5824"><a href="#L-5824"><span class="linenos">5824</span></a><span class="sd"> name: the name of the function to build.</span> +</span><span id="L-5825"><a href="#L-5825"><span class="linenos">5825</span></a><span class="sd"> args: the args used to instantiate the function of interest.</span> +</span><span id="L-5826"><a href="#L-5826"><span class="linenos">5826</span></a><span class="sd"> dialect: the source dialect.</span> +</span><span id="L-5827"><a href="#L-5827"><span class="linenos">5827</span></a><span class="sd"> kwargs: the kwargs used to instantiate the function of interest.</span> </span><span id="L-5828"><a href="#L-5828"><span class="linenos">5828</span></a> -</span><span id="L-5829"><a href="#L-5829"><span class="linenos">5829</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dialects.dialect</span> <span class="kn">import</span> <span class="n">Dialect</span> -</span><span id="L-5830"><a href="#L-5830"><span class="linenos">5830</span></a> -</span><span id="L-5831"><a href="#L-5831"><span class="linenos">5831</span></a> <span class="n">converted</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">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">]</span> -</span><span id="L-5832"><a href="#L-5832"><span class="linenos">5832</span></a> <span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span><span class="n">key</span><span class="p">:</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span> -</span><span id="L-5833"><a href="#L-5833"><span class="linenos">5833</span></a> -</span><span id="L-5834"><a href="#L-5834"><span class="linenos">5834</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)()</span><span class="o">.</span><span class="n">parser</span><span class="p">()</span> -</span><span id="L-5835"><a href="#L-5835"><span class="linenos">5835</span></a> <span class="n">from_args_list</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span> -</span><span id="L-5836"><a href="#L-5836"><span class="linenos">5836</span></a> -</span><span id="L-5837"><a href="#L-5837"><span class="linenos">5837</span></a> <span class="k">if</span> <span class="n">from_args_list</span><span class="p">:</span> -</span><span id="L-5838"><a href="#L-5838"><span class="linenos">5838</span></a> <span class="n">function</span> <span class="o">=</span> <span class="n">from_args_list</span><span class="p">(</span><span class="n">converted</span><span class="p">)</span> <span class="k">if</span> <span class="n">converted</span> <span class="k">else</span> <span class="n">from_args_list</span><span class="o">.</span><span class="vm">__self__</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="L-5839"><a href="#L-5839"><span class="linenos">5839</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-5840"><a href="#L-5840"><span class="linenos">5840</span></a> <span class="n">kwargs</span> <span class="o">=</span> <span class="n">kwargs</span> <span class="ow">or</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="n">converted</span><span class="p">}</span> -</span><span id="L-5841"><a href="#L-5841"><span class="linenos">5841</span></a> <span class="n">function</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="n">name</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="L-5842"><a href="#L-5842"><span class="linenos">5842</span></a> -</span><span id="L-5843"><a href="#L-5843"><span class="linenos">5843</span></a> <span class="k">for</span> <span class="n">error_message</span> <span class="ow">in</span> <span class="n">function</span><span class="o">.</span><span class="n">error_messages</span><span class="p">(</span><span class="n">converted</span><span class="p">):</span> -</span><span id="L-5844"><a href="#L-5844"><span class="linenos">5844</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">error_message</span><span class="p">)</span> -</span><span id="L-5845"><a href="#L-5845"><span class="linenos">5845</span></a> -</span><span id="L-5846"><a href="#L-5846"><span class="linenos">5846</span></a> <span class="k">return</span> <span class="n">function</span> -</span><span id="L-5847"><a href="#L-5847"><span class="linenos">5847</span></a> -</span><span id="L-5848"><a href="#L-5848"><span class="linenos">5848</span></a> -</span><span id="L-5849"><a href="#L-5849"><span class="linenos">5849</span></a><span class="k">def</span> <span class="nf">true</span><span class="p">()</span> <span class="o">-></span> <span class="n">Boolean</span><span class="p">:</span> -</span><span id="L-5850"><a href="#L-5850"><span class="linenos">5850</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-5851"><a href="#L-5851"><span class="linenos">5851</span></a><span class="sd"> Returns a true Boolean expression.</span> -</span><span id="L-5852"><a href="#L-5852"><span class="linenos">5852</span></a><span class="sd"> """</span> -</span><span id="L-5853"><a href="#L-5853"><span class="linenos">5853</span></a> <span class="k">return</span> <span class="n">Boolean</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-5854"><a href="#L-5854"><span class="linenos">5854</span></a> +</span><span id="L-5829"><a href="#L-5829"><span class="linenos">5829</span></a><span class="sd"> Note:</span> +</span><span id="L-5830"><a href="#L-5830"><span class="linenos">5830</span></a><span class="sd"> The arguments `args` and `kwargs` are mutually exclusive.</span> +</span><span id="L-5831"><a href="#L-5831"><span class="linenos">5831</span></a> +</span><span id="L-5832"><a href="#L-5832"><span class="linenos">5832</span></a><span class="sd"> Returns:</span> +</span><span id="L-5833"><a href="#L-5833"><span class="linenos">5833</span></a><span class="sd"> An instance of the function of interest, or an anonymous function, if `name` doesn't</span> +</span><span id="L-5834"><a href="#L-5834"><span class="linenos">5834</span></a><span class="sd"> correspond to an existing `sqlglot.expressions.Func` class.</span> +</span><span id="L-5835"><a href="#L-5835"><span class="linenos">5835</span></a><span class="sd"> """</span> +</span><span id="L-5836"><a href="#L-5836"><span class="linenos">5836</span></a> <span class="k">if</span> <span class="n">args</span> <span class="ow">and</span> <span class="n">kwargs</span><span class="p">:</span> +</span><span id="L-5837"><a href="#L-5837"><span class="linenos">5837</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Can't use both args and kwargs to instantiate a function."</span><span class="p">)</span> +</span><span id="L-5838"><a href="#L-5838"><span class="linenos">5838</span></a> +</span><span id="L-5839"><a href="#L-5839"><span class="linenos">5839</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dialects.dialect</span> <span class="kn">import</span> <span class="n">Dialect</span> +</span><span id="L-5840"><a href="#L-5840"><span class="linenos">5840</span></a> +</span><span id="L-5841"><a href="#L-5841"><span class="linenos">5841</span></a> <span class="n">converted</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">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">]</span> +</span><span id="L-5842"><a href="#L-5842"><span class="linenos">5842</span></a> <span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span><span class="n">key</span><span class="p">:</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span> +</span><span id="L-5843"><a href="#L-5843"><span class="linenos">5843</span></a> +</span><span id="L-5844"><a href="#L-5844"><span class="linenos">5844</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)()</span><span class="o">.</span><span class="n">parser</span><span class="p">()</span> +</span><span id="L-5845"><a href="#L-5845"><span class="linenos">5845</span></a> <span class="n">from_args_list</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span> +</span><span id="L-5846"><a href="#L-5846"><span class="linenos">5846</span></a> +</span><span id="L-5847"><a href="#L-5847"><span class="linenos">5847</span></a> <span class="k">if</span> <span class="n">from_args_list</span><span class="p">:</span> +</span><span id="L-5848"><a href="#L-5848"><span class="linenos">5848</span></a> <span class="n">function</span> <span class="o">=</span> <span class="n">from_args_list</span><span class="p">(</span><span class="n">converted</span><span class="p">)</span> <span class="k">if</span> <span class="n">converted</span> <span class="k">else</span> <span class="n">from_args_list</span><span class="o">.</span><span class="vm">__self__</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="L-5849"><a href="#L-5849"><span class="linenos">5849</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-5850"><a href="#L-5850"><span class="linenos">5850</span></a> <span class="n">kwargs</span> <span class="o">=</span> <span class="n">kwargs</span> <span class="ow">or</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="n">converted</span><span class="p">}</span> +</span><span id="L-5851"><a href="#L-5851"><span class="linenos">5851</span></a> <span class="n">function</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="n">name</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="L-5852"><a href="#L-5852"><span class="linenos">5852</span></a> +</span><span id="L-5853"><a href="#L-5853"><span class="linenos">5853</span></a> <span class="k">for</span> <span class="n">error_message</span> <span class="ow">in</span> <span class="n">function</span><span class="o">.</span><span class="n">error_messages</span><span class="p">(</span><span class="n">converted</span><span class="p">):</span> +</span><span id="L-5854"><a href="#L-5854"><span class="linenos">5854</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">error_message</span><span class="p">)</span> </span><span id="L-5855"><a href="#L-5855"><span class="linenos">5855</span></a> -</span><span id="L-5856"><a href="#L-5856"><span class="linenos">5856</span></a><span class="k">def</span> <span class="nf">false</span><span class="p">()</span> <span class="o">-></span> <span class="n">Boolean</span><span class="p">:</span> -</span><span id="L-5857"><a href="#L-5857"><span class="linenos">5857</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-5858"><a href="#L-5858"><span class="linenos">5858</span></a><span class="sd"> Returns a false Boolean expression.</span> -</span><span id="L-5859"><a href="#L-5859"><span class="linenos">5859</span></a><span class="sd"> """</span> -</span><span id="L-5860"><a href="#L-5860"><span class="linenos">5860</span></a> <span class="k">return</span> <span class="n">Boolean</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-5861"><a href="#L-5861"><span class="linenos">5861</span></a> -</span><span id="L-5862"><a href="#L-5862"><span class="linenos">5862</span></a> -</span><span id="L-5863"><a href="#L-5863"><span class="linenos">5863</span></a><span class="k">def</span> <span class="nf">null</span><span class="p">()</span> <span class="o">-></span> <span class="n">Null</span><span class="p">:</span> -</span><span id="L-5864"><a href="#L-5864"><span class="linenos">5864</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-5865"><a href="#L-5865"><span class="linenos">5865</span></a><span class="sd"> Returns a Null expression.</span> -</span><span id="L-5866"><a href="#L-5866"><span class="linenos">5866</span></a><span class="sd"> """</span> -</span><span id="L-5867"><a href="#L-5867"><span class="linenos">5867</span></a> <span class="k">return</span> <span class="n">Null</span><span class="p">()</span> -</span><span id="L-5868"><a href="#L-5868"><span class="linenos">5868</span></a> -</span><span id="L-5869"><a href="#L-5869"><span class="linenos">5869</span></a> -</span><span id="L-5870"><a href="#L-5870"><span class="linenos">5870</span></a><span class="c1"># TODO: deprecate this</span> -</span><span id="L-5871"><a href="#L-5871"><span class="linenos">5871</span></a><span class="n">TRUE</span> <span class="o">=</span> <span class="n">Boolean</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-5872"><a href="#L-5872"><span class="linenos">5872</span></a><span class="n">FALSE</span> <span class="o">=</span> <span class="n">Boolean</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-5873"><a href="#L-5873"><span class="linenos">5873</span></a><span class="n">NULL</span> <span class="o">=</span> <span class="n">Null</span><span class="p">()</span> +</span><span id="L-5856"><a href="#L-5856"><span class="linenos">5856</span></a> <span class="k">return</span> <span class="n">function</span> +</span><span id="L-5857"><a href="#L-5857"><span class="linenos">5857</span></a> +</span><span id="L-5858"><a href="#L-5858"><span class="linenos">5858</span></a> +</span><span id="L-5859"><a href="#L-5859"><span class="linenos">5859</span></a><span class="k">def</span> <span class="nf">true</span><span class="p">()</span> <span class="o">-></span> <span class="n">Boolean</span><span class="p">:</span> +</span><span id="L-5860"><a href="#L-5860"><span class="linenos">5860</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-5861"><a href="#L-5861"><span class="linenos">5861</span></a><span class="sd"> Returns a true Boolean expression.</span> +</span><span id="L-5862"><a href="#L-5862"><span class="linenos">5862</span></a><span class="sd"> """</span> +</span><span id="L-5863"><a href="#L-5863"><span class="linenos">5863</span></a> <span class="k">return</span> <span class="n">Boolean</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-5864"><a href="#L-5864"><span class="linenos">5864</span></a> +</span><span id="L-5865"><a href="#L-5865"><span class="linenos">5865</span></a> +</span><span id="L-5866"><a href="#L-5866"><span class="linenos">5866</span></a><span class="k">def</span> <span class="nf">false</span><span class="p">()</span> <span class="o">-></span> <span class="n">Boolean</span><span class="p">:</span> +</span><span id="L-5867"><a href="#L-5867"><span class="linenos">5867</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-5868"><a href="#L-5868"><span class="linenos">5868</span></a><span class="sd"> Returns a false Boolean expression.</span> +</span><span id="L-5869"><a href="#L-5869"><span class="linenos">5869</span></a><span class="sd"> """</span> +</span><span id="L-5870"><a href="#L-5870"><span class="linenos">5870</span></a> <span class="k">return</span> <span class="n">Boolean</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-5871"><a href="#L-5871"><span class="linenos">5871</span></a> +</span><span id="L-5872"><a href="#L-5872"><span class="linenos">5872</span></a> +</span><span id="L-5873"><a href="#L-5873"><span class="linenos">5873</span></a><span class="k">def</span> <span class="nf">null</span><span class="p">()</span> <span class="o">-></span> <span class="n">Null</span><span class="p">:</span> +</span><span id="L-5874"><a href="#L-5874"><span class="linenos">5874</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-5875"><a href="#L-5875"><span class="linenos">5875</span></a><span class="sd"> Returns a Null expression.</span> +</span><span id="L-5876"><a href="#L-5876"><span class="linenos">5876</span></a><span class="sd"> """</span> +</span><span id="L-5877"><a href="#L-5877"><span class="linenos">5877</span></a> <span class="k">return</span> <span class="n">Null</span><span class="p">()</span> +</span><span id="L-5878"><a href="#L-5878"><span class="linenos">5878</span></a> +</span><span id="L-5879"><a href="#L-5879"><span class="linenos">5879</span></a> +</span><span id="L-5880"><a href="#L-5880"><span class="linenos">5880</span></a><span class="c1"># TODO: deprecate this</span> +</span><span id="L-5881"><a href="#L-5881"><span class="linenos">5881</span></a><span class="n">TRUE</span> <span class="o">=</span> <span class="n">Boolean</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-5882"><a href="#L-5882"><span class="linenos">5882</span></a><span class="n">FALSE</span> <span class="o">=</span> <span class="n">Boolean</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-5883"><a href="#L-5883"><span class="linenos">5883</span></a><span class="n">NULL</span> <span class="o">=</span> <span class="n">Null</span><span class="p">()</span> </span></pre></div> @@ -19532,6 +19548,71 @@ Otherwise, this resets the expression.</li> </dl> </div> </section> + <section id="CopyGrantsProperty"> + <input id="CopyGrantsProperty-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr class"> + + <span class="def">class</span> + <span class="name">CopyGrantsProperty</span><wbr>(<span class="base"><a href="#Property">Property</a></span>): + + <label class="view-source-button" for="CopyGrantsProperty-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#CopyGrantsProperty"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="CopyGrantsProperty-1848"><a href="#CopyGrantsProperty-1848"><span class="linenos">1848</span></a><span class="k">class</span> <span class="nc">CopyGrantsProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="CopyGrantsProperty-1849"><a href="#CopyGrantsProperty-1849"><span class="linenos">1849</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{}</span> +</span></pre></div> + + + + + <div class="inherited"> + <h5>Inherited Members</h5> + <dl> + <div><dt><a href="#Expression">Expression</a></dt> + <dd id="CopyGrantsProperty.__init__" class="function"><a href="#Expression.__init__">Expression</a></dd> + <dd id="CopyGrantsProperty.this" class="variable"><a href="#Expression.this">this</a></dd> + <dd id="CopyGrantsProperty.expression" class="variable"><a href="#Expression.expression">expression</a></dd> + <dd id="CopyGrantsProperty.expressions" class="variable"><a href="#Expression.expressions">expressions</a></dd> + <dd id="CopyGrantsProperty.text" class="function"><a href="#Expression.text">text</a></dd> + <dd id="CopyGrantsProperty.is_string" class="variable"><a href="#Expression.is_string">is_string</a></dd> + <dd id="CopyGrantsProperty.is_number" class="variable"><a href="#Expression.is_number">is_number</a></dd> + <dd id="CopyGrantsProperty.is_int" class="variable"><a href="#Expression.is_int">is_int</a></dd> + <dd id="CopyGrantsProperty.is_star" class="variable"><a href="#Expression.is_star">is_star</a></dd> + <dd id="CopyGrantsProperty.alias" class="variable"><a href="#Expression.alias">alias</a></dd> + <dd id="CopyGrantsProperty.output_name" class="variable"><a href="#Expression.output_name">output_name</a></dd> + <dd id="CopyGrantsProperty.copy" class="function"><a href="#Expression.copy">copy</a></dd> + <dd id="CopyGrantsProperty.add_comments" class="function"><a href="#Expression.add_comments">add_comments</a></dd> + <dd id="CopyGrantsProperty.append" class="function"><a href="#Expression.append">append</a></dd> + <dd id="CopyGrantsProperty.set" class="function"><a href="#Expression.set">set</a></dd> + <dd id="CopyGrantsProperty.depth" class="variable"><a href="#Expression.depth">depth</a></dd> + <dd id="CopyGrantsProperty.iter_expressions" class="function"><a href="#Expression.iter_expressions">iter_expressions</a></dd> + <dd id="CopyGrantsProperty.find" class="function"><a href="#Expression.find">find</a></dd> + <dd id="CopyGrantsProperty.find_all" class="function"><a href="#Expression.find_all">find_all</a></dd> + <dd id="CopyGrantsProperty.find_ancestor" class="function"><a href="#Expression.find_ancestor">find_ancestor</a></dd> + <dd id="CopyGrantsProperty.parent_select" class="variable"><a href="#Expression.parent_select">parent_select</a></dd> + <dd id="CopyGrantsProperty.same_parent" class="variable"><a href="#Expression.same_parent">same_parent</a></dd> + <dd id="CopyGrantsProperty.root" class="function"><a href="#Expression.root">root</a></dd> + <dd id="CopyGrantsProperty.walk" class="function"><a href="#Expression.walk">walk</a></dd> + <dd id="CopyGrantsProperty.dfs" class="function"><a href="#Expression.dfs">dfs</a></dd> + <dd id="CopyGrantsProperty.bfs" class="function"><a href="#Expression.bfs">bfs</a></dd> + <dd id="CopyGrantsProperty.unnest" class="function"><a href="#Expression.unnest">unnest</a></dd> + <dd id="CopyGrantsProperty.unalias" class="function"><a href="#Expression.unalias">unalias</a></dd> + <dd id="CopyGrantsProperty.unnest_operands" class="function"><a href="#Expression.unnest_operands">unnest_operands</a></dd> + <dd id="CopyGrantsProperty.flatten" class="function"><a href="#Expression.flatten">flatten</a></dd> + <dd id="CopyGrantsProperty.sql" class="function"><a href="#Expression.sql">sql</a></dd> + <dd id="CopyGrantsProperty.transform" class="function"><a href="#Expression.transform">transform</a></dd> + <dd id="CopyGrantsProperty.replace" class="function"><a href="#Expression.replace">replace</a></dd> + <dd id="CopyGrantsProperty.pop" class="function"><a href="#Expression.pop">pop</a></dd> + <dd id="CopyGrantsProperty.assert_is" class="function"><a href="#Expression.assert_is">assert_is</a></dd> + <dd id="CopyGrantsProperty.error_messages" class="function"><a href="#Expression.error_messages">error_messages</a></dd> + <dd id="CopyGrantsProperty.dump" class="function"><a href="#Expression.dump">dump</a></dd> + <dd id="CopyGrantsProperty.load" class="function"><a href="#Expression.load">load</a></dd> + + </div> + </dl> + </div> + </section> <section id="DataBlocksizeProperty"> <input id="DataBlocksizeProperty-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> <div class="attr class"> @@ -19543,14 +19624,14 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#DataBlocksizeProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataBlocksizeProperty-1848"><a href="#DataBlocksizeProperty-1848"><span class="linenos">1848</span></a><span class="k">class</span> <span class="nc">DataBlocksizeProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="DataBlocksizeProperty-1849"><a href="#DataBlocksizeProperty-1849"><span class="linenos">1849</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DataBlocksizeProperty-1850"><a href="#DataBlocksizeProperty-1850"><span class="linenos">1850</span></a> <span class="s2">"size"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="DataBlocksizeProperty-1851"><a href="#DataBlocksizeProperty-1851"><span class="linenos">1851</span></a> <span class="s2">"units"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="DataBlocksizeProperty-1852"><a href="#DataBlocksizeProperty-1852"><span class="linenos">1852</span></a> <span class="s2">"minimum"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="DataBlocksizeProperty-1853"><a href="#DataBlocksizeProperty-1853"><span class="linenos">1853</span></a> <span class="s2">"maximum"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="DataBlocksizeProperty-1854"><a href="#DataBlocksizeProperty-1854"><span class="linenos">1854</span></a> <span class="s2">"default"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="DataBlocksizeProperty-1855"><a href="#DataBlocksizeProperty-1855"><span class="linenos">1855</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataBlocksizeProperty-1852"><a href="#DataBlocksizeProperty-1852"><span class="linenos">1852</span></a><span class="k">class</span> <span class="nc">DataBlocksizeProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="DataBlocksizeProperty-1853"><a href="#DataBlocksizeProperty-1853"><span class="linenos">1853</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DataBlocksizeProperty-1854"><a href="#DataBlocksizeProperty-1854"><span class="linenos">1854</span></a> <span class="s2">"size"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="DataBlocksizeProperty-1855"><a href="#DataBlocksizeProperty-1855"><span class="linenos">1855</span></a> <span class="s2">"units"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="DataBlocksizeProperty-1856"><a href="#DataBlocksizeProperty-1856"><span class="linenos">1856</span></a> <span class="s2">"minimum"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="DataBlocksizeProperty-1857"><a href="#DataBlocksizeProperty-1857"><span class="linenos">1857</span></a> <span class="s2">"maximum"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="DataBlocksizeProperty-1858"><a href="#DataBlocksizeProperty-1858"><span class="linenos">1858</span></a> <span class="s2">"default"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="DataBlocksizeProperty-1859"><a href="#DataBlocksizeProperty-1859"><span class="linenos">1859</span></a> <span class="p">}</span> </span></pre></div> @@ -19614,8 +19695,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#DefinerProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DefinerProperty-1858"><a href="#DefinerProperty-1858"><span class="linenos">1858</span></a><span class="k">class</span> <span class="nc">DefinerProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="DefinerProperty-1859"><a href="#DefinerProperty-1859"><span class="linenos">1859</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DefinerProperty-1862"><a href="#DefinerProperty-1862"><span class="linenos">1862</span></a><span class="k">class</span> <span class="nc">DefinerProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="DefinerProperty-1863"><a href="#DefinerProperty-1863"><span class="linenos">1863</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -19679,8 +19760,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#DistKeyProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DistKeyProperty-1862"><a href="#DistKeyProperty-1862"><span class="linenos">1862</span></a><span class="k">class</span> <span class="nc">DistKeyProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="DistKeyProperty-1863"><a href="#DistKeyProperty-1863"><span class="linenos">1863</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DistKeyProperty-1866"><a href="#DistKeyProperty-1866"><span class="linenos">1866</span></a><span class="k">class</span> <span class="nc">DistKeyProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="DistKeyProperty-1867"><a href="#DistKeyProperty-1867"><span class="linenos">1867</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -19744,8 +19825,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#DistStyleProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DistStyleProperty-1866"><a href="#DistStyleProperty-1866"><span class="linenos">1866</span></a><span class="k">class</span> <span class="nc">DistStyleProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="DistStyleProperty-1867"><a href="#DistStyleProperty-1867"><span class="linenos">1867</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DistStyleProperty-1870"><a href="#DistStyleProperty-1870"><span class="linenos">1870</span></a><span class="k">class</span> <span class="nc">DistStyleProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="DistStyleProperty-1871"><a href="#DistStyleProperty-1871"><span class="linenos">1871</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -19809,8 +19890,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#EngineProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="EngineProperty-1870"><a href="#EngineProperty-1870"><span class="linenos">1870</span></a><span class="k">class</span> <span class="nc">EngineProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="EngineProperty-1871"><a href="#EngineProperty-1871"><span class="linenos">1871</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="EngineProperty-1874"><a href="#EngineProperty-1874"><span class="linenos">1874</span></a><span class="k">class</span> <span class="nc">EngineProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="EngineProperty-1875"><a href="#EngineProperty-1875"><span class="linenos">1875</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -19874,8 +19955,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#ToTableProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ToTableProperty-1874"><a href="#ToTableProperty-1874"><span class="linenos">1874</span></a><span class="k">class</span> <span class="nc">ToTableProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="ToTableProperty-1875"><a href="#ToTableProperty-1875"><span class="linenos">1875</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ToTableProperty-1878"><a href="#ToTableProperty-1878"><span class="linenos">1878</span></a><span class="k">class</span> <span class="nc">ToTableProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="ToTableProperty-1879"><a href="#ToTableProperty-1879"><span class="linenos">1879</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -19939,8 +20020,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#ExecuteAsProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ExecuteAsProperty-1878"><a href="#ExecuteAsProperty-1878"><span class="linenos">1878</span></a><span class="k">class</span> <span class="nc">ExecuteAsProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="ExecuteAsProperty-1879"><a href="#ExecuteAsProperty-1879"><span class="linenos">1879</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ExecuteAsProperty-1882"><a href="#ExecuteAsProperty-1882"><span class="linenos">1882</span></a><span class="k">class</span> <span class="nc">ExecuteAsProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="ExecuteAsProperty-1883"><a href="#ExecuteAsProperty-1883"><span class="linenos">1883</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -20004,8 +20085,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#ExternalProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ExternalProperty-1882"><a href="#ExternalProperty-1882"><span class="linenos">1882</span></a><span class="k">class</span> <span class="nc">ExternalProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="ExternalProperty-1883"><a href="#ExternalProperty-1883"><span class="linenos">1883</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ExternalProperty-1886"><a href="#ExternalProperty-1886"><span class="linenos">1886</span></a><span class="k">class</span> <span class="nc">ExternalProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="ExternalProperty-1887"><a href="#ExternalProperty-1887"><span class="linenos">1887</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -20069,8 +20150,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#FallbackProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="FallbackProperty-1886"><a href="#FallbackProperty-1886"><span class="linenos">1886</span></a><span class="k">class</span> <span class="nc">FallbackProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="FallbackProperty-1887"><a href="#FallbackProperty-1887"><span class="linenos">1887</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"no"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"protection"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="FallbackProperty-1890"><a href="#FallbackProperty-1890"><span class="linenos">1890</span></a><span class="k">class</span> <span class="nc">FallbackProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="FallbackProperty-1891"><a href="#FallbackProperty-1891"><span class="linenos">1891</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"no"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"protection"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -20134,8 +20215,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#FileFormatProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="FileFormatProperty-1890"><a href="#FileFormatProperty-1890"><span class="linenos">1890</span></a><span class="k">class</span> <span class="nc">FileFormatProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="FileFormatProperty-1891"><a href="#FileFormatProperty-1891"><span class="linenos">1891</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="FileFormatProperty-1894"><a href="#FileFormatProperty-1894"><span class="linenos">1894</span></a><span class="k">class</span> <span class="nc">FileFormatProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="FileFormatProperty-1895"><a href="#FileFormatProperty-1895"><span class="linenos">1895</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -20199,8 +20280,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#FreespaceProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="FreespaceProperty-1894"><a href="#FreespaceProperty-1894"><span class="linenos">1894</span></a><span class="k">class</span> <span class="nc">FreespaceProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="FreespaceProperty-1895"><a href="#FreespaceProperty-1895"><span class="linenos">1895</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="FreespaceProperty-1898"><a href="#FreespaceProperty-1898"><span class="linenos">1898</span></a><span class="k">class</span> <span class="nc">FreespaceProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="FreespaceProperty-1899"><a href="#FreespaceProperty-1899"><span class="linenos">1899</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -20264,8 +20345,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#InputOutputFormat"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="InputOutputFormat-1898"><a href="#InputOutputFormat-1898"><span class="linenos">1898</span></a><span class="k">class</span> <span class="nc">InputOutputFormat</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="InputOutputFormat-1899"><a href="#InputOutputFormat-1899"><span class="linenos">1899</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"input_format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"output_format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="InputOutputFormat-1902"><a href="#InputOutputFormat-1902"><span class="linenos">1902</span></a><span class="k">class</span> <span class="nc">InputOutputFormat</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="InputOutputFormat-1903"><a href="#InputOutputFormat-1903"><span class="linenos">1903</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"input_format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"output_format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -20329,14 +20410,14 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#IsolatedLoadingProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="IsolatedLoadingProperty-1902"><a href="#IsolatedLoadingProperty-1902"><span class="linenos">1902</span></a><span class="k">class</span> <span class="nc">IsolatedLoadingProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="IsolatedLoadingProperty-1903"><a href="#IsolatedLoadingProperty-1903"><span class="linenos">1903</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="IsolatedLoadingProperty-1904"><a href="#IsolatedLoadingProperty-1904"><span class="linenos">1904</span></a> <span class="s2">"no"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="IsolatedLoadingProperty-1905"><a href="#IsolatedLoadingProperty-1905"><span class="linenos">1905</span></a> <span class="s2">"concurrent"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="IsolatedLoadingProperty-1906"><a href="#IsolatedLoadingProperty-1906"><span class="linenos">1906</span></a> <span class="s2">"for_all"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="IsolatedLoadingProperty-1907"><a href="#IsolatedLoadingProperty-1907"><span class="linenos">1907</span></a> <span class="s2">"for_insert"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="IsolatedLoadingProperty-1908"><a href="#IsolatedLoadingProperty-1908"><span class="linenos">1908</span></a> <span class="s2">"for_none"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="IsolatedLoadingProperty-1909"><a href="#IsolatedLoadingProperty-1909"><span class="linenos">1909</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="IsolatedLoadingProperty-1906"><a href="#IsolatedLoadingProperty-1906"><span class="linenos">1906</span></a><span class="k">class</span> <span class="nc">IsolatedLoadingProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="IsolatedLoadingProperty-1907"><a href="#IsolatedLoadingProperty-1907"><span class="linenos">1907</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="IsolatedLoadingProperty-1908"><a href="#IsolatedLoadingProperty-1908"><span class="linenos">1908</span></a> <span class="s2">"no"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="IsolatedLoadingProperty-1909"><a href="#IsolatedLoadingProperty-1909"><span class="linenos">1909</span></a> <span class="s2">"concurrent"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="IsolatedLoadingProperty-1910"><a href="#IsolatedLoadingProperty-1910"><span class="linenos">1910</span></a> <span class="s2">"for_all"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="IsolatedLoadingProperty-1911"><a href="#IsolatedLoadingProperty-1911"><span class="linenos">1911</span></a> <span class="s2">"for_insert"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="IsolatedLoadingProperty-1912"><a href="#IsolatedLoadingProperty-1912"><span class="linenos">1912</span></a> <span class="s2">"for_none"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="IsolatedLoadingProperty-1913"><a href="#IsolatedLoadingProperty-1913"><span class="linenos">1913</span></a> <span class="p">}</span> </span></pre></div> @@ -20400,14 +20481,14 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#JournalProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="JournalProperty-1912"><a href="#JournalProperty-1912"><span class="linenos">1912</span></a><span class="k">class</span> <span class="nc">JournalProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="JournalProperty-1913"><a href="#JournalProperty-1913"><span class="linenos">1913</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="JournalProperty-1914"><a href="#JournalProperty-1914"><span class="linenos">1914</span></a> <span class="s2">"no"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="JournalProperty-1915"><a href="#JournalProperty-1915"><span class="linenos">1915</span></a> <span class="s2">"dual"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="JournalProperty-1916"><a href="#JournalProperty-1916"><span class="linenos">1916</span></a> <span class="s2">"before"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="JournalProperty-1917"><a href="#JournalProperty-1917"><span class="linenos">1917</span></a> <span class="s2">"local"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="JournalProperty-1918"><a href="#JournalProperty-1918"><span class="linenos">1918</span></a> <span class="s2">"after"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="JournalProperty-1919"><a href="#JournalProperty-1919"><span class="linenos">1919</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="JournalProperty-1916"><a href="#JournalProperty-1916"><span class="linenos">1916</span></a><span class="k">class</span> <span class="nc">JournalProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="JournalProperty-1917"><a href="#JournalProperty-1917"><span class="linenos">1917</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="JournalProperty-1918"><a href="#JournalProperty-1918"><span class="linenos">1918</span></a> <span class="s2">"no"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="JournalProperty-1919"><a href="#JournalProperty-1919"><span class="linenos">1919</span></a> <span class="s2">"dual"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="JournalProperty-1920"><a href="#JournalProperty-1920"><span class="linenos">1920</span></a> <span class="s2">"before"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="JournalProperty-1921"><a href="#JournalProperty-1921"><span class="linenos">1921</span></a> <span class="s2">"local"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="JournalProperty-1922"><a href="#JournalProperty-1922"><span class="linenos">1922</span></a> <span class="s2">"after"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="JournalProperty-1923"><a href="#JournalProperty-1923"><span class="linenos">1923</span></a> <span class="p">}</span> </span></pre></div> @@ -20471,8 +20552,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#LanguageProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="LanguageProperty-1922"><a href="#LanguageProperty-1922"><span class="linenos">1922</span></a><span class="k">class</span> <span class="nc">LanguageProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="LanguageProperty-1923"><a href="#LanguageProperty-1923"><span class="linenos">1923</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="LanguageProperty-1926"><a href="#LanguageProperty-1926"><span class="linenos">1926</span></a><span class="k">class</span> <span class="nc">LanguageProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="LanguageProperty-1927"><a href="#LanguageProperty-1927"><span class="linenos">1927</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -20536,8 +20617,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#DictProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DictProperty-1926"><a href="#DictProperty-1926"><span class="linenos">1926</span></a><span class="k">class</span> <span class="nc">DictProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="DictProperty-1927"><a href="#DictProperty-1927"><span class="linenos">1927</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"settings"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DictProperty-1930"><a href="#DictProperty-1930"><span class="linenos">1930</span></a><span class="k">class</span> <span class="nc">DictProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="DictProperty-1931"><a href="#DictProperty-1931"><span class="linenos">1931</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"settings"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -20601,8 +20682,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#DictSubProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DictSubProperty-1930"><a href="#DictSubProperty-1930"><span class="linenos">1930</span></a><span class="k">class</span> <span class="nc">DictSubProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="DictSubProperty-1931"><a href="#DictSubProperty-1931"><span class="linenos">1931</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DictSubProperty-1934"><a href="#DictSubProperty-1934"><span class="linenos">1934</span></a><span class="k">class</span> <span class="nc">DictSubProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="DictSubProperty-1935"><a href="#DictSubProperty-1935"><span class="linenos">1935</span></a> <span class="k">pass</span> </span></pre></div> @@ -20666,8 +20747,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#DictRange"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DictRange-1934"><a href="#DictRange-1934"><span class="linenos">1934</span></a><span class="k">class</span> <span class="nc">DictRange</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="DictRange-1935"><a href="#DictRange-1935"><span class="linenos">1935</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"min"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"max"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DictRange-1938"><a href="#DictRange-1938"><span class="linenos">1938</span></a><span class="k">class</span> <span class="nc">DictRange</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="DictRange-1939"><a href="#DictRange-1939"><span class="linenos">1939</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"min"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"max"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -20731,8 +20812,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#OnCluster"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="OnCluster-1940"><a href="#OnCluster-1940"><span class="linenos">1940</span></a><span class="k">class</span> <span class="nc">OnCluster</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="OnCluster-1941"><a href="#OnCluster-1941"><span class="linenos">1941</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="OnCluster-1944"><a href="#OnCluster-1944"><span class="linenos">1944</span></a><span class="k">class</span> <span class="nc">OnCluster</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="OnCluster-1945"><a href="#OnCluster-1945"><span class="linenos">1945</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -20796,8 +20877,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#LikeProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="LikeProperty-1944"><a href="#LikeProperty-1944"><span class="linenos">1944</span></a><span class="k">class</span> <span class="nc">LikeProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="LikeProperty-1945"><a href="#LikeProperty-1945"><span class="linenos">1945</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="LikeProperty-1948"><a href="#LikeProperty-1948"><span class="linenos">1948</span></a><span class="k">class</span> <span class="nc">LikeProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="LikeProperty-1949"><a href="#LikeProperty-1949"><span class="linenos">1949</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -20861,8 +20942,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#LocationProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="LocationProperty-1948"><a href="#LocationProperty-1948"><span class="linenos">1948</span></a><span class="k">class</span> <span class="nc">LocationProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="LocationProperty-1949"><a href="#LocationProperty-1949"><span class="linenos">1949</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="LocationProperty-1952"><a href="#LocationProperty-1952"><span class="linenos">1952</span></a><span class="k">class</span> <span class="nc">LocationProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="LocationProperty-1953"><a href="#LocationProperty-1953"><span class="linenos">1953</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -20926,14 +21007,14 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#LockingProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="LockingProperty-1952"><a href="#LockingProperty-1952"><span class="linenos">1952</span></a><span class="k">class</span> <span class="nc">LockingProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="LockingProperty-1953"><a href="#LockingProperty-1953"><span class="linenos">1953</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="LockingProperty-1954"><a href="#LockingProperty-1954"><span class="linenos">1954</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="LockingProperty-1955"><a href="#LockingProperty-1955"><span class="linenos">1955</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="LockingProperty-1956"><a href="#LockingProperty-1956"><span class="linenos">1956</span></a> <span class="s2">"for_or_in"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="LockingProperty-1957"><a href="#LockingProperty-1957"><span class="linenos">1957</span></a> <span class="s2">"lock_type"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="LockingProperty-1958"><a href="#LockingProperty-1958"><span class="linenos">1958</span></a> <span class="s2">"override"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="LockingProperty-1959"><a href="#LockingProperty-1959"><span class="linenos">1959</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="LockingProperty-1956"><a href="#LockingProperty-1956"><span class="linenos">1956</span></a><span class="k">class</span> <span class="nc">LockingProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="LockingProperty-1957"><a href="#LockingProperty-1957"><span class="linenos">1957</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="LockingProperty-1958"><a href="#LockingProperty-1958"><span class="linenos">1958</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="LockingProperty-1959"><a href="#LockingProperty-1959"><span class="linenos">1959</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="LockingProperty-1960"><a href="#LockingProperty-1960"><span class="linenos">1960</span></a> <span class="s2">"for_or_in"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="LockingProperty-1961"><a href="#LockingProperty-1961"><span class="linenos">1961</span></a> <span class="s2">"lock_type"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="LockingProperty-1962"><a href="#LockingProperty-1962"><span class="linenos">1962</span></a> <span class="s2">"override"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="LockingProperty-1963"><a href="#LockingProperty-1963"><span class="linenos">1963</span></a> <span class="p">}</span> </span></pre></div> @@ -20997,8 +21078,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#LogProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="LogProperty-1962"><a href="#LogProperty-1962"><span class="linenos">1962</span></a><span class="k">class</span> <span class="nc">LogProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="LogProperty-1963"><a href="#LogProperty-1963"><span class="linenos">1963</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"no"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="LogProperty-1966"><a href="#LogProperty-1966"><span class="linenos">1966</span></a><span class="k">class</span> <span class="nc">LogProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="LogProperty-1967"><a href="#LogProperty-1967"><span class="linenos">1967</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"no"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -21062,8 +21143,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#MaterializedProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="MaterializedProperty-1966"><a href="#MaterializedProperty-1966"><span class="linenos">1966</span></a><span class="k">class</span> <span class="nc">MaterializedProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="MaterializedProperty-1967"><a href="#MaterializedProperty-1967"><span class="linenos">1967</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="MaterializedProperty-1970"><a href="#MaterializedProperty-1970"><span class="linenos">1970</span></a><span class="k">class</span> <span class="nc">MaterializedProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="MaterializedProperty-1971"><a href="#MaterializedProperty-1971"><span class="linenos">1971</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -21127,8 +21208,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#MergeBlockRatioProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="MergeBlockRatioProperty-1970"><a href="#MergeBlockRatioProperty-1970"><span class="linenos">1970</span></a><span class="k">class</span> <span class="nc">MergeBlockRatioProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="MergeBlockRatioProperty-1971"><a href="#MergeBlockRatioProperty-1971"><span class="linenos">1971</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"no"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="MergeBlockRatioProperty-1974"><a href="#MergeBlockRatioProperty-1974"><span class="linenos">1974</span></a><span class="k">class</span> <span class="nc">MergeBlockRatioProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="MergeBlockRatioProperty-1975"><a href="#MergeBlockRatioProperty-1975"><span class="linenos">1975</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"no"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -21192,8 +21273,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#NoPrimaryIndexProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="NoPrimaryIndexProperty-1974"><a href="#NoPrimaryIndexProperty-1974"><span class="linenos">1974</span></a><span class="k">class</span> <span class="nc">NoPrimaryIndexProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="NoPrimaryIndexProperty-1975"><a href="#NoPrimaryIndexProperty-1975"><span class="linenos">1975</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="NoPrimaryIndexProperty-1978"><a href="#NoPrimaryIndexProperty-1978"><span class="linenos">1978</span></a><span class="k">class</span> <span class="nc">NoPrimaryIndexProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="NoPrimaryIndexProperty-1979"><a href="#NoPrimaryIndexProperty-1979"><span class="linenos">1979</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{}</span> </span></pre></div> @@ -21257,8 +21338,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#OnCommitProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="OnCommitProperty-1978"><a href="#OnCommitProperty-1978"><span class="linenos">1978</span></a><span class="k">class</span> <span class="nc">OnCommitProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="OnCommitProperty-1979"><a href="#OnCommitProperty-1979"><span class="linenos">1979</span></a> <span class="n">arg_type</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"delete"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="OnCommitProperty-1982"><a href="#OnCommitProperty-1982"><span class="linenos">1982</span></a><span class="k">class</span> <span class="nc">OnCommitProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="OnCommitProperty-1983"><a href="#OnCommitProperty-1983"><span class="linenos">1983</span></a> <span class="n">arg_type</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"delete"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -21322,8 +21403,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#PartitionedByProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="PartitionedByProperty-1982"><a href="#PartitionedByProperty-1982"><span class="linenos">1982</span></a><span class="k">class</span> <span class="nc">PartitionedByProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="PartitionedByProperty-1983"><a href="#PartitionedByProperty-1983"><span class="linenos">1983</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="PartitionedByProperty-1986"><a href="#PartitionedByProperty-1986"><span class="linenos">1986</span></a><span class="k">class</span> <span class="nc">PartitionedByProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="PartitionedByProperty-1987"><a href="#PartitionedByProperty-1987"><span class="linenos">1987</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -21387,8 +21468,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#ReturnsProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ReturnsProperty-1986"><a href="#ReturnsProperty-1986"><span class="linenos">1986</span></a><span class="k">class</span> <span class="nc">ReturnsProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="ReturnsProperty-1987"><a href="#ReturnsProperty-1987"><span class="linenos">1987</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"is_table"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"table"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ReturnsProperty-1990"><a href="#ReturnsProperty-1990"><span class="linenos">1990</span></a><span class="k">class</span> <span class="nc">ReturnsProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="ReturnsProperty-1991"><a href="#ReturnsProperty-1991"><span class="linenos">1991</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"is_table"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"table"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -21452,8 +21533,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#RowFormatProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="RowFormatProperty-1990"><a href="#RowFormatProperty-1990"><span class="linenos">1990</span></a><span class="k">class</span> <span class="nc">RowFormatProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="RowFormatProperty-1991"><a href="#RowFormatProperty-1991"><span class="linenos">1991</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="RowFormatProperty-1994"><a href="#RowFormatProperty-1994"><span class="linenos">1994</span></a><span class="k">class</span> <span class="nc">RowFormatProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="RowFormatProperty-1995"><a href="#RowFormatProperty-1995"><span class="linenos">1995</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -21517,17 +21598,17 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#RowFormatDelimitedProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="RowFormatDelimitedProperty-1994"><a href="#RowFormatDelimitedProperty-1994"><span class="linenos">1994</span></a><span class="k">class</span> <span class="nc">RowFormatDelimitedProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="RowFormatDelimitedProperty-1995"><a href="#RowFormatDelimitedProperty-1995"><span class="linenos">1995</span></a> <span class="c1"># https://cwiki.apache.org/confluence/display/hive/languagemanual+dml</span> -</span><span id="RowFormatDelimitedProperty-1996"><a href="#RowFormatDelimitedProperty-1996"><span class="linenos">1996</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="RowFormatDelimitedProperty-1997"><a href="#RowFormatDelimitedProperty-1997"><span class="linenos">1997</span></a> <span class="s2">"fields"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="RowFormatDelimitedProperty-1998"><a href="#RowFormatDelimitedProperty-1998"><span class="linenos">1998</span></a> <span class="s2">"escaped"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="RowFormatDelimitedProperty-1999"><a href="#RowFormatDelimitedProperty-1999"><span class="linenos">1999</span></a> <span class="s2">"collection_items"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="RowFormatDelimitedProperty-2000"><a href="#RowFormatDelimitedProperty-2000"><span class="linenos">2000</span></a> <span class="s2">"map_keys"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="RowFormatDelimitedProperty-2001"><a href="#RowFormatDelimitedProperty-2001"><span class="linenos">2001</span></a> <span class="s2">"lines"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="RowFormatDelimitedProperty-2002"><a href="#RowFormatDelimitedProperty-2002"><span class="linenos">2002</span></a> <span class="s2">"null"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="RowFormatDelimitedProperty-2003"><a href="#RowFormatDelimitedProperty-2003"><span class="linenos">2003</span></a> <span class="s2">"serde"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="RowFormatDelimitedProperty-2004"><a href="#RowFormatDelimitedProperty-2004"><span class="linenos">2004</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="RowFormatDelimitedProperty-1998"><a href="#RowFormatDelimitedProperty-1998"><span class="linenos">1998</span></a><span class="k">class</span> <span class="nc">RowFormatDelimitedProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="RowFormatDelimitedProperty-1999"><a href="#RowFormatDelimitedProperty-1999"><span class="linenos">1999</span></a> <span class="c1"># https://cwiki.apache.org/confluence/display/hive/languagemanual+dml</span> +</span><span id="RowFormatDelimitedProperty-2000"><a href="#RowFormatDelimitedProperty-2000"><span class="linenos">2000</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="RowFormatDelimitedProperty-2001"><a href="#RowFormatDelimitedProperty-2001"><span class="linenos">2001</span></a> <span class="s2">"fields"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="RowFormatDelimitedProperty-2002"><a href="#RowFormatDelimitedProperty-2002"><span class="linenos">2002</span></a> <span class="s2">"escaped"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="RowFormatDelimitedProperty-2003"><a href="#RowFormatDelimitedProperty-2003"><span class="linenos">2003</span></a> <span class="s2">"collection_items"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="RowFormatDelimitedProperty-2004"><a href="#RowFormatDelimitedProperty-2004"><span class="linenos">2004</span></a> <span class="s2">"map_keys"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="RowFormatDelimitedProperty-2005"><a href="#RowFormatDelimitedProperty-2005"><span class="linenos">2005</span></a> <span class="s2">"lines"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="RowFormatDelimitedProperty-2006"><a href="#RowFormatDelimitedProperty-2006"><span class="linenos">2006</span></a> <span class="s2">"null"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="RowFormatDelimitedProperty-2007"><a href="#RowFormatDelimitedProperty-2007"><span class="linenos">2007</span></a> <span class="s2">"serde"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="RowFormatDelimitedProperty-2008"><a href="#RowFormatDelimitedProperty-2008"><span class="linenos">2008</span></a> <span class="p">}</span> </span></pre></div> @@ -21591,8 +21672,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#RowFormatSerdeProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="RowFormatSerdeProperty-2007"><a href="#RowFormatSerdeProperty-2007"><span class="linenos">2007</span></a><span class="k">class</span> <span class="nc">RowFormatSerdeProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="RowFormatSerdeProperty-2008"><a href="#RowFormatSerdeProperty-2008"><span class="linenos">2008</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="RowFormatSerdeProperty-2011"><a href="#RowFormatSerdeProperty-2011"><span class="linenos">2011</span></a><span class="k">class</span> <span class="nc">RowFormatSerdeProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="RowFormatSerdeProperty-2012"><a href="#RowFormatSerdeProperty-2012"><span class="linenos">2012</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -21656,8 +21737,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#SchemaCommentProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SchemaCommentProperty-2011"><a href="#SchemaCommentProperty-2011"><span class="linenos">2011</span></a><span class="k">class</span> <span class="nc">SchemaCommentProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="SchemaCommentProperty-2012"><a href="#SchemaCommentProperty-2012"><span class="linenos">2012</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SchemaCommentProperty-2015"><a href="#SchemaCommentProperty-2015"><span class="linenos">2015</span></a><span class="k">class</span> <span class="nc">SchemaCommentProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="SchemaCommentProperty-2016"><a href="#SchemaCommentProperty-2016"><span class="linenos">2016</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -21721,8 +21802,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#SerdeProperties"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SerdeProperties-2015"><a href="#SerdeProperties-2015"><span class="linenos">2015</span></a><span class="k">class</span> <span class="nc">SerdeProperties</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="SerdeProperties-2016"><a href="#SerdeProperties-2016"><span class="linenos">2016</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SerdeProperties-2019"><a href="#SerdeProperties-2019"><span class="linenos">2019</span></a><span class="k">class</span> <span class="nc">SerdeProperties</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="SerdeProperties-2020"><a href="#SerdeProperties-2020"><span class="linenos">2020</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -21786,8 +21867,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#SetProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SetProperty-2019"><a href="#SetProperty-2019"><span class="linenos">2019</span></a><span class="k">class</span> <span class="nc">SetProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="SetProperty-2020"><a href="#SetProperty-2020"><span class="linenos">2020</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"multi"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SetProperty-2023"><a href="#SetProperty-2023"><span class="linenos">2023</span></a><span class="k">class</span> <span class="nc">SetProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="SetProperty-2024"><a href="#SetProperty-2024"><span class="linenos">2024</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"multi"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -21851,8 +21932,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#SettingsProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SettingsProperty-2023"><a href="#SettingsProperty-2023"><span class="linenos">2023</span></a><span class="k">class</span> <span class="nc">SettingsProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="SettingsProperty-2024"><a href="#SettingsProperty-2024"><span class="linenos">2024</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SettingsProperty-2027"><a href="#SettingsProperty-2027"><span class="linenos">2027</span></a><span class="k">class</span> <span class="nc">SettingsProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="SettingsProperty-2028"><a href="#SettingsProperty-2028"><span class="linenos">2028</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -21916,8 +21997,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#SortKeyProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SortKeyProperty-2027"><a href="#SortKeyProperty-2027"><span class="linenos">2027</span></a><span class="k">class</span> <span class="nc">SortKeyProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="SortKeyProperty-2028"><a href="#SortKeyProperty-2028"><span class="linenos">2028</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"compound"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SortKeyProperty-2031"><a href="#SortKeyProperty-2031"><span class="linenos">2031</span></a><span class="k">class</span> <span class="nc">SortKeyProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="SortKeyProperty-2032"><a href="#SortKeyProperty-2032"><span class="linenos">2032</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"compound"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -21981,8 +22062,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#SqlSecurityProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SqlSecurityProperty-2031"><a href="#SqlSecurityProperty-2031"><span class="linenos">2031</span></a><span class="k">class</span> <span class="nc">SqlSecurityProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="SqlSecurityProperty-2032"><a href="#SqlSecurityProperty-2032"><span class="linenos">2032</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"definer"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SqlSecurityProperty-2035"><a href="#SqlSecurityProperty-2035"><span class="linenos">2035</span></a><span class="k">class</span> <span class="nc">SqlSecurityProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="SqlSecurityProperty-2036"><a href="#SqlSecurityProperty-2036"><span class="linenos">2036</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"definer"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -22046,8 +22127,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#StabilityProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="StabilityProperty-2035"><a href="#StabilityProperty-2035"><span class="linenos">2035</span></a><span class="k">class</span> <span class="nc">StabilityProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="StabilityProperty-2036"><a href="#StabilityProperty-2036"><span class="linenos">2036</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="StabilityProperty-2039"><a href="#StabilityProperty-2039"><span class="linenos">2039</span></a><span class="k">class</span> <span class="nc">StabilityProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="StabilityProperty-2040"><a href="#StabilityProperty-2040"><span class="linenos">2040</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -22111,8 +22192,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#TemporaryProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TemporaryProperty-2039"><a href="#TemporaryProperty-2039"><span class="linenos">2039</span></a><span class="k">class</span> <span class="nc">TemporaryProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="TemporaryProperty-2040"><a href="#TemporaryProperty-2040"><span class="linenos">2040</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TemporaryProperty-2043"><a href="#TemporaryProperty-2043"><span class="linenos">2043</span></a><span class="k">class</span> <span class="nc">TemporaryProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="TemporaryProperty-2044"><a href="#TemporaryProperty-2044"><span class="linenos">2044</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{}</span> </span></pre></div> @@ -22176,8 +22257,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#TransientProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TransientProperty-2043"><a href="#TransientProperty-2043"><span class="linenos">2043</span></a><span class="k">class</span> <span class="nc">TransientProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="TransientProperty-2044"><a href="#TransientProperty-2044"><span class="linenos">2044</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TransientProperty-2047"><a href="#TransientProperty-2047"><span class="linenos">2047</span></a><span class="k">class</span> <span class="nc">TransientProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="TransientProperty-2048"><a href="#TransientProperty-2048"><span class="linenos">2048</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -22241,8 +22322,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#VolatileProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="VolatileProperty-2047"><a href="#VolatileProperty-2047"><span class="linenos">2047</span></a><span class="k">class</span> <span class="nc">VolatileProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="VolatileProperty-2048"><a href="#VolatileProperty-2048"><span class="linenos">2048</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="VolatileProperty-2051"><a href="#VolatileProperty-2051"><span class="linenos">2051</span></a><span class="k">class</span> <span class="nc">VolatileProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="VolatileProperty-2052"><a href="#VolatileProperty-2052"><span class="linenos">2052</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -22306,8 +22387,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#WithDataProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="WithDataProperty-2051"><a href="#WithDataProperty-2051"><span class="linenos">2051</span></a><span class="k">class</span> <span class="nc">WithDataProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="WithDataProperty-2052"><a href="#WithDataProperty-2052"><span class="linenos">2052</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"no"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"statistics"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="WithDataProperty-2055"><a href="#WithDataProperty-2055"><span class="linenos">2055</span></a><span class="k">class</span> <span class="nc">WithDataProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="WithDataProperty-2056"><a href="#WithDataProperty-2056"><span class="linenos">2056</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"no"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"statistics"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -22371,8 +22452,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#WithJournalTableProperty"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="WithJournalTableProperty-2055"><a href="#WithJournalTableProperty-2055"><span class="linenos">2055</span></a><span class="k">class</span> <span class="nc">WithJournalTableProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> -</span><span id="WithJournalTableProperty-2056"><a href="#WithJournalTableProperty-2056"><span class="linenos">2056</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="WithJournalTableProperty-2059"><a href="#WithJournalTableProperty-2059"><span class="linenos">2059</span></a><span class="k">class</span> <span class="nc">WithJournalTableProperty</span><span class="p">(</span><span class="n">Property</span><span class="p">):</span> +</span><span id="WithJournalTableProperty-2060"><a href="#WithJournalTableProperty-2060"><span class="linenos">2060</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -22436,65 +22517,65 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#Properties"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Properties-2059"><a href="#Properties-2059"><span class="linenos">2059</span></a><span class="k">class</span> <span class="nc">Properties</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Properties-2060"><a href="#Properties-2060"><span class="linenos">2060</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="Properties-2061"><a href="#Properties-2061"><span class="linenos">2061</span></a> -</span><span id="Properties-2062"><a href="#Properties-2062"><span class="linenos">2062</span></a> <span class="n">NAME_TO_PROPERTY</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Properties-2063"><a href="#Properties-2063"><span class="linenos">2063</span></a> <span class="s2">"ALGORITHM"</span><span class="p">:</span> <span class="n">AlgorithmProperty</span><span class="p">,</span> -</span><span id="Properties-2064"><a href="#Properties-2064"><span class="linenos">2064</span></a> <span class="s2">"AUTO_INCREMENT"</span><span class="p">:</span> <span class="n">AutoIncrementProperty</span><span class="p">,</span> -</span><span id="Properties-2065"><a href="#Properties-2065"><span class="linenos">2065</span></a> <span class="s2">"CHARACTER SET"</span><span class="p">:</span> <span class="n">CharacterSetProperty</span><span class="p">,</span> -</span><span id="Properties-2066"><a href="#Properties-2066"><span class="linenos">2066</span></a> <span class="s2">"COLLATE"</span><span class="p">:</span> <span class="n">CollateProperty</span><span class="p">,</span> -</span><span id="Properties-2067"><a href="#Properties-2067"><span class="linenos">2067</span></a> <span class="s2">"COMMENT"</span><span class="p">:</span> <span class="n">SchemaCommentProperty</span><span class="p">,</span> -</span><span id="Properties-2068"><a href="#Properties-2068"><span class="linenos">2068</span></a> <span class="s2">"DEFINER"</span><span class="p">:</span> <span class="n">DefinerProperty</span><span class="p">,</span> -</span><span id="Properties-2069"><a href="#Properties-2069"><span class="linenos">2069</span></a> <span class="s2">"DISTKEY"</span><span class="p">:</span> <span class="n">DistKeyProperty</span><span class="p">,</span> -</span><span id="Properties-2070"><a href="#Properties-2070"><span class="linenos">2070</span></a> <span class="s2">"DISTSTYLE"</span><span class="p">:</span> <span class="n">DistStyleProperty</span><span class="p">,</span> -</span><span id="Properties-2071"><a href="#Properties-2071"><span class="linenos">2071</span></a> <span class="s2">"ENGINE"</span><span class="p">:</span> <span class="n">EngineProperty</span><span class="p">,</span> -</span><span id="Properties-2072"><a href="#Properties-2072"><span class="linenos">2072</span></a> <span class="s2">"EXECUTE AS"</span><span class="p">:</span> <span class="n">ExecuteAsProperty</span><span class="p">,</span> -</span><span id="Properties-2073"><a href="#Properties-2073"><span class="linenos">2073</span></a> <span class="s2">"FORMAT"</span><span class="p">:</span> <span class="n">FileFormatProperty</span><span class="p">,</span> -</span><span id="Properties-2074"><a href="#Properties-2074"><span class="linenos">2074</span></a> <span class="s2">"LANGUAGE"</span><span class="p">:</span> <span class="n">LanguageProperty</span><span class="p">,</span> -</span><span id="Properties-2075"><a href="#Properties-2075"><span class="linenos">2075</span></a> <span class="s2">"LOCATION"</span><span class="p">:</span> <span class="n">LocationProperty</span><span class="p">,</span> -</span><span id="Properties-2076"><a href="#Properties-2076"><span class="linenos">2076</span></a> <span class="s2">"PARTITIONED_BY"</span><span class="p">:</span> <span class="n">PartitionedByProperty</span><span class="p">,</span> -</span><span id="Properties-2077"><a href="#Properties-2077"><span class="linenos">2077</span></a> <span class="s2">"RETURNS"</span><span class="p">:</span> <span class="n">ReturnsProperty</span><span class="p">,</span> -</span><span id="Properties-2078"><a href="#Properties-2078"><span class="linenos">2078</span></a> <span class="s2">"ROW_FORMAT"</span><span class="p">:</span> <span class="n">RowFormatProperty</span><span class="p">,</span> -</span><span id="Properties-2079"><a href="#Properties-2079"><span class="linenos">2079</span></a> <span class="s2">"SORTKEY"</span><span class="p">:</span> <span class="n">SortKeyProperty</span><span class="p">,</span> -</span><span id="Properties-2080"><a href="#Properties-2080"><span class="linenos">2080</span></a> <span class="p">}</span> -</span><span id="Properties-2081"><a href="#Properties-2081"><span class="linenos">2081</span></a> -</span><span id="Properties-2082"><a href="#Properties-2082"><span class="linenos">2082</span></a> <span class="n">PROPERTY_TO_NAME</span> <span class="o">=</span> <span class="p">{</span><span class="n">v</span><span class="p">:</span> <span class="n">k</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">NAME_TO_PROPERTY</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span> -</span><span id="Properties-2083"><a href="#Properties-2083"><span class="linenos">2083</span></a> -</span><span id="Properties-2084"><a href="#Properties-2084"><span class="linenos">2084</span></a> <span class="c1"># CREATE property locations</span> -</span><span id="Properties-2085"><a href="#Properties-2085"><span class="linenos">2085</span></a> <span class="c1"># Form: schema specified</span> -</span><span id="Properties-2086"><a href="#Properties-2086"><span class="linenos">2086</span></a> <span class="c1"># create [POST_CREATE]</span> -</span><span id="Properties-2087"><a href="#Properties-2087"><span class="linenos">2087</span></a> <span class="c1"># table a [POST_NAME]</span> -</span><span id="Properties-2088"><a href="#Properties-2088"><span class="linenos">2088</span></a> <span class="c1"># (b int) [POST_SCHEMA]</span> -</span><span id="Properties-2089"><a href="#Properties-2089"><span class="linenos">2089</span></a> <span class="c1"># with ([POST_WITH])</span> -</span><span id="Properties-2090"><a href="#Properties-2090"><span class="linenos">2090</span></a> <span class="c1"># index (b) [POST_INDEX]</span> -</span><span id="Properties-2091"><a href="#Properties-2091"><span class="linenos">2091</span></a> <span class="c1">#</span> -</span><span id="Properties-2092"><a href="#Properties-2092"><span class="linenos">2092</span></a> <span class="c1"># Form: alias selection</span> -</span><span id="Properties-2093"><a href="#Properties-2093"><span class="linenos">2093</span></a> <span class="c1"># create [POST_CREATE]</span> -</span><span id="Properties-2094"><a href="#Properties-2094"><span class="linenos">2094</span></a> <span class="c1"># table a [POST_NAME]</span> -</span><span id="Properties-2095"><a href="#Properties-2095"><span class="linenos">2095</span></a> <span class="c1"># as [POST_ALIAS] (select * from b) [POST_EXPRESSION]</span> -</span><span id="Properties-2096"><a href="#Properties-2096"><span class="linenos">2096</span></a> <span class="c1"># index (c) [POST_INDEX]</span> -</span><span id="Properties-2097"><a href="#Properties-2097"><span class="linenos">2097</span></a> <span class="k">class</span> <span class="nc">Location</span><span class="p">(</span><span class="n">AutoName</span><span class="p">):</span> -</span><span id="Properties-2098"><a href="#Properties-2098"><span class="linenos">2098</span></a> <span class="n">POST_CREATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="Properties-2099"><a href="#Properties-2099"><span class="linenos">2099</span></a> <span class="n">POST_NAME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="Properties-2100"><a href="#Properties-2100"><span class="linenos">2100</span></a> <span class="n">POST_SCHEMA</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="Properties-2101"><a href="#Properties-2101"><span class="linenos">2101</span></a> <span class="n">POST_WITH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="Properties-2102"><a href="#Properties-2102"><span class="linenos">2102</span></a> <span class="n">POST_ALIAS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="Properties-2103"><a href="#Properties-2103"><span class="linenos">2103</span></a> <span class="n">POST_EXPRESSION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="Properties-2104"><a href="#Properties-2104"><span class="linenos">2104</span></a> <span class="n">POST_INDEX</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="Properties-2105"><a href="#Properties-2105"><span class="linenos">2105</span></a> <span class="n">UNSUPPORTED</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="Properties-2106"><a href="#Properties-2106"><span class="linenos">2106</span></a> -</span><span id="Properties-2107"><a href="#Properties-2107"><span class="linenos">2107</span></a> <span class="nd">@classmethod</span> -</span><span id="Properties-2108"><a href="#Properties-2108"><span class="linenos">2108</span></a> <span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">properties_dict</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">)</span> <span class="o">-></span> <span class="n">Properties</span><span class="p">:</span> -</span><span id="Properties-2109"><a href="#Properties-2109"><span class="linenos">2109</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Properties-2110"><a href="#Properties-2110"><span class="linenos">2110</span></a> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">properties_dict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> -</span><span id="Properties-2111"><a href="#Properties-2111"><span class="linenos">2111</span></a> <span class="n">property_cls</span> <span class="o">=</span> <span class="bp">cls</span><span class="o">.</span><span class="n">NAME_TO_PROPERTY</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span> -</span><span id="Properties-2112"><a href="#Properties-2112"><span class="linenos">2112</span></a> <span class="k">if</span> <span class="n">property_cls</span><span class="p">:</span> -</span><span id="Properties-2113"><a href="#Properties-2113"><span class="linenos">2113</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">property_cls</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">convert</span><span class="p">(</span><span class="n">value</span><span class="p">)))</span> -</span><span id="Properties-2114"><a href="#Properties-2114"><span class="linenos">2114</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Properties-2115"><a href="#Properties-2115"><span class="linenos">2115</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Property</span><span class="p">(</span><span class="n">this</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">key</span><span class="p">),</span> <span class="n">value</span><span class="o">=</span><span class="n">convert</span><span class="p">(</span><span class="n">value</span><span class="p">)))</span> -</span><span id="Properties-2116"><a href="#Properties-2116"><span class="linenos">2116</span></a> -</span><span id="Properties-2117"><a href="#Properties-2117"><span class="linenos">2117</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Properties-2063"><a href="#Properties-2063"><span class="linenos">2063</span></a><span class="k">class</span> <span class="nc">Properties</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Properties-2064"><a href="#Properties-2064"><span class="linenos">2064</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="Properties-2065"><a href="#Properties-2065"><span class="linenos">2065</span></a> +</span><span id="Properties-2066"><a href="#Properties-2066"><span class="linenos">2066</span></a> <span class="n">NAME_TO_PROPERTY</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Properties-2067"><a href="#Properties-2067"><span class="linenos">2067</span></a> <span class="s2">"ALGORITHM"</span><span class="p">:</span> <span class="n">AlgorithmProperty</span><span class="p">,</span> +</span><span id="Properties-2068"><a href="#Properties-2068"><span class="linenos">2068</span></a> <span class="s2">"AUTO_INCREMENT"</span><span class="p">:</span> <span class="n">AutoIncrementProperty</span><span class="p">,</span> +</span><span id="Properties-2069"><a href="#Properties-2069"><span class="linenos">2069</span></a> <span class="s2">"CHARACTER SET"</span><span class="p">:</span> <span class="n">CharacterSetProperty</span><span class="p">,</span> +</span><span id="Properties-2070"><a href="#Properties-2070"><span class="linenos">2070</span></a> <span class="s2">"COLLATE"</span><span class="p">:</span> <span class="n">CollateProperty</span><span class="p">,</span> +</span><span id="Properties-2071"><a href="#Properties-2071"><span class="linenos">2071</span></a> <span class="s2">"COMMENT"</span><span class="p">:</span> <span class="n">SchemaCommentProperty</span><span class="p">,</span> +</span><span id="Properties-2072"><a href="#Properties-2072"><span class="linenos">2072</span></a> <span class="s2">"DEFINER"</span><span class="p">:</span> <span class="n">DefinerProperty</span><span class="p">,</span> +</span><span id="Properties-2073"><a href="#Properties-2073"><span class="linenos">2073</span></a> <span class="s2">"DISTKEY"</span><span class="p">:</span> <span class="n">DistKeyProperty</span><span class="p">,</span> +</span><span id="Properties-2074"><a href="#Properties-2074"><span class="linenos">2074</span></a> <span class="s2">"DISTSTYLE"</span><span class="p">:</span> <span class="n">DistStyleProperty</span><span class="p">,</span> +</span><span id="Properties-2075"><a href="#Properties-2075"><span class="linenos">2075</span></a> <span class="s2">"ENGINE"</span><span class="p">:</span> <span class="n">EngineProperty</span><span class="p">,</span> +</span><span id="Properties-2076"><a href="#Properties-2076"><span class="linenos">2076</span></a> <span class="s2">"EXECUTE AS"</span><span class="p">:</span> <span class="n">ExecuteAsProperty</span><span class="p">,</span> +</span><span id="Properties-2077"><a href="#Properties-2077"><span class="linenos">2077</span></a> <span class="s2">"FORMAT"</span><span class="p">:</span> <span class="n">FileFormatProperty</span><span class="p">,</span> +</span><span id="Properties-2078"><a href="#Properties-2078"><span class="linenos">2078</span></a> <span class="s2">"LANGUAGE"</span><span class="p">:</span> <span class="n">LanguageProperty</span><span class="p">,</span> +</span><span id="Properties-2079"><a href="#Properties-2079"><span class="linenos">2079</span></a> <span class="s2">"LOCATION"</span><span class="p">:</span> <span class="n">LocationProperty</span><span class="p">,</span> +</span><span id="Properties-2080"><a href="#Properties-2080"><span class="linenos">2080</span></a> <span class="s2">"PARTITIONED_BY"</span><span class="p">:</span> <span class="n">PartitionedByProperty</span><span class="p">,</span> +</span><span id="Properties-2081"><a href="#Properties-2081"><span class="linenos">2081</span></a> <span class="s2">"RETURNS"</span><span class="p">:</span> <span class="n">ReturnsProperty</span><span class="p">,</span> +</span><span id="Properties-2082"><a href="#Properties-2082"><span class="linenos">2082</span></a> <span class="s2">"ROW_FORMAT"</span><span class="p">:</span> <span class="n">RowFormatProperty</span><span class="p">,</span> +</span><span id="Properties-2083"><a href="#Properties-2083"><span class="linenos">2083</span></a> <span class="s2">"SORTKEY"</span><span class="p">:</span> <span class="n">SortKeyProperty</span><span class="p">,</span> +</span><span id="Properties-2084"><a href="#Properties-2084"><span class="linenos">2084</span></a> <span class="p">}</span> +</span><span id="Properties-2085"><a href="#Properties-2085"><span class="linenos">2085</span></a> +</span><span id="Properties-2086"><a href="#Properties-2086"><span class="linenos">2086</span></a> <span class="n">PROPERTY_TO_NAME</span> <span class="o">=</span> <span class="p">{</span><span class="n">v</span><span class="p">:</span> <span class="n">k</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">NAME_TO_PROPERTY</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span> +</span><span id="Properties-2087"><a href="#Properties-2087"><span class="linenos">2087</span></a> +</span><span id="Properties-2088"><a href="#Properties-2088"><span class="linenos">2088</span></a> <span class="c1"># CREATE property locations</span> +</span><span id="Properties-2089"><a href="#Properties-2089"><span class="linenos">2089</span></a> <span class="c1"># Form: schema specified</span> +</span><span id="Properties-2090"><a href="#Properties-2090"><span class="linenos">2090</span></a> <span class="c1"># create [POST_CREATE]</span> +</span><span id="Properties-2091"><a href="#Properties-2091"><span class="linenos">2091</span></a> <span class="c1"># table a [POST_NAME]</span> +</span><span id="Properties-2092"><a href="#Properties-2092"><span class="linenos">2092</span></a> <span class="c1"># (b int) [POST_SCHEMA]</span> +</span><span id="Properties-2093"><a href="#Properties-2093"><span class="linenos">2093</span></a> <span class="c1"># with ([POST_WITH])</span> +</span><span id="Properties-2094"><a href="#Properties-2094"><span class="linenos">2094</span></a> <span class="c1"># index (b) [POST_INDEX]</span> +</span><span id="Properties-2095"><a href="#Properties-2095"><span class="linenos">2095</span></a> <span class="c1">#</span> +</span><span id="Properties-2096"><a href="#Properties-2096"><span class="linenos">2096</span></a> <span class="c1"># Form: alias selection</span> +</span><span id="Properties-2097"><a href="#Properties-2097"><span class="linenos">2097</span></a> <span class="c1"># create [POST_CREATE]</span> +</span><span id="Properties-2098"><a href="#Properties-2098"><span class="linenos">2098</span></a> <span class="c1"># table a [POST_NAME]</span> +</span><span id="Properties-2099"><a href="#Properties-2099"><span class="linenos">2099</span></a> <span class="c1"># as [POST_ALIAS] (select * from b) [POST_EXPRESSION]</span> +</span><span id="Properties-2100"><a href="#Properties-2100"><span class="linenos">2100</span></a> <span class="c1"># index (c) [POST_INDEX]</span> +</span><span id="Properties-2101"><a href="#Properties-2101"><span class="linenos">2101</span></a> <span class="k">class</span> <span class="nc">Location</span><span class="p">(</span><span class="n">AutoName</span><span class="p">):</span> +</span><span id="Properties-2102"><a href="#Properties-2102"><span class="linenos">2102</span></a> <span class="n">POST_CREATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="Properties-2103"><a href="#Properties-2103"><span class="linenos">2103</span></a> <span class="n">POST_NAME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="Properties-2104"><a href="#Properties-2104"><span class="linenos">2104</span></a> <span class="n">POST_SCHEMA</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="Properties-2105"><a href="#Properties-2105"><span class="linenos">2105</span></a> <span class="n">POST_WITH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="Properties-2106"><a href="#Properties-2106"><span class="linenos">2106</span></a> <span class="n">POST_ALIAS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="Properties-2107"><a href="#Properties-2107"><span class="linenos">2107</span></a> <span class="n">POST_EXPRESSION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="Properties-2108"><a href="#Properties-2108"><span class="linenos">2108</span></a> <span class="n">POST_INDEX</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="Properties-2109"><a href="#Properties-2109"><span class="linenos">2109</span></a> <span class="n">UNSUPPORTED</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="Properties-2110"><a href="#Properties-2110"><span class="linenos">2110</span></a> +</span><span id="Properties-2111"><a href="#Properties-2111"><span class="linenos">2111</span></a> <span class="nd">@classmethod</span> +</span><span id="Properties-2112"><a href="#Properties-2112"><span class="linenos">2112</span></a> <span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">properties_dict</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">)</span> <span class="o">-></span> <span class="n">Properties</span><span class="p">:</span> +</span><span id="Properties-2113"><a href="#Properties-2113"><span class="linenos">2113</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Properties-2114"><a href="#Properties-2114"><span class="linenos">2114</span></a> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">properties_dict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> +</span><span id="Properties-2115"><a href="#Properties-2115"><span class="linenos">2115</span></a> <span class="n">property_cls</span> <span class="o">=</span> <span class="bp">cls</span><span class="o">.</span><span class="n">NAME_TO_PROPERTY</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span> +</span><span id="Properties-2116"><a href="#Properties-2116"><span class="linenos">2116</span></a> <span class="k">if</span> <span class="n">property_cls</span><span class="p">:</span> +</span><span id="Properties-2117"><a href="#Properties-2117"><span class="linenos">2117</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">property_cls</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">convert</span><span class="p">(</span><span class="n">value</span><span class="p">)))</span> +</span><span id="Properties-2118"><a href="#Properties-2118"><span class="linenos">2118</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Properties-2119"><a href="#Properties-2119"><span class="linenos">2119</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Property</span><span class="p">(</span><span class="n">this</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">key</span><span class="p">),</span> <span class="n">value</span><span class="o">=</span><span class="n">convert</span><span class="p">(</span><span class="n">value</span><span class="p">)))</span> +</span><span id="Properties-2120"><a href="#Properties-2120"><span class="linenos">2120</span></a> +</span><span id="Properties-2121"><a href="#Properties-2121"><span class="linenos">2121</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> </span></pre></div> @@ -22512,17 +22593,17 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#Properties.from_dict"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Properties.from_dict-2107"><a href="#Properties.from_dict-2107"><span class="linenos">2107</span></a> <span class="nd">@classmethod</span> -</span><span id="Properties.from_dict-2108"><a href="#Properties.from_dict-2108"><span class="linenos">2108</span></a> <span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">properties_dict</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">)</span> <span class="o">-></span> <span class="n">Properties</span><span class="p">:</span> -</span><span id="Properties.from_dict-2109"><a href="#Properties.from_dict-2109"><span class="linenos">2109</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Properties.from_dict-2110"><a href="#Properties.from_dict-2110"><span class="linenos">2110</span></a> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">properties_dict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> -</span><span id="Properties.from_dict-2111"><a href="#Properties.from_dict-2111"><span class="linenos">2111</span></a> <span class="n">property_cls</span> <span class="o">=</span> <span class="bp">cls</span><span class="o">.</span><span class="n">NAME_TO_PROPERTY</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span> -</span><span id="Properties.from_dict-2112"><a href="#Properties.from_dict-2112"><span class="linenos">2112</span></a> <span class="k">if</span> <span class="n">property_cls</span><span class="p">:</span> -</span><span id="Properties.from_dict-2113"><a href="#Properties.from_dict-2113"><span class="linenos">2113</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">property_cls</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">convert</span><span class="p">(</span><span class="n">value</span><span class="p">)))</span> -</span><span id="Properties.from_dict-2114"><a href="#Properties.from_dict-2114"><span class="linenos">2114</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Properties.from_dict-2115"><a href="#Properties.from_dict-2115"><span class="linenos">2115</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Property</span><span class="p">(</span><span class="n">this</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">key</span><span class="p">),</span> <span class="n">value</span><span class="o">=</span><span class="n">convert</span><span class="p">(</span><span class="n">value</span><span class="p">)))</span> -</span><span id="Properties.from_dict-2116"><a href="#Properties.from_dict-2116"><span class="linenos">2116</span></a> -</span><span id="Properties.from_dict-2117"><a href="#Properties.from_dict-2117"><span class="linenos">2117</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Properties.from_dict-2111"><a href="#Properties.from_dict-2111"><span class="linenos">2111</span></a> <span class="nd">@classmethod</span> +</span><span id="Properties.from_dict-2112"><a href="#Properties.from_dict-2112"><span class="linenos">2112</span></a> <span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">properties_dict</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">)</span> <span class="o">-></span> <span class="n">Properties</span><span class="p">:</span> +</span><span id="Properties.from_dict-2113"><a href="#Properties.from_dict-2113"><span class="linenos">2113</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Properties.from_dict-2114"><a href="#Properties.from_dict-2114"><span class="linenos">2114</span></a> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">properties_dict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> +</span><span id="Properties.from_dict-2115"><a href="#Properties.from_dict-2115"><span class="linenos">2115</span></a> <span class="n">property_cls</span> <span class="o">=</span> <span class="bp">cls</span><span class="o">.</span><span class="n">NAME_TO_PROPERTY</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span> +</span><span id="Properties.from_dict-2116"><a href="#Properties.from_dict-2116"><span class="linenos">2116</span></a> <span class="k">if</span> <span class="n">property_cls</span><span class="p">:</span> +</span><span id="Properties.from_dict-2117"><a href="#Properties.from_dict-2117"><span class="linenos">2117</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">property_cls</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">convert</span><span class="p">(</span><span class="n">value</span><span class="p">)))</span> +</span><span id="Properties.from_dict-2118"><a href="#Properties.from_dict-2118"><span class="linenos">2118</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Properties.from_dict-2119"><a href="#Properties.from_dict-2119"><span class="linenos">2119</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Property</span><span class="p">(</span><span class="n">this</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">key</span><span class="p">),</span> <span class="n">value</span><span class="o">=</span><span class="n">convert</span><span class="p">(</span><span class="n">value</span><span class="p">)))</span> +</span><span id="Properties.from_dict-2120"><a href="#Properties.from_dict-2120"><span class="linenos">2120</span></a> +</span><span id="Properties.from_dict-2121"><a href="#Properties.from_dict-2121"><span class="linenos">2121</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> </span></pre></div> @@ -22587,15 +22668,15 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#Properties.Location"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Properties.Location-2097"><a href="#Properties.Location-2097"><span class="linenos">2097</span></a> <span class="k">class</span> <span class="nc">Location</span><span class="p">(</span><span class="n">AutoName</span><span class="p">):</span> -</span><span id="Properties.Location-2098"><a href="#Properties.Location-2098"><span class="linenos">2098</span></a> <span class="n">POST_CREATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="Properties.Location-2099"><a href="#Properties.Location-2099"><span class="linenos">2099</span></a> <span class="n">POST_NAME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="Properties.Location-2100"><a href="#Properties.Location-2100"><span class="linenos">2100</span></a> <span class="n">POST_SCHEMA</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="Properties.Location-2101"><a href="#Properties.Location-2101"><span class="linenos">2101</span></a> <span class="n">POST_WITH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="Properties.Location-2102"><a href="#Properties.Location-2102"><span class="linenos">2102</span></a> <span class="n">POST_ALIAS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="Properties.Location-2103"><a href="#Properties.Location-2103"><span class="linenos">2103</span></a> <span class="n">POST_EXPRESSION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="Properties.Location-2104"><a href="#Properties.Location-2104"><span class="linenos">2104</span></a> <span class="n">POST_INDEX</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="Properties.Location-2105"><a href="#Properties.Location-2105"><span class="linenos">2105</span></a> <span class="n">UNSUPPORTED</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Properties.Location-2101"><a href="#Properties.Location-2101"><span class="linenos">2101</span></a> <span class="k">class</span> <span class="nc">Location</span><span class="p">(</span><span class="n">AutoName</span><span class="p">):</span> +</span><span id="Properties.Location-2102"><a href="#Properties.Location-2102"><span class="linenos">2102</span></a> <span class="n">POST_CREATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="Properties.Location-2103"><a href="#Properties.Location-2103"><span class="linenos">2103</span></a> <span class="n">POST_NAME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="Properties.Location-2104"><a href="#Properties.Location-2104"><span class="linenos">2104</span></a> <span class="n">POST_SCHEMA</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="Properties.Location-2105"><a href="#Properties.Location-2105"><span class="linenos">2105</span></a> <span class="n">POST_WITH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="Properties.Location-2106"><a href="#Properties.Location-2106"><span class="linenos">2106</span></a> <span class="n">POST_ALIAS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="Properties.Location-2107"><a href="#Properties.Location-2107"><span class="linenos">2107</span></a> <span class="n">POST_EXPRESSION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="Properties.Location-2108"><a href="#Properties.Location-2108"><span class="linenos">2108</span></a> <span class="n">POST_INDEX</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="Properties.Location-2109"><a href="#Properties.Location-2109"><span class="linenos">2109</span></a> <span class="n">UNSUPPORTED</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> </span></pre></div> @@ -22721,8 +22802,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#Qualify"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Qualify-2120"><a href="#Qualify-2120"><span class="linenos">2120</span></a><span class="k">class</span> <span class="nc">Qualify</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Qualify-2121"><a href="#Qualify-2121"><span class="linenos">2121</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Qualify-2124"><a href="#Qualify-2124"><span class="linenos">2124</span></a><span class="k">class</span> <span class="nc">Qualify</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Qualify-2125"><a href="#Qualify-2125"><span class="linenos">2125</span></a> <span class="k">pass</span> </span></pre></div> @@ -22786,8 +22867,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#Return"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Return-2125"><a href="#Return-2125"><span class="linenos">2125</span></a><span class="k">class</span> <span class="nc">Return</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Return-2126"><a href="#Return-2126"><span class="linenos">2126</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Return-2129"><a href="#Return-2129"><span class="linenos">2129</span></a><span class="k">class</span> <span class="nc">Return</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Return-2130"><a href="#Return-2130"><span class="linenos">2130</span></a> <span class="k">pass</span> </span></pre></div> @@ -22851,8 +22932,8 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#Reference"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Reference-2129"><a href="#Reference-2129"><span class="linenos">2129</span></a><span class="k">class</span> <span class="nc">Reference</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Reference-2130"><a href="#Reference-2130"><span class="linenos">2130</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"options"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Reference-2133"><a href="#Reference-2133"><span class="linenos">2133</span></a><span class="k">class</span> <span class="nc">Reference</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Reference-2134"><a href="#Reference-2134"><span class="linenos">2134</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"options"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -22916,17 +22997,17 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#Tuple"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Tuple-2133"><a href="#Tuple-2133"><span class="linenos">2133</span></a><span class="k">class</span> <span class="nc">Tuple</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Tuple-2134"><a href="#Tuple-2134"><span class="linenos">2134</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="Tuple-2135"><a href="#Tuple-2135"><span class="linenos">2135</span></a> -</span><span id="Tuple-2136"><a href="#Tuple-2136"><span class="linenos">2136</span></a> <span class="k">def</span> <span class="nf">isin</span><span class="p">(</span> -</span><span id="Tuple-2137"><a href="#Tuple-2137"><span class="linenos">2137</span></a> <span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="n">query</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="Tuple-2138"><a href="#Tuple-2138"><span class="linenos">2138</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">In</span><span class="p">:</span> -</span><span id="Tuple-2139"><a href="#Tuple-2139"><span class="linenos">2139</span></a> <span class="k">return</span> <span class="n">In</span><span class="p">(</span> -</span><span id="Tuple-2140"><a href="#Tuple-2140"><span class="linenos">2140</span></a> <span class="n">this</span><span class="o">=</span><span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">),</span> -</span><span id="Tuple-2141"><a href="#Tuple-2141"><span class="linenos">2141</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">],</span> -</span><span id="Tuple-2142"><a href="#Tuple-2142"><span class="linenos">2142</span></a> <span class="n">query</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">query</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="k">if</span> <span class="n">query</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Tuple-2143"><a href="#Tuple-2143"><span class="linenos">2143</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Tuple-2137"><a href="#Tuple-2137"><span class="linenos">2137</span></a><span class="k">class</span> <span class="nc">Tuple</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Tuple-2138"><a href="#Tuple-2138"><span class="linenos">2138</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="Tuple-2139"><a href="#Tuple-2139"><span class="linenos">2139</span></a> +</span><span id="Tuple-2140"><a href="#Tuple-2140"><span class="linenos">2140</span></a> <span class="k">def</span> <span class="nf">isin</span><span class="p">(</span> +</span><span id="Tuple-2141"><a href="#Tuple-2141"><span class="linenos">2141</span></a> <span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="n">query</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="Tuple-2142"><a href="#Tuple-2142"><span class="linenos">2142</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">In</span><span class="p">:</span> +</span><span id="Tuple-2143"><a href="#Tuple-2143"><span class="linenos">2143</span></a> <span class="k">return</span> <span class="n">In</span><span class="p">(</span> +</span><span id="Tuple-2144"><a href="#Tuple-2144"><span class="linenos">2144</span></a> <span class="n">this</span><span class="o">=</span><span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">),</span> +</span><span id="Tuple-2145"><a href="#Tuple-2145"><span class="linenos">2145</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">],</span> +</span><span id="Tuple-2146"><a href="#Tuple-2146"><span class="linenos">2146</span></a> <span class="n">query</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">query</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="k">if</span> <span class="n">query</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Tuple-2147"><a href="#Tuple-2147"><span class="linenos">2147</span></a> <span class="p">)</span> </span></pre></div> @@ -22943,14 +23024,14 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#Tuple.isin"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Tuple.isin-2136"><a href="#Tuple.isin-2136"><span class="linenos">2136</span></a> <span class="k">def</span> <span class="nf">isin</span><span class="p">(</span> -</span><span id="Tuple.isin-2137"><a href="#Tuple.isin-2137"><span class="linenos">2137</span></a> <span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="n">query</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="Tuple.isin-2138"><a href="#Tuple.isin-2138"><span class="linenos">2138</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">In</span><span class="p">:</span> -</span><span id="Tuple.isin-2139"><a href="#Tuple.isin-2139"><span class="linenos">2139</span></a> <span class="k">return</span> <span class="n">In</span><span class="p">(</span> -</span><span id="Tuple.isin-2140"><a href="#Tuple.isin-2140"><span class="linenos">2140</span></a> <span class="n">this</span><span class="o">=</span><span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">),</span> -</span><span id="Tuple.isin-2141"><a href="#Tuple.isin-2141"><span class="linenos">2141</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">],</span> -</span><span id="Tuple.isin-2142"><a href="#Tuple.isin-2142"><span class="linenos">2142</span></a> <span class="n">query</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">query</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="k">if</span> <span class="n">query</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Tuple.isin-2143"><a href="#Tuple.isin-2143"><span class="linenos">2143</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Tuple.isin-2140"><a href="#Tuple.isin-2140"><span class="linenos">2140</span></a> <span class="k">def</span> <span class="nf">isin</span><span class="p">(</span> +</span><span id="Tuple.isin-2141"><a href="#Tuple.isin-2141"><span class="linenos">2141</span></a> <span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="n">query</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="Tuple.isin-2142"><a href="#Tuple.isin-2142"><span class="linenos">2142</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">In</span><span class="p">:</span> +</span><span id="Tuple.isin-2143"><a href="#Tuple.isin-2143"><span class="linenos">2143</span></a> <span class="k">return</span> <span class="n">In</span><span class="p">(</span> +</span><span id="Tuple.isin-2144"><a href="#Tuple.isin-2144"><span class="linenos">2144</span></a> <span class="n">this</span><span class="o">=</span><span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">),</span> +</span><span id="Tuple.isin-2145"><a href="#Tuple.isin-2145"><span class="linenos">2145</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">],</span> +</span><span id="Tuple.isin-2146"><a href="#Tuple.isin-2146"><span class="linenos">2146</span></a> <span class="n">query</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">query</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="k">if</span> <span class="n">query</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Tuple.isin-2147"><a href="#Tuple.isin-2147"><span class="linenos">2147</span></a> <span class="p">)</span> </span></pre></div> @@ -23015,84 +23096,84 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#Subqueryable"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Subqueryable-2146"><a href="#Subqueryable-2146"><span class="linenos">2146</span></a><span class="k">class</span> <span class="nc">Subqueryable</span><span class="p">(</span><span class="n">Unionable</span><span class="p">):</span> -</span><span id="Subqueryable-2147"><a href="#Subqueryable-2147"><span class="linenos">2147</span></a> <span class="k">def</span> <span class="nf">subquery</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">alias</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Subquery</span><span class="p">:</span> -</span><span id="Subqueryable-2148"><a href="#Subqueryable-2148"><span class="linenos">2148</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Subqueryable-2149"><a href="#Subqueryable-2149"><span class="linenos">2149</span></a><span class="sd"> Convert this expression to an aliased expression that can be used as a Subquery.</span> -</span><span id="Subqueryable-2150"><a href="#Subqueryable-2150"><span class="linenos">2150</span></a> -</span><span id="Subqueryable-2151"><a href="#Subqueryable-2151"><span class="linenos">2151</span></a><span class="sd"> Example:</span> -</span><span id="Subqueryable-2152"><a href="#Subqueryable-2152"><span class="linenos">2152</span></a><span class="sd"> >>> subquery = Select().select("x").from_("tbl").subquery()</span> -</span><span id="Subqueryable-2153"><a href="#Subqueryable-2153"><span class="linenos">2153</span></a><span class="sd"> >>> Select().select("x").from_(subquery).sql()</span> -</span><span id="Subqueryable-2154"><a href="#Subqueryable-2154"><span class="linenos">2154</span></a><span class="sd"> 'SELECT x FROM (SELECT x FROM tbl)'</span> -</span><span id="Subqueryable-2155"><a href="#Subqueryable-2155"><span class="linenos">2155</span></a> -</span><span id="Subqueryable-2156"><a href="#Subqueryable-2156"><span class="linenos">2156</span></a><span class="sd"> Args:</span> -</span><span id="Subqueryable-2157"><a href="#Subqueryable-2157"><span class="linenos">2157</span></a><span class="sd"> alias (str | Identifier): an optional alias for the subquery</span> -</span><span id="Subqueryable-2158"><a href="#Subqueryable-2158"><span class="linenos">2158</span></a><span class="sd"> copy (bool): if `False`, modify this expression instance in-place.</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Subqueryable-2150"><a href="#Subqueryable-2150"><span class="linenos">2150</span></a><span class="k">class</span> <span class="nc">Subqueryable</span><span class="p">(</span><span class="n">Unionable</span><span class="p">):</span> +</span><span id="Subqueryable-2151"><a href="#Subqueryable-2151"><span class="linenos">2151</span></a> <span class="k">def</span> <span class="nf">subquery</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">alias</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Subquery</span><span class="p">:</span> +</span><span id="Subqueryable-2152"><a href="#Subqueryable-2152"><span class="linenos">2152</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Subqueryable-2153"><a href="#Subqueryable-2153"><span class="linenos">2153</span></a><span class="sd"> Convert this expression to an aliased expression that can be used as a Subquery.</span> +</span><span id="Subqueryable-2154"><a href="#Subqueryable-2154"><span class="linenos">2154</span></a> +</span><span id="Subqueryable-2155"><a href="#Subqueryable-2155"><span class="linenos">2155</span></a><span class="sd"> Example:</span> +</span><span id="Subqueryable-2156"><a href="#Subqueryable-2156"><span class="linenos">2156</span></a><span class="sd"> >>> subquery = Select().select("x").from_("tbl").subquery()</span> +</span><span id="Subqueryable-2157"><a href="#Subqueryable-2157"><span class="linenos">2157</span></a><span class="sd"> >>> Select().select("x").from_(subquery).sql()</span> +</span><span id="Subqueryable-2158"><a href="#Subqueryable-2158"><span class="linenos">2158</span></a><span class="sd"> 'SELECT x FROM (SELECT x FROM tbl)'</span> </span><span id="Subqueryable-2159"><a href="#Subqueryable-2159"><span class="linenos">2159</span></a> -</span><span id="Subqueryable-2160"><a href="#Subqueryable-2160"><span class="linenos">2160</span></a><span class="sd"> Returns:</span> -</span><span id="Subqueryable-2161"><a href="#Subqueryable-2161"><span class="linenos">2161</span></a><span class="sd"> Alias: the subquery</span> -</span><span id="Subqueryable-2162"><a href="#Subqueryable-2162"><span class="linenos">2162</span></a><span class="sd"> """</span> -</span><span id="Subqueryable-2163"><a href="#Subqueryable-2163"><span class="linenos">2163</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="Subqueryable-2164"><a href="#Subqueryable-2164"><span class="linenos">2164</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> -</span><span id="Subqueryable-2165"><a href="#Subqueryable-2165"><span class="linenos">2165</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">))</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="Subqueryable-2166"><a href="#Subqueryable-2166"><span class="linenos">2166</span></a> -</span><span id="Subqueryable-2167"><a href="#Subqueryable-2167"><span class="linenos">2167</span></a> <span class="k">return</span> <span class="n">Subquery</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">instance</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> -</span><span id="Subqueryable-2168"><a href="#Subqueryable-2168"><span class="linenos">2168</span></a> -</span><span id="Subqueryable-2169"><a href="#Subqueryable-2169"><span class="linenos">2169</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span> -</span><span id="Subqueryable-2170"><a href="#Subqueryable-2170"><span class="linenos">2170</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="Subqueryable-2171"><a href="#Subqueryable-2171"><span class="linenos">2171</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Subqueryable-2172"><a href="#Subqueryable-2172"><span class="linenos">2172</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span> -</span><span id="Subqueryable-2173"><a href="#Subqueryable-2173"><span class="linenos">2173</span></a> -</span><span id="Subqueryable-2174"><a href="#Subqueryable-2174"><span class="linenos">2174</span></a> <span class="nd">@property</span> -</span><span id="Subqueryable-2175"><a href="#Subqueryable-2175"><span class="linenos">2175</span></a> <span class="k">def</span> <span class="nf">ctes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Subqueryable-2176"><a href="#Subqueryable-2176"><span class="linenos">2176</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"with"</span><span class="p">)</span> -</span><span id="Subqueryable-2177"><a href="#Subqueryable-2177"><span class="linenos">2177</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">with_</span><span class="p">:</span> -</span><span id="Subqueryable-2178"><a href="#Subqueryable-2178"><span class="linenos">2178</span></a> <span class="k">return</span> <span class="p">[]</span> -</span><span id="Subqueryable-2179"><a href="#Subqueryable-2179"><span class="linenos">2179</span></a> <span class="k">return</span> <span class="n">with_</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="Subqueryable-2180"><a href="#Subqueryable-2180"><span class="linenos">2180</span></a> -</span><span id="Subqueryable-2181"><a href="#Subqueryable-2181"><span class="linenos">2181</span></a> <span class="nd">@property</span> -</span><span id="Subqueryable-2182"><a href="#Subqueryable-2182"><span class="linenos">2182</span></a> <span class="k">def</span> <span class="nf">selects</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Subqueryable-2183"><a href="#Subqueryable-2183"><span class="linenos">2183</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s2">"Subqueryable objects must implement `selects`"</span><span class="p">)</span> +</span><span id="Subqueryable-2160"><a href="#Subqueryable-2160"><span class="linenos">2160</span></a><span class="sd"> Args:</span> +</span><span id="Subqueryable-2161"><a href="#Subqueryable-2161"><span class="linenos">2161</span></a><span class="sd"> alias (str | Identifier): an optional alias for the subquery</span> +</span><span id="Subqueryable-2162"><a href="#Subqueryable-2162"><span class="linenos">2162</span></a><span class="sd"> copy (bool): if `False`, modify this expression instance in-place.</span> +</span><span id="Subqueryable-2163"><a href="#Subqueryable-2163"><span class="linenos">2163</span></a> +</span><span id="Subqueryable-2164"><a href="#Subqueryable-2164"><span class="linenos">2164</span></a><span class="sd"> Returns:</span> +</span><span id="Subqueryable-2165"><a href="#Subqueryable-2165"><span class="linenos">2165</span></a><span class="sd"> Alias: the subquery</span> +</span><span id="Subqueryable-2166"><a href="#Subqueryable-2166"><span class="linenos">2166</span></a><span class="sd"> """</span> +</span><span id="Subqueryable-2167"><a href="#Subqueryable-2167"><span class="linenos">2167</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="Subqueryable-2168"><a href="#Subqueryable-2168"><span class="linenos">2168</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> +</span><span id="Subqueryable-2169"><a href="#Subqueryable-2169"><span class="linenos">2169</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">))</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="Subqueryable-2170"><a href="#Subqueryable-2170"><span class="linenos">2170</span></a> +</span><span id="Subqueryable-2171"><a href="#Subqueryable-2171"><span class="linenos">2171</span></a> <span class="k">return</span> <span class="n">Subquery</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">instance</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> +</span><span id="Subqueryable-2172"><a href="#Subqueryable-2172"><span class="linenos">2172</span></a> +</span><span id="Subqueryable-2173"><a href="#Subqueryable-2173"><span class="linenos">2173</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span> +</span><span id="Subqueryable-2174"><a href="#Subqueryable-2174"><span class="linenos">2174</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="Subqueryable-2175"><a href="#Subqueryable-2175"><span class="linenos">2175</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Subqueryable-2176"><a href="#Subqueryable-2176"><span class="linenos">2176</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span> +</span><span id="Subqueryable-2177"><a href="#Subqueryable-2177"><span class="linenos">2177</span></a> +</span><span id="Subqueryable-2178"><a href="#Subqueryable-2178"><span class="linenos">2178</span></a> <span class="nd">@property</span> +</span><span id="Subqueryable-2179"><a href="#Subqueryable-2179"><span class="linenos">2179</span></a> <span class="k">def</span> <span class="nf">ctes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Subqueryable-2180"><a href="#Subqueryable-2180"><span class="linenos">2180</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"with"</span><span class="p">)</span> +</span><span id="Subqueryable-2181"><a href="#Subqueryable-2181"><span class="linenos">2181</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">with_</span><span class="p">:</span> +</span><span id="Subqueryable-2182"><a href="#Subqueryable-2182"><span class="linenos">2182</span></a> <span class="k">return</span> <span class="p">[]</span> +</span><span id="Subqueryable-2183"><a href="#Subqueryable-2183"><span class="linenos">2183</span></a> <span class="k">return</span> <span class="n">with_</span><span class="o">.</span><span class="n">expressions</span> </span><span id="Subqueryable-2184"><a href="#Subqueryable-2184"><span class="linenos">2184</span></a> </span><span id="Subqueryable-2185"><a href="#Subqueryable-2185"><span class="linenos">2185</span></a> <span class="nd">@property</span> -</span><span id="Subqueryable-2186"><a href="#Subqueryable-2186"><span class="linenos">2186</span></a> <span class="k">def</span> <span class="nf">named_selects</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Subqueryable-2187"><a href="#Subqueryable-2187"><span class="linenos">2187</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s2">"Subqueryable objects must implement `named_selects`"</span><span class="p">)</span> +</span><span id="Subqueryable-2186"><a href="#Subqueryable-2186"><span class="linenos">2186</span></a> <span class="k">def</span> <span class="nf">selects</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Subqueryable-2187"><a href="#Subqueryable-2187"><span class="linenos">2187</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s2">"Subqueryable objects must implement `selects`"</span><span class="p">)</span> </span><span id="Subqueryable-2188"><a href="#Subqueryable-2188"><span class="linenos">2188</span></a> -</span><span id="Subqueryable-2189"><a href="#Subqueryable-2189"><span class="linenos">2189</span></a> <span class="k">def</span> <span class="nf">with_</span><span class="p">(</span> -</span><span id="Subqueryable-2190"><a href="#Subqueryable-2190"><span class="linenos">2190</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Subqueryable-2191"><a href="#Subqueryable-2191"><span class="linenos">2191</span></a> <span class="n">alias</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="Subqueryable-2192"><a href="#Subqueryable-2192"><span class="linenos">2192</span></a> <span class="n">as_</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="Subqueryable-2193"><a href="#Subqueryable-2193"><span class="linenos">2193</span></a> <span class="n">recursive</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Subqueryable-2194"><a href="#Subqueryable-2194"><span class="linenos">2194</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Subqueryable-2195"><a href="#Subqueryable-2195"><span class="linenos">2195</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Subqueryable-2196"><a href="#Subqueryable-2196"><span class="linenos">2196</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Subqueryable-2197"><a href="#Subqueryable-2197"><span class="linenos">2197</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Subqueryable-2198"><a href="#Subqueryable-2198"><span class="linenos">2198</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Subqueryable</span><span class="p">:</span> -</span><span id="Subqueryable-2199"><a href="#Subqueryable-2199"><span class="linenos">2199</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Subqueryable-2200"><a href="#Subqueryable-2200"><span class="linenos">2200</span></a><span class="sd"> Append to or set the common table expressions.</span> -</span><span id="Subqueryable-2201"><a href="#Subqueryable-2201"><span class="linenos">2201</span></a> -</span><span id="Subqueryable-2202"><a href="#Subqueryable-2202"><span class="linenos">2202</span></a><span class="sd"> Example:</span> -</span><span id="Subqueryable-2203"><a href="#Subqueryable-2203"><span class="linenos">2203</span></a><span class="sd"> >>> Select().with_("tbl2", as_="SELECT * FROM tbl").select("x").from_("tbl2").sql()</span> -</span><span id="Subqueryable-2204"><a href="#Subqueryable-2204"><span class="linenos">2204</span></a><span class="sd"> 'WITH tbl2 AS (SELECT * FROM tbl) SELECT x FROM tbl2'</span> +</span><span id="Subqueryable-2189"><a href="#Subqueryable-2189"><span class="linenos">2189</span></a> <span class="nd">@property</span> +</span><span id="Subqueryable-2190"><a href="#Subqueryable-2190"><span class="linenos">2190</span></a> <span class="k">def</span> <span class="nf">named_selects</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Subqueryable-2191"><a href="#Subqueryable-2191"><span class="linenos">2191</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s2">"Subqueryable objects must implement `named_selects`"</span><span class="p">)</span> +</span><span id="Subqueryable-2192"><a href="#Subqueryable-2192"><span class="linenos">2192</span></a> +</span><span id="Subqueryable-2193"><a href="#Subqueryable-2193"><span class="linenos">2193</span></a> <span class="k">def</span> <span class="nf">with_</span><span class="p">(</span> +</span><span id="Subqueryable-2194"><a href="#Subqueryable-2194"><span class="linenos">2194</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Subqueryable-2195"><a href="#Subqueryable-2195"><span class="linenos">2195</span></a> <span class="n">alias</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="Subqueryable-2196"><a href="#Subqueryable-2196"><span class="linenos">2196</span></a> <span class="n">as_</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="Subqueryable-2197"><a href="#Subqueryable-2197"><span class="linenos">2197</span></a> <span class="n">recursive</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Subqueryable-2198"><a href="#Subqueryable-2198"><span class="linenos">2198</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Subqueryable-2199"><a href="#Subqueryable-2199"><span class="linenos">2199</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Subqueryable-2200"><a href="#Subqueryable-2200"><span class="linenos">2200</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Subqueryable-2201"><a href="#Subqueryable-2201"><span class="linenos">2201</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Subqueryable-2202"><a href="#Subqueryable-2202"><span class="linenos">2202</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Subqueryable</span><span class="p">:</span> +</span><span id="Subqueryable-2203"><a href="#Subqueryable-2203"><span class="linenos">2203</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Subqueryable-2204"><a href="#Subqueryable-2204"><span class="linenos">2204</span></a><span class="sd"> Append to or set the common table expressions.</span> </span><span id="Subqueryable-2205"><a href="#Subqueryable-2205"><span class="linenos">2205</span></a> -</span><span id="Subqueryable-2206"><a href="#Subqueryable-2206"><span class="linenos">2206</span></a><span class="sd"> Args:</span> -</span><span id="Subqueryable-2207"><a href="#Subqueryable-2207"><span class="linenos">2207</span></a><span class="sd"> alias: the SQL code string to parse as the table name.</span> -</span><span id="Subqueryable-2208"><a href="#Subqueryable-2208"><span class="linenos">2208</span></a><span class="sd"> If an `Expression` instance is passed, this is used as-is.</span> -</span><span id="Subqueryable-2209"><a href="#Subqueryable-2209"><span class="linenos">2209</span></a><span class="sd"> as_: the SQL code string to parse as the table expression.</span> -</span><span id="Subqueryable-2210"><a href="#Subqueryable-2210"><span class="linenos">2210</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Subqueryable-2211"><a href="#Subqueryable-2211"><span class="linenos">2211</span></a><span class="sd"> recursive: set the RECURSIVE part of the expression. Defaults to `False`.</span> -</span><span id="Subqueryable-2212"><a href="#Subqueryable-2212"><span class="linenos">2212</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="Subqueryable-2213"><a href="#Subqueryable-2213"><span class="linenos">2213</span></a><span class="sd"> Otherwise, this resets the expressions.</span> -</span><span id="Subqueryable-2214"><a href="#Subqueryable-2214"><span class="linenos">2214</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="Subqueryable-2215"><a href="#Subqueryable-2215"><span class="linenos">2215</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Subqueryable-2216"><a href="#Subqueryable-2216"><span class="linenos">2216</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Subqueryable-2217"><a href="#Subqueryable-2217"><span class="linenos">2217</span></a> -</span><span id="Subqueryable-2218"><a href="#Subqueryable-2218"><span class="linenos">2218</span></a><span class="sd"> Returns:</span> -</span><span id="Subqueryable-2219"><a href="#Subqueryable-2219"><span class="linenos">2219</span></a><span class="sd"> The modified expression.</span> -</span><span id="Subqueryable-2220"><a href="#Subqueryable-2220"><span class="linenos">2220</span></a><span class="sd"> """</span> -</span><span id="Subqueryable-2221"><a href="#Subqueryable-2221"><span class="linenos">2221</span></a> <span class="k">return</span> <span class="n">_apply_cte_builder</span><span class="p">(</span> -</span><span id="Subqueryable-2222"><a href="#Subqueryable-2222"><span class="linenos">2222</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">alias</span><span class="p">,</span> <span class="n">as_</span><span class="p">,</span> <span class="n">recursive</span><span class="o">=</span><span class="n">recursive</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="Subqueryable-2223"><a href="#Subqueryable-2223"><span class="linenos">2223</span></a> <span class="p">)</span> +</span><span id="Subqueryable-2206"><a href="#Subqueryable-2206"><span class="linenos">2206</span></a><span class="sd"> Example:</span> +</span><span id="Subqueryable-2207"><a href="#Subqueryable-2207"><span class="linenos">2207</span></a><span class="sd"> >>> Select().with_("tbl2", as_="SELECT * FROM tbl").select("x").from_("tbl2").sql()</span> +</span><span id="Subqueryable-2208"><a href="#Subqueryable-2208"><span class="linenos">2208</span></a><span class="sd"> 'WITH tbl2 AS (SELECT * FROM tbl) SELECT x FROM tbl2'</span> +</span><span id="Subqueryable-2209"><a href="#Subqueryable-2209"><span class="linenos">2209</span></a> +</span><span id="Subqueryable-2210"><a href="#Subqueryable-2210"><span class="linenos">2210</span></a><span class="sd"> Args:</span> +</span><span id="Subqueryable-2211"><a href="#Subqueryable-2211"><span class="linenos">2211</span></a><span class="sd"> alias: the SQL code string to parse as the table name.</span> +</span><span id="Subqueryable-2212"><a href="#Subqueryable-2212"><span class="linenos">2212</span></a><span class="sd"> If an `Expression` instance is passed, this is used as-is.</span> +</span><span id="Subqueryable-2213"><a href="#Subqueryable-2213"><span class="linenos">2213</span></a><span class="sd"> as_: the SQL code string to parse as the table expression.</span> +</span><span id="Subqueryable-2214"><a href="#Subqueryable-2214"><span class="linenos">2214</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="Subqueryable-2215"><a href="#Subqueryable-2215"><span class="linenos">2215</span></a><span class="sd"> recursive: set the RECURSIVE part of the expression. Defaults to `False`.</span> +</span><span id="Subqueryable-2216"><a href="#Subqueryable-2216"><span class="linenos">2216</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="Subqueryable-2217"><a href="#Subqueryable-2217"><span class="linenos">2217</span></a><span class="sd"> Otherwise, this resets the expressions.</span> +</span><span id="Subqueryable-2218"><a href="#Subqueryable-2218"><span class="linenos">2218</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="Subqueryable-2219"><a href="#Subqueryable-2219"><span class="linenos">2219</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Subqueryable-2220"><a href="#Subqueryable-2220"><span class="linenos">2220</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Subqueryable-2221"><a href="#Subqueryable-2221"><span class="linenos">2221</span></a> +</span><span id="Subqueryable-2222"><a href="#Subqueryable-2222"><span class="linenos">2222</span></a><span class="sd"> Returns:</span> +</span><span id="Subqueryable-2223"><a href="#Subqueryable-2223"><span class="linenos">2223</span></a><span class="sd"> The modified expression.</span> +</span><span id="Subqueryable-2224"><a href="#Subqueryable-2224"><span class="linenos">2224</span></a><span class="sd"> """</span> +</span><span id="Subqueryable-2225"><a href="#Subqueryable-2225"><span class="linenos">2225</span></a> <span class="k">return</span> <span class="n">_apply_cte_builder</span><span class="p">(</span> +</span><span id="Subqueryable-2226"><a href="#Subqueryable-2226"><span class="linenos">2226</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">alias</span><span class="p">,</span> <span class="n">as_</span><span class="p">,</span> <span class="n">recursive</span><span class="o">=</span><span class="n">recursive</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="Subqueryable-2227"><a href="#Subqueryable-2227"><span class="linenos">2227</span></a> <span class="p">)</span> </span></pre></div> @@ -23109,27 +23190,27 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#Subqueryable.subquery"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Subqueryable.subquery-2147"><a href="#Subqueryable.subquery-2147"><span class="linenos">2147</span></a> <span class="k">def</span> <span class="nf">subquery</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">alias</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Subquery</span><span class="p">:</span> -</span><span id="Subqueryable.subquery-2148"><a href="#Subqueryable.subquery-2148"><span class="linenos">2148</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Subqueryable.subquery-2149"><a href="#Subqueryable.subquery-2149"><span class="linenos">2149</span></a><span class="sd"> Convert this expression to an aliased expression that can be used as a Subquery.</span> -</span><span id="Subqueryable.subquery-2150"><a href="#Subqueryable.subquery-2150"><span class="linenos">2150</span></a> -</span><span id="Subqueryable.subquery-2151"><a href="#Subqueryable.subquery-2151"><span class="linenos">2151</span></a><span class="sd"> Example:</span> -</span><span id="Subqueryable.subquery-2152"><a href="#Subqueryable.subquery-2152"><span class="linenos">2152</span></a><span class="sd"> >>> subquery = Select().select("x").from_("tbl").subquery()</span> -</span><span id="Subqueryable.subquery-2153"><a href="#Subqueryable.subquery-2153"><span class="linenos">2153</span></a><span class="sd"> >>> Select().select("x").from_(subquery).sql()</span> -</span><span id="Subqueryable.subquery-2154"><a href="#Subqueryable.subquery-2154"><span class="linenos">2154</span></a><span class="sd"> 'SELECT x FROM (SELECT x FROM tbl)'</span> -</span><span id="Subqueryable.subquery-2155"><a href="#Subqueryable.subquery-2155"><span class="linenos">2155</span></a> -</span><span id="Subqueryable.subquery-2156"><a href="#Subqueryable.subquery-2156"><span class="linenos">2156</span></a><span class="sd"> Args:</span> -</span><span id="Subqueryable.subquery-2157"><a href="#Subqueryable.subquery-2157"><span class="linenos">2157</span></a><span class="sd"> alias (str | Identifier): an optional alias for the subquery</span> -</span><span id="Subqueryable.subquery-2158"><a href="#Subqueryable.subquery-2158"><span class="linenos">2158</span></a><span class="sd"> copy (bool): if `False`, modify this expression instance in-place.</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Subqueryable.subquery-2151"><a href="#Subqueryable.subquery-2151"><span class="linenos">2151</span></a> <span class="k">def</span> <span class="nf">subquery</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">alias</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Subquery</span><span class="p">:</span> +</span><span id="Subqueryable.subquery-2152"><a href="#Subqueryable.subquery-2152"><span class="linenos">2152</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Subqueryable.subquery-2153"><a href="#Subqueryable.subquery-2153"><span class="linenos">2153</span></a><span class="sd"> Convert this expression to an aliased expression that can be used as a Subquery.</span> +</span><span id="Subqueryable.subquery-2154"><a href="#Subqueryable.subquery-2154"><span class="linenos">2154</span></a> +</span><span id="Subqueryable.subquery-2155"><a href="#Subqueryable.subquery-2155"><span class="linenos">2155</span></a><span class="sd"> Example:</span> +</span><span id="Subqueryable.subquery-2156"><a href="#Subqueryable.subquery-2156"><span class="linenos">2156</span></a><span class="sd"> >>> subquery = Select().select("x").from_("tbl").subquery()</span> +</span><span id="Subqueryable.subquery-2157"><a href="#Subqueryable.subquery-2157"><span class="linenos">2157</span></a><span class="sd"> >>> Select().select("x").from_(subquery).sql()</span> +</span><span id="Subqueryable.subquery-2158"><a href="#Subqueryable.subquery-2158"><span class="linenos">2158</span></a><span class="sd"> 'SELECT x FROM (SELECT x FROM tbl)'</span> </span><span id="Subqueryable.subquery-2159"><a href="#Subqueryable.subquery-2159"><span class="linenos">2159</span></a> -</span><span id="Subqueryable.subquery-2160"><a href="#Subqueryable.subquery-2160"><span class="linenos">2160</span></a><span class="sd"> Returns:</span> -</span><span id="Subqueryable.subquery-2161"><a href="#Subqueryable.subquery-2161"><span class="linenos">2161</span></a><span class="sd"> Alias: the subquery</span> -</span><span id="Subqueryable.subquery-2162"><a href="#Subqueryable.subquery-2162"><span class="linenos">2162</span></a><span class="sd"> """</span> -</span><span id="Subqueryable.subquery-2163"><a href="#Subqueryable.subquery-2163"><span class="linenos">2163</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="Subqueryable.subquery-2164"><a href="#Subqueryable.subquery-2164"><span class="linenos">2164</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> -</span><span id="Subqueryable.subquery-2165"><a href="#Subqueryable.subquery-2165"><span class="linenos">2165</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">))</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="Subqueryable.subquery-2166"><a href="#Subqueryable.subquery-2166"><span class="linenos">2166</span></a> -</span><span id="Subqueryable.subquery-2167"><a href="#Subqueryable.subquery-2167"><span class="linenos">2167</span></a> <span class="k">return</span> <span class="n">Subquery</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">instance</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> +</span><span id="Subqueryable.subquery-2160"><a href="#Subqueryable.subquery-2160"><span class="linenos">2160</span></a><span class="sd"> Args:</span> +</span><span id="Subqueryable.subquery-2161"><a href="#Subqueryable.subquery-2161"><span class="linenos">2161</span></a><span class="sd"> alias (str | Identifier): an optional alias for the subquery</span> +</span><span id="Subqueryable.subquery-2162"><a href="#Subqueryable.subquery-2162"><span class="linenos">2162</span></a><span class="sd"> copy (bool): if `False`, modify this expression instance in-place.</span> +</span><span id="Subqueryable.subquery-2163"><a href="#Subqueryable.subquery-2163"><span class="linenos">2163</span></a> +</span><span id="Subqueryable.subquery-2164"><a href="#Subqueryable.subquery-2164"><span class="linenos">2164</span></a><span class="sd"> Returns:</span> +</span><span id="Subqueryable.subquery-2165"><a href="#Subqueryable.subquery-2165"><span class="linenos">2165</span></a><span class="sd"> Alias: the subquery</span> +</span><span id="Subqueryable.subquery-2166"><a href="#Subqueryable.subquery-2166"><span class="linenos">2166</span></a><span class="sd"> """</span> +</span><span id="Subqueryable.subquery-2167"><a href="#Subqueryable.subquery-2167"><span class="linenos">2167</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="Subqueryable.subquery-2168"><a href="#Subqueryable.subquery-2168"><span class="linenos">2168</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> +</span><span id="Subqueryable.subquery-2169"><a href="#Subqueryable.subquery-2169"><span class="linenos">2169</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">))</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="Subqueryable.subquery-2170"><a href="#Subqueryable.subquery-2170"><span class="linenos">2170</span></a> +</span><span id="Subqueryable.subquery-2171"><a href="#Subqueryable.subquery-2171"><span class="linenos">2171</span></a> <span class="k">return</span> <span class="n">Subquery</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">instance</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> </span></pre></div> @@ -23173,10 +23254,10 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#Subqueryable.limit"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Subqueryable.limit-2169"><a href="#Subqueryable.limit-2169"><span class="linenos">2169</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span> -</span><span id="Subqueryable.limit-2170"><a href="#Subqueryable.limit-2170"><span class="linenos">2170</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="Subqueryable.limit-2171"><a href="#Subqueryable.limit-2171"><span class="linenos">2171</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Subqueryable.limit-2172"><a href="#Subqueryable.limit-2172"><span class="linenos">2172</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Subqueryable.limit-2173"><a href="#Subqueryable.limit-2173"><span class="linenos">2173</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span> +</span><span id="Subqueryable.limit-2174"><a href="#Subqueryable.limit-2174"><span class="linenos">2174</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="Subqueryable.limit-2175"><a href="#Subqueryable.limit-2175"><span class="linenos">2175</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Subqueryable.limit-2176"><a href="#Subqueryable.limit-2176"><span class="linenos">2176</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span> </span></pre></div> @@ -23194,41 +23275,41 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#Subqueryable.with_"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Subqueryable.with_-2189"><a href="#Subqueryable.with_-2189"><span class="linenos">2189</span></a> <span class="k">def</span> <span class="nf">with_</span><span class="p">(</span> -</span><span id="Subqueryable.with_-2190"><a href="#Subqueryable.with_-2190"><span class="linenos">2190</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Subqueryable.with_-2191"><a href="#Subqueryable.with_-2191"><span class="linenos">2191</span></a> <span class="n">alias</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="Subqueryable.with_-2192"><a href="#Subqueryable.with_-2192"><span class="linenos">2192</span></a> <span class="n">as_</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="Subqueryable.with_-2193"><a href="#Subqueryable.with_-2193"><span class="linenos">2193</span></a> <span class="n">recursive</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Subqueryable.with_-2194"><a href="#Subqueryable.with_-2194"><span class="linenos">2194</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Subqueryable.with_-2195"><a href="#Subqueryable.with_-2195"><span class="linenos">2195</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Subqueryable.with_-2196"><a href="#Subqueryable.with_-2196"><span class="linenos">2196</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Subqueryable.with_-2197"><a href="#Subqueryable.with_-2197"><span class="linenos">2197</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Subqueryable.with_-2198"><a href="#Subqueryable.with_-2198"><span class="linenos">2198</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Subqueryable</span><span class="p">:</span> -</span><span id="Subqueryable.with_-2199"><a href="#Subqueryable.with_-2199"><span class="linenos">2199</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Subqueryable.with_-2200"><a href="#Subqueryable.with_-2200"><span class="linenos">2200</span></a><span class="sd"> Append to or set the common table expressions.</span> -</span><span id="Subqueryable.with_-2201"><a href="#Subqueryable.with_-2201"><span class="linenos">2201</span></a> -</span><span id="Subqueryable.with_-2202"><a href="#Subqueryable.with_-2202"><span class="linenos">2202</span></a><span class="sd"> Example:</span> -</span><span id="Subqueryable.with_-2203"><a href="#Subqueryable.with_-2203"><span class="linenos">2203</span></a><span class="sd"> >>> Select().with_("tbl2", as_="SELECT * FROM tbl").select("x").from_("tbl2").sql()</span> -</span><span id="Subqueryable.with_-2204"><a href="#Subqueryable.with_-2204"><span class="linenos">2204</span></a><span class="sd"> 'WITH tbl2 AS (SELECT * FROM tbl) SELECT x FROM tbl2'</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Subqueryable.with_-2193"><a href="#Subqueryable.with_-2193"><span class="linenos">2193</span></a> <span class="k">def</span> <span class="nf">with_</span><span class="p">(</span> +</span><span id="Subqueryable.with_-2194"><a href="#Subqueryable.with_-2194"><span class="linenos">2194</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Subqueryable.with_-2195"><a href="#Subqueryable.with_-2195"><span class="linenos">2195</span></a> <span class="n">alias</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="Subqueryable.with_-2196"><a href="#Subqueryable.with_-2196"><span class="linenos">2196</span></a> <span class="n">as_</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="Subqueryable.with_-2197"><a href="#Subqueryable.with_-2197"><span class="linenos">2197</span></a> <span class="n">recursive</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Subqueryable.with_-2198"><a href="#Subqueryable.with_-2198"><span class="linenos">2198</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Subqueryable.with_-2199"><a href="#Subqueryable.with_-2199"><span class="linenos">2199</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Subqueryable.with_-2200"><a href="#Subqueryable.with_-2200"><span class="linenos">2200</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Subqueryable.with_-2201"><a href="#Subqueryable.with_-2201"><span class="linenos">2201</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Subqueryable.with_-2202"><a href="#Subqueryable.with_-2202"><span class="linenos">2202</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Subqueryable</span><span class="p">:</span> +</span><span id="Subqueryable.with_-2203"><a href="#Subqueryable.with_-2203"><span class="linenos">2203</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Subqueryable.with_-2204"><a href="#Subqueryable.with_-2204"><span class="linenos">2204</span></a><span class="sd"> Append to or set the common table expressions.</span> </span><span id="Subqueryable.with_-2205"><a href="#Subqueryable.with_-2205"><span class="linenos">2205</span></a> -</span><span id="Subqueryable.with_-2206"><a href="#Subqueryable.with_-2206"><span class="linenos">2206</span></a><span class="sd"> Args:</span> -</span><span id="Subqueryable.with_-2207"><a href="#Subqueryable.with_-2207"><span class="linenos">2207</span></a><span class="sd"> alias: the SQL code string to parse as the table name.</span> -</span><span id="Subqueryable.with_-2208"><a href="#Subqueryable.with_-2208"><span class="linenos">2208</span></a><span class="sd"> If an `Expression` instance is passed, this is used as-is.</span> -</span><span id="Subqueryable.with_-2209"><a href="#Subqueryable.with_-2209"><span class="linenos">2209</span></a><span class="sd"> as_: the SQL code string to parse as the table expression.</span> -</span><span id="Subqueryable.with_-2210"><a href="#Subqueryable.with_-2210"><span class="linenos">2210</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Subqueryable.with_-2211"><a href="#Subqueryable.with_-2211"><span class="linenos">2211</span></a><span class="sd"> recursive: set the RECURSIVE part of the expression. Defaults to `False`.</span> -</span><span id="Subqueryable.with_-2212"><a href="#Subqueryable.with_-2212"><span class="linenos">2212</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="Subqueryable.with_-2213"><a href="#Subqueryable.with_-2213"><span class="linenos">2213</span></a><span class="sd"> Otherwise, this resets the expressions.</span> -</span><span id="Subqueryable.with_-2214"><a href="#Subqueryable.with_-2214"><span class="linenos">2214</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="Subqueryable.with_-2215"><a href="#Subqueryable.with_-2215"><span class="linenos">2215</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Subqueryable.with_-2216"><a href="#Subqueryable.with_-2216"><span class="linenos">2216</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Subqueryable.with_-2217"><a href="#Subqueryable.with_-2217"><span class="linenos">2217</span></a> -</span><span id="Subqueryable.with_-2218"><a href="#Subqueryable.with_-2218"><span class="linenos">2218</span></a><span class="sd"> Returns:</span> -</span><span id="Subqueryable.with_-2219"><a href="#Subqueryable.with_-2219"><span class="linenos">2219</span></a><span class="sd"> The modified expression.</span> -</span><span id="Subqueryable.with_-2220"><a href="#Subqueryable.with_-2220"><span class="linenos">2220</span></a><span class="sd"> """</span> -</span><span id="Subqueryable.with_-2221"><a href="#Subqueryable.with_-2221"><span class="linenos">2221</span></a> <span class="k">return</span> <span class="n">_apply_cte_builder</span><span class="p">(</span> -</span><span id="Subqueryable.with_-2222"><a href="#Subqueryable.with_-2222"><span class="linenos">2222</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">alias</span><span class="p">,</span> <span class="n">as_</span><span class="p">,</span> <span class="n">recursive</span><span class="o">=</span><span class="n">recursive</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="Subqueryable.with_-2223"><a href="#Subqueryable.with_-2223"><span class="linenos">2223</span></a> <span class="p">)</span> +</span><span id="Subqueryable.with_-2206"><a href="#Subqueryable.with_-2206"><span class="linenos">2206</span></a><span class="sd"> Example:</span> +</span><span id="Subqueryable.with_-2207"><a href="#Subqueryable.with_-2207"><span class="linenos">2207</span></a><span class="sd"> >>> Select().with_("tbl2", as_="SELECT * FROM tbl").select("x").from_("tbl2").sql()</span> +</span><span id="Subqueryable.with_-2208"><a href="#Subqueryable.with_-2208"><span class="linenos">2208</span></a><span class="sd"> 'WITH tbl2 AS (SELECT * FROM tbl) SELECT x FROM tbl2'</span> +</span><span id="Subqueryable.with_-2209"><a href="#Subqueryable.with_-2209"><span class="linenos">2209</span></a> +</span><span id="Subqueryable.with_-2210"><a href="#Subqueryable.with_-2210"><span class="linenos">2210</span></a><span class="sd"> Args:</span> +</span><span id="Subqueryable.with_-2211"><a href="#Subqueryable.with_-2211"><span class="linenos">2211</span></a><span class="sd"> alias: the SQL code string to parse as the table name.</span> +</span><span id="Subqueryable.with_-2212"><a href="#Subqueryable.with_-2212"><span class="linenos">2212</span></a><span class="sd"> If an `Expression` instance is passed, this is used as-is.</span> +</span><span id="Subqueryable.with_-2213"><a href="#Subqueryable.with_-2213"><span class="linenos">2213</span></a><span class="sd"> as_: the SQL code string to parse as the table expression.</span> +</span><span id="Subqueryable.with_-2214"><a href="#Subqueryable.with_-2214"><span class="linenos">2214</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="Subqueryable.with_-2215"><a href="#Subqueryable.with_-2215"><span class="linenos">2215</span></a><span class="sd"> recursive: set the RECURSIVE part of the expression. Defaults to `False`.</span> +</span><span id="Subqueryable.with_-2216"><a href="#Subqueryable.with_-2216"><span class="linenos">2216</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="Subqueryable.with_-2217"><a href="#Subqueryable.with_-2217"><span class="linenos">2217</span></a><span class="sd"> Otherwise, this resets the expressions.</span> +</span><span id="Subqueryable.with_-2218"><a href="#Subqueryable.with_-2218"><span class="linenos">2218</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="Subqueryable.with_-2219"><a href="#Subqueryable.with_-2219"><span class="linenos">2219</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Subqueryable.with_-2220"><a href="#Subqueryable.with_-2220"><span class="linenos">2220</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Subqueryable.with_-2221"><a href="#Subqueryable.with_-2221"><span class="linenos">2221</span></a> +</span><span id="Subqueryable.with_-2222"><a href="#Subqueryable.with_-2222"><span class="linenos">2222</span></a><span class="sd"> Returns:</span> +</span><span id="Subqueryable.with_-2223"><a href="#Subqueryable.with_-2223"><span class="linenos">2223</span></a><span class="sd"> The modified expression.</span> +</span><span id="Subqueryable.with_-2224"><a href="#Subqueryable.with_-2224"><span class="linenos">2224</span></a><span class="sd"> """</span> +</span><span id="Subqueryable.with_-2225"><a href="#Subqueryable.with_-2225"><span class="linenos">2225</span></a> <span class="k">return</span> <span class="n">_apply_cte_builder</span><span class="p">(</span> +</span><span id="Subqueryable.with_-2226"><a href="#Subqueryable.with_-2226"><span class="linenos">2226</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">alias</span><span class="p">,</span> <span class="n">as_</span><span class="p">,</span> <span class="n">recursive</span><span class="o">=</span><span class="n">recursive</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="Subqueryable.with_-2227"><a href="#Subqueryable.with_-2227"><span class="linenos">2227</span></a> <span class="p">)</span> </span></pre></div> @@ -23332,35 +23413,35 @@ Otherwise, this resets the expressions.</li> </div> <a class="headerlink" href="#Table"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Table-2249"><a href="#Table-2249"><span class="linenos">2249</span></a><span class="k">class</span> <span class="nc">Table</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Table-2250"><a href="#Table-2250"><span class="linenos">2250</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Table-2251"><a href="#Table-2251"><span class="linenos">2251</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Table-2252"><a href="#Table-2252"><span class="linenos">2252</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Table-2253"><a href="#Table-2253"><span class="linenos">2253</span></a> <span class="s2">"db"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Table-2254"><a href="#Table-2254"><span class="linenos">2254</span></a> <span class="s2">"catalog"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Table-2255"><a href="#Table-2255"><span class="linenos">2255</span></a> <span class="s2">"laterals"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Table-2256"><a href="#Table-2256"><span class="linenos">2256</span></a> <span class="s2">"joins"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Table-2257"><a href="#Table-2257"><span class="linenos">2257</span></a> <span class="s2">"pivots"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Table-2258"><a href="#Table-2258"><span class="linenos">2258</span></a> <span class="s2">"hints"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Table-2259"><a href="#Table-2259"><span class="linenos">2259</span></a> <span class="s2">"system_time"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Table-2260"><a href="#Table-2260"><span class="linenos">2260</span></a> <span class="p">}</span> -</span><span id="Table-2261"><a href="#Table-2261"><span class="linenos">2261</span></a> -</span><span id="Table-2262"><a href="#Table-2262"><span class="linenos">2262</span></a> <span class="nd">@property</span> -</span><span id="Table-2263"><a href="#Table-2263"><span class="linenos">2263</span></a> <span class="k">def</span> <span class="nf">db</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Table-2264"><a href="#Table-2264"><span class="linenos">2264</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"db"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Table-2253"><a href="#Table-2253"><span class="linenos">2253</span></a><span class="k">class</span> <span class="nc">Table</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Table-2254"><a href="#Table-2254"><span class="linenos">2254</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Table-2255"><a href="#Table-2255"><span class="linenos">2255</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Table-2256"><a href="#Table-2256"><span class="linenos">2256</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Table-2257"><a href="#Table-2257"><span class="linenos">2257</span></a> <span class="s2">"db"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Table-2258"><a href="#Table-2258"><span class="linenos">2258</span></a> <span class="s2">"catalog"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Table-2259"><a href="#Table-2259"><span class="linenos">2259</span></a> <span class="s2">"laterals"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Table-2260"><a href="#Table-2260"><span class="linenos">2260</span></a> <span class="s2">"joins"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Table-2261"><a href="#Table-2261"><span class="linenos">2261</span></a> <span class="s2">"pivots"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Table-2262"><a href="#Table-2262"><span class="linenos">2262</span></a> <span class="s2">"hints"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Table-2263"><a href="#Table-2263"><span class="linenos">2263</span></a> <span class="s2">"system_time"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Table-2264"><a href="#Table-2264"><span class="linenos">2264</span></a> <span class="p">}</span> </span><span id="Table-2265"><a href="#Table-2265"><span class="linenos">2265</span></a> </span><span id="Table-2266"><a href="#Table-2266"><span class="linenos">2266</span></a> <span class="nd">@property</span> -</span><span id="Table-2267"><a href="#Table-2267"><span class="linenos">2267</span></a> <span class="k">def</span> <span class="nf">catalog</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Table-2268"><a href="#Table-2268"><span class="linenos">2268</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">)</span> +</span><span id="Table-2267"><a href="#Table-2267"><span class="linenos">2267</span></a> <span class="k">def</span> <span class="nf">db</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Table-2268"><a href="#Table-2268"><span class="linenos">2268</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"db"</span><span class="p">)</span> </span><span id="Table-2269"><a href="#Table-2269"><span class="linenos">2269</span></a> </span><span id="Table-2270"><a href="#Table-2270"><span class="linenos">2270</span></a> <span class="nd">@property</span> -</span><span id="Table-2271"><a href="#Table-2271"><span class="linenos">2271</span></a> <span class="k">def</span> <span class="nf">parts</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Identifier</span><span class="p">]:</span> -</span><span id="Table-2272"><a href="#Table-2272"><span class="linenos">2272</span></a><span class="w"> </span><span class="sd">"""Return the parts of a table in order catalog, db, table."""</span> -</span><span id="Table-2273"><a href="#Table-2273"><span class="linenos">2273</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="Table-2274"><a href="#Table-2274"><span class="linenos">2274</span></a> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">Identifier</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="n">part</span><span class="p">])</span> -</span><span id="Table-2275"><a href="#Table-2275"><span class="linenos">2275</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"catalog"</span><span class="p">,</span> <span class="s2">"db"</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Table-2276"><a href="#Table-2276"><span class="linenos">2276</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> -</span><span id="Table-2277"><a href="#Table-2277"><span class="linenos">2277</span></a> <span class="p">]</span> +</span><span id="Table-2271"><a href="#Table-2271"><span class="linenos">2271</span></a> <span class="k">def</span> <span class="nf">catalog</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Table-2272"><a href="#Table-2272"><span class="linenos">2272</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">)</span> +</span><span id="Table-2273"><a href="#Table-2273"><span class="linenos">2273</span></a> +</span><span id="Table-2274"><a href="#Table-2274"><span class="linenos">2274</span></a> <span class="nd">@property</span> +</span><span id="Table-2275"><a href="#Table-2275"><span class="linenos">2275</span></a> <span class="k">def</span> <span class="nf">parts</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Identifier</span><span class="p">]:</span> +</span><span id="Table-2276"><a href="#Table-2276"><span class="linenos">2276</span></a><span class="w"> </span><span class="sd">"""Return the parts of a table in order catalog, db, table."""</span> +</span><span id="Table-2277"><a href="#Table-2277"><span class="linenos">2277</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="Table-2278"><a href="#Table-2278"><span class="linenos">2278</span></a> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">Identifier</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="n">part</span><span class="p">])</span> +</span><span id="Table-2279"><a href="#Table-2279"><span class="linenos">2279</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"catalog"</span><span class="p">,</span> <span class="s2">"db"</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Table-2280"><a href="#Table-2280"><span class="linenos">2280</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> +</span><span id="Table-2281"><a href="#Table-2281"><span class="linenos">2281</span></a> <span class="p">]</span> </span></pre></div> @@ -23437,12 +23518,12 @@ Otherwise, this resets the expressions.</li> </div> <a class="headerlink" href="#SystemTime"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SystemTime-2281"><a href="#SystemTime-2281"><span class="linenos">2281</span></a><span class="k">class</span> <span class="nc">SystemTime</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="SystemTime-2282"><a href="#SystemTime-2282"><span class="linenos">2282</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="SystemTime-2283"><a href="#SystemTime-2283"><span class="linenos">2283</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="SystemTime-2284"><a href="#SystemTime-2284"><span class="linenos">2284</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="SystemTime-2285"><a href="#SystemTime-2285"><span class="linenos">2285</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="SystemTime-2286"><a href="#SystemTime-2286"><span class="linenos">2286</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SystemTime-2285"><a href="#SystemTime-2285"><span class="linenos">2285</span></a><span class="k">class</span> <span class="nc">SystemTime</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="SystemTime-2286"><a href="#SystemTime-2286"><span class="linenos">2286</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="SystemTime-2287"><a href="#SystemTime-2287"><span class="linenos">2287</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="SystemTime-2288"><a href="#SystemTime-2288"><span class="linenos">2288</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="SystemTime-2289"><a href="#SystemTime-2289"><span class="linenos">2289</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="SystemTime-2290"><a href="#SystemTime-2290"><span class="linenos">2290</span></a> <span class="p">}</span> </span></pre></div> @@ -23506,96 +23587,96 @@ Otherwise, this resets the expressions.</li> </div> <a class="headerlink" href="#Union"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Union-2289"><a href="#Union-2289"><span class="linenos">2289</span></a><span class="k">class</span> <span class="nc">Union</span><span class="p">(</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="Union-2290"><a href="#Union-2290"><span class="linenos">2290</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Union-2291"><a href="#Union-2291"><span class="linenos">2291</span></a> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Union-2292"><a href="#Union-2292"><span class="linenos">2292</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Union-2293"><a href="#Union-2293"><span class="linenos">2293</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Union-2294"><a href="#Union-2294"><span class="linenos">2294</span></a> <span class="s2">"distinct"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Union-2295"><a href="#Union-2295"><span class="linenos">2295</span></a> <span class="o">**</span><span class="n">QUERY_MODIFIERS</span><span class="p">,</span> -</span><span id="Union-2296"><a href="#Union-2296"><span class="linenos">2296</span></a> <span class="p">}</span> -</span><span id="Union-2297"><a href="#Union-2297"><span class="linenos">2297</span></a> -</span><span id="Union-2298"><a href="#Union-2298"><span class="linenos">2298</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span> -</span><span id="Union-2299"><a href="#Union-2299"><span class="linenos">2299</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="Union-2300"><a href="#Union-2300"><span class="linenos">2300</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Union-2301"><a href="#Union-2301"><span class="linenos">2301</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Union-2302"><a href="#Union-2302"><span class="linenos">2302</span></a><span class="sd"> Set the LIMIT expression.</span> -</span><span id="Union-2303"><a href="#Union-2303"><span class="linenos">2303</span></a> -</span><span id="Union-2304"><a href="#Union-2304"><span class="linenos">2304</span></a><span class="sd"> Example:</span> -</span><span id="Union-2305"><a href="#Union-2305"><span class="linenos">2305</span></a><span class="sd"> >>> select("1").union(select("1")).limit(1).sql()</span> -</span><span id="Union-2306"><a href="#Union-2306"><span class="linenos">2306</span></a><span class="sd"> 'SELECT * FROM (SELECT 1 UNION SELECT 1) AS _l_0 LIMIT 1'</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Union-2293"><a href="#Union-2293"><span class="linenos">2293</span></a><span class="k">class</span> <span class="nc">Union</span><span class="p">(</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="Union-2294"><a href="#Union-2294"><span class="linenos">2294</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Union-2295"><a href="#Union-2295"><span class="linenos">2295</span></a> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Union-2296"><a href="#Union-2296"><span class="linenos">2296</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Union-2297"><a href="#Union-2297"><span class="linenos">2297</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Union-2298"><a href="#Union-2298"><span class="linenos">2298</span></a> <span class="s2">"distinct"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Union-2299"><a href="#Union-2299"><span class="linenos">2299</span></a> <span class="o">**</span><span class="n">QUERY_MODIFIERS</span><span class="p">,</span> +</span><span id="Union-2300"><a href="#Union-2300"><span class="linenos">2300</span></a> <span class="p">}</span> +</span><span id="Union-2301"><a href="#Union-2301"><span class="linenos">2301</span></a> +</span><span id="Union-2302"><a href="#Union-2302"><span class="linenos">2302</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span> +</span><span id="Union-2303"><a href="#Union-2303"><span class="linenos">2303</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="Union-2304"><a href="#Union-2304"><span class="linenos">2304</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Union-2305"><a href="#Union-2305"><span class="linenos">2305</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Union-2306"><a href="#Union-2306"><span class="linenos">2306</span></a><span class="sd"> Set the LIMIT expression.</span> </span><span id="Union-2307"><a href="#Union-2307"><span class="linenos">2307</span></a> -</span><span id="Union-2308"><a href="#Union-2308"><span class="linenos">2308</span></a><span class="sd"> Args:</span> -</span><span id="Union-2309"><a href="#Union-2309"><span class="linenos">2309</span></a><span class="sd"> expression: the SQL code string to parse.</span> -</span><span id="Union-2310"><a href="#Union-2310"><span class="linenos">2310</span></a><span class="sd"> This can also be an integer.</span> -</span><span id="Union-2311"><a href="#Union-2311"><span class="linenos">2311</span></a><span class="sd"> If a `Limit` instance is passed, this is used as-is.</span> -</span><span id="Union-2312"><a href="#Union-2312"><span class="linenos">2312</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Limit`.</span> -</span><span id="Union-2313"><a href="#Union-2313"><span class="linenos">2313</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="Union-2314"><a href="#Union-2314"><span class="linenos">2314</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Union-2315"><a href="#Union-2315"><span class="linenos">2315</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Union-2316"><a href="#Union-2316"><span class="linenos">2316</span></a> -</span><span id="Union-2317"><a href="#Union-2317"><span class="linenos">2317</span></a><span class="sd"> Returns:</span> -</span><span id="Union-2318"><a href="#Union-2318"><span class="linenos">2318</span></a><span class="sd"> The limited subqueryable.</span> -</span><span id="Union-2319"><a href="#Union-2319"><span class="linenos">2319</span></a><span class="sd"> """</span> -</span><span id="Union-2320"><a href="#Union-2320"><span class="linenos">2320</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="Union-2321"><a href="#Union-2321"><span class="linenos">2321</span></a> <span class="n">select</span><span class="p">(</span><span class="s2">"*"</span><span class="p">)</span> -</span><span id="Union-2322"><a href="#Union-2322"><span class="linenos">2322</span></a> <span class="o">.</span><span class="n">from_</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">alias</span><span class="o">=</span><span class="s2">"_l_0"</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">))</span> -</span><span id="Union-2323"><a href="#Union-2323"><span class="linenos">2323</span></a> <span class="o">.</span><span class="n">limit</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="Union-2324"><a href="#Union-2324"><span class="linenos">2324</span></a> <span class="p">)</span> -</span><span id="Union-2325"><a href="#Union-2325"><span class="linenos">2325</span></a> -</span><span id="Union-2326"><a href="#Union-2326"><span class="linenos">2326</span></a> <span class="k">def</span> <span class="nf">select</span><span class="p">(</span> -</span><span id="Union-2327"><a href="#Union-2327"><span class="linenos">2327</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Union-2328"><a href="#Union-2328"><span class="linenos">2328</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Union-2329"><a href="#Union-2329"><span class="linenos">2329</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Union-2330"><a href="#Union-2330"><span class="linenos">2330</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Union-2331"><a href="#Union-2331"><span class="linenos">2331</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Union-2332"><a href="#Union-2332"><span class="linenos">2332</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Union-2333"><a href="#Union-2333"><span class="linenos">2333</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">:</span> -</span><span id="Union-2334"><a href="#Union-2334"><span class="linenos">2334</span></a><span class="w"> </span><span class="sd">"""Append to or set the SELECT of the union recursively.</span> -</span><span id="Union-2335"><a href="#Union-2335"><span class="linenos">2335</span></a> -</span><span id="Union-2336"><a href="#Union-2336"><span class="linenos">2336</span></a><span class="sd"> Example:</span> -</span><span id="Union-2337"><a href="#Union-2337"><span class="linenos">2337</span></a><span class="sd"> >>> from sqlglot import parse_one</span> -</span><span id="Union-2338"><a href="#Union-2338"><span class="linenos">2338</span></a><span class="sd"> >>> parse_one("select a from x union select a from y union select a from z").select("b").sql()</span> -</span><span id="Union-2339"><a href="#Union-2339"><span class="linenos">2339</span></a><span class="sd"> 'SELECT a, b FROM x UNION SELECT a, b FROM y UNION SELECT a, b FROM z'</span> -</span><span id="Union-2340"><a href="#Union-2340"><span class="linenos">2340</span></a> -</span><span id="Union-2341"><a href="#Union-2341"><span class="linenos">2341</span></a><span class="sd"> Args:</span> -</span><span id="Union-2342"><a href="#Union-2342"><span class="linenos">2342</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="Union-2343"><a href="#Union-2343"><span class="linenos">2343</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Union-2344"><a href="#Union-2344"><span class="linenos">2344</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="Union-2345"><a href="#Union-2345"><span class="linenos">2345</span></a><span class="sd"> Otherwise, this resets the expressions.</span> -</span><span id="Union-2346"><a href="#Union-2346"><span class="linenos">2346</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="Union-2347"><a href="#Union-2347"><span class="linenos">2347</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Union-2348"><a href="#Union-2348"><span class="linenos">2348</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Union-2349"><a href="#Union-2349"><span class="linenos">2349</span></a> -</span><span id="Union-2350"><a href="#Union-2350"><span class="linenos">2350</span></a><span class="sd"> Returns:</span> -</span><span id="Union-2351"><a href="#Union-2351"><span class="linenos">2351</span></a><span class="sd"> Union: the modified expression.</span> -</span><span id="Union-2352"><a href="#Union-2352"><span class="linenos">2352</span></a><span class="sd"> """</span> -</span><span id="Union-2353"><a href="#Union-2353"><span class="linenos">2353</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="k">if</span> <span class="n">copy</span> <span class="k">else</span> <span class="bp">self</span> -</span><span id="Union-2354"><a href="#Union-2354"><span class="linenos">2354</span></a> <span class="n">this</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">expressions</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="Union-2355"><a href="#Union-2355"><span class="linenos">2355</span></a> <span class="n">this</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span> -</span><span id="Union-2356"><a href="#Union-2356"><span class="linenos">2356</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="Union-2357"><a href="#Union-2357"><span class="linenos">2357</span></a> <span class="p">)</span> -</span><span id="Union-2358"><a href="#Union-2358"><span class="linenos">2358</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Union-2359"><a href="#Union-2359"><span class="linenos">2359</span></a> -</span><span id="Union-2360"><a href="#Union-2360"><span class="linenos">2360</span></a> <span class="nd">@property</span> -</span><span id="Union-2361"><a href="#Union-2361"><span class="linenos">2361</span></a> <span class="k">def</span> <span class="nf">named_selects</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Union-2362"><a href="#Union-2362"><span class="linenos">2362</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">named_selects</span> +</span><span id="Union-2308"><a href="#Union-2308"><span class="linenos">2308</span></a><span class="sd"> Example:</span> +</span><span id="Union-2309"><a href="#Union-2309"><span class="linenos">2309</span></a><span class="sd"> >>> select("1").union(select("1")).limit(1).sql()</span> +</span><span id="Union-2310"><a href="#Union-2310"><span class="linenos">2310</span></a><span class="sd"> 'SELECT * FROM (SELECT 1 UNION SELECT 1) AS _l_0 LIMIT 1'</span> +</span><span id="Union-2311"><a href="#Union-2311"><span class="linenos">2311</span></a> +</span><span id="Union-2312"><a href="#Union-2312"><span class="linenos">2312</span></a><span class="sd"> Args:</span> +</span><span id="Union-2313"><a href="#Union-2313"><span class="linenos">2313</span></a><span class="sd"> expression: the SQL code string to parse.</span> +</span><span id="Union-2314"><a href="#Union-2314"><span class="linenos">2314</span></a><span class="sd"> This can also be an integer.</span> +</span><span id="Union-2315"><a href="#Union-2315"><span class="linenos">2315</span></a><span class="sd"> If a `Limit` instance is passed, this is used as-is.</span> +</span><span id="Union-2316"><a href="#Union-2316"><span class="linenos">2316</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Limit`.</span> +</span><span id="Union-2317"><a href="#Union-2317"><span class="linenos">2317</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="Union-2318"><a href="#Union-2318"><span class="linenos">2318</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Union-2319"><a href="#Union-2319"><span class="linenos">2319</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Union-2320"><a href="#Union-2320"><span class="linenos">2320</span></a> +</span><span id="Union-2321"><a href="#Union-2321"><span class="linenos">2321</span></a><span class="sd"> Returns:</span> +</span><span id="Union-2322"><a href="#Union-2322"><span class="linenos">2322</span></a><span class="sd"> The limited subqueryable.</span> +</span><span id="Union-2323"><a href="#Union-2323"><span class="linenos">2323</span></a><span class="sd"> """</span> +</span><span id="Union-2324"><a href="#Union-2324"><span class="linenos">2324</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="Union-2325"><a href="#Union-2325"><span class="linenos">2325</span></a> <span class="n">select</span><span class="p">(</span><span class="s2">"*"</span><span class="p">)</span> +</span><span id="Union-2326"><a href="#Union-2326"><span class="linenos">2326</span></a> <span class="o">.</span><span class="n">from_</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">alias</span><span class="o">=</span><span class="s2">"_l_0"</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">))</span> +</span><span id="Union-2327"><a href="#Union-2327"><span class="linenos">2327</span></a> <span class="o">.</span><span class="n">limit</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="Union-2328"><a href="#Union-2328"><span class="linenos">2328</span></a> <span class="p">)</span> +</span><span id="Union-2329"><a href="#Union-2329"><span class="linenos">2329</span></a> +</span><span id="Union-2330"><a href="#Union-2330"><span class="linenos">2330</span></a> <span class="k">def</span> <span class="nf">select</span><span class="p">(</span> +</span><span id="Union-2331"><a href="#Union-2331"><span class="linenos">2331</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Union-2332"><a href="#Union-2332"><span class="linenos">2332</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Union-2333"><a href="#Union-2333"><span class="linenos">2333</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Union-2334"><a href="#Union-2334"><span class="linenos">2334</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Union-2335"><a href="#Union-2335"><span class="linenos">2335</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Union-2336"><a href="#Union-2336"><span class="linenos">2336</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Union-2337"><a href="#Union-2337"><span class="linenos">2337</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">:</span> +</span><span id="Union-2338"><a href="#Union-2338"><span class="linenos">2338</span></a><span class="w"> </span><span class="sd">"""Append to or set the SELECT of the union recursively.</span> +</span><span id="Union-2339"><a href="#Union-2339"><span class="linenos">2339</span></a> +</span><span id="Union-2340"><a href="#Union-2340"><span class="linenos">2340</span></a><span class="sd"> Example:</span> +</span><span id="Union-2341"><a href="#Union-2341"><span class="linenos">2341</span></a><span class="sd"> >>> from sqlglot import parse_one</span> +</span><span id="Union-2342"><a href="#Union-2342"><span class="linenos">2342</span></a><span class="sd"> >>> parse_one("select a from x union select a from y union select a from z").select("b").sql()</span> +</span><span id="Union-2343"><a href="#Union-2343"><span class="linenos">2343</span></a><span class="sd"> 'SELECT a, b FROM x UNION SELECT a, b FROM y UNION SELECT a, b FROM z'</span> +</span><span id="Union-2344"><a href="#Union-2344"><span class="linenos">2344</span></a> +</span><span id="Union-2345"><a href="#Union-2345"><span class="linenos">2345</span></a><span class="sd"> Args:</span> +</span><span id="Union-2346"><a href="#Union-2346"><span class="linenos">2346</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="Union-2347"><a href="#Union-2347"><span class="linenos">2347</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="Union-2348"><a href="#Union-2348"><span class="linenos">2348</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="Union-2349"><a href="#Union-2349"><span class="linenos">2349</span></a><span class="sd"> Otherwise, this resets the expressions.</span> +</span><span id="Union-2350"><a href="#Union-2350"><span class="linenos">2350</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="Union-2351"><a href="#Union-2351"><span class="linenos">2351</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Union-2352"><a href="#Union-2352"><span class="linenos">2352</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Union-2353"><a href="#Union-2353"><span class="linenos">2353</span></a> +</span><span id="Union-2354"><a href="#Union-2354"><span class="linenos">2354</span></a><span class="sd"> Returns:</span> +</span><span id="Union-2355"><a href="#Union-2355"><span class="linenos">2355</span></a><span class="sd"> Union: the modified expression.</span> +</span><span id="Union-2356"><a href="#Union-2356"><span class="linenos">2356</span></a><span class="sd"> """</span> +</span><span id="Union-2357"><a href="#Union-2357"><span class="linenos">2357</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="k">if</span> <span class="n">copy</span> <span class="k">else</span> <span class="bp">self</span> +</span><span id="Union-2358"><a href="#Union-2358"><span class="linenos">2358</span></a> <span class="n">this</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">expressions</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="Union-2359"><a href="#Union-2359"><span class="linenos">2359</span></a> <span class="n">this</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span> +</span><span id="Union-2360"><a href="#Union-2360"><span class="linenos">2360</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="Union-2361"><a href="#Union-2361"><span class="linenos">2361</span></a> <span class="p">)</span> +</span><span id="Union-2362"><a href="#Union-2362"><span class="linenos">2362</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="Union-2363"><a href="#Union-2363"><span class="linenos">2363</span></a> </span><span id="Union-2364"><a href="#Union-2364"><span class="linenos">2364</span></a> <span class="nd">@property</span> -</span><span id="Union-2365"><a href="#Union-2365"><span class="linenos">2365</span></a> <span class="k">def</span> <span class="nf">is_star</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="Union-2366"><a href="#Union-2366"><span class="linenos">2366</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">is_star</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">is_star</span> +</span><span id="Union-2365"><a href="#Union-2365"><span class="linenos">2365</span></a> <span class="k">def</span> <span class="nf">named_selects</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Union-2366"><a href="#Union-2366"><span class="linenos">2366</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">named_selects</span> </span><span id="Union-2367"><a href="#Union-2367"><span class="linenos">2367</span></a> </span><span id="Union-2368"><a href="#Union-2368"><span class="linenos">2368</span></a> <span class="nd">@property</span> -</span><span id="Union-2369"><a href="#Union-2369"><span class="linenos">2369</span></a> <span class="k">def</span> <span class="nf">selects</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Union-2370"><a href="#Union-2370"><span class="linenos">2370</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">selects</span> +</span><span id="Union-2369"><a href="#Union-2369"><span class="linenos">2369</span></a> <span class="k">def</span> <span class="nf">is_star</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Union-2370"><a href="#Union-2370"><span class="linenos">2370</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">is_star</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">is_star</span> </span><span id="Union-2371"><a href="#Union-2371"><span class="linenos">2371</span></a> </span><span id="Union-2372"><a href="#Union-2372"><span class="linenos">2372</span></a> <span class="nd">@property</span> -</span><span id="Union-2373"><a href="#Union-2373"><span class="linenos">2373</span></a> <span class="k">def</span> <span class="nf">left</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Union-2374"><a href="#Union-2374"><span class="linenos">2374</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span> +</span><span id="Union-2373"><a href="#Union-2373"><span class="linenos">2373</span></a> <span class="k">def</span> <span class="nf">selects</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Union-2374"><a href="#Union-2374"><span class="linenos">2374</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">selects</span> </span><span id="Union-2375"><a href="#Union-2375"><span class="linenos">2375</span></a> </span><span id="Union-2376"><a href="#Union-2376"><span class="linenos">2376</span></a> <span class="nd">@property</span> -</span><span id="Union-2377"><a href="#Union-2377"><span class="linenos">2377</span></a> <span class="k">def</span> <span class="nf">right</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Union-2378"><a href="#Union-2378"><span class="linenos">2378</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span> +</span><span id="Union-2377"><a href="#Union-2377"><span class="linenos">2377</span></a> <span class="k">def</span> <span class="nf">left</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Union-2378"><a href="#Union-2378"><span class="linenos">2378</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span> +</span><span id="Union-2379"><a href="#Union-2379"><span class="linenos">2379</span></a> +</span><span id="Union-2380"><a href="#Union-2380"><span class="linenos">2380</span></a> <span class="nd">@property</span> +</span><span id="Union-2381"><a href="#Union-2381"><span class="linenos">2381</span></a> <span class="k">def</span> <span class="nf">right</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Union-2382"><a href="#Union-2382"><span class="linenos">2382</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span> </span></pre></div> @@ -23612,33 +23693,33 @@ Otherwise, this resets the expressions.</li> </div> <a class="headerlink" href="#Union.limit"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Union.limit-2298"><a href="#Union.limit-2298"><span class="linenos">2298</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span> -</span><span id="Union.limit-2299"><a href="#Union.limit-2299"><span class="linenos">2299</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="Union.limit-2300"><a href="#Union.limit-2300"><span class="linenos">2300</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Union.limit-2301"><a href="#Union.limit-2301"><span class="linenos">2301</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Union.limit-2302"><a href="#Union.limit-2302"><span class="linenos">2302</span></a><span class="sd"> Set the LIMIT expression.</span> -</span><span id="Union.limit-2303"><a href="#Union.limit-2303"><span class="linenos">2303</span></a> -</span><span id="Union.limit-2304"><a href="#Union.limit-2304"><span class="linenos">2304</span></a><span class="sd"> Example:</span> -</span><span id="Union.limit-2305"><a href="#Union.limit-2305"><span class="linenos">2305</span></a><span class="sd"> >>> select("1").union(select("1")).limit(1).sql()</span> -</span><span id="Union.limit-2306"><a href="#Union.limit-2306"><span class="linenos">2306</span></a><span class="sd"> 'SELECT * FROM (SELECT 1 UNION SELECT 1) AS _l_0 LIMIT 1'</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Union.limit-2302"><a href="#Union.limit-2302"><span class="linenos">2302</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span> +</span><span id="Union.limit-2303"><a href="#Union.limit-2303"><span class="linenos">2303</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="Union.limit-2304"><a href="#Union.limit-2304"><span class="linenos">2304</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Union.limit-2305"><a href="#Union.limit-2305"><span class="linenos">2305</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Union.limit-2306"><a href="#Union.limit-2306"><span class="linenos">2306</span></a><span class="sd"> Set the LIMIT expression.</span> </span><span id="Union.limit-2307"><a href="#Union.limit-2307"><span class="linenos">2307</span></a> -</span><span id="Union.limit-2308"><a href="#Union.limit-2308"><span class="linenos">2308</span></a><span class="sd"> Args:</span> -</span><span id="Union.limit-2309"><a href="#Union.limit-2309"><span class="linenos">2309</span></a><span class="sd"> expression: the SQL code string to parse.</span> -</span><span id="Union.limit-2310"><a href="#Union.limit-2310"><span class="linenos">2310</span></a><span class="sd"> This can also be an integer.</span> -</span><span id="Union.limit-2311"><a href="#Union.limit-2311"><span class="linenos">2311</span></a><span class="sd"> If a `Limit` instance is passed, this is used as-is.</span> -</span><span id="Union.limit-2312"><a href="#Union.limit-2312"><span class="linenos">2312</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Limit`.</span> -</span><span id="Union.limit-2313"><a href="#Union.limit-2313"><span class="linenos">2313</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="Union.limit-2314"><a href="#Union.limit-2314"><span class="linenos">2314</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Union.limit-2315"><a href="#Union.limit-2315"><span class="linenos">2315</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Union.limit-2316"><a href="#Union.limit-2316"><span class="linenos">2316</span></a> -</span><span id="Union.limit-2317"><a href="#Union.limit-2317"><span class="linenos">2317</span></a><span class="sd"> Returns:</span> -</span><span id="Union.limit-2318"><a href="#Union.limit-2318"><span class="linenos">2318</span></a><span class="sd"> The limited subqueryable.</span> -</span><span id="Union.limit-2319"><a href="#Union.limit-2319"><span class="linenos">2319</span></a><span class="sd"> """</span> -</span><span id="Union.limit-2320"><a href="#Union.limit-2320"><span class="linenos">2320</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="Union.limit-2321"><a href="#Union.limit-2321"><span class="linenos">2321</span></a> <span class="n">select</span><span class="p">(</span><span class="s2">"*"</span><span class="p">)</span> -</span><span id="Union.limit-2322"><a href="#Union.limit-2322"><span class="linenos">2322</span></a> <span class="o">.</span><span class="n">from_</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">alias</span><span class="o">=</span><span class="s2">"_l_0"</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">))</span> -</span><span id="Union.limit-2323"><a href="#Union.limit-2323"><span class="linenos">2323</span></a> <span class="o">.</span><span class="n">limit</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="Union.limit-2324"><a href="#Union.limit-2324"><span class="linenos">2324</span></a> <span class="p">)</span> +</span><span id="Union.limit-2308"><a href="#Union.limit-2308"><span class="linenos">2308</span></a><span class="sd"> Example:</span> +</span><span id="Union.limit-2309"><a href="#Union.limit-2309"><span class="linenos">2309</span></a><span class="sd"> >>> select("1").union(select("1")).limit(1).sql()</span> +</span><span id="Union.limit-2310"><a href="#Union.limit-2310"><span class="linenos">2310</span></a><span class="sd"> 'SELECT * FROM (SELECT 1 UNION SELECT 1) AS _l_0 LIMIT 1'</span> +</span><span id="Union.limit-2311"><a href="#Union.limit-2311"><span class="linenos">2311</span></a> +</span><span id="Union.limit-2312"><a href="#Union.limit-2312"><span class="linenos">2312</span></a><span class="sd"> Args:</span> +</span><span id="Union.limit-2313"><a href="#Union.limit-2313"><span class="linenos">2313</span></a><span class="sd"> expression: the SQL code string to parse.</span> +</span><span id="Union.limit-2314"><a href="#Union.limit-2314"><span class="linenos">2314</span></a><span class="sd"> This can also be an integer.</span> +</span><span id="Union.limit-2315"><a href="#Union.limit-2315"><span class="linenos">2315</span></a><span class="sd"> If a `Limit` instance is passed, this is used as-is.</span> +</span><span id="Union.limit-2316"><a href="#Union.limit-2316"><span class="linenos">2316</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Limit`.</span> +</span><span id="Union.limit-2317"><a href="#Union.limit-2317"><span class="linenos">2317</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="Union.limit-2318"><a href="#Union.limit-2318"><span class="linenos">2318</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Union.limit-2319"><a href="#Union.limit-2319"><span class="linenos">2319</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Union.limit-2320"><a href="#Union.limit-2320"><span class="linenos">2320</span></a> +</span><span id="Union.limit-2321"><a href="#Union.limit-2321"><span class="linenos">2321</span></a><span class="sd"> Returns:</span> +</span><span id="Union.limit-2322"><a href="#Union.limit-2322"><span class="linenos">2322</span></a><span class="sd"> The limited subqueryable.</span> +</span><span id="Union.limit-2323"><a href="#Union.limit-2323"><span class="linenos">2323</span></a><span class="sd"> """</span> +</span><span id="Union.limit-2324"><a href="#Union.limit-2324"><span class="linenos">2324</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="Union.limit-2325"><a href="#Union.limit-2325"><span class="linenos">2325</span></a> <span class="n">select</span><span class="p">(</span><span class="s2">"*"</span><span class="p">)</span> +</span><span id="Union.limit-2326"><a href="#Union.limit-2326"><span class="linenos">2326</span></a> <span class="o">.</span><span class="n">from_</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">alias</span><span class="o">=</span><span class="s2">"_l_0"</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">))</span> +</span><span id="Union.limit-2327"><a href="#Union.limit-2327"><span class="linenos">2327</span></a> <span class="o">.</span><span class="n">limit</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="Union.limit-2328"><a href="#Union.limit-2328"><span class="linenos">2328</span></a> <span class="p">)</span> </span></pre></div> @@ -23686,39 +23767,39 @@ If another <code><a href="#Expression">Expression</a></code> instance is passed, </div> <a class="headerlink" href="#Union.select"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Union.select-2326"><a href="#Union.select-2326"><span class="linenos">2326</span></a> <span class="k">def</span> <span class="nf">select</span><span class="p">(</span> -</span><span id="Union.select-2327"><a href="#Union.select-2327"><span class="linenos">2327</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Union.select-2328"><a href="#Union.select-2328"><span class="linenos">2328</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Union.select-2329"><a href="#Union.select-2329"><span class="linenos">2329</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Union.select-2330"><a href="#Union.select-2330"><span class="linenos">2330</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Union.select-2331"><a href="#Union.select-2331"><span class="linenos">2331</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Union.select-2332"><a href="#Union.select-2332"><span class="linenos">2332</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Union.select-2333"><a href="#Union.select-2333"><span class="linenos">2333</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">:</span> -</span><span id="Union.select-2334"><a href="#Union.select-2334"><span class="linenos">2334</span></a><span class="w"> </span><span class="sd">"""Append to or set the SELECT of the union recursively.</span> -</span><span id="Union.select-2335"><a href="#Union.select-2335"><span class="linenos">2335</span></a> -</span><span id="Union.select-2336"><a href="#Union.select-2336"><span class="linenos">2336</span></a><span class="sd"> Example:</span> -</span><span id="Union.select-2337"><a href="#Union.select-2337"><span class="linenos">2337</span></a><span class="sd"> >>> from sqlglot import parse_one</span> -</span><span id="Union.select-2338"><a href="#Union.select-2338"><span class="linenos">2338</span></a><span class="sd"> >>> parse_one("select a from x union select a from y union select a from z").select("b").sql()</span> -</span><span id="Union.select-2339"><a href="#Union.select-2339"><span class="linenos">2339</span></a><span class="sd"> 'SELECT a, b FROM x UNION SELECT a, b FROM y UNION SELECT a, b FROM z'</span> -</span><span id="Union.select-2340"><a href="#Union.select-2340"><span class="linenos">2340</span></a> -</span><span id="Union.select-2341"><a href="#Union.select-2341"><span class="linenos">2341</span></a><span class="sd"> Args:</span> -</span><span id="Union.select-2342"><a href="#Union.select-2342"><span class="linenos">2342</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="Union.select-2343"><a href="#Union.select-2343"><span class="linenos">2343</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Union.select-2344"><a href="#Union.select-2344"><span class="linenos">2344</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="Union.select-2345"><a href="#Union.select-2345"><span class="linenos">2345</span></a><span class="sd"> Otherwise, this resets the expressions.</span> -</span><span id="Union.select-2346"><a href="#Union.select-2346"><span class="linenos">2346</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="Union.select-2347"><a href="#Union.select-2347"><span class="linenos">2347</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Union.select-2348"><a href="#Union.select-2348"><span class="linenos">2348</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Union.select-2349"><a href="#Union.select-2349"><span class="linenos">2349</span></a> -</span><span id="Union.select-2350"><a href="#Union.select-2350"><span class="linenos">2350</span></a><span class="sd"> Returns:</span> -</span><span id="Union.select-2351"><a href="#Union.select-2351"><span class="linenos">2351</span></a><span class="sd"> Union: the modified expression.</span> -</span><span id="Union.select-2352"><a href="#Union.select-2352"><span class="linenos">2352</span></a><span class="sd"> """</span> -</span><span id="Union.select-2353"><a href="#Union.select-2353"><span class="linenos">2353</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="k">if</span> <span class="n">copy</span> <span class="k">else</span> <span class="bp">self</span> -</span><span id="Union.select-2354"><a href="#Union.select-2354"><span class="linenos">2354</span></a> <span class="n">this</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">expressions</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="Union.select-2355"><a href="#Union.select-2355"><span class="linenos">2355</span></a> <span class="n">this</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span> -</span><span id="Union.select-2356"><a href="#Union.select-2356"><span class="linenos">2356</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="Union.select-2357"><a href="#Union.select-2357"><span class="linenos">2357</span></a> <span class="p">)</span> -</span><span id="Union.select-2358"><a href="#Union.select-2358"><span class="linenos">2358</span></a> <span class="k">return</span> <span class="n">this</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Union.select-2330"><a href="#Union.select-2330"><span class="linenos">2330</span></a> <span class="k">def</span> <span class="nf">select</span><span class="p">(</span> +</span><span id="Union.select-2331"><a href="#Union.select-2331"><span class="linenos">2331</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Union.select-2332"><a href="#Union.select-2332"><span class="linenos">2332</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Union.select-2333"><a href="#Union.select-2333"><span class="linenos">2333</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Union.select-2334"><a href="#Union.select-2334"><span class="linenos">2334</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Union.select-2335"><a href="#Union.select-2335"><span class="linenos">2335</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Union.select-2336"><a href="#Union.select-2336"><span class="linenos">2336</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Union.select-2337"><a href="#Union.select-2337"><span class="linenos">2337</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">:</span> +</span><span id="Union.select-2338"><a href="#Union.select-2338"><span class="linenos">2338</span></a><span class="w"> </span><span class="sd">"""Append to or set the SELECT of the union recursively.</span> +</span><span id="Union.select-2339"><a href="#Union.select-2339"><span class="linenos">2339</span></a> +</span><span id="Union.select-2340"><a href="#Union.select-2340"><span class="linenos">2340</span></a><span class="sd"> Example:</span> +</span><span id="Union.select-2341"><a href="#Union.select-2341"><span class="linenos">2341</span></a><span class="sd"> >>> from sqlglot import parse_one</span> +</span><span id="Union.select-2342"><a href="#Union.select-2342"><span class="linenos">2342</span></a><span class="sd"> >>> parse_one("select a from x union select a from y union select a from z").select("b").sql()</span> +</span><span id="Union.select-2343"><a href="#Union.select-2343"><span class="linenos">2343</span></a><span class="sd"> 'SELECT a, b FROM x UNION SELECT a, b FROM y UNION SELECT a, b FROM z'</span> +</span><span id="Union.select-2344"><a href="#Union.select-2344"><span class="linenos">2344</span></a> +</span><span id="Union.select-2345"><a href="#Union.select-2345"><span class="linenos">2345</span></a><span class="sd"> Args:</span> +</span><span id="Union.select-2346"><a href="#Union.select-2346"><span class="linenos">2346</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="Union.select-2347"><a href="#Union.select-2347"><span class="linenos">2347</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="Union.select-2348"><a href="#Union.select-2348"><span class="linenos">2348</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="Union.select-2349"><a href="#Union.select-2349"><span class="linenos">2349</span></a><span class="sd"> Otherwise, this resets the expressions.</span> +</span><span id="Union.select-2350"><a href="#Union.select-2350"><span class="linenos">2350</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="Union.select-2351"><a href="#Union.select-2351"><span class="linenos">2351</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Union.select-2352"><a href="#Union.select-2352"><span class="linenos">2352</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Union.select-2353"><a href="#Union.select-2353"><span class="linenos">2353</span></a> +</span><span id="Union.select-2354"><a href="#Union.select-2354"><span class="linenos">2354</span></a><span class="sd"> Returns:</span> +</span><span id="Union.select-2355"><a href="#Union.select-2355"><span class="linenos">2355</span></a><span class="sd"> Union: the modified expression.</span> +</span><span id="Union.select-2356"><a href="#Union.select-2356"><span class="linenos">2356</span></a><span class="sd"> """</span> +</span><span id="Union.select-2357"><a href="#Union.select-2357"><span class="linenos">2357</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="k">if</span> <span class="n">copy</span> <span class="k">else</span> <span class="bp">self</span> +</span><span id="Union.select-2358"><a href="#Union.select-2358"><span class="linenos">2358</span></a> <span class="n">this</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">expressions</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="Union.select-2359"><a href="#Union.select-2359"><span class="linenos">2359</span></a> <span class="n">this</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">unnest</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span> +</span><span id="Union.select-2360"><a href="#Union.select-2360"><span class="linenos">2360</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="Union.select-2361"><a href="#Union.select-2361"><span class="linenos">2361</span></a> <span class="p">)</span> +</span><span id="Union.select-2362"><a href="#Union.select-2362"><span class="linenos">2362</span></a> <span class="k">return</span> <span class="n">this</span> </span></pre></div> @@ -23837,8 +23918,8 @@ Otherwise, this resets the expressions.</li> </div> <a class="headerlink" href="#Except"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Except-2381"><a href="#Except-2381"><span class="linenos">2381</span></a><span class="k">class</span> <span class="nc">Except</span><span class="p">(</span><span class="n">Union</span><span class="p">):</span> -</span><span id="Except-2382"><a href="#Except-2382"><span class="linenos">2382</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Except-2385"><a href="#Except-2385"><span class="linenos">2385</span></a><span class="k">class</span> <span class="nc">Except</span><span class="p">(</span><span class="n">Union</span><span class="p">):</span> +</span><span id="Except-2386"><a href="#Except-2386"><span class="linenos">2386</span></a> <span class="k">pass</span> </span></pre></div> @@ -23918,8 +23999,8 @@ Otherwise, this resets the expressions.</li> </div> <a class="headerlink" href="#Intersect"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Intersect-2385"><a href="#Intersect-2385"><span class="linenos">2385</span></a><span class="k">class</span> <span class="nc">Intersect</span><span class="p">(</span><span class="n">Union</span><span class="p">):</span> -</span><span id="Intersect-2386"><a href="#Intersect-2386"><span class="linenos">2386</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Intersect-2389"><a href="#Intersect-2389"><span class="linenos">2389</span></a><span class="k">class</span> <span class="nc">Intersect</span><span class="p">(</span><span class="n">Union</span><span class="p">):</span> +</span><span id="Intersect-2390"><a href="#Intersect-2390"><span class="linenos">2390</span></a> <span class="k">pass</span> </span></pre></div> @@ -23999,13 +24080,13 @@ Otherwise, this resets the expressions.</li> </div> <a class="headerlink" href="#Unnest"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Unnest-2389"><a href="#Unnest-2389"><span class="linenos">2389</span></a><span class="k">class</span> <span class="nc">Unnest</span><span class="p">(</span><span class="n">UDTF</span><span class="p">):</span> -</span><span id="Unnest-2390"><a href="#Unnest-2390"><span class="linenos">2390</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Unnest-2391"><a href="#Unnest-2391"><span class="linenos">2391</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Unnest-2392"><a href="#Unnest-2392"><span class="linenos">2392</span></a> <span class="s2">"ordinality"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Unnest-2393"><a href="#Unnest-2393"><span class="linenos">2393</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Unnest-2394"><a href="#Unnest-2394"><span class="linenos">2394</span></a> <span class="s2">"offset"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Unnest-2395"><a href="#Unnest-2395"><span class="linenos">2395</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Unnest-2393"><a href="#Unnest-2393"><span class="linenos">2393</span></a><span class="k">class</span> <span class="nc">Unnest</span><span class="p">(</span><span class="n">UDTF</span><span class="p">):</span> +</span><span id="Unnest-2394"><a href="#Unnest-2394"><span class="linenos">2394</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Unnest-2395"><a href="#Unnest-2395"><span class="linenos">2395</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Unnest-2396"><a href="#Unnest-2396"><span class="linenos">2396</span></a> <span class="s2">"ordinality"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Unnest-2397"><a href="#Unnest-2397"><span class="linenos">2397</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Unnest-2398"><a href="#Unnest-2398"><span class="linenos">2398</span></a> <span class="s2">"offset"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Unnest-2399"><a href="#Unnest-2399"><span class="linenos">2399</span></a> <span class="p">}</span> </span></pre></div> @@ -24075,15 +24156,15 @@ Otherwise, this resets the expressions.</li> </div> <a class="headerlink" href="#Update"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Update-2398"><a href="#Update-2398"><span class="linenos">2398</span></a><span class="k">class</span> <span class="nc">Update</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Update-2399"><a href="#Update-2399"><span class="linenos">2399</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Update-2400"><a href="#Update-2400"><span class="linenos">2400</span></a> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Update-2401"><a href="#Update-2401"><span class="linenos">2401</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Update-2402"><a href="#Update-2402"><span class="linenos">2402</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Update-2403"><a href="#Update-2403"><span class="linenos">2403</span></a> <span class="s2">"from"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Update-2404"><a href="#Update-2404"><span class="linenos">2404</span></a> <span class="s2">"where"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Update-2405"><a href="#Update-2405"><span class="linenos">2405</span></a> <span class="s2">"returning"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Update-2406"><a href="#Update-2406"><span class="linenos">2406</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Update-2402"><a href="#Update-2402"><span class="linenos">2402</span></a><span class="k">class</span> <span class="nc">Update</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Update-2403"><a href="#Update-2403"><span class="linenos">2403</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Update-2404"><a href="#Update-2404"><span class="linenos">2404</span></a> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Update-2405"><a href="#Update-2405"><span class="linenos">2405</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Update-2406"><a href="#Update-2406"><span class="linenos">2406</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Update-2407"><a href="#Update-2407"><span class="linenos">2407</span></a> <span class="s2">"from"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Update-2408"><a href="#Update-2408"><span class="linenos">2408</span></a> <span class="s2">"where"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Update-2409"><a href="#Update-2409"><span class="linenos">2409</span></a> <span class="s2">"returning"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Update-2410"><a href="#Update-2410"><span class="linenos">2410</span></a> <span class="p">}</span> </span></pre></div> @@ -24147,12 +24228,12 @@ Otherwise, this resets the expressions.</li> </div> <a class="headerlink" href="#Values"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Values-2409"><a href="#Values-2409"><span class="linenos">2409</span></a><span class="k">class</span> <span class="nc">Values</span><span class="p">(</span><span class="n">UDTF</span><span class="p">):</span> -</span><span id="Values-2410"><a href="#Values-2410"><span class="linenos">2410</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Values-2411"><a href="#Values-2411"><span class="linenos">2411</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Values-2412"><a href="#Values-2412"><span class="linenos">2412</span></a> <span class="s2">"ordinality"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Values-2413"><a href="#Values-2413"><span class="linenos">2413</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Values-2414"><a href="#Values-2414"><span class="linenos">2414</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Values-2413"><a href="#Values-2413"><span class="linenos">2413</span></a><span class="k">class</span> <span class="nc">Values</span><span class="p">(</span><span class="n">UDTF</span><span class="p">):</span> +</span><span id="Values-2414"><a href="#Values-2414"><span class="linenos">2414</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Values-2415"><a href="#Values-2415"><span class="linenos">2415</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Values-2416"><a href="#Values-2416"><span class="linenos">2416</span></a> <span class="s2">"ordinality"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Values-2417"><a href="#Values-2417"><span class="linenos">2417</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Values-2418"><a href="#Values-2418"><span class="linenos">2418</span></a> <span class="p">}</span> </span></pre></div> @@ -24222,8 +24303,8 @@ Otherwise, this resets the expressions.</li> </div> <a class="headerlink" href="#Var"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Var-2417"><a href="#Var-2417"><span class="linenos">2417</span></a><span class="k">class</span> <span class="nc">Var</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Var-2418"><a href="#Var-2418"><span class="linenos">2418</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Var-2421"><a href="#Var-2421"><span class="linenos">2421</span></a><span class="k">class</span> <span class="nc">Var</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Var-2422"><a href="#Var-2422"><span class="linenos">2422</span></a> <span class="k">pass</span> </span></pre></div> @@ -24287,8 +24368,8 @@ Otherwise, this resets the expressions.</li> </div> <a class="headerlink" href="#Schema"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Schema-2421"><a href="#Schema-2421"><span class="linenos">2421</span></a><span class="k">class</span> <span class="nc">Schema</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Schema-2422"><a href="#Schema-2422"><span class="linenos">2422</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Schema-2425"><a href="#Schema-2425"><span class="linenos">2425</span></a><span class="k">class</span> <span class="nc">Schema</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Schema-2426"><a href="#Schema-2426"><span class="linenos">2426</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -24352,8 +24433,8 @@ Otherwise, this resets the expressions.</li> </div> <a class="headerlink" href="#Lock"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Lock-2427"><a href="#Lock-2427"><span class="linenos">2427</span></a><span class="k">class</span> <span class="nc">Lock</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Lock-2428"><a href="#Lock-2428"><span class="linenos">2428</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"update"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"wait"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Lock-2431"><a href="#Lock-2431"><span class="linenos">2431</span></a><span class="k">class</span> <span class="nc">Lock</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Lock-2432"><a href="#Lock-2432"><span class="linenos">2432</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"update"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"wait"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -24417,696 +24498,694 @@ Otherwise, this resets the expressions.</li> </div> <a class="headerlink" href="#Select"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Select-2431"><a href="#Select-2431"><span class="linenos">2431</span></a><span class="k">class</span> <span class="nc">Select</span><span class="p">(</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="Select-2432"><a href="#Select-2432"><span class="linenos">2432</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Select-2433"><a href="#Select-2433"><span class="linenos">2433</span></a> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Select-2434"><a href="#Select-2434"><span class="linenos">2434</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Select-2435"><a href="#Select-2435"><span class="linenos">2435</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Select-2436"><a href="#Select-2436"><span class="linenos">2436</span></a> <span class="s2">"hint"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Select-2437"><a href="#Select-2437"><span class="linenos">2437</span></a> <span class="s2">"distinct"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Select-2438"><a href="#Select-2438"><span class="linenos">2438</span></a> <span class="s2">"struct"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#return_query_results_as_a_value_table</span> -</span><span id="Select-2439"><a href="#Select-2439"><span class="linenos">2439</span></a> <span class="s2">"value"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Select-2440"><a href="#Select-2440"><span class="linenos">2440</span></a> <span class="s2">"into"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Select-2441"><a href="#Select-2441"><span class="linenos">2441</span></a> <span class="s2">"from"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Select-2442"><a href="#Select-2442"><span class="linenos">2442</span></a> <span class="o">**</span><span class="n">QUERY_MODIFIERS</span><span class="p">,</span> -</span><span id="Select-2443"><a href="#Select-2443"><span class="linenos">2443</span></a> <span class="p">}</span> -</span><span id="Select-2444"><a href="#Select-2444"><span class="linenos">2444</span></a> -</span><span id="Select-2445"><a href="#Select-2445"><span class="linenos">2445</span></a> <span class="k">def</span> <span class="nf">from_</span><span class="p">(</span> -</span><span id="Select-2446"><a href="#Select-2446"><span class="linenos">2446</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="Select-2447"><a href="#Select-2447"><span class="linenos">2447</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select-2448"><a href="#Select-2448"><span class="linenos">2448</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select-2449"><a href="#Select-2449"><span class="linenos">2449</span></a><span class="sd"> Set the FROM expression.</span> -</span><span id="Select-2450"><a href="#Select-2450"><span class="linenos">2450</span></a> -</span><span id="Select-2451"><a href="#Select-2451"><span class="linenos">2451</span></a><span class="sd"> Example:</span> -</span><span id="Select-2452"><a href="#Select-2452"><span class="linenos">2452</span></a><span class="sd"> >>> Select().from_("tbl").select("x").sql()</span> -</span><span id="Select-2453"><a href="#Select-2453"><span class="linenos">2453</span></a><span class="sd"> 'SELECT x FROM tbl'</span> -</span><span id="Select-2454"><a href="#Select-2454"><span class="linenos">2454</span></a> -</span><span id="Select-2455"><a href="#Select-2455"><span class="linenos">2455</span></a><span class="sd"> Args:</span> -</span><span id="Select-2456"><a href="#Select-2456"><span class="linenos">2456</span></a><span class="sd"> expression : the SQL code strings to parse.</span> -</span><span id="Select-2457"><a href="#Select-2457"><span class="linenos">2457</span></a><span class="sd"> If a `From` instance is passed, this is used as-is.</span> -</span><span id="Select-2458"><a href="#Select-2458"><span class="linenos">2458</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `From`.</span> -</span><span id="Select-2459"><a href="#Select-2459"><span class="linenos">2459</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="Select-2460"><a href="#Select-2460"><span class="linenos">2460</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select-2461"><a href="#Select-2461"><span class="linenos">2461</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select-2462"><a href="#Select-2462"><span class="linenos">2462</span></a> -</span><span id="Select-2463"><a href="#Select-2463"><span class="linenos">2463</span></a><span class="sd"> Returns:</span> -</span><span id="Select-2464"><a href="#Select-2464"><span class="linenos">2464</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="Select-2465"><a href="#Select-2465"><span class="linenos">2465</span></a><span class="sd"> """</span> -</span><span id="Select-2466"><a href="#Select-2466"><span class="linenos">2466</span></a> <span class="k">return</span> <span class="n">_apply_builder</span><span class="p">(</span> -</span><span id="Select-2467"><a href="#Select-2467"><span class="linenos">2467</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> -</span><span id="Select-2468"><a href="#Select-2468"><span class="linenos">2468</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2469"><a href="#Select-2469"><span class="linenos">2469</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"from"</span><span class="p">,</span> -</span><span id="Select-2470"><a href="#Select-2470"><span class="linenos">2470</span></a> <span class="n">into</span><span class="o">=</span><span class="n">From</span><span class="p">,</span> -</span><span id="Select-2471"><a href="#Select-2471"><span class="linenos">2471</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"FROM"</span><span class="p">,</span> -</span><span id="Select-2472"><a href="#Select-2472"><span class="linenos">2472</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select-2473"><a href="#Select-2473"><span class="linenos">2473</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select-2474"><a href="#Select-2474"><span class="linenos">2474</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2475"><a href="#Select-2475"><span class="linenos">2475</span></a> <span class="p">)</span> -</span><span id="Select-2476"><a href="#Select-2476"><span class="linenos">2476</span></a> -</span><span id="Select-2477"><a href="#Select-2477"><span class="linenos">2477</span></a> <span class="k">def</span> <span class="nf">group_by</span><span class="p">(</span> -</span><span id="Select-2478"><a href="#Select-2478"><span class="linenos">2478</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2479"><a href="#Select-2479"><span class="linenos">2479</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select-2480"><a href="#Select-2480"><span class="linenos">2480</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2481"><a href="#Select-2481"><span class="linenos">2481</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select-2482"><a href="#Select-2482"><span class="linenos">2482</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2483"><a href="#Select-2483"><span class="linenos">2483</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2484"><a href="#Select-2484"><span class="linenos">2484</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select-2485"><a href="#Select-2485"><span class="linenos">2485</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select-2486"><a href="#Select-2486"><span class="linenos">2486</span></a><span class="sd"> Set the GROUP BY expression.</span> -</span><span id="Select-2487"><a href="#Select-2487"><span class="linenos">2487</span></a> -</span><span id="Select-2488"><a href="#Select-2488"><span class="linenos">2488</span></a><span class="sd"> Example:</span> -</span><span id="Select-2489"><a href="#Select-2489"><span class="linenos">2489</span></a><span class="sd"> >>> Select().from_("tbl").select("x", "COUNT(1)").group_by("x").sql()</span> -</span><span id="Select-2490"><a href="#Select-2490"><span class="linenos">2490</span></a><span class="sd"> 'SELECT x, COUNT(1) FROM tbl GROUP BY x'</span> -</span><span id="Select-2491"><a href="#Select-2491"><span class="linenos">2491</span></a> -</span><span id="Select-2492"><a href="#Select-2492"><span class="linenos">2492</span></a><span class="sd"> Args:</span> -</span><span id="Select-2493"><a href="#Select-2493"><span class="linenos">2493</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="Select-2494"><a href="#Select-2494"><span class="linenos">2494</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> -</span><span id="Select-2495"><a href="#Select-2495"><span class="linenos">2495</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Group`.</span> -</span><span id="Select-2496"><a href="#Select-2496"><span class="linenos">2496</span></a><span class="sd"> If nothing is passed in then a group by is not applied to the expression</span> -</span><span id="Select-2497"><a href="#Select-2497"><span class="linenos">2497</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="Select-2498"><a href="#Select-2498"><span class="linenos">2498</span></a><span class="sd"> Otherwise, this flattens all the `Group` expression into a single expression.</span> -</span><span id="Select-2499"><a href="#Select-2499"><span class="linenos">2499</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="Select-2500"><a href="#Select-2500"><span class="linenos">2500</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select-2501"><a href="#Select-2501"><span class="linenos">2501</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select-2502"><a href="#Select-2502"><span class="linenos">2502</span></a> -</span><span id="Select-2503"><a href="#Select-2503"><span class="linenos">2503</span></a><span class="sd"> Returns:</span> -</span><span id="Select-2504"><a href="#Select-2504"><span class="linenos">2504</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="Select-2505"><a href="#Select-2505"><span class="linenos">2505</span></a><span class="sd"> """</span> -</span><span id="Select-2506"><a href="#Select-2506"><span class="linenos">2506</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="Select-2507"><a href="#Select-2507"><span class="linenos">2507</span></a> <span class="k">return</span> <span class="bp">self</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">copy</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Select-2508"><a href="#Select-2508"><span class="linenos">2508</span></a> -</span><span id="Select-2509"><a href="#Select-2509"><span class="linenos">2509</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> -</span><span id="Select-2510"><a href="#Select-2510"><span class="linenos">2510</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select-2511"><a href="#Select-2511"><span class="linenos">2511</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2512"><a href="#Select-2512"><span class="linenos">2512</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"group"</span><span class="p">,</span> -</span><span id="Select-2513"><a href="#Select-2513"><span class="linenos">2513</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select-2514"><a href="#Select-2514"><span class="linenos">2514</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select-2515"><a href="#Select-2515"><span class="linenos">2515</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"GROUP BY"</span><span class="p">,</span> -</span><span id="Select-2516"><a href="#Select-2516"><span class="linenos">2516</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Group</span><span class="p">,</span> -</span><span id="Select-2517"><a href="#Select-2517"><span class="linenos">2517</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select-2518"><a href="#Select-2518"><span class="linenos">2518</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2519"><a href="#Select-2519"><span class="linenos">2519</span></a> <span class="p">)</span> -</span><span id="Select-2520"><a href="#Select-2520"><span class="linenos">2520</span></a> -</span><span id="Select-2521"><a href="#Select-2521"><span class="linenos">2521</span></a> <span class="k">def</span> <span class="nf">order_by</span><span class="p">(</span> -</span><span id="Select-2522"><a href="#Select-2522"><span class="linenos">2522</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2523"><a href="#Select-2523"><span class="linenos">2523</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select-2524"><a href="#Select-2524"><span class="linenos">2524</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2525"><a href="#Select-2525"><span class="linenos">2525</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select-2526"><a href="#Select-2526"><span class="linenos">2526</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2527"><a href="#Select-2527"><span class="linenos">2527</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2528"><a href="#Select-2528"><span class="linenos">2528</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select-2529"><a href="#Select-2529"><span class="linenos">2529</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select-2530"><a href="#Select-2530"><span class="linenos">2530</span></a><span class="sd"> Set the ORDER BY expression.</span> -</span><span id="Select-2531"><a href="#Select-2531"><span class="linenos">2531</span></a> -</span><span id="Select-2532"><a href="#Select-2532"><span class="linenos">2532</span></a><span class="sd"> Example:</span> -</span><span id="Select-2533"><a href="#Select-2533"><span class="linenos">2533</span></a><span class="sd"> >>> Select().from_("tbl").select("x").order_by("x DESC").sql()</span> -</span><span id="Select-2534"><a href="#Select-2534"><span class="linenos">2534</span></a><span class="sd"> 'SELECT x FROM tbl ORDER BY x DESC'</span> -</span><span id="Select-2535"><a href="#Select-2535"><span class="linenos">2535</span></a> -</span><span id="Select-2536"><a href="#Select-2536"><span class="linenos">2536</span></a><span class="sd"> Args:</span> -</span><span id="Select-2537"><a href="#Select-2537"><span class="linenos">2537</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="Select-2538"><a href="#Select-2538"><span class="linenos">2538</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> -</span><span id="Select-2539"><a href="#Select-2539"><span class="linenos">2539</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Order`.</span> -</span><span id="Select-2540"><a href="#Select-2540"><span class="linenos">2540</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="Select-2541"><a href="#Select-2541"><span class="linenos">2541</span></a><span class="sd"> Otherwise, this flattens all the `Order` expression into a single expression.</span> -</span><span id="Select-2542"><a href="#Select-2542"><span class="linenos">2542</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="Select-2543"><a href="#Select-2543"><span class="linenos">2543</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select-2544"><a href="#Select-2544"><span class="linenos">2544</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select-2545"><a href="#Select-2545"><span class="linenos">2545</span></a> -</span><span id="Select-2546"><a href="#Select-2546"><span class="linenos">2546</span></a><span class="sd"> Returns:</span> -</span><span id="Select-2547"><a href="#Select-2547"><span class="linenos">2547</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="Select-2548"><a href="#Select-2548"><span class="linenos">2548</span></a><span class="sd"> """</span> -</span><span id="Select-2549"><a href="#Select-2549"><span class="linenos">2549</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> -</span><span id="Select-2550"><a href="#Select-2550"><span class="linenos">2550</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select-2551"><a href="#Select-2551"><span class="linenos">2551</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2552"><a href="#Select-2552"><span class="linenos">2552</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"order"</span><span class="p">,</span> -</span><span id="Select-2553"><a href="#Select-2553"><span class="linenos">2553</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select-2554"><a href="#Select-2554"><span class="linenos">2554</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select-2555"><a href="#Select-2555"><span class="linenos">2555</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ORDER BY"</span><span class="p">,</span> -</span><span id="Select-2556"><a href="#Select-2556"><span class="linenos">2556</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Order</span><span class="p">,</span> -</span><span id="Select-2557"><a href="#Select-2557"><span class="linenos">2557</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select-2558"><a href="#Select-2558"><span class="linenos">2558</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2559"><a href="#Select-2559"><span class="linenos">2559</span></a> <span class="p">)</span> -</span><span id="Select-2560"><a href="#Select-2560"><span class="linenos">2560</span></a> -</span><span id="Select-2561"><a href="#Select-2561"><span class="linenos">2561</span></a> <span class="k">def</span> <span class="nf">sort_by</span><span class="p">(</span> -</span><span id="Select-2562"><a href="#Select-2562"><span class="linenos">2562</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2563"><a href="#Select-2563"><span class="linenos">2563</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select-2564"><a href="#Select-2564"><span class="linenos">2564</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2565"><a href="#Select-2565"><span class="linenos">2565</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select-2566"><a href="#Select-2566"><span class="linenos">2566</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2567"><a href="#Select-2567"><span class="linenos">2567</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2568"><a href="#Select-2568"><span class="linenos">2568</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select-2569"><a href="#Select-2569"><span class="linenos">2569</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select-2570"><a href="#Select-2570"><span class="linenos">2570</span></a><span class="sd"> Set the SORT BY expression.</span> -</span><span id="Select-2571"><a href="#Select-2571"><span class="linenos">2571</span></a> -</span><span id="Select-2572"><a href="#Select-2572"><span class="linenos">2572</span></a><span class="sd"> Example:</span> -</span><span id="Select-2573"><a href="#Select-2573"><span class="linenos">2573</span></a><span class="sd"> >>> Select().from_("tbl").select("x").sort_by("x DESC").sql(dialect="hive")</span> -</span><span id="Select-2574"><a href="#Select-2574"><span class="linenos">2574</span></a><span class="sd"> 'SELECT x FROM tbl SORT BY x DESC'</span> -</span><span id="Select-2575"><a href="#Select-2575"><span class="linenos">2575</span></a> -</span><span id="Select-2576"><a href="#Select-2576"><span class="linenos">2576</span></a><span class="sd"> Args:</span> -</span><span id="Select-2577"><a href="#Select-2577"><span class="linenos">2577</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="Select-2578"><a href="#Select-2578"><span class="linenos">2578</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> -</span><span id="Select-2579"><a href="#Select-2579"><span class="linenos">2579</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `SORT`.</span> -</span><span id="Select-2580"><a href="#Select-2580"><span class="linenos">2580</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="Select-2581"><a href="#Select-2581"><span class="linenos">2581</span></a><span class="sd"> Otherwise, this flattens all the `Order` expression into a single expression.</span> -</span><span id="Select-2582"><a href="#Select-2582"><span class="linenos">2582</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="Select-2583"><a href="#Select-2583"><span class="linenos">2583</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select-2584"><a href="#Select-2584"><span class="linenos">2584</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select-2585"><a href="#Select-2585"><span class="linenos">2585</span></a> -</span><span id="Select-2586"><a href="#Select-2586"><span class="linenos">2586</span></a><span class="sd"> Returns:</span> -</span><span id="Select-2587"><a href="#Select-2587"><span class="linenos">2587</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="Select-2588"><a href="#Select-2588"><span class="linenos">2588</span></a><span class="sd"> """</span> -</span><span id="Select-2589"><a href="#Select-2589"><span class="linenos">2589</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> -</span><span id="Select-2590"><a href="#Select-2590"><span class="linenos">2590</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select-2591"><a href="#Select-2591"><span class="linenos">2591</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2592"><a href="#Select-2592"><span class="linenos">2592</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"sort"</span><span class="p">,</span> -</span><span id="Select-2593"><a href="#Select-2593"><span class="linenos">2593</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select-2594"><a href="#Select-2594"><span class="linenos">2594</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select-2595"><a href="#Select-2595"><span class="linenos">2595</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"SORT BY"</span><span class="p">,</span> -</span><span id="Select-2596"><a href="#Select-2596"><span class="linenos">2596</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Sort</span><span class="p">,</span> -</span><span id="Select-2597"><a href="#Select-2597"><span class="linenos">2597</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select-2598"><a href="#Select-2598"><span class="linenos">2598</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2599"><a href="#Select-2599"><span class="linenos">2599</span></a> <span class="p">)</span> -</span><span id="Select-2600"><a href="#Select-2600"><span class="linenos">2600</span></a> -</span><span id="Select-2601"><a href="#Select-2601"><span class="linenos">2601</span></a> <span class="k">def</span> <span class="nf">cluster_by</span><span class="p">(</span> -</span><span id="Select-2602"><a href="#Select-2602"><span class="linenos">2602</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2603"><a href="#Select-2603"><span class="linenos">2603</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select-2604"><a href="#Select-2604"><span class="linenos">2604</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2605"><a href="#Select-2605"><span class="linenos">2605</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select-2606"><a href="#Select-2606"><span class="linenos">2606</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2607"><a href="#Select-2607"><span class="linenos">2607</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2608"><a href="#Select-2608"><span class="linenos">2608</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select-2609"><a href="#Select-2609"><span class="linenos">2609</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select-2610"><a href="#Select-2610"><span class="linenos">2610</span></a><span class="sd"> Set the CLUSTER BY expression.</span> -</span><span id="Select-2611"><a href="#Select-2611"><span class="linenos">2611</span></a> -</span><span id="Select-2612"><a href="#Select-2612"><span class="linenos">2612</span></a><span class="sd"> Example:</span> -</span><span id="Select-2613"><a href="#Select-2613"><span class="linenos">2613</span></a><span class="sd"> >>> Select().from_("tbl").select("x").cluster_by("x DESC").sql(dialect="hive")</span> -</span><span id="Select-2614"><a href="#Select-2614"><span class="linenos">2614</span></a><span class="sd"> 'SELECT x FROM tbl CLUSTER BY x DESC'</span> -</span><span id="Select-2615"><a href="#Select-2615"><span class="linenos">2615</span></a> -</span><span id="Select-2616"><a href="#Select-2616"><span class="linenos">2616</span></a><span class="sd"> Args:</span> -</span><span id="Select-2617"><a href="#Select-2617"><span class="linenos">2617</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="Select-2618"><a href="#Select-2618"><span class="linenos">2618</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> -</span><span id="Select-2619"><a href="#Select-2619"><span class="linenos">2619</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Cluster`.</span> -</span><span id="Select-2620"><a href="#Select-2620"><span class="linenos">2620</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="Select-2621"><a href="#Select-2621"><span class="linenos">2621</span></a><span class="sd"> Otherwise, this flattens all the `Order` expression into a single expression.</span> -</span><span id="Select-2622"><a href="#Select-2622"><span class="linenos">2622</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="Select-2623"><a href="#Select-2623"><span class="linenos">2623</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select-2624"><a href="#Select-2624"><span class="linenos">2624</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select-2625"><a href="#Select-2625"><span class="linenos">2625</span></a> -</span><span id="Select-2626"><a href="#Select-2626"><span class="linenos">2626</span></a><span class="sd"> Returns:</span> -</span><span id="Select-2627"><a href="#Select-2627"><span class="linenos">2627</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="Select-2628"><a href="#Select-2628"><span class="linenos">2628</span></a><span class="sd"> """</span> -</span><span id="Select-2629"><a href="#Select-2629"><span class="linenos">2629</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> -</span><span id="Select-2630"><a href="#Select-2630"><span class="linenos">2630</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select-2631"><a href="#Select-2631"><span class="linenos">2631</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2632"><a href="#Select-2632"><span class="linenos">2632</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"cluster"</span><span class="p">,</span> -</span><span id="Select-2633"><a href="#Select-2633"><span class="linenos">2633</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select-2634"><a href="#Select-2634"><span class="linenos">2634</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select-2635"><a href="#Select-2635"><span class="linenos">2635</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"CLUSTER BY"</span><span class="p">,</span> -</span><span id="Select-2636"><a href="#Select-2636"><span class="linenos">2636</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Cluster</span><span class="p">,</span> -</span><span id="Select-2637"><a href="#Select-2637"><span class="linenos">2637</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select-2638"><a href="#Select-2638"><span class="linenos">2638</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2639"><a href="#Select-2639"><span class="linenos">2639</span></a> <span class="p">)</span> -</span><span id="Select-2640"><a href="#Select-2640"><span class="linenos">2640</span></a> -</span><span id="Select-2641"><a href="#Select-2641"><span class="linenos">2641</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span> -</span><span id="Select-2642"><a href="#Select-2642"><span class="linenos">2642</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="Select-2643"><a href="#Select-2643"><span class="linenos">2643</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select-2644"><a href="#Select-2644"><span class="linenos">2644</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select-2645"><a href="#Select-2645"><span class="linenos">2645</span></a><span class="sd"> Set the LIMIT expression.</span> -</span><span id="Select-2646"><a href="#Select-2646"><span class="linenos">2646</span></a> -</span><span id="Select-2647"><a href="#Select-2647"><span class="linenos">2647</span></a><span class="sd"> Example:</span> -</span><span id="Select-2648"><a href="#Select-2648"><span class="linenos">2648</span></a><span class="sd"> >>> Select().from_("tbl").select("x").limit(10).sql()</span> -</span><span id="Select-2649"><a href="#Select-2649"><span class="linenos">2649</span></a><span class="sd"> 'SELECT x FROM tbl LIMIT 10'</span> -</span><span id="Select-2650"><a href="#Select-2650"><span class="linenos">2650</span></a> -</span><span id="Select-2651"><a href="#Select-2651"><span class="linenos">2651</span></a><span class="sd"> Args:</span> -</span><span id="Select-2652"><a href="#Select-2652"><span class="linenos">2652</span></a><span class="sd"> expression: the SQL code string to parse.</span> -</span><span id="Select-2653"><a href="#Select-2653"><span class="linenos">2653</span></a><span class="sd"> This can also be an integer.</span> -</span><span id="Select-2654"><a href="#Select-2654"><span class="linenos">2654</span></a><span class="sd"> If a `Limit` instance is passed, this is used as-is.</span> -</span><span id="Select-2655"><a href="#Select-2655"><span class="linenos">2655</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Limit`.</span> -</span><span id="Select-2656"><a href="#Select-2656"><span class="linenos">2656</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="Select-2657"><a href="#Select-2657"><span class="linenos">2657</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select-2658"><a href="#Select-2658"><span class="linenos">2658</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select-2659"><a href="#Select-2659"><span class="linenos">2659</span></a> -</span><span id="Select-2660"><a href="#Select-2660"><span class="linenos">2660</span></a><span class="sd"> Returns:</span> -</span><span id="Select-2661"><a href="#Select-2661"><span class="linenos">2661</span></a><span class="sd"> Select: the modified expression.</span> -</span><span id="Select-2662"><a href="#Select-2662"><span class="linenos">2662</span></a><span class="sd"> """</span> -</span><span id="Select-2663"><a href="#Select-2663"><span class="linenos">2663</span></a> <span class="k">return</span> <span class="n">_apply_builder</span><span class="p">(</span> -</span><span id="Select-2664"><a href="#Select-2664"><span class="linenos">2664</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> -</span><span id="Select-2665"><a href="#Select-2665"><span class="linenos">2665</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2666"><a href="#Select-2666"><span class="linenos">2666</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"limit"</span><span class="p">,</span> -</span><span id="Select-2667"><a href="#Select-2667"><span class="linenos">2667</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Limit</span><span class="p">,</span> -</span><span id="Select-2668"><a href="#Select-2668"><span class="linenos">2668</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"LIMIT"</span><span class="p">,</span> -</span><span id="Select-2669"><a href="#Select-2669"><span class="linenos">2669</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select-2670"><a href="#Select-2670"><span class="linenos">2670</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select-2671"><a href="#Select-2671"><span class="linenos">2671</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2672"><a href="#Select-2672"><span class="linenos">2672</span></a> <span class="p">)</span> -</span><span id="Select-2673"><a href="#Select-2673"><span class="linenos">2673</span></a> -</span><span id="Select-2674"><a href="#Select-2674"><span class="linenos">2674</span></a> <span class="k">def</span> <span class="nf">offset</span><span class="p">(</span> -</span><span id="Select-2675"><a href="#Select-2675"><span class="linenos">2675</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="Select-2676"><a href="#Select-2676"><span class="linenos">2676</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select-2677"><a href="#Select-2677"><span class="linenos">2677</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select-2678"><a href="#Select-2678"><span class="linenos">2678</span></a><span class="sd"> Set the OFFSET expression.</span> -</span><span id="Select-2679"><a href="#Select-2679"><span class="linenos">2679</span></a> -</span><span id="Select-2680"><a href="#Select-2680"><span class="linenos">2680</span></a><span class="sd"> Example:</span> -</span><span id="Select-2681"><a href="#Select-2681"><span class="linenos">2681</span></a><span class="sd"> >>> Select().from_("tbl").select("x").offset(10).sql()</span> -</span><span id="Select-2682"><a href="#Select-2682"><span class="linenos">2682</span></a><span class="sd"> 'SELECT x FROM tbl OFFSET 10'</span> -</span><span id="Select-2683"><a href="#Select-2683"><span class="linenos">2683</span></a> -</span><span id="Select-2684"><a href="#Select-2684"><span class="linenos">2684</span></a><span class="sd"> Args:</span> -</span><span id="Select-2685"><a href="#Select-2685"><span class="linenos">2685</span></a><span class="sd"> expression: the SQL code string to parse.</span> -</span><span id="Select-2686"><a href="#Select-2686"><span class="linenos">2686</span></a><span class="sd"> This can also be an integer.</span> -</span><span id="Select-2687"><a href="#Select-2687"><span class="linenos">2687</span></a><span class="sd"> If a `Offset` instance is passed, this is used as-is.</span> -</span><span id="Select-2688"><a href="#Select-2688"><span class="linenos">2688</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Offset`.</span> -</span><span id="Select-2689"><a href="#Select-2689"><span class="linenos">2689</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="Select-2690"><a href="#Select-2690"><span class="linenos">2690</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select-2691"><a href="#Select-2691"><span class="linenos">2691</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select-2692"><a href="#Select-2692"><span class="linenos">2692</span></a> -</span><span id="Select-2693"><a href="#Select-2693"><span class="linenos">2693</span></a><span class="sd"> Returns:</span> -</span><span id="Select-2694"><a href="#Select-2694"><span class="linenos">2694</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="Select-2695"><a href="#Select-2695"><span class="linenos">2695</span></a><span class="sd"> """</span> -</span><span id="Select-2696"><a href="#Select-2696"><span class="linenos">2696</span></a> <span class="k">return</span> <span class="n">_apply_builder</span><span class="p">(</span> -</span><span id="Select-2697"><a href="#Select-2697"><span class="linenos">2697</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> -</span><span id="Select-2698"><a href="#Select-2698"><span class="linenos">2698</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2699"><a href="#Select-2699"><span class="linenos">2699</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"offset"</span><span class="p">,</span> -</span><span id="Select-2700"><a href="#Select-2700"><span class="linenos">2700</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Offset</span><span class="p">,</span> -</span><span id="Select-2701"><a href="#Select-2701"><span class="linenos">2701</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"OFFSET"</span><span class="p">,</span> -</span><span id="Select-2702"><a href="#Select-2702"><span class="linenos">2702</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select-2703"><a href="#Select-2703"><span class="linenos">2703</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select-2704"><a href="#Select-2704"><span class="linenos">2704</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2705"><a href="#Select-2705"><span class="linenos">2705</span></a> <span class="p">)</span> -</span><span id="Select-2706"><a href="#Select-2706"><span class="linenos">2706</span></a> -</span><span id="Select-2707"><a href="#Select-2707"><span class="linenos">2707</span></a> <span class="k">def</span> <span class="nf">select</span><span class="p">(</span> -</span><span id="Select-2708"><a href="#Select-2708"><span class="linenos">2708</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2709"><a href="#Select-2709"><span class="linenos">2709</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select-2710"><a href="#Select-2710"><span class="linenos">2710</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2711"><a href="#Select-2711"><span class="linenos">2711</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select-2712"><a href="#Select-2712"><span class="linenos">2712</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2713"><a href="#Select-2713"><span class="linenos">2713</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2714"><a href="#Select-2714"><span class="linenos">2714</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select-2715"><a href="#Select-2715"><span class="linenos">2715</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select-2716"><a href="#Select-2716"><span class="linenos">2716</span></a><span class="sd"> Append to or set the SELECT expressions.</span> -</span><span id="Select-2717"><a href="#Select-2717"><span class="linenos">2717</span></a> -</span><span id="Select-2718"><a href="#Select-2718"><span class="linenos">2718</span></a><span class="sd"> Example:</span> -</span><span id="Select-2719"><a href="#Select-2719"><span class="linenos">2719</span></a><span class="sd"> >>> Select().select("x", "y").sql()</span> -</span><span id="Select-2720"><a href="#Select-2720"><span class="linenos">2720</span></a><span class="sd"> 'SELECT x, y'</span> -</span><span id="Select-2721"><a href="#Select-2721"><span class="linenos">2721</span></a> -</span><span id="Select-2722"><a href="#Select-2722"><span class="linenos">2722</span></a><span class="sd"> Args:</span> -</span><span id="Select-2723"><a href="#Select-2723"><span class="linenos">2723</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="Select-2724"><a href="#Select-2724"><span class="linenos">2724</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Select-2725"><a href="#Select-2725"><span class="linenos">2725</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="Select-2726"><a href="#Select-2726"><span class="linenos">2726</span></a><span class="sd"> Otherwise, this resets the expressions.</span> -</span><span id="Select-2727"><a href="#Select-2727"><span class="linenos">2727</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="Select-2728"><a href="#Select-2728"><span class="linenos">2728</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select-2729"><a href="#Select-2729"><span class="linenos">2729</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select-2730"><a href="#Select-2730"><span class="linenos">2730</span></a> -</span><span id="Select-2731"><a href="#Select-2731"><span class="linenos">2731</span></a><span class="sd"> Returns:</span> -</span><span id="Select-2732"><a href="#Select-2732"><span class="linenos">2732</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="Select-2733"><a href="#Select-2733"><span class="linenos">2733</span></a><span class="sd"> """</span> -</span><span id="Select-2734"><a href="#Select-2734"><span class="linenos">2734</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> -</span><span id="Select-2735"><a href="#Select-2735"><span class="linenos">2735</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select-2736"><a href="#Select-2736"><span class="linenos">2736</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2737"><a href="#Select-2737"><span class="linenos">2737</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"expressions"</span><span class="p">,</span> -</span><span id="Select-2738"><a href="#Select-2738"><span class="linenos">2738</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select-2739"><a href="#Select-2739"><span class="linenos">2739</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select-2740"><a href="#Select-2740"><span class="linenos">2740</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select-2741"><a href="#Select-2741"><span class="linenos">2741</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2742"><a href="#Select-2742"><span class="linenos">2742</span></a> <span class="p">)</span> -</span><span id="Select-2743"><a href="#Select-2743"><span class="linenos">2743</span></a> -</span><span id="Select-2744"><a href="#Select-2744"><span class="linenos">2744</span></a> <span class="k">def</span> <span class="nf">lateral</span><span class="p">(</span> -</span><span id="Select-2745"><a href="#Select-2745"><span class="linenos">2745</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2746"><a href="#Select-2746"><span class="linenos">2746</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select-2747"><a href="#Select-2747"><span class="linenos">2747</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2748"><a href="#Select-2748"><span class="linenos">2748</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select-2749"><a href="#Select-2749"><span class="linenos">2749</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2750"><a href="#Select-2750"><span class="linenos">2750</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2751"><a href="#Select-2751"><span class="linenos">2751</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select-2752"><a href="#Select-2752"><span class="linenos">2752</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select-2753"><a href="#Select-2753"><span class="linenos">2753</span></a><span class="sd"> Append to or set the LATERAL expressions.</span> -</span><span id="Select-2754"><a href="#Select-2754"><span class="linenos">2754</span></a> -</span><span id="Select-2755"><a href="#Select-2755"><span class="linenos">2755</span></a><span class="sd"> Example:</span> -</span><span id="Select-2756"><a href="#Select-2756"><span class="linenos">2756</span></a><span class="sd"> >>> Select().select("x").lateral("OUTER explode(y) tbl2 AS z").from_("tbl").sql()</span> -</span><span id="Select-2757"><a href="#Select-2757"><span class="linenos">2757</span></a><span class="sd"> 'SELECT x FROM tbl LATERAL VIEW OUTER EXPLODE(y) tbl2 AS z'</span> -</span><span id="Select-2758"><a href="#Select-2758"><span class="linenos">2758</span></a> -</span><span id="Select-2759"><a href="#Select-2759"><span class="linenos">2759</span></a><span class="sd"> Args:</span> -</span><span id="Select-2760"><a href="#Select-2760"><span class="linenos">2760</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="Select-2761"><a href="#Select-2761"><span class="linenos">2761</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Select-2762"><a href="#Select-2762"><span class="linenos">2762</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="Select-2763"><a href="#Select-2763"><span class="linenos">2763</span></a><span class="sd"> Otherwise, this resets the expressions.</span> -</span><span id="Select-2764"><a href="#Select-2764"><span class="linenos">2764</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="Select-2765"><a href="#Select-2765"><span class="linenos">2765</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select-2766"><a href="#Select-2766"><span class="linenos">2766</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select-2767"><a href="#Select-2767"><span class="linenos">2767</span></a> -</span><span id="Select-2768"><a href="#Select-2768"><span class="linenos">2768</span></a><span class="sd"> Returns:</span> -</span><span id="Select-2769"><a href="#Select-2769"><span class="linenos">2769</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="Select-2770"><a href="#Select-2770"><span class="linenos">2770</span></a><span class="sd"> """</span> -</span><span id="Select-2771"><a href="#Select-2771"><span class="linenos">2771</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> -</span><span id="Select-2772"><a href="#Select-2772"><span class="linenos">2772</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select-2773"><a href="#Select-2773"><span class="linenos">2773</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2774"><a href="#Select-2774"><span class="linenos">2774</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"laterals"</span><span class="p">,</span> -</span><span id="Select-2775"><a href="#Select-2775"><span class="linenos">2775</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select-2776"><a href="#Select-2776"><span class="linenos">2776</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Lateral</span><span class="p">,</span> -</span><span id="Select-2777"><a href="#Select-2777"><span class="linenos">2777</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"LATERAL VIEW"</span><span class="p">,</span> -</span><span id="Select-2778"><a href="#Select-2778"><span class="linenos">2778</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select-2779"><a href="#Select-2779"><span class="linenos">2779</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select-2780"><a href="#Select-2780"><span class="linenos">2780</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2781"><a href="#Select-2781"><span class="linenos">2781</span></a> <span class="p">)</span> -</span><span id="Select-2782"><a href="#Select-2782"><span class="linenos">2782</span></a> -</span><span id="Select-2783"><a href="#Select-2783"><span class="linenos">2783</span></a> <span class="k">def</span> <span class="nf">join</span><span class="p">(</span> -</span><span id="Select-2784"><a href="#Select-2784"><span class="linenos">2784</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2785"><a href="#Select-2785"><span class="linenos">2785</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="Select-2786"><a href="#Select-2786"><span class="linenos">2786</span></a> <span class="n">on</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select-2787"><a href="#Select-2787"><span class="linenos">2787</span></a> <span class="n">using</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">ExpOrStr</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">ExpOrStr</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select-2788"><a href="#Select-2788"><span class="linenos">2788</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2789"><a href="#Select-2789"><span class="linenos">2789</span></a> <span class="n">join_type</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="Select-2790"><a href="#Select-2790"><span class="linenos">2790</span></a> <span class="n">join_alias</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">Identifier</span> <span class="o">|</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="Select-2791"><a href="#Select-2791"><span class="linenos">2791</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select-2792"><a href="#Select-2792"><span class="linenos">2792</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2793"><a href="#Select-2793"><span class="linenos">2793</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2794"><a href="#Select-2794"><span class="linenos">2794</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select-2795"><a href="#Select-2795"><span class="linenos">2795</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select-2796"><a href="#Select-2796"><span class="linenos">2796</span></a><span class="sd"> Append to or set the JOIN expressions.</span> -</span><span id="Select-2797"><a href="#Select-2797"><span class="linenos">2797</span></a> -</span><span id="Select-2798"><a href="#Select-2798"><span class="linenos">2798</span></a><span class="sd"> Example:</span> -</span><span id="Select-2799"><a href="#Select-2799"><span class="linenos">2799</span></a><span class="sd"> >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y").sql()</span> -</span><span id="Select-2800"><a href="#Select-2800"><span class="linenos">2800</span></a><span class="sd"> 'SELECT * FROM tbl JOIN tbl2 ON tbl1.y = tbl2.y'</span> -</span><span id="Select-2801"><a href="#Select-2801"><span class="linenos">2801</span></a> -</span><span id="Select-2802"><a href="#Select-2802"><span class="linenos">2802</span></a><span class="sd"> >>> Select().select("1").from_("a").join("b", using=["x", "y", "z"]).sql()</span> -</span><span id="Select-2803"><a href="#Select-2803"><span class="linenos">2803</span></a><span class="sd"> 'SELECT 1 FROM a JOIN b USING (x, y, z)'</span> -</span><span id="Select-2804"><a href="#Select-2804"><span class="linenos">2804</span></a> -</span><span id="Select-2805"><a href="#Select-2805"><span class="linenos">2805</span></a><span class="sd"> Use `join_type` to change the type of join:</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Select-2435"><a href="#Select-2435"><span class="linenos">2435</span></a><span class="k">class</span> <span class="nc">Select</span><span class="p">(</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="Select-2436"><a href="#Select-2436"><span class="linenos">2436</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Select-2437"><a href="#Select-2437"><span class="linenos">2437</span></a> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Select-2438"><a href="#Select-2438"><span class="linenos">2438</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Select-2439"><a href="#Select-2439"><span class="linenos">2439</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Select-2440"><a href="#Select-2440"><span class="linenos">2440</span></a> <span class="s2">"hint"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Select-2441"><a href="#Select-2441"><span class="linenos">2441</span></a> <span class="s2">"distinct"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Select-2442"><a href="#Select-2442"><span class="linenos">2442</span></a> <span class="s2">"into"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Select-2443"><a href="#Select-2443"><span class="linenos">2443</span></a> <span class="s2">"from"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Select-2444"><a href="#Select-2444"><span class="linenos">2444</span></a> <span class="o">**</span><span class="n">QUERY_MODIFIERS</span><span class="p">,</span> +</span><span id="Select-2445"><a href="#Select-2445"><span class="linenos">2445</span></a> <span class="p">}</span> +</span><span id="Select-2446"><a href="#Select-2446"><span class="linenos">2446</span></a> +</span><span id="Select-2447"><a href="#Select-2447"><span class="linenos">2447</span></a> <span class="k">def</span> <span class="nf">from_</span><span class="p">(</span> +</span><span id="Select-2448"><a href="#Select-2448"><span class="linenos">2448</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="Select-2449"><a href="#Select-2449"><span class="linenos">2449</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select-2450"><a href="#Select-2450"><span class="linenos">2450</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select-2451"><a href="#Select-2451"><span class="linenos">2451</span></a><span class="sd"> Set the FROM expression.</span> +</span><span id="Select-2452"><a href="#Select-2452"><span class="linenos">2452</span></a> +</span><span id="Select-2453"><a href="#Select-2453"><span class="linenos">2453</span></a><span class="sd"> Example:</span> +</span><span id="Select-2454"><a href="#Select-2454"><span class="linenos">2454</span></a><span class="sd"> >>> Select().from_("tbl").select("x").sql()</span> +</span><span id="Select-2455"><a href="#Select-2455"><span class="linenos">2455</span></a><span class="sd"> 'SELECT x FROM tbl'</span> +</span><span id="Select-2456"><a href="#Select-2456"><span class="linenos">2456</span></a> +</span><span id="Select-2457"><a href="#Select-2457"><span class="linenos">2457</span></a><span class="sd"> Args:</span> +</span><span id="Select-2458"><a href="#Select-2458"><span class="linenos">2458</span></a><span class="sd"> expression : the SQL code strings to parse.</span> +</span><span id="Select-2459"><a href="#Select-2459"><span class="linenos">2459</span></a><span class="sd"> If a `From` instance is passed, this is used as-is.</span> +</span><span id="Select-2460"><a href="#Select-2460"><span class="linenos">2460</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `From`.</span> +</span><span id="Select-2461"><a href="#Select-2461"><span class="linenos">2461</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="Select-2462"><a href="#Select-2462"><span class="linenos">2462</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select-2463"><a href="#Select-2463"><span class="linenos">2463</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select-2464"><a href="#Select-2464"><span class="linenos">2464</span></a> +</span><span id="Select-2465"><a href="#Select-2465"><span class="linenos">2465</span></a><span class="sd"> Returns:</span> +</span><span id="Select-2466"><a href="#Select-2466"><span class="linenos">2466</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="Select-2467"><a href="#Select-2467"><span class="linenos">2467</span></a><span class="sd"> """</span> +</span><span id="Select-2468"><a href="#Select-2468"><span class="linenos">2468</span></a> <span class="k">return</span> <span class="n">_apply_builder</span><span class="p">(</span> +</span><span id="Select-2469"><a href="#Select-2469"><span class="linenos">2469</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> +</span><span id="Select-2470"><a href="#Select-2470"><span class="linenos">2470</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2471"><a href="#Select-2471"><span class="linenos">2471</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"from"</span><span class="p">,</span> +</span><span id="Select-2472"><a href="#Select-2472"><span class="linenos">2472</span></a> <span class="n">into</span><span class="o">=</span><span class="n">From</span><span class="p">,</span> +</span><span id="Select-2473"><a href="#Select-2473"><span class="linenos">2473</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"FROM"</span><span class="p">,</span> +</span><span id="Select-2474"><a href="#Select-2474"><span class="linenos">2474</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select-2475"><a href="#Select-2475"><span class="linenos">2475</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select-2476"><a href="#Select-2476"><span class="linenos">2476</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2477"><a href="#Select-2477"><span class="linenos">2477</span></a> <span class="p">)</span> +</span><span id="Select-2478"><a href="#Select-2478"><span class="linenos">2478</span></a> +</span><span id="Select-2479"><a href="#Select-2479"><span class="linenos">2479</span></a> <span class="k">def</span> <span class="nf">group_by</span><span class="p">(</span> +</span><span id="Select-2480"><a href="#Select-2480"><span class="linenos">2480</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2481"><a href="#Select-2481"><span class="linenos">2481</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select-2482"><a href="#Select-2482"><span class="linenos">2482</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2483"><a href="#Select-2483"><span class="linenos">2483</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select-2484"><a href="#Select-2484"><span class="linenos">2484</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2485"><a href="#Select-2485"><span class="linenos">2485</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2486"><a href="#Select-2486"><span class="linenos">2486</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select-2487"><a href="#Select-2487"><span class="linenos">2487</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select-2488"><a href="#Select-2488"><span class="linenos">2488</span></a><span class="sd"> Set the GROUP BY expression.</span> +</span><span id="Select-2489"><a href="#Select-2489"><span class="linenos">2489</span></a> +</span><span id="Select-2490"><a href="#Select-2490"><span class="linenos">2490</span></a><span class="sd"> Example:</span> +</span><span id="Select-2491"><a href="#Select-2491"><span class="linenos">2491</span></a><span class="sd"> >>> Select().from_("tbl").select("x", "COUNT(1)").group_by("x").sql()</span> +</span><span id="Select-2492"><a href="#Select-2492"><span class="linenos">2492</span></a><span class="sd"> 'SELECT x, COUNT(1) FROM tbl GROUP BY x'</span> +</span><span id="Select-2493"><a href="#Select-2493"><span class="linenos">2493</span></a> +</span><span id="Select-2494"><a href="#Select-2494"><span class="linenos">2494</span></a><span class="sd"> Args:</span> +</span><span id="Select-2495"><a href="#Select-2495"><span class="linenos">2495</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="Select-2496"><a href="#Select-2496"><span class="linenos">2496</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> +</span><span id="Select-2497"><a href="#Select-2497"><span class="linenos">2497</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Group`.</span> +</span><span id="Select-2498"><a href="#Select-2498"><span class="linenos">2498</span></a><span class="sd"> If nothing is passed in then a group by is not applied to the expression</span> +</span><span id="Select-2499"><a href="#Select-2499"><span class="linenos">2499</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="Select-2500"><a href="#Select-2500"><span class="linenos">2500</span></a><span class="sd"> Otherwise, this flattens all the `Group` expression into a single expression.</span> +</span><span id="Select-2501"><a href="#Select-2501"><span class="linenos">2501</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="Select-2502"><a href="#Select-2502"><span class="linenos">2502</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select-2503"><a href="#Select-2503"><span class="linenos">2503</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select-2504"><a href="#Select-2504"><span class="linenos">2504</span></a> +</span><span id="Select-2505"><a href="#Select-2505"><span class="linenos">2505</span></a><span class="sd"> Returns:</span> +</span><span id="Select-2506"><a href="#Select-2506"><span class="linenos">2506</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="Select-2507"><a href="#Select-2507"><span class="linenos">2507</span></a><span class="sd"> """</span> +</span><span id="Select-2508"><a href="#Select-2508"><span class="linenos">2508</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="Select-2509"><a href="#Select-2509"><span class="linenos">2509</span></a> <span class="k">return</span> <span class="bp">self</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">copy</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Select-2510"><a href="#Select-2510"><span class="linenos">2510</span></a> +</span><span id="Select-2511"><a href="#Select-2511"><span class="linenos">2511</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> +</span><span id="Select-2512"><a href="#Select-2512"><span class="linenos">2512</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select-2513"><a href="#Select-2513"><span class="linenos">2513</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2514"><a href="#Select-2514"><span class="linenos">2514</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"group"</span><span class="p">,</span> +</span><span id="Select-2515"><a href="#Select-2515"><span class="linenos">2515</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select-2516"><a href="#Select-2516"><span class="linenos">2516</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select-2517"><a href="#Select-2517"><span class="linenos">2517</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"GROUP BY"</span><span class="p">,</span> +</span><span id="Select-2518"><a href="#Select-2518"><span class="linenos">2518</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Group</span><span class="p">,</span> +</span><span id="Select-2519"><a href="#Select-2519"><span class="linenos">2519</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select-2520"><a href="#Select-2520"><span class="linenos">2520</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2521"><a href="#Select-2521"><span class="linenos">2521</span></a> <span class="p">)</span> +</span><span id="Select-2522"><a href="#Select-2522"><span class="linenos">2522</span></a> +</span><span id="Select-2523"><a href="#Select-2523"><span class="linenos">2523</span></a> <span class="k">def</span> <span class="nf">order_by</span><span class="p">(</span> +</span><span id="Select-2524"><a href="#Select-2524"><span class="linenos">2524</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2525"><a href="#Select-2525"><span class="linenos">2525</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select-2526"><a href="#Select-2526"><span class="linenos">2526</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2527"><a href="#Select-2527"><span class="linenos">2527</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select-2528"><a href="#Select-2528"><span class="linenos">2528</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2529"><a href="#Select-2529"><span class="linenos">2529</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2530"><a href="#Select-2530"><span class="linenos">2530</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select-2531"><a href="#Select-2531"><span class="linenos">2531</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select-2532"><a href="#Select-2532"><span class="linenos">2532</span></a><span class="sd"> Set the ORDER BY expression.</span> +</span><span id="Select-2533"><a href="#Select-2533"><span class="linenos">2533</span></a> +</span><span id="Select-2534"><a href="#Select-2534"><span class="linenos">2534</span></a><span class="sd"> Example:</span> +</span><span id="Select-2535"><a href="#Select-2535"><span class="linenos">2535</span></a><span class="sd"> >>> Select().from_("tbl").select("x").order_by("x DESC").sql()</span> +</span><span id="Select-2536"><a href="#Select-2536"><span class="linenos">2536</span></a><span class="sd"> 'SELECT x FROM tbl ORDER BY x DESC'</span> +</span><span id="Select-2537"><a href="#Select-2537"><span class="linenos">2537</span></a> +</span><span id="Select-2538"><a href="#Select-2538"><span class="linenos">2538</span></a><span class="sd"> Args:</span> +</span><span id="Select-2539"><a href="#Select-2539"><span class="linenos">2539</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="Select-2540"><a href="#Select-2540"><span class="linenos">2540</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> +</span><span id="Select-2541"><a href="#Select-2541"><span class="linenos">2541</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Order`.</span> +</span><span id="Select-2542"><a href="#Select-2542"><span class="linenos">2542</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="Select-2543"><a href="#Select-2543"><span class="linenos">2543</span></a><span class="sd"> Otherwise, this flattens all the `Order` expression into a single expression.</span> +</span><span id="Select-2544"><a href="#Select-2544"><span class="linenos">2544</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="Select-2545"><a href="#Select-2545"><span class="linenos">2545</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select-2546"><a href="#Select-2546"><span class="linenos">2546</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select-2547"><a href="#Select-2547"><span class="linenos">2547</span></a> +</span><span id="Select-2548"><a href="#Select-2548"><span class="linenos">2548</span></a><span class="sd"> Returns:</span> +</span><span id="Select-2549"><a href="#Select-2549"><span class="linenos">2549</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="Select-2550"><a href="#Select-2550"><span class="linenos">2550</span></a><span class="sd"> """</span> +</span><span id="Select-2551"><a href="#Select-2551"><span class="linenos">2551</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> +</span><span id="Select-2552"><a href="#Select-2552"><span class="linenos">2552</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select-2553"><a href="#Select-2553"><span class="linenos">2553</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2554"><a href="#Select-2554"><span class="linenos">2554</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"order"</span><span class="p">,</span> +</span><span id="Select-2555"><a href="#Select-2555"><span class="linenos">2555</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select-2556"><a href="#Select-2556"><span class="linenos">2556</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select-2557"><a href="#Select-2557"><span class="linenos">2557</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ORDER BY"</span><span class="p">,</span> +</span><span id="Select-2558"><a href="#Select-2558"><span class="linenos">2558</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Order</span><span class="p">,</span> +</span><span id="Select-2559"><a href="#Select-2559"><span class="linenos">2559</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select-2560"><a href="#Select-2560"><span class="linenos">2560</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2561"><a href="#Select-2561"><span class="linenos">2561</span></a> <span class="p">)</span> +</span><span id="Select-2562"><a href="#Select-2562"><span class="linenos">2562</span></a> +</span><span id="Select-2563"><a href="#Select-2563"><span class="linenos">2563</span></a> <span class="k">def</span> <span class="nf">sort_by</span><span class="p">(</span> +</span><span id="Select-2564"><a href="#Select-2564"><span class="linenos">2564</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2565"><a href="#Select-2565"><span class="linenos">2565</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select-2566"><a href="#Select-2566"><span class="linenos">2566</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2567"><a href="#Select-2567"><span class="linenos">2567</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select-2568"><a href="#Select-2568"><span class="linenos">2568</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2569"><a href="#Select-2569"><span class="linenos">2569</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2570"><a href="#Select-2570"><span class="linenos">2570</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select-2571"><a href="#Select-2571"><span class="linenos">2571</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select-2572"><a href="#Select-2572"><span class="linenos">2572</span></a><span class="sd"> Set the SORT BY expression.</span> +</span><span id="Select-2573"><a href="#Select-2573"><span class="linenos">2573</span></a> +</span><span id="Select-2574"><a href="#Select-2574"><span class="linenos">2574</span></a><span class="sd"> Example:</span> +</span><span id="Select-2575"><a href="#Select-2575"><span class="linenos">2575</span></a><span class="sd"> >>> Select().from_("tbl").select("x").sort_by("x DESC").sql(dialect="hive")</span> +</span><span id="Select-2576"><a href="#Select-2576"><span class="linenos">2576</span></a><span class="sd"> 'SELECT x FROM tbl SORT BY x DESC'</span> +</span><span id="Select-2577"><a href="#Select-2577"><span class="linenos">2577</span></a> +</span><span id="Select-2578"><a href="#Select-2578"><span class="linenos">2578</span></a><span class="sd"> Args:</span> +</span><span id="Select-2579"><a href="#Select-2579"><span class="linenos">2579</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="Select-2580"><a href="#Select-2580"><span class="linenos">2580</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> +</span><span id="Select-2581"><a href="#Select-2581"><span class="linenos">2581</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `SORT`.</span> +</span><span id="Select-2582"><a href="#Select-2582"><span class="linenos">2582</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="Select-2583"><a href="#Select-2583"><span class="linenos">2583</span></a><span class="sd"> Otherwise, this flattens all the `Order` expression into a single expression.</span> +</span><span id="Select-2584"><a href="#Select-2584"><span class="linenos">2584</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="Select-2585"><a href="#Select-2585"><span class="linenos">2585</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select-2586"><a href="#Select-2586"><span class="linenos">2586</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select-2587"><a href="#Select-2587"><span class="linenos">2587</span></a> +</span><span id="Select-2588"><a href="#Select-2588"><span class="linenos">2588</span></a><span class="sd"> Returns:</span> +</span><span id="Select-2589"><a href="#Select-2589"><span class="linenos">2589</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="Select-2590"><a href="#Select-2590"><span class="linenos">2590</span></a><span class="sd"> """</span> +</span><span id="Select-2591"><a href="#Select-2591"><span class="linenos">2591</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> +</span><span id="Select-2592"><a href="#Select-2592"><span class="linenos">2592</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select-2593"><a href="#Select-2593"><span class="linenos">2593</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2594"><a href="#Select-2594"><span class="linenos">2594</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"sort"</span><span class="p">,</span> +</span><span id="Select-2595"><a href="#Select-2595"><span class="linenos">2595</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select-2596"><a href="#Select-2596"><span class="linenos">2596</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select-2597"><a href="#Select-2597"><span class="linenos">2597</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"SORT BY"</span><span class="p">,</span> +</span><span id="Select-2598"><a href="#Select-2598"><span class="linenos">2598</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Sort</span><span class="p">,</span> +</span><span id="Select-2599"><a href="#Select-2599"><span class="linenos">2599</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select-2600"><a href="#Select-2600"><span class="linenos">2600</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2601"><a href="#Select-2601"><span class="linenos">2601</span></a> <span class="p">)</span> +</span><span id="Select-2602"><a href="#Select-2602"><span class="linenos">2602</span></a> +</span><span id="Select-2603"><a href="#Select-2603"><span class="linenos">2603</span></a> <span class="k">def</span> <span class="nf">cluster_by</span><span class="p">(</span> +</span><span id="Select-2604"><a href="#Select-2604"><span class="linenos">2604</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2605"><a href="#Select-2605"><span class="linenos">2605</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select-2606"><a href="#Select-2606"><span class="linenos">2606</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2607"><a href="#Select-2607"><span class="linenos">2607</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select-2608"><a href="#Select-2608"><span class="linenos">2608</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2609"><a href="#Select-2609"><span class="linenos">2609</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2610"><a href="#Select-2610"><span class="linenos">2610</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select-2611"><a href="#Select-2611"><span class="linenos">2611</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select-2612"><a href="#Select-2612"><span class="linenos">2612</span></a><span class="sd"> Set the CLUSTER BY expression.</span> +</span><span id="Select-2613"><a href="#Select-2613"><span class="linenos">2613</span></a> +</span><span id="Select-2614"><a href="#Select-2614"><span class="linenos">2614</span></a><span class="sd"> Example:</span> +</span><span id="Select-2615"><a href="#Select-2615"><span class="linenos">2615</span></a><span class="sd"> >>> Select().from_("tbl").select("x").cluster_by("x DESC").sql(dialect="hive")</span> +</span><span id="Select-2616"><a href="#Select-2616"><span class="linenos">2616</span></a><span class="sd"> 'SELECT x FROM tbl CLUSTER BY x DESC'</span> +</span><span id="Select-2617"><a href="#Select-2617"><span class="linenos">2617</span></a> +</span><span id="Select-2618"><a href="#Select-2618"><span class="linenos">2618</span></a><span class="sd"> Args:</span> +</span><span id="Select-2619"><a href="#Select-2619"><span class="linenos">2619</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="Select-2620"><a href="#Select-2620"><span class="linenos">2620</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> +</span><span id="Select-2621"><a href="#Select-2621"><span class="linenos">2621</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Cluster`.</span> +</span><span id="Select-2622"><a href="#Select-2622"><span class="linenos">2622</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="Select-2623"><a href="#Select-2623"><span class="linenos">2623</span></a><span class="sd"> Otherwise, this flattens all the `Order` expression into a single expression.</span> +</span><span id="Select-2624"><a href="#Select-2624"><span class="linenos">2624</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="Select-2625"><a href="#Select-2625"><span class="linenos">2625</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select-2626"><a href="#Select-2626"><span class="linenos">2626</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select-2627"><a href="#Select-2627"><span class="linenos">2627</span></a> +</span><span id="Select-2628"><a href="#Select-2628"><span class="linenos">2628</span></a><span class="sd"> Returns:</span> +</span><span id="Select-2629"><a href="#Select-2629"><span class="linenos">2629</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="Select-2630"><a href="#Select-2630"><span class="linenos">2630</span></a><span class="sd"> """</span> +</span><span id="Select-2631"><a href="#Select-2631"><span class="linenos">2631</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> +</span><span id="Select-2632"><a href="#Select-2632"><span class="linenos">2632</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select-2633"><a href="#Select-2633"><span class="linenos">2633</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2634"><a href="#Select-2634"><span class="linenos">2634</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"cluster"</span><span class="p">,</span> +</span><span id="Select-2635"><a href="#Select-2635"><span class="linenos">2635</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select-2636"><a href="#Select-2636"><span class="linenos">2636</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select-2637"><a href="#Select-2637"><span class="linenos">2637</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"CLUSTER BY"</span><span class="p">,</span> +</span><span id="Select-2638"><a href="#Select-2638"><span class="linenos">2638</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Cluster</span><span class="p">,</span> +</span><span id="Select-2639"><a href="#Select-2639"><span class="linenos">2639</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select-2640"><a href="#Select-2640"><span class="linenos">2640</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2641"><a href="#Select-2641"><span class="linenos">2641</span></a> <span class="p">)</span> +</span><span id="Select-2642"><a href="#Select-2642"><span class="linenos">2642</span></a> +</span><span id="Select-2643"><a href="#Select-2643"><span class="linenos">2643</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span> +</span><span id="Select-2644"><a href="#Select-2644"><span class="linenos">2644</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="Select-2645"><a href="#Select-2645"><span class="linenos">2645</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select-2646"><a href="#Select-2646"><span class="linenos">2646</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select-2647"><a href="#Select-2647"><span class="linenos">2647</span></a><span class="sd"> Set the LIMIT expression.</span> +</span><span id="Select-2648"><a href="#Select-2648"><span class="linenos">2648</span></a> +</span><span id="Select-2649"><a href="#Select-2649"><span class="linenos">2649</span></a><span class="sd"> Example:</span> +</span><span id="Select-2650"><a href="#Select-2650"><span class="linenos">2650</span></a><span class="sd"> >>> Select().from_("tbl").select("x").limit(10).sql()</span> +</span><span id="Select-2651"><a href="#Select-2651"><span class="linenos">2651</span></a><span class="sd"> 'SELECT x FROM tbl LIMIT 10'</span> +</span><span id="Select-2652"><a href="#Select-2652"><span class="linenos">2652</span></a> +</span><span id="Select-2653"><a href="#Select-2653"><span class="linenos">2653</span></a><span class="sd"> Args:</span> +</span><span id="Select-2654"><a href="#Select-2654"><span class="linenos">2654</span></a><span class="sd"> expression: the SQL code string to parse.</span> +</span><span id="Select-2655"><a href="#Select-2655"><span class="linenos">2655</span></a><span class="sd"> This can also be an integer.</span> +</span><span id="Select-2656"><a href="#Select-2656"><span class="linenos">2656</span></a><span class="sd"> If a `Limit` instance is passed, this is used as-is.</span> +</span><span id="Select-2657"><a href="#Select-2657"><span class="linenos">2657</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Limit`.</span> +</span><span id="Select-2658"><a href="#Select-2658"><span class="linenos">2658</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="Select-2659"><a href="#Select-2659"><span class="linenos">2659</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select-2660"><a href="#Select-2660"><span class="linenos">2660</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select-2661"><a href="#Select-2661"><span class="linenos">2661</span></a> +</span><span id="Select-2662"><a href="#Select-2662"><span class="linenos">2662</span></a><span class="sd"> Returns:</span> +</span><span id="Select-2663"><a href="#Select-2663"><span class="linenos">2663</span></a><span class="sd"> Select: the modified expression.</span> +</span><span id="Select-2664"><a href="#Select-2664"><span class="linenos">2664</span></a><span class="sd"> """</span> +</span><span id="Select-2665"><a href="#Select-2665"><span class="linenos">2665</span></a> <span class="k">return</span> <span class="n">_apply_builder</span><span class="p">(</span> +</span><span id="Select-2666"><a href="#Select-2666"><span class="linenos">2666</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> +</span><span id="Select-2667"><a href="#Select-2667"><span class="linenos">2667</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2668"><a href="#Select-2668"><span class="linenos">2668</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"limit"</span><span class="p">,</span> +</span><span id="Select-2669"><a href="#Select-2669"><span class="linenos">2669</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Limit</span><span class="p">,</span> +</span><span id="Select-2670"><a href="#Select-2670"><span class="linenos">2670</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"LIMIT"</span><span class="p">,</span> +</span><span id="Select-2671"><a href="#Select-2671"><span class="linenos">2671</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select-2672"><a href="#Select-2672"><span class="linenos">2672</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select-2673"><a href="#Select-2673"><span class="linenos">2673</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2674"><a href="#Select-2674"><span class="linenos">2674</span></a> <span class="p">)</span> +</span><span id="Select-2675"><a href="#Select-2675"><span class="linenos">2675</span></a> +</span><span id="Select-2676"><a href="#Select-2676"><span class="linenos">2676</span></a> <span class="k">def</span> <span class="nf">offset</span><span class="p">(</span> +</span><span id="Select-2677"><a href="#Select-2677"><span class="linenos">2677</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="Select-2678"><a href="#Select-2678"><span class="linenos">2678</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select-2679"><a href="#Select-2679"><span class="linenos">2679</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select-2680"><a href="#Select-2680"><span class="linenos">2680</span></a><span class="sd"> Set the OFFSET expression.</span> +</span><span id="Select-2681"><a href="#Select-2681"><span class="linenos">2681</span></a> +</span><span id="Select-2682"><a href="#Select-2682"><span class="linenos">2682</span></a><span class="sd"> Example:</span> +</span><span id="Select-2683"><a href="#Select-2683"><span class="linenos">2683</span></a><span class="sd"> >>> Select().from_("tbl").select("x").offset(10).sql()</span> +</span><span id="Select-2684"><a href="#Select-2684"><span class="linenos">2684</span></a><span class="sd"> 'SELECT x FROM tbl OFFSET 10'</span> +</span><span id="Select-2685"><a href="#Select-2685"><span class="linenos">2685</span></a> +</span><span id="Select-2686"><a href="#Select-2686"><span class="linenos">2686</span></a><span class="sd"> Args:</span> +</span><span id="Select-2687"><a href="#Select-2687"><span class="linenos">2687</span></a><span class="sd"> expression: the SQL code string to parse.</span> +</span><span id="Select-2688"><a href="#Select-2688"><span class="linenos">2688</span></a><span class="sd"> This can also be an integer.</span> +</span><span id="Select-2689"><a href="#Select-2689"><span class="linenos">2689</span></a><span class="sd"> If a `Offset` instance is passed, this is used as-is.</span> +</span><span id="Select-2690"><a href="#Select-2690"><span class="linenos">2690</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Offset`.</span> +</span><span id="Select-2691"><a href="#Select-2691"><span class="linenos">2691</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="Select-2692"><a href="#Select-2692"><span class="linenos">2692</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select-2693"><a href="#Select-2693"><span class="linenos">2693</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select-2694"><a href="#Select-2694"><span class="linenos">2694</span></a> +</span><span id="Select-2695"><a href="#Select-2695"><span class="linenos">2695</span></a><span class="sd"> Returns:</span> +</span><span id="Select-2696"><a href="#Select-2696"><span class="linenos">2696</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="Select-2697"><a href="#Select-2697"><span class="linenos">2697</span></a><span class="sd"> """</span> +</span><span id="Select-2698"><a href="#Select-2698"><span class="linenos">2698</span></a> <span class="k">return</span> <span class="n">_apply_builder</span><span class="p">(</span> +</span><span id="Select-2699"><a href="#Select-2699"><span class="linenos">2699</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> +</span><span id="Select-2700"><a href="#Select-2700"><span class="linenos">2700</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2701"><a href="#Select-2701"><span class="linenos">2701</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"offset"</span><span class="p">,</span> +</span><span id="Select-2702"><a href="#Select-2702"><span class="linenos">2702</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Offset</span><span class="p">,</span> +</span><span id="Select-2703"><a href="#Select-2703"><span class="linenos">2703</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"OFFSET"</span><span class="p">,</span> +</span><span id="Select-2704"><a href="#Select-2704"><span class="linenos">2704</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select-2705"><a href="#Select-2705"><span class="linenos">2705</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select-2706"><a href="#Select-2706"><span class="linenos">2706</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2707"><a href="#Select-2707"><span class="linenos">2707</span></a> <span class="p">)</span> +</span><span id="Select-2708"><a href="#Select-2708"><span class="linenos">2708</span></a> +</span><span id="Select-2709"><a href="#Select-2709"><span class="linenos">2709</span></a> <span class="k">def</span> <span class="nf">select</span><span class="p">(</span> +</span><span id="Select-2710"><a href="#Select-2710"><span class="linenos">2710</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2711"><a href="#Select-2711"><span class="linenos">2711</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select-2712"><a href="#Select-2712"><span class="linenos">2712</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2713"><a href="#Select-2713"><span class="linenos">2713</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select-2714"><a href="#Select-2714"><span class="linenos">2714</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2715"><a href="#Select-2715"><span class="linenos">2715</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2716"><a href="#Select-2716"><span class="linenos">2716</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select-2717"><a href="#Select-2717"><span class="linenos">2717</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select-2718"><a href="#Select-2718"><span class="linenos">2718</span></a><span class="sd"> Append to or set the SELECT expressions.</span> +</span><span id="Select-2719"><a href="#Select-2719"><span class="linenos">2719</span></a> +</span><span id="Select-2720"><a href="#Select-2720"><span class="linenos">2720</span></a><span class="sd"> Example:</span> +</span><span id="Select-2721"><a href="#Select-2721"><span class="linenos">2721</span></a><span class="sd"> >>> Select().select("x", "y").sql()</span> +</span><span id="Select-2722"><a href="#Select-2722"><span class="linenos">2722</span></a><span class="sd"> 'SELECT x, y'</span> +</span><span id="Select-2723"><a href="#Select-2723"><span class="linenos">2723</span></a> +</span><span id="Select-2724"><a href="#Select-2724"><span class="linenos">2724</span></a><span class="sd"> Args:</span> +</span><span id="Select-2725"><a href="#Select-2725"><span class="linenos">2725</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="Select-2726"><a href="#Select-2726"><span class="linenos">2726</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="Select-2727"><a href="#Select-2727"><span class="linenos">2727</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="Select-2728"><a href="#Select-2728"><span class="linenos">2728</span></a><span class="sd"> Otherwise, this resets the expressions.</span> +</span><span id="Select-2729"><a href="#Select-2729"><span class="linenos">2729</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="Select-2730"><a href="#Select-2730"><span class="linenos">2730</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select-2731"><a href="#Select-2731"><span class="linenos">2731</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select-2732"><a href="#Select-2732"><span class="linenos">2732</span></a> +</span><span id="Select-2733"><a href="#Select-2733"><span class="linenos">2733</span></a><span class="sd"> Returns:</span> +</span><span id="Select-2734"><a href="#Select-2734"><span class="linenos">2734</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="Select-2735"><a href="#Select-2735"><span class="linenos">2735</span></a><span class="sd"> """</span> +</span><span id="Select-2736"><a href="#Select-2736"><span class="linenos">2736</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> +</span><span id="Select-2737"><a href="#Select-2737"><span class="linenos">2737</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select-2738"><a href="#Select-2738"><span class="linenos">2738</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2739"><a href="#Select-2739"><span class="linenos">2739</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"expressions"</span><span class="p">,</span> +</span><span id="Select-2740"><a href="#Select-2740"><span class="linenos">2740</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select-2741"><a href="#Select-2741"><span class="linenos">2741</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select-2742"><a href="#Select-2742"><span class="linenos">2742</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select-2743"><a href="#Select-2743"><span class="linenos">2743</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2744"><a href="#Select-2744"><span class="linenos">2744</span></a> <span class="p">)</span> +</span><span id="Select-2745"><a href="#Select-2745"><span class="linenos">2745</span></a> +</span><span id="Select-2746"><a href="#Select-2746"><span class="linenos">2746</span></a> <span class="k">def</span> <span class="nf">lateral</span><span class="p">(</span> +</span><span id="Select-2747"><a href="#Select-2747"><span class="linenos">2747</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2748"><a href="#Select-2748"><span class="linenos">2748</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select-2749"><a href="#Select-2749"><span class="linenos">2749</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2750"><a href="#Select-2750"><span class="linenos">2750</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select-2751"><a href="#Select-2751"><span class="linenos">2751</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2752"><a href="#Select-2752"><span class="linenos">2752</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2753"><a href="#Select-2753"><span class="linenos">2753</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select-2754"><a href="#Select-2754"><span class="linenos">2754</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select-2755"><a href="#Select-2755"><span class="linenos">2755</span></a><span class="sd"> Append to or set the LATERAL expressions.</span> +</span><span id="Select-2756"><a href="#Select-2756"><span class="linenos">2756</span></a> +</span><span id="Select-2757"><a href="#Select-2757"><span class="linenos">2757</span></a><span class="sd"> Example:</span> +</span><span id="Select-2758"><a href="#Select-2758"><span class="linenos">2758</span></a><span class="sd"> >>> Select().select("x").lateral("OUTER explode(y) tbl2 AS z").from_("tbl").sql()</span> +</span><span id="Select-2759"><a href="#Select-2759"><span class="linenos">2759</span></a><span class="sd"> 'SELECT x FROM tbl LATERAL VIEW OUTER EXPLODE(y) tbl2 AS z'</span> +</span><span id="Select-2760"><a href="#Select-2760"><span class="linenos">2760</span></a> +</span><span id="Select-2761"><a href="#Select-2761"><span class="linenos">2761</span></a><span class="sd"> Args:</span> +</span><span id="Select-2762"><a href="#Select-2762"><span class="linenos">2762</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="Select-2763"><a href="#Select-2763"><span class="linenos">2763</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="Select-2764"><a href="#Select-2764"><span class="linenos">2764</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="Select-2765"><a href="#Select-2765"><span class="linenos">2765</span></a><span class="sd"> Otherwise, this resets the expressions.</span> +</span><span id="Select-2766"><a href="#Select-2766"><span class="linenos">2766</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="Select-2767"><a href="#Select-2767"><span class="linenos">2767</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select-2768"><a href="#Select-2768"><span class="linenos">2768</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select-2769"><a href="#Select-2769"><span class="linenos">2769</span></a> +</span><span id="Select-2770"><a href="#Select-2770"><span class="linenos">2770</span></a><span class="sd"> Returns:</span> +</span><span id="Select-2771"><a href="#Select-2771"><span class="linenos">2771</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="Select-2772"><a href="#Select-2772"><span class="linenos">2772</span></a><span class="sd"> """</span> +</span><span id="Select-2773"><a href="#Select-2773"><span class="linenos">2773</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> +</span><span id="Select-2774"><a href="#Select-2774"><span class="linenos">2774</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select-2775"><a href="#Select-2775"><span class="linenos">2775</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2776"><a href="#Select-2776"><span class="linenos">2776</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"laterals"</span><span class="p">,</span> +</span><span id="Select-2777"><a href="#Select-2777"><span class="linenos">2777</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select-2778"><a href="#Select-2778"><span class="linenos">2778</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Lateral</span><span class="p">,</span> +</span><span id="Select-2779"><a href="#Select-2779"><span class="linenos">2779</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"LATERAL VIEW"</span><span class="p">,</span> +</span><span id="Select-2780"><a href="#Select-2780"><span class="linenos">2780</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select-2781"><a href="#Select-2781"><span class="linenos">2781</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select-2782"><a href="#Select-2782"><span class="linenos">2782</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2783"><a href="#Select-2783"><span class="linenos">2783</span></a> <span class="p">)</span> +</span><span id="Select-2784"><a href="#Select-2784"><span class="linenos">2784</span></a> +</span><span id="Select-2785"><a href="#Select-2785"><span class="linenos">2785</span></a> <span class="k">def</span> <span class="nf">join</span><span class="p">(</span> +</span><span id="Select-2786"><a href="#Select-2786"><span class="linenos">2786</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2787"><a href="#Select-2787"><span class="linenos">2787</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="Select-2788"><a href="#Select-2788"><span class="linenos">2788</span></a> <span class="n">on</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select-2789"><a href="#Select-2789"><span class="linenos">2789</span></a> <span class="n">using</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">ExpOrStr</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">ExpOrStr</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select-2790"><a href="#Select-2790"><span class="linenos">2790</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2791"><a href="#Select-2791"><span class="linenos">2791</span></a> <span class="n">join_type</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="Select-2792"><a href="#Select-2792"><span class="linenos">2792</span></a> <span class="n">join_alias</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">Identifier</span> <span class="o">|</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="Select-2793"><a href="#Select-2793"><span class="linenos">2793</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select-2794"><a href="#Select-2794"><span class="linenos">2794</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2795"><a href="#Select-2795"><span class="linenos">2795</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2796"><a href="#Select-2796"><span class="linenos">2796</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select-2797"><a href="#Select-2797"><span class="linenos">2797</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select-2798"><a href="#Select-2798"><span class="linenos">2798</span></a><span class="sd"> Append to or set the JOIN expressions.</span> +</span><span id="Select-2799"><a href="#Select-2799"><span class="linenos">2799</span></a> +</span><span id="Select-2800"><a href="#Select-2800"><span class="linenos">2800</span></a><span class="sd"> Example:</span> +</span><span id="Select-2801"><a href="#Select-2801"><span class="linenos">2801</span></a><span class="sd"> >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y").sql()</span> +</span><span id="Select-2802"><a href="#Select-2802"><span class="linenos">2802</span></a><span class="sd"> 'SELECT * FROM tbl JOIN tbl2 ON tbl1.y = tbl2.y'</span> +</span><span id="Select-2803"><a href="#Select-2803"><span class="linenos">2803</span></a> +</span><span id="Select-2804"><a href="#Select-2804"><span class="linenos">2804</span></a><span class="sd"> >>> Select().select("1").from_("a").join("b", using=["x", "y", "z"]).sql()</span> +</span><span id="Select-2805"><a href="#Select-2805"><span class="linenos">2805</span></a><span class="sd"> 'SELECT 1 FROM a JOIN b USING (x, y, z)'</span> </span><span id="Select-2806"><a href="#Select-2806"><span class="linenos">2806</span></a> -</span><span id="Select-2807"><a href="#Select-2807"><span class="linenos">2807</span></a><span class="sd"> >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y", join_type="left outer").sql()</span> -</span><span id="Select-2808"><a href="#Select-2808"><span class="linenos">2808</span></a><span class="sd"> 'SELECT * FROM tbl LEFT OUTER JOIN tbl2 ON tbl1.y = tbl2.y'</span> -</span><span id="Select-2809"><a href="#Select-2809"><span class="linenos">2809</span></a> -</span><span id="Select-2810"><a href="#Select-2810"><span class="linenos">2810</span></a><span class="sd"> Args:</span> -</span><span id="Select-2811"><a href="#Select-2811"><span class="linenos">2811</span></a><span class="sd"> expression: the SQL code string to parse.</span> -</span><span id="Select-2812"><a href="#Select-2812"><span class="linenos">2812</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Select-2813"><a href="#Select-2813"><span class="linenos">2813</span></a><span class="sd"> on: optionally specify the join "on" criteria as a SQL string.</span> +</span><span id="Select-2807"><a href="#Select-2807"><span class="linenos">2807</span></a><span class="sd"> Use `join_type` to change the type of join:</span> +</span><span id="Select-2808"><a href="#Select-2808"><span class="linenos">2808</span></a> +</span><span id="Select-2809"><a href="#Select-2809"><span class="linenos">2809</span></a><span class="sd"> >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y", join_type="left outer").sql()</span> +</span><span id="Select-2810"><a href="#Select-2810"><span class="linenos">2810</span></a><span class="sd"> 'SELECT * FROM tbl LEFT OUTER JOIN tbl2 ON tbl1.y = tbl2.y'</span> +</span><span id="Select-2811"><a href="#Select-2811"><span class="linenos">2811</span></a> +</span><span id="Select-2812"><a href="#Select-2812"><span class="linenos">2812</span></a><span class="sd"> Args:</span> +</span><span id="Select-2813"><a href="#Select-2813"><span class="linenos">2813</span></a><span class="sd"> expression: the SQL code string to parse.</span> </span><span id="Select-2814"><a href="#Select-2814"><span class="linenos">2814</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Select-2815"><a href="#Select-2815"><span class="linenos">2815</span></a><span class="sd"> using: optionally specify the join "using" criteria as a SQL string.</span> +</span><span id="Select-2815"><a href="#Select-2815"><span class="linenos">2815</span></a><span class="sd"> on: optionally specify the join "on" criteria as a SQL string.</span> </span><span id="Select-2816"><a href="#Select-2816"><span class="linenos">2816</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Select-2817"><a href="#Select-2817"><span class="linenos">2817</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="Select-2818"><a href="#Select-2818"><span class="linenos">2818</span></a><span class="sd"> Otherwise, this resets the expressions.</span> -</span><span id="Select-2819"><a href="#Select-2819"><span class="linenos">2819</span></a><span class="sd"> join_type: if set, alter the parsed join type.</span> -</span><span id="Select-2820"><a href="#Select-2820"><span class="linenos">2820</span></a><span class="sd"> join_alias: an optional alias for the joined source.</span> -</span><span id="Select-2821"><a href="#Select-2821"><span class="linenos">2821</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="Select-2822"><a href="#Select-2822"><span class="linenos">2822</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select-2823"><a href="#Select-2823"><span class="linenos">2823</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select-2824"><a href="#Select-2824"><span class="linenos">2824</span></a> -</span><span id="Select-2825"><a href="#Select-2825"><span class="linenos">2825</span></a><span class="sd"> Returns:</span> -</span><span id="Select-2826"><a href="#Select-2826"><span class="linenos">2826</span></a><span class="sd"> Select: the modified expression.</span> -</span><span id="Select-2827"><a href="#Select-2827"><span class="linenos">2827</span></a><span class="sd"> """</span> -</span><span id="Select-2828"><a href="#Select-2828"><span class="linenos">2828</span></a> <span class="n">parse_args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"dialect"</span><span class="p">:</span> <span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">}</span> -</span><span id="Select-2829"><a href="#Select-2829"><span class="linenos">2829</span></a> -</span><span id="Select-2830"><a href="#Select-2830"><span class="linenos">2830</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="Select-2831"><a href="#Select-2831"><span class="linenos">2831</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Join</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"JOIN"</span><span class="p">,</span> <span class="o">**</span><span class="n">parse_args</span><span class="p">)</span> -</span><span id="Select-2832"><a href="#Select-2832"><span class="linenos">2832</span></a> <span class="k">except</span> <span class="n">ParseError</span><span class="p">:</span> -</span><span id="Select-2833"><a href="#Select-2833"><span class="linenos">2833</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="p">(</span><span class="n">Join</span><span class="p">,</span> <span class="n">Expression</span><span class="p">),</span> <span class="o">**</span><span class="n">parse_args</span><span class="p">)</span> -</span><span id="Select-2834"><a href="#Select-2834"><span class="linenos">2834</span></a> -</span><span id="Select-2835"><a href="#Select-2835"><span class="linenos">2835</span></a> <span class="n">join</span> <span class="o">=</span> <span class="n">expression</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Join</span><span class="p">)</span> <span class="k">else</span> <span class="n">Join</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Select-2817"><a href="#Select-2817"><span class="linenos">2817</span></a><span class="sd"> using: optionally specify the join "using" criteria as a SQL string.</span> +</span><span id="Select-2818"><a href="#Select-2818"><span class="linenos">2818</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="Select-2819"><a href="#Select-2819"><span class="linenos">2819</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="Select-2820"><a href="#Select-2820"><span class="linenos">2820</span></a><span class="sd"> Otherwise, this resets the expressions.</span> +</span><span id="Select-2821"><a href="#Select-2821"><span class="linenos">2821</span></a><span class="sd"> join_type: if set, alter the parsed join type.</span> +</span><span id="Select-2822"><a href="#Select-2822"><span class="linenos">2822</span></a><span class="sd"> join_alias: an optional alias for the joined source.</span> +</span><span id="Select-2823"><a href="#Select-2823"><span class="linenos">2823</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="Select-2824"><a href="#Select-2824"><span class="linenos">2824</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select-2825"><a href="#Select-2825"><span class="linenos">2825</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select-2826"><a href="#Select-2826"><span class="linenos">2826</span></a> +</span><span id="Select-2827"><a href="#Select-2827"><span class="linenos">2827</span></a><span class="sd"> Returns:</span> +</span><span id="Select-2828"><a href="#Select-2828"><span class="linenos">2828</span></a><span class="sd"> Select: the modified expression.</span> +</span><span id="Select-2829"><a href="#Select-2829"><span class="linenos">2829</span></a><span class="sd"> """</span> +</span><span id="Select-2830"><a href="#Select-2830"><span class="linenos">2830</span></a> <span class="n">parse_args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"dialect"</span><span class="p">:</span> <span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">}</span> +</span><span id="Select-2831"><a href="#Select-2831"><span class="linenos">2831</span></a> +</span><span id="Select-2832"><a href="#Select-2832"><span class="linenos">2832</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="Select-2833"><a href="#Select-2833"><span class="linenos">2833</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Join</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"JOIN"</span><span class="p">,</span> <span class="o">**</span><span class="n">parse_args</span><span class="p">)</span> +</span><span id="Select-2834"><a href="#Select-2834"><span class="linenos">2834</span></a> <span class="k">except</span> <span class="n">ParseError</span><span class="p">:</span> +</span><span id="Select-2835"><a href="#Select-2835"><span class="linenos">2835</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="p">(</span><span class="n">Join</span><span class="p">,</span> <span class="n">Expression</span><span class="p">),</span> <span class="o">**</span><span class="n">parse_args</span><span class="p">)</span> </span><span id="Select-2836"><a href="#Select-2836"><span class="linenos">2836</span></a> -</span><span id="Select-2837"><a href="#Select-2837"><span class="linenos">2837</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">Select</span><span class="p">):</span> -</span><span id="Select-2838"><a href="#Select-2838"><span class="linenos">2838</span></a> <span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">subquery</span><span class="p">())</span> -</span><span id="Select-2839"><a href="#Select-2839"><span class="linenos">2839</span></a> -</span><span id="Select-2840"><a href="#Select-2840"><span class="linenos">2840</span></a> <span class="k">if</span> <span class="n">join_type</span><span class="p">:</span> -</span><span id="Select-2841"><a href="#Select-2841"><span class="linenos">2841</span></a> <span class="n">method</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">Token</span><span class="p">]</span> -</span><span id="Select-2842"><a href="#Select-2842"><span class="linenos">2842</span></a> <span class="n">side</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">Token</span><span class="p">]</span> -</span><span id="Select-2843"><a href="#Select-2843"><span class="linenos">2843</span></a> <span class="n">kind</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">Token</span><span class="p">]</span> -</span><span id="Select-2844"><a href="#Select-2844"><span class="linenos">2844</span></a> -</span><span id="Select-2845"><a href="#Select-2845"><span class="linenos">2845</span></a> <span class="n">method</span><span class="p">,</span> <span class="n">side</span><span class="p">,</span> <span class="n">kind</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">join_type</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="s2">"JOIN_TYPE"</span><span class="p">,</span> <span class="o">**</span><span class="n">parse_args</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="Select-2837"><a href="#Select-2837"><span class="linenos">2837</span></a> <span class="n">join</span> <span class="o">=</span> <span class="n">expression</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Join</span><span class="p">)</span> <span class="k">else</span> <span class="n">Join</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Select-2838"><a href="#Select-2838"><span class="linenos">2838</span></a> +</span><span id="Select-2839"><a href="#Select-2839"><span class="linenos">2839</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">Select</span><span class="p">):</span> +</span><span id="Select-2840"><a href="#Select-2840"><span class="linenos">2840</span></a> <span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">subquery</span><span class="p">())</span> +</span><span id="Select-2841"><a href="#Select-2841"><span class="linenos">2841</span></a> +</span><span id="Select-2842"><a href="#Select-2842"><span class="linenos">2842</span></a> <span class="k">if</span> <span class="n">join_type</span><span class="p">:</span> +</span><span id="Select-2843"><a href="#Select-2843"><span class="linenos">2843</span></a> <span class="n">method</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">Token</span><span class="p">]</span> +</span><span id="Select-2844"><a href="#Select-2844"><span class="linenos">2844</span></a> <span class="n">side</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">Token</span><span class="p">]</span> +</span><span id="Select-2845"><a href="#Select-2845"><span class="linenos">2845</span></a> <span class="n">kind</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">Token</span><span class="p">]</span> </span><span id="Select-2846"><a href="#Select-2846"><span class="linenos">2846</span></a> -</span><span id="Select-2847"><a href="#Select-2847"><span class="linenos">2847</span></a> <span class="k">if</span> <span class="n">method</span><span class="p">:</span> -</span><span id="Select-2848"><a href="#Select-2848"><span class="linenos">2848</span></a> <span class="n">join</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">method</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> -</span><span id="Select-2849"><a href="#Select-2849"><span class="linenos">2849</span></a> <span class="k">if</span> <span class="n">side</span><span class="p">:</span> -</span><span id="Select-2850"><a href="#Select-2850"><span class="linenos">2850</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"side"</span><span class="p">,</span> <span class="n">side</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> -</span><span id="Select-2851"><a href="#Select-2851"><span class="linenos">2851</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="Select-2852"><a href="#Select-2852"><span class="linenos">2852</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="n">kind</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> -</span><span id="Select-2853"><a href="#Select-2853"><span class="linenos">2853</span></a> -</span><span id="Select-2854"><a href="#Select-2854"><span class="linenos">2854</span></a> <span class="k">if</span> <span class="n">on</span><span class="p">:</span> -</span><span id="Select-2855"><a href="#Select-2855"><span class="linenos">2855</span></a> <span class="n">on</span> <span class="o">=</span> <span class="n">and_</span><span class="p">(</span><span class="o">*</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">on</span><span class="p">),</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="Select-2856"><a href="#Select-2856"><span class="linenos">2856</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"on"</span><span class="p">,</span> <span class="n">on</span><span class="p">)</span> -</span><span id="Select-2857"><a href="#Select-2857"><span class="linenos">2857</span></a> -</span><span id="Select-2858"><a href="#Select-2858"><span class="linenos">2858</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> -</span><span id="Select-2859"><a href="#Select-2859"><span class="linenos">2859</span></a> <span class="n">join</span> <span class="o">=</span> <span class="n">_apply_list_builder</span><span class="p">(</span> -</span><span id="Select-2860"><a href="#Select-2860"><span class="linenos">2860</span></a> <span class="o">*</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">using</span><span class="p">),</span> -</span><span id="Select-2861"><a href="#Select-2861"><span class="linenos">2861</span></a> <span class="n">instance</span><span class="o">=</span><span class="n">join</span><span class="p">,</span> -</span><span id="Select-2862"><a href="#Select-2862"><span class="linenos">2862</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"using"</span><span class="p">,</span> -</span><span id="Select-2863"><a href="#Select-2863"><span class="linenos">2863</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select-2864"><a href="#Select-2864"><span class="linenos">2864</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select-2865"><a href="#Select-2865"><span class="linenos">2865</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2866"><a href="#Select-2866"><span class="linenos">2866</span></a> <span class="p">)</span> -</span><span id="Select-2867"><a href="#Select-2867"><span class="linenos">2867</span></a> -</span><span id="Select-2868"><a href="#Select-2868"><span class="linenos">2868</span></a> <span class="k">if</span> <span class="n">join_alias</span><span class="p">:</span> -</span><span id="Select-2869"><a href="#Select-2869"><span class="linenos">2869</span></a> <span class="n">join</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">alias_</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">join_alias</span><span class="p">,</span> <span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> -</span><span id="Select-2870"><a href="#Select-2870"><span class="linenos">2870</span></a> -</span><span id="Select-2871"><a href="#Select-2871"><span class="linenos">2871</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> -</span><span id="Select-2872"><a href="#Select-2872"><span class="linenos">2872</span></a> <span class="n">join</span><span class="p">,</span> -</span><span id="Select-2873"><a href="#Select-2873"><span class="linenos">2873</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2874"><a href="#Select-2874"><span class="linenos">2874</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"joins"</span><span class="p">,</span> -</span><span id="Select-2875"><a href="#Select-2875"><span class="linenos">2875</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select-2876"><a href="#Select-2876"><span class="linenos">2876</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select-2877"><a href="#Select-2877"><span class="linenos">2877</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2878"><a href="#Select-2878"><span class="linenos">2878</span></a> <span class="p">)</span> -</span><span id="Select-2879"><a href="#Select-2879"><span class="linenos">2879</span></a> -</span><span id="Select-2880"><a href="#Select-2880"><span class="linenos">2880</span></a> <span class="k">def</span> <span class="nf">where</span><span class="p">(</span> -</span><span id="Select-2881"><a href="#Select-2881"><span class="linenos">2881</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2882"><a href="#Select-2882"><span class="linenos">2882</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select-2883"><a href="#Select-2883"><span class="linenos">2883</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2884"><a href="#Select-2884"><span class="linenos">2884</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select-2885"><a href="#Select-2885"><span class="linenos">2885</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2886"><a href="#Select-2886"><span class="linenos">2886</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2887"><a href="#Select-2887"><span class="linenos">2887</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select-2888"><a href="#Select-2888"><span class="linenos">2888</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select-2889"><a href="#Select-2889"><span class="linenos">2889</span></a><span class="sd"> Append to or set the WHERE expressions.</span> -</span><span id="Select-2890"><a href="#Select-2890"><span class="linenos">2890</span></a> -</span><span id="Select-2891"><a href="#Select-2891"><span class="linenos">2891</span></a><span class="sd"> Example:</span> -</span><span id="Select-2892"><a href="#Select-2892"><span class="linenos">2892</span></a><span class="sd"> >>> Select().select("x").from_("tbl").where("x = 'a' OR x < 'b'").sql()</span> -</span><span id="Select-2893"><a href="#Select-2893"><span class="linenos">2893</span></a><span class="sd"> "SELECT x FROM tbl WHERE x = 'a' OR x < 'b'"</span> -</span><span id="Select-2894"><a href="#Select-2894"><span class="linenos">2894</span></a> -</span><span id="Select-2895"><a href="#Select-2895"><span class="linenos">2895</span></a><span class="sd"> Args:</span> -</span><span id="Select-2896"><a href="#Select-2896"><span class="linenos">2896</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="Select-2897"><a href="#Select-2897"><span class="linenos">2897</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Select-2898"><a href="#Select-2898"><span class="linenos">2898</span></a><span class="sd"> Multiple expressions are combined with an AND operator.</span> -</span><span id="Select-2899"><a href="#Select-2899"><span class="linenos">2899</span></a><span class="sd"> append: if `True`, AND the new expressions to any existing expression.</span> -</span><span id="Select-2900"><a href="#Select-2900"><span class="linenos">2900</span></a><span class="sd"> Otherwise, this resets the expression.</span> -</span><span id="Select-2901"><a href="#Select-2901"><span class="linenos">2901</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="Select-2902"><a href="#Select-2902"><span class="linenos">2902</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select-2903"><a href="#Select-2903"><span class="linenos">2903</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select-2904"><a href="#Select-2904"><span class="linenos">2904</span></a> -</span><span id="Select-2905"><a href="#Select-2905"><span class="linenos">2905</span></a><span class="sd"> Returns:</span> -</span><span id="Select-2906"><a href="#Select-2906"><span class="linenos">2906</span></a><span class="sd"> Select: the modified expression.</span> -</span><span id="Select-2907"><a href="#Select-2907"><span class="linenos">2907</span></a><span class="sd"> """</span> -</span><span id="Select-2908"><a href="#Select-2908"><span class="linenos">2908</span></a> <span class="k">return</span> <span class="n">_apply_conjunction_builder</span><span class="p">(</span> -</span><span id="Select-2909"><a href="#Select-2909"><span class="linenos">2909</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select-2910"><a href="#Select-2910"><span class="linenos">2910</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2911"><a href="#Select-2911"><span class="linenos">2911</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"where"</span><span class="p">,</span> -</span><span id="Select-2912"><a href="#Select-2912"><span class="linenos">2912</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select-2913"><a href="#Select-2913"><span class="linenos">2913</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Where</span><span class="p">,</span> -</span><span id="Select-2914"><a href="#Select-2914"><span class="linenos">2914</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select-2915"><a href="#Select-2915"><span class="linenos">2915</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select-2916"><a href="#Select-2916"><span class="linenos">2916</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2917"><a href="#Select-2917"><span class="linenos">2917</span></a> <span class="p">)</span> -</span><span id="Select-2918"><a href="#Select-2918"><span class="linenos">2918</span></a> -</span><span id="Select-2919"><a href="#Select-2919"><span class="linenos">2919</span></a> <span class="k">def</span> <span class="nf">having</span><span class="p">(</span> -</span><span id="Select-2920"><a href="#Select-2920"><span class="linenos">2920</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2921"><a href="#Select-2921"><span class="linenos">2921</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select-2922"><a href="#Select-2922"><span class="linenos">2922</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2923"><a href="#Select-2923"><span class="linenos">2923</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select-2924"><a href="#Select-2924"><span class="linenos">2924</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2925"><a href="#Select-2925"><span class="linenos">2925</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2926"><a href="#Select-2926"><span class="linenos">2926</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select-2927"><a href="#Select-2927"><span class="linenos">2927</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select-2928"><a href="#Select-2928"><span class="linenos">2928</span></a><span class="sd"> Append to or set the HAVING expressions.</span> -</span><span id="Select-2929"><a href="#Select-2929"><span class="linenos">2929</span></a> -</span><span id="Select-2930"><a href="#Select-2930"><span class="linenos">2930</span></a><span class="sd"> Example:</span> -</span><span id="Select-2931"><a href="#Select-2931"><span class="linenos">2931</span></a><span class="sd"> >>> Select().select("x", "COUNT(y)").from_("tbl").group_by("x").having("COUNT(y) > 3").sql()</span> -</span><span id="Select-2932"><a href="#Select-2932"><span class="linenos">2932</span></a><span class="sd"> 'SELECT x, COUNT(y) FROM tbl GROUP BY x HAVING COUNT(y) > 3'</span> -</span><span id="Select-2933"><a href="#Select-2933"><span class="linenos">2933</span></a> -</span><span id="Select-2934"><a href="#Select-2934"><span class="linenos">2934</span></a><span class="sd"> Args:</span> -</span><span id="Select-2935"><a href="#Select-2935"><span class="linenos">2935</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="Select-2936"><a href="#Select-2936"><span class="linenos">2936</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Select-2937"><a href="#Select-2937"><span class="linenos">2937</span></a><span class="sd"> Multiple expressions are combined with an AND operator.</span> -</span><span id="Select-2938"><a href="#Select-2938"><span class="linenos">2938</span></a><span class="sd"> append: if `True`, AND the new expressions to any existing expression.</span> -</span><span id="Select-2939"><a href="#Select-2939"><span class="linenos">2939</span></a><span class="sd"> Otherwise, this resets the expression.</span> -</span><span id="Select-2940"><a href="#Select-2940"><span class="linenos">2940</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="Select-2941"><a href="#Select-2941"><span class="linenos">2941</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select-2942"><a href="#Select-2942"><span class="linenos">2942</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select-2943"><a href="#Select-2943"><span class="linenos">2943</span></a> -</span><span id="Select-2944"><a href="#Select-2944"><span class="linenos">2944</span></a><span class="sd"> Returns:</span> -</span><span id="Select-2945"><a href="#Select-2945"><span class="linenos">2945</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="Select-2946"><a href="#Select-2946"><span class="linenos">2946</span></a><span class="sd"> """</span> -</span><span id="Select-2947"><a href="#Select-2947"><span class="linenos">2947</span></a> <span class="k">return</span> <span class="n">_apply_conjunction_builder</span><span class="p">(</span> -</span><span id="Select-2948"><a href="#Select-2948"><span class="linenos">2948</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select-2949"><a href="#Select-2949"><span class="linenos">2949</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2950"><a href="#Select-2950"><span class="linenos">2950</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"having"</span><span class="p">,</span> -</span><span id="Select-2951"><a href="#Select-2951"><span class="linenos">2951</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select-2952"><a href="#Select-2952"><span class="linenos">2952</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Having</span><span class="p">,</span> -</span><span id="Select-2953"><a href="#Select-2953"><span class="linenos">2953</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select-2954"><a href="#Select-2954"><span class="linenos">2954</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select-2955"><a href="#Select-2955"><span class="linenos">2955</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2956"><a href="#Select-2956"><span class="linenos">2956</span></a> <span class="p">)</span> -</span><span id="Select-2957"><a href="#Select-2957"><span class="linenos">2957</span></a> -</span><span id="Select-2958"><a href="#Select-2958"><span class="linenos">2958</span></a> <span class="k">def</span> <span class="nf">window</span><span class="p">(</span> -</span><span id="Select-2959"><a href="#Select-2959"><span class="linenos">2959</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2960"><a href="#Select-2960"><span class="linenos">2960</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select-2961"><a href="#Select-2961"><span class="linenos">2961</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2962"><a href="#Select-2962"><span class="linenos">2962</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select-2963"><a href="#Select-2963"><span class="linenos">2963</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2964"><a href="#Select-2964"><span class="linenos">2964</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2965"><a href="#Select-2965"><span class="linenos">2965</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select-2966"><a href="#Select-2966"><span class="linenos">2966</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> -</span><span id="Select-2967"><a href="#Select-2967"><span class="linenos">2967</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select-2968"><a href="#Select-2968"><span class="linenos">2968</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2969"><a href="#Select-2969"><span class="linenos">2969</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"windows"</span><span class="p">,</span> -</span><span id="Select-2970"><a href="#Select-2970"><span class="linenos">2970</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select-2971"><a href="#Select-2971"><span class="linenos">2971</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Window</span><span class="p">,</span> -</span><span id="Select-2972"><a href="#Select-2972"><span class="linenos">2972</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select-2973"><a href="#Select-2973"><span class="linenos">2973</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select-2974"><a href="#Select-2974"><span class="linenos">2974</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2975"><a href="#Select-2975"><span class="linenos">2975</span></a> <span class="p">)</span> -</span><span id="Select-2976"><a href="#Select-2976"><span class="linenos">2976</span></a> -</span><span id="Select-2977"><a href="#Select-2977"><span class="linenos">2977</span></a> <span class="k">def</span> <span class="nf">qualify</span><span class="p">(</span> -</span><span id="Select-2978"><a href="#Select-2978"><span class="linenos">2978</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2979"><a href="#Select-2979"><span class="linenos">2979</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select-2980"><a href="#Select-2980"><span class="linenos">2980</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2981"><a href="#Select-2981"><span class="linenos">2981</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select-2982"><a href="#Select-2982"><span class="linenos">2982</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-2983"><a href="#Select-2983"><span class="linenos">2983</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2984"><a href="#Select-2984"><span class="linenos">2984</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select-2985"><a href="#Select-2985"><span class="linenos">2985</span></a> <span class="k">return</span> <span class="n">_apply_conjunction_builder</span><span class="p">(</span> -</span><span id="Select-2986"><a href="#Select-2986"><span class="linenos">2986</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select-2987"><a href="#Select-2987"><span class="linenos">2987</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select-2988"><a href="#Select-2988"><span class="linenos">2988</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"qualify"</span><span class="p">,</span> -</span><span id="Select-2989"><a href="#Select-2989"><span class="linenos">2989</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select-2990"><a href="#Select-2990"><span class="linenos">2990</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Qualify</span><span class="p">,</span> -</span><span id="Select-2991"><a href="#Select-2991"><span class="linenos">2991</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select-2992"><a href="#Select-2992"><span class="linenos">2992</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select-2993"><a href="#Select-2993"><span class="linenos">2993</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-2994"><a href="#Select-2994"><span class="linenos">2994</span></a> <span class="p">)</span> -</span><span id="Select-2995"><a href="#Select-2995"><span class="linenos">2995</span></a> -</span><span id="Select-2996"><a href="#Select-2996"><span class="linenos">2996</span></a> <span class="k">def</span> <span class="nf">distinct</span><span class="p">(</span> -</span><span id="Select-2997"><a href="#Select-2997"><span class="linenos">2997</span></a> <span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">ons</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">ExpOrStr</span><span class="p">],</span> <span class="n">distinct</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Select-2998"><a href="#Select-2998"><span class="linenos">2998</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select-2999"><a href="#Select-2999"><span class="linenos">2999</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select-3000"><a href="#Select-3000"><span class="linenos">3000</span></a><span class="sd"> Set the OFFSET expression.</span> -</span><span id="Select-3001"><a href="#Select-3001"><span class="linenos">3001</span></a> -</span><span id="Select-3002"><a href="#Select-3002"><span class="linenos">3002</span></a><span class="sd"> Example:</span> -</span><span id="Select-3003"><a href="#Select-3003"><span class="linenos">3003</span></a><span class="sd"> >>> Select().from_("tbl").select("x").distinct().sql()</span> -</span><span id="Select-3004"><a href="#Select-3004"><span class="linenos">3004</span></a><span class="sd"> 'SELECT DISTINCT x FROM tbl'</span> -</span><span id="Select-3005"><a href="#Select-3005"><span class="linenos">3005</span></a> -</span><span id="Select-3006"><a href="#Select-3006"><span class="linenos">3006</span></a><span class="sd"> Args:</span> -</span><span id="Select-3007"><a href="#Select-3007"><span class="linenos">3007</span></a><span class="sd"> ons: the expressions to distinct on</span> -</span><span id="Select-3008"><a href="#Select-3008"><span class="linenos">3008</span></a><span class="sd"> distinct: whether the Select should be distinct</span> -</span><span id="Select-3009"><a href="#Select-3009"><span class="linenos">3009</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select-3010"><a href="#Select-3010"><span class="linenos">3010</span></a> -</span><span id="Select-3011"><a href="#Select-3011"><span class="linenos">3011</span></a><span class="sd"> Returns:</span> -</span><span id="Select-3012"><a href="#Select-3012"><span class="linenos">3012</span></a><span class="sd"> Select: the modified expression.</span> -</span><span id="Select-3013"><a href="#Select-3013"><span class="linenos">3013</span></a><span class="sd"> """</span> -</span><span id="Select-3014"><a href="#Select-3014"><span class="linenos">3014</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="Select-3015"><a href="#Select-3015"><span class="linenos">3015</span></a> <span class="n">on</span> <span class="o">=</span> <span class="n">Tuple</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">on</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">on</span> <span class="ow">in</span> <span class="n">ons</span> <span class="k">if</span> <span class="n">on</span><span class="p">])</span> <span class="k">if</span> <span class="n">ons</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="Select-3016"><a href="#Select-3016"><span class="linenos">3016</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"distinct"</span><span class="p">,</span> <span class="n">Distinct</span><span class="p">(</span><span class="n">on</span><span class="o">=</span><span class="n">on</span><span class="p">)</span> <span class="k">if</span> <span class="n">distinct</span> <span class="k">else</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="Select-3017"><a href="#Select-3017"><span class="linenos">3017</span></a> <span class="k">return</span> <span class="n">instance</span> -</span><span id="Select-3018"><a href="#Select-3018"><span class="linenos">3018</span></a> -</span><span id="Select-3019"><a href="#Select-3019"><span class="linenos">3019</span></a> <span class="k">def</span> <span class="nf">ctas</span><span class="p">(</span> -</span><span id="Select-3020"><a href="#Select-3020"><span class="linenos">3020</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select-3021"><a href="#Select-3021"><span class="linenos">3021</span></a> <span class="n">table</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="Select-3022"><a href="#Select-3022"><span class="linenos">3022</span></a> <span class="n">properties</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select-3023"><a href="#Select-3023"><span class="linenos">3023</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select-3024"><a href="#Select-3024"><span class="linenos">3024</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select-3025"><a href="#Select-3025"><span class="linenos">3025</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-3026"><a href="#Select-3026"><span class="linenos">3026</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Create</span><span class="p">:</span> -</span><span id="Select-3027"><a href="#Select-3027"><span class="linenos">3027</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select-3028"><a href="#Select-3028"><span class="linenos">3028</span></a><span class="sd"> Convert this expression to a CREATE TABLE AS statement.</span> -</span><span id="Select-3029"><a href="#Select-3029"><span class="linenos">3029</span></a> -</span><span id="Select-3030"><a href="#Select-3030"><span class="linenos">3030</span></a><span class="sd"> Example:</span> -</span><span id="Select-3031"><a href="#Select-3031"><span class="linenos">3031</span></a><span class="sd"> >>> Select().select("*").from_("tbl").ctas("x").sql()</span> -</span><span id="Select-3032"><a href="#Select-3032"><span class="linenos">3032</span></a><span class="sd"> 'CREATE TABLE x AS SELECT * FROM tbl'</span> -</span><span id="Select-3033"><a href="#Select-3033"><span class="linenos">3033</span></a> -</span><span id="Select-3034"><a href="#Select-3034"><span class="linenos">3034</span></a><span class="sd"> Args:</span> -</span><span id="Select-3035"><a href="#Select-3035"><span class="linenos">3035</span></a><span class="sd"> table: the SQL code string to parse as the table name.</span> -</span><span id="Select-3036"><a href="#Select-3036"><span class="linenos">3036</span></a><span class="sd"> If another `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Select-3037"><a href="#Select-3037"><span class="linenos">3037</span></a><span class="sd"> properties: an optional mapping of table properties</span> -</span><span id="Select-3038"><a href="#Select-3038"><span class="linenos">3038</span></a><span class="sd"> dialect: the dialect used to parse the input table.</span> -</span><span id="Select-3039"><a href="#Select-3039"><span class="linenos">3039</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select-3040"><a href="#Select-3040"><span class="linenos">3040</span></a><span class="sd"> opts: other options to use to parse the input table.</span> -</span><span id="Select-3041"><a href="#Select-3041"><span class="linenos">3041</span></a> -</span><span id="Select-3042"><a href="#Select-3042"><span class="linenos">3042</span></a><span class="sd"> Returns:</span> -</span><span id="Select-3043"><a href="#Select-3043"><span class="linenos">3043</span></a><span class="sd"> The new Create expression.</span> -</span><span id="Select-3044"><a href="#Select-3044"><span class="linenos">3044</span></a><span class="sd"> """</span> -</span><span id="Select-3045"><a href="#Select-3045"><span class="linenos">3045</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="Select-3046"><a href="#Select-3046"><span class="linenos">3046</span></a> <span class="n">table_expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span> -</span><span id="Select-3047"><a href="#Select-3047"><span class="linenos">3047</span></a> <span class="n">table</span><span class="p">,</span> -</span><span id="Select-3048"><a href="#Select-3048"><span class="linenos">3048</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">,</span> -</span><span id="Select-3049"><a href="#Select-3049"><span class="linenos">3049</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select-3050"><a href="#Select-3050"><span class="linenos">3050</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select-3051"><a href="#Select-3051"><span class="linenos">3051</span></a> <span class="p">)</span> -</span><span id="Select-3052"><a href="#Select-3052"><span class="linenos">3052</span></a> <span class="n">properties_expression</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Select-3053"><a href="#Select-3053"><span class="linenos">3053</span></a> <span class="k">if</span> <span class="n">properties</span><span class="p">:</span> -</span><span id="Select-3054"><a href="#Select-3054"><span class="linenos">3054</span></a> <span class="n">properties_expression</span> <span class="o">=</span> <span class="n">Properties</span><span class="o">.</span><span class="n">from_dict</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span> -</span><span id="Select-3055"><a href="#Select-3055"><span class="linenos">3055</span></a> -</span><span id="Select-3056"><a href="#Select-3056"><span class="linenos">3056</span></a> <span class="k">return</span> <span class="n">Create</span><span class="p">(</span> -</span><span id="Select-3057"><a href="#Select-3057"><span class="linenos">3057</span></a> <span class="n">this</span><span class="o">=</span><span class="n">table_expression</span><span class="p">,</span> -</span><span id="Select-3058"><a href="#Select-3058"><span class="linenos">3058</span></a> <span class="n">kind</span><span class="o">=</span><span class="s2">"table"</span><span class="p">,</span> -</span><span id="Select-3059"><a href="#Select-3059"><span class="linenos">3059</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">instance</span><span class="p">,</span> -</span><span id="Select-3060"><a href="#Select-3060"><span class="linenos">3060</span></a> <span class="n">properties</span><span class="o">=</span><span class="n">properties_expression</span><span class="p">,</span> -</span><span id="Select-3061"><a href="#Select-3061"><span class="linenos">3061</span></a> <span class="p">)</span> -</span><span id="Select-3062"><a href="#Select-3062"><span class="linenos">3062</span></a> -</span><span id="Select-3063"><a href="#Select-3063"><span class="linenos">3063</span></a> <span class="k">def</span> <span class="nf">lock</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">update</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select-3064"><a href="#Select-3064"><span class="linenos">3064</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select-3065"><a href="#Select-3065"><span class="linenos">3065</span></a><span class="sd"> Set the locking read mode for this expression.</span> -</span><span id="Select-3066"><a href="#Select-3066"><span class="linenos">3066</span></a> -</span><span id="Select-3067"><a href="#Select-3067"><span class="linenos">3067</span></a><span class="sd"> Examples:</span> -</span><span id="Select-3068"><a href="#Select-3068"><span class="linenos">3068</span></a><span class="sd"> >>> Select().select("x").from_("tbl").where("x = 'a'").lock().sql("mysql")</span> -</span><span id="Select-3069"><a href="#Select-3069"><span class="linenos">3069</span></a><span class="sd"> "SELECT x FROM tbl WHERE x = 'a' FOR UPDATE"</span> -</span><span id="Select-3070"><a href="#Select-3070"><span class="linenos">3070</span></a> -</span><span id="Select-3071"><a href="#Select-3071"><span class="linenos">3071</span></a><span class="sd"> >>> Select().select("x").from_("tbl").where("x = 'a'").lock(update=False).sql("mysql")</span> -</span><span id="Select-3072"><a href="#Select-3072"><span class="linenos">3072</span></a><span class="sd"> "SELECT x FROM tbl WHERE x = 'a' FOR SHARE"</span> -</span><span id="Select-3073"><a href="#Select-3073"><span class="linenos">3073</span></a> -</span><span id="Select-3074"><a href="#Select-3074"><span class="linenos">3074</span></a><span class="sd"> Args:</span> -</span><span id="Select-3075"><a href="#Select-3075"><span class="linenos">3075</span></a><span class="sd"> update: if `True`, the locking type will be `FOR UPDATE`, else it will be `FOR SHARE`.</span> -</span><span id="Select-3076"><a href="#Select-3076"><span class="linenos">3076</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select-3077"><a href="#Select-3077"><span class="linenos">3077</span></a> -</span><span id="Select-3078"><a href="#Select-3078"><span class="linenos">3078</span></a><span class="sd"> Returns:</span> -</span><span id="Select-3079"><a href="#Select-3079"><span class="linenos">3079</span></a><span class="sd"> The modified expression.</span> -</span><span id="Select-3080"><a href="#Select-3080"><span class="linenos">3080</span></a><span class="sd"> """</span> -</span><span id="Select-3081"><a href="#Select-3081"><span class="linenos">3081</span></a> <span class="n">inst</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="Select-3082"><a href="#Select-3082"><span class="linenos">3082</span></a> <span class="n">inst</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"locks"</span><span class="p">,</span> <span class="p">[</span><span class="n">Lock</span><span class="p">(</span><span class="n">update</span><span class="o">=</span><span class="n">update</span><span class="p">)])</span> -</span><span id="Select-3083"><a href="#Select-3083"><span class="linenos">3083</span></a> -</span><span id="Select-3084"><a href="#Select-3084"><span class="linenos">3084</span></a> <span class="k">return</span> <span class="n">inst</span> +</span><span id="Select-2847"><a href="#Select-2847"><span class="linenos">2847</span></a> <span class="n">method</span><span class="p">,</span> <span class="n">side</span><span class="p">,</span> <span class="n">kind</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">join_type</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="s2">"JOIN_TYPE"</span><span class="p">,</span> <span class="o">**</span><span class="n">parse_args</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="Select-2848"><a href="#Select-2848"><span class="linenos">2848</span></a> +</span><span id="Select-2849"><a href="#Select-2849"><span class="linenos">2849</span></a> <span class="k">if</span> <span class="n">method</span><span class="p">:</span> +</span><span id="Select-2850"><a href="#Select-2850"><span class="linenos">2850</span></a> <span class="n">join</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">method</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> +</span><span id="Select-2851"><a href="#Select-2851"><span class="linenos">2851</span></a> <span class="k">if</span> <span class="n">side</span><span class="p">:</span> +</span><span id="Select-2852"><a href="#Select-2852"><span class="linenos">2852</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"side"</span><span class="p">,</span> <span class="n">side</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> +</span><span id="Select-2853"><a href="#Select-2853"><span class="linenos">2853</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="Select-2854"><a href="#Select-2854"><span class="linenos">2854</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="n">kind</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> +</span><span id="Select-2855"><a href="#Select-2855"><span class="linenos">2855</span></a> +</span><span id="Select-2856"><a href="#Select-2856"><span class="linenos">2856</span></a> <span class="k">if</span> <span class="n">on</span><span class="p">:</span> +</span><span id="Select-2857"><a href="#Select-2857"><span class="linenos">2857</span></a> <span class="n">on</span> <span class="o">=</span> <span class="n">and_</span><span class="p">(</span><span class="o">*</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">on</span><span class="p">),</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="Select-2858"><a href="#Select-2858"><span class="linenos">2858</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"on"</span><span class="p">,</span> <span class="n">on</span><span class="p">)</span> +</span><span id="Select-2859"><a href="#Select-2859"><span class="linenos">2859</span></a> +</span><span id="Select-2860"><a href="#Select-2860"><span class="linenos">2860</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> +</span><span id="Select-2861"><a href="#Select-2861"><span class="linenos">2861</span></a> <span class="n">join</span> <span class="o">=</span> <span class="n">_apply_list_builder</span><span class="p">(</span> +</span><span id="Select-2862"><a href="#Select-2862"><span class="linenos">2862</span></a> <span class="o">*</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">using</span><span class="p">),</span> +</span><span id="Select-2863"><a href="#Select-2863"><span class="linenos">2863</span></a> <span class="n">instance</span><span class="o">=</span><span class="n">join</span><span class="p">,</span> +</span><span id="Select-2864"><a href="#Select-2864"><span class="linenos">2864</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"using"</span><span class="p">,</span> +</span><span id="Select-2865"><a href="#Select-2865"><span class="linenos">2865</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select-2866"><a href="#Select-2866"><span class="linenos">2866</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select-2867"><a href="#Select-2867"><span class="linenos">2867</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2868"><a href="#Select-2868"><span class="linenos">2868</span></a> <span class="p">)</span> +</span><span id="Select-2869"><a href="#Select-2869"><span class="linenos">2869</span></a> +</span><span id="Select-2870"><a href="#Select-2870"><span class="linenos">2870</span></a> <span class="k">if</span> <span class="n">join_alias</span><span class="p">:</span> +</span><span id="Select-2871"><a href="#Select-2871"><span class="linenos">2871</span></a> <span class="n">join</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">alias_</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">join_alias</span><span class="p">,</span> <span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="Select-2872"><a href="#Select-2872"><span class="linenos">2872</span></a> +</span><span id="Select-2873"><a href="#Select-2873"><span class="linenos">2873</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> +</span><span id="Select-2874"><a href="#Select-2874"><span class="linenos">2874</span></a> <span class="n">join</span><span class="p">,</span> +</span><span id="Select-2875"><a href="#Select-2875"><span class="linenos">2875</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2876"><a href="#Select-2876"><span class="linenos">2876</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"joins"</span><span class="p">,</span> +</span><span id="Select-2877"><a href="#Select-2877"><span class="linenos">2877</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select-2878"><a href="#Select-2878"><span class="linenos">2878</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select-2879"><a href="#Select-2879"><span class="linenos">2879</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2880"><a href="#Select-2880"><span class="linenos">2880</span></a> <span class="p">)</span> +</span><span id="Select-2881"><a href="#Select-2881"><span class="linenos">2881</span></a> +</span><span id="Select-2882"><a href="#Select-2882"><span class="linenos">2882</span></a> <span class="k">def</span> <span class="nf">where</span><span class="p">(</span> +</span><span id="Select-2883"><a href="#Select-2883"><span class="linenos">2883</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2884"><a href="#Select-2884"><span class="linenos">2884</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select-2885"><a href="#Select-2885"><span class="linenos">2885</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2886"><a href="#Select-2886"><span class="linenos">2886</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select-2887"><a href="#Select-2887"><span class="linenos">2887</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2888"><a href="#Select-2888"><span class="linenos">2888</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2889"><a href="#Select-2889"><span class="linenos">2889</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select-2890"><a href="#Select-2890"><span class="linenos">2890</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select-2891"><a href="#Select-2891"><span class="linenos">2891</span></a><span class="sd"> Append to or set the WHERE expressions.</span> +</span><span id="Select-2892"><a href="#Select-2892"><span class="linenos">2892</span></a> +</span><span id="Select-2893"><a href="#Select-2893"><span class="linenos">2893</span></a><span class="sd"> Example:</span> +</span><span id="Select-2894"><a href="#Select-2894"><span class="linenos">2894</span></a><span class="sd"> >>> Select().select("x").from_("tbl").where("x = 'a' OR x < 'b'").sql()</span> +</span><span id="Select-2895"><a href="#Select-2895"><span class="linenos">2895</span></a><span class="sd"> "SELECT x FROM tbl WHERE x = 'a' OR x < 'b'"</span> +</span><span id="Select-2896"><a href="#Select-2896"><span class="linenos">2896</span></a> +</span><span id="Select-2897"><a href="#Select-2897"><span class="linenos">2897</span></a><span class="sd"> Args:</span> +</span><span id="Select-2898"><a href="#Select-2898"><span class="linenos">2898</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="Select-2899"><a href="#Select-2899"><span class="linenos">2899</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="Select-2900"><a href="#Select-2900"><span class="linenos">2900</span></a><span class="sd"> Multiple expressions are combined with an AND operator.</span> +</span><span id="Select-2901"><a href="#Select-2901"><span class="linenos">2901</span></a><span class="sd"> append: if `True`, AND the new expressions to any existing expression.</span> +</span><span id="Select-2902"><a href="#Select-2902"><span class="linenos">2902</span></a><span class="sd"> Otherwise, this resets the expression.</span> +</span><span id="Select-2903"><a href="#Select-2903"><span class="linenos">2903</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="Select-2904"><a href="#Select-2904"><span class="linenos">2904</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select-2905"><a href="#Select-2905"><span class="linenos">2905</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select-2906"><a href="#Select-2906"><span class="linenos">2906</span></a> +</span><span id="Select-2907"><a href="#Select-2907"><span class="linenos">2907</span></a><span class="sd"> Returns:</span> +</span><span id="Select-2908"><a href="#Select-2908"><span class="linenos">2908</span></a><span class="sd"> Select: the modified expression.</span> +</span><span id="Select-2909"><a href="#Select-2909"><span class="linenos">2909</span></a><span class="sd"> """</span> +</span><span id="Select-2910"><a href="#Select-2910"><span class="linenos">2910</span></a> <span class="k">return</span> <span class="n">_apply_conjunction_builder</span><span class="p">(</span> +</span><span id="Select-2911"><a href="#Select-2911"><span class="linenos">2911</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select-2912"><a href="#Select-2912"><span class="linenos">2912</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2913"><a href="#Select-2913"><span class="linenos">2913</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"where"</span><span class="p">,</span> +</span><span id="Select-2914"><a href="#Select-2914"><span class="linenos">2914</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select-2915"><a href="#Select-2915"><span class="linenos">2915</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Where</span><span class="p">,</span> +</span><span id="Select-2916"><a href="#Select-2916"><span class="linenos">2916</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select-2917"><a href="#Select-2917"><span class="linenos">2917</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select-2918"><a href="#Select-2918"><span class="linenos">2918</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2919"><a href="#Select-2919"><span class="linenos">2919</span></a> <span class="p">)</span> +</span><span id="Select-2920"><a href="#Select-2920"><span class="linenos">2920</span></a> +</span><span id="Select-2921"><a href="#Select-2921"><span class="linenos">2921</span></a> <span class="k">def</span> <span class="nf">having</span><span class="p">(</span> +</span><span id="Select-2922"><a href="#Select-2922"><span class="linenos">2922</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2923"><a href="#Select-2923"><span class="linenos">2923</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select-2924"><a href="#Select-2924"><span class="linenos">2924</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2925"><a href="#Select-2925"><span class="linenos">2925</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select-2926"><a href="#Select-2926"><span class="linenos">2926</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2927"><a href="#Select-2927"><span class="linenos">2927</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2928"><a href="#Select-2928"><span class="linenos">2928</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select-2929"><a href="#Select-2929"><span class="linenos">2929</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select-2930"><a href="#Select-2930"><span class="linenos">2930</span></a><span class="sd"> Append to or set the HAVING expressions.</span> +</span><span id="Select-2931"><a href="#Select-2931"><span class="linenos">2931</span></a> +</span><span id="Select-2932"><a href="#Select-2932"><span class="linenos">2932</span></a><span class="sd"> Example:</span> +</span><span id="Select-2933"><a href="#Select-2933"><span class="linenos">2933</span></a><span class="sd"> >>> Select().select("x", "COUNT(y)").from_("tbl").group_by("x").having("COUNT(y) > 3").sql()</span> +</span><span id="Select-2934"><a href="#Select-2934"><span class="linenos">2934</span></a><span class="sd"> 'SELECT x, COUNT(y) FROM tbl GROUP BY x HAVING COUNT(y) > 3'</span> +</span><span id="Select-2935"><a href="#Select-2935"><span class="linenos">2935</span></a> +</span><span id="Select-2936"><a href="#Select-2936"><span class="linenos">2936</span></a><span class="sd"> Args:</span> +</span><span id="Select-2937"><a href="#Select-2937"><span class="linenos">2937</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="Select-2938"><a href="#Select-2938"><span class="linenos">2938</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="Select-2939"><a href="#Select-2939"><span class="linenos">2939</span></a><span class="sd"> Multiple expressions are combined with an AND operator.</span> +</span><span id="Select-2940"><a href="#Select-2940"><span class="linenos">2940</span></a><span class="sd"> append: if `True`, AND the new expressions to any existing expression.</span> +</span><span id="Select-2941"><a href="#Select-2941"><span class="linenos">2941</span></a><span class="sd"> Otherwise, this resets the expression.</span> +</span><span id="Select-2942"><a href="#Select-2942"><span class="linenos">2942</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="Select-2943"><a href="#Select-2943"><span class="linenos">2943</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select-2944"><a href="#Select-2944"><span class="linenos">2944</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select-2945"><a href="#Select-2945"><span class="linenos">2945</span></a> +</span><span id="Select-2946"><a href="#Select-2946"><span class="linenos">2946</span></a><span class="sd"> Returns:</span> +</span><span id="Select-2947"><a href="#Select-2947"><span class="linenos">2947</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="Select-2948"><a href="#Select-2948"><span class="linenos">2948</span></a><span class="sd"> """</span> +</span><span id="Select-2949"><a href="#Select-2949"><span class="linenos">2949</span></a> <span class="k">return</span> <span class="n">_apply_conjunction_builder</span><span class="p">(</span> +</span><span id="Select-2950"><a href="#Select-2950"><span class="linenos">2950</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select-2951"><a href="#Select-2951"><span class="linenos">2951</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2952"><a href="#Select-2952"><span class="linenos">2952</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"having"</span><span class="p">,</span> +</span><span id="Select-2953"><a href="#Select-2953"><span class="linenos">2953</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select-2954"><a href="#Select-2954"><span class="linenos">2954</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Having</span><span class="p">,</span> +</span><span id="Select-2955"><a href="#Select-2955"><span class="linenos">2955</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select-2956"><a href="#Select-2956"><span class="linenos">2956</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select-2957"><a href="#Select-2957"><span class="linenos">2957</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2958"><a href="#Select-2958"><span class="linenos">2958</span></a> <span class="p">)</span> +</span><span id="Select-2959"><a href="#Select-2959"><span class="linenos">2959</span></a> +</span><span id="Select-2960"><a href="#Select-2960"><span class="linenos">2960</span></a> <span class="k">def</span> <span class="nf">window</span><span class="p">(</span> +</span><span id="Select-2961"><a href="#Select-2961"><span class="linenos">2961</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2962"><a href="#Select-2962"><span class="linenos">2962</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select-2963"><a href="#Select-2963"><span class="linenos">2963</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2964"><a href="#Select-2964"><span class="linenos">2964</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select-2965"><a href="#Select-2965"><span class="linenos">2965</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2966"><a href="#Select-2966"><span class="linenos">2966</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2967"><a href="#Select-2967"><span class="linenos">2967</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select-2968"><a href="#Select-2968"><span class="linenos">2968</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> +</span><span id="Select-2969"><a href="#Select-2969"><span class="linenos">2969</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select-2970"><a href="#Select-2970"><span class="linenos">2970</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2971"><a href="#Select-2971"><span class="linenos">2971</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"windows"</span><span class="p">,</span> +</span><span id="Select-2972"><a href="#Select-2972"><span class="linenos">2972</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select-2973"><a href="#Select-2973"><span class="linenos">2973</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Window</span><span class="p">,</span> +</span><span id="Select-2974"><a href="#Select-2974"><span class="linenos">2974</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select-2975"><a href="#Select-2975"><span class="linenos">2975</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select-2976"><a href="#Select-2976"><span class="linenos">2976</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2977"><a href="#Select-2977"><span class="linenos">2977</span></a> <span class="p">)</span> +</span><span id="Select-2978"><a href="#Select-2978"><span class="linenos">2978</span></a> +</span><span id="Select-2979"><a href="#Select-2979"><span class="linenos">2979</span></a> <span class="k">def</span> <span class="nf">qualify</span><span class="p">(</span> +</span><span id="Select-2980"><a href="#Select-2980"><span class="linenos">2980</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2981"><a href="#Select-2981"><span class="linenos">2981</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select-2982"><a href="#Select-2982"><span class="linenos">2982</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2983"><a href="#Select-2983"><span class="linenos">2983</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select-2984"><a href="#Select-2984"><span class="linenos">2984</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-2985"><a href="#Select-2985"><span class="linenos">2985</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2986"><a href="#Select-2986"><span class="linenos">2986</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select-2987"><a href="#Select-2987"><span class="linenos">2987</span></a> <span class="k">return</span> <span class="n">_apply_conjunction_builder</span><span class="p">(</span> +</span><span id="Select-2988"><a href="#Select-2988"><span class="linenos">2988</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select-2989"><a href="#Select-2989"><span class="linenos">2989</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select-2990"><a href="#Select-2990"><span class="linenos">2990</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"qualify"</span><span class="p">,</span> +</span><span id="Select-2991"><a href="#Select-2991"><span class="linenos">2991</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select-2992"><a href="#Select-2992"><span class="linenos">2992</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Qualify</span><span class="p">,</span> +</span><span id="Select-2993"><a href="#Select-2993"><span class="linenos">2993</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select-2994"><a href="#Select-2994"><span class="linenos">2994</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select-2995"><a href="#Select-2995"><span class="linenos">2995</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-2996"><a href="#Select-2996"><span class="linenos">2996</span></a> <span class="p">)</span> +</span><span id="Select-2997"><a href="#Select-2997"><span class="linenos">2997</span></a> +</span><span id="Select-2998"><a href="#Select-2998"><span class="linenos">2998</span></a> <span class="k">def</span> <span class="nf">distinct</span><span class="p">(</span> +</span><span id="Select-2999"><a href="#Select-2999"><span class="linenos">2999</span></a> <span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">ons</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">ExpOrStr</span><span class="p">],</span> <span class="n">distinct</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Select-3000"><a href="#Select-3000"><span class="linenos">3000</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select-3001"><a href="#Select-3001"><span class="linenos">3001</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select-3002"><a href="#Select-3002"><span class="linenos">3002</span></a><span class="sd"> Set the OFFSET expression.</span> +</span><span id="Select-3003"><a href="#Select-3003"><span class="linenos">3003</span></a> +</span><span id="Select-3004"><a href="#Select-3004"><span class="linenos">3004</span></a><span class="sd"> Example:</span> +</span><span id="Select-3005"><a href="#Select-3005"><span class="linenos">3005</span></a><span class="sd"> >>> Select().from_("tbl").select("x").distinct().sql()</span> +</span><span id="Select-3006"><a href="#Select-3006"><span class="linenos">3006</span></a><span class="sd"> 'SELECT DISTINCT x FROM tbl'</span> +</span><span id="Select-3007"><a href="#Select-3007"><span class="linenos">3007</span></a> +</span><span id="Select-3008"><a href="#Select-3008"><span class="linenos">3008</span></a><span class="sd"> Args:</span> +</span><span id="Select-3009"><a href="#Select-3009"><span class="linenos">3009</span></a><span class="sd"> ons: the expressions to distinct on</span> +</span><span id="Select-3010"><a href="#Select-3010"><span class="linenos">3010</span></a><span class="sd"> distinct: whether the Select should be distinct</span> +</span><span id="Select-3011"><a href="#Select-3011"><span class="linenos">3011</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select-3012"><a href="#Select-3012"><span class="linenos">3012</span></a> +</span><span id="Select-3013"><a href="#Select-3013"><span class="linenos">3013</span></a><span class="sd"> Returns:</span> +</span><span id="Select-3014"><a href="#Select-3014"><span class="linenos">3014</span></a><span class="sd"> Select: the modified expression.</span> +</span><span id="Select-3015"><a href="#Select-3015"><span class="linenos">3015</span></a><span class="sd"> """</span> +</span><span id="Select-3016"><a href="#Select-3016"><span class="linenos">3016</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="Select-3017"><a href="#Select-3017"><span class="linenos">3017</span></a> <span class="n">on</span> <span class="o">=</span> <span class="n">Tuple</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">on</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">on</span> <span class="ow">in</span> <span class="n">ons</span> <span class="k">if</span> <span class="n">on</span><span class="p">])</span> <span class="k">if</span> <span class="n">ons</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="Select-3018"><a href="#Select-3018"><span class="linenos">3018</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"distinct"</span><span class="p">,</span> <span class="n">Distinct</span><span class="p">(</span><span class="n">on</span><span class="o">=</span><span class="n">on</span><span class="p">)</span> <span class="k">if</span> <span class="n">distinct</span> <span class="k">else</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="Select-3019"><a href="#Select-3019"><span class="linenos">3019</span></a> <span class="k">return</span> <span class="n">instance</span> +</span><span id="Select-3020"><a href="#Select-3020"><span class="linenos">3020</span></a> +</span><span id="Select-3021"><a href="#Select-3021"><span class="linenos">3021</span></a> <span class="k">def</span> <span class="nf">ctas</span><span class="p">(</span> +</span><span id="Select-3022"><a href="#Select-3022"><span class="linenos">3022</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select-3023"><a href="#Select-3023"><span class="linenos">3023</span></a> <span class="n">table</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="Select-3024"><a href="#Select-3024"><span class="linenos">3024</span></a> <span class="n">properties</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select-3025"><a href="#Select-3025"><span class="linenos">3025</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select-3026"><a href="#Select-3026"><span class="linenos">3026</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select-3027"><a href="#Select-3027"><span class="linenos">3027</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-3028"><a href="#Select-3028"><span class="linenos">3028</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Create</span><span class="p">:</span> +</span><span id="Select-3029"><a href="#Select-3029"><span class="linenos">3029</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select-3030"><a href="#Select-3030"><span class="linenos">3030</span></a><span class="sd"> Convert this expression to a CREATE TABLE AS statement.</span> +</span><span id="Select-3031"><a href="#Select-3031"><span class="linenos">3031</span></a> +</span><span id="Select-3032"><a href="#Select-3032"><span class="linenos">3032</span></a><span class="sd"> Example:</span> +</span><span id="Select-3033"><a href="#Select-3033"><span class="linenos">3033</span></a><span class="sd"> >>> Select().select("*").from_("tbl").ctas("x").sql()</span> +</span><span id="Select-3034"><a href="#Select-3034"><span class="linenos">3034</span></a><span class="sd"> 'CREATE TABLE x AS SELECT * FROM tbl'</span> +</span><span id="Select-3035"><a href="#Select-3035"><span class="linenos">3035</span></a> +</span><span id="Select-3036"><a href="#Select-3036"><span class="linenos">3036</span></a><span class="sd"> Args:</span> +</span><span id="Select-3037"><a href="#Select-3037"><span class="linenos">3037</span></a><span class="sd"> table: the SQL code string to parse as the table name.</span> +</span><span id="Select-3038"><a href="#Select-3038"><span class="linenos">3038</span></a><span class="sd"> If another `Expression` instance is passed, it will be used as-is.</span> +</span><span id="Select-3039"><a href="#Select-3039"><span class="linenos">3039</span></a><span class="sd"> properties: an optional mapping of table properties</span> +</span><span id="Select-3040"><a href="#Select-3040"><span class="linenos">3040</span></a><span class="sd"> dialect: the dialect used to parse the input table.</span> +</span><span id="Select-3041"><a href="#Select-3041"><span class="linenos">3041</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select-3042"><a href="#Select-3042"><span class="linenos">3042</span></a><span class="sd"> opts: other options to use to parse the input table.</span> +</span><span id="Select-3043"><a href="#Select-3043"><span class="linenos">3043</span></a> +</span><span id="Select-3044"><a href="#Select-3044"><span class="linenos">3044</span></a><span class="sd"> Returns:</span> +</span><span id="Select-3045"><a href="#Select-3045"><span class="linenos">3045</span></a><span class="sd"> The new Create expression.</span> +</span><span id="Select-3046"><a href="#Select-3046"><span class="linenos">3046</span></a><span class="sd"> """</span> +</span><span id="Select-3047"><a href="#Select-3047"><span class="linenos">3047</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="Select-3048"><a href="#Select-3048"><span class="linenos">3048</span></a> <span class="n">table_expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span> +</span><span id="Select-3049"><a href="#Select-3049"><span class="linenos">3049</span></a> <span class="n">table</span><span class="p">,</span> +</span><span id="Select-3050"><a href="#Select-3050"><span class="linenos">3050</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">,</span> +</span><span id="Select-3051"><a href="#Select-3051"><span class="linenos">3051</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select-3052"><a href="#Select-3052"><span class="linenos">3052</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select-3053"><a href="#Select-3053"><span class="linenos">3053</span></a> <span class="p">)</span> +</span><span id="Select-3054"><a href="#Select-3054"><span class="linenos">3054</span></a> <span class="n">properties_expression</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Select-3055"><a href="#Select-3055"><span class="linenos">3055</span></a> <span class="k">if</span> <span class="n">properties</span><span class="p">:</span> +</span><span id="Select-3056"><a href="#Select-3056"><span class="linenos">3056</span></a> <span class="n">properties_expression</span> <span class="o">=</span> <span class="n">Properties</span><span class="o">.</span><span class="n">from_dict</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span> +</span><span id="Select-3057"><a href="#Select-3057"><span class="linenos">3057</span></a> +</span><span id="Select-3058"><a href="#Select-3058"><span class="linenos">3058</span></a> <span class="k">return</span> <span class="n">Create</span><span class="p">(</span> +</span><span id="Select-3059"><a href="#Select-3059"><span class="linenos">3059</span></a> <span class="n">this</span><span class="o">=</span><span class="n">table_expression</span><span class="p">,</span> +</span><span id="Select-3060"><a href="#Select-3060"><span class="linenos">3060</span></a> <span class="n">kind</span><span class="o">=</span><span class="s2">"table"</span><span class="p">,</span> +</span><span id="Select-3061"><a href="#Select-3061"><span class="linenos">3061</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">instance</span><span class="p">,</span> +</span><span id="Select-3062"><a href="#Select-3062"><span class="linenos">3062</span></a> <span class="n">properties</span><span class="o">=</span><span class="n">properties_expression</span><span class="p">,</span> +</span><span id="Select-3063"><a href="#Select-3063"><span class="linenos">3063</span></a> <span class="p">)</span> +</span><span id="Select-3064"><a href="#Select-3064"><span class="linenos">3064</span></a> +</span><span id="Select-3065"><a href="#Select-3065"><span class="linenos">3065</span></a> <span class="k">def</span> <span class="nf">lock</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">update</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select-3066"><a href="#Select-3066"><span class="linenos">3066</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select-3067"><a href="#Select-3067"><span class="linenos">3067</span></a><span class="sd"> Set the locking read mode for this expression.</span> +</span><span id="Select-3068"><a href="#Select-3068"><span class="linenos">3068</span></a> +</span><span id="Select-3069"><a href="#Select-3069"><span class="linenos">3069</span></a><span class="sd"> Examples:</span> +</span><span id="Select-3070"><a href="#Select-3070"><span class="linenos">3070</span></a><span class="sd"> >>> Select().select("x").from_("tbl").where("x = 'a'").lock().sql("mysql")</span> +</span><span id="Select-3071"><a href="#Select-3071"><span class="linenos">3071</span></a><span class="sd"> "SELECT x FROM tbl WHERE x = 'a' FOR UPDATE"</span> +</span><span id="Select-3072"><a href="#Select-3072"><span class="linenos">3072</span></a> +</span><span id="Select-3073"><a href="#Select-3073"><span class="linenos">3073</span></a><span class="sd"> >>> Select().select("x").from_("tbl").where("x = 'a'").lock(update=False).sql("mysql")</span> +</span><span id="Select-3074"><a href="#Select-3074"><span class="linenos">3074</span></a><span class="sd"> "SELECT x FROM tbl WHERE x = 'a' FOR SHARE"</span> +</span><span id="Select-3075"><a href="#Select-3075"><span class="linenos">3075</span></a> +</span><span id="Select-3076"><a href="#Select-3076"><span class="linenos">3076</span></a><span class="sd"> Args:</span> +</span><span id="Select-3077"><a href="#Select-3077"><span class="linenos">3077</span></a><span class="sd"> update: if `True`, the locking type will be `FOR UPDATE`, else it will be `FOR SHARE`.</span> +</span><span id="Select-3078"><a href="#Select-3078"><span class="linenos">3078</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select-3079"><a href="#Select-3079"><span class="linenos">3079</span></a> +</span><span id="Select-3080"><a href="#Select-3080"><span class="linenos">3080</span></a><span class="sd"> Returns:</span> +</span><span id="Select-3081"><a href="#Select-3081"><span class="linenos">3081</span></a><span class="sd"> The modified expression.</span> +</span><span id="Select-3082"><a href="#Select-3082"><span class="linenos">3082</span></a><span class="sd"> """</span> +</span><span id="Select-3083"><a href="#Select-3083"><span class="linenos">3083</span></a> <span class="n">inst</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="Select-3084"><a href="#Select-3084"><span class="linenos">3084</span></a> <span class="n">inst</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"locks"</span><span class="p">,</span> <span class="p">[</span><span class="n">Lock</span><span class="p">(</span><span class="n">update</span><span class="o">=</span><span class="n">update</span><span class="p">)])</span> </span><span id="Select-3085"><a href="#Select-3085"><span class="linenos">3085</span></a> -</span><span id="Select-3086"><a href="#Select-3086"><span class="linenos">3086</span></a> <span class="k">def</span> <span class="nf">hint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">hints</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select-3087"><a href="#Select-3087"><span class="linenos">3087</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select-3088"><a href="#Select-3088"><span class="linenos">3088</span></a><span class="sd"> Set hints for this expression.</span> -</span><span id="Select-3089"><a href="#Select-3089"><span class="linenos">3089</span></a> -</span><span id="Select-3090"><a href="#Select-3090"><span class="linenos">3090</span></a><span class="sd"> Examples:</span> -</span><span id="Select-3091"><a href="#Select-3091"><span class="linenos">3091</span></a><span class="sd"> >>> Select().select("x").from_("tbl").hint("BROADCAST(y)").sql(dialect="spark")</span> -</span><span id="Select-3092"><a href="#Select-3092"><span class="linenos">3092</span></a><span class="sd"> 'SELECT /*+ BROADCAST(y) */ x FROM tbl'</span> -</span><span id="Select-3093"><a href="#Select-3093"><span class="linenos">3093</span></a> -</span><span id="Select-3094"><a href="#Select-3094"><span class="linenos">3094</span></a><span class="sd"> Args:</span> -</span><span id="Select-3095"><a href="#Select-3095"><span class="linenos">3095</span></a><span class="sd"> hints: The SQL code strings to parse as the hints.</span> -</span><span id="Select-3096"><a href="#Select-3096"><span class="linenos">3096</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Select-3097"><a href="#Select-3097"><span class="linenos">3097</span></a><span class="sd"> dialect: The dialect used to parse the hints.</span> -</span><span id="Select-3098"><a href="#Select-3098"><span class="linenos">3098</span></a><span class="sd"> copy: If `False`, modify this expression instance in-place.</span> -</span><span id="Select-3099"><a href="#Select-3099"><span class="linenos">3099</span></a> -</span><span id="Select-3100"><a href="#Select-3100"><span class="linenos">3100</span></a><span class="sd"> Returns:</span> -</span><span id="Select-3101"><a href="#Select-3101"><span class="linenos">3101</span></a><span class="sd"> The modified expression.</span> -</span><span id="Select-3102"><a href="#Select-3102"><span class="linenos">3102</span></a><span class="sd"> """</span> -</span><span id="Select-3103"><a href="#Select-3103"><span class="linenos">3103</span></a> <span class="n">inst</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="Select-3104"><a href="#Select-3104"><span class="linenos">3104</span></a> <span class="n">inst</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="Select-3105"><a href="#Select-3105"><span class="linenos">3105</span></a> <span class="s2">"hint"</span><span class="p">,</span> <span class="n">Hint</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> <span class="k">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">hints</span><span class="p">])</span> -</span><span id="Select-3106"><a href="#Select-3106"><span class="linenos">3106</span></a> <span class="p">)</span> -</span><span id="Select-3107"><a href="#Select-3107"><span class="linenos">3107</span></a> -</span><span id="Select-3108"><a href="#Select-3108"><span class="linenos">3108</span></a> <span class="k">return</span> <span class="n">inst</span> +</span><span id="Select-3086"><a href="#Select-3086"><span class="linenos">3086</span></a> <span class="k">return</span> <span class="n">inst</span> +</span><span id="Select-3087"><a href="#Select-3087"><span class="linenos">3087</span></a> +</span><span id="Select-3088"><a href="#Select-3088"><span class="linenos">3088</span></a> <span class="k">def</span> <span class="nf">hint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">hints</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select-3089"><a href="#Select-3089"><span class="linenos">3089</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select-3090"><a href="#Select-3090"><span class="linenos">3090</span></a><span class="sd"> Set hints for this expression.</span> +</span><span id="Select-3091"><a href="#Select-3091"><span class="linenos">3091</span></a> +</span><span id="Select-3092"><a href="#Select-3092"><span class="linenos">3092</span></a><span class="sd"> Examples:</span> +</span><span id="Select-3093"><a href="#Select-3093"><span class="linenos">3093</span></a><span class="sd"> >>> Select().select("x").from_("tbl").hint("BROADCAST(y)").sql(dialect="spark")</span> +</span><span id="Select-3094"><a href="#Select-3094"><span class="linenos">3094</span></a><span class="sd"> 'SELECT /*+ BROADCAST(y) */ x FROM tbl'</span> +</span><span id="Select-3095"><a href="#Select-3095"><span class="linenos">3095</span></a> +</span><span id="Select-3096"><a href="#Select-3096"><span class="linenos">3096</span></a><span class="sd"> Args:</span> +</span><span id="Select-3097"><a href="#Select-3097"><span class="linenos">3097</span></a><span class="sd"> hints: The SQL code strings to parse as the hints.</span> +</span><span id="Select-3098"><a href="#Select-3098"><span class="linenos">3098</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="Select-3099"><a href="#Select-3099"><span class="linenos">3099</span></a><span class="sd"> dialect: The dialect used to parse the hints.</span> +</span><span id="Select-3100"><a href="#Select-3100"><span class="linenos">3100</span></a><span class="sd"> copy: If `False`, modify this expression instance in-place.</span> +</span><span id="Select-3101"><a href="#Select-3101"><span class="linenos">3101</span></a> +</span><span id="Select-3102"><a href="#Select-3102"><span class="linenos">3102</span></a><span class="sd"> Returns:</span> +</span><span id="Select-3103"><a href="#Select-3103"><span class="linenos">3103</span></a><span class="sd"> The modified expression.</span> +</span><span id="Select-3104"><a href="#Select-3104"><span class="linenos">3104</span></a><span class="sd"> """</span> +</span><span id="Select-3105"><a href="#Select-3105"><span class="linenos">3105</span></a> <span class="n">inst</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="Select-3106"><a href="#Select-3106"><span class="linenos">3106</span></a> <span class="n">inst</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="Select-3107"><a href="#Select-3107"><span class="linenos">3107</span></a> <span class="s2">"hint"</span><span class="p">,</span> <span class="n">Hint</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> <span class="k">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">hints</span><span class="p">])</span> +</span><span id="Select-3108"><a href="#Select-3108"><span class="linenos">3108</span></a> <span class="p">)</span> </span><span id="Select-3109"><a href="#Select-3109"><span class="linenos">3109</span></a> -</span><span id="Select-3110"><a href="#Select-3110"><span class="linenos">3110</span></a> <span class="nd">@property</span> -</span><span id="Select-3111"><a href="#Select-3111"><span class="linenos">3111</span></a> <span class="k">def</span> <span class="nf">named_selects</span><span class="p">(</span><span class="bp">self</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="Select-3112"><a href="#Select-3112"><span class="linenos">3112</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">e</span><span class="o">.</span><span class="n">output_name</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> -</span><span id="Select-3113"><a href="#Select-3113"><span class="linenos">3113</span></a> -</span><span id="Select-3114"><a href="#Select-3114"><span class="linenos">3114</span></a> <span class="nd">@property</span> -</span><span id="Select-3115"><a href="#Select-3115"><span class="linenos">3115</span></a> <span class="k">def</span> <span class="nf">is_star</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="Select-3116"><a href="#Select-3116"><span class="linenos">3116</span></a> <span class="k">return</span> <span class="nb">any</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">is_star</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Select-3117"><a href="#Select-3117"><span class="linenos">3117</span></a> -</span><span id="Select-3118"><a href="#Select-3118"><span class="linenos">3118</span></a> <span class="nd">@property</span> -</span><span id="Select-3119"><a href="#Select-3119"><span class="linenos">3119</span></a> <span class="k">def</span> <span class="nf">selects</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Expression</span><span class="p">]:</span> -</span><span id="Select-3120"><a href="#Select-3120"><span class="linenos">3120</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="Select-3110"><a href="#Select-3110"><span class="linenos">3110</span></a> <span class="k">return</span> <span class="n">inst</span> +</span><span id="Select-3111"><a href="#Select-3111"><span class="linenos">3111</span></a> +</span><span id="Select-3112"><a href="#Select-3112"><span class="linenos">3112</span></a> <span class="nd">@property</span> +</span><span id="Select-3113"><a href="#Select-3113"><span class="linenos">3113</span></a> <span class="k">def</span> <span class="nf">named_selects</span><span class="p">(</span><span class="bp">self</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="Select-3114"><a href="#Select-3114"><span class="linenos">3114</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">e</span><span class="o">.</span><span class="n">output_name</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span> <span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> +</span><span id="Select-3115"><a href="#Select-3115"><span class="linenos">3115</span></a> +</span><span id="Select-3116"><a href="#Select-3116"><span class="linenos">3116</span></a> <span class="nd">@property</span> +</span><span id="Select-3117"><a href="#Select-3117"><span class="linenos">3117</span></a> <span class="k">def</span> <span class="nf">is_star</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Select-3118"><a href="#Select-3118"><span class="linenos">3118</span></a> <span class="k">return</span> <span class="nb">any</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">is_star</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Select-3119"><a href="#Select-3119"><span class="linenos">3119</span></a> +</span><span id="Select-3120"><a href="#Select-3120"><span class="linenos">3120</span></a> <span class="nd">@property</span> +</span><span id="Select-3121"><a href="#Select-3121"><span class="linenos">3121</span></a> <span class="k">def</span> <span class="nf">selects</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Expression</span><span class="p">]:</span> +</span><span id="Select-3122"><a href="#Select-3122"><span class="linenos">3122</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span> </span></pre></div> @@ -25123,37 +25202,37 @@ Otherwise, this resets the expressions.</li> </div> <a class="headerlink" href="#Select.from_"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Select.from_-2445"><a href="#Select.from_-2445"><span class="linenos">2445</span></a> <span class="k">def</span> <span class="nf">from_</span><span class="p">(</span> -</span><span id="Select.from_-2446"><a href="#Select.from_-2446"><span class="linenos">2446</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="Select.from_-2447"><a href="#Select.from_-2447"><span class="linenos">2447</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select.from_-2448"><a href="#Select.from_-2448"><span class="linenos">2448</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select.from_-2449"><a href="#Select.from_-2449"><span class="linenos">2449</span></a><span class="sd"> Set the FROM expression.</span> -</span><span id="Select.from_-2450"><a href="#Select.from_-2450"><span class="linenos">2450</span></a> -</span><span id="Select.from_-2451"><a href="#Select.from_-2451"><span class="linenos">2451</span></a><span class="sd"> Example:</span> -</span><span id="Select.from_-2452"><a href="#Select.from_-2452"><span class="linenos">2452</span></a><span class="sd"> >>> Select().from_("tbl").select("x").sql()</span> -</span><span id="Select.from_-2453"><a href="#Select.from_-2453"><span class="linenos">2453</span></a><span class="sd"> 'SELECT x FROM tbl'</span> -</span><span id="Select.from_-2454"><a href="#Select.from_-2454"><span class="linenos">2454</span></a> -</span><span id="Select.from_-2455"><a href="#Select.from_-2455"><span class="linenos">2455</span></a><span class="sd"> Args:</span> -</span><span id="Select.from_-2456"><a href="#Select.from_-2456"><span class="linenos">2456</span></a><span class="sd"> expression : the SQL code strings to parse.</span> -</span><span id="Select.from_-2457"><a href="#Select.from_-2457"><span class="linenos">2457</span></a><span class="sd"> If a `From` instance is passed, this is used as-is.</span> -</span><span id="Select.from_-2458"><a href="#Select.from_-2458"><span class="linenos">2458</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `From`.</span> -</span><span id="Select.from_-2459"><a href="#Select.from_-2459"><span class="linenos">2459</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="Select.from_-2460"><a href="#Select.from_-2460"><span class="linenos">2460</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select.from_-2461"><a href="#Select.from_-2461"><span class="linenos">2461</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select.from_-2462"><a href="#Select.from_-2462"><span class="linenos">2462</span></a> -</span><span id="Select.from_-2463"><a href="#Select.from_-2463"><span class="linenos">2463</span></a><span class="sd"> Returns:</span> -</span><span id="Select.from_-2464"><a href="#Select.from_-2464"><span class="linenos">2464</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="Select.from_-2465"><a href="#Select.from_-2465"><span class="linenos">2465</span></a><span class="sd"> """</span> -</span><span id="Select.from_-2466"><a href="#Select.from_-2466"><span class="linenos">2466</span></a> <span class="k">return</span> <span class="n">_apply_builder</span><span class="p">(</span> -</span><span id="Select.from_-2467"><a href="#Select.from_-2467"><span class="linenos">2467</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> -</span><span id="Select.from_-2468"><a href="#Select.from_-2468"><span class="linenos">2468</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select.from_-2469"><a href="#Select.from_-2469"><span class="linenos">2469</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"from"</span><span class="p">,</span> -</span><span id="Select.from_-2470"><a href="#Select.from_-2470"><span class="linenos">2470</span></a> <span class="n">into</span><span class="o">=</span><span class="n">From</span><span class="p">,</span> -</span><span id="Select.from_-2471"><a href="#Select.from_-2471"><span class="linenos">2471</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"FROM"</span><span class="p">,</span> -</span><span id="Select.from_-2472"><a href="#Select.from_-2472"><span class="linenos">2472</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select.from_-2473"><a href="#Select.from_-2473"><span class="linenos">2473</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select.from_-2474"><a href="#Select.from_-2474"><span class="linenos">2474</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.from_-2475"><a href="#Select.from_-2475"><span class="linenos">2475</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Select.from_-2447"><a href="#Select.from_-2447"><span class="linenos">2447</span></a> <span class="k">def</span> <span class="nf">from_</span><span class="p">(</span> +</span><span id="Select.from_-2448"><a href="#Select.from_-2448"><span class="linenos">2448</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="Select.from_-2449"><a href="#Select.from_-2449"><span class="linenos">2449</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select.from_-2450"><a href="#Select.from_-2450"><span class="linenos">2450</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select.from_-2451"><a href="#Select.from_-2451"><span class="linenos">2451</span></a><span class="sd"> Set the FROM expression.</span> +</span><span id="Select.from_-2452"><a href="#Select.from_-2452"><span class="linenos">2452</span></a> +</span><span id="Select.from_-2453"><a href="#Select.from_-2453"><span class="linenos">2453</span></a><span class="sd"> Example:</span> +</span><span id="Select.from_-2454"><a href="#Select.from_-2454"><span class="linenos">2454</span></a><span class="sd"> >>> Select().from_("tbl").select("x").sql()</span> +</span><span id="Select.from_-2455"><a href="#Select.from_-2455"><span class="linenos">2455</span></a><span class="sd"> 'SELECT x FROM tbl'</span> +</span><span id="Select.from_-2456"><a href="#Select.from_-2456"><span class="linenos">2456</span></a> +</span><span id="Select.from_-2457"><a href="#Select.from_-2457"><span class="linenos">2457</span></a><span class="sd"> Args:</span> +</span><span id="Select.from_-2458"><a href="#Select.from_-2458"><span class="linenos">2458</span></a><span class="sd"> expression : the SQL code strings to parse.</span> +</span><span id="Select.from_-2459"><a href="#Select.from_-2459"><span class="linenos">2459</span></a><span class="sd"> If a `From` instance is passed, this is used as-is.</span> +</span><span id="Select.from_-2460"><a href="#Select.from_-2460"><span class="linenos">2460</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `From`.</span> +</span><span id="Select.from_-2461"><a href="#Select.from_-2461"><span class="linenos">2461</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="Select.from_-2462"><a href="#Select.from_-2462"><span class="linenos">2462</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select.from_-2463"><a href="#Select.from_-2463"><span class="linenos">2463</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select.from_-2464"><a href="#Select.from_-2464"><span class="linenos">2464</span></a> +</span><span id="Select.from_-2465"><a href="#Select.from_-2465"><span class="linenos">2465</span></a><span class="sd"> Returns:</span> +</span><span id="Select.from_-2466"><a href="#Select.from_-2466"><span class="linenos">2466</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="Select.from_-2467"><a href="#Select.from_-2467"><span class="linenos">2467</span></a><span class="sd"> """</span> +</span><span id="Select.from_-2468"><a href="#Select.from_-2468"><span class="linenos">2468</span></a> <span class="k">return</span> <span class="n">_apply_builder</span><span class="p">(</span> +</span><span id="Select.from_-2469"><a href="#Select.from_-2469"><span class="linenos">2469</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> +</span><span id="Select.from_-2470"><a href="#Select.from_-2470"><span class="linenos">2470</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select.from_-2471"><a href="#Select.from_-2471"><span class="linenos">2471</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"from"</span><span class="p">,</span> +</span><span id="Select.from_-2472"><a href="#Select.from_-2472"><span class="linenos">2472</span></a> <span class="n">into</span><span class="o">=</span><span class="n">From</span><span class="p">,</span> +</span><span id="Select.from_-2473"><a href="#Select.from_-2473"><span class="linenos">2473</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"FROM"</span><span class="p">,</span> +</span><span id="Select.from_-2474"><a href="#Select.from_-2474"><span class="linenos">2474</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select.from_-2475"><a href="#Select.from_-2475"><span class="linenos">2475</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select.from_-2476"><a href="#Select.from_-2476"><span class="linenos">2476</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.from_-2477"><a href="#Select.from_-2477"><span class="linenos">2477</span></a> <span class="p">)</span> </span></pre></div> @@ -25200,49 +25279,49 @@ If another <code><a href="#Expression">Expression</a></code> instance is passed, </div> <a class="headerlink" href="#Select.group_by"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Select.group_by-2477"><a href="#Select.group_by-2477"><span class="linenos">2477</span></a> <span class="k">def</span> <span class="nf">group_by</span><span class="p">(</span> -</span><span id="Select.group_by-2478"><a href="#Select.group_by-2478"><span class="linenos">2478</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select.group_by-2479"><a href="#Select.group_by-2479"><span class="linenos">2479</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select.group_by-2480"><a href="#Select.group_by-2480"><span class="linenos">2480</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.group_by-2481"><a href="#Select.group_by-2481"><span class="linenos">2481</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select.group_by-2482"><a href="#Select.group_by-2482"><span class="linenos">2482</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.group_by-2483"><a href="#Select.group_by-2483"><span class="linenos">2483</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.group_by-2484"><a href="#Select.group_by-2484"><span class="linenos">2484</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select.group_by-2485"><a href="#Select.group_by-2485"><span class="linenos">2485</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select.group_by-2486"><a href="#Select.group_by-2486"><span class="linenos">2486</span></a><span class="sd"> Set the GROUP BY expression.</span> -</span><span id="Select.group_by-2487"><a href="#Select.group_by-2487"><span class="linenos">2487</span></a> -</span><span id="Select.group_by-2488"><a href="#Select.group_by-2488"><span class="linenos">2488</span></a><span class="sd"> Example:</span> -</span><span id="Select.group_by-2489"><a href="#Select.group_by-2489"><span class="linenos">2489</span></a><span class="sd"> >>> Select().from_("tbl").select("x", "COUNT(1)").group_by("x").sql()</span> -</span><span id="Select.group_by-2490"><a href="#Select.group_by-2490"><span class="linenos">2490</span></a><span class="sd"> 'SELECT x, COUNT(1) FROM tbl GROUP BY x'</span> -</span><span id="Select.group_by-2491"><a href="#Select.group_by-2491"><span class="linenos">2491</span></a> -</span><span id="Select.group_by-2492"><a href="#Select.group_by-2492"><span class="linenos">2492</span></a><span class="sd"> Args:</span> -</span><span id="Select.group_by-2493"><a href="#Select.group_by-2493"><span class="linenos">2493</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="Select.group_by-2494"><a href="#Select.group_by-2494"><span class="linenos">2494</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> -</span><span id="Select.group_by-2495"><a href="#Select.group_by-2495"><span class="linenos">2495</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Group`.</span> -</span><span id="Select.group_by-2496"><a href="#Select.group_by-2496"><span class="linenos">2496</span></a><span class="sd"> If nothing is passed in then a group by is not applied to the expression</span> -</span><span id="Select.group_by-2497"><a href="#Select.group_by-2497"><span class="linenos">2497</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="Select.group_by-2498"><a href="#Select.group_by-2498"><span class="linenos">2498</span></a><span class="sd"> Otherwise, this flattens all the `Group` expression into a single expression.</span> -</span><span id="Select.group_by-2499"><a href="#Select.group_by-2499"><span class="linenos">2499</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="Select.group_by-2500"><a href="#Select.group_by-2500"><span class="linenos">2500</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select.group_by-2501"><a href="#Select.group_by-2501"><span class="linenos">2501</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select.group_by-2502"><a href="#Select.group_by-2502"><span class="linenos">2502</span></a> -</span><span id="Select.group_by-2503"><a href="#Select.group_by-2503"><span class="linenos">2503</span></a><span class="sd"> Returns:</span> -</span><span id="Select.group_by-2504"><a href="#Select.group_by-2504"><span class="linenos">2504</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="Select.group_by-2505"><a href="#Select.group_by-2505"><span class="linenos">2505</span></a><span class="sd"> """</span> -</span><span id="Select.group_by-2506"><a href="#Select.group_by-2506"><span class="linenos">2506</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="Select.group_by-2507"><a href="#Select.group_by-2507"><span class="linenos">2507</span></a> <span class="k">return</span> <span class="bp">self</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">copy</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Select.group_by-2508"><a href="#Select.group_by-2508"><span class="linenos">2508</span></a> -</span><span id="Select.group_by-2509"><a href="#Select.group_by-2509"><span class="linenos">2509</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> -</span><span id="Select.group_by-2510"><a href="#Select.group_by-2510"><span class="linenos">2510</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select.group_by-2511"><a href="#Select.group_by-2511"><span class="linenos">2511</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select.group_by-2512"><a href="#Select.group_by-2512"><span class="linenos">2512</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"group"</span><span class="p">,</span> -</span><span id="Select.group_by-2513"><a href="#Select.group_by-2513"><span class="linenos">2513</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select.group_by-2514"><a href="#Select.group_by-2514"><span class="linenos">2514</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select.group_by-2515"><a href="#Select.group_by-2515"><span class="linenos">2515</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"GROUP BY"</span><span class="p">,</span> -</span><span id="Select.group_by-2516"><a href="#Select.group_by-2516"><span class="linenos">2516</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Group</span><span class="p">,</span> -</span><span id="Select.group_by-2517"><a href="#Select.group_by-2517"><span class="linenos">2517</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select.group_by-2518"><a href="#Select.group_by-2518"><span class="linenos">2518</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.group_by-2519"><a href="#Select.group_by-2519"><span class="linenos">2519</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Select.group_by-2479"><a href="#Select.group_by-2479"><span class="linenos">2479</span></a> <span class="k">def</span> <span class="nf">group_by</span><span class="p">(</span> +</span><span id="Select.group_by-2480"><a href="#Select.group_by-2480"><span class="linenos">2480</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select.group_by-2481"><a href="#Select.group_by-2481"><span class="linenos">2481</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select.group_by-2482"><a href="#Select.group_by-2482"><span class="linenos">2482</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.group_by-2483"><a href="#Select.group_by-2483"><span class="linenos">2483</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select.group_by-2484"><a href="#Select.group_by-2484"><span class="linenos">2484</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.group_by-2485"><a href="#Select.group_by-2485"><span class="linenos">2485</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.group_by-2486"><a href="#Select.group_by-2486"><span class="linenos">2486</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select.group_by-2487"><a href="#Select.group_by-2487"><span class="linenos">2487</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select.group_by-2488"><a href="#Select.group_by-2488"><span class="linenos">2488</span></a><span class="sd"> Set the GROUP BY expression.</span> +</span><span id="Select.group_by-2489"><a href="#Select.group_by-2489"><span class="linenos">2489</span></a> +</span><span id="Select.group_by-2490"><a href="#Select.group_by-2490"><span class="linenos">2490</span></a><span class="sd"> Example:</span> +</span><span id="Select.group_by-2491"><a href="#Select.group_by-2491"><span class="linenos">2491</span></a><span class="sd"> >>> Select().from_("tbl").select("x", "COUNT(1)").group_by("x").sql()</span> +</span><span id="Select.group_by-2492"><a href="#Select.group_by-2492"><span class="linenos">2492</span></a><span class="sd"> 'SELECT x, COUNT(1) FROM tbl GROUP BY x'</span> +</span><span id="Select.group_by-2493"><a href="#Select.group_by-2493"><span class="linenos">2493</span></a> +</span><span id="Select.group_by-2494"><a href="#Select.group_by-2494"><span class="linenos">2494</span></a><span class="sd"> Args:</span> +</span><span id="Select.group_by-2495"><a href="#Select.group_by-2495"><span class="linenos">2495</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="Select.group_by-2496"><a href="#Select.group_by-2496"><span class="linenos">2496</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> +</span><span id="Select.group_by-2497"><a href="#Select.group_by-2497"><span class="linenos">2497</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Group`.</span> +</span><span id="Select.group_by-2498"><a href="#Select.group_by-2498"><span class="linenos">2498</span></a><span class="sd"> If nothing is passed in then a group by is not applied to the expression</span> +</span><span id="Select.group_by-2499"><a href="#Select.group_by-2499"><span class="linenos">2499</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="Select.group_by-2500"><a href="#Select.group_by-2500"><span class="linenos">2500</span></a><span class="sd"> Otherwise, this flattens all the `Group` expression into a single expression.</span> +</span><span id="Select.group_by-2501"><a href="#Select.group_by-2501"><span class="linenos">2501</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="Select.group_by-2502"><a href="#Select.group_by-2502"><span class="linenos">2502</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select.group_by-2503"><a href="#Select.group_by-2503"><span class="linenos">2503</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select.group_by-2504"><a href="#Select.group_by-2504"><span class="linenos">2504</span></a> +</span><span id="Select.group_by-2505"><a href="#Select.group_by-2505"><span class="linenos">2505</span></a><span class="sd"> Returns:</span> +</span><span id="Select.group_by-2506"><a href="#Select.group_by-2506"><span class="linenos">2506</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="Select.group_by-2507"><a href="#Select.group_by-2507"><span class="linenos">2507</span></a><span class="sd"> """</span> +</span><span id="Select.group_by-2508"><a href="#Select.group_by-2508"><span class="linenos">2508</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="Select.group_by-2509"><a href="#Select.group_by-2509"><span class="linenos">2509</span></a> <span class="k">return</span> <span class="bp">self</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">copy</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Select.group_by-2510"><a href="#Select.group_by-2510"><span class="linenos">2510</span></a> +</span><span id="Select.group_by-2511"><a href="#Select.group_by-2511"><span class="linenos">2511</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> +</span><span id="Select.group_by-2512"><a href="#Select.group_by-2512"><span class="linenos">2512</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select.group_by-2513"><a href="#Select.group_by-2513"><span class="linenos">2513</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select.group_by-2514"><a href="#Select.group_by-2514"><span class="linenos">2514</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"group"</span><span class="p">,</span> +</span><span id="Select.group_by-2515"><a href="#Select.group_by-2515"><span class="linenos">2515</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select.group_by-2516"><a href="#Select.group_by-2516"><span class="linenos">2516</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select.group_by-2517"><a href="#Select.group_by-2517"><span class="linenos">2517</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"GROUP BY"</span><span class="p">,</span> +</span><span id="Select.group_by-2518"><a href="#Select.group_by-2518"><span class="linenos">2518</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Group</span><span class="p">,</span> +</span><span id="Select.group_by-2519"><a href="#Select.group_by-2519"><span class="linenos">2519</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select.group_by-2520"><a href="#Select.group_by-2520"><span class="linenos">2520</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.group_by-2521"><a href="#Select.group_by-2521"><span class="linenos">2521</span></a> <span class="p">)</span> </span></pre></div> @@ -25292,45 +25371,45 @@ Otherwise, this flattens all the <code><a href="#Group">Group</a></code> express </div> <a class="headerlink" href="#Select.order_by"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Select.order_by-2521"><a href="#Select.order_by-2521"><span class="linenos">2521</span></a> <span class="k">def</span> <span class="nf">order_by</span><span class="p">(</span> -</span><span id="Select.order_by-2522"><a href="#Select.order_by-2522"><span class="linenos">2522</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select.order_by-2523"><a href="#Select.order_by-2523"><span class="linenos">2523</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select.order_by-2524"><a href="#Select.order_by-2524"><span class="linenos">2524</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.order_by-2525"><a href="#Select.order_by-2525"><span class="linenos">2525</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select.order_by-2526"><a href="#Select.order_by-2526"><span class="linenos">2526</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.order_by-2527"><a href="#Select.order_by-2527"><span class="linenos">2527</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.order_by-2528"><a href="#Select.order_by-2528"><span class="linenos">2528</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select.order_by-2529"><a href="#Select.order_by-2529"><span class="linenos">2529</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select.order_by-2530"><a href="#Select.order_by-2530"><span class="linenos">2530</span></a><span class="sd"> Set the ORDER BY expression.</span> -</span><span id="Select.order_by-2531"><a href="#Select.order_by-2531"><span class="linenos">2531</span></a> -</span><span id="Select.order_by-2532"><a href="#Select.order_by-2532"><span class="linenos">2532</span></a><span class="sd"> Example:</span> -</span><span id="Select.order_by-2533"><a href="#Select.order_by-2533"><span class="linenos">2533</span></a><span class="sd"> >>> Select().from_("tbl").select("x").order_by("x DESC").sql()</span> -</span><span id="Select.order_by-2534"><a href="#Select.order_by-2534"><span class="linenos">2534</span></a><span class="sd"> 'SELECT x FROM tbl ORDER BY x DESC'</span> -</span><span id="Select.order_by-2535"><a href="#Select.order_by-2535"><span class="linenos">2535</span></a> -</span><span id="Select.order_by-2536"><a href="#Select.order_by-2536"><span class="linenos">2536</span></a><span class="sd"> Args:</span> -</span><span id="Select.order_by-2537"><a href="#Select.order_by-2537"><span class="linenos">2537</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="Select.order_by-2538"><a href="#Select.order_by-2538"><span class="linenos">2538</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> -</span><span id="Select.order_by-2539"><a href="#Select.order_by-2539"><span class="linenos">2539</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Order`.</span> -</span><span id="Select.order_by-2540"><a href="#Select.order_by-2540"><span class="linenos">2540</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="Select.order_by-2541"><a href="#Select.order_by-2541"><span class="linenos">2541</span></a><span class="sd"> Otherwise, this flattens all the `Order` expression into a single expression.</span> -</span><span id="Select.order_by-2542"><a href="#Select.order_by-2542"><span class="linenos">2542</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="Select.order_by-2543"><a href="#Select.order_by-2543"><span class="linenos">2543</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select.order_by-2544"><a href="#Select.order_by-2544"><span class="linenos">2544</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select.order_by-2545"><a href="#Select.order_by-2545"><span class="linenos">2545</span></a> -</span><span id="Select.order_by-2546"><a href="#Select.order_by-2546"><span class="linenos">2546</span></a><span class="sd"> Returns:</span> -</span><span id="Select.order_by-2547"><a href="#Select.order_by-2547"><span class="linenos">2547</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="Select.order_by-2548"><a href="#Select.order_by-2548"><span class="linenos">2548</span></a><span class="sd"> """</span> -</span><span id="Select.order_by-2549"><a href="#Select.order_by-2549"><span class="linenos">2549</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> -</span><span id="Select.order_by-2550"><a href="#Select.order_by-2550"><span class="linenos">2550</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select.order_by-2551"><a href="#Select.order_by-2551"><span class="linenos">2551</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select.order_by-2552"><a href="#Select.order_by-2552"><span class="linenos">2552</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"order"</span><span class="p">,</span> -</span><span id="Select.order_by-2553"><a href="#Select.order_by-2553"><span class="linenos">2553</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select.order_by-2554"><a href="#Select.order_by-2554"><span class="linenos">2554</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select.order_by-2555"><a href="#Select.order_by-2555"><span class="linenos">2555</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ORDER BY"</span><span class="p">,</span> -</span><span id="Select.order_by-2556"><a href="#Select.order_by-2556"><span class="linenos">2556</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Order</span><span class="p">,</span> -</span><span id="Select.order_by-2557"><a href="#Select.order_by-2557"><span class="linenos">2557</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select.order_by-2558"><a href="#Select.order_by-2558"><span class="linenos">2558</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.order_by-2559"><a href="#Select.order_by-2559"><span class="linenos">2559</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Select.order_by-2523"><a href="#Select.order_by-2523"><span class="linenos">2523</span></a> <span class="k">def</span> <span class="nf">order_by</span><span class="p">(</span> +</span><span id="Select.order_by-2524"><a href="#Select.order_by-2524"><span class="linenos">2524</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select.order_by-2525"><a href="#Select.order_by-2525"><span class="linenos">2525</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select.order_by-2526"><a href="#Select.order_by-2526"><span class="linenos">2526</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.order_by-2527"><a href="#Select.order_by-2527"><span class="linenos">2527</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select.order_by-2528"><a href="#Select.order_by-2528"><span class="linenos">2528</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.order_by-2529"><a href="#Select.order_by-2529"><span class="linenos">2529</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.order_by-2530"><a href="#Select.order_by-2530"><span class="linenos">2530</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select.order_by-2531"><a href="#Select.order_by-2531"><span class="linenos">2531</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select.order_by-2532"><a href="#Select.order_by-2532"><span class="linenos">2532</span></a><span class="sd"> Set the ORDER BY expression.</span> +</span><span id="Select.order_by-2533"><a href="#Select.order_by-2533"><span class="linenos">2533</span></a> +</span><span id="Select.order_by-2534"><a href="#Select.order_by-2534"><span class="linenos">2534</span></a><span class="sd"> Example:</span> +</span><span id="Select.order_by-2535"><a href="#Select.order_by-2535"><span class="linenos">2535</span></a><span class="sd"> >>> Select().from_("tbl").select("x").order_by("x DESC").sql()</span> +</span><span id="Select.order_by-2536"><a href="#Select.order_by-2536"><span class="linenos">2536</span></a><span class="sd"> 'SELECT x FROM tbl ORDER BY x DESC'</span> +</span><span id="Select.order_by-2537"><a href="#Select.order_by-2537"><span class="linenos">2537</span></a> +</span><span id="Select.order_by-2538"><a href="#Select.order_by-2538"><span class="linenos">2538</span></a><span class="sd"> Args:</span> +</span><span id="Select.order_by-2539"><a href="#Select.order_by-2539"><span class="linenos">2539</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="Select.order_by-2540"><a href="#Select.order_by-2540"><span class="linenos">2540</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> +</span><span id="Select.order_by-2541"><a href="#Select.order_by-2541"><span class="linenos">2541</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Order`.</span> +</span><span id="Select.order_by-2542"><a href="#Select.order_by-2542"><span class="linenos">2542</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="Select.order_by-2543"><a href="#Select.order_by-2543"><span class="linenos">2543</span></a><span class="sd"> Otherwise, this flattens all the `Order` expression into a single expression.</span> +</span><span id="Select.order_by-2544"><a href="#Select.order_by-2544"><span class="linenos">2544</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="Select.order_by-2545"><a href="#Select.order_by-2545"><span class="linenos">2545</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select.order_by-2546"><a href="#Select.order_by-2546"><span class="linenos">2546</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select.order_by-2547"><a href="#Select.order_by-2547"><span class="linenos">2547</span></a> +</span><span id="Select.order_by-2548"><a href="#Select.order_by-2548"><span class="linenos">2548</span></a><span class="sd"> Returns:</span> +</span><span id="Select.order_by-2549"><a href="#Select.order_by-2549"><span class="linenos">2549</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="Select.order_by-2550"><a href="#Select.order_by-2550"><span class="linenos">2550</span></a><span class="sd"> """</span> +</span><span id="Select.order_by-2551"><a href="#Select.order_by-2551"><span class="linenos">2551</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> +</span><span id="Select.order_by-2552"><a href="#Select.order_by-2552"><span class="linenos">2552</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select.order_by-2553"><a href="#Select.order_by-2553"><span class="linenos">2553</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select.order_by-2554"><a href="#Select.order_by-2554"><span class="linenos">2554</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"order"</span><span class="p">,</span> +</span><span id="Select.order_by-2555"><a href="#Select.order_by-2555"><span class="linenos">2555</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select.order_by-2556"><a href="#Select.order_by-2556"><span class="linenos">2556</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select.order_by-2557"><a href="#Select.order_by-2557"><span class="linenos">2557</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ORDER BY"</span><span class="p">,</span> +</span><span id="Select.order_by-2558"><a href="#Select.order_by-2558"><span class="linenos">2558</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Order</span><span class="p">,</span> +</span><span id="Select.order_by-2559"><a href="#Select.order_by-2559"><span class="linenos">2559</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select.order_by-2560"><a href="#Select.order_by-2560"><span class="linenos">2560</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.order_by-2561"><a href="#Select.order_by-2561"><span class="linenos">2561</span></a> <span class="p">)</span> </span></pre></div> @@ -25379,45 +25458,45 @@ Otherwise, this flattens all the <code><a href="#Order">Order</a></code> express </div> <a class="headerlink" href="#Select.sort_by"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Select.sort_by-2561"><a href="#Select.sort_by-2561"><span class="linenos">2561</span></a> <span class="k">def</span> <span class="nf">sort_by</span><span class="p">(</span> -</span><span id="Select.sort_by-2562"><a href="#Select.sort_by-2562"><span class="linenos">2562</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select.sort_by-2563"><a href="#Select.sort_by-2563"><span class="linenos">2563</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select.sort_by-2564"><a href="#Select.sort_by-2564"><span class="linenos">2564</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.sort_by-2565"><a href="#Select.sort_by-2565"><span class="linenos">2565</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select.sort_by-2566"><a href="#Select.sort_by-2566"><span class="linenos">2566</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.sort_by-2567"><a href="#Select.sort_by-2567"><span class="linenos">2567</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.sort_by-2568"><a href="#Select.sort_by-2568"><span class="linenos">2568</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select.sort_by-2569"><a href="#Select.sort_by-2569"><span class="linenos">2569</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select.sort_by-2570"><a href="#Select.sort_by-2570"><span class="linenos">2570</span></a><span class="sd"> Set the SORT BY expression.</span> -</span><span id="Select.sort_by-2571"><a href="#Select.sort_by-2571"><span class="linenos">2571</span></a> -</span><span id="Select.sort_by-2572"><a href="#Select.sort_by-2572"><span class="linenos">2572</span></a><span class="sd"> Example:</span> -</span><span id="Select.sort_by-2573"><a href="#Select.sort_by-2573"><span class="linenos">2573</span></a><span class="sd"> >>> Select().from_("tbl").select("x").sort_by("x DESC").sql(dialect="hive")</span> -</span><span id="Select.sort_by-2574"><a href="#Select.sort_by-2574"><span class="linenos">2574</span></a><span class="sd"> 'SELECT x FROM tbl SORT BY x DESC'</span> -</span><span id="Select.sort_by-2575"><a href="#Select.sort_by-2575"><span class="linenos">2575</span></a> -</span><span id="Select.sort_by-2576"><a href="#Select.sort_by-2576"><span class="linenos">2576</span></a><span class="sd"> Args:</span> -</span><span id="Select.sort_by-2577"><a href="#Select.sort_by-2577"><span class="linenos">2577</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="Select.sort_by-2578"><a href="#Select.sort_by-2578"><span class="linenos">2578</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> -</span><span id="Select.sort_by-2579"><a href="#Select.sort_by-2579"><span class="linenos">2579</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `SORT`.</span> -</span><span id="Select.sort_by-2580"><a href="#Select.sort_by-2580"><span class="linenos">2580</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="Select.sort_by-2581"><a href="#Select.sort_by-2581"><span class="linenos">2581</span></a><span class="sd"> Otherwise, this flattens all the `Order` expression into a single expression.</span> -</span><span id="Select.sort_by-2582"><a href="#Select.sort_by-2582"><span class="linenos">2582</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="Select.sort_by-2583"><a href="#Select.sort_by-2583"><span class="linenos">2583</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select.sort_by-2584"><a href="#Select.sort_by-2584"><span class="linenos">2584</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select.sort_by-2585"><a href="#Select.sort_by-2585"><span class="linenos">2585</span></a> -</span><span id="Select.sort_by-2586"><a href="#Select.sort_by-2586"><span class="linenos">2586</span></a><span class="sd"> Returns:</span> -</span><span id="Select.sort_by-2587"><a href="#Select.sort_by-2587"><span class="linenos">2587</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="Select.sort_by-2588"><a href="#Select.sort_by-2588"><span class="linenos">2588</span></a><span class="sd"> """</span> -</span><span id="Select.sort_by-2589"><a href="#Select.sort_by-2589"><span class="linenos">2589</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> -</span><span id="Select.sort_by-2590"><a href="#Select.sort_by-2590"><span class="linenos">2590</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select.sort_by-2591"><a href="#Select.sort_by-2591"><span class="linenos">2591</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select.sort_by-2592"><a href="#Select.sort_by-2592"><span class="linenos">2592</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"sort"</span><span class="p">,</span> -</span><span id="Select.sort_by-2593"><a href="#Select.sort_by-2593"><span class="linenos">2593</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select.sort_by-2594"><a href="#Select.sort_by-2594"><span class="linenos">2594</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select.sort_by-2595"><a href="#Select.sort_by-2595"><span class="linenos">2595</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"SORT BY"</span><span class="p">,</span> -</span><span id="Select.sort_by-2596"><a href="#Select.sort_by-2596"><span class="linenos">2596</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Sort</span><span class="p">,</span> -</span><span id="Select.sort_by-2597"><a href="#Select.sort_by-2597"><span class="linenos">2597</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select.sort_by-2598"><a href="#Select.sort_by-2598"><span class="linenos">2598</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.sort_by-2599"><a href="#Select.sort_by-2599"><span class="linenos">2599</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Select.sort_by-2563"><a href="#Select.sort_by-2563"><span class="linenos">2563</span></a> <span class="k">def</span> <span class="nf">sort_by</span><span class="p">(</span> +</span><span id="Select.sort_by-2564"><a href="#Select.sort_by-2564"><span class="linenos">2564</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select.sort_by-2565"><a href="#Select.sort_by-2565"><span class="linenos">2565</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select.sort_by-2566"><a href="#Select.sort_by-2566"><span class="linenos">2566</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.sort_by-2567"><a href="#Select.sort_by-2567"><span class="linenos">2567</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select.sort_by-2568"><a href="#Select.sort_by-2568"><span class="linenos">2568</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.sort_by-2569"><a href="#Select.sort_by-2569"><span class="linenos">2569</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.sort_by-2570"><a href="#Select.sort_by-2570"><span class="linenos">2570</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select.sort_by-2571"><a href="#Select.sort_by-2571"><span class="linenos">2571</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select.sort_by-2572"><a href="#Select.sort_by-2572"><span class="linenos">2572</span></a><span class="sd"> Set the SORT BY expression.</span> +</span><span id="Select.sort_by-2573"><a href="#Select.sort_by-2573"><span class="linenos">2573</span></a> +</span><span id="Select.sort_by-2574"><a href="#Select.sort_by-2574"><span class="linenos">2574</span></a><span class="sd"> Example:</span> +</span><span id="Select.sort_by-2575"><a href="#Select.sort_by-2575"><span class="linenos">2575</span></a><span class="sd"> >>> Select().from_("tbl").select("x").sort_by("x DESC").sql(dialect="hive")</span> +</span><span id="Select.sort_by-2576"><a href="#Select.sort_by-2576"><span class="linenos">2576</span></a><span class="sd"> 'SELECT x FROM tbl SORT BY x DESC'</span> +</span><span id="Select.sort_by-2577"><a href="#Select.sort_by-2577"><span class="linenos">2577</span></a> +</span><span id="Select.sort_by-2578"><a href="#Select.sort_by-2578"><span class="linenos">2578</span></a><span class="sd"> Args:</span> +</span><span id="Select.sort_by-2579"><a href="#Select.sort_by-2579"><span class="linenos">2579</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="Select.sort_by-2580"><a href="#Select.sort_by-2580"><span class="linenos">2580</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> +</span><span id="Select.sort_by-2581"><a href="#Select.sort_by-2581"><span class="linenos">2581</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `SORT`.</span> +</span><span id="Select.sort_by-2582"><a href="#Select.sort_by-2582"><span class="linenos">2582</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="Select.sort_by-2583"><a href="#Select.sort_by-2583"><span class="linenos">2583</span></a><span class="sd"> Otherwise, this flattens all the `Order` expression into a single expression.</span> +</span><span id="Select.sort_by-2584"><a href="#Select.sort_by-2584"><span class="linenos">2584</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="Select.sort_by-2585"><a href="#Select.sort_by-2585"><span class="linenos">2585</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select.sort_by-2586"><a href="#Select.sort_by-2586"><span class="linenos">2586</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select.sort_by-2587"><a href="#Select.sort_by-2587"><span class="linenos">2587</span></a> +</span><span id="Select.sort_by-2588"><a href="#Select.sort_by-2588"><span class="linenos">2588</span></a><span class="sd"> Returns:</span> +</span><span id="Select.sort_by-2589"><a href="#Select.sort_by-2589"><span class="linenos">2589</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="Select.sort_by-2590"><a href="#Select.sort_by-2590"><span class="linenos">2590</span></a><span class="sd"> """</span> +</span><span id="Select.sort_by-2591"><a href="#Select.sort_by-2591"><span class="linenos">2591</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> +</span><span id="Select.sort_by-2592"><a href="#Select.sort_by-2592"><span class="linenos">2592</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select.sort_by-2593"><a href="#Select.sort_by-2593"><span class="linenos">2593</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select.sort_by-2594"><a href="#Select.sort_by-2594"><span class="linenos">2594</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"sort"</span><span class="p">,</span> +</span><span id="Select.sort_by-2595"><a href="#Select.sort_by-2595"><span class="linenos">2595</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select.sort_by-2596"><a href="#Select.sort_by-2596"><span class="linenos">2596</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select.sort_by-2597"><a href="#Select.sort_by-2597"><span class="linenos">2597</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"SORT BY"</span><span class="p">,</span> +</span><span id="Select.sort_by-2598"><a href="#Select.sort_by-2598"><span class="linenos">2598</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Sort</span><span class="p">,</span> +</span><span id="Select.sort_by-2599"><a href="#Select.sort_by-2599"><span class="linenos">2599</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select.sort_by-2600"><a href="#Select.sort_by-2600"><span class="linenos">2600</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.sort_by-2601"><a href="#Select.sort_by-2601"><span class="linenos">2601</span></a> <span class="p">)</span> </span></pre></div> @@ -25466,45 +25545,45 @@ Otherwise, this flattens all the <code><a href="#Order">Order</a></code> express </div> <a class="headerlink" href="#Select.cluster_by"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Select.cluster_by-2601"><a href="#Select.cluster_by-2601"><span class="linenos">2601</span></a> <span class="k">def</span> <span class="nf">cluster_by</span><span class="p">(</span> -</span><span id="Select.cluster_by-2602"><a href="#Select.cluster_by-2602"><span class="linenos">2602</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select.cluster_by-2603"><a href="#Select.cluster_by-2603"><span class="linenos">2603</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select.cluster_by-2604"><a href="#Select.cluster_by-2604"><span class="linenos">2604</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.cluster_by-2605"><a href="#Select.cluster_by-2605"><span class="linenos">2605</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select.cluster_by-2606"><a href="#Select.cluster_by-2606"><span class="linenos">2606</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.cluster_by-2607"><a href="#Select.cluster_by-2607"><span class="linenos">2607</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.cluster_by-2608"><a href="#Select.cluster_by-2608"><span class="linenos">2608</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select.cluster_by-2609"><a href="#Select.cluster_by-2609"><span class="linenos">2609</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select.cluster_by-2610"><a href="#Select.cluster_by-2610"><span class="linenos">2610</span></a><span class="sd"> Set the CLUSTER BY expression.</span> -</span><span id="Select.cluster_by-2611"><a href="#Select.cluster_by-2611"><span class="linenos">2611</span></a> -</span><span id="Select.cluster_by-2612"><a href="#Select.cluster_by-2612"><span class="linenos">2612</span></a><span class="sd"> Example:</span> -</span><span id="Select.cluster_by-2613"><a href="#Select.cluster_by-2613"><span class="linenos">2613</span></a><span class="sd"> >>> Select().from_("tbl").select("x").cluster_by("x DESC").sql(dialect="hive")</span> -</span><span id="Select.cluster_by-2614"><a href="#Select.cluster_by-2614"><span class="linenos">2614</span></a><span class="sd"> 'SELECT x FROM tbl CLUSTER BY x DESC'</span> -</span><span id="Select.cluster_by-2615"><a href="#Select.cluster_by-2615"><span class="linenos">2615</span></a> -</span><span id="Select.cluster_by-2616"><a href="#Select.cluster_by-2616"><span class="linenos">2616</span></a><span class="sd"> Args:</span> -</span><span id="Select.cluster_by-2617"><a href="#Select.cluster_by-2617"><span class="linenos">2617</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="Select.cluster_by-2618"><a href="#Select.cluster_by-2618"><span class="linenos">2618</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> -</span><span id="Select.cluster_by-2619"><a href="#Select.cluster_by-2619"><span class="linenos">2619</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Cluster`.</span> -</span><span id="Select.cluster_by-2620"><a href="#Select.cluster_by-2620"><span class="linenos">2620</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="Select.cluster_by-2621"><a href="#Select.cluster_by-2621"><span class="linenos">2621</span></a><span class="sd"> Otherwise, this flattens all the `Order` expression into a single expression.</span> -</span><span id="Select.cluster_by-2622"><a href="#Select.cluster_by-2622"><span class="linenos">2622</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="Select.cluster_by-2623"><a href="#Select.cluster_by-2623"><span class="linenos">2623</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select.cluster_by-2624"><a href="#Select.cluster_by-2624"><span class="linenos">2624</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select.cluster_by-2625"><a href="#Select.cluster_by-2625"><span class="linenos">2625</span></a> -</span><span id="Select.cluster_by-2626"><a href="#Select.cluster_by-2626"><span class="linenos">2626</span></a><span class="sd"> Returns:</span> -</span><span id="Select.cluster_by-2627"><a href="#Select.cluster_by-2627"><span class="linenos">2627</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="Select.cluster_by-2628"><a href="#Select.cluster_by-2628"><span class="linenos">2628</span></a><span class="sd"> """</span> -</span><span id="Select.cluster_by-2629"><a href="#Select.cluster_by-2629"><span class="linenos">2629</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> -</span><span id="Select.cluster_by-2630"><a href="#Select.cluster_by-2630"><span class="linenos">2630</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select.cluster_by-2631"><a href="#Select.cluster_by-2631"><span class="linenos">2631</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select.cluster_by-2632"><a href="#Select.cluster_by-2632"><span class="linenos">2632</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"cluster"</span><span class="p">,</span> -</span><span id="Select.cluster_by-2633"><a href="#Select.cluster_by-2633"><span class="linenos">2633</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select.cluster_by-2634"><a href="#Select.cluster_by-2634"><span class="linenos">2634</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select.cluster_by-2635"><a href="#Select.cluster_by-2635"><span class="linenos">2635</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"CLUSTER BY"</span><span class="p">,</span> -</span><span id="Select.cluster_by-2636"><a href="#Select.cluster_by-2636"><span class="linenos">2636</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Cluster</span><span class="p">,</span> -</span><span id="Select.cluster_by-2637"><a href="#Select.cluster_by-2637"><span class="linenos">2637</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select.cluster_by-2638"><a href="#Select.cluster_by-2638"><span class="linenos">2638</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.cluster_by-2639"><a href="#Select.cluster_by-2639"><span class="linenos">2639</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Select.cluster_by-2603"><a href="#Select.cluster_by-2603"><span class="linenos">2603</span></a> <span class="k">def</span> <span class="nf">cluster_by</span><span class="p">(</span> +</span><span id="Select.cluster_by-2604"><a href="#Select.cluster_by-2604"><span class="linenos">2604</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select.cluster_by-2605"><a href="#Select.cluster_by-2605"><span class="linenos">2605</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select.cluster_by-2606"><a href="#Select.cluster_by-2606"><span class="linenos">2606</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.cluster_by-2607"><a href="#Select.cluster_by-2607"><span class="linenos">2607</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select.cluster_by-2608"><a href="#Select.cluster_by-2608"><span class="linenos">2608</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.cluster_by-2609"><a href="#Select.cluster_by-2609"><span class="linenos">2609</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.cluster_by-2610"><a href="#Select.cluster_by-2610"><span class="linenos">2610</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select.cluster_by-2611"><a href="#Select.cluster_by-2611"><span class="linenos">2611</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select.cluster_by-2612"><a href="#Select.cluster_by-2612"><span class="linenos">2612</span></a><span class="sd"> Set the CLUSTER BY expression.</span> +</span><span id="Select.cluster_by-2613"><a href="#Select.cluster_by-2613"><span class="linenos">2613</span></a> +</span><span id="Select.cluster_by-2614"><a href="#Select.cluster_by-2614"><span class="linenos">2614</span></a><span class="sd"> Example:</span> +</span><span id="Select.cluster_by-2615"><a href="#Select.cluster_by-2615"><span class="linenos">2615</span></a><span class="sd"> >>> Select().from_("tbl").select("x").cluster_by("x DESC").sql(dialect="hive")</span> +</span><span id="Select.cluster_by-2616"><a href="#Select.cluster_by-2616"><span class="linenos">2616</span></a><span class="sd"> 'SELECT x FROM tbl CLUSTER BY x DESC'</span> +</span><span id="Select.cluster_by-2617"><a href="#Select.cluster_by-2617"><span class="linenos">2617</span></a> +</span><span id="Select.cluster_by-2618"><a href="#Select.cluster_by-2618"><span class="linenos">2618</span></a><span class="sd"> Args:</span> +</span><span id="Select.cluster_by-2619"><a href="#Select.cluster_by-2619"><span class="linenos">2619</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="Select.cluster_by-2620"><a href="#Select.cluster_by-2620"><span class="linenos">2620</span></a><span class="sd"> If a `Group` instance is passed, this is used as-is.</span> +</span><span id="Select.cluster_by-2621"><a href="#Select.cluster_by-2621"><span class="linenos">2621</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Cluster`.</span> +</span><span id="Select.cluster_by-2622"><a href="#Select.cluster_by-2622"><span class="linenos">2622</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="Select.cluster_by-2623"><a href="#Select.cluster_by-2623"><span class="linenos">2623</span></a><span class="sd"> Otherwise, this flattens all the `Order` expression into a single expression.</span> +</span><span id="Select.cluster_by-2624"><a href="#Select.cluster_by-2624"><span class="linenos">2624</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="Select.cluster_by-2625"><a href="#Select.cluster_by-2625"><span class="linenos">2625</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select.cluster_by-2626"><a href="#Select.cluster_by-2626"><span class="linenos">2626</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select.cluster_by-2627"><a href="#Select.cluster_by-2627"><span class="linenos">2627</span></a> +</span><span id="Select.cluster_by-2628"><a href="#Select.cluster_by-2628"><span class="linenos">2628</span></a><span class="sd"> Returns:</span> +</span><span id="Select.cluster_by-2629"><a href="#Select.cluster_by-2629"><span class="linenos">2629</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="Select.cluster_by-2630"><a href="#Select.cluster_by-2630"><span class="linenos">2630</span></a><span class="sd"> """</span> +</span><span id="Select.cluster_by-2631"><a href="#Select.cluster_by-2631"><span class="linenos">2631</span></a> <span class="k">return</span> <span class="n">_apply_child_list_builder</span><span class="p">(</span> +</span><span id="Select.cluster_by-2632"><a href="#Select.cluster_by-2632"><span class="linenos">2632</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select.cluster_by-2633"><a href="#Select.cluster_by-2633"><span class="linenos">2633</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select.cluster_by-2634"><a href="#Select.cluster_by-2634"><span class="linenos">2634</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"cluster"</span><span class="p">,</span> +</span><span id="Select.cluster_by-2635"><a href="#Select.cluster_by-2635"><span class="linenos">2635</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select.cluster_by-2636"><a href="#Select.cluster_by-2636"><span class="linenos">2636</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select.cluster_by-2637"><a href="#Select.cluster_by-2637"><span class="linenos">2637</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"CLUSTER BY"</span><span class="p">,</span> +</span><span id="Select.cluster_by-2638"><a href="#Select.cluster_by-2638"><span class="linenos">2638</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Cluster</span><span class="p">,</span> +</span><span id="Select.cluster_by-2639"><a href="#Select.cluster_by-2639"><span class="linenos">2639</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select.cluster_by-2640"><a href="#Select.cluster_by-2640"><span class="linenos">2640</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.cluster_by-2641"><a href="#Select.cluster_by-2641"><span class="linenos">2641</span></a> <span class="p">)</span> </span></pre></div> @@ -25553,38 +25632,38 @@ Otherwise, this flattens all the <code><a href="#Order">Order</a></code> express </div> <a class="headerlink" href="#Select.limit"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Select.limit-2641"><a href="#Select.limit-2641"><span class="linenos">2641</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span> -</span><span id="Select.limit-2642"><a href="#Select.limit-2642"><span class="linenos">2642</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="Select.limit-2643"><a href="#Select.limit-2643"><span class="linenos">2643</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select.limit-2644"><a href="#Select.limit-2644"><span class="linenos">2644</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select.limit-2645"><a href="#Select.limit-2645"><span class="linenos">2645</span></a><span class="sd"> Set the LIMIT expression.</span> -</span><span id="Select.limit-2646"><a href="#Select.limit-2646"><span class="linenos">2646</span></a> -</span><span id="Select.limit-2647"><a href="#Select.limit-2647"><span class="linenos">2647</span></a><span class="sd"> Example:</span> -</span><span id="Select.limit-2648"><a href="#Select.limit-2648"><span class="linenos">2648</span></a><span class="sd"> >>> Select().from_("tbl").select("x").limit(10).sql()</span> -</span><span id="Select.limit-2649"><a href="#Select.limit-2649"><span class="linenos">2649</span></a><span class="sd"> 'SELECT x FROM tbl LIMIT 10'</span> -</span><span id="Select.limit-2650"><a href="#Select.limit-2650"><span class="linenos">2650</span></a> -</span><span id="Select.limit-2651"><a href="#Select.limit-2651"><span class="linenos">2651</span></a><span class="sd"> Args:</span> -</span><span id="Select.limit-2652"><a href="#Select.limit-2652"><span class="linenos">2652</span></a><span class="sd"> expression: the SQL code string to parse.</span> -</span><span id="Select.limit-2653"><a href="#Select.limit-2653"><span class="linenos">2653</span></a><span class="sd"> This can also be an integer.</span> -</span><span id="Select.limit-2654"><a href="#Select.limit-2654"><span class="linenos">2654</span></a><span class="sd"> If a `Limit` instance is passed, this is used as-is.</span> -</span><span id="Select.limit-2655"><a href="#Select.limit-2655"><span class="linenos">2655</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Limit`.</span> -</span><span id="Select.limit-2656"><a href="#Select.limit-2656"><span class="linenos">2656</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="Select.limit-2657"><a href="#Select.limit-2657"><span class="linenos">2657</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select.limit-2658"><a href="#Select.limit-2658"><span class="linenos">2658</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select.limit-2659"><a href="#Select.limit-2659"><span class="linenos">2659</span></a> -</span><span id="Select.limit-2660"><a href="#Select.limit-2660"><span class="linenos">2660</span></a><span class="sd"> Returns:</span> -</span><span id="Select.limit-2661"><a href="#Select.limit-2661"><span class="linenos">2661</span></a><span class="sd"> Select: the modified expression.</span> -</span><span id="Select.limit-2662"><a href="#Select.limit-2662"><span class="linenos">2662</span></a><span class="sd"> """</span> -</span><span id="Select.limit-2663"><a href="#Select.limit-2663"><span class="linenos">2663</span></a> <span class="k">return</span> <span class="n">_apply_builder</span><span class="p">(</span> -</span><span id="Select.limit-2664"><a href="#Select.limit-2664"><span class="linenos">2664</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> -</span><span id="Select.limit-2665"><a href="#Select.limit-2665"><span class="linenos">2665</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select.limit-2666"><a href="#Select.limit-2666"><span class="linenos">2666</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"limit"</span><span class="p">,</span> -</span><span id="Select.limit-2667"><a href="#Select.limit-2667"><span class="linenos">2667</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Limit</span><span class="p">,</span> -</span><span id="Select.limit-2668"><a href="#Select.limit-2668"><span class="linenos">2668</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"LIMIT"</span><span class="p">,</span> -</span><span id="Select.limit-2669"><a href="#Select.limit-2669"><span class="linenos">2669</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select.limit-2670"><a href="#Select.limit-2670"><span class="linenos">2670</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select.limit-2671"><a href="#Select.limit-2671"><span class="linenos">2671</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.limit-2672"><a href="#Select.limit-2672"><span class="linenos">2672</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Select.limit-2643"><a href="#Select.limit-2643"><span class="linenos">2643</span></a> <span class="k">def</span> <span class="nf">limit</span><span class="p">(</span> +</span><span id="Select.limit-2644"><a href="#Select.limit-2644"><span class="linenos">2644</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="Select.limit-2645"><a href="#Select.limit-2645"><span class="linenos">2645</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select.limit-2646"><a href="#Select.limit-2646"><span class="linenos">2646</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select.limit-2647"><a href="#Select.limit-2647"><span class="linenos">2647</span></a><span class="sd"> Set the LIMIT expression.</span> +</span><span id="Select.limit-2648"><a href="#Select.limit-2648"><span class="linenos">2648</span></a> +</span><span id="Select.limit-2649"><a href="#Select.limit-2649"><span class="linenos">2649</span></a><span class="sd"> Example:</span> +</span><span id="Select.limit-2650"><a href="#Select.limit-2650"><span class="linenos">2650</span></a><span class="sd"> >>> Select().from_("tbl").select("x").limit(10).sql()</span> +</span><span id="Select.limit-2651"><a href="#Select.limit-2651"><span class="linenos">2651</span></a><span class="sd"> 'SELECT x FROM tbl LIMIT 10'</span> +</span><span id="Select.limit-2652"><a href="#Select.limit-2652"><span class="linenos">2652</span></a> +</span><span id="Select.limit-2653"><a href="#Select.limit-2653"><span class="linenos">2653</span></a><span class="sd"> Args:</span> +</span><span id="Select.limit-2654"><a href="#Select.limit-2654"><span class="linenos">2654</span></a><span class="sd"> expression: the SQL code string to parse.</span> +</span><span id="Select.limit-2655"><a href="#Select.limit-2655"><span class="linenos">2655</span></a><span class="sd"> This can also be an integer.</span> +</span><span id="Select.limit-2656"><a href="#Select.limit-2656"><span class="linenos">2656</span></a><span class="sd"> If a `Limit` instance is passed, this is used as-is.</span> +</span><span id="Select.limit-2657"><a href="#Select.limit-2657"><span class="linenos">2657</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Limit`.</span> +</span><span id="Select.limit-2658"><a href="#Select.limit-2658"><span class="linenos">2658</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="Select.limit-2659"><a href="#Select.limit-2659"><span class="linenos">2659</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select.limit-2660"><a href="#Select.limit-2660"><span class="linenos">2660</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select.limit-2661"><a href="#Select.limit-2661"><span class="linenos">2661</span></a> +</span><span id="Select.limit-2662"><a href="#Select.limit-2662"><span class="linenos">2662</span></a><span class="sd"> Returns:</span> +</span><span id="Select.limit-2663"><a href="#Select.limit-2663"><span class="linenos">2663</span></a><span class="sd"> Select: the modified expression.</span> +</span><span id="Select.limit-2664"><a href="#Select.limit-2664"><span class="linenos">2664</span></a><span class="sd"> """</span> +</span><span id="Select.limit-2665"><a href="#Select.limit-2665"><span class="linenos">2665</span></a> <span class="k">return</span> <span class="n">_apply_builder</span><span class="p">(</span> +</span><span id="Select.limit-2666"><a href="#Select.limit-2666"><span class="linenos">2666</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> +</span><span id="Select.limit-2667"><a href="#Select.limit-2667"><span class="linenos">2667</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select.limit-2668"><a href="#Select.limit-2668"><span class="linenos">2668</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"limit"</span><span class="p">,</span> +</span><span id="Select.limit-2669"><a href="#Select.limit-2669"><span class="linenos">2669</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Limit</span><span class="p">,</span> +</span><span id="Select.limit-2670"><a href="#Select.limit-2670"><span class="linenos">2670</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"LIMIT"</span><span class="p">,</span> +</span><span id="Select.limit-2671"><a href="#Select.limit-2671"><span class="linenos">2671</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select.limit-2672"><a href="#Select.limit-2672"><span class="linenos">2672</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select.limit-2673"><a href="#Select.limit-2673"><span class="linenos">2673</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.limit-2674"><a href="#Select.limit-2674"><span class="linenos">2674</span></a> <span class="p">)</span> </span></pre></div> @@ -25632,38 +25711,38 @@ If another <code><a href="#Expression">Expression</a></code> instance is passed, </div> <a class="headerlink" href="#Select.offset"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Select.offset-2674"><a href="#Select.offset-2674"><span class="linenos">2674</span></a> <span class="k">def</span> <span class="nf">offset</span><span class="p">(</span> -</span><span id="Select.offset-2675"><a href="#Select.offset-2675"><span class="linenos">2675</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="Select.offset-2676"><a href="#Select.offset-2676"><span class="linenos">2676</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select.offset-2677"><a href="#Select.offset-2677"><span class="linenos">2677</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select.offset-2678"><a href="#Select.offset-2678"><span class="linenos">2678</span></a><span class="sd"> Set the OFFSET expression.</span> -</span><span id="Select.offset-2679"><a href="#Select.offset-2679"><span class="linenos">2679</span></a> -</span><span id="Select.offset-2680"><a href="#Select.offset-2680"><span class="linenos">2680</span></a><span class="sd"> Example:</span> -</span><span id="Select.offset-2681"><a href="#Select.offset-2681"><span class="linenos">2681</span></a><span class="sd"> >>> Select().from_("tbl").select("x").offset(10).sql()</span> -</span><span id="Select.offset-2682"><a href="#Select.offset-2682"><span class="linenos">2682</span></a><span class="sd"> 'SELECT x FROM tbl OFFSET 10'</span> -</span><span id="Select.offset-2683"><a href="#Select.offset-2683"><span class="linenos">2683</span></a> -</span><span id="Select.offset-2684"><a href="#Select.offset-2684"><span class="linenos">2684</span></a><span class="sd"> Args:</span> -</span><span id="Select.offset-2685"><a href="#Select.offset-2685"><span class="linenos">2685</span></a><span class="sd"> expression: the SQL code string to parse.</span> -</span><span id="Select.offset-2686"><a href="#Select.offset-2686"><span class="linenos">2686</span></a><span class="sd"> This can also be an integer.</span> -</span><span id="Select.offset-2687"><a href="#Select.offset-2687"><span class="linenos">2687</span></a><span class="sd"> If a `Offset` instance is passed, this is used as-is.</span> -</span><span id="Select.offset-2688"><a href="#Select.offset-2688"><span class="linenos">2688</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Offset`.</span> -</span><span id="Select.offset-2689"><a href="#Select.offset-2689"><span class="linenos">2689</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="Select.offset-2690"><a href="#Select.offset-2690"><span class="linenos">2690</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select.offset-2691"><a href="#Select.offset-2691"><span class="linenos">2691</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select.offset-2692"><a href="#Select.offset-2692"><span class="linenos">2692</span></a> -</span><span id="Select.offset-2693"><a href="#Select.offset-2693"><span class="linenos">2693</span></a><span class="sd"> Returns:</span> -</span><span id="Select.offset-2694"><a href="#Select.offset-2694"><span class="linenos">2694</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="Select.offset-2695"><a href="#Select.offset-2695"><span class="linenos">2695</span></a><span class="sd"> """</span> -</span><span id="Select.offset-2696"><a href="#Select.offset-2696"><span class="linenos">2696</span></a> <span class="k">return</span> <span class="n">_apply_builder</span><span class="p">(</span> -</span><span id="Select.offset-2697"><a href="#Select.offset-2697"><span class="linenos">2697</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> -</span><span id="Select.offset-2698"><a href="#Select.offset-2698"><span class="linenos">2698</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select.offset-2699"><a href="#Select.offset-2699"><span class="linenos">2699</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"offset"</span><span class="p">,</span> -</span><span id="Select.offset-2700"><a href="#Select.offset-2700"><span class="linenos">2700</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Offset</span><span class="p">,</span> -</span><span id="Select.offset-2701"><a href="#Select.offset-2701"><span class="linenos">2701</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"OFFSET"</span><span class="p">,</span> -</span><span id="Select.offset-2702"><a href="#Select.offset-2702"><span class="linenos">2702</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select.offset-2703"><a href="#Select.offset-2703"><span class="linenos">2703</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select.offset-2704"><a href="#Select.offset-2704"><span class="linenos">2704</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.offset-2705"><a href="#Select.offset-2705"><span class="linenos">2705</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Select.offset-2676"><a href="#Select.offset-2676"><span class="linenos">2676</span></a> <span class="k">def</span> <span class="nf">offset</span><span class="p">(</span> +</span><span id="Select.offset-2677"><a href="#Select.offset-2677"><span class="linenos">2677</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span> <span class="o">|</span> <span class="nb">int</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="Select.offset-2678"><a href="#Select.offset-2678"><span class="linenos">2678</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select.offset-2679"><a href="#Select.offset-2679"><span class="linenos">2679</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select.offset-2680"><a href="#Select.offset-2680"><span class="linenos">2680</span></a><span class="sd"> Set the OFFSET expression.</span> +</span><span id="Select.offset-2681"><a href="#Select.offset-2681"><span class="linenos">2681</span></a> +</span><span id="Select.offset-2682"><a href="#Select.offset-2682"><span class="linenos">2682</span></a><span class="sd"> Example:</span> +</span><span id="Select.offset-2683"><a href="#Select.offset-2683"><span class="linenos">2683</span></a><span class="sd"> >>> Select().from_("tbl").select("x").offset(10).sql()</span> +</span><span id="Select.offset-2684"><a href="#Select.offset-2684"><span class="linenos">2684</span></a><span class="sd"> 'SELECT x FROM tbl OFFSET 10'</span> +</span><span id="Select.offset-2685"><a href="#Select.offset-2685"><span class="linenos">2685</span></a> +</span><span id="Select.offset-2686"><a href="#Select.offset-2686"><span class="linenos">2686</span></a><span class="sd"> Args:</span> +</span><span id="Select.offset-2687"><a href="#Select.offset-2687"><span class="linenos">2687</span></a><span class="sd"> expression: the SQL code string to parse.</span> +</span><span id="Select.offset-2688"><a href="#Select.offset-2688"><span class="linenos">2688</span></a><span class="sd"> This can also be an integer.</span> +</span><span id="Select.offset-2689"><a href="#Select.offset-2689"><span class="linenos">2689</span></a><span class="sd"> If a `Offset` instance is passed, this is used as-is.</span> +</span><span id="Select.offset-2690"><a href="#Select.offset-2690"><span class="linenos">2690</span></a><span class="sd"> If another `Expression` instance is passed, it will be wrapped in a `Offset`.</span> +</span><span id="Select.offset-2691"><a href="#Select.offset-2691"><span class="linenos">2691</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="Select.offset-2692"><a href="#Select.offset-2692"><span class="linenos">2692</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select.offset-2693"><a href="#Select.offset-2693"><span class="linenos">2693</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select.offset-2694"><a href="#Select.offset-2694"><span class="linenos">2694</span></a> +</span><span id="Select.offset-2695"><a href="#Select.offset-2695"><span class="linenos">2695</span></a><span class="sd"> Returns:</span> +</span><span id="Select.offset-2696"><a href="#Select.offset-2696"><span class="linenos">2696</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="Select.offset-2697"><a href="#Select.offset-2697"><span class="linenos">2697</span></a><span class="sd"> """</span> +</span><span id="Select.offset-2698"><a href="#Select.offset-2698"><span class="linenos">2698</span></a> <span class="k">return</span> <span class="n">_apply_builder</span><span class="p">(</span> +</span><span id="Select.offset-2699"><a href="#Select.offset-2699"><span class="linenos">2699</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> +</span><span id="Select.offset-2700"><a href="#Select.offset-2700"><span class="linenos">2700</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select.offset-2701"><a href="#Select.offset-2701"><span class="linenos">2701</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"offset"</span><span class="p">,</span> +</span><span id="Select.offset-2702"><a href="#Select.offset-2702"><span class="linenos">2702</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Offset</span><span class="p">,</span> +</span><span id="Select.offset-2703"><a href="#Select.offset-2703"><span class="linenos">2703</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"OFFSET"</span><span class="p">,</span> +</span><span id="Select.offset-2704"><a href="#Select.offset-2704"><span class="linenos">2704</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select.offset-2705"><a href="#Select.offset-2705"><span class="linenos">2705</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select.offset-2706"><a href="#Select.offset-2706"><span class="linenos">2706</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.offset-2707"><a href="#Select.offset-2707"><span class="linenos">2707</span></a> <span class="p">)</span> </span></pre></div> @@ -25711,42 +25790,42 @@ If another <code><a href="#Expression">Expression</a></code> instance is passed, </div> <a class="headerlink" href="#Select.select"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Select.select-2707"><a href="#Select.select-2707"><span class="linenos">2707</span></a> <span class="k">def</span> <span class="nf">select</span><span class="p">(</span> -</span><span id="Select.select-2708"><a href="#Select.select-2708"><span class="linenos">2708</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select.select-2709"><a href="#Select.select-2709"><span class="linenos">2709</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select.select-2710"><a href="#Select.select-2710"><span class="linenos">2710</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.select-2711"><a href="#Select.select-2711"><span class="linenos">2711</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select.select-2712"><a href="#Select.select-2712"><span class="linenos">2712</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.select-2713"><a href="#Select.select-2713"><span class="linenos">2713</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.select-2714"><a href="#Select.select-2714"><span class="linenos">2714</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select.select-2715"><a href="#Select.select-2715"><span class="linenos">2715</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select.select-2716"><a href="#Select.select-2716"><span class="linenos">2716</span></a><span class="sd"> Append to or set the SELECT expressions.</span> -</span><span id="Select.select-2717"><a href="#Select.select-2717"><span class="linenos">2717</span></a> -</span><span id="Select.select-2718"><a href="#Select.select-2718"><span class="linenos">2718</span></a><span class="sd"> Example:</span> -</span><span id="Select.select-2719"><a href="#Select.select-2719"><span class="linenos">2719</span></a><span class="sd"> >>> Select().select("x", "y").sql()</span> -</span><span id="Select.select-2720"><a href="#Select.select-2720"><span class="linenos">2720</span></a><span class="sd"> 'SELECT x, y'</span> -</span><span id="Select.select-2721"><a href="#Select.select-2721"><span class="linenos">2721</span></a> -</span><span id="Select.select-2722"><a href="#Select.select-2722"><span class="linenos">2722</span></a><span class="sd"> Args:</span> -</span><span id="Select.select-2723"><a href="#Select.select-2723"><span class="linenos">2723</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="Select.select-2724"><a href="#Select.select-2724"><span class="linenos">2724</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Select.select-2725"><a href="#Select.select-2725"><span class="linenos">2725</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="Select.select-2726"><a href="#Select.select-2726"><span class="linenos">2726</span></a><span class="sd"> Otherwise, this resets the expressions.</span> -</span><span id="Select.select-2727"><a href="#Select.select-2727"><span class="linenos">2727</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="Select.select-2728"><a href="#Select.select-2728"><span class="linenos">2728</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select.select-2729"><a href="#Select.select-2729"><span class="linenos">2729</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select.select-2730"><a href="#Select.select-2730"><span class="linenos">2730</span></a> -</span><span id="Select.select-2731"><a href="#Select.select-2731"><span class="linenos">2731</span></a><span class="sd"> Returns:</span> -</span><span id="Select.select-2732"><a href="#Select.select-2732"><span class="linenos">2732</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="Select.select-2733"><a href="#Select.select-2733"><span class="linenos">2733</span></a><span class="sd"> """</span> -</span><span id="Select.select-2734"><a href="#Select.select-2734"><span class="linenos">2734</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> -</span><span id="Select.select-2735"><a href="#Select.select-2735"><span class="linenos">2735</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select.select-2736"><a href="#Select.select-2736"><span class="linenos">2736</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select.select-2737"><a href="#Select.select-2737"><span class="linenos">2737</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"expressions"</span><span class="p">,</span> -</span><span id="Select.select-2738"><a href="#Select.select-2738"><span class="linenos">2738</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select.select-2739"><a href="#Select.select-2739"><span class="linenos">2739</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select.select-2740"><a href="#Select.select-2740"><span class="linenos">2740</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select.select-2741"><a href="#Select.select-2741"><span class="linenos">2741</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.select-2742"><a href="#Select.select-2742"><span class="linenos">2742</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Select.select-2709"><a href="#Select.select-2709"><span class="linenos">2709</span></a> <span class="k">def</span> <span class="nf">select</span><span class="p">(</span> +</span><span id="Select.select-2710"><a href="#Select.select-2710"><span class="linenos">2710</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select.select-2711"><a href="#Select.select-2711"><span class="linenos">2711</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select.select-2712"><a href="#Select.select-2712"><span class="linenos">2712</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.select-2713"><a href="#Select.select-2713"><span class="linenos">2713</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select.select-2714"><a href="#Select.select-2714"><span class="linenos">2714</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.select-2715"><a href="#Select.select-2715"><span class="linenos">2715</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.select-2716"><a href="#Select.select-2716"><span class="linenos">2716</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select.select-2717"><a href="#Select.select-2717"><span class="linenos">2717</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select.select-2718"><a href="#Select.select-2718"><span class="linenos">2718</span></a><span class="sd"> Append to or set the SELECT expressions.</span> +</span><span id="Select.select-2719"><a href="#Select.select-2719"><span class="linenos">2719</span></a> +</span><span id="Select.select-2720"><a href="#Select.select-2720"><span class="linenos">2720</span></a><span class="sd"> Example:</span> +</span><span id="Select.select-2721"><a href="#Select.select-2721"><span class="linenos">2721</span></a><span class="sd"> >>> Select().select("x", "y").sql()</span> +</span><span id="Select.select-2722"><a href="#Select.select-2722"><span class="linenos">2722</span></a><span class="sd"> 'SELECT x, y'</span> +</span><span id="Select.select-2723"><a href="#Select.select-2723"><span class="linenos">2723</span></a> +</span><span id="Select.select-2724"><a href="#Select.select-2724"><span class="linenos">2724</span></a><span class="sd"> Args:</span> +</span><span id="Select.select-2725"><a href="#Select.select-2725"><span class="linenos">2725</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="Select.select-2726"><a href="#Select.select-2726"><span class="linenos">2726</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="Select.select-2727"><a href="#Select.select-2727"><span class="linenos">2727</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="Select.select-2728"><a href="#Select.select-2728"><span class="linenos">2728</span></a><span class="sd"> Otherwise, this resets the expressions.</span> +</span><span id="Select.select-2729"><a href="#Select.select-2729"><span class="linenos">2729</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="Select.select-2730"><a href="#Select.select-2730"><span class="linenos">2730</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select.select-2731"><a href="#Select.select-2731"><span class="linenos">2731</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select.select-2732"><a href="#Select.select-2732"><span class="linenos">2732</span></a> +</span><span id="Select.select-2733"><a href="#Select.select-2733"><span class="linenos">2733</span></a><span class="sd"> Returns:</span> +</span><span id="Select.select-2734"><a href="#Select.select-2734"><span class="linenos">2734</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="Select.select-2735"><a href="#Select.select-2735"><span class="linenos">2735</span></a><span class="sd"> """</span> +</span><span id="Select.select-2736"><a href="#Select.select-2736"><span class="linenos">2736</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> +</span><span id="Select.select-2737"><a href="#Select.select-2737"><span class="linenos">2737</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select.select-2738"><a href="#Select.select-2738"><span class="linenos">2738</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select.select-2739"><a href="#Select.select-2739"><span class="linenos">2739</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"expressions"</span><span class="p">,</span> +</span><span id="Select.select-2740"><a href="#Select.select-2740"><span class="linenos">2740</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select.select-2741"><a href="#Select.select-2741"><span class="linenos">2741</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select.select-2742"><a href="#Select.select-2742"><span class="linenos">2742</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select.select-2743"><a href="#Select.select-2743"><span class="linenos">2743</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.select-2744"><a href="#Select.select-2744"><span class="linenos">2744</span></a> <span class="p">)</span> </span></pre></div> @@ -25794,44 +25873,44 @@ Otherwise, this resets the expressions.</li> </div> <a class="headerlink" href="#Select.lateral"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Select.lateral-2744"><a href="#Select.lateral-2744"><span class="linenos">2744</span></a> <span class="k">def</span> <span class="nf">lateral</span><span class="p">(</span> -</span><span id="Select.lateral-2745"><a href="#Select.lateral-2745"><span class="linenos">2745</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select.lateral-2746"><a href="#Select.lateral-2746"><span class="linenos">2746</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select.lateral-2747"><a href="#Select.lateral-2747"><span class="linenos">2747</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.lateral-2748"><a href="#Select.lateral-2748"><span class="linenos">2748</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select.lateral-2749"><a href="#Select.lateral-2749"><span class="linenos">2749</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.lateral-2750"><a href="#Select.lateral-2750"><span class="linenos">2750</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.lateral-2751"><a href="#Select.lateral-2751"><span class="linenos">2751</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select.lateral-2752"><a href="#Select.lateral-2752"><span class="linenos">2752</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select.lateral-2753"><a href="#Select.lateral-2753"><span class="linenos">2753</span></a><span class="sd"> Append to or set the LATERAL expressions.</span> -</span><span id="Select.lateral-2754"><a href="#Select.lateral-2754"><span class="linenos">2754</span></a> -</span><span id="Select.lateral-2755"><a href="#Select.lateral-2755"><span class="linenos">2755</span></a><span class="sd"> Example:</span> -</span><span id="Select.lateral-2756"><a href="#Select.lateral-2756"><span class="linenos">2756</span></a><span class="sd"> >>> Select().select("x").lateral("OUTER explode(y) tbl2 AS z").from_("tbl").sql()</span> -</span><span id="Select.lateral-2757"><a href="#Select.lateral-2757"><span class="linenos">2757</span></a><span class="sd"> 'SELECT x FROM tbl LATERAL VIEW OUTER EXPLODE(y) tbl2 AS z'</span> -</span><span id="Select.lateral-2758"><a href="#Select.lateral-2758"><span class="linenos">2758</span></a> -</span><span id="Select.lateral-2759"><a href="#Select.lateral-2759"><span class="linenos">2759</span></a><span class="sd"> Args:</span> -</span><span id="Select.lateral-2760"><a href="#Select.lateral-2760"><span class="linenos">2760</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="Select.lateral-2761"><a href="#Select.lateral-2761"><span class="linenos">2761</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Select.lateral-2762"><a href="#Select.lateral-2762"><span class="linenos">2762</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="Select.lateral-2763"><a href="#Select.lateral-2763"><span class="linenos">2763</span></a><span class="sd"> Otherwise, this resets the expressions.</span> -</span><span id="Select.lateral-2764"><a href="#Select.lateral-2764"><span class="linenos">2764</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="Select.lateral-2765"><a href="#Select.lateral-2765"><span class="linenos">2765</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select.lateral-2766"><a href="#Select.lateral-2766"><span class="linenos">2766</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select.lateral-2767"><a href="#Select.lateral-2767"><span class="linenos">2767</span></a> -</span><span id="Select.lateral-2768"><a href="#Select.lateral-2768"><span class="linenos">2768</span></a><span class="sd"> Returns:</span> -</span><span id="Select.lateral-2769"><a href="#Select.lateral-2769"><span class="linenos">2769</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="Select.lateral-2770"><a href="#Select.lateral-2770"><span class="linenos">2770</span></a><span class="sd"> """</span> -</span><span id="Select.lateral-2771"><a href="#Select.lateral-2771"><span class="linenos">2771</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> -</span><span id="Select.lateral-2772"><a href="#Select.lateral-2772"><span class="linenos">2772</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select.lateral-2773"><a href="#Select.lateral-2773"><span class="linenos">2773</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select.lateral-2774"><a href="#Select.lateral-2774"><span class="linenos">2774</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"laterals"</span><span class="p">,</span> -</span><span id="Select.lateral-2775"><a href="#Select.lateral-2775"><span class="linenos">2775</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select.lateral-2776"><a href="#Select.lateral-2776"><span class="linenos">2776</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Lateral</span><span class="p">,</span> -</span><span id="Select.lateral-2777"><a href="#Select.lateral-2777"><span class="linenos">2777</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"LATERAL VIEW"</span><span class="p">,</span> -</span><span id="Select.lateral-2778"><a href="#Select.lateral-2778"><span class="linenos">2778</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select.lateral-2779"><a href="#Select.lateral-2779"><span class="linenos">2779</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select.lateral-2780"><a href="#Select.lateral-2780"><span class="linenos">2780</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.lateral-2781"><a href="#Select.lateral-2781"><span class="linenos">2781</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Select.lateral-2746"><a href="#Select.lateral-2746"><span class="linenos">2746</span></a> <span class="k">def</span> <span class="nf">lateral</span><span class="p">(</span> +</span><span id="Select.lateral-2747"><a href="#Select.lateral-2747"><span class="linenos">2747</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select.lateral-2748"><a href="#Select.lateral-2748"><span class="linenos">2748</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select.lateral-2749"><a href="#Select.lateral-2749"><span class="linenos">2749</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.lateral-2750"><a href="#Select.lateral-2750"><span class="linenos">2750</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select.lateral-2751"><a href="#Select.lateral-2751"><span class="linenos">2751</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.lateral-2752"><a href="#Select.lateral-2752"><span class="linenos">2752</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.lateral-2753"><a href="#Select.lateral-2753"><span class="linenos">2753</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select.lateral-2754"><a href="#Select.lateral-2754"><span class="linenos">2754</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select.lateral-2755"><a href="#Select.lateral-2755"><span class="linenos">2755</span></a><span class="sd"> Append to or set the LATERAL expressions.</span> +</span><span id="Select.lateral-2756"><a href="#Select.lateral-2756"><span class="linenos">2756</span></a> +</span><span id="Select.lateral-2757"><a href="#Select.lateral-2757"><span class="linenos">2757</span></a><span class="sd"> Example:</span> +</span><span id="Select.lateral-2758"><a href="#Select.lateral-2758"><span class="linenos">2758</span></a><span class="sd"> >>> Select().select("x").lateral("OUTER explode(y) tbl2 AS z").from_("tbl").sql()</span> +</span><span id="Select.lateral-2759"><a href="#Select.lateral-2759"><span class="linenos">2759</span></a><span class="sd"> 'SELECT x FROM tbl LATERAL VIEW OUTER EXPLODE(y) tbl2 AS z'</span> +</span><span id="Select.lateral-2760"><a href="#Select.lateral-2760"><span class="linenos">2760</span></a> +</span><span id="Select.lateral-2761"><a href="#Select.lateral-2761"><span class="linenos">2761</span></a><span class="sd"> Args:</span> +</span><span id="Select.lateral-2762"><a href="#Select.lateral-2762"><span class="linenos">2762</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="Select.lateral-2763"><a href="#Select.lateral-2763"><span class="linenos">2763</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="Select.lateral-2764"><a href="#Select.lateral-2764"><span class="linenos">2764</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="Select.lateral-2765"><a href="#Select.lateral-2765"><span class="linenos">2765</span></a><span class="sd"> Otherwise, this resets the expressions.</span> +</span><span id="Select.lateral-2766"><a href="#Select.lateral-2766"><span class="linenos">2766</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="Select.lateral-2767"><a href="#Select.lateral-2767"><span class="linenos">2767</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select.lateral-2768"><a href="#Select.lateral-2768"><span class="linenos">2768</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select.lateral-2769"><a href="#Select.lateral-2769"><span class="linenos">2769</span></a> +</span><span id="Select.lateral-2770"><a href="#Select.lateral-2770"><span class="linenos">2770</span></a><span class="sd"> Returns:</span> +</span><span id="Select.lateral-2771"><a href="#Select.lateral-2771"><span class="linenos">2771</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="Select.lateral-2772"><a href="#Select.lateral-2772"><span class="linenos">2772</span></a><span class="sd"> """</span> +</span><span id="Select.lateral-2773"><a href="#Select.lateral-2773"><span class="linenos">2773</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> +</span><span id="Select.lateral-2774"><a href="#Select.lateral-2774"><span class="linenos">2774</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select.lateral-2775"><a href="#Select.lateral-2775"><span class="linenos">2775</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select.lateral-2776"><a href="#Select.lateral-2776"><span class="linenos">2776</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"laterals"</span><span class="p">,</span> +</span><span id="Select.lateral-2777"><a href="#Select.lateral-2777"><span class="linenos">2777</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select.lateral-2778"><a href="#Select.lateral-2778"><span class="linenos">2778</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Lateral</span><span class="p">,</span> +</span><span id="Select.lateral-2779"><a href="#Select.lateral-2779"><span class="linenos">2779</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"LATERAL VIEW"</span><span class="p">,</span> +</span><span id="Select.lateral-2780"><a href="#Select.lateral-2780"><span class="linenos">2780</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select.lateral-2781"><a href="#Select.lateral-2781"><span class="linenos">2781</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select.lateral-2782"><a href="#Select.lateral-2782"><span class="linenos">2782</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.lateral-2783"><a href="#Select.lateral-2783"><span class="linenos">2783</span></a> <span class="p">)</span> </span></pre></div> @@ -25879,102 +25958,102 @@ Otherwise, this resets the expressions.</li> </div> <a class="headerlink" href="#Select.join"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Select.join-2783"><a href="#Select.join-2783"><span class="linenos">2783</span></a> <span class="k">def</span> <span class="nf">join</span><span class="p">(</span> -</span><span id="Select.join-2784"><a href="#Select.join-2784"><span class="linenos">2784</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select.join-2785"><a href="#Select.join-2785"><span class="linenos">2785</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="Select.join-2786"><a href="#Select.join-2786"><span class="linenos">2786</span></a> <span class="n">on</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select.join-2787"><a href="#Select.join-2787"><span class="linenos">2787</span></a> <span class="n">using</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">ExpOrStr</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">ExpOrStr</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select.join-2788"><a href="#Select.join-2788"><span class="linenos">2788</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.join-2789"><a href="#Select.join-2789"><span class="linenos">2789</span></a> <span class="n">join_type</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="Select.join-2790"><a href="#Select.join-2790"><span class="linenos">2790</span></a> <span class="n">join_alias</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">Identifier</span> <span class="o">|</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="Select.join-2791"><a href="#Select.join-2791"><span class="linenos">2791</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select.join-2792"><a href="#Select.join-2792"><span class="linenos">2792</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.join-2793"><a href="#Select.join-2793"><span class="linenos">2793</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.join-2794"><a href="#Select.join-2794"><span class="linenos">2794</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select.join-2795"><a href="#Select.join-2795"><span class="linenos">2795</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select.join-2796"><a href="#Select.join-2796"><span class="linenos">2796</span></a><span class="sd"> Append to or set the JOIN expressions.</span> -</span><span id="Select.join-2797"><a href="#Select.join-2797"><span class="linenos">2797</span></a> -</span><span id="Select.join-2798"><a href="#Select.join-2798"><span class="linenos">2798</span></a><span class="sd"> Example:</span> -</span><span id="Select.join-2799"><a href="#Select.join-2799"><span class="linenos">2799</span></a><span class="sd"> >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y").sql()</span> -</span><span id="Select.join-2800"><a href="#Select.join-2800"><span class="linenos">2800</span></a><span class="sd"> 'SELECT * FROM tbl JOIN tbl2 ON tbl1.y = tbl2.y'</span> -</span><span id="Select.join-2801"><a href="#Select.join-2801"><span class="linenos">2801</span></a> -</span><span id="Select.join-2802"><a href="#Select.join-2802"><span class="linenos">2802</span></a><span class="sd"> >>> Select().select("1").from_("a").join("b", using=["x", "y", "z"]).sql()</span> -</span><span id="Select.join-2803"><a href="#Select.join-2803"><span class="linenos">2803</span></a><span class="sd"> 'SELECT 1 FROM a JOIN b USING (x, y, z)'</span> -</span><span id="Select.join-2804"><a href="#Select.join-2804"><span class="linenos">2804</span></a> -</span><span id="Select.join-2805"><a href="#Select.join-2805"><span class="linenos">2805</span></a><span class="sd"> Use `join_type` to change the type of join:</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Select.join-2785"><a href="#Select.join-2785"><span class="linenos">2785</span></a> <span class="k">def</span> <span class="nf">join</span><span class="p">(</span> +</span><span id="Select.join-2786"><a href="#Select.join-2786"><span class="linenos">2786</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select.join-2787"><a href="#Select.join-2787"><span class="linenos">2787</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="Select.join-2788"><a href="#Select.join-2788"><span class="linenos">2788</span></a> <span class="n">on</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select.join-2789"><a href="#Select.join-2789"><span class="linenos">2789</span></a> <span class="n">using</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">ExpOrStr</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">ExpOrStr</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select.join-2790"><a href="#Select.join-2790"><span class="linenos">2790</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.join-2791"><a href="#Select.join-2791"><span class="linenos">2791</span></a> <span class="n">join_type</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="Select.join-2792"><a href="#Select.join-2792"><span class="linenos">2792</span></a> <span class="n">join_alias</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">Identifier</span> <span class="o">|</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="Select.join-2793"><a href="#Select.join-2793"><span class="linenos">2793</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select.join-2794"><a href="#Select.join-2794"><span class="linenos">2794</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.join-2795"><a href="#Select.join-2795"><span class="linenos">2795</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.join-2796"><a href="#Select.join-2796"><span class="linenos">2796</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select.join-2797"><a href="#Select.join-2797"><span class="linenos">2797</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select.join-2798"><a href="#Select.join-2798"><span class="linenos">2798</span></a><span class="sd"> Append to or set the JOIN expressions.</span> +</span><span id="Select.join-2799"><a href="#Select.join-2799"><span class="linenos">2799</span></a> +</span><span id="Select.join-2800"><a href="#Select.join-2800"><span class="linenos">2800</span></a><span class="sd"> Example:</span> +</span><span id="Select.join-2801"><a href="#Select.join-2801"><span class="linenos">2801</span></a><span class="sd"> >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y").sql()</span> +</span><span id="Select.join-2802"><a href="#Select.join-2802"><span class="linenos">2802</span></a><span class="sd"> 'SELECT * FROM tbl JOIN tbl2 ON tbl1.y = tbl2.y'</span> +</span><span id="Select.join-2803"><a href="#Select.join-2803"><span class="linenos">2803</span></a> +</span><span id="Select.join-2804"><a href="#Select.join-2804"><span class="linenos">2804</span></a><span class="sd"> >>> Select().select("1").from_("a").join("b", using=["x", "y", "z"]).sql()</span> +</span><span id="Select.join-2805"><a href="#Select.join-2805"><span class="linenos">2805</span></a><span class="sd"> 'SELECT 1 FROM a JOIN b USING (x, y, z)'</span> </span><span id="Select.join-2806"><a href="#Select.join-2806"><span class="linenos">2806</span></a> -</span><span id="Select.join-2807"><a href="#Select.join-2807"><span class="linenos">2807</span></a><span class="sd"> >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y", join_type="left outer").sql()</span> -</span><span id="Select.join-2808"><a href="#Select.join-2808"><span class="linenos">2808</span></a><span class="sd"> 'SELECT * FROM tbl LEFT OUTER JOIN tbl2 ON tbl1.y = tbl2.y'</span> -</span><span id="Select.join-2809"><a href="#Select.join-2809"><span class="linenos">2809</span></a> -</span><span id="Select.join-2810"><a href="#Select.join-2810"><span class="linenos">2810</span></a><span class="sd"> Args:</span> -</span><span id="Select.join-2811"><a href="#Select.join-2811"><span class="linenos">2811</span></a><span class="sd"> expression: the SQL code string to parse.</span> -</span><span id="Select.join-2812"><a href="#Select.join-2812"><span class="linenos">2812</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Select.join-2813"><a href="#Select.join-2813"><span class="linenos">2813</span></a><span class="sd"> on: optionally specify the join "on" criteria as a SQL string.</span> +</span><span id="Select.join-2807"><a href="#Select.join-2807"><span class="linenos">2807</span></a><span class="sd"> Use `join_type` to change the type of join:</span> +</span><span id="Select.join-2808"><a href="#Select.join-2808"><span class="linenos">2808</span></a> +</span><span id="Select.join-2809"><a href="#Select.join-2809"><span class="linenos">2809</span></a><span class="sd"> >>> Select().select("*").from_("tbl").join("tbl2", on="tbl1.y = tbl2.y", join_type="left outer").sql()</span> +</span><span id="Select.join-2810"><a href="#Select.join-2810"><span class="linenos">2810</span></a><span class="sd"> 'SELECT * FROM tbl LEFT OUTER JOIN tbl2 ON tbl1.y = tbl2.y'</span> +</span><span id="Select.join-2811"><a href="#Select.join-2811"><span class="linenos">2811</span></a> +</span><span id="Select.join-2812"><a href="#Select.join-2812"><span class="linenos">2812</span></a><span class="sd"> Args:</span> +</span><span id="Select.join-2813"><a href="#Select.join-2813"><span class="linenos">2813</span></a><span class="sd"> expression: the SQL code string to parse.</span> </span><span id="Select.join-2814"><a href="#Select.join-2814"><span class="linenos">2814</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Select.join-2815"><a href="#Select.join-2815"><span class="linenos">2815</span></a><span class="sd"> using: optionally specify the join "using" criteria as a SQL string.</span> +</span><span id="Select.join-2815"><a href="#Select.join-2815"><span class="linenos">2815</span></a><span class="sd"> on: optionally specify the join "on" criteria as a SQL string.</span> </span><span id="Select.join-2816"><a href="#Select.join-2816"><span class="linenos">2816</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Select.join-2817"><a href="#Select.join-2817"><span class="linenos">2817</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> -</span><span id="Select.join-2818"><a href="#Select.join-2818"><span class="linenos">2818</span></a><span class="sd"> Otherwise, this resets the expressions.</span> -</span><span id="Select.join-2819"><a href="#Select.join-2819"><span class="linenos">2819</span></a><span class="sd"> join_type: if set, alter the parsed join type.</span> -</span><span id="Select.join-2820"><a href="#Select.join-2820"><span class="linenos">2820</span></a><span class="sd"> join_alias: an optional alias for the joined source.</span> -</span><span id="Select.join-2821"><a href="#Select.join-2821"><span class="linenos">2821</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="Select.join-2822"><a href="#Select.join-2822"><span class="linenos">2822</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select.join-2823"><a href="#Select.join-2823"><span class="linenos">2823</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select.join-2824"><a href="#Select.join-2824"><span class="linenos">2824</span></a> -</span><span id="Select.join-2825"><a href="#Select.join-2825"><span class="linenos">2825</span></a><span class="sd"> Returns:</span> -</span><span id="Select.join-2826"><a href="#Select.join-2826"><span class="linenos">2826</span></a><span class="sd"> Select: the modified expression.</span> -</span><span id="Select.join-2827"><a href="#Select.join-2827"><span class="linenos">2827</span></a><span class="sd"> """</span> -</span><span id="Select.join-2828"><a href="#Select.join-2828"><span class="linenos">2828</span></a> <span class="n">parse_args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"dialect"</span><span class="p">:</span> <span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">}</span> -</span><span id="Select.join-2829"><a href="#Select.join-2829"><span class="linenos">2829</span></a> -</span><span id="Select.join-2830"><a href="#Select.join-2830"><span class="linenos">2830</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="Select.join-2831"><a href="#Select.join-2831"><span class="linenos">2831</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Join</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"JOIN"</span><span class="p">,</span> <span class="o">**</span><span class="n">parse_args</span><span class="p">)</span> -</span><span id="Select.join-2832"><a href="#Select.join-2832"><span class="linenos">2832</span></a> <span class="k">except</span> <span class="n">ParseError</span><span class="p">:</span> -</span><span id="Select.join-2833"><a href="#Select.join-2833"><span class="linenos">2833</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="p">(</span><span class="n">Join</span><span class="p">,</span> <span class="n">Expression</span><span class="p">),</span> <span class="o">**</span><span class="n">parse_args</span><span class="p">)</span> -</span><span id="Select.join-2834"><a href="#Select.join-2834"><span class="linenos">2834</span></a> -</span><span id="Select.join-2835"><a href="#Select.join-2835"><span class="linenos">2835</span></a> <span class="n">join</span> <span class="o">=</span> <span class="n">expression</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Join</span><span class="p">)</span> <span class="k">else</span> <span class="n">Join</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Select.join-2817"><a href="#Select.join-2817"><span class="linenos">2817</span></a><span class="sd"> using: optionally specify the join "using" criteria as a SQL string.</span> +</span><span id="Select.join-2818"><a href="#Select.join-2818"><span class="linenos">2818</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="Select.join-2819"><a href="#Select.join-2819"><span class="linenos">2819</span></a><span class="sd"> append: if `True`, add to any existing expressions.</span> +</span><span id="Select.join-2820"><a href="#Select.join-2820"><span class="linenos">2820</span></a><span class="sd"> Otherwise, this resets the expressions.</span> +</span><span id="Select.join-2821"><a href="#Select.join-2821"><span class="linenos">2821</span></a><span class="sd"> join_type: if set, alter the parsed join type.</span> +</span><span id="Select.join-2822"><a href="#Select.join-2822"><span class="linenos">2822</span></a><span class="sd"> join_alias: an optional alias for the joined source.</span> +</span><span id="Select.join-2823"><a href="#Select.join-2823"><span class="linenos">2823</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="Select.join-2824"><a href="#Select.join-2824"><span class="linenos">2824</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select.join-2825"><a href="#Select.join-2825"><span class="linenos">2825</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select.join-2826"><a href="#Select.join-2826"><span class="linenos">2826</span></a> +</span><span id="Select.join-2827"><a href="#Select.join-2827"><span class="linenos">2827</span></a><span class="sd"> Returns:</span> +</span><span id="Select.join-2828"><a href="#Select.join-2828"><span class="linenos">2828</span></a><span class="sd"> Select: the modified expression.</span> +</span><span id="Select.join-2829"><a href="#Select.join-2829"><span class="linenos">2829</span></a><span class="sd"> """</span> +</span><span id="Select.join-2830"><a href="#Select.join-2830"><span class="linenos">2830</span></a> <span class="n">parse_args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"dialect"</span><span class="p">:</span> <span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">}</span> +</span><span id="Select.join-2831"><a href="#Select.join-2831"><span class="linenos">2831</span></a> +</span><span id="Select.join-2832"><a href="#Select.join-2832"><span class="linenos">2832</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="Select.join-2833"><a href="#Select.join-2833"><span class="linenos">2833</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Join</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"JOIN"</span><span class="p">,</span> <span class="o">**</span><span class="n">parse_args</span><span class="p">)</span> +</span><span id="Select.join-2834"><a href="#Select.join-2834"><span class="linenos">2834</span></a> <span class="k">except</span> <span class="n">ParseError</span><span class="p">:</span> +</span><span id="Select.join-2835"><a href="#Select.join-2835"><span class="linenos">2835</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="p">(</span><span class="n">Join</span><span class="p">,</span> <span class="n">Expression</span><span class="p">),</span> <span class="o">**</span><span class="n">parse_args</span><span class="p">)</span> </span><span id="Select.join-2836"><a href="#Select.join-2836"><span class="linenos">2836</span></a> -</span><span id="Select.join-2837"><a href="#Select.join-2837"><span class="linenos">2837</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">Select</span><span class="p">):</span> -</span><span id="Select.join-2838"><a href="#Select.join-2838"><span class="linenos">2838</span></a> <span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">subquery</span><span class="p">())</span> -</span><span id="Select.join-2839"><a href="#Select.join-2839"><span class="linenos">2839</span></a> -</span><span id="Select.join-2840"><a href="#Select.join-2840"><span class="linenos">2840</span></a> <span class="k">if</span> <span class="n">join_type</span><span class="p">:</span> -</span><span id="Select.join-2841"><a href="#Select.join-2841"><span class="linenos">2841</span></a> <span class="n">method</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">Token</span><span class="p">]</span> -</span><span id="Select.join-2842"><a href="#Select.join-2842"><span class="linenos">2842</span></a> <span class="n">side</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">Token</span><span class="p">]</span> -</span><span id="Select.join-2843"><a href="#Select.join-2843"><span class="linenos">2843</span></a> <span class="n">kind</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">Token</span><span class="p">]</span> -</span><span id="Select.join-2844"><a href="#Select.join-2844"><span class="linenos">2844</span></a> -</span><span id="Select.join-2845"><a href="#Select.join-2845"><span class="linenos">2845</span></a> <span class="n">method</span><span class="p">,</span> <span class="n">side</span><span class="p">,</span> <span class="n">kind</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">join_type</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="s2">"JOIN_TYPE"</span><span class="p">,</span> <span class="o">**</span><span class="n">parse_args</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="Select.join-2837"><a href="#Select.join-2837"><span class="linenos">2837</span></a> <span class="n">join</span> <span class="o">=</span> <span class="n">expression</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Join</span><span class="p">)</span> <span class="k">else</span> <span class="n">Join</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Select.join-2838"><a href="#Select.join-2838"><span class="linenos">2838</span></a> +</span><span id="Select.join-2839"><a href="#Select.join-2839"><span class="linenos">2839</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">Select</span><span class="p">):</span> +</span><span id="Select.join-2840"><a href="#Select.join-2840"><span class="linenos">2840</span></a> <span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">subquery</span><span class="p">())</span> +</span><span id="Select.join-2841"><a href="#Select.join-2841"><span class="linenos">2841</span></a> +</span><span id="Select.join-2842"><a href="#Select.join-2842"><span class="linenos">2842</span></a> <span class="k">if</span> <span class="n">join_type</span><span class="p">:</span> +</span><span id="Select.join-2843"><a href="#Select.join-2843"><span class="linenos">2843</span></a> <span class="n">method</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">Token</span><span class="p">]</span> +</span><span id="Select.join-2844"><a href="#Select.join-2844"><span class="linenos">2844</span></a> <span class="n">side</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">Token</span><span class="p">]</span> +</span><span id="Select.join-2845"><a href="#Select.join-2845"><span class="linenos">2845</span></a> <span class="n">kind</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">Token</span><span class="p">]</span> </span><span id="Select.join-2846"><a href="#Select.join-2846"><span class="linenos">2846</span></a> -</span><span id="Select.join-2847"><a href="#Select.join-2847"><span class="linenos">2847</span></a> <span class="k">if</span> <span class="n">method</span><span class="p">:</span> -</span><span id="Select.join-2848"><a href="#Select.join-2848"><span class="linenos">2848</span></a> <span class="n">join</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">method</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> -</span><span id="Select.join-2849"><a href="#Select.join-2849"><span class="linenos">2849</span></a> <span class="k">if</span> <span class="n">side</span><span class="p">:</span> -</span><span id="Select.join-2850"><a href="#Select.join-2850"><span class="linenos">2850</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"side"</span><span class="p">,</span> <span class="n">side</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> -</span><span id="Select.join-2851"><a href="#Select.join-2851"><span class="linenos">2851</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="Select.join-2852"><a href="#Select.join-2852"><span class="linenos">2852</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="n">kind</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> -</span><span id="Select.join-2853"><a href="#Select.join-2853"><span class="linenos">2853</span></a> -</span><span id="Select.join-2854"><a href="#Select.join-2854"><span class="linenos">2854</span></a> <span class="k">if</span> <span class="n">on</span><span class="p">:</span> -</span><span id="Select.join-2855"><a href="#Select.join-2855"><span class="linenos">2855</span></a> <span class="n">on</span> <span class="o">=</span> <span class="n">and_</span><span class="p">(</span><span class="o">*</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">on</span><span class="p">),</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="Select.join-2856"><a href="#Select.join-2856"><span class="linenos">2856</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"on"</span><span class="p">,</span> <span class="n">on</span><span class="p">)</span> -</span><span id="Select.join-2857"><a href="#Select.join-2857"><span class="linenos">2857</span></a> -</span><span id="Select.join-2858"><a href="#Select.join-2858"><span class="linenos">2858</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> -</span><span id="Select.join-2859"><a href="#Select.join-2859"><span class="linenos">2859</span></a> <span class="n">join</span> <span class="o">=</span> <span class="n">_apply_list_builder</span><span class="p">(</span> -</span><span id="Select.join-2860"><a href="#Select.join-2860"><span class="linenos">2860</span></a> <span class="o">*</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">using</span><span class="p">),</span> -</span><span id="Select.join-2861"><a href="#Select.join-2861"><span class="linenos">2861</span></a> <span class="n">instance</span><span class="o">=</span><span class="n">join</span><span class="p">,</span> -</span><span id="Select.join-2862"><a href="#Select.join-2862"><span class="linenos">2862</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"using"</span><span class="p">,</span> -</span><span id="Select.join-2863"><a href="#Select.join-2863"><span class="linenos">2863</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select.join-2864"><a href="#Select.join-2864"><span class="linenos">2864</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select.join-2865"><a href="#Select.join-2865"><span class="linenos">2865</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.join-2866"><a href="#Select.join-2866"><span class="linenos">2866</span></a> <span class="p">)</span> -</span><span id="Select.join-2867"><a href="#Select.join-2867"><span class="linenos">2867</span></a> -</span><span id="Select.join-2868"><a href="#Select.join-2868"><span class="linenos">2868</span></a> <span class="k">if</span> <span class="n">join_alias</span><span class="p">:</span> -</span><span id="Select.join-2869"><a href="#Select.join-2869"><span class="linenos">2869</span></a> <span class="n">join</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">alias_</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">join_alias</span><span class="p">,</span> <span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> -</span><span id="Select.join-2870"><a href="#Select.join-2870"><span class="linenos">2870</span></a> -</span><span id="Select.join-2871"><a href="#Select.join-2871"><span class="linenos">2871</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> -</span><span id="Select.join-2872"><a href="#Select.join-2872"><span class="linenos">2872</span></a> <span class="n">join</span><span class="p">,</span> -</span><span id="Select.join-2873"><a href="#Select.join-2873"><span class="linenos">2873</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select.join-2874"><a href="#Select.join-2874"><span class="linenos">2874</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"joins"</span><span class="p">,</span> -</span><span id="Select.join-2875"><a href="#Select.join-2875"><span class="linenos">2875</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select.join-2876"><a href="#Select.join-2876"><span class="linenos">2876</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select.join-2877"><a href="#Select.join-2877"><span class="linenos">2877</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.join-2878"><a href="#Select.join-2878"><span class="linenos">2878</span></a> <span class="p">)</span> +</span><span id="Select.join-2847"><a href="#Select.join-2847"><span class="linenos">2847</span></a> <span class="n">method</span><span class="p">,</span> <span class="n">side</span><span class="p">,</span> <span class="n">kind</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">join_type</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="s2">"JOIN_TYPE"</span><span class="p">,</span> <span class="o">**</span><span class="n">parse_args</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="Select.join-2848"><a href="#Select.join-2848"><span class="linenos">2848</span></a> +</span><span id="Select.join-2849"><a href="#Select.join-2849"><span class="linenos">2849</span></a> <span class="k">if</span> <span class="n">method</span><span class="p">:</span> +</span><span id="Select.join-2850"><a href="#Select.join-2850"><span class="linenos">2850</span></a> <span class="n">join</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">method</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> +</span><span id="Select.join-2851"><a href="#Select.join-2851"><span class="linenos">2851</span></a> <span class="k">if</span> <span class="n">side</span><span class="p">:</span> +</span><span id="Select.join-2852"><a href="#Select.join-2852"><span class="linenos">2852</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"side"</span><span class="p">,</span> <span class="n">side</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> +</span><span id="Select.join-2853"><a href="#Select.join-2853"><span class="linenos">2853</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="Select.join-2854"><a href="#Select.join-2854"><span class="linenos">2854</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="n">kind</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> +</span><span id="Select.join-2855"><a href="#Select.join-2855"><span class="linenos">2855</span></a> +</span><span id="Select.join-2856"><a href="#Select.join-2856"><span class="linenos">2856</span></a> <span class="k">if</span> <span class="n">on</span><span class="p">:</span> +</span><span id="Select.join-2857"><a href="#Select.join-2857"><span class="linenos">2857</span></a> <span class="n">on</span> <span class="o">=</span> <span class="n">and_</span><span class="p">(</span><span class="o">*</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">on</span><span class="p">),</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="Select.join-2858"><a href="#Select.join-2858"><span class="linenos">2858</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"on"</span><span class="p">,</span> <span class="n">on</span><span class="p">)</span> +</span><span id="Select.join-2859"><a href="#Select.join-2859"><span class="linenos">2859</span></a> +</span><span id="Select.join-2860"><a href="#Select.join-2860"><span class="linenos">2860</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> +</span><span id="Select.join-2861"><a href="#Select.join-2861"><span class="linenos">2861</span></a> <span class="n">join</span> <span class="o">=</span> <span class="n">_apply_list_builder</span><span class="p">(</span> +</span><span id="Select.join-2862"><a href="#Select.join-2862"><span class="linenos">2862</span></a> <span class="o">*</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">using</span><span class="p">),</span> +</span><span id="Select.join-2863"><a href="#Select.join-2863"><span class="linenos">2863</span></a> <span class="n">instance</span><span class="o">=</span><span class="n">join</span><span class="p">,</span> +</span><span id="Select.join-2864"><a href="#Select.join-2864"><span class="linenos">2864</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"using"</span><span class="p">,</span> +</span><span id="Select.join-2865"><a href="#Select.join-2865"><span class="linenos">2865</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select.join-2866"><a href="#Select.join-2866"><span class="linenos">2866</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select.join-2867"><a href="#Select.join-2867"><span class="linenos">2867</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.join-2868"><a href="#Select.join-2868"><span class="linenos">2868</span></a> <span class="p">)</span> +</span><span id="Select.join-2869"><a href="#Select.join-2869"><span class="linenos">2869</span></a> +</span><span id="Select.join-2870"><a href="#Select.join-2870"><span class="linenos">2870</span></a> <span class="k">if</span> <span class="n">join_alias</span><span class="p">:</span> +</span><span id="Select.join-2871"><a href="#Select.join-2871"><span class="linenos">2871</span></a> <span class="n">join</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">alias_</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">join_alias</span><span class="p">,</span> <span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="Select.join-2872"><a href="#Select.join-2872"><span class="linenos">2872</span></a> +</span><span id="Select.join-2873"><a href="#Select.join-2873"><span class="linenos">2873</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> +</span><span id="Select.join-2874"><a href="#Select.join-2874"><span class="linenos">2874</span></a> <span class="n">join</span><span class="p">,</span> +</span><span id="Select.join-2875"><a href="#Select.join-2875"><span class="linenos">2875</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select.join-2876"><a href="#Select.join-2876"><span class="linenos">2876</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"joins"</span><span class="p">,</span> +</span><span id="Select.join-2877"><a href="#Select.join-2877"><span class="linenos">2877</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select.join-2878"><a href="#Select.join-2878"><span class="linenos">2878</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select.join-2879"><a href="#Select.join-2879"><span class="linenos">2879</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.join-2880"><a href="#Select.join-2880"><span class="linenos">2880</span></a> <span class="p">)</span> </span></pre></div> @@ -26042,44 +26121,44 @@ Otherwise, this resets the expressions.</li> </div> <a class="headerlink" href="#Select.where"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Select.where-2880"><a href="#Select.where-2880"><span class="linenos">2880</span></a> <span class="k">def</span> <span class="nf">where</span><span class="p">(</span> -</span><span id="Select.where-2881"><a href="#Select.where-2881"><span class="linenos">2881</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select.where-2882"><a href="#Select.where-2882"><span class="linenos">2882</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select.where-2883"><a href="#Select.where-2883"><span class="linenos">2883</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.where-2884"><a href="#Select.where-2884"><span class="linenos">2884</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select.where-2885"><a href="#Select.where-2885"><span class="linenos">2885</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.where-2886"><a href="#Select.where-2886"><span class="linenos">2886</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.where-2887"><a href="#Select.where-2887"><span class="linenos">2887</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select.where-2888"><a href="#Select.where-2888"><span class="linenos">2888</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select.where-2889"><a href="#Select.where-2889"><span class="linenos">2889</span></a><span class="sd"> Append to or set the WHERE expressions.</span> -</span><span id="Select.where-2890"><a href="#Select.where-2890"><span class="linenos">2890</span></a> -</span><span id="Select.where-2891"><a href="#Select.where-2891"><span class="linenos">2891</span></a><span class="sd"> Example:</span> -</span><span id="Select.where-2892"><a href="#Select.where-2892"><span class="linenos">2892</span></a><span class="sd"> >>> Select().select("x").from_("tbl").where("x = 'a' OR x < 'b'").sql()</span> -</span><span id="Select.where-2893"><a href="#Select.where-2893"><span class="linenos">2893</span></a><span class="sd"> "SELECT x FROM tbl WHERE x = 'a' OR x < 'b'"</span> -</span><span id="Select.where-2894"><a href="#Select.where-2894"><span class="linenos">2894</span></a> -</span><span id="Select.where-2895"><a href="#Select.where-2895"><span class="linenos">2895</span></a><span class="sd"> Args:</span> -</span><span id="Select.where-2896"><a href="#Select.where-2896"><span class="linenos">2896</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="Select.where-2897"><a href="#Select.where-2897"><span class="linenos">2897</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Select.where-2898"><a href="#Select.where-2898"><span class="linenos">2898</span></a><span class="sd"> Multiple expressions are combined with an AND operator.</span> -</span><span id="Select.where-2899"><a href="#Select.where-2899"><span class="linenos">2899</span></a><span class="sd"> append: if `True`, AND the new expressions to any existing expression.</span> -</span><span id="Select.where-2900"><a href="#Select.where-2900"><span class="linenos">2900</span></a><span class="sd"> Otherwise, this resets the expression.</span> -</span><span id="Select.where-2901"><a href="#Select.where-2901"><span class="linenos">2901</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="Select.where-2902"><a href="#Select.where-2902"><span class="linenos">2902</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select.where-2903"><a href="#Select.where-2903"><span class="linenos">2903</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select.where-2904"><a href="#Select.where-2904"><span class="linenos">2904</span></a> -</span><span id="Select.where-2905"><a href="#Select.where-2905"><span class="linenos">2905</span></a><span class="sd"> Returns:</span> -</span><span id="Select.where-2906"><a href="#Select.where-2906"><span class="linenos">2906</span></a><span class="sd"> Select: the modified expression.</span> -</span><span id="Select.where-2907"><a href="#Select.where-2907"><span class="linenos">2907</span></a><span class="sd"> """</span> -</span><span id="Select.where-2908"><a href="#Select.where-2908"><span class="linenos">2908</span></a> <span class="k">return</span> <span class="n">_apply_conjunction_builder</span><span class="p">(</span> -</span><span id="Select.where-2909"><a href="#Select.where-2909"><span class="linenos">2909</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select.where-2910"><a href="#Select.where-2910"><span class="linenos">2910</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select.where-2911"><a href="#Select.where-2911"><span class="linenos">2911</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"where"</span><span class="p">,</span> -</span><span id="Select.where-2912"><a href="#Select.where-2912"><span class="linenos">2912</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select.where-2913"><a href="#Select.where-2913"><span class="linenos">2913</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Where</span><span class="p">,</span> -</span><span id="Select.where-2914"><a href="#Select.where-2914"><span class="linenos">2914</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select.where-2915"><a href="#Select.where-2915"><span class="linenos">2915</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select.where-2916"><a href="#Select.where-2916"><span class="linenos">2916</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.where-2917"><a href="#Select.where-2917"><span class="linenos">2917</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Select.where-2882"><a href="#Select.where-2882"><span class="linenos">2882</span></a> <span class="k">def</span> <span class="nf">where</span><span class="p">(</span> +</span><span id="Select.where-2883"><a href="#Select.where-2883"><span class="linenos">2883</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select.where-2884"><a href="#Select.where-2884"><span class="linenos">2884</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select.where-2885"><a href="#Select.where-2885"><span class="linenos">2885</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.where-2886"><a href="#Select.where-2886"><span class="linenos">2886</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select.where-2887"><a href="#Select.where-2887"><span class="linenos">2887</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.where-2888"><a href="#Select.where-2888"><span class="linenos">2888</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.where-2889"><a href="#Select.where-2889"><span class="linenos">2889</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select.where-2890"><a href="#Select.where-2890"><span class="linenos">2890</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select.where-2891"><a href="#Select.where-2891"><span class="linenos">2891</span></a><span class="sd"> Append to or set the WHERE expressions.</span> +</span><span id="Select.where-2892"><a href="#Select.where-2892"><span class="linenos">2892</span></a> +</span><span id="Select.where-2893"><a href="#Select.where-2893"><span class="linenos">2893</span></a><span class="sd"> Example:</span> +</span><span id="Select.where-2894"><a href="#Select.where-2894"><span class="linenos">2894</span></a><span class="sd"> >>> Select().select("x").from_("tbl").where("x = 'a' OR x < 'b'").sql()</span> +</span><span id="Select.where-2895"><a href="#Select.where-2895"><span class="linenos">2895</span></a><span class="sd"> "SELECT x FROM tbl WHERE x = 'a' OR x < 'b'"</span> +</span><span id="Select.where-2896"><a href="#Select.where-2896"><span class="linenos">2896</span></a> +</span><span id="Select.where-2897"><a href="#Select.where-2897"><span class="linenos">2897</span></a><span class="sd"> Args:</span> +</span><span id="Select.where-2898"><a href="#Select.where-2898"><span class="linenos">2898</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="Select.where-2899"><a href="#Select.where-2899"><span class="linenos">2899</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="Select.where-2900"><a href="#Select.where-2900"><span class="linenos">2900</span></a><span class="sd"> Multiple expressions are combined with an AND operator.</span> +</span><span id="Select.where-2901"><a href="#Select.where-2901"><span class="linenos">2901</span></a><span class="sd"> append: if `True`, AND the new expressions to any existing expression.</span> +</span><span id="Select.where-2902"><a href="#Select.where-2902"><span class="linenos">2902</span></a><span class="sd"> Otherwise, this resets the expression.</span> +</span><span id="Select.where-2903"><a href="#Select.where-2903"><span class="linenos">2903</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="Select.where-2904"><a href="#Select.where-2904"><span class="linenos">2904</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select.where-2905"><a href="#Select.where-2905"><span class="linenos">2905</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select.where-2906"><a href="#Select.where-2906"><span class="linenos">2906</span></a> +</span><span id="Select.where-2907"><a href="#Select.where-2907"><span class="linenos">2907</span></a><span class="sd"> Returns:</span> +</span><span id="Select.where-2908"><a href="#Select.where-2908"><span class="linenos">2908</span></a><span class="sd"> Select: the modified expression.</span> +</span><span id="Select.where-2909"><a href="#Select.where-2909"><span class="linenos">2909</span></a><span class="sd"> """</span> +</span><span id="Select.where-2910"><a href="#Select.where-2910"><span class="linenos">2910</span></a> <span class="k">return</span> <span class="n">_apply_conjunction_builder</span><span class="p">(</span> +</span><span id="Select.where-2911"><a href="#Select.where-2911"><span class="linenos">2911</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select.where-2912"><a href="#Select.where-2912"><span class="linenos">2912</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select.where-2913"><a href="#Select.where-2913"><span class="linenos">2913</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"where"</span><span class="p">,</span> +</span><span id="Select.where-2914"><a href="#Select.where-2914"><span class="linenos">2914</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select.where-2915"><a href="#Select.where-2915"><span class="linenos">2915</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Where</span><span class="p">,</span> +</span><span id="Select.where-2916"><a href="#Select.where-2916"><span class="linenos">2916</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select.where-2917"><a href="#Select.where-2917"><span class="linenos">2917</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select.where-2918"><a href="#Select.where-2918"><span class="linenos">2918</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.where-2919"><a href="#Select.where-2919"><span class="linenos">2919</span></a> <span class="p">)</span> </span></pre></div> @@ -26128,44 +26207,44 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#Select.having"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Select.having-2919"><a href="#Select.having-2919"><span class="linenos">2919</span></a> <span class="k">def</span> <span class="nf">having</span><span class="p">(</span> -</span><span id="Select.having-2920"><a href="#Select.having-2920"><span class="linenos">2920</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select.having-2921"><a href="#Select.having-2921"><span class="linenos">2921</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select.having-2922"><a href="#Select.having-2922"><span class="linenos">2922</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.having-2923"><a href="#Select.having-2923"><span class="linenos">2923</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select.having-2924"><a href="#Select.having-2924"><span class="linenos">2924</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.having-2925"><a href="#Select.having-2925"><span class="linenos">2925</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.having-2926"><a href="#Select.having-2926"><span class="linenos">2926</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select.having-2927"><a href="#Select.having-2927"><span class="linenos">2927</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select.having-2928"><a href="#Select.having-2928"><span class="linenos">2928</span></a><span class="sd"> Append to or set the HAVING expressions.</span> -</span><span id="Select.having-2929"><a href="#Select.having-2929"><span class="linenos">2929</span></a> -</span><span id="Select.having-2930"><a href="#Select.having-2930"><span class="linenos">2930</span></a><span class="sd"> Example:</span> -</span><span id="Select.having-2931"><a href="#Select.having-2931"><span class="linenos">2931</span></a><span class="sd"> >>> Select().select("x", "COUNT(y)").from_("tbl").group_by("x").having("COUNT(y) > 3").sql()</span> -</span><span id="Select.having-2932"><a href="#Select.having-2932"><span class="linenos">2932</span></a><span class="sd"> 'SELECT x, COUNT(y) FROM tbl GROUP BY x HAVING COUNT(y) > 3'</span> -</span><span id="Select.having-2933"><a href="#Select.having-2933"><span class="linenos">2933</span></a> -</span><span id="Select.having-2934"><a href="#Select.having-2934"><span class="linenos">2934</span></a><span class="sd"> Args:</span> -</span><span id="Select.having-2935"><a href="#Select.having-2935"><span class="linenos">2935</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="Select.having-2936"><a href="#Select.having-2936"><span class="linenos">2936</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Select.having-2937"><a href="#Select.having-2937"><span class="linenos">2937</span></a><span class="sd"> Multiple expressions are combined with an AND operator.</span> -</span><span id="Select.having-2938"><a href="#Select.having-2938"><span class="linenos">2938</span></a><span class="sd"> append: if `True`, AND the new expressions to any existing expression.</span> -</span><span id="Select.having-2939"><a href="#Select.having-2939"><span class="linenos">2939</span></a><span class="sd"> Otherwise, this resets the expression.</span> -</span><span id="Select.having-2940"><a href="#Select.having-2940"><span class="linenos">2940</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="Select.having-2941"><a href="#Select.having-2941"><span class="linenos">2941</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select.having-2942"><a href="#Select.having-2942"><span class="linenos">2942</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="Select.having-2943"><a href="#Select.having-2943"><span class="linenos">2943</span></a> -</span><span id="Select.having-2944"><a href="#Select.having-2944"><span class="linenos">2944</span></a><span class="sd"> Returns:</span> -</span><span id="Select.having-2945"><a href="#Select.having-2945"><span class="linenos">2945</span></a><span class="sd"> The modified Select expression.</span> -</span><span id="Select.having-2946"><a href="#Select.having-2946"><span class="linenos">2946</span></a><span class="sd"> """</span> -</span><span id="Select.having-2947"><a href="#Select.having-2947"><span class="linenos">2947</span></a> <span class="k">return</span> <span class="n">_apply_conjunction_builder</span><span class="p">(</span> -</span><span id="Select.having-2948"><a href="#Select.having-2948"><span class="linenos">2948</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select.having-2949"><a href="#Select.having-2949"><span class="linenos">2949</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select.having-2950"><a href="#Select.having-2950"><span class="linenos">2950</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"having"</span><span class="p">,</span> -</span><span id="Select.having-2951"><a href="#Select.having-2951"><span class="linenos">2951</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select.having-2952"><a href="#Select.having-2952"><span class="linenos">2952</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Having</span><span class="p">,</span> -</span><span id="Select.having-2953"><a href="#Select.having-2953"><span class="linenos">2953</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select.having-2954"><a href="#Select.having-2954"><span class="linenos">2954</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select.having-2955"><a href="#Select.having-2955"><span class="linenos">2955</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.having-2956"><a href="#Select.having-2956"><span class="linenos">2956</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Select.having-2921"><a href="#Select.having-2921"><span class="linenos">2921</span></a> <span class="k">def</span> <span class="nf">having</span><span class="p">(</span> +</span><span id="Select.having-2922"><a href="#Select.having-2922"><span class="linenos">2922</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select.having-2923"><a href="#Select.having-2923"><span class="linenos">2923</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select.having-2924"><a href="#Select.having-2924"><span class="linenos">2924</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.having-2925"><a href="#Select.having-2925"><span class="linenos">2925</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select.having-2926"><a href="#Select.having-2926"><span class="linenos">2926</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.having-2927"><a href="#Select.having-2927"><span class="linenos">2927</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.having-2928"><a href="#Select.having-2928"><span class="linenos">2928</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select.having-2929"><a href="#Select.having-2929"><span class="linenos">2929</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select.having-2930"><a href="#Select.having-2930"><span class="linenos">2930</span></a><span class="sd"> Append to or set the HAVING expressions.</span> +</span><span id="Select.having-2931"><a href="#Select.having-2931"><span class="linenos">2931</span></a> +</span><span id="Select.having-2932"><a href="#Select.having-2932"><span class="linenos">2932</span></a><span class="sd"> Example:</span> +</span><span id="Select.having-2933"><a href="#Select.having-2933"><span class="linenos">2933</span></a><span class="sd"> >>> Select().select("x", "COUNT(y)").from_("tbl").group_by("x").having("COUNT(y) > 3").sql()</span> +</span><span id="Select.having-2934"><a href="#Select.having-2934"><span class="linenos">2934</span></a><span class="sd"> 'SELECT x, COUNT(y) FROM tbl GROUP BY x HAVING COUNT(y) > 3'</span> +</span><span id="Select.having-2935"><a href="#Select.having-2935"><span class="linenos">2935</span></a> +</span><span id="Select.having-2936"><a href="#Select.having-2936"><span class="linenos">2936</span></a><span class="sd"> Args:</span> +</span><span id="Select.having-2937"><a href="#Select.having-2937"><span class="linenos">2937</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="Select.having-2938"><a href="#Select.having-2938"><span class="linenos">2938</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="Select.having-2939"><a href="#Select.having-2939"><span class="linenos">2939</span></a><span class="sd"> Multiple expressions are combined with an AND operator.</span> +</span><span id="Select.having-2940"><a href="#Select.having-2940"><span class="linenos">2940</span></a><span class="sd"> append: if `True`, AND the new expressions to any existing expression.</span> +</span><span id="Select.having-2941"><a href="#Select.having-2941"><span class="linenos">2941</span></a><span class="sd"> Otherwise, this resets the expression.</span> +</span><span id="Select.having-2942"><a href="#Select.having-2942"><span class="linenos">2942</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="Select.having-2943"><a href="#Select.having-2943"><span class="linenos">2943</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select.having-2944"><a href="#Select.having-2944"><span class="linenos">2944</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="Select.having-2945"><a href="#Select.having-2945"><span class="linenos">2945</span></a> +</span><span id="Select.having-2946"><a href="#Select.having-2946"><span class="linenos">2946</span></a><span class="sd"> Returns:</span> +</span><span id="Select.having-2947"><a href="#Select.having-2947"><span class="linenos">2947</span></a><span class="sd"> The modified Select expression.</span> +</span><span id="Select.having-2948"><a href="#Select.having-2948"><span class="linenos">2948</span></a><span class="sd"> """</span> +</span><span id="Select.having-2949"><a href="#Select.having-2949"><span class="linenos">2949</span></a> <span class="k">return</span> <span class="n">_apply_conjunction_builder</span><span class="p">(</span> +</span><span id="Select.having-2950"><a href="#Select.having-2950"><span class="linenos">2950</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select.having-2951"><a href="#Select.having-2951"><span class="linenos">2951</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select.having-2952"><a href="#Select.having-2952"><span class="linenos">2952</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"having"</span><span class="p">,</span> +</span><span id="Select.having-2953"><a href="#Select.having-2953"><span class="linenos">2953</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select.having-2954"><a href="#Select.having-2954"><span class="linenos">2954</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Having</span><span class="p">,</span> +</span><span id="Select.having-2955"><a href="#Select.having-2955"><span class="linenos">2955</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select.having-2956"><a href="#Select.having-2956"><span class="linenos">2956</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select.having-2957"><a href="#Select.having-2957"><span class="linenos">2957</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.having-2958"><a href="#Select.having-2958"><span class="linenos">2958</span></a> <span class="p">)</span> </span></pre></div> @@ -26214,24 +26293,24 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#Select.window"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Select.window-2958"><a href="#Select.window-2958"><span class="linenos">2958</span></a> <span class="k">def</span> <span class="nf">window</span><span class="p">(</span> -</span><span id="Select.window-2959"><a href="#Select.window-2959"><span class="linenos">2959</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select.window-2960"><a href="#Select.window-2960"><span class="linenos">2960</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select.window-2961"><a href="#Select.window-2961"><span class="linenos">2961</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.window-2962"><a href="#Select.window-2962"><span class="linenos">2962</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select.window-2963"><a href="#Select.window-2963"><span class="linenos">2963</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.window-2964"><a href="#Select.window-2964"><span class="linenos">2964</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.window-2965"><a href="#Select.window-2965"><span class="linenos">2965</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select.window-2966"><a href="#Select.window-2966"><span class="linenos">2966</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> -</span><span id="Select.window-2967"><a href="#Select.window-2967"><span class="linenos">2967</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select.window-2968"><a href="#Select.window-2968"><span class="linenos">2968</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select.window-2969"><a href="#Select.window-2969"><span class="linenos">2969</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"windows"</span><span class="p">,</span> -</span><span id="Select.window-2970"><a href="#Select.window-2970"><span class="linenos">2970</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select.window-2971"><a href="#Select.window-2971"><span class="linenos">2971</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Window</span><span class="p">,</span> -</span><span id="Select.window-2972"><a href="#Select.window-2972"><span class="linenos">2972</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select.window-2973"><a href="#Select.window-2973"><span class="linenos">2973</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select.window-2974"><a href="#Select.window-2974"><span class="linenos">2974</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.window-2975"><a href="#Select.window-2975"><span class="linenos">2975</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Select.window-2960"><a href="#Select.window-2960"><span class="linenos">2960</span></a> <span class="k">def</span> <span class="nf">window</span><span class="p">(</span> +</span><span id="Select.window-2961"><a href="#Select.window-2961"><span class="linenos">2961</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select.window-2962"><a href="#Select.window-2962"><span class="linenos">2962</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select.window-2963"><a href="#Select.window-2963"><span class="linenos">2963</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.window-2964"><a href="#Select.window-2964"><span class="linenos">2964</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select.window-2965"><a href="#Select.window-2965"><span class="linenos">2965</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.window-2966"><a href="#Select.window-2966"><span class="linenos">2966</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.window-2967"><a href="#Select.window-2967"><span class="linenos">2967</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select.window-2968"><a href="#Select.window-2968"><span class="linenos">2968</span></a> <span class="k">return</span> <span class="n">_apply_list_builder</span><span class="p">(</span> +</span><span id="Select.window-2969"><a href="#Select.window-2969"><span class="linenos">2969</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select.window-2970"><a href="#Select.window-2970"><span class="linenos">2970</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select.window-2971"><a href="#Select.window-2971"><span class="linenos">2971</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"windows"</span><span class="p">,</span> +</span><span id="Select.window-2972"><a href="#Select.window-2972"><span class="linenos">2972</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select.window-2973"><a href="#Select.window-2973"><span class="linenos">2973</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Window</span><span class="p">,</span> +</span><span id="Select.window-2974"><a href="#Select.window-2974"><span class="linenos">2974</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select.window-2975"><a href="#Select.window-2975"><span class="linenos">2975</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select.window-2976"><a href="#Select.window-2976"><span class="linenos">2976</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.window-2977"><a href="#Select.window-2977"><span class="linenos">2977</span></a> <span class="p">)</span> </span></pre></div> @@ -26249,24 +26328,24 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#Select.qualify"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Select.qualify-2977"><a href="#Select.qualify-2977"><span class="linenos">2977</span></a> <span class="k">def</span> <span class="nf">qualify</span><span class="p">(</span> -</span><span id="Select.qualify-2978"><a href="#Select.qualify-2978"><span class="linenos">2978</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select.qualify-2979"><a href="#Select.qualify-2979"><span class="linenos">2979</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> -</span><span id="Select.qualify-2980"><a href="#Select.qualify-2980"><span class="linenos">2980</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.qualify-2981"><a href="#Select.qualify-2981"><span class="linenos">2981</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select.qualify-2982"><a href="#Select.qualify-2982"><span class="linenos">2982</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.qualify-2983"><a href="#Select.qualify-2983"><span class="linenos">2983</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.qualify-2984"><a href="#Select.qualify-2984"><span class="linenos">2984</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select.qualify-2985"><a href="#Select.qualify-2985"><span class="linenos">2985</span></a> <span class="k">return</span> <span class="n">_apply_conjunction_builder</span><span class="p">(</span> -</span><span id="Select.qualify-2986"><a href="#Select.qualify-2986"><span class="linenos">2986</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Select.qualify-2987"><a href="#Select.qualify-2987"><span class="linenos">2987</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> -</span><span id="Select.qualify-2988"><a href="#Select.qualify-2988"><span class="linenos">2988</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"qualify"</span><span class="p">,</span> -</span><span id="Select.qualify-2989"><a href="#Select.qualify-2989"><span class="linenos">2989</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> -</span><span id="Select.qualify-2990"><a href="#Select.qualify-2990"><span class="linenos">2990</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Qualify</span><span class="p">,</span> -</span><span id="Select.qualify-2991"><a href="#Select.qualify-2991"><span class="linenos">2991</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select.qualify-2992"><a href="#Select.qualify-2992"><span class="linenos">2992</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="Select.qualify-2993"><a href="#Select.qualify-2993"><span class="linenos">2993</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.qualify-2994"><a href="#Select.qualify-2994"><span class="linenos">2994</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Select.qualify-2979"><a href="#Select.qualify-2979"><span class="linenos">2979</span></a> <span class="k">def</span> <span class="nf">qualify</span><span class="p">(</span> +</span><span id="Select.qualify-2980"><a href="#Select.qualify-2980"><span class="linenos">2980</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select.qualify-2981"><a href="#Select.qualify-2981"><span class="linenos">2981</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> +</span><span id="Select.qualify-2982"><a href="#Select.qualify-2982"><span class="linenos">2982</span></a> <span class="n">append</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.qualify-2983"><a href="#Select.qualify-2983"><span class="linenos">2983</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select.qualify-2984"><a href="#Select.qualify-2984"><span class="linenos">2984</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.qualify-2985"><a href="#Select.qualify-2985"><span class="linenos">2985</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.qualify-2986"><a href="#Select.qualify-2986"><span class="linenos">2986</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select.qualify-2987"><a href="#Select.qualify-2987"><span class="linenos">2987</span></a> <span class="k">return</span> <span class="n">_apply_conjunction_builder</span><span class="p">(</span> +</span><span id="Select.qualify-2988"><a href="#Select.qualify-2988"><span class="linenos">2988</span></a> <span class="o">*</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Select.qualify-2989"><a href="#Select.qualify-2989"><span class="linenos">2989</span></a> <span class="n">instance</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> +</span><span id="Select.qualify-2990"><a href="#Select.qualify-2990"><span class="linenos">2990</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"qualify"</span><span class="p">,</span> +</span><span id="Select.qualify-2991"><a href="#Select.qualify-2991"><span class="linenos">2991</span></a> <span class="n">append</span><span class="o">=</span><span class="n">append</span><span class="p">,</span> +</span><span id="Select.qualify-2992"><a href="#Select.qualify-2992"><span class="linenos">2992</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Qualify</span><span class="p">,</span> +</span><span id="Select.qualify-2993"><a href="#Select.qualify-2993"><span class="linenos">2993</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select.qualify-2994"><a href="#Select.qualify-2994"><span class="linenos">2994</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="Select.qualify-2995"><a href="#Select.qualify-2995"><span class="linenos">2995</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.qualify-2996"><a href="#Select.qualify-2996"><span class="linenos">2996</span></a> <span class="p">)</span> </span></pre></div> @@ -26284,28 +26363,28 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#Select.distinct"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Select.distinct-2996"><a href="#Select.distinct-2996"><span class="linenos">2996</span></a> <span class="k">def</span> <span class="nf">distinct</span><span class="p">(</span> -</span><span id="Select.distinct-2997"><a href="#Select.distinct-2997"><span class="linenos">2997</span></a> <span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">ons</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">ExpOrStr</span><span class="p">],</span> <span class="n">distinct</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Select.distinct-2998"><a href="#Select.distinct-2998"><span class="linenos">2998</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select.distinct-2999"><a href="#Select.distinct-2999"><span class="linenos">2999</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select.distinct-3000"><a href="#Select.distinct-3000"><span class="linenos">3000</span></a><span class="sd"> Set the OFFSET expression.</span> -</span><span id="Select.distinct-3001"><a href="#Select.distinct-3001"><span class="linenos">3001</span></a> -</span><span id="Select.distinct-3002"><a href="#Select.distinct-3002"><span class="linenos">3002</span></a><span class="sd"> Example:</span> -</span><span id="Select.distinct-3003"><a href="#Select.distinct-3003"><span class="linenos">3003</span></a><span class="sd"> >>> Select().from_("tbl").select("x").distinct().sql()</span> -</span><span id="Select.distinct-3004"><a href="#Select.distinct-3004"><span class="linenos">3004</span></a><span class="sd"> 'SELECT DISTINCT x FROM tbl'</span> -</span><span id="Select.distinct-3005"><a href="#Select.distinct-3005"><span class="linenos">3005</span></a> -</span><span id="Select.distinct-3006"><a href="#Select.distinct-3006"><span class="linenos">3006</span></a><span class="sd"> Args:</span> -</span><span id="Select.distinct-3007"><a href="#Select.distinct-3007"><span class="linenos">3007</span></a><span class="sd"> ons: the expressions to distinct on</span> -</span><span id="Select.distinct-3008"><a href="#Select.distinct-3008"><span class="linenos">3008</span></a><span class="sd"> distinct: whether the Select should be distinct</span> -</span><span id="Select.distinct-3009"><a href="#Select.distinct-3009"><span class="linenos">3009</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select.distinct-3010"><a href="#Select.distinct-3010"><span class="linenos">3010</span></a> -</span><span id="Select.distinct-3011"><a href="#Select.distinct-3011"><span class="linenos">3011</span></a><span class="sd"> Returns:</span> -</span><span id="Select.distinct-3012"><a href="#Select.distinct-3012"><span class="linenos">3012</span></a><span class="sd"> Select: the modified expression.</span> -</span><span id="Select.distinct-3013"><a href="#Select.distinct-3013"><span class="linenos">3013</span></a><span class="sd"> """</span> -</span><span id="Select.distinct-3014"><a href="#Select.distinct-3014"><span class="linenos">3014</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="Select.distinct-3015"><a href="#Select.distinct-3015"><span class="linenos">3015</span></a> <span class="n">on</span> <span class="o">=</span> <span class="n">Tuple</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">on</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">on</span> <span class="ow">in</span> <span class="n">ons</span> <span class="k">if</span> <span class="n">on</span><span class="p">])</span> <span class="k">if</span> <span class="n">ons</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="Select.distinct-3016"><a href="#Select.distinct-3016"><span class="linenos">3016</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"distinct"</span><span class="p">,</span> <span class="n">Distinct</span><span class="p">(</span><span class="n">on</span><span class="o">=</span><span class="n">on</span><span class="p">)</span> <span class="k">if</span> <span class="n">distinct</span> <span class="k">else</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="Select.distinct-3017"><a href="#Select.distinct-3017"><span class="linenos">3017</span></a> <span class="k">return</span> <span class="n">instance</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Select.distinct-2998"><a href="#Select.distinct-2998"><span class="linenos">2998</span></a> <span class="k">def</span> <span class="nf">distinct</span><span class="p">(</span> +</span><span id="Select.distinct-2999"><a href="#Select.distinct-2999"><span class="linenos">2999</span></a> <span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">ons</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">ExpOrStr</span><span class="p">],</span> <span class="n">distinct</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Select.distinct-3000"><a href="#Select.distinct-3000"><span class="linenos">3000</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select.distinct-3001"><a href="#Select.distinct-3001"><span class="linenos">3001</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select.distinct-3002"><a href="#Select.distinct-3002"><span class="linenos">3002</span></a><span class="sd"> Set the OFFSET expression.</span> +</span><span id="Select.distinct-3003"><a href="#Select.distinct-3003"><span class="linenos">3003</span></a> +</span><span id="Select.distinct-3004"><a href="#Select.distinct-3004"><span class="linenos">3004</span></a><span class="sd"> Example:</span> +</span><span id="Select.distinct-3005"><a href="#Select.distinct-3005"><span class="linenos">3005</span></a><span class="sd"> >>> Select().from_("tbl").select("x").distinct().sql()</span> +</span><span id="Select.distinct-3006"><a href="#Select.distinct-3006"><span class="linenos">3006</span></a><span class="sd"> 'SELECT DISTINCT x FROM tbl'</span> +</span><span id="Select.distinct-3007"><a href="#Select.distinct-3007"><span class="linenos">3007</span></a> +</span><span id="Select.distinct-3008"><a href="#Select.distinct-3008"><span class="linenos">3008</span></a><span class="sd"> Args:</span> +</span><span id="Select.distinct-3009"><a href="#Select.distinct-3009"><span class="linenos">3009</span></a><span class="sd"> ons: the expressions to distinct on</span> +</span><span id="Select.distinct-3010"><a href="#Select.distinct-3010"><span class="linenos">3010</span></a><span class="sd"> distinct: whether the Select should be distinct</span> +</span><span id="Select.distinct-3011"><a href="#Select.distinct-3011"><span class="linenos">3011</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select.distinct-3012"><a href="#Select.distinct-3012"><span class="linenos">3012</span></a> +</span><span id="Select.distinct-3013"><a href="#Select.distinct-3013"><span class="linenos">3013</span></a><span class="sd"> Returns:</span> +</span><span id="Select.distinct-3014"><a href="#Select.distinct-3014"><span class="linenos">3014</span></a><span class="sd"> Select: the modified expression.</span> +</span><span id="Select.distinct-3015"><a href="#Select.distinct-3015"><span class="linenos">3015</span></a><span class="sd"> """</span> +</span><span id="Select.distinct-3016"><a href="#Select.distinct-3016"><span class="linenos">3016</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="Select.distinct-3017"><a href="#Select.distinct-3017"><span class="linenos">3017</span></a> <span class="n">on</span> <span class="o">=</span> <span class="n">Tuple</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">on</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">on</span> <span class="ow">in</span> <span class="n">ons</span> <span class="k">if</span> <span class="n">on</span><span class="p">])</span> <span class="k">if</span> <span class="n">ons</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="Select.distinct-3018"><a href="#Select.distinct-3018"><span class="linenos">3018</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"distinct"</span><span class="p">,</span> <span class="n">Distinct</span><span class="p">(</span><span class="n">on</span><span class="o">=</span><span class="n">on</span><span class="p">)</span> <span class="k">if</span> <span class="n">distinct</span> <span class="k">else</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="Select.distinct-3019"><a href="#Select.distinct-3019"><span class="linenos">3019</span></a> <span class="k">return</span> <span class="n">instance</span> </span></pre></div> @@ -26349,49 +26428,49 @@ Otherwise, this resets the expression.</li> </div> <a class="headerlink" href="#Select.ctas"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Select.ctas-3019"><a href="#Select.ctas-3019"><span class="linenos">3019</span></a> <span class="k">def</span> <span class="nf">ctas</span><span class="p">(</span> -</span><span id="Select.ctas-3020"><a href="#Select.ctas-3020"><span class="linenos">3020</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Select.ctas-3021"><a href="#Select.ctas-3021"><span class="linenos">3021</span></a> <span class="n">table</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="Select.ctas-3022"><a href="#Select.ctas-3022"><span class="linenos">3022</span></a> <span class="n">properties</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select.ctas-3023"><a href="#Select.ctas-3023"><span class="linenos">3023</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Select.ctas-3024"><a href="#Select.ctas-3024"><span class="linenos">3024</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Select.ctas-3025"><a href="#Select.ctas-3025"><span class="linenos">3025</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.ctas-3026"><a href="#Select.ctas-3026"><span class="linenos">3026</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Create</span><span class="p">:</span> -</span><span id="Select.ctas-3027"><a href="#Select.ctas-3027"><span class="linenos">3027</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select.ctas-3028"><a href="#Select.ctas-3028"><span class="linenos">3028</span></a><span class="sd"> Convert this expression to a CREATE TABLE AS statement.</span> -</span><span id="Select.ctas-3029"><a href="#Select.ctas-3029"><span class="linenos">3029</span></a> -</span><span id="Select.ctas-3030"><a href="#Select.ctas-3030"><span class="linenos">3030</span></a><span class="sd"> Example:</span> -</span><span id="Select.ctas-3031"><a href="#Select.ctas-3031"><span class="linenos">3031</span></a><span class="sd"> >>> Select().select("*").from_("tbl").ctas("x").sql()</span> -</span><span id="Select.ctas-3032"><a href="#Select.ctas-3032"><span class="linenos">3032</span></a><span class="sd"> 'CREATE TABLE x AS SELECT * FROM tbl'</span> -</span><span id="Select.ctas-3033"><a href="#Select.ctas-3033"><span class="linenos">3033</span></a> -</span><span id="Select.ctas-3034"><a href="#Select.ctas-3034"><span class="linenos">3034</span></a><span class="sd"> Args:</span> -</span><span id="Select.ctas-3035"><a href="#Select.ctas-3035"><span class="linenos">3035</span></a><span class="sd"> table: the SQL code string to parse as the table name.</span> -</span><span id="Select.ctas-3036"><a href="#Select.ctas-3036"><span class="linenos">3036</span></a><span class="sd"> If another `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Select.ctas-3037"><a href="#Select.ctas-3037"><span class="linenos">3037</span></a><span class="sd"> properties: an optional mapping of table properties</span> -</span><span id="Select.ctas-3038"><a href="#Select.ctas-3038"><span class="linenos">3038</span></a><span class="sd"> dialect: the dialect used to parse the input table.</span> -</span><span id="Select.ctas-3039"><a href="#Select.ctas-3039"><span class="linenos">3039</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select.ctas-3040"><a href="#Select.ctas-3040"><span class="linenos">3040</span></a><span class="sd"> opts: other options to use to parse the input table.</span> -</span><span id="Select.ctas-3041"><a href="#Select.ctas-3041"><span class="linenos">3041</span></a> -</span><span id="Select.ctas-3042"><a href="#Select.ctas-3042"><span class="linenos">3042</span></a><span class="sd"> Returns:</span> -</span><span id="Select.ctas-3043"><a href="#Select.ctas-3043"><span class="linenos">3043</span></a><span class="sd"> The new Create expression.</span> -</span><span id="Select.ctas-3044"><a href="#Select.ctas-3044"><span class="linenos">3044</span></a><span class="sd"> """</span> -</span><span id="Select.ctas-3045"><a href="#Select.ctas-3045"><span class="linenos">3045</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="Select.ctas-3046"><a href="#Select.ctas-3046"><span class="linenos">3046</span></a> <span class="n">table_expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span> -</span><span id="Select.ctas-3047"><a href="#Select.ctas-3047"><span class="linenos">3047</span></a> <span class="n">table</span><span class="p">,</span> -</span><span id="Select.ctas-3048"><a href="#Select.ctas-3048"><span class="linenos">3048</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">,</span> -</span><span id="Select.ctas-3049"><a href="#Select.ctas-3049"><span class="linenos">3049</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="Select.ctas-3050"><a href="#Select.ctas-3050"><span class="linenos">3050</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="Select.ctas-3051"><a href="#Select.ctas-3051"><span class="linenos">3051</span></a> <span class="p">)</span> -</span><span id="Select.ctas-3052"><a href="#Select.ctas-3052"><span class="linenos">3052</span></a> <span class="n">properties_expression</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Select.ctas-3053"><a href="#Select.ctas-3053"><span class="linenos">3053</span></a> <span class="k">if</span> <span class="n">properties</span><span class="p">:</span> -</span><span id="Select.ctas-3054"><a href="#Select.ctas-3054"><span class="linenos">3054</span></a> <span class="n">properties_expression</span> <span class="o">=</span> <span class="n">Properties</span><span class="o">.</span><span class="n">from_dict</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span> -</span><span id="Select.ctas-3055"><a href="#Select.ctas-3055"><span class="linenos">3055</span></a> -</span><span id="Select.ctas-3056"><a href="#Select.ctas-3056"><span class="linenos">3056</span></a> <span class="k">return</span> <span class="n">Create</span><span class="p">(</span> -</span><span id="Select.ctas-3057"><a href="#Select.ctas-3057"><span class="linenos">3057</span></a> <span class="n">this</span><span class="o">=</span><span class="n">table_expression</span><span class="p">,</span> -</span><span id="Select.ctas-3058"><a href="#Select.ctas-3058"><span class="linenos">3058</span></a> <span class="n">kind</span><span class="o">=</span><span class="s2">"table"</span><span class="p">,</span> -</span><span id="Select.ctas-3059"><a href="#Select.ctas-3059"><span class="linenos">3059</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">instance</span><span class="p">,</span> -</span><span id="Select.ctas-3060"><a href="#Select.ctas-3060"><span class="linenos">3060</span></a> <span class="n">properties</span><span class="o">=</span><span class="n">properties_expression</span><span class="p">,</span> -</span><span id="Select.ctas-3061"><a href="#Select.ctas-3061"><span class="linenos">3061</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Select.ctas-3021"><a href="#Select.ctas-3021"><span class="linenos">3021</span></a> <span class="k">def</span> <span class="nf">ctas</span><span class="p">(</span> +</span><span id="Select.ctas-3022"><a href="#Select.ctas-3022"><span class="linenos">3022</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Select.ctas-3023"><a href="#Select.ctas-3023"><span class="linenos">3023</span></a> <span class="n">table</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="Select.ctas-3024"><a href="#Select.ctas-3024"><span class="linenos">3024</span></a> <span class="n">properties</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select.ctas-3025"><a href="#Select.ctas-3025"><span class="linenos">3025</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Select.ctas-3026"><a href="#Select.ctas-3026"><span class="linenos">3026</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Select.ctas-3027"><a href="#Select.ctas-3027"><span class="linenos">3027</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.ctas-3028"><a href="#Select.ctas-3028"><span class="linenos">3028</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">Create</span><span class="p">:</span> +</span><span id="Select.ctas-3029"><a href="#Select.ctas-3029"><span class="linenos">3029</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select.ctas-3030"><a href="#Select.ctas-3030"><span class="linenos">3030</span></a><span class="sd"> Convert this expression to a CREATE TABLE AS statement.</span> +</span><span id="Select.ctas-3031"><a href="#Select.ctas-3031"><span class="linenos">3031</span></a> +</span><span id="Select.ctas-3032"><a href="#Select.ctas-3032"><span class="linenos">3032</span></a><span class="sd"> Example:</span> +</span><span id="Select.ctas-3033"><a href="#Select.ctas-3033"><span class="linenos">3033</span></a><span class="sd"> >>> Select().select("*").from_("tbl").ctas("x").sql()</span> +</span><span id="Select.ctas-3034"><a href="#Select.ctas-3034"><span class="linenos">3034</span></a><span class="sd"> 'CREATE TABLE x AS SELECT * FROM tbl'</span> +</span><span id="Select.ctas-3035"><a href="#Select.ctas-3035"><span class="linenos">3035</span></a> +</span><span id="Select.ctas-3036"><a href="#Select.ctas-3036"><span class="linenos">3036</span></a><span class="sd"> Args:</span> +</span><span id="Select.ctas-3037"><a href="#Select.ctas-3037"><span class="linenos">3037</span></a><span class="sd"> table: the SQL code string to parse as the table name.</span> +</span><span id="Select.ctas-3038"><a href="#Select.ctas-3038"><span class="linenos">3038</span></a><span class="sd"> If another `Expression` instance is passed, it will be used as-is.</span> +</span><span id="Select.ctas-3039"><a href="#Select.ctas-3039"><span class="linenos">3039</span></a><span class="sd"> properties: an optional mapping of table properties</span> +</span><span id="Select.ctas-3040"><a href="#Select.ctas-3040"><span class="linenos">3040</span></a><span class="sd"> dialect: the dialect used to parse the input table.</span> +</span><span id="Select.ctas-3041"><a href="#Select.ctas-3041"><span class="linenos">3041</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select.ctas-3042"><a href="#Select.ctas-3042"><span class="linenos">3042</span></a><span class="sd"> opts: other options to use to parse the input table.</span> +</span><span id="Select.ctas-3043"><a href="#Select.ctas-3043"><span class="linenos">3043</span></a> +</span><span id="Select.ctas-3044"><a href="#Select.ctas-3044"><span class="linenos">3044</span></a><span class="sd"> Returns:</span> +</span><span id="Select.ctas-3045"><a href="#Select.ctas-3045"><span class="linenos">3045</span></a><span class="sd"> The new Create expression.</span> +</span><span id="Select.ctas-3046"><a href="#Select.ctas-3046"><span class="linenos">3046</span></a><span class="sd"> """</span> +</span><span id="Select.ctas-3047"><a href="#Select.ctas-3047"><span class="linenos">3047</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="Select.ctas-3048"><a href="#Select.ctas-3048"><span class="linenos">3048</span></a> <span class="n">table_expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span> +</span><span id="Select.ctas-3049"><a href="#Select.ctas-3049"><span class="linenos">3049</span></a> <span class="n">table</span><span class="p">,</span> +</span><span id="Select.ctas-3050"><a href="#Select.ctas-3050"><span class="linenos">3050</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">,</span> +</span><span id="Select.ctas-3051"><a href="#Select.ctas-3051"><span class="linenos">3051</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="Select.ctas-3052"><a href="#Select.ctas-3052"><span class="linenos">3052</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="Select.ctas-3053"><a href="#Select.ctas-3053"><span class="linenos">3053</span></a> <span class="p">)</span> +</span><span id="Select.ctas-3054"><a href="#Select.ctas-3054"><span class="linenos">3054</span></a> <span class="n">properties_expression</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Select.ctas-3055"><a href="#Select.ctas-3055"><span class="linenos">3055</span></a> <span class="k">if</span> <span class="n">properties</span><span class="p">:</span> +</span><span id="Select.ctas-3056"><a href="#Select.ctas-3056"><span class="linenos">3056</span></a> <span class="n">properties_expression</span> <span class="o">=</span> <span class="n">Properties</span><span class="o">.</span><span class="n">from_dict</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span> +</span><span id="Select.ctas-3057"><a href="#Select.ctas-3057"><span class="linenos">3057</span></a> +</span><span id="Select.ctas-3058"><a href="#Select.ctas-3058"><span class="linenos">3058</span></a> <span class="k">return</span> <span class="n">Create</span><span class="p">(</span> +</span><span id="Select.ctas-3059"><a href="#Select.ctas-3059"><span class="linenos">3059</span></a> <span class="n">this</span><span class="o">=</span><span class="n">table_expression</span><span class="p">,</span> +</span><span id="Select.ctas-3060"><a href="#Select.ctas-3060"><span class="linenos">3060</span></a> <span class="n">kind</span><span class="o">=</span><span class="s2">"table"</span><span class="p">,</span> +</span><span id="Select.ctas-3061"><a href="#Select.ctas-3061"><span class="linenos">3061</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">instance</span><span class="p">,</span> +</span><span id="Select.ctas-3062"><a href="#Select.ctas-3062"><span class="linenos">3062</span></a> <span class="n">properties</span><span class="o">=</span><span class="n">properties_expression</span><span class="p">,</span> +</span><span id="Select.ctas-3063"><a href="#Select.ctas-3063"><span class="linenos">3063</span></a> <span class="p">)</span> </span></pre></div> @@ -26438,28 +26517,28 @@ If another <code><a href="#Expression">Expression</a></code> instance is passed, </div> <a class="headerlink" href="#Select.lock"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Select.lock-3063"><a href="#Select.lock-3063"><span class="linenos">3063</span></a> <span class="k">def</span> <span class="nf">lock</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">update</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select.lock-3064"><a href="#Select.lock-3064"><span class="linenos">3064</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select.lock-3065"><a href="#Select.lock-3065"><span class="linenos">3065</span></a><span class="sd"> Set the locking read mode for this expression.</span> -</span><span id="Select.lock-3066"><a href="#Select.lock-3066"><span class="linenos">3066</span></a> -</span><span id="Select.lock-3067"><a href="#Select.lock-3067"><span class="linenos">3067</span></a><span class="sd"> Examples:</span> -</span><span id="Select.lock-3068"><a href="#Select.lock-3068"><span class="linenos">3068</span></a><span class="sd"> >>> Select().select("x").from_("tbl").where("x = 'a'").lock().sql("mysql")</span> -</span><span id="Select.lock-3069"><a href="#Select.lock-3069"><span class="linenos">3069</span></a><span class="sd"> "SELECT x FROM tbl WHERE x = 'a' FOR UPDATE"</span> -</span><span id="Select.lock-3070"><a href="#Select.lock-3070"><span class="linenos">3070</span></a> -</span><span id="Select.lock-3071"><a href="#Select.lock-3071"><span class="linenos">3071</span></a><span class="sd"> >>> Select().select("x").from_("tbl").where("x = 'a'").lock(update=False).sql("mysql")</span> -</span><span id="Select.lock-3072"><a href="#Select.lock-3072"><span class="linenos">3072</span></a><span class="sd"> "SELECT x FROM tbl WHERE x = 'a' FOR SHARE"</span> -</span><span id="Select.lock-3073"><a href="#Select.lock-3073"><span class="linenos">3073</span></a> -</span><span id="Select.lock-3074"><a href="#Select.lock-3074"><span class="linenos">3074</span></a><span class="sd"> Args:</span> -</span><span id="Select.lock-3075"><a href="#Select.lock-3075"><span class="linenos">3075</span></a><span class="sd"> update: if `True`, the locking type will be `FOR UPDATE`, else it will be `FOR SHARE`.</span> -</span><span id="Select.lock-3076"><a href="#Select.lock-3076"><span class="linenos">3076</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> -</span><span id="Select.lock-3077"><a href="#Select.lock-3077"><span class="linenos">3077</span></a> -</span><span id="Select.lock-3078"><a href="#Select.lock-3078"><span class="linenos">3078</span></a><span class="sd"> Returns:</span> -</span><span id="Select.lock-3079"><a href="#Select.lock-3079"><span class="linenos">3079</span></a><span class="sd"> The modified expression.</span> -</span><span id="Select.lock-3080"><a href="#Select.lock-3080"><span class="linenos">3080</span></a><span class="sd"> """</span> -</span><span id="Select.lock-3081"><a href="#Select.lock-3081"><span class="linenos">3081</span></a> <span class="n">inst</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="Select.lock-3082"><a href="#Select.lock-3082"><span class="linenos">3082</span></a> <span class="n">inst</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"locks"</span><span class="p">,</span> <span class="p">[</span><span class="n">Lock</span><span class="p">(</span><span class="n">update</span><span class="o">=</span><span class="n">update</span><span class="p">)])</span> -</span><span id="Select.lock-3083"><a href="#Select.lock-3083"><span class="linenos">3083</span></a> -</span><span id="Select.lock-3084"><a href="#Select.lock-3084"><span class="linenos">3084</span></a> <span class="k">return</span> <span class="n">inst</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Select.lock-3065"><a href="#Select.lock-3065"><span class="linenos">3065</span></a> <span class="k">def</span> <span class="nf">lock</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">update</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select.lock-3066"><a href="#Select.lock-3066"><span class="linenos">3066</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select.lock-3067"><a href="#Select.lock-3067"><span class="linenos">3067</span></a><span class="sd"> Set the locking read mode for this expression.</span> +</span><span id="Select.lock-3068"><a href="#Select.lock-3068"><span class="linenos">3068</span></a> +</span><span id="Select.lock-3069"><a href="#Select.lock-3069"><span class="linenos">3069</span></a><span class="sd"> Examples:</span> +</span><span id="Select.lock-3070"><a href="#Select.lock-3070"><span class="linenos">3070</span></a><span class="sd"> >>> Select().select("x").from_("tbl").where("x = 'a'").lock().sql("mysql")</span> +</span><span id="Select.lock-3071"><a href="#Select.lock-3071"><span class="linenos">3071</span></a><span class="sd"> "SELECT x FROM tbl WHERE x = 'a' FOR UPDATE"</span> +</span><span id="Select.lock-3072"><a href="#Select.lock-3072"><span class="linenos">3072</span></a> +</span><span id="Select.lock-3073"><a href="#Select.lock-3073"><span class="linenos">3073</span></a><span class="sd"> >>> Select().select("x").from_("tbl").where("x = 'a'").lock(update=False).sql("mysql")</span> +</span><span id="Select.lock-3074"><a href="#Select.lock-3074"><span class="linenos">3074</span></a><span class="sd"> "SELECT x FROM tbl WHERE x = 'a' FOR SHARE"</span> +</span><span id="Select.lock-3075"><a href="#Select.lock-3075"><span class="linenos">3075</span></a> +</span><span id="Select.lock-3076"><a href="#Select.lock-3076"><span class="linenos">3076</span></a><span class="sd"> Args:</span> +</span><span id="Select.lock-3077"><a href="#Select.lock-3077"><span class="linenos">3077</span></a><span class="sd"> update: if `True`, the locking type will be `FOR UPDATE`, else it will be `FOR SHARE`.</span> +</span><span id="Select.lock-3078"><a href="#Select.lock-3078"><span class="linenos">3078</span></a><span class="sd"> copy: if `False`, modify this expression instance in-place.</span> +</span><span id="Select.lock-3079"><a href="#Select.lock-3079"><span class="linenos">3079</span></a> +</span><span id="Select.lock-3080"><a href="#Select.lock-3080"><span class="linenos">3080</span></a><span class="sd"> Returns:</span> +</span><span id="Select.lock-3081"><a href="#Select.lock-3081"><span class="linenos">3081</span></a><span class="sd"> The modified expression.</span> +</span><span id="Select.lock-3082"><a href="#Select.lock-3082"><span class="linenos">3082</span></a><span class="sd"> """</span> +</span><span id="Select.lock-3083"><a href="#Select.lock-3083"><span class="linenos">3083</span></a> <span class="n">inst</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="Select.lock-3084"><a href="#Select.lock-3084"><span class="linenos">3084</span></a> <span class="n">inst</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"locks"</span><span class="p">,</span> <span class="p">[</span><span class="n">Lock</span><span class="p">(</span><span class="n">update</span><span class="o">=</span><span class="n">update</span><span class="p">)])</span> +</span><span id="Select.lock-3085"><a href="#Select.lock-3085"><span class="linenos">3085</span></a> +</span><span id="Select.lock-3086"><a href="#Select.lock-3086"><span class="linenos">3086</span></a> <span class="k">return</span> <span class="n">inst</span> </span></pre></div> @@ -26508,29 +26587,29 @@ If another <code><a href="#Expression">Expression</a></code> instance is passed, </div> <a class="headerlink" href="#Select.hint"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Select.hint-3086"><a href="#Select.hint-3086"><span class="linenos">3086</span></a> <span class="k">def</span> <span class="nf">hint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">hints</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="Select.hint-3087"><a href="#Select.hint-3087"><span class="linenos">3087</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Select.hint-3088"><a href="#Select.hint-3088"><span class="linenos">3088</span></a><span class="sd"> Set hints for this expression.</span> -</span><span id="Select.hint-3089"><a href="#Select.hint-3089"><span class="linenos">3089</span></a> -</span><span id="Select.hint-3090"><a href="#Select.hint-3090"><span class="linenos">3090</span></a><span class="sd"> Examples:</span> -</span><span id="Select.hint-3091"><a href="#Select.hint-3091"><span class="linenos">3091</span></a><span class="sd"> >>> Select().select("x").from_("tbl").hint("BROADCAST(y)").sql(dialect="spark")</span> -</span><span id="Select.hint-3092"><a href="#Select.hint-3092"><span class="linenos">3092</span></a><span class="sd"> 'SELECT /*+ BROADCAST(y) */ x FROM tbl'</span> -</span><span id="Select.hint-3093"><a href="#Select.hint-3093"><span class="linenos">3093</span></a> -</span><span id="Select.hint-3094"><a href="#Select.hint-3094"><span class="linenos">3094</span></a><span class="sd"> Args:</span> -</span><span id="Select.hint-3095"><a href="#Select.hint-3095"><span class="linenos">3095</span></a><span class="sd"> hints: The SQL code strings to parse as the hints.</span> -</span><span id="Select.hint-3096"><a href="#Select.hint-3096"><span class="linenos">3096</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="Select.hint-3097"><a href="#Select.hint-3097"><span class="linenos">3097</span></a><span class="sd"> dialect: The dialect used to parse the hints.</span> -</span><span id="Select.hint-3098"><a href="#Select.hint-3098"><span class="linenos">3098</span></a><span class="sd"> copy: If `False`, modify this expression instance in-place.</span> -</span><span id="Select.hint-3099"><a href="#Select.hint-3099"><span class="linenos">3099</span></a> -</span><span id="Select.hint-3100"><a href="#Select.hint-3100"><span class="linenos">3100</span></a><span class="sd"> Returns:</span> -</span><span id="Select.hint-3101"><a href="#Select.hint-3101"><span class="linenos">3101</span></a><span class="sd"> The modified expression.</span> -</span><span id="Select.hint-3102"><a href="#Select.hint-3102"><span class="linenos">3102</span></a><span class="sd"> """</span> -</span><span id="Select.hint-3103"><a href="#Select.hint-3103"><span class="linenos">3103</span></a> <span class="n">inst</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="Select.hint-3104"><a href="#Select.hint-3104"><span class="linenos">3104</span></a> <span class="n">inst</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="Select.hint-3105"><a href="#Select.hint-3105"><span class="linenos">3105</span></a> <span class="s2">"hint"</span><span class="p">,</span> <span class="n">Hint</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> <span class="k">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">hints</span><span class="p">])</span> -</span><span id="Select.hint-3106"><a href="#Select.hint-3106"><span class="linenos">3106</span></a> <span class="p">)</span> -</span><span id="Select.hint-3107"><a href="#Select.hint-3107"><span class="linenos">3107</span></a> -</span><span id="Select.hint-3108"><a href="#Select.hint-3108"><span class="linenos">3108</span></a> <span class="k">return</span> <span class="n">inst</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Select.hint-3088"><a href="#Select.hint-3088"><span class="linenos">3088</span></a> <span class="k">def</span> <span class="nf">hint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">hints</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="Select.hint-3089"><a href="#Select.hint-3089"><span class="linenos">3089</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Select.hint-3090"><a href="#Select.hint-3090"><span class="linenos">3090</span></a><span class="sd"> Set hints for this expression.</span> +</span><span id="Select.hint-3091"><a href="#Select.hint-3091"><span class="linenos">3091</span></a> +</span><span id="Select.hint-3092"><a href="#Select.hint-3092"><span class="linenos">3092</span></a><span class="sd"> Examples:</span> +</span><span id="Select.hint-3093"><a href="#Select.hint-3093"><span class="linenos">3093</span></a><span class="sd"> >>> Select().select("x").from_("tbl").hint("BROADCAST(y)").sql(dialect="spark")</span> +</span><span id="Select.hint-3094"><a href="#Select.hint-3094"><span class="linenos">3094</span></a><span class="sd"> 'SELECT /*+ BROADCAST(y) */ x FROM tbl'</span> +</span><span id="Select.hint-3095"><a href="#Select.hint-3095"><span class="linenos">3095</span></a> +</span><span id="Select.hint-3096"><a href="#Select.hint-3096"><span class="linenos">3096</span></a><span class="sd"> Args:</span> +</span><span id="Select.hint-3097"><a href="#Select.hint-3097"><span class="linenos">3097</span></a><span class="sd"> hints: The SQL code strings to parse as the hints.</span> +</span><span id="Select.hint-3098"><a href="#Select.hint-3098"><span class="linenos">3098</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="Select.hint-3099"><a href="#Select.hint-3099"><span class="linenos">3099</span></a><span class="sd"> dialect: The dialect used to parse the hints.</span> +</span><span id="Select.hint-3100"><a href="#Select.hint-3100"><span class="linenos">3100</span></a><span class="sd"> copy: If `False`, modify this expression instance in-place.</span> +</span><span id="Select.hint-3101"><a href="#Select.hint-3101"><span class="linenos">3101</span></a> +</span><span id="Select.hint-3102"><a href="#Select.hint-3102"><span class="linenos">3102</span></a><span class="sd"> Returns:</span> +</span><span id="Select.hint-3103"><a href="#Select.hint-3103"><span class="linenos">3103</span></a><span class="sd"> The modified expression.</span> +</span><span id="Select.hint-3104"><a href="#Select.hint-3104"><span class="linenos">3104</span></a><span class="sd"> """</span> +</span><span id="Select.hint-3105"><a href="#Select.hint-3105"><span class="linenos">3105</span></a> <span class="n">inst</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="Select.hint-3106"><a href="#Select.hint-3106"><span class="linenos">3106</span></a> <span class="n">inst</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="Select.hint-3107"><a href="#Select.hint-3107"><span class="linenos">3107</span></a> <span class="s2">"hint"</span><span class="p">,</span> <span class="n">Hint</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> <span class="k">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">hints</span><span class="p">])</span> +</span><span id="Select.hint-3108"><a href="#Select.hint-3108"><span class="linenos">3108</span></a> <span class="p">)</span> +</span><span id="Select.hint-3109"><a href="#Select.hint-3109"><span class="linenos">3109</span></a> +</span><span id="Select.hint-3110"><a href="#Select.hint-3110"><span class="linenos">3110</span></a> <span class="k">return</span> <span class="n">inst</span> </span></pre></div> @@ -26645,30 +26724,30 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Subquery"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Subquery-3123"><a href="#Subquery-3123"><span class="linenos">3123</span></a><span class="k">class</span> <span class="nc">Subquery</span><span class="p">(</span><span class="n">DerivedTable</span><span class="p">,</span> <span class="n">Unionable</span><span class="p">):</span> -</span><span id="Subquery-3124"><a href="#Subquery-3124"><span class="linenos">3124</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Subquery-3125"><a href="#Subquery-3125"><span class="linenos">3125</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Subquery-3126"><a href="#Subquery-3126"><span class="linenos">3126</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Subquery-3127"><a href="#Subquery-3127"><span class="linenos">3127</span></a> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Subquery-3128"><a href="#Subquery-3128"><span class="linenos">3128</span></a> <span class="o">**</span><span class="n">QUERY_MODIFIERS</span><span class="p">,</span> -</span><span id="Subquery-3129"><a href="#Subquery-3129"><span class="linenos">3129</span></a> <span class="p">}</span> -</span><span id="Subquery-3130"><a href="#Subquery-3130"><span class="linenos">3130</span></a> -</span><span id="Subquery-3131"><a href="#Subquery-3131"><span class="linenos">3131</span></a> <span class="k">def</span> <span class="nf">unnest</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Subquery-3132"><a href="#Subquery-3132"><span class="linenos">3132</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Subquery-3133"><a href="#Subquery-3133"><span class="linenos">3133</span></a><span class="sd"> Returns the first non subquery.</span> -</span><span id="Subquery-3134"><a href="#Subquery-3134"><span class="linenos">3134</span></a><span class="sd"> """</span> -</span><span id="Subquery-3135"><a href="#Subquery-3135"><span class="linenos">3135</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span> -</span><span id="Subquery-3136"><a href="#Subquery-3136"><span class="linenos">3136</span></a> <span class="k">while</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Subquery</span><span class="p">):</span> -</span><span id="Subquery-3137"><a href="#Subquery-3137"><span class="linenos">3137</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="Subquery-3138"><a href="#Subquery-3138"><span class="linenos">3138</span></a> <span class="k">return</span> <span class="n">expression</span> -</span><span id="Subquery-3139"><a href="#Subquery-3139"><span class="linenos">3139</span></a> -</span><span id="Subquery-3140"><a href="#Subquery-3140"><span class="linenos">3140</span></a> <span class="nd">@property</span> -</span><span id="Subquery-3141"><a href="#Subquery-3141"><span class="linenos">3141</span></a> <span class="k">def</span> <span class="nf">is_star</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="Subquery-3142"><a href="#Subquery-3142"><span class="linenos">3142</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">is_star</span> -</span><span id="Subquery-3143"><a href="#Subquery-3143"><span class="linenos">3143</span></a> -</span><span id="Subquery-3144"><a href="#Subquery-3144"><span class="linenos">3144</span></a> <span class="nd">@property</span> -</span><span id="Subquery-3145"><a href="#Subquery-3145"><span class="linenos">3145</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Subquery-3146"><a href="#Subquery-3146"><span class="linenos">3146</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">alias</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Subquery-3125"><a href="#Subquery-3125"><span class="linenos">3125</span></a><span class="k">class</span> <span class="nc">Subquery</span><span class="p">(</span><span class="n">DerivedTable</span><span class="p">,</span> <span class="n">Unionable</span><span class="p">):</span> +</span><span id="Subquery-3126"><a href="#Subquery-3126"><span class="linenos">3126</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Subquery-3127"><a href="#Subquery-3127"><span class="linenos">3127</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Subquery-3128"><a href="#Subquery-3128"><span class="linenos">3128</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Subquery-3129"><a href="#Subquery-3129"><span class="linenos">3129</span></a> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Subquery-3130"><a href="#Subquery-3130"><span class="linenos">3130</span></a> <span class="o">**</span><span class="n">QUERY_MODIFIERS</span><span class="p">,</span> +</span><span id="Subquery-3131"><a href="#Subquery-3131"><span class="linenos">3131</span></a> <span class="p">}</span> +</span><span id="Subquery-3132"><a href="#Subquery-3132"><span class="linenos">3132</span></a> +</span><span id="Subquery-3133"><a href="#Subquery-3133"><span class="linenos">3133</span></a> <span class="k">def</span> <span class="nf">unnest</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Subquery-3134"><a href="#Subquery-3134"><span class="linenos">3134</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Subquery-3135"><a href="#Subquery-3135"><span class="linenos">3135</span></a><span class="sd"> Returns the first non subquery.</span> +</span><span id="Subquery-3136"><a href="#Subquery-3136"><span class="linenos">3136</span></a><span class="sd"> """</span> +</span><span id="Subquery-3137"><a href="#Subquery-3137"><span class="linenos">3137</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span> +</span><span id="Subquery-3138"><a href="#Subquery-3138"><span class="linenos">3138</span></a> <span class="k">while</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Subquery</span><span class="p">):</span> +</span><span id="Subquery-3139"><a href="#Subquery-3139"><span class="linenos">3139</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="Subquery-3140"><a href="#Subquery-3140"><span class="linenos">3140</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="Subquery-3141"><a href="#Subquery-3141"><span class="linenos">3141</span></a> +</span><span id="Subquery-3142"><a href="#Subquery-3142"><span class="linenos">3142</span></a> <span class="nd">@property</span> +</span><span id="Subquery-3143"><a href="#Subquery-3143"><span class="linenos">3143</span></a> <span class="k">def</span> <span class="nf">is_star</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Subquery-3144"><a href="#Subquery-3144"><span class="linenos">3144</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">is_star</span> +</span><span id="Subquery-3145"><a href="#Subquery-3145"><span class="linenos">3145</span></a> +</span><span id="Subquery-3146"><a href="#Subquery-3146"><span class="linenos">3146</span></a> <span class="nd">@property</span> +</span><span id="Subquery-3147"><a href="#Subquery-3147"><span class="linenos">3147</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Subquery-3148"><a href="#Subquery-3148"><span class="linenos">3148</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">alias</span> </span></pre></div> @@ -26685,14 +26764,14 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Subquery.unnest"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Subquery.unnest-3131"><a href="#Subquery.unnest-3131"><span class="linenos">3131</span></a> <span class="k">def</span> <span class="nf">unnest</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Subquery.unnest-3132"><a href="#Subquery.unnest-3132"><span class="linenos">3132</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Subquery.unnest-3133"><a href="#Subquery.unnest-3133"><span class="linenos">3133</span></a><span class="sd"> Returns the first non subquery.</span> -</span><span id="Subquery.unnest-3134"><a href="#Subquery.unnest-3134"><span class="linenos">3134</span></a><span class="sd"> """</span> -</span><span id="Subquery.unnest-3135"><a href="#Subquery.unnest-3135"><span class="linenos">3135</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span> -</span><span id="Subquery.unnest-3136"><a href="#Subquery.unnest-3136"><span class="linenos">3136</span></a> <span class="k">while</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Subquery</span><span class="p">):</span> -</span><span id="Subquery.unnest-3137"><a href="#Subquery.unnest-3137"><span class="linenos">3137</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="Subquery.unnest-3138"><a href="#Subquery.unnest-3138"><span class="linenos">3138</span></a> <span class="k">return</span> <span class="n">expression</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Subquery.unnest-3133"><a href="#Subquery.unnest-3133"><span class="linenos">3133</span></a> <span class="k">def</span> <span class="nf">unnest</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Subquery.unnest-3134"><a href="#Subquery.unnest-3134"><span class="linenos">3134</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Subquery.unnest-3135"><a href="#Subquery.unnest-3135"><span class="linenos">3135</span></a><span class="sd"> Returns the first non subquery.</span> +</span><span id="Subquery.unnest-3136"><a href="#Subquery.unnest-3136"><span class="linenos">3136</span></a><span class="sd"> """</span> +</span><span id="Subquery.unnest-3137"><a href="#Subquery.unnest-3137"><span class="linenos">3137</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span> +</span><span id="Subquery.unnest-3138"><a href="#Subquery.unnest-3138"><span class="linenos">3138</span></a> <span class="k">while</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">Subquery</span><span class="p">):</span> +</span><span id="Subquery.unnest-3139"><a href="#Subquery.unnest-3139"><span class="linenos">3139</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="Subquery.unnest-3140"><a href="#Subquery.unnest-3140"><span class="linenos">3140</span></a> <span class="k">return</span> <span class="n">expression</span> </span></pre></div> @@ -26805,19 +26884,19 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#TableSample"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TableSample-3149"><a href="#TableSample-3149"><span class="linenos">3149</span></a><span class="k">class</span> <span class="nc">TableSample</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="TableSample-3150"><a href="#TableSample-3150"><span class="linenos">3150</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="TableSample-3151"><a href="#TableSample-3151"><span class="linenos">3151</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="TableSample-3152"><a href="#TableSample-3152"><span class="linenos">3152</span></a> <span class="s2">"method"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="TableSample-3153"><a href="#TableSample-3153"><span class="linenos">3153</span></a> <span class="s2">"bucket_numerator"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="TableSample-3154"><a href="#TableSample-3154"><span class="linenos">3154</span></a> <span class="s2">"bucket_denominator"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="TableSample-3155"><a href="#TableSample-3155"><span class="linenos">3155</span></a> <span class="s2">"bucket_field"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="TableSample-3156"><a href="#TableSample-3156"><span class="linenos">3156</span></a> <span class="s2">"percent"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="TableSample-3157"><a href="#TableSample-3157"><span class="linenos">3157</span></a> <span class="s2">"rows"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="TableSample-3158"><a href="#TableSample-3158"><span class="linenos">3158</span></a> <span class="s2">"size"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="TableSample-3159"><a href="#TableSample-3159"><span class="linenos">3159</span></a> <span class="s2">"seed"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="TableSample-3160"><a href="#TableSample-3160"><span class="linenos">3160</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="TableSample-3161"><a href="#TableSample-3161"><span class="linenos">3161</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TableSample-3151"><a href="#TableSample-3151"><span class="linenos">3151</span></a><span class="k">class</span> <span class="nc">TableSample</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="TableSample-3152"><a href="#TableSample-3152"><span class="linenos">3152</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="TableSample-3153"><a href="#TableSample-3153"><span class="linenos">3153</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="TableSample-3154"><a href="#TableSample-3154"><span class="linenos">3154</span></a> <span class="s2">"method"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="TableSample-3155"><a href="#TableSample-3155"><span class="linenos">3155</span></a> <span class="s2">"bucket_numerator"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="TableSample-3156"><a href="#TableSample-3156"><span class="linenos">3156</span></a> <span class="s2">"bucket_denominator"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="TableSample-3157"><a href="#TableSample-3157"><span class="linenos">3157</span></a> <span class="s2">"bucket_field"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="TableSample-3158"><a href="#TableSample-3158"><span class="linenos">3158</span></a> <span class="s2">"percent"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="TableSample-3159"><a href="#TableSample-3159"><span class="linenos">3159</span></a> <span class="s2">"rows"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="TableSample-3160"><a href="#TableSample-3160"><span class="linenos">3160</span></a> <span class="s2">"size"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="TableSample-3161"><a href="#TableSample-3161"><span class="linenos">3161</span></a> <span class="s2">"seed"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="TableSample-3162"><a href="#TableSample-3162"><span class="linenos">3162</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="TableSample-3163"><a href="#TableSample-3163"><span class="linenos">3163</span></a> <span class="p">}</span> </span></pre></div> @@ -26881,14 +26960,14 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Tag"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Tag-3164"><a href="#Tag-3164"><span class="linenos">3164</span></a><span class="k">class</span> <span class="nc">Tag</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Tag-3165"><a href="#Tag-3165"><span class="linenos">3165</span></a><span class="w"> </span><span class="sd">"""Tags are used for generating arbitrary sql like SELECT <span>x</span>."""</span> -</span><span id="Tag-3166"><a href="#Tag-3166"><span class="linenos">3166</span></a> -</span><span id="Tag-3167"><a href="#Tag-3167"><span class="linenos">3167</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Tag-3168"><a href="#Tag-3168"><span class="linenos">3168</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Tag-3169"><a href="#Tag-3169"><span class="linenos">3169</span></a> <span class="s2">"prefix"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Tag-3170"><a href="#Tag-3170"><span class="linenos">3170</span></a> <span class="s2">"postfix"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Tag-3171"><a href="#Tag-3171"><span class="linenos">3171</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Tag-3166"><a href="#Tag-3166"><span class="linenos">3166</span></a><span class="k">class</span> <span class="nc">Tag</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Tag-3167"><a href="#Tag-3167"><span class="linenos">3167</span></a><span class="w"> </span><span class="sd">"""Tags are used for generating arbitrary sql like SELECT <span>x</span>."""</span> +</span><span id="Tag-3168"><a href="#Tag-3168"><span class="linenos">3168</span></a> +</span><span id="Tag-3169"><a href="#Tag-3169"><span class="linenos">3169</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Tag-3170"><a href="#Tag-3170"><span class="linenos">3170</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Tag-3171"><a href="#Tag-3171"><span class="linenos">3171</span></a> <span class="s2">"prefix"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Tag-3172"><a href="#Tag-3172"><span class="linenos">3172</span></a> <span class="s2">"postfix"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Tag-3173"><a href="#Tag-3173"><span class="linenos">3173</span></a> <span class="p">}</span> </span></pre></div> @@ -26954,17 +27033,17 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Pivot"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Pivot-3176"><a href="#Pivot-3176"><span class="linenos">3176</span></a><span class="k">class</span> <span class="nc">Pivot</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Pivot-3177"><a href="#Pivot-3177"><span class="linenos">3177</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Pivot-3178"><a href="#Pivot-3178"><span class="linenos">3178</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Pivot-3179"><a href="#Pivot-3179"><span class="linenos">3179</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Pivot-3180"><a href="#Pivot-3180"><span class="linenos">3180</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Pivot-3181"><a href="#Pivot-3181"><span class="linenos">3181</span></a> <span class="s2">"field"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Pivot-3182"><a href="#Pivot-3182"><span class="linenos">3182</span></a> <span class="s2">"unpivot"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Pivot-3183"><a href="#Pivot-3183"><span class="linenos">3183</span></a> <span class="s2">"using"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Pivot-3184"><a href="#Pivot-3184"><span class="linenos">3184</span></a> <span class="s2">"group"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Pivot-3185"><a href="#Pivot-3185"><span class="linenos">3185</span></a> <span class="s2">"columns"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Pivot-3186"><a href="#Pivot-3186"><span class="linenos">3186</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Pivot-3178"><a href="#Pivot-3178"><span class="linenos">3178</span></a><span class="k">class</span> <span class="nc">Pivot</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Pivot-3179"><a href="#Pivot-3179"><span class="linenos">3179</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Pivot-3180"><a href="#Pivot-3180"><span class="linenos">3180</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Pivot-3181"><a href="#Pivot-3181"><span class="linenos">3181</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Pivot-3182"><a href="#Pivot-3182"><span class="linenos">3182</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Pivot-3183"><a href="#Pivot-3183"><span class="linenos">3183</span></a> <span class="s2">"field"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Pivot-3184"><a href="#Pivot-3184"><span class="linenos">3184</span></a> <span class="s2">"unpivot"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Pivot-3185"><a href="#Pivot-3185"><span class="linenos">3185</span></a> <span class="s2">"using"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Pivot-3186"><a href="#Pivot-3186"><span class="linenos">3186</span></a> <span class="s2">"group"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Pivot-3187"><a href="#Pivot-3187"><span class="linenos">3187</span></a> <span class="s2">"columns"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Pivot-3188"><a href="#Pivot-3188"><span class="linenos">3188</span></a> <span class="p">}</span> </span></pre></div> @@ -27028,16 +27107,16 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Window"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Window-3189"><a href="#Window-3189"><span class="linenos">3189</span></a><span class="k">class</span> <span class="nc">Window</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Window-3190"><a href="#Window-3190"><span class="linenos">3190</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Window-3191"><a href="#Window-3191"><span class="linenos">3191</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Window-3192"><a href="#Window-3192"><span class="linenos">3192</span></a> <span class="s2">"partition_by"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Window-3193"><a href="#Window-3193"><span class="linenos">3193</span></a> <span class="s2">"order"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Window-3194"><a href="#Window-3194"><span class="linenos">3194</span></a> <span class="s2">"spec"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Window-3195"><a href="#Window-3195"><span class="linenos">3195</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Window-3196"><a href="#Window-3196"><span class="linenos">3196</span></a> <span class="s2">"over"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Window-3197"><a href="#Window-3197"><span class="linenos">3197</span></a> <span class="s2">"first"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Window-3198"><a href="#Window-3198"><span class="linenos">3198</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Window-3191"><a href="#Window-3191"><span class="linenos">3191</span></a><span class="k">class</span> <span class="nc">Window</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Window-3192"><a href="#Window-3192"><span class="linenos">3192</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Window-3193"><a href="#Window-3193"><span class="linenos">3193</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Window-3194"><a href="#Window-3194"><span class="linenos">3194</span></a> <span class="s2">"partition_by"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Window-3195"><a href="#Window-3195"><span class="linenos">3195</span></a> <span class="s2">"order"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Window-3196"><a href="#Window-3196"><span class="linenos">3196</span></a> <span class="s2">"spec"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Window-3197"><a href="#Window-3197"><span class="linenos">3197</span></a> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Window-3198"><a href="#Window-3198"><span class="linenos">3198</span></a> <span class="s2">"over"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Window-3199"><a href="#Window-3199"><span class="linenos">3199</span></a> <span class="s2">"first"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Window-3200"><a href="#Window-3200"><span class="linenos">3200</span></a> <span class="p">}</span> </span></pre></div> @@ -27101,14 +27180,14 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#WindowSpec"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="WindowSpec-3201"><a href="#WindowSpec-3201"><span class="linenos">3201</span></a><span class="k">class</span> <span class="nc">WindowSpec</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="WindowSpec-3202"><a href="#WindowSpec-3202"><span class="linenos">3202</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="WindowSpec-3203"><a href="#WindowSpec-3203"><span class="linenos">3203</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="WindowSpec-3204"><a href="#WindowSpec-3204"><span class="linenos">3204</span></a> <span class="s2">"start"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="WindowSpec-3205"><a href="#WindowSpec-3205"><span class="linenos">3205</span></a> <span class="s2">"start_side"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="WindowSpec-3206"><a href="#WindowSpec-3206"><span class="linenos">3206</span></a> <span class="s2">"end"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="WindowSpec-3207"><a href="#WindowSpec-3207"><span class="linenos">3207</span></a> <span class="s2">"end_side"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="WindowSpec-3208"><a href="#WindowSpec-3208"><span class="linenos">3208</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="WindowSpec-3203"><a href="#WindowSpec-3203"><span class="linenos">3203</span></a><span class="k">class</span> <span class="nc">WindowSpec</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="WindowSpec-3204"><a href="#WindowSpec-3204"><span class="linenos">3204</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="WindowSpec-3205"><a href="#WindowSpec-3205"><span class="linenos">3205</span></a> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="WindowSpec-3206"><a href="#WindowSpec-3206"><span class="linenos">3206</span></a> <span class="s2">"start"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="WindowSpec-3207"><a href="#WindowSpec-3207"><span class="linenos">3207</span></a> <span class="s2">"start_side"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="WindowSpec-3208"><a href="#WindowSpec-3208"><span class="linenos">3208</span></a> <span class="s2">"end"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="WindowSpec-3209"><a href="#WindowSpec-3209"><span class="linenos">3209</span></a> <span class="s2">"end_side"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="WindowSpec-3210"><a href="#WindowSpec-3210"><span class="linenos">3210</span></a> <span class="p">}</span> </span></pre></div> @@ -27172,8 +27251,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Where"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Where-3211"><a href="#Where-3211"><span class="linenos">3211</span></a><span class="k">class</span> <span class="nc">Where</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Where-3212"><a href="#Where-3212"><span class="linenos">3212</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Where-3213"><a href="#Where-3213"><span class="linenos">3213</span></a><span class="k">class</span> <span class="nc">Where</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Where-3214"><a href="#Where-3214"><span class="linenos">3214</span></a> <span class="k">pass</span> </span></pre></div> @@ -27237,16 +27316,16 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Star"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Star-3215"><a href="#Star-3215"><span class="linenos">3215</span></a><span class="k">class</span> <span class="nc">Star</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Star-3216"><a href="#Star-3216"><span class="linenos">3216</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"except"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"replace"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="Star-3217"><a href="#Star-3217"><span class="linenos">3217</span></a> -</span><span id="Star-3218"><a href="#Star-3218"><span class="linenos">3218</span></a> <span class="nd">@property</span> -</span><span id="Star-3219"><a href="#Star-3219"><span class="linenos">3219</span></a> <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Star-3220"><a href="#Star-3220"><span class="linenos">3220</span></a> <span class="k">return</span> <span class="s2">"*"</span> -</span><span id="Star-3221"><a href="#Star-3221"><span class="linenos">3221</span></a> -</span><span id="Star-3222"><a href="#Star-3222"><span class="linenos">3222</span></a> <span class="nd">@property</span> -</span><span id="Star-3223"><a href="#Star-3223"><span class="linenos">3223</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Star-3224"><a href="#Star-3224"><span class="linenos">3224</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Star-3217"><a href="#Star-3217"><span class="linenos">3217</span></a><span class="k">class</span> <span class="nc">Star</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Star-3218"><a href="#Star-3218"><span class="linenos">3218</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"except"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"replace"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="Star-3219"><a href="#Star-3219"><span class="linenos">3219</span></a> +</span><span id="Star-3220"><a href="#Star-3220"><span class="linenos">3220</span></a> <span class="nd">@property</span> +</span><span id="Star-3221"><a href="#Star-3221"><span class="linenos">3221</span></a> <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Star-3222"><a href="#Star-3222"><span class="linenos">3222</span></a> <span class="k">return</span> <span class="s2">"*"</span> +</span><span id="Star-3223"><a href="#Star-3223"><span class="linenos">3223</span></a> +</span><span id="Star-3224"><a href="#Star-3224"><span class="linenos">3224</span></a> <span class="nd">@property</span> +</span><span id="Star-3225"><a href="#Star-3225"><span class="linenos">3225</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Star-3226"><a href="#Star-3226"><span class="linenos">3226</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> </span></pre></div> @@ -27333,14 +27412,14 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w <div class="attr class"> <span class="def">class</span> - <span class="name">Parameter</span><wbr>(<span class="base"><a href="#Expression">Expression</a></span>): + <span class="name">Parameter</span><wbr>(<span class="base"><a href="#Condition">Condition</a></span>): <label class="view-source-button" for="Parameter-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#Parameter"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Parameter-3227"><a href="#Parameter-3227"><span class="linenos">3227</span></a><span class="k">class</span> <span class="nc">Parameter</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Parameter-3228"><a href="#Parameter-3228"><span class="linenos">3228</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"wrapped"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Parameter-3229"><a href="#Parameter-3229"><span class="linenos">3229</span></a><span class="k">class</span> <span class="nc">Parameter</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> +</span><span id="Parameter-3230"><a href="#Parameter-3230"><span class="linenos">3230</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"wrapped"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -27390,6 +27469,21 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w <dd id="Parameter.load" class="function"><a href="#Expression.load">load</a></dd> </div> + <div><dt><a href="#Condition">Condition</a></dt> + <dd id="Parameter.and_" class="function"><a href="#Condition.and_">and_</a></dd> + <dd id="Parameter.or_" class="function"><a href="#Condition.or_">or_</a></dd> + <dd id="Parameter.not_" class="function"><a href="#Condition.not_">not_</a></dd> + <dd id="Parameter.as_" class="function"><a href="#Condition.as_">as_</a></dd> + <dd id="Parameter.isin" class="function"><a href="#Condition.isin">isin</a></dd> + <dd id="Parameter.between" class="function"><a href="#Condition.between">between</a></dd> + <dd id="Parameter.is_" class="function"><a href="#Condition.is_">is_</a></dd> + <dd id="Parameter.like" class="function"><a href="#Condition.like">like</a></dd> + <dd id="Parameter.ilike" class="function"><a href="#Condition.ilike">ilike</a></dd> + <dd id="Parameter.eq" class="function"><a href="#Condition.eq">eq</a></dd> + <dd id="Parameter.neq" class="function"><a href="#Condition.neq">neq</a></dd> + <dd id="Parameter.rlike" class="function"><a href="#Condition.rlike">rlike</a></dd> + + </div> </dl> </div> </section> @@ -27398,14 +27492,14 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w <div class="attr class"> <span class="def">class</span> - <span class="name">SessionParameter</span><wbr>(<span class="base"><a href="#Expression">Expression</a></span>): + <span class="name">SessionParameter</span><wbr>(<span class="base"><a href="#Condition">Condition</a></span>): <label class="view-source-button" for="SessionParameter-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#SessionParameter"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SessionParameter-3231"><a href="#SessionParameter-3231"><span class="linenos">3231</span></a><span class="k">class</span> <span class="nc">SessionParameter</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="SessionParameter-3232"><a href="#SessionParameter-3232"><span class="linenos">3232</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SessionParameter-3233"><a href="#SessionParameter-3233"><span class="linenos">3233</span></a><span class="k">class</span> <span class="nc">SessionParameter</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> +</span><span id="SessionParameter-3234"><a href="#SessionParameter-3234"><span class="linenos">3234</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -27455,6 +27549,21 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w <dd id="SessionParameter.load" class="function"><a href="#Expression.load">load</a></dd> </div> + <div><dt><a href="#Condition">Condition</a></dt> + <dd id="SessionParameter.and_" class="function"><a href="#Condition.and_">and_</a></dd> + <dd id="SessionParameter.or_" class="function"><a href="#Condition.or_">or_</a></dd> + <dd id="SessionParameter.not_" class="function"><a href="#Condition.not_">not_</a></dd> + <dd id="SessionParameter.as_" class="function"><a href="#Condition.as_">as_</a></dd> + <dd id="SessionParameter.isin" class="function"><a href="#Condition.isin">isin</a></dd> + <dd id="SessionParameter.between" class="function"><a href="#Condition.between">between</a></dd> + <dd id="SessionParameter.is_" class="function"><a href="#Condition.is_">is_</a></dd> + <dd id="SessionParameter.like" class="function"><a href="#Condition.like">like</a></dd> + <dd id="SessionParameter.ilike" class="function"><a href="#Condition.ilike">ilike</a></dd> + <dd id="SessionParameter.eq" class="function"><a href="#Condition.eq">eq</a></dd> + <dd id="SessionParameter.neq" class="function"><a href="#Condition.neq">neq</a></dd> + <dd id="SessionParameter.rlike" class="function"><a href="#Condition.rlike">rlike</a></dd> + + </div> </dl> </div> </section> @@ -27463,14 +27572,14 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w <div class="attr class"> <span class="def">class</span> - <span class="name">Placeholder</span><wbr>(<span class="base"><a href="#Expression">Expression</a></span>): + <span class="name">Placeholder</span><wbr>(<span class="base"><a href="#Condition">Condition</a></span>): <label class="view-source-button" for="Placeholder-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#Placeholder"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Placeholder-3235"><a href="#Placeholder-3235"><span class="linenos">3235</span></a><span class="k">class</span> <span class="nc">Placeholder</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Placeholder-3236"><a href="#Placeholder-3236"><span class="linenos">3236</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Placeholder-3237"><a href="#Placeholder-3237"><span class="linenos">3237</span></a><span class="k">class</span> <span class="nc">Placeholder</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> +</span><span id="Placeholder-3238"><a href="#Placeholder-3238"><span class="linenos">3238</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -27520,6 +27629,21 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w <dd id="Placeholder.load" class="function"><a href="#Expression.load">load</a></dd> </div> + <div><dt><a href="#Condition">Condition</a></dt> + <dd id="Placeholder.and_" class="function"><a href="#Condition.and_">and_</a></dd> + <dd id="Placeholder.or_" class="function"><a href="#Condition.or_">or_</a></dd> + <dd id="Placeholder.not_" class="function"><a href="#Condition.not_">not_</a></dd> + <dd id="Placeholder.as_" class="function"><a href="#Condition.as_">as_</a></dd> + <dd id="Placeholder.isin" class="function"><a href="#Condition.isin">isin</a></dd> + <dd id="Placeholder.between" class="function"><a href="#Condition.between">between</a></dd> + <dd id="Placeholder.is_" class="function"><a href="#Condition.is_">is_</a></dd> + <dd id="Placeholder.like" class="function"><a href="#Condition.like">like</a></dd> + <dd id="Placeholder.ilike" class="function"><a href="#Condition.ilike">ilike</a></dd> + <dd id="Placeholder.eq" class="function"><a href="#Condition.eq">eq</a></dd> + <dd id="Placeholder.neq" class="function"><a href="#Condition.neq">neq</a></dd> + <dd id="Placeholder.rlike" class="function"><a href="#Condition.rlike">rlike</a></dd> + + </div> </dl> </div> </section> @@ -27534,12 +27658,12 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Null"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Null-3239"><a href="#Null-3239"><span class="linenos">3239</span></a><span class="k">class</span> <span class="nc">Null</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> -</span><span id="Null-3240"><a href="#Null-3240"><span class="linenos">3240</span></a> <span class="n">arg_types</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Null-3241"><a href="#Null-3241"><span class="linenos">3241</span></a> -</span><span id="Null-3242"><a href="#Null-3242"><span class="linenos">3242</span></a> <span class="nd">@property</span> -</span><span id="Null-3243"><a href="#Null-3243"><span class="linenos">3243</span></a> <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Null-3244"><a href="#Null-3244"><span class="linenos">3244</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Null-3241"><a href="#Null-3241"><span class="linenos">3241</span></a><span class="k">class</span> <span class="nc">Null</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> +</span><span id="Null-3242"><a href="#Null-3242"><span class="linenos">3242</span></a> <span class="n">arg_types</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Null-3243"><a href="#Null-3243"><span class="linenos">3243</span></a> +</span><span id="Null-3244"><a href="#Null-3244"><span class="linenos">3244</span></a> <span class="nd">@property</span> +</span><span id="Null-3245"><a href="#Null-3245"><span class="linenos">3245</span></a> <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Null-3246"><a href="#Null-3246"><span class="linenos">3246</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> </span></pre></div> @@ -27618,8 +27742,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Boolean"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Boolean-3247"><a href="#Boolean-3247"><span class="linenos">3247</span></a><span class="k">class</span> <span class="nc">Boolean</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> -</span><span id="Boolean-3248"><a href="#Boolean-3248"><span class="linenos">3248</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Boolean-3249"><a href="#Boolean-3249"><span class="linenos">3249</span></a><span class="k">class</span> <span class="nc">Boolean</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> +</span><span id="Boolean-3250"><a href="#Boolean-3250"><span class="linenos">3250</span></a> <span class="k">pass</span> </span></pre></div> @@ -27698,8 +27822,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#DataTypeSize"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataTypeSize-3251"><a href="#DataTypeSize-3251"><span class="linenos">3251</span></a><span class="k">class</span> <span class="nc">DataTypeSize</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="DataTypeSize-3252"><a href="#DataTypeSize-3252"><span class="linenos">3252</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataTypeSize-3253"><a href="#DataTypeSize-3253"><span class="linenos">3253</span></a><span class="k">class</span> <span class="nc">DataTypeSize</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="DataTypeSize-3254"><a href="#DataTypeSize-3254"><span class="linenos">3254</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -27763,153 +27887,156 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#DataType"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataType-3255"><a href="#DataType-3255"><span class="linenos">3255</span></a><span class="k">class</span> <span class="nc">DataType</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="DataType-3256"><a href="#DataType-3256"><span class="linenos">3256</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DataType-3257"><a href="#DataType-3257"><span class="linenos">3257</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="DataType-3258"><a href="#DataType-3258"><span class="linenos">3258</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="DataType-3259"><a href="#DataType-3259"><span class="linenos">3259</span></a> <span class="s2">"nested"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="DataType-3260"><a href="#DataType-3260"><span class="linenos">3260</span></a> <span class="s2">"values"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="DataType-3261"><a href="#DataType-3261"><span class="linenos">3261</span></a> <span class="s2">"prefix"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="DataType-3262"><a href="#DataType-3262"><span class="linenos">3262</span></a> <span class="p">}</span> -</span><span id="DataType-3263"><a href="#DataType-3263"><span class="linenos">3263</span></a> -</span><span id="DataType-3264"><a href="#DataType-3264"><span class="linenos">3264</span></a> <span class="k">class</span> <span class="nc">Type</span><span class="p">(</span><span class="n">AutoName</span><span class="p">):</span> -</span><span id="DataType-3265"><a href="#DataType-3265"><span class="linenos">3265</span></a> <span class="n">ARRAY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3266"><a href="#DataType-3266"><span class="linenos">3266</span></a> <span class="n">BIGDECIMAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3267"><a href="#DataType-3267"><span class="linenos">3267</span></a> <span class="n">BIGINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3268"><a href="#DataType-3268"><span class="linenos">3268</span></a> <span class="n">BIGSERIAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3269"><a href="#DataType-3269"><span class="linenos">3269</span></a> <span class="n">BINARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3270"><a href="#DataType-3270"><span class="linenos">3270</span></a> <span class="n">BIT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3271"><a href="#DataType-3271"><span class="linenos">3271</span></a> <span class="n">BOOLEAN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3272"><a href="#DataType-3272"><span class="linenos">3272</span></a> <span class="n">CHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3273"><a href="#DataType-3273"><span class="linenos">3273</span></a> <span class="n">DATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3274"><a href="#DataType-3274"><span class="linenos">3274</span></a> <span class="n">DATETIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3275"><a href="#DataType-3275"><span class="linenos">3275</span></a> <span class="n">DATETIME64</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3276"><a href="#DataType-3276"><span class="linenos">3276</span></a> <span class="n">ENUM</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3277"><a href="#DataType-3277"><span class="linenos">3277</span></a> <span class="n">INT4RANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3278"><a href="#DataType-3278"><span class="linenos">3278</span></a> <span class="n">INT4MULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3279"><a href="#DataType-3279"><span class="linenos">3279</span></a> <span class="n">INT8RANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3280"><a href="#DataType-3280"><span class="linenos">3280</span></a> <span class="n">INT8MULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3281"><a href="#DataType-3281"><span class="linenos">3281</span></a> <span class="n">NUMRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3282"><a href="#DataType-3282"><span class="linenos">3282</span></a> <span class="n">NUMMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3283"><a href="#DataType-3283"><span class="linenos">3283</span></a> <span class="n">TSRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3284"><a href="#DataType-3284"><span class="linenos">3284</span></a> <span class="n">TSMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3285"><a href="#DataType-3285"><span class="linenos">3285</span></a> <span class="n">TSTZRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3286"><a href="#DataType-3286"><span class="linenos">3286</span></a> <span class="n">TSTZMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3287"><a href="#DataType-3287"><span class="linenos">3287</span></a> <span class="n">DATERANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3288"><a href="#DataType-3288"><span class="linenos">3288</span></a> <span class="n">DATEMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3289"><a href="#DataType-3289"><span class="linenos">3289</span></a> <span class="n">DECIMAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3290"><a href="#DataType-3290"><span class="linenos">3290</span></a> <span class="n">DOUBLE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3291"><a href="#DataType-3291"><span class="linenos">3291</span></a> <span class="n">FLOAT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3292"><a href="#DataType-3292"><span class="linenos">3292</span></a> <span class="n">GEOGRAPHY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3293"><a href="#DataType-3293"><span class="linenos">3293</span></a> <span class="n">GEOMETRY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3294"><a href="#DataType-3294"><span class="linenos">3294</span></a> <span class="n">HLLSKETCH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3295"><a href="#DataType-3295"><span class="linenos">3295</span></a> <span class="n">HSTORE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3296"><a href="#DataType-3296"><span class="linenos">3296</span></a> <span class="n">IMAGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3297"><a href="#DataType-3297"><span class="linenos">3297</span></a> <span class="n">INET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3298"><a href="#DataType-3298"><span class="linenos">3298</span></a> <span class="n">INT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3299"><a href="#DataType-3299"><span class="linenos">3299</span></a> <span class="n">INT128</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3300"><a href="#DataType-3300"><span class="linenos">3300</span></a> <span class="n">INT256</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3301"><a href="#DataType-3301"><span class="linenos">3301</span></a> <span class="n">INTERVAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3302"><a href="#DataType-3302"><span class="linenos">3302</span></a> <span class="n">JSON</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3303"><a href="#DataType-3303"><span class="linenos">3303</span></a> <span class="n">JSONB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3304"><a href="#DataType-3304"><span class="linenos">3304</span></a> <span class="n">LONGBLOB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3305"><a href="#DataType-3305"><span class="linenos">3305</span></a> <span class="n">LONGTEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3306"><a href="#DataType-3306"><span class="linenos">3306</span></a> <span class="n">MAP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3307"><a href="#DataType-3307"><span class="linenos">3307</span></a> <span class="n">MEDIUMBLOB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3308"><a href="#DataType-3308"><span class="linenos">3308</span></a> <span class="n">MEDIUMTEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3309"><a href="#DataType-3309"><span class="linenos">3309</span></a> <span class="n">MONEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3310"><a href="#DataType-3310"><span class="linenos">3310</span></a> <span class="n">NCHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3311"><a href="#DataType-3311"><span class="linenos">3311</span></a> <span class="n">NULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3312"><a href="#DataType-3312"><span class="linenos">3312</span></a> <span class="n">NULLABLE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3313"><a href="#DataType-3313"><span class="linenos">3313</span></a> <span class="n">NVARCHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3314"><a href="#DataType-3314"><span class="linenos">3314</span></a> <span class="n">OBJECT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3315"><a href="#DataType-3315"><span class="linenos">3315</span></a> <span class="n">ROWVERSION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3316"><a href="#DataType-3316"><span class="linenos">3316</span></a> <span class="n">SERIAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3317"><a href="#DataType-3317"><span class="linenos">3317</span></a> <span class="n">SET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3318"><a href="#DataType-3318"><span class="linenos">3318</span></a> <span class="n">SMALLINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3319"><a href="#DataType-3319"><span class="linenos">3319</span></a> <span class="n">SMALLMONEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3320"><a href="#DataType-3320"><span class="linenos">3320</span></a> <span class="n">SMALLSERIAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3321"><a href="#DataType-3321"><span class="linenos">3321</span></a> <span class="n">STRUCT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3322"><a href="#DataType-3322"><span class="linenos">3322</span></a> <span class="n">SUPER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3323"><a href="#DataType-3323"><span class="linenos">3323</span></a> <span class="n">TEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3324"><a href="#DataType-3324"><span class="linenos">3324</span></a> <span class="n">TIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3325"><a href="#DataType-3325"><span class="linenos">3325</span></a> <span class="n">TIMESTAMP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3326"><a href="#DataType-3326"><span class="linenos">3326</span></a> <span class="n">TIMESTAMPTZ</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3327"><a href="#DataType-3327"><span class="linenos">3327</span></a> <span class="n">TIMESTAMPLTZ</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3328"><a href="#DataType-3328"><span class="linenos">3328</span></a> <span class="n">TINYINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3329"><a href="#DataType-3329"><span class="linenos">3329</span></a> <span class="n">UBIGINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3330"><a href="#DataType-3330"><span class="linenos">3330</span></a> <span class="n">UINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3331"><a href="#DataType-3331"><span class="linenos">3331</span></a> <span class="n">USMALLINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3332"><a href="#DataType-3332"><span class="linenos">3332</span></a> <span class="n">UTINYINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3333"><a href="#DataType-3333"><span class="linenos">3333</span></a> <span class="n">UNKNOWN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> <span class="c1"># Sentinel value, useful for type annotation</span> -</span><span id="DataType-3334"><a href="#DataType-3334"><span class="linenos">3334</span></a> <span class="n">UINT128</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3335"><a href="#DataType-3335"><span class="linenos">3335</span></a> <span class="n">UINT256</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3336"><a href="#DataType-3336"><span class="linenos">3336</span></a> <span class="n">UNIQUEIDENTIFIER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3337"><a href="#DataType-3337"><span class="linenos">3337</span></a> <span class="n">UUID</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3338"><a href="#DataType-3338"><span class="linenos">3338</span></a> <span class="n">VARBINARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3339"><a href="#DataType-3339"><span class="linenos">3339</span></a> <span class="n">VARCHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3340"><a href="#DataType-3340"><span class="linenos">3340</span></a> <span class="n">VARIANT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3341"><a href="#DataType-3341"><span class="linenos">3341</span></a> <span class="n">XML</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType-3342"><a href="#DataType-3342"><span class="linenos">3342</span></a> -</span><span id="DataType-3343"><a href="#DataType-3343"><span class="linenos">3343</span></a> <span class="n">TEXT_TYPES</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DataType-3344"><a href="#DataType-3344"><span class="linenos">3344</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span> -</span><span id="DataType-3345"><a href="#DataType-3345"><span class="linenos">3345</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">,</span> -</span><span id="DataType-3346"><a href="#DataType-3346"><span class="linenos">3346</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> -</span><span id="DataType-3347"><a href="#DataType-3347"><span class="linenos">3347</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">,</span> -</span><span id="DataType-3348"><a href="#DataType-3348"><span class="linenos">3348</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> -</span><span id="DataType-3349"><a href="#DataType-3349"><span class="linenos">3349</span></a> <span class="p">}</span> -</span><span id="DataType-3350"><a href="#DataType-3350"><span class="linenos">3350</span></a> -</span><span id="DataType-3351"><a href="#DataType-3351"><span class="linenos">3351</span></a> <span class="n">INTEGER_TYPES</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DataType-3352"><a href="#DataType-3352"><span class="linenos">3352</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">,</span> -</span><span id="DataType-3353"><a href="#DataType-3353"><span class="linenos">3353</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">,</span> -</span><span id="DataType-3354"><a href="#DataType-3354"><span class="linenos">3354</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> -</span><span id="DataType-3355"><a href="#DataType-3355"><span class="linenos">3355</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> -</span><span id="DataType-3356"><a href="#DataType-3356"><span class="linenos">3356</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">INT128</span><span class="p">,</span> -</span><span id="DataType-3357"><a href="#DataType-3357"><span class="linenos">3357</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">INT256</span><span class="p">,</span> -</span><span id="DataType-3358"><a href="#DataType-3358"><span class="linenos">3358</span></a> <span class="p">}</span> -</span><span id="DataType-3359"><a href="#DataType-3359"><span class="linenos">3359</span></a> -</span><span id="DataType-3360"><a href="#DataType-3360"><span class="linenos">3360</span></a> <span class="n">FLOAT_TYPES</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DataType-3361"><a href="#DataType-3361"><span class="linenos">3361</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span> -</span><span id="DataType-3362"><a href="#DataType-3362"><span class="linenos">3362</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> -</span><span id="DataType-3363"><a href="#DataType-3363"><span class="linenos">3363</span></a> <span class="p">}</span> -</span><span id="DataType-3364"><a href="#DataType-3364"><span class="linenos">3364</span></a> -</span><span id="DataType-3365"><a href="#DataType-3365"><span class="linenos">3365</span></a> <span class="n">NUMERIC_TYPES</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">INTEGER_TYPES</span><span class="p">,</span> <span class="o">*</span><span class="n">FLOAT_TYPES</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataType-3257"><a href="#DataType-3257"><span class="linenos">3257</span></a><span class="k">class</span> <span class="nc">DataType</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="DataType-3258"><a href="#DataType-3258"><span class="linenos">3258</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DataType-3259"><a href="#DataType-3259"><span class="linenos">3259</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="DataType-3260"><a href="#DataType-3260"><span class="linenos">3260</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="DataType-3261"><a href="#DataType-3261"><span class="linenos">3261</span></a> <span class="s2">"nested"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="DataType-3262"><a href="#DataType-3262"><span class="linenos">3262</span></a> <span class="s2">"values"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="DataType-3263"><a href="#DataType-3263"><span class="linenos">3263</span></a> <span class="s2">"prefix"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="DataType-3264"><a href="#DataType-3264"><span class="linenos">3264</span></a> <span class="p">}</span> +</span><span id="DataType-3265"><a href="#DataType-3265"><span class="linenos">3265</span></a> +</span><span id="DataType-3266"><a href="#DataType-3266"><span class="linenos">3266</span></a> <span class="k">class</span> <span class="nc">Type</span><span class="p">(</span><span class="n">AutoName</span><span class="p">):</span> +</span><span id="DataType-3267"><a href="#DataType-3267"><span class="linenos">3267</span></a> <span class="n">ARRAY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3268"><a href="#DataType-3268"><span class="linenos">3268</span></a> <span class="n">BIGDECIMAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3269"><a href="#DataType-3269"><span class="linenos">3269</span></a> <span class="n">BIGINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3270"><a href="#DataType-3270"><span class="linenos">3270</span></a> <span class="n">BIGSERIAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3271"><a href="#DataType-3271"><span class="linenos">3271</span></a> <span class="n">BINARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3272"><a href="#DataType-3272"><span class="linenos">3272</span></a> <span class="n">BIT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3273"><a href="#DataType-3273"><span class="linenos">3273</span></a> <span class="n">BOOLEAN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3274"><a href="#DataType-3274"><span class="linenos">3274</span></a> <span class="n">CHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3275"><a href="#DataType-3275"><span class="linenos">3275</span></a> <span class="n">DATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3276"><a href="#DataType-3276"><span class="linenos">3276</span></a> <span class="n">DATETIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3277"><a href="#DataType-3277"><span class="linenos">3277</span></a> <span class="n">DATETIME64</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3278"><a href="#DataType-3278"><span class="linenos">3278</span></a> <span class="n">ENUM</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3279"><a href="#DataType-3279"><span class="linenos">3279</span></a> <span class="n">INT4RANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3280"><a href="#DataType-3280"><span class="linenos">3280</span></a> <span class="n">INT4MULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3281"><a href="#DataType-3281"><span class="linenos">3281</span></a> <span class="n">INT8RANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3282"><a href="#DataType-3282"><span class="linenos">3282</span></a> <span class="n">INT8MULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3283"><a href="#DataType-3283"><span class="linenos">3283</span></a> <span class="n">NUMRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3284"><a href="#DataType-3284"><span class="linenos">3284</span></a> <span class="n">NUMMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3285"><a href="#DataType-3285"><span class="linenos">3285</span></a> <span class="n">TSRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3286"><a href="#DataType-3286"><span class="linenos">3286</span></a> <span class="n">TSMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3287"><a href="#DataType-3287"><span class="linenos">3287</span></a> <span class="n">TSTZRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3288"><a href="#DataType-3288"><span class="linenos">3288</span></a> <span class="n">TSTZMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3289"><a href="#DataType-3289"><span class="linenos">3289</span></a> <span class="n">DATERANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3290"><a href="#DataType-3290"><span class="linenos">3290</span></a> <span class="n">DATEMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3291"><a href="#DataType-3291"><span class="linenos">3291</span></a> <span class="n">DECIMAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3292"><a href="#DataType-3292"><span class="linenos">3292</span></a> <span class="n">DOUBLE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3293"><a href="#DataType-3293"><span class="linenos">3293</span></a> <span class="n">FLOAT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3294"><a href="#DataType-3294"><span class="linenos">3294</span></a> <span class="n">GEOGRAPHY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3295"><a href="#DataType-3295"><span class="linenos">3295</span></a> <span class="n">GEOMETRY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3296"><a href="#DataType-3296"><span class="linenos">3296</span></a> <span class="n">HLLSKETCH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3297"><a href="#DataType-3297"><span class="linenos">3297</span></a> <span class="n">HSTORE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3298"><a href="#DataType-3298"><span class="linenos">3298</span></a> <span class="n">IMAGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3299"><a href="#DataType-3299"><span class="linenos">3299</span></a> <span class="n">INET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3300"><a href="#DataType-3300"><span class="linenos">3300</span></a> <span class="n">INT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3301"><a href="#DataType-3301"><span class="linenos">3301</span></a> <span class="n">INT128</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3302"><a href="#DataType-3302"><span class="linenos">3302</span></a> <span class="n">INT256</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3303"><a href="#DataType-3303"><span class="linenos">3303</span></a> <span class="n">INTERVAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3304"><a href="#DataType-3304"><span class="linenos">3304</span></a> <span class="n">JSON</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3305"><a href="#DataType-3305"><span class="linenos">3305</span></a> <span class="n">JSONB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3306"><a href="#DataType-3306"><span class="linenos">3306</span></a> <span class="n">LONGBLOB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3307"><a href="#DataType-3307"><span class="linenos">3307</span></a> <span class="n">LONGTEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3308"><a href="#DataType-3308"><span class="linenos">3308</span></a> <span class="n">MAP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3309"><a href="#DataType-3309"><span class="linenos">3309</span></a> <span class="n">MEDIUMBLOB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3310"><a href="#DataType-3310"><span class="linenos">3310</span></a> <span class="n">MEDIUMTEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3311"><a href="#DataType-3311"><span class="linenos">3311</span></a> <span class="n">MONEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3312"><a href="#DataType-3312"><span class="linenos">3312</span></a> <span class="n">NCHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3313"><a href="#DataType-3313"><span class="linenos">3313</span></a> <span class="n">NULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3314"><a href="#DataType-3314"><span class="linenos">3314</span></a> <span class="n">NULLABLE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3315"><a href="#DataType-3315"><span class="linenos">3315</span></a> <span class="n">NVARCHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3316"><a href="#DataType-3316"><span class="linenos">3316</span></a> <span class="n">OBJECT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3317"><a href="#DataType-3317"><span class="linenos">3317</span></a> <span class="n">ROWVERSION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3318"><a href="#DataType-3318"><span class="linenos">3318</span></a> <span class="n">SERIAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3319"><a href="#DataType-3319"><span class="linenos">3319</span></a> <span class="n">SET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3320"><a href="#DataType-3320"><span class="linenos">3320</span></a> <span class="n">SMALLINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3321"><a href="#DataType-3321"><span class="linenos">3321</span></a> <span class="n">SMALLMONEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3322"><a href="#DataType-3322"><span class="linenos">3322</span></a> <span class="n">SMALLSERIAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3323"><a href="#DataType-3323"><span class="linenos">3323</span></a> <span class="n">STRUCT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3324"><a href="#DataType-3324"><span class="linenos">3324</span></a> <span class="n">SUPER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3325"><a href="#DataType-3325"><span class="linenos">3325</span></a> <span class="n">TEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3326"><a href="#DataType-3326"><span class="linenos">3326</span></a> <span class="n">TIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3327"><a href="#DataType-3327"><span class="linenos">3327</span></a> <span class="n">TIMESTAMP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3328"><a href="#DataType-3328"><span class="linenos">3328</span></a> <span class="n">TIMESTAMPTZ</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3329"><a href="#DataType-3329"><span class="linenos">3329</span></a> <span class="n">TIMESTAMPLTZ</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3330"><a href="#DataType-3330"><span class="linenos">3330</span></a> <span class="n">TINYINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3331"><a href="#DataType-3331"><span class="linenos">3331</span></a> <span class="n">UBIGINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3332"><a href="#DataType-3332"><span class="linenos">3332</span></a> <span class="n">UINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3333"><a href="#DataType-3333"><span class="linenos">3333</span></a> <span class="n">USMALLINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3334"><a href="#DataType-3334"><span class="linenos">3334</span></a> <span class="n">UTINYINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3335"><a href="#DataType-3335"><span class="linenos">3335</span></a> <span class="n">UNKNOWN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> <span class="c1"># Sentinel value, useful for type annotation</span> +</span><span id="DataType-3336"><a href="#DataType-3336"><span class="linenos">3336</span></a> <span class="n">UINT128</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3337"><a href="#DataType-3337"><span class="linenos">3337</span></a> <span class="n">UINT256</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3338"><a href="#DataType-3338"><span class="linenos">3338</span></a> <span class="n">UNIQUEIDENTIFIER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3339"><a href="#DataType-3339"><span class="linenos">3339</span></a> <span class="n">UUID</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3340"><a href="#DataType-3340"><span class="linenos">3340</span></a> <span class="n">VARBINARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3341"><a href="#DataType-3341"><span class="linenos">3341</span></a> <span class="n">VARCHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3342"><a href="#DataType-3342"><span class="linenos">3342</span></a> <span class="n">VARIANT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3343"><a href="#DataType-3343"><span class="linenos">3343</span></a> <span class="n">XML</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType-3344"><a href="#DataType-3344"><span class="linenos">3344</span></a> +</span><span id="DataType-3345"><a href="#DataType-3345"><span class="linenos">3345</span></a> <span class="n">TEXT_TYPES</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DataType-3346"><a href="#DataType-3346"><span class="linenos">3346</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span> +</span><span id="DataType-3347"><a href="#DataType-3347"><span class="linenos">3347</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">,</span> +</span><span id="DataType-3348"><a href="#DataType-3348"><span class="linenos">3348</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> +</span><span id="DataType-3349"><a href="#DataType-3349"><span class="linenos">3349</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">,</span> +</span><span id="DataType-3350"><a href="#DataType-3350"><span class="linenos">3350</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TEXT</span><span class="p">,</span> +</span><span id="DataType-3351"><a href="#DataType-3351"><span class="linenos">3351</span></a> <span class="p">}</span> +</span><span id="DataType-3352"><a href="#DataType-3352"><span class="linenos">3352</span></a> +</span><span id="DataType-3353"><a href="#DataType-3353"><span class="linenos">3353</span></a> <span class="n">INTEGER_TYPES</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DataType-3354"><a href="#DataType-3354"><span class="linenos">3354</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">,</span> +</span><span id="DataType-3355"><a href="#DataType-3355"><span class="linenos">3355</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">,</span> +</span><span id="DataType-3356"><a href="#DataType-3356"><span class="linenos">3356</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> +</span><span id="DataType-3357"><a href="#DataType-3357"><span class="linenos">3357</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> +</span><span id="DataType-3358"><a href="#DataType-3358"><span class="linenos">3358</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">INT128</span><span class="p">,</span> +</span><span id="DataType-3359"><a href="#DataType-3359"><span class="linenos">3359</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">INT256</span><span class="p">,</span> +</span><span id="DataType-3360"><a href="#DataType-3360"><span class="linenos">3360</span></a> <span class="p">}</span> +</span><span id="DataType-3361"><a href="#DataType-3361"><span class="linenos">3361</span></a> +</span><span id="DataType-3362"><a href="#DataType-3362"><span class="linenos">3362</span></a> <span class="n">FLOAT_TYPES</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DataType-3363"><a href="#DataType-3363"><span class="linenos">3363</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span> +</span><span id="DataType-3364"><a href="#DataType-3364"><span class="linenos">3364</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> +</span><span id="DataType-3365"><a href="#DataType-3365"><span class="linenos">3365</span></a> <span class="p">}</span> </span><span id="DataType-3366"><a href="#DataType-3366"><span class="linenos">3366</span></a> -</span><span id="DataType-3367"><a href="#DataType-3367"><span class="linenos">3367</span></a> <span class="n">TEMPORAL_TYPES</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="DataType-3368"><a href="#DataType-3368"><span class="linenos">3368</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TIME</span><span class="p">,</span> -</span><span id="DataType-3369"><a href="#DataType-3369"><span class="linenos">3369</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> -</span><span id="DataType-3370"><a href="#DataType-3370"><span class="linenos">3370</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> -</span><span id="DataType-3371"><a href="#DataType-3371"><span class="linenos">3371</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">,</span> -</span><span id="DataType-3372"><a href="#DataType-3372"><span class="linenos">3372</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">DATE</span><span class="p">,</span> -</span><span id="DataType-3373"><a href="#DataType-3373"><span class="linenos">3373</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">DATETIME</span><span class="p">,</span> -</span><span id="DataType-3374"><a href="#DataType-3374"><span class="linenos">3374</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">DATETIME64</span><span class="p">,</span> -</span><span id="DataType-3375"><a href="#DataType-3375"><span class="linenos">3375</span></a> <span class="p">}</span> -</span><span id="DataType-3376"><a href="#DataType-3376"><span class="linenos">3376</span></a> -</span><span id="DataType-3377"><a href="#DataType-3377"><span class="linenos">3377</span></a> <span class="nd">@classmethod</span> -</span><span id="DataType-3378"><a href="#DataType-3378"><span class="linenos">3378</span></a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span> -</span><span id="DataType-3379"><a href="#DataType-3379"><span class="linenos">3379</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">dtype</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> -</span><span id="DataType-3380"><a href="#DataType-3380"><span class="linenos">3380</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataType</span><span class="p">:</span> -</span><span id="DataType-3381"><a href="#DataType-3381"><span class="linenos">3381</span></a> <span class="kn">from</span> <span class="nn">sqlglot</span> <span class="kn">import</span> <span class="n">parse_one</span> -</span><span id="DataType-3382"><a href="#DataType-3382"><span class="linenos">3382</span></a> -</span><span id="DataType-3383"><a href="#DataType-3383"><span class="linenos">3383</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="DataType-3384"><a href="#DataType-3384"><span class="linenos">3384</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"UNKNOWN"</span><span class="p">:</span> -</span><span id="DataType-3385"><a href="#DataType-3385"><span class="linenos">3385</span></a> <span class="n">data_type_exp</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">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UNKNOWN</span><span class="p">)</span> -</span><span id="DataType-3386"><a href="#DataType-3386"><span class="linenos">3386</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataType-3387"><a href="#DataType-3387"><span class="linenos">3387</span></a> <span class="n">data_type_exp</span> <span class="o">=</span> <span class="n">parse_one</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">read</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">DataType</span><span class="p">)</span> -</span><span id="DataType-3388"><a href="#DataType-3388"><span class="linenos">3388</span></a> -</span><span id="DataType-3389"><a href="#DataType-3389"><span class="linenos">3389</span></a> <span class="k">if</span> <span class="n">data_type_exp</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="DataType-3390"><a href="#DataType-3390"><span class="linenos">3390</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unparsable data type value: </span><span class="si">{</span><span class="n">dtype</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="DataType-3391"><a href="#DataType-3391"><span class="linenos">3391</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">):</span> -</span><span id="DataType-3392"><a href="#DataType-3392"><span class="linenos">3392</span></a> <span class="n">data_type_exp</span> <span class="o">=</span> <span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">dtype</span><span class="p">)</span> -</span><span id="DataType-3393"><a href="#DataType-3393"><span class="linenos">3393</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">DataType</span><span class="p">):</span> -</span><span id="DataType-3394"><a href="#DataType-3394"><span class="linenos">3394</span></a> <span class="k">return</span> <span class="n">dtype</span> -</span><span id="DataType-3395"><a href="#DataType-3395"><span class="linenos">3395</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataType-3396"><a href="#DataType-3396"><span class="linenos">3396</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid data type: </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span><span class="si">}</span><span class="s2">. Expected str or DataType.Type"</span><span class="p">)</span> -</span><span id="DataType-3397"><a href="#DataType-3397"><span class="linenos">3397</span></a> -</span><span id="DataType-3398"><a href="#DataType-3398"><span class="linenos">3398</span></a> <span class="k">return</span> <span class="n">DataType</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="o">**</span><span class="n">data_type_exp</span><span class="o">.</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">})</span> -</span><span id="DataType-3399"><a href="#DataType-3399"><span class="linenos">3399</span></a> -</span><span id="DataType-3400"><a href="#DataType-3400"><span class="linenos">3400</span></a> <span class="k">def</span> <span class="nf">is_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">dtypes</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="DataType-3401"><a href="#DataType-3401"><span class="linenos">3401</span></a> <span class="k">return</span> <span class="nb">any</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">this</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="n">dtype</span><span class="p">)</span><span class="o">.</span><span class="n">this</span> <span class="k">for</span> <span class="n">dtype</span> <span class="ow">in</span> <span class="n">dtypes</span><span class="p">)</span> +</span><span id="DataType-3367"><a href="#DataType-3367"><span class="linenos">3367</span></a> <span class="n">NUMERIC_TYPES</span> <span class="o">=</span> <span class="p">{</span><span class="o">*</span><span class="n">INTEGER_TYPES</span><span class="p">,</span> <span class="o">*</span><span class="n">FLOAT_TYPES</span><span class="p">}</span> +</span><span id="DataType-3368"><a href="#DataType-3368"><span class="linenos">3368</span></a> +</span><span id="DataType-3369"><a href="#DataType-3369"><span class="linenos">3369</span></a> <span class="n">TEMPORAL_TYPES</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="DataType-3370"><a href="#DataType-3370"><span class="linenos">3370</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TIME</span><span class="p">,</span> +</span><span id="DataType-3371"><a href="#DataType-3371"><span class="linenos">3371</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMP</span><span class="p">,</span> +</span><span id="DataType-3372"><a href="#DataType-3372"><span class="linenos">3372</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> +</span><span id="DataType-3373"><a href="#DataType-3373"><span class="linenos">3373</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">,</span> +</span><span id="DataType-3374"><a href="#DataType-3374"><span class="linenos">3374</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">DATE</span><span class="p">,</span> +</span><span id="DataType-3375"><a href="#DataType-3375"><span class="linenos">3375</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">DATETIME</span><span class="p">,</span> +</span><span id="DataType-3376"><a href="#DataType-3376"><span class="linenos">3376</span></a> <span class="n">Type</span><span class="o">.</span><span class="n">DATETIME64</span><span class="p">,</span> +</span><span id="DataType-3377"><a href="#DataType-3377"><span class="linenos">3377</span></a> <span class="p">}</span> +</span><span id="DataType-3378"><a href="#DataType-3378"><span class="linenos">3378</span></a> +</span><span id="DataType-3379"><a href="#DataType-3379"><span class="linenos">3379</span></a> <span class="n">META_TYPES</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"UNKNOWN"</span><span class="p">,</span> <span class="s2">"NULL"</span><span class="p">}</span> +</span><span id="DataType-3380"><a href="#DataType-3380"><span class="linenos">3380</span></a> +</span><span id="DataType-3381"><a href="#DataType-3381"><span class="linenos">3381</span></a> <span class="nd">@classmethod</span> +</span><span id="DataType-3382"><a href="#DataType-3382"><span class="linenos">3382</span></a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span> +</span><span id="DataType-3383"><a href="#DataType-3383"><span class="linenos">3383</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">dtype</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> +</span><span id="DataType-3384"><a href="#DataType-3384"><span class="linenos">3384</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataType</span><span class="p">:</span> +</span><span id="DataType-3385"><a href="#DataType-3385"><span class="linenos">3385</span></a> <span class="kn">from</span> <span class="nn">sqlglot</span> <span class="kn">import</span> <span class="n">parse_one</span> +</span><span id="DataType-3386"><a href="#DataType-3386"><span class="linenos">3386</span></a> +</span><span id="DataType-3387"><a href="#DataType-3387"><span class="linenos">3387</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="DataType-3388"><a href="#DataType-3388"><span class="linenos">3388</span></a> <span class="n">upper</span> <span class="o">=</span> <span class="n">dtype</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="DataType-3389"><a href="#DataType-3389"><span class="linenos">3389</span></a> <span class="k">if</span> <span class="n">upper</span> <span class="ow">in</span> <span class="n">DataType</span><span class="o">.</span><span class="n">META_TYPES</span><span class="p">:</span> +</span><span id="DataType-3390"><a href="#DataType-3390"><span class="linenos">3390</span></a> <span class="n">data_type_exp</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">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">upper</span><span class="p">])</span> +</span><span id="DataType-3391"><a href="#DataType-3391"><span class="linenos">3391</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataType-3392"><a href="#DataType-3392"><span class="linenos">3392</span></a> <span class="n">data_type_exp</span> <span class="o">=</span> <span class="n">parse_one</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">read</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">DataType</span><span class="p">)</span> +</span><span id="DataType-3393"><a href="#DataType-3393"><span class="linenos">3393</span></a> +</span><span id="DataType-3394"><a href="#DataType-3394"><span class="linenos">3394</span></a> <span class="k">if</span> <span class="n">data_type_exp</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="DataType-3395"><a href="#DataType-3395"><span class="linenos">3395</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unparsable data type value: </span><span class="si">{</span><span class="n">dtype</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="DataType-3396"><a href="#DataType-3396"><span class="linenos">3396</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">):</span> +</span><span id="DataType-3397"><a href="#DataType-3397"><span class="linenos">3397</span></a> <span class="n">data_type_exp</span> <span class="o">=</span> <span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">dtype</span><span class="p">)</span> +</span><span id="DataType-3398"><a href="#DataType-3398"><span class="linenos">3398</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">DataType</span><span class="p">):</span> +</span><span id="DataType-3399"><a href="#DataType-3399"><span class="linenos">3399</span></a> <span class="k">return</span> <span class="n">dtype</span> +</span><span id="DataType-3400"><a href="#DataType-3400"><span class="linenos">3400</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataType-3401"><a href="#DataType-3401"><span class="linenos">3401</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid data type: </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span><span class="si">}</span><span class="s2">. Expected str or DataType.Type"</span><span class="p">)</span> +</span><span id="DataType-3402"><a href="#DataType-3402"><span class="linenos">3402</span></a> +</span><span id="DataType-3403"><a href="#DataType-3403"><span class="linenos">3403</span></a> <span class="k">return</span> <span class="n">DataType</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="o">**</span><span class="n">data_type_exp</span><span class="o">.</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">})</span> +</span><span id="DataType-3404"><a href="#DataType-3404"><span class="linenos">3404</span></a> +</span><span id="DataType-3405"><a href="#DataType-3405"><span class="linenos">3405</span></a> <span class="k">def</span> <span class="nf">is_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">dtypes</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="DataType-3406"><a href="#DataType-3406"><span class="linenos">3406</span></a> <span class="k">return</span> <span class="nb">any</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">this</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="n">dtype</span><span class="p">)</span><span class="o">.</span><span class="n">this</span> <span class="k">for</span> <span class="n">dtype</span> <span class="ow">in</span> <span class="n">dtypes</span><span class="p">)</span> </span></pre></div> @@ -27927,28 +28054,29 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#DataType.build"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataType.build-3377"><a href="#DataType.build-3377"><span class="linenos">3377</span></a> <span class="nd">@classmethod</span> -</span><span id="DataType.build-3378"><a href="#DataType.build-3378"><span class="linenos">3378</span></a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span> -</span><span id="DataType.build-3379"><a href="#DataType.build-3379"><span class="linenos">3379</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">dtype</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> -</span><span id="DataType.build-3380"><a href="#DataType.build-3380"><span class="linenos">3380</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataType</span><span class="p">:</span> -</span><span id="DataType.build-3381"><a href="#DataType.build-3381"><span class="linenos">3381</span></a> <span class="kn">from</span> <span class="nn">sqlglot</span> <span class="kn">import</span> <span class="n">parse_one</span> -</span><span id="DataType.build-3382"><a href="#DataType.build-3382"><span class="linenos">3382</span></a> -</span><span id="DataType.build-3383"><a href="#DataType.build-3383"><span class="linenos">3383</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="DataType.build-3384"><a href="#DataType.build-3384"><span class="linenos">3384</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"UNKNOWN"</span><span class="p">:</span> -</span><span id="DataType.build-3385"><a href="#DataType.build-3385"><span class="linenos">3385</span></a> <span class="n">data_type_exp</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">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">UNKNOWN</span><span class="p">)</span> -</span><span id="DataType.build-3386"><a href="#DataType.build-3386"><span class="linenos">3386</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataType.build-3387"><a href="#DataType.build-3387"><span class="linenos">3387</span></a> <span class="n">data_type_exp</span> <span class="o">=</span> <span class="n">parse_one</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">read</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">DataType</span><span class="p">)</span> -</span><span id="DataType.build-3388"><a href="#DataType.build-3388"><span class="linenos">3388</span></a> -</span><span id="DataType.build-3389"><a href="#DataType.build-3389"><span class="linenos">3389</span></a> <span class="k">if</span> <span class="n">data_type_exp</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="DataType.build-3390"><a href="#DataType.build-3390"><span class="linenos">3390</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unparsable data type value: </span><span class="si">{</span><span class="n">dtype</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="DataType.build-3391"><a href="#DataType.build-3391"><span class="linenos">3391</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">):</span> -</span><span id="DataType.build-3392"><a href="#DataType.build-3392"><span class="linenos">3392</span></a> <span class="n">data_type_exp</span> <span class="o">=</span> <span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">dtype</span><span class="p">)</span> -</span><span id="DataType.build-3393"><a href="#DataType.build-3393"><span class="linenos">3393</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">DataType</span><span class="p">):</span> -</span><span id="DataType.build-3394"><a href="#DataType.build-3394"><span class="linenos">3394</span></a> <span class="k">return</span> <span class="n">dtype</span> -</span><span id="DataType.build-3395"><a href="#DataType.build-3395"><span class="linenos">3395</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="DataType.build-3396"><a href="#DataType.build-3396"><span class="linenos">3396</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid data type: </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span><span class="si">}</span><span class="s2">. Expected str or DataType.Type"</span><span class="p">)</span> -</span><span id="DataType.build-3397"><a href="#DataType.build-3397"><span class="linenos">3397</span></a> -</span><span id="DataType.build-3398"><a href="#DataType.build-3398"><span class="linenos">3398</span></a> <span class="k">return</span> <span class="n">DataType</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="o">**</span><span class="n">data_type_exp</span><span class="o">.</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">})</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataType.build-3381"><a href="#DataType.build-3381"><span class="linenos">3381</span></a> <span class="nd">@classmethod</span> +</span><span id="DataType.build-3382"><a href="#DataType.build-3382"><span class="linenos">3382</span></a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span> +</span><span id="DataType.build-3383"><a href="#DataType.build-3383"><span class="linenos">3383</span></a> <span class="bp">cls</span><span class="p">,</span> <span class="n">dtype</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> +</span><span id="DataType.build-3384"><a href="#DataType.build-3384"><span class="linenos">3384</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">DataType</span><span class="p">:</span> +</span><span id="DataType.build-3385"><a href="#DataType.build-3385"><span class="linenos">3385</span></a> <span class="kn">from</span> <span class="nn">sqlglot</span> <span class="kn">import</span> <span class="n">parse_one</span> +</span><span id="DataType.build-3386"><a href="#DataType.build-3386"><span class="linenos">3386</span></a> +</span><span id="DataType.build-3387"><a href="#DataType.build-3387"><span class="linenos">3387</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="DataType.build-3388"><a href="#DataType.build-3388"><span class="linenos">3388</span></a> <span class="n">upper</span> <span class="o">=</span> <span class="n">dtype</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="DataType.build-3389"><a href="#DataType.build-3389"><span class="linenos">3389</span></a> <span class="k">if</span> <span class="n">upper</span> <span class="ow">in</span> <span class="n">DataType</span><span class="o">.</span><span class="n">META_TYPES</span><span class="p">:</span> +</span><span id="DataType.build-3390"><a href="#DataType.build-3390"><span class="linenos">3390</span></a> <span class="n">data_type_exp</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">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">upper</span><span class="p">])</span> +</span><span id="DataType.build-3391"><a href="#DataType.build-3391"><span class="linenos">3391</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataType.build-3392"><a href="#DataType.build-3392"><span class="linenos">3392</span></a> <span class="n">data_type_exp</span> <span class="o">=</span> <span class="n">parse_one</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">read</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">DataType</span><span class="p">)</span> +</span><span id="DataType.build-3393"><a href="#DataType.build-3393"><span class="linenos">3393</span></a> +</span><span id="DataType.build-3394"><a href="#DataType.build-3394"><span class="linenos">3394</span></a> <span class="k">if</span> <span class="n">data_type_exp</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="DataType.build-3395"><a href="#DataType.build-3395"><span class="linenos">3395</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unparsable data type value: </span><span class="si">{</span><span class="n">dtype</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="DataType.build-3396"><a href="#DataType.build-3396"><span class="linenos">3396</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">):</span> +</span><span id="DataType.build-3397"><a href="#DataType.build-3397"><span class="linenos">3397</span></a> <span class="n">data_type_exp</span> <span class="o">=</span> <span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">dtype</span><span class="p">)</span> +</span><span id="DataType.build-3398"><a href="#DataType.build-3398"><span class="linenos">3398</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">DataType</span><span class="p">):</span> +</span><span id="DataType.build-3399"><a href="#DataType.build-3399"><span class="linenos">3399</span></a> <span class="k">return</span> <span class="n">dtype</span> +</span><span id="DataType.build-3400"><a href="#DataType.build-3400"><span class="linenos">3400</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="DataType.build-3401"><a href="#DataType.build-3401"><span class="linenos">3401</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid data type: </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span><span class="si">}</span><span class="s2">. Expected str or DataType.Type"</span><span class="p">)</span> +</span><span id="DataType.build-3402"><a href="#DataType.build-3402"><span class="linenos">3402</span></a> +</span><span id="DataType.build-3403"><a href="#DataType.build-3403"><span class="linenos">3403</span></a> <span class="k">return</span> <span class="n">DataType</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="o">**</span><span class="n">data_type_exp</span><span class="o">.</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">})</span> </span></pre></div> @@ -27966,8 +28094,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#DataType.is_type"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataType.is_type-3400"><a href="#DataType.is_type-3400"><span class="linenos">3400</span></a> <span class="k">def</span> <span class="nf">is_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">dtypes</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="DataType.is_type-3401"><a href="#DataType.is_type-3401"><span class="linenos">3401</span></a> <span class="k">return</span> <span class="nb">any</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">this</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="n">dtype</span><span class="p">)</span><span class="o">.</span><span class="n">this</span> <span class="k">for</span> <span class="n">dtype</span> <span class="ow">in</span> <span class="n">dtypes</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataType.is_type-3405"><a href="#DataType.is_type-3405"><span class="linenos">3405</span></a> <span class="k">def</span> <span class="nf">is_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">dtypes</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="DataType.is_type-3406"><a href="#DataType.is_type-3406"><span class="linenos">3406</span></a> <span class="k">return</span> <span class="nb">any</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">this</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="n">dtype</span><span class="p">)</span><span class="o">.</span><span class="n">this</span> <span class="k">for</span> <span class="n">dtype</span> <span class="ow">in</span> <span class="n">dtypes</span><span class="p">)</span> </span></pre></div> @@ -28032,84 +28160,84 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#DataType.Type"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DataType.Type-3264"><a href="#DataType.Type-3264"><span class="linenos">3264</span></a> <span class="k">class</span> <span class="nc">Type</span><span class="p">(</span><span class="n">AutoName</span><span class="p">):</span> -</span><span id="DataType.Type-3265"><a href="#DataType.Type-3265"><span class="linenos">3265</span></a> <span class="n">ARRAY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3266"><a href="#DataType.Type-3266"><span class="linenos">3266</span></a> <span class="n">BIGDECIMAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3267"><a href="#DataType.Type-3267"><span class="linenos">3267</span></a> <span class="n">BIGINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3268"><a href="#DataType.Type-3268"><span class="linenos">3268</span></a> <span class="n">BIGSERIAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3269"><a href="#DataType.Type-3269"><span class="linenos">3269</span></a> <span class="n">BINARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3270"><a href="#DataType.Type-3270"><span class="linenos">3270</span></a> <span class="n">BIT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3271"><a href="#DataType.Type-3271"><span class="linenos">3271</span></a> <span class="n">BOOLEAN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3272"><a href="#DataType.Type-3272"><span class="linenos">3272</span></a> <span class="n">CHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3273"><a href="#DataType.Type-3273"><span class="linenos">3273</span></a> <span class="n">DATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3274"><a href="#DataType.Type-3274"><span class="linenos">3274</span></a> <span class="n">DATETIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3275"><a href="#DataType.Type-3275"><span class="linenos">3275</span></a> <span class="n">DATETIME64</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3276"><a href="#DataType.Type-3276"><span class="linenos">3276</span></a> <span class="n">ENUM</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3277"><a href="#DataType.Type-3277"><span class="linenos">3277</span></a> <span class="n">INT4RANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3278"><a href="#DataType.Type-3278"><span class="linenos">3278</span></a> <span class="n">INT4MULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3279"><a href="#DataType.Type-3279"><span class="linenos">3279</span></a> <span class="n">INT8RANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3280"><a href="#DataType.Type-3280"><span class="linenos">3280</span></a> <span class="n">INT8MULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3281"><a href="#DataType.Type-3281"><span class="linenos">3281</span></a> <span class="n">NUMRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3282"><a href="#DataType.Type-3282"><span class="linenos">3282</span></a> <span class="n">NUMMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3283"><a href="#DataType.Type-3283"><span class="linenos">3283</span></a> <span class="n">TSRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3284"><a href="#DataType.Type-3284"><span class="linenos">3284</span></a> <span class="n">TSMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3285"><a href="#DataType.Type-3285"><span class="linenos">3285</span></a> <span class="n">TSTZRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3286"><a href="#DataType.Type-3286"><span class="linenos">3286</span></a> <span class="n">TSTZMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3287"><a href="#DataType.Type-3287"><span class="linenos">3287</span></a> <span class="n">DATERANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3288"><a href="#DataType.Type-3288"><span class="linenos">3288</span></a> <span class="n">DATEMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3289"><a href="#DataType.Type-3289"><span class="linenos">3289</span></a> <span class="n">DECIMAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3290"><a href="#DataType.Type-3290"><span class="linenos">3290</span></a> <span class="n">DOUBLE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3291"><a href="#DataType.Type-3291"><span class="linenos">3291</span></a> <span class="n">FLOAT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3292"><a href="#DataType.Type-3292"><span class="linenos">3292</span></a> <span class="n">GEOGRAPHY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3293"><a href="#DataType.Type-3293"><span class="linenos">3293</span></a> <span class="n">GEOMETRY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3294"><a href="#DataType.Type-3294"><span class="linenos">3294</span></a> <span class="n">HLLSKETCH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3295"><a href="#DataType.Type-3295"><span class="linenos">3295</span></a> <span class="n">HSTORE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3296"><a href="#DataType.Type-3296"><span class="linenos">3296</span></a> <span class="n">IMAGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3297"><a href="#DataType.Type-3297"><span class="linenos">3297</span></a> <span class="n">INET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3298"><a href="#DataType.Type-3298"><span class="linenos">3298</span></a> <span class="n">INT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3299"><a href="#DataType.Type-3299"><span class="linenos">3299</span></a> <span class="n">INT128</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3300"><a href="#DataType.Type-3300"><span class="linenos">3300</span></a> <span class="n">INT256</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3301"><a href="#DataType.Type-3301"><span class="linenos">3301</span></a> <span class="n">INTERVAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3302"><a href="#DataType.Type-3302"><span class="linenos">3302</span></a> <span class="n">JSON</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3303"><a href="#DataType.Type-3303"><span class="linenos">3303</span></a> <span class="n">JSONB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3304"><a href="#DataType.Type-3304"><span class="linenos">3304</span></a> <span class="n">LONGBLOB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3305"><a href="#DataType.Type-3305"><span class="linenos">3305</span></a> <span class="n">LONGTEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3306"><a href="#DataType.Type-3306"><span class="linenos">3306</span></a> <span class="n">MAP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3307"><a href="#DataType.Type-3307"><span class="linenos">3307</span></a> <span class="n">MEDIUMBLOB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3308"><a href="#DataType.Type-3308"><span class="linenos">3308</span></a> <span class="n">MEDIUMTEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3309"><a href="#DataType.Type-3309"><span class="linenos">3309</span></a> <span class="n">MONEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3310"><a href="#DataType.Type-3310"><span class="linenos">3310</span></a> <span class="n">NCHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3311"><a href="#DataType.Type-3311"><span class="linenos">3311</span></a> <span class="n">NULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3312"><a href="#DataType.Type-3312"><span class="linenos">3312</span></a> <span class="n">NULLABLE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3313"><a href="#DataType.Type-3313"><span class="linenos">3313</span></a> <span class="n">NVARCHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3314"><a href="#DataType.Type-3314"><span class="linenos">3314</span></a> <span class="n">OBJECT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3315"><a href="#DataType.Type-3315"><span class="linenos">3315</span></a> <span class="n">ROWVERSION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3316"><a href="#DataType.Type-3316"><span class="linenos">3316</span></a> <span class="n">SERIAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3317"><a href="#DataType.Type-3317"><span class="linenos">3317</span></a> <span class="n">SET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3318"><a href="#DataType.Type-3318"><span class="linenos">3318</span></a> <span class="n">SMALLINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3319"><a href="#DataType.Type-3319"><span class="linenos">3319</span></a> <span class="n">SMALLMONEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3320"><a href="#DataType.Type-3320"><span class="linenos">3320</span></a> <span class="n">SMALLSERIAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3321"><a href="#DataType.Type-3321"><span class="linenos">3321</span></a> <span class="n">STRUCT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3322"><a href="#DataType.Type-3322"><span class="linenos">3322</span></a> <span class="n">SUPER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3323"><a href="#DataType.Type-3323"><span class="linenos">3323</span></a> <span class="n">TEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3324"><a href="#DataType.Type-3324"><span class="linenos">3324</span></a> <span class="n">TIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3325"><a href="#DataType.Type-3325"><span class="linenos">3325</span></a> <span class="n">TIMESTAMP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3326"><a href="#DataType.Type-3326"><span class="linenos">3326</span></a> <span class="n">TIMESTAMPTZ</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3327"><a href="#DataType.Type-3327"><span class="linenos">3327</span></a> <span class="n">TIMESTAMPLTZ</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3328"><a href="#DataType.Type-3328"><span class="linenos">3328</span></a> <span class="n">TINYINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3329"><a href="#DataType.Type-3329"><span class="linenos">3329</span></a> <span class="n">UBIGINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3330"><a href="#DataType.Type-3330"><span class="linenos">3330</span></a> <span class="n">UINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3331"><a href="#DataType.Type-3331"><span class="linenos">3331</span></a> <span class="n">USMALLINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3332"><a href="#DataType.Type-3332"><span class="linenos">3332</span></a> <span class="n">UTINYINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3333"><a href="#DataType.Type-3333"><span class="linenos">3333</span></a> <span class="n">UNKNOWN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> <span class="c1"># Sentinel value, useful for type annotation</span> -</span><span id="DataType.Type-3334"><a href="#DataType.Type-3334"><span class="linenos">3334</span></a> <span class="n">UINT128</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3335"><a href="#DataType.Type-3335"><span class="linenos">3335</span></a> <span class="n">UINT256</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3336"><a href="#DataType.Type-3336"><span class="linenos">3336</span></a> <span class="n">UNIQUEIDENTIFIER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3337"><a href="#DataType.Type-3337"><span class="linenos">3337</span></a> <span class="n">UUID</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3338"><a href="#DataType.Type-3338"><span class="linenos">3338</span></a> <span class="n">VARBINARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3339"><a href="#DataType.Type-3339"><span class="linenos">3339</span></a> <span class="n">VARCHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3340"><a href="#DataType.Type-3340"><span class="linenos">3340</span></a> <span class="n">VARIANT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="DataType.Type-3341"><a href="#DataType.Type-3341"><span class="linenos">3341</span></a> <span class="n">XML</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DataType.Type-3266"><a href="#DataType.Type-3266"><span class="linenos">3266</span></a> <span class="k">class</span> <span class="nc">Type</span><span class="p">(</span><span class="n">AutoName</span><span class="p">):</span> +</span><span id="DataType.Type-3267"><a href="#DataType.Type-3267"><span class="linenos">3267</span></a> <span class="n">ARRAY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3268"><a href="#DataType.Type-3268"><span class="linenos">3268</span></a> <span class="n">BIGDECIMAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3269"><a href="#DataType.Type-3269"><span class="linenos">3269</span></a> <span class="n">BIGINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3270"><a href="#DataType.Type-3270"><span class="linenos">3270</span></a> <span class="n">BIGSERIAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3271"><a href="#DataType.Type-3271"><span class="linenos">3271</span></a> <span class="n">BINARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3272"><a href="#DataType.Type-3272"><span class="linenos">3272</span></a> <span class="n">BIT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3273"><a href="#DataType.Type-3273"><span class="linenos">3273</span></a> <span class="n">BOOLEAN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3274"><a href="#DataType.Type-3274"><span class="linenos">3274</span></a> <span class="n">CHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3275"><a href="#DataType.Type-3275"><span class="linenos">3275</span></a> <span class="n">DATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3276"><a href="#DataType.Type-3276"><span class="linenos">3276</span></a> <span class="n">DATETIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3277"><a href="#DataType.Type-3277"><span class="linenos">3277</span></a> <span class="n">DATETIME64</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3278"><a href="#DataType.Type-3278"><span class="linenos">3278</span></a> <span class="n">ENUM</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3279"><a href="#DataType.Type-3279"><span class="linenos">3279</span></a> <span class="n">INT4RANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3280"><a href="#DataType.Type-3280"><span class="linenos">3280</span></a> <span class="n">INT4MULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3281"><a href="#DataType.Type-3281"><span class="linenos">3281</span></a> <span class="n">INT8RANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3282"><a href="#DataType.Type-3282"><span class="linenos">3282</span></a> <span class="n">INT8MULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3283"><a href="#DataType.Type-3283"><span class="linenos">3283</span></a> <span class="n">NUMRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3284"><a href="#DataType.Type-3284"><span class="linenos">3284</span></a> <span class="n">NUMMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3285"><a href="#DataType.Type-3285"><span class="linenos">3285</span></a> <span class="n">TSRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3286"><a href="#DataType.Type-3286"><span class="linenos">3286</span></a> <span class="n">TSMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3287"><a href="#DataType.Type-3287"><span class="linenos">3287</span></a> <span class="n">TSTZRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3288"><a href="#DataType.Type-3288"><span class="linenos">3288</span></a> <span class="n">TSTZMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3289"><a href="#DataType.Type-3289"><span class="linenos">3289</span></a> <span class="n">DATERANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3290"><a href="#DataType.Type-3290"><span class="linenos">3290</span></a> <span class="n">DATEMULTIRANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3291"><a href="#DataType.Type-3291"><span class="linenos">3291</span></a> <span class="n">DECIMAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3292"><a href="#DataType.Type-3292"><span class="linenos">3292</span></a> <span class="n">DOUBLE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3293"><a href="#DataType.Type-3293"><span class="linenos">3293</span></a> <span class="n">FLOAT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3294"><a href="#DataType.Type-3294"><span class="linenos">3294</span></a> <span class="n">GEOGRAPHY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3295"><a href="#DataType.Type-3295"><span class="linenos">3295</span></a> <span class="n">GEOMETRY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3296"><a href="#DataType.Type-3296"><span class="linenos">3296</span></a> <span class="n">HLLSKETCH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3297"><a href="#DataType.Type-3297"><span class="linenos">3297</span></a> <span class="n">HSTORE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3298"><a href="#DataType.Type-3298"><span class="linenos">3298</span></a> <span class="n">IMAGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3299"><a href="#DataType.Type-3299"><span class="linenos">3299</span></a> <span class="n">INET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3300"><a href="#DataType.Type-3300"><span class="linenos">3300</span></a> <span class="n">INT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3301"><a href="#DataType.Type-3301"><span class="linenos">3301</span></a> <span class="n">INT128</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3302"><a href="#DataType.Type-3302"><span class="linenos">3302</span></a> <span class="n">INT256</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3303"><a href="#DataType.Type-3303"><span class="linenos">3303</span></a> <span class="n">INTERVAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3304"><a href="#DataType.Type-3304"><span class="linenos">3304</span></a> <span class="n">JSON</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3305"><a href="#DataType.Type-3305"><span class="linenos">3305</span></a> <span class="n">JSONB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3306"><a href="#DataType.Type-3306"><span class="linenos">3306</span></a> <span class="n">LONGBLOB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3307"><a href="#DataType.Type-3307"><span class="linenos">3307</span></a> <span class="n">LONGTEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3308"><a href="#DataType.Type-3308"><span class="linenos">3308</span></a> <span class="n">MAP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3309"><a href="#DataType.Type-3309"><span class="linenos">3309</span></a> <span class="n">MEDIUMBLOB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3310"><a href="#DataType.Type-3310"><span class="linenos">3310</span></a> <span class="n">MEDIUMTEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3311"><a href="#DataType.Type-3311"><span class="linenos">3311</span></a> <span class="n">MONEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3312"><a href="#DataType.Type-3312"><span class="linenos">3312</span></a> <span class="n">NCHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3313"><a href="#DataType.Type-3313"><span class="linenos">3313</span></a> <span class="n">NULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3314"><a href="#DataType.Type-3314"><span class="linenos">3314</span></a> <span class="n">NULLABLE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3315"><a href="#DataType.Type-3315"><span class="linenos">3315</span></a> <span class="n">NVARCHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3316"><a href="#DataType.Type-3316"><span class="linenos">3316</span></a> <span class="n">OBJECT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3317"><a href="#DataType.Type-3317"><span class="linenos">3317</span></a> <span class="n">ROWVERSION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3318"><a href="#DataType.Type-3318"><span class="linenos">3318</span></a> <span class="n">SERIAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3319"><a href="#DataType.Type-3319"><span class="linenos">3319</span></a> <span class="n">SET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3320"><a href="#DataType.Type-3320"><span class="linenos">3320</span></a> <span class="n">SMALLINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3321"><a href="#DataType.Type-3321"><span class="linenos">3321</span></a> <span class="n">SMALLMONEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3322"><a href="#DataType.Type-3322"><span class="linenos">3322</span></a> <span class="n">SMALLSERIAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3323"><a href="#DataType.Type-3323"><span class="linenos">3323</span></a> <span class="n">STRUCT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3324"><a href="#DataType.Type-3324"><span class="linenos">3324</span></a> <span class="n">SUPER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3325"><a href="#DataType.Type-3325"><span class="linenos">3325</span></a> <span class="n">TEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3326"><a href="#DataType.Type-3326"><span class="linenos">3326</span></a> <span class="n">TIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3327"><a href="#DataType.Type-3327"><span class="linenos">3327</span></a> <span class="n">TIMESTAMP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3328"><a href="#DataType.Type-3328"><span class="linenos">3328</span></a> <span class="n">TIMESTAMPTZ</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3329"><a href="#DataType.Type-3329"><span class="linenos">3329</span></a> <span class="n">TIMESTAMPLTZ</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3330"><a href="#DataType.Type-3330"><span class="linenos">3330</span></a> <span class="n">TINYINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3331"><a href="#DataType.Type-3331"><span class="linenos">3331</span></a> <span class="n">UBIGINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3332"><a href="#DataType.Type-3332"><span class="linenos">3332</span></a> <span class="n">UINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3333"><a href="#DataType.Type-3333"><span class="linenos">3333</span></a> <span class="n">USMALLINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3334"><a href="#DataType.Type-3334"><span class="linenos">3334</span></a> <span class="n">UTINYINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3335"><a href="#DataType.Type-3335"><span class="linenos">3335</span></a> <span class="n">UNKNOWN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> <span class="c1"># Sentinel value, useful for type annotation</span> +</span><span id="DataType.Type-3336"><a href="#DataType.Type-3336"><span class="linenos">3336</span></a> <span class="n">UINT128</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3337"><a href="#DataType.Type-3337"><span class="linenos">3337</span></a> <span class="n">UINT256</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3338"><a href="#DataType.Type-3338"><span class="linenos">3338</span></a> <span class="n">UNIQUEIDENTIFIER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3339"><a href="#DataType.Type-3339"><span class="linenos">3339</span></a> <span class="n">UUID</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3340"><a href="#DataType.Type-3340"><span class="linenos">3340</span></a> <span class="n">VARBINARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3341"><a href="#DataType.Type-3341"><span class="linenos">3341</span></a> <span class="n">VARCHAR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3342"><a href="#DataType.Type-3342"><span class="linenos">3342</span></a> <span class="n">VARIANT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="DataType.Type-3343"><a href="#DataType.Type-3343"><span class="linenos">3343</span></a> <span class="n">XML</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> </span></pre></div> @@ -29063,8 +29191,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#PseudoType"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="PseudoType-3405"><a href="#PseudoType-3405"><span class="linenos">3405</span></a><span class="k">class</span> <span class="nc">PseudoType</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="PseudoType-3406"><a href="#PseudoType-3406"><span class="linenos">3406</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="PseudoType-3410"><a href="#PseudoType-3410"><span class="linenos">3410</span></a><span class="k">class</span> <span class="nc">PseudoType</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="PseudoType-3411"><a href="#PseudoType-3411"><span class="linenos">3411</span></a> <span class="k">pass</span> </span></pre></div> @@ -29128,8 +29256,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#SubqueryPredicate"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SubqueryPredicate-3410"><a href="#SubqueryPredicate-3410"><span class="linenos">3410</span></a><span class="k">class</span> <span class="nc">SubqueryPredicate</span><span class="p">(</span><span class="n">Predicate</span><span class="p">):</span> -</span><span id="SubqueryPredicate-3411"><a href="#SubqueryPredicate-3411"><span class="linenos">3411</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SubqueryPredicate-3415"><a href="#SubqueryPredicate-3415"><span class="linenos">3415</span></a><span class="k">class</span> <span class="nc">SubqueryPredicate</span><span class="p">(</span><span class="n">Predicate</span><span class="p">):</span> +</span><span id="SubqueryPredicate-3416"><a href="#SubqueryPredicate-3416"><span class="linenos">3416</span></a> <span class="k">pass</span> </span></pre></div> @@ -29208,8 +29336,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#All"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="All-3414"><a href="#All-3414"><span class="linenos">3414</span></a><span class="k">class</span> <span class="nc">All</span><span class="p">(</span><span class="n">SubqueryPredicate</span><span class="p">):</span> -</span><span id="All-3415"><a href="#All-3415"><span class="linenos">3415</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="All-3419"><a href="#All-3419"><span class="linenos">3419</span></a><span class="k">class</span> <span class="nc">All</span><span class="p">(</span><span class="n">SubqueryPredicate</span><span class="p">):</span> +</span><span id="All-3420"><a href="#All-3420"><span class="linenos">3420</span></a> <span class="k">pass</span> </span></pre></div> @@ -29288,8 +29416,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Any"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Any-3418"><a href="#Any-3418"><span class="linenos">3418</span></a><span class="k">class</span> <span class="nc">Any</span><span class="p">(</span><span class="n">SubqueryPredicate</span><span class="p">):</span> -</span><span id="Any-3419"><a href="#Any-3419"><span class="linenos">3419</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Any-3423"><a href="#Any-3423"><span class="linenos">3423</span></a><span class="k">class</span> <span class="nc">Any</span><span class="p">(</span><span class="n">SubqueryPredicate</span><span class="p">):</span> +</span><span id="Any-3424"><a href="#Any-3424"><span class="linenos">3424</span></a> <span class="k">pass</span> </span></pre></div> @@ -29368,8 +29496,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Exists"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Exists-3422"><a href="#Exists-3422"><span class="linenos">3422</span></a><span class="k">class</span> <span class="nc">Exists</span><span class="p">(</span><span class="n">SubqueryPredicate</span><span class="p">):</span> -</span><span id="Exists-3423"><a href="#Exists-3423"><span class="linenos">3423</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Exists-3427"><a href="#Exists-3427"><span class="linenos">3427</span></a><span class="k">class</span> <span class="nc">Exists</span><span class="p">(</span><span class="n">SubqueryPredicate</span><span class="p">):</span> +</span><span id="Exists-3428"><a href="#Exists-3428"><span class="linenos">3428</span></a> <span class="k">pass</span> </span></pre></div> @@ -29448,8 +29576,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Command"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Command-3428"><a href="#Command-3428"><span class="linenos">3428</span></a><span class="k">class</span> <span class="nc">Command</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Command-3429"><a href="#Command-3429"><span class="linenos">3429</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Command-3433"><a href="#Command-3433"><span class="linenos">3433</span></a><span class="k">class</span> <span class="nc">Command</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Command-3434"><a href="#Command-3434"><span class="linenos">3434</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -29513,8 +29641,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Transaction"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Transaction-3432"><a href="#Transaction-3432"><span class="linenos">3432</span></a><span class="k">class</span> <span class="nc">Transaction</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Transaction-3433"><a href="#Transaction-3433"><span class="linenos">3433</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"modes"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Transaction-3437"><a href="#Transaction-3437"><span class="linenos">3437</span></a><span class="k">class</span> <span class="nc">Transaction</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Transaction-3438"><a href="#Transaction-3438"><span class="linenos">3438</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"modes"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -29578,8 +29706,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Commit"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Commit-3436"><a href="#Commit-3436"><span class="linenos">3436</span></a><span class="k">class</span> <span class="nc">Commit</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Commit-3437"><a href="#Commit-3437"><span class="linenos">3437</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"chain"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Commit-3441"><a href="#Commit-3441"><span class="linenos">3441</span></a><span class="k">class</span> <span class="nc">Commit</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Commit-3442"><a href="#Commit-3442"><span class="linenos">3442</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"chain"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -29643,8 +29771,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Rollback"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Rollback-3440"><a href="#Rollback-3440"><span class="linenos">3440</span></a><span class="k">class</span> <span class="nc">Rollback</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Rollback-3441"><a href="#Rollback-3441"><span class="linenos">3441</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"savepoint"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Rollback-3445"><a href="#Rollback-3445"><span class="linenos">3445</span></a><span class="k">class</span> <span class="nc">Rollback</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Rollback-3446"><a href="#Rollback-3446"><span class="linenos">3446</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"savepoint"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -29708,8 +29836,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#AlterTable"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="AlterTable-3444"><a href="#AlterTable-3444"><span class="linenos">3444</span></a><span class="k">class</span> <span class="nc">AlterTable</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="AlterTable-3445"><a href="#AlterTable-3445"><span class="linenos">3445</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"actions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"exists"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="AlterTable-3449"><a href="#AlterTable-3449"><span class="linenos">3449</span></a><span class="k">class</span> <span class="nc">AlterTable</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="AlterTable-3450"><a href="#AlterTable-3450"><span class="linenos">3450</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"actions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"exists"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -29773,8 +29901,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#AddConstraint"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="AddConstraint-3448"><a href="#AddConstraint-3448"><span class="linenos">3448</span></a><span class="k">class</span> <span class="nc">AddConstraint</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="AddConstraint-3449"><a href="#AddConstraint-3449"><span class="linenos">3449</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"enforced"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="AddConstraint-3453"><a href="#AddConstraint-3453"><span class="linenos">3453</span></a><span class="k">class</span> <span class="nc">AddConstraint</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="AddConstraint-3454"><a href="#AddConstraint-3454"><span class="linenos">3454</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"enforced"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -29838,8 +29966,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#DropPartition"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DropPartition-3452"><a href="#DropPartition-3452"><span class="linenos">3452</span></a><span class="k">class</span> <span class="nc">DropPartition</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="DropPartition-3453"><a href="#DropPartition-3453"><span class="linenos">3453</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"exists"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DropPartition-3457"><a href="#DropPartition-3457"><span class="linenos">3457</span></a><span class="k">class</span> <span class="nc">DropPartition</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="DropPartition-3458"><a href="#DropPartition-3458"><span class="linenos">3458</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"exists"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -29903,16 +30031,16 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Binary"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Binary-3457"><a href="#Binary-3457"><span class="linenos">3457</span></a><span class="k">class</span> <span class="nc">Binary</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> -</span><span id="Binary-3458"><a href="#Binary-3458"><span class="linenos">3458</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="Binary-3459"><a href="#Binary-3459"><span class="linenos">3459</span></a> -</span><span id="Binary-3460"><a href="#Binary-3460"><span class="linenos">3460</span></a> <span class="nd">@property</span> -</span><span id="Binary-3461"><a href="#Binary-3461"><span class="linenos">3461</span></a> <span class="k">def</span> <span class="nf">left</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Binary-3462"><a href="#Binary-3462"><span class="linenos">3462</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span> -</span><span id="Binary-3463"><a href="#Binary-3463"><span class="linenos">3463</span></a> -</span><span id="Binary-3464"><a href="#Binary-3464"><span class="linenos">3464</span></a> <span class="nd">@property</span> -</span><span id="Binary-3465"><a href="#Binary-3465"><span class="linenos">3465</span></a> <span class="k">def</span> <span class="nf">right</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Binary-3466"><a href="#Binary-3466"><span class="linenos">3466</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Binary-3462"><a href="#Binary-3462"><span class="linenos">3462</span></a><span class="k">class</span> <span class="nc">Binary</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> +</span><span id="Binary-3463"><a href="#Binary-3463"><span class="linenos">3463</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="Binary-3464"><a href="#Binary-3464"><span class="linenos">3464</span></a> +</span><span id="Binary-3465"><a href="#Binary-3465"><span class="linenos">3465</span></a> <span class="nd">@property</span> +</span><span id="Binary-3466"><a href="#Binary-3466"><span class="linenos">3466</span></a> <span class="k">def</span> <span class="nf">left</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Binary-3467"><a href="#Binary-3467"><span class="linenos">3467</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span> +</span><span id="Binary-3468"><a href="#Binary-3468"><span class="linenos">3468</span></a> +</span><span id="Binary-3469"><a href="#Binary-3469"><span class="linenos">3469</span></a> <span class="nd">@property</span> +</span><span id="Binary-3470"><a href="#Binary-3470"><span class="linenos">3470</span></a> <span class="k">def</span> <span class="nf">right</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Binary-3471"><a href="#Binary-3471"><span class="linenos">3471</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span> </span></pre></div> @@ -29991,8 +30119,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Add"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Add-3469"><a href="#Add-3469"><span class="linenos">3469</span></a><span class="k">class</span> <span class="nc">Add</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="Add-3470"><a href="#Add-3470"><span class="linenos">3470</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Add-3474"><a href="#Add-3474"><span class="linenos">3474</span></a><span class="k">class</span> <span class="nc">Add</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="Add-3475"><a href="#Add-3475"><span class="linenos">3475</span></a> <span class="k">pass</span> </span></pre></div> @@ -30071,8 +30199,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Connector"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Connector-3473"><a href="#Connector-3473"><span class="linenos">3473</span></a><span class="k">class</span> <span class="nc">Connector</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="Connector-3474"><a href="#Connector-3474"><span class="linenos">3474</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Connector-3478"><a href="#Connector-3478"><span class="linenos">3478</span></a><span class="k">class</span> <span class="nc">Connector</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="Connector-3479"><a href="#Connector-3479"><span class="linenos">3479</span></a> <span class="k">pass</span> </span></pre></div> @@ -30151,8 +30279,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#And"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="And-3477"><a href="#And-3477"><span class="linenos">3477</span></a><span class="k">class</span> <span class="nc">And</span><span class="p">(</span><span class="n">Connector</span><span class="p">):</span> -</span><span id="And-3478"><a href="#And-3478"><span class="linenos">3478</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="And-3482"><a href="#And-3482"><span class="linenos">3482</span></a><span class="k">class</span> <span class="nc">And</span><span class="p">(</span><span class="n">Connector</span><span class="p">):</span> +</span><span id="And-3483"><a href="#And-3483"><span class="linenos">3483</span></a> <span class="k">pass</span> </span></pre></div> @@ -30231,8 +30359,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Or"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Or-3481"><a href="#Or-3481"><span class="linenos">3481</span></a><span class="k">class</span> <span class="nc">Or</span><span class="p">(</span><span class="n">Connector</span><span class="p">):</span> -</span><span id="Or-3482"><a href="#Or-3482"><span class="linenos">3482</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Or-3486"><a href="#Or-3486"><span class="linenos">3486</span></a><span class="k">class</span> <span class="nc">Or</span><span class="p">(</span><span class="n">Connector</span><span class="p">):</span> +</span><span id="Or-3487"><a href="#Or-3487"><span class="linenos">3487</span></a> <span class="k">pass</span> </span></pre></div> @@ -30311,8 +30439,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#BitwiseAnd"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BitwiseAnd-3485"><a href="#BitwiseAnd-3485"><span class="linenos">3485</span></a><span class="k">class</span> <span class="nc">BitwiseAnd</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="BitwiseAnd-3486"><a href="#BitwiseAnd-3486"><span class="linenos">3486</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BitwiseAnd-3490"><a href="#BitwiseAnd-3490"><span class="linenos">3490</span></a><span class="k">class</span> <span class="nc">BitwiseAnd</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="BitwiseAnd-3491"><a href="#BitwiseAnd-3491"><span class="linenos">3491</span></a> <span class="k">pass</span> </span></pre></div> @@ -30391,8 +30519,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#BitwiseLeftShift"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BitwiseLeftShift-3489"><a href="#BitwiseLeftShift-3489"><span class="linenos">3489</span></a><span class="k">class</span> <span class="nc">BitwiseLeftShift</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="BitwiseLeftShift-3490"><a href="#BitwiseLeftShift-3490"><span class="linenos">3490</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BitwiseLeftShift-3494"><a href="#BitwiseLeftShift-3494"><span class="linenos">3494</span></a><span class="k">class</span> <span class="nc">BitwiseLeftShift</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="BitwiseLeftShift-3495"><a href="#BitwiseLeftShift-3495"><span class="linenos">3495</span></a> <span class="k">pass</span> </span></pre></div> @@ -30471,8 +30599,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#BitwiseOr"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BitwiseOr-3493"><a href="#BitwiseOr-3493"><span class="linenos">3493</span></a><span class="k">class</span> <span class="nc">BitwiseOr</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="BitwiseOr-3494"><a href="#BitwiseOr-3494"><span class="linenos">3494</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BitwiseOr-3498"><a href="#BitwiseOr-3498"><span class="linenos">3498</span></a><span class="k">class</span> <span class="nc">BitwiseOr</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="BitwiseOr-3499"><a href="#BitwiseOr-3499"><span class="linenos">3499</span></a> <span class="k">pass</span> </span></pre></div> @@ -30551,8 +30679,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#BitwiseRightShift"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BitwiseRightShift-3497"><a href="#BitwiseRightShift-3497"><span class="linenos">3497</span></a><span class="k">class</span> <span class="nc">BitwiseRightShift</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="BitwiseRightShift-3498"><a href="#BitwiseRightShift-3498"><span class="linenos">3498</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BitwiseRightShift-3502"><a href="#BitwiseRightShift-3502"><span class="linenos">3502</span></a><span class="k">class</span> <span class="nc">BitwiseRightShift</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="BitwiseRightShift-3503"><a href="#BitwiseRightShift-3503"><span class="linenos">3503</span></a> <span class="k">pass</span> </span></pre></div> @@ -30631,8 +30759,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#BitwiseXor"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BitwiseXor-3501"><a href="#BitwiseXor-3501"><span class="linenos">3501</span></a><span class="k">class</span> <span class="nc">BitwiseXor</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="BitwiseXor-3502"><a href="#BitwiseXor-3502"><span class="linenos">3502</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BitwiseXor-3506"><a href="#BitwiseXor-3506"><span class="linenos">3506</span></a><span class="k">class</span> <span class="nc">BitwiseXor</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="BitwiseXor-3507"><a href="#BitwiseXor-3507"><span class="linenos">3507</span></a> <span class="k">pass</span> </span></pre></div> @@ -30711,8 +30839,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Div"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Div-3505"><a href="#Div-3505"><span class="linenos">3505</span></a><span class="k">class</span> <span class="nc">Div</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="Div-3506"><a href="#Div-3506"><span class="linenos">3506</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Div-3510"><a href="#Div-3510"><span class="linenos">3510</span></a><span class="k">class</span> <span class="nc">Div</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="Div-3511"><a href="#Div-3511"><span class="linenos">3511</span></a> <span class="k">pass</span> </span></pre></div> @@ -30791,8 +30919,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Overlaps"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Overlaps-3509"><a href="#Overlaps-3509"><span class="linenos">3509</span></a><span class="k">class</span> <span class="nc">Overlaps</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="Overlaps-3510"><a href="#Overlaps-3510"><span class="linenos">3510</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Overlaps-3514"><a href="#Overlaps-3514"><span class="linenos">3514</span></a><span class="k">class</span> <span class="nc">Overlaps</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="Overlaps-3515"><a href="#Overlaps-3515"><span class="linenos">3515</span></a> <span class="k">pass</span> </span></pre></div> @@ -30871,28 +30999,28 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Dot"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Dot-3513"><a href="#Dot-3513"><span class="linenos">3513</span></a><span class="k">class</span> <span class="nc">Dot</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="Dot-3514"><a href="#Dot-3514"><span class="linenos">3514</span></a> <span class="nd">@property</span> -</span><span id="Dot-3515"><a href="#Dot-3515"><span class="linenos">3515</span></a> <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Dot-3516"><a href="#Dot-3516"><span class="linenos">3516</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span> -</span><span id="Dot-3517"><a href="#Dot-3517"><span class="linenos">3517</span></a> -</span><span id="Dot-3518"><a href="#Dot-3518"><span class="linenos">3518</span></a> <span class="nd">@property</span> -</span><span id="Dot-3519"><a href="#Dot-3519"><span class="linenos">3519</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Dot-3520"><a href="#Dot-3520"><span class="linenos">3520</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> -</span><span id="Dot-3521"><a href="#Dot-3521"><span class="linenos">3521</span></a> -</span><span id="Dot-3522"><a href="#Dot-3522"><span class="linenos">3522</span></a> <span class="nd">@classmethod</span> -</span><span id="Dot-3523"><a href="#Dot-3523"><span class="linenos">3523</span></a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expressions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">Dot</span><span class="p">:</span> -</span><span id="Dot-3524"><a href="#Dot-3524"><span class="linenos">3524</span></a><span class="w"> </span><span class="sd">"""Build a Dot object with a sequence of expressions."""</span> -</span><span id="Dot-3525"><a href="#Dot-3525"><span class="linenos">3525</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o"><</span> <span class="mi">2</span><span class="p">:</span> -</span><span id="Dot-3526"><a href="#Dot-3526"><span class="linenos">3526</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Dot requires >= 2 expressions."</span><span class="p">)</span> -</span><span id="Dot-3527"><a href="#Dot-3527"><span class="linenos">3527</span></a> -</span><span id="Dot-3528"><a href="#Dot-3528"><span class="linenos">3528</span></a> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span> <span class="o">=</span> <span class="n">expressions</span> -</span><span id="Dot-3529"><a href="#Dot-3529"><span class="linenos">3529</span></a> <span class="n">dot</span> <span class="o">=</span> <span class="n">Dot</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">a</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">b</span><span class="p">)</span> -</span><span id="Dot-3530"><a href="#Dot-3530"><span class="linenos">3530</span></a> -</span><span id="Dot-3531"><a href="#Dot-3531"><span class="linenos">3531</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="Dot-3532"><a href="#Dot-3532"><span class="linenos">3532</span></a> <span class="n">dot</span> <span class="o">=</span> <span class="n">Dot</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">dot</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Dot-3533"><a href="#Dot-3533"><span class="linenos">3533</span></a> -</span><span id="Dot-3534"><a href="#Dot-3534"><span class="linenos">3534</span></a> <span class="k">return</span> <span class="n">dot</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Dot-3518"><a href="#Dot-3518"><span class="linenos">3518</span></a><span class="k">class</span> <span class="nc">Dot</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="Dot-3519"><a href="#Dot-3519"><span class="linenos">3519</span></a> <span class="nd">@property</span> +</span><span id="Dot-3520"><a href="#Dot-3520"><span class="linenos">3520</span></a> <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Dot-3521"><a href="#Dot-3521"><span class="linenos">3521</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span> +</span><span id="Dot-3522"><a href="#Dot-3522"><span class="linenos">3522</span></a> +</span><span id="Dot-3523"><a href="#Dot-3523"><span class="linenos">3523</span></a> <span class="nd">@property</span> +</span><span id="Dot-3524"><a href="#Dot-3524"><span class="linenos">3524</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Dot-3525"><a href="#Dot-3525"><span class="linenos">3525</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> +</span><span id="Dot-3526"><a href="#Dot-3526"><span class="linenos">3526</span></a> +</span><span id="Dot-3527"><a href="#Dot-3527"><span class="linenos">3527</span></a> <span class="nd">@classmethod</span> +</span><span id="Dot-3528"><a href="#Dot-3528"><span class="linenos">3528</span></a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expressions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">Dot</span><span class="p">:</span> +</span><span id="Dot-3529"><a href="#Dot-3529"><span class="linenos">3529</span></a><span class="w"> </span><span class="sd">"""Build a Dot object with a sequence of expressions."""</span> +</span><span id="Dot-3530"><a href="#Dot-3530"><span class="linenos">3530</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o"><</span> <span class="mi">2</span><span class="p">:</span> +</span><span id="Dot-3531"><a href="#Dot-3531"><span class="linenos">3531</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Dot requires >= 2 expressions."</span><span class="p">)</span> +</span><span id="Dot-3532"><a href="#Dot-3532"><span class="linenos">3532</span></a> +</span><span id="Dot-3533"><a href="#Dot-3533"><span class="linenos">3533</span></a> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span> <span class="o">=</span> <span class="n">expressions</span> +</span><span id="Dot-3534"><a href="#Dot-3534"><span class="linenos">3534</span></a> <span class="n">dot</span> <span class="o">=</span> <span class="n">Dot</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">a</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">b</span><span class="p">)</span> +</span><span id="Dot-3535"><a href="#Dot-3535"><span class="linenos">3535</span></a> +</span><span id="Dot-3536"><a href="#Dot-3536"><span class="linenos">3536</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="Dot-3537"><a href="#Dot-3537"><span class="linenos">3537</span></a> <span class="n">dot</span> <span class="o">=</span> <span class="n">Dot</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">dot</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Dot-3538"><a href="#Dot-3538"><span class="linenos">3538</span></a> +</span><span id="Dot-3539"><a href="#Dot-3539"><span class="linenos">3539</span></a> <span class="k">return</span> <span class="n">dot</span> </span></pre></div> @@ -30940,19 +31068,19 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Dot.build"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Dot.build-3522"><a href="#Dot.build-3522"><span class="linenos">3522</span></a> <span class="nd">@classmethod</span> -</span><span id="Dot.build-3523"><a href="#Dot.build-3523"><span class="linenos">3523</span></a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expressions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">Dot</span><span class="p">:</span> -</span><span id="Dot.build-3524"><a href="#Dot.build-3524"><span class="linenos">3524</span></a><span class="w"> </span><span class="sd">"""Build a Dot object with a sequence of expressions."""</span> -</span><span id="Dot.build-3525"><a href="#Dot.build-3525"><span class="linenos">3525</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o"><</span> <span class="mi">2</span><span class="p">:</span> -</span><span id="Dot.build-3526"><a href="#Dot.build-3526"><span class="linenos">3526</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Dot requires >= 2 expressions."</span><span class="p">)</span> -</span><span id="Dot.build-3527"><a href="#Dot.build-3527"><span class="linenos">3527</span></a> -</span><span id="Dot.build-3528"><a href="#Dot.build-3528"><span class="linenos">3528</span></a> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span> <span class="o">=</span> <span class="n">expressions</span> -</span><span id="Dot.build-3529"><a href="#Dot.build-3529"><span class="linenos">3529</span></a> <span class="n">dot</span> <span class="o">=</span> <span class="n">Dot</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">a</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">b</span><span class="p">)</span> -</span><span id="Dot.build-3530"><a href="#Dot.build-3530"><span class="linenos">3530</span></a> -</span><span id="Dot.build-3531"><a href="#Dot.build-3531"><span class="linenos">3531</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="Dot.build-3532"><a href="#Dot.build-3532"><span class="linenos">3532</span></a> <span class="n">dot</span> <span class="o">=</span> <span class="n">Dot</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">dot</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Dot.build-3533"><a href="#Dot.build-3533"><span class="linenos">3533</span></a> -</span><span id="Dot.build-3534"><a href="#Dot.build-3534"><span class="linenos">3534</span></a> <span class="k">return</span> <span class="n">dot</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Dot.build-3527"><a href="#Dot.build-3527"><span class="linenos">3527</span></a> <span class="nd">@classmethod</span> +</span><span id="Dot.build-3528"><a href="#Dot.build-3528"><span class="linenos">3528</span></a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expressions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="n">Dot</span><span class="p">:</span> +</span><span id="Dot.build-3529"><a href="#Dot.build-3529"><span class="linenos">3529</span></a><span class="w"> </span><span class="sd">"""Build a Dot object with a sequence of expressions."""</span> +</span><span id="Dot.build-3530"><a href="#Dot.build-3530"><span class="linenos">3530</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o"><</span> <span class="mi">2</span><span class="p">:</span> +</span><span id="Dot.build-3531"><a href="#Dot.build-3531"><span class="linenos">3531</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Dot requires >= 2 expressions."</span><span class="p">)</span> +</span><span id="Dot.build-3532"><a href="#Dot.build-3532"><span class="linenos">3532</span></a> +</span><span id="Dot.build-3533"><a href="#Dot.build-3533"><span class="linenos">3533</span></a> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span> <span class="o">=</span> <span class="n">expressions</span> +</span><span id="Dot.build-3534"><a href="#Dot.build-3534"><span class="linenos">3534</span></a> <span class="n">dot</span> <span class="o">=</span> <span class="n">Dot</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">a</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">b</span><span class="p">)</span> +</span><span id="Dot.build-3535"><a href="#Dot.build-3535"><span class="linenos">3535</span></a> +</span><span id="Dot.build-3536"><a href="#Dot.build-3536"><span class="linenos">3536</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="Dot.build-3537"><a href="#Dot.build-3537"><span class="linenos">3537</span></a> <span class="n">dot</span> <span class="o">=</span> <span class="n">Dot</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">dot</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Dot.build-3538"><a href="#Dot.build-3538"><span class="linenos">3538</span></a> +</span><span id="Dot.build-3539"><a href="#Dot.build-3539"><span class="linenos">3539</span></a> <span class="k">return</span> <span class="n">dot</span> </span></pre></div> @@ -31033,8 +31161,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#DPipe"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DPipe-3537"><a href="#DPipe-3537"><span class="linenos">3537</span></a><span class="k">class</span> <span class="nc">DPipe</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="DPipe-3538"><a href="#DPipe-3538"><span class="linenos">3538</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DPipe-3542"><a href="#DPipe-3542"><span class="linenos">3542</span></a><span class="k">class</span> <span class="nc">DPipe</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="DPipe-3543"><a href="#DPipe-3543"><span class="linenos">3543</span></a> <span class="k">pass</span> </span></pre></div> @@ -31113,8 +31241,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#SafeDPipe"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SafeDPipe-3541"><a href="#SafeDPipe-3541"><span class="linenos">3541</span></a><span class="k">class</span> <span class="nc">SafeDPipe</span><span class="p">(</span><span class="n">DPipe</span><span class="p">):</span> -</span><span id="SafeDPipe-3542"><a href="#SafeDPipe-3542"><span class="linenos">3542</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SafeDPipe-3546"><a href="#SafeDPipe-3546"><span class="linenos">3546</span></a><span class="k">class</span> <span class="nc">SafeDPipe</span><span class="p">(</span><span class="n">DPipe</span><span class="p">):</span> +</span><span id="SafeDPipe-3547"><a href="#SafeDPipe-3547"><span class="linenos">3547</span></a> <span class="k">pass</span> </span></pre></div> @@ -31193,8 +31321,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#EQ"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="EQ-3545"><a href="#EQ-3545"><span class="linenos">3545</span></a><span class="k">class</span> <span class="nc">EQ</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="EQ-3546"><a href="#EQ-3546"><span class="linenos">3546</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="EQ-3550"><a href="#EQ-3550"><span class="linenos">3550</span></a><span class="k">class</span> <span class="nc">EQ</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="EQ-3551"><a href="#EQ-3551"><span class="linenos">3551</span></a> <span class="k">pass</span> </span></pre></div> @@ -31273,8 +31401,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#NullSafeEQ"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="NullSafeEQ-3549"><a href="#NullSafeEQ-3549"><span class="linenos">3549</span></a><span class="k">class</span> <span class="nc">NullSafeEQ</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="NullSafeEQ-3550"><a href="#NullSafeEQ-3550"><span class="linenos">3550</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="NullSafeEQ-3554"><a href="#NullSafeEQ-3554"><span class="linenos">3554</span></a><span class="k">class</span> <span class="nc">NullSafeEQ</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="NullSafeEQ-3555"><a href="#NullSafeEQ-3555"><span class="linenos">3555</span></a> <span class="k">pass</span> </span></pre></div> @@ -31353,8 +31481,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#NullSafeNEQ"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="NullSafeNEQ-3553"><a href="#NullSafeNEQ-3553"><span class="linenos">3553</span></a><span class="k">class</span> <span class="nc">NullSafeNEQ</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="NullSafeNEQ-3554"><a href="#NullSafeNEQ-3554"><span class="linenos">3554</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="NullSafeNEQ-3558"><a href="#NullSafeNEQ-3558"><span class="linenos">3558</span></a><span class="k">class</span> <span class="nc">NullSafeNEQ</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="NullSafeNEQ-3559"><a href="#NullSafeNEQ-3559"><span class="linenos">3559</span></a> <span class="k">pass</span> </span></pre></div> @@ -31433,8 +31561,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Distance"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Distance-3557"><a href="#Distance-3557"><span class="linenos">3557</span></a><span class="k">class</span> <span class="nc">Distance</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="Distance-3558"><a href="#Distance-3558"><span class="linenos">3558</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Distance-3562"><a href="#Distance-3562"><span class="linenos">3562</span></a><span class="k">class</span> <span class="nc">Distance</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="Distance-3563"><a href="#Distance-3563"><span class="linenos">3563</span></a> <span class="k">pass</span> </span></pre></div> @@ -31513,8 +31641,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Escape"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Escape-3561"><a href="#Escape-3561"><span class="linenos">3561</span></a><span class="k">class</span> <span class="nc">Escape</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="Escape-3562"><a href="#Escape-3562"><span class="linenos">3562</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Escape-3566"><a href="#Escape-3566"><span class="linenos">3566</span></a><span class="k">class</span> <span class="nc">Escape</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="Escape-3567"><a href="#Escape-3567"><span class="linenos">3567</span></a> <span class="k">pass</span> </span></pre></div> @@ -31593,8 +31721,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Glob"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Glob-3565"><a href="#Glob-3565"><span class="linenos">3565</span></a><span class="k">class</span> <span class="nc">Glob</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="Glob-3566"><a href="#Glob-3566"><span class="linenos">3566</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Glob-3570"><a href="#Glob-3570"><span class="linenos">3570</span></a><span class="k">class</span> <span class="nc">Glob</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="Glob-3571"><a href="#Glob-3571"><span class="linenos">3571</span></a> <span class="k">pass</span> </span></pre></div> @@ -31673,8 +31801,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#GT"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="GT-3569"><a href="#GT-3569"><span class="linenos">3569</span></a><span class="k">class</span> <span class="nc">GT</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="GT-3570"><a href="#GT-3570"><span class="linenos">3570</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="GT-3574"><a href="#GT-3574"><span class="linenos">3574</span></a><span class="k">class</span> <span class="nc">GT</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="GT-3575"><a href="#GT-3575"><span class="linenos">3575</span></a> <span class="k">pass</span> </span></pre></div> @@ -31753,8 +31881,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#GTE"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="GTE-3573"><a href="#GTE-3573"><span class="linenos">3573</span></a><span class="k">class</span> <span class="nc">GTE</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="GTE-3574"><a href="#GTE-3574"><span class="linenos">3574</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="GTE-3578"><a href="#GTE-3578"><span class="linenos">3578</span></a><span class="k">class</span> <span class="nc">GTE</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="GTE-3579"><a href="#GTE-3579"><span class="linenos">3579</span></a> <span class="k">pass</span> </span></pre></div> @@ -31833,8 +31961,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#ILike"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ILike-3577"><a href="#ILike-3577"><span class="linenos">3577</span></a><span class="k">class</span> <span class="nc">ILike</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="ILike-3578"><a href="#ILike-3578"><span class="linenos">3578</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ILike-3582"><a href="#ILike-3582"><span class="linenos">3582</span></a><span class="k">class</span> <span class="nc">ILike</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="ILike-3583"><a href="#ILike-3583"><span class="linenos">3583</span></a> <span class="k">pass</span> </span></pre></div> @@ -31913,8 +32041,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#ILikeAny"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ILikeAny-3581"><a href="#ILikeAny-3581"><span class="linenos">3581</span></a><span class="k">class</span> <span class="nc">ILikeAny</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="ILikeAny-3582"><a href="#ILikeAny-3582"><span class="linenos">3582</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ILikeAny-3586"><a href="#ILikeAny-3586"><span class="linenos">3586</span></a><span class="k">class</span> <span class="nc">ILikeAny</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="ILikeAny-3587"><a href="#ILikeAny-3587"><span class="linenos">3587</span></a> <span class="k">pass</span> </span></pre></div> @@ -31993,8 +32121,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#IntDiv"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="IntDiv-3585"><a href="#IntDiv-3585"><span class="linenos">3585</span></a><span class="k">class</span> <span class="nc">IntDiv</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="IntDiv-3586"><a href="#IntDiv-3586"><span class="linenos">3586</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="IntDiv-3590"><a href="#IntDiv-3590"><span class="linenos">3590</span></a><span class="k">class</span> <span class="nc">IntDiv</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="IntDiv-3591"><a href="#IntDiv-3591"><span class="linenos">3591</span></a> <span class="k">pass</span> </span></pre></div> @@ -32073,8 +32201,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Is"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Is-3589"><a href="#Is-3589"><span class="linenos">3589</span></a><span class="k">class</span> <span class="nc">Is</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="Is-3590"><a href="#Is-3590"><span class="linenos">3590</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Is-3594"><a href="#Is-3594"><span class="linenos">3594</span></a><span class="k">class</span> <span class="nc">Is</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="Is-3595"><a href="#Is-3595"><span class="linenos">3595</span></a> <span class="k">pass</span> </span></pre></div> @@ -32153,8 +32281,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Kwarg"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Kwarg-3593"><a href="#Kwarg-3593"><span class="linenos">3593</span></a><span class="k">class</span> <span class="nc">Kwarg</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="Kwarg-3594"><a href="#Kwarg-3594"><span class="linenos">3594</span></a><span class="w"> </span><span class="sd">"""Kwarg in special functions like func(kwarg => y)."""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Kwarg-3598"><a href="#Kwarg-3598"><span class="linenos">3598</span></a><span class="k">class</span> <span class="nc">Kwarg</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="Kwarg-3599"><a href="#Kwarg-3599"><span class="linenos">3599</span></a><span class="w"> </span><span class="sd">"""Kwarg in special functions like func(kwarg => y)."""</span> </span></pre></div> @@ -32235,8 +32363,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Like"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Like-3597"><a href="#Like-3597"><span class="linenos">3597</span></a><span class="k">class</span> <span class="nc">Like</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="Like-3598"><a href="#Like-3598"><span class="linenos">3598</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Like-3602"><a href="#Like-3602"><span class="linenos">3602</span></a><span class="k">class</span> <span class="nc">Like</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="Like-3603"><a href="#Like-3603"><span class="linenos">3603</span></a> <span class="k">pass</span> </span></pre></div> @@ -32315,8 +32443,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#LikeAny"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="LikeAny-3601"><a href="#LikeAny-3601"><span class="linenos">3601</span></a><span class="k">class</span> <span class="nc">LikeAny</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="LikeAny-3602"><a href="#LikeAny-3602"><span class="linenos">3602</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="LikeAny-3606"><a href="#LikeAny-3606"><span class="linenos">3606</span></a><span class="k">class</span> <span class="nc">LikeAny</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="LikeAny-3607"><a href="#LikeAny-3607"><span class="linenos">3607</span></a> <span class="k">pass</span> </span></pre></div> @@ -32395,8 +32523,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#LT"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="LT-3605"><a href="#LT-3605"><span class="linenos">3605</span></a><span class="k">class</span> <span class="nc">LT</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="LT-3606"><a href="#LT-3606"><span class="linenos">3606</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="LT-3610"><a href="#LT-3610"><span class="linenos">3610</span></a><span class="k">class</span> <span class="nc">LT</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="LT-3611"><a href="#LT-3611"><span class="linenos">3611</span></a> <span class="k">pass</span> </span></pre></div> @@ -32475,8 +32603,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#LTE"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="LTE-3609"><a href="#LTE-3609"><span class="linenos">3609</span></a><span class="k">class</span> <span class="nc">LTE</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="LTE-3610"><a href="#LTE-3610"><span class="linenos">3610</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="LTE-3614"><a href="#LTE-3614"><span class="linenos">3614</span></a><span class="k">class</span> <span class="nc">LTE</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="LTE-3615"><a href="#LTE-3615"><span class="linenos">3615</span></a> <span class="k">pass</span> </span></pre></div> @@ -32555,8 +32683,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Mod"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Mod-3613"><a href="#Mod-3613"><span class="linenos">3613</span></a><span class="k">class</span> <span class="nc">Mod</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="Mod-3614"><a href="#Mod-3614"><span class="linenos">3614</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Mod-3618"><a href="#Mod-3618"><span class="linenos">3618</span></a><span class="k">class</span> <span class="nc">Mod</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="Mod-3619"><a href="#Mod-3619"><span class="linenos">3619</span></a> <span class="k">pass</span> </span></pre></div> @@ -32635,8 +32763,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Mul"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Mul-3617"><a href="#Mul-3617"><span class="linenos">3617</span></a><span class="k">class</span> <span class="nc">Mul</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="Mul-3618"><a href="#Mul-3618"><span class="linenos">3618</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Mul-3622"><a href="#Mul-3622"><span class="linenos">3622</span></a><span class="k">class</span> <span class="nc">Mul</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="Mul-3623"><a href="#Mul-3623"><span class="linenos">3623</span></a> <span class="k">pass</span> </span></pre></div> @@ -32715,8 +32843,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#NEQ"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="NEQ-3621"><a href="#NEQ-3621"><span class="linenos">3621</span></a><span class="k">class</span> <span class="nc">NEQ</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="NEQ-3622"><a href="#NEQ-3622"><span class="linenos">3622</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="NEQ-3626"><a href="#NEQ-3626"><span class="linenos">3626</span></a><span class="k">class</span> <span class="nc">NEQ</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="NEQ-3627"><a href="#NEQ-3627"><span class="linenos">3627</span></a> <span class="k">pass</span> </span></pre></div> @@ -32795,8 +32923,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#SimilarTo"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SimilarTo-3625"><a href="#SimilarTo-3625"><span class="linenos">3625</span></a><span class="k">class</span> <span class="nc">SimilarTo</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> -</span><span id="SimilarTo-3626"><a href="#SimilarTo-3626"><span class="linenos">3626</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SimilarTo-3630"><a href="#SimilarTo-3630"><span class="linenos">3630</span></a><span class="k">class</span> <span class="nc">SimilarTo</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Predicate</span><span class="p">):</span> +</span><span id="SimilarTo-3631"><a href="#SimilarTo-3631"><span class="linenos">3631</span></a> <span class="k">pass</span> </span></pre></div> @@ -32875,8 +33003,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Slice"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Slice-3629"><a href="#Slice-3629"><span class="linenos">3629</span></a><span class="k">class</span> <span class="nc">Slice</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="Slice-3630"><a href="#Slice-3630"><span class="linenos">3630</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Slice-3634"><a href="#Slice-3634"><span class="linenos">3634</span></a><span class="k">class</span> <span class="nc">Slice</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="Slice-3635"><a href="#Slice-3635"><span class="linenos">3635</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -32955,8 +33083,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Sub"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Sub-3633"><a href="#Sub-3633"><span class="linenos">3633</span></a><span class="k">class</span> <span class="nc">Sub</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="Sub-3634"><a href="#Sub-3634"><span class="linenos">3634</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Sub-3638"><a href="#Sub-3638"><span class="linenos">3638</span></a><span class="k">class</span> <span class="nc">Sub</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="Sub-3639"><a href="#Sub-3639"><span class="linenos">3639</span></a> <span class="k">pass</span> </span></pre></div> @@ -33035,8 +33163,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#ArrayOverlaps"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayOverlaps-3637"><a href="#ArrayOverlaps-3637"><span class="linenos">3637</span></a><span class="k">class</span> <span class="nc">ArrayOverlaps</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="ArrayOverlaps-3638"><a href="#ArrayOverlaps-3638"><span class="linenos">3638</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayOverlaps-3642"><a href="#ArrayOverlaps-3642"><span class="linenos">3642</span></a><span class="k">class</span> <span class="nc">ArrayOverlaps</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="ArrayOverlaps-3643"><a href="#ArrayOverlaps-3643"><span class="linenos">3643</span></a> <span class="k">pass</span> </span></pre></div> @@ -33115,8 +33243,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Unary"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Unary-3643"><a href="#Unary-3643"><span class="linenos">3643</span></a><span class="k">class</span> <span class="nc">Unary</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> -</span><span id="Unary-3644"><a href="#Unary-3644"><span class="linenos">3644</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Unary-3648"><a href="#Unary-3648"><span class="linenos">3648</span></a><span class="k">class</span> <span class="nc">Unary</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> +</span><span id="Unary-3649"><a href="#Unary-3649"><span class="linenos">3649</span></a> <span class="k">pass</span> </span></pre></div> @@ -33195,8 +33323,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#BitwiseNot"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="BitwiseNot-3647"><a href="#BitwiseNot-3647"><span class="linenos">3647</span></a><span class="k">class</span> <span class="nc">BitwiseNot</span><span class="p">(</span><span class="n">Unary</span><span class="p">):</span> -</span><span id="BitwiseNot-3648"><a href="#BitwiseNot-3648"><span class="linenos">3648</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="BitwiseNot-3652"><a href="#BitwiseNot-3652"><span class="linenos">3652</span></a><span class="k">class</span> <span class="nc">BitwiseNot</span><span class="p">(</span><span class="n">Unary</span><span class="p">):</span> +</span><span id="BitwiseNot-3653"><a href="#BitwiseNot-3653"><span class="linenos">3653</span></a> <span class="k">pass</span> </span></pre></div> @@ -33275,8 +33403,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Not"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Not-3651"><a href="#Not-3651"><span class="linenos">3651</span></a><span class="k">class</span> <span class="nc">Not</span><span class="p">(</span><span class="n">Unary</span><span class="p">):</span> -</span><span id="Not-3652"><a href="#Not-3652"><span class="linenos">3652</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Not-3656"><a href="#Not-3656"><span class="linenos">3656</span></a><span class="k">class</span> <span class="nc">Not</span><span class="p">(</span><span class="n">Unary</span><span class="p">):</span> +</span><span id="Not-3657"><a href="#Not-3657"><span class="linenos">3657</span></a> <span class="k">pass</span> </span></pre></div> @@ -33355,12 +33483,12 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Paren"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Paren-3655"><a href="#Paren-3655"><span class="linenos">3655</span></a><span class="k">class</span> <span class="nc">Paren</span><span class="p">(</span><span class="n">Unary</span><span class="p">):</span> -</span><span id="Paren-3656"><a href="#Paren-3656"><span class="linenos">3656</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="Paren-3657"><a href="#Paren-3657"><span class="linenos">3657</span></a> -</span><span id="Paren-3658"><a href="#Paren-3658"><span class="linenos">3658</span></a> <span class="nd">@property</span> -</span><span id="Paren-3659"><a href="#Paren-3659"><span class="linenos">3659</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Paren-3660"><a href="#Paren-3660"><span class="linenos">3660</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Paren-3660"><a href="#Paren-3660"><span class="linenos">3660</span></a><span class="k">class</span> <span class="nc">Paren</span><span class="p">(</span><span class="n">Unary</span><span class="p">):</span> +</span><span id="Paren-3661"><a href="#Paren-3661"><span class="linenos">3661</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"with"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="Paren-3662"><a href="#Paren-3662"><span class="linenos">3662</span></a> +</span><span id="Paren-3663"><a href="#Paren-3663"><span class="linenos">3663</span></a> <span class="nd">@property</span> +</span><span id="Paren-3664"><a href="#Paren-3664"><span class="linenos">3664</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Paren-3665"><a href="#Paren-3665"><span class="linenos">3665</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> </span></pre></div> @@ -33468,8 +33596,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Neg"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Neg-3663"><a href="#Neg-3663"><span class="linenos">3663</span></a><span class="k">class</span> <span class="nc">Neg</span><span class="p">(</span><span class="n">Unary</span><span class="p">):</span> -</span><span id="Neg-3664"><a href="#Neg-3664"><span class="linenos">3664</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Neg-3668"><a href="#Neg-3668"><span class="linenos">3668</span></a><span class="k">class</span> <span class="nc">Neg</span><span class="p">(</span><span class="n">Unary</span><span class="p">):</span> +</span><span id="Neg-3669"><a href="#Neg-3669"><span class="linenos">3669</span></a> <span class="k">pass</span> </span></pre></div> @@ -33548,12 +33676,12 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Alias"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Alias-3667"><a href="#Alias-3667"><span class="linenos">3667</span></a><span class="k">class</span> <span class="nc">Alias</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Alias-3668"><a href="#Alias-3668"><span class="linenos">3668</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="Alias-3669"><a href="#Alias-3669"><span class="linenos">3669</span></a> -</span><span id="Alias-3670"><a href="#Alias-3670"><span class="linenos">3670</span></a> <span class="nd">@property</span> -</span><span id="Alias-3671"><a href="#Alias-3671"><span class="linenos">3671</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Alias-3672"><a href="#Alias-3672"><span class="linenos">3672</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">alias</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Alias-3672"><a href="#Alias-3672"><span class="linenos">3672</span></a><span class="k">class</span> <span class="nc">Alias</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Alias-3673"><a href="#Alias-3673"><span class="linenos">3673</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="Alias-3674"><a href="#Alias-3674"><span class="linenos">3674</span></a> +</span><span id="Alias-3675"><a href="#Alias-3675"><span class="linenos">3675</span></a> <span class="nd">@property</span> +</span><span id="Alias-3676"><a href="#Alias-3676"><span class="linenos">3676</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Alias-3677"><a href="#Alias-3677"><span class="linenos">3677</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">alias</span> </span></pre></div> @@ -33646,12 +33774,12 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Aliases"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Aliases-3675"><a href="#Aliases-3675"><span class="linenos">3675</span></a><span class="k">class</span> <span class="nc">Aliases</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Aliases-3676"><a href="#Aliases-3676"><span class="linenos">3676</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="Aliases-3677"><a href="#Aliases-3677"><span class="linenos">3677</span></a> -</span><span id="Aliases-3678"><a href="#Aliases-3678"><span class="linenos">3678</span></a> <span class="nd">@property</span> -</span><span id="Aliases-3679"><a href="#Aliases-3679"><span class="linenos">3679</span></a> <span class="k">def</span> <span class="nf">aliases</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Aliases-3680"><a href="#Aliases-3680"><span class="linenos">3680</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Aliases-3680"><a href="#Aliases-3680"><span class="linenos">3680</span></a><span class="k">class</span> <span class="nc">Aliases</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Aliases-3681"><a href="#Aliases-3681"><span class="linenos">3681</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="Aliases-3682"><a href="#Aliases-3682"><span class="linenos">3682</span></a> +</span><span id="Aliases-3683"><a href="#Aliases-3683"><span class="linenos">3683</span></a> <span class="nd">@property</span> +</span><span id="Aliases-3684"><a href="#Aliases-3684"><span class="linenos">3684</span></a> <span class="k">def</span> <span class="nf">aliases</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Aliases-3685"><a href="#Aliases-3685"><span class="linenos">3685</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span> </span></pre></div> @@ -33715,8 +33843,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#AtTimeZone"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="AtTimeZone-3683"><a href="#AtTimeZone-3683"><span class="linenos">3683</span></a><span class="k">class</span> <span class="nc">AtTimeZone</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="AtTimeZone-3684"><a href="#AtTimeZone-3684"><span class="linenos">3684</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="AtTimeZone-3688"><a href="#AtTimeZone-3688"><span class="linenos">3688</span></a><span class="k">class</span> <span class="nc">AtTimeZone</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="AtTimeZone-3689"><a href="#AtTimeZone-3689"><span class="linenos">3689</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -33780,8 +33908,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Between"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Between-3687"><a href="#Between-3687"><span class="linenos">3687</span></a><span class="k">class</span> <span class="nc">Between</span><span class="p">(</span><span class="n">Predicate</span><span class="p">):</span> -</span><span id="Between-3688"><a href="#Between-3688"><span class="linenos">3688</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"low"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"high"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Between-3692"><a href="#Between-3692"><span class="linenos">3692</span></a><span class="k">class</span> <span class="nc">Between</span><span class="p">(</span><span class="n">Predicate</span><span class="p">):</span> +</span><span id="Between-3693"><a href="#Between-3693"><span class="linenos">3693</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"low"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"high"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -33860,8 +33988,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Bracket"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Bracket-3691"><a href="#Bracket-3691"><span class="linenos">3691</span></a><span class="k">class</span> <span class="nc">Bracket</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> -</span><span id="Bracket-3692"><a href="#Bracket-3692"><span class="linenos">3692</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Bracket-3696"><a href="#Bracket-3696"><span class="linenos">3696</span></a><span class="k">class</span> <span class="nc">Bracket</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> +</span><span id="Bracket-3697"><a href="#Bracket-3697"><span class="linenos">3697</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -33940,8 +34068,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Distinct"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Distinct-3695"><a href="#Distinct-3695"><span class="linenos">3695</span></a><span class="k">class</span> <span class="nc">Distinct</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Distinct-3696"><a href="#Distinct-3696"><span class="linenos">3696</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Distinct-3700"><a href="#Distinct-3700"><span class="linenos">3700</span></a><span class="k">class</span> <span class="nc">Distinct</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Distinct-3701"><a href="#Distinct-3701"><span class="linenos">3701</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -34005,15 +34133,15 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#In"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="In-3699"><a href="#In-3699"><span class="linenos">3699</span></a><span class="k">class</span> <span class="nc">In</span><span class="p">(</span><span class="n">Predicate</span><span class="p">):</span> -</span><span id="In-3700"><a href="#In-3700"><span class="linenos">3700</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="In-3701"><a href="#In-3701"><span class="linenos">3701</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="In-3702"><a href="#In-3702"><span class="linenos">3702</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="In-3703"><a href="#In-3703"><span class="linenos">3703</span></a> <span class="s2">"query"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="In-3704"><a href="#In-3704"><span class="linenos">3704</span></a> <span class="s2">"unnest"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="In-3705"><a href="#In-3705"><span class="linenos">3705</span></a> <span class="s2">"field"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="In-3706"><a href="#In-3706"><span class="linenos">3706</span></a> <span class="s2">"is_global"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="In-3707"><a href="#In-3707"><span class="linenos">3707</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="In-3704"><a href="#In-3704"><span class="linenos">3704</span></a><span class="k">class</span> <span class="nc">In</span><span class="p">(</span><span class="n">Predicate</span><span class="p">):</span> +</span><span id="In-3705"><a href="#In-3705"><span class="linenos">3705</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="In-3706"><a href="#In-3706"><span class="linenos">3706</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="In-3707"><a href="#In-3707"><span class="linenos">3707</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="In-3708"><a href="#In-3708"><span class="linenos">3708</span></a> <span class="s2">"query"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="In-3709"><a href="#In-3709"><span class="linenos">3709</span></a> <span class="s2">"unnest"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="In-3710"><a href="#In-3710"><span class="linenos">3710</span></a> <span class="s2">"field"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="In-3711"><a href="#In-3711"><span class="linenos">3711</span></a> <span class="s2">"is_global"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="In-3712"><a href="#In-3712"><span class="linenos">3712</span></a> <span class="p">}</span> </span></pre></div> @@ -34092,19 +34220,19 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#TimeUnit"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TimeUnit-3710"><a href="#TimeUnit-3710"><span class="linenos">3710</span></a><span class="k">class</span> <span class="nc">TimeUnit</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="TimeUnit-3711"><a href="#TimeUnit-3711"><span class="linenos">3711</span></a><span class="w"> </span><span class="sd">"""Automatically converts unit arg into a var."""</span> -</span><span id="TimeUnit-3712"><a href="#TimeUnit-3712"><span class="linenos">3712</span></a> -</span><span id="TimeUnit-3713"><a href="#TimeUnit-3713"><span class="linenos">3713</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="TimeUnit-3714"><a href="#TimeUnit-3714"><span class="linenos">3714</span></a> -</span><span id="TimeUnit-3715"><a href="#TimeUnit-3715"><span class="linenos">3715</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">args</span><span class="p">):</span> -</span><span id="TimeUnit-3716"><a href="#TimeUnit-3716"><span class="linenos">3716</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> -</span><span id="TimeUnit-3717"><a href="#TimeUnit-3717"><span class="linenos">3717</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">unit</span><span class="p">,</span> <span class="p">(</span><span class="n">Column</span><span class="p">,</span> <span class="n">Literal</span><span class="p">)):</span> -</span><span id="TimeUnit-3718"><a href="#TimeUnit-3718"><span class="linenos">3718</span></a> <span class="n">args</span><span class="p">[</span><span class="s2">"unit"</span><span class="p">]</span> <span class="o">=</span> <span class="n">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">unit</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> -</span><span id="TimeUnit-3719"><a href="#TimeUnit-3719"><span class="linenos">3719</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">unit</span><span class="p">,</span> <span class="n">Week</span><span class="p">):</span> -</span><span id="TimeUnit-3720"><a href="#TimeUnit-3720"><span class="linenos">3720</span></a> <span class="n">unit</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">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">unit</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> -</span><span id="TimeUnit-3721"><a href="#TimeUnit-3721"><span class="linenos">3721</span></a> -</span><span id="TimeUnit-3722"><a href="#TimeUnit-3722"><span class="linenos">3722</span></a> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">**</span><span class="n">args</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TimeUnit-3715"><a href="#TimeUnit-3715"><span class="linenos">3715</span></a><span class="k">class</span> <span class="nc">TimeUnit</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="TimeUnit-3716"><a href="#TimeUnit-3716"><span class="linenos">3716</span></a><span class="w"> </span><span class="sd">"""Automatically converts unit arg into a var."""</span> +</span><span id="TimeUnit-3717"><a href="#TimeUnit-3717"><span class="linenos">3717</span></a> +</span><span id="TimeUnit-3718"><a href="#TimeUnit-3718"><span class="linenos">3718</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="TimeUnit-3719"><a href="#TimeUnit-3719"><span class="linenos">3719</span></a> +</span><span id="TimeUnit-3720"><a href="#TimeUnit-3720"><span class="linenos">3720</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">args</span><span class="p">):</span> +</span><span id="TimeUnit-3721"><a href="#TimeUnit-3721"><span class="linenos">3721</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> +</span><span id="TimeUnit-3722"><a href="#TimeUnit-3722"><span class="linenos">3722</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">unit</span><span class="p">,</span> <span class="p">(</span><span class="n">Column</span><span class="p">,</span> <span class="n">Literal</span><span class="p">)):</span> +</span><span id="TimeUnit-3723"><a href="#TimeUnit-3723"><span class="linenos">3723</span></a> <span class="n">args</span><span class="p">[</span><span class="s2">"unit"</span><span class="p">]</span> <span class="o">=</span> <span class="n">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">unit</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> +</span><span id="TimeUnit-3724"><a href="#TimeUnit-3724"><span class="linenos">3724</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">unit</span><span class="p">,</span> <span class="n">Week</span><span class="p">):</span> +</span><span id="TimeUnit-3725"><a href="#TimeUnit-3725"><span class="linenos">3725</span></a> <span class="n">unit</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">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">unit</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> +</span><span id="TimeUnit-3726"><a href="#TimeUnit-3726"><span class="linenos">3726</span></a> +</span><span id="TimeUnit-3727"><a href="#TimeUnit-3727"><span class="linenos">3727</span></a> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">**</span><span class="n">args</span><span class="p">)</span> </span></pre></div> @@ -34122,14 +34250,14 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#TimeUnit.__init__"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TimeUnit.__init__-3715"><a href="#TimeUnit.__init__-3715"><span class="linenos">3715</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">args</span><span class="p">):</span> -</span><span id="TimeUnit.__init__-3716"><a href="#TimeUnit.__init__-3716"><span class="linenos">3716</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> -</span><span id="TimeUnit.__init__-3717"><a href="#TimeUnit.__init__-3717"><span class="linenos">3717</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">unit</span><span class="p">,</span> <span class="p">(</span><span class="n">Column</span><span class="p">,</span> <span class="n">Literal</span><span class="p">)):</span> -</span><span id="TimeUnit.__init__-3718"><a href="#TimeUnit.__init__-3718"><span class="linenos">3718</span></a> <span class="n">args</span><span class="p">[</span><span class="s2">"unit"</span><span class="p">]</span> <span class="o">=</span> <span class="n">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">unit</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> -</span><span id="TimeUnit.__init__-3719"><a href="#TimeUnit.__init__-3719"><span class="linenos">3719</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">unit</span><span class="p">,</span> <span class="n">Week</span><span class="p">):</span> -</span><span id="TimeUnit.__init__-3720"><a href="#TimeUnit.__init__-3720"><span class="linenos">3720</span></a> <span class="n">unit</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">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">unit</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> -</span><span id="TimeUnit.__init__-3721"><a href="#TimeUnit.__init__-3721"><span class="linenos">3721</span></a> -</span><span id="TimeUnit.__init__-3722"><a href="#TimeUnit.__init__-3722"><span class="linenos">3722</span></a> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">**</span><span class="n">args</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TimeUnit.__init__-3720"><a href="#TimeUnit.__init__-3720"><span class="linenos">3720</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">args</span><span class="p">):</span> +</span><span id="TimeUnit.__init__-3721"><a href="#TimeUnit.__init__-3721"><span class="linenos">3721</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> +</span><span id="TimeUnit.__init__-3722"><a href="#TimeUnit.__init__-3722"><span class="linenos">3722</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">unit</span><span class="p">,</span> <span class="p">(</span><span class="n">Column</span><span class="p">,</span> <span class="n">Literal</span><span class="p">)):</span> +</span><span id="TimeUnit.__init__-3723"><a href="#TimeUnit.__init__-3723"><span class="linenos">3723</span></a> <span class="n">args</span><span class="p">[</span><span class="s2">"unit"</span><span class="p">]</span> <span class="o">=</span> <span class="n">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">unit</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> +</span><span id="TimeUnit.__init__-3724"><a href="#TimeUnit.__init__-3724"><span class="linenos">3724</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">unit</span><span class="p">,</span> <span class="n">Week</span><span class="p">):</span> +</span><span id="TimeUnit.__init__-3725"><a href="#TimeUnit.__init__-3725"><span class="linenos">3725</span></a> <span class="n">unit</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">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">unit</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> +</span><span id="TimeUnit.__init__-3726"><a href="#TimeUnit.__init__-3726"><span class="linenos">3726</span></a> +</span><span id="TimeUnit.__init__-3727"><a href="#TimeUnit.__init__-3727"><span class="linenos">3727</span></a> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">**</span><span class="n">args</span><span class="p">)</span> </span></pre></div> @@ -34193,12 +34321,12 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Interval"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Interval-3725"><a href="#Interval-3725"><span class="linenos">3725</span></a><span class="k">class</span> <span class="nc">Interval</span><span class="p">(</span><span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="Interval-3726"><a href="#Interval-3726"><span class="linenos">3726</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="Interval-3727"><a href="#Interval-3727"><span class="linenos">3727</span></a> -</span><span id="Interval-3728"><a href="#Interval-3728"><span class="linenos">3728</span></a> <span class="nd">@property</span> -</span><span id="Interval-3729"><a href="#Interval-3729"><span class="linenos">3729</span></a> <span class="k">def</span> <span class="nf">unit</span><span class="p">(</span><span class="bp">self</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">Var</span><span class="p">]:</span> -</span><span id="Interval-3730"><a href="#Interval-3730"><span class="linenos">3730</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Interval-3730"><a href="#Interval-3730"><span class="linenos">3730</span></a><span class="k">class</span> <span class="nc">Interval</span><span class="p">(</span><span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="Interval-3731"><a href="#Interval-3731"><span class="linenos">3731</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="Interval-3732"><a href="#Interval-3732"><span class="linenos">3732</span></a> +</span><span id="Interval-3733"><a href="#Interval-3733"><span class="linenos">3733</span></a> <span class="nd">@property</span> +</span><span id="Interval-3734"><a href="#Interval-3734"><span class="linenos">3734</span></a> <span class="k">def</span> <span class="nf">unit</span><span class="p">(</span><span class="bp">self</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">Var</span><span class="p">]:</span> +</span><span id="Interval-3735"><a href="#Interval-3735"><span class="linenos">3735</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">)</span> </span></pre></div> @@ -34265,8 +34393,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#IgnoreNulls"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="IgnoreNulls-3733"><a href="#IgnoreNulls-3733"><span class="linenos">3733</span></a><span class="k">class</span> <span class="nc">IgnoreNulls</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="IgnoreNulls-3734"><a href="#IgnoreNulls-3734"><span class="linenos">3734</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="IgnoreNulls-3738"><a href="#IgnoreNulls-3738"><span class="linenos">3738</span></a><span class="k">class</span> <span class="nc">IgnoreNulls</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="IgnoreNulls-3739"><a href="#IgnoreNulls-3739"><span class="linenos">3739</span></a> <span class="k">pass</span> </span></pre></div> @@ -34330,8 +34458,8 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#RespectNulls"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="RespectNulls-3737"><a href="#RespectNulls-3737"><span class="linenos">3737</span></a><span class="k">class</span> <span class="nc">RespectNulls</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="RespectNulls-3738"><a href="#RespectNulls-3738"><span class="linenos">3738</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="RespectNulls-3742"><a href="#RespectNulls-3742"><span class="linenos">3742</span></a><span class="k">class</span> <span class="nc">RespectNulls</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="RespectNulls-3743"><a href="#RespectNulls-3743"><span class="linenos">3743</span></a> <span class="k">pass</span> </span></pre></div> @@ -34395,53 +34523,53 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#Func"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Func-3742"><a href="#Func-3742"><span class="linenos">3742</span></a><span class="k">class</span> <span class="nc">Func</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> -</span><span id="Func-3743"><a href="#Func-3743"><span class="linenos">3743</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Func-3744"><a href="#Func-3744"><span class="linenos">3744</span></a><span class="sd"> The base class for all function expressions.</span> -</span><span id="Func-3745"><a href="#Func-3745"><span class="linenos">3745</span></a> -</span><span id="Func-3746"><a href="#Func-3746"><span class="linenos">3746</span></a><span class="sd"> Attributes:</span> -</span><span id="Func-3747"><a href="#Func-3747"><span class="linenos">3747</span></a><span class="sd"> is_var_len_args (bool): if set to True the last argument defined in arg_types will be</span> -</span><span id="Func-3748"><a href="#Func-3748"><span class="linenos">3748</span></a><span class="sd"> treated as a variable length argument and the argument's value will be stored as a list.</span> -</span><span id="Func-3749"><a href="#Func-3749"><span class="linenos">3749</span></a><span class="sd"> _sql_names (list): determines the SQL name (1st item in the list) and aliases (subsequent items)</span> -</span><span id="Func-3750"><a href="#Func-3750"><span class="linenos">3750</span></a><span class="sd"> for this function expression. These values are used to map this node to a name during parsing</span> -</span><span id="Func-3751"><a href="#Func-3751"><span class="linenos">3751</span></a><span class="sd"> as well as to provide the function's name during SQL string generation. By default the SQL</span> -</span><span id="Func-3752"><a href="#Func-3752"><span class="linenos">3752</span></a><span class="sd"> name is set to the expression's class name transformed to snake case.</span> -</span><span id="Func-3753"><a href="#Func-3753"><span class="linenos">3753</span></a><span class="sd"> """</span> -</span><span id="Func-3754"><a href="#Func-3754"><span class="linenos">3754</span></a> -</span><span id="Func-3755"><a href="#Func-3755"><span class="linenos">3755</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Func-3756"><a href="#Func-3756"><span class="linenos">3756</span></a> -</span><span id="Func-3757"><a href="#Func-3757"><span class="linenos">3757</span></a> <span class="nd">@classmethod</span> -</span><span id="Func-3758"><a href="#Func-3758"><span class="linenos">3758</span></a> <span class="k">def</span> <span class="nf">from_arg_list</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">args</span><span class="p">):</span> -</span><span id="Func-3759"><a href="#Func-3759"><span class="linenos">3759</span></a> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">is_var_len_args</span><span class="p">:</span> -</span><span id="Func-3760"><a href="#Func-3760"><span class="linenos">3760</span></a> <span class="n">all_arg_keys</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="bp">cls</span><span class="o">.</span><span class="n">arg_types</span><span class="p">)</span> -</span><span id="Func-3761"><a href="#Func-3761"><span class="linenos">3761</span></a> <span class="c1"># If this function supports variable length argument treat the last argument as such.</span> -</span><span id="Func-3762"><a href="#Func-3762"><span class="linenos">3762</span></a> <span class="n">non_var_len_arg_keys</span> <span class="o">=</span> <span class="n">all_arg_keys</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">is_var_len_args</span> <span class="k">else</span> <span class="n">all_arg_keys</span> -</span><span id="Func-3763"><a href="#Func-3763"><span class="linenos">3763</span></a> <span class="n">num_non_var</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">non_var_len_arg_keys</span><span class="p">)</span> -</span><span id="Func-3764"><a href="#Func-3764"><span class="linenos">3764</span></a> -</span><span id="Func-3765"><a href="#Func-3765"><span class="linenos">3765</span></a> <span class="n">args_dict</span> <span class="o">=</span> <span class="p">{</span><span class="n">arg_key</span><span class="p">:</span> <span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span><span class="p">,</span> <span class="n">arg_key</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="n">non_var_len_arg_keys</span><span class="p">)}</span> -</span><span id="Func-3766"><a href="#Func-3766"><span class="linenos">3766</span></a> <span class="n">args_dict</span><span class="p">[</span><span class="n">all_arg_keys</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="n">num_non_var</span><span class="p">:]</span> -</span><span id="Func-3767"><a href="#Func-3767"><span class="linenos">3767</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Func-3768"><a href="#Func-3768"><span class="linenos">3768</span></a> <span class="n">args_dict</span> <span class="o">=</span> <span class="p">{</span><span class="n">arg_key</span><span class="p">:</span> <span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span><span class="p">,</span> <span class="n">arg_key</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">arg_types</span><span class="p">)}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Func-3747"><a href="#Func-3747"><span class="linenos">3747</span></a><span class="k">class</span> <span class="nc">Func</span><span class="p">(</span><span class="n">Condition</span><span class="p">):</span> +</span><span id="Func-3748"><a href="#Func-3748"><span class="linenos">3748</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Func-3749"><a href="#Func-3749"><span class="linenos">3749</span></a><span class="sd"> The base class for all function expressions.</span> +</span><span id="Func-3750"><a href="#Func-3750"><span class="linenos">3750</span></a> +</span><span id="Func-3751"><a href="#Func-3751"><span class="linenos">3751</span></a><span class="sd"> Attributes:</span> +</span><span id="Func-3752"><a href="#Func-3752"><span class="linenos">3752</span></a><span class="sd"> is_var_len_args (bool): if set to True the last argument defined in arg_types will be</span> +</span><span id="Func-3753"><a href="#Func-3753"><span class="linenos">3753</span></a><span class="sd"> treated as a variable length argument and the argument's value will be stored as a list.</span> +</span><span id="Func-3754"><a href="#Func-3754"><span class="linenos">3754</span></a><span class="sd"> _sql_names (list): determines the SQL name (1st item in the list) and aliases (subsequent items)</span> +</span><span id="Func-3755"><a href="#Func-3755"><span class="linenos">3755</span></a><span class="sd"> for this function expression. These values are used to map this node to a name during parsing</span> +</span><span id="Func-3756"><a href="#Func-3756"><span class="linenos">3756</span></a><span class="sd"> as well as to provide the function's name during SQL string generation. By default the SQL</span> +</span><span id="Func-3757"><a href="#Func-3757"><span class="linenos">3757</span></a><span class="sd"> name is set to the expression's class name transformed to snake case.</span> +</span><span id="Func-3758"><a href="#Func-3758"><span class="linenos">3758</span></a><span class="sd"> """</span> +</span><span id="Func-3759"><a href="#Func-3759"><span class="linenos">3759</span></a> +</span><span id="Func-3760"><a href="#Func-3760"><span class="linenos">3760</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Func-3761"><a href="#Func-3761"><span class="linenos">3761</span></a> +</span><span id="Func-3762"><a href="#Func-3762"><span class="linenos">3762</span></a> <span class="nd">@classmethod</span> +</span><span id="Func-3763"><a href="#Func-3763"><span class="linenos">3763</span></a> <span class="k">def</span> <span class="nf">from_arg_list</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">args</span><span class="p">):</span> +</span><span id="Func-3764"><a href="#Func-3764"><span class="linenos">3764</span></a> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">is_var_len_args</span><span class="p">:</span> +</span><span id="Func-3765"><a href="#Func-3765"><span class="linenos">3765</span></a> <span class="n">all_arg_keys</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="bp">cls</span><span class="o">.</span><span class="n">arg_types</span><span class="p">)</span> +</span><span id="Func-3766"><a href="#Func-3766"><span class="linenos">3766</span></a> <span class="c1"># If this function supports variable length argument treat the last argument as such.</span> +</span><span id="Func-3767"><a href="#Func-3767"><span class="linenos">3767</span></a> <span class="n">non_var_len_arg_keys</span> <span class="o">=</span> <span class="n">all_arg_keys</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">is_var_len_args</span> <span class="k">else</span> <span class="n">all_arg_keys</span> +</span><span id="Func-3768"><a href="#Func-3768"><span class="linenos">3768</span></a> <span class="n">num_non_var</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">non_var_len_arg_keys</span><span class="p">)</span> </span><span id="Func-3769"><a href="#Func-3769"><span class="linenos">3769</span></a> -</span><span id="Func-3770"><a href="#Func-3770"><span class="linenos">3770</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="o">**</span><span class="n">args_dict</span><span class="p">)</span> -</span><span id="Func-3771"><a href="#Func-3771"><span class="linenos">3771</span></a> -</span><span id="Func-3772"><a href="#Func-3772"><span class="linenos">3772</span></a> <span class="nd">@classmethod</span> -</span><span id="Func-3773"><a href="#Func-3773"><span class="linenos">3773</span></a> <span class="k">def</span> <span class="nf">sql_names</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span> -</span><span id="Func-3774"><a href="#Func-3774"><span class="linenos">3774</span></a> <span class="k">if</span> <span class="bp">cls</span> <span class="ow">is</span> <span class="n">Func</span><span class="p">:</span> -</span><span id="Func-3775"><a href="#Func-3775"><span class="linenos">3775</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span> -</span><span id="Func-3776"><a href="#Func-3776"><span class="linenos">3776</span></a> <span class="s2">"SQL name is only supported by concrete function implementations"</span> -</span><span id="Func-3777"><a href="#Func-3777"><span class="linenos">3777</span></a> <span class="p">)</span> -</span><span id="Func-3778"><a href="#Func-3778"><span class="linenos">3778</span></a> <span class="k">if</span> <span class="s2">"_sql_names"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">cls</span><span class="o">.</span><span class="vm">__dict__</span><span class="p">:</span> -</span><span id="Func-3779"><a href="#Func-3779"><span class="linenos">3779</span></a> <span class="bp">cls</span><span class="o">.</span><span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="n">camel_to_snake_case</span><span class="p">(</span><span class="bp">cls</span><span class="o">.</span><span class="vm">__name__</span><span class="p">)]</span> -</span><span id="Func-3780"><a href="#Func-3780"><span class="linenos">3780</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">_sql_names</span> -</span><span id="Func-3781"><a href="#Func-3781"><span class="linenos">3781</span></a> -</span><span id="Func-3782"><a href="#Func-3782"><span class="linenos">3782</span></a> <span class="nd">@classmethod</span> -</span><span id="Func-3783"><a href="#Func-3783"><span class="linenos">3783</span></a> <span class="k">def</span> <span class="nf">sql_name</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span> -</span><span id="Func-3784"><a href="#Func-3784"><span class="linenos">3784</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">sql_names</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="Func-3785"><a href="#Func-3785"><span class="linenos">3785</span></a> -</span><span id="Func-3786"><a href="#Func-3786"><span class="linenos">3786</span></a> <span class="nd">@classmethod</span> -</span><span id="Func-3787"><a href="#Func-3787"><span class="linenos">3787</span></a> <span class="k">def</span> <span class="nf">default_parser_mappings</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span> -</span><span id="Func-3788"><a href="#Func-3788"><span class="linenos">3788</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">name</span><span class="p">:</span> <span class="bp">cls</span><span class="o">.</span><span class="n">from_arg_list</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="bp">cls</span><span class="o">.</span><span class="n">sql_names</span><span class="p">()}</span> +</span><span id="Func-3770"><a href="#Func-3770"><span class="linenos">3770</span></a> <span class="n">args_dict</span> <span class="o">=</span> <span class="p">{</span><span class="n">arg_key</span><span class="p">:</span> <span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span><span class="p">,</span> <span class="n">arg_key</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="n">non_var_len_arg_keys</span><span class="p">)}</span> +</span><span id="Func-3771"><a href="#Func-3771"><span class="linenos">3771</span></a> <span class="n">args_dict</span><span class="p">[</span><span class="n">all_arg_keys</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="n">num_non_var</span><span class="p">:]</span> +</span><span id="Func-3772"><a href="#Func-3772"><span class="linenos">3772</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Func-3773"><a href="#Func-3773"><span class="linenos">3773</span></a> <span class="n">args_dict</span> <span class="o">=</span> <span class="p">{</span><span class="n">arg_key</span><span class="p">:</span> <span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span><span class="p">,</span> <span class="n">arg_key</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">arg_types</span><span class="p">)}</span> +</span><span id="Func-3774"><a href="#Func-3774"><span class="linenos">3774</span></a> +</span><span id="Func-3775"><a href="#Func-3775"><span class="linenos">3775</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="o">**</span><span class="n">args_dict</span><span class="p">)</span> +</span><span id="Func-3776"><a href="#Func-3776"><span class="linenos">3776</span></a> +</span><span id="Func-3777"><a href="#Func-3777"><span class="linenos">3777</span></a> <span class="nd">@classmethod</span> +</span><span id="Func-3778"><a href="#Func-3778"><span class="linenos">3778</span></a> <span class="k">def</span> <span class="nf">sql_names</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span> +</span><span id="Func-3779"><a href="#Func-3779"><span class="linenos">3779</span></a> <span class="k">if</span> <span class="bp">cls</span> <span class="ow">is</span> <span class="n">Func</span><span class="p">:</span> +</span><span id="Func-3780"><a href="#Func-3780"><span class="linenos">3780</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span> +</span><span id="Func-3781"><a href="#Func-3781"><span class="linenos">3781</span></a> <span class="s2">"SQL name is only supported by concrete function implementations"</span> +</span><span id="Func-3782"><a href="#Func-3782"><span class="linenos">3782</span></a> <span class="p">)</span> +</span><span id="Func-3783"><a href="#Func-3783"><span class="linenos">3783</span></a> <span class="k">if</span> <span class="s2">"_sql_names"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">cls</span><span class="o">.</span><span class="vm">__dict__</span><span class="p">:</span> +</span><span id="Func-3784"><a href="#Func-3784"><span class="linenos">3784</span></a> <span class="bp">cls</span><span class="o">.</span><span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="n">camel_to_snake_case</span><span class="p">(</span><span class="bp">cls</span><span class="o">.</span><span class="vm">__name__</span><span class="p">)]</span> +</span><span id="Func-3785"><a href="#Func-3785"><span class="linenos">3785</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">_sql_names</span> +</span><span id="Func-3786"><a href="#Func-3786"><span class="linenos">3786</span></a> +</span><span id="Func-3787"><a href="#Func-3787"><span class="linenos">3787</span></a> <span class="nd">@classmethod</span> +</span><span id="Func-3788"><a href="#Func-3788"><span class="linenos">3788</span></a> <span class="k">def</span> <span class="nf">sql_name</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span> +</span><span id="Func-3789"><a href="#Func-3789"><span class="linenos">3789</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">sql_names</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="Func-3790"><a href="#Func-3790"><span class="linenos">3790</span></a> +</span><span id="Func-3791"><a href="#Func-3791"><span class="linenos">3791</span></a> <span class="nd">@classmethod</span> +</span><span id="Func-3792"><a href="#Func-3792"><span class="linenos">3792</span></a> <span class="k">def</span> <span class="nf">default_parser_mappings</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span> +</span><span id="Func-3793"><a href="#Func-3793"><span class="linenos">3793</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">name</span><span class="p">:</span> <span class="bp">cls</span><span class="o">.</span><span class="n">from_arg_list</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="bp">cls</span><span class="o">.</span><span class="n">sql_names</span><span class="p">()}</span> </span></pre></div> @@ -34472,20 +34600,20 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Func.from_arg_list"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Func.from_arg_list-3757"><a href="#Func.from_arg_list-3757"><span class="linenos">3757</span></a> <span class="nd">@classmethod</span> -</span><span id="Func.from_arg_list-3758"><a href="#Func.from_arg_list-3758"><span class="linenos">3758</span></a> <span class="k">def</span> <span class="nf">from_arg_list</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">args</span><span class="p">):</span> -</span><span id="Func.from_arg_list-3759"><a href="#Func.from_arg_list-3759"><span class="linenos">3759</span></a> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">is_var_len_args</span><span class="p">:</span> -</span><span id="Func.from_arg_list-3760"><a href="#Func.from_arg_list-3760"><span class="linenos">3760</span></a> <span class="n">all_arg_keys</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="bp">cls</span><span class="o">.</span><span class="n">arg_types</span><span class="p">)</span> -</span><span id="Func.from_arg_list-3761"><a href="#Func.from_arg_list-3761"><span class="linenos">3761</span></a> <span class="c1"># If this function supports variable length argument treat the last argument as such.</span> -</span><span id="Func.from_arg_list-3762"><a href="#Func.from_arg_list-3762"><span class="linenos">3762</span></a> <span class="n">non_var_len_arg_keys</span> <span class="o">=</span> <span class="n">all_arg_keys</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">is_var_len_args</span> <span class="k">else</span> <span class="n">all_arg_keys</span> -</span><span id="Func.from_arg_list-3763"><a href="#Func.from_arg_list-3763"><span class="linenos">3763</span></a> <span class="n">num_non_var</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">non_var_len_arg_keys</span><span class="p">)</span> -</span><span id="Func.from_arg_list-3764"><a href="#Func.from_arg_list-3764"><span class="linenos">3764</span></a> -</span><span id="Func.from_arg_list-3765"><a href="#Func.from_arg_list-3765"><span class="linenos">3765</span></a> <span class="n">args_dict</span> <span class="o">=</span> <span class="p">{</span><span class="n">arg_key</span><span class="p">:</span> <span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span><span class="p">,</span> <span class="n">arg_key</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="n">non_var_len_arg_keys</span><span class="p">)}</span> -</span><span id="Func.from_arg_list-3766"><a href="#Func.from_arg_list-3766"><span class="linenos">3766</span></a> <span class="n">args_dict</span><span class="p">[</span><span class="n">all_arg_keys</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="n">num_non_var</span><span class="p">:]</span> -</span><span id="Func.from_arg_list-3767"><a href="#Func.from_arg_list-3767"><span class="linenos">3767</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Func.from_arg_list-3768"><a href="#Func.from_arg_list-3768"><span class="linenos">3768</span></a> <span class="n">args_dict</span> <span class="o">=</span> <span class="p">{</span><span class="n">arg_key</span><span class="p">:</span> <span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span><span class="p">,</span> <span class="n">arg_key</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">arg_types</span><span class="p">)}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Func.from_arg_list-3762"><a href="#Func.from_arg_list-3762"><span class="linenos">3762</span></a> <span class="nd">@classmethod</span> +</span><span id="Func.from_arg_list-3763"><a href="#Func.from_arg_list-3763"><span class="linenos">3763</span></a> <span class="k">def</span> <span class="nf">from_arg_list</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">args</span><span class="p">):</span> +</span><span id="Func.from_arg_list-3764"><a href="#Func.from_arg_list-3764"><span class="linenos">3764</span></a> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">is_var_len_args</span><span class="p">:</span> +</span><span id="Func.from_arg_list-3765"><a href="#Func.from_arg_list-3765"><span class="linenos">3765</span></a> <span class="n">all_arg_keys</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="bp">cls</span><span class="o">.</span><span class="n">arg_types</span><span class="p">)</span> +</span><span id="Func.from_arg_list-3766"><a href="#Func.from_arg_list-3766"><span class="linenos">3766</span></a> <span class="c1"># If this function supports variable length argument treat the last argument as such.</span> +</span><span id="Func.from_arg_list-3767"><a href="#Func.from_arg_list-3767"><span class="linenos">3767</span></a> <span class="n">non_var_len_arg_keys</span> <span class="o">=</span> <span class="n">all_arg_keys</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="k">if</span> <span class="bp">cls</span><span class="o">.</span><span class="n">is_var_len_args</span> <span class="k">else</span> <span class="n">all_arg_keys</span> +</span><span id="Func.from_arg_list-3768"><a href="#Func.from_arg_list-3768"><span class="linenos">3768</span></a> <span class="n">num_non_var</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">non_var_len_arg_keys</span><span class="p">)</span> </span><span id="Func.from_arg_list-3769"><a href="#Func.from_arg_list-3769"><span class="linenos">3769</span></a> -</span><span id="Func.from_arg_list-3770"><a href="#Func.from_arg_list-3770"><span class="linenos">3770</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="o">**</span><span class="n">args_dict</span><span class="p">)</span> +</span><span id="Func.from_arg_list-3770"><a href="#Func.from_arg_list-3770"><span class="linenos">3770</span></a> <span class="n">args_dict</span> <span class="o">=</span> <span class="p">{</span><span class="n">arg_key</span><span class="p">:</span> <span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span><span class="p">,</span> <span class="n">arg_key</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="n">non_var_len_arg_keys</span><span class="p">)}</span> +</span><span id="Func.from_arg_list-3771"><a href="#Func.from_arg_list-3771"><span class="linenos">3771</span></a> <span class="n">args_dict</span><span class="p">[</span><span class="n">all_arg_keys</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">args</span><span class="p">[</span><span class="n">num_non_var</span><span class="p">:]</span> +</span><span id="Func.from_arg_list-3772"><a href="#Func.from_arg_list-3772"><span class="linenos">3772</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Func.from_arg_list-3773"><a href="#Func.from_arg_list-3773"><span class="linenos">3773</span></a> <span class="n">args_dict</span> <span class="o">=</span> <span class="p">{</span><span class="n">arg_key</span><span class="p">:</span> <span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span><span class="p">,</span> <span class="n">arg_key</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="bp">cls</span><span class="o">.</span><span class="n">arg_types</span><span class="p">)}</span> +</span><span id="Func.from_arg_list-3774"><a href="#Func.from_arg_list-3774"><span class="linenos">3774</span></a> +</span><span id="Func.from_arg_list-3775"><a href="#Func.from_arg_list-3775"><span class="linenos">3775</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="o">**</span><span class="n">args_dict</span><span class="p">)</span> </span></pre></div> @@ -34504,15 +34632,15 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Func.sql_names"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Func.sql_names-3772"><a href="#Func.sql_names-3772"><span class="linenos">3772</span></a> <span class="nd">@classmethod</span> -</span><span id="Func.sql_names-3773"><a href="#Func.sql_names-3773"><span class="linenos">3773</span></a> <span class="k">def</span> <span class="nf">sql_names</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span> -</span><span id="Func.sql_names-3774"><a href="#Func.sql_names-3774"><span class="linenos">3774</span></a> <span class="k">if</span> <span class="bp">cls</span> <span class="ow">is</span> <span class="n">Func</span><span class="p">:</span> -</span><span id="Func.sql_names-3775"><a href="#Func.sql_names-3775"><span class="linenos">3775</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span> -</span><span id="Func.sql_names-3776"><a href="#Func.sql_names-3776"><span class="linenos">3776</span></a> <span class="s2">"SQL name is only supported by concrete function implementations"</span> -</span><span id="Func.sql_names-3777"><a href="#Func.sql_names-3777"><span class="linenos">3777</span></a> <span class="p">)</span> -</span><span id="Func.sql_names-3778"><a href="#Func.sql_names-3778"><span class="linenos">3778</span></a> <span class="k">if</span> <span class="s2">"_sql_names"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">cls</span><span class="o">.</span><span class="vm">__dict__</span><span class="p">:</span> -</span><span id="Func.sql_names-3779"><a href="#Func.sql_names-3779"><span class="linenos">3779</span></a> <span class="bp">cls</span><span class="o">.</span><span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="n">camel_to_snake_case</span><span class="p">(</span><span class="bp">cls</span><span class="o">.</span><span class="vm">__name__</span><span class="p">)]</span> -</span><span id="Func.sql_names-3780"><a href="#Func.sql_names-3780"><span class="linenos">3780</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">_sql_names</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Func.sql_names-3777"><a href="#Func.sql_names-3777"><span class="linenos">3777</span></a> <span class="nd">@classmethod</span> +</span><span id="Func.sql_names-3778"><a href="#Func.sql_names-3778"><span class="linenos">3778</span></a> <span class="k">def</span> <span class="nf">sql_names</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span> +</span><span id="Func.sql_names-3779"><a href="#Func.sql_names-3779"><span class="linenos">3779</span></a> <span class="k">if</span> <span class="bp">cls</span> <span class="ow">is</span> <span class="n">Func</span><span class="p">:</span> +</span><span id="Func.sql_names-3780"><a href="#Func.sql_names-3780"><span class="linenos">3780</span></a> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span> +</span><span id="Func.sql_names-3781"><a href="#Func.sql_names-3781"><span class="linenos">3781</span></a> <span class="s2">"SQL name is only supported by concrete function implementations"</span> +</span><span id="Func.sql_names-3782"><a href="#Func.sql_names-3782"><span class="linenos">3782</span></a> <span class="p">)</span> +</span><span id="Func.sql_names-3783"><a href="#Func.sql_names-3783"><span class="linenos">3783</span></a> <span class="k">if</span> <span class="s2">"_sql_names"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">cls</span><span class="o">.</span><span class="vm">__dict__</span><span class="p">:</span> +</span><span id="Func.sql_names-3784"><a href="#Func.sql_names-3784"><span class="linenos">3784</span></a> <span class="bp">cls</span><span class="o">.</span><span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="n">camel_to_snake_case</span><span class="p">(</span><span class="bp">cls</span><span class="o">.</span><span class="vm">__name__</span><span class="p">)]</span> +</span><span id="Func.sql_names-3785"><a href="#Func.sql_names-3785"><span class="linenos">3785</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">_sql_names</span> </span></pre></div> @@ -34531,9 +34659,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Func.sql_name"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Func.sql_name-3782"><a href="#Func.sql_name-3782"><span class="linenos">3782</span></a> <span class="nd">@classmethod</span> -</span><span id="Func.sql_name-3783"><a href="#Func.sql_name-3783"><span class="linenos">3783</span></a> <span class="k">def</span> <span class="nf">sql_name</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span> -</span><span id="Func.sql_name-3784"><a href="#Func.sql_name-3784"><span class="linenos">3784</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">sql_names</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Func.sql_name-3787"><a href="#Func.sql_name-3787"><span class="linenos">3787</span></a> <span class="nd">@classmethod</span> +</span><span id="Func.sql_name-3788"><a href="#Func.sql_name-3788"><span class="linenos">3788</span></a> <span class="k">def</span> <span class="nf">sql_name</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span> +</span><span id="Func.sql_name-3789"><a href="#Func.sql_name-3789"><span class="linenos">3789</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">sql_names</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> </span></pre></div> @@ -34552,9 +34680,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Func.default_parser_mappings"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Func.default_parser_mappings-3786"><a href="#Func.default_parser_mappings-3786"><span class="linenos">3786</span></a> <span class="nd">@classmethod</span> -</span><span id="Func.default_parser_mappings-3787"><a href="#Func.default_parser_mappings-3787"><span class="linenos">3787</span></a> <span class="k">def</span> <span class="nf">default_parser_mappings</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span> -</span><span id="Func.default_parser_mappings-3788"><a href="#Func.default_parser_mappings-3788"><span class="linenos">3788</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">name</span><span class="p">:</span> <span class="bp">cls</span><span class="o">.</span><span class="n">from_arg_list</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="bp">cls</span><span class="o">.</span><span class="n">sql_names</span><span class="p">()}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Func.default_parser_mappings-3791"><a href="#Func.default_parser_mappings-3791"><span class="linenos">3791</span></a> <span class="nd">@classmethod</span> +</span><span id="Func.default_parser_mappings-3792"><a href="#Func.default_parser_mappings-3792"><span class="linenos">3792</span></a> <span class="k">def</span> <span class="nf">default_parser_mappings</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span> +</span><span id="Func.default_parser_mappings-3793"><a href="#Func.default_parser_mappings-3793"><span class="linenos">3793</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">name</span><span class="p">:</span> <span class="bp">cls</span><span class="o">.</span><span class="n">from_arg_list</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="bp">cls</span><span class="o">.</span><span class="n">sql_names</span><span class="p">()}</span> </span></pre></div> @@ -34634,8 +34762,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#AggFunc"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="AggFunc-3791"><a href="#AggFunc-3791"><span class="linenos">3791</span></a><span class="k">class</span> <span class="nc">AggFunc</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="AggFunc-3792"><a href="#AggFunc-3792"><span class="linenos">3792</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="AggFunc-3796"><a href="#AggFunc-3796"><span class="linenos">3796</span></a><span class="k">class</span> <span class="nc">AggFunc</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="AggFunc-3797"><a href="#AggFunc-3797"><span class="linenos">3797</span></a> <span class="k">pass</span> </span></pre></div> @@ -34721,8 +34849,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#ParameterizedAgg"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ParameterizedAgg-3795"><a href="#ParameterizedAgg-3795"><span class="linenos">3795</span></a><span class="k">class</span> <span class="nc">ParameterizedAgg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="ParameterizedAgg-3796"><a href="#ParameterizedAgg-3796"><span class="linenos">3796</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"params"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ParameterizedAgg-3800"><a href="#ParameterizedAgg-3800"><span class="linenos">3800</span></a><span class="k">class</span> <span class="nc">ParameterizedAgg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="ParameterizedAgg-3801"><a href="#ParameterizedAgg-3801"><span class="linenos">3801</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"params"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -34808,8 +34936,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Abs"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Abs-3799"><a href="#Abs-3799"><span class="linenos">3799</span></a><span class="k">class</span> <span class="nc">Abs</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Abs-3800"><a href="#Abs-3800"><span class="linenos">3800</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Abs-3804"><a href="#Abs-3804"><span class="linenos">3804</span></a><span class="k">class</span> <span class="nc">Abs</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Abs-3805"><a href="#Abs-3805"><span class="linenos">3805</span></a> <span class="k">pass</span> </span></pre></div> @@ -34895,9 +35023,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Anonymous"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Anonymous-3803"><a href="#Anonymous-3803"><span class="linenos">3803</span></a><span class="k">class</span> <span class="nc">Anonymous</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Anonymous-3804"><a href="#Anonymous-3804"><span class="linenos">3804</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="Anonymous-3805"><a href="#Anonymous-3805"><span class="linenos">3805</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Anonymous-3808"><a href="#Anonymous-3808"><span class="linenos">3808</span></a><span class="k">class</span> <span class="nc">Anonymous</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Anonymous-3809"><a href="#Anonymous-3809"><span class="linenos">3809</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="Anonymous-3810"><a href="#Anonymous-3810"><span class="linenos">3810</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span></pre></div> @@ -34983,9 +35111,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Hll"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Hll-3810"><a href="#Hll-3810"><span class="linenos">3810</span></a><span class="k">class</span> <span class="nc">Hll</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="Hll-3811"><a href="#Hll-3811"><span class="linenos">3811</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="Hll-3812"><a href="#Hll-3812"><span class="linenos">3812</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Hll-3815"><a href="#Hll-3815"><span class="linenos">3815</span></a><span class="k">class</span> <span class="nc">Hll</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="Hll-3816"><a href="#Hll-3816"><span class="linenos">3816</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="Hll-3817"><a href="#Hll-3817"><span class="linenos">3817</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span></pre></div> @@ -35071,9 +35199,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#ApproxDistinct"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ApproxDistinct-3815"><a href="#ApproxDistinct-3815"><span class="linenos">3815</span></a><span class="k">class</span> <span class="nc">ApproxDistinct</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="ApproxDistinct-3816"><a href="#ApproxDistinct-3816"><span class="linenos">3816</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"accuracy"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="ApproxDistinct-3817"><a href="#ApproxDistinct-3817"><span class="linenos">3817</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"APPROX_DISTINCT"</span><span class="p">,</span> <span class="s2">"APPROX_COUNT_DISTINCT"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ApproxDistinct-3820"><a href="#ApproxDistinct-3820"><span class="linenos">3820</span></a><span class="k">class</span> <span class="nc">ApproxDistinct</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="ApproxDistinct-3821"><a href="#ApproxDistinct-3821"><span class="linenos">3821</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"accuracy"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="ApproxDistinct-3822"><a href="#ApproxDistinct-3822"><span class="linenos">3822</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"APPROX_DISTINCT"</span><span class="p">,</span> <span class="s2">"APPROX_COUNT_DISTINCT"</span><span class="p">]</span> </span></pre></div> @@ -35159,9 +35287,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Array"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Array-3820"><a href="#Array-3820"><span class="linenos">3820</span></a><span class="k">class</span> <span class="nc">Array</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Array-3821"><a href="#Array-3821"><span class="linenos">3821</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="Array-3822"><a href="#Array-3822"><span class="linenos">3822</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Array-3825"><a href="#Array-3825"><span class="linenos">3825</span></a><span class="k">class</span> <span class="nc">Array</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Array-3826"><a href="#Array-3826"><span class="linenos">3826</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="Array-3827"><a href="#Array-3827"><span class="linenos">3827</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span></pre></div> @@ -35247,8 +35375,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#ToChar"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ToChar-3826"><a href="#ToChar-3826"><span class="linenos">3826</span></a><span class="k">class</span> <span class="nc">ToChar</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="ToChar-3827"><a href="#ToChar-3827"><span class="linenos">3827</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ToChar-3831"><a href="#ToChar-3831"><span class="linenos">3831</span></a><span class="k">class</span> <span class="nc">ToChar</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="ToChar-3832"><a href="#ToChar-3832"><span class="linenos">3832</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -35334,8 +35462,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#GenerateSeries"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="GenerateSeries-3830"><a href="#GenerateSeries-3830"><span class="linenos">3830</span></a><span class="k">class</span> <span class="nc">GenerateSeries</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="GenerateSeries-3831"><a href="#GenerateSeries-3831"><span class="linenos">3831</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"start"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"end"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"step"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="GenerateSeries-3835"><a href="#GenerateSeries-3835"><span class="linenos">3835</span></a><span class="k">class</span> <span class="nc">GenerateSeries</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="GenerateSeries-3836"><a href="#GenerateSeries-3836"><span class="linenos">3836</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"start"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"end"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"step"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -35421,8 +35549,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#ArrayAgg"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayAgg-3834"><a href="#ArrayAgg-3834"><span class="linenos">3834</span></a><span class="k">class</span> <span class="nc">ArrayAgg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="ArrayAgg-3835"><a href="#ArrayAgg-3835"><span class="linenos">3835</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayAgg-3839"><a href="#ArrayAgg-3839"><span class="linenos">3839</span></a><span class="k">class</span> <span class="nc">ArrayAgg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="ArrayAgg-3840"><a href="#ArrayAgg-3840"><span class="linenos">3840</span></a> <span class="k">pass</span> </span></pre></div> @@ -35508,8 +35636,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#ArrayAll"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayAll-3838"><a href="#ArrayAll-3838"><span class="linenos">3838</span></a><span class="k">class</span> <span class="nc">ArrayAll</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="ArrayAll-3839"><a href="#ArrayAll-3839"><span class="linenos">3839</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayAll-3843"><a href="#ArrayAll-3843"><span class="linenos">3843</span></a><span class="k">class</span> <span class="nc">ArrayAll</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="ArrayAll-3844"><a href="#ArrayAll-3844"><span class="linenos">3844</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -35595,8 +35723,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#ArrayAny"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayAny-3842"><a href="#ArrayAny-3842"><span class="linenos">3842</span></a><span class="k">class</span> <span class="nc">ArrayAny</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="ArrayAny-3843"><a href="#ArrayAny-3843"><span class="linenos">3843</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayAny-3847"><a href="#ArrayAny-3847"><span class="linenos">3847</span></a><span class="k">class</span> <span class="nc">ArrayAny</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="ArrayAny-3848"><a href="#ArrayAny-3848"><span class="linenos">3848</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -35682,9 +35810,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#ArrayConcat"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayConcat-3846"><a href="#ArrayConcat-3846"><span class="linenos">3846</span></a><span class="k">class</span> <span class="nc">ArrayConcat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="ArrayConcat-3847"><a href="#ArrayConcat-3847"><span class="linenos">3847</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="ArrayConcat-3848"><a href="#ArrayConcat-3848"><span class="linenos">3848</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayConcat-3851"><a href="#ArrayConcat-3851"><span class="linenos">3851</span></a><span class="k">class</span> <span class="nc">ArrayConcat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="ArrayConcat-3852"><a href="#ArrayConcat-3852"><span class="linenos">3852</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="ArrayConcat-3853"><a href="#ArrayConcat-3853"><span class="linenos">3853</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span></pre></div> @@ -35770,8 +35898,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#ArrayContains"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayContains-3851"><a href="#ArrayContains-3851"><span class="linenos">3851</span></a><span class="k">class</span> <span class="nc">ArrayContains</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Func</span><span class="p">):</span> -</span><span id="ArrayContains-3852"><a href="#ArrayContains-3852"><span class="linenos">3852</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayContains-3856"><a href="#ArrayContains-3856"><span class="linenos">3856</span></a><span class="k">class</span> <span class="nc">ArrayContains</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Func</span><span class="p">):</span> +</span><span id="ArrayContains-3857"><a href="#ArrayContains-3857"><span class="linenos">3857</span></a> <span class="k">pass</span> </span></pre></div> @@ -35857,8 +35985,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#ArrayContained"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayContained-3855"><a href="#ArrayContained-3855"><span class="linenos">3855</span></a><span class="k">class</span> <span class="nc">ArrayContained</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="ArrayContained-3856"><a href="#ArrayContained-3856"><span class="linenos">3856</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayContained-3860"><a href="#ArrayContained-3860"><span class="linenos">3860</span></a><span class="k">class</span> <span class="nc">ArrayContained</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="ArrayContained-3861"><a href="#ArrayContained-3861"><span class="linenos">3861</span></a> <span class="k">pass</span> </span></pre></div> @@ -35937,9 +36065,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#ArrayFilter"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayFilter-3859"><a href="#ArrayFilter-3859"><span class="linenos">3859</span></a><span class="k">class</span> <span class="nc">ArrayFilter</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="ArrayFilter-3860"><a href="#ArrayFilter-3860"><span class="linenos">3860</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="ArrayFilter-3861"><a href="#ArrayFilter-3861"><span class="linenos">3861</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"FILTER"</span><span class="p">,</span> <span class="s2">"ARRAY_FILTER"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayFilter-3864"><a href="#ArrayFilter-3864"><span class="linenos">3864</span></a><span class="k">class</span> <span class="nc">ArrayFilter</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="ArrayFilter-3865"><a href="#ArrayFilter-3865"><span class="linenos">3865</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="ArrayFilter-3866"><a href="#ArrayFilter-3866"><span class="linenos">3866</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"FILTER"</span><span class="p">,</span> <span class="s2">"ARRAY_FILTER"</span><span class="p">]</span> </span></pre></div> @@ -36025,8 +36153,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#ArrayJoin"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayJoin-3864"><a href="#ArrayJoin-3864"><span class="linenos">3864</span></a><span class="k">class</span> <span class="nc">ArrayJoin</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="ArrayJoin-3865"><a href="#ArrayJoin-3865"><span class="linenos">3865</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"null"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayJoin-3869"><a href="#ArrayJoin-3869"><span class="linenos">3869</span></a><span class="k">class</span> <span class="nc">ArrayJoin</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="ArrayJoin-3870"><a href="#ArrayJoin-3870"><span class="linenos">3870</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"null"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -36112,8 +36240,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#ArraySize"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ArraySize-3868"><a href="#ArraySize-3868"><span class="linenos">3868</span></a><span class="k">class</span> <span class="nc">ArraySize</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="ArraySize-3869"><a href="#ArraySize-3869"><span class="linenos">3869</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ArraySize-3873"><a href="#ArraySize-3873"><span class="linenos">3873</span></a><span class="k">class</span> <span class="nc">ArraySize</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="ArraySize-3874"><a href="#ArraySize-3874"><span class="linenos">3874</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -36199,8 +36327,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#ArraySort"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ArraySort-3872"><a href="#ArraySort-3872"><span class="linenos">3872</span></a><span class="k">class</span> <span class="nc">ArraySort</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="ArraySort-3873"><a href="#ArraySort-3873"><span class="linenos">3873</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ArraySort-3877"><a href="#ArraySort-3877"><span class="linenos">3877</span></a><span class="k">class</span> <span class="nc">ArraySort</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="ArraySort-3878"><a href="#ArraySort-3878"><span class="linenos">3878</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -36286,8 +36414,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#ArraySum"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ArraySum-3876"><a href="#ArraySum-3876"><span class="linenos">3876</span></a><span class="k">class</span> <span class="nc">ArraySum</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="ArraySum-3877"><a href="#ArraySum-3877"><span class="linenos">3877</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ArraySum-3881"><a href="#ArraySum-3881"><span class="linenos">3881</span></a><span class="k">class</span> <span class="nc">ArraySum</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="ArraySum-3882"><a href="#ArraySum-3882"><span class="linenos">3882</span></a> <span class="k">pass</span> </span></pre></div> @@ -36373,8 +36501,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#ArrayUnionAgg"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayUnionAgg-3880"><a href="#ArrayUnionAgg-3880"><span class="linenos">3880</span></a><span class="k">class</span> <span class="nc">ArrayUnionAgg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="ArrayUnionAgg-3881"><a href="#ArrayUnionAgg-3881"><span class="linenos">3881</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ArrayUnionAgg-3885"><a href="#ArrayUnionAgg-3885"><span class="linenos">3885</span></a><span class="k">class</span> <span class="nc">ArrayUnionAgg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="ArrayUnionAgg-3886"><a href="#ArrayUnionAgg-3886"><span class="linenos">3886</span></a> <span class="k">pass</span> </span></pre></div> @@ -36460,8 +36588,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Avg"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Avg-3884"><a href="#Avg-3884"><span class="linenos">3884</span></a><span class="k">class</span> <span class="nc">Avg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="Avg-3885"><a href="#Avg-3885"><span class="linenos">3885</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Avg-3889"><a href="#Avg-3889"><span class="linenos">3889</span></a><span class="k">class</span> <span class="nc">Avg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="Avg-3890"><a href="#Avg-3890"><span class="linenos">3890</span></a> <span class="k">pass</span> </span></pre></div> @@ -36547,8 +36675,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#AnyValue"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="AnyValue-3888"><a href="#AnyValue-3888"><span class="linenos">3888</span></a><span class="k">class</span> <span class="nc">AnyValue</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="AnyValue-3889"><a href="#AnyValue-3889"><span class="linenos">3889</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="AnyValue-3893"><a href="#AnyValue-3893"><span class="linenos">3893</span></a><span class="k">class</span> <span class="nc">AnyValue</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="AnyValue-3894"><a href="#AnyValue-3894"><span class="linenos">3894</span></a> <span class="k">pass</span> </span></pre></div> @@ -36634,24 +36762,24 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Case"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Case-3892"><a href="#Case-3892"><span class="linenos">3892</span></a><span class="k">class</span> <span class="nc">Case</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Case-3893"><a href="#Case-3893"><span class="linenos">3893</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"ifs"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="Case-3894"><a href="#Case-3894"><span class="linenos">3894</span></a> -</span><span id="Case-3895"><a href="#Case-3895"><span class="linenos">3895</span></a> <span class="k">def</span> <span class="nf">when</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">condition</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">then</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Case</span><span class="p">:</span> -</span><span id="Case-3896"><a href="#Case-3896"><span class="linenos">3896</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="Case-3897"><a href="#Case-3897"><span class="linenos">3897</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="Case-3898"><a href="#Case-3898"><span class="linenos">3898</span></a> <span class="s2">"ifs"</span><span class="p">,</span> -</span><span id="Case-3899"><a href="#Case-3899"><span class="linenos">3899</span></a> <span class="n">If</span><span class="p">(</span> -</span><span id="Case-3900"><a href="#Case-3900"><span class="linenos">3900</span></a> <span class="n">this</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">condition</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> -</span><span id="Case-3901"><a href="#Case-3901"><span class="linenos">3901</span></a> <span class="n">true</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">then</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> -</span><span id="Case-3902"><a href="#Case-3902"><span class="linenos">3902</span></a> <span class="p">),</span> -</span><span id="Case-3903"><a href="#Case-3903"><span class="linenos">3903</span></a> <span class="p">)</span> -</span><span id="Case-3904"><a href="#Case-3904"><span class="linenos">3904</span></a> <span class="k">return</span> <span class="n">instance</span> -</span><span id="Case-3905"><a href="#Case-3905"><span class="linenos">3905</span></a> -</span><span id="Case-3906"><a href="#Case-3906"><span class="linenos">3906</span></a> <span class="k">def</span> <span class="nf">else_</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">condition</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Case</span><span class="p">:</span> -</span><span id="Case-3907"><a href="#Case-3907"><span class="linenos">3907</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="Case-3908"><a href="#Case-3908"><span class="linenos">3908</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"default"</span><span class="p">,</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">condition</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Case-3897"><a href="#Case-3897"><span class="linenos">3897</span></a><span class="k">class</span> <span class="nc">Case</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Case-3898"><a href="#Case-3898"><span class="linenos">3898</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"ifs"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="Case-3899"><a href="#Case-3899"><span class="linenos">3899</span></a> +</span><span id="Case-3900"><a href="#Case-3900"><span class="linenos">3900</span></a> <span class="k">def</span> <span class="nf">when</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">condition</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">then</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Case</span><span class="p">:</span> +</span><span id="Case-3901"><a href="#Case-3901"><span class="linenos">3901</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="Case-3902"><a href="#Case-3902"><span class="linenos">3902</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="Case-3903"><a href="#Case-3903"><span class="linenos">3903</span></a> <span class="s2">"ifs"</span><span class="p">,</span> +</span><span id="Case-3904"><a href="#Case-3904"><span class="linenos">3904</span></a> <span class="n">If</span><span class="p">(</span> +</span><span id="Case-3905"><a href="#Case-3905"><span class="linenos">3905</span></a> <span class="n">this</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">condition</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> +</span><span id="Case-3906"><a href="#Case-3906"><span class="linenos">3906</span></a> <span class="n">true</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">then</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> +</span><span id="Case-3907"><a href="#Case-3907"><span class="linenos">3907</span></a> <span class="p">),</span> +</span><span id="Case-3908"><a href="#Case-3908"><span class="linenos">3908</span></a> <span class="p">)</span> </span><span id="Case-3909"><a href="#Case-3909"><span class="linenos">3909</span></a> <span class="k">return</span> <span class="n">instance</span> +</span><span id="Case-3910"><a href="#Case-3910"><span class="linenos">3910</span></a> +</span><span id="Case-3911"><a href="#Case-3911"><span class="linenos">3911</span></a> <span class="k">def</span> <span class="nf">else_</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">condition</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Case</span><span class="p">:</span> +</span><span id="Case-3912"><a href="#Case-3912"><span class="linenos">3912</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="Case-3913"><a href="#Case-3913"><span class="linenos">3913</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"default"</span><span class="p">,</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">condition</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">))</span> +</span><span id="Case-3914"><a href="#Case-3914"><span class="linenos">3914</span></a> <span class="k">return</span> <span class="n">instance</span> </span></pre></div> @@ -36668,16 +36796,16 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Case.when"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Case.when-3895"><a href="#Case.when-3895"><span class="linenos">3895</span></a> <span class="k">def</span> <span class="nf">when</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">condition</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">then</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Case</span><span class="p">:</span> -</span><span id="Case.when-3896"><a href="#Case.when-3896"><span class="linenos">3896</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="Case.when-3897"><a href="#Case.when-3897"><span class="linenos">3897</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="Case.when-3898"><a href="#Case.when-3898"><span class="linenos">3898</span></a> <span class="s2">"ifs"</span><span class="p">,</span> -</span><span id="Case.when-3899"><a href="#Case.when-3899"><span class="linenos">3899</span></a> <span class="n">If</span><span class="p">(</span> -</span><span id="Case.when-3900"><a href="#Case.when-3900"><span class="linenos">3900</span></a> <span class="n">this</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">condition</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> -</span><span id="Case.when-3901"><a href="#Case.when-3901"><span class="linenos">3901</span></a> <span class="n">true</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">then</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> -</span><span id="Case.when-3902"><a href="#Case.when-3902"><span class="linenos">3902</span></a> <span class="p">),</span> -</span><span id="Case.when-3903"><a href="#Case.when-3903"><span class="linenos">3903</span></a> <span class="p">)</span> -</span><span id="Case.when-3904"><a href="#Case.when-3904"><span class="linenos">3904</span></a> <span class="k">return</span> <span class="n">instance</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Case.when-3900"><a href="#Case.when-3900"><span class="linenos">3900</span></a> <span class="k">def</span> <span class="nf">when</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">condition</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">then</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Case</span><span class="p">:</span> +</span><span id="Case.when-3901"><a href="#Case.when-3901"><span class="linenos">3901</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="Case.when-3902"><a href="#Case.when-3902"><span class="linenos">3902</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="Case.when-3903"><a href="#Case.when-3903"><span class="linenos">3903</span></a> <span class="s2">"ifs"</span><span class="p">,</span> +</span><span id="Case.when-3904"><a href="#Case.when-3904"><span class="linenos">3904</span></a> <span class="n">If</span><span class="p">(</span> +</span><span id="Case.when-3905"><a href="#Case.when-3905"><span class="linenos">3905</span></a> <span class="n">this</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">condition</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> +</span><span id="Case.when-3906"><a href="#Case.when-3906"><span class="linenos">3906</span></a> <span class="n">true</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">then</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> +</span><span id="Case.when-3907"><a href="#Case.when-3907"><span class="linenos">3907</span></a> <span class="p">),</span> +</span><span id="Case.when-3908"><a href="#Case.when-3908"><span class="linenos">3908</span></a> <span class="p">)</span> +</span><span id="Case.when-3909"><a href="#Case.when-3909"><span class="linenos">3909</span></a> <span class="k">return</span> <span class="n">instance</span> </span></pre></div> @@ -36695,10 +36823,10 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Case.else_"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Case.else_-3906"><a href="#Case.else_-3906"><span class="linenos">3906</span></a> <span class="k">def</span> <span class="nf">else_</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">condition</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Case</span><span class="p">:</span> -</span><span id="Case.else_-3907"><a href="#Case.else_-3907"><span class="linenos">3907</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="Case.else_-3908"><a href="#Case.else_-3908"><span class="linenos">3908</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"default"</span><span class="p">,</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">condition</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">))</span> -</span><span id="Case.else_-3909"><a href="#Case.else_-3909"><span class="linenos">3909</span></a> <span class="k">return</span> <span class="n">instance</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Case.else_-3911"><a href="#Case.else_-3911"><span class="linenos">3911</span></a> <span class="k">def</span> <span class="nf">else_</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">condition</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Case</span><span class="p">:</span> +</span><span id="Case.else_-3912"><a href="#Case.else_-3912"><span class="linenos">3912</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="Case.else_-3913"><a href="#Case.else_-3913"><span class="linenos">3913</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"default"</span><span class="p">,</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">condition</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">))</span> +</span><span id="Case.else_-3914"><a href="#Case.else_-3914"><span class="linenos">3914</span></a> <span class="k">return</span> <span class="n">instance</span> </span></pre></div> @@ -36785,23 +36913,23 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Cast"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Cast-3912"><a href="#Cast-3912"><span class="linenos">3912</span></a><span class="k">class</span> <span class="nc">Cast</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Cast-3913"><a href="#Cast-3913"><span class="linenos">3913</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"to"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="Cast-3914"><a href="#Cast-3914"><span class="linenos">3914</span></a> -</span><span id="Cast-3915"><a href="#Cast-3915"><span class="linenos">3915</span></a> <span class="nd">@property</span> -</span><span id="Cast-3916"><a href="#Cast-3916"><span class="linenos">3916</span></a> <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Cast-3917"><a href="#Cast-3917"><span class="linenos">3917</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> -</span><span id="Cast-3918"><a href="#Cast-3918"><span class="linenos">3918</span></a> -</span><span id="Cast-3919"><a href="#Cast-3919"><span class="linenos">3919</span></a> <span class="nd">@property</span> -</span><span id="Cast-3920"><a href="#Cast-3920"><span class="linenos">3920</span></a> <span class="k">def</span> <span class="nf">to</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataType</span><span class="p">:</span> -</span><span id="Cast-3921"><a href="#Cast-3921"><span class="linenos">3921</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"to"</span><span class="p">]</span> -</span><span id="Cast-3922"><a href="#Cast-3922"><span class="linenos">3922</span></a> -</span><span id="Cast-3923"><a href="#Cast-3923"><span class="linenos">3923</span></a> <span class="nd">@property</span> -</span><span id="Cast-3924"><a href="#Cast-3924"><span class="linenos">3924</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Cast-3925"><a href="#Cast-3925"><span class="linenos">3925</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> -</span><span id="Cast-3926"><a href="#Cast-3926"><span class="linenos">3926</span></a> -</span><span id="Cast-3927"><a href="#Cast-3927"><span class="linenos">3927</span></a> <span class="k">def</span> <span class="nf">is_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">dtypes</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="Cast-3928"><a href="#Cast-3928"><span class="linenos">3928</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="o">*</span><span class="n">dtypes</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Cast-3917"><a href="#Cast-3917"><span class="linenos">3917</span></a><span class="k">class</span> <span class="nc">Cast</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Cast-3918"><a href="#Cast-3918"><span class="linenos">3918</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"to"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="Cast-3919"><a href="#Cast-3919"><span class="linenos">3919</span></a> +</span><span id="Cast-3920"><a href="#Cast-3920"><span class="linenos">3920</span></a> <span class="nd">@property</span> +</span><span id="Cast-3921"><a href="#Cast-3921"><span class="linenos">3921</span></a> <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Cast-3922"><a href="#Cast-3922"><span class="linenos">3922</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> +</span><span id="Cast-3923"><a href="#Cast-3923"><span class="linenos">3923</span></a> +</span><span id="Cast-3924"><a href="#Cast-3924"><span class="linenos">3924</span></a> <span class="nd">@property</span> +</span><span id="Cast-3925"><a href="#Cast-3925"><span class="linenos">3925</span></a> <span class="k">def</span> <span class="nf">to</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">DataType</span><span class="p">:</span> +</span><span id="Cast-3926"><a href="#Cast-3926"><span class="linenos">3926</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"to"</span><span class="p">]</span> +</span><span id="Cast-3927"><a href="#Cast-3927"><span class="linenos">3927</span></a> +</span><span id="Cast-3928"><a href="#Cast-3928"><span class="linenos">3928</span></a> <span class="nd">@property</span> +</span><span id="Cast-3929"><a href="#Cast-3929"><span class="linenos">3929</span></a> <span class="k">def</span> <span class="nf">output_name</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Cast-3930"><a href="#Cast-3930"><span class="linenos">3930</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> +</span><span id="Cast-3931"><a href="#Cast-3931"><span class="linenos">3931</span></a> +</span><span id="Cast-3932"><a href="#Cast-3932"><span class="linenos">3932</span></a> <span class="k">def</span> <span class="nf">is_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">dtypes</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Cast-3933"><a href="#Cast-3933"><span class="linenos">3933</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="o">*</span><span class="n">dtypes</span><span class="p">)</span> </span></pre></div> @@ -36848,8 +36976,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Cast.is_type"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Cast.is_type-3927"><a href="#Cast.is_type-3927"><span class="linenos">3927</span></a> <span class="k">def</span> <span class="nf">is_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">dtypes</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="Cast.is_type-3928"><a href="#Cast.is_type-3928"><span class="linenos">3928</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="o">*</span><span class="n">dtypes</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Cast.is_type-3932"><a href="#Cast.is_type-3932"><span class="linenos">3932</span></a> <span class="k">def</span> <span class="nf">is_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">dtypes</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Cast.is_type-3933"><a href="#Cast.is_type-3933"><span class="linenos">3933</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">to</span><span class="o">.</span><span class="n">is_type</span><span class="p">(</span><span class="o">*</span><span class="n">dtypes</span><span class="p">)</span> </span></pre></div> @@ -36935,8 +37063,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#CastToStrType"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="CastToStrType-3931"><a href="#CastToStrType-3931"><span class="linenos">3931</span></a><span class="k">class</span> <span class="nc">CastToStrType</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="CastToStrType-3932"><a href="#CastToStrType-3932"><span class="linenos">3932</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="CastToStrType-3936"><a href="#CastToStrType-3936"><span class="linenos">3936</span></a><span class="k">class</span> <span class="nc">CastToStrType</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="CastToStrType-3937"><a href="#CastToStrType-3937"><span class="linenos">3937</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -37022,8 +37150,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Collate"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Collate-3935"><a href="#Collate-3935"><span class="linenos">3935</span></a><span class="k">class</span> <span class="nc">Collate</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="Collate-3936"><a href="#Collate-3936"><span class="linenos">3936</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Collate-3940"><a href="#Collate-3940"><span class="linenos">3940</span></a><span class="k">class</span> <span class="nc">Collate</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="Collate-3941"><a href="#Collate-3941"><span class="linenos">3941</span></a> <span class="k">pass</span> </span></pre></div> @@ -37102,8 +37230,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#TryCast"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TryCast-3939"><a href="#TryCast-3939"><span class="linenos">3939</span></a><span class="k">class</span> <span class="nc">TryCast</span><span class="p">(</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="TryCast-3940"><a href="#TryCast-3940"><span class="linenos">3940</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TryCast-3944"><a href="#TryCast-3944"><span class="linenos">3944</span></a><span class="k">class</span> <span class="nc">TryCast</span><span class="p">(</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="TryCast-3945"><a href="#TryCast-3945"><span class="linenos">3945</span></a> <span class="k">pass</span> </span></pre></div> @@ -37193,9 +37321,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Ceil"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Ceil-3943"><a href="#Ceil-3943"><span class="linenos">3943</span></a><span class="k">class</span> <span class="nc">Ceil</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Ceil-3944"><a href="#Ceil-3944"><span class="linenos">3944</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"decimals"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="Ceil-3945"><a href="#Ceil-3945"><span class="linenos">3945</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"CEIL"</span><span class="p">,</span> <span class="s2">"CEILING"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Ceil-3948"><a href="#Ceil-3948"><span class="linenos">3948</span></a><span class="k">class</span> <span class="nc">Ceil</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Ceil-3949"><a href="#Ceil-3949"><span class="linenos">3949</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"decimals"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="Ceil-3950"><a href="#Ceil-3950"><span class="linenos">3950</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"CEIL"</span><span class="p">,</span> <span class="s2">"CEILING"</span><span class="p">]</span> </span></pre></div> @@ -37281,10 +37409,10 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Coalesce"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Coalesce-3948"><a href="#Coalesce-3948"><span class="linenos">3948</span></a><span class="k">class</span> <span class="nc">Coalesce</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Coalesce-3949"><a href="#Coalesce-3949"><span class="linenos">3949</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="Coalesce-3950"><a href="#Coalesce-3950"><span class="linenos">3950</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Coalesce-3951"><a href="#Coalesce-3951"><span class="linenos">3951</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"COALESCE"</span><span class="p">,</span> <span class="s2">"IFNULL"</span><span class="p">,</span> <span class="s2">"NVL"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Coalesce-3953"><a href="#Coalesce-3953"><span class="linenos">3953</span></a><span class="k">class</span> <span class="nc">Coalesce</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Coalesce-3954"><a href="#Coalesce-3954"><span class="linenos">3954</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="Coalesce-3955"><a href="#Coalesce-3955"><span class="linenos">3955</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Coalesce-3956"><a href="#Coalesce-3956"><span class="linenos">3956</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"COALESCE"</span><span class="p">,</span> <span class="s2">"IFNULL"</span><span class="p">,</span> <span class="s2">"NVL"</span><span class="p">]</span> </span></pre></div> @@ -37370,9 +37498,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Concat"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Concat-3954"><a href="#Concat-3954"><span class="linenos">3954</span></a><span class="k">class</span> <span class="nc">Concat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Concat-3955"><a href="#Concat-3955"><span class="linenos">3955</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="Concat-3956"><a href="#Concat-3956"><span class="linenos">3956</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Concat-3959"><a href="#Concat-3959"><span class="linenos">3959</span></a><span class="k">class</span> <span class="nc">Concat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Concat-3960"><a href="#Concat-3960"><span class="linenos">3960</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="Concat-3961"><a href="#Concat-3961"><span class="linenos">3961</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span></pre></div> @@ -37458,8 +37586,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#SafeConcat"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SafeConcat-3959"><a href="#SafeConcat-3959"><span class="linenos">3959</span></a><span class="k">class</span> <span class="nc">SafeConcat</span><span class="p">(</span><span class="n">Concat</span><span class="p">):</span> -</span><span id="SafeConcat-3960"><a href="#SafeConcat-3960"><span class="linenos">3960</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SafeConcat-3964"><a href="#SafeConcat-3964"><span class="linenos">3964</span></a><span class="k">class</span> <span class="nc">SafeConcat</span><span class="p">(</span><span class="n">Concat</span><span class="p">):</span> +</span><span id="SafeConcat-3965"><a href="#SafeConcat-3965"><span class="linenos">3965</span></a> <span class="k">pass</span> </span></pre></div> @@ -37545,8 +37673,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#ConcatWs"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ConcatWs-3963"><a href="#ConcatWs-3963"><span class="linenos">3963</span></a><span class="k">class</span> <span class="nc">ConcatWs</span><span class="p">(</span><span class="n">Concat</span><span class="p">):</span> -</span><span id="ConcatWs-3964"><a href="#ConcatWs-3964"><span class="linenos">3964</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"CONCAT_WS"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ConcatWs-3968"><a href="#ConcatWs-3968"><span class="linenos">3968</span></a><span class="k">class</span> <span class="nc">ConcatWs</span><span class="p">(</span><span class="n">Concat</span><span class="p">):</span> +</span><span id="ConcatWs-3969"><a href="#ConcatWs-3969"><span class="linenos">3969</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"CONCAT_WS"</span><span class="p">]</span> </span></pre></div> @@ -37632,9 +37760,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Count"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Count-3967"><a href="#Count-3967"><span class="linenos">3967</span></a><span class="k">class</span> <span class="nc">Count</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="Count-3968"><a href="#Count-3968"><span class="linenos">3968</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="Count-3969"><a href="#Count-3969"><span class="linenos">3969</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Count-3972"><a href="#Count-3972"><span class="linenos">3972</span></a><span class="k">class</span> <span class="nc">Count</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="Count-3973"><a href="#Count-3973"><span class="linenos">3973</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="Count-3974"><a href="#Count-3974"><span class="linenos">3974</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span></pre></div> @@ -37720,8 +37848,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#CountIf"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="CountIf-3972"><a href="#CountIf-3972"><span class="linenos">3972</span></a><span class="k">class</span> <span class="nc">CountIf</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="CountIf-3973"><a href="#CountIf-3973"><span class="linenos">3973</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="CountIf-3977"><a href="#CountIf-3977"><span class="linenos">3977</span></a><span class="k">class</span> <span class="nc">CountIf</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="CountIf-3978"><a href="#CountIf-3978"><span class="linenos">3978</span></a> <span class="k">pass</span> </span></pre></div> @@ -37807,8 +37935,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#CurrentDate"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="CurrentDate-3976"><a href="#CurrentDate-3976"><span class="linenos">3976</span></a><span class="k">class</span> <span class="nc">CurrentDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="CurrentDate-3977"><a href="#CurrentDate-3977"><span class="linenos">3977</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="CurrentDate-3981"><a href="#CurrentDate-3981"><span class="linenos">3981</span></a><span class="k">class</span> <span class="nc">CurrentDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="CurrentDate-3982"><a href="#CurrentDate-3982"><span class="linenos">3982</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -37894,8 +38022,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#CurrentDatetime"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="CurrentDatetime-3980"><a href="#CurrentDatetime-3980"><span class="linenos">3980</span></a><span class="k">class</span> <span class="nc">CurrentDatetime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="CurrentDatetime-3981"><a href="#CurrentDatetime-3981"><span class="linenos">3981</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="CurrentDatetime-3985"><a href="#CurrentDatetime-3985"><span class="linenos">3985</span></a><span class="k">class</span> <span class="nc">CurrentDatetime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="CurrentDatetime-3986"><a href="#CurrentDatetime-3986"><span class="linenos">3986</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -37981,8 +38109,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#CurrentTime"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="CurrentTime-3984"><a href="#CurrentTime-3984"><span class="linenos">3984</span></a><span class="k">class</span> <span class="nc">CurrentTime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="CurrentTime-3985"><a href="#CurrentTime-3985"><span class="linenos">3985</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="CurrentTime-3989"><a href="#CurrentTime-3989"><span class="linenos">3989</span></a><span class="k">class</span> <span class="nc">CurrentTime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="CurrentTime-3990"><a href="#CurrentTime-3990"><span class="linenos">3990</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -38068,8 +38196,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#CurrentTimestamp"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="CurrentTimestamp-3988"><a href="#CurrentTimestamp-3988"><span class="linenos">3988</span></a><span class="k">class</span> <span class="nc">CurrentTimestamp</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="CurrentTimestamp-3989"><a href="#CurrentTimestamp-3989"><span class="linenos">3989</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="CurrentTimestamp-3993"><a href="#CurrentTimestamp-3993"><span class="linenos">3993</span></a><span class="k">class</span> <span class="nc">CurrentTimestamp</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="CurrentTimestamp-3994"><a href="#CurrentTimestamp-3994"><span class="linenos">3994</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -38155,8 +38283,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#CurrentUser"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="CurrentUser-3992"><a href="#CurrentUser-3992"><span class="linenos">3992</span></a><span class="k">class</span> <span class="nc">CurrentUser</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="CurrentUser-3993"><a href="#CurrentUser-3993"><span class="linenos">3993</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="CurrentUser-3997"><a href="#CurrentUser-3997"><span class="linenos">3997</span></a><span class="k">class</span> <span class="nc">CurrentUser</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="CurrentUser-3998"><a href="#CurrentUser-3998"><span class="linenos">3998</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -38242,8 +38370,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#DateAdd"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DateAdd-3996"><a href="#DateAdd-3996"><span class="linenos">3996</span></a><span class="k">class</span> <span class="nc">DateAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="DateAdd-3997"><a href="#DateAdd-3997"><span class="linenos">3997</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DateAdd-4001"><a href="#DateAdd-4001"><span class="linenos">4001</span></a><span class="k">class</span> <span class="nc">DateAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="DateAdd-4002"><a href="#DateAdd-4002"><span class="linenos">4002</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -38332,8 +38460,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#DateSub"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DateSub-4000"><a href="#DateSub-4000"><span class="linenos">4000</span></a><span class="k">class</span> <span class="nc">DateSub</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="DateSub-4001"><a href="#DateSub-4001"><span class="linenos">4001</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DateSub-4005"><a href="#DateSub-4005"><span class="linenos">4005</span></a><span class="k">class</span> <span class="nc">DateSub</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="DateSub-4006"><a href="#DateSub-4006"><span class="linenos">4006</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -38422,9 +38550,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#DateDiff"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DateDiff-4004"><a href="#DateDiff-4004"><span class="linenos">4004</span></a><span class="k">class</span> <span class="nc">DateDiff</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="DateDiff-4005"><a href="#DateDiff-4005"><span class="linenos">4005</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DATEDIFF"</span><span class="p">,</span> <span class="s2">"DATE_DIFF"</span><span class="p">]</span> -</span><span id="DateDiff-4006"><a href="#DateDiff-4006"><span class="linenos">4006</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DateDiff-4009"><a href="#DateDiff-4009"><span class="linenos">4009</span></a><span class="k">class</span> <span class="nc">DateDiff</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="DateDiff-4010"><a href="#DateDiff-4010"><span class="linenos">4010</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DATEDIFF"</span><span class="p">,</span> <span class="s2">"DATE_DIFF"</span><span class="p">]</span> +</span><span id="DateDiff-4011"><a href="#DateDiff-4011"><span class="linenos">4011</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -38513,8 +38641,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#DateTrunc"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DateTrunc-4009"><a href="#DateTrunc-4009"><span class="linenos">4009</span></a><span class="k">class</span> <span class="nc">DateTrunc</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="DateTrunc-4010"><a href="#DateTrunc-4010"><span class="linenos">4010</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"unit"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DateTrunc-4014"><a href="#DateTrunc-4014"><span class="linenos">4014</span></a><span class="k">class</span> <span class="nc">DateTrunc</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="DateTrunc-4015"><a href="#DateTrunc-4015"><span class="linenos">4015</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"unit"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -38600,8 +38728,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#DatetimeAdd"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DatetimeAdd-4013"><a href="#DatetimeAdd-4013"><span class="linenos">4013</span></a><span class="k">class</span> <span class="nc">DatetimeAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="DatetimeAdd-4014"><a href="#DatetimeAdd-4014"><span class="linenos">4014</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DatetimeAdd-4018"><a href="#DatetimeAdd-4018"><span class="linenos">4018</span></a><span class="k">class</span> <span class="nc">DatetimeAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="DatetimeAdd-4019"><a href="#DatetimeAdd-4019"><span class="linenos">4019</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -38690,8 +38818,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#DatetimeSub"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DatetimeSub-4017"><a href="#DatetimeSub-4017"><span class="linenos">4017</span></a><span class="k">class</span> <span class="nc">DatetimeSub</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="DatetimeSub-4018"><a href="#DatetimeSub-4018"><span class="linenos">4018</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DatetimeSub-4022"><a href="#DatetimeSub-4022"><span class="linenos">4022</span></a><span class="k">class</span> <span class="nc">DatetimeSub</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="DatetimeSub-4023"><a href="#DatetimeSub-4023"><span class="linenos">4023</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -38780,8 +38908,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#DatetimeDiff"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DatetimeDiff-4021"><a href="#DatetimeDiff-4021"><span class="linenos">4021</span></a><span class="k">class</span> <span class="nc">DatetimeDiff</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="DatetimeDiff-4022"><a href="#DatetimeDiff-4022"><span class="linenos">4022</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DatetimeDiff-4026"><a href="#DatetimeDiff-4026"><span class="linenos">4026</span></a><span class="k">class</span> <span class="nc">DatetimeDiff</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="DatetimeDiff-4027"><a href="#DatetimeDiff-4027"><span class="linenos">4027</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -38870,8 +38998,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#DatetimeTrunc"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DatetimeTrunc-4025"><a href="#DatetimeTrunc-4025"><span class="linenos">4025</span></a><span class="k">class</span> <span class="nc">DatetimeTrunc</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="DatetimeTrunc-4026"><a href="#DatetimeTrunc-4026"><span class="linenos">4026</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DatetimeTrunc-4030"><a href="#DatetimeTrunc-4030"><span class="linenos">4030</span></a><span class="k">class</span> <span class="nc">DatetimeTrunc</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="DatetimeTrunc-4031"><a href="#DatetimeTrunc-4031"><span class="linenos">4031</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -38960,8 +39088,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#DayOfWeek"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DayOfWeek-4029"><a href="#DayOfWeek-4029"><span class="linenos">4029</span></a><span class="k">class</span> <span class="nc">DayOfWeek</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="DayOfWeek-4030"><a href="#DayOfWeek-4030"><span class="linenos">4030</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DAY_OF_WEEK"</span><span class="p">,</span> <span class="s2">"DAYOFWEEK"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DayOfWeek-4034"><a href="#DayOfWeek-4034"><span class="linenos">4034</span></a><span class="k">class</span> <span class="nc">DayOfWeek</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="DayOfWeek-4035"><a href="#DayOfWeek-4035"><span class="linenos">4035</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DAY_OF_WEEK"</span><span class="p">,</span> <span class="s2">"DAYOFWEEK"</span><span class="p">]</span> </span></pre></div> @@ -39047,8 +39175,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#DayOfMonth"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DayOfMonth-4033"><a href="#DayOfMonth-4033"><span class="linenos">4033</span></a><span class="k">class</span> <span class="nc">DayOfMonth</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="DayOfMonth-4034"><a href="#DayOfMonth-4034"><span class="linenos">4034</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DAY_OF_MONTH"</span><span class="p">,</span> <span class="s2">"DAYOFMONTH"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DayOfMonth-4038"><a href="#DayOfMonth-4038"><span class="linenos">4038</span></a><span class="k">class</span> <span class="nc">DayOfMonth</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="DayOfMonth-4039"><a href="#DayOfMonth-4039"><span class="linenos">4039</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DAY_OF_MONTH"</span><span class="p">,</span> <span class="s2">"DAYOFMONTH"</span><span class="p">]</span> </span></pre></div> @@ -39134,8 +39262,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#DayOfYear"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DayOfYear-4037"><a href="#DayOfYear-4037"><span class="linenos">4037</span></a><span class="k">class</span> <span class="nc">DayOfYear</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="DayOfYear-4038"><a href="#DayOfYear-4038"><span class="linenos">4038</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DAY_OF_YEAR"</span><span class="p">,</span> <span class="s2">"DAYOFYEAR"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DayOfYear-4042"><a href="#DayOfYear-4042"><span class="linenos">4042</span></a><span class="k">class</span> <span class="nc">DayOfYear</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="DayOfYear-4043"><a href="#DayOfYear-4043"><span class="linenos">4043</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DAY_OF_YEAR"</span><span class="p">,</span> <span class="s2">"DAYOFYEAR"</span><span class="p">]</span> </span></pre></div> @@ -39221,8 +39349,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#WeekOfYear"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="WeekOfYear-4041"><a href="#WeekOfYear-4041"><span class="linenos">4041</span></a><span class="k">class</span> <span class="nc">WeekOfYear</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="WeekOfYear-4042"><a href="#WeekOfYear-4042"><span class="linenos">4042</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"WEEK_OF_YEAR"</span><span class="p">,</span> <span class="s2">"WEEKOFYEAR"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="WeekOfYear-4046"><a href="#WeekOfYear-4046"><span class="linenos">4046</span></a><span class="k">class</span> <span class="nc">WeekOfYear</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="WeekOfYear-4047"><a href="#WeekOfYear-4047"><span class="linenos">4047</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"WEEK_OF_YEAR"</span><span class="p">,</span> <span class="s2">"WEEKOFYEAR"</span><span class="p">]</span> </span></pre></div> @@ -39308,8 +39436,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#LastDateOfMonth"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="LastDateOfMonth-4045"><a href="#LastDateOfMonth-4045"><span class="linenos">4045</span></a><span class="k">class</span> <span class="nc">LastDateOfMonth</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="LastDateOfMonth-4046"><a href="#LastDateOfMonth-4046"><span class="linenos">4046</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="LastDateOfMonth-4050"><a href="#LastDateOfMonth-4050"><span class="linenos">4050</span></a><span class="k">class</span> <span class="nc">LastDateOfMonth</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="LastDateOfMonth-4051"><a href="#LastDateOfMonth-4051"><span class="linenos">4051</span></a> <span class="k">pass</span> </span></pre></div> @@ -39395,8 +39523,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Extract"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Extract-4049"><a href="#Extract-4049"><span class="linenos">4049</span></a><span class="k">class</span> <span class="nc">Extract</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Extract-4050"><a href="#Extract-4050"><span class="linenos">4050</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Extract-4054"><a href="#Extract-4054"><span class="linenos">4054</span></a><span class="k">class</span> <span class="nc">Extract</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Extract-4055"><a href="#Extract-4055"><span class="linenos">4055</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -39482,8 +39610,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#TimestampAdd"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TimestampAdd-4053"><a href="#TimestampAdd-4053"><span class="linenos">4053</span></a><span class="k">class</span> <span class="nc">TimestampAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="TimestampAdd-4054"><a href="#TimestampAdd-4054"><span class="linenos">4054</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TimestampAdd-4058"><a href="#TimestampAdd-4058"><span class="linenos">4058</span></a><span class="k">class</span> <span class="nc">TimestampAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="TimestampAdd-4059"><a href="#TimestampAdd-4059"><span class="linenos">4059</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -39572,8 +39700,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#TimestampSub"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TimestampSub-4057"><a href="#TimestampSub-4057"><span class="linenos">4057</span></a><span class="k">class</span> <span class="nc">TimestampSub</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="TimestampSub-4058"><a href="#TimestampSub-4058"><span class="linenos">4058</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TimestampSub-4062"><a href="#TimestampSub-4062"><span class="linenos">4062</span></a><span class="k">class</span> <span class="nc">TimestampSub</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="TimestampSub-4063"><a href="#TimestampSub-4063"><span class="linenos">4063</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -39662,8 +39790,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#TimestampDiff"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TimestampDiff-4061"><a href="#TimestampDiff-4061"><span class="linenos">4061</span></a><span class="k">class</span> <span class="nc">TimestampDiff</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="TimestampDiff-4062"><a href="#TimestampDiff-4062"><span class="linenos">4062</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TimestampDiff-4066"><a href="#TimestampDiff-4066"><span class="linenos">4066</span></a><span class="k">class</span> <span class="nc">TimestampDiff</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="TimestampDiff-4067"><a href="#TimestampDiff-4067"><span class="linenos">4067</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -39752,8 +39880,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#TimestampTrunc"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TimestampTrunc-4065"><a href="#TimestampTrunc-4065"><span class="linenos">4065</span></a><span class="k">class</span> <span class="nc">TimestampTrunc</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="TimestampTrunc-4066"><a href="#TimestampTrunc-4066"><span class="linenos">4066</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TimestampTrunc-4070"><a href="#TimestampTrunc-4070"><span class="linenos">4070</span></a><span class="k">class</span> <span class="nc">TimestampTrunc</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="TimestampTrunc-4071"><a href="#TimestampTrunc-4071"><span class="linenos">4071</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -39842,8 +39970,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#TimeAdd"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TimeAdd-4069"><a href="#TimeAdd-4069"><span class="linenos">4069</span></a><span class="k">class</span> <span class="nc">TimeAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="TimeAdd-4070"><a href="#TimeAdd-4070"><span class="linenos">4070</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TimeAdd-4074"><a href="#TimeAdd-4074"><span class="linenos">4074</span></a><span class="k">class</span> <span class="nc">TimeAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="TimeAdd-4075"><a href="#TimeAdd-4075"><span class="linenos">4075</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -39932,8 +40060,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#TimeSub"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TimeSub-4073"><a href="#TimeSub-4073"><span class="linenos">4073</span></a><span class="k">class</span> <span class="nc">TimeSub</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="TimeSub-4074"><a href="#TimeSub-4074"><span class="linenos">4074</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TimeSub-4078"><a href="#TimeSub-4078"><span class="linenos">4078</span></a><span class="k">class</span> <span class="nc">TimeSub</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="TimeSub-4079"><a href="#TimeSub-4079"><span class="linenos">4079</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -40022,8 +40150,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#TimeDiff"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TimeDiff-4077"><a href="#TimeDiff-4077"><span class="linenos">4077</span></a><span class="k">class</span> <span class="nc">TimeDiff</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="TimeDiff-4078"><a href="#TimeDiff-4078"><span class="linenos">4078</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TimeDiff-4082"><a href="#TimeDiff-4082"><span class="linenos">4082</span></a><span class="k">class</span> <span class="nc">TimeDiff</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="TimeDiff-4083"><a href="#TimeDiff-4083"><span class="linenos">4083</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -40112,8 +40240,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#TimeTrunc"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TimeTrunc-4081"><a href="#TimeTrunc-4081"><span class="linenos">4081</span></a><span class="k">class</span> <span class="nc">TimeTrunc</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="TimeTrunc-4082"><a href="#TimeTrunc-4082"><span class="linenos">4082</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TimeTrunc-4086"><a href="#TimeTrunc-4086"><span class="linenos">4086</span></a><span class="k">class</span> <span class="nc">TimeTrunc</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="TimeTrunc-4087"><a href="#TimeTrunc-4087"><span class="linenos">4087</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -40202,9 +40330,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#DateFromParts"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DateFromParts-4085"><a href="#DateFromParts-4085"><span class="linenos">4085</span></a><span class="k">class</span> <span class="nc">DateFromParts</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="DateFromParts-4086"><a href="#DateFromParts-4086"><span class="linenos">4086</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DATEFROMPARTS"</span><span class="p">]</span> -</span><span id="DateFromParts-4087"><a href="#DateFromParts-4087"><span class="linenos">4087</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"year"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"month"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"day"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DateFromParts-4090"><a href="#DateFromParts-4090"><span class="linenos">4090</span></a><span class="k">class</span> <span class="nc">DateFromParts</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="DateFromParts-4091"><a href="#DateFromParts-4091"><span class="linenos">4091</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"DATEFROMPARTS"</span><span class="p">]</span> +</span><span id="DateFromParts-4092"><a href="#DateFromParts-4092"><span class="linenos">4092</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"year"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"month"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"day"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -40290,8 +40418,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#DateStrToDate"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DateStrToDate-4090"><a href="#DateStrToDate-4090"><span class="linenos">4090</span></a><span class="k">class</span> <span class="nc">DateStrToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="DateStrToDate-4091"><a href="#DateStrToDate-4091"><span class="linenos">4091</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DateStrToDate-4095"><a href="#DateStrToDate-4095"><span class="linenos">4095</span></a><span class="k">class</span> <span class="nc">DateStrToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="DateStrToDate-4096"><a href="#DateStrToDate-4096"><span class="linenos">4096</span></a> <span class="k">pass</span> </span></pre></div> @@ -40377,8 +40505,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#DateToDateStr"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DateToDateStr-4094"><a href="#DateToDateStr-4094"><span class="linenos">4094</span></a><span class="k">class</span> <span class="nc">DateToDateStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="DateToDateStr-4095"><a href="#DateToDateStr-4095"><span class="linenos">4095</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DateToDateStr-4099"><a href="#DateToDateStr-4099"><span class="linenos">4099</span></a><span class="k">class</span> <span class="nc">DateToDateStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="DateToDateStr-4100"><a href="#DateToDateStr-4100"><span class="linenos">4100</span></a> <span class="k">pass</span> </span></pre></div> @@ -40464,8 +40592,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#DateToDi"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DateToDi-4098"><a href="#DateToDi-4098"><span class="linenos">4098</span></a><span class="k">class</span> <span class="nc">DateToDi</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="DateToDi-4099"><a href="#DateToDi-4099"><span class="linenos">4099</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DateToDi-4103"><a href="#DateToDi-4103"><span class="linenos">4103</span></a><span class="k">class</span> <span class="nc">DateToDi</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="DateToDi-4104"><a href="#DateToDi-4104"><span class="linenos">4104</span></a> <span class="k">pass</span> </span></pre></div> @@ -40551,9 +40679,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Date"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Date-4102"><a href="#Date-4102"><span class="linenos">4102</span></a><span class="k">class</span> <span class="nc">Date</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Date-4103"><a href="#Date-4103"><span class="linenos">4103</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="Date-4104"><a href="#Date-4104"><span class="linenos">4104</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Date-4107"><a href="#Date-4107"><span class="linenos">4107</span></a><span class="k">class</span> <span class="nc">Date</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Date-4108"><a href="#Date-4108"><span class="linenos">4108</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="Date-4109"><a href="#Date-4109"><span class="linenos">4109</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span></pre></div> @@ -40639,8 +40767,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Day"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Day-4107"><a href="#Day-4107"><span class="linenos">4107</span></a><span class="k">class</span> <span class="nc">Day</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Day-4108"><a href="#Day-4108"><span class="linenos">4108</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Day-4112"><a href="#Day-4112"><span class="linenos">4112</span></a><span class="k">class</span> <span class="nc">Day</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Day-4113"><a href="#Day-4113"><span class="linenos">4113</span></a> <span class="k">pass</span> </span></pre></div> @@ -40726,8 +40854,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Decode"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Decode-4111"><a href="#Decode-4111"><span class="linenos">4111</span></a><span class="k">class</span> <span class="nc">Decode</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Decode-4112"><a href="#Decode-4112"><span class="linenos">4112</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"charset"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"replace"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Decode-4116"><a href="#Decode-4116"><span class="linenos">4116</span></a><span class="k">class</span> <span class="nc">Decode</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Decode-4117"><a href="#Decode-4117"><span class="linenos">4117</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"charset"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"replace"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -40813,8 +40941,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#DiToDate"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="DiToDate-4115"><a href="#DiToDate-4115"><span class="linenos">4115</span></a><span class="k">class</span> <span class="nc">DiToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="DiToDate-4116"><a href="#DiToDate-4116"><span class="linenos">4116</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="DiToDate-4120"><a href="#DiToDate-4120"><span class="linenos">4120</span></a><span class="k">class</span> <span class="nc">DiToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="DiToDate-4121"><a href="#DiToDate-4121"><span class="linenos">4121</span></a> <span class="k">pass</span> </span></pre></div> @@ -40900,8 +41028,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Encode"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Encode-4119"><a href="#Encode-4119"><span class="linenos">4119</span></a><span class="k">class</span> <span class="nc">Encode</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Encode-4120"><a href="#Encode-4120"><span class="linenos">4120</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"charset"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Encode-4124"><a href="#Encode-4124"><span class="linenos">4124</span></a><span class="k">class</span> <span class="nc">Encode</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Encode-4125"><a href="#Encode-4125"><span class="linenos">4125</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"charset"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -40987,8 +41115,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Exp"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Exp-4123"><a href="#Exp-4123"><span class="linenos">4123</span></a><span class="k">class</span> <span class="nc">Exp</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Exp-4124"><a href="#Exp-4124"><span class="linenos">4124</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Exp-4128"><a href="#Exp-4128"><span class="linenos">4128</span></a><span class="k">class</span> <span class="nc">Exp</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Exp-4129"><a href="#Exp-4129"><span class="linenos">4129</span></a> <span class="k">pass</span> </span></pre></div> @@ -41074,8 +41202,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Explode"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Explode-4127"><a href="#Explode-4127"><span class="linenos">4127</span></a><span class="k">class</span> <span class="nc">Explode</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Explode-4128"><a href="#Explode-4128"><span class="linenos">4128</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Explode-4132"><a href="#Explode-4132"><span class="linenos">4132</span></a><span class="k">class</span> <span class="nc">Explode</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Explode-4133"><a href="#Explode-4133"><span class="linenos">4133</span></a> <span class="k">pass</span> </span></pre></div> @@ -41161,8 +41289,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Floor"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Floor-4131"><a href="#Floor-4131"><span class="linenos">4131</span></a><span class="k">class</span> <span class="nc">Floor</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Floor-4132"><a href="#Floor-4132"><span class="linenos">4132</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"decimals"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Floor-4136"><a href="#Floor-4136"><span class="linenos">4136</span></a><span class="k">class</span> <span class="nc">Floor</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Floor-4137"><a href="#Floor-4137"><span class="linenos">4137</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"decimals"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -41248,8 +41376,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#FromBase64"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="FromBase64-4135"><a href="#FromBase64-4135"><span class="linenos">4135</span></a><span class="k">class</span> <span class="nc">FromBase64</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="FromBase64-4136"><a href="#FromBase64-4136"><span class="linenos">4136</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="FromBase64-4140"><a href="#FromBase64-4140"><span class="linenos">4140</span></a><span class="k">class</span> <span class="nc">FromBase64</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="FromBase64-4141"><a href="#FromBase64-4141"><span class="linenos">4141</span></a> <span class="k">pass</span> </span></pre></div> @@ -41335,8 +41463,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#ToBase64"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ToBase64-4139"><a href="#ToBase64-4139"><span class="linenos">4139</span></a><span class="k">class</span> <span class="nc">ToBase64</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="ToBase64-4140"><a href="#ToBase64-4140"><span class="linenos">4140</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ToBase64-4144"><a href="#ToBase64-4144"><span class="linenos">4144</span></a><span class="k">class</span> <span class="nc">ToBase64</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="ToBase64-4145"><a href="#ToBase64-4145"><span class="linenos">4145</span></a> <span class="k">pass</span> </span></pre></div> @@ -41422,9 +41550,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Greatest"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Greatest-4143"><a href="#Greatest-4143"><span class="linenos">4143</span></a><span class="k">class</span> <span class="nc">Greatest</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Greatest-4144"><a href="#Greatest-4144"><span class="linenos">4144</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="Greatest-4145"><a href="#Greatest-4145"><span class="linenos">4145</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Greatest-4148"><a href="#Greatest-4148"><span class="linenos">4148</span></a><span class="k">class</span> <span class="nc">Greatest</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Greatest-4149"><a href="#Greatest-4149"><span class="linenos">4149</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="Greatest-4150"><a href="#Greatest-4150"><span class="linenos">4150</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span></pre></div> @@ -41510,8 +41638,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#GroupConcat"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="GroupConcat-4148"><a href="#GroupConcat-4148"><span class="linenos">4148</span></a><span class="k">class</span> <span class="nc">GroupConcat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="GroupConcat-4149"><a href="#GroupConcat-4149"><span class="linenos">4149</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"separator"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="GroupConcat-4153"><a href="#GroupConcat-4153"><span class="linenos">4153</span></a><span class="k">class</span> <span class="nc">GroupConcat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="GroupConcat-4154"><a href="#GroupConcat-4154"><span class="linenos">4154</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"separator"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -41597,8 +41725,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Hex"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Hex-4152"><a href="#Hex-4152"><span class="linenos">4152</span></a><span class="k">class</span> <span class="nc">Hex</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Hex-4153"><a href="#Hex-4153"><span class="linenos">4153</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Hex-4157"><a href="#Hex-4157"><span class="linenos">4157</span></a><span class="k">class</span> <span class="nc">Hex</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Hex-4158"><a href="#Hex-4158"><span class="linenos">4158</span></a> <span class="k">pass</span> </span></pre></div> @@ -41684,8 +41812,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#If"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="If-4156"><a href="#If-4156"><span class="linenos">4156</span></a><span class="k">class</span> <span class="nc">If</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="If-4157"><a href="#If-4157"><span class="linenos">4157</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"true"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"false"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="If-4161"><a href="#If-4161"><span class="linenos">4161</span></a><span class="k">class</span> <span class="nc">If</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="If-4162"><a href="#If-4162"><span class="linenos">4162</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"true"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"false"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -41771,8 +41899,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Initcap"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Initcap-4160"><a href="#Initcap-4160"><span class="linenos">4160</span></a><span class="k">class</span> <span class="nc">Initcap</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Initcap-4161"><a href="#Initcap-4161"><span class="linenos">4161</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Initcap-4165"><a href="#Initcap-4165"><span class="linenos">4165</span></a><span class="k">class</span> <span class="nc">Initcap</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Initcap-4166"><a href="#Initcap-4166"><span class="linenos">4166</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -41858,8 +41986,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#JSONKeyValue"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="JSONKeyValue-4164"><a href="#JSONKeyValue-4164"><span class="linenos">4164</span></a><span class="k">class</span> <span class="nc">JSONKeyValue</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="JSONKeyValue-4165"><a href="#JSONKeyValue-4165"><span class="linenos">4165</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="JSONKeyValue-4169"><a href="#JSONKeyValue-4169"><span class="linenos">4169</span></a><span class="k">class</span> <span class="nc">JSONKeyValue</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="JSONKeyValue-4170"><a href="#JSONKeyValue-4170"><span class="linenos">4170</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -41923,15 +42051,15 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#JSONObject"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="JSONObject-4168"><a href="#JSONObject-4168"><span class="linenos">4168</span></a><span class="k">class</span> <span class="nc">JSONObject</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="JSONObject-4169"><a href="#JSONObject-4169"><span class="linenos">4169</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="JSONObject-4170"><a href="#JSONObject-4170"><span class="linenos">4170</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="JSONObject-4171"><a href="#JSONObject-4171"><span class="linenos">4171</span></a> <span class="s2">"null_handling"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="JSONObject-4172"><a href="#JSONObject-4172"><span class="linenos">4172</span></a> <span class="s2">"unique_keys"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="JSONObject-4173"><a href="#JSONObject-4173"><span class="linenos">4173</span></a> <span class="s2">"return_type"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="JSONObject-4174"><a href="#JSONObject-4174"><span class="linenos">4174</span></a> <span class="s2">"format_json"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="JSONObject-4175"><a href="#JSONObject-4175"><span class="linenos">4175</span></a> <span class="s2">"encoding"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="JSONObject-4176"><a href="#JSONObject-4176"><span class="linenos">4176</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="JSONObject-4173"><a href="#JSONObject-4173"><span class="linenos">4173</span></a><span class="k">class</span> <span class="nc">JSONObject</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="JSONObject-4174"><a href="#JSONObject-4174"><span class="linenos">4174</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="JSONObject-4175"><a href="#JSONObject-4175"><span class="linenos">4175</span></a> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="JSONObject-4176"><a href="#JSONObject-4176"><span class="linenos">4176</span></a> <span class="s2">"null_handling"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="JSONObject-4177"><a href="#JSONObject-4177"><span class="linenos">4177</span></a> <span class="s2">"unique_keys"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="JSONObject-4178"><a href="#JSONObject-4178"><span class="linenos">4178</span></a> <span class="s2">"return_type"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="JSONObject-4179"><a href="#JSONObject-4179"><span class="linenos">4179</span></a> <span class="s2">"format_json"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="JSONObject-4180"><a href="#JSONObject-4180"><span class="linenos">4180</span></a> <span class="s2">"encoding"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="JSONObject-4181"><a href="#JSONObject-4181"><span class="linenos">4181</span></a> <span class="p">}</span> </span></pre></div> @@ -42017,8 +42145,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#OpenJSONColumnDef"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="OpenJSONColumnDef-4179"><a href="#OpenJSONColumnDef-4179"><span class="linenos">4179</span></a><span class="k">class</span> <span class="nc">OpenJSONColumnDef</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="OpenJSONColumnDef-4180"><a href="#OpenJSONColumnDef-4180"><span class="linenos">4180</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"as_json"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="OpenJSONColumnDef-4184"><a href="#OpenJSONColumnDef-4184"><span class="linenos">4184</span></a><span class="k">class</span> <span class="nc">OpenJSONColumnDef</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="OpenJSONColumnDef-4185"><a href="#OpenJSONColumnDef-4185"><span class="linenos">4185</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"as_json"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -42082,8 +42210,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#OpenJSON"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="OpenJSON-4183"><a href="#OpenJSON-4183"><span class="linenos">4183</span></a><span class="k">class</span> <span class="nc">OpenJSON</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="OpenJSON-4184"><a href="#OpenJSON-4184"><span class="linenos">4184</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="OpenJSON-4188"><a href="#OpenJSON-4188"><span class="linenos">4188</span></a><span class="k">class</span> <span class="nc">OpenJSON</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="OpenJSON-4189"><a href="#OpenJSON-4189"><span class="linenos">4189</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -42169,8 +42297,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#JSONBContains"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="JSONBContains-4187"><a href="#JSONBContains-4187"><span class="linenos">4187</span></a><span class="k">class</span> <span class="nc">JSONBContains</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="JSONBContains-4188"><a href="#JSONBContains-4188"><span class="linenos">4188</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSONB_CONTAINS"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="JSONBContains-4192"><a href="#JSONBContains-4192"><span class="linenos">4192</span></a><span class="k">class</span> <span class="nc">JSONBContains</span><span class="p">(</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="JSONBContains-4193"><a href="#JSONBContains-4193"><span class="linenos">4193</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSONB_CONTAINS"</span><span class="p">]</span> </span></pre></div> @@ -42249,8 +42377,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#JSONExtract"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="JSONExtract-4191"><a href="#JSONExtract-4191"><span class="linenos">4191</span></a><span class="k">class</span> <span class="nc">JSONExtract</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Func</span><span class="p">):</span> -</span><span id="JSONExtract-4192"><a href="#JSONExtract-4192"><span class="linenos">4192</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSON_EXTRACT"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="JSONExtract-4196"><a href="#JSONExtract-4196"><span class="linenos">4196</span></a><span class="k">class</span> <span class="nc">JSONExtract</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Func</span><span class="p">):</span> +</span><span id="JSONExtract-4197"><a href="#JSONExtract-4197"><span class="linenos">4197</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSON_EXTRACT"</span><span class="p">]</span> </span></pre></div> @@ -42336,8 +42464,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#JSONExtractScalar"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="JSONExtractScalar-4195"><a href="#JSONExtractScalar-4195"><span class="linenos">4195</span></a><span class="k">class</span> <span class="nc">JSONExtractScalar</span><span class="p">(</span><span class="n">JSONExtract</span><span class="p">):</span> -</span><span id="JSONExtractScalar-4196"><a href="#JSONExtractScalar-4196"><span class="linenos">4196</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSON_EXTRACT_SCALAR"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="JSONExtractScalar-4200"><a href="#JSONExtractScalar-4200"><span class="linenos">4200</span></a><span class="k">class</span> <span class="nc">JSONExtractScalar</span><span class="p">(</span><span class="n">JSONExtract</span><span class="p">):</span> +</span><span id="JSONExtractScalar-4201"><a href="#JSONExtractScalar-4201"><span class="linenos">4201</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSON_EXTRACT_SCALAR"</span><span class="p">]</span> </span></pre></div> @@ -42423,8 +42551,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#JSONBExtract"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="JSONBExtract-4199"><a href="#JSONBExtract-4199"><span class="linenos">4199</span></a><span class="k">class</span> <span class="nc">JSONBExtract</span><span class="p">(</span><span class="n">JSONExtract</span><span class="p">):</span> -</span><span id="JSONBExtract-4200"><a href="#JSONBExtract-4200"><span class="linenos">4200</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSONB_EXTRACT"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="JSONBExtract-4204"><a href="#JSONBExtract-4204"><span class="linenos">4204</span></a><span class="k">class</span> <span class="nc">JSONBExtract</span><span class="p">(</span><span class="n">JSONExtract</span><span class="p">):</span> +</span><span id="JSONBExtract-4205"><a href="#JSONBExtract-4205"><span class="linenos">4205</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSONB_EXTRACT"</span><span class="p">]</span> </span></pre></div> @@ -42510,8 +42638,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#JSONBExtractScalar"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="JSONBExtractScalar-4203"><a href="#JSONBExtractScalar-4203"><span class="linenos">4203</span></a><span class="k">class</span> <span class="nc">JSONBExtractScalar</span><span class="p">(</span><span class="n">JSONExtract</span><span class="p">):</span> -</span><span id="JSONBExtractScalar-4204"><a href="#JSONBExtractScalar-4204"><span class="linenos">4204</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSONB_EXTRACT_SCALAR"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="JSONBExtractScalar-4208"><a href="#JSONBExtractScalar-4208"><span class="linenos">4208</span></a><span class="k">class</span> <span class="nc">JSONBExtractScalar</span><span class="p">(</span><span class="n">JSONExtract</span><span class="p">):</span> +</span><span id="JSONBExtractScalar-4209"><a href="#JSONBExtractScalar-4209"><span class="linenos">4209</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSONB_EXTRACT_SCALAR"</span><span class="p">]</span> </span></pre></div> @@ -42597,9 +42725,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#JSONFormat"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="JSONFormat-4207"><a href="#JSONFormat-4207"><span class="linenos">4207</span></a><span class="k">class</span> <span class="nc">JSONFormat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="JSONFormat-4208"><a href="#JSONFormat-4208"><span class="linenos">4208</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"options"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="JSONFormat-4209"><a href="#JSONFormat-4209"><span class="linenos">4209</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSON_FORMAT"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="JSONFormat-4212"><a href="#JSONFormat-4212"><span class="linenos">4212</span></a><span class="k">class</span> <span class="nc">JSONFormat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="JSONFormat-4213"><a href="#JSONFormat-4213"><span class="linenos">4213</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"options"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="JSONFormat-4214"><a href="#JSONFormat-4214"><span class="linenos">4214</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"JSON_FORMAT"</span><span class="p">]</span> </span></pre></div> @@ -42685,9 +42813,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Least"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Least-4212"><a href="#Least-4212"><span class="linenos">4212</span></a><span class="k">class</span> <span class="nc">Least</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Least-4213"><a href="#Least-4213"><span class="linenos">4213</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="Least-4214"><a href="#Least-4214"><span class="linenos">4214</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Least-4217"><a href="#Least-4217"><span class="linenos">4217</span></a><span class="k">class</span> <span class="nc">Least</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Least-4218"><a href="#Least-4218"><span class="linenos">4218</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="Least-4219"><a href="#Least-4219"><span class="linenos">4219</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span></pre></div> @@ -42773,8 +42901,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Left"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Left-4217"><a href="#Left-4217"><span class="linenos">4217</span></a><span class="k">class</span> <span class="nc">Left</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Left-4218"><a href="#Left-4218"><span class="linenos">4218</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Left-4222"><a href="#Left-4222"><span class="linenos">4222</span></a><span class="k">class</span> <span class="nc">Left</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Left-4223"><a href="#Left-4223"><span class="linenos">4223</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -42860,8 +42988,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Right"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Right-4221"><a href="#Right-4221"><span class="linenos">4221</span></a><span class="k">class</span> <span class="nc">Right</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Right-4222"><a href="#Right-4222"><span class="linenos">4222</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Right-4226"><a href="#Right-4226"><span class="linenos">4226</span></a><span class="k">class</span> <span class="nc">Right</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Right-4227"><a href="#Right-4227"><span class="linenos">4227</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -42947,8 +43075,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Length"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Length-4225"><a href="#Length-4225"><span class="linenos">4225</span></a><span class="k">class</span> <span class="nc">Length</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Length-4226"><a href="#Length-4226"><span class="linenos">4226</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="s2">"LEN"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Length-4230"><a href="#Length-4230"><span class="linenos">4230</span></a><span class="k">class</span> <span class="nc">Length</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Length-4231"><a href="#Length-4231"><span class="linenos">4231</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"LENGTH"</span><span class="p">,</span> <span class="s2">"LEN"</span><span class="p">]</span> </span></pre></div> @@ -43034,14 +43162,14 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Levenshtein"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Levenshtein-4229"><a href="#Levenshtein-4229"><span class="linenos">4229</span></a><span class="k">class</span> <span class="nc">Levenshtein</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Levenshtein-4230"><a href="#Levenshtein-4230"><span class="linenos">4230</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Levenshtein-4231"><a href="#Levenshtein-4231"><span class="linenos">4231</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Levenshtein-4232"><a href="#Levenshtein-4232"><span class="linenos">4232</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Levenshtein-4233"><a href="#Levenshtein-4233"><span class="linenos">4233</span></a> <span class="s2">"ins_cost"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Levenshtein-4234"><a href="#Levenshtein-4234"><span class="linenos">4234</span></a> <span class="s2">"del_cost"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Levenshtein-4235"><a href="#Levenshtein-4235"><span class="linenos">4235</span></a> <span class="s2">"sub_cost"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Levenshtein-4236"><a href="#Levenshtein-4236"><span class="linenos">4236</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Levenshtein-4234"><a href="#Levenshtein-4234"><span class="linenos">4234</span></a><span class="k">class</span> <span class="nc">Levenshtein</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Levenshtein-4235"><a href="#Levenshtein-4235"><span class="linenos">4235</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Levenshtein-4236"><a href="#Levenshtein-4236"><span class="linenos">4236</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Levenshtein-4237"><a href="#Levenshtein-4237"><span class="linenos">4237</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Levenshtein-4238"><a href="#Levenshtein-4238"><span class="linenos">4238</span></a> <span class="s2">"ins_cost"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Levenshtein-4239"><a href="#Levenshtein-4239"><span class="linenos">4239</span></a> <span class="s2">"del_cost"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Levenshtein-4240"><a href="#Levenshtein-4240"><span class="linenos">4240</span></a> <span class="s2">"sub_cost"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Levenshtein-4241"><a href="#Levenshtein-4241"><span class="linenos">4241</span></a> <span class="p">}</span> </span></pre></div> @@ -43127,8 +43255,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Ln"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Ln-4239"><a href="#Ln-4239"><span class="linenos">4239</span></a><span class="k">class</span> <span class="nc">Ln</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Ln-4240"><a href="#Ln-4240"><span class="linenos">4240</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Ln-4244"><a href="#Ln-4244"><span class="linenos">4244</span></a><span class="k">class</span> <span class="nc">Ln</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Ln-4245"><a href="#Ln-4245"><span class="linenos">4245</span></a> <span class="k">pass</span> </span></pre></div> @@ -43214,8 +43342,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Log"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Log-4243"><a href="#Log-4243"><span class="linenos">4243</span></a><span class="k">class</span> <span class="nc">Log</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Log-4244"><a href="#Log-4244"><span class="linenos">4244</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Log-4248"><a href="#Log-4248"><span class="linenos">4248</span></a><span class="k">class</span> <span class="nc">Log</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Log-4249"><a href="#Log-4249"><span class="linenos">4249</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -43301,8 +43429,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Log2"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Log2-4247"><a href="#Log2-4247"><span class="linenos">4247</span></a><span class="k">class</span> <span class="nc">Log2</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Log2-4248"><a href="#Log2-4248"><span class="linenos">4248</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Log2-4252"><a href="#Log2-4252"><span class="linenos">4252</span></a><span class="k">class</span> <span class="nc">Log2</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Log2-4253"><a href="#Log2-4253"><span class="linenos">4253</span></a> <span class="k">pass</span> </span></pre></div> @@ -43388,8 +43516,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Log10"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Log10-4251"><a href="#Log10-4251"><span class="linenos">4251</span></a><span class="k">class</span> <span class="nc">Log10</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Log10-4252"><a href="#Log10-4252"><span class="linenos">4252</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Log10-4256"><a href="#Log10-4256"><span class="linenos">4256</span></a><span class="k">class</span> <span class="nc">Log10</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Log10-4257"><a href="#Log10-4257"><span class="linenos">4257</span></a> <span class="k">pass</span> </span></pre></div> @@ -43475,8 +43603,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#LogicalOr"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="LogicalOr-4255"><a href="#LogicalOr-4255"><span class="linenos">4255</span></a><span class="k">class</span> <span class="nc">LogicalOr</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="LogicalOr-4256"><a href="#LogicalOr-4256"><span class="linenos">4256</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"LOGICAL_OR"</span><span class="p">,</span> <span class="s2">"BOOL_OR"</span><span class="p">,</span> <span class="s2">"BOOLOR_AGG"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="LogicalOr-4260"><a href="#LogicalOr-4260"><span class="linenos">4260</span></a><span class="k">class</span> <span class="nc">LogicalOr</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="LogicalOr-4261"><a href="#LogicalOr-4261"><span class="linenos">4261</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"LOGICAL_OR"</span><span class="p">,</span> <span class="s2">"BOOL_OR"</span><span class="p">,</span> <span class="s2">"BOOLOR_AGG"</span><span class="p">]</span> </span></pre></div> @@ -43562,8 +43690,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#LogicalAnd"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="LogicalAnd-4259"><a href="#LogicalAnd-4259"><span class="linenos">4259</span></a><span class="k">class</span> <span class="nc">LogicalAnd</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="LogicalAnd-4260"><a href="#LogicalAnd-4260"><span class="linenos">4260</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"LOGICAL_AND"</span><span class="p">,</span> <span class="s2">"BOOL_AND"</span><span class="p">,</span> <span class="s2">"BOOLAND_AGG"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="LogicalAnd-4264"><a href="#LogicalAnd-4264"><span class="linenos">4264</span></a><span class="k">class</span> <span class="nc">LogicalAnd</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="LogicalAnd-4265"><a href="#LogicalAnd-4265"><span class="linenos">4265</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"LOGICAL_AND"</span><span class="p">,</span> <span class="s2">"BOOL_AND"</span><span class="p">,</span> <span class="s2">"BOOLAND_AGG"</span><span class="p">]</span> </span></pre></div> @@ -43649,8 +43777,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Lower"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Lower-4263"><a href="#Lower-4263"><span class="linenos">4263</span></a><span class="k">class</span> <span class="nc">Lower</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Lower-4264"><a href="#Lower-4264"><span class="linenos">4264</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"LOWER"</span><span class="p">,</span> <span class="s2">"LCASE"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Lower-4268"><a href="#Lower-4268"><span class="linenos">4268</span></a><span class="k">class</span> <span class="nc">Lower</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Lower-4269"><a href="#Lower-4269"><span class="linenos">4269</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"LOWER"</span><span class="p">,</span> <span class="s2">"LCASE"</span><span class="p">]</span> </span></pre></div> @@ -43736,8 +43864,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Map"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Map-4267"><a href="#Map-4267"><span class="linenos">4267</span></a><span class="k">class</span> <span class="nc">Map</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Map-4268"><a href="#Map-4268"><span class="linenos">4268</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"keys"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"values"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Map-4272"><a href="#Map-4272"><span class="linenos">4272</span></a><span class="k">class</span> <span class="nc">Map</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Map-4273"><a href="#Map-4273"><span class="linenos">4273</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"keys"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"values"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -43823,8 +43951,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#StarMap"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="StarMap-4271"><a href="#StarMap-4271"><span class="linenos">4271</span></a><span class="k">class</span> <span class="nc">StarMap</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="StarMap-4272"><a href="#StarMap-4272"><span class="linenos">4272</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="StarMap-4276"><a href="#StarMap-4276"><span class="linenos">4276</span></a><span class="k">class</span> <span class="nc">StarMap</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="StarMap-4277"><a href="#StarMap-4277"><span class="linenos">4277</span></a> <span class="k">pass</span> </span></pre></div> @@ -43910,17 +44038,17 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#VarMap"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="VarMap-4275"><a href="#VarMap-4275"><span class="linenos">4275</span></a><span class="k">class</span> <span class="nc">VarMap</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="VarMap-4276"><a href="#VarMap-4276"><span class="linenos">4276</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"keys"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"values"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="VarMap-4277"><a href="#VarMap-4277"><span class="linenos">4277</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="VarMap-4278"><a href="#VarMap-4278"><span class="linenos">4278</span></a> -</span><span id="VarMap-4279"><a href="#VarMap-4279"><span class="linenos">4279</span></a> <span class="nd">@property</span> -</span><span id="VarMap-4280"><a href="#VarMap-4280"><span class="linenos">4280</span></a> <span class="k">def</span> <span class="nf">keys</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Expression</span><span class="p">]:</span> -</span><span id="VarMap-4281"><a href="#VarMap-4281"><span class="linenos">4281</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"keys"</span><span class="p">]</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="VarMap-4282"><a href="#VarMap-4282"><span class="linenos">4282</span></a> -</span><span id="VarMap-4283"><a href="#VarMap-4283"><span class="linenos">4283</span></a> <span class="nd">@property</span> -</span><span id="VarMap-4284"><a href="#VarMap-4284"><span class="linenos">4284</span></a> <span class="k">def</span> <span class="nf">values</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Expression</span><span class="p">]:</span> -</span><span id="VarMap-4285"><a href="#VarMap-4285"><span class="linenos">4285</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"values"</span><span class="p">]</span><span class="o">.</span><span class="n">expressions</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="VarMap-4280"><a href="#VarMap-4280"><span class="linenos">4280</span></a><span class="k">class</span> <span class="nc">VarMap</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="VarMap-4281"><a href="#VarMap-4281"><span class="linenos">4281</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"keys"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"values"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="VarMap-4282"><a href="#VarMap-4282"><span class="linenos">4282</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="VarMap-4283"><a href="#VarMap-4283"><span class="linenos">4283</span></a> +</span><span id="VarMap-4284"><a href="#VarMap-4284"><span class="linenos">4284</span></a> <span class="nd">@property</span> +</span><span id="VarMap-4285"><a href="#VarMap-4285"><span class="linenos">4285</span></a> <span class="k">def</span> <span class="nf">keys</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Expression</span><span class="p">]:</span> +</span><span id="VarMap-4286"><a href="#VarMap-4286"><span class="linenos">4286</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"keys"</span><span class="p">]</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="VarMap-4287"><a href="#VarMap-4287"><span class="linenos">4287</span></a> +</span><span id="VarMap-4288"><a href="#VarMap-4288"><span class="linenos">4288</span></a> <span class="nd">@property</span> +</span><span id="VarMap-4289"><a href="#VarMap-4289"><span class="linenos">4289</span></a> <span class="k">def</span> <span class="nf">values</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Expression</span><span class="p">]:</span> +</span><span id="VarMap-4290"><a href="#VarMap-4290"><span class="linenos">4290</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"values"</span><span class="p">]</span><span class="o">.</span><span class="n">expressions</span> </span></pre></div> @@ -44006,8 +44134,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#MatchAgainst"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="MatchAgainst-4289"><a href="#MatchAgainst-4289"><span class="linenos">4289</span></a><span class="k">class</span> <span class="nc">MatchAgainst</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="MatchAgainst-4290"><a href="#MatchAgainst-4290"><span class="linenos">4290</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"modifier"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="MatchAgainst-4294"><a href="#MatchAgainst-4294"><span class="linenos">4294</span></a><span class="k">class</span> <span class="nc">MatchAgainst</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="MatchAgainst-4295"><a href="#MatchAgainst-4295"><span class="linenos">4295</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"modifier"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -44093,9 +44221,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Max"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Max-4293"><a href="#Max-4293"><span class="linenos">4293</span></a><span class="k">class</span> <span class="nc">Max</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="Max-4294"><a href="#Max-4294"><span class="linenos">4294</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="Max-4295"><a href="#Max-4295"><span class="linenos">4295</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Max-4298"><a href="#Max-4298"><span class="linenos">4298</span></a><span class="k">class</span> <span class="nc">Max</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="Max-4299"><a href="#Max-4299"><span class="linenos">4299</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="Max-4300"><a href="#Max-4300"><span class="linenos">4300</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span></pre></div> @@ -44181,8 +44309,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#MD5"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="MD5-4298"><a href="#MD5-4298"><span class="linenos">4298</span></a><span class="k">class</span> <span class="nc">MD5</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="MD5-4299"><a href="#MD5-4299"><span class="linenos">4299</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"MD5"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="MD5-4303"><a href="#MD5-4303"><span class="linenos">4303</span></a><span class="k">class</span> <span class="nc">MD5</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="MD5-4304"><a href="#MD5-4304"><span class="linenos">4304</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"MD5"</span><span class="p">]</span> </span></pre></div> @@ -44268,9 +44396,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Min"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Min-4302"><a href="#Min-4302"><span class="linenos">4302</span></a><span class="k">class</span> <span class="nc">Min</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="Min-4303"><a href="#Min-4303"><span class="linenos">4303</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="Min-4304"><a href="#Min-4304"><span class="linenos">4304</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Min-4307"><a href="#Min-4307"><span class="linenos">4307</span></a><span class="k">class</span> <span class="nc">Min</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="Min-4308"><a href="#Min-4308"><span class="linenos">4308</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="Min-4309"><a href="#Min-4309"><span class="linenos">4309</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span></pre></div> @@ -44356,8 +44484,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Month"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Month-4307"><a href="#Month-4307"><span class="linenos">4307</span></a><span class="k">class</span> <span class="nc">Month</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Month-4308"><a href="#Month-4308"><span class="linenos">4308</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Month-4312"><a href="#Month-4312"><span class="linenos">4312</span></a><span class="k">class</span> <span class="nc">Month</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Month-4313"><a href="#Month-4313"><span class="linenos">4313</span></a> <span class="k">pass</span> </span></pre></div> @@ -44443,8 +44571,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Nvl2"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Nvl2-4311"><a href="#Nvl2-4311"><span class="linenos">4311</span></a><span class="k">class</span> <span class="nc">Nvl2</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Nvl2-4312"><a href="#Nvl2-4312"><span class="linenos">4312</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"true"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"false"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Nvl2-4316"><a href="#Nvl2-4316"><span class="linenos">4316</span></a><span class="k">class</span> <span class="nc">Nvl2</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Nvl2-4317"><a href="#Nvl2-4317"><span class="linenos">4317</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"true"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"false"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -44530,8 +44658,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Posexplode"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Posexplode-4315"><a href="#Posexplode-4315"><span class="linenos">4315</span></a><span class="k">class</span> <span class="nc">Posexplode</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Posexplode-4316"><a href="#Posexplode-4316"><span class="linenos">4316</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Posexplode-4320"><a href="#Posexplode-4320"><span class="linenos">4320</span></a><span class="k">class</span> <span class="nc">Posexplode</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Posexplode-4321"><a href="#Posexplode-4321"><span class="linenos">4321</span></a> <span class="k">pass</span> </span></pre></div> @@ -44617,8 +44745,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Pow"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Pow-4319"><a href="#Pow-4319"><span class="linenos">4319</span></a><span class="k">class</span> <span class="nc">Pow</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Func</span><span class="p">):</span> -</span><span id="Pow-4320"><a href="#Pow-4320"><span class="linenos">4320</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"POWER"</span><span class="p">,</span> <span class="s2">"POW"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Pow-4324"><a href="#Pow-4324"><span class="linenos">4324</span></a><span class="k">class</span> <span class="nc">Pow</span><span class="p">(</span><span class="n">Binary</span><span class="p">,</span> <span class="n">Func</span><span class="p">):</span> +</span><span id="Pow-4325"><a href="#Pow-4325"><span class="linenos">4325</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"POWER"</span><span class="p">,</span> <span class="s2">"POW"</span><span class="p">]</span> </span></pre></div> @@ -44704,8 +44832,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#PercentileCont"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="PercentileCont-4323"><a href="#PercentileCont-4323"><span class="linenos">4323</span></a><span class="k">class</span> <span class="nc">PercentileCont</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="PercentileCont-4324"><a href="#PercentileCont-4324"><span class="linenos">4324</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="PercentileCont-4328"><a href="#PercentileCont-4328"><span class="linenos">4328</span></a><span class="k">class</span> <span class="nc">PercentileCont</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="PercentileCont-4329"><a href="#PercentileCont-4329"><span class="linenos">4329</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -44791,8 +44919,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#PercentileDisc"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="PercentileDisc-4327"><a href="#PercentileDisc-4327"><span class="linenos">4327</span></a><span class="k">class</span> <span class="nc">PercentileDisc</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="PercentileDisc-4328"><a href="#PercentileDisc-4328"><span class="linenos">4328</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="PercentileDisc-4332"><a href="#PercentileDisc-4332"><span class="linenos">4332</span></a><span class="k">class</span> <span class="nc">PercentileDisc</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="PercentileDisc-4333"><a href="#PercentileDisc-4333"><span class="linenos">4333</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -44878,8 +45006,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Quantile"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Quantile-4331"><a href="#Quantile-4331"><span class="linenos">4331</span></a><span class="k">class</span> <span class="nc">Quantile</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="Quantile-4332"><a href="#Quantile-4332"><span class="linenos">4332</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"quantile"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Quantile-4336"><a href="#Quantile-4336"><span class="linenos">4336</span></a><span class="k">class</span> <span class="nc">Quantile</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="Quantile-4337"><a href="#Quantile-4337"><span class="linenos">4337</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"quantile"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -44965,8 +45093,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#ApproxQuantile"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ApproxQuantile-4335"><a href="#ApproxQuantile-4335"><span class="linenos">4335</span></a><span class="k">class</span> <span class="nc">ApproxQuantile</span><span class="p">(</span><span class="n">Quantile</span><span class="p">):</span> -</span><span id="ApproxQuantile-4336"><a href="#ApproxQuantile-4336"><span class="linenos">4336</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"quantile"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"accuracy"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ApproxQuantile-4340"><a href="#ApproxQuantile-4340"><span class="linenos">4340</span></a><span class="k">class</span> <span class="nc">ApproxQuantile</span><span class="p">(</span><span class="n">Quantile</span><span class="p">):</span> +</span><span id="ApproxQuantile-4341"><a href="#ApproxQuantile-4341"><span class="linenos">4341</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"quantile"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"accuracy"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -45052,8 +45180,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#RangeN"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="RangeN-4339"><a href="#RangeN-4339"><span class="linenos">4339</span></a><span class="k">class</span> <span class="nc">RangeN</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="RangeN-4340"><a href="#RangeN-4340"><span class="linenos">4340</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"each"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="RangeN-4344"><a href="#RangeN-4344"><span class="linenos">4344</span></a><span class="k">class</span> <span class="nc">RangeN</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="RangeN-4345"><a href="#RangeN-4345"><span class="linenos">4345</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"each"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -45139,10 +45267,10 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#ReadCSV"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ReadCSV-4343"><a href="#ReadCSV-4343"><span class="linenos">4343</span></a><span class="k">class</span> <span class="nc">ReadCSV</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="ReadCSV-4344"><a href="#ReadCSV-4344"><span class="linenos">4344</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"READ_CSV"</span><span class="p">]</span> -</span><span id="ReadCSV-4345"><a href="#ReadCSV-4345"><span class="linenos">4345</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="ReadCSV-4346"><a href="#ReadCSV-4346"><span class="linenos">4346</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ReadCSV-4348"><a href="#ReadCSV-4348"><span class="linenos">4348</span></a><span class="k">class</span> <span class="nc">ReadCSV</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="ReadCSV-4349"><a href="#ReadCSV-4349"><span class="linenos">4349</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"READ_CSV"</span><span class="p">]</span> +</span><span id="ReadCSV-4350"><a href="#ReadCSV-4350"><span class="linenos">4350</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="ReadCSV-4351"><a href="#ReadCSV-4351"><span class="linenos">4351</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -45228,8 +45356,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Reduce"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Reduce-4349"><a href="#Reduce-4349"><span class="linenos">4349</span></a><span class="k">class</span> <span class="nc">Reduce</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Reduce-4350"><a href="#Reduce-4350"><span class="linenos">4350</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"initial"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"merge"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"finish"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Reduce-4354"><a href="#Reduce-4354"><span class="linenos">4354</span></a><span class="k">class</span> <span class="nc">Reduce</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Reduce-4355"><a href="#Reduce-4355"><span class="linenos">4355</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"initial"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"merge"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"finish"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -45315,14 +45443,14 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#RegexpExtract"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="RegexpExtract-4353"><a href="#RegexpExtract-4353"><span class="linenos">4353</span></a><span class="k">class</span> <span class="nc">RegexpExtract</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="RegexpExtract-4354"><a href="#RegexpExtract-4354"><span class="linenos">4354</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="RegexpExtract-4355"><a href="#RegexpExtract-4355"><span class="linenos">4355</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="RegexpExtract-4356"><a href="#RegexpExtract-4356"><span class="linenos">4356</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="RegexpExtract-4357"><a href="#RegexpExtract-4357"><span class="linenos">4357</span></a> <span class="s2">"position"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="RegexpExtract-4358"><a href="#RegexpExtract-4358"><span class="linenos">4358</span></a> <span class="s2">"occurrence"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="RegexpExtract-4359"><a href="#RegexpExtract-4359"><span class="linenos">4359</span></a> <span class="s2">"group"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="RegexpExtract-4360"><a href="#RegexpExtract-4360"><span class="linenos">4360</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="RegexpExtract-4358"><a href="#RegexpExtract-4358"><span class="linenos">4358</span></a><span class="k">class</span> <span class="nc">RegexpExtract</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="RegexpExtract-4359"><a href="#RegexpExtract-4359"><span class="linenos">4359</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="RegexpExtract-4360"><a href="#RegexpExtract-4360"><span class="linenos">4360</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="RegexpExtract-4361"><a href="#RegexpExtract-4361"><span class="linenos">4361</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="RegexpExtract-4362"><a href="#RegexpExtract-4362"><span class="linenos">4362</span></a> <span class="s2">"position"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="RegexpExtract-4363"><a href="#RegexpExtract-4363"><span class="linenos">4363</span></a> <span class="s2">"occurrence"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="RegexpExtract-4364"><a href="#RegexpExtract-4364"><span class="linenos">4364</span></a> <span class="s2">"group"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="RegexpExtract-4365"><a href="#RegexpExtract-4365"><span class="linenos">4365</span></a> <span class="p">}</span> </span></pre></div> @@ -45408,8 +45536,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#RegexpLike"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="RegexpLike-4363"><a href="#RegexpLike-4363"><span class="linenos">4363</span></a><span class="k">class</span> <span class="nc">RegexpLike</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="RegexpLike-4364"><a href="#RegexpLike-4364"><span class="linenos">4364</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"flag"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="RegexpLike-4368"><a href="#RegexpLike-4368"><span class="linenos">4368</span></a><span class="k">class</span> <span class="nc">RegexpLike</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="RegexpLike-4369"><a href="#RegexpLike-4369"><span class="linenos">4369</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"flag"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -45495,8 +45623,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#RegexpILike"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="RegexpILike-4367"><a href="#RegexpILike-4367"><span class="linenos">4367</span></a><span class="k">class</span> <span class="nc">RegexpILike</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="RegexpILike-4368"><a href="#RegexpILike-4368"><span class="linenos">4368</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"flag"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="RegexpILike-4372"><a href="#RegexpILike-4372"><span class="linenos">4372</span></a><span class="k">class</span> <span class="nc">RegexpILike</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="RegexpILike-4373"><a href="#RegexpILike-4373"><span class="linenos">4373</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"flag"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -45582,8 +45710,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#RegexpSplit"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="RegexpSplit-4373"><a href="#RegexpSplit-4373"><span class="linenos">4373</span></a><span class="k">class</span> <span class="nc">RegexpSplit</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="RegexpSplit-4374"><a href="#RegexpSplit-4374"><span class="linenos">4374</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="RegexpSplit-4378"><a href="#RegexpSplit-4378"><span class="linenos">4378</span></a><span class="k">class</span> <span class="nc">RegexpSplit</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="RegexpSplit-4379"><a href="#RegexpSplit-4379"><span class="linenos">4379</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -45669,8 +45797,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Repeat"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Repeat-4377"><a href="#Repeat-4377"><span class="linenos">4377</span></a><span class="k">class</span> <span class="nc">Repeat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Repeat-4378"><a href="#Repeat-4378"><span class="linenos">4378</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"times"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Repeat-4382"><a href="#Repeat-4382"><span class="linenos">4382</span></a><span class="k">class</span> <span class="nc">Repeat</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Repeat-4383"><a href="#Repeat-4383"><span class="linenos">4383</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"times"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -45756,8 +45884,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Round"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Round-4381"><a href="#Round-4381"><span class="linenos">4381</span></a><span class="k">class</span> <span class="nc">Round</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Round-4382"><a href="#Round-4382"><span class="linenos">4382</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"decimals"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Round-4386"><a href="#Round-4386"><span class="linenos">4386</span></a><span class="k">class</span> <span class="nc">Round</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Round-4387"><a href="#Round-4387"><span class="linenos">4387</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"decimals"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -45843,8 +45971,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#RowNumber"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="RowNumber-4385"><a href="#RowNumber-4385"><span class="linenos">4385</span></a><span class="k">class</span> <span class="nc">RowNumber</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="RowNumber-4386"><a href="#RowNumber-4386"><span class="linenos">4386</span></a> <span class="n">arg_types</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="RowNumber-4390"><a href="#RowNumber-4390"><span class="linenos">4390</span></a><span class="k">class</span> <span class="nc">RowNumber</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="RowNumber-4391"><a href="#RowNumber-4391"><span class="linenos">4391</span></a> <span class="n">arg_types</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> </span></pre></div> @@ -45930,8 +46058,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#SafeDivide"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SafeDivide-4389"><a href="#SafeDivide-4389"><span class="linenos">4389</span></a><span class="k">class</span> <span class="nc">SafeDivide</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="SafeDivide-4390"><a href="#SafeDivide-4390"><span class="linenos">4390</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SafeDivide-4394"><a href="#SafeDivide-4394"><span class="linenos">4394</span></a><span class="k">class</span> <span class="nc">SafeDivide</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="SafeDivide-4395"><a href="#SafeDivide-4395"><span class="linenos">4395</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -46017,8 +46145,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#SetAgg"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SetAgg-4393"><a href="#SetAgg-4393"><span class="linenos">4393</span></a><span class="k">class</span> <span class="nc">SetAgg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="SetAgg-4394"><a href="#SetAgg-4394"><span class="linenos">4394</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SetAgg-4398"><a href="#SetAgg-4398"><span class="linenos">4398</span></a><span class="k">class</span> <span class="nc">SetAgg</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="SetAgg-4399"><a href="#SetAgg-4399"><span class="linenos">4399</span></a> <span class="k">pass</span> </span></pre></div> @@ -46104,8 +46232,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#SHA"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SHA-4397"><a href="#SHA-4397"><span class="linenos">4397</span></a><span class="k">class</span> <span class="nc">SHA</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="SHA-4398"><a href="#SHA-4398"><span class="linenos">4398</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"SHA"</span><span class="p">,</span> <span class="s2">"SHA1"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SHA-4402"><a href="#SHA-4402"><span class="linenos">4402</span></a><span class="k">class</span> <span class="nc">SHA</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="SHA-4403"><a href="#SHA-4403"><span class="linenos">4403</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"SHA"</span><span class="p">,</span> <span class="s2">"SHA1"</span><span class="p">]</span> </span></pre></div> @@ -46191,9 +46319,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#SHA2"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SHA2-4401"><a href="#SHA2-4401"><span class="linenos">4401</span></a><span class="k">class</span> <span class="nc">SHA2</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="SHA2-4402"><a href="#SHA2-4402"><span class="linenos">4402</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"SHA2"</span><span class="p">]</span> -</span><span id="SHA2-4403"><a href="#SHA2-4403"><span class="linenos">4403</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"length"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SHA2-4406"><a href="#SHA2-4406"><span class="linenos">4406</span></a><span class="k">class</span> <span class="nc">SHA2</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="SHA2-4407"><a href="#SHA2-4407"><span class="linenos">4407</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"SHA2"</span><span class="p">]</span> +</span><span id="SHA2-4408"><a href="#SHA2-4408"><span class="linenos">4408</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"length"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -46279,8 +46407,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#SortArray"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="SortArray-4406"><a href="#SortArray-4406"><span class="linenos">4406</span></a><span class="k">class</span> <span class="nc">SortArray</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="SortArray-4407"><a href="#SortArray-4407"><span class="linenos">4407</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"asc"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="SortArray-4411"><a href="#SortArray-4411"><span class="linenos">4411</span></a><span class="k">class</span> <span class="nc">SortArray</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="SortArray-4412"><a href="#SortArray-4412"><span class="linenos">4412</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"asc"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -46366,8 +46494,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Split"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Split-4410"><a href="#Split-4410"><span class="linenos">4410</span></a><span class="k">class</span> <span class="nc">Split</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Split-4411"><a href="#Split-4411"><span class="linenos">4411</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Split-4415"><a href="#Split-4415"><span class="linenos">4415</span></a><span class="k">class</span> <span class="nc">Split</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Split-4416"><a href="#Split-4416"><span class="linenos">4416</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"limit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -46453,8 +46581,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Substring"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Substring-4416"><a href="#Substring-4416"><span class="linenos">4416</span></a><span class="k">class</span> <span class="nc">Substring</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Substring-4417"><a href="#Substring-4417"><span class="linenos">4417</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"length"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Substring-4421"><a href="#Substring-4421"><span class="linenos">4421</span></a><span class="k">class</span> <span class="nc">Substring</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Substring-4422"><a href="#Substring-4422"><span class="linenos">4422</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"length"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -46540,8 +46668,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#StandardHash"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="StandardHash-4420"><a href="#StandardHash-4420"><span class="linenos">4420</span></a><span class="k">class</span> <span class="nc">StandardHash</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="StandardHash-4421"><a href="#StandardHash-4421"><span class="linenos">4421</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="StandardHash-4425"><a href="#StandardHash-4425"><span class="linenos">4425</span></a><span class="k">class</span> <span class="nc">StandardHash</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="StandardHash-4426"><a href="#StandardHash-4426"><span class="linenos">4426</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -46627,13 +46755,13 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#StrPosition"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="StrPosition-4424"><a href="#StrPosition-4424"><span class="linenos">4424</span></a><span class="k">class</span> <span class="nc">StrPosition</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="StrPosition-4425"><a href="#StrPosition-4425"><span class="linenos">4425</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="StrPosition-4426"><a href="#StrPosition-4426"><span class="linenos">4426</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="StrPosition-4427"><a href="#StrPosition-4427"><span class="linenos">4427</span></a> <span class="s2">"substr"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="StrPosition-4428"><a href="#StrPosition-4428"><span class="linenos">4428</span></a> <span class="s2">"position"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="StrPosition-4429"><a href="#StrPosition-4429"><span class="linenos">4429</span></a> <span class="s2">"instance"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="StrPosition-4430"><a href="#StrPosition-4430"><span class="linenos">4430</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="StrPosition-4429"><a href="#StrPosition-4429"><span class="linenos">4429</span></a><span class="k">class</span> <span class="nc">StrPosition</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="StrPosition-4430"><a href="#StrPosition-4430"><span class="linenos">4430</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="StrPosition-4431"><a href="#StrPosition-4431"><span class="linenos">4431</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="StrPosition-4432"><a href="#StrPosition-4432"><span class="linenos">4432</span></a> <span class="s2">"substr"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="StrPosition-4433"><a href="#StrPosition-4433"><span class="linenos">4433</span></a> <span class="s2">"position"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="StrPosition-4434"><a href="#StrPosition-4434"><span class="linenos">4434</span></a> <span class="s2">"instance"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="StrPosition-4435"><a href="#StrPosition-4435"><span class="linenos">4435</span></a> <span class="p">}</span> </span></pre></div> @@ -46719,8 +46847,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#StrToDate"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="StrToDate-4433"><a href="#StrToDate-4433"><span class="linenos">4433</span></a><span class="k">class</span> <span class="nc">StrToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="StrToDate-4434"><a href="#StrToDate-4434"><span class="linenos">4434</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="StrToDate-4438"><a href="#StrToDate-4438"><span class="linenos">4438</span></a><span class="k">class</span> <span class="nc">StrToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="StrToDate-4439"><a href="#StrToDate-4439"><span class="linenos">4439</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -46806,8 +46934,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#StrToTime"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="StrToTime-4437"><a href="#StrToTime-4437"><span class="linenos">4437</span></a><span class="k">class</span> <span class="nc">StrToTime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="StrToTime-4438"><a href="#StrToTime-4438"><span class="linenos">4438</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="StrToTime-4442"><a href="#StrToTime-4442"><span class="linenos">4442</span></a><span class="k">class</span> <span class="nc">StrToTime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="StrToTime-4443"><a href="#StrToTime-4443"><span class="linenos">4443</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -46893,8 +47021,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#StrToUnix"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="StrToUnix-4443"><a href="#StrToUnix-4443"><span class="linenos">4443</span></a><span class="k">class</span> <span class="nc">StrToUnix</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="StrToUnix-4444"><a href="#StrToUnix-4444"><span class="linenos">4444</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="StrToUnix-4448"><a href="#StrToUnix-4448"><span class="linenos">4448</span></a><span class="k">class</span> <span class="nc">StrToUnix</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="StrToUnix-4449"><a href="#StrToUnix-4449"><span class="linenos">4449</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -46980,8 +47108,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#NumberToStr"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="NumberToStr-4447"><a href="#NumberToStr-4447"><span class="linenos">4447</span></a><span class="k">class</span> <span class="nc">NumberToStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="NumberToStr-4448"><a href="#NumberToStr-4448"><span class="linenos">4448</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="NumberToStr-4452"><a href="#NumberToStr-4452"><span class="linenos">4452</span></a><span class="k">class</span> <span class="nc">NumberToStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="NumberToStr-4453"><a href="#NumberToStr-4453"><span class="linenos">4453</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -47067,8 +47195,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#FromBase"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="FromBase-4451"><a href="#FromBase-4451"><span class="linenos">4451</span></a><span class="k">class</span> <span class="nc">FromBase</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="FromBase-4452"><a href="#FromBase-4452"><span class="linenos">4452</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="FromBase-4456"><a href="#FromBase-4456"><span class="linenos">4456</span></a><span class="k">class</span> <span class="nc">FromBase</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="FromBase-4457"><a href="#FromBase-4457"><span class="linenos">4457</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -47154,9 +47282,9 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Struct"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Struct-4455"><a href="#Struct-4455"><span class="linenos">4455</span></a><span class="k">class</span> <span class="nc">Struct</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Struct-4456"><a href="#Struct-4456"><span class="linenos">4456</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> -</span><span id="Struct-4457"><a href="#Struct-4457"><span class="linenos">4457</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Struct-4460"><a href="#Struct-4460"><span class="linenos">4460</span></a><span class="k">class</span> <span class="nc">Struct</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Struct-4461"><a href="#Struct-4461"><span class="linenos">4461</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> +</span><span id="Struct-4462"><a href="#Struct-4462"><span class="linenos">4462</span></a> <span class="n">is_var_len_args</span> <span class="o">=</span> <span class="kc">True</span> </span></pre></div> @@ -47242,8 +47370,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#StructExtract"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="StructExtract-4460"><a href="#StructExtract-4460"><span class="linenos">4460</span></a><span class="k">class</span> <span class="nc">StructExtract</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="StructExtract-4461"><a href="#StructExtract-4461"><span class="linenos">4461</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="StructExtract-4465"><a href="#StructExtract-4465"><span class="linenos">4465</span></a><span class="k">class</span> <span class="nc">StructExtract</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="StructExtract-4466"><a href="#StructExtract-4466"><span class="linenos">4466</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -47329,8 +47457,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Sum"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Sum-4464"><a href="#Sum-4464"><span class="linenos">4464</span></a><span class="k">class</span> <span class="nc">Sum</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="Sum-4465"><a href="#Sum-4465"><span class="linenos">4465</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Sum-4469"><a href="#Sum-4469"><span class="linenos">4469</span></a><span class="k">class</span> <span class="nc">Sum</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="Sum-4470"><a href="#Sum-4470"><span class="linenos">4470</span></a> <span class="k">pass</span> </span></pre></div> @@ -47416,8 +47544,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Sqrt"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Sqrt-4468"><a href="#Sqrt-4468"><span class="linenos">4468</span></a><span class="k">class</span> <span class="nc">Sqrt</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Sqrt-4469"><a href="#Sqrt-4469"><span class="linenos">4469</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Sqrt-4473"><a href="#Sqrt-4473"><span class="linenos">4473</span></a><span class="k">class</span> <span class="nc">Sqrt</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Sqrt-4474"><a href="#Sqrt-4474"><span class="linenos">4474</span></a> <span class="k">pass</span> </span></pre></div> @@ -47503,8 +47631,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Stddev"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Stddev-4472"><a href="#Stddev-4472"><span class="linenos">4472</span></a><span class="k">class</span> <span class="nc">Stddev</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="Stddev-4473"><a href="#Stddev-4473"><span class="linenos">4473</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Stddev-4477"><a href="#Stddev-4477"><span class="linenos">4477</span></a><span class="k">class</span> <span class="nc">Stddev</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="Stddev-4478"><a href="#Stddev-4478"><span class="linenos">4478</span></a> <span class="k">pass</span> </span></pre></div> @@ -47590,8 +47718,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#StddevPop"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="StddevPop-4476"><a href="#StddevPop-4476"><span class="linenos">4476</span></a><span class="k">class</span> <span class="nc">StddevPop</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="StddevPop-4477"><a href="#StddevPop-4477"><span class="linenos">4477</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="StddevPop-4481"><a href="#StddevPop-4481"><span class="linenos">4481</span></a><span class="k">class</span> <span class="nc">StddevPop</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="StddevPop-4482"><a href="#StddevPop-4482"><span class="linenos">4482</span></a> <span class="k">pass</span> </span></pre></div> @@ -47677,8 +47805,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#StddevSamp"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="StddevSamp-4480"><a href="#StddevSamp-4480"><span class="linenos">4480</span></a><span class="k">class</span> <span class="nc">StddevSamp</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="StddevSamp-4481"><a href="#StddevSamp-4481"><span class="linenos">4481</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="StddevSamp-4485"><a href="#StddevSamp-4485"><span class="linenos">4485</span></a><span class="k">class</span> <span class="nc">StddevSamp</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="StddevSamp-4486"><a href="#StddevSamp-4486"><span class="linenos">4486</span></a> <span class="k">pass</span> </span></pre></div> @@ -47764,8 +47892,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#TimeToStr"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TimeToStr-4484"><a href="#TimeToStr-4484"><span class="linenos">4484</span></a><span class="k">class</span> <span class="nc">TimeToStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="TimeToStr-4485"><a href="#TimeToStr-4485"><span class="linenos">4485</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TimeToStr-4489"><a href="#TimeToStr-4489"><span class="linenos">4489</span></a><span class="k">class</span> <span class="nc">TimeToStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="TimeToStr-4490"><a href="#TimeToStr-4490"><span class="linenos">4490</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -47851,8 +47979,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#TimeToTimeStr"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TimeToTimeStr-4488"><a href="#TimeToTimeStr-4488"><span class="linenos">4488</span></a><span class="k">class</span> <span class="nc">TimeToTimeStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="TimeToTimeStr-4489"><a href="#TimeToTimeStr-4489"><span class="linenos">4489</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TimeToTimeStr-4493"><a href="#TimeToTimeStr-4493"><span class="linenos">4493</span></a><span class="k">class</span> <span class="nc">TimeToTimeStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="TimeToTimeStr-4494"><a href="#TimeToTimeStr-4494"><span class="linenos">4494</span></a> <span class="k">pass</span> </span></pre></div> @@ -47938,8 +48066,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#TimeToUnix"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TimeToUnix-4492"><a href="#TimeToUnix-4492"><span class="linenos">4492</span></a><span class="k">class</span> <span class="nc">TimeToUnix</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="TimeToUnix-4493"><a href="#TimeToUnix-4493"><span class="linenos">4493</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TimeToUnix-4497"><a href="#TimeToUnix-4497"><span class="linenos">4497</span></a><span class="k">class</span> <span class="nc">TimeToUnix</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="TimeToUnix-4498"><a href="#TimeToUnix-4498"><span class="linenos">4498</span></a> <span class="k">pass</span> </span></pre></div> @@ -48025,8 +48153,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#TimeStrToDate"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TimeStrToDate-4496"><a href="#TimeStrToDate-4496"><span class="linenos">4496</span></a><span class="k">class</span> <span class="nc">TimeStrToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="TimeStrToDate-4497"><a href="#TimeStrToDate-4497"><span class="linenos">4497</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TimeStrToDate-4501"><a href="#TimeStrToDate-4501"><span class="linenos">4501</span></a><span class="k">class</span> <span class="nc">TimeStrToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="TimeStrToDate-4502"><a href="#TimeStrToDate-4502"><span class="linenos">4502</span></a> <span class="k">pass</span> </span></pre></div> @@ -48112,8 +48240,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#TimeStrToTime"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TimeStrToTime-4500"><a href="#TimeStrToTime-4500"><span class="linenos">4500</span></a><span class="k">class</span> <span class="nc">TimeStrToTime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="TimeStrToTime-4501"><a href="#TimeStrToTime-4501"><span class="linenos">4501</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TimeStrToTime-4505"><a href="#TimeStrToTime-4505"><span class="linenos">4505</span></a><span class="k">class</span> <span class="nc">TimeStrToTime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="TimeStrToTime-4506"><a href="#TimeStrToTime-4506"><span class="linenos">4506</span></a> <span class="k">pass</span> </span></pre></div> @@ -48199,8 +48327,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#TimeStrToUnix"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TimeStrToUnix-4504"><a href="#TimeStrToUnix-4504"><span class="linenos">4504</span></a><span class="k">class</span> <span class="nc">TimeStrToUnix</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="TimeStrToUnix-4505"><a href="#TimeStrToUnix-4505"><span class="linenos">4505</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TimeStrToUnix-4509"><a href="#TimeStrToUnix-4509"><span class="linenos">4509</span></a><span class="k">class</span> <span class="nc">TimeStrToUnix</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="TimeStrToUnix-4510"><a href="#TimeStrToUnix-4510"><span class="linenos">4510</span></a> <span class="k">pass</span> </span></pre></div> @@ -48286,13 +48414,13 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Trim"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Trim-4508"><a href="#Trim-4508"><span class="linenos">4508</span></a><span class="k">class</span> <span class="nc">Trim</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Trim-4509"><a href="#Trim-4509"><span class="linenos">4509</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Trim-4510"><a href="#Trim-4510"><span class="linenos">4510</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Trim-4511"><a href="#Trim-4511"><span class="linenos">4511</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Trim-4512"><a href="#Trim-4512"><span class="linenos">4512</span></a> <span class="s2">"position"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Trim-4513"><a href="#Trim-4513"><span class="linenos">4513</span></a> <span class="s2">"collation"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Trim-4514"><a href="#Trim-4514"><span class="linenos">4514</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Trim-4513"><a href="#Trim-4513"><span class="linenos">4513</span></a><span class="k">class</span> <span class="nc">Trim</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Trim-4514"><a href="#Trim-4514"><span class="linenos">4514</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Trim-4515"><a href="#Trim-4515"><span class="linenos">4515</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Trim-4516"><a href="#Trim-4516"><span class="linenos">4516</span></a> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Trim-4517"><a href="#Trim-4517"><span class="linenos">4517</span></a> <span class="s2">"position"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Trim-4518"><a href="#Trim-4518"><span class="linenos">4518</span></a> <span class="s2">"collation"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Trim-4519"><a href="#Trim-4519"><span class="linenos">4519</span></a> <span class="p">}</span> </span></pre></div> @@ -48378,8 +48506,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#TsOrDsAdd"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TsOrDsAdd-4517"><a href="#TsOrDsAdd-4517"><span class="linenos">4517</span></a><span class="k">class</span> <span class="nc">TsOrDsAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> -</span><span id="TsOrDsAdd-4518"><a href="#TsOrDsAdd-4518"><span class="linenos">4518</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TsOrDsAdd-4522"><a href="#TsOrDsAdd-4522"><span class="linenos">4522</span></a><span class="k">class</span> <span class="nc">TsOrDsAdd</span><span class="p">(</span><span class="n">Func</span><span class="p">,</span> <span class="n">TimeUnit</span><span class="p">):</span> +</span><span id="TsOrDsAdd-4523"><a href="#TsOrDsAdd-4523"><span class="linenos">4523</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -48468,8 +48596,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#TsOrDsToDateStr"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TsOrDsToDateStr-4521"><a href="#TsOrDsToDateStr-4521"><span class="linenos">4521</span></a><span class="k">class</span> <span class="nc">TsOrDsToDateStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="TsOrDsToDateStr-4522"><a href="#TsOrDsToDateStr-4522"><span class="linenos">4522</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TsOrDsToDateStr-4526"><a href="#TsOrDsToDateStr-4526"><span class="linenos">4526</span></a><span class="k">class</span> <span class="nc">TsOrDsToDateStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="TsOrDsToDateStr-4527"><a href="#TsOrDsToDateStr-4527"><span class="linenos">4527</span></a> <span class="k">pass</span> </span></pre></div> @@ -48555,8 +48683,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#TsOrDsToDate"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TsOrDsToDate-4525"><a href="#TsOrDsToDate-4525"><span class="linenos">4525</span></a><span class="k">class</span> <span class="nc">TsOrDsToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="TsOrDsToDate-4526"><a href="#TsOrDsToDate-4526"><span class="linenos">4526</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TsOrDsToDate-4530"><a href="#TsOrDsToDate-4530"><span class="linenos">4530</span></a><span class="k">class</span> <span class="nc">TsOrDsToDate</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="TsOrDsToDate-4531"><a href="#TsOrDsToDate-4531"><span class="linenos">4531</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -48642,8 +48770,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#TsOrDiToDi"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="TsOrDiToDi-4529"><a href="#TsOrDiToDi-4529"><span class="linenos">4529</span></a><span class="k">class</span> <span class="nc">TsOrDiToDi</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="TsOrDiToDi-4530"><a href="#TsOrDiToDi-4530"><span class="linenos">4530</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="TsOrDiToDi-4534"><a href="#TsOrDiToDi-4534"><span class="linenos">4534</span></a><span class="k">class</span> <span class="nc">TsOrDiToDi</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="TsOrDiToDi-4535"><a href="#TsOrDiToDi-4535"><span class="linenos">4535</span></a> <span class="k">pass</span> </span></pre></div> @@ -48729,8 +48857,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Unhex"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Unhex-4533"><a href="#Unhex-4533"><span class="linenos">4533</span></a><span class="k">class</span> <span class="nc">Unhex</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Unhex-4534"><a href="#Unhex-4534"><span class="linenos">4534</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Unhex-4538"><a href="#Unhex-4538"><span class="linenos">4538</span></a><span class="k">class</span> <span class="nc">Unhex</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Unhex-4539"><a href="#Unhex-4539"><span class="linenos">4539</span></a> <span class="k">pass</span> </span></pre></div> @@ -48816,8 +48944,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#UnixToStr"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="UnixToStr-4537"><a href="#UnixToStr-4537"><span class="linenos">4537</span></a><span class="k">class</span> <span class="nc">UnixToStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="UnixToStr-4538"><a href="#UnixToStr-4538"><span class="linenos">4538</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="UnixToStr-4542"><a href="#UnixToStr-4542"><span class="linenos">4542</span></a><span class="k">class</span> <span class="nc">UnixToStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="UnixToStr-4543"><a href="#UnixToStr-4543"><span class="linenos">4543</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -48903,12 +49031,12 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#UnixToTime"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="UnixToTime-4543"><a href="#UnixToTime-4543"><span class="linenos">4543</span></a><span class="k">class</span> <span class="nc">UnixToTime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="UnixToTime-4544"><a href="#UnixToTime-4544"><span class="linenos">4544</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"scale"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"hours"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"minutes"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> -</span><span id="UnixToTime-4545"><a href="#UnixToTime-4545"><span class="linenos">4545</span></a> -</span><span id="UnixToTime-4546"><a href="#UnixToTime-4546"><span class="linenos">4546</span></a> <span class="n">SECONDS</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">"seconds"</span><span class="p">)</span> -</span><span id="UnixToTime-4547"><a href="#UnixToTime-4547"><span class="linenos">4547</span></a> <span class="n">MILLIS</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">"millis"</span><span class="p">)</span> -</span><span id="UnixToTime-4548"><a href="#UnixToTime-4548"><span class="linenos">4548</span></a> <span class="n">MICROS</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">"micros"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="UnixToTime-4548"><a href="#UnixToTime-4548"><span class="linenos">4548</span></a><span class="k">class</span> <span class="nc">UnixToTime</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="UnixToTime-4549"><a href="#UnixToTime-4549"><span class="linenos">4549</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"scale"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"hours"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"minutes"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> +</span><span id="UnixToTime-4550"><a href="#UnixToTime-4550"><span class="linenos">4550</span></a> +</span><span id="UnixToTime-4551"><a href="#UnixToTime-4551"><span class="linenos">4551</span></a> <span class="n">SECONDS</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">"seconds"</span><span class="p">)</span> +</span><span id="UnixToTime-4552"><a href="#UnixToTime-4552"><span class="linenos">4552</span></a> <span class="n">MILLIS</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">"millis"</span><span class="p">)</span> +</span><span id="UnixToTime-4553"><a href="#UnixToTime-4553"><span class="linenos">4553</span></a> <span class="n">MICROS</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">"micros"</span><span class="p">)</span> </span></pre></div> @@ -48994,8 +49122,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#UnixToTimeStr"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="UnixToTimeStr-4551"><a href="#UnixToTimeStr-4551"><span class="linenos">4551</span></a><span class="k">class</span> <span class="nc">UnixToTimeStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="UnixToTimeStr-4552"><a href="#UnixToTimeStr-4552"><span class="linenos">4552</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="UnixToTimeStr-4556"><a href="#UnixToTimeStr-4556"><span class="linenos">4556</span></a><span class="k">class</span> <span class="nc">UnixToTimeStr</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="UnixToTimeStr-4557"><a href="#UnixToTimeStr-4557"><span class="linenos">4557</span></a> <span class="k">pass</span> </span></pre></div> @@ -49081,8 +49209,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Upper"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Upper-4555"><a href="#Upper-4555"><span class="linenos">4555</span></a><span class="k">class</span> <span class="nc">Upper</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Upper-4556"><a href="#Upper-4556"><span class="linenos">4556</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"UPPER"</span><span class="p">,</span> <span class="s2">"UCASE"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Upper-4560"><a href="#Upper-4560"><span class="linenos">4560</span></a><span class="k">class</span> <span class="nc">Upper</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Upper-4561"><a href="#Upper-4561"><span class="linenos">4561</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"UPPER"</span><span class="p">,</span> <span class="s2">"UCASE"</span><span class="p">]</span> </span></pre></div> @@ -49168,8 +49296,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Variance"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Variance-4559"><a href="#Variance-4559"><span class="linenos">4559</span></a><span class="k">class</span> <span class="nc">Variance</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="Variance-4560"><a href="#Variance-4560"><span class="linenos">4560</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"VARIANCE"</span><span class="p">,</span> <span class="s2">"VARIANCE_SAMP"</span><span class="p">,</span> <span class="s2">"VAR_SAMP"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Variance-4564"><a href="#Variance-4564"><span class="linenos">4564</span></a><span class="k">class</span> <span class="nc">Variance</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="Variance-4565"><a href="#Variance-4565"><span class="linenos">4565</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"VARIANCE"</span><span class="p">,</span> <span class="s2">"VARIANCE_SAMP"</span><span class="p">,</span> <span class="s2">"VAR_SAMP"</span><span class="p">]</span> </span></pre></div> @@ -49255,8 +49383,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#VariancePop"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="VariancePop-4563"><a href="#VariancePop-4563"><span class="linenos">4563</span></a><span class="k">class</span> <span class="nc">VariancePop</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> -</span><span id="VariancePop-4564"><a href="#VariancePop-4564"><span class="linenos">4564</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"VARIANCE_POP"</span><span class="p">,</span> <span class="s2">"VAR_POP"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="VariancePop-4568"><a href="#VariancePop-4568"><span class="linenos">4568</span></a><span class="k">class</span> <span class="nc">VariancePop</span><span class="p">(</span><span class="n">AggFunc</span><span class="p">):</span> +</span><span id="VariancePop-4569"><a href="#VariancePop-4569"><span class="linenos">4569</span></a> <span class="n">_sql_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"VARIANCE_POP"</span><span class="p">,</span> <span class="s2">"VAR_POP"</span><span class="p">]</span> </span></pre></div> @@ -49342,8 +49470,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Week"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Week-4567"><a href="#Week-4567"><span class="linenos">4567</span></a><span class="k">class</span> <span class="nc">Week</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Week-4568"><a href="#Week-4568"><span class="linenos">4568</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"mode"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Week-4572"><a href="#Week-4572"><span class="linenos">4572</span></a><span class="k">class</span> <span class="nc">Week</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Week-4573"><a href="#Week-4573"><span class="linenos">4573</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"mode"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -49429,8 +49557,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#XMLTable"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="XMLTable-4571"><a href="#XMLTable-4571"><span class="linenos">4571</span></a><span class="k">class</span> <span class="nc">XMLTable</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="XMLTable-4572"><a href="#XMLTable-4572"><span class="linenos">4572</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"passing"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"columns"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"by_ref"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="XMLTable-4576"><a href="#XMLTable-4576"><span class="linenos">4576</span></a><span class="k">class</span> <span class="nc">XMLTable</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="XMLTable-4577"><a href="#XMLTable-4577"><span class="linenos">4577</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"passing"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"columns"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"by_ref"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -49516,8 +49644,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Year"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Year-4575"><a href="#Year-4575"><span class="linenos">4575</span></a><span class="k">class</span> <span class="nc">Year</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Year-4576"><a href="#Year-4576"><span class="linenos">4576</span></a> <span class="k">pass</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Year-4580"><a href="#Year-4580"><span class="linenos">4580</span></a><span class="k">class</span> <span class="nc">Year</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Year-4581"><a href="#Year-4581"><span class="linenos">4581</span></a> <span class="k">pass</span> </span></pre></div> @@ -49603,8 +49731,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Use"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Use-4579"><a href="#Use-4579"><span class="linenos">4579</span></a><span class="k">class</span> <span class="nc">Use</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Use-4580"><a href="#Use-4580"><span class="linenos">4580</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Use-4584"><a href="#Use-4584"><span class="linenos">4584</span></a><span class="k">class</span> <span class="nc">Use</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Use-4585"><a href="#Use-4585"><span class="linenos">4585</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -49668,8 +49796,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#Merge"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Merge-4583"><a href="#Merge-4583"><span class="linenos">4583</span></a><span class="k">class</span> <span class="nc">Merge</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Merge-4584"><a href="#Merge-4584"><span class="linenos">4584</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Merge-4588"><a href="#Merge-4588"><span class="linenos">4588</span></a><span class="k">class</span> <span class="nc">Merge</span><span class="p">(</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Merge-4589"><a href="#Merge-4589"><span class="linenos">4589</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"expressions"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -49733,8 +49861,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#When"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="When-4587"><a href="#When-4587"><span class="linenos">4587</span></a><span class="k">class</span> <span class="nc">When</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="When-4588"><a href="#When-4588"><span class="linenos">4588</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"matched"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"source"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"then"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="When-4592"><a href="#When-4592"><span class="linenos">4592</span></a><span class="k">class</span> <span class="nc">When</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="When-4593"><a href="#When-4593"><span class="linenos">4593</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"matched"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"source"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">"then"</span><span class="p">:</span> <span class="kc">True</span><span class="p">}</span> </span></pre></div> @@ -49820,8 +49948,8 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#NextValueFor"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="NextValueFor-4593"><a href="#NextValueFor-4593"><span class="linenos">4593</span></a><span class="k">class</span> <span class="nc">NextValueFor</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> -</span><span id="NextValueFor-4594"><a href="#NextValueFor-4594"><span class="linenos">4594</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="NextValueFor-4598"><a href="#NextValueFor-4598"><span class="linenos">4598</span></a><span class="k">class</span> <span class="nc">NextValueFor</span><span class="p">(</span><span class="n">Func</span><span class="p">):</span> +</span><span id="NextValueFor-4599"><a href="#NextValueFor-4599"><span class="linenos">4599</span></a> <span class="n">arg_types</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> </span></pre></div> @@ -49907,52 +50035,52 @@ name is set to the expression's class name transformed to snake case.</li> </div> <a class="headerlink" href="#maybe_parse"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="maybe_parse-4631"><a href="#maybe_parse-4631"><span class="linenos">4631</span></a><span class="k">def</span> <span class="nf">maybe_parse</span><span class="p">(</span> -</span><span id="maybe_parse-4632"><a href="#maybe_parse-4632"><span class="linenos">4632</span></a> <span class="n">sql_or_expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="maybe_parse-4633"><a href="#maybe_parse-4633"><span class="linenos">4633</span></a> <span class="o">*</span><span class="p">,</span> -</span><span id="maybe_parse-4634"><a href="#maybe_parse-4634"><span class="linenos">4634</span></a> <span class="n">into</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">IntoType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="maybe_parse-4635"><a href="#maybe_parse-4635"><span class="linenos">4635</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="maybe_parse-4636"><a href="#maybe_parse-4636"><span class="linenos">4636</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="maybe_parse-4637"><a href="#maybe_parse-4637"><span class="linenos">4637</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="maybe_parse-4638"><a href="#maybe_parse-4638"><span class="linenos">4638</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="maybe_parse-4639"><a href="#maybe_parse-4639"><span class="linenos">4639</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> -</span><span id="maybe_parse-4640"><a href="#maybe_parse-4640"><span class="linenos">4640</span></a><span class="w"> </span><span class="sd">"""Gracefully handle a possible string or expression.</span> -</span><span id="maybe_parse-4641"><a href="#maybe_parse-4641"><span class="linenos">4641</span></a> -</span><span id="maybe_parse-4642"><a href="#maybe_parse-4642"><span class="linenos">4642</span></a><span class="sd"> Example:</span> -</span><span id="maybe_parse-4643"><a href="#maybe_parse-4643"><span class="linenos">4643</span></a><span class="sd"> >>> maybe_parse("1")</span> -</span><span id="maybe_parse-4644"><a href="#maybe_parse-4644"><span class="linenos">4644</span></a><span class="sd"> (LITERAL this: 1, is_string: False)</span> -</span><span id="maybe_parse-4645"><a href="#maybe_parse-4645"><span class="linenos">4645</span></a><span class="sd"> >>> maybe_parse(to_identifier("x"))</span> -</span><span id="maybe_parse-4646"><a href="#maybe_parse-4646"><span class="linenos">4646</span></a><span class="sd"> (IDENTIFIER this: x, quoted: False)</span> -</span><span id="maybe_parse-4647"><a href="#maybe_parse-4647"><span class="linenos">4647</span></a> -</span><span id="maybe_parse-4648"><a href="#maybe_parse-4648"><span class="linenos">4648</span></a><span class="sd"> Args:</span> -</span><span id="maybe_parse-4649"><a href="#maybe_parse-4649"><span class="linenos">4649</span></a><span class="sd"> sql_or_expression: the SQL code string or an expression</span> -</span><span id="maybe_parse-4650"><a href="#maybe_parse-4650"><span class="linenos">4650</span></a><span class="sd"> into: the SQLGlot Expression to parse into</span> -</span><span id="maybe_parse-4651"><a href="#maybe_parse-4651"><span class="linenos">4651</span></a><span class="sd"> dialect: the dialect used to parse the input expressions (in the case that an</span> -</span><span id="maybe_parse-4652"><a href="#maybe_parse-4652"><span class="linenos">4652</span></a><span class="sd"> input expression is a SQL string).</span> -</span><span id="maybe_parse-4653"><a href="#maybe_parse-4653"><span class="linenos">4653</span></a><span class="sd"> prefix: a string to prefix the sql with before it gets parsed</span> -</span><span id="maybe_parse-4654"><a href="#maybe_parse-4654"><span class="linenos">4654</span></a><span class="sd"> (automatically includes a space)</span> -</span><span id="maybe_parse-4655"><a href="#maybe_parse-4655"><span class="linenos">4655</span></a><span class="sd"> copy: whether or not to copy the expression.</span> -</span><span id="maybe_parse-4656"><a href="#maybe_parse-4656"><span class="linenos">4656</span></a><span class="sd"> **opts: other options to use to parse the input expressions (again, in the case</span> -</span><span id="maybe_parse-4657"><a href="#maybe_parse-4657"><span class="linenos">4657</span></a><span class="sd"> that an input expression is a SQL string).</span> -</span><span id="maybe_parse-4658"><a href="#maybe_parse-4658"><span class="linenos">4658</span></a> -</span><span id="maybe_parse-4659"><a href="#maybe_parse-4659"><span class="linenos">4659</span></a><span class="sd"> Returns:</span> -</span><span id="maybe_parse-4660"><a href="#maybe_parse-4660"><span class="linenos">4660</span></a><span class="sd"> Expression: the parsed or given expression.</span> -</span><span id="maybe_parse-4661"><a href="#maybe_parse-4661"><span class="linenos">4661</span></a><span class="sd"> """</span> -</span><span id="maybe_parse-4662"><a href="#maybe_parse-4662"><span class="linenos">4662</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> -</span><span id="maybe_parse-4663"><a href="#maybe_parse-4663"><span class="linenos">4663</span></a> <span class="k">if</span> <span class="n">copy</span><span class="p">:</span> -</span><span id="maybe_parse-4664"><a href="#maybe_parse-4664"><span class="linenos">4664</span></a> <span class="k">return</span> <span class="n">sql_or_expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="maybe_parse-4665"><a href="#maybe_parse-4665"><span class="linenos">4665</span></a> <span class="k">return</span> <span class="n">sql_or_expression</span> -</span><span id="maybe_parse-4666"><a href="#maybe_parse-4666"><span class="linenos">4666</span></a> -</span><span id="maybe_parse-4667"><a href="#maybe_parse-4667"><span class="linenos">4667</span></a> <span class="k">if</span> <span class="n">sql_or_expression</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="maybe_parse-4668"><a href="#maybe_parse-4668"><span class="linenos">4668</span></a> <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"SQL cannot be None"</span><span class="p">)</span> -</span><span id="maybe_parse-4669"><a href="#maybe_parse-4669"><span class="linenos">4669</span></a> -</span><span id="maybe_parse-4670"><a href="#maybe_parse-4670"><span class="linenos">4670</span></a> <span class="kn">import</span> <span class="nn">sqlglot</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="maybe_parse-4636"><a href="#maybe_parse-4636"><span class="linenos">4636</span></a><span class="k">def</span> <span class="nf">maybe_parse</span><span class="p">(</span> +</span><span id="maybe_parse-4637"><a href="#maybe_parse-4637"><span class="linenos">4637</span></a> <span class="n">sql_or_expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="maybe_parse-4638"><a href="#maybe_parse-4638"><span class="linenos">4638</span></a> <span class="o">*</span><span class="p">,</span> +</span><span id="maybe_parse-4639"><a href="#maybe_parse-4639"><span class="linenos">4639</span></a> <span class="n">into</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">IntoType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="maybe_parse-4640"><a href="#maybe_parse-4640"><span class="linenos">4640</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="maybe_parse-4641"><a href="#maybe_parse-4641"><span class="linenos">4641</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="maybe_parse-4642"><a href="#maybe_parse-4642"><span class="linenos">4642</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="maybe_parse-4643"><a href="#maybe_parse-4643"><span class="linenos">4643</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="maybe_parse-4644"><a href="#maybe_parse-4644"><span class="linenos">4644</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> +</span><span id="maybe_parse-4645"><a href="#maybe_parse-4645"><span class="linenos">4645</span></a><span class="w"> </span><span class="sd">"""Gracefully handle a possible string or expression.</span> +</span><span id="maybe_parse-4646"><a href="#maybe_parse-4646"><span class="linenos">4646</span></a> +</span><span id="maybe_parse-4647"><a href="#maybe_parse-4647"><span class="linenos">4647</span></a><span class="sd"> Example:</span> +</span><span id="maybe_parse-4648"><a href="#maybe_parse-4648"><span class="linenos">4648</span></a><span class="sd"> >>> maybe_parse("1")</span> +</span><span id="maybe_parse-4649"><a href="#maybe_parse-4649"><span class="linenos">4649</span></a><span class="sd"> (LITERAL this: 1, is_string: False)</span> +</span><span id="maybe_parse-4650"><a href="#maybe_parse-4650"><span class="linenos">4650</span></a><span class="sd"> >>> maybe_parse(to_identifier("x"))</span> +</span><span id="maybe_parse-4651"><a href="#maybe_parse-4651"><span class="linenos">4651</span></a><span class="sd"> (IDENTIFIER this: x, quoted: False)</span> +</span><span id="maybe_parse-4652"><a href="#maybe_parse-4652"><span class="linenos">4652</span></a> +</span><span id="maybe_parse-4653"><a href="#maybe_parse-4653"><span class="linenos">4653</span></a><span class="sd"> Args:</span> +</span><span id="maybe_parse-4654"><a href="#maybe_parse-4654"><span class="linenos">4654</span></a><span class="sd"> sql_or_expression: the SQL code string or an expression</span> +</span><span id="maybe_parse-4655"><a href="#maybe_parse-4655"><span class="linenos">4655</span></a><span class="sd"> into: the SQLGlot Expression to parse into</span> +</span><span id="maybe_parse-4656"><a href="#maybe_parse-4656"><span class="linenos">4656</span></a><span class="sd"> dialect: the dialect used to parse the input expressions (in the case that an</span> +</span><span id="maybe_parse-4657"><a href="#maybe_parse-4657"><span class="linenos">4657</span></a><span class="sd"> input expression is a SQL string).</span> +</span><span id="maybe_parse-4658"><a href="#maybe_parse-4658"><span class="linenos">4658</span></a><span class="sd"> prefix: a string to prefix the sql with before it gets parsed</span> +</span><span id="maybe_parse-4659"><a href="#maybe_parse-4659"><span class="linenos">4659</span></a><span class="sd"> (automatically includes a space)</span> +</span><span id="maybe_parse-4660"><a href="#maybe_parse-4660"><span class="linenos">4660</span></a><span class="sd"> copy: whether or not to copy the expression.</span> +</span><span id="maybe_parse-4661"><a href="#maybe_parse-4661"><span class="linenos">4661</span></a><span class="sd"> **opts: other options to use to parse the input expressions (again, in the case</span> +</span><span id="maybe_parse-4662"><a href="#maybe_parse-4662"><span class="linenos">4662</span></a><span class="sd"> that an input expression is a SQL string).</span> +</span><span id="maybe_parse-4663"><a href="#maybe_parse-4663"><span class="linenos">4663</span></a> +</span><span id="maybe_parse-4664"><a href="#maybe_parse-4664"><span class="linenos">4664</span></a><span class="sd"> Returns:</span> +</span><span id="maybe_parse-4665"><a href="#maybe_parse-4665"><span class="linenos">4665</span></a><span class="sd"> Expression: the parsed or given expression.</span> +</span><span id="maybe_parse-4666"><a href="#maybe_parse-4666"><span class="linenos">4666</span></a><span class="sd"> """</span> +</span><span id="maybe_parse-4667"><a href="#maybe_parse-4667"><span class="linenos">4667</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> +</span><span id="maybe_parse-4668"><a href="#maybe_parse-4668"><span class="linenos">4668</span></a> <span class="k">if</span> <span class="n">copy</span><span class="p">:</span> +</span><span id="maybe_parse-4669"><a href="#maybe_parse-4669"><span class="linenos">4669</span></a> <span class="k">return</span> <span class="n">sql_or_expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="maybe_parse-4670"><a href="#maybe_parse-4670"><span class="linenos">4670</span></a> <span class="k">return</span> <span class="n">sql_or_expression</span> </span><span id="maybe_parse-4671"><a href="#maybe_parse-4671"><span class="linenos">4671</span></a> -</span><span id="maybe_parse-4672"><a href="#maybe_parse-4672"><span class="linenos">4672</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="p">)</span> -</span><span id="maybe_parse-4673"><a href="#maybe_parse-4673"><span class="linenos">4673</span></a> <span class="k">if</span> <span class="n">prefix</span><span class="p">:</span> -</span><span id="maybe_parse-4674"><a href="#maybe_parse-4674"><span class="linenos">4674</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="maybe_parse-4675"><a href="#maybe_parse-4675"><span class="linenos">4675</span></a> -</span><span id="maybe_parse-4676"><a href="#maybe_parse-4676"><span class="linenos">4676</span></a> <span class="k">return</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">parse_one</span><span class="p">(</span><span class="n">sql</span><span class="p">,</span> <span class="n">read</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">into</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="maybe_parse-4672"><a href="#maybe_parse-4672"><span class="linenos">4672</span></a> <span class="k">if</span> <span class="n">sql_or_expression</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="maybe_parse-4673"><a href="#maybe_parse-4673"><span class="linenos">4673</span></a> <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"SQL cannot be None"</span><span class="p">)</span> +</span><span id="maybe_parse-4674"><a href="#maybe_parse-4674"><span class="linenos">4674</span></a> +</span><span id="maybe_parse-4675"><a href="#maybe_parse-4675"><span class="linenos">4675</span></a> <span class="kn">import</span> <span class="nn">sqlglot</span> +</span><span id="maybe_parse-4676"><a href="#maybe_parse-4676"><span class="linenos">4676</span></a> +</span><span id="maybe_parse-4677"><a href="#maybe_parse-4677"><span class="linenos">4677</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="p">)</span> +</span><span id="maybe_parse-4678"><a href="#maybe_parse-4678"><span class="linenos">4678</span></a> <span class="k">if</span> <span class="n">prefix</span><span class="p">:</span> +</span><span id="maybe_parse-4679"><a href="#maybe_parse-4679"><span class="linenos">4679</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="maybe_parse-4680"><a href="#maybe_parse-4680"><span class="linenos">4680</span></a> +</span><span id="maybe_parse-4681"><a href="#maybe_parse-4681"><span class="linenos">4681</span></a> <span class="k">return</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">parse_one</span><span class="p">(</span><span class="n">sql</span><span class="p">,</span> <span class="n">read</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">into</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> </span></pre></div> @@ -50004,32 +50132,32 @@ that an input expression is a SQL string).</li> </div> <a class="headerlink" href="#union"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="union-4860"><a href="#union-4860"><span class="linenos">4860</span></a><span class="k">def</span> <span class="nf">union</span><span class="p">(</span> -</span><span id="union-4861"><a href="#union-4861"><span class="linenos">4861</span></a> <span class="n">left</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">right</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">distinct</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="union-4862"><a href="#union-4862"><span class="linenos">4862</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">:</span> -</span><span id="union-4863"><a href="#union-4863"><span class="linenos">4863</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="union-4864"><a href="#union-4864"><span class="linenos">4864</span></a><span class="sd"> Initializes a syntax tree from one UNION expression.</span> -</span><span id="union-4865"><a href="#union-4865"><span class="linenos">4865</span></a> -</span><span id="union-4866"><a href="#union-4866"><span class="linenos">4866</span></a><span class="sd"> Example:</span> -</span><span id="union-4867"><a href="#union-4867"><span class="linenos">4867</span></a><span class="sd"> >>> union("SELECT * FROM foo", "SELECT * FROM bla").sql()</span> -</span><span id="union-4868"><a href="#union-4868"><span class="linenos">4868</span></a><span class="sd"> 'SELECT * FROM foo UNION SELECT * FROM bla'</span> -</span><span id="union-4869"><a href="#union-4869"><span class="linenos">4869</span></a> -</span><span id="union-4870"><a href="#union-4870"><span class="linenos">4870</span></a><span class="sd"> Args:</span> -</span><span id="union-4871"><a href="#union-4871"><span class="linenos">4871</span></a><span class="sd"> left: the SQL code string corresponding to the left-hand side.</span> -</span><span id="union-4872"><a href="#union-4872"><span class="linenos">4872</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="union-4873"><a href="#union-4873"><span class="linenos">4873</span></a><span class="sd"> right: the SQL code string corresponding to the right-hand side.</span> -</span><span id="union-4874"><a href="#union-4874"><span class="linenos">4874</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="union-4875"><a href="#union-4875"><span class="linenos">4875</span></a><span class="sd"> distinct: set the DISTINCT flag if and only if this is true.</span> -</span><span id="union-4876"><a href="#union-4876"><span class="linenos">4876</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="union-4877"><a href="#union-4877"><span class="linenos">4877</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="union-4878"><a href="#union-4878"><span class="linenos">4878</span></a> -</span><span id="union-4879"><a href="#union-4879"><span class="linenos">4879</span></a><span class="sd"> Returns:</span> -</span><span id="union-4880"><a href="#union-4880"><span class="linenos">4880</span></a><span class="sd"> The new Union instance.</span> -</span><span id="union-4881"><a href="#union-4881"><span class="linenos">4881</span></a><span class="sd"> """</span> -</span><span id="union-4882"><a href="#union-4882"><span class="linenos">4882</span></a> <span class="n">left</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="union-4883"><a href="#union-4883"><span class="linenos">4883</span></a> <span class="n">right</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="union-4884"><a href="#union-4884"><span class="linenos">4884</span></a> -</span><span id="union-4885"><a href="#union-4885"><span class="linenos">4885</span></a> <span class="k">return</span> <span class="n">Union</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="n">distinct</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="union-4865"><a href="#union-4865"><span class="linenos">4865</span></a><span class="k">def</span> <span class="nf">union</span><span class="p">(</span> +</span><span id="union-4866"><a href="#union-4866"><span class="linenos">4866</span></a> <span class="n">left</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">right</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">distinct</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="union-4867"><a href="#union-4867"><span class="linenos">4867</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Union</span><span class="p">:</span> +</span><span id="union-4868"><a href="#union-4868"><span class="linenos">4868</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="union-4869"><a href="#union-4869"><span class="linenos">4869</span></a><span class="sd"> Initializes a syntax tree from one UNION expression.</span> +</span><span id="union-4870"><a href="#union-4870"><span class="linenos">4870</span></a> +</span><span id="union-4871"><a href="#union-4871"><span class="linenos">4871</span></a><span class="sd"> Example:</span> +</span><span id="union-4872"><a href="#union-4872"><span class="linenos">4872</span></a><span class="sd"> >>> union("SELECT * FROM foo", "SELECT * FROM bla").sql()</span> +</span><span id="union-4873"><a href="#union-4873"><span class="linenos">4873</span></a><span class="sd"> 'SELECT * FROM foo UNION SELECT * FROM bla'</span> +</span><span id="union-4874"><a href="#union-4874"><span class="linenos">4874</span></a> +</span><span id="union-4875"><a href="#union-4875"><span class="linenos">4875</span></a><span class="sd"> Args:</span> +</span><span id="union-4876"><a href="#union-4876"><span class="linenos">4876</span></a><span class="sd"> left: the SQL code string corresponding to the left-hand side.</span> +</span><span id="union-4877"><a href="#union-4877"><span class="linenos">4877</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="union-4878"><a href="#union-4878"><span class="linenos">4878</span></a><span class="sd"> right: the SQL code string corresponding to the right-hand side.</span> +</span><span id="union-4879"><a href="#union-4879"><span class="linenos">4879</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="union-4880"><a href="#union-4880"><span class="linenos">4880</span></a><span class="sd"> distinct: set the DISTINCT flag if and only if this is true.</span> +</span><span id="union-4881"><a href="#union-4881"><span class="linenos">4881</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="union-4882"><a href="#union-4882"><span class="linenos">4882</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="union-4883"><a href="#union-4883"><span class="linenos">4883</span></a> +</span><span id="union-4884"><a href="#union-4884"><span class="linenos">4884</span></a><span class="sd"> Returns:</span> +</span><span id="union-4885"><a href="#union-4885"><span class="linenos">4885</span></a><span class="sd"> The new Union instance.</span> +</span><span id="union-4886"><a href="#union-4886"><span class="linenos">4886</span></a><span class="sd"> """</span> +</span><span id="union-4887"><a href="#union-4887"><span class="linenos">4887</span></a> <span class="n">left</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="union-4888"><a href="#union-4888"><span class="linenos">4888</span></a> <span class="n">right</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="union-4889"><a href="#union-4889"><span class="linenos">4889</span></a> +</span><span id="union-4890"><a href="#union-4890"><span class="linenos">4890</span></a> <span class="k">return</span> <span class="n">Union</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="n">distinct</span><span class="p">)</span> </span></pre></div> @@ -50077,32 +50205,32 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#intersect"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="intersect-4888"><a href="#intersect-4888"><span class="linenos">4888</span></a><span class="k">def</span> <span class="nf">intersect</span><span class="p">(</span> -</span><span id="intersect-4889"><a href="#intersect-4889"><span class="linenos">4889</span></a> <span class="n">left</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">right</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">distinct</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="intersect-4890"><a href="#intersect-4890"><span class="linenos">4890</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Intersect</span><span class="p">:</span> -</span><span id="intersect-4891"><a href="#intersect-4891"><span class="linenos">4891</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="intersect-4892"><a href="#intersect-4892"><span class="linenos">4892</span></a><span class="sd"> Initializes a syntax tree from one INTERSECT expression.</span> -</span><span id="intersect-4893"><a href="#intersect-4893"><span class="linenos">4893</span></a> -</span><span id="intersect-4894"><a href="#intersect-4894"><span class="linenos">4894</span></a><span class="sd"> Example:</span> -</span><span id="intersect-4895"><a href="#intersect-4895"><span class="linenos">4895</span></a><span class="sd"> >>> intersect("SELECT * FROM foo", "SELECT * FROM bla").sql()</span> -</span><span id="intersect-4896"><a href="#intersect-4896"><span class="linenos">4896</span></a><span class="sd"> 'SELECT * FROM foo INTERSECT SELECT * FROM bla'</span> -</span><span id="intersect-4897"><a href="#intersect-4897"><span class="linenos">4897</span></a> -</span><span id="intersect-4898"><a href="#intersect-4898"><span class="linenos">4898</span></a><span class="sd"> Args:</span> -</span><span id="intersect-4899"><a href="#intersect-4899"><span class="linenos">4899</span></a><span class="sd"> left: the SQL code string corresponding to the left-hand side.</span> -</span><span id="intersect-4900"><a href="#intersect-4900"><span class="linenos">4900</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="intersect-4901"><a href="#intersect-4901"><span class="linenos">4901</span></a><span class="sd"> right: the SQL code string corresponding to the right-hand side.</span> -</span><span id="intersect-4902"><a href="#intersect-4902"><span class="linenos">4902</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="intersect-4903"><a href="#intersect-4903"><span class="linenos">4903</span></a><span class="sd"> distinct: set the DISTINCT flag if and only if this is true.</span> -</span><span id="intersect-4904"><a href="#intersect-4904"><span class="linenos">4904</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="intersect-4905"><a href="#intersect-4905"><span class="linenos">4905</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="intersect-4906"><a href="#intersect-4906"><span class="linenos">4906</span></a> -</span><span id="intersect-4907"><a href="#intersect-4907"><span class="linenos">4907</span></a><span class="sd"> Returns:</span> -</span><span id="intersect-4908"><a href="#intersect-4908"><span class="linenos">4908</span></a><span class="sd"> The new Intersect instance.</span> -</span><span id="intersect-4909"><a href="#intersect-4909"><span class="linenos">4909</span></a><span class="sd"> """</span> -</span><span id="intersect-4910"><a href="#intersect-4910"><span class="linenos">4910</span></a> <span class="n">left</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="intersect-4911"><a href="#intersect-4911"><span class="linenos">4911</span></a> <span class="n">right</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="intersect-4912"><a href="#intersect-4912"><span class="linenos">4912</span></a> -</span><span id="intersect-4913"><a href="#intersect-4913"><span class="linenos">4913</span></a> <span class="k">return</span> <span class="n">Intersect</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="n">distinct</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="intersect-4893"><a href="#intersect-4893"><span class="linenos">4893</span></a><span class="k">def</span> <span class="nf">intersect</span><span class="p">(</span> +</span><span id="intersect-4894"><a href="#intersect-4894"><span class="linenos">4894</span></a> <span class="n">left</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">right</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">distinct</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="intersect-4895"><a href="#intersect-4895"><span class="linenos">4895</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Intersect</span><span class="p">:</span> +</span><span id="intersect-4896"><a href="#intersect-4896"><span class="linenos">4896</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="intersect-4897"><a href="#intersect-4897"><span class="linenos">4897</span></a><span class="sd"> Initializes a syntax tree from one INTERSECT expression.</span> +</span><span id="intersect-4898"><a href="#intersect-4898"><span class="linenos">4898</span></a> +</span><span id="intersect-4899"><a href="#intersect-4899"><span class="linenos">4899</span></a><span class="sd"> Example:</span> +</span><span id="intersect-4900"><a href="#intersect-4900"><span class="linenos">4900</span></a><span class="sd"> >>> intersect("SELECT * FROM foo", "SELECT * FROM bla").sql()</span> +</span><span id="intersect-4901"><a href="#intersect-4901"><span class="linenos">4901</span></a><span class="sd"> 'SELECT * FROM foo INTERSECT SELECT * FROM bla'</span> +</span><span id="intersect-4902"><a href="#intersect-4902"><span class="linenos">4902</span></a> +</span><span id="intersect-4903"><a href="#intersect-4903"><span class="linenos">4903</span></a><span class="sd"> Args:</span> +</span><span id="intersect-4904"><a href="#intersect-4904"><span class="linenos">4904</span></a><span class="sd"> left: the SQL code string corresponding to the left-hand side.</span> +</span><span id="intersect-4905"><a href="#intersect-4905"><span class="linenos">4905</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="intersect-4906"><a href="#intersect-4906"><span class="linenos">4906</span></a><span class="sd"> right: the SQL code string corresponding to the right-hand side.</span> +</span><span id="intersect-4907"><a href="#intersect-4907"><span class="linenos">4907</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="intersect-4908"><a href="#intersect-4908"><span class="linenos">4908</span></a><span class="sd"> distinct: set the DISTINCT flag if and only if this is true.</span> +</span><span id="intersect-4909"><a href="#intersect-4909"><span class="linenos">4909</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="intersect-4910"><a href="#intersect-4910"><span class="linenos">4910</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="intersect-4911"><a href="#intersect-4911"><span class="linenos">4911</span></a> +</span><span id="intersect-4912"><a href="#intersect-4912"><span class="linenos">4912</span></a><span class="sd"> Returns:</span> +</span><span id="intersect-4913"><a href="#intersect-4913"><span class="linenos">4913</span></a><span class="sd"> The new Intersect instance.</span> +</span><span id="intersect-4914"><a href="#intersect-4914"><span class="linenos">4914</span></a><span class="sd"> """</span> +</span><span id="intersect-4915"><a href="#intersect-4915"><span class="linenos">4915</span></a> <span class="n">left</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="intersect-4916"><a href="#intersect-4916"><span class="linenos">4916</span></a> <span class="n">right</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="intersect-4917"><a href="#intersect-4917"><span class="linenos">4917</span></a> +</span><span id="intersect-4918"><a href="#intersect-4918"><span class="linenos">4918</span></a> <span class="k">return</span> <span class="n">Intersect</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="n">distinct</span><span class="p">)</span> </span></pre></div> @@ -50150,32 +50278,32 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#except_"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="except_-4916"><a href="#except_-4916"><span class="linenos">4916</span></a><span class="k">def</span> <span class="nf">except_</span><span class="p">(</span> -</span><span id="except_-4917"><a href="#except_-4917"><span class="linenos">4917</span></a> <span class="n">left</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">right</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">distinct</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="except_-4918"><a href="#except_-4918"><span class="linenos">4918</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Except</span><span class="p">:</span> -</span><span id="except_-4919"><a href="#except_-4919"><span class="linenos">4919</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="except_-4920"><a href="#except_-4920"><span class="linenos">4920</span></a><span class="sd"> Initializes a syntax tree from one EXCEPT expression.</span> -</span><span id="except_-4921"><a href="#except_-4921"><span class="linenos">4921</span></a> -</span><span id="except_-4922"><a href="#except_-4922"><span class="linenos">4922</span></a><span class="sd"> Example:</span> -</span><span id="except_-4923"><a href="#except_-4923"><span class="linenos">4923</span></a><span class="sd"> >>> except_("SELECT * FROM foo", "SELECT * FROM bla").sql()</span> -</span><span id="except_-4924"><a href="#except_-4924"><span class="linenos">4924</span></a><span class="sd"> 'SELECT * FROM foo EXCEPT SELECT * FROM bla'</span> -</span><span id="except_-4925"><a href="#except_-4925"><span class="linenos">4925</span></a> -</span><span id="except_-4926"><a href="#except_-4926"><span class="linenos">4926</span></a><span class="sd"> Args:</span> -</span><span id="except_-4927"><a href="#except_-4927"><span class="linenos">4927</span></a><span class="sd"> left: the SQL code string corresponding to the left-hand side.</span> -</span><span id="except_-4928"><a href="#except_-4928"><span class="linenos">4928</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="except_-4929"><a href="#except_-4929"><span class="linenos">4929</span></a><span class="sd"> right: the SQL code string corresponding to the right-hand side.</span> -</span><span id="except_-4930"><a href="#except_-4930"><span class="linenos">4930</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> -</span><span id="except_-4931"><a href="#except_-4931"><span class="linenos">4931</span></a><span class="sd"> distinct: set the DISTINCT flag if and only if this is true.</span> -</span><span id="except_-4932"><a href="#except_-4932"><span class="linenos">4932</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="except_-4933"><a href="#except_-4933"><span class="linenos">4933</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> -</span><span id="except_-4934"><a href="#except_-4934"><span class="linenos">4934</span></a> -</span><span id="except_-4935"><a href="#except_-4935"><span class="linenos">4935</span></a><span class="sd"> Returns:</span> -</span><span id="except_-4936"><a href="#except_-4936"><span class="linenos">4936</span></a><span class="sd"> The new Except instance.</span> -</span><span id="except_-4937"><a href="#except_-4937"><span class="linenos">4937</span></a><span class="sd"> """</span> -</span><span id="except_-4938"><a href="#except_-4938"><span class="linenos">4938</span></a> <span class="n">left</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="except_-4939"><a href="#except_-4939"><span class="linenos">4939</span></a> <span class="n">right</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="except_-4940"><a href="#except_-4940"><span class="linenos">4940</span></a> -</span><span id="except_-4941"><a href="#except_-4941"><span class="linenos">4941</span></a> <span class="k">return</span> <span class="n">Except</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="n">distinct</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="except_-4921"><a href="#except_-4921"><span class="linenos">4921</span></a><span class="k">def</span> <span class="nf">except_</span><span class="p">(</span> +</span><span id="except_-4922"><a href="#except_-4922"><span class="linenos">4922</span></a> <span class="n">left</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">right</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">distinct</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="except_-4923"><a href="#except_-4923"><span class="linenos">4923</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Except</span><span class="p">:</span> +</span><span id="except_-4924"><a href="#except_-4924"><span class="linenos">4924</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="except_-4925"><a href="#except_-4925"><span class="linenos">4925</span></a><span class="sd"> Initializes a syntax tree from one EXCEPT expression.</span> +</span><span id="except_-4926"><a href="#except_-4926"><span class="linenos">4926</span></a> +</span><span id="except_-4927"><a href="#except_-4927"><span class="linenos">4927</span></a><span class="sd"> Example:</span> +</span><span id="except_-4928"><a href="#except_-4928"><span class="linenos">4928</span></a><span class="sd"> >>> except_("SELECT * FROM foo", "SELECT * FROM bla").sql()</span> +</span><span id="except_-4929"><a href="#except_-4929"><span class="linenos">4929</span></a><span class="sd"> 'SELECT * FROM foo EXCEPT SELECT * FROM bla'</span> +</span><span id="except_-4930"><a href="#except_-4930"><span class="linenos">4930</span></a> +</span><span id="except_-4931"><a href="#except_-4931"><span class="linenos">4931</span></a><span class="sd"> Args:</span> +</span><span id="except_-4932"><a href="#except_-4932"><span class="linenos">4932</span></a><span class="sd"> left: the SQL code string corresponding to the left-hand side.</span> +</span><span id="except_-4933"><a href="#except_-4933"><span class="linenos">4933</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="except_-4934"><a href="#except_-4934"><span class="linenos">4934</span></a><span class="sd"> right: the SQL code string corresponding to the right-hand side.</span> +</span><span id="except_-4935"><a href="#except_-4935"><span class="linenos">4935</span></a><span class="sd"> If an `Expression` instance is passed, it will be used as-is.</span> +</span><span id="except_-4936"><a href="#except_-4936"><span class="linenos">4936</span></a><span class="sd"> distinct: set the DISTINCT flag if and only if this is true.</span> +</span><span id="except_-4937"><a href="#except_-4937"><span class="linenos">4937</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="except_-4938"><a href="#except_-4938"><span class="linenos">4938</span></a><span class="sd"> opts: other options to use to parse the input expressions.</span> +</span><span id="except_-4939"><a href="#except_-4939"><span class="linenos">4939</span></a> +</span><span id="except_-4940"><a href="#except_-4940"><span class="linenos">4940</span></a><span class="sd"> Returns:</span> +</span><span id="except_-4941"><a href="#except_-4941"><span class="linenos">4941</span></a><span class="sd"> The new Except instance.</span> +</span><span id="except_-4942"><a href="#except_-4942"><span class="linenos">4942</span></a><span class="sd"> """</span> +</span><span id="except_-4943"><a href="#except_-4943"><span class="linenos">4943</span></a> <span class="n">left</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="except_-4944"><a href="#except_-4944"><span class="linenos">4944</span></a> <span class="n">right</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_or_expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="except_-4945"><a href="#except_-4945"><span class="linenos">4945</span></a> +</span><span id="except_-4946"><a href="#except_-4946"><span class="linenos">4946</span></a> <span class="k">return</span> <span class="n">Except</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">right</span><span class="p">,</span> <span class="n">distinct</span><span class="o">=</span><span class="n">distinct</span><span class="p">)</span> </span></pre></div> @@ -50223,26 +50351,26 @@ If an <code><a href="#Expression">Expression</a></code> instance is passed, it w </div> <a class="headerlink" href="#select"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="select-4944"><a href="#select-4944"><span class="linenos">4944</span></a><span class="k">def</span> <span class="nf">select</span><span class="p">(</span><span class="o">*</span><span class="n">expressions</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="select-4945"><a href="#select-4945"><span class="linenos">4945</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="select-4946"><a href="#select-4946"><span class="linenos">4946</span></a><span class="sd"> Initializes a syntax tree from one or multiple SELECT expressions.</span> -</span><span id="select-4947"><a href="#select-4947"><span class="linenos">4947</span></a> -</span><span id="select-4948"><a href="#select-4948"><span class="linenos">4948</span></a><span class="sd"> Example:</span> -</span><span id="select-4949"><a href="#select-4949"><span class="linenos">4949</span></a><span class="sd"> >>> select("col1", "col2").from_("tbl").sql()</span> -</span><span id="select-4950"><a href="#select-4950"><span class="linenos">4950</span></a><span class="sd"> 'SELECT col1, col2 FROM tbl'</span> -</span><span id="select-4951"><a href="#select-4951"><span class="linenos">4951</span></a> -</span><span id="select-4952"><a href="#select-4952"><span class="linenos">4952</span></a><span class="sd"> Args:</span> -</span><span id="select-4953"><a href="#select-4953"><span class="linenos">4953</span></a><span class="sd"> *expressions: the SQL code string to parse as the expressions of a</span> -</span><span id="select-4954"><a href="#select-4954"><span class="linenos">4954</span></a><span class="sd"> SELECT statement. If an Expression instance is passed, this is used as-is.</span> -</span><span id="select-4955"><a href="#select-4955"><span class="linenos">4955</span></a><span class="sd"> dialect: the dialect used to parse the input expressions (in the case that an</span> -</span><span id="select-4956"><a href="#select-4956"><span class="linenos">4956</span></a><span class="sd"> input expression is a SQL string).</span> -</span><span id="select-4957"><a href="#select-4957"><span class="linenos">4957</span></a><span class="sd"> **opts: other options to use to parse the input expressions (again, in the case</span> -</span><span id="select-4958"><a href="#select-4958"><span class="linenos">4958</span></a><span class="sd"> that an input expression is a SQL string).</span> -</span><span id="select-4959"><a href="#select-4959"><span class="linenos">4959</span></a> -</span><span id="select-4960"><a href="#select-4960"><span class="linenos">4960</span></a><span class="sd"> Returns:</span> -</span><span id="select-4961"><a href="#select-4961"><span class="linenos">4961</span></a><span class="sd"> Select: the syntax tree for the SELECT statement.</span> -</span><span id="select-4962"><a href="#select-4962"><span class="linenos">4962</span></a><span class="sd"> """</span> -</span><span id="select-4963"><a href="#select-4963"><span class="linenos">4963</span></a> <span class="k">return</span> <span class="n">Select</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">expressions</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="select-4949"><a href="#select-4949"><span class="linenos">4949</span></a><span class="k">def</span> <span class="nf">select</span><span class="p">(</span><span class="o">*</span><span class="n">expressions</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="select-4950"><a href="#select-4950"><span class="linenos">4950</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="select-4951"><a href="#select-4951"><span class="linenos">4951</span></a><span class="sd"> Initializes a syntax tree from one or multiple SELECT expressions.</span> +</span><span id="select-4952"><a href="#select-4952"><span class="linenos">4952</span></a> +</span><span id="select-4953"><a href="#select-4953"><span class="linenos">4953</span></a><span class="sd"> Example:</span> +</span><span id="select-4954"><a href="#select-4954"><span class="linenos">4954</span></a><span class="sd"> >>> select("col1", "col2").from_("tbl").sql()</span> +</span><span id="select-4955"><a href="#select-4955"><span class="linenos">4955</span></a><span class="sd"> 'SELECT col1, col2 FROM tbl'</span> +</span><span id="select-4956"><a href="#select-4956"><span class="linenos">4956</span></a> +</span><span id="select-4957"><a href="#select-4957"><span class="linenos">4957</span></a><span class="sd"> Args:</span> +</span><span id="select-4958"><a href="#select-4958"><span class="linenos">4958</span></a><span class="sd"> *expressions: the SQL code string to parse as the expressions of a</span> +</span><span id="select-4959"><a href="#select-4959"><span class="linenos">4959</span></a><span class="sd"> SELECT statement. If an Expression instance is passed, this is used as-is.</span> +</span><span id="select-4960"><a href="#select-4960"><span class="linenos">4960</span></a><span class="sd"> dialect: the dialect used to parse the input expressions (in the case that an</span> +</span><span id="select-4961"><a href="#select-4961"><span class="linenos">4961</span></a><span class="sd"> input expression is a SQL string).</span> +</span><span id="select-4962"><a href="#select-4962"><span class="linenos">4962</span></a><span class="sd"> **opts: other options to use to parse the input expressions (again, in the case</span> +</span><span id="select-4963"><a href="#select-4963"><span class="linenos">4963</span></a><span class="sd"> that an input expression is a SQL string).</span> +</span><span id="select-4964"><a href="#select-4964"><span class="linenos">4964</span></a> +</span><span id="select-4965"><a href="#select-4965"><span class="linenos">4965</span></a><span class="sd"> Returns:</span> +</span><span id="select-4966"><a href="#select-4966"><span class="linenos">4966</span></a><span class="sd"> Select: the syntax tree for the SELECT statement.</span> +</span><span id="select-4967"><a href="#select-4967"><span class="linenos">4967</span></a><span class="sd"> """</span> +</span><span id="select-4968"><a href="#select-4968"><span class="linenos">4968</span></a> <span class="k">return</span> <span class="n">Select</span><span class="p">()</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="o">*</span><span class="n">expressions</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> </span></pre></div> @@ -50289,26 +50417,26 @@ that an input expression is a SQL string).</li> </div> <a class="headerlink" href="#from_"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="from_-4966"><a href="#from_-4966"><span class="linenos">4966</span></a><span class="k">def</span> <span class="nf">from_</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="from_-4967"><a href="#from_-4967"><span class="linenos">4967</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="from_-4968"><a href="#from_-4968"><span class="linenos">4968</span></a><span class="sd"> Initializes a syntax tree from a FROM expression.</span> -</span><span id="from_-4969"><a href="#from_-4969"><span class="linenos">4969</span></a> -</span><span id="from_-4970"><a href="#from_-4970"><span class="linenos">4970</span></a><span class="sd"> Example:</span> -</span><span id="from_-4971"><a href="#from_-4971"><span class="linenos">4971</span></a><span class="sd"> >>> from_("tbl").select("col1", "col2").sql()</span> -</span><span id="from_-4972"><a href="#from_-4972"><span class="linenos">4972</span></a><span class="sd"> 'SELECT col1, col2 FROM tbl'</span> -</span><span id="from_-4973"><a href="#from_-4973"><span class="linenos">4973</span></a> -</span><span id="from_-4974"><a href="#from_-4974"><span class="linenos">4974</span></a><span class="sd"> Args:</span> -</span><span id="from_-4975"><a href="#from_-4975"><span class="linenos">4975</span></a><span class="sd"> *expression: the SQL code string to parse as the FROM expressions of a</span> -</span><span id="from_-4976"><a href="#from_-4976"><span class="linenos">4976</span></a><span class="sd"> SELECT statement. If an Expression instance is passed, this is used as-is.</span> -</span><span id="from_-4977"><a href="#from_-4977"><span class="linenos">4977</span></a><span class="sd"> dialect: the dialect used to parse the input expression (in the case that the</span> -</span><span id="from_-4978"><a href="#from_-4978"><span class="linenos">4978</span></a><span class="sd"> input expression is a SQL string).</span> -</span><span id="from_-4979"><a href="#from_-4979"><span class="linenos">4979</span></a><span class="sd"> **opts: other options to use to parse the input expressions (again, in the case</span> -</span><span id="from_-4980"><a href="#from_-4980"><span class="linenos">4980</span></a><span class="sd"> that the input expression is a SQL string).</span> -</span><span id="from_-4981"><a href="#from_-4981"><span class="linenos">4981</span></a> -</span><span id="from_-4982"><a href="#from_-4982"><span class="linenos">4982</span></a><span class="sd"> Returns:</span> -</span><span id="from_-4983"><a href="#from_-4983"><span class="linenos">4983</span></a><span class="sd"> Select: the syntax tree for the SELECT statement.</span> -</span><span id="from_-4984"><a href="#from_-4984"><span class="linenos">4984</span></a><span class="sd"> """</span> -</span><span id="from_-4985"><a href="#from_-4985"><span class="linenos">4985</span></a> <span class="k">return</span> <span class="n">Select</span><span class="p">()</span><span class="o">.</span><span class="n">from_</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="from_-4971"><a href="#from_-4971"><span class="linenos">4971</span></a><span class="k">def</span> <span class="nf">from_</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="from_-4972"><a href="#from_-4972"><span class="linenos">4972</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="from_-4973"><a href="#from_-4973"><span class="linenos">4973</span></a><span class="sd"> Initializes a syntax tree from a FROM expression.</span> +</span><span id="from_-4974"><a href="#from_-4974"><span class="linenos">4974</span></a> +</span><span id="from_-4975"><a href="#from_-4975"><span class="linenos">4975</span></a><span class="sd"> Example:</span> +</span><span id="from_-4976"><a href="#from_-4976"><span class="linenos">4976</span></a><span class="sd"> >>> from_("tbl").select("col1", "col2").sql()</span> +</span><span id="from_-4977"><a href="#from_-4977"><span class="linenos">4977</span></a><span class="sd"> 'SELECT col1, col2 FROM tbl'</span> +</span><span id="from_-4978"><a href="#from_-4978"><span class="linenos">4978</span></a> +</span><span id="from_-4979"><a href="#from_-4979"><span class="linenos">4979</span></a><span class="sd"> Args:</span> +</span><span id="from_-4980"><a href="#from_-4980"><span class="linenos">4980</span></a><span class="sd"> *expression: the SQL code string to parse as the FROM expressions of a</span> +</span><span id="from_-4981"><a href="#from_-4981"><span class="linenos">4981</span></a><span class="sd"> SELECT statement. If an Expression instance is passed, this is used as-is.</span> +</span><span id="from_-4982"><a href="#from_-4982"><span class="linenos">4982</span></a><span class="sd"> dialect: the dialect used to parse the input expression (in the case that the</span> +</span><span id="from_-4983"><a href="#from_-4983"><span class="linenos">4983</span></a><span class="sd"> input expression is a SQL string).</span> +</span><span id="from_-4984"><a href="#from_-4984"><span class="linenos">4984</span></a><span class="sd"> **opts: other options to use to parse the input expressions (again, in the case</span> +</span><span id="from_-4985"><a href="#from_-4985"><span class="linenos">4985</span></a><span class="sd"> that the input expression is a SQL string).</span> +</span><span id="from_-4986"><a href="#from_-4986"><span class="linenos">4986</span></a> +</span><span id="from_-4987"><a href="#from_-4987"><span class="linenos">4987</span></a><span class="sd"> Returns:</span> +</span><span id="from_-4988"><a href="#from_-4988"><span class="linenos">4988</span></a><span class="sd"> Select: the syntax tree for the SELECT statement.</span> +</span><span id="from_-4989"><a href="#from_-4989"><span class="linenos">4989</span></a><span class="sd"> """</span> +</span><span id="from_-4990"><a href="#from_-4990"><span class="linenos">4990</span></a> <span class="k">return</span> <span class="n">Select</span><span class="p">()</span><span class="o">.</span><span class="n">from_</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> </span></pre></div> @@ -50355,53 +50483,53 @@ that the input expression is a SQL string).</li> </div> <a class="headerlink" href="#update"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="update-4988"><a href="#update-4988"><span class="linenos">4988</span></a><span class="k">def</span> <span class="nf">update</span><span class="p">(</span> -</span><span id="update-4989"><a href="#update-4989"><span class="linenos">4989</span></a> <span class="n">table</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Table</span><span class="p">,</span> -</span><span id="update-4990"><a href="#update-4990"><span class="linenos">4990</span></a> <span class="n">properties</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> -</span><span id="update-4991"><a href="#update-4991"><span class="linenos">4991</span></a> <span class="n">where</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="update-4992"><a href="#update-4992"><span class="linenos">4992</span></a> <span class="n">from_</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="update-4993"><a href="#update-4993"><span class="linenos">4993</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="update-4994"><a href="#update-4994"><span class="linenos">4994</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="update-4995"><a href="#update-4995"><span class="linenos">4995</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Update</span><span class="p">:</span> -</span><span id="update-4996"><a href="#update-4996"><span class="linenos">4996</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="update-4997"><a href="#update-4997"><span class="linenos">4997</span></a><span class="sd"> Creates an update statement.</span> -</span><span id="update-4998"><a href="#update-4998"><span class="linenos">4998</span></a> -</span><span id="update-4999"><a href="#update-4999"><span class="linenos">4999</span></a><span class="sd"> Example:</span> -</span><span id="update-5000"><a href="#update-5000"><span class="linenos">5000</span></a><span class="sd"> >>> update("my_table", {"x": 1, "y": "2", "z": None}, from_="baz", where="id > 1").sql()</span> -</span><span id="update-5001"><a href="#update-5001"><span class="linenos">5001</span></a><span class="sd"> "UPDATE my_table SET x = 1, y = '2', z = NULL FROM baz WHERE id > 1"</span> -</span><span id="update-5002"><a href="#update-5002"><span class="linenos">5002</span></a> -</span><span id="update-5003"><a href="#update-5003"><span class="linenos">5003</span></a><span class="sd"> Args:</span> -</span><span id="update-5004"><a href="#update-5004"><span class="linenos">5004</span></a><span class="sd"> *properties: dictionary of properties to set which are</span> -</span><span id="update-5005"><a href="#update-5005"><span class="linenos">5005</span></a><span class="sd"> auto converted to sql objects eg None -> NULL</span> -</span><span id="update-5006"><a href="#update-5006"><span class="linenos">5006</span></a><span class="sd"> where: sql conditional parsed into a WHERE statement</span> -</span><span id="update-5007"><a href="#update-5007"><span class="linenos">5007</span></a><span class="sd"> from_: sql statement parsed into a FROM statement</span> -</span><span id="update-5008"><a href="#update-5008"><span class="linenos">5008</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="update-5009"><a href="#update-5009"><span class="linenos">5009</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> -</span><span id="update-5010"><a href="#update-5010"><span class="linenos">5010</span></a> -</span><span id="update-5011"><a href="#update-5011"><span class="linenos">5011</span></a><span class="sd"> Returns:</span> -</span><span id="update-5012"><a href="#update-5012"><span class="linenos">5012</span></a><span class="sd"> Update: the syntax tree for the UPDATE statement.</span> -</span><span id="update-5013"><a href="#update-5013"><span class="linenos">5013</span></a><span class="sd"> """</span> -</span><span id="update-5014"><a href="#update-5014"><span class="linenos">5014</span></a> <span class="n">update_expr</span> <span class="o">=</span> <span class="n">Update</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">))</span> -</span><span id="update-5015"><a href="#update-5015"><span class="linenos">5015</span></a> <span class="n">update_expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="update-5016"><a href="#update-5016"><span class="linenos">5016</span></a> <span class="s2">"expressions"</span><span class="p">,</span> -</span><span id="update-5017"><a href="#update-5017"><span class="linenos">5017</span></a> <span class="p">[</span> -</span><span id="update-5018"><a href="#update-5018"><span class="linenos">5018</span></a> <span class="n">EQ</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">convert</span><span class="p">(</span><span class="n">v</span><span class="p">))</span> -</span><span id="update-5019"><a href="#update-5019"><span class="linenos">5019</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> -</span><span id="update-5020"><a href="#update-5020"><span class="linenos">5020</span></a> <span class="p">],</span> -</span><span id="update-5021"><a href="#update-5021"><span class="linenos">5021</span></a> <span class="p">)</span> -</span><span id="update-5022"><a href="#update-5022"><span class="linenos">5022</span></a> <span class="k">if</span> <span class="n">from_</span><span class="p">:</span> -</span><span id="update-5023"><a href="#update-5023"><span class="linenos">5023</span></a> <span class="n">update_expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="update-5024"><a href="#update-5024"><span class="linenos">5024</span></a> <span class="s2">"from"</span><span class="p">,</span> -</span><span id="update-5025"><a href="#update-5025"><span class="linenos">5025</span></a> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">from_</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">From</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"FROM"</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> -</span><span id="update-5026"><a href="#update-5026"><span class="linenos">5026</span></a> <span class="p">)</span> -</span><span id="update-5027"><a href="#update-5027"><span class="linenos">5027</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">where</span><span class="p">,</span> <span class="n">Condition</span><span class="p">):</span> -</span><span id="update-5028"><a href="#update-5028"><span class="linenos">5028</span></a> <span class="n">where</span> <span class="o">=</span> <span class="n">Where</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">where</span><span class="p">)</span> -</span><span id="update-5029"><a href="#update-5029"><span class="linenos">5029</span></a> <span class="k">if</span> <span class="n">where</span><span class="p">:</span> -</span><span id="update-5030"><a href="#update-5030"><span class="linenos">5030</span></a> <span class="n">update_expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="update-5031"><a href="#update-5031"><span class="linenos">5031</span></a> <span class="s2">"where"</span><span class="p">,</span> -</span><span id="update-5032"><a href="#update-5032"><span class="linenos">5032</span></a> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">where</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Where</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"WHERE"</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> -</span><span id="update-5033"><a href="#update-5033"><span class="linenos">5033</span></a> <span class="p">)</span> -</span><span id="update-5034"><a href="#update-5034"><span class="linenos">5034</span></a> <span class="k">return</span> <span class="n">update_expr</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="update-4993"><a href="#update-4993"><span class="linenos">4993</span></a><span class="k">def</span> <span class="nf">update</span><span class="p">(</span> +</span><span id="update-4994"><a href="#update-4994"><span class="linenos">4994</span></a> <span class="n">table</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Table</span><span class="p">,</span> +</span><span id="update-4995"><a href="#update-4995"><span class="linenos">4995</span></a> <span class="n">properties</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> +</span><span id="update-4996"><a href="#update-4996"><span class="linenos">4996</span></a> <span class="n">where</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="update-4997"><a href="#update-4997"><span class="linenos">4997</span></a> <span class="n">from_</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="update-4998"><a href="#update-4998"><span class="linenos">4998</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="update-4999"><a href="#update-4999"><span class="linenos">4999</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="update-5000"><a href="#update-5000"><span class="linenos">5000</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Update</span><span class="p">:</span> +</span><span id="update-5001"><a href="#update-5001"><span class="linenos">5001</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="update-5002"><a href="#update-5002"><span class="linenos">5002</span></a><span class="sd"> Creates an update statement.</span> +</span><span id="update-5003"><a href="#update-5003"><span class="linenos">5003</span></a> +</span><span id="update-5004"><a href="#update-5004"><span class="linenos">5004</span></a><span class="sd"> Example:</span> +</span><span id="update-5005"><a href="#update-5005"><span class="linenos">5005</span></a><span class="sd"> >>> update("my_table", {"x": 1, "y": "2", "z": None}, from_="baz", where="id > 1").sql()</span> +</span><span id="update-5006"><a href="#update-5006"><span class="linenos">5006</span></a><span class="sd"> "UPDATE my_table SET x = 1, y = '2', z = NULL FROM baz WHERE id > 1"</span> +</span><span id="update-5007"><a href="#update-5007"><span class="linenos">5007</span></a> +</span><span id="update-5008"><a href="#update-5008"><span class="linenos">5008</span></a><span class="sd"> Args:</span> +</span><span id="update-5009"><a href="#update-5009"><span class="linenos">5009</span></a><span class="sd"> *properties: dictionary of properties to set which are</span> +</span><span id="update-5010"><a href="#update-5010"><span class="linenos">5010</span></a><span class="sd"> auto converted to sql objects eg None -> NULL</span> +</span><span id="update-5011"><a href="#update-5011"><span class="linenos">5011</span></a><span class="sd"> where: sql conditional parsed into a WHERE statement</span> +</span><span id="update-5012"><a href="#update-5012"><span class="linenos">5012</span></a><span class="sd"> from_: sql statement parsed into a FROM statement</span> +</span><span id="update-5013"><a href="#update-5013"><span class="linenos">5013</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="update-5014"><a href="#update-5014"><span class="linenos">5014</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> +</span><span id="update-5015"><a href="#update-5015"><span class="linenos">5015</span></a> +</span><span id="update-5016"><a href="#update-5016"><span class="linenos">5016</span></a><span class="sd"> Returns:</span> +</span><span id="update-5017"><a href="#update-5017"><span class="linenos">5017</span></a><span class="sd"> Update: the syntax tree for the UPDATE statement.</span> +</span><span id="update-5018"><a href="#update-5018"><span class="linenos">5018</span></a><span class="sd"> """</span> +</span><span id="update-5019"><a href="#update-5019"><span class="linenos">5019</span></a> <span class="n">update_expr</span> <span class="o">=</span> <span class="n">Update</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">))</span> +</span><span id="update-5020"><a href="#update-5020"><span class="linenos">5020</span></a> <span class="n">update_expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="update-5021"><a href="#update-5021"><span class="linenos">5021</span></a> <span class="s2">"expressions"</span><span class="p">,</span> +</span><span id="update-5022"><a href="#update-5022"><span class="linenos">5022</span></a> <span class="p">[</span> +</span><span id="update-5023"><a href="#update-5023"><span class="linenos">5023</span></a> <span class="n">EQ</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> <span class="n">expression</span><span class="o">=</span><span class="n">convert</span><span class="p">(</span><span class="n">v</span><span class="p">))</span> +</span><span id="update-5024"><a href="#update-5024"><span class="linenos">5024</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> +</span><span id="update-5025"><a href="#update-5025"><span class="linenos">5025</span></a> <span class="p">],</span> +</span><span id="update-5026"><a href="#update-5026"><span class="linenos">5026</span></a> <span class="p">)</span> +</span><span id="update-5027"><a href="#update-5027"><span class="linenos">5027</span></a> <span class="k">if</span> <span class="n">from_</span><span class="p">:</span> +</span><span id="update-5028"><a href="#update-5028"><span class="linenos">5028</span></a> <span class="n">update_expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="update-5029"><a href="#update-5029"><span class="linenos">5029</span></a> <span class="s2">"from"</span><span class="p">,</span> +</span><span id="update-5030"><a href="#update-5030"><span class="linenos">5030</span></a> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">from_</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">From</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"FROM"</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> +</span><span id="update-5031"><a href="#update-5031"><span class="linenos">5031</span></a> <span class="p">)</span> +</span><span id="update-5032"><a href="#update-5032"><span class="linenos">5032</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">where</span><span class="p">,</span> <span class="n">Condition</span><span class="p">):</span> +</span><span id="update-5033"><a href="#update-5033"><span class="linenos">5033</span></a> <span class="n">where</span> <span class="o">=</span> <span class="n">Where</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">where</span><span class="p">)</span> +</span><span id="update-5034"><a href="#update-5034"><span class="linenos">5034</span></a> <span class="k">if</span> <span class="n">where</span><span class="p">:</span> +</span><span id="update-5035"><a href="#update-5035"><span class="linenos">5035</span></a> <span class="n">update_expr</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="update-5036"><a href="#update-5036"><span class="linenos">5036</span></a> <span class="s2">"where"</span><span class="p">,</span> +</span><span id="update-5037"><a href="#update-5037"><span class="linenos">5037</span></a> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">where</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Where</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"WHERE"</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">),</span> +</span><span id="update-5038"><a href="#update-5038"><span class="linenos">5038</span></a> <span class="p">)</span> +</span><span id="update-5039"><a href="#update-5039"><span class="linenos">5039</span></a> <span class="k">return</span> <span class="n">update_expr</span> </span></pre></div> @@ -50448,35 +50576,35 @@ auto converted to sql objects eg None -> NULL</li> </div> <a class="headerlink" href="#delete"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="delete-5037"><a href="#delete-5037"><span class="linenos">5037</span></a><span class="k">def</span> <span class="nf">delete</span><span class="p">(</span> -</span><span id="delete-5038"><a href="#delete-5038"><span class="linenos">5038</span></a> <span class="n">table</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="delete-5039"><a href="#delete-5039"><span class="linenos">5039</span></a> <span class="n">where</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="delete-5040"><a href="#delete-5040"><span class="linenos">5040</span></a> <span class="n">returning</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="delete-5041"><a href="#delete-5041"><span class="linenos">5041</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="delete-5042"><a href="#delete-5042"><span class="linenos">5042</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="delete-5043"><a href="#delete-5043"><span class="linenos">5043</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Delete</span><span class="p">:</span> -</span><span id="delete-5044"><a href="#delete-5044"><span class="linenos">5044</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="delete-5045"><a href="#delete-5045"><span class="linenos">5045</span></a><span class="sd"> Builds a delete statement.</span> -</span><span id="delete-5046"><a href="#delete-5046"><span class="linenos">5046</span></a> -</span><span id="delete-5047"><a href="#delete-5047"><span class="linenos">5047</span></a><span class="sd"> Example:</span> -</span><span id="delete-5048"><a href="#delete-5048"><span class="linenos">5048</span></a><span class="sd"> >>> delete("my_table", where="id > 1").sql()</span> -</span><span id="delete-5049"><a href="#delete-5049"><span class="linenos">5049</span></a><span class="sd"> 'DELETE FROM my_table WHERE id > 1'</span> -</span><span id="delete-5050"><a href="#delete-5050"><span class="linenos">5050</span></a> -</span><span id="delete-5051"><a href="#delete-5051"><span class="linenos">5051</span></a><span class="sd"> Args:</span> -</span><span id="delete-5052"><a href="#delete-5052"><span class="linenos">5052</span></a><span class="sd"> where: sql conditional parsed into a WHERE statement</span> -</span><span id="delete-5053"><a href="#delete-5053"><span class="linenos">5053</span></a><span class="sd"> returning: sql conditional parsed into a RETURNING statement</span> -</span><span id="delete-5054"><a href="#delete-5054"><span class="linenos">5054</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="delete-5055"><a href="#delete-5055"><span class="linenos">5055</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> -</span><span id="delete-5056"><a href="#delete-5056"><span class="linenos">5056</span></a> -</span><span id="delete-5057"><a href="#delete-5057"><span class="linenos">5057</span></a><span class="sd"> Returns:</span> -</span><span id="delete-5058"><a href="#delete-5058"><span class="linenos">5058</span></a><span class="sd"> Delete: the syntax tree for the DELETE statement.</span> -</span><span id="delete-5059"><a href="#delete-5059"><span class="linenos">5059</span></a><span class="sd"> """</span> -</span><span id="delete-5060"><a href="#delete-5060"><span class="linenos">5060</span></a> <span class="n">delete_expr</span> <span class="o">=</span> <span class="n">Delete</span><span class="p">()</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="delete-5061"><a href="#delete-5061"><span class="linenos">5061</span></a> <span class="k">if</span> <span class="n">where</span><span class="p">:</span> -</span><span id="delete-5062"><a href="#delete-5062"><span class="linenos">5062</span></a> <span class="n">delete_expr</span> <span class="o">=</span> <span class="n">delete_expr</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">where</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="delete-5063"><a href="#delete-5063"><span class="linenos">5063</span></a> <span class="k">if</span> <span class="n">returning</span><span class="p">:</span> -</span><span id="delete-5064"><a href="#delete-5064"><span class="linenos">5064</span></a> <span class="n">delete_expr</span> <span class="o">=</span> <span class="n">delete_expr</span><span class="o">.</span><span class="n">returning</span><span class="p">(</span><span class="n">returning</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="delete-5065"><a href="#delete-5065"><span class="linenos">5065</span></a> <span class="k">return</span> <span class="n">delete_expr</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="delete-5042"><a href="#delete-5042"><span class="linenos">5042</span></a><span class="k">def</span> <span class="nf">delete</span><span class="p">(</span> +</span><span id="delete-5043"><a href="#delete-5043"><span class="linenos">5043</span></a> <span class="n">table</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="delete-5044"><a href="#delete-5044"><span class="linenos">5044</span></a> <span class="n">where</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="delete-5045"><a href="#delete-5045"><span class="linenos">5045</span></a> <span class="n">returning</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">ExpOrStr</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="delete-5046"><a href="#delete-5046"><span class="linenos">5046</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="delete-5047"><a href="#delete-5047"><span class="linenos">5047</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="delete-5048"><a href="#delete-5048"><span class="linenos">5048</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Delete</span><span class="p">:</span> +</span><span id="delete-5049"><a href="#delete-5049"><span class="linenos">5049</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="delete-5050"><a href="#delete-5050"><span class="linenos">5050</span></a><span class="sd"> Builds a delete statement.</span> +</span><span id="delete-5051"><a href="#delete-5051"><span class="linenos">5051</span></a> +</span><span id="delete-5052"><a href="#delete-5052"><span class="linenos">5052</span></a><span class="sd"> Example:</span> +</span><span id="delete-5053"><a href="#delete-5053"><span class="linenos">5053</span></a><span class="sd"> >>> delete("my_table", where="id > 1").sql()</span> +</span><span id="delete-5054"><a href="#delete-5054"><span class="linenos">5054</span></a><span class="sd"> 'DELETE FROM my_table WHERE id > 1'</span> +</span><span id="delete-5055"><a href="#delete-5055"><span class="linenos">5055</span></a> +</span><span id="delete-5056"><a href="#delete-5056"><span class="linenos">5056</span></a><span class="sd"> Args:</span> +</span><span id="delete-5057"><a href="#delete-5057"><span class="linenos">5057</span></a><span class="sd"> where: sql conditional parsed into a WHERE statement</span> +</span><span id="delete-5058"><a href="#delete-5058"><span class="linenos">5058</span></a><span class="sd"> returning: sql conditional parsed into a RETURNING statement</span> +</span><span id="delete-5059"><a href="#delete-5059"><span class="linenos">5059</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="delete-5060"><a href="#delete-5060"><span class="linenos">5060</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> +</span><span id="delete-5061"><a href="#delete-5061"><span class="linenos">5061</span></a> +</span><span id="delete-5062"><a href="#delete-5062"><span class="linenos">5062</span></a><span class="sd"> Returns:</span> +</span><span id="delete-5063"><a href="#delete-5063"><span class="linenos">5063</span></a><span class="sd"> Delete: the syntax tree for the DELETE statement.</span> +</span><span id="delete-5064"><a href="#delete-5064"><span class="linenos">5064</span></a><span class="sd"> """</span> +</span><span id="delete-5065"><a href="#delete-5065"><span class="linenos">5065</span></a> <span class="n">delete_expr</span> <span class="o">=</span> <span class="n">Delete</span><span class="p">()</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="delete-5066"><a href="#delete-5066"><span class="linenos">5066</span></a> <span class="k">if</span> <span class="n">where</span><span class="p">:</span> +</span><span id="delete-5067"><a href="#delete-5067"><span class="linenos">5067</span></a> <span class="n">delete_expr</span> <span class="o">=</span> <span class="n">delete_expr</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">where</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="delete-5068"><a href="#delete-5068"><span class="linenos">5068</span></a> <span class="k">if</span> <span class="n">returning</span><span class="p">:</span> +</span><span id="delete-5069"><a href="#delete-5069"><span class="linenos">5069</span></a> <span class="n">delete_expr</span> <span class="o">=</span> <span class="n">delete_expr</span><span class="o">.</span><span class="n">returning</span><span class="p">(</span><span class="n">returning</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="delete-5070"><a href="#delete-5070"><span class="linenos">5070</span></a> <span class="k">return</span> <span class="n">delete_expr</span> </span></pre></div> @@ -50521,49 +50649,49 @@ auto converted to sql objects eg None -> NULL</li> </div> <a class="headerlink" href="#insert"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="insert-5068"><a href="#insert-5068"><span class="linenos">5068</span></a><span class="k">def</span> <span class="nf">insert</span><span class="p">(</span> -</span><span id="insert-5069"><a href="#insert-5069"><span class="linenos">5069</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="insert-5070"><a href="#insert-5070"><span class="linenos">5070</span></a> <span class="n">into</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="insert-5071"><a href="#insert-5071"><span class="linenos">5071</span></a> <span class="n">columns</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="n">ExpOrStr</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="insert-5072"><a href="#insert-5072"><span class="linenos">5072</span></a> <span class="n">overwrite</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="insert-5073"><a href="#insert-5073"><span class="linenos">5073</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="insert-5074"><a href="#insert-5074"><span class="linenos">5074</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="insert-5075"><a href="#insert-5075"><span class="linenos">5075</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="insert-5076"><a href="#insert-5076"><span class="linenos">5076</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Insert</span><span class="p">:</span> -</span><span id="insert-5077"><a href="#insert-5077"><span class="linenos">5077</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="insert-5078"><a href="#insert-5078"><span class="linenos">5078</span></a><span class="sd"> Builds an INSERT statement.</span> -</span><span id="insert-5079"><a href="#insert-5079"><span class="linenos">5079</span></a> -</span><span id="insert-5080"><a href="#insert-5080"><span class="linenos">5080</span></a><span class="sd"> Example:</span> -</span><span id="insert-5081"><a href="#insert-5081"><span class="linenos">5081</span></a><span class="sd"> >>> insert("VALUES (1, 2, 3)", "tbl").sql()</span> -</span><span id="insert-5082"><a href="#insert-5082"><span class="linenos">5082</span></a><span class="sd"> 'INSERT INTO tbl VALUES (1, 2, 3)'</span> -</span><span id="insert-5083"><a href="#insert-5083"><span class="linenos">5083</span></a> -</span><span id="insert-5084"><a href="#insert-5084"><span class="linenos">5084</span></a><span class="sd"> Args:</span> -</span><span id="insert-5085"><a href="#insert-5085"><span class="linenos">5085</span></a><span class="sd"> expression: the sql string or expression of the INSERT statement</span> -</span><span id="insert-5086"><a href="#insert-5086"><span class="linenos">5086</span></a><span class="sd"> into: the tbl to insert data to.</span> -</span><span id="insert-5087"><a href="#insert-5087"><span class="linenos">5087</span></a><span class="sd"> columns: optionally the table's column names.</span> -</span><span id="insert-5088"><a href="#insert-5088"><span class="linenos">5088</span></a><span class="sd"> overwrite: whether to INSERT OVERWRITE or not.</span> -</span><span id="insert-5089"><a href="#insert-5089"><span class="linenos">5089</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> -</span><span id="insert-5090"><a href="#insert-5090"><span class="linenos">5090</span></a><span class="sd"> copy: whether or not to copy the expression.</span> -</span><span id="insert-5091"><a href="#insert-5091"><span class="linenos">5091</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> -</span><span id="insert-5092"><a href="#insert-5092"><span class="linenos">5092</span></a> -</span><span id="insert-5093"><a href="#insert-5093"><span class="linenos">5093</span></a><span class="sd"> Returns:</span> -</span><span id="insert-5094"><a href="#insert-5094"><span class="linenos">5094</span></a><span class="sd"> Insert: the syntax tree for the INSERT statement.</span> -</span><span id="insert-5095"><a href="#insert-5095"><span class="linenos">5095</span></a><span class="sd"> """</span> -</span><span id="insert-5096"><a href="#insert-5096"><span class="linenos">5096</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="insert-5097"><a href="#insert-5097"><span class="linenos">5097</span></a> <span class="n">this</span><span class="p">:</span> <span class="n">Table</span> <span class="o">|</span> <span class="n">Schema</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">into</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="insert-5098"><a href="#insert-5098"><span class="linenos">5098</span></a> -</span><span id="insert-5099"><a href="#insert-5099"><span class="linenos">5099</span></a> <span class="k">if</span> <span class="n">columns</span><span class="p">:</span> -</span><span id="insert-5100"><a href="#insert-5100"><span class="linenos">5100</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">_apply_list_builder</span><span class="p">(</span> -</span><span id="insert-5101"><a href="#insert-5101"><span class="linenos">5101</span></a> <span class="o">*</span><span class="n">columns</span><span class="p">,</span> -</span><span id="insert-5102"><a href="#insert-5102"><span class="linenos">5102</span></a> <span class="n">instance</span><span class="o">=</span><span class="n">Schema</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">),</span> -</span><span id="insert-5103"><a href="#insert-5103"><span class="linenos">5103</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"expressions"</span><span class="p">,</span> -</span><span id="insert-5104"><a href="#insert-5104"><span class="linenos">5104</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Identifier</span><span class="p">,</span> -</span><span id="insert-5105"><a href="#insert-5105"><span class="linenos">5105</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="insert-5106"><a href="#insert-5106"><span class="linenos">5106</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="insert-5107"><a href="#insert-5107"><span class="linenos">5107</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="insert-5108"><a href="#insert-5108"><span class="linenos">5108</span></a> <span class="p">)</span> -</span><span id="insert-5109"><a href="#insert-5109"><span class="linenos">5109</span></a> -</span><span id="insert-5110"><a href="#insert-5110"><span class="linenos">5110</span></a> <span class="k">return</span> <span class="n">Insert</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expr</span><span class="p">,</span> <span class="n">overwrite</span><span class="o">=</span><span class="n">overwrite</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="insert-5073"><a href="#insert-5073"><span class="linenos">5073</span></a><span class="k">def</span> <span class="nf">insert</span><span class="p">(</span> +</span><span id="insert-5074"><a href="#insert-5074"><span class="linenos">5074</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="insert-5075"><a href="#insert-5075"><span class="linenos">5075</span></a> <span class="n">into</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="insert-5076"><a href="#insert-5076"><span class="linenos">5076</span></a> <span class="n">columns</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="n">ExpOrStr</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="insert-5077"><a href="#insert-5077"><span class="linenos">5077</span></a> <span class="n">overwrite</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="insert-5078"><a href="#insert-5078"><span class="linenos">5078</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="insert-5079"><a href="#insert-5079"><span class="linenos">5079</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="insert-5080"><a href="#insert-5080"><span class="linenos">5080</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="insert-5081"><a href="#insert-5081"><span class="linenos">5081</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Insert</span><span class="p">:</span> +</span><span id="insert-5082"><a href="#insert-5082"><span class="linenos">5082</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="insert-5083"><a href="#insert-5083"><span class="linenos">5083</span></a><span class="sd"> Builds an INSERT statement.</span> +</span><span id="insert-5084"><a href="#insert-5084"><span class="linenos">5084</span></a> +</span><span id="insert-5085"><a href="#insert-5085"><span class="linenos">5085</span></a><span class="sd"> Example:</span> +</span><span id="insert-5086"><a href="#insert-5086"><span class="linenos">5086</span></a><span class="sd"> >>> insert("VALUES (1, 2, 3)", "tbl").sql()</span> +</span><span id="insert-5087"><a href="#insert-5087"><span class="linenos">5087</span></a><span class="sd"> 'INSERT INTO tbl VALUES (1, 2, 3)'</span> +</span><span id="insert-5088"><a href="#insert-5088"><span class="linenos">5088</span></a> +</span><span id="insert-5089"><a href="#insert-5089"><span class="linenos">5089</span></a><span class="sd"> Args:</span> +</span><span id="insert-5090"><a href="#insert-5090"><span class="linenos">5090</span></a><span class="sd"> expression: the sql string or expression of the INSERT statement</span> +</span><span id="insert-5091"><a href="#insert-5091"><span class="linenos">5091</span></a><span class="sd"> into: the tbl to insert data to.</span> +</span><span id="insert-5092"><a href="#insert-5092"><span class="linenos">5092</span></a><span class="sd"> columns: optionally the table's column names.</span> +</span><span id="insert-5093"><a href="#insert-5093"><span class="linenos">5093</span></a><span class="sd"> overwrite: whether to INSERT OVERWRITE or not.</span> +</span><span id="insert-5094"><a href="#insert-5094"><span class="linenos">5094</span></a><span class="sd"> dialect: the dialect used to parse the input expressions.</span> +</span><span id="insert-5095"><a href="#insert-5095"><span class="linenos">5095</span></a><span class="sd"> copy: whether or not to copy the expression.</span> +</span><span id="insert-5096"><a href="#insert-5096"><span class="linenos">5096</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> +</span><span id="insert-5097"><a href="#insert-5097"><span class="linenos">5097</span></a> +</span><span id="insert-5098"><a href="#insert-5098"><span class="linenos">5098</span></a><span class="sd"> Returns:</span> +</span><span id="insert-5099"><a href="#insert-5099"><span class="linenos">5099</span></a><span class="sd"> Insert: the syntax tree for the INSERT statement.</span> +</span><span id="insert-5100"><a href="#insert-5100"><span class="linenos">5100</span></a><span class="sd"> """</span> +</span><span id="insert-5101"><a href="#insert-5101"><span class="linenos">5101</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="insert-5102"><a href="#insert-5102"><span class="linenos">5102</span></a> <span class="n">this</span><span class="p">:</span> <span class="n">Table</span> <span class="o">|</span> <span class="n">Schema</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">into</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="insert-5103"><a href="#insert-5103"><span class="linenos">5103</span></a> +</span><span id="insert-5104"><a href="#insert-5104"><span class="linenos">5104</span></a> <span class="k">if</span> <span class="n">columns</span><span class="p">:</span> +</span><span id="insert-5105"><a href="#insert-5105"><span class="linenos">5105</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">_apply_list_builder</span><span class="p">(</span> +</span><span id="insert-5106"><a href="#insert-5106"><span class="linenos">5106</span></a> <span class="o">*</span><span class="n">columns</span><span class="p">,</span> +</span><span id="insert-5107"><a href="#insert-5107"><span class="linenos">5107</span></a> <span class="n">instance</span><span class="o">=</span><span class="n">Schema</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">),</span> +</span><span id="insert-5108"><a href="#insert-5108"><span class="linenos">5108</span></a> <span class="n">arg</span><span class="o">=</span><span class="s2">"expressions"</span><span class="p">,</span> +</span><span id="insert-5109"><a href="#insert-5109"><span class="linenos">5109</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Identifier</span><span class="p">,</span> +</span><span id="insert-5110"><a href="#insert-5110"><span class="linenos">5110</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="insert-5111"><a href="#insert-5111"><span class="linenos">5111</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="insert-5112"><a href="#insert-5112"><span class="linenos">5112</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="insert-5113"><a href="#insert-5113"><span class="linenos">5113</span></a> <span class="p">)</span> +</span><span id="insert-5114"><a href="#insert-5114"><span class="linenos">5114</span></a> +</span><span id="insert-5115"><a href="#insert-5115"><span class="linenos">5115</span></a> <span class="k">return</span> <span class="n">Insert</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expr</span><span class="p">,</span> <span class="n">overwrite</span><span class="o">=</span><span class="n">overwrite</span><span class="p">)</span> </span></pre></div> @@ -50611,41 +50739,41 @@ auto converted to sql objects eg None -> NULL</li> </div> <a class="headerlink" href="#condition"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="condition-5113"><a href="#condition-5113"><span class="linenos">5113</span></a><span class="k">def</span> <span class="nf">condition</span><span class="p">(</span> -</span><span id="condition-5114"><a href="#condition-5114"><span class="linenos">5114</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="condition-5115"><a href="#condition-5115"><span class="linenos">5115</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Condition</span><span class="p">:</span> -</span><span id="condition-5116"><a href="#condition-5116"><span class="linenos">5116</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="condition-5117"><a href="#condition-5117"><span class="linenos">5117</span></a><span class="sd"> Initialize a logical condition expression.</span> -</span><span id="condition-5118"><a href="#condition-5118"><span class="linenos">5118</span></a> -</span><span id="condition-5119"><a href="#condition-5119"><span class="linenos">5119</span></a><span class="sd"> Example:</span> -</span><span id="condition-5120"><a href="#condition-5120"><span class="linenos">5120</span></a><span class="sd"> >>> condition("x=1").sql()</span> -</span><span id="condition-5121"><a href="#condition-5121"><span class="linenos">5121</span></a><span class="sd"> 'x = 1'</span> -</span><span id="condition-5122"><a href="#condition-5122"><span class="linenos">5122</span></a> -</span><span id="condition-5123"><a href="#condition-5123"><span class="linenos">5123</span></a><span class="sd"> This is helpful for composing larger logical syntax trees:</span> -</span><span id="condition-5124"><a href="#condition-5124"><span class="linenos">5124</span></a><span class="sd"> >>> where = condition("x=1")</span> -</span><span id="condition-5125"><a href="#condition-5125"><span class="linenos">5125</span></a><span class="sd"> >>> where = where.and_("y=1")</span> -</span><span id="condition-5126"><a href="#condition-5126"><span class="linenos">5126</span></a><span class="sd"> >>> Select().from_("tbl").select("*").where(where).sql()</span> -</span><span id="condition-5127"><a href="#condition-5127"><span class="linenos">5127</span></a><span class="sd"> 'SELECT * FROM tbl WHERE x = 1 AND y = 1'</span> -</span><span id="condition-5128"><a href="#condition-5128"><span class="linenos">5128</span></a> -</span><span id="condition-5129"><a href="#condition-5129"><span class="linenos">5129</span></a><span class="sd"> Args:</span> -</span><span id="condition-5130"><a href="#condition-5130"><span class="linenos">5130</span></a><span class="sd"> *expression: the SQL code string to parse.</span> -</span><span id="condition-5131"><a href="#condition-5131"><span class="linenos">5131</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> -</span><span id="condition-5132"><a href="#condition-5132"><span class="linenos">5132</span></a><span class="sd"> dialect: the dialect used to parse the input expression (in the case that the</span> -</span><span id="condition-5133"><a href="#condition-5133"><span class="linenos">5133</span></a><span class="sd"> input expression is a SQL string).</span> -</span><span id="condition-5134"><a href="#condition-5134"><span class="linenos">5134</span></a><span class="sd"> copy: Whether or not to copy `expression` (only applies to expressions).</span> -</span><span id="condition-5135"><a href="#condition-5135"><span class="linenos">5135</span></a><span class="sd"> **opts: other options to use to parse the input expressions (again, in the case</span> -</span><span id="condition-5136"><a href="#condition-5136"><span class="linenos">5136</span></a><span class="sd"> that the input expression is a SQL string).</span> -</span><span id="condition-5137"><a href="#condition-5137"><span class="linenos">5137</span></a> -</span><span id="condition-5138"><a href="#condition-5138"><span class="linenos">5138</span></a><span class="sd"> Returns:</span> -</span><span id="condition-5139"><a href="#condition-5139"><span class="linenos">5139</span></a><span class="sd"> The new Condition instance</span> -</span><span id="condition-5140"><a href="#condition-5140"><span class="linenos">5140</span></a><span class="sd"> """</span> -</span><span id="condition-5141"><a href="#condition-5141"><span class="linenos">5141</span></a> <span class="k">return</span> <span class="n">maybe_parse</span><span class="p">(</span> -</span><span id="condition-5142"><a href="#condition-5142"><span class="linenos">5142</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="condition-5143"><a href="#condition-5143"><span class="linenos">5143</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Condition</span><span class="p">,</span> -</span><span id="condition-5144"><a href="#condition-5144"><span class="linenos">5144</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="condition-5145"><a href="#condition-5145"><span class="linenos">5145</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="condition-5146"><a href="#condition-5146"><span class="linenos">5146</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="condition-5147"><a href="#condition-5147"><span class="linenos">5147</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="condition-5118"><a href="#condition-5118"><span class="linenos">5118</span></a><span class="k">def</span> <span class="nf">condition</span><span class="p">(</span> +</span><span id="condition-5119"><a href="#condition-5119"><span class="linenos">5119</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="condition-5120"><a href="#condition-5120"><span class="linenos">5120</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Condition</span><span class="p">:</span> +</span><span id="condition-5121"><a href="#condition-5121"><span class="linenos">5121</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="condition-5122"><a href="#condition-5122"><span class="linenos">5122</span></a><span class="sd"> Initialize a logical condition expression.</span> +</span><span id="condition-5123"><a href="#condition-5123"><span class="linenos">5123</span></a> +</span><span id="condition-5124"><a href="#condition-5124"><span class="linenos">5124</span></a><span class="sd"> Example:</span> +</span><span id="condition-5125"><a href="#condition-5125"><span class="linenos">5125</span></a><span class="sd"> >>> condition("x=1").sql()</span> +</span><span id="condition-5126"><a href="#condition-5126"><span class="linenos">5126</span></a><span class="sd"> 'x = 1'</span> +</span><span id="condition-5127"><a href="#condition-5127"><span class="linenos">5127</span></a> +</span><span id="condition-5128"><a href="#condition-5128"><span class="linenos">5128</span></a><span class="sd"> This is helpful for composing larger logical syntax trees:</span> +</span><span id="condition-5129"><a href="#condition-5129"><span class="linenos">5129</span></a><span class="sd"> >>> where = condition("x=1")</span> +</span><span id="condition-5130"><a href="#condition-5130"><span class="linenos">5130</span></a><span class="sd"> >>> where = where.and_("y=1")</span> +</span><span id="condition-5131"><a href="#condition-5131"><span class="linenos">5131</span></a><span class="sd"> >>> Select().from_("tbl").select("*").where(where).sql()</span> +</span><span id="condition-5132"><a href="#condition-5132"><span class="linenos">5132</span></a><span class="sd"> 'SELECT * FROM tbl WHERE x = 1 AND y = 1'</span> +</span><span id="condition-5133"><a href="#condition-5133"><span class="linenos">5133</span></a> +</span><span id="condition-5134"><a href="#condition-5134"><span class="linenos">5134</span></a><span class="sd"> Args:</span> +</span><span id="condition-5135"><a href="#condition-5135"><span class="linenos">5135</span></a><span class="sd"> *expression: the SQL code string to parse.</span> +</span><span id="condition-5136"><a href="#condition-5136"><span class="linenos">5136</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> +</span><span id="condition-5137"><a href="#condition-5137"><span class="linenos">5137</span></a><span class="sd"> dialect: the dialect used to parse the input expression (in the case that the</span> +</span><span id="condition-5138"><a href="#condition-5138"><span class="linenos">5138</span></a><span class="sd"> input expression is a SQL string).</span> +</span><span id="condition-5139"><a href="#condition-5139"><span class="linenos">5139</span></a><span class="sd"> copy: Whether or not to copy `expression` (only applies to expressions).</span> +</span><span id="condition-5140"><a href="#condition-5140"><span class="linenos">5140</span></a><span class="sd"> **opts: other options to use to parse the input expressions (again, in the case</span> +</span><span id="condition-5141"><a href="#condition-5141"><span class="linenos">5141</span></a><span class="sd"> that the input expression is a SQL string).</span> +</span><span id="condition-5142"><a href="#condition-5142"><span class="linenos">5142</span></a> +</span><span id="condition-5143"><a href="#condition-5143"><span class="linenos">5143</span></a><span class="sd"> Returns:</span> +</span><span id="condition-5144"><a href="#condition-5144"><span class="linenos">5144</span></a><span class="sd"> The new Condition instance</span> +</span><span id="condition-5145"><a href="#condition-5145"><span class="linenos">5145</span></a><span class="sd"> """</span> +</span><span id="condition-5146"><a href="#condition-5146"><span class="linenos">5146</span></a> <span class="k">return</span> <span class="n">maybe_parse</span><span class="p">(</span> +</span><span id="condition-5147"><a href="#condition-5147"><span class="linenos">5147</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="condition-5148"><a href="#condition-5148"><span class="linenos">5148</span></a> <span class="n">into</span><span class="o">=</span><span class="n">Condition</span><span class="p">,</span> +</span><span id="condition-5149"><a href="#condition-5149"><span class="linenos">5149</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="condition-5150"><a href="#condition-5150"><span class="linenos">5150</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="condition-5151"><a href="#condition-5151"><span class="linenos">5151</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="condition-5152"><a href="#condition-5152"><span class="linenos">5152</span></a> <span class="p">)</span> </span></pre></div> @@ -50703,27 +50831,27 @@ that the input expression is a SQL string).</li> </div> <a class="headerlink" href="#and_"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="and_-5150"><a href="#and_-5150"><span class="linenos">5150</span></a><span class="k">def</span> <span class="nf">and_</span><span class="p">(</span> -</span><span id="and_-5151"><a href="#and_-5151"><span class="linenos">5151</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="and_-5152"><a href="#and_-5152"><span class="linenos">5152</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Condition</span><span class="p">:</span> -</span><span id="and_-5153"><a href="#and_-5153"><span class="linenos">5153</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="and_-5154"><a href="#and_-5154"><span class="linenos">5154</span></a><span class="sd"> Combine multiple conditions with an AND logical operator.</span> -</span><span id="and_-5155"><a href="#and_-5155"><span class="linenos">5155</span></a> -</span><span id="and_-5156"><a href="#and_-5156"><span class="linenos">5156</span></a><span class="sd"> Example:</span> -</span><span id="and_-5157"><a href="#and_-5157"><span class="linenos">5157</span></a><span class="sd"> >>> and_("x=1", and_("y=1", "z=1")).sql()</span> -</span><span id="and_-5158"><a href="#and_-5158"><span class="linenos">5158</span></a><span class="sd"> 'x = 1 AND (y = 1 AND z = 1)'</span> -</span><span id="and_-5159"><a href="#and_-5159"><span class="linenos">5159</span></a> -</span><span id="and_-5160"><a href="#and_-5160"><span class="linenos">5160</span></a><span class="sd"> Args:</span> -</span><span id="and_-5161"><a href="#and_-5161"><span class="linenos">5161</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="and_-5162"><a href="#and_-5162"><span class="linenos">5162</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> -</span><span id="and_-5163"><a href="#and_-5163"><span class="linenos">5163</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="and_-5164"><a href="#and_-5164"><span class="linenos">5164</span></a><span class="sd"> copy: whether or not to copy `expressions` (only applies to Expressions).</span> -</span><span id="and_-5165"><a href="#and_-5165"><span class="linenos">5165</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> -</span><span id="and_-5166"><a href="#and_-5166"><span class="linenos">5166</span></a> -</span><span id="and_-5167"><a href="#and_-5167"><span class="linenos">5167</span></a><span class="sd"> Returns:</span> -</span><span id="and_-5168"><a href="#and_-5168"><span class="linenos">5168</span></a><span class="sd"> And: the new condition</span> -</span><span id="and_-5169"><a href="#and_-5169"><span class="linenos">5169</span></a><span class="sd"> """</span> -</span><span id="and_-5170"><a href="#and_-5170"><span class="linenos">5170</span></a> <span class="k">return</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">Condition</span><span class="p">,</span> <span class="n">_combine</span><span class="p">(</span><span class="n">expressions</span><span class="p">,</span> <span class="n">And</span><span class="p">,</span> <span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="and_-5155"><a href="#and_-5155"><span class="linenos">5155</span></a><span class="k">def</span> <span class="nf">and_</span><span class="p">(</span> +</span><span id="and_-5156"><a href="#and_-5156"><span class="linenos">5156</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="and_-5157"><a href="#and_-5157"><span class="linenos">5157</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Condition</span><span class="p">:</span> +</span><span id="and_-5158"><a href="#and_-5158"><span class="linenos">5158</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="and_-5159"><a href="#and_-5159"><span class="linenos">5159</span></a><span class="sd"> Combine multiple conditions with an AND logical operator.</span> +</span><span id="and_-5160"><a href="#and_-5160"><span class="linenos">5160</span></a> +</span><span id="and_-5161"><a href="#and_-5161"><span class="linenos">5161</span></a><span class="sd"> Example:</span> +</span><span id="and_-5162"><a href="#and_-5162"><span class="linenos">5162</span></a><span class="sd"> >>> and_("x=1", and_("y=1", "z=1")).sql()</span> +</span><span id="and_-5163"><a href="#and_-5163"><span class="linenos">5163</span></a><span class="sd"> 'x = 1 AND (y = 1 AND z = 1)'</span> +</span><span id="and_-5164"><a href="#and_-5164"><span class="linenos">5164</span></a> +</span><span id="and_-5165"><a href="#and_-5165"><span class="linenos">5165</span></a><span class="sd"> Args:</span> +</span><span id="and_-5166"><a href="#and_-5166"><span class="linenos">5166</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="and_-5167"><a href="#and_-5167"><span class="linenos">5167</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> +</span><span id="and_-5168"><a href="#and_-5168"><span class="linenos">5168</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="and_-5169"><a href="#and_-5169"><span class="linenos">5169</span></a><span class="sd"> copy: whether or not to copy `expressions` (only applies to Expressions).</span> +</span><span id="and_-5170"><a href="#and_-5170"><span class="linenos">5170</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> +</span><span id="and_-5171"><a href="#and_-5171"><span class="linenos">5171</span></a> +</span><span id="and_-5172"><a href="#and_-5172"><span class="linenos">5172</span></a><span class="sd"> Returns:</span> +</span><span id="and_-5173"><a href="#and_-5173"><span class="linenos">5173</span></a><span class="sd"> And: the new condition</span> +</span><span id="and_-5174"><a href="#and_-5174"><span class="linenos">5174</span></a><span class="sd"> """</span> +</span><span id="and_-5175"><a href="#and_-5175"><span class="linenos">5175</span></a> <span class="k">return</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">Condition</span><span class="p">,</span> <span class="n">_combine</span><span class="p">(</span><span class="n">expressions</span><span class="p">,</span> <span class="n">And</span><span class="p">,</span> <span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">))</span> </span></pre></div> @@ -50769,27 +50897,27 @@ If an Expression instance is passed, this is used as-is.</li> </div> <a class="headerlink" href="#or_"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="or_-5173"><a href="#or_-5173"><span class="linenos">5173</span></a><span class="k">def</span> <span class="nf">or_</span><span class="p">(</span> -</span><span id="or_-5174"><a href="#or_-5174"><span class="linenos">5174</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> -</span><span id="or_-5175"><a href="#or_-5175"><span class="linenos">5175</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Condition</span><span class="p">:</span> -</span><span id="or_-5176"><a href="#or_-5176"><span class="linenos">5176</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="or_-5177"><a href="#or_-5177"><span class="linenos">5177</span></a><span class="sd"> Combine multiple conditions with an OR logical operator.</span> -</span><span id="or_-5178"><a href="#or_-5178"><span class="linenos">5178</span></a> -</span><span id="or_-5179"><a href="#or_-5179"><span class="linenos">5179</span></a><span class="sd"> Example:</span> -</span><span id="or_-5180"><a href="#or_-5180"><span class="linenos">5180</span></a><span class="sd"> >>> or_("x=1", or_("y=1", "z=1")).sql()</span> -</span><span id="or_-5181"><a href="#or_-5181"><span class="linenos">5181</span></a><span class="sd"> 'x = 1 OR (y = 1 OR z = 1)'</span> -</span><span id="or_-5182"><a href="#or_-5182"><span class="linenos">5182</span></a> -</span><span id="or_-5183"><a href="#or_-5183"><span class="linenos">5183</span></a><span class="sd"> Args:</span> -</span><span id="or_-5184"><a href="#or_-5184"><span class="linenos">5184</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> -</span><span id="or_-5185"><a href="#or_-5185"><span class="linenos">5185</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> -</span><span id="or_-5186"><a href="#or_-5186"><span class="linenos">5186</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="or_-5187"><a href="#or_-5187"><span class="linenos">5187</span></a><span class="sd"> copy: whether or not to copy `expressions` (only applies to Expressions).</span> -</span><span id="or_-5188"><a href="#or_-5188"><span class="linenos">5188</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> -</span><span id="or_-5189"><a href="#or_-5189"><span class="linenos">5189</span></a> -</span><span id="or_-5190"><a href="#or_-5190"><span class="linenos">5190</span></a><span class="sd"> Returns:</span> -</span><span id="or_-5191"><a href="#or_-5191"><span class="linenos">5191</span></a><span class="sd"> Or: the new condition</span> -</span><span id="or_-5192"><a href="#or_-5192"><span class="linenos">5192</span></a><span class="sd"> """</span> -</span><span id="or_-5193"><a href="#or_-5193"><span class="linenos">5193</span></a> <span class="k">return</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">Condition</span><span class="p">,</span> <span class="n">_combine</span><span class="p">(</span><span class="n">expressions</span><span class="p">,</span> <span class="n">Or</span><span class="p">,</span> <span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="or_-5178"><a href="#or_-5178"><span class="linenos">5178</span></a><span class="k">def</span> <span class="nf">or_</span><span class="p">(</span> +</span><span id="or_-5179"><a href="#or_-5179"><span class="linenos">5179</span></a> <span class="o">*</span><span class="n">expressions</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">ExpOrStr</span><span class="p">],</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span> +</span><span id="or_-5180"><a href="#or_-5180"><span class="linenos">5180</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Condition</span><span class="p">:</span> +</span><span id="or_-5181"><a href="#or_-5181"><span class="linenos">5181</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="or_-5182"><a href="#or_-5182"><span class="linenos">5182</span></a><span class="sd"> Combine multiple conditions with an OR logical operator.</span> +</span><span id="or_-5183"><a href="#or_-5183"><span class="linenos">5183</span></a> +</span><span id="or_-5184"><a href="#or_-5184"><span class="linenos">5184</span></a><span class="sd"> Example:</span> +</span><span id="or_-5185"><a href="#or_-5185"><span class="linenos">5185</span></a><span class="sd"> >>> or_("x=1", or_("y=1", "z=1")).sql()</span> +</span><span id="or_-5186"><a href="#or_-5186"><span class="linenos">5186</span></a><span class="sd"> 'x = 1 OR (y = 1 OR z = 1)'</span> +</span><span id="or_-5187"><a href="#or_-5187"><span class="linenos">5187</span></a> +</span><span id="or_-5188"><a href="#or_-5188"><span class="linenos">5188</span></a><span class="sd"> Args:</span> +</span><span id="or_-5189"><a href="#or_-5189"><span class="linenos">5189</span></a><span class="sd"> *expressions: the SQL code strings to parse.</span> +</span><span id="or_-5190"><a href="#or_-5190"><span class="linenos">5190</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> +</span><span id="or_-5191"><a href="#or_-5191"><span class="linenos">5191</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="or_-5192"><a href="#or_-5192"><span class="linenos">5192</span></a><span class="sd"> copy: whether or not to copy `expressions` (only applies to Expressions).</span> +</span><span id="or_-5193"><a href="#or_-5193"><span class="linenos">5193</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> +</span><span id="or_-5194"><a href="#or_-5194"><span class="linenos">5194</span></a> +</span><span id="or_-5195"><a href="#or_-5195"><span class="linenos">5195</span></a><span class="sd"> Returns:</span> +</span><span id="or_-5196"><a href="#or_-5196"><span class="linenos">5196</span></a><span class="sd"> Or: the new condition</span> +</span><span id="or_-5197"><a href="#or_-5197"><span class="linenos">5197</span></a><span class="sd"> """</span> +</span><span id="or_-5198"><a href="#or_-5198"><span class="linenos">5198</span></a> <span class="k">return</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">Condition</span><span class="p">,</span> <span class="n">_combine</span><span class="p">(</span><span class="n">expressions</span><span class="p">,</span> <span class="n">Or</span><span class="p">,</span> <span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">))</span> </span></pre></div> @@ -50835,31 +50963,31 @@ If an Expression instance is passed, this is used as-is.</li> </div> <a class="headerlink" href="#not_"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="not_-5196"><a href="#not_-5196"><span class="linenos">5196</span></a><span class="k">def</span> <span class="nf">not_</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Not</span><span class="p">:</span> -</span><span id="not_-5197"><a href="#not_-5197"><span class="linenos">5197</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="not_-5198"><a href="#not_-5198"><span class="linenos">5198</span></a><span class="sd"> Wrap a condition with a NOT operator.</span> -</span><span id="not_-5199"><a href="#not_-5199"><span class="linenos">5199</span></a> -</span><span id="not_-5200"><a href="#not_-5200"><span class="linenos">5200</span></a><span class="sd"> Example:</span> -</span><span id="not_-5201"><a href="#not_-5201"><span class="linenos">5201</span></a><span class="sd"> >>> not_("this_suit='black'").sql()</span> -</span><span id="not_-5202"><a href="#not_-5202"><span class="linenos">5202</span></a><span class="sd"> "NOT this_suit = 'black'"</span> -</span><span id="not_-5203"><a href="#not_-5203"><span class="linenos">5203</span></a> -</span><span id="not_-5204"><a href="#not_-5204"><span class="linenos">5204</span></a><span class="sd"> Args:</span> -</span><span id="not_-5205"><a href="#not_-5205"><span class="linenos">5205</span></a><span class="sd"> expression: the SQL code string to parse.</span> -</span><span id="not_-5206"><a href="#not_-5206"><span class="linenos">5206</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> -</span><span id="not_-5207"><a href="#not_-5207"><span class="linenos">5207</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="not_-5208"><a href="#not_-5208"><span class="linenos">5208</span></a><span class="sd"> copy: whether to copy the expression or not.</span> -</span><span id="not_-5209"><a href="#not_-5209"><span class="linenos">5209</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> -</span><span id="not_-5210"><a href="#not_-5210"><span class="linenos">5210</span></a> -</span><span id="not_-5211"><a href="#not_-5211"><span class="linenos">5211</span></a><span class="sd"> Returns:</span> -</span><span id="not_-5212"><a href="#not_-5212"><span class="linenos">5212</span></a><span class="sd"> The new condition.</span> -</span><span id="not_-5213"><a href="#not_-5213"><span class="linenos">5213</span></a><span class="sd"> """</span> -</span><span id="not_-5214"><a href="#not_-5214"><span class="linenos">5214</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">condition</span><span class="p">(</span> -</span><span id="not_-5215"><a href="#not_-5215"><span class="linenos">5215</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="not_-5216"><a href="#not_-5216"><span class="linenos">5216</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> -</span><span id="not_-5217"><a href="#not_-5217"><span class="linenos">5217</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> -</span><span id="not_-5218"><a href="#not_-5218"><span class="linenos">5218</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="not_-5219"><a href="#not_-5219"><span class="linenos">5219</span></a> <span class="p">)</span> -</span><span id="not_-5220"><a href="#not_-5220"><span class="linenos">5220</span></a> <span class="k">return</span> <span class="n">Not</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">_wrap</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">Connector</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="not_-5201"><a href="#not_-5201"><span class="linenos">5201</span></a><span class="k">def</span> <span class="nf">not_</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Not</span><span class="p">:</span> +</span><span id="not_-5202"><a href="#not_-5202"><span class="linenos">5202</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="not_-5203"><a href="#not_-5203"><span class="linenos">5203</span></a><span class="sd"> Wrap a condition with a NOT operator.</span> +</span><span id="not_-5204"><a href="#not_-5204"><span class="linenos">5204</span></a> +</span><span id="not_-5205"><a href="#not_-5205"><span class="linenos">5205</span></a><span class="sd"> Example:</span> +</span><span id="not_-5206"><a href="#not_-5206"><span class="linenos">5206</span></a><span class="sd"> >>> not_("this_suit='black'").sql()</span> +</span><span id="not_-5207"><a href="#not_-5207"><span class="linenos">5207</span></a><span class="sd"> "NOT this_suit = 'black'"</span> +</span><span id="not_-5208"><a href="#not_-5208"><span class="linenos">5208</span></a> +</span><span id="not_-5209"><a href="#not_-5209"><span class="linenos">5209</span></a><span class="sd"> Args:</span> +</span><span id="not_-5210"><a href="#not_-5210"><span class="linenos">5210</span></a><span class="sd"> expression: the SQL code string to parse.</span> +</span><span id="not_-5211"><a href="#not_-5211"><span class="linenos">5211</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> +</span><span id="not_-5212"><a href="#not_-5212"><span class="linenos">5212</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="not_-5213"><a href="#not_-5213"><span class="linenos">5213</span></a><span class="sd"> copy: whether to copy the expression or not.</span> +</span><span id="not_-5214"><a href="#not_-5214"><span class="linenos">5214</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> +</span><span id="not_-5215"><a href="#not_-5215"><span class="linenos">5215</span></a> +</span><span id="not_-5216"><a href="#not_-5216"><span class="linenos">5216</span></a><span class="sd"> Returns:</span> +</span><span id="not_-5217"><a href="#not_-5217"><span class="linenos">5217</span></a><span class="sd"> The new condition.</span> +</span><span id="not_-5218"><a href="#not_-5218"><span class="linenos">5218</span></a><span class="sd"> """</span> +</span><span id="not_-5219"><a href="#not_-5219"><span class="linenos">5219</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">condition</span><span class="p">(</span> +</span><span id="not_-5220"><a href="#not_-5220"><span class="linenos">5220</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="not_-5221"><a href="#not_-5221"><span class="linenos">5221</span></a> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> +</span><span id="not_-5222"><a href="#not_-5222"><span class="linenos">5222</span></a> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> +</span><span id="not_-5223"><a href="#not_-5223"><span class="linenos">5223</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="not_-5224"><a href="#not_-5224"><span class="linenos">5224</span></a> <span class="p">)</span> +</span><span id="not_-5225"><a href="#not_-5225"><span class="linenos">5225</span></a> <span class="k">return</span> <span class="n">Not</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">_wrap</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">Connector</span><span class="p">))</span> </span></pre></div> @@ -50905,23 +51033,23 @@ If an Expression instance is passed, this is used as-is.</li> </div> <a class="headerlink" href="#paren"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="paren-5223"><a href="#paren-5223"><span class="linenos">5223</span></a><span class="k">def</span> <span class="nf">paren</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Paren</span><span class="p">:</span> -</span><span id="paren-5224"><a href="#paren-5224"><span class="linenos">5224</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="paren-5225"><a href="#paren-5225"><span class="linenos">5225</span></a><span class="sd"> Wrap an expression in parentheses.</span> -</span><span id="paren-5226"><a href="#paren-5226"><span class="linenos">5226</span></a> -</span><span id="paren-5227"><a href="#paren-5227"><span class="linenos">5227</span></a><span class="sd"> Example:</span> -</span><span id="paren-5228"><a href="#paren-5228"><span class="linenos">5228</span></a><span class="sd"> >>> paren("5 + 3").sql()</span> -</span><span id="paren-5229"><a href="#paren-5229"><span class="linenos">5229</span></a><span class="sd"> '(5 + 3)'</span> -</span><span id="paren-5230"><a href="#paren-5230"><span class="linenos">5230</span></a> -</span><span id="paren-5231"><a href="#paren-5231"><span class="linenos">5231</span></a><span class="sd"> Args:</span> -</span><span id="paren-5232"><a href="#paren-5232"><span class="linenos">5232</span></a><span class="sd"> expression: the SQL code string to parse.</span> -</span><span id="paren-5233"><a href="#paren-5233"><span class="linenos">5233</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> -</span><span id="paren-5234"><a href="#paren-5234"><span class="linenos">5234</span></a><span class="sd"> copy: whether to copy the expression or not.</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="paren-5228"><a href="#paren-5228"><span class="linenos">5228</span></a><span class="k">def</span> <span class="nf">paren</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">Paren</span><span class="p">:</span> +</span><span id="paren-5229"><a href="#paren-5229"><span class="linenos">5229</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="paren-5230"><a href="#paren-5230"><span class="linenos">5230</span></a><span class="sd"> Wrap an expression in parentheses.</span> +</span><span id="paren-5231"><a href="#paren-5231"><span class="linenos">5231</span></a> +</span><span id="paren-5232"><a href="#paren-5232"><span class="linenos">5232</span></a><span class="sd"> Example:</span> +</span><span id="paren-5233"><a href="#paren-5233"><span class="linenos">5233</span></a><span class="sd"> >>> paren("5 + 3").sql()</span> +</span><span id="paren-5234"><a href="#paren-5234"><span class="linenos">5234</span></a><span class="sd"> '(5 + 3)'</span> </span><span id="paren-5235"><a href="#paren-5235"><span class="linenos">5235</span></a> -</span><span id="paren-5236"><a href="#paren-5236"><span class="linenos">5236</span></a><span class="sd"> Returns:</span> -</span><span id="paren-5237"><a href="#paren-5237"><span class="linenos">5237</span></a><span class="sd"> The wrapped expression.</span> -</span><span id="paren-5238"><a href="#paren-5238"><span class="linenos">5238</span></a><span class="sd"> """</span> -</span><span id="paren-5239"><a href="#paren-5239"><span class="linenos">5239</span></a> <span class="k">return</span> <span class="n">Paren</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">))</span> +</span><span id="paren-5236"><a href="#paren-5236"><span class="linenos">5236</span></a><span class="sd"> Args:</span> +</span><span id="paren-5237"><a href="#paren-5237"><span class="linenos">5237</span></a><span class="sd"> expression: the SQL code string to parse.</span> +</span><span id="paren-5238"><a href="#paren-5238"><span class="linenos">5238</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> +</span><span id="paren-5239"><a href="#paren-5239"><span class="linenos">5239</span></a><span class="sd"> copy: whether to copy the expression or not.</span> +</span><span id="paren-5240"><a href="#paren-5240"><span class="linenos">5240</span></a> +</span><span id="paren-5241"><a href="#paren-5241"><span class="linenos">5241</span></a><span class="sd"> Returns:</span> +</span><span id="paren-5242"><a href="#paren-5242"><span class="linenos">5242</span></a><span class="sd"> The wrapped expression.</span> +</span><span id="paren-5243"><a href="#paren-5243"><span class="linenos">5243</span></a><span class="sd"> """</span> +</span><span id="paren-5244"><a href="#paren-5244"><span class="linenos">5244</span></a> <span class="k">return</span> <span class="n">Paren</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">))</span> </span></pre></div> @@ -50965,31 +51093,31 @@ If an Expression instance is passed, this is used as-is.</li> </div> <a class="headerlink" href="#to_identifier"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="to_identifier-5257"><a href="#to_identifier-5257"><span class="linenos">5257</span></a><span class="k">def</span> <span class="nf">to_identifier</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="kc">None</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="to_identifier-5258"><a href="#to_identifier-5258"><span class="linenos">5258</span></a><span class="w"> </span><span class="sd">"""Builds an identifier.</span> -</span><span id="to_identifier-5259"><a href="#to_identifier-5259"><span class="linenos">5259</span></a> -</span><span id="to_identifier-5260"><a href="#to_identifier-5260"><span class="linenos">5260</span></a><span class="sd"> Args:</span> -</span><span id="to_identifier-5261"><a href="#to_identifier-5261"><span class="linenos">5261</span></a><span class="sd"> name: The name to turn into an identifier.</span> -</span><span id="to_identifier-5262"><a href="#to_identifier-5262"><span class="linenos">5262</span></a><span class="sd"> quoted: Whether or not force quote the identifier.</span> -</span><span id="to_identifier-5263"><a href="#to_identifier-5263"><span class="linenos">5263</span></a><span class="sd"> copy: Whether or not to copy a passed in Identefier node.</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="to_identifier-5262"><a href="#to_identifier-5262"><span class="linenos">5262</span></a><span class="k">def</span> <span class="nf">to_identifier</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="kc">None</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="to_identifier-5263"><a href="#to_identifier-5263"><span class="linenos">5263</span></a><span class="w"> </span><span class="sd">"""Builds an identifier.</span> </span><span id="to_identifier-5264"><a href="#to_identifier-5264"><span class="linenos">5264</span></a> -</span><span id="to_identifier-5265"><a href="#to_identifier-5265"><span class="linenos">5265</span></a><span class="sd"> Returns:</span> -</span><span id="to_identifier-5266"><a href="#to_identifier-5266"><span class="linenos">5266</span></a><span class="sd"> The identifier ast node.</span> -</span><span id="to_identifier-5267"><a href="#to_identifier-5267"><span class="linenos">5267</span></a><span class="sd"> """</span> -</span><span id="to_identifier-5268"><a href="#to_identifier-5268"><span class="linenos">5268</span></a> -</span><span id="to_identifier-5269"><a href="#to_identifier-5269"><span class="linenos">5269</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="to_identifier-5270"><a href="#to_identifier-5270"><span class="linenos">5270</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="to_identifier-5271"><a href="#to_identifier-5271"><span class="linenos">5271</span></a> -</span><span id="to_identifier-5272"><a href="#to_identifier-5272"><span class="linenos">5272</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">Identifier</span><span class="p">):</span> -</span><span id="to_identifier-5273"><a href="#to_identifier-5273"><span class="linenos">5273</span></a> <span class="n">identifier</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="to_identifier-5274"><a href="#to_identifier-5274"><span class="linenos">5274</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="to_identifier-5275"><a href="#to_identifier-5275"><span class="linenos">5275</span></a> <span class="n">identifier</span> <span class="o">=</span> <span class="n">Identifier</span><span class="p">(</span> -</span><span id="to_identifier-5276"><a href="#to_identifier-5276"><span class="linenos">5276</span></a> <span class="n">this</span><span class="o">=</span><span class="n">name</span><span class="p">,</span> -</span><span id="to_identifier-5277"><a href="#to_identifier-5277"><span class="linenos">5277</span></a> <span class="n">quoted</span><span class="o">=</span><span class="ow">not</span> <span class="n">SAFE_IDENTIFIER_RE</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> <span class="k">if</span> <span class="n">quoted</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">quoted</span><span class="p">,</span> -</span><span id="to_identifier-5278"><a href="#to_identifier-5278"><span class="linenos">5278</span></a> <span class="p">)</span> -</span><span id="to_identifier-5279"><a href="#to_identifier-5279"><span class="linenos">5279</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="to_identifier-5280"><a href="#to_identifier-5280"><span class="linenos">5280</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Name needs to be a string or an Identifier, got: </span><span class="si">{</span><span class="n">name</span><span class="o">.</span><span class="vm">__class__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="to_identifier-5281"><a href="#to_identifier-5281"><span class="linenos">5281</span></a> <span class="k">return</span> <span class="n">identifier</span> +</span><span id="to_identifier-5265"><a href="#to_identifier-5265"><span class="linenos">5265</span></a><span class="sd"> Args:</span> +</span><span id="to_identifier-5266"><a href="#to_identifier-5266"><span class="linenos">5266</span></a><span class="sd"> name: The name to turn into an identifier.</span> +</span><span id="to_identifier-5267"><a href="#to_identifier-5267"><span class="linenos">5267</span></a><span class="sd"> quoted: Whether or not force quote the identifier.</span> +</span><span id="to_identifier-5268"><a href="#to_identifier-5268"><span class="linenos">5268</span></a><span class="sd"> copy: Whether or not to copy a passed in Identefier node.</span> +</span><span id="to_identifier-5269"><a href="#to_identifier-5269"><span class="linenos">5269</span></a> +</span><span id="to_identifier-5270"><a href="#to_identifier-5270"><span class="linenos">5270</span></a><span class="sd"> Returns:</span> +</span><span id="to_identifier-5271"><a href="#to_identifier-5271"><span class="linenos">5271</span></a><span class="sd"> The identifier ast node.</span> +</span><span id="to_identifier-5272"><a href="#to_identifier-5272"><span class="linenos">5272</span></a><span class="sd"> """</span> +</span><span id="to_identifier-5273"><a href="#to_identifier-5273"><span class="linenos">5273</span></a> +</span><span id="to_identifier-5274"><a href="#to_identifier-5274"><span class="linenos">5274</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="to_identifier-5275"><a href="#to_identifier-5275"><span class="linenos">5275</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="to_identifier-5276"><a href="#to_identifier-5276"><span class="linenos">5276</span></a> +</span><span id="to_identifier-5277"><a href="#to_identifier-5277"><span class="linenos">5277</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">Identifier</span><span class="p">):</span> +</span><span id="to_identifier-5278"><a href="#to_identifier-5278"><span class="linenos">5278</span></a> <span class="n">identifier</span> <span class="o">=</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="to_identifier-5279"><a href="#to_identifier-5279"><span class="linenos">5279</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="to_identifier-5280"><a href="#to_identifier-5280"><span class="linenos">5280</span></a> <span class="n">identifier</span> <span class="o">=</span> <span class="n">Identifier</span><span class="p">(</span> +</span><span id="to_identifier-5281"><a href="#to_identifier-5281"><span class="linenos">5281</span></a> <span class="n">this</span><span class="o">=</span><span class="n">name</span><span class="p">,</span> +</span><span id="to_identifier-5282"><a href="#to_identifier-5282"><span class="linenos">5282</span></a> <span class="n">quoted</span><span class="o">=</span><span class="ow">not</span> <span class="n">SAFE_IDENTIFIER_RE</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> <span class="k">if</span> <span class="n">quoted</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">quoted</span><span class="p">,</span> +</span><span id="to_identifier-5283"><a href="#to_identifier-5283"><span class="linenos">5283</span></a> <span class="p">)</span> +</span><span id="to_identifier-5284"><a href="#to_identifier-5284"><span class="linenos">5284</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="to_identifier-5285"><a href="#to_identifier-5285"><span class="linenos">5285</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Name needs to be a string or an Identifier, got: </span><span class="si">{</span><span class="n">name</span><span class="o">.</span><span class="vm">__class__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="to_identifier-5286"><a href="#to_identifier-5286"><span class="linenos">5286</span></a> <span class="k">return</span> <span class="n">identifier</span> </span></pre></div> @@ -51023,23 +51151,23 @@ If an Expression instance is passed, this is used as-is.</li> </div> <a class="headerlink" href="#to_interval"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="to_interval-5287"><a href="#to_interval-5287"><span class="linenos">5287</span></a><span class="k">def</span> <span class="nf">to_interval</span><span class="p">(</span><span class="n">interval</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Literal</span><span class="p">)</span> <span class="o">-></span> <span class="n">Interval</span><span class="p">:</span> -</span><span id="to_interval-5288"><a href="#to_interval-5288"><span class="linenos">5288</span></a><span class="w"> </span><span class="sd">"""Builds an interval expression from a string like '1 day' or '5 months'."""</span> -</span><span id="to_interval-5289"><a href="#to_interval-5289"><span class="linenos">5289</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">interval</span><span class="p">,</span> <span class="n">Literal</span><span class="p">):</span> -</span><span id="to_interval-5290"><a href="#to_interval-5290"><span class="linenos">5290</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">interval</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> -</span><span id="to_interval-5291"><a href="#to_interval-5291"><span class="linenos">5291</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Invalid interval string."</span><span class="p">)</span> -</span><span id="to_interval-5292"><a href="#to_interval-5292"><span class="linenos">5292</span></a> -</span><span id="to_interval-5293"><a href="#to_interval-5293"><span class="linenos">5293</span></a> <span class="n">interval</span> <span class="o">=</span> <span class="n">interval</span><span class="o">.</span><span class="n">this</span> -</span><span id="to_interval-5294"><a href="#to_interval-5294"><span class="linenos">5294</span></a> -</span><span id="to_interval-5295"><a href="#to_interval-5295"><span class="linenos">5295</span></a> <span class="n">interval_parts</span> <span class="o">=</span> <span class="n">INTERVAL_STRING_RE</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">interval</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="to_interval-5296"><a href="#to_interval-5296"><span class="linenos">5296</span></a> -</span><span id="to_interval-5297"><a href="#to_interval-5297"><span class="linenos">5297</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">interval_parts</span><span class="p">:</span> -</span><span id="to_interval-5298"><a href="#to_interval-5298"><span class="linenos">5298</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Invalid interval string."</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="to_interval-5292"><a href="#to_interval-5292"><span class="linenos">5292</span></a><span class="k">def</span> <span class="nf">to_interval</span><span class="p">(</span><span class="n">interval</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Literal</span><span class="p">)</span> <span class="o">-></span> <span class="n">Interval</span><span class="p">:</span> +</span><span id="to_interval-5293"><a href="#to_interval-5293"><span class="linenos">5293</span></a><span class="w"> </span><span class="sd">"""Builds an interval expression from a string like '1 day' or '5 months'."""</span> +</span><span id="to_interval-5294"><a href="#to_interval-5294"><span class="linenos">5294</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">interval</span><span class="p">,</span> <span class="n">Literal</span><span class="p">):</span> +</span><span id="to_interval-5295"><a href="#to_interval-5295"><span class="linenos">5295</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">interval</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> +</span><span id="to_interval-5296"><a href="#to_interval-5296"><span class="linenos">5296</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Invalid interval string."</span><span class="p">)</span> +</span><span id="to_interval-5297"><a href="#to_interval-5297"><span class="linenos">5297</span></a> +</span><span id="to_interval-5298"><a href="#to_interval-5298"><span class="linenos">5298</span></a> <span class="n">interval</span> <span class="o">=</span> <span class="n">interval</span><span class="o">.</span><span class="n">this</span> </span><span id="to_interval-5299"><a href="#to_interval-5299"><span class="linenos">5299</span></a> -</span><span id="to_interval-5300"><a href="#to_interval-5300"><span class="linenos">5300</span></a> <span class="k">return</span> <span class="n">Interval</span><span class="p">(</span> -</span><span id="to_interval-5301"><a href="#to_interval-5301"><span class="linenos">5301</span></a> <span class="n">this</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">interval_parts</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)),</span> -</span><span id="to_interval-5302"><a href="#to_interval-5302"><span class="linenos">5302</span></a> <span class="n">unit</span><span class="o">=</span><span class="n">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">interval_parts</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">)),</span> -</span><span id="to_interval-5303"><a href="#to_interval-5303"><span class="linenos">5303</span></a> <span class="p">)</span> +</span><span id="to_interval-5300"><a href="#to_interval-5300"><span class="linenos">5300</span></a> <span class="n">interval_parts</span> <span class="o">=</span> <span class="n">INTERVAL_STRING_RE</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">interval</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="to_interval-5301"><a href="#to_interval-5301"><span class="linenos">5301</span></a> +</span><span id="to_interval-5302"><a href="#to_interval-5302"><span class="linenos">5302</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">interval_parts</span><span class="p">:</span> +</span><span id="to_interval-5303"><a href="#to_interval-5303"><span class="linenos">5303</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Invalid interval string."</span><span class="p">)</span> +</span><span id="to_interval-5304"><a href="#to_interval-5304"><span class="linenos">5304</span></a> +</span><span id="to_interval-5305"><a href="#to_interval-5305"><span class="linenos">5305</span></a> <span class="k">return</span> <span class="n">Interval</span><span class="p">(</span> +</span><span id="to_interval-5306"><a href="#to_interval-5306"><span class="linenos">5306</span></a> <span class="n">this</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">interval_parts</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)),</span> +</span><span id="to_interval-5307"><a href="#to_interval-5307"><span class="linenos">5307</span></a> <span class="n">unit</span><span class="o">=</span><span class="n">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">interval_parts</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">)),</span> +</span><span id="to_interval-5308"><a href="#to_interval-5308"><span class="linenos">5308</span></a> <span class="p">)</span> </span></pre></div> @@ -51059,32 +51187,32 @@ If an Expression instance is passed, this is used as-is.</li> </div> <a class="headerlink" href="#to_table"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="to_table-5316"><a href="#to_table-5316"><span class="linenos">5316</span></a><span class="k">def</span> <span class="nf">to_table</span><span class="p">(</span> -</span><span id="to_table-5317"><a href="#to_table-5317"><span class="linenos">5317</span></a> <span class="n">sql_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="nb">str</span> <span class="o">|</span> <span class="n">Table</span><span class="p">],</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> -</span><span id="to_table-5318"><a href="#to_table-5318"><span class="linenos">5318</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">Table</span><span class="p">]:</span> -</span><span id="to_table-5319"><a href="#to_table-5319"><span class="linenos">5319</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="to_table-5320"><a href="#to_table-5320"><span class="linenos">5320</span></a><span class="sd"> Create a table expression from a `[catalog].[schema].[table]` sql path. Catalog and schema are optional.</span> -</span><span id="to_table-5321"><a href="#to_table-5321"><span class="linenos">5321</span></a><span class="sd"> If a table is passed in then that table is returned.</span> -</span><span id="to_table-5322"><a href="#to_table-5322"><span class="linenos">5322</span></a> -</span><span id="to_table-5323"><a href="#to_table-5323"><span class="linenos">5323</span></a><span class="sd"> Args:</span> -</span><span id="to_table-5324"><a href="#to_table-5324"><span class="linenos">5324</span></a><span class="sd"> sql_path: a `[catalog].[schema].[table]` string.</span> -</span><span id="to_table-5325"><a href="#to_table-5325"><span class="linenos">5325</span></a><span class="sd"> dialect: the source dialect according to which the table name will be parsed.</span> -</span><span id="to_table-5326"><a href="#to_table-5326"><span class="linenos">5326</span></a><span class="sd"> kwargs: the kwargs to instantiate the resulting `Table` expression with.</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="to_table-5321"><a href="#to_table-5321"><span class="linenos">5321</span></a><span class="k">def</span> <span class="nf">to_table</span><span class="p">(</span> +</span><span id="to_table-5322"><a href="#to_table-5322"><span class="linenos">5322</span></a> <span class="n">sql_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="nb">str</span> <span class="o">|</span> <span class="n">Table</span><span class="p">],</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> +</span><span id="to_table-5323"><a href="#to_table-5323"><span class="linenos">5323</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">Table</span><span class="p">]:</span> +</span><span id="to_table-5324"><a href="#to_table-5324"><span class="linenos">5324</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="to_table-5325"><a href="#to_table-5325"><span class="linenos">5325</span></a><span class="sd"> Create a table expression from a `[catalog].[schema].[table]` sql path. Catalog and schema are optional.</span> +</span><span id="to_table-5326"><a href="#to_table-5326"><span class="linenos">5326</span></a><span class="sd"> If a table is passed in then that table is returned.</span> </span><span id="to_table-5327"><a href="#to_table-5327"><span class="linenos">5327</span></a> -</span><span id="to_table-5328"><a href="#to_table-5328"><span class="linenos">5328</span></a><span class="sd"> Returns:</span> -</span><span id="to_table-5329"><a href="#to_table-5329"><span class="linenos">5329</span></a><span class="sd"> A table expression.</span> -</span><span id="to_table-5330"><a href="#to_table-5330"><span class="linenos">5330</span></a><span class="sd"> """</span> -</span><span id="to_table-5331"><a href="#to_table-5331"><span class="linenos">5331</span></a> <span class="k">if</span> <span class="n">sql_path</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="n">Table</span><span class="p">):</span> -</span><span id="to_table-5332"><a href="#to_table-5332"><span class="linenos">5332</span></a> <span class="k">return</span> <span class="n">sql_path</span> -</span><span id="to_table-5333"><a href="#to_table-5333"><span class="linenos">5333</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="to_table-5334"><a href="#to_table-5334"><span class="linenos">5334</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid type provided for a table: </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">sql_path</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="to_table-5335"><a href="#to_table-5335"><span class="linenos">5335</span></a> -</span><span id="to_table-5336"><a href="#to_table-5336"><span class="linenos">5336</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> -</span><span id="to_table-5337"><a href="#to_table-5337"><span class="linenos">5337</span></a> <span class="k">if</span> <span class="n">table</span><span class="p">:</span> -</span><span id="to_table-5338"><a href="#to_table-5338"><span class="linenos">5338</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> -</span><span id="to_table-5339"><a href="#to_table-5339"><span class="linenos">5339</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> +</span><span id="to_table-5328"><a href="#to_table-5328"><span class="linenos">5328</span></a><span class="sd"> Args:</span> +</span><span id="to_table-5329"><a href="#to_table-5329"><span class="linenos">5329</span></a><span class="sd"> sql_path: a `[catalog].[schema].[table]` string.</span> +</span><span id="to_table-5330"><a href="#to_table-5330"><span class="linenos">5330</span></a><span class="sd"> dialect: the source dialect according to which the table name will be parsed.</span> +</span><span id="to_table-5331"><a href="#to_table-5331"><span class="linenos">5331</span></a><span class="sd"> kwargs: the kwargs to instantiate the resulting `Table` expression with.</span> +</span><span id="to_table-5332"><a href="#to_table-5332"><span class="linenos">5332</span></a> +</span><span id="to_table-5333"><a href="#to_table-5333"><span class="linenos">5333</span></a><span class="sd"> Returns:</span> +</span><span id="to_table-5334"><a href="#to_table-5334"><span class="linenos">5334</span></a><span class="sd"> A table expression.</span> +</span><span id="to_table-5335"><a href="#to_table-5335"><span class="linenos">5335</span></a><span class="sd"> """</span> +</span><span id="to_table-5336"><a href="#to_table-5336"><span class="linenos">5336</span></a> <span class="k">if</span> <span class="n">sql_path</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="n">Table</span><span class="p">):</span> +</span><span id="to_table-5337"><a href="#to_table-5337"><span class="linenos">5337</span></a> <span class="k">return</span> <span class="n">sql_path</span> +</span><span id="to_table-5338"><a href="#to_table-5338"><span class="linenos">5338</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="to_table-5339"><a href="#to_table-5339"><span class="linenos">5339</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid type provided for a table: </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">sql_path</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> </span><span id="to_table-5340"><a href="#to_table-5340"><span class="linenos">5340</span></a> -</span><span id="to_table-5341"><a href="#to_table-5341"><span class="linenos">5341</span></a> <span class="k">return</span> <span class="n">table</span> +</span><span id="to_table-5341"><a href="#to_table-5341"><span class="linenos">5341</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> +</span><span id="to_table-5342"><a href="#to_table-5342"><span class="linenos">5342</span></a> <span class="k">if</span> <span class="n">table</span><span class="p">:</span> +</span><span id="to_table-5343"><a href="#to_table-5343"><span class="linenos">5343</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> +</span><span id="to_table-5344"><a href="#to_table-5344"><span class="linenos">5344</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> +</span><span id="to_table-5345"><a href="#to_table-5345"><span class="linenos">5345</span></a> +</span><span id="to_table-5346"><a href="#to_table-5346"><span class="linenos">5346</span></a> <span class="k">return</span> <span class="n">table</span> </span></pre></div> @@ -51119,22 +51247,22 @@ If a table is passed in then that table is returned.</p> </div> <a class="headerlink" href="#to_column"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="to_column-5344"><a href="#to_column-5344"><span class="linenos">5344</span></a><span class="k">def</span> <span class="nf">to_column</span><span class="p">(</span><span class="n">sql_path</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Column</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="to_column-5345"><a href="#to_column-5345"><span class="linenos">5345</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="to_column-5346"><a href="#to_column-5346"><span class="linenos">5346</span></a><span class="sd"> Create a column from a `[table].[column]` sql path. Schema is optional.</span> -</span><span id="to_column-5347"><a href="#to_column-5347"><span class="linenos">5347</span></a> -</span><span id="to_column-5348"><a href="#to_column-5348"><span class="linenos">5348</span></a><span class="sd"> If a column is passed in then that column is returned.</span> -</span><span id="to_column-5349"><a href="#to_column-5349"><span class="linenos">5349</span></a> -</span><span id="to_column-5350"><a href="#to_column-5350"><span class="linenos">5350</span></a><span class="sd"> Args:</span> -</span><span id="to_column-5351"><a href="#to_column-5351"><span class="linenos">5351</span></a><span class="sd"> sql_path: `[table].[column]` string</span> -</span><span id="to_column-5352"><a href="#to_column-5352"><span class="linenos">5352</span></a><span class="sd"> Returns:</span> -</span><span id="to_column-5353"><a href="#to_column-5353"><span class="linenos">5353</span></a><span class="sd"> Table: A column expression</span> -</span><span id="to_column-5354"><a href="#to_column-5354"><span class="linenos">5354</span></a><span class="sd"> """</span> -</span><span id="to_column-5355"><a href="#to_column-5355"><span class="linenos">5355</span></a> <span class="k">if</span> <span class="n">sql_path</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="n">Column</span><span class="p">):</span> -</span><span id="to_column-5356"><a href="#to_column-5356"><span class="linenos">5356</span></a> <span class="k">return</span> <span class="n">sql_path</span> -</span><span id="to_column-5357"><a href="#to_column-5357"><span class="linenos">5357</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="to_column-5358"><a href="#to_column-5358"><span class="linenos">5358</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid type provided for column: </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">sql_path</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="to_column-5359"><a href="#to_column-5359"><span class="linenos">5359</span></a> <span class="k">return</span> <span class="n">column</span><span class="p">(</span><span class="o">*</span><span class="nb">reversed</span><span class="p">(</span><span class="n">sql_path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"."</span><span class="p">)),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="c1"># type: ignore</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="to_column-5349"><a href="#to_column-5349"><span class="linenos">5349</span></a><span class="k">def</span> <span class="nf">to_column</span><span class="p">(</span><span class="n">sql_path</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Column</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="to_column-5350"><a href="#to_column-5350"><span class="linenos">5350</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="to_column-5351"><a href="#to_column-5351"><span class="linenos">5351</span></a><span class="sd"> Create a column from a `[table].[column]` sql path. Schema is optional.</span> +</span><span id="to_column-5352"><a href="#to_column-5352"><span class="linenos">5352</span></a> +</span><span id="to_column-5353"><a href="#to_column-5353"><span class="linenos">5353</span></a><span class="sd"> If a column is passed in then that column is returned.</span> +</span><span id="to_column-5354"><a href="#to_column-5354"><span class="linenos">5354</span></a> +</span><span id="to_column-5355"><a href="#to_column-5355"><span class="linenos">5355</span></a><span class="sd"> Args:</span> +</span><span id="to_column-5356"><a href="#to_column-5356"><span class="linenos">5356</span></a><span class="sd"> sql_path: `[table].[column]` string</span> +</span><span id="to_column-5357"><a href="#to_column-5357"><span class="linenos">5357</span></a><span class="sd"> Returns:</span> +</span><span id="to_column-5358"><a href="#to_column-5358"><span class="linenos">5358</span></a><span class="sd"> Table: A column expression</span> +</span><span id="to_column-5359"><a href="#to_column-5359"><span class="linenos">5359</span></a><span class="sd"> """</span> +</span><span id="to_column-5360"><a href="#to_column-5360"><span class="linenos">5360</span></a> <span class="k">if</span> <span class="n">sql_path</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="n">Column</span><span class="p">):</span> +</span><span id="to_column-5361"><a href="#to_column-5361"><span class="linenos">5361</span></a> <span class="k">return</span> <span class="n">sql_path</span> +</span><span id="to_column-5362"><a href="#to_column-5362"><span class="linenos">5362</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sql_path</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="to_column-5363"><a href="#to_column-5363"><span class="linenos">5363</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid type provided for column: </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">sql_path</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="to_column-5364"><a href="#to_column-5364"><span class="linenos">5364</span></a> <span class="k">return</span> <span class="n">column</span><span class="p">(</span><span class="o">*</span><span class="nb">reversed</span><span class="p">(</span><span class="n">sql_path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"."</span><span class="p">)),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="c1"># type: ignore</span> </span></pre></div> @@ -51168,61 +51296,61 @@ If a table is passed in then that table is returned.</p> </div> <a class="headerlink" href="#alias_"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="alias_-5362"><a href="#alias_-5362"><span class="linenos">5362</span></a><span class="k">def</span> <span class="nf">alias_</span><span class="p">(</span> -</span><span id="alias_-5363"><a href="#alias_-5363"><span class="linenos">5363</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="alias_-5364"><a href="#alias_-5364"><span class="linenos">5364</span></a> <span class="n">alias</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">,</span> -</span><span id="alias_-5365"><a href="#alias_-5365"><span class="linenos">5365</span></a> <span class="n">table</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="alias_-5366"><a href="#alias_-5366"><span class="linenos">5366</span></a> <span class="n">quoted</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="alias_-5367"><a href="#alias_-5367"><span class="linenos">5367</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="alias_-5368"><a href="#alias_-5368"><span class="linenos">5368</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="alias_-5369"><a href="#alias_-5369"><span class="linenos">5369</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="alias_-5370"><a href="#alias_-5370"><span class="linenos">5370</span></a><span class="p">):</span> -</span><span id="alias_-5371"><a href="#alias_-5371"><span class="linenos">5371</span></a><span class="w"> </span><span class="sd">"""Create an Alias expression.</span> -</span><span id="alias_-5372"><a href="#alias_-5372"><span class="linenos">5372</span></a> -</span><span id="alias_-5373"><a href="#alias_-5373"><span class="linenos">5373</span></a><span class="sd"> Example:</span> -</span><span id="alias_-5374"><a href="#alias_-5374"><span class="linenos">5374</span></a><span class="sd"> >>> alias_('foo', 'bar').sql()</span> -</span><span id="alias_-5375"><a href="#alias_-5375"><span class="linenos">5375</span></a><span class="sd"> 'foo AS bar'</span> -</span><span id="alias_-5376"><a href="#alias_-5376"><span class="linenos">5376</span></a> -</span><span id="alias_-5377"><a href="#alias_-5377"><span class="linenos">5377</span></a><span class="sd"> >>> alias_('(select 1, 2)', 'bar', table=['a', 'b']).sql()</span> -</span><span id="alias_-5378"><a href="#alias_-5378"><span class="linenos">5378</span></a><span class="sd"> '(SELECT 1, 2) AS bar(a, b)'</span> -</span><span id="alias_-5379"><a href="#alias_-5379"><span class="linenos">5379</span></a> -</span><span id="alias_-5380"><a href="#alias_-5380"><span class="linenos">5380</span></a><span class="sd"> Args:</span> -</span><span id="alias_-5381"><a href="#alias_-5381"><span class="linenos">5381</span></a><span class="sd"> expression: the SQL code strings to parse.</span> -</span><span id="alias_-5382"><a href="#alias_-5382"><span class="linenos">5382</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> -</span><span id="alias_-5383"><a href="#alias_-5383"><span class="linenos">5383</span></a><span class="sd"> alias: the alias name to use. If the name has</span> -</span><span id="alias_-5384"><a href="#alias_-5384"><span class="linenos">5384</span></a><span class="sd"> special characters it is quoted.</span> -</span><span id="alias_-5385"><a href="#alias_-5385"><span class="linenos">5385</span></a><span class="sd"> table: Whether or not to create a table alias, can also be a list of columns.</span> -</span><span id="alias_-5386"><a href="#alias_-5386"><span class="linenos">5386</span></a><span class="sd"> quoted: whether or not to quote the alias</span> -</span><span id="alias_-5387"><a href="#alias_-5387"><span class="linenos">5387</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="alias_-5388"><a href="#alias_-5388"><span class="linenos">5388</span></a><span class="sd"> copy: Whether or not to copy the expression.</span> -</span><span id="alias_-5389"><a href="#alias_-5389"><span class="linenos">5389</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> -</span><span id="alias_-5390"><a href="#alias_-5390"><span class="linenos">5390</span></a> -</span><span id="alias_-5391"><a href="#alias_-5391"><span class="linenos">5391</span></a><span class="sd"> Returns:</span> -</span><span id="alias_-5392"><a href="#alias_-5392"><span class="linenos">5392</span></a><span class="sd"> Alias: the aliased expression</span> -</span><span id="alias_-5393"><a href="#alias_-5393"><span class="linenos">5393</span></a><span class="sd"> """</span> -</span><span id="alias_-5394"><a href="#alias_-5394"><span class="linenos">5394</span></a> <span class="n">exp</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="alias_-5395"><a href="#alias_-5395"><span class="linenos">5395</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">)</span> -</span><span id="alias_-5396"><a href="#alias_-5396"><span class="linenos">5396</span></a> -</span><span id="alias_-5397"><a href="#alias_-5397"><span class="linenos">5397</span></a> <span class="k">if</span> <span class="n">table</span><span class="p">:</span> -</span><span id="alias_-5398"><a href="#alias_-5398"><span class="linenos">5398</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> -</span><span id="alias_-5399"><a href="#alias_-5399"><span class="linenos">5399</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="n">table_alias</span><span class="p">)</span> -</span><span id="alias_-5400"><a href="#alias_-5400"><span class="linenos">5400</span></a> -</span><span id="alias_-5401"><a href="#alias_-5401"><span class="linenos">5401</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="nb">bool</span><span class="p">):</span> -</span><span id="alias_-5402"><a href="#alias_-5402"><span class="linenos">5402</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">table</span><span class="p">:</span> -</span><span id="alias_-5403"><a href="#alias_-5403"><span class="linenos">5403</span></a> <span class="n">table_alias</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">to_identifier</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">))</span> -</span><span id="alias_-5404"><a href="#alias_-5404"><span class="linenos">5404</span></a> -</span><span id="alias_-5405"><a href="#alias_-5405"><span class="linenos">5405</span></a> <span class="k">return</span> <span class="n">exp</span> -</span><span id="alias_-5406"><a href="#alias_-5406"><span class="linenos">5406</span></a> -</span><span id="alias_-5407"><a href="#alias_-5407"><span class="linenos">5407</span></a> <span class="c1"># We don't set the "alias" arg for Window expressions, because that would add an IDENTIFIER node in</span> -</span><span id="alias_-5408"><a href="#alias_-5408"><span class="linenos">5408</span></a> <span class="c1"># the AST, representing a "named_window" [1] construct (eg. bigquery). What we want is an ALIAS node</span> -</span><span id="alias_-5409"><a href="#alias_-5409"><span class="linenos">5409</span></a> <span class="c1"># for the complete Window expression.</span> -</span><span id="alias_-5410"><a href="#alias_-5410"><span class="linenos">5410</span></a> <span class="c1">#</span> -</span><span id="alias_-5411"><a href="#alias_-5411"><span class="linenos">5411</span></a> <span class="c1"># [1]: https://cloud.google.com/bigquery/docs/reference/standard-sql/window-function-calls</span> -</span><span id="alias_-5412"><a href="#alias_-5412"><span class="linenos">5412</span></a> -</span><span id="alias_-5413"><a href="#alias_-5413"><span class="linenos">5413</span></a> <span class="k">if</span> <span class="s2">"alias"</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">arg_types</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">exp</span><span class="p">,</span> <span class="n">Window</span><span class="p">):</span> -</span><span id="alias_-5414"><a href="#alias_-5414"><span class="linenos">5414</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="n">alias</span><span class="p">)</span> -</span><span id="alias_-5415"><a href="#alias_-5415"><span class="linenos">5415</span></a> <span class="k">return</span> <span class="n">exp</span> -</span><span id="alias_-5416"><a href="#alias_-5416"><span class="linenos">5416</span></a> <span class="k">return</span> <span class="n">Alias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="alias_-5367"><a href="#alias_-5367"><span class="linenos">5367</span></a><span class="k">def</span> <span class="nf">alias_</span><span class="p">(</span> +</span><span id="alias_-5368"><a href="#alias_-5368"><span class="linenos">5368</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="alias_-5369"><a href="#alias_-5369"><span class="linenos">5369</span></a> <span class="n">alias</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">,</span> +</span><span id="alias_-5370"><a href="#alias_-5370"><span class="linenos">5370</span></a> <span class="n">table</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="alias_-5371"><a href="#alias_-5371"><span class="linenos">5371</span></a> <span class="n">quoted</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="alias_-5372"><a href="#alias_-5372"><span class="linenos">5372</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="alias_-5373"><a href="#alias_-5373"><span class="linenos">5373</span></a> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="alias_-5374"><a href="#alias_-5374"><span class="linenos">5374</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="alias_-5375"><a href="#alias_-5375"><span class="linenos">5375</span></a><span class="p">):</span> +</span><span id="alias_-5376"><a href="#alias_-5376"><span class="linenos">5376</span></a><span class="w"> </span><span class="sd">"""Create an Alias expression.</span> +</span><span id="alias_-5377"><a href="#alias_-5377"><span class="linenos">5377</span></a> +</span><span id="alias_-5378"><a href="#alias_-5378"><span class="linenos">5378</span></a><span class="sd"> Example:</span> +</span><span id="alias_-5379"><a href="#alias_-5379"><span class="linenos">5379</span></a><span class="sd"> >>> alias_('foo', 'bar').sql()</span> +</span><span id="alias_-5380"><a href="#alias_-5380"><span class="linenos">5380</span></a><span class="sd"> 'foo AS bar'</span> +</span><span id="alias_-5381"><a href="#alias_-5381"><span class="linenos">5381</span></a> +</span><span id="alias_-5382"><a href="#alias_-5382"><span class="linenos">5382</span></a><span class="sd"> >>> alias_('(select 1, 2)', 'bar', table=['a', 'b']).sql()</span> +</span><span id="alias_-5383"><a href="#alias_-5383"><span class="linenos">5383</span></a><span class="sd"> '(SELECT 1, 2) AS bar(a, b)'</span> +</span><span id="alias_-5384"><a href="#alias_-5384"><span class="linenos">5384</span></a> +</span><span id="alias_-5385"><a href="#alias_-5385"><span class="linenos">5385</span></a><span class="sd"> Args:</span> +</span><span id="alias_-5386"><a href="#alias_-5386"><span class="linenos">5386</span></a><span class="sd"> expression: the SQL code strings to parse.</span> +</span><span id="alias_-5387"><a href="#alias_-5387"><span class="linenos">5387</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> +</span><span id="alias_-5388"><a href="#alias_-5388"><span class="linenos">5388</span></a><span class="sd"> alias: the alias name to use. If the name has</span> +</span><span id="alias_-5389"><a href="#alias_-5389"><span class="linenos">5389</span></a><span class="sd"> special characters it is quoted.</span> +</span><span id="alias_-5390"><a href="#alias_-5390"><span class="linenos">5390</span></a><span class="sd"> table: Whether or not to create a table alias, can also be a list of columns.</span> +</span><span id="alias_-5391"><a href="#alias_-5391"><span class="linenos">5391</span></a><span class="sd"> quoted: whether or not to quote the alias</span> +</span><span id="alias_-5392"><a href="#alias_-5392"><span class="linenos">5392</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="alias_-5393"><a href="#alias_-5393"><span class="linenos">5393</span></a><span class="sd"> copy: Whether or not to copy the expression.</span> +</span><span id="alias_-5394"><a href="#alias_-5394"><span class="linenos">5394</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> +</span><span id="alias_-5395"><a href="#alias_-5395"><span class="linenos">5395</span></a> +</span><span id="alias_-5396"><a href="#alias_-5396"><span class="linenos">5396</span></a><span class="sd"> Returns:</span> +</span><span id="alias_-5397"><a href="#alias_-5397"><span class="linenos">5397</span></a><span class="sd"> Alias: the aliased expression</span> +</span><span id="alias_-5398"><a href="#alias_-5398"><span class="linenos">5398</span></a><span class="sd"> """</span> +</span><span id="alias_-5399"><a href="#alias_-5399"><span class="linenos">5399</span></a> <span class="n">exp</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="alias_-5400"><a href="#alias_-5400"><span class="linenos">5400</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">)</span> +</span><span id="alias_-5401"><a href="#alias_-5401"><span class="linenos">5401</span></a> +</span><span id="alias_-5402"><a href="#alias_-5402"><span class="linenos">5402</span></a> <span class="k">if</span> <span class="n">table</span><span class="p">:</span> +</span><span id="alias_-5403"><a href="#alias_-5403"><span class="linenos">5403</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> +</span><span id="alias_-5404"><a href="#alias_-5404"><span class="linenos">5404</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="n">table_alias</span><span class="p">)</span> +</span><span id="alias_-5405"><a href="#alias_-5405"><span class="linenos">5405</span></a> +</span><span id="alias_-5406"><a href="#alias_-5406"><span class="linenos">5406</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="nb">bool</span><span class="p">):</span> +</span><span id="alias_-5407"><a href="#alias_-5407"><span class="linenos">5407</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">table</span><span class="p">:</span> +</span><span id="alias_-5408"><a href="#alias_-5408"><span class="linenos">5408</span></a> <span class="n">table_alias</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">to_identifier</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">))</span> +</span><span id="alias_-5409"><a href="#alias_-5409"><span class="linenos">5409</span></a> +</span><span id="alias_-5410"><a href="#alias_-5410"><span class="linenos">5410</span></a> <span class="k">return</span> <span class="n">exp</span> +</span><span id="alias_-5411"><a href="#alias_-5411"><span class="linenos">5411</span></a> +</span><span id="alias_-5412"><a href="#alias_-5412"><span class="linenos">5412</span></a> <span class="c1"># We don't set the "alias" arg for Window expressions, because that would add an IDENTIFIER node in</span> +</span><span id="alias_-5413"><a href="#alias_-5413"><span class="linenos">5413</span></a> <span class="c1"># the AST, representing a "named_window" [1] construct (eg. bigquery). What we want is an ALIAS node</span> +</span><span id="alias_-5414"><a href="#alias_-5414"><span class="linenos">5414</span></a> <span class="c1"># for the complete Window expression.</span> +</span><span id="alias_-5415"><a href="#alias_-5415"><span class="linenos">5415</span></a> <span class="c1">#</span> +</span><span id="alias_-5416"><a href="#alias_-5416"><span class="linenos">5416</span></a> <span class="c1"># [1]: https://cloud.google.com/bigquery/docs/reference/standard-sql/window-function-calls</span> +</span><span id="alias_-5417"><a href="#alias_-5417"><span class="linenos">5417</span></a> +</span><span id="alias_-5418"><a href="#alias_-5418"><span class="linenos">5418</span></a> <span class="k">if</span> <span class="s2">"alias"</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">arg_types</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">exp</span><span class="p">,</span> <span class="n">Window</span><span class="p">):</span> +</span><span id="alias_-5419"><a href="#alias_-5419"><span class="linenos">5419</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="n">alias</span><span class="p">)</span> +</span><span id="alias_-5420"><a href="#alias_-5420"><span class="linenos">5420</span></a> <span class="k">return</span> <span class="n">exp</span> +</span><span id="alias_-5421"><a href="#alias_-5421"><span class="linenos">5421</span></a> <span class="k">return</span> <span class="n">Alias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> </span></pre></div> @@ -51278,32 +51406,32 @@ special characters it is quoted.</li> </div> <a class="headerlink" href="#subquery"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="subquery-5419"><a href="#subquery-5419"><span class="linenos">5419</span></a><span class="k">def</span> <span class="nf">subquery</span><span class="p">(</span> -</span><span id="subquery-5420"><a href="#subquery-5420"><span class="linenos">5420</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> -</span><span id="subquery-5421"><a href="#subquery-5421"><span class="linenos">5421</span></a> <span class="n">alias</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">Identifier</span> <span class="o">|</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="subquery-5422"><a href="#subquery-5422"><span class="linenos">5422</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="subquery-5423"><a href="#subquery-5423"><span class="linenos">5423</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> -</span><span id="subquery-5424"><a href="#subquery-5424"><span class="linenos">5424</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> -</span><span id="subquery-5425"><a href="#subquery-5425"><span class="linenos">5425</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="subquery-5426"><a href="#subquery-5426"><span class="linenos">5426</span></a><span class="sd"> Build a subquery expression.</span> -</span><span id="subquery-5427"><a href="#subquery-5427"><span class="linenos">5427</span></a> -</span><span id="subquery-5428"><a href="#subquery-5428"><span class="linenos">5428</span></a><span class="sd"> Example:</span> -</span><span id="subquery-5429"><a href="#subquery-5429"><span class="linenos">5429</span></a><span class="sd"> >>> subquery('select x from tbl', 'bar').select('x').sql()</span> -</span><span id="subquery-5430"><a href="#subquery-5430"><span class="linenos">5430</span></a><span class="sd"> 'SELECT x FROM (SELECT x FROM tbl) AS bar'</span> -</span><span id="subquery-5431"><a href="#subquery-5431"><span class="linenos">5431</span></a> -</span><span id="subquery-5432"><a href="#subquery-5432"><span class="linenos">5432</span></a><span class="sd"> Args:</span> -</span><span id="subquery-5433"><a href="#subquery-5433"><span class="linenos">5433</span></a><span class="sd"> expression: the SQL code strings to parse.</span> -</span><span id="subquery-5434"><a href="#subquery-5434"><span class="linenos">5434</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> -</span><span id="subquery-5435"><a href="#subquery-5435"><span class="linenos">5435</span></a><span class="sd"> alias: the alias name to use.</span> -</span><span id="subquery-5436"><a href="#subquery-5436"><span class="linenos">5436</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> -</span><span id="subquery-5437"><a href="#subquery-5437"><span class="linenos">5437</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> -</span><span id="subquery-5438"><a href="#subquery-5438"><span class="linenos">5438</span></a> -</span><span id="subquery-5439"><a href="#subquery-5439"><span class="linenos">5439</span></a><span class="sd"> Returns:</span> -</span><span id="subquery-5440"><a href="#subquery-5440"><span class="linenos">5440</span></a><span class="sd"> A new Select instance with the subquery expression included.</span> -</span><span id="subquery-5441"><a href="#subquery-5441"><span class="linenos">5441</span></a><span class="sd"> """</span> -</span><span id="subquery-5442"><a href="#subquery-5442"><span class="linenos">5442</span></a> -</span><span id="subquery-5443"><a href="#subquery-5443"><span class="linenos">5443</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">alias</span><span class="p">)</span> -</span><span id="subquery-5444"><a href="#subquery-5444"><span class="linenos">5444</span></a> <span class="k">return</span> <span class="n">Select</span><span class="p">()</span><span class="o">.</span><span class="n">from_</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="subquery-5424"><a href="#subquery-5424"><span class="linenos">5424</span></a><span class="k">def</span> <span class="nf">subquery</span><span class="p">(</span> +</span><span id="subquery-5425"><a href="#subquery-5425"><span class="linenos">5425</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> +</span><span id="subquery-5426"><a href="#subquery-5426"><span class="linenos">5426</span></a> <span class="n">alias</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">Identifier</span> <span class="o">|</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="subquery-5427"><a href="#subquery-5427"><span class="linenos">5427</span></a> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="subquery-5428"><a href="#subquery-5428"><span class="linenos">5428</span></a> <span class="o">**</span><span class="n">opts</span><span class="p">,</span> +</span><span id="subquery-5429"><a href="#subquery-5429"><span class="linenos">5429</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Select</span><span class="p">:</span> +</span><span id="subquery-5430"><a href="#subquery-5430"><span class="linenos">5430</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="subquery-5431"><a href="#subquery-5431"><span class="linenos">5431</span></a><span class="sd"> Build a subquery expression.</span> +</span><span id="subquery-5432"><a href="#subquery-5432"><span class="linenos">5432</span></a> +</span><span id="subquery-5433"><a href="#subquery-5433"><span class="linenos">5433</span></a><span class="sd"> Example:</span> +</span><span id="subquery-5434"><a href="#subquery-5434"><span class="linenos">5434</span></a><span class="sd"> >>> subquery('select x from tbl', 'bar').select('x').sql()</span> +</span><span id="subquery-5435"><a href="#subquery-5435"><span class="linenos">5435</span></a><span class="sd"> 'SELECT x FROM (SELECT x FROM tbl) AS bar'</span> +</span><span id="subquery-5436"><a href="#subquery-5436"><span class="linenos">5436</span></a> +</span><span id="subquery-5437"><a href="#subquery-5437"><span class="linenos">5437</span></a><span class="sd"> Args:</span> +</span><span id="subquery-5438"><a href="#subquery-5438"><span class="linenos">5438</span></a><span class="sd"> expression: the SQL code strings to parse.</span> +</span><span id="subquery-5439"><a href="#subquery-5439"><span class="linenos">5439</span></a><span class="sd"> If an Expression instance is passed, this is used as-is.</span> +</span><span id="subquery-5440"><a href="#subquery-5440"><span class="linenos">5440</span></a><span class="sd"> alias: the alias name to use.</span> +</span><span id="subquery-5441"><a href="#subquery-5441"><span class="linenos">5441</span></a><span class="sd"> dialect: the dialect used to parse the input expression.</span> +</span><span id="subquery-5442"><a href="#subquery-5442"><span class="linenos">5442</span></a><span class="sd"> **opts: other options to use to parse the input expressions.</span> +</span><span id="subquery-5443"><a href="#subquery-5443"><span class="linenos">5443</span></a> +</span><span id="subquery-5444"><a href="#subquery-5444"><span class="linenos">5444</span></a><span class="sd"> Returns:</span> +</span><span id="subquery-5445"><a href="#subquery-5445"><span class="linenos">5445</span></a><span class="sd"> A new Select instance with the subquery expression included.</span> +</span><span id="subquery-5446"><a href="#subquery-5446"><span class="linenos">5446</span></a><span class="sd"> """</span> +</span><span id="subquery-5447"><a href="#subquery-5447"><span class="linenos">5447</span></a> +</span><span id="subquery-5448"><a href="#subquery-5448"><span class="linenos">5448</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">alias</span><span class="p">)</span> +</span><span id="subquery-5449"><a href="#subquery-5449"><span class="linenos">5449</span></a> <span class="k">return</span> <span class="n">Select</span><span class="p">()</span><span class="o">.</span><span class="n">from_</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> </span></pre></div> @@ -51349,32 +51477,32 @@ If an Expression instance is passed, this is used as-is.</li> </div> <a class="headerlink" href="#column"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="column-5447"><a href="#column-5447"><span class="linenos">5447</span></a><span class="k">def</span> <span class="nf">column</span><span class="p">(</span> -</span><span id="column-5448"><a href="#column-5448"><span class="linenos">5448</span></a> <span class="n">col</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">,</span> -</span><span id="column-5449"><a href="#column-5449"><span class="linenos">5449</span></a> <span class="n">table</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="column-5450"><a href="#column-5450"><span class="linenos">5450</span></a> <span class="n">db</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="column-5451"><a href="#column-5451"><span class="linenos">5451</span></a> <span class="n">catalog</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="column-5452"><a href="#column-5452"><span class="linenos">5452</span></a> <span class="n">quoted</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="column-5453"><a href="#column-5453"><span class="linenos">5453</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> -</span><span id="column-5454"><a href="#column-5454"><span class="linenos">5454</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="column-5455"><a href="#column-5455"><span class="linenos">5455</span></a><span class="sd"> Build a Column.</span> -</span><span id="column-5456"><a href="#column-5456"><span class="linenos">5456</span></a> -</span><span id="column-5457"><a href="#column-5457"><span class="linenos">5457</span></a><span class="sd"> Args:</span> -</span><span id="column-5458"><a href="#column-5458"><span class="linenos">5458</span></a><span class="sd"> col: Column name.</span> -</span><span id="column-5459"><a href="#column-5459"><span class="linenos">5459</span></a><span class="sd"> table: Table name.</span> -</span><span id="column-5460"><a href="#column-5460"><span class="linenos">5460</span></a><span class="sd"> db: Database name.</span> -</span><span id="column-5461"><a href="#column-5461"><span class="linenos">5461</span></a><span class="sd"> catalog: Catalog name.</span> -</span><span id="column-5462"><a href="#column-5462"><span class="linenos">5462</span></a><span class="sd"> quoted: Whether to force quotes on the column's identifiers.</span> -</span><span id="column-5463"><a href="#column-5463"><span class="linenos">5463</span></a> -</span><span id="column-5464"><a href="#column-5464"><span class="linenos">5464</span></a><span class="sd"> Returns:</span> -</span><span id="column-5465"><a href="#column-5465"><span class="linenos">5465</span></a><span class="sd"> The new Column instance.</span> -</span><span id="column-5466"><a href="#column-5466"><span class="linenos">5466</span></a><span class="sd"> """</span> -</span><span id="column-5467"><a href="#column-5467"><span class="linenos">5467</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span> -</span><span id="column-5468"><a href="#column-5468"><span class="linenos">5468</span></a> <span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">col</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> -</span><span id="column-5469"><a href="#column-5469"><span class="linenos">5469</span></a> <span class="n">table</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> -</span><span id="column-5470"><a href="#column-5470"><span class="linenos">5470</span></a> <span class="n">db</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">db</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> -</span><span id="column-5471"><a href="#column-5471"><span class="linenos">5471</span></a> <span class="n">catalog</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">catalog</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> -</span><span id="column-5472"><a href="#column-5472"><span class="linenos">5472</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="column-5452"><a href="#column-5452"><span class="linenos">5452</span></a><span class="k">def</span> <span class="nf">column</span><span class="p">(</span> +</span><span id="column-5453"><a href="#column-5453"><span class="linenos">5453</span></a> <span class="n">col</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">,</span> +</span><span id="column-5454"><a href="#column-5454"><span class="linenos">5454</span></a> <span class="n">table</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="column-5455"><a href="#column-5455"><span class="linenos">5455</span></a> <span class="n">db</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="column-5456"><a href="#column-5456"><span class="linenos">5456</span></a> <span class="n">catalog</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">Identifier</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="column-5457"><a href="#column-5457"><span class="linenos">5457</span></a> <span class="n">quoted</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="column-5458"><a href="#column-5458"><span class="linenos">5458</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Column</span><span class="p">:</span> +</span><span id="column-5459"><a href="#column-5459"><span class="linenos">5459</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="column-5460"><a href="#column-5460"><span class="linenos">5460</span></a><span class="sd"> Build a Column.</span> +</span><span id="column-5461"><a href="#column-5461"><span class="linenos">5461</span></a> +</span><span id="column-5462"><a href="#column-5462"><span class="linenos">5462</span></a><span class="sd"> Args:</span> +</span><span id="column-5463"><a href="#column-5463"><span class="linenos">5463</span></a><span class="sd"> col: Column name.</span> +</span><span id="column-5464"><a href="#column-5464"><span class="linenos">5464</span></a><span class="sd"> table: Table name.</span> +</span><span id="column-5465"><a href="#column-5465"><span class="linenos">5465</span></a><span class="sd"> db: Database name.</span> +</span><span id="column-5466"><a href="#column-5466"><span class="linenos">5466</span></a><span class="sd"> catalog: Catalog name.</span> +</span><span id="column-5467"><a href="#column-5467"><span class="linenos">5467</span></a><span class="sd"> quoted: Whether to force quotes on the column's identifiers.</span> +</span><span id="column-5468"><a href="#column-5468"><span class="linenos">5468</span></a> +</span><span id="column-5469"><a href="#column-5469"><span class="linenos">5469</span></a><span class="sd"> Returns:</span> +</span><span id="column-5470"><a href="#column-5470"><span class="linenos">5470</span></a><span class="sd"> The new Column instance.</span> +</span><span id="column-5471"><a href="#column-5471"><span class="linenos">5471</span></a><span class="sd"> """</span> +</span><span id="column-5472"><a href="#column-5472"><span class="linenos">5472</span></a> <span class="k">return</span> <span class="n">Column</span><span class="p">(</span> +</span><span id="column-5473"><a href="#column-5473"><span class="linenos">5473</span></a> <span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">col</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> +</span><span id="column-5474"><a href="#column-5474"><span class="linenos">5474</span></a> <span class="n">table</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> +</span><span id="column-5475"><a href="#column-5475"><span class="linenos">5475</span></a> <span class="n">db</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">db</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> +</span><span id="column-5476"><a href="#column-5476"><span class="linenos">5476</span></a> <span class="n">catalog</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">catalog</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> +</span><span id="column-5477"><a href="#column-5477"><span class="linenos">5477</span></a> <span class="p">)</span> </span></pre></div> @@ -51410,22 +51538,22 @@ If an Expression instance is passed, this is used as-is.</li> </div> <a class="headerlink" href="#cast"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="cast-5475"><a href="#cast-5475"><span class="linenos">5475</span></a><span class="k">def</span> <span class="nf">cast</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">to</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Cast</span><span class="p">:</span> -</span><span id="cast-5476"><a href="#cast-5476"><span class="linenos">5476</span></a><span class="w"> </span><span class="sd">"""Cast an expression to a data type.</span> -</span><span id="cast-5477"><a href="#cast-5477"><span class="linenos">5477</span></a> -</span><span id="cast-5478"><a href="#cast-5478"><span class="linenos">5478</span></a><span class="sd"> Example:</span> -</span><span id="cast-5479"><a href="#cast-5479"><span class="linenos">5479</span></a><span class="sd"> >>> cast('x + 1', 'int').sql()</span> -</span><span id="cast-5480"><a href="#cast-5480"><span class="linenos">5480</span></a><span class="sd"> 'CAST(x + 1 AS INT)'</span> -</span><span id="cast-5481"><a href="#cast-5481"><span class="linenos">5481</span></a> -</span><span id="cast-5482"><a href="#cast-5482"><span class="linenos">5482</span></a><span class="sd"> Args:</span> -</span><span id="cast-5483"><a href="#cast-5483"><span class="linenos">5483</span></a><span class="sd"> expression: The expression to cast.</span> -</span><span id="cast-5484"><a href="#cast-5484"><span class="linenos">5484</span></a><span class="sd"> to: The datatype to cast to.</span> -</span><span id="cast-5485"><a href="#cast-5485"><span class="linenos">5485</span></a> -</span><span id="cast-5486"><a href="#cast-5486"><span class="linenos">5486</span></a><span class="sd"> Returns:</span> -</span><span id="cast-5487"><a href="#cast-5487"><span class="linenos">5487</span></a><span class="sd"> The new Cast instance.</span> -</span><span id="cast-5488"><a href="#cast-5488"><span class="linenos">5488</span></a><span class="sd"> """</span> -</span><span id="cast-5489"><a href="#cast-5489"><span class="linenos">5489</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> -</span><span id="cast-5490"><a href="#cast-5490"><span class="linenos">5490</span></a> <span class="k">return</span> <span class="n">Cast</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">to</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="n">to</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="cast-5480"><a href="#cast-5480"><span class="linenos">5480</span></a><span class="k">def</span> <span class="nf">cast</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">ExpOrStr</span><span class="p">,</span> <span class="n">to</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">DataType</span> <span class="o">|</span> <span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> <span class="o">-></span> <span class="n">Cast</span><span class="p">:</span> +</span><span id="cast-5481"><a href="#cast-5481"><span class="linenos">5481</span></a><span class="w"> </span><span class="sd">"""Cast an expression to a data type.</span> +</span><span id="cast-5482"><a href="#cast-5482"><span class="linenos">5482</span></a> +</span><span id="cast-5483"><a href="#cast-5483"><span class="linenos">5483</span></a><span class="sd"> Example:</span> +</span><span id="cast-5484"><a href="#cast-5484"><span class="linenos">5484</span></a><span class="sd"> >>> cast('x + 1', 'int').sql()</span> +</span><span id="cast-5485"><a href="#cast-5485"><span class="linenos">5485</span></a><span class="sd"> 'CAST(x + 1 AS INT)'</span> +</span><span id="cast-5486"><a href="#cast-5486"><span class="linenos">5486</span></a> +</span><span id="cast-5487"><a href="#cast-5487"><span class="linenos">5487</span></a><span class="sd"> Args:</span> +</span><span id="cast-5488"><a href="#cast-5488"><span class="linenos">5488</span></a><span class="sd"> expression: The expression to cast.</span> +</span><span id="cast-5489"><a href="#cast-5489"><span class="linenos">5489</span></a><span class="sd"> to: The datatype to cast to.</span> +</span><span id="cast-5490"><a href="#cast-5490"><span class="linenos">5490</span></a> +</span><span id="cast-5491"><a href="#cast-5491"><span class="linenos">5491</span></a><span class="sd"> Returns:</span> +</span><span id="cast-5492"><a href="#cast-5492"><span class="linenos">5492</span></a><span class="sd"> The new Cast instance.</span> +</span><span id="cast-5493"><a href="#cast-5493"><span class="linenos">5493</span></a><span class="sd"> """</span> +</span><span id="cast-5494"><a href="#cast-5494"><span class="linenos">5494</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">)</span> +</span><span id="cast-5495"><a href="#cast-5495"><span class="linenos">5495</span></a> <span class="k">return</span> <span class="n">Cast</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">to</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="n">to</span><span class="p">,</span> <span class="o">**</span><span class="n">opts</span><span class="p">))</span> </span></pre></div> @@ -51468,31 +51596,31 @@ If an Expression instance is passed, this is used as-is.</li> </div> <a class="headerlink" href="#table_"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="table_-5493"><a href="#table_-5493"><span class="linenos">5493</span></a><span class="k">def</span> <span class="nf">table_</span><span class="p">(</span> -</span><span id="table_-5494"><a href="#table_-5494"><span class="linenos">5494</span></a> <span class="n">table</span><span class="p">:</span> <span class="n">Identifier</span> <span class="o">|</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="table_-5495"><a href="#table_-5495"><span class="linenos">5495</span></a> <span class="n">db</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">Identifier</span> <span class="o">|</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="table_-5496"><a href="#table_-5496"><span class="linenos">5496</span></a> <span class="n">catalog</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">Identifier</span> <span class="o">|</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="table_-5497"><a href="#table_-5497"><span class="linenos">5497</span></a> <span class="n">quoted</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="table_-5498"><a href="#table_-5498"><span class="linenos">5498</span></a> <span class="n">alias</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">Identifier</span> <span class="o">|</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="table_-5499"><a href="#table_-5499"><span class="linenos">5499</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Table</span><span class="p">:</span> -</span><span id="table_-5500"><a href="#table_-5500"><span class="linenos">5500</span></a><span class="w"> </span><span class="sd">"""Build a Table.</span> -</span><span id="table_-5501"><a href="#table_-5501"><span class="linenos">5501</span></a> -</span><span id="table_-5502"><a href="#table_-5502"><span class="linenos">5502</span></a><span class="sd"> Args:</span> -</span><span id="table_-5503"><a href="#table_-5503"><span class="linenos">5503</span></a><span class="sd"> table: Table name.</span> -</span><span id="table_-5504"><a href="#table_-5504"><span class="linenos">5504</span></a><span class="sd"> db: Database name.</span> -</span><span id="table_-5505"><a href="#table_-5505"><span class="linenos">5505</span></a><span class="sd"> catalog: Catalog name.</span> -</span><span id="table_-5506"><a href="#table_-5506"><span class="linenos">5506</span></a><span class="sd"> quote: Whether to force quotes on the table's identifiers.</span> -</span><span id="table_-5507"><a href="#table_-5507"><span class="linenos">5507</span></a><span class="sd"> alias: Table's alias.</span> -</span><span id="table_-5508"><a href="#table_-5508"><span class="linenos">5508</span></a> -</span><span id="table_-5509"><a href="#table_-5509"><span class="linenos">5509</span></a><span class="sd"> Returns:</span> -</span><span id="table_-5510"><a href="#table_-5510"><span class="linenos">5510</span></a><span class="sd"> The new Table instance.</span> -</span><span id="table_-5511"><a href="#table_-5511"><span class="linenos">5511</span></a><span class="sd"> """</span> -</span><span id="table_-5512"><a href="#table_-5512"><span class="linenos">5512</span></a> <span class="k">return</span> <span class="n">Table</span><span class="p">(</span> -</span><span id="table_-5513"><a href="#table_-5513"><span class="linenos">5513</span></a> <span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> -</span><span id="table_-5514"><a href="#table_-5514"><span class="linenos">5514</span></a> <span class="n">db</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">db</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> -</span><span id="table_-5515"><a href="#table_-5515"><span class="linenos">5515</span></a> <span class="n">catalog</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">catalog</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> -</span><span id="table_-5516"><a href="#table_-5516"><span class="linenos">5516</span></a> <span class="n">alias</span><span class="o">=</span><span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">))</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="table_-5517"><a href="#table_-5517"><span class="linenos">5517</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="table_-5498"><a href="#table_-5498"><span class="linenos">5498</span></a><span class="k">def</span> <span class="nf">table_</span><span class="p">(</span> +</span><span id="table_-5499"><a href="#table_-5499"><span class="linenos">5499</span></a> <span class="n">table</span><span class="p">:</span> <span class="n">Identifier</span> <span class="o">|</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="table_-5500"><a href="#table_-5500"><span class="linenos">5500</span></a> <span class="n">db</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">Identifier</span> <span class="o">|</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="table_-5501"><a href="#table_-5501"><span class="linenos">5501</span></a> <span class="n">catalog</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">Identifier</span> <span class="o">|</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="table_-5502"><a href="#table_-5502"><span class="linenos">5502</span></a> <span class="n">quoted</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="table_-5503"><a href="#table_-5503"><span class="linenos">5503</span></a> <span class="n">alias</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">Identifier</span> <span class="o">|</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="table_-5504"><a href="#table_-5504"><span class="linenos">5504</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Table</span><span class="p">:</span> +</span><span id="table_-5505"><a href="#table_-5505"><span class="linenos">5505</span></a><span class="w"> </span><span class="sd">"""Build a Table.</span> +</span><span id="table_-5506"><a href="#table_-5506"><span class="linenos">5506</span></a> +</span><span id="table_-5507"><a href="#table_-5507"><span class="linenos">5507</span></a><span class="sd"> Args:</span> +</span><span id="table_-5508"><a href="#table_-5508"><span class="linenos">5508</span></a><span class="sd"> table: Table name.</span> +</span><span id="table_-5509"><a href="#table_-5509"><span class="linenos">5509</span></a><span class="sd"> db: Database name.</span> +</span><span id="table_-5510"><a href="#table_-5510"><span class="linenos">5510</span></a><span class="sd"> catalog: Catalog name.</span> +</span><span id="table_-5511"><a href="#table_-5511"><span class="linenos">5511</span></a><span class="sd"> quote: Whether to force quotes on the table's identifiers.</span> +</span><span id="table_-5512"><a href="#table_-5512"><span class="linenos">5512</span></a><span class="sd"> alias: Table's alias.</span> +</span><span id="table_-5513"><a href="#table_-5513"><span class="linenos">5513</span></a> +</span><span id="table_-5514"><a href="#table_-5514"><span class="linenos">5514</span></a><span class="sd"> Returns:</span> +</span><span id="table_-5515"><a href="#table_-5515"><span class="linenos">5515</span></a><span class="sd"> The new Table instance.</span> +</span><span id="table_-5516"><a href="#table_-5516"><span class="linenos">5516</span></a><span class="sd"> """</span> +</span><span id="table_-5517"><a href="#table_-5517"><span class="linenos">5517</span></a> <span class="k">return</span> <span class="n">Table</span><span class="p">(</span> +</span><span id="table_-5518"><a href="#table_-5518"><span class="linenos">5518</span></a> <span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> +</span><span id="table_-5519"><a href="#table_-5519"><span class="linenos">5519</span></a> <span class="n">db</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">db</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> +</span><span id="table_-5520"><a href="#table_-5520"><span class="linenos">5520</span></a> <span class="n">catalog</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">catalog</span><span class="p">,</span> <span class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">),</span> +</span><span id="table_-5521"><a href="#table_-5521"><span class="linenos">5521</span></a> <span class="n">alias</span><span class="o">=</span><span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">))</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="table_-5522"><a href="#table_-5522"><span class="linenos">5522</span></a> <span class="p">)</span> </span></pre></div> @@ -51528,37 +51656,37 @@ If an Expression instance is passed, this is used as-is.</li> </div> <a class="headerlink" href="#values"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="values-5520"><a href="#values-5520"><span class="linenos">5520</span></a><span class="k">def</span> <span class="nf">values</span><span class="p">(</span> -</span><span id="values-5521"><a href="#values-5521"><span class="linenos">5521</span></a> <span class="n">values</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="o">...</span><span class="p">]],</span> -</span><span id="values-5522"><a href="#values-5522"><span class="linenos">5522</span></a> <span class="n">alias</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="values-5523"><a href="#values-5523"><span class="linenos">5523</span></a> <span class="n">columns</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">DataType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="values-5524"><a href="#values-5524"><span class="linenos">5524</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Values</span><span class="p">:</span> -</span><span id="values-5525"><a href="#values-5525"><span class="linenos">5525</span></a><span class="w"> </span><span class="sd">"""Build VALUES statement.</span> -</span><span id="values-5526"><a href="#values-5526"><span class="linenos">5526</span></a> -</span><span id="values-5527"><a href="#values-5527"><span class="linenos">5527</span></a><span class="sd"> Example:</span> -</span><span id="values-5528"><a href="#values-5528"><span class="linenos">5528</span></a><span class="sd"> >>> values([(1, '2')]).sql()</span> -</span><span id="values-5529"><a href="#values-5529"><span class="linenos">5529</span></a><span class="sd"> "VALUES (1, '2')"</span> -</span><span id="values-5530"><a href="#values-5530"><span class="linenos">5530</span></a> -</span><span id="values-5531"><a href="#values-5531"><span class="linenos">5531</span></a><span class="sd"> Args:</span> -</span><span id="values-5532"><a href="#values-5532"><span class="linenos">5532</span></a><span class="sd"> values: values statements that will be converted to SQL</span> -</span><span id="values-5533"><a href="#values-5533"><span class="linenos">5533</span></a><span class="sd"> alias: optional alias</span> -</span><span id="values-5534"><a href="#values-5534"><span class="linenos">5534</span></a><span class="sd"> columns: Optional list of ordered column names or ordered dictionary of column names to types.</span> -</span><span id="values-5535"><a href="#values-5535"><span class="linenos">5535</span></a><span class="sd"> If either are provided then an alias is also required.</span> -</span><span id="values-5536"><a href="#values-5536"><span class="linenos">5536</span></a> -</span><span id="values-5537"><a href="#values-5537"><span class="linenos">5537</span></a><span class="sd"> Returns:</span> -</span><span id="values-5538"><a href="#values-5538"><span class="linenos">5538</span></a><span class="sd"> Values: the Values expression object</span> -</span><span id="values-5539"><a href="#values-5539"><span class="linenos">5539</span></a><span class="sd"> """</span> -</span><span id="values-5540"><a href="#values-5540"><span class="linenos">5540</span></a> <span class="k">if</span> <span class="n">columns</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">alias</span><span class="p">:</span> -</span><span id="values-5541"><a href="#values-5541"><span class="linenos">5541</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Alias is required when providing columns"</span><span class="p">)</span> -</span><span id="values-5542"><a href="#values-5542"><span class="linenos">5542</span></a> -</span><span id="values-5543"><a href="#values-5543"><span class="linenos">5543</span></a> <span class="k">return</span> <span class="n">Values</span><span class="p">(</span> -</span><span id="values-5544"><a href="#values-5544"><span class="linenos">5544</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">tup</span><span class="p">)</span> <span class="k">for</span> <span class="n">tup</span> <span class="ow">in</span> <span class="n">values</span><span class="p">],</span> -</span><span id="values-5545"><a href="#values-5545"><span class="linenos">5545</span></a> <span class="n">alias</span><span class="o">=</span><span class="p">(</span> -</span><span id="values-5546"><a href="#values-5546"><span class="linenos">5546</span></a> <span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">),</span> <span class="n">columns</span><span class="o">=</span><span class="p">[</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">columns</span><span class="p">])</span> -</span><span id="values-5547"><a href="#values-5547"><span class="linenos">5547</span></a> <span class="k">if</span> <span class="n">columns</span> -</span><span id="values-5548"><a href="#values-5548"><span class="linenos">5548</span></a> <span class="k">else</span> <span class="p">(</span><span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">))</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="values-5549"><a href="#values-5549"><span class="linenos">5549</span></a> <span class="p">),</span> -</span><span id="values-5550"><a href="#values-5550"><span class="linenos">5550</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="values-5525"><a href="#values-5525"><span class="linenos">5525</span></a><span class="k">def</span> <span class="nf">values</span><span class="p">(</span> +</span><span id="values-5526"><a href="#values-5526"><span class="linenos">5526</span></a> <span class="n">values</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="o">...</span><span class="p">]],</span> +</span><span id="values-5527"><a href="#values-5527"><span class="linenos">5527</span></a> <span class="n">alias</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="values-5528"><a href="#values-5528"><span class="linenos">5528</span></a> <span class="n">columns</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">DataType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="values-5529"><a href="#values-5529"><span class="linenos">5529</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Values</span><span class="p">:</span> +</span><span id="values-5530"><a href="#values-5530"><span class="linenos">5530</span></a><span class="w"> </span><span class="sd">"""Build VALUES statement.</span> +</span><span id="values-5531"><a href="#values-5531"><span class="linenos">5531</span></a> +</span><span id="values-5532"><a href="#values-5532"><span class="linenos">5532</span></a><span class="sd"> Example:</span> +</span><span id="values-5533"><a href="#values-5533"><span class="linenos">5533</span></a><span class="sd"> >>> values([(1, '2')]).sql()</span> +</span><span id="values-5534"><a href="#values-5534"><span class="linenos">5534</span></a><span class="sd"> "VALUES (1, '2')"</span> +</span><span id="values-5535"><a href="#values-5535"><span class="linenos">5535</span></a> +</span><span id="values-5536"><a href="#values-5536"><span class="linenos">5536</span></a><span class="sd"> Args:</span> +</span><span id="values-5537"><a href="#values-5537"><span class="linenos">5537</span></a><span class="sd"> values: values statements that will be converted to SQL</span> +</span><span id="values-5538"><a href="#values-5538"><span class="linenos">5538</span></a><span class="sd"> alias: optional alias</span> +</span><span id="values-5539"><a href="#values-5539"><span class="linenos">5539</span></a><span class="sd"> columns: Optional list of ordered column names or ordered dictionary of column names to types.</span> +</span><span id="values-5540"><a href="#values-5540"><span class="linenos">5540</span></a><span class="sd"> If either are provided then an alias is also required.</span> +</span><span id="values-5541"><a href="#values-5541"><span class="linenos">5541</span></a> +</span><span id="values-5542"><a href="#values-5542"><span class="linenos">5542</span></a><span class="sd"> Returns:</span> +</span><span id="values-5543"><a href="#values-5543"><span class="linenos">5543</span></a><span class="sd"> Values: the Values expression object</span> +</span><span id="values-5544"><a href="#values-5544"><span class="linenos">5544</span></a><span class="sd"> """</span> +</span><span id="values-5545"><a href="#values-5545"><span class="linenos">5545</span></a> <span class="k">if</span> <span class="n">columns</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">alias</span><span class="p">:</span> +</span><span id="values-5546"><a href="#values-5546"><span class="linenos">5546</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Alias is required when providing columns"</span><span class="p">)</span> +</span><span id="values-5547"><a href="#values-5547"><span class="linenos">5547</span></a> +</span><span id="values-5548"><a href="#values-5548"><span class="linenos">5548</span></a> <span class="k">return</span> <span class="n">Values</span><span class="p">(</span> +</span><span id="values-5549"><a href="#values-5549"><span class="linenos">5549</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">tup</span><span class="p">)</span> <span class="k">for</span> <span class="n">tup</span> <span class="ow">in</span> <span class="n">values</span><span class="p">],</span> +</span><span id="values-5550"><a href="#values-5550"><span class="linenos">5550</span></a> <span class="n">alias</span><span class="o">=</span><span class="p">(</span> +</span><span id="values-5551"><a href="#values-5551"><span class="linenos">5551</span></a> <span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">),</span> <span class="n">columns</span><span class="o">=</span><span class="p">[</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">columns</span><span class="p">])</span> +</span><span id="values-5552"><a href="#values-5552"><span class="linenos">5552</span></a> <span class="k">if</span> <span class="n">columns</span> +</span><span id="values-5553"><a href="#values-5553"><span class="linenos">5553</span></a> <span class="k">else</span> <span class="p">(</span><span class="n">TableAlias</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">alias</span><span class="p">))</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="values-5554"><a href="#values-5554"><span class="linenos">5554</span></a> <span class="p">),</span> +</span><span id="values-5555"><a href="#values-5555"><span class="linenos">5555</span></a> <span class="p">)</span> </span></pre></div> @@ -51603,28 +51731,28 @@ If either are provided then an alias is also required.</li> </div> <a class="headerlink" href="#var"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="var-5553"><a href="#var-5553"><span class="linenos">5553</span></a><span class="k">def</span> <span class="nf">var</span><span class="p">(</span><span class="n">name</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">ExpOrStr</span><span class="p">])</span> <span class="o">-></span> <span class="n">Var</span><span class="p">:</span> -</span><span id="var-5554"><a href="#var-5554"><span class="linenos">5554</span></a><span class="w"> </span><span class="sd">"""Build a SQL variable.</span> -</span><span id="var-5555"><a href="#var-5555"><span class="linenos">5555</span></a> -</span><span id="var-5556"><a href="#var-5556"><span class="linenos">5556</span></a><span class="sd"> Example:</span> -</span><span id="var-5557"><a href="#var-5557"><span class="linenos">5557</span></a><span class="sd"> >>> repr(var('x'))</span> -</span><span id="var-5558"><a href="#var-5558"><span class="linenos">5558</span></a><span class="sd"> '(VAR this: x)'</span> -</span><span id="var-5559"><a href="#var-5559"><span class="linenos">5559</span></a> -</span><span id="var-5560"><a href="#var-5560"><span class="linenos">5560</span></a><span class="sd"> >>> repr(var(column('x', table='y')))</span> -</span><span id="var-5561"><a href="#var-5561"><span class="linenos">5561</span></a><span class="sd"> '(VAR this: x)'</span> -</span><span id="var-5562"><a href="#var-5562"><span class="linenos">5562</span></a> -</span><span id="var-5563"><a href="#var-5563"><span class="linenos">5563</span></a><span class="sd"> Args:</span> -</span><span id="var-5564"><a href="#var-5564"><span class="linenos">5564</span></a><span class="sd"> name: The name of the var or an expression who's name will become the var.</span> -</span><span id="var-5565"><a href="#var-5565"><span class="linenos">5565</span></a> -</span><span id="var-5566"><a href="#var-5566"><span class="linenos">5566</span></a><span class="sd"> Returns:</span> -</span><span id="var-5567"><a href="#var-5567"><span class="linenos">5567</span></a><span class="sd"> The new variable node.</span> -</span><span id="var-5568"><a href="#var-5568"><span class="linenos">5568</span></a><span class="sd"> """</span> -</span><span id="var-5569"><a href="#var-5569"><span class="linenos">5569</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">name</span><span class="p">:</span> -</span><span id="var-5570"><a href="#var-5570"><span class="linenos">5570</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Cannot convert empty name into var."</span><span class="p">)</span> -</span><span id="var-5571"><a href="#var-5571"><span class="linenos">5571</span></a> -</span><span id="var-5572"><a href="#var-5572"><span class="linenos">5572</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> -</span><span id="var-5573"><a href="#var-5573"><span class="linenos">5573</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">name</span><span class="o">.</span><span class="n">name</span> -</span><span id="var-5574"><a href="#var-5574"><span class="linenos">5574</span></a> <span class="k">return</span> <span class="n">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">name</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="var-5558"><a href="#var-5558"><span class="linenos">5558</span></a><span class="k">def</span> <span class="nf">var</span><span class="p">(</span><span class="n">name</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">ExpOrStr</span><span class="p">])</span> <span class="o">-></span> <span class="n">Var</span><span class="p">:</span> +</span><span id="var-5559"><a href="#var-5559"><span class="linenos">5559</span></a><span class="w"> </span><span class="sd">"""Build a SQL variable.</span> +</span><span id="var-5560"><a href="#var-5560"><span class="linenos">5560</span></a> +</span><span id="var-5561"><a href="#var-5561"><span class="linenos">5561</span></a><span class="sd"> Example:</span> +</span><span id="var-5562"><a href="#var-5562"><span class="linenos">5562</span></a><span class="sd"> >>> repr(var('x'))</span> +</span><span id="var-5563"><a href="#var-5563"><span class="linenos">5563</span></a><span class="sd"> '(VAR this: x)'</span> +</span><span id="var-5564"><a href="#var-5564"><span class="linenos">5564</span></a> +</span><span id="var-5565"><a href="#var-5565"><span class="linenos">5565</span></a><span class="sd"> >>> repr(var(column('x', table='y')))</span> +</span><span id="var-5566"><a href="#var-5566"><span class="linenos">5566</span></a><span class="sd"> '(VAR this: x)'</span> +</span><span id="var-5567"><a href="#var-5567"><span class="linenos">5567</span></a> +</span><span id="var-5568"><a href="#var-5568"><span class="linenos">5568</span></a><span class="sd"> Args:</span> +</span><span id="var-5569"><a href="#var-5569"><span class="linenos">5569</span></a><span class="sd"> name: The name of the var or an expression who's name will become the var.</span> +</span><span id="var-5570"><a href="#var-5570"><span class="linenos">5570</span></a> +</span><span id="var-5571"><a href="#var-5571"><span class="linenos">5571</span></a><span class="sd"> Returns:</span> +</span><span id="var-5572"><a href="#var-5572"><span class="linenos">5572</span></a><span class="sd"> The new variable node.</span> +</span><span id="var-5573"><a href="#var-5573"><span class="linenos">5573</span></a><span class="sd"> """</span> +</span><span id="var-5574"><a href="#var-5574"><span class="linenos">5574</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">name</span><span class="p">:</span> +</span><span id="var-5575"><a href="#var-5575"><span class="linenos">5575</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Cannot convert empty name into var."</span><span class="p">)</span> +</span><span id="var-5576"><a href="#var-5576"><span class="linenos">5576</span></a> +</span><span id="var-5577"><a href="#var-5577"><span class="linenos">5577</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> +</span><span id="var-5578"><a href="#var-5578"><span class="linenos">5578</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">name</span><span class="o">.</span><span class="n">name</span> +</span><span id="var-5579"><a href="#var-5579"><span class="linenos">5579</span></a> <span class="k">return</span> <span class="n">Var</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">name</span><span class="p">)</span> </span></pre></div> @@ -51672,24 +51800,24 @@ If either are provided then an alias is also required.</li> </div> <a class="headerlink" href="#rename_table"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="rename_table-5577"><a href="#rename_table-5577"><span class="linenos">5577</span></a><span class="k">def</span> <span class="nf">rename_table</span><span class="p">(</span><span class="n">old_name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Table</span><span class="p">,</span> <span class="n">new_name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Table</span><span class="p">)</span> <span class="o">-></span> <span class="n">AlterTable</span><span class="p">:</span> -</span><span id="rename_table-5578"><a href="#rename_table-5578"><span class="linenos">5578</span></a><span class="w"> </span><span class="sd">"""Build ALTER TABLE... RENAME... expression</span> -</span><span id="rename_table-5579"><a href="#rename_table-5579"><span class="linenos">5579</span></a> -</span><span id="rename_table-5580"><a href="#rename_table-5580"><span class="linenos">5580</span></a><span class="sd"> Args:</span> -</span><span id="rename_table-5581"><a href="#rename_table-5581"><span class="linenos">5581</span></a><span class="sd"> old_name: The old name of the table</span> -</span><span id="rename_table-5582"><a href="#rename_table-5582"><span class="linenos">5582</span></a><span class="sd"> new_name: The new name of the table</span> -</span><span id="rename_table-5583"><a href="#rename_table-5583"><span class="linenos">5583</span></a> -</span><span id="rename_table-5584"><a href="#rename_table-5584"><span class="linenos">5584</span></a><span class="sd"> Returns:</span> -</span><span id="rename_table-5585"><a href="#rename_table-5585"><span class="linenos">5585</span></a><span class="sd"> Alter table expression</span> -</span><span id="rename_table-5586"><a href="#rename_table-5586"><span class="linenos">5586</span></a><span class="sd"> """</span> -</span><span id="rename_table-5587"><a href="#rename_table-5587"><span class="linenos">5587</span></a> <span class="n">old_table</span> <span class="o">=</span> <span class="n">to_table</span><span class="p">(</span><span class="n">old_name</span><span class="p">)</span> -</span><span id="rename_table-5588"><a href="#rename_table-5588"><span class="linenos">5588</span></a> <span class="n">new_table</span> <span class="o">=</span> <span class="n">to_table</span><span class="p">(</span><span class="n">new_name</span><span class="p">)</span> -</span><span id="rename_table-5589"><a href="#rename_table-5589"><span class="linenos">5589</span></a> <span class="k">return</span> <span class="n">AlterTable</span><span class="p">(</span> -</span><span id="rename_table-5590"><a href="#rename_table-5590"><span class="linenos">5590</span></a> <span class="n">this</span><span class="o">=</span><span class="n">old_table</span><span class="p">,</span> -</span><span id="rename_table-5591"><a href="#rename_table-5591"><span class="linenos">5591</span></a> <span class="n">actions</span><span class="o">=</span><span class="p">[</span> -</span><span id="rename_table-5592"><a href="#rename_table-5592"><span class="linenos">5592</span></a> <span class="n">RenameTable</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">new_table</span><span class="p">),</span> -</span><span id="rename_table-5593"><a href="#rename_table-5593"><span class="linenos">5593</span></a> <span class="p">],</span> -</span><span id="rename_table-5594"><a href="#rename_table-5594"><span class="linenos">5594</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="rename_table-5582"><a href="#rename_table-5582"><span class="linenos">5582</span></a><span class="k">def</span> <span class="nf">rename_table</span><span class="p">(</span><span class="n">old_name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Table</span><span class="p">,</span> <span class="n">new_name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">Table</span><span class="p">)</span> <span class="o">-></span> <span class="n">AlterTable</span><span class="p">:</span> +</span><span id="rename_table-5583"><a href="#rename_table-5583"><span class="linenos">5583</span></a><span class="w"> </span><span class="sd">"""Build ALTER TABLE... RENAME... expression</span> +</span><span id="rename_table-5584"><a href="#rename_table-5584"><span class="linenos">5584</span></a> +</span><span id="rename_table-5585"><a href="#rename_table-5585"><span class="linenos">5585</span></a><span class="sd"> Args:</span> +</span><span id="rename_table-5586"><a href="#rename_table-5586"><span class="linenos">5586</span></a><span class="sd"> old_name: The old name of the table</span> +</span><span id="rename_table-5587"><a href="#rename_table-5587"><span class="linenos">5587</span></a><span class="sd"> new_name: The new name of the table</span> +</span><span id="rename_table-5588"><a href="#rename_table-5588"><span class="linenos">5588</span></a> +</span><span id="rename_table-5589"><a href="#rename_table-5589"><span class="linenos">5589</span></a><span class="sd"> Returns:</span> +</span><span id="rename_table-5590"><a href="#rename_table-5590"><span class="linenos">5590</span></a><span class="sd"> Alter table expression</span> +</span><span id="rename_table-5591"><a href="#rename_table-5591"><span class="linenos">5591</span></a><span class="sd"> """</span> +</span><span id="rename_table-5592"><a href="#rename_table-5592"><span class="linenos">5592</span></a> <span class="n">old_table</span> <span class="o">=</span> <span class="n">to_table</span><span class="p">(</span><span class="n">old_name</span><span class="p">)</span> +</span><span id="rename_table-5593"><a href="#rename_table-5593"><span class="linenos">5593</span></a> <span class="n">new_table</span> <span class="o">=</span> <span class="n">to_table</span><span class="p">(</span><span class="n">new_name</span><span class="p">)</span> +</span><span id="rename_table-5594"><a href="#rename_table-5594"><span class="linenos">5594</span></a> <span class="k">return</span> <span class="n">AlterTable</span><span class="p">(</span> +</span><span id="rename_table-5595"><a href="#rename_table-5595"><span class="linenos">5595</span></a> <span class="n">this</span><span class="o">=</span><span class="n">old_table</span><span class="p">,</span> +</span><span id="rename_table-5596"><a href="#rename_table-5596"><span class="linenos">5596</span></a> <span class="n">actions</span><span class="o">=</span><span class="p">[</span> +</span><span id="rename_table-5597"><a href="#rename_table-5597"><span class="linenos">5597</span></a> <span class="n">RenameTable</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">new_table</span><span class="p">),</span> +</span><span id="rename_table-5598"><a href="#rename_table-5598"><span class="linenos">5598</span></a> <span class="p">],</span> +</span><span id="rename_table-5599"><a href="#rename_table-5599"><span class="linenos">5599</span></a> <span class="p">)</span> </span></pre></div> @@ -51722,46 +51850,46 @@ If either are provided then an alias is also required.</li> </div> <a class="headerlink" href="#convert"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="convert-5597"><a href="#convert-5597"><span class="linenos">5597</span></a><span class="k">def</span> <span class="nf">convert</span><span class="p">(</span><span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> -</span><span id="convert-5598"><a href="#convert-5598"><span class="linenos">5598</span></a><span class="w"> </span><span class="sd">"""Convert a python value into an expression object.</span> -</span><span id="convert-5599"><a href="#convert-5599"><span class="linenos">5599</span></a> -</span><span id="convert-5600"><a href="#convert-5600"><span class="linenos">5600</span></a><span class="sd"> Raises an error if a conversion is not possible.</span> -</span><span id="convert-5601"><a href="#convert-5601"><span class="linenos">5601</span></a> -</span><span id="convert-5602"><a href="#convert-5602"><span class="linenos">5602</span></a><span class="sd"> Args:</span> -</span><span id="convert-5603"><a href="#convert-5603"><span class="linenos">5603</span></a><span class="sd"> value: A python object.</span> -</span><span id="convert-5604"><a href="#convert-5604"><span class="linenos">5604</span></a><span class="sd"> copy: Whether or not to copy `value` (only applies to Expressions and collections).</span> -</span><span id="convert-5605"><a href="#convert-5605"><span class="linenos">5605</span></a> -</span><span id="convert-5606"><a href="#convert-5606"><span class="linenos">5606</span></a><span class="sd"> Returns:</span> -</span><span id="convert-5607"><a href="#convert-5607"><span class="linenos">5607</span></a><span class="sd"> Expression: the equivalent expression object.</span> -</span><span id="convert-5608"><a href="#convert-5608"><span class="linenos">5608</span></a><span class="sd"> """</span> -</span><span id="convert-5609"><a href="#convert-5609"><span class="linenos">5609</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> -</span><span id="convert-5610"><a href="#convert-5610"><span class="linenos">5610</span></a> <span class="k">return</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> -</span><span id="convert-5611"><a href="#convert-5611"><span class="linenos">5611</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="convert-5612"><a href="#convert-5612"><span class="linenos">5612</span></a> <span class="k">return</span> <span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="convert-5613"><a href="#convert-5613"><span class="linenos">5613</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">bool</span><span class="p">):</span> -</span><span id="convert-5614"><a href="#convert-5614"><span class="linenos">5614</span></a> <span class="k">return</span> <span class="n">Boolean</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">value</span><span class="p">)</span> -</span><span id="convert-5615"><a href="#convert-5615"><span class="linenos">5615</span></a> <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="p">(</span><span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">float</span><span class="p">)</span> <span class="ow">and</span> <span class="n">math</span><span class="o">.</span><span class="n">isnan</span><span class="p">(</span><span class="n">value</span><span class="p">)):</span> -</span><span id="convert-5616"><a href="#convert-5616"><span class="linenos">5616</span></a> <span class="k">return</span> <span class="n">NULL</span> -</span><span id="convert-5617"><a href="#convert-5617"><span class="linenos">5617</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">numbers</span><span class="o">.</span><span class="n">Number</span><span class="p">):</span> -</span><span id="convert-5618"><a href="#convert-5618"><span class="linenos">5618</span></a> <span class="k">return</span> <span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="convert-5619"><a href="#convert-5619"><span class="linenos">5619</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="p">):</span> -</span><span id="convert-5620"><a href="#convert-5620"><span class="linenos">5620</span></a> <span class="n">datetime_literal</span> <span class="o">=</span> <span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span> -</span><span id="convert-5621"><a href="#convert-5621"><span class="linenos">5621</span></a> <span class="p">(</span><span class="n">value</span> <span class="k">if</span> <span class="n">value</span><span class="o">.</span><span class="n">tzinfo</span> <span class="k">else</span> <span class="n">value</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">tzinfo</span><span class="o">=</span><span class="n">datetime</span><span class="o">.</span><span class="n">timezone</span><span class="o">.</span><span class="n">utc</span><span class="p">))</span><span class="o">.</span><span class="n">isoformat</span><span class="p">()</span> -</span><span id="convert-5622"><a href="#convert-5622"><span class="linenos">5622</span></a> <span class="p">)</span> -</span><span id="convert-5623"><a href="#convert-5623"><span class="linenos">5623</span></a> <span class="k">return</span> <span class="n">TimeStrToTime</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">datetime_literal</span><span class="p">)</span> -</span><span id="convert-5624"><a href="#convert-5624"><span class="linenos">5624</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">datetime</span><span class="o">.</span><span class="n">date</span><span class="p">):</span> -</span><span id="convert-5625"><a href="#convert-5625"><span class="linenos">5625</span></a> <span class="n">date_literal</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">value</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">"%Y-%m-</span><span class="si">%d</span><span class="s2">"</span><span class="p">))</span> -</span><span id="convert-5626"><a href="#convert-5626"><span class="linenos">5626</span></a> <span class="k">return</span> <span class="n">DateStrToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">date_literal</span><span class="p">)</span> -</span><span id="convert-5627"><a href="#convert-5627"><span class="linenos">5627</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">):</span> -</span><span id="convert-5628"><a href="#convert-5628"><span class="linenos">5628</span></a> <span class="k">return</span> <span class="n">Tuple</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">value</span><span class="p">])</span> -</span><span id="convert-5629"><a href="#convert-5629"><span class="linenos">5629</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="convert-5630"><a href="#convert-5630"><span class="linenos">5630</span></a> <span class="k">return</span> <span class="n">Array</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">value</span><span class="p">])</span> -</span><span id="convert-5631"><a href="#convert-5631"><span class="linenos">5631</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span> -</span><span id="convert-5632"><a href="#convert-5632"><span class="linenos">5632</span></a> <span class="k">return</span> <span class="n">Map</span><span class="p">(</span> -</span><span id="convert-5633"><a href="#convert-5633"><span class="linenos">5633</span></a> <span class="n">keys</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">value</span><span class="p">],</span> -</span><span id="convert-5634"><a href="#convert-5634"><span class="linenos">5634</span></a> <span class="n">values</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">value</span><span class="o">.</span><span class="n">values</span><span class="p">()],</span> -</span><span id="convert-5635"><a href="#convert-5635"><span class="linenos">5635</span></a> <span class="p">)</span> -</span><span id="convert-5636"><a href="#convert-5636"><span class="linenos">5636</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Cannot convert </span><span class="si">{</span><span class="n">value</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="convert-5602"><a href="#convert-5602"><span class="linenos">5602</span></a><span class="k">def</span> <span class="nf">convert</span><span class="p">(</span><span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> +</span><span id="convert-5603"><a href="#convert-5603"><span class="linenos">5603</span></a><span class="w"> </span><span class="sd">"""Convert a python value into an expression object.</span> +</span><span id="convert-5604"><a href="#convert-5604"><span class="linenos">5604</span></a> +</span><span id="convert-5605"><a href="#convert-5605"><span class="linenos">5605</span></a><span class="sd"> Raises an error if a conversion is not possible.</span> +</span><span id="convert-5606"><a href="#convert-5606"><span class="linenos">5606</span></a> +</span><span id="convert-5607"><a href="#convert-5607"><span class="linenos">5607</span></a><span class="sd"> Args:</span> +</span><span id="convert-5608"><a href="#convert-5608"><span class="linenos">5608</span></a><span class="sd"> value: A python object.</span> +</span><span id="convert-5609"><a href="#convert-5609"><span class="linenos">5609</span></a><span class="sd"> copy: Whether or not to copy `value` (only applies to Expressions and collections).</span> +</span><span id="convert-5610"><a href="#convert-5610"><span class="linenos">5610</span></a> +</span><span id="convert-5611"><a href="#convert-5611"><span class="linenos">5611</span></a><span class="sd"> Returns:</span> +</span><span id="convert-5612"><a href="#convert-5612"><span class="linenos">5612</span></a><span class="sd"> Expression: the equivalent expression object.</span> +</span><span id="convert-5613"><a href="#convert-5613"><span class="linenos">5613</span></a><span class="sd"> """</span> +</span><span id="convert-5614"><a href="#convert-5614"><span class="linenos">5614</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> +</span><span id="convert-5615"><a href="#convert-5615"><span class="linenos">5615</span></a> <span class="k">return</span> <span class="n">_maybe_copy</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">copy</span><span class="p">)</span> +</span><span id="convert-5616"><a href="#convert-5616"><span class="linenos">5616</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="convert-5617"><a href="#convert-5617"><span class="linenos">5617</span></a> <span class="k">return</span> <span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="convert-5618"><a href="#convert-5618"><span class="linenos">5618</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">bool</span><span class="p">):</span> +</span><span id="convert-5619"><a href="#convert-5619"><span class="linenos">5619</span></a> <span class="k">return</span> <span class="n">Boolean</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">value</span><span class="p">)</span> +</span><span id="convert-5620"><a href="#convert-5620"><span class="linenos">5620</span></a> <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="p">(</span><span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">float</span><span class="p">)</span> <span class="ow">and</span> <span class="n">math</span><span class="o">.</span><span class="n">isnan</span><span class="p">(</span><span class="n">value</span><span class="p">)):</span> +</span><span id="convert-5621"><a href="#convert-5621"><span class="linenos">5621</span></a> <span class="k">return</span> <span class="n">NULL</span> +</span><span id="convert-5622"><a href="#convert-5622"><span class="linenos">5622</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">numbers</span><span class="o">.</span><span class="n">Number</span><span class="p">):</span> +</span><span id="convert-5623"><a href="#convert-5623"><span class="linenos">5623</span></a> <span class="k">return</span> <span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="convert-5624"><a href="#convert-5624"><span class="linenos">5624</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="p">):</span> +</span><span id="convert-5625"><a href="#convert-5625"><span class="linenos">5625</span></a> <span class="n">datetime_literal</span> <span class="o">=</span> <span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span> +</span><span id="convert-5626"><a href="#convert-5626"><span class="linenos">5626</span></a> <span class="p">(</span><span class="n">value</span> <span class="k">if</span> <span class="n">value</span><span class="o">.</span><span class="n">tzinfo</span> <span class="k">else</span> <span class="n">value</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">tzinfo</span><span class="o">=</span><span class="n">datetime</span><span class="o">.</span><span class="n">timezone</span><span class="o">.</span><span class="n">utc</span><span class="p">))</span><span class="o">.</span><span class="n">isoformat</span><span class="p">()</span> +</span><span id="convert-5627"><a href="#convert-5627"><span class="linenos">5627</span></a> <span class="p">)</span> +</span><span id="convert-5628"><a href="#convert-5628"><span class="linenos">5628</span></a> <span class="k">return</span> <span class="n">TimeStrToTime</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">datetime_literal</span><span class="p">)</span> +</span><span id="convert-5629"><a href="#convert-5629"><span class="linenos">5629</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">datetime</span><span class="o">.</span><span class="n">date</span><span class="p">):</span> +</span><span id="convert-5630"><a href="#convert-5630"><span class="linenos">5630</span></a> <span class="n">date_literal</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">value</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">"%Y-%m-</span><span class="si">%d</span><span class="s2">"</span><span class="p">))</span> +</span><span id="convert-5631"><a href="#convert-5631"><span class="linenos">5631</span></a> <span class="k">return</span> <span class="n">DateStrToDate</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">date_literal</span><span class="p">)</span> +</span><span id="convert-5632"><a href="#convert-5632"><span class="linenos">5632</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">):</span> +</span><span id="convert-5633"><a href="#convert-5633"><span class="linenos">5633</span></a> <span class="k">return</span> <span class="n">Tuple</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">value</span><span class="p">])</span> +</span><span id="convert-5634"><a href="#convert-5634"><span class="linenos">5634</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="convert-5635"><a href="#convert-5635"><span class="linenos">5635</span></a> <span class="k">return</span> <span class="n">Array</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">value</span><span class="p">])</span> +</span><span id="convert-5636"><a href="#convert-5636"><span class="linenos">5636</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span> +</span><span id="convert-5637"><a href="#convert-5637"><span class="linenos">5637</span></a> <span class="k">return</span> <span class="n">Map</span><span class="p">(</span> +</span><span id="convert-5638"><a href="#convert-5638"><span class="linenos">5638</span></a> <span class="n">keys</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">value</span><span class="p">],</span> +</span><span id="convert-5639"><a href="#convert-5639"><span class="linenos">5639</span></a> <span class="n">values</span><span class="o">=</span><span class="p">[</span><span class="n">convert</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">value</span><span class="o">.</span><span class="n">values</span><span class="p">()],</span> +</span><span id="convert-5640"><a href="#convert-5640"><span class="linenos">5640</span></a> <span class="p">)</span> +</span><span id="convert-5641"><a href="#convert-5641"><span class="linenos">5641</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Cannot convert </span><span class="si">{</span><span class="n">value</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> </span></pre></div> @@ -51796,26 +51924,26 @@ If either are provided then an alias is also required.</li> </div> <a class="headerlink" href="#replace_children"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="replace_children-5639"><a href="#replace_children-5639"><span class="linenos">5639</span></a><span class="k">def</span> <span class="nf">replace_children</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="n">fun</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="replace_children-5640"><a href="#replace_children-5640"><span class="linenos">5640</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="replace_children-5641"><a href="#replace_children-5641"><span class="linenos">5641</span></a><span class="sd"> Replace children of an expression with the result of a lambda fun(child) -> exp.</span> -</span><span id="replace_children-5642"><a href="#replace_children-5642"><span class="linenos">5642</span></a><span class="sd"> """</span> -</span><span id="replace_children-5643"><a href="#replace_children-5643"><span class="linenos">5643</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> -</span><span id="replace_children-5644"><a href="#replace_children-5644"><span class="linenos">5644</span></a> <span class="n">is_list_arg</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="ow">is</span> <span class="nb">list</span> -</span><span id="replace_children-5645"><a href="#replace_children-5645"><span class="linenos">5645</span></a> -</span><span id="replace_children-5646"><a href="#replace_children-5646"><span class="linenos">5646</span></a> <span class="n">child_nodes</span> <span class="o">=</span> <span class="n">v</span> <span class="k">if</span> <span class="n">is_list_arg</span> <span class="k">else</span> <span class="p">[</span><span class="n">v</span><span class="p">]</span> -</span><span id="replace_children-5647"><a href="#replace_children-5647"><span class="linenos">5647</span></a> <span class="n">new_child_nodes</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="replace_children-5648"><a href="#replace_children-5648"><span class="linenos">5648</span></a> -</span><span id="replace_children-5649"><a href="#replace_children-5649"><span class="linenos">5649</span></a> <span class="k">for</span> <span class="n">cn</span> <span class="ow">in</span> <span class="n">child_nodes</span><span class="p">:</span> -</span><span id="replace_children-5650"><a href="#replace_children-5650"><span class="linenos">5650</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">cn</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> -</span><span id="replace_children-5651"><a href="#replace_children-5651"><span class="linenos">5651</span></a> <span class="k">for</span> <span class="n">child_node</span> <span class="ow">in</span> <span class="n">ensure_collection</span><span class="p">(</span><span class="n">fun</span><span class="p">(</span><span class="n">cn</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)):</span> -</span><span id="replace_children-5652"><a href="#replace_children-5652"><span class="linenos">5652</span></a> <span class="n">new_child_nodes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">child_node</span><span class="p">)</span> -</span><span id="replace_children-5653"><a href="#replace_children-5653"><span class="linenos">5653</span></a> <span class="n">child_node</span><span class="o">.</span><span class="n">parent</span> <span class="o">=</span> <span class="n">expression</span> -</span><span id="replace_children-5654"><a href="#replace_children-5654"><span class="linenos">5654</span></a> <span class="n">child_node</span><span class="o">.</span><span class="n">arg_key</span> <span class="o">=</span> <span class="n">k</span> -</span><span id="replace_children-5655"><a href="#replace_children-5655"><span class="linenos">5655</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="replace_children-5656"><a href="#replace_children-5656"><span class="linenos">5656</span></a> <span class="n">new_child_nodes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">cn</span><span class="p">)</span> -</span><span id="replace_children-5657"><a href="#replace_children-5657"><span class="linenos">5657</span></a> -</span><span id="replace_children-5658"><a href="#replace_children-5658"><span class="linenos">5658</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">new_child_nodes</span> <span class="k">if</span> <span class="n">is_list_arg</span> <span class="k">else</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">new_child_nodes</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="replace_children-5644"><a href="#replace_children-5644"><span class="linenos">5644</span></a><span class="k">def</span> <span class="nf">replace_children</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="n">fun</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="replace_children-5645"><a href="#replace_children-5645"><span class="linenos">5645</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="replace_children-5646"><a href="#replace_children-5646"><span class="linenos">5646</span></a><span class="sd"> Replace children of an expression with the result of a lambda fun(child) -> exp.</span> +</span><span id="replace_children-5647"><a href="#replace_children-5647"><span class="linenos">5647</span></a><span class="sd"> """</span> +</span><span id="replace_children-5648"><a href="#replace_children-5648"><span class="linenos">5648</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> +</span><span id="replace_children-5649"><a href="#replace_children-5649"><span class="linenos">5649</span></a> <span class="n">is_list_arg</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="ow">is</span> <span class="nb">list</span> +</span><span id="replace_children-5650"><a href="#replace_children-5650"><span class="linenos">5650</span></a> +</span><span id="replace_children-5651"><a href="#replace_children-5651"><span class="linenos">5651</span></a> <span class="n">child_nodes</span> <span class="o">=</span> <span class="n">v</span> <span class="k">if</span> <span class="n">is_list_arg</span> <span class="k">else</span> <span class="p">[</span><span class="n">v</span><span class="p">]</span> +</span><span id="replace_children-5652"><a href="#replace_children-5652"><span class="linenos">5652</span></a> <span class="n">new_child_nodes</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="replace_children-5653"><a href="#replace_children-5653"><span class="linenos">5653</span></a> +</span><span id="replace_children-5654"><a href="#replace_children-5654"><span class="linenos">5654</span></a> <span class="k">for</span> <span class="n">cn</span> <span class="ow">in</span> <span class="n">child_nodes</span><span class="p">:</span> +</span><span id="replace_children-5655"><a href="#replace_children-5655"><span class="linenos">5655</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">cn</span><span class="p">,</span> <span class="n">Expression</span><span class="p">):</span> +</span><span id="replace_children-5656"><a href="#replace_children-5656"><span class="linenos">5656</span></a> <span class="k">for</span> <span class="n">child_node</span> <span class="ow">in</span> <span class="n">ensure_collection</span><span class="p">(</span><span class="n">fun</span><span class="p">(</span><span class="n">cn</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)):</span> +</span><span id="replace_children-5657"><a href="#replace_children-5657"><span class="linenos">5657</span></a> <span class="n">new_child_nodes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">child_node</span><span class="p">)</span> +</span><span id="replace_children-5658"><a href="#replace_children-5658"><span class="linenos">5658</span></a> <span class="n">child_node</span><span class="o">.</span><span class="n">parent</span> <span class="o">=</span> <span class="n">expression</span> +</span><span id="replace_children-5659"><a href="#replace_children-5659"><span class="linenos">5659</span></a> <span class="n">child_node</span><span class="o">.</span><span class="n">arg_key</span> <span class="o">=</span> <span class="n">k</span> +</span><span id="replace_children-5660"><a href="#replace_children-5660"><span class="linenos">5660</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="replace_children-5661"><a href="#replace_children-5661"><span class="linenos">5661</span></a> <span class="n">new_child_nodes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">cn</span><span class="p">)</span> +</span><span id="replace_children-5662"><a href="#replace_children-5662"><span class="linenos">5662</span></a> +</span><span id="replace_children-5663"><a href="#replace_children-5663"><span class="linenos">5663</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">new_child_nodes</span> <span class="k">if</span> <span class="n">is_list_arg</span> <span class="k">else</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">new_child_nodes</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> </span></pre></div> @@ -51829,28 +51957,33 @@ If either are provided then an alias is also required.</li> <div class="attr function"> <span class="def">def</span> - <span class="name">column_table_names</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">expression</span><span class="p">:</span> <span class="n"><a href="#Expression">sqlglot.expressions.Expression</a></span></span><span class="return-annotation">) -> <span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span>:</span></span> + <span class="name">column_table_names</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="n">expression</span><span class="p">:</span> <span class="n"><a href="#Expression">sqlglot.expressions.Expression</a></span>,</span><span class="param"> <span class="n">exclude</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">''</span></span><span class="return-annotation">) -> <span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span>:</span></span> <label class="view-source-button" for="column_table_names-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#column_table_names"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="column_table_names-5661"><a href="#column_table_names-5661"><span class="linenos">5661</span></a><span class="k">def</span> <span class="nf">column_table_names</span><span class="p">(</span><span class="n">expression</span><span class="p">:</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="column_table_names-5662"><a href="#column_table_names-5662"><span class="linenos">5662</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="column_table_names-5663"><a href="#column_table_names-5663"><span class="linenos">5663</span></a><span class="sd"> Return all table names referenced through columns in an expression.</span> -</span><span id="column_table_names-5664"><a href="#column_table_names-5664"><span class="linenos">5664</span></a> -</span><span id="column_table_names-5665"><a href="#column_table_names-5665"><span class="linenos">5665</span></a><span class="sd"> Example:</span> -</span><span id="column_table_names-5666"><a href="#column_table_names-5666"><span class="linenos">5666</span></a><span class="sd"> >>> import sqlglot</span> -</span><span id="column_table_names-5667"><a href="#column_table_names-5667"><span class="linenos">5667</span></a><span class="sd"> >>> column_table_names(sqlglot.parse_one("a.b AND c.d AND c.e"))</span> -</span><span id="column_table_names-5668"><a href="#column_table_names-5668"><span class="linenos">5668</span></a><span class="sd"> ['c', 'a']</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="column_table_names-5666"><a href="#column_table_names-5666"><span class="linenos">5666</span></a><span class="k">def</span> <span class="nf">column_table_names</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="n">exclude</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="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="column_table_names-5667"><a href="#column_table_names-5667"><span class="linenos">5667</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="column_table_names-5668"><a href="#column_table_names-5668"><span class="linenos">5668</span></a><span class="sd"> Return all table names referenced through columns in an expression.</span> </span><span id="column_table_names-5669"><a href="#column_table_names-5669"><span class="linenos">5669</span></a> -</span><span id="column_table_names-5670"><a href="#column_table_names-5670"><span class="linenos">5670</span></a><span class="sd"> Args:</span> -</span><span id="column_table_names-5671"><a href="#column_table_names-5671"><span class="linenos">5671</span></a><span class="sd"> expression: expression to find table names.</span> -</span><span id="column_table_names-5672"><a href="#column_table_names-5672"><span class="linenos">5672</span></a> -</span><span id="column_table_names-5673"><a href="#column_table_names-5673"><span class="linenos">5673</span></a><span class="sd"> Returns:</span> -</span><span id="column_table_names-5674"><a href="#column_table_names-5674"><span class="linenos">5674</span></a><span class="sd"> A list of unique names.</span> -</span><span id="column_table_names-5675"><a href="#column_table_names-5675"><span class="linenos">5675</span></a><span class="sd"> """</span> -</span><span id="column_table_names-5676"><a href="#column_table_names-5676"><span class="linenos">5676</span></a> <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="nb">dict</span><span class="o">.</span><span class="n">fromkeys</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">table</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">Column</span><span class="p">)))</span> +</span><span id="column_table_names-5670"><a href="#column_table_names-5670"><span class="linenos">5670</span></a><span class="sd"> Example:</span> +</span><span id="column_table_names-5671"><a href="#column_table_names-5671"><span class="linenos">5671</span></a><span class="sd"> >>> import sqlglot</span> +</span><span id="column_table_names-5672"><a href="#column_table_names-5672"><span class="linenos">5672</span></a><span class="sd"> >>> sorted(column_table_names(sqlglot.parse_one("a.b AND c.d AND c.e")))</span> +</span><span id="column_table_names-5673"><a href="#column_table_names-5673"><span class="linenos">5673</span></a><span class="sd"> ['a', 'c']</span> +</span><span id="column_table_names-5674"><a href="#column_table_names-5674"><span class="linenos">5674</span></a> +</span><span id="column_table_names-5675"><a href="#column_table_names-5675"><span class="linenos">5675</span></a><span class="sd"> Args:</span> +</span><span id="column_table_names-5676"><a href="#column_table_names-5676"><span class="linenos">5676</span></a><span class="sd"> expression: expression to find table names.</span> +</span><span id="column_table_names-5677"><a href="#column_table_names-5677"><span class="linenos">5677</span></a><span class="sd"> exclude: a table name to exclude</span> +</span><span id="column_table_names-5678"><a href="#column_table_names-5678"><span class="linenos">5678</span></a> +</span><span id="column_table_names-5679"><a href="#column_table_names-5679"><span class="linenos">5679</span></a><span class="sd"> Returns:</span> +</span><span id="column_table_names-5680"><a href="#column_table_names-5680"><span class="linenos">5680</span></a><span class="sd"> A list of unique names.</span> +</span><span id="column_table_names-5681"><a href="#column_table_names-5681"><span class="linenos">5681</span></a><span class="sd"> """</span> +</span><span id="column_table_names-5682"><a href="#column_table_names-5682"><span class="linenos">5682</span></a> <span class="k">return</span> <span class="p">{</span> +</span><span id="column_table_names-5683"><a href="#column_table_names-5683"><span class="linenos">5683</span></a> <span class="n">table</span> +</span><span id="column_table_names-5684"><a href="#column_table_names-5684"><span class="linenos">5684</span></a> <span class="k">for</span> <span class="n">table</span> <span class="ow">in</span> <span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">table</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">Column</span><span class="p">))</span> +</span><span id="column_table_names-5685"><a href="#column_table_names-5685"><span class="linenos">5685</span></a> <span class="k">if</span> <span class="n">table</span> <span class="ow">and</span> <span class="n">table</span> <span class="o">!=</span> <span class="n">exclude</span> +</span><span id="column_table_names-5686"><a href="#column_table_names-5686"><span class="linenos">5686</span></a> <span class="p">}</span> </span></pre></div> @@ -51861,8 +51994,8 @@ If either are provided then an alias is also required.</li> <blockquote> <div class="pdoc-code codehilite"> <pre><span></span><code><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">sqlglot</span> -<span class="gp">>>> </span><span class="n">column_table_names</span><span class="p">(</span><span class="n"><a href="../sqlglot.html#parse_one">sqlglot.parse_one</a></span><span class="p">(</span><span class="s2">"a.b AND c.d AND c.e"</span><span class="p">))</span> -<span class="go">['c', 'a']</span> +<span class="gp">>>> </span><span class="nb">sorted</span><span class="p">(</span><span class="n">column_table_names</span><span class="p">(</span><span class="n"><a href="../sqlglot.html#parse_one">sqlglot.parse_one</a></span><span class="p">(</span><span class="s2">"a.b AND c.d AND c.e"</span><span class="p">)))</span> +<span class="go">['a', 'c']</span> </code></pre> </div> </blockquote> @@ -51871,6 +52004,7 @@ If either are provided then an alias is also required.</li> <ul> <li><strong>expression:</strong> expression to find table names.</li> +<li><strong>exclude:</strong> a table name to exclude</li> </ul> <h6 id="returns">Returns:</h6> @@ -51893,27 +52027,27 @@ If either are provided then an alias is also required.</li> </div> <a class="headerlink" href="#table_name"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="table_name-5679"><a href="#table_name-5679"><span class="linenos">5679</span></a><span class="k">def</span> <span class="nf">table_name</span><span class="p">(</span><span class="n">table</span><span class="p">:</span> <span class="n">Table</span> <span class="o">|</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="table_name-5680"><a href="#table_name-5680"><span class="linenos">5680</span></a><span class="w"> </span><span class="sd">"""Get the full name of a table as a string.</span> -</span><span id="table_name-5681"><a href="#table_name-5681"><span class="linenos">5681</span></a> -</span><span id="table_name-5682"><a href="#table_name-5682"><span class="linenos">5682</span></a><span class="sd"> Args:</span> -</span><span id="table_name-5683"><a href="#table_name-5683"><span class="linenos">5683</span></a><span class="sd"> table: table expression node or string.</span> -</span><span id="table_name-5684"><a href="#table_name-5684"><span class="linenos">5684</span></a> -</span><span id="table_name-5685"><a href="#table_name-5685"><span class="linenos">5685</span></a><span class="sd"> Examples:</span> -</span><span id="table_name-5686"><a href="#table_name-5686"><span class="linenos">5686</span></a><span class="sd"> >>> from sqlglot import exp, parse_one</span> -</span><span id="table_name-5687"><a href="#table_name-5687"><span class="linenos">5687</span></a><span class="sd"> >>> table_name(parse_one("select * from a.b.c").find(exp.Table))</span> -</span><span id="table_name-5688"><a href="#table_name-5688"><span class="linenos">5688</span></a><span class="sd"> 'a.b.c'</span> -</span><span id="table_name-5689"><a href="#table_name-5689"><span class="linenos">5689</span></a> -</span><span id="table_name-5690"><a href="#table_name-5690"><span class="linenos">5690</span></a><span class="sd"> Returns:</span> -</span><span id="table_name-5691"><a href="#table_name-5691"><span class="linenos">5691</span></a><span class="sd"> The table name.</span> -</span><span id="table_name-5692"><a href="#table_name-5692"><span class="linenos">5692</span></a><span class="sd"> """</span> -</span><span id="table_name-5693"><a href="#table_name-5693"><span class="linenos">5693</span></a> -</span><span id="table_name-5694"><a href="#table_name-5694"><span class="linenos">5694</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">)</span> -</span><span id="table_name-5695"><a href="#table_name-5695"><span class="linenos">5695</span></a> -</span><span id="table_name-5696"><a href="#table_name-5696"><span class="linenos">5696</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span><span class="p">:</span> -</span><span id="table_name-5697"><a href="#table_name-5697"><span class="linenos">5697</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Cannot parse </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="table_name-5698"><a href="#table_name-5698"><span class="linenos">5698</span></a> -</span><span id="table_name-5699"><a href="#table_name-5699"><span class="linenos">5699</span></a> <span class="k">return</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">part</span> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">),</span> <span class="n">table</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"db"</span><span class="p">),</span> <span class="n">table</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> <span class="k">if</span> <span class="n">part</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="table_name-5689"><a href="#table_name-5689"><span class="linenos">5689</span></a><span class="k">def</span> <span class="nf">table_name</span><span class="p">(</span><span class="n">table</span><span class="p">:</span> <span class="n">Table</span> <span class="o">|</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="table_name-5690"><a href="#table_name-5690"><span class="linenos">5690</span></a><span class="w"> </span><span class="sd">"""Get the full name of a table as a string.</span> +</span><span id="table_name-5691"><a href="#table_name-5691"><span class="linenos">5691</span></a> +</span><span id="table_name-5692"><a href="#table_name-5692"><span class="linenos">5692</span></a><span class="sd"> Args:</span> +</span><span id="table_name-5693"><a href="#table_name-5693"><span class="linenos">5693</span></a><span class="sd"> table: table expression node or string.</span> +</span><span id="table_name-5694"><a href="#table_name-5694"><span class="linenos">5694</span></a> +</span><span id="table_name-5695"><a href="#table_name-5695"><span class="linenos">5695</span></a><span class="sd"> Examples:</span> +</span><span id="table_name-5696"><a href="#table_name-5696"><span class="linenos">5696</span></a><span class="sd"> >>> from sqlglot import exp, parse_one</span> +</span><span id="table_name-5697"><a href="#table_name-5697"><span class="linenos">5697</span></a><span class="sd"> >>> table_name(parse_one("select * from a.b.c").find(exp.Table))</span> +</span><span id="table_name-5698"><a href="#table_name-5698"><span class="linenos">5698</span></a><span class="sd"> 'a.b.c'</span> +</span><span id="table_name-5699"><a href="#table_name-5699"><span class="linenos">5699</span></a> +</span><span id="table_name-5700"><a href="#table_name-5700"><span class="linenos">5700</span></a><span class="sd"> Returns:</span> +</span><span id="table_name-5701"><a href="#table_name-5701"><span class="linenos">5701</span></a><span class="sd"> The table name.</span> +</span><span id="table_name-5702"><a href="#table_name-5702"><span class="linenos">5702</span></a><span class="sd"> """</span> +</span><span id="table_name-5703"><a href="#table_name-5703"><span class="linenos">5703</span></a> +</span><span id="table_name-5704"><a href="#table_name-5704"><span class="linenos">5704</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">Table</span><span class="p">)</span> +</span><span id="table_name-5705"><a href="#table_name-5705"><span class="linenos">5705</span></a> +</span><span id="table_name-5706"><a href="#table_name-5706"><span class="linenos">5706</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span><span class="p">:</span> +</span><span id="table_name-5707"><a href="#table_name-5707"><span class="linenos">5707</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Cannot parse </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="table_name-5708"><a href="#table_name-5708"><span class="linenos">5708</span></a> +</span><span id="table_name-5709"><a href="#table_name-5709"><span class="linenos">5709</span></a> <span class="k">return</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">part</span> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">),</span> <span class="n">table</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"db"</span><span class="p">),</span> <span class="n">table</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> <span class="k">if</span> <span class="n">part</span><span class="p">)</span> </span></pre></div> @@ -51956,34 +52090,34 @@ If either are provided then an alias is also required.</li> </div> <a class="headerlink" href="#replace_tables"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="replace_tables-5702"><a href="#replace_tables-5702"><span class="linenos">5702</span></a><span class="k">def</span> <span class="nf">replace_tables</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">mapping</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="replace_tables-5703"><a href="#replace_tables-5703"><span class="linenos">5703</span></a><span class="w"> </span><span class="sd">"""Replace all tables in expression according to the mapping.</span> -</span><span id="replace_tables-5704"><a href="#replace_tables-5704"><span class="linenos">5704</span></a> -</span><span id="replace_tables-5705"><a href="#replace_tables-5705"><span class="linenos">5705</span></a><span class="sd"> Args:</span> -</span><span id="replace_tables-5706"><a href="#replace_tables-5706"><span class="linenos">5706</span></a><span class="sd"> expression: expression node to be transformed and replaced.</span> -</span><span id="replace_tables-5707"><a href="#replace_tables-5707"><span class="linenos">5707</span></a><span class="sd"> mapping: mapping of table names.</span> -</span><span id="replace_tables-5708"><a href="#replace_tables-5708"><span class="linenos">5708</span></a><span class="sd"> copy: whether or not to copy the expression.</span> -</span><span id="replace_tables-5709"><a href="#replace_tables-5709"><span class="linenos">5709</span></a> -</span><span id="replace_tables-5710"><a href="#replace_tables-5710"><span class="linenos">5710</span></a><span class="sd"> Examples:</span> -</span><span id="replace_tables-5711"><a href="#replace_tables-5711"><span class="linenos">5711</span></a><span class="sd"> >>> from sqlglot import exp, parse_one</span> -</span><span id="replace_tables-5712"><a href="#replace_tables-5712"><span class="linenos">5712</span></a><span class="sd"> >>> replace_tables(parse_one("select * from a.b"), {"a.b": "c"}).sql()</span> -</span><span id="replace_tables-5713"><a href="#replace_tables-5713"><span class="linenos">5713</span></a><span class="sd"> 'SELECT * FROM c'</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="replace_tables-5712"><a href="#replace_tables-5712"><span class="linenos">5712</span></a><span class="k">def</span> <span class="nf">replace_tables</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">mapping</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="replace_tables-5713"><a href="#replace_tables-5713"><span class="linenos">5713</span></a><span class="w"> </span><span class="sd">"""Replace all tables in expression according to the mapping.</span> </span><span id="replace_tables-5714"><a href="#replace_tables-5714"><span class="linenos">5714</span></a> -</span><span id="replace_tables-5715"><a href="#replace_tables-5715"><span class="linenos">5715</span></a><span class="sd"> Returns:</span> -</span><span id="replace_tables-5716"><a href="#replace_tables-5716"><span class="linenos">5716</span></a><span class="sd"> The mapped expression.</span> -</span><span id="replace_tables-5717"><a href="#replace_tables-5717"><span class="linenos">5717</span></a><span class="sd"> """</span> -</span><span id="replace_tables-5718"><a href="#replace_tables-5718"><span class="linenos">5718</span></a> -</span><span id="replace_tables-5719"><a href="#replace_tables-5719"><span class="linenos">5719</span></a> <span class="k">def</span> <span class="nf">_replace_tables</span><span class="p">(</span><span class="n">node</span><span class="p">:</span> <span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> -</span><span id="replace_tables-5720"><a href="#replace_tables-5720"><span class="linenos">5720</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">Table</span><span class="p">):</span> -</span><span id="replace_tables-5721"><a href="#replace_tables-5721"><span class="linenos">5721</span></a> <span class="n">new_name</span> <span class="o">=</span> <span class="n">mapping</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table_name</span><span class="p">(</span><span class="n">node</span><span class="p">))</span> -</span><span id="replace_tables-5722"><a href="#replace_tables-5722"><span class="linenos">5722</span></a> <span class="k">if</span> <span class="n">new_name</span><span class="p">:</span> -</span><span id="replace_tables-5723"><a href="#replace_tables-5723"><span class="linenos">5723</span></a> <span class="k">return</span> <span class="n">to_table</span><span class="p">(</span> -</span><span id="replace_tables-5724"><a href="#replace_tables-5724"><span class="linenos">5724</span></a> <span class="n">new_name</span><span class="p">,</span> -</span><span id="replace_tables-5725"><a href="#replace_tables-5725"><span class="linenos">5725</span></a> <span class="o">**</span><span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="n">v</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">node</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="k">if</span> <span class="n">k</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="s2">"db"</span><span class="p">,</span> <span class="s2">"catalog"</span><span class="p">)},</span> -</span><span id="replace_tables-5726"><a href="#replace_tables-5726"><span class="linenos">5726</span></a> <span class="p">)</span> -</span><span id="replace_tables-5727"><a href="#replace_tables-5727"><span class="linenos">5727</span></a> <span class="k">return</span> <span class="n">node</span> +</span><span id="replace_tables-5715"><a href="#replace_tables-5715"><span class="linenos">5715</span></a><span class="sd"> Args:</span> +</span><span id="replace_tables-5716"><a href="#replace_tables-5716"><span class="linenos">5716</span></a><span class="sd"> expression: expression node to be transformed and replaced.</span> +</span><span id="replace_tables-5717"><a href="#replace_tables-5717"><span class="linenos">5717</span></a><span class="sd"> mapping: mapping of table names.</span> +</span><span id="replace_tables-5718"><a href="#replace_tables-5718"><span class="linenos">5718</span></a><span class="sd"> copy: whether or not to copy the expression.</span> +</span><span id="replace_tables-5719"><a href="#replace_tables-5719"><span class="linenos">5719</span></a> +</span><span id="replace_tables-5720"><a href="#replace_tables-5720"><span class="linenos">5720</span></a><span class="sd"> Examples:</span> +</span><span id="replace_tables-5721"><a href="#replace_tables-5721"><span class="linenos">5721</span></a><span class="sd"> >>> from sqlglot import exp, parse_one</span> +</span><span id="replace_tables-5722"><a href="#replace_tables-5722"><span class="linenos">5722</span></a><span class="sd"> >>> replace_tables(parse_one("select * from a.b"), {"a.b": "c"}).sql()</span> +</span><span id="replace_tables-5723"><a href="#replace_tables-5723"><span class="linenos">5723</span></a><span class="sd"> 'SELECT * FROM c'</span> +</span><span id="replace_tables-5724"><a href="#replace_tables-5724"><span class="linenos">5724</span></a> +</span><span id="replace_tables-5725"><a href="#replace_tables-5725"><span class="linenos">5725</span></a><span class="sd"> Returns:</span> +</span><span id="replace_tables-5726"><a href="#replace_tables-5726"><span class="linenos">5726</span></a><span class="sd"> The mapped expression.</span> +</span><span id="replace_tables-5727"><a href="#replace_tables-5727"><span class="linenos">5727</span></a><span class="sd"> """</span> </span><span id="replace_tables-5728"><a href="#replace_tables-5728"><span class="linenos">5728</span></a> -</span><span id="replace_tables-5729"><a href="#replace_tables-5729"><span class="linenos">5729</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_replace_tables</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> +</span><span id="replace_tables-5729"><a href="#replace_tables-5729"><span class="linenos">5729</span></a> <span class="k">def</span> <span class="nf">_replace_tables</span><span class="p">(</span><span class="n">node</span><span class="p">:</span> <span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> +</span><span id="replace_tables-5730"><a href="#replace_tables-5730"><span class="linenos">5730</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">Table</span><span class="p">):</span> +</span><span id="replace_tables-5731"><a href="#replace_tables-5731"><span class="linenos">5731</span></a> <span class="n">new_name</span> <span class="o">=</span> <span class="n">mapping</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table_name</span><span class="p">(</span><span class="n">node</span><span class="p">))</span> +</span><span id="replace_tables-5732"><a href="#replace_tables-5732"><span class="linenos">5732</span></a> <span class="k">if</span> <span class="n">new_name</span><span class="p">:</span> +</span><span id="replace_tables-5733"><a href="#replace_tables-5733"><span class="linenos">5733</span></a> <span class="k">return</span> <span class="n">to_table</span><span class="p">(</span> +</span><span id="replace_tables-5734"><a href="#replace_tables-5734"><span class="linenos">5734</span></a> <span class="n">new_name</span><span class="p">,</span> +</span><span id="replace_tables-5735"><a href="#replace_tables-5735"><span class="linenos">5735</span></a> <span class="o">**</span><span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="n">v</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">node</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="k">if</span> <span class="n">k</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="s2">"db"</span><span class="p">,</span> <span class="s2">"catalog"</span><span class="p">)},</span> +</span><span id="replace_tables-5736"><a href="#replace_tables-5736"><span class="linenos">5736</span></a> <span class="p">)</span> +</span><span id="replace_tables-5737"><a href="#replace_tables-5737"><span class="linenos">5737</span></a> <span class="k">return</span> <span class="n">node</span> +</span><span id="replace_tables-5738"><a href="#replace_tables-5738"><span class="linenos">5738</span></a> +</span><span id="replace_tables-5739"><a href="#replace_tables-5739"><span class="linenos">5739</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_replace_tables</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> </span></pre></div> @@ -52028,40 +52162,40 @@ If either are provided then an alias is also required.</li> </div> <a class="headerlink" href="#replace_placeholders"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="replace_placeholders-5732"><a href="#replace_placeholders-5732"><span class="linenos">5732</span></a><span class="k">def</span> <span class="nf">replace_placeholders</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> -</span><span id="replace_placeholders-5733"><a href="#replace_placeholders-5733"><span class="linenos">5733</span></a><span class="w"> </span><span class="sd">"""Replace placeholders in an expression.</span> -</span><span id="replace_placeholders-5734"><a href="#replace_placeholders-5734"><span class="linenos">5734</span></a> -</span><span id="replace_placeholders-5735"><a href="#replace_placeholders-5735"><span class="linenos">5735</span></a><span class="sd"> Args:</span> -</span><span id="replace_placeholders-5736"><a href="#replace_placeholders-5736"><span class="linenos">5736</span></a><span class="sd"> expression: expression node to be transformed and replaced.</span> -</span><span id="replace_placeholders-5737"><a href="#replace_placeholders-5737"><span class="linenos">5737</span></a><span class="sd"> args: positional names that will substitute unnamed placeholders in the given order.</span> -</span><span id="replace_placeholders-5738"><a href="#replace_placeholders-5738"><span class="linenos">5738</span></a><span class="sd"> kwargs: keyword arguments that will substitute named placeholders.</span> -</span><span id="replace_placeholders-5739"><a href="#replace_placeholders-5739"><span class="linenos">5739</span></a> -</span><span id="replace_placeholders-5740"><a href="#replace_placeholders-5740"><span class="linenos">5740</span></a><span class="sd"> Examples:</span> -</span><span id="replace_placeholders-5741"><a href="#replace_placeholders-5741"><span class="linenos">5741</span></a><span class="sd"> >>> from sqlglot import exp, parse_one</span> -</span><span id="replace_placeholders-5742"><a href="#replace_placeholders-5742"><span class="linenos">5742</span></a><span class="sd"> >>> replace_placeholders(</span> -</span><span id="replace_placeholders-5743"><a href="#replace_placeholders-5743"><span class="linenos">5743</span></a><span class="sd"> ... parse_one("select * from :tbl where ? = ?"),</span> -</span><span id="replace_placeholders-5744"><a href="#replace_placeholders-5744"><span class="linenos">5744</span></a><span class="sd"> ... exp.to_identifier("str_col"), "b", tbl=exp.to_identifier("foo")</span> -</span><span id="replace_placeholders-5745"><a href="#replace_placeholders-5745"><span class="linenos">5745</span></a><span class="sd"> ... ).sql()</span> -</span><span id="replace_placeholders-5746"><a href="#replace_placeholders-5746"><span class="linenos">5746</span></a><span class="sd"> "SELECT * FROM foo WHERE str_col = 'b'"</span> -</span><span id="replace_placeholders-5747"><a href="#replace_placeholders-5747"><span class="linenos">5747</span></a> -</span><span id="replace_placeholders-5748"><a href="#replace_placeholders-5748"><span class="linenos">5748</span></a><span class="sd"> Returns:</span> -</span><span id="replace_placeholders-5749"><a href="#replace_placeholders-5749"><span class="linenos">5749</span></a><span class="sd"> The mapped expression.</span> -</span><span id="replace_placeholders-5750"><a href="#replace_placeholders-5750"><span class="linenos">5750</span></a><span class="sd"> """</span> -</span><span id="replace_placeholders-5751"><a href="#replace_placeholders-5751"><span class="linenos">5751</span></a> -</span><span id="replace_placeholders-5752"><a href="#replace_placeholders-5752"><span class="linenos">5752</span></a> <span class="k">def</span> <span class="nf">_replace_placeholders</span><span class="p">(</span><span class="n">node</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> -</span><span id="replace_placeholders-5753"><a href="#replace_placeholders-5753"><span class="linenos">5753</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">Placeholder</span><span class="p">):</span> -</span><span id="replace_placeholders-5754"><a href="#replace_placeholders-5754"><span class="linenos">5754</span></a> <span class="k">if</span> <span class="n">node</span><span class="o">.</span><span class="n">name</span><span class="p">:</span> -</span><span id="replace_placeholders-5755"><a href="#replace_placeholders-5755"><span class="linenos">5755</span></a> <span class="n">new_name</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> -</span><span id="replace_placeholders-5756"><a href="#replace_placeholders-5756"><span class="linenos">5756</span></a> <span class="k">if</span> <span class="n">new_name</span><span class="p">:</span> -</span><span id="replace_placeholders-5757"><a href="#replace_placeholders-5757"><span class="linenos">5757</span></a> <span class="k">return</span> <span class="n">convert</span><span class="p">(</span><span class="n">new_name</span><span class="p">)</span> -</span><span id="replace_placeholders-5758"><a href="#replace_placeholders-5758"><span class="linenos">5758</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="replace_placeholders-5759"><a href="#replace_placeholders-5759"><span class="linenos">5759</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="replace_placeholders-5760"><a href="#replace_placeholders-5760"><span class="linenos">5760</span></a> <span class="k">return</span> <span class="n">convert</span><span class="p">(</span><span class="nb">next</span><span class="p">(</span><span class="n">args</span><span class="p">))</span> -</span><span id="replace_placeholders-5761"><a href="#replace_placeholders-5761"><span class="linenos">5761</span></a> <span class="k">except</span> <span class="ne">StopIteration</span><span class="p">:</span> -</span><span id="replace_placeholders-5762"><a href="#replace_placeholders-5762"><span class="linenos">5762</span></a> <span class="k">pass</span> -</span><span id="replace_placeholders-5763"><a href="#replace_placeholders-5763"><span class="linenos">5763</span></a> <span class="k">return</span> <span class="n">node</span> -</span><span id="replace_placeholders-5764"><a href="#replace_placeholders-5764"><span class="linenos">5764</span></a> -</span><span id="replace_placeholders-5765"><a href="#replace_placeholders-5765"><span class="linenos">5765</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_replace_placeholders</span><span class="p">,</span> <span class="nb">iter</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="replace_placeholders-5742"><a href="#replace_placeholders-5742"><span class="linenos">5742</span></a><span class="k">def</span> <span class="nf">replace_placeholders</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> +</span><span id="replace_placeholders-5743"><a href="#replace_placeholders-5743"><span class="linenos">5743</span></a><span class="w"> </span><span class="sd">"""Replace placeholders in an expression.</span> +</span><span id="replace_placeholders-5744"><a href="#replace_placeholders-5744"><span class="linenos">5744</span></a> +</span><span id="replace_placeholders-5745"><a href="#replace_placeholders-5745"><span class="linenos">5745</span></a><span class="sd"> Args:</span> +</span><span id="replace_placeholders-5746"><a href="#replace_placeholders-5746"><span class="linenos">5746</span></a><span class="sd"> expression: expression node to be transformed and replaced.</span> +</span><span id="replace_placeholders-5747"><a href="#replace_placeholders-5747"><span class="linenos">5747</span></a><span class="sd"> args: positional names that will substitute unnamed placeholders in the given order.</span> +</span><span id="replace_placeholders-5748"><a href="#replace_placeholders-5748"><span class="linenos">5748</span></a><span class="sd"> kwargs: keyword arguments that will substitute named placeholders.</span> +</span><span id="replace_placeholders-5749"><a href="#replace_placeholders-5749"><span class="linenos">5749</span></a> +</span><span id="replace_placeholders-5750"><a href="#replace_placeholders-5750"><span class="linenos">5750</span></a><span class="sd"> Examples:</span> +</span><span id="replace_placeholders-5751"><a href="#replace_placeholders-5751"><span class="linenos">5751</span></a><span class="sd"> >>> from sqlglot import exp, parse_one</span> +</span><span id="replace_placeholders-5752"><a href="#replace_placeholders-5752"><span class="linenos">5752</span></a><span class="sd"> >>> replace_placeholders(</span> +</span><span id="replace_placeholders-5753"><a href="#replace_placeholders-5753"><span class="linenos">5753</span></a><span class="sd"> ... parse_one("select * from :tbl where ? = ?"),</span> +</span><span id="replace_placeholders-5754"><a href="#replace_placeholders-5754"><span class="linenos">5754</span></a><span class="sd"> ... exp.to_identifier("str_col"), "b", tbl=exp.to_identifier("foo")</span> +</span><span id="replace_placeholders-5755"><a href="#replace_placeholders-5755"><span class="linenos">5755</span></a><span class="sd"> ... ).sql()</span> +</span><span id="replace_placeholders-5756"><a href="#replace_placeholders-5756"><span class="linenos">5756</span></a><span class="sd"> "SELECT * FROM foo WHERE str_col = 'b'"</span> +</span><span id="replace_placeholders-5757"><a href="#replace_placeholders-5757"><span class="linenos">5757</span></a> +</span><span id="replace_placeholders-5758"><a href="#replace_placeholders-5758"><span class="linenos">5758</span></a><span class="sd"> Returns:</span> +</span><span id="replace_placeholders-5759"><a href="#replace_placeholders-5759"><span class="linenos">5759</span></a><span class="sd"> The mapped expression.</span> +</span><span id="replace_placeholders-5760"><a href="#replace_placeholders-5760"><span class="linenos">5760</span></a><span class="sd"> """</span> +</span><span id="replace_placeholders-5761"><a href="#replace_placeholders-5761"><span class="linenos">5761</span></a> +</span><span id="replace_placeholders-5762"><a href="#replace_placeholders-5762"><span class="linenos">5762</span></a> <span class="k">def</span> <span class="nf">_replace_placeholders</span><span class="p">(</span><span class="n">node</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> +</span><span id="replace_placeholders-5763"><a href="#replace_placeholders-5763"><span class="linenos">5763</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">Placeholder</span><span class="p">):</span> +</span><span id="replace_placeholders-5764"><a href="#replace_placeholders-5764"><span class="linenos">5764</span></a> <span class="k">if</span> <span class="n">node</span><span class="o">.</span><span class="n">name</span><span class="p">:</span> +</span><span id="replace_placeholders-5765"><a href="#replace_placeholders-5765"><span class="linenos">5765</span></a> <span class="n">new_name</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> +</span><span id="replace_placeholders-5766"><a href="#replace_placeholders-5766"><span class="linenos">5766</span></a> <span class="k">if</span> <span class="n">new_name</span><span class="p">:</span> +</span><span id="replace_placeholders-5767"><a href="#replace_placeholders-5767"><span class="linenos">5767</span></a> <span class="k">return</span> <span class="n">convert</span><span class="p">(</span><span class="n">new_name</span><span class="p">)</span> +</span><span id="replace_placeholders-5768"><a href="#replace_placeholders-5768"><span class="linenos">5768</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="replace_placeholders-5769"><a href="#replace_placeholders-5769"><span class="linenos">5769</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="replace_placeholders-5770"><a href="#replace_placeholders-5770"><span class="linenos">5770</span></a> <span class="k">return</span> <span class="n">convert</span><span class="p">(</span><span class="nb">next</span><span class="p">(</span><span class="n">args</span><span class="p">))</span> +</span><span id="replace_placeholders-5771"><a href="#replace_placeholders-5771"><span class="linenos">5771</span></a> <span class="k">except</span> <span class="ne">StopIteration</span><span class="p">:</span> +</span><span id="replace_placeholders-5772"><a href="#replace_placeholders-5772"><span class="linenos">5772</span></a> <span class="k">pass</span> +</span><span id="replace_placeholders-5773"><a href="#replace_placeholders-5773"><span class="linenos">5773</span></a> <span class="k">return</span> <span class="n">node</span> +</span><span id="replace_placeholders-5774"><a href="#replace_placeholders-5774"><span class="linenos">5774</span></a> +</span><span id="replace_placeholders-5775"><a href="#replace_placeholders-5775"><span class="linenos">5775</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_replace_placeholders</span><span class="p">,</span> <span class="nb">iter</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> </span></pre></div> @@ -52109,39 +52243,39 @@ If either are provided then an alias is also required.</li> </div> <a class="headerlink" href="#expand"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="expand-5768"><a href="#expand-5768"><span class="linenos">5768</span></a><span class="k">def</span> <span class="nf">expand</span><span class="p">(</span> -</span><span id="expand-5769"><a href="#expand-5769"><span class="linenos">5769</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="n">sources</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Subqueryable</span><span class="p">],</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="expand-5770"><a href="#expand-5770"><span class="linenos">5770</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> -</span><span id="expand-5771"><a href="#expand-5771"><span class="linenos">5771</span></a><span class="w"> </span><span class="sd">"""Transforms an expression by expanding all referenced sources into subqueries.</span> -</span><span id="expand-5772"><a href="#expand-5772"><span class="linenos">5772</span></a> -</span><span id="expand-5773"><a href="#expand-5773"><span class="linenos">5773</span></a><span class="sd"> Examples:</span> -</span><span id="expand-5774"><a href="#expand-5774"><span class="linenos">5774</span></a><span class="sd"> >>> from sqlglot import parse_one</span> -</span><span id="expand-5775"><a href="#expand-5775"><span class="linenos">5775</span></a><span class="sd"> >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y")}).sql()</span> -</span><span id="expand-5776"><a href="#expand-5776"><span class="linenos">5776</span></a><span class="sd"> 'SELECT * FROM (SELECT * FROM y) AS z /* source: x */'</span> -</span><span id="expand-5777"><a href="#expand-5777"><span class="linenos">5777</span></a> -</span><span id="expand-5778"><a href="#expand-5778"><span class="linenos">5778</span></a><span class="sd"> >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y"), "y": parse_one("select * from z")}).sql()</span> -</span><span id="expand-5779"><a href="#expand-5779"><span class="linenos">5779</span></a><span class="sd"> 'SELECT * FROM (SELECT * FROM (SELECT * FROM z) AS y /* source: y */) AS z /* source: x */'</span> -</span><span id="expand-5780"><a href="#expand-5780"><span class="linenos">5780</span></a> -</span><span id="expand-5781"><a href="#expand-5781"><span class="linenos">5781</span></a><span class="sd"> Args:</span> -</span><span id="expand-5782"><a href="#expand-5782"><span class="linenos">5782</span></a><span class="sd"> expression: The expression to expand.</span> -</span><span id="expand-5783"><a href="#expand-5783"><span class="linenos">5783</span></a><span class="sd"> sources: A dictionary of name to Subqueryables.</span> -</span><span id="expand-5784"><a href="#expand-5784"><span class="linenos">5784</span></a><span class="sd"> copy: Whether or not to copy the expression during transformation. Defaults to True.</span> -</span><span id="expand-5785"><a href="#expand-5785"><span class="linenos">5785</span></a> -</span><span id="expand-5786"><a href="#expand-5786"><span class="linenos">5786</span></a><span class="sd"> Returns:</span> -</span><span id="expand-5787"><a href="#expand-5787"><span class="linenos">5787</span></a><span class="sd"> The transformed expression.</span> -</span><span id="expand-5788"><a href="#expand-5788"><span class="linenos">5788</span></a><span class="sd"> """</span> -</span><span id="expand-5789"><a href="#expand-5789"><span class="linenos">5789</span></a> -</span><span id="expand-5790"><a href="#expand-5790"><span class="linenos">5790</span></a> <span class="k">def</span> <span class="nf">_expand</span><span class="p">(</span><span class="n">node</span><span class="p">:</span> <span class="n">Expression</span><span class="p">):</span> -</span><span id="expand-5791"><a href="#expand-5791"><span class="linenos">5791</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">Table</span><span class="p">):</span> -</span><span id="expand-5792"><a href="#expand-5792"><span class="linenos">5792</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">table_name</span><span class="p">(</span><span class="n">node</span><span class="p">)</span> -</span><span id="expand-5793"><a href="#expand-5793"><span class="linenos">5793</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">sources</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> -</span><span id="expand-5794"><a href="#expand-5794"><span class="linenos">5794</span></a> <span class="k">if</span> <span class="n">source</span><span class="p">:</span> -</span><span id="expand-5795"><a href="#expand-5795"><span class="linenos">5795</span></a> <span class="n">subquery</span> <span class="o">=</span> <span class="n">source</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">alias</span> <span class="ow">or</span> <span class="n">name</span><span class="p">)</span> -</span><span id="expand-5796"><a href="#expand-5796"><span class="linenos">5796</span></a> <span class="n">subquery</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="p">[</span><span class="sa">f</span><span class="s2">"source: </span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span><span class="p">]</span> -</span><span id="expand-5797"><a href="#expand-5797"><span class="linenos">5797</span></a> <span class="k">return</span> <span class="n">subquery</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_expand</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="expand-5798"><a href="#expand-5798"><span class="linenos">5798</span></a> <span class="k">return</span> <span class="n">node</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="expand-5778"><a href="#expand-5778"><span class="linenos">5778</span></a><span class="k">def</span> <span class="nf">expand</span><span class="p">(</span> +</span><span id="expand-5779"><a href="#expand-5779"><span class="linenos">5779</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="n">sources</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Subqueryable</span><span class="p">],</span> <span class="n">copy</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="expand-5780"><a href="#expand-5780"><span class="linenos">5780</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">Expression</span><span class="p">:</span> +</span><span id="expand-5781"><a href="#expand-5781"><span class="linenos">5781</span></a><span class="w"> </span><span class="sd">"""Transforms an expression by expanding all referenced sources into subqueries.</span> +</span><span id="expand-5782"><a href="#expand-5782"><span class="linenos">5782</span></a> +</span><span id="expand-5783"><a href="#expand-5783"><span class="linenos">5783</span></a><span class="sd"> Examples:</span> +</span><span id="expand-5784"><a href="#expand-5784"><span class="linenos">5784</span></a><span class="sd"> >>> from sqlglot import parse_one</span> +</span><span id="expand-5785"><a href="#expand-5785"><span class="linenos">5785</span></a><span class="sd"> >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y")}).sql()</span> +</span><span id="expand-5786"><a href="#expand-5786"><span class="linenos">5786</span></a><span class="sd"> 'SELECT * FROM (SELECT * FROM y) AS z /* source: x */'</span> +</span><span id="expand-5787"><a href="#expand-5787"><span class="linenos">5787</span></a> +</span><span id="expand-5788"><a href="#expand-5788"><span class="linenos">5788</span></a><span class="sd"> >>> expand(parse_one("select * from x AS z"), {"x": parse_one("select * from y"), "y": parse_one("select * from z")}).sql()</span> +</span><span id="expand-5789"><a href="#expand-5789"><span class="linenos">5789</span></a><span class="sd"> 'SELECT * FROM (SELECT * FROM (SELECT * FROM z) AS y /* source: y */) AS z /* source: x */'</span> +</span><span id="expand-5790"><a href="#expand-5790"><span class="linenos">5790</span></a> +</span><span id="expand-5791"><a href="#expand-5791"><span class="linenos">5791</span></a><span class="sd"> Args:</span> +</span><span id="expand-5792"><a href="#expand-5792"><span class="linenos">5792</span></a><span class="sd"> expression: The expression to expand.</span> +</span><span id="expand-5793"><a href="#expand-5793"><span class="linenos">5793</span></a><span class="sd"> sources: A dictionary of name to Subqueryables.</span> +</span><span id="expand-5794"><a href="#expand-5794"><span class="linenos">5794</span></a><span class="sd"> copy: Whether or not to copy the expression during transformation. Defaults to True.</span> +</span><span id="expand-5795"><a href="#expand-5795"><span class="linenos">5795</span></a> +</span><span id="expand-5796"><a href="#expand-5796"><span class="linenos">5796</span></a><span class="sd"> Returns:</span> +</span><span id="expand-5797"><a href="#expand-5797"><span class="linenos">5797</span></a><span class="sd"> The transformed expression.</span> +</span><span id="expand-5798"><a href="#expand-5798"><span class="linenos">5798</span></a><span class="sd"> """</span> </span><span id="expand-5799"><a href="#expand-5799"><span class="linenos">5799</span></a> -</span><span id="expand-5800"><a href="#expand-5800"><span class="linenos">5800</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_expand</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> +</span><span id="expand-5800"><a href="#expand-5800"><span class="linenos">5800</span></a> <span class="k">def</span> <span class="nf">_expand</span><span class="p">(</span><span class="n">node</span><span class="p">:</span> <span class="n">Expression</span><span class="p">):</span> +</span><span id="expand-5801"><a href="#expand-5801"><span class="linenos">5801</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">Table</span><span class="p">):</span> +</span><span id="expand-5802"><a href="#expand-5802"><span class="linenos">5802</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">table_name</span><span class="p">(</span><span class="n">node</span><span class="p">)</span> +</span><span id="expand-5803"><a href="#expand-5803"><span class="linenos">5803</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">sources</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> +</span><span id="expand-5804"><a href="#expand-5804"><span class="linenos">5804</span></a> <span class="k">if</span> <span class="n">source</span><span class="p">:</span> +</span><span id="expand-5805"><a href="#expand-5805"><span class="linenos">5805</span></a> <span class="n">subquery</span> <span class="o">=</span> <span class="n">source</span><span class="o">.</span><span class="n">subquery</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">alias</span> <span class="ow">or</span> <span class="n">name</span><span class="p">)</span> +</span><span id="expand-5806"><a href="#expand-5806"><span class="linenos">5806</span></a> <span class="n">subquery</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="p">[</span><span class="sa">f</span><span class="s2">"source: </span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span><span class="p">]</span> +</span><span id="expand-5807"><a href="#expand-5807"><span class="linenos">5807</span></a> <span class="k">return</span> <span class="n">subquery</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_expand</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="expand-5808"><a href="#expand-5808"><span class="linenos">5808</span></a> <span class="k">return</span> <span class="n">node</span> +</span><span id="expand-5809"><a href="#expand-5809"><span class="linenos">5809</span></a> +</span><span id="expand-5810"><a href="#expand-5810"><span class="linenos">5810</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_expand</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="n">copy</span><span class="p">)</span> </span></pre></div> @@ -52192,51 +52326,51 @@ If either are provided then an alias is also required.</li> </div> <a class="headerlink" href="#func"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="func-5803"><a href="#func-5803"><span class="linenos">5803</span></a><span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Func</span><span class="p">:</span> -</span><span id="func-5804"><a href="#func-5804"><span class="linenos">5804</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="func-5805"><a href="#func-5805"><span class="linenos">5805</span></a><span class="sd"> Returns a Func expression.</span> -</span><span id="func-5806"><a href="#func-5806"><span class="linenos">5806</span></a> -</span><span id="func-5807"><a href="#func-5807"><span class="linenos">5807</span></a><span class="sd"> Examples:</span> -</span><span id="func-5808"><a href="#func-5808"><span class="linenos">5808</span></a><span class="sd"> >>> func("abs", 5).sql()</span> -</span><span id="func-5809"><a href="#func-5809"><span class="linenos">5809</span></a><span class="sd"> 'ABS(5)'</span> -</span><span id="func-5810"><a href="#func-5810"><span class="linenos">5810</span></a> -</span><span id="func-5811"><a href="#func-5811"><span class="linenos">5811</span></a><span class="sd"> >>> func("cast", this=5, to=DataType.build("DOUBLE")).sql()</span> -</span><span id="func-5812"><a href="#func-5812"><span class="linenos">5812</span></a><span class="sd"> 'CAST(5 AS DOUBLE)'</span> -</span><span id="func-5813"><a href="#func-5813"><span class="linenos">5813</span></a> -</span><span id="func-5814"><a href="#func-5814"><span class="linenos">5814</span></a><span class="sd"> Args:</span> -</span><span id="func-5815"><a href="#func-5815"><span class="linenos">5815</span></a><span class="sd"> name: the name of the function to build.</span> -</span><span id="func-5816"><a href="#func-5816"><span class="linenos">5816</span></a><span class="sd"> args: the args used to instantiate the function of interest.</span> -</span><span id="func-5817"><a href="#func-5817"><span class="linenos">5817</span></a><span class="sd"> dialect: the source dialect.</span> -</span><span id="func-5818"><a href="#func-5818"><span class="linenos">5818</span></a><span class="sd"> kwargs: the kwargs used to instantiate the function of interest.</span> -</span><span id="func-5819"><a href="#func-5819"><span class="linenos">5819</span></a> -</span><span id="func-5820"><a href="#func-5820"><span class="linenos">5820</span></a><span class="sd"> Note:</span> -</span><span id="func-5821"><a href="#func-5821"><span class="linenos">5821</span></a><span class="sd"> The arguments `args` and `kwargs` are mutually exclusive.</span> -</span><span id="func-5822"><a href="#func-5822"><span class="linenos">5822</span></a> -</span><span id="func-5823"><a href="#func-5823"><span class="linenos">5823</span></a><span class="sd"> Returns:</span> -</span><span id="func-5824"><a href="#func-5824"><span class="linenos">5824</span></a><span class="sd"> An instance of the function of interest, or an anonymous function, if `name` doesn't</span> -</span><span id="func-5825"><a href="#func-5825"><span class="linenos">5825</span></a><span class="sd"> correspond to an existing `sqlglot.expressions.Func` class.</span> -</span><span id="func-5826"><a href="#func-5826"><span class="linenos">5826</span></a><span class="sd"> """</span> -</span><span id="func-5827"><a href="#func-5827"><span class="linenos">5827</span></a> <span class="k">if</span> <span class="n">args</span> <span class="ow">and</span> <span class="n">kwargs</span><span class="p">:</span> -</span><span id="func-5828"><a href="#func-5828"><span class="linenos">5828</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Can't use both args and kwargs to instantiate a function."</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="func-5813"><a href="#func-5813"><span class="linenos">5813</span></a><span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">Func</span><span class="p">:</span> +</span><span id="func-5814"><a href="#func-5814"><span class="linenos">5814</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="func-5815"><a href="#func-5815"><span class="linenos">5815</span></a><span class="sd"> Returns a Func expression.</span> +</span><span id="func-5816"><a href="#func-5816"><span class="linenos">5816</span></a> +</span><span id="func-5817"><a href="#func-5817"><span class="linenos">5817</span></a><span class="sd"> Examples:</span> +</span><span id="func-5818"><a href="#func-5818"><span class="linenos">5818</span></a><span class="sd"> >>> func("abs", 5).sql()</span> +</span><span id="func-5819"><a href="#func-5819"><span class="linenos">5819</span></a><span class="sd"> 'ABS(5)'</span> +</span><span id="func-5820"><a href="#func-5820"><span class="linenos">5820</span></a> +</span><span id="func-5821"><a href="#func-5821"><span class="linenos">5821</span></a><span class="sd"> >>> func("cast", this=5, to=DataType.build("DOUBLE")).sql()</span> +</span><span id="func-5822"><a href="#func-5822"><span class="linenos">5822</span></a><span class="sd"> 'CAST(5 AS DOUBLE)'</span> +</span><span id="func-5823"><a href="#func-5823"><span class="linenos">5823</span></a> +</span><span id="func-5824"><a href="#func-5824"><span class="linenos">5824</span></a><span class="sd"> Args:</span> +</span><span id="func-5825"><a href="#func-5825"><span class="linenos">5825</span></a><span class="sd"> name: the name of the function to build.</span> +</span><span id="func-5826"><a href="#func-5826"><span class="linenos">5826</span></a><span class="sd"> args: the args used to instantiate the function of interest.</span> +</span><span id="func-5827"><a href="#func-5827"><span class="linenos">5827</span></a><span class="sd"> dialect: the source dialect.</span> +</span><span id="func-5828"><a href="#func-5828"><span class="linenos">5828</span></a><span class="sd"> kwargs: the kwargs used to instantiate the function of interest.</span> </span><span id="func-5829"><a href="#func-5829"><span class="linenos">5829</span></a> -</span><span id="func-5830"><a href="#func-5830"><span class="linenos">5830</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dialects.dialect</span> <span class="kn">import</span> <span class="n">Dialect</span> -</span><span id="func-5831"><a href="#func-5831"><span class="linenos">5831</span></a> -</span><span id="func-5832"><a href="#func-5832"><span class="linenos">5832</span></a> <span class="n">converted</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">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">]</span> -</span><span id="func-5833"><a href="#func-5833"><span class="linenos">5833</span></a> <span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span><span class="n">key</span><span class="p">:</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span> -</span><span id="func-5834"><a href="#func-5834"><span class="linenos">5834</span></a> -</span><span id="func-5835"><a href="#func-5835"><span class="linenos">5835</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)()</span><span class="o">.</span><span class="n">parser</span><span class="p">()</span> -</span><span id="func-5836"><a href="#func-5836"><span class="linenos">5836</span></a> <span class="n">from_args_list</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span> -</span><span id="func-5837"><a href="#func-5837"><span class="linenos">5837</span></a> -</span><span id="func-5838"><a href="#func-5838"><span class="linenos">5838</span></a> <span class="k">if</span> <span class="n">from_args_list</span><span class="p">:</span> -</span><span id="func-5839"><a href="#func-5839"><span class="linenos">5839</span></a> <span class="n">function</span> <span class="o">=</span> <span class="n">from_args_list</span><span class="p">(</span><span class="n">converted</span><span class="p">)</span> <span class="k">if</span> <span class="n">converted</span> <span class="k">else</span> <span class="n">from_args_list</span><span class="o">.</span><span class="vm">__self__</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="func-5840"><a href="#func-5840"><span class="linenos">5840</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="func-5841"><a href="#func-5841"><span class="linenos">5841</span></a> <span class="n">kwargs</span> <span class="o">=</span> <span class="n">kwargs</span> <span class="ow">or</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="n">converted</span><span class="p">}</span> -</span><span id="func-5842"><a href="#func-5842"><span class="linenos">5842</span></a> <span class="n">function</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="n">name</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="func-5843"><a href="#func-5843"><span class="linenos">5843</span></a> -</span><span id="func-5844"><a href="#func-5844"><span class="linenos">5844</span></a> <span class="k">for</span> <span class="n">error_message</span> <span class="ow">in</span> <span class="n">function</span><span class="o">.</span><span class="n">error_messages</span><span class="p">(</span><span class="n">converted</span><span class="p">):</span> -</span><span id="func-5845"><a href="#func-5845"><span class="linenos">5845</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">error_message</span><span class="p">)</span> -</span><span id="func-5846"><a href="#func-5846"><span class="linenos">5846</span></a> -</span><span id="func-5847"><a href="#func-5847"><span class="linenos">5847</span></a> <span class="k">return</span> <span class="n">function</span> +</span><span id="func-5830"><a href="#func-5830"><span class="linenos">5830</span></a><span class="sd"> Note:</span> +</span><span id="func-5831"><a href="#func-5831"><span class="linenos">5831</span></a><span class="sd"> The arguments `args` and `kwargs` are mutually exclusive.</span> +</span><span id="func-5832"><a href="#func-5832"><span class="linenos">5832</span></a> +</span><span id="func-5833"><a href="#func-5833"><span class="linenos">5833</span></a><span class="sd"> Returns:</span> +</span><span id="func-5834"><a href="#func-5834"><span class="linenos">5834</span></a><span class="sd"> An instance of the function of interest, or an anonymous function, if `name` doesn't</span> +</span><span id="func-5835"><a href="#func-5835"><span class="linenos">5835</span></a><span class="sd"> correspond to an existing `sqlglot.expressions.Func` class.</span> +</span><span id="func-5836"><a href="#func-5836"><span class="linenos">5836</span></a><span class="sd"> """</span> +</span><span id="func-5837"><a href="#func-5837"><span class="linenos">5837</span></a> <span class="k">if</span> <span class="n">args</span> <span class="ow">and</span> <span class="n">kwargs</span><span class="p">:</span> +</span><span id="func-5838"><a href="#func-5838"><span class="linenos">5838</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Can't use both args and kwargs to instantiate a function."</span><span class="p">)</span> +</span><span id="func-5839"><a href="#func-5839"><span class="linenos">5839</span></a> +</span><span id="func-5840"><a href="#func-5840"><span class="linenos">5840</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dialects.dialect</span> <span class="kn">import</span> <span class="n">Dialect</span> +</span><span id="func-5841"><a href="#func-5841"><span class="linenos">5841</span></a> +</span><span id="func-5842"><a href="#func-5842"><span class="linenos">5842</span></a> <span class="n">converted</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">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">]</span> +</span><span id="func-5843"><a href="#func-5843"><span class="linenos">5843</span></a> <span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span><span class="n">key</span><span class="p">:</span> <span class="n">maybe_parse</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span> +</span><span id="func-5844"><a href="#func-5844"><span class="linenos">5844</span></a> +</span><span id="func-5845"><a href="#func-5845"><span class="linenos">5845</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)()</span><span class="o">.</span><span class="n">parser</span><span class="p">()</span> +</span><span id="func-5846"><a href="#func-5846"><span class="linenos">5846</span></a> <span class="n">from_args_list</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">FUNCTIONS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span> +</span><span id="func-5847"><a href="#func-5847"><span class="linenos">5847</span></a> +</span><span id="func-5848"><a href="#func-5848"><span class="linenos">5848</span></a> <span class="k">if</span> <span class="n">from_args_list</span><span class="p">:</span> +</span><span id="func-5849"><a href="#func-5849"><span class="linenos">5849</span></a> <span class="n">function</span> <span class="o">=</span> <span class="n">from_args_list</span><span class="p">(</span><span class="n">converted</span><span class="p">)</span> <span class="k">if</span> <span class="n">converted</span> <span class="k">else</span> <span class="n">from_args_list</span><span class="o">.</span><span class="vm">__self__</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="func-5850"><a href="#func-5850"><span class="linenos">5850</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="func-5851"><a href="#func-5851"><span class="linenos">5851</span></a> <span class="n">kwargs</span> <span class="o">=</span> <span class="n">kwargs</span> <span class="ow">or</span> <span class="p">{</span><span class="s2">"expressions"</span><span class="p">:</span> <span class="n">converted</span><span class="p">}</span> +</span><span id="func-5852"><a href="#func-5852"><span class="linenos">5852</span></a> <span class="n">function</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="n">name</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="func-5853"><a href="#func-5853"><span class="linenos">5853</span></a> +</span><span id="func-5854"><a href="#func-5854"><span class="linenos">5854</span></a> <span class="k">for</span> <span class="n">error_message</span> <span class="ow">in</span> <span class="n">function</span><span class="o">.</span><span class="n">error_messages</span><span class="p">(</span><span class="n">converted</span><span class="p">):</span> +</span><span id="func-5855"><a href="#func-5855"><span class="linenos">5855</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">error_message</span><span class="p">)</span> +</span><span id="func-5856"><a href="#func-5856"><span class="linenos">5856</span></a> +</span><span id="func-5857"><a href="#func-5857"><span class="linenos">5857</span></a> <span class="k">return</span> <span class="n">function</span> </span></pre></div> @@ -52294,11 +52428,11 @@ If either are provided then an alias is also required.</li> </div> <a class="headerlink" href="#true"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="true-5850"><a href="#true-5850"><span class="linenos">5850</span></a><span class="k">def</span> <span class="nf">true</span><span class="p">()</span> <span class="o">-></span> <span class="n">Boolean</span><span class="p">:</span> -</span><span id="true-5851"><a href="#true-5851"><span class="linenos">5851</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="true-5852"><a href="#true-5852"><span class="linenos">5852</span></a><span class="sd"> Returns a true Boolean expression.</span> -</span><span id="true-5853"><a href="#true-5853"><span class="linenos">5853</span></a><span class="sd"> """</span> -</span><span id="true-5854"><a href="#true-5854"><span class="linenos">5854</span></a> <span class="k">return</span> <span class="n">Boolean</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="true-5860"><a href="#true-5860"><span class="linenos">5860</span></a><span class="k">def</span> <span class="nf">true</span><span class="p">()</span> <span class="o">-></span> <span class="n">Boolean</span><span class="p">:</span> +</span><span id="true-5861"><a href="#true-5861"><span class="linenos">5861</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="true-5862"><a href="#true-5862"><span class="linenos">5862</span></a><span class="sd"> Returns a true Boolean expression.</span> +</span><span id="true-5863"><a href="#true-5863"><span class="linenos">5863</span></a><span class="sd"> """</span> +</span><span id="true-5864"><a href="#true-5864"><span class="linenos">5864</span></a> <span class="k">return</span> <span class="n">Boolean</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></pre></div> @@ -52318,11 +52452,11 @@ If either are provided then an alias is also required.</li> </div> <a class="headerlink" href="#false"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="false-5857"><a href="#false-5857"><span class="linenos">5857</span></a><span class="k">def</span> <span class="nf">false</span><span class="p">()</span> <span class="o">-></span> <span class="n">Boolean</span><span class="p">:</span> -</span><span id="false-5858"><a href="#false-5858"><span class="linenos">5858</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="false-5859"><a href="#false-5859"><span class="linenos">5859</span></a><span class="sd"> Returns a false Boolean expression.</span> -</span><span id="false-5860"><a href="#false-5860"><span class="linenos">5860</span></a><span class="sd"> """</span> -</span><span id="false-5861"><a href="#false-5861"><span class="linenos">5861</span></a> <span class="k">return</span> <span class="n">Boolean</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="false-5867"><a href="#false-5867"><span class="linenos">5867</span></a><span class="k">def</span> <span class="nf">false</span><span class="p">()</span> <span class="o">-></span> <span class="n">Boolean</span><span class="p">:</span> +</span><span id="false-5868"><a href="#false-5868"><span class="linenos">5868</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="false-5869"><a href="#false-5869"><span class="linenos">5869</span></a><span class="sd"> Returns a false Boolean expression.</span> +</span><span id="false-5870"><a href="#false-5870"><span class="linenos">5870</span></a><span class="sd"> """</span> +</span><span id="false-5871"><a href="#false-5871"><span class="linenos">5871</span></a> <span class="k">return</span> <span class="n">Boolean</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> </span></pre></div> @@ -52342,11 +52476,11 @@ If either are provided then an alias is also required.</li> </div> <a class="headerlink" href="#null"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="null-5864"><a href="#null-5864"><span class="linenos">5864</span></a><span class="k">def</span> <span class="nf">null</span><span class="p">()</span> <span class="o">-></span> <span class="n">Null</span><span class="p">:</span> -</span><span id="null-5865"><a href="#null-5865"><span class="linenos">5865</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="null-5866"><a href="#null-5866"><span class="linenos">5866</span></a><span class="sd"> Returns a Null expression.</span> -</span><span id="null-5867"><a href="#null-5867"><span class="linenos">5867</span></a><span class="sd"> """</span> -</span><span id="null-5868"><a href="#null-5868"><span class="linenos">5868</span></a> <span class="k">return</span> <span class="n">Null</span><span class="p">()</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="null-5874"><a href="#null-5874"><span class="linenos">5874</span></a><span class="k">def</span> <span class="nf">null</span><span class="p">()</span> <span class="o">-></span> <span class="n">Null</span><span class="p">:</span> +</span><span id="null-5875"><a href="#null-5875"><span class="linenos">5875</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="null-5876"><a href="#null-5876"><span class="linenos">5876</span></a><span class="sd"> Returns a Null expression.</span> +</span><span id="null-5877"><a href="#null-5877"><span class="linenos">5877</span></a><span class="sd"> """</span> +</span><span id="null-5878"><a href="#null-5878"><span class="linenos">5878</span></a> <span class="k">return</span> <span class="n">Null</span><span class="p">()</span> </span></pre></div> diff --git a/docs/sqlglot/generator.html b/docs/sqlglot/generator.html index 3ca0cff..6944156 100644 --- a/docs/sqlglot/generator.html +++ b/docs/sqlglot/generator.html @@ -37,6 +37,9 @@ <a class="function" href="#Generator.__init__">Generator</a> </li> <li> + <a class="function" href="#Generator.can_identify">can_identify</a> + </li> + <li> <a class="function" href="#Generator.generate">generate</a> </li> <li> @@ -328,6 +331,9 @@ <a class="function" href="#Generator.literal_sql">literal_sql</a> </li> <li> + <a class="function" href="#Generator.escape_str">escape_str</a> + </li> + <li> <a class="function" href="#Generator.loaddata_sql">loaddata_sql</a> </li> <li> @@ -786,7 +792,7 @@ </span><span id="L-5"><a href="#L-5"><span class="linenos"> 5</span></a> </span><span id="L-6"><a href="#L-6"><span class="linenos"> 6</span></a><span class="kn">from</span> <span class="nn">sqlglot</span> <span class="kn">import</span> <span class="n">exp</span> </span><span id="L-7"><a href="#L-7"><span class="linenos"> 7</span></a><span class="kn">from</span> <span class="nn">sqlglot.errors</span> <span class="kn">import</span> <span class="n">ErrorLevel</span><span class="p">,</span> <span class="n">UnsupportedError</span><span class="p">,</span> <span class="n">concat_messages</span> -</span><span id="L-8"><a href="#L-8"><span class="linenos"> 8</span></a><span class="kn">from</span> <span class="nn">sqlglot.helper</span> <span class="kn">import</span> <span class="n">apply_index_offset</span><span class="p">,</span> <span class="n">csv</span><span class="p">,</span> <span class="n">seq_get</span><span class="p">,</span> <span class="n">should_identify</span> +</span><span id="L-8"><a href="#L-8"><span class="linenos"> 8</span></a><span class="kn">from</span> <span class="nn">sqlglot.helper</span> <span class="kn">import</span> <span class="n">apply_index_offset</span><span class="p">,</span> <span class="n">csv</span><span class="p">,</span> <span class="n">seq_get</span> </span><span id="L-9"><a href="#L-9"><span class="linenos"> 9</span></a><span class="kn">from</span> <span class="nn">sqlglot.time</span> <span class="kn">import</span> <span class="n">format_time</span> </span><span id="L-10"><a href="#L-10"><span class="linenos"> 10</span></a><span class="kn">from</span> <span class="nn">sqlglot.tokens</span> <span class="kn">import</span> <span class="n">TokenType</span> </span><span id="L-11"><a href="#L-11"><span class="linenos"> 11</span></a> @@ -837,2322 +843,2355 @@ </span><span id="L-56"><a href="#L-56"><span class="linenos"> 56</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</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-57"><a href="#L-57"><span class="linenos"> 57</span></a> <span class="s2">"TS_OR_DS_ADD"</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">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">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">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">))</span> </span><span id="L-58"><a href="#L-58"><span class="linenos"> 58</span></a> <span class="p">),</span> -</span><span id="L-59"><a href="#L-59"><span class="linenos"> 59</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</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">"MAP"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"keys"</span><span class="p">],</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"values"</span><span class="p">]),</span> -</span><span id="L-60"><a href="#L-60"><span class="linenos"> 60</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</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">"</span><span class="si">{</span><span class="s1">'DEFAULT '</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'default'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">CHARACTER SET=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-61"><a href="#L-61"><span class="linenos"> 61</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExecuteAsProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="L-62"><a href="#L-62"><span class="linenos"> 62</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExternalProperty</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">"EXTERNAL"</span><span class="p">,</span> -</span><span id="L-63"><a href="#L-63"><span class="linenos"> 63</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LanguageProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="L-64"><a href="#L-64"><span class="linenos"> 64</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="L-65"><a href="#L-65"><span class="linenos"> 65</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogProperty</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">"</span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">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">'no'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">LOG"</span><span class="p">,</span> -</span><span id="L-66"><a href="#L-66"><span class="linenos"> 66</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MaterializedProperty</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">"MATERIALIZED"</span><span class="p">,</span> -</span><span id="L-67"><a href="#L-67"><span class="linenos"> 67</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NoPrimaryIndexProperty</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">"NO PRIMARY INDEX"</span><span class="p">,</span> -</span><span id="L-68"><a href="#L-68"><span class="linenos"> 68</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</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">"ON COMMIT </span><span class="si">{</span><span class="s1">'DELETE'</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'delete'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'PRESERVE'</span><span class="si">}</span><span class="s2"> ROWS"</span><span class="p">,</span> -</span><span id="L-69"><a href="#L-69"><span class="linenos"> 69</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="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="L-70"><a href="#L-70"><span class="linenos"> 70</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</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">"</span><span class="si">{</span><span class="s1">'MULTI'</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'multi'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">SET"</span><span class="p">,</span> -</span><span id="L-71"><a href="#L-71"><span class="linenos"> 71</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SettingsProperty</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">"SETTINGS</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">e</span><span class="p">))</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-72"><a href="#L-72"><span class="linenos"> 72</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SqlSecurityProperty</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">"SQL SECURITY </span><span class="si">{</span><span class="s1">'DEFINER'</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'definer'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'INVOKER'</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-73"><a href="#L-73"><span class="linenos"> 73</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</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">"TEMPORARY"</span><span class="p">,</span> -</span><span id="L-74"><a href="#L-74"><span class="linenos"> 74</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToTableProperty</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">"TO </span><span 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="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-75"><a href="#L-75"><span class="linenos"> 75</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TransientProperty</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">"TRANSIENT"</span><span class="p">,</span> -</span><span id="L-76"><a href="#L-76"><span class="linenos"> 76</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</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">e</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> -</span><span id="L-77"><a href="#L-77"><span class="linenos"> 77</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</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">"VOLATILE"</span><span class="p">,</span> -</span><span id="L-78"><a href="#L-78"><span class="linenos"> 78</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithJournalTableProperty</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">"WITH JOURNAL TABLE=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-79"><a href="#L-79"><span class="linenos"> 79</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CaseSpecificColumnConstraint</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">"</span><span class="si">{</span><span class="s1">'NOT '</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'not_'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">CASESPECIFIC"</span><span class="p">,</span> -</span><span id="L-80"><a href="#L-80"><span class="linenos"> 80</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetColumnConstraint</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">"CHARACTER SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-81"><a href="#L-81"><span class="linenos"> 81</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFormatColumnConstraint</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">"FORMAT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-82"><a href="#L-82"><span class="linenos"> 82</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnUpdateColumnConstraint</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">"ON UPDATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-83"><a href="#L-83"><span class="linenos"> 83</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UppercaseColumnConstraint</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">"UPPERCASE"</span><span class="p">,</span> -</span><span id="L-84"><a href="#L-84"><span class="linenos"> 84</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TitleColumnConstraint</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">"TITLE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-85"><a href="#L-85"><span class="linenos"> 85</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PathColumnConstraint</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">"PATH </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-86"><a href="#L-86"><span class="linenos"> 86</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CheckColumnConstraint</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">"CHECK (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-87"><a href="#L-87"><span class="linenos"> 87</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CommentColumnConstraint</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">"COMMENT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-88"><a href="#L-88"><span class="linenos"> 88</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateColumnConstraint</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">"COLLATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-89"><a href="#L-89"><span class="linenos"> 89</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">EncodeColumnConstraint</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">"ENCODE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-90"><a href="#L-90"><span class="linenos"> 90</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DefaultColumnConstraint</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">"DEFAULT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-91"><a href="#L-91"><span class="linenos"> 91</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">InlineLengthColumnConstraint</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">"INLINE LENGTH </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-92"><a href="#L-92"><span class="linenos"> 92</span></a> <span class="p">}</span> -</span><span id="L-93"><a href="#L-93"><span class="linenos"> 93</span></a> -</span><span id="L-94"><a href="#L-94"><span class="linenos"> 94</span></a> <span class="c1"># Whether or not null ordering is supported in order by</span> -</span><span id="L-95"><a href="#L-95"><span class="linenos"> 95</span></a> <span class="n">NULL_ORDERING_SUPPORTED</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> -</span><span id="L-97"><a href="#L-97"><span class="linenos"> 97</span></a> <span class="c1"># Whether or not locking reads (i.e. SELECT ... FOR UPDATE/SHARE) are supported</span> -</span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a> <span class="n">LOCKING_READS_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a> -</span><span id="L-100"><a href="#L-100"><span class="linenos"> 100</span></a> <span class="c1"># Always do union distinct or union all</span> -</span><span id="L-101"><a href="#L-101"><span class="linenos"> 101</span></a> <span class="n">EXPLICIT_UNION</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-102"><a href="#L-102"><span class="linenos"> 102</span></a> -</span><span id="L-103"><a href="#L-103"><span class="linenos"> 103</span></a> <span class="c1"># Wrap derived values in parens, usually standard but spark doesn't support it</span> -</span><span id="L-104"><a href="#L-104"><span class="linenos"> 104</span></a> <span class="n">WRAP_DERIVED_VALUES</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-105"><a href="#L-105"><span class="linenos"> 105</span></a> -</span><span id="L-106"><a href="#L-106"><span class="linenos"> 106</span></a> <span class="c1"># Whether or not create function uses an AS before the RETURN</span> -</span><span id="L-107"><a href="#L-107"><span class="linenos"> 107</span></a> <span class="n">CREATE_FUNCTION_RETURN_AS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-108"><a href="#L-108"><span class="linenos"> 108</span></a> -</span><span id="L-109"><a href="#L-109"><span class="linenos"> 109</span></a> <span class="c1"># Whether or not MERGE ... WHEN MATCHED BY SOURCE is allowed</span> -</span><span id="L-110"><a href="#L-110"><span class="linenos"> 110</span></a> <span class="n">MATCHED_BY_SOURCE</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-111"><a href="#L-111"><span class="linenos"> 111</span></a> -</span><span id="L-112"><a href="#L-112"><span class="linenos"> 112</span></a> <span class="c1"># Whether or not the INTERVAL expression works only with values like '1 day'</span> -</span><span id="L-113"><a href="#L-113"><span class="linenos"> 113</span></a> <span class="n">SINGLE_STRING_INTERVAL</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-114"><a href="#L-114"><span class="linenos"> 114</span></a> -</span><span id="L-115"><a href="#L-115"><span class="linenos"> 115</span></a> <span class="c1"># Whether or not the plural form of date parts like day (i.e. "days") is supported in INTERVALs</span> -</span><span id="L-116"><a href="#L-116"><span class="linenos"> 116</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-117"><a href="#L-117"><span class="linenos"> 117</span></a> -</span><span id="L-118"><a href="#L-118"><span class="linenos"> 118</span></a> <span class="c1"># Whether or not the TABLESAMPLE clause supports a method name, like BERNOULLI</span> -</span><span id="L-119"><a href="#L-119"><span class="linenos"> 119</span></a> <span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-120"><a href="#L-120"><span class="linenos"> 120</span></a> -</span><span id="L-121"><a href="#L-121"><span class="linenos"> 121</span></a> <span class="c1"># Whether or not to treat the number in TABLESAMPLE (50) as a percentage</span> -</span><span id="L-122"><a href="#L-122"><span class="linenos"> 122</span></a> <span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-123"><a href="#L-123"><span class="linenos"> 123</span></a> -</span><span id="L-124"><a href="#L-124"><span class="linenos"> 124</span></a> <span class="c1"># Whether or not limit and fetch are supported (possible values: "ALL", "LIMIT", "FETCH")</span> -</span><span id="L-125"><a href="#L-125"><span class="linenos"> 125</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"ALL"</span> -</span><span id="L-126"><a href="#L-126"><span class="linenos"> 126</span></a> -</span><span id="L-127"><a href="#L-127"><span class="linenos"> 127</span></a> <span class="c1"># Whether or not a table is allowed to be renamed with a db</span> -</span><span id="L-128"><a href="#L-128"><span class="linenos"> 128</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-129"><a href="#L-129"><span class="linenos"> 129</span></a> -</span><span id="L-130"><a href="#L-130"><span class="linenos"> 130</span></a> <span class="c1"># The separator for grouping sets and rollups</span> -</span><span id="L-131"><a href="#L-131"><span class="linenos"> 131</span></a> <span class="n">GROUPINGS_SEP</span> <span class="o">=</span> <span class="s2">","</span> -</span><span id="L-132"><a href="#L-132"><span class="linenos"> 132</span></a> -</span><span id="L-133"><a href="#L-133"><span class="linenos"> 133</span></a> <span class="c1"># The string used for creating an index on a table</span> -</span><span id="L-134"><a href="#L-134"><span class="linenos"> 134</span></a> <span class="n">INDEX_ON</span> <span class="o">=</span> <span class="s2">"ON"</span> -</span><span id="L-135"><a href="#L-135"><span class="linenos"> 135</span></a> -</span><span id="L-136"><a href="#L-136"><span class="linenos"> 136</span></a> <span class="c1"># Whether or not join hints should be generated</span> -</span><span id="L-137"><a href="#L-137"><span class="linenos"> 137</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-138"><a href="#L-138"><span class="linenos"> 138</span></a> -</span><span id="L-139"><a href="#L-139"><span class="linenos"> 139</span></a> <span class="c1"># Whether or not table hints should be generated</span> -</span><span id="L-140"><a href="#L-140"><span class="linenos"> 140</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-141"><a href="#L-141"><span class="linenos"> 141</span></a> -</span><span id="L-142"><a href="#L-142"><span class="linenos"> 142</span></a> <span class="c1"># Whether or not comparing against booleans (e.g. x IS TRUE) is supported</span> -</span><span id="L-143"><a href="#L-143"><span class="linenos"> 143</span></a> <span class="n">IS_BOOL_ALLOWED</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-144"><a href="#L-144"><span class="linenos"> 144</span></a> -</span><span id="L-145"><a href="#L-145"><span class="linenos"> 145</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-146"><a href="#L-146"><span class="linenos"> 146</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"CHAR"</span><span class="p">,</span> -</span><span id="L-147"><a href="#L-147"><span class="linenos"> 147</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"VARCHAR"</span><span class="p">,</span> -</span><span id="L-148"><a href="#L-148"><span class="linenos"> 148</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">MEDIUMTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="L-149"><a href="#L-149"><span class="linenos"> 149</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">LONGTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="L-150"><a href="#L-150"><span class="linenos"> 150</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">MEDIUMBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> -</span><span id="L-151"><a href="#L-151"><span class="linenos"> 151</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">LONGBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> -</span><span id="L-152"><a href="#L-152"><span class="linenos"> 152</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INET</span><span class="p">:</span> <span class="s2">"INET"</span><span class="p">,</span> -</span><span id="L-153"><a href="#L-153"><span class="linenos"> 153</span></a> <span class="p">}</span> -</span><span id="L-154"><a href="#L-154"><span class="linenos"> 154</span></a> -</span><span id="L-155"><a href="#L-155"><span class="linenos"> 155</span></a> <span class="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-156"><a href="#L-156"><span class="linenos"> 156</span></a> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCEPT"</span><span class="p">,</span> -</span><span id="L-157"><a href="#L-157"><span class="linenos"> 157</span></a> <span class="s2">"replace"</span><span class="p">:</span> <span class="s2">"REPLACE"</span><span class="p">,</span> -</span><span id="L-158"><a href="#L-158"><span class="linenos"> 158</span></a> <span class="p">}</span> -</span><span id="L-159"><a href="#L-159"><span class="linenos"> 159</span></a> -</span><span id="L-160"><a href="#L-160"><span class="linenos"> 160</span></a> <span class="n">TIME_PART_SINGULARS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-161"><a href="#L-161"><span class="linenos"> 161</span></a> <span class="s2">"microseconds"</span><span class="p">:</span> <span class="s2">"microsecond"</span><span class="p">,</span> -</span><span id="L-162"><a href="#L-162"><span class="linenos"> 162</span></a> <span class="s2">"seconds"</span><span class="p">:</span> <span class="s2">"second"</span><span class="p">,</span> -</span><span id="L-163"><a href="#L-163"><span class="linenos"> 163</span></a> <span class="s2">"minutes"</span><span class="p">:</span> <span class="s2">"minute"</span><span class="p">,</span> -</span><span id="L-164"><a href="#L-164"><span class="linenos"> 164</span></a> <span class="s2">"hours"</span><span class="p">:</span> <span class="s2">"hour"</span><span class="p">,</span> -</span><span id="L-165"><a href="#L-165"><span class="linenos"> 165</span></a> <span class="s2">"days"</span><span class="p">:</span> <span class="s2">"day"</span><span class="p">,</span> -</span><span id="L-166"><a href="#L-166"><span class="linenos"> 166</span></a> <span class="s2">"weeks"</span><span class="p">:</span> <span class="s2">"week"</span><span class="p">,</span> -</span><span id="L-167"><a href="#L-167"><span class="linenos"> 167</span></a> <span class="s2">"months"</span><span class="p">:</span> <span class="s2">"month"</span><span class="p">,</span> -</span><span id="L-168"><a href="#L-168"><span class="linenos"> 168</span></a> <span class="s2">"quarters"</span><span class="p">:</span> <span class="s2">"quarter"</span><span class="p">,</span> -</span><span id="L-169"><a href="#L-169"><span class="linenos"> 169</span></a> <span class="s2">"years"</span><span class="p">:</span> <span class="s2">"year"</span><span class="p">,</span> -</span><span id="L-170"><a href="#L-170"><span class="linenos"> 170</span></a> <span class="p">}</span> -</span><span id="L-171"><a href="#L-171"><span class="linenos"> 171</span></a> -</span><span id="L-172"><a href="#L-172"><span class="linenos"> 172</span></a> <span class="n">TOKEN_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">TokenType</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-173"><a href="#L-173"><span class="linenos"> 173</span></a> -</span><span id="L-174"><a href="#L-174"><span class="linenos"> 174</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-59"><a href="#L-59"><span class="linenos"> 59</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CaseSpecificColumnConstraint</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">"</span><span class="si">{</span><span class="s1">'NOT '</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'not_'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">CASESPECIFIC"</span><span class="p">,</span> +</span><span id="L-60"><a href="#L-60"><span class="linenos"> 60</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetColumnConstraint</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">"CHARACTER SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-61"><a href="#L-61"><span class="linenos"> 61</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</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">"</span><span class="si">{</span><span class="s1">'DEFAULT '</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'default'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">CHARACTER SET=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-62"><a href="#L-62"><span class="linenos"> 62</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CheckColumnConstraint</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">"CHECK (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-63"><a href="#L-63"><span class="linenos"> 63</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateColumnConstraint</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">"COLLATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-64"><a href="#L-64"><span class="linenos"> 64</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CopyGrantsProperty</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">"COPY GRANTS"</span><span class="p">,</span> +</span><span id="L-65"><a href="#L-65"><span class="linenos"> 65</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CommentColumnConstraint</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">"COMMENT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-66"><a href="#L-66"><span class="linenos"> 66</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFormatColumnConstraint</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">"FORMAT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-67"><a href="#L-67"><span class="linenos"> 67</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DefaultColumnConstraint</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">"DEFAULT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-68"><a href="#L-68"><span class="linenos"> 68</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">EncodeColumnConstraint</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">"ENCODE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-69"><a href="#L-69"><span class="linenos"> 69</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExecuteAsProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="L-70"><a href="#L-70"><span class="linenos"> 70</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExternalProperty</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">"EXTERNAL"</span><span class="p">,</span> +</span><span id="L-71"><a href="#L-71"><span class="linenos"> 71</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">InlineLengthColumnConstraint</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">"INLINE LENGTH </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-72"><a href="#L-72"><span class="linenos"> 72</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LanguageProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="L-73"><a href="#L-73"><span class="linenos"> 73</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="L-74"><a href="#L-74"><span class="linenos"> 74</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogProperty</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">"</span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">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">'no'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">LOG"</span><span class="p">,</span> +</span><span id="L-75"><a href="#L-75"><span class="linenos"> 75</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MaterializedProperty</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">"MATERIALIZED"</span><span class="p">,</span> +</span><span id="L-76"><a href="#L-76"><span class="linenos"> 76</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NoPrimaryIndexProperty</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">"NO PRIMARY INDEX"</span><span class="p">,</span> +</span><span id="L-77"><a href="#L-77"><span class="linenos"> 77</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</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">"ON COMMIT </span><span class="si">{</span><span class="s1">'DELETE'</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'delete'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'PRESERVE'</span><span class="si">}</span><span class="s2"> ROWS"</span><span class="p">,</span> +</span><span id="L-78"><a href="#L-78"><span class="linenos"> 78</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnUpdateColumnConstraint</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">"ON UPDATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-79"><a href="#L-79"><span class="linenos"> 79</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PathColumnConstraint</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">"PATH </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-80"><a href="#L-80"><span class="linenos"> 80</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="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="L-81"><a href="#L-81"><span class="linenos"> 81</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</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">"</span><span class="si">{</span><span class="s1">'MULTI'</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'multi'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">SET"</span><span class="p">,</span> +</span><span id="L-82"><a href="#L-82"><span class="linenos"> 82</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SettingsProperty</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">"SETTINGS</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">e</span><span class="p">))</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-83"><a href="#L-83"><span class="linenos"> 83</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SqlSecurityProperty</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">"SQL SECURITY </span><span class="si">{</span><span class="s1">'DEFINER'</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'definer'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'INVOKER'</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-84"><a href="#L-84"><span class="linenos"> 84</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</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">e</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> +</span><span id="L-85"><a href="#L-85"><span class="linenos"> 85</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</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">"TEMPORARY"</span><span class="p">,</span> +</span><span id="L-86"><a href="#L-86"><span class="linenos"> 86</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToTableProperty</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">"TO </span><span 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="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-87"><a href="#L-87"><span class="linenos"> 87</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TransientProperty</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">"TRANSIENT"</span><span class="p">,</span> +</span><span id="L-88"><a href="#L-88"><span class="linenos"> 88</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TitleColumnConstraint</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">"TITLE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-89"><a href="#L-89"><span class="linenos"> 89</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UppercaseColumnConstraint</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">"UPPERCASE"</span><span class="p">,</span> +</span><span id="L-90"><a href="#L-90"><span class="linenos"> 90</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</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">"MAP"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"keys"</span><span class="p">],</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"values"</span><span class="p">]),</span> +</span><span id="L-91"><a href="#L-91"><span class="linenos"> 91</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</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">"VOLATILE"</span><span class="p">,</span> +</span><span id="L-92"><a href="#L-92"><span class="linenos"> 92</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithJournalTableProperty</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">"WITH JOURNAL TABLE=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-93"><a href="#L-93"><span class="linenos"> 93</span></a> <span class="p">}</span> +</span><span id="L-94"><a href="#L-94"><span class="linenos"> 94</span></a> +</span><span id="L-95"><a href="#L-95"><span class="linenos"> 95</span></a> <span class="c1"># Whether or not null ordering is supported in order by</span> +</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> <span class="n">NULL_ORDERING_SUPPORTED</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-97"><a href="#L-97"><span class="linenos"> 97</span></a> +</span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a> <span class="c1"># Whether or not locking reads (i.e. SELECT ... FOR UPDATE/SHARE) are supported</span> +</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a> <span class="n">LOCKING_READS_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-100"><a href="#L-100"><span class="linenos"> 100</span></a> +</span><span id="L-101"><a href="#L-101"><span class="linenos"> 101</span></a> <span class="c1"># Always do union distinct or union all</span> +</span><span id="L-102"><a href="#L-102"><span class="linenos"> 102</span></a> <span class="n">EXPLICIT_UNION</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-103"><a href="#L-103"><span class="linenos"> 103</span></a> +</span><span id="L-104"><a href="#L-104"><span class="linenos"> 104</span></a> <span class="c1"># Wrap derived values in parens, usually standard but spark doesn't support it</span> +</span><span id="L-105"><a href="#L-105"><span class="linenos"> 105</span></a> <span class="n">WRAP_DERIVED_VALUES</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-106"><a href="#L-106"><span class="linenos"> 106</span></a> +</span><span id="L-107"><a href="#L-107"><span class="linenos"> 107</span></a> <span class="c1"># Whether or not create function uses an AS before the RETURN</span> +</span><span id="L-108"><a href="#L-108"><span class="linenos"> 108</span></a> <span class="n">CREATE_FUNCTION_RETURN_AS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-109"><a href="#L-109"><span class="linenos"> 109</span></a> +</span><span id="L-110"><a href="#L-110"><span class="linenos"> 110</span></a> <span class="c1"># Whether or not MERGE ... WHEN MATCHED BY SOURCE is allowed</span> +</span><span id="L-111"><a href="#L-111"><span class="linenos"> 111</span></a> <span class="n">MATCHED_BY_SOURCE</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-112"><a href="#L-112"><span class="linenos"> 112</span></a> +</span><span id="L-113"><a href="#L-113"><span class="linenos"> 113</span></a> <span class="c1"># Whether or not the INTERVAL expression works only with values like '1 day'</span> +</span><span id="L-114"><a href="#L-114"><span class="linenos"> 114</span></a> <span class="n">SINGLE_STRING_INTERVAL</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-115"><a href="#L-115"><span class="linenos"> 115</span></a> +</span><span id="L-116"><a href="#L-116"><span class="linenos"> 116</span></a> <span class="c1"># Whether or not the plural form of date parts like day (i.e. "days") is supported in INTERVALs</span> +</span><span id="L-117"><a href="#L-117"><span class="linenos"> 117</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-118"><a href="#L-118"><span class="linenos"> 118</span></a> +</span><span id="L-119"><a href="#L-119"><span class="linenos"> 119</span></a> <span class="c1"># Whether or not the TABLESAMPLE clause supports a method name, like BERNOULLI</span> +</span><span id="L-120"><a href="#L-120"><span class="linenos"> 120</span></a> <span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-121"><a href="#L-121"><span class="linenos"> 121</span></a> +</span><span id="L-122"><a href="#L-122"><span class="linenos"> 122</span></a> <span class="c1"># Whether or not to treat the number in TABLESAMPLE (50) as a percentage</span> +</span><span id="L-123"><a href="#L-123"><span class="linenos"> 123</span></a> <span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-124"><a href="#L-124"><span class="linenos"> 124</span></a> +</span><span id="L-125"><a href="#L-125"><span class="linenos"> 125</span></a> <span class="c1"># Whether or not limit and fetch are supported (possible values: "ALL", "LIMIT", "FETCH")</span> +</span><span id="L-126"><a href="#L-126"><span class="linenos"> 126</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"ALL"</span> +</span><span id="L-127"><a href="#L-127"><span class="linenos"> 127</span></a> +</span><span id="L-128"><a href="#L-128"><span class="linenos"> 128</span></a> <span class="c1"># Whether or not a table is allowed to be renamed with a db</span> +</span><span id="L-129"><a href="#L-129"><span class="linenos"> 129</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-130"><a href="#L-130"><span class="linenos"> 130</span></a> +</span><span id="L-131"><a href="#L-131"><span class="linenos"> 131</span></a> <span class="c1"># The separator for grouping sets and rollups</span> +</span><span id="L-132"><a href="#L-132"><span class="linenos"> 132</span></a> <span class="n">GROUPINGS_SEP</span> <span class="o">=</span> <span class="s2">","</span> +</span><span id="L-133"><a href="#L-133"><span class="linenos"> 133</span></a> +</span><span id="L-134"><a href="#L-134"><span class="linenos"> 134</span></a> <span class="c1"># The string used for creating an index on a table</span> +</span><span id="L-135"><a href="#L-135"><span class="linenos"> 135</span></a> <span class="n">INDEX_ON</span> <span class="o">=</span> <span class="s2">"ON"</span> +</span><span id="L-136"><a href="#L-136"><span class="linenos"> 136</span></a> +</span><span id="L-137"><a href="#L-137"><span class="linenos"> 137</span></a> <span class="c1"># Whether or not join hints should be generated</span> +</span><span id="L-138"><a href="#L-138"><span class="linenos"> 138</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-139"><a href="#L-139"><span class="linenos"> 139</span></a> +</span><span id="L-140"><a href="#L-140"><span class="linenos"> 140</span></a> <span class="c1"># Whether or not table hints should be generated</span> +</span><span id="L-141"><a href="#L-141"><span class="linenos"> 141</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-142"><a href="#L-142"><span class="linenos"> 142</span></a> +</span><span id="L-143"><a href="#L-143"><span class="linenos"> 143</span></a> <span class="c1"># Whether or not comparing against booleans (e.g. x IS TRUE) is supported</span> +</span><span id="L-144"><a href="#L-144"><span class="linenos"> 144</span></a> <span class="n">IS_BOOL_ALLOWED</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-145"><a href="#L-145"><span class="linenos"> 145</span></a> +</span><span id="L-146"><a href="#L-146"><span class="linenos"> 146</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax</span> +</span><span id="L-147"><a href="#L-147"><span class="linenos"> 147</span></a> <span class="n">SELECT_KINDS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"STRUCT"</span><span class="p">,</span> <span class="s2">"VALUE"</span><span class="p">)</span> +</span><span id="L-148"><a href="#L-148"><span class="linenos"> 148</span></a> +</span><span id="L-149"><a href="#L-149"><span class="linenos"> 149</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-150"><a href="#L-150"><span class="linenos"> 150</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"CHAR"</span><span class="p">,</span> +</span><span id="L-151"><a href="#L-151"><span class="linenos"> 151</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"VARCHAR"</span><span class="p">,</span> +</span><span id="L-152"><a href="#L-152"><span class="linenos"> 152</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">MEDIUMTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="L-153"><a href="#L-153"><span class="linenos"> 153</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">LONGTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="L-154"><a href="#L-154"><span class="linenos"> 154</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">MEDIUMBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> +</span><span id="L-155"><a href="#L-155"><span class="linenos"> 155</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">LONGBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> +</span><span id="L-156"><a href="#L-156"><span class="linenos"> 156</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INET</span><span class="p">:</span> <span class="s2">"INET"</span><span class="p">,</span> +</span><span id="L-157"><a href="#L-157"><span class="linenos"> 157</span></a> <span class="p">}</span> +</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="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-160"><a href="#L-160"><span class="linenos"> 160</span></a> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCEPT"</span><span class="p">,</span> +</span><span id="L-161"><a href="#L-161"><span class="linenos"> 161</span></a> <span class="s2">"replace"</span><span class="p">:</span> <span class="s2">"REPLACE"</span><span class="p">,</span> +</span><span id="L-162"><a href="#L-162"><span class="linenos"> 162</span></a> <span class="p">}</span> +</span><span id="L-163"><a href="#L-163"><span class="linenos"> 163</span></a> +</span><span id="L-164"><a href="#L-164"><span class="linenos"> 164</span></a> <span class="n">TIME_PART_SINGULARS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-165"><a href="#L-165"><span class="linenos"> 165</span></a> <span class="s2">"microseconds"</span><span class="p">:</span> <span class="s2">"microsecond"</span><span class="p">,</span> +</span><span id="L-166"><a href="#L-166"><span class="linenos"> 166</span></a> <span class="s2">"seconds"</span><span class="p">:</span> <span class="s2">"second"</span><span class="p">,</span> +</span><span id="L-167"><a href="#L-167"><span class="linenos"> 167</span></a> <span class="s2">"minutes"</span><span class="p">:</span> <span class="s2">"minute"</span><span class="p">,</span> +</span><span id="L-168"><a href="#L-168"><span class="linenos"> 168</span></a> <span class="s2">"hours"</span><span class="p">:</span> <span class="s2">"hour"</span><span class="p">,</span> +</span><span id="L-169"><a href="#L-169"><span class="linenos"> 169</span></a> <span class="s2">"days"</span><span class="p">:</span> <span class="s2">"day"</span><span class="p">,</span> +</span><span id="L-170"><a href="#L-170"><span class="linenos"> 170</span></a> <span class="s2">"weeks"</span><span class="p">:</span> <span class="s2">"week"</span><span class="p">,</span> +</span><span id="L-171"><a href="#L-171"><span class="linenos"> 171</span></a> <span class="s2">"months"</span><span class="p">:</span> <span class="s2">"month"</span><span class="p">,</span> +</span><span id="L-172"><a href="#L-172"><span class="linenos"> 172</span></a> <span class="s2">"quarters"</span><span class="p">:</span> <span class="s2">"quarter"</span><span class="p">,</span> +</span><span id="L-173"><a href="#L-173"><span class="linenos"> 173</span></a> <span class="s2">"years"</span><span class="p">:</span> <span class="s2">"year"</span><span class="p">,</span> +</span><span id="L-174"><a href="#L-174"><span class="linenos"> 174</span></a> <span class="p">}</span> </span><span id="L-175"><a href="#L-175"><span class="linenos"> 175</span></a> -</span><span id="L-176"><a href="#L-176"><span class="linenos"> 176</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"@"</span> +</span><span id="L-176"><a href="#L-176"><span class="linenos"> 176</span></a> <span class="n">TOKEN_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">TokenType</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> </span><span id="L-177"><a href="#L-177"><span class="linenos"> 177</span></a> -</span><span id="L-178"><a href="#L-178"><span class="linenos"> 178</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-179"><a href="#L-179"><span class="linenos"> 179</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AlgorithmProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="L-180"><a href="#L-180"><span class="linenos"> 180</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AutoIncrementProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-181"><a href="#L-181"><span class="linenos"> 181</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-182"><a href="#L-182"><span class="linenos"> 182</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-183"><a href="#L-183"><span class="linenos"> 183</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-184"><a href="#L-184"><span class="linenos"> 184</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-185"><a href="#L-185"><span class="linenos"> 185</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-186"><a href="#L-186"><span class="linenos"> 186</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-187"><a href="#L-187"><span class="linenos"> 187</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DefinerProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="L-188"><a href="#L-188"><span class="linenos"> 188</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictRange</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-189"><a href="#L-189"><span class="linenos"> 189</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-190"><a href="#L-190"><span class="linenos"> 190</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-191"><a href="#L-191"><span class="linenos"> 191</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-192"><a href="#L-192"><span class="linenos"> 192</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">EngineProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-193"><a href="#L-193"><span class="linenos"> 193</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExecuteAsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-194"><a href="#L-194"><span class="linenos"> 194</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExternalProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="L-195"><a href="#L-195"><span class="linenos"> 195</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-196"><a href="#L-196"><span class="linenos"> 196</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> -</span><span id="L-197"><a href="#L-197"><span class="linenos"> 197</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-198"><a href="#L-198"><span class="linenos"> 198</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-199"><a href="#L-199"><span class="linenos"> 199</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-200"><a href="#L-200"><span class="linenos"> 200</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LanguageProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-201"><a href="#L-201"><span class="linenos"> 201</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-202"><a href="#L-202"><span class="linenos"> 202</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-203"><a href="#L-203"><span class="linenos"> 203</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">,</span> -</span><span id="L-204"><a href="#L-204"><span class="linenos"> 204</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-205"><a href="#L-205"><span class="linenos"> 205</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MaterializedProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="L-206"><a href="#L-206"><span class="linenos"> 206</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-207"><a href="#L-207"><span class="linenos"> 207</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NoPrimaryIndexProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> -</span><span id="L-208"><a href="#L-208"><span class="linenos"> 208</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> -</span><span id="L-209"><a href="#L-209"><span class="linenos"> 209</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-210"><a href="#L-210"><span class="linenos"> 210</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> -</span><span id="L-211"><a href="#L-211"><span class="linenos"> 211</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKey</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-212"><a href="#L-212"><span class="linenos"> 212</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> -</span><span id="L-213"><a href="#L-213"><span class="linenos"> 213</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-214"><a href="#L-214"><span class="linenos"> 214</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-215"><a href="#L-215"><span class="linenos"> 215</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-216"><a href="#L-216"><span class="linenos"> 216</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatSerdeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-217"><a href="#L-217"><span class="linenos"> 217</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-218"><a href="#L-218"><span class="linenos"> 218</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-219"><a href="#L-219"><span class="linenos"> 219</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-220"><a href="#L-220"><span class="linenos"> 220</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SettingsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-221"><a href="#L-221"><span class="linenos"> 221</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="L-222"><a href="#L-222"><span class="linenos"> 222</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-223"><a href="#L-223"><span class="linenos"> 223</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SqlSecurityProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="L-224"><a href="#L-224"><span class="linenos"> 224</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-225"><a href="#L-225"><span class="linenos"> 225</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="L-226"><a href="#L-226"><span class="linenos"> 226</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToTableProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-227"><a href="#L-227"><span class="linenos"> 227</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TransientProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="L-228"><a href="#L-228"><span class="linenos"> 228</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="L-229"><a href="#L-229"><span class="linenos"> 229</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="L-230"><a href="#L-230"><span class="linenos"> 230</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> -</span><span id="L-231"><a href="#L-231"><span class="linenos"> 231</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithJournalTableProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="L-232"><a href="#L-232"><span class="linenos"> 232</span></a> <span class="p">}</span> -</span><span id="L-233"><a href="#L-233"><span class="linenos"> 233</span></a> -</span><span id="L-234"><a href="#L-234"><span class="linenos"> 234</span></a> <span class="c1"># Keywords that can't be used as unquoted identifier names</span> -</span><span id="L-235"><a href="#L-235"><span class="linenos"> 235</span></a> <span class="n">RESERVED_KEYWORDS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> -</span><span id="L-236"><a href="#L-236"><span class="linenos"> 236</span></a> -</span><span id="L-237"><a href="#L-237"><span class="linenos"> 237</span></a> <span class="c1"># Expressions whose comments are separated from them for better formatting</span> -</span><span id="L-238"><a href="#L-238"><span class="linenos"> 238</span></a> <span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> <span class="o">...</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-239"><a href="#L-239"><span class="linenos"> 239</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> -</span><span id="L-240"><a href="#L-240"><span class="linenos"> 240</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> -</span><span id="L-241"><a href="#L-241"><span class="linenos"> 241</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">,</span> -</span><span id="L-242"><a href="#L-242"><span class="linenos"> 242</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">,</span> -</span><span id="L-243"><a href="#L-243"><span class="linenos"> 243</span></a> <span class="p">)</span> -</span><span id="L-244"><a href="#L-244"><span class="linenos"> 244</span></a> -</span><span id="L-245"><a href="#L-245"><span class="linenos"> 245</span></a> <span class="c1"># Expressions that can remain unwrapped when appearing in the context of an INTERVAL</span> -</span><span id="L-246"><a href="#L-246"><span class="linenos"> 246</span></a> <span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> <span class="o">...</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-247"><a href="#L-247"><span class="linenos"> 247</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">,</span> -</span><span id="L-248"><a href="#L-248"><span class="linenos"> 248</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">,</span> -</span><span id="L-249"><a href="#L-249"><span class="linenos"> 249</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Neg</span><span class="p">,</span> -</span><span id="L-250"><a href="#L-250"><span class="linenos"> 250</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</span><span class="p">,</span> -</span><span id="L-251"><a href="#L-251"><span class="linenos"> 251</span></a> <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">SENTINEL_LINE_BREAK</span> <span class="o">=</span> <span class="s2">"__SQLGLOT__LB__"</span> -</span><span id="L-254"><a href="#L-254"><span class="linenos"> 254</span></a> -</span><span id="L-255"><a href="#L-255"><span class="linenos"> 255</span></a> <span class="c1"># Autofilled</span> -</span><span id="L-256"><a href="#L-256"><span class="linenos"> 256</span></a> <span class="n">INVERSE_TIME_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-257"><a href="#L-257"><span class="linenos"> 257</span></a> <span class="n">INVERSE_TIME_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-258"><a href="#L-258"><span class="linenos"> 258</span></a> <span class="n">INDEX_OFFSET</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="L-259"><a href="#L-259"><span class="linenos"> 259</span></a> <span class="n">UNNEST_COLUMN_ONLY</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-260"><a href="#L-260"><span class="linenos"> 260</span></a> <span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-261"><a href="#L-261"><span class="linenos"> 261</span></a> <span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-262"><a href="#L-262"><span class="linenos"> 262</span></a> <span class="n">STRICT_STRING_CONCAT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-263"><a href="#L-263"><span class="linenos"> 263</span></a> <span class="n">NORMALIZE_FUNCTIONS</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">|</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"upper"</span> -</span><span id="L-264"><a href="#L-264"><span class="linenos"> 264</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_small"</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="c1"># Delimiters for quotes, identifiers and the corresponding escape characters</span> -</span><span id="L-267"><a href="#L-267"><span class="linenos"> 267</span></a> <span class="n">QUOTE_START</span> <span class="o">=</span> <span class="s2">"'"</span> -</span><span id="L-268"><a href="#L-268"><span class="linenos"> 268</span></a> <span class="n">QUOTE_END</span> <span class="o">=</span> <span class="s2">"'"</span> -</span><span id="L-269"><a href="#L-269"><span class="linenos"> 269</span></a> <span class="n">IDENTIFIER_START</span> <span class="o">=</span> <span class="s1">'"'</span> -</span><span id="L-270"><a href="#L-270"><span class="linenos"> 270</span></a> <span class="n">IDENTIFIER_END</span> <span class="o">=</span> <span class="s1">'"'</span> -</span><span id="L-271"><a href="#L-271"><span class="linenos"> 271</span></a> <span class="n">STRING_ESCAPE</span> <span class="o">=</span> <span class="s2">"'"</span> -</span><span id="L-272"><a href="#L-272"><span class="linenos"> 272</span></a> <span class="n">IDENTIFIER_ESCAPE</span> <span class="o">=</span> <span class="s1">'"'</span> -</span><span id="L-273"><a href="#L-273"><span class="linenos"> 273</span></a> -</span><span id="L-274"><a href="#L-274"><span class="linenos"> 274</span></a> <span class="c1"># Delimiters for bit, hex, byte and raw literals</span> -</span><span id="L-275"><a href="#L-275"><span class="linenos"> 275</span></a> <span class="n">BIT_START</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><span id="L-276"><a href="#L-276"><span class="linenos"> 276</span></a> <span class="n">BIT_END</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><span id="L-277"><a href="#L-277"><span class="linenos"> 277</span></a> <span class="n">HEX_START</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><span id="L-278"><a href="#L-278"><span class="linenos"> 278</span></a> <span class="n">HEX_END</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><span id="L-279"><a href="#L-279"><span class="linenos"> 279</span></a> <span class="n">BYTE_START</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><span id="L-280"><a href="#L-280"><span class="linenos"> 280</span></a> <span class="n">BYTE_END</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><span id="L-281"><a href="#L-281"><span class="linenos"> 281</span></a> <span class="n">RAW_START</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><span id="L-282"><a href="#L-282"><span class="linenos"> 282</span></a> <span class="n">RAW_END</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><span id="L-283"><a href="#L-283"><span class="linenos"> 283</span></a> -</span><span id="L-284"><a href="#L-284"><span class="linenos"> 284</span></a> <span class="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-285"><a href="#L-285"><span class="linenos"> 285</span></a> <span class="s2">"pretty"</span><span class="p">,</span> -</span><span id="L-286"><a href="#L-286"><span class="linenos"> 286</span></a> <span class="s2">"identify"</span><span class="p">,</span> -</span><span id="L-287"><a href="#L-287"><span class="linenos"> 287</span></a> <span class="s2">"normalize"</span><span class="p">,</span> -</span><span id="L-288"><a href="#L-288"><span class="linenos"> 288</span></a> <span class="s2">"pad"</span><span class="p">,</span> -</span><span id="L-289"><a href="#L-289"><span class="linenos"> 289</span></a> <span class="s2">"_indent"</span><span class="p">,</span> -</span><span id="L-290"><a href="#L-290"><span class="linenos"> 290</span></a> <span class="s2">"normalize_functions"</span><span class="p">,</span> -</span><span id="L-291"><a href="#L-291"><span class="linenos"> 291</span></a> <span class="s2">"unsupported_level"</span><span class="p">,</span> -</span><span id="L-292"><a href="#L-292"><span class="linenos"> 292</span></a> <span class="s2">"max_unsupported"</span><span class="p">,</span> -</span><span id="L-293"><a href="#L-293"><span class="linenos"> 293</span></a> <span class="s2">"leading_comma"</span><span class="p">,</span> -</span><span id="L-294"><a href="#L-294"><span class="linenos"> 294</span></a> <span class="s2">"max_text_width"</span><span class="p">,</span> -</span><span id="L-295"><a href="#L-295"><span class="linenos"> 295</span></a> <span class="s2">"comments"</span><span class="p">,</span> -</span><span id="L-296"><a href="#L-296"><span class="linenos"> 296</span></a> <span class="s2">"unsupported_messages"</span><span class="p">,</span> -</span><span id="L-297"><a href="#L-297"><span class="linenos"> 297</span></a> <span class="s2">"_escaped_quote_end"</span><span class="p">,</span> -</span><span id="L-298"><a href="#L-298"><span class="linenos"> 298</span></a> <span class="s2">"_escaped_identifier_end"</span><span class="p">,</span> -</span><span id="L-299"><a href="#L-299"><span class="linenos"> 299</span></a> <span class="s2">"_cache"</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><span id="L-302"><a href="#L-302"><span class="linenos"> 302</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> -</span><span id="L-303"><a href="#L-303"><span class="linenos"> 303</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-304"><a href="#L-304"><span class="linenos"> 304</span></a> <span class="n">pretty</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-305"><a href="#L-305"><span class="linenos"> 305</span></a> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-306"><a href="#L-306"><span class="linenos"> 306</span></a> <span class="n">normalize</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-307"><a href="#L-307"><span class="linenos"> 307</span></a> <span class="n">pad</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> -</span><span id="L-308"><a href="#L-308"><span class="linenos"> 308</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> -</span><span id="L-309"><a href="#L-309"><span class="linenos"> 309</span></a> <span class="n">normalize_functions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-310"><a href="#L-310"><span class="linenos"> 310</span></a> <span class="n">unsupported_level</span><span class="p">:</span> <span class="n">ErrorLevel</span> <span class="o">=</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">,</span> -</span><span id="L-311"><a href="#L-311"><span class="linenos"> 311</span></a> <span class="n">max_unsupported</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> -</span><span id="L-312"><a href="#L-312"><span class="linenos"> 312</span></a> <span class="n">leading_comma</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-313"><a href="#L-313"><span class="linenos"> 313</span></a> <span class="n">max_text_width</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">80</span><span class="p">,</span> -</span><span id="L-314"><a href="#L-314"><span class="linenos"> 314</span></a> <span class="n">comments</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-315"><a href="#L-315"><span class="linenos"> 315</span></a> <span class="p">):</span> -</span><span id="L-316"><a href="#L-316"><span class="linenos"> 316</span></a> <span class="kn">import</span> <span class="nn">sqlglot</span> -</span><span id="L-317"><a href="#L-317"><span class="linenos"> 317</span></a> -</span><span id="L-318"><a href="#L-318"><span class="linenos"> 318</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="o">=</span> <span class="n">pretty</span> <span class="k">if</span> <span class="n">pretty</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">pretty</span> -</span><span id="L-319"><a href="#L-319"><span class="linenos"> 319</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">identify</span> -</span><span id="L-320"><a href="#L-320"><span class="linenos"> 320</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="o">=</span> <span class="n">normalize</span> -</span><span id="L-321"><a href="#L-321"><span class="linenos"> 321</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="o">=</span> <span class="n">pad</span> -</span><span id="L-322"><a href="#L-322"><span class="linenos"> 322</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_indent</span> <span class="o">=</span> <span class="n">indent</span> -</span><span id="L-323"><a href="#L-323"><span class="linenos"> 323</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">=</span> <span class="n">unsupported_level</span> -</span><span id="L-324"><a href="#L-324"><span class="linenos"> 324</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span> <span class="o">=</span> <span class="n">max_unsupported</span> -</span><span id="L-325"><a href="#L-325"><span class="linenos"> 325</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span> <span class="o">=</span> <span class="n">leading_comma</span> -</span><span id="L-326"><a href="#L-326"><span class="linenos"> 326</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="o">=</span> <span class="n">max_text_width</span> -</span><span id="L-327"><a href="#L-327"><span class="linenos"> 327</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> -</span><span id="L-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="c1"># This is both a Dialect property and a Generator argument, so we prioritize the latter</span> -</span><span id="L-330"><a href="#L-330"><span class="linenos"> 330</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-331"><a href="#L-331"><span class="linenos"> 331</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">NORMALIZE_FUNCTIONS</span> <span class="k">if</span> <span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">normalize_functions</span> -</span><span id="L-332"><a href="#L-332"><span class="linenos"> 332</span></a> <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="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-335"><a href="#L-335"><span class="linenos"> 335</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRING_ESCAPE</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span> -</span><span id="L-336"><a href="#L-336"><span class="linenos"> 336</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_ESCAPE</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_END</span> -</span><span id="L-337"><a href="#L-337"><span class="linenos"> 337</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-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="k">def</span> <span class="nf">generate</span><span class="p">(</span> -</span><span id="L-340"><a href="#L-340"><span class="linenos"> 340</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-341"><a href="#L-341"><span class="linenos"> 341</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> -</span><span id="L-342"><a href="#L-342"><span class="linenos"> 342</span></a> <span class="n">cache</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-343"><a href="#L-343"><span class="linenos"> 343</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-344"><a href="#L-344"><span class="linenos"> 344</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-345"><a href="#L-345"><span class="linenos"> 345</span></a><span class="sd"> Generates the SQL string corresponding to the given syntax tree.</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="sd"> Args:</span> -</span><span id="L-348"><a href="#L-348"><span class="linenos"> 348</span></a><span class="sd"> expression: The syntax tree.</span> -</span><span id="L-349"><a href="#L-349"><span class="linenos"> 349</span></a><span class="sd"> cache: An optional sql string cache. This leverages the hash of an Expression</span> -</span><span id="L-350"><a href="#L-350"><span class="linenos"> 350</span></a><span class="sd"> which can be slow to compute, so only use it if you set _hash on each node.</span> -</span><span id="L-351"><a href="#L-351"><span class="linenos"> 351</span></a> -</span><span id="L-352"><a href="#L-352"><span class="linenos"> 352</span></a><span class="sd"> Returns:</span> -</span><span id="L-353"><a href="#L-353"><span class="linenos"> 353</span></a><span class="sd"> The SQL string corresponding to `expression`.</span> -</span><span id="L-354"><a href="#L-354"><span class="linenos"> 354</span></a><span class="sd"> """</span> -</span><span id="L-355"><a href="#L-355"><span class="linenos"> 355</span></a> <span class="k">if</span> <span class="n">cache</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-356"><a href="#L-356"><span class="linenos"> 356</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="o">=</span> <span class="n">cache</span> -</span><span id="L-357"><a href="#L-357"><span class="linenos"> 357</span></a> -</span><span id="L-358"><a href="#L-358"><span class="linenos"> 358</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-359"><a href="#L-359"><span class="linenos"> 359</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="L-360"><a href="#L-360"><span class="linenos"> 360</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-361"><a href="#L-361"><span class="linenos"> 361</span></a> -</span><span id="L-362"><a href="#L-362"><span class="linenos"> 362</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IGNORE</span><span class="p">:</span> -</span><span id="L-363"><a href="#L-363"><span class="linenos"> 363</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="L-178"><a href="#L-178"><span class="linenos"> 178</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-179"><a href="#L-179"><span class="linenos"> 179</span></a> +</span><span id="L-180"><a href="#L-180"><span class="linenos"> 180</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"@"</span> +</span><span id="L-181"><a href="#L-181"><span class="linenos"> 181</span></a> +</span><span id="L-182"><a href="#L-182"><span class="linenos"> 182</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-183"><a href="#L-183"><span class="linenos"> 183</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AlgorithmProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="L-184"><a href="#L-184"><span class="linenos"> 184</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AutoIncrementProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-185"><a href="#L-185"><span class="linenos"> 185</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-186"><a href="#L-186"><span class="linenos"> 186</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-187"><a href="#L-187"><span class="linenos"> 187</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-188"><a href="#L-188"><span class="linenos"> 188</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-189"><a href="#L-189"><span class="linenos"> 189</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CopyGrantsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-190"><a href="#L-190"><span class="linenos"> 190</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-191"><a href="#L-191"><span class="linenos"> 191</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-192"><a href="#L-192"><span class="linenos"> 192</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DefinerProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="L-193"><a href="#L-193"><span class="linenos"> 193</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictRange</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-194"><a href="#L-194"><span class="linenos"> 194</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-195"><a href="#L-195"><span class="linenos"> 195</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-196"><a href="#L-196"><span class="linenos"> 196</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-197"><a href="#L-197"><span class="linenos"> 197</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">EngineProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-198"><a href="#L-198"><span class="linenos"> 198</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExecuteAsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-199"><a href="#L-199"><span class="linenos"> 199</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExternalProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="L-200"><a href="#L-200"><span class="linenos"> 200</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-201"><a href="#L-201"><span class="linenos"> 201</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> +</span><span id="L-202"><a href="#L-202"><span class="linenos"> 202</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-203"><a href="#L-203"><span class="linenos"> 203</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-204"><a href="#L-204"><span class="linenos"> 204</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-205"><a href="#L-205"><span class="linenos"> 205</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LanguageProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-206"><a href="#L-206"><span class="linenos"> 206</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-207"><a href="#L-207"><span class="linenos"> 207</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-208"><a href="#L-208"><span class="linenos"> 208</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">,</span> +</span><span id="L-209"><a href="#L-209"><span class="linenos"> 209</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-210"><a href="#L-210"><span class="linenos"> 210</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MaterializedProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="L-211"><a href="#L-211"><span class="linenos"> 211</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-212"><a href="#L-212"><span class="linenos"> 212</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NoPrimaryIndexProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> +</span><span id="L-213"><a href="#L-213"><span class="linenos"> 213</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> +</span><span id="L-214"><a href="#L-214"><span class="linenos"> 214</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-215"><a href="#L-215"><span class="linenos"> 215</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> +</span><span id="L-216"><a href="#L-216"><span class="linenos"> 216</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKey</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-217"><a href="#L-217"><span class="linenos"> 217</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> +</span><span id="L-218"><a href="#L-218"><span class="linenos"> 218</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-219"><a href="#L-219"><span class="linenos"> 219</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-220"><a href="#L-220"><span class="linenos"> 220</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-221"><a href="#L-221"><span class="linenos"> 221</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatSerdeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-222"><a href="#L-222"><span class="linenos"> 222</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-223"><a href="#L-223"><span class="linenos"> 223</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-224"><a href="#L-224"><span class="linenos"> 224</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-225"><a href="#L-225"><span class="linenos"> 225</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SettingsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-226"><a href="#L-226"><span class="linenos"> 226</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="L-227"><a href="#L-227"><span class="linenos"> 227</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-228"><a href="#L-228"><span class="linenos"> 228</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SqlSecurityProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="L-229"><a href="#L-229"><span class="linenos"> 229</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-230"><a href="#L-230"><span class="linenos"> 230</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="L-231"><a href="#L-231"><span class="linenos"> 231</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToTableProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-232"><a href="#L-232"><span class="linenos"> 232</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TransientProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="L-233"><a href="#L-233"><span class="linenos"> 233</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="L-234"><a href="#L-234"><span class="linenos"> 234</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="L-235"><a href="#L-235"><span class="linenos"> 235</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> +</span><span id="L-236"><a href="#L-236"><span class="linenos"> 236</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithJournalTableProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="L-237"><a href="#L-237"><span class="linenos"> 237</span></a> <span class="p">}</span> +</span><span id="L-238"><a href="#L-238"><span class="linenos"> 238</span></a> +</span><span id="L-239"><a href="#L-239"><span class="linenos"> 239</span></a> <span class="c1"># Keywords that can't be used as unquoted identifier names</span> +</span><span id="L-240"><a href="#L-240"><span class="linenos"> 240</span></a> <span class="n">RESERVED_KEYWORDS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> +</span><span id="L-241"><a href="#L-241"><span class="linenos"> 241</span></a> +</span><span id="L-242"><a href="#L-242"><span class="linenos"> 242</span></a> <span class="c1"># Expressions whose comments are separated from them for better formatting</span> +</span><span id="L-243"><a href="#L-243"><span class="linenos"> 243</span></a> <span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> <span class="o">...</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-244"><a href="#L-244"><span class="linenos"> 244</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> +</span><span id="L-245"><a href="#L-245"><span class="linenos"> 245</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> +</span><span id="L-246"><a href="#L-246"><span class="linenos"> 246</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">,</span> +</span><span id="L-247"><a href="#L-247"><span class="linenos"> 247</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">,</span> +</span><span id="L-248"><a href="#L-248"><span class="linenos"> 248</span></a> <span class="p">)</span> +</span><span id="L-249"><a href="#L-249"><span class="linenos"> 249</span></a> +</span><span id="L-250"><a href="#L-250"><span class="linenos"> 250</span></a> <span class="c1"># Expressions that can remain unwrapped when appearing in the context of an INTERVAL</span> +</span><span id="L-251"><a href="#L-251"><span class="linenos"> 251</span></a> <span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> <span class="o">...</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-252"><a href="#L-252"><span class="linenos"> 252</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">,</span> +</span><span id="L-253"><a href="#L-253"><span class="linenos"> 253</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">,</span> +</span><span id="L-254"><a href="#L-254"><span class="linenos"> 254</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Neg</span><span class="p">,</span> +</span><span id="L-255"><a href="#L-255"><span class="linenos"> 255</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</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="n">SENTINEL_LINE_BREAK</span> <span class="o">=</span> <span class="s2">"__SQLGLOT__LB__"</span> +</span><span id="L-259"><a href="#L-259"><span class="linenos"> 259</span></a> +</span><span id="L-260"><a href="#L-260"><span class="linenos"> 260</span></a> <span class="c1"># Autofilled</span> +</span><span id="L-261"><a href="#L-261"><span class="linenos"> 261</span></a> <span class="n">INVERSE_TIME_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-262"><a href="#L-262"><span class="linenos"> 262</span></a> <span class="n">INVERSE_TIME_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-263"><a href="#L-263"><span class="linenos"> 263</span></a> <span class="n">INDEX_OFFSET</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="L-264"><a href="#L-264"><span class="linenos"> 264</span></a> <span class="n">UNNEST_COLUMN_ONLY</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-265"><a href="#L-265"><span class="linenos"> 265</span></a> <span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-266"><a href="#L-266"><span class="linenos"> 266</span></a> <span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-267"><a href="#L-267"><span class="linenos"> 267</span></a> <span class="n">STRICT_STRING_CONCAT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-268"><a href="#L-268"><span class="linenos"> 268</span></a> <span class="n">NORMALIZE_FUNCTIONS</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">|</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"upper"</span> +</span><span id="L-269"><a href="#L-269"><span class="linenos"> 269</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_small"</span> +</span><span id="L-270"><a href="#L-270"><span class="linenos"> 270</span></a> +</span><span id="L-271"><a href="#L-271"><span class="linenos"> 271</span></a> <span class="n">can_identify</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span><span class="p">],</span> <span class="nb">bool</span><span class="p">]</span> +</span><span id="L-272"><a href="#L-272"><span class="linenos"> 272</span></a> +</span><span id="L-273"><a href="#L-273"><span class="linenos"> 273</span></a> <span class="c1"># Delimiters for quotes, identifiers and the corresponding escape characters</span> +</span><span id="L-274"><a href="#L-274"><span class="linenos"> 274</span></a> <span class="n">QUOTE_START</span> <span class="o">=</span> <span class="s2">"'"</span> +</span><span id="L-275"><a href="#L-275"><span class="linenos"> 275</span></a> <span class="n">QUOTE_END</span> <span class="o">=</span> <span class="s2">"'"</span> +</span><span id="L-276"><a href="#L-276"><span class="linenos"> 276</span></a> <span class="n">IDENTIFIER_START</span> <span class="o">=</span> <span class="s1">'"'</span> +</span><span id="L-277"><a href="#L-277"><span class="linenos"> 277</span></a> <span class="n">IDENTIFIER_END</span> <span class="o">=</span> <span class="s1">'"'</span> +</span><span id="L-278"><a href="#L-278"><span class="linenos"> 278</span></a> <span class="n">STRING_ESCAPE</span> <span class="o">=</span> <span class="s2">"'"</span> +</span><span id="L-279"><a href="#L-279"><span class="linenos"> 279</span></a> <span class="n">IDENTIFIER_ESCAPE</span> <span class="o">=</span> <span class="s1">'"'</span> +</span><span id="L-280"><a href="#L-280"><span class="linenos"> 280</span></a> +</span><span id="L-281"><a href="#L-281"><span class="linenos"> 281</span></a> <span class="c1"># Delimiters for bit, hex, byte and raw literals</span> +</span><span id="L-282"><a href="#L-282"><span class="linenos"> 282</span></a> <span class="n">BIT_START</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><span id="L-283"><a href="#L-283"><span class="linenos"> 283</span></a> <span class="n">BIT_END</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><span id="L-284"><a href="#L-284"><span class="linenos"> 284</span></a> <span class="n">HEX_START</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><span id="L-285"><a href="#L-285"><span class="linenos"> 285</span></a> <span class="n">HEX_END</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><span id="L-286"><a href="#L-286"><span class="linenos"> 286</span></a> <span class="n">BYTE_START</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><span id="L-287"><a href="#L-287"><span class="linenos"> 287</span></a> <span class="n">BYTE_END</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><span id="L-288"><a href="#L-288"><span class="linenos"> 288</span></a> <span class="n">RAW_START</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><span id="L-289"><a href="#L-289"><span class="linenos"> 289</span></a> <span class="n">RAW_END</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><span id="L-290"><a href="#L-290"><span class="linenos"> 290</span></a> +</span><span id="L-291"><a href="#L-291"><span class="linenos"> 291</span></a> <span class="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-292"><a href="#L-292"><span class="linenos"> 292</span></a> <span class="s2">"pretty"</span><span class="p">,</span> +</span><span id="L-293"><a href="#L-293"><span class="linenos"> 293</span></a> <span class="s2">"identify"</span><span class="p">,</span> +</span><span id="L-294"><a href="#L-294"><span class="linenos"> 294</span></a> <span class="s2">"normalize"</span><span class="p">,</span> +</span><span id="L-295"><a href="#L-295"><span class="linenos"> 295</span></a> <span class="s2">"pad"</span><span class="p">,</span> +</span><span id="L-296"><a href="#L-296"><span class="linenos"> 296</span></a> <span class="s2">"_indent"</span><span class="p">,</span> +</span><span id="L-297"><a href="#L-297"><span class="linenos"> 297</span></a> <span class="s2">"normalize_functions"</span><span class="p">,</span> +</span><span id="L-298"><a href="#L-298"><span class="linenos"> 298</span></a> <span class="s2">"unsupported_level"</span><span class="p">,</span> +</span><span id="L-299"><a href="#L-299"><span class="linenos"> 299</span></a> <span class="s2">"max_unsupported"</span><span class="p">,</span> +</span><span id="L-300"><a href="#L-300"><span class="linenos"> 300</span></a> <span class="s2">"leading_comma"</span><span class="p">,</span> +</span><span id="L-301"><a href="#L-301"><span class="linenos"> 301</span></a> <span class="s2">"max_text_width"</span><span class="p">,</span> +</span><span id="L-302"><a href="#L-302"><span class="linenos"> 302</span></a> <span class="s2">"comments"</span><span class="p">,</span> +</span><span id="L-303"><a href="#L-303"><span class="linenos"> 303</span></a> <span class="s2">"unsupported_messages"</span><span class="p">,</span> +</span><span id="L-304"><a href="#L-304"><span class="linenos"> 304</span></a> <span class="s2">"_escaped_quote_end"</span><span class="p">,</span> +</span><span id="L-305"><a href="#L-305"><span class="linenos"> 305</span></a> <span class="s2">"_escaped_identifier_end"</span><span class="p">,</span> +</span><span id="L-306"><a href="#L-306"><span class="linenos"> 306</span></a> <span class="s2">"_cache"</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><span id="L-309"><a href="#L-309"><span class="linenos"> 309</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> +</span><span id="L-310"><a href="#L-310"><span class="linenos"> 310</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-311"><a href="#L-311"><span class="linenos"> 311</span></a> <span class="n">pretty</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-312"><a href="#L-312"><span class="linenos"> 312</span></a> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-313"><a href="#L-313"><span class="linenos"> 313</span></a> <span class="n">normalize</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-314"><a href="#L-314"><span class="linenos"> 314</span></a> <span class="n">pad</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> +</span><span id="L-315"><a href="#L-315"><span class="linenos"> 315</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> +</span><span id="L-316"><a href="#L-316"><span class="linenos"> 316</span></a> <span class="n">normalize_functions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-317"><a href="#L-317"><span class="linenos"> 317</span></a> <span class="n">unsupported_level</span><span class="p">:</span> <span class="n">ErrorLevel</span> <span class="o">=</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">,</span> +</span><span id="L-318"><a href="#L-318"><span class="linenos"> 318</span></a> <span class="n">max_unsupported</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> +</span><span id="L-319"><a href="#L-319"><span class="linenos"> 319</span></a> <span class="n">leading_comma</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-320"><a href="#L-320"><span class="linenos"> 320</span></a> <span class="n">max_text_width</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">80</span><span class="p">,</span> +</span><span id="L-321"><a href="#L-321"><span class="linenos"> 321</span></a> <span class="n">comments</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-322"><a href="#L-322"><span class="linenos"> 322</span></a> <span class="p">):</span> +</span><span id="L-323"><a href="#L-323"><span class="linenos"> 323</span></a> <span class="kn">import</span> <span class="nn">sqlglot</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="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="o">=</span> <span class="n">pretty</span> <span class="k">if</span> <span class="n">pretty</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">pretty</span> +</span><span id="L-326"><a href="#L-326"><span class="linenos"> 326</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">identify</span> +</span><span id="L-327"><a href="#L-327"><span class="linenos"> 327</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="o">=</span> <span class="n">normalize</span> +</span><span id="L-328"><a href="#L-328"><span class="linenos"> 328</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="o">=</span> <span class="n">pad</span> +</span><span id="L-329"><a href="#L-329"><span class="linenos"> 329</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_indent</span> <span class="o">=</span> <span class="n">indent</span> +</span><span id="L-330"><a href="#L-330"><span class="linenos"> 330</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">=</span> <span class="n">unsupported_level</span> +</span><span id="L-331"><a href="#L-331"><span class="linenos"> 331</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span> <span class="o">=</span> <span class="n">max_unsupported</span> +</span><span id="L-332"><a href="#L-332"><span class="linenos"> 332</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span> <span class="o">=</span> <span class="n">leading_comma</span> +</span><span id="L-333"><a href="#L-333"><span class="linenos"> 333</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="o">=</span> <span class="n">max_text_width</span> +</span><span id="L-334"><a href="#L-334"><span class="linenos"> 334</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> +</span><span id="L-335"><a href="#L-335"><span class="linenos"> 335</span></a> +</span><span id="L-336"><a href="#L-336"><span class="linenos"> 336</span></a> <span class="c1"># This is both a Dialect property and a Generator argument, so we prioritize the latter</span> +</span><span id="L-337"><a href="#L-337"><span class="linenos"> 337</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-338"><a href="#L-338"><span class="linenos"> 338</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">NORMALIZE_FUNCTIONS</span> <span class="k">if</span> <span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">normalize_functions</span> +</span><span id="L-339"><a href="#L-339"><span class="linenos"> 339</span></a> <span class="p">)</span> +</span><span id="L-340"><a href="#L-340"><span class="linenos"> 340</span></a> +</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">unsupported_messages</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-342"><a href="#L-342"><span class="linenos"> 342</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRING_ESCAPE</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span> +</span><span id="L-343"><a href="#L-343"><span class="linenos"> 343</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_ESCAPE</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_END</span> +</span><span id="L-344"><a href="#L-344"><span class="linenos"> 344</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-345"><a href="#L-345"><span class="linenos"> 345</span></a> +</span><span id="L-346"><a href="#L-346"><span class="linenos"> 346</span></a> <span class="k">def</span> <span class="nf">generate</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="p">,</span> +</span><span id="L-348"><a href="#L-348"><span class="linenos"> 348</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> +</span><span id="L-349"><a href="#L-349"><span class="linenos"> 349</span></a> <span class="n">cache</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-350"><a href="#L-350"><span class="linenos"> 350</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-351"><a href="#L-351"><span class="linenos"> 351</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-352"><a href="#L-352"><span class="linenos"> 352</span></a><span class="sd"> Generates the SQL string corresponding to the given syntax tree.</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="sd"> Args:</span> +</span><span id="L-355"><a href="#L-355"><span class="linenos"> 355</span></a><span class="sd"> expression: The syntax tree.</span> +</span><span id="L-356"><a href="#L-356"><span class="linenos"> 356</span></a><span class="sd"> cache: An optional sql string cache. This leverages the hash of an Expression</span> +</span><span id="L-357"><a href="#L-357"><span class="linenos"> 357</span></a><span class="sd"> which can be slow to compute, so only use it if you set _hash on each node.</span> +</span><span id="L-358"><a href="#L-358"><span class="linenos"> 358</span></a> +</span><span id="L-359"><a href="#L-359"><span class="linenos"> 359</span></a><span class="sd"> Returns:</span> +</span><span id="L-360"><a href="#L-360"><span class="linenos"> 360</span></a><span class="sd"> The SQL string corresponding to `expression`.</span> +</span><span id="L-361"><a href="#L-361"><span class="linenos"> 361</span></a><span class="sd"> """</span> +</span><span id="L-362"><a href="#L-362"><span class="linenos"> 362</span></a> <span class="k">if</span> <span class="n">cache</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-363"><a href="#L-363"><span class="linenos"> 363</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="o">=</span> <span class="n">cache</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">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">:</span> -</span><span id="L-366"><a href="#L-366"><span class="linenos"> 366</span></a> <span class="k">for</span> <span class="n">msg</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> -</span><span id="L-367"><a href="#L-367"><span class="linenos"> 367</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> -</span><span id="L-368"><a href="#L-368"><span class="linenos"> 368</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">RAISE</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> -</span><span id="L-369"><a href="#L-369"><span class="linenos"> 369</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">concat_messages</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span><span class="p">))</span> -</span><span id="L-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">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="L-372"><a href="#L-372"><span class="linenos"> 372</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">,</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-373"><a href="#L-373"><span class="linenos"> 373</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="L-374"><a href="#L-374"><span class="linenos"> 374</span></a> -</span><span id="L-375"><a href="#L-375"><span class="linenos"> 375</span></a> <span class="k">def</span> <span class="nf">unsupported</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-376"><a href="#L-376"><span class="linenos"> 376</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span><span class="p">:</span> -</span><span id="L-377"><a href="#L-377"><span class="linenos"> 377</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> -</span><span id="L-378"><a href="#L-378"><span class="linenos"> 378</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> -</span><span id="L-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">sep</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-381"><a href="#L-381"><span class="linenos"> 381</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="n">sep</span> -</span><span id="L-382"><a href="#L-382"><span class="linenos"> 382</span></a> -</span><span id="L-383"><a href="#L-383"><span class="linenos"> 383</span></a> <span class="k">def</span> <span class="nf">seg</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-384"><a href="#L-384"><span class="linenos"> 384</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-385"><a href="#L-385"><span class="linenos"> 385</span></a> -</span><span id="L-386"><a href="#L-386"><span class="linenos"> 386</span></a> <span class="k">def</span> <span class="nf">pad_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">comment</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-387"><a href="#L-387"><span class="linenos"> 387</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">+</span> <span class="n">comment</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> -</span><span id="L-388"><a href="#L-388"><span class="linenos"> 388</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="n">comment</span> <span class="o">+</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> -</span><span id="L-389"><a href="#L-389"><span class="linenos"> 389</span></a> <span class="k">return</span> <span class="n">comment</span> -</span><span id="L-390"><a href="#L-390"><span class="linenos"> 390</span></a> -</span><span id="L-391"><a href="#L-391"><span class="linenos"> 391</span></a> <span class="k">def</span> <span class="nf">maybe_comment</span><span class="p">(</span> -</span><span id="L-392"><a href="#L-392"><span class="linenos"> 392</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-393"><a href="#L-393"><span class="linenos"> 393</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="L-394"><a href="#L-394"><span class="linenos"> 394</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-395"><a href="#L-395"><span class="linenos"> 395</span></a> <span class="n">comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-396"><a href="#L-396"><span class="linenos"> 396</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-397"><a href="#L-397"><span class="linenos"> 397</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-398"><a href="#L-398"><span class="linenos"> 398</span></a> <span class="p">((</span><span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> <span class="k">if</span> <span class="n">comments</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">comments</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="L-399"><a href="#L-399"><span class="linenos"> 399</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> -</span><span id="L-400"><a href="#L-400"><span class="linenos"> 400</span></a> <span class="k">else</span> <span class="kc">None</span> -</span><span id="L-401"><a href="#L-401"><span class="linenos"> 401</span></a> <span class="p">)</span> -</span><span id="L-402"><a href="#L-402"><span class="linenos"> 402</span></a> -</span><span id="L-403"><a href="#L-403"><span class="linenos"> 403</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="L-404"><a href="#L-404"><span class="linenos"> 404</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="L-405"><a href="#L-405"><span class="linenos"> 405</span></a> -</span><span id="L-406"><a href="#L-406"><span class="linenos"> 406</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="L-407"><a href="#L-407"><span class="linenos"> 407</span></a> <span class="n">comments_sql</span> <span class="o">=</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="L-408"><a href="#L-408"><span class="linenos"> 408</span></a> <span class="sa">f</span><span class="s2">"/*</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">pad_comment</span><span class="p">(</span><span class="n">comment</span><span class="p">)</span><span class="si">}</span><span class="s2">*/"</span> <span class="k">for</span> <span class="n">comment</span> <span class="ow">in</span> <span class="n">comments</span> <span class="k">if</span> <span class="n">comment</span> -</span><span id="L-409"><a href="#L-409"><span class="linenos"> 409</span></a> <span class="p">)</span> -</span><span id="L-410"><a href="#L-410"><span class="linenos"> 410</span></a> -</span><span id="L-411"><a href="#L-411"><span class="linenos"> 411</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments_sql</span><span class="p">:</span> -</span><span id="L-412"><a href="#L-412"><span class="linenos"> 412</span></a> <span class="k">return</span> <span class="n">sql</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="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">):</span> -</span><span id="L-415"><a href="#L-415"><span class="linenos"> 415</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="L-416"><a href="#L-416"><span class="linenos"> 416</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">comments_sql</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-417"><a href="#L-417"><span class="linenos"> 417</span></a> <span class="k">if</span> <span class="n">sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">isspace</span><span class="p">()</span> -</span><span id="L-418"><a href="#L-418"><span class="linenos"> 418</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">comments_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-419"><a href="#L-419"><span class="linenos"> 419</span></a> <span class="p">)</span> +</span><span id="L-365"><a href="#L-365"><span class="linenos"> 365</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-366"><a href="#L-366"><span class="linenos"> 366</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="L-367"><a href="#L-367"><span class="linenos"> 367</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="o">=</span> <span class="kc">None</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">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IGNORE</span><span class="p">:</span> +</span><span id="L-370"><a href="#L-370"><span class="linenos"> 370</span></a> <span class="k">return</span> <span class="n">sql</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">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">:</span> +</span><span id="L-373"><a href="#L-373"><span class="linenos"> 373</span></a> <span class="k">for</span> <span class="n">msg</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> +</span><span id="L-374"><a href="#L-374"><span class="linenos"> 374</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> +</span><span id="L-375"><a href="#L-375"><span class="linenos"> 375</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">RAISE</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> +</span><span id="L-376"><a href="#L-376"><span class="linenos"> 376</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">concat_messages</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span><span class="p">))</span> +</span><span id="L-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="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="L-379"><a href="#L-379"><span class="linenos"> 379</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">,</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-380"><a href="#L-380"><span class="linenos"> 380</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="L-381"><a href="#L-381"><span class="linenos"> 381</span></a> +</span><span id="L-382"><a href="#L-382"><span class="linenos"> 382</span></a> <span class="k">def</span> <span class="nf">unsupported</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-383"><a href="#L-383"><span class="linenos"> 383</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span><span class="p">:</span> +</span><span id="L-384"><a href="#L-384"><span class="linenos"> 384</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> +</span><span id="L-385"><a href="#L-385"><span class="linenos"> 385</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> +</span><span id="L-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">sep</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-388"><a href="#L-388"><span class="linenos"> 388</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="n">sep</span> +</span><span id="L-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">seg</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-391"><a href="#L-391"><span class="linenos"> 391</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-392"><a href="#L-392"><span class="linenos"> 392</span></a> +</span><span id="L-393"><a href="#L-393"><span class="linenos"> 393</span></a> <span class="k">def</span> <span class="nf">pad_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">comment</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-394"><a href="#L-394"><span class="linenos"> 394</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">+</span> <span class="n">comment</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> +</span><span id="L-395"><a href="#L-395"><span class="linenos"> 395</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="n">comment</span> <span class="o">+</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> +</span><span id="L-396"><a href="#L-396"><span class="linenos"> 396</span></a> <span class="k">return</span> <span class="n">comment</span> +</span><span id="L-397"><a href="#L-397"><span class="linenos"> 397</span></a> +</span><span id="L-398"><a href="#L-398"><span class="linenos"> 398</span></a> <span class="k">def</span> <span class="nf">maybe_comment</span><span class="p">(</span> +</span><span id="L-399"><a href="#L-399"><span class="linenos"> 399</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-400"><a href="#L-400"><span class="linenos"> 400</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="L-401"><a href="#L-401"><span class="linenos"> 401</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-402"><a href="#L-402"><span class="linenos"> 402</span></a> <span class="n">comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-403"><a href="#L-403"><span class="linenos"> 403</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-404"><a href="#L-404"><span class="linenos"> 404</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-405"><a href="#L-405"><span class="linenos"> 405</span></a> <span class="p">((</span><span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> <span class="k">if</span> <span class="n">comments</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">comments</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="L-406"><a href="#L-406"><span class="linenos"> 406</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> +</span><span id="L-407"><a href="#L-407"><span class="linenos"> 407</span></a> <span class="k">else</span> <span class="kc">None</span> +</span><span id="L-408"><a href="#L-408"><span class="linenos"> 408</span></a> <span class="p">)</span> +</span><span id="L-409"><a href="#L-409"><span class="linenos"> 409</span></a> +</span><span id="L-410"><a href="#L-410"><span class="linenos"> 410</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="L-411"><a href="#L-411"><span class="linenos"> 411</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="L-412"><a href="#L-412"><span class="linenos"> 412</span></a> +</span><span id="L-413"><a href="#L-413"><span class="linenos"> 413</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="L-414"><a href="#L-414"><span class="linenos"> 414</span></a> <span class="n">comments_sql</span> <span class="o">=</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="L-415"><a href="#L-415"><span class="linenos"> 415</span></a> <span class="sa">f</span><span class="s2">"/*</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">pad_comment</span><span class="p">(</span><span class="n">comment</span><span class="p">)</span><span class="si">}</span><span class="s2">*/"</span> <span class="k">for</span> <span class="n">comment</span> <span class="ow">in</span> <span class="n">comments</span> <span class="k">if</span> <span class="n">comment</span> +</span><span id="L-416"><a href="#L-416"><span class="linenos"> 416</span></a> <span class="p">)</span> +</span><span id="L-417"><a href="#L-417"><span class="linenos"> 417</span></a> +</span><span id="L-418"><a href="#L-418"><span class="linenos"> 418</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments_sql</span><span class="p">:</span> +</span><span id="L-419"><a href="#L-419"><span class="linenos"> 419</span></a> <span class="k">return</span> <span class="n">sql</span> </span><span id="L-420"><a href="#L-420"><span class="linenos"> 420</span></a> -</span><span id="L-421"><a href="#L-421"><span class="linenos"> 421</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">comments_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-422"><a href="#L-422"><span class="linenos"> 422</span></a> -</span><span id="L-423"><a href="#L-423"><span class="linenos"> 423</span></a> <span class="k">def</span> <span class="nf">wrap</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">|</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-424"><a href="#L-424"><span class="linenos"> 424</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span> -</span><span id="L-425"><a href="#L-425"><span class="linenos"> 425</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-426"><a href="#L-426"><span class="linenos"> 426</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">))</span> -</span><span id="L-427"><a href="#L-427"><span class="linenos"> 427</span></a> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> -</span><span id="L-428"><a href="#L-428"><span class="linenos"> 428</span></a> <span class="n">level</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> -</span><span id="L-429"><a href="#L-429"><span class="linenos"> 429</span></a> <span class="n">pad</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> -</span><span id="L-430"><a href="#L-430"><span class="linenos"> 430</span></a> <span class="p">)</span> -</span><span id="L-431"><a href="#L-431"><span class="linenos"> 431</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">this_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-432"><a href="#L-432"><span class="linenos"> 432</span></a> -</span><span id="L-433"><a href="#L-433"><span class="linenos"> 433</span></a> <span class="k">def</span> <span class="nf">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">func</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-434"><a href="#L-434"><span class="linenos"> 434</span></a> <span class="n">original</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> -</span><span id="L-435"><a href="#L-435"><span class="linenos"> 435</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-436"><a href="#L-436"><span class="linenos"> 436</span></a> <span class="n">result</span> <span class="o">=</span> <span class="n">func</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="L-437"><a href="#L-437"><span class="linenos"> 437</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">original</span> -</span><span id="L-438"><a href="#L-438"><span class="linenos"> 438</span></a> <span class="k">return</span> <span class="n">result</span> +</span><span id="L-421"><a href="#L-421"><span class="linenos"> 421</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">):</span> +</span><span id="L-422"><a href="#L-422"><span class="linenos"> 422</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="L-423"><a href="#L-423"><span class="linenos"> 423</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">comments_sql</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-424"><a href="#L-424"><span class="linenos"> 424</span></a> <span class="k">if</span> <span class="n">sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">isspace</span><span class="p">()</span> +</span><span id="L-425"><a href="#L-425"><span class="linenos"> 425</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">comments_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-426"><a href="#L-426"><span class="linenos"> 426</span></a> <span class="p">)</span> +</span><span id="L-427"><a href="#L-427"><span class="linenos"> 427</span></a> +</span><span id="L-428"><a href="#L-428"><span class="linenos"> 428</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">comments_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-429"><a href="#L-429"><span class="linenos"> 429</span></a> +</span><span id="L-430"><a href="#L-430"><span class="linenos"> 430</span></a> <span class="k">def</span> <span class="nf">wrap</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">|</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-431"><a href="#L-431"><span class="linenos"> 431</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span> +</span><span id="L-432"><a href="#L-432"><span class="linenos"> 432</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-433"><a href="#L-433"><span class="linenos"> 433</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">))</span> +</span><span id="L-434"><a href="#L-434"><span class="linenos"> 434</span></a> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> +</span><span id="L-435"><a href="#L-435"><span class="linenos"> 435</span></a> <span class="n">level</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> +</span><span id="L-436"><a href="#L-436"><span class="linenos"> 436</span></a> <span class="n">pad</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> +</span><span id="L-437"><a href="#L-437"><span class="linenos"> 437</span></a> <span class="p">)</span> +</span><span id="L-438"><a href="#L-438"><span class="linenos"> 438</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">this_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-439"><a href="#L-439"><span class="linenos"> 439</span></a> -</span><span id="L-440"><a href="#L-440"><span class="linenos"> 440</span></a> <span class="k">def</span> <span class="nf">normalize_func</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-441"><a href="#L-441"><span class="linenos"> 441</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"upper"</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-442"><a href="#L-442"><span class="linenos"> 442</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-443"><a href="#L-443"><span class="linenos"> 443</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"lower"</span><span class="p">:</span> -</span><span id="L-444"><a href="#L-444"><span class="linenos"> 444</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="L-445"><a href="#L-445"><span class="linenos"> 445</span></a> <span class="k">return</span> <span class="n">name</span> +</span><span id="L-440"><a href="#L-440"><span class="linenos"> 440</span></a> <span class="k">def</span> <span class="nf">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">func</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-441"><a href="#L-441"><span class="linenos"> 441</span></a> <span class="n">original</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> +</span><span id="L-442"><a href="#L-442"><span class="linenos"> 442</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-443"><a href="#L-443"><span class="linenos"> 443</span></a> <span class="n">result</span> <span class="o">=</span> <span class="n">func</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="L-444"><a href="#L-444"><span class="linenos"> 444</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">original</span> +</span><span id="L-445"><a href="#L-445"><span class="linenos"> 445</span></a> <span class="k">return</span> <span class="n">result</span> </span><span id="L-446"><a href="#L-446"><span class="linenos"> 446</span></a> -</span><span id="L-447"><a href="#L-447"><span class="linenos"> 447</span></a> <span class="k">def</span> <span class="nf">indent</span><span class="p">(</span> -</span><span id="L-448"><a href="#L-448"><span class="linenos"> 448</span></a> <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">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="L-450"><a href="#L-450"><span class="linenos"> 450</span></a> <span class="n">level</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> -</span><span id="L-451"><a href="#L-451"><span class="linenos"> 451</span></a> <span class="n">pad</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-452"><a href="#L-452"><span class="linenos"> 452</span></a> <span class="n">skip_first</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-453"><a href="#L-453"><span class="linenos"> 453</span></a> <span class="n">skip_last</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-454"><a href="#L-454"><span class="linenos"> 454</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-455"><a href="#L-455"><span class="linenos"> 455</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="L-456"><a href="#L-456"><span class="linenos"> 456</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="L-457"><a href="#L-457"><span class="linenos"> 457</span></a> -</span><span id="L-458"><a href="#L-458"><span class="linenos"> 458</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="k">if</span> <span class="n">pad</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">pad</span> -</span><span id="L-459"><a href="#L-459"><span class="linenos"> 459</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-460"><a href="#L-460"><span class="linenos"> 460</span></a> -</span><span id="L-461"><a href="#L-461"><span class="linenos"> 461</span></a> <span class="k">return</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="L-462"><a href="#L-462"><span class="linenos"> 462</span></a> <span class="n">line</span> -</span><span id="L-463"><a href="#L-463"><span class="linenos"> 463</span></a> <span class="k">if</span> <span class="p">(</span><span class="n">skip_first</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">skip_last</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="L-464"><a href="#L-464"><span class="linenos"> 464</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' '</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="n">level</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="bp">self</span><span class="o">.</span><span class="n">_indent</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">pad</span><span class="p">)</span><span class="si">}{</span><span class="n">line</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-465"><a href="#L-465"><span class="linenos"> 465</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">line</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> -</span><span id="L-466"><a href="#L-466"><span class="linenos"> 466</span></a> <span class="p">)</span> +</span><span id="L-447"><a href="#L-447"><span class="linenos"> 447</span></a> <span class="k">def</span> <span class="nf">normalize_func</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-448"><a href="#L-448"><span class="linenos"> 448</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"upper"</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-449"><a href="#L-449"><span class="linenos"> 449</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-450"><a href="#L-450"><span class="linenos"> 450</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"lower"</span><span class="p">:</span> +</span><span id="L-451"><a href="#L-451"><span class="linenos"> 451</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> +</span><span id="L-452"><a href="#L-452"><span class="linenos"> 452</span></a> <span class="k">return</span> <span class="n">name</span> +</span><span id="L-453"><a href="#L-453"><span class="linenos"> 453</span></a> +</span><span id="L-454"><a href="#L-454"><span class="linenos"> 454</span></a> <span class="k">def</span> <span class="nf">indent</span><span class="p">(</span> +</span><span id="L-455"><a href="#L-455"><span class="linenos"> 455</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-456"><a href="#L-456"><span class="linenos"> 456</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="L-457"><a href="#L-457"><span class="linenos"> 457</span></a> <span class="n">level</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> +</span><span id="L-458"><a href="#L-458"><span class="linenos"> 458</span></a> <span class="n">pad</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-459"><a href="#L-459"><span class="linenos"> 459</span></a> <span class="n">skip_first</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-460"><a href="#L-460"><span class="linenos"> 460</span></a> <span class="n">skip_last</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-461"><a href="#L-461"><span class="linenos"> 461</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-462"><a href="#L-462"><span class="linenos"> 462</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="L-463"><a href="#L-463"><span class="linenos"> 463</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="L-464"><a href="#L-464"><span class="linenos"> 464</span></a> +</span><span id="L-465"><a href="#L-465"><span class="linenos"> 465</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="k">if</span> <span class="n">pad</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">pad</span> +</span><span id="L-466"><a href="#L-466"><span class="linenos"> 466</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> </span><span id="L-467"><a href="#L-467"><span class="linenos"> 467</span></a> -</span><span id="L-468"><a href="#L-468"><span class="linenos"> 468</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span> -</span><span id="L-469"><a href="#L-469"><span class="linenos"> 469</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-470"><a href="#L-470"><span class="linenos"> 470</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> -</span><span id="L-471"><a href="#L-471"><span class="linenos"> 471</span></a> <span class="n">key</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-472"><a href="#L-472"><span class="linenos"> 472</span></a> <span class="n">comment</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-473"><a href="#L-473"><span class="linenos"> 473</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-474"><a href="#L-474"><span class="linenos"> 474</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> -</span><span id="L-475"><a href="#L-475"><span class="linenos"> 475</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="L-476"><a href="#L-476"><span class="linenos"> 476</span></a> -</span><span id="L-477"><a href="#L-477"><span class="linenos"> 477</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="L-478"><a href="#L-478"><span class="linenos"> 478</span></a> <span class="k">return</span> <span class="n">expression</span> -</span><span id="L-479"><a href="#L-479"><span class="linenos"> 479</span></a> -</span><span id="L-480"><a href="#L-480"><span class="linenos"> 480</span></a> <span class="k">if</span> <span class="n">key</span><span class="p">:</span> -</span><span id="L-481"><a href="#L-481"><span class="linenos"> 481</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="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">))</span> -</span><span id="L-482"><a href="#L-482"><span class="linenos"> 482</span></a> -</span><span id="L-483"><a href="#L-483"><span class="linenos"> 483</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-484"><a href="#L-484"><span class="linenos"> 484</span></a> <span class="n">expression_id</span> <span class="o">=</span> <span class="nb">hash</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-485"><a href="#L-485"><span class="linenos"> 485</span></a> -</span><span id="L-486"><a href="#L-486"><span class="linenos"> 486</span></a> <span class="k">if</span> <span class="n">expression_id</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">:</span> -</span><span id="L-487"><a href="#L-487"><span class="linenos"> 487</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">[</span><span class="n">expression_id</span><span class="p">]</span> -</span><span id="L-488"><a href="#L-488"><span class="linenos"> 488</span></a> -</span><span id="L-489"><a href="#L-489"><span class="linenos"> 489</span></a> <span class="n">transform</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span> -</span><span id="L-490"><a href="#L-490"><span class="linenos"> 490</span></a> -</span><span id="L-491"><a href="#L-491"><span class="linenos"> 491</span></a> <span class="k">if</span> <span class="nb">callable</span><span class="p">(</span><span class="n">transform</span><span class="p">):</span> -</span><span id="L-492"><a href="#L-492"><span class="linenos"> 492</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-493"><a href="#L-493"><span class="linenos"> 493</span></a> <span class="k">elif</span> <span class="n">transform</span><span class="p">:</span> -</span><span id="L-494"><a href="#L-494"><span class="linenos"> 494</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span> -</span><span id="L-495"><a href="#L-495"><span class="linenos"> 495</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="L-496"><a href="#L-496"><span class="linenos"> 496</span></a> <span class="n">exp_handler_name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">_sql"</span> +</span><span id="L-468"><a href="#L-468"><span class="linenos"> 468</span></a> <span class="k">return</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="L-469"><a href="#L-469"><span class="linenos"> 469</span></a> <span class="n">line</span> +</span><span id="L-470"><a href="#L-470"><span class="linenos"> 470</span></a> <span class="k">if</span> <span class="p">(</span><span class="n">skip_first</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">skip_last</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="L-471"><a href="#L-471"><span class="linenos"> 471</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' '</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="n">level</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="bp">self</span><span class="o">.</span><span class="n">_indent</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">pad</span><span class="p">)</span><span class="si">}{</span><span class="n">line</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-472"><a href="#L-472"><span class="linenos"> 472</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">line</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> +</span><span id="L-473"><a href="#L-473"><span class="linenos"> 473</span></a> <span class="p">)</span> +</span><span id="L-474"><a href="#L-474"><span class="linenos"> 474</span></a> +</span><span id="L-475"><a href="#L-475"><span class="linenos"> 475</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span> +</span><span id="L-476"><a href="#L-476"><span class="linenos"> 476</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-477"><a href="#L-477"><span class="linenos"> 477</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> +</span><span id="L-478"><a href="#L-478"><span class="linenos"> 478</span></a> <span class="n">key</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-479"><a href="#L-479"><span class="linenos"> 479</span></a> <span class="n">comment</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-480"><a href="#L-480"><span class="linenos"> 480</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-481"><a href="#L-481"><span class="linenos"> 481</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> +</span><span id="L-482"><a href="#L-482"><span class="linenos"> 482</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-483"><a href="#L-483"><span class="linenos"> 483</span></a> +</span><span id="L-484"><a href="#L-484"><span class="linenos"> 484</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="L-485"><a href="#L-485"><span class="linenos"> 485</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-486"><a href="#L-486"><span class="linenos"> 486</span></a> +</span><span id="L-487"><a href="#L-487"><span class="linenos"> 487</span></a> <span class="k">if</span> <span class="n">key</span><span class="p">:</span> +</span><span id="L-488"><a href="#L-488"><span class="linenos"> 488</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="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">))</span> +</span><span id="L-489"><a href="#L-489"><span class="linenos"> 489</span></a> +</span><span id="L-490"><a href="#L-490"><span class="linenos"> 490</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-491"><a href="#L-491"><span class="linenos"> 491</span></a> <span class="n">expression_id</span> <span class="o">=</span> <span class="nb">hash</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-492"><a href="#L-492"><span class="linenos"> 492</span></a> +</span><span id="L-493"><a href="#L-493"><span class="linenos"> 493</span></a> <span class="k">if</span> <span class="n">expression_id</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">:</span> +</span><span id="L-494"><a href="#L-494"><span class="linenos"> 494</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">[</span><span class="n">expression_id</span><span class="p">]</span> +</span><span id="L-495"><a href="#L-495"><span class="linenos"> 495</span></a> +</span><span id="L-496"><a href="#L-496"><span class="linenos"> 496</span></a> <span class="n">transform</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span> </span><span id="L-497"><a href="#L-497"><span class="linenos"> 497</span></a> -</span><span id="L-498"><a href="#L-498"><span class="linenos"> 498</span></a> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">):</span> -</span><span id="L-499"><a href="#L-499"><span class="linenos"> 499</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">)(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-500"><a href="#L-500"><span class="linenos"> 500</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-501"><a href="#L-501"><span class="linenos"> 501</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-502"><a href="#L-502"><span class="linenos"> 502</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">):</span> -</span><span id="L-503"><a href="#L-503"><span class="linenos"> 503</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">property_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-504"><a href="#L-504"><span class="linenos"> 504</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-505"><a href="#L-505"><span class="linenos"> 505</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported expression type </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-506"><a href="#L-506"><span class="linenos"> 506</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-507"><a href="#L-507"><span class="linenos"> 507</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Expected an Expression. Received </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">expression</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-508"><a href="#L-508"><span class="linenos"> 508</span></a> -</span><span id="L-509"><a href="#L-509"><span class="linenos"> 509</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">sql</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="ow">and</span> <span class="n">comment</span> <span class="k">else</span> <span class="n">sql</span> -</span><span id="L-510"><a href="#L-510"><span class="linenos"> 510</span></a> -</span><span id="L-511"><a href="#L-511"><span class="linenos"> 511</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-512"><a href="#L-512"><span class="linenos"> 512</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">[</span><span class="n">expression_id</span><span class="p">]</span> <span class="o">=</span> <span class="n">sql</span> -</span><span id="L-513"><a href="#L-513"><span class="linenos"> 513</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="L-514"><a href="#L-514"><span class="linenos"> 514</span></a> -</span><span id="L-515"><a href="#L-515"><span class="linenos"> 515</span></a> <span class="k">def</span> <span class="nf">uncache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Uncache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-516"><a href="#L-516"><span class="linenos"> 516</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-517"><a href="#L-517"><span class="linenos"> 517</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-518"><a href="#L-518"><span class="linenos"> 518</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNCACHE TABLE</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-519"><a href="#L-519"><span class="linenos"> 519</span></a> -</span><span id="L-520"><a href="#L-520"><span class="linenos"> 520</span></a> <span class="k">def</span> <span class="nf">cache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-521"><a href="#L-521"><span class="linenos"> 521</span></a> <span class="n">lazy</span> <span class="o">=</span> <span class="s2">" LAZY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lazy"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-522"><a href="#L-522"><span class="linenos"> 522</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-523"><a href="#L-523"><span class="linenos"> 523</span></a> <span class="n">options</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"options"</span><span class="p">)</span> -</span><span id="L-524"><a href="#L-524"><span class="linenos"> 524</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OPTIONS(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span><span class="si">}</span><span class="s2"> = </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-525"><a href="#L-525"><span class="linenos"> 525</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="L-526"><a href="#L-526"><span class="linenos"> 526</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-527"><a href="#L-527"><span class="linenos"> 527</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CACHE</span><span class="si">{</span><span class="n">lazy</span><span class="si">}</span><span class="s2"> TABLE </span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">options</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-528"><a href="#L-528"><span class="linenos"> 528</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="L-529"><a href="#L-529"><span class="linenos"> 529</span></a> -</span><span id="L-530"><a href="#L-530"><span class="linenos"> 530</span></a> <span class="k">def</span> <span class="nf">characterset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSet</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-531"><a href="#L-531"><span class="linenos"> 531</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="L-532"><a href="#L-532"><span class="linenos"> 532</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHAR CHARACTER SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-533"><a href="#L-533"><span class="linenos"> 533</span></a> <span class="n">default</span> <span class="o">=</span> <span class="s2">"DEFAULT "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-534"><a href="#L-534"><span class="linenos"> 534</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">CHARACTER SET=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-535"><a href="#L-535"><span class="linenos"> 535</span></a> -</span><span id="L-536"><a href="#L-536"><span class="linenos"> 536</span></a> <span class="k">def</span> <span class="nf">column_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-537"><a href="#L-537"><span class="linenos"> 537</span></a> <span class="k">return</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="L-538"><a href="#L-538"><span class="linenos"> 538</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> -</span><span id="L-539"><a href="#L-539"><span class="linenos"> 539</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="L-540"><a href="#L-540"><span class="linenos"> 540</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">),</span> -</span><span id="L-541"><a href="#L-541"><span class="linenos"> 541</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"db"</span><span class="p">),</span> -</span><span id="L-542"><a href="#L-542"><span class="linenos"> 542</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"table"</span><span class="p">),</span> -</span><span id="L-543"><a href="#L-543"><span class="linenos"> 543</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"this"</span><span class="p">),</span> -</span><span id="L-544"><a href="#L-544"><span class="linenos"> 544</span></a> <span class="p">)</span> -</span><span id="L-545"><a href="#L-545"><span class="linenos"> 545</span></a> <span class="k">if</span> <span class="n">part</span> -</span><span id="L-546"><a href="#L-546"><span class="linenos"> 546</span></a> <span class="p">)</span> -</span><span id="L-547"><a href="#L-547"><span class="linenos"> 547</span></a> -</span><span id="L-548"><a href="#L-548"><span class="linenos"> 548</span></a> <span class="k">def</span> <span class="nf">columnposition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-549"><a href="#L-549"><span class="linenos"> 549</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-550"><a href="#L-550"><span class="linenos"> 550</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-551"><a href="#L-551"><span class="linenos"> 551</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> -</span><span id="L-552"><a href="#L-552"><span class="linenos"> 552</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">position</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-553"><a href="#L-553"><span class="linenos"> 553</span></a> -</span><span id="L-554"><a href="#L-554"><span class="linenos"> 554</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-555"><a href="#L-555"><span class="linenos"> 555</span></a> <span class="n">column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-556"><a href="#L-556"><span class="linenos"> 556</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="L-557"><a href="#L-557"><span class="linenos"> 557</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"constraints"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-558"><a href="#L-558"><span class="linenos"> 558</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">"IF NOT EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-559"><a href="#L-559"><span class="linenos"> 559</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-560"><a href="#L-560"><span class="linenos"> 560</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">constraints</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">constraints</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-561"><a href="#L-561"><span class="linenos"> 561</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> -</span><span id="L-562"><a href="#L-562"><span class="linenos"> 562</span></a> <span class="n">position</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">position</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-563"><a href="#L-563"><span class="linenos"> 563</span></a> -</span><span id="L-564"><a href="#L-564"><span class="linenos"> 564</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">column</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-565"><a href="#L-565"><span class="linenos"> 565</span></a> -</span><span id="L-566"><a href="#L-566"><span class="linenos"> 566</span></a> <span class="k">def</span> <span class="nf">columnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-567"><a href="#L-567"><span class="linenos"> 567</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-568"><a href="#L-568"><span class="linenos"> 568</span></a> <span class="n">kind_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="L-569"><a href="#L-569"><span class="linenos"> 569</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="n">kind_sql</span> +</span><span id="L-498"><a href="#L-498"><span class="linenos"> 498</span></a> <span class="k">if</span> <span class="nb">callable</span><span class="p">(</span><span class="n">transform</span><span class="p">):</span> +</span><span id="L-499"><a href="#L-499"><span class="linenos"> 499</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-500"><a href="#L-500"><span class="linenos"> 500</span></a> <span class="k">elif</span> <span class="n">transform</span><span class="p">:</span> +</span><span id="L-501"><a href="#L-501"><span class="linenos"> 501</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span> +</span><span id="L-502"><a href="#L-502"><span class="linenos"> 502</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="L-503"><a href="#L-503"><span class="linenos"> 503</span></a> <span class="n">exp_handler_name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">_sql"</span> +</span><span id="L-504"><a href="#L-504"><span class="linenos"> 504</span></a> +</span><span id="L-505"><a href="#L-505"><span class="linenos"> 505</span></a> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">):</span> +</span><span id="L-506"><a href="#L-506"><span class="linenos"> 506</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">)(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-507"><a href="#L-507"><span class="linenos"> 507</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-508"><a href="#L-508"><span class="linenos"> 508</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-509"><a href="#L-509"><span class="linenos"> 509</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">):</span> +</span><span id="L-510"><a href="#L-510"><span class="linenos"> 510</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">property_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-511"><a href="#L-511"><span class="linenos"> 511</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-512"><a href="#L-512"><span class="linenos"> 512</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported expression type </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-513"><a href="#L-513"><span class="linenos"> 513</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-514"><a href="#L-514"><span class="linenos"> 514</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Expected an Expression. Received </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">expression</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-515"><a href="#L-515"><span class="linenos"> 515</span></a> +</span><span id="L-516"><a href="#L-516"><span class="linenos"> 516</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">sql</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="ow">and</span> <span class="n">comment</span> <span class="k">else</span> <span class="n">sql</span> +</span><span id="L-517"><a href="#L-517"><span class="linenos"> 517</span></a> +</span><span id="L-518"><a href="#L-518"><span class="linenos"> 518</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-519"><a href="#L-519"><span class="linenos"> 519</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">[</span><span class="n">expression_id</span><span class="p">]</span> <span class="o">=</span> <span class="n">sql</span> +</span><span id="L-520"><a href="#L-520"><span class="linenos"> 520</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="L-521"><a href="#L-521"><span class="linenos"> 521</span></a> +</span><span id="L-522"><a href="#L-522"><span class="linenos"> 522</span></a> <span class="k">def</span> <span class="nf">uncache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Uncache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-523"><a href="#L-523"><span class="linenos"> 523</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-524"><a href="#L-524"><span class="linenos"> 524</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-525"><a href="#L-525"><span class="linenos"> 525</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNCACHE TABLE</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-526"><a href="#L-526"><span class="linenos"> 526</span></a> +</span><span id="L-527"><a href="#L-527"><span class="linenos"> 527</span></a> <span class="k">def</span> <span class="nf">cache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-528"><a href="#L-528"><span class="linenos"> 528</span></a> <span class="n">lazy</span> <span class="o">=</span> <span class="s2">" LAZY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lazy"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-529"><a href="#L-529"><span class="linenos"> 529</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-530"><a href="#L-530"><span class="linenos"> 530</span></a> <span class="n">options</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"options"</span><span class="p">)</span> +</span><span id="L-531"><a href="#L-531"><span class="linenos"> 531</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OPTIONS(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span><span class="si">}</span><span class="s2"> = </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-532"><a href="#L-532"><span class="linenos"> 532</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="L-533"><a href="#L-533"><span class="linenos"> 533</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-534"><a href="#L-534"><span class="linenos"> 534</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CACHE</span><span class="si">{</span><span class="n">lazy</span><span class="si">}</span><span class="s2"> TABLE </span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">options</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-535"><a href="#L-535"><span class="linenos"> 535</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="L-536"><a href="#L-536"><span class="linenos"> 536</span></a> +</span><span id="L-537"><a href="#L-537"><span class="linenos"> 537</span></a> <span class="k">def</span> <span class="nf">characterset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSet</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-538"><a href="#L-538"><span class="linenos"> 538</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="L-539"><a href="#L-539"><span class="linenos"> 539</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHAR CHARACTER SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-540"><a href="#L-540"><span class="linenos"> 540</span></a> <span class="n">default</span> <span class="o">=</span> <span class="s2">"DEFAULT "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-541"><a href="#L-541"><span class="linenos"> 541</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">CHARACTER SET=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-542"><a href="#L-542"><span class="linenos"> 542</span></a> +</span><span id="L-543"><a href="#L-543"><span class="linenos"> 543</span></a> <span class="k">def</span> <span class="nf">column_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-544"><a href="#L-544"><span class="linenos"> 544</span></a> <span class="k">return</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="L-545"><a href="#L-545"><span class="linenos"> 545</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> +</span><span id="L-546"><a href="#L-546"><span class="linenos"> 546</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="L-547"><a href="#L-547"><span class="linenos"> 547</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">),</span> +</span><span id="L-548"><a href="#L-548"><span class="linenos"> 548</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"db"</span><span class="p">),</span> +</span><span id="L-549"><a href="#L-549"><span class="linenos"> 549</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"table"</span><span class="p">),</span> +</span><span id="L-550"><a href="#L-550"><span class="linenos"> 550</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"this"</span><span class="p">),</span> +</span><span id="L-551"><a href="#L-551"><span class="linenos"> 551</span></a> <span class="p">)</span> +</span><span id="L-552"><a href="#L-552"><span class="linenos"> 552</span></a> <span class="k">if</span> <span class="n">part</span> +</span><span id="L-553"><a href="#L-553"><span class="linenos"> 553</span></a> <span class="p">)</span> +</span><span id="L-554"><a href="#L-554"><span class="linenos"> 554</span></a> +</span><span id="L-555"><a href="#L-555"><span class="linenos"> 555</span></a> <span class="k">def</span> <span class="nf">columnposition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-556"><a href="#L-556"><span class="linenos"> 556</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-557"><a href="#L-557"><span class="linenos"> 557</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-558"><a href="#L-558"><span class="linenos"> 558</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> +</span><span id="L-559"><a href="#L-559"><span class="linenos"> 559</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">position</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-560"><a href="#L-560"><span class="linenos"> 560</span></a> +</span><span id="L-561"><a href="#L-561"><span class="linenos"> 561</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-562"><a href="#L-562"><span class="linenos"> 562</span></a> <span class="n">column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-563"><a href="#L-563"><span class="linenos"> 563</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="L-564"><a href="#L-564"><span class="linenos"> 564</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"constraints"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-565"><a href="#L-565"><span class="linenos"> 565</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">"IF NOT EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-566"><a href="#L-566"><span class="linenos"> 566</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-567"><a href="#L-567"><span class="linenos"> 567</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">constraints</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">constraints</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-568"><a href="#L-568"><span class="linenos"> 568</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> +</span><span id="L-569"><a href="#L-569"><span class="linenos"> 569</span></a> <span class="n">position</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">position</span> <span class="k">else</span> <span class="s2">""</span> </span><span id="L-570"><a href="#L-570"><span class="linenos"> 570</span></a> -</span><span id="L-571"><a href="#L-571"><span class="linenos"> 571</span></a> <span class="k">def</span> <span class="nf">autoincrementcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-572"><a href="#L-572"><span class="linenos"> 572</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">token_sql</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">)</span> -</span><span id="L-573"><a href="#L-573"><span class="linenos"> 573</span></a> -</span><span id="L-574"><a href="#L-574"><span class="linenos"> 574</span></a> <span class="k">def</span> <span class="nf">compresscolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CompressColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-575"><a href="#L-575"><span class="linenos"> 575</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="L-576"><a href="#L-576"><span class="linenos"> 576</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> -</span><span id="L-577"><a href="#L-577"><span class="linenos"> 577</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-578"><a href="#L-578"><span class="linenos"> 578</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-579"><a href="#L-579"><span class="linenos"> 579</span></a> -</span><span id="L-580"><a href="#L-580"><span class="linenos"> 580</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMPRESS </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-581"><a href="#L-581"><span class="linenos"> 581</span></a> -</span><span id="L-582"><a href="#L-582"><span class="linenos"> 582</span></a> <span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> -</span><span id="L-583"><a href="#L-583"><span class="linenos"> 583</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> -</span><span id="L-584"><a href="#L-584"><span class="linenos"> 584</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-585"><a href="#L-585"><span class="linenos"> 585</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-586"><a href="#L-586"><span class="linenos"> 586</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-587"><a href="#L-587"><span class="linenos"> 587</span></a> <span class="n">on_null</span> <span class="o">=</span> <span class="s2">"ON NULL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on_null"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-588"><a href="#L-588"><span class="linenos"> 588</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" ALWAYS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" BY DEFAULT </span><span class="si">{</span><span class="n">on_null</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-589"><a href="#L-589"><span class="linenos"> 589</span></a> -</span><span id="L-590"><a href="#L-590"><span class="linenos"> 590</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"start"</span><span class="p">)</span> -</span><span id="L-591"><a href="#L-591"><span class="linenos"> 591</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"START WITH </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-592"><a href="#L-592"><span class="linenos"> 592</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"increment"</span><span class="p">)</span> -</span><span id="L-593"><a href="#L-593"><span class="linenos"> 593</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT BY </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-594"><a href="#L-594"><span class="linenos"> 594</span></a> <span class="n">minvalue</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"minvalue"</span><span class="p">)</span> -</span><span id="L-595"><a href="#L-595"><span class="linenos"> 595</span></a> <span class="n">minvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MINVALUE </span><span class="si">{</span><span class="n">minvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">minvalue</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-596"><a href="#L-596"><span class="linenos"> 596</span></a> <span class="n">maxvalue</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"maxvalue"</span><span class="p">)</span> -</span><span id="L-597"><a href="#L-597"><span class="linenos"> 597</span></a> <span class="n">maxvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAXVALUE </span><span class="si">{</span><span class="n">maxvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">maxvalue</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-598"><a href="#L-598"><span class="linenos"> 598</span></a> <span class="n">cycle</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"cycle"</span><span class="p">)</span> -</span><span id="L-599"><a href="#L-599"><span class="linenos"> 599</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-600"><a href="#L-600"><span class="linenos"> 600</span></a> -</span><span id="L-601"><a href="#L-601"><span class="linenos"> 601</span></a> <span class="k">if</span> <span class="n">cycle</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-602"><a href="#L-602"><span class="linenos"> 602</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' NO'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">cycle</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2"> CYCLE"</span> -</span><span id="L-603"><a href="#L-603"><span class="linenos"> 603</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="n">cycle_sql</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">start</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">increment</span> <span class="k">else</span> <span class="n">cycle_sql</span> -</span><span id="L-604"><a href="#L-604"><span class="linenos"> 604</span></a> -</span><span id="L-605"><a href="#L-605"><span class="linenos"> 605</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-606"><a href="#L-606"><span class="linenos"> 606</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">or</span> <span class="n">increment</span> <span class="ow">or</span> <span class="n">cycle_sql</span><span class="p">:</span> -</span><span id="L-607"><a href="#L-607"><span class="linenos"> 607</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}{</span><span class="n">minvalue</span><span class="si">}{</span><span class="n">maxvalue</span><span class="si">}{</span><span class="n">cycle_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-608"><a href="#L-608"><span class="linenos"> 608</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">sequence_opts</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-609"><a href="#L-609"><span class="linenos"> 609</span></a> -</span><span id="L-610"><a href="#L-610"><span class="linenos"> 610</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="L-611"><a href="#L-611"><span class="linenos"> 611</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expr</span> <span class="k">else</span> <span class="s2">"IDENTITY"</span> -</span><span id="L-612"><a href="#L-612"><span class="linenos"> 612</span></a> -</span><span id="L-613"><a href="#L-613"><span class="linenos"> 613</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GENERATED</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">AS </span><span class="si">{</span><span class="n">expr</span><span class="si">}{</span><span class="n">sequence_opts</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-614"><a href="#L-614"><span class="linenos"> 614</span></a> -</span><span id="L-615"><a href="#L-615"><span class="linenos"> 615</span></a> <span class="k">def</span> <span class="nf">notnullcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NotNullColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-616"><a href="#L-616"><span class="linenos"> 616</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">''</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'allow_null'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'NOT '</span><span class="si">}</span><span class="s2">NULL"</span> -</span><span id="L-617"><a href="#L-617"><span class="linenos"> 617</span></a> -</span><span id="L-618"><a href="#L-618"><span class="linenos"> 618</span></a> <span class="k">def</span> <span class="nf">primarykeycolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKeyColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-619"><a href="#L-619"><span class="linenos"> 619</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"desc"</span><span class="p">)</span> -</span><span id="L-620"><a href="#L-620"><span class="linenos"> 620</span></a> <span class="k">if</span> <span class="n">desc</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-621"><a href="#L-621"><span class="linenos"> 621</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY</span><span class="si">{</span><span class="s1">' DESC'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">desc</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ASC'</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-622"><a href="#L-622"><span class="linenos"> 622</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY"</span> -</span><span id="L-623"><a href="#L-623"><span class="linenos"> 623</span></a> -</span><span id="L-624"><a href="#L-624"><span class="linenos"> 624</span></a> <span class="k">def</span> <span class="nf">uniquecolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UniqueColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-625"><a href="#L-625"><span class="linenos"> 625</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-626"><a href="#L-626"><span class="linenos"> 626</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-627"><a href="#L-627"><span class="linenos"> 627</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNIQUE</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-628"><a href="#L-628"><span class="linenos"> 628</span></a> -</span><span id="L-629"><a href="#L-629"><span class="linenos"> 629</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span> -</span><span id="L-630"><a href="#L-630"><span class="linenos"> 630</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="nb">dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">]]</span> -</span><span id="L-631"><a href="#L-631"><span class="linenos"> 631</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-632"><a href="#L-632"><span class="linenos"> 632</span></a> <span class="k">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-633"><a href="#L-633"><span class="linenos"> 633</span></a> -</span><span id="L-634"><a href="#L-634"><span class="linenos"> 634</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-635"><a href="#L-635"><span class="linenos"> 635</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-636"><a href="#L-636"><span class="linenos"> 636</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"properties"</span><span class="p">)</span> -</span><span id="L-637"><a href="#L-637"><span class="linenos"> 637</span></a> <span class="n">properties_locs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">locate_properties</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span> <span class="k">if</span> <span class="n">properties</span> <span class="k">else</span> <span class="p">{}</span> -</span><span id="L-638"><a href="#L-638"><span class="linenos"> 638</span></a> -</span><span id="L-639"><a href="#L-639"><span class="linenos"> 639</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">properties_locs</span><span class="p">)</span> +</span><span id="L-571"><a href="#L-571"><span class="linenos"> 571</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">column</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-572"><a href="#L-572"><span class="linenos"> 572</span></a> +</span><span id="L-573"><a href="#L-573"><span class="linenos"> 573</span></a> <span class="k">def</span> <span class="nf">columnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-574"><a href="#L-574"><span class="linenos"> 574</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-575"><a href="#L-575"><span class="linenos"> 575</span></a> <span class="n">kind_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="L-576"><a href="#L-576"><span class="linenos"> 576</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="n">kind_sql</span> +</span><span id="L-577"><a href="#L-577"><span class="linenos"> 577</span></a> +</span><span id="L-578"><a href="#L-578"><span class="linenos"> 578</span></a> <span class="k">def</span> <span class="nf">autoincrementcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-579"><a href="#L-579"><span class="linenos"> 579</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">token_sql</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">)</span> +</span><span id="L-580"><a href="#L-580"><span class="linenos"> 580</span></a> +</span><span id="L-581"><a href="#L-581"><span class="linenos"> 581</span></a> <span class="k">def</span> <span class="nf">compresscolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CompressColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-582"><a href="#L-582"><span class="linenos"> 582</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="L-583"><a href="#L-583"><span class="linenos"> 583</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="L-584"><a href="#L-584"><span class="linenos"> 584</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-585"><a href="#L-585"><span class="linenos"> 585</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-586"><a href="#L-586"><span class="linenos"> 586</span></a> +</span><span id="L-587"><a href="#L-587"><span class="linenos"> 587</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMPRESS </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-588"><a href="#L-588"><span class="linenos"> 588</span></a> +</span><span id="L-589"><a href="#L-589"><span class="linenos"> 589</span></a> <span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> +</span><span id="L-590"><a href="#L-590"><span class="linenos"> 590</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> +</span><span id="L-591"><a href="#L-591"><span class="linenos"> 591</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-592"><a href="#L-592"><span class="linenos"> 592</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-593"><a href="#L-593"><span class="linenos"> 593</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-594"><a href="#L-594"><span class="linenos"> 594</span></a> <span class="n">on_null</span> <span class="o">=</span> <span class="s2">"ON NULL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on_null"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-595"><a href="#L-595"><span class="linenos"> 595</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" ALWAYS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" BY DEFAULT </span><span class="si">{</span><span class="n">on_null</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-596"><a href="#L-596"><span class="linenos"> 596</span></a> +</span><span id="L-597"><a href="#L-597"><span class="linenos"> 597</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"start"</span><span class="p">)</span> +</span><span id="L-598"><a href="#L-598"><span class="linenos"> 598</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"START WITH </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-599"><a href="#L-599"><span class="linenos"> 599</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"increment"</span><span class="p">)</span> +</span><span id="L-600"><a href="#L-600"><span class="linenos"> 600</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT BY </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-601"><a href="#L-601"><span class="linenos"> 601</span></a> <span class="n">minvalue</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"minvalue"</span><span class="p">)</span> +</span><span id="L-602"><a href="#L-602"><span class="linenos"> 602</span></a> <span class="n">minvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MINVALUE </span><span class="si">{</span><span class="n">minvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">minvalue</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-603"><a href="#L-603"><span class="linenos"> 603</span></a> <span class="n">maxvalue</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"maxvalue"</span><span class="p">)</span> +</span><span id="L-604"><a href="#L-604"><span class="linenos"> 604</span></a> <span class="n">maxvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAXVALUE </span><span class="si">{</span><span class="n">maxvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">maxvalue</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-605"><a href="#L-605"><span class="linenos"> 605</span></a> <span class="n">cycle</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"cycle"</span><span class="p">)</span> +</span><span id="L-606"><a href="#L-606"><span class="linenos"> 606</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-607"><a href="#L-607"><span class="linenos"> 607</span></a> +</span><span id="L-608"><a href="#L-608"><span class="linenos"> 608</span></a> <span class="k">if</span> <span class="n">cycle</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-609"><a href="#L-609"><span class="linenos"> 609</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' NO'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">cycle</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2"> CYCLE"</span> +</span><span id="L-610"><a href="#L-610"><span class="linenos"> 610</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="n">cycle_sql</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">start</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">increment</span> <span class="k">else</span> <span class="n">cycle_sql</span> +</span><span id="L-611"><a href="#L-611"><span class="linenos"> 611</span></a> +</span><span id="L-612"><a href="#L-612"><span class="linenos"> 612</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-613"><a href="#L-613"><span class="linenos"> 613</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">or</span> <span class="n">increment</span> <span class="ow">or</span> <span class="n">cycle_sql</span><span class="p">:</span> +</span><span id="L-614"><a href="#L-614"><span class="linenos"> 614</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}{</span><span class="n">minvalue</span><span class="si">}{</span><span class="n">maxvalue</span><span class="si">}{</span><span class="n">cycle_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-615"><a href="#L-615"><span class="linenos"> 615</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">sequence_opts</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-616"><a href="#L-616"><span class="linenos"> 616</span></a> +</span><span id="L-617"><a href="#L-617"><span class="linenos"> 617</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="L-618"><a href="#L-618"><span class="linenos"> 618</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expr</span> <span class="k">else</span> <span class="s2">"IDENTITY"</span> +</span><span id="L-619"><a href="#L-619"><span class="linenos"> 619</span></a> +</span><span id="L-620"><a href="#L-620"><span class="linenos"> 620</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GENERATED</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">AS </span><span class="si">{</span><span class="n">expr</span><span class="si">}{</span><span class="n">sequence_opts</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-621"><a href="#L-621"><span class="linenos"> 621</span></a> +</span><span id="L-622"><a href="#L-622"><span class="linenos"> 622</span></a> <span class="k">def</span> <span class="nf">notnullcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NotNullColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-623"><a href="#L-623"><span class="linenos"> 623</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">''</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'allow_null'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'NOT '</span><span class="si">}</span><span class="s2">NULL"</span> +</span><span id="L-624"><a href="#L-624"><span class="linenos"> 624</span></a> +</span><span id="L-625"><a href="#L-625"><span class="linenos"> 625</span></a> <span class="k">def</span> <span class="nf">primarykeycolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKeyColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-626"><a href="#L-626"><span class="linenos"> 626</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"desc"</span><span class="p">)</span> +</span><span id="L-627"><a href="#L-627"><span class="linenos"> 627</span></a> <span class="k">if</span> <span class="n">desc</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-628"><a href="#L-628"><span class="linenos"> 628</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY</span><span class="si">{</span><span class="s1">' DESC'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">desc</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ASC'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-629"><a href="#L-629"><span class="linenos"> 629</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY"</span> +</span><span id="L-630"><a href="#L-630"><span class="linenos"> 630</span></a> +</span><span id="L-631"><a href="#L-631"><span class="linenos"> 631</span></a> <span class="k">def</span> <span class="nf">uniquecolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UniqueColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-632"><a href="#L-632"><span class="linenos"> 632</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-633"><a href="#L-633"><span class="linenos"> 633</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-634"><a href="#L-634"><span class="linenos"> 634</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNIQUE</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-635"><a href="#L-635"><span class="linenos"> 635</span></a> +</span><span id="L-636"><a href="#L-636"><span class="linenos"> 636</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span> +</span><span id="L-637"><a href="#L-637"><span class="linenos"> 637</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="nb">dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">]]</span> +</span><span id="L-638"><a href="#L-638"><span class="linenos"> 638</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-639"><a href="#L-639"><span class="linenos"> 639</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-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="n">properties_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-642"><a href="#L-642"><span class="linenos"> 642</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">)</span> <span class="ow">or</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> -</span><span id="L-643"><a href="#L-643"><span class="linenos"> 643</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span> -</span><span id="L-644"><a href="#L-644"><span class="linenos"> 644</span></a> <span class="p">):</span> -</span><span id="L-645"><a href="#L-645"><span class="linenos"> 645</span></a> <span class="n">properties_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="L-646"><a href="#L-646"><span class="linenos"> 646</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> -</span><span id="L-647"><a href="#L-647"><span class="linenos"> 647</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> -</span><span id="L-648"><a href="#L-648"><span class="linenos"> 648</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">],</span> -</span><span id="L-649"><a href="#L-649"><span class="linenos"> 649</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">],</span> -</span><span id="L-650"><a href="#L-650"><span class="linenos"> 650</span></a> <span class="p">]</span> -</span><span id="L-651"><a href="#L-651"><span class="linenos"> 651</span></a> <span class="p">)</span> -</span><span id="L-652"><a href="#L-652"><span class="linenos"> 652</span></a> <span class="p">)</span> -</span><span id="L-653"><a href="#L-653"><span class="linenos"> 653</span></a> -</span><span id="L-654"><a href="#L-654"><span class="linenos"> 654</span></a> <span class="n">begin</span> <span class="o">=</span> <span class="s2">" BEGIN"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"begin"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-655"><a href="#L-655"><span class="linenos"> 655</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-656"><a href="#L-656"><span class="linenos"> 656</span></a> <span class="k">if</span> <span class="n">expression_sql</span><span class="p">:</span> -</span><span id="L-657"><a href="#L-657"><span class="linenos"> 657</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">begin</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-658"><a href="#L-658"><span class="linenos"> 658</span></a> -</span><span id="L-659"><a href="#L-659"><span class="linenos"> 659</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CREATE_FUNCTION_RETURN_AS</span> <span class="ow">or</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Return</span><span class="p">):</span> -</span><span id="L-660"><a href="#L-660"><span class="linenos"> 660</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">):</span> -</span><span id="L-661"><a href="#L-661"><span class="linenos"> 661</span></a> <span class="n">postalias_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="L-662"><a href="#L-662"><span class="linenos"> 662</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> -</span><span id="L-663"><a href="#L-663"><span class="linenos"> 663</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">]</span> -</span><span id="L-664"><a href="#L-664"><span class="linenos"> 664</span></a> <span class="p">),</span> -</span><span id="L-665"><a href="#L-665"><span class="linenos"> 665</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="L-666"><a href="#L-666"><span class="linenos"> 666</span></a> <span class="p">)</span> -</span><span id="L-667"><a href="#L-667"><span class="linenos"> 667</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">postalias_props_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-668"><a href="#L-668"><span class="linenos"> 668</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-669"><a href="#L-669"><span class="linenos"> 669</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-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="n">postindex_props_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-672"><a href="#L-672"><span class="linenos"> 672</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">):</span> -</span><span id="L-673"><a href="#L-673"><span class="linenos"> 673</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="L-674"><a href="#L-674"><span class="linenos"> 674</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">]),</span> -</span><span id="L-675"><a href="#L-675"><span class="linenos"> 675</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="L-676"><a href="#L-676"><span class="linenos"> 676</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="L-677"><a href="#L-677"><span class="linenos"> 677</span></a> <span class="p">)</span> -</span><span id="L-678"><a href="#L-678"><span class="linenos"> 678</span></a> -</span><span id="L-679"><a href="#L-679"><span class="linenos"> 679</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"indexes"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="L-680"><a href="#L-680"><span class="linenos"> 680</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">indexes</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">indexes</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-681"><a href="#L-681"><span class="linenos"> 681</span></a> <span class="n">index_sql</span> <span class="o">=</span> <span class="n">indexes</span> <span class="o">+</span> <span class="n">postindex_props_sql</span> -</span><span id="L-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">replace</span> <span class="o">=</span> <span class="s2">" OR REPLACE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"replace"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-684"><a href="#L-684"><span class="linenos"> 684</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">" UNIQUE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-641"><a href="#L-641"><span class="linenos"> 641</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-642"><a href="#L-642"><span class="linenos"> 642</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-643"><a href="#L-643"><span class="linenos"> 643</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"properties"</span><span class="p">)</span> +</span><span id="L-644"><a href="#L-644"><span class="linenos"> 644</span></a> <span class="n">properties_locs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">locate_properties</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span> <span class="k">if</span> <span class="n">properties</span> <span class="k">else</span> <span class="p">{}</span> +</span><span id="L-645"><a href="#L-645"><span class="linenos"> 645</span></a> +</span><span id="L-646"><a href="#L-646"><span class="linenos"> 646</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">properties_locs</span><span class="p">)</span> +</span><span id="L-647"><a href="#L-647"><span class="linenos"> 647</span></a> +</span><span id="L-648"><a href="#L-648"><span class="linenos"> 648</span></a> <span class="n">properties_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-649"><a href="#L-649"><span class="linenos"> 649</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">)</span> <span class="ow">or</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> +</span><span id="L-650"><a href="#L-650"><span class="linenos"> 650</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span> +</span><span id="L-651"><a href="#L-651"><span class="linenos"> 651</span></a> <span class="p">):</span> +</span><span id="L-652"><a href="#L-652"><span class="linenos"> 652</span></a> <span class="n">properties_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="L-653"><a href="#L-653"><span class="linenos"> 653</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> +</span><span id="L-654"><a href="#L-654"><span class="linenos"> 654</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> +</span><span id="L-655"><a href="#L-655"><span class="linenos"> 655</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">],</span> +</span><span id="L-656"><a href="#L-656"><span class="linenos"> 656</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">],</span> +</span><span id="L-657"><a href="#L-657"><span class="linenos"> 657</span></a> <span class="p">]</span> +</span><span id="L-658"><a href="#L-658"><span class="linenos"> 658</span></a> <span class="p">)</span> +</span><span id="L-659"><a href="#L-659"><span class="linenos"> 659</span></a> <span class="p">)</span> +</span><span id="L-660"><a href="#L-660"><span class="linenos"> 660</span></a> +</span><span id="L-661"><a href="#L-661"><span class="linenos"> 661</span></a> <span class="n">begin</span> <span class="o">=</span> <span class="s2">" BEGIN"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"begin"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-662"><a href="#L-662"><span class="linenos"> 662</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-663"><a href="#L-663"><span class="linenos"> 663</span></a> <span class="k">if</span> <span class="n">expression_sql</span><span class="p">:</span> +</span><span id="L-664"><a href="#L-664"><span class="linenos"> 664</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">begin</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-665"><a href="#L-665"><span class="linenos"> 665</span></a> +</span><span id="L-666"><a href="#L-666"><span class="linenos"> 666</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CREATE_FUNCTION_RETURN_AS</span> <span class="ow">or</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Return</span><span class="p">):</span> +</span><span id="L-667"><a href="#L-667"><span class="linenos"> 667</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">):</span> +</span><span id="L-668"><a href="#L-668"><span class="linenos"> 668</span></a> <span class="n">postalias_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="L-669"><a href="#L-669"><span class="linenos"> 669</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> +</span><span id="L-670"><a href="#L-670"><span class="linenos"> 670</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">]</span> +</span><span id="L-671"><a href="#L-671"><span class="linenos"> 671</span></a> <span class="p">),</span> +</span><span id="L-672"><a href="#L-672"><span class="linenos"> 672</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="L-673"><a href="#L-673"><span class="linenos"> 673</span></a> <span class="p">)</span> +</span><span id="L-674"><a href="#L-674"><span class="linenos"> 674</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">postalias_props_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-675"><a href="#L-675"><span class="linenos"> 675</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-676"><a href="#L-676"><span class="linenos"> 676</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-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="n">postindex_props_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-679"><a href="#L-679"><span class="linenos"> 679</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">):</span> +</span><span id="L-680"><a href="#L-680"><span class="linenos"> 680</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="L-681"><a href="#L-681"><span class="linenos"> 681</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">]),</span> +</span><span id="L-682"><a href="#L-682"><span class="linenos"> 682</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="L-683"><a href="#L-683"><span class="linenos"> 683</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="L-684"><a href="#L-684"><span class="linenos"> 684</span></a> <span class="p">)</span> </span><span id="L-685"><a href="#L-685"><span class="linenos"> 685</span></a> -</span><span id="L-686"><a href="#L-686"><span class="linenos"> 686</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-687"><a href="#L-687"><span class="linenos"> 687</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">):</span> -</span><span id="L-688"><a href="#L-688"><span class="linenos"> 688</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="L-689"><a href="#L-689"><span class="linenos"> 689</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">]),</span> -</span><span id="L-690"><a href="#L-690"><span class="linenos"> 690</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="L-691"><a href="#L-691"><span class="linenos"> 691</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="L-692"><a href="#L-692"><span class="linenos"> 692</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="L-693"><a href="#L-693"><span class="linenos"> 693</span></a> <span class="p">)</span> -</span><span id="L-694"><a href="#L-694"><span class="linenos"> 694</span></a> -</span><span id="L-695"><a href="#L-695"><span class="linenos"> 695</span></a> <span class="n">modifiers</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">replace</span><span class="p">,</span> <span class="n">unique</span><span class="p">,</span> <span class="n">postcreate_props_sql</span><span class="p">))</span> -</span><span id="L-696"><a href="#L-696"><span class="linenos"> 696</span></a> -</span><span id="L-697"><a href="#L-697"><span class="linenos"> 697</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-698"><a href="#L-698"><span class="linenos"> 698</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">):</span> -</span><span id="L-699"><a href="#L-699"><span class="linenos"> 699</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="L-700"><a href="#L-700"><span class="linenos"> 700</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> -</span><span id="L-701"><a href="#L-701"><span class="linenos"> 701</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">]</span> -</span><span id="L-702"><a href="#L-702"><span class="linenos"> 702</span></a> <span class="p">),</span> -</span><span id="L-703"><a href="#L-703"><span class="linenos"> 703</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="L-704"><a href="#L-704"><span class="linenos"> 704</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="L-705"><a href="#L-705"><span class="linenos"> 705</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</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><span id="L-708"><a href="#L-708"><span class="linenos"> 708</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF NOT EXISTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-709"><a href="#L-709"><span class="linenos"> 709</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-710"><a href="#L-710"><span class="linenos"> 710</span></a> <span class="s2">" WITH NO SCHEMA BINDING"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no_schema_binding"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-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="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"clone"</span><span class="p">)</span> -</span><span id="L-714"><a href="#L-714"><span class="linenos"> 714</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">clone</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-715"><a href="#L-715"><span class="linenos"> 715</span></a> -</span><span id="L-716"><a href="#L-716"><span class="linenos"> 716</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CREATE</span><span class="si">{</span><span class="n">modifiers</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">properties_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">postexpression_props_sql</span><span class="si">}{</span><span class="n">index_sql</span><span class="si">}{</span><span class="n">no_schema_binding</span><span class="si">}{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-717"><a href="#L-717"><span class="linenos"> 717</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">expression_sql</span><span class="p">)</span> -</span><span id="L-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">clone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Clone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-720"><a href="#L-720"><span class="linenos"> 720</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-721"><a href="#L-721"><span class="linenos"> 721</span></a> <span class="n">when</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"when"</span><span class="p">)</span> +</span><span id="L-686"><a href="#L-686"><span class="linenos"> 686</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"indexes"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="L-687"><a href="#L-687"><span class="linenos"> 687</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">indexes</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">indexes</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-688"><a href="#L-688"><span class="linenos"> 688</span></a> <span class="n">index_sql</span> <span class="o">=</span> <span class="n">indexes</span> <span class="o">+</span> <span class="n">postindex_props_sql</span> +</span><span id="L-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="n">replace</span> <span class="o">=</span> <span class="s2">" OR REPLACE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"replace"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-691"><a href="#L-691"><span class="linenos"> 691</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">" UNIQUE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-692"><a href="#L-692"><span class="linenos"> 692</span></a> +</span><span id="L-693"><a href="#L-693"><span class="linenos"> 693</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-694"><a href="#L-694"><span class="linenos"> 694</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">):</span> +</span><span id="L-695"><a href="#L-695"><span class="linenos"> 695</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="L-696"><a href="#L-696"><span class="linenos"> 696</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">]),</span> +</span><span id="L-697"><a href="#L-697"><span class="linenos"> 697</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="L-698"><a href="#L-698"><span class="linenos"> 698</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="L-699"><a href="#L-699"><span class="linenos"> 699</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="L-700"><a href="#L-700"><span class="linenos"> 700</span></a> <span class="p">)</span> +</span><span id="L-701"><a href="#L-701"><span class="linenos"> 701</span></a> +</span><span id="L-702"><a href="#L-702"><span class="linenos"> 702</span></a> <span class="n">modifiers</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">replace</span><span class="p">,</span> <span class="n">unique</span><span class="p">,</span> <span class="n">postcreate_props_sql</span><span class="p">))</span> +</span><span id="L-703"><a href="#L-703"><span class="linenos"> 703</span></a> +</span><span id="L-704"><a href="#L-704"><span class="linenos"> 704</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-705"><a href="#L-705"><span class="linenos"> 705</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">):</span> +</span><span id="L-706"><a href="#L-706"><span class="linenos"> 706</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="L-707"><a href="#L-707"><span class="linenos"> 707</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> +</span><span id="L-708"><a href="#L-708"><span class="linenos"> 708</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">]</span> +</span><span id="L-709"><a href="#L-709"><span class="linenos"> 709</span></a> <span class="p">),</span> +</span><span id="L-710"><a href="#L-710"><span class="linenos"> 710</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="L-711"><a href="#L-711"><span class="linenos"> 711</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="L-712"><a href="#L-712"><span class="linenos"> 712</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="L-713"><a href="#L-713"><span class="linenos"> 713</span></a> <span class="p">)</span> +</span><span id="L-714"><a href="#L-714"><span class="linenos"> 714</span></a> +</span><span id="L-715"><a href="#L-715"><span class="linenos"> 715</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF NOT EXISTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-716"><a href="#L-716"><span class="linenos"> 716</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-717"><a href="#L-717"><span class="linenos"> 717</span></a> <span class="s2">" WITH NO SCHEMA BINDING"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no_schema_binding"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-718"><a href="#L-718"><span class="linenos"> 718</span></a> <span class="p">)</span> +</span><span id="L-719"><a href="#L-719"><span class="linenos"> 719</span></a> +</span><span id="L-720"><a href="#L-720"><span class="linenos"> 720</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"clone"</span><span class="p">)</span> +</span><span id="L-721"><a href="#L-721"><span class="linenos"> 721</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">clone</span> <span class="k">else</span> <span class="s2">""</span> </span><span id="L-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">when</span><span class="p">:</span> -</span><span id="L-724"><a href="#L-724"><span class="linenos"> 724</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="L-725"><a href="#L-725"><span class="linenos"> 725</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="L-726"><a href="#L-726"><span class="linenos"> 726</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CLONE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">when</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> => </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-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">return</span> <span class="sa">f</span><span class="s2">"CLONE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-723"><a href="#L-723"><span class="linenos"> 723</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CREATE</span><span class="si">{</span><span class="n">modifiers</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">properties_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">postexpression_props_sql</span><span class="si">}{</span><span class="n">index_sql</span><span class="si">}{</span><span class="n">no_schema_binding</span><span class="si">}{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-724"><a href="#L-724"><span class="linenos"> 724</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">expression_sql</span><span class="p">)</span> +</span><span id="L-725"><a href="#L-725"><span class="linenos"> 725</span></a> +</span><span id="L-726"><a href="#L-726"><span class="linenos"> 726</span></a> <span class="k">def</span> <span class="nf">clone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Clone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-727"><a href="#L-727"><span class="linenos"> 727</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-728"><a href="#L-728"><span class="linenos"> 728</span></a> <span class="n">when</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"when"</span><span class="p">)</span> </span><span id="L-729"><a href="#L-729"><span class="linenos"> 729</span></a> -</span><span id="L-730"><a href="#L-730"><span class="linenos"> 730</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-731"><a href="#L-731"><span class="linenos"> 731</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-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">prepend_ctes</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-734"><a href="#L-734"><span class="linenos"> 734</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"with"</span><span class="p">)</span> -</span><span id="L-735"><a href="#L-735"><span class="linenos"> 735</span></a> <span class="k">if</span> <span class="n">with_</span><span class="p">:</span> -</span><span id="L-736"><a href="#L-736"><span class="linenos"> 736</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">with_</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-737"><a href="#L-737"><span class="linenos"> 737</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="L-738"><a href="#L-738"><span class="linenos"> 738</span></a> -</span><span id="L-739"><a href="#L-739"><span class="linenos"> 739</span></a> <span class="k">def</span> <span class="nf">with_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-740"><a href="#L-740"><span class="linenos"> 740</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-741"><a href="#L-741"><span class="linenos"> 741</span></a> <span class="n">recursive</span> <span class="o">=</span> <span class="s2">"RECURSIVE "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"recursive"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-742"><a href="#L-742"><span class="linenos"> 742</span></a> -</span><span id="L-743"><a href="#L-743"><span class="linenos"> 743</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="n">recursive</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-744"><a href="#L-744"><span class="linenos"> 744</span></a> -</span><span id="L-745"><a href="#L-745"><span class="linenos"> 745</span></a> <span class="k">def</span> <span class="nf">cte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-746"><a href="#L-746"><span class="linenos"> 746</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="L-747"><a href="#L-747"><span class="linenos"> 747</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-748"><a href="#L-748"><span class="linenos"> 748</span></a> -</span><span id="L-749"><a href="#L-749"><span class="linenos"> 749</span></a> <span class="k">def</span> <span class="nf">tablealias_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableAlias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-750"><a href="#L-750"><span class="linenos"> 750</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-751"><a href="#L-751"><span class="linenos"> 751</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-752"><a href="#L-752"><span class="linenos"> 752</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-753"><a href="#L-753"><span class="linenos"> 753</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-754"><a href="#L-754"><span class="linenos"> 754</span></a> -</span><span id="L-755"><a href="#L-755"><span class="linenos"> 755</span></a> <span class="k">def</span> <span class="nf">bitstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-756"><a href="#L-756"><span class="linenos"> 756</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-757"><a href="#L-757"><span class="linenos"> 757</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">BIT_START</span><span class="p">:</span> -</span><span id="L-758"><a href="#L-758"><span class="linenos"> 758</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">BIT_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">BIT_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-759"><a href="#L-759"><span class="linenos"> 759</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-760"><a href="#L-760"><span class="linenos"> 760</span></a> -</span><span id="L-761"><a href="#L-761"><span class="linenos"> 761</span></a> <span class="k">def</span> <span class="nf">hexstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">HexString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-762"><a href="#L-762"><span class="linenos"> 762</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-763"><a href="#L-763"><span class="linenos"> 763</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HEX_START</span><span class="p">:</span> -</span><span id="L-764"><a href="#L-764"><span class="linenos"> 764</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">HEX_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">HEX_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-765"><a href="#L-765"><span class="linenos"> 765</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">16</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-766"><a href="#L-766"><span class="linenos"> 766</span></a> -</span><span id="L-767"><a href="#L-767"><span class="linenos"> 767</span></a> <span class="k">def</span> <span class="nf">bytestring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ByteString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-768"><a href="#L-768"><span class="linenos"> 768</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-769"><a href="#L-769"><span class="linenos"> 769</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">BYTE_START</span><span class="p">:</span> -</span><span id="L-770"><a href="#L-770"><span class="linenos"> 770</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">BYTE_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">BYTE_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-771"><a href="#L-771"><span class="linenos"> 771</span></a> <span class="k">return</span> <span class="n">this</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="k">def</span> <span class="nf">rawstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RawString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-774"><a href="#L-774"><span class="linenos"> 774</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RAW_START</span><span class="p">:</span> -</span><span id="L-775"><a href="#L-775"><span class="linenos"> 775</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">RAW_START</span><span class="si">}{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">RAW_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-776"><a href="#L-776"><span class="linenos"> 776</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">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"</span><span class="se">\\\\</span><span class="s2">"</span><span class="p">)))</span> -</span><span id="L-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="k">def</span> <span class="nf">datatypesize_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataTypeSize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-779"><a href="#L-779"><span class="linenos"> 779</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-780"><a href="#L-780"><span class="linenos"> 780</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="L-781"><a href="#L-781"><span class="linenos"> 781</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">specifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">specifier</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-782"><a href="#L-782"><span class="linenos"> 782</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">specifier</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-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">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-785"><a href="#L-785"><span class="linenos"> 785</span></a> <span class="n">type_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-786"><a href="#L-786"><span class="linenos"> 786</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">type_value</span><span class="p">,</span> <span class="n">type_value</span><span class="o">.</span><span class="n">value</span><span class="p">)</span> -</span><span id="L-787"><a href="#L-787"><span class="linenos"> 787</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-788"><a href="#L-788"><span class="linenos"> 788</span></a> <span class="n">interior</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-789"><a href="#L-789"><span class="linenos"> 789</span></a> <span class="n">values</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-790"><a href="#L-790"><span class="linenos"> 790</span></a> <span class="k">if</span> <span class="n">interior</span><span class="p">:</span> -</span><span id="L-791"><a href="#L-791"><span class="linenos"> 791</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nested"</span><span class="p">):</span> -</span><span id="L-792"><a href="#L-792"><span class="linenos"> 792</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">interior</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-793"><a href="#L-793"><span class="linenos"> 793</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"values"</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-794"><a href="#L-794"><span class="linenos"> 794</span></a> <span class="n">delimiters</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"["</span><span class="p">,</span> <span class="s2">"]"</span><span class="p">)</span> <span class="k">if</span> <span class="n">type_value</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span> <span class="k">else</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> -</span><span id="L-795"><a href="#L-795"><span class="linenos"> 795</span></a> <span class="n">values</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"values"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-796"><a href="#L-796"><span class="linenos"> 796</span></a> <span class="n">values</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">values</span><span class="si">}{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-797"><a href="#L-797"><span class="linenos"> 797</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-798"><a href="#L-798"><span class="linenos"> 798</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">interior</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-799"><a href="#L-799"><span class="linenos"> 799</span></a> -</span><span id="L-800"><a href="#L-800"><span class="linenos"> 800</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}{</span><span class="n">nested</span><span class="si">}{</span><span class="n">values</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-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="k">def</span> <span class="nf">directory_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-803"><a href="#L-803"><span class="linenos"> 803</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">"LOCAL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-804"><a href="#L-804"><span class="linenos"> 804</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"row_format"</span><span class="p">)</span> -</span><span id="L-805"><a href="#L-805"><span class="linenos"> 805</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-806"><a href="#L-806"><span class="linenos"> 806</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2">DIRECTORY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">row_format</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-807"><a href="#L-807"><span class="linenos"> 807</span></a> -</span><span id="L-808"><a href="#L-808"><span class="linenos"> 808</span></a> <span class="k">def</span> <span class="nf">delete_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-809"><a href="#L-809"><span class="linenos"> 809</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-810"><a href="#L-810"><span class="linenos"> 810</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FROM </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-811"><a href="#L-811"><span class="linenos"> 811</span></a> <span class="n">using_sql</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="sa">f</span><span class="s2">" USING </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">'using'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">', USING '</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-813"><a href="#L-813"><span class="linenos"> 813</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">"using"</span><span class="p">)</span> -</span><span id="L-814"><a href="#L-814"><span class="linenos"> 814</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-815"><a href="#L-815"><span class="linenos"> 815</span></a> <span class="p">)</span> -</span><span id="L-816"><a href="#L-816"><span class="linenos"> 816</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> -</span><span id="L-817"><a href="#L-817"><span class="linenos"> 817</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> -</span><span id="L-818"><a href="#L-818"><span class="linenos"> 818</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"DELETE</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">using_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-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">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="L-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">drop_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-822"><a href="#L-822"><span class="linenos"> 822</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-823"><a href="#L-823"><span class="linenos"> 823</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> -</span><span id="L-824"><a href="#L-824"><span class="linenos"> 824</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="L-825"><a href="#L-825"><span class="linenos"> 825</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-826"><a href="#L-826"><span class="linenos"> 826</span></a> <span class="n">materialized</span> <span class="o">=</span> <span class="s2">" MATERIALIZED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"materialized"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-827"><a href="#L-827"><span class="linenos"> 827</span></a> <span class="n">cascade</span> <span class="o">=</span> <span class="s2">" CASCADE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"cascade"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-828"><a href="#L-828"><span class="linenos"> 828</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="s2">" CONSTRAINTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"constraints"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-829"><a href="#L-829"><span class="linenos"> 829</span></a> <span class="n">purge</span> <span class="o">=</span> <span class="s2">" PURGE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"purge"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-830"><a href="#L-830"><span class="linenos"> 830</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="L-831"><a href="#L-831"><span class="linenos"> 831</span></a> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">temporary</span><span class="si">}{</span><span class="n">materialized</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">exists_sql</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">cascade</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">purge</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-832"><a href="#L-832"><span class="linenos"> 832</span></a> <span class="p">)</span> -</span><span id="L-833"><a href="#L-833"><span class="linenos"> 833</span></a> -</span><span id="L-834"><a href="#L-834"><span class="linenos"> 834</span></a> <span class="k">def</span> <span class="nf">except_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-835"><a href="#L-835"><span class="linenos"> 835</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span> -</span><span id="L-836"><a href="#L-836"><span class="linenos"> 836</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="L-837"><a href="#L-837"><span class="linenos"> 837</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> -</span><span id="L-838"><a href="#L-838"><span class="linenos"> 838</span></a> <span class="p">)</span> -</span><span id="L-839"><a href="#L-839"><span class="linenos"> 839</span></a> -</span><span id="L-840"><a href="#L-840"><span class="linenos"> 840</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-841"><a href="#L-841"><span class="linenos"> 841</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">''</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-730"><a href="#L-730"><span class="linenos"> 730</span></a> <span class="k">if</span> <span class="n">when</span><span class="p">:</span> +</span><span id="L-731"><a href="#L-731"><span class="linenos"> 731</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="L-732"><a href="#L-732"><span class="linenos"> 732</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="L-733"><a href="#L-733"><span class="linenos"> 733</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CLONE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">when</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> => </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-734"><a href="#L-734"><span class="linenos"> 734</span></a> +</span><span id="L-735"><a href="#L-735"><span class="linenos"> 735</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CLONE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-736"><a href="#L-736"><span class="linenos"> 736</span></a> +</span><span id="L-737"><a href="#L-737"><span class="linenos"> 737</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-738"><a href="#L-738"><span class="linenos"> 738</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-739"><a href="#L-739"><span class="linenos"> 739</span></a> +</span><span id="L-740"><a href="#L-740"><span class="linenos"> 740</span></a> <span class="k">def</span> <span class="nf">prepend_ctes</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-741"><a href="#L-741"><span class="linenos"> 741</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"with"</span><span class="p">)</span> +</span><span id="L-742"><a href="#L-742"><span class="linenos"> 742</span></a> <span class="k">if</span> <span class="n">with_</span><span class="p">:</span> +</span><span id="L-743"><a href="#L-743"><span class="linenos"> 743</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">with_</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-744"><a href="#L-744"><span class="linenos"> 744</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="L-745"><a href="#L-745"><span class="linenos"> 745</span></a> +</span><span id="L-746"><a href="#L-746"><span class="linenos"> 746</span></a> <span class="k">def</span> <span class="nf">with_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-747"><a href="#L-747"><span class="linenos"> 747</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-748"><a href="#L-748"><span class="linenos"> 748</span></a> <span class="n">recursive</span> <span class="o">=</span> <span class="s2">"RECURSIVE "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"recursive"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</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="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="n">recursive</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-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">cte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-753"><a href="#L-753"><span class="linenos"> 753</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="L-754"><a href="#L-754"><span class="linenos"> 754</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-755"><a href="#L-755"><span class="linenos"> 755</span></a> +</span><span id="L-756"><a href="#L-756"><span class="linenos"> 756</span></a> <span class="k">def</span> <span class="nf">tablealias_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableAlias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-757"><a href="#L-757"><span class="linenos"> 757</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-758"><a href="#L-758"><span class="linenos"> 758</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-759"><a href="#L-759"><span class="linenos"> 759</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-760"><a href="#L-760"><span class="linenos"> 760</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-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="k">def</span> <span class="nf">bitstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-763"><a href="#L-763"><span class="linenos"> 763</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-764"><a href="#L-764"><span class="linenos"> 764</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">BIT_START</span><span class="p">:</span> +</span><span id="L-765"><a href="#L-765"><span class="linenos"> 765</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">BIT_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">BIT_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-766"><a href="#L-766"><span class="linenos"> 766</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-767"><a href="#L-767"><span class="linenos"> 767</span></a> +</span><span id="L-768"><a href="#L-768"><span class="linenos"> 768</span></a> <span class="k">def</span> <span class="nf">hexstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">HexString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-769"><a href="#L-769"><span class="linenos"> 769</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-770"><a href="#L-770"><span class="linenos"> 770</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HEX_START</span><span class="p">:</span> +</span><span id="L-771"><a href="#L-771"><span class="linenos"> 771</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">HEX_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">HEX_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-772"><a href="#L-772"><span class="linenos"> 772</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">16</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-773"><a href="#L-773"><span class="linenos"> 773</span></a> +</span><span id="L-774"><a href="#L-774"><span class="linenos"> 774</span></a> <span class="k">def</span> <span class="nf">bytestring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ByteString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-775"><a href="#L-775"><span class="linenos"> 775</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-776"><a href="#L-776"><span class="linenos"> 776</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">BYTE_START</span><span class="p">:</span> +</span><span id="L-777"><a href="#L-777"><span class="linenos"> 777</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">BYTE_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">BYTE_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-778"><a href="#L-778"><span class="linenos"> 778</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-779"><a href="#L-779"><span class="linenos"> 779</span></a> +</span><span id="L-780"><a href="#L-780"><span class="linenos"> 780</span></a> <span class="k">def</span> <span class="nf">rawstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RawString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-781"><a href="#L-781"><span class="linenos"> 781</span></a> <span class="n">string</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-782"><a href="#L-782"><span class="linenos"> 782</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RAW_START</span><span class="p">:</span> +</span><span id="L-783"><a href="#L-783"><span class="linenos"> 783</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">RAW_START</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">RAW_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-784"><a href="#L-784"><span class="linenos"> 784</span></a> <span class="n">string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">string</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"</span><span class="se">\\\\</span><span class="s2">"</span><span class="p">))</span> +</span><span id="L-785"><a href="#L-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="bp">self</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="n">string</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</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="k">def</span> <span class="nf">datatypesize_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataTypeSize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-788"><a href="#L-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><span id="L-789"><a href="#L-789"><span class="linenos"> 789</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="L-790"><a href="#L-790"><span class="linenos"> 790</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">specifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">specifier</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-791"><a href="#L-791"><span class="linenos"> 791</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">specifier</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-792"><a href="#L-792"><span class="linenos"> 792</span></a> +</span><span id="L-793"><a href="#L-793"><span class="linenos"> 793</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-794"><a href="#L-794"><span class="linenos"> 794</span></a> <span class="n">type_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-795"><a href="#L-795"><span class="linenos"> 795</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">type_value</span><span class="p">,</span> <span class="n">type_value</span><span class="o">.</span><span class="n">value</span><span class="p">)</span> +</span><span id="L-796"><a href="#L-796"><span class="linenos"> 796</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-797"><a href="#L-797"><span class="linenos"> 797</span></a> <span class="n">interior</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-798"><a href="#L-798"><span class="linenos"> 798</span></a> <span class="n">values</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-799"><a href="#L-799"><span class="linenos"> 799</span></a> <span class="k">if</span> <span class="n">interior</span><span class="p">:</span> +</span><span id="L-800"><a href="#L-800"><span class="linenos"> 800</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nested"</span><span class="p">):</span> +</span><span id="L-801"><a href="#L-801"><span class="linenos"> 801</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">interior</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-802"><a href="#L-802"><span class="linenos"> 802</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"values"</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-803"><a href="#L-803"><span class="linenos"> 803</span></a> <span class="n">delimiters</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"["</span><span class="p">,</span> <span class="s2">"]"</span><span class="p">)</span> <span class="k">if</span> <span class="n">type_value</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span> <span class="k">else</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> +</span><span id="L-804"><a href="#L-804"><span class="linenos"> 804</span></a> <span class="n">values</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"values"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-805"><a href="#L-805"><span class="linenos"> 805</span></a> <span class="n">values</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">values</span><span class="si">}{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-806"><a href="#L-806"><span class="linenos"> 806</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-807"><a href="#L-807"><span class="linenos"> 807</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">interior</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-808"><a href="#L-808"><span class="linenos"> 808</span></a> +</span><span id="L-809"><a href="#L-809"><span class="linenos"> 809</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}{</span><span class="n">nested</span><span class="si">}{</span><span class="n">values</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-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="k">def</span> <span class="nf">directory_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-812"><a href="#L-812"><span class="linenos"> 812</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">"LOCAL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-813"><a href="#L-813"><span class="linenos"> 813</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"row_format"</span><span class="p">)</span> +</span><span id="L-814"><a href="#L-814"><span class="linenos"> 814</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-815"><a href="#L-815"><span class="linenos"> 815</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2">DIRECTORY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">row_format</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-816"><a href="#L-816"><span class="linenos"> 816</span></a> +</span><span id="L-817"><a href="#L-817"><span class="linenos"> 817</span></a> <span class="k">def</span> <span class="nf">delete_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-818"><a href="#L-818"><span class="linenos"> 818</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-819"><a href="#L-819"><span class="linenos"> 819</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FROM </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-820"><a href="#L-820"><span class="linenos"> 820</span></a> <span class="n">using_sql</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-821"><a href="#L-821"><span class="linenos"> 821</span></a> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">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">'using'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">', USING '</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-822"><a href="#L-822"><span class="linenos"> 822</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">"using"</span><span class="p">)</span> +</span><span id="L-823"><a href="#L-823"><span class="linenos"> 823</span></a> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-824"><a href="#L-824"><span class="linenos"> 824</span></a> <span class="p">)</span> +</span><span id="L-825"><a href="#L-825"><span class="linenos"> 825</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> +</span><span id="L-826"><a href="#L-826"><span class="linenos"> 826</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="L-827"><a href="#L-827"><span class="linenos"> 827</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"DELETE</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">using_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-828"><a href="#L-828"><span class="linenos"> 828</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="L-829"><a href="#L-829"><span class="linenos"> 829</span></a> +</span><span id="L-830"><a href="#L-830"><span class="linenos"> 830</span></a> <span class="k">def</span> <span class="nf">drop_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-831"><a href="#L-831"><span class="linenos"> 831</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-832"><a href="#L-832"><span class="linenos"> 832</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> +</span><span id="L-833"><a href="#L-833"><span class="linenos"> 833</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="L-834"><a href="#L-834"><span class="linenos"> 834</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-835"><a href="#L-835"><span class="linenos"> 835</span></a> <span class="n">materialized</span> <span class="o">=</span> <span class="s2">" MATERIALIZED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"materialized"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-836"><a href="#L-836"><span class="linenos"> 836</span></a> <span class="n">cascade</span> <span class="o">=</span> <span class="s2">" CASCADE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"cascade"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-837"><a href="#L-837"><span class="linenos"> 837</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="s2">" CONSTRAINTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"constraints"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-838"><a href="#L-838"><span class="linenos"> 838</span></a> <span class="n">purge</span> <span class="o">=</span> <span class="s2">" PURGE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"purge"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-839"><a href="#L-839"><span class="linenos"> 839</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="L-840"><a href="#L-840"><span class="linenos"> 840</span></a> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">temporary</span><span class="si">}{</span><span class="n">materialized</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">exists_sql</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">cascade</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">purge</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-841"><a href="#L-841"><span class="linenos"> 841</span></a> <span class="p">)</span> </span><span id="L-842"><a href="#L-842"><span class="linenos"> 842</span></a> -</span><span id="L-843"><a href="#L-843"><span class="linenos"> 843</span></a> <span class="k">def</span> <span class="nf">fetch_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-844"><a href="#L-844"><span class="linenos"> 844</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"direction"</span><span class="p">)</span> -</span><span id="L-845"><a href="#L-845"><span class="linenos"> 845</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">direction</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">direction</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-846"><a href="#L-846"><span class="linenos"> 846</span></a> <span class="n">count</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"count"</span><span class="p">)</span> -</span><span id="L-847"><a href="#L-847"><span class="linenos"> 847</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">count</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-848"><a href="#L-848"><span class="linenos"> 848</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"percent"</span><span class="p">):</span> -</span><span id="L-849"><a href="#L-849"><span class="linenos"> 849</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2"> PERCENT"</span> -</span><span id="L-850"><a href="#L-850"><span class="linenos"> 850</span></a> <span class="n">with_ties_or_only</span> <span class="o">=</span> <span class="s2">"WITH TIES"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"with_ties"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ONLY"</span> -</span><span id="L-851"><a href="#L-851"><span class="linenos"> 851</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'FETCH'</span><span class="p">)</span><span class="si">}{</span><span class="n">direction</span><span class="si">}{</span><span class="n">count</span><span class="si">}</span><span class="s2"> ROWS </span><span class="si">{</span><span class="n">with_ties_or_only</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-852"><a href="#L-852"><span class="linenos"> 852</span></a> -</span><span id="L-853"><a href="#L-853"><span class="linenos"> 853</span></a> <span class="k">def</span> <span class="nf">filter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Filter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-854"><a href="#L-854"><span class="linenos"> 854</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-855"><a href="#L-855"><span class="linenos"> 855</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)[</span><span class="mi">1</span><span class="p">:]</span> <span class="c1"># where has a leading space</span> -</span><span id="L-856"><a href="#L-856"><span class="linenos"> 856</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FILTER(</span><span class="si">{</span><span class="n">where</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-857"><a href="#L-857"><span class="linenos"> 857</span></a> -</span><span id="L-858"><a href="#L-858"><span class="linenos"> 858</span></a> <span class="k">def</span> <span class="nf">hint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-859"><a href="#L-859"><span class="linenos"> 859</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">):</span> -</span><span id="L-860"><a href="#L-860"><span class="linenos"> 860</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Hints are not supported"</span><span class="p">)</span> -</span><span id="L-861"><a href="#L-861"><span class="linenos"> 861</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="L-862"><a href="#L-862"><span class="linenos"> 862</span></a> -</span><span id="L-863"><a href="#L-863"><span class="linenos"> 863</span></a> <span class="k">def</span> <span class="nf">index_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Index</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-864"><a href="#L-864"><span class="linenos"> 864</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">"UNIQUE "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-865"><a href="#L-865"><span class="linenos"> 865</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="s2">"PRIMARY "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"primary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-866"><a href="#L-866"><span class="linenos"> 866</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="s2">"AMP "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"amp"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-867"><a href="#L-867"><span class="linenos"> 867</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-868"><a href="#L-868"><span class="linenos"> 868</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"table"</span><span class="p">)</span> -</span><span id="L-869"><a href="#L-869"><span class="linenos"> 869</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">INDEX_ON</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">table</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-870"><a href="#L-870"><span class="linenos"> 870</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> -</span><span id="L-871"><a href="#L-871"><span class="linenos"> 871</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-872"><a href="#L-872"><span class="linenos"> 872</span></a> <span class="n">index</span> <span class="o">=</span> <span class="s2">"INDEX "</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-873"><a href="#L-873"><span class="linenos"> 873</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-874"><a href="#L-874"><span class="linenos"> 874</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-875"><a href="#L-875"><span class="linenos"> 875</span></a> <span class="n">partition_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"partition_by"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-876"><a href="#L-876"><span class="linenos"> 876</span></a> <span class="n">partition_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" PARTITION BY </span><span class="si">{</span><span class="n">partition_by</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition_by</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-877"><a href="#L-877"><span class="linenos"> 877</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">unique</span><span class="si">}{</span><span class="n">primary</span><span class="si">}{</span><span class="n">amp</span><span class="si">}{</span><span class="n">index</span><span class="si">}{</span><span class="n">name</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">columns</span><span class="si">}{</span><span class="n">partition_by</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-878"><a href="#L-878"><span class="linenos"> 878</span></a> -</span><span id="L-879"><a href="#L-879"><span class="linenos"> 879</span></a> <span class="k">def</span> <span class="nf">identifier_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-880"><a href="#L-880"><span class="linenos"> 880</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> -</span><span id="L-881"><a href="#L-881"><span class="linenos"> 881</span></a> <span class="n">lower</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="L-882"><a href="#L-882"><span class="linenos"> 882</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">lower</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> <span class="k">else</span> <span class="n">text</span> -</span><span id="L-883"><a href="#L-883"><span class="linenos"> 883</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">)</span> -</span><span id="L-884"><a href="#L-884"><span class="linenos"> 884</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="L-885"><a href="#L-885"><span class="linenos"> 885</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> -</span><span id="L-886"><a href="#L-886"><span class="linenos"> 886</span></a> <span class="ow">or</span> <span class="n">should_identify</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span><span class="p">)</span> -</span><span id="L-887"><a href="#L-887"><span class="linenos"> 887</span></a> <span class="ow">or</span> <span class="n">lower</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span> -</span><span id="L-888"><a href="#L-888"><span class="linenos"> 888</span></a> <span class="ow">or</span> <span class="p">(</span><span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="ow">and</span> <span class="n">text</span><span class="p">[:</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">isdigit</span><span class="p">())</span> -</span><span id="L-889"><a href="#L-889"><span class="linenos"> 889</span></a> <span class="p">):</span> -</span><span id="L-890"><a href="#L-890"><span class="linenos"> 890</span></a> <span class="n">text</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_START</span><span class="si">}{</span><span class="n">text</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-891"><a href="#L-891"><span class="linenos"> 891</span></a> <span class="k">return</span> <span class="n">text</span> -</span><span id="L-892"><a href="#L-892"><span class="linenos"> 892</span></a> -</span><span id="L-893"><a href="#L-893"><span class="linenos"> 893</span></a> <span class="k">def</span> <span class="nf">inputoutputformat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-894"><a href="#L-894"><span class="linenos"> 894</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> -</span><span id="L-895"><a href="#L-895"><span class="linenos"> 895</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-896"><a href="#L-896"><span class="linenos"> 896</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"output_format"</span><span class="p">)</span> -</span><span id="L-897"><a href="#L-897"><span class="linenos"> 897</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OUTPUTFORMAT </span><span class="si">{</span><span class="n">output_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">output_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-898"><a href="#L-898"><span class="linenos"> 898</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">input_format</span><span class="p">,</span> <span class="n">output_format</span><span class="p">))</span> -</span><span id="L-899"><a href="#L-899"><span class="linenos"> 899</span></a> -</span><span id="L-900"><a href="#L-900"><span class="linenos"> 900</span></a> <span class="k">def</span> <span class="nf">national_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">National</span><span class="p">,</span> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"N"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-901"><a href="#L-901"><span class="linenos"> 901</span></a> <span class="n">string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> -</span><span id="L-902"><a href="#L-902"><span class="linenos"> 902</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">string</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-903"><a href="#L-903"><span class="linenos"> 903</span></a> -</span><span id="L-904"><a href="#L-904"><span class="linenos"> 904</span></a> <span class="k">def</span> <span class="nf">partition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Partition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-905"><a href="#L-905"><span class="linenos"> 905</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-906"><a href="#L-906"><span class="linenos"> 906</span></a> -</span><span id="L-907"><a href="#L-907"><span class="linenos"> 907</span></a> <span class="k">def</span> <span class="nf">properties_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-908"><a href="#L-908"><span class="linenos"> 908</span></a> <span class="n">root_properties</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-909"><a href="#L-909"><span class="linenos"> 909</span></a> <span class="n">with_properties</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-910"><a href="#L-910"><span class="linenos"> 910</span></a> -</span><span id="L-911"><a href="#L-911"><span class="linenos"> 911</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="L-912"><a href="#L-912"><span class="linenos"> 912</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> -</span><span id="L-913"><a href="#L-913"><span class="linenos"> 913</span></a> <span class="k">if</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">:</span> -</span><span id="L-914"><a href="#L-914"><span class="linenos"> 914</span></a> <span class="n">with_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="L-915"><a href="#L-915"><span class="linenos"> 915</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">:</span> -</span><span id="L-916"><a href="#L-916"><span class="linenos"> 916</span></a> <span class="n">root_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="L-917"><a href="#L-917"><span class="linenos"> 917</span></a> -</span><span id="L-918"><a href="#L-918"><span class="linenos"> 918</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_properties</span><span class="p">(</span> -</span><span id="L-919"><a href="#L-919"><span class="linenos"> 919</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">root_properties</span><span class="p">)</span> -</span><span id="L-920"><a href="#L-920"><span class="linenos"> 920</span></a> <span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">with_properties</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">with_properties</span><span class="p">))</span> -</span><span id="L-921"><a href="#L-921"><span class="linenos"> 921</span></a> -</span><span id="L-922"><a href="#L-922"><span class="linenos"> 922</span></a> <span class="k">def</span> <span class="nf">root_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-923"><a href="#L-923"><span class="linenos"> 923</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="L-924"><a href="#L-924"><span class="linenos"> 924</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="L-925"><a href="#L-925"><span class="linenos"> 925</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-843"><a href="#L-843"><span class="linenos"> 843</span></a> <span class="k">def</span> <span class="nf">except_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-844"><a href="#L-844"><span class="linenos"> 844</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span> +</span><span id="L-845"><a href="#L-845"><span class="linenos"> 845</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="L-846"><a href="#L-846"><span class="linenos"> 846</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> +</span><span id="L-847"><a href="#L-847"><span class="linenos"> 847</span></a> <span class="p">)</span> +</span><span id="L-848"><a href="#L-848"><span class="linenos"> 848</span></a> +</span><span id="L-849"><a href="#L-849"><span class="linenos"> 849</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-850"><a href="#L-850"><span class="linenos"> 850</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">''</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-851"><a href="#L-851"><span class="linenos"> 851</span></a> +</span><span id="L-852"><a href="#L-852"><span class="linenos"> 852</span></a> <span class="k">def</span> <span class="nf">fetch_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-853"><a href="#L-853"><span class="linenos"> 853</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"direction"</span><span class="p">)</span> +</span><span id="L-854"><a href="#L-854"><span class="linenos"> 854</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">direction</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">direction</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-855"><a href="#L-855"><span class="linenos"> 855</span></a> <span class="n">count</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"count"</span><span class="p">)</span> +</span><span id="L-856"><a href="#L-856"><span class="linenos"> 856</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">count</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-857"><a href="#L-857"><span class="linenos"> 857</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"percent"</span><span class="p">):</span> +</span><span id="L-858"><a href="#L-858"><span class="linenos"> 858</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2"> PERCENT"</span> +</span><span id="L-859"><a href="#L-859"><span class="linenos"> 859</span></a> <span class="n">with_ties_or_only</span> <span class="o">=</span> <span class="s2">"WITH TIES"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"with_ties"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ONLY"</span> +</span><span id="L-860"><a href="#L-860"><span class="linenos"> 860</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'FETCH'</span><span class="p">)</span><span class="si">}{</span><span class="n">direction</span><span class="si">}{</span><span class="n">count</span><span class="si">}</span><span class="s2"> ROWS </span><span class="si">{</span><span class="n">with_ties_or_only</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-861"><a href="#L-861"><span class="linenos"> 861</span></a> +</span><span id="L-862"><a href="#L-862"><span class="linenos"> 862</span></a> <span class="k">def</span> <span class="nf">filter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Filter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-863"><a href="#L-863"><span class="linenos"> 863</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-864"><a href="#L-864"><span class="linenos"> 864</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)[</span><span class="mi">1</span><span class="p">:]</span> <span class="c1"># where has a leading space</span> +</span><span id="L-865"><a href="#L-865"><span class="linenos"> 865</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FILTER(</span><span class="si">{</span><span class="n">where</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-866"><a href="#L-866"><span class="linenos"> 866</span></a> +</span><span id="L-867"><a href="#L-867"><span class="linenos"> 867</span></a> <span class="k">def</span> <span class="nf">hint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-868"><a href="#L-868"><span class="linenos"> 868</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-869"><a href="#L-869"><span class="linenos"> 869</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Hints are not supported"</span><span class="p">)</span> +</span><span id="L-870"><a href="#L-870"><span class="linenos"> 870</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-871"><a href="#L-871"><span class="linenos"> 871</span></a> +</span><span id="L-872"><a href="#L-872"><span class="linenos"> 872</span></a> <span class="k">def</span> <span class="nf">index_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Index</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-873"><a href="#L-873"><span class="linenos"> 873</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">"UNIQUE "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-874"><a href="#L-874"><span class="linenos"> 874</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="s2">"PRIMARY "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"primary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-875"><a href="#L-875"><span class="linenos"> 875</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="s2">"AMP "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"amp"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-876"><a href="#L-876"><span class="linenos"> 876</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-877"><a href="#L-877"><span class="linenos"> 877</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"table"</span><span class="p">)</span> +</span><span id="L-878"><a href="#L-878"><span class="linenos"> 878</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">INDEX_ON</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">table</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-879"><a href="#L-879"><span class="linenos"> 879</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> +</span><span id="L-880"><a href="#L-880"><span class="linenos"> 880</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-881"><a href="#L-881"><span class="linenos"> 881</span></a> <span class="n">index</span> <span class="o">=</span> <span class="s2">"INDEX "</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-882"><a href="#L-882"><span class="linenos"> 882</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-883"><a href="#L-883"><span class="linenos"> 883</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-884"><a href="#L-884"><span class="linenos"> 884</span></a> <span class="n">partition_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"partition_by"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-885"><a href="#L-885"><span class="linenos"> 885</span></a> <span class="n">partition_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" PARTITION BY </span><span class="si">{</span><span class="n">partition_by</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition_by</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-886"><a href="#L-886"><span class="linenos"> 886</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">unique</span><span class="si">}{</span><span class="n">primary</span><span class="si">}{</span><span class="n">amp</span><span class="si">}{</span><span class="n">index</span><span class="si">}{</span><span class="n">name</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">columns</span><span class="si">}{</span><span class="n">partition_by</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-887"><a href="#L-887"><span class="linenos"> 887</span></a> +</span><span id="L-888"><a href="#L-888"><span class="linenos"> 888</span></a> <span class="k">def</span> <span class="nf">identifier_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-889"><a href="#L-889"><span class="linenos"> 889</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-890"><a href="#L-890"><span class="linenos"> 890</span></a> <span class="n">lower</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> +</span><span id="L-891"><a href="#L-891"><span class="linenos"> 891</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">lower</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> <span class="k">else</span> <span class="n">text</span> +</span><span id="L-892"><a href="#L-892"><span class="linenos"> 892</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">)</span> +</span><span id="L-893"><a href="#L-893"><span class="linenos"> 893</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="L-894"><a href="#L-894"><span class="linenos"> 894</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> +</span><span id="L-895"><a href="#L-895"><span class="linenos"> 895</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">can_identify</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span><span class="p">)</span> +</span><span id="L-896"><a href="#L-896"><span class="linenos"> 896</span></a> <span class="ow">or</span> <span class="n">lower</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span> +</span><span id="L-897"><a href="#L-897"><span class="linenos"> 897</span></a> <span class="ow">or</span> <span class="p">(</span><span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="ow">and</span> <span class="n">text</span><span class="p">[:</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">isdigit</span><span class="p">())</span> +</span><span id="L-898"><a href="#L-898"><span class="linenos"> 898</span></a> <span class="p">):</span> +</span><span id="L-899"><a href="#L-899"><span class="linenos"> 899</span></a> <span class="n">text</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_START</span><span class="si">}{</span><span class="n">text</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-900"><a href="#L-900"><span class="linenos"> 900</span></a> <span class="k">return</span> <span class="n">text</span> +</span><span id="L-901"><a href="#L-901"><span class="linenos"> 901</span></a> +</span><span id="L-902"><a href="#L-902"><span class="linenos"> 902</span></a> <span class="k">def</span> <span class="nf">inputoutputformat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-903"><a href="#L-903"><span class="linenos"> 903</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> +</span><span id="L-904"><a href="#L-904"><span class="linenos"> 904</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-905"><a href="#L-905"><span class="linenos"> 905</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"output_format"</span><span class="p">)</span> +</span><span id="L-906"><a href="#L-906"><span class="linenos"> 906</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OUTPUTFORMAT </span><span class="si">{</span><span class="n">output_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">output_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-907"><a href="#L-907"><span class="linenos"> 907</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">input_format</span><span class="p">,</span> <span class="n">output_format</span><span class="p">))</span> +</span><span id="L-908"><a href="#L-908"><span class="linenos"> 908</span></a> +</span><span id="L-909"><a href="#L-909"><span class="linenos"> 909</span></a> <span class="k">def</span> <span class="nf">national_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">National</span><span class="p">,</span> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"N"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-910"><a href="#L-910"><span class="linenos"> 910</span></a> <span class="n">string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> +</span><span id="L-911"><a href="#L-911"><span class="linenos"> 911</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">string</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-912"><a href="#L-912"><span class="linenos"> 912</span></a> +</span><span id="L-913"><a href="#L-913"><span class="linenos"> 913</span></a> <span class="k">def</span> <span class="nf">partition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Partition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-914"><a href="#L-914"><span class="linenos"> 914</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-915"><a href="#L-915"><span class="linenos"> 915</span></a> +</span><span id="L-916"><a href="#L-916"><span class="linenos"> 916</span></a> <span class="k">def</span> <span class="nf">properties_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-917"><a href="#L-917"><span class="linenos"> 917</span></a> <span class="n">root_properties</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-918"><a href="#L-918"><span class="linenos"> 918</span></a> <span class="n">with_properties</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-919"><a href="#L-919"><span class="linenos"> 919</span></a> +</span><span id="L-920"><a href="#L-920"><span class="linenos"> 920</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="L-921"><a href="#L-921"><span class="linenos"> 921</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> +</span><span id="L-922"><a href="#L-922"><span class="linenos"> 922</span></a> <span class="k">if</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">:</span> +</span><span id="L-923"><a href="#L-923"><span class="linenos"> 923</span></a> <span class="n">with_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="L-924"><a href="#L-924"><span class="linenos"> 924</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">:</span> +</span><span id="L-925"><a href="#L-925"><span class="linenos"> 925</span></a> <span class="n">root_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> </span><span id="L-926"><a href="#L-926"><span class="linenos"> 926</span></a> -</span><span id="L-927"><a href="#L-927"><span class="linenos"> 927</span></a> <span class="k">def</span> <span class="nf">properties</span><span class="p">(</span> -</span><span id="L-928"><a href="#L-928"><span class="linenos"> 928</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-929"><a href="#L-929"><span class="linenos"> 929</span></a> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">,</span> -</span><span id="L-930"><a href="#L-930"><span class="linenos"> 930</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="L-931"><a href="#L-931"><span class="linenos"> 931</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">,</span> -</span><span id="L-932"><a href="#L-932"><span class="linenos"> 932</span></a> <span class="n">suffix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="L-933"><a href="#L-933"><span class="linenos"> 933</span></a> <span class="n">wrapped</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-934"><a href="#L-934"><span class="linenos"> 934</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-935"><a href="#L-935"><span class="linenos"> 935</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="L-936"><a href="#L-936"><span class="linenos"> 936</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-937"><a href="#L-937"><span class="linenos"> 937</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">wrapped</span> <span class="k">else</span> <span class="n">expressions</span> -</span><span id="L-938"><a href="#L-938"><span class="linenos"> 938</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="s1">' '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">prefix</span><span class="w"> </span><span class="ow">and</span><span class="w"> </span><span class="n">prefix</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="s1">' '</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-939"><a href="#L-939"><span class="linenos"> 939</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="L-940"><a href="#L-940"><span class="linenos"> 940</span></a> -</span><span id="L-941"><a href="#L-941"><span class="linenos"> 941</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-942"><a href="#L-942"><span class="linenos"> 942</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">))</span> -</span><span id="L-943"><a href="#L-943"><span class="linenos"> 943</span></a> -</span><span id="L-944"><a href="#L-944"><span class="linenos"> 944</span></a> <span class="k">def</span> <span class="nf">locate_properties</span><span class="p">(</span> -</span><span id="L-945"><a href="#L-945"><span class="linenos"> 945</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span> -</span><span id="L-946"><a href="#L-946"><span class="linenos"> 946</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">]]:</span> -</span><span id="L-947"><a href="#L-947"><span class="linenos"> 947</span></a> <span class="n">properties_locs</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-948"><a href="#L-948"><span class="linenos"> 948</span></a> <span class="n">key</span><span class="p">:</span> <span class="p">[]</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span> -</span><span id="L-949"><a href="#L-949"><span class="linenos"> 949</span></a> <span class="p">}</span> -</span><span id="L-950"><a href="#L-950"><span class="linenos"> 950</span></a> -</span><span id="L-951"><a href="#L-951"><span class="linenos"> 951</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="L-952"><a href="#L-952"><span class="linenos"> 952</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> -</span><span id="L-953"><a href="#L-953"><span class="linenos"> 953</span></a> <span class="k">if</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">:</span> -</span><span id="L-954"><a href="#L-954"><span class="linenos"> 954</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="L-955"><a href="#L-955"><span class="linenos"> 955</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">:</span> -</span><span id="L-956"><a href="#L-956"><span class="linenos"> 956</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="L-957"><a href="#L-957"><span class="linenos"> 957</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">:</span> -</span><span id="L-958"><a href="#L-958"><span class="linenos"> 958</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="L-959"><a href="#L-959"><span class="linenos"> 959</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">:</span> -</span><span id="L-960"><a href="#L-960"><span class="linenos"> 960</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="L-961"><a href="#L-961"><span class="linenos"> 961</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">:</span> -</span><span id="L-962"><a href="#L-962"><span class="linenos"> 962</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="L-963"><a href="#L-963"><span class="linenos"> 963</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">:</span> -</span><span id="L-964"><a href="#L-964"><span class="linenos"> 964</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="L-965"><a href="#L-965"><span class="linenos"> 965</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">:</span> -</span><span id="L-966"><a href="#L-966"><span class="linenos"> 966</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="L-967"><a href="#L-967"><span class="linenos"> 967</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">:</span> -</span><span id="L-968"><a href="#L-968"><span class="linenos"> 968</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">p</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-969"><a href="#L-969"><span class="linenos"> 969</span></a> -</span><span id="L-970"><a href="#L-970"><span class="linenos"> 970</span></a> <span class="k">return</span> <span class="n">properties_locs</span> -</span><span id="L-971"><a href="#L-971"><span class="linenos"> 971</span></a> -</span><span id="L-972"><a href="#L-972"><span class="linenos"> 972</span></a> <span class="k">def</span> <span class="nf">property_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-973"><a href="#L-973"><span class="linenos"> 973</span></a> <span class="n">property_cls</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span> -</span><span id="L-974"><a href="#L-974"><span class="linenos"> 974</span></a> <span class="k">if</span> <span class="n">property_cls</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> -</span><span id="L-975"><a href="#L-975"><span class="linenos"> 975</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-976"><a href="#L-976"><span class="linenos"> 976</span></a> -</span><span id="L-977"><a href="#L-977"><span class="linenos"> 977</span></a> <span class="n">property_name</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">PROPERTY_TO_NAME</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">property_cls</span><span class="p">)</span> -</span><span id="L-978"><a href="#L-978"><span class="linenos"> 978</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">property_name</span><span class="p">:</span> -</span><span id="L-979"><a href="#L-979"><span class="linenos"> 979</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-927"><a href="#L-927"><span class="linenos"> 927</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_properties</span><span class="p">(</span> +</span><span id="L-928"><a href="#L-928"><span class="linenos"> 928</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">root_properties</span><span class="p">)</span> +</span><span id="L-929"><a href="#L-929"><span class="linenos"> 929</span></a> <span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">with_properties</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">with_properties</span><span class="p">))</span> +</span><span id="L-930"><a href="#L-930"><span class="linenos"> 930</span></a> +</span><span id="L-931"><a href="#L-931"><span class="linenos"> 931</span></a> <span class="k">def</span> <span class="nf">root_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-932"><a href="#L-932"><span class="linenos"> 932</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="L-933"><a href="#L-933"><span class="linenos"> 933</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="L-934"><a href="#L-934"><span class="linenos"> 934</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-935"><a href="#L-935"><span class="linenos"> 935</span></a> +</span><span id="L-936"><a href="#L-936"><span class="linenos"> 936</span></a> <span class="k">def</span> <span class="nf">properties</span><span class="p">(</span> +</span><span id="L-937"><a href="#L-937"><span class="linenos"> 937</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-938"><a href="#L-938"><span class="linenos"> 938</span></a> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">,</span> +</span><span id="L-939"><a href="#L-939"><span class="linenos"> 939</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="L-940"><a href="#L-940"><span class="linenos"> 940</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">,</span> +</span><span id="L-941"><a href="#L-941"><span class="linenos"> 941</span></a> <span class="n">suffix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="L-942"><a href="#L-942"><span class="linenos"> 942</span></a> <span class="n">wrapped</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-943"><a href="#L-943"><span class="linenos"> 943</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-944"><a href="#L-944"><span class="linenos"> 944</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="L-945"><a href="#L-945"><span class="linenos"> 945</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-946"><a href="#L-946"><span class="linenos"> 946</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">wrapped</span> <span class="k">else</span> <span class="n">expressions</span> +</span><span id="L-947"><a href="#L-947"><span class="linenos"> 947</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="s1">' '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">prefix</span><span class="w"> </span><span class="ow">and</span><span class="w"> </span><span class="n">prefix</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="s1">' '</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-948"><a href="#L-948"><span class="linenos"> 948</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-949"><a href="#L-949"><span class="linenos"> 949</span></a> +</span><span id="L-950"><a href="#L-950"><span class="linenos"> 950</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-951"><a href="#L-951"><span class="linenos"> 951</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">))</span> +</span><span id="L-952"><a href="#L-952"><span class="linenos"> 952</span></a> +</span><span id="L-953"><a href="#L-953"><span class="linenos"> 953</span></a> <span class="k">def</span> <span class="nf">locate_properties</span><span class="p">(</span> +</span><span id="L-954"><a href="#L-954"><span class="linenos"> 954</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span> +</span><span id="L-955"><a href="#L-955"><span class="linenos"> 955</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">]]:</span> +</span><span id="L-956"><a href="#L-956"><span class="linenos"> 956</span></a> <span class="n">properties_locs</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-957"><a href="#L-957"><span class="linenos"> 957</span></a> <span class="n">key</span><span class="p">:</span> <span class="p">[]</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span> +</span><span id="L-958"><a href="#L-958"><span class="linenos"> 958</span></a> <span class="p">}</span> +</span><span id="L-959"><a href="#L-959"><span class="linenos"> 959</span></a> +</span><span id="L-960"><a href="#L-960"><span class="linenos"> 960</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="L-961"><a href="#L-961"><span class="linenos"> 961</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> +</span><span id="L-962"><a href="#L-962"><span class="linenos"> 962</span></a> <span class="k">if</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">:</span> +</span><span id="L-963"><a href="#L-963"><span class="linenos"> 963</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="L-964"><a href="#L-964"><span class="linenos"> 964</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">:</span> +</span><span id="L-965"><a href="#L-965"><span class="linenos"> 965</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="L-966"><a href="#L-966"><span class="linenos"> 966</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">:</span> +</span><span id="L-967"><a href="#L-967"><span class="linenos"> 967</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="L-968"><a href="#L-968"><span class="linenos"> 968</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">:</span> +</span><span id="L-969"><a href="#L-969"><span class="linenos"> 969</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="L-970"><a href="#L-970"><span class="linenos"> 970</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">:</span> +</span><span id="L-971"><a href="#L-971"><span class="linenos"> 971</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="L-972"><a href="#L-972"><span class="linenos"> 972</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">:</span> +</span><span id="L-973"><a href="#L-973"><span class="linenos"> 973</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="L-974"><a href="#L-974"><span class="linenos"> 974</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">:</span> +</span><span id="L-975"><a href="#L-975"><span class="linenos"> 975</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="L-976"><a href="#L-976"><span class="linenos"> 976</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">:</span> +</span><span id="L-977"><a href="#L-977"><span class="linenos"> 977</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">p</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-978"><a href="#L-978"><span class="linenos"> 978</span></a> +</span><span id="L-979"><a href="#L-979"><span class="linenos"> 979</span></a> <span class="k">return</span> <span class="n">properties_locs</span> </span><span id="L-980"><a href="#L-980"><span class="linenos"> 980</span></a> -</span><span id="L-981"><a href="#L-981"><span class="linenos"> 981</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">property_name</span><span class="si">}</span><span class="s2">=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-982"><a href="#L-982"><span class="linenos"> 982</span></a> -</span><span id="L-983"><a href="#L-983"><span class="linenos"> 983</span></a> <span class="k">def</span> <span class="nf">likeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-984"><a href="#L-984"><span class="linenos"> 984</span></a> <span class="n">options</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-985"><a href="#L-985"><span class="linenos"> 985</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-986"><a href="#L-986"><span class="linenos"> 986</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LIKE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-987"><a href="#L-987"><span class="linenos"> 987</span></a> -</span><span id="L-988"><a href="#L-988"><span class="linenos"> 988</span></a> <span class="k">def</span> <span class="nf">fallbackproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-989"><a href="#L-989"><span class="linenos"> 989</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-990"><a href="#L-990"><span class="linenos"> 990</span></a> <span class="n">protection</span> <span class="o">=</span> <span class="s2">" PROTECTION"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"protection"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-991"><a href="#L-991"><span class="linenos"> 991</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}</span><span class="s2">FALLBACK</span><span class="si">{</span><span class="n">protection</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-992"><a href="#L-992"><span class="linenos"> 992</span></a> -</span><span id="L-993"><a href="#L-993"><span class="linenos"> 993</span></a> <span class="k">def</span> <span class="nf">journalproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-994"><a href="#L-994"><span class="linenos"> 994</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-995"><a href="#L-995"><span class="linenos"> 995</span></a> <span class="n">local</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"local"</span><span class="p">)</span> -</span><span id="L-996"><a href="#L-996"><span class="linenos"> 996</span></a> <span class="n">local</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">local</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-997"><a href="#L-997"><span class="linenos"> 997</span></a> <span class="n">dual</span> <span class="o">=</span> <span class="s2">"DUAL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"dual"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-998"><a href="#L-998"><span class="linenos"> 998</span></a> <span class="n">before</span> <span class="o">=</span> <span class="s2">"BEFORE "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"before"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-999"><a href="#L-999"><span class="linenos"> 999</span></a> <span class="n">after</span> <span class="o">=</span> <span class="s2">"AFTER "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"after"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1000"><a href="#L-1000"><span class="linenos">1000</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">local</span><span class="si">}{</span><span class="n">dual</span><span class="si">}{</span><span class="n">before</span><span class="si">}{</span><span class="n">after</span><span class="si">}</span><span class="s2">JOURNAL"</span> +</span><span id="L-981"><a href="#L-981"><span class="linenos"> 981</span></a> <span class="k">def</span> <span class="nf">property_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-982"><a href="#L-982"><span class="linenos"> 982</span></a> <span class="n">property_cls</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span> +</span><span id="L-983"><a href="#L-983"><span class="linenos"> 983</span></a> <span class="k">if</span> <span class="n">property_cls</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> +</span><span id="L-984"><a href="#L-984"><span class="linenos"> 984</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-985"><a href="#L-985"><span class="linenos"> 985</span></a> +</span><span id="L-986"><a href="#L-986"><span class="linenos"> 986</span></a> <span class="n">property_name</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">PROPERTY_TO_NAME</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">property_cls</span><span class="p">)</span> +</span><span id="L-987"><a href="#L-987"><span class="linenos"> 987</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">property_name</span><span class="p">:</span> +</span><span id="L-988"><a href="#L-988"><span class="linenos"> 988</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-989"><a href="#L-989"><span class="linenos"> 989</span></a> +</span><span id="L-990"><a href="#L-990"><span class="linenos"> 990</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">property_name</span><span class="si">}</span><span class="s2">=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-991"><a href="#L-991"><span class="linenos"> 991</span></a> +</span><span id="L-992"><a href="#L-992"><span class="linenos"> 992</span></a> <span class="k">def</span> <span class="nf">likeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-993"><a href="#L-993"><span class="linenos"> 993</span></a> <span class="n">options</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-994"><a href="#L-994"><span class="linenos"> 994</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-995"><a href="#L-995"><span class="linenos"> 995</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LIKE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-996"><a href="#L-996"><span class="linenos"> 996</span></a> +</span><span id="L-997"><a href="#L-997"><span class="linenos"> 997</span></a> <span class="k">def</span> <span class="nf">fallbackproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-998"><a href="#L-998"><span class="linenos"> 998</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-999"><a href="#L-999"><span class="linenos"> 999</span></a> <span class="n">protection</span> <span class="o">=</span> <span class="s2">" PROTECTION"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"protection"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1000"><a href="#L-1000"><span class="linenos">1000</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}</span><span class="s2">FALLBACK</span><span class="si">{</span><span class="n">protection</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-1001"><a href="#L-1001"><span class="linenos">1001</span></a> -</span><span id="L-1002"><a href="#L-1002"><span class="linenos">1002</span></a> <span class="k">def</span> <span class="nf">freespaceproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1003"><a href="#L-1003"><span class="linenos">1003</span></a> <span class="n">freespace</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-1004"><a href="#L-1004"><span class="linenos">1004</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1005"><a href="#L-1005"><span class="linenos">1005</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FREESPACE=</span><span class="si">{</span><span class="n">freespace</span><span class="si">}{</span><span class="n">percent</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1006"><a href="#L-1006"><span class="linenos">1006</span></a> -</span><span id="L-1007"><a href="#L-1007"><span class="linenos">1007</span></a> <span class="k">def</span> <span class="nf">checksumproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1008"><a href="#L-1008"><span class="linenos">1008</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">):</span> -</span><span id="L-1009"><a href="#L-1009"><span class="linenos">1009</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> -</span><span id="L-1010"><a href="#L-1010"><span class="linenos">1010</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on"</span><span class="p">):</span> -</span><span id="L-1011"><a href="#L-1011"><span class="linenos">1011</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"ON"</span> -</span><span id="L-1012"><a href="#L-1012"><span class="linenos">1012</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1013"><a href="#L-1013"><span class="linenos">1013</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"OFF"</span> -</span><span id="L-1014"><a href="#L-1014"><span class="linenos">1014</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECKSUM=</span><span class="si">{</span><span class="nb">property</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1002"><a href="#L-1002"><span class="linenos">1002</span></a> <span class="k">def</span> <span class="nf">journalproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1003"><a href="#L-1003"><span class="linenos">1003</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1004"><a href="#L-1004"><span class="linenos">1004</span></a> <span class="n">local</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"local"</span><span class="p">)</span> +</span><span id="L-1005"><a href="#L-1005"><span class="linenos">1005</span></a> <span class="n">local</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">local</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1006"><a href="#L-1006"><span class="linenos">1006</span></a> <span class="n">dual</span> <span class="o">=</span> <span class="s2">"DUAL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"dual"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1007"><a href="#L-1007"><span class="linenos">1007</span></a> <span class="n">before</span> <span class="o">=</span> <span class="s2">"BEFORE "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"before"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1008"><a href="#L-1008"><span class="linenos">1008</span></a> <span class="n">after</span> <span class="o">=</span> <span class="s2">"AFTER "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"after"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1009"><a href="#L-1009"><span class="linenos">1009</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">local</span><span class="si">}{</span><span class="n">dual</span><span class="si">}{</span><span class="n">before</span><span class="si">}{</span><span class="n">after</span><span class="si">}</span><span class="s2">JOURNAL"</span> +</span><span id="L-1010"><a href="#L-1010"><span class="linenos">1010</span></a> +</span><span id="L-1011"><a href="#L-1011"><span class="linenos">1011</span></a> <span class="k">def</span> <span class="nf">freespaceproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1012"><a href="#L-1012"><span class="linenos">1012</span></a> <span class="n">freespace</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-1013"><a href="#L-1013"><span class="linenos">1013</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1014"><a href="#L-1014"><span class="linenos">1014</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FREESPACE=</span><span class="si">{</span><span class="n">freespace</span><span class="si">}{</span><span class="n">percent</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-1015"><a href="#L-1015"><span class="linenos">1015</span></a> -</span><span id="L-1016"><a href="#L-1016"><span class="linenos">1016</span></a> <span class="k">def</span> <span class="nf">mergeblockratioproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1017"><a href="#L-1017"><span class="linenos">1017</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">):</span> -</span><span id="L-1018"><a href="#L-1018"><span class="linenos">1018</span></a> <span class="k">return</span> <span class="s2">"NO MERGEBLOCKRATIO"</span> -</span><span id="L-1019"><a href="#L-1019"><span class="linenos">1019</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">):</span> -</span><span id="L-1020"><a href="#L-1020"><span class="linenos">1020</span></a> <span class="k">return</span> <span class="s2">"DEFAULT MERGEBLOCKRATIO"</span> -</span><span id="L-1021"><a href="#L-1021"><span class="linenos">1021</span></a> -</span><span id="L-1022"><a href="#L-1022"><span class="linenos">1022</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1023"><a href="#L-1023"><span class="linenos">1023</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGEBLOCKRATIO=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">percent</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1016"><a href="#L-1016"><span class="linenos">1016</span></a> <span class="k">def</span> <span class="nf">checksumproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1017"><a href="#L-1017"><span class="linenos">1017</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">):</span> +</span><span id="L-1018"><a href="#L-1018"><span class="linenos">1018</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> +</span><span id="L-1019"><a href="#L-1019"><span class="linenos">1019</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on"</span><span class="p">):</span> +</span><span id="L-1020"><a href="#L-1020"><span class="linenos">1020</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"ON"</span> +</span><span id="L-1021"><a href="#L-1021"><span class="linenos">1021</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1022"><a href="#L-1022"><span class="linenos">1022</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"OFF"</span> +</span><span id="L-1023"><a href="#L-1023"><span class="linenos">1023</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECKSUM=</span><span class="si">{</span><span class="nb">property</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-1024"><a href="#L-1024"><span class="linenos">1024</span></a> -</span><span id="L-1025"><a href="#L-1025"><span class="linenos">1025</span></a> <span class="k">def</span> <span class="nf">datablocksizeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1026"><a href="#L-1026"><span class="linenos">1026</span></a> <span class="n">default</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> -</span><span id="L-1027"><a href="#L-1027"><span class="linenos">1027</span></a> <span class="n">minimum</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"minimum"</span><span class="p">)</span> -</span><span id="L-1028"><a href="#L-1028"><span class="linenos">1028</span></a> <span class="n">maximum</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"maximum"</span><span class="p">)</span> -</span><span id="L-1029"><a href="#L-1029"><span class="linenos">1029</span></a> <span class="k">if</span> <span class="n">default</span> <span class="ow">or</span> <span class="n">minimum</span> <span class="ow">or</span> <span class="n">maximum</span><span class="p">:</span> -</span><span id="L-1030"><a href="#L-1030"><span class="linenos">1030</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="L-1031"><a href="#L-1031"><span class="linenos">1031</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> -</span><span id="L-1032"><a href="#L-1032"><span class="linenos">1032</span></a> <span class="k">elif</span> <span class="n">minimum</span><span class="p">:</span> -</span><span id="L-1033"><a href="#L-1033"><span class="linenos">1033</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MINIMUM"</span> -</span><span id="L-1034"><a href="#L-1034"><span class="linenos">1034</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1035"><a href="#L-1035"><span class="linenos">1035</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MAXIMUM"</span> -</span><span id="L-1036"><a href="#L-1036"><span class="linenos">1036</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2"> DATABLOCKSIZE"</span> -</span><span id="L-1037"><a href="#L-1037"><span class="linenos">1037</span></a> <span class="n">units</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"units"</span><span class="p">)</span> -</span><span id="L-1038"><a href="#L-1038"><span class="linenos">1038</span></a> <span class="n">units</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">units</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1039"><a href="#L-1039"><span class="linenos">1039</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DATABLOCKSIZE=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'size'</span><span class="p">)</span><span class="si">}{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1040"><a href="#L-1040"><span class="linenos">1040</span></a> -</span><span id="L-1041"><a href="#L-1041"><span class="linenos">1041</span></a> <span class="k">def</span> <span class="nf">blockcompressionproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1042"><a href="#L-1042"><span class="linenos">1042</span></a> <span class="n">autotemp</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"autotemp"</span><span class="p">)</span> -</span><span id="L-1043"><a href="#L-1043"><span class="linenos">1043</span></a> <span class="n">always</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"always"</span><span class="p">)</span> -</span><span id="L-1044"><a href="#L-1044"><span class="linenos">1044</span></a> <span class="n">default</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> -</span><span id="L-1045"><a href="#L-1045"><span class="linenos">1045</span></a> <span class="n">manual</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"manual"</span><span class="p">)</span> -</span><span id="L-1046"><a href="#L-1046"><span class="linenos">1046</span></a> <span class="n">never</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"never"</span><span class="p">)</span> -</span><span id="L-1047"><a href="#L-1047"><span class="linenos">1047</span></a> -</span><span id="L-1048"><a href="#L-1048"><span class="linenos">1048</span></a> <span class="k">if</span> <span class="n">autotemp</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-1049"><a href="#L-1049"><span class="linenos">1049</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"AUTOTEMP(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">autotemp</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1050"><a href="#L-1050"><span class="linenos">1050</span></a> <span class="k">elif</span> <span class="n">always</span><span class="p">:</span> -</span><span id="L-1051"><a href="#L-1051"><span class="linenos">1051</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"ALWAYS"</span> -</span><span id="L-1052"><a href="#L-1052"><span class="linenos">1052</span></a> <span class="k">elif</span> <span class="n">default</span><span class="p">:</span> -</span><span id="L-1053"><a href="#L-1053"><span class="linenos">1053</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> -</span><span id="L-1054"><a href="#L-1054"><span class="linenos">1054</span></a> <span class="k">elif</span> <span class="n">manual</span><span class="p">:</span> -</span><span id="L-1055"><a href="#L-1055"><span class="linenos">1055</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MANUAL"</span> -</span><span id="L-1056"><a href="#L-1056"><span class="linenos">1056</span></a> <span class="k">elif</span> <span class="n">never</span><span class="p">:</span> -</span><span id="L-1057"><a href="#L-1057"><span class="linenos">1057</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"NEVER"</span> -</span><span id="L-1058"><a href="#L-1058"><span class="linenos">1058</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BLOCKCOMPRESSION=</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1059"><a href="#L-1059"><span class="linenos">1059</span></a> -</span><span id="L-1060"><a href="#L-1060"><span class="linenos">1060</span></a> <span class="k">def</span> <span class="nf">isolatedloadingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1061"><a href="#L-1061"><span class="linenos">1061</span></a> <span class="n">no</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">)</span> -</span><span id="L-1062"><a href="#L-1062"><span class="linenos">1062</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">" NO"</span> <span class="k">if</span> <span class="n">no</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1063"><a href="#L-1063"><span class="linenos">1063</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"concurrent"</span><span class="p">)</span> -</span><span id="L-1064"><a href="#L-1064"><span class="linenos">1064</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="s2">" CONCURRENT"</span> <span class="k">if</span> <span class="n">concurrent</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1065"><a href="#L-1065"><span class="linenos">1065</span></a> -</span><span id="L-1066"><a href="#L-1066"><span class="linenos">1066</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-1067"><a href="#L-1067"><span class="linenos">1067</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_all"</span><span class="p">):</span> -</span><span id="L-1068"><a href="#L-1068"><span class="linenos">1068</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR ALL"</span> -</span><span id="L-1069"><a href="#L-1069"><span class="linenos">1069</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_insert"</span><span class="p">):</span> -</span><span id="L-1070"><a href="#L-1070"><span class="linenos">1070</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR INSERT"</span> -</span><span id="L-1071"><a href="#L-1071"><span class="linenos">1071</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_none"</span><span class="p">):</span> -</span><span id="L-1072"><a href="#L-1072"><span class="linenos">1072</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR NONE"</span> -</span><span id="L-1073"><a href="#L-1073"><span class="linenos">1073</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">concurrent</span><span class="si">}</span><span class="s2"> ISOLATED LOADING</span><span class="si">{</span><span class="n">for_</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1025"><a href="#L-1025"><span class="linenos">1025</span></a> <span class="k">def</span> <span class="nf">mergeblockratioproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1026"><a href="#L-1026"><span class="linenos">1026</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">):</span> +</span><span id="L-1027"><a href="#L-1027"><span class="linenos">1027</span></a> <span class="k">return</span> <span class="s2">"NO MERGEBLOCKRATIO"</span> +</span><span id="L-1028"><a href="#L-1028"><span class="linenos">1028</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">):</span> +</span><span id="L-1029"><a href="#L-1029"><span class="linenos">1029</span></a> <span class="k">return</span> <span class="s2">"DEFAULT MERGEBLOCKRATIO"</span> +</span><span id="L-1030"><a href="#L-1030"><span class="linenos">1030</span></a> +</span><span id="L-1031"><a href="#L-1031"><span class="linenos">1031</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1032"><a href="#L-1032"><span class="linenos">1032</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGEBLOCKRATIO=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">percent</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1033"><a href="#L-1033"><span class="linenos">1033</span></a> +</span><span id="L-1034"><a href="#L-1034"><span class="linenos">1034</span></a> <span class="k">def</span> <span class="nf">datablocksizeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1035"><a href="#L-1035"><span class="linenos">1035</span></a> <span class="n">default</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> +</span><span id="L-1036"><a href="#L-1036"><span class="linenos">1036</span></a> <span class="n">minimum</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"minimum"</span><span class="p">)</span> +</span><span id="L-1037"><a href="#L-1037"><span class="linenos">1037</span></a> <span class="n">maximum</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"maximum"</span><span class="p">)</span> +</span><span id="L-1038"><a href="#L-1038"><span class="linenos">1038</span></a> <span class="k">if</span> <span class="n">default</span> <span class="ow">or</span> <span class="n">minimum</span> <span class="ow">or</span> <span class="n">maximum</span><span class="p">:</span> +</span><span id="L-1039"><a href="#L-1039"><span class="linenos">1039</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> +</span><span id="L-1040"><a href="#L-1040"><span class="linenos">1040</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> +</span><span id="L-1041"><a href="#L-1041"><span class="linenos">1041</span></a> <span class="k">elif</span> <span class="n">minimum</span><span class="p">:</span> +</span><span id="L-1042"><a href="#L-1042"><span class="linenos">1042</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MINIMUM"</span> +</span><span id="L-1043"><a href="#L-1043"><span class="linenos">1043</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1044"><a href="#L-1044"><span class="linenos">1044</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MAXIMUM"</span> +</span><span id="L-1045"><a href="#L-1045"><span class="linenos">1045</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2"> DATABLOCKSIZE"</span> +</span><span id="L-1046"><a href="#L-1046"><span class="linenos">1046</span></a> <span class="n">units</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"units"</span><span class="p">)</span> +</span><span id="L-1047"><a href="#L-1047"><span class="linenos">1047</span></a> <span class="n">units</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">units</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1048"><a href="#L-1048"><span class="linenos">1048</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DATABLOCKSIZE=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'size'</span><span class="p">)</span><span class="si">}{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1049"><a href="#L-1049"><span class="linenos">1049</span></a> +</span><span id="L-1050"><a href="#L-1050"><span class="linenos">1050</span></a> <span class="k">def</span> <span class="nf">blockcompressionproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1051"><a href="#L-1051"><span class="linenos">1051</span></a> <span class="n">autotemp</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"autotemp"</span><span class="p">)</span> +</span><span id="L-1052"><a href="#L-1052"><span class="linenos">1052</span></a> <span class="n">always</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"always"</span><span class="p">)</span> +</span><span id="L-1053"><a href="#L-1053"><span class="linenos">1053</span></a> <span class="n">default</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> +</span><span id="L-1054"><a href="#L-1054"><span class="linenos">1054</span></a> <span class="n">manual</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"manual"</span><span class="p">)</span> +</span><span id="L-1055"><a href="#L-1055"><span class="linenos">1055</span></a> <span class="n">never</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"never"</span><span class="p">)</span> +</span><span id="L-1056"><a href="#L-1056"><span class="linenos">1056</span></a> +</span><span id="L-1057"><a href="#L-1057"><span class="linenos">1057</span></a> <span class="k">if</span> <span class="n">autotemp</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-1058"><a href="#L-1058"><span class="linenos">1058</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"AUTOTEMP(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">autotemp</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1059"><a href="#L-1059"><span class="linenos">1059</span></a> <span class="k">elif</span> <span class="n">always</span><span class="p">:</span> +</span><span id="L-1060"><a href="#L-1060"><span class="linenos">1060</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"ALWAYS"</span> +</span><span id="L-1061"><a href="#L-1061"><span class="linenos">1061</span></a> <span class="k">elif</span> <span class="n">default</span><span class="p">:</span> +</span><span id="L-1062"><a href="#L-1062"><span class="linenos">1062</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> +</span><span id="L-1063"><a href="#L-1063"><span class="linenos">1063</span></a> <span class="k">elif</span> <span class="n">manual</span><span class="p">:</span> +</span><span id="L-1064"><a href="#L-1064"><span class="linenos">1064</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MANUAL"</span> +</span><span id="L-1065"><a href="#L-1065"><span class="linenos">1065</span></a> <span class="k">elif</span> <span class="n">never</span><span class="p">:</span> +</span><span id="L-1066"><a href="#L-1066"><span class="linenos">1066</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"NEVER"</span> +</span><span id="L-1067"><a href="#L-1067"><span class="linenos">1067</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BLOCKCOMPRESSION=</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1068"><a href="#L-1068"><span class="linenos">1068</span></a> +</span><span id="L-1069"><a href="#L-1069"><span class="linenos">1069</span></a> <span class="k">def</span> <span class="nf">isolatedloadingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1070"><a href="#L-1070"><span class="linenos">1070</span></a> <span class="n">no</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">)</span> +</span><span id="L-1071"><a href="#L-1071"><span class="linenos">1071</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">" NO"</span> <span class="k">if</span> <span class="n">no</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1072"><a href="#L-1072"><span class="linenos">1072</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"concurrent"</span><span class="p">)</span> +</span><span id="L-1073"><a href="#L-1073"><span class="linenos">1073</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="s2">" CONCURRENT"</span> <span class="k">if</span> <span class="n">concurrent</span> <span class="k">else</span> <span class="s2">""</span> </span><span id="L-1074"><a href="#L-1074"><span class="linenos">1074</span></a> -</span><span id="L-1075"><a href="#L-1075"><span class="linenos">1075</span></a> <span class="k">def</span> <span class="nf">lockingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1076"><a href="#L-1076"><span class="linenos">1076</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> -</span><span id="L-1077"><a href="#L-1077"><span class="linenos">1077</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1078"><a href="#L-1078"><span class="linenos">1078</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_or_in"</span><span class="p">)</span> -</span><span id="L-1079"><a href="#L-1079"><span class="linenos">1079</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lock_type"</span><span class="p">)</span> -</span><span id="L-1080"><a href="#L-1080"><span class="linenos">1080</span></a> <span class="n">override</span> <span class="o">=</span> <span class="s2">" OVERRIDE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"override"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1081"><a href="#L-1081"><span class="linenos">1081</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOCKING </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">for_or_in</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">override</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1082"><a href="#L-1082"><span class="linenos">1082</span></a> -</span><span id="L-1083"><a href="#L-1083"><span class="linenos">1083</span></a> <span class="k">def</span> <span class="nf">withdataproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1084"><a href="#L-1084"><span class="linenos">1084</span></a> <span class="n">data_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'no'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">DATA"</span> -</span><span id="L-1085"><a href="#L-1085"><span class="linenos">1085</span></a> <span class="n">statistics</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"statistics"</span><span class="p">)</span> -</span><span id="L-1086"><a href="#L-1086"><span class="linenos">1086</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-1087"><a href="#L-1087"><span class="linenos">1087</span></a> <span class="k">if</span> <span class="n">statistics</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-1088"><a href="#L-1088"><span class="linenos">1088</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">statistics</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">STATISTICS"</span> -</span><span id="L-1089"><a href="#L-1089"><span class="linenos">1089</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">data_sql</span><span class="si">}{</span><span class="n">statistics_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1090"><a href="#L-1090"><span class="linenos">1090</span></a> -</span><span id="L-1091"><a href="#L-1091"><span class="linenos">1091</span></a> <span class="k">def</span> <span class="nf">insert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1092"><a href="#L-1092"><span class="linenos">1092</span></a> <span class="n">overwrite</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"overwrite"</span><span class="p">)</span> -</span><span id="L-1093"><a href="#L-1093"><span class="linenos">1093</span></a> -</span><span id="L-1094"><a href="#L-1094"><span class="linenos">1094</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">):</span> -</span><span id="L-1095"><a href="#L-1095"><span class="linenos">1095</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">"OVERWRITE "</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">"INTO "</span> -</span><span id="L-1096"><a href="#L-1096"><span class="linenos">1096</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1097"><a href="#L-1097"><span class="linenos">1097</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">"OVERWRITE TABLE "</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">"INTO "</span> -</span><span id="L-1098"><a href="#L-1098"><span class="linenos">1098</span></a> -</span><span id="L-1099"><a href="#L-1099"><span class="linenos">1099</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alternative"</span><span class="p">)</span> -</span><span id="L-1100"><a href="#L-1100"><span class="linenos">1100</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OR </span><span class="si">{</span><span class="n">alternative</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">alternative</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="L-1101"><a href="#L-1101"><span class="linenos">1101</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1075"><a href="#L-1075"><span class="linenos">1075</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-1076"><a href="#L-1076"><span class="linenos">1076</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_all"</span><span class="p">):</span> +</span><span id="L-1077"><a href="#L-1077"><span class="linenos">1077</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR ALL"</span> +</span><span id="L-1078"><a href="#L-1078"><span class="linenos">1078</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_insert"</span><span class="p">):</span> +</span><span id="L-1079"><a href="#L-1079"><span class="linenos">1079</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR INSERT"</span> +</span><span id="L-1080"><a href="#L-1080"><span class="linenos">1080</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_none"</span><span class="p">):</span> +</span><span id="L-1081"><a href="#L-1081"><span class="linenos">1081</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR NONE"</span> +</span><span id="L-1082"><a href="#L-1082"><span class="linenos">1082</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">concurrent</span><span class="si">}</span><span class="s2"> ISOLATED LOADING</span><span class="si">{</span><span class="n">for_</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1083"><a href="#L-1083"><span class="linenos">1083</span></a> +</span><span id="L-1084"><a href="#L-1084"><span class="linenos">1084</span></a> <span class="k">def</span> <span class="nf">lockingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1085"><a href="#L-1085"><span class="linenos">1085</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> +</span><span id="L-1086"><a href="#L-1086"><span class="linenos">1086</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1087"><a href="#L-1087"><span class="linenos">1087</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_or_in"</span><span class="p">)</span> +</span><span id="L-1088"><a href="#L-1088"><span class="linenos">1088</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lock_type"</span><span class="p">)</span> +</span><span id="L-1089"><a href="#L-1089"><span class="linenos">1089</span></a> <span class="n">override</span> <span class="o">=</span> <span class="s2">" OVERRIDE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"override"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1090"><a href="#L-1090"><span class="linenos">1090</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOCKING </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">for_or_in</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">override</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1091"><a href="#L-1091"><span class="linenos">1091</span></a> +</span><span id="L-1092"><a href="#L-1092"><span class="linenos">1092</span></a> <span class="k">def</span> <span class="nf">withdataproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1093"><a href="#L-1093"><span class="linenos">1093</span></a> <span class="n">data_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'no'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">DATA"</span> +</span><span id="L-1094"><a href="#L-1094"><span class="linenos">1094</span></a> <span class="n">statistics</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"statistics"</span><span class="p">)</span> +</span><span id="L-1095"><a href="#L-1095"><span class="linenos">1095</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-1096"><a href="#L-1096"><span class="linenos">1096</span></a> <span class="k">if</span> <span class="n">statistics</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-1097"><a href="#L-1097"><span class="linenos">1097</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">statistics</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">STATISTICS"</span> +</span><span id="L-1098"><a href="#L-1098"><span class="linenos">1098</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">data_sql</span><span class="si">}{</span><span class="n">statistics_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1099"><a href="#L-1099"><span class="linenos">1099</span></a> +</span><span id="L-1100"><a href="#L-1100"><span class="linenos">1100</span></a> <span class="k">def</span> <span class="nf">insert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1101"><a href="#L-1101"><span class="linenos">1101</span></a> <span class="n">overwrite</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"overwrite"</span><span class="p">)</span> </span><span id="L-1102"><a href="#L-1102"><span class="linenos">1102</span></a> -</span><span id="L-1103"><a href="#L-1103"><span class="linenos">1103</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="L-1104"><a href="#L-1104"><span class="linenos">1104</span></a> <span class="n">partition_sql</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-1105"><a href="#L-1105"><span class="linenos">1105</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"partition"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"partition"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1106"><a href="#L-1106"><span class="linenos">1106</span></a> <span class="p">)</span> -</span><span id="L-1107"><a href="#L-1107"><span class="linenos">1107</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-1108"><a href="#L-1108"><span class="linenos">1108</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"conflict"</span><span class="p">)</span> -</span><span id="L-1109"><a href="#L-1109"><span class="linenos">1109</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> -</span><span id="L-1110"><a href="#L-1110"><span class="linenos">1110</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span> <span class="k">if</span> <span class="n">partition_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1111"><a href="#L-1111"><span class="linenos">1111</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT</span><span class="si">{</span><span class="n">alternative</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">exists</span><span class="si">}{</span><span class="n">partition_sql</span><span class="si">}{</span><span class="n">sep</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">conflict</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1112"><a href="#L-1112"><span class="linenos">1112</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="L-1113"><a href="#L-1113"><span class="linenos">1113</span></a> -</span><span id="L-1114"><a href="#L-1114"><span class="linenos">1114</span></a> <span class="k">def</span> <span class="nf">intersect_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1115"><a href="#L-1115"><span class="linenos">1115</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span> -</span><span id="L-1116"><a href="#L-1116"><span class="linenos">1116</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="L-1117"><a href="#L-1117"><span class="linenos">1117</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> -</span><span id="L-1118"><a href="#L-1118"><span class="linenos">1118</span></a> <span class="p">)</span> -</span><span id="L-1119"><a href="#L-1119"><span class="linenos">1119</span></a> -</span><span id="L-1120"><a href="#L-1120"><span class="linenos">1120</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1121"><a href="#L-1121"><span class="linenos">1121</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">''</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1103"><a href="#L-1103"><span class="linenos">1103</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">):</span> +</span><span id="L-1104"><a href="#L-1104"><span class="linenos">1104</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">"OVERWRITE "</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">"INTO "</span> +</span><span id="L-1105"><a href="#L-1105"><span class="linenos">1105</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1106"><a href="#L-1106"><span class="linenos">1106</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">"OVERWRITE TABLE "</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">"INTO "</span> +</span><span id="L-1107"><a href="#L-1107"><span class="linenos">1107</span></a> +</span><span id="L-1108"><a href="#L-1108"><span class="linenos">1108</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alternative"</span><span class="p">)</span> +</span><span id="L-1109"><a href="#L-1109"><span class="linenos">1109</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OR </span><span class="si">{</span><span class="n">alternative</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">alternative</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="L-1110"><a href="#L-1110"><span class="linenos">1110</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1111"><a href="#L-1111"><span class="linenos">1111</span></a> +</span><span id="L-1112"><a href="#L-1112"><span class="linenos">1112</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="L-1113"><a href="#L-1113"><span class="linenos">1113</span></a> <span class="n">partition_sql</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-1114"><a href="#L-1114"><span class="linenos">1114</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"partition"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"partition"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1115"><a href="#L-1115"><span class="linenos">1115</span></a> <span class="p">)</span> +</span><span id="L-1116"><a href="#L-1116"><span class="linenos">1116</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-1117"><a href="#L-1117"><span class="linenos">1117</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"conflict"</span><span class="p">)</span> +</span><span id="L-1118"><a href="#L-1118"><span class="linenos">1118</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="L-1119"><a href="#L-1119"><span class="linenos">1119</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span> <span class="k">if</span> <span class="n">partition_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1120"><a href="#L-1120"><span class="linenos">1120</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT</span><span class="si">{</span><span class="n">alternative</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">exists</span><span class="si">}{</span><span class="n">partition_sql</span><span class="si">}{</span><span class="n">sep</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">conflict</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1121"><a href="#L-1121"><span class="linenos">1121</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> </span><span id="L-1122"><a href="#L-1122"><span class="linenos">1122</span></a> -</span><span id="L-1123"><a href="#L-1123"><span class="linenos">1123</span></a> <span class="k">def</span> <span class="nf">introducer_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Introducer</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1124"><a href="#L-1124"><span class="linenos">1124</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1125"><a href="#L-1125"><span class="linenos">1125</span></a> -</span><span id="L-1126"><a href="#L-1126"><span class="linenos">1126</span></a> <span class="k">def</span> <span class="nf">pseudotype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PseudoType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1127"><a href="#L-1127"><span class="linenos">1127</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-1123"><a href="#L-1123"><span class="linenos">1123</span></a> <span class="k">def</span> <span class="nf">intersect_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1124"><a href="#L-1124"><span class="linenos">1124</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span> +</span><span id="L-1125"><a href="#L-1125"><span class="linenos">1125</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="L-1126"><a href="#L-1126"><span class="linenos">1126</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> +</span><span id="L-1127"><a href="#L-1127"><span class="linenos">1127</span></a> <span class="p">)</span> </span><span id="L-1128"><a href="#L-1128"><span class="linenos">1128</span></a> -</span><span id="L-1129"><a href="#L-1129"><span class="linenos">1129</span></a> <span class="k">def</span> <span class="nf">onconflict_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnConflict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1130"><a href="#L-1130"><span class="linenos">1130</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="s2">"ON DUPLICATE KEY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ON CONFLICT"</span> -</span><span id="L-1131"><a href="#L-1131"><span class="linenos">1131</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"constraint"</span><span class="p">)</span> -</span><span id="L-1132"><a href="#L-1132"><span class="linenos">1132</span></a> <span class="k">if</span> <span class="n">constraint</span><span class="p">:</span> -</span><span id="L-1133"><a href="#L-1133"><span class="linenos">1133</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON CONSTRAINT </span><span class="si">{</span><span class="n">constraint</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1134"><a href="#L-1134"><span class="linenos">1134</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"key"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1135"><a href="#L-1135"><span class="linenos">1135</span></a> <span class="n">do</span> <span class="o">=</span> <span class="s2">""</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" DO "</span> -</span><span id="L-1136"><a href="#L-1136"><span class="linenos">1136</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="s2">"NOTHING"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nothing"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1137"><a href="#L-1137"><span class="linenos">1137</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1138"><a href="#L-1138"><span class="linenos">1138</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="L-1139"><a href="#L-1139"><span class="linenos">1139</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE SET </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1140"><a href="#L-1140"><span class="linenos">1140</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">conflict</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">constraint</span><span class="si">}{</span><span class="n">key</span><span class="si">}{</span><span class="n">do</span><span class="si">}{</span><span class="n">nothing</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1141"><a href="#L-1141"><span class="linenos">1141</span></a> -</span><span id="L-1142"><a href="#L-1142"><span class="linenos">1142</span></a> <span class="k">def</span> <span class="nf">returning_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Returning</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1143"><a href="#L-1143"><span class="linenos">1143</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'RETURNING'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1144"><a href="#L-1144"><span class="linenos">1144</span></a> -</span><span id="L-1145"><a href="#L-1145"><span class="linenos">1145</span></a> <span class="k">def</span> <span class="nf">rowformatdelimitedproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1146"><a href="#L-1146"><span class="linenos">1146</span></a> <span class="n">fields</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"fields"</span><span class="p">)</span> -</span><span id="L-1147"><a href="#L-1147"><span class="linenos">1147</span></a> <span class="n">fields</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FIELDS TERMINATED BY </span><span class="si">{</span><span class="n">fields</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">fields</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1148"><a href="#L-1148"><span class="linenos">1148</span></a> <span class="n">escaped</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"escaped"</span><span class="p">)</span> -</span><span id="L-1149"><a href="#L-1149"><span class="linenos">1149</span></a> <span class="n">escaped</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ESCAPED BY </span><span class="si">{</span><span class="n">escaped</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">escaped</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1150"><a href="#L-1150"><span class="linenos">1150</span></a> <span class="n">items</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"collection_items"</span><span class="p">)</span> -</span><span id="L-1151"><a href="#L-1151"><span class="linenos">1151</span></a> <span class="n">items</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLECTION ITEMS TERMINATED BY </span><span class="si">{</span><span class="n">items</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">items</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1152"><a href="#L-1152"><span class="linenos">1152</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"map_keys"</span><span class="p">)</span> -</span><span id="L-1153"><a href="#L-1153"><span class="linenos">1153</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAP KEYS TERMINATED BY </span><span class="si">{</span><span class="n">keys</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">keys</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1154"><a href="#L-1154"><span class="linenos">1154</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lines"</span><span class="p">)</span> -</span><span id="L-1155"><a href="#L-1155"><span class="linenos">1155</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" LINES TERMINATED BY </span><span class="si">{</span><span class="n">lines</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">lines</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1156"><a href="#L-1156"><span class="linenos">1156</span></a> <span class="n">null</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"null"</span><span class="p">)</span> -</span><span id="L-1157"><a href="#L-1157"><span class="linenos">1157</span></a> <span class="n">null</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" NULL DEFINED AS </span><span class="si">{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1158"><a href="#L-1158"><span class="linenos">1158</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROW FORMAT DELIMITED</span><span class="si">{</span><span class="n">fields</span><span class="si">}{</span><span class="n">escaped</span><span class="si">}{</span><span class="n">items</span><span class="si">}{</span><span class="n">keys</span><span class="si">}{</span><span class="n">lines</span><span class="si">}{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1159"><a href="#L-1159"><span class="linenos">1159</span></a> -</span><span id="L-1160"><a href="#L-1160"><span class="linenos">1160</span></a> <span class="k">def</span> <span class="nf">table_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1161"><a href="#L-1161"><span class="linenos">1161</span></a> <span class="n">table</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="L-1162"><a href="#L-1162"><span class="linenos">1162</span></a> <span class="n">part</span> -</span><span id="L-1163"><a href="#L-1163"><span class="linenos">1163</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">[</span> -</span><span id="L-1164"><a href="#L-1164"><span class="linenos">1164</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"catalog"</span><span class="p">),</span> -</span><span id="L-1165"><a href="#L-1165"><span class="linenos">1165</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"db"</span><span class="p">),</span> -</span><span id="L-1166"><a href="#L-1166"><span class="linenos">1166</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> -</span><span id="L-1167"><a href="#L-1167"><span class="linenos">1167</span></a> <span class="p">]</span> -</span><span id="L-1168"><a href="#L-1168"><span class="linenos">1168</span></a> <span class="k">if</span> <span class="n">part</span> -</span><span id="L-1169"><a href="#L-1169"><span class="linenos">1169</span></a> <span class="p">)</span> -</span><span id="L-1170"><a href="#L-1170"><span class="linenos">1170</span></a> -</span><span id="L-1171"><a href="#L-1171"><span class="linenos">1171</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="L-1172"><a href="#L-1172"><span class="linenos">1172</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1173"><a href="#L-1173"><span class="linenos">1173</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"hints"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1174"><a href="#L-1174"><span class="linenos">1174</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH (</span><span class="si">{</span><span class="n">hints</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">hints</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_HINTS</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1175"><a href="#L-1175"><span class="linenos">1175</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1176"><a href="#L-1176"><span class="linenos">1176</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1177"><a href="#L-1177"><span class="linenos">1177</span></a> <span class="n">joins</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"joins"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="L-1178"><a href="#L-1178"><span class="linenos">1178</span></a> <span class="n">laterals</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"laterals"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="L-1179"><a href="#L-1179"><span class="linenos">1179</span></a> <span class="n">system_time</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"system_time"</span><span class="p">)</span> -</span><span id="L-1180"><a href="#L-1180"><span class="linenos">1180</span></a> <span class="n">system_time</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'system_time'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">system_time</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1181"><a href="#L-1181"><span class="linenos">1181</span></a> -</span><span id="L-1182"><a href="#L-1182"><span class="linenos">1182</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">system_time</span><span class="si">}{</span><span class="n">alias</span><span class="si">}{</span><span class="n">hints</span><span class="si">}{</span><span class="n">pivots</span><span class="si">}{</span><span class="n">joins</span><span class="si">}{</span><span class="n">laterals</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1183"><a href="#L-1183"><span class="linenos">1183</span></a> -</span><span id="L-1184"><a href="#L-1184"><span class="linenos">1184</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="L-1185"><a href="#L-1185"><span class="linenos">1185</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" AS "</span> -</span><span id="L-1186"><a href="#L-1186"><span class="linenos">1186</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1187"><a href="#L-1187"><span class="linenos">1187</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> -</span><span id="L-1188"><a href="#L-1188"><span class="linenos">1188</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="L-1189"><a href="#L-1189"><span class="linenos">1189</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="L-1190"><a href="#L-1190"><span class="linenos">1190</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> -</span><span id="L-1191"><a href="#L-1191"><span class="linenos">1191</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="s1">'alias'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1192"><a href="#L-1192"><span class="linenos">1192</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1193"><a href="#L-1193"><span class="linenos">1193</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1194"><a href="#L-1194"><span class="linenos">1194</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-1195"><a href="#L-1195"><span class="linenos">1195</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"method"</span><span class="p">)</span> -</span><span id="L-1196"><a href="#L-1196"><span class="linenos">1196</span></a> <span class="n">method</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">method</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1197"><a href="#L-1197"><span class="linenos">1197</span></a> <span class="n">numerator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_numerator"</span><span class="p">)</span> -</span><span id="L-1198"><a href="#L-1198"><span class="linenos">1198</span></a> <span class="n">denominator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_denominator"</span><span class="p">)</span> -</span><span id="L-1199"><a href="#L-1199"><span class="linenos">1199</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_field"</span><span class="p">)</span> -</span><span id="L-1200"><a href="#L-1200"><span class="linenos">1200</span></a> <span class="n">field</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">field</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1201"><a href="#L-1201"><span class="linenos">1201</span></a> <span class="n">bucket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"BUCKET </span><span class="si">{</span><span class="n">numerator</span><span class="si">}</span><span class="s2"> OUT OF </span><span class="si">{</span><span class="n">denominator</span><span class="si">}{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">numerator</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1202"><a href="#L-1202"><span class="linenos">1202</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">)</span> -</span><span id="L-1203"><a href="#L-1203"><span class="linenos">1203</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">percent</span><span class="si">}</span><span class="s2"> PERCENT"</span> <span class="k">if</span> <span class="n">percent</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1204"><a href="#L-1204"><span class="linenos">1204</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> -</span><span id="L-1205"><a href="#L-1205"><span class="linenos">1205</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">rows</span><span class="si">}</span><span class="s2"> ROWS"</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1206"><a href="#L-1206"><span class="linenos">1206</span></a> <span class="n">size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"size"</span><span class="p">)</span> -</span><span id="L-1207"><a href="#L-1207"><span class="linenos">1207</span></a> <span class="k">if</span> <span class="n">size</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span><span class="p">:</span> -</span><span id="L-1208"><a href="#L-1208"><span class="linenos">1208</span></a> <span class="n">size</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">size</span><span class="si">}</span><span class="s2"> PERCENT"</span> -</span><span id="L-1209"><a href="#L-1209"><span class="linenos">1209</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"seed"</span><span class="p">)</span> -</span><span id="L-1210"><a href="#L-1210"><span class="linenos">1210</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">seed_prefix</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">seed</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">seed</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1211"><a href="#L-1211"><span class="linenos">1211</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"TABLESAMPLE"</span><span class="p">)</span> -</span><span id="L-1212"><a href="#L-1212"><span class="linenos">1212</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">method</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">bucket</span><span class="si">}{</span><span class="n">percent</span><span class="si">}{</span><span class="n">rows</span><span class="si">}{</span><span class="n">size</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">seed</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1213"><a href="#L-1213"><span class="linenos">1213</span></a> -</span><span id="L-1214"><a href="#L-1214"><span class="linenos">1214</span></a> <span class="k">def</span> <span class="nf">pivot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1215"><a href="#L-1215"><span class="linenos">1215</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1216"><a href="#L-1216"><span class="linenos">1216</span></a> -</span><span id="L-1217"><a href="#L-1217"><span class="linenos">1217</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> -</span><span id="L-1218"><a href="#L-1218"><span class="linenos">1218</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1219"><a href="#L-1219"><span class="linenos">1219</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'ON'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1220"><a href="#L-1220"><span class="linenos">1220</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"using"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1221"><a href="#L-1221"><span class="linenos">1221</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'USING'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1222"><a href="#L-1222"><span class="linenos">1222</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">)</span> -</span><span id="L-1223"><a href="#L-1223"><span class="linenos">1223</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PIVOT </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">on</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">group</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1224"><a href="#L-1224"><span class="linenos">1224</span></a> -</span><span id="L-1225"><a href="#L-1225"><span class="linenos">1225</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="L-1226"><a href="#L-1226"><span class="linenos">1226</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1227"><a href="#L-1227"><span class="linenos">1227</span></a> <span class="n">unpivot</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unpivot"</span><span class="p">)</span> -</span><span id="L-1228"><a href="#L-1228"><span class="linenos">1228</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="s2">"UNPIVOT"</span> <span class="k">if</span> <span class="n">unpivot</span> <span class="k">else</span> <span class="s2">"PIVOT"</span> -</span><span id="L-1229"><a href="#L-1229"><span class="linenos">1229</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"field"</span><span class="p">)</span> -</span><span id="L-1230"><a href="#L-1230"><span class="linenos">1230</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">direction</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2"> FOR </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1231"><a href="#L-1231"><span class="linenos">1231</span></a> -</span><span id="L-1232"><a href="#L-1232"><span class="linenos">1232</span></a> <span class="k">def</span> <span class="nf">tuple_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Tuple</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1233"><a href="#L-1233"><span class="linenos">1233</span></a> <span class="k">return</span> <span 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-1234"><a href="#L-1234"><span class="linenos">1234</span></a> -</span><span id="L-1235"><a href="#L-1235"><span class="linenos">1235</span></a> <span class="k">def</span> <span class="nf">update_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1236"><a href="#L-1236"><span class="linenos">1236</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1237"><a href="#L-1237"><span class="linenos">1237</span></a> <span class="n">set_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1238"><a href="#L-1238"><span class="linenos">1238</span></a> <span class="n">from_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">)</span> -</span><span id="L-1239"><a href="#L-1239"><span class="linenos">1239</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> -</span><span id="L-1240"><a href="#L-1240"><span class="linenos">1240</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> -</span><span id="L-1241"><a href="#L-1241"><span class="linenos">1241</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1242"><a href="#L-1242"><span class="linenos">1242</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="L-1129"><a href="#L-1129"><span class="linenos">1129</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1130"><a href="#L-1130"><span class="linenos">1130</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">''</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1131"><a href="#L-1131"><span class="linenos">1131</span></a> +</span><span id="L-1132"><a href="#L-1132"><span class="linenos">1132</span></a> <span class="k">def</span> <span class="nf">introducer_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Introducer</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1133"><a href="#L-1133"><span class="linenos">1133</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1134"><a href="#L-1134"><span class="linenos">1134</span></a> +</span><span id="L-1135"><a href="#L-1135"><span class="linenos">1135</span></a> <span class="k">def</span> <span class="nf">pseudotype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PseudoType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1136"><a href="#L-1136"><span class="linenos">1136</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-1137"><a href="#L-1137"><span class="linenos">1137</span></a> +</span><span id="L-1138"><a href="#L-1138"><span class="linenos">1138</span></a> <span class="k">def</span> <span class="nf">onconflict_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnConflict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1139"><a href="#L-1139"><span class="linenos">1139</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="s2">"ON DUPLICATE KEY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ON CONFLICT"</span> +</span><span id="L-1140"><a href="#L-1140"><span class="linenos">1140</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"constraint"</span><span class="p">)</span> +</span><span id="L-1141"><a href="#L-1141"><span class="linenos">1141</span></a> <span class="k">if</span> <span class="n">constraint</span><span class="p">:</span> +</span><span id="L-1142"><a href="#L-1142"><span class="linenos">1142</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON CONSTRAINT </span><span class="si">{</span><span class="n">constraint</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1143"><a href="#L-1143"><span class="linenos">1143</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"key"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1144"><a href="#L-1144"><span class="linenos">1144</span></a> <span class="n">do</span> <span class="o">=</span> <span class="s2">""</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" DO "</span> +</span><span id="L-1145"><a href="#L-1145"><span class="linenos">1145</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="s2">"NOTHING"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nothing"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1146"><a href="#L-1146"><span class="linenos">1146</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1147"><a href="#L-1147"><span class="linenos">1147</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="L-1148"><a href="#L-1148"><span class="linenos">1148</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE SET </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1149"><a href="#L-1149"><span class="linenos">1149</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">conflict</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">constraint</span><span class="si">}{</span><span class="n">key</span><span class="si">}{</span><span class="n">do</span><span class="si">}{</span><span class="n">nothing</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1150"><a href="#L-1150"><span class="linenos">1150</span></a> +</span><span id="L-1151"><a href="#L-1151"><span class="linenos">1151</span></a> <span class="k">def</span> <span class="nf">returning_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Returning</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1152"><a href="#L-1152"><span class="linenos">1152</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'RETURNING'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1153"><a href="#L-1153"><span class="linenos">1153</span></a> +</span><span id="L-1154"><a href="#L-1154"><span class="linenos">1154</span></a> <span class="k">def</span> <span class="nf">rowformatdelimitedproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1155"><a href="#L-1155"><span class="linenos">1155</span></a> <span class="n">fields</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"fields"</span><span class="p">)</span> +</span><span id="L-1156"><a href="#L-1156"><span class="linenos">1156</span></a> <span class="n">fields</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FIELDS TERMINATED BY </span><span class="si">{</span><span class="n">fields</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">fields</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1157"><a href="#L-1157"><span class="linenos">1157</span></a> <span class="n">escaped</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"escaped"</span><span class="p">)</span> +</span><span id="L-1158"><a href="#L-1158"><span class="linenos">1158</span></a> <span class="n">escaped</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ESCAPED BY </span><span class="si">{</span><span class="n">escaped</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">escaped</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1159"><a href="#L-1159"><span class="linenos">1159</span></a> <span class="n">items</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"collection_items"</span><span class="p">)</span> +</span><span id="L-1160"><a href="#L-1160"><span class="linenos">1160</span></a> <span class="n">items</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLECTION ITEMS TERMINATED BY </span><span class="si">{</span><span class="n">items</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">items</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1161"><a href="#L-1161"><span class="linenos">1161</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"map_keys"</span><span class="p">)</span> +</span><span id="L-1162"><a href="#L-1162"><span class="linenos">1162</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAP KEYS TERMINATED BY </span><span class="si">{</span><span class="n">keys</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">keys</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1163"><a href="#L-1163"><span class="linenos">1163</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lines"</span><span class="p">)</span> +</span><span id="L-1164"><a href="#L-1164"><span class="linenos">1164</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" LINES TERMINATED BY </span><span class="si">{</span><span class="n">lines</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">lines</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1165"><a href="#L-1165"><span class="linenos">1165</span></a> <span class="n">null</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"null"</span><span class="p">)</span> +</span><span id="L-1166"><a href="#L-1166"><span class="linenos">1166</span></a> <span class="n">null</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" NULL DEFINED AS </span><span class="si">{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1167"><a href="#L-1167"><span class="linenos">1167</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROW FORMAT DELIMITED</span><span class="si">{</span><span class="n">fields</span><span class="si">}{</span><span class="n">escaped</span><span class="si">}{</span><span class="n">items</span><span class="si">}{</span><span class="n">keys</span><span class="si">}{</span><span class="n">lines</span><span class="si">}{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1168"><a href="#L-1168"><span class="linenos">1168</span></a> +</span><span id="L-1169"><a href="#L-1169"><span class="linenos">1169</span></a> <span class="k">def</span> <span class="nf">table_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1170"><a href="#L-1170"><span class="linenos">1170</span></a> <span class="n">table</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="L-1171"><a href="#L-1171"><span class="linenos">1171</span></a> <span class="n">part</span> +</span><span id="L-1172"><a href="#L-1172"><span class="linenos">1172</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">[</span> +</span><span id="L-1173"><a href="#L-1173"><span class="linenos">1173</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"catalog"</span><span class="p">),</span> +</span><span id="L-1174"><a href="#L-1174"><span class="linenos">1174</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"db"</span><span class="p">),</span> +</span><span id="L-1175"><a href="#L-1175"><span class="linenos">1175</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> +</span><span id="L-1176"><a href="#L-1176"><span class="linenos">1176</span></a> <span class="p">]</span> +</span><span id="L-1177"><a href="#L-1177"><span class="linenos">1177</span></a> <span class="k">if</span> <span class="n">part</span> +</span><span id="L-1178"><a href="#L-1178"><span class="linenos">1178</span></a> <span class="p">)</span> +</span><span id="L-1179"><a href="#L-1179"><span class="linenos">1179</span></a> +</span><span id="L-1180"><a href="#L-1180"><span class="linenos">1180</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="L-1181"><a href="#L-1181"><span class="linenos">1181</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1182"><a href="#L-1182"><span class="linenos">1182</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"hints"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1183"><a href="#L-1183"><span class="linenos">1183</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH (</span><span class="si">{</span><span class="n">hints</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">hints</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_HINTS</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1184"><a href="#L-1184"><span class="linenos">1184</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1185"><a href="#L-1185"><span class="linenos">1185</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1186"><a href="#L-1186"><span class="linenos">1186</span></a> <span class="n">joins</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"joins"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> +</span><span id="L-1187"><a href="#L-1187"><span class="linenos">1187</span></a> <span class="n">laterals</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"laterals"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> +</span><span id="L-1188"><a href="#L-1188"><span class="linenos">1188</span></a> <span class="n">system_time</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"system_time"</span><span class="p">)</span> +</span><span id="L-1189"><a href="#L-1189"><span class="linenos">1189</span></a> <span class="n">system_time</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'system_time'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">system_time</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1190"><a href="#L-1190"><span class="linenos">1190</span></a> +</span><span id="L-1191"><a href="#L-1191"><span class="linenos">1191</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">system_time</span><span class="si">}{</span><span class="n">alias</span><span class="si">}{</span><span class="n">hints</span><span class="si">}{</span><span class="n">pivots</span><span class="si">}{</span><span class="n">joins</span><span class="si">}{</span><span class="n">laterals</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1192"><a href="#L-1192"><span class="linenos">1192</span></a> +</span><span id="L-1193"><a href="#L-1193"><span class="linenos">1193</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="L-1194"><a href="#L-1194"><span class="linenos">1194</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" AS "</span> +</span><span id="L-1195"><a href="#L-1195"><span class="linenos">1195</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1196"><a href="#L-1196"><span class="linenos">1196</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> +</span><span id="L-1197"><a href="#L-1197"><span class="linenos">1197</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="L-1198"><a href="#L-1198"><span class="linenos">1198</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="L-1199"><a href="#L-1199"><span class="linenos">1199</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> +</span><span id="L-1200"><a href="#L-1200"><span class="linenos">1200</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="s1">'alias'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1201"><a href="#L-1201"><span class="linenos">1201</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1202"><a href="#L-1202"><span class="linenos">1202</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1203"><a href="#L-1203"><span class="linenos">1203</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-1204"><a href="#L-1204"><span class="linenos">1204</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"method"</span><span class="p">)</span> +</span><span id="L-1205"><a href="#L-1205"><span class="linenos">1205</span></a> <span class="n">method</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">method</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1206"><a href="#L-1206"><span class="linenos">1206</span></a> <span class="n">numerator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_numerator"</span><span class="p">)</span> +</span><span id="L-1207"><a href="#L-1207"><span class="linenos">1207</span></a> <span class="n">denominator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_denominator"</span><span class="p">)</span> +</span><span id="L-1208"><a href="#L-1208"><span class="linenos">1208</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_field"</span><span class="p">)</span> +</span><span id="L-1209"><a href="#L-1209"><span class="linenos">1209</span></a> <span class="n">field</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">field</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1210"><a href="#L-1210"><span class="linenos">1210</span></a> <span class="n">bucket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"BUCKET </span><span class="si">{</span><span class="n">numerator</span><span class="si">}</span><span class="s2"> OUT OF </span><span class="si">{</span><span class="n">denominator</span><span class="si">}{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">numerator</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1211"><a href="#L-1211"><span class="linenos">1211</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">)</span> +</span><span id="L-1212"><a href="#L-1212"><span class="linenos">1212</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">percent</span><span class="si">}</span><span class="s2"> PERCENT"</span> <span class="k">if</span> <span class="n">percent</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1213"><a href="#L-1213"><span class="linenos">1213</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> +</span><span id="L-1214"><a href="#L-1214"><span class="linenos">1214</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">rows</span><span class="si">}</span><span class="s2"> ROWS"</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1215"><a href="#L-1215"><span class="linenos">1215</span></a> <span class="n">size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"size"</span><span class="p">)</span> +</span><span id="L-1216"><a href="#L-1216"><span class="linenos">1216</span></a> <span class="k">if</span> <span class="n">size</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span><span class="p">:</span> +</span><span id="L-1217"><a href="#L-1217"><span class="linenos">1217</span></a> <span class="n">size</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">size</span><span class="si">}</span><span class="s2"> PERCENT"</span> +</span><span id="L-1218"><a href="#L-1218"><span class="linenos">1218</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"seed"</span><span class="p">)</span> +</span><span id="L-1219"><a href="#L-1219"><span class="linenos">1219</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">seed_prefix</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">seed</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">seed</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1220"><a href="#L-1220"><span class="linenos">1220</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"TABLESAMPLE"</span><span class="p">)</span> +</span><span id="L-1221"><a href="#L-1221"><span class="linenos">1221</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">method</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">bucket</span><span class="si">}{</span><span class="n">percent</span><span class="si">}{</span><span class="n">rows</span><span class="si">}{</span><span class="n">size</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">seed</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1222"><a href="#L-1222"><span class="linenos">1222</span></a> +</span><span id="L-1223"><a href="#L-1223"><span class="linenos">1223</span></a> <span class="k">def</span> <span class="nf">pivot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1224"><a href="#L-1224"><span class="linenos">1224</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1225"><a href="#L-1225"><span class="linenos">1225</span></a> +</span><span id="L-1226"><a href="#L-1226"><span class="linenos">1226</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> +</span><span id="L-1227"><a href="#L-1227"><span class="linenos">1227</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1228"><a href="#L-1228"><span class="linenos">1228</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'ON'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1229"><a href="#L-1229"><span class="linenos">1229</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"using"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1230"><a href="#L-1230"><span class="linenos">1230</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'USING'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1231"><a href="#L-1231"><span class="linenos">1231</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">)</span> +</span><span id="L-1232"><a href="#L-1232"><span class="linenos">1232</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PIVOT </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">on</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">group</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1233"><a href="#L-1233"><span class="linenos">1233</span></a> +</span><span id="L-1234"><a href="#L-1234"><span class="linenos">1234</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="L-1235"><a href="#L-1235"><span class="linenos">1235</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1236"><a href="#L-1236"><span class="linenos">1236</span></a> <span class="n">unpivot</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unpivot"</span><span class="p">)</span> +</span><span id="L-1237"><a href="#L-1237"><span class="linenos">1237</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="s2">"UNPIVOT"</span> <span class="k">if</span> <span class="n">unpivot</span> <span class="k">else</span> <span class="s2">"PIVOT"</span> +</span><span id="L-1238"><a href="#L-1238"><span class="linenos">1238</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"field"</span><span class="p">)</span> +</span><span id="L-1239"><a href="#L-1239"><span class="linenos">1239</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">direction</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2"> FOR </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1240"><a href="#L-1240"><span class="linenos">1240</span></a> +</span><span id="L-1241"><a href="#L-1241"><span class="linenos">1241</span></a> <span class="k">def</span> <span class="nf">tuple_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Tuple</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1242"><a href="#L-1242"><span class="linenos">1242</span></a> <span class="k">return</span> <span 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-1243"><a href="#L-1243"><span class="linenos">1243</span></a> -</span><span id="L-1244"><a href="#L-1244"><span class="linenos">1244</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1245"><a href="#L-1245"><span class="linenos">1245</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-1246"><a href="#L-1246"><span class="linenos">1246</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="L-1247"><a href="#L-1247"><span class="linenos">1247</span></a> <span class="n">values</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"VALUES</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1248"><a href="#L-1248"><span class="linenos">1248</span></a> <span class="n">values</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-1249"><a href="#L-1249"><span class="linenos">1249</span></a> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">values</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1250"><a href="#L-1250"><span class="linenos">1250</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">WRAP_DERIVED_VALUES</span> <span class="ow">and</span> <span class="p">(</span><span class="n">alias</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">))</span> -</span><span id="L-1251"><a href="#L-1251"><span class="linenos">1251</span></a> <span class="k">else</span> <span class="n">values</span> -</span><span id="L-1252"><a href="#L-1252"><span class="linenos">1252</span></a> <span class="p">)</span> -</span><span id="L-1253"><a href="#L-1253"><span class="linenos">1253</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">values</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">values</span> -</span><span id="L-1254"><a href="#L-1254"><span class="linenos">1254</span></a> -</span><span id="L-1255"><a href="#L-1255"><span class="linenos">1255</span></a> <span class="k">def</span> <span class="nf">var_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Var</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1256"><a href="#L-1256"><span class="linenos">1256</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-1257"><a href="#L-1257"><span class="linenos">1257</span></a> -</span><span id="L-1258"><a href="#L-1258"><span class="linenos">1258</span></a> <span class="k">def</span> <span class="nf">into_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Into</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1259"><a href="#L-1259"><span class="linenos">1259</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1260"><a href="#L-1260"><span class="linenos">1260</span></a> <span class="n">unlogged</span> <span class="o">=</span> <span class="s2">" UNLOGGED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unlogged"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1261"><a href="#L-1261"><span class="linenos">1261</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'INTO'</span><span class="p">)</span><span class="si">}{</span><span class="n">temporary</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="n">unlogged</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1262"><a href="#L-1262"><span class="linenos">1262</span></a> -</span><span id="L-1263"><a href="#L-1263"><span class="linenos">1263</span></a> <span class="k">def</span> <span class="nf">from_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1264"><a href="#L-1264"><span class="linenos">1264</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'FROM'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1265"><a href="#L-1265"><span class="linenos">1265</span></a> -</span><span id="L-1266"><a href="#L-1266"><span class="linenos">1266</span></a> <span class="k">def</span> <span class="nf">group_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Group</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1267"><a href="#L-1267"><span class="linenos">1267</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"GROUP BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-1268"><a href="#L-1268"><span class="linenos">1268</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"grouping_sets"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-1269"><a href="#L-1269"><span class="linenos">1269</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-1270"><a href="#L-1270"><span class="linenos">1270</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'GROUPING SETS'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">grouping_sets</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">grouping_sets</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1271"><a href="#L-1271"><span class="linenos">1271</span></a> <span class="p">)</span> -</span><span id="L-1272"><a href="#L-1272"><span class="linenos">1272</span></a> -</span><span id="L-1273"><a href="#L-1273"><span class="linenos">1273</span></a> <span class="n">cube</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"cube"</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="L-1274"><a href="#L-1274"><span class="linenos">1274</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">cube</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-1275"><a href="#L-1275"><span class="linenos">1275</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'WITH CUBE'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1276"><a href="#L-1276"><span class="linenos">1276</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1277"><a href="#L-1277"><span class="linenos">1277</span></a> <span class="n">cube_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"cube"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-1278"><a href="#L-1278"><span class="linenos">1278</span></a> <span class="n">cube_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'CUBE'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">cube_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">cube_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1279"><a href="#L-1279"><span class="linenos">1279</span></a> -</span><span id="L-1280"><a href="#L-1280"><span class="linenos">1280</span></a> <span class="n">rollup</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"rollup"</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="L-1281"><a href="#L-1281"><span class="linenos">1281</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">rollup</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-1282"><a href="#L-1282"><span class="linenos">1282</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'WITH ROLLUP'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1283"><a href="#L-1283"><span class="linenos">1283</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1284"><a href="#L-1284"><span class="linenos">1284</span></a> <span class="n">rollup_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"rollup"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-1285"><a href="#L-1285"><span class="linenos">1285</span></a> <span class="n">rollup_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'ROLLUP'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">rollup_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">rollup_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1286"><a href="#L-1286"><span class="linenos">1286</span></a> -</span><span id="L-1287"><a href="#L-1287"><span class="linenos">1287</span></a> <span class="n">groupings</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span> -</span><span id="L-1288"><a href="#L-1288"><span class="linenos">1288</span></a> <span class="n">grouping_sets</span><span class="p">,</span> -</span><span id="L-1289"><a href="#L-1289"><span class="linenos">1289</span></a> <span class="n">cube_sql</span><span class="p">,</span> -</span><span id="L-1290"><a href="#L-1290"><span class="linenos">1290</span></a> <span class="n">rollup_sql</span><span class="p">,</span> -</span><span id="L-1291"><a href="#L-1291"><span class="linenos">1291</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WITH TOTALS"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"totals"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="L-1292"><a href="#L-1292"><span class="linenos">1292</span></a> <span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="p">,</span> -</span><span id="L-1293"><a href="#L-1293"><span class="linenos">1293</span></a> <span class="p">)</span> -</span><span id="L-1294"><a href="#L-1294"><span class="linenos">1294</span></a> -</span><span id="L-1295"><a href="#L-1295"><span class="linenos">1295</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> <span class="ow">and</span> <span class="n">groupings</span><span class="p">:</span> -</span><span id="L-1296"><a href="#L-1296"><span class="linenos">1296</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1297"><a href="#L-1297"><span class="linenos">1297</span></a> -</span><span id="L-1298"><a href="#L-1298"><span class="linenos">1298</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="n">groupings</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1299"><a href="#L-1299"><span class="linenos">1299</span></a> -</span><span id="L-1300"><a href="#L-1300"><span class="linenos">1300</span></a> <span class="k">def</span> <span class="nf">having_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Having</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1301"><a href="#L-1301"><span class="linenos">1301</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))</span> -</span><span id="L-1302"><a href="#L-1302"><span class="linenos">1302</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'HAVING'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1244"><a href="#L-1244"><span class="linenos">1244</span></a> <span class="k">def</span> <span class="nf">update_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1245"><a href="#L-1245"><span class="linenos">1245</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-1246"><a href="#L-1246"><span class="linenos">1246</span></a> <span class="n">set_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1247"><a href="#L-1247"><span class="linenos">1247</span></a> <span class="n">from_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">)</span> +</span><span id="L-1248"><a href="#L-1248"><span class="linenos">1248</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> +</span><span id="L-1249"><a href="#L-1249"><span class="linenos">1249</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="L-1250"><a href="#L-1250"><span class="linenos">1250</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1251"><a href="#L-1251"><span class="linenos">1251</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="L-1252"><a href="#L-1252"><span class="linenos">1252</span></a> +</span><span id="L-1253"><a href="#L-1253"><span class="linenos">1253</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1254"><a href="#L-1254"><span class="linenos">1254</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-1255"><a href="#L-1255"><span class="linenos">1255</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="L-1256"><a href="#L-1256"><span class="linenos">1256</span></a> <span class="n">values</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"VALUES</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1257"><a href="#L-1257"><span class="linenos">1257</span></a> <span class="n">values</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-1258"><a href="#L-1258"><span class="linenos">1258</span></a> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">values</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1259"><a href="#L-1259"><span class="linenos">1259</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">WRAP_DERIVED_VALUES</span> <span class="ow">and</span> <span class="p">(</span><span class="n">alias</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">))</span> +</span><span id="L-1260"><a href="#L-1260"><span class="linenos">1260</span></a> <span class="k">else</span> <span class="n">values</span> +</span><span id="L-1261"><a href="#L-1261"><span class="linenos">1261</span></a> <span class="p">)</span> +</span><span id="L-1262"><a href="#L-1262"><span class="linenos">1262</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">values</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">values</span> +</span><span id="L-1263"><a href="#L-1263"><span class="linenos">1263</span></a> +</span><span id="L-1264"><a href="#L-1264"><span class="linenos">1264</span></a> <span class="k">def</span> <span class="nf">var_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Var</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1265"><a href="#L-1265"><span class="linenos">1265</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-1266"><a href="#L-1266"><span class="linenos">1266</span></a> +</span><span id="L-1267"><a href="#L-1267"><span class="linenos">1267</span></a> <span class="k">def</span> <span class="nf">into_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Into</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1268"><a href="#L-1268"><span class="linenos">1268</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1269"><a href="#L-1269"><span class="linenos">1269</span></a> <span class="n">unlogged</span> <span class="o">=</span> <span class="s2">" UNLOGGED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unlogged"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1270"><a href="#L-1270"><span class="linenos">1270</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'INTO'</span><span class="p">)</span><span class="si">}{</span><span class="n">temporary</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="n">unlogged</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1271"><a href="#L-1271"><span class="linenos">1271</span></a> +</span><span id="L-1272"><a href="#L-1272"><span class="linenos">1272</span></a> <span class="k">def</span> <span class="nf">from_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1273"><a href="#L-1273"><span class="linenos">1273</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'FROM'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1274"><a href="#L-1274"><span class="linenos">1274</span></a> +</span><span id="L-1275"><a href="#L-1275"><span class="linenos">1275</span></a> <span class="k">def</span> <span class="nf">group_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Group</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1276"><a href="#L-1276"><span class="linenos">1276</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"GROUP BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-1277"><a href="#L-1277"><span class="linenos">1277</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"grouping_sets"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-1278"><a href="#L-1278"><span class="linenos">1278</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-1279"><a href="#L-1279"><span class="linenos">1279</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'GROUPING SETS'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">grouping_sets</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">grouping_sets</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1280"><a href="#L-1280"><span class="linenos">1280</span></a> <span class="p">)</span> +</span><span id="L-1281"><a href="#L-1281"><span class="linenos">1281</span></a> +</span><span id="L-1282"><a href="#L-1282"><span class="linenos">1282</span></a> <span class="n">cube</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"cube"</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="L-1283"><a href="#L-1283"><span class="linenos">1283</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">cube</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-1284"><a href="#L-1284"><span class="linenos">1284</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'WITH CUBE'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1285"><a href="#L-1285"><span class="linenos">1285</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1286"><a href="#L-1286"><span class="linenos">1286</span></a> <span class="n">cube_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"cube"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-1287"><a href="#L-1287"><span class="linenos">1287</span></a> <span class="n">cube_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'CUBE'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">cube_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">cube_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1288"><a href="#L-1288"><span class="linenos">1288</span></a> +</span><span id="L-1289"><a href="#L-1289"><span class="linenos">1289</span></a> <span class="n">rollup</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"rollup"</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="L-1290"><a href="#L-1290"><span class="linenos">1290</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">rollup</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-1291"><a href="#L-1291"><span class="linenos">1291</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'WITH ROLLUP'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1292"><a href="#L-1292"><span class="linenos">1292</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1293"><a href="#L-1293"><span class="linenos">1293</span></a> <span class="n">rollup_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"rollup"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-1294"><a href="#L-1294"><span class="linenos">1294</span></a> <span class="n">rollup_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'ROLLUP'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">rollup_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">rollup_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1295"><a href="#L-1295"><span class="linenos">1295</span></a> +</span><span id="L-1296"><a href="#L-1296"><span class="linenos">1296</span></a> <span class="n">groupings</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span> +</span><span id="L-1297"><a href="#L-1297"><span class="linenos">1297</span></a> <span class="n">grouping_sets</span><span class="p">,</span> +</span><span id="L-1298"><a href="#L-1298"><span class="linenos">1298</span></a> <span class="n">cube_sql</span><span class="p">,</span> +</span><span id="L-1299"><a href="#L-1299"><span class="linenos">1299</span></a> <span class="n">rollup_sql</span><span class="p">,</span> +</span><span id="L-1300"><a href="#L-1300"><span class="linenos">1300</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WITH TOTALS"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"totals"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="L-1301"><a href="#L-1301"><span class="linenos">1301</span></a> <span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="p">,</span> +</span><span id="L-1302"><a href="#L-1302"><span class="linenos">1302</span></a> <span class="p">)</span> </span><span id="L-1303"><a href="#L-1303"><span class="linenos">1303</span></a> -</span><span id="L-1304"><a href="#L-1304"><span class="linenos">1304</span></a> <span class="k">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-1305"><a href="#L-1305"><span class="linenos">1305</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="L-1306"><a href="#L-1306"><span class="linenos">1306</span></a> <span class="n">op</span> -</span><span id="L-1307"><a href="#L-1307"><span class="linenos">1307</span></a> <span class="k">for</span> <span class="n">op</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="L-1308"><a href="#L-1308"><span class="linenos">1308</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">method</span><span class="p">,</span> -</span><span id="L-1309"><a href="#L-1309"><span class="linenos">1309</span></a> <span class="s2">"GLOBAL"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-1310"><a href="#L-1310"><span class="linenos">1310</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">side</span><span class="p">,</span> -</span><span id="L-1311"><a href="#L-1311"><span class="linenos">1311</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">kind</span><span class="p">,</span> -</span><span id="L-1312"><a href="#L-1312"><span class="linenos">1312</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">hint</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">JOIN_HINTS</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-1313"><a href="#L-1313"><span class="linenos">1313</span></a> <span class="p">)</span> -</span><span id="L-1314"><a href="#L-1314"><span class="linenos">1314</span></a> <span class="k">if</span> <span class="n">op</span> -</span><span id="L-1315"><a href="#L-1315"><span class="linenos">1315</span></a> <span class="p">)</span> -</span><span id="L-1316"><a href="#L-1316"><span class="linenos">1316</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">)</span> -</span><span id="L-1317"><a href="#L-1317"><span class="linenos">1317</span></a> <span class="n">using</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"using"</span><span class="p">)</span> -</span><span id="L-1318"><a href="#L-1318"><span class="linenos">1318</span></a> -</span><span id="L-1319"><a href="#L-1319"><span class="linenos">1319</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">on_sql</span> <span class="ow">and</span> <span class="n">using</span><span class="p">:</span> -</span><span id="L-1320"><a href="#L-1320"><span class="linenos">1320</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span><span class="o">*</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">column</span><span class="p">)</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">using</span><span class="p">))</span> -</span><span id="L-1321"><a href="#L-1321"><span class="linenos">1321</span></a> -</span><span id="L-1322"><a href="#L-1322"><span class="linenos">1322</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-1323"><a href="#L-1323"><span class="linenos">1323</span></a> -</span><span id="L-1324"><a href="#L-1324"><span class="linenos">1324</span></a> <span class="k">if</span> <span class="n">on_sql</span><span class="p">:</span> -</span><span id="L-1325"><a href="#L-1325"><span class="linenos">1325</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">on_sql</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1326"><a href="#L-1326"><span class="linenos">1326</span></a> <span class="n">space</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="L-1327"><a href="#L-1327"><span class="linenos">1327</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> -</span><span id="L-1328"><a href="#L-1328"><span class="linenos">1328</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">USING (</span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1329"><a href="#L-1329"><span class="linenos">1329</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1330"><a href="#L-1330"><span class="linenos">1330</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1331"><a href="#L-1331"><span class="linenos">1331</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">op_sql</span><span class="p">:</span> -</span><span id="L-1332"><a href="#L-1332"><span class="linenos">1332</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1333"><a href="#L-1333"><span class="linenos">1333</span></a> -</span><span id="L-1334"><a href="#L-1334"><span class="linenos">1334</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</span><span class="si">}</span><span class="s2"> JOIN"</span> <span class="k">if</span> <span class="n">op_sql</span> <span class="k">else</span> <span class="s2">"JOIN"</span> -</span><span id="L-1335"><a href="#L-1335"><span class="linenos">1335</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op_sql</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1336"><a href="#L-1336"><span class="linenos">1336</span></a> -</span><span id="L-1337"><a href="#L-1337"><span class="linenos">1337</span></a> <span class="k">def</span> <span class="nf">lambda_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lambda</span><span class="p">,</span> <span class="n">arrow_sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"->"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1338"><a href="#L-1338"><span class="linenos">1338</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1339"><a href="#L-1339"><span class="linenos">1339</span></a> <span class="n">args</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">))</span> <span class="o">></span> <span class="mi">1</span> <span class="k">else</span> <span class="n">args</span> -</span><span id="L-1340"><a href="#L-1340"><span class="linenos">1340</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">arrow_sep</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1341"><a href="#L-1341"><span class="linenos">1341</span></a> -</span><span id="L-1342"><a href="#L-1342"><span class="linenos">1342</span></a> <span class="k">def</span> <span class="nf">lateral_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1343"><a href="#L-1343"><span class="linenos">1343</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1344"><a href="#L-1344"><span class="linenos">1344</span></a> -</span><span id="L-1345"><a href="#L-1345"><span class="linenos">1345</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">):</span> -</span><span id="L-1346"><a href="#L-1346"><span class="linenos">1346</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LATERAL </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1347"><a href="#L-1347"><span class="linenos">1347</span></a> -</span><span id="L-1348"><a href="#L-1348"><span class="linenos">1348</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"view"</span><span class="p">):</span> -</span><span id="L-1349"><a href="#L-1349"><span class="linenos">1349</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"alias"</span><span class="p">]</span> -</span><span id="L-1350"><a href="#L-1350"><span class="linenos">1350</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1351"><a href="#L-1351"><span class="linenos">1351</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">alias</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1352"><a href="#L-1352"><span class="linenos">1352</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1353"><a href="#L-1353"><span class="linenos">1353</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"LATERAL VIEW</span><span class="si">{</span><span class="s1">' OUTER'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'outer'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-1354"><a href="#L-1354"><span class="linenos">1354</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1355"><a href="#L-1355"><span class="linenos">1355</span></a> -</span><span id="L-1356"><a href="#L-1356"><span class="linenos">1356</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="L-1357"><a href="#L-1357"><span class="linenos">1357</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1358"><a href="#L-1358"><span class="linenos">1358</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LATERAL </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1359"><a href="#L-1359"><span class="linenos">1359</span></a> -</span><span id="L-1360"><a href="#L-1360"><span class="linenos">1360</span></a> <span class="k">def</span> <span class="nf">limit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1361"><a href="#L-1361"><span class="linenos">1361</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1362"><a href="#L-1362"><span class="linenos">1362</span></a> <span class="n">args</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="L-1363"><a href="#L-1363"><span class="linenos">1363</span></a> <span class="n">sql</span> -</span><span id="L-1364"><a href="#L-1364"><span class="linenos">1364</span></a> <span class="k">for</span> <span class="n">sql</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="L-1365"><a href="#L-1365"><span class="linenos">1365</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> -</span><span id="L-1366"><a href="#L-1366"><span class="linenos">1366</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">),</span> -</span><span id="L-1367"><a href="#L-1367"><span class="linenos">1367</span></a> <span class="p">)</span> -</span><span id="L-1368"><a href="#L-1368"><span class="linenos">1368</span></a> <span class="k">if</span> <span class="n">sql</span> -</span><span id="L-1369"><a href="#L-1369"><span class="linenos">1369</span></a> <span class="p">)</span> -</span><span id="L-1370"><a href="#L-1370"><span class="linenos">1370</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'LIMIT'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1371"><a href="#L-1371"><span class="linenos">1371</span></a> -</span><span id="L-1372"><a href="#L-1372"><span class="linenos">1372</span></a> <span class="k">def</span> <span class="nf">offset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Offset</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1373"><a href="#L-1373"><span class="linenos">1373</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1374"><a href="#L-1374"><span class="linenos">1374</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'OFFSET'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1375"><a href="#L-1375"><span class="linenos">1375</span></a> -</span><span id="L-1376"><a href="#L-1376"><span class="linenos">1376</span></a> <span class="k">def</span> <span class="nf">setitem_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetItem</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1377"><a href="#L-1377"><span class="linenos">1377</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="L-1378"><a href="#L-1378"><span class="linenos">1378</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1379"><a href="#L-1379"><span class="linenos">1379</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1380"><a href="#L-1380"><span class="linenos">1380</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-1381"><a href="#L-1381"><span class="linenos">1381</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collate"</span><span class="p">)</span> -</span><span id="L-1382"><a href="#L-1382"><span class="linenos">1382</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collate</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1383"><a href="#L-1383"><span class="linenos">1383</span></a> <span class="n">global_</span> <span class="o">=</span> <span class="s2">"GLOBAL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1384"><a href="#L-1384"><span class="linenos">1384</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">global_</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1385"><a href="#L-1385"><span class="linenos">1385</span></a> -</span><span id="L-1386"><a href="#L-1386"><span class="linenos">1386</span></a> <span class="k">def</span> <span class="nf">set_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1387"><a href="#L-1387"><span class="linenos">1387</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-1388"><a href="#L-1388"><span class="linenos">1388</span></a> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1389"><a href="#L-1389"><span class="linenos">1389</span></a> <span class="p">)</span> -</span><span id="L-1390"><a href="#L-1390"><span class="linenos">1390</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SET</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1391"><a href="#L-1391"><span class="linenos">1391</span></a> -</span><span id="L-1392"><a href="#L-1392"><span class="linenos">1392</span></a> <span class="k">def</span> <span class="nf">pragma_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pragma</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1393"><a href="#L-1393"><span class="linenos">1393</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRAGMA </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1304"><a href="#L-1304"><span class="linenos">1304</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> <span class="ow">and</span> <span class="n">groupings</span><span class="p">:</span> +</span><span id="L-1305"><a href="#L-1305"><span class="linenos">1305</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1306"><a href="#L-1306"><span class="linenos">1306</span></a> +</span><span id="L-1307"><a href="#L-1307"><span class="linenos">1307</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="n">groupings</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1308"><a href="#L-1308"><span class="linenos">1308</span></a> +</span><span id="L-1309"><a href="#L-1309"><span class="linenos">1309</span></a> <span class="k">def</span> <span class="nf">having_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Having</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1310"><a href="#L-1310"><span class="linenos">1310</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))</span> +</span><span id="L-1311"><a href="#L-1311"><span class="linenos">1311</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'HAVING'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1312"><a href="#L-1312"><span class="linenos">1312</span></a> +</span><span id="L-1313"><a href="#L-1313"><span class="linenos">1313</span></a> <span class="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-1314"><a href="#L-1314"><span class="linenos">1314</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="L-1315"><a href="#L-1315"><span class="linenos">1315</span></a> <span class="n">op</span> +</span><span id="L-1316"><a href="#L-1316"><span class="linenos">1316</span></a> <span class="k">for</span> <span class="n">op</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="L-1317"><a href="#L-1317"><span class="linenos">1317</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">method</span><span class="p">,</span> +</span><span id="L-1318"><a href="#L-1318"><span class="linenos">1318</span></a> <span class="s2">"GLOBAL"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-1319"><a href="#L-1319"><span class="linenos">1319</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">side</span><span class="p">,</span> +</span><span id="L-1320"><a href="#L-1320"><span class="linenos">1320</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">kind</span><span class="p">,</span> +</span><span id="L-1321"><a href="#L-1321"><span class="linenos">1321</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">hint</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">JOIN_HINTS</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-1322"><a href="#L-1322"><span class="linenos">1322</span></a> <span class="p">)</span> +</span><span id="L-1323"><a href="#L-1323"><span class="linenos">1323</span></a> <span class="k">if</span> <span class="n">op</span> +</span><span id="L-1324"><a href="#L-1324"><span class="linenos">1324</span></a> <span class="p">)</span> +</span><span id="L-1325"><a href="#L-1325"><span class="linenos">1325</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">)</span> +</span><span id="L-1326"><a href="#L-1326"><span class="linenos">1326</span></a> <span class="n">using</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"using"</span><span class="p">)</span> +</span><span id="L-1327"><a href="#L-1327"><span class="linenos">1327</span></a> +</span><span id="L-1328"><a href="#L-1328"><span class="linenos">1328</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">on_sql</span> <span class="ow">and</span> <span class="n">using</span><span class="p">:</span> +</span><span id="L-1329"><a href="#L-1329"><span class="linenos">1329</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span><span class="o">*</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">column</span><span class="p">)</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">using</span><span class="p">))</span> +</span><span id="L-1330"><a href="#L-1330"><span class="linenos">1330</span></a> +</span><span id="L-1331"><a href="#L-1331"><span class="linenos">1331</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-1332"><a href="#L-1332"><span class="linenos">1332</span></a> +</span><span id="L-1333"><a href="#L-1333"><span class="linenos">1333</span></a> <span class="k">if</span> <span class="n">on_sql</span><span class="p">:</span> +</span><span id="L-1334"><a href="#L-1334"><span class="linenos">1334</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">on_sql</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1335"><a href="#L-1335"><span class="linenos">1335</span></a> <span class="n">space</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="L-1336"><a href="#L-1336"><span class="linenos">1336</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> +</span><span id="L-1337"><a href="#L-1337"><span class="linenos">1337</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">USING (</span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1338"><a href="#L-1338"><span class="linenos">1338</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1339"><a href="#L-1339"><span class="linenos">1339</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1340"><a href="#L-1340"><span class="linenos">1340</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">op_sql</span><span class="p">:</span> +</span><span id="L-1341"><a href="#L-1341"><span class="linenos">1341</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1342"><a href="#L-1342"><span class="linenos">1342</span></a> +</span><span id="L-1343"><a href="#L-1343"><span class="linenos">1343</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</span><span class="si">}</span><span class="s2"> JOIN"</span> <span class="k">if</span> <span class="n">op_sql</span> <span class="k">else</span> <span class="s2">"JOIN"</span> +</span><span id="L-1344"><a href="#L-1344"><span class="linenos">1344</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op_sql</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1345"><a href="#L-1345"><span class="linenos">1345</span></a> +</span><span id="L-1346"><a href="#L-1346"><span class="linenos">1346</span></a> <span class="k">def</span> <span class="nf">lambda_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lambda</span><span class="p">,</span> <span class="n">arrow_sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"->"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1347"><a href="#L-1347"><span class="linenos">1347</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1348"><a href="#L-1348"><span class="linenos">1348</span></a> <span class="n">args</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">))</span> <span class="o">></span> <span class="mi">1</span> <span class="k">else</span> <span class="n">args</span> +</span><span id="L-1349"><a href="#L-1349"><span class="linenos">1349</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">arrow_sep</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1350"><a href="#L-1350"><span class="linenos">1350</span></a> +</span><span id="L-1351"><a href="#L-1351"><span class="linenos">1351</span></a> <span class="k">def</span> <span class="nf">lateral_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1352"><a href="#L-1352"><span class="linenos">1352</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1353"><a href="#L-1353"><span class="linenos">1353</span></a> +</span><span id="L-1354"><a href="#L-1354"><span class="linenos">1354</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">):</span> +</span><span id="L-1355"><a href="#L-1355"><span class="linenos">1355</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LATERAL </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1356"><a href="#L-1356"><span class="linenos">1356</span></a> +</span><span id="L-1357"><a href="#L-1357"><span class="linenos">1357</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"view"</span><span class="p">):</span> +</span><span id="L-1358"><a href="#L-1358"><span class="linenos">1358</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"alias"</span><span class="p">]</span> +</span><span id="L-1359"><a href="#L-1359"><span class="linenos">1359</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1360"><a href="#L-1360"><span class="linenos">1360</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">alias</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1361"><a href="#L-1361"><span class="linenos">1361</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1362"><a href="#L-1362"><span class="linenos">1362</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"LATERAL VIEW</span><span class="si">{</span><span class="s1">' OUTER'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'outer'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-1363"><a href="#L-1363"><span class="linenos">1363</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1364"><a href="#L-1364"><span class="linenos">1364</span></a> +</span><span id="L-1365"><a href="#L-1365"><span class="linenos">1365</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="L-1366"><a href="#L-1366"><span class="linenos">1366</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1367"><a href="#L-1367"><span class="linenos">1367</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LATERAL </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1368"><a href="#L-1368"><span class="linenos">1368</span></a> +</span><span id="L-1369"><a href="#L-1369"><span class="linenos">1369</span></a> <span class="k">def</span> <span class="nf">limit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1370"><a href="#L-1370"><span class="linenos">1370</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1371"><a href="#L-1371"><span class="linenos">1371</span></a> <span class="n">args</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="L-1372"><a href="#L-1372"><span class="linenos">1372</span></a> <span class="n">sql</span> +</span><span id="L-1373"><a href="#L-1373"><span class="linenos">1373</span></a> <span class="k">for</span> <span class="n">sql</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="L-1374"><a href="#L-1374"><span class="linenos">1374</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> +</span><span id="L-1375"><a href="#L-1375"><span class="linenos">1375</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">),</span> +</span><span id="L-1376"><a href="#L-1376"><span class="linenos">1376</span></a> <span class="p">)</span> +</span><span id="L-1377"><a href="#L-1377"><span class="linenos">1377</span></a> <span class="k">if</span> <span class="n">sql</span> +</span><span id="L-1378"><a href="#L-1378"><span class="linenos">1378</span></a> <span class="p">)</span> +</span><span id="L-1379"><a href="#L-1379"><span class="linenos">1379</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'LIMIT'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1380"><a href="#L-1380"><span class="linenos">1380</span></a> +</span><span id="L-1381"><a href="#L-1381"><span class="linenos">1381</span></a> <span class="k">def</span> <span class="nf">offset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Offset</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1382"><a href="#L-1382"><span class="linenos">1382</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1383"><a href="#L-1383"><span class="linenos">1383</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'OFFSET'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1384"><a href="#L-1384"><span class="linenos">1384</span></a> +</span><span id="L-1385"><a href="#L-1385"><span class="linenos">1385</span></a> <span class="k">def</span> <span class="nf">setitem_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetItem</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1386"><a href="#L-1386"><span class="linenos">1386</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="L-1387"><a href="#L-1387"><span class="linenos">1387</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1388"><a href="#L-1388"><span class="linenos">1388</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1389"><a href="#L-1389"><span class="linenos">1389</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-1390"><a href="#L-1390"><span class="linenos">1390</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collate"</span><span class="p">)</span> +</span><span id="L-1391"><a href="#L-1391"><span class="linenos">1391</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collate</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1392"><a href="#L-1392"><span class="linenos">1392</span></a> <span class="n">global_</span> <span class="o">=</span> <span class="s2">"GLOBAL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1393"><a href="#L-1393"><span class="linenos">1393</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">global_</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-1394"><a href="#L-1394"><span class="linenos">1394</span></a> -</span><span id="L-1395"><a href="#L-1395"><span class="linenos">1395</span></a> <span class="k">def</span> <span class="nf">lock_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lock</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1396"><a href="#L-1396"><span class="linenos">1396</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOCKING_READS_SUPPORTED</span><span class="p">:</span> -</span><span id="L-1397"><a href="#L-1397"><span class="linenos">1397</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Locking reads using 'FOR UPDATE/SHARE' are not supported"</span><span class="p">)</span> -</span><span id="L-1398"><a href="#L-1398"><span class="linenos">1398</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="L-1399"><a href="#L-1399"><span class="linenos">1399</span></a> -</span><span id="L-1400"><a href="#L-1400"><span class="linenos">1400</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"FOR UPDATE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"update"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"FOR SHARE"</span> -</span><span id="L-1401"><a href="#L-1401"><span class="linenos">1401</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1402"><a href="#L-1402"><span class="linenos">1402</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OF </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1403"><a href="#L-1403"><span class="linenos">1403</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"wait"</span><span class="p">)</span> -</span><span id="L-1404"><a href="#L-1404"><span class="linenos">1404</span></a> -</span><span id="L-1405"><a href="#L-1405"><span class="linenos">1405</span></a> <span class="k">if</span> <span class="n">wait</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-1406"><a href="#L-1406"><span class="linenos">1406</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">wait</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> -</span><span id="L-1407"><a href="#L-1407"><span class="linenos">1407</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WAIT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">wait</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1408"><a href="#L-1408"><span class="linenos">1408</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1409"><a href="#L-1409"><span class="linenos">1409</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="s2">" NOWAIT"</span> <span class="k">if</span> <span class="n">wait</span> <span class="k">else</span> <span class="s2">" SKIP LOCKED"</span> -</span><span id="L-1410"><a href="#L-1410"><span class="linenos">1410</span></a> -</span><span id="L-1411"><a href="#L-1411"><span class="linenos">1411</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">wait</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1412"><a href="#L-1412"><span class="linenos">1412</span></a> -</span><span id="L-1413"><a href="#L-1413"><span class="linenos">1413</span></a> <span class="k">def</span> <span class="nf">literal_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1414"><a href="#L-1414"><span class="linenos">1414</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">or</span> <span class="s2">""</span> -</span><span id="L-1415"><a href="#L-1415"><span class="linenos">1415</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> -</span><span id="L-1416"><a href="#L-1416"><span class="linenos">1416</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">)</span> -</span><span id="L-1417"><a href="#L-1417"><span class="linenos">1417</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="L-1418"><a href="#L-1418"><span class="linenos">1418</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">)</span> -</span><span id="L-1419"><a href="#L-1419"><span class="linenos">1419</span></a> <span class="n">text</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="n">text</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1420"><a href="#L-1420"><span class="linenos">1420</span></a> <span class="k">return</span> <span class="n">text</span> +</span><span id="L-1395"><a href="#L-1395"><span class="linenos">1395</span></a> <span class="k">def</span> <span class="nf">set_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1396"><a href="#L-1396"><span class="linenos">1396</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-1397"><a href="#L-1397"><span class="linenos">1397</span></a> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1398"><a href="#L-1398"><span class="linenos">1398</span></a> <span class="p">)</span> +</span><span id="L-1399"><a href="#L-1399"><span class="linenos">1399</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SET</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1400"><a href="#L-1400"><span class="linenos">1400</span></a> +</span><span id="L-1401"><a href="#L-1401"><span class="linenos">1401</span></a> <span class="k">def</span> <span class="nf">pragma_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pragma</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1402"><a href="#L-1402"><span class="linenos">1402</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRAGMA </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1403"><a href="#L-1403"><span class="linenos">1403</span></a> +</span><span id="L-1404"><a href="#L-1404"><span class="linenos">1404</span></a> <span class="k">def</span> <span class="nf">lock_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lock</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1405"><a href="#L-1405"><span class="linenos">1405</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOCKING_READS_SUPPORTED</span><span class="p">:</span> +</span><span id="L-1406"><a href="#L-1406"><span class="linenos">1406</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Locking reads using 'FOR UPDATE/SHARE' are not supported"</span><span class="p">)</span> +</span><span id="L-1407"><a href="#L-1407"><span class="linenos">1407</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-1408"><a href="#L-1408"><span class="linenos">1408</span></a> +</span><span id="L-1409"><a href="#L-1409"><span class="linenos">1409</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"FOR UPDATE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"update"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"FOR SHARE"</span> +</span><span id="L-1410"><a href="#L-1410"><span class="linenos">1410</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1411"><a href="#L-1411"><span class="linenos">1411</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OF </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1412"><a href="#L-1412"><span class="linenos">1412</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"wait"</span><span class="p">)</span> +</span><span id="L-1413"><a href="#L-1413"><span class="linenos">1413</span></a> +</span><span id="L-1414"><a href="#L-1414"><span class="linenos">1414</span></a> <span class="k">if</span> <span class="n">wait</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-1415"><a href="#L-1415"><span class="linenos">1415</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">wait</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> +</span><span id="L-1416"><a href="#L-1416"><span class="linenos">1416</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WAIT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">wait</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1417"><a href="#L-1417"><span class="linenos">1417</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1418"><a href="#L-1418"><span class="linenos">1418</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="s2">" NOWAIT"</span> <span class="k">if</span> <span class="n">wait</span> <span class="k">else</span> <span class="s2">" SKIP LOCKED"</span> +</span><span id="L-1419"><a href="#L-1419"><span class="linenos">1419</span></a> +</span><span id="L-1420"><a href="#L-1420"><span class="linenos">1420</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">wait</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-1421"><a href="#L-1421"><span class="linenos">1421</span></a> -</span><span id="L-1422"><a href="#L-1422"><span class="linenos">1422</span></a> <span class="k">def</span> <span class="nf">loaddata_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LoadData</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1423"><a href="#L-1423"><span class="linenos">1423</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">" LOCAL"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1424"><a href="#L-1424"><span class="linenos">1424</span></a> <span class="n">inpath</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPATH </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'inpath'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1425"><a href="#L-1425"><span class="linenos">1425</span></a> <span class="n">overwrite</span> <span class="o">=</span> <span class="s2">" OVERWRITE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"overwrite"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1426"><a href="#L-1426"><span class="linenos">1426</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INTO TABLE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1427"><a href="#L-1427"><span class="linenos">1427</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"partition"</span><span class="p">)</span> -</span><span id="L-1428"><a href="#L-1428"><span class="linenos">1428</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1429"><a href="#L-1429"><span class="linenos">1429</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> -</span><span id="L-1430"><a href="#L-1430"><span class="linenos">1430</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1431"><a href="#L-1431"><span class="linenos">1431</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"serde"</span><span class="p">)</span> -</span><span id="L-1432"><a href="#L-1432"><span class="linenos">1432</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" SERDE </span><span class="si">{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">serde</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1433"><a href="#L-1433"><span class="linenos">1433</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOAD DATA</span><span class="si">{</span><span class="n">local</span><span class="si">}{</span><span class="n">inpath</span><span class="si">}{</span><span class="n">overwrite</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">partition</span><span class="si">}{</span><span class="n">input_format</span><span class="si">}{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1434"><a href="#L-1434"><span class="linenos">1434</span></a> -</span><span id="L-1435"><a href="#L-1435"><span class="linenos">1435</span></a> <span class="k">def</span> <span class="nf">null_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1436"><a href="#L-1436"><span class="linenos">1436</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> -</span><span id="L-1437"><a href="#L-1437"><span class="linenos">1437</span></a> -</span><span id="L-1438"><a href="#L-1438"><span class="linenos">1438</span></a> <span class="k">def</span> <span class="nf">boolean_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Boolean</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1439"><a href="#L-1439"><span class="linenos">1439</span></a> <span class="k">return</span> <span class="s2">"TRUE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">"FALSE"</span> -</span><span id="L-1440"><a href="#L-1440"><span class="linenos">1440</span></a> -</span><span id="L-1441"><a href="#L-1441"><span class="linenos">1441</span></a> <span class="k">def</span> <span class="nf">order_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">,</span> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1442"><a href="#L-1442"><span class="linenos">1442</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1443"><a href="#L-1443"><span class="linenos">1443</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="n">this</span> -</span><span id="L-1444"><a href="#L-1444"><span class="linenos">1444</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">ORDER BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="n">this</span> <span class="ow">or</span> <span class="n">flat</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="L-1445"><a href="#L-1445"><span class="linenos">1445</span></a> -</span><span id="L-1446"><a href="#L-1446"><span class="linenos">1446</span></a> <span class="k">def</span> <span class="nf">cluster_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1447"><a href="#L-1447"><span class="linenos">1447</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"CLUSTER BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-1448"><a href="#L-1448"><span class="linenos">1448</span></a> -</span><span id="L-1449"><a href="#L-1449"><span class="linenos">1449</span></a> <span class="k">def</span> <span class="nf">distribute_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distribute</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1450"><a href="#L-1450"><span class="linenos">1450</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"DISTRIBUTE BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-1451"><a href="#L-1451"><span class="linenos">1451</span></a> -</span><span id="L-1452"><a href="#L-1452"><span class="linenos">1452</span></a> <span class="k">def</span> <span class="nf">sort_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1453"><a href="#L-1453"><span class="linenos">1453</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"SORT BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-1454"><a href="#L-1454"><span class="linenos">1454</span></a> -</span><span id="L-1455"><a href="#L-1455"><span class="linenos">1455</span></a> <span class="k">def</span> <span class="nf">ordered_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1456"><a href="#L-1456"><span class="linenos">1456</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"desc"</span><span class="p">)</span> -</span><span id="L-1457"><a href="#L-1457"><span class="linenos">1457</span></a> <span class="n">asc</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">desc</span> -</span><span id="L-1458"><a href="#L-1458"><span class="linenos">1458</span></a> -</span><span id="L-1459"><a href="#L-1459"><span class="linenos">1459</span></a> <span class="n">nulls_first</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nulls_first"</span><span class="p">)</span> -</span><span id="L-1460"><a href="#L-1460"><span class="linenos">1460</span></a> <span class="n">nulls_last</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">nulls_first</span> -</span><span id="L-1461"><a href="#L-1461"><span class="linenos">1461</span></a> <span class="n">nulls_are_large</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_large"</span> -</span><span id="L-1462"><a href="#L-1462"><span class="linenos">1462</span></a> <span class="n">nulls_are_small</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_small"</span> -</span><span id="L-1463"><a href="#L-1463"><span class="linenos">1463</span></a> <span class="n">nulls_are_last</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_last"</span> -</span><span id="L-1464"><a href="#L-1464"><span class="linenos">1464</span></a> -</span><span id="L-1465"><a href="#L-1465"><span class="linenos">1465</span></a> <span class="n">sort_order</span> <span class="o">=</span> <span class="s2">" DESC"</span> <span class="k">if</span> <span class="n">desc</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1466"><a href="#L-1466"><span class="linenos">1466</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-1467"><a href="#L-1467"><span class="linenos">1467</span></a> <span class="k">if</span> <span class="n">nulls_first</span> <span class="ow">and</span> <span class="p">(</span> -</span><span id="L-1468"><a href="#L-1468"><span class="linenos">1468</span></a> <span class="p">(</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="n">nulls_are_last</span> -</span><span id="L-1469"><a href="#L-1469"><span class="linenos">1469</span></a> <span class="p">):</span> -</span><span id="L-1470"><a href="#L-1470"><span class="linenos">1470</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS FIRST"</span> -</span><span id="L-1471"><a href="#L-1471"><span class="linenos">1471</span></a> <span class="k">elif</span> <span class="p">(</span> -</span><span id="L-1472"><a href="#L-1472"><span class="linenos">1472</span></a> <span class="n">nulls_last</span> -</span><span id="L-1473"><a href="#L-1473"><span class="linenos">1473</span></a> <span class="ow">and</span> <span class="p">((</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">))</span> -</span><span id="L-1474"><a href="#L-1474"><span class="linenos">1474</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">nulls_are_last</span> -</span><span id="L-1475"><a href="#L-1475"><span class="linenos">1475</span></a> <span class="p">):</span> -</span><span id="L-1476"><a href="#L-1476"><span class="linenos">1476</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS LAST"</span> -</span><span id="L-1477"><a href="#L-1477"><span class="linenos">1477</span></a> -</span><span id="L-1478"><a href="#L-1478"><span class="linenos">1478</span></a> <span class="k">if</span> <span class="n">nulls_sort_change</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING_SUPPORTED</span><span class="p">:</span> -</span><span id="L-1479"><a href="#L-1479"><span class="linenos">1479</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span> -</span><span id="L-1480"><a href="#L-1480"><span class="linenos">1480</span></a> <span class="s2">"Sorting in an ORDER BY on NULLS FIRST/NULLS LAST is not supported by this dialect"</span> -</span><span id="L-1481"><a href="#L-1481"><span class="linenos">1481</span></a> <span class="p">)</span> -</span><span id="L-1482"><a href="#L-1482"><span class="linenos">1482</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-1483"><a href="#L-1483"><span class="linenos">1483</span></a> -</span><span id="L-1484"><a href="#L-1484"><span class="linenos">1484</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">sort_order</span><span class="si">}{</span><span class="n">nulls_sort_change</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1485"><a href="#L-1485"><span class="linenos">1485</span></a> -</span><span id="L-1486"><a href="#L-1486"><span class="linenos">1486</span></a> <span class="k">def</span> <span class="nf">matchrecognize_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1487"><a href="#L-1487"><span class="linenos">1487</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-1488"><a href="#L-1488"><span class="linenos">1488</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> -</span><span id="L-1489"><a href="#L-1489"><span class="linenos">1489</span></a> <span class="n">measures</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"measures"</span><span class="p">)</span> -</span><span id="L-1490"><a href="#L-1490"><span class="linenos">1490</span></a> <span class="n">measures</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"MEASURES</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">measures</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">measures</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1491"><a href="#L-1491"><span class="linenos">1491</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> -</span><span id="L-1492"><a href="#L-1492"><span class="linenos">1492</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">rows</span><span class="p">)</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1493"><a href="#L-1493"><span class="linenos">1493</span></a> <span class="n">after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"after"</span><span class="p">)</span> -</span><span id="L-1494"><a href="#L-1494"><span class="linenos">1494</span></a> <span class="n">after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">after</span><span class="p">)</span> <span class="k">if</span> <span class="n">after</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1495"><a href="#L-1495"><span class="linenos">1495</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"pattern"</span><span class="p">)</span> -</span><span id="L-1496"><a href="#L-1496"><span class="linenos">1496</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"PATTERN (</span><span class="si">{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">)"</span><span class="p">)</span> <span class="k">if</span> <span class="n">pattern</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1497"><a href="#L-1497"><span class="linenos">1497</span></a> <span class="n">definition_sqls</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="L-1498"><a href="#L-1498"><span class="linenos">1498</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">definition</span><span class="p">,</span><span class="w"> </span><span class="s1">'alias'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">definition</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1499"><a href="#L-1499"><span class="linenos">1499</span></a> <span class="k">for</span> <span class="n">definition</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"define"</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="L-1500"><a href="#L-1500"><span class="linenos">1500</span></a> <span class="p">]</span> -</span><span id="L-1501"><a href="#L-1501"><span class="linenos">1501</span></a> <span class="n">definitions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">sqls</span><span class="o">=</span><span class="n">definition_sqls</span><span class="p">)</span> -</span><span id="L-1502"><a href="#L-1502"><span class="linenos">1502</span></a> <span class="n">define</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"DEFINE</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">definitions</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">definitions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1503"><a href="#L-1503"><span class="linenos">1503</span></a> <span class="n">body</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="L-1504"><a href="#L-1504"><span class="linenos">1504</span></a> <span class="p">(</span> -</span><span id="L-1505"><a href="#L-1505"><span class="linenos">1505</span></a> <span class="n">partition</span><span class="p">,</span> -</span><span id="L-1506"><a href="#L-1506"><span class="linenos">1506</span></a> <span class="n">order</span><span class="p">,</span> -</span><span id="L-1507"><a href="#L-1507"><span class="linenos">1507</span></a> <span class="n">measures</span><span class="p">,</span> -</span><span id="L-1508"><a href="#L-1508"><span class="linenos">1508</span></a> <span class="n">rows</span><span class="p">,</span> -</span><span id="L-1509"><a href="#L-1509"><span class="linenos">1509</span></a> <span class="n">after</span><span class="p">,</span> -</span><span id="L-1510"><a href="#L-1510"><span class="linenos">1510</span></a> <span class="n">pattern</span><span class="p">,</span> -</span><span id="L-1511"><a href="#L-1511"><span class="linenos">1511</span></a> <span class="n">define</span><span class="p">,</span> -</span><span id="L-1512"><a href="#L-1512"><span class="linenos">1512</span></a> <span class="p">)</span> -</span><span id="L-1513"><a href="#L-1513"><span class="linenos">1513</span></a> <span class="p">)</span> -</span><span id="L-1514"><a href="#L-1514"><span class="linenos">1514</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="L-1515"><a href="#L-1515"><span class="linenos">1515</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1516"><a href="#L-1516"><span class="linenos">1516</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'MATCH_RECOGNIZE'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">body</span><span class="p">)</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1517"><a href="#L-1517"><span class="linenos">1517</span></a> -</span><span id="L-1518"><a href="#L-1518"><span class="linenos">1518</span></a> <span class="k">def</span> <span class="nf">query_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="o">*</span><span class="n">sqls</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1519"><a href="#L-1519"><span class="linenos">1519</span></a> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"limit"</span><span class="p">)</span> -</span><span id="L-1520"><a href="#L-1520"><span class="linenos">1520</span></a> -</span><span id="L-1521"><a href="#L-1521"><span class="linenos">1521</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"LIMIT"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">):</span> -</span><span id="L-1522"><a href="#L-1522"><span class="linenos">1522</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">limit</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"count"</span><span class="p">))</span> -</span><span id="L-1523"><a href="#L-1523"><span class="linenos">1523</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"FETCH"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">):</span> -</span><span id="L-1524"><a href="#L-1524"><span class="linenos">1524</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">(</span><span class="n">direction</span><span class="o">=</span><span class="s2">"FIRST"</span><span class="p">,</span> <span class="n">count</span><span class="o">=</span><span class="n">limit</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-1525"><a href="#L-1525"><span class="linenos">1525</span></a> -</span><span id="L-1526"><a href="#L-1526"><span class="linenos">1526</span></a> <span class="n">fetch</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> -</span><span id="L-1527"><a href="#L-1527"><span class="linenos">1527</span></a> -</span><span id="L-1528"><a href="#L-1528"><span class="linenos">1528</span></a> <span class="k">return</span> <span class="n">csv</span><span class="p">(</span> -</span><span id="L-1529"><a href="#L-1529"><span class="linenos">1529</span></a> <span class="o">*</span><span class="n">sqls</span><span class="p">,</span> -</span><span id="L-1530"><a href="#L-1530"><span class="linenos">1530</span></a> <span class="o">*</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">join</span><span class="p">)</span> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> -</span><span id="L-1531"><a href="#L-1531"><span class="linenos">1531</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"match"</span><span class="p">),</span> -</span><span id="L-1532"><a href="#L-1532"><span class="linenos">1532</span></a> <span class="o">*</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">lateral</span><span class="p">)</span> <span class="k">for</span> <span class="n">lateral</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"laterals"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> -</span><span id="L-1533"><a href="#L-1533"><span class="linenos">1533</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">),</span> -</span><span id="L-1534"><a href="#L-1534"><span class="linenos">1534</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">),</span> -</span><span id="L-1535"><a href="#L-1535"><span class="linenos">1535</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"having"</span><span class="p">),</span> -</span><span id="L-1536"><a href="#L-1536"><span class="linenos">1536</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> -</span><span id="L-1537"><a href="#L-1537"><span class="linenos">1537</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">),</span> -</span><span id="L-1538"><a href="#L-1538"><span class="linenos">1538</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">offset_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">,</span> <span class="n">limit</span><span class="p">),</span> -</span><span id="L-1539"><a href="#L-1539"><span class="linenos">1539</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> -</span><span id="L-1540"><a href="#L-1540"><span class="linenos">1540</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> -</span><span id="L-1541"><a href="#L-1541"><span class="linenos">1541</span></a> <span class="p">)</span> -</span><span id="L-1542"><a href="#L-1542"><span class="linenos">1542</span></a> -</span><span id="L-1543"><a href="#L-1543"><span class="linenos">1543</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> -</span><span id="L-1544"><a href="#L-1544"><span class="linenos">1544</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> -</span><span id="L-1545"><a href="#L-1545"><span class="linenos">1545</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="L-1546"><a href="#L-1546"><span class="linenos">1546</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="L-1547"><a href="#L-1547"><span class="linenos">1547</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> -</span><span id="L-1548"><a href="#L-1548"><span class="linenos">1548</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> -</span><span id="L-1549"><a href="#L-1549"><span class="linenos">1549</span></a> <span class="p">]</span> -</span><span id="L-1550"><a href="#L-1550"><span class="linenos">1550</span></a> -</span><span id="L-1551"><a href="#L-1551"><span class="linenos">1551</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="L-1552"><a href="#L-1552"><span class="linenos">1552</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="L-1553"><a href="#L-1553"><span class="linenos">1553</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"qualify"</span><span class="p">),</span> -</span><span id="L-1554"><a href="#L-1554"><span class="linenos">1554</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WINDOW "</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"windows"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1555"><a href="#L-1555"><span class="linenos">1555</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"windows"</span><span class="p">)</span> -</span><span id="L-1556"><a href="#L-1556"><span class="linenos">1556</span></a> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="L-1557"><a href="#L-1557"><span class="linenos">1557</span></a> <span class="p">]</span> -</span><span id="L-1558"><a href="#L-1558"><span class="linenos">1558</span></a> -</span><span id="L-1559"><a href="#L-1559"><span class="linenos">1559</span></a> <span class="k">def</span> <span class="nf">after_limit_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="L-1560"><a href="#L-1560"><span class="linenos">1560</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"locks"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="L-1561"><a href="#L-1561"><span class="linenos">1561</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">locks</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">locks</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1562"><a href="#L-1562"><span class="linenos">1562</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">locks</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"sample"</span><span class="p">)]</span> -</span><span id="L-1563"><a href="#L-1563"><span class="linenos">1563</span></a> -</span><span id="L-1564"><a href="#L-1564"><span class="linenos">1564</span></a> <span class="k">def</span> <span class="nf">select_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1565"><a href="#L-1565"><span class="linenos">1565</span></a> <span class="n">hint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"hint"</span><span class="p">)</span> -</span><span id="L-1566"><a href="#L-1566"><span class="linenos">1566</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distinct"</span><span class="p">)</span> -</span><span id="L-1567"><a href="#L-1567"><span class="linenos">1567</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">distinct</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">distinct</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1568"><a href="#L-1568"><span class="linenos">1568</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> -</span><span id="L-1569"><a href="#L-1569"><span class="linenos">1569</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1570"><a href="#L-1570"><span class="linenos">1570</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-1571"><a href="#L-1571"><span class="linenos">1571</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="n">expressions</span> -</span><span id="L-1572"><a href="#L-1572"><span class="linenos">1572</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> -</span><span id="L-1573"><a href="#L-1573"><span class="linenos">1573</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="L-1574"><a href="#L-1574"><span class="linenos">1574</span></a> <span class="sa">f</span><span class="s2">"SELECT</span><span class="si">{</span><span class="n">hint</span><span class="si">}{</span><span class="n">distinct</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-1575"><a href="#L-1575"><span class="linenos">1575</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"into"</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="L-1576"><a href="#L-1576"><span class="linenos">1576</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="L-1577"><a href="#L-1577"><span class="linenos">1577</span></a> <span class="p">)</span> -</span><span id="L-1578"><a href="#L-1578"><span class="linenos">1578</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="L-1579"><a href="#L-1579"><span class="linenos">1579</span></a> -</span><span id="L-1580"><a href="#L-1580"><span class="linenos">1580</span></a> <span class="k">def</span> <span class="nf">schema_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1581"><a href="#L-1581"><span class="linenos">1581</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1582"><a href="#L-1582"><span class="linenos">1582</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1583"><a href="#L-1583"><span class="linenos">1583</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-1584"><a href="#L-1584"><span class="linenos">1584</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1585"><a href="#L-1585"><span class="linenos">1585</span></a> -</span><span id="L-1586"><a href="#L-1586"><span class="linenos">1586</span></a> <span class="k">def</span> <span class="nf">schema_columns_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1587"><a href="#L-1587"><span class="linenos">1587</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1588"><a href="#L-1588"><span class="linenos">1588</span></a> -</span><span id="L-1589"><a href="#L-1589"><span class="linenos">1589</span></a> <span class="k">def</span> <span class="nf">star_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1590"><a href="#L-1590"><span class="linenos">1590</span></a> <span class="n">except_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"except"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1591"><a href="#L-1591"><span class="linenos">1591</span></a> <span class="n">except_</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'except'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">except_</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">except_</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1592"><a href="#L-1592"><span class="linenos">1592</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"replace"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1593"><a href="#L-1593"><span class="linenos">1593</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'replace'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">replace</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">replace</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1594"><a href="#L-1594"><span class="linenos">1594</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"*</span><span class="si">{</span><span class="n">except_</span><span class="si">}{</span><span class="n">replace</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1595"><a href="#L-1595"><span class="linenos">1595</span></a> -</span><span id="L-1596"><a href="#L-1596"><span class="linenos">1596</span></a> <span class="k">def</span> <span class="nf">parameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Parameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1597"><a href="#L-1597"><span class="linenos">1597</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1598"><a href="#L-1598"><span class="linenos">1598</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="se">{{</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="se">}}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"wrapped"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1599"><a href="#L-1599"><span class="linenos">1599</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">PARAMETER_TOKEN</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1600"><a href="#L-1600"><span class="linenos">1600</span></a> -</span><span id="L-1601"><a href="#L-1601"><span class="linenos">1601</span></a> <span class="k">def</span> <span class="nf">sessionparameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SessionParameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1602"><a href="#L-1602"><span class="linenos">1602</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1603"><a href="#L-1603"><span class="linenos">1603</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> -</span><span id="L-1604"><a href="#L-1604"><span class="linenos">1604</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="L-1605"><a href="#L-1605"><span class="linenos">1605</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">."</span> -</span><span id="L-1606"><a href="#L-1606"><span class="linenos">1606</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"@@</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1607"><a href="#L-1607"><span class="linenos">1607</span></a> -</span><span id="L-1608"><a href="#L-1608"><span class="linenos">1608</span></a> <span class="k">def</span> <span class="nf">placeholder_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Placeholder</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1609"><a href="#L-1609"><span class="linenos">1609</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">":</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">"?"</span> -</span><span id="L-1610"><a href="#L-1610"><span class="linenos">1610</span></a> -</span><span id="L-1611"><a href="#L-1611"><span class="linenos">1611</span></a> <span class="k">def</span> <span class="nf">subquery_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1612"><a href="#L-1612"><span class="linenos">1612</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="L-1613"><a href="#L-1613"><span class="linenos">1613</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1614"><a href="#L-1614"><span class="linenos">1614</span></a> -</span><span id="L-1615"><a href="#L-1615"><span class="linenos">1615</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1616"><a href="#L-1616"><span class="linenos">1616</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1617"><a href="#L-1617"><span class="linenos">1617</span></a> -</span><span id="L-1618"><a href="#L-1618"><span class="linenos">1618</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> <span class="n">alias</span><span class="p">,</span> <span class="n">pivots</span><span class="p">)</span> -</span><span id="L-1619"><a href="#L-1619"><span class="linenos">1619</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="L-1620"><a href="#L-1620"><span class="linenos">1620</span></a> -</span><span id="L-1621"><a href="#L-1621"><span class="linenos">1621</span></a> <span class="k">def</span> <span class="nf">qualify_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Qualify</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1622"><a href="#L-1622"><span class="linenos">1622</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))</span> -</span><span id="L-1623"><a href="#L-1623"><span class="linenos">1623</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'QUALIFY'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1624"><a href="#L-1624"><span class="linenos">1624</span></a> -</span><span id="L-1625"><a href="#L-1625"><span class="linenos">1625</span></a> <span class="k">def</span> <span class="nf">union_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1626"><a href="#L-1626"><span class="linenos">1626</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span> -</span><span id="L-1627"><a href="#L-1627"><span class="linenos">1627</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="L-1628"><a href="#L-1628"><span class="linenos">1628</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">union_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> -</span><span id="L-1629"><a href="#L-1629"><span class="linenos">1629</span></a> <span class="p">)</span> -</span><span id="L-1630"><a href="#L-1630"><span class="linenos">1630</span></a> -</span><span id="L-1631"><a href="#L-1631"><span class="linenos">1631</span></a> <span class="k">def</span> <span class="nf">union_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1632"><a href="#L-1632"><span class="linenos">1632</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">" DISTINCT"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPLICIT_UNION</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1633"><a href="#L-1633"><span class="linenos">1633</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">kind</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"distinct"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" ALL"</span> -</span><span id="L-1634"><a href="#L-1634"><span class="linenos">1634</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNION</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1635"><a href="#L-1635"><span class="linenos">1635</span></a> -</span><span id="L-1636"><a href="#L-1636"><span class="linenos">1636</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1637"><a href="#L-1637"><span class="linenos">1637</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1638"><a href="#L-1638"><span class="linenos">1638</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">)</span> -</span><span id="L-1639"><a href="#L-1639"><span class="linenos">1639</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> -</span><span id="L-1640"><a href="#L-1640"><span class="linenos">1640</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">alias</span><span class="o">.</span><span class="n">columns</span> -</span><span id="L-1641"><a href="#L-1641"><span class="linenos">1641</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">columns</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1642"><a href="#L-1642"><span class="linenos">1642</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1643"><a href="#L-1643"><span class="linenos">1643</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="L-1644"><a href="#L-1644"><span class="linenos">1644</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">alias</span> -</span><span id="L-1645"><a href="#L-1645"><span class="linenos">1645</span></a> <span class="n">ordinality</span> <span class="o">=</span> <span class="s2">" WITH ORDINALITY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ordinality"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1646"><a href="#L-1646"><span class="linenos">1646</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">)</span> -</span><span id="L-1647"><a href="#L-1647"><span class="linenos">1647</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH OFFSET AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">offset</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">offset</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1648"><a href="#L-1648"><span class="linenos">1648</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNNEST(</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">ordinality</span><span class="si">}{</span><span class="n">alias</span><span class="si">}{</span><span class="n">offset</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1649"><a href="#L-1649"><span class="linenos">1649</span></a> -</span><span id="L-1650"><a href="#L-1650"><span class="linenos">1650</span></a> <span class="k">def</span> <span class="nf">where_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1651"><a href="#L-1651"><span class="linenos">1651</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))</span> -</span><span id="L-1652"><a href="#L-1652"><span class="linenos">1652</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'WHERE'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1422"><a href="#L-1422"><span class="linenos">1422</span></a> <span class="k">def</span> <span class="nf">literal_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1423"><a href="#L-1423"><span class="linenos">1423</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">or</span> <span class="s2">""</span> +</span><span id="L-1424"><a href="#L-1424"><span class="linenos">1424</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> +</span><span id="L-1425"><a href="#L-1425"><span class="linenos">1425</span></a> <span class="n">text</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">text</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1426"><a href="#L-1426"><span class="linenos">1426</span></a> <span class="k">return</span> <span class="n">text</span> +</span><span id="L-1427"><a href="#L-1427"><span class="linenos">1427</span></a> +</span><span id="L-1428"><a href="#L-1428"><span class="linenos">1428</span></a> <span class="k">def</span> <span class="nf">escape_str</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1429"><a href="#L-1429"><span class="linenos">1429</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">)</span> +</span><span id="L-1430"><a href="#L-1430"><span class="linenos">1430</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="L-1431"><a href="#L-1431"><span class="linenos">1431</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">)</span> +</span><span id="L-1432"><a href="#L-1432"><span class="linenos">1432</span></a> <span class="k">return</span> <span class="n">text</span> +</span><span id="L-1433"><a href="#L-1433"><span class="linenos">1433</span></a> +</span><span id="L-1434"><a href="#L-1434"><span class="linenos">1434</span></a> <span class="k">def</span> <span class="nf">loaddata_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LoadData</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1435"><a href="#L-1435"><span class="linenos">1435</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">" LOCAL"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1436"><a href="#L-1436"><span class="linenos">1436</span></a> <span class="n">inpath</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPATH </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'inpath'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1437"><a href="#L-1437"><span class="linenos">1437</span></a> <span class="n">overwrite</span> <span class="o">=</span> <span class="s2">" OVERWRITE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"overwrite"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1438"><a href="#L-1438"><span class="linenos">1438</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INTO TABLE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1439"><a href="#L-1439"><span class="linenos">1439</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"partition"</span><span class="p">)</span> +</span><span id="L-1440"><a href="#L-1440"><span class="linenos">1440</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1441"><a href="#L-1441"><span class="linenos">1441</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> +</span><span id="L-1442"><a href="#L-1442"><span class="linenos">1442</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1443"><a href="#L-1443"><span class="linenos">1443</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"serde"</span><span class="p">)</span> +</span><span id="L-1444"><a href="#L-1444"><span class="linenos">1444</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" SERDE </span><span class="si">{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">serde</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1445"><a href="#L-1445"><span class="linenos">1445</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOAD DATA</span><span class="si">{</span><span class="n">local</span><span class="si">}{</span><span class="n">inpath</span><span class="si">}{</span><span class="n">overwrite</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">partition</span><span class="si">}{</span><span class="n">input_format</span><span class="si">}{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1446"><a href="#L-1446"><span class="linenos">1446</span></a> +</span><span id="L-1447"><a href="#L-1447"><span class="linenos">1447</span></a> <span class="k">def</span> <span class="nf">null_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1448"><a href="#L-1448"><span class="linenos">1448</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> +</span><span id="L-1449"><a href="#L-1449"><span class="linenos">1449</span></a> +</span><span id="L-1450"><a href="#L-1450"><span class="linenos">1450</span></a> <span class="k">def</span> <span class="nf">boolean_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Boolean</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1451"><a href="#L-1451"><span class="linenos">1451</span></a> <span class="k">return</span> <span class="s2">"TRUE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">"FALSE"</span> +</span><span id="L-1452"><a href="#L-1452"><span class="linenos">1452</span></a> +</span><span id="L-1453"><a href="#L-1453"><span class="linenos">1453</span></a> <span class="k">def</span> <span class="nf">order_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">,</span> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1454"><a href="#L-1454"><span class="linenos">1454</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1455"><a href="#L-1455"><span class="linenos">1455</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="n">this</span> +</span><span id="L-1456"><a href="#L-1456"><span class="linenos">1456</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">ORDER BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="n">this</span> <span class="ow">or</span> <span class="n">flat</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="L-1457"><a href="#L-1457"><span class="linenos">1457</span></a> +</span><span id="L-1458"><a href="#L-1458"><span class="linenos">1458</span></a> <span class="k">def</span> <span class="nf">cluster_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1459"><a href="#L-1459"><span class="linenos">1459</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"CLUSTER BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-1460"><a href="#L-1460"><span class="linenos">1460</span></a> +</span><span id="L-1461"><a href="#L-1461"><span class="linenos">1461</span></a> <span class="k">def</span> <span class="nf">distribute_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distribute</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1462"><a href="#L-1462"><span class="linenos">1462</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"DISTRIBUTE BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-1463"><a href="#L-1463"><span class="linenos">1463</span></a> +</span><span id="L-1464"><a href="#L-1464"><span class="linenos">1464</span></a> <span class="k">def</span> <span class="nf">sort_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1465"><a href="#L-1465"><span class="linenos">1465</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"SORT BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-1466"><a href="#L-1466"><span class="linenos">1466</span></a> +</span><span id="L-1467"><a href="#L-1467"><span class="linenos">1467</span></a> <span class="k">def</span> <span class="nf">ordered_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1468"><a href="#L-1468"><span class="linenos">1468</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"desc"</span><span class="p">)</span> +</span><span id="L-1469"><a href="#L-1469"><span class="linenos">1469</span></a> <span class="n">asc</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">desc</span> +</span><span id="L-1470"><a href="#L-1470"><span class="linenos">1470</span></a> +</span><span id="L-1471"><a href="#L-1471"><span class="linenos">1471</span></a> <span class="n">nulls_first</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nulls_first"</span><span class="p">)</span> +</span><span id="L-1472"><a href="#L-1472"><span class="linenos">1472</span></a> <span class="n">nulls_last</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">nulls_first</span> +</span><span id="L-1473"><a href="#L-1473"><span class="linenos">1473</span></a> <span class="n">nulls_are_large</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_large"</span> +</span><span id="L-1474"><a href="#L-1474"><span class="linenos">1474</span></a> <span class="n">nulls_are_small</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_small"</span> +</span><span id="L-1475"><a href="#L-1475"><span class="linenos">1475</span></a> <span class="n">nulls_are_last</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_last"</span> +</span><span id="L-1476"><a href="#L-1476"><span class="linenos">1476</span></a> +</span><span id="L-1477"><a href="#L-1477"><span class="linenos">1477</span></a> <span class="n">sort_order</span> <span class="o">=</span> <span class="s2">" DESC"</span> <span class="k">if</span> <span class="n">desc</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1478"><a href="#L-1478"><span class="linenos">1478</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-1479"><a href="#L-1479"><span class="linenos">1479</span></a> <span class="k">if</span> <span class="n">nulls_first</span> <span class="ow">and</span> <span class="p">(</span> +</span><span id="L-1480"><a href="#L-1480"><span class="linenos">1480</span></a> <span class="p">(</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="n">nulls_are_last</span> +</span><span id="L-1481"><a href="#L-1481"><span class="linenos">1481</span></a> <span class="p">):</span> +</span><span id="L-1482"><a href="#L-1482"><span class="linenos">1482</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS FIRST"</span> +</span><span id="L-1483"><a href="#L-1483"><span class="linenos">1483</span></a> <span class="k">elif</span> <span class="p">(</span> +</span><span id="L-1484"><a href="#L-1484"><span class="linenos">1484</span></a> <span class="n">nulls_last</span> +</span><span id="L-1485"><a href="#L-1485"><span class="linenos">1485</span></a> <span class="ow">and</span> <span class="p">((</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">))</span> +</span><span id="L-1486"><a href="#L-1486"><span class="linenos">1486</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">nulls_are_last</span> +</span><span id="L-1487"><a href="#L-1487"><span class="linenos">1487</span></a> <span class="p">):</span> +</span><span id="L-1488"><a href="#L-1488"><span class="linenos">1488</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS LAST"</span> +</span><span id="L-1489"><a href="#L-1489"><span class="linenos">1489</span></a> +</span><span id="L-1490"><a href="#L-1490"><span class="linenos">1490</span></a> <span class="k">if</span> <span class="n">nulls_sort_change</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING_SUPPORTED</span><span class="p">:</span> +</span><span id="L-1491"><a href="#L-1491"><span class="linenos">1491</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span> +</span><span id="L-1492"><a href="#L-1492"><span class="linenos">1492</span></a> <span class="s2">"Sorting in an ORDER BY on NULLS FIRST/NULLS LAST is not supported by this dialect"</span> +</span><span id="L-1493"><a href="#L-1493"><span class="linenos">1493</span></a> <span class="p">)</span> +</span><span id="L-1494"><a href="#L-1494"><span class="linenos">1494</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-1495"><a href="#L-1495"><span class="linenos">1495</span></a> +</span><span id="L-1496"><a href="#L-1496"><span class="linenos">1496</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">sort_order</span><span class="si">}{</span><span class="n">nulls_sort_change</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1497"><a href="#L-1497"><span class="linenos">1497</span></a> +</span><span id="L-1498"><a href="#L-1498"><span class="linenos">1498</span></a> <span class="k">def</span> <span class="nf">matchrecognize_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1499"><a href="#L-1499"><span class="linenos">1499</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-1500"><a href="#L-1500"><span class="linenos">1500</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> +</span><span id="L-1501"><a href="#L-1501"><span class="linenos">1501</span></a> <span class="n">measures</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"measures"</span><span class="p">)</span> +</span><span id="L-1502"><a href="#L-1502"><span class="linenos">1502</span></a> <span class="n">measures</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"MEASURES</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">measures</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">measures</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1503"><a href="#L-1503"><span class="linenos">1503</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> +</span><span id="L-1504"><a href="#L-1504"><span class="linenos">1504</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">rows</span><span class="p">)</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1505"><a href="#L-1505"><span class="linenos">1505</span></a> <span class="n">after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"after"</span><span class="p">)</span> +</span><span id="L-1506"><a href="#L-1506"><span class="linenos">1506</span></a> <span class="n">after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">after</span><span class="p">)</span> <span class="k">if</span> <span class="n">after</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1507"><a href="#L-1507"><span class="linenos">1507</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"pattern"</span><span class="p">)</span> +</span><span id="L-1508"><a href="#L-1508"><span class="linenos">1508</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"PATTERN (</span><span class="si">{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">)"</span><span class="p">)</span> <span class="k">if</span> <span class="n">pattern</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1509"><a href="#L-1509"><span class="linenos">1509</span></a> <span class="n">definition_sqls</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="L-1510"><a href="#L-1510"><span class="linenos">1510</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">definition</span><span class="p">,</span><span class="w"> </span><span class="s1">'alias'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">definition</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1511"><a href="#L-1511"><span class="linenos">1511</span></a> <span class="k">for</span> <span class="n">definition</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"define"</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="L-1512"><a href="#L-1512"><span class="linenos">1512</span></a> <span class="p">]</span> +</span><span id="L-1513"><a href="#L-1513"><span class="linenos">1513</span></a> <span class="n">definitions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">sqls</span><span class="o">=</span><span class="n">definition_sqls</span><span class="p">)</span> +</span><span id="L-1514"><a href="#L-1514"><span class="linenos">1514</span></a> <span class="n">define</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"DEFINE</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">definitions</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">definitions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1515"><a href="#L-1515"><span class="linenos">1515</span></a> <span class="n">body</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="L-1516"><a href="#L-1516"><span class="linenos">1516</span></a> <span class="p">(</span> +</span><span id="L-1517"><a href="#L-1517"><span class="linenos">1517</span></a> <span class="n">partition</span><span class="p">,</span> +</span><span id="L-1518"><a href="#L-1518"><span class="linenos">1518</span></a> <span class="n">order</span><span class="p">,</span> +</span><span id="L-1519"><a href="#L-1519"><span class="linenos">1519</span></a> <span class="n">measures</span><span class="p">,</span> +</span><span id="L-1520"><a href="#L-1520"><span class="linenos">1520</span></a> <span class="n">rows</span><span class="p">,</span> +</span><span id="L-1521"><a href="#L-1521"><span class="linenos">1521</span></a> <span class="n">after</span><span class="p">,</span> +</span><span id="L-1522"><a href="#L-1522"><span class="linenos">1522</span></a> <span class="n">pattern</span><span class="p">,</span> +</span><span id="L-1523"><a href="#L-1523"><span class="linenos">1523</span></a> <span class="n">define</span><span class="p">,</span> +</span><span id="L-1524"><a href="#L-1524"><span class="linenos">1524</span></a> <span class="p">)</span> +</span><span id="L-1525"><a href="#L-1525"><span class="linenos">1525</span></a> <span class="p">)</span> +</span><span id="L-1526"><a href="#L-1526"><span class="linenos">1526</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="L-1527"><a href="#L-1527"><span class="linenos">1527</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1528"><a href="#L-1528"><span class="linenos">1528</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'MATCH_RECOGNIZE'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">body</span><span class="p">)</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1529"><a href="#L-1529"><span class="linenos">1529</span></a> +</span><span id="L-1530"><a href="#L-1530"><span class="linenos">1530</span></a> <span class="k">def</span> <span class="nf">query_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="o">*</span><span class="n">sqls</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1531"><a href="#L-1531"><span class="linenos">1531</span></a> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"limit"</span><span class="p">)</span> +</span><span id="L-1532"><a href="#L-1532"><span class="linenos">1532</span></a> +</span><span id="L-1533"><a href="#L-1533"><span class="linenos">1533</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"LIMIT"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">):</span> +</span><span id="L-1534"><a href="#L-1534"><span class="linenos">1534</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">limit</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"count"</span><span class="p">))</span> +</span><span id="L-1535"><a href="#L-1535"><span class="linenos">1535</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"FETCH"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">):</span> +</span><span id="L-1536"><a href="#L-1536"><span class="linenos">1536</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">(</span><span class="n">direction</span><span class="o">=</span><span class="s2">"FIRST"</span><span class="p">,</span> <span class="n">count</span><span class="o">=</span><span class="n">limit</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-1537"><a href="#L-1537"><span class="linenos">1537</span></a> +</span><span id="L-1538"><a href="#L-1538"><span class="linenos">1538</span></a> <span class="n">fetch</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> +</span><span id="L-1539"><a href="#L-1539"><span class="linenos">1539</span></a> +</span><span id="L-1540"><a href="#L-1540"><span class="linenos">1540</span></a> <span class="k">return</span> <span class="n">csv</span><span class="p">(</span> +</span><span id="L-1541"><a href="#L-1541"><span class="linenos">1541</span></a> <span class="o">*</span><span class="n">sqls</span><span class="p">,</span> +</span><span id="L-1542"><a href="#L-1542"><span class="linenos">1542</span></a> <span class="o">*</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">join</span><span class="p">)</span> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> +</span><span id="L-1543"><a href="#L-1543"><span class="linenos">1543</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"match"</span><span class="p">),</span> +</span><span id="L-1544"><a href="#L-1544"><span class="linenos">1544</span></a> <span class="o">*</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">lateral</span><span class="p">)</span> <span class="k">for</span> <span class="n">lateral</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"laterals"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> +</span><span id="L-1545"><a href="#L-1545"><span class="linenos">1545</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">),</span> +</span><span id="L-1546"><a href="#L-1546"><span class="linenos">1546</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">),</span> +</span><span id="L-1547"><a href="#L-1547"><span class="linenos">1547</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"having"</span><span class="p">),</span> +</span><span id="L-1548"><a href="#L-1548"><span class="linenos">1548</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> +</span><span id="L-1549"><a href="#L-1549"><span class="linenos">1549</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">),</span> +</span><span id="L-1550"><a href="#L-1550"><span class="linenos">1550</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">offset_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">,</span> <span class="n">limit</span><span class="p">),</span> +</span><span id="L-1551"><a href="#L-1551"><span class="linenos">1551</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> +</span><span id="L-1552"><a href="#L-1552"><span class="linenos">1552</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> +</span><span id="L-1553"><a href="#L-1553"><span class="linenos">1553</span></a> <span class="p">)</span> +</span><span id="L-1554"><a href="#L-1554"><span class="linenos">1554</span></a> +</span><span id="L-1555"><a href="#L-1555"><span class="linenos">1555</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> +</span><span id="L-1556"><a href="#L-1556"><span class="linenos">1556</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> +</span><span id="L-1557"><a href="#L-1557"><span class="linenos">1557</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="L-1558"><a href="#L-1558"><span class="linenos">1558</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="L-1559"><a href="#L-1559"><span class="linenos">1559</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> +</span><span id="L-1560"><a href="#L-1560"><span class="linenos">1560</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> +</span><span id="L-1561"><a href="#L-1561"><span class="linenos">1561</span></a> <span class="p">]</span> +</span><span id="L-1562"><a href="#L-1562"><span class="linenos">1562</span></a> +</span><span id="L-1563"><a href="#L-1563"><span class="linenos">1563</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="L-1564"><a href="#L-1564"><span class="linenos">1564</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="L-1565"><a href="#L-1565"><span class="linenos">1565</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"qualify"</span><span class="p">),</span> +</span><span id="L-1566"><a href="#L-1566"><span class="linenos">1566</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WINDOW "</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"windows"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1567"><a href="#L-1567"><span class="linenos">1567</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"windows"</span><span class="p">)</span> +</span><span id="L-1568"><a href="#L-1568"><span class="linenos">1568</span></a> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="L-1569"><a href="#L-1569"><span class="linenos">1569</span></a> <span class="p">]</span> +</span><span id="L-1570"><a href="#L-1570"><span class="linenos">1570</span></a> +</span><span id="L-1571"><a href="#L-1571"><span class="linenos">1571</span></a> <span class="k">def</span> <span class="nf">after_limit_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="L-1572"><a href="#L-1572"><span class="linenos">1572</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"locks"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="L-1573"><a href="#L-1573"><span class="linenos">1573</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">locks</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">locks</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1574"><a href="#L-1574"><span class="linenos">1574</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">locks</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"sample"</span><span class="p">)]</span> +</span><span id="L-1575"><a href="#L-1575"><span class="linenos">1575</span></a> +</span><span id="L-1576"><a href="#L-1576"><span class="linenos">1576</span></a> <span class="k">def</span> <span class="nf">select_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1577"><a href="#L-1577"><span class="linenos">1577</span></a> <span class="n">hint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"hint"</span><span class="p">)</span> +</span><span id="L-1578"><a href="#L-1578"><span class="linenos">1578</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distinct"</span><span class="p">)</span> +</span><span id="L-1579"><a href="#L-1579"><span class="linenos">1579</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">distinct</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">distinct</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1580"><a href="#L-1580"><span class="linenos">1580</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-1581"><a href="#L-1581"><span class="linenos">1581</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-1582"><a href="#L-1582"><span class="linenos">1582</span></a> +</span><span id="L-1583"><a href="#L-1583"><span class="linenos">1583</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="L-1584"><a href="#L-1584"><span class="linenos">1584</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SELECT_KINDS</span><span class="p">:</span> +</span><span id="L-1585"><a href="#L-1585"><span class="linenos">1585</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1586"><a href="#L-1586"><span class="linenos">1586</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1587"><a href="#L-1587"><span class="linenos">1587</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"STRUCT"</span><span class="p">:</span> +</span><span id="L-1588"><a href="#L-1588"><span class="linenos">1588</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span> +</span><span id="L-1589"><a href="#L-1589"><span class="linenos">1589</span></a> <span class="n">sqls</span><span class="o">=</span><span class="p">[</span> +</span><span id="L-1590"><a href="#L-1590"><span class="linenos">1590</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="L-1591"><a href="#L-1591"><span class="linenos">1591</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">(</span> +</span><span id="L-1592"><a href="#L-1592"><span class="linenos">1592</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> +</span><span id="L-1593"><a href="#L-1593"><span class="linenos">1593</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">output_name</span><span class="p">)</span><span class="o">.</span><span class="n">eq</span><span class="p">(</span> +</span><span id="L-1594"><a href="#L-1594"><span class="linenos">1594</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">)</span> <span class="k">else</span> <span class="n">e</span> +</span><span id="L-1595"><a href="#L-1595"><span class="linenos">1595</span></a> <span class="p">)</span> +</span><span id="L-1596"><a href="#L-1596"><span class="linenos">1596</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="L-1597"><a href="#L-1597"><span class="linenos">1597</span></a> <span class="p">]</span> +</span><span id="L-1598"><a href="#L-1598"><span class="linenos">1598</span></a> <span class="p">)</span> +</span><span id="L-1599"><a href="#L-1599"><span class="linenos">1599</span></a> <span class="p">)</span> +</span><span id="L-1600"><a href="#L-1600"><span class="linenos">1600</span></a> <span class="p">]</span> +</span><span id="L-1601"><a href="#L-1601"><span class="linenos">1601</span></a> <span class="p">)</span> +</span><span id="L-1602"><a href="#L-1602"><span class="linenos">1602</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-1603"><a href="#L-1603"><span class="linenos">1603</span></a> +</span><span id="L-1604"><a href="#L-1604"><span class="linenos">1604</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="n">expressions</span> +</span><span id="L-1605"><a href="#L-1605"><span class="linenos">1605</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> +</span><span id="L-1606"><a href="#L-1606"><span class="linenos">1606</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="L-1607"><a href="#L-1607"><span class="linenos">1607</span></a> <span class="sa">f</span><span class="s2">"SELECT</span><span class="si">{</span><span class="n">hint</span><span class="si">}{</span><span class="n">distinct</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-1608"><a href="#L-1608"><span class="linenos">1608</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"into"</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="L-1609"><a href="#L-1609"><span class="linenos">1609</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="L-1610"><a href="#L-1610"><span class="linenos">1610</span></a> <span class="p">)</span> +</span><span id="L-1611"><a href="#L-1611"><span class="linenos">1611</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="L-1612"><a href="#L-1612"><span class="linenos">1612</span></a> +</span><span id="L-1613"><a href="#L-1613"><span class="linenos">1613</span></a> <span class="k">def</span> <span class="nf">schema_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1614"><a href="#L-1614"><span class="linenos">1614</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1615"><a href="#L-1615"><span class="linenos">1615</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1616"><a href="#L-1616"><span class="linenos">1616</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-1617"><a href="#L-1617"><span class="linenos">1617</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">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1618"><a href="#L-1618"><span class="linenos">1618</span></a> +</span><span id="L-1619"><a href="#L-1619"><span class="linenos">1619</span></a> <span class="k">def</span> <span class="nf">schema_columns_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1620"><a href="#L-1620"><span class="linenos">1620</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1621"><a href="#L-1621"><span class="linenos">1621</span></a> +</span><span id="L-1622"><a href="#L-1622"><span class="linenos">1622</span></a> <span class="k">def</span> <span class="nf">star_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1623"><a href="#L-1623"><span class="linenos">1623</span></a> <span class="n">except_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"except"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1624"><a href="#L-1624"><span class="linenos">1624</span></a> <span class="n">except_</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'except'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">except_</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">except_</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1625"><a href="#L-1625"><span class="linenos">1625</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"replace"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1626"><a href="#L-1626"><span class="linenos">1626</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'replace'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">replace</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">replace</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1627"><a href="#L-1627"><span class="linenos">1627</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"*</span><span class="si">{</span><span class="n">except_</span><span class="si">}{</span><span class="n">replace</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1628"><a href="#L-1628"><span class="linenos">1628</span></a> +</span><span id="L-1629"><a href="#L-1629"><span class="linenos">1629</span></a> <span class="k">def</span> <span class="nf">parameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Parameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1630"><a href="#L-1630"><span class="linenos">1630</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1631"><a href="#L-1631"><span class="linenos">1631</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="se">{{</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="se">}}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"wrapped"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1632"><a href="#L-1632"><span class="linenos">1632</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">PARAMETER_TOKEN</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1633"><a href="#L-1633"><span class="linenos">1633</span></a> +</span><span id="L-1634"><a href="#L-1634"><span class="linenos">1634</span></a> <span class="k">def</span> <span class="nf">sessionparameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SessionParameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1635"><a href="#L-1635"><span class="linenos">1635</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1636"><a href="#L-1636"><span class="linenos">1636</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> +</span><span id="L-1637"><a href="#L-1637"><span class="linenos">1637</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="L-1638"><a href="#L-1638"><span class="linenos">1638</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">."</span> +</span><span id="L-1639"><a href="#L-1639"><span class="linenos">1639</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"@@</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1640"><a href="#L-1640"><span class="linenos">1640</span></a> +</span><span id="L-1641"><a href="#L-1641"><span class="linenos">1641</span></a> <span class="k">def</span> <span class="nf">placeholder_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Placeholder</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1642"><a href="#L-1642"><span class="linenos">1642</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">":</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">"?"</span> +</span><span id="L-1643"><a href="#L-1643"><span class="linenos">1643</span></a> +</span><span id="L-1644"><a href="#L-1644"><span class="linenos">1644</span></a> <span class="k">def</span> <span class="nf">subquery_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1645"><a href="#L-1645"><span class="linenos">1645</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="L-1646"><a href="#L-1646"><span class="linenos">1646</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1647"><a href="#L-1647"><span class="linenos">1647</span></a> +</span><span id="L-1648"><a href="#L-1648"><span class="linenos">1648</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1649"><a href="#L-1649"><span class="linenos">1649</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1650"><a href="#L-1650"><span class="linenos">1650</span></a> +</span><span id="L-1651"><a href="#L-1651"><span class="linenos">1651</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> <span class="n">alias</span><span class="p">,</span> <span class="n">pivots</span><span class="p">)</span> +</span><span id="L-1652"><a href="#L-1652"><span class="linenos">1652</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> </span><span id="L-1653"><a href="#L-1653"><span class="linenos">1653</span></a> -</span><span id="L-1654"><a href="#L-1654"><span class="linenos">1654</span></a> <span class="k">def</span> <span class="nf">window_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1655"><a href="#L-1655"><span class="linenos">1655</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1656"><a href="#L-1656"><span class="linenos">1656</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-1657"><a href="#L-1657"><span class="linenos">1657</span></a> <span class="n">order</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"order"</span><span class="p">)</span> -</span><span id="L-1658"><a href="#L-1658"><span class="linenos">1658</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1659"><a href="#L-1659"><span class="linenos">1659</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"spec"</span><span class="p">)</span> -</span><span id="L-1660"><a href="#L-1660"><span class="linenos">1660</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="L-1661"><a href="#L-1661"><span class="linenos">1661</span></a> <span class="n">over</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"over"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"OVER"</span> -</span><span id="L-1662"><a href="#L-1662"><span class="linenos">1662</span></a> -</span><span id="L-1663"><a href="#L-1663"><span class="linenos">1663</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="s1">'AS'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">arg_key</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s1">'windows'</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">over</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1664"><a href="#L-1664"><span class="linenos">1664</span></a> -</span><span id="L-1665"><a href="#L-1665"><span class="linenos">1665</span></a> <span class="n">first</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"first"</span><span class="p">)</span> -</span><span id="L-1666"><a href="#L-1666"><span class="linenos">1666</span></a> <span class="k">if</span> <span class="n">first</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-1667"><a href="#L-1667"><span class="linenos">1667</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-1668"><a href="#L-1668"><span class="linenos">1668</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1669"><a href="#L-1669"><span class="linenos">1669</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">"FIRST"</span> <span class="k">if</span> <span class="n">first</span> <span class="k">else</span> <span class="s2">"LAST"</span> -</span><span id="L-1670"><a href="#L-1670"><span class="linenos">1670</span></a> -</span><span id="L-1671"><a href="#L-1671"><span class="linenos">1671</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">partition</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">order</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">spec</span> <span class="ow">and</span> <span class="n">alias</span><span class="p">:</span> -</span><span id="L-1672"><a href="#L-1672"><span class="linenos">1672</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1673"><a href="#L-1673"><span class="linenos">1673</span></a> -</span><span id="L-1674"><a href="#L-1674"><span class="linenos">1674</span></a> <span class="n">args</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">first</span><span class="p">,</span> <span class="n">partition</span><span class="p">,</span> <span class="n">order</span><span class="p">,</span> <span class="n">spec</span><span class="p">)</span> <span class="k">if</span> <span class="n">arg</span><span class="p">)</span> -</span><span id="L-1675"><a href="#L-1675"><span class="linenos">1675</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1676"><a href="#L-1676"><span class="linenos">1676</span></a> -</span><span id="L-1677"><a href="#L-1677"><span class="linenos">1677</span></a> <span class="k">def</span> <span class="nf">partition_by_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1678"><a href="#L-1678"><span class="linenos">1678</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"partition_by"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1679"><a href="#L-1679"><span class="linenos">1679</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1680"><a href="#L-1680"><span class="linenos">1680</span></a> -</span><span id="L-1681"><a href="#L-1681"><span class="linenos">1681</span></a> <span class="k">def</span> <span class="nf">windowspec_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WindowSpec</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1682"><a href="#L-1682"><span class="linenos">1682</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="L-1683"><a href="#L-1683"><span class="linenos">1683</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"start_side"</span><span class="p">),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="L-1684"><a href="#L-1684"><span class="linenos">1684</span></a> <span class="n">end</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-1685"><a href="#L-1685"><span class="linenos">1685</span></a> <span class="n">csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"end"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"end_side"</span><span class="p">),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="L-1686"><a href="#L-1686"><span class="linenos">1686</span></a> <span class="ow">or</span> <span class="s2">"CURRENT ROW"</span> -</span><span id="L-1687"><a href="#L-1687"><span class="linenos">1687</span></a> <span class="p">)</span> -</span><span id="L-1688"><a href="#L-1688"><span class="linenos">1688</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">end</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1689"><a href="#L-1689"><span class="linenos">1689</span></a> -</span><span id="L-1690"><a href="#L-1690"><span class="linenos">1690</span></a> <span class="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-1691"><a href="#L-1691"><span class="linenos">1691</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-1692"><a href="#L-1692"><span class="linenos">1692</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)[</span><span class="mi">1</span><span class="p">:]</span> <span class="c1"># order has a leading space</span> -</span><span id="L-1693"><a href="#L-1693"><span class="linenos">1693</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> WITHIN GROUP (</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1694"><a href="#L-1694"><span class="linenos">1694</span></a> -</span><span id="L-1695"><a href="#L-1695"><span class="linenos">1695</span></a> <span class="k">def</span> <span class="nf">between_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1696"><a href="#L-1696"><span class="linenos">1696</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-1697"><a href="#L-1697"><span class="linenos">1697</span></a> <span class="n">low</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"low"</span><span class="p">)</span> -</span><span id="L-1698"><a href="#L-1698"><span class="linenos">1698</span></a> <span class="n">high</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"high"</span><span class="p">)</span> -</span><span id="L-1699"><a href="#L-1699"><span class="linenos">1699</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">low</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">high</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1700"><a href="#L-1700"><span class="linenos">1700</span></a> -</span><span id="L-1701"><a href="#L-1701"><span class="linenos">1701</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-1702"><a href="#L-1702"><span class="linenos">1702</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">apply_index_offset</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">INDEX_OFFSET</span><span class="p">)</span> -</span><span id="L-1703"><a href="#L-1703"><span class="linenos">1703</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> -</span><span id="L-1704"><a href="#L-1704"><span class="linenos">1704</span></a> -</span><span id="L-1705"><a href="#L-1705"><span class="linenos">1705</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">[</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> +</span><span id="L-1654"><a href="#L-1654"><span class="linenos">1654</span></a> <span class="k">def</span> <span class="nf">qualify_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Qualify</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1655"><a href="#L-1655"><span class="linenos">1655</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))</span> +</span><span id="L-1656"><a href="#L-1656"><span class="linenos">1656</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'QUALIFY'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1657"><a href="#L-1657"><span class="linenos">1657</span></a> +</span><span id="L-1658"><a href="#L-1658"><span class="linenos">1658</span></a> <span class="k">def</span> <span class="nf">union_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1659"><a href="#L-1659"><span class="linenos">1659</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span> +</span><span id="L-1660"><a href="#L-1660"><span class="linenos">1660</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="L-1661"><a href="#L-1661"><span class="linenos">1661</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">union_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> +</span><span id="L-1662"><a href="#L-1662"><span class="linenos">1662</span></a> <span class="p">)</span> +</span><span id="L-1663"><a href="#L-1663"><span class="linenos">1663</span></a> +</span><span id="L-1664"><a href="#L-1664"><span class="linenos">1664</span></a> <span class="k">def</span> <span class="nf">union_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1665"><a href="#L-1665"><span class="linenos">1665</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">" DISTINCT"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPLICIT_UNION</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1666"><a href="#L-1666"><span class="linenos">1666</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">kind</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"distinct"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" ALL"</span> +</span><span id="L-1667"><a href="#L-1667"><span class="linenos">1667</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNION</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1668"><a href="#L-1668"><span class="linenos">1668</span></a> +</span><span id="L-1669"><a href="#L-1669"><span class="linenos">1669</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1670"><a href="#L-1670"><span class="linenos">1670</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1671"><a href="#L-1671"><span class="linenos">1671</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">)</span> +</span><span id="L-1672"><a href="#L-1672"><span class="linenos">1672</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> +</span><span id="L-1673"><a href="#L-1673"><span class="linenos">1673</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">alias</span><span class="o">.</span><span class="n">columns</span> +</span><span id="L-1674"><a href="#L-1674"><span class="linenos">1674</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">columns</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1675"><a href="#L-1675"><span class="linenos">1675</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1676"><a href="#L-1676"><span class="linenos">1676</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="L-1677"><a href="#L-1677"><span class="linenos">1677</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">alias</span> +</span><span id="L-1678"><a href="#L-1678"><span class="linenos">1678</span></a> <span class="n">ordinality</span> <span class="o">=</span> <span class="s2">" WITH ORDINALITY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ordinality"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1679"><a href="#L-1679"><span class="linenos">1679</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">)</span> +</span><span id="L-1680"><a href="#L-1680"><span class="linenos">1680</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH OFFSET AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">offset</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">offset</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1681"><a href="#L-1681"><span class="linenos">1681</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNNEST(</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">ordinality</span><span class="si">}{</span><span class="n">alias</span><span class="si">}{</span><span class="n">offset</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1682"><a href="#L-1682"><span class="linenos">1682</span></a> +</span><span id="L-1683"><a href="#L-1683"><span class="linenos">1683</span></a> <span class="k">def</span> <span class="nf">where_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1684"><a href="#L-1684"><span class="linenos">1684</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))</span> +</span><span id="L-1685"><a href="#L-1685"><span class="linenos">1685</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'WHERE'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1686"><a href="#L-1686"><span class="linenos">1686</span></a> +</span><span id="L-1687"><a href="#L-1687"><span class="linenos">1687</span></a> <span class="k">def</span> <span class="nf">window_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1688"><a href="#L-1688"><span class="linenos">1688</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1689"><a href="#L-1689"><span class="linenos">1689</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-1690"><a href="#L-1690"><span class="linenos">1690</span></a> <span class="n">order</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"order"</span><span class="p">)</span> +</span><span id="L-1691"><a href="#L-1691"><span class="linenos">1691</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1692"><a href="#L-1692"><span class="linenos">1692</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"spec"</span><span class="p">)</span> +</span><span id="L-1693"><a href="#L-1693"><span class="linenos">1693</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="L-1694"><a href="#L-1694"><span class="linenos">1694</span></a> <span class="n">over</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"over"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"OVER"</span> +</span><span id="L-1695"><a href="#L-1695"><span class="linenos">1695</span></a> +</span><span id="L-1696"><a href="#L-1696"><span class="linenos">1696</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="s1">'AS'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">arg_key</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s1">'windows'</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">over</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1697"><a href="#L-1697"><span class="linenos">1697</span></a> +</span><span id="L-1698"><a href="#L-1698"><span class="linenos">1698</span></a> <span class="n">first</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"first"</span><span class="p">)</span> +</span><span id="L-1699"><a href="#L-1699"><span class="linenos">1699</span></a> <span class="k">if</span> <span class="n">first</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-1700"><a href="#L-1700"><span class="linenos">1700</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-1701"><a href="#L-1701"><span class="linenos">1701</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1702"><a href="#L-1702"><span class="linenos">1702</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">"FIRST"</span> <span class="k">if</span> <span class="n">first</span> <span class="k">else</span> <span class="s2">"LAST"</span> +</span><span id="L-1703"><a href="#L-1703"><span class="linenos">1703</span></a> +</span><span id="L-1704"><a href="#L-1704"><span class="linenos">1704</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">partition</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">order</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">spec</span> <span class="ow">and</span> <span class="n">alias</span><span class="p">:</span> +</span><span id="L-1705"><a href="#L-1705"><span class="linenos">1705</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-1706"><a href="#L-1706"><span class="linenos">1706</span></a> -</span><span id="L-1707"><a href="#L-1707"><span class="linenos">1707</span></a> <span class="k">def</span> <span class="nf">all_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">All</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1708"><a href="#L-1708"><span class="linenos">1708</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALL </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1707"><a href="#L-1707"><span class="linenos">1707</span></a> <span class="n">args</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">first</span><span class="p">,</span> <span class="n">partition</span><span class="p">,</span> <span class="n">order</span><span class="p">,</span> <span class="n">spec</span><span class="p">)</span> <span class="k">if</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="L-1708"><a href="#L-1708"><span class="linenos">1708</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> </span><span id="L-1709"><a href="#L-1709"><span class="linenos">1709</span></a> -</span><span id="L-1710"><a href="#L-1710"><span class="linenos">1710</span></a> <span class="k">def</span> <span class="nf">any_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1711"><a href="#L-1711"><span class="linenos">1711</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1712"><a href="#L-1712"><span class="linenos">1712</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="L-1713"><a href="#L-1713"><span class="linenos">1713</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-1714"><a href="#L-1714"><span class="linenos">1714</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ANY </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1715"><a href="#L-1715"><span class="linenos">1715</span></a> -</span><span id="L-1716"><a href="#L-1716"><span class="linenos">1716</span></a> <span class="k">def</span> <span class="nf">exists_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Exists</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1717"><a href="#L-1717"><span class="linenos">1717</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXISTS</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1718"><a href="#L-1718"><span class="linenos">1718</span></a> -</span><span id="L-1719"><a href="#L-1719"><span class="linenos">1719</span></a> <span class="k">def</span> <span class="nf">case_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1720"><a href="#L-1720"><span class="linenos">1720</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1721"><a href="#L-1721"><span class="linenos">1721</span></a> <span class="n">statements</span> <span class="o">=</span> <span class="p">[</span><span class="sa">f</span><span class="s2">"CASE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">"CASE"</span><span class="p">]</span> +</span><span id="L-1710"><a href="#L-1710"><span class="linenos">1710</span></a> <span class="k">def</span> <span class="nf">partition_by_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1711"><a href="#L-1711"><span class="linenos">1711</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"partition_by"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1712"><a href="#L-1712"><span class="linenos">1712</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1713"><a href="#L-1713"><span class="linenos">1713</span></a> +</span><span id="L-1714"><a href="#L-1714"><span class="linenos">1714</span></a> <span class="k">def</span> <span class="nf">windowspec_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WindowSpec</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1715"><a href="#L-1715"><span class="linenos">1715</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="L-1716"><a href="#L-1716"><span class="linenos">1716</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"start_side"</span><span class="p">),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="L-1717"><a href="#L-1717"><span class="linenos">1717</span></a> <span class="n">end</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-1718"><a href="#L-1718"><span class="linenos">1718</span></a> <span class="n">csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"end"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"end_side"</span><span class="p">),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="L-1719"><a href="#L-1719"><span class="linenos">1719</span></a> <span class="ow">or</span> <span class="s2">"CURRENT ROW"</span> +</span><span id="L-1720"><a href="#L-1720"><span class="linenos">1720</span></a> <span class="p">)</span> +</span><span id="L-1721"><a href="#L-1721"><span class="linenos">1721</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">end</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-1722"><a href="#L-1722"><span class="linenos">1722</span></a> -</span><span id="L-1723"><a href="#L-1723"><span class="linenos">1723</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"ifs"</span><span class="p">]:</span> -</span><span id="L-1724"><a href="#L-1724"><span class="linenos">1724</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"WHEN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-1725"><a href="#L-1725"><span class="linenos">1725</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"THEN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'true'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-1726"><a href="#L-1726"><span class="linenos">1726</span></a> -</span><span id="L-1727"><a href="#L-1727"><span class="linenos">1727</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">)</span> -</span><span id="L-1728"><a href="#L-1728"><span class="linenos">1728</span></a> -</span><span id="L-1729"><a href="#L-1729"><span class="linenos">1729</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="L-1730"><a href="#L-1730"><span class="linenos">1730</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"ELSE </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-1731"><a href="#L-1731"><span class="linenos">1731</span></a> -</span><span id="L-1732"><a href="#L-1732"><span class="linenos">1732</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"END"</span><span class="p">)</span> +</span><span id="L-1723"><a href="#L-1723"><span class="linenos">1723</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-1724"><a href="#L-1724"><span class="linenos">1724</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1725"><a href="#L-1725"><span class="linenos">1725</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)[</span><span class="mi">1</span><span class="p">:]</span> <span class="c1"># order has a leading space</span> +</span><span id="L-1726"><a href="#L-1726"><span class="linenos">1726</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> WITHIN GROUP (</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1727"><a href="#L-1727"><span class="linenos">1727</span></a> +</span><span id="L-1728"><a href="#L-1728"><span class="linenos">1728</span></a> <span class="k">def</span> <span class="nf">between_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1729"><a href="#L-1729"><span class="linenos">1729</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1730"><a href="#L-1730"><span class="linenos">1730</span></a> <span class="n">low</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"low"</span><span class="p">)</span> +</span><span id="L-1731"><a href="#L-1731"><span class="linenos">1731</span></a> <span class="n">high</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"high"</span><span class="p">)</span> +</span><span id="L-1732"><a href="#L-1732"><span class="linenos">1732</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">low</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">high</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-1733"><a href="#L-1733"><span class="linenos">1733</span></a> -</span><span id="L-1734"><a href="#L-1734"><span class="linenos">1734</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">statements</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span><span class="p">:</span> -</span><span id="L-1735"><a href="#L-1735"><span class="linenos">1735</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">statements</span><span class="p">),</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">skip_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1736"><a href="#L-1736"><span class="linenos">1736</span></a> -</span><span id="L-1737"><a href="#L-1737"><span class="linenos">1737</span></a> <span class="k">return</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">statements</span><span class="p">)</span> -</span><span id="L-1738"><a href="#L-1738"><span class="linenos">1738</span></a> -</span><span id="L-1739"><a href="#L-1739"><span class="linenos">1739</span></a> <span class="k">def</span> <span class="nf">constraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Constraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1740"><a href="#L-1740"><span class="linenos">1740</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1741"><a href="#L-1741"><span class="linenos">1741</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1742"><a href="#L-1742"><span class="linenos">1742</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1743"><a href="#L-1743"><span class="linenos">1743</span></a> -</span><span id="L-1744"><a href="#L-1744"><span class="linenos">1744</span></a> <span class="k">def</span> <span class="nf">nextvaluefor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NextValueFor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1745"><a href="#L-1745"><span class="linenos">1745</span></a> <span class="n">order</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"order"</span><span class="p">)</span> -</span><span id="L-1746"><a href="#L-1746"><span class="linenos">1746</span></a> <span class="n">order</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OVER (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1747"><a href="#L-1747"><span class="linenos">1747</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NEXT VALUE FOR </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">order</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1734"><a href="#L-1734"><span class="linenos">1734</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-1735"><a href="#L-1735"><span class="linenos">1735</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">apply_index_offset</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">INDEX_OFFSET</span><span class="p">)</span> +</span><span id="L-1736"><a href="#L-1736"><span class="linenos">1736</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> +</span><span id="L-1737"><a href="#L-1737"><span class="linenos">1737</span></a> +</span><span id="L-1738"><a href="#L-1738"><span class="linenos">1738</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">[</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> +</span><span id="L-1739"><a href="#L-1739"><span class="linenos">1739</span></a> +</span><span id="L-1740"><a href="#L-1740"><span class="linenos">1740</span></a> <span class="k">def</span> <span class="nf">all_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">All</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1741"><a href="#L-1741"><span class="linenos">1741</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALL </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1742"><a href="#L-1742"><span class="linenos">1742</span></a> +</span><span id="L-1743"><a href="#L-1743"><span class="linenos">1743</span></a> <span class="k">def</span> <span class="nf">any_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1744"><a href="#L-1744"><span class="linenos">1744</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1745"><a href="#L-1745"><span class="linenos">1745</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="L-1746"><a href="#L-1746"><span class="linenos">1746</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-1747"><a href="#L-1747"><span class="linenos">1747</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ANY </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-1748"><a href="#L-1748"><span class="linenos">1748</span></a> -</span><span id="L-1749"><a href="#L-1749"><span class="linenos">1749</span></a> <span class="k">def</span> <span class="nf">extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1750"><a href="#L-1750"><span class="linenos">1750</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1751"><a href="#L-1751"><span class="linenos">1751</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-1752"><a href="#L-1752"><span class="linenos">1752</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXTRACT(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FROM </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1753"><a href="#L-1753"><span class="linenos">1753</span></a> -</span><span id="L-1754"><a href="#L-1754"><span class="linenos">1754</span></a> <span class="k">def</span> <span class="nf">trim_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1755"><a href="#L-1755"><span class="linenos">1755</span></a> <span class="n">trim_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> -</span><span id="L-1756"><a href="#L-1756"><span class="linenos">1756</span></a> -</span><span id="L-1757"><a href="#L-1757"><span class="linenos">1757</span></a> <span class="k">if</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"LEADING"</span><span class="p">:</span> -</span><span id="L-1758"><a href="#L-1758"><span class="linenos">1758</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LTRIM"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-1759"><a href="#L-1759"><span class="linenos">1759</span></a> <span class="k">elif</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"TRAILING"</span><span class="p">:</span> -</span><span id="L-1760"><a href="#L-1760"><span class="linenos">1760</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"RTRIM"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-1761"><a href="#L-1761"><span class="linenos">1761</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1762"><a href="#L-1762"><span class="linenos">1762</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-1763"><a href="#L-1763"><span class="linenos">1763</span></a> -</span><span id="L-1764"><a href="#L-1764"><span class="linenos">1764</span></a> <span class="k">def</span> <span class="nf">safeconcat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1765"><a href="#L-1765"><span class="linenos">1765</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="L-1766"><a href="#L-1766"><span class="linenos">1766</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> -</span><span id="L-1767"><a href="#L-1767"><span class="linenos">1767</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> -</span><span id="L-1768"><a href="#L-1768"><span class="linenos">1768</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-1749"><a href="#L-1749"><span class="linenos">1749</span></a> <span class="k">def</span> <span class="nf">exists_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Exists</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1750"><a href="#L-1750"><span class="linenos">1750</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXISTS</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1751"><a href="#L-1751"><span class="linenos">1751</span></a> +</span><span id="L-1752"><a href="#L-1752"><span class="linenos">1752</span></a> <span class="k">def</span> <span class="nf">case_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1753"><a href="#L-1753"><span class="linenos">1753</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1754"><a href="#L-1754"><span class="linenos">1754</span></a> <span class="n">statements</span> <span class="o">=</span> <span class="p">[</span><span class="sa">f</span><span class="s2">"CASE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">"CASE"</span><span class="p">]</span> +</span><span id="L-1755"><a href="#L-1755"><span class="linenos">1755</span></a> +</span><span id="L-1756"><a href="#L-1756"><span class="linenos">1756</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"ifs"</span><span class="p">]:</span> +</span><span id="L-1757"><a href="#L-1757"><span class="linenos">1757</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"WHEN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-1758"><a href="#L-1758"><span class="linenos">1758</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"THEN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'true'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-1759"><a href="#L-1759"><span class="linenos">1759</span></a> +</span><span id="L-1760"><a href="#L-1760"><span class="linenos">1760</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">)</span> +</span><span id="L-1761"><a href="#L-1761"><span class="linenos">1761</span></a> +</span><span id="L-1762"><a href="#L-1762"><span class="linenos">1762</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> +</span><span id="L-1763"><a href="#L-1763"><span class="linenos">1763</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"ELSE </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-1764"><a href="#L-1764"><span class="linenos">1764</span></a> +</span><span id="L-1765"><a href="#L-1765"><span class="linenos">1765</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"END"</span><span class="p">)</span> +</span><span id="L-1766"><a href="#L-1766"><span class="linenos">1766</span></a> +</span><span id="L-1767"><a href="#L-1767"><span class="linenos">1767</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">statements</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span><span class="p">:</span> +</span><span id="L-1768"><a href="#L-1768"><span class="linenos">1768</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">statements</span><span class="p">),</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">skip_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span><span id="L-1769"><a href="#L-1769"><span class="linenos">1769</span></a> -</span><span id="L-1770"><a href="#L-1770"><span class="linenos">1770</span></a> <span class="k">def</span> <span class="nf">check_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Check</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1771"><a href="#L-1771"><span class="linenos">1771</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-1772"><a href="#L-1772"><span class="linenos">1772</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECK (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1773"><a href="#L-1773"><span class="linenos">1773</span></a> -</span><span id="L-1774"><a href="#L-1774"><span class="linenos">1774</span></a> <span class="k">def</span> <span class="nf">foreignkey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1775"><a href="#L-1775"><span class="linenos">1775</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1776"><a href="#L-1776"><span class="linenos">1776</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"reference"</span><span class="p">)</span> -</span><span id="L-1777"><a href="#L-1777"><span class="linenos">1777</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">reference</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">reference</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1778"><a href="#L-1778"><span class="linenos">1778</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"delete"</span><span class="p">)</span> -</span><span id="L-1779"><a href="#L-1779"><span class="linenos">1779</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON DELETE </span><span class="si">{</span><span class="n">delete</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">delete</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1780"><a href="#L-1780"><span class="linenos">1780</span></a> <span class="n">update</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"update"</span><span class="p">)</span> -</span><span id="L-1781"><a href="#L-1781"><span class="linenos">1781</span></a> <span class="n">update</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON UPDATE </span><span class="si">{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">update</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1782"><a href="#L-1782"><span class="linenos">1782</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FOREIGN KEY (</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">reference</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1783"><a href="#L-1783"><span class="linenos">1783</span></a> -</span><span id="L-1784"><a href="#L-1784"><span class="linenos">1784</span></a> <span class="k">def</span> <span class="nf">primarykey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1785"><a href="#L-1785"><span class="linenos">1785</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1786"><a href="#L-1786"><span class="linenos">1786</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="L-1787"><a href="#L-1787"><span class="linenos">1787</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1788"><a href="#L-1788"><span class="linenos">1788</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY (</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1770"><a href="#L-1770"><span class="linenos">1770</span></a> <span class="k">return</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">statements</span><span class="p">)</span> +</span><span id="L-1771"><a href="#L-1771"><span class="linenos">1771</span></a> +</span><span id="L-1772"><a href="#L-1772"><span class="linenos">1772</span></a> <span class="k">def</span> <span class="nf">constraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Constraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1773"><a href="#L-1773"><span class="linenos">1773</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1774"><a href="#L-1774"><span class="linenos">1774</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1775"><a href="#L-1775"><span class="linenos">1775</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1776"><a href="#L-1776"><span class="linenos">1776</span></a> +</span><span id="L-1777"><a href="#L-1777"><span class="linenos">1777</span></a> <span class="k">def</span> <span class="nf">nextvaluefor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NextValueFor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1778"><a href="#L-1778"><span class="linenos">1778</span></a> <span class="n">order</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"order"</span><span class="p">)</span> +</span><span id="L-1779"><a href="#L-1779"><span class="linenos">1779</span></a> <span class="n">order</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OVER (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1780"><a href="#L-1780"><span class="linenos">1780</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NEXT VALUE FOR </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">order</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1781"><a href="#L-1781"><span class="linenos">1781</span></a> +</span><span id="L-1782"><a href="#L-1782"><span class="linenos">1782</span></a> <span class="k">def</span> <span class="nf">extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1783"><a href="#L-1783"><span class="linenos">1783</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-1784"><a href="#L-1784"><span class="linenos">1784</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-1785"><a href="#L-1785"><span class="linenos">1785</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXTRACT(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FROM </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1786"><a href="#L-1786"><span class="linenos">1786</span></a> +</span><span id="L-1787"><a href="#L-1787"><span class="linenos">1787</span></a> <span class="k">def</span> <span class="nf">trim_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1788"><a href="#L-1788"><span class="linenos">1788</span></a> <span class="n">trim_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> </span><span id="L-1789"><a href="#L-1789"><span class="linenos">1789</span></a> -</span><span id="L-1790"><a href="#L-1790"><span class="linenos">1790</span></a> <span class="k">def</span> <span class="nf">if_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1791"><a href="#L-1791"><span class="linenos">1791</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">case_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">(</span><span class="n">ifs</span><span class="o">=</span><span class="p">[</span><span class="n">expression</span><span class="p">],</span> <span class="n">default</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"false"</span><span class="p">)))</span> -</span><span id="L-1792"><a href="#L-1792"><span class="linenos">1792</span></a> -</span><span id="L-1793"><a href="#L-1793"><span class="linenos">1793</span></a> <span class="k">def</span> <span class="nf">matchagainst_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchAgainst</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1794"><a href="#L-1794"><span class="linenos">1794</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modifier"</span><span class="p">)</span> -</span><span id="L-1795"><a href="#L-1795"><span class="linenos">1795</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">modifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modifier</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1796"><a href="#L-1796"><span class="linenos">1796</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'MATCH'</span><span class="p">,</span><span class="w"> </span><span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span><span class="si">}</span><span class="s2"> AGAINST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">modifier</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1797"><a href="#L-1797"><span class="linenos">1797</span></a> -</span><span id="L-1798"><a href="#L-1798"><span class="linenos">1798</span></a> <span class="k">def</span> <span class="nf">jsonkeyvalue_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONKeyValue</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1799"><a href="#L-1799"><span class="linenos">1799</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1800"><a href="#L-1800"><span class="linenos">1800</span></a> -</span><span id="L-1801"><a href="#L-1801"><span class="linenos">1801</span></a> <span class="k">def</span> <span class="nf">jsonobject_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONObject</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1802"><a href="#L-1802"><span class="linenos">1802</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"null_handling"</span><span class="p">)</span> -</span><span id="L-1803"><a href="#L-1803"><span class="linenos">1803</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1804"><a href="#L-1804"><span class="linenos">1804</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unique_keys"</span><span class="p">)</span> -</span><span id="L-1805"><a href="#L-1805"><span class="linenos">1805</span></a> <span class="k">if</span> <span class="n">unique_keys</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-1806"><a href="#L-1806"><span class="linenos">1806</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">'WITH'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">unique_keys</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'WITHOUT'</span><span class="si">}</span><span class="s2"> UNIQUE KEYS"</span> -</span><span id="L-1807"><a href="#L-1807"><span class="linenos">1807</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1808"><a href="#L-1808"><span class="linenos">1808</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-1809"><a href="#L-1809"><span class="linenos">1809</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"return_type"</span><span class="p">)</span> -</span><span id="L-1810"><a href="#L-1810"><span class="linenos">1810</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1811"><a href="#L-1811"><span class="linenos">1811</span></a> <span class="n">format_json</span> <span class="o">=</span> <span class="s2">" FORMAT JSON"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"format_json"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1812"><a href="#L-1812"><span class="linenos">1812</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"encoding"</span><span class="p">)</span> -</span><span id="L-1813"><a href="#L-1813"><span class="linenos">1813</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ENCODING </span><span class="si">{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">encoding</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1814"><a href="#L-1814"><span class="linenos">1814</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-1815"><a href="#L-1815"><span class="linenos">1815</span></a> <span class="s2">"JSON_OBJECT"</span><span class="p">,</span> -</span><span id="L-1816"><a href="#L-1816"><span class="linenos">1816</span></a> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-1817"><a href="#L-1817"><span class="linenos">1817</span></a> <span class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">null_handling</span><span class="si">}{</span><span class="n">unique_keys</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">format_json</span><span class="si">}{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="L-1818"><a href="#L-1818"><span class="linenos">1818</span></a> <span class="p">)</span> -</span><span id="L-1819"><a href="#L-1819"><span class="linenos">1819</span></a> -</span><span id="L-1820"><a href="#L-1820"><span class="linenos">1820</span></a> <span class="k">def</span> <span class="nf">openjsoncolumndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSONColumnDef</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1821"><a href="#L-1821"><span class="linenos">1821</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1822"><a href="#L-1822"><span class="linenos">1822</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="L-1823"><a href="#L-1823"><span class="linenos">1823</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> -</span><span id="L-1824"><a href="#L-1824"><span class="linenos">1824</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1825"><a href="#L-1825"><span class="linenos">1825</span></a> <span class="n">as_json</span> <span class="o">=</span> <span class="s2">" AS JSON"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"as_json"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1826"><a href="#L-1826"><span class="linenos">1826</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">path</span><span class="si">}{</span><span class="n">as_json</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1827"><a href="#L-1827"><span class="linenos">1827</span></a> -</span><span id="L-1828"><a href="#L-1828"><span class="linenos">1828</span></a> <span class="k">def</span> <span class="nf">openjson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1829"><a href="#L-1829"><span class="linenos">1829</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1830"><a href="#L-1830"><span class="linenos">1830</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> -</span><span id="L-1831"><a href="#L-1831"><span class="linenos">1831</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1832"><a href="#L-1832"><span class="linenos">1832</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-1833"><a href="#L-1833"><span class="linenos">1833</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-1834"><a href="#L-1834"><span class="linenos">1834</span></a> <span class="sa">f</span><span class="s2">" WITH (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">expressions</span><span class="p">),</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1835"><a href="#L-1835"><span class="linenos">1835</span></a> <span class="k">if</span> <span class="n">expressions</span> -</span><span id="L-1836"><a href="#L-1836"><span class="linenos">1836</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1837"><a href="#L-1837"><span class="linenos">1837</span></a> <span class="p">)</span> -</span><span id="L-1838"><a href="#L-1838"><span class="linenos">1838</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"OPENJSON(</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">path</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">with_</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1839"><a href="#L-1839"><span class="linenos">1839</span></a> -</span><span id="L-1840"><a href="#L-1840"><span class="linenos">1840</span></a> <span class="k">def</span> <span class="nf">in_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">In</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1841"><a href="#L-1841"><span class="linenos">1841</span></a> <span class="n">query</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"query"</span><span class="p">)</span> -</span><span id="L-1842"><a href="#L-1842"><span class="linenos">1842</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unnest"</span><span class="p">)</span> -</span><span id="L-1843"><a href="#L-1843"><span class="linenos">1843</span></a> <span class="n">field</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"field"</span><span class="p">)</span> -</span><span id="L-1844"><a href="#L-1844"><span class="linenos">1844</span></a> <span class="n">is_global</span> <span class="o">=</span> <span class="s2">" GLOBAL"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"is_global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1845"><a href="#L-1845"><span class="linenos">1845</span></a> -</span><span id="L-1846"><a href="#L-1846"><span class="linenos">1846</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> -</span><span id="L-1847"><a href="#L-1847"><span class="linenos">1847</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">query</span><span class="p">)</span> -</span><span id="L-1848"><a href="#L-1848"><span class="linenos">1848</span></a> <span class="k">elif</span> <span class="n">unnest</span><span class="p">:</span> -</span><span id="L-1849"><a href="#L-1849"><span class="linenos">1849</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">in_unnest_op</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span> -</span><span id="L-1850"><a href="#L-1850"><span class="linenos">1850</span></a> <span class="k">elif</span> <span class="n">field</span><span class="p">:</span> -</span><span id="L-1851"><a href="#L-1851"><span class="linenos">1851</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">field</span><span class="p">)</span> -</span><span id="L-1852"><a href="#L-1852"><span class="linenos">1852</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1853"><a href="#L-1853"><span class="linenos">1853</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1854"><a href="#L-1854"><span class="linenos">1854</span></a> -</span><span id="L-1855"><a href="#L-1855"><span class="linenos">1855</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">is_global</span><span class="si">}</span><span class="s2"> IN </span><span class="si">{</span><span class="n">in_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1856"><a href="#L-1856"><span class="linenos">1856</span></a> -</span><span id="L-1857"><a href="#L-1857"><span class="linenos">1857</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">unnest</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1858"><a href="#L-1858"><span class="linenos">1858</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(SELECT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1859"><a href="#L-1859"><span class="linenos">1859</span></a> -</span><span id="L-1860"><a href="#L-1860"><span class="linenos">1860</span></a> <span class="k">def</span> <span class="nf">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-1861"><a href="#L-1861"><span class="linenos">1861</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> -</span><span id="L-1862"><a href="#L-1862"><span class="linenos">1862</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span><span class="p">:</span> -</span><span id="L-1863"><a href="#L-1863"><span class="linenos">1863</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_PART_SINGULARS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> <span class="n">unit</span><span class="p">)</span> -</span><span id="L-1864"><a href="#L-1864"><span class="linenos">1864</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1865"><a href="#L-1865"><span class="linenos">1865</span></a> -</span><span id="L-1866"><a href="#L-1866"><span class="linenos">1866</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_STRING_INTERVAL</span><span class="p">:</span> -</span><span id="L-1867"><a href="#L-1867"><span class="linenos">1867</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1868"><a href="#L-1868"><span class="linenos">1868</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL '</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">'"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1869"><a href="#L-1869"><span class="linenos">1869</span></a> -</span><span id="L-1870"><a href="#L-1870"><span class="linenos">1870</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1871"><a href="#L-1871"><span class="linenos">1871</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> -</span><span id="L-1872"><a href="#L-1872"><span class="linenos">1872</span></a> <span class="n">unwrapped</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">)</span> -</span><span id="L-1873"><a href="#L-1873"><span class="linenos">1873</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unwrapped</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1874"><a href="#L-1874"><span class="linenos">1874</span></a> -</span><span id="L-1875"><a href="#L-1875"><span class="linenos">1875</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1876"><a href="#L-1876"><span class="linenos">1876</span></a> -</span><span id="L-1877"><a href="#L-1877"><span class="linenos">1877</span></a> <span class="k">def</span> <span class="nf">return_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Return</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1878"><a href="#L-1878"><span class="linenos">1878</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RETURN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1879"><a href="#L-1879"><span class="linenos">1879</span></a> -</span><span id="L-1880"><a href="#L-1880"><span class="linenos">1880</span></a> <span class="k">def</span> <span class="nf">reference_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Reference</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1881"><a href="#L-1881"><span class="linenos">1881</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1882"><a href="#L-1882"><span class="linenos">1882</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1883"><a href="#L-1883"><span class="linenos">1883</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1884"><a href="#L-1884"><span class="linenos">1884</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="L-1885"><a href="#L-1885"><span class="linenos">1885</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1886"><a href="#L-1886"><span class="linenos">1886</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"REFERENCES </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1790"><a href="#L-1790"><span class="linenos">1790</span></a> <span class="k">if</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"LEADING"</span><span class="p">:</span> +</span><span id="L-1791"><a href="#L-1791"><span class="linenos">1791</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LTRIM"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-1792"><a href="#L-1792"><span class="linenos">1792</span></a> <span class="k">elif</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"TRAILING"</span><span class="p">:</span> +</span><span id="L-1793"><a href="#L-1793"><span class="linenos">1793</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"RTRIM"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-1794"><a href="#L-1794"><span class="linenos">1794</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1795"><a href="#L-1795"><span class="linenos">1795</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-1796"><a href="#L-1796"><span class="linenos">1796</span></a> +</span><span id="L-1797"><a href="#L-1797"><span class="linenos">1797</span></a> <span class="k">def</span> <span class="nf">safeconcat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1798"><a href="#L-1798"><span class="linenos">1798</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="L-1799"><a href="#L-1799"><span class="linenos">1799</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> +</span><span id="L-1800"><a href="#L-1800"><span class="linenos">1800</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> +</span><span id="L-1801"><a href="#L-1801"><span class="linenos">1801</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-1802"><a href="#L-1802"><span class="linenos">1802</span></a> +</span><span id="L-1803"><a href="#L-1803"><span class="linenos">1803</span></a> <span class="k">def</span> <span class="nf">check_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Check</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1804"><a href="#L-1804"><span class="linenos">1804</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-1805"><a href="#L-1805"><span class="linenos">1805</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECK (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1806"><a href="#L-1806"><span class="linenos">1806</span></a> +</span><span id="L-1807"><a href="#L-1807"><span class="linenos">1807</span></a> <span class="k">def</span> <span class="nf">foreignkey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1808"><a href="#L-1808"><span class="linenos">1808</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1809"><a href="#L-1809"><span class="linenos">1809</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"reference"</span><span class="p">)</span> +</span><span id="L-1810"><a href="#L-1810"><span class="linenos">1810</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">reference</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">reference</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1811"><a href="#L-1811"><span class="linenos">1811</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"delete"</span><span class="p">)</span> +</span><span id="L-1812"><a href="#L-1812"><span class="linenos">1812</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON DELETE </span><span class="si">{</span><span class="n">delete</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">delete</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1813"><a href="#L-1813"><span class="linenos">1813</span></a> <span class="n">update</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"update"</span><span class="p">)</span> +</span><span id="L-1814"><a href="#L-1814"><span class="linenos">1814</span></a> <span class="n">update</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON UPDATE </span><span class="si">{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">update</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1815"><a href="#L-1815"><span class="linenos">1815</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FOREIGN KEY (</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">reference</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1816"><a href="#L-1816"><span class="linenos">1816</span></a> +</span><span id="L-1817"><a href="#L-1817"><span class="linenos">1817</span></a> <span class="k">def</span> <span class="nf">primarykey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1818"><a href="#L-1818"><span class="linenos">1818</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1819"><a href="#L-1819"><span class="linenos">1819</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="L-1820"><a href="#L-1820"><span class="linenos">1820</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1821"><a href="#L-1821"><span class="linenos">1821</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY (</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1822"><a href="#L-1822"><span class="linenos">1822</span></a> +</span><span id="L-1823"><a href="#L-1823"><span class="linenos">1823</span></a> <span class="k">def</span> <span class="nf">if_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1824"><a href="#L-1824"><span class="linenos">1824</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">case_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">(</span><span class="n">ifs</span><span class="o">=</span><span class="p">[</span><span class="n">expression</span><span class="p">],</span> <span class="n">default</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"false"</span><span class="p">)))</span> +</span><span id="L-1825"><a href="#L-1825"><span class="linenos">1825</span></a> +</span><span id="L-1826"><a href="#L-1826"><span class="linenos">1826</span></a> <span class="k">def</span> <span class="nf">matchagainst_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchAgainst</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1827"><a href="#L-1827"><span class="linenos">1827</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modifier"</span><span class="p">)</span> +</span><span id="L-1828"><a href="#L-1828"><span class="linenos">1828</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">modifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modifier</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1829"><a href="#L-1829"><span class="linenos">1829</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'MATCH'</span><span class="p">,</span><span class="w"> </span><span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span><span class="si">}</span><span class="s2"> AGAINST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">modifier</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1830"><a href="#L-1830"><span class="linenos">1830</span></a> +</span><span id="L-1831"><a href="#L-1831"><span class="linenos">1831</span></a> <span class="k">def</span> <span class="nf">jsonkeyvalue_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONKeyValue</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1832"><a href="#L-1832"><span class="linenos">1832</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1833"><a href="#L-1833"><span class="linenos">1833</span></a> +</span><span id="L-1834"><a href="#L-1834"><span class="linenos">1834</span></a> <span class="k">def</span> <span class="nf">jsonobject_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONObject</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1835"><a href="#L-1835"><span class="linenos">1835</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"null_handling"</span><span class="p">)</span> +</span><span id="L-1836"><a href="#L-1836"><span class="linenos">1836</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1837"><a href="#L-1837"><span class="linenos">1837</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unique_keys"</span><span class="p">)</span> +</span><span id="L-1838"><a href="#L-1838"><span class="linenos">1838</span></a> <span class="k">if</span> <span class="n">unique_keys</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-1839"><a href="#L-1839"><span class="linenos">1839</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">'WITH'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">unique_keys</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'WITHOUT'</span><span class="si">}</span><span class="s2"> UNIQUE KEYS"</span> +</span><span id="L-1840"><a href="#L-1840"><span class="linenos">1840</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1841"><a href="#L-1841"><span class="linenos">1841</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-1842"><a href="#L-1842"><span class="linenos">1842</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"return_type"</span><span class="p">)</span> +</span><span id="L-1843"><a href="#L-1843"><span class="linenos">1843</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1844"><a href="#L-1844"><span class="linenos">1844</span></a> <span class="n">format_json</span> <span class="o">=</span> <span class="s2">" FORMAT JSON"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"format_json"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1845"><a href="#L-1845"><span class="linenos">1845</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"encoding"</span><span class="p">)</span> +</span><span id="L-1846"><a href="#L-1846"><span class="linenos">1846</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ENCODING </span><span class="si">{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">encoding</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1847"><a href="#L-1847"><span class="linenos">1847</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-1848"><a href="#L-1848"><span class="linenos">1848</span></a> <span class="s2">"JSON_OBJECT"</span><span class="p">,</span> +</span><span id="L-1849"><a href="#L-1849"><span class="linenos">1849</span></a> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-1850"><a href="#L-1850"><span class="linenos">1850</span></a> <span class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">null_handling</span><span class="si">}{</span><span class="n">unique_keys</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">format_json</span><span class="si">}{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="L-1851"><a href="#L-1851"><span class="linenos">1851</span></a> <span class="p">)</span> +</span><span id="L-1852"><a href="#L-1852"><span class="linenos">1852</span></a> +</span><span id="L-1853"><a href="#L-1853"><span class="linenos">1853</span></a> <span class="k">def</span> <span class="nf">openjsoncolumndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSONColumnDef</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1854"><a href="#L-1854"><span class="linenos">1854</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1855"><a href="#L-1855"><span class="linenos">1855</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="L-1856"><a href="#L-1856"><span class="linenos">1856</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> +</span><span id="L-1857"><a href="#L-1857"><span class="linenos">1857</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1858"><a href="#L-1858"><span class="linenos">1858</span></a> <span class="n">as_json</span> <span class="o">=</span> <span class="s2">" AS JSON"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"as_json"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1859"><a href="#L-1859"><span class="linenos">1859</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">path</span><span class="si">}{</span><span class="n">as_json</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1860"><a href="#L-1860"><span class="linenos">1860</span></a> +</span><span id="L-1861"><a href="#L-1861"><span class="linenos">1861</span></a> <span class="k">def</span> <span class="nf">openjson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1862"><a href="#L-1862"><span class="linenos">1862</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1863"><a href="#L-1863"><span class="linenos">1863</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> +</span><span id="L-1864"><a href="#L-1864"><span class="linenos">1864</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1865"><a href="#L-1865"><span class="linenos">1865</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-1866"><a href="#L-1866"><span class="linenos">1866</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-1867"><a href="#L-1867"><span class="linenos">1867</span></a> <span class="sa">f</span><span class="s2">" WITH (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">expressions</span><span class="p">),</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1868"><a href="#L-1868"><span class="linenos">1868</span></a> <span class="k">if</span> <span class="n">expressions</span> +</span><span id="L-1869"><a href="#L-1869"><span class="linenos">1869</span></a> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1870"><a href="#L-1870"><span class="linenos">1870</span></a> <span class="p">)</span> +</span><span id="L-1871"><a href="#L-1871"><span class="linenos">1871</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"OPENJSON(</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">path</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">with_</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1872"><a href="#L-1872"><span class="linenos">1872</span></a> +</span><span id="L-1873"><a href="#L-1873"><span class="linenos">1873</span></a> <span class="k">def</span> <span class="nf">in_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">In</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1874"><a href="#L-1874"><span class="linenos">1874</span></a> <span class="n">query</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"query"</span><span class="p">)</span> +</span><span id="L-1875"><a href="#L-1875"><span class="linenos">1875</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unnest"</span><span class="p">)</span> +</span><span id="L-1876"><a href="#L-1876"><span class="linenos">1876</span></a> <span class="n">field</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"field"</span><span class="p">)</span> +</span><span id="L-1877"><a href="#L-1877"><span class="linenos">1877</span></a> <span class="n">is_global</span> <span class="o">=</span> <span class="s2">" GLOBAL"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"is_global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1878"><a href="#L-1878"><span class="linenos">1878</span></a> +</span><span id="L-1879"><a href="#L-1879"><span class="linenos">1879</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> +</span><span id="L-1880"><a href="#L-1880"><span class="linenos">1880</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">query</span><span class="p">)</span> +</span><span id="L-1881"><a href="#L-1881"><span class="linenos">1881</span></a> <span class="k">elif</span> <span class="n">unnest</span><span class="p">:</span> +</span><span id="L-1882"><a href="#L-1882"><span class="linenos">1882</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">in_unnest_op</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span> +</span><span id="L-1883"><a href="#L-1883"><span class="linenos">1883</span></a> <span class="k">elif</span> <span class="n">field</span><span class="p">:</span> +</span><span id="L-1884"><a href="#L-1884"><span class="linenos">1884</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">field</span><span class="p">)</span> +</span><span id="L-1885"><a href="#L-1885"><span class="linenos">1885</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1886"><a href="#L-1886"><span class="linenos">1886</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> </span><span id="L-1887"><a href="#L-1887"><span class="linenos">1887</span></a> -</span><span id="L-1888"><a href="#L-1888"><span class="linenos">1888</span></a> <span class="k">def</span> <span class="nf">anonymous_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Anonymous</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1889"><a href="#L-1889"><span class="linenos">1889</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-1890"><a href="#L-1890"><span class="linenos">1890</span></a> -</span><span id="L-1891"><a href="#L-1891"><span class="linenos">1891</span></a> <span class="k">def</span> <span class="nf">paren_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1892"><a href="#L-1892"><span class="linenos">1892</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">unnest</span><span class="p">(),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> -</span><span id="L-1893"><a href="#L-1893"><span class="linenos">1893</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-1894"><a href="#L-1894"><span class="linenos">1894</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1895"><a href="#L-1895"><span class="linenos">1895</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="L-1896"><a href="#L-1896"><span class="linenos">1896</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1897"><a href="#L-1897"><span class="linenos">1897</span></a> -</span><span id="L-1898"><a href="#L-1898"><span class="linenos">1898</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="L-1899"><a href="#L-1899"><span class="linenos">1899</span></a> -</span><span id="L-1900"><a href="#L-1900"><span class="linenos">1900</span></a> <span class="k">def</span> <span class="nf">neg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Neg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1901"><a href="#L-1901"><span class="linenos">1901</span></a> <span class="c1"># This makes sure we don't convert "- - 5" to "--5", which is a comment</span> -</span><span id="L-1902"><a href="#L-1902"><span class="linenos">1902</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-1903"><a href="#L-1903"><span class="linenos">1903</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">this_sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"-"</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1904"><a href="#L-1904"><span class="linenos">1904</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"-</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1905"><a href="#L-1905"><span class="linenos">1905</span></a> -</span><span id="L-1906"><a href="#L-1906"><span class="linenos">1906</span></a> <span class="k">def</span> <span class="nf">not_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Not</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1907"><a href="#L-1907"><span class="linenos">1907</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NOT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1908"><a href="#L-1908"><span class="linenos">1908</span></a> -</span><span id="L-1909"><a href="#L-1909"><span class="linenos">1909</span></a> <span class="k">def</span> <span class="nf">alias_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1910"><a href="#L-1910"><span class="linenos">1910</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="L-1911"><a href="#L-1911"><span class="linenos">1911</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1912"><a href="#L-1912"><span class="linenos">1912</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1913"><a href="#L-1913"><span class="linenos">1913</span></a> -</span><span id="L-1914"><a href="#L-1914"><span class="linenos">1914</span></a> <span class="k">def</span> <span class="nf">aliases_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Aliases</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1915"><a href="#L-1915"><span class="linenos">1915</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-1916"><a href="#L-1916"><span class="linenos">1916</span></a> -</span><span id="L-1917"><a href="#L-1917"><span class="linenos">1917</span></a> <span class="k">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1918"><a href="#L-1918"><span class="linenos">1918</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1919"><a href="#L-1919"><span class="linenos">1919</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">)</span> -</span><span id="L-1920"><a href="#L-1920"><span class="linenos">1920</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> AT TIME ZONE </span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1921"><a href="#L-1921"><span class="linenos">1921</span></a> -</span><span id="L-1922"><a href="#L-1922"><span class="linenos">1922</span></a> <span class="k">def</span> <span class="nf">add_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Add</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1923"><a href="#L-1923"><span class="linenos">1923</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">)</span> -</span><span id="L-1924"><a href="#L-1924"><span class="linenos">1924</span></a> -</span><span id="L-1925"><a href="#L-1925"><span class="linenos">1925</span></a> <span class="k">def</span> <span class="nf">and_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">And</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1926"><a href="#L-1926"><span class="linenos">1926</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"AND"</span><span class="p">)</span> -</span><span id="L-1927"><a href="#L-1927"><span class="linenos">1927</span></a> -</span><span id="L-1928"><a href="#L-1928"><span class="linenos">1928</span></a> <span class="k">def</span> <span class="nf">connector_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Connector</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1929"><a href="#L-1929"><span class="linenos">1929</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="L-1930"><a href="#L-1930"><span class="linenos">1930</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">op</span><span class="p">)</span> -</span><span id="L-1931"><a href="#L-1931"><span class="linenos">1931</span></a> -</span><span id="L-1932"><a href="#L-1932"><span class="linenos">1932</span></a> <span class="n">sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> -</span><span id="L-1933"><a href="#L-1933"><span class="linenos">1933</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> <span class="n">e</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">comments</span> <span class="ow">or</span> <span class="p">[])</span> <span class="k">if</span> <span class="n">i</span> <span class="o">!=</span> <span class="mi">1</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> -</span><span id="L-1934"><a href="#L-1934"><span class="linenos">1934</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">(</span><span class="n">unnest</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> -</span><span id="L-1935"><a href="#L-1935"><span class="linenos">1935</span></a> <span class="p">)</span> -</span><span id="L-1936"><a href="#L-1936"><span class="linenos">1936</span></a> -</span><span id="L-1937"><a href="#L-1937"><span class="linenos">1937</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="L-1938"><a href="#L-1938"><span class="linenos">1938</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">op</span><span class="si">}</span><span class="s2"> "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> -</span><span id="L-1939"><a href="#L-1939"><span class="linenos">1939</span></a> -</span><span id="L-1940"><a href="#L-1940"><span class="linenos">1940</span></a> <span class="k">def</span> <span class="nf">bitwiseand_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1941"><a href="#L-1941"><span class="linenos">1941</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"&"</span><span class="p">)</span> -</span><span id="L-1942"><a href="#L-1942"><span class="linenos">1942</span></a> -</span><span id="L-1943"><a href="#L-1943"><span class="linenos">1943</span></a> <span class="k">def</span> <span class="nf">bitwiseleftshift_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1944"><a href="#L-1944"><span class="linenos">1944</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<<"</span><span class="p">)</span> -</span><span id="L-1945"><a href="#L-1945"><span class="linenos">1945</span></a> -</span><span id="L-1946"><a href="#L-1946"><span class="linenos">1946</span></a> <span class="k">def</span> <span class="nf">bitwisenot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1947"><a href="#L-1947"><span class="linenos">1947</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"~</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1948"><a href="#L-1948"><span class="linenos">1948</span></a> -</span><span id="L-1949"><a href="#L-1949"><span class="linenos">1949</span></a> <span class="k">def</span> <span class="nf">bitwiseor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1950"><a href="#L-1950"><span class="linenos">1950</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"|"</span><span class="p">)</span> -</span><span id="L-1951"><a href="#L-1951"><span class="linenos">1951</span></a> -</span><span id="L-1952"><a href="#L-1952"><span class="linenos">1952</span></a> <span class="k">def</span> <span class="nf">bitwiserightshift_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1953"><a href="#L-1953"><span class="linenos">1953</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">>"</span><span class="p">)</span> +</span><span id="L-1888"><a href="#L-1888"><span class="linenos">1888</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">is_global</span><span class="si">}</span><span class="s2"> IN </span><span class="si">{</span><span class="n">in_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1889"><a href="#L-1889"><span class="linenos">1889</span></a> +</span><span id="L-1890"><a href="#L-1890"><span class="linenos">1890</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">unnest</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1891"><a href="#L-1891"><span class="linenos">1891</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(SELECT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1892"><a href="#L-1892"><span class="linenos">1892</span></a> +</span><span id="L-1893"><a href="#L-1893"><span class="linenos">1893</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-1894"><a href="#L-1894"><span class="linenos">1894</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> +</span><span id="L-1895"><a href="#L-1895"><span class="linenos">1895</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span><span class="p">:</span> +</span><span id="L-1896"><a href="#L-1896"><span class="linenos">1896</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_PART_SINGULARS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> <span class="n">unit</span><span class="p">)</span> +</span><span id="L-1897"><a href="#L-1897"><span class="linenos">1897</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1898"><a href="#L-1898"><span class="linenos">1898</span></a> +</span><span id="L-1899"><a href="#L-1899"><span class="linenos">1899</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_STRING_INTERVAL</span><span class="p">:</span> +</span><span id="L-1900"><a href="#L-1900"><span class="linenos">1900</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1901"><a href="#L-1901"><span class="linenos">1901</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL '</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">'"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1902"><a href="#L-1902"><span class="linenos">1902</span></a> +</span><span id="L-1903"><a href="#L-1903"><span class="linenos">1903</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1904"><a href="#L-1904"><span class="linenos">1904</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> +</span><span id="L-1905"><a href="#L-1905"><span class="linenos">1905</span></a> <span class="n">unwrapped</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">)</span> +</span><span id="L-1906"><a href="#L-1906"><span class="linenos">1906</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unwrapped</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1907"><a href="#L-1907"><span class="linenos">1907</span></a> +</span><span id="L-1908"><a href="#L-1908"><span class="linenos">1908</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1909"><a href="#L-1909"><span class="linenos">1909</span></a> +</span><span id="L-1910"><a href="#L-1910"><span class="linenos">1910</span></a> <span class="k">def</span> <span class="nf">return_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Return</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1911"><a href="#L-1911"><span class="linenos">1911</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RETURN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1912"><a href="#L-1912"><span class="linenos">1912</span></a> +</span><span id="L-1913"><a href="#L-1913"><span class="linenos">1913</span></a> <span class="k">def</span> <span class="nf">reference_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Reference</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1914"><a href="#L-1914"><span class="linenos">1914</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1915"><a href="#L-1915"><span class="linenos">1915</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1916"><a href="#L-1916"><span class="linenos">1916</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1917"><a href="#L-1917"><span class="linenos">1917</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="L-1918"><a href="#L-1918"><span class="linenos">1918</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1919"><a href="#L-1919"><span class="linenos">1919</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"REFERENCES </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1920"><a href="#L-1920"><span class="linenos">1920</span></a> +</span><span id="L-1921"><a href="#L-1921"><span class="linenos">1921</span></a> <span class="k">def</span> <span class="nf">anonymous_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Anonymous</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1922"><a href="#L-1922"><span class="linenos">1922</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-1923"><a href="#L-1923"><span class="linenos">1923</span></a> +</span><span id="L-1924"><a href="#L-1924"><span class="linenos">1924</span></a> <span class="k">def</span> <span class="nf">paren_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1925"><a href="#L-1925"><span class="linenos">1925</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">unnest</span><span class="p">(),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> +</span><span id="L-1926"><a href="#L-1926"><span class="linenos">1926</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-1927"><a href="#L-1927"><span class="linenos">1927</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1928"><a href="#L-1928"><span class="linenos">1928</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> +</span><span id="L-1929"><a href="#L-1929"><span class="linenos">1929</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1930"><a href="#L-1930"><span class="linenos">1930</span></a> +</span><span id="L-1931"><a href="#L-1931"><span class="linenos">1931</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="L-1932"><a href="#L-1932"><span class="linenos">1932</span></a> +</span><span id="L-1933"><a href="#L-1933"><span class="linenos">1933</span></a> <span class="k">def</span> <span class="nf">neg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Neg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1934"><a href="#L-1934"><span class="linenos">1934</span></a> <span class="c1"># This makes sure we don't convert "- - 5" to "--5", which is a comment</span> +</span><span id="L-1935"><a href="#L-1935"><span class="linenos">1935</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-1936"><a href="#L-1936"><span class="linenos">1936</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">this_sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"-"</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1937"><a href="#L-1937"><span class="linenos">1937</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"-</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1938"><a href="#L-1938"><span class="linenos">1938</span></a> +</span><span id="L-1939"><a href="#L-1939"><span class="linenos">1939</span></a> <span class="k">def</span> <span class="nf">not_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Not</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1940"><a href="#L-1940"><span class="linenos">1940</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NOT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1941"><a href="#L-1941"><span class="linenos">1941</span></a> +</span><span id="L-1942"><a href="#L-1942"><span class="linenos">1942</span></a> <span class="k">def</span> <span class="nf">alias_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1943"><a href="#L-1943"><span class="linenos">1943</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="L-1944"><a href="#L-1944"><span class="linenos">1944</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-1945"><a href="#L-1945"><span class="linenos">1945</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1946"><a href="#L-1946"><span class="linenos">1946</span></a> +</span><span id="L-1947"><a href="#L-1947"><span class="linenos">1947</span></a> <span class="k">def</span> <span class="nf">aliases_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Aliases</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1948"><a href="#L-1948"><span class="linenos">1948</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1949"><a href="#L-1949"><span class="linenos">1949</span></a> +</span><span id="L-1950"><a href="#L-1950"><span class="linenos">1950</span></a> <span class="k">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1951"><a href="#L-1951"><span class="linenos">1951</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1952"><a href="#L-1952"><span class="linenos">1952</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">)</span> +</span><span id="L-1953"><a href="#L-1953"><span class="linenos">1953</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> AT TIME ZONE </span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-1954"><a href="#L-1954"><span class="linenos">1954</span></a> -</span><span id="L-1955"><a href="#L-1955"><span class="linenos">1955</span></a> <span class="k">def</span> <span class="nf">bitwisexor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1956"><a href="#L-1956"><span class="linenos">1956</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"^"</span><span class="p">)</span> +</span><span id="L-1955"><a href="#L-1955"><span class="linenos">1955</span></a> <span class="k">def</span> <span class="nf">add_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Add</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1956"><a href="#L-1956"><span class="linenos">1956</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">)</span> </span><span id="L-1957"><a href="#L-1957"><span class="linenos">1957</span></a> -</span><span id="L-1958"><a href="#L-1958"><span class="linenos">1958</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1959"><a href="#L-1959"><span class="linenos">1959</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">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'to'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1958"><a href="#L-1958"><span class="linenos">1958</span></a> <span class="k">def</span> <span class="nf">and_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">And</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1959"><a href="#L-1959"><span class="linenos">1959</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"AND"</span><span class="p">)</span> </span><span id="L-1960"><a href="#L-1960"><span class="linenos">1960</span></a> -</span><span id="L-1961"><a href="#L-1961"><span class="linenos">1961</span></a> <span class="k">def</span> <span class="nf">currentdate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1962"><a href="#L-1962"><span class="linenos">1962</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-1963"><a href="#L-1963"><span class="linenos">1963</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CURRENT_DATE(</span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">zone</span> <span class="k">else</span> <span class="s2">"CURRENT_DATE"</span> +</span><span id="L-1961"><a href="#L-1961"><span class="linenos">1961</span></a> <span class="k">def</span> <span class="nf">connector_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Connector</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1962"><a href="#L-1962"><span class="linenos">1962</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="L-1963"><a href="#L-1963"><span class="linenos">1963</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">op</span><span class="p">)</span> </span><span id="L-1964"><a href="#L-1964"><span class="linenos">1964</span></a> -</span><span id="L-1965"><a href="#L-1965"><span class="linenos">1965</span></a> <span class="k">def</span> <span class="nf">collate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Collate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1966"><a href="#L-1966"><span class="linenos">1966</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"COLLATE"</span><span class="p">)</span> -</span><span id="L-1967"><a href="#L-1967"><span class="linenos">1967</span></a> -</span><span id="L-1968"><a href="#L-1968"><span class="linenos">1968</span></a> <span class="k">def</span> <span class="nf">command_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1969"><a href="#L-1969"><span class="linenos">1969</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s1">'expression'</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1970"><a href="#L-1970"><span class="linenos">1970</span></a> -</span><span id="L-1971"><a href="#L-1971"><span class="linenos">1971</span></a> <span class="k">def</span> <span class="nf">comment_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Comment</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1972"><a href="#L-1972"><span class="linenos">1972</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-1973"><a href="#L-1973"><span class="linenos">1973</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> -</span><span id="L-1974"><a href="#L-1974"><span class="linenos">1974</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="L-1975"><a href="#L-1975"><span class="linenos">1975</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-1976"><a href="#L-1976"><span class="linenos">1976</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMENT</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> IS </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1977"><a href="#L-1977"><span class="linenos">1977</span></a> -</span><span id="L-1978"><a href="#L-1978"><span class="linenos">1978</span></a> <span class="k">def</span> <span class="nf">mergetreettlaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTLAction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1979"><a href="#L-1979"><span class="linenos">1979</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-1980"><a href="#L-1980"><span class="linenos">1980</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="s2">" DELETE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"delete"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1981"><a href="#L-1981"><span class="linenos">1981</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"recompress"</span><span class="p">)</span> -</span><span id="L-1982"><a href="#L-1982"><span class="linenos">1982</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECOMPRESS </span><span class="si">{</span><span class="n">recompress</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">recompress</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1983"><a href="#L-1983"><span class="linenos">1983</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_disk"</span><span class="p">)</span> -</span><span id="L-1984"><a href="#L-1984"><span class="linenos">1984</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO DISK </span><span class="si">{</span><span class="n">to_disk</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_disk</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1985"><a href="#L-1985"><span class="linenos">1985</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_volume"</span><span class="p">)</span> -</span><span id="L-1986"><a href="#L-1986"><span class="linenos">1986</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO VOLUME </span><span class="si">{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_volume</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1987"><a href="#L-1987"><span class="linenos">1987</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">recompress</span><span class="si">}{</span><span class="n">to_disk</span><span class="si">}{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1988"><a href="#L-1988"><span class="linenos">1988</span></a> -</span><span id="L-1989"><a href="#L-1989"><span class="linenos">1989</span></a> <span class="k">def</span> <span class="nf">mergetreettl_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1990"><a href="#L-1990"><span class="linenos">1990</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> -</span><span id="L-1991"><a href="#L-1991"><span class="linenos">1991</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">)</span> -</span><span id="L-1992"><a href="#L-1992"><span class="linenos">1992</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"aggregates"</span><span class="p">)</span> -</span><span id="L-1993"><a href="#L-1993"><span class="linenos">1993</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"SET"</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">aggregates</span><span class="p">)</span> <span class="k">if</span> <span class="n">aggregates</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-1994"><a href="#L-1994"><span class="linenos">1994</span></a> -</span><span id="L-1995"><a href="#L-1995"><span class="linenos">1995</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">where</span> <span class="ow">or</span> <span class="n">group</span> <span class="ow">or</span> <span class="n">aggregates</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-1996"><a href="#L-1996"><span class="linenos">1996</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1965"><a href="#L-1965"><span class="linenos">1965</span></a> <span class="n">sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> +</span><span id="L-1966"><a href="#L-1966"><span class="linenos">1966</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> <span class="n">e</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">comments</span> <span class="ow">or</span> <span class="p">[])</span> <span class="k">if</span> <span class="n">i</span> <span class="o">!=</span> <span class="mi">1</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> +</span><span id="L-1967"><a href="#L-1967"><span class="linenos">1967</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">(</span><span class="n">unnest</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> +</span><span id="L-1968"><a href="#L-1968"><span class="linenos">1968</span></a> <span class="p">)</span> +</span><span id="L-1969"><a href="#L-1969"><span class="linenos">1969</span></a> +</span><span id="L-1970"><a href="#L-1970"><span class="linenos">1970</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="L-1971"><a href="#L-1971"><span class="linenos">1971</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">op</span><span class="si">}</span><span class="s2"> "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> +</span><span id="L-1972"><a href="#L-1972"><span class="linenos">1972</span></a> +</span><span id="L-1973"><a href="#L-1973"><span class="linenos">1973</span></a> <span class="k">def</span> <span class="nf">bitwiseand_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1974"><a href="#L-1974"><span class="linenos">1974</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"&"</span><span class="p">)</span> +</span><span id="L-1975"><a href="#L-1975"><span class="linenos">1975</span></a> +</span><span id="L-1976"><a href="#L-1976"><span class="linenos">1976</span></a> <span class="k">def</span> <span class="nf">bitwiseleftshift_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1977"><a href="#L-1977"><span class="linenos">1977</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<<"</span><span class="p">)</span> +</span><span id="L-1978"><a href="#L-1978"><span class="linenos">1978</span></a> +</span><span id="L-1979"><a href="#L-1979"><span class="linenos">1979</span></a> <span class="k">def</span> <span class="nf">bitwisenot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1980"><a href="#L-1980"><span class="linenos">1980</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"~</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1981"><a href="#L-1981"><span class="linenos">1981</span></a> +</span><span id="L-1982"><a href="#L-1982"><span class="linenos">1982</span></a> <span class="k">def</span> <span class="nf">bitwiseor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1983"><a href="#L-1983"><span class="linenos">1983</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"|"</span><span class="p">)</span> +</span><span id="L-1984"><a href="#L-1984"><span class="linenos">1984</span></a> +</span><span id="L-1985"><a href="#L-1985"><span class="linenos">1985</span></a> <span class="k">def</span> <span class="nf">bitwiserightshift_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1986"><a href="#L-1986"><span class="linenos">1986</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">>"</span><span class="p">)</span> +</span><span id="L-1987"><a href="#L-1987"><span class="linenos">1987</span></a> +</span><span id="L-1988"><a href="#L-1988"><span class="linenos">1988</span></a> <span class="k">def</span> <span class="nf">bitwisexor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1989"><a href="#L-1989"><span class="linenos">1989</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"^"</span><span class="p">)</span> +</span><span id="L-1990"><a href="#L-1990"><span class="linenos">1990</span></a> +</span><span id="L-1991"><a href="#L-1991"><span class="linenos">1991</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1992"><a href="#L-1992"><span class="linenos">1992</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'to'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-1993"><a href="#L-1993"><span class="linenos">1993</span></a> +</span><span id="L-1994"><a href="#L-1994"><span class="linenos">1994</span></a> <span class="k">def</span> <span class="nf">currentdate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1995"><a href="#L-1995"><span class="linenos">1995</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-1996"><a href="#L-1996"><span class="linenos">1996</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CURRENT_DATE(</span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">zone</span> <span class="k">else</span> <span class="s2">"CURRENT_DATE"</span> </span><span id="L-1997"><a href="#L-1997"><span class="linenos">1997</span></a> -</span><span id="L-1998"><a href="#L-1998"><span class="linenos">1998</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">))</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">group</span><span class="si">}{</span><span class="n">aggregates</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1999"><a href="#L-1999"><span class="linenos">1999</span></a> -</span><span id="L-2000"><a href="#L-2000"><span class="linenos">2000</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2001"><a href="#L-2001"><span class="linenos">2001</span></a> <span class="k">return</span> <span class="s2">"BEGIN"</span> -</span><span id="L-2002"><a href="#L-2002"><span class="linenos">2002</span></a> -</span><span id="L-2003"><a href="#L-2003"><span class="linenos">2003</span></a> <span class="k">def</span> <span class="nf">commit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Commit</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2004"><a href="#L-2004"><span class="linenos">2004</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"chain"</span><span class="p">)</span> -</span><span id="L-2005"><a href="#L-2005"><span class="linenos">2005</span></a> <span class="k">if</span> <span class="n">chain</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-2006"><a href="#L-2006"><span class="linenos">2006</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="s2">" AND CHAIN"</span> <span class="k">if</span> <span class="n">chain</span> <span class="k">else</span> <span class="s2">" AND NO CHAIN"</span> -</span><span id="L-2007"><a href="#L-2007"><span class="linenos">2007</span></a> -</span><span id="L-2008"><a href="#L-2008"><span class="linenos">2008</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMIT</span><span class="si">{</span><span class="n">chain</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2009"><a href="#L-2009"><span class="linenos">2009</span></a> -</span><span id="L-2010"><a href="#L-2010"><span class="linenos">2010</span></a> <span class="k">def</span> <span class="nf">rollback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Rollback</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2011"><a href="#L-2011"><span class="linenos">2011</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"savepoint"</span><span class="p">)</span> -</span><span id="L-2012"><a href="#L-2012"><span class="linenos">2012</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO </span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">savepoint</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2013"><a href="#L-2013"><span class="linenos">2013</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROLLBACK</span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2014"><a href="#L-2014"><span class="linenos">2014</span></a> -</span><span id="L-2015"><a href="#L-2015"><span class="linenos">2015</span></a> <span class="k">def</span> <span class="nf">altercolumn_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AlterColumn</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2016"><a href="#L-2016"><span class="linenos">2016</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-2017"><a href="#L-2017"><span class="linenos">2017</span></a> -</span><span id="L-2018"><a href="#L-2018"><span class="linenos">2018</span></a> <span class="n">dtype</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"dtype"</span><span class="p">)</span> -</span><span id="L-2019"><a href="#L-2019"><span class="linenos">2019</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="p">:</span> -</span><span id="L-2020"><a href="#L-2020"><span class="linenos">2020</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collate"</span><span class="p">)</span> -</span><span id="L-2021"><a href="#L-2021"><span class="linenos">2021</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collate</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2022"><a href="#L-2022"><span class="linenos">2022</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> -</span><span id="L-2023"><a href="#L-2023"><span class="linenos">2023</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2024"><a href="#L-2024"><span class="linenos">2024</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> TYPE </span><span class="si">{</span><span class="n">dtype</span><span class="si">}{</span><span class="n">collate</span><span class="si">}{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2025"><a href="#L-2025"><span class="linenos">2025</span></a> -</span><span id="L-2026"><a href="#L-2026"><span class="linenos">2026</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">)</span> -</span><span id="L-2027"><a href="#L-2027"><span class="linenos">2027</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="L-2028"><a href="#L-2028"><span class="linenos">2028</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET DEFAULT </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2029"><a href="#L-2029"><span class="linenos">2029</span></a> -</span><span id="L-2030"><a href="#L-2030"><span class="linenos">2030</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"drop"</span><span class="p">):</span> -</span><span id="L-2031"><a href="#L-2031"><span class="linenos">2031</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Unsupported ALTER COLUMN syntax"</span><span class="p">)</span> +</span><span id="L-1998"><a href="#L-1998"><span class="linenos">1998</span></a> <span class="k">def</span> <span class="nf">collate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Collate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1999"><a href="#L-1999"><span class="linenos">1999</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"COLLATE"</span><span class="p">)</span> +</span><span id="L-2000"><a href="#L-2000"><span class="linenos">2000</span></a> +</span><span id="L-2001"><a href="#L-2001"><span class="linenos">2001</span></a> <span class="k">def</span> <span class="nf">command_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2002"><a href="#L-2002"><span class="linenos">2002</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s1">'expression'</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2003"><a href="#L-2003"><span class="linenos">2003</span></a> +</span><span id="L-2004"><a href="#L-2004"><span class="linenos">2004</span></a> <span class="k">def</span> <span class="nf">comment_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Comment</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2005"><a href="#L-2005"><span class="linenos">2005</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-2006"><a href="#L-2006"><span class="linenos">2006</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> +</span><span id="L-2007"><a href="#L-2007"><span class="linenos">2007</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="L-2008"><a href="#L-2008"><span class="linenos">2008</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-2009"><a href="#L-2009"><span class="linenos">2009</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMENT</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> IS </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2010"><a href="#L-2010"><span class="linenos">2010</span></a> +</span><span id="L-2011"><a href="#L-2011"><span class="linenos">2011</span></a> <span class="k">def</span> <span class="nf">mergetreettlaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTLAction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2012"><a href="#L-2012"><span class="linenos">2012</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-2013"><a href="#L-2013"><span class="linenos">2013</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="s2">" DELETE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"delete"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2014"><a href="#L-2014"><span class="linenos">2014</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"recompress"</span><span class="p">)</span> +</span><span id="L-2015"><a href="#L-2015"><span class="linenos">2015</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECOMPRESS </span><span class="si">{</span><span class="n">recompress</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">recompress</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2016"><a href="#L-2016"><span class="linenos">2016</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_disk"</span><span class="p">)</span> +</span><span id="L-2017"><a href="#L-2017"><span class="linenos">2017</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO DISK </span><span class="si">{</span><span class="n">to_disk</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_disk</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2018"><a href="#L-2018"><span class="linenos">2018</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_volume"</span><span class="p">)</span> +</span><span id="L-2019"><a href="#L-2019"><span class="linenos">2019</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO VOLUME </span><span class="si">{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_volume</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2020"><a href="#L-2020"><span class="linenos">2020</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">recompress</span><span class="si">}{</span><span class="n">to_disk</span><span class="si">}{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2021"><a href="#L-2021"><span class="linenos">2021</span></a> +</span><span id="L-2022"><a href="#L-2022"><span class="linenos">2022</span></a> <span class="k">def</span> <span class="nf">mergetreettl_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2023"><a href="#L-2023"><span class="linenos">2023</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> +</span><span id="L-2024"><a href="#L-2024"><span class="linenos">2024</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">)</span> +</span><span id="L-2025"><a href="#L-2025"><span class="linenos">2025</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"aggregates"</span><span class="p">)</span> +</span><span id="L-2026"><a href="#L-2026"><span class="linenos">2026</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"SET"</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">aggregates</span><span class="p">)</span> <span class="k">if</span> <span class="n">aggregates</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2027"><a href="#L-2027"><span class="linenos">2027</span></a> +</span><span id="L-2028"><a href="#L-2028"><span class="linenos">2028</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">where</span> <span class="ow">or</span> <span class="n">group</span> <span class="ow">or</span> <span class="n">aggregates</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-2029"><a href="#L-2029"><span class="linenos">2029</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2030"><a href="#L-2030"><span class="linenos">2030</span></a> +</span><span id="L-2031"><a href="#L-2031"><span class="linenos">2031</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">))</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">group</span><span class="si">}{</span><span class="n">aggregates</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2032"><a href="#L-2032"><span class="linenos">2032</span></a> -</span><span id="L-2033"><a href="#L-2033"><span class="linenos">2033</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> DROP DEFAULT"</span> -</span><span id="L-2034"><a href="#L-2034"><span class="linenos">2034</span></a> -</span><span id="L-2035"><a href="#L-2035"><span class="linenos">2035</span></a> <span class="k">def</span> <span class="nf">renametable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RenameTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2036"><a href="#L-2036"><span class="linenos">2036</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">RENAME_TABLE_WITH_DB</span><span class="p">:</span> -</span><span id="L-2037"><a href="#L-2037"><span class="linenos">2037</span></a> <span class="c1"># Remove db from tables</span> -</span><span id="L-2038"><a href="#L-2038"><span class="linenos">2038</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> -</span><span id="L-2039"><a href="#L-2039"><span class="linenos">2039</span></a> <span class="k">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">table_</span><span class="p">(</span><span class="n">n</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="k">else</span> <span class="n">n</span> -</span><span id="L-2040"><a href="#L-2040"><span class="linenos">2040</span></a> <span class="p">)</span> -</span><span id="L-2041"><a href="#L-2041"><span class="linenos">2041</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-2042"><a href="#L-2042"><span class="linenos">2042</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RENAME TO </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2043"><a href="#L-2043"><span class="linenos">2043</span></a> -</span><span id="L-2044"><a href="#L-2044"><span class="linenos">2044</span></a> <span class="k">def</span> <span class="nf">altertable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AlterTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2045"><a href="#L-2045"><span class="linenos">2045</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"actions"</span><span class="p">]</span> -</span><span id="L-2046"><a href="#L-2046"><span class="linenos">2046</span></a> -</span><span id="L-2047"><a href="#L-2047"><span class="linenos">2047</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">):</span> -</span><span id="L-2048"><a href="#L-2048"><span class="linenos">2048</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMN "</span><span class="p">)</span> -</span><span id="L-2049"><a href="#L-2049"><span class="linenos">2049</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">):</span> -</span><span id="L-2050"><a href="#L-2050"><span class="linenos">2050</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMNS "</span><span class="p">)</span> -</span><span id="L-2051"><a href="#L-2051"><span class="linenos">2051</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">):</span> -</span><span id="L-2052"><a href="#L-2052"><span class="linenos">2052</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2053"><a href="#L-2053"><span class="linenos">2053</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2054"><a href="#L-2054"><span class="linenos">2054</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">)</span> -</span><span id="L-2055"><a href="#L-2055"><span class="linenos">2055</span></a> -</span><span id="L-2056"><a href="#L-2056"><span class="linenos">2056</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2057"><a href="#L-2057"><span class="linenos">2057</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER TABLE</span><span class="si">{</span><span class="n">exists</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">actions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2033"><a href="#L-2033"><span class="linenos">2033</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2034"><a href="#L-2034"><span class="linenos">2034</span></a> <span class="k">return</span> <span class="s2">"BEGIN"</span> +</span><span id="L-2035"><a href="#L-2035"><span class="linenos">2035</span></a> +</span><span id="L-2036"><a href="#L-2036"><span class="linenos">2036</span></a> <span class="k">def</span> <span class="nf">commit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Commit</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2037"><a href="#L-2037"><span class="linenos">2037</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"chain"</span><span class="p">)</span> +</span><span id="L-2038"><a href="#L-2038"><span class="linenos">2038</span></a> <span class="k">if</span> <span class="n">chain</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-2039"><a href="#L-2039"><span class="linenos">2039</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="s2">" AND CHAIN"</span> <span class="k">if</span> <span class="n">chain</span> <span class="k">else</span> <span class="s2">" AND NO CHAIN"</span> +</span><span id="L-2040"><a href="#L-2040"><span class="linenos">2040</span></a> +</span><span id="L-2041"><a href="#L-2041"><span class="linenos">2041</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMIT</span><span class="si">{</span><span class="n">chain</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2042"><a href="#L-2042"><span class="linenos">2042</span></a> +</span><span id="L-2043"><a href="#L-2043"><span class="linenos">2043</span></a> <span class="k">def</span> <span class="nf">rollback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Rollback</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2044"><a href="#L-2044"><span class="linenos">2044</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"savepoint"</span><span class="p">)</span> +</span><span id="L-2045"><a href="#L-2045"><span class="linenos">2045</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO </span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">savepoint</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2046"><a href="#L-2046"><span class="linenos">2046</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROLLBACK</span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2047"><a href="#L-2047"><span class="linenos">2047</span></a> +</span><span id="L-2048"><a href="#L-2048"><span class="linenos">2048</span></a> <span class="k">def</span> <span class="nf">altercolumn_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AlterColumn</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2049"><a href="#L-2049"><span class="linenos">2049</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-2050"><a href="#L-2050"><span class="linenos">2050</span></a> +</span><span id="L-2051"><a href="#L-2051"><span class="linenos">2051</span></a> <span class="n">dtype</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"dtype"</span><span class="p">)</span> +</span><span id="L-2052"><a href="#L-2052"><span class="linenos">2052</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="p">:</span> +</span><span id="L-2053"><a href="#L-2053"><span class="linenos">2053</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collate"</span><span class="p">)</span> +</span><span id="L-2054"><a href="#L-2054"><span class="linenos">2054</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collate</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2055"><a href="#L-2055"><span class="linenos">2055</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> +</span><span id="L-2056"><a href="#L-2056"><span class="linenos">2056</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2057"><a href="#L-2057"><span class="linenos">2057</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> TYPE </span><span class="si">{</span><span class="n">dtype</span><span class="si">}{</span><span class="n">collate</span><span class="si">}{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2058"><a href="#L-2058"><span class="linenos">2058</span></a> -</span><span id="L-2059"><a href="#L-2059"><span class="linenos">2059</span></a> <span class="k">def</span> <span class="nf">droppartition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DropPartition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2060"><a href="#L-2060"><span class="linenos">2060</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-2061"><a href="#L-2061"><span class="linenos">2061</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="L-2062"><a href="#L-2062"><span class="linenos">2062</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2063"><a href="#L-2063"><span class="linenos">2063</span></a> -</span><span id="L-2064"><a href="#L-2064"><span class="linenos">2064</span></a> <span class="k">def</span> <span class="nf">addconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AddConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2065"><a href="#L-2065"><span class="linenos">2065</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-2066"><a href="#L-2066"><span class="linenos">2066</span></a> <span class="n">expression_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="L-2067"><a href="#L-2067"><span class="linenos">2067</span></a> <span class="n">add_constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ADD CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">"ADD"</span> -</span><span id="L-2068"><a href="#L-2068"><span class="linenos">2068</span></a> -</span><span id="L-2069"><a href="#L-2069"><span class="linenos">2069</span></a> <span class="n">enforced</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"enforced"</span><span class="p">)</span> -</span><span id="L-2070"><a href="#L-2070"><span class="linenos">2070</span></a> <span class="k">if</span> <span class="n">enforced</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-2071"><a href="#L-2071"><span class="linenos">2071</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> CHECK (</span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="s1">' ENFORCED'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">enforced</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2072"><a href="#L-2072"><span class="linenos">2072</span></a> -</span><span id="L-2073"><a href="#L-2073"><span class="linenos">2073</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2074"><a href="#L-2074"><span class="linenos">2074</span></a> -</span><span id="L-2075"><a href="#L-2075"><span class="linenos">2075</span></a> <span class="k">def</span> <span class="nf">distinct_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distinct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2076"><a href="#L-2076"><span class="linenos">2076</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2077"><a href="#L-2077"><span class="linenos">2077</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2078"><a href="#L-2078"><span class="linenos">2078</span></a> -</span><span id="L-2079"><a href="#L-2079"><span class="linenos">2079</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">)</span> -</span><span id="L-2080"><a href="#L-2080"><span class="linenos">2080</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">on</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2081"><a href="#L-2081"><span class="linenos">2081</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DISTINCT</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2082"><a href="#L-2082"><span class="linenos">2082</span></a> -</span><span id="L-2083"><a href="#L-2083"><span class="linenos">2083</span></a> <span class="k">def</span> <span class="nf">ignorenulls_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IgnoreNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2084"><a href="#L-2084"><span class="linenos">2084</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> IGNORE NULLS"</span> -</span><span id="L-2085"><a href="#L-2085"><span class="linenos">2085</span></a> -</span><span id="L-2086"><a href="#L-2086"><span class="linenos">2086</span></a> <span class="k">def</span> <span class="nf">respectnulls_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RespectNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2087"><a href="#L-2087"><span class="linenos">2087</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> RESPECT NULLS"</span> +</span><span id="L-2059"><a href="#L-2059"><span class="linenos">2059</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">)</span> +</span><span id="L-2060"><a href="#L-2060"><span class="linenos">2060</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> +</span><span id="L-2061"><a href="#L-2061"><span class="linenos">2061</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET DEFAULT </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2062"><a href="#L-2062"><span class="linenos">2062</span></a> +</span><span id="L-2063"><a href="#L-2063"><span class="linenos">2063</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"drop"</span><span class="p">):</span> +</span><span id="L-2064"><a href="#L-2064"><span class="linenos">2064</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Unsupported ALTER COLUMN syntax"</span><span class="p">)</span> +</span><span id="L-2065"><a href="#L-2065"><span class="linenos">2065</span></a> +</span><span id="L-2066"><a href="#L-2066"><span class="linenos">2066</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> DROP DEFAULT"</span> +</span><span id="L-2067"><a href="#L-2067"><span class="linenos">2067</span></a> +</span><span id="L-2068"><a href="#L-2068"><span class="linenos">2068</span></a> <span class="k">def</span> <span class="nf">renametable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RenameTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2069"><a href="#L-2069"><span class="linenos">2069</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">RENAME_TABLE_WITH_DB</span><span class="p">:</span> +</span><span id="L-2070"><a href="#L-2070"><span class="linenos">2070</span></a> <span class="c1"># Remove db from tables</span> +</span><span id="L-2071"><a href="#L-2071"><span class="linenos">2071</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> +</span><span id="L-2072"><a href="#L-2072"><span class="linenos">2072</span></a> <span class="k">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">table_</span><span class="p">(</span><span class="n">n</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="k">else</span> <span class="n">n</span> +</span><span id="L-2073"><a href="#L-2073"><span class="linenos">2073</span></a> <span class="p">)</span> +</span><span id="L-2074"><a href="#L-2074"><span class="linenos">2074</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-2075"><a href="#L-2075"><span class="linenos">2075</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RENAME TO </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2076"><a href="#L-2076"><span class="linenos">2076</span></a> +</span><span id="L-2077"><a href="#L-2077"><span class="linenos">2077</span></a> <span class="k">def</span> <span class="nf">altertable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AlterTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2078"><a href="#L-2078"><span class="linenos">2078</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"actions"</span><span class="p">]</span> +</span><span id="L-2079"><a href="#L-2079"><span class="linenos">2079</span></a> +</span><span id="L-2080"><a href="#L-2080"><span class="linenos">2080</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">):</span> +</span><span id="L-2081"><a href="#L-2081"><span class="linenos">2081</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMN "</span><span class="p">)</span> +</span><span id="L-2082"><a href="#L-2082"><span class="linenos">2082</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">):</span> +</span><span id="L-2083"><a href="#L-2083"><span class="linenos">2083</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMNS "</span><span class="p">)</span> +</span><span id="L-2084"><a href="#L-2084"><span class="linenos">2084</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">):</span> +</span><span id="L-2085"><a href="#L-2085"><span class="linenos">2085</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-2086"><a href="#L-2086"><span class="linenos">2086</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2087"><a href="#L-2087"><span class="linenos">2087</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">)</span> </span><span id="L-2088"><a href="#L-2088"><span class="linenos">2088</span></a> -</span><span id="L-2089"><a href="#L-2089"><span class="linenos">2089</span></a> <span class="k">def</span> <span class="nf">intdiv_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2090"><a href="#L-2090"><span class="linenos">2090</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="L-2091"><a href="#L-2091"><span class="linenos">2091</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">(</span> -</span><span id="L-2092"><a href="#L-2092"><span class="linenos">2092</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">),</span> -</span><span id="L-2093"><a href="#L-2093"><span class="linenos">2093</span></a> <span class="n">to</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">),</span> -</span><span id="L-2094"><a href="#L-2094"><span class="linenos">2094</span></a> <span class="p">)</span> -</span><span id="L-2095"><a href="#L-2095"><span class="linenos">2095</span></a> <span class="p">)</span> +</span><span id="L-2089"><a href="#L-2089"><span class="linenos">2089</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2090"><a href="#L-2090"><span class="linenos">2090</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER TABLE</span><span class="si">{</span><span class="n">exists</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">actions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2091"><a href="#L-2091"><span class="linenos">2091</span></a> +</span><span id="L-2092"><a href="#L-2092"><span class="linenos">2092</span></a> <span class="k">def</span> <span class="nf">droppartition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DropPartition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2093"><a href="#L-2093"><span class="linenos">2093</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-2094"><a href="#L-2094"><span class="linenos">2094</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="L-2095"><a href="#L-2095"><span class="linenos">2095</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2096"><a href="#L-2096"><span class="linenos">2096</span></a> -</span><span id="L-2097"><a href="#L-2097"><span class="linenos">2097</span></a> <span class="k">def</span> <span class="nf">dpipe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2098"><a href="#L-2098"><span class="linenos">2098</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"||"</span><span class="p">)</span> -</span><span id="L-2099"><a href="#L-2099"><span class="linenos">2099</span></a> -</span><span id="L-2100"><a href="#L-2100"><span class="linenos">2100</span></a> <span class="k">def</span> <span class="nf">safedpipe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2101"><a href="#L-2101"><span class="linenos">2101</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> -</span><span id="L-2102"><a href="#L-2102"><span class="linenos">2102</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">,</span> <span class="o">*</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">()))</span> -</span><span id="L-2103"><a href="#L-2103"><span class="linenos">2103</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">dpipe_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-2104"><a href="#L-2104"><span class="linenos">2104</span></a> -</span><span id="L-2105"><a href="#L-2105"><span class="linenos">2105</span></a> <span class="k">def</span> <span class="nf">div_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2106"><a href="#L-2106"><span class="linenos">2106</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"/"</span><span class="p">)</span> +</span><span id="L-2097"><a href="#L-2097"><span class="linenos">2097</span></a> <span class="k">def</span> <span class="nf">addconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AddConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2098"><a href="#L-2098"><span class="linenos">2098</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2099"><a href="#L-2099"><span class="linenos">2099</span></a> <span class="n">expression_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="L-2100"><a href="#L-2100"><span class="linenos">2100</span></a> <span class="n">add_constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ADD CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">"ADD"</span> +</span><span id="L-2101"><a href="#L-2101"><span class="linenos">2101</span></a> +</span><span id="L-2102"><a href="#L-2102"><span class="linenos">2102</span></a> <span class="n">enforced</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"enforced"</span><span class="p">)</span> +</span><span id="L-2103"><a href="#L-2103"><span class="linenos">2103</span></a> <span class="k">if</span> <span class="n">enforced</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-2104"><a href="#L-2104"><span class="linenos">2104</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> CHECK (</span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="s1">' ENFORCED'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">enforced</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2105"><a href="#L-2105"><span class="linenos">2105</span></a> +</span><span id="L-2106"><a href="#L-2106"><span class="linenos">2106</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2107"><a href="#L-2107"><span class="linenos">2107</span></a> -</span><span id="L-2108"><a href="#L-2108"><span class="linenos">2108</span></a> <span class="k">def</span> <span class="nf">overlaps_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Overlaps</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2109"><a href="#L-2109"><span class="linenos">2109</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OVERLAPS"</span><span class="p">)</span> -</span><span id="L-2110"><a href="#L-2110"><span class="linenos">2110</span></a> -</span><span id="L-2111"><a href="#L-2111"><span class="linenos">2111</span></a> <span class="k">def</span> <span class="nf">distance_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distance</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2112"><a href="#L-2112"><span class="linenos">2112</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<->"</span><span class="p">)</span> -</span><span id="L-2113"><a href="#L-2113"><span class="linenos">2113</span></a> -</span><span id="L-2114"><a href="#L-2114"><span class="linenos">2114</span></a> <span class="k">def</span> <span class="nf">dot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2115"><a href="#L-2115"><span class="linenos">2115</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2116"><a href="#L-2116"><span class="linenos">2116</span></a> -</span><span id="L-2117"><a href="#L-2117"><span class="linenos">2117</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2118"><a href="#L-2118"><span class="linenos">2118</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> -</span><span id="L-2119"><a href="#L-2119"><span class="linenos">2119</span></a> -</span><span id="L-2120"><a href="#L-2120"><span class="linenos">2120</span></a> <span class="k">def</span> <span class="nf">escape_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Escape</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2121"><a href="#L-2121"><span class="linenos">2121</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ESCAPE"</span><span class="p">)</span> -</span><span id="L-2122"><a href="#L-2122"><span class="linenos">2122</span></a> -</span><span id="L-2123"><a href="#L-2123"><span class="linenos">2123</span></a> <span class="k">def</span> <span class="nf">glob_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Glob</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2124"><a href="#L-2124"><span class="linenos">2124</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"GLOB"</span><span class="p">)</span> -</span><span id="L-2125"><a href="#L-2125"><span class="linenos">2125</span></a> -</span><span id="L-2126"><a href="#L-2126"><span class="linenos">2126</span></a> <span class="k">def</span> <span class="nf">gt_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2127"><a href="#L-2127"><span class="linenos">2127</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">"</span><span class="p">)</span> -</span><span id="L-2128"><a href="#L-2128"><span class="linenos">2128</span></a> -</span><span id="L-2129"><a href="#L-2129"><span class="linenos">2129</span></a> <span class="k">def</span> <span class="nf">gte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2130"><a href="#L-2130"><span class="linenos">2130</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">="</span><span class="p">)</span> -</span><span id="L-2131"><a href="#L-2131"><span class="linenos">2131</span></a> -</span><span id="L-2132"><a href="#L-2132"><span class="linenos">2132</span></a> <span class="k">def</span> <span class="nf">ilike_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2133"><a href="#L-2133"><span class="linenos">2133</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE"</span><span class="p">)</span> -</span><span id="L-2134"><a href="#L-2134"><span class="linenos">2134</span></a> -</span><span id="L-2135"><a href="#L-2135"><span class="linenos">2135</span></a> <span class="k">def</span> <span class="nf">ilikeany_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2136"><a href="#L-2136"><span class="linenos">2136</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE ANY"</span><span class="p">)</span> +</span><span id="L-2108"><a href="#L-2108"><span class="linenos">2108</span></a> <span class="k">def</span> <span class="nf">distinct_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distinct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2109"><a href="#L-2109"><span class="linenos">2109</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-2110"><a href="#L-2110"><span class="linenos">2110</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2111"><a href="#L-2111"><span class="linenos">2111</span></a> +</span><span id="L-2112"><a href="#L-2112"><span class="linenos">2112</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">)</span> +</span><span id="L-2113"><a href="#L-2113"><span class="linenos">2113</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">on</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2114"><a href="#L-2114"><span class="linenos">2114</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DISTINCT</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2115"><a href="#L-2115"><span class="linenos">2115</span></a> +</span><span id="L-2116"><a href="#L-2116"><span class="linenos">2116</span></a> <span class="k">def</span> <span class="nf">ignorenulls_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IgnoreNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2117"><a href="#L-2117"><span class="linenos">2117</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> IGNORE NULLS"</span> +</span><span id="L-2118"><a href="#L-2118"><span class="linenos">2118</span></a> +</span><span id="L-2119"><a href="#L-2119"><span class="linenos">2119</span></a> <span class="k">def</span> <span class="nf">respectnulls_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RespectNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2120"><a href="#L-2120"><span class="linenos">2120</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> RESPECT NULLS"</span> +</span><span id="L-2121"><a href="#L-2121"><span class="linenos">2121</span></a> +</span><span id="L-2122"><a href="#L-2122"><span class="linenos">2122</span></a> <span class="k">def</span> <span class="nf">intdiv_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2123"><a href="#L-2123"><span class="linenos">2123</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="L-2124"><a href="#L-2124"><span class="linenos">2124</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">(</span> +</span><span id="L-2125"><a href="#L-2125"><span class="linenos">2125</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">),</span> +</span><span id="L-2126"><a href="#L-2126"><span class="linenos">2126</span></a> <span class="n">to</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">),</span> +</span><span id="L-2127"><a href="#L-2127"><span class="linenos">2127</span></a> <span class="p">)</span> +</span><span id="L-2128"><a href="#L-2128"><span class="linenos">2128</span></a> <span class="p">)</span> +</span><span id="L-2129"><a href="#L-2129"><span class="linenos">2129</span></a> +</span><span id="L-2130"><a href="#L-2130"><span class="linenos">2130</span></a> <span class="k">def</span> <span class="nf">dpipe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2131"><a href="#L-2131"><span class="linenos">2131</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"||"</span><span class="p">)</span> +</span><span id="L-2132"><a href="#L-2132"><span class="linenos">2132</span></a> +</span><span id="L-2133"><a href="#L-2133"><span class="linenos">2133</span></a> <span class="k">def</span> <span class="nf">safedpipe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2134"><a href="#L-2134"><span class="linenos">2134</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> +</span><span id="L-2135"><a href="#L-2135"><span class="linenos">2135</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">,</span> <span class="o">*</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">()))</span> +</span><span id="L-2136"><a href="#L-2136"><span class="linenos">2136</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">dpipe_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="L-2137"><a href="#L-2137"><span class="linenos">2137</span></a> -</span><span id="L-2138"><a href="#L-2138"><span class="linenos">2138</span></a> <span class="k">def</span> <span class="nf">is_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2139"><a href="#L-2139"><span class="linenos">2139</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">IS_BOOL_ALLOWED</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Boolean</span><span class="p">):</span> -</span><span id="L-2140"><a href="#L-2140"><span class="linenos">2140</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="L-2141"><a href="#L-2141"><span class="linenos">2141</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">not_</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-2142"><a href="#L-2142"><span class="linenos">2142</span></a> <span class="p">)</span> -</span><span id="L-2143"><a href="#L-2143"><span class="linenos">2143</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS"</span><span class="p">)</span> -</span><span id="L-2144"><a href="#L-2144"><span class="linenos">2144</span></a> -</span><span id="L-2145"><a href="#L-2145"><span class="linenos">2145</span></a> <span class="k">def</span> <span class="nf">like_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Like</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2146"><a href="#L-2146"><span class="linenos">2146</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE"</span><span class="p">)</span> -</span><span id="L-2147"><a href="#L-2147"><span class="linenos">2147</span></a> -</span><span id="L-2148"><a href="#L-2148"><span class="linenos">2148</span></a> <span class="k">def</span> <span class="nf">likeany_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2149"><a href="#L-2149"><span class="linenos">2149</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE ANY"</span><span class="p">)</span> -</span><span id="L-2150"><a href="#L-2150"><span class="linenos">2150</span></a> -</span><span id="L-2151"><a href="#L-2151"><span class="linenos">2151</span></a> <span class="k">def</span> <span class="nf">similarto_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SimilarTo</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2152"><a href="#L-2152"><span class="linenos">2152</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"SIMILAR TO"</span><span class="p">)</span> -</span><span id="L-2153"><a href="#L-2153"><span class="linenos">2153</span></a> -</span><span id="L-2154"><a href="#L-2154"><span class="linenos">2154</span></a> <span class="k">def</span> <span class="nf">lt_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2155"><a href="#L-2155"><span class="linenos">2155</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<"</span><span class="p">)</span> -</span><span id="L-2156"><a href="#L-2156"><span class="linenos">2156</span></a> -</span><span id="L-2157"><a href="#L-2157"><span class="linenos">2157</span></a> <span class="k">def</span> <span class="nf">lte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2158"><a href="#L-2158"><span class="linenos">2158</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<="</span><span class="p">)</span> -</span><span id="L-2159"><a href="#L-2159"><span class="linenos">2159</span></a> -</span><span id="L-2160"><a href="#L-2160"><span class="linenos">2160</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2161"><a href="#L-2161"><span class="linenos">2161</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"%"</span><span class="p">)</span> -</span><span id="L-2162"><a href="#L-2162"><span class="linenos">2162</span></a> -</span><span id="L-2163"><a href="#L-2163"><span class="linenos">2163</span></a> <span class="k">def</span> <span class="nf">mul_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mul</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2164"><a href="#L-2164"><span class="linenos">2164</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"*"</span><span class="p">)</span> -</span><span id="L-2165"><a href="#L-2165"><span class="linenos">2165</span></a> -</span><span id="L-2166"><a href="#L-2166"><span class="linenos">2166</span></a> <span class="k">def</span> <span class="nf">neq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2167"><a href="#L-2167"><span class="linenos">2167</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<>"</span><span class="p">)</span> -</span><span id="L-2168"><a href="#L-2168"><span class="linenos">2168</span></a> -</span><span id="L-2169"><a href="#L-2169"><span class="linenos">2169</span></a> <span class="k">def</span> <span class="nf">nullsafeeq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2170"><a href="#L-2170"><span class="linenos">2170</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS NOT DISTINCT FROM"</span><span class="p">)</span> -</span><span id="L-2171"><a href="#L-2171"><span class="linenos">2171</span></a> -</span><span id="L-2172"><a href="#L-2172"><span class="linenos">2172</span></a> <span class="k">def</span> <span class="nf">nullsafeneq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeNEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2173"><a href="#L-2173"><span class="linenos">2173</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS DISTINCT FROM"</span><span class="p">)</span> -</span><span id="L-2174"><a href="#L-2174"><span class="linenos">2174</span></a> -</span><span id="L-2175"><a href="#L-2175"><span class="linenos">2175</span></a> <span class="k">def</span> <span class="nf">or_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Or</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2176"><a href="#L-2176"><span class="linenos">2176</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OR"</span><span class="p">)</span> +</span><span id="L-2138"><a href="#L-2138"><span class="linenos">2138</span></a> <span class="k">def</span> <span class="nf">div_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2139"><a href="#L-2139"><span class="linenos">2139</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"/"</span><span class="p">)</span> +</span><span id="L-2140"><a href="#L-2140"><span class="linenos">2140</span></a> +</span><span id="L-2141"><a href="#L-2141"><span class="linenos">2141</span></a> <span class="k">def</span> <span class="nf">overlaps_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Overlaps</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2142"><a href="#L-2142"><span class="linenos">2142</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OVERLAPS"</span><span class="p">)</span> +</span><span id="L-2143"><a href="#L-2143"><span class="linenos">2143</span></a> +</span><span id="L-2144"><a href="#L-2144"><span class="linenos">2144</span></a> <span class="k">def</span> <span class="nf">distance_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distance</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2145"><a href="#L-2145"><span class="linenos">2145</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<->"</span><span class="p">)</span> +</span><span id="L-2146"><a href="#L-2146"><span class="linenos">2146</span></a> +</span><span id="L-2147"><a href="#L-2147"><span class="linenos">2147</span></a> <span class="k">def</span> <span class="nf">dot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2148"><a href="#L-2148"><span class="linenos">2148</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2149"><a href="#L-2149"><span class="linenos">2149</span></a> +</span><span id="L-2150"><a href="#L-2150"><span class="linenos">2150</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2151"><a href="#L-2151"><span class="linenos">2151</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> +</span><span id="L-2152"><a href="#L-2152"><span class="linenos">2152</span></a> +</span><span id="L-2153"><a href="#L-2153"><span class="linenos">2153</span></a> <span class="k">def</span> <span class="nf">escape_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Escape</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2154"><a href="#L-2154"><span class="linenos">2154</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ESCAPE"</span><span class="p">)</span> +</span><span id="L-2155"><a href="#L-2155"><span class="linenos">2155</span></a> +</span><span id="L-2156"><a href="#L-2156"><span class="linenos">2156</span></a> <span class="k">def</span> <span class="nf">glob_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Glob</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2157"><a href="#L-2157"><span class="linenos">2157</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"GLOB"</span><span class="p">)</span> +</span><span id="L-2158"><a href="#L-2158"><span class="linenos">2158</span></a> +</span><span id="L-2159"><a href="#L-2159"><span class="linenos">2159</span></a> <span class="k">def</span> <span class="nf">gt_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2160"><a href="#L-2160"><span class="linenos">2160</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">"</span><span class="p">)</span> +</span><span id="L-2161"><a href="#L-2161"><span class="linenos">2161</span></a> +</span><span id="L-2162"><a href="#L-2162"><span class="linenos">2162</span></a> <span class="k">def</span> <span class="nf">gte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2163"><a href="#L-2163"><span class="linenos">2163</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">="</span><span class="p">)</span> +</span><span id="L-2164"><a href="#L-2164"><span class="linenos">2164</span></a> +</span><span id="L-2165"><a href="#L-2165"><span class="linenos">2165</span></a> <span class="k">def</span> <span class="nf">ilike_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2166"><a href="#L-2166"><span class="linenos">2166</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE"</span><span class="p">)</span> +</span><span id="L-2167"><a href="#L-2167"><span class="linenos">2167</span></a> +</span><span id="L-2168"><a href="#L-2168"><span class="linenos">2168</span></a> <span class="k">def</span> <span class="nf">ilikeany_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2169"><a href="#L-2169"><span class="linenos">2169</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE ANY"</span><span class="p">)</span> +</span><span id="L-2170"><a href="#L-2170"><span class="linenos">2170</span></a> +</span><span id="L-2171"><a href="#L-2171"><span class="linenos">2171</span></a> <span class="k">def</span> <span class="nf">is_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2172"><a href="#L-2172"><span class="linenos">2172</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">IS_BOOL_ALLOWED</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Boolean</span><span class="p">):</span> +</span><span id="L-2173"><a href="#L-2173"><span class="linenos">2173</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="L-2174"><a href="#L-2174"><span class="linenos">2174</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">not_</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-2175"><a href="#L-2175"><span class="linenos">2175</span></a> <span class="p">)</span> +</span><span id="L-2176"><a href="#L-2176"><span class="linenos">2176</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS"</span><span class="p">)</span> </span><span id="L-2177"><a href="#L-2177"><span class="linenos">2177</span></a> -</span><span id="L-2178"><a href="#L-2178"><span class="linenos">2178</span></a> <span class="k">def</span> <span class="nf">slice_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Slice</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2179"><a href="#L-2179"><span class="linenos">2179</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">":"</span><span class="p">)</span> +</span><span id="L-2178"><a href="#L-2178"><span class="linenos">2178</span></a> <span class="k">def</span> <span class="nf">like_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Like</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2179"><a href="#L-2179"><span class="linenos">2179</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE"</span><span class="p">)</span> </span><span id="L-2180"><a href="#L-2180"><span class="linenos">2180</span></a> -</span><span id="L-2181"><a href="#L-2181"><span class="linenos">2181</span></a> <span class="k">def</span> <span class="nf">sub_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Sub</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2182"><a href="#L-2182"><span class="linenos">2182</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)</span> +</span><span id="L-2181"><a href="#L-2181"><span class="linenos">2181</span></a> <span class="k">def</span> <span class="nf">likeany_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2182"><a href="#L-2182"><span class="linenos">2182</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE ANY"</span><span class="p">)</span> </span><span id="L-2183"><a href="#L-2183"><span class="linenos">2183</span></a> -</span><span id="L-2184"><a href="#L-2184"><span class="linenos">2184</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2185"><a href="#L-2185"><span class="linenos">2185</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TRY_CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'to'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2184"><a href="#L-2184"><span class="linenos">2184</span></a> <span class="k">def</span> <span class="nf">similarto_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SimilarTo</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2185"><a href="#L-2185"><span class="linenos">2185</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"SIMILAR TO"</span><span class="p">)</span> </span><span id="L-2186"><a href="#L-2186"><span class="linenos">2186</span></a> -</span><span id="L-2187"><a href="#L-2187"><span class="linenos">2187</span></a> <span class="k">def</span> <span class="nf">use_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Use</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2188"><a href="#L-2188"><span class="linenos">2188</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="L-2189"><a href="#L-2189"><span class="linenos">2189</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2190"><a href="#L-2190"><span class="linenos">2190</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2191"><a href="#L-2191"><span class="linenos">2191</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2192"><a href="#L-2192"><span class="linenos">2192</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"USE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2193"><a href="#L-2193"><span class="linenos">2193</span></a> -</span><span id="L-2194"><a href="#L-2194"><span class="linenos">2194</span></a> <span class="k">def</span> <span class="nf">binary</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Binary</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2195"><a href="#L-2195"><span class="linenos">2195</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">op</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> -</span><span id="L-2196"><a href="#L-2196"><span class="linenos">2196</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2197"><a href="#L-2197"><span class="linenos">2197</span></a> -</span><span id="L-2198"><a href="#L-2198"><span class="linenos">2198</span></a> <span class="k">def</span> <span class="nf">function_fallback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2199"><a href="#L-2199"><span class="linenos">2199</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-2200"><a href="#L-2200"><span class="linenos">2200</span></a> <span class="k">for</span> <span class="n">arg_value</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> -</span><span id="L-2201"><a href="#L-2201"><span class="linenos">2201</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">arg_value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="L-2202"><a href="#L-2202"><span class="linenos">2202</span></a> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">arg_value</span><span class="p">:</span> -</span><span id="L-2203"><a href="#L-2203"><span class="linenos">2203</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="L-2204"><a href="#L-2204"><span class="linenos">2204</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2205"><a href="#L-2205"><span class="linenos">2205</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">arg_value</span><span class="p">)</span> -</span><span id="L-2206"><a href="#L-2206"><span class="linenos">2206</span></a> -</span><span id="L-2207"><a href="#L-2207"><span class="linenos">2207</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">sql_name</span><span class="p">(),</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> -</span><span id="L-2208"><a href="#L-2208"><span class="linenos">2208</span></a> -</span><span id="L-2209"><a href="#L-2209"><span class="linenos">2209</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span> -</span><span id="L-2210"><a href="#L-2210"><span class="linenos">2210</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2211"><a href="#L-2211"><span class="linenos">2211</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="L-2212"><a href="#L-2212"><span class="linenos">2212</span></a> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">|</span> <span class="nb">str</span><span class="p">],</span> -</span><span id="L-2213"><a href="#L-2213"><span class="linenos">2213</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"("</span><span class="p">,</span> -</span><span id="L-2214"><a href="#L-2214"><span class="linenos">2214</span></a> <span class="n">suffix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">")"</span><span class="p">,</span> -</span><span id="L-2215"><a href="#L-2215"><span class="linenos">2215</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2216"><a href="#L-2216"><span class="linenos">2216</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">normalize_func</span><span class="p">(</span><span class="n">name</span><span class="p">)</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2217"><a href="#L-2217"><span class="linenos">2217</span></a> -</span><span id="L-2218"><a href="#L-2218"><span class="linenos">2218</span></a> <span class="k">def</span> <span class="nf">format_args</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2219"><a href="#L-2219"><span class="linenos">2219</span></a> <span class="n">arg_sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span> <span class="k">if</span> <span class="n">arg</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="L-2220"><a href="#L-2220"><span class="linenos">2220</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span><span class="p">:</span> -</span><span id="L-2221"><a href="#L-2221"><span class="linenos">2221</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="sa">f</span><span class="s2">",</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">skip_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2222"><a href="#L-2222"><span class="linenos">2222</span></a> <span class="k">return</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> -</span><span id="L-2223"><a href="#L-2223"><span class="linenos">2223</span></a> -</span><span id="L-2224"><a href="#L-2224"><span class="linenos">2224</span></a> <span class="k">def</span> <span class="nf">text_width</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> -</span><span id="L-2225"><a href="#L-2225"><span class="linenos">2225</span></a> <span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> +</span><span id="L-2187"><a href="#L-2187"><span class="linenos">2187</span></a> <span class="k">def</span> <span class="nf">lt_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2188"><a href="#L-2188"><span class="linenos">2188</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<"</span><span class="p">)</span> +</span><span id="L-2189"><a href="#L-2189"><span class="linenos">2189</span></a> +</span><span id="L-2190"><a href="#L-2190"><span class="linenos">2190</span></a> <span class="k">def</span> <span class="nf">lte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2191"><a href="#L-2191"><span class="linenos">2191</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<="</span><span class="p">)</span> +</span><span id="L-2192"><a href="#L-2192"><span class="linenos">2192</span></a> +</span><span id="L-2193"><a href="#L-2193"><span class="linenos">2193</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2194"><a href="#L-2194"><span class="linenos">2194</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"%"</span><span class="p">)</span> +</span><span id="L-2195"><a href="#L-2195"><span class="linenos">2195</span></a> +</span><span id="L-2196"><a href="#L-2196"><span class="linenos">2196</span></a> <span class="k">def</span> <span class="nf">mul_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mul</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2197"><a href="#L-2197"><span class="linenos">2197</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"*"</span><span class="p">)</span> +</span><span id="L-2198"><a href="#L-2198"><span class="linenos">2198</span></a> +</span><span id="L-2199"><a href="#L-2199"><span class="linenos">2199</span></a> <span class="k">def</span> <span class="nf">neq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2200"><a href="#L-2200"><span class="linenos">2200</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<>"</span><span class="p">)</span> +</span><span id="L-2201"><a href="#L-2201"><span class="linenos">2201</span></a> +</span><span id="L-2202"><a href="#L-2202"><span class="linenos">2202</span></a> <span class="k">def</span> <span class="nf">nullsafeeq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2203"><a href="#L-2203"><span class="linenos">2203</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS NOT DISTINCT FROM"</span><span class="p">)</span> +</span><span id="L-2204"><a href="#L-2204"><span class="linenos">2204</span></a> +</span><span id="L-2205"><a href="#L-2205"><span class="linenos">2205</span></a> <span class="k">def</span> <span class="nf">nullsafeneq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeNEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2206"><a href="#L-2206"><span class="linenos">2206</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS DISTINCT FROM"</span><span class="p">)</span> +</span><span id="L-2207"><a href="#L-2207"><span class="linenos">2207</span></a> +</span><span id="L-2208"><a href="#L-2208"><span class="linenos">2208</span></a> <span class="k">def</span> <span class="nf">or_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Or</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2209"><a href="#L-2209"><span class="linenos">2209</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OR"</span><span class="p">)</span> +</span><span id="L-2210"><a href="#L-2210"><span class="linenos">2210</span></a> +</span><span id="L-2211"><a href="#L-2211"><span class="linenos">2211</span></a> <span class="k">def</span> <span class="nf">slice_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Slice</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2212"><a href="#L-2212"><span class="linenos">2212</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">":"</span><span class="p">)</span> +</span><span id="L-2213"><a href="#L-2213"><span class="linenos">2213</span></a> +</span><span id="L-2214"><a href="#L-2214"><span class="linenos">2214</span></a> <span class="k">def</span> <span class="nf">sub_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Sub</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2215"><a href="#L-2215"><span class="linenos">2215</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)</span> +</span><span id="L-2216"><a href="#L-2216"><span class="linenos">2216</span></a> +</span><span id="L-2217"><a href="#L-2217"><span class="linenos">2217</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2218"><a href="#L-2218"><span class="linenos">2218</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TRY_CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'to'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2219"><a href="#L-2219"><span class="linenos">2219</span></a> +</span><span id="L-2220"><a href="#L-2220"><span class="linenos">2220</span></a> <span class="k">def</span> <span class="nf">use_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Use</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2221"><a href="#L-2221"><span class="linenos">2221</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="L-2222"><a href="#L-2222"><span class="linenos">2222</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2223"><a href="#L-2223"><span class="linenos">2223</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-2224"><a href="#L-2224"><span class="linenos">2224</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2225"><a href="#L-2225"><span class="linenos">2225</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"USE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2226"><a href="#L-2226"><span class="linenos">2226</span></a> -</span><span id="L-2227"><a href="#L-2227"><span class="linenos">2227</span></a> <span class="k">def</span> <span class="nf">format_time</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="L-2228"><a href="#L-2228"><span class="linenos">2228</span></a> <span class="k">return</span> <span class="n">format_time</span><span class="p">(</span> -</span><span id="L-2229"><a href="#L-2229"><span class="linenos">2229</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span> -</span><span id="L-2230"><a href="#L-2230"><span class="linenos">2230</span></a> <span class="p">)</span> -</span><span id="L-2231"><a href="#L-2231"><span class="linenos">2231</span></a> -</span><span id="L-2232"><a href="#L-2232"><span class="linenos">2232</span></a> <span class="k">def</span> <span class="nf">expressions</span><span class="p">(</span> -</span><span id="L-2233"><a href="#L-2233"><span class="linenos">2233</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2234"><a href="#L-2234"><span class="linenos">2234</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2235"><a href="#L-2235"><span class="linenos">2235</span></a> <span class="n">key</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2236"><a href="#L-2236"><span class="linenos">2236</span></a> <span class="n">sqls</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2237"><a href="#L-2237"><span class="linenos">2237</span></a> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2238"><a href="#L-2238"><span class="linenos">2238</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2239"><a href="#L-2239"><span class="linenos">2239</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">,</span> -</span><span id="L-2240"><a href="#L-2240"><span class="linenos">2240</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="L-2241"><a href="#L-2241"><span class="linenos">2241</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2242"><a href="#L-2242"><span class="linenos">2242</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span> <span class="ow">or</span> <span class="s2">"expressions"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span> <span class="k">else</span> <span class="n">sqls</span> -</span><span id="L-2243"><a href="#L-2243"><span class="linenos">2243</span></a> -</span><span id="L-2244"><a href="#L-2244"><span class="linenos">2244</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="L-2245"><a href="#L-2245"><span class="linenos">2245</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="L-2246"><a href="#L-2246"><span class="linenos">2246</span></a> -</span><span id="L-2247"><a href="#L-2247"><span class="linenos">2247</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> -</span><span id="L-2248"><a href="#L-2248"><span class="linenos">2248</span></a> <span class="k">return</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> -</span><span id="L-2249"><a href="#L-2249"><span class="linenos">2249</span></a> -</span><span id="L-2250"><a href="#L-2250"><span class="linenos">2250</span></a> <span class="n">num_sqls</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-2251"><a href="#L-2251"><span class="linenos">2251</span></a> -</span><span id="L-2252"><a href="#L-2252"><span class="linenos">2252</span></a> <span class="c1"># These are calculated once in case we have the leading_comma / pretty option set, correspondingly</span> -</span><span id="L-2253"><a href="#L-2253"><span class="linenos">2253</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> -</span><span id="L-2254"><a href="#L-2254"><span class="linenos">2254</span></a> <span class="n">stripped_sep</span> <span class="o">=</span> <span class="n">sep</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="L-2255"><a href="#L-2255"><span class="linenos">2255</span></a> -</span><span id="L-2256"><a href="#L-2256"><span class="linenos">2256</span></a> <span class="n">result_sqls</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-2257"><a href="#L-2257"><span class="linenos">2257</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expressions</span><span class="p">):</span> -</span><span id="L-2258"><a href="#L-2258"><span class="linenos">2258</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-2259"><a href="#L-2259"><span class="linenos">2259</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2260"><a href="#L-2260"><span class="linenos">2260</span></a> -</span><span id="L-2261"><a href="#L-2261"><span class="linenos">2261</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="L-2262"><a href="#L-2262"><span class="linenos">2262</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span><span class="p">:</span> -</span><span id="L-2263"><a href="#L-2263"><span class="linenos">2263</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">pad</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-2264"><a href="#L-2264"><span class="linenos">2264</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2265"><a href="#L-2265"><span class="linenos">2265</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="L-2266"><a href="#L-2266"><span class="linenos">2266</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">stripped_sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2267"><a href="#L-2267"><span class="linenos">2267</span></a> <span class="p">)</span> -</span><span id="L-2268"><a href="#L-2268"><span class="linenos">2268</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2269"><a href="#L-2269"><span class="linenos">2269</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-2270"><a href="#L-2270"><span class="linenos">2270</span></a> -</span><span id="L-2271"><a href="#L-2271"><span class="linenos">2271</span></a> <span class="n">result_sql</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> -</span><span id="L-2272"><a href="#L-2272"><span class="linenos">2272</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">result_sql</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="k">if</span> <span class="n">indent</span> <span class="k">else</span> <span class="n">result_sql</span> -</span><span id="L-2273"><a href="#L-2273"><span class="linenos">2273</span></a> -</span><span id="L-2274"><a href="#L-2274"><span class="linenos">2274</span></a> <span class="k">def</span> <span class="nf">op_expressions</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2275"><a href="#L-2275"><span class="linenos">2275</span></a> <span class="n">flat</span> <span class="o">=</span> <span class="n">flat</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> -</span><span id="L-2276"><a href="#L-2276"><span class="linenos">2276</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="n">flat</span><span class="p">)</span> -</span><span id="L-2277"><a href="#L-2277"><span class="linenos">2277</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> -</span><span id="L-2278"><a href="#L-2278"><span class="linenos">2278</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2279"><a href="#L-2279"><span class="linenos">2279</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expressions_sql</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2280"><a href="#L-2280"><span class="linenos">2280</span></a> -</span><span id="L-2281"><a href="#L-2281"><span class="linenos">2281</span></a> <span class="k">def</span> <span class="nf">naked_property</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2282"><a href="#L-2282"><span class="linenos">2282</span></a> <span class="n">property_name</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">PROPERTY_TO_NAME</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span> -</span><span id="L-2283"><a href="#L-2283"><span class="linenos">2283</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">property_name</span><span class="p">:</span> -</span><span id="L-2284"><a href="#L-2284"><span class="linenos">2284</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-2285"><a href="#L-2285"><span class="linenos">2285</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">property_name</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2286"><a href="#L-2286"><span class="linenos">2286</span></a> -</span><span id="L-2287"><a href="#L-2287"><span class="linenos">2287</span></a> <span class="k">def</span> <span class="nf">set_operation</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2288"><a href="#L-2288"><span class="linenos">2288</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-2289"><a href="#L-2289"><span class="linenos">2289</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span> -</span><span id="L-2290"><a href="#L-2290"><span class="linenos">2290</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> -</span><span id="L-2291"><a href="#L-2291"><span class="linenos">2291</span></a> <span class="n">expression</span><span class="p">,</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">op</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2292"><a href="#L-2292"><span class="linenos">2292</span></a> <span class="p">)</span> +</span><span id="L-2227"><a href="#L-2227"><span class="linenos">2227</span></a> <span class="k">def</span> <span class="nf">binary</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Binary</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2228"><a href="#L-2228"><span class="linenos">2228</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">op</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> +</span><span id="L-2229"><a href="#L-2229"><span class="linenos">2229</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2230"><a href="#L-2230"><span class="linenos">2230</span></a> +</span><span id="L-2231"><a href="#L-2231"><span class="linenos">2231</span></a> <span class="k">def</span> <span class="nf">function_fallback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2232"><a href="#L-2232"><span class="linenos">2232</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-2233"><a href="#L-2233"><span class="linenos">2233</span></a> <span class="k">for</span> <span class="n">arg_value</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> +</span><span id="L-2234"><a href="#L-2234"><span class="linenos">2234</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">arg_value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="L-2235"><a href="#L-2235"><span class="linenos">2235</span></a> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">arg_value</span><span class="p">:</span> +</span><span id="L-2236"><a href="#L-2236"><span class="linenos">2236</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="L-2237"><a href="#L-2237"><span class="linenos">2237</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2238"><a href="#L-2238"><span class="linenos">2238</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">arg_value</span><span class="p">)</span> +</span><span id="L-2239"><a href="#L-2239"><span class="linenos">2239</span></a> +</span><span id="L-2240"><a href="#L-2240"><span class="linenos">2240</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">sql_name</span><span class="p">(),</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> +</span><span id="L-2241"><a href="#L-2241"><span class="linenos">2241</span></a> +</span><span id="L-2242"><a href="#L-2242"><span class="linenos">2242</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span> +</span><span id="L-2243"><a href="#L-2243"><span class="linenos">2243</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2244"><a href="#L-2244"><span class="linenos">2244</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="L-2245"><a href="#L-2245"><span class="linenos">2245</span></a> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">|</span> <span class="nb">str</span><span class="p">],</span> +</span><span id="L-2246"><a href="#L-2246"><span class="linenos">2246</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"("</span><span class="p">,</span> +</span><span id="L-2247"><a href="#L-2247"><span class="linenos">2247</span></a> <span class="n">suffix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">")"</span><span class="p">,</span> +</span><span id="L-2248"><a href="#L-2248"><span class="linenos">2248</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2249"><a href="#L-2249"><span class="linenos">2249</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">normalize_func</span><span class="p">(</span><span class="n">name</span><span class="p">)</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2250"><a href="#L-2250"><span class="linenos">2250</span></a> +</span><span id="L-2251"><a href="#L-2251"><span class="linenos">2251</span></a> <span class="k">def</span> <span class="nf">format_args</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2252"><a href="#L-2252"><span class="linenos">2252</span></a> <span class="n">arg_sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span> <span class="k">if</span> <span class="n">arg</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="L-2253"><a href="#L-2253"><span class="linenos">2253</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span><span class="p">:</span> +</span><span id="L-2254"><a href="#L-2254"><span class="linenos">2254</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="sa">f</span><span class="s2">",</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">skip_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-2255"><a href="#L-2255"><span class="linenos">2255</span></a> <span class="k">return</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> +</span><span id="L-2256"><a href="#L-2256"><span class="linenos">2256</span></a> +</span><span id="L-2257"><a href="#L-2257"><span class="linenos">2257</span></a> <span class="k">def</span> <span class="nf">text_width</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> +</span><span id="L-2258"><a href="#L-2258"><span class="linenos">2258</span></a> <span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> +</span><span id="L-2259"><a href="#L-2259"><span class="linenos">2259</span></a> +</span><span id="L-2260"><a href="#L-2260"><span class="linenos">2260</span></a> <span class="k">def</span> <span class="nf">format_time</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="L-2261"><a href="#L-2261"><span class="linenos">2261</span></a> <span class="k">return</span> <span class="n">format_time</span><span class="p">(</span> +</span><span id="L-2262"><a href="#L-2262"><span class="linenos">2262</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span> +</span><span id="L-2263"><a href="#L-2263"><span class="linenos">2263</span></a> <span class="p">)</span> +</span><span id="L-2264"><a href="#L-2264"><span class="linenos">2264</span></a> +</span><span id="L-2265"><a href="#L-2265"><span class="linenos">2265</span></a> <span class="k">def</span> <span class="nf">expressions</span><span class="p">(</span> +</span><span id="L-2266"><a href="#L-2266"><span class="linenos">2266</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2267"><a href="#L-2267"><span class="linenos">2267</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2268"><a href="#L-2268"><span class="linenos">2268</span></a> <span class="n">key</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2269"><a href="#L-2269"><span class="linenos">2269</span></a> <span class="n">sqls</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2270"><a href="#L-2270"><span class="linenos">2270</span></a> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2271"><a href="#L-2271"><span class="linenos">2271</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2272"><a href="#L-2272"><span class="linenos">2272</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">,</span> +</span><span id="L-2273"><a href="#L-2273"><span class="linenos">2273</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="L-2274"><a href="#L-2274"><span class="linenos">2274</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2275"><a href="#L-2275"><span class="linenos">2275</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span> <span class="ow">or</span> <span class="s2">"expressions"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span> <span class="k">else</span> <span class="n">sqls</span> +</span><span id="L-2276"><a href="#L-2276"><span class="linenos">2276</span></a> +</span><span id="L-2277"><a href="#L-2277"><span class="linenos">2277</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="L-2278"><a href="#L-2278"><span class="linenos">2278</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-2279"><a href="#L-2279"><span class="linenos">2279</span></a> +</span><span id="L-2280"><a href="#L-2280"><span class="linenos">2280</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> +</span><span id="L-2281"><a href="#L-2281"><span class="linenos">2281</span></a> <span class="k">return</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> +</span><span id="L-2282"><a href="#L-2282"><span class="linenos">2282</span></a> +</span><span id="L-2283"><a href="#L-2283"><span class="linenos">2283</span></a> <span class="n">num_sqls</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-2284"><a href="#L-2284"><span class="linenos">2284</span></a> +</span><span id="L-2285"><a href="#L-2285"><span class="linenos">2285</span></a> <span class="c1"># These are calculated once in case we have the leading_comma / pretty option set, correspondingly</span> +</span><span id="L-2286"><a href="#L-2286"><span class="linenos">2286</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> +</span><span id="L-2287"><a href="#L-2287"><span class="linenos">2287</span></a> <span class="n">stripped_sep</span> <span class="o">=</span> <span class="n">sep</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="L-2288"><a href="#L-2288"><span class="linenos">2288</span></a> +</span><span id="L-2289"><a href="#L-2289"><span class="linenos">2289</span></a> <span class="n">result_sqls</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-2290"><a href="#L-2290"><span class="linenos">2290</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expressions</span><span class="p">):</span> +</span><span id="L-2291"><a href="#L-2291"><span class="linenos">2291</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-2292"><a href="#L-2292"><span class="linenos">2292</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> </span><span id="L-2293"><a href="#L-2293"><span class="linenos">2293</span></a> -</span><span id="L-2294"><a href="#L-2294"><span class="linenos">2294</span></a> <span class="k">def</span> <span class="nf">tag_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Tag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2295"><a href="#L-2295"><span class="linenos">2295</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'prefix'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}{</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'postfix'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2296"><a href="#L-2296"><span class="linenos">2296</span></a> -</span><span id="L-2297"><a href="#L-2297"><span class="linenos">2297</span></a> <span class="k">def</span> <span class="nf">token_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2298"><a href="#L-2298"><span class="linenos">2298</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">TOKEN_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">token_type</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> -</span><span id="L-2299"><a href="#L-2299"><span class="linenos">2299</span></a> -</span><span id="L-2300"><a href="#L-2300"><span class="linenos">2300</span></a> <span class="k">def</span> <span class="nf">userdefinedfunction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UserDefinedFunction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2301"><a href="#L-2301"><span class="linenos">2301</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2302"><a href="#L-2302"><span class="linenos">2302</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-2303"><a href="#L-2303"><span class="linenos">2303</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-2304"><a href="#L-2304"><span class="linenos">2304</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"wrapped"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2305"><a href="#L-2305"><span class="linenos">2305</span></a> <span class="p">)</span> -</span><span id="L-2306"><a href="#L-2306"><span class="linenos">2306</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2307"><a href="#L-2307"><span class="linenos">2307</span></a> -</span><span id="L-2308"><a href="#L-2308"><span class="linenos">2308</span></a> <span class="k">def</span> <span class="nf">joinhint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JoinHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2309"><a href="#L-2309"><span class="linenos">2309</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2310"><a href="#L-2310"><span class="linenos">2310</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2311"><a href="#L-2311"><span class="linenos">2311</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-2312"><a href="#L-2312"><span class="linenos">2312</span></a> -</span><span id="L-2313"><a href="#L-2313"><span class="linenos">2313</span></a> <span class="k">def</span> <span class="nf">kwarg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Kwarg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2314"><a href="#L-2314"><span class="linenos">2314</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"=>"</span><span class="p">)</span> -</span><span id="L-2315"><a href="#L-2315"><span class="linenos">2315</span></a> -</span><span id="L-2316"><a href="#L-2316"><span class="linenos">2316</span></a> <span class="k">def</span> <span class="nf">when_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">When</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2317"><a href="#L-2317"><span class="linenos">2317</span></a> <span class="n">matched</span> <span class="o">=</span> <span class="s2">"MATCHED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"matched"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"NOT MATCHED"</span> -</span><span id="L-2318"><a href="#L-2318"><span class="linenos">2318</span></a> <span class="n">source</span> <span class="o">=</span> <span class="s2">" BY SOURCE"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">MATCHED_BY_SOURCE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"source"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2319"><a href="#L-2319"><span class="linenos">2319</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">)</span> -</span><span id="L-2320"><a href="#L-2320"><span class="linenos">2320</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">condition</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2321"><a href="#L-2321"><span class="linenos">2321</span></a> -</span><span id="L-2322"><a href="#L-2322"><span class="linenos">2322</span></a> <span class="n">then_expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"then"</span><span class="p">)</span> -</span><span id="L-2323"><a href="#L-2323"><span class="linenos">2323</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">):</span> -</span><span id="L-2324"><a href="#L-2324"><span class="linenos">2324</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2325"><a href="#L-2325"><span class="linenos">2325</span></a> <span class="k">if</span> <span class="s2">"expression"</span> <span class="ow">in</span> <span class="n">then_expression</span><span class="o">.</span><span class="n">args</span><span class="p">:</span> -</span><span id="L-2326"><a href="#L-2326"><span class="linenos">2326</span></a> <span class="n">then</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" VALUES </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2327"><a href="#L-2327"><span class="linenos">2327</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> -</span><span id="L-2328"><a href="#L-2328"><span class="linenos">2328</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">):</span> -</span><span id="L-2329"><a href="#L-2329"><span class="linenos">2329</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expressions'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2330"><a href="#L-2330"><span class="linenos">2330</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2331"><a href="#L-2331"><span class="linenos">2331</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2332"><a href="#L-2332"><span class="linenos">2332</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2333"><a href="#L-2333"><span class="linenos">2333</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">)</span> -</span><span id="L-2334"><a href="#L-2334"><span class="linenos">2334</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WHEN </span><span class="si">{</span><span class="n">matched</span><span class="si">}{</span><span class="n">source</span><span class="si">}{</span><span class="n">condition</span><span class="si">}</span><span class="s2"> THEN </span><span class="si">{</span><span class="n">then</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2335"><a href="#L-2335"><span class="linenos">2335</span></a> -</span><span id="L-2336"><a href="#L-2336"><span class="linenos">2336</span></a> <span class="k">def</span> <span class="nf">merge_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Merge</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2337"><a href="#L-2337"><span class="linenos">2337</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-2338"><a href="#L-2338"><span class="linenos">2338</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'using'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2339"><a href="#L-2339"><span class="linenos">2339</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'on'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2340"><a href="#L-2340"><span class="linenos">2340</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGE INTO </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">' '</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2341"><a href="#L-2341"><span class="linenos">2341</span></a> -</span><span id="L-2342"><a href="#L-2342"><span class="linenos">2342</span></a> <span class="k">def</span> <span class="nf">tochar_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2343"><a href="#L-2343"><span class="linenos">2343</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"format"</span><span class="p">):</span> -</span><span id="L-2344"><a href="#L-2344"><span class="linenos">2344</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Format argument unsupported for TO_CHAR/TO_VARCHAR function"</span><span class="p">)</span> +</span><span id="L-2294"><a href="#L-2294"><span class="linenos">2294</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="L-2295"><a href="#L-2295"><span class="linenos">2295</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span><span class="p">:</span> +</span><span id="L-2296"><a href="#L-2296"><span class="linenos">2296</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">pad</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-2297"><a href="#L-2297"><span class="linenos">2297</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2298"><a href="#L-2298"><span class="linenos">2298</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="L-2299"><a href="#L-2299"><span class="linenos">2299</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">stripped_sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2300"><a href="#L-2300"><span class="linenos">2300</span></a> <span class="p">)</span> +</span><span id="L-2301"><a href="#L-2301"><span class="linenos">2301</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2302"><a href="#L-2302"><span class="linenos">2302</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-2303"><a href="#L-2303"><span class="linenos">2303</span></a> +</span><span id="L-2304"><a href="#L-2304"><span class="linenos">2304</span></a> <span class="n">result_sql</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> +</span><span id="L-2305"><a href="#L-2305"><span class="linenos">2305</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">result_sql</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="k">if</span> <span class="n">indent</span> <span class="k">else</span> <span class="n">result_sql</span> +</span><span id="L-2306"><a href="#L-2306"><span class="linenos">2306</span></a> +</span><span id="L-2307"><a href="#L-2307"><span class="linenos">2307</span></a> <span class="k">def</span> <span class="nf">op_expressions</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2308"><a href="#L-2308"><span class="linenos">2308</span></a> <span class="n">flat</span> <span class="o">=</span> <span class="n">flat</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> +</span><span id="L-2309"><a href="#L-2309"><span class="linenos">2309</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="n">flat</span><span class="p">)</span> +</span><span id="L-2310"><a href="#L-2310"><span class="linenos">2310</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> +</span><span id="L-2311"><a href="#L-2311"><span class="linenos">2311</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2312"><a href="#L-2312"><span class="linenos">2312</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expressions_sql</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2313"><a href="#L-2313"><span class="linenos">2313</span></a> +</span><span id="L-2314"><a href="#L-2314"><span class="linenos">2314</span></a> <span class="k">def</span> <span class="nf">naked_property</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2315"><a href="#L-2315"><span class="linenos">2315</span></a> <span class="n">property_name</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">PROPERTY_TO_NAME</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span> +</span><span id="L-2316"><a href="#L-2316"><span class="linenos">2316</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">property_name</span><span class="p">:</span> +</span><span id="L-2317"><a href="#L-2317"><span class="linenos">2317</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-2318"><a href="#L-2318"><span class="linenos">2318</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">property_name</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2319"><a href="#L-2319"><span class="linenos">2319</span></a> +</span><span id="L-2320"><a href="#L-2320"><span class="linenos">2320</span></a> <span class="k">def</span> <span class="nf">set_operation</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2321"><a href="#L-2321"><span class="linenos">2321</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-2322"><a href="#L-2322"><span class="linenos">2322</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span> +</span><span id="L-2323"><a href="#L-2323"><span class="linenos">2323</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> +</span><span id="L-2324"><a href="#L-2324"><span class="linenos">2324</span></a> <span class="n">expression</span><span class="p">,</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">op</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2325"><a href="#L-2325"><span class="linenos">2325</span></a> <span class="p">)</span> +</span><span id="L-2326"><a href="#L-2326"><span class="linenos">2326</span></a> +</span><span id="L-2327"><a href="#L-2327"><span class="linenos">2327</span></a> <span class="k">def</span> <span class="nf">tag_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Tag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2328"><a href="#L-2328"><span class="linenos">2328</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'prefix'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}{</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'postfix'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2329"><a href="#L-2329"><span class="linenos">2329</span></a> +</span><span id="L-2330"><a href="#L-2330"><span class="linenos">2330</span></a> <span class="k">def</span> <span class="nf">token_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2331"><a href="#L-2331"><span class="linenos">2331</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">TOKEN_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">token_type</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> +</span><span id="L-2332"><a href="#L-2332"><span class="linenos">2332</span></a> +</span><span id="L-2333"><a href="#L-2333"><span class="linenos">2333</span></a> <span class="k">def</span> <span class="nf">userdefinedfunction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UserDefinedFunction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2334"><a href="#L-2334"><span class="linenos">2334</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-2335"><a href="#L-2335"><span class="linenos">2335</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-2336"><a href="#L-2336"><span class="linenos">2336</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-2337"><a href="#L-2337"><span class="linenos">2337</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"wrapped"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2338"><a href="#L-2338"><span class="linenos">2338</span></a> <span class="p">)</span> +</span><span id="L-2339"><a href="#L-2339"><span class="linenos">2339</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2340"><a href="#L-2340"><span class="linenos">2340</span></a> +</span><span id="L-2341"><a href="#L-2341"><span class="linenos">2341</span></a> <span class="k">def</span> <span class="nf">joinhint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JoinHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2342"><a href="#L-2342"><span class="linenos">2342</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2343"><a href="#L-2343"><span class="linenos">2343</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-2344"><a href="#L-2344"><span class="linenos">2344</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> </span><span id="L-2345"><a href="#L-2345"><span class="linenos">2345</span></a> -</span><span id="L-2346"><a href="#L-2346"><span class="linenos">2346</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">))</span> -</span><span id="L-2347"><a href="#L-2347"><span class="linenos">2347</span></a> -</span><span id="L-2348"><a href="#L-2348"><span class="linenos">2348</span></a> <span class="k">def</span> <span class="nf">dictproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2349"><a href="#L-2349"><span class="linenos">2349</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2350"><a href="#L-2350"><span class="linenos">2350</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="L-2351"><a href="#L-2351"><span class="linenos">2351</span></a> <span class="n">settings_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"settings"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="L-2352"><a href="#L-2352"><span class="linenos">2352</span></a> <span class="n">args</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">settings_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">settings_sql</span> <span class="k">else</span> <span class="s2">"()"</span> -</span><span id="L-2353"><a href="#L-2353"><span class="linenos">2353</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2346"><a href="#L-2346"><span class="linenos">2346</span></a> <span class="k">def</span> <span class="nf">kwarg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Kwarg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2347"><a href="#L-2347"><span class="linenos">2347</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"=>"</span><span class="p">)</span> +</span><span id="L-2348"><a href="#L-2348"><span class="linenos">2348</span></a> +</span><span id="L-2349"><a href="#L-2349"><span class="linenos">2349</span></a> <span class="k">def</span> <span class="nf">when_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">When</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2350"><a href="#L-2350"><span class="linenos">2350</span></a> <span class="n">matched</span> <span class="o">=</span> <span class="s2">"MATCHED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"matched"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"NOT MATCHED"</span> +</span><span id="L-2351"><a href="#L-2351"><span class="linenos">2351</span></a> <span class="n">source</span> <span class="o">=</span> <span class="s2">" BY SOURCE"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">MATCHED_BY_SOURCE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"source"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2352"><a href="#L-2352"><span class="linenos">2352</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">)</span> +</span><span id="L-2353"><a href="#L-2353"><span class="linenos">2353</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">condition</span> <span class="k">else</span> <span class="s2">""</span> </span><span id="L-2354"><a href="#L-2354"><span class="linenos">2354</span></a> -</span><span id="L-2355"><a href="#L-2355"><span class="linenos">2355</span></a> <span class="k">def</span> <span class="nf">dictrange_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DictRange</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2356"><a href="#L-2356"><span class="linenos">2356</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2357"><a href="#L-2357"><span class="linenos">2357</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"max"</span><span class="p">)</span> -</span><span id="L-2358"><a href="#L-2358"><span class="linenos">2358</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"min"</span><span class="p">)</span> -</span><span id="L-2359"><a href="#L-2359"><span class="linenos">2359</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(MIN </span><span class="si">{</span><span class="nb">min</span><span class="si">}</span><span class="s2"> MAX </span><span class="si">{</span><span class="nb">max</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-2360"><a href="#L-2360"><span class="linenos">2360</span></a> -</span><span id="L-2361"><a href="#L-2361"><span class="linenos">2361</span></a> <span class="k">def</span> <span class="nf">dictsubproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DictSubProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2362"><a href="#L-2362"><span class="linenos">2362</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2363"><a href="#L-2363"><span class="linenos">2363</span></a> -</span><span id="L-2364"><a href="#L-2364"><span class="linenos">2364</span></a> <span class="k">def</span> <span class="nf">oncluster_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnCluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2365"><a href="#L-2365"><span class="linenos">2365</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="L-2366"><a href="#L-2366"><span class="linenos">2366</span></a> -</span><span id="L-2367"><a href="#L-2367"><span class="linenos">2367</span></a> -</span><span id="L-2368"><a href="#L-2368"><span class="linenos">2368</span></a><span class="k">def</span> <span class="nf">cached_generator</span><span class="p">(</span> -</span><span id="L-2369"><a href="#L-2369"><span class="linenos">2369</span></a> <span class="n">cache</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2370"><a href="#L-2370"><span class="linenos">2370</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> -</span><span id="L-2371"><a href="#L-2371"><span class="linenos">2371</span></a><span class="w"> </span><span class="sd">"""Returns a cached generator."""</span> -</span><span id="L-2372"><a href="#L-2372"><span class="linenos">2372</span></a> <span class="n">cache</span> <span class="o">=</span> <span class="p">{}</span> <span class="k">if</span> <span class="n">cache</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">cache</span> -</span><span id="L-2373"><a href="#L-2373"><span class="linenos">2373</span></a> <span class="n">generator</span> <span class="o">=</span> <span class="n">Generator</span><span class="p">(</span><span class="n">normalize</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">identify</span><span class="o">=</span><span class="s2">"safe"</span><span class="p">)</span> -</span><span id="L-2374"><a href="#L-2374"><span class="linenos">2374</span></a> <span class="k">return</span> <span class="k">lambda</span> <span class="n">e</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">cache</span><span class="p">)</span> +</span><span id="L-2355"><a href="#L-2355"><span class="linenos">2355</span></a> <span class="n">then_expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"then"</span><span class="p">)</span> +</span><span id="L-2356"><a href="#L-2356"><span class="linenos">2356</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">):</span> +</span><span id="L-2357"><a href="#L-2357"><span class="linenos">2357</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2358"><a href="#L-2358"><span class="linenos">2358</span></a> <span class="k">if</span> <span class="s2">"expression"</span> <span class="ow">in</span> <span class="n">then_expression</span><span class="o">.</span><span class="n">args</span><span class="p">:</span> +</span><span id="L-2359"><a href="#L-2359"><span class="linenos">2359</span></a> <span class="n">then</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" VALUES </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2360"><a href="#L-2360"><span class="linenos">2360</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> +</span><span id="L-2361"><a href="#L-2361"><span class="linenos">2361</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">):</span> +</span><span id="L-2362"><a href="#L-2362"><span class="linenos">2362</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expressions'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2363"><a href="#L-2363"><span class="linenos">2363</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2364"><a href="#L-2364"><span class="linenos">2364</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2365"><a href="#L-2365"><span class="linenos">2365</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2366"><a href="#L-2366"><span class="linenos">2366</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">)</span> +</span><span id="L-2367"><a href="#L-2367"><span class="linenos">2367</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WHEN </span><span class="si">{</span><span class="n">matched</span><span class="si">}{</span><span class="n">source</span><span class="si">}{</span><span class="n">condition</span><span class="si">}</span><span class="s2"> THEN </span><span class="si">{</span><span class="n">then</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2368"><a href="#L-2368"><span class="linenos">2368</span></a> +</span><span id="L-2369"><a href="#L-2369"><span class="linenos">2369</span></a> <span class="k">def</span> <span class="nf">merge_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Merge</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2370"><a href="#L-2370"><span class="linenos">2370</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2371"><a href="#L-2371"><span class="linenos">2371</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'using'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2372"><a href="#L-2372"><span class="linenos">2372</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'on'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2373"><a href="#L-2373"><span class="linenos">2373</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGE INTO </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">' '</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2374"><a href="#L-2374"><span class="linenos">2374</span></a> +</span><span id="L-2375"><a href="#L-2375"><span class="linenos">2375</span></a> <span class="k">def</span> <span class="nf">tochar_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2376"><a href="#L-2376"><span class="linenos">2376</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"format"</span><span class="p">):</span> +</span><span id="L-2377"><a href="#L-2377"><span class="linenos">2377</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Format argument unsupported for TO_CHAR/TO_VARCHAR function"</span><span class="p">)</span> +</span><span id="L-2378"><a href="#L-2378"><span class="linenos">2378</span></a> +</span><span id="L-2379"><a href="#L-2379"><span class="linenos">2379</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">))</span> +</span><span id="L-2380"><a href="#L-2380"><span class="linenos">2380</span></a> +</span><span id="L-2381"><a href="#L-2381"><span class="linenos">2381</span></a> <span class="k">def</span> <span class="nf">dictproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2382"><a href="#L-2382"><span class="linenos">2382</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-2383"><a href="#L-2383"><span class="linenos">2383</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="L-2384"><a href="#L-2384"><span class="linenos">2384</span></a> <span class="n">settings_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"settings"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="L-2385"><a href="#L-2385"><span class="linenos">2385</span></a> <span class="n">args</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">settings_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">settings_sql</span> <span class="k">else</span> <span class="s2">"()"</span> +</span><span id="L-2386"><a href="#L-2386"><span class="linenos">2386</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2387"><a href="#L-2387"><span class="linenos">2387</span></a> +</span><span id="L-2388"><a href="#L-2388"><span class="linenos">2388</span></a> <span class="k">def</span> <span class="nf">dictrange_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DictRange</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2389"><a href="#L-2389"><span class="linenos">2389</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span 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-2390"><a href="#L-2390"><span class="linenos">2390</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"max"</span><span class="p">)</span> +</span><span id="L-2391"><a href="#L-2391"><span class="linenos">2391</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"min"</span><span class="p">)</span> +</span><span id="L-2392"><a href="#L-2392"><span class="linenos">2392</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(MIN </span><span class="si">{</span><span class="nb">min</span><span class="si">}</span><span class="s2"> MAX </span><span class="si">{</span><span class="nb">max</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2393"><a href="#L-2393"><span class="linenos">2393</span></a> +</span><span id="L-2394"><a href="#L-2394"><span class="linenos">2394</span></a> <span class="k">def</span> <span class="nf">dictsubproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DictSubProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2395"><a href="#L-2395"><span class="linenos">2395</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2396"><a href="#L-2396"><span class="linenos">2396</span></a> +</span><span id="L-2397"><a href="#L-2397"><span class="linenos">2397</span></a> <span class="k">def</span> <span class="nf">oncluster_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnCluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2398"><a href="#L-2398"><span class="linenos">2398</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-2399"><a href="#L-2399"><span class="linenos">2399</span></a> +</span><span id="L-2400"><a href="#L-2400"><span class="linenos">2400</span></a> +</span><span id="L-2401"><a href="#L-2401"><span class="linenos">2401</span></a><span class="k">def</span> <span class="nf">cached_generator</span><span class="p">(</span> +</span><span id="L-2402"><a href="#L-2402"><span class="linenos">2402</span></a> <span class="n">cache</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2403"><a href="#L-2403"><span class="linenos">2403</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> +</span><span id="L-2404"><a href="#L-2404"><span class="linenos">2404</span></a><span class="w"> </span><span class="sd">"""Returns a cached generator."""</span> +</span><span id="L-2405"><a href="#L-2405"><span class="linenos">2405</span></a> <span class="n">cache</span> <span class="o">=</span> <span class="p">{}</span> <span class="k">if</span> <span class="n">cache</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">cache</span> +</span><span id="L-2406"><a href="#L-2406"><span class="linenos">2406</span></a> <span class="n">generator</span> <span class="o">=</span> <span class="n">Generator</span><span class="p">(</span><span class="n">normalize</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">identify</span><span class="o">=</span><span class="s2">"safe"</span><span class="p">)</span> +</span><span id="L-2407"><a href="#L-2407"><span class="linenos">2407</span></a> <span class="k">return</span> <span class="k">lambda</span> <span class="n">e</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">cache</span><span class="p">)</span> </span></pre></div> @@ -3212,2313 +3251,2346 @@ </span><span id="Generator-57"><a href="#Generator-57"><span class="linenos"> 57</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TsOrDsAdd</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="Generator-58"><a href="#Generator-58"><span class="linenos"> 58</span></a> <span class="s2">"TS_OR_DS_ADD"</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">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">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">text</span><span class="p">(</span><span class="s2">"unit"</span><span class="p">))</span> </span><span id="Generator-59"><a href="#Generator-59"><span class="linenos"> 59</span></a> <span class="p">),</span> -</span><span id="Generator-60"><a href="#Generator-60"><span class="linenos"> 60</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</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">"MAP"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"keys"</span><span class="p">],</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"values"</span><span class="p">]),</span> -</span><span id="Generator-61"><a href="#Generator-61"><span class="linenos"> 61</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</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">"</span><span class="si">{</span><span class="s1">'DEFAULT '</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'default'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">CHARACTER SET=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Generator-62"><a href="#Generator-62"><span class="linenos"> 62</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExecuteAsProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="Generator-63"><a href="#Generator-63"><span class="linenos"> 63</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExternalProperty</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">"EXTERNAL"</span><span class="p">,</span> -</span><span id="Generator-64"><a href="#Generator-64"><span class="linenos"> 64</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LanguageProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="Generator-65"><a href="#Generator-65"><span class="linenos"> 65</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="Generator-66"><a href="#Generator-66"><span class="linenos"> 66</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogProperty</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">"</span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">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">'no'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">LOG"</span><span class="p">,</span> -</span><span id="Generator-67"><a href="#Generator-67"><span class="linenos"> 67</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MaterializedProperty</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">"MATERIALIZED"</span><span class="p">,</span> -</span><span id="Generator-68"><a href="#Generator-68"><span class="linenos"> 68</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NoPrimaryIndexProperty</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">"NO PRIMARY INDEX"</span><span class="p">,</span> -</span><span id="Generator-69"><a href="#Generator-69"><span class="linenos"> 69</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</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">"ON COMMIT </span><span class="si">{</span><span class="s1">'DELETE'</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'delete'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'PRESERVE'</span><span class="si">}</span><span class="s2"> ROWS"</span><span class="p">,</span> -</span><span id="Generator-70"><a href="#Generator-70"><span class="linenos"> 70</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="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> -</span><span id="Generator-71"><a href="#Generator-71"><span class="linenos"> 71</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</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">"</span><span class="si">{</span><span class="s1">'MULTI'</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'multi'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">SET"</span><span class="p">,</span> -</span><span id="Generator-72"><a href="#Generator-72"><span class="linenos"> 72</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SettingsProperty</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">"SETTINGS</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">e</span><span class="p">))</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Generator-73"><a href="#Generator-73"><span class="linenos"> 73</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SqlSecurityProperty</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">"SQL SECURITY </span><span class="si">{</span><span class="s1">'DEFINER'</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'definer'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'INVOKER'</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Generator-74"><a href="#Generator-74"><span class="linenos"> 74</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</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">"TEMPORARY"</span><span class="p">,</span> -</span><span id="Generator-75"><a href="#Generator-75"><span class="linenos"> 75</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToTableProperty</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">"TO </span><span 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="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Generator-76"><a href="#Generator-76"><span class="linenos"> 76</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TransientProperty</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">"TRANSIENT"</span><span class="p">,</span> -</span><span id="Generator-77"><a href="#Generator-77"><span class="linenos"> 77</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</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">e</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> -</span><span id="Generator-78"><a href="#Generator-78"><span class="linenos"> 78</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</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">"VOLATILE"</span><span class="p">,</span> -</span><span id="Generator-79"><a href="#Generator-79"><span class="linenos"> 79</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithJournalTableProperty</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">"WITH JOURNAL TABLE=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Generator-80"><a href="#Generator-80"><span class="linenos"> 80</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CaseSpecificColumnConstraint</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">"</span><span class="si">{</span><span class="s1">'NOT '</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'not_'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">CASESPECIFIC"</span><span class="p">,</span> -</span><span id="Generator-81"><a href="#Generator-81"><span class="linenos"> 81</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetColumnConstraint</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">"CHARACTER SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Generator-82"><a href="#Generator-82"><span class="linenos"> 82</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFormatColumnConstraint</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">"FORMAT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Generator-83"><a href="#Generator-83"><span class="linenos"> 83</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnUpdateColumnConstraint</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">"ON UPDATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Generator-84"><a href="#Generator-84"><span class="linenos"> 84</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UppercaseColumnConstraint</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">"UPPERCASE"</span><span class="p">,</span> -</span><span id="Generator-85"><a href="#Generator-85"><span class="linenos"> 85</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TitleColumnConstraint</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">"TITLE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Generator-86"><a href="#Generator-86"><span class="linenos"> 86</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PathColumnConstraint</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">"PATH </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Generator-87"><a href="#Generator-87"><span class="linenos"> 87</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CheckColumnConstraint</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">"CHECK (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Generator-88"><a href="#Generator-88"><span class="linenos"> 88</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CommentColumnConstraint</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">"COMMENT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Generator-89"><a href="#Generator-89"><span class="linenos"> 89</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateColumnConstraint</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">"COLLATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Generator-90"><a href="#Generator-90"><span class="linenos"> 90</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">EncodeColumnConstraint</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">"ENCODE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Generator-91"><a href="#Generator-91"><span class="linenos"> 91</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DefaultColumnConstraint</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">"DEFAULT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Generator-92"><a href="#Generator-92"><span class="linenos"> 92</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">InlineLengthColumnConstraint</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">"INLINE LENGTH </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Generator-93"><a href="#Generator-93"><span class="linenos"> 93</span></a> <span class="p">}</span> -</span><span id="Generator-94"><a href="#Generator-94"><span class="linenos"> 94</span></a> -</span><span id="Generator-95"><a href="#Generator-95"><span class="linenos"> 95</span></a> <span class="c1"># Whether or not null ordering is supported in order by</span> -</span><span id="Generator-96"><a href="#Generator-96"><span class="linenos"> 96</span></a> <span class="n">NULL_ORDERING_SUPPORTED</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Generator-97"><a href="#Generator-97"><span class="linenos"> 97</span></a> -</span><span id="Generator-98"><a href="#Generator-98"><span class="linenos"> 98</span></a> <span class="c1"># Whether or not locking reads (i.e. SELECT ... FOR UPDATE/SHARE) are supported</span> -</span><span id="Generator-99"><a href="#Generator-99"><span class="linenos"> 99</span></a> <span class="n">LOCKING_READS_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Generator-100"><a href="#Generator-100"><span class="linenos"> 100</span></a> -</span><span id="Generator-101"><a href="#Generator-101"><span class="linenos"> 101</span></a> <span class="c1"># Always do union distinct or union all</span> -</span><span id="Generator-102"><a href="#Generator-102"><span class="linenos"> 102</span></a> <span class="n">EXPLICIT_UNION</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Generator-103"><a href="#Generator-103"><span class="linenos"> 103</span></a> -</span><span id="Generator-104"><a href="#Generator-104"><span class="linenos"> 104</span></a> <span class="c1"># Wrap derived values in parens, usually standard but spark doesn't support it</span> -</span><span id="Generator-105"><a href="#Generator-105"><span class="linenos"> 105</span></a> <span class="n">WRAP_DERIVED_VALUES</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Generator-106"><a href="#Generator-106"><span class="linenos"> 106</span></a> -</span><span id="Generator-107"><a href="#Generator-107"><span class="linenos"> 107</span></a> <span class="c1"># Whether or not create function uses an AS before the RETURN</span> -</span><span id="Generator-108"><a href="#Generator-108"><span class="linenos"> 108</span></a> <span class="n">CREATE_FUNCTION_RETURN_AS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Generator-109"><a href="#Generator-109"><span class="linenos"> 109</span></a> -</span><span id="Generator-110"><a href="#Generator-110"><span class="linenos"> 110</span></a> <span class="c1"># Whether or not MERGE ... WHEN MATCHED BY SOURCE is allowed</span> -</span><span id="Generator-111"><a href="#Generator-111"><span class="linenos"> 111</span></a> <span class="n">MATCHED_BY_SOURCE</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Generator-112"><a href="#Generator-112"><span class="linenos"> 112</span></a> -</span><span id="Generator-113"><a href="#Generator-113"><span class="linenos"> 113</span></a> <span class="c1"># Whether or not the INTERVAL expression works only with values like '1 day'</span> -</span><span id="Generator-114"><a href="#Generator-114"><span class="linenos"> 114</span></a> <span class="n">SINGLE_STRING_INTERVAL</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Generator-115"><a href="#Generator-115"><span class="linenos"> 115</span></a> -</span><span id="Generator-116"><a href="#Generator-116"><span class="linenos"> 116</span></a> <span class="c1"># Whether or not the plural form of date parts like day (i.e. "days") is supported in INTERVALs</span> -</span><span id="Generator-117"><a href="#Generator-117"><span class="linenos"> 117</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Generator-118"><a href="#Generator-118"><span class="linenos"> 118</span></a> -</span><span id="Generator-119"><a href="#Generator-119"><span class="linenos"> 119</span></a> <span class="c1"># Whether or not the TABLESAMPLE clause supports a method name, like BERNOULLI</span> -</span><span id="Generator-120"><a href="#Generator-120"><span class="linenos"> 120</span></a> <span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Generator-121"><a href="#Generator-121"><span class="linenos"> 121</span></a> -</span><span id="Generator-122"><a href="#Generator-122"><span class="linenos"> 122</span></a> <span class="c1"># Whether or not to treat the number in TABLESAMPLE (50) as a percentage</span> -</span><span id="Generator-123"><a href="#Generator-123"><span class="linenos"> 123</span></a> <span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Generator-124"><a href="#Generator-124"><span class="linenos"> 124</span></a> -</span><span id="Generator-125"><a href="#Generator-125"><span class="linenos"> 125</span></a> <span class="c1"># Whether or not limit and fetch are supported (possible values: "ALL", "LIMIT", "FETCH")</span> -</span><span id="Generator-126"><a href="#Generator-126"><span class="linenos"> 126</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"ALL"</span> -</span><span id="Generator-127"><a href="#Generator-127"><span class="linenos"> 127</span></a> -</span><span id="Generator-128"><a href="#Generator-128"><span class="linenos"> 128</span></a> <span class="c1"># Whether or not a table is allowed to be renamed with a db</span> -</span><span id="Generator-129"><a href="#Generator-129"><span class="linenos"> 129</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Generator-130"><a href="#Generator-130"><span class="linenos"> 130</span></a> -</span><span id="Generator-131"><a href="#Generator-131"><span class="linenos"> 131</span></a> <span class="c1"># The separator for grouping sets and rollups</span> -</span><span id="Generator-132"><a href="#Generator-132"><span class="linenos"> 132</span></a> <span class="n">GROUPINGS_SEP</span> <span class="o">=</span> <span class="s2">","</span> -</span><span id="Generator-133"><a href="#Generator-133"><span class="linenos"> 133</span></a> -</span><span id="Generator-134"><a href="#Generator-134"><span class="linenos"> 134</span></a> <span class="c1"># The string used for creating an index on a table</span> -</span><span id="Generator-135"><a href="#Generator-135"><span class="linenos"> 135</span></a> <span class="n">INDEX_ON</span> <span class="o">=</span> <span class="s2">"ON"</span> -</span><span id="Generator-136"><a href="#Generator-136"><span class="linenos"> 136</span></a> -</span><span id="Generator-137"><a href="#Generator-137"><span class="linenos"> 137</span></a> <span class="c1"># Whether or not join hints should be generated</span> -</span><span id="Generator-138"><a href="#Generator-138"><span class="linenos"> 138</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Generator-139"><a href="#Generator-139"><span class="linenos"> 139</span></a> -</span><span id="Generator-140"><a href="#Generator-140"><span class="linenos"> 140</span></a> <span class="c1"># Whether or not table hints should be generated</span> -</span><span id="Generator-141"><a href="#Generator-141"><span class="linenos"> 141</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Generator-142"><a href="#Generator-142"><span class="linenos"> 142</span></a> -</span><span id="Generator-143"><a href="#Generator-143"><span class="linenos"> 143</span></a> <span class="c1"># Whether or not comparing against booleans (e.g. x IS TRUE) is supported</span> -</span><span id="Generator-144"><a href="#Generator-144"><span class="linenos"> 144</span></a> <span class="n">IS_BOOL_ALLOWED</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Generator-145"><a href="#Generator-145"><span class="linenos"> 145</span></a> -</span><span id="Generator-146"><a href="#Generator-146"><span class="linenos"> 146</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Generator-147"><a href="#Generator-147"><span class="linenos"> 147</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"CHAR"</span><span class="p">,</span> -</span><span id="Generator-148"><a href="#Generator-148"><span class="linenos"> 148</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"VARCHAR"</span><span class="p">,</span> -</span><span id="Generator-149"><a href="#Generator-149"><span class="linenos"> 149</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">MEDIUMTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="Generator-150"><a href="#Generator-150"><span class="linenos"> 150</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">LONGTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> -</span><span id="Generator-151"><a href="#Generator-151"><span class="linenos"> 151</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">MEDIUMBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> -</span><span id="Generator-152"><a href="#Generator-152"><span class="linenos"> 152</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">LONGBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> -</span><span id="Generator-153"><a href="#Generator-153"><span class="linenos"> 153</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INET</span><span class="p">:</span> <span class="s2">"INET"</span><span class="p">,</span> -</span><span id="Generator-154"><a href="#Generator-154"><span class="linenos"> 154</span></a> <span class="p">}</span> -</span><span id="Generator-155"><a href="#Generator-155"><span class="linenos"> 155</span></a> -</span><span id="Generator-156"><a href="#Generator-156"><span class="linenos"> 156</span></a> <span class="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Generator-157"><a href="#Generator-157"><span class="linenos"> 157</span></a> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCEPT"</span><span class="p">,</span> -</span><span id="Generator-158"><a href="#Generator-158"><span class="linenos"> 158</span></a> <span class="s2">"replace"</span><span class="p">:</span> <span class="s2">"REPLACE"</span><span class="p">,</span> -</span><span id="Generator-159"><a href="#Generator-159"><span class="linenos"> 159</span></a> <span class="p">}</span> -</span><span id="Generator-160"><a href="#Generator-160"><span class="linenos"> 160</span></a> -</span><span id="Generator-161"><a href="#Generator-161"><span class="linenos"> 161</span></a> <span class="n">TIME_PART_SINGULARS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Generator-162"><a href="#Generator-162"><span class="linenos"> 162</span></a> <span class="s2">"microseconds"</span><span class="p">:</span> <span class="s2">"microsecond"</span><span class="p">,</span> -</span><span id="Generator-163"><a href="#Generator-163"><span class="linenos"> 163</span></a> <span class="s2">"seconds"</span><span class="p">:</span> <span class="s2">"second"</span><span class="p">,</span> -</span><span id="Generator-164"><a href="#Generator-164"><span class="linenos"> 164</span></a> <span class="s2">"minutes"</span><span class="p">:</span> <span class="s2">"minute"</span><span class="p">,</span> -</span><span id="Generator-165"><a href="#Generator-165"><span class="linenos"> 165</span></a> <span class="s2">"hours"</span><span class="p">:</span> <span class="s2">"hour"</span><span class="p">,</span> -</span><span id="Generator-166"><a href="#Generator-166"><span class="linenos"> 166</span></a> <span class="s2">"days"</span><span class="p">:</span> <span class="s2">"day"</span><span class="p">,</span> -</span><span id="Generator-167"><a href="#Generator-167"><span class="linenos"> 167</span></a> <span class="s2">"weeks"</span><span class="p">:</span> <span class="s2">"week"</span><span class="p">,</span> -</span><span id="Generator-168"><a href="#Generator-168"><span class="linenos"> 168</span></a> <span class="s2">"months"</span><span class="p">:</span> <span class="s2">"month"</span><span class="p">,</span> -</span><span id="Generator-169"><a href="#Generator-169"><span class="linenos"> 169</span></a> <span class="s2">"quarters"</span><span class="p">:</span> <span class="s2">"quarter"</span><span class="p">,</span> -</span><span id="Generator-170"><a href="#Generator-170"><span class="linenos"> 170</span></a> <span class="s2">"years"</span><span class="p">:</span> <span class="s2">"year"</span><span class="p">,</span> -</span><span id="Generator-171"><a href="#Generator-171"><span class="linenos"> 171</span></a> <span class="p">}</span> -</span><span id="Generator-172"><a href="#Generator-172"><span class="linenos"> 172</span></a> -</span><span id="Generator-173"><a href="#Generator-173"><span class="linenos"> 173</span></a> <span class="n">TOKEN_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">TokenType</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Generator-174"><a href="#Generator-174"><span class="linenos"> 174</span></a> -</span><span id="Generator-175"><a href="#Generator-175"><span class="linenos"> 175</span></a> <span class="n">STRUCT_DELIMITER</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"<"</span><span class="p">,</span> <span class="s2">">"</span><span class="p">)</span> +</span><span id="Generator-60"><a href="#Generator-60"><span class="linenos"> 60</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CaseSpecificColumnConstraint</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">"</span><span class="si">{</span><span class="s1">'NOT '</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'not_'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">CASESPECIFIC"</span><span class="p">,</span> +</span><span id="Generator-61"><a href="#Generator-61"><span class="linenos"> 61</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetColumnConstraint</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">"CHARACTER SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Generator-62"><a href="#Generator-62"><span class="linenos"> 62</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</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">"</span><span class="si">{</span><span class="s1">'DEFAULT '</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'default'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">CHARACTER SET=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Generator-63"><a href="#Generator-63"><span class="linenos"> 63</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CheckColumnConstraint</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">"CHECK (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Generator-64"><a href="#Generator-64"><span class="linenos"> 64</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateColumnConstraint</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">"COLLATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Generator-65"><a href="#Generator-65"><span class="linenos"> 65</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CopyGrantsProperty</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">"COPY GRANTS"</span><span class="p">,</span> +</span><span id="Generator-66"><a href="#Generator-66"><span class="linenos"> 66</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CommentColumnConstraint</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">"COMMENT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Generator-67"><a href="#Generator-67"><span class="linenos"> 67</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFormatColumnConstraint</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">"FORMAT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Generator-68"><a href="#Generator-68"><span class="linenos"> 68</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DefaultColumnConstraint</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">"DEFAULT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Generator-69"><a href="#Generator-69"><span class="linenos"> 69</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">EncodeColumnConstraint</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">"ENCODE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Generator-70"><a href="#Generator-70"><span class="linenos"> 70</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExecuteAsProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="Generator-71"><a href="#Generator-71"><span class="linenos"> 71</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExternalProperty</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">"EXTERNAL"</span><span class="p">,</span> +</span><span id="Generator-72"><a href="#Generator-72"><span class="linenos"> 72</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">InlineLengthColumnConstraint</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">"INLINE LENGTH </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Generator-73"><a href="#Generator-73"><span class="linenos"> 73</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LanguageProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="Generator-74"><a href="#Generator-74"><span class="linenos"> 74</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</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">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="Generator-75"><a href="#Generator-75"><span class="linenos"> 75</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogProperty</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">"</span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">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">'no'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">LOG"</span><span class="p">,</span> +</span><span id="Generator-76"><a href="#Generator-76"><span class="linenos"> 76</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MaterializedProperty</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">"MATERIALIZED"</span><span class="p">,</span> +</span><span id="Generator-77"><a href="#Generator-77"><span class="linenos"> 77</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NoPrimaryIndexProperty</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">"NO PRIMARY INDEX"</span><span class="p">,</span> +</span><span id="Generator-78"><a href="#Generator-78"><span class="linenos"> 78</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</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">"ON COMMIT </span><span class="si">{</span><span class="s1">'DELETE'</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'delete'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'PRESERVE'</span><span class="si">}</span><span class="s2"> ROWS"</span><span class="p">,</span> +</span><span id="Generator-79"><a href="#Generator-79"><span class="linenos"> 79</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnUpdateColumnConstraint</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">"ON UPDATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Generator-80"><a href="#Generator-80"><span class="linenos"> 80</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PathColumnConstraint</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">"PATH </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Generator-81"><a href="#Generator-81"><span class="linenos"> 81</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="bp">self</span><span class="o">.</span><span class="n">naked_property</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> +</span><span id="Generator-82"><a href="#Generator-82"><span class="linenos"> 82</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</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">"</span><span class="si">{</span><span class="s1">'MULTI'</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'multi'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">SET"</span><span class="p">,</span> +</span><span id="Generator-83"><a href="#Generator-83"><span class="linenos"> 83</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SettingsProperty</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">"SETTINGS</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">e</span><span class="p">))</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Generator-84"><a href="#Generator-84"><span class="linenos"> 84</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SqlSecurityProperty</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">"SQL SECURITY </span><span class="si">{</span><span class="s1">'DEFINER'</span><span class="w"> </span><span class="k">if</span><span class="w"> </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">'definer'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'INVOKER'</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Generator-85"><a href="#Generator-85"><span class="linenos"> 85</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</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">e</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> +</span><span id="Generator-86"><a href="#Generator-86"><span class="linenos"> 86</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</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">"TEMPORARY"</span><span class="p">,</span> +</span><span id="Generator-87"><a href="#Generator-87"><span class="linenos"> 87</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToTableProperty</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">"TO </span><span 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="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Generator-88"><a href="#Generator-88"><span class="linenos"> 88</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TransientProperty</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">"TRANSIENT"</span><span class="p">,</span> +</span><span id="Generator-89"><a href="#Generator-89"><span class="linenos"> 89</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TitleColumnConstraint</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">"TITLE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Generator-90"><a href="#Generator-90"><span class="linenos"> 90</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UppercaseColumnConstraint</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">"UPPERCASE"</span><span class="p">,</span> +</span><span id="Generator-91"><a href="#Generator-91"><span class="linenos"> 91</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VarMap</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">"MAP"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"keys"</span><span class="p">],</span> <span class="n">e</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"values"</span><span class="p">]),</span> +</span><span id="Generator-92"><a href="#Generator-92"><span class="linenos"> 92</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</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">"VOLATILE"</span><span class="p">,</span> +</span><span id="Generator-93"><a href="#Generator-93"><span class="linenos"> 93</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithJournalTableProperty</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">"WITH JOURNAL TABLE=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Generator-94"><a href="#Generator-94"><span class="linenos"> 94</span></a> <span class="p">}</span> +</span><span id="Generator-95"><a href="#Generator-95"><span class="linenos"> 95</span></a> +</span><span id="Generator-96"><a href="#Generator-96"><span class="linenos"> 96</span></a> <span class="c1"># Whether or not null ordering is supported in order by</span> +</span><span id="Generator-97"><a href="#Generator-97"><span class="linenos"> 97</span></a> <span class="n">NULL_ORDERING_SUPPORTED</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Generator-98"><a href="#Generator-98"><span class="linenos"> 98</span></a> +</span><span id="Generator-99"><a href="#Generator-99"><span class="linenos"> 99</span></a> <span class="c1"># Whether or not locking reads (i.e. SELECT ... FOR UPDATE/SHARE) are supported</span> +</span><span id="Generator-100"><a href="#Generator-100"><span class="linenos"> 100</span></a> <span class="n">LOCKING_READS_SUPPORTED</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Generator-101"><a href="#Generator-101"><span class="linenos"> 101</span></a> +</span><span id="Generator-102"><a href="#Generator-102"><span class="linenos"> 102</span></a> <span class="c1"># Always do union distinct or union all</span> +</span><span id="Generator-103"><a href="#Generator-103"><span class="linenos"> 103</span></a> <span class="n">EXPLICIT_UNION</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Generator-104"><a href="#Generator-104"><span class="linenos"> 104</span></a> +</span><span id="Generator-105"><a href="#Generator-105"><span class="linenos"> 105</span></a> <span class="c1"># Wrap derived values in parens, usually standard but spark doesn't support it</span> +</span><span id="Generator-106"><a href="#Generator-106"><span class="linenos"> 106</span></a> <span class="n">WRAP_DERIVED_VALUES</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Generator-107"><a href="#Generator-107"><span class="linenos"> 107</span></a> +</span><span id="Generator-108"><a href="#Generator-108"><span class="linenos"> 108</span></a> <span class="c1"># Whether or not create function uses an AS before the RETURN</span> +</span><span id="Generator-109"><a href="#Generator-109"><span class="linenos"> 109</span></a> <span class="n">CREATE_FUNCTION_RETURN_AS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Generator-110"><a href="#Generator-110"><span class="linenos"> 110</span></a> +</span><span id="Generator-111"><a href="#Generator-111"><span class="linenos"> 111</span></a> <span class="c1"># Whether or not MERGE ... WHEN MATCHED BY SOURCE is allowed</span> +</span><span id="Generator-112"><a href="#Generator-112"><span class="linenos"> 112</span></a> <span class="n">MATCHED_BY_SOURCE</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Generator-113"><a href="#Generator-113"><span class="linenos"> 113</span></a> +</span><span id="Generator-114"><a href="#Generator-114"><span class="linenos"> 114</span></a> <span class="c1"># Whether or not the INTERVAL expression works only with values like '1 day'</span> +</span><span id="Generator-115"><a href="#Generator-115"><span class="linenos"> 115</span></a> <span class="n">SINGLE_STRING_INTERVAL</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Generator-116"><a href="#Generator-116"><span class="linenos"> 116</span></a> +</span><span id="Generator-117"><a href="#Generator-117"><span class="linenos"> 117</span></a> <span class="c1"># Whether or not the plural form of date parts like day (i.e. "days") is supported in INTERVALs</span> +</span><span id="Generator-118"><a href="#Generator-118"><span class="linenos"> 118</span></a> <span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Generator-119"><a href="#Generator-119"><span class="linenos"> 119</span></a> +</span><span id="Generator-120"><a href="#Generator-120"><span class="linenos"> 120</span></a> <span class="c1"># Whether or not the TABLESAMPLE clause supports a method name, like BERNOULLI</span> +</span><span id="Generator-121"><a href="#Generator-121"><span class="linenos"> 121</span></a> <span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Generator-122"><a href="#Generator-122"><span class="linenos"> 122</span></a> +</span><span id="Generator-123"><a href="#Generator-123"><span class="linenos"> 123</span></a> <span class="c1"># Whether or not to treat the number in TABLESAMPLE (50) as a percentage</span> +</span><span id="Generator-124"><a href="#Generator-124"><span class="linenos"> 124</span></a> <span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Generator-125"><a href="#Generator-125"><span class="linenos"> 125</span></a> +</span><span id="Generator-126"><a href="#Generator-126"><span class="linenos"> 126</span></a> <span class="c1"># Whether or not limit and fetch are supported (possible values: "ALL", "LIMIT", "FETCH")</span> +</span><span id="Generator-127"><a href="#Generator-127"><span class="linenos"> 127</span></a> <span class="n">LIMIT_FETCH</span> <span class="o">=</span> <span class="s2">"ALL"</span> +</span><span id="Generator-128"><a href="#Generator-128"><span class="linenos"> 128</span></a> +</span><span id="Generator-129"><a href="#Generator-129"><span class="linenos"> 129</span></a> <span class="c1"># Whether or not a table is allowed to be renamed with a db</span> +</span><span id="Generator-130"><a href="#Generator-130"><span class="linenos"> 130</span></a> <span class="n">RENAME_TABLE_WITH_DB</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Generator-131"><a href="#Generator-131"><span class="linenos"> 131</span></a> +</span><span id="Generator-132"><a href="#Generator-132"><span class="linenos"> 132</span></a> <span class="c1"># The separator for grouping sets and rollups</span> +</span><span id="Generator-133"><a href="#Generator-133"><span class="linenos"> 133</span></a> <span class="n">GROUPINGS_SEP</span> <span class="o">=</span> <span class="s2">","</span> +</span><span id="Generator-134"><a href="#Generator-134"><span class="linenos"> 134</span></a> +</span><span id="Generator-135"><a href="#Generator-135"><span class="linenos"> 135</span></a> <span class="c1"># The string used for creating an index on a table</span> +</span><span id="Generator-136"><a href="#Generator-136"><span class="linenos"> 136</span></a> <span class="n">INDEX_ON</span> <span class="o">=</span> <span class="s2">"ON"</span> +</span><span id="Generator-137"><a href="#Generator-137"><span class="linenos"> 137</span></a> +</span><span id="Generator-138"><a href="#Generator-138"><span class="linenos"> 138</span></a> <span class="c1"># Whether or not join hints should be generated</span> +</span><span id="Generator-139"><a href="#Generator-139"><span class="linenos"> 139</span></a> <span class="n">JOIN_HINTS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Generator-140"><a href="#Generator-140"><span class="linenos"> 140</span></a> +</span><span id="Generator-141"><a href="#Generator-141"><span class="linenos"> 141</span></a> <span class="c1"># Whether or not table hints should be generated</span> +</span><span id="Generator-142"><a href="#Generator-142"><span class="linenos"> 142</span></a> <span class="n">TABLE_HINTS</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Generator-143"><a href="#Generator-143"><span class="linenos"> 143</span></a> +</span><span id="Generator-144"><a href="#Generator-144"><span class="linenos"> 144</span></a> <span class="c1"># Whether or not comparing against booleans (e.g. x IS TRUE) is supported</span> +</span><span id="Generator-145"><a href="#Generator-145"><span class="linenos"> 145</span></a> <span class="n">IS_BOOL_ALLOWED</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Generator-146"><a href="#Generator-146"><span class="linenos"> 146</span></a> +</span><span id="Generator-147"><a href="#Generator-147"><span class="linenos"> 147</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax</span> +</span><span id="Generator-148"><a href="#Generator-148"><span class="linenos"> 148</span></a> <span class="n">SELECT_KINDS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="o">...</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"STRUCT"</span><span class="p">,</span> <span class="s2">"VALUE"</span><span class="p">)</span> +</span><span id="Generator-149"><a href="#Generator-149"><span class="linenos"> 149</span></a> +</span><span id="Generator-150"><a href="#Generator-150"><span class="linenos"> 150</span></a> <span class="n">TYPE_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Generator-151"><a href="#Generator-151"><span class="linenos"> 151</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">:</span> <span class="s2">"CHAR"</span><span class="p">,</span> +</span><span id="Generator-152"><a href="#Generator-152"><span class="linenos"> 152</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">:</span> <span class="s2">"VARCHAR"</span><span class="p">,</span> +</span><span id="Generator-153"><a href="#Generator-153"><span class="linenos"> 153</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">MEDIUMTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="Generator-154"><a href="#Generator-154"><span class="linenos"> 154</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">LONGTEXT</span><span class="p">:</span> <span class="s2">"TEXT"</span><span class="p">,</span> +</span><span id="Generator-155"><a href="#Generator-155"><span class="linenos"> 155</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">MEDIUMBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> +</span><span id="Generator-156"><a href="#Generator-156"><span class="linenos"> 156</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">LONGBLOB</span><span class="p">:</span> <span class="s2">"BLOB"</span><span class="p">,</span> +</span><span id="Generator-157"><a href="#Generator-157"><span class="linenos"> 157</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INET</span><span class="p">:</span> <span class="s2">"INET"</span><span class="p">,</span> +</span><span id="Generator-158"><a href="#Generator-158"><span class="linenos"> 158</span></a> <span class="p">}</span> +</span><span id="Generator-159"><a href="#Generator-159"><span class="linenos"> 159</span></a> +</span><span id="Generator-160"><a href="#Generator-160"><span class="linenos"> 160</span></a> <span class="n">STAR_MAPPING</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Generator-161"><a href="#Generator-161"><span class="linenos"> 161</span></a> <span class="s2">"except"</span><span class="p">:</span> <span class="s2">"EXCEPT"</span><span class="p">,</span> +</span><span id="Generator-162"><a href="#Generator-162"><span class="linenos"> 162</span></a> <span class="s2">"replace"</span><span class="p">:</span> <span class="s2">"REPLACE"</span><span class="p">,</span> +</span><span id="Generator-163"><a href="#Generator-163"><span class="linenos"> 163</span></a> <span class="p">}</span> +</span><span id="Generator-164"><a href="#Generator-164"><span class="linenos"> 164</span></a> +</span><span id="Generator-165"><a href="#Generator-165"><span class="linenos"> 165</span></a> <span class="n">TIME_PART_SINGULARS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Generator-166"><a href="#Generator-166"><span class="linenos"> 166</span></a> <span class="s2">"microseconds"</span><span class="p">:</span> <span class="s2">"microsecond"</span><span class="p">,</span> +</span><span id="Generator-167"><a href="#Generator-167"><span class="linenos"> 167</span></a> <span class="s2">"seconds"</span><span class="p">:</span> <span class="s2">"second"</span><span class="p">,</span> +</span><span id="Generator-168"><a href="#Generator-168"><span class="linenos"> 168</span></a> <span class="s2">"minutes"</span><span class="p">:</span> <span class="s2">"minute"</span><span class="p">,</span> +</span><span id="Generator-169"><a href="#Generator-169"><span class="linenos"> 169</span></a> <span class="s2">"hours"</span><span class="p">:</span> <span class="s2">"hour"</span><span class="p">,</span> +</span><span id="Generator-170"><a href="#Generator-170"><span class="linenos"> 170</span></a> <span class="s2">"days"</span><span class="p">:</span> <span class="s2">"day"</span><span class="p">,</span> +</span><span id="Generator-171"><a href="#Generator-171"><span class="linenos"> 171</span></a> <span class="s2">"weeks"</span><span class="p">:</span> <span class="s2">"week"</span><span class="p">,</span> +</span><span id="Generator-172"><a href="#Generator-172"><span class="linenos"> 172</span></a> <span class="s2">"months"</span><span class="p">:</span> <span class="s2">"month"</span><span class="p">,</span> +</span><span id="Generator-173"><a href="#Generator-173"><span class="linenos"> 173</span></a> <span class="s2">"quarters"</span><span class="p">:</span> <span class="s2">"quarter"</span><span class="p">,</span> +</span><span id="Generator-174"><a href="#Generator-174"><span class="linenos"> 174</span></a> <span class="s2">"years"</span><span class="p">:</span> <span class="s2">"year"</span><span class="p">,</span> +</span><span id="Generator-175"><a href="#Generator-175"><span class="linenos"> 175</span></a> <span class="p">}</span> </span><span id="Generator-176"><a href="#Generator-176"><span class="linenos"> 176</span></a> -</span><span id="Generator-177"><a href="#Generator-177"><span class="linenos"> 177</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"@"</span> +</span><span id="Generator-177"><a href="#Generator-177"><span class="linenos"> 177</span></a> <span class="n">TOKEN_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">TokenType</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> </span><span id="Generator-178"><a href="#Generator-178"><span class="linenos"> 178</span></a> -</span><span id="Generator-179"><a href="#Generator-179"><span class="linenos"> 179</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Generator-180"><a href="#Generator-180"><span class="linenos"> 180</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AlgorithmProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="Generator-181"><a href="#Generator-181"><span class="linenos"> 181</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AutoIncrementProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-182"><a href="#Generator-182"><span class="linenos"> 182</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-183"><a href="#Generator-183"><span class="linenos"> 183</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-184"><a href="#Generator-184"><span class="linenos"> 184</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-185"><a href="#Generator-185"><span class="linenos"> 185</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-186"><a href="#Generator-186"><span class="linenos"> 186</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-187"><a href="#Generator-187"><span class="linenos"> 187</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-188"><a href="#Generator-188"><span class="linenos"> 188</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DefinerProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="Generator-189"><a href="#Generator-189"><span class="linenos"> 189</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictRange</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-190"><a href="#Generator-190"><span class="linenos"> 190</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-191"><a href="#Generator-191"><span class="linenos"> 191</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-192"><a href="#Generator-192"><span class="linenos"> 192</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-193"><a href="#Generator-193"><span class="linenos"> 193</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">EngineProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-194"><a href="#Generator-194"><span class="linenos"> 194</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExecuteAsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-195"><a href="#Generator-195"><span class="linenos"> 195</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExternalProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="Generator-196"><a href="#Generator-196"><span class="linenos"> 196</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-197"><a href="#Generator-197"><span class="linenos"> 197</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> -</span><span id="Generator-198"><a href="#Generator-198"><span class="linenos"> 198</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-199"><a href="#Generator-199"><span class="linenos"> 199</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-200"><a href="#Generator-200"><span class="linenos"> 200</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-201"><a href="#Generator-201"><span class="linenos"> 201</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LanguageProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-202"><a href="#Generator-202"><span class="linenos"> 202</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-203"><a href="#Generator-203"><span class="linenos"> 203</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-204"><a href="#Generator-204"><span class="linenos"> 204</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">,</span> -</span><span id="Generator-205"><a href="#Generator-205"><span class="linenos"> 205</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-206"><a href="#Generator-206"><span class="linenos"> 206</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MaterializedProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="Generator-207"><a href="#Generator-207"><span class="linenos"> 207</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-208"><a href="#Generator-208"><span class="linenos"> 208</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NoPrimaryIndexProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> -</span><span id="Generator-209"><a href="#Generator-209"><span class="linenos"> 209</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> -</span><span id="Generator-210"><a href="#Generator-210"><span class="linenos"> 210</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-211"><a href="#Generator-211"><span class="linenos"> 211</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> -</span><span id="Generator-212"><a href="#Generator-212"><span class="linenos"> 212</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKey</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-213"><a href="#Generator-213"><span class="linenos"> 213</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> -</span><span id="Generator-214"><a href="#Generator-214"><span class="linenos"> 214</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-215"><a href="#Generator-215"><span class="linenos"> 215</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-216"><a href="#Generator-216"><span class="linenos"> 216</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-217"><a href="#Generator-217"><span class="linenos"> 217</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatSerdeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-218"><a href="#Generator-218"><span class="linenos"> 218</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-219"><a href="#Generator-219"><span class="linenos"> 219</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-220"><a href="#Generator-220"><span class="linenos"> 220</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-221"><a href="#Generator-221"><span class="linenos"> 221</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SettingsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-222"><a href="#Generator-222"><span class="linenos"> 222</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="Generator-223"><a href="#Generator-223"><span class="linenos"> 223</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-224"><a href="#Generator-224"><span class="linenos"> 224</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SqlSecurityProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="Generator-225"><a href="#Generator-225"><span class="linenos"> 225</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-226"><a href="#Generator-226"><span class="linenos"> 226</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="Generator-227"><a href="#Generator-227"><span class="linenos"> 227</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToTableProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-228"><a href="#Generator-228"><span class="linenos"> 228</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TransientProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="Generator-229"><a href="#Generator-229"><span class="linenos"> 229</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> -</span><span id="Generator-230"><a href="#Generator-230"><span class="linenos"> 230</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> -</span><span id="Generator-231"><a href="#Generator-231"><span class="linenos"> 231</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> -</span><span id="Generator-232"><a href="#Generator-232"><span class="linenos"> 232</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithJournalTableProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> -</span><span id="Generator-233"><a href="#Generator-233"><span class="linenos"> 233</span></a> <span class="p">}</span> -</span><span id="Generator-234"><a href="#Generator-234"><span class="linenos"> 234</span></a> -</span><span id="Generator-235"><a href="#Generator-235"><span class="linenos"> 235</span></a> <span class="c1"># Keywords that can't be used as unquoted identifier names</span> -</span><span id="Generator-236"><a href="#Generator-236"><span class="linenos"> 236</span></a> <span class="n">RESERVED_KEYWORDS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> -</span><span id="Generator-237"><a href="#Generator-237"><span class="linenos"> 237</span></a> -</span><span id="Generator-238"><a href="#Generator-238"><span class="linenos"> 238</span></a> <span class="c1"># Expressions whose comments are separated from them for better formatting</span> -</span><span id="Generator-239"><a href="#Generator-239"><span class="linenos"> 239</span></a> <span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> <span class="o">...</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-240"><a href="#Generator-240"><span class="linenos"> 240</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> -</span><span id="Generator-241"><a href="#Generator-241"><span class="linenos"> 241</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> -</span><span id="Generator-242"><a href="#Generator-242"><span class="linenos"> 242</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">,</span> -</span><span id="Generator-243"><a href="#Generator-243"><span class="linenos"> 243</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">,</span> -</span><span id="Generator-244"><a href="#Generator-244"><span class="linenos"> 244</span></a> <span class="p">)</span> -</span><span id="Generator-245"><a href="#Generator-245"><span class="linenos"> 245</span></a> -</span><span id="Generator-246"><a href="#Generator-246"><span class="linenos"> 246</span></a> <span class="c1"># Expressions that can remain unwrapped when appearing in the context of an INTERVAL</span> -</span><span id="Generator-247"><a href="#Generator-247"><span class="linenos"> 247</span></a> <span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> <span class="o">...</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-248"><a href="#Generator-248"><span class="linenos"> 248</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">,</span> -</span><span id="Generator-249"><a href="#Generator-249"><span class="linenos"> 249</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">,</span> -</span><span id="Generator-250"><a href="#Generator-250"><span class="linenos"> 250</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Neg</span><span class="p">,</span> -</span><span id="Generator-251"><a href="#Generator-251"><span class="linenos"> 251</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</span><span class="p">,</span> -</span><span id="Generator-252"><a href="#Generator-252"><span class="linenos"> 252</span></a> <span class="p">)</span> -</span><span id="Generator-253"><a href="#Generator-253"><span class="linenos"> 253</span></a> -</span><span id="Generator-254"><a href="#Generator-254"><span class="linenos"> 254</span></a> <span class="n">SENTINEL_LINE_BREAK</span> <span class="o">=</span> <span class="s2">"__SQLGLOT__LB__"</span> -</span><span id="Generator-255"><a href="#Generator-255"><span class="linenos"> 255</span></a> -</span><span id="Generator-256"><a href="#Generator-256"><span class="linenos"> 256</span></a> <span class="c1"># Autofilled</span> -</span><span id="Generator-257"><a href="#Generator-257"><span class="linenos"> 257</span></a> <span class="n">INVERSE_TIME_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Generator-258"><a href="#Generator-258"><span class="linenos"> 258</span></a> <span class="n">INVERSE_TIME_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Generator-259"><a href="#Generator-259"><span class="linenos"> 259</span></a> <span class="n">INDEX_OFFSET</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="Generator-260"><a href="#Generator-260"><span class="linenos"> 260</span></a> <span class="n">UNNEST_COLUMN_ONLY</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Generator-261"><a href="#Generator-261"><span class="linenos"> 261</span></a> <span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Generator-262"><a href="#Generator-262"><span class="linenos"> 262</span></a> <span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Generator-263"><a href="#Generator-263"><span class="linenos"> 263</span></a> <span class="n">STRICT_STRING_CONCAT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Generator-264"><a href="#Generator-264"><span class="linenos"> 264</span></a> <span class="n">NORMALIZE_FUNCTIONS</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">|</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"upper"</span> -</span><span id="Generator-265"><a href="#Generator-265"><span class="linenos"> 265</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_small"</span> -</span><span id="Generator-266"><a href="#Generator-266"><span class="linenos"> 266</span></a> -</span><span id="Generator-267"><a href="#Generator-267"><span class="linenos"> 267</span></a> <span class="c1"># Delimiters for quotes, identifiers and the corresponding escape characters</span> -</span><span id="Generator-268"><a href="#Generator-268"><span class="linenos"> 268</span></a> <span class="n">QUOTE_START</span> <span class="o">=</span> <span class="s2">"'"</span> -</span><span id="Generator-269"><a href="#Generator-269"><span class="linenos"> 269</span></a> <span class="n">QUOTE_END</span> <span class="o">=</span> <span class="s2">"'"</span> -</span><span id="Generator-270"><a href="#Generator-270"><span class="linenos"> 270</span></a> <span class="n">IDENTIFIER_START</span> <span class="o">=</span> <span class="s1">'"'</span> -</span><span id="Generator-271"><a href="#Generator-271"><span class="linenos"> 271</span></a> <span class="n">IDENTIFIER_END</span> <span class="o">=</span> <span class="s1">'"'</span> -</span><span id="Generator-272"><a href="#Generator-272"><span class="linenos"> 272</span></a> <span class="n">STRING_ESCAPE</span> <span class="o">=</span> <span class="s2">"'"</span> -</span><span id="Generator-273"><a href="#Generator-273"><span class="linenos"> 273</span></a> <span class="n">IDENTIFIER_ESCAPE</span> <span class="o">=</span> <span class="s1">'"'</span> -</span><span id="Generator-274"><a href="#Generator-274"><span class="linenos"> 274</span></a> -</span><span id="Generator-275"><a href="#Generator-275"><span class="linenos"> 275</span></a> <span class="c1"># Delimiters for bit, hex, byte and raw literals</span> -</span><span id="Generator-276"><a href="#Generator-276"><span class="linenos"> 276</span></a> <span class="n">BIT_START</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><span id="Generator-277"><a href="#Generator-277"><span class="linenos"> 277</span></a> <span class="n">BIT_END</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><span id="Generator-278"><a href="#Generator-278"><span class="linenos"> 278</span></a> <span class="n">HEX_START</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><span id="Generator-279"><a href="#Generator-279"><span class="linenos"> 279</span></a> <span class="n">HEX_END</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><span id="Generator-280"><a href="#Generator-280"><span class="linenos"> 280</span></a> <span class="n">BYTE_START</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><span id="Generator-281"><a href="#Generator-281"><span class="linenos"> 281</span></a> <span class="n">BYTE_END</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><span id="Generator-282"><a href="#Generator-282"><span class="linenos"> 282</span></a> <span class="n">RAW_START</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><span id="Generator-283"><a href="#Generator-283"><span class="linenos"> 283</span></a> <span class="n">RAW_END</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><span id="Generator-284"><a href="#Generator-284"><span class="linenos"> 284</span></a> -</span><span id="Generator-285"><a href="#Generator-285"><span class="linenos"> 285</span></a> <span class="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-286"><a href="#Generator-286"><span class="linenos"> 286</span></a> <span class="s2">"pretty"</span><span class="p">,</span> -</span><span id="Generator-287"><a href="#Generator-287"><span class="linenos"> 287</span></a> <span class="s2">"identify"</span><span class="p">,</span> -</span><span id="Generator-288"><a href="#Generator-288"><span class="linenos"> 288</span></a> <span class="s2">"normalize"</span><span class="p">,</span> -</span><span id="Generator-289"><a href="#Generator-289"><span class="linenos"> 289</span></a> <span class="s2">"pad"</span><span class="p">,</span> -</span><span id="Generator-290"><a href="#Generator-290"><span class="linenos"> 290</span></a> <span class="s2">"_indent"</span><span class="p">,</span> -</span><span id="Generator-291"><a href="#Generator-291"><span class="linenos"> 291</span></a> <span class="s2">"normalize_functions"</span><span class="p">,</span> -</span><span id="Generator-292"><a href="#Generator-292"><span class="linenos"> 292</span></a> <span class="s2">"unsupported_level"</span><span class="p">,</span> -</span><span id="Generator-293"><a href="#Generator-293"><span class="linenos"> 293</span></a> <span class="s2">"max_unsupported"</span><span class="p">,</span> -</span><span id="Generator-294"><a href="#Generator-294"><span class="linenos"> 294</span></a> <span class="s2">"leading_comma"</span><span class="p">,</span> -</span><span id="Generator-295"><a href="#Generator-295"><span class="linenos"> 295</span></a> <span class="s2">"max_text_width"</span><span class="p">,</span> -</span><span id="Generator-296"><a href="#Generator-296"><span class="linenos"> 296</span></a> <span class="s2">"comments"</span><span class="p">,</span> -</span><span id="Generator-297"><a href="#Generator-297"><span class="linenos"> 297</span></a> <span class="s2">"unsupported_messages"</span><span class="p">,</span> -</span><span id="Generator-298"><a href="#Generator-298"><span class="linenos"> 298</span></a> <span class="s2">"_escaped_quote_end"</span><span class="p">,</span> -</span><span id="Generator-299"><a href="#Generator-299"><span class="linenos"> 299</span></a> <span class="s2">"_escaped_identifier_end"</span><span class="p">,</span> -</span><span id="Generator-300"><a href="#Generator-300"><span class="linenos"> 300</span></a> <span class="s2">"_cache"</span><span class="p">,</span> -</span><span id="Generator-301"><a href="#Generator-301"><span class="linenos"> 301</span></a> <span class="p">)</span> -</span><span id="Generator-302"><a href="#Generator-302"><span class="linenos"> 302</span></a> -</span><span id="Generator-303"><a href="#Generator-303"><span class="linenos"> 303</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> -</span><span id="Generator-304"><a href="#Generator-304"><span class="linenos"> 304</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator-305"><a href="#Generator-305"><span class="linenos"> 305</span></a> <span class="n">pretty</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-306"><a href="#Generator-306"><span class="linenos"> 306</span></a> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Generator-307"><a href="#Generator-307"><span class="linenos"> 307</span></a> <span class="n">normalize</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Generator-308"><a href="#Generator-308"><span class="linenos"> 308</span></a> <span class="n">pad</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> -</span><span id="Generator-309"><a href="#Generator-309"><span class="linenos"> 309</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> -</span><span id="Generator-310"><a href="#Generator-310"><span class="linenos"> 310</span></a> <span class="n">normalize_functions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-311"><a href="#Generator-311"><span class="linenos"> 311</span></a> <span class="n">unsupported_level</span><span class="p">:</span> <span class="n">ErrorLevel</span> <span class="o">=</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">,</span> -</span><span id="Generator-312"><a href="#Generator-312"><span class="linenos"> 312</span></a> <span class="n">max_unsupported</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> -</span><span id="Generator-313"><a href="#Generator-313"><span class="linenos"> 313</span></a> <span class="n">leading_comma</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Generator-314"><a href="#Generator-314"><span class="linenos"> 314</span></a> <span class="n">max_text_width</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">80</span><span class="p">,</span> -</span><span id="Generator-315"><a href="#Generator-315"><span class="linenos"> 315</span></a> <span class="n">comments</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Generator-316"><a href="#Generator-316"><span class="linenos"> 316</span></a> <span class="p">):</span> -</span><span id="Generator-317"><a href="#Generator-317"><span class="linenos"> 317</span></a> <span class="kn">import</span> <span class="nn">sqlglot</span> -</span><span id="Generator-318"><a href="#Generator-318"><span class="linenos"> 318</span></a> -</span><span id="Generator-319"><a href="#Generator-319"><span class="linenos"> 319</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="o">=</span> <span class="n">pretty</span> <span class="k">if</span> <span class="n">pretty</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">pretty</span> -</span><span id="Generator-320"><a href="#Generator-320"><span class="linenos"> 320</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">identify</span> -</span><span id="Generator-321"><a href="#Generator-321"><span class="linenos"> 321</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="o">=</span> <span class="n">normalize</span> -</span><span id="Generator-322"><a href="#Generator-322"><span class="linenos"> 322</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="o">=</span> <span class="n">pad</span> -</span><span id="Generator-323"><a href="#Generator-323"><span class="linenos"> 323</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_indent</span> <span class="o">=</span> <span class="n">indent</span> -</span><span id="Generator-324"><a href="#Generator-324"><span class="linenos"> 324</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">=</span> <span class="n">unsupported_level</span> -</span><span id="Generator-325"><a href="#Generator-325"><span class="linenos"> 325</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span> <span class="o">=</span> <span class="n">max_unsupported</span> -</span><span id="Generator-326"><a href="#Generator-326"><span class="linenos"> 326</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span> <span class="o">=</span> <span class="n">leading_comma</span> -</span><span id="Generator-327"><a href="#Generator-327"><span class="linenos"> 327</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="o">=</span> <span class="n">max_text_width</span> -</span><span id="Generator-328"><a href="#Generator-328"><span class="linenos"> 328</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> -</span><span id="Generator-329"><a href="#Generator-329"><span class="linenos"> 329</span></a> -</span><span id="Generator-330"><a href="#Generator-330"><span class="linenos"> 330</span></a> <span class="c1"># This is both a Dialect property and a Generator argument, so we prioritize the latter</span> -</span><span id="Generator-331"><a href="#Generator-331"><span class="linenos"> 331</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-332"><a href="#Generator-332"><span class="linenos"> 332</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">NORMALIZE_FUNCTIONS</span> <span class="k">if</span> <span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">normalize_functions</span> -</span><span id="Generator-333"><a href="#Generator-333"><span class="linenos"> 333</span></a> <span class="p">)</span> -</span><span id="Generator-334"><a href="#Generator-334"><span class="linenos"> 334</span></a> -</span><span id="Generator-335"><a href="#Generator-335"><span class="linenos"> 335</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator-336"><a href="#Generator-336"><span class="linenos"> 336</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRING_ESCAPE</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span> -</span><span id="Generator-337"><a href="#Generator-337"><span class="linenos"> 337</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_ESCAPE</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_END</span> -</span><span id="Generator-338"><a href="#Generator-338"><span class="linenos"> 338</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Generator-339"><a href="#Generator-339"><span class="linenos"> 339</span></a> -</span><span id="Generator-340"><a href="#Generator-340"><span class="linenos"> 340</span></a> <span class="k">def</span> <span class="nf">generate</span><span class="p">(</span> -</span><span id="Generator-341"><a href="#Generator-341"><span class="linenos"> 341</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator-342"><a href="#Generator-342"><span class="linenos"> 342</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> -</span><span id="Generator-343"><a href="#Generator-343"><span class="linenos"> 343</span></a> <span class="n">cache</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-344"><a href="#Generator-344"><span class="linenos"> 344</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-345"><a href="#Generator-345"><span class="linenos"> 345</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Generator-346"><a href="#Generator-346"><span class="linenos"> 346</span></a><span class="sd"> Generates the SQL string corresponding to the given syntax tree.</span> -</span><span id="Generator-347"><a href="#Generator-347"><span class="linenos"> 347</span></a> -</span><span id="Generator-348"><a href="#Generator-348"><span class="linenos"> 348</span></a><span class="sd"> Args:</span> -</span><span id="Generator-349"><a href="#Generator-349"><span class="linenos"> 349</span></a><span class="sd"> expression: The syntax tree.</span> -</span><span id="Generator-350"><a href="#Generator-350"><span class="linenos"> 350</span></a><span class="sd"> cache: An optional sql string cache. This leverages the hash of an Expression</span> -</span><span id="Generator-351"><a href="#Generator-351"><span class="linenos"> 351</span></a><span class="sd"> which can be slow to compute, so only use it if you set _hash on each node.</span> -</span><span id="Generator-352"><a href="#Generator-352"><span class="linenos"> 352</span></a> -</span><span id="Generator-353"><a href="#Generator-353"><span class="linenos"> 353</span></a><span class="sd"> Returns:</span> -</span><span id="Generator-354"><a href="#Generator-354"><span class="linenos"> 354</span></a><span class="sd"> The SQL string corresponding to `expression`.</span> -</span><span id="Generator-355"><a href="#Generator-355"><span class="linenos"> 355</span></a><span class="sd"> """</span> -</span><span id="Generator-356"><a href="#Generator-356"><span class="linenos"> 356</span></a> <span class="k">if</span> <span class="n">cache</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-357"><a href="#Generator-357"><span class="linenos"> 357</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="o">=</span> <span class="n">cache</span> -</span><span id="Generator-358"><a href="#Generator-358"><span class="linenos"> 358</span></a> -</span><span id="Generator-359"><a href="#Generator-359"><span class="linenos"> 359</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator-360"><a href="#Generator-360"><span class="linenos"> 360</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="Generator-361"><a href="#Generator-361"><span class="linenos"> 361</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Generator-362"><a href="#Generator-362"><span class="linenos"> 362</span></a> -</span><span id="Generator-363"><a href="#Generator-363"><span class="linenos"> 363</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IGNORE</span><span class="p">:</span> -</span><span id="Generator-364"><a href="#Generator-364"><span class="linenos"> 364</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator-179"><a href="#Generator-179"><span class="linenos"> 179</span></a> <span class="n">STRUCT_DELIMITER</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"<"</span><span class="p">,</span> <span class="s2">">"</span><span class="p">)</span> +</span><span id="Generator-180"><a href="#Generator-180"><span class="linenos"> 180</span></a> +</span><span id="Generator-181"><a href="#Generator-181"><span class="linenos"> 181</span></a> <span class="n">PARAMETER_TOKEN</span> <span class="o">=</span> <span class="s2">"@"</span> +</span><span id="Generator-182"><a href="#Generator-182"><span class="linenos"> 182</span></a> +</span><span id="Generator-183"><a href="#Generator-183"><span class="linenos"> 183</span></a> <span class="n">PROPERTIES_LOCATION</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Generator-184"><a href="#Generator-184"><span class="linenos"> 184</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AlgorithmProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="Generator-185"><a href="#Generator-185"><span class="linenos"> 185</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AutoIncrementProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-186"><a href="#Generator-186"><span class="linenos"> 186</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-187"><a href="#Generator-187"><span class="linenos"> 187</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-188"><a href="#Generator-188"><span class="linenos"> 188</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-189"><a href="#Generator-189"><span class="linenos"> 189</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-190"><a href="#Generator-190"><span class="linenos"> 190</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CopyGrantsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-191"><a href="#Generator-191"><span class="linenos"> 191</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-192"><a href="#Generator-192"><span class="linenos"> 192</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-193"><a href="#Generator-193"><span class="linenos"> 193</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DefinerProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="Generator-194"><a href="#Generator-194"><span class="linenos"> 194</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictRange</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-195"><a href="#Generator-195"><span class="linenos"> 195</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-196"><a href="#Generator-196"><span class="linenos"> 196</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistKeyProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-197"><a href="#Generator-197"><span class="linenos"> 197</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-198"><a href="#Generator-198"><span class="linenos"> 198</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">EngineProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-199"><a href="#Generator-199"><span class="linenos"> 199</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExecuteAsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-200"><a href="#Generator-200"><span class="linenos"> 200</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ExternalProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="Generator-201"><a href="#Generator-201"><span class="linenos"> 201</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-202"><a href="#Generator-202"><span class="linenos"> 202</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> +</span><span id="Generator-203"><a href="#Generator-203"><span class="linenos"> 203</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-204"><a href="#Generator-204"><span class="linenos"> 204</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-205"><a href="#Generator-205"><span class="linenos"> 205</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-206"><a href="#Generator-206"><span class="linenos"> 206</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LanguageProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-207"><a href="#Generator-207"><span class="linenos"> 207</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-208"><a href="#Generator-208"><span class="linenos"> 208</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-209"><a href="#Generator-209"><span class="linenos"> 209</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">,</span> +</span><span id="Generator-210"><a href="#Generator-210"><span class="linenos"> 210</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LogProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-211"><a href="#Generator-211"><span class="linenos"> 211</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MaterializedProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="Generator-212"><a href="#Generator-212"><span class="linenos"> 212</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-213"><a href="#Generator-213"><span class="linenos"> 213</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NoPrimaryIndexProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> +</span><span id="Generator-214"><a href="#Generator-214"><span class="linenos"> 214</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> +</span><span id="Generator-215"><a href="#Generator-215"><span class="linenos"> 215</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-216"><a href="#Generator-216"><span class="linenos"> 216</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> +</span><span id="Generator-217"><a href="#Generator-217"><span class="linenos"> 217</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKey</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-218"><a href="#Generator-218"><span class="linenos"> 218</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">,</span> +</span><span id="Generator-219"><a href="#Generator-219"><span class="linenos"> 219</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ReturnsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-220"><a href="#Generator-220"><span class="linenos"> 220</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-221"><a href="#Generator-221"><span class="linenos"> 221</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-222"><a href="#Generator-222"><span class="linenos"> 222</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatSerdeProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-223"><a href="#Generator-223"><span class="linenos"> 223</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-224"><a href="#Generator-224"><span class="linenos"> 224</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SerdeProperties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-225"><a href="#Generator-225"><span class="linenos"> 225</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-226"><a href="#Generator-226"><span class="linenos"> 226</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SettingsProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-227"><a href="#Generator-227"><span class="linenos"> 227</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="Generator-228"><a href="#Generator-228"><span class="linenos"> 228</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-229"><a href="#Generator-229"><span class="linenos"> 229</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SqlSecurityProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="Generator-230"><a href="#Generator-230"><span class="linenos"> 230</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-231"><a href="#Generator-231"><span class="linenos"> 231</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="Generator-232"><a href="#Generator-232"><span class="linenos"> 232</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ToTableProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-233"><a href="#Generator-233"><span class="linenos"> 233</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TransientProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="Generator-234"><a href="#Generator-234"><span class="linenos"> 234</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">,</span> +</span><span id="Generator-235"><a href="#Generator-235"><span class="linenos"> 235</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">,</span> +</span><span id="Generator-236"><a href="#Generator-236"><span class="linenos"> 236</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">,</span> +</span><span id="Generator-237"><a href="#Generator-237"><span class="linenos"> 237</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WithJournalTableProperty</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">,</span> +</span><span id="Generator-238"><a href="#Generator-238"><span class="linenos"> 238</span></a> <span class="p">}</span> +</span><span id="Generator-239"><a href="#Generator-239"><span class="linenos"> 239</span></a> +</span><span id="Generator-240"><a href="#Generator-240"><span class="linenos"> 240</span></a> <span class="c1"># Keywords that can't be used as unquoted identifier names</span> +</span><span id="Generator-241"><a href="#Generator-241"><span class="linenos"> 241</span></a> <span class="n">RESERVED_KEYWORDS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> +</span><span id="Generator-242"><a href="#Generator-242"><span class="linenos"> 242</span></a> +</span><span id="Generator-243"><a href="#Generator-243"><span class="linenos"> 243</span></a> <span class="c1"># Expressions whose comments are separated from them for better formatting</span> +</span><span id="Generator-244"><a href="#Generator-244"><span class="linenos"> 244</span></a> <span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> <span class="o">...</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-245"><a href="#Generator-245"><span class="linenos"> 245</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> +</span><span id="Generator-246"><a href="#Generator-246"><span class="linenos"> 246</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> +</span><span id="Generator-247"><a href="#Generator-247"><span class="linenos"> 247</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">,</span> +</span><span id="Generator-248"><a href="#Generator-248"><span class="linenos"> 248</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">,</span> +</span><span id="Generator-249"><a href="#Generator-249"><span class="linenos"> 249</span></a> <span class="p">)</span> +</span><span id="Generator-250"><a href="#Generator-250"><span class="linenos"> 250</span></a> +</span><span id="Generator-251"><a href="#Generator-251"><span class="linenos"> 251</span></a> <span class="c1"># Expressions that can remain unwrapped when appearing in the context of an INTERVAL</span> +</span><span id="Generator-252"><a href="#Generator-252"><span class="linenos"> 252</span></a> <span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> <span class="o">...</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-253"><a href="#Generator-253"><span class="linenos"> 253</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">,</span> +</span><span id="Generator-254"><a href="#Generator-254"><span class="linenos"> 254</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">,</span> +</span><span id="Generator-255"><a href="#Generator-255"><span class="linenos"> 255</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Neg</span><span class="p">,</span> +</span><span id="Generator-256"><a href="#Generator-256"><span class="linenos"> 256</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</span><span class="p">,</span> +</span><span id="Generator-257"><a href="#Generator-257"><span class="linenos"> 257</span></a> <span class="p">)</span> +</span><span id="Generator-258"><a href="#Generator-258"><span class="linenos"> 258</span></a> +</span><span id="Generator-259"><a href="#Generator-259"><span class="linenos"> 259</span></a> <span class="n">SENTINEL_LINE_BREAK</span> <span class="o">=</span> <span class="s2">"__SQLGLOT__LB__"</span> +</span><span id="Generator-260"><a href="#Generator-260"><span class="linenos"> 260</span></a> +</span><span id="Generator-261"><a href="#Generator-261"><span class="linenos"> 261</span></a> <span class="c1"># Autofilled</span> +</span><span id="Generator-262"><a href="#Generator-262"><span class="linenos"> 262</span></a> <span class="n">INVERSE_TIME_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Generator-263"><a href="#Generator-263"><span class="linenos"> 263</span></a> <span class="n">INVERSE_TIME_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Generator-264"><a href="#Generator-264"><span class="linenos"> 264</span></a> <span class="n">INDEX_OFFSET</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="Generator-265"><a href="#Generator-265"><span class="linenos"> 265</span></a> <span class="n">UNNEST_COLUMN_ONLY</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Generator-266"><a href="#Generator-266"><span class="linenos"> 266</span></a> <span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Generator-267"><a href="#Generator-267"><span class="linenos"> 267</span></a> <span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Generator-268"><a href="#Generator-268"><span class="linenos"> 268</span></a> <span class="n">STRICT_STRING_CONCAT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Generator-269"><a href="#Generator-269"><span class="linenos"> 269</span></a> <span class="n">NORMALIZE_FUNCTIONS</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">|</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"upper"</span> +</span><span id="Generator-270"><a href="#Generator-270"><span class="linenos"> 270</span></a> <span class="n">NULL_ORDERING</span> <span class="o">=</span> <span class="s2">"nulls_are_small"</span> +</span><span id="Generator-271"><a href="#Generator-271"><span class="linenos"> 271</span></a> +</span><span id="Generator-272"><a href="#Generator-272"><span class="linenos"> 272</span></a> <span class="n">can_identify</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span><span class="p">],</span> <span class="nb">bool</span><span class="p">]</span> +</span><span id="Generator-273"><a href="#Generator-273"><span class="linenos"> 273</span></a> +</span><span id="Generator-274"><a href="#Generator-274"><span class="linenos"> 274</span></a> <span class="c1"># Delimiters for quotes, identifiers and the corresponding escape characters</span> +</span><span id="Generator-275"><a href="#Generator-275"><span class="linenos"> 275</span></a> <span class="n">QUOTE_START</span> <span class="o">=</span> <span class="s2">"'"</span> +</span><span id="Generator-276"><a href="#Generator-276"><span class="linenos"> 276</span></a> <span class="n">QUOTE_END</span> <span class="o">=</span> <span class="s2">"'"</span> +</span><span id="Generator-277"><a href="#Generator-277"><span class="linenos"> 277</span></a> <span class="n">IDENTIFIER_START</span> <span class="o">=</span> <span class="s1">'"'</span> +</span><span id="Generator-278"><a href="#Generator-278"><span class="linenos"> 278</span></a> <span class="n">IDENTIFIER_END</span> <span class="o">=</span> <span class="s1">'"'</span> +</span><span id="Generator-279"><a href="#Generator-279"><span class="linenos"> 279</span></a> <span class="n">STRING_ESCAPE</span> <span class="o">=</span> <span class="s2">"'"</span> +</span><span id="Generator-280"><a href="#Generator-280"><span class="linenos"> 280</span></a> <span class="n">IDENTIFIER_ESCAPE</span> <span class="o">=</span> <span class="s1">'"'</span> +</span><span id="Generator-281"><a href="#Generator-281"><span class="linenos"> 281</span></a> +</span><span id="Generator-282"><a href="#Generator-282"><span class="linenos"> 282</span></a> <span class="c1"># Delimiters for bit, hex, byte and raw literals</span> +</span><span id="Generator-283"><a href="#Generator-283"><span class="linenos"> 283</span></a> <span class="n">BIT_START</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><span id="Generator-284"><a href="#Generator-284"><span class="linenos"> 284</span></a> <span class="n">BIT_END</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><span id="Generator-285"><a href="#Generator-285"><span class="linenos"> 285</span></a> <span class="n">HEX_START</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><span id="Generator-286"><a href="#Generator-286"><span class="linenos"> 286</span></a> <span class="n">HEX_END</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><span id="Generator-287"><a href="#Generator-287"><span class="linenos"> 287</span></a> <span class="n">BYTE_START</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><span id="Generator-288"><a href="#Generator-288"><span class="linenos"> 288</span></a> <span class="n">BYTE_END</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><span id="Generator-289"><a href="#Generator-289"><span class="linenos"> 289</span></a> <span class="n">RAW_START</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><span id="Generator-290"><a href="#Generator-290"><span class="linenos"> 290</span></a> <span class="n">RAW_END</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><span id="Generator-291"><a href="#Generator-291"><span class="linenos"> 291</span></a> +</span><span id="Generator-292"><a href="#Generator-292"><span class="linenos"> 292</span></a> <span class="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-293"><a href="#Generator-293"><span class="linenos"> 293</span></a> <span class="s2">"pretty"</span><span class="p">,</span> +</span><span id="Generator-294"><a href="#Generator-294"><span class="linenos"> 294</span></a> <span class="s2">"identify"</span><span class="p">,</span> +</span><span id="Generator-295"><a href="#Generator-295"><span class="linenos"> 295</span></a> <span class="s2">"normalize"</span><span class="p">,</span> +</span><span id="Generator-296"><a href="#Generator-296"><span class="linenos"> 296</span></a> <span class="s2">"pad"</span><span class="p">,</span> +</span><span id="Generator-297"><a href="#Generator-297"><span class="linenos"> 297</span></a> <span class="s2">"_indent"</span><span class="p">,</span> +</span><span id="Generator-298"><a href="#Generator-298"><span class="linenos"> 298</span></a> <span class="s2">"normalize_functions"</span><span class="p">,</span> +</span><span id="Generator-299"><a href="#Generator-299"><span class="linenos"> 299</span></a> <span class="s2">"unsupported_level"</span><span class="p">,</span> +</span><span id="Generator-300"><a href="#Generator-300"><span class="linenos"> 300</span></a> <span class="s2">"max_unsupported"</span><span class="p">,</span> +</span><span id="Generator-301"><a href="#Generator-301"><span class="linenos"> 301</span></a> <span class="s2">"leading_comma"</span><span class="p">,</span> +</span><span id="Generator-302"><a href="#Generator-302"><span class="linenos"> 302</span></a> <span class="s2">"max_text_width"</span><span class="p">,</span> +</span><span id="Generator-303"><a href="#Generator-303"><span class="linenos"> 303</span></a> <span class="s2">"comments"</span><span class="p">,</span> +</span><span id="Generator-304"><a href="#Generator-304"><span class="linenos"> 304</span></a> <span class="s2">"unsupported_messages"</span><span class="p">,</span> +</span><span id="Generator-305"><a href="#Generator-305"><span class="linenos"> 305</span></a> <span class="s2">"_escaped_quote_end"</span><span class="p">,</span> +</span><span id="Generator-306"><a href="#Generator-306"><span class="linenos"> 306</span></a> <span class="s2">"_escaped_identifier_end"</span><span class="p">,</span> +</span><span id="Generator-307"><a href="#Generator-307"><span class="linenos"> 307</span></a> <span class="s2">"_cache"</span><span class="p">,</span> +</span><span id="Generator-308"><a href="#Generator-308"><span class="linenos"> 308</span></a> <span class="p">)</span> +</span><span id="Generator-309"><a href="#Generator-309"><span class="linenos"> 309</span></a> +</span><span id="Generator-310"><a href="#Generator-310"><span class="linenos"> 310</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> +</span><span id="Generator-311"><a href="#Generator-311"><span class="linenos"> 311</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator-312"><a href="#Generator-312"><span class="linenos"> 312</span></a> <span class="n">pretty</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-313"><a href="#Generator-313"><span class="linenos"> 313</span></a> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Generator-314"><a href="#Generator-314"><span class="linenos"> 314</span></a> <span class="n">normalize</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Generator-315"><a href="#Generator-315"><span class="linenos"> 315</span></a> <span class="n">pad</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> +</span><span id="Generator-316"><a href="#Generator-316"><span class="linenos"> 316</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> +</span><span id="Generator-317"><a href="#Generator-317"><span class="linenos"> 317</span></a> <span class="n">normalize_functions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-318"><a href="#Generator-318"><span class="linenos"> 318</span></a> <span class="n">unsupported_level</span><span class="p">:</span> <span class="n">ErrorLevel</span> <span class="o">=</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">,</span> +</span><span id="Generator-319"><a href="#Generator-319"><span class="linenos"> 319</span></a> <span class="n">max_unsupported</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> +</span><span id="Generator-320"><a href="#Generator-320"><span class="linenos"> 320</span></a> <span class="n">leading_comma</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Generator-321"><a href="#Generator-321"><span class="linenos"> 321</span></a> <span class="n">max_text_width</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">80</span><span class="p">,</span> +</span><span id="Generator-322"><a href="#Generator-322"><span class="linenos"> 322</span></a> <span class="n">comments</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Generator-323"><a href="#Generator-323"><span class="linenos"> 323</span></a> <span class="p">):</span> +</span><span id="Generator-324"><a href="#Generator-324"><span class="linenos"> 324</span></a> <span class="kn">import</span> <span class="nn">sqlglot</span> +</span><span id="Generator-325"><a href="#Generator-325"><span class="linenos"> 325</span></a> +</span><span id="Generator-326"><a href="#Generator-326"><span class="linenos"> 326</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="o">=</span> <span class="n">pretty</span> <span class="k">if</span> <span class="n">pretty</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">pretty</span> +</span><span id="Generator-327"><a href="#Generator-327"><span class="linenos"> 327</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">identify</span> +</span><span id="Generator-328"><a href="#Generator-328"><span class="linenos"> 328</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="o">=</span> <span class="n">normalize</span> +</span><span id="Generator-329"><a href="#Generator-329"><span class="linenos"> 329</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="o">=</span> <span class="n">pad</span> +</span><span id="Generator-330"><a href="#Generator-330"><span class="linenos"> 330</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_indent</span> <span class="o">=</span> <span class="n">indent</span> +</span><span id="Generator-331"><a href="#Generator-331"><span class="linenos"> 331</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">=</span> <span class="n">unsupported_level</span> +</span><span id="Generator-332"><a href="#Generator-332"><span class="linenos"> 332</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span> <span class="o">=</span> <span class="n">max_unsupported</span> +</span><span id="Generator-333"><a href="#Generator-333"><span class="linenos"> 333</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span> <span class="o">=</span> <span class="n">leading_comma</span> +</span><span id="Generator-334"><a href="#Generator-334"><span class="linenos"> 334</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="o">=</span> <span class="n">max_text_width</span> +</span><span id="Generator-335"><a href="#Generator-335"><span class="linenos"> 335</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> +</span><span id="Generator-336"><a href="#Generator-336"><span class="linenos"> 336</span></a> +</span><span id="Generator-337"><a href="#Generator-337"><span class="linenos"> 337</span></a> <span class="c1"># This is both a Dialect property and a Generator argument, so we prioritize the latter</span> +</span><span id="Generator-338"><a href="#Generator-338"><span class="linenos"> 338</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-339"><a href="#Generator-339"><span class="linenos"> 339</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">NORMALIZE_FUNCTIONS</span> <span class="k">if</span> <span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">normalize_functions</span> +</span><span id="Generator-340"><a href="#Generator-340"><span class="linenos"> 340</span></a> <span class="p">)</span> +</span><span id="Generator-341"><a href="#Generator-341"><span class="linenos"> 341</span></a> +</span><span id="Generator-342"><a href="#Generator-342"><span class="linenos"> 342</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator-343"><a href="#Generator-343"><span class="linenos"> 343</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRING_ESCAPE</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span> +</span><span id="Generator-344"><a href="#Generator-344"><span class="linenos"> 344</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_ESCAPE</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_END</span> +</span><span id="Generator-345"><a href="#Generator-345"><span class="linenos"> 345</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Generator-346"><a href="#Generator-346"><span class="linenos"> 346</span></a> +</span><span id="Generator-347"><a href="#Generator-347"><span class="linenos"> 347</span></a> <span class="k">def</span> <span class="nf">generate</span><span class="p">(</span> +</span><span id="Generator-348"><a href="#Generator-348"><span class="linenos"> 348</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator-349"><a href="#Generator-349"><span class="linenos"> 349</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> +</span><span id="Generator-350"><a href="#Generator-350"><span class="linenos"> 350</span></a> <span class="n">cache</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-351"><a href="#Generator-351"><span class="linenos"> 351</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-352"><a href="#Generator-352"><span class="linenos"> 352</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Generator-353"><a href="#Generator-353"><span class="linenos"> 353</span></a><span class="sd"> Generates the SQL string corresponding to the given syntax tree.</span> +</span><span id="Generator-354"><a href="#Generator-354"><span class="linenos"> 354</span></a> +</span><span id="Generator-355"><a href="#Generator-355"><span class="linenos"> 355</span></a><span class="sd"> Args:</span> +</span><span id="Generator-356"><a href="#Generator-356"><span class="linenos"> 356</span></a><span class="sd"> expression: The syntax tree.</span> +</span><span id="Generator-357"><a href="#Generator-357"><span class="linenos"> 357</span></a><span class="sd"> cache: An optional sql string cache. This leverages the hash of an Expression</span> +</span><span id="Generator-358"><a href="#Generator-358"><span class="linenos"> 358</span></a><span class="sd"> which can be slow to compute, so only use it if you set _hash on each node.</span> +</span><span id="Generator-359"><a href="#Generator-359"><span class="linenos"> 359</span></a> +</span><span id="Generator-360"><a href="#Generator-360"><span class="linenos"> 360</span></a><span class="sd"> Returns:</span> +</span><span id="Generator-361"><a href="#Generator-361"><span class="linenos"> 361</span></a><span class="sd"> The SQL string corresponding to `expression`.</span> +</span><span id="Generator-362"><a href="#Generator-362"><span class="linenos"> 362</span></a><span class="sd"> """</span> +</span><span id="Generator-363"><a href="#Generator-363"><span class="linenos"> 363</span></a> <span class="k">if</span> <span class="n">cache</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-364"><a href="#Generator-364"><span class="linenos"> 364</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="o">=</span> <span class="n">cache</span> </span><span id="Generator-365"><a href="#Generator-365"><span class="linenos"> 365</span></a> -</span><span id="Generator-366"><a href="#Generator-366"><span class="linenos"> 366</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">:</span> -</span><span id="Generator-367"><a href="#Generator-367"><span class="linenos"> 367</span></a> <span class="k">for</span> <span class="n">msg</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> -</span><span id="Generator-368"><a href="#Generator-368"><span class="linenos"> 368</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> -</span><span id="Generator-369"><a href="#Generator-369"><span class="linenos"> 369</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">RAISE</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> -</span><span id="Generator-370"><a href="#Generator-370"><span class="linenos"> 370</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">concat_messages</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span><span class="p">))</span> -</span><span id="Generator-371"><a href="#Generator-371"><span class="linenos"> 371</span></a> -</span><span id="Generator-372"><a href="#Generator-372"><span class="linenos"> 372</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="Generator-373"><a href="#Generator-373"><span class="linenos"> 373</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">,</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-374"><a href="#Generator-374"><span class="linenos"> 374</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="Generator-375"><a href="#Generator-375"><span class="linenos"> 375</span></a> -</span><span id="Generator-376"><a href="#Generator-376"><span class="linenos"> 376</span></a> <span class="k">def</span> <span class="nf">unsupported</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-377"><a href="#Generator-377"><span class="linenos"> 377</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span><span class="p">:</span> -</span><span id="Generator-378"><a href="#Generator-378"><span class="linenos"> 378</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> -</span><span id="Generator-379"><a href="#Generator-379"><span class="linenos"> 379</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> -</span><span id="Generator-380"><a href="#Generator-380"><span class="linenos"> 380</span></a> -</span><span id="Generator-381"><a href="#Generator-381"><span class="linenos"> 381</span></a> <span class="k">def</span> <span class="nf">sep</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-382"><a href="#Generator-382"><span class="linenos"> 382</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="n">sep</span> -</span><span id="Generator-383"><a href="#Generator-383"><span class="linenos"> 383</span></a> -</span><span id="Generator-384"><a href="#Generator-384"><span class="linenos"> 384</span></a> <span class="k">def</span> <span class="nf">seg</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-385"><a href="#Generator-385"><span class="linenos"> 385</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-386"><a href="#Generator-386"><span class="linenos"> 386</span></a> -</span><span id="Generator-387"><a href="#Generator-387"><span class="linenos"> 387</span></a> <span class="k">def</span> <span class="nf">pad_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">comment</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-388"><a href="#Generator-388"><span class="linenos"> 388</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">+</span> <span class="n">comment</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> -</span><span id="Generator-389"><a href="#Generator-389"><span class="linenos"> 389</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="n">comment</span> <span class="o">+</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> -</span><span id="Generator-390"><a href="#Generator-390"><span class="linenos"> 390</span></a> <span class="k">return</span> <span class="n">comment</span> -</span><span id="Generator-391"><a href="#Generator-391"><span class="linenos"> 391</span></a> -</span><span id="Generator-392"><a href="#Generator-392"><span class="linenos"> 392</span></a> <span class="k">def</span> <span class="nf">maybe_comment</span><span class="p">(</span> -</span><span id="Generator-393"><a href="#Generator-393"><span class="linenos"> 393</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator-394"><a href="#Generator-394"><span class="linenos"> 394</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="Generator-395"><a href="#Generator-395"><span class="linenos"> 395</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-396"><a href="#Generator-396"><span class="linenos"> 396</span></a> <span class="n">comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-397"><a href="#Generator-397"><span class="linenos"> 397</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-398"><a href="#Generator-398"><span class="linenos"> 398</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-399"><a href="#Generator-399"><span class="linenos"> 399</span></a> <span class="p">((</span><span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> <span class="k">if</span> <span class="n">comments</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">comments</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="Generator-400"><a href="#Generator-400"><span class="linenos"> 400</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> -</span><span id="Generator-401"><a href="#Generator-401"><span class="linenos"> 401</span></a> <span class="k">else</span> <span class="kc">None</span> -</span><span id="Generator-402"><a href="#Generator-402"><span class="linenos"> 402</span></a> <span class="p">)</span> -</span><span id="Generator-403"><a href="#Generator-403"><span class="linenos"> 403</span></a> -</span><span id="Generator-404"><a href="#Generator-404"><span class="linenos"> 404</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="Generator-405"><a href="#Generator-405"><span class="linenos"> 405</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="Generator-406"><a href="#Generator-406"><span class="linenos"> 406</span></a> -</span><span id="Generator-407"><a href="#Generator-407"><span class="linenos"> 407</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator-408"><a href="#Generator-408"><span class="linenos"> 408</span></a> <span class="n">comments_sql</span> <span class="o">=</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator-409"><a href="#Generator-409"><span class="linenos"> 409</span></a> <span class="sa">f</span><span class="s2">"/*</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">pad_comment</span><span class="p">(</span><span class="n">comment</span><span class="p">)</span><span class="si">}</span><span class="s2">*/"</span> <span class="k">for</span> <span class="n">comment</span> <span class="ow">in</span> <span class="n">comments</span> <span class="k">if</span> <span class="n">comment</span> -</span><span id="Generator-410"><a href="#Generator-410"><span class="linenos"> 410</span></a> <span class="p">)</span> -</span><span id="Generator-411"><a href="#Generator-411"><span class="linenos"> 411</span></a> -</span><span id="Generator-412"><a href="#Generator-412"><span class="linenos"> 412</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments_sql</span><span class="p">:</span> -</span><span id="Generator-413"><a href="#Generator-413"><span class="linenos"> 413</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="Generator-414"><a href="#Generator-414"><span class="linenos"> 414</span></a> -</span><span id="Generator-415"><a href="#Generator-415"><span class="linenos"> 415</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">):</span> -</span><span id="Generator-416"><a href="#Generator-416"><span class="linenos"> 416</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="Generator-417"><a href="#Generator-417"><span class="linenos"> 417</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">comments_sql</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-418"><a href="#Generator-418"><span class="linenos"> 418</span></a> <span class="k">if</span> <span class="n">sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">isspace</span><span class="p">()</span> -</span><span id="Generator-419"><a href="#Generator-419"><span class="linenos"> 419</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">comments_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-420"><a href="#Generator-420"><span class="linenos"> 420</span></a> <span class="p">)</span> +</span><span id="Generator-366"><a href="#Generator-366"><span class="linenos"> 366</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator-367"><a href="#Generator-367"><span class="linenos"> 367</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="Generator-368"><a href="#Generator-368"><span class="linenos"> 368</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Generator-369"><a href="#Generator-369"><span class="linenos"> 369</span></a> +</span><span id="Generator-370"><a href="#Generator-370"><span class="linenos"> 370</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IGNORE</span><span class="p">:</span> +</span><span id="Generator-371"><a href="#Generator-371"><span class="linenos"> 371</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator-372"><a href="#Generator-372"><span class="linenos"> 372</span></a> +</span><span id="Generator-373"><a href="#Generator-373"><span class="linenos"> 373</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">:</span> +</span><span id="Generator-374"><a href="#Generator-374"><span class="linenos"> 374</span></a> <span class="k">for</span> <span class="n">msg</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> +</span><span id="Generator-375"><a href="#Generator-375"><span class="linenos"> 375</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> +</span><span id="Generator-376"><a href="#Generator-376"><span class="linenos"> 376</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">RAISE</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> +</span><span id="Generator-377"><a href="#Generator-377"><span class="linenos"> 377</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">concat_messages</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span><span class="p">))</span> +</span><span id="Generator-378"><a href="#Generator-378"><span class="linenos"> 378</span></a> +</span><span id="Generator-379"><a href="#Generator-379"><span class="linenos"> 379</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="Generator-380"><a href="#Generator-380"><span class="linenos"> 380</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">,</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-381"><a href="#Generator-381"><span class="linenos"> 381</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator-382"><a href="#Generator-382"><span class="linenos"> 382</span></a> +</span><span id="Generator-383"><a href="#Generator-383"><span class="linenos"> 383</span></a> <span class="k">def</span> <span class="nf">unsupported</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-384"><a href="#Generator-384"><span class="linenos"> 384</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span><span class="p">:</span> +</span><span id="Generator-385"><a href="#Generator-385"><span class="linenos"> 385</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> +</span><span id="Generator-386"><a href="#Generator-386"><span class="linenos"> 386</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> +</span><span id="Generator-387"><a href="#Generator-387"><span class="linenos"> 387</span></a> +</span><span id="Generator-388"><a href="#Generator-388"><span class="linenos"> 388</span></a> <span class="k">def</span> <span class="nf">sep</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-389"><a href="#Generator-389"><span class="linenos"> 389</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="n">sep</span> +</span><span id="Generator-390"><a href="#Generator-390"><span class="linenos"> 390</span></a> +</span><span id="Generator-391"><a href="#Generator-391"><span class="linenos"> 391</span></a> <span class="k">def</span> <span class="nf">seg</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-392"><a href="#Generator-392"><span class="linenos"> 392</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-393"><a href="#Generator-393"><span class="linenos"> 393</span></a> +</span><span id="Generator-394"><a href="#Generator-394"><span class="linenos"> 394</span></a> <span class="k">def</span> <span class="nf">pad_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">comment</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-395"><a href="#Generator-395"><span class="linenos"> 395</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">+</span> <span class="n">comment</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> +</span><span id="Generator-396"><a href="#Generator-396"><span class="linenos"> 396</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="n">comment</span> <span class="o">+</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> +</span><span id="Generator-397"><a href="#Generator-397"><span class="linenos"> 397</span></a> <span class="k">return</span> <span class="n">comment</span> +</span><span id="Generator-398"><a href="#Generator-398"><span class="linenos"> 398</span></a> +</span><span id="Generator-399"><a href="#Generator-399"><span class="linenos"> 399</span></a> <span class="k">def</span> <span class="nf">maybe_comment</span><span class="p">(</span> +</span><span id="Generator-400"><a href="#Generator-400"><span class="linenos"> 400</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator-401"><a href="#Generator-401"><span class="linenos"> 401</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="Generator-402"><a href="#Generator-402"><span class="linenos"> 402</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-403"><a href="#Generator-403"><span class="linenos"> 403</span></a> <span class="n">comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-404"><a href="#Generator-404"><span class="linenos"> 404</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-405"><a href="#Generator-405"><span class="linenos"> 405</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-406"><a href="#Generator-406"><span class="linenos"> 406</span></a> <span class="p">((</span><span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> <span class="k">if</span> <span class="n">comments</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">comments</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="Generator-407"><a href="#Generator-407"><span class="linenos"> 407</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> +</span><span id="Generator-408"><a href="#Generator-408"><span class="linenos"> 408</span></a> <span class="k">else</span> <span class="kc">None</span> +</span><span id="Generator-409"><a href="#Generator-409"><span class="linenos"> 409</span></a> <span class="p">)</span> +</span><span id="Generator-410"><a href="#Generator-410"><span class="linenos"> 410</span></a> +</span><span id="Generator-411"><a href="#Generator-411"><span class="linenos"> 411</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="Generator-412"><a href="#Generator-412"><span class="linenos"> 412</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator-413"><a href="#Generator-413"><span class="linenos"> 413</span></a> +</span><span id="Generator-414"><a href="#Generator-414"><span class="linenos"> 414</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator-415"><a href="#Generator-415"><span class="linenos"> 415</span></a> <span class="n">comments_sql</span> <span class="o">=</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator-416"><a href="#Generator-416"><span class="linenos"> 416</span></a> <span class="sa">f</span><span class="s2">"/*</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">pad_comment</span><span class="p">(</span><span class="n">comment</span><span class="p">)</span><span class="si">}</span><span class="s2">*/"</span> <span class="k">for</span> <span class="n">comment</span> <span class="ow">in</span> <span class="n">comments</span> <span class="k">if</span> <span class="n">comment</span> +</span><span id="Generator-417"><a href="#Generator-417"><span class="linenos"> 417</span></a> <span class="p">)</span> +</span><span id="Generator-418"><a href="#Generator-418"><span class="linenos"> 418</span></a> +</span><span id="Generator-419"><a href="#Generator-419"><span class="linenos"> 419</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments_sql</span><span class="p">:</span> +</span><span id="Generator-420"><a href="#Generator-420"><span class="linenos"> 420</span></a> <span class="k">return</span> <span class="n">sql</span> </span><span id="Generator-421"><a href="#Generator-421"><span class="linenos"> 421</span></a> -</span><span id="Generator-422"><a href="#Generator-422"><span class="linenos"> 422</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">comments_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-423"><a href="#Generator-423"><span class="linenos"> 423</span></a> -</span><span id="Generator-424"><a href="#Generator-424"><span class="linenos"> 424</span></a> <span class="k">def</span> <span class="nf">wrap</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">|</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-425"><a href="#Generator-425"><span class="linenos"> 425</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span> -</span><span id="Generator-426"><a href="#Generator-426"><span class="linenos"> 426</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-427"><a href="#Generator-427"><span class="linenos"> 427</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">))</span> -</span><span id="Generator-428"><a href="#Generator-428"><span class="linenos"> 428</span></a> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> -</span><span id="Generator-429"><a href="#Generator-429"><span class="linenos"> 429</span></a> <span class="n">level</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> -</span><span id="Generator-430"><a href="#Generator-430"><span class="linenos"> 430</span></a> <span class="n">pad</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> -</span><span id="Generator-431"><a href="#Generator-431"><span class="linenos"> 431</span></a> <span class="p">)</span> -</span><span id="Generator-432"><a href="#Generator-432"><span class="linenos"> 432</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">this_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-433"><a href="#Generator-433"><span class="linenos"> 433</span></a> -</span><span id="Generator-434"><a href="#Generator-434"><span class="linenos"> 434</span></a> <span class="k">def</span> <span class="nf">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">func</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-435"><a href="#Generator-435"><span class="linenos"> 435</span></a> <span class="n">original</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> -</span><span id="Generator-436"><a href="#Generator-436"><span class="linenos"> 436</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Generator-437"><a href="#Generator-437"><span class="linenos"> 437</span></a> <span class="n">result</span> <span class="o">=</span> <span class="n">func</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="Generator-438"><a href="#Generator-438"><span class="linenos"> 438</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">original</span> -</span><span id="Generator-439"><a href="#Generator-439"><span class="linenos"> 439</span></a> <span class="k">return</span> <span class="n">result</span> +</span><span id="Generator-422"><a href="#Generator-422"><span class="linenos"> 422</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">):</span> +</span><span id="Generator-423"><a href="#Generator-423"><span class="linenos"> 423</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="Generator-424"><a href="#Generator-424"><span class="linenos"> 424</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">comments_sql</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-425"><a href="#Generator-425"><span class="linenos"> 425</span></a> <span class="k">if</span> <span class="n">sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">isspace</span><span class="p">()</span> +</span><span id="Generator-426"><a href="#Generator-426"><span class="linenos"> 426</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">comments_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-427"><a href="#Generator-427"><span class="linenos"> 427</span></a> <span class="p">)</span> +</span><span id="Generator-428"><a href="#Generator-428"><span class="linenos"> 428</span></a> +</span><span id="Generator-429"><a href="#Generator-429"><span class="linenos"> 429</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">comments_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-430"><a href="#Generator-430"><span class="linenos"> 430</span></a> +</span><span id="Generator-431"><a href="#Generator-431"><span class="linenos"> 431</span></a> <span class="k">def</span> <span class="nf">wrap</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">|</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-432"><a href="#Generator-432"><span class="linenos"> 432</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span> +</span><span id="Generator-433"><a href="#Generator-433"><span class="linenos"> 433</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-434"><a href="#Generator-434"><span class="linenos"> 434</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">))</span> +</span><span id="Generator-435"><a href="#Generator-435"><span class="linenos"> 435</span></a> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> +</span><span id="Generator-436"><a href="#Generator-436"><span class="linenos"> 436</span></a> <span class="n">level</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> +</span><span id="Generator-437"><a href="#Generator-437"><span class="linenos"> 437</span></a> <span class="n">pad</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> +</span><span id="Generator-438"><a href="#Generator-438"><span class="linenos"> 438</span></a> <span class="p">)</span> +</span><span id="Generator-439"><a href="#Generator-439"><span class="linenos"> 439</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">this_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-440"><a href="#Generator-440"><span class="linenos"> 440</span></a> -</span><span id="Generator-441"><a href="#Generator-441"><span class="linenos"> 441</span></a> <span class="k">def</span> <span class="nf">normalize_func</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-442"><a href="#Generator-442"><span class="linenos"> 442</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"upper"</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Generator-443"><a href="#Generator-443"><span class="linenos"> 443</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Generator-444"><a href="#Generator-444"><span class="linenos"> 444</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"lower"</span><span class="p">:</span> -</span><span id="Generator-445"><a href="#Generator-445"><span class="linenos"> 445</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="Generator-446"><a href="#Generator-446"><span class="linenos"> 446</span></a> <span class="k">return</span> <span class="n">name</span> +</span><span id="Generator-441"><a href="#Generator-441"><span class="linenos"> 441</span></a> <span class="k">def</span> <span class="nf">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">func</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-442"><a href="#Generator-442"><span class="linenos"> 442</span></a> <span class="n">original</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> +</span><span id="Generator-443"><a href="#Generator-443"><span class="linenos"> 443</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Generator-444"><a href="#Generator-444"><span class="linenos"> 444</span></a> <span class="n">result</span> <span class="o">=</span> <span class="n">func</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="Generator-445"><a href="#Generator-445"><span class="linenos"> 445</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">original</span> +</span><span id="Generator-446"><a href="#Generator-446"><span class="linenos"> 446</span></a> <span class="k">return</span> <span class="n">result</span> </span><span id="Generator-447"><a href="#Generator-447"><span class="linenos"> 447</span></a> -</span><span id="Generator-448"><a href="#Generator-448"><span class="linenos"> 448</span></a> <span class="k">def</span> <span class="nf">indent</span><span class="p">(</span> -</span><span id="Generator-449"><a href="#Generator-449"><span class="linenos"> 449</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator-450"><a href="#Generator-450"><span class="linenos"> 450</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="Generator-451"><a href="#Generator-451"><span class="linenos"> 451</span></a> <span class="n">level</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> -</span><span id="Generator-452"><a href="#Generator-452"><span class="linenos"> 452</span></a> <span class="n">pad</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-453"><a href="#Generator-453"><span class="linenos"> 453</span></a> <span class="n">skip_first</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Generator-454"><a href="#Generator-454"><span class="linenos"> 454</span></a> <span class="n">skip_last</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Generator-455"><a href="#Generator-455"><span class="linenos"> 455</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-456"><a href="#Generator-456"><span class="linenos"> 456</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="Generator-457"><a href="#Generator-457"><span class="linenos"> 457</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="Generator-458"><a href="#Generator-458"><span class="linenos"> 458</span></a> -</span><span id="Generator-459"><a href="#Generator-459"><span class="linenos"> 459</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="k">if</span> <span class="n">pad</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">pad</span> -</span><span id="Generator-460"><a href="#Generator-460"><span class="linenos"> 460</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-461"><a href="#Generator-461"><span class="linenos"> 461</span></a> -</span><span id="Generator-462"><a href="#Generator-462"><span class="linenos"> 462</span></a> <span class="k">return</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator-463"><a href="#Generator-463"><span class="linenos"> 463</span></a> <span class="n">line</span> -</span><span id="Generator-464"><a href="#Generator-464"><span class="linenos"> 464</span></a> <span class="k">if</span> <span class="p">(</span><span class="n">skip_first</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">skip_last</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="Generator-465"><a href="#Generator-465"><span class="linenos"> 465</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' '</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="n">level</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="bp">self</span><span class="o">.</span><span class="n">_indent</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">pad</span><span class="p">)</span><span class="si">}{</span><span class="n">line</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-466"><a href="#Generator-466"><span class="linenos"> 466</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">line</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> -</span><span id="Generator-467"><a href="#Generator-467"><span class="linenos"> 467</span></a> <span class="p">)</span> +</span><span id="Generator-448"><a href="#Generator-448"><span class="linenos"> 448</span></a> <span class="k">def</span> <span class="nf">normalize_func</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-449"><a href="#Generator-449"><span class="linenos"> 449</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"upper"</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Generator-450"><a href="#Generator-450"><span class="linenos"> 450</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Generator-451"><a href="#Generator-451"><span class="linenos"> 451</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"lower"</span><span class="p">:</span> +</span><span id="Generator-452"><a href="#Generator-452"><span class="linenos"> 452</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> +</span><span id="Generator-453"><a href="#Generator-453"><span class="linenos"> 453</span></a> <span class="k">return</span> <span class="n">name</span> +</span><span id="Generator-454"><a href="#Generator-454"><span class="linenos"> 454</span></a> +</span><span id="Generator-455"><a href="#Generator-455"><span class="linenos"> 455</span></a> <span class="k">def</span> <span class="nf">indent</span><span class="p">(</span> +</span><span id="Generator-456"><a href="#Generator-456"><span class="linenos"> 456</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator-457"><a href="#Generator-457"><span class="linenos"> 457</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="Generator-458"><a href="#Generator-458"><span class="linenos"> 458</span></a> <span class="n">level</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> +</span><span id="Generator-459"><a href="#Generator-459"><span class="linenos"> 459</span></a> <span class="n">pad</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-460"><a href="#Generator-460"><span class="linenos"> 460</span></a> <span class="n">skip_first</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Generator-461"><a href="#Generator-461"><span class="linenos"> 461</span></a> <span class="n">skip_last</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Generator-462"><a href="#Generator-462"><span class="linenos"> 462</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-463"><a href="#Generator-463"><span class="linenos"> 463</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="Generator-464"><a href="#Generator-464"><span class="linenos"> 464</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator-465"><a href="#Generator-465"><span class="linenos"> 465</span></a> +</span><span id="Generator-466"><a href="#Generator-466"><span class="linenos"> 466</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="k">if</span> <span class="n">pad</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">pad</span> +</span><span id="Generator-467"><a href="#Generator-467"><span class="linenos"> 467</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> </span><span id="Generator-468"><a href="#Generator-468"><span class="linenos"> 468</span></a> -</span><span id="Generator-469"><a href="#Generator-469"><span class="linenos"> 469</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span> -</span><span id="Generator-470"><a href="#Generator-470"><span class="linenos"> 470</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator-471"><a href="#Generator-471"><span class="linenos"> 471</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> -</span><span id="Generator-472"><a href="#Generator-472"><span class="linenos"> 472</span></a> <span class="n">key</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-473"><a href="#Generator-473"><span class="linenos"> 473</span></a> <span class="n">comment</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Generator-474"><a href="#Generator-474"><span class="linenos"> 474</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-475"><a href="#Generator-475"><span class="linenos"> 475</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> -</span><span id="Generator-476"><a href="#Generator-476"><span class="linenos"> 476</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator-477"><a href="#Generator-477"><span class="linenos"> 477</span></a> -</span><span id="Generator-478"><a href="#Generator-478"><span class="linenos"> 478</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="Generator-479"><a href="#Generator-479"><span class="linenos"> 479</span></a> <span class="k">return</span> <span class="n">expression</span> -</span><span id="Generator-480"><a href="#Generator-480"><span class="linenos"> 480</span></a> -</span><span id="Generator-481"><a href="#Generator-481"><span class="linenos"> 481</span></a> <span class="k">if</span> <span class="n">key</span><span class="p">:</span> -</span><span id="Generator-482"><a href="#Generator-482"><span class="linenos"> 482</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="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">))</span> -</span><span id="Generator-483"><a href="#Generator-483"><span class="linenos"> 483</span></a> -</span><span id="Generator-484"><a href="#Generator-484"><span class="linenos"> 484</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-485"><a href="#Generator-485"><span class="linenos"> 485</span></a> <span class="n">expression_id</span> <span class="o">=</span> <span class="nb">hash</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-486"><a href="#Generator-486"><span class="linenos"> 486</span></a> -</span><span id="Generator-487"><a href="#Generator-487"><span class="linenos"> 487</span></a> <span class="k">if</span> <span class="n">expression_id</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">:</span> -</span><span id="Generator-488"><a href="#Generator-488"><span class="linenos"> 488</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">[</span><span class="n">expression_id</span><span class="p">]</span> -</span><span id="Generator-489"><a href="#Generator-489"><span class="linenos"> 489</span></a> -</span><span id="Generator-490"><a href="#Generator-490"><span class="linenos"> 490</span></a> <span class="n">transform</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span> -</span><span id="Generator-491"><a href="#Generator-491"><span class="linenos"> 491</span></a> -</span><span id="Generator-492"><a href="#Generator-492"><span class="linenos"> 492</span></a> <span class="k">if</span> <span class="nb">callable</span><span class="p">(</span><span class="n">transform</span><span class="p">):</span> -</span><span id="Generator-493"><a href="#Generator-493"><span class="linenos"> 493</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-494"><a href="#Generator-494"><span class="linenos"> 494</span></a> <span class="k">elif</span> <span class="n">transform</span><span class="p">:</span> -</span><span id="Generator-495"><a href="#Generator-495"><span class="linenos"> 495</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span> -</span><span id="Generator-496"><a href="#Generator-496"><span class="linenos"> 496</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Generator-497"><a href="#Generator-497"><span class="linenos"> 497</span></a> <span class="n">exp_handler_name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">_sql"</span> +</span><span id="Generator-469"><a href="#Generator-469"><span class="linenos"> 469</span></a> <span class="k">return</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator-470"><a href="#Generator-470"><span class="linenos"> 470</span></a> <span class="n">line</span> +</span><span id="Generator-471"><a href="#Generator-471"><span class="linenos"> 471</span></a> <span class="k">if</span> <span class="p">(</span><span class="n">skip_first</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">skip_last</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="Generator-472"><a href="#Generator-472"><span class="linenos"> 472</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' '</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="n">level</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="bp">self</span><span class="o">.</span><span class="n">_indent</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">pad</span><span class="p">)</span><span class="si">}{</span><span class="n">line</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-473"><a href="#Generator-473"><span class="linenos"> 473</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">line</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> +</span><span id="Generator-474"><a href="#Generator-474"><span class="linenos"> 474</span></a> <span class="p">)</span> +</span><span id="Generator-475"><a href="#Generator-475"><span class="linenos"> 475</span></a> +</span><span id="Generator-476"><a href="#Generator-476"><span class="linenos"> 476</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span> +</span><span id="Generator-477"><a href="#Generator-477"><span class="linenos"> 477</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator-478"><a href="#Generator-478"><span class="linenos"> 478</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> +</span><span id="Generator-479"><a href="#Generator-479"><span class="linenos"> 479</span></a> <span class="n">key</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-480"><a href="#Generator-480"><span class="linenos"> 480</span></a> <span class="n">comment</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Generator-481"><a href="#Generator-481"><span class="linenos"> 481</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-482"><a href="#Generator-482"><span class="linenos"> 482</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> +</span><span id="Generator-483"><a href="#Generator-483"><span class="linenos"> 483</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator-484"><a href="#Generator-484"><span class="linenos"> 484</span></a> +</span><span id="Generator-485"><a href="#Generator-485"><span class="linenos"> 485</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="Generator-486"><a href="#Generator-486"><span class="linenos"> 486</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="Generator-487"><a href="#Generator-487"><span class="linenos"> 487</span></a> +</span><span id="Generator-488"><a href="#Generator-488"><span class="linenos"> 488</span></a> <span class="k">if</span> <span class="n">key</span><span class="p">:</span> +</span><span id="Generator-489"><a href="#Generator-489"><span class="linenos"> 489</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="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">))</span> +</span><span id="Generator-490"><a href="#Generator-490"><span class="linenos"> 490</span></a> +</span><span id="Generator-491"><a href="#Generator-491"><span class="linenos"> 491</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-492"><a href="#Generator-492"><span class="linenos"> 492</span></a> <span class="n">expression_id</span> <span class="o">=</span> <span class="nb">hash</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-493"><a href="#Generator-493"><span class="linenos"> 493</span></a> +</span><span id="Generator-494"><a href="#Generator-494"><span class="linenos"> 494</span></a> <span class="k">if</span> <span class="n">expression_id</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">:</span> +</span><span id="Generator-495"><a href="#Generator-495"><span class="linenos"> 495</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">[</span><span class="n">expression_id</span><span class="p">]</span> +</span><span id="Generator-496"><a href="#Generator-496"><span class="linenos"> 496</span></a> +</span><span id="Generator-497"><a href="#Generator-497"><span class="linenos"> 497</span></a> <span class="n">transform</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span> </span><span id="Generator-498"><a href="#Generator-498"><span class="linenos"> 498</span></a> -</span><span id="Generator-499"><a href="#Generator-499"><span class="linenos"> 499</span></a> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">):</span> -</span><span id="Generator-500"><a href="#Generator-500"><span class="linenos"> 500</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">)(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-501"><a href="#Generator-501"><span class="linenos"> 501</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Generator-502"><a href="#Generator-502"><span class="linenos"> 502</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-503"><a href="#Generator-503"><span class="linenos"> 503</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">):</span> -</span><span id="Generator-504"><a href="#Generator-504"><span class="linenos"> 504</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">property_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-505"><a href="#Generator-505"><span class="linenos"> 505</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-506"><a href="#Generator-506"><span class="linenos"> 506</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported expression type </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-507"><a href="#Generator-507"><span class="linenos"> 507</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-508"><a href="#Generator-508"><span class="linenos"> 508</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Expected an Expression. Received </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">expression</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-509"><a href="#Generator-509"><span class="linenos"> 509</span></a> -</span><span id="Generator-510"><a href="#Generator-510"><span class="linenos"> 510</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">sql</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="ow">and</span> <span class="n">comment</span> <span class="k">else</span> <span class="n">sql</span> -</span><span id="Generator-511"><a href="#Generator-511"><span class="linenos"> 511</span></a> -</span><span id="Generator-512"><a href="#Generator-512"><span class="linenos"> 512</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-513"><a href="#Generator-513"><span class="linenos"> 513</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">[</span><span class="n">expression_id</span><span class="p">]</span> <span class="o">=</span> <span class="n">sql</span> -</span><span id="Generator-514"><a href="#Generator-514"><span class="linenos"> 514</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="Generator-515"><a href="#Generator-515"><span class="linenos"> 515</span></a> -</span><span id="Generator-516"><a href="#Generator-516"><span class="linenos"> 516</span></a> <span class="k">def</span> <span class="nf">uncache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Uncache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-517"><a href="#Generator-517"><span class="linenos"> 517</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-518"><a href="#Generator-518"><span class="linenos"> 518</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-519"><a href="#Generator-519"><span class="linenos"> 519</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNCACHE TABLE</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-520"><a href="#Generator-520"><span class="linenos"> 520</span></a> -</span><span id="Generator-521"><a href="#Generator-521"><span class="linenos"> 521</span></a> <span class="k">def</span> <span class="nf">cache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-522"><a href="#Generator-522"><span class="linenos"> 522</span></a> <span class="n">lazy</span> <span class="o">=</span> <span class="s2">" LAZY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lazy"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-523"><a href="#Generator-523"><span class="linenos"> 523</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-524"><a href="#Generator-524"><span class="linenos"> 524</span></a> <span class="n">options</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"options"</span><span class="p">)</span> -</span><span id="Generator-525"><a href="#Generator-525"><span class="linenos"> 525</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OPTIONS(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span><span class="si">}</span><span class="s2"> = </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-526"><a href="#Generator-526"><span class="linenos"> 526</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator-527"><a href="#Generator-527"><span class="linenos"> 527</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-528"><a href="#Generator-528"><span class="linenos"> 528</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CACHE</span><span class="si">{</span><span class="n">lazy</span><span class="si">}</span><span class="s2"> TABLE </span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">options</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-529"><a href="#Generator-529"><span class="linenos"> 529</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="Generator-530"><a href="#Generator-530"><span class="linenos"> 530</span></a> -</span><span id="Generator-531"><a href="#Generator-531"><span class="linenos"> 531</span></a> <span class="k">def</span> <span class="nf">characterset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSet</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-532"><a href="#Generator-532"><span class="linenos"> 532</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="Generator-533"><a href="#Generator-533"><span class="linenos"> 533</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHAR CHARACTER SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-534"><a href="#Generator-534"><span class="linenos"> 534</span></a> <span class="n">default</span> <span class="o">=</span> <span class="s2">"DEFAULT "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-535"><a href="#Generator-535"><span class="linenos"> 535</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">CHARACTER SET=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-536"><a href="#Generator-536"><span class="linenos"> 536</span></a> -</span><span id="Generator-537"><a href="#Generator-537"><span class="linenos"> 537</span></a> <span class="k">def</span> <span class="nf">column_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-538"><a href="#Generator-538"><span class="linenos"> 538</span></a> <span class="k">return</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator-539"><a href="#Generator-539"><span class="linenos"> 539</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> -</span><span id="Generator-540"><a href="#Generator-540"><span class="linenos"> 540</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="Generator-541"><a href="#Generator-541"><span class="linenos"> 541</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">),</span> -</span><span id="Generator-542"><a href="#Generator-542"><span class="linenos"> 542</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"db"</span><span class="p">),</span> -</span><span id="Generator-543"><a href="#Generator-543"><span class="linenos"> 543</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"table"</span><span class="p">),</span> -</span><span id="Generator-544"><a href="#Generator-544"><span class="linenos"> 544</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"this"</span><span class="p">),</span> -</span><span id="Generator-545"><a href="#Generator-545"><span class="linenos"> 545</span></a> <span class="p">)</span> -</span><span id="Generator-546"><a href="#Generator-546"><span class="linenos"> 546</span></a> <span class="k">if</span> <span class="n">part</span> -</span><span id="Generator-547"><a href="#Generator-547"><span class="linenos"> 547</span></a> <span class="p">)</span> -</span><span id="Generator-548"><a href="#Generator-548"><span class="linenos"> 548</span></a> -</span><span id="Generator-549"><a href="#Generator-549"><span class="linenos"> 549</span></a> <span class="k">def</span> <span class="nf">columnposition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-550"><a href="#Generator-550"><span class="linenos"> 550</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-551"><a href="#Generator-551"><span class="linenos"> 551</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-552"><a href="#Generator-552"><span class="linenos"> 552</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> -</span><span id="Generator-553"><a href="#Generator-553"><span class="linenos"> 553</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">position</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-554"><a href="#Generator-554"><span class="linenos"> 554</span></a> -</span><span id="Generator-555"><a href="#Generator-555"><span class="linenos"> 555</span></a> <span class="k">def</span> <span class="nf">columndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-556"><a href="#Generator-556"><span class="linenos"> 556</span></a> <span class="n">column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-557"><a href="#Generator-557"><span class="linenos"> 557</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator-558"><a href="#Generator-558"><span class="linenos"> 558</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"constraints"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-559"><a href="#Generator-559"><span class="linenos"> 559</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">"IF NOT EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-560"><a href="#Generator-560"><span class="linenos"> 560</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-561"><a href="#Generator-561"><span class="linenos"> 561</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">constraints</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">constraints</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-562"><a href="#Generator-562"><span class="linenos"> 562</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> -</span><span id="Generator-563"><a href="#Generator-563"><span class="linenos"> 563</span></a> <span class="n">position</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">position</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-564"><a href="#Generator-564"><span class="linenos"> 564</span></a> -</span><span id="Generator-565"><a href="#Generator-565"><span class="linenos"> 565</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">column</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-566"><a href="#Generator-566"><span class="linenos"> 566</span></a> -</span><span id="Generator-567"><a href="#Generator-567"><span class="linenos"> 567</span></a> <span class="k">def</span> <span class="nf">columnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-568"><a href="#Generator-568"><span class="linenos"> 568</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-569"><a href="#Generator-569"><span class="linenos"> 569</span></a> <span class="n">kind_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="Generator-570"><a href="#Generator-570"><span class="linenos"> 570</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="n">kind_sql</span> +</span><span id="Generator-499"><a href="#Generator-499"><span class="linenos"> 499</span></a> <span class="k">if</span> <span class="nb">callable</span><span class="p">(</span><span class="n">transform</span><span class="p">):</span> +</span><span id="Generator-500"><a href="#Generator-500"><span class="linenos"> 500</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-501"><a href="#Generator-501"><span class="linenos"> 501</span></a> <span class="k">elif</span> <span class="n">transform</span><span class="p">:</span> +</span><span id="Generator-502"><a href="#Generator-502"><span class="linenos"> 502</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span> +</span><span id="Generator-503"><a href="#Generator-503"><span class="linenos"> 503</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Generator-504"><a href="#Generator-504"><span class="linenos"> 504</span></a> <span class="n">exp_handler_name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">_sql"</span> +</span><span id="Generator-505"><a href="#Generator-505"><span class="linenos"> 505</span></a> +</span><span id="Generator-506"><a href="#Generator-506"><span class="linenos"> 506</span></a> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">):</span> +</span><span id="Generator-507"><a href="#Generator-507"><span class="linenos"> 507</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">)(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-508"><a href="#Generator-508"><span class="linenos"> 508</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Generator-509"><a href="#Generator-509"><span class="linenos"> 509</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-510"><a href="#Generator-510"><span class="linenos"> 510</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">):</span> +</span><span id="Generator-511"><a href="#Generator-511"><span class="linenos"> 511</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">property_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-512"><a href="#Generator-512"><span class="linenos"> 512</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-513"><a href="#Generator-513"><span class="linenos"> 513</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported expression type </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-514"><a href="#Generator-514"><span class="linenos"> 514</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-515"><a href="#Generator-515"><span class="linenos"> 515</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Expected an Expression. Received </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">expression</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-516"><a href="#Generator-516"><span class="linenos"> 516</span></a> +</span><span id="Generator-517"><a href="#Generator-517"><span class="linenos"> 517</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">sql</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="ow">and</span> <span class="n">comment</span> <span class="k">else</span> <span class="n">sql</span> +</span><span id="Generator-518"><a href="#Generator-518"><span class="linenos"> 518</span></a> +</span><span id="Generator-519"><a href="#Generator-519"><span class="linenos"> 519</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-520"><a href="#Generator-520"><span class="linenos"> 520</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">[</span><span class="n">expression_id</span><span class="p">]</span> <span class="o">=</span> <span class="n">sql</span> +</span><span id="Generator-521"><a href="#Generator-521"><span class="linenos"> 521</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator-522"><a href="#Generator-522"><span class="linenos"> 522</span></a> +</span><span id="Generator-523"><a href="#Generator-523"><span class="linenos"> 523</span></a> <span class="k">def</span> <span class="nf">uncache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Uncache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-524"><a href="#Generator-524"><span class="linenos"> 524</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-525"><a href="#Generator-525"><span class="linenos"> 525</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-526"><a href="#Generator-526"><span class="linenos"> 526</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNCACHE TABLE</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-527"><a href="#Generator-527"><span class="linenos"> 527</span></a> +</span><span id="Generator-528"><a href="#Generator-528"><span class="linenos"> 528</span></a> <span class="k">def</span> <span class="nf">cache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-529"><a href="#Generator-529"><span class="linenos"> 529</span></a> <span class="n">lazy</span> <span class="o">=</span> <span class="s2">" LAZY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lazy"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-530"><a href="#Generator-530"><span class="linenos"> 530</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-531"><a href="#Generator-531"><span class="linenos"> 531</span></a> <span class="n">options</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"options"</span><span class="p">)</span> +</span><span id="Generator-532"><a href="#Generator-532"><span class="linenos"> 532</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OPTIONS(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span><span class="si">}</span><span class="s2"> = </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-533"><a href="#Generator-533"><span class="linenos"> 533</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator-534"><a href="#Generator-534"><span class="linenos"> 534</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-535"><a href="#Generator-535"><span class="linenos"> 535</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CACHE</span><span class="si">{</span><span class="n">lazy</span><span class="si">}</span><span class="s2"> TABLE </span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">options</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-536"><a href="#Generator-536"><span class="linenos"> 536</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="Generator-537"><a href="#Generator-537"><span class="linenos"> 537</span></a> +</span><span id="Generator-538"><a href="#Generator-538"><span class="linenos"> 538</span></a> <span class="k">def</span> <span class="nf">characterset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSet</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-539"><a href="#Generator-539"><span class="linenos"> 539</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="Generator-540"><a href="#Generator-540"><span class="linenos"> 540</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHAR CHARACTER SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-541"><a href="#Generator-541"><span class="linenos"> 541</span></a> <span class="n">default</span> <span class="o">=</span> <span class="s2">"DEFAULT "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-542"><a href="#Generator-542"><span class="linenos"> 542</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">CHARACTER SET=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-543"><a href="#Generator-543"><span class="linenos"> 543</span></a> +</span><span id="Generator-544"><a href="#Generator-544"><span class="linenos"> 544</span></a> <span class="k">def</span> <span class="nf">column_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-545"><a href="#Generator-545"><span class="linenos"> 545</span></a> <span class="k">return</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator-546"><a href="#Generator-546"><span class="linenos"> 546</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> +</span><span id="Generator-547"><a href="#Generator-547"><span class="linenos"> 547</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="Generator-548"><a href="#Generator-548"><span class="linenos"> 548</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">),</span> +</span><span id="Generator-549"><a href="#Generator-549"><span class="linenos"> 549</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"db"</span><span class="p">),</span> +</span><span id="Generator-550"><a href="#Generator-550"><span class="linenos"> 550</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"table"</span><span class="p">),</span> +</span><span id="Generator-551"><a href="#Generator-551"><span class="linenos"> 551</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"this"</span><span class="p">),</span> +</span><span id="Generator-552"><a href="#Generator-552"><span class="linenos"> 552</span></a> <span class="p">)</span> +</span><span id="Generator-553"><a href="#Generator-553"><span class="linenos"> 553</span></a> <span class="k">if</span> <span class="n">part</span> +</span><span id="Generator-554"><a href="#Generator-554"><span class="linenos"> 554</span></a> <span class="p">)</span> +</span><span id="Generator-555"><a href="#Generator-555"><span class="linenos"> 555</span></a> +</span><span id="Generator-556"><a href="#Generator-556"><span class="linenos"> 556</span></a> <span class="k">def</span> <span class="nf">columnposition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-557"><a href="#Generator-557"><span class="linenos"> 557</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-558"><a href="#Generator-558"><span class="linenos"> 558</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-559"><a href="#Generator-559"><span class="linenos"> 559</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> +</span><span id="Generator-560"><a href="#Generator-560"><span class="linenos"> 560</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">position</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-561"><a href="#Generator-561"><span class="linenos"> 561</span></a> +</span><span id="Generator-562"><a href="#Generator-562"><span class="linenos"> 562</span></a> <span class="k">def</span> <span class="nf">columndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-563"><a href="#Generator-563"><span class="linenos"> 563</span></a> <span class="n">column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-564"><a href="#Generator-564"><span class="linenos"> 564</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator-565"><a href="#Generator-565"><span class="linenos"> 565</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"constraints"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-566"><a href="#Generator-566"><span class="linenos"> 566</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">"IF NOT EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-567"><a href="#Generator-567"><span class="linenos"> 567</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-568"><a href="#Generator-568"><span class="linenos"> 568</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">constraints</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">constraints</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-569"><a href="#Generator-569"><span class="linenos"> 569</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> +</span><span id="Generator-570"><a href="#Generator-570"><span class="linenos"> 570</span></a> <span class="n">position</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">position</span> <span class="k">else</span> <span class="s2">""</span> </span><span id="Generator-571"><a href="#Generator-571"><span class="linenos"> 571</span></a> -</span><span id="Generator-572"><a href="#Generator-572"><span class="linenos"> 572</span></a> <span class="k">def</span> <span class="nf">autoincrementcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-573"><a href="#Generator-573"><span class="linenos"> 573</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">token_sql</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">)</span> -</span><span id="Generator-574"><a href="#Generator-574"><span class="linenos"> 574</span></a> -</span><span id="Generator-575"><a href="#Generator-575"><span class="linenos"> 575</span></a> <span class="k">def</span> <span class="nf">compresscolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CompressColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-576"><a href="#Generator-576"><span class="linenos"> 576</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="Generator-577"><a href="#Generator-577"><span class="linenos"> 577</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> -</span><span id="Generator-578"><a href="#Generator-578"><span class="linenos"> 578</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-579"><a href="#Generator-579"><span class="linenos"> 579</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-580"><a href="#Generator-580"><span class="linenos"> 580</span></a> -</span><span id="Generator-581"><a href="#Generator-581"><span class="linenos"> 581</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMPRESS </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-582"><a href="#Generator-582"><span class="linenos"> 582</span></a> -</span><span id="Generator-583"><a href="#Generator-583"><span class="linenos"> 583</span></a> <span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> -</span><span id="Generator-584"><a href="#Generator-584"><span class="linenos"> 584</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> -</span><span id="Generator-585"><a href="#Generator-585"><span class="linenos"> 585</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-586"><a href="#Generator-586"><span class="linenos"> 586</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-587"><a href="#Generator-587"><span class="linenos"> 587</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-588"><a href="#Generator-588"><span class="linenos"> 588</span></a> <span class="n">on_null</span> <span class="o">=</span> <span class="s2">"ON NULL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on_null"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-589"><a href="#Generator-589"><span class="linenos"> 589</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" ALWAYS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" BY DEFAULT </span><span class="si">{</span><span class="n">on_null</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-590"><a href="#Generator-590"><span class="linenos"> 590</span></a> -</span><span id="Generator-591"><a href="#Generator-591"><span class="linenos"> 591</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"start"</span><span class="p">)</span> -</span><span id="Generator-592"><a href="#Generator-592"><span class="linenos"> 592</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"START WITH </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-593"><a href="#Generator-593"><span class="linenos"> 593</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"increment"</span><span class="p">)</span> -</span><span id="Generator-594"><a href="#Generator-594"><span class="linenos"> 594</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT BY </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-595"><a href="#Generator-595"><span class="linenos"> 595</span></a> <span class="n">minvalue</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"minvalue"</span><span class="p">)</span> -</span><span id="Generator-596"><a href="#Generator-596"><span class="linenos"> 596</span></a> <span class="n">minvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MINVALUE </span><span class="si">{</span><span class="n">minvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">minvalue</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-597"><a href="#Generator-597"><span class="linenos"> 597</span></a> <span class="n">maxvalue</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"maxvalue"</span><span class="p">)</span> -</span><span id="Generator-598"><a href="#Generator-598"><span class="linenos"> 598</span></a> <span class="n">maxvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAXVALUE </span><span class="si">{</span><span class="n">maxvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">maxvalue</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-599"><a href="#Generator-599"><span class="linenos"> 599</span></a> <span class="n">cycle</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"cycle"</span><span class="p">)</span> -</span><span id="Generator-600"><a href="#Generator-600"><span class="linenos"> 600</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-601"><a href="#Generator-601"><span class="linenos"> 601</span></a> -</span><span id="Generator-602"><a href="#Generator-602"><span class="linenos"> 602</span></a> <span class="k">if</span> <span class="n">cycle</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-603"><a href="#Generator-603"><span class="linenos"> 603</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' NO'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">cycle</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2"> CYCLE"</span> -</span><span id="Generator-604"><a href="#Generator-604"><span class="linenos"> 604</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="n">cycle_sql</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">start</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">increment</span> <span class="k">else</span> <span class="n">cycle_sql</span> -</span><span id="Generator-605"><a href="#Generator-605"><span class="linenos"> 605</span></a> -</span><span id="Generator-606"><a href="#Generator-606"><span class="linenos"> 606</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-607"><a href="#Generator-607"><span class="linenos"> 607</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">or</span> <span class="n">increment</span> <span class="ow">or</span> <span class="n">cycle_sql</span><span class="p">:</span> -</span><span id="Generator-608"><a href="#Generator-608"><span class="linenos"> 608</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}{</span><span class="n">minvalue</span><span class="si">}{</span><span class="n">maxvalue</span><span class="si">}{</span><span class="n">cycle_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-609"><a href="#Generator-609"><span class="linenos"> 609</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">sequence_opts</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-610"><a href="#Generator-610"><span class="linenos"> 610</span></a> -</span><span id="Generator-611"><a href="#Generator-611"><span class="linenos"> 611</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator-612"><a href="#Generator-612"><span class="linenos"> 612</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expr</span> <span class="k">else</span> <span class="s2">"IDENTITY"</span> -</span><span id="Generator-613"><a href="#Generator-613"><span class="linenos"> 613</span></a> -</span><span id="Generator-614"><a href="#Generator-614"><span class="linenos"> 614</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GENERATED</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">AS </span><span class="si">{</span><span class="n">expr</span><span class="si">}{</span><span class="n">sequence_opts</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-615"><a href="#Generator-615"><span class="linenos"> 615</span></a> -</span><span id="Generator-616"><a href="#Generator-616"><span class="linenos"> 616</span></a> <span class="k">def</span> <span class="nf">notnullcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NotNullColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-617"><a href="#Generator-617"><span class="linenos"> 617</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">''</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'allow_null'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'NOT '</span><span class="si">}</span><span class="s2">NULL"</span> -</span><span id="Generator-618"><a href="#Generator-618"><span class="linenos"> 618</span></a> -</span><span id="Generator-619"><a href="#Generator-619"><span class="linenos"> 619</span></a> <span class="k">def</span> <span class="nf">primarykeycolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKeyColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-620"><a href="#Generator-620"><span class="linenos"> 620</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"desc"</span><span class="p">)</span> -</span><span id="Generator-621"><a href="#Generator-621"><span class="linenos"> 621</span></a> <span class="k">if</span> <span class="n">desc</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-622"><a href="#Generator-622"><span class="linenos"> 622</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY</span><span class="si">{</span><span class="s1">' DESC'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">desc</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ASC'</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-623"><a href="#Generator-623"><span class="linenos"> 623</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY"</span> -</span><span id="Generator-624"><a href="#Generator-624"><span class="linenos"> 624</span></a> -</span><span id="Generator-625"><a href="#Generator-625"><span class="linenos"> 625</span></a> <span class="k">def</span> <span class="nf">uniquecolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UniqueColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-626"><a href="#Generator-626"><span class="linenos"> 626</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-627"><a href="#Generator-627"><span class="linenos"> 627</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-628"><a href="#Generator-628"><span class="linenos"> 628</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNIQUE</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-629"><a href="#Generator-629"><span class="linenos"> 629</span></a> -</span><span id="Generator-630"><a href="#Generator-630"><span class="linenos"> 630</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span> -</span><span id="Generator-631"><a href="#Generator-631"><span class="linenos"> 631</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="nb">dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">]]</span> -</span><span id="Generator-632"><a href="#Generator-632"><span class="linenos"> 632</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-633"><a href="#Generator-633"><span class="linenos"> 633</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-634"><a href="#Generator-634"><span class="linenos"> 634</span></a> -</span><span id="Generator-635"><a href="#Generator-635"><span class="linenos"> 635</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-636"><a href="#Generator-636"><span class="linenos"> 636</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Generator-637"><a href="#Generator-637"><span class="linenos"> 637</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"properties"</span><span class="p">)</span> -</span><span id="Generator-638"><a href="#Generator-638"><span class="linenos"> 638</span></a> <span class="n">properties_locs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">locate_properties</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span> <span class="k">if</span> <span class="n">properties</span> <span class="k">else</span> <span class="p">{}</span> -</span><span id="Generator-639"><a href="#Generator-639"><span class="linenos"> 639</span></a> -</span><span id="Generator-640"><a href="#Generator-640"><span class="linenos"> 640</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">properties_locs</span><span class="p">)</span> +</span><span id="Generator-572"><a href="#Generator-572"><span class="linenos"> 572</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">column</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-573"><a href="#Generator-573"><span class="linenos"> 573</span></a> +</span><span id="Generator-574"><a href="#Generator-574"><span class="linenos"> 574</span></a> <span class="k">def</span> <span class="nf">columnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-575"><a href="#Generator-575"><span class="linenos"> 575</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-576"><a href="#Generator-576"><span class="linenos"> 576</span></a> <span class="n">kind_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="Generator-577"><a href="#Generator-577"><span class="linenos"> 577</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="n">kind_sql</span> +</span><span id="Generator-578"><a href="#Generator-578"><span class="linenos"> 578</span></a> +</span><span id="Generator-579"><a href="#Generator-579"><span class="linenos"> 579</span></a> <span class="k">def</span> <span class="nf">autoincrementcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-580"><a href="#Generator-580"><span class="linenos"> 580</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">token_sql</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">)</span> +</span><span id="Generator-581"><a href="#Generator-581"><span class="linenos"> 581</span></a> +</span><span id="Generator-582"><a href="#Generator-582"><span class="linenos"> 582</span></a> <span class="k">def</span> <span class="nf">compresscolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CompressColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-583"><a href="#Generator-583"><span class="linenos"> 583</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="Generator-584"><a href="#Generator-584"><span class="linenos"> 584</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="Generator-585"><a href="#Generator-585"><span class="linenos"> 585</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-586"><a href="#Generator-586"><span class="linenos"> 586</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-587"><a href="#Generator-587"><span class="linenos"> 587</span></a> +</span><span id="Generator-588"><a href="#Generator-588"><span class="linenos"> 588</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMPRESS </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-589"><a href="#Generator-589"><span class="linenos"> 589</span></a> +</span><span id="Generator-590"><a href="#Generator-590"><span class="linenos"> 590</span></a> <span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> +</span><span id="Generator-591"><a href="#Generator-591"><span class="linenos"> 591</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> +</span><span id="Generator-592"><a href="#Generator-592"><span class="linenos"> 592</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-593"><a href="#Generator-593"><span class="linenos"> 593</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-594"><a href="#Generator-594"><span class="linenos"> 594</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-595"><a href="#Generator-595"><span class="linenos"> 595</span></a> <span class="n">on_null</span> <span class="o">=</span> <span class="s2">"ON NULL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on_null"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-596"><a href="#Generator-596"><span class="linenos"> 596</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" ALWAYS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" BY DEFAULT </span><span class="si">{</span><span class="n">on_null</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-597"><a href="#Generator-597"><span class="linenos"> 597</span></a> +</span><span id="Generator-598"><a href="#Generator-598"><span class="linenos"> 598</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"start"</span><span class="p">)</span> +</span><span id="Generator-599"><a href="#Generator-599"><span class="linenos"> 599</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"START WITH </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-600"><a href="#Generator-600"><span class="linenos"> 600</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"increment"</span><span class="p">)</span> +</span><span id="Generator-601"><a href="#Generator-601"><span class="linenos"> 601</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT BY </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-602"><a href="#Generator-602"><span class="linenos"> 602</span></a> <span class="n">minvalue</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"minvalue"</span><span class="p">)</span> +</span><span id="Generator-603"><a href="#Generator-603"><span class="linenos"> 603</span></a> <span class="n">minvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MINVALUE </span><span class="si">{</span><span class="n">minvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">minvalue</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-604"><a href="#Generator-604"><span class="linenos"> 604</span></a> <span class="n">maxvalue</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"maxvalue"</span><span class="p">)</span> +</span><span id="Generator-605"><a href="#Generator-605"><span class="linenos"> 605</span></a> <span class="n">maxvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAXVALUE </span><span class="si">{</span><span class="n">maxvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">maxvalue</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-606"><a href="#Generator-606"><span class="linenos"> 606</span></a> <span class="n">cycle</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"cycle"</span><span class="p">)</span> +</span><span id="Generator-607"><a href="#Generator-607"><span class="linenos"> 607</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-608"><a href="#Generator-608"><span class="linenos"> 608</span></a> +</span><span id="Generator-609"><a href="#Generator-609"><span class="linenos"> 609</span></a> <span class="k">if</span> <span class="n">cycle</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-610"><a href="#Generator-610"><span class="linenos"> 610</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' NO'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">cycle</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2"> CYCLE"</span> +</span><span id="Generator-611"><a href="#Generator-611"><span class="linenos"> 611</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="n">cycle_sql</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">start</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">increment</span> <span class="k">else</span> <span class="n">cycle_sql</span> +</span><span id="Generator-612"><a href="#Generator-612"><span class="linenos"> 612</span></a> +</span><span id="Generator-613"><a href="#Generator-613"><span class="linenos"> 613</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-614"><a href="#Generator-614"><span class="linenos"> 614</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">or</span> <span class="n">increment</span> <span class="ow">or</span> <span class="n">cycle_sql</span><span class="p">:</span> +</span><span id="Generator-615"><a href="#Generator-615"><span class="linenos"> 615</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}{</span><span class="n">minvalue</span><span class="si">}{</span><span class="n">maxvalue</span><span class="si">}{</span><span class="n">cycle_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-616"><a href="#Generator-616"><span class="linenos"> 616</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">sequence_opts</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-617"><a href="#Generator-617"><span class="linenos"> 617</span></a> +</span><span id="Generator-618"><a href="#Generator-618"><span class="linenos"> 618</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator-619"><a href="#Generator-619"><span class="linenos"> 619</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expr</span> <span class="k">else</span> <span class="s2">"IDENTITY"</span> +</span><span id="Generator-620"><a href="#Generator-620"><span class="linenos"> 620</span></a> +</span><span id="Generator-621"><a href="#Generator-621"><span class="linenos"> 621</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GENERATED</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">AS </span><span class="si">{</span><span class="n">expr</span><span class="si">}{</span><span class="n">sequence_opts</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-622"><a href="#Generator-622"><span class="linenos"> 622</span></a> +</span><span id="Generator-623"><a href="#Generator-623"><span class="linenos"> 623</span></a> <span class="k">def</span> <span class="nf">notnullcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NotNullColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-624"><a href="#Generator-624"><span class="linenos"> 624</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">''</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'allow_null'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'NOT '</span><span class="si">}</span><span class="s2">NULL"</span> +</span><span id="Generator-625"><a href="#Generator-625"><span class="linenos"> 625</span></a> +</span><span id="Generator-626"><a href="#Generator-626"><span class="linenos"> 626</span></a> <span class="k">def</span> <span class="nf">primarykeycolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKeyColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-627"><a href="#Generator-627"><span class="linenos"> 627</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"desc"</span><span class="p">)</span> +</span><span id="Generator-628"><a href="#Generator-628"><span class="linenos"> 628</span></a> <span class="k">if</span> <span class="n">desc</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-629"><a href="#Generator-629"><span class="linenos"> 629</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY</span><span class="si">{</span><span class="s1">' DESC'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">desc</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ASC'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-630"><a href="#Generator-630"><span class="linenos"> 630</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY"</span> +</span><span id="Generator-631"><a href="#Generator-631"><span class="linenos"> 631</span></a> +</span><span id="Generator-632"><a href="#Generator-632"><span class="linenos"> 632</span></a> <span class="k">def</span> <span class="nf">uniquecolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UniqueColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-633"><a href="#Generator-633"><span class="linenos"> 633</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-634"><a href="#Generator-634"><span class="linenos"> 634</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-635"><a href="#Generator-635"><span class="linenos"> 635</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNIQUE</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-636"><a href="#Generator-636"><span class="linenos"> 636</span></a> +</span><span id="Generator-637"><a href="#Generator-637"><span class="linenos"> 637</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span> +</span><span id="Generator-638"><a href="#Generator-638"><span class="linenos"> 638</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="nb">dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">]]</span> +</span><span id="Generator-639"><a href="#Generator-639"><span class="linenos"> 639</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-640"><a href="#Generator-640"><span class="linenos"> 640</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> </span><span id="Generator-641"><a href="#Generator-641"><span class="linenos"> 641</span></a> -</span><span id="Generator-642"><a href="#Generator-642"><span class="linenos"> 642</span></a> <span class="n">properties_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-643"><a href="#Generator-643"><span class="linenos"> 643</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">)</span> <span class="ow">or</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> -</span><span id="Generator-644"><a href="#Generator-644"><span class="linenos"> 644</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span> -</span><span id="Generator-645"><a href="#Generator-645"><span class="linenos"> 645</span></a> <span class="p">):</span> -</span><span id="Generator-646"><a href="#Generator-646"><span class="linenos"> 646</span></a> <span class="n">properties_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="Generator-647"><a href="#Generator-647"><span class="linenos"> 647</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> -</span><span id="Generator-648"><a href="#Generator-648"><span class="linenos"> 648</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> -</span><span id="Generator-649"><a href="#Generator-649"><span class="linenos"> 649</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">],</span> -</span><span id="Generator-650"><a href="#Generator-650"><span class="linenos"> 650</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">],</span> -</span><span id="Generator-651"><a href="#Generator-651"><span class="linenos"> 651</span></a> <span class="p">]</span> -</span><span id="Generator-652"><a href="#Generator-652"><span class="linenos"> 652</span></a> <span class="p">)</span> -</span><span id="Generator-653"><a href="#Generator-653"><span class="linenos"> 653</span></a> <span class="p">)</span> -</span><span id="Generator-654"><a href="#Generator-654"><span class="linenos"> 654</span></a> -</span><span id="Generator-655"><a href="#Generator-655"><span class="linenos"> 655</span></a> <span class="n">begin</span> <span class="o">=</span> <span class="s2">" BEGIN"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"begin"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-656"><a href="#Generator-656"><span class="linenos"> 656</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator-657"><a href="#Generator-657"><span class="linenos"> 657</span></a> <span class="k">if</span> <span class="n">expression_sql</span><span class="p">:</span> -</span><span id="Generator-658"><a href="#Generator-658"><span class="linenos"> 658</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">begin</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-659"><a href="#Generator-659"><span class="linenos"> 659</span></a> -</span><span id="Generator-660"><a href="#Generator-660"><span class="linenos"> 660</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CREATE_FUNCTION_RETURN_AS</span> <span class="ow">or</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Return</span><span class="p">):</span> -</span><span id="Generator-661"><a href="#Generator-661"><span class="linenos"> 661</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">):</span> -</span><span id="Generator-662"><a href="#Generator-662"><span class="linenos"> 662</span></a> <span class="n">postalias_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="Generator-663"><a href="#Generator-663"><span class="linenos"> 663</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> -</span><span id="Generator-664"><a href="#Generator-664"><span class="linenos"> 664</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">]</span> -</span><span id="Generator-665"><a href="#Generator-665"><span class="linenos"> 665</span></a> <span class="p">),</span> -</span><span id="Generator-666"><a href="#Generator-666"><span class="linenos"> 666</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Generator-667"><a href="#Generator-667"><span class="linenos"> 667</span></a> <span class="p">)</span> -</span><span id="Generator-668"><a href="#Generator-668"><span class="linenos"> 668</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">postalias_props_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-669"><a href="#Generator-669"><span class="linenos"> 669</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-670"><a href="#Generator-670"><span class="linenos"> 670</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-671"><a href="#Generator-671"><span class="linenos"> 671</span></a> -</span><span id="Generator-672"><a href="#Generator-672"><span class="linenos"> 672</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-673"><a href="#Generator-673"><span class="linenos"> 673</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">):</span> -</span><span id="Generator-674"><a href="#Generator-674"><span class="linenos"> 674</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="Generator-675"><a href="#Generator-675"><span class="linenos"> 675</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">]),</span> -</span><span id="Generator-676"><a href="#Generator-676"><span class="linenos"> 676</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Generator-677"><a href="#Generator-677"><span class="linenos"> 677</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator-678"><a href="#Generator-678"><span class="linenos"> 678</span></a> <span class="p">)</span> -</span><span id="Generator-679"><a href="#Generator-679"><span class="linenos"> 679</span></a> -</span><span id="Generator-680"><a href="#Generator-680"><span class="linenos"> 680</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"indexes"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator-681"><a href="#Generator-681"><span class="linenos"> 681</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">indexes</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">indexes</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-682"><a href="#Generator-682"><span class="linenos"> 682</span></a> <span class="n">index_sql</span> <span class="o">=</span> <span class="n">indexes</span> <span class="o">+</span> <span class="n">postindex_props_sql</span> -</span><span id="Generator-683"><a href="#Generator-683"><span class="linenos"> 683</span></a> -</span><span id="Generator-684"><a href="#Generator-684"><span class="linenos"> 684</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="s2">" OR REPLACE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"replace"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-685"><a href="#Generator-685"><span class="linenos"> 685</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">" UNIQUE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-642"><a href="#Generator-642"><span class="linenos"> 642</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-643"><a href="#Generator-643"><span class="linenos"> 643</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Generator-644"><a href="#Generator-644"><span class="linenos"> 644</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"properties"</span><span class="p">)</span> +</span><span id="Generator-645"><a href="#Generator-645"><span class="linenos"> 645</span></a> <span class="n">properties_locs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">locate_properties</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span> <span class="k">if</span> <span class="n">properties</span> <span class="k">else</span> <span class="p">{}</span> +</span><span id="Generator-646"><a href="#Generator-646"><span class="linenos"> 646</span></a> +</span><span id="Generator-647"><a href="#Generator-647"><span class="linenos"> 647</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">properties_locs</span><span class="p">)</span> +</span><span id="Generator-648"><a href="#Generator-648"><span class="linenos"> 648</span></a> +</span><span id="Generator-649"><a href="#Generator-649"><span class="linenos"> 649</span></a> <span class="n">properties_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-650"><a href="#Generator-650"><span class="linenos"> 650</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">)</span> <span class="ow">or</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> +</span><span id="Generator-651"><a href="#Generator-651"><span class="linenos"> 651</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span> +</span><span id="Generator-652"><a href="#Generator-652"><span class="linenos"> 652</span></a> <span class="p">):</span> +</span><span id="Generator-653"><a href="#Generator-653"><span class="linenos"> 653</span></a> <span class="n">properties_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="Generator-654"><a href="#Generator-654"><span class="linenos"> 654</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> +</span><span id="Generator-655"><a href="#Generator-655"><span class="linenos"> 655</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> +</span><span id="Generator-656"><a href="#Generator-656"><span class="linenos"> 656</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">],</span> +</span><span id="Generator-657"><a href="#Generator-657"><span class="linenos"> 657</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">],</span> +</span><span id="Generator-658"><a href="#Generator-658"><span class="linenos"> 658</span></a> <span class="p">]</span> +</span><span id="Generator-659"><a href="#Generator-659"><span class="linenos"> 659</span></a> <span class="p">)</span> +</span><span id="Generator-660"><a href="#Generator-660"><span class="linenos"> 660</span></a> <span class="p">)</span> +</span><span id="Generator-661"><a href="#Generator-661"><span class="linenos"> 661</span></a> +</span><span id="Generator-662"><a href="#Generator-662"><span class="linenos"> 662</span></a> <span class="n">begin</span> <span class="o">=</span> <span class="s2">" BEGIN"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"begin"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-663"><a href="#Generator-663"><span class="linenos"> 663</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator-664"><a href="#Generator-664"><span class="linenos"> 664</span></a> <span class="k">if</span> <span class="n">expression_sql</span><span class="p">:</span> +</span><span id="Generator-665"><a href="#Generator-665"><span class="linenos"> 665</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">begin</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-666"><a href="#Generator-666"><span class="linenos"> 666</span></a> +</span><span id="Generator-667"><a href="#Generator-667"><span class="linenos"> 667</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CREATE_FUNCTION_RETURN_AS</span> <span class="ow">or</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Return</span><span class="p">):</span> +</span><span id="Generator-668"><a href="#Generator-668"><span class="linenos"> 668</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">):</span> +</span><span id="Generator-669"><a href="#Generator-669"><span class="linenos"> 669</span></a> <span class="n">postalias_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="Generator-670"><a href="#Generator-670"><span class="linenos"> 670</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> +</span><span id="Generator-671"><a href="#Generator-671"><span class="linenos"> 671</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">]</span> +</span><span id="Generator-672"><a href="#Generator-672"><span class="linenos"> 672</span></a> <span class="p">),</span> +</span><span id="Generator-673"><a href="#Generator-673"><span class="linenos"> 673</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Generator-674"><a href="#Generator-674"><span class="linenos"> 674</span></a> <span class="p">)</span> +</span><span id="Generator-675"><a href="#Generator-675"><span class="linenos"> 675</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">postalias_props_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-676"><a href="#Generator-676"><span class="linenos"> 676</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-677"><a href="#Generator-677"><span class="linenos"> 677</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-678"><a href="#Generator-678"><span class="linenos"> 678</span></a> +</span><span id="Generator-679"><a href="#Generator-679"><span class="linenos"> 679</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-680"><a href="#Generator-680"><span class="linenos"> 680</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">):</span> +</span><span id="Generator-681"><a href="#Generator-681"><span class="linenos"> 681</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="Generator-682"><a href="#Generator-682"><span class="linenos"> 682</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">]),</span> +</span><span id="Generator-683"><a href="#Generator-683"><span class="linenos"> 683</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Generator-684"><a href="#Generator-684"><span class="linenos"> 684</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator-685"><a href="#Generator-685"><span class="linenos"> 685</span></a> <span class="p">)</span> </span><span id="Generator-686"><a href="#Generator-686"><span class="linenos"> 686</span></a> -</span><span id="Generator-687"><a href="#Generator-687"><span class="linenos"> 687</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-688"><a href="#Generator-688"><span class="linenos"> 688</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">):</span> -</span><span id="Generator-689"><a href="#Generator-689"><span class="linenos"> 689</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="Generator-690"><a href="#Generator-690"><span class="linenos"> 690</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">]),</span> -</span><span id="Generator-691"><a href="#Generator-691"><span class="linenos"> 691</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator-692"><a href="#Generator-692"><span class="linenos"> 692</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator-693"><a href="#Generator-693"><span class="linenos"> 693</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Generator-694"><a href="#Generator-694"><span class="linenos"> 694</span></a> <span class="p">)</span> -</span><span id="Generator-695"><a href="#Generator-695"><span class="linenos"> 695</span></a> -</span><span id="Generator-696"><a href="#Generator-696"><span class="linenos"> 696</span></a> <span class="n">modifiers</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">replace</span><span class="p">,</span> <span class="n">unique</span><span class="p">,</span> <span class="n">postcreate_props_sql</span><span class="p">))</span> -</span><span id="Generator-697"><a href="#Generator-697"><span class="linenos"> 697</span></a> -</span><span id="Generator-698"><a href="#Generator-698"><span class="linenos"> 698</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-699"><a href="#Generator-699"><span class="linenos"> 699</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">):</span> -</span><span id="Generator-700"><a href="#Generator-700"><span class="linenos"> 700</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="Generator-701"><a href="#Generator-701"><span class="linenos"> 701</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> -</span><span id="Generator-702"><a href="#Generator-702"><span class="linenos"> 702</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">]</span> -</span><span id="Generator-703"><a href="#Generator-703"><span class="linenos"> 703</span></a> <span class="p">),</span> -</span><span id="Generator-704"><a href="#Generator-704"><span class="linenos"> 704</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator-705"><a href="#Generator-705"><span class="linenos"> 705</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator-706"><a href="#Generator-706"><span class="linenos"> 706</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Generator-707"><a href="#Generator-707"><span class="linenos"> 707</span></a> <span class="p">)</span> -</span><span id="Generator-708"><a href="#Generator-708"><span class="linenos"> 708</span></a> -</span><span id="Generator-709"><a href="#Generator-709"><span class="linenos"> 709</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF NOT EXISTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-710"><a href="#Generator-710"><span class="linenos"> 710</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-711"><a href="#Generator-711"><span class="linenos"> 711</span></a> <span class="s2">" WITH NO SCHEMA BINDING"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no_schema_binding"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-712"><a href="#Generator-712"><span class="linenos"> 712</span></a> <span class="p">)</span> -</span><span id="Generator-713"><a href="#Generator-713"><span class="linenos"> 713</span></a> -</span><span id="Generator-714"><a href="#Generator-714"><span class="linenos"> 714</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"clone"</span><span class="p">)</span> -</span><span id="Generator-715"><a href="#Generator-715"><span class="linenos"> 715</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">clone</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-716"><a href="#Generator-716"><span class="linenos"> 716</span></a> -</span><span id="Generator-717"><a href="#Generator-717"><span class="linenos"> 717</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CREATE</span><span class="si">{</span><span class="n">modifiers</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">properties_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">postexpression_props_sql</span><span class="si">}{</span><span class="n">index_sql</span><span class="si">}{</span><span class="n">no_schema_binding</span><span class="si">}{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-718"><a href="#Generator-718"><span class="linenos"> 718</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">expression_sql</span><span class="p">)</span> -</span><span id="Generator-719"><a href="#Generator-719"><span class="linenos"> 719</span></a> -</span><span id="Generator-720"><a href="#Generator-720"><span class="linenos"> 720</span></a> <span class="k">def</span> <span class="nf">clone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Clone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-721"><a href="#Generator-721"><span class="linenos"> 721</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-722"><a href="#Generator-722"><span class="linenos"> 722</span></a> <span class="n">when</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"when"</span><span class="p">)</span> +</span><span id="Generator-687"><a href="#Generator-687"><span class="linenos"> 687</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"indexes"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator-688"><a href="#Generator-688"><span class="linenos"> 688</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">indexes</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">indexes</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-689"><a href="#Generator-689"><span class="linenos"> 689</span></a> <span class="n">index_sql</span> <span class="o">=</span> <span class="n">indexes</span> <span class="o">+</span> <span class="n">postindex_props_sql</span> +</span><span id="Generator-690"><a href="#Generator-690"><span class="linenos"> 690</span></a> +</span><span id="Generator-691"><a href="#Generator-691"><span class="linenos"> 691</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="s2">" OR REPLACE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"replace"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-692"><a href="#Generator-692"><span class="linenos"> 692</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">" UNIQUE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-693"><a href="#Generator-693"><span class="linenos"> 693</span></a> +</span><span id="Generator-694"><a href="#Generator-694"><span class="linenos"> 694</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-695"><a href="#Generator-695"><span class="linenos"> 695</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">):</span> +</span><span id="Generator-696"><a href="#Generator-696"><span class="linenos"> 696</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="Generator-697"><a href="#Generator-697"><span class="linenos"> 697</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">]),</span> +</span><span id="Generator-698"><a href="#Generator-698"><span class="linenos"> 698</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator-699"><a href="#Generator-699"><span class="linenos"> 699</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator-700"><a href="#Generator-700"><span class="linenos"> 700</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Generator-701"><a href="#Generator-701"><span class="linenos"> 701</span></a> <span class="p">)</span> +</span><span id="Generator-702"><a href="#Generator-702"><span class="linenos"> 702</span></a> +</span><span id="Generator-703"><a href="#Generator-703"><span class="linenos"> 703</span></a> <span class="n">modifiers</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">replace</span><span class="p">,</span> <span class="n">unique</span><span class="p">,</span> <span class="n">postcreate_props_sql</span><span class="p">))</span> +</span><span id="Generator-704"><a href="#Generator-704"><span class="linenos"> 704</span></a> +</span><span id="Generator-705"><a href="#Generator-705"><span class="linenos"> 705</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-706"><a href="#Generator-706"><span class="linenos"> 706</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">):</span> +</span><span id="Generator-707"><a href="#Generator-707"><span class="linenos"> 707</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="Generator-708"><a href="#Generator-708"><span class="linenos"> 708</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> +</span><span id="Generator-709"><a href="#Generator-709"><span class="linenos"> 709</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">]</span> +</span><span id="Generator-710"><a href="#Generator-710"><span class="linenos"> 710</span></a> <span class="p">),</span> +</span><span id="Generator-711"><a href="#Generator-711"><span class="linenos"> 711</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator-712"><a href="#Generator-712"><span class="linenos"> 712</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator-713"><a href="#Generator-713"><span class="linenos"> 713</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Generator-714"><a href="#Generator-714"><span class="linenos"> 714</span></a> <span class="p">)</span> +</span><span id="Generator-715"><a href="#Generator-715"><span class="linenos"> 715</span></a> +</span><span id="Generator-716"><a href="#Generator-716"><span class="linenos"> 716</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF NOT EXISTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-717"><a href="#Generator-717"><span class="linenos"> 717</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-718"><a href="#Generator-718"><span class="linenos"> 718</span></a> <span class="s2">" WITH NO SCHEMA BINDING"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no_schema_binding"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-719"><a href="#Generator-719"><span class="linenos"> 719</span></a> <span class="p">)</span> +</span><span id="Generator-720"><a href="#Generator-720"><span class="linenos"> 720</span></a> +</span><span id="Generator-721"><a href="#Generator-721"><span class="linenos"> 721</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"clone"</span><span class="p">)</span> +</span><span id="Generator-722"><a href="#Generator-722"><span class="linenos"> 722</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">clone</span> <span class="k">else</span> <span class="s2">""</span> </span><span id="Generator-723"><a href="#Generator-723"><span class="linenos"> 723</span></a> -</span><span id="Generator-724"><a href="#Generator-724"><span class="linenos"> 724</span></a> <span class="k">if</span> <span class="n">when</span><span class="p">:</span> -</span><span id="Generator-725"><a href="#Generator-725"><span class="linenos"> 725</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator-726"><a href="#Generator-726"><span class="linenos"> 726</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator-727"><a href="#Generator-727"><span class="linenos"> 727</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CLONE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">when</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> => </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-728"><a href="#Generator-728"><span class="linenos"> 728</span></a> -</span><span id="Generator-729"><a href="#Generator-729"><span class="linenos"> 729</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CLONE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-724"><a href="#Generator-724"><span class="linenos"> 724</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CREATE</span><span class="si">{</span><span class="n">modifiers</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">properties_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">postexpression_props_sql</span><span class="si">}{</span><span class="n">index_sql</span><span class="si">}{</span><span class="n">no_schema_binding</span><span class="si">}{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-725"><a href="#Generator-725"><span class="linenos"> 725</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">expression_sql</span><span class="p">)</span> +</span><span id="Generator-726"><a href="#Generator-726"><span class="linenos"> 726</span></a> +</span><span id="Generator-727"><a href="#Generator-727"><span class="linenos"> 727</span></a> <span class="k">def</span> <span class="nf">clone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Clone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-728"><a href="#Generator-728"><span class="linenos"> 728</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-729"><a href="#Generator-729"><span class="linenos"> 729</span></a> <span class="n">when</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"when"</span><span class="p">)</span> </span><span id="Generator-730"><a href="#Generator-730"><span class="linenos"> 730</span></a> -</span><span id="Generator-731"><a href="#Generator-731"><span class="linenos"> 731</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-732"><a href="#Generator-732"><span class="linenos"> 732</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-733"><a href="#Generator-733"><span class="linenos"> 733</span></a> -</span><span id="Generator-734"><a href="#Generator-734"><span class="linenos"> 734</span></a> <span class="k">def</span> <span class="nf">prepend_ctes</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-735"><a href="#Generator-735"><span class="linenos"> 735</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"with"</span><span class="p">)</span> -</span><span id="Generator-736"><a href="#Generator-736"><span class="linenos"> 736</span></a> <span class="k">if</span> <span class="n">with_</span><span class="p">:</span> -</span><span id="Generator-737"><a href="#Generator-737"><span class="linenos"> 737</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">with_</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-738"><a href="#Generator-738"><span class="linenos"> 738</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="Generator-739"><a href="#Generator-739"><span class="linenos"> 739</span></a> -</span><span id="Generator-740"><a href="#Generator-740"><span class="linenos"> 740</span></a> <span class="k">def</span> <span class="nf">with_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-741"><a href="#Generator-741"><span class="linenos"> 741</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-742"><a href="#Generator-742"><span class="linenos"> 742</span></a> <span class="n">recursive</span> <span class="o">=</span> <span class="s2">"RECURSIVE "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"recursive"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-743"><a href="#Generator-743"><span class="linenos"> 743</span></a> -</span><span id="Generator-744"><a href="#Generator-744"><span class="linenos"> 744</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="n">recursive</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-745"><a href="#Generator-745"><span class="linenos"> 745</span></a> -</span><span id="Generator-746"><a href="#Generator-746"><span class="linenos"> 746</span></a> <span class="k">def</span> <span class="nf">cte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-747"><a href="#Generator-747"><span class="linenos"> 747</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator-748"><a href="#Generator-748"><span class="linenos"> 748</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-749"><a href="#Generator-749"><span class="linenos"> 749</span></a> -</span><span id="Generator-750"><a href="#Generator-750"><span class="linenos"> 750</span></a> <span class="k">def</span> <span class="nf">tablealias_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableAlias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-751"><a href="#Generator-751"><span class="linenos"> 751</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-752"><a href="#Generator-752"><span class="linenos"> 752</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-753"><a href="#Generator-753"><span class="linenos"> 753</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-754"><a href="#Generator-754"><span class="linenos"> 754</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-755"><a href="#Generator-755"><span class="linenos"> 755</span></a> -</span><span id="Generator-756"><a href="#Generator-756"><span class="linenos"> 756</span></a> <span class="k">def</span> <span class="nf">bitstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-757"><a href="#Generator-757"><span class="linenos"> 757</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-758"><a href="#Generator-758"><span class="linenos"> 758</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">BIT_START</span><span class="p">:</span> -</span><span id="Generator-759"><a href="#Generator-759"><span class="linenos"> 759</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">BIT_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">BIT_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-760"><a href="#Generator-760"><span class="linenos"> 760</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-761"><a href="#Generator-761"><span class="linenos"> 761</span></a> -</span><span id="Generator-762"><a href="#Generator-762"><span class="linenos"> 762</span></a> <span class="k">def</span> <span class="nf">hexstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">HexString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-763"><a href="#Generator-763"><span class="linenos"> 763</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-764"><a href="#Generator-764"><span class="linenos"> 764</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HEX_START</span><span class="p">:</span> -</span><span id="Generator-765"><a href="#Generator-765"><span class="linenos"> 765</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">HEX_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">HEX_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-766"><a href="#Generator-766"><span class="linenos"> 766</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">16</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-767"><a href="#Generator-767"><span class="linenos"> 767</span></a> -</span><span id="Generator-768"><a href="#Generator-768"><span class="linenos"> 768</span></a> <span class="k">def</span> <span class="nf">bytestring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ByteString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-769"><a href="#Generator-769"><span class="linenos"> 769</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-770"><a href="#Generator-770"><span class="linenos"> 770</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">BYTE_START</span><span class="p">:</span> -</span><span id="Generator-771"><a href="#Generator-771"><span class="linenos"> 771</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">BYTE_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">BYTE_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-772"><a href="#Generator-772"><span class="linenos"> 772</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Generator-773"><a href="#Generator-773"><span class="linenos"> 773</span></a> -</span><span id="Generator-774"><a href="#Generator-774"><span class="linenos"> 774</span></a> <span class="k">def</span> <span class="nf">rawstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RawString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-775"><a href="#Generator-775"><span class="linenos"> 775</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RAW_START</span><span class="p">:</span> -</span><span id="Generator-776"><a href="#Generator-776"><span class="linenos"> 776</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">RAW_START</span><span class="si">}{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">RAW_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-777"><a href="#Generator-777"><span class="linenos"> 777</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">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"</span><span class="se">\\\\</span><span class="s2">"</span><span class="p">)))</span> -</span><span id="Generator-778"><a href="#Generator-778"><span class="linenos"> 778</span></a> -</span><span id="Generator-779"><a href="#Generator-779"><span class="linenos"> 779</span></a> <span class="k">def</span> <span class="nf">datatypesize_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataTypeSize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-780"><a href="#Generator-780"><span class="linenos"> 780</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-781"><a href="#Generator-781"><span class="linenos"> 781</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator-782"><a href="#Generator-782"><span class="linenos"> 782</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">specifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">specifier</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-783"><a href="#Generator-783"><span class="linenos"> 783</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">specifier</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-784"><a href="#Generator-784"><span class="linenos"> 784</span></a> -</span><span id="Generator-785"><a href="#Generator-785"><span class="linenos"> 785</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-786"><a href="#Generator-786"><span class="linenos"> 786</span></a> <span class="n">type_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="Generator-787"><a href="#Generator-787"><span class="linenos"> 787</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">type_value</span><span class="p">,</span> <span class="n">type_value</span><span class="o">.</span><span class="n">value</span><span class="p">)</span> -</span><span id="Generator-788"><a href="#Generator-788"><span class="linenos"> 788</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-789"><a href="#Generator-789"><span class="linenos"> 789</span></a> <span class="n">interior</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-790"><a href="#Generator-790"><span class="linenos"> 790</span></a> <span class="n">values</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-791"><a href="#Generator-791"><span class="linenos"> 791</span></a> <span class="k">if</span> <span class="n">interior</span><span class="p">:</span> -</span><span id="Generator-792"><a href="#Generator-792"><span class="linenos"> 792</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nested"</span><span class="p">):</span> -</span><span id="Generator-793"><a href="#Generator-793"><span class="linenos"> 793</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">interior</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-794"><a href="#Generator-794"><span class="linenos"> 794</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"values"</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-795"><a href="#Generator-795"><span class="linenos"> 795</span></a> <span class="n">delimiters</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"["</span><span class="p">,</span> <span class="s2">"]"</span><span class="p">)</span> <span class="k">if</span> <span class="n">type_value</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span> <span class="k">else</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> -</span><span id="Generator-796"><a href="#Generator-796"><span class="linenos"> 796</span></a> <span class="n">values</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"values"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-797"><a href="#Generator-797"><span class="linenos"> 797</span></a> <span class="n">values</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">values</span><span class="si">}{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-798"><a href="#Generator-798"><span class="linenos"> 798</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-799"><a href="#Generator-799"><span class="linenos"> 799</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">interior</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-800"><a href="#Generator-800"><span class="linenos"> 800</span></a> -</span><span id="Generator-801"><a href="#Generator-801"><span class="linenos"> 801</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}{</span><span class="n">nested</span><span class="si">}{</span><span class="n">values</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-802"><a href="#Generator-802"><span class="linenos"> 802</span></a> -</span><span id="Generator-803"><a href="#Generator-803"><span class="linenos"> 803</span></a> <span class="k">def</span> <span class="nf">directory_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-804"><a href="#Generator-804"><span class="linenos"> 804</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">"LOCAL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-805"><a href="#Generator-805"><span class="linenos"> 805</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"row_format"</span><span class="p">)</span> -</span><span id="Generator-806"><a href="#Generator-806"><span class="linenos"> 806</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-807"><a href="#Generator-807"><span class="linenos"> 807</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2">DIRECTORY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">row_format</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-808"><a href="#Generator-808"><span class="linenos"> 808</span></a> -</span><span id="Generator-809"><a href="#Generator-809"><span class="linenos"> 809</span></a> <span class="k">def</span> <span class="nf">delete_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-810"><a href="#Generator-810"><span class="linenos"> 810</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-811"><a href="#Generator-811"><span class="linenos"> 811</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FROM </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-812"><a href="#Generator-812"><span class="linenos"> 812</span></a> <span class="n">using_sql</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-813"><a href="#Generator-813"><span class="linenos"> 813</span></a> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">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">'using'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">', USING '</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-814"><a href="#Generator-814"><span class="linenos"> 814</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">"using"</span><span class="p">)</span> -</span><span id="Generator-815"><a href="#Generator-815"><span class="linenos"> 815</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-816"><a href="#Generator-816"><span class="linenos"> 816</span></a> <span class="p">)</span> -</span><span id="Generator-817"><a href="#Generator-817"><span class="linenos"> 817</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> -</span><span id="Generator-818"><a href="#Generator-818"><span class="linenos"> 818</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> -</span><span id="Generator-819"><a href="#Generator-819"><span class="linenos"> 819</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"DELETE</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">using_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-820"><a href="#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">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="Generator-821"><a href="#Generator-821"><span class="linenos"> 821</span></a> -</span><span id="Generator-822"><a href="#Generator-822"><span class="linenos"> 822</span></a> <span class="k">def</span> <span class="nf">drop_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-823"><a href="#Generator-823"><span class="linenos"> 823</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-824"><a href="#Generator-824"><span class="linenos"> 824</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> -</span><span id="Generator-825"><a href="#Generator-825"><span class="linenos"> 825</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator-826"><a href="#Generator-826"><span class="linenos"> 826</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-827"><a href="#Generator-827"><span class="linenos"> 827</span></a> <span class="n">materialized</span> <span class="o">=</span> <span class="s2">" MATERIALIZED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"materialized"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-828"><a href="#Generator-828"><span class="linenos"> 828</span></a> <span class="n">cascade</span> <span class="o">=</span> <span class="s2">" CASCADE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"cascade"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-829"><a href="#Generator-829"><span class="linenos"> 829</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="s2">" CONSTRAINTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"constraints"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-830"><a href="#Generator-830"><span class="linenos"> 830</span></a> <span class="n">purge</span> <span class="o">=</span> <span class="s2">" PURGE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"purge"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-831"><a href="#Generator-831"><span class="linenos"> 831</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="Generator-832"><a href="#Generator-832"><span class="linenos"> 832</span></a> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">temporary</span><span class="si">}{</span><span class="n">materialized</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">exists_sql</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">cascade</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">purge</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-833"><a href="#Generator-833"><span class="linenos"> 833</span></a> <span class="p">)</span> -</span><span id="Generator-834"><a href="#Generator-834"><span class="linenos"> 834</span></a> -</span><span id="Generator-835"><a href="#Generator-835"><span class="linenos"> 835</span></a> <span class="k">def</span> <span class="nf">except_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-836"><a href="#Generator-836"><span class="linenos"> 836</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span> -</span><span id="Generator-837"><a href="#Generator-837"><span class="linenos"> 837</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator-838"><a href="#Generator-838"><span class="linenos"> 838</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> -</span><span id="Generator-839"><a href="#Generator-839"><span class="linenos"> 839</span></a> <span class="p">)</span> -</span><span id="Generator-840"><a href="#Generator-840"><span class="linenos"> 840</span></a> -</span><span id="Generator-841"><a href="#Generator-841"><span class="linenos"> 841</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-842"><a href="#Generator-842"><span class="linenos"> 842</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">''</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-731"><a href="#Generator-731"><span class="linenos"> 731</span></a> <span class="k">if</span> <span class="n">when</span><span class="p">:</span> +</span><span id="Generator-732"><a href="#Generator-732"><span class="linenos"> 732</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator-733"><a href="#Generator-733"><span class="linenos"> 733</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator-734"><a href="#Generator-734"><span class="linenos"> 734</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CLONE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">when</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> => </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-735"><a href="#Generator-735"><span class="linenos"> 735</span></a> +</span><span id="Generator-736"><a href="#Generator-736"><span class="linenos"> 736</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CLONE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-737"><a href="#Generator-737"><span class="linenos"> 737</span></a> +</span><span id="Generator-738"><a href="#Generator-738"><span class="linenos"> 738</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-739"><a href="#Generator-739"><span class="linenos"> 739</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-740"><a href="#Generator-740"><span class="linenos"> 740</span></a> +</span><span id="Generator-741"><a href="#Generator-741"><span class="linenos"> 741</span></a> <span class="k">def</span> <span class="nf">prepend_ctes</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-742"><a href="#Generator-742"><span class="linenos"> 742</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"with"</span><span class="p">)</span> +</span><span id="Generator-743"><a href="#Generator-743"><span class="linenos"> 743</span></a> <span class="k">if</span> <span class="n">with_</span><span class="p">:</span> +</span><span id="Generator-744"><a href="#Generator-744"><span class="linenos"> 744</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">with_</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-745"><a href="#Generator-745"><span class="linenos"> 745</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator-746"><a href="#Generator-746"><span class="linenos"> 746</span></a> +</span><span id="Generator-747"><a href="#Generator-747"><span class="linenos"> 747</span></a> <span class="k">def</span> <span class="nf">with_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-748"><a href="#Generator-748"><span class="linenos"> 748</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-749"><a href="#Generator-749"><span class="linenos"> 749</span></a> <span class="n">recursive</span> <span class="o">=</span> <span class="s2">"RECURSIVE "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"recursive"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-750"><a href="#Generator-750"><span class="linenos"> 750</span></a> +</span><span id="Generator-751"><a href="#Generator-751"><span class="linenos"> 751</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="n">recursive</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-752"><a href="#Generator-752"><span class="linenos"> 752</span></a> +</span><span id="Generator-753"><a href="#Generator-753"><span class="linenos"> 753</span></a> <span class="k">def</span> <span class="nf">cte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-754"><a href="#Generator-754"><span class="linenos"> 754</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator-755"><a href="#Generator-755"><span class="linenos"> 755</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-756"><a href="#Generator-756"><span class="linenos"> 756</span></a> +</span><span id="Generator-757"><a href="#Generator-757"><span class="linenos"> 757</span></a> <span class="k">def</span> <span class="nf">tablealias_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableAlias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-758"><a href="#Generator-758"><span class="linenos"> 758</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-759"><a href="#Generator-759"><span class="linenos"> 759</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-760"><a href="#Generator-760"><span class="linenos"> 760</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-761"><a href="#Generator-761"><span class="linenos"> 761</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-762"><a href="#Generator-762"><span class="linenos"> 762</span></a> +</span><span id="Generator-763"><a href="#Generator-763"><span class="linenos"> 763</span></a> <span class="k">def</span> <span class="nf">bitstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-764"><a href="#Generator-764"><span class="linenos"> 764</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-765"><a href="#Generator-765"><span class="linenos"> 765</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">BIT_START</span><span class="p">:</span> +</span><span id="Generator-766"><a href="#Generator-766"><span class="linenos"> 766</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">BIT_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">BIT_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-767"><a href="#Generator-767"><span class="linenos"> 767</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-768"><a href="#Generator-768"><span class="linenos"> 768</span></a> +</span><span id="Generator-769"><a href="#Generator-769"><span class="linenos"> 769</span></a> <span class="k">def</span> <span class="nf">hexstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">HexString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-770"><a href="#Generator-770"><span class="linenos"> 770</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-771"><a href="#Generator-771"><span class="linenos"> 771</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HEX_START</span><span class="p">:</span> +</span><span id="Generator-772"><a href="#Generator-772"><span class="linenos"> 772</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">HEX_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">HEX_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-773"><a href="#Generator-773"><span class="linenos"> 773</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">16</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-774"><a href="#Generator-774"><span class="linenos"> 774</span></a> +</span><span id="Generator-775"><a href="#Generator-775"><span class="linenos"> 775</span></a> <span class="k">def</span> <span class="nf">bytestring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ByteString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-776"><a href="#Generator-776"><span class="linenos"> 776</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-777"><a href="#Generator-777"><span class="linenos"> 777</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">BYTE_START</span><span class="p">:</span> +</span><span id="Generator-778"><a href="#Generator-778"><span class="linenos"> 778</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">BYTE_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">BYTE_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-779"><a href="#Generator-779"><span class="linenos"> 779</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Generator-780"><a href="#Generator-780"><span class="linenos"> 780</span></a> +</span><span id="Generator-781"><a href="#Generator-781"><span class="linenos"> 781</span></a> <span class="k">def</span> <span class="nf">rawstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RawString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-782"><a href="#Generator-782"><span class="linenos"> 782</span></a> <span class="n">string</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="Generator-783"><a href="#Generator-783"><span class="linenos"> 783</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RAW_START</span><span class="p">:</span> +</span><span id="Generator-784"><a href="#Generator-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="bp">self</span><span class="o">.</span><span class="n">RAW_START</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">RAW_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-785"><a href="#Generator-785"><span class="linenos"> 785</span></a> <span class="n">string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">string</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"</span><span class="se">\\\\</span><span class="s2">"</span><span class="p">))</span> +</span><span id="Generator-786"><a href="#Generator-786"><span class="linenos"> 786</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="n">string</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-787"><a href="#Generator-787"><span class="linenos"> 787</span></a> +</span><span id="Generator-788"><a href="#Generator-788"><span class="linenos"> 788</span></a> <span class="k">def</span> <span class="nf">datatypesize_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataTypeSize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-789"><a href="#Generator-789"><span class="linenos"> 789</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-790"><a href="#Generator-790"><span class="linenos"> 790</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator-791"><a href="#Generator-791"><span class="linenos"> 791</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">specifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">specifier</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-792"><a href="#Generator-792"><span class="linenos"> 792</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">specifier</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-793"><a href="#Generator-793"><span class="linenos"> 793</span></a> +</span><span id="Generator-794"><a href="#Generator-794"><span class="linenos"> 794</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-795"><a href="#Generator-795"><span class="linenos"> 795</span></a> <span class="n">type_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="Generator-796"><a href="#Generator-796"><span class="linenos"> 796</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">type_value</span><span class="p">,</span> <span class="n">type_value</span><span class="o">.</span><span class="n">value</span><span class="p">)</span> +</span><span id="Generator-797"><a href="#Generator-797"><span class="linenos"> 797</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-798"><a href="#Generator-798"><span class="linenos"> 798</span></a> <span class="n">interior</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-799"><a href="#Generator-799"><span class="linenos"> 799</span></a> <span class="n">values</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-800"><a href="#Generator-800"><span class="linenos"> 800</span></a> <span class="k">if</span> <span class="n">interior</span><span class="p">:</span> +</span><span id="Generator-801"><a href="#Generator-801"><span class="linenos"> 801</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nested"</span><span class="p">):</span> +</span><span id="Generator-802"><a href="#Generator-802"><span class="linenos"> 802</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">interior</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-803"><a href="#Generator-803"><span class="linenos"> 803</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"values"</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-804"><a href="#Generator-804"><span class="linenos"> 804</span></a> <span class="n">delimiters</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"["</span><span class="p">,</span> <span class="s2">"]"</span><span class="p">)</span> <span class="k">if</span> <span class="n">type_value</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span> <span class="k">else</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> +</span><span id="Generator-805"><a href="#Generator-805"><span class="linenos"> 805</span></a> <span class="n">values</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"values"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-806"><a href="#Generator-806"><span class="linenos"> 806</span></a> <span class="n">values</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">values</span><span class="si">}{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-807"><a href="#Generator-807"><span class="linenos"> 807</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-808"><a href="#Generator-808"><span class="linenos"> 808</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">interior</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-809"><a href="#Generator-809"><span class="linenos"> 809</span></a> +</span><span id="Generator-810"><a href="#Generator-810"><span class="linenos"> 810</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}{</span><span class="n">nested</span><span class="si">}{</span><span class="n">values</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-811"><a href="#Generator-811"><span class="linenos"> 811</span></a> +</span><span id="Generator-812"><a href="#Generator-812"><span class="linenos"> 812</span></a> <span class="k">def</span> <span class="nf">directory_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-813"><a href="#Generator-813"><span class="linenos"> 813</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">"LOCAL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-814"><a href="#Generator-814"><span class="linenos"> 814</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"row_format"</span><span class="p">)</span> +</span><span id="Generator-815"><a href="#Generator-815"><span class="linenos"> 815</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-816"><a href="#Generator-816"><span class="linenos"> 816</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2">DIRECTORY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">row_format</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-817"><a href="#Generator-817"><span class="linenos"> 817</span></a> +</span><span id="Generator-818"><a href="#Generator-818"><span class="linenos"> 818</span></a> <span class="k">def</span> <span class="nf">delete_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-819"><a href="#Generator-819"><span class="linenos"> 819</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-820"><a href="#Generator-820"><span class="linenos"> 820</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FROM </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-821"><a href="#Generator-821"><span class="linenos"> 821</span></a> <span class="n">using_sql</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-822"><a href="#Generator-822"><span class="linenos"> 822</span></a> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">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">'using'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">', USING '</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-823"><a href="#Generator-823"><span class="linenos"> 823</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">"using"</span><span class="p">)</span> +</span><span id="Generator-824"><a href="#Generator-824"><span class="linenos"> 824</span></a> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-825"><a href="#Generator-825"><span class="linenos"> 825</span></a> <span class="p">)</span> +</span><span id="Generator-826"><a href="#Generator-826"><span class="linenos"> 826</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> +</span><span id="Generator-827"><a href="#Generator-827"><span class="linenos"> 827</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="Generator-828"><a href="#Generator-828"><span class="linenos"> 828</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"DELETE</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">using_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-829"><a href="#Generator-829"><span class="linenos"> 829</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="Generator-830"><a href="#Generator-830"><span class="linenos"> 830</span></a> +</span><span id="Generator-831"><a href="#Generator-831"><span class="linenos"> 831</span></a> <span class="k">def</span> <span class="nf">drop_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-832"><a href="#Generator-832"><span class="linenos"> 832</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-833"><a href="#Generator-833"><span class="linenos"> 833</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> +</span><span id="Generator-834"><a href="#Generator-834"><span class="linenos"> 834</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator-835"><a href="#Generator-835"><span class="linenos"> 835</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-836"><a href="#Generator-836"><span class="linenos"> 836</span></a> <span class="n">materialized</span> <span class="o">=</span> <span class="s2">" MATERIALIZED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"materialized"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-837"><a href="#Generator-837"><span class="linenos"> 837</span></a> <span class="n">cascade</span> <span class="o">=</span> <span class="s2">" CASCADE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"cascade"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-838"><a href="#Generator-838"><span class="linenos"> 838</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="s2">" CONSTRAINTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"constraints"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-839"><a href="#Generator-839"><span class="linenos"> 839</span></a> <span class="n">purge</span> <span class="o">=</span> <span class="s2">" PURGE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"purge"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-840"><a href="#Generator-840"><span class="linenos"> 840</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="Generator-841"><a href="#Generator-841"><span class="linenos"> 841</span></a> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">temporary</span><span class="si">}{</span><span class="n">materialized</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">exists_sql</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">cascade</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">purge</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-842"><a href="#Generator-842"><span class="linenos"> 842</span></a> <span class="p">)</span> </span><span id="Generator-843"><a href="#Generator-843"><span class="linenos"> 843</span></a> -</span><span id="Generator-844"><a href="#Generator-844"><span class="linenos"> 844</span></a> <span class="k">def</span> <span class="nf">fetch_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-845"><a href="#Generator-845"><span class="linenos"> 845</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"direction"</span><span class="p">)</span> -</span><span id="Generator-846"><a href="#Generator-846"><span class="linenos"> 846</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">direction</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">direction</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-847"><a href="#Generator-847"><span class="linenos"> 847</span></a> <span class="n">count</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"count"</span><span class="p">)</span> -</span><span id="Generator-848"><a href="#Generator-848"><span class="linenos"> 848</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">count</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-849"><a href="#Generator-849"><span class="linenos"> 849</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"percent"</span><span class="p">):</span> -</span><span id="Generator-850"><a href="#Generator-850"><span class="linenos"> 850</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2"> PERCENT"</span> -</span><span id="Generator-851"><a href="#Generator-851"><span class="linenos"> 851</span></a> <span class="n">with_ties_or_only</span> <span class="o">=</span> <span class="s2">"WITH TIES"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"with_ties"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ONLY"</span> -</span><span id="Generator-852"><a href="#Generator-852"><span class="linenos"> 852</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'FETCH'</span><span class="p">)</span><span class="si">}{</span><span class="n">direction</span><span class="si">}{</span><span class="n">count</span><span class="si">}</span><span class="s2"> ROWS </span><span class="si">{</span><span class="n">with_ties_or_only</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-853"><a href="#Generator-853"><span class="linenos"> 853</span></a> -</span><span id="Generator-854"><a href="#Generator-854"><span class="linenos"> 854</span></a> <span class="k">def</span> <span class="nf">filter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Filter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-855"><a href="#Generator-855"><span class="linenos"> 855</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-856"><a href="#Generator-856"><span class="linenos"> 856</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)[</span><span class="mi">1</span><span class="p">:]</span> <span class="c1"># where has a leading space</span> -</span><span id="Generator-857"><a href="#Generator-857"><span class="linenos"> 857</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FILTER(</span><span class="si">{</span><span class="n">where</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-858"><a href="#Generator-858"><span class="linenos"> 858</span></a> -</span><span id="Generator-859"><a href="#Generator-859"><span class="linenos"> 859</span></a> <span class="k">def</span> <span class="nf">hint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-860"><a href="#Generator-860"><span class="linenos"> 860</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">):</span> -</span><span id="Generator-861"><a href="#Generator-861"><span class="linenos"> 861</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Hints are not supported"</span><span class="p">)</span> -</span><span id="Generator-862"><a href="#Generator-862"><span class="linenos"> 862</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator-863"><a href="#Generator-863"><span class="linenos"> 863</span></a> -</span><span id="Generator-864"><a href="#Generator-864"><span class="linenos"> 864</span></a> <span class="k">def</span> <span class="nf">index_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Index</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-865"><a href="#Generator-865"><span class="linenos"> 865</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">"UNIQUE "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-866"><a href="#Generator-866"><span class="linenos"> 866</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="s2">"PRIMARY "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"primary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-867"><a href="#Generator-867"><span class="linenos"> 867</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="s2">"AMP "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"amp"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-868"><a href="#Generator-868"><span class="linenos"> 868</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-869"><a href="#Generator-869"><span class="linenos"> 869</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"table"</span><span class="p">)</span> -</span><span id="Generator-870"><a href="#Generator-870"><span class="linenos"> 870</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">INDEX_ON</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">table</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-871"><a href="#Generator-871"><span class="linenos"> 871</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> -</span><span id="Generator-872"><a href="#Generator-872"><span class="linenos"> 872</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-873"><a href="#Generator-873"><span class="linenos"> 873</span></a> <span class="n">index</span> <span class="o">=</span> <span class="s2">"INDEX "</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-874"><a href="#Generator-874"><span class="linenos"> 874</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-875"><a href="#Generator-875"><span class="linenos"> 875</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-876"><a href="#Generator-876"><span class="linenos"> 876</span></a> <span class="n">partition_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"partition_by"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-877"><a href="#Generator-877"><span class="linenos"> 877</span></a> <span class="n">partition_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" PARTITION BY </span><span class="si">{</span><span class="n">partition_by</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition_by</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-878"><a href="#Generator-878"><span class="linenos"> 878</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">unique</span><span class="si">}{</span><span class="n">primary</span><span class="si">}{</span><span class="n">amp</span><span class="si">}{</span><span class="n">index</span><span class="si">}{</span><span class="n">name</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">columns</span><span class="si">}{</span><span class="n">partition_by</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-879"><a href="#Generator-879"><span class="linenos"> 879</span></a> -</span><span id="Generator-880"><a href="#Generator-880"><span class="linenos"> 880</span></a> <span class="k">def</span> <span class="nf">identifier_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-881"><a href="#Generator-881"><span class="linenos"> 881</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> -</span><span id="Generator-882"><a href="#Generator-882"><span class="linenos"> 882</span></a> <span class="n">lower</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="Generator-883"><a href="#Generator-883"><span class="linenos"> 883</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">lower</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> <span class="k">else</span> <span class="n">text</span> -</span><span id="Generator-884"><a href="#Generator-884"><span class="linenos"> 884</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">)</span> -</span><span id="Generator-885"><a href="#Generator-885"><span class="linenos"> 885</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="Generator-886"><a href="#Generator-886"><span class="linenos"> 886</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> -</span><span id="Generator-887"><a href="#Generator-887"><span class="linenos"> 887</span></a> <span class="ow">or</span> <span class="n">should_identify</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span><span class="p">)</span> -</span><span id="Generator-888"><a href="#Generator-888"><span class="linenos"> 888</span></a> <span class="ow">or</span> <span class="n">lower</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span> -</span><span id="Generator-889"><a href="#Generator-889"><span class="linenos"> 889</span></a> <span class="ow">or</span> <span class="p">(</span><span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="ow">and</span> <span class="n">text</span><span class="p">[:</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">isdigit</span><span class="p">())</span> -</span><span id="Generator-890"><a href="#Generator-890"><span class="linenos"> 890</span></a> <span class="p">):</span> -</span><span id="Generator-891"><a href="#Generator-891"><span class="linenos"> 891</span></a> <span class="n">text</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_START</span><span class="si">}{</span><span class="n">text</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-892"><a href="#Generator-892"><span class="linenos"> 892</span></a> <span class="k">return</span> <span class="n">text</span> -</span><span id="Generator-893"><a href="#Generator-893"><span class="linenos"> 893</span></a> -</span><span id="Generator-894"><a href="#Generator-894"><span class="linenos"> 894</span></a> <span class="k">def</span> <span class="nf">inputoutputformat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-895"><a href="#Generator-895"><span class="linenos"> 895</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> -</span><span id="Generator-896"><a href="#Generator-896"><span class="linenos"> 896</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-897"><a href="#Generator-897"><span class="linenos"> 897</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"output_format"</span><span class="p">)</span> -</span><span id="Generator-898"><a href="#Generator-898"><span class="linenos"> 898</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OUTPUTFORMAT </span><span class="si">{</span><span class="n">output_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">output_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-899"><a href="#Generator-899"><span class="linenos"> 899</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">input_format</span><span class="p">,</span> <span class="n">output_format</span><span class="p">))</span> -</span><span id="Generator-900"><a href="#Generator-900"><span class="linenos"> 900</span></a> -</span><span id="Generator-901"><a href="#Generator-901"><span class="linenos"> 901</span></a> <span class="k">def</span> <span class="nf">national_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">National</span><span class="p">,</span> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"N"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-902"><a href="#Generator-902"><span class="linenos"> 902</span></a> <span class="n">string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> -</span><span id="Generator-903"><a href="#Generator-903"><span class="linenos"> 903</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">string</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-904"><a href="#Generator-904"><span class="linenos"> 904</span></a> -</span><span id="Generator-905"><a href="#Generator-905"><span class="linenos"> 905</span></a> <span class="k">def</span> <span class="nf">partition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Partition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-906"><a href="#Generator-906"><span class="linenos"> 906</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-907"><a href="#Generator-907"><span class="linenos"> 907</span></a> -</span><span id="Generator-908"><a href="#Generator-908"><span class="linenos"> 908</span></a> <span class="k">def</span> <span class="nf">properties_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-909"><a href="#Generator-909"><span class="linenos"> 909</span></a> <span class="n">root_properties</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator-910"><a href="#Generator-910"><span class="linenos"> 910</span></a> <span class="n">with_properties</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator-911"><a href="#Generator-911"><span class="linenos"> 911</span></a> -</span><span id="Generator-912"><a href="#Generator-912"><span class="linenos"> 912</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator-913"><a href="#Generator-913"><span class="linenos"> 913</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> -</span><span id="Generator-914"><a href="#Generator-914"><span class="linenos"> 914</span></a> <span class="k">if</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">:</span> -</span><span id="Generator-915"><a href="#Generator-915"><span class="linenos"> 915</span></a> <span class="n">with_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator-916"><a href="#Generator-916"><span class="linenos"> 916</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">:</span> -</span><span id="Generator-917"><a href="#Generator-917"><span class="linenos"> 917</span></a> <span class="n">root_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator-918"><a href="#Generator-918"><span class="linenos"> 918</span></a> -</span><span id="Generator-919"><a href="#Generator-919"><span class="linenos"> 919</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_properties</span><span class="p">(</span> -</span><span id="Generator-920"><a href="#Generator-920"><span class="linenos"> 920</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">root_properties</span><span class="p">)</span> -</span><span id="Generator-921"><a href="#Generator-921"><span class="linenos"> 921</span></a> <span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">with_properties</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">with_properties</span><span class="p">))</span> -</span><span id="Generator-922"><a href="#Generator-922"><span class="linenos"> 922</span></a> -</span><span id="Generator-923"><a href="#Generator-923"><span class="linenos"> 923</span></a> <span class="k">def</span> <span class="nf">root_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-924"><a href="#Generator-924"><span class="linenos"> 924</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator-925"><a href="#Generator-925"><span class="linenos"> 925</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator-926"><a href="#Generator-926"><span class="linenos"> 926</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator-844"><a href="#Generator-844"><span class="linenos"> 844</span></a> <span class="k">def</span> <span class="nf">except_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-845"><a href="#Generator-845"><span class="linenos"> 845</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span> +</span><span id="Generator-846"><a href="#Generator-846"><span class="linenos"> 846</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator-847"><a href="#Generator-847"><span class="linenos"> 847</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> +</span><span id="Generator-848"><a href="#Generator-848"><span class="linenos"> 848</span></a> <span class="p">)</span> +</span><span id="Generator-849"><a href="#Generator-849"><span class="linenos"> 849</span></a> +</span><span id="Generator-850"><a href="#Generator-850"><span class="linenos"> 850</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-851"><a href="#Generator-851"><span class="linenos"> 851</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">''</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-852"><a href="#Generator-852"><span class="linenos"> 852</span></a> +</span><span id="Generator-853"><a href="#Generator-853"><span class="linenos"> 853</span></a> <span class="k">def</span> <span class="nf">fetch_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-854"><a href="#Generator-854"><span class="linenos"> 854</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"direction"</span><span class="p">)</span> +</span><span id="Generator-855"><a href="#Generator-855"><span class="linenos"> 855</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">direction</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">direction</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-856"><a href="#Generator-856"><span class="linenos"> 856</span></a> <span class="n">count</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"count"</span><span class="p">)</span> +</span><span id="Generator-857"><a href="#Generator-857"><span class="linenos"> 857</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">count</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-858"><a href="#Generator-858"><span class="linenos"> 858</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"percent"</span><span class="p">):</span> +</span><span id="Generator-859"><a href="#Generator-859"><span class="linenos"> 859</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2"> PERCENT"</span> +</span><span id="Generator-860"><a href="#Generator-860"><span class="linenos"> 860</span></a> <span class="n">with_ties_or_only</span> <span class="o">=</span> <span class="s2">"WITH TIES"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"with_ties"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ONLY"</span> +</span><span id="Generator-861"><a href="#Generator-861"><span class="linenos"> 861</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'FETCH'</span><span class="p">)</span><span class="si">}{</span><span class="n">direction</span><span class="si">}{</span><span class="n">count</span><span class="si">}</span><span class="s2"> ROWS </span><span class="si">{</span><span class="n">with_ties_or_only</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-862"><a href="#Generator-862"><span class="linenos"> 862</span></a> +</span><span id="Generator-863"><a href="#Generator-863"><span class="linenos"> 863</span></a> <span class="k">def</span> <span class="nf">filter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Filter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-864"><a href="#Generator-864"><span class="linenos"> 864</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-865"><a href="#Generator-865"><span class="linenos"> 865</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)[</span><span class="mi">1</span><span class="p">:]</span> <span class="c1"># where has a leading space</span> +</span><span id="Generator-866"><a href="#Generator-866"><span class="linenos"> 866</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FILTER(</span><span class="si">{</span><span class="n">where</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-867"><a href="#Generator-867"><span class="linenos"> 867</span></a> +</span><span id="Generator-868"><a href="#Generator-868"><span class="linenos"> 868</span></a> <span class="k">def</span> <span class="nf">hint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-869"><a href="#Generator-869"><span class="linenos"> 869</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">):</span> +</span><span id="Generator-870"><a href="#Generator-870"><span class="linenos"> 870</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Hints are not supported"</span><span class="p">)</span> +</span><span id="Generator-871"><a href="#Generator-871"><span class="linenos"> 871</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator-872"><a href="#Generator-872"><span class="linenos"> 872</span></a> +</span><span id="Generator-873"><a href="#Generator-873"><span class="linenos"> 873</span></a> <span class="k">def</span> <span class="nf">index_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Index</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-874"><a href="#Generator-874"><span class="linenos"> 874</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">"UNIQUE "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-875"><a href="#Generator-875"><span class="linenos"> 875</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="s2">"PRIMARY "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"primary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-876"><a href="#Generator-876"><span class="linenos"> 876</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="s2">"AMP "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"amp"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-877"><a href="#Generator-877"><span class="linenos"> 877</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-878"><a href="#Generator-878"><span class="linenos"> 878</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"table"</span><span class="p">)</span> +</span><span id="Generator-879"><a href="#Generator-879"><span class="linenos"> 879</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">INDEX_ON</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">table</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-880"><a href="#Generator-880"><span class="linenos"> 880</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> +</span><span id="Generator-881"><a href="#Generator-881"><span class="linenos"> 881</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-882"><a href="#Generator-882"><span class="linenos"> 882</span></a> <span class="n">index</span> <span class="o">=</span> <span class="s2">"INDEX "</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-883"><a href="#Generator-883"><span class="linenos"> 883</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-884"><a href="#Generator-884"><span class="linenos"> 884</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-885"><a href="#Generator-885"><span class="linenos"> 885</span></a> <span class="n">partition_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"partition_by"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-886"><a href="#Generator-886"><span class="linenos"> 886</span></a> <span class="n">partition_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" PARTITION BY </span><span class="si">{</span><span class="n">partition_by</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition_by</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-887"><a href="#Generator-887"><span class="linenos"> 887</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">unique</span><span class="si">}{</span><span class="n">primary</span><span class="si">}{</span><span class="n">amp</span><span class="si">}{</span><span class="n">index</span><span class="si">}{</span><span class="n">name</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">columns</span><span class="si">}{</span><span class="n">partition_by</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-888"><a href="#Generator-888"><span class="linenos"> 888</span></a> +</span><span id="Generator-889"><a href="#Generator-889"><span class="linenos"> 889</span></a> <span class="k">def</span> <span class="nf">identifier_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-890"><a href="#Generator-890"><span class="linenos"> 890</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> +</span><span id="Generator-891"><a href="#Generator-891"><span class="linenos"> 891</span></a> <span class="n">lower</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> +</span><span id="Generator-892"><a href="#Generator-892"><span class="linenos"> 892</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">lower</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> <span class="k">else</span> <span class="n">text</span> +</span><span id="Generator-893"><a href="#Generator-893"><span class="linenos"> 893</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">)</span> +</span><span id="Generator-894"><a href="#Generator-894"><span class="linenos"> 894</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="Generator-895"><a href="#Generator-895"><span class="linenos"> 895</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> +</span><span id="Generator-896"><a href="#Generator-896"><span class="linenos"> 896</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">can_identify</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span><span class="p">)</span> +</span><span id="Generator-897"><a href="#Generator-897"><span class="linenos"> 897</span></a> <span class="ow">or</span> <span class="n">lower</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span> +</span><span id="Generator-898"><a href="#Generator-898"><span class="linenos"> 898</span></a> <span class="ow">or</span> <span class="p">(</span><span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="ow">and</span> <span class="n">text</span><span class="p">[:</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">isdigit</span><span class="p">())</span> +</span><span id="Generator-899"><a href="#Generator-899"><span class="linenos"> 899</span></a> <span class="p">):</span> +</span><span id="Generator-900"><a href="#Generator-900"><span class="linenos"> 900</span></a> <span class="n">text</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_START</span><span class="si">}{</span><span class="n">text</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-901"><a href="#Generator-901"><span class="linenos"> 901</span></a> <span class="k">return</span> <span class="n">text</span> +</span><span id="Generator-902"><a href="#Generator-902"><span class="linenos"> 902</span></a> +</span><span id="Generator-903"><a href="#Generator-903"><span class="linenos"> 903</span></a> <span class="k">def</span> <span class="nf">inputoutputformat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-904"><a href="#Generator-904"><span class="linenos"> 904</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> +</span><span id="Generator-905"><a href="#Generator-905"><span class="linenos"> 905</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-906"><a href="#Generator-906"><span class="linenos"> 906</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"output_format"</span><span class="p">)</span> +</span><span id="Generator-907"><a href="#Generator-907"><span class="linenos"> 907</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OUTPUTFORMAT </span><span class="si">{</span><span class="n">output_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">output_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-908"><a href="#Generator-908"><span class="linenos"> 908</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">input_format</span><span class="p">,</span> <span class="n">output_format</span><span class="p">))</span> +</span><span id="Generator-909"><a href="#Generator-909"><span class="linenos"> 909</span></a> +</span><span id="Generator-910"><a href="#Generator-910"><span class="linenos"> 910</span></a> <span class="k">def</span> <span class="nf">national_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">National</span><span class="p">,</span> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"N"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-911"><a href="#Generator-911"><span class="linenos"> 911</span></a> <span class="n">string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> +</span><span id="Generator-912"><a href="#Generator-912"><span class="linenos"> 912</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">string</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-913"><a href="#Generator-913"><span class="linenos"> 913</span></a> +</span><span id="Generator-914"><a href="#Generator-914"><span class="linenos"> 914</span></a> <span class="k">def</span> <span class="nf">partition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Partition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-915"><a href="#Generator-915"><span class="linenos"> 915</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-916"><a href="#Generator-916"><span class="linenos"> 916</span></a> +</span><span id="Generator-917"><a href="#Generator-917"><span class="linenos"> 917</span></a> <span class="k">def</span> <span class="nf">properties_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-918"><a href="#Generator-918"><span class="linenos"> 918</span></a> <span class="n">root_properties</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator-919"><a href="#Generator-919"><span class="linenos"> 919</span></a> <span class="n">with_properties</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator-920"><a href="#Generator-920"><span class="linenos"> 920</span></a> +</span><span id="Generator-921"><a href="#Generator-921"><span class="linenos"> 921</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator-922"><a href="#Generator-922"><span class="linenos"> 922</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> +</span><span id="Generator-923"><a href="#Generator-923"><span class="linenos"> 923</span></a> <span class="k">if</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">:</span> +</span><span id="Generator-924"><a href="#Generator-924"><span class="linenos"> 924</span></a> <span class="n">with_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator-925"><a href="#Generator-925"><span class="linenos"> 925</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">:</span> +</span><span id="Generator-926"><a href="#Generator-926"><span class="linenos"> 926</span></a> <span class="n">root_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> </span><span id="Generator-927"><a href="#Generator-927"><span class="linenos"> 927</span></a> -</span><span id="Generator-928"><a href="#Generator-928"><span class="linenos"> 928</span></a> <span class="k">def</span> <span class="nf">properties</span><span class="p">(</span> -</span><span id="Generator-929"><a href="#Generator-929"><span class="linenos"> 929</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator-930"><a href="#Generator-930"><span class="linenos"> 930</span></a> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">,</span> -</span><span id="Generator-931"><a href="#Generator-931"><span class="linenos"> 931</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="Generator-932"><a href="#Generator-932"><span class="linenos"> 932</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">,</span> -</span><span id="Generator-933"><a href="#Generator-933"><span class="linenos"> 933</span></a> <span class="n">suffix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="Generator-934"><a href="#Generator-934"><span class="linenos"> 934</span></a> <span class="n">wrapped</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Generator-935"><a href="#Generator-935"><span class="linenos"> 935</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-936"><a href="#Generator-936"><span class="linenos"> 936</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator-937"><a href="#Generator-937"><span class="linenos"> 937</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator-938"><a href="#Generator-938"><span class="linenos"> 938</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">wrapped</span> <span class="k">else</span> <span class="n">expressions</span> -</span><span id="Generator-939"><a href="#Generator-939"><span class="linenos"> 939</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="s1">' '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">prefix</span><span class="w"> </span><span class="ow">and</span><span class="w"> </span><span class="n">prefix</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="s1">' '</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-940"><a href="#Generator-940"><span class="linenos"> 940</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator-941"><a href="#Generator-941"><span class="linenos"> 941</span></a> -</span><span id="Generator-942"><a href="#Generator-942"><span class="linenos"> 942</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-943"><a href="#Generator-943"><span class="linenos"> 943</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">))</span> -</span><span id="Generator-944"><a href="#Generator-944"><span class="linenos"> 944</span></a> -</span><span id="Generator-945"><a href="#Generator-945"><span class="linenos"> 945</span></a> <span class="k">def</span> <span class="nf">locate_properties</span><span class="p">(</span> -</span><span id="Generator-946"><a href="#Generator-946"><span class="linenos"> 946</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span> -</span><span id="Generator-947"><a href="#Generator-947"><span class="linenos"> 947</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">]]:</span> -</span><span id="Generator-948"><a href="#Generator-948"><span class="linenos"> 948</span></a> <span class="n">properties_locs</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Generator-949"><a href="#Generator-949"><span class="linenos"> 949</span></a> <span class="n">key</span><span class="p">:</span> <span class="p">[]</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span> -</span><span id="Generator-950"><a href="#Generator-950"><span class="linenos"> 950</span></a> <span class="p">}</span> -</span><span id="Generator-951"><a href="#Generator-951"><span class="linenos"> 951</span></a> -</span><span id="Generator-952"><a href="#Generator-952"><span class="linenos"> 952</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator-953"><a href="#Generator-953"><span class="linenos"> 953</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> -</span><span id="Generator-954"><a href="#Generator-954"><span class="linenos"> 954</span></a> <span class="k">if</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">:</span> -</span><span id="Generator-955"><a href="#Generator-955"><span class="linenos"> 955</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator-956"><a href="#Generator-956"><span class="linenos"> 956</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">:</span> -</span><span id="Generator-957"><a href="#Generator-957"><span class="linenos"> 957</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator-958"><a href="#Generator-958"><span class="linenos"> 958</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">:</span> -</span><span id="Generator-959"><a href="#Generator-959"><span class="linenos"> 959</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator-960"><a href="#Generator-960"><span class="linenos"> 960</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">:</span> -</span><span id="Generator-961"><a href="#Generator-961"><span class="linenos"> 961</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator-962"><a href="#Generator-962"><span class="linenos"> 962</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">:</span> -</span><span id="Generator-963"><a href="#Generator-963"><span class="linenos"> 963</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator-964"><a href="#Generator-964"><span class="linenos"> 964</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">:</span> -</span><span id="Generator-965"><a href="#Generator-965"><span class="linenos"> 965</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator-966"><a href="#Generator-966"><span class="linenos"> 966</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">:</span> -</span><span id="Generator-967"><a href="#Generator-967"><span class="linenos"> 967</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator-968"><a href="#Generator-968"><span class="linenos"> 968</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">:</span> -</span><span id="Generator-969"><a href="#Generator-969"><span class="linenos"> 969</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">p</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-970"><a href="#Generator-970"><span class="linenos"> 970</span></a> -</span><span id="Generator-971"><a href="#Generator-971"><span class="linenos"> 971</span></a> <span class="k">return</span> <span class="n">properties_locs</span> -</span><span id="Generator-972"><a href="#Generator-972"><span class="linenos"> 972</span></a> -</span><span id="Generator-973"><a href="#Generator-973"><span class="linenos"> 973</span></a> <span class="k">def</span> <span class="nf">property_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-974"><a href="#Generator-974"><span class="linenos"> 974</span></a> <span class="n">property_cls</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span> -</span><span id="Generator-975"><a href="#Generator-975"><span class="linenos"> 975</span></a> <span class="k">if</span> <span class="n">property_cls</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> -</span><span id="Generator-976"><a href="#Generator-976"><span class="linenos"> 976</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-977"><a href="#Generator-977"><span class="linenos"> 977</span></a> -</span><span id="Generator-978"><a href="#Generator-978"><span class="linenos"> 978</span></a> <span class="n">property_name</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">PROPERTY_TO_NAME</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">property_cls</span><span class="p">)</span> -</span><span id="Generator-979"><a href="#Generator-979"><span class="linenos"> 979</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">property_name</span><span class="p">:</span> -</span><span id="Generator-980"><a href="#Generator-980"><span class="linenos"> 980</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-928"><a href="#Generator-928"><span class="linenos"> 928</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_properties</span><span class="p">(</span> +</span><span id="Generator-929"><a href="#Generator-929"><span class="linenos"> 929</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">root_properties</span><span class="p">)</span> +</span><span id="Generator-930"><a href="#Generator-930"><span class="linenos"> 930</span></a> <span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">with_properties</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">with_properties</span><span class="p">))</span> +</span><span id="Generator-931"><a href="#Generator-931"><span class="linenos"> 931</span></a> +</span><span id="Generator-932"><a href="#Generator-932"><span class="linenos"> 932</span></a> <span class="k">def</span> <span class="nf">root_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-933"><a href="#Generator-933"><span class="linenos"> 933</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator-934"><a href="#Generator-934"><span class="linenos"> 934</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator-935"><a href="#Generator-935"><span class="linenos"> 935</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator-936"><a href="#Generator-936"><span class="linenos"> 936</span></a> +</span><span id="Generator-937"><a href="#Generator-937"><span class="linenos"> 937</span></a> <span class="k">def</span> <span class="nf">properties</span><span class="p">(</span> +</span><span id="Generator-938"><a href="#Generator-938"><span class="linenos"> 938</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator-939"><a href="#Generator-939"><span class="linenos"> 939</span></a> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">,</span> +</span><span id="Generator-940"><a href="#Generator-940"><span class="linenos"> 940</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="Generator-941"><a href="#Generator-941"><span class="linenos"> 941</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">,</span> +</span><span id="Generator-942"><a href="#Generator-942"><span class="linenos"> 942</span></a> <span class="n">suffix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="Generator-943"><a href="#Generator-943"><span class="linenos"> 943</span></a> <span class="n">wrapped</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Generator-944"><a href="#Generator-944"><span class="linenos"> 944</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-945"><a href="#Generator-945"><span class="linenos"> 945</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator-946"><a href="#Generator-946"><span class="linenos"> 946</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator-947"><a href="#Generator-947"><span class="linenos"> 947</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">wrapped</span> <span class="k">else</span> <span class="n">expressions</span> +</span><span id="Generator-948"><a href="#Generator-948"><span class="linenos"> 948</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="s1">' '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">prefix</span><span class="w"> </span><span class="ow">and</span><span class="w"> </span><span class="n">prefix</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="s1">' '</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-949"><a href="#Generator-949"><span class="linenos"> 949</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator-950"><a href="#Generator-950"><span class="linenos"> 950</span></a> +</span><span id="Generator-951"><a href="#Generator-951"><span class="linenos"> 951</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-952"><a href="#Generator-952"><span class="linenos"> 952</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">))</span> +</span><span id="Generator-953"><a href="#Generator-953"><span class="linenos"> 953</span></a> +</span><span id="Generator-954"><a href="#Generator-954"><span class="linenos"> 954</span></a> <span class="k">def</span> <span class="nf">locate_properties</span><span class="p">(</span> +</span><span id="Generator-955"><a href="#Generator-955"><span class="linenos"> 955</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span> +</span><span id="Generator-956"><a href="#Generator-956"><span class="linenos"> 956</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">]]:</span> +</span><span id="Generator-957"><a href="#Generator-957"><span class="linenos"> 957</span></a> <span class="n">properties_locs</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Generator-958"><a href="#Generator-958"><span class="linenos"> 958</span></a> <span class="n">key</span><span class="p">:</span> <span class="p">[]</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span> +</span><span id="Generator-959"><a href="#Generator-959"><span class="linenos"> 959</span></a> <span class="p">}</span> +</span><span id="Generator-960"><a href="#Generator-960"><span class="linenos"> 960</span></a> +</span><span id="Generator-961"><a href="#Generator-961"><span class="linenos"> 961</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator-962"><a href="#Generator-962"><span class="linenos"> 962</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> +</span><span id="Generator-963"><a href="#Generator-963"><span class="linenos"> 963</span></a> <span class="k">if</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">:</span> +</span><span id="Generator-964"><a href="#Generator-964"><span class="linenos"> 964</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator-965"><a href="#Generator-965"><span class="linenos"> 965</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">:</span> +</span><span id="Generator-966"><a href="#Generator-966"><span class="linenos"> 966</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator-967"><a href="#Generator-967"><span class="linenos"> 967</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">:</span> +</span><span id="Generator-968"><a href="#Generator-968"><span class="linenos"> 968</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator-969"><a href="#Generator-969"><span class="linenos"> 969</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">:</span> +</span><span id="Generator-970"><a href="#Generator-970"><span class="linenos"> 970</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator-971"><a href="#Generator-971"><span class="linenos"> 971</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">:</span> +</span><span id="Generator-972"><a href="#Generator-972"><span class="linenos"> 972</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator-973"><a href="#Generator-973"><span class="linenos"> 973</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">:</span> +</span><span id="Generator-974"><a href="#Generator-974"><span class="linenos"> 974</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator-975"><a href="#Generator-975"><span class="linenos"> 975</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">:</span> +</span><span id="Generator-976"><a href="#Generator-976"><span class="linenos"> 976</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator-977"><a href="#Generator-977"><span class="linenos"> 977</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">:</span> +</span><span id="Generator-978"><a href="#Generator-978"><span class="linenos"> 978</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">p</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-979"><a href="#Generator-979"><span class="linenos"> 979</span></a> +</span><span id="Generator-980"><a href="#Generator-980"><span class="linenos"> 980</span></a> <span class="k">return</span> <span class="n">properties_locs</span> </span><span id="Generator-981"><a href="#Generator-981"><span class="linenos"> 981</span></a> -</span><span id="Generator-982"><a href="#Generator-982"><span class="linenos"> 982</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">property_name</span><span class="si">}</span><span class="s2">=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-983"><a href="#Generator-983"><span class="linenos"> 983</span></a> -</span><span id="Generator-984"><a href="#Generator-984"><span class="linenos"> 984</span></a> <span class="k">def</span> <span class="nf">likeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-985"><a href="#Generator-985"><span class="linenos"> 985</span></a> <span class="n">options</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Generator-986"><a href="#Generator-986"><span class="linenos"> 986</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-987"><a href="#Generator-987"><span class="linenos"> 987</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LIKE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-988"><a href="#Generator-988"><span class="linenos"> 988</span></a> -</span><span id="Generator-989"><a href="#Generator-989"><span class="linenos"> 989</span></a> <span class="k">def</span> <span class="nf">fallbackproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-990"><a href="#Generator-990"><span class="linenos"> 990</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-991"><a href="#Generator-991"><span class="linenos"> 991</span></a> <span class="n">protection</span> <span class="o">=</span> <span class="s2">" PROTECTION"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"protection"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-992"><a href="#Generator-992"><span class="linenos"> 992</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}</span><span class="s2">FALLBACK</span><span class="si">{</span><span class="n">protection</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-993"><a href="#Generator-993"><span class="linenos"> 993</span></a> -</span><span id="Generator-994"><a href="#Generator-994"><span class="linenos"> 994</span></a> <span class="k">def</span> <span class="nf">journalproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-995"><a href="#Generator-995"><span class="linenos"> 995</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-996"><a href="#Generator-996"><span class="linenos"> 996</span></a> <span class="n">local</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"local"</span><span class="p">)</span> -</span><span id="Generator-997"><a href="#Generator-997"><span class="linenos"> 997</span></a> <span class="n">local</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">local</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-998"><a href="#Generator-998"><span class="linenos"> 998</span></a> <span class="n">dual</span> <span class="o">=</span> <span class="s2">"DUAL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"dual"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-999"><a href="#Generator-999"><span class="linenos"> 999</span></a> <span class="n">before</span> <span class="o">=</span> <span class="s2">"BEFORE "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"before"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1000"><a href="#Generator-1000"><span class="linenos">1000</span></a> <span class="n">after</span> <span class="o">=</span> <span class="s2">"AFTER "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"after"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1001"><a href="#Generator-1001"><span class="linenos">1001</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">local</span><span class="si">}{</span><span class="n">dual</span><span class="si">}{</span><span class="n">before</span><span class="si">}{</span><span class="n">after</span><span class="si">}</span><span class="s2">JOURNAL"</span> +</span><span id="Generator-982"><a href="#Generator-982"><span class="linenos"> 982</span></a> <span class="k">def</span> <span class="nf">property_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-983"><a href="#Generator-983"><span class="linenos"> 983</span></a> <span class="n">property_cls</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span> +</span><span id="Generator-984"><a href="#Generator-984"><span class="linenos"> 984</span></a> <span class="k">if</span> <span class="n">property_cls</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> +</span><span id="Generator-985"><a href="#Generator-985"><span class="linenos"> 985</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-986"><a href="#Generator-986"><span class="linenos"> 986</span></a> +</span><span id="Generator-987"><a href="#Generator-987"><span class="linenos"> 987</span></a> <span class="n">property_name</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">PROPERTY_TO_NAME</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">property_cls</span><span class="p">)</span> +</span><span id="Generator-988"><a href="#Generator-988"><span class="linenos"> 988</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">property_name</span><span class="p">:</span> +</span><span id="Generator-989"><a href="#Generator-989"><span class="linenos"> 989</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-990"><a href="#Generator-990"><span class="linenos"> 990</span></a> +</span><span id="Generator-991"><a href="#Generator-991"><span class="linenos"> 991</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">property_name</span><span class="si">}</span><span class="s2">=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-992"><a href="#Generator-992"><span class="linenos"> 992</span></a> +</span><span id="Generator-993"><a href="#Generator-993"><span class="linenos"> 993</span></a> <span class="k">def</span> <span class="nf">likeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-994"><a href="#Generator-994"><span class="linenos"> 994</span></a> <span class="n">options</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator-995"><a href="#Generator-995"><span class="linenos"> 995</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-996"><a href="#Generator-996"><span class="linenos"> 996</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LIKE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-997"><a href="#Generator-997"><span class="linenos"> 997</span></a> +</span><span id="Generator-998"><a href="#Generator-998"><span class="linenos"> 998</span></a> <span class="k">def</span> <span class="nf">fallbackproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-999"><a href="#Generator-999"><span class="linenos"> 999</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1000"><a href="#Generator-1000"><span class="linenos">1000</span></a> <span class="n">protection</span> <span class="o">=</span> <span class="s2">" PROTECTION"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"protection"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1001"><a href="#Generator-1001"><span class="linenos">1001</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}</span><span class="s2">FALLBACK</span><span class="si">{</span><span class="n">protection</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-1002"><a href="#Generator-1002"><span class="linenos">1002</span></a> -</span><span id="Generator-1003"><a href="#Generator-1003"><span class="linenos">1003</span></a> <span class="k">def</span> <span class="nf">freespaceproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1004"><a href="#Generator-1004"><span class="linenos">1004</span></a> <span class="n">freespace</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1005"><a href="#Generator-1005"><span class="linenos">1005</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1006"><a href="#Generator-1006"><span class="linenos">1006</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FREESPACE=</span><span class="si">{</span><span class="n">freespace</span><span class="si">}{</span><span class="n">percent</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1007"><a href="#Generator-1007"><span class="linenos">1007</span></a> -</span><span id="Generator-1008"><a href="#Generator-1008"><span class="linenos">1008</span></a> <span class="k">def</span> <span class="nf">checksumproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1009"><a href="#Generator-1009"><span class="linenos">1009</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">):</span> -</span><span id="Generator-1010"><a href="#Generator-1010"><span class="linenos">1010</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> -</span><span id="Generator-1011"><a href="#Generator-1011"><span class="linenos">1011</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on"</span><span class="p">):</span> -</span><span id="Generator-1012"><a href="#Generator-1012"><span class="linenos">1012</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"ON"</span> -</span><span id="Generator-1013"><a href="#Generator-1013"><span class="linenos">1013</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1014"><a href="#Generator-1014"><span class="linenos">1014</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"OFF"</span> -</span><span id="Generator-1015"><a href="#Generator-1015"><span class="linenos">1015</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECKSUM=</span><span class="si">{</span><span class="nb">property</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1003"><a href="#Generator-1003"><span class="linenos">1003</span></a> <span class="k">def</span> <span class="nf">journalproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1004"><a href="#Generator-1004"><span class="linenos">1004</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1005"><a href="#Generator-1005"><span class="linenos">1005</span></a> <span class="n">local</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"local"</span><span class="p">)</span> +</span><span id="Generator-1006"><a href="#Generator-1006"><span class="linenos">1006</span></a> <span class="n">local</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">local</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1007"><a href="#Generator-1007"><span class="linenos">1007</span></a> <span class="n">dual</span> <span class="o">=</span> <span class="s2">"DUAL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"dual"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1008"><a href="#Generator-1008"><span class="linenos">1008</span></a> <span class="n">before</span> <span class="o">=</span> <span class="s2">"BEFORE "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"before"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1009"><a href="#Generator-1009"><span class="linenos">1009</span></a> <span class="n">after</span> <span class="o">=</span> <span class="s2">"AFTER "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"after"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1010"><a href="#Generator-1010"><span class="linenos">1010</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">local</span><span class="si">}{</span><span class="n">dual</span><span class="si">}{</span><span class="n">before</span><span class="si">}{</span><span class="n">after</span><span class="si">}</span><span class="s2">JOURNAL"</span> +</span><span id="Generator-1011"><a href="#Generator-1011"><span class="linenos">1011</span></a> +</span><span id="Generator-1012"><a href="#Generator-1012"><span class="linenos">1012</span></a> <span class="k">def</span> <span class="nf">freespaceproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1013"><a href="#Generator-1013"><span class="linenos">1013</span></a> <span class="n">freespace</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1014"><a href="#Generator-1014"><span class="linenos">1014</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1015"><a href="#Generator-1015"><span class="linenos">1015</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FREESPACE=</span><span class="si">{</span><span class="n">freespace</span><span class="si">}{</span><span class="n">percent</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-1016"><a href="#Generator-1016"><span class="linenos">1016</span></a> -</span><span id="Generator-1017"><a href="#Generator-1017"><span class="linenos">1017</span></a> <span class="k">def</span> <span class="nf">mergeblockratioproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1018"><a href="#Generator-1018"><span class="linenos">1018</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">):</span> -</span><span id="Generator-1019"><a href="#Generator-1019"><span class="linenos">1019</span></a> <span class="k">return</span> <span class="s2">"NO MERGEBLOCKRATIO"</span> -</span><span id="Generator-1020"><a href="#Generator-1020"><span class="linenos">1020</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">):</span> -</span><span id="Generator-1021"><a href="#Generator-1021"><span class="linenos">1021</span></a> <span class="k">return</span> <span class="s2">"DEFAULT MERGEBLOCKRATIO"</span> -</span><span id="Generator-1022"><a href="#Generator-1022"><span class="linenos">1022</span></a> -</span><span id="Generator-1023"><a href="#Generator-1023"><span class="linenos">1023</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1024"><a href="#Generator-1024"><span class="linenos">1024</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGEBLOCKRATIO=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">percent</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1017"><a href="#Generator-1017"><span class="linenos">1017</span></a> <span class="k">def</span> <span class="nf">checksumproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1018"><a href="#Generator-1018"><span class="linenos">1018</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">):</span> +</span><span id="Generator-1019"><a href="#Generator-1019"><span class="linenos">1019</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> +</span><span id="Generator-1020"><a href="#Generator-1020"><span class="linenos">1020</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on"</span><span class="p">):</span> +</span><span id="Generator-1021"><a href="#Generator-1021"><span class="linenos">1021</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"ON"</span> +</span><span id="Generator-1022"><a href="#Generator-1022"><span class="linenos">1022</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1023"><a href="#Generator-1023"><span class="linenos">1023</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"OFF"</span> +</span><span id="Generator-1024"><a href="#Generator-1024"><span class="linenos">1024</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECKSUM=</span><span class="si">{</span><span class="nb">property</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-1025"><a href="#Generator-1025"><span class="linenos">1025</span></a> -</span><span id="Generator-1026"><a href="#Generator-1026"><span class="linenos">1026</span></a> <span class="k">def</span> <span class="nf">datablocksizeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1027"><a href="#Generator-1027"><span class="linenos">1027</span></a> <span class="n">default</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> -</span><span id="Generator-1028"><a href="#Generator-1028"><span class="linenos">1028</span></a> <span class="n">minimum</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"minimum"</span><span class="p">)</span> -</span><span id="Generator-1029"><a href="#Generator-1029"><span class="linenos">1029</span></a> <span class="n">maximum</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"maximum"</span><span class="p">)</span> -</span><span id="Generator-1030"><a href="#Generator-1030"><span class="linenos">1030</span></a> <span class="k">if</span> <span class="n">default</span> <span class="ow">or</span> <span class="n">minimum</span> <span class="ow">or</span> <span class="n">maximum</span><span class="p">:</span> -</span><span id="Generator-1031"><a href="#Generator-1031"><span class="linenos">1031</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="Generator-1032"><a href="#Generator-1032"><span class="linenos">1032</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> -</span><span id="Generator-1033"><a href="#Generator-1033"><span class="linenos">1033</span></a> <span class="k">elif</span> <span class="n">minimum</span><span class="p">:</span> -</span><span id="Generator-1034"><a href="#Generator-1034"><span class="linenos">1034</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MINIMUM"</span> -</span><span id="Generator-1035"><a href="#Generator-1035"><span class="linenos">1035</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1036"><a href="#Generator-1036"><span class="linenos">1036</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MAXIMUM"</span> -</span><span id="Generator-1037"><a href="#Generator-1037"><span class="linenos">1037</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2"> DATABLOCKSIZE"</span> -</span><span id="Generator-1038"><a href="#Generator-1038"><span class="linenos">1038</span></a> <span class="n">units</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"units"</span><span class="p">)</span> -</span><span id="Generator-1039"><a href="#Generator-1039"><span class="linenos">1039</span></a> <span class="n">units</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">units</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1040"><a href="#Generator-1040"><span class="linenos">1040</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DATABLOCKSIZE=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'size'</span><span class="p">)</span><span class="si">}{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1041"><a href="#Generator-1041"><span class="linenos">1041</span></a> -</span><span id="Generator-1042"><a href="#Generator-1042"><span class="linenos">1042</span></a> <span class="k">def</span> <span class="nf">blockcompressionproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1043"><a href="#Generator-1043"><span class="linenos">1043</span></a> <span class="n">autotemp</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"autotemp"</span><span class="p">)</span> -</span><span id="Generator-1044"><a href="#Generator-1044"><span class="linenos">1044</span></a> <span class="n">always</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"always"</span><span class="p">)</span> -</span><span id="Generator-1045"><a href="#Generator-1045"><span class="linenos">1045</span></a> <span class="n">default</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> -</span><span id="Generator-1046"><a href="#Generator-1046"><span class="linenos">1046</span></a> <span class="n">manual</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"manual"</span><span class="p">)</span> -</span><span id="Generator-1047"><a href="#Generator-1047"><span class="linenos">1047</span></a> <span class="n">never</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"never"</span><span class="p">)</span> -</span><span id="Generator-1048"><a href="#Generator-1048"><span class="linenos">1048</span></a> -</span><span id="Generator-1049"><a href="#Generator-1049"><span class="linenos">1049</span></a> <span class="k">if</span> <span class="n">autotemp</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-1050"><a href="#Generator-1050"><span class="linenos">1050</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"AUTOTEMP(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">autotemp</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1051"><a href="#Generator-1051"><span class="linenos">1051</span></a> <span class="k">elif</span> <span class="n">always</span><span class="p">:</span> -</span><span id="Generator-1052"><a href="#Generator-1052"><span class="linenos">1052</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"ALWAYS"</span> -</span><span id="Generator-1053"><a href="#Generator-1053"><span class="linenos">1053</span></a> <span class="k">elif</span> <span class="n">default</span><span class="p">:</span> -</span><span id="Generator-1054"><a href="#Generator-1054"><span class="linenos">1054</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> -</span><span id="Generator-1055"><a href="#Generator-1055"><span class="linenos">1055</span></a> <span class="k">elif</span> <span class="n">manual</span><span class="p">:</span> -</span><span id="Generator-1056"><a href="#Generator-1056"><span class="linenos">1056</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MANUAL"</span> -</span><span id="Generator-1057"><a href="#Generator-1057"><span class="linenos">1057</span></a> <span class="k">elif</span> <span class="n">never</span><span class="p">:</span> -</span><span id="Generator-1058"><a href="#Generator-1058"><span class="linenos">1058</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"NEVER"</span> -</span><span id="Generator-1059"><a href="#Generator-1059"><span class="linenos">1059</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BLOCKCOMPRESSION=</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1060"><a href="#Generator-1060"><span class="linenos">1060</span></a> -</span><span id="Generator-1061"><a href="#Generator-1061"><span class="linenos">1061</span></a> <span class="k">def</span> <span class="nf">isolatedloadingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1062"><a href="#Generator-1062"><span class="linenos">1062</span></a> <span class="n">no</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">)</span> -</span><span id="Generator-1063"><a href="#Generator-1063"><span class="linenos">1063</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">" NO"</span> <span class="k">if</span> <span class="n">no</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1064"><a href="#Generator-1064"><span class="linenos">1064</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"concurrent"</span><span class="p">)</span> -</span><span id="Generator-1065"><a href="#Generator-1065"><span class="linenos">1065</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="s2">" CONCURRENT"</span> <span class="k">if</span> <span class="n">concurrent</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1066"><a href="#Generator-1066"><span class="linenos">1066</span></a> -</span><span id="Generator-1067"><a href="#Generator-1067"><span class="linenos">1067</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-1068"><a href="#Generator-1068"><span class="linenos">1068</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_all"</span><span class="p">):</span> -</span><span id="Generator-1069"><a href="#Generator-1069"><span class="linenos">1069</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR ALL"</span> -</span><span id="Generator-1070"><a href="#Generator-1070"><span class="linenos">1070</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_insert"</span><span class="p">):</span> -</span><span id="Generator-1071"><a href="#Generator-1071"><span class="linenos">1071</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR INSERT"</span> -</span><span id="Generator-1072"><a href="#Generator-1072"><span class="linenos">1072</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_none"</span><span class="p">):</span> -</span><span id="Generator-1073"><a href="#Generator-1073"><span class="linenos">1073</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR NONE"</span> -</span><span id="Generator-1074"><a href="#Generator-1074"><span class="linenos">1074</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">concurrent</span><span class="si">}</span><span class="s2"> ISOLATED LOADING</span><span class="si">{</span><span class="n">for_</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1026"><a href="#Generator-1026"><span class="linenos">1026</span></a> <span class="k">def</span> <span class="nf">mergeblockratioproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1027"><a href="#Generator-1027"><span class="linenos">1027</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">):</span> +</span><span id="Generator-1028"><a href="#Generator-1028"><span class="linenos">1028</span></a> <span class="k">return</span> <span class="s2">"NO MERGEBLOCKRATIO"</span> +</span><span id="Generator-1029"><a href="#Generator-1029"><span class="linenos">1029</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">):</span> +</span><span id="Generator-1030"><a href="#Generator-1030"><span class="linenos">1030</span></a> <span class="k">return</span> <span class="s2">"DEFAULT MERGEBLOCKRATIO"</span> +</span><span id="Generator-1031"><a href="#Generator-1031"><span class="linenos">1031</span></a> +</span><span id="Generator-1032"><a href="#Generator-1032"><span class="linenos">1032</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1033"><a href="#Generator-1033"><span class="linenos">1033</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGEBLOCKRATIO=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">percent</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1034"><a href="#Generator-1034"><span class="linenos">1034</span></a> +</span><span id="Generator-1035"><a href="#Generator-1035"><span class="linenos">1035</span></a> <span class="k">def</span> <span class="nf">datablocksizeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1036"><a href="#Generator-1036"><span class="linenos">1036</span></a> <span class="n">default</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> +</span><span id="Generator-1037"><a href="#Generator-1037"><span class="linenos">1037</span></a> <span class="n">minimum</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"minimum"</span><span class="p">)</span> +</span><span id="Generator-1038"><a href="#Generator-1038"><span class="linenos">1038</span></a> <span class="n">maximum</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"maximum"</span><span class="p">)</span> +</span><span id="Generator-1039"><a href="#Generator-1039"><span class="linenos">1039</span></a> <span class="k">if</span> <span class="n">default</span> <span class="ow">or</span> <span class="n">minimum</span> <span class="ow">or</span> <span class="n">maximum</span><span class="p">:</span> +</span><span id="Generator-1040"><a href="#Generator-1040"><span class="linenos">1040</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> +</span><span id="Generator-1041"><a href="#Generator-1041"><span class="linenos">1041</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> +</span><span id="Generator-1042"><a href="#Generator-1042"><span class="linenos">1042</span></a> <span class="k">elif</span> <span class="n">minimum</span><span class="p">:</span> +</span><span id="Generator-1043"><a href="#Generator-1043"><span class="linenos">1043</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MINIMUM"</span> +</span><span id="Generator-1044"><a href="#Generator-1044"><span class="linenos">1044</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1045"><a href="#Generator-1045"><span class="linenos">1045</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MAXIMUM"</span> +</span><span id="Generator-1046"><a href="#Generator-1046"><span class="linenos">1046</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2"> DATABLOCKSIZE"</span> +</span><span id="Generator-1047"><a href="#Generator-1047"><span class="linenos">1047</span></a> <span class="n">units</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"units"</span><span class="p">)</span> +</span><span id="Generator-1048"><a href="#Generator-1048"><span class="linenos">1048</span></a> <span class="n">units</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">units</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1049"><a href="#Generator-1049"><span class="linenos">1049</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DATABLOCKSIZE=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'size'</span><span class="p">)</span><span class="si">}{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1050"><a href="#Generator-1050"><span class="linenos">1050</span></a> +</span><span id="Generator-1051"><a href="#Generator-1051"><span class="linenos">1051</span></a> <span class="k">def</span> <span class="nf">blockcompressionproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1052"><a href="#Generator-1052"><span class="linenos">1052</span></a> <span class="n">autotemp</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"autotemp"</span><span class="p">)</span> +</span><span id="Generator-1053"><a href="#Generator-1053"><span class="linenos">1053</span></a> <span class="n">always</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"always"</span><span class="p">)</span> +</span><span id="Generator-1054"><a href="#Generator-1054"><span class="linenos">1054</span></a> <span class="n">default</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> +</span><span id="Generator-1055"><a href="#Generator-1055"><span class="linenos">1055</span></a> <span class="n">manual</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"manual"</span><span class="p">)</span> +</span><span id="Generator-1056"><a href="#Generator-1056"><span class="linenos">1056</span></a> <span class="n">never</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"never"</span><span class="p">)</span> +</span><span id="Generator-1057"><a href="#Generator-1057"><span class="linenos">1057</span></a> +</span><span id="Generator-1058"><a href="#Generator-1058"><span class="linenos">1058</span></a> <span class="k">if</span> <span class="n">autotemp</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-1059"><a href="#Generator-1059"><span class="linenos">1059</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"AUTOTEMP(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">autotemp</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1060"><a href="#Generator-1060"><span class="linenos">1060</span></a> <span class="k">elif</span> <span class="n">always</span><span class="p">:</span> +</span><span id="Generator-1061"><a href="#Generator-1061"><span class="linenos">1061</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"ALWAYS"</span> +</span><span id="Generator-1062"><a href="#Generator-1062"><span class="linenos">1062</span></a> <span class="k">elif</span> <span class="n">default</span><span class="p">:</span> +</span><span id="Generator-1063"><a href="#Generator-1063"><span class="linenos">1063</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> +</span><span id="Generator-1064"><a href="#Generator-1064"><span class="linenos">1064</span></a> <span class="k">elif</span> <span class="n">manual</span><span class="p">:</span> +</span><span id="Generator-1065"><a href="#Generator-1065"><span class="linenos">1065</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MANUAL"</span> +</span><span id="Generator-1066"><a href="#Generator-1066"><span class="linenos">1066</span></a> <span class="k">elif</span> <span class="n">never</span><span class="p">:</span> +</span><span id="Generator-1067"><a href="#Generator-1067"><span class="linenos">1067</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"NEVER"</span> +</span><span id="Generator-1068"><a href="#Generator-1068"><span class="linenos">1068</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BLOCKCOMPRESSION=</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1069"><a href="#Generator-1069"><span class="linenos">1069</span></a> +</span><span id="Generator-1070"><a href="#Generator-1070"><span class="linenos">1070</span></a> <span class="k">def</span> <span class="nf">isolatedloadingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1071"><a href="#Generator-1071"><span class="linenos">1071</span></a> <span class="n">no</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">)</span> +</span><span id="Generator-1072"><a href="#Generator-1072"><span class="linenos">1072</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">" NO"</span> <span class="k">if</span> <span class="n">no</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1073"><a href="#Generator-1073"><span class="linenos">1073</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"concurrent"</span><span class="p">)</span> +</span><span id="Generator-1074"><a href="#Generator-1074"><span class="linenos">1074</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="s2">" CONCURRENT"</span> <span class="k">if</span> <span class="n">concurrent</span> <span class="k">else</span> <span class="s2">""</span> </span><span id="Generator-1075"><a href="#Generator-1075"><span class="linenos">1075</span></a> -</span><span id="Generator-1076"><a href="#Generator-1076"><span class="linenos">1076</span></a> <span class="k">def</span> <span class="nf">lockingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1077"><a href="#Generator-1077"><span class="linenos">1077</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator-1078"><a href="#Generator-1078"><span class="linenos">1078</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1079"><a href="#Generator-1079"><span class="linenos">1079</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_or_in"</span><span class="p">)</span> -</span><span id="Generator-1080"><a href="#Generator-1080"><span class="linenos">1080</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lock_type"</span><span class="p">)</span> -</span><span id="Generator-1081"><a href="#Generator-1081"><span class="linenos">1081</span></a> <span class="n">override</span> <span class="o">=</span> <span class="s2">" OVERRIDE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"override"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1082"><a href="#Generator-1082"><span class="linenos">1082</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOCKING </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">for_or_in</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">override</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1083"><a href="#Generator-1083"><span class="linenos">1083</span></a> -</span><span id="Generator-1084"><a href="#Generator-1084"><span class="linenos">1084</span></a> <span class="k">def</span> <span class="nf">withdataproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1085"><a href="#Generator-1085"><span class="linenos">1085</span></a> <span class="n">data_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'no'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">DATA"</span> -</span><span id="Generator-1086"><a href="#Generator-1086"><span class="linenos">1086</span></a> <span class="n">statistics</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"statistics"</span><span class="p">)</span> -</span><span id="Generator-1087"><a href="#Generator-1087"><span class="linenos">1087</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-1088"><a href="#Generator-1088"><span class="linenos">1088</span></a> <span class="k">if</span> <span class="n">statistics</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-1089"><a href="#Generator-1089"><span class="linenos">1089</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">statistics</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">STATISTICS"</span> -</span><span id="Generator-1090"><a href="#Generator-1090"><span class="linenos">1090</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">data_sql</span><span class="si">}{</span><span class="n">statistics_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1091"><a href="#Generator-1091"><span class="linenos">1091</span></a> -</span><span id="Generator-1092"><a href="#Generator-1092"><span class="linenos">1092</span></a> <span class="k">def</span> <span class="nf">insert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1093"><a href="#Generator-1093"><span class="linenos">1093</span></a> <span class="n">overwrite</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"overwrite"</span><span class="p">)</span> -</span><span id="Generator-1094"><a href="#Generator-1094"><span class="linenos">1094</span></a> -</span><span id="Generator-1095"><a href="#Generator-1095"><span class="linenos">1095</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">):</span> -</span><span id="Generator-1096"><a href="#Generator-1096"><span class="linenos">1096</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">"OVERWRITE "</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">"INTO "</span> -</span><span id="Generator-1097"><a href="#Generator-1097"><span class="linenos">1097</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1098"><a href="#Generator-1098"><span class="linenos">1098</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">"OVERWRITE TABLE "</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">"INTO "</span> -</span><span id="Generator-1099"><a href="#Generator-1099"><span class="linenos">1099</span></a> -</span><span id="Generator-1100"><a href="#Generator-1100"><span class="linenos">1100</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alternative"</span><span class="p">)</span> -</span><span id="Generator-1101"><a href="#Generator-1101"><span class="linenos">1101</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OR </span><span class="si">{</span><span class="n">alternative</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">alternative</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator-1102"><a href="#Generator-1102"><span class="linenos">1102</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1076"><a href="#Generator-1076"><span class="linenos">1076</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-1077"><a href="#Generator-1077"><span class="linenos">1077</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_all"</span><span class="p">):</span> +</span><span id="Generator-1078"><a href="#Generator-1078"><span class="linenos">1078</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR ALL"</span> +</span><span id="Generator-1079"><a href="#Generator-1079"><span class="linenos">1079</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_insert"</span><span class="p">):</span> +</span><span id="Generator-1080"><a href="#Generator-1080"><span class="linenos">1080</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR INSERT"</span> +</span><span id="Generator-1081"><a href="#Generator-1081"><span class="linenos">1081</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_none"</span><span class="p">):</span> +</span><span id="Generator-1082"><a href="#Generator-1082"><span class="linenos">1082</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR NONE"</span> +</span><span id="Generator-1083"><a href="#Generator-1083"><span class="linenos">1083</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">concurrent</span><span class="si">}</span><span class="s2"> ISOLATED LOADING</span><span class="si">{</span><span class="n">for_</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1084"><a href="#Generator-1084"><span class="linenos">1084</span></a> +</span><span id="Generator-1085"><a href="#Generator-1085"><span class="linenos">1085</span></a> <span class="k">def</span> <span class="nf">lockingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1086"><a href="#Generator-1086"><span class="linenos">1086</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator-1087"><a href="#Generator-1087"><span class="linenos">1087</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1088"><a href="#Generator-1088"><span class="linenos">1088</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_or_in"</span><span class="p">)</span> +</span><span id="Generator-1089"><a href="#Generator-1089"><span class="linenos">1089</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lock_type"</span><span class="p">)</span> +</span><span id="Generator-1090"><a href="#Generator-1090"><span class="linenos">1090</span></a> <span class="n">override</span> <span class="o">=</span> <span class="s2">" OVERRIDE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"override"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1091"><a href="#Generator-1091"><span class="linenos">1091</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOCKING </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">for_or_in</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">override</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1092"><a href="#Generator-1092"><span class="linenos">1092</span></a> +</span><span id="Generator-1093"><a href="#Generator-1093"><span class="linenos">1093</span></a> <span class="k">def</span> <span class="nf">withdataproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1094"><a href="#Generator-1094"><span class="linenos">1094</span></a> <span class="n">data_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'no'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">DATA"</span> +</span><span id="Generator-1095"><a href="#Generator-1095"><span class="linenos">1095</span></a> <span class="n">statistics</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"statistics"</span><span class="p">)</span> +</span><span id="Generator-1096"><a href="#Generator-1096"><span class="linenos">1096</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-1097"><a href="#Generator-1097"><span class="linenos">1097</span></a> <span class="k">if</span> <span class="n">statistics</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-1098"><a href="#Generator-1098"><span class="linenos">1098</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">statistics</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">STATISTICS"</span> +</span><span id="Generator-1099"><a href="#Generator-1099"><span class="linenos">1099</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">data_sql</span><span class="si">}{</span><span class="n">statistics_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1100"><a href="#Generator-1100"><span class="linenos">1100</span></a> +</span><span id="Generator-1101"><a href="#Generator-1101"><span class="linenos">1101</span></a> <span class="k">def</span> <span class="nf">insert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1102"><a href="#Generator-1102"><span class="linenos">1102</span></a> <span class="n">overwrite</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"overwrite"</span><span class="p">)</span> </span><span id="Generator-1103"><a href="#Generator-1103"><span class="linenos">1103</span></a> -</span><span id="Generator-1104"><a href="#Generator-1104"><span class="linenos">1104</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator-1105"><a href="#Generator-1105"><span class="linenos">1105</span></a> <span class="n">partition_sql</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-1106"><a href="#Generator-1106"><span class="linenos">1106</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"partition"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"partition"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1107"><a href="#Generator-1107"><span class="linenos">1107</span></a> <span class="p">)</span> -</span><span id="Generator-1108"><a href="#Generator-1108"><span class="linenos">1108</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator-1109"><a href="#Generator-1109"><span class="linenos">1109</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"conflict"</span><span class="p">)</span> -</span><span id="Generator-1110"><a href="#Generator-1110"><span class="linenos">1110</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> -</span><span id="Generator-1111"><a href="#Generator-1111"><span class="linenos">1111</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span> <span class="k">if</span> <span class="n">partition_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1112"><a href="#Generator-1112"><span class="linenos">1112</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT</span><span class="si">{</span><span class="n">alternative</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">exists</span><span class="si">}{</span><span class="n">partition_sql</span><span class="si">}{</span><span class="n">sep</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">conflict</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1113"><a href="#Generator-1113"><span class="linenos">1113</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="Generator-1114"><a href="#Generator-1114"><span class="linenos">1114</span></a> -</span><span id="Generator-1115"><a href="#Generator-1115"><span class="linenos">1115</span></a> <span class="k">def</span> <span class="nf">intersect_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1116"><a href="#Generator-1116"><span class="linenos">1116</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span> -</span><span id="Generator-1117"><a href="#Generator-1117"><span class="linenos">1117</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator-1118"><a href="#Generator-1118"><span class="linenos">1118</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> -</span><span id="Generator-1119"><a href="#Generator-1119"><span class="linenos">1119</span></a> <span class="p">)</span> -</span><span id="Generator-1120"><a href="#Generator-1120"><span class="linenos">1120</span></a> -</span><span id="Generator-1121"><a href="#Generator-1121"><span class="linenos">1121</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1122"><a href="#Generator-1122"><span class="linenos">1122</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">''</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1104"><a href="#Generator-1104"><span class="linenos">1104</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">):</span> +</span><span id="Generator-1105"><a href="#Generator-1105"><span class="linenos">1105</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">"OVERWRITE "</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">"INTO "</span> +</span><span id="Generator-1106"><a href="#Generator-1106"><span class="linenos">1106</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1107"><a href="#Generator-1107"><span class="linenos">1107</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">"OVERWRITE TABLE "</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">"INTO "</span> +</span><span id="Generator-1108"><a href="#Generator-1108"><span class="linenos">1108</span></a> +</span><span id="Generator-1109"><a href="#Generator-1109"><span class="linenos">1109</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alternative"</span><span class="p">)</span> +</span><span id="Generator-1110"><a href="#Generator-1110"><span class="linenos">1110</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OR </span><span class="si">{</span><span class="n">alternative</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">alternative</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator-1111"><a href="#Generator-1111"><span class="linenos">1111</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1112"><a href="#Generator-1112"><span class="linenos">1112</span></a> +</span><span id="Generator-1113"><a href="#Generator-1113"><span class="linenos">1113</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator-1114"><a href="#Generator-1114"><span class="linenos">1114</span></a> <span class="n">partition_sql</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-1115"><a href="#Generator-1115"><span class="linenos">1115</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"partition"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"partition"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1116"><a href="#Generator-1116"><span class="linenos">1116</span></a> <span class="p">)</span> +</span><span id="Generator-1117"><a href="#Generator-1117"><span class="linenos">1117</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator-1118"><a href="#Generator-1118"><span class="linenos">1118</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"conflict"</span><span class="p">)</span> +</span><span id="Generator-1119"><a href="#Generator-1119"><span class="linenos">1119</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="Generator-1120"><a href="#Generator-1120"><span class="linenos">1120</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span> <span class="k">if</span> <span class="n">partition_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1121"><a href="#Generator-1121"><span class="linenos">1121</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT</span><span class="si">{</span><span class="n">alternative</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">exists</span><span class="si">}{</span><span class="n">partition_sql</span><span class="si">}{</span><span class="n">sep</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">conflict</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1122"><a href="#Generator-1122"><span class="linenos">1122</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> </span><span id="Generator-1123"><a href="#Generator-1123"><span class="linenos">1123</span></a> -</span><span id="Generator-1124"><a href="#Generator-1124"><span class="linenos">1124</span></a> <span class="k">def</span> <span class="nf">introducer_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Introducer</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1125"><a href="#Generator-1125"><span class="linenos">1125</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1126"><a href="#Generator-1126"><span class="linenos">1126</span></a> -</span><span id="Generator-1127"><a href="#Generator-1127"><span class="linenos">1127</span></a> <span class="k">def</span> <span class="nf">pseudotype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PseudoType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1128"><a href="#Generator-1128"><span class="linenos">1128</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Generator-1124"><a href="#Generator-1124"><span class="linenos">1124</span></a> <span class="k">def</span> <span class="nf">intersect_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1125"><a href="#Generator-1125"><span class="linenos">1125</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span> +</span><span id="Generator-1126"><a href="#Generator-1126"><span class="linenos">1126</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator-1127"><a href="#Generator-1127"><span class="linenos">1127</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> +</span><span id="Generator-1128"><a href="#Generator-1128"><span class="linenos">1128</span></a> <span class="p">)</span> </span><span id="Generator-1129"><a href="#Generator-1129"><span class="linenos">1129</span></a> -</span><span id="Generator-1130"><a href="#Generator-1130"><span class="linenos">1130</span></a> <span class="k">def</span> <span class="nf">onconflict_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnConflict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1131"><a href="#Generator-1131"><span class="linenos">1131</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="s2">"ON DUPLICATE KEY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ON CONFLICT"</span> -</span><span id="Generator-1132"><a href="#Generator-1132"><span class="linenos">1132</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"constraint"</span><span class="p">)</span> -</span><span id="Generator-1133"><a href="#Generator-1133"><span class="linenos">1133</span></a> <span class="k">if</span> <span class="n">constraint</span><span class="p">:</span> -</span><span id="Generator-1134"><a href="#Generator-1134"><span class="linenos">1134</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON CONSTRAINT </span><span class="si">{</span><span class="n">constraint</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1135"><a href="#Generator-1135"><span class="linenos">1135</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"key"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1136"><a href="#Generator-1136"><span class="linenos">1136</span></a> <span class="n">do</span> <span class="o">=</span> <span class="s2">""</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" DO "</span> -</span><span id="Generator-1137"><a href="#Generator-1137"><span class="linenos">1137</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="s2">"NOTHING"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nothing"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1138"><a href="#Generator-1138"><span class="linenos">1138</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1139"><a href="#Generator-1139"><span class="linenos">1139</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator-1140"><a href="#Generator-1140"><span class="linenos">1140</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE SET </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1141"><a href="#Generator-1141"><span class="linenos">1141</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">conflict</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">constraint</span><span class="si">}{</span><span class="n">key</span><span class="si">}{</span><span class="n">do</span><span class="si">}{</span><span class="n">nothing</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1142"><a href="#Generator-1142"><span class="linenos">1142</span></a> -</span><span id="Generator-1143"><a href="#Generator-1143"><span class="linenos">1143</span></a> <span class="k">def</span> <span class="nf">returning_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Returning</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1144"><a href="#Generator-1144"><span class="linenos">1144</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'RETURNING'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1145"><a href="#Generator-1145"><span class="linenos">1145</span></a> -</span><span id="Generator-1146"><a href="#Generator-1146"><span class="linenos">1146</span></a> <span class="k">def</span> <span class="nf">rowformatdelimitedproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1147"><a href="#Generator-1147"><span class="linenos">1147</span></a> <span class="n">fields</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"fields"</span><span class="p">)</span> -</span><span id="Generator-1148"><a href="#Generator-1148"><span class="linenos">1148</span></a> <span class="n">fields</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FIELDS TERMINATED BY </span><span class="si">{</span><span class="n">fields</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">fields</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1149"><a href="#Generator-1149"><span class="linenos">1149</span></a> <span class="n">escaped</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"escaped"</span><span class="p">)</span> -</span><span id="Generator-1150"><a href="#Generator-1150"><span class="linenos">1150</span></a> <span class="n">escaped</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ESCAPED BY </span><span class="si">{</span><span class="n">escaped</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">escaped</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1151"><a href="#Generator-1151"><span class="linenos">1151</span></a> <span class="n">items</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"collection_items"</span><span class="p">)</span> -</span><span id="Generator-1152"><a href="#Generator-1152"><span class="linenos">1152</span></a> <span class="n">items</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLECTION ITEMS TERMINATED BY </span><span class="si">{</span><span class="n">items</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">items</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1153"><a href="#Generator-1153"><span class="linenos">1153</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"map_keys"</span><span class="p">)</span> -</span><span id="Generator-1154"><a href="#Generator-1154"><span class="linenos">1154</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAP KEYS TERMINATED BY </span><span class="si">{</span><span class="n">keys</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">keys</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1155"><a href="#Generator-1155"><span class="linenos">1155</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lines"</span><span class="p">)</span> -</span><span id="Generator-1156"><a href="#Generator-1156"><span class="linenos">1156</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" LINES TERMINATED BY </span><span class="si">{</span><span class="n">lines</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">lines</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1157"><a href="#Generator-1157"><span class="linenos">1157</span></a> <span class="n">null</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"null"</span><span class="p">)</span> -</span><span id="Generator-1158"><a href="#Generator-1158"><span class="linenos">1158</span></a> <span class="n">null</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" NULL DEFINED AS </span><span class="si">{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1159"><a href="#Generator-1159"><span class="linenos">1159</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROW FORMAT DELIMITED</span><span class="si">{</span><span class="n">fields</span><span class="si">}{</span><span class="n">escaped</span><span class="si">}{</span><span class="n">items</span><span class="si">}{</span><span class="n">keys</span><span class="si">}{</span><span class="n">lines</span><span class="si">}{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1160"><a href="#Generator-1160"><span class="linenos">1160</span></a> -</span><span id="Generator-1161"><a href="#Generator-1161"><span class="linenos">1161</span></a> <span class="k">def</span> <span class="nf">table_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1162"><a href="#Generator-1162"><span class="linenos">1162</span></a> <span class="n">table</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator-1163"><a href="#Generator-1163"><span class="linenos">1163</span></a> <span class="n">part</span> -</span><span id="Generator-1164"><a href="#Generator-1164"><span class="linenos">1164</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">[</span> -</span><span id="Generator-1165"><a href="#Generator-1165"><span class="linenos">1165</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"catalog"</span><span class="p">),</span> -</span><span id="Generator-1166"><a href="#Generator-1166"><span class="linenos">1166</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"db"</span><span class="p">),</span> -</span><span id="Generator-1167"><a href="#Generator-1167"><span class="linenos">1167</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> -</span><span id="Generator-1168"><a href="#Generator-1168"><span class="linenos">1168</span></a> <span class="p">]</span> -</span><span id="Generator-1169"><a href="#Generator-1169"><span class="linenos">1169</span></a> <span class="k">if</span> <span class="n">part</span> -</span><span id="Generator-1170"><a href="#Generator-1170"><span class="linenos">1170</span></a> <span class="p">)</span> -</span><span id="Generator-1171"><a href="#Generator-1171"><span class="linenos">1171</span></a> -</span><span id="Generator-1172"><a href="#Generator-1172"><span class="linenos">1172</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator-1173"><a href="#Generator-1173"><span class="linenos">1173</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1174"><a href="#Generator-1174"><span class="linenos">1174</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"hints"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1175"><a href="#Generator-1175"><span class="linenos">1175</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH (</span><span class="si">{</span><span class="n">hints</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">hints</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_HINTS</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1176"><a href="#Generator-1176"><span class="linenos">1176</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1177"><a href="#Generator-1177"><span class="linenos">1177</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1178"><a href="#Generator-1178"><span class="linenos">1178</span></a> <span class="n">joins</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"joins"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="Generator-1179"><a href="#Generator-1179"><span class="linenos">1179</span></a> <span class="n">laterals</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"laterals"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="Generator-1180"><a href="#Generator-1180"><span class="linenos">1180</span></a> <span class="n">system_time</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"system_time"</span><span class="p">)</span> -</span><span id="Generator-1181"><a href="#Generator-1181"><span class="linenos">1181</span></a> <span class="n">system_time</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'system_time'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">system_time</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1182"><a href="#Generator-1182"><span class="linenos">1182</span></a> -</span><span id="Generator-1183"><a href="#Generator-1183"><span class="linenos">1183</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">system_time</span><span class="si">}{</span><span class="n">alias</span><span class="si">}{</span><span class="n">hints</span><span class="si">}{</span><span class="n">pivots</span><span class="si">}{</span><span class="n">joins</span><span class="si">}{</span><span class="n">laterals</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1184"><a href="#Generator-1184"><span class="linenos">1184</span></a> -</span><span id="Generator-1185"><a href="#Generator-1185"><span class="linenos">1185</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="Generator-1186"><a href="#Generator-1186"><span class="linenos">1186</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" AS "</span> -</span><span id="Generator-1187"><a href="#Generator-1187"><span class="linenos">1187</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1188"><a href="#Generator-1188"><span class="linenos">1188</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> -</span><span id="Generator-1189"><a href="#Generator-1189"><span class="linenos">1189</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Generator-1190"><a href="#Generator-1190"><span class="linenos">1190</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="Generator-1191"><a href="#Generator-1191"><span class="linenos">1191</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> -</span><span id="Generator-1192"><a href="#Generator-1192"><span class="linenos">1192</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="s1">'alias'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1193"><a href="#Generator-1193"><span class="linenos">1193</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1194"><a href="#Generator-1194"><span class="linenos">1194</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1195"><a href="#Generator-1195"><span class="linenos">1195</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-1196"><a href="#Generator-1196"><span class="linenos">1196</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"method"</span><span class="p">)</span> -</span><span id="Generator-1197"><a href="#Generator-1197"><span class="linenos">1197</span></a> <span class="n">method</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">method</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1198"><a href="#Generator-1198"><span class="linenos">1198</span></a> <span class="n">numerator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_numerator"</span><span class="p">)</span> -</span><span id="Generator-1199"><a href="#Generator-1199"><span class="linenos">1199</span></a> <span class="n">denominator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_denominator"</span><span class="p">)</span> -</span><span id="Generator-1200"><a href="#Generator-1200"><span class="linenos">1200</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_field"</span><span class="p">)</span> -</span><span id="Generator-1201"><a href="#Generator-1201"><span class="linenos">1201</span></a> <span class="n">field</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">field</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1202"><a href="#Generator-1202"><span class="linenos">1202</span></a> <span class="n">bucket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"BUCKET </span><span class="si">{</span><span class="n">numerator</span><span class="si">}</span><span class="s2"> OUT OF </span><span class="si">{</span><span class="n">denominator</span><span class="si">}{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">numerator</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1203"><a href="#Generator-1203"><span class="linenos">1203</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">)</span> -</span><span id="Generator-1204"><a href="#Generator-1204"><span class="linenos">1204</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">percent</span><span class="si">}</span><span class="s2"> PERCENT"</span> <span class="k">if</span> <span class="n">percent</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1205"><a href="#Generator-1205"><span class="linenos">1205</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> -</span><span id="Generator-1206"><a href="#Generator-1206"><span class="linenos">1206</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">rows</span><span class="si">}</span><span class="s2"> ROWS"</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1207"><a href="#Generator-1207"><span class="linenos">1207</span></a> <span class="n">size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"size"</span><span class="p">)</span> -</span><span id="Generator-1208"><a href="#Generator-1208"><span class="linenos">1208</span></a> <span class="k">if</span> <span class="n">size</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span><span class="p">:</span> -</span><span id="Generator-1209"><a href="#Generator-1209"><span class="linenos">1209</span></a> <span class="n">size</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">size</span><span class="si">}</span><span class="s2"> PERCENT"</span> -</span><span id="Generator-1210"><a href="#Generator-1210"><span class="linenos">1210</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"seed"</span><span class="p">)</span> -</span><span id="Generator-1211"><a href="#Generator-1211"><span class="linenos">1211</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">seed_prefix</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">seed</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">seed</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1212"><a href="#Generator-1212"><span class="linenos">1212</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"TABLESAMPLE"</span><span class="p">)</span> -</span><span id="Generator-1213"><a href="#Generator-1213"><span class="linenos">1213</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">method</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">bucket</span><span class="si">}{</span><span class="n">percent</span><span class="si">}{</span><span class="n">rows</span><span class="si">}{</span><span class="n">size</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">seed</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1214"><a href="#Generator-1214"><span class="linenos">1214</span></a> -</span><span id="Generator-1215"><a href="#Generator-1215"><span class="linenos">1215</span></a> <span class="k">def</span> <span class="nf">pivot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1216"><a href="#Generator-1216"><span class="linenos">1216</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1217"><a href="#Generator-1217"><span class="linenos">1217</span></a> -</span><span id="Generator-1218"><a href="#Generator-1218"><span class="linenos">1218</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> -</span><span id="Generator-1219"><a href="#Generator-1219"><span class="linenos">1219</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1220"><a href="#Generator-1220"><span class="linenos">1220</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'ON'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1221"><a href="#Generator-1221"><span class="linenos">1221</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"using"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1222"><a href="#Generator-1222"><span class="linenos">1222</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'USING'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1223"><a href="#Generator-1223"><span class="linenos">1223</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">)</span> -</span><span id="Generator-1224"><a href="#Generator-1224"><span class="linenos">1224</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PIVOT </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">on</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">group</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1225"><a href="#Generator-1225"><span class="linenos">1225</span></a> -</span><span id="Generator-1226"><a href="#Generator-1226"><span class="linenos">1226</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator-1227"><a href="#Generator-1227"><span class="linenos">1227</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1228"><a href="#Generator-1228"><span class="linenos">1228</span></a> <span class="n">unpivot</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unpivot"</span><span class="p">)</span> -</span><span id="Generator-1229"><a href="#Generator-1229"><span class="linenos">1229</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="s2">"UNPIVOT"</span> <span class="k">if</span> <span class="n">unpivot</span> <span class="k">else</span> <span class="s2">"PIVOT"</span> -</span><span id="Generator-1230"><a href="#Generator-1230"><span class="linenos">1230</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"field"</span><span class="p">)</span> -</span><span id="Generator-1231"><a href="#Generator-1231"><span class="linenos">1231</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">direction</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2"> FOR </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1232"><a href="#Generator-1232"><span class="linenos">1232</span></a> -</span><span id="Generator-1233"><a href="#Generator-1233"><span class="linenos">1233</span></a> <span class="k">def</span> <span class="nf">tuple_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Tuple</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1234"><a href="#Generator-1234"><span class="linenos">1234</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1235"><a href="#Generator-1235"><span class="linenos">1235</span></a> -</span><span id="Generator-1236"><a href="#Generator-1236"><span class="linenos">1236</span></a> <span class="k">def</span> <span class="nf">update_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1237"><a href="#Generator-1237"><span class="linenos">1237</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1238"><a href="#Generator-1238"><span class="linenos">1238</span></a> <span class="n">set_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1239"><a href="#Generator-1239"><span class="linenos">1239</span></a> <span class="n">from_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">)</span> -</span><span id="Generator-1240"><a href="#Generator-1240"><span class="linenos">1240</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> -</span><span id="Generator-1241"><a href="#Generator-1241"><span class="linenos">1241</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> -</span><span id="Generator-1242"><a href="#Generator-1242"><span class="linenos">1242</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1243"><a href="#Generator-1243"><span class="linenos">1243</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="Generator-1130"><a href="#Generator-1130"><span class="linenos">1130</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1131"><a href="#Generator-1131"><span class="linenos">1131</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">''</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1132"><a href="#Generator-1132"><span class="linenos">1132</span></a> +</span><span id="Generator-1133"><a href="#Generator-1133"><span class="linenos">1133</span></a> <span class="k">def</span> <span class="nf">introducer_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Introducer</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1134"><a href="#Generator-1134"><span class="linenos">1134</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1135"><a href="#Generator-1135"><span class="linenos">1135</span></a> +</span><span id="Generator-1136"><a href="#Generator-1136"><span class="linenos">1136</span></a> <span class="k">def</span> <span class="nf">pseudotype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PseudoType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1137"><a href="#Generator-1137"><span class="linenos">1137</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Generator-1138"><a href="#Generator-1138"><span class="linenos">1138</span></a> +</span><span id="Generator-1139"><a href="#Generator-1139"><span class="linenos">1139</span></a> <span class="k">def</span> <span class="nf">onconflict_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnConflict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1140"><a href="#Generator-1140"><span class="linenos">1140</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="s2">"ON DUPLICATE KEY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ON CONFLICT"</span> +</span><span id="Generator-1141"><a href="#Generator-1141"><span class="linenos">1141</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"constraint"</span><span class="p">)</span> +</span><span id="Generator-1142"><a href="#Generator-1142"><span class="linenos">1142</span></a> <span class="k">if</span> <span class="n">constraint</span><span class="p">:</span> +</span><span id="Generator-1143"><a href="#Generator-1143"><span class="linenos">1143</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON CONSTRAINT </span><span class="si">{</span><span class="n">constraint</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1144"><a href="#Generator-1144"><span class="linenos">1144</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"key"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1145"><a href="#Generator-1145"><span class="linenos">1145</span></a> <span class="n">do</span> <span class="o">=</span> <span class="s2">""</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" DO "</span> +</span><span id="Generator-1146"><a href="#Generator-1146"><span class="linenos">1146</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="s2">"NOTHING"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nothing"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1147"><a href="#Generator-1147"><span class="linenos">1147</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1148"><a href="#Generator-1148"><span class="linenos">1148</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator-1149"><a href="#Generator-1149"><span class="linenos">1149</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE SET </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1150"><a href="#Generator-1150"><span class="linenos">1150</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">conflict</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">constraint</span><span class="si">}{</span><span class="n">key</span><span class="si">}{</span><span class="n">do</span><span class="si">}{</span><span class="n">nothing</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1151"><a href="#Generator-1151"><span class="linenos">1151</span></a> +</span><span id="Generator-1152"><a href="#Generator-1152"><span class="linenos">1152</span></a> <span class="k">def</span> <span class="nf">returning_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Returning</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1153"><a href="#Generator-1153"><span class="linenos">1153</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'RETURNING'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1154"><a href="#Generator-1154"><span class="linenos">1154</span></a> +</span><span id="Generator-1155"><a href="#Generator-1155"><span class="linenos">1155</span></a> <span class="k">def</span> <span class="nf">rowformatdelimitedproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1156"><a href="#Generator-1156"><span class="linenos">1156</span></a> <span class="n">fields</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"fields"</span><span class="p">)</span> +</span><span id="Generator-1157"><a href="#Generator-1157"><span class="linenos">1157</span></a> <span class="n">fields</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FIELDS TERMINATED BY </span><span class="si">{</span><span class="n">fields</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">fields</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1158"><a href="#Generator-1158"><span class="linenos">1158</span></a> <span class="n">escaped</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"escaped"</span><span class="p">)</span> +</span><span id="Generator-1159"><a href="#Generator-1159"><span class="linenos">1159</span></a> <span class="n">escaped</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ESCAPED BY </span><span class="si">{</span><span class="n">escaped</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">escaped</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1160"><a href="#Generator-1160"><span class="linenos">1160</span></a> <span class="n">items</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"collection_items"</span><span class="p">)</span> +</span><span id="Generator-1161"><a href="#Generator-1161"><span class="linenos">1161</span></a> <span class="n">items</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLECTION ITEMS TERMINATED BY </span><span class="si">{</span><span class="n">items</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">items</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1162"><a href="#Generator-1162"><span class="linenos">1162</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"map_keys"</span><span class="p">)</span> +</span><span id="Generator-1163"><a href="#Generator-1163"><span class="linenos">1163</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAP KEYS TERMINATED BY </span><span class="si">{</span><span class="n">keys</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">keys</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1164"><a href="#Generator-1164"><span class="linenos">1164</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lines"</span><span class="p">)</span> +</span><span id="Generator-1165"><a href="#Generator-1165"><span class="linenos">1165</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" LINES TERMINATED BY </span><span class="si">{</span><span class="n">lines</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">lines</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1166"><a href="#Generator-1166"><span class="linenos">1166</span></a> <span class="n">null</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"null"</span><span class="p">)</span> +</span><span id="Generator-1167"><a href="#Generator-1167"><span class="linenos">1167</span></a> <span class="n">null</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" NULL DEFINED AS </span><span class="si">{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1168"><a href="#Generator-1168"><span class="linenos">1168</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROW FORMAT DELIMITED</span><span class="si">{</span><span class="n">fields</span><span class="si">}{</span><span class="n">escaped</span><span class="si">}{</span><span class="n">items</span><span class="si">}{</span><span class="n">keys</span><span class="si">}{</span><span class="n">lines</span><span class="si">}{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1169"><a href="#Generator-1169"><span class="linenos">1169</span></a> +</span><span id="Generator-1170"><a href="#Generator-1170"><span class="linenos">1170</span></a> <span class="k">def</span> <span class="nf">table_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1171"><a href="#Generator-1171"><span class="linenos">1171</span></a> <span class="n">table</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator-1172"><a href="#Generator-1172"><span class="linenos">1172</span></a> <span class="n">part</span> +</span><span id="Generator-1173"><a href="#Generator-1173"><span class="linenos">1173</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">[</span> +</span><span id="Generator-1174"><a href="#Generator-1174"><span class="linenos">1174</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"catalog"</span><span class="p">),</span> +</span><span id="Generator-1175"><a href="#Generator-1175"><span class="linenos">1175</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"db"</span><span class="p">),</span> +</span><span id="Generator-1176"><a href="#Generator-1176"><span class="linenos">1176</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> +</span><span id="Generator-1177"><a href="#Generator-1177"><span class="linenos">1177</span></a> <span class="p">]</span> +</span><span id="Generator-1178"><a href="#Generator-1178"><span class="linenos">1178</span></a> <span class="k">if</span> <span class="n">part</span> +</span><span id="Generator-1179"><a href="#Generator-1179"><span class="linenos">1179</span></a> <span class="p">)</span> +</span><span id="Generator-1180"><a href="#Generator-1180"><span class="linenos">1180</span></a> +</span><span id="Generator-1181"><a href="#Generator-1181"><span class="linenos">1181</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator-1182"><a href="#Generator-1182"><span class="linenos">1182</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1183"><a href="#Generator-1183"><span class="linenos">1183</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"hints"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1184"><a href="#Generator-1184"><span class="linenos">1184</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH (</span><span class="si">{</span><span class="n">hints</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">hints</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_HINTS</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1185"><a href="#Generator-1185"><span class="linenos">1185</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1186"><a href="#Generator-1186"><span class="linenos">1186</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1187"><a href="#Generator-1187"><span class="linenos">1187</span></a> <span class="n">joins</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"joins"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> +</span><span id="Generator-1188"><a href="#Generator-1188"><span class="linenos">1188</span></a> <span class="n">laterals</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"laterals"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> +</span><span id="Generator-1189"><a href="#Generator-1189"><span class="linenos">1189</span></a> <span class="n">system_time</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"system_time"</span><span class="p">)</span> +</span><span id="Generator-1190"><a href="#Generator-1190"><span class="linenos">1190</span></a> <span class="n">system_time</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'system_time'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">system_time</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1191"><a href="#Generator-1191"><span class="linenos">1191</span></a> +</span><span id="Generator-1192"><a href="#Generator-1192"><span class="linenos">1192</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">system_time</span><span class="si">}{</span><span class="n">alias</span><span class="si">}{</span><span class="n">hints</span><span class="si">}{</span><span class="n">pivots</span><span class="si">}{</span><span class="n">joins</span><span class="si">}{</span><span class="n">laterals</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1193"><a href="#Generator-1193"><span class="linenos">1193</span></a> +</span><span id="Generator-1194"><a href="#Generator-1194"><span class="linenos">1194</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="Generator-1195"><a href="#Generator-1195"><span class="linenos">1195</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" AS "</span> +</span><span id="Generator-1196"><a href="#Generator-1196"><span class="linenos">1196</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1197"><a href="#Generator-1197"><span class="linenos">1197</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> +</span><span id="Generator-1198"><a href="#Generator-1198"><span class="linenos">1198</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Generator-1199"><a href="#Generator-1199"><span class="linenos">1199</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="Generator-1200"><a href="#Generator-1200"><span class="linenos">1200</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> +</span><span id="Generator-1201"><a href="#Generator-1201"><span class="linenos">1201</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="s1">'alias'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1202"><a href="#Generator-1202"><span class="linenos">1202</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1203"><a href="#Generator-1203"><span class="linenos">1203</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1204"><a href="#Generator-1204"><span class="linenos">1204</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-1205"><a href="#Generator-1205"><span class="linenos">1205</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"method"</span><span class="p">)</span> +</span><span id="Generator-1206"><a href="#Generator-1206"><span class="linenos">1206</span></a> <span class="n">method</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">method</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1207"><a href="#Generator-1207"><span class="linenos">1207</span></a> <span class="n">numerator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_numerator"</span><span class="p">)</span> +</span><span id="Generator-1208"><a href="#Generator-1208"><span class="linenos">1208</span></a> <span class="n">denominator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_denominator"</span><span class="p">)</span> +</span><span id="Generator-1209"><a href="#Generator-1209"><span class="linenos">1209</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_field"</span><span class="p">)</span> +</span><span id="Generator-1210"><a href="#Generator-1210"><span class="linenos">1210</span></a> <span class="n">field</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">field</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1211"><a href="#Generator-1211"><span class="linenos">1211</span></a> <span class="n">bucket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"BUCKET </span><span class="si">{</span><span class="n">numerator</span><span class="si">}</span><span class="s2"> OUT OF </span><span class="si">{</span><span class="n">denominator</span><span class="si">}{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">numerator</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1212"><a href="#Generator-1212"><span class="linenos">1212</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">)</span> +</span><span id="Generator-1213"><a href="#Generator-1213"><span class="linenos">1213</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">percent</span><span class="si">}</span><span class="s2"> PERCENT"</span> <span class="k">if</span> <span class="n">percent</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1214"><a href="#Generator-1214"><span class="linenos">1214</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> +</span><span id="Generator-1215"><a href="#Generator-1215"><span class="linenos">1215</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">rows</span><span class="si">}</span><span class="s2"> ROWS"</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1216"><a href="#Generator-1216"><span class="linenos">1216</span></a> <span class="n">size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"size"</span><span class="p">)</span> +</span><span id="Generator-1217"><a href="#Generator-1217"><span class="linenos">1217</span></a> <span class="k">if</span> <span class="n">size</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span><span class="p">:</span> +</span><span id="Generator-1218"><a href="#Generator-1218"><span class="linenos">1218</span></a> <span class="n">size</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">size</span><span class="si">}</span><span class="s2"> PERCENT"</span> +</span><span id="Generator-1219"><a href="#Generator-1219"><span class="linenos">1219</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"seed"</span><span class="p">)</span> +</span><span id="Generator-1220"><a href="#Generator-1220"><span class="linenos">1220</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">seed_prefix</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">seed</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">seed</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1221"><a href="#Generator-1221"><span class="linenos">1221</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"TABLESAMPLE"</span><span class="p">)</span> +</span><span id="Generator-1222"><a href="#Generator-1222"><span class="linenos">1222</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">method</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">bucket</span><span class="si">}{</span><span class="n">percent</span><span class="si">}{</span><span class="n">rows</span><span class="si">}{</span><span class="n">size</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">seed</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1223"><a href="#Generator-1223"><span class="linenos">1223</span></a> +</span><span id="Generator-1224"><a href="#Generator-1224"><span class="linenos">1224</span></a> <span class="k">def</span> <span class="nf">pivot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1225"><a href="#Generator-1225"><span class="linenos">1225</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1226"><a href="#Generator-1226"><span class="linenos">1226</span></a> +</span><span id="Generator-1227"><a href="#Generator-1227"><span class="linenos">1227</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> +</span><span id="Generator-1228"><a href="#Generator-1228"><span class="linenos">1228</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1229"><a href="#Generator-1229"><span class="linenos">1229</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'ON'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1230"><a href="#Generator-1230"><span class="linenos">1230</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"using"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1231"><a href="#Generator-1231"><span class="linenos">1231</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'USING'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1232"><a href="#Generator-1232"><span class="linenos">1232</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">)</span> +</span><span id="Generator-1233"><a href="#Generator-1233"><span class="linenos">1233</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PIVOT </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">on</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">group</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1234"><a href="#Generator-1234"><span class="linenos">1234</span></a> +</span><span id="Generator-1235"><a href="#Generator-1235"><span class="linenos">1235</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator-1236"><a href="#Generator-1236"><span class="linenos">1236</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1237"><a href="#Generator-1237"><span class="linenos">1237</span></a> <span class="n">unpivot</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unpivot"</span><span class="p">)</span> +</span><span id="Generator-1238"><a href="#Generator-1238"><span class="linenos">1238</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="s2">"UNPIVOT"</span> <span class="k">if</span> <span class="n">unpivot</span> <span class="k">else</span> <span class="s2">"PIVOT"</span> +</span><span id="Generator-1239"><a href="#Generator-1239"><span class="linenos">1239</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"field"</span><span class="p">)</span> +</span><span id="Generator-1240"><a href="#Generator-1240"><span class="linenos">1240</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">direction</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2"> FOR </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1241"><a href="#Generator-1241"><span class="linenos">1241</span></a> +</span><span id="Generator-1242"><a href="#Generator-1242"><span class="linenos">1242</span></a> <span class="k">def</span> <span class="nf">tuple_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Tuple</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1243"><a href="#Generator-1243"><span class="linenos">1243</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> </span><span id="Generator-1244"><a href="#Generator-1244"><span class="linenos">1244</span></a> -</span><span id="Generator-1245"><a href="#Generator-1245"><span class="linenos">1245</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1246"><a href="#Generator-1246"><span class="linenos">1246</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1247"><a href="#Generator-1247"><span class="linenos">1247</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator-1248"><a href="#Generator-1248"><span class="linenos">1248</span></a> <span class="n">values</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"VALUES</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1249"><a href="#Generator-1249"><span class="linenos">1249</span></a> <span class="n">values</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-1250"><a href="#Generator-1250"><span class="linenos">1250</span></a> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">values</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1251"><a href="#Generator-1251"><span class="linenos">1251</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">WRAP_DERIVED_VALUES</span> <span class="ow">and</span> <span class="p">(</span><span class="n">alias</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">))</span> -</span><span id="Generator-1252"><a href="#Generator-1252"><span class="linenos">1252</span></a> <span class="k">else</span> <span class="n">values</span> -</span><span id="Generator-1253"><a href="#Generator-1253"><span class="linenos">1253</span></a> <span class="p">)</span> -</span><span id="Generator-1254"><a href="#Generator-1254"><span class="linenos">1254</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">values</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">values</span> -</span><span id="Generator-1255"><a href="#Generator-1255"><span class="linenos">1255</span></a> -</span><span id="Generator-1256"><a href="#Generator-1256"><span class="linenos">1256</span></a> <span class="k">def</span> <span class="nf">var_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Var</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1257"><a href="#Generator-1257"><span class="linenos">1257</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1258"><a href="#Generator-1258"><span class="linenos">1258</span></a> -</span><span id="Generator-1259"><a href="#Generator-1259"><span class="linenos">1259</span></a> <span class="k">def</span> <span class="nf">into_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Into</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1260"><a href="#Generator-1260"><span class="linenos">1260</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1261"><a href="#Generator-1261"><span class="linenos">1261</span></a> <span class="n">unlogged</span> <span class="o">=</span> <span class="s2">" UNLOGGED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unlogged"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1262"><a href="#Generator-1262"><span class="linenos">1262</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'INTO'</span><span class="p">)</span><span class="si">}{</span><span class="n">temporary</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="n">unlogged</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1263"><a href="#Generator-1263"><span class="linenos">1263</span></a> -</span><span id="Generator-1264"><a href="#Generator-1264"><span class="linenos">1264</span></a> <span class="k">def</span> <span class="nf">from_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1265"><a href="#Generator-1265"><span class="linenos">1265</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'FROM'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1266"><a href="#Generator-1266"><span class="linenos">1266</span></a> -</span><span id="Generator-1267"><a href="#Generator-1267"><span class="linenos">1267</span></a> <span class="k">def</span> <span class="nf">group_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Group</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1268"><a href="#Generator-1268"><span class="linenos">1268</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"GROUP BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1269"><a href="#Generator-1269"><span class="linenos">1269</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"grouping_sets"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator-1270"><a href="#Generator-1270"><span class="linenos">1270</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-1271"><a href="#Generator-1271"><span class="linenos">1271</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'GROUPING SETS'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">grouping_sets</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">grouping_sets</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1272"><a href="#Generator-1272"><span class="linenos">1272</span></a> <span class="p">)</span> -</span><span id="Generator-1273"><a href="#Generator-1273"><span class="linenos">1273</span></a> -</span><span id="Generator-1274"><a href="#Generator-1274"><span class="linenos">1274</span></a> <span class="n">cube</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"cube"</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="Generator-1275"><a href="#Generator-1275"><span class="linenos">1275</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">cube</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Generator-1276"><a href="#Generator-1276"><span class="linenos">1276</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'WITH CUBE'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1277"><a href="#Generator-1277"><span class="linenos">1277</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1278"><a href="#Generator-1278"><span class="linenos">1278</span></a> <span class="n">cube_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"cube"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator-1279"><a href="#Generator-1279"><span class="linenos">1279</span></a> <span class="n">cube_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'CUBE'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">cube_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">cube_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1280"><a href="#Generator-1280"><span class="linenos">1280</span></a> -</span><span id="Generator-1281"><a href="#Generator-1281"><span class="linenos">1281</span></a> <span class="n">rollup</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"rollup"</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="Generator-1282"><a href="#Generator-1282"><span class="linenos">1282</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">rollup</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Generator-1283"><a href="#Generator-1283"><span class="linenos">1283</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'WITH ROLLUP'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1284"><a href="#Generator-1284"><span class="linenos">1284</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1285"><a href="#Generator-1285"><span class="linenos">1285</span></a> <span class="n">rollup_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"rollup"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator-1286"><a href="#Generator-1286"><span class="linenos">1286</span></a> <span class="n">rollup_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'ROLLUP'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">rollup_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">rollup_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1287"><a href="#Generator-1287"><span class="linenos">1287</span></a> -</span><span id="Generator-1288"><a href="#Generator-1288"><span class="linenos">1288</span></a> <span class="n">groupings</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span> -</span><span id="Generator-1289"><a href="#Generator-1289"><span class="linenos">1289</span></a> <span class="n">grouping_sets</span><span class="p">,</span> -</span><span id="Generator-1290"><a href="#Generator-1290"><span class="linenos">1290</span></a> <span class="n">cube_sql</span><span class="p">,</span> -</span><span id="Generator-1291"><a href="#Generator-1291"><span class="linenos">1291</span></a> <span class="n">rollup_sql</span><span class="p">,</span> -</span><span id="Generator-1292"><a href="#Generator-1292"><span class="linenos">1292</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WITH TOTALS"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"totals"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="Generator-1293"><a href="#Generator-1293"><span class="linenos">1293</span></a> <span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="p">,</span> -</span><span id="Generator-1294"><a href="#Generator-1294"><span class="linenos">1294</span></a> <span class="p">)</span> -</span><span id="Generator-1295"><a href="#Generator-1295"><span class="linenos">1295</span></a> -</span><span id="Generator-1296"><a href="#Generator-1296"><span class="linenos">1296</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> <span class="ow">and</span> <span class="n">groupings</span><span class="p">:</span> -</span><span id="Generator-1297"><a href="#Generator-1297"><span class="linenos">1297</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1298"><a href="#Generator-1298"><span class="linenos">1298</span></a> -</span><span id="Generator-1299"><a href="#Generator-1299"><span class="linenos">1299</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="n">groupings</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1300"><a href="#Generator-1300"><span class="linenos">1300</span></a> -</span><span id="Generator-1301"><a href="#Generator-1301"><span class="linenos">1301</span></a> <span class="k">def</span> <span class="nf">having_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Having</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1302"><a href="#Generator-1302"><span class="linenos">1302</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))</span> -</span><span id="Generator-1303"><a href="#Generator-1303"><span class="linenos">1303</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'HAVING'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1245"><a href="#Generator-1245"><span class="linenos">1245</span></a> <span class="k">def</span> <span class="nf">update_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1246"><a href="#Generator-1246"><span class="linenos">1246</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1247"><a href="#Generator-1247"><span class="linenos">1247</span></a> <span class="n">set_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1248"><a href="#Generator-1248"><span class="linenos">1248</span></a> <span class="n">from_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">)</span> +</span><span id="Generator-1249"><a href="#Generator-1249"><span class="linenos">1249</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> +</span><span id="Generator-1250"><a href="#Generator-1250"><span class="linenos">1250</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="Generator-1251"><a href="#Generator-1251"><span class="linenos">1251</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1252"><a href="#Generator-1252"><span class="linenos">1252</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="Generator-1253"><a href="#Generator-1253"><span class="linenos">1253</span></a> +</span><span id="Generator-1254"><a href="#Generator-1254"><span class="linenos">1254</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1255"><a href="#Generator-1255"><span class="linenos">1255</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1256"><a href="#Generator-1256"><span class="linenos">1256</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator-1257"><a href="#Generator-1257"><span class="linenos">1257</span></a> <span class="n">values</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"VALUES</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1258"><a href="#Generator-1258"><span class="linenos">1258</span></a> <span class="n">values</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-1259"><a href="#Generator-1259"><span class="linenos">1259</span></a> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">values</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1260"><a href="#Generator-1260"><span class="linenos">1260</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">WRAP_DERIVED_VALUES</span> <span class="ow">and</span> <span class="p">(</span><span class="n">alias</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">))</span> +</span><span id="Generator-1261"><a href="#Generator-1261"><span class="linenos">1261</span></a> <span class="k">else</span> <span class="n">values</span> +</span><span id="Generator-1262"><a href="#Generator-1262"><span class="linenos">1262</span></a> <span class="p">)</span> +</span><span id="Generator-1263"><a href="#Generator-1263"><span class="linenos">1263</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">values</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">values</span> +</span><span id="Generator-1264"><a href="#Generator-1264"><span class="linenos">1264</span></a> +</span><span id="Generator-1265"><a href="#Generator-1265"><span class="linenos">1265</span></a> <span class="k">def</span> <span class="nf">var_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Var</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1266"><a href="#Generator-1266"><span class="linenos">1266</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1267"><a href="#Generator-1267"><span class="linenos">1267</span></a> +</span><span id="Generator-1268"><a href="#Generator-1268"><span class="linenos">1268</span></a> <span class="k">def</span> <span class="nf">into_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Into</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1269"><a href="#Generator-1269"><span class="linenos">1269</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1270"><a href="#Generator-1270"><span class="linenos">1270</span></a> <span class="n">unlogged</span> <span class="o">=</span> <span class="s2">" UNLOGGED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unlogged"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1271"><a href="#Generator-1271"><span class="linenos">1271</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'INTO'</span><span class="p">)</span><span class="si">}{</span><span class="n">temporary</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="n">unlogged</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1272"><a href="#Generator-1272"><span class="linenos">1272</span></a> +</span><span id="Generator-1273"><a href="#Generator-1273"><span class="linenos">1273</span></a> <span class="k">def</span> <span class="nf">from_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1274"><a href="#Generator-1274"><span class="linenos">1274</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'FROM'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1275"><a href="#Generator-1275"><span class="linenos">1275</span></a> +</span><span id="Generator-1276"><a href="#Generator-1276"><span class="linenos">1276</span></a> <span class="k">def</span> <span class="nf">group_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Group</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1277"><a href="#Generator-1277"><span class="linenos">1277</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"GROUP BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1278"><a href="#Generator-1278"><span class="linenos">1278</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"grouping_sets"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator-1279"><a href="#Generator-1279"><span class="linenos">1279</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-1280"><a href="#Generator-1280"><span class="linenos">1280</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'GROUPING SETS'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">grouping_sets</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">grouping_sets</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1281"><a href="#Generator-1281"><span class="linenos">1281</span></a> <span class="p">)</span> +</span><span id="Generator-1282"><a href="#Generator-1282"><span class="linenos">1282</span></a> +</span><span id="Generator-1283"><a href="#Generator-1283"><span class="linenos">1283</span></a> <span class="n">cube</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"cube"</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="Generator-1284"><a href="#Generator-1284"><span class="linenos">1284</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">cube</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Generator-1285"><a href="#Generator-1285"><span class="linenos">1285</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'WITH CUBE'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1286"><a href="#Generator-1286"><span class="linenos">1286</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1287"><a href="#Generator-1287"><span class="linenos">1287</span></a> <span class="n">cube_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"cube"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator-1288"><a href="#Generator-1288"><span class="linenos">1288</span></a> <span class="n">cube_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'CUBE'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">cube_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">cube_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1289"><a href="#Generator-1289"><span class="linenos">1289</span></a> +</span><span id="Generator-1290"><a href="#Generator-1290"><span class="linenos">1290</span></a> <span class="n">rollup</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"rollup"</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="Generator-1291"><a href="#Generator-1291"><span class="linenos">1291</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">rollup</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Generator-1292"><a href="#Generator-1292"><span class="linenos">1292</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'WITH ROLLUP'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1293"><a href="#Generator-1293"><span class="linenos">1293</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1294"><a href="#Generator-1294"><span class="linenos">1294</span></a> <span class="n">rollup_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"rollup"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator-1295"><a href="#Generator-1295"><span class="linenos">1295</span></a> <span class="n">rollup_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'ROLLUP'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">rollup_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">rollup_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1296"><a href="#Generator-1296"><span class="linenos">1296</span></a> +</span><span id="Generator-1297"><a href="#Generator-1297"><span class="linenos">1297</span></a> <span class="n">groupings</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span> +</span><span id="Generator-1298"><a href="#Generator-1298"><span class="linenos">1298</span></a> <span class="n">grouping_sets</span><span class="p">,</span> +</span><span id="Generator-1299"><a href="#Generator-1299"><span class="linenos">1299</span></a> <span class="n">cube_sql</span><span class="p">,</span> +</span><span id="Generator-1300"><a href="#Generator-1300"><span class="linenos">1300</span></a> <span class="n">rollup_sql</span><span class="p">,</span> +</span><span id="Generator-1301"><a href="#Generator-1301"><span class="linenos">1301</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WITH TOTALS"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"totals"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="Generator-1302"><a href="#Generator-1302"><span class="linenos">1302</span></a> <span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="p">,</span> +</span><span id="Generator-1303"><a href="#Generator-1303"><span class="linenos">1303</span></a> <span class="p">)</span> </span><span id="Generator-1304"><a href="#Generator-1304"><span class="linenos">1304</span></a> -</span><span id="Generator-1305"><a href="#Generator-1305"><span class="linenos">1305</span></a> <span class="k">def</span> <span class="nf">join_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1306"><a href="#Generator-1306"><span class="linenos">1306</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator-1307"><a href="#Generator-1307"><span class="linenos">1307</span></a> <span class="n">op</span> -</span><span id="Generator-1308"><a href="#Generator-1308"><span class="linenos">1308</span></a> <span class="k">for</span> <span class="n">op</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="Generator-1309"><a href="#Generator-1309"><span class="linenos">1309</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">method</span><span class="p">,</span> -</span><span id="Generator-1310"><a href="#Generator-1310"><span class="linenos">1310</span></a> <span class="s2">"GLOBAL"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-1311"><a href="#Generator-1311"><span class="linenos">1311</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">side</span><span class="p">,</span> -</span><span id="Generator-1312"><a href="#Generator-1312"><span class="linenos">1312</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">kind</span><span class="p">,</span> -</span><span id="Generator-1313"><a href="#Generator-1313"><span class="linenos">1313</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">hint</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">JOIN_HINTS</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-1314"><a href="#Generator-1314"><span class="linenos">1314</span></a> <span class="p">)</span> -</span><span id="Generator-1315"><a href="#Generator-1315"><span class="linenos">1315</span></a> <span class="k">if</span> <span class="n">op</span> -</span><span id="Generator-1316"><a href="#Generator-1316"><span class="linenos">1316</span></a> <span class="p">)</span> -</span><span id="Generator-1317"><a href="#Generator-1317"><span class="linenos">1317</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">)</span> -</span><span id="Generator-1318"><a href="#Generator-1318"><span class="linenos">1318</span></a> <span class="n">using</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"using"</span><span class="p">)</span> -</span><span id="Generator-1319"><a href="#Generator-1319"><span class="linenos">1319</span></a> -</span><span id="Generator-1320"><a href="#Generator-1320"><span class="linenos">1320</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">on_sql</span> <span class="ow">and</span> <span class="n">using</span><span class="p">:</span> -</span><span id="Generator-1321"><a href="#Generator-1321"><span class="linenos">1321</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span><span class="o">*</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">column</span><span class="p">)</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">using</span><span class="p">))</span> -</span><span id="Generator-1322"><a href="#Generator-1322"><span class="linenos">1322</span></a> -</span><span id="Generator-1323"><a href="#Generator-1323"><span class="linenos">1323</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1324"><a href="#Generator-1324"><span class="linenos">1324</span></a> -</span><span id="Generator-1325"><a href="#Generator-1325"><span class="linenos">1325</span></a> <span class="k">if</span> <span class="n">on_sql</span><span class="p">:</span> -</span><span id="Generator-1326"><a href="#Generator-1326"><span class="linenos">1326</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">on_sql</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1327"><a href="#Generator-1327"><span class="linenos">1327</span></a> <span class="n">space</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator-1328"><a href="#Generator-1328"><span class="linenos">1328</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> -</span><span id="Generator-1329"><a href="#Generator-1329"><span class="linenos">1329</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">USING (</span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1330"><a href="#Generator-1330"><span class="linenos">1330</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1331"><a href="#Generator-1331"><span class="linenos">1331</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1332"><a href="#Generator-1332"><span class="linenos">1332</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">op_sql</span><span class="p">:</span> -</span><span id="Generator-1333"><a href="#Generator-1333"><span class="linenos">1333</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1334"><a href="#Generator-1334"><span class="linenos">1334</span></a> -</span><span id="Generator-1335"><a href="#Generator-1335"><span class="linenos">1335</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</span><span class="si">}</span><span class="s2"> JOIN"</span> <span class="k">if</span> <span class="n">op_sql</span> <span class="k">else</span> <span class="s2">"JOIN"</span> -</span><span id="Generator-1336"><a href="#Generator-1336"><span class="linenos">1336</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op_sql</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1337"><a href="#Generator-1337"><span class="linenos">1337</span></a> -</span><span id="Generator-1338"><a href="#Generator-1338"><span class="linenos">1338</span></a> <span class="k">def</span> <span class="nf">lambda_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lambda</span><span class="p">,</span> <span class="n">arrow_sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"->"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1339"><a href="#Generator-1339"><span class="linenos">1339</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1340"><a href="#Generator-1340"><span class="linenos">1340</span></a> <span class="n">args</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">))</span> <span class="o">></span> <span class="mi">1</span> <span class="k">else</span> <span class="n">args</span> -</span><span id="Generator-1341"><a href="#Generator-1341"><span class="linenos">1341</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">arrow_sep</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1342"><a href="#Generator-1342"><span class="linenos">1342</span></a> -</span><span id="Generator-1343"><a href="#Generator-1343"><span class="linenos">1343</span></a> <span class="k">def</span> <span class="nf">lateral_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1344"><a href="#Generator-1344"><span class="linenos">1344</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1345"><a href="#Generator-1345"><span class="linenos">1345</span></a> -</span><span id="Generator-1346"><a href="#Generator-1346"><span class="linenos">1346</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">):</span> -</span><span id="Generator-1347"><a href="#Generator-1347"><span class="linenos">1347</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LATERAL </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1348"><a href="#Generator-1348"><span class="linenos">1348</span></a> -</span><span id="Generator-1349"><a href="#Generator-1349"><span class="linenos">1349</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"view"</span><span class="p">):</span> -</span><span id="Generator-1350"><a href="#Generator-1350"><span class="linenos">1350</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"alias"</span><span class="p">]</span> -</span><span id="Generator-1351"><a href="#Generator-1351"><span class="linenos">1351</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1352"><a href="#Generator-1352"><span class="linenos">1352</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">alias</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1353"><a href="#Generator-1353"><span class="linenos">1353</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1354"><a href="#Generator-1354"><span class="linenos">1354</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"LATERAL VIEW</span><span class="si">{</span><span class="s1">' OUTER'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'outer'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-1355"><a href="#Generator-1355"><span class="linenos">1355</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1356"><a href="#Generator-1356"><span class="linenos">1356</span></a> -</span><span id="Generator-1357"><a href="#Generator-1357"><span class="linenos">1357</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator-1358"><a href="#Generator-1358"><span class="linenos">1358</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1359"><a href="#Generator-1359"><span class="linenos">1359</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LATERAL </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1360"><a href="#Generator-1360"><span class="linenos">1360</span></a> -</span><span id="Generator-1361"><a href="#Generator-1361"><span class="linenos">1361</span></a> <span class="k">def</span> <span class="nf">limit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1362"><a href="#Generator-1362"><span class="linenos">1362</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1363"><a href="#Generator-1363"><span class="linenos">1363</span></a> <span class="n">args</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator-1364"><a href="#Generator-1364"><span class="linenos">1364</span></a> <span class="n">sql</span> -</span><span id="Generator-1365"><a href="#Generator-1365"><span class="linenos">1365</span></a> <span class="k">for</span> <span class="n">sql</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="Generator-1366"><a href="#Generator-1366"><span class="linenos">1366</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> -</span><span id="Generator-1367"><a href="#Generator-1367"><span class="linenos">1367</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">),</span> -</span><span id="Generator-1368"><a href="#Generator-1368"><span class="linenos">1368</span></a> <span class="p">)</span> -</span><span id="Generator-1369"><a href="#Generator-1369"><span class="linenos">1369</span></a> <span class="k">if</span> <span class="n">sql</span> -</span><span id="Generator-1370"><a href="#Generator-1370"><span class="linenos">1370</span></a> <span class="p">)</span> -</span><span id="Generator-1371"><a href="#Generator-1371"><span class="linenos">1371</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'LIMIT'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1372"><a href="#Generator-1372"><span class="linenos">1372</span></a> -</span><span id="Generator-1373"><a href="#Generator-1373"><span class="linenos">1373</span></a> <span class="k">def</span> <span class="nf">offset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Offset</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1374"><a href="#Generator-1374"><span class="linenos">1374</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1375"><a href="#Generator-1375"><span class="linenos">1375</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'OFFSET'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1376"><a href="#Generator-1376"><span class="linenos">1376</span></a> -</span><span id="Generator-1377"><a href="#Generator-1377"><span class="linenos">1377</span></a> <span class="k">def</span> <span class="nf">setitem_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetItem</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1378"><a href="#Generator-1378"><span class="linenos">1378</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator-1379"><a href="#Generator-1379"><span class="linenos">1379</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1380"><a href="#Generator-1380"><span class="linenos">1380</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1381"><a href="#Generator-1381"><span class="linenos">1381</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1382"><a href="#Generator-1382"><span class="linenos">1382</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collate"</span><span class="p">)</span> -</span><span id="Generator-1383"><a href="#Generator-1383"><span class="linenos">1383</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collate</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1384"><a href="#Generator-1384"><span class="linenos">1384</span></a> <span class="n">global_</span> <span class="o">=</span> <span class="s2">"GLOBAL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1385"><a href="#Generator-1385"><span class="linenos">1385</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">global_</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1386"><a href="#Generator-1386"><span class="linenos">1386</span></a> -</span><span id="Generator-1387"><a href="#Generator-1387"><span class="linenos">1387</span></a> <span class="k">def</span> <span class="nf">set_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1388"><a href="#Generator-1388"><span class="linenos">1388</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-1389"><a href="#Generator-1389"><span class="linenos">1389</span></a> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1390"><a href="#Generator-1390"><span class="linenos">1390</span></a> <span class="p">)</span> -</span><span id="Generator-1391"><a href="#Generator-1391"><span class="linenos">1391</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SET</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1392"><a href="#Generator-1392"><span class="linenos">1392</span></a> -</span><span id="Generator-1393"><a href="#Generator-1393"><span class="linenos">1393</span></a> <span class="k">def</span> <span class="nf">pragma_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pragma</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1394"><a href="#Generator-1394"><span class="linenos">1394</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRAGMA </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1305"><a href="#Generator-1305"><span class="linenos">1305</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> <span class="ow">and</span> <span class="n">groupings</span><span class="p">:</span> +</span><span id="Generator-1306"><a href="#Generator-1306"><span class="linenos">1306</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1307"><a href="#Generator-1307"><span class="linenos">1307</span></a> +</span><span id="Generator-1308"><a href="#Generator-1308"><span class="linenos">1308</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="n">groupings</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1309"><a href="#Generator-1309"><span class="linenos">1309</span></a> +</span><span id="Generator-1310"><a href="#Generator-1310"><span class="linenos">1310</span></a> <span class="k">def</span> <span class="nf">having_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Having</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1311"><a href="#Generator-1311"><span class="linenos">1311</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))</span> +</span><span id="Generator-1312"><a href="#Generator-1312"><span class="linenos">1312</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'HAVING'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1313"><a href="#Generator-1313"><span class="linenos">1313</span></a> +</span><span id="Generator-1314"><a href="#Generator-1314"><span class="linenos">1314</span></a> <span class="k">def</span> <span class="nf">join_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1315"><a href="#Generator-1315"><span class="linenos">1315</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator-1316"><a href="#Generator-1316"><span class="linenos">1316</span></a> <span class="n">op</span> +</span><span id="Generator-1317"><a href="#Generator-1317"><span class="linenos">1317</span></a> <span class="k">for</span> <span class="n">op</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="Generator-1318"><a href="#Generator-1318"><span class="linenos">1318</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">method</span><span class="p">,</span> +</span><span id="Generator-1319"><a href="#Generator-1319"><span class="linenos">1319</span></a> <span class="s2">"GLOBAL"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-1320"><a href="#Generator-1320"><span class="linenos">1320</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">side</span><span class="p">,</span> +</span><span id="Generator-1321"><a href="#Generator-1321"><span class="linenos">1321</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">kind</span><span class="p">,</span> +</span><span id="Generator-1322"><a href="#Generator-1322"><span class="linenos">1322</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">hint</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">JOIN_HINTS</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-1323"><a href="#Generator-1323"><span class="linenos">1323</span></a> <span class="p">)</span> +</span><span id="Generator-1324"><a href="#Generator-1324"><span class="linenos">1324</span></a> <span class="k">if</span> <span class="n">op</span> +</span><span id="Generator-1325"><a href="#Generator-1325"><span class="linenos">1325</span></a> <span class="p">)</span> +</span><span id="Generator-1326"><a href="#Generator-1326"><span class="linenos">1326</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">)</span> +</span><span id="Generator-1327"><a href="#Generator-1327"><span class="linenos">1327</span></a> <span class="n">using</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"using"</span><span class="p">)</span> +</span><span id="Generator-1328"><a href="#Generator-1328"><span class="linenos">1328</span></a> +</span><span id="Generator-1329"><a href="#Generator-1329"><span class="linenos">1329</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">on_sql</span> <span class="ow">and</span> <span class="n">using</span><span class="p">:</span> +</span><span id="Generator-1330"><a href="#Generator-1330"><span class="linenos">1330</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span><span class="o">*</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">column</span><span class="p">)</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">using</span><span class="p">))</span> +</span><span id="Generator-1331"><a href="#Generator-1331"><span class="linenos">1331</span></a> +</span><span id="Generator-1332"><a href="#Generator-1332"><span class="linenos">1332</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1333"><a href="#Generator-1333"><span class="linenos">1333</span></a> +</span><span id="Generator-1334"><a href="#Generator-1334"><span class="linenos">1334</span></a> <span class="k">if</span> <span class="n">on_sql</span><span class="p">:</span> +</span><span id="Generator-1335"><a href="#Generator-1335"><span class="linenos">1335</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">on_sql</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1336"><a href="#Generator-1336"><span class="linenos">1336</span></a> <span class="n">space</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator-1337"><a href="#Generator-1337"><span class="linenos">1337</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> +</span><span id="Generator-1338"><a href="#Generator-1338"><span class="linenos">1338</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">USING (</span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1339"><a href="#Generator-1339"><span class="linenos">1339</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1340"><a href="#Generator-1340"><span class="linenos">1340</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1341"><a href="#Generator-1341"><span class="linenos">1341</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">op_sql</span><span class="p">:</span> +</span><span id="Generator-1342"><a href="#Generator-1342"><span class="linenos">1342</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1343"><a href="#Generator-1343"><span class="linenos">1343</span></a> +</span><span id="Generator-1344"><a href="#Generator-1344"><span class="linenos">1344</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</span><span class="si">}</span><span class="s2"> JOIN"</span> <span class="k">if</span> <span class="n">op_sql</span> <span class="k">else</span> <span class="s2">"JOIN"</span> +</span><span id="Generator-1345"><a href="#Generator-1345"><span class="linenos">1345</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op_sql</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1346"><a href="#Generator-1346"><span class="linenos">1346</span></a> +</span><span id="Generator-1347"><a href="#Generator-1347"><span class="linenos">1347</span></a> <span class="k">def</span> <span class="nf">lambda_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lambda</span><span class="p">,</span> <span class="n">arrow_sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"->"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1348"><a href="#Generator-1348"><span class="linenos">1348</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1349"><a href="#Generator-1349"><span class="linenos">1349</span></a> <span class="n">args</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">))</span> <span class="o">></span> <span class="mi">1</span> <span class="k">else</span> <span class="n">args</span> +</span><span id="Generator-1350"><a href="#Generator-1350"><span class="linenos">1350</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">arrow_sep</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1351"><a href="#Generator-1351"><span class="linenos">1351</span></a> +</span><span id="Generator-1352"><a href="#Generator-1352"><span class="linenos">1352</span></a> <span class="k">def</span> <span class="nf">lateral_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1353"><a href="#Generator-1353"><span class="linenos">1353</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1354"><a href="#Generator-1354"><span class="linenos">1354</span></a> +</span><span id="Generator-1355"><a href="#Generator-1355"><span class="linenos">1355</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">):</span> +</span><span id="Generator-1356"><a href="#Generator-1356"><span class="linenos">1356</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LATERAL </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1357"><a href="#Generator-1357"><span class="linenos">1357</span></a> +</span><span id="Generator-1358"><a href="#Generator-1358"><span class="linenos">1358</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"view"</span><span class="p">):</span> +</span><span id="Generator-1359"><a href="#Generator-1359"><span class="linenos">1359</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"alias"</span><span class="p">]</span> +</span><span id="Generator-1360"><a href="#Generator-1360"><span class="linenos">1360</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1361"><a href="#Generator-1361"><span class="linenos">1361</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">alias</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1362"><a href="#Generator-1362"><span class="linenos">1362</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1363"><a href="#Generator-1363"><span class="linenos">1363</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"LATERAL VIEW</span><span class="si">{</span><span class="s1">' OUTER'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'outer'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-1364"><a href="#Generator-1364"><span class="linenos">1364</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1365"><a href="#Generator-1365"><span class="linenos">1365</span></a> +</span><span id="Generator-1366"><a href="#Generator-1366"><span class="linenos">1366</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator-1367"><a href="#Generator-1367"><span class="linenos">1367</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1368"><a href="#Generator-1368"><span class="linenos">1368</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LATERAL </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1369"><a href="#Generator-1369"><span class="linenos">1369</span></a> +</span><span id="Generator-1370"><a href="#Generator-1370"><span class="linenos">1370</span></a> <span class="k">def</span> <span class="nf">limit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1371"><a href="#Generator-1371"><span class="linenos">1371</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1372"><a href="#Generator-1372"><span class="linenos">1372</span></a> <span class="n">args</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator-1373"><a href="#Generator-1373"><span class="linenos">1373</span></a> <span class="n">sql</span> +</span><span id="Generator-1374"><a href="#Generator-1374"><span class="linenos">1374</span></a> <span class="k">for</span> <span class="n">sql</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="Generator-1375"><a href="#Generator-1375"><span class="linenos">1375</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> +</span><span id="Generator-1376"><a href="#Generator-1376"><span class="linenos">1376</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">),</span> +</span><span id="Generator-1377"><a href="#Generator-1377"><span class="linenos">1377</span></a> <span class="p">)</span> +</span><span id="Generator-1378"><a href="#Generator-1378"><span class="linenos">1378</span></a> <span class="k">if</span> <span class="n">sql</span> +</span><span id="Generator-1379"><a href="#Generator-1379"><span class="linenos">1379</span></a> <span class="p">)</span> +</span><span id="Generator-1380"><a href="#Generator-1380"><span class="linenos">1380</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'LIMIT'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1381"><a href="#Generator-1381"><span class="linenos">1381</span></a> +</span><span id="Generator-1382"><a href="#Generator-1382"><span class="linenos">1382</span></a> <span class="k">def</span> <span class="nf">offset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Offset</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1383"><a href="#Generator-1383"><span class="linenos">1383</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1384"><a href="#Generator-1384"><span class="linenos">1384</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'OFFSET'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1385"><a href="#Generator-1385"><span class="linenos">1385</span></a> +</span><span id="Generator-1386"><a href="#Generator-1386"><span class="linenos">1386</span></a> <span class="k">def</span> <span class="nf">setitem_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetItem</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1387"><a href="#Generator-1387"><span class="linenos">1387</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator-1388"><a href="#Generator-1388"><span class="linenos">1388</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1389"><a href="#Generator-1389"><span class="linenos">1389</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1390"><a href="#Generator-1390"><span class="linenos">1390</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1391"><a href="#Generator-1391"><span class="linenos">1391</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collate"</span><span class="p">)</span> +</span><span id="Generator-1392"><a href="#Generator-1392"><span class="linenos">1392</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collate</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1393"><a href="#Generator-1393"><span class="linenos">1393</span></a> <span class="n">global_</span> <span class="o">=</span> <span class="s2">"GLOBAL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1394"><a href="#Generator-1394"><span class="linenos">1394</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">global_</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-1395"><a href="#Generator-1395"><span class="linenos">1395</span></a> -</span><span id="Generator-1396"><a href="#Generator-1396"><span class="linenos">1396</span></a> <span class="k">def</span> <span class="nf">lock_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lock</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1397"><a href="#Generator-1397"><span class="linenos">1397</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOCKING_READS_SUPPORTED</span><span class="p">:</span> -</span><span id="Generator-1398"><a href="#Generator-1398"><span class="linenos">1398</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Locking reads using 'FOR UPDATE/SHARE' are not supported"</span><span class="p">)</span> -</span><span id="Generator-1399"><a href="#Generator-1399"><span class="linenos">1399</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator-1400"><a href="#Generator-1400"><span class="linenos">1400</span></a> -</span><span id="Generator-1401"><a href="#Generator-1401"><span class="linenos">1401</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"FOR UPDATE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"update"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"FOR SHARE"</span> -</span><span id="Generator-1402"><a href="#Generator-1402"><span class="linenos">1402</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1403"><a href="#Generator-1403"><span class="linenos">1403</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OF </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1404"><a href="#Generator-1404"><span class="linenos">1404</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"wait"</span><span class="p">)</span> -</span><span id="Generator-1405"><a href="#Generator-1405"><span class="linenos">1405</span></a> -</span><span id="Generator-1406"><a href="#Generator-1406"><span class="linenos">1406</span></a> <span class="k">if</span> <span class="n">wait</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-1407"><a href="#Generator-1407"><span class="linenos">1407</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">wait</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> -</span><span id="Generator-1408"><a href="#Generator-1408"><span class="linenos">1408</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WAIT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">wait</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1409"><a href="#Generator-1409"><span class="linenos">1409</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1410"><a href="#Generator-1410"><span class="linenos">1410</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="s2">" NOWAIT"</span> <span class="k">if</span> <span class="n">wait</span> <span class="k">else</span> <span class="s2">" SKIP LOCKED"</span> -</span><span id="Generator-1411"><a href="#Generator-1411"><span class="linenos">1411</span></a> -</span><span id="Generator-1412"><a href="#Generator-1412"><span class="linenos">1412</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">wait</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1413"><a href="#Generator-1413"><span class="linenos">1413</span></a> -</span><span id="Generator-1414"><a href="#Generator-1414"><span class="linenos">1414</span></a> <span class="k">def</span> <span class="nf">literal_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1415"><a href="#Generator-1415"><span class="linenos">1415</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">or</span> <span class="s2">""</span> -</span><span id="Generator-1416"><a href="#Generator-1416"><span class="linenos">1416</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> -</span><span id="Generator-1417"><a href="#Generator-1417"><span class="linenos">1417</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">)</span> -</span><span id="Generator-1418"><a href="#Generator-1418"><span class="linenos">1418</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="Generator-1419"><a href="#Generator-1419"><span class="linenos">1419</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">)</span> -</span><span id="Generator-1420"><a href="#Generator-1420"><span class="linenos">1420</span></a> <span class="n">text</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="n">text</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1421"><a href="#Generator-1421"><span class="linenos">1421</span></a> <span class="k">return</span> <span class="n">text</span> +</span><span id="Generator-1396"><a href="#Generator-1396"><span class="linenos">1396</span></a> <span class="k">def</span> <span class="nf">set_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1397"><a href="#Generator-1397"><span class="linenos">1397</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-1398"><a href="#Generator-1398"><span class="linenos">1398</span></a> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1399"><a href="#Generator-1399"><span class="linenos">1399</span></a> <span class="p">)</span> +</span><span id="Generator-1400"><a href="#Generator-1400"><span class="linenos">1400</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SET</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1401"><a href="#Generator-1401"><span class="linenos">1401</span></a> +</span><span id="Generator-1402"><a href="#Generator-1402"><span class="linenos">1402</span></a> <span class="k">def</span> <span class="nf">pragma_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pragma</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1403"><a href="#Generator-1403"><span class="linenos">1403</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRAGMA </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1404"><a href="#Generator-1404"><span class="linenos">1404</span></a> +</span><span id="Generator-1405"><a href="#Generator-1405"><span class="linenos">1405</span></a> <span class="k">def</span> <span class="nf">lock_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lock</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1406"><a href="#Generator-1406"><span class="linenos">1406</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOCKING_READS_SUPPORTED</span><span class="p">:</span> +</span><span id="Generator-1407"><a href="#Generator-1407"><span class="linenos">1407</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Locking reads using 'FOR UPDATE/SHARE' are not supported"</span><span class="p">)</span> +</span><span id="Generator-1408"><a href="#Generator-1408"><span class="linenos">1408</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator-1409"><a href="#Generator-1409"><span class="linenos">1409</span></a> +</span><span id="Generator-1410"><a href="#Generator-1410"><span class="linenos">1410</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"FOR UPDATE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"update"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"FOR SHARE"</span> +</span><span id="Generator-1411"><a href="#Generator-1411"><span class="linenos">1411</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1412"><a href="#Generator-1412"><span class="linenos">1412</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OF </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1413"><a href="#Generator-1413"><span class="linenos">1413</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"wait"</span><span class="p">)</span> +</span><span id="Generator-1414"><a href="#Generator-1414"><span class="linenos">1414</span></a> +</span><span id="Generator-1415"><a href="#Generator-1415"><span class="linenos">1415</span></a> <span class="k">if</span> <span class="n">wait</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-1416"><a href="#Generator-1416"><span class="linenos">1416</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">wait</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> +</span><span id="Generator-1417"><a href="#Generator-1417"><span class="linenos">1417</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WAIT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">wait</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1418"><a href="#Generator-1418"><span class="linenos">1418</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1419"><a href="#Generator-1419"><span class="linenos">1419</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="s2">" NOWAIT"</span> <span class="k">if</span> <span class="n">wait</span> <span class="k">else</span> <span class="s2">" SKIP LOCKED"</span> +</span><span id="Generator-1420"><a href="#Generator-1420"><span class="linenos">1420</span></a> +</span><span id="Generator-1421"><a href="#Generator-1421"><span class="linenos">1421</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">wait</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-1422"><a href="#Generator-1422"><span class="linenos">1422</span></a> -</span><span id="Generator-1423"><a href="#Generator-1423"><span class="linenos">1423</span></a> <span class="k">def</span> <span class="nf">loaddata_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LoadData</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1424"><a href="#Generator-1424"><span class="linenos">1424</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">" LOCAL"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1425"><a href="#Generator-1425"><span class="linenos">1425</span></a> <span class="n">inpath</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPATH </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'inpath'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1426"><a href="#Generator-1426"><span class="linenos">1426</span></a> <span class="n">overwrite</span> <span class="o">=</span> <span class="s2">" OVERWRITE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"overwrite"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1427"><a href="#Generator-1427"><span class="linenos">1427</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INTO TABLE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1428"><a href="#Generator-1428"><span class="linenos">1428</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"partition"</span><span class="p">)</span> -</span><span id="Generator-1429"><a href="#Generator-1429"><span class="linenos">1429</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1430"><a href="#Generator-1430"><span class="linenos">1430</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> -</span><span id="Generator-1431"><a href="#Generator-1431"><span class="linenos">1431</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1432"><a href="#Generator-1432"><span class="linenos">1432</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"serde"</span><span class="p">)</span> -</span><span id="Generator-1433"><a href="#Generator-1433"><span class="linenos">1433</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" SERDE </span><span class="si">{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">serde</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1434"><a href="#Generator-1434"><span class="linenos">1434</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOAD DATA</span><span class="si">{</span><span class="n">local</span><span class="si">}{</span><span class="n">inpath</span><span class="si">}{</span><span class="n">overwrite</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">partition</span><span class="si">}{</span><span class="n">input_format</span><span class="si">}{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1435"><a href="#Generator-1435"><span class="linenos">1435</span></a> -</span><span id="Generator-1436"><a href="#Generator-1436"><span class="linenos">1436</span></a> <span class="k">def</span> <span class="nf">null_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1437"><a href="#Generator-1437"><span class="linenos">1437</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> -</span><span id="Generator-1438"><a href="#Generator-1438"><span class="linenos">1438</span></a> -</span><span id="Generator-1439"><a href="#Generator-1439"><span class="linenos">1439</span></a> <span class="k">def</span> <span class="nf">boolean_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Boolean</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1440"><a href="#Generator-1440"><span class="linenos">1440</span></a> <span class="k">return</span> <span class="s2">"TRUE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">"FALSE"</span> -</span><span id="Generator-1441"><a href="#Generator-1441"><span class="linenos">1441</span></a> -</span><span id="Generator-1442"><a href="#Generator-1442"><span class="linenos">1442</span></a> <span class="k">def</span> <span class="nf">order_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">,</span> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1443"><a href="#Generator-1443"><span class="linenos">1443</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1444"><a href="#Generator-1444"><span class="linenos">1444</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="n">this</span> -</span><span id="Generator-1445"><a href="#Generator-1445"><span class="linenos">1445</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">ORDER BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="n">this</span> <span class="ow">or</span> <span class="n">flat</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="Generator-1446"><a href="#Generator-1446"><span class="linenos">1446</span></a> -</span><span id="Generator-1447"><a href="#Generator-1447"><span class="linenos">1447</span></a> <span class="k">def</span> <span class="nf">cluster_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1448"><a href="#Generator-1448"><span class="linenos">1448</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"CLUSTER BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1449"><a href="#Generator-1449"><span class="linenos">1449</span></a> -</span><span id="Generator-1450"><a href="#Generator-1450"><span class="linenos">1450</span></a> <span class="k">def</span> <span class="nf">distribute_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distribute</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1451"><a href="#Generator-1451"><span class="linenos">1451</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"DISTRIBUTE BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1452"><a href="#Generator-1452"><span class="linenos">1452</span></a> -</span><span id="Generator-1453"><a href="#Generator-1453"><span class="linenos">1453</span></a> <span class="k">def</span> <span class="nf">sort_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1454"><a href="#Generator-1454"><span class="linenos">1454</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"SORT BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1455"><a href="#Generator-1455"><span class="linenos">1455</span></a> -</span><span id="Generator-1456"><a href="#Generator-1456"><span class="linenos">1456</span></a> <span class="k">def</span> <span class="nf">ordered_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1457"><a href="#Generator-1457"><span class="linenos">1457</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"desc"</span><span class="p">)</span> -</span><span id="Generator-1458"><a href="#Generator-1458"><span class="linenos">1458</span></a> <span class="n">asc</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">desc</span> -</span><span id="Generator-1459"><a href="#Generator-1459"><span class="linenos">1459</span></a> -</span><span id="Generator-1460"><a href="#Generator-1460"><span class="linenos">1460</span></a> <span class="n">nulls_first</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nulls_first"</span><span class="p">)</span> -</span><span id="Generator-1461"><a href="#Generator-1461"><span class="linenos">1461</span></a> <span class="n">nulls_last</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">nulls_first</span> -</span><span id="Generator-1462"><a href="#Generator-1462"><span class="linenos">1462</span></a> <span class="n">nulls_are_large</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_large"</span> -</span><span id="Generator-1463"><a href="#Generator-1463"><span class="linenos">1463</span></a> <span class="n">nulls_are_small</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_small"</span> -</span><span id="Generator-1464"><a href="#Generator-1464"><span class="linenos">1464</span></a> <span class="n">nulls_are_last</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_last"</span> -</span><span id="Generator-1465"><a href="#Generator-1465"><span class="linenos">1465</span></a> -</span><span id="Generator-1466"><a href="#Generator-1466"><span class="linenos">1466</span></a> <span class="n">sort_order</span> <span class="o">=</span> <span class="s2">" DESC"</span> <span class="k">if</span> <span class="n">desc</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1467"><a href="#Generator-1467"><span class="linenos">1467</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-1468"><a href="#Generator-1468"><span class="linenos">1468</span></a> <span class="k">if</span> <span class="n">nulls_first</span> <span class="ow">and</span> <span class="p">(</span> -</span><span id="Generator-1469"><a href="#Generator-1469"><span class="linenos">1469</span></a> <span class="p">(</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="n">nulls_are_last</span> -</span><span id="Generator-1470"><a href="#Generator-1470"><span class="linenos">1470</span></a> <span class="p">):</span> -</span><span id="Generator-1471"><a href="#Generator-1471"><span class="linenos">1471</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS FIRST"</span> -</span><span id="Generator-1472"><a href="#Generator-1472"><span class="linenos">1472</span></a> <span class="k">elif</span> <span class="p">(</span> -</span><span id="Generator-1473"><a href="#Generator-1473"><span class="linenos">1473</span></a> <span class="n">nulls_last</span> -</span><span id="Generator-1474"><a href="#Generator-1474"><span class="linenos">1474</span></a> <span class="ow">and</span> <span class="p">((</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">))</span> -</span><span id="Generator-1475"><a href="#Generator-1475"><span class="linenos">1475</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">nulls_are_last</span> -</span><span id="Generator-1476"><a href="#Generator-1476"><span class="linenos">1476</span></a> <span class="p">):</span> -</span><span id="Generator-1477"><a href="#Generator-1477"><span class="linenos">1477</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS LAST"</span> -</span><span id="Generator-1478"><a href="#Generator-1478"><span class="linenos">1478</span></a> -</span><span id="Generator-1479"><a href="#Generator-1479"><span class="linenos">1479</span></a> <span class="k">if</span> <span class="n">nulls_sort_change</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING_SUPPORTED</span><span class="p">:</span> -</span><span id="Generator-1480"><a href="#Generator-1480"><span class="linenos">1480</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span> -</span><span id="Generator-1481"><a href="#Generator-1481"><span class="linenos">1481</span></a> <span class="s2">"Sorting in an ORDER BY on NULLS FIRST/NULLS LAST is not supported by this dialect"</span> -</span><span id="Generator-1482"><a href="#Generator-1482"><span class="linenos">1482</span></a> <span class="p">)</span> -</span><span id="Generator-1483"><a href="#Generator-1483"><span class="linenos">1483</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-1484"><a href="#Generator-1484"><span class="linenos">1484</span></a> -</span><span id="Generator-1485"><a href="#Generator-1485"><span class="linenos">1485</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">sort_order</span><span class="si">}{</span><span class="n">nulls_sort_change</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1486"><a href="#Generator-1486"><span class="linenos">1486</span></a> -</span><span id="Generator-1487"><a href="#Generator-1487"><span class="linenos">1487</span></a> <span class="k">def</span> <span class="nf">matchrecognize_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1488"><a href="#Generator-1488"><span class="linenos">1488</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1489"><a href="#Generator-1489"><span class="linenos">1489</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> -</span><span id="Generator-1490"><a href="#Generator-1490"><span class="linenos">1490</span></a> <span class="n">measures</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"measures"</span><span class="p">)</span> -</span><span id="Generator-1491"><a href="#Generator-1491"><span class="linenos">1491</span></a> <span class="n">measures</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"MEASURES</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">measures</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">measures</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1492"><a href="#Generator-1492"><span class="linenos">1492</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> -</span><span id="Generator-1493"><a href="#Generator-1493"><span class="linenos">1493</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">rows</span><span class="p">)</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1494"><a href="#Generator-1494"><span class="linenos">1494</span></a> <span class="n">after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"after"</span><span class="p">)</span> -</span><span id="Generator-1495"><a href="#Generator-1495"><span class="linenos">1495</span></a> <span class="n">after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">after</span><span class="p">)</span> <span class="k">if</span> <span class="n">after</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1496"><a href="#Generator-1496"><span class="linenos">1496</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"pattern"</span><span class="p">)</span> -</span><span id="Generator-1497"><a href="#Generator-1497"><span class="linenos">1497</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"PATTERN (</span><span class="si">{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">)"</span><span class="p">)</span> <span class="k">if</span> <span class="n">pattern</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1498"><a href="#Generator-1498"><span class="linenos">1498</span></a> <span class="n">definition_sqls</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="Generator-1499"><a href="#Generator-1499"><span class="linenos">1499</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">definition</span><span class="p">,</span><span class="w"> </span><span class="s1">'alias'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">definition</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1500"><a href="#Generator-1500"><span class="linenos">1500</span></a> <span class="k">for</span> <span class="n">definition</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"define"</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="Generator-1501"><a href="#Generator-1501"><span class="linenos">1501</span></a> <span class="p">]</span> -</span><span id="Generator-1502"><a href="#Generator-1502"><span class="linenos">1502</span></a> <span class="n">definitions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">sqls</span><span class="o">=</span><span class="n">definition_sqls</span><span class="p">)</span> -</span><span id="Generator-1503"><a href="#Generator-1503"><span class="linenos">1503</span></a> <span class="n">define</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"DEFINE</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">definitions</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">definitions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1504"><a href="#Generator-1504"><span class="linenos">1504</span></a> <span class="n">body</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator-1505"><a href="#Generator-1505"><span class="linenos">1505</span></a> <span class="p">(</span> -</span><span id="Generator-1506"><a href="#Generator-1506"><span class="linenos">1506</span></a> <span class="n">partition</span><span class="p">,</span> -</span><span id="Generator-1507"><a href="#Generator-1507"><span class="linenos">1507</span></a> <span class="n">order</span><span class="p">,</span> -</span><span id="Generator-1508"><a href="#Generator-1508"><span class="linenos">1508</span></a> <span class="n">measures</span><span class="p">,</span> -</span><span id="Generator-1509"><a href="#Generator-1509"><span class="linenos">1509</span></a> <span class="n">rows</span><span class="p">,</span> -</span><span id="Generator-1510"><a href="#Generator-1510"><span class="linenos">1510</span></a> <span class="n">after</span><span class="p">,</span> -</span><span id="Generator-1511"><a href="#Generator-1511"><span class="linenos">1511</span></a> <span class="n">pattern</span><span class="p">,</span> -</span><span id="Generator-1512"><a href="#Generator-1512"><span class="linenos">1512</span></a> <span class="n">define</span><span class="p">,</span> -</span><span id="Generator-1513"><a href="#Generator-1513"><span class="linenos">1513</span></a> <span class="p">)</span> -</span><span id="Generator-1514"><a href="#Generator-1514"><span class="linenos">1514</span></a> <span class="p">)</span> -</span><span id="Generator-1515"><a href="#Generator-1515"><span class="linenos">1515</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator-1516"><a href="#Generator-1516"><span class="linenos">1516</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1517"><a href="#Generator-1517"><span class="linenos">1517</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'MATCH_RECOGNIZE'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">body</span><span class="p">)</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1518"><a href="#Generator-1518"><span class="linenos">1518</span></a> -</span><span id="Generator-1519"><a href="#Generator-1519"><span class="linenos">1519</span></a> <span class="k">def</span> <span class="nf">query_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="o">*</span><span class="n">sqls</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1520"><a href="#Generator-1520"><span class="linenos">1520</span></a> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"limit"</span><span class="p">)</span> -</span><span id="Generator-1521"><a href="#Generator-1521"><span class="linenos">1521</span></a> -</span><span id="Generator-1522"><a href="#Generator-1522"><span class="linenos">1522</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"LIMIT"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">):</span> -</span><span id="Generator-1523"><a href="#Generator-1523"><span class="linenos">1523</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">limit</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"count"</span><span class="p">))</span> -</span><span id="Generator-1524"><a href="#Generator-1524"><span class="linenos">1524</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"FETCH"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">):</span> -</span><span id="Generator-1525"><a href="#Generator-1525"><span class="linenos">1525</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">(</span><span class="n">direction</span><span class="o">=</span><span class="s2">"FIRST"</span><span class="p">,</span> <span class="n">count</span><span class="o">=</span><span class="n">limit</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1526"><a href="#Generator-1526"><span class="linenos">1526</span></a> -</span><span id="Generator-1527"><a href="#Generator-1527"><span class="linenos">1527</span></a> <span class="n">fetch</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> -</span><span id="Generator-1528"><a href="#Generator-1528"><span class="linenos">1528</span></a> -</span><span id="Generator-1529"><a href="#Generator-1529"><span class="linenos">1529</span></a> <span class="k">return</span> <span class="n">csv</span><span class="p">(</span> -</span><span id="Generator-1530"><a href="#Generator-1530"><span class="linenos">1530</span></a> <span class="o">*</span><span class="n">sqls</span><span class="p">,</span> -</span><span id="Generator-1531"><a href="#Generator-1531"><span class="linenos">1531</span></a> <span class="o">*</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">join</span><span class="p">)</span> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> -</span><span id="Generator-1532"><a href="#Generator-1532"><span class="linenos">1532</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"match"</span><span class="p">),</span> -</span><span id="Generator-1533"><a href="#Generator-1533"><span class="linenos">1533</span></a> <span class="o">*</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">lateral</span><span class="p">)</span> <span class="k">for</span> <span class="n">lateral</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"laterals"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> -</span><span id="Generator-1534"><a href="#Generator-1534"><span class="linenos">1534</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">),</span> -</span><span id="Generator-1535"><a href="#Generator-1535"><span class="linenos">1535</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">),</span> -</span><span id="Generator-1536"><a href="#Generator-1536"><span class="linenos">1536</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"having"</span><span class="p">),</span> -</span><span id="Generator-1537"><a href="#Generator-1537"><span class="linenos">1537</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> -</span><span id="Generator-1538"><a href="#Generator-1538"><span class="linenos">1538</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">),</span> -</span><span id="Generator-1539"><a href="#Generator-1539"><span class="linenos">1539</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">offset_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">,</span> <span class="n">limit</span><span class="p">),</span> -</span><span id="Generator-1540"><a href="#Generator-1540"><span class="linenos">1540</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> -</span><span id="Generator-1541"><a href="#Generator-1541"><span class="linenos">1541</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> -</span><span id="Generator-1542"><a href="#Generator-1542"><span class="linenos">1542</span></a> <span class="p">)</span> -</span><span id="Generator-1543"><a href="#Generator-1543"><span class="linenos">1543</span></a> -</span><span id="Generator-1544"><a href="#Generator-1544"><span class="linenos">1544</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> -</span><span id="Generator-1545"><a href="#Generator-1545"><span class="linenos">1545</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> -</span><span id="Generator-1546"><a href="#Generator-1546"><span class="linenos">1546</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Generator-1547"><a href="#Generator-1547"><span class="linenos">1547</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="Generator-1548"><a href="#Generator-1548"><span class="linenos">1548</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> -</span><span id="Generator-1549"><a href="#Generator-1549"><span class="linenos">1549</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> -</span><span id="Generator-1550"><a href="#Generator-1550"><span class="linenos">1550</span></a> <span class="p">]</span> -</span><span id="Generator-1551"><a href="#Generator-1551"><span class="linenos">1551</span></a> -</span><span id="Generator-1552"><a href="#Generator-1552"><span class="linenos">1552</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Generator-1553"><a href="#Generator-1553"><span class="linenos">1553</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="Generator-1554"><a href="#Generator-1554"><span class="linenos">1554</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"qualify"</span><span class="p">),</span> -</span><span id="Generator-1555"><a href="#Generator-1555"><span class="linenos">1555</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WINDOW "</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"windows"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1556"><a href="#Generator-1556"><span class="linenos">1556</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"windows"</span><span class="p">)</span> -</span><span id="Generator-1557"><a href="#Generator-1557"><span class="linenos">1557</span></a> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="Generator-1558"><a href="#Generator-1558"><span class="linenos">1558</span></a> <span class="p">]</span> -</span><span id="Generator-1559"><a href="#Generator-1559"><span class="linenos">1559</span></a> -</span><span id="Generator-1560"><a href="#Generator-1560"><span class="linenos">1560</span></a> <span class="k">def</span> <span class="nf">after_limit_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Generator-1561"><a href="#Generator-1561"><span class="linenos">1561</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"locks"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator-1562"><a href="#Generator-1562"><span class="linenos">1562</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">locks</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">locks</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1563"><a href="#Generator-1563"><span class="linenos">1563</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">locks</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"sample"</span><span class="p">)]</span> -</span><span id="Generator-1564"><a href="#Generator-1564"><span class="linenos">1564</span></a> -</span><span id="Generator-1565"><a href="#Generator-1565"><span class="linenos">1565</span></a> <span class="k">def</span> <span class="nf">select_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1566"><a href="#Generator-1566"><span class="linenos">1566</span></a> <span class="n">hint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"hint"</span><span class="p">)</span> -</span><span id="Generator-1567"><a href="#Generator-1567"><span class="linenos">1567</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distinct"</span><span class="p">)</span> -</span><span id="Generator-1568"><a href="#Generator-1568"><span class="linenos">1568</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">distinct</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">distinct</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1569"><a href="#Generator-1569"><span class="linenos">1569</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator-1570"><a href="#Generator-1570"><span class="linenos">1570</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1571"><a href="#Generator-1571"><span class="linenos">1571</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1572"><a href="#Generator-1572"><span class="linenos">1572</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="n">expressions</span> -</span><span id="Generator-1573"><a href="#Generator-1573"><span class="linenos">1573</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> -</span><span id="Generator-1574"><a href="#Generator-1574"><span class="linenos">1574</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator-1575"><a href="#Generator-1575"><span class="linenos">1575</span></a> <span class="sa">f</span><span class="s2">"SELECT</span><span class="si">{</span><span class="n">hint</span><span class="si">}{</span><span class="n">distinct</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Generator-1576"><a href="#Generator-1576"><span class="linenos">1576</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"into"</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="Generator-1577"><a href="#Generator-1577"><span class="linenos">1577</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="Generator-1578"><a href="#Generator-1578"><span class="linenos">1578</span></a> <span class="p">)</span> -</span><span id="Generator-1579"><a href="#Generator-1579"><span class="linenos">1579</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="Generator-1580"><a href="#Generator-1580"><span class="linenos">1580</span></a> -</span><span id="Generator-1581"><a href="#Generator-1581"><span class="linenos">1581</span></a> <span class="k">def</span> <span class="nf">schema_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1582"><a href="#Generator-1582"><span class="linenos">1582</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1583"><a href="#Generator-1583"><span class="linenos">1583</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1584"><a href="#Generator-1584"><span class="linenos">1584</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1585"><a href="#Generator-1585"><span class="linenos">1585</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">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1586"><a href="#Generator-1586"><span class="linenos">1586</span></a> -</span><span id="Generator-1587"><a href="#Generator-1587"><span class="linenos">1587</span></a> <span class="k">def</span> <span class="nf">schema_columns_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1588"><a href="#Generator-1588"><span class="linenos">1588</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1589"><a href="#Generator-1589"><span class="linenos">1589</span></a> -</span><span id="Generator-1590"><a href="#Generator-1590"><span class="linenos">1590</span></a> <span class="k">def</span> <span class="nf">star_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1591"><a href="#Generator-1591"><span class="linenos">1591</span></a> <span class="n">except_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"except"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1592"><a href="#Generator-1592"><span class="linenos">1592</span></a> <span class="n">except_</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'except'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">except_</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">except_</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1593"><a href="#Generator-1593"><span class="linenos">1593</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"replace"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1594"><a href="#Generator-1594"><span class="linenos">1594</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'replace'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">replace</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">replace</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1595"><a href="#Generator-1595"><span class="linenos">1595</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"*</span><span class="si">{</span><span class="n">except_</span><span class="si">}{</span><span class="n">replace</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1596"><a href="#Generator-1596"><span class="linenos">1596</span></a> -</span><span id="Generator-1597"><a href="#Generator-1597"><span class="linenos">1597</span></a> <span class="k">def</span> <span class="nf">parameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Parameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1598"><a href="#Generator-1598"><span class="linenos">1598</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1599"><a href="#Generator-1599"><span class="linenos">1599</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="se">{{</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="se">}}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"wrapped"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1600"><a href="#Generator-1600"><span class="linenos">1600</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">PARAMETER_TOKEN</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1601"><a href="#Generator-1601"><span class="linenos">1601</span></a> -</span><span id="Generator-1602"><a href="#Generator-1602"><span class="linenos">1602</span></a> <span class="k">def</span> <span class="nf">sessionparameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SessionParameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1603"><a href="#Generator-1603"><span class="linenos">1603</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1604"><a href="#Generator-1604"><span class="linenos">1604</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator-1605"><a href="#Generator-1605"><span class="linenos">1605</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="Generator-1606"><a href="#Generator-1606"><span class="linenos">1606</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">."</span> -</span><span id="Generator-1607"><a href="#Generator-1607"><span class="linenos">1607</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"@@</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1608"><a href="#Generator-1608"><span class="linenos">1608</span></a> -</span><span id="Generator-1609"><a href="#Generator-1609"><span class="linenos">1609</span></a> <span class="k">def</span> <span class="nf">placeholder_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Placeholder</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1610"><a href="#Generator-1610"><span class="linenos">1610</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">":</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">"?"</span> -</span><span id="Generator-1611"><a href="#Generator-1611"><span class="linenos">1611</span></a> -</span><span id="Generator-1612"><a href="#Generator-1612"><span class="linenos">1612</span></a> <span class="k">def</span> <span class="nf">subquery_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1613"><a href="#Generator-1613"><span class="linenos">1613</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator-1614"><a href="#Generator-1614"><span class="linenos">1614</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1615"><a href="#Generator-1615"><span class="linenos">1615</span></a> -</span><span id="Generator-1616"><a href="#Generator-1616"><span class="linenos">1616</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1617"><a href="#Generator-1617"><span class="linenos">1617</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1618"><a href="#Generator-1618"><span class="linenos">1618</span></a> -</span><span id="Generator-1619"><a href="#Generator-1619"><span class="linenos">1619</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> <span class="n">alias</span><span class="p">,</span> <span class="n">pivots</span><span class="p">)</span> -</span><span id="Generator-1620"><a href="#Generator-1620"><span class="linenos">1620</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="Generator-1621"><a href="#Generator-1621"><span class="linenos">1621</span></a> -</span><span id="Generator-1622"><a href="#Generator-1622"><span class="linenos">1622</span></a> <span class="k">def</span> <span class="nf">qualify_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Qualify</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1623"><a href="#Generator-1623"><span class="linenos">1623</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))</span> -</span><span id="Generator-1624"><a href="#Generator-1624"><span class="linenos">1624</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'QUALIFY'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1625"><a href="#Generator-1625"><span class="linenos">1625</span></a> -</span><span id="Generator-1626"><a href="#Generator-1626"><span class="linenos">1626</span></a> <span class="k">def</span> <span class="nf">union_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1627"><a href="#Generator-1627"><span class="linenos">1627</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span> -</span><span id="Generator-1628"><a href="#Generator-1628"><span class="linenos">1628</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator-1629"><a href="#Generator-1629"><span class="linenos">1629</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">union_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> -</span><span id="Generator-1630"><a href="#Generator-1630"><span class="linenos">1630</span></a> <span class="p">)</span> -</span><span id="Generator-1631"><a href="#Generator-1631"><span class="linenos">1631</span></a> -</span><span id="Generator-1632"><a href="#Generator-1632"><span class="linenos">1632</span></a> <span class="k">def</span> <span class="nf">union_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1633"><a href="#Generator-1633"><span class="linenos">1633</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">" DISTINCT"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPLICIT_UNION</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1634"><a href="#Generator-1634"><span class="linenos">1634</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">kind</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"distinct"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" ALL"</span> -</span><span id="Generator-1635"><a href="#Generator-1635"><span class="linenos">1635</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNION</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1636"><a href="#Generator-1636"><span class="linenos">1636</span></a> -</span><span id="Generator-1637"><a href="#Generator-1637"><span class="linenos">1637</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1638"><a href="#Generator-1638"><span class="linenos">1638</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1639"><a href="#Generator-1639"><span class="linenos">1639</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator-1640"><a href="#Generator-1640"><span class="linenos">1640</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> -</span><span id="Generator-1641"><a href="#Generator-1641"><span class="linenos">1641</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">alias</span><span class="o">.</span><span class="n">columns</span> -</span><span id="Generator-1642"><a href="#Generator-1642"><span class="linenos">1642</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">columns</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1643"><a href="#Generator-1643"><span class="linenos">1643</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1644"><a href="#Generator-1644"><span class="linenos">1644</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator-1645"><a href="#Generator-1645"><span class="linenos">1645</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">alias</span> -</span><span id="Generator-1646"><a href="#Generator-1646"><span class="linenos">1646</span></a> <span class="n">ordinality</span> <span class="o">=</span> <span class="s2">" WITH ORDINALITY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ordinality"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1647"><a href="#Generator-1647"><span class="linenos">1647</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">)</span> -</span><span id="Generator-1648"><a href="#Generator-1648"><span class="linenos">1648</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH OFFSET AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">offset</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">offset</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1649"><a href="#Generator-1649"><span class="linenos">1649</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNNEST(</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">ordinality</span><span class="si">}{</span><span class="n">alias</span><span class="si">}{</span><span class="n">offset</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1650"><a href="#Generator-1650"><span class="linenos">1650</span></a> -</span><span id="Generator-1651"><a href="#Generator-1651"><span class="linenos">1651</span></a> <span class="k">def</span> <span class="nf">where_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1652"><a href="#Generator-1652"><span class="linenos">1652</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))</span> -</span><span id="Generator-1653"><a href="#Generator-1653"><span class="linenos">1653</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'WHERE'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1423"><a href="#Generator-1423"><span class="linenos">1423</span></a> <span class="k">def</span> <span class="nf">literal_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1424"><a href="#Generator-1424"><span class="linenos">1424</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">or</span> <span class="s2">""</span> +</span><span id="Generator-1425"><a href="#Generator-1425"><span class="linenos">1425</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> +</span><span id="Generator-1426"><a href="#Generator-1426"><span class="linenos">1426</span></a> <span class="n">text</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">text</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1427"><a href="#Generator-1427"><span class="linenos">1427</span></a> <span class="k">return</span> <span class="n">text</span> +</span><span id="Generator-1428"><a href="#Generator-1428"><span class="linenos">1428</span></a> +</span><span id="Generator-1429"><a href="#Generator-1429"><span class="linenos">1429</span></a> <span class="k">def</span> <span class="nf">escape_str</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1430"><a href="#Generator-1430"><span class="linenos">1430</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">)</span> +</span><span id="Generator-1431"><a href="#Generator-1431"><span class="linenos">1431</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="Generator-1432"><a href="#Generator-1432"><span class="linenos">1432</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">)</span> +</span><span id="Generator-1433"><a href="#Generator-1433"><span class="linenos">1433</span></a> <span class="k">return</span> <span class="n">text</span> +</span><span id="Generator-1434"><a href="#Generator-1434"><span class="linenos">1434</span></a> +</span><span id="Generator-1435"><a href="#Generator-1435"><span class="linenos">1435</span></a> <span class="k">def</span> <span class="nf">loaddata_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LoadData</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1436"><a href="#Generator-1436"><span class="linenos">1436</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">" LOCAL"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1437"><a href="#Generator-1437"><span class="linenos">1437</span></a> <span class="n">inpath</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPATH </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'inpath'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1438"><a href="#Generator-1438"><span class="linenos">1438</span></a> <span class="n">overwrite</span> <span class="o">=</span> <span class="s2">" OVERWRITE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"overwrite"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1439"><a href="#Generator-1439"><span class="linenos">1439</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INTO TABLE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1440"><a href="#Generator-1440"><span class="linenos">1440</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"partition"</span><span class="p">)</span> +</span><span id="Generator-1441"><a href="#Generator-1441"><span class="linenos">1441</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1442"><a href="#Generator-1442"><span class="linenos">1442</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> +</span><span id="Generator-1443"><a href="#Generator-1443"><span class="linenos">1443</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1444"><a href="#Generator-1444"><span class="linenos">1444</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"serde"</span><span class="p">)</span> +</span><span id="Generator-1445"><a href="#Generator-1445"><span class="linenos">1445</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" SERDE </span><span class="si">{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">serde</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1446"><a href="#Generator-1446"><span class="linenos">1446</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOAD DATA</span><span class="si">{</span><span class="n">local</span><span class="si">}{</span><span class="n">inpath</span><span class="si">}{</span><span class="n">overwrite</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">partition</span><span class="si">}{</span><span class="n">input_format</span><span class="si">}{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1447"><a href="#Generator-1447"><span class="linenos">1447</span></a> +</span><span id="Generator-1448"><a href="#Generator-1448"><span class="linenos">1448</span></a> <span class="k">def</span> <span class="nf">null_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1449"><a href="#Generator-1449"><span class="linenos">1449</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> +</span><span id="Generator-1450"><a href="#Generator-1450"><span class="linenos">1450</span></a> +</span><span id="Generator-1451"><a href="#Generator-1451"><span class="linenos">1451</span></a> <span class="k">def</span> <span class="nf">boolean_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Boolean</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1452"><a href="#Generator-1452"><span class="linenos">1452</span></a> <span class="k">return</span> <span class="s2">"TRUE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">"FALSE"</span> +</span><span id="Generator-1453"><a href="#Generator-1453"><span class="linenos">1453</span></a> +</span><span id="Generator-1454"><a href="#Generator-1454"><span class="linenos">1454</span></a> <span class="k">def</span> <span class="nf">order_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">,</span> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1455"><a href="#Generator-1455"><span class="linenos">1455</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1456"><a href="#Generator-1456"><span class="linenos">1456</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="n">this</span> +</span><span id="Generator-1457"><a href="#Generator-1457"><span class="linenos">1457</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">ORDER BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="n">this</span> <span class="ow">or</span> <span class="n">flat</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="Generator-1458"><a href="#Generator-1458"><span class="linenos">1458</span></a> +</span><span id="Generator-1459"><a href="#Generator-1459"><span class="linenos">1459</span></a> <span class="k">def</span> <span class="nf">cluster_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1460"><a href="#Generator-1460"><span class="linenos">1460</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"CLUSTER BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1461"><a href="#Generator-1461"><span class="linenos">1461</span></a> +</span><span id="Generator-1462"><a href="#Generator-1462"><span class="linenos">1462</span></a> <span class="k">def</span> <span class="nf">distribute_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distribute</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1463"><a href="#Generator-1463"><span class="linenos">1463</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"DISTRIBUTE BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1464"><a href="#Generator-1464"><span class="linenos">1464</span></a> +</span><span id="Generator-1465"><a href="#Generator-1465"><span class="linenos">1465</span></a> <span class="k">def</span> <span class="nf">sort_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1466"><a href="#Generator-1466"><span class="linenos">1466</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"SORT BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1467"><a href="#Generator-1467"><span class="linenos">1467</span></a> +</span><span id="Generator-1468"><a href="#Generator-1468"><span class="linenos">1468</span></a> <span class="k">def</span> <span class="nf">ordered_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1469"><a href="#Generator-1469"><span class="linenos">1469</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"desc"</span><span class="p">)</span> +</span><span id="Generator-1470"><a href="#Generator-1470"><span class="linenos">1470</span></a> <span class="n">asc</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">desc</span> +</span><span id="Generator-1471"><a href="#Generator-1471"><span class="linenos">1471</span></a> +</span><span id="Generator-1472"><a href="#Generator-1472"><span class="linenos">1472</span></a> <span class="n">nulls_first</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nulls_first"</span><span class="p">)</span> +</span><span id="Generator-1473"><a href="#Generator-1473"><span class="linenos">1473</span></a> <span class="n">nulls_last</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">nulls_first</span> +</span><span id="Generator-1474"><a href="#Generator-1474"><span class="linenos">1474</span></a> <span class="n">nulls_are_large</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_large"</span> +</span><span id="Generator-1475"><a href="#Generator-1475"><span class="linenos">1475</span></a> <span class="n">nulls_are_small</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_small"</span> +</span><span id="Generator-1476"><a href="#Generator-1476"><span class="linenos">1476</span></a> <span class="n">nulls_are_last</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_last"</span> +</span><span id="Generator-1477"><a href="#Generator-1477"><span class="linenos">1477</span></a> +</span><span id="Generator-1478"><a href="#Generator-1478"><span class="linenos">1478</span></a> <span class="n">sort_order</span> <span class="o">=</span> <span class="s2">" DESC"</span> <span class="k">if</span> <span class="n">desc</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1479"><a href="#Generator-1479"><span class="linenos">1479</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-1480"><a href="#Generator-1480"><span class="linenos">1480</span></a> <span class="k">if</span> <span class="n">nulls_first</span> <span class="ow">and</span> <span class="p">(</span> +</span><span id="Generator-1481"><a href="#Generator-1481"><span class="linenos">1481</span></a> <span class="p">(</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="n">nulls_are_last</span> +</span><span id="Generator-1482"><a href="#Generator-1482"><span class="linenos">1482</span></a> <span class="p">):</span> +</span><span id="Generator-1483"><a href="#Generator-1483"><span class="linenos">1483</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS FIRST"</span> +</span><span id="Generator-1484"><a href="#Generator-1484"><span class="linenos">1484</span></a> <span class="k">elif</span> <span class="p">(</span> +</span><span id="Generator-1485"><a href="#Generator-1485"><span class="linenos">1485</span></a> <span class="n">nulls_last</span> +</span><span id="Generator-1486"><a href="#Generator-1486"><span class="linenos">1486</span></a> <span class="ow">and</span> <span class="p">((</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">))</span> +</span><span id="Generator-1487"><a href="#Generator-1487"><span class="linenos">1487</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">nulls_are_last</span> +</span><span id="Generator-1488"><a href="#Generator-1488"><span class="linenos">1488</span></a> <span class="p">):</span> +</span><span id="Generator-1489"><a href="#Generator-1489"><span class="linenos">1489</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS LAST"</span> +</span><span id="Generator-1490"><a href="#Generator-1490"><span class="linenos">1490</span></a> +</span><span id="Generator-1491"><a href="#Generator-1491"><span class="linenos">1491</span></a> <span class="k">if</span> <span class="n">nulls_sort_change</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING_SUPPORTED</span><span class="p">:</span> +</span><span id="Generator-1492"><a href="#Generator-1492"><span class="linenos">1492</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span> +</span><span id="Generator-1493"><a href="#Generator-1493"><span class="linenos">1493</span></a> <span class="s2">"Sorting in an ORDER BY on NULLS FIRST/NULLS LAST is not supported by this dialect"</span> +</span><span id="Generator-1494"><a href="#Generator-1494"><span class="linenos">1494</span></a> <span class="p">)</span> +</span><span id="Generator-1495"><a href="#Generator-1495"><span class="linenos">1495</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-1496"><a href="#Generator-1496"><span class="linenos">1496</span></a> +</span><span id="Generator-1497"><a href="#Generator-1497"><span class="linenos">1497</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">sort_order</span><span class="si">}{</span><span class="n">nulls_sort_change</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1498"><a href="#Generator-1498"><span class="linenos">1498</span></a> +</span><span id="Generator-1499"><a href="#Generator-1499"><span class="linenos">1499</span></a> <span class="k">def</span> <span class="nf">matchrecognize_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1500"><a href="#Generator-1500"><span class="linenos">1500</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1501"><a href="#Generator-1501"><span class="linenos">1501</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> +</span><span id="Generator-1502"><a href="#Generator-1502"><span class="linenos">1502</span></a> <span class="n">measures</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"measures"</span><span class="p">)</span> +</span><span id="Generator-1503"><a href="#Generator-1503"><span class="linenos">1503</span></a> <span class="n">measures</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"MEASURES</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">measures</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">measures</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1504"><a href="#Generator-1504"><span class="linenos">1504</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> +</span><span id="Generator-1505"><a href="#Generator-1505"><span class="linenos">1505</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">rows</span><span class="p">)</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1506"><a href="#Generator-1506"><span class="linenos">1506</span></a> <span class="n">after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"after"</span><span class="p">)</span> +</span><span id="Generator-1507"><a href="#Generator-1507"><span class="linenos">1507</span></a> <span class="n">after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">after</span><span class="p">)</span> <span class="k">if</span> <span class="n">after</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1508"><a href="#Generator-1508"><span class="linenos">1508</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"pattern"</span><span class="p">)</span> +</span><span id="Generator-1509"><a href="#Generator-1509"><span class="linenos">1509</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"PATTERN (</span><span class="si">{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">)"</span><span class="p">)</span> <span class="k">if</span> <span class="n">pattern</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1510"><a href="#Generator-1510"><span class="linenos">1510</span></a> <span class="n">definition_sqls</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="Generator-1511"><a href="#Generator-1511"><span class="linenos">1511</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">definition</span><span class="p">,</span><span class="w"> </span><span class="s1">'alias'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">definition</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1512"><a href="#Generator-1512"><span class="linenos">1512</span></a> <span class="k">for</span> <span class="n">definition</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"define"</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="Generator-1513"><a href="#Generator-1513"><span class="linenos">1513</span></a> <span class="p">]</span> +</span><span id="Generator-1514"><a href="#Generator-1514"><span class="linenos">1514</span></a> <span class="n">definitions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">sqls</span><span class="o">=</span><span class="n">definition_sqls</span><span class="p">)</span> +</span><span id="Generator-1515"><a href="#Generator-1515"><span class="linenos">1515</span></a> <span class="n">define</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"DEFINE</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">definitions</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">definitions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1516"><a href="#Generator-1516"><span class="linenos">1516</span></a> <span class="n">body</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator-1517"><a href="#Generator-1517"><span class="linenos">1517</span></a> <span class="p">(</span> +</span><span id="Generator-1518"><a href="#Generator-1518"><span class="linenos">1518</span></a> <span class="n">partition</span><span class="p">,</span> +</span><span id="Generator-1519"><a href="#Generator-1519"><span class="linenos">1519</span></a> <span class="n">order</span><span class="p">,</span> +</span><span id="Generator-1520"><a href="#Generator-1520"><span class="linenos">1520</span></a> <span class="n">measures</span><span class="p">,</span> +</span><span id="Generator-1521"><a href="#Generator-1521"><span class="linenos">1521</span></a> <span class="n">rows</span><span class="p">,</span> +</span><span id="Generator-1522"><a href="#Generator-1522"><span class="linenos">1522</span></a> <span class="n">after</span><span class="p">,</span> +</span><span id="Generator-1523"><a href="#Generator-1523"><span class="linenos">1523</span></a> <span class="n">pattern</span><span class="p">,</span> +</span><span id="Generator-1524"><a href="#Generator-1524"><span class="linenos">1524</span></a> <span class="n">define</span><span class="p">,</span> +</span><span id="Generator-1525"><a href="#Generator-1525"><span class="linenos">1525</span></a> <span class="p">)</span> +</span><span id="Generator-1526"><a href="#Generator-1526"><span class="linenos">1526</span></a> <span class="p">)</span> +</span><span id="Generator-1527"><a href="#Generator-1527"><span class="linenos">1527</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator-1528"><a href="#Generator-1528"><span class="linenos">1528</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1529"><a href="#Generator-1529"><span class="linenos">1529</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'MATCH_RECOGNIZE'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">body</span><span class="p">)</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1530"><a href="#Generator-1530"><span class="linenos">1530</span></a> +</span><span id="Generator-1531"><a href="#Generator-1531"><span class="linenos">1531</span></a> <span class="k">def</span> <span class="nf">query_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="o">*</span><span class="n">sqls</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1532"><a href="#Generator-1532"><span class="linenos">1532</span></a> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"limit"</span><span class="p">)</span> +</span><span id="Generator-1533"><a href="#Generator-1533"><span class="linenos">1533</span></a> +</span><span id="Generator-1534"><a href="#Generator-1534"><span class="linenos">1534</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"LIMIT"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">):</span> +</span><span id="Generator-1535"><a href="#Generator-1535"><span class="linenos">1535</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">limit</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"count"</span><span class="p">))</span> +</span><span id="Generator-1536"><a href="#Generator-1536"><span class="linenos">1536</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"FETCH"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">):</span> +</span><span id="Generator-1537"><a href="#Generator-1537"><span class="linenos">1537</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">(</span><span class="n">direction</span><span class="o">=</span><span class="s2">"FIRST"</span><span class="p">,</span> <span class="n">count</span><span class="o">=</span><span class="n">limit</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1538"><a href="#Generator-1538"><span class="linenos">1538</span></a> +</span><span id="Generator-1539"><a href="#Generator-1539"><span class="linenos">1539</span></a> <span class="n">fetch</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> +</span><span id="Generator-1540"><a href="#Generator-1540"><span class="linenos">1540</span></a> +</span><span id="Generator-1541"><a href="#Generator-1541"><span class="linenos">1541</span></a> <span class="k">return</span> <span class="n">csv</span><span class="p">(</span> +</span><span id="Generator-1542"><a href="#Generator-1542"><span class="linenos">1542</span></a> <span class="o">*</span><span class="n">sqls</span><span class="p">,</span> +</span><span id="Generator-1543"><a href="#Generator-1543"><span class="linenos">1543</span></a> <span class="o">*</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">join</span><span class="p">)</span> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> +</span><span id="Generator-1544"><a href="#Generator-1544"><span class="linenos">1544</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"match"</span><span class="p">),</span> +</span><span id="Generator-1545"><a href="#Generator-1545"><span class="linenos">1545</span></a> <span class="o">*</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">lateral</span><span class="p">)</span> <span class="k">for</span> <span class="n">lateral</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"laterals"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> +</span><span id="Generator-1546"><a href="#Generator-1546"><span class="linenos">1546</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">),</span> +</span><span id="Generator-1547"><a href="#Generator-1547"><span class="linenos">1547</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">),</span> +</span><span id="Generator-1548"><a href="#Generator-1548"><span class="linenos">1548</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"having"</span><span class="p">),</span> +</span><span id="Generator-1549"><a href="#Generator-1549"><span class="linenos">1549</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> +</span><span id="Generator-1550"><a href="#Generator-1550"><span class="linenos">1550</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">),</span> +</span><span id="Generator-1551"><a href="#Generator-1551"><span class="linenos">1551</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">offset_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">,</span> <span class="n">limit</span><span class="p">),</span> +</span><span id="Generator-1552"><a href="#Generator-1552"><span class="linenos">1552</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> +</span><span id="Generator-1553"><a href="#Generator-1553"><span class="linenos">1553</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> +</span><span id="Generator-1554"><a href="#Generator-1554"><span class="linenos">1554</span></a> <span class="p">)</span> +</span><span id="Generator-1555"><a href="#Generator-1555"><span class="linenos">1555</span></a> +</span><span id="Generator-1556"><a href="#Generator-1556"><span class="linenos">1556</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> +</span><span id="Generator-1557"><a href="#Generator-1557"><span class="linenos">1557</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> +</span><span id="Generator-1558"><a href="#Generator-1558"><span class="linenos">1558</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Generator-1559"><a href="#Generator-1559"><span class="linenos">1559</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="Generator-1560"><a href="#Generator-1560"><span class="linenos">1560</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> +</span><span id="Generator-1561"><a href="#Generator-1561"><span class="linenos">1561</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> +</span><span id="Generator-1562"><a href="#Generator-1562"><span class="linenos">1562</span></a> <span class="p">]</span> +</span><span id="Generator-1563"><a href="#Generator-1563"><span class="linenos">1563</span></a> +</span><span id="Generator-1564"><a href="#Generator-1564"><span class="linenos">1564</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Generator-1565"><a href="#Generator-1565"><span class="linenos">1565</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="Generator-1566"><a href="#Generator-1566"><span class="linenos">1566</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"qualify"</span><span class="p">),</span> +</span><span id="Generator-1567"><a href="#Generator-1567"><span class="linenos">1567</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WINDOW "</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"windows"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1568"><a href="#Generator-1568"><span class="linenos">1568</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"windows"</span><span class="p">)</span> +</span><span id="Generator-1569"><a href="#Generator-1569"><span class="linenos">1569</span></a> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="Generator-1570"><a href="#Generator-1570"><span class="linenos">1570</span></a> <span class="p">]</span> +</span><span id="Generator-1571"><a href="#Generator-1571"><span class="linenos">1571</span></a> +</span><span id="Generator-1572"><a href="#Generator-1572"><span class="linenos">1572</span></a> <span class="k">def</span> <span class="nf">after_limit_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Generator-1573"><a href="#Generator-1573"><span class="linenos">1573</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"locks"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator-1574"><a href="#Generator-1574"><span class="linenos">1574</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">locks</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">locks</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1575"><a href="#Generator-1575"><span class="linenos">1575</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">locks</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"sample"</span><span class="p">)]</span> +</span><span id="Generator-1576"><a href="#Generator-1576"><span class="linenos">1576</span></a> +</span><span id="Generator-1577"><a href="#Generator-1577"><span class="linenos">1577</span></a> <span class="k">def</span> <span class="nf">select_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1578"><a href="#Generator-1578"><span class="linenos">1578</span></a> <span class="n">hint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"hint"</span><span class="p">)</span> +</span><span id="Generator-1579"><a href="#Generator-1579"><span class="linenos">1579</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distinct"</span><span class="p">)</span> +</span><span id="Generator-1580"><a href="#Generator-1580"><span class="linenos">1580</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">distinct</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">distinct</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1581"><a href="#Generator-1581"><span class="linenos">1581</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Generator-1582"><a href="#Generator-1582"><span class="linenos">1582</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1583"><a href="#Generator-1583"><span class="linenos">1583</span></a> +</span><span id="Generator-1584"><a href="#Generator-1584"><span class="linenos">1584</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="Generator-1585"><a href="#Generator-1585"><span class="linenos">1585</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SELECT_KINDS</span><span class="p">:</span> +</span><span id="Generator-1586"><a href="#Generator-1586"><span class="linenos">1586</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1587"><a href="#Generator-1587"><span class="linenos">1587</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1588"><a href="#Generator-1588"><span class="linenos">1588</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"STRUCT"</span><span class="p">:</span> +</span><span id="Generator-1589"><a href="#Generator-1589"><span class="linenos">1589</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span> +</span><span id="Generator-1590"><a href="#Generator-1590"><span class="linenos">1590</span></a> <span class="n">sqls</span><span class="o">=</span><span class="p">[</span> +</span><span id="Generator-1591"><a href="#Generator-1591"><span class="linenos">1591</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="Generator-1592"><a href="#Generator-1592"><span class="linenos">1592</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">(</span> +</span><span id="Generator-1593"><a href="#Generator-1593"><span class="linenos">1593</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> +</span><span id="Generator-1594"><a href="#Generator-1594"><span class="linenos">1594</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">output_name</span><span class="p">)</span><span class="o">.</span><span class="n">eq</span><span class="p">(</span> +</span><span id="Generator-1595"><a href="#Generator-1595"><span class="linenos">1595</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">)</span> <span class="k">else</span> <span class="n">e</span> +</span><span id="Generator-1596"><a href="#Generator-1596"><span class="linenos">1596</span></a> <span class="p">)</span> +</span><span id="Generator-1597"><a href="#Generator-1597"><span class="linenos">1597</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="Generator-1598"><a href="#Generator-1598"><span class="linenos">1598</span></a> <span class="p">]</span> +</span><span id="Generator-1599"><a href="#Generator-1599"><span class="linenos">1599</span></a> <span class="p">)</span> +</span><span id="Generator-1600"><a href="#Generator-1600"><span class="linenos">1600</span></a> <span class="p">)</span> +</span><span id="Generator-1601"><a href="#Generator-1601"><span class="linenos">1601</span></a> <span class="p">]</span> +</span><span id="Generator-1602"><a href="#Generator-1602"><span class="linenos">1602</span></a> <span class="p">)</span> +</span><span id="Generator-1603"><a href="#Generator-1603"><span class="linenos">1603</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-1604"><a href="#Generator-1604"><span class="linenos">1604</span></a> +</span><span id="Generator-1605"><a href="#Generator-1605"><span class="linenos">1605</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="n">expressions</span> +</span><span id="Generator-1606"><a href="#Generator-1606"><span class="linenos">1606</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> +</span><span id="Generator-1607"><a href="#Generator-1607"><span class="linenos">1607</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator-1608"><a href="#Generator-1608"><span class="linenos">1608</span></a> <span class="sa">f</span><span class="s2">"SELECT</span><span class="si">{</span><span class="n">hint</span><span class="si">}{</span><span class="n">distinct</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Generator-1609"><a href="#Generator-1609"><span class="linenos">1609</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"into"</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="Generator-1610"><a href="#Generator-1610"><span class="linenos">1610</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="Generator-1611"><a href="#Generator-1611"><span class="linenos">1611</span></a> <span class="p">)</span> +</span><span id="Generator-1612"><a href="#Generator-1612"><span class="linenos">1612</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="Generator-1613"><a href="#Generator-1613"><span class="linenos">1613</span></a> +</span><span id="Generator-1614"><a href="#Generator-1614"><span class="linenos">1614</span></a> <span class="k">def</span> <span class="nf">schema_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1615"><a href="#Generator-1615"><span class="linenos">1615</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1616"><a href="#Generator-1616"><span class="linenos">1616</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1617"><a href="#Generator-1617"><span class="linenos">1617</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1618"><a href="#Generator-1618"><span class="linenos">1618</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">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1619"><a href="#Generator-1619"><span class="linenos">1619</span></a> +</span><span id="Generator-1620"><a href="#Generator-1620"><span class="linenos">1620</span></a> <span class="k">def</span> <span class="nf">schema_columns_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1621"><a href="#Generator-1621"><span class="linenos">1621</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1622"><a href="#Generator-1622"><span class="linenos">1622</span></a> +</span><span id="Generator-1623"><a href="#Generator-1623"><span class="linenos">1623</span></a> <span class="k">def</span> <span class="nf">star_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1624"><a href="#Generator-1624"><span class="linenos">1624</span></a> <span class="n">except_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"except"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1625"><a href="#Generator-1625"><span class="linenos">1625</span></a> <span class="n">except_</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'except'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">except_</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">except_</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1626"><a href="#Generator-1626"><span class="linenos">1626</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"replace"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1627"><a href="#Generator-1627"><span class="linenos">1627</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'replace'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">replace</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">replace</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1628"><a href="#Generator-1628"><span class="linenos">1628</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"*</span><span class="si">{</span><span class="n">except_</span><span class="si">}{</span><span class="n">replace</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1629"><a href="#Generator-1629"><span class="linenos">1629</span></a> +</span><span id="Generator-1630"><a href="#Generator-1630"><span class="linenos">1630</span></a> <span class="k">def</span> <span class="nf">parameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Parameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1631"><a href="#Generator-1631"><span class="linenos">1631</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1632"><a href="#Generator-1632"><span class="linenos">1632</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="se">{{</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="se">}}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"wrapped"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1633"><a href="#Generator-1633"><span class="linenos">1633</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">PARAMETER_TOKEN</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1634"><a href="#Generator-1634"><span class="linenos">1634</span></a> +</span><span id="Generator-1635"><a href="#Generator-1635"><span class="linenos">1635</span></a> <span class="k">def</span> <span class="nf">sessionparameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SessionParameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1636"><a href="#Generator-1636"><span class="linenos">1636</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1637"><a href="#Generator-1637"><span class="linenos">1637</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator-1638"><a href="#Generator-1638"><span class="linenos">1638</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="Generator-1639"><a href="#Generator-1639"><span class="linenos">1639</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">."</span> +</span><span id="Generator-1640"><a href="#Generator-1640"><span class="linenos">1640</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"@@</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1641"><a href="#Generator-1641"><span class="linenos">1641</span></a> +</span><span id="Generator-1642"><a href="#Generator-1642"><span class="linenos">1642</span></a> <span class="k">def</span> <span class="nf">placeholder_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Placeholder</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1643"><a href="#Generator-1643"><span class="linenos">1643</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">":</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">"?"</span> +</span><span id="Generator-1644"><a href="#Generator-1644"><span class="linenos">1644</span></a> +</span><span id="Generator-1645"><a href="#Generator-1645"><span class="linenos">1645</span></a> <span class="k">def</span> <span class="nf">subquery_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1646"><a href="#Generator-1646"><span class="linenos">1646</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator-1647"><a href="#Generator-1647"><span class="linenos">1647</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1648"><a href="#Generator-1648"><span class="linenos">1648</span></a> +</span><span id="Generator-1649"><a href="#Generator-1649"><span class="linenos">1649</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1650"><a href="#Generator-1650"><span class="linenos">1650</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1651"><a href="#Generator-1651"><span class="linenos">1651</span></a> +</span><span id="Generator-1652"><a href="#Generator-1652"><span class="linenos">1652</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> <span class="n">alias</span><span class="p">,</span> <span class="n">pivots</span><span class="p">)</span> +</span><span id="Generator-1653"><a href="#Generator-1653"><span class="linenos">1653</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> </span><span id="Generator-1654"><a href="#Generator-1654"><span class="linenos">1654</span></a> -</span><span id="Generator-1655"><a href="#Generator-1655"><span class="linenos">1655</span></a> <span class="k">def</span> <span class="nf">window_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1656"><a href="#Generator-1656"><span class="linenos">1656</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1657"><a href="#Generator-1657"><span class="linenos">1657</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1658"><a href="#Generator-1658"><span class="linenos">1658</span></a> <span class="n">order</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"order"</span><span class="p">)</span> -</span><span id="Generator-1659"><a href="#Generator-1659"><span class="linenos">1659</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1660"><a href="#Generator-1660"><span class="linenos">1660</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"spec"</span><span class="p">)</span> -</span><span id="Generator-1661"><a href="#Generator-1661"><span class="linenos">1661</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator-1662"><a href="#Generator-1662"><span class="linenos">1662</span></a> <span class="n">over</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"over"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"OVER"</span> -</span><span id="Generator-1663"><a href="#Generator-1663"><span class="linenos">1663</span></a> -</span><span id="Generator-1664"><a href="#Generator-1664"><span class="linenos">1664</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="s1">'AS'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">arg_key</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s1">'windows'</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">over</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1665"><a href="#Generator-1665"><span class="linenos">1665</span></a> -</span><span id="Generator-1666"><a href="#Generator-1666"><span class="linenos">1666</span></a> <span class="n">first</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"first"</span><span class="p">)</span> -</span><span id="Generator-1667"><a href="#Generator-1667"><span class="linenos">1667</span></a> <span class="k">if</span> <span class="n">first</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-1668"><a href="#Generator-1668"><span class="linenos">1668</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-1669"><a href="#Generator-1669"><span class="linenos">1669</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1670"><a href="#Generator-1670"><span class="linenos">1670</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">"FIRST"</span> <span class="k">if</span> <span class="n">first</span> <span class="k">else</span> <span class="s2">"LAST"</span> -</span><span id="Generator-1671"><a href="#Generator-1671"><span class="linenos">1671</span></a> -</span><span id="Generator-1672"><a href="#Generator-1672"><span class="linenos">1672</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">partition</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">order</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">spec</span> <span class="ow">and</span> <span class="n">alias</span><span class="p">:</span> -</span><span id="Generator-1673"><a href="#Generator-1673"><span class="linenos">1673</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1674"><a href="#Generator-1674"><span class="linenos">1674</span></a> -</span><span id="Generator-1675"><a href="#Generator-1675"><span class="linenos">1675</span></a> <span class="n">args</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">first</span><span class="p">,</span> <span class="n">partition</span><span class="p">,</span> <span class="n">order</span><span class="p">,</span> <span class="n">spec</span><span class="p">)</span> <span class="k">if</span> <span class="n">arg</span><span class="p">)</span> -</span><span id="Generator-1676"><a href="#Generator-1676"><span class="linenos">1676</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1677"><a href="#Generator-1677"><span class="linenos">1677</span></a> -</span><span id="Generator-1678"><a href="#Generator-1678"><span class="linenos">1678</span></a> <span class="k">def</span> <span class="nf">partition_by_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1679"><a href="#Generator-1679"><span class="linenos">1679</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"partition_by"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1680"><a href="#Generator-1680"><span class="linenos">1680</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1681"><a href="#Generator-1681"><span class="linenos">1681</span></a> -</span><span id="Generator-1682"><a href="#Generator-1682"><span class="linenos">1682</span></a> <span class="k">def</span> <span class="nf">windowspec_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WindowSpec</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1683"><a href="#Generator-1683"><span class="linenos">1683</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator-1684"><a href="#Generator-1684"><span class="linenos">1684</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"start_side"</span><span class="p">),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator-1685"><a href="#Generator-1685"><span class="linenos">1685</span></a> <span class="n">end</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-1686"><a href="#Generator-1686"><span class="linenos">1686</span></a> <span class="n">csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"end"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"end_side"</span><span class="p">),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator-1687"><a href="#Generator-1687"><span class="linenos">1687</span></a> <span class="ow">or</span> <span class="s2">"CURRENT ROW"</span> -</span><span id="Generator-1688"><a href="#Generator-1688"><span class="linenos">1688</span></a> <span class="p">)</span> -</span><span id="Generator-1689"><a href="#Generator-1689"><span class="linenos">1689</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">end</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1690"><a href="#Generator-1690"><span class="linenos">1690</span></a> -</span><span id="Generator-1691"><a href="#Generator-1691"><span class="linenos">1691</span></a> <span class="k">def</span> <span class="nf">withingroup_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1692"><a href="#Generator-1692"><span class="linenos">1692</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1693"><a href="#Generator-1693"><span class="linenos">1693</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)[</span><span class="mi">1</span><span class="p">:]</span> <span class="c1"># order has a leading space</span> -</span><span id="Generator-1694"><a href="#Generator-1694"><span class="linenos">1694</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> WITHIN GROUP (</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1695"><a href="#Generator-1695"><span class="linenos">1695</span></a> -</span><span id="Generator-1696"><a href="#Generator-1696"><span class="linenos">1696</span></a> <span class="k">def</span> <span class="nf">between_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1697"><a href="#Generator-1697"><span class="linenos">1697</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1698"><a href="#Generator-1698"><span class="linenos">1698</span></a> <span class="n">low</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"low"</span><span class="p">)</span> -</span><span id="Generator-1699"><a href="#Generator-1699"><span class="linenos">1699</span></a> <span class="n">high</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"high"</span><span class="p">)</span> -</span><span id="Generator-1700"><a href="#Generator-1700"><span class="linenos">1700</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">low</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">high</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1701"><a href="#Generator-1701"><span class="linenos">1701</span></a> -</span><span id="Generator-1702"><a href="#Generator-1702"><span class="linenos">1702</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1703"><a href="#Generator-1703"><span class="linenos">1703</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">apply_index_offset</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">INDEX_OFFSET</span><span class="p">)</span> -</span><span id="Generator-1704"><a href="#Generator-1704"><span class="linenos">1704</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> -</span><span id="Generator-1705"><a href="#Generator-1705"><span class="linenos">1705</span></a> -</span><span id="Generator-1706"><a href="#Generator-1706"><span class="linenos">1706</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">[</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> +</span><span id="Generator-1655"><a href="#Generator-1655"><span class="linenos">1655</span></a> <span class="k">def</span> <span class="nf">qualify_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Qualify</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1656"><a href="#Generator-1656"><span class="linenos">1656</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))</span> +</span><span id="Generator-1657"><a href="#Generator-1657"><span class="linenos">1657</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'QUALIFY'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1658"><a href="#Generator-1658"><span class="linenos">1658</span></a> +</span><span id="Generator-1659"><a href="#Generator-1659"><span class="linenos">1659</span></a> <span class="k">def</span> <span class="nf">union_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1660"><a href="#Generator-1660"><span class="linenos">1660</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span> +</span><span id="Generator-1661"><a href="#Generator-1661"><span class="linenos">1661</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator-1662"><a href="#Generator-1662"><span class="linenos">1662</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">union_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> +</span><span id="Generator-1663"><a href="#Generator-1663"><span class="linenos">1663</span></a> <span class="p">)</span> +</span><span id="Generator-1664"><a href="#Generator-1664"><span class="linenos">1664</span></a> +</span><span id="Generator-1665"><a href="#Generator-1665"><span class="linenos">1665</span></a> <span class="k">def</span> <span class="nf">union_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1666"><a href="#Generator-1666"><span class="linenos">1666</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">" DISTINCT"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPLICIT_UNION</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1667"><a href="#Generator-1667"><span class="linenos">1667</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">kind</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"distinct"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" ALL"</span> +</span><span id="Generator-1668"><a href="#Generator-1668"><span class="linenos">1668</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNION</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1669"><a href="#Generator-1669"><span class="linenos">1669</span></a> +</span><span id="Generator-1670"><a href="#Generator-1670"><span class="linenos">1670</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1671"><a href="#Generator-1671"><span class="linenos">1671</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1672"><a href="#Generator-1672"><span class="linenos">1672</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator-1673"><a href="#Generator-1673"><span class="linenos">1673</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> +</span><span id="Generator-1674"><a href="#Generator-1674"><span class="linenos">1674</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">alias</span><span class="o">.</span><span class="n">columns</span> +</span><span id="Generator-1675"><a href="#Generator-1675"><span class="linenos">1675</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">columns</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1676"><a href="#Generator-1676"><span class="linenos">1676</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1677"><a href="#Generator-1677"><span class="linenos">1677</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator-1678"><a href="#Generator-1678"><span class="linenos">1678</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">alias</span> +</span><span id="Generator-1679"><a href="#Generator-1679"><span class="linenos">1679</span></a> <span class="n">ordinality</span> <span class="o">=</span> <span class="s2">" WITH ORDINALITY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ordinality"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1680"><a href="#Generator-1680"><span class="linenos">1680</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">)</span> +</span><span id="Generator-1681"><a href="#Generator-1681"><span class="linenos">1681</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH OFFSET AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">offset</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">offset</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1682"><a href="#Generator-1682"><span class="linenos">1682</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNNEST(</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">ordinality</span><span class="si">}{</span><span class="n">alias</span><span class="si">}{</span><span class="n">offset</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1683"><a href="#Generator-1683"><span class="linenos">1683</span></a> +</span><span id="Generator-1684"><a href="#Generator-1684"><span class="linenos">1684</span></a> <span class="k">def</span> <span class="nf">where_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1685"><a href="#Generator-1685"><span class="linenos">1685</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))</span> +</span><span id="Generator-1686"><a href="#Generator-1686"><span class="linenos">1686</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'WHERE'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1687"><a href="#Generator-1687"><span class="linenos">1687</span></a> +</span><span id="Generator-1688"><a href="#Generator-1688"><span class="linenos">1688</span></a> <span class="k">def</span> <span class="nf">window_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1689"><a href="#Generator-1689"><span class="linenos">1689</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1690"><a href="#Generator-1690"><span class="linenos">1690</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1691"><a href="#Generator-1691"><span class="linenos">1691</span></a> <span class="n">order</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"order"</span><span class="p">)</span> +</span><span id="Generator-1692"><a href="#Generator-1692"><span class="linenos">1692</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1693"><a href="#Generator-1693"><span class="linenos">1693</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"spec"</span><span class="p">)</span> +</span><span id="Generator-1694"><a href="#Generator-1694"><span class="linenos">1694</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator-1695"><a href="#Generator-1695"><span class="linenos">1695</span></a> <span class="n">over</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"over"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"OVER"</span> +</span><span id="Generator-1696"><a href="#Generator-1696"><span class="linenos">1696</span></a> +</span><span id="Generator-1697"><a href="#Generator-1697"><span class="linenos">1697</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="s1">'AS'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">arg_key</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s1">'windows'</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">over</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1698"><a href="#Generator-1698"><span class="linenos">1698</span></a> +</span><span id="Generator-1699"><a href="#Generator-1699"><span class="linenos">1699</span></a> <span class="n">first</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"first"</span><span class="p">)</span> +</span><span id="Generator-1700"><a href="#Generator-1700"><span class="linenos">1700</span></a> <span class="k">if</span> <span class="n">first</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-1701"><a href="#Generator-1701"><span class="linenos">1701</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-1702"><a href="#Generator-1702"><span class="linenos">1702</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1703"><a href="#Generator-1703"><span class="linenos">1703</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">"FIRST"</span> <span class="k">if</span> <span class="n">first</span> <span class="k">else</span> <span class="s2">"LAST"</span> +</span><span id="Generator-1704"><a href="#Generator-1704"><span class="linenos">1704</span></a> +</span><span id="Generator-1705"><a href="#Generator-1705"><span class="linenos">1705</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">partition</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">order</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">spec</span> <span class="ow">and</span> <span class="n">alias</span><span class="p">:</span> +</span><span id="Generator-1706"><a href="#Generator-1706"><span class="linenos">1706</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-1707"><a href="#Generator-1707"><span class="linenos">1707</span></a> -</span><span id="Generator-1708"><a href="#Generator-1708"><span class="linenos">1708</span></a> <span class="k">def</span> <span class="nf">all_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">All</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1709"><a href="#Generator-1709"><span class="linenos">1709</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALL </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1708"><a href="#Generator-1708"><span class="linenos">1708</span></a> <span class="n">args</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">first</span><span class="p">,</span> <span class="n">partition</span><span class="p">,</span> <span class="n">order</span><span class="p">,</span> <span class="n">spec</span><span class="p">)</span> <span class="k">if</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="Generator-1709"><a href="#Generator-1709"><span class="linenos">1709</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> </span><span id="Generator-1710"><a href="#Generator-1710"><span class="linenos">1710</span></a> -</span><span id="Generator-1711"><a href="#Generator-1711"><span class="linenos">1711</span></a> <span class="k">def</span> <span class="nf">any_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1712"><a href="#Generator-1712"><span class="linenos">1712</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1713"><a href="#Generator-1713"><span class="linenos">1713</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="Generator-1714"><a href="#Generator-1714"><span class="linenos">1714</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="Generator-1715"><a href="#Generator-1715"><span class="linenos">1715</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ANY </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1716"><a href="#Generator-1716"><span class="linenos">1716</span></a> -</span><span id="Generator-1717"><a href="#Generator-1717"><span class="linenos">1717</span></a> <span class="k">def</span> <span class="nf">exists_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Exists</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1718"><a href="#Generator-1718"><span class="linenos">1718</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXISTS</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1719"><a href="#Generator-1719"><span class="linenos">1719</span></a> -</span><span id="Generator-1720"><a href="#Generator-1720"><span class="linenos">1720</span></a> <span class="k">def</span> <span class="nf">case_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1721"><a href="#Generator-1721"><span class="linenos">1721</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1722"><a href="#Generator-1722"><span class="linenos">1722</span></a> <span class="n">statements</span> <span class="o">=</span> <span class="p">[</span><span class="sa">f</span><span class="s2">"CASE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">"CASE"</span><span class="p">]</span> +</span><span id="Generator-1711"><a href="#Generator-1711"><span class="linenos">1711</span></a> <span class="k">def</span> <span class="nf">partition_by_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1712"><a href="#Generator-1712"><span class="linenos">1712</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"partition_by"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1713"><a href="#Generator-1713"><span class="linenos">1713</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1714"><a href="#Generator-1714"><span class="linenos">1714</span></a> +</span><span id="Generator-1715"><a href="#Generator-1715"><span class="linenos">1715</span></a> <span class="k">def</span> <span class="nf">windowspec_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WindowSpec</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1716"><a href="#Generator-1716"><span class="linenos">1716</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator-1717"><a href="#Generator-1717"><span class="linenos">1717</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"start_side"</span><span class="p">),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator-1718"><a href="#Generator-1718"><span class="linenos">1718</span></a> <span class="n">end</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-1719"><a href="#Generator-1719"><span class="linenos">1719</span></a> <span class="n">csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"end"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"end_side"</span><span class="p">),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator-1720"><a href="#Generator-1720"><span class="linenos">1720</span></a> <span class="ow">or</span> <span class="s2">"CURRENT ROW"</span> +</span><span id="Generator-1721"><a href="#Generator-1721"><span class="linenos">1721</span></a> <span class="p">)</span> +</span><span id="Generator-1722"><a href="#Generator-1722"><span class="linenos">1722</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">end</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-1723"><a href="#Generator-1723"><span class="linenos">1723</span></a> -</span><span id="Generator-1724"><a href="#Generator-1724"><span class="linenos">1724</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"ifs"</span><span class="p">]:</span> -</span><span id="Generator-1725"><a href="#Generator-1725"><span class="linenos">1725</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"WHEN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-1726"><a href="#Generator-1726"><span class="linenos">1726</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"THEN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'true'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-1727"><a href="#Generator-1727"><span class="linenos">1727</span></a> -</span><span id="Generator-1728"><a href="#Generator-1728"><span class="linenos">1728</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">)</span> -</span><span id="Generator-1729"><a href="#Generator-1729"><span class="linenos">1729</span></a> -</span><span id="Generator-1730"><a href="#Generator-1730"><span class="linenos">1730</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="Generator-1731"><a href="#Generator-1731"><span class="linenos">1731</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"ELSE </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-1732"><a href="#Generator-1732"><span class="linenos">1732</span></a> -</span><span id="Generator-1733"><a href="#Generator-1733"><span class="linenos">1733</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"END"</span><span class="p">)</span> +</span><span id="Generator-1724"><a href="#Generator-1724"><span class="linenos">1724</span></a> <span class="k">def</span> <span class="nf">withingroup_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1725"><a href="#Generator-1725"><span class="linenos">1725</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1726"><a href="#Generator-1726"><span class="linenos">1726</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)[</span><span class="mi">1</span><span class="p">:]</span> <span class="c1"># order has a leading space</span> +</span><span id="Generator-1727"><a href="#Generator-1727"><span class="linenos">1727</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> WITHIN GROUP (</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1728"><a href="#Generator-1728"><span class="linenos">1728</span></a> +</span><span id="Generator-1729"><a href="#Generator-1729"><span class="linenos">1729</span></a> <span class="k">def</span> <span class="nf">between_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1730"><a href="#Generator-1730"><span class="linenos">1730</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1731"><a href="#Generator-1731"><span class="linenos">1731</span></a> <span class="n">low</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"low"</span><span class="p">)</span> +</span><span id="Generator-1732"><a href="#Generator-1732"><span class="linenos">1732</span></a> <span class="n">high</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"high"</span><span class="p">)</span> +</span><span id="Generator-1733"><a href="#Generator-1733"><span class="linenos">1733</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">low</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">high</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-1734"><a href="#Generator-1734"><span class="linenos">1734</span></a> -</span><span id="Generator-1735"><a href="#Generator-1735"><span class="linenos">1735</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">statements</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span><span class="p">:</span> -</span><span id="Generator-1736"><a href="#Generator-1736"><span class="linenos">1736</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">statements</span><span class="p">),</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">skip_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1737"><a href="#Generator-1737"><span class="linenos">1737</span></a> -</span><span id="Generator-1738"><a href="#Generator-1738"><span class="linenos">1738</span></a> <span class="k">return</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">statements</span><span class="p">)</span> -</span><span id="Generator-1739"><a href="#Generator-1739"><span class="linenos">1739</span></a> -</span><span id="Generator-1740"><a href="#Generator-1740"><span class="linenos">1740</span></a> <span class="k">def</span> <span class="nf">constraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Constraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1741"><a href="#Generator-1741"><span class="linenos">1741</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1742"><a href="#Generator-1742"><span class="linenos">1742</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1743"><a href="#Generator-1743"><span class="linenos">1743</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1744"><a href="#Generator-1744"><span class="linenos">1744</span></a> -</span><span id="Generator-1745"><a href="#Generator-1745"><span class="linenos">1745</span></a> <span class="k">def</span> <span class="nf">nextvaluefor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NextValueFor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1746"><a href="#Generator-1746"><span class="linenos">1746</span></a> <span class="n">order</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"order"</span><span class="p">)</span> -</span><span id="Generator-1747"><a href="#Generator-1747"><span class="linenos">1747</span></a> <span class="n">order</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OVER (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1748"><a href="#Generator-1748"><span class="linenos">1748</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NEXT VALUE FOR </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">order</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1735"><a href="#Generator-1735"><span class="linenos">1735</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1736"><a href="#Generator-1736"><span class="linenos">1736</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">apply_index_offset</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">INDEX_OFFSET</span><span class="p">)</span> +</span><span id="Generator-1737"><a href="#Generator-1737"><span class="linenos">1737</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator-1738"><a href="#Generator-1738"><span class="linenos">1738</span></a> +</span><span id="Generator-1739"><a href="#Generator-1739"><span class="linenos">1739</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">[</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> +</span><span id="Generator-1740"><a href="#Generator-1740"><span class="linenos">1740</span></a> +</span><span id="Generator-1741"><a href="#Generator-1741"><span class="linenos">1741</span></a> <span class="k">def</span> <span class="nf">all_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">All</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1742"><a href="#Generator-1742"><span class="linenos">1742</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALL </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1743"><a href="#Generator-1743"><span class="linenos">1743</span></a> +</span><span id="Generator-1744"><a href="#Generator-1744"><span class="linenos">1744</span></a> <span class="k">def</span> <span class="nf">any_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1745"><a href="#Generator-1745"><span class="linenos">1745</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1746"><a href="#Generator-1746"><span class="linenos">1746</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="Generator-1747"><a href="#Generator-1747"><span class="linenos">1747</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="Generator-1748"><a href="#Generator-1748"><span class="linenos">1748</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ANY </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-1749"><a href="#Generator-1749"><span class="linenos">1749</span></a> -</span><span id="Generator-1750"><a href="#Generator-1750"><span class="linenos">1750</span></a> <span class="k">def</span> <span class="nf">extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1751"><a href="#Generator-1751"><span class="linenos">1751</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1752"><a href="#Generator-1752"><span class="linenos">1752</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator-1753"><a href="#Generator-1753"><span class="linenos">1753</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXTRACT(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FROM </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1754"><a href="#Generator-1754"><span class="linenos">1754</span></a> -</span><span id="Generator-1755"><a href="#Generator-1755"><span class="linenos">1755</span></a> <span class="k">def</span> <span class="nf">trim_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1756"><a href="#Generator-1756"><span class="linenos">1756</span></a> <span class="n">trim_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> -</span><span id="Generator-1757"><a href="#Generator-1757"><span class="linenos">1757</span></a> -</span><span id="Generator-1758"><a href="#Generator-1758"><span class="linenos">1758</span></a> <span class="k">if</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"LEADING"</span><span class="p">:</span> -</span><span id="Generator-1759"><a href="#Generator-1759"><span class="linenos">1759</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LTRIM"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="Generator-1760"><a href="#Generator-1760"><span class="linenos">1760</span></a> <span class="k">elif</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"TRAILING"</span><span class="p">:</span> -</span><span id="Generator-1761"><a href="#Generator-1761"><span class="linenos">1761</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"RTRIM"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="Generator-1762"><a href="#Generator-1762"><span class="linenos">1762</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1763"><a href="#Generator-1763"><span class="linenos">1763</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1764"><a href="#Generator-1764"><span class="linenos">1764</span></a> -</span><span id="Generator-1765"><a href="#Generator-1765"><span class="linenos">1765</span></a> <span class="k">def</span> <span class="nf">safeconcat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1766"><a href="#Generator-1766"><span class="linenos">1766</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="Generator-1767"><a href="#Generator-1767"><span class="linenos">1767</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> -</span><span id="Generator-1768"><a href="#Generator-1768"><span class="linenos">1768</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> -</span><span id="Generator-1769"><a href="#Generator-1769"><span class="linenos">1769</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator-1750"><a href="#Generator-1750"><span class="linenos">1750</span></a> <span class="k">def</span> <span class="nf">exists_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Exists</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1751"><a href="#Generator-1751"><span class="linenos">1751</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXISTS</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1752"><a href="#Generator-1752"><span class="linenos">1752</span></a> +</span><span id="Generator-1753"><a href="#Generator-1753"><span class="linenos">1753</span></a> <span class="k">def</span> <span class="nf">case_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1754"><a href="#Generator-1754"><span class="linenos">1754</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1755"><a href="#Generator-1755"><span class="linenos">1755</span></a> <span class="n">statements</span> <span class="o">=</span> <span class="p">[</span><span class="sa">f</span><span class="s2">"CASE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">"CASE"</span><span class="p">]</span> +</span><span id="Generator-1756"><a href="#Generator-1756"><span class="linenos">1756</span></a> +</span><span id="Generator-1757"><a href="#Generator-1757"><span class="linenos">1757</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"ifs"</span><span class="p">]:</span> +</span><span id="Generator-1758"><a href="#Generator-1758"><span class="linenos">1758</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"WHEN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-1759"><a href="#Generator-1759"><span class="linenos">1759</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"THEN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'true'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-1760"><a href="#Generator-1760"><span class="linenos">1760</span></a> +</span><span id="Generator-1761"><a href="#Generator-1761"><span class="linenos">1761</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">)</span> +</span><span id="Generator-1762"><a href="#Generator-1762"><span class="linenos">1762</span></a> +</span><span id="Generator-1763"><a href="#Generator-1763"><span class="linenos">1763</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> +</span><span id="Generator-1764"><a href="#Generator-1764"><span class="linenos">1764</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"ELSE </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-1765"><a href="#Generator-1765"><span class="linenos">1765</span></a> +</span><span id="Generator-1766"><a href="#Generator-1766"><span class="linenos">1766</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"END"</span><span class="p">)</span> +</span><span id="Generator-1767"><a href="#Generator-1767"><span class="linenos">1767</span></a> +</span><span id="Generator-1768"><a href="#Generator-1768"><span class="linenos">1768</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">statements</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span><span class="p">:</span> +</span><span id="Generator-1769"><a href="#Generator-1769"><span class="linenos">1769</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">statements</span><span class="p">),</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">skip_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span><span id="Generator-1770"><a href="#Generator-1770"><span class="linenos">1770</span></a> -</span><span id="Generator-1771"><a href="#Generator-1771"><span class="linenos">1771</span></a> <span class="k">def</span> <span class="nf">check_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Check</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1772"><a href="#Generator-1772"><span class="linenos">1772</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1773"><a href="#Generator-1773"><span class="linenos">1773</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECK (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1774"><a href="#Generator-1774"><span class="linenos">1774</span></a> -</span><span id="Generator-1775"><a href="#Generator-1775"><span class="linenos">1775</span></a> <span class="k">def</span> <span class="nf">foreignkey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1776"><a href="#Generator-1776"><span class="linenos">1776</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1777"><a href="#Generator-1777"><span class="linenos">1777</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"reference"</span><span class="p">)</span> -</span><span id="Generator-1778"><a href="#Generator-1778"><span class="linenos">1778</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">reference</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">reference</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1779"><a href="#Generator-1779"><span class="linenos">1779</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"delete"</span><span class="p">)</span> -</span><span id="Generator-1780"><a href="#Generator-1780"><span class="linenos">1780</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON DELETE </span><span class="si">{</span><span class="n">delete</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">delete</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1781"><a href="#Generator-1781"><span class="linenos">1781</span></a> <span class="n">update</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"update"</span><span class="p">)</span> -</span><span id="Generator-1782"><a href="#Generator-1782"><span class="linenos">1782</span></a> <span class="n">update</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON UPDATE </span><span class="si">{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">update</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1783"><a href="#Generator-1783"><span class="linenos">1783</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FOREIGN KEY (</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">reference</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1784"><a href="#Generator-1784"><span class="linenos">1784</span></a> -</span><span id="Generator-1785"><a href="#Generator-1785"><span class="linenos">1785</span></a> <span class="k">def</span> <span class="nf">primarykey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1786"><a href="#Generator-1786"><span class="linenos">1786</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1787"><a href="#Generator-1787"><span class="linenos">1787</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator-1788"><a href="#Generator-1788"><span class="linenos">1788</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1789"><a href="#Generator-1789"><span class="linenos">1789</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY (</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1771"><a href="#Generator-1771"><span class="linenos">1771</span></a> <span class="k">return</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">statements</span><span class="p">)</span> +</span><span id="Generator-1772"><a href="#Generator-1772"><span class="linenos">1772</span></a> +</span><span id="Generator-1773"><a href="#Generator-1773"><span class="linenos">1773</span></a> <span class="k">def</span> <span class="nf">constraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Constraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1774"><a href="#Generator-1774"><span class="linenos">1774</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1775"><a href="#Generator-1775"><span class="linenos">1775</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1776"><a href="#Generator-1776"><span class="linenos">1776</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1777"><a href="#Generator-1777"><span class="linenos">1777</span></a> +</span><span id="Generator-1778"><a href="#Generator-1778"><span class="linenos">1778</span></a> <span class="k">def</span> <span class="nf">nextvaluefor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NextValueFor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1779"><a href="#Generator-1779"><span class="linenos">1779</span></a> <span class="n">order</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"order"</span><span class="p">)</span> +</span><span id="Generator-1780"><a href="#Generator-1780"><span class="linenos">1780</span></a> <span class="n">order</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OVER (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1781"><a href="#Generator-1781"><span class="linenos">1781</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NEXT VALUE FOR </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">order</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1782"><a href="#Generator-1782"><span class="linenos">1782</span></a> +</span><span id="Generator-1783"><a href="#Generator-1783"><span class="linenos">1783</span></a> <span class="k">def</span> <span class="nf">extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1784"><a href="#Generator-1784"><span class="linenos">1784</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1785"><a href="#Generator-1785"><span class="linenos">1785</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator-1786"><a href="#Generator-1786"><span class="linenos">1786</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXTRACT(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FROM </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1787"><a href="#Generator-1787"><span class="linenos">1787</span></a> +</span><span id="Generator-1788"><a href="#Generator-1788"><span class="linenos">1788</span></a> <span class="k">def</span> <span class="nf">trim_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1789"><a href="#Generator-1789"><span class="linenos">1789</span></a> <span class="n">trim_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> </span><span id="Generator-1790"><a href="#Generator-1790"><span class="linenos">1790</span></a> -</span><span id="Generator-1791"><a href="#Generator-1791"><span class="linenos">1791</span></a> <span class="k">def</span> <span class="nf">if_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1792"><a href="#Generator-1792"><span class="linenos">1792</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">case_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">(</span><span class="n">ifs</span><span class="o">=</span><span class="p">[</span><span class="n">expression</span><span class="p">],</span> <span class="n">default</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"false"</span><span class="p">)))</span> -</span><span id="Generator-1793"><a href="#Generator-1793"><span class="linenos">1793</span></a> -</span><span id="Generator-1794"><a href="#Generator-1794"><span class="linenos">1794</span></a> <span class="k">def</span> <span class="nf">matchagainst_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchAgainst</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1795"><a href="#Generator-1795"><span class="linenos">1795</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modifier"</span><span class="p">)</span> -</span><span id="Generator-1796"><a href="#Generator-1796"><span class="linenos">1796</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">modifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modifier</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1797"><a href="#Generator-1797"><span class="linenos">1797</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'MATCH'</span><span class="p">,</span><span class="w"> </span><span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span><span class="si">}</span><span class="s2"> AGAINST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">modifier</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1798"><a href="#Generator-1798"><span class="linenos">1798</span></a> -</span><span id="Generator-1799"><a href="#Generator-1799"><span class="linenos">1799</span></a> <span class="k">def</span> <span class="nf">jsonkeyvalue_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONKeyValue</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1800"><a href="#Generator-1800"><span class="linenos">1800</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1801"><a href="#Generator-1801"><span class="linenos">1801</span></a> -</span><span id="Generator-1802"><a href="#Generator-1802"><span class="linenos">1802</span></a> <span class="k">def</span> <span class="nf">jsonobject_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONObject</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1803"><a href="#Generator-1803"><span class="linenos">1803</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"null_handling"</span><span class="p">)</span> -</span><span id="Generator-1804"><a href="#Generator-1804"><span class="linenos">1804</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1805"><a href="#Generator-1805"><span class="linenos">1805</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unique_keys"</span><span class="p">)</span> -</span><span id="Generator-1806"><a href="#Generator-1806"><span class="linenos">1806</span></a> <span class="k">if</span> <span class="n">unique_keys</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-1807"><a href="#Generator-1807"><span class="linenos">1807</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">'WITH'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">unique_keys</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'WITHOUT'</span><span class="si">}</span><span class="s2"> UNIQUE KEYS"</span> -</span><span id="Generator-1808"><a href="#Generator-1808"><span class="linenos">1808</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1809"><a href="#Generator-1809"><span class="linenos">1809</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-1810"><a href="#Generator-1810"><span class="linenos">1810</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"return_type"</span><span class="p">)</span> -</span><span id="Generator-1811"><a href="#Generator-1811"><span class="linenos">1811</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1812"><a href="#Generator-1812"><span class="linenos">1812</span></a> <span class="n">format_json</span> <span class="o">=</span> <span class="s2">" FORMAT JSON"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"format_json"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1813"><a href="#Generator-1813"><span class="linenos">1813</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"encoding"</span><span class="p">)</span> -</span><span id="Generator-1814"><a href="#Generator-1814"><span class="linenos">1814</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ENCODING </span><span class="si">{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">encoding</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1815"><a href="#Generator-1815"><span class="linenos">1815</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="Generator-1816"><a href="#Generator-1816"><span class="linenos">1816</span></a> <span class="s2">"JSON_OBJECT"</span><span class="p">,</span> -</span><span id="Generator-1817"><a href="#Generator-1817"><span class="linenos">1817</span></a> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Generator-1818"><a href="#Generator-1818"><span class="linenos">1818</span></a> <span class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">null_handling</span><span class="si">}{</span><span class="n">unique_keys</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">format_json</span><span class="si">}{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Generator-1819"><a href="#Generator-1819"><span class="linenos">1819</span></a> <span class="p">)</span> -</span><span id="Generator-1820"><a href="#Generator-1820"><span class="linenos">1820</span></a> -</span><span id="Generator-1821"><a href="#Generator-1821"><span class="linenos">1821</span></a> <span class="k">def</span> <span class="nf">openjsoncolumndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSONColumnDef</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1822"><a href="#Generator-1822"><span class="linenos">1822</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1823"><a href="#Generator-1823"><span class="linenos">1823</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator-1824"><a href="#Generator-1824"><span class="linenos">1824</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> -</span><span id="Generator-1825"><a href="#Generator-1825"><span class="linenos">1825</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1826"><a href="#Generator-1826"><span class="linenos">1826</span></a> <span class="n">as_json</span> <span class="o">=</span> <span class="s2">" AS JSON"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"as_json"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1827"><a href="#Generator-1827"><span class="linenos">1827</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">path</span><span class="si">}{</span><span class="n">as_json</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1828"><a href="#Generator-1828"><span class="linenos">1828</span></a> -</span><span id="Generator-1829"><a href="#Generator-1829"><span class="linenos">1829</span></a> <span class="k">def</span> <span class="nf">openjson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1830"><a href="#Generator-1830"><span class="linenos">1830</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1831"><a href="#Generator-1831"><span class="linenos">1831</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> -</span><span id="Generator-1832"><a href="#Generator-1832"><span class="linenos">1832</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1833"><a href="#Generator-1833"><span class="linenos">1833</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1834"><a href="#Generator-1834"><span class="linenos">1834</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-1835"><a href="#Generator-1835"><span class="linenos">1835</span></a> <span class="sa">f</span><span class="s2">" WITH (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">expressions</span><span class="p">),</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1836"><a href="#Generator-1836"><span class="linenos">1836</span></a> <span class="k">if</span> <span class="n">expressions</span> -</span><span id="Generator-1837"><a href="#Generator-1837"><span class="linenos">1837</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1838"><a href="#Generator-1838"><span class="linenos">1838</span></a> <span class="p">)</span> -</span><span id="Generator-1839"><a href="#Generator-1839"><span class="linenos">1839</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"OPENJSON(</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">path</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">with_</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1840"><a href="#Generator-1840"><span class="linenos">1840</span></a> -</span><span id="Generator-1841"><a href="#Generator-1841"><span class="linenos">1841</span></a> <span class="k">def</span> <span class="nf">in_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">In</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1842"><a href="#Generator-1842"><span class="linenos">1842</span></a> <span class="n">query</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"query"</span><span class="p">)</span> -</span><span id="Generator-1843"><a href="#Generator-1843"><span class="linenos">1843</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unnest"</span><span class="p">)</span> -</span><span id="Generator-1844"><a href="#Generator-1844"><span class="linenos">1844</span></a> <span class="n">field</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"field"</span><span class="p">)</span> -</span><span id="Generator-1845"><a href="#Generator-1845"><span class="linenos">1845</span></a> <span class="n">is_global</span> <span class="o">=</span> <span class="s2">" GLOBAL"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"is_global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1846"><a href="#Generator-1846"><span class="linenos">1846</span></a> -</span><span id="Generator-1847"><a href="#Generator-1847"><span class="linenos">1847</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> -</span><span id="Generator-1848"><a href="#Generator-1848"><span class="linenos">1848</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">query</span><span class="p">)</span> -</span><span id="Generator-1849"><a href="#Generator-1849"><span class="linenos">1849</span></a> <span class="k">elif</span> <span class="n">unnest</span><span class="p">:</span> -</span><span id="Generator-1850"><a href="#Generator-1850"><span class="linenos">1850</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">in_unnest_op</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span> -</span><span id="Generator-1851"><a href="#Generator-1851"><span class="linenos">1851</span></a> <span class="k">elif</span> <span class="n">field</span><span class="p">:</span> -</span><span id="Generator-1852"><a href="#Generator-1852"><span class="linenos">1852</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">field</span><span class="p">)</span> -</span><span id="Generator-1853"><a href="#Generator-1853"><span class="linenos">1853</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1854"><a href="#Generator-1854"><span class="linenos">1854</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1855"><a href="#Generator-1855"><span class="linenos">1855</span></a> -</span><span id="Generator-1856"><a href="#Generator-1856"><span class="linenos">1856</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">is_global</span><span class="si">}</span><span class="s2"> IN </span><span class="si">{</span><span class="n">in_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1857"><a href="#Generator-1857"><span class="linenos">1857</span></a> -</span><span id="Generator-1858"><a href="#Generator-1858"><span class="linenos">1858</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">unnest</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1859"><a href="#Generator-1859"><span class="linenos">1859</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(SELECT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1860"><a href="#Generator-1860"><span class="linenos">1860</span></a> -</span><span id="Generator-1861"><a href="#Generator-1861"><span class="linenos">1861</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1862"><a href="#Generator-1862"><span class="linenos">1862</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> -</span><span id="Generator-1863"><a href="#Generator-1863"><span class="linenos">1863</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span><span class="p">:</span> -</span><span id="Generator-1864"><a href="#Generator-1864"><span class="linenos">1864</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_PART_SINGULARS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> <span class="n">unit</span><span class="p">)</span> -</span><span id="Generator-1865"><a href="#Generator-1865"><span class="linenos">1865</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1866"><a href="#Generator-1866"><span class="linenos">1866</span></a> -</span><span id="Generator-1867"><a href="#Generator-1867"><span class="linenos">1867</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_STRING_INTERVAL</span><span class="p">:</span> -</span><span id="Generator-1868"><a href="#Generator-1868"><span class="linenos">1868</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1869"><a href="#Generator-1869"><span class="linenos">1869</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL '</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">'"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1870"><a href="#Generator-1870"><span class="linenos">1870</span></a> -</span><span id="Generator-1871"><a href="#Generator-1871"><span class="linenos">1871</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1872"><a href="#Generator-1872"><span class="linenos">1872</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> -</span><span id="Generator-1873"><a href="#Generator-1873"><span class="linenos">1873</span></a> <span class="n">unwrapped</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">)</span> -</span><span id="Generator-1874"><a href="#Generator-1874"><span class="linenos">1874</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unwrapped</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1875"><a href="#Generator-1875"><span class="linenos">1875</span></a> -</span><span id="Generator-1876"><a href="#Generator-1876"><span class="linenos">1876</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1877"><a href="#Generator-1877"><span class="linenos">1877</span></a> -</span><span id="Generator-1878"><a href="#Generator-1878"><span class="linenos">1878</span></a> <span class="k">def</span> <span class="nf">return_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Return</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1879"><a href="#Generator-1879"><span class="linenos">1879</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RETURN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1880"><a href="#Generator-1880"><span class="linenos">1880</span></a> -</span><span id="Generator-1881"><a href="#Generator-1881"><span class="linenos">1881</span></a> <span class="k">def</span> <span class="nf">reference_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Reference</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1882"><a href="#Generator-1882"><span class="linenos">1882</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1883"><a href="#Generator-1883"><span class="linenos">1883</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-1884"><a href="#Generator-1884"><span class="linenos">1884</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1885"><a href="#Generator-1885"><span class="linenos">1885</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator-1886"><a href="#Generator-1886"><span class="linenos">1886</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1887"><a href="#Generator-1887"><span class="linenos">1887</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"REFERENCES </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1791"><a href="#Generator-1791"><span class="linenos">1791</span></a> <span class="k">if</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"LEADING"</span><span class="p">:</span> +</span><span id="Generator-1792"><a href="#Generator-1792"><span class="linenos">1792</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LTRIM"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="Generator-1793"><a href="#Generator-1793"><span class="linenos">1793</span></a> <span class="k">elif</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"TRAILING"</span><span class="p">:</span> +</span><span id="Generator-1794"><a href="#Generator-1794"><span class="linenos">1794</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"RTRIM"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="Generator-1795"><a href="#Generator-1795"><span class="linenos">1795</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1796"><a href="#Generator-1796"><span class="linenos">1796</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1797"><a href="#Generator-1797"><span class="linenos">1797</span></a> +</span><span id="Generator-1798"><a href="#Generator-1798"><span class="linenos">1798</span></a> <span class="k">def</span> <span class="nf">safeconcat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1799"><a href="#Generator-1799"><span class="linenos">1799</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="Generator-1800"><a href="#Generator-1800"><span class="linenos">1800</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> +</span><span id="Generator-1801"><a href="#Generator-1801"><span class="linenos">1801</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator-1802"><a href="#Generator-1802"><span class="linenos">1802</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator-1803"><a href="#Generator-1803"><span class="linenos">1803</span></a> +</span><span id="Generator-1804"><a href="#Generator-1804"><span class="linenos">1804</span></a> <span class="k">def</span> <span class="nf">check_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Check</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1805"><a href="#Generator-1805"><span class="linenos">1805</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1806"><a href="#Generator-1806"><span class="linenos">1806</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECK (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1807"><a href="#Generator-1807"><span class="linenos">1807</span></a> +</span><span id="Generator-1808"><a href="#Generator-1808"><span class="linenos">1808</span></a> <span class="k">def</span> <span class="nf">foreignkey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1809"><a href="#Generator-1809"><span class="linenos">1809</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1810"><a href="#Generator-1810"><span class="linenos">1810</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"reference"</span><span class="p">)</span> +</span><span id="Generator-1811"><a href="#Generator-1811"><span class="linenos">1811</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">reference</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">reference</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1812"><a href="#Generator-1812"><span class="linenos">1812</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"delete"</span><span class="p">)</span> +</span><span id="Generator-1813"><a href="#Generator-1813"><span class="linenos">1813</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON DELETE </span><span class="si">{</span><span class="n">delete</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">delete</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1814"><a href="#Generator-1814"><span class="linenos">1814</span></a> <span class="n">update</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"update"</span><span class="p">)</span> +</span><span id="Generator-1815"><a href="#Generator-1815"><span class="linenos">1815</span></a> <span class="n">update</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON UPDATE </span><span class="si">{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">update</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1816"><a href="#Generator-1816"><span class="linenos">1816</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FOREIGN KEY (</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">reference</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1817"><a href="#Generator-1817"><span class="linenos">1817</span></a> +</span><span id="Generator-1818"><a href="#Generator-1818"><span class="linenos">1818</span></a> <span class="k">def</span> <span class="nf">primarykey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1819"><a href="#Generator-1819"><span class="linenos">1819</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1820"><a href="#Generator-1820"><span class="linenos">1820</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator-1821"><a href="#Generator-1821"><span class="linenos">1821</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1822"><a href="#Generator-1822"><span class="linenos">1822</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY (</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1823"><a href="#Generator-1823"><span class="linenos">1823</span></a> +</span><span id="Generator-1824"><a href="#Generator-1824"><span class="linenos">1824</span></a> <span class="k">def</span> <span class="nf">if_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1825"><a href="#Generator-1825"><span class="linenos">1825</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">case_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">(</span><span class="n">ifs</span><span class="o">=</span><span class="p">[</span><span class="n">expression</span><span class="p">],</span> <span class="n">default</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"false"</span><span class="p">)))</span> +</span><span id="Generator-1826"><a href="#Generator-1826"><span class="linenos">1826</span></a> +</span><span id="Generator-1827"><a href="#Generator-1827"><span class="linenos">1827</span></a> <span class="k">def</span> <span class="nf">matchagainst_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchAgainst</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1828"><a href="#Generator-1828"><span class="linenos">1828</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modifier"</span><span class="p">)</span> +</span><span id="Generator-1829"><a href="#Generator-1829"><span class="linenos">1829</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">modifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modifier</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1830"><a href="#Generator-1830"><span class="linenos">1830</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'MATCH'</span><span class="p">,</span><span class="w"> </span><span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span><span class="si">}</span><span class="s2"> AGAINST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">modifier</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1831"><a href="#Generator-1831"><span class="linenos">1831</span></a> +</span><span id="Generator-1832"><a href="#Generator-1832"><span class="linenos">1832</span></a> <span class="k">def</span> <span class="nf">jsonkeyvalue_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONKeyValue</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1833"><a href="#Generator-1833"><span class="linenos">1833</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1834"><a href="#Generator-1834"><span class="linenos">1834</span></a> +</span><span id="Generator-1835"><a href="#Generator-1835"><span class="linenos">1835</span></a> <span class="k">def</span> <span class="nf">jsonobject_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONObject</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1836"><a href="#Generator-1836"><span class="linenos">1836</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"null_handling"</span><span class="p">)</span> +</span><span id="Generator-1837"><a href="#Generator-1837"><span class="linenos">1837</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1838"><a href="#Generator-1838"><span class="linenos">1838</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unique_keys"</span><span class="p">)</span> +</span><span id="Generator-1839"><a href="#Generator-1839"><span class="linenos">1839</span></a> <span class="k">if</span> <span class="n">unique_keys</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-1840"><a href="#Generator-1840"><span class="linenos">1840</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">'WITH'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">unique_keys</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'WITHOUT'</span><span class="si">}</span><span class="s2"> UNIQUE KEYS"</span> +</span><span id="Generator-1841"><a href="#Generator-1841"><span class="linenos">1841</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1842"><a href="#Generator-1842"><span class="linenos">1842</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-1843"><a href="#Generator-1843"><span class="linenos">1843</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"return_type"</span><span class="p">)</span> +</span><span id="Generator-1844"><a href="#Generator-1844"><span class="linenos">1844</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1845"><a href="#Generator-1845"><span class="linenos">1845</span></a> <span class="n">format_json</span> <span class="o">=</span> <span class="s2">" FORMAT JSON"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"format_json"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1846"><a href="#Generator-1846"><span class="linenos">1846</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"encoding"</span><span class="p">)</span> +</span><span id="Generator-1847"><a href="#Generator-1847"><span class="linenos">1847</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ENCODING </span><span class="si">{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">encoding</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1848"><a href="#Generator-1848"><span class="linenos">1848</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="Generator-1849"><a href="#Generator-1849"><span class="linenos">1849</span></a> <span class="s2">"JSON_OBJECT"</span><span class="p">,</span> +</span><span id="Generator-1850"><a href="#Generator-1850"><span class="linenos">1850</span></a> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Generator-1851"><a href="#Generator-1851"><span class="linenos">1851</span></a> <span class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">null_handling</span><span class="si">}{</span><span class="n">unique_keys</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">format_json</span><span class="si">}{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Generator-1852"><a href="#Generator-1852"><span class="linenos">1852</span></a> <span class="p">)</span> +</span><span id="Generator-1853"><a href="#Generator-1853"><span class="linenos">1853</span></a> +</span><span id="Generator-1854"><a href="#Generator-1854"><span class="linenos">1854</span></a> <span class="k">def</span> <span class="nf">openjsoncolumndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSONColumnDef</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1855"><a href="#Generator-1855"><span class="linenos">1855</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1856"><a href="#Generator-1856"><span class="linenos">1856</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator-1857"><a href="#Generator-1857"><span class="linenos">1857</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> +</span><span id="Generator-1858"><a href="#Generator-1858"><span class="linenos">1858</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1859"><a href="#Generator-1859"><span class="linenos">1859</span></a> <span class="n">as_json</span> <span class="o">=</span> <span class="s2">" AS JSON"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"as_json"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1860"><a href="#Generator-1860"><span class="linenos">1860</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">path</span><span class="si">}{</span><span class="n">as_json</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1861"><a href="#Generator-1861"><span class="linenos">1861</span></a> +</span><span id="Generator-1862"><a href="#Generator-1862"><span class="linenos">1862</span></a> <span class="k">def</span> <span class="nf">openjson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1863"><a href="#Generator-1863"><span class="linenos">1863</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1864"><a href="#Generator-1864"><span class="linenos">1864</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> +</span><span id="Generator-1865"><a href="#Generator-1865"><span class="linenos">1865</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1866"><a href="#Generator-1866"><span class="linenos">1866</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1867"><a href="#Generator-1867"><span class="linenos">1867</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-1868"><a href="#Generator-1868"><span class="linenos">1868</span></a> <span class="sa">f</span><span class="s2">" WITH (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">expressions</span><span class="p">),</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1869"><a href="#Generator-1869"><span class="linenos">1869</span></a> <span class="k">if</span> <span class="n">expressions</span> +</span><span id="Generator-1870"><a href="#Generator-1870"><span class="linenos">1870</span></a> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1871"><a href="#Generator-1871"><span class="linenos">1871</span></a> <span class="p">)</span> +</span><span id="Generator-1872"><a href="#Generator-1872"><span class="linenos">1872</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"OPENJSON(</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">path</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">with_</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1873"><a href="#Generator-1873"><span class="linenos">1873</span></a> +</span><span id="Generator-1874"><a href="#Generator-1874"><span class="linenos">1874</span></a> <span class="k">def</span> <span class="nf">in_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">In</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1875"><a href="#Generator-1875"><span class="linenos">1875</span></a> <span class="n">query</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"query"</span><span class="p">)</span> +</span><span id="Generator-1876"><a href="#Generator-1876"><span class="linenos">1876</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unnest"</span><span class="p">)</span> +</span><span id="Generator-1877"><a href="#Generator-1877"><span class="linenos">1877</span></a> <span class="n">field</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"field"</span><span class="p">)</span> +</span><span id="Generator-1878"><a href="#Generator-1878"><span class="linenos">1878</span></a> <span class="n">is_global</span> <span class="o">=</span> <span class="s2">" GLOBAL"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"is_global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1879"><a href="#Generator-1879"><span class="linenos">1879</span></a> +</span><span id="Generator-1880"><a href="#Generator-1880"><span class="linenos">1880</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> +</span><span id="Generator-1881"><a href="#Generator-1881"><span class="linenos">1881</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">query</span><span class="p">)</span> +</span><span id="Generator-1882"><a href="#Generator-1882"><span class="linenos">1882</span></a> <span class="k">elif</span> <span class="n">unnest</span><span class="p">:</span> +</span><span id="Generator-1883"><a href="#Generator-1883"><span class="linenos">1883</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">in_unnest_op</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span> +</span><span id="Generator-1884"><a href="#Generator-1884"><span class="linenos">1884</span></a> <span class="k">elif</span> <span class="n">field</span><span class="p">:</span> +</span><span id="Generator-1885"><a href="#Generator-1885"><span class="linenos">1885</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">field</span><span class="p">)</span> +</span><span id="Generator-1886"><a href="#Generator-1886"><span class="linenos">1886</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1887"><a href="#Generator-1887"><span class="linenos">1887</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> </span><span id="Generator-1888"><a href="#Generator-1888"><span class="linenos">1888</span></a> -</span><span id="Generator-1889"><a href="#Generator-1889"><span class="linenos">1889</span></a> <span class="k">def</span> <span class="nf">anonymous_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Anonymous</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1890"><a href="#Generator-1890"><span class="linenos">1890</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Generator-1891"><a href="#Generator-1891"><span class="linenos">1891</span></a> -</span><span id="Generator-1892"><a href="#Generator-1892"><span class="linenos">1892</span></a> <span class="k">def</span> <span class="nf">paren_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1893"><a href="#Generator-1893"><span class="linenos">1893</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">unnest</span><span class="p">(),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> -</span><span id="Generator-1894"><a href="#Generator-1894"><span class="linenos">1894</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-1895"><a href="#Generator-1895"><span class="linenos">1895</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-1896"><a href="#Generator-1896"><span class="linenos">1896</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="Generator-1897"><a href="#Generator-1897"><span class="linenos">1897</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1898"><a href="#Generator-1898"><span class="linenos">1898</span></a> -</span><span id="Generator-1899"><a href="#Generator-1899"><span class="linenos">1899</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="Generator-1900"><a href="#Generator-1900"><span class="linenos">1900</span></a> -</span><span id="Generator-1901"><a href="#Generator-1901"><span class="linenos">1901</span></a> <span class="k">def</span> <span class="nf">neg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Neg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1902"><a href="#Generator-1902"><span class="linenos">1902</span></a> <span class="c1"># This makes sure we don't convert "- - 5" to "--5", which is a comment</span> -</span><span id="Generator-1903"><a href="#Generator-1903"><span class="linenos">1903</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1904"><a href="#Generator-1904"><span class="linenos">1904</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">this_sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"-"</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1905"><a href="#Generator-1905"><span class="linenos">1905</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"-</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1906"><a href="#Generator-1906"><span class="linenos">1906</span></a> -</span><span id="Generator-1907"><a href="#Generator-1907"><span class="linenos">1907</span></a> <span class="k">def</span> <span class="nf">not_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Not</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1908"><a href="#Generator-1908"><span class="linenos">1908</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NOT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1909"><a href="#Generator-1909"><span class="linenos">1909</span></a> -</span><span id="Generator-1910"><a href="#Generator-1910"><span class="linenos">1910</span></a> <span class="k">def</span> <span class="nf">alias_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1911"><a href="#Generator-1911"><span class="linenos">1911</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator-1912"><a href="#Generator-1912"><span class="linenos">1912</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1913"><a href="#Generator-1913"><span class="linenos">1913</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1914"><a href="#Generator-1914"><span class="linenos">1914</span></a> -</span><span id="Generator-1915"><a href="#Generator-1915"><span class="linenos">1915</span></a> <span class="k">def</span> <span class="nf">aliases_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Aliases</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1916"><a href="#Generator-1916"><span class="linenos">1916</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-1917"><a href="#Generator-1917"><span class="linenos">1917</span></a> -</span><span id="Generator-1918"><a href="#Generator-1918"><span class="linenos">1918</span></a> <span class="k">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1919"><a href="#Generator-1919"><span class="linenos">1919</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1920"><a href="#Generator-1920"><span class="linenos">1920</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">)</span> -</span><span id="Generator-1921"><a href="#Generator-1921"><span class="linenos">1921</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> AT TIME ZONE </span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1922"><a href="#Generator-1922"><span class="linenos">1922</span></a> -</span><span id="Generator-1923"><a href="#Generator-1923"><span class="linenos">1923</span></a> <span class="k">def</span> <span class="nf">add_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Add</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1924"><a href="#Generator-1924"><span class="linenos">1924</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">)</span> -</span><span id="Generator-1925"><a href="#Generator-1925"><span class="linenos">1925</span></a> -</span><span id="Generator-1926"><a href="#Generator-1926"><span class="linenos">1926</span></a> <span class="k">def</span> <span class="nf">and_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">And</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1927"><a href="#Generator-1927"><span class="linenos">1927</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"AND"</span><span class="p">)</span> -</span><span id="Generator-1928"><a href="#Generator-1928"><span class="linenos">1928</span></a> -</span><span id="Generator-1929"><a href="#Generator-1929"><span class="linenos">1929</span></a> <span class="k">def</span> <span class="nf">connector_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Connector</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1930"><a href="#Generator-1930"><span class="linenos">1930</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="Generator-1931"><a href="#Generator-1931"><span class="linenos">1931</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">op</span><span class="p">)</span> -</span><span id="Generator-1932"><a href="#Generator-1932"><span class="linenos">1932</span></a> -</span><span id="Generator-1933"><a href="#Generator-1933"><span class="linenos">1933</span></a> <span class="n">sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> -</span><span id="Generator-1934"><a href="#Generator-1934"><span class="linenos">1934</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> <span class="n">e</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">comments</span> <span class="ow">or</span> <span class="p">[])</span> <span class="k">if</span> <span class="n">i</span> <span class="o">!=</span> <span class="mi">1</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> -</span><span id="Generator-1935"><a href="#Generator-1935"><span class="linenos">1935</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">(</span><span class="n">unnest</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> -</span><span id="Generator-1936"><a href="#Generator-1936"><span class="linenos">1936</span></a> <span class="p">)</span> -</span><span id="Generator-1937"><a href="#Generator-1937"><span class="linenos">1937</span></a> -</span><span id="Generator-1938"><a href="#Generator-1938"><span class="linenos">1938</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator-1939"><a href="#Generator-1939"><span class="linenos">1939</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">op</span><span class="si">}</span><span class="s2"> "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> -</span><span id="Generator-1940"><a href="#Generator-1940"><span class="linenos">1940</span></a> -</span><span id="Generator-1941"><a href="#Generator-1941"><span class="linenos">1941</span></a> <span class="k">def</span> <span class="nf">bitwiseand_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1942"><a href="#Generator-1942"><span class="linenos">1942</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"&"</span><span class="p">)</span> -</span><span id="Generator-1943"><a href="#Generator-1943"><span class="linenos">1943</span></a> -</span><span id="Generator-1944"><a href="#Generator-1944"><span class="linenos">1944</span></a> <span class="k">def</span> <span class="nf">bitwiseleftshift_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1945"><a href="#Generator-1945"><span class="linenos">1945</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<<"</span><span class="p">)</span> -</span><span id="Generator-1946"><a href="#Generator-1946"><span class="linenos">1946</span></a> -</span><span id="Generator-1947"><a href="#Generator-1947"><span class="linenos">1947</span></a> <span class="k">def</span> <span class="nf">bitwisenot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1948"><a href="#Generator-1948"><span class="linenos">1948</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"~</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1949"><a href="#Generator-1949"><span class="linenos">1949</span></a> -</span><span id="Generator-1950"><a href="#Generator-1950"><span class="linenos">1950</span></a> <span class="k">def</span> <span class="nf">bitwiseor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1951"><a href="#Generator-1951"><span class="linenos">1951</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"|"</span><span class="p">)</span> -</span><span id="Generator-1952"><a href="#Generator-1952"><span class="linenos">1952</span></a> -</span><span id="Generator-1953"><a href="#Generator-1953"><span class="linenos">1953</span></a> <span class="k">def</span> <span class="nf">bitwiserightshift_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1954"><a href="#Generator-1954"><span class="linenos">1954</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">>"</span><span class="p">)</span> +</span><span id="Generator-1889"><a href="#Generator-1889"><span class="linenos">1889</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">is_global</span><span class="si">}</span><span class="s2"> IN </span><span class="si">{</span><span class="n">in_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1890"><a href="#Generator-1890"><span class="linenos">1890</span></a> +</span><span id="Generator-1891"><a href="#Generator-1891"><span class="linenos">1891</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">unnest</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1892"><a href="#Generator-1892"><span class="linenos">1892</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(SELECT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1893"><a href="#Generator-1893"><span class="linenos">1893</span></a> +</span><span id="Generator-1894"><a href="#Generator-1894"><span class="linenos">1894</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1895"><a href="#Generator-1895"><span class="linenos">1895</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> +</span><span id="Generator-1896"><a href="#Generator-1896"><span class="linenos">1896</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span><span class="p">:</span> +</span><span id="Generator-1897"><a href="#Generator-1897"><span class="linenos">1897</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_PART_SINGULARS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> <span class="n">unit</span><span class="p">)</span> +</span><span id="Generator-1898"><a href="#Generator-1898"><span class="linenos">1898</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1899"><a href="#Generator-1899"><span class="linenos">1899</span></a> +</span><span id="Generator-1900"><a href="#Generator-1900"><span class="linenos">1900</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_STRING_INTERVAL</span><span class="p">:</span> +</span><span id="Generator-1901"><a href="#Generator-1901"><span class="linenos">1901</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1902"><a href="#Generator-1902"><span class="linenos">1902</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL '</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">'"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1903"><a href="#Generator-1903"><span class="linenos">1903</span></a> +</span><span id="Generator-1904"><a href="#Generator-1904"><span class="linenos">1904</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1905"><a href="#Generator-1905"><span class="linenos">1905</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> +</span><span id="Generator-1906"><a href="#Generator-1906"><span class="linenos">1906</span></a> <span class="n">unwrapped</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">)</span> +</span><span id="Generator-1907"><a href="#Generator-1907"><span class="linenos">1907</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unwrapped</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1908"><a href="#Generator-1908"><span class="linenos">1908</span></a> +</span><span id="Generator-1909"><a href="#Generator-1909"><span class="linenos">1909</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1910"><a href="#Generator-1910"><span class="linenos">1910</span></a> +</span><span id="Generator-1911"><a href="#Generator-1911"><span class="linenos">1911</span></a> <span class="k">def</span> <span class="nf">return_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Return</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1912"><a href="#Generator-1912"><span class="linenos">1912</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RETURN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1913"><a href="#Generator-1913"><span class="linenos">1913</span></a> +</span><span id="Generator-1914"><a href="#Generator-1914"><span class="linenos">1914</span></a> <span class="k">def</span> <span class="nf">reference_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Reference</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1915"><a href="#Generator-1915"><span class="linenos">1915</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1916"><a href="#Generator-1916"><span class="linenos">1916</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-1917"><a href="#Generator-1917"><span class="linenos">1917</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1918"><a href="#Generator-1918"><span class="linenos">1918</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator-1919"><a href="#Generator-1919"><span class="linenos">1919</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1920"><a href="#Generator-1920"><span class="linenos">1920</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"REFERENCES </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1921"><a href="#Generator-1921"><span class="linenos">1921</span></a> +</span><span id="Generator-1922"><a href="#Generator-1922"><span class="linenos">1922</span></a> <span class="k">def</span> <span class="nf">anonymous_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Anonymous</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1923"><a href="#Generator-1923"><span class="linenos">1923</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator-1924"><a href="#Generator-1924"><span class="linenos">1924</span></a> +</span><span id="Generator-1925"><a href="#Generator-1925"><span class="linenos">1925</span></a> <span class="k">def</span> <span class="nf">paren_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1926"><a href="#Generator-1926"><span class="linenos">1926</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">unnest</span><span class="p">(),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> +</span><span id="Generator-1927"><a href="#Generator-1927"><span class="linenos">1927</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-1928"><a href="#Generator-1928"><span class="linenos">1928</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-1929"><a href="#Generator-1929"><span class="linenos">1929</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> +</span><span id="Generator-1930"><a href="#Generator-1930"><span class="linenos">1930</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1931"><a href="#Generator-1931"><span class="linenos">1931</span></a> +</span><span id="Generator-1932"><a href="#Generator-1932"><span class="linenos">1932</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="Generator-1933"><a href="#Generator-1933"><span class="linenos">1933</span></a> +</span><span id="Generator-1934"><a href="#Generator-1934"><span class="linenos">1934</span></a> <span class="k">def</span> <span class="nf">neg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Neg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1935"><a href="#Generator-1935"><span class="linenos">1935</span></a> <span class="c1"># This makes sure we don't convert "- - 5" to "--5", which is a comment</span> +</span><span id="Generator-1936"><a href="#Generator-1936"><span class="linenos">1936</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1937"><a href="#Generator-1937"><span class="linenos">1937</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">this_sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"-"</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1938"><a href="#Generator-1938"><span class="linenos">1938</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"-</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1939"><a href="#Generator-1939"><span class="linenos">1939</span></a> +</span><span id="Generator-1940"><a href="#Generator-1940"><span class="linenos">1940</span></a> <span class="k">def</span> <span class="nf">not_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Not</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1941"><a href="#Generator-1941"><span class="linenos">1941</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NOT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1942"><a href="#Generator-1942"><span class="linenos">1942</span></a> +</span><span id="Generator-1943"><a href="#Generator-1943"><span class="linenos">1943</span></a> <span class="k">def</span> <span class="nf">alias_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1944"><a href="#Generator-1944"><span class="linenos">1944</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator-1945"><a href="#Generator-1945"><span class="linenos">1945</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-1946"><a href="#Generator-1946"><span class="linenos">1946</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1947"><a href="#Generator-1947"><span class="linenos">1947</span></a> +</span><span id="Generator-1948"><a href="#Generator-1948"><span class="linenos">1948</span></a> <span class="k">def</span> <span class="nf">aliases_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Aliases</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1949"><a href="#Generator-1949"><span class="linenos">1949</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1950"><a href="#Generator-1950"><span class="linenos">1950</span></a> +</span><span id="Generator-1951"><a href="#Generator-1951"><span class="linenos">1951</span></a> <span class="k">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1952"><a href="#Generator-1952"><span class="linenos">1952</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1953"><a href="#Generator-1953"><span class="linenos">1953</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">)</span> +</span><span id="Generator-1954"><a href="#Generator-1954"><span class="linenos">1954</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> AT TIME ZONE </span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-1955"><a href="#Generator-1955"><span class="linenos">1955</span></a> -</span><span id="Generator-1956"><a href="#Generator-1956"><span class="linenos">1956</span></a> <span class="k">def</span> <span class="nf">bitwisexor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1957"><a href="#Generator-1957"><span class="linenos">1957</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"^"</span><span class="p">)</span> +</span><span id="Generator-1956"><a href="#Generator-1956"><span class="linenos">1956</span></a> <span class="k">def</span> <span class="nf">add_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Add</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1957"><a href="#Generator-1957"><span class="linenos">1957</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">)</span> </span><span id="Generator-1958"><a href="#Generator-1958"><span class="linenos">1958</span></a> -</span><span id="Generator-1959"><a href="#Generator-1959"><span class="linenos">1959</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1960"><a href="#Generator-1960"><span class="linenos">1960</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">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'to'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1959"><a href="#Generator-1959"><span class="linenos">1959</span></a> <span class="k">def</span> <span class="nf">and_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">And</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1960"><a href="#Generator-1960"><span class="linenos">1960</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"AND"</span><span class="p">)</span> </span><span id="Generator-1961"><a href="#Generator-1961"><span class="linenos">1961</span></a> -</span><span id="Generator-1962"><a href="#Generator-1962"><span class="linenos">1962</span></a> <span class="k">def</span> <span class="nf">currentdate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1963"><a href="#Generator-1963"><span class="linenos">1963</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1964"><a href="#Generator-1964"><span class="linenos">1964</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CURRENT_DATE(</span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">zone</span> <span class="k">else</span> <span class="s2">"CURRENT_DATE"</span> +</span><span id="Generator-1962"><a href="#Generator-1962"><span class="linenos">1962</span></a> <span class="k">def</span> <span class="nf">connector_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Connector</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1963"><a href="#Generator-1963"><span class="linenos">1963</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="Generator-1964"><a href="#Generator-1964"><span class="linenos">1964</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">op</span><span class="p">)</span> </span><span id="Generator-1965"><a href="#Generator-1965"><span class="linenos">1965</span></a> -</span><span id="Generator-1966"><a href="#Generator-1966"><span class="linenos">1966</span></a> <span class="k">def</span> <span class="nf">collate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Collate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1967"><a href="#Generator-1967"><span class="linenos">1967</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"COLLATE"</span><span class="p">)</span> -</span><span id="Generator-1968"><a href="#Generator-1968"><span class="linenos">1968</span></a> -</span><span id="Generator-1969"><a href="#Generator-1969"><span class="linenos">1969</span></a> <span class="k">def</span> <span class="nf">command_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1970"><a href="#Generator-1970"><span class="linenos">1970</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s1">'expression'</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1971"><a href="#Generator-1971"><span class="linenos">1971</span></a> -</span><span id="Generator-1972"><a href="#Generator-1972"><span class="linenos">1972</span></a> <span class="k">def</span> <span class="nf">comment_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Comment</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1973"><a href="#Generator-1973"><span class="linenos">1973</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1974"><a href="#Generator-1974"><span class="linenos">1974</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> -</span><span id="Generator-1975"><a href="#Generator-1975"><span class="linenos">1975</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator-1976"><a href="#Generator-1976"><span class="linenos">1976</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator-1977"><a href="#Generator-1977"><span class="linenos">1977</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMENT</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> IS </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1978"><a href="#Generator-1978"><span class="linenos">1978</span></a> -</span><span id="Generator-1979"><a href="#Generator-1979"><span class="linenos">1979</span></a> <span class="k">def</span> <span class="nf">mergetreettlaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTLAction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1980"><a href="#Generator-1980"><span class="linenos">1980</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-1981"><a href="#Generator-1981"><span class="linenos">1981</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="s2">" DELETE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"delete"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1982"><a href="#Generator-1982"><span class="linenos">1982</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"recompress"</span><span class="p">)</span> -</span><span id="Generator-1983"><a href="#Generator-1983"><span class="linenos">1983</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECOMPRESS </span><span class="si">{</span><span class="n">recompress</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">recompress</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1984"><a href="#Generator-1984"><span class="linenos">1984</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_disk"</span><span class="p">)</span> -</span><span id="Generator-1985"><a href="#Generator-1985"><span class="linenos">1985</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO DISK </span><span class="si">{</span><span class="n">to_disk</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_disk</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1986"><a href="#Generator-1986"><span class="linenos">1986</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_volume"</span><span class="p">)</span> -</span><span id="Generator-1987"><a href="#Generator-1987"><span class="linenos">1987</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO VOLUME </span><span class="si">{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_volume</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1988"><a href="#Generator-1988"><span class="linenos">1988</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">recompress</span><span class="si">}{</span><span class="n">to_disk</span><span class="si">}{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-1989"><a href="#Generator-1989"><span class="linenos">1989</span></a> -</span><span id="Generator-1990"><a href="#Generator-1990"><span class="linenos">1990</span></a> <span class="k">def</span> <span class="nf">mergetreettl_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-1991"><a href="#Generator-1991"><span class="linenos">1991</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> -</span><span id="Generator-1992"><a href="#Generator-1992"><span class="linenos">1992</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">)</span> -</span><span id="Generator-1993"><a href="#Generator-1993"><span class="linenos">1993</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"aggregates"</span><span class="p">)</span> -</span><span id="Generator-1994"><a href="#Generator-1994"><span class="linenos">1994</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"SET"</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">aggregates</span><span class="p">)</span> <span class="k">if</span> <span class="n">aggregates</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-1995"><a href="#Generator-1995"><span class="linenos">1995</span></a> -</span><span id="Generator-1996"><a href="#Generator-1996"><span class="linenos">1996</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">where</span> <span class="ow">or</span> <span class="n">group</span> <span class="ow">or</span> <span class="n">aggregates</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Generator-1997"><a href="#Generator-1997"><span class="linenos">1997</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1966"><a href="#Generator-1966"><span class="linenos">1966</span></a> <span class="n">sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> +</span><span id="Generator-1967"><a href="#Generator-1967"><span class="linenos">1967</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> <span class="n">e</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">comments</span> <span class="ow">or</span> <span class="p">[])</span> <span class="k">if</span> <span class="n">i</span> <span class="o">!=</span> <span class="mi">1</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> +</span><span id="Generator-1968"><a href="#Generator-1968"><span class="linenos">1968</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">(</span><span class="n">unnest</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> +</span><span id="Generator-1969"><a href="#Generator-1969"><span class="linenos">1969</span></a> <span class="p">)</span> +</span><span id="Generator-1970"><a href="#Generator-1970"><span class="linenos">1970</span></a> +</span><span id="Generator-1971"><a href="#Generator-1971"><span class="linenos">1971</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator-1972"><a href="#Generator-1972"><span class="linenos">1972</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">op</span><span class="si">}</span><span class="s2"> "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> +</span><span id="Generator-1973"><a href="#Generator-1973"><span class="linenos">1973</span></a> +</span><span id="Generator-1974"><a href="#Generator-1974"><span class="linenos">1974</span></a> <span class="k">def</span> <span class="nf">bitwiseand_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1975"><a href="#Generator-1975"><span class="linenos">1975</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"&"</span><span class="p">)</span> +</span><span id="Generator-1976"><a href="#Generator-1976"><span class="linenos">1976</span></a> +</span><span id="Generator-1977"><a href="#Generator-1977"><span class="linenos">1977</span></a> <span class="k">def</span> <span class="nf">bitwiseleftshift_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1978"><a href="#Generator-1978"><span class="linenos">1978</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<<"</span><span class="p">)</span> +</span><span id="Generator-1979"><a href="#Generator-1979"><span class="linenos">1979</span></a> +</span><span id="Generator-1980"><a href="#Generator-1980"><span class="linenos">1980</span></a> <span class="k">def</span> <span class="nf">bitwisenot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1981"><a href="#Generator-1981"><span class="linenos">1981</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"~</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-1982"><a href="#Generator-1982"><span class="linenos">1982</span></a> +</span><span id="Generator-1983"><a href="#Generator-1983"><span class="linenos">1983</span></a> <span class="k">def</span> <span class="nf">bitwiseor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1984"><a href="#Generator-1984"><span class="linenos">1984</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"|"</span><span class="p">)</span> +</span><span id="Generator-1985"><a href="#Generator-1985"><span class="linenos">1985</span></a> +</span><span id="Generator-1986"><a href="#Generator-1986"><span class="linenos">1986</span></a> <span class="k">def</span> <span class="nf">bitwiserightshift_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1987"><a href="#Generator-1987"><span class="linenos">1987</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">>"</span><span class="p">)</span> +</span><span id="Generator-1988"><a href="#Generator-1988"><span class="linenos">1988</span></a> +</span><span id="Generator-1989"><a href="#Generator-1989"><span class="linenos">1989</span></a> <span class="k">def</span> <span class="nf">bitwisexor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1990"><a href="#Generator-1990"><span class="linenos">1990</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"^"</span><span class="p">)</span> +</span><span id="Generator-1991"><a href="#Generator-1991"><span class="linenos">1991</span></a> +</span><span id="Generator-1992"><a href="#Generator-1992"><span class="linenos">1992</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1993"><a href="#Generator-1993"><span class="linenos">1993</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'to'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-1994"><a href="#Generator-1994"><span class="linenos">1994</span></a> +</span><span id="Generator-1995"><a href="#Generator-1995"><span class="linenos">1995</span></a> <span class="k">def</span> <span class="nf">currentdate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-1996"><a href="#Generator-1996"><span class="linenos">1996</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-1997"><a href="#Generator-1997"><span class="linenos">1997</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CURRENT_DATE(</span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">zone</span> <span class="k">else</span> <span class="s2">"CURRENT_DATE"</span> </span><span id="Generator-1998"><a href="#Generator-1998"><span class="linenos">1998</span></a> -</span><span id="Generator-1999"><a href="#Generator-1999"><span class="linenos">1999</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">))</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">group</span><span class="si">}{</span><span class="n">aggregates</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2000"><a href="#Generator-2000"><span class="linenos">2000</span></a> -</span><span id="Generator-2001"><a href="#Generator-2001"><span class="linenos">2001</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2002"><a href="#Generator-2002"><span class="linenos">2002</span></a> <span class="k">return</span> <span class="s2">"BEGIN"</span> -</span><span id="Generator-2003"><a href="#Generator-2003"><span class="linenos">2003</span></a> -</span><span id="Generator-2004"><a href="#Generator-2004"><span class="linenos">2004</span></a> <span class="k">def</span> <span class="nf">commit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Commit</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2005"><a href="#Generator-2005"><span class="linenos">2005</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"chain"</span><span class="p">)</span> -</span><span id="Generator-2006"><a href="#Generator-2006"><span class="linenos">2006</span></a> <span class="k">if</span> <span class="n">chain</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-2007"><a href="#Generator-2007"><span class="linenos">2007</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="s2">" AND CHAIN"</span> <span class="k">if</span> <span class="n">chain</span> <span class="k">else</span> <span class="s2">" AND NO CHAIN"</span> -</span><span id="Generator-2008"><a href="#Generator-2008"><span class="linenos">2008</span></a> -</span><span id="Generator-2009"><a href="#Generator-2009"><span class="linenos">2009</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMIT</span><span class="si">{</span><span class="n">chain</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2010"><a href="#Generator-2010"><span class="linenos">2010</span></a> -</span><span id="Generator-2011"><a href="#Generator-2011"><span class="linenos">2011</span></a> <span class="k">def</span> <span class="nf">rollback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Rollback</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2012"><a href="#Generator-2012"><span class="linenos">2012</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"savepoint"</span><span class="p">)</span> -</span><span id="Generator-2013"><a href="#Generator-2013"><span class="linenos">2013</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO </span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">savepoint</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2014"><a href="#Generator-2014"><span class="linenos">2014</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROLLBACK</span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2015"><a href="#Generator-2015"><span class="linenos">2015</span></a> -</span><span id="Generator-2016"><a href="#Generator-2016"><span class="linenos">2016</span></a> <span class="k">def</span> <span class="nf">altercolumn_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AlterColumn</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2017"><a href="#Generator-2017"><span class="linenos">2017</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2018"><a href="#Generator-2018"><span class="linenos">2018</span></a> -</span><span id="Generator-2019"><a href="#Generator-2019"><span class="linenos">2019</span></a> <span class="n">dtype</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"dtype"</span><span class="p">)</span> -</span><span id="Generator-2020"><a href="#Generator-2020"><span class="linenos">2020</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="p">:</span> -</span><span id="Generator-2021"><a href="#Generator-2021"><span class="linenos">2021</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collate"</span><span class="p">)</span> -</span><span id="Generator-2022"><a href="#Generator-2022"><span class="linenos">2022</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collate</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2023"><a href="#Generator-2023"><span class="linenos">2023</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> -</span><span id="Generator-2024"><a href="#Generator-2024"><span class="linenos">2024</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2025"><a href="#Generator-2025"><span class="linenos">2025</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> TYPE </span><span class="si">{</span><span class="n">dtype</span><span class="si">}{</span><span class="n">collate</span><span class="si">}{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2026"><a href="#Generator-2026"><span class="linenos">2026</span></a> -</span><span id="Generator-2027"><a href="#Generator-2027"><span class="linenos">2027</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">)</span> -</span><span id="Generator-2028"><a href="#Generator-2028"><span class="linenos">2028</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="Generator-2029"><a href="#Generator-2029"><span class="linenos">2029</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET DEFAULT </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2030"><a href="#Generator-2030"><span class="linenos">2030</span></a> -</span><span id="Generator-2031"><a href="#Generator-2031"><span class="linenos">2031</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"drop"</span><span class="p">):</span> -</span><span id="Generator-2032"><a href="#Generator-2032"><span class="linenos">2032</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Unsupported ALTER COLUMN syntax"</span><span class="p">)</span> +</span><span id="Generator-1999"><a href="#Generator-1999"><span class="linenos">1999</span></a> <span class="k">def</span> <span class="nf">collate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Collate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2000"><a href="#Generator-2000"><span class="linenos">2000</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"COLLATE"</span><span class="p">)</span> +</span><span id="Generator-2001"><a href="#Generator-2001"><span class="linenos">2001</span></a> +</span><span id="Generator-2002"><a href="#Generator-2002"><span class="linenos">2002</span></a> <span class="k">def</span> <span class="nf">command_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2003"><a href="#Generator-2003"><span class="linenos">2003</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s1">'expression'</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2004"><a href="#Generator-2004"><span class="linenos">2004</span></a> +</span><span id="Generator-2005"><a href="#Generator-2005"><span class="linenos">2005</span></a> <span class="k">def</span> <span class="nf">comment_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Comment</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2006"><a href="#Generator-2006"><span class="linenos">2006</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2007"><a href="#Generator-2007"><span class="linenos">2007</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> +</span><span id="Generator-2008"><a href="#Generator-2008"><span class="linenos">2008</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator-2009"><a href="#Generator-2009"><span class="linenos">2009</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator-2010"><a href="#Generator-2010"><span class="linenos">2010</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMENT</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> IS </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2011"><a href="#Generator-2011"><span class="linenos">2011</span></a> +</span><span id="Generator-2012"><a href="#Generator-2012"><span class="linenos">2012</span></a> <span class="k">def</span> <span class="nf">mergetreettlaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTLAction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2013"><a href="#Generator-2013"><span class="linenos">2013</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2014"><a href="#Generator-2014"><span class="linenos">2014</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="s2">" DELETE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"delete"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2015"><a href="#Generator-2015"><span class="linenos">2015</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"recompress"</span><span class="p">)</span> +</span><span id="Generator-2016"><a href="#Generator-2016"><span class="linenos">2016</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECOMPRESS </span><span class="si">{</span><span class="n">recompress</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">recompress</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2017"><a href="#Generator-2017"><span class="linenos">2017</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_disk"</span><span class="p">)</span> +</span><span id="Generator-2018"><a href="#Generator-2018"><span class="linenos">2018</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO DISK </span><span class="si">{</span><span class="n">to_disk</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_disk</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2019"><a href="#Generator-2019"><span class="linenos">2019</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_volume"</span><span class="p">)</span> +</span><span id="Generator-2020"><a href="#Generator-2020"><span class="linenos">2020</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO VOLUME </span><span class="si">{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_volume</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2021"><a href="#Generator-2021"><span class="linenos">2021</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">recompress</span><span class="si">}{</span><span class="n">to_disk</span><span class="si">}{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2022"><a href="#Generator-2022"><span class="linenos">2022</span></a> +</span><span id="Generator-2023"><a href="#Generator-2023"><span class="linenos">2023</span></a> <span class="k">def</span> <span class="nf">mergetreettl_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2024"><a href="#Generator-2024"><span class="linenos">2024</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> +</span><span id="Generator-2025"><a href="#Generator-2025"><span class="linenos">2025</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">)</span> +</span><span id="Generator-2026"><a href="#Generator-2026"><span class="linenos">2026</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"aggregates"</span><span class="p">)</span> +</span><span id="Generator-2027"><a href="#Generator-2027"><span class="linenos">2027</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"SET"</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">aggregates</span><span class="p">)</span> <span class="k">if</span> <span class="n">aggregates</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2028"><a href="#Generator-2028"><span class="linenos">2028</span></a> +</span><span id="Generator-2029"><a href="#Generator-2029"><span class="linenos">2029</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">where</span> <span class="ow">or</span> <span class="n">group</span> <span class="ow">or</span> <span class="n">aggregates</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Generator-2030"><a href="#Generator-2030"><span class="linenos">2030</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2031"><a href="#Generator-2031"><span class="linenos">2031</span></a> +</span><span id="Generator-2032"><a href="#Generator-2032"><span class="linenos">2032</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">))</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">group</span><span class="si">}{</span><span class="n">aggregates</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2033"><a href="#Generator-2033"><span class="linenos">2033</span></a> -</span><span id="Generator-2034"><a href="#Generator-2034"><span class="linenos">2034</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> DROP DEFAULT"</span> -</span><span id="Generator-2035"><a href="#Generator-2035"><span class="linenos">2035</span></a> -</span><span id="Generator-2036"><a href="#Generator-2036"><span class="linenos">2036</span></a> <span class="k">def</span> <span class="nf">renametable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RenameTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2037"><a href="#Generator-2037"><span class="linenos">2037</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">RENAME_TABLE_WITH_DB</span><span class="p">:</span> -</span><span id="Generator-2038"><a href="#Generator-2038"><span class="linenos">2038</span></a> <span class="c1"># Remove db from tables</span> -</span><span id="Generator-2039"><a href="#Generator-2039"><span class="linenos">2039</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> -</span><span id="Generator-2040"><a href="#Generator-2040"><span class="linenos">2040</span></a> <span class="k">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">table_</span><span class="p">(</span><span class="n">n</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="k">else</span> <span class="n">n</span> -</span><span id="Generator-2041"><a href="#Generator-2041"><span class="linenos">2041</span></a> <span class="p">)</span> -</span><span id="Generator-2042"><a href="#Generator-2042"><span class="linenos">2042</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2043"><a href="#Generator-2043"><span class="linenos">2043</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RENAME TO </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2044"><a href="#Generator-2044"><span class="linenos">2044</span></a> -</span><span id="Generator-2045"><a href="#Generator-2045"><span class="linenos">2045</span></a> <span class="k">def</span> <span class="nf">altertable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AlterTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2046"><a href="#Generator-2046"><span class="linenos">2046</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"actions"</span><span class="p">]</span> -</span><span id="Generator-2047"><a href="#Generator-2047"><span class="linenos">2047</span></a> -</span><span id="Generator-2048"><a href="#Generator-2048"><span class="linenos">2048</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">):</span> -</span><span id="Generator-2049"><a href="#Generator-2049"><span class="linenos">2049</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMN "</span><span class="p">)</span> -</span><span id="Generator-2050"><a href="#Generator-2050"><span class="linenos">2050</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">):</span> -</span><span id="Generator-2051"><a href="#Generator-2051"><span class="linenos">2051</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMNS "</span><span class="p">)</span> -</span><span id="Generator-2052"><a href="#Generator-2052"><span class="linenos">2052</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">):</span> -</span><span id="Generator-2053"><a href="#Generator-2053"><span class="linenos">2053</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-2054"><a href="#Generator-2054"><span class="linenos">2054</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2055"><a href="#Generator-2055"><span class="linenos">2055</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">)</span> -</span><span id="Generator-2056"><a href="#Generator-2056"><span class="linenos">2056</span></a> -</span><span id="Generator-2057"><a href="#Generator-2057"><span class="linenos">2057</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2058"><a href="#Generator-2058"><span class="linenos">2058</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER TABLE</span><span class="si">{</span><span class="n">exists</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">actions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2034"><a href="#Generator-2034"><span class="linenos">2034</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2035"><a href="#Generator-2035"><span class="linenos">2035</span></a> <span class="k">return</span> <span class="s2">"BEGIN"</span> +</span><span id="Generator-2036"><a href="#Generator-2036"><span class="linenos">2036</span></a> +</span><span id="Generator-2037"><a href="#Generator-2037"><span class="linenos">2037</span></a> <span class="k">def</span> <span class="nf">commit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Commit</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2038"><a href="#Generator-2038"><span class="linenos">2038</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"chain"</span><span class="p">)</span> +</span><span id="Generator-2039"><a href="#Generator-2039"><span class="linenos">2039</span></a> <span class="k">if</span> <span class="n">chain</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-2040"><a href="#Generator-2040"><span class="linenos">2040</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="s2">" AND CHAIN"</span> <span class="k">if</span> <span class="n">chain</span> <span class="k">else</span> <span class="s2">" AND NO CHAIN"</span> +</span><span id="Generator-2041"><a href="#Generator-2041"><span class="linenos">2041</span></a> +</span><span id="Generator-2042"><a href="#Generator-2042"><span class="linenos">2042</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMIT</span><span class="si">{</span><span class="n">chain</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2043"><a href="#Generator-2043"><span class="linenos">2043</span></a> +</span><span id="Generator-2044"><a href="#Generator-2044"><span class="linenos">2044</span></a> <span class="k">def</span> <span class="nf">rollback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Rollback</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2045"><a href="#Generator-2045"><span class="linenos">2045</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"savepoint"</span><span class="p">)</span> +</span><span id="Generator-2046"><a href="#Generator-2046"><span class="linenos">2046</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO </span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">savepoint</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2047"><a href="#Generator-2047"><span class="linenos">2047</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROLLBACK</span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2048"><a href="#Generator-2048"><span class="linenos">2048</span></a> +</span><span id="Generator-2049"><a href="#Generator-2049"><span class="linenos">2049</span></a> <span class="k">def</span> <span class="nf">altercolumn_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AlterColumn</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2050"><a href="#Generator-2050"><span class="linenos">2050</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2051"><a href="#Generator-2051"><span class="linenos">2051</span></a> +</span><span id="Generator-2052"><a href="#Generator-2052"><span class="linenos">2052</span></a> <span class="n">dtype</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"dtype"</span><span class="p">)</span> +</span><span id="Generator-2053"><a href="#Generator-2053"><span class="linenos">2053</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="p">:</span> +</span><span id="Generator-2054"><a href="#Generator-2054"><span class="linenos">2054</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collate"</span><span class="p">)</span> +</span><span id="Generator-2055"><a href="#Generator-2055"><span class="linenos">2055</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collate</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2056"><a href="#Generator-2056"><span class="linenos">2056</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> +</span><span id="Generator-2057"><a href="#Generator-2057"><span class="linenos">2057</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2058"><a href="#Generator-2058"><span class="linenos">2058</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> TYPE </span><span class="si">{</span><span class="n">dtype</span><span class="si">}{</span><span class="n">collate</span><span class="si">}{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2059"><a href="#Generator-2059"><span class="linenos">2059</span></a> -</span><span id="Generator-2060"><a href="#Generator-2060"><span class="linenos">2060</span></a> <span class="k">def</span> <span class="nf">droppartition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DropPartition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2061"><a href="#Generator-2061"><span class="linenos">2061</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-2062"><a href="#Generator-2062"><span class="linenos">2062</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator-2063"><a href="#Generator-2063"><span class="linenos">2063</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2064"><a href="#Generator-2064"><span class="linenos">2064</span></a> -</span><span id="Generator-2065"><a href="#Generator-2065"><span class="linenos">2065</span></a> <span class="k">def</span> <span class="nf">addconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AddConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2066"><a href="#Generator-2066"><span class="linenos">2066</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2067"><a href="#Generator-2067"><span class="linenos">2067</span></a> <span class="n">expression_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator-2068"><a href="#Generator-2068"><span class="linenos">2068</span></a> <span class="n">add_constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ADD CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">"ADD"</span> -</span><span id="Generator-2069"><a href="#Generator-2069"><span class="linenos">2069</span></a> -</span><span id="Generator-2070"><a href="#Generator-2070"><span class="linenos">2070</span></a> <span class="n">enforced</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"enforced"</span><span class="p">)</span> -</span><span id="Generator-2071"><a href="#Generator-2071"><span class="linenos">2071</span></a> <span class="k">if</span> <span class="n">enforced</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-2072"><a href="#Generator-2072"><span class="linenos">2072</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> CHECK (</span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="s1">' ENFORCED'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">enforced</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2073"><a href="#Generator-2073"><span class="linenos">2073</span></a> -</span><span id="Generator-2074"><a href="#Generator-2074"><span class="linenos">2074</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2075"><a href="#Generator-2075"><span class="linenos">2075</span></a> -</span><span id="Generator-2076"><a href="#Generator-2076"><span class="linenos">2076</span></a> <span class="k">def</span> <span class="nf">distinct_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distinct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2077"><a href="#Generator-2077"><span class="linenos">2077</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-2078"><a href="#Generator-2078"><span class="linenos">2078</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2079"><a href="#Generator-2079"><span class="linenos">2079</span></a> -</span><span id="Generator-2080"><a href="#Generator-2080"><span class="linenos">2080</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">)</span> -</span><span id="Generator-2081"><a href="#Generator-2081"><span class="linenos">2081</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">on</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2082"><a href="#Generator-2082"><span class="linenos">2082</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DISTINCT</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2083"><a href="#Generator-2083"><span class="linenos">2083</span></a> -</span><span id="Generator-2084"><a href="#Generator-2084"><span class="linenos">2084</span></a> <span class="k">def</span> <span class="nf">ignorenulls_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IgnoreNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2085"><a href="#Generator-2085"><span class="linenos">2085</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> IGNORE NULLS"</span> -</span><span id="Generator-2086"><a href="#Generator-2086"><span class="linenos">2086</span></a> -</span><span id="Generator-2087"><a href="#Generator-2087"><span class="linenos">2087</span></a> <span class="k">def</span> <span class="nf">respectnulls_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RespectNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2088"><a href="#Generator-2088"><span class="linenos">2088</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> RESPECT NULLS"</span> +</span><span id="Generator-2060"><a href="#Generator-2060"><span class="linenos">2060</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">)</span> +</span><span id="Generator-2061"><a href="#Generator-2061"><span class="linenos">2061</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> +</span><span id="Generator-2062"><a href="#Generator-2062"><span class="linenos">2062</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET DEFAULT </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2063"><a href="#Generator-2063"><span class="linenos">2063</span></a> +</span><span id="Generator-2064"><a href="#Generator-2064"><span class="linenos">2064</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"drop"</span><span class="p">):</span> +</span><span id="Generator-2065"><a href="#Generator-2065"><span class="linenos">2065</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Unsupported ALTER COLUMN syntax"</span><span class="p">)</span> +</span><span id="Generator-2066"><a href="#Generator-2066"><span class="linenos">2066</span></a> +</span><span id="Generator-2067"><a href="#Generator-2067"><span class="linenos">2067</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> DROP DEFAULT"</span> +</span><span id="Generator-2068"><a href="#Generator-2068"><span class="linenos">2068</span></a> +</span><span id="Generator-2069"><a href="#Generator-2069"><span class="linenos">2069</span></a> <span class="k">def</span> <span class="nf">renametable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RenameTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2070"><a href="#Generator-2070"><span class="linenos">2070</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">RENAME_TABLE_WITH_DB</span><span class="p">:</span> +</span><span id="Generator-2071"><a href="#Generator-2071"><span class="linenos">2071</span></a> <span class="c1"># Remove db from tables</span> +</span><span id="Generator-2072"><a href="#Generator-2072"><span class="linenos">2072</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> +</span><span id="Generator-2073"><a href="#Generator-2073"><span class="linenos">2073</span></a> <span class="k">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">table_</span><span class="p">(</span><span class="n">n</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="k">else</span> <span class="n">n</span> +</span><span id="Generator-2074"><a href="#Generator-2074"><span class="linenos">2074</span></a> <span class="p">)</span> +</span><span id="Generator-2075"><a href="#Generator-2075"><span class="linenos">2075</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2076"><a href="#Generator-2076"><span class="linenos">2076</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RENAME TO </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2077"><a href="#Generator-2077"><span class="linenos">2077</span></a> +</span><span id="Generator-2078"><a href="#Generator-2078"><span class="linenos">2078</span></a> <span class="k">def</span> <span class="nf">altertable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AlterTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2079"><a href="#Generator-2079"><span class="linenos">2079</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"actions"</span><span class="p">]</span> +</span><span id="Generator-2080"><a href="#Generator-2080"><span class="linenos">2080</span></a> +</span><span id="Generator-2081"><a href="#Generator-2081"><span class="linenos">2081</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">):</span> +</span><span id="Generator-2082"><a href="#Generator-2082"><span class="linenos">2082</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMN "</span><span class="p">)</span> +</span><span id="Generator-2083"><a href="#Generator-2083"><span class="linenos">2083</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">):</span> +</span><span id="Generator-2084"><a href="#Generator-2084"><span class="linenos">2084</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMNS "</span><span class="p">)</span> +</span><span id="Generator-2085"><a href="#Generator-2085"><span class="linenos">2085</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">):</span> +</span><span id="Generator-2086"><a href="#Generator-2086"><span class="linenos">2086</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-2087"><a href="#Generator-2087"><span class="linenos">2087</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2088"><a href="#Generator-2088"><span class="linenos">2088</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">)</span> </span><span id="Generator-2089"><a href="#Generator-2089"><span class="linenos">2089</span></a> -</span><span id="Generator-2090"><a href="#Generator-2090"><span class="linenos">2090</span></a> <span class="k">def</span> <span class="nf">intdiv_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2091"><a href="#Generator-2091"><span class="linenos">2091</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="Generator-2092"><a href="#Generator-2092"><span class="linenos">2092</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">(</span> -</span><span id="Generator-2093"><a href="#Generator-2093"><span class="linenos">2093</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">),</span> -</span><span id="Generator-2094"><a href="#Generator-2094"><span class="linenos">2094</span></a> <span class="n">to</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">),</span> -</span><span id="Generator-2095"><a href="#Generator-2095"><span class="linenos">2095</span></a> <span class="p">)</span> -</span><span id="Generator-2096"><a href="#Generator-2096"><span class="linenos">2096</span></a> <span class="p">)</span> +</span><span id="Generator-2090"><a href="#Generator-2090"><span class="linenos">2090</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2091"><a href="#Generator-2091"><span class="linenos">2091</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER TABLE</span><span class="si">{</span><span class="n">exists</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">actions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2092"><a href="#Generator-2092"><span class="linenos">2092</span></a> +</span><span id="Generator-2093"><a href="#Generator-2093"><span class="linenos">2093</span></a> <span class="k">def</span> <span class="nf">droppartition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DropPartition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2094"><a href="#Generator-2094"><span class="linenos">2094</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-2095"><a href="#Generator-2095"><span class="linenos">2095</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator-2096"><a href="#Generator-2096"><span class="linenos">2096</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2097"><a href="#Generator-2097"><span class="linenos">2097</span></a> -</span><span id="Generator-2098"><a href="#Generator-2098"><span class="linenos">2098</span></a> <span class="k">def</span> <span class="nf">dpipe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2099"><a href="#Generator-2099"><span class="linenos">2099</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"||"</span><span class="p">)</span> -</span><span id="Generator-2100"><a href="#Generator-2100"><span class="linenos">2100</span></a> -</span><span id="Generator-2101"><a href="#Generator-2101"><span class="linenos">2101</span></a> <span class="k">def</span> <span class="nf">safedpipe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2102"><a href="#Generator-2102"><span class="linenos">2102</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> -</span><span id="Generator-2103"><a href="#Generator-2103"><span class="linenos">2103</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">,</span> <span class="o">*</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">()))</span> -</span><span id="Generator-2104"><a href="#Generator-2104"><span class="linenos">2104</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">dpipe_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-2105"><a href="#Generator-2105"><span class="linenos">2105</span></a> -</span><span id="Generator-2106"><a href="#Generator-2106"><span class="linenos">2106</span></a> <span class="k">def</span> <span class="nf">div_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2107"><a href="#Generator-2107"><span class="linenos">2107</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"/"</span><span class="p">)</span> +</span><span id="Generator-2098"><a href="#Generator-2098"><span class="linenos">2098</span></a> <span class="k">def</span> <span class="nf">addconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AddConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2099"><a href="#Generator-2099"><span class="linenos">2099</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2100"><a href="#Generator-2100"><span class="linenos">2100</span></a> <span class="n">expression_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator-2101"><a href="#Generator-2101"><span class="linenos">2101</span></a> <span class="n">add_constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ADD CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">"ADD"</span> +</span><span id="Generator-2102"><a href="#Generator-2102"><span class="linenos">2102</span></a> +</span><span id="Generator-2103"><a href="#Generator-2103"><span class="linenos">2103</span></a> <span class="n">enforced</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"enforced"</span><span class="p">)</span> +</span><span id="Generator-2104"><a href="#Generator-2104"><span class="linenos">2104</span></a> <span class="k">if</span> <span class="n">enforced</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-2105"><a href="#Generator-2105"><span class="linenos">2105</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> CHECK (</span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="s1">' ENFORCED'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">enforced</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2106"><a href="#Generator-2106"><span class="linenos">2106</span></a> +</span><span id="Generator-2107"><a href="#Generator-2107"><span class="linenos">2107</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2108"><a href="#Generator-2108"><span class="linenos">2108</span></a> -</span><span id="Generator-2109"><a href="#Generator-2109"><span class="linenos">2109</span></a> <span class="k">def</span> <span class="nf">overlaps_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Overlaps</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2110"><a href="#Generator-2110"><span class="linenos">2110</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OVERLAPS"</span><span class="p">)</span> -</span><span id="Generator-2111"><a href="#Generator-2111"><span class="linenos">2111</span></a> -</span><span id="Generator-2112"><a href="#Generator-2112"><span class="linenos">2112</span></a> <span class="k">def</span> <span class="nf">distance_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distance</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2113"><a href="#Generator-2113"><span class="linenos">2113</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<->"</span><span class="p">)</span> -</span><span id="Generator-2114"><a href="#Generator-2114"><span class="linenos">2114</span></a> -</span><span id="Generator-2115"><a href="#Generator-2115"><span class="linenos">2115</span></a> <span class="k">def</span> <span class="nf">dot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2116"><a href="#Generator-2116"><span class="linenos">2116</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2117"><a href="#Generator-2117"><span class="linenos">2117</span></a> -</span><span id="Generator-2118"><a href="#Generator-2118"><span class="linenos">2118</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2119"><a href="#Generator-2119"><span class="linenos">2119</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> -</span><span id="Generator-2120"><a href="#Generator-2120"><span class="linenos">2120</span></a> -</span><span id="Generator-2121"><a href="#Generator-2121"><span class="linenos">2121</span></a> <span class="k">def</span> <span class="nf">escape_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Escape</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2122"><a href="#Generator-2122"><span class="linenos">2122</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ESCAPE"</span><span class="p">)</span> -</span><span id="Generator-2123"><a href="#Generator-2123"><span class="linenos">2123</span></a> -</span><span id="Generator-2124"><a href="#Generator-2124"><span class="linenos">2124</span></a> <span class="k">def</span> <span class="nf">glob_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Glob</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2125"><a href="#Generator-2125"><span class="linenos">2125</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"GLOB"</span><span class="p">)</span> -</span><span id="Generator-2126"><a href="#Generator-2126"><span class="linenos">2126</span></a> -</span><span id="Generator-2127"><a href="#Generator-2127"><span class="linenos">2127</span></a> <span class="k">def</span> <span class="nf">gt_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2128"><a href="#Generator-2128"><span class="linenos">2128</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">"</span><span class="p">)</span> -</span><span id="Generator-2129"><a href="#Generator-2129"><span class="linenos">2129</span></a> -</span><span id="Generator-2130"><a href="#Generator-2130"><span class="linenos">2130</span></a> <span class="k">def</span> <span class="nf">gte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2131"><a href="#Generator-2131"><span class="linenos">2131</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">="</span><span class="p">)</span> -</span><span id="Generator-2132"><a href="#Generator-2132"><span class="linenos">2132</span></a> -</span><span id="Generator-2133"><a href="#Generator-2133"><span class="linenos">2133</span></a> <span class="k">def</span> <span class="nf">ilike_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2134"><a href="#Generator-2134"><span class="linenos">2134</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE"</span><span class="p">)</span> -</span><span id="Generator-2135"><a href="#Generator-2135"><span class="linenos">2135</span></a> -</span><span id="Generator-2136"><a href="#Generator-2136"><span class="linenos">2136</span></a> <span class="k">def</span> <span class="nf">ilikeany_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2137"><a href="#Generator-2137"><span class="linenos">2137</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE ANY"</span><span class="p">)</span> +</span><span id="Generator-2109"><a href="#Generator-2109"><span class="linenos">2109</span></a> <span class="k">def</span> <span class="nf">distinct_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distinct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2110"><a href="#Generator-2110"><span class="linenos">2110</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-2111"><a href="#Generator-2111"><span class="linenos">2111</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2112"><a href="#Generator-2112"><span class="linenos">2112</span></a> +</span><span id="Generator-2113"><a href="#Generator-2113"><span class="linenos">2113</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">)</span> +</span><span id="Generator-2114"><a href="#Generator-2114"><span class="linenos">2114</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">on</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2115"><a href="#Generator-2115"><span class="linenos">2115</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DISTINCT</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2116"><a href="#Generator-2116"><span class="linenos">2116</span></a> +</span><span id="Generator-2117"><a href="#Generator-2117"><span class="linenos">2117</span></a> <span class="k">def</span> <span class="nf">ignorenulls_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IgnoreNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2118"><a href="#Generator-2118"><span class="linenos">2118</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> IGNORE NULLS"</span> +</span><span id="Generator-2119"><a href="#Generator-2119"><span class="linenos">2119</span></a> +</span><span id="Generator-2120"><a href="#Generator-2120"><span class="linenos">2120</span></a> <span class="k">def</span> <span class="nf">respectnulls_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RespectNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2121"><a href="#Generator-2121"><span class="linenos">2121</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> RESPECT NULLS"</span> +</span><span id="Generator-2122"><a href="#Generator-2122"><span class="linenos">2122</span></a> +</span><span id="Generator-2123"><a href="#Generator-2123"><span class="linenos">2123</span></a> <span class="k">def</span> <span class="nf">intdiv_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2124"><a href="#Generator-2124"><span class="linenos">2124</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="Generator-2125"><a href="#Generator-2125"><span class="linenos">2125</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">(</span> +</span><span id="Generator-2126"><a href="#Generator-2126"><span class="linenos">2126</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">),</span> +</span><span id="Generator-2127"><a href="#Generator-2127"><span class="linenos">2127</span></a> <span class="n">to</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">),</span> +</span><span id="Generator-2128"><a href="#Generator-2128"><span class="linenos">2128</span></a> <span class="p">)</span> +</span><span id="Generator-2129"><a href="#Generator-2129"><span class="linenos">2129</span></a> <span class="p">)</span> +</span><span id="Generator-2130"><a href="#Generator-2130"><span class="linenos">2130</span></a> +</span><span id="Generator-2131"><a href="#Generator-2131"><span class="linenos">2131</span></a> <span class="k">def</span> <span class="nf">dpipe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2132"><a href="#Generator-2132"><span class="linenos">2132</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"||"</span><span class="p">)</span> +</span><span id="Generator-2133"><a href="#Generator-2133"><span class="linenos">2133</span></a> +</span><span id="Generator-2134"><a href="#Generator-2134"><span class="linenos">2134</span></a> <span class="k">def</span> <span class="nf">safedpipe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2135"><a href="#Generator-2135"><span class="linenos">2135</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> +</span><span id="Generator-2136"><a href="#Generator-2136"><span class="linenos">2136</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">,</span> <span class="o">*</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">()))</span> +</span><span id="Generator-2137"><a href="#Generator-2137"><span class="linenos">2137</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">dpipe_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span><span id="Generator-2138"><a href="#Generator-2138"><span class="linenos">2138</span></a> -</span><span id="Generator-2139"><a href="#Generator-2139"><span class="linenos">2139</span></a> <span class="k">def</span> <span class="nf">is_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2140"><a href="#Generator-2140"><span class="linenos">2140</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">IS_BOOL_ALLOWED</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Boolean</span><span class="p">):</span> -</span><span id="Generator-2141"><a href="#Generator-2141"><span class="linenos">2141</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="Generator-2142"><a href="#Generator-2142"><span class="linenos">2142</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">not_</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="Generator-2143"><a href="#Generator-2143"><span class="linenos">2143</span></a> <span class="p">)</span> -</span><span id="Generator-2144"><a href="#Generator-2144"><span class="linenos">2144</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS"</span><span class="p">)</span> -</span><span id="Generator-2145"><a href="#Generator-2145"><span class="linenos">2145</span></a> -</span><span id="Generator-2146"><a href="#Generator-2146"><span class="linenos">2146</span></a> <span class="k">def</span> <span class="nf">like_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Like</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2147"><a href="#Generator-2147"><span class="linenos">2147</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE"</span><span class="p">)</span> -</span><span id="Generator-2148"><a href="#Generator-2148"><span class="linenos">2148</span></a> -</span><span id="Generator-2149"><a href="#Generator-2149"><span class="linenos">2149</span></a> <span class="k">def</span> <span class="nf">likeany_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2150"><a href="#Generator-2150"><span class="linenos">2150</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE ANY"</span><span class="p">)</span> -</span><span id="Generator-2151"><a href="#Generator-2151"><span class="linenos">2151</span></a> -</span><span id="Generator-2152"><a href="#Generator-2152"><span class="linenos">2152</span></a> <span class="k">def</span> <span class="nf">similarto_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SimilarTo</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2153"><a href="#Generator-2153"><span class="linenos">2153</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"SIMILAR TO"</span><span class="p">)</span> -</span><span id="Generator-2154"><a href="#Generator-2154"><span class="linenos">2154</span></a> -</span><span id="Generator-2155"><a href="#Generator-2155"><span class="linenos">2155</span></a> <span class="k">def</span> <span class="nf">lt_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2156"><a href="#Generator-2156"><span class="linenos">2156</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<"</span><span class="p">)</span> -</span><span id="Generator-2157"><a href="#Generator-2157"><span class="linenos">2157</span></a> -</span><span id="Generator-2158"><a href="#Generator-2158"><span class="linenos">2158</span></a> <span class="k">def</span> <span class="nf">lte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2159"><a href="#Generator-2159"><span class="linenos">2159</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<="</span><span class="p">)</span> -</span><span id="Generator-2160"><a href="#Generator-2160"><span class="linenos">2160</span></a> -</span><span id="Generator-2161"><a href="#Generator-2161"><span class="linenos">2161</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2162"><a href="#Generator-2162"><span class="linenos">2162</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"%"</span><span class="p">)</span> -</span><span id="Generator-2163"><a href="#Generator-2163"><span class="linenos">2163</span></a> -</span><span id="Generator-2164"><a href="#Generator-2164"><span class="linenos">2164</span></a> <span class="k">def</span> <span class="nf">mul_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mul</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2165"><a href="#Generator-2165"><span class="linenos">2165</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"*"</span><span class="p">)</span> -</span><span id="Generator-2166"><a href="#Generator-2166"><span class="linenos">2166</span></a> -</span><span id="Generator-2167"><a href="#Generator-2167"><span class="linenos">2167</span></a> <span class="k">def</span> <span class="nf">neq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2168"><a href="#Generator-2168"><span class="linenos">2168</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<>"</span><span class="p">)</span> -</span><span id="Generator-2169"><a href="#Generator-2169"><span class="linenos">2169</span></a> -</span><span id="Generator-2170"><a href="#Generator-2170"><span class="linenos">2170</span></a> <span class="k">def</span> <span class="nf">nullsafeeq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2171"><a href="#Generator-2171"><span class="linenos">2171</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS NOT DISTINCT FROM"</span><span class="p">)</span> -</span><span id="Generator-2172"><a href="#Generator-2172"><span class="linenos">2172</span></a> -</span><span id="Generator-2173"><a href="#Generator-2173"><span class="linenos">2173</span></a> <span class="k">def</span> <span class="nf">nullsafeneq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeNEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2174"><a href="#Generator-2174"><span class="linenos">2174</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS DISTINCT FROM"</span><span class="p">)</span> -</span><span id="Generator-2175"><a href="#Generator-2175"><span class="linenos">2175</span></a> -</span><span id="Generator-2176"><a href="#Generator-2176"><span class="linenos">2176</span></a> <span class="k">def</span> <span class="nf">or_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Or</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2177"><a href="#Generator-2177"><span class="linenos">2177</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OR"</span><span class="p">)</span> +</span><span id="Generator-2139"><a href="#Generator-2139"><span class="linenos">2139</span></a> <span class="k">def</span> <span class="nf">div_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2140"><a href="#Generator-2140"><span class="linenos">2140</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"/"</span><span class="p">)</span> +</span><span id="Generator-2141"><a href="#Generator-2141"><span class="linenos">2141</span></a> +</span><span id="Generator-2142"><a href="#Generator-2142"><span class="linenos">2142</span></a> <span class="k">def</span> <span class="nf">overlaps_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Overlaps</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2143"><a href="#Generator-2143"><span class="linenos">2143</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OVERLAPS"</span><span class="p">)</span> +</span><span id="Generator-2144"><a href="#Generator-2144"><span class="linenos">2144</span></a> +</span><span id="Generator-2145"><a href="#Generator-2145"><span class="linenos">2145</span></a> <span class="k">def</span> <span class="nf">distance_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distance</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2146"><a href="#Generator-2146"><span class="linenos">2146</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<->"</span><span class="p">)</span> +</span><span id="Generator-2147"><a href="#Generator-2147"><span class="linenos">2147</span></a> +</span><span id="Generator-2148"><a href="#Generator-2148"><span class="linenos">2148</span></a> <span class="k">def</span> <span class="nf">dot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2149"><a href="#Generator-2149"><span class="linenos">2149</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2150"><a href="#Generator-2150"><span class="linenos">2150</span></a> +</span><span id="Generator-2151"><a href="#Generator-2151"><span class="linenos">2151</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2152"><a href="#Generator-2152"><span class="linenos">2152</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> +</span><span id="Generator-2153"><a href="#Generator-2153"><span class="linenos">2153</span></a> +</span><span id="Generator-2154"><a href="#Generator-2154"><span class="linenos">2154</span></a> <span class="k">def</span> <span class="nf">escape_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Escape</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2155"><a href="#Generator-2155"><span class="linenos">2155</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ESCAPE"</span><span class="p">)</span> +</span><span id="Generator-2156"><a href="#Generator-2156"><span class="linenos">2156</span></a> +</span><span id="Generator-2157"><a href="#Generator-2157"><span class="linenos">2157</span></a> <span class="k">def</span> <span class="nf">glob_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Glob</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2158"><a href="#Generator-2158"><span class="linenos">2158</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"GLOB"</span><span class="p">)</span> +</span><span id="Generator-2159"><a href="#Generator-2159"><span class="linenos">2159</span></a> +</span><span id="Generator-2160"><a href="#Generator-2160"><span class="linenos">2160</span></a> <span class="k">def</span> <span class="nf">gt_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2161"><a href="#Generator-2161"><span class="linenos">2161</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">"</span><span class="p">)</span> +</span><span id="Generator-2162"><a href="#Generator-2162"><span class="linenos">2162</span></a> +</span><span id="Generator-2163"><a href="#Generator-2163"><span class="linenos">2163</span></a> <span class="k">def</span> <span class="nf">gte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2164"><a href="#Generator-2164"><span class="linenos">2164</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">="</span><span class="p">)</span> +</span><span id="Generator-2165"><a href="#Generator-2165"><span class="linenos">2165</span></a> +</span><span id="Generator-2166"><a href="#Generator-2166"><span class="linenos">2166</span></a> <span class="k">def</span> <span class="nf">ilike_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2167"><a href="#Generator-2167"><span class="linenos">2167</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE"</span><span class="p">)</span> +</span><span id="Generator-2168"><a href="#Generator-2168"><span class="linenos">2168</span></a> +</span><span id="Generator-2169"><a href="#Generator-2169"><span class="linenos">2169</span></a> <span class="k">def</span> <span class="nf">ilikeany_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2170"><a href="#Generator-2170"><span class="linenos">2170</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE ANY"</span><span class="p">)</span> +</span><span id="Generator-2171"><a href="#Generator-2171"><span class="linenos">2171</span></a> +</span><span id="Generator-2172"><a href="#Generator-2172"><span class="linenos">2172</span></a> <span class="k">def</span> <span class="nf">is_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2173"><a href="#Generator-2173"><span class="linenos">2173</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">IS_BOOL_ALLOWED</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Boolean</span><span class="p">):</span> +</span><span id="Generator-2174"><a href="#Generator-2174"><span class="linenos">2174</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="Generator-2175"><a href="#Generator-2175"><span class="linenos">2175</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">not_</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="Generator-2176"><a href="#Generator-2176"><span class="linenos">2176</span></a> <span class="p">)</span> +</span><span id="Generator-2177"><a href="#Generator-2177"><span class="linenos">2177</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS"</span><span class="p">)</span> </span><span id="Generator-2178"><a href="#Generator-2178"><span class="linenos">2178</span></a> -</span><span id="Generator-2179"><a href="#Generator-2179"><span class="linenos">2179</span></a> <span class="k">def</span> <span class="nf">slice_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Slice</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2180"><a href="#Generator-2180"><span class="linenos">2180</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">":"</span><span class="p">)</span> +</span><span id="Generator-2179"><a href="#Generator-2179"><span class="linenos">2179</span></a> <span class="k">def</span> <span class="nf">like_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Like</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2180"><a href="#Generator-2180"><span class="linenos">2180</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE"</span><span class="p">)</span> </span><span id="Generator-2181"><a href="#Generator-2181"><span class="linenos">2181</span></a> -</span><span id="Generator-2182"><a href="#Generator-2182"><span class="linenos">2182</span></a> <span class="k">def</span> <span class="nf">sub_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Sub</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2183"><a href="#Generator-2183"><span class="linenos">2183</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)</span> +</span><span id="Generator-2182"><a href="#Generator-2182"><span class="linenos">2182</span></a> <span class="k">def</span> <span class="nf">likeany_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2183"><a href="#Generator-2183"><span class="linenos">2183</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE ANY"</span><span class="p">)</span> </span><span id="Generator-2184"><a href="#Generator-2184"><span class="linenos">2184</span></a> -</span><span id="Generator-2185"><a href="#Generator-2185"><span class="linenos">2185</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2186"><a href="#Generator-2186"><span class="linenos">2186</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TRY_CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'to'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2185"><a href="#Generator-2185"><span class="linenos">2185</span></a> <span class="k">def</span> <span class="nf">similarto_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SimilarTo</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2186"><a href="#Generator-2186"><span class="linenos">2186</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"SIMILAR TO"</span><span class="p">)</span> </span><span id="Generator-2187"><a href="#Generator-2187"><span class="linenos">2187</span></a> -</span><span id="Generator-2188"><a href="#Generator-2188"><span class="linenos">2188</span></a> <span class="k">def</span> <span class="nf">use_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Use</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2189"><a href="#Generator-2189"><span class="linenos">2189</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator-2190"><a href="#Generator-2190"><span class="linenos">2190</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2191"><a href="#Generator-2191"><span class="linenos">2191</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2192"><a href="#Generator-2192"><span class="linenos">2192</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2193"><a href="#Generator-2193"><span class="linenos">2193</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"USE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2194"><a href="#Generator-2194"><span class="linenos">2194</span></a> -</span><span id="Generator-2195"><a href="#Generator-2195"><span class="linenos">2195</span></a> <span class="k">def</span> <span class="nf">binary</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Binary</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2196"><a href="#Generator-2196"><span class="linenos">2196</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">op</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> -</span><span id="Generator-2197"><a href="#Generator-2197"><span class="linenos">2197</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2198"><a href="#Generator-2198"><span class="linenos">2198</span></a> -</span><span id="Generator-2199"><a href="#Generator-2199"><span class="linenos">2199</span></a> <span class="k">def</span> <span class="nf">function_fallback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2200"><a href="#Generator-2200"><span class="linenos">2200</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator-2201"><a href="#Generator-2201"><span class="linenos">2201</span></a> <span class="k">for</span> <span class="n">arg_value</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> -</span><span id="Generator-2202"><a href="#Generator-2202"><span class="linenos">2202</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">arg_value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="Generator-2203"><a href="#Generator-2203"><span class="linenos">2203</span></a> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">arg_value</span><span class="p">:</span> -</span><span id="Generator-2204"><a href="#Generator-2204"><span class="linenos">2204</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="Generator-2205"><a href="#Generator-2205"><span class="linenos">2205</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2206"><a href="#Generator-2206"><span class="linenos">2206</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">arg_value</span><span class="p">)</span> -</span><span id="Generator-2207"><a href="#Generator-2207"><span class="linenos">2207</span></a> -</span><span id="Generator-2208"><a href="#Generator-2208"><span class="linenos">2208</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">sql_name</span><span class="p">(),</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> -</span><span id="Generator-2209"><a href="#Generator-2209"><span class="linenos">2209</span></a> -</span><span id="Generator-2210"><a href="#Generator-2210"><span class="linenos">2210</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span> -</span><span id="Generator-2211"><a href="#Generator-2211"><span class="linenos">2211</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator-2212"><a href="#Generator-2212"><span class="linenos">2212</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="Generator-2213"><a href="#Generator-2213"><span class="linenos">2213</span></a> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">|</span> <span class="nb">str</span><span class="p">],</span> -</span><span id="Generator-2214"><a href="#Generator-2214"><span class="linenos">2214</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"("</span><span class="p">,</span> -</span><span id="Generator-2215"><a href="#Generator-2215"><span class="linenos">2215</span></a> <span class="n">suffix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">")"</span><span class="p">,</span> -</span><span id="Generator-2216"><a href="#Generator-2216"><span class="linenos">2216</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2217"><a href="#Generator-2217"><span class="linenos">2217</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">normalize_func</span><span class="p">(</span><span class="n">name</span><span class="p">)</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2218"><a href="#Generator-2218"><span class="linenos">2218</span></a> -</span><span id="Generator-2219"><a href="#Generator-2219"><span class="linenos">2219</span></a> <span class="k">def</span> <span class="nf">format_args</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2220"><a href="#Generator-2220"><span class="linenos">2220</span></a> <span class="n">arg_sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span> <span class="k">if</span> <span class="n">arg</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="Generator-2221"><a href="#Generator-2221"><span class="linenos">2221</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span><span class="p">:</span> -</span><span id="Generator-2222"><a href="#Generator-2222"><span class="linenos">2222</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="sa">f</span><span class="s2">",</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">skip_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-2223"><a href="#Generator-2223"><span class="linenos">2223</span></a> <span class="k">return</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> -</span><span id="Generator-2224"><a href="#Generator-2224"><span class="linenos">2224</span></a> -</span><span id="Generator-2225"><a href="#Generator-2225"><span class="linenos">2225</span></a> <span class="k">def</span> <span class="nf">text_width</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> -</span><span id="Generator-2226"><a href="#Generator-2226"><span class="linenos">2226</span></a> <span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> +</span><span id="Generator-2188"><a href="#Generator-2188"><span class="linenos">2188</span></a> <span class="k">def</span> <span class="nf">lt_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2189"><a href="#Generator-2189"><span class="linenos">2189</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<"</span><span class="p">)</span> +</span><span id="Generator-2190"><a href="#Generator-2190"><span class="linenos">2190</span></a> +</span><span id="Generator-2191"><a href="#Generator-2191"><span class="linenos">2191</span></a> <span class="k">def</span> <span class="nf">lte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2192"><a href="#Generator-2192"><span class="linenos">2192</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<="</span><span class="p">)</span> +</span><span id="Generator-2193"><a href="#Generator-2193"><span class="linenos">2193</span></a> +</span><span id="Generator-2194"><a href="#Generator-2194"><span class="linenos">2194</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2195"><a href="#Generator-2195"><span class="linenos">2195</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"%"</span><span class="p">)</span> +</span><span id="Generator-2196"><a href="#Generator-2196"><span class="linenos">2196</span></a> +</span><span id="Generator-2197"><a href="#Generator-2197"><span class="linenos">2197</span></a> <span class="k">def</span> <span class="nf">mul_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mul</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2198"><a href="#Generator-2198"><span class="linenos">2198</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"*"</span><span class="p">)</span> +</span><span id="Generator-2199"><a href="#Generator-2199"><span class="linenos">2199</span></a> +</span><span id="Generator-2200"><a href="#Generator-2200"><span class="linenos">2200</span></a> <span class="k">def</span> <span class="nf">neq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2201"><a href="#Generator-2201"><span class="linenos">2201</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<>"</span><span class="p">)</span> +</span><span id="Generator-2202"><a href="#Generator-2202"><span class="linenos">2202</span></a> +</span><span id="Generator-2203"><a href="#Generator-2203"><span class="linenos">2203</span></a> <span class="k">def</span> <span class="nf">nullsafeeq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2204"><a href="#Generator-2204"><span class="linenos">2204</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS NOT DISTINCT FROM"</span><span class="p">)</span> +</span><span id="Generator-2205"><a href="#Generator-2205"><span class="linenos">2205</span></a> +</span><span id="Generator-2206"><a href="#Generator-2206"><span class="linenos">2206</span></a> <span class="k">def</span> <span class="nf">nullsafeneq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeNEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2207"><a href="#Generator-2207"><span class="linenos">2207</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS DISTINCT FROM"</span><span class="p">)</span> +</span><span id="Generator-2208"><a href="#Generator-2208"><span class="linenos">2208</span></a> +</span><span id="Generator-2209"><a href="#Generator-2209"><span class="linenos">2209</span></a> <span class="k">def</span> <span class="nf">or_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Or</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2210"><a href="#Generator-2210"><span class="linenos">2210</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OR"</span><span class="p">)</span> +</span><span id="Generator-2211"><a href="#Generator-2211"><span class="linenos">2211</span></a> +</span><span id="Generator-2212"><a href="#Generator-2212"><span class="linenos">2212</span></a> <span class="k">def</span> <span class="nf">slice_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Slice</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2213"><a href="#Generator-2213"><span class="linenos">2213</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">":"</span><span class="p">)</span> +</span><span id="Generator-2214"><a href="#Generator-2214"><span class="linenos">2214</span></a> +</span><span id="Generator-2215"><a href="#Generator-2215"><span class="linenos">2215</span></a> <span class="k">def</span> <span class="nf">sub_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Sub</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2216"><a href="#Generator-2216"><span class="linenos">2216</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)</span> +</span><span id="Generator-2217"><a href="#Generator-2217"><span class="linenos">2217</span></a> +</span><span id="Generator-2218"><a href="#Generator-2218"><span class="linenos">2218</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2219"><a href="#Generator-2219"><span class="linenos">2219</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TRY_CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'to'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2220"><a href="#Generator-2220"><span class="linenos">2220</span></a> +</span><span id="Generator-2221"><a href="#Generator-2221"><span class="linenos">2221</span></a> <span class="k">def</span> <span class="nf">use_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Use</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2222"><a href="#Generator-2222"><span class="linenos">2222</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator-2223"><a href="#Generator-2223"><span class="linenos">2223</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2224"><a href="#Generator-2224"><span class="linenos">2224</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2225"><a href="#Generator-2225"><span class="linenos">2225</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2226"><a href="#Generator-2226"><span class="linenos">2226</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"USE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2227"><a href="#Generator-2227"><span class="linenos">2227</span></a> -</span><span id="Generator-2228"><a href="#Generator-2228"><span class="linenos">2228</span></a> <span class="k">def</span> <span class="nf">format_time</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Generator-2229"><a href="#Generator-2229"><span class="linenos">2229</span></a> <span class="k">return</span> <span class="n">format_time</span><span class="p">(</span> -</span><span id="Generator-2230"><a href="#Generator-2230"><span class="linenos">2230</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span> -</span><span id="Generator-2231"><a href="#Generator-2231"><span class="linenos">2231</span></a> <span class="p">)</span> -</span><span id="Generator-2232"><a href="#Generator-2232"><span class="linenos">2232</span></a> -</span><span id="Generator-2233"><a href="#Generator-2233"><span class="linenos">2233</span></a> <span class="k">def</span> <span class="nf">expressions</span><span class="p">(</span> -</span><span id="Generator-2234"><a href="#Generator-2234"><span class="linenos">2234</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator-2235"><a href="#Generator-2235"><span class="linenos">2235</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-2236"><a href="#Generator-2236"><span class="linenos">2236</span></a> <span class="n">key</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-2237"><a href="#Generator-2237"><span class="linenos">2237</span></a> <span class="n">sqls</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-2238"><a href="#Generator-2238"><span class="linenos">2238</span></a> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Generator-2239"><a href="#Generator-2239"><span class="linenos">2239</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Generator-2240"><a href="#Generator-2240"><span class="linenos">2240</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">,</span> -</span><span id="Generator-2241"><a href="#Generator-2241"><span class="linenos">2241</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="Generator-2242"><a href="#Generator-2242"><span class="linenos">2242</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2243"><a href="#Generator-2243"><span class="linenos">2243</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span> <span class="ow">or</span> <span class="s2">"expressions"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span> <span class="k">else</span> <span class="n">sqls</span> -</span><span id="Generator-2244"><a href="#Generator-2244"><span class="linenos">2244</span></a> -</span><span id="Generator-2245"><a href="#Generator-2245"><span class="linenos">2245</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator-2246"><a href="#Generator-2246"><span class="linenos">2246</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator-2247"><a href="#Generator-2247"><span class="linenos">2247</span></a> -</span><span id="Generator-2248"><a href="#Generator-2248"><span class="linenos">2248</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> -</span><span id="Generator-2249"><a href="#Generator-2249"><span class="linenos">2249</span></a> <span class="k">return</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> -</span><span id="Generator-2250"><a href="#Generator-2250"><span class="linenos">2250</span></a> -</span><span id="Generator-2251"><a href="#Generator-2251"><span class="linenos">2251</span></a> <span class="n">num_sqls</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Generator-2252"><a href="#Generator-2252"><span class="linenos">2252</span></a> -</span><span id="Generator-2253"><a href="#Generator-2253"><span class="linenos">2253</span></a> <span class="c1"># These are calculated once in case we have the leading_comma / pretty option set, correspondingly</span> -</span><span id="Generator-2254"><a href="#Generator-2254"><span class="linenos">2254</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> -</span><span id="Generator-2255"><a href="#Generator-2255"><span class="linenos">2255</span></a> <span class="n">stripped_sep</span> <span class="o">=</span> <span class="n">sep</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="Generator-2256"><a href="#Generator-2256"><span class="linenos">2256</span></a> -</span><span id="Generator-2257"><a href="#Generator-2257"><span class="linenos">2257</span></a> <span class="n">result_sqls</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator-2258"><a href="#Generator-2258"><span class="linenos">2258</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expressions</span><span class="p">):</span> -</span><span id="Generator-2259"><a href="#Generator-2259"><span class="linenos">2259</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator-2260"><a href="#Generator-2260"><span class="linenos">2260</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2261"><a href="#Generator-2261"><span class="linenos">2261</span></a> -</span><span id="Generator-2262"><a href="#Generator-2262"><span class="linenos">2262</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="Generator-2263"><a href="#Generator-2263"><span class="linenos">2263</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span><span class="p">:</span> -</span><span id="Generator-2264"><a href="#Generator-2264"><span class="linenos">2264</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">pad</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-2265"><a href="#Generator-2265"><span class="linenos">2265</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2266"><a href="#Generator-2266"><span class="linenos">2266</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="Generator-2267"><a href="#Generator-2267"><span class="linenos">2267</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">stripped_sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2268"><a href="#Generator-2268"><span class="linenos">2268</span></a> <span class="p">)</span> -</span><span id="Generator-2269"><a href="#Generator-2269"><span class="linenos">2269</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2270"><a href="#Generator-2270"><span class="linenos">2270</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-2271"><a href="#Generator-2271"><span class="linenos">2271</span></a> -</span><span id="Generator-2272"><a href="#Generator-2272"><span class="linenos">2272</span></a> <span class="n">result_sql</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> -</span><span id="Generator-2273"><a href="#Generator-2273"><span class="linenos">2273</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">result_sql</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="k">if</span> <span class="n">indent</span> <span class="k">else</span> <span class="n">result_sql</span> -</span><span id="Generator-2274"><a href="#Generator-2274"><span class="linenos">2274</span></a> -</span><span id="Generator-2275"><a href="#Generator-2275"><span class="linenos">2275</span></a> <span class="k">def</span> <span class="nf">op_expressions</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2276"><a href="#Generator-2276"><span class="linenos">2276</span></a> <span class="n">flat</span> <span class="o">=</span> <span class="n">flat</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> -</span><span id="Generator-2277"><a href="#Generator-2277"><span class="linenos">2277</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="n">flat</span><span class="p">)</span> -</span><span id="Generator-2278"><a href="#Generator-2278"><span class="linenos">2278</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> -</span><span id="Generator-2279"><a href="#Generator-2279"><span class="linenos">2279</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2280"><a href="#Generator-2280"><span class="linenos">2280</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expressions_sql</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2281"><a href="#Generator-2281"><span class="linenos">2281</span></a> -</span><span id="Generator-2282"><a href="#Generator-2282"><span class="linenos">2282</span></a> <span class="k">def</span> <span class="nf">naked_property</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2283"><a href="#Generator-2283"><span class="linenos">2283</span></a> <span class="n">property_name</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">PROPERTY_TO_NAME</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span> -</span><span id="Generator-2284"><a href="#Generator-2284"><span class="linenos">2284</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">property_name</span><span class="p">:</span> -</span><span id="Generator-2285"><a href="#Generator-2285"><span class="linenos">2285</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-2286"><a href="#Generator-2286"><span class="linenos">2286</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">property_name</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2287"><a href="#Generator-2287"><span class="linenos">2287</span></a> -</span><span id="Generator-2288"><a href="#Generator-2288"><span class="linenos">2288</span></a> <span class="k">def</span> <span class="nf">set_operation</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2289"><a href="#Generator-2289"><span class="linenos">2289</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2290"><a href="#Generator-2290"><span class="linenos">2290</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span> -</span><span id="Generator-2291"><a href="#Generator-2291"><span class="linenos">2291</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> -</span><span id="Generator-2292"><a href="#Generator-2292"><span class="linenos">2292</span></a> <span class="n">expression</span><span class="p">,</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">op</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2293"><a href="#Generator-2293"><span class="linenos">2293</span></a> <span class="p">)</span> +</span><span id="Generator-2228"><a href="#Generator-2228"><span class="linenos">2228</span></a> <span class="k">def</span> <span class="nf">binary</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Binary</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2229"><a href="#Generator-2229"><span class="linenos">2229</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">op</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> +</span><span id="Generator-2230"><a href="#Generator-2230"><span class="linenos">2230</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2231"><a href="#Generator-2231"><span class="linenos">2231</span></a> +</span><span id="Generator-2232"><a href="#Generator-2232"><span class="linenos">2232</span></a> <span class="k">def</span> <span class="nf">function_fallback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2233"><a href="#Generator-2233"><span class="linenos">2233</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator-2234"><a href="#Generator-2234"><span class="linenos">2234</span></a> <span class="k">for</span> <span class="n">arg_value</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> +</span><span id="Generator-2235"><a href="#Generator-2235"><span class="linenos">2235</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">arg_value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="Generator-2236"><a href="#Generator-2236"><span class="linenos">2236</span></a> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">arg_value</span><span class="p">:</span> +</span><span id="Generator-2237"><a href="#Generator-2237"><span class="linenos">2237</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="Generator-2238"><a href="#Generator-2238"><span class="linenos">2238</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2239"><a href="#Generator-2239"><span class="linenos">2239</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">arg_value</span><span class="p">)</span> +</span><span id="Generator-2240"><a href="#Generator-2240"><span class="linenos">2240</span></a> +</span><span id="Generator-2241"><a href="#Generator-2241"><span class="linenos">2241</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">sql_name</span><span class="p">(),</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> +</span><span id="Generator-2242"><a href="#Generator-2242"><span class="linenos">2242</span></a> +</span><span id="Generator-2243"><a href="#Generator-2243"><span class="linenos">2243</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span> +</span><span id="Generator-2244"><a href="#Generator-2244"><span class="linenos">2244</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator-2245"><a href="#Generator-2245"><span class="linenos">2245</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="Generator-2246"><a href="#Generator-2246"><span class="linenos">2246</span></a> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">|</span> <span class="nb">str</span><span class="p">],</span> +</span><span id="Generator-2247"><a href="#Generator-2247"><span class="linenos">2247</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"("</span><span class="p">,</span> +</span><span id="Generator-2248"><a href="#Generator-2248"><span class="linenos">2248</span></a> <span class="n">suffix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">")"</span><span class="p">,</span> +</span><span id="Generator-2249"><a href="#Generator-2249"><span class="linenos">2249</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2250"><a href="#Generator-2250"><span class="linenos">2250</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">normalize_func</span><span class="p">(</span><span class="n">name</span><span class="p">)</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2251"><a href="#Generator-2251"><span class="linenos">2251</span></a> +</span><span id="Generator-2252"><a href="#Generator-2252"><span class="linenos">2252</span></a> <span class="k">def</span> <span class="nf">format_args</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2253"><a href="#Generator-2253"><span class="linenos">2253</span></a> <span class="n">arg_sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span> <span class="k">if</span> <span class="n">arg</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="Generator-2254"><a href="#Generator-2254"><span class="linenos">2254</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span><span class="p">:</span> +</span><span id="Generator-2255"><a href="#Generator-2255"><span class="linenos">2255</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="sa">f</span><span class="s2">",</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">skip_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-2256"><a href="#Generator-2256"><span class="linenos">2256</span></a> <span class="k">return</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> +</span><span id="Generator-2257"><a href="#Generator-2257"><span class="linenos">2257</span></a> +</span><span id="Generator-2258"><a href="#Generator-2258"><span class="linenos">2258</span></a> <span class="k">def</span> <span class="nf">text_width</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> +</span><span id="Generator-2259"><a href="#Generator-2259"><span class="linenos">2259</span></a> <span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> +</span><span id="Generator-2260"><a href="#Generator-2260"><span class="linenos">2260</span></a> +</span><span id="Generator-2261"><a href="#Generator-2261"><span class="linenos">2261</span></a> <span class="k">def</span> <span class="nf">format_time</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Generator-2262"><a href="#Generator-2262"><span class="linenos">2262</span></a> <span class="k">return</span> <span class="n">format_time</span><span class="p">(</span> +</span><span id="Generator-2263"><a href="#Generator-2263"><span class="linenos">2263</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span> +</span><span id="Generator-2264"><a href="#Generator-2264"><span class="linenos">2264</span></a> <span class="p">)</span> +</span><span id="Generator-2265"><a href="#Generator-2265"><span class="linenos">2265</span></a> +</span><span id="Generator-2266"><a href="#Generator-2266"><span class="linenos">2266</span></a> <span class="k">def</span> <span class="nf">expressions</span><span class="p">(</span> +</span><span id="Generator-2267"><a href="#Generator-2267"><span class="linenos">2267</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator-2268"><a href="#Generator-2268"><span class="linenos">2268</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-2269"><a href="#Generator-2269"><span class="linenos">2269</span></a> <span class="n">key</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-2270"><a href="#Generator-2270"><span class="linenos">2270</span></a> <span class="n">sqls</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-2271"><a href="#Generator-2271"><span class="linenos">2271</span></a> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Generator-2272"><a href="#Generator-2272"><span class="linenos">2272</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Generator-2273"><a href="#Generator-2273"><span class="linenos">2273</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">,</span> +</span><span id="Generator-2274"><a href="#Generator-2274"><span class="linenos">2274</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="Generator-2275"><a href="#Generator-2275"><span class="linenos">2275</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2276"><a href="#Generator-2276"><span class="linenos">2276</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span> <span class="ow">or</span> <span class="s2">"expressions"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span> <span class="k">else</span> <span class="n">sqls</span> +</span><span id="Generator-2277"><a href="#Generator-2277"><span class="linenos">2277</span></a> +</span><span id="Generator-2278"><a href="#Generator-2278"><span class="linenos">2278</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator-2279"><a href="#Generator-2279"><span class="linenos">2279</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator-2280"><a href="#Generator-2280"><span class="linenos">2280</span></a> +</span><span id="Generator-2281"><a href="#Generator-2281"><span class="linenos">2281</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> +</span><span id="Generator-2282"><a href="#Generator-2282"><span class="linenos">2282</span></a> <span class="k">return</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator-2283"><a href="#Generator-2283"><span class="linenos">2283</span></a> +</span><span id="Generator-2284"><a href="#Generator-2284"><span class="linenos">2284</span></a> <span class="n">num_sqls</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator-2285"><a href="#Generator-2285"><span class="linenos">2285</span></a> +</span><span id="Generator-2286"><a href="#Generator-2286"><span class="linenos">2286</span></a> <span class="c1"># These are calculated once in case we have the leading_comma / pretty option set, correspondingly</span> +</span><span id="Generator-2287"><a href="#Generator-2287"><span class="linenos">2287</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> +</span><span id="Generator-2288"><a href="#Generator-2288"><span class="linenos">2288</span></a> <span class="n">stripped_sep</span> <span class="o">=</span> <span class="n">sep</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="Generator-2289"><a href="#Generator-2289"><span class="linenos">2289</span></a> +</span><span id="Generator-2290"><a href="#Generator-2290"><span class="linenos">2290</span></a> <span class="n">result_sqls</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator-2291"><a href="#Generator-2291"><span class="linenos">2291</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expressions</span><span class="p">):</span> +</span><span id="Generator-2292"><a href="#Generator-2292"><span class="linenos">2292</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator-2293"><a href="#Generator-2293"><span class="linenos">2293</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> </span><span id="Generator-2294"><a href="#Generator-2294"><span class="linenos">2294</span></a> -</span><span id="Generator-2295"><a href="#Generator-2295"><span class="linenos">2295</span></a> <span class="k">def</span> <span class="nf">tag_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Tag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2296"><a href="#Generator-2296"><span class="linenos">2296</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'prefix'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}{</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'postfix'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2297"><a href="#Generator-2297"><span class="linenos">2297</span></a> -</span><span id="Generator-2298"><a href="#Generator-2298"><span class="linenos">2298</span></a> <span class="k">def</span> <span class="nf">token_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2299"><a href="#Generator-2299"><span class="linenos">2299</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">TOKEN_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">token_type</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> -</span><span id="Generator-2300"><a href="#Generator-2300"><span class="linenos">2300</span></a> -</span><span id="Generator-2301"><a href="#Generator-2301"><span class="linenos">2301</span></a> <span class="k">def</span> <span class="nf">userdefinedfunction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UserDefinedFunction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2302"><a href="#Generator-2302"><span class="linenos">2302</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2303"><a href="#Generator-2303"><span class="linenos">2303</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-2304"><a href="#Generator-2304"><span class="linenos">2304</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-2305"><a href="#Generator-2305"><span class="linenos">2305</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"wrapped"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2306"><a href="#Generator-2306"><span class="linenos">2306</span></a> <span class="p">)</span> -</span><span id="Generator-2307"><a href="#Generator-2307"><span class="linenos">2307</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2308"><a href="#Generator-2308"><span class="linenos">2308</span></a> -</span><span id="Generator-2309"><a href="#Generator-2309"><span class="linenos">2309</span></a> <span class="k">def</span> <span class="nf">joinhint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JoinHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2310"><a href="#Generator-2310"><span class="linenos">2310</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2311"><a href="#Generator-2311"><span class="linenos">2311</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-2312"><a href="#Generator-2312"><span class="linenos">2312</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-2313"><a href="#Generator-2313"><span class="linenos">2313</span></a> -</span><span id="Generator-2314"><a href="#Generator-2314"><span class="linenos">2314</span></a> <span class="k">def</span> <span class="nf">kwarg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Kwarg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2315"><a href="#Generator-2315"><span class="linenos">2315</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"=>"</span><span class="p">)</span> -</span><span id="Generator-2316"><a href="#Generator-2316"><span class="linenos">2316</span></a> -</span><span id="Generator-2317"><a href="#Generator-2317"><span class="linenos">2317</span></a> <span class="k">def</span> <span class="nf">when_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">When</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2318"><a href="#Generator-2318"><span class="linenos">2318</span></a> <span class="n">matched</span> <span class="o">=</span> <span class="s2">"MATCHED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"matched"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"NOT MATCHED"</span> -</span><span id="Generator-2319"><a href="#Generator-2319"><span class="linenos">2319</span></a> <span class="n">source</span> <span class="o">=</span> <span class="s2">" BY SOURCE"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">MATCHED_BY_SOURCE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"source"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2320"><a href="#Generator-2320"><span class="linenos">2320</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">)</span> -</span><span id="Generator-2321"><a href="#Generator-2321"><span class="linenos">2321</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">condition</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2322"><a href="#Generator-2322"><span class="linenos">2322</span></a> -</span><span id="Generator-2323"><a href="#Generator-2323"><span class="linenos">2323</span></a> <span class="n">then_expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"then"</span><span class="p">)</span> -</span><span id="Generator-2324"><a href="#Generator-2324"><span class="linenos">2324</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">):</span> -</span><span id="Generator-2325"><a href="#Generator-2325"><span class="linenos">2325</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2326"><a href="#Generator-2326"><span class="linenos">2326</span></a> <span class="k">if</span> <span class="s2">"expression"</span> <span class="ow">in</span> <span class="n">then_expression</span><span class="o">.</span><span class="n">args</span><span class="p">:</span> -</span><span id="Generator-2327"><a href="#Generator-2327"><span class="linenos">2327</span></a> <span class="n">then</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" VALUES </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2328"><a href="#Generator-2328"><span class="linenos">2328</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> -</span><span id="Generator-2329"><a href="#Generator-2329"><span class="linenos">2329</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">):</span> -</span><span id="Generator-2330"><a href="#Generator-2330"><span class="linenos">2330</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expressions'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2331"><a href="#Generator-2331"><span class="linenos">2331</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2332"><a href="#Generator-2332"><span class="linenos">2332</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2333"><a href="#Generator-2333"><span class="linenos">2333</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2334"><a href="#Generator-2334"><span class="linenos">2334</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">)</span> -</span><span id="Generator-2335"><a href="#Generator-2335"><span class="linenos">2335</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WHEN </span><span class="si">{</span><span class="n">matched</span><span class="si">}{</span><span class="n">source</span><span class="si">}{</span><span class="n">condition</span><span class="si">}</span><span class="s2"> THEN </span><span class="si">{</span><span class="n">then</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2336"><a href="#Generator-2336"><span class="linenos">2336</span></a> -</span><span id="Generator-2337"><a href="#Generator-2337"><span class="linenos">2337</span></a> <span class="k">def</span> <span class="nf">merge_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Merge</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2338"><a href="#Generator-2338"><span class="linenos">2338</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2339"><a href="#Generator-2339"><span class="linenos">2339</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'using'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2340"><a href="#Generator-2340"><span class="linenos">2340</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'on'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2341"><a href="#Generator-2341"><span class="linenos">2341</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGE INTO </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">' '</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2342"><a href="#Generator-2342"><span class="linenos">2342</span></a> -</span><span id="Generator-2343"><a href="#Generator-2343"><span class="linenos">2343</span></a> <span class="k">def</span> <span class="nf">tochar_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2344"><a href="#Generator-2344"><span class="linenos">2344</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"format"</span><span class="p">):</span> -</span><span id="Generator-2345"><a href="#Generator-2345"><span class="linenos">2345</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Format argument unsupported for TO_CHAR/TO_VARCHAR function"</span><span class="p">)</span> +</span><span id="Generator-2295"><a href="#Generator-2295"><span class="linenos">2295</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="Generator-2296"><a href="#Generator-2296"><span class="linenos">2296</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span><span class="p">:</span> +</span><span id="Generator-2297"><a href="#Generator-2297"><span class="linenos">2297</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">pad</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-2298"><a href="#Generator-2298"><span class="linenos">2298</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2299"><a href="#Generator-2299"><span class="linenos">2299</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="Generator-2300"><a href="#Generator-2300"><span class="linenos">2300</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">stripped_sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2301"><a href="#Generator-2301"><span class="linenos">2301</span></a> <span class="p">)</span> +</span><span id="Generator-2302"><a href="#Generator-2302"><span class="linenos">2302</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2303"><a href="#Generator-2303"><span class="linenos">2303</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-2304"><a href="#Generator-2304"><span class="linenos">2304</span></a> +</span><span id="Generator-2305"><a href="#Generator-2305"><span class="linenos">2305</span></a> <span class="n">result_sql</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> +</span><span id="Generator-2306"><a href="#Generator-2306"><span class="linenos">2306</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">result_sql</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="k">if</span> <span class="n">indent</span> <span class="k">else</span> <span class="n">result_sql</span> +</span><span id="Generator-2307"><a href="#Generator-2307"><span class="linenos">2307</span></a> +</span><span id="Generator-2308"><a href="#Generator-2308"><span class="linenos">2308</span></a> <span class="k">def</span> <span class="nf">op_expressions</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2309"><a href="#Generator-2309"><span class="linenos">2309</span></a> <span class="n">flat</span> <span class="o">=</span> <span class="n">flat</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> +</span><span id="Generator-2310"><a href="#Generator-2310"><span class="linenos">2310</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="n">flat</span><span class="p">)</span> +</span><span id="Generator-2311"><a href="#Generator-2311"><span class="linenos">2311</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> +</span><span id="Generator-2312"><a href="#Generator-2312"><span class="linenos">2312</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2313"><a href="#Generator-2313"><span class="linenos">2313</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expressions_sql</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2314"><a href="#Generator-2314"><span class="linenos">2314</span></a> +</span><span id="Generator-2315"><a href="#Generator-2315"><span class="linenos">2315</span></a> <span class="k">def</span> <span class="nf">naked_property</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2316"><a href="#Generator-2316"><span class="linenos">2316</span></a> <span class="n">property_name</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">PROPERTY_TO_NAME</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span> +</span><span id="Generator-2317"><a href="#Generator-2317"><span class="linenos">2317</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">property_name</span><span class="p">:</span> +</span><span id="Generator-2318"><a href="#Generator-2318"><span class="linenos">2318</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-2319"><a href="#Generator-2319"><span class="linenos">2319</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">property_name</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2320"><a href="#Generator-2320"><span class="linenos">2320</span></a> +</span><span id="Generator-2321"><a href="#Generator-2321"><span class="linenos">2321</span></a> <span class="k">def</span> <span class="nf">set_operation</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2322"><a href="#Generator-2322"><span class="linenos">2322</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2323"><a href="#Generator-2323"><span class="linenos">2323</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span> +</span><span id="Generator-2324"><a href="#Generator-2324"><span class="linenos">2324</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> +</span><span id="Generator-2325"><a href="#Generator-2325"><span class="linenos">2325</span></a> <span class="n">expression</span><span class="p">,</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">op</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2326"><a href="#Generator-2326"><span class="linenos">2326</span></a> <span class="p">)</span> +</span><span id="Generator-2327"><a href="#Generator-2327"><span class="linenos">2327</span></a> +</span><span id="Generator-2328"><a href="#Generator-2328"><span class="linenos">2328</span></a> <span class="k">def</span> <span class="nf">tag_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Tag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2329"><a href="#Generator-2329"><span class="linenos">2329</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'prefix'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}{</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'postfix'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2330"><a href="#Generator-2330"><span class="linenos">2330</span></a> +</span><span id="Generator-2331"><a href="#Generator-2331"><span class="linenos">2331</span></a> <span class="k">def</span> <span class="nf">token_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2332"><a href="#Generator-2332"><span class="linenos">2332</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">TOKEN_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">token_type</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> +</span><span id="Generator-2333"><a href="#Generator-2333"><span class="linenos">2333</span></a> +</span><span id="Generator-2334"><a href="#Generator-2334"><span class="linenos">2334</span></a> <span class="k">def</span> <span class="nf">userdefinedfunction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UserDefinedFunction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2335"><a href="#Generator-2335"><span class="linenos">2335</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2336"><a href="#Generator-2336"><span class="linenos">2336</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-2337"><a href="#Generator-2337"><span class="linenos">2337</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-2338"><a href="#Generator-2338"><span class="linenos">2338</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"wrapped"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2339"><a href="#Generator-2339"><span class="linenos">2339</span></a> <span class="p">)</span> +</span><span id="Generator-2340"><a href="#Generator-2340"><span class="linenos">2340</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2341"><a href="#Generator-2341"><span class="linenos">2341</span></a> +</span><span id="Generator-2342"><a href="#Generator-2342"><span class="linenos">2342</span></a> <span class="k">def</span> <span class="nf">joinhint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JoinHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2343"><a href="#Generator-2343"><span class="linenos">2343</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2344"><a href="#Generator-2344"><span class="linenos">2344</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-2345"><a href="#Generator-2345"><span class="linenos">2345</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> </span><span id="Generator-2346"><a href="#Generator-2346"><span class="linenos">2346</span></a> -</span><span id="Generator-2347"><a href="#Generator-2347"><span class="linenos">2347</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">))</span> -</span><span id="Generator-2348"><a href="#Generator-2348"><span class="linenos">2348</span></a> -</span><span id="Generator-2349"><a href="#Generator-2349"><span class="linenos">2349</span></a> <span class="k">def</span> <span class="nf">dictproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2350"><a href="#Generator-2350"><span class="linenos">2350</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2351"><a href="#Generator-2351"><span class="linenos">2351</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator-2352"><a href="#Generator-2352"><span class="linenos">2352</span></a> <span class="n">settings_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"settings"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator-2353"><a href="#Generator-2353"><span class="linenos">2353</span></a> <span class="n">args</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">settings_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">settings_sql</span> <span class="k">else</span> <span class="s2">"()"</span> -</span><span id="Generator-2354"><a href="#Generator-2354"><span class="linenos">2354</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2347"><a href="#Generator-2347"><span class="linenos">2347</span></a> <span class="k">def</span> <span class="nf">kwarg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Kwarg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2348"><a href="#Generator-2348"><span class="linenos">2348</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"=>"</span><span class="p">)</span> +</span><span id="Generator-2349"><a href="#Generator-2349"><span class="linenos">2349</span></a> +</span><span id="Generator-2350"><a href="#Generator-2350"><span class="linenos">2350</span></a> <span class="k">def</span> <span class="nf">when_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">When</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2351"><a href="#Generator-2351"><span class="linenos">2351</span></a> <span class="n">matched</span> <span class="o">=</span> <span class="s2">"MATCHED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"matched"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"NOT MATCHED"</span> +</span><span id="Generator-2352"><a href="#Generator-2352"><span class="linenos">2352</span></a> <span class="n">source</span> <span class="o">=</span> <span class="s2">" BY SOURCE"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">MATCHED_BY_SOURCE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"source"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2353"><a href="#Generator-2353"><span class="linenos">2353</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">)</span> +</span><span id="Generator-2354"><a href="#Generator-2354"><span class="linenos">2354</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">condition</span> <span class="k">else</span> <span class="s2">""</span> </span><span id="Generator-2355"><a href="#Generator-2355"><span class="linenos">2355</span></a> -</span><span id="Generator-2356"><a href="#Generator-2356"><span class="linenos">2356</span></a> <span class="k">def</span> <span class="nf">dictrange_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DictRange</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2357"><a href="#Generator-2357"><span class="linenos">2357</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2358"><a href="#Generator-2358"><span class="linenos">2358</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"max"</span><span class="p">)</span> -</span><span id="Generator-2359"><a href="#Generator-2359"><span class="linenos">2359</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"min"</span><span class="p">)</span> -</span><span id="Generator-2360"><a href="#Generator-2360"><span class="linenos">2360</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(MIN </span><span class="si">{</span><span class="nb">min</span><span class="si">}</span><span class="s2"> MAX </span><span class="si">{</span><span class="nb">max</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-2361"><a href="#Generator-2361"><span class="linenos">2361</span></a> -</span><span id="Generator-2362"><a href="#Generator-2362"><span class="linenos">2362</span></a> <span class="k">def</span> <span class="nf">dictsubproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DictSubProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2363"><a href="#Generator-2363"><span class="linenos">2363</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2364"><a href="#Generator-2364"><span class="linenos">2364</span></a> -</span><span id="Generator-2365"><a href="#Generator-2365"><span class="linenos">2365</span></a> <span class="k">def</span> <span class="nf">oncluster_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnCluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2366"><a href="#Generator-2366"><span class="linenos">2366</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator-2356"><a href="#Generator-2356"><span class="linenos">2356</span></a> <span class="n">then_expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"then"</span><span class="p">)</span> +</span><span id="Generator-2357"><a href="#Generator-2357"><span class="linenos">2357</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">):</span> +</span><span id="Generator-2358"><a href="#Generator-2358"><span class="linenos">2358</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2359"><a href="#Generator-2359"><span class="linenos">2359</span></a> <span class="k">if</span> <span class="s2">"expression"</span> <span class="ow">in</span> <span class="n">then_expression</span><span class="o">.</span><span class="n">args</span><span class="p">:</span> +</span><span id="Generator-2360"><a href="#Generator-2360"><span class="linenos">2360</span></a> <span class="n">then</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" VALUES </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2361"><a href="#Generator-2361"><span class="linenos">2361</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> +</span><span id="Generator-2362"><a href="#Generator-2362"><span class="linenos">2362</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">):</span> +</span><span id="Generator-2363"><a href="#Generator-2363"><span class="linenos">2363</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expressions'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2364"><a href="#Generator-2364"><span class="linenos">2364</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2365"><a href="#Generator-2365"><span class="linenos">2365</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2366"><a href="#Generator-2366"><span class="linenos">2366</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2367"><a href="#Generator-2367"><span class="linenos">2367</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">)</span> +</span><span id="Generator-2368"><a href="#Generator-2368"><span class="linenos">2368</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WHEN </span><span class="si">{</span><span class="n">matched</span><span class="si">}{</span><span class="n">source</span><span class="si">}{</span><span class="n">condition</span><span class="si">}</span><span class="s2"> THEN </span><span class="si">{</span><span class="n">then</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2369"><a href="#Generator-2369"><span class="linenos">2369</span></a> +</span><span id="Generator-2370"><a href="#Generator-2370"><span class="linenos">2370</span></a> <span class="k">def</span> <span class="nf">merge_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Merge</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2371"><a href="#Generator-2371"><span class="linenos">2371</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2372"><a href="#Generator-2372"><span class="linenos">2372</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'using'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2373"><a href="#Generator-2373"><span class="linenos">2373</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'on'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2374"><a href="#Generator-2374"><span class="linenos">2374</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGE INTO </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">' '</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2375"><a href="#Generator-2375"><span class="linenos">2375</span></a> +</span><span id="Generator-2376"><a href="#Generator-2376"><span class="linenos">2376</span></a> <span class="k">def</span> <span class="nf">tochar_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2377"><a href="#Generator-2377"><span class="linenos">2377</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"format"</span><span class="p">):</span> +</span><span id="Generator-2378"><a href="#Generator-2378"><span class="linenos">2378</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Format argument unsupported for TO_CHAR/TO_VARCHAR function"</span><span class="p">)</span> +</span><span id="Generator-2379"><a href="#Generator-2379"><span class="linenos">2379</span></a> +</span><span id="Generator-2380"><a href="#Generator-2380"><span class="linenos">2380</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">))</span> +</span><span id="Generator-2381"><a href="#Generator-2381"><span class="linenos">2381</span></a> +</span><span id="Generator-2382"><a href="#Generator-2382"><span class="linenos">2382</span></a> <span class="k">def</span> <span class="nf">dictproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2383"><a href="#Generator-2383"><span class="linenos">2383</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2384"><a href="#Generator-2384"><span class="linenos">2384</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator-2385"><a href="#Generator-2385"><span class="linenos">2385</span></a> <span class="n">settings_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"settings"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator-2386"><a href="#Generator-2386"><span class="linenos">2386</span></a> <span class="n">args</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">settings_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">settings_sql</span> <span class="k">else</span> <span class="s2">"()"</span> +</span><span id="Generator-2387"><a href="#Generator-2387"><span class="linenos">2387</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2388"><a href="#Generator-2388"><span class="linenos">2388</span></a> +</span><span id="Generator-2389"><a href="#Generator-2389"><span class="linenos">2389</span></a> <span class="k">def</span> <span class="nf">dictrange_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DictRange</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2390"><a href="#Generator-2390"><span class="linenos">2390</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2391"><a href="#Generator-2391"><span class="linenos">2391</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"max"</span><span class="p">)</span> +</span><span id="Generator-2392"><a href="#Generator-2392"><span class="linenos">2392</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"min"</span><span class="p">)</span> +</span><span id="Generator-2393"><a href="#Generator-2393"><span class="linenos">2393</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(MIN </span><span class="si">{</span><span class="nb">min</span><span class="si">}</span><span class="s2"> MAX </span><span class="si">{</span><span class="nb">max</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2394"><a href="#Generator-2394"><span class="linenos">2394</span></a> +</span><span id="Generator-2395"><a href="#Generator-2395"><span class="linenos">2395</span></a> <span class="k">def</span> <span class="nf">dictsubproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DictSubProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2396"><a href="#Generator-2396"><span class="linenos">2396</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2397"><a href="#Generator-2397"><span class="linenos">2397</span></a> +</span><span id="Generator-2398"><a href="#Generator-2398"><span class="linenos">2398</span></a> <span class="k">def</span> <span class="nf">oncluster_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnCluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2399"><a href="#Generator-2399"><span class="linenos">2399</span></a> <span class="k">return</span> <span class="s2">""</span> </span></pre></div> @@ -5571,46 +5643,100 @@ Default: True</li> </div> <a class="headerlink" href="#Generator.__init__"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.__init__-303"><a href="#Generator.__init__-303"><span class="linenos">303</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> -</span><span id="Generator.__init__-304"><a href="#Generator.__init__-304"><span class="linenos">304</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator.__init__-305"><a href="#Generator.__init__-305"><span class="linenos">305</span></a> <span class="n">pretty</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.__init__-306"><a href="#Generator.__init__-306"><span class="linenos">306</span></a> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Generator.__init__-307"><a href="#Generator.__init__-307"><span class="linenos">307</span></a> <span class="n">normalize</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Generator.__init__-308"><a href="#Generator.__init__-308"><span class="linenos">308</span></a> <span class="n">pad</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> -</span><span id="Generator.__init__-309"><a href="#Generator.__init__-309"><span class="linenos">309</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> -</span><span id="Generator.__init__-310"><a href="#Generator.__init__-310"><span class="linenos">310</span></a> <span class="n">normalize_functions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.__init__-311"><a href="#Generator.__init__-311"><span class="linenos">311</span></a> <span class="n">unsupported_level</span><span class="p">:</span> <span class="n">ErrorLevel</span> <span class="o">=</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">,</span> -</span><span id="Generator.__init__-312"><a href="#Generator.__init__-312"><span class="linenos">312</span></a> <span class="n">max_unsupported</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> -</span><span id="Generator.__init__-313"><a href="#Generator.__init__-313"><span class="linenos">313</span></a> <span class="n">leading_comma</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Generator.__init__-314"><a href="#Generator.__init__-314"><span class="linenos">314</span></a> <span class="n">max_text_width</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">80</span><span class="p">,</span> -</span><span id="Generator.__init__-315"><a href="#Generator.__init__-315"><span class="linenos">315</span></a> <span class="n">comments</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Generator.__init__-316"><a href="#Generator.__init__-316"><span class="linenos">316</span></a> <span class="p">):</span> -</span><span id="Generator.__init__-317"><a href="#Generator.__init__-317"><span class="linenos">317</span></a> <span class="kn">import</span> <span class="nn">sqlglot</span> -</span><span id="Generator.__init__-318"><a href="#Generator.__init__-318"><span class="linenos">318</span></a> -</span><span id="Generator.__init__-319"><a href="#Generator.__init__-319"><span class="linenos">319</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="o">=</span> <span class="n">pretty</span> <span class="k">if</span> <span class="n">pretty</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">pretty</span> -</span><span id="Generator.__init__-320"><a href="#Generator.__init__-320"><span class="linenos">320</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">identify</span> -</span><span id="Generator.__init__-321"><a href="#Generator.__init__-321"><span class="linenos">321</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="o">=</span> <span class="n">normalize</span> -</span><span id="Generator.__init__-322"><a href="#Generator.__init__-322"><span class="linenos">322</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="o">=</span> <span class="n">pad</span> -</span><span id="Generator.__init__-323"><a href="#Generator.__init__-323"><span class="linenos">323</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_indent</span> <span class="o">=</span> <span class="n">indent</span> -</span><span id="Generator.__init__-324"><a href="#Generator.__init__-324"><span class="linenos">324</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">=</span> <span class="n">unsupported_level</span> -</span><span id="Generator.__init__-325"><a href="#Generator.__init__-325"><span class="linenos">325</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span> <span class="o">=</span> <span class="n">max_unsupported</span> -</span><span id="Generator.__init__-326"><a href="#Generator.__init__-326"><span class="linenos">326</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span> <span class="o">=</span> <span class="n">leading_comma</span> -</span><span id="Generator.__init__-327"><a href="#Generator.__init__-327"><span class="linenos">327</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="o">=</span> <span class="n">max_text_width</span> -</span><span id="Generator.__init__-328"><a href="#Generator.__init__-328"><span class="linenos">328</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> -</span><span id="Generator.__init__-329"><a href="#Generator.__init__-329"><span class="linenos">329</span></a> -</span><span id="Generator.__init__-330"><a href="#Generator.__init__-330"><span class="linenos">330</span></a> <span class="c1"># This is both a Dialect property and a Generator argument, so we prioritize the latter</span> -</span><span id="Generator.__init__-331"><a href="#Generator.__init__-331"><span class="linenos">331</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.__init__-332"><a href="#Generator.__init__-332"><span class="linenos">332</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">NORMALIZE_FUNCTIONS</span> <span class="k">if</span> <span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">normalize_functions</span> -</span><span id="Generator.__init__-333"><a href="#Generator.__init__-333"><span class="linenos">333</span></a> <span class="p">)</span> -</span><span id="Generator.__init__-334"><a href="#Generator.__init__-334"><span class="linenos">334</span></a> -</span><span id="Generator.__init__-335"><a href="#Generator.__init__-335"><span class="linenos">335</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator.__init__-336"><a href="#Generator.__init__-336"><span class="linenos">336</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRING_ESCAPE</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span> -</span><span id="Generator.__init__-337"><a href="#Generator.__init__-337"><span class="linenos">337</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_ESCAPE</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_END</span> -</span><span id="Generator.__init__-338"><a href="#Generator.__init__-338"><span class="linenos">338</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span></pre></div> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.__init__-310"><a href="#Generator.__init__-310"><span class="linenos">310</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> +</span><span id="Generator.__init__-311"><a href="#Generator.__init__-311"><span class="linenos">311</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator.__init__-312"><a href="#Generator.__init__-312"><span class="linenos">312</span></a> <span class="n">pretty</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.__init__-313"><a href="#Generator.__init__-313"><span class="linenos">313</span></a> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Generator.__init__-314"><a href="#Generator.__init__-314"><span class="linenos">314</span></a> <span class="n">normalize</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Generator.__init__-315"><a href="#Generator.__init__-315"><span class="linenos">315</span></a> <span class="n">pad</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> +</span><span id="Generator.__init__-316"><a href="#Generator.__init__-316"><span class="linenos">316</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">2</span><span class="p">,</span> +</span><span id="Generator.__init__-317"><a href="#Generator.__init__-317"><span class="linenos">317</span></a> <span class="n">normalize_functions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.__init__-318"><a href="#Generator.__init__-318"><span class="linenos">318</span></a> <span class="n">unsupported_level</span><span class="p">:</span> <span class="n">ErrorLevel</span> <span class="o">=</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">,</span> +</span><span id="Generator.__init__-319"><a href="#Generator.__init__-319"><span class="linenos">319</span></a> <span class="n">max_unsupported</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> +</span><span id="Generator.__init__-320"><a href="#Generator.__init__-320"><span class="linenos">320</span></a> <span class="n">leading_comma</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Generator.__init__-321"><a href="#Generator.__init__-321"><span class="linenos">321</span></a> <span class="n">max_text_width</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">80</span><span class="p">,</span> +</span><span id="Generator.__init__-322"><a href="#Generator.__init__-322"><span class="linenos">322</span></a> <span class="n">comments</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Generator.__init__-323"><a href="#Generator.__init__-323"><span class="linenos">323</span></a> <span class="p">):</span> +</span><span id="Generator.__init__-324"><a href="#Generator.__init__-324"><span class="linenos">324</span></a> <span class="kn">import</span> <span class="nn">sqlglot</span> +</span><span id="Generator.__init__-325"><a href="#Generator.__init__-325"><span class="linenos">325</span></a> +</span><span id="Generator.__init__-326"><a href="#Generator.__init__-326"><span class="linenos">326</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="o">=</span> <span class="n">pretty</span> <span class="k">if</span> <span class="n">pretty</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">pretty</span> +</span><span id="Generator.__init__-327"><a href="#Generator.__init__-327"><span class="linenos">327</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">identify</span> +</span><span id="Generator.__init__-328"><a href="#Generator.__init__-328"><span class="linenos">328</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="o">=</span> <span class="n">normalize</span> +</span><span id="Generator.__init__-329"><a href="#Generator.__init__-329"><span class="linenos">329</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="o">=</span> <span class="n">pad</span> +</span><span id="Generator.__init__-330"><a href="#Generator.__init__-330"><span class="linenos">330</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_indent</span> <span class="o">=</span> <span class="n">indent</span> +</span><span id="Generator.__init__-331"><a href="#Generator.__init__-331"><span class="linenos">331</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">=</span> <span class="n">unsupported_level</span> +</span><span id="Generator.__init__-332"><a href="#Generator.__init__-332"><span class="linenos">332</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span> <span class="o">=</span> <span class="n">max_unsupported</span> +</span><span id="Generator.__init__-333"><a href="#Generator.__init__-333"><span class="linenos">333</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span> <span class="o">=</span> <span class="n">leading_comma</span> +</span><span id="Generator.__init__-334"><a href="#Generator.__init__-334"><span class="linenos">334</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="o">=</span> <span class="n">max_text_width</span> +</span><span id="Generator.__init__-335"><a href="#Generator.__init__-335"><span class="linenos">335</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> +</span><span id="Generator.__init__-336"><a href="#Generator.__init__-336"><span class="linenos">336</span></a> +</span><span id="Generator.__init__-337"><a href="#Generator.__init__-337"><span class="linenos">337</span></a> <span class="c1"># This is both a Dialect property and a Generator argument, so we prioritize the latter</span> +</span><span id="Generator.__init__-338"><a href="#Generator.__init__-338"><span class="linenos">338</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.__init__-339"><a href="#Generator.__init__-339"><span class="linenos">339</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">NORMALIZE_FUNCTIONS</span> <span class="k">if</span> <span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">normalize_functions</span> +</span><span id="Generator.__init__-340"><a href="#Generator.__init__-340"><span class="linenos">340</span></a> <span class="p">)</span> +</span><span id="Generator.__init__-341"><a href="#Generator.__init__-341"><span class="linenos">341</span></a> +</span><span id="Generator.__init__-342"><a href="#Generator.__init__-342"><span class="linenos">342</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator.__init__-343"><a href="#Generator.__init__-343"><span class="linenos">343</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRING_ESCAPE</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span> +</span><span id="Generator.__init__-344"><a href="#Generator.__init__-344"><span class="linenos">344</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_ESCAPE</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_END</span> +</span><span id="Generator.__init__-345"><a href="#Generator.__init__-345"><span class="linenos">345</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span></pre></div> + + + + + </div> + <div id="Generator.can_identify" class="classattr"> + <input id="Generator.can_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + <div class="decorator">@classmethod</div> + + <span class="def">def</span> + <span class="name">can_identify</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span>, </span><span class="param"><span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s1">'safe'</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> + + <label class="view-source-button" for="Generator.can_identify-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Generator.can_identify"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.can_identify-247"><a href="#Generator.can_identify-247"><span class="linenos">247</span></a> <span class="nd">@classmethod</span> +</span><span id="Generator.can_identify-248"><a href="#Generator.can_identify-248"><span class="linenos">248</span></a> <span class="k">def</span> <span class="nf">can_identify</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span> <span class="o">=</span> <span class="s2">"safe"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Generator.can_identify-249"><a href="#Generator.can_identify-249"><span class="linenos">249</span></a><span class="w"> </span><span class="sd">"""Checks if text can be identified given an identify option.</span> +</span><span id="Generator.can_identify-250"><a href="#Generator.can_identify-250"><span class="linenos">250</span></a> +</span><span id="Generator.can_identify-251"><a href="#Generator.can_identify-251"><span class="linenos">251</span></a><span class="sd"> Args:</span> +</span><span id="Generator.can_identify-252"><a href="#Generator.can_identify-252"><span class="linenos">252</span></a><span class="sd"> text: The text to check.</span> +</span><span id="Generator.can_identify-253"><a href="#Generator.can_identify-253"><span class="linenos">253</span></a><span class="sd"> identify:</span> +</span><span id="Generator.can_identify-254"><a href="#Generator.can_identify-254"><span class="linenos">254</span></a><span class="sd"> "always" or `True`: Always returns true.</span> +</span><span id="Generator.can_identify-255"><a href="#Generator.can_identify-255"><span class="linenos">255</span></a><span class="sd"> "safe": True if the identifier is case-insensitive.</span> +</span><span id="Generator.can_identify-256"><a href="#Generator.can_identify-256"><span class="linenos">256</span></a> +</span><span id="Generator.can_identify-257"><a href="#Generator.can_identify-257"><span class="linenos">257</span></a><span class="sd"> Returns:</span> +</span><span id="Generator.can_identify-258"><a href="#Generator.can_identify-258"><span class="linenos">258</span></a><span class="sd"> Whether or not the given text can be identified.</span> +</span><span id="Generator.can_identify-259"><a href="#Generator.can_identify-259"><span class="linenos">259</span></a><span class="sd"> """</span> +</span><span id="Generator.can_identify-260"><a href="#Generator.can_identify-260"><span class="linenos">260</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> +</span><span id="Generator.can_identify-261"><a href="#Generator.can_identify-261"><span class="linenos">261</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Generator.can_identify-262"><a href="#Generator.can_identify-262"><span class="linenos">262</span></a> +</span><span id="Generator.can_identify-263"><a href="#Generator.can_identify-263"><span class="linenos">263</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> +</span><span id="Generator.can_identify-264"><a href="#Generator.can_identify-264"><span class="linenos">264</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="bp">cls</span><span class="o">.</span><span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">)</span> +</span><span id="Generator.can_identify-265"><a href="#Generator.can_identify-265"><span class="linenos">265</span></a> +</span><span id="Generator.can_identify-266"><a href="#Generator.can_identify-266"><span class="linenos">266</span></a> <span class="k">return</span> <span class="kc">False</span> +</span></pre></div> + + + <div class="docstring"><p>Checks if text can be identified given an identify option.</p> +<h6 id="arguments">Arguments:</h6> + +<ul> +<li><strong>text:</strong> The text to check.</li> +<li><strong>identify:</strong> "always" or <code>True</code>: Always returns true. +"safe": True if the identifier is case-insensitive.</li> +</ul> + +<h6 id="returns">Returns:</h6> + +<blockquote> + <p>Whether or not the given text can be identified.</p> +</blockquote> +</div> - </div> <div id="Generator.generate" class="classattr"> @@ -5624,41 +5750,41 @@ Default: True</li> </div> <a class="headerlink" href="#Generator.generate"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.generate-340"><a href="#Generator.generate-340"><span class="linenos">340</span></a> <span class="k">def</span> <span class="nf">generate</span><span class="p">(</span> -</span><span id="Generator.generate-341"><a href="#Generator.generate-341"><span class="linenos">341</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator.generate-342"><a href="#Generator.generate-342"><span class="linenos">342</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> -</span><span id="Generator.generate-343"><a href="#Generator.generate-343"><span class="linenos">343</span></a> <span class="n">cache</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.generate-344"><a href="#Generator.generate-344"><span class="linenos">344</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.generate-345"><a href="#Generator.generate-345"><span class="linenos">345</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Generator.generate-346"><a href="#Generator.generate-346"><span class="linenos">346</span></a><span class="sd"> Generates the SQL string corresponding to the given syntax tree.</span> -</span><span id="Generator.generate-347"><a href="#Generator.generate-347"><span class="linenos">347</span></a> -</span><span id="Generator.generate-348"><a href="#Generator.generate-348"><span class="linenos">348</span></a><span class="sd"> Args:</span> -</span><span id="Generator.generate-349"><a href="#Generator.generate-349"><span class="linenos">349</span></a><span class="sd"> expression: The syntax tree.</span> -</span><span id="Generator.generate-350"><a href="#Generator.generate-350"><span class="linenos">350</span></a><span class="sd"> cache: An optional sql string cache. This leverages the hash of an Expression</span> -</span><span id="Generator.generate-351"><a href="#Generator.generate-351"><span class="linenos">351</span></a><span class="sd"> which can be slow to compute, so only use it if you set _hash on each node.</span> -</span><span id="Generator.generate-352"><a href="#Generator.generate-352"><span class="linenos">352</span></a> -</span><span id="Generator.generate-353"><a href="#Generator.generate-353"><span class="linenos">353</span></a><span class="sd"> Returns:</span> -</span><span id="Generator.generate-354"><a href="#Generator.generate-354"><span class="linenos">354</span></a><span class="sd"> The SQL string corresponding to `expression`.</span> -</span><span id="Generator.generate-355"><a href="#Generator.generate-355"><span class="linenos">355</span></a><span class="sd"> """</span> -</span><span id="Generator.generate-356"><a href="#Generator.generate-356"><span class="linenos">356</span></a> <span class="k">if</span> <span class="n">cache</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.generate-357"><a href="#Generator.generate-357"><span class="linenos">357</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="o">=</span> <span class="n">cache</span> -</span><span id="Generator.generate-358"><a href="#Generator.generate-358"><span class="linenos">358</span></a> -</span><span id="Generator.generate-359"><a href="#Generator.generate-359"><span class="linenos">359</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator.generate-360"><a href="#Generator.generate-360"><span class="linenos">360</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="Generator.generate-361"><a href="#Generator.generate-361"><span class="linenos">361</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Generator.generate-362"><a href="#Generator.generate-362"><span class="linenos">362</span></a> -</span><span id="Generator.generate-363"><a href="#Generator.generate-363"><span class="linenos">363</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IGNORE</span><span class="p">:</span> -</span><span id="Generator.generate-364"><a href="#Generator.generate-364"><span class="linenos">364</span></a> <span class="k">return</span> <span class="n">sql</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.generate-347"><a href="#Generator.generate-347"><span class="linenos">347</span></a> <span class="k">def</span> <span class="nf">generate</span><span class="p">(</span> +</span><span id="Generator.generate-348"><a href="#Generator.generate-348"><span class="linenos">348</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator.generate-349"><a href="#Generator.generate-349"><span class="linenos">349</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> +</span><span id="Generator.generate-350"><a href="#Generator.generate-350"><span class="linenos">350</span></a> <span class="n">cache</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.generate-351"><a href="#Generator.generate-351"><span class="linenos">351</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.generate-352"><a href="#Generator.generate-352"><span class="linenos">352</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Generator.generate-353"><a href="#Generator.generate-353"><span class="linenos">353</span></a><span class="sd"> Generates the SQL string corresponding to the given syntax tree.</span> +</span><span id="Generator.generate-354"><a href="#Generator.generate-354"><span class="linenos">354</span></a> +</span><span id="Generator.generate-355"><a href="#Generator.generate-355"><span class="linenos">355</span></a><span class="sd"> Args:</span> +</span><span id="Generator.generate-356"><a href="#Generator.generate-356"><span class="linenos">356</span></a><span class="sd"> expression: The syntax tree.</span> +</span><span id="Generator.generate-357"><a href="#Generator.generate-357"><span class="linenos">357</span></a><span class="sd"> cache: An optional sql string cache. This leverages the hash of an Expression</span> +</span><span id="Generator.generate-358"><a href="#Generator.generate-358"><span class="linenos">358</span></a><span class="sd"> which can be slow to compute, so only use it if you set _hash on each node.</span> +</span><span id="Generator.generate-359"><a href="#Generator.generate-359"><span class="linenos">359</span></a> +</span><span id="Generator.generate-360"><a href="#Generator.generate-360"><span class="linenos">360</span></a><span class="sd"> Returns:</span> +</span><span id="Generator.generate-361"><a href="#Generator.generate-361"><span class="linenos">361</span></a><span class="sd"> The SQL string corresponding to `expression`.</span> +</span><span id="Generator.generate-362"><a href="#Generator.generate-362"><span class="linenos">362</span></a><span class="sd"> """</span> +</span><span id="Generator.generate-363"><a href="#Generator.generate-363"><span class="linenos">363</span></a> <span class="k">if</span> <span class="n">cache</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.generate-364"><a href="#Generator.generate-364"><span class="linenos">364</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="o">=</span> <span class="n">cache</span> </span><span id="Generator.generate-365"><a href="#Generator.generate-365"><span class="linenos">365</span></a> -</span><span id="Generator.generate-366"><a href="#Generator.generate-366"><span class="linenos">366</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">:</span> -</span><span id="Generator.generate-367"><a href="#Generator.generate-367"><span class="linenos">367</span></a> <span class="k">for</span> <span class="n">msg</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> -</span><span id="Generator.generate-368"><a href="#Generator.generate-368"><span class="linenos">368</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> -</span><span id="Generator.generate-369"><a href="#Generator.generate-369"><span class="linenos">369</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">RAISE</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> -</span><span id="Generator.generate-370"><a href="#Generator.generate-370"><span class="linenos">370</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">concat_messages</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span><span class="p">))</span> -</span><span id="Generator.generate-371"><a href="#Generator.generate-371"><span class="linenos">371</span></a> -</span><span id="Generator.generate-372"><a href="#Generator.generate-372"><span class="linenos">372</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="Generator.generate-373"><a href="#Generator.generate-373"><span class="linenos">373</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">,</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.generate-374"><a href="#Generator.generate-374"><span class="linenos">374</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator.generate-366"><a href="#Generator.generate-366"><span class="linenos">366</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator.generate-367"><a href="#Generator.generate-367"><span class="linenos">367</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="Generator.generate-368"><a href="#Generator.generate-368"><span class="linenos">368</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Generator.generate-369"><a href="#Generator.generate-369"><span class="linenos">369</span></a> +</span><span id="Generator.generate-370"><a href="#Generator.generate-370"><span class="linenos">370</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IGNORE</span><span class="p">:</span> +</span><span id="Generator.generate-371"><a href="#Generator.generate-371"><span class="linenos">371</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator.generate-372"><a href="#Generator.generate-372"><span class="linenos">372</span></a> +</span><span id="Generator.generate-373"><a href="#Generator.generate-373"><span class="linenos">373</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">:</span> +</span><span id="Generator.generate-374"><a href="#Generator.generate-374"><span class="linenos">374</span></a> <span class="k">for</span> <span class="n">msg</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> +</span><span id="Generator.generate-375"><a href="#Generator.generate-375"><span class="linenos">375</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> +</span><span id="Generator.generate-376"><a href="#Generator.generate-376"><span class="linenos">376</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">RAISE</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">:</span> +</span><span id="Generator.generate-377"><a href="#Generator.generate-377"><span class="linenos">377</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">concat_messages</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_unsupported</span><span class="p">))</span> +</span><span id="Generator.generate-378"><a href="#Generator.generate-378"><span class="linenos">378</span></a> +</span><span id="Generator.generate-379"><a href="#Generator.generate-379"><span class="linenos">379</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="Generator.generate-380"><a href="#Generator.generate-380"><span class="linenos">380</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">,</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.generate-381"><a href="#Generator.generate-381"><span class="linenos">381</span></a> <span class="k">return</span> <span class="n">sql</span> </span></pre></div> @@ -5692,10 +5818,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.unsupported"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.unsupported-376"><a href="#Generator.unsupported-376"><span class="linenos">376</span></a> <span class="k">def</span> <span class="nf">unsupported</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.unsupported-377"><a href="#Generator.unsupported-377"><span class="linenos">377</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span><span class="p">:</span> -</span><span id="Generator.unsupported-378"><a href="#Generator.unsupported-378"><span class="linenos">378</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> -</span><span id="Generator.unsupported-379"><a href="#Generator.unsupported-379"><span class="linenos">379</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.unsupported-383"><a href="#Generator.unsupported-383"><span class="linenos">383</span></a> <span class="k">def</span> <span class="nf">unsupported</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.unsupported-384"><a href="#Generator.unsupported-384"><span class="linenos">384</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span><span class="p">:</span> +</span><span id="Generator.unsupported-385"><a href="#Generator.unsupported-385"><span class="linenos">385</span></a> <span class="k">raise</span> <span class="n">UnsupportedError</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> +</span><span id="Generator.unsupported-386"><a href="#Generator.unsupported-386"><span class="linenos">386</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported_messages</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> </span></pre></div> @@ -5713,8 +5839,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.sep"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sep-381"><a href="#Generator.sep-381"><span class="linenos">381</span></a> <span class="k">def</span> <span class="nf">sep</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.sep-382"><a href="#Generator.sep-382"><span class="linenos">382</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="n">sep</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sep-388"><a href="#Generator.sep-388"><span class="linenos">388</span></a> <span class="k">def</span> <span class="nf">sep</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.sep-389"><a href="#Generator.sep-389"><span class="linenos">389</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="n">sep</span> </span></pre></div> @@ -5732,8 +5858,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.seg"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.seg-384"><a href="#Generator.seg-384"><span class="linenos">384</span></a> <span class="k">def</span> <span class="nf">seg</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.seg-385"><a href="#Generator.seg-385"><span class="linenos">385</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.seg-391"><a href="#Generator.seg-391"><span class="linenos">391</span></a> <span class="k">def</span> <span class="nf">seg</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.seg-392"><a href="#Generator.seg-392"><span class="linenos">392</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -5751,10 +5877,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.pad_comment"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.pad_comment-387"><a href="#Generator.pad_comment-387"><span class="linenos">387</span></a> <span class="k">def</span> <span class="nf">pad_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">comment</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.pad_comment-388"><a href="#Generator.pad_comment-388"><span class="linenos">388</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">+</span> <span class="n">comment</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> -</span><span id="Generator.pad_comment-389"><a href="#Generator.pad_comment-389"><span class="linenos">389</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="n">comment</span> <span class="o">+</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> -</span><span id="Generator.pad_comment-390"><a href="#Generator.pad_comment-390"><span class="linenos">390</span></a> <span class="k">return</span> <span class="n">comment</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.pad_comment-394"><a href="#Generator.pad_comment-394"><span class="linenos">394</span></a> <span class="k">def</span> <span class="nf">pad_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">comment</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.pad_comment-395"><a href="#Generator.pad_comment-395"><span class="linenos">395</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">+</span> <span class="n">comment</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> +</span><span id="Generator.pad_comment-396"><a href="#Generator.pad_comment-396"><span class="linenos">396</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="n">comment</span> <span class="o">+</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">comment</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">else</span> <span class="n">comment</span> +</span><span id="Generator.pad_comment-397"><a href="#Generator.pad_comment-397"><span class="linenos">397</span></a> <span class="k">return</span> <span class="n">comment</span> </span></pre></div> @@ -5772,37 +5898,37 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.maybe_comment"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.maybe_comment-392"><a href="#Generator.maybe_comment-392"><span class="linenos">392</span></a> <span class="k">def</span> <span class="nf">maybe_comment</span><span class="p">(</span> -</span><span id="Generator.maybe_comment-393"><a href="#Generator.maybe_comment-393"><span class="linenos">393</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator.maybe_comment-394"><a href="#Generator.maybe_comment-394"><span class="linenos">394</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="Generator.maybe_comment-395"><a href="#Generator.maybe_comment-395"><span class="linenos">395</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.maybe_comment-396"><a href="#Generator.maybe_comment-396"><span class="linenos">396</span></a> <span class="n">comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.maybe_comment-397"><a href="#Generator.maybe_comment-397"><span class="linenos">397</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.maybe_comment-398"><a href="#Generator.maybe_comment-398"><span class="linenos">398</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.maybe_comment-399"><a href="#Generator.maybe_comment-399"><span class="linenos">399</span></a> <span class="p">((</span><span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> <span class="k">if</span> <span class="n">comments</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">comments</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="Generator.maybe_comment-400"><a href="#Generator.maybe_comment-400"><span class="linenos">400</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> -</span><span id="Generator.maybe_comment-401"><a href="#Generator.maybe_comment-401"><span class="linenos">401</span></a> <span class="k">else</span> <span class="kc">None</span> -</span><span id="Generator.maybe_comment-402"><a href="#Generator.maybe_comment-402"><span class="linenos">402</span></a> <span class="p">)</span> -</span><span id="Generator.maybe_comment-403"><a href="#Generator.maybe_comment-403"><span class="linenos">403</span></a> -</span><span id="Generator.maybe_comment-404"><a href="#Generator.maybe_comment-404"><span class="linenos">404</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Binary</span><span class="p">):</span> -</span><span id="Generator.maybe_comment-405"><a href="#Generator.maybe_comment-405"><span class="linenos">405</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="Generator.maybe_comment-406"><a href="#Generator.maybe_comment-406"><span class="linenos">406</span></a> -</span><span id="Generator.maybe_comment-407"><a href="#Generator.maybe_comment-407"><span class="linenos">407</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator.maybe_comment-408"><a href="#Generator.maybe_comment-408"><span class="linenos">408</span></a> <span class="n">comments_sql</span> <span class="o">=</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator.maybe_comment-409"><a href="#Generator.maybe_comment-409"><span class="linenos">409</span></a> <span class="sa">f</span><span class="s2">"/*</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">pad_comment</span><span class="p">(</span><span class="n">comment</span><span class="p">)</span><span class="si">}</span><span class="s2">*/"</span> <span class="k">for</span> <span class="n">comment</span> <span class="ow">in</span> <span class="n">comments</span> <span class="k">if</span> <span class="n">comment</span> -</span><span id="Generator.maybe_comment-410"><a href="#Generator.maybe_comment-410"><span class="linenos">410</span></a> <span class="p">)</span> -</span><span id="Generator.maybe_comment-411"><a href="#Generator.maybe_comment-411"><span class="linenos">411</span></a> -</span><span id="Generator.maybe_comment-412"><a href="#Generator.maybe_comment-412"><span class="linenos">412</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments_sql</span><span class="p">:</span> -</span><span id="Generator.maybe_comment-413"><a href="#Generator.maybe_comment-413"><span class="linenos">413</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="Generator.maybe_comment-414"><a href="#Generator.maybe_comment-414"><span class="linenos">414</span></a> -</span><span id="Generator.maybe_comment-415"><a href="#Generator.maybe_comment-415"><span class="linenos">415</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">):</span> -</span><span id="Generator.maybe_comment-416"><a href="#Generator.maybe_comment-416"><span class="linenos">416</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="Generator.maybe_comment-417"><a href="#Generator.maybe_comment-417"><span class="linenos">417</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">comments_sql</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.maybe_comment-418"><a href="#Generator.maybe_comment-418"><span class="linenos">418</span></a> <span class="k">if</span> <span class="n">sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">isspace</span><span class="p">()</span> -</span><span id="Generator.maybe_comment-419"><a href="#Generator.maybe_comment-419"><span class="linenos">419</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">comments_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.maybe_comment-420"><a href="#Generator.maybe_comment-420"><span class="linenos">420</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.maybe_comment-399"><a href="#Generator.maybe_comment-399"><span class="linenos">399</span></a> <span class="k">def</span> <span class="nf">maybe_comment</span><span class="p">(</span> +</span><span id="Generator.maybe_comment-400"><a href="#Generator.maybe_comment-400"><span class="linenos">400</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator.maybe_comment-401"><a href="#Generator.maybe_comment-401"><span class="linenos">401</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="Generator.maybe_comment-402"><a href="#Generator.maybe_comment-402"><span class="linenos">402</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.maybe_comment-403"><a href="#Generator.maybe_comment-403"><span class="linenos">403</span></a> <span class="n">comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.maybe_comment-404"><a href="#Generator.maybe_comment-404"><span class="linenos">404</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.maybe_comment-405"><a href="#Generator.maybe_comment-405"><span class="linenos">405</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.maybe_comment-406"><a href="#Generator.maybe_comment-406"><span class="linenos">406</span></a> <span class="p">((</span><span class="n">expression</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> <span class="k">if</span> <span class="n">comments</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">comments</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="Generator.maybe_comment-407"><a href="#Generator.maybe_comment-407"><span class="linenos">407</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> +</span><span id="Generator.maybe_comment-408"><a href="#Generator.maybe_comment-408"><span class="linenos">408</span></a> <span class="k">else</span> <span class="kc">None</span> +</span><span id="Generator.maybe_comment-409"><a href="#Generator.maybe_comment-409"><span class="linenos">409</span></a> <span class="p">)</span> +</span><span id="Generator.maybe_comment-410"><a href="#Generator.maybe_comment-410"><span class="linenos">410</span></a> +</span><span id="Generator.maybe_comment-411"><a href="#Generator.maybe_comment-411"><span class="linenos">411</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Binary</span><span class="p">):</span> +</span><span id="Generator.maybe_comment-412"><a href="#Generator.maybe_comment-412"><span class="linenos">412</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator.maybe_comment-413"><a href="#Generator.maybe_comment-413"><span class="linenos">413</span></a> +</span><span id="Generator.maybe_comment-414"><a href="#Generator.maybe_comment-414"><span class="linenos">414</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator.maybe_comment-415"><a href="#Generator.maybe_comment-415"><span class="linenos">415</span></a> <span class="n">comments_sql</span> <span class="o">=</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator.maybe_comment-416"><a href="#Generator.maybe_comment-416"><span class="linenos">416</span></a> <span class="sa">f</span><span class="s2">"/*</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">pad_comment</span><span class="p">(</span><span class="n">comment</span><span class="p">)</span><span class="si">}</span><span class="s2">*/"</span> <span class="k">for</span> <span class="n">comment</span> <span class="ow">in</span> <span class="n">comments</span> <span class="k">if</span> <span class="n">comment</span> +</span><span id="Generator.maybe_comment-417"><a href="#Generator.maybe_comment-417"><span class="linenos">417</span></a> <span class="p">)</span> +</span><span id="Generator.maybe_comment-418"><a href="#Generator.maybe_comment-418"><span class="linenos">418</span></a> +</span><span id="Generator.maybe_comment-419"><a href="#Generator.maybe_comment-419"><span class="linenos">419</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">comments_sql</span><span class="p">:</span> +</span><span id="Generator.maybe_comment-420"><a href="#Generator.maybe_comment-420"><span class="linenos">420</span></a> <span class="k">return</span> <span class="n">sql</span> </span><span id="Generator.maybe_comment-421"><a href="#Generator.maybe_comment-421"><span class="linenos">421</span></a> -</span><span id="Generator.maybe_comment-422"><a href="#Generator.maybe_comment-422"><span class="linenos">422</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">comments_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.maybe_comment-422"><a href="#Generator.maybe_comment-422"><span class="linenos">422</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">WITH_SEPARATED_COMMENTS</span><span class="p">):</span> +</span><span id="Generator.maybe_comment-423"><a href="#Generator.maybe_comment-423"><span class="linenos">423</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="Generator.maybe_comment-424"><a href="#Generator.maybe_comment-424"><span class="linenos">424</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">comments_sql</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.maybe_comment-425"><a href="#Generator.maybe_comment-425"><span class="linenos">425</span></a> <span class="k">if</span> <span class="n">sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">isspace</span><span class="p">()</span> +</span><span id="Generator.maybe_comment-426"><a href="#Generator.maybe_comment-426"><span class="linenos">426</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">comments_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.maybe_comment-427"><a href="#Generator.maybe_comment-427"><span class="linenos">427</span></a> <span class="p">)</span> +</span><span id="Generator.maybe_comment-428"><a href="#Generator.maybe_comment-428"><span class="linenos">428</span></a> +</span><span id="Generator.maybe_comment-429"><a href="#Generator.maybe_comment-429"><span class="linenos">429</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">comments_sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -5820,15 +5946,15 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.wrap"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.wrap-424"><a href="#Generator.wrap-424"><span class="linenos">424</span></a> <span class="k">def</span> <span class="nf">wrap</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">|</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.wrap-425"><a href="#Generator.wrap-425"><span class="linenos">425</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span> -</span><span id="Generator.wrap-426"><a href="#Generator.wrap-426"><span class="linenos">426</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.wrap-427"><a href="#Generator.wrap-427"><span class="linenos">427</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">))</span> -</span><span id="Generator.wrap-428"><a href="#Generator.wrap-428"><span class="linenos">428</span></a> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> -</span><span id="Generator.wrap-429"><a href="#Generator.wrap-429"><span class="linenos">429</span></a> <span class="n">level</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> -</span><span id="Generator.wrap-430"><a href="#Generator.wrap-430"><span class="linenos">430</span></a> <span class="n">pad</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> -</span><span id="Generator.wrap-431"><a href="#Generator.wrap-431"><span class="linenos">431</span></a> <span class="p">)</span> -</span><span id="Generator.wrap-432"><a href="#Generator.wrap-432"><span class="linenos">432</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">this_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.wrap-431"><a href="#Generator.wrap-431"><span class="linenos">431</span></a> <span class="k">def</span> <span class="nf">wrap</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">|</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.wrap-432"><a href="#Generator.wrap-432"><span class="linenos">432</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span> +</span><span id="Generator.wrap-433"><a href="#Generator.wrap-433"><span class="linenos">433</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.wrap-434"><a href="#Generator.wrap-434"><span class="linenos">434</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">))</span> +</span><span id="Generator.wrap-435"><a href="#Generator.wrap-435"><span class="linenos">435</span></a> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> +</span><span id="Generator.wrap-436"><a href="#Generator.wrap-436"><span class="linenos">436</span></a> <span class="n">level</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> +</span><span id="Generator.wrap-437"><a href="#Generator.wrap-437"><span class="linenos">437</span></a> <span class="n">pad</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> +</span><span id="Generator.wrap-438"><a href="#Generator.wrap-438"><span class="linenos">438</span></a> <span class="p">)</span> +</span><span id="Generator.wrap-439"><a href="#Generator.wrap-439"><span class="linenos">439</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">this_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -5846,12 +5972,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.no_identify"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.no_identify-434"><a href="#Generator.no_identify-434"><span class="linenos">434</span></a> <span class="k">def</span> <span class="nf">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">func</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.no_identify-435"><a href="#Generator.no_identify-435"><span class="linenos">435</span></a> <span class="n">original</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> -</span><span id="Generator.no_identify-436"><a href="#Generator.no_identify-436"><span class="linenos">436</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Generator.no_identify-437"><a href="#Generator.no_identify-437"><span class="linenos">437</span></a> <span class="n">result</span> <span class="o">=</span> <span class="n">func</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="Generator.no_identify-438"><a href="#Generator.no_identify-438"><span class="linenos">438</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">original</span> -</span><span id="Generator.no_identify-439"><a href="#Generator.no_identify-439"><span class="linenos">439</span></a> <span class="k">return</span> <span class="n">result</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.no_identify-441"><a href="#Generator.no_identify-441"><span class="linenos">441</span></a> <span class="k">def</span> <span class="nf">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">func</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.no_identify-442"><a href="#Generator.no_identify-442"><span class="linenos">442</span></a> <span class="n">original</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> +</span><span id="Generator.no_identify-443"><a href="#Generator.no_identify-443"><span class="linenos">443</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Generator.no_identify-444"><a href="#Generator.no_identify-444"><span class="linenos">444</span></a> <span class="n">result</span> <span class="o">=</span> <span class="n">func</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="Generator.no_identify-445"><a href="#Generator.no_identify-445"><span class="linenos">445</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span> <span class="o">=</span> <span class="n">original</span> +</span><span id="Generator.no_identify-446"><a href="#Generator.no_identify-446"><span class="linenos">446</span></a> <span class="k">return</span> <span class="n">result</span> </span></pre></div> @@ -5869,12 +5995,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.normalize_func"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.normalize_func-441"><a href="#Generator.normalize_func-441"><span class="linenos">441</span></a> <span class="k">def</span> <span class="nf">normalize_func</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.normalize_func-442"><a href="#Generator.normalize_func-442"><span class="linenos">442</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"upper"</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Generator.normalize_func-443"><a href="#Generator.normalize_func-443"><span class="linenos">443</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Generator.normalize_func-444"><a href="#Generator.normalize_func-444"><span class="linenos">444</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"lower"</span><span class="p">:</span> -</span><span id="Generator.normalize_func-445"><a href="#Generator.normalize_func-445"><span class="linenos">445</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="Generator.normalize_func-446"><a href="#Generator.normalize_func-446"><span class="linenos">446</span></a> <span class="k">return</span> <span class="n">name</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.normalize_func-448"><a href="#Generator.normalize_func-448"><span class="linenos">448</span></a> <span class="k">def</span> <span class="nf">normalize_func</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.normalize_func-449"><a href="#Generator.normalize_func-449"><span class="linenos">449</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"upper"</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Generator.normalize_func-450"><a href="#Generator.normalize_func-450"><span class="linenos">450</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Generator.normalize_func-451"><a href="#Generator.normalize_func-451"><span class="linenos">451</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span> <span class="o">==</span> <span class="s2">"lower"</span><span class="p">:</span> +</span><span id="Generator.normalize_func-452"><a href="#Generator.normalize_func-452"><span class="linenos">452</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> +</span><span id="Generator.normalize_func-453"><a href="#Generator.normalize_func-453"><span class="linenos">453</span></a> <span class="k">return</span> <span class="n">name</span> </span></pre></div> @@ -5892,26 +6018,26 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.indent"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.indent-448"><a href="#Generator.indent-448"><span class="linenos">448</span></a> <span class="k">def</span> <span class="nf">indent</span><span class="p">(</span> -</span><span id="Generator.indent-449"><a href="#Generator.indent-449"><span class="linenos">449</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator.indent-450"><a href="#Generator.indent-450"><span class="linenos">450</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="Generator.indent-451"><a href="#Generator.indent-451"><span class="linenos">451</span></a> <span class="n">level</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> -</span><span id="Generator.indent-452"><a href="#Generator.indent-452"><span class="linenos">452</span></a> <span class="n">pad</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.indent-453"><a href="#Generator.indent-453"><span class="linenos">453</span></a> <span class="n">skip_first</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Generator.indent-454"><a href="#Generator.indent-454"><span class="linenos">454</span></a> <span class="n">skip_last</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Generator.indent-455"><a href="#Generator.indent-455"><span class="linenos">455</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.indent-456"><a href="#Generator.indent-456"><span class="linenos">456</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="Generator.indent-457"><a href="#Generator.indent-457"><span class="linenos">457</span></a> <span class="k">return</span> <span class="n">sql</span> -</span><span id="Generator.indent-458"><a href="#Generator.indent-458"><span class="linenos">458</span></a> -</span><span id="Generator.indent-459"><a href="#Generator.indent-459"><span class="linenos">459</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="k">if</span> <span class="n">pad</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">pad</span> -</span><span id="Generator.indent-460"><a href="#Generator.indent-460"><span class="linenos">460</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.indent-461"><a href="#Generator.indent-461"><span class="linenos">461</span></a> -</span><span id="Generator.indent-462"><a href="#Generator.indent-462"><span class="linenos">462</span></a> <span class="k">return</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator.indent-463"><a href="#Generator.indent-463"><span class="linenos">463</span></a> <span class="n">line</span> -</span><span id="Generator.indent-464"><a href="#Generator.indent-464"><span class="linenos">464</span></a> <span class="k">if</span> <span class="p">(</span><span class="n">skip_first</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">skip_last</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="Generator.indent-465"><a href="#Generator.indent-465"><span class="linenos">465</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' '</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="n">level</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="bp">self</span><span class="o">.</span><span class="n">_indent</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">pad</span><span class="p">)</span><span class="si">}{</span><span class="n">line</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.indent-466"><a href="#Generator.indent-466"><span class="linenos">466</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">line</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> -</span><span id="Generator.indent-467"><a href="#Generator.indent-467"><span class="linenos">467</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.indent-455"><a href="#Generator.indent-455"><span class="linenos">455</span></a> <span class="k">def</span> <span class="nf">indent</span><span class="p">(</span> +</span><span id="Generator.indent-456"><a href="#Generator.indent-456"><span class="linenos">456</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator.indent-457"><a href="#Generator.indent-457"><span class="linenos">457</span></a> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="Generator.indent-458"><a href="#Generator.indent-458"><span class="linenos">458</span></a> <span class="n">level</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> +</span><span id="Generator.indent-459"><a href="#Generator.indent-459"><span class="linenos">459</span></a> <span class="n">pad</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.indent-460"><a href="#Generator.indent-460"><span class="linenos">460</span></a> <span class="n">skip_first</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Generator.indent-461"><a href="#Generator.indent-461"><span class="linenos">461</span></a> <span class="n">skip_last</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Generator.indent-462"><a href="#Generator.indent-462"><span class="linenos">462</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.indent-463"><a href="#Generator.indent-463"><span class="linenos">463</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="Generator.indent-464"><a href="#Generator.indent-464"><span class="linenos">464</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator.indent-465"><a href="#Generator.indent-465"><span class="linenos">465</span></a> +</span><span id="Generator.indent-466"><a href="#Generator.indent-466"><span class="linenos">466</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="k">if</span> <span class="n">pad</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">pad</span> +</span><span id="Generator.indent-467"><a href="#Generator.indent-467"><span class="linenos">467</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="n">sql</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.indent-468"><a href="#Generator.indent-468"><span class="linenos">468</span></a> +</span><span id="Generator.indent-469"><a href="#Generator.indent-469"><span class="linenos">469</span></a> <span class="k">return</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator.indent-470"><a href="#Generator.indent-470"><span class="linenos">470</span></a> <span class="n">line</span> +</span><span id="Generator.indent-471"><a href="#Generator.indent-471"><span class="linenos">471</span></a> <span class="k">if</span> <span class="p">(</span><span class="n">skip_first</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">skip_last</span> <span class="ow">and</span> <span class="n">i</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="Generator.indent-472"><a href="#Generator.indent-472"><span class="linenos">472</span></a> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' '</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="p">(</span><span class="n">level</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="bp">self</span><span class="o">.</span><span class="n">_indent</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">pad</span><span class="p">)</span><span class="si">}{</span><span class="n">line</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.indent-473"><a href="#Generator.indent-473"><span class="linenos">473</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">line</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> +</span><span id="Generator.indent-474"><a href="#Generator.indent-474"><span class="linenos">474</span></a> <span class="p">)</span> </span></pre></div> @@ -5929,52 +6055,52 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sql-469"><a href="#Generator.sql-469"><span class="linenos">469</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span> -</span><span id="Generator.sql-470"><a href="#Generator.sql-470"><span class="linenos">470</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator.sql-471"><a href="#Generator.sql-471"><span class="linenos">471</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> -</span><span id="Generator.sql-472"><a href="#Generator.sql-472"><span class="linenos">472</span></a> <span class="n">key</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.sql-473"><a href="#Generator.sql-473"><span class="linenos">473</span></a> <span class="n">comment</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Generator.sql-474"><a href="#Generator.sql-474"><span class="linenos">474</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.sql-475"><a href="#Generator.sql-475"><span class="linenos">475</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> -</span><span id="Generator.sql-476"><a href="#Generator.sql-476"><span class="linenos">476</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator.sql-477"><a href="#Generator.sql-477"><span class="linenos">477</span></a> -</span><span id="Generator.sql-478"><a href="#Generator.sql-478"><span class="linenos">478</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="Generator.sql-479"><a href="#Generator.sql-479"><span class="linenos">479</span></a> <span class="k">return</span> <span class="n">expression</span> -</span><span id="Generator.sql-480"><a href="#Generator.sql-480"><span class="linenos">480</span></a> -</span><span id="Generator.sql-481"><a href="#Generator.sql-481"><span class="linenos">481</span></a> <span class="k">if</span> <span class="n">key</span><span class="p">:</span> -</span><span id="Generator.sql-482"><a href="#Generator.sql-482"><span class="linenos">482</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="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">))</span> -</span><span id="Generator.sql-483"><a href="#Generator.sql-483"><span class="linenos">483</span></a> -</span><span id="Generator.sql-484"><a href="#Generator.sql-484"><span class="linenos">484</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.sql-485"><a href="#Generator.sql-485"><span class="linenos">485</span></a> <span class="n">expression_id</span> <span class="o">=</span> <span class="nb">hash</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.sql-486"><a href="#Generator.sql-486"><span class="linenos">486</span></a> -</span><span id="Generator.sql-487"><a href="#Generator.sql-487"><span class="linenos">487</span></a> <span class="k">if</span> <span class="n">expression_id</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">:</span> -</span><span id="Generator.sql-488"><a href="#Generator.sql-488"><span class="linenos">488</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">[</span><span class="n">expression_id</span><span class="p">]</span> -</span><span id="Generator.sql-489"><a href="#Generator.sql-489"><span class="linenos">489</span></a> -</span><span id="Generator.sql-490"><a href="#Generator.sql-490"><span class="linenos">490</span></a> <span class="n">transform</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span> -</span><span id="Generator.sql-491"><a href="#Generator.sql-491"><span class="linenos">491</span></a> -</span><span id="Generator.sql-492"><a href="#Generator.sql-492"><span class="linenos">492</span></a> <span class="k">if</span> <span class="nb">callable</span><span class="p">(</span><span class="n">transform</span><span class="p">):</span> -</span><span id="Generator.sql-493"><a href="#Generator.sql-493"><span class="linenos">493</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.sql-494"><a href="#Generator.sql-494"><span class="linenos">494</span></a> <span class="k">elif</span> <span class="n">transform</span><span class="p">:</span> -</span><span id="Generator.sql-495"><a href="#Generator.sql-495"><span class="linenos">495</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span> -</span><span id="Generator.sql-496"><a href="#Generator.sql-496"><span class="linenos">496</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> -</span><span id="Generator.sql-497"><a href="#Generator.sql-497"><span class="linenos">497</span></a> <span class="n">exp_handler_name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">_sql"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sql-476"><a href="#Generator.sql-476"><span class="linenos">476</span></a> <span class="k">def</span> <span class="nf">sql</span><span class="p">(</span> +</span><span id="Generator.sql-477"><a href="#Generator.sql-477"><span class="linenos">477</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator.sql-478"><a href="#Generator.sql-478"><span class="linenos">478</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> +</span><span id="Generator.sql-479"><a href="#Generator.sql-479"><span class="linenos">479</span></a> <span class="n">key</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.sql-480"><a href="#Generator.sql-480"><span class="linenos">480</span></a> <span class="n">comment</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Generator.sql-481"><a href="#Generator.sql-481"><span class="linenos">481</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.sql-482"><a href="#Generator.sql-482"><span class="linenos">482</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> +</span><span id="Generator.sql-483"><a href="#Generator.sql-483"><span class="linenos">483</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator.sql-484"><a href="#Generator.sql-484"><span class="linenos">484</span></a> +</span><span id="Generator.sql-485"><a href="#Generator.sql-485"><span class="linenos">485</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="Generator.sql-486"><a href="#Generator.sql-486"><span class="linenos">486</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="Generator.sql-487"><a href="#Generator.sql-487"><span class="linenos">487</span></a> +</span><span id="Generator.sql-488"><a href="#Generator.sql-488"><span class="linenos">488</span></a> <span class="k">if</span> <span class="n">key</span><span class="p">:</span> +</span><span id="Generator.sql-489"><a href="#Generator.sql-489"><span class="linenos">489</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="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">))</span> +</span><span id="Generator.sql-490"><a href="#Generator.sql-490"><span class="linenos">490</span></a> +</span><span id="Generator.sql-491"><a href="#Generator.sql-491"><span class="linenos">491</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.sql-492"><a href="#Generator.sql-492"><span class="linenos">492</span></a> <span class="n">expression_id</span> <span class="o">=</span> <span class="nb">hash</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.sql-493"><a href="#Generator.sql-493"><span class="linenos">493</span></a> +</span><span id="Generator.sql-494"><a href="#Generator.sql-494"><span class="linenos">494</span></a> <span class="k">if</span> <span class="n">expression_id</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">:</span> +</span><span id="Generator.sql-495"><a href="#Generator.sql-495"><span class="linenos">495</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">[</span><span class="n">expression_id</span><span class="p">]</span> +</span><span id="Generator.sql-496"><a href="#Generator.sql-496"><span class="linenos">496</span></a> +</span><span id="Generator.sql-497"><a href="#Generator.sql-497"><span class="linenos">497</span></a> <span class="n">transform</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TRANSFORMS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span> </span><span id="Generator.sql-498"><a href="#Generator.sql-498"><span class="linenos">498</span></a> -</span><span id="Generator.sql-499"><a href="#Generator.sql-499"><span class="linenos">499</span></a> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">):</span> -</span><span id="Generator.sql-500"><a href="#Generator.sql-500"><span class="linenos">500</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">)(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.sql-501"><a href="#Generator.sql-501"><span class="linenos">501</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Generator.sql-502"><a href="#Generator.sql-502"><span class="linenos">502</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.sql-503"><a href="#Generator.sql-503"><span class="linenos">503</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">):</span> -</span><span id="Generator.sql-504"><a href="#Generator.sql-504"><span class="linenos">504</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">property_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.sql-505"><a href="#Generator.sql-505"><span class="linenos">505</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.sql-506"><a href="#Generator.sql-506"><span class="linenos">506</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported expression type </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.sql-507"><a href="#Generator.sql-507"><span class="linenos">507</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.sql-508"><a href="#Generator.sql-508"><span class="linenos">508</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Expected an Expression. Received </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">expression</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.sql-509"><a href="#Generator.sql-509"><span class="linenos">509</span></a> -</span><span id="Generator.sql-510"><a href="#Generator.sql-510"><span class="linenos">510</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">sql</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="ow">and</span> <span class="n">comment</span> <span class="k">else</span> <span class="n">sql</span> -</span><span id="Generator.sql-511"><a href="#Generator.sql-511"><span class="linenos">511</span></a> -</span><span id="Generator.sql-512"><a href="#Generator.sql-512"><span class="linenos">512</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.sql-513"><a href="#Generator.sql-513"><span class="linenos">513</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">[</span><span class="n">expression_id</span><span class="p">]</span> <span class="o">=</span> <span class="n">sql</span> -</span><span id="Generator.sql-514"><a href="#Generator.sql-514"><span class="linenos">514</span></a> <span class="k">return</span> <span class="n">sql</span> +</span><span id="Generator.sql-499"><a href="#Generator.sql-499"><span class="linenos">499</span></a> <span class="k">if</span> <span class="nb">callable</span><span class="p">(</span><span class="n">transform</span><span class="p">):</span> +</span><span id="Generator.sql-500"><a href="#Generator.sql-500"><span class="linenos">500</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.sql-501"><a href="#Generator.sql-501"><span class="linenos">501</span></a> <span class="k">elif</span> <span class="n">transform</span><span class="p">:</span> +</span><span id="Generator.sql-502"><a href="#Generator.sql-502"><span class="linenos">502</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="n">transform</span> +</span><span id="Generator.sql-503"><a href="#Generator.sql-503"><span class="linenos">503</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">):</span> +</span><span id="Generator.sql-504"><a href="#Generator.sql-504"><span class="linenos">504</span></a> <span class="n">exp_handler_name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">_sql"</span> +</span><span id="Generator.sql-505"><a href="#Generator.sql-505"><span class="linenos">505</span></a> +</span><span id="Generator.sql-506"><a href="#Generator.sql-506"><span class="linenos">506</span></a> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">):</span> +</span><span id="Generator.sql-507"><a href="#Generator.sql-507"><span class="linenos">507</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_handler_name</span><span class="p">)(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.sql-508"><a href="#Generator.sql-508"><span class="linenos">508</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Generator.sql-509"><a href="#Generator.sql-509"><span class="linenos">509</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.sql-510"><a href="#Generator.sql-510"><span class="linenos">510</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">):</span> +</span><span id="Generator.sql-511"><a href="#Generator.sql-511"><span class="linenos">511</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">property_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.sql-512"><a href="#Generator.sql-512"><span class="linenos">512</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.sql-513"><a href="#Generator.sql-513"><span class="linenos">513</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported expression type </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.sql-514"><a href="#Generator.sql-514"><span class="linenos">514</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.sql-515"><a href="#Generator.sql-515"><span class="linenos">515</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Expected an Expression. Received </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">expression</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.sql-516"><a href="#Generator.sql-516"><span class="linenos">516</span></a> +</span><span id="Generator.sql-517"><a href="#Generator.sql-517"><span class="linenos">517</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">sql</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="ow">and</span> <span class="n">comment</span> <span class="k">else</span> <span class="n">sql</span> +</span><span id="Generator.sql-518"><a href="#Generator.sql-518"><span class="linenos">518</span></a> +</span><span id="Generator.sql-519"><a href="#Generator.sql-519"><span class="linenos">519</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.sql-520"><a href="#Generator.sql-520"><span class="linenos">520</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_cache</span><span class="p">[</span><span class="n">expression_id</span><span class="p">]</span> <span class="o">=</span> <span class="n">sql</span> +</span><span id="Generator.sql-521"><a href="#Generator.sql-521"><span class="linenos">521</span></a> <span class="k">return</span> <span class="n">sql</span> </span></pre></div> @@ -5992,10 +6118,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.uncache_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.uncache_sql-516"><a href="#Generator.uncache_sql-516"><span class="linenos">516</span></a> <span class="k">def</span> <span class="nf">uncache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Uncache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.uncache_sql-517"><a href="#Generator.uncache_sql-517"><span class="linenos">517</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.uncache_sql-518"><a href="#Generator.uncache_sql-518"><span class="linenos">518</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.uncache_sql-519"><a href="#Generator.uncache_sql-519"><span class="linenos">519</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNCACHE TABLE</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.uncache_sql-523"><a href="#Generator.uncache_sql-523"><span class="linenos">523</span></a> <span class="k">def</span> <span class="nf">uncache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Uncache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.uncache_sql-524"><a href="#Generator.uncache_sql-524"><span class="linenos">524</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.uncache_sql-525"><a href="#Generator.uncache_sql-525"><span class="linenos">525</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.uncache_sql-526"><a href="#Generator.uncache_sql-526"><span class="linenos">526</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNCACHE TABLE</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6013,15 +6139,15 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.cache_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.cache_sql-521"><a href="#Generator.cache_sql-521"><span class="linenos">521</span></a> <span class="k">def</span> <span class="nf">cache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.cache_sql-522"><a href="#Generator.cache_sql-522"><span class="linenos">522</span></a> <span class="n">lazy</span> <span class="o">=</span> <span class="s2">" LAZY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lazy"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.cache_sql-523"><a href="#Generator.cache_sql-523"><span class="linenos">523</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.cache_sql-524"><a href="#Generator.cache_sql-524"><span class="linenos">524</span></a> <span class="n">options</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"options"</span><span class="p">)</span> -</span><span id="Generator.cache_sql-525"><a href="#Generator.cache_sql-525"><span class="linenos">525</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OPTIONS(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span><span class="si">}</span><span class="s2"> = </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.cache_sql-526"><a href="#Generator.cache_sql-526"><span class="linenos">526</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator.cache_sql-527"><a href="#Generator.cache_sql-527"><span class="linenos">527</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.cache_sql-528"><a href="#Generator.cache_sql-528"><span class="linenos">528</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CACHE</span><span class="si">{</span><span class="n">lazy</span><span class="si">}</span><span class="s2"> TABLE </span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">options</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.cache_sql-529"><a href="#Generator.cache_sql-529"><span class="linenos">529</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.cache_sql-528"><a href="#Generator.cache_sql-528"><span class="linenos">528</span></a> <span class="k">def</span> <span class="nf">cache_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.cache_sql-529"><a href="#Generator.cache_sql-529"><span class="linenos">529</span></a> <span class="n">lazy</span> <span class="o">=</span> <span class="s2">" LAZY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lazy"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.cache_sql-530"><a href="#Generator.cache_sql-530"><span class="linenos">530</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.cache_sql-531"><a href="#Generator.cache_sql-531"><span class="linenos">531</span></a> <span class="n">options</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"options"</span><span class="p">)</span> +</span><span id="Generator.cache_sql-532"><a href="#Generator.cache_sql-532"><span class="linenos">532</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OPTIONS(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span><span class="si">}</span><span class="s2"> = </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">options</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.cache_sql-533"><a href="#Generator.cache_sql-533"><span class="linenos">533</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator.cache_sql-534"><a href="#Generator.cache_sql-534"><span class="linenos">534</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.cache_sql-535"><a href="#Generator.cache_sql-535"><span class="linenos">535</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CACHE</span><span class="si">{</span><span class="n">lazy</span><span class="si">}</span><span class="s2"> TABLE </span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">options</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.cache_sql-536"><a href="#Generator.cache_sql-536"><span class="linenos">536</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> </span></pre></div> @@ -6039,11 +6165,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.characterset_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.characterset_sql-531"><a href="#Generator.characterset_sql-531"><span class="linenos">531</span></a> <span class="k">def</span> <span class="nf">characterset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSet</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.characterset_sql-532"><a href="#Generator.characterset_sql-532"><span class="linenos">532</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> -</span><span id="Generator.characterset_sql-533"><a href="#Generator.characterset_sql-533"><span class="linenos">533</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHAR CHARACTER SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.characterset_sql-534"><a href="#Generator.characterset_sql-534"><span class="linenos">534</span></a> <span class="n">default</span> <span class="o">=</span> <span class="s2">"DEFAULT "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.characterset_sql-535"><a href="#Generator.characterset_sql-535"><span class="linenos">535</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">CHARACTER SET=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.characterset_sql-538"><a href="#Generator.characterset_sql-538"><span class="linenos">538</span></a> <span class="k">def</span> <span class="nf">characterset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSet</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.characterset_sql-539"><a href="#Generator.characterset_sql-539"><span class="linenos">539</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">):</span> +</span><span id="Generator.characterset_sql-540"><a href="#Generator.characterset_sql-540"><span class="linenos">540</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHAR CHARACTER SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.characterset_sql-541"><a href="#Generator.characterset_sql-541"><span class="linenos">541</span></a> <span class="n">default</span> <span class="o">=</span> <span class="s2">"DEFAULT "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.characterset_sql-542"><a href="#Generator.characterset_sql-542"><span class="linenos">542</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">CHARACTER SET=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6061,17 +6187,17 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.column_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.column_sql-537"><a href="#Generator.column_sql-537"><span class="linenos">537</span></a> <span class="k">def</span> <span class="nf">column_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.column_sql-538"><a href="#Generator.column_sql-538"><span class="linenos">538</span></a> <span class="k">return</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator.column_sql-539"><a href="#Generator.column_sql-539"><span class="linenos">539</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> -</span><span id="Generator.column_sql-540"><a href="#Generator.column_sql-540"><span class="linenos">540</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="Generator.column_sql-541"><a href="#Generator.column_sql-541"><span class="linenos">541</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">),</span> -</span><span id="Generator.column_sql-542"><a href="#Generator.column_sql-542"><span class="linenos">542</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"db"</span><span class="p">),</span> -</span><span id="Generator.column_sql-543"><a href="#Generator.column_sql-543"><span class="linenos">543</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"table"</span><span class="p">),</span> -</span><span id="Generator.column_sql-544"><a href="#Generator.column_sql-544"><span class="linenos">544</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"this"</span><span class="p">),</span> -</span><span id="Generator.column_sql-545"><a href="#Generator.column_sql-545"><span class="linenos">545</span></a> <span class="p">)</span> -</span><span id="Generator.column_sql-546"><a href="#Generator.column_sql-546"><span class="linenos">546</span></a> <span class="k">if</span> <span class="n">part</span> -</span><span id="Generator.column_sql-547"><a href="#Generator.column_sql-547"><span class="linenos">547</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.column_sql-544"><a href="#Generator.column_sql-544"><span class="linenos">544</span></a> <span class="k">def</span> <span class="nf">column_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.column_sql-545"><a href="#Generator.column_sql-545"><span class="linenos">545</span></a> <span class="k">return</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator.column_sql-546"><a href="#Generator.column_sql-546"><span class="linenos">546</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">part</span><span class="p">)</span> +</span><span id="Generator.column_sql-547"><a href="#Generator.column_sql-547"><span class="linenos">547</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="Generator.column_sql-548"><a href="#Generator.column_sql-548"><span class="linenos">548</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">),</span> +</span><span id="Generator.column_sql-549"><a href="#Generator.column_sql-549"><span class="linenos">549</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"db"</span><span class="p">),</span> +</span><span id="Generator.column_sql-550"><a href="#Generator.column_sql-550"><span class="linenos">550</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"table"</span><span class="p">),</span> +</span><span id="Generator.column_sql-551"><a href="#Generator.column_sql-551"><span class="linenos">551</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"this"</span><span class="p">),</span> +</span><span id="Generator.column_sql-552"><a href="#Generator.column_sql-552"><span class="linenos">552</span></a> <span class="p">)</span> +</span><span id="Generator.column_sql-553"><a href="#Generator.column_sql-553"><span class="linenos">553</span></a> <span class="k">if</span> <span class="n">part</span> +</span><span id="Generator.column_sql-554"><a href="#Generator.column_sql-554"><span class="linenos">554</span></a> <span class="p">)</span> </span></pre></div> @@ -6089,11 +6215,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.columnposition_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.columnposition_sql-549"><a href="#Generator.columnposition_sql-549"><span class="linenos">549</span></a> <span class="k">def</span> <span class="nf">columnposition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.columnposition_sql-550"><a href="#Generator.columnposition_sql-550"><span class="linenos">550</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.columnposition_sql-551"><a href="#Generator.columnposition_sql-551"><span class="linenos">551</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.columnposition_sql-552"><a href="#Generator.columnposition_sql-552"><span class="linenos">552</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> -</span><span id="Generator.columnposition_sql-553"><a href="#Generator.columnposition_sql-553"><span class="linenos">553</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">position</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.columnposition_sql-556"><a href="#Generator.columnposition_sql-556"><span class="linenos">556</span></a> <span class="k">def</span> <span class="nf">columnposition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnPosition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.columnposition_sql-557"><a href="#Generator.columnposition_sql-557"><span class="linenos">557</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.columnposition_sql-558"><a href="#Generator.columnposition_sql-558"><span class="linenos">558</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.columnposition_sql-559"><a href="#Generator.columnposition_sql-559"><span class="linenos">559</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> +</span><span id="Generator.columnposition_sql-560"><a href="#Generator.columnposition_sql-560"><span class="linenos">560</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">position</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6111,17 +6237,17 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.columndef_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.columndef_sql-555"><a href="#Generator.columndef_sql-555"><span class="linenos">555</span></a> <span class="k">def</span> <span class="nf">columndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.columndef_sql-556"><a href="#Generator.columndef_sql-556"><span class="linenos">556</span></a> <span class="n">column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.columndef_sql-557"><a href="#Generator.columndef_sql-557"><span class="linenos">557</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator.columndef_sql-558"><a href="#Generator.columndef_sql-558"><span class="linenos">558</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"constraints"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.columndef_sql-559"><a href="#Generator.columndef_sql-559"><span class="linenos">559</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">"IF NOT EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.columndef_sql-560"><a href="#Generator.columndef_sql-560"><span class="linenos">560</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.columndef_sql-561"><a href="#Generator.columndef_sql-561"><span class="linenos">561</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">constraints</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">constraints</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.columndef_sql-562"><a href="#Generator.columndef_sql-562"><span class="linenos">562</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> -</span><span id="Generator.columndef_sql-563"><a href="#Generator.columndef_sql-563"><span class="linenos">563</span></a> <span class="n">position</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">position</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.columndef_sql-564"><a href="#Generator.columndef_sql-564"><span class="linenos">564</span></a> -</span><span id="Generator.columndef_sql-565"><a href="#Generator.columndef_sql-565"><span class="linenos">565</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">column</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.columndef_sql-562"><a href="#Generator.columndef_sql-562"><span class="linenos">562</span></a> <span class="k">def</span> <span class="nf">columndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.columndef_sql-563"><a href="#Generator.columndef_sql-563"><span class="linenos">563</span></a> <span class="n">column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.columndef_sql-564"><a href="#Generator.columndef_sql-564"><span class="linenos">564</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator.columndef_sql-565"><a href="#Generator.columndef_sql-565"><span class="linenos">565</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"constraints"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.columndef_sql-566"><a href="#Generator.columndef_sql-566"><span class="linenos">566</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">"IF NOT EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.columndef_sql-567"><a href="#Generator.columndef_sql-567"><span class="linenos">567</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.columndef_sql-568"><a href="#Generator.columndef_sql-568"><span class="linenos">568</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">constraints</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">constraints</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.columndef_sql-569"><a href="#Generator.columndef_sql-569"><span class="linenos">569</span></a> <span class="n">position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> +</span><span id="Generator.columndef_sql-570"><a href="#Generator.columndef_sql-570"><span class="linenos">570</span></a> <span class="n">position</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">position</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.columndef_sql-571"><a href="#Generator.columndef_sql-571"><span class="linenos">571</span></a> +</span><span id="Generator.columndef_sql-572"><a href="#Generator.columndef_sql-572"><span class="linenos">572</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">column</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">position</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6139,10 +6265,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.columnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.columnconstraint_sql-567"><a href="#Generator.columnconstraint_sql-567"><span class="linenos">567</span></a> <span class="k">def</span> <span class="nf">columnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.columnconstraint_sql-568"><a href="#Generator.columnconstraint_sql-568"><span class="linenos">568</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.columnconstraint_sql-569"><a href="#Generator.columnconstraint_sql-569"><span class="linenos">569</span></a> <span class="n">kind_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="Generator.columnconstraint_sql-570"><a href="#Generator.columnconstraint_sql-570"><span class="linenos">570</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="n">kind_sql</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.columnconstraint_sql-574"><a href="#Generator.columnconstraint_sql-574"><span class="linenos">574</span></a> <span class="k">def</span> <span class="nf">columnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.columnconstraint_sql-575"><a href="#Generator.columnconstraint_sql-575"><span class="linenos">575</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.columnconstraint_sql-576"><a href="#Generator.columnconstraint_sql-576"><span class="linenos">576</span></a> <span class="n">kind_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="Generator.columnconstraint_sql-577"><a href="#Generator.columnconstraint_sql-577"><span class="linenos">577</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="n">kind_sql</span> </span></pre></div> @@ -6160,8 +6286,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.autoincrementcolumnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.autoincrementcolumnconstraint_sql-572"><a href="#Generator.autoincrementcolumnconstraint_sql-572"><span class="linenos">572</span></a> <span class="k">def</span> <span class="nf">autoincrementcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.autoincrementcolumnconstraint_sql-573"><a href="#Generator.autoincrementcolumnconstraint_sql-573"><span class="linenos">573</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">token_sql</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.autoincrementcolumnconstraint_sql-579"><a href="#Generator.autoincrementcolumnconstraint_sql-579"><span class="linenos">579</span></a> <span class="k">def</span> <span class="nf">autoincrementcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.autoincrementcolumnconstraint_sql-580"><a href="#Generator.autoincrementcolumnconstraint_sql-580"><span class="linenos">580</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">token_sql</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">)</span> </span></pre></div> @@ -6179,13 +6305,13 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.compresscolumnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.compresscolumnconstraint_sql-575"><a href="#Generator.compresscolumnconstraint_sql-575"><span class="linenos">575</span></a> <span class="k">def</span> <span class="nf">compresscolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CompressColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.compresscolumnconstraint_sql-576"><a href="#Generator.compresscolumnconstraint_sql-576"><span class="linenos">576</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="Generator.compresscolumnconstraint_sql-577"><a href="#Generator.compresscolumnconstraint_sql-577"><span class="linenos">577</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> -</span><span id="Generator.compresscolumnconstraint_sql-578"><a href="#Generator.compresscolumnconstraint_sql-578"><span class="linenos">578</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.compresscolumnconstraint_sql-579"><a href="#Generator.compresscolumnconstraint_sql-579"><span class="linenos">579</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.compresscolumnconstraint_sql-580"><a href="#Generator.compresscolumnconstraint_sql-580"><span class="linenos">580</span></a> -</span><span id="Generator.compresscolumnconstraint_sql-581"><a href="#Generator.compresscolumnconstraint_sql-581"><span class="linenos">581</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMPRESS </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.compresscolumnconstraint_sql-582"><a href="#Generator.compresscolumnconstraint_sql-582"><span class="linenos">582</span></a> <span class="k">def</span> <span class="nf">compresscolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CompressColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.compresscolumnconstraint_sql-583"><a href="#Generator.compresscolumnconstraint_sql-583"><span class="linenos">583</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="Generator.compresscolumnconstraint_sql-584"><a href="#Generator.compresscolumnconstraint_sql-584"><span class="linenos">584</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="Generator.compresscolumnconstraint_sql-585"><a href="#Generator.compresscolumnconstraint_sql-585"><span class="linenos">585</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.compresscolumnconstraint_sql-586"><a href="#Generator.compresscolumnconstraint_sql-586"><span class="linenos">586</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.compresscolumnconstraint_sql-587"><a href="#Generator.compresscolumnconstraint_sql-587"><span class="linenos">587</span></a> +</span><span id="Generator.compresscolumnconstraint_sql-588"><a href="#Generator.compresscolumnconstraint_sql-588"><span class="linenos">588</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMPRESS </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6203,38 +6329,38 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.generatedasidentitycolumnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.generatedasidentitycolumnconstraint_sql-583"><a href="#Generator.generatedasidentitycolumnconstraint_sql-583"><span class="linenos">583</span></a> <span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-584"><a href="#Generator.generatedasidentitycolumnconstraint_sql-584"><span class="linenos">584</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-585"><a href="#Generator.generatedasidentitycolumnconstraint_sql-585"><span class="linenos">585</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-586"><a href="#Generator.generatedasidentitycolumnconstraint_sql-586"><span class="linenos">586</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-587"><a href="#Generator.generatedasidentitycolumnconstraint_sql-587"><span class="linenos">587</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-588"><a href="#Generator.generatedasidentitycolumnconstraint_sql-588"><span class="linenos">588</span></a> <span class="n">on_null</span> <span class="o">=</span> <span class="s2">"ON NULL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on_null"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-589"><a href="#Generator.generatedasidentitycolumnconstraint_sql-589"><span class="linenos">589</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" ALWAYS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" BY DEFAULT </span><span class="si">{</span><span class="n">on_null</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-590"><a href="#Generator.generatedasidentitycolumnconstraint_sql-590"><span class="linenos">590</span></a> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-591"><a href="#Generator.generatedasidentitycolumnconstraint_sql-591"><span class="linenos">591</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"start"</span><span class="p">)</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-592"><a href="#Generator.generatedasidentitycolumnconstraint_sql-592"><span class="linenos">592</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"START WITH </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-593"><a href="#Generator.generatedasidentitycolumnconstraint_sql-593"><span class="linenos">593</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"increment"</span><span class="p">)</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-594"><a href="#Generator.generatedasidentitycolumnconstraint_sql-594"><span class="linenos">594</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT BY </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-595"><a href="#Generator.generatedasidentitycolumnconstraint_sql-595"><span class="linenos">595</span></a> <span class="n">minvalue</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"minvalue"</span><span class="p">)</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-596"><a href="#Generator.generatedasidentitycolumnconstraint_sql-596"><span class="linenos">596</span></a> <span class="n">minvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MINVALUE </span><span class="si">{</span><span class="n">minvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">minvalue</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-597"><a href="#Generator.generatedasidentitycolumnconstraint_sql-597"><span class="linenos">597</span></a> <span class="n">maxvalue</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"maxvalue"</span><span class="p">)</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-598"><a href="#Generator.generatedasidentitycolumnconstraint_sql-598"><span class="linenos">598</span></a> <span class="n">maxvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAXVALUE </span><span class="si">{</span><span class="n">maxvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">maxvalue</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-599"><a href="#Generator.generatedasidentitycolumnconstraint_sql-599"><span class="linenos">599</span></a> <span class="n">cycle</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"cycle"</span><span class="p">)</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-600"><a href="#Generator.generatedasidentitycolumnconstraint_sql-600"><span class="linenos">600</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-601"><a href="#Generator.generatedasidentitycolumnconstraint_sql-601"><span class="linenos">601</span></a> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-602"><a href="#Generator.generatedasidentitycolumnconstraint_sql-602"><span class="linenos">602</span></a> <span class="k">if</span> <span class="n">cycle</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-603"><a href="#Generator.generatedasidentitycolumnconstraint_sql-603"><span class="linenos">603</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' NO'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">cycle</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2"> CYCLE"</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-604"><a href="#Generator.generatedasidentitycolumnconstraint_sql-604"><span class="linenos">604</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="n">cycle_sql</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">start</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">increment</span> <span class="k">else</span> <span class="n">cycle_sql</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-605"><a href="#Generator.generatedasidentitycolumnconstraint_sql-605"><span class="linenos">605</span></a> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-606"><a href="#Generator.generatedasidentitycolumnconstraint_sql-606"><span class="linenos">606</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-607"><a href="#Generator.generatedasidentitycolumnconstraint_sql-607"><span class="linenos">607</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">or</span> <span class="n">increment</span> <span class="ow">or</span> <span class="n">cycle_sql</span><span class="p">:</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-608"><a href="#Generator.generatedasidentitycolumnconstraint_sql-608"><span class="linenos">608</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}{</span><span class="n">minvalue</span><span class="si">}{</span><span class="n">maxvalue</span><span class="si">}{</span><span class="n">cycle_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-609"><a href="#Generator.generatedasidentitycolumnconstraint_sql-609"><span class="linenos">609</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">sequence_opts</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-610"><a href="#Generator.generatedasidentitycolumnconstraint_sql-610"><span class="linenos">610</span></a> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-611"><a href="#Generator.generatedasidentitycolumnconstraint_sql-611"><span class="linenos">611</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-612"><a href="#Generator.generatedasidentitycolumnconstraint_sql-612"><span class="linenos">612</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expr</span> <span class="k">else</span> <span class="s2">"IDENTITY"</span> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-613"><a href="#Generator.generatedasidentitycolumnconstraint_sql-613"><span class="linenos">613</span></a> -</span><span id="Generator.generatedasidentitycolumnconstraint_sql-614"><a href="#Generator.generatedasidentitycolumnconstraint_sql-614"><span class="linenos">614</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GENERATED</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">AS </span><span class="si">{</span><span class="n">expr</span><span class="si">}{</span><span class="n">sequence_opts</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.generatedasidentitycolumnconstraint_sql-590"><a href="#Generator.generatedasidentitycolumnconstraint_sql-590"><span class="linenos">590</span></a> <span class="k">def</span> <span class="nf">generatedasidentitycolumnconstraint_sql</span><span class="p">(</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-591"><a href="#Generator.generatedasidentitycolumnconstraint_sql-591"><span class="linenos">591</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-592"><a href="#Generator.generatedasidentitycolumnconstraint_sql-592"><span class="linenos">592</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-593"><a href="#Generator.generatedasidentitycolumnconstraint_sql-593"><span class="linenos">593</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-594"><a href="#Generator.generatedasidentitycolumnconstraint_sql-594"><span class="linenos">594</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-595"><a href="#Generator.generatedasidentitycolumnconstraint_sql-595"><span class="linenos">595</span></a> <span class="n">on_null</span> <span class="o">=</span> <span class="s2">"ON NULL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on_null"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-596"><a href="#Generator.generatedasidentitycolumnconstraint_sql-596"><span class="linenos">596</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">" ALWAYS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" BY DEFAULT </span><span class="si">{</span><span class="n">on_null</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-597"><a href="#Generator.generatedasidentitycolumnconstraint_sql-597"><span class="linenos">597</span></a> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-598"><a href="#Generator.generatedasidentitycolumnconstraint_sql-598"><span class="linenos">598</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"start"</span><span class="p">)</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-599"><a href="#Generator.generatedasidentitycolumnconstraint_sql-599"><span class="linenos">599</span></a> <span class="n">start</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"START WITH </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">start</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-600"><a href="#Generator.generatedasidentitycolumnconstraint_sql-600"><span class="linenos">600</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"increment"</span><span class="p">)</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-601"><a href="#Generator.generatedasidentitycolumnconstraint_sql-601"><span class="linenos">601</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INCREMENT BY </span><span class="si">{</span><span class="n">increment</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">increment</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-602"><a href="#Generator.generatedasidentitycolumnconstraint_sql-602"><span class="linenos">602</span></a> <span class="n">minvalue</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"minvalue"</span><span class="p">)</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-603"><a href="#Generator.generatedasidentitycolumnconstraint_sql-603"><span class="linenos">603</span></a> <span class="n">minvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MINVALUE </span><span class="si">{</span><span class="n">minvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">minvalue</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-604"><a href="#Generator.generatedasidentitycolumnconstraint_sql-604"><span class="linenos">604</span></a> <span class="n">maxvalue</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"maxvalue"</span><span class="p">)</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-605"><a href="#Generator.generatedasidentitycolumnconstraint_sql-605"><span class="linenos">605</span></a> <span class="n">maxvalue</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAXVALUE </span><span class="si">{</span><span class="n">maxvalue</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">maxvalue</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-606"><a href="#Generator.generatedasidentitycolumnconstraint_sql-606"><span class="linenos">606</span></a> <span class="n">cycle</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"cycle"</span><span class="p">)</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-607"><a href="#Generator.generatedasidentitycolumnconstraint_sql-607"><span class="linenos">607</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-608"><a href="#Generator.generatedasidentitycolumnconstraint_sql-608"><span class="linenos">608</span></a> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-609"><a href="#Generator.generatedasidentitycolumnconstraint_sql-609"><span class="linenos">609</span></a> <span class="k">if</span> <span class="n">cycle</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-610"><a href="#Generator.generatedasidentitycolumnconstraint_sql-610"><span class="linenos">610</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">' NO'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">cycle</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2"> CYCLE"</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-611"><a href="#Generator.generatedasidentitycolumnconstraint_sql-611"><span class="linenos">611</span></a> <span class="n">cycle_sql</span> <span class="o">=</span> <span class="n">cycle_sql</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">start</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">increment</span> <span class="k">else</span> <span class="n">cycle_sql</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-612"><a href="#Generator.generatedasidentitycolumnconstraint_sql-612"><span class="linenos">612</span></a> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-613"><a href="#Generator.generatedasidentitycolumnconstraint_sql-613"><span class="linenos">613</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-614"><a href="#Generator.generatedasidentitycolumnconstraint_sql-614"><span class="linenos">614</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">or</span> <span class="n">increment</span> <span class="ow">or</span> <span class="n">cycle_sql</span><span class="p">:</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-615"><a href="#Generator.generatedasidentitycolumnconstraint_sql-615"><span class="linenos">615</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">start</span><span class="si">}{</span><span class="n">increment</span><span class="si">}{</span><span class="n">minvalue</span><span class="si">}{</span><span class="n">maxvalue</span><span class="si">}{</span><span class="n">cycle_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-616"><a href="#Generator.generatedasidentitycolumnconstraint_sql-616"><span class="linenos">616</span></a> <span class="n">sequence_opts</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">sequence_opts</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-617"><a href="#Generator.generatedasidentitycolumnconstraint_sql-617"><span class="linenos">617</span></a> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-618"><a href="#Generator.generatedasidentitycolumnconstraint_sql-618"><span class="linenos">618</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-619"><a href="#Generator.generatedasidentitycolumnconstraint_sql-619"><span class="linenos">619</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expr</span> <span class="k">else</span> <span class="s2">"IDENTITY"</span> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-620"><a href="#Generator.generatedasidentitycolumnconstraint_sql-620"><span class="linenos">620</span></a> +</span><span id="Generator.generatedasidentitycolumnconstraint_sql-621"><a href="#Generator.generatedasidentitycolumnconstraint_sql-621"><span class="linenos">621</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"GENERATED</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">AS </span><span class="si">{</span><span class="n">expr</span><span class="si">}{</span><span class="n">sequence_opts</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6252,8 +6378,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.notnullcolumnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.notnullcolumnconstraint_sql-616"><a href="#Generator.notnullcolumnconstraint_sql-616"><span class="linenos">616</span></a> <span class="k">def</span> <span class="nf">notnullcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NotNullColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.notnullcolumnconstraint_sql-617"><a href="#Generator.notnullcolumnconstraint_sql-617"><span class="linenos">617</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">''</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'allow_null'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'NOT '</span><span class="si">}</span><span class="s2">NULL"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.notnullcolumnconstraint_sql-623"><a href="#Generator.notnullcolumnconstraint_sql-623"><span class="linenos">623</span></a> <span class="k">def</span> <span class="nf">notnullcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NotNullColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.notnullcolumnconstraint_sql-624"><a href="#Generator.notnullcolumnconstraint_sql-624"><span class="linenos">624</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="s1">''</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'allow_null'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'NOT '</span><span class="si">}</span><span class="s2">NULL"</span> </span></pre></div> @@ -6271,11 +6397,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.primarykeycolumnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.primarykeycolumnconstraint_sql-619"><a href="#Generator.primarykeycolumnconstraint_sql-619"><span class="linenos">619</span></a> <span class="k">def</span> <span class="nf">primarykeycolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKeyColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.primarykeycolumnconstraint_sql-620"><a href="#Generator.primarykeycolumnconstraint_sql-620"><span class="linenos">620</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"desc"</span><span class="p">)</span> -</span><span id="Generator.primarykeycolumnconstraint_sql-621"><a href="#Generator.primarykeycolumnconstraint_sql-621"><span class="linenos">621</span></a> <span class="k">if</span> <span class="n">desc</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.primarykeycolumnconstraint_sql-622"><a href="#Generator.primarykeycolumnconstraint_sql-622"><span class="linenos">622</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY</span><span class="si">{</span><span class="s1">' DESC'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">desc</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ASC'</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.primarykeycolumnconstraint_sql-623"><a href="#Generator.primarykeycolumnconstraint_sql-623"><span class="linenos">623</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.primarykeycolumnconstraint_sql-626"><a href="#Generator.primarykeycolumnconstraint_sql-626"><span class="linenos">626</span></a> <span class="k">def</span> <span class="nf">primarykeycolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKeyColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.primarykeycolumnconstraint_sql-627"><a href="#Generator.primarykeycolumnconstraint_sql-627"><span class="linenos">627</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"desc"</span><span class="p">)</span> +</span><span id="Generator.primarykeycolumnconstraint_sql-628"><a href="#Generator.primarykeycolumnconstraint_sql-628"><span class="linenos">628</span></a> <span class="k">if</span> <span class="n">desc</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.primarykeycolumnconstraint_sql-629"><a href="#Generator.primarykeycolumnconstraint_sql-629"><span class="linenos">629</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY</span><span class="si">{</span><span class="s1">' DESC'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">desc</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ASC'</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.primarykeycolumnconstraint_sql-630"><a href="#Generator.primarykeycolumnconstraint_sql-630"><span class="linenos">630</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY"</span> </span></pre></div> @@ -6293,10 +6419,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.uniquecolumnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.uniquecolumnconstraint_sql-625"><a href="#Generator.uniquecolumnconstraint_sql-625"><span class="linenos">625</span></a> <span class="k">def</span> <span class="nf">uniquecolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UniqueColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.uniquecolumnconstraint_sql-626"><a href="#Generator.uniquecolumnconstraint_sql-626"><span class="linenos">626</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.uniquecolumnconstraint_sql-627"><a href="#Generator.uniquecolumnconstraint_sql-627"><span class="linenos">627</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.uniquecolumnconstraint_sql-628"><a href="#Generator.uniquecolumnconstraint_sql-628"><span class="linenos">628</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNIQUE</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.uniquecolumnconstraint_sql-632"><a href="#Generator.uniquecolumnconstraint_sql-632"><span class="linenos">632</span></a> <span class="k">def</span> <span class="nf">uniquecolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UniqueColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.uniquecolumnconstraint_sql-633"><a href="#Generator.uniquecolumnconstraint_sql-633"><span class="linenos">633</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.uniquecolumnconstraint_sql-634"><a href="#Generator.uniquecolumnconstraint_sql-634"><span class="linenos">634</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.uniquecolumnconstraint_sql-635"><a href="#Generator.uniquecolumnconstraint_sql-635"><span class="linenos">635</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNIQUE</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6314,10 +6440,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.createable_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.createable_sql-630"><a href="#Generator.createable_sql-630"><span class="linenos">630</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span> -</span><span id="Generator.createable_sql-631"><a href="#Generator.createable_sql-631"><span class="linenos">631</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="nb">dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">]]</span> -</span><span id="Generator.createable_sql-632"><a href="#Generator.createable_sql-632"><span class="linenos">632</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.createable_sql-633"><a href="#Generator.createable_sql-633"><span class="linenos">633</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.createable_sql-637"><a href="#Generator.createable_sql-637"><span class="linenos">637</span></a> <span class="k">def</span> <span class="nf">createable_sql</span><span class="p">(</span> +</span><span id="Generator.createable_sql-638"><a href="#Generator.createable_sql-638"><span class="linenos">638</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> <span class="n">locations</span><span class="p">:</span> <span class="nb">dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">]]</span> +</span><span id="Generator.createable_sql-639"><a href="#Generator.createable_sql-639"><span class="linenos">639</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.createable_sql-640"><a href="#Generator.createable_sql-640"><span class="linenos">640</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> </span></pre></div> @@ -6335,90 +6461,90 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.create_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.create_sql-635"><a href="#Generator.create_sql-635"><span class="linenos">635</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.create_sql-636"><a href="#Generator.create_sql-636"><span class="linenos">636</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Generator.create_sql-637"><a href="#Generator.create_sql-637"><span class="linenos">637</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"properties"</span><span class="p">)</span> -</span><span id="Generator.create_sql-638"><a href="#Generator.create_sql-638"><span class="linenos">638</span></a> <span class="n">properties_locs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">locate_properties</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span> <span class="k">if</span> <span class="n">properties</span> <span class="k">else</span> <span class="p">{}</span> -</span><span id="Generator.create_sql-639"><a href="#Generator.create_sql-639"><span class="linenos">639</span></a> -</span><span id="Generator.create_sql-640"><a href="#Generator.create_sql-640"><span class="linenos">640</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">properties_locs</span><span class="p">)</span> -</span><span id="Generator.create_sql-641"><a href="#Generator.create_sql-641"><span class="linenos">641</span></a> -</span><span id="Generator.create_sql-642"><a href="#Generator.create_sql-642"><span class="linenos">642</span></a> <span class="n">properties_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.create_sql-643"><a href="#Generator.create_sql-643"><span class="linenos">643</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">)</span> <span class="ow">or</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> -</span><span id="Generator.create_sql-644"><a href="#Generator.create_sql-644"><span class="linenos">644</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span> -</span><span id="Generator.create_sql-645"><a href="#Generator.create_sql-645"><span class="linenos">645</span></a> <span class="p">):</span> -</span><span id="Generator.create_sql-646"><a href="#Generator.create_sql-646"><span class="linenos">646</span></a> <span class="n">properties_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="Generator.create_sql-647"><a href="#Generator.create_sql-647"><span class="linenos">647</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> -</span><span id="Generator.create_sql-648"><a href="#Generator.create_sql-648"><span class="linenos">648</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> -</span><span id="Generator.create_sql-649"><a href="#Generator.create_sql-649"><span class="linenos">649</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">],</span> -</span><span id="Generator.create_sql-650"><a href="#Generator.create_sql-650"><span class="linenos">650</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">],</span> -</span><span id="Generator.create_sql-651"><a href="#Generator.create_sql-651"><span class="linenos">651</span></a> <span class="p">]</span> -</span><span id="Generator.create_sql-652"><a href="#Generator.create_sql-652"><span class="linenos">652</span></a> <span class="p">)</span> -</span><span id="Generator.create_sql-653"><a href="#Generator.create_sql-653"><span class="linenos">653</span></a> <span class="p">)</span> -</span><span id="Generator.create_sql-654"><a href="#Generator.create_sql-654"><span class="linenos">654</span></a> -</span><span id="Generator.create_sql-655"><a href="#Generator.create_sql-655"><span class="linenos">655</span></a> <span class="n">begin</span> <span class="o">=</span> <span class="s2">" BEGIN"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"begin"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.create_sql-656"><a href="#Generator.create_sql-656"><span class="linenos">656</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator.create_sql-657"><a href="#Generator.create_sql-657"><span class="linenos">657</span></a> <span class="k">if</span> <span class="n">expression_sql</span><span class="p">:</span> -</span><span id="Generator.create_sql-658"><a href="#Generator.create_sql-658"><span class="linenos">658</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">begin</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.create_sql-659"><a href="#Generator.create_sql-659"><span class="linenos">659</span></a> -</span><span id="Generator.create_sql-660"><a href="#Generator.create_sql-660"><span class="linenos">660</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CREATE_FUNCTION_RETURN_AS</span> <span class="ow">or</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Return</span><span class="p">):</span> -</span><span id="Generator.create_sql-661"><a href="#Generator.create_sql-661"><span class="linenos">661</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">):</span> -</span><span id="Generator.create_sql-662"><a href="#Generator.create_sql-662"><span class="linenos">662</span></a> <span class="n">postalias_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="Generator.create_sql-663"><a href="#Generator.create_sql-663"><span class="linenos">663</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> -</span><span id="Generator.create_sql-664"><a href="#Generator.create_sql-664"><span class="linenos">664</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">]</span> -</span><span id="Generator.create_sql-665"><a href="#Generator.create_sql-665"><span class="linenos">665</span></a> <span class="p">),</span> -</span><span id="Generator.create_sql-666"><a href="#Generator.create_sql-666"><span class="linenos">666</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Generator.create_sql-667"><a href="#Generator.create_sql-667"><span class="linenos">667</span></a> <span class="p">)</span> -</span><span id="Generator.create_sql-668"><a href="#Generator.create_sql-668"><span class="linenos">668</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">postalias_props_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.create_sql-669"><a href="#Generator.create_sql-669"><span class="linenos">669</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.create_sql-670"><a href="#Generator.create_sql-670"><span class="linenos">670</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.create_sql-671"><a href="#Generator.create_sql-671"><span class="linenos">671</span></a> -</span><span id="Generator.create_sql-672"><a href="#Generator.create_sql-672"><span class="linenos">672</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.create_sql-673"><a href="#Generator.create_sql-673"><span class="linenos">673</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">):</span> -</span><span id="Generator.create_sql-674"><a href="#Generator.create_sql-674"><span class="linenos">674</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="Generator.create_sql-675"><a href="#Generator.create_sql-675"><span class="linenos">675</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">]),</span> -</span><span id="Generator.create_sql-676"><a href="#Generator.create_sql-676"><span class="linenos">676</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Generator.create_sql-677"><a href="#Generator.create_sql-677"><span class="linenos">677</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator.create_sql-678"><a href="#Generator.create_sql-678"><span class="linenos">678</span></a> <span class="p">)</span> -</span><span id="Generator.create_sql-679"><a href="#Generator.create_sql-679"><span class="linenos">679</span></a> -</span><span id="Generator.create_sql-680"><a href="#Generator.create_sql-680"><span class="linenos">680</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"indexes"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator.create_sql-681"><a href="#Generator.create_sql-681"><span class="linenos">681</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">indexes</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">indexes</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.create_sql-682"><a href="#Generator.create_sql-682"><span class="linenos">682</span></a> <span class="n">index_sql</span> <span class="o">=</span> <span class="n">indexes</span> <span class="o">+</span> <span class="n">postindex_props_sql</span> -</span><span id="Generator.create_sql-683"><a href="#Generator.create_sql-683"><span class="linenos">683</span></a> -</span><span id="Generator.create_sql-684"><a href="#Generator.create_sql-684"><span class="linenos">684</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="s2">" OR REPLACE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"replace"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.create_sql-685"><a href="#Generator.create_sql-685"><span class="linenos">685</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">" UNIQUE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.create_sql-642"><a href="#Generator.create_sql-642"><span class="linenos">642</span></a> <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.create_sql-643"><a href="#Generator.create_sql-643"><span class="linenos">643</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Generator.create_sql-644"><a href="#Generator.create_sql-644"><span class="linenos">644</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"properties"</span><span class="p">)</span> +</span><span id="Generator.create_sql-645"><a href="#Generator.create_sql-645"><span class="linenos">645</span></a> <span class="n">properties_locs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">locate_properties</span><span class="p">(</span><span class="n">properties</span><span class="p">)</span> <span class="k">if</span> <span class="n">properties</span> <span class="k">else</span> <span class="p">{}</span> +</span><span id="Generator.create_sql-646"><a href="#Generator.create_sql-646"><span class="linenos">646</span></a> +</span><span id="Generator.create_sql-647"><a href="#Generator.create_sql-647"><span class="linenos">647</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">createable_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">properties_locs</span><span class="p">)</span> +</span><span id="Generator.create_sql-648"><a href="#Generator.create_sql-648"><span class="linenos">648</span></a> +</span><span id="Generator.create_sql-649"><a href="#Generator.create_sql-649"><span class="linenos">649</span></a> <span class="n">properties_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-650"><a href="#Generator.create_sql-650"><span class="linenos">650</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">)</span> <span class="ow">or</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> +</span><span id="Generator.create_sql-651"><a href="#Generator.create_sql-651"><span class="linenos">651</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span> +</span><span id="Generator.create_sql-652"><a href="#Generator.create_sql-652"><span class="linenos">652</span></a> <span class="p">):</span> +</span><span id="Generator.create_sql-653"><a href="#Generator.create_sql-653"><span class="linenos">653</span></a> <span class="n">properties_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="Generator.create_sql-654"><a href="#Generator.create_sql-654"><span class="linenos">654</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> +</span><span id="Generator.create_sql-655"><a href="#Generator.create_sql-655"><span class="linenos">655</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> +</span><span id="Generator.create_sql-656"><a href="#Generator.create_sql-656"><span class="linenos">656</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">],</span> +</span><span id="Generator.create_sql-657"><a href="#Generator.create_sql-657"><span class="linenos">657</span></a> <span class="o">*</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">],</span> +</span><span id="Generator.create_sql-658"><a href="#Generator.create_sql-658"><span class="linenos">658</span></a> <span class="p">]</span> +</span><span id="Generator.create_sql-659"><a href="#Generator.create_sql-659"><span class="linenos">659</span></a> <span class="p">)</span> +</span><span id="Generator.create_sql-660"><a href="#Generator.create_sql-660"><span class="linenos">660</span></a> <span class="p">)</span> +</span><span id="Generator.create_sql-661"><a href="#Generator.create_sql-661"><span class="linenos">661</span></a> +</span><span id="Generator.create_sql-662"><a href="#Generator.create_sql-662"><span class="linenos">662</span></a> <span class="n">begin</span> <span class="o">=</span> <span class="s2">" BEGIN"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"begin"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-663"><a href="#Generator.create_sql-663"><span class="linenos">663</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator.create_sql-664"><a href="#Generator.create_sql-664"><span class="linenos">664</span></a> <span class="k">if</span> <span class="n">expression_sql</span><span class="p">:</span> +</span><span id="Generator.create_sql-665"><a href="#Generator.create_sql-665"><span class="linenos">665</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">begin</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.create_sql-666"><a href="#Generator.create_sql-666"><span class="linenos">666</span></a> +</span><span id="Generator.create_sql-667"><a href="#Generator.create_sql-667"><span class="linenos">667</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CREATE_FUNCTION_RETURN_AS</span> <span class="ow">or</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Return</span><span class="p">):</span> +</span><span id="Generator.create_sql-668"><a href="#Generator.create_sql-668"><span class="linenos">668</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">):</span> +</span><span id="Generator.create_sql-669"><a href="#Generator.create_sql-669"><span class="linenos">669</span></a> <span class="n">postalias_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="Generator.create_sql-670"><a href="#Generator.create_sql-670"><span class="linenos">670</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> +</span><span id="Generator.create_sql-671"><a href="#Generator.create_sql-671"><span class="linenos">671</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">]</span> +</span><span id="Generator.create_sql-672"><a href="#Generator.create_sql-672"><span class="linenos">672</span></a> <span class="p">),</span> +</span><span id="Generator.create_sql-673"><a href="#Generator.create_sql-673"><span class="linenos">673</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Generator.create_sql-674"><a href="#Generator.create_sql-674"><span class="linenos">674</span></a> <span class="p">)</span> +</span><span id="Generator.create_sql-675"><a href="#Generator.create_sql-675"><span class="linenos">675</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">postalias_props_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.create_sql-676"><a href="#Generator.create_sql-676"><span class="linenos">676</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.create_sql-677"><a href="#Generator.create_sql-677"><span class="linenos">677</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.create_sql-678"><a href="#Generator.create_sql-678"><span class="linenos">678</span></a> +</span><span id="Generator.create_sql-679"><a href="#Generator.create_sql-679"><span class="linenos">679</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-680"><a href="#Generator.create_sql-680"><span class="linenos">680</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">):</span> +</span><span id="Generator.create_sql-681"><a href="#Generator.create_sql-681"><span class="linenos">681</span></a> <span class="n">postindex_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="Generator.create_sql-682"><a href="#Generator.create_sql-682"><span class="linenos">682</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">]),</span> +</span><span id="Generator.create_sql-683"><a href="#Generator.create_sql-683"><span class="linenos">683</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Generator.create_sql-684"><a href="#Generator.create_sql-684"><span class="linenos">684</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator.create_sql-685"><a href="#Generator.create_sql-685"><span class="linenos">685</span></a> <span class="p">)</span> </span><span id="Generator.create_sql-686"><a href="#Generator.create_sql-686"><span class="linenos">686</span></a> -</span><span id="Generator.create_sql-687"><a href="#Generator.create_sql-687"><span class="linenos">687</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.create_sql-688"><a href="#Generator.create_sql-688"><span class="linenos">688</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">):</span> -</span><span id="Generator.create_sql-689"><a href="#Generator.create_sql-689"><span class="linenos">689</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="Generator.create_sql-690"><a href="#Generator.create_sql-690"><span class="linenos">690</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">]),</span> -</span><span id="Generator.create_sql-691"><a href="#Generator.create_sql-691"><span class="linenos">691</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator.create_sql-692"><a href="#Generator.create_sql-692"><span class="linenos">692</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator.create_sql-693"><a href="#Generator.create_sql-693"><span class="linenos">693</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Generator.create_sql-694"><a href="#Generator.create_sql-694"><span class="linenos">694</span></a> <span class="p">)</span> -</span><span id="Generator.create_sql-695"><a href="#Generator.create_sql-695"><span class="linenos">695</span></a> -</span><span id="Generator.create_sql-696"><a href="#Generator.create_sql-696"><span class="linenos">696</span></a> <span class="n">modifiers</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">replace</span><span class="p">,</span> <span class="n">unique</span><span class="p">,</span> <span class="n">postcreate_props_sql</span><span class="p">))</span> -</span><span id="Generator.create_sql-697"><a href="#Generator.create_sql-697"><span class="linenos">697</span></a> -</span><span id="Generator.create_sql-698"><a href="#Generator.create_sql-698"><span class="linenos">698</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.create_sql-699"><a href="#Generator.create_sql-699"><span class="linenos">699</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">):</span> -</span><span id="Generator.create_sql-700"><a href="#Generator.create_sql-700"><span class="linenos">700</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> -</span><span id="Generator.create_sql-701"><a href="#Generator.create_sql-701"><span class="linenos">701</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> -</span><span id="Generator.create_sql-702"><a href="#Generator.create_sql-702"><span class="linenos">702</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">]</span> -</span><span id="Generator.create_sql-703"><a href="#Generator.create_sql-703"><span class="linenos">703</span></a> <span class="p">),</span> -</span><span id="Generator.create_sql-704"><a href="#Generator.create_sql-704"><span class="linenos">704</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator.create_sql-705"><a href="#Generator.create_sql-705"><span class="linenos">705</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> -</span><span id="Generator.create_sql-706"><a href="#Generator.create_sql-706"><span class="linenos">706</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Generator.create_sql-707"><a href="#Generator.create_sql-707"><span class="linenos">707</span></a> <span class="p">)</span> -</span><span id="Generator.create_sql-708"><a href="#Generator.create_sql-708"><span class="linenos">708</span></a> -</span><span id="Generator.create_sql-709"><a href="#Generator.create_sql-709"><span class="linenos">709</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF NOT EXISTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.create_sql-710"><a href="#Generator.create_sql-710"><span class="linenos">710</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.create_sql-711"><a href="#Generator.create_sql-711"><span class="linenos">711</span></a> <span class="s2">" WITH NO SCHEMA BINDING"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no_schema_binding"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.create_sql-712"><a href="#Generator.create_sql-712"><span class="linenos">712</span></a> <span class="p">)</span> -</span><span id="Generator.create_sql-713"><a href="#Generator.create_sql-713"><span class="linenos">713</span></a> -</span><span id="Generator.create_sql-714"><a href="#Generator.create_sql-714"><span class="linenos">714</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"clone"</span><span class="p">)</span> -</span><span id="Generator.create_sql-715"><a href="#Generator.create_sql-715"><span class="linenos">715</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">clone</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.create_sql-716"><a href="#Generator.create_sql-716"><span class="linenos">716</span></a> -</span><span id="Generator.create_sql-717"><a href="#Generator.create_sql-717"><span class="linenos">717</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CREATE</span><span class="si">{</span><span class="n">modifiers</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">properties_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">postexpression_props_sql</span><span class="si">}{</span><span class="n">index_sql</span><span class="si">}{</span><span class="n">no_schema_binding</span><span class="si">}{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.create_sql-718"><a href="#Generator.create_sql-718"><span class="linenos">718</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">expression_sql</span><span class="p">)</span> +</span><span id="Generator.create_sql-687"><a href="#Generator.create_sql-687"><span class="linenos">687</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"indexes"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator.create_sql-688"><a href="#Generator.create_sql-688"><span class="linenos">688</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">indexes</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">indexes</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-689"><a href="#Generator.create_sql-689"><span class="linenos">689</span></a> <span class="n">index_sql</span> <span class="o">=</span> <span class="n">indexes</span> <span class="o">+</span> <span class="n">postindex_props_sql</span> +</span><span id="Generator.create_sql-690"><a href="#Generator.create_sql-690"><span class="linenos">690</span></a> +</span><span id="Generator.create_sql-691"><a href="#Generator.create_sql-691"><span class="linenos">691</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="s2">" OR REPLACE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"replace"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-692"><a href="#Generator.create_sql-692"><span class="linenos">692</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">" UNIQUE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-693"><a href="#Generator.create_sql-693"><span class="linenos">693</span></a> +</span><span id="Generator.create_sql-694"><a href="#Generator.create_sql-694"><span class="linenos">694</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-695"><a href="#Generator.create_sql-695"><span class="linenos">695</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">):</span> +</span><span id="Generator.create_sql-696"><a href="#Generator.create_sql-696"><span class="linenos">696</span></a> <span class="n">postcreate_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="Generator.create_sql-697"><a href="#Generator.create_sql-697"><span class="linenos">697</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">]),</span> +</span><span id="Generator.create_sql-698"><a href="#Generator.create_sql-698"><span class="linenos">698</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator.create_sql-699"><a href="#Generator.create_sql-699"><span class="linenos">699</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator.create_sql-700"><a href="#Generator.create_sql-700"><span class="linenos">700</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Generator.create_sql-701"><a href="#Generator.create_sql-701"><span class="linenos">701</span></a> <span class="p">)</span> +</span><span id="Generator.create_sql-702"><a href="#Generator.create_sql-702"><span class="linenos">702</span></a> +</span><span id="Generator.create_sql-703"><a href="#Generator.create_sql-703"><span class="linenos">703</span></a> <span class="n">modifiers</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">replace</span><span class="p">,</span> <span class="n">unique</span><span class="p">,</span> <span class="n">postcreate_props_sql</span><span class="p">))</span> +</span><span id="Generator.create_sql-704"><a href="#Generator.create_sql-704"><span class="linenos">704</span></a> +</span><span id="Generator.create_sql-705"><a href="#Generator.create_sql-705"><span class="linenos">705</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-706"><a href="#Generator.create_sql-706"><span class="linenos">706</span></a> <span class="k">if</span> <span class="n">properties_locs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">):</span> +</span><span id="Generator.create_sql-707"><a href="#Generator.create_sql-707"><span class="linenos">707</span></a> <span class="n">postexpression_props_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span> +</span><span id="Generator.create_sql-708"><a href="#Generator.create_sql-708"><span class="linenos">708</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span> +</span><span id="Generator.create_sql-709"><a href="#Generator.create_sql-709"><span class="linenos">709</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">]</span> +</span><span id="Generator.create_sql-710"><a href="#Generator.create_sql-710"><span class="linenos">710</span></a> <span class="p">),</span> +</span><span id="Generator.create_sql-711"><a href="#Generator.create_sql-711"><span class="linenos">711</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator.create_sql-712"><a href="#Generator.create_sql-712"><span class="linenos">712</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> +</span><span id="Generator.create_sql-713"><a href="#Generator.create_sql-713"><span class="linenos">713</span></a> <span class="n">wrapped</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Generator.create_sql-714"><a href="#Generator.create_sql-714"><span class="linenos">714</span></a> <span class="p">)</span> +</span><span id="Generator.create_sql-715"><a href="#Generator.create_sql-715"><span class="linenos">715</span></a> +</span><span id="Generator.create_sql-716"><a href="#Generator.create_sql-716"><span class="linenos">716</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF NOT EXISTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-717"><a href="#Generator.create_sql-717"><span class="linenos">717</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.create_sql-718"><a href="#Generator.create_sql-718"><span class="linenos">718</span></a> <span class="s2">" WITH NO SCHEMA BINDING"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no_schema_binding"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-719"><a href="#Generator.create_sql-719"><span class="linenos">719</span></a> <span class="p">)</span> +</span><span id="Generator.create_sql-720"><a href="#Generator.create_sql-720"><span class="linenos">720</span></a> +</span><span id="Generator.create_sql-721"><a href="#Generator.create_sql-721"><span class="linenos">721</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"clone"</span><span class="p">)</span> +</span><span id="Generator.create_sql-722"><a href="#Generator.create_sql-722"><span class="linenos">722</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">clone</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.create_sql-723"><a href="#Generator.create_sql-723"><span class="linenos">723</span></a> +</span><span id="Generator.create_sql-724"><a href="#Generator.create_sql-724"><span class="linenos">724</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"CREATE</span><span class="si">{</span><span class="n">modifiers</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">properties_sql</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">postexpression_props_sql</span><span class="si">}{</span><span class="n">index_sql</span><span class="si">}{</span><span class="n">no_schema_binding</span><span class="si">}{</span><span class="n">clone</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.create_sql-725"><a href="#Generator.create_sql-725"><span class="linenos">725</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">expression_sql</span><span class="p">)</span> </span></pre></div> @@ -6436,16 +6562,16 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.clone_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.clone_sql-720"><a href="#Generator.clone_sql-720"><span class="linenos">720</span></a> <span class="k">def</span> <span class="nf">clone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Clone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.clone_sql-721"><a href="#Generator.clone_sql-721"><span class="linenos">721</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.clone_sql-722"><a href="#Generator.clone_sql-722"><span class="linenos">722</span></a> <span class="n">when</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"when"</span><span class="p">)</span> -</span><span id="Generator.clone_sql-723"><a href="#Generator.clone_sql-723"><span class="linenos">723</span></a> -</span><span id="Generator.clone_sql-724"><a href="#Generator.clone_sql-724"><span class="linenos">724</span></a> <span class="k">if</span> <span class="n">when</span><span class="p">:</span> -</span><span id="Generator.clone_sql-725"><a href="#Generator.clone_sql-725"><span class="linenos">725</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator.clone_sql-726"><a href="#Generator.clone_sql-726"><span class="linenos">726</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator.clone_sql-727"><a href="#Generator.clone_sql-727"><span class="linenos">727</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CLONE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">when</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> => </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.clone_sql-728"><a href="#Generator.clone_sql-728"><span class="linenos">728</span></a> -</span><span id="Generator.clone_sql-729"><a href="#Generator.clone_sql-729"><span class="linenos">729</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CLONE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.clone_sql-727"><a href="#Generator.clone_sql-727"><span class="linenos">727</span></a> <span class="k">def</span> <span class="nf">clone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Clone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.clone_sql-728"><a href="#Generator.clone_sql-728"><span class="linenos">728</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.clone_sql-729"><a href="#Generator.clone_sql-729"><span class="linenos">729</span></a> <span class="n">when</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"when"</span><span class="p">)</span> +</span><span id="Generator.clone_sql-730"><a href="#Generator.clone_sql-730"><span class="linenos">730</span></a> +</span><span id="Generator.clone_sql-731"><a href="#Generator.clone_sql-731"><span class="linenos">731</span></a> <span class="k">if</span> <span class="n">when</span><span class="p">:</span> +</span><span id="Generator.clone_sql-732"><a href="#Generator.clone_sql-732"><span class="linenos">732</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator.clone_sql-733"><a href="#Generator.clone_sql-733"><span class="linenos">733</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator.clone_sql-734"><a href="#Generator.clone_sql-734"><span class="linenos">734</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CLONE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">when</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> => </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.clone_sql-735"><a href="#Generator.clone_sql-735"><span class="linenos">735</span></a> +</span><span id="Generator.clone_sql-736"><a href="#Generator.clone_sql-736"><span class="linenos">736</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CLONE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6463,8 +6589,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.describe_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.describe_sql-731"><a href="#Generator.describe_sql-731"><span class="linenos">731</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.describe_sql-732"><a href="#Generator.describe_sql-732"><span class="linenos">732</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.describe_sql-738"><a href="#Generator.describe_sql-738"><span class="linenos">738</span></a> <span class="k">def</span> <span class="nf">describe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Describe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.describe_sql-739"><a href="#Generator.describe_sql-739"><span class="linenos">739</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DESCRIBE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6482,11 +6608,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.prepend_ctes"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.prepend_ctes-734"><a href="#Generator.prepend_ctes-734"><span class="linenos">734</span></a> <span class="k">def</span> <span class="nf">prepend_ctes</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.prepend_ctes-735"><a href="#Generator.prepend_ctes-735"><span class="linenos">735</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"with"</span><span class="p">)</span> -</span><span id="Generator.prepend_ctes-736"><a href="#Generator.prepend_ctes-736"><span class="linenos">736</span></a> <span class="k">if</span> <span class="n">with_</span><span class="p">:</span> -</span><span id="Generator.prepend_ctes-737"><a href="#Generator.prepend_ctes-737"><span class="linenos">737</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">with_</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.prepend_ctes-738"><a href="#Generator.prepend_ctes-738"><span class="linenos">738</span></a> <span class="k">return</span> <span class="n">sql</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.prepend_ctes-741"><a href="#Generator.prepend_ctes-741"><span class="linenos">741</span></a> <span class="k">def</span> <span class="nf">prepend_ctes</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.prepend_ctes-742"><a href="#Generator.prepend_ctes-742"><span class="linenos">742</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"with"</span><span class="p">)</span> +</span><span id="Generator.prepend_ctes-743"><a href="#Generator.prepend_ctes-743"><span class="linenos">743</span></a> <span class="k">if</span> <span class="n">with_</span><span class="p">:</span> +</span><span id="Generator.prepend_ctes-744"><a href="#Generator.prepend_ctes-744"><span class="linenos">744</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">with_</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.prepend_ctes-745"><a href="#Generator.prepend_ctes-745"><span class="linenos">745</span></a> <span class="k">return</span> <span class="n">sql</span> </span></pre></div> @@ -6504,11 +6630,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.with_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.with_sql-740"><a href="#Generator.with_sql-740"><span class="linenos">740</span></a> <span class="k">def</span> <span class="nf">with_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.with_sql-741"><a href="#Generator.with_sql-741"><span class="linenos">741</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.with_sql-742"><a href="#Generator.with_sql-742"><span class="linenos">742</span></a> <span class="n">recursive</span> <span class="o">=</span> <span class="s2">"RECURSIVE "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"recursive"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.with_sql-743"><a href="#Generator.with_sql-743"><span class="linenos">743</span></a> -</span><span id="Generator.with_sql-744"><a href="#Generator.with_sql-744"><span class="linenos">744</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="n">recursive</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.with_sql-747"><a href="#Generator.with_sql-747"><span class="linenos">747</span></a> <span class="k">def</span> <span class="nf">with_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.with_sql-748"><a href="#Generator.with_sql-748"><span class="linenos">748</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.with_sql-749"><a href="#Generator.with_sql-749"><span class="linenos">749</span></a> <span class="n">recursive</span> <span class="o">=</span> <span class="s2">"RECURSIVE "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"recursive"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.with_sql-750"><a href="#Generator.with_sql-750"><span class="linenos">750</span></a> +</span><span id="Generator.with_sql-751"><a href="#Generator.with_sql-751"><span class="linenos">751</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="n">recursive</span><span class="si">}{</span><span class="n">sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6526,9 +6652,9 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.cte_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.cte_sql-746"><a href="#Generator.cte_sql-746"><span class="linenos">746</span></a> <span class="k">def</span> <span class="nf">cte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.cte_sql-747"><a href="#Generator.cte_sql-747"><span class="linenos">747</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator.cte_sql-748"><a href="#Generator.cte_sql-748"><span class="linenos">748</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.cte_sql-753"><a href="#Generator.cte_sql-753"><span class="linenos">753</span></a> <span class="k">def</span> <span class="nf">cte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.cte_sql-754"><a href="#Generator.cte_sql-754"><span class="linenos">754</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator.cte_sql-755"><a href="#Generator.cte_sql-755"><span class="linenos">755</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6546,11 +6672,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.tablealias_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tablealias_sql-750"><a href="#Generator.tablealias_sql-750"><span class="linenos">750</span></a> <span class="k">def</span> <span class="nf">tablealias_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableAlias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.tablealias_sql-751"><a href="#Generator.tablealias_sql-751"><span class="linenos">751</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.tablealias_sql-752"><a href="#Generator.tablealias_sql-752"><span class="linenos">752</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.tablealias_sql-753"><a href="#Generator.tablealias_sql-753"><span class="linenos">753</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.tablealias_sql-754"><a href="#Generator.tablealias_sql-754"><span class="linenos">754</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tablealias_sql-757"><a href="#Generator.tablealias_sql-757"><span class="linenos">757</span></a> <span class="k">def</span> <span class="nf">tablealias_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableAlias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.tablealias_sql-758"><a href="#Generator.tablealias_sql-758"><span class="linenos">758</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.tablealias_sql-759"><a href="#Generator.tablealias_sql-759"><span class="linenos">759</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.tablealias_sql-760"><a href="#Generator.tablealias_sql-760"><span class="linenos">760</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.tablealias_sql-761"><a href="#Generator.tablealias_sql-761"><span class="linenos">761</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">alias</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6568,11 +6694,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.bitstring_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitstring_sql-756"><a href="#Generator.bitstring_sql-756"><span class="linenos">756</span></a> <span class="k">def</span> <span class="nf">bitstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.bitstring_sql-757"><a href="#Generator.bitstring_sql-757"><span class="linenos">757</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.bitstring_sql-758"><a href="#Generator.bitstring_sql-758"><span class="linenos">758</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">BIT_START</span><span class="p">:</span> -</span><span id="Generator.bitstring_sql-759"><a href="#Generator.bitstring_sql-759"><span class="linenos">759</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">BIT_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">BIT_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.bitstring_sql-760"><a href="#Generator.bitstring_sql-760"><span class="linenos">760</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitstring_sql-763"><a href="#Generator.bitstring_sql-763"><span class="linenos">763</span></a> <span class="k">def</span> <span class="nf">bitstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.bitstring_sql-764"><a href="#Generator.bitstring_sql-764"><span class="linenos">764</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.bitstring_sql-765"><a href="#Generator.bitstring_sql-765"><span class="linenos">765</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">BIT_START</span><span class="p">:</span> +</span><span id="Generator.bitstring_sql-766"><a href="#Generator.bitstring_sql-766"><span class="linenos">766</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">BIT_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">BIT_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.bitstring_sql-767"><a href="#Generator.bitstring_sql-767"><span class="linenos">767</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6590,11 +6716,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.hexstring_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.hexstring_sql-762"><a href="#Generator.hexstring_sql-762"><span class="linenos">762</span></a> <span class="k">def</span> <span class="nf">hexstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">HexString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.hexstring_sql-763"><a href="#Generator.hexstring_sql-763"><span class="linenos">763</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.hexstring_sql-764"><a href="#Generator.hexstring_sql-764"><span class="linenos">764</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HEX_START</span><span class="p">:</span> -</span><span id="Generator.hexstring_sql-765"><a href="#Generator.hexstring_sql-765"><span class="linenos">765</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">HEX_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">HEX_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.hexstring_sql-766"><a href="#Generator.hexstring_sql-766"><span class="linenos">766</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">16</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.hexstring_sql-769"><a href="#Generator.hexstring_sql-769"><span class="linenos">769</span></a> <span class="k">def</span> <span class="nf">hexstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">HexString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.hexstring_sql-770"><a href="#Generator.hexstring_sql-770"><span class="linenos">770</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.hexstring_sql-771"><a href="#Generator.hexstring_sql-771"><span class="linenos">771</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HEX_START</span><span class="p">:</span> +</span><span id="Generator.hexstring_sql-772"><a href="#Generator.hexstring_sql-772"><span class="linenos">772</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">HEX_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">HEX_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.hexstring_sql-773"><a href="#Generator.hexstring_sql-773"><span class="linenos">773</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="mi">16</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6612,11 +6738,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.bytestring_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bytestring_sql-768"><a href="#Generator.bytestring_sql-768"><span class="linenos">768</span></a> <span class="k">def</span> <span class="nf">bytestring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ByteString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.bytestring_sql-769"><a href="#Generator.bytestring_sql-769"><span class="linenos">769</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.bytestring_sql-770"><a href="#Generator.bytestring_sql-770"><span class="linenos">770</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">BYTE_START</span><span class="p">:</span> -</span><span id="Generator.bytestring_sql-771"><a href="#Generator.bytestring_sql-771"><span class="linenos">771</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">BYTE_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">BYTE_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.bytestring_sql-772"><a href="#Generator.bytestring_sql-772"><span class="linenos">772</span></a> <span class="k">return</span> <span class="n">this</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bytestring_sql-775"><a href="#Generator.bytestring_sql-775"><span class="linenos">775</span></a> <span class="k">def</span> <span class="nf">bytestring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ByteString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.bytestring_sql-776"><a href="#Generator.bytestring_sql-776"><span class="linenos">776</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.bytestring_sql-777"><a href="#Generator.bytestring_sql-777"><span class="linenos">777</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">BYTE_START</span><span class="p">:</span> +</span><span id="Generator.bytestring_sql-778"><a href="#Generator.bytestring_sql-778"><span class="linenos">778</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">BYTE_START</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">BYTE_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.bytestring_sql-779"><a href="#Generator.bytestring_sql-779"><span class="linenos">779</span></a> <span class="k">return</span> <span class="n">this</span> </span></pre></div> @@ -6634,10 +6760,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.rawstring_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.rawstring_sql-774"><a href="#Generator.rawstring_sql-774"><span class="linenos">774</span></a> <span class="k">def</span> <span class="nf">rawstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RawString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.rawstring_sql-775"><a href="#Generator.rawstring_sql-775"><span class="linenos">775</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RAW_START</span><span class="p">:</span> -</span><span id="Generator.rawstring_sql-776"><a href="#Generator.rawstring_sql-776"><span class="linenos">776</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">RAW_START</span><span class="si">}{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">RAW_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.rawstring_sql-777"><a href="#Generator.rawstring_sql-777"><span class="linenos">777</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">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"</span><span class="se">\\\\</span><span class="s2">"</span><span class="p">)))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.rawstring_sql-781"><a href="#Generator.rawstring_sql-781"><span class="linenos">781</span></a> <span class="k">def</span> <span class="nf">rawstring_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RawString</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.rawstring_sql-782"><a href="#Generator.rawstring_sql-782"><span class="linenos">782</span></a> <span class="n">string</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="Generator.rawstring_sql-783"><a href="#Generator.rawstring_sql-783"><span class="linenos">783</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">RAW_START</span><span class="p">:</span> +</span><span id="Generator.rawstring_sql-784"><a href="#Generator.rawstring_sql-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="bp">self</span><span class="o">.</span><span class="n">RAW_START</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">RAW_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.rawstring_sql-785"><a href="#Generator.rawstring_sql-785"><span class="linenos">785</span></a> <span class="n">string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">string</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">,</span> <span class="s2">"</span><span class="se">\\\\</span><span class="s2">"</span><span class="p">))</span> +</span><span id="Generator.rawstring_sql-786"><a href="#Generator.rawstring_sql-786"><span class="linenos">786</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="n">string</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6655,11 +6783,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.datatypesize_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.datatypesize_sql-779"><a href="#Generator.datatypesize_sql-779"><span class="linenos">779</span></a> <span class="k">def</span> <span class="nf">datatypesize_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataTypeSize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.datatypesize_sql-780"><a href="#Generator.datatypesize_sql-780"><span class="linenos">780</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.datatypesize_sql-781"><a href="#Generator.datatypesize_sql-781"><span class="linenos">781</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator.datatypesize_sql-782"><a href="#Generator.datatypesize_sql-782"><span class="linenos">782</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">specifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">specifier</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.datatypesize_sql-783"><a href="#Generator.datatypesize_sql-783"><span class="linenos">783</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">specifier</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.datatypesize_sql-788"><a href="#Generator.datatypesize_sql-788"><span class="linenos">788</span></a> <span class="k">def</span> <span class="nf">datatypesize_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataTypeSize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.datatypesize_sql-789"><a href="#Generator.datatypesize_sql-789"><span class="linenos">789</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.datatypesize_sql-790"><a href="#Generator.datatypesize_sql-790"><span class="linenos">790</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator.datatypesize_sql-791"><a href="#Generator.datatypesize_sql-791"><span class="linenos">791</span></a> <span class="n">specifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">specifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">specifier</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.datatypesize_sql-792"><a href="#Generator.datatypesize_sql-792"><span class="linenos">792</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">specifier</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6677,23 +6805,23 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.datatype_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.datatype_sql-785"><a href="#Generator.datatype_sql-785"><span class="linenos">785</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.datatype_sql-786"><a href="#Generator.datatype_sql-786"><span class="linenos">786</span></a> <span class="n">type_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="Generator.datatype_sql-787"><a href="#Generator.datatype_sql-787"><span class="linenos">787</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">type_value</span><span class="p">,</span> <span class="n">type_value</span><span class="o">.</span><span class="n">value</span><span class="p">)</span> -</span><span id="Generator.datatype_sql-788"><a href="#Generator.datatype_sql-788"><span class="linenos">788</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.datatype_sql-789"><a href="#Generator.datatype_sql-789"><span class="linenos">789</span></a> <span class="n">interior</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.datatype_sql-790"><a href="#Generator.datatype_sql-790"><span class="linenos">790</span></a> <span class="n">values</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.datatype_sql-791"><a href="#Generator.datatype_sql-791"><span class="linenos">791</span></a> <span class="k">if</span> <span class="n">interior</span><span class="p">:</span> -</span><span id="Generator.datatype_sql-792"><a href="#Generator.datatype_sql-792"><span class="linenos">792</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nested"</span><span class="p">):</span> -</span><span id="Generator.datatype_sql-793"><a href="#Generator.datatype_sql-793"><span class="linenos">793</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">interior</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.datatype_sql-794"><a href="#Generator.datatype_sql-794"><span class="linenos">794</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"values"</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.datatype_sql-795"><a href="#Generator.datatype_sql-795"><span class="linenos">795</span></a> <span class="n">delimiters</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"["</span><span class="p">,</span> <span class="s2">"]"</span><span class="p">)</span> <span class="k">if</span> <span class="n">type_value</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span> <span class="k">else</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> -</span><span id="Generator.datatype_sql-796"><a href="#Generator.datatype_sql-796"><span class="linenos">796</span></a> <span class="n">values</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"values"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.datatype_sql-797"><a href="#Generator.datatype_sql-797"><span class="linenos">797</span></a> <span class="n">values</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">values</span><span class="si">}{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.datatype_sql-798"><a href="#Generator.datatype_sql-798"><span class="linenos">798</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.datatype_sql-799"><a href="#Generator.datatype_sql-799"><span class="linenos">799</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">interior</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.datatype_sql-800"><a href="#Generator.datatype_sql-800"><span class="linenos">800</span></a> -</span><span id="Generator.datatype_sql-801"><a href="#Generator.datatype_sql-801"><span class="linenos">801</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}{</span><span class="n">nested</span><span class="si">}{</span><span class="n">values</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.datatype_sql-794"><a href="#Generator.datatype_sql-794"><span class="linenos">794</span></a> <span class="k">def</span> <span class="nf">datatype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.datatype_sql-795"><a href="#Generator.datatype_sql-795"><span class="linenos">795</span></a> <span class="n">type_value</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="Generator.datatype_sql-796"><a href="#Generator.datatype_sql-796"><span class="linenos">796</span></a> <span class="n">type_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TYPE_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">type_value</span><span class="p">,</span> <span class="n">type_value</span><span class="o">.</span><span class="n">value</span><span class="p">)</span> +</span><span id="Generator.datatype_sql-797"><a href="#Generator.datatype_sql-797"><span class="linenos">797</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.datatype_sql-798"><a href="#Generator.datatype_sql-798"><span class="linenos">798</span></a> <span class="n">interior</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.datatype_sql-799"><a href="#Generator.datatype_sql-799"><span class="linenos">799</span></a> <span class="n">values</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.datatype_sql-800"><a href="#Generator.datatype_sql-800"><span class="linenos">800</span></a> <span class="k">if</span> <span class="n">interior</span><span class="p">:</span> +</span><span id="Generator.datatype_sql-801"><a href="#Generator.datatype_sql-801"><span class="linenos">801</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nested"</span><span class="p">):</span> +</span><span id="Generator.datatype_sql-802"><a href="#Generator.datatype_sql-802"><span class="linenos">802</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">interior</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">STRUCT_DELIMITER</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.datatype_sql-803"><a href="#Generator.datatype_sql-803"><span class="linenos">803</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"values"</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.datatype_sql-804"><a href="#Generator.datatype_sql-804"><span class="linenos">804</span></a> <span class="n">delimiters</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"["</span><span class="p">,</span> <span class="s2">"]"</span><span class="p">)</span> <span class="k">if</span> <span class="n">type_value</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span> <span class="k">else</span> <span class="p">(</span><span class="s2">"("</span><span class="p">,</span> <span class="s2">")"</span><span class="p">)</span> +</span><span id="Generator.datatype_sql-805"><a href="#Generator.datatype_sql-805"><span class="linenos">805</span></a> <span class="n">values</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"values"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.datatype_sql-806"><a href="#Generator.datatype_sql-806"><span class="linenos">806</span></a> <span class="n">values</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}{</span><span class="n">values</span><span class="si">}{</span><span class="n">delimiters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.datatype_sql-807"><a href="#Generator.datatype_sql-807"><span class="linenos">807</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.datatype_sql-808"><a href="#Generator.datatype_sql-808"><span class="linenos">808</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">interior</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.datatype_sql-809"><a href="#Generator.datatype_sql-809"><span class="linenos">809</span></a> +</span><span id="Generator.datatype_sql-810"><a href="#Generator.datatype_sql-810"><span class="linenos">810</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">type_sql</span><span class="si">}{</span><span class="n">nested</span><span class="si">}{</span><span class="n">values</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6711,11 +6839,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.directory_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.directory_sql-803"><a href="#Generator.directory_sql-803"><span class="linenos">803</span></a> <span class="k">def</span> <span class="nf">directory_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.directory_sql-804"><a href="#Generator.directory_sql-804"><span class="linenos">804</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">"LOCAL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.directory_sql-805"><a href="#Generator.directory_sql-805"><span class="linenos">805</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"row_format"</span><span class="p">)</span> -</span><span id="Generator.directory_sql-806"><a href="#Generator.directory_sql-806"><span class="linenos">806</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.directory_sql-807"><a href="#Generator.directory_sql-807"><span class="linenos">807</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2">DIRECTORY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">row_format</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.directory_sql-812"><a href="#Generator.directory_sql-812"><span class="linenos">812</span></a> <span class="k">def</span> <span class="nf">directory_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.directory_sql-813"><a href="#Generator.directory_sql-813"><span class="linenos">813</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">"LOCAL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.directory_sql-814"><a href="#Generator.directory_sql-814"><span class="linenos">814</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"row_format"</span><span class="p">)</span> +</span><span id="Generator.directory_sql-815"><a href="#Generator.directory_sql-815"><span class="linenos">815</span></a> <span class="n">row_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.directory_sql-816"><a href="#Generator.directory_sql-816"><span class="linenos">816</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2">DIRECTORY </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">row_format</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6733,18 +6861,18 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.delete_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.delete_sql-809"><a href="#Generator.delete_sql-809"><span class="linenos">809</span></a> <span class="k">def</span> <span class="nf">delete_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.delete_sql-810"><a href="#Generator.delete_sql-810"><span class="linenos">810</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.delete_sql-811"><a href="#Generator.delete_sql-811"><span class="linenos">811</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FROM </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.delete_sql-812"><a href="#Generator.delete_sql-812"><span class="linenos">812</span></a> <span class="n">using_sql</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.delete_sql-813"><a href="#Generator.delete_sql-813"><span class="linenos">813</span></a> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">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">'using'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">', USING '</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.delete_sql-814"><a href="#Generator.delete_sql-814"><span class="linenos">814</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">"using"</span><span class="p">)</span> -</span><span id="Generator.delete_sql-815"><a href="#Generator.delete_sql-815"><span class="linenos">815</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.delete_sql-816"><a href="#Generator.delete_sql-816"><span class="linenos">816</span></a> <span class="p">)</span> -</span><span id="Generator.delete_sql-817"><a href="#Generator.delete_sql-817"><span class="linenos">817</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> -</span><span id="Generator.delete_sql-818"><a href="#Generator.delete_sql-818"><span class="linenos">818</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> -</span><span id="Generator.delete_sql-819"><a href="#Generator.delete_sql-819"><span class="linenos">819</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"DELETE</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">using_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.delete_sql-820"><a href="#Generator.delete_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">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.delete_sql-818"><a href="#Generator.delete_sql-818"><span class="linenos">818</span></a> <span class="k">def</span> <span class="nf">delete_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.delete_sql-819"><a href="#Generator.delete_sql-819"><span class="linenos">819</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.delete_sql-820"><a href="#Generator.delete_sql-820"><span class="linenos">820</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FROM </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.delete_sql-821"><a href="#Generator.delete_sql-821"><span class="linenos">821</span></a> <span class="n">using_sql</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.delete_sql-822"><a href="#Generator.delete_sql-822"><span class="linenos">822</span></a> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">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">'using'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">', USING '</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.delete_sql-823"><a href="#Generator.delete_sql-823"><span class="linenos">823</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">"using"</span><span class="p">)</span> +</span><span id="Generator.delete_sql-824"><a href="#Generator.delete_sql-824"><span class="linenos">824</span></a> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.delete_sql-825"><a href="#Generator.delete_sql-825"><span class="linenos">825</span></a> <span class="p">)</span> +</span><span id="Generator.delete_sql-826"><a href="#Generator.delete_sql-826"><span class="linenos">826</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> +</span><span id="Generator.delete_sql-827"><a href="#Generator.delete_sql-827"><span class="linenos">827</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="Generator.delete_sql-828"><a href="#Generator.delete_sql-828"><span class="linenos">828</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"DELETE</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">using_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.delete_sql-829"><a href="#Generator.delete_sql-829"><span class="linenos">829</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> </span></pre></div> @@ -6762,18 +6890,18 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.drop_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.drop_sql-822"><a href="#Generator.drop_sql-822"><span class="linenos">822</span></a> <span class="k">def</span> <span class="nf">drop_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.drop_sql-823"><a href="#Generator.drop_sql-823"><span class="linenos">823</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.drop_sql-824"><a href="#Generator.drop_sql-824"><span class="linenos">824</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> -</span><span id="Generator.drop_sql-825"><a href="#Generator.drop_sql-825"><span class="linenos">825</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator.drop_sql-826"><a href="#Generator.drop_sql-826"><span class="linenos">826</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.drop_sql-827"><a href="#Generator.drop_sql-827"><span class="linenos">827</span></a> <span class="n">materialized</span> <span class="o">=</span> <span class="s2">" MATERIALIZED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"materialized"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.drop_sql-828"><a href="#Generator.drop_sql-828"><span class="linenos">828</span></a> <span class="n">cascade</span> <span class="o">=</span> <span class="s2">" CASCADE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"cascade"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.drop_sql-829"><a href="#Generator.drop_sql-829"><span class="linenos">829</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="s2">" CONSTRAINTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"constraints"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.drop_sql-830"><a href="#Generator.drop_sql-830"><span class="linenos">830</span></a> <span class="n">purge</span> <span class="o">=</span> <span class="s2">" PURGE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"purge"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.drop_sql-831"><a href="#Generator.drop_sql-831"><span class="linenos">831</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="Generator.drop_sql-832"><a href="#Generator.drop_sql-832"><span class="linenos">832</span></a> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">temporary</span><span class="si">}{</span><span class="n">materialized</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">exists_sql</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">cascade</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">purge</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.drop_sql-833"><a href="#Generator.drop_sql-833"><span class="linenos">833</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.drop_sql-831"><a href="#Generator.drop_sql-831"><span class="linenos">831</span></a> <span class="k">def</span> <span class="nf">drop_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.drop_sql-832"><a href="#Generator.drop_sql-832"><span class="linenos">832</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.drop_sql-833"><a href="#Generator.drop_sql-833"><span class="linenos">833</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> +</span><span id="Generator.drop_sql-834"><a href="#Generator.drop_sql-834"><span class="linenos">834</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator.drop_sql-835"><a href="#Generator.drop_sql-835"><span class="linenos">835</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.drop_sql-836"><a href="#Generator.drop_sql-836"><span class="linenos">836</span></a> <span class="n">materialized</span> <span class="o">=</span> <span class="s2">" MATERIALIZED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"materialized"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.drop_sql-837"><a href="#Generator.drop_sql-837"><span class="linenos">837</span></a> <span class="n">cascade</span> <span class="o">=</span> <span class="s2">" CASCADE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"cascade"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.drop_sql-838"><a href="#Generator.drop_sql-838"><span class="linenos">838</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="s2">" CONSTRAINTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"constraints"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.drop_sql-839"><a href="#Generator.drop_sql-839"><span class="linenos">839</span></a> <span class="n">purge</span> <span class="o">=</span> <span class="s2">" PURGE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"purge"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.drop_sql-840"><a href="#Generator.drop_sql-840"><span class="linenos">840</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="Generator.drop_sql-841"><a href="#Generator.drop_sql-841"><span class="linenos">841</span></a> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">temporary</span><span class="si">}{</span><span class="n">materialized</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">exists_sql</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">cascade</span><span class="si">}{</span><span class="n">constraints</span><span class="si">}{</span><span class="n">purge</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.drop_sql-842"><a href="#Generator.drop_sql-842"><span class="linenos">842</span></a> <span class="p">)</span> </span></pre></div> @@ -6791,11 +6919,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.except_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.except_sql-835"><a href="#Generator.except_sql-835"><span class="linenos">835</span></a> <span class="k">def</span> <span class="nf">except_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.except_sql-836"><a href="#Generator.except_sql-836"><span class="linenos">836</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span> -</span><span id="Generator.except_sql-837"><a href="#Generator.except_sql-837"><span class="linenos">837</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator.except_sql-838"><a href="#Generator.except_sql-838"><span class="linenos">838</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> -</span><span id="Generator.except_sql-839"><a href="#Generator.except_sql-839"><span class="linenos">839</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.except_sql-844"><a href="#Generator.except_sql-844"><span class="linenos">844</span></a> <span class="k">def</span> <span class="nf">except_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.except_sql-845"><a href="#Generator.except_sql-845"><span class="linenos">845</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span> +</span><span id="Generator.except_sql-846"><a href="#Generator.except_sql-846"><span class="linenos">846</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator.except_sql-847"><a href="#Generator.except_sql-847"><span class="linenos">847</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">except_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> +</span><span id="Generator.except_sql-848"><a href="#Generator.except_sql-848"><span class="linenos">848</span></a> <span class="p">)</span> </span></pre></div> @@ -6813,8 +6941,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.except_op"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.except_op-841"><a href="#Generator.except_op-841"><span class="linenos">841</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.except_op-842"><a href="#Generator.except_op-842"><span class="linenos">842</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">''</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.except_op-850"><a href="#Generator.except_op-850"><span class="linenos">850</span></a> <span class="k">def</span> <span class="nf">except_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.except_op-851"><a href="#Generator.except_op-851"><span class="linenos">851</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXCEPT</span><span class="si">{</span><span class="s1">''</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6832,15 +6960,15 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.fetch_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.fetch_sql-844"><a href="#Generator.fetch_sql-844"><span class="linenos">844</span></a> <span class="k">def</span> <span class="nf">fetch_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.fetch_sql-845"><a href="#Generator.fetch_sql-845"><span class="linenos">845</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"direction"</span><span class="p">)</span> -</span><span id="Generator.fetch_sql-846"><a href="#Generator.fetch_sql-846"><span class="linenos">846</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">direction</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">direction</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.fetch_sql-847"><a href="#Generator.fetch_sql-847"><span class="linenos">847</span></a> <span class="n">count</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"count"</span><span class="p">)</span> -</span><span id="Generator.fetch_sql-848"><a href="#Generator.fetch_sql-848"><span class="linenos">848</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">count</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.fetch_sql-849"><a href="#Generator.fetch_sql-849"><span class="linenos">849</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"percent"</span><span class="p">):</span> -</span><span id="Generator.fetch_sql-850"><a href="#Generator.fetch_sql-850"><span class="linenos">850</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2"> PERCENT"</span> -</span><span id="Generator.fetch_sql-851"><a href="#Generator.fetch_sql-851"><span class="linenos">851</span></a> <span class="n">with_ties_or_only</span> <span class="o">=</span> <span class="s2">"WITH TIES"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"with_ties"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ONLY"</span> -</span><span id="Generator.fetch_sql-852"><a href="#Generator.fetch_sql-852"><span class="linenos">852</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'FETCH'</span><span class="p">)</span><span class="si">}{</span><span class="n">direction</span><span class="si">}{</span><span class="n">count</span><span class="si">}</span><span class="s2"> ROWS </span><span class="si">{</span><span class="n">with_ties_or_only</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.fetch_sql-853"><a href="#Generator.fetch_sql-853"><span class="linenos">853</span></a> <span class="k">def</span> <span class="nf">fetch_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.fetch_sql-854"><a href="#Generator.fetch_sql-854"><span class="linenos">854</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"direction"</span><span class="p">)</span> +</span><span id="Generator.fetch_sql-855"><a href="#Generator.fetch_sql-855"><span class="linenos">855</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">direction</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">direction</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.fetch_sql-856"><a href="#Generator.fetch_sql-856"><span class="linenos">856</span></a> <span class="n">count</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"count"</span><span class="p">)</span> +</span><span id="Generator.fetch_sql-857"><a href="#Generator.fetch_sql-857"><span class="linenos">857</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">count</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.fetch_sql-858"><a href="#Generator.fetch_sql-858"><span class="linenos">858</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"percent"</span><span class="p">):</span> +</span><span id="Generator.fetch_sql-859"><a href="#Generator.fetch_sql-859"><span class="linenos">859</span></a> <span class="n">count</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2"> PERCENT"</span> +</span><span id="Generator.fetch_sql-860"><a href="#Generator.fetch_sql-860"><span class="linenos">860</span></a> <span class="n">with_ties_or_only</span> <span class="o">=</span> <span class="s2">"WITH TIES"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"with_ties"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ONLY"</span> +</span><span id="Generator.fetch_sql-861"><a href="#Generator.fetch_sql-861"><span class="linenos">861</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'FETCH'</span><span class="p">)</span><span class="si">}{</span><span class="n">direction</span><span class="si">}{</span><span class="n">count</span><span class="si">}</span><span class="s2"> ROWS </span><span class="si">{</span><span class="n">with_ties_or_only</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6858,10 +6986,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.filter_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.filter_sql-854"><a href="#Generator.filter_sql-854"><span class="linenos">854</span></a> <span class="k">def</span> <span class="nf">filter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Filter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.filter_sql-855"><a href="#Generator.filter_sql-855"><span class="linenos">855</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.filter_sql-856"><a href="#Generator.filter_sql-856"><span class="linenos">856</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)[</span><span class="mi">1</span><span class="p">:]</span> <span class="c1"># where has a leading space</span> -</span><span id="Generator.filter_sql-857"><a href="#Generator.filter_sql-857"><span class="linenos">857</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FILTER(</span><span class="si">{</span><span class="n">where</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.filter_sql-863"><a href="#Generator.filter_sql-863"><span class="linenos">863</span></a> <span class="k">def</span> <span class="nf">filter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Filter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.filter_sql-864"><a href="#Generator.filter_sql-864"><span class="linenos">864</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.filter_sql-865"><a href="#Generator.filter_sql-865"><span class="linenos">865</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)[</span><span class="mi">1</span><span class="p">:]</span> <span class="c1"># where has a leading space</span> +</span><span id="Generator.filter_sql-866"><a href="#Generator.filter_sql-866"><span class="linenos">866</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FILTER(</span><span class="si">{</span><span class="n">where</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -6879,10 +7007,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.hint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.hint_sql-859"><a href="#Generator.hint_sql-859"><span class="linenos">859</span></a> <span class="k">def</span> <span class="nf">hint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.hint_sql-860"><a href="#Generator.hint_sql-860"><span class="linenos">860</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">):</span> -</span><span id="Generator.hint_sql-861"><a href="#Generator.hint_sql-861"><span class="linenos">861</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Hints are not supported"</span><span class="p">)</span> -</span><span id="Generator.hint_sql-862"><a href="#Generator.hint_sql-862"><span class="linenos">862</span></a> <span class="k">return</span> <span class="s2">""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.hint_sql-868"><a href="#Generator.hint_sql-868"><span class="linenos">868</span></a> <span class="k">def</span> <span class="nf">hint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Hint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.hint_sql-869"><a href="#Generator.hint_sql-869"><span class="linenos">869</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">):</span> +</span><span id="Generator.hint_sql-870"><a href="#Generator.hint_sql-870"><span class="linenos">870</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Hints are not supported"</span><span class="p">)</span> +</span><span id="Generator.hint_sql-871"><a href="#Generator.hint_sql-871"><span class="linenos">871</span></a> <span class="k">return</span> <span class="s2">""</span> </span></pre></div> @@ -6900,21 +7028,21 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.index_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.index_sql-864"><a href="#Generator.index_sql-864"><span class="linenos">864</span></a> <span class="k">def</span> <span class="nf">index_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Index</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.index_sql-865"><a href="#Generator.index_sql-865"><span class="linenos">865</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">"UNIQUE "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.index_sql-866"><a href="#Generator.index_sql-866"><span class="linenos">866</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="s2">"PRIMARY "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"primary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.index_sql-867"><a href="#Generator.index_sql-867"><span class="linenos">867</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="s2">"AMP "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"amp"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.index_sql-868"><a href="#Generator.index_sql-868"><span class="linenos">868</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.index_sql-869"><a href="#Generator.index_sql-869"><span class="linenos">869</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"table"</span><span class="p">)</span> -</span><span id="Generator.index_sql-870"><a href="#Generator.index_sql-870"><span class="linenos">870</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">INDEX_ON</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">table</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.index_sql-871"><a href="#Generator.index_sql-871"><span class="linenos">871</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> -</span><span id="Generator.index_sql-872"><a href="#Generator.index_sql-872"><span class="linenos">872</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.index_sql-873"><a href="#Generator.index_sql-873"><span class="linenos">873</span></a> <span class="n">index</span> <span class="o">=</span> <span class="s2">"INDEX "</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.index_sql-874"><a href="#Generator.index_sql-874"><span class="linenos">874</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.index_sql-875"><a href="#Generator.index_sql-875"><span class="linenos">875</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.index_sql-876"><a href="#Generator.index_sql-876"><span class="linenos">876</span></a> <span class="n">partition_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"partition_by"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.index_sql-877"><a href="#Generator.index_sql-877"><span class="linenos">877</span></a> <span class="n">partition_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" PARTITION BY </span><span class="si">{</span><span class="n">partition_by</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition_by</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.index_sql-878"><a href="#Generator.index_sql-878"><span class="linenos">878</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">unique</span><span class="si">}{</span><span class="n">primary</span><span class="si">}{</span><span class="n">amp</span><span class="si">}{</span><span class="n">index</span><span class="si">}{</span><span class="n">name</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">columns</span><span class="si">}{</span><span class="n">partition_by</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.index_sql-873"><a href="#Generator.index_sql-873"><span class="linenos">873</span></a> <span class="k">def</span> <span class="nf">index_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Index</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.index_sql-874"><a href="#Generator.index_sql-874"><span class="linenos">874</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="s2">"UNIQUE "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unique"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.index_sql-875"><a href="#Generator.index_sql-875"><span class="linenos">875</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="s2">"PRIMARY "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"primary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.index_sql-876"><a href="#Generator.index_sql-876"><span class="linenos">876</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="s2">"AMP "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"amp"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.index_sql-877"><a href="#Generator.index_sql-877"><span class="linenos">877</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.index_sql-878"><a href="#Generator.index_sql-878"><span class="linenos">878</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"table"</span><span class="p">)</span> +</span><span id="Generator.index_sql-879"><a href="#Generator.index_sql-879"><span class="linenos">879</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">INDEX_ON</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">table</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.index_sql-880"><a href="#Generator.index_sql-880"><span class="linenos">880</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> +</span><span id="Generator.index_sql-881"><a href="#Generator.index_sql-881"><span class="linenos">881</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.index_sql-882"><a href="#Generator.index_sql-882"><span class="linenos">882</span></a> <span class="n">index</span> <span class="o">=</span> <span class="s2">"INDEX "</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.index_sql-883"><a href="#Generator.index_sql-883"><span class="linenos">883</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.index_sql-884"><a href="#Generator.index_sql-884"><span class="linenos">884</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.index_sql-885"><a href="#Generator.index_sql-885"><span class="linenos">885</span></a> <span class="n">partition_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"partition_by"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.index_sql-886"><a href="#Generator.index_sql-886"><span class="linenos">886</span></a> <span class="n">partition_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" PARTITION BY </span><span class="si">{</span><span class="n">partition_by</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition_by</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.index_sql-887"><a href="#Generator.index_sql-887"><span class="linenos">887</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">unique</span><span class="si">}{</span><span class="n">primary</span><span class="si">}{</span><span class="n">amp</span><span class="si">}{</span><span class="n">index</span><span class="si">}{</span><span class="n">name</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">columns</span><span class="si">}{</span><span class="n">partition_by</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -6932,19 +7060,19 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.identifier_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.identifier_sql-880"><a href="#Generator.identifier_sql-880"><span class="linenos">880</span></a> <span class="k">def</span> <span class="nf">identifier_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.identifier_sql-881"><a href="#Generator.identifier_sql-881"><span class="linenos">881</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> -</span><span id="Generator.identifier_sql-882"><a href="#Generator.identifier_sql-882"><span class="linenos">882</span></a> <span class="n">lower</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="Generator.identifier_sql-883"><a href="#Generator.identifier_sql-883"><span class="linenos">883</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">lower</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> <span class="k">else</span> <span class="n">text</span> -</span><span id="Generator.identifier_sql-884"><a href="#Generator.identifier_sql-884"><span class="linenos">884</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">)</span> -</span><span id="Generator.identifier_sql-885"><a href="#Generator.identifier_sql-885"><span class="linenos">885</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="Generator.identifier_sql-886"><a href="#Generator.identifier_sql-886"><span class="linenos">886</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> -</span><span id="Generator.identifier_sql-887"><a href="#Generator.identifier_sql-887"><span class="linenos">887</span></a> <span class="ow">or</span> <span class="n">should_identify</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span><span class="p">)</span> -</span><span id="Generator.identifier_sql-888"><a href="#Generator.identifier_sql-888"><span class="linenos">888</span></a> <span class="ow">or</span> <span class="n">lower</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span> -</span><span id="Generator.identifier_sql-889"><a href="#Generator.identifier_sql-889"><span class="linenos">889</span></a> <span class="ow">or</span> <span class="p">(</span><span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="ow">and</span> <span class="n">text</span><span class="p">[:</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">isdigit</span><span class="p">())</span> -</span><span id="Generator.identifier_sql-890"><a href="#Generator.identifier_sql-890"><span class="linenos">890</span></a> <span class="p">):</span> -</span><span id="Generator.identifier_sql-891"><a href="#Generator.identifier_sql-891"><span class="linenos">891</span></a> <span class="n">text</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_START</span><span class="si">}{</span><span class="n">text</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.identifier_sql-892"><a href="#Generator.identifier_sql-892"><span class="linenos">892</span></a> <span class="k">return</span> <span class="n">text</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.identifier_sql-889"><a href="#Generator.identifier_sql-889"><span class="linenos">889</span></a> <span class="k">def</span> <span class="nf">identifier_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.identifier_sql-890"><a href="#Generator.identifier_sql-890"><span class="linenos">890</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> +</span><span id="Generator.identifier_sql-891"><a href="#Generator.identifier_sql-891"><span class="linenos">891</span></a> <span class="n">lower</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> +</span><span id="Generator.identifier_sql-892"><a href="#Generator.identifier_sql-892"><span class="linenos">892</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">lower</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> <span class="k">else</span> <span class="n">text</span> +</span><span id="Generator.identifier_sql-893"><a href="#Generator.identifier_sql-893"><span class="linenos">893</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_identifier_end</span><span class="p">)</span> +</span><span id="Generator.identifier_sql-894"><a href="#Generator.identifier_sql-894"><span class="linenos">894</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="Generator.identifier_sql-895"><a href="#Generator.identifier_sql-895"><span class="linenos">895</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">quoted</span> +</span><span id="Generator.identifier_sql-896"><a href="#Generator.identifier_sql-896"><span class="linenos">896</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">can_identify</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">identify</span><span class="p">)</span> +</span><span id="Generator.identifier_sql-897"><a href="#Generator.identifier_sql-897"><span class="linenos">897</span></a> <span class="ow">or</span> <span class="n">lower</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span> +</span><span id="Generator.identifier_sql-898"><a href="#Generator.identifier_sql-898"><span class="linenos">898</span></a> <span class="ow">or</span> <span class="p">(</span><span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span> <span class="ow">and</span> <span class="n">text</span><span class="p">[:</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">isdigit</span><span class="p">())</span> +</span><span id="Generator.identifier_sql-899"><a href="#Generator.identifier_sql-899"><span class="linenos">899</span></a> <span class="p">):</span> +</span><span id="Generator.identifier_sql-900"><a href="#Generator.identifier_sql-900"><span class="linenos">900</span></a> <span class="n">text</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_START</span><span class="si">}{</span><span class="n">text</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIER_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.identifier_sql-901"><a href="#Generator.identifier_sql-901"><span class="linenos">901</span></a> <span class="k">return</span> <span class="n">text</span> </span></pre></div> @@ -6962,12 +7090,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.inputoutputformat_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.inputoutputformat_sql-894"><a href="#Generator.inputoutputformat_sql-894"><span class="linenos">894</span></a> <span class="k">def</span> <span class="nf">inputoutputformat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.inputoutputformat_sql-895"><a href="#Generator.inputoutputformat_sql-895"><span class="linenos">895</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> -</span><span id="Generator.inputoutputformat_sql-896"><a href="#Generator.inputoutputformat_sql-896"><span class="linenos">896</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.inputoutputformat_sql-897"><a href="#Generator.inputoutputformat_sql-897"><span class="linenos">897</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"output_format"</span><span class="p">)</span> -</span><span id="Generator.inputoutputformat_sql-898"><a href="#Generator.inputoutputformat_sql-898"><span class="linenos">898</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OUTPUTFORMAT </span><span class="si">{</span><span class="n">output_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">output_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.inputoutputformat_sql-899"><a href="#Generator.inputoutputformat_sql-899"><span class="linenos">899</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">input_format</span><span class="p">,</span> <span class="n">output_format</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.inputoutputformat_sql-903"><a href="#Generator.inputoutputformat_sql-903"><span class="linenos">903</span></a> <span class="k">def</span> <span class="nf">inputoutputformat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.inputoutputformat_sql-904"><a href="#Generator.inputoutputformat_sql-904"><span class="linenos">904</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> +</span><span id="Generator.inputoutputformat_sql-905"><a href="#Generator.inputoutputformat_sql-905"><span class="linenos">905</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.inputoutputformat_sql-906"><a href="#Generator.inputoutputformat_sql-906"><span class="linenos">906</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"output_format"</span><span class="p">)</span> +</span><span id="Generator.inputoutputformat_sql-907"><a href="#Generator.inputoutputformat_sql-907"><span class="linenos">907</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"OUTPUTFORMAT </span><span class="si">{</span><span class="n">output_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">output_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.inputoutputformat_sql-908"><a href="#Generator.inputoutputformat_sql-908"><span class="linenos">908</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="n">input_format</span><span class="p">,</span> <span class="n">output_format</span><span class="p">))</span> </span></pre></div> @@ -6985,9 +7113,9 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.national_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.national_sql-901"><a href="#Generator.national_sql-901"><span class="linenos">901</span></a> <span class="k">def</span> <span class="nf">national_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">National</span><span class="p">,</span> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"N"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.national_sql-902"><a href="#Generator.national_sql-902"><span class="linenos">902</span></a> <span class="n">string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> -</span><span id="Generator.national_sql-903"><a href="#Generator.national_sql-903"><span class="linenos">903</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">string</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.national_sql-910"><a href="#Generator.national_sql-910"><span class="linenos">910</span></a> <span class="k">def</span> <span class="nf">national_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">National</span><span class="p">,</span> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"N"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.national_sql-911"><a href="#Generator.national_sql-911"><span class="linenos">911</span></a> <span class="n">string</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> +</span><span id="Generator.national_sql-912"><a href="#Generator.national_sql-912"><span class="linenos">912</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">string</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7005,8 +7133,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.partition_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.partition_sql-905"><a href="#Generator.partition_sql-905"><span class="linenos">905</span></a> <span class="k">def</span> <span class="nf">partition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Partition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.partition_sql-906"><a href="#Generator.partition_sql-906"><span class="linenos">906</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.partition_sql-914"><a href="#Generator.partition_sql-914"><span class="linenos">914</span></a> <span class="k">def</span> <span class="nf">partition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Partition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.partition_sql-915"><a href="#Generator.partition_sql-915"><span class="linenos">915</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -7024,20 +7152,20 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.properties_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.properties_sql-908"><a href="#Generator.properties_sql-908"><span class="linenos">908</span></a> <span class="k">def</span> <span class="nf">properties_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.properties_sql-909"><a href="#Generator.properties_sql-909"><span class="linenos">909</span></a> <span class="n">root_properties</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator.properties_sql-910"><a href="#Generator.properties_sql-910"><span class="linenos">910</span></a> <span class="n">with_properties</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator.properties_sql-911"><a href="#Generator.properties_sql-911"><span class="linenos">911</span></a> -</span><span id="Generator.properties_sql-912"><a href="#Generator.properties_sql-912"><span class="linenos">912</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator.properties_sql-913"><a href="#Generator.properties_sql-913"><span class="linenos">913</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> -</span><span id="Generator.properties_sql-914"><a href="#Generator.properties_sql-914"><span class="linenos">914</span></a> <span class="k">if</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">:</span> -</span><span id="Generator.properties_sql-915"><a href="#Generator.properties_sql-915"><span class="linenos">915</span></a> <span class="n">with_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator.properties_sql-916"><a href="#Generator.properties_sql-916"><span class="linenos">916</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">:</span> -</span><span id="Generator.properties_sql-917"><a href="#Generator.properties_sql-917"><span class="linenos">917</span></a> <span class="n">root_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator.properties_sql-918"><a href="#Generator.properties_sql-918"><span class="linenos">918</span></a> -</span><span id="Generator.properties_sql-919"><a href="#Generator.properties_sql-919"><span class="linenos">919</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_properties</span><span class="p">(</span> -</span><span id="Generator.properties_sql-920"><a href="#Generator.properties_sql-920"><span class="linenos">920</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">root_properties</span><span class="p">)</span> -</span><span id="Generator.properties_sql-921"><a href="#Generator.properties_sql-921"><span class="linenos">921</span></a> <span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">with_properties</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">with_properties</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.properties_sql-917"><a href="#Generator.properties_sql-917"><span class="linenos">917</span></a> <span class="k">def</span> <span class="nf">properties_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.properties_sql-918"><a href="#Generator.properties_sql-918"><span class="linenos">918</span></a> <span class="n">root_properties</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator.properties_sql-919"><a href="#Generator.properties_sql-919"><span class="linenos">919</span></a> <span class="n">with_properties</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator.properties_sql-920"><a href="#Generator.properties_sql-920"><span class="linenos">920</span></a> +</span><span id="Generator.properties_sql-921"><a href="#Generator.properties_sql-921"><span class="linenos">921</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator.properties_sql-922"><a href="#Generator.properties_sql-922"><span class="linenos">922</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> +</span><span id="Generator.properties_sql-923"><a href="#Generator.properties_sql-923"><span class="linenos">923</span></a> <span class="k">if</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">:</span> +</span><span id="Generator.properties_sql-924"><a href="#Generator.properties_sql-924"><span class="linenos">924</span></a> <span class="n">with_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator.properties_sql-925"><a href="#Generator.properties_sql-925"><span class="linenos">925</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">:</span> +</span><span id="Generator.properties_sql-926"><a href="#Generator.properties_sql-926"><span class="linenos">926</span></a> <span class="n">root_properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator.properties_sql-927"><a href="#Generator.properties_sql-927"><span class="linenos">927</span></a> +</span><span id="Generator.properties_sql-928"><a href="#Generator.properties_sql-928"><span class="linenos">928</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">root_properties</span><span class="p">(</span> +</span><span id="Generator.properties_sql-929"><a href="#Generator.properties_sql-929"><span class="linenos">929</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">root_properties</span><span class="p">)</span> +</span><span id="Generator.properties_sql-930"><a href="#Generator.properties_sql-930"><span class="linenos">930</span></a> <span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">with_properties</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">(</span><span class="n">expressions</span><span class="o">=</span><span class="n">with_properties</span><span class="p">))</span> </span></pre></div> @@ -7055,10 +7183,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.root_properties"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.root_properties-923"><a href="#Generator.root_properties-923"><span class="linenos">923</span></a> <span class="k">def</span> <span class="nf">root_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.root_properties-924"><a href="#Generator.root_properties-924"><span class="linenos">924</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator.root_properties-925"><a href="#Generator.root_properties-925"><span class="linenos">925</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator.root_properties-926"><a href="#Generator.root_properties-926"><span class="linenos">926</span></a> <span class="k">return</span> <span class="s2">""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.root_properties-932"><a href="#Generator.root_properties-932"><span class="linenos">932</span></a> <span class="k">def</span> <span class="nf">root_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.root_properties-933"><a href="#Generator.root_properties-933"><span class="linenos">933</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator.root_properties-934"><a href="#Generator.root_properties-934"><span class="linenos">934</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator.root_properties-935"><a href="#Generator.root_properties-935"><span class="linenos">935</span></a> <span class="k">return</span> <span class="s2">""</span> </span></pre></div> @@ -7076,19 +7204,19 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.properties"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.properties-928"><a href="#Generator.properties-928"><span class="linenos">928</span></a> <span class="k">def</span> <span class="nf">properties</span><span class="p">(</span> -</span><span id="Generator.properties-929"><a href="#Generator.properties-929"><span class="linenos">929</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator.properties-930"><a href="#Generator.properties-930"><span class="linenos">930</span></a> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">,</span> -</span><span id="Generator.properties-931"><a href="#Generator.properties-931"><span class="linenos">931</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="Generator.properties-932"><a href="#Generator.properties-932"><span class="linenos">932</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">,</span> -</span><span id="Generator.properties-933"><a href="#Generator.properties-933"><span class="linenos">933</span></a> <span class="n">suffix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="Generator.properties-934"><a href="#Generator.properties-934"><span class="linenos">934</span></a> <span class="n">wrapped</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Generator.properties-935"><a href="#Generator.properties-935"><span class="linenos">935</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.properties-936"><a href="#Generator.properties-936"><span class="linenos">936</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator.properties-937"><a href="#Generator.properties-937"><span class="linenos">937</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator.properties-938"><a href="#Generator.properties-938"><span class="linenos">938</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">wrapped</span> <span class="k">else</span> <span class="n">expressions</span> -</span><span id="Generator.properties-939"><a href="#Generator.properties-939"><span class="linenos">939</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="s1">' '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">prefix</span><span class="w"> </span><span class="ow">and</span><span class="w"> </span><span class="n">prefix</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="s1">' '</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.properties-940"><a href="#Generator.properties-940"><span class="linenos">940</span></a> <span class="k">return</span> <span class="s2">""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.properties-937"><a href="#Generator.properties-937"><span class="linenos">937</span></a> <span class="k">def</span> <span class="nf">properties</span><span class="p">(</span> +</span><span id="Generator.properties-938"><a href="#Generator.properties-938"><span class="linenos">938</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator.properties-939"><a href="#Generator.properties-939"><span class="linenos">939</span></a> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">,</span> +</span><span id="Generator.properties-940"><a href="#Generator.properties-940"><span class="linenos">940</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="Generator.properties-941"><a href="#Generator.properties-941"><span class="linenos">941</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">,</span> +</span><span id="Generator.properties-942"><a href="#Generator.properties-942"><span class="linenos">942</span></a> <span class="n">suffix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="Generator.properties-943"><a href="#Generator.properties-943"><span class="linenos">943</span></a> <span class="n">wrapped</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Generator.properties-944"><a href="#Generator.properties-944"><span class="linenos">944</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.properties-945"><a href="#Generator.properties-945"><span class="linenos">945</span></a> <span class="k">if</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator.properties-946"><a href="#Generator.properties-946"><span class="linenos">946</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator.properties-947"><a href="#Generator.properties-947"><span class="linenos">947</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">wrapped</span> <span class="k">else</span> <span class="n">expressions</span> +</span><span id="Generator.properties-948"><a href="#Generator.properties-948"><span class="linenos">948</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="s1">' '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">prefix</span><span class="w"> </span><span class="ow">and</span><span class="w"> </span><span class="n">prefix</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="s1">' '</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.properties-949"><a href="#Generator.properties-949"><span class="linenos">949</span></a> <span class="k">return</span> <span class="s2">""</span> </span></pre></div> @@ -7106,8 +7234,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.with_properties"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.with_properties-942"><a href="#Generator.with_properties-942"><span class="linenos">942</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.with_properties-943"><a href="#Generator.with_properties-943"><span class="linenos">943</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.with_properties-951"><a href="#Generator.with_properties-951"><span class="linenos">951</span></a> <span class="k">def</span> <span class="nf">with_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.with_properties-952"><a href="#Generator.with_properties-952"><span class="linenos">952</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">properties</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">))</span> </span></pre></div> @@ -7125,33 +7253,33 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.locate_properties"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.locate_properties-945"><a href="#Generator.locate_properties-945"><span class="linenos">945</span></a> <span class="k">def</span> <span class="nf">locate_properties</span><span class="p">(</span> -</span><span id="Generator.locate_properties-946"><a href="#Generator.locate_properties-946"><span class="linenos">946</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span> -</span><span id="Generator.locate_properties-947"><a href="#Generator.locate_properties-947"><span class="linenos">947</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">]]:</span> -</span><span id="Generator.locate_properties-948"><a href="#Generator.locate_properties-948"><span class="linenos">948</span></a> <span class="n">properties_locs</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Generator.locate_properties-949"><a href="#Generator.locate_properties-949"><span class="linenos">949</span></a> <span class="n">key</span><span class="p">:</span> <span class="p">[]</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span> -</span><span id="Generator.locate_properties-950"><a href="#Generator.locate_properties-950"><span class="linenos">950</span></a> <span class="p">}</span> -</span><span id="Generator.locate_properties-951"><a href="#Generator.locate_properties-951"><span class="linenos">951</span></a> -</span><span id="Generator.locate_properties-952"><a href="#Generator.locate_properties-952"><span class="linenos">952</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator.locate_properties-953"><a href="#Generator.locate_properties-953"><span class="linenos">953</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> -</span><span id="Generator.locate_properties-954"><a href="#Generator.locate_properties-954"><span class="linenos">954</span></a> <span class="k">if</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">:</span> -</span><span id="Generator.locate_properties-955"><a href="#Generator.locate_properties-955"><span class="linenos">955</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator.locate_properties-956"><a href="#Generator.locate_properties-956"><span class="linenos">956</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">:</span> -</span><span id="Generator.locate_properties-957"><a href="#Generator.locate_properties-957"><span class="linenos">957</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator.locate_properties-958"><a href="#Generator.locate_properties-958"><span class="linenos">958</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">:</span> -</span><span id="Generator.locate_properties-959"><a href="#Generator.locate_properties-959"><span class="linenos">959</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator.locate_properties-960"><a href="#Generator.locate_properties-960"><span class="linenos">960</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">:</span> -</span><span id="Generator.locate_properties-961"><a href="#Generator.locate_properties-961"><span class="linenos">961</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator.locate_properties-962"><a href="#Generator.locate_properties-962"><span class="linenos">962</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">:</span> -</span><span id="Generator.locate_properties-963"><a href="#Generator.locate_properties-963"><span class="linenos">963</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator.locate_properties-964"><a href="#Generator.locate_properties-964"><span class="linenos">964</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">:</span> -</span><span id="Generator.locate_properties-965"><a href="#Generator.locate_properties-965"><span class="linenos">965</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator.locate_properties-966"><a href="#Generator.locate_properties-966"><span class="linenos">966</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">:</span> -</span><span id="Generator.locate_properties-967"><a href="#Generator.locate_properties-967"><span class="linenos">967</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Generator.locate_properties-968"><a href="#Generator.locate_properties-968"><span class="linenos">968</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">:</span> -</span><span id="Generator.locate_properties-969"><a href="#Generator.locate_properties-969"><span class="linenos">969</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">p</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.locate_properties-970"><a href="#Generator.locate_properties-970"><span class="linenos">970</span></a> -</span><span id="Generator.locate_properties-971"><a href="#Generator.locate_properties-971"><span class="linenos">971</span></a> <span class="k">return</span> <span class="n">properties_locs</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.locate_properties-954"><a href="#Generator.locate_properties-954"><span class="linenos">954</span></a> <span class="k">def</span> <span class="nf">locate_properties</span><span class="p">(</span> +</span><span id="Generator.locate_properties-955"><a href="#Generator.locate_properties-955"><span class="linenos">955</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">properties</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span> +</span><span id="Generator.locate_properties-956"><a href="#Generator.locate_properties-956"><span class="linenos">956</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">]]:</span> +</span><span id="Generator.locate_properties-957"><a href="#Generator.locate_properties-957"><span class="linenos">957</span></a> <span class="n">properties_locs</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Generator.locate_properties-958"><a href="#Generator.locate_properties-958"><span class="linenos">958</span></a> <span class="n">key</span><span class="p">:</span> <span class="p">[]</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span> +</span><span id="Generator.locate_properties-959"><a href="#Generator.locate_properties-959"><span class="linenos">959</span></a> <span class="p">}</span> +</span><span id="Generator.locate_properties-960"><a href="#Generator.locate_properties-960"><span class="linenos">960</span></a> +</span><span id="Generator.locate_properties-961"><a href="#Generator.locate_properties-961"><span class="linenos">961</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator.locate_properties-962"><a href="#Generator.locate_properties-962"><span class="linenos">962</span></a> <span class="n">p_loc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTIES_LOCATION</span><span class="p">[</span><span class="n">p</span><span class="o">.</span><span class="vm">__class__</span><span class="p">]</span> +</span><span id="Generator.locate_properties-963"><a href="#Generator.locate_properties-963"><span class="linenos">963</span></a> <span class="k">if</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">:</span> +</span><span id="Generator.locate_properties-964"><a href="#Generator.locate_properties-964"><span class="linenos">964</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_NAME</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator.locate_properties-965"><a href="#Generator.locate_properties-965"><span class="linenos">965</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">:</span> +</span><span id="Generator.locate_properties-966"><a href="#Generator.locate_properties-966"><span class="linenos">966</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_INDEX</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator.locate_properties-967"><a href="#Generator.locate_properties-967"><span class="linenos">967</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">:</span> +</span><span id="Generator.locate_properties-968"><a href="#Generator.locate_properties-968"><span class="linenos">968</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_SCHEMA</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator.locate_properties-969"><a href="#Generator.locate_properties-969"><span class="linenos">969</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">:</span> +</span><span id="Generator.locate_properties-970"><a href="#Generator.locate_properties-970"><span class="linenos">970</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_WITH</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator.locate_properties-971"><a href="#Generator.locate_properties-971"><span class="linenos">971</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">:</span> +</span><span id="Generator.locate_properties-972"><a href="#Generator.locate_properties-972"><span class="linenos">972</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_CREATE</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator.locate_properties-973"><a href="#Generator.locate_properties-973"><span class="linenos">973</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">:</span> +</span><span id="Generator.locate_properties-974"><a href="#Generator.locate_properties-974"><span class="linenos">974</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_ALIAS</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator.locate_properties-975"><a href="#Generator.locate_properties-975"><span class="linenos">975</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">:</span> +</span><span id="Generator.locate_properties-976"><a href="#Generator.locate_properties-976"><span class="linenos">976</span></a> <span class="n">properties_locs</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">POST_EXPRESSION</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Generator.locate_properties-977"><a href="#Generator.locate_properties-977"><span class="linenos">977</span></a> <span class="k">elif</span> <span class="n">p_loc</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">Location</span><span class="o">.</span><span class="n">UNSUPPORTED</span><span class="p">:</span> +</span><span id="Generator.locate_properties-978"><a href="#Generator.locate_properties-978"><span class="linenos">978</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">p</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.locate_properties-979"><a href="#Generator.locate_properties-979"><span class="linenos">979</span></a> +</span><span id="Generator.locate_properties-980"><a href="#Generator.locate_properties-980"><span class="linenos">980</span></a> <span class="k">return</span> <span class="n">properties_locs</span> </span></pre></div> @@ -7169,16 +7297,16 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.property_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.property_sql-973"><a href="#Generator.property_sql-973"><span class="linenos">973</span></a> <span class="k">def</span> <span class="nf">property_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.property_sql-974"><a href="#Generator.property_sql-974"><span class="linenos">974</span></a> <span class="n">property_cls</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span> -</span><span id="Generator.property_sql-975"><a href="#Generator.property_sql-975"><span class="linenos">975</span></a> <span class="k">if</span> <span class="n">property_cls</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> -</span><span id="Generator.property_sql-976"><a href="#Generator.property_sql-976"><span class="linenos">976</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.property_sql-977"><a href="#Generator.property_sql-977"><span class="linenos">977</span></a> -</span><span id="Generator.property_sql-978"><a href="#Generator.property_sql-978"><span class="linenos">978</span></a> <span class="n">property_name</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">PROPERTY_TO_NAME</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">property_cls</span><span class="p">)</span> -</span><span id="Generator.property_sql-979"><a href="#Generator.property_sql-979"><span class="linenos">979</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">property_name</span><span class="p">:</span> -</span><span id="Generator.property_sql-980"><a href="#Generator.property_sql-980"><span class="linenos">980</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.property_sql-981"><a href="#Generator.property_sql-981"><span class="linenos">981</span></a> -</span><span id="Generator.property_sql-982"><a href="#Generator.property_sql-982"><span class="linenos">982</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">property_name</span><span class="si">}</span><span class="s2">=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.property_sql-982"><a href="#Generator.property_sql-982"><span class="linenos">982</span></a> <span class="k">def</span> <span class="nf">property_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.property_sql-983"><a href="#Generator.property_sql-983"><span class="linenos">983</span></a> <span class="n">property_cls</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span> +</span><span id="Generator.property_sql-984"><a href="#Generator.property_sql-984"><span class="linenos">984</span></a> <span class="k">if</span> <span class="n">property_cls</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">:</span> +</span><span id="Generator.property_sql-985"><a href="#Generator.property_sql-985"><span class="linenos">985</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.property_sql-986"><a href="#Generator.property_sql-986"><span class="linenos">986</span></a> +</span><span id="Generator.property_sql-987"><a href="#Generator.property_sql-987"><span class="linenos">987</span></a> <span class="n">property_name</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">PROPERTY_TO_NAME</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">property_cls</span><span class="p">)</span> +</span><span id="Generator.property_sql-988"><a href="#Generator.property_sql-988"><span class="linenos">988</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">property_name</span><span class="p">:</span> +</span><span id="Generator.property_sql-989"><a href="#Generator.property_sql-989"><span class="linenos">989</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.property_sql-990"><a href="#Generator.property_sql-990"><span class="linenos">990</span></a> +</span><span id="Generator.property_sql-991"><a href="#Generator.property_sql-991"><span class="linenos">991</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">property_name</span><span class="si">}</span><span class="s2">=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7196,10 +7324,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.likeproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.likeproperty_sql-984"><a href="#Generator.likeproperty_sql-984"><span class="linenos">984</span></a> <span class="k">def</span> <span class="nf">likeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.likeproperty_sql-985"><a href="#Generator.likeproperty_sql-985"><span class="linenos">985</span></a> <span class="n">options</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Generator.likeproperty_sql-986"><a href="#Generator.likeproperty_sql-986"><span class="linenos">986</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.likeproperty_sql-987"><a href="#Generator.likeproperty_sql-987"><span class="linenos">987</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LIKE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.likeproperty_sql-993"><a href="#Generator.likeproperty_sql-993"><span class="linenos">993</span></a> <span class="k">def</span> <span class="nf">likeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LikeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.likeproperty_sql-994"><a href="#Generator.likeproperty_sql-994"><span class="linenos">994</span></a> <span class="n">options</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">e</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator.likeproperty_sql-995"><a href="#Generator.likeproperty_sql-995"><span class="linenos">995</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.likeproperty_sql-996"><a href="#Generator.likeproperty_sql-996"><span class="linenos">996</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LIKE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7217,10 +7345,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.fallbackproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.fallbackproperty_sql-989"><a href="#Generator.fallbackproperty_sql-989"><span class="linenos">989</span></a> <span class="k">def</span> <span class="nf">fallbackproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.fallbackproperty_sql-990"><a href="#Generator.fallbackproperty_sql-990"><span class="linenos">990</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.fallbackproperty_sql-991"><a href="#Generator.fallbackproperty_sql-991"><span class="linenos">991</span></a> <span class="n">protection</span> <span class="o">=</span> <span class="s2">" PROTECTION"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"protection"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.fallbackproperty_sql-992"><a href="#Generator.fallbackproperty_sql-992"><span class="linenos">992</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}</span><span class="s2">FALLBACK</span><span class="si">{</span><span class="n">protection</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.fallbackproperty_sql-998"><a href="#Generator.fallbackproperty_sql-998"><span class="linenos"> 998</span></a> <span class="k">def</span> <span class="nf">fallbackproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.fallbackproperty_sql-999"><a href="#Generator.fallbackproperty_sql-999"><span class="linenos"> 999</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.fallbackproperty_sql-1000"><a href="#Generator.fallbackproperty_sql-1000"><span class="linenos">1000</span></a> <span class="n">protection</span> <span class="o">=</span> <span class="s2">" PROTECTION"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"protection"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.fallbackproperty_sql-1001"><a href="#Generator.fallbackproperty_sql-1001"><span class="linenos">1001</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}</span><span class="s2">FALLBACK</span><span class="si">{</span><span class="n">protection</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7238,14 +7366,14 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.journalproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.journalproperty_sql-994"><a href="#Generator.journalproperty_sql-994"><span class="linenos"> 994</span></a> <span class="k">def</span> <span class="nf">journalproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.journalproperty_sql-995"><a href="#Generator.journalproperty_sql-995"><span class="linenos"> 995</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.journalproperty_sql-996"><a href="#Generator.journalproperty_sql-996"><span class="linenos"> 996</span></a> <span class="n">local</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"local"</span><span class="p">)</span> -</span><span id="Generator.journalproperty_sql-997"><a href="#Generator.journalproperty_sql-997"><span class="linenos"> 997</span></a> <span class="n">local</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">local</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.journalproperty_sql-998"><a href="#Generator.journalproperty_sql-998"><span class="linenos"> 998</span></a> <span class="n">dual</span> <span class="o">=</span> <span class="s2">"DUAL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"dual"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.journalproperty_sql-999"><a href="#Generator.journalproperty_sql-999"><span class="linenos"> 999</span></a> <span class="n">before</span> <span class="o">=</span> <span class="s2">"BEFORE "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"before"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.journalproperty_sql-1000"><a href="#Generator.journalproperty_sql-1000"><span class="linenos">1000</span></a> <span class="n">after</span> <span class="o">=</span> <span class="s2">"AFTER "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"after"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.journalproperty_sql-1001"><a href="#Generator.journalproperty_sql-1001"><span class="linenos">1001</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">local</span><span class="si">}{</span><span class="n">dual</span><span class="si">}{</span><span class="n">before</span><span class="si">}{</span><span class="n">after</span><span class="si">}</span><span class="s2">JOURNAL"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.journalproperty_sql-1003"><a href="#Generator.journalproperty_sql-1003"><span class="linenos">1003</span></a> <span class="k">def</span> <span class="nf">journalproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.journalproperty_sql-1004"><a href="#Generator.journalproperty_sql-1004"><span class="linenos">1004</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">"NO "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.journalproperty_sql-1005"><a href="#Generator.journalproperty_sql-1005"><span class="linenos">1005</span></a> <span class="n">local</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"local"</span><span class="p">)</span> +</span><span id="Generator.journalproperty_sql-1006"><a href="#Generator.journalproperty_sql-1006"><span class="linenos">1006</span></a> <span class="n">local</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">local</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">local</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.journalproperty_sql-1007"><a href="#Generator.journalproperty_sql-1007"><span class="linenos">1007</span></a> <span class="n">dual</span> <span class="o">=</span> <span class="s2">"DUAL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"dual"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.journalproperty_sql-1008"><a href="#Generator.journalproperty_sql-1008"><span class="linenos">1008</span></a> <span class="n">before</span> <span class="o">=</span> <span class="s2">"BEFORE "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"before"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.journalproperty_sql-1009"><a href="#Generator.journalproperty_sql-1009"><span class="linenos">1009</span></a> <span class="n">after</span> <span class="o">=</span> <span class="s2">"AFTER "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"after"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.journalproperty_sql-1010"><a href="#Generator.journalproperty_sql-1010"><span class="linenos">1010</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">local</span><span class="si">}{</span><span class="n">dual</span><span class="si">}{</span><span class="n">before</span><span class="si">}{</span><span class="n">after</span><span class="si">}</span><span class="s2">JOURNAL"</span> </span></pre></div> @@ -7263,10 +7391,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.freespaceproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.freespaceproperty_sql-1003"><a href="#Generator.freespaceproperty_sql-1003"><span class="linenos">1003</span></a> <span class="k">def</span> <span class="nf">freespaceproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.freespaceproperty_sql-1004"><a href="#Generator.freespaceproperty_sql-1004"><span class="linenos">1004</span></a> <span class="n">freespace</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.freespaceproperty_sql-1005"><a href="#Generator.freespaceproperty_sql-1005"><span class="linenos">1005</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.freespaceproperty_sql-1006"><a href="#Generator.freespaceproperty_sql-1006"><span class="linenos">1006</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FREESPACE=</span><span class="si">{</span><span class="n">freespace</span><span class="si">}{</span><span class="n">percent</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.freespaceproperty_sql-1012"><a href="#Generator.freespaceproperty_sql-1012"><span class="linenos">1012</span></a> <span class="k">def</span> <span class="nf">freespaceproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.freespaceproperty_sql-1013"><a href="#Generator.freespaceproperty_sql-1013"><span class="linenos">1013</span></a> <span class="n">freespace</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.freespaceproperty_sql-1014"><a href="#Generator.freespaceproperty_sql-1014"><span class="linenos">1014</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.freespaceproperty_sql-1015"><a href="#Generator.freespaceproperty_sql-1015"><span class="linenos">1015</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FREESPACE=</span><span class="si">{</span><span class="n">freespace</span><span class="si">}{</span><span class="n">percent</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7284,14 +7412,14 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.checksumproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.checksumproperty_sql-1008"><a href="#Generator.checksumproperty_sql-1008"><span class="linenos">1008</span></a> <span class="k">def</span> <span class="nf">checksumproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.checksumproperty_sql-1009"><a href="#Generator.checksumproperty_sql-1009"><span class="linenos">1009</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">):</span> -</span><span id="Generator.checksumproperty_sql-1010"><a href="#Generator.checksumproperty_sql-1010"><span class="linenos">1010</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> -</span><span id="Generator.checksumproperty_sql-1011"><a href="#Generator.checksumproperty_sql-1011"><span class="linenos">1011</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on"</span><span class="p">):</span> -</span><span id="Generator.checksumproperty_sql-1012"><a href="#Generator.checksumproperty_sql-1012"><span class="linenos">1012</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"ON"</span> -</span><span id="Generator.checksumproperty_sql-1013"><a href="#Generator.checksumproperty_sql-1013"><span class="linenos">1013</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.checksumproperty_sql-1014"><a href="#Generator.checksumproperty_sql-1014"><span class="linenos">1014</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"OFF"</span> -</span><span id="Generator.checksumproperty_sql-1015"><a href="#Generator.checksumproperty_sql-1015"><span class="linenos">1015</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECKSUM=</span><span class="si">{</span><span class="nb">property</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.checksumproperty_sql-1017"><a href="#Generator.checksumproperty_sql-1017"><span class="linenos">1017</span></a> <span class="k">def</span> <span class="nf">checksumproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ChecksumProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.checksumproperty_sql-1018"><a href="#Generator.checksumproperty_sql-1018"><span class="linenos">1018</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">):</span> +</span><span id="Generator.checksumproperty_sql-1019"><a href="#Generator.checksumproperty_sql-1019"><span class="linenos">1019</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> +</span><span id="Generator.checksumproperty_sql-1020"><a href="#Generator.checksumproperty_sql-1020"><span class="linenos">1020</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"on"</span><span class="p">):</span> +</span><span id="Generator.checksumproperty_sql-1021"><a href="#Generator.checksumproperty_sql-1021"><span class="linenos">1021</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"ON"</span> +</span><span id="Generator.checksumproperty_sql-1022"><a href="#Generator.checksumproperty_sql-1022"><span class="linenos">1022</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.checksumproperty_sql-1023"><a href="#Generator.checksumproperty_sql-1023"><span class="linenos">1023</span></a> <span class="nb">property</span> <span class="o">=</span> <span class="s2">"OFF"</span> +</span><span id="Generator.checksumproperty_sql-1024"><a href="#Generator.checksumproperty_sql-1024"><span class="linenos">1024</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECKSUM=</span><span class="si">{</span><span class="nb">property</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7309,14 +7437,14 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.mergeblockratioproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mergeblockratioproperty_sql-1017"><a href="#Generator.mergeblockratioproperty_sql-1017"><span class="linenos">1017</span></a> <span class="k">def</span> <span class="nf">mergeblockratioproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.mergeblockratioproperty_sql-1018"><a href="#Generator.mergeblockratioproperty_sql-1018"><span class="linenos">1018</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">):</span> -</span><span id="Generator.mergeblockratioproperty_sql-1019"><a href="#Generator.mergeblockratioproperty_sql-1019"><span class="linenos">1019</span></a> <span class="k">return</span> <span class="s2">"NO MERGEBLOCKRATIO"</span> -</span><span id="Generator.mergeblockratioproperty_sql-1020"><a href="#Generator.mergeblockratioproperty_sql-1020"><span class="linenos">1020</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">):</span> -</span><span id="Generator.mergeblockratioproperty_sql-1021"><a href="#Generator.mergeblockratioproperty_sql-1021"><span class="linenos">1021</span></a> <span class="k">return</span> <span class="s2">"DEFAULT MERGEBLOCKRATIO"</span> -</span><span id="Generator.mergeblockratioproperty_sql-1022"><a href="#Generator.mergeblockratioproperty_sql-1022"><span class="linenos">1022</span></a> -</span><span id="Generator.mergeblockratioproperty_sql-1023"><a href="#Generator.mergeblockratioproperty_sql-1023"><span class="linenos">1023</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.mergeblockratioproperty_sql-1024"><a href="#Generator.mergeblockratioproperty_sql-1024"><span class="linenos">1024</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGEBLOCKRATIO=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">percent</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mergeblockratioproperty_sql-1026"><a href="#Generator.mergeblockratioproperty_sql-1026"><span class="linenos">1026</span></a> <span class="k">def</span> <span class="nf">mergeblockratioproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.mergeblockratioproperty_sql-1027"><a href="#Generator.mergeblockratioproperty_sql-1027"><span class="linenos">1027</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">):</span> +</span><span id="Generator.mergeblockratioproperty_sql-1028"><a href="#Generator.mergeblockratioproperty_sql-1028"><span class="linenos">1028</span></a> <span class="k">return</span> <span class="s2">"NO MERGEBLOCKRATIO"</span> +</span><span id="Generator.mergeblockratioproperty_sql-1029"><a href="#Generator.mergeblockratioproperty_sql-1029"><span class="linenos">1029</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">):</span> +</span><span id="Generator.mergeblockratioproperty_sql-1030"><a href="#Generator.mergeblockratioproperty_sql-1030"><span class="linenos">1030</span></a> <span class="k">return</span> <span class="s2">"DEFAULT MERGEBLOCKRATIO"</span> +</span><span id="Generator.mergeblockratioproperty_sql-1031"><a href="#Generator.mergeblockratioproperty_sql-1031"><span class="linenos">1031</span></a> +</span><span id="Generator.mergeblockratioproperty_sql-1032"><a href="#Generator.mergeblockratioproperty_sql-1032"><span class="linenos">1032</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="s2">" PERCENT"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"percent"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.mergeblockratioproperty_sql-1033"><a href="#Generator.mergeblockratioproperty_sql-1033"><span class="linenos">1033</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGEBLOCKRATIO=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">percent</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7334,21 +7462,21 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.datablocksizeproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.datablocksizeproperty_sql-1026"><a href="#Generator.datablocksizeproperty_sql-1026"><span class="linenos">1026</span></a> <span class="k">def</span> <span class="nf">datablocksizeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.datablocksizeproperty_sql-1027"><a href="#Generator.datablocksizeproperty_sql-1027"><span class="linenos">1027</span></a> <span class="n">default</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> -</span><span id="Generator.datablocksizeproperty_sql-1028"><a href="#Generator.datablocksizeproperty_sql-1028"><span class="linenos">1028</span></a> <span class="n">minimum</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"minimum"</span><span class="p">)</span> -</span><span id="Generator.datablocksizeproperty_sql-1029"><a href="#Generator.datablocksizeproperty_sql-1029"><span class="linenos">1029</span></a> <span class="n">maximum</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"maximum"</span><span class="p">)</span> -</span><span id="Generator.datablocksizeproperty_sql-1030"><a href="#Generator.datablocksizeproperty_sql-1030"><span class="linenos">1030</span></a> <span class="k">if</span> <span class="n">default</span> <span class="ow">or</span> <span class="n">minimum</span> <span class="ow">or</span> <span class="n">maximum</span><span class="p">:</span> -</span><span id="Generator.datablocksizeproperty_sql-1031"><a href="#Generator.datablocksizeproperty_sql-1031"><span class="linenos">1031</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="Generator.datablocksizeproperty_sql-1032"><a href="#Generator.datablocksizeproperty_sql-1032"><span class="linenos">1032</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> -</span><span id="Generator.datablocksizeproperty_sql-1033"><a href="#Generator.datablocksizeproperty_sql-1033"><span class="linenos">1033</span></a> <span class="k">elif</span> <span class="n">minimum</span><span class="p">:</span> -</span><span id="Generator.datablocksizeproperty_sql-1034"><a href="#Generator.datablocksizeproperty_sql-1034"><span class="linenos">1034</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MINIMUM"</span> -</span><span id="Generator.datablocksizeproperty_sql-1035"><a href="#Generator.datablocksizeproperty_sql-1035"><span class="linenos">1035</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.datablocksizeproperty_sql-1036"><a href="#Generator.datablocksizeproperty_sql-1036"><span class="linenos">1036</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MAXIMUM"</span> -</span><span id="Generator.datablocksizeproperty_sql-1037"><a href="#Generator.datablocksizeproperty_sql-1037"><span class="linenos">1037</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2"> DATABLOCKSIZE"</span> -</span><span id="Generator.datablocksizeproperty_sql-1038"><a href="#Generator.datablocksizeproperty_sql-1038"><span class="linenos">1038</span></a> <span class="n">units</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"units"</span><span class="p">)</span> -</span><span id="Generator.datablocksizeproperty_sql-1039"><a href="#Generator.datablocksizeproperty_sql-1039"><span class="linenos">1039</span></a> <span class="n">units</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">units</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.datablocksizeproperty_sql-1040"><a href="#Generator.datablocksizeproperty_sql-1040"><span class="linenos">1040</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DATABLOCKSIZE=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'size'</span><span class="p">)</span><span class="si">}{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.datablocksizeproperty_sql-1035"><a href="#Generator.datablocksizeproperty_sql-1035"><span class="linenos">1035</span></a> <span class="k">def</span> <span class="nf">datablocksizeproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.datablocksizeproperty_sql-1036"><a href="#Generator.datablocksizeproperty_sql-1036"><span class="linenos">1036</span></a> <span class="n">default</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> +</span><span id="Generator.datablocksizeproperty_sql-1037"><a href="#Generator.datablocksizeproperty_sql-1037"><span class="linenos">1037</span></a> <span class="n">minimum</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"minimum"</span><span class="p">)</span> +</span><span id="Generator.datablocksizeproperty_sql-1038"><a href="#Generator.datablocksizeproperty_sql-1038"><span class="linenos">1038</span></a> <span class="n">maximum</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"maximum"</span><span class="p">)</span> +</span><span id="Generator.datablocksizeproperty_sql-1039"><a href="#Generator.datablocksizeproperty_sql-1039"><span class="linenos">1039</span></a> <span class="k">if</span> <span class="n">default</span> <span class="ow">or</span> <span class="n">minimum</span> <span class="ow">or</span> <span class="n">maximum</span><span class="p">:</span> +</span><span id="Generator.datablocksizeproperty_sql-1040"><a href="#Generator.datablocksizeproperty_sql-1040"><span class="linenos">1040</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> +</span><span id="Generator.datablocksizeproperty_sql-1041"><a href="#Generator.datablocksizeproperty_sql-1041"><span class="linenos">1041</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> +</span><span id="Generator.datablocksizeproperty_sql-1042"><a href="#Generator.datablocksizeproperty_sql-1042"><span class="linenos">1042</span></a> <span class="k">elif</span> <span class="n">minimum</span><span class="p">:</span> +</span><span id="Generator.datablocksizeproperty_sql-1043"><a href="#Generator.datablocksizeproperty_sql-1043"><span class="linenos">1043</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MINIMUM"</span> +</span><span id="Generator.datablocksizeproperty_sql-1044"><a href="#Generator.datablocksizeproperty_sql-1044"><span class="linenos">1044</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.datablocksizeproperty_sql-1045"><a href="#Generator.datablocksizeproperty_sql-1045"><span class="linenos">1045</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MAXIMUM"</span> +</span><span id="Generator.datablocksizeproperty_sql-1046"><a href="#Generator.datablocksizeproperty_sql-1046"><span class="linenos">1046</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2"> DATABLOCKSIZE"</span> +</span><span id="Generator.datablocksizeproperty_sql-1047"><a href="#Generator.datablocksizeproperty_sql-1047"><span class="linenos">1047</span></a> <span class="n">units</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"units"</span><span class="p">)</span> +</span><span id="Generator.datablocksizeproperty_sql-1048"><a href="#Generator.datablocksizeproperty_sql-1048"><span class="linenos">1048</span></a> <span class="n">units</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">units</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.datablocksizeproperty_sql-1049"><a href="#Generator.datablocksizeproperty_sql-1049"><span class="linenos">1049</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DATABLOCKSIZE=</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'size'</span><span class="p">)</span><span class="si">}{</span><span class="n">units</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7366,24 +7494,24 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.blockcompressionproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.blockcompressionproperty_sql-1042"><a href="#Generator.blockcompressionproperty_sql-1042"><span class="linenos">1042</span></a> <span class="k">def</span> <span class="nf">blockcompressionproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.blockcompressionproperty_sql-1043"><a href="#Generator.blockcompressionproperty_sql-1043"><span class="linenos">1043</span></a> <span class="n">autotemp</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"autotemp"</span><span class="p">)</span> -</span><span id="Generator.blockcompressionproperty_sql-1044"><a href="#Generator.blockcompressionproperty_sql-1044"><span class="linenos">1044</span></a> <span class="n">always</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"always"</span><span class="p">)</span> -</span><span id="Generator.blockcompressionproperty_sql-1045"><a href="#Generator.blockcompressionproperty_sql-1045"><span class="linenos">1045</span></a> <span class="n">default</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> -</span><span id="Generator.blockcompressionproperty_sql-1046"><a href="#Generator.blockcompressionproperty_sql-1046"><span class="linenos">1046</span></a> <span class="n">manual</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"manual"</span><span class="p">)</span> -</span><span id="Generator.blockcompressionproperty_sql-1047"><a href="#Generator.blockcompressionproperty_sql-1047"><span class="linenos">1047</span></a> <span class="n">never</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"never"</span><span class="p">)</span> -</span><span id="Generator.blockcompressionproperty_sql-1048"><a href="#Generator.blockcompressionproperty_sql-1048"><span class="linenos">1048</span></a> -</span><span id="Generator.blockcompressionproperty_sql-1049"><a href="#Generator.blockcompressionproperty_sql-1049"><span class="linenos">1049</span></a> <span class="k">if</span> <span class="n">autotemp</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.blockcompressionproperty_sql-1050"><a href="#Generator.blockcompressionproperty_sql-1050"><span class="linenos">1050</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"AUTOTEMP(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">autotemp</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.blockcompressionproperty_sql-1051"><a href="#Generator.blockcompressionproperty_sql-1051"><span class="linenos">1051</span></a> <span class="k">elif</span> <span class="n">always</span><span class="p">:</span> -</span><span id="Generator.blockcompressionproperty_sql-1052"><a href="#Generator.blockcompressionproperty_sql-1052"><span class="linenos">1052</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"ALWAYS"</span> -</span><span id="Generator.blockcompressionproperty_sql-1053"><a href="#Generator.blockcompressionproperty_sql-1053"><span class="linenos">1053</span></a> <span class="k">elif</span> <span class="n">default</span><span class="p">:</span> -</span><span id="Generator.blockcompressionproperty_sql-1054"><a href="#Generator.blockcompressionproperty_sql-1054"><span class="linenos">1054</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> -</span><span id="Generator.blockcompressionproperty_sql-1055"><a href="#Generator.blockcompressionproperty_sql-1055"><span class="linenos">1055</span></a> <span class="k">elif</span> <span class="n">manual</span><span class="p">:</span> -</span><span id="Generator.blockcompressionproperty_sql-1056"><a href="#Generator.blockcompressionproperty_sql-1056"><span class="linenos">1056</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MANUAL"</span> -</span><span id="Generator.blockcompressionproperty_sql-1057"><a href="#Generator.blockcompressionproperty_sql-1057"><span class="linenos">1057</span></a> <span class="k">elif</span> <span class="n">never</span><span class="p">:</span> -</span><span id="Generator.blockcompressionproperty_sql-1058"><a href="#Generator.blockcompressionproperty_sql-1058"><span class="linenos">1058</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"NEVER"</span> -</span><span id="Generator.blockcompressionproperty_sql-1059"><a href="#Generator.blockcompressionproperty_sql-1059"><span class="linenos">1059</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BLOCKCOMPRESSION=</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.blockcompressionproperty_sql-1051"><a href="#Generator.blockcompressionproperty_sql-1051"><span class="linenos">1051</span></a> <span class="k">def</span> <span class="nf">blockcompressionproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.blockcompressionproperty_sql-1052"><a href="#Generator.blockcompressionproperty_sql-1052"><span class="linenos">1052</span></a> <span class="n">autotemp</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"autotemp"</span><span class="p">)</span> +</span><span id="Generator.blockcompressionproperty_sql-1053"><a href="#Generator.blockcompressionproperty_sql-1053"><span class="linenos">1053</span></a> <span class="n">always</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"always"</span><span class="p">)</span> +</span><span id="Generator.blockcompressionproperty_sql-1054"><a href="#Generator.blockcompressionproperty_sql-1054"><span class="linenos">1054</span></a> <span class="n">default</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span> +</span><span id="Generator.blockcompressionproperty_sql-1055"><a href="#Generator.blockcompressionproperty_sql-1055"><span class="linenos">1055</span></a> <span class="n">manual</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"manual"</span><span class="p">)</span> +</span><span id="Generator.blockcompressionproperty_sql-1056"><a href="#Generator.blockcompressionproperty_sql-1056"><span class="linenos">1056</span></a> <span class="n">never</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"never"</span><span class="p">)</span> +</span><span id="Generator.blockcompressionproperty_sql-1057"><a href="#Generator.blockcompressionproperty_sql-1057"><span class="linenos">1057</span></a> +</span><span id="Generator.blockcompressionproperty_sql-1058"><a href="#Generator.blockcompressionproperty_sql-1058"><span class="linenos">1058</span></a> <span class="k">if</span> <span class="n">autotemp</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.blockcompressionproperty_sql-1059"><a href="#Generator.blockcompressionproperty_sql-1059"><span class="linenos">1059</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"AUTOTEMP(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">autotemp</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.blockcompressionproperty_sql-1060"><a href="#Generator.blockcompressionproperty_sql-1060"><span class="linenos">1060</span></a> <span class="k">elif</span> <span class="n">always</span><span class="p">:</span> +</span><span id="Generator.blockcompressionproperty_sql-1061"><a href="#Generator.blockcompressionproperty_sql-1061"><span class="linenos">1061</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"ALWAYS"</span> +</span><span id="Generator.blockcompressionproperty_sql-1062"><a href="#Generator.blockcompressionproperty_sql-1062"><span class="linenos">1062</span></a> <span class="k">elif</span> <span class="n">default</span><span class="p">:</span> +</span><span id="Generator.blockcompressionproperty_sql-1063"><a href="#Generator.blockcompressionproperty_sql-1063"><span class="linenos">1063</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"DEFAULT"</span> +</span><span id="Generator.blockcompressionproperty_sql-1064"><a href="#Generator.blockcompressionproperty_sql-1064"><span class="linenos">1064</span></a> <span class="k">elif</span> <span class="n">manual</span><span class="p">:</span> +</span><span id="Generator.blockcompressionproperty_sql-1065"><a href="#Generator.blockcompressionproperty_sql-1065"><span class="linenos">1065</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"MANUAL"</span> +</span><span id="Generator.blockcompressionproperty_sql-1066"><a href="#Generator.blockcompressionproperty_sql-1066"><span class="linenos">1066</span></a> <span class="k">elif</span> <span class="n">never</span><span class="p">:</span> +</span><span id="Generator.blockcompressionproperty_sql-1067"><a href="#Generator.blockcompressionproperty_sql-1067"><span class="linenos">1067</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="s2">"NEVER"</span> +</span><span id="Generator.blockcompressionproperty_sql-1068"><a href="#Generator.blockcompressionproperty_sql-1068"><span class="linenos">1068</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"BLOCKCOMPRESSION=</span><span class="si">{</span><span class="n">prop</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7401,20 +7529,20 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.isolatedloadingproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.isolatedloadingproperty_sql-1061"><a href="#Generator.isolatedloadingproperty_sql-1061"><span class="linenos">1061</span></a> <span class="k">def</span> <span class="nf">isolatedloadingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.isolatedloadingproperty_sql-1062"><a href="#Generator.isolatedloadingproperty_sql-1062"><span class="linenos">1062</span></a> <span class="n">no</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">)</span> -</span><span id="Generator.isolatedloadingproperty_sql-1063"><a href="#Generator.isolatedloadingproperty_sql-1063"><span class="linenos">1063</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">" NO"</span> <span class="k">if</span> <span class="n">no</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.isolatedloadingproperty_sql-1064"><a href="#Generator.isolatedloadingproperty_sql-1064"><span class="linenos">1064</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"concurrent"</span><span class="p">)</span> -</span><span id="Generator.isolatedloadingproperty_sql-1065"><a href="#Generator.isolatedloadingproperty_sql-1065"><span class="linenos">1065</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="s2">" CONCURRENT"</span> <span class="k">if</span> <span class="n">concurrent</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.isolatedloadingproperty_sql-1066"><a href="#Generator.isolatedloadingproperty_sql-1066"><span class="linenos">1066</span></a> -</span><span id="Generator.isolatedloadingproperty_sql-1067"><a href="#Generator.isolatedloadingproperty_sql-1067"><span class="linenos">1067</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.isolatedloadingproperty_sql-1068"><a href="#Generator.isolatedloadingproperty_sql-1068"><span class="linenos">1068</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_all"</span><span class="p">):</span> -</span><span id="Generator.isolatedloadingproperty_sql-1069"><a href="#Generator.isolatedloadingproperty_sql-1069"><span class="linenos">1069</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR ALL"</span> -</span><span id="Generator.isolatedloadingproperty_sql-1070"><a href="#Generator.isolatedloadingproperty_sql-1070"><span class="linenos">1070</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_insert"</span><span class="p">):</span> -</span><span id="Generator.isolatedloadingproperty_sql-1071"><a href="#Generator.isolatedloadingproperty_sql-1071"><span class="linenos">1071</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR INSERT"</span> -</span><span id="Generator.isolatedloadingproperty_sql-1072"><a href="#Generator.isolatedloadingproperty_sql-1072"><span class="linenos">1072</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_none"</span><span class="p">):</span> -</span><span id="Generator.isolatedloadingproperty_sql-1073"><a href="#Generator.isolatedloadingproperty_sql-1073"><span class="linenos">1073</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR NONE"</span> -</span><span id="Generator.isolatedloadingproperty_sql-1074"><a href="#Generator.isolatedloadingproperty_sql-1074"><span class="linenos">1074</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">concurrent</span><span class="si">}</span><span class="s2"> ISOLATED LOADING</span><span class="si">{</span><span class="n">for_</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.isolatedloadingproperty_sql-1070"><a href="#Generator.isolatedloadingproperty_sql-1070"><span class="linenos">1070</span></a> <span class="k">def</span> <span class="nf">isolatedloadingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.isolatedloadingproperty_sql-1071"><a href="#Generator.isolatedloadingproperty_sql-1071"><span class="linenos">1071</span></a> <span class="n">no</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"no"</span><span class="p">)</span> +</span><span id="Generator.isolatedloadingproperty_sql-1072"><a href="#Generator.isolatedloadingproperty_sql-1072"><span class="linenos">1072</span></a> <span class="n">no</span> <span class="o">=</span> <span class="s2">" NO"</span> <span class="k">if</span> <span class="n">no</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.isolatedloadingproperty_sql-1073"><a href="#Generator.isolatedloadingproperty_sql-1073"><span class="linenos">1073</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"concurrent"</span><span class="p">)</span> +</span><span id="Generator.isolatedloadingproperty_sql-1074"><a href="#Generator.isolatedloadingproperty_sql-1074"><span class="linenos">1074</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="s2">" CONCURRENT"</span> <span class="k">if</span> <span class="n">concurrent</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.isolatedloadingproperty_sql-1075"><a href="#Generator.isolatedloadingproperty_sql-1075"><span class="linenos">1075</span></a> +</span><span id="Generator.isolatedloadingproperty_sql-1076"><a href="#Generator.isolatedloadingproperty_sql-1076"><span class="linenos">1076</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.isolatedloadingproperty_sql-1077"><a href="#Generator.isolatedloadingproperty_sql-1077"><span class="linenos">1077</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_all"</span><span class="p">):</span> +</span><span id="Generator.isolatedloadingproperty_sql-1078"><a href="#Generator.isolatedloadingproperty_sql-1078"><span class="linenos">1078</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR ALL"</span> +</span><span id="Generator.isolatedloadingproperty_sql-1079"><a href="#Generator.isolatedloadingproperty_sql-1079"><span class="linenos">1079</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_insert"</span><span class="p">):</span> +</span><span id="Generator.isolatedloadingproperty_sql-1080"><a href="#Generator.isolatedloadingproperty_sql-1080"><span class="linenos">1080</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR INSERT"</span> +</span><span id="Generator.isolatedloadingproperty_sql-1081"><a href="#Generator.isolatedloadingproperty_sql-1081"><span class="linenos">1081</span></a> <span class="k">elif</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_none"</span><span class="p">):</span> +</span><span id="Generator.isolatedloadingproperty_sql-1082"><a href="#Generator.isolatedloadingproperty_sql-1082"><span class="linenos">1082</span></a> <span class="n">for_</span> <span class="o">=</span> <span class="s2">" FOR NONE"</span> +</span><span id="Generator.isolatedloadingproperty_sql-1083"><a href="#Generator.isolatedloadingproperty_sql-1083"><span class="linenos">1083</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH</span><span class="si">{</span><span class="n">no</span><span class="si">}{</span><span class="n">concurrent</span><span class="si">}</span><span class="s2"> ISOLATED LOADING</span><span class="si">{</span><span class="n">for_</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7432,13 +7560,13 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.lockingproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lockingproperty_sql-1076"><a href="#Generator.lockingproperty_sql-1076"><span class="linenos">1076</span></a> <span class="k">def</span> <span class="nf">lockingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.lockingproperty_sql-1077"><a href="#Generator.lockingproperty_sql-1077"><span class="linenos">1077</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator.lockingproperty_sql-1078"><a href="#Generator.lockingproperty_sql-1078"><span class="linenos">1078</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.lockingproperty_sql-1079"><a href="#Generator.lockingproperty_sql-1079"><span class="linenos">1079</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_or_in"</span><span class="p">)</span> -</span><span id="Generator.lockingproperty_sql-1080"><a href="#Generator.lockingproperty_sql-1080"><span class="linenos">1080</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lock_type"</span><span class="p">)</span> -</span><span id="Generator.lockingproperty_sql-1081"><a href="#Generator.lockingproperty_sql-1081"><span class="linenos">1081</span></a> <span class="n">override</span> <span class="o">=</span> <span class="s2">" OVERRIDE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"override"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.lockingproperty_sql-1082"><a href="#Generator.lockingproperty_sql-1082"><span class="linenos">1082</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOCKING </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">for_or_in</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">override</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lockingproperty_sql-1085"><a href="#Generator.lockingproperty_sql-1085"><span class="linenos">1085</span></a> <span class="k">def</span> <span class="nf">lockingproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.lockingproperty_sql-1086"><a href="#Generator.lockingproperty_sql-1086"><span class="linenos">1086</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator.lockingproperty_sql-1087"><a href="#Generator.lockingproperty_sql-1087"><span class="linenos">1087</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.lockingproperty_sql-1088"><a href="#Generator.lockingproperty_sql-1088"><span class="linenos">1088</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"for_or_in"</span><span class="p">)</span> +</span><span id="Generator.lockingproperty_sql-1089"><a href="#Generator.lockingproperty_sql-1089"><span class="linenos">1089</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lock_type"</span><span class="p">)</span> +</span><span id="Generator.lockingproperty_sql-1090"><a href="#Generator.lockingproperty_sql-1090"><span class="linenos">1090</span></a> <span class="n">override</span> <span class="o">=</span> <span class="s2">" OVERRIDE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"override"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.lockingproperty_sql-1091"><a href="#Generator.lockingproperty_sql-1091"><span class="linenos">1091</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOCKING </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">for_or_in</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">override</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7456,13 +7584,13 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.withdataproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.withdataproperty_sql-1084"><a href="#Generator.withdataproperty_sql-1084"><span class="linenos">1084</span></a> <span class="k">def</span> <span class="nf">withdataproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.withdataproperty_sql-1085"><a href="#Generator.withdataproperty_sql-1085"><span class="linenos">1085</span></a> <span class="n">data_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'no'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">DATA"</span> -</span><span id="Generator.withdataproperty_sql-1086"><a href="#Generator.withdataproperty_sql-1086"><span class="linenos">1086</span></a> <span class="n">statistics</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"statistics"</span><span class="p">)</span> -</span><span id="Generator.withdataproperty_sql-1087"><a href="#Generator.withdataproperty_sql-1087"><span class="linenos">1087</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.withdataproperty_sql-1088"><a href="#Generator.withdataproperty_sql-1088"><span class="linenos">1088</span></a> <span class="k">if</span> <span class="n">statistics</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.withdataproperty_sql-1089"><a href="#Generator.withdataproperty_sql-1089"><span class="linenos">1089</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">statistics</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">STATISTICS"</span> -</span><span id="Generator.withdataproperty_sql-1090"><a href="#Generator.withdataproperty_sql-1090"><span class="linenos">1090</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">data_sql</span><span class="si">}{</span><span class="n">statistics_sql</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.withdataproperty_sql-1093"><a href="#Generator.withdataproperty_sql-1093"><span class="linenos">1093</span></a> <span class="k">def</span> <span class="nf">withdataproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.withdataproperty_sql-1094"><a href="#Generator.withdataproperty_sql-1094"><span class="linenos">1094</span></a> <span class="n">data_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"WITH </span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'no'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">DATA"</span> +</span><span id="Generator.withdataproperty_sql-1095"><a href="#Generator.withdataproperty_sql-1095"><span class="linenos">1095</span></a> <span class="n">statistics</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"statistics"</span><span class="p">)</span> +</span><span id="Generator.withdataproperty_sql-1096"><a href="#Generator.withdataproperty_sql-1096"><span class="linenos">1096</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.withdataproperty_sql-1097"><a href="#Generator.withdataproperty_sql-1097"><span class="linenos">1097</span></a> <span class="k">if</span> <span class="n">statistics</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.withdataproperty_sql-1098"><a href="#Generator.withdataproperty_sql-1098"><span class="linenos">1098</span></a> <span class="n">statistics_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="s1">'NO '</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="ow">not</span><span class="w"> </span><span class="n">statistics</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">STATISTICS"</span> +</span><span id="Generator.withdataproperty_sql-1099"><a href="#Generator.withdataproperty_sql-1099"><span class="linenos">1099</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">data_sql</span><span class="si">}{</span><span class="n">statistics_sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7480,28 +7608,28 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.insert_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.insert_sql-1092"><a href="#Generator.insert_sql-1092"><span class="linenos">1092</span></a> <span class="k">def</span> <span class="nf">insert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.insert_sql-1093"><a href="#Generator.insert_sql-1093"><span class="linenos">1093</span></a> <span class="n">overwrite</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"overwrite"</span><span class="p">)</span> -</span><span id="Generator.insert_sql-1094"><a href="#Generator.insert_sql-1094"><span class="linenos">1094</span></a> -</span><span id="Generator.insert_sql-1095"><a href="#Generator.insert_sql-1095"><span class="linenos">1095</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">):</span> -</span><span id="Generator.insert_sql-1096"><a href="#Generator.insert_sql-1096"><span class="linenos">1096</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">"OVERWRITE "</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">"INTO "</span> -</span><span id="Generator.insert_sql-1097"><a href="#Generator.insert_sql-1097"><span class="linenos">1097</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.insert_sql-1098"><a href="#Generator.insert_sql-1098"><span class="linenos">1098</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">"OVERWRITE TABLE "</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">"INTO "</span> -</span><span id="Generator.insert_sql-1099"><a href="#Generator.insert_sql-1099"><span class="linenos">1099</span></a> -</span><span id="Generator.insert_sql-1100"><a href="#Generator.insert_sql-1100"><span class="linenos">1100</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alternative"</span><span class="p">)</span> -</span><span id="Generator.insert_sql-1101"><a href="#Generator.insert_sql-1101"><span class="linenos">1101</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OR </span><span class="si">{</span><span class="n">alternative</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">alternative</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator.insert_sql-1102"><a href="#Generator.insert_sql-1102"><span class="linenos">1102</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.insert_sql-1101"><a href="#Generator.insert_sql-1101"><span class="linenos">1101</span></a> <span class="k">def</span> <span class="nf">insert_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.insert_sql-1102"><a href="#Generator.insert_sql-1102"><span class="linenos">1102</span></a> <span class="n">overwrite</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"overwrite"</span><span class="p">)</span> </span><span id="Generator.insert_sql-1103"><a href="#Generator.insert_sql-1103"><span class="linenos">1103</span></a> -</span><span id="Generator.insert_sql-1104"><a href="#Generator.insert_sql-1104"><span class="linenos">1104</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator.insert_sql-1105"><a href="#Generator.insert_sql-1105"><span class="linenos">1105</span></a> <span class="n">partition_sql</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.insert_sql-1106"><a href="#Generator.insert_sql-1106"><span class="linenos">1106</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"partition"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"partition"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.insert_sql-1107"><a href="#Generator.insert_sql-1107"><span class="linenos">1107</span></a> <span class="p">)</span> -</span><span id="Generator.insert_sql-1108"><a href="#Generator.insert_sql-1108"><span class="linenos">1108</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator.insert_sql-1109"><a href="#Generator.insert_sql-1109"><span class="linenos">1109</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"conflict"</span><span class="p">)</span> -</span><span id="Generator.insert_sql-1110"><a href="#Generator.insert_sql-1110"><span class="linenos">1110</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> -</span><span id="Generator.insert_sql-1111"><a href="#Generator.insert_sql-1111"><span class="linenos">1111</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span> <span class="k">if</span> <span class="n">partition_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.insert_sql-1112"><a href="#Generator.insert_sql-1112"><span class="linenos">1112</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT</span><span class="si">{</span><span class="n">alternative</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">exists</span><span class="si">}{</span><span class="n">partition_sql</span><span class="si">}{</span><span class="n">sep</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">conflict</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.insert_sql-1113"><a href="#Generator.insert_sql-1113"><span class="linenos">1113</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="Generator.insert_sql-1104"><a href="#Generator.insert_sql-1104"><span class="linenos">1104</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">):</span> +</span><span id="Generator.insert_sql-1105"><a href="#Generator.insert_sql-1105"><span class="linenos">1105</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">"OVERWRITE "</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">"INTO "</span> +</span><span id="Generator.insert_sql-1106"><a href="#Generator.insert_sql-1106"><span class="linenos">1106</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.insert_sql-1107"><a href="#Generator.insert_sql-1107"><span class="linenos">1107</span></a> <span class="n">this</span> <span class="o">=</span> <span class="s2">"OVERWRITE TABLE "</span> <span class="k">if</span> <span class="n">overwrite</span> <span class="k">else</span> <span class="s2">"INTO "</span> +</span><span id="Generator.insert_sql-1108"><a href="#Generator.insert_sql-1108"><span class="linenos">1108</span></a> +</span><span id="Generator.insert_sql-1109"><a href="#Generator.insert_sql-1109"><span class="linenos">1109</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alternative"</span><span class="p">)</span> +</span><span id="Generator.insert_sql-1110"><a href="#Generator.insert_sql-1110"><span class="linenos">1110</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OR </span><span class="si">{</span><span class="n">alternative</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">alternative</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator.insert_sql-1111"><a href="#Generator.insert_sql-1111"><span class="linenos">1111</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.insert_sql-1112"><a href="#Generator.insert_sql-1112"><span class="linenos">1112</span></a> +</span><span id="Generator.insert_sql-1113"><a href="#Generator.insert_sql-1113"><span class="linenos">1113</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator.insert_sql-1114"><a href="#Generator.insert_sql-1114"><span class="linenos">1114</span></a> <span class="n">partition_sql</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.insert_sql-1115"><a href="#Generator.insert_sql-1115"><span class="linenos">1115</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"partition"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"partition"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.insert_sql-1116"><a href="#Generator.insert_sql-1116"><span class="linenos">1116</span></a> <span class="p">)</span> +</span><span id="Generator.insert_sql-1117"><a href="#Generator.insert_sql-1117"><span class="linenos">1117</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator.insert_sql-1118"><a href="#Generator.insert_sql-1118"><span class="linenos">1118</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"conflict"</span><span class="p">)</span> +</span><span id="Generator.insert_sql-1119"><a href="#Generator.insert_sql-1119"><span class="linenos">1119</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="Generator.insert_sql-1120"><a href="#Generator.insert_sql-1120"><span class="linenos">1120</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span> <span class="k">if</span> <span class="n">partition_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.insert_sql-1121"><a href="#Generator.insert_sql-1121"><span class="linenos">1121</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT</span><span class="si">{</span><span class="n">alternative</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">exists</span><span class="si">}{</span><span class="n">partition_sql</span><span class="si">}{</span><span class="n">sep</span><span class="si">}{</span><span class="n">expression_sql</span><span class="si">}{</span><span class="n">conflict</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.insert_sql-1122"><a href="#Generator.insert_sql-1122"><span class="linenos">1122</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> </span></pre></div> @@ -7519,11 +7647,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.intersect_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.intersect_sql-1115"><a href="#Generator.intersect_sql-1115"><span class="linenos">1115</span></a> <span class="k">def</span> <span class="nf">intersect_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.intersect_sql-1116"><a href="#Generator.intersect_sql-1116"><span class="linenos">1116</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span> -</span><span id="Generator.intersect_sql-1117"><a href="#Generator.intersect_sql-1117"><span class="linenos">1117</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator.intersect_sql-1118"><a href="#Generator.intersect_sql-1118"><span class="linenos">1118</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> -</span><span id="Generator.intersect_sql-1119"><a href="#Generator.intersect_sql-1119"><span class="linenos">1119</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.intersect_sql-1124"><a href="#Generator.intersect_sql-1124"><span class="linenos">1124</span></a> <span class="k">def</span> <span class="nf">intersect_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.intersect_sql-1125"><a href="#Generator.intersect_sql-1125"><span class="linenos">1125</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span> +</span><span id="Generator.intersect_sql-1126"><a href="#Generator.intersect_sql-1126"><span class="linenos">1126</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator.intersect_sql-1127"><a href="#Generator.intersect_sql-1127"><span class="linenos">1127</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">intersect_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> +</span><span id="Generator.intersect_sql-1128"><a href="#Generator.intersect_sql-1128"><span class="linenos">1128</span></a> <span class="p">)</span> </span></pre></div> @@ -7541,8 +7669,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.intersect_op"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.intersect_op-1121"><a href="#Generator.intersect_op-1121"><span class="linenos">1121</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.intersect_op-1122"><a href="#Generator.intersect_op-1122"><span class="linenos">1122</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">''</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.intersect_op-1130"><a href="#Generator.intersect_op-1130"><span class="linenos">1130</span></a> <span class="k">def</span> <span class="nf">intersect_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.intersect_op-1131"><a href="#Generator.intersect_op-1131"><span class="linenos">1131</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERSECT</span><span class="si">{</span><span class="s1">''</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'distinct'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">' ALL'</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7560,8 +7688,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.introducer_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.introducer_sql-1124"><a href="#Generator.introducer_sql-1124"><span class="linenos">1124</span></a> <span class="k">def</span> <span class="nf">introducer_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Introducer</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.introducer_sql-1125"><a href="#Generator.introducer_sql-1125"><span class="linenos">1125</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.introducer_sql-1133"><a href="#Generator.introducer_sql-1133"><span class="linenos">1133</span></a> <span class="k">def</span> <span class="nf">introducer_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Introducer</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.introducer_sql-1134"><a href="#Generator.introducer_sql-1134"><span class="linenos">1134</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7579,8 +7707,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.pseudotype_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.pseudotype_sql-1127"><a href="#Generator.pseudotype_sql-1127"><span class="linenos">1127</span></a> <span class="k">def</span> <span class="nf">pseudotype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PseudoType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.pseudotype_sql-1128"><a href="#Generator.pseudotype_sql-1128"><span class="linenos">1128</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.pseudotype_sql-1136"><a href="#Generator.pseudotype_sql-1136"><span class="linenos">1136</span></a> <span class="k">def</span> <span class="nf">pseudotype_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">PseudoType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.pseudotype_sql-1137"><a href="#Generator.pseudotype_sql-1137"><span class="linenos">1137</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> </span></pre></div> @@ -7598,18 +7726,18 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.onconflict_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.onconflict_sql-1130"><a href="#Generator.onconflict_sql-1130"><span class="linenos">1130</span></a> <span class="k">def</span> <span class="nf">onconflict_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnConflict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.onconflict_sql-1131"><a href="#Generator.onconflict_sql-1131"><span class="linenos">1131</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="s2">"ON DUPLICATE KEY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ON CONFLICT"</span> -</span><span id="Generator.onconflict_sql-1132"><a href="#Generator.onconflict_sql-1132"><span class="linenos">1132</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"constraint"</span><span class="p">)</span> -</span><span id="Generator.onconflict_sql-1133"><a href="#Generator.onconflict_sql-1133"><span class="linenos">1133</span></a> <span class="k">if</span> <span class="n">constraint</span><span class="p">:</span> -</span><span id="Generator.onconflict_sql-1134"><a href="#Generator.onconflict_sql-1134"><span class="linenos">1134</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON CONSTRAINT </span><span class="si">{</span><span class="n">constraint</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.onconflict_sql-1135"><a href="#Generator.onconflict_sql-1135"><span class="linenos">1135</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"key"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.onconflict_sql-1136"><a href="#Generator.onconflict_sql-1136"><span class="linenos">1136</span></a> <span class="n">do</span> <span class="o">=</span> <span class="s2">""</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" DO "</span> -</span><span id="Generator.onconflict_sql-1137"><a href="#Generator.onconflict_sql-1137"><span class="linenos">1137</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="s2">"NOTHING"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nothing"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.onconflict_sql-1138"><a href="#Generator.onconflict_sql-1138"><span class="linenos">1138</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.onconflict_sql-1139"><a href="#Generator.onconflict_sql-1139"><span class="linenos">1139</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator.onconflict_sql-1140"><a href="#Generator.onconflict_sql-1140"><span class="linenos">1140</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE SET </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.onconflict_sql-1141"><a href="#Generator.onconflict_sql-1141"><span class="linenos">1141</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">conflict</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">constraint</span><span class="si">}{</span><span class="n">key</span><span class="si">}{</span><span class="n">do</span><span class="si">}{</span><span class="n">nothing</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.onconflict_sql-1139"><a href="#Generator.onconflict_sql-1139"><span class="linenos">1139</span></a> <span class="k">def</span> <span class="nf">onconflict_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnConflict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.onconflict_sql-1140"><a href="#Generator.onconflict_sql-1140"><span class="linenos">1140</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="s2">"ON DUPLICATE KEY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">"ON CONFLICT"</span> +</span><span id="Generator.onconflict_sql-1141"><a href="#Generator.onconflict_sql-1141"><span class="linenos">1141</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"constraint"</span><span class="p">)</span> +</span><span id="Generator.onconflict_sql-1142"><a href="#Generator.onconflict_sql-1142"><span class="linenos">1142</span></a> <span class="k">if</span> <span class="n">constraint</span><span class="p">:</span> +</span><span id="Generator.onconflict_sql-1143"><a href="#Generator.onconflict_sql-1143"><span class="linenos">1143</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON CONSTRAINT </span><span class="si">{</span><span class="n">constraint</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.onconflict_sql-1144"><a href="#Generator.onconflict_sql-1144"><span class="linenos">1144</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"key"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.onconflict_sql-1145"><a href="#Generator.onconflict_sql-1145"><span class="linenos">1145</span></a> <span class="n">do</span> <span class="o">=</span> <span class="s2">""</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"duplicate"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" DO "</span> +</span><span id="Generator.onconflict_sql-1146"><a href="#Generator.onconflict_sql-1146"><span class="linenos">1146</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="s2">"NOTHING"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nothing"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.onconflict_sql-1147"><a href="#Generator.onconflict_sql-1147"><span class="linenos">1147</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.onconflict_sql-1148"><a href="#Generator.onconflict_sql-1148"><span class="linenos">1148</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator.onconflict_sql-1149"><a href="#Generator.onconflict_sql-1149"><span class="linenos">1149</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE SET </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.onconflict_sql-1150"><a href="#Generator.onconflict_sql-1150"><span class="linenos">1150</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">conflict</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">constraint</span><span class="si">}{</span><span class="n">key</span><span class="si">}{</span><span class="n">do</span><span class="si">}{</span><span class="n">nothing</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7627,8 +7755,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.returning_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.returning_sql-1143"><a href="#Generator.returning_sql-1143"><span class="linenos">1143</span></a> <span class="k">def</span> <span class="nf">returning_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Returning</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.returning_sql-1144"><a href="#Generator.returning_sql-1144"><span class="linenos">1144</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'RETURNING'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.returning_sql-1152"><a href="#Generator.returning_sql-1152"><span class="linenos">1152</span></a> <span class="k">def</span> <span class="nf">returning_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Returning</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.returning_sql-1153"><a href="#Generator.returning_sql-1153"><span class="linenos">1153</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'RETURNING'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7646,20 +7774,20 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.rowformatdelimitedproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.rowformatdelimitedproperty_sql-1146"><a href="#Generator.rowformatdelimitedproperty_sql-1146"><span class="linenos">1146</span></a> <span class="k">def</span> <span class="nf">rowformatdelimitedproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1147"><a href="#Generator.rowformatdelimitedproperty_sql-1147"><span class="linenos">1147</span></a> <span class="n">fields</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"fields"</span><span class="p">)</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1148"><a href="#Generator.rowformatdelimitedproperty_sql-1148"><span class="linenos">1148</span></a> <span class="n">fields</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FIELDS TERMINATED BY </span><span class="si">{</span><span class="n">fields</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">fields</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1149"><a href="#Generator.rowformatdelimitedproperty_sql-1149"><span class="linenos">1149</span></a> <span class="n">escaped</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"escaped"</span><span class="p">)</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1150"><a href="#Generator.rowformatdelimitedproperty_sql-1150"><span class="linenos">1150</span></a> <span class="n">escaped</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ESCAPED BY </span><span class="si">{</span><span class="n">escaped</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">escaped</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1151"><a href="#Generator.rowformatdelimitedproperty_sql-1151"><span class="linenos">1151</span></a> <span class="n">items</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"collection_items"</span><span class="p">)</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1152"><a href="#Generator.rowformatdelimitedproperty_sql-1152"><span class="linenos">1152</span></a> <span class="n">items</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLECTION ITEMS TERMINATED BY </span><span class="si">{</span><span class="n">items</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">items</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1153"><a href="#Generator.rowformatdelimitedproperty_sql-1153"><span class="linenos">1153</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"map_keys"</span><span class="p">)</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1154"><a href="#Generator.rowformatdelimitedproperty_sql-1154"><span class="linenos">1154</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAP KEYS TERMINATED BY </span><span class="si">{</span><span class="n">keys</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">keys</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1155"><a href="#Generator.rowformatdelimitedproperty_sql-1155"><span class="linenos">1155</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lines"</span><span class="p">)</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1156"><a href="#Generator.rowformatdelimitedproperty_sql-1156"><span class="linenos">1156</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" LINES TERMINATED BY </span><span class="si">{</span><span class="n">lines</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">lines</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1157"><a href="#Generator.rowformatdelimitedproperty_sql-1157"><span class="linenos">1157</span></a> <span class="n">null</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"null"</span><span class="p">)</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1158"><a href="#Generator.rowformatdelimitedproperty_sql-1158"><span class="linenos">1158</span></a> <span class="n">null</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" NULL DEFINED AS </span><span class="si">{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.rowformatdelimitedproperty_sql-1159"><a href="#Generator.rowformatdelimitedproperty_sql-1159"><span class="linenos">1159</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROW FORMAT DELIMITED</span><span class="si">{</span><span class="n">fields</span><span class="si">}{</span><span class="n">escaped</span><span class="si">}{</span><span class="n">items</span><span class="si">}{</span><span class="n">keys</span><span class="si">}{</span><span class="n">lines</span><span class="si">}{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.rowformatdelimitedproperty_sql-1155"><a href="#Generator.rowformatdelimitedproperty_sql-1155"><span class="linenos">1155</span></a> <span class="k">def</span> <span class="nf">rowformatdelimitedproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1156"><a href="#Generator.rowformatdelimitedproperty_sql-1156"><span class="linenos">1156</span></a> <span class="n">fields</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"fields"</span><span class="p">)</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1157"><a href="#Generator.rowformatdelimitedproperty_sql-1157"><span class="linenos">1157</span></a> <span class="n">fields</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FIELDS TERMINATED BY </span><span class="si">{</span><span class="n">fields</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">fields</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1158"><a href="#Generator.rowformatdelimitedproperty_sql-1158"><span class="linenos">1158</span></a> <span class="n">escaped</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"escaped"</span><span class="p">)</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1159"><a href="#Generator.rowformatdelimitedproperty_sql-1159"><span class="linenos">1159</span></a> <span class="n">escaped</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ESCAPED BY </span><span class="si">{</span><span class="n">escaped</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">escaped</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1160"><a href="#Generator.rowformatdelimitedproperty_sql-1160"><span class="linenos">1160</span></a> <span class="n">items</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"collection_items"</span><span class="p">)</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1161"><a href="#Generator.rowformatdelimitedproperty_sql-1161"><span class="linenos">1161</span></a> <span class="n">items</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLECTION ITEMS TERMINATED BY </span><span class="si">{</span><span class="n">items</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">items</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1162"><a href="#Generator.rowformatdelimitedproperty_sql-1162"><span class="linenos">1162</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"map_keys"</span><span class="p">)</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1163"><a href="#Generator.rowformatdelimitedproperty_sql-1163"><span class="linenos">1163</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" MAP KEYS TERMINATED BY </span><span class="si">{</span><span class="n">keys</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">keys</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1164"><a href="#Generator.rowformatdelimitedproperty_sql-1164"><span class="linenos">1164</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lines"</span><span class="p">)</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1165"><a href="#Generator.rowformatdelimitedproperty_sql-1165"><span class="linenos">1165</span></a> <span class="n">lines</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" LINES TERMINATED BY </span><span class="si">{</span><span class="n">lines</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">lines</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1166"><a href="#Generator.rowformatdelimitedproperty_sql-1166"><span class="linenos">1166</span></a> <span class="n">null</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"null"</span><span class="p">)</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1167"><a href="#Generator.rowformatdelimitedproperty_sql-1167"><span class="linenos">1167</span></a> <span class="n">null</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" NULL DEFINED AS </span><span class="si">{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.rowformatdelimitedproperty_sql-1168"><a href="#Generator.rowformatdelimitedproperty_sql-1168"><span class="linenos">1168</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROW FORMAT DELIMITED</span><span class="si">{</span><span class="n">fields</span><span class="si">}{</span><span class="n">escaped</span><span class="si">}{</span><span class="n">items</span><span class="si">}{</span><span class="n">keys</span><span class="si">}{</span><span class="n">lines</span><span class="si">}{</span><span class="n">null</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7677,29 +7805,29 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.table_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.table_sql-1161"><a href="#Generator.table_sql-1161"><span class="linenos">1161</span></a> <span class="k">def</span> <span class="nf">table_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.table_sql-1162"><a href="#Generator.table_sql-1162"><span class="linenos">1162</span></a> <span class="n">table</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator.table_sql-1163"><a href="#Generator.table_sql-1163"><span class="linenos">1163</span></a> <span class="n">part</span> -</span><span id="Generator.table_sql-1164"><a href="#Generator.table_sql-1164"><span class="linenos">1164</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">[</span> -</span><span id="Generator.table_sql-1165"><a href="#Generator.table_sql-1165"><span class="linenos">1165</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"catalog"</span><span class="p">),</span> -</span><span id="Generator.table_sql-1166"><a href="#Generator.table_sql-1166"><span class="linenos">1166</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"db"</span><span class="p">),</span> -</span><span id="Generator.table_sql-1167"><a href="#Generator.table_sql-1167"><span class="linenos">1167</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> -</span><span id="Generator.table_sql-1168"><a href="#Generator.table_sql-1168"><span class="linenos">1168</span></a> <span class="p">]</span> -</span><span id="Generator.table_sql-1169"><a href="#Generator.table_sql-1169"><span class="linenos">1169</span></a> <span class="k">if</span> <span class="n">part</span> -</span><span id="Generator.table_sql-1170"><a href="#Generator.table_sql-1170"><span class="linenos">1170</span></a> <span class="p">)</span> -</span><span id="Generator.table_sql-1171"><a href="#Generator.table_sql-1171"><span class="linenos">1171</span></a> -</span><span id="Generator.table_sql-1172"><a href="#Generator.table_sql-1172"><span class="linenos">1172</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator.table_sql-1173"><a href="#Generator.table_sql-1173"><span class="linenos">1173</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.table_sql-1174"><a href="#Generator.table_sql-1174"><span class="linenos">1174</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"hints"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.table_sql-1175"><a href="#Generator.table_sql-1175"><span class="linenos">1175</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH (</span><span class="si">{</span><span class="n">hints</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">hints</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_HINTS</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.table_sql-1176"><a href="#Generator.table_sql-1176"><span class="linenos">1176</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.table_sql-1177"><a href="#Generator.table_sql-1177"><span class="linenos">1177</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.table_sql-1178"><a href="#Generator.table_sql-1178"><span class="linenos">1178</span></a> <span class="n">joins</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"joins"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="Generator.table_sql-1179"><a href="#Generator.table_sql-1179"><span class="linenos">1179</span></a> <span class="n">laterals</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"laterals"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="Generator.table_sql-1180"><a href="#Generator.table_sql-1180"><span class="linenos">1180</span></a> <span class="n">system_time</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"system_time"</span><span class="p">)</span> -</span><span id="Generator.table_sql-1181"><a href="#Generator.table_sql-1181"><span class="linenos">1181</span></a> <span class="n">system_time</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'system_time'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">system_time</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.table_sql-1182"><a href="#Generator.table_sql-1182"><span class="linenos">1182</span></a> -</span><span id="Generator.table_sql-1183"><a href="#Generator.table_sql-1183"><span class="linenos">1183</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">system_time</span><span class="si">}{</span><span class="n">alias</span><span class="si">}{</span><span class="n">hints</span><span class="si">}{</span><span class="n">pivots</span><span class="si">}{</span><span class="n">joins</span><span class="si">}{</span><span class="n">laterals</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.table_sql-1170"><a href="#Generator.table_sql-1170"><span class="linenos">1170</span></a> <span class="k">def</span> <span class="nf">table_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.table_sql-1171"><a href="#Generator.table_sql-1171"><span class="linenos">1171</span></a> <span class="n">table</span> <span class="o">=</span> <span class="s2">"."</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator.table_sql-1172"><a href="#Generator.table_sql-1172"><span class="linenos">1172</span></a> <span class="n">part</span> +</span><span id="Generator.table_sql-1173"><a href="#Generator.table_sql-1173"><span class="linenos">1173</span></a> <span class="k">for</span> <span class="n">part</span> <span class="ow">in</span> <span class="p">[</span> +</span><span id="Generator.table_sql-1174"><a href="#Generator.table_sql-1174"><span class="linenos">1174</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"catalog"</span><span class="p">),</span> +</span><span id="Generator.table_sql-1175"><a href="#Generator.table_sql-1175"><span class="linenos">1175</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"db"</span><span class="p">),</span> +</span><span id="Generator.table_sql-1176"><a href="#Generator.table_sql-1176"><span class="linenos">1176</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">),</span> +</span><span id="Generator.table_sql-1177"><a href="#Generator.table_sql-1177"><span class="linenos">1177</span></a> <span class="p">]</span> +</span><span id="Generator.table_sql-1178"><a href="#Generator.table_sql-1178"><span class="linenos">1178</span></a> <span class="k">if</span> <span class="n">part</span> +</span><span id="Generator.table_sql-1179"><a href="#Generator.table_sql-1179"><span class="linenos">1179</span></a> <span class="p">)</span> +</span><span id="Generator.table_sql-1180"><a href="#Generator.table_sql-1180"><span class="linenos">1180</span></a> +</span><span id="Generator.table_sql-1181"><a href="#Generator.table_sql-1181"><span class="linenos">1181</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator.table_sql-1182"><a href="#Generator.table_sql-1182"><span class="linenos">1182</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.table_sql-1183"><a href="#Generator.table_sql-1183"><span class="linenos">1183</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"hints"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.table_sql-1184"><a href="#Generator.table_sql-1184"><span class="linenos">1184</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH (</span><span class="si">{</span><span class="n">hints</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">hints</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_HINTS</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.table_sql-1185"><a href="#Generator.table_sql-1185"><span class="linenos">1185</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.table_sql-1186"><a href="#Generator.table_sql-1186"><span class="linenos">1186</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.table_sql-1187"><a href="#Generator.table_sql-1187"><span class="linenos">1187</span></a> <span class="n">joins</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"joins"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> +</span><span id="Generator.table_sql-1188"><a href="#Generator.table_sql-1188"><span class="linenos">1188</span></a> <span class="n">laterals</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"laterals"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> +</span><span id="Generator.table_sql-1189"><a href="#Generator.table_sql-1189"><span class="linenos">1189</span></a> <span class="n">system_time</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"system_time"</span><span class="p">)</span> +</span><span id="Generator.table_sql-1190"><a href="#Generator.table_sql-1190"><span class="linenos">1190</span></a> <span class="n">system_time</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'system_time'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">system_time</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.table_sql-1191"><a href="#Generator.table_sql-1191"><span class="linenos">1191</span></a> +</span><span id="Generator.table_sql-1192"><a href="#Generator.table_sql-1192"><span class="linenos">1192</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">table</span><span class="si">}{</span><span class="n">system_time</span><span class="si">}{</span><span class="n">alias</span><span class="si">}{</span><span class="n">hints</span><span class="si">}{</span><span class="n">pivots</span><span class="si">}{</span><span class="n">joins</span><span class="si">}{</span><span class="n">laterals</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7717,35 +7845,35 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.tablesample_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tablesample_sql-1185"><a href="#Generator.tablesample_sql-1185"><span class="linenos">1185</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> -</span><span id="Generator.tablesample_sql-1186"><a href="#Generator.tablesample_sql-1186"><span class="linenos">1186</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" AS "</span> -</span><span id="Generator.tablesample_sql-1187"><a href="#Generator.tablesample_sql-1187"><span class="linenos">1187</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.tablesample_sql-1188"><a href="#Generator.tablesample_sql-1188"><span class="linenos">1188</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> -</span><span id="Generator.tablesample_sql-1189"><a href="#Generator.tablesample_sql-1189"><span class="linenos">1189</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Generator.tablesample_sql-1190"><a href="#Generator.tablesample_sql-1190"><span class="linenos">1190</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1191"><a href="#Generator.tablesample_sql-1191"><span class="linenos">1191</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1192"><a href="#Generator.tablesample_sql-1192"><span class="linenos">1192</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="s1">'alias'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.tablesample_sql-1193"><a href="#Generator.tablesample_sql-1193"><span class="linenos">1193</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.tablesample_sql-1194"><a href="#Generator.tablesample_sql-1194"><span class="linenos">1194</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1195"><a href="#Generator.tablesample_sql-1195"><span class="linenos">1195</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.tablesample_sql-1196"><a href="#Generator.tablesample_sql-1196"><span class="linenos">1196</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"method"</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1197"><a href="#Generator.tablesample_sql-1197"><span class="linenos">1197</span></a> <span class="n">method</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">method</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.tablesample_sql-1198"><a href="#Generator.tablesample_sql-1198"><span class="linenos">1198</span></a> <span class="n">numerator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_numerator"</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1199"><a href="#Generator.tablesample_sql-1199"><span class="linenos">1199</span></a> <span class="n">denominator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_denominator"</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1200"><a href="#Generator.tablesample_sql-1200"><span class="linenos">1200</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_field"</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1201"><a href="#Generator.tablesample_sql-1201"><span class="linenos">1201</span></a> <span class="n">field</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">field</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.tablesample_sql-1202"><a href="#Generator.tablesample_sql-1202"><span class="linenos">1202</span></a> <span class="n">bucket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"BUCKET </span><span class="si">{</span><span class="n">numerator</span><span class="si">}</span><span class="s2"> OUT OF </span><span class="si">{</span><span class="n">denominator</span><span class="si">}{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">numerator</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.tablesample_sql-1203"><a href="#Generator.tablesample_sql-1203"><span class="linenos">1203</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1204"><a href="#Generator.tablesample_sql-1204"><span class="linenos">1204</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">percent</span><span class="si">}</span><span class="s2"> PERCENT"</span> <span class="k">if</span> <span class="n">percent</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.tablesample_sql-1205"><a href="#Generator.tablesample_sql-1205"><span class="linenos">1205</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1206"><a href="#Generator.tablesample_sql-1206"><span class="linenos">1206</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">rows</span><span class="si">}</span><span class="s2"> ROWS"</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.tablesample_sql-1207"><a href="#Generator.tablesample_sql-1207"><span class="linenos">1207</span></a> <span class="n">size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"size"</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1208"><a href="#Generator.tablesample_sql-1208"><span class="linenos">1208</span></a> <span class="k">if</span> <span class="n">size</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span><span class="p">:</span> -</span><span id="Generator.tablesample_sql-1209"><a href="#Generator.tablesample_sql-1209"><span class="linenos">1209</span></a> <span class="n">size</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">size</span><span class="si">}</span><span class="s2"> PERCENT"</span> -</span><span id="Generator.tablesample_sql-1210"><a href="#Generator.tablesample_sql-1210"><span class="linenos">1210</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"seed"</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1211"><a href="#Generator.tablesample_sql-1211"><span class="linenos">1211</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">seed_prefix</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">seed</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">seed</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.tablesample_sql-1212"><a href="#Generator.tablesample_sql-1212"><span class="linenos">1212</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"TABLESAMPLE"</span><span class="p">)</span> -</span><span id="Generator.tablesample_sql-1213"><a href="#Generator.tablesample_sql-1213"><span class="linenos">1213</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">method</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">bucket</span><span class="si">}{</span><span class="n">percent</span><span class="si">}{</span><span class="n">rows</span><span class="si">}{</span><span class="n">size</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">seed</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tablesample_sql-1194"><a href="#Generator.tablesample_sql-1194"><span class="linenos">1194</span></a> <span class="k">def</span> <span class="nf">tablesample_sql</span><span class="p">(</span> +</span><span id="Generator.tablesample_sql-1195"><a href="#Generator.tablesample_sql-1195"><span class="linenos">1195</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> <span class="n">seed_prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SEED"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" AS "</span> +</span><span id="Generator.tablesample_sql-1196"><a href="#Generator.tablesample_sql-1196"><span class="linenos">1196</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.tablesample_sql-1197"><a href="#Generator.tablesample_sql-1197"><span class="linenos">1197</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> +</span><span id="Generator.tablesample_sql-1198"><a href="#Generator.tablesample_sql-1198"><span class="linenos">1198</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Generator.tablesample_sql-1199"><a href="#Generator.tablesample_sql-1199"><span class="linenos">1199</span></a> <span class="n">table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1200"><a href="#Generator.tablesample_sql-1200"><span class="linenos">1200</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1201"><a href="#Generator.tablesample_sql-1201"><span class="linenos">1201</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span><span class="w"> </span><span class="s1">'alias'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.tablesample_sql-1202"><a href="#Generator.tablesample_sql-1202"><span class="linenos">1202</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.tablesample_sql-1203"><a href="#Generator.tablesample_sql-1203"><span class="linenos">1203</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1204"><a href="#Generator.tablesample_sql-1204"><span class="linenos">1204</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.tablesample_sql-1205"><a href="#Generator.tablesample_sql-1205"><span class="linenos">1205</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"method"</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1206"><a href="#Generator.tablesample_sql-1206"><span class="linenos">1206</span></a> <span class="n">method</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">method</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">method</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_WITH_METHOD</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.tablesample_sql-1207"><a href="#Generator.tablesample_sql-1207"><span class="linenos">1207</span></a> <span class="n">numerator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_numerator"</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1208"><a href="#Generator.tablesample_sql-1208"><span class="linenos">1208</span></a> <span class="n">denominator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_denominator"</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1209"><a href="#Generator.tablesample_sql-1209"><span class="linenos">1209</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"bucket_field"</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1210"><a href="#Generator.tablesample_sql-1210"><span class="linenos">1210</span></a> <span class="n">field</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">field</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.tablesample_sql-1211"><a href="#Generator.tablesample_sql-1211"><span class="linenos">1211</span></a> <span class="n">bucket</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"BUCKET </span><span class="si">{</span><span class="n">numerator</span><span class="si">}</span><span class="s2"> OUT OF </span><span class="si">{</span><span class="n">denominator</span><span class="si">}{</span><span class="n">field</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">numerator</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.tablesample_sql-1212"><a href="#Generator.tablesample_sql-1212"><span class="linenos">1212</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"percent"</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1213"><a href="#Generator.tablesample_sql-1213"><span class="linenos">1213</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">percent</span><span class="si">}</span><span class="s2"> PERCENT"</span> <span class="k">if</span> <span class="n">percent</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.tablesample_sql-1214"><a href="#Generator.tablesample_sql-1214"><span class="linenos">1214</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1215"><a href="#Generator.tablesample_sql-1215"><span class="linenos">1215</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">rows</span><span class="si">}</span><span class="s2"> ROWS"</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.tablesample_sql-1216"><a href="#Generator.tablesample_sql-1216"><span class="linenos">1216</span></a> <span class="n">size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"size"</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1217"><a href="#Generator.tablesample_sql-1217"><span class="linenos">1217</span></a> <span class="k">if</span> <span class="n">size</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLESAMPLE_SIZE_IS_PERCENT</span><span class="p">:</span> +</span><span id="Generator.tablesample_sql-1218"><a href="#Generator.tablesample_sql-1218"><span class="linenos">1218</span></a> <span class="n">size</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">size</span><span class="si">}</span><span class="s2"> PERCENT"</span> +</span><span id="Generator.tablesample_sql-1219"><a href="#Generator.tablesample_sql-1219"><span class="linenos">1219</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"seed"</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1220"><a href="#Generator.tablesample_sql-1220"><span class="linenos">1220</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">seed_prefix</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">seed</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">seed</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.tablesample_sql-1221"><a href="#Generator.tablesample_sql-1221"><span class="linenos">1221</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"TABLESAMPLE"</span><span class="p">)</span> +</span><span id="Generator.tablesample_sql-1222"><a href="#Generator.tablesample_sql-1222"><span class="linenos">1222</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">method</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">bucket</span><span class="si">}{</span><span class="n">percent</span><span class="si">}{</span><span class="n">rows</span><span class="si">}{</span><span class="n">size</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">seed</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7763,23 +7891,23 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.pivot_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.pivot_sql-1215"><a href="#Generator.pivot_sql-1215"><span class="linenos">1215</span></a> <span class="k">def</span> <span class="nf">pivot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.pivot_sql-1216"><a href="#Generator.pivot_sql-1216"><span class="linenos">1216</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.pivot_sql-1217"><a href="#Generator.pivot_sql-1217"><span class="linenos">1217</span></a> -</span><span id="Generator.pivot_sql-1218"><a href="#Generator.pivot_sql-1218"><span class="linenos">1218</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> -</span><span id="Generator.pivot_sql-1219"><a href="#Generator.pivot_sql-1219"><span class="linenos">1219</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.pivot_sql-1220"><a href="#Generator.pivot_sql-1220"><span class="linenos">1220</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'ON'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.pivot_sql-1221"><a href="#Generator.pivot_sql-1221"><span class="linenos">1221</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"using"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.pivot_sql-1222"><a href="#Generator.pivot_sql-1222"><span class="linenos">1222</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'USING'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.pivot_sql-1223"><a href="#Generator.pivot_sql-1223"><span class="linenos">1223</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">)</span> -</span><span id="Generator.pivot_sql-1224"><a href="#Generator.pivot_sql-1224"><span class="linenos">1224</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PIVOT </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">on</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">group</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.pivot_sql-1225"><a href="#Generator.pivot_sql-1225"><span class="linenos">1225</span></a> -</span><span id="Generator.pivot_sql-1226"><a href="#Generator.pivot_sql-1226"><span class="linenos">1226</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator.pivot_sql-1227"><a href="#Generator.pivot_sql-1227"><span class="linenos">1227</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.pivot_sql-1228"><a href="#Generator.pivot_sql-1228"><span class="linenos">1228</span></a> <span class="n">unpivot</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unpivot"</span><span class="p">)</span> -</span><span id="Generator.pivot_sql-1229"><a href="#Generator.pivot_sql-1229"><span class="linenos">1229</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="s2">"UNPIVOT"</span> <span class="k">if</span> <span class="n">unpivot</span> <span class="k">else</span> <span class="s2">"PIVOT"</span> -</span><span id="Generator.pivot_sql-1230"><a href="#Generator.pivot_sql-1230"><span class="linenos">1230</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"field"</span><span class="p">)</span> -</span><span id="Generator.pivot_sql-1231"><a href="#Generator.pivot_sql-1231"><span class="linenos">1231</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">direction</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2"> FOR </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.pivot_sql-1224"><a href="#Generator.pivot_sql-1224"><span class="linenos">1224</span></a> <span class="k">def</span> <span class="nf">pivot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.pivot_sql-1225"><a href="#Generator.pivot_sql-1225"><span class="linenos">1225</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.pivot_sql-1226"><a href="#Generator.pivot_sql-1226"><span class="linenos">1226</span></a> +</span><span id="Generator.pivot_sql-1227"><a href="#Generator.pivot_sql-1227"><span class="linenos">1227</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> +</span><span id="Generator.pivot_sql-1228"><a href="#Generator.pivot_sql-1228"><span class="linenos">1228</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.pivot_sql-1229"><a href="#Generator.pivot_sql-1229"><span class="linenos">1229</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'ON'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.pivot_sql-1230"><a href="#Generator.pivot_sql-1230"><span class="linenos">1230</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"using"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.pivot_sql-1231"><a href="#Generator.pivot_sql-1231"><span class="linenos">1231</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'USING'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.pivot_sql-1232"><a href="#Generator.pivot_sql-1232"><span class="linenos">1232</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">)</span> +</span><span id="Generator.pivot_sql-1233"><a href="#Generator.pivot_sql-1233"><span class="linenos">1233</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PIVOT </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">on</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">group</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.pivot_sql-1234"><a href="#Generator.pivot_sql-1234"><span class="linenos">1234</span></a> +</span><span id="Generator.pivot_sql-1235"><a href="#Generator.pivot_sql-1235"><span class="linenos">1235</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator.pivot_sql-1236"><a href="#Generator.pivot_sql-1236"><span class="linenos">1236</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.pivot_sql-1237"><a href="#Generator.pivot_sql-1237"><span class="linenos">1237</span></a> <span class="n">unpivot</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unpivot"</span><span class="p">)</span> +</span><span id="Generator.pivot_sql-1238"><a href="#Generator.pivot_sql-1238"><span class="linenos">1238</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="s2">"UNPIVOT"</span> <span class="k">if</span> <span class="n">unpivot</span> <span class="k">else</span> <span class="s2">"PIVOT"</span> +</span><span id="Generator.pivot_sql-1239"><a href="#Generator.pivot_sql-1239"><span class="linenos">1239</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"field"</span><span class="p">)</span> +</span><span id="Generator.pivot_sql-1240"><a href="#Generator.pivot_sql-1240"><span class="linenos">1240</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">direction</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2"> FOR </span><span class="si">{</span><span class="n">field</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7797,8 +7925,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.tuple_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tuple_sql-1233"><a href="#Generator.tuple_sql-1233"><span class="linenos">1233</span></a> <span class="k">def</span> <span class="nf">tuple_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Tuple</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.tuple_sql-1234"><a href="#Generator.tuple_sql-1234"><span class="linenos">1234</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tuple_sql-1242"><a href="#Generator.tuple_sql-1242"><span class="linenos">1242</span></a> <span class="k">def</span> <span class="nf">tuple_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Tuple</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.tuple_sql-1243"><a href="#Generator.tuple_sql-1243"><span class="linenos">1243</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -7816,14 +7944,14 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.update_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.update_sql-1236"><a href="#Generator.update_sql-1236"><span class="linenos">1236</span></a> <span class="k">def</span> <span class="nf">update_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.update_sql-1237"><a href="#Generator.update_sql-1237"><span class="linenos">1237</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.update_sql-1238"><a href="#Generator.update_sql-1238"><span class="linenos">1238</span></a> <span class="n">set_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.update_sql-1239"><a href="#Generator.update_sql-1239"><span class="linenos">1239</span></a> <span class="n">from_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">)</span> -</span><span id="Generator.update_sql-1240"><a href="#Generator.update_sql-1240"><span class="linenos">1240</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> -</span><span id="Generator.update_sql-1241"><a href="#Generator.update_sql-1241"><span class="linenos">1241</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> -</span><span id="Generator.update_sql-1242"><a href="#Generator.update_sql-1242"><span class="linenos">1242</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.update_sql-1243"><a href="#Generator.update_sql-1243"><span class="linenos">1243</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.update_sql-1245"><a href="#Generator.update_sql-1245"><span class="linenos">1245</span></a> <span class="k">def</span> <span class="nf">update_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.update_sql-1246"><a href="#Generator.update_sql-1246"><span class="linenos">1246</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.update_sql-1247"><a href="#Generator.update_sql-1247"><span class="linenos">1247</span></a> <span class="n">set_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.update_sql-1248"><a href="#Generator.update_sql-1248"><span class="linenos">1248</span></a> <span class="n">from_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">)</span> +</span><span id="Generator.update_sql-1249"><a href="#Generator.update_sql-1249"><span class="linenos">1249</span></a> <span class="n">where_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> +</span><span id="Generator.update_sql-1250"><a href="#Generator.update_sql-1250"><span class="linenos">1250</span></a> <span class="n">returning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"returning"</span><span class="p">)</span> +</span><span id="Generator.update_sql-1251"><a href="#Generator.update_sql-1251"><span class="linenos">1251</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET </span><span class="si">{</span><span class="n">set_sql</span><span class="si">}{</span><span class="n">from_sql</span><span class="si">}{</span><span class="n">where_sql</span><span class="si">}{</span><span class="n">returning</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.update_sql-1252"><a href="#Generator.update_sql-1252"><span class="linenos">1252</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> </span></pre></div> @@ -7841,16 +7969,16 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.values_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.values_sql-1245"><a href="#Generator.values_sql-1245"><span class="linenos">1245</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.values_sql-1246"><a href="#Generator.values_sql-1246"><span class="linenos">1246</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.values_sql-1247"><a href="#Generator.values_sql-1247"><span class="linenos">1247</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator.values_sql-1248"><a href="#Generator.values_sql-1248"><span class="linenos">1248</span></a> <span class="n">values</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"VALUES</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.values_sql-1249"><a href="#Generator.values_sql-1249"><span class="linenos">1249</span></a> <span class="n">values</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.values_sql-1250"><a href="#Generator.values_sql-1250"><span class="linenos">1250</span></a> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">values</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.values_sql-1251"><a href="#Generator.values_sql-1251"><span class="linenos">1251</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">WRAP_DERIVED_VALUES</span> <span class="ow">and</span> <span class="p">(</span><span class="n">alias</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">))</span> -</span><span id="Generator.values_sql-1252"><a href="#Generator.values_sql-1252"><span class="linenos">1252</span></a> <span class="k">else</span> <span class="n">values</span> -</span><span id="Generator.values_sql-1253"><a href="#Generator.values_sql-1253"><span class="linenos">1253</span></a> <span class="p">)</span> -</span><span id="Generator.values_sql-1254"><a href="#Generator.values_sql-1254"><span class="linenos">1254</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">values</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">values</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.values_sql-1254"><a href="#Generator.values_sql-1254"><span class="linenos">1254</span></a> <span class="k">def</span> <span class="nf">values_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.values_sql-1255"><a href="#Generator.values_sql-1255"><span class="linenos">1255</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.values_sql-1256"><a href="#Generator.values_sql-1256"><span class="linenos">1256</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator.values_sql-1257"><a href="#Generator.values_sql-1257"><span class="linenos">1257</span></a> <span class="n">values</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"VALUES</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.values_sql-1258"><a href="#Generator.values_sql-1258"><span class="linenos">1258</span></a> <span class="n">values</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.values_sql-1259"><a href="#Generator.values_sql-1259"><span class="linenos">1259</span></a> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">values</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.values_sql-1260"><a href="#Generator.values_sql-1260"><span class="linenos">1260</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">WRAP_DERIVED_VALUES</span> <span class="ow">and</span> <span class="p">(</span><span class="n">alias</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">))</span> +</span><span id="Generator.values_sql-1261"><a href="#Generator.values_sql-1261"><span class="linenos">1261</span></a> <span class="k">else</span> <span class="n">values</span> +</span><span id="Generator.values_sql-1262"><a href="#Generator.values_sql-1262"><span class="linenos">1262</span></a> <span class="p">)</span> +</span><span id="Generator.values_sql-1263"><a href="#Generator.values_sql-1263"><span class="linenos">1263</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">values</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">values</span> </span></pre></div> @@ -7868,8 +7996,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.var_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.var_sql-1256"><a href="#Generator.var_sql-1256"><span class="linenos">1256</span></a> <span class="k">def</span> <span class="nf">var_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Var</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.var_sql-1257"><a href="#Generator.var_sql-1257"><span class="linenos">1257</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.var_sql-1265"><a href="#Generator.var_sql-1265"><span class="linenos">1265</span></a> <span class="k">def</span> <span class="nf">var_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Var</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.var_sql-1266"><a href="#Generator.var_sql-1266"><span class="linenos">1266</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> </span></pre></div> @@ -7887,10 +8015,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.into_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.into_sql-1259"><a href="#Generator.into_sql-1259"><span class="linenos">1259</span></a> <span class="k">def</span> <span class="nf">into_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Into</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.into_sql-1260"><a href="#Generator.into_sql-1260"><span class="linenos">1260</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.into_sql-1261"><a href="#Generator.into_sql-1261"><span class="linenos">1261</span></a> <span class="n">unlogged</span> <span class="o">=</span> <span class="s2">" UNLOGGED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unlogged"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.into_sql-1262"><a href="#Generator.into_sql-1262"><span class="linenos">1262</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'INTO'</span><span class="p">)</span><span class="si">}{</span><span class="n">temporary</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="n">unlogged</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.into_sql-1268"><a href="#Generator.into_sql-1268"><span class="linenos">1268</span></a> <span class="k">def</span> <span class="nf">into_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Into</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.into_sql-1269"><a href="#Generator.into_sql-1269"><span class="linenos">1269</span></a> <span class="n">temporary</span> <span class="o">=</span> <span class="s2">" TEMPORARY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"temporary"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.into_sql-1270"><a href="#Generator.into_sql-1270"><span class="linenos">1270</span></a> <span class="n">unlogged</span> <span class="o">=</span> <span class="s2">" UNLOGGED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unlogged"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.into_sql-1271"><a href="#Generator.into_sql-1271"><span class="linenos">1271</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'INTO'</span><span class="p">)</span><span class="si">}{</span><span class="n">temporary</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="n">unlogged</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7908,8 +8036,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.from_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.from_sql-1264"><a href="#Generator.from_sql-1264"><span class="linenos">1264</span></a> <span class="k">def</span> <span class="nf">from_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.from_sql-1265"><a href="#Generator.from_sql-1265"><span class="linenos">1265</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'FROM'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.from_sql-1273"><a href="#Generator.from_sql-1273"><span class="linenos">1273</span></a> <span class="k">def</span> <span class="nf">from_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.from_sql-1274"><a href="#Generator.from_sql-1274"><span class="linenos">1274</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'FROM'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7927,39 +8055,39 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.group_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.group_sql-1267"><a href="#Generator.group_sql-1267"><span class="linenos">1267</span></a> <span class="k">def</span> <span class="nf">group_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Group</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.group_sql-1268"><a href="#Generator.group_sql-1268"><span class="linenos">1268</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"GROUP BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.group_sql-1269"><a href="#Generator.group_sql-1269"><span class="linenos">1269</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"grouping_sets"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator.group_sql-1270"><a href="#Generator.group_sql-1270"><span class="linenos">1270</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.group_sql-1271"><a href="#Generator.group_sql-1271"><span class="linenos">1271</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'GROUPING SETS'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">grouping_sets</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">grouping_sets</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.group_sql-1272"><a href="#Generator.group_sql-1272"><span class="linenos">1272</span></a> <span class="p">)</span> -</span><span id="Generator.group_sql-1273"><a href="#Generator.group_sql-1273"><span class="linenos">1273</span></a> -</span><span id="Generator.group_sql-1274"><a href="#Generator.group_sql-1274"><span class="linenos">1274</span></a> <span class="n">cube</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"cube"</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="Generator.group_sql-1275"><a href="#Generator.group_sql-1275"><span class="linenos">1275</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">cube</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Generator.group_sql-1276"><a href="#Generator.group_sql-1276"><span class="linenos">1276</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'WITH CUBE'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.group_sql-1277"><a href="#Generator.group_sql-1277"><span class="linenos">1277</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.group_sql-1278"><a href="#Generator.group_sql-1278"><span class="linenos">1278</span></a> <span class="n">cube_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"cube"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator.group_sql-1279"><a href="#Generator.group_sql-1279"><span class="linenos">1279</span></a> <span class="n">cube_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'CUBE'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">cube_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">cube_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.group_sql-1280"><a href="#Generator.group_sql-1280"><span class="linenos">1280</span></a> -</span><span id="Generator.group_sql-1281"><a href="#Generator.group_sql-1281"><span class="linenos">1281</span></a> <span class="n">rollup</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"rollup"</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="Generator.group_sql-1282"><a href="#Generator.group_sql-1282"><span class="linenos">1282</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">rollup</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Generator.group_sql-1283"><a href="#Generator.group_sql-1283"><span class="linenos">1283</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'WITH ROLLUP'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.group_sql-1284"><a href="#Generator.group_sql-1284"><span class="linenos">1284</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.group_sql-1285"><a href="#Generator.group_sql-1285"><span class="linenos">1285</span></a> <span class="n">rollup_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"rollup"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator.group_sql-1286"><a href="#Generator.group_sql-1286"><span class="linenos">1286</span></a> <span class="n">rollup_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'ROLLUP'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">rollup_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">rollup_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.group_sql-1287"><a href="#Generator.group_sql-1287"><span class="linenos">1287</span></a> -</span><span id="Generator.group_sql-1288"><a href="#Generator.group_sql-1288"><span class="linenos">1288</span></a> <span class="n">groupings</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span> -</span><span id="Generator.group_sql-1289"><a href="#Generator.group_sql-1289"><span class="linenos">1289</span></a> <span class="n">grouping_sets</span><span class="p">,</span> -</span><span id="Generator.group_sql-1290"><a href="#Generator.group_sql-1290"><span class="linenos">1290</span></a> <span class="n">cube_sql</span><span class="p">,</span> -</span><span id="Generator.group_sql-1291"><a href="#Generator.group_sql-1291"><span class="linenos">1291</span></a> <span class="n">rollup_sql</span><span class="p">,</span> -</span><span id="Generator.group_sql-1292"><a href="#Generator.group_sql-1292"><span class="linenos">1292</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WITH TOTALS"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"totals"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="Generator.group_sql-1293"><a href="#Generator.group_sql-1293"><span class="linenos">1293</span></a> <span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="p">,</span> -</span><span id="Generator.group_sql-1294"><a href="#Generator.group_sql-1294"><span class="linenos">1294</span></a> <span class="p">)</span> -</span><span id="Generator.group_sql-1295"><a href="#Generator.group_sql-1295"><span class="linenos">1295</span></a> -</span><span id="Generator.group_sql-1296"><a href="#Generator.group_sql-1296"><span class="linenos">1296</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> <span class="ow">and</span> <span class="n">groupings</span><span class="p">:</span> -</span><span id="Generator.group_sql-1297"><a href="#Generator.group_sql-1297"><span class="linenos">1297</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.group_sql-1298"><a href="#Generator.group_sql-1298"><span class="linenos">1298</span></a> -</span><span id="Generator.group_sql-1299"><a href="#Generator.group_sql-1299"><span class="linenos">1299</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="n">groupings</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.group_sql-1276"><a href="#Generator.group_sql-1276"><span class="linenos">1276</span></a> <span class="k">def</span> <span class="nf">group_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Group</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.group_sql-1277"><a href="#Generator.group_sql-1277"><span class="linenos">1277</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"GROUP BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.group_sql-1278"><a href="#Generator.group_sql-1278"><span class="linenos">1278</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"grouping_sets"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator.group_sql-1279"><a href="#Generator.group_sql-1279"><span class="linenos">1279</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.group_sql-1280"><a href="#Generator.group_sql-1280"><span class="linenos">1280</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'GROUPING SETS'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">grouping_sets</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">grouping_sets</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.group_sql-1281"><a href="#Generator.group_sql-1281"><span class="linenos">1281</span></a> <span class="p">)</span> +</span><span id="Generator.group_sql-1282"><a href="#Generator.group_sql-1282"><span class="linenos">1282</span></a> +</span><span id="Generator.group_sql-1283"><a href="#Generator.group_sql-1283"><span class="linenos">1283</span></a> <span class="n">cube</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"cube"</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="Generator.group_sql-1284"><a href="#Generator.group_sql-1284"><span class="linenos">1284</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">cube</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Generator.group_sql-1285"><a href="#Generator.group_sql-1285"><span class="linenos">1285</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'WITH CUBE'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.group_sql-1286"><a href="#Generator.group_sql-1286"><span class="linenos">1286</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.group_sql-1287"><a href="#Generator.group_sql-1287"><span class="linenos">1287</span></a> <span class="n">cube_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"cube"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator.group_sql-1288"><a href="#Generator.group_sql-1288"><span class="linenos">1288</span></a> <span class="n">cube_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'CUBE'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">cube_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">cube_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.group_sql-1289"><a href="#Generator.group_sql-1289"><span class="linenos">1289</span></a> +</span><span id="Generator.group_sql-1290"><a href="#Generator.group_sql-1290"><span class="linenos">1290</span></a> <span class="n">rollup</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"rollup"</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="Generator.group_sql-1291"><a href="#Generator.group_sql-1291"><span class="linenos">1291</span></a> <span class="k">if</span> <span class="n">seq_get</span><span class="p">(</span><span class="n">rollup</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Generator.group_sql-1292"><a href="#Generator.group_sql-1292"><span class="linenos">1292</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'WITH ROLLUP'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.group_sql-1293"><a href="#Generator.group_sql-1293"><span class="linenos">1293</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.group_sql-1294"><a href="#Generator.group_sql-1294"><span class="linenos">1294</span></a> <span class="n">rollup_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"rollup"</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator.group_sql-1295"><a href="#Generator.group_sql-1295"><span class="linenos">1295</span></a> <span class="n">rollup_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'ROLLUP'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">rollup_sql</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">rollup_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.group_sql-1296"><a href="#Generator.group_sql-1296"><span class="linenos">1296</span></a> +</span><span id="Generator.group_sql-1297"><a href="#Generator.group_sql-1297"><span class="linenos">1297</span></a> <span class="n">groupings</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span> +</span><span id="Generator.group_sql-1298"><a href="#Generator.group_sql-1298"><span class="linenos">1298</span></a> <span class="n">grouping_sets</span><span class="p">,</span> +</span><span id="Generator.group_sql-1299"><a href="#Generator.group_sql-1299"><span class="linenos">1299</span></a> <span class="n">cube_sql</span><span class="p">,</span> +</span><span id="Generator.group_sql-1300"><a href="#Generator.group_sql-1300"><span class="linenos">1300</span></a> <span class="n">rollup_sql</span><span class="p">,</span> +</span><span id="Generator.group_sql-1301"><a href="#Generator.group_sql-1301"><span class="linenos">1301</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WITH TOTALS"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"totals"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="Generator.group_sql-1302"><a href="#Generator.group_sql-1302"><span class="linenos">1302</span></a> <span class="n">sep</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="p">,</span> +</span><span id="Generator.group_sql-1303"><a href="#Generator.group_sql-1303"><span class="linenos">1303</span></a> <span class="p">)</span> +</span><span id="Generator.group_sql-1304"><a href="#Generator.group_sql-1304"><span class="linenos">1304</span></a> +</span><span id="Generator.group_sql-1305"><a href="#Generator.group_sql-1305"><span class="linenos">1305</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">)</span> <span class="ow">and</span> <span class="n">groupings</span><span class="p">:</span> +</span><span id="Generator.group_sql-1306"><a href="#Generator.group_sql-1306"><span class="linenos">1306</span></a> <span class="n">group_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">GROUPINGS_SEP</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.group_sql-1307"><a href="#Generator.group_sql-1307"><span class="linenos">1307</span></a> +</span><span id="Generator.group_sql-1308"><a href="#Generator.group_sql-1308"><span class="linenos">1308</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">group_by</span><span class="si">}{</span><span class="n">groupings</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7977,9 +8105,9 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.having_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.having_sql-1301"><a href="#Generator.having_sql-1301"><span class="linenos">1301</span></a> <span class="k">def</span> <span class="nf">having_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Having</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.having_sql-1302"><a href="#Generator.having_sql-1302"><span class="linenos">1302</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))</span> -</span><span id="Generator.having_sql-1303"><a href="#Generator.having_sql-1303"><span class="linenos">1303</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'HAVING'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.having_sql-1310"><a href="#Generator.having_sql-1310"><span class="linenos">1310</span></a> <span class="k">def</span> <span class="nf">having_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Having</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.having_sql-1311"><a href="#Generator.having_sql-1311"><span class="linenos">1311</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))</span> +</span><span id="Generator.having_sql-1312"><a href="#Generator.having_sql-1312"><span class="linenos">1312</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'HAVING'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -7997,38 +8125,38 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.join_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.join_sql-1305"><a href="#Generator.join_sql-1305"><span class="linenos">1305</span></a> <span class="k">def</span> <span class="nf">join_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.join_sql-1306"><a href="#Generator.join_sql-1306"><span class="linenos">1306</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator.join_sql-1307"><a href="#Generator.join_sql-1307"><span class="linenos">1307</span></a> <span class="n">op</span> -</span><span id="Generator.join_sql-1308"><a href="#Generator.join_sql-1308"><span class="linenos">1308</span></a> <span class="k">for</span> <span class="n">op</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="Generator.join_sql-1309"><a href="#Generator.join_sql-1309"><span class="linenos">1309</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">method</span><span class="p">,</span> -</span><span id="Generator.join_sql-1310"><a href="#Generator.join_sql-1310"><span class="linenos">1310</span></a> <span class="s2">"GLOBAL"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.join_sql-1311"><a href="#Generator.join_sql-1311"><span class="linenos">1311</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">side</span><span class="p">,</span> -</span><span id="Generator.join_sql-1312"><a href="#Generator.join_sql-1312"><span class="linenos">1312</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">kind</span><span class="p">,</span> -</span><span id="Generator.join_sql-1313"><a href="#Generator.join_sql-1313"><span class="linenos">1313</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">hint</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">JOIN_HINTS</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.join_sql-1314"><a href="#Generator.join_sql-1314"><span class="linenos">1314</span></a> <span class="p">)</span> -</span><span id="Generator.join_sql-1315"><a href="#Generator.join_sql-1315"><span class="linenos">1315</span></a> <span class="k">if</span> <span class="n">op</span> -</span><span id="Generator.join_sql-1316"><a href="#Generator.join_sql-1316"><span class="linenos">1316</span></a> <span class="p">)</span> -</span><span id="Generator.join_sql-1317"><a href="#Generator.join_sql-1317"><span class="linenos">1317</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">)</span> -</span><span id="Generator.join_sql-1318"><a href="#Generator.join_sql-1318"><span class="linenos">1318</span></a> <span class="n">using</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"using"</span><span class="p">)</span> -</span><span id="Generator.join_sql-1319"><a href="#Generator.join_sql-1319"><span class="linenos">1319</span></a> -</span><span id="Generator.join_sql-1320"><a href="#Generator.join_sql-1320"><span class="linenos">1320</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">on_sql</span> <span class="ow">and</span> <span class="n">using</span><span class="p">:</span> -</span><span id="Generator.join_sql-1321"><a href="#Generator.join_sql-1321"><span class="linenos">1321</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span><span class="o">*</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">column</span><span class="p">)</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">using</span><span class="p">))</span> -</span><span id="Generator.join_sql-1322"><a href="#Generator.join_sql-1322"><span class="linenos">1322</span></a> -</span><span id="Generator.join_sql-1323"><a href="#Generator.join_sql-1323"><span class="linenos">1323</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.join_sql-1324"><a href="#Generator.join_sql-1324"><span class="linenos">1324</span></a> -</span><span id="Generator.join_sql-1325"><a href="#Generator.join_sql-1325"><span class="linenos">1325</span></a> <span class="k">if</span> <span class="n">on_sql</span><span class="p">:</span> -</span><span id="Generator.join_sql-1326"><a href="#Generator.join_sql-1326"><span class="linenos">1326</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">on_sql</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.join_sql-1327"><a href="#Generator.join_sql-1327"><span class="linenos">1327</span></a> <span class="n">space</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator.join_sql-1328"><a href="#Generator.join_sql-1328"><span class="linenos">1328</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> -</span><span id="Generator.join_sql-1329"><a href="#Generator.join_sql-1329"><span class="linenos">1329</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">USING (</span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.join_sql-1330"><a href="#Generator.join_sql-1330"><span class="linenos">1330</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.join_sql-1331"><a href="#Generator.join_sql-1331"><span class="linenos">1331</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.join_sql-1332"><a href="#Generator.join_sql-1332"><span class="linenos">1332</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">op_sql</span><span class="p">:</span> -</span><span id="Generator.join_sql-1333"><a href="#Generator.join_sql-1333"><span class="linenos">1333</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.join_sql-1334"><a href="#Generator.join_sql-1334"><span class="linenos">1334</span></a> -</span><span id="Generator.join_sql-1335"><a href="#Generator.join_sql-1335"><span class="linenos">1335</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</span><span class="si">}</span><span class="s2"> JOIN"</span> <span class="k">if</span> <span class="n">op_sql</span> <span class="k">else</span> <span class="s2">"JOIN"</span> -</span><span id="Generator.join_sql-1336"><a href="#Generator.join_sql-1336"><span class="linenos">1336</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op_sql</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.join_sql-1314"><a href="#Generator.join_sql-1314"><span class="linenos">1314</span></a> <span class="k">def</span> <span class="nf">join_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.join_sql-1315"><a href="#Generator.join_sql-1315"><span class="linenos">1315</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator.join_sql-1316"><a href="#Generator.join_sql-1316"><span class="linenos">1316</span></a> <span class="n">op</span> +</span><span id="Generator.join_sql-1317"><a href="#Generator.join_sql-1317"><span class="linenos">1317</span></a> <span class="k">for</span> <span class="n">op</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="Generator.join_sql-1318"><a href="#Generator.join_sql-1318"><span class="linenos">1318</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">method</span><span class="p">,</span> +</span><span id="Generator.join_sql-1319"><a href="#Generator.join_sql-1319"><span class="linenos">1319</span></a> <span class="s2">"GLOBAL"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.join_sql-1320"><a href="#Generator.join_sql-1320"><span class="linenos">1320</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">side</span><span class="p">,</span> +</span><span id="Generator.join_sql-1321"><a href="#Generator.join_sql-1321"><span class="linenos">1321</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">kind</span><span class="p">,</span> +</span><span id="Generator.join_sql-1322"><a href="#Generator.join_sql-1322"><span class="linenos">1322</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">hint</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">JOIN_HINTS</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.join_sql-1323"><a href="#Generator.join_sql-1323"><span class="linenos">1323</span></a> <span class="p">)</span> +</span><span id="Generator.join_sql-1324"><a href="#Generator.join_sql-1324"><span class="linenos">1324</span></a> <span class="k">if</span> <span class="n">op</span> +</span><span id="Generator.join_sql-1325"><a href="#Generator.join_sql-1325"><span class="linenos">1325</span></a> <span class="p">)</span> +</span><span id="Generator.join_sql-1326"><a href="#Generator.join_sql-1326"><span class="linenos">1326</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">)</span> +</span><span id="Generator.join_sql-1327"><a href="#Generator.join_sql-1327"><span class="linenos">1327</span></a> <span class="n">using</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"using"</span><span class="p">)</span> +</span><span id="Generator.join_sql-1328"><a href="#Generator.join_sql-1328"><span class="linenos">1328</span></a> +</span><span id="Generator.join_sql-1329"><a href="#Generator.join_sql-1329"><span class="linenos">1329</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">on_sql</span> <span class="ow">and</span> <span class="n">using</span><span class="p">:</span> +</span><span id="Generator.join_sql-1330"><a href="#Generator.join_sql-1330"><span class="linenos">1330</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span><span class="o">*</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">column</span><span class="p">)</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">using</span><span class="p">))</span> +</span><span id="Generator.join_sql-1331"><a href="#Generator.join_sql-1331"><span class="linenos">1331</span></a> +</span><span id="Generator.join_sql-1332"><a href="#Generator.join_sql-1332"><span class="linenos">1332</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.join_sql-1333"><a href="#Generator.join_sql-1333"><span class="linenos">1333</span></a> +</span><span id="Generator.join_sql-1334"><a href="#Generator.join_sql-1334"><span class="linenos">1334</span></a> <span class="k">if</span> <span class="n">on_sql</span><span class="p">:</span> +</span><span id="Generator.join_sql-1335"><a href="#Generator.join_sql-1335"><span class="linenos">1335</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">on_sql</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.join_sql-1336"><a href="#Generator.join_sql-1336"><span class="linenos">1336</span></a> <span class="n">space</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator.join_sql-1337"><a href="#Generator.join_sql-1337"><span class="linenos">1337</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> +</span><span id="Generator.join_sql-1338"><a href="#Generator.join_sql-1338"><span class="linenos">1338</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">USING (</span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.join_sql-1339"><a href="#Generator.join_sql-1339"><span class="linenos">1339</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.join_sql-1340"><a href="#Generator.join_sql-1340"><span class="linenos">1340</span></a> <span class="n">on_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">space</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.join_sql-1341"><a href="#Generator.join_sql-1341"><span class="linenos">1341</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">op_sql</span><span class="p">:</span> +</span><span id="Generator.join_sql-1342"><a href="#Generator.join_sql-1342"><span class="linenos">1342</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.join_sql-1343"><a href="#Generator.join_sql-1343"><span class="linenos">1343</span></a> +</span><span id="Generator.join_sql-1344"><a href="#Generator.join_sql-1344"><span class="linenos">1344</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</span><span class="si">}</span><span class="s2"> JOIN"</span> <span class="k">if</span> <span class="n">op_sql</span> <span class="k">else</span> <span class="s2">"JOIN"</span> +</span><span id="Generator.join_sql-1345"><a href="#Generator.join_sql-1345"><span class="linenos">1345</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op_sql</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this_sql</span><span class="si">}{</span><span class="n">on_sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8046,10 +8174,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.lambda_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lambda_sql-1338"><a href="#Generator.lambda_sql-1338"><span class="linenos">1338</span></a> <span class="k">def</span> <span class="nf">lambda_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lambda</span><span class="p">,</span> <span class="n">arrow_sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"->"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.lambda_sql-1339"><a href="#Generator.lambda_sql-1339"><span class="linenos">1339</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.lambda_sql-1340"><a href="#Generator.lambda_sql-1340"><span class="linenos">1340</span></a> <span class="n">args</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">))</span> <span class="o">></span> <span class="mi">1</span> <span class="k">else</span> <span class="n">args</span> -</span><span id="Generator.lambda_sql-1341"><a href="#Generator.lambda_sql-1341"><span class="linenos">1341</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">arrow_sep</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lambda_sql-1347"><a href="#Generator.lambda_sql-1347"><span class="linenos">1347</span></a> <span class="k">def</span> <span class="nf">lambda_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lambda</span><span class="p">,</span> <span class="n">arrow_sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"->"</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.lambda_sql-1348"><a href="#Generator.lambda_sql-1348"><span class="linenos">1348</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.lambda_sql-1349"><a href="#Generator.lambda_sql-1349"><span class="linenos">1349</span></a> <span class="n">args</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">))</span> <span class="o">></span> <span class="mi">1</span> <span class="k">else</span> <span class="n">args</span> +</span><span id="Generator.lambda_sql-1350"><a href="#Generator.lambda_sql-1350"><span class="linenos">1350</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">arrow_sep</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8067,23 +8195,23 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.lateral_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lateral_sql-1343"><a href="#Generator.lateral_sql-1343"><span class="linenos">1343</span></a> <span class="k">def</span> <span class="nf">lateral_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.lateral_sql-1344"><a href="#Generator.lateral_sql-1344"><span class="linenos">1344</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.lateral_sql-1345"><a href="#Generator.lateral_sql-1345"><span class="linenos">1345</span></a> -</span><span id="Generator.lateral_sql-1346"><a href="#Generator.lateral_sql-1346"><span class="linenos">1346</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">):</span> -</span><span id="Generator.lateral_sql-1347"><a href="#Generator.lateral_sql-1347"><span class="linenos">1347</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LATERAL </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.lateral_sql-1348"><a href="#Generator.lateral_sql-1348"><span class="linenos">1348</span></a> -</span><span id="Generator.lateral_sql-1349"><a href="#Generator.lateral_sql-1349"><span class="linenos">1349</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"view"</span><span class="p">):</span> -</span><span id="Generator.lateral_sql-1350"><a href="#Generator.lateral_sql-1350"><span class="linenos">1350</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"alias"</span><span class="p">]</span> -</span><span id="Generator.lateral_sql-1351"><a href="#Generator.lateral_sql-1351"><span class="linenos">1351</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.lateral_sql-1352"><a href="#Generator.lateral_sql-1352"><span class="linenos">1352</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">alias</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.lateral_sql-1353"><a href="#Generator.lateral_sql-1353"><span class="linenos">1353</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.lateral_sql-1354"><a href="#Generator.lateral_sql-1354"><span class="linenos">1354</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"LATERAL VIEW</span><span class="si">{</span><span class="s1">' OUTER'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'outer'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.lateral_sql-1355"><a href="#Generator.lateral_sql-1355"><span class="linenos">1355</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.lateral_sql-1356"><a href="#Generator.lateral_sql-1356"><span class="linenos">1356</span></a> -</span><span id="Generator.lateral_sql-1357"><a href="#Generator.lateral_sql-1357"><span class="linenos">1357</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator.lateral_sql-1358"><a href="#Generator.lateral_sql-1358"><span class="linenos">1358</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.lateral_sql-1359"><a href="#Generator.lateral_sql-1359"><span class="linenos">1359</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LATERAL </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lateral_sql-1352"><a href="#Generator.lateral_sql-1352"><span class="linenos">1352</span></a> <span class="k">def</span> <span class="nf">lateral_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lateral</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.lateral_sql-1353"><a href="#Generator.lateral_sql-1353"><span class="linenos">1353</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.lateral_sql-1354"><a href="#Generator.lateral_sql-1354"><span class="linenos">1354</span></a> +</span><span id="Generator.lateral_sql-1355"><a href="#Generator.lateral_sql-1355"><span class="linenos">1355</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">):</span> +</span><span id="Generator.lateral_sql-1356"><a href="#Generator.lateral_sql-1356"><span class="linenos">1356</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LATERAL </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.lateral_sql-1357"><a href="#Generator.lateral_sql-1357"><span class="linenos">1357</span></a> +</span><span id="Generator.lateral_sql-1358"><a href="#Generator.lateral_sql-1358"><span class="linenos">1358</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"view"</span><span class="p">):</span> +</span><span id="Generator.lateral_sql-1359"><a href="#Generator.lateral_sql-1359"><span class="linenos">1359</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"alias"</span><span class="p">]</span> +</span><span id="Generator.lateral_sql-1360"><a href="#Generator.lateral_sql-1360"><span class="linenos">1360</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.lateral_sql-1361"><a href="#Generator.lateral_sql-1361"><span class="linenos">1361</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">alias</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.lateral_sql-1362"><a href="#Generator.lateral_sql-1362"><span class="linenos">1362</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.lateral_sql-1363"><a href="#Generator.lateral_sql-1363"><span class="linenos">1363</span></a> <span class="n">op_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"LATERAL VIEW</span><span class="si">{</span><span class="s1">' OUTER'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'outer'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.lateral_sql-1364"><a href="#Generator.lateral_sql-1364"><span class="linenos">1364</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">table</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.lateral_sql-1365"><a href="#Generator.lateral_sql-1365"><span class="linenos">1365</span></a> +</span><span id="Generator.lateral_sql-1366"><a href="#Generator.lateral_sql-1366"><span class="linenos">1366</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator.lateral_sql-1367"><a href="#Generator.lateral_sql-1367"><span class="linenos">1367</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.lateral_sql-1368"><a href="#Generator.lateral_sql-1368"><span class="linenos">1368</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LATERAL </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8101,17 +8229,17 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.limit_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.limit_sql-1361"><a href="#Generator.limit_sql-1361"><span class="linenos">1361</span></a> <span class="k">def</span> <span class="nf">limit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.limit_sql-1362"><a href="#Generator.limit_sql-1362"><span class="linenos">1362</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.limit_sql-1363"><a href="#Generator.limit_sql-1363"><span class="linenos">1363</span></a> <span class="n">args</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator.limit_sql-1364"><a href="#Generator.limit_sql-1364"><span class="linenos">1364</span></a> <span class="n">sql</span> -</span><span id="Generator.limit_sql-1365"><a href="#Generator.limit_sql-1365"><span class="linenos">1365</span></a> <span class="k">for</span> <span class="n">sql</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="Generator.limit_sql-1366"><a href="#Generator.limit_sql-1366"><span class="linenos">1366</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> -</span><span id="Generator.limit_sql-1367"><a href="#Generator.limit_sql-1367"><span class="linenos">1367</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">),</span> -</span><span id="Generator.limit_sql-1368"><a href="#Generator.limit_sql-1368"><span class="linenos">1368</span></a> <span class="p">)</span> -</span><span id="Generator.limit_sql-1369"><a href="#Generator.limit_sql-1369"><span class="linenos">1369</span></a> <span class="k">if</span> <span class="n">sql</span> -</span><span id="Generator.limit_sql-1370"><a href="#Generator.limit_sql-1370"><span class="linenos">1370</span></a> <span class="p">)</span> -</span><span id="Generator.limit_sql-1371"><a href="#Generator.limit_sql-1371"><span class="linenos">1371</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'LIMIT'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.limit_sql-1370"><a href="#Generator.limit_sql-1370"><span class="linenos">1370</span></a> <span class="k">def</span> <span class="nf">limit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.limit_sql-1371"><a href="#Generator.limit_sql-1371"><span class="linenos">1371</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.limit_sql-1372"><a href="#Generator.limit_sql-1372"><span class="linenos">1372</span></a> <span class="n">args</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator.limit_sql-1373"><a href="#Generator.limit_sql-1373"><span class="linenos">1373</span></a> <span class="n">sql</span> +</span><span id="Generator.limit_sql-1374"><a href="#Generator.limit_sql-1374"><span class="linenos">1374</span></a> <span class="k">for</span> <span class="n">sql</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="Generator.limit_sql-1375"><a href="#Generator.limit_sql-1375"><span class="linenos">1375</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> +</span><span id="Generator.limit_sql-1376"><a href="#Generator.limit_sql-1376"><span class="linenos">1376</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">),</span> +</span><span id="Generator.limit_sql-1377"><a href="#Generator.limit_sql-1377"><span class="linenos">1377</span></a> <span class="p">)</span> +</span><span id="Generator.limit_sql-1378"><a href="#Generator.limit_sql-1378"><span class="linenos">1378</span></a> <span class="k">if</span> <span class="n">sql</span> +</span><span id="Generator.limit_sql-1379"><a href="#Generator.limit_sql-1379"><span class="linenos">1379</span></a> <span class="p">)</span> +</span><span id="Generator.limit_sql-1380"><a href="#Generator.limit_sql-1380"><span class="linenos">1380</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'LIMIT'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8129,9 +8257,9 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.offset_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.offset_sql-1373"><a href="#Generator.offset_sql-1373"><span class="linenos">1373</span></a> <span class="k">def</span> <span class="nf">offset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Offset</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.offset_sql-1374"><a href="#Generator.offset_sql-1374"><span class="linenos">1374</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.offset_sql-1375"><a href="#Generator.offset_sql-1375"><span class="linenos">1375</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'OFFSET'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.offset_sql-1382"><a href="#Generator.offset_sql-1382"><span class="linenos">1382</span></a> <span class="k">def</span> <span class="nf">offset_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Offset</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.offset_sql-1383"><a href="#Generator.offset_sql-1383"><span class="linenos">1383</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.offset_sql-1384"><a href="#Generator.offset_sql-1384"><span class="linenos">1384</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'OFFSET'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8149,15 +8277,15 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.setitem_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.setitem_sql-1377"><a href="#Generator.setitem_sql-1377"><span class="linenos">1377</span></a> <span class="k">def</span> <span class="nf">setitem_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetItem</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.setitem_sql-1378"><a href="#Generator.setitem_sql-1378"><span class="linenos">1378</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator.setitem_sql-1379"><a href="#Generator.setitem_sql-1379"><span class="linenos">1379</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.setitem_sql-1380"><a href="#Generator.setitem_sql-1380"><span class="linenos">1380</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.setitem_sql-1381"><a href="#Generator.setitem_sql-1381"><span class="linenos">1381</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.setitem_sql-1382"><a href="#Generator.setitem_sql-1382"><span class="linenos">1382</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collate"</span><span class="p">)</span> -</span><span id="Generator.setitem_sql-1383"><a href="#Generator.setitem_sql-1383"><span class="linenos">1383</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collate</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.setitem_sql-1384"><a href="#Generator.setitem_sql-1384"><span class="linenos">1384</span></a> <span class="n">global_</span> <span class="o">=</span> <span class="s2">"GLOBAL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.setitem_sql-1385"><a href="#Generator.setitem_sql-1385"><span class="linenos">1385</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">global_</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.setitem_sql-1386"><a href="#Generator.setitem_sql-1386"><span class="linenos">1386</span></a> <span class="k">def</span> <span class="nf">setitem_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SetItem</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.setitem_sql-1387"><a href="#Generator.setitem_sql-1387"><span class="linenos">1387</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator.setitem_sql-1388"><a href="#Generator.setitem_sql-1388"><span class="linenos">1388</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.setitem_sql-1389"><a href="#Generator.setitem_sql-1389"><span class="linenos">1389</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.setitem_sql-1390"><a href="#Generator.setitem_sql-1390"><span class="linenos">1390</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.setitem_sql-1391"><a href="#Generator.setitem_sql-1391"><span class="linenos">1391</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collate"</span><span class="p">)</span> +</span><span id="Generator.setitem_sql-1392"><a href="#Generator.setitem_sql-1392"><span class="linenos">1392</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collate</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.setitem_sql-1393"><a href="#Generator.setitem_sql-1393"><span class="linenos">1393</span></a> <span class="n">global_</span> <span class="o">=</span> <span class="s2">"GLOBAL "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.setitem_sql-1394"><a href="#Generator.setitem_sql-1394"><span class="linenos">1394</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">global_</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8175,11 +8303,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.set_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.set_sql-1387"><a href="#Generator.set_sql-1387"><span class="linenos">1387</span></a> <span class="k">def</span> <span class="nf">set_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.set_sql-1388"><a href="#Generator.set_sql-1388"><span class="linenos">1388</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.set_sql-1389"><a href="#Generator.set_sql-1389"><span class="linenos">1389</span></a> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.set_sql-1390"><a href="#Generator.set_sql-1390"><span class="linenos">1390</span></a> <span class="p">)</span> -</span><span id="Generator.set_sql-1391"><a href="#Generator.set_sql-1391"><span class="linenos">1391</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SET</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.set_sql-1396"><a href="#Generator.set_sql-1396"><span class="linenos">1396</span></a> <span class="k">def</span> <span class="nf">set_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Set</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.set_sql-1397"><a href="#Generator.set_sql-1397"><span class="linenos">1397</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.set_sql-1398"><a href="#Generator.set_sql-1398"><span class="linenos">1398</span></a> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.set_sql-1399"><a href="#Generator.set_sql-1399"><span class="linenos">1399</span></a> <span class="p">)</span> +</span><span id="Generator.set_sql-1400"><a href="#Generator.set_sql-1400"><span class="linenos">1400</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SET</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8197,8 +8325,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.pragma_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.pragma_sql-1393"><a href="#Generator.pragma_sql-1393"><span class="linenos">1393</span></a> <span class="k">def</span> <span class="nf">pragma_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pragma</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.pragma_sql-1394"><a href="#Generator.pragma_sql-1394"><span class="linenos">1394</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRAGMA </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.pragma_sql-1402"><a href="#Generator.pragma_sql-1402"><span class="linenos">1402</span></a> <span class="k">def</span> <span class="nf">pragma_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Pragma</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.pragma_sql-1403"><a href="#Generator.pragma_sql-1403"><span class="linenos">1403</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRAGMA </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8216,23 +8344,23 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.lock_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lock_sql-1396"><a href="#Generator.lock_sql-1396"><span class="linenos">1396</span></a> <span class="k">def</span> <span class="nf">lock_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lock</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.lock_sql-1397"><a href="#Generator.lock_sql-1397"><span class="linenos">1397</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOCKING_READS_SUPPORTED</span><span class="p">:</span> -</span><span id="Generator.lock_sql-1398"><a href="#Generator.lock_sql-1398"><span class="linenos">1398</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Locking reads using 'FOR UPDATE/SHARE' are not supported"</span><span class="p">)</span> -</span><span id="Generator.lock_sql-1399"><a href="#Generator.lock_sql-1399"><span class="linenos">1399</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator.lock_sql-1400"><a href="#Generator.lock_sql-1400"><span class="linenos">1400</span></a> -</span><span id="Generator.lock_sql-1401"><a href="#Generator.lock_sql-1401"><span class="linenos">1401</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"FOR UPDATE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"update"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"FOR SHARE"</span> -</span><span id="Generator.lock_sql-1402"><a href="#Generator.lock_sql-1402"><span class="linenos">1402</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.lock_sql-1403"><a href="#Generator.lock_sql-1403"><span class="linenos">1403</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OF </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.lock_sql-1404"><a href="#Generator.lock_sql-1404"><span class="linenos">1404</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"wait"</span><span class="p">)</span> -</span><span id="Generator.lock_sql-1405"><a href="#Generator.lock_sql-1405"><span class="linenos">1405</span></a> -</span><span id="Generator.lock_sql-1406"><a href="#Generator.lock_sql-1406"><span class="linenos">1406</span></a> <span class="k">if</span> <span class="n">wait</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.lock_sql-1407"><a href="#Generator.lock_sql-1407"><span class="linenos">1407</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">wait</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> -</span><span id="Generator.lock_sql-1408"><a href="#Generator.lock_sql-1408"><span class="linenos">1408</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WAIT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">wait</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.lock_sql-1409"><a href="#Generator.lock_sql-1409"><span class="linenos">1409</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.lock_sql-1410"><a href="#Generator.lock_sql-1410"><span class="linenos">1410</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="s2">" NOWAIT"</span> <span class="k">if</span> <span class="n">wait</span> <span class="k">else</span> <span class="s2">" SKIP LOCKED"</span> -</span><span id="Generator.lock_sql-1411"><a href="#Generator.lock_sql-1411"><span class="linenos">1411</span></a> -</span><span id="Generator.lock_sql-1412"><a href="#Generator.lock_sql-1412"><span class="linenos">1412</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">wait</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lock_sql-1405"><a href="#Generator.lock_sql-1405"><span class="linenos">1405</span></a> <span class="k">def</span> <span class="nf">lock_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Lock</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.lock_sql-1406"><a href="#Generator.lock_sql-1406"><span class="linenos">1406</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOCKING_READS_SUPPORTED</span><span class="p">:</span> +</span><span id="Generator.lock_sql-1407"><a href="#Generator.lock_sql-1407"><span class="linenos">1407</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Locking reads using 'FOR UPDATE/SHARE' are not supported"</span><span class="p">)</span> +</span><span id="Generator.lock_sql-1408"><a href="#Generator.lock_sql-1408"><span class="linenos">1408</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator.lock_sql-1409"><a href="#Generator.lock_sql-1409"><span class="linenos">1409</span></a> +</span><span id="Generator.lock_sql-1410"><a href="#Generator.lock_sql-1410"><span class="linenos">1410</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"FOR UPDATE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"update"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"FOR SHARE"</span> +</span><span id="Generator.lock_sql-1411"><a href="#Generator.lock_sql-1411"><span class="linenos">1411</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.lock_sql-1412"><a href="#Generator.lock_sql-1412"><span class="linenos">1412</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OF </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.lock_sql-1413"><a href="#Generator.lock_sql-1413"><span class="linenos">1413</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"wait"</span><span class="p">)</span> +</span><span id="Generator.lock_sql-1414"><a href="#Generator.lock_sql-1414"><span class="linenos">1414</span></a> +</span><span id="Generator.lock_sql-1415"><a href="#Generator.lock_sql-1415"><span class="linenos">1415</span></a> <span class="k">if</span> <span class="n">wait</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.lock_sql-1416"><a href="#Generator.lock_sql-1416"><span class="linenos">1416</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">wait</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> +</span><span id="Generator.lock_sql-1417"><a href="#Generator.lock_sql-1417"><span class="linenos">1417</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WAIT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">wait</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.lock_sql-1418"><a href="#Generator.lock_sql-1418"><span class="linenos">1418</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.lock_sql-1419"><a href="#Generator.lock_sql-1419"><span class="linenos">1419</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="s2">" NOWAIT"</span> <span class="k">if</span> <span class="n">wait</span> <span class="k">else</span> <span class="s2">" SKIP LOCKED"</span> +</span><span id="Generator.lock_sql-1420"><a href="#Generator.lock_sql-1420"><span class="linenos">1420</span></a> +</span><span id="Generator.lock_sql-1421"><a href="#Generator.lock_sql-1421"><span class="linenos">1421</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">lock_type</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">wait</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8250,14 +8378,33 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.literal_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.literal_sql-1414"><a href="#Generator.literal_sql-1414"><span class="linenos">1414</span></a> <span class="k">def</span> <span class="nf">literal_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.literal_sql-1415"><a href="#Generator.literal_sql-1415"><span class="linenos">1415</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">or</span> <span class="s2">""</span> -</span><span id="Generator.literal_sql-1416"><a href="#Generator.literal_sql-1416"><span class="linenos">1416</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> -</span><span id="Generator.literal_sql-1417"><a href="#Generator.literal_sql-1417"><span class="linenos">1417</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">)</span> -</span><span id="Generator.literal_sql-1418"><a href="#Generator.literal_sql-1418"><span class="linenos">1418</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="Generator.literal_sql-1419"><a href="#Generator.literal_sql-1419"><span class="linenos">1419</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">)</span> -</span><span id="Generator.literal_sql-1420"><a href="#Generator.literal_sql-1420"><span class="linenos">1420</span></a> <span class="n">text</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="n">text</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.literal_sql-1421"><a href="#Generator.literal_sql-1421"><span class="linenos">1421</span></a> <span class="k">return</span> <span class="n">text</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.literal_sql-1423"><a href="#Generator.literal_sql-1423"><span class="linenos">1423</span></a> <span class="k">def</span> <span class="nf">literal_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.literal_sql-1424"><a href="#Generator.literal_sql-1424"><span class="linenos">1424</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="ow">or</span> <span class="s2">""</span> +</span><span id="Generator.literal_sql-1425"><a href="#Generator.literal_sql-1425"><span class="linenos">1425</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> +</span><span id="Generator.literal_sql-1426"><a href="#Generator.literal_sql-1426"><span class="linenos">1426</span></a> <span class="n">text</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_START</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">escape_str</span><span class="p">(</span><span class="n">text</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.literal_sql-1427"><a href="#Generator.literal_sql-1427"><span class="linenos">1427</span></a> <span class="k">return</span> <span class="n">text</span> +</span></pre></div> + + + + + </div> + <div id="Generator.escape_str" class="classattr"> + <input id="Generator.escape_str-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + + <span class="def">def</span> + <span class="name">escape_str</span><span class="signature pdoc-code condensed">(<span class="param"><span class="bp">self</span>, </span><span class="param"><span class="n">text</span><span class="p">:</span> <span class="nb">str</span></span><span class="return-annotation">) -> <span class="nb">str</span>:</span></span> + + <label class="view-source-button" for="Generator.escape_str-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Generator.escape_str"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.escape_str-1429"><a href="#Generator.escape_str-1429"><span class="linenos">1429</span></a> <span class="k">def</span> <span class="nf">escape_str</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.escape_str-1430"><a href="#Generator.escape_str-1430"><span class="linenos">1430</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">QUOTE_END</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_escaped_quote_end</span><span class="p">)</span> +</span><span id="Generator.escape_str-1431"><a href="#Generator.escape_str-1431"><span class="linenos">1431</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="Generator.escape_str-1432"><a href="#Generator.escape_str-1432"><span class="linenos">1432</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SENTINEL_LINE_BREAK</span><span class="p">)</span> +</span><span id="Generator.escape_str-1433"><a href="#Generator.escape_str-1433"><span class="linenos">1433</span></a> <span class="k">return</span> <span class="n">text</span> </span></pre></div> @@ -8275,18 +8422,18 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.loaddata_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.loaddata_sql-1423"><a href="#Generator.loaddata_sql-1423"><span class="linenos">1423</span></a> <span class="k">def</span> <span class="nf">loaddata_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LoadData</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.loaddata_sql-1424"><a href="#Generator.loaddata_sql-1424"><span class="linenos">1424</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">" LOCAL"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.loaddata_sql-1425"><a href="#Generator.loaddata_sql-1425"><span class="linenos">1425</span></a> <span class="n">inpath</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPATH </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'inpath'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.loaddata_sql-1426"><a href="#Generator.loaddata_sql-1426"><span class="linenos">1426</span></a> <span class="n">overwrite</span> <span class="o">=</span> <span class="s2">" OVERWRITE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"overwrite"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.loaddata_sql-1427"><a href="#Generator.loaddata_sql-1427"><span class="linenos">1427</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INTO TABLE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.loaddata_sql-1428"><a href="#Generator.loaddata_sql-1428"><span class="linenos">1428</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"partition"</span><span class="p">)</span> -</span><span id="Generator.loaddata_sql-1429"><a href="#Generator.loaddata_sql-1429"><span class="linenos">1429</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.loaddata_sql-1430"><a href="#Generator.loaddata_sql-1430"><span class="linenos">1430</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> -</span><span id="Generator.loaddata_sql-1431"><a href="#Generator.loaddata_sql-1431"><span class="linenos">1431</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.loaddata_sql-1432"><a href="#Generator.loaddata_sql-1432"><span class="linenos">1432</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"serde"</span><span class="p">)</span> -</span><span id="Generator.loaddata_sql-1433"><a href="#Generator.loaddata_sql-1433"><span class="linenos">1433</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" SERDE </span><span class="si">{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">serde</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.loaddata_sql-1434"><a href="#Generator.loaddata_sql-1434"><span class="linenos">1434</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOAD DATA</span><span class="si">{</span><span class="n">local</span><span class="si">}{</span><span class="n">inpath</span><span class="si">}{</span><span class="n">overwrite</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">partition</span><span class="si">}{</span><span class="n">input_format</span><span class="si">}{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.loaddata_sql-1435"><a href="#Generator.loaddata_sql-1435"><span class="linenos">1435</span></a> <span class="k">def</span> <span class="nf">loaddata_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LoadData</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.loaddata_sql-1436"><a href="#Generator.loaddata_sql-1436"><span class="linenos">1436</span></a> <span class="n">local</span> <span class="o">=</span> <span class="s2">" LOCAL"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"local"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.loaddata_sql-1437"><a href="#Generator.loaddata_sql-1437"><span class="linenos">1437</span></a> <span class="n">inpath</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPATH </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'inpath'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.loaddata_sql-1438"><a href="#Generator.loaddata_sql-1438"><span class="linenos">1438</span></a> <span class="n">overwrite</span> <span class="o">=</span> <span class="s2">" OVERWRITE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"overwrite"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.loaddata_sql-1439"><a href="#Generator.loaddata_sql-1439"><span class="linenos">1439</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INTO TABLE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.loaddata_sql-1440"><a href="#Generator.loaddata_sql-1440"><span class="linenos">1440</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"partition"</span><span class="p">)</span> +</span><span id="Generator.loaddata_sql-1441"><a href="#Generator.loaddata_sql-1441"><span class="linenos">1441</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.loaddata_sql-1442"><a href="#Generator.loaddata_sql-1442"><span class="linenos">1442</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"input_format"</span><span class="p">)</span> +</span><span id="Generator.loaddata_sql-1443"><a href="#Generator.loaddata_sql-1443"><span class="linenos">1443</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" INPUTFORMAT </span><span class="si">{</span><span class="n">input_format</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">input_format</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.loaddata_sql-1444"><a href="#Generator.loaddata_sql-1444"><span class="linenos">1444</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"serde"</span><span class="p">)</span> +</span><span id="Generator.loaddata_sql-1445"><a href="#Generator.loaddata_sql-1445"><span class="linenos">1445</span></a> <span class="n">serde</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" SERDE </span><span class="si">{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">serde</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.loaddata_sql-1446"><a href="#Generator.loaddata_sql-1446"><span class="linenos">1446</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"LOAD DATA</span><span class="si">{</span><span class="n">local</span><span class="si">}{</span><span class="n">inpath</span><span class="si">}{</span><span class="n">overwrite</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">partition</span><span class="si">}{</span><span class="n">input_format</span><span class="si">}{</span><span class="n">serde</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8304,8 +8451,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.null_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.null_sql-1436"><a href="#Generator.null_sql-1436"><span class="linenos">1436</span></a> <span class="k">def</span> <span class="nf">null_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.null_sql-1437"><a href="#Generator.null_sql-1437"><span class="linenos">1437</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.null_sql-1448"><a href="#Generator.null_sql-1448"><span class="linenos">1448</span></a> <span class="k">def</span> <span class="nf">null_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.null_sql-1449"><a href="#Generator.null_sql-1449"><span class="linenos">1449</span></a> <span class="k">return</span> <span class="s2">"NULL"</span> </span></pre></div> @@ -8323,8 +8470,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.boolean_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.boolean_sql-1439"><a href="#Generator.boolean_sql-1439"><span class="linenos">1439</span></a> <span class="k">def</span> <span class="nf">boolean_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Boolean</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.boolean_sql-1440"><a href="#Generator.boolean_sql-1440"><span class="linenos">1440</span></a> <span class="k">return</span> <span class="s2">"TRUE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">"FALSE"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.boolean_sql-1451"><a href="#Generator.boolean_sql-1451"><span class="linenos">1451</span></a> <span class="k">def</span> <span class="nf">boolean_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Boolean</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.boolean_sql-1452"><a href="#Generator.boolean_sql-1452"><span class="linenos">1452</span></a> <span class="k">return</span> <span class="s2">"TRUE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">"FALSE"</span> </span></pre></div> @@ -8342,10 +8489,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.order_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.order_sql-1442"><a href="#Generator.order_sql-1442"><span class="linenos">1442</span></a> <span class="k">def</span> <span class="nf">order_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">,</span> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.order_sql-1443"><a href="#Generator.order_sql-1443"><span class="linenos">1443</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.order_sql-1444"><a href="#Generator.order_sql-1444"><span class="linenos">1444</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="n">this</span> -</span><span id="Generator.order_sql-1445"><a href="#Generator.order_sql-1445"><span class="linenos">1445</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">ORDER BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="n">this</span> <span class="ow">or</span> <span class="n">flat</span><span class="p">)</span> <span class="c1"># type: ignore</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.order_sql-1454"><a href="#Generator.order_sql-1454"><span class="linenos">1454</span></a> <span class="k">def</span> <span class="nf">order_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">,</span> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.order_sql-1455"><a href="#Generator.order_sql-1455"><span class="linenos">1455</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.order_sql-1456"><a href="#Generator.order_sql-1456"><span class="linenos">1456</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="n">this</span> +</span><span id="Generator.order_sql-1457"><a href="#Generator.order_sql-1457"><span class="linenos">1457</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">ORDER BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="n">this</span> <span class="ow">or</span> <span class="n">flat</span><span class="p">)</span> <span class="c1"># type: ignore</span> </span></pre></div> @@ -8363,8 +8510,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.cluster_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.cluster_sql-1447"><a href="#Generator.cluster_sql-1447"><span class="linenos">1447</span></a> <span class="k">def</span> <span class="nf">cluster_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.cluster_sql-1448"><a href="#Generator.cluster_sql-1448"><span class="linenos">1448</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"CLUSTER BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.cluster_sql-1459"><a href="#Generator.cluster_sql-1459"><span class="linenos">1459</span></a> <span class="k">def</span> <span class="nf">cluster_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.cluster_sql-1460"><a href="#Generator.cluster_sql-1460"><span class="linenos">1460</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"CLUSTER BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -8382,8 +8529,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.distribute_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.distribute_sql-1450"><a href="#Generator.distribute_sql-1450"><span class="linenos">1450</span></a> <span class="k">def</span> <span class="nf">distribute_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distribute</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.distribute_sql-1451"><a href="#Generator.distribute_sql-1451"><span class="linenos">1451</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"DISTRIBUTE BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.distribute_sql-1462"><a href="#Generator.distribute_sql-1462"><span class="linenos">1462</span></a> <span class="k">def</span> <span class="nf">distribute_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distribute</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.distribute_sql-1463"><a href="#Generator.distribute_sql-1463"><span class="linenos">1463</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"DISTRIBUTE BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -8401,8 +8548,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.sort_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sort_sql-1453"><a href="#Generator.sort_sql-1453"><span class="linenos">1453</span></a> <span class="k">def</span> <span class="nf">sort_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.sort_sql-1454"><a href="#Generator.sort_sql-1454"><span class="linenos">1454</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"SORT BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sort_sql-1465"><a href="#Generator.sort_sql-1465"><span class="linenos">1465</span></a> <span class="k">def</span> <span class="nf">sort_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.sort_sql-1466"><a href="#Generator.sort_sql-1466"><span class="linenos">1466</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">op_expressions</span><span class="p">(</span><span class="s2">"SORT BY"</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -8420,36 +8567,36 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.ordered_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.ordered_sql-1456"><a href="#Generator.ordered_sql-1456"><span class="linenos">1456</span></a> <span class="k">def</span> <span class="nf">ordered_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.ordered_sql-1457"><a href="#Generator.ordered_sql-1457"><span class="linenos">1457</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"desc"</span><span class="p">)</span> -</span><span id="Generator.ordered_sql-1458"><a href="#Generator.ordered_sql-1458"><span class="linenos">1458</span></a> <span class="n">asc</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">desc</span> -</span><span id="Generator.ordered_sql-1459"><a href="#Generator.ordered_sql-1459"><span class="linenos">1459</span></a> -</span><span id="Generator.ordered_sql-1460"><a href="#Generator.ordered_sql-1460"><span class="linenos">1460</span></a> <span class="n">nulls_first</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nulls_first"</span><span class="p">)</span> -</span><span id="Generator.ordered_sql-1461"><a href="#Generator.ordered_sql-1461"><span class="linenos">1461</span></a> <span class="n">nulls_last</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">nulls_first</span> -</span><span id="Generator.ordered_sql-1462"><a href="#Generator.ordered_sql-1462"><span class="linenos">1462</span></a> <span class="n">nulls_are_large</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_large"</span> -</span><span id="Generator.ordered_sql-1463"><a href="#Generator.ordered_sql-1463"><span class="linenos">1463</span></a> <span class="n">nulls_are_small</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_small"</span> -</span><span id="Generator.ordered_sql-1464"><a href="#Generator.ordered_sql-1464"><span class="linenos">1464</span></a> <span class="n">nulls_are_last</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_last"</span> -</span><span id="Generator.ordered_sql-1465"><a href="#Generator.ordered_sql-1465"><span class="linenos">1465</span></a> -</span><span id="Generator.ordered_sql-1466"><a href="#Generator.ordered_sql-1466"><span class="linenos">1466</span></a> <span class="n">sort_order</span> <span class="o">=</span> <span class="s2">" DESC"</span> <span class="k">if</span> <span class="n">desc</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.ordered_sql-1467"><a href="#Generator.ordered_sql-1467"><span class="linenos">1467</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.ordered_sql-1468"><a href="#Generator.ordered_sql-1468"><span class="linenos">1468</span></a> <span class="k">if</span> <span class="n">nulls_first</span> <span class="ow">and</span> <span class="p">(</span> -</span><span id="Generator.ordered_sql-1469"><a href="#Generator.ordered_sql-1469"><span class="linenos">1469</span></a> <span class="p">(</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="n">nulls_are_last</span> -</span><span id="Generator.ordered_sql-1470"><a href="#Generator.ordered_sql-1470"><span class="linenos">1470</span></a> <span class="p">):</span> -</span><span id="Generator.ordered_sql-1471"><a href="#Generator.ordered_sql-1471"><span class="linenos">1471</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS FIRST"</span> -</span><span id="Generator.ordered_sql-1472"><a href="#Generator.ordered_sql-1472"><span class="linenos">1472</span></a> <span class="k">elif</span> <span class="p">(</span> -</span><span id="Generator.ordered_sql-1473"><a href="#Generator.ordered_sql-1473"><span class="linenos">1473</span></a> <span class="n">nulls_last</span> -</span><span id="Generator.ordered_sql-1474"><a href="#Generator.ordered_sql-1474"><span class="linenos">1474</span></a> <span class="ow">and</span> <span class="p">((</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">))</span> -</span><span id="Generator.ordered_sql-1475"><a href="#Generator.ordered_sql-1475"><span class="linenos">1475</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">nulls_are_last</span> -</span><span id="Generator.ordered_sql-1476"><a href="#Generator.ordered_sql-1476"><span class="linenos">1476</span></a> <span class="p">):</span> -</span><span id="Generator.ordered_sql-1477"><a href="#Generator.ordered_sql-1477"><span class="linenos">1477</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS LAST"</span> -</span><span id="Generator.ordered_sql-1478"><a href="#Generator.ordered_sql-1478"><span class="linenos">1478</span></a> -</span><span id="Generator.ordered_sql-1479"><a href="#Generator.ordered_sql-1479"><span class="linenos">1479</span></a> <span class="k">if</span> <span class="n">nulls_sort_change</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING_SUPPORTED</span><span class="p">:</span> -</span><span id="Generator.ordered_sql-1480"><a href="#Generator.ordered_sql-1480"><span class="linenos">1480</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span> -</span><span id="Generator.ordered_sql-1481"><a href="#Generator.ordered_sql-1481"><span class="linenos">1481</span></a> <span class="s2">"Sorting in an ORDER BY on NULLS FIRST/NULLS LAST is not supported by this dialect"</span> -</span><span id="Generator.ordered_sql-1482"><a href="#Generator.ordered_sql-1482"><span class="linenos">1482</span></a> <span class="p">)</span> -</span><span id="Generator.ordered_sql-1483"><a href="#Generator.ordered_sql-1483"><span class="linenos">1483</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.ordered_sql-1484"><a href="#Generator.ordered_sql-1484"><span class="linenos">1484</span></a> -</span><span id="Generator.ordered_sql-1485"><a href="#Generator.ordered_sql-1485"><span class="linenos">1485</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">sort_order</span><span class="si">}{</span><span class="n">nulls_sort_change</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.ordered_sql-1468"><a href="#Generator.ordered_sql-1468"><span class="linenos">1468</span></a> <span class="k">def</span> <span class="nf">ordered_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.ordered_sql-1469"><a href="#Generator.ordered_sql-1469"><span class="linenos">1469</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"desc"</span><span class="p">)</span> +</span><span id="Generator.ordered_sql-1470"><a href="#Generator.ordered_sql-1470"><span class="linenos">1470</span></a> <span class="n">asc</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">desc</span> +</span><span id="Generator.ordered_sql-1471"><a href="#Generator.ordered_sql-1471"><span class="linenos">1471</span></a> +</span><span id="Generator.ordered_sql-1472"><a href="#Generator.ordered_sql-1472"><span class="linenos">1472</span></a> <span class="n">nulls_first</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nulls_first"</span><span class="p">)</span> +</span><span id="Generator.ordered_sql-1473"><a href="#Generator.ordered_sql-1473"><span class="linenos">1473</span></a> <span class="n">nulls_last</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">nulls_first</span> +</span><span id="Generator.ordered_sql-1474"><a href="#Generator.ordered_sql-1474"><span class="linenos">1474</span></a> <span class="n">nulls_are_large</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_large"</span> +</span><span id="Generator.ordered_sql-1475"><a href="#Generator.ordered_sql-1475"><span class="linenos">1475</span></a> <span class="n">nulls_are_small</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_small"</span> +</span><span id="Generator.ordered_sql-1476"><a href="#Generator.ordered_sql-1476"><span class="linenos">1476</span></a> <span class="n">nulls_are_last</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_last"</span> +</span><span id="Generator.ordered_sql-1477"><a href="#Generator.ordered_sql-1477"><span class="linenos">1477</span></a> +</span><span id="Generator.ordered_sql-1478"><a href="#Generator.ordered_sql-1478"><span class="linenos">1478</span></a> <span class="n">sort_order</span> <span class="o">=</span> <span class="s2">" DESC"</span> <span class="k">if</span> <span class="n">desc</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.ordered_sql-1479"><a href="#Generator.ordered_sql-1479"><span class="linenos">1479</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.ordered_sql-1480"><a href="#Generator.ordered_sql-1480"><span class="linenos">1480</span></a> <span class="k">if</span> <span class="n">nulls_first</span> <span class="ow">and</span> <span class="p">(</span> +</span><span id="Generator.ordered_sql-1481"><a href="#Generator.ordered_sql-1481"><span class="linenos">1481</span></a> <span class="p">(</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="n">nulls_are_last</span> +</span><span id="Generator.ordered_sql-1482"><a href="#Generator.ordered_sql-1482"><span class="linenos">1482</span></a> <span class="p">):</span> +</span><span id="Generator.ordered_sql-1483"><a href="#Generator.ordered_sql-1483"><span class="linenos">1483</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS FIRST"</span> +</span><span id="Generator.ordered_sql-1484"><a href="#Generator.ordered_sql-1484"><span class="linenos">1484</span></a> <span class="k">elif</span> <span class="p">(</span> +</span><span id="Generator.ordered_sql-1485"><a href="#Generator.ordered_sql-1485"><span class="linenos">1485</span></a> <span class="n">nulls_last</span> +</span><span id="Generator.ordered_sql-1486"><a href="#Generator.ordered_sql-1486"><span class="linenos">1486</span></a> <span class="ow">and</span> <span class="p">((</span><span class="n">asc</span> <span class="ow">and</span> <span class="n">nulls_are_small</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="n">nulls_are_large</span><span class="p">))</span> +</span><span id="Generator.ordered_sql-1487"><a href="#Generator.ordered_sql-1487"><span class="linenos">1487</span></a> <span class="ow">and</span> <span class="ow">not</span> <span class="n">nulls_are_last</span> +</span><span id="Generator.ordered_sql-1488"><a href="#Generator.ordered_sql-1488"><span class="linenos">1488</span></a> <span class="p">):</span> +</span><span id="Generator.ordered_sql-1489"><a href="#Generator.ordered_sql-1489"><span class="linenos">1489</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">" NULLS LAST"</span> +</span><span id="Generator.ordered_sql-1490"><a href="#Generator.ordered_sql-1490"><span class="linenos">1490</span></a> +</span><span id="Generator.ordered_sql-1491"><a href="#Generator.ordered_sql-1491"><span class="linenos">1491</span></a> <span class="k">if</span> <span class="n">nulls_sort_change</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING_SUPPORTED</span><span class="p">:</span> +</span><span id="Generator.ordered_sql-1492"><a href="#Generator.ordered_sql-1492"><span class="linenos">1492</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span> +</span><span id="Generator.ordered_sql-1493"><a href="#Generator.ordered_sql-1493"><span class="linenos">1493</span></a> <span class="s2">"Sorting in an ORDER BY on NULLS FIRST/NULLS LAST is not supported by this dialect"</span> +</span><span id="Generator.ordered_sql-1494"><a href="#Generator.ordered_sql-1494"><span class="linenos">1494</span></a> <span class="p">)</span> +</span><span id="Generator.ordered_sql-1495"><a href="#Generator.ordered_sql-1495"><span class="linenos">1495</span></a> <span class="n">nulls_sort_change</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.ordered_sql-1496"><a href="#Generator.ordered_sql-1496"><span class="linenos">1496</span></a> +</span><span id="Generator.ordered_sql-1497"><a href="#Generator.ordered_sql-1497"><span class="linenos">1497</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">sort_order</span><span class="si">}{</span><span class="n">nulls_sort_change</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8467,37 +8614,37 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.matchrecognize_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.matchrecognize_sql-1487"><a href="#Generator.matchrecognize_sql-1487"><span class="linenos">1487</span></a> <span class="k">def</span> <span class="nf">matchrecognize_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.matchrecognize_sql-1488"><a href="#Generator.matchrecognize_sql-1488"><span class="linenos">1488</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.matchrecognize_sql-1489"><a href="#Generator.matchrecognize_sql-1489"><span class="linenos">1489</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> -</span><span id="Generator.matchrecognize_sql-1490"><a href="#Generator.matchrecognize_sql-1490"><span class="linenos">1490</span></a> <span class="n">measures</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"measures"</span><span class="p">)</span> -</span><span id="Generator.matchrecognize_sql-1491"><a href="#Generator.matchrecognize_sql-1491"><span class="linenos">1491</span></a> <span class="n">measures</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"MEASURES</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">measures</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">measures</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.matchrecognize_sql-1492"><a href="#Generator.matchrecognize_sql-1492"><span class="linenos">1492</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> -</span><span id="Generator.matchrecognize_sql-1493"><a href="#Generator.matchrecognize_sql-1493"><span class="linenos">1493</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">rows</span><span class="p">)</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.matchrecognize_sql-1494"><a href="#Generator.matchrecognize_sql-1494"><span class="linenos">1494</span></a> <span class="n">after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"after"</span><span class="p">)</span> -</span><span id="Generator.matchrecognize_sql-1495"><a href="#Generator.matchrecognize_sql-1495"><span class="linenos">1495</span></a> <span class="n">after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">after</span><span class="p">)</span> <span class="k">if</span> <span class="n">after</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.matchrecognize_sql-1496"><a href="#Generator.matchrecognize_sql-1496"><span class="linenos">1496</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"pattern"</span><span class="p">)</span> -</span><span id="Generator.matchrecognize_sql-1497"><a href="#Generator.matchrecognize_sql-1497"><span class="linenos">1497</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"PATTERN (</span><span class="si">{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">)"</span><span class="p">)</span> <span class="k">if</span> <span class="n">pattern</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.matchrecognize_sql-1498"><a href="#Generator.matchrecognize_sql-1498"><span class="linenos">1498</span></a> <span class="n">definition_sqls</span> <span class="o">=</span> <span class="p">[</span> -</span><span id="Generator.matchrecognize_sql-1499"><a href="#Generator.matchrecognize_sql-1499"><span class="linenos">1499</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">definition</span><span class="p">,</span><span class="w"> </span><span class="s1">'alias'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">definition</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.matchrecognize_sql-1500"><a href="#Generator.matchrecognize_sql-1500"><span class="linenos">1500</span></a> <span class="k">for</span> <span class="n">definition</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"define"</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="Generator.matchrecognize_sql-1501"><a href="#Generator.matchrecognize_sql-1501"><span class="linenos">1501</span></a> <span class="p">]</span> -</span><span id="Generator.matchrecognize_sql-1502"><a href="#Generator.matchrecognize_sql-1502"><span class="linenos">1502</span></a> <span class="n">definitions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">sqls</span><span class="o">=</span><span class="n">definition_sqls</span><span class="p">)</span> -</span><span id="Generator.matchrecognize_sql-1503"><a href="#Generator.matchrecognize_sql-1503"><span class="linenos">1503</span></a> <span class="n">define</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"DEFINE</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">definitions</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">definitions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.matchrecognize_sql-1504"><a href="#Generator.matchrecognize_sql-1504"><span class="linenos">1504</span></a> <span class="n">body</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> -</span><span id="Generator.matchrecognize_sql-1505"><a href="#Generator.matchrecognize_sql-1505"><span class="linenos">1505</span></a> <span class="p">(</span> -</span><span id="Generator.matchrecognize_sql-1506"><a href="#Generator.matchrecognize_sql-1506"><span class="linenos">1506</span></a> <span class="n">partition</span><span class="p">,</span> -</span><span id="Generator.matchrecognize_sql-1507"><a href="#Generator.matchrecognize_sql-1507"><span class="linenos">1507</span></a> <span class="n">order</span><span class="p">,</span> -</span><span id="Generator.matchrecognize_sql-1508"><a href="#Generator.matchrecognize_sql-1508"><span class="linenos">1508</span></a> <span class="n">measures</span><span class="p">,</span> -</span><span id="Generator.matchrecognize_sql-1509"><a href="#Generator.matchrecognize_sql-1509"><span class="linenos">1509</span></a> <span class="n">rows</span><span class="p">,</span> -</span><span id="Generator.matchrecognize_sql-1510"><a href="#Generator.matchrecognize_sql-1510"><span class="linenos">1510</span></a> <span class="n">after</span><span class="p">,</span> -</span><span id="Generator.matchrecognize_sql-1511"><a href="#Generator.matchrecognize_sql-1511"><span class="linenos">1511</span></a> <span class="n">pattern</span><span class="p">,</span> -</span><span id="Generator.matchrecognize_sql-1512"><a href="#Generator.matchrecognize_sql-1512"><span class="linenos">1512</span></a> <span class="n">define</span><span class="p">,</span> -</span><span id="Generator.matchrecognize_sql-1513"><a href="#Generator.matchrecognize_sql-1513"><span class="linenos">1513</span></a> <span class="p">)</span> -</span><span id="Generator.matchrecognize_sql-1514"><a href="#Generator.matchrecognize_sql-1514"><span class="linenos">1514</span></a> <span class="p">)</span> -</span><span id="Generator.matchrecognize_sql-1515"><a href="#Generator.matchrecognize_sql-1515"><span class="linenos">1515</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator.matchrecognize_sql-1516"><a href="#Generator.matchrecognize_sql-1516"><span class="linenos">1516</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.matchrecognize_sql-1517"><a href="#Generator.matchrecognize_sql-1517"><span class="linenos">1517</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'MATCH_RECOGNIZE'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">body</span><span class="p">)</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.matchrecognize_sql-1499"><a href="#Generator.matchrecognize_sql-1499"><span class="linenos">1499</span></a> <span class="k">def</span> <span class="nf">matchrecognize_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.matchrecognize_sql-1500"><a href="#Generator.matchrecognize_sql-1500"><span class="linenos">1500</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.matchrecognize_sql-1501"><a href="#Generator.matchrecognize_sql-1501"><span class="linenos">1501</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">)</span> +</span><span id="Generator.matchrecognize_sql-1502"><a href="#Generator.matchrecognize_sql-1502"><span class="linenos">1502</span></a> <span class="n">measures</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"measures"</span><span class="p">)</span> +</span><span id="Generator.matchrecognize_sql-1503"><a href="#Generator.matchrecognize_sql-1503"><span class="linenos">1503</span></a> <span class="n">measures</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"MEASURES</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">measures</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">measures</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.matchrecognize_sql-1504"><a href="#Generator.matchrecognize_sql-1504"><span class="linenos">1504</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"rows"</span><span class="p">)</span> +</span><span id="Generator.matchrecognize_sql-1505"><a href="#Generator.matchrecognize_sql-1505"><span class="linenos">1505</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">rows</span><span class="p">)</span> <span class="k">if</span> <span class="n">rows</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.matchrecognize_sql-1506"><a href="#Generator.matchrecognize_sql-1506"><span class="linenos">1506</span></a> <span class="n">after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"after"</span><span class="p">)</span> +</span><span id="Generator.matchrecognize_sql-1507"><a href="#Generator.matchrecognize_sql-1507"><span class="linenos">1507</span></a> <span class="n">after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">after</span><span class="p">)</span> <span class="k">if</span> <span class="n">after</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.matchrecognize_sql-1508"><a href="#Generator.matchrecognize_sql-1508"><span class="linenos">1508</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"pattern"</span><span class="p">)</span> +</span><span id="Generator.matchrecognize_sql-1509"><a href="#Generator.matchrecognize_sql-1509"><span class="linenos">1509</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"PATTERN (</span><span class="si">{</span><span class="n">pattern</span><span class="si">}</span><span class="s2">)"</span><span class="p">)</span> <span class="k">if</span> <span class="n">pattern</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.matchrecognize_sql-1510"><a href="#Generator.matchrecognize_sql-1510"><span class="linenos">1510</span></a> <span class="n">definition_sqls</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="Generator.matchrecognize_sql-1511"><a href="#Generator.matchrecognize_sql-1511"><span class="linenos">1511</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">definition</span><span class="p">,</span><span class="w"> </span><span class="s1">'alias'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">definition</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.matchrecognize_sql-1512"><a href="#Generator.matchrecognize_sql-1512"><span class="linenos">1512</span></a> <span class="k">for</span> <span class="n">definition</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"define"</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="Generator.matchrecognize_sql-1513"><a href="#Generator.matchrecognize_sql-1513"><span class="linenos">1513</span></a> <span class="p">]</span> +</span><span id="Generator.matchrecognize_sql-1514"><a href="#Generator.matchrecognize_sql-1514"><span class="linenos">1514</span></a> <span class="n">definitions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">sqls</span><span class="o">=</span><span class="n">definition_sqls</span><span class="p">)</span> +</span><span id="Generator.matchrecognize_sql-1515"><a href="#Generator.matchrecognize_sql-1515"><span class="linenos">1515</span></a> <span class="n">define</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="sa">f</span><span class="s2">"DEFINE</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">definitions</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> <span class="k">if</span> <span class="n">definitions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.matchrecognize_sql-1516"><a href="#Generator.matchrecognize_sql-1516"><span class="linenos">1516</span></a> <span class="n">body</span> <span class="o">=</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span> +</span><span id="Generator.matchrecognize_sql-1517"><a href="#Generator.matchrecognize_sql-1517"><span class="linenos">1517</span></a> <span class="p">(</span> +</span><span id="Generator.matchrecognize_sql-1518"><a href="#Generator.matchrecognize_sql-1518"><span class="linenos">1518</span></a> <span class="n">partition</span><span class="p">,</span> +</span><span id="Generator.matchrecognize_sql-1519"><a href="#Generator.matchrecognize_sql-1519"><span class="linenos">1519</span></a> <span class="n">order</span><span class="p">,</span> +</span><span id="Generator.matchrecognize_sql-1520"><a href="#Generator.matchrecognize_sql-1520"><span class="linenos">1520</span></a> <span class="n">measures</span><span class="p">,</span> +</span><span id="Generator.matchrecognize_sql-1521"><a href="#Generator.matchrecognize_sql-1521"><span class="linenos">1521</span></a> <span class="n">rows</span><span class="p">,</span> +</span><span id="Generator.matchrecognize_sql-1522"><a href="#Generator.matchrecognize_sql-1522"><span class="linenos">1522</span></a> <span class="n">after</span><span class="p">,</span> +</span><span id="Generator.matchrecognize_sql-1523"><a href="#Generator.matchrecognize_sql-1523"><span class="linenos">1523</span></a> <span class="n">pattern</span><span class="p">,</span> +</span><span id="Generator.matchrecognize_sql-1524"><a href="#Generator.matchrecognize_sql-1524"><span class="linenos">1524</span></a> <span class="n">define</span><span class="p">,</span> +</span><span id="Generator.matchrecognize_sql-1525"><a href="#Generator.matchrecognize_sql-1525"><span class="linenos">1525</span></a> <span class="p">)</span> +</span><span id="Generator.matchrecognize_sql-1526"><a href="#Generator.matchrecognize_sql-1526"><span class="linenos">1526</span></a> <span class="p">)</span> +</span><span id="Generator.matchrecognize_sql-1527"><a href="#Generator.matchrecognize_sql-1527"><span class="linenos">1527</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator.matchrecognize_sql-1528"><a href="#Generator.matchrecognize_sql-1528"><span class="linenos">1528</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.matchrecognize_sql-1529"><a href="#Generator.matchrecognize_sql-1529"><span class="linenos">1529</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'MATCH_RECOGNIZE'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">body</span><span class="p">)</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8515,30 +8662,30 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.query_modifiers"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.query_modifiers-1519"><a href="#Generator.query_modifiers-1519"><span class="linenos">1519</span></a> <span class="k">def</span> <span class="nf">query_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="o">*</span><span class="n">sqls</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.query_modifiers-1520"><a href="#Generator.query_modifiers-1520"><span class="linenos">1520</span></a> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"limit"</span><span class="p">)</span> -</span><span id="Generator.query_modifiers-1521"><a href="#Generator.query_modifiers-1521"><span class="linenos">1521</span></a> -</span><span id="Generator.query_modifiers-1522"><a href="#Generator.query_modifiers-1522"><span class="linenos">1522</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"LIMIT"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">):</span> -</span><span id="Generator.query_modifiers-1523"><a href="#Generator.query_modifiers-1523"><span class="linenos">1523</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">limit</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"count"</span><span class="p">))</span> -</span><span id="Generator.query_modifiers-1524"><a href="#Generator.query_modifiers-1524"><span class="linenos">1524</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"FETCH"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">):</span> -</span><span id="Generator.query_modifiers-1525"><a href="#Generator.query_modifiers-1525"><span class="linenos">1525</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">(</span><span class="n">direction</span><span class="o">=</span><span class="s2">"FIRST"</span><span class="p">,</span> <span class="n">count</span><span class="o">=</span><span class="n">limit</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.query_modifiers-1526"><a href="#Generator.query_modifiers-1526"><span class="linenos">1526</span></a> -</span><span id="Generator.query_modifiers-1527"><a href="#Generator.query_modifiers-1527"><span class="linenos">1527</span></a> <span class="n">fetch</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> -</span><span id="Generator.query_modifiers-1528"><a href="#Generator.query_modifiers-1528"><span class="linenos">1528</span></a> -</span><span id="Generator.query_modifiers-1529"><a href="#Generator.query_modifiers-1529"><span class="linenos">1529</span></a> <span class="k">return</span> <span class="n">csv</span><span class="p">(</span> -</span><span id="Generator.query_modifiers-1530"><a href="#Generator.query_modifiers-1530"><span class="linenos">1530</span></a> <span class="o">*</span><span class="n">sqls</span><span class="p">,</span> -</span><span id="Generator.query_modifiers-1531"><a href="#Generator.query_modifiers-1531"><span class="linenos">1531</span></a> <span class="o">*</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">join</span><span class="p">)</span> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> -</span><span id="Generator.query_modifiers-1532"><a href="#Generator.query_modifiers-1532"><span class="linenos">1532</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"match"</span><span class="p">),</span> -</span><span id="Generator.query_modifiers-1533"><a href="#Generator.query_modifiers-1533"><span class="linenos">1533</span></a> <span class="o">*</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">lateral</span><span class="p">)</span> <span class="k">for</span> <span class="n">lateral</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"laterals"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> -</span><span id="Generator.query_modifiers-1534"><a href="#Generator.query_modifiers-1534"><span class="linenos">1534</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">),</span> -</span><span id="Generator.query_modifiers-1535"><a href="#Generator.query_modifiers-1535"><span class="linenos">1535</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">),</span> -</span><span id="Generator.query_modifiers-1536"><a href="#Generator.query_modifiers-1536"><span class="linenos">1536</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"having"</span><span class="p">),</span> -</span><span id="Generator.query_modifiers-1537"><a href="#Generator.query_modifiers-1537"><span class="linenos">1537</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> -</span><span id="Generator.query_modifiers-1538"><a href="#Generator.query_modifiers-1538"><span class="linenos">1538</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">),</span> -</span><span id="Generator.query_modifiers-1539"><a href="#Generator.query_modifiers-1539"><span class="linenos">1539</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">offset_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">,</span> <span class="n">limit</span><span class="p">),</span> -</span><span id="Generator.query_modifiers-1540"><a href="#Generator.query_modifiers-1540"><span class="linenos">1540</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> -</span><span id="Generator.query_modifiers-1541"><a href="#Generator.query_modifiers-1541"><span class="linenos">1541</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> -</span><span id="Generator.query_modifiers-1542"><a href="#Generator.query_modifiers-1542"><span class="linenos">1542</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.query_modifiers-1531"><a href="#Generator.query_modifiers-1531"><span class="linenos">1531</span></a> <span class="k">def</span> <span class="nf">query_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="o">*</span><span class="n">sqls</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.query_modifiers-1532"><a href="#Generator.query_modifiers-1532"><span class="linenos">1532</span></a> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"limit"</span><span class="p">)</span> +</span><span id="Generator.query_modifiers-1533"><a href="#Generator.query_modifiers-1533"><span class="linenos">1533</span></a> +</span><span id="Generator.query_modifiers-1534"><a href="#Generator.query_modifiers-1534"><span class="linenos">1534</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"LIMIT"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">):</span> +</span><span id="Generator.query_modifiers-1535"><a href="#Generator.query_modifiers-1535"><span class="linenos">1535</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">limit</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"count"</span><span class="p">))</span> +</span><span id="Generator.query_modifiers-1536"><a href="#Generator.query_modifiers-1536"><span class="linenos">1536</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">LIMIT_FETCH</span> <span class="o">==</span> <span class="s2">"FETCH"</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">):</span> +</span><span id="Generator.query_modifiers-1537"><a href="#Generator.query_modifiers-1537"><span class="linenos">1537</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">(</span><span class="n">direction</span><span class="o">=</span><span class="s2">"FIRST"</span><span class="p">,</span> <span class="n">count</span><span class="o">=</span><span class="n">limit</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.query_modifiers-1538"><a href="#Generator.query_modifiers-1538"><span class="linenos">1538</span></a> +</span><span id="Generator.query_modifiers-1539"><a href="#Generator.query_modifiers-1539"><span class="linenos">1539</span></a> <span class="n">fetch</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">limit</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">)</span> +</span><span id="Generator.query_modifiers-1540"><a href="#Generator.query_modifiers-1540"><span class="linenos">1540</span></a> +</span><span id="Generator.query_modifiers-1541"><a href="#Generator.query_modifiers-1541"><span class="linenos">1541</span></a> <span class="k">return</span> <span class="n">csv</span><span class="p">(</span> +</span><span id="Generator.query_modifiers-1542"><a href="#Generator.query_modifiers-1542"><span class="linenos">1542</span></a> <span class="o">*</span><span class="n">sqls</span><span class="p">,</span> +</span><span id="Generator.query_modifiers-1543"><a href="#Generator.query_modifiers-1543"><span class="linenos">1543</span></a> <span class="o">*</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">join</span><span class="p">)</span> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> +</span><span id="Generator.query_modifiers-1544"><a href="#Generator.query_modifiers-1544"><span class="linenos">1544</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"match"</span><span class="p">),</span> +</span><span id="Generator.query_modifiers-1545"><a href="#Generator.query_modifiers-1545"><span class="linenos">1545</span></a> <span class="o">*</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">lateral</span><span class="p">)</span> <span class="k">for</span> <span class="n">lateral</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"laterals"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]],</span> +</span><span id="Generator.query_modifiers-1546"><a href="#Generator.query_modifiers-1546"><span class="linenos">1546</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">),</span> +</span><span id="Generator.query_modifiers-1547"><a href="#Generator.query_modifiers-1547"><span class="linenos">1547</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">),</span> +</span><span id="Generator.query_modifiers-1548"><a href="#Generator.query_modifiers-1548"><span class="linenos">1548</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"having"</span><span class="p">),</span> +</span><span id="Generator.query_modifiers-1549"><a href="#Generator.query_modifiers-1549"><span class="linenos">1549</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_having_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> +</span><span id="Generator.query_modifiers-1550"><a href="#Generator.query_modifiers-1550"><span class="linenos">1550</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">),</span> +</span><span id="Generator.query_modifiers-1551"><a href="#Generator.query_modifiers-1551"><span class="linenos">1551</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">offset_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">,</span> <span class="n">limit</span><span class="p">),</span> +</span><span id="Generator.query_modifiers-1552"><a href="#Generator.query_modifiers-1552"><span class="linenos">1552</span></a> <span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">after_limit_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> +</span><span id="Generator.query_modifiers-1553"><a href="#Generator.query_modifiers-1553"><span class="linenos">1553</span></a> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> +</span><span id="Generator.query_modifiers-1554"><a href="#Generator.query_modifiers-1554"><span class="linenos">1554</span></a> <span class="p">)</span> </span></pre></div> @@ -8556,13 +8703,13 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.offset_limit_modifiers"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.offset_limit_modifiers-1544"><a href="#Generator.offset_limit_modifiers-1544"><span class="linenos">1544</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> -</span><span id="Generator.offset_limit_modifiers-1545"><a href="#Generator.offset_limit_modifiers-1545"><span class="linenos">1545</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> -</span><span id="Generator.offset_limit_modifiers-1546"><a href="#Generator.offset_limit_modifiers-1546"><span class="linenos">1546</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Generator.offset_limit_modifiers-1547"><a href="#Generator.offset_limit_modifiers-1547"><span class="linenos">1547</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="Generator.offset_limit_modifiers-1548"><a href="#Generator.offset_limit_modifiers-1548"><span class="linenos">1548</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> -</span><span id="Generator.offset_limit_modifiers-1549"><a href="#Generator.offset_limit_modifiers-1549"><span class="linenos">1549</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> -</span><span id="Generator.offset_limit_modifiers-1550"><a href="#Generator.offset_limit_modifiers-1550"><span class="linenos">1550</span></a> <span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.offset_limit_modifiers-1556"><a href="#Generator.offset_limit_modifiers-1556"><span class="linenos">1556</span></a> <span class="k">def</span> <span class="nf">offset_limit_modifiers</span><span class="p">(</span> +</span><span id="Generator.offset_limit_modifiers-1557"><a href="#Generator.offset_limit_modifiers-1557"><span class="linenos">1557</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">fetch</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">limit</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Limit</span><span class="p">]</span> +</span><span id="Generator.offset_limit_modifiers-1558"><a href="#Generator.offset_limit_modifiers-1558"><span class="linenos">1558</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Generator.offset_limit_modifiers-1559"><a href="#Generator.offset_limit_modifiers-1559"><span class="linenos">1559</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="Generator.offset_limit_modifiers-1560"><a href="#Generator.offset_limit_modifiers-1560"><span class="linenos">1560</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">),</span> +</span><span id="Generator.offset_limit_modifiers-1561"><a href="#Generator.offset_limit_modifiers-1561"><span class="linenos">1561</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">limit</span><span class="p">)</span> <span class="k">if</span> <span class="n">fetch</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"offset"</span><span class="p">),</span> +</span><span id="Generator.offset_limit_modifiers-1562"><a href="#Generator.offset_limit_modifiers-1562"><span class="linenos">1562</span></a> <span class="p">]</span> </span></pre></div> @@ -8580,13 +8727,13 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.after_having_modifiers"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.after_having_modifiers-1552"><a href="#Generator.after_having_modifiers-1552"><span class="linenos">1552</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Generator.after_having_modifiers-1553"><a href="#Generator.after_having_modifiers-1553"><span class="linenos">1553</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="Generator.after_having_modifiers-1554"><a href="#Generator.after_having_modifiers-1554"><span class="linenos">1554</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"qualify"</span><span class="p">),</span> -</span><span id="Generator.after_having_modifiers-1555"><a href="#Generator.after_having_modifiers-1555"><span class="linenos">1555</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WINDOW "</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"windows"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.after_having_modifiers-1556"><a href="#Generator.after_having_modifiers-1556"><span class="linenos">1556</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"windows"</span><span class="p">)</span> -</span><span id="Generator.after_having_modifiers-1557"><a href="#Generator.after_having_modifiers-1557"><span class="linenos">1557</span></a> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="Generator.after_having_modifiers-1558"><a href="#Generator.after_having_modifiers-1558"><span class="linenos">1558</span></a> <span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.after_having_modifiers-1564"><a href="#Generator.after_having_modifiers-1564"><span class="linenos">1564</span></a> <span class="k">def</span> <span class="nf">after_having_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Generator.after_having_modifiers-1565"><a href="#Generator.after_having_modifiers-1565"><span class="linenos">1565</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="Generator.after_having_modifiers-1566"><a href="#Generator.after_having_modifiers-1566"><span class="linenos">1566</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"qualify"</span><span class="p">),</span> +</span><span id="Generator.after_having_modifiers-1567"><a href="#Generator.after_having_modifiers-1567"><span class="linenos">1567</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"WINDOW "</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"windows"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.after_having_modifiers-1568"><a href="#Generator.after_having_modifiers-1568"><span class="linenos">1568</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"windows"</span><span class="p">)</span> +</span><span id="Generator.after_having_modifiers-1569"><a href="#Generator.after_having_modifiers-1569"><span class="linenos">1569</span></a> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="Generator.after_having_modifiers-1570"><a href="#Generator.after_having_modifiers-1570"><span class="linenos">1570</span></a> <span class="p">]</span> </span></pre></div> @@ -8604,10 +8751,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.after_limit_modifiers"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.after_limit_modifiers-1560"><a href="#Generator.after_limit_modifiers-1560"><span class="linenos">1560</span></a> <span class="k">def</span> <span class="nf">after_limit_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Generator.after_limit_modifiers-1561"><a href="#Generator.after_limit_modifiers-1561"><span class="linenos">1561</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"locks"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator.after_limit_modifiers-1562"><a href="#Generator.after_limit_modifiers-1562"><span class="linenos">1562</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">locks</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">locks</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.after_limit_modifiers-1563"><a href="#Generator.after_limit_modifiers-1563"><span class="linenos">1563</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">locks</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"sample"</span><span class="p">)]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.after_limit_modifiers-1572"><a href="#Generator.after_limit_modifiers-1572"><span class="linenos">1572</span></a> <span class="k">def</span> <span class="nf">after_limit_modifiers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Generator.after_limit_modifiers-1573"><a href="#Generator.after_limit_modifiers-1573"><span class="linenos">1573</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"locks"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator.after_limit_modifiers-1574"><a href="#Generator.after_limit_modifiers-1574"><span class="linenos">1574</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">locks</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">locks</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.after_limit_modifiers-1575"><a href="#Generator.after_limit_modifiers-1575"><span class="linenos">1575</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">locks</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"sample"</span><span class="p">)]</span> </span></pre></div> @@ -8625,21 +8772,42 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.select_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.select_sql-1565"><a href="#Generator.select_sql-1565"><span class="linenos">1565</span></a> <span class="k">def</span> <span class="nf">select_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.select_sql-1566"><a href="#Generator.select_sql-1566"><span class="linenos">1566</span></a> <span class="n">hint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"hint"</span><span class="p">)</span> -</span><span id="Generator.select_sql-1567"><a href="#Generator.select_sql-1567"><span class="linenos">1567</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distinct"</span><span class="p">)</span> -</span><span id="Generator.select_sql-1568"><a href="#Generator.select_sql-1568"><span class="linenos">1568</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">distinct</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">distinct</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.select_sql-1569"><a href="#Generator.select_sql-1569"><span class="linenos">1569</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator.select_sql-1570"><a href="#Generator.select_sql-1570"><span class="linenos">1570</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.select_sql-1571"><a href="#Generator.select_sql-1571"><span class="linenos">1571</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.select_sql-1572"><a href="#Generator.select_sql-1572"><span class="linenos">1572</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="n">expressions</span> -</span><span id="Generator.select_sql-1573"><a href="#Generator.select_sql-1573"><span class="linenos">1573</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> -</span><span id="Generator.select_sql-1574"><a href="#Generator.select_sql-1574"><span class="linenos">1574</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator.select_sql-1575"><a href="#Generator.select_sql-1575"><span class="linenos">1575</span></a> <span class="sa">f</span><span class="s2">"SELECT</span><span class="si">{</span><span class="n">hint</span><span class="si">}{</span><span class="n">distinct</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Generator.select_sql-1576"><a href="#Generator.select_sql-1576"><span class="linenos">1576</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"into"</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="Generator.select_sql-1577"><a href="#Generator.select_sql-1577"><span class="linenos">1577</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="Generator.select_sql-1578"><a href="#Generator.select_sql-1578"><span class="linenos">1578</span></a> <span class="p">)</span> -</span><span id="Generator.select_sql-1579"><a href="#Generator.select_sql-1579"><span class="linenos">1579</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.select_sql-1577"><a href="#Generator.select_sql-1577"><span class="linenos">1577</span></a> <span class="k">def</span> <span class="nf">select_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.select_sql-1578"><a href="#Generator.select_sql-1578"><span class="linenos">1578</span></a> <span class="n">hint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"hint"</span><span class="p">)</span> +</span><span id="Generator.select_sql-1579"><a href="#Generator.select_sql-1579"><span class="linenos">1579</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"distinct"</span><span class="p">)</span> +</span><span id="Generator.select_sql-1580"><a href="#Generator.select_sql-1580"><span class="linenos">1580</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">distinct</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">distinct</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.select_sql-1581"><a href="#Generator.select_sql-1581"><span class="linenos">1581</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Generator.select_sql-1582"><a href="#Generator.select_sql-1582"><span class="linenos">1582</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.select_sql-1583"><a href="#Generator.select_sql-1583"><span class="linenos">1583</span></a> +</span><span id="Generator.select_sql-1584"><a href="#Generator.select_sql-1584"><span class="linenos">1584</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="Generator.select_sql-1585"><a href="#Generator.select_sql-1585"><span class="linenos">1585</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SELECT_KINDS</span><span class="p">:</span> +</span><span id="Generator.select_sql-1586"><a href="#Generator.select_sql-1586"><span class="linenos">1586</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.select_sql-1587"><a href="#Generator.select_sql-1587"><span class="linenos">1587</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.select_sql-1588"><a href="#Generator.select_sql-1588"><span class="linenos">1588</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="s2">"STRUCT"</span><span class="p">:</span> +</span><span id="Generator.select_sql-1589"><a href="#Generator.select_sql-1589"><span class="linenos">1589</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span> +</span><span id="Generator.select_sql-1590"><a href="#Generator.select_sql-1590"><span class="linenos">1590</span></a> <span class="n">sqls</span><span class="o">=</span><span class="p">[</span> +</span><span id="Generator.select_sql-1591"><a href="#Generator.select_sql-1591"><span class="linenos">1591</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="Generator.select_sql-1592"><a href="#Generator.select_sql-1592"><span class="linenos">1592</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Struct</span><span class="p">(</span> +</span><span id="Generator.select_sql-1593"><a href="#Generator.select_sql-1593"><span class="linenos">1593</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span> +</span><span id="Generator.select_sql-1594"><a href="#Generator.select_sql-1594"><span class="linenos">1594</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">output_name</span><span class="p">)</span><span class="o">.</span><span class="n">eq</span><span class="p">(</span> +</span><span id="Generator.select_sql-1595"><a href="#Generator.select_sql-1595"><span class="linenos">1595</span></a> <span class="n">e</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">)</span> <span class="k">else</span> <span class="n">e</span> +</span><span id="Generator.select_sql-1596"><a href="#Generator.select_sql-1596"><span class="linenos">1596</span></a> <span class="p">)</span> +</span><span id="Generator.select_sql-1597"><a href="#Generator.select_sql-1597"><span class="linenos">1597</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="Generator.select_sql-1598"><a href="#Generator.select_sql-1598"><span class="linenos">1598</span></a> <span class="p">]</span> +</span><span id="Generator.select_sql-1599"><a href="#Generator.select_sql-1599"><span class="linenos">1599</span></a> <span class="p">)</span> +</span><span id="Generator.select_sql-1600"><a href="#Generator.select_sql-1600"><span class="linenos">1600</span></a> <span class="p">)</span> +</span><span id="Generator.select_sql-1601"><a href="#Generator.select_sql-1601"><span class="linenos">1601</span></a> <span class="p">]</span> +</span><span id="Generator.select_sql-1602"><a href="#Generator.select_sql-1602"><span class="linenos">1602</span></a> <span class="p">)</span> +</span><span id="Generator.select_sql-1603"><a href="#Generator.select_sql-1603"><span class="linenos">1603</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.select_sql-1604"><a href="#Generator.select_sql-1604"><span class="linenos">1604</span></a> +</span><span id="Generator.select_sql-1605"><a href="#Generator.select_sql-1605"><span class="linenos">1605</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="n">expressions</span> +</span><span id="Generator.select_sql-1606"><a href="#Generator.select_sql-1606"><span class="linenos">1606</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> +</span><span id="Generator.select_sql-1607"><a href="#Generator.select_sql-1607"><span class="linenos">1607</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator.select_sql-1608"><a href="#Generator.select_sql-1608"><span class="linenos">1608</span></a> <span class="sa">f</span><span class="s2">"SELECT</span><span class="si">{</span><span class="n">hint</span><span class="si">}{</span><span class="n">distinct</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Generator.select_sql-1609"><a href="#Generator.select_sql-1609"><span class="linenos">1609</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"into"</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="Generator.select_sql-1610"><a href="#Generator.select_sql-1610"><span class="linenos">1610</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"from"</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="Generator.select_sql-1611"><a href="#Generator.select_sql-1611"><span class="linenos">1611</span></a> <span class="p">)</span> +</span><span id="Generator.select_sql-1612"><a href="#Generator.select_sql-1612"><span class="linenos">1612</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> </span></pre></div> @@ -8657,11 +8825,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.schema_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.schema_sql-1581"><a href="#Generator.schema_sql-1581"><span class="linenos">1581</span></a> <span class="k">def</span> <span class="nf">schema_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.schema_sql-1582"><a href="#Generator.schema_sql-1582"><span class="linenos">1582</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.schema_sql-1583"><a href="#Generator.schema_sql-1583"><span class="linenos">1583</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.schema_sql-1584"><a href="#Generator.schema_sql-1584"><span class="linenos">1584</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.schema_sql-1585"><a href="#Generator.schema_sql-1585"><span class="linenos">1585</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">sql</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.schema_sql-1614"><a href="#Generator.schema_sql-1614"><span class="linenos">1614</span></a> <span class="k">def</span> <span class="nf">schema_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.schema_sql-1615"><a href="#Generator.schema_sql-1615"><span class="linenos">1615</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.schema_sql-1616"><a href="#Generator.schema_sql-1616"><span class="linenos">1616</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> "</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.schema_sql-1617"><a href="#Generator.schema_sql-1617"><span class="linenos">1617</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema_columns_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.schema_sql-1618"><a href="#Generator.schema_sql-1618"><span class="linenos">1618</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">sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8679,8 +8847,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.schema_columns_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.schema_columns_sql-1587"><a href="#Generator.schema_columns_sql-1587"><span class="linenos">1587</span></a> <span class="k">def</span> <span class="nf">schema_columns_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.schema_columns_sql-1588"><a href="#Generator.schema_columns_sql-1588"><span class="linenos">1588</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.schema_columns_sql-1620"><a href="#Generator.schema_columns_sql-1620"><span class="linenos">1620</span></a> <span class="k">def</span> <span class="nf">schema_columns_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.schema_columns_sql-1621"><a href="#Generator.schema_columns_sql-1621"><span class="linenos">1621</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8698,12 +8866,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.star_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.star_sql-1590"><a href="#Generator.star_sql-1590"><span class="linenos">1590</span></a> <span class="k">def</span> <span class="nf">star_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.star_sql-1591"><a href="#Generator.star_sql-1591"><span class="linenos">1591</span></a> <span class="n">except_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"except"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.star_sql-1592"><a href="#Generator.star_sql-1592"><span class="linenos">1592</span></a> <span class="n">except_</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'except'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">except_</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">except_</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.star_sql-1593"><a href="#Generator.star_sql-1593"><span class="linenos">1593</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"replace"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.star_sql-1594"><a href="#Generator.star_sql-1594"><span class="linenos">1594</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'replace'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">replace</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">replace</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.star_sql-1595"><a href="#Generator.star_sql-1595"><span class="linenos">1595</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"*</span><span class="si">{</span><span class="n">except_</span><span class="si">}{</span><span class="n">replace</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.star_sql-1623"><a href="#Generator.star_sql-1623"><span class="linenos">1623</span></a> <span class="k">def</span> <span class="nf">star_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.star_sql-1624"><a href="#Generator.star_sql-1624"><span class="linenos">1624</span></a> <span class="n">except_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"except"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.star_sql-1625"><a href="#Generator.star_sql-1625"><span class="linenos">1625</span></a> <span class="n">except_</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'except'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">except_</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">except_</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.star_sql-1626"><a href="#Generator.star_sql-1626"><span class="linenos">1626</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"replace"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.star_sql-1627"><a href="#Generator.star_sql-1627"><span class="linenos">1627</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STAR_MAPPING</span><span class="p">[</span><span class="s1">'replace'</span><span class="p">])</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">replace</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">replace</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.star_sql-1628"><a href="#Generator.star_sql-1628"><span class="linenos">1628</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"*</span><span class="si">{</span><span class="n">except_</span><span class="si">}{</span><span class="n">replace</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8721,10 +8889,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.parameter_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.parameter_sql-1597"><a href="#Generator.parameter_sql-1597"><span class="linenos">1597</span></a> <span class="k">def</span> <span class="nf">parameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Parameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.parameter_sql-1598"><a href="#Generator.parameter_sql-1598"><span class="linenos">1598</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.parameter_sql-1599"><a href="#Generator.parameter_sql-1599"><span class="linenos">1599</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="se">{{</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="se">}}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"wrapped"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.parameter_sql-1600"><a href="#Generator.parameter_sql-1600"><span class="linenos">1600</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">PARAMETER_TOKEN</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.parameter_sql-1630"><a href="#Generator.parameter_sql-1630"><span class="linenos">1630</span></a> <span class="k">def</span> <span class="nf">parameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Parameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.parameter_sql-1631"><a href="#Generator.parameter_sql-1631"><span class="linenos">1631</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.parameter_sql-1632"><a href="#Generator.parameter_sql-1632"><span class="linenos">1632</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="se">{{</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="se">}}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"wrapped"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.parameter_sql-1633"><a href="#Generator.parameter_sql-1633"><span class="linenos">1633</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">PARAMETER_TOKEN</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8742,12 +8910,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.sessionparameter_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sessionparameter_sql-1602"><a href="#Generator.sessionparameter_sql-1602"><span class="linenos">1602</span></a> <span class="k">def</span> <span class="nf">sessionparameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SessionParameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.sessionparameter_sql-1603"><a href="#Generator.sessionparameter_sql-1603"><span class="linenos">1603</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.sessionparameter_sql-1604"><a href="#Generator.sessionparameter_sql-1604"><span class="linenos">1604</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator.sessionparameter_sql-1605"><a href="#Generator.sessionparameter_sql-1605"><span class="linenos">1605</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="Generator.sessionparameter_sql-1606"><a href="#Generator.sessionparameter_sql-1606"><span class="linenos">1606</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">."</span> -</span><span id="Generator.sessionparameter_sql-1607"><a href="#Generator.sessionparameter_sql-1607"><span class="linenos">1607</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"@@</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sessionparameter_sql-1635"><a href="#Generator.sessionparameter_sql-1635"><span class="linenos">1635</span></a> <span class="k">def</span> <span class="nf">sessionparameter_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SessionParameter</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.sessionparameter_sql-1636"><a href="#Generator.sessionparameter_sql-1636"><span class="linenos">1636</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.sessionparameter_sql-1637"><a href="#Generator.sessionparameter_sql-1637"><span class="linenos">1637</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator.sessionparameter_sql-1638"><a href="#Generator.sessionparameter_sql-1638"><span class="linenos">1638</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="Generator.sessionparameter_sql-1639"><a href="#Generator.sessionparameter_sql-1639"><span class="linenos">1639</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">."</span> +</span><span id="Generator.sessionparameter_sql-1640"><a href="#Generator.sessionparameter_sql-1640"><span class="linenos">1640</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"@@</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8765,8 +8933,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.placeholder_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.placeholder_sql-1609"><a href="#Generator.placeholder_sql-1609"><span class="linenos">1609</span></a> <span class="k">def</span> <span class="nf">placeholder_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Placeholder</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.placeholder_sql-1610"><a href="#Generator.placeholder_sql-1610"><span class="linenos">1610</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">":</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">"?"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.placeholder_sql-1642"><a href="#Generator.placeholder_sql-1642"><span class="linenos">1642</span></a> <span class="k">def</span> <span class="nf">placeholder_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Placeholder</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.placeholder_sql-1643"><a href="#Generator.placeholder_sql-1643"><span class="linenos">1643</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">":</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">name</span> <span class="k">else</span> <span class="s2">"?"</span> </span></pre></div> @@ -8784,15 +8952,15 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.subquery_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.subquery_sql-1612"><a href="#Generator.subquery_sql-1612"><span class="linenos">1612</span></a> <span class="k">def</span> <span class="nf">subquery_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.subquery_sql-1613"><a href="#Generator.subquery_sql-1613"><span class="linenos">1613</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator.subquery_sql-1614"><a href="#Generator.subquery_sql-1614"><span class="linenos">1614</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.subquery_sql-1615"><a href="#Generator.subquery_sql-1615"><span class="linenos">1615</span></a> -</span><span id="Generator.subquery_sql-1616"><a href="#Generator.subquery_sql-1616"><span class="linenos">1616</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.subquery_sql-1617"><a href="#Generator.subquery_sql-1617"><span class="linenos">1617</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.subquery_sql-1618"><a href="#Generator.subquery_sql-1618"><span class="linenos">1618</span></a> -</span><span id="Generator.subquery_sql-1619"><a href="#Generator.subquery_sql-1619"><span class="linenos">1619</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> <span class="n">alias</span><span class="p">,</span> <span class="n">pivots</span><span class="p">)</span> -</span><span id="Generator.subquery_sql-1620"><a href="#Generator.subquery_sql-1620"><span class="linenos">1620</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.subquery_sql-1645"><a href="#Generator.subquery_sql-1645"><span class="linenos">1645</span></a> <span class="k">def</span> <span class="nf">subquery_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">" AS "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.subquery_sql-1646"><a href="#Generator.subquery_sql-1646"><span class="linenos">1646</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator.subquery_sql-1647"><a href="#Generator.subquery_sql-1647"><span class="linenos">1647</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.subquery_sql-1648"><a href="#Generator.subquery_sql-1648"><span class="linenos">1648</span></a> +</span><span id="Generator.subquery_sql-1649"><a href="#Generator.subquery_sql-1649"><span class="linenos">1649</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.subquery_sql-1650"><a href="#Generator.subquery_sql-1650"><span class="linenos">1650</span></a> <span class="n">pivots</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">pivots</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">pivots</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.subquery_sql-1651"><a href="#Generator.subquery_sql-1651"><span class="linenos">1651</span></a> +</span><span id="Generator.subquery_sql-1652"><a href="#Generator.subquery_sql-1652"><span class="linenos">1652</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">),</span> <span class="n">alias</span><span class="p">,</span> <span class="n">pivots</span><span class="p">)</span> +</span><span id="Generator.subquery_sql-1653"><a href="#Generator.subquery_sql-1653"><span class="linenos">1653</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> </span></pre></div> @@ -8810,9 +8978,9 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.qualify_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.qualify_sql-1622"><a href="#Generator.qualify_sql-1622"><span class="linenos">1622</span></a> <span class="k">def</span> <span class="nf">qualify_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Qualify</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.qualify_sql-1623"><a href="#Generator.qualify_sql-1623"><span class="linenos">1623</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))</span> -</span><span id="Generator.qualify_sql-1624"><a href="#Generator.qualify_sql-1624"><span class="linenos">1624</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'QUALIFY'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.qualify_sql-1655"><a href="#Generator.qualify_sql-1655"><span class="linenos">1655</span></a> <span class="k">def</span> <span class="nf">qualify_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Qualify</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.qualify_sql-1656"><a href="#Generator.qualify_sql-1656"><span class="linenos">1656</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))</span> +</span><span id="Generator.qualify_sql-1657"><a href="#Generator.qualify_sql-1657"><span class="linenos">1657</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'QUALIFY'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8830,11 +8998,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.union_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.union_sql-1626"><a href="#Generator.union_sql-1626"><span class="linenos">1626</span></a> <span class="k">def</span> <span class="nf">union_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.union_sql-1627"><a href="#Generator.union_sql-1627"><span class="linenos">1627</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span> -</span><span id="Generator.union_sql-1628"><a href="#Generator.union_sql-1628"><span class="linenos">1628</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator.union_sql-1629"><a href="#Generator.union_sql-1629"><span class="linenos">1629</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">union_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> -</span><span id="Generator.union_sql-1630"><a href="#Generator.union_sql-1630"><span class="linenos">1630</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.union_sql-1659"><a href="#Generator.union_sql-1659"><span class="linenos">1659</span></a> <span class="k">def</span> <span class="nf">union_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.union_sql-1660"><a href="#Generator.union_sql-1660"><span class="linenos">1660</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span> +</span><span id="Generator.union_sql-1661"><a href="#Generator.union_sql-1661"><span class="linenos">1661</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator.union_sql-1662"><a href="#Generator.union_sql-1662"><span class="linenos">1662</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">set_operation</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">union_op</span><span class="p">(</span><span class="n">expression</span><span class="p">)),</span> +</span><span id="Generator.union_sql-1663"><a href="#Generator.union_sql-1663"><span class="linenos">1663</span></a> <span class="p">)</span> </span></pre></div> @@ -8852,10 +9020,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.union_op"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.union_op-1632"><a href="#Generator.union_op-1632"><span class="linenos">1632</span></a> <span class="k">def</span> <span class="nf">union_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.union_op-1633"><a href="#Generator.union_op-1633"><span class="linenos">1633</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">" DISTINCT"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPLICIT_UNION</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.union_op-1634"><a href="#Generator.union_op-1634"><span class="linenos">1634</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">kind</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"distinct"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" ALL"</span> -</span><span id="Generator.union_op-1635"><a href="#Generator.union_op-1635"><span class="linenos">1635</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNION</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.union_op-1665"><a href="#Generator.union_op-1665"><span class="linenos">1665</span></a> <span class="k">def</span> <span class="nf">union_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.union_op-1666"><a href="#Generator.union_op-1666"><span class="linenos">1666</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">" DISTINCT"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPLICIT_UNION</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.union_op-1667"><a href="#Generator.union_op-1667"><span class="linenos">1667</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">kind</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"distinct"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" ALL"</span> +</span><span id="Generator.union_op-1668"><a href="#Generator.union_op-1668"><span class="linenos">1668</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNION</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8873,19 +9041,19 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.unnest_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.unnest_sql-1637"><a href="#Generator.unnest_sql-1637"><span class="linenos">1637</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.unnest_sql-1638"><a href="#Generator.unnest_sql-1638"><span class="linenos">1638</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.unnest_sql-1639"><a href="#Generator.unnest_sql-1639"><span class="linenos">1639</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator.unnest_sql-1640"><a href="#Generator.unnest_sql-1640"><span class="linenos">1640</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> -</span><span id="Generator.unnest_sql-1641"><a href="#Generator.unnest_sql-1641"><span class="linenos">1641</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">alias</span><span class="o">.</span><span class="n">columns</span> -</span><span id="Generator.unnest_sql-1642"><a href="#Generator.unnest_sql-1642"><span class="linenos">1642</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">columns</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.unnest_sql-1643"><a href="#Generator.unnest_sql-1643"><span class="linenos">1643</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.unnest_sql-1644"><a href="#Generator.unnest_sql-1644"><span class="linenos">1644</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator.unnest_sql-1645"><a href="#Generator.unnest_sql-1645"><span class="linenos">1645</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">alias</span> -</span><span id="Generator.unnest_sql-1646"><a href="#Generator.unnest_sql-1646"><span class="linenos">1646</span></a> <span class="n">ordinality</span> <span class="o">=</span> <span class="s2">" WITH ORDINALITY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ordinality"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.unnest_sql-1647"><a href="#Generator.unnest_sql-1647"><span class="linenos">1647</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">)</span> -</span><span id="Generator.unnest_sql-1648"><a href="#Generator.unnest_sql-1648"><span class="linenos">1648</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH OFFSET AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">offset</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">offset</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.unnest_sql-1649"><a href="#Generator.unnest_sql-1649"><span class="linenos">1649</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNNEST(</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">ordinality</span><span class="si">}{</span><span class="n">alias</span><span class="si">}{</span><span class="n">offset</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.unnest_sql-1670"><a href="#Generator.unnest_sql-1670"><span class="linenos">1670</span></a> <span class="k">def</span> <span class="nf">unnest_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.unnest_sql-1671"><a href="#Generator.unnest_sql-1671"><span class="linenos">1671</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.unnest_sql-1672"><a href="#Generator.unnest_sql-1672"><span class="linenos">1672</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator.unnest_sql-1673"><a href="#Generator.unnest_sql-1673"><span class="linenos">1673</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> +</span><span id="Generator.unnest_sql-1674"><a href="#Generator.unnest_sql-1674"><span class="linenos">1674</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">alias</span><span class="o">.</span><span class="n">columns</span> +</span><span id="Generator.unnest_sql-1675"><a href="#Generator.unnest_sql-1675"><span class="linenos">1675</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">columns</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.unnest_sql-1676"><a href="#Generator.unnest_sql-1676"><span class="linenos">1676</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.unnest_sql-1677"><a href="#Generator.unnest_sql-1677"><span class="linenos">1677</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator.unnest_sql-1678"><a href="#Generator.unnest_sql-1678"><span class="linenos">1678</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="n">alias</span> +</span><span id="Generator.unnest_sql-1679"><a href="#Generator.unnest_sql-1679"><span class="linenos">1679</span></a> <span class="n">ordinality</span> <span class="o">=</span> <span class="s2">" WITH ORDINALITY"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"ordinality"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.unnest_sql-1680"><a href="#Generator.unnest_sql-1680"><span class="linenos">1680</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">)</span> +</span><span id="Generator.unnest_sql-1681"><a href="#Generator.unnest_sql-1681"><span class="linenos">1681</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" WITH OFFSET AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">offset</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">offset</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.unnest_sql-1682"><a href="#Generator.unnest_sql-1682"><span class="linenos">1682</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"UNNEST(</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">ordinality</span><span class="si">}{</span><span class="n">alias</span><span class="si">}{</span><span class="n">offset</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8903,9 +9071,9 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.where_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.where_sql-1651"><a href="#Generator.where_sql-1651"><span class="linenos">1651</span></a> <span class="k">def</span> <span class="nf">where_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.where_sql-1652"><a href="#Generator.where_sql-1652"><span class="linenos">1652</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))</span> -</span><span id="Generator.where_sql-1653"><a href="#Generator.where_sql-1653"><span class="linenos">1653</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'WHERE'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.where_sql-1684"><a href="#Generator.where_sql-1684"><span class="linenos">1684</span></a> <span class="k">def</span> <span class="nf">where_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.where_sql-1685"><a href="#Generator.where_sql-1685"><span class="linenos">1685</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">))</span> +</span><span id="Generator.where_sql-1686"><a href="#Generator.where_sql-1686"><span class="linenos">1686</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">'WHERE'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -8923,28 +9091,28 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.window_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.window_sql-1655"><a href="#Generator.window_sql-1655"><span class="linenos">1655</span></a> <span class="k">def</span> <span class="nf">window_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.window_sql-1656"><a href="#Generator.window_sql-1656"><span class="linenos">1656</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.window_sql-1657"><a href="#Generator.window_sql-1657"><span class="linenos">1657</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.window_sql-1658"><a href="#Generator.window_sql-1658"><span class="linenos">1658</span></a> <span class="n">order</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"order"</span><span class="p">)</span> -</span><span id="Generator.window_sql-1659"><a href="#Generator.window_sql-1659"><span class="linenos">1659</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.window_sql-1660"><a href="#Generator.window_sql-1660"><span class="linenos">1660</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"spec"</span><span class="p">)</span> -</span><span id="Generator.window_sql-1661"><a href="#Generator.window_sql-1661"><span class="linenos">1661</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator.window_sql-1662"><a href="#Generator.window_sql-1662"><span class="linenos">1662</span></a> <span class="n">over</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"over"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"OVER"</span> -</span><span id="Generator.window_sql-1663"><a href="#Generator.window_sql-1663"><span class="linenos">1663</span></a> -</span><span id="Generator.window_sql-1664"><a href="#Generator.window_sql-1664"><span class="linenos">1664</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="s1">'AS'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">arg_key</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s1">'windows'</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">over</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.window_sql-1665"><a href="#Generator.window_sql-1665"><span class="linenos">1665</span></a> -</span><span id="Generator.window_sql-1666"><a href="#Generator.window_sql-1666"><span class="linenos">1666</span></a> <span class="n">first</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"first"</span><span class="p">)</span> -</span><span id="Generator.window_sql-1667"><a href="#Generator.window_sql-1667"><span class="linenos">1667</span></a> <span class="k">if</span> <span class="n">first</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.window_sql-1668"><a href="#Generator.window_sql-1668"><span class="linenos">1668</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.window_sql-1669"><a href="#Generator.window_sql-1669"><span class="linenos">1669</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.window_sql-1670"><a href="#Generator.window_sql-1670"><span class="linenos">1670</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">"FIRST"</span> <span class="k">if</span> <span class="n">first</span> <span class="k">else</span> <span class="s2">"LAST"</span> -</span><span id="Generator.window_sql-1671"><a href="#Generator.window_sql-1671"><span class="linenos">1671</span></a> -</span><span id="Generator.window_sql-1672"><a href="#Generator.window_sql-1672"><span class="linenos">1672</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">partition</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">order</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">spec</span> <span class="ow">and</span> <span class="n">alias</span><span class="p">:</span> -</span><span id="Generator.window_sql-1673"><a href="#Generator.window_sql-1673"><span class="linenos">1673</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.window_sql-1674"><a href="#Generator.window_sql-1674"><span class="linenos">1674</span></a> -</span><span id="Generator.window_sql-1675"><a href="#Generator.window_sql-1675"><span class="linenos">1675</span></a> <span class="n">args</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">first</span><span class="p">,</span> <span class="n">partition</span><span class="p">,</span> <span class="n">order</span><span class="p">,</span> <span class="n">spec</span><span class="p">)</span> <span class="k">if</span> <span class="n">arg</span><span class="p">)</span> -</span><span id="Generator.window_sql-1676"><a href="#Generator.window_sql-1676"><span class="linenos">1676</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.window_sql-1688"><a href="#Generator.window_sql-1688"><span class="linenos">1688</span></a> <span class="k">def</span> <span class="nf">window_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.window_sql-1689"><a href="#Generator.window_sql-1689"><span class="linenos">1689</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.window_sql-1690"><a href="#Generator.window_sql-1690"><span class="linenos">1690</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partition_by_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.window_sql-1691"><a href="#Generator.window_sql-1691"><span class="linenos">1691</span></a> <span class="n">order</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"order"</span><span class="p">)</span> +</span><span id="Generator.window_sql-1692"><a href="#Generator.window_sql-1692"><span class="linenos">1692</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.window_sql-1693"><a href="#Generator.window_sql-1693"><span class="linenos">1693</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"spec"</span><span class="p">)</span> +</span><span id="Generator.window_sql-1694"><a href="#Generator.window_sql-1694"><span class="linenos">1694</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator.window_sql-1695"><a href="#Generator.window_sql-1695"><span class="linenos">1695</span></a> <span class="n">over</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"over"</span><span class="p">)</span> <span class="ow">or</span> <span class="s2">"OVER"</span> +</span><span id="Generator.window_sql-1696"><a href="#Generator.window_sql-1696"><span class="linenos">1696</span></a> +</span><span id="Generator.window_sql-1697"><a href="#Generator.window_sql-1697"><span class="linenos">1697</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="s1">'AS'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expression</span><span class="o">.</span><span class="n">arg_key</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s1">'windows'</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">over</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.window_sql-1698"><a href="#Generator.window_sql-1698"><span class="linenos">1698</span></a> +</span><span id="Generator.window_sql-1699"><a href="#Generator.window_sql-1699"><span class="linenos">1699</span></a> <span class="n">first</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"first"</span><span class="p">)</span> +</span><span id="Generator.window_sql-1700"><a href="#Generator.window_sql-1700"><span class="linenos">1700</span></a> <span class="k">if</span> <span class="n">first</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.window_sql-1701"><a href="#Generator.window_sql-1701"><span class="linenos">1701</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.window_sql-1702"><a href="#Generator.window_sql-1702"><span class="linenos">1702</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.window_sql-1703"><a href="#Generator.window_sql-1703"><span class="linenos">1703</span></a> <span class="n">first</span> <span class="o">=</span> <span class="s2">"FIRST"</span> <span class="k">if</span> <span class="n">first</span> <span class="k">else</span> <span class="s2">"LAST"</span> +</span><span id="Generator.window_sql-1704"><a href="#Generator.window_sql-1704"><span class="linenos">1704</span></a> +</span><span id="Generator.window_sql-1705"><a href="#Generator.window_sql-1705"><span class="linenos">1705</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">partition</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">order</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">spec</span> <span class="ow">and</span> <span class="n">alias</span><span class="p">:</span> +</span><span id="Generator.window_sql-1706"><a href="#Generator.window_sql-1706"><span class="linenos">1706</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.window_sql-1707"><a href="#Generator.window_sql-1707"><span class="linenos">1707</span></a> +</span><span id="Generator.window_sql-1708"><a href="#Generator.window_sql-1708"><span class="linenos">1708</span></a> <span class="n">args</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="p">(</span><span class="n">alias</span><span class="p">,</span> <span class="n">first</span><span class="p">,</span> <span class="n">partition</span><span class="p">,</span> <span class="n">order</span><span class="p">,</span> <span class="n">spec</span><span class="p">)</span> <span class="k">if</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="Generator.window_sql-1709"><a href="#Generator.window_sql-1709"><span class="linenos">1709</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> (</span><span class="si">{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -8962,9 +9130,9 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.partition_by_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.partition_by_sql-1678"><a href="#Generator.partition_by_sql-1678"><span class="linenos">1678</span></a> <span class="k">def</span> <span class="nf">partition_by_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.partition_by_sql-1679"><a href="#Generator.partition_by_sql-1679"><span class="linenos">1679</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"partition_by"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.partition_by_sql-1680"><a href="#Generator.partition_by_sql-1680"><span class="linenos">1680</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.partition_by_sql-1711"><a href="#Generator.partition_by_sql-1711"><span class="linenos">1711</span></a> <span class="k">def</span> <span class="nf">partition_by_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.partition_by_sql-1712"><a href="#Generator.partition_by_sql-1712"><span class="linenos">1712</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"partition_by"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.partition_by_sql-1713"><a href="#Generator.partition_by_sql-1713"><span class="linenos">1713</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PARTITION BY </span><span class="si">{</span><span class="n">partition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">partition</span> <span class="k">else</span> <span class="s2">""</span> </span></pre></div> @@ -8982,14 +9150,14 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.windowspec_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.windowspec_sql-1682"><a href="#Generator.windowspec_sql-1682"><span class="linenos">1682</span></a> <span class="k">def</span> <span class="nf">windowspec_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WindowSpec</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.windowspec_sql-1683"><a href="#Generator.windowspec_sql-1683"><span class="linenos">1683</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator.windowspec_sql-1684"><a href="#Generator.windowspec_sql-1684"><span class="linenos">1684</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"start_side"</span><span class="p">),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator.windowspec_sql-1685"><a href="#Generator.windowspec_sql-1685"><span class="linenos">1685</span></a> <span class="n">end</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.windowspec_sql-1686"><a href="#Generator.windowspec_sql-1686"><span class="linenos">1686</span></a> <span class="n">csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"end"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"end_side"</span><span class="p">),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator.windowspec_sql-1687"><a href="#Generator.windowspec_sql-1687"><span class="linenos">1687</span></a> <span class="ow">or</span> <span class="s2">"CURRENT ROW"</span> -</span><span id="Generator.windowspec_sql-1688"><a href="#Generator.windowspec_sql-1688"><span class="linenos">1688</span></a> <span class="p">)</span> -</span><span id="Generator.windowspec_sql-1689"><a href="#Generator.windowspec_sql-1689"><span class="linenos">1689</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">end</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.windowspec_sql-1715"><a href="#Generator.windowspec_sql-1715"><span class="linenos">1715</span></a> <span class="k">def</span> <span class="nf">windowspec_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WindowSpec</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.windowspec_sql-1716"><a href="#Generator.windowspec_sql-1716"><span class="linenos">1716</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator.windowspec_sql-1717"><a href="#Generator.windowspec_sql-1717"><span class="linenos">1717</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"start_side"</span><span class="p">),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator.windowspec_sql-1718"><a href="#Generator.windowspec_sql-1718"><span class="linenos">1718</span></a> <span class="n">end</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.windowspec_sql-1719"><a href="#Generator.windowspec_sql-1719"><span class="linenos">1719</span></a> <span class="n">csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"end"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"end_side"</span><span class="p">),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator.windowspec_sql-1720"><a href="#Generator.windowspec_sql-1720"><span class="linenos">1720</span></a> <span class="ow">or</span> <span class="s2">"CURRENT ROW"</span> +</span><span id="Generator.windowspec_sql-1721"><a href="#Generator.windowspec_sql-1721"><span class="linenos">1721</span></a> <span class="p">)</span> +</span><span id="Generator.windowspec_sql-1722"><a href="#Generator.windowspec_sql-1722"><span class="linenos">1722</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">start</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">end</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9007,10 +9175,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.withingroup_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.withingroup_sql-1691"><a href="#Generator.withingroup_sql-1691"><span class="linenos">1691</span></a> <span class="k">def</span> <span class="nf">withingroup_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.withingroup_sql-1692"><a href="#Generator.withingroup_sql-1692"><span class="linenos">1692</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.withingroup_sql-1693"><a href="#Generator.withingroup_sql-1693"><span class="linenos">1693</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)[</span><span class="mi">1</span><span class="p">:]</span> <span class="c1"># order has a leading space</span> -</span><span id="Generator.withingroup_sql-1694"><a href="#Generator.withingroup_sql-1694"><span class="linenos">1694</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> WITHIN GROUP (</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.withingroup_sql-1724"><a href="#Generator.withingroup_sql-1724"><span class="linenos">1724</span></a> <span class="k">def</span> <span class="nf">withingroup_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithinGroup</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.withingroup_sql-1725"><a href="#Generator.withingroup_sql-1725"><span class="linenos">1725</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.withingroup_sql-1726"><a href="#Generator.withingroup_sql-1726"><span class="linenos">1726</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)[</span><span class="mi">1</span><span class="p">:]</span> <span class="c1"># order has a leading space</span> +</span><span id="Generator.withingroup_sql-1727"><a href="#Generator.withingroup_sql-1727"><span class="linenos">1727</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> WITHIN GROUP (</span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -9028,11 +9196,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.between_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.between_sql-1696"><a href="#Generator.between_sql-1696"><span class="linenos">1696</span></a> <span class="k">def</span> <span class="nf">between_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.between_sql-1697"><a href="#Generator.between_sql-1697"><span class="linenos">1697</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.between_sql-1698"><a href="#Generator.between_sql-1698"><span class="linenos">1698</span></a> <span class="n">low</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"low"</span><span class="p">)</span> -</span><span id="Generator.between_sql-1699"><a href="#Generator.between_sql-1699"><span class="linenos">1699</span></a> <span class="n">high</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"high"</span><span class="p">)</span> -</span><span id="Generator.between_sql-1700"><a href="#Generator.between_sql-1700"><span class="linenos">1700</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">low</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">high</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.between_sql-1729"><a href="#Generator.between_sql-1729"><span class="linenos">1729</span></a> <span class="k">def</span> <span class="nf">between_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.between_sql-1730"><a href="#Generator.between_sql-1730"><span class="linenos">1730</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.between_sql-1731"><a href="#Generator.between_sql-1731"><span class="linenos">1731</span></a> <span class="n">low</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"low"</span><span class="p">)</span> +</span><span id="Generator.between_sql-1732"><a href="#Generator.between_sql-1732"><span class="linenos">1732</span></a> <span class="n">high</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"high"</span><span class="p">)</span> +</span><span id="Generator.between_sql-1733"><a href="#Generator.between_sql-1733"><span class="linenos">1733</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> BETWEEN </span><span class="si">{</span><span class="n">low</span><span class="si">}</span><span class="s2"> AND </span><span class="si">{</span><span class="n">high</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9050,11 +9218,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.bracket_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bracket_sql-1702"><a href="#Generator.bracket_sql-1702"><span class="linenos">1702</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.bracket_sql-1703"><a href="#Generator.bracket_sql-1703"><span class="linenos">1703</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">apply_index_offset</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">INDEX_OFFSET</span><span class="p">)</span> -</span><span id="Generator.bracket_sql-1704"><a href="#Generator.bracket_sql-1704"><span class="linenos">1704</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> -</span><span id="Generator.bracket_sql-1705"><a href="#Generator.bracket_sql-1705"><span class="linenos">1705</span></a> -</span><span id="Generator.bracket_sql-1706"><a href="#Generator.bracket_sql-1706"><span class="linenos">1706</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">[</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bracket_sql-1735"><a href="#Generator.bracket_sql-1735"><span class="linenos">1735</span></a> <span class="k">def</span> <span class="nf">bracket_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Bracket</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.bracket_sql-1736"><a href="#Generator.bracket_sql-1736"><span class="linenos">1736</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">apply_index_offset</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">INDEX_OFFSET</span><span class="p">)</span> +</span><span id="Generator.bracket_sql-1737"><a href="#Generator.bracket_sql-1737"><span class="linenos">1737</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator.bracket_sql-1738"><a href="#Generator.bracket_sql-1738"><span class="linenos">1738</span></a> +</span><span id="Generator.bracket_sql-1739"><a href="#Generator.bracket_sql-1739"><span class="linenos">1739</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">[</span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">]"</span> </span></pre></div> @@ -9072,8 +9240,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.all_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.all_sql-1708"><a href="#Generator.all_sql-1708"><span class="linenos">1708</span></a> <span class="k">def</span> <span class="nf">all_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">All</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.all_sql-1709"><a href="#Generator.all_sql-1709"><span class="linenos">1709</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALL </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.all_sql-1741"><a href="#Generator.all_sql-1741"><span class="linenos">1741</span></a> <span class="k">def</span> <span class="nf">all_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">All</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.all_sql-1742"><a href="#Generator.all_sql-1742"><span class="linenos">1742</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALL </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9091,11 +9259,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.any_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.any_sql-1711"><a href="#Generator.any_sql-1711"><span class="linenos">1711</span></a> <span class="k">def</span> <span class="nf">any_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.any_sql-1712"><a href="#Generator.any_sql-1712"><span class="linenos">1712</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.any_sql-1713"><a href="#Generator.any_sql-1713"><span class="linenos">1713</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="Generator.any_sql-1714"><a href="#Generator.any_sql-1714"><span class="linenos">1714</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="Generator.any_sql-1715"><a href="#Generator.any_sql-1715"><span class="linenos">1715</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ANY </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.any_sql-1744"><a href="#Generator.any_sql-1744"><span class="linenos">1744</span></a> <span class="k">def</span> <span class="nf">any_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.any_sql-1745"><a href="#Generator.any_sql-1745"><span class="linenos">1745</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.any_sql-1746"><a href="#Generator.any_sql-1746"><span class="linenos">1746</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="Generator.any_sql-1747"><a href="#Generator.any_sql-1747"><span class="linenos">1747</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="Generator.any_sql-1748"><a href="#Generator.any_sql-1748"><span class="linenos">1748</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ANY </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9113,8 +9281,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.exists_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.exists_sql-1717"><a href="#Generator.exists_sql-1717"><span class="linenos">1717</span></a> <span class="k">def</span> <span class="nf">exists_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Exists</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.exists_sql-1718"><a href="#Generator.exists_sql-1718"><span class="linenos">1718</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXISTS</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.exists_sql-1750"><a href="#Generator.exists_sql-1750"><span class="linenos">1750</span></a> <span class="k">def</span> <span class="nf">exists_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Exists</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.exists_sql-1751"><a href="#Generator.exists_sql-1751"><span class="linenos">1751</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXISTS</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9132,25 +9300,25 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.case_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.case_sql-1720"><a href="#Generator.case_sql-1720"><span class="linenos">1720</span></a> <span class="k">def</span> <span class="nf">case_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.case_sql-1721"><a href="#Generator.case_sql-1721"><span class="linenos">1721</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.case_sql-1722"><a href="#Generator.case_sql-1722"><span class="linenos">1722</span></a> <span class="n">statements</span> <span class="o">=</span> <span class="p">[</span><span class="sa">f</span><span class="s2">"CASE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">"CASE"</span><span class="p">]</span> -</span><span id="Generator.case_sql-1723"><a href="#Generator.case_sql-1723"><span class="linenos">1723</span></a> -</span><span id="Generator.case_sql-1724"><a href="#Generator.case_sql-1724"><span class="linenos">1724</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"ifs"</span><span class="p">]:</span> -</span><span id="Generator.case_sql-1725"><a href="#Generator.case_sql-1725"><span class="linenos">1725</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"WHEN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.case_sql-1726"><a href="#Generator.case_sql-1726"><span class="linenos">1726</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"THEN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'true'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.case_sql-1727"><a href="#Generator.case_sql-1727"><span class="linenos">1727</span></a> -</span><span id="Generator.case_sql-1728"><a href="#Generator.case_sql-1728"><span class="linenos">1728</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">)</span> -</span><span id="Generator.case_sql-1729"><a href="#Generator.case_sql-1729"><span class="linenos">1729</span></a> -</span><span id="Generator.case_sql-1730"><a href="#Generator.case_sql-1730"><span class="linenos">1730</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="Generator.case_sql-1731"><a href="#Generator.case_sql-1731"><span class="linenos">1731</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"ELSE </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.case_sql-1732"><a href="#Generator.case_sql-1732"><span class="linenos">1732</span></a> -</span><span id="Generator.case_sql-1733"><a href="#Generator.case_sql-1733"><span class="linenos">1733</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"END"</span><span class="p">)</span> -</span><span id="Generator.case_sql-1734"><a href="#Generator.case_sql-1734"><span class="linenos">1734</span></a> -</span><span id="Generator.case_sql-1735"><a href="#Generator.case_sql-1735"><span class="linenos">1735</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">statements</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span><span class="p">:</span> -</span><span id="Generator.case_sql-1736"><a href="#Generator.case_sql-1736"><span class="linenos">1736</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">statements</span><span class="p">),</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">skip_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.case_sql-1737"><a href="#Generator.case_sql-1737"><span class="linenos">1737</span></a> -</span><span id="Generator.case_sql-1738"><a href="#Generator.case_sql-1738"><span class="linenos">1738</span></a> <span class="k">return</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">statements</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.case_sql-1753"><a href="#Generator.case_sql-1753"><span class="linenos">1753</span></a> <span class="k">def</span> <span class="nf">case_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.case_sql-1754"><a href="#Generator.case_sql-1754"><span class="linenos">1754</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.case_sql-1755"><a href="#Generator.case_sql-1755"><span class="linenos">1755</span></a> <span class="n">statements</span> <span class="o">=</span> <span class="p">[</span><span class="sa">f</span><span class="s2">"CASE </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">"CASE"</span><span class="p">]</span> +</span><span id="Generator.case_sql-1756"><a href="#Generator.case_sql-1756"><span class="linenos">1756</span></a> +</span><span id="Generator.case_sql-1757"><a href="#Generator.case_sql-1757"><span class="linenos">1757</span></a> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"ifs"</span><span class="p">]:</span> +</span><span id="Generator.case_sql-1758"><a href="#Generator.case_sql-1758"><span class="linenos">1758</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"WHEN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.case_sql-1759"><a href="#Generator.case_sql-1759"><span class="linenos">1759</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"THEN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span><span class="w"> </span><span class="s1">'true'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.case_sql-1760"><a href="#Generator.case_sql-1760"><span class="linenos">1760</span></a> +</span><span id="Generator.case_sql-1761"><a href="#Generator.case_sql-1761"><span class="linenos">1761</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">)</span> +</span><span id="Generator.case_sql-1762"><a href="#Generator.case_sql-1762"><span class="linenos">1762</span></a> +</span><span id="Generator.case_sql-1763"><a href="#Generator.case_sql-1763"><span class="linenos">1763</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> +</span><span id="Generator.case_sql-1764"><a href="#Generator.case_sql-1764"><span class="linenos">1764</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"ELSE </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.case_sql-1765"><a href="#Generator.case_sql-1765"><span class="linenos">1765</span></a> +</span><span id="Generator.case_sql-1766"><a href="#Generator.case_sql-1766"><span class="linenos">1766</span></a> <span class="n">statements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"END"</span><span class="p">)</span> +</span><span id="Generator.case_sql-1767"><a href="#Generator.case_sql-1767"><span class="linenos">1767</span></a> +</span><span id="Generator.case_sql-1768"><a href="#Generator.case_sql-1768"><span class="linenos">1768</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">statements</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span><span class="p">:</span> +</span><span id="Generator.case_sql-1769"><a href="#Generator.case_sql-1769"><span class="linenos">1769</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">statements</span><span class="p">),</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">skip_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.case_sql-1770"><a href="#Generator.case_sql-1770"><span class="linenos">1770</span></a> +</span><span id="Generator.case_sql-1771"><a href="#Generator.case_sql-1771"><span class="linenos">1771</span></a> <span class="k">return</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">statements</span><span class="p">)</span> </span></pre></div> @@ -9168,10 +9336,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.constraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.constraint_sql-1740"><a href="#Generator.constraint_sql-1740"><span class="linenos">1740</span></a> <span class="k">def</span> <span class="nf">constraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Constraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.constraint_sql-1741"><a href="#Generator.constraint_sql-1741"><span class="linenos">1741</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.constraint_sql-1742"><a href="#Generator.constraint_sql-1742"><span class="linenos">1742</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.constraint_sql-1743"><a href="#Generator.constraint_sql-1743"><span class="linenos">1743</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.constraint_sql-1773"><a href="#Generator.constraint_sql-1773"><span class="linenos">1773</span></a> <span class="k">def</span> <span class="nf">constraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Constraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.constraint_sql-1774"><a href="#Generator.constraint_sql-1774"><span class="linenos">1774</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.constraint_sql-1775"><a href="#Generator.constraint_sql-1775"><span class="linenos">1775</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.constraint_sql-1776"><a href="#Generator.constraint_sql-1776"><span class="linenos">1776</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9189,10 +9357,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.nextvaluefor_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.nextvaluefor_sql-1745"><a href="#Generator.nextvaluefor_sql-1745"><span class="linenos">1745</span></a> <span class="k">def</span> <span class="nf">nextvaluefor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NextValueFor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.nextvaluefor_sql-1746"><a href="#Generator.nextvaluefor_sql-1746"><span class="linenos">1746</span></a> <span class="n">order</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"order"</span><span class="p">)</span> -</span><span id="Generator.nextvaluefor_sql-1747"><a href="#Generator.nextvaluefor_sql-1747"><span class="linenos">1747</span></a> <span class="n">order</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OVER (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.nextvaluefor_sql-1748"><a href="#Generator.nextvaluefor_sql-1748"><span class="linenos">1748</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NEXT VALUE FOR </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">order</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.nextvaluefor_sql-1778"><a href="#Generator.nextvaluefor_sql-1778"><span class="linenos">1778</span></a> <span class="k">def</span> <span class="nf">nextvaluefor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NextValueFor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.nextvaluefor_sql-1779"><a href="#Generator.nextvaluefor_sql-1779"><span class="linenos">1779</span></a> <span class="n">order</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"order"</span><span class="p">)</span> +</span><span id="Generator.nextvaluefor_sql-1780"><a href="#Generator.nextvaluefor_sql-1780"><span class="linenos">1780</span></a> <span class="n">order</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" OVER (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">order_sql</span><span class="p">(</span><span class="n">order</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">order</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.nextvaluefor_sql-1781"><a href="#Generator.nextvaluefor_sql-1781"><span class="linenos">1781</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NEXT VALUE FOR </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">order</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9210,10 +9378,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.extract_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.extract_sql-1750"><a href="#Generator.extract_sql-1750"><span class="linenos">1750</span></a> <span class="k">def</span> <span class="nf">extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.extract_sql-1751"><a href="#Generator.extract_sql-1751"><span class="linenos">1751</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.extract_sql-1752"><a href="#Generator.extract_sql-1752"><span class="linenos">1752</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator.extract_sql-1753"><a href="#Generator.extract_sql-1753"><span class="linenos">1753</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXTRACT(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FROM </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.extract_sql-1783"><a href="#Generator.extract_sql-1783"><span class="linenos">1783</span></a> <span class="k">def</span> <span class="nf">extract_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Extract</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.extract_sql-1784"><a href="#Generator.extract_sql-1784"><span class="linenos">1784</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.extract_sql-1785"><a href="#Generator.extract_sql-1785"><span class="linenos">1785</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator.extract_sql-1786"><a href="#Generator.extract_sql-1786"><span class="linenos">1786</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"EXTRACT(</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FROM </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -9231,15 +9399,15 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.trim_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.trim_sql-1755"><a href="#Generator.trim_sql-1755"><span class="linenos">1755</span></a> <span class="k">def</span> <span class="nf">trim_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.trim_sql-1756"><a href="#Generator.trim_sql-1756"><span class="linenos">1756</span></a> <span class="n">trim_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> -</span><span id="Generator.trim_sql-1757"><a href="#Generator.trim_sql-1757"><span class="linenos">1757</span></a> -</span><span id="Generator.trim_sql-1758"><a href="#Generator.trim_sql-1758"><span class="linenos">1758</span></a> <span class="k">if</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"LEADING"</span><span class="p">:</span> -</span><span id="Generator.trim_sql-1759"><a href="#Generator.trim_sql-1759"><span class="linenos">1759</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LTRIM"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="Generator.trim_sql-1760"><a href="#Generator.trim_sql-1760"><span class="linenos">1760</span></a> <span class="k">elif</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"TRAILING"</span><span class="p">:</span> -</span><span id="Generator.trim_sql-1761"><a href="#Generator.trim_sql-1761"><span class="linenos">1761</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"RTRIM"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="Generator.trim_sql-1762"><a href="#Generator.trim_sql-1762"><span class="linenos">1762</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.trim_sql-1763"><a href="#Generator.trim_sql-1763"><span class="linenos">1763</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.trim_sql-1788"><a href="#Generator.trim_sql-1788"><span class="linenos">1788</span></a> <span class="k">def</span> <span class="nf">trim_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.trim_sql-1789"><a href="#Generator.trim_sql-1789"><span class="linenos">1789</span></a> <span class="n">trim_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"position"</span><span class="p">)</span> +</span><span id="Generator.trim_sql-1790"><a href="#Generator.trim_sql-1790"><span class="linenos">1790</span></a> +</span><span id="Generator.trim_sql-1791"><a href="#Generator.trim_sql-1791"><span class="linenos">1791</span></a> <span class="k">if</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"LEADING"</span><span class="p">:</span> +</span><span id="Generator.trim_sql-1792"><a href="#Generator.trim_sql-1792"><span class="linenos">1792</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LTRIM"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="Generator.trim_sql-1793"><a href="#Generator.trim_sql-1793"><span class="linenos">1793</span></a> <span class="k">elif</span> <span class="n">trim_type</span> <span class="o">==</span> <span class="s2">"TRAILING"</span><span class="p">:</span> +</span><span id="Generator.trim_sql-1794"><a href="#Generator.trim_sql-1794"><span class="linenos">1794</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"RTRIM"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="Generator.trim_sql-1795"><a href="#Generator.trim_sql-1795"><span class="linenos">1795</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.trim_sql-1796"><a href="#Generator.trim_sql-1796"><span class="linenos">1796</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TRIM"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -9257,11 +9425,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.safeconcat_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.safeconcat_sql-1765"><a href="#Generator.safeconcat_sql-1765"><span class="linenos">1765</span></a> <span class="k">def</span> <span class="nf">safeconcat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.safeconcat_sql-1766"><a href="#Generator.safeconcat_sql-1766"><span class="linenos">1766</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="Generator.safeconcat_sql-1767"><a href="#Generator.safeconcat_sql-1767"><span class="linenos">1767</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> -</span><span id="Generator.safeconcat_sql-1768"><a href="#Generator.safeconcat_sql-1768"><span class="linenos">1768</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> -</span><span id="Generator.safeconcat_sql-1769"><a href="#Generator.safeconcat_sql-1769"><span class="linenos">1769</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.safeconcat_sql-1798"><a href="#Generator.safeconcat_sql-1798"><span class="linenos">1798</span></a> <span class="k">def</span> <span class="nf">safeconcat_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.safeconcat_sql-1799"><a href="#Generator.safeconcat_sql-1799"><span class="linenos">1799</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="Generator.safeconcat_sql-1800"><a href="#Generator.safeconcat_sql-1800"><span class="linenos">1800</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> +</span><span id="Generator.safeconcat_sql-1801"><a href="#Generator.safeconcat_sql-1801"><span class="linenos">1801</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator.safeconcat_sql-1802"><a href="#Generator.safeconcat_sql-1802"><span class="linenos">1802</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span><span class="p">)</span> </span></pre></div> @@ -9279,9 +9447,9 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.check_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.check_sql-1771"><a href="#Generator.check_sql-1771"><span class="linenos">1771</span></a> <span class="k">def</span> <span class="nf">check_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Check</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.check_sql-1772"><a href="#Generator.check_sql-1772"><span class="linenos">1772</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.check_sql-1773"><a href="#Generator.check_sql-1773"><span class="linenos">1773</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECK (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.check_sql-1804"><a href="#Generator.check_sql-1804"><span class="linenos">1804</span></a> <span class="k">def</span> <span class="nf">check_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Check</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.check_sql-1805"><a href="#Generator.check_sql-1805"><span class="linenos">1805</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.check_sql-1806"><a href="#Generator.check_sql-1806"><span class="linenos">1806</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CHECK (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -9299,15 +9467,15 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.foreignkey_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.foreignkey_sql-1775"><a href="#Generator.foreignkey_sql-1775"><span class="linenos">1775</span></a> <span class="k">def</span> <span class="nf">foreignkey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.foreignkey_sql-1776"><a href="#Generator.foreignkey_sql-1776"><span class="linenos">1776</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.foreignkey_sql-1777"><a href="#Generator.foreignkey_sql-1777"><span class="linenos">1777</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"reference"</span><span class="p">)</span> -</span><span id="Generator.foreignkey_sql-1778"><a href="#Generator.foreignkey_sql-1778"><span class="linenos">1778</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">reference</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">reference</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.foreignkey_sql-1779"><a href="#Generator.foreignkey_sql-1779"><span class="linenos">1779</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"delete"</span><span class="p">)</span> -</span><span id="Generator.foreignkey_sql-1780"><a href="#Generator.foreignkey_sql-1780"><span class="linenos">1780</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON DELETE </span><span class="si">{</span><span class="n">delete</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">delete</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.foreignkey_sql-1781"><a href="#Generator.foreignkey_sql-1781"><span class="linenos">1781</span></a> <span class="n">update</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"update"</span><span class="p">)</span> -</span><span id="Generator.foreignkey_sql-1782"><a href="#Generator.foreignkey_sql-1782"><span class="linenos">1782</span></a> <span class="n">update</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON UPDATE </span><span class="si">{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">update</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.foreignkey_sql-1783"><a href="#Generator.foreignkey_sql-1783"><span class="linenos">1783</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FOREIGN KEY (</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">reference</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.foreignkey_sql-1808"><a href="#Generator.foreignkey_sql-1808"><span class="linenos">1808</span></a> <span class="k">def</span> <span class="nf">foreignkey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.foreignkey_sql-1809"><a href="#Generator.foreignkey_sql-1809"><span class="linenos">1809</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.foreignkey_sql-1810"><a href="#Generator.foreignkey_sql-1810"><span class="linenos">1810</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"reference"</span><span class="p">)</span> +</span><span id="Generator.foreignkey_sql-1811"><a href="#Generator.foreignkey_sql-1811"><span class="linenos">1811</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">reference</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">reference</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.foreignkey_sql-1812"><a href="#Generator.foreignkey_sql-1812"><span class="linenos">1812</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"delete"</span><span class="p">)</span> +</span><span id="Generator.foreignkey_sql-1813"><a href="#Generator.foreignkey_sql-1813"><span class="linenos">1813</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON DELETE </span><span class="si">{</span><span class="n">delete</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">delete</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.foreignkey_sql-1814"><a href="#Generator.foreignkey_sql-1814"><span class="linenos">1814</span></a> <span class="n">update</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"update"</span><span class="p">)</span> +</span><span id="Generator.foreignkey_sql-1815"><a href="#Generator.foreignkey_sql-1815"><span class="linenos">1815</span></a> <span class="n">update</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON UPDATE </span><span class="si">{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">update</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.foreignkey_sql-1816"><a href="#Generator.foreignkey_sql-1816"><span class="linenos">1816</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"FOREIGN KEY (</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">reference</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">update</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9325,11 +9493,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.primarykey_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.primarykey_sql-1785"><a href="#Generator.primarykey_sql-1785"><span class="linenos">1785</span></a> <span class="k">def</span> <span class="nf">primarykey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.primarykey_sql-1786"><a href="#Generator.primarykey_sql-1786"><span class="linenos">1786</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.primarykey_sql-1787"><a href="#Generator.primarykey_sql-1787"><span class="linenos">1787</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator.primarykey_sql-1788"><a href="#Generator.primarykey_sql-1788"><span class="linenos">1788</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.primarykey_sql-1789"><a href="#Generator.primarykey_sql-1789"><span class="linenos">1789</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY (</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.primarykey_sql-1818"><a href="#Generator.primarykey_sql-1818"><span class="linenos">1818</span></a> <span class="k">def</span> <span class="nf">primarykey_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.primarykey_sql-1819"><a href="#Generator.primarykey_sql-1819"><span class="linenos">1819</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.primarykey_sql-1820"><a href="#Generator.primarykey_sql-1820"><span class="linenos">1820</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator.primarykey_sql-1821"><a href="#Generator.primarykey_sql-1821"><span class="linenos">1821</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.primarykey_sql-1822"><a href="#Generator.primarykey_sql-1822"><span class="linenos">1822</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"PRIMARY KEY (</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9347,8 +9515,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.if_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.if_sql-1791"><a href="#Generator.if_sql-1791"><span class="linenos">1791</span></a> <span class="k">def</span> <span class="nf">if_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.if_sql-1792"><a href="#Generator.if_sql-1792"><span class="linenos">1792</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">case_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">(</span><span class="n">ifs</span><span class="o">=</span><span class="p">[</span><span class="n">expression</span><span class="p">],</span> <span class="n">default</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"false"</span><span class="p">)))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.if_sql-1824"><a href="#Generator.if_sql-1824"><span class="linenos">1824</span></a> <span class="k">def</span> <span class="nf">if_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.if_sql-1825"><a href="#Generator.if_sql-1825"><span class="linenos">1825</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">case_sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">(</span><span class="n">ifs</span><span class="o">=</span><span class="p">[</span><span class="n">expression</span><span class="p">],</span> <span class="n">default</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"false"</span><span class="p">)))</span> </span></pre></div> @@ -9366,10 +9534,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.matchagainst_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.matchagainst_sql-1794"><a href="#Generator.matchagainst_sql-1794"><span class="linenos">1794</span></a> <span class="k">def</span> <span class="nf">matchagainst_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchAgainst</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.matchagainst_sql-1795"><a href="#Generator.matchagainst_sql-1795"><span class="linenos">1795</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modifier"</span><span class="p">)</span> -</span><span id="Generator.matchagainst_sql-1796"><a href="#Generator.matchagainst_sql-1796"><span class="linenos">1796</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">modifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modifier</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.matchagainst_sql-1797"><a href="#Generator.matchagainst_sql-1797"><span class="linenos">1797</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'MATCH'</span><span class="p">,</span><span class="w"> </span><span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span><span class="si">}</span><span class="s2"> AGAINST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">modifier</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.matchagainst_sql-1827"><a href="#Generator.matchagainst_sql-1827"><span class="linenos">1827</span></a> <span class="k">def</span> <span class="nf">matchagainst_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MatchAgainst</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.matchagainst_sql-1828"><a href="#Generator.matchagainst_sql-1828"><span class="linenos">1828</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"modifier"</span><span class="p">)</span> +</span><span id="Generator.matchagainst_sql-1829"><a href="#Generator.matchagainst_sql-1829"><span class="linenos">1829</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">modifier</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">modifier</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.matchagainst_sql-1830"><a href="#Generator.matchagainst_sql-1830"><span class="linenos">1830</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s1">'MATCH'</span><span class="p">,</span><span class="w"> </span><span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span><span class="si">}</span><span class="s2"> AGAINST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">modifier</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -9387,8 +9555,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.jsonkeyvalue_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsonkeyvalue_sql-1799"><a href="#Generator.jsonkeyvalue_sql-1799"><span class="linenos">1799</span></a> <span class="k">def</span> <span class="nf">jsonkeyvalue_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONKeyValue</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.jsonkeyvalue_sql-1800"><a href="#Generator.jsonkeyvalue_sql-1800"><span class="linenos">1800</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsonkeyvalue_sql-1832"><a href="#Generator.jsonkeyvalue_sql-1832"><span class="linenos">1832</span></a> <span class="k">def</span> <span class="nf">jsonkeyvalue_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONKeyValue</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.jsonkeyvalue_sql-1833"><a href="#Generator.jsonkeyvalue_sql-1833"><span class="linenos">1833</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9406,24 +9574,24 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.jsonobject_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsonobject_sql-1802"><a href="#Generator.jsonobject_sql-1802"><span class="linenos">1802</span></a> <span class="k">def</span> <span class="nf">jsonobject_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONObject</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.jsonobject_sql-1803"><a href="#Generator.jsonobject_sql-1803"><span class="linenos">1803</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"null_handling"</span><span class="p">)</span> -</span><span id="Generator.jsonobject_sql-1804"><a href="#Generator.jsonobject_sql-1804"><span class="linenos">1804</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.jsonobject_sql-1805"><a href="#Generator.jsonobject_sql-1805"><span class="linenos">1805</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unique_keys"</span><span class="p">)</span> -</span><span id="Generator.jsonobject_sql-1806"><a href="#Generator.jsonobject_sql-1806"><span class="linenos">1806</span></a> <span class="k">if</span> <span class="n">unique_keys</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.jsonobject_sql-1807"><a href="#Generator.jsonobject_sql-1807"><span class="linenos">1807</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">'WITH'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">unique_keys</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'WITHOUT'</span><span class="si">}</span><span class="s2"> UNIQUE KEYS"</span> -</span><span id="Generator.jsonobject_sql-1808"><a href="#Generator.jsonobject_sql-1808"><span class="linenos">1808</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.jsonobject_sql-1809"><a href="#Generator.jsonobject_sql-1809"><span class="linenos">1809</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.jsonobject_sql-1810"><a href="#Generator.jsonobject_sql-1810"><span class="linenos">1810</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"return_type"</span><span class="p">)</span> -</span><span id="Generator.jsonobject_sql-1811"><a href="#Generator.jsonobject_sql-1811"><span class="linenos">1811</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.jsonobject_sql-1812"><a href="#Generator.jsonobject_sql-1812"><span class="linenos">1812</span></a> <span class="n">format_json</span> <span class="o">=</span> <span class="s2">" FORMAT JSON"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"format_json"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.jsonobject_sql-1813"><a href="#Generator.jsonobject_sql-1813"><span class="linenos">1813</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"encoding"</span><span class="p">)</span> -</span><span id="Generator.jsonobject_sql-1814"><a href="#Generator.jsonobject_sql-1814"><span class="linenos">1814</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ENCODING </span><span class="si">{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">encoding</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.jsonobject_sql-1815"><a href="#Generator.jsonobject_sql-1815"><span class="linenos">1815</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="Generator.jsonobject_sql-1816"><a href="#Generator.jsonobject_sql-1816"><span class="linenos">1816</span></a> <span class="s2">"JSON_OBJECT"</span><span class="p">,</span> -</span><span id="Generator.jsonobject_sql-1817"><a href="#Generator.jsonobject_sql-1817"><span class="linenos">1817</span></a> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Generator.jsonobject_sql-1818"><a href="#Generator.jsonobject_sql-1818"><span class="linenos">1818</span></a> <span class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">null_handling</span><span class="si">}{</span><span class="n">unique_keys</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">format_json</span><span class="si">}{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> -</span><span id="Generator.jsonobject_sql-1819"><a href="#Generator.jsonobject_sql-1819"><span class="linenos">1819</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsonobject_sql-1835"><a href="#Generator.jsonobject_sql-1835"><span class="linenos">1835</span></a> <span class="k">def</span> <span class="nf">jsonobject_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JSONObject</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.jsonobject_sql-1836"><a href="#Generator.jsonobject_sql-1836"><span class="linenos">1836</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"null_handling"</span><span class="p">)</span> +</span><span id="Generator.jsonobject_sql-1837"><a href="#Generator.jsonobject_sql-1837"><span class="linenos">1837</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">null_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">null_handling</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.jsonobject_sql-1838"><a href="#Generator.jsonobject_sql-1838"><span class="linenos">1838</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unique_keys"</span><span class="p">)</span> +</span><span id="Generator.jsonobject_sql-1839"><a href="#Generator.jsonobject_sql-1839"><span class="linenos">1839</span></a> <span class="k">if</span> <span class="n">unique_keys</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.jsonobject_sql-1840"><a href="#Generator.jsonobject_sql-1840"><span class="linenos">1840</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="s1">'WITH'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">unique_keys</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'WITHOUT'</span><span class="si">}</span><span class="s2"> UNIQUE KEYS"</span> +</span><span id="Generator.jsonobject_sql-1841"><a href="#Generator.jsonobject_sql-1841"><span class="linenos">1841</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.jsonobject_sql-1842"><a href="#Generator.jsonobject_sql-1842"><span class="linenos">1842</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.jsonobject_sql-1843"><a href="#Generator.jsonobject_sql-1843"><span class="linenos">1843</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"return_type"</span><span class="p">)</span> +</span><span id="Generator.jsonobject_sql-1844"><a href="#Generator.jsonobject_sql-1844"><span class="linenos">1844</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RETURNING </span><span class="si">{</span><span class="n">return_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">return_type</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.jsonobject_sql-1845"><a href="#Generator.jsonobject_sql-1845"><span class="linenos">1845</span></a> <span class="n">format_json</span> <span class="o">=</span> <span class="s2">" FORMAT JSON"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"format_json"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.jsonobject_sql-1846"><a href="#Generator.jsonobject_sql-1846"><span class="linenos">1846</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"encoding"</span><span class="p">)</span> +</span><span id="Generator.jsonobject_sql-1847"><a href="#Generator.jsonobject_sql-1847"><span class="linenos">1847</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ENCODING </span><span class="si">{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">encoding</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.jsonobject_sql-1848"><a href="#Generator.jsonobject_sql-1848"><span class="linenos">1848</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="Generator.jsonobject_sql-1849"><a href="#Generator.jsonobject_sql-1849"><span class="linenos">1849</span></a> <span class="s2">"JSON_OBJECT"</span><span class="p">,</span> +</span><span id="Generator.jsonobject_sql-1850"><a href="#Generator.jsonobject_sql-1850"><span class="linenos">1850</span></a> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Generator.jsonobject_sql-1851"><a href="#Generator.jsonobject_sql-1851"><span class="linenos">1851</span></a> <span class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">null_handling</span><span class="si">}{</span><span class="n">unique_keys</span><span class="si">}{</span><span class="n">return_type</span><span class="si">}{</span><span class="n">format_json</span><span class="si">}{</span><span class="n">encoding</span><span class="si">}</span><span class="s2">)"</span><span class="p">,</span> +</span><span id="Generator.jsonobject_sql-1852"><a href="#Generator.jsonobject_sql-1852"><span class="linenos">1852</span></a> <span class="p">)</span> </span></pre></div> @@ -9441,13 +9609,13 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.openjsoncolumndef_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.openjsoncolumndef_sql-1821"><a href="#Generator.openjsoncolumndef_sql-1821"><span class="linenos">1821</span></a> <span class="k">def</span> <span class="nf">openjsoncolumndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSONColumnDef</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.openjsoncolumndef_sql-1822"><a href="#Generator.openjsoncolumndef_sql-1822"><span class="linenos">1822</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.openjsoncolumndef_sql-1823"><a href="#Generator.openjsoncolumndef_sql-1823"><span class="linenos">1823</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator.openjsoncolumndef_sql-1824"><a href="#Generator.openjsoncolumndef_sql-1824"><span class="linenos">1824</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> -</span><span id="Generator.openjsoncolumndef_sql-1825"><a href="#Generator.openjsoncolumndef_sql-1825"><span class="linenos">1825</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.openjsoncolumndef_sql-1826"><a href="#Generator.openjsoncolumndef_sql-1826"><span class="linenos">1826</span></a> <span class="n">as_json</span> <span class="o">=</span> <span class="s2">" AS JSON"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"as_json"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.openjsoncolumndef_sql-1827"><a href="#Generator.openjsoncolumndef_sql-1827"><span class="linenos">1827</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">path</span><span class="si">}{</span><span class="n">as_json</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.openjsoncolumndef_sql-1854"><a href="#Generator.openjsoncolumndef_sql-1854"><span class="linenos">1854</span></a> <span class="k">def</span> <span class="nf">openjsoncolumndef_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSONColumnDef</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.openjsoncolumndef_sql-1855"><a href="#Generator.openjsoncolumndef_sql-1855"><span class="linenos">1855</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.openjsoncolumndef_sql-1856"><a href="#Generator.openjsoncolumndef_sql-1856"><span class="linenos">1856</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator.openjsoncolumndef_sql-1857"><a href="#Generator.openjsoncolumndef_sql-1857"><span class="linenos">1857</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> +</span><span id="Generator.openjsoncolumndef_sql-1858"><a href="#Generator.openjsoncolumndef_sql-1858"><span class="linenos">1858</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.openjsoncolumndef_sql-1859"><a href="#Generator.openjsoncolumndef_sql-1859"><span class="linenos">1859</span></a> <span class="n">as_json</span> <span class="o">=</span> <span class="s2">" AS JSON"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"as_json"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.openjsoncolumndef_sql-1860"><a href="#Generator.openjsoncolumndef_sql-1860"><span class="linenos">1860</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">path</span><span class="si">}{</span><span class="n">as_json</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9465,17 +9633,17 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.openjson_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.openjson_sql-1829"><a href="#Generator.openjson_sql-1829"><span class="linenos">1829</span></a> <span class="k">def</span> <span class="nf">openjson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.openjson_sql-1830"><a href="#Generator.openjson_sql-1830"><span class="linenos">1830</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.openjson_sql-1831"><a href="#Generator.openjson_sql-1831"><span class="linenos">1831</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> -</span><span id="Generator.openjson_sql-1832"><a href="#Generator.openjson_sql-1832"><span class="linenos">1832</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.openjson_sql-1833"><a href="#Generator.openjson_sql-1833"><span class="linenos">1833</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.openjson_sql-1834"><a href="#Generator.openjson_sql-1834"><span class="linenos">1834</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.openjson_sql-1835"><a href="#Generator.openjson_sql-1835"><span class="linenos">1835</span></a> <span class="sa">f</span><span class="s2">" WITH (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">expressions</span><span class="p">),</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.openjson_sql-1836"><a href="#Generator.openjson_sql-1836"><span class="linenos">1836</span></a> <span class="k">if</span> <span class="n">expressions</span> -</span><span id="Generator.openjson_sql-1837"><a href="#Generator.openjson_sql-1837"><span class="linenos">1837</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.openjson_sql-1838"><a href="#Generator.openjson_sql-1838"><span class="linenos">1838</span></a> <span class="p">)</span> -</span><span id="Generator.openjson_sql-1839"><a href="#Generator.openjson_sql-1839"><span class="linenos">1839</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"OPENJSON(</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">path</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">with_</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.openjson_sql-1862"><a href="#Generator.openjson_sql-1862"><span class="linenos">1862</span></a> <span class="k">def</span> <span class="nf">openjson_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.openjson_sql-1863"><a href="#Generator.openjson_sql-1863"><span class="linenos">1863</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.openjson_sql-1864"><a href="#Generator.openjson_sql-1864"><span class="linenos">1864</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> +</span><span id="Generator.openjson_sql-1865"><a href="#Generator.openjson_sql-1865"><span class="linenos">1865</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.openjson_sql-1866"><a href="#Generator.openjson_sql-1866"><span class="linenos">1866</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.openjson_sql-1867"><a href="#Generator.openjson_sql-1867"><span class="linenos">1867</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.openjson_sql-1868"><a href="#Generator.openjson_sql-1868"><span class="linenos">1868</span></a> <span class="sa">f</span><span class="s2">" WITH (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">expressions</span><span class="p">),</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.openjson_sql-1869"><a href="#Generator.openjson_sql-1869"><span class="linenos">1869</span></a> <span class="k">if</span> <span class="n">expressions</span> +</span><span id="Generator.openjson_sql-1870"><a href="#Generator.openjson_sql-1870"><span class="linenos">1870</span></a> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.openjson_sql-1871"><a href="#Generator.openjson_sql-1871"><span class="linenos">1871</span></a> <span class="p">)</span> +</span><span id="Generator.openjson_sql-1872"><a href="#Generator.openjson_sql-1872"><span class="linenos">1872</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"OPENJSON(</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">path</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">with_</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9493,22 +9661,22 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.in_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.in_sql-1841"><a href="#Generator.in_sql-1841"><span class="linenos">1841</span></a> <span class="k">def</span> <span class="nf">in_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">In</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.in_sql-1842"><a href="#Generator.in_sql-1842"><span class="linenos">1842</span></a> <span class="n">query</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"query"</span><span class="p">)</span> -</span><span id="Generator.in_sql-1843"><a href="#Generator.in_sql-1843"><span class="linenos">1843</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unnest"</span><span class="p">)</span> -</span><span id="Generator.in_sql-1844"><a href="#Generator.in_sql-1844"><span class="linenos">1844</span></a> <span class="n">field</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"field"</span><span class="p">)</span> -</span><span id="Generator.in_sql-1845"><a href="#Generator.in_sql-1845"><span class="linenos">1845</span></a> <span class="n">is_global</span> <span class="o">=</span> <span class="s2">" GLOBAL"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"is_global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.in_sql-1846"><a href="#Generator.in_sql-1846"><span class="linenos">1846</span></a> -</span><span id="Generator.in_sql-1847"><a href="#Generator.in_sql-1847"><span class="linenos">1847</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> -</span><span id="Generator.in_sql-1848"><a href="#Generator.in_sql-1848"><span class="linenos">1848</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">query</span><span class="p">)</span> -</span><span id="Generator.in_sql-1849"><a href="#Generator.in_sql-1849"><span class="linenos">1849</span></a> <span class="k">elif</span> <span class="n">unnest</span><span class="p">:</span> -</span><span id="Generator.in_sql-1850"><a href="#Generator.in_sql-1850"><span class="linenos">1850</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">in_unnest_op</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span> -</span><span id="Generator.in_sql-1851"><a href="#Generator.in_sql-1851"><span class="linenos">1851</span></a> <span class="k">elif</span> <span class="n">field</span><span class="p">:</span> -</span><span id="Generator.in_sql-1852"><a href="#Generator.in_sql-1852"><span class="linenos">1852</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">field</span><span class="p">)</span> -</span><span id="Generator.in_sql-1853"><a href="#Generator.in_sql-1853"><span class="linenos">1853</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.in_sql-1854"><a href="#Generator.in_sql-1854"><span class="linenos">1854</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.in_sql-1855"><a href="#Generator.in_sql-1855"><span class="linenos">1855</span></a> -</span><span id="Generator.in_sql-1856"><a href="#Generator.in_sql-1856"><span class="linenos">1856</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">is_global</span><span class="si">}</span><span class="s2"> IN </span><span class="si">{</span><span class="n">in_sql</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.in_sql-1874"><a href="#Generator.in_sql-1874"><span class="linenos">1874</span></a> <span class="k">def</span> <span class="nf">in_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">In</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.in_sql-1875"><a href="#Generator.in_sql-1875"><span class="linenos">1875</span></a> <span class="n">query</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"query"</span><span class="p">)</span> +</span><span id="Generator.in_sql-1876"><a href="#Generator.in_sql-1876"><span class="linenos">1876</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"unnest"</span><span class="p">)</span> +</span><span id="Generator.in_sql-1877"><a href="#Generator.in_sql-1877"><span class="linenos">1877</span></a> <span class="n">field</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"field"</span><span class="p">)</span> +</span><span id="Generator.in_sql-1878"><a href="#Generator.in_sql-1878"><span class="linenos">1878</span></a> <span class="n">is_global</span> <span class="o">=</span> <span class="s2">" GLOBAL"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"is_global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.in_sql-1879"><a href="#Generator.in_sql-1879"><span class="linenos">1879</span></a> +</span><span id="Generator.in_sql-1880"><a href="#Generator.in_sql-1880"><span class="linenos">1880</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> +</span><span id="Generator.in_sql-1881"><a href="#Generator.in_sql-1881"><span class="linenos">1881</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">query</span><span class="p">)</span> +</span><span id="Generator.in_sql-1882"><a href="#Generator.in_sql-1882"><span class="linenos">1882</span></a> <span class="k">elif</span> <span class="n">unnest</span><span class="p">:</span> +</span><span id="Generator.in_sql-1883"><a href="#Generator.in_sql-1883"><span class="linenos">1883</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">in_unnest_op</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span> +</span><span id="Generator.in_sql-1884"><a href="#Generator.in_sql-1884"><span class="linenos">1884</span></a> <span class="k">elif</span> <span class="n">field</span><span class="p">:</span> +</span><span id="Generator.in_sql-1885"><a href="#Generator.in_sql-1885"><span class="linenos">1885</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">field</span><span class="p">)</span> +</span><span id="Generator.in_sql-1886"><a href="#Generator.in_sql-1886"><span class="linenos">1886</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.in_sql-1887"><a href="#Generator.in_sql-1887"><span class="linenos">1887</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.in_sql-1888"><a href="#Generator.in_sql-1888"><span class="linenos">1888</span></a> +</span><span id="Generator.in_sql-1889"><a href="#Generator.in_sql-1889"><span class="linenos">1889</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">is_global</span><span class="si">}</span><span class="s2"> IN </span><span class="si">{</span><span class="n">in_sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9526,8 +9694,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.in_unnest_op"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.in_unnest_op-1858"><a href="#Generator.in_unnest_op-1858"><span class="linenos">1858</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">unnest</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.in_unnest_op-1859"><a href="#Generator.in_unnest_op-1859"><span class="linenos">1859</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(SELECT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.in_unnest_op-1891"><a href="#Generator.in_unnest_op-1891"><span class="linenos">1891</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">unnest</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.in_unnest_op-1892"><a href="#Generator.in_unnest_op-1892"><span class="linenos">1892</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(SELECT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -9545,22 +9713,22 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.interval_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.interval_sql-1861"><a href="#Generator.interval_sql-1861"><span class="linenos">1861</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.interval_sql-1862"><a href="#Generator.interval_sql-1862"><span class="linenos">1862</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> -</span><span id="Generator.interval_sql-1863"><a href="#Generator.interval_sql-1863"><span class="linenos">1863</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span><span class="p">:</span> -</span><span id="Generator.interval_sql-1864"><a href="#Generator.interval_sql-1864"><span class="linenos">1864</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_PART_SINGULARS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> <span class="n">unit</span><span class="p">)</span> -</span><span id="Generator.interval_sql-1865"><a href="#Generator.interval_sql-1865"><span class="linenos">1865</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.interval_sql-1866"><a href="#Generator.interval_sql-1866"><span class="linenos">1866</span></a> -</span><span id="Generator.interval_sql-1867"><a href="#Generator.interval_sql-1867"><span class="linenos">1867</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_STRING_INTERVAL</span><span class="p">:</span> -</span><span id="Generator.interval_sql-1868"><a href="#Generator.interval_sql-1868"><span class="linenos">1868</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.interval_sql-1869"><a href="#Generator.interval_sql-1869"><span class="linenos">1869</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL '</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">'"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.interval_sql-1870"><a href="#Generator.interval_sql-1870"><span class="linenos">1870</span></a> -</span><span id="Generator.interval_sql-1871"><a href="#Generator.interval_sql-1871"><span class="linenos">1871</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.interval_sql-1872"><a href="#Generator.interval_sql-1872"><span class="linenos">1872</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> -</span><span id="Generator.interval_sql-1873"><a href="#Generator.interval_sql-1873"><span class="linenos">1873</span></a> <span class="n">unwrapped</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">)</span> -</span><span id="Generator.interval_sql-1874"><a href="#Generator.interval_sql-1874"><span class="linenos">1874</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unwrapped</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.interval_sql-1875"><a href="#Generator.interval_sql-1875"><span class="linenos">1875</span></a> -</span><span id="Generator.interval_sql-1876"><a href="#Generator.interval_sql-1876"><span class="linenos">1876</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.interval_sql-1894"><a href="#Generator.interval_sql-1894"><span class="linenos">1894</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.interval_sql-1895"><a href="#Generator.interval_sql-1895"><span class="linenos">1895</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> +</span><span id="Generator.interval_sql-1896"><a href="#Generator.interval_sql-1896"><span class="linenos">1896</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span><span class="p">:</span> +</span><span id="Generator.interval_sql-1897"><a href="#Generator.interval_sql-1897"><span class="linenos">1897</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_PART_SINGULARS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> <span class="n">unit</span><span class="p">)</span> +</span><span id="Generator.interval_sql-1898"><a href="#Generator.interval_sql-1898"><span class="linenos">1898</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.interval_sql-1899"><a href="#Generator.interval_sql-1899"><span class="linenos">1899</span></a> +</span><span id="Generator.interval_sql-1900"><a href="#Generator.interval_sql-1900"><span class="linenos">1900</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_STRING_INTERVAL</span><span class="p">:</span> +</span><span id="Generator.interval_sql-1901"><a href="#Generator.interval_sql-1901"><span class="linenos">1901</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.interval_sql-1902"><a href="#Generator.interval_sql-1902"><span class="linenos">1902</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL '</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">'"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.interval_sql-1903"><a href="#Generator.interval_sql-1903"><span class="linenos">1903</span></a> +</span><span id="Generator.interval_sql-1904"><a href="#Generator.interval_sql-1904"><span class="linenos">1904</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.interval_sql-1905"><a href="#Generator.interval_sql-1905"><span class="linenos">1905</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> +</span><span id="Generator.interval_sql-1906"><a href="#Generator.interval_sql-1906"><span class="linenos">1906</span></a> <span class="n">unwrapped</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">)</span> +</span><span id="Generator.interval_sql-1907"><a href="#Generator.interval_sql-1907"><span class="linenos">1907</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unwrapped</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.interval_sql-1908"><a href="#Generator.interval_sql-1908"><span class="linenos">1908</span></a> +</span><span id="Generator.interval_sql-1909"><a href="#Generator.interval_sql-1909"><span class="linenos">1909</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9578,8 +9746,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.return_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.return_sql-1878"><a href="#Generator.return_sql-1878"><span class="linenos">1878</span></a> <span class="k">def</span> <span class="nf">return_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Return</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.return_sql-1879"><a href="#Generator.return_sql-1879"><span class="linenos">1879</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RETURN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.return_sql-1911"><a href="#Generator.return_sql-1911"><span class="linenos">1911</span></a> <span class="k">def</span> <span class="nf">return_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Return</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.return_sql-1912"><a href="#Generator.return_sql-1912"><span class="linenos">1912</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RETURN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9597,13 +9765,13 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.reference_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.reference_sql-1881"><a href="#Generator.reference_sql-1881"><span class="linenos">1881</span></a> <span class="k">def</span> <span class="nf">reference_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Reference</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.reference_sql-1882"><a href="#Generator.reference_sql-1882"><span class="linenos">1882</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.reference_sql-1883"><a href="#Generator.reference_sql-1883"><span class="linenos">1883</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.reference_sql-1884"><a href="#Generator.reference_sql-1884"><span class="linenos">1884</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.reference_sql-1885"><a href="#Generator.reference_sql-1885"><span class="linenos">1885</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator.reference_sql-1886"><a href="#Generator.reference_sql-1886"><span class="linenos">1886</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.reference_sql-1887"><a href="#Generator.reference_sql-1887"><span class="linenos">1887</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"REFERENCES </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.reference_sql-1914"><a href="#Generator.reference_sql-1914"><span class="linenos">1914</span></a> <span class="k">def</span> <span class="nf">reference_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Reference</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.reference_sql-1915"><a href="#Generator.reference_sql-1915"><span class="linenos">1915</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.reference_sql-1916"><a href="#Generator.reference_sql-1916"><span class="linenos">1916</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.reference_sql-1917"><a href="#Generator.reference_sql-1917"><span class="linenos">1917</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.reference_sql-1918"><a href="#Generator.reference_sql-1918"><span class="linenos">1918</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator.reference_sql-1919"><a href="#Generator.reference_sql-1919"><span class="linenos">1919</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.reference_sql-1920"><a href="#Generator.reference_sql-1920"><span class="linenos">1920</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"REFERENCES </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9621,8 +9789,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.anonymous_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.anonymous_sql-1889"><a href="#Generator.anonymous_sql-1889"><span class="linenos">1889</span></a> <span class="k">def</span> <span class="nf">anonymous_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Anonymous</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.anonymous_sql-1890"><a href="#Generator.anonymous_sql-1890"><span class="linenos">1890</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.anonymous_sql-1922"><a href="#Generator.anonymous_sql-1922"><span class="linenos">1922</span></a> <span class="k">def</span> <span class="nf">anonymous_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Anonymous</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.anonymous_sql-1923"><a href="#Generator.anonymous_sql-1923"><span class="linenos">1923</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> </span></pre></div> @@ -9640,14 +9808,14 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.paren_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.paren_sql-1892"><a href="#Generator.paren_sql-1892"><span class="linenos">1892</span></a> <span class="k">def</span> <span class="nf">paren_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.paren_sql-1893"><a href="#Generator.paren_sql-1893"><span class="linenos">1893</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">unnest</span><span class="p">(),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> -</span><span id="Generator.paren_sql-1894"><a href="#Generator.paren_sql-1894"><span class="linenos">1894</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.paren_sql-1895"><a href="#Generator.paren_sql-1895"><span class="linenos">1895</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.paren_sql-1896"><a href="#Generator.paren_sql-1896"><span class="linenos">1896</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="Generator.paren_sql-1897"><a href="#Generator.paren_sql-1897"><span class="linenos">1897</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.paren_sql-1898"><a href="#Generator.paren_sql-1898"><span class="linenos">1898</span></a> -</span><span id="Generator.paren_sql-1899"><a href="#Generator.paren_sql-1899"><span class="linenos">1899</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.paren_sql-1925"><a href="#Generator.paren_sql-1925"><span class="linenos">1925</span></a> <span class="k">def</span> <span class="nf">paren_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Paren</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.paren_sql-1926"><a href="#Generator.paren_sql-1926"><span class="linenos">1926</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">unnest</span><span class="p">(),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> +</span><span id="Generator.paren_sql-1927"><a href="#Generator.paren_sql-1927"><span class="linenos">1927</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.paren_sql-1928"><a href="#Generator.paren_sql-1928"><span class="linenos">1928</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.paren_sql-1929"><a href="#Generator.paren_sql-1929"><span class="linenos">1929</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> +</span><span id="Generator.paren_sql-1930"><a href="#Generator.paren_sql-1930"><span class="linenos">1930</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.paren_sql-1931"><a href="#Generator.paren_sql-1931"><span class="linenos">1931</span></a> +</span><span id="Generator.paren_sql-1932"><a href="#Generator.paren_sql-1932"><span class="linenos">1932</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> </span></pre></div> @@ -9665,11 +9833,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.neg_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.neg_sql-1901"><a href="#Generator.neg_sql-1901"><span class="linenos">1901</span></a> <span class="k">def</span> <span class="nf">neg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Neg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.neg_sql-1902"><a href="#Generator.neg_sql-1902"><span class="linenos">1902</span></a> <span class="c1"># This makes sure we don't convert "- - 5" to "--5", which is a comment</span> -</span><span id="Generator.neg_sql-1903"><a href="#Generator.neg_sql-1903"><span class="linenos">1903</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.neg_sql-1904"><a href="#Generator.neg_sql-1904"><span class="linenos">1904</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">this_sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"-"</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.neg_sql-1905"><a href="#Generator.neg_sql-1905"><span class="linenos">1905</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"-</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.neg_sql-1934"><a href="#Generator.neg_sql-1934"><span class="linenos">1934</span></a> <span class="k">def</span> <span class="nf">neg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Neg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.neg_sql-1935"><a href="#Generator.neg_sql-1935"><span class="linenos">1935</span></a> <span class="c1"># This makes sure we don't convert "- - 5" to "--5", which is a comment</span> +</span><span id="Generator.neg_sql-1936"><a href="#Generator.neg_sql-1936"><span class="linenos">1936</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.neg_sql-1937"><a href="#Generator.neg_sql-1937"><span class="linenos">1937</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">this_sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"-"</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.neg_sql-1938"><a href="#Generator.neg_sql-1938"><span class="linenos">1938</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"-</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9687,8 +9855,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.not_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.not_sql-1907"><a href="#Generator.not_sql-1907"><span class="linenos">1907</span></a> <span class="k">def</span> <span class="nf">not_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Not</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.not_sql-1908"><a href="#Generator.not_sql-1908"><span class="linenos">1908</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NOT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.not_sql-1940"><a href="#Generator.not_sql-1940"><span class="linenos">1940</span></a> <span class="k">def</span> <span class="nf">not_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Not</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.not_sql-1941"><a href="#Generator.not_sql-1941"><span class="linenos">1941</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NOT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9706,10 +9874,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.alias_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.alias_sql-1910"><a href="#Generator.alias_sql-1910"><span class="linenos">1910</span></a> <span class="k">def</span> <span class="nf">alias_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.alias_sql-1911"><a href="#Generator.alias_sql-1911"><span class="linenos">1911</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator.alias_sql-1912"><a href="#Generator.alias_sql-1912"><span class="linenos">1912</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.alias_sql-1913"><a href="#Generator.alias_sql-1913"><span class="linenos">1913</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.alias_sql-1943"><a href="#Generator.alias_sql-1943"><span class="linenos">1943</span></a> <span class="k">def</span> <span class="nf">alias_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.alias_sql-1944"><a href="#Generator.alias_sql-1944"><span class="linenos">1944</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator.alias_sql-1945"><a href="#Generator.alias_sql-1945"><span class="linenos">1945</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.alias_sql-1946"><a href="#Generator.alias_sql-1946"><span class="linenos">1946</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9727,8 +9895,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.aliases_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.aliases_sql-1915"><a href="#Generator.aliases_sql-1915"><span class="linenos">1915</span></a> <span class="k">def</span> <span class="nf">aliases_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Aliases</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.aliases_sql-1916"><a href="#Generator.aliases_sql-1916"><span class="linenos">1916</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.aliases_sql-1948"><a href="#Generator.aliases_sql-1948"><span class="linenos">1948</span></a> <span class="k">def</span> <span class="nf">aliases_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Aliases</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.aliases_sql-1949"><a href="#Generator.aliases_sql-1949"><span class="linenos">1949</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -9746,10 +9914,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.attimezone_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.attimezone_sql-1918"><a href="#Generator.attimezone_sql-1918"><span class="linenos">1918</span></a> <span class="k">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.attimezone_sql-1919"><a href="#Generator.attimezone_sql-1919"><span class="linenos">1919</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.attimezone_sql-1920"><a href="#Generator.attimezone_sql-1920"><span class="linenos">1920</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">)</span> -</span><span id="Generator.attimezone_sql-1921"><a href="#Generator.attimezone_sql-1921"><span class="linenos">1921</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> AT TIME ZONE </span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.attimezone_sql-1951"><a href="#Generator.attimezone_sql-1951"><span class="linenos">1951</span></a> <span class="k">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.attimezone_sql-1952"><a href="#Generator.attimezone_sql-1952"><span class="linenos">1952</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.attimezone_sql-1953"><a href="#Generator.attimezone_sql-1953"><span class="linenos">1953</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">)</span> +</span><span id="Generator.attimezone_sql-1954"><a href="#Generator.attimezone_sql-1954"><span class="linenos">1954</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> AT TIME ZONE </span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9767,8 +9935,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.add_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.add_sql-1923"><a href="#Generator.add_sql-1923"><span class="linenos">1923</span></a> <span class="k">def</span> <span class="nf">add_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Add</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.add_sql-1924"><a href="#Generator.add_sql-1924"><span class="linenos">1924</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.add_sql-1956"><a href="#Generator.add_sql-1956"><span class="linenos">1956</span></a> <span class="k">def</span> <span class="nf">add_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Add</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.add_sql-1957"><a href="#Generator.add_sql-1957"><span class="linenos">1957</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">)</span> </span></pre></div> @@ -9786,8 +9954,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.and_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.and_sql-1926"><a href="#Generator.and_sql-1926"><span class="linenos">1926</span></a> <span class="k">def</span> <span class="nf">and_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">And</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.and_sql-1927"><a href="#Generator.and_sql-1927"><span class="linenos">1927</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"AND"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.and_sql-1959"><a href="#Generator.and_sql-1959"><span class="linenos">1959</span></a> <span class="k">def</span> <span class="nf">and_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">And</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.and_sql-1960"><a href="#Generator.and_sql-1960"><span class="linenos">1960</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"AND"</span><span class="p">)</span> </span></pre></div> @@ -9805,17 +9973,17 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.connector_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.connector_sql-1929"><a href="#Generator.connector_sql-1929"><span class="linenos">1929</span></a> <span class="k">def</span> <span class="nf">connector_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Connector</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.connector_sql-1930"><a href="#Generator.connector_sql-1930"><span class="linenos">1930</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="Generator.connector_sql-1931"><a href="#Generator.connector_sql-1931"><span class="linenos">1931</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">op</span><span class="p">)</span> -</span><span id="Generator.connector_sql-1932"><a href="#Generator.connector_sql-1932"><span class="linenos">1932</span></a> -</span><span id="Generator.connector_sql-1933"><a href="#Generator.connector_sql-1933"><span class="linenos">1933</span></a> <span class="n">sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> -</span><span id="Generator.connector_sql-1934"><a href="#Generator.connector_sql-1934"><span class="linenos">1934</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> <span class="n">e</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">comments</span> <span class="ow">or</span> <span class="p">[])</span> <span class="k">if</span> <span class="n">i</span> <span class="o">!=</span> <span class="mi">1</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> -</span><span id="Generator.connector_sql-1935"><a href="#Generator.connector_sql-1935"><span class="linenos">1935</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">(</span><span class="n">unnest</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> -</span><span id="Generator.connector_sql-1936"><a href="#Generator.connector_sql-1936"><span class="linenos">1936</span></a> <span class="p">)</span> -</span><span id="Generator.connector_sql-1937"><a href="#Generator.connector_sql-1937"><span class="linenos">1937</span></a> -</span><span id="Generator.connector_sql-1938"><a href="#Generator.connector_sql-1938"><span class="linenos">1938</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator.connector_sql-1939"><a href="#Generator.connector_sql-1939"><span class="linenos">1939</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">op</span><span class="si">}</span><span class="s2"> "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.connector_sql-1962"><a href="#Generator.connector_sql-1962"><span class="linenos">1962</span></a> <span class="k">def</span> <span class="nf">connector_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Connector</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.connector_sql-1963"><a href="#Generator.connector_sql-1963"><span class="linenos">1963</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="Generator.connector_sql-1964"><a href="#Generator.connector_sql-1964"><span class="linenos">1964</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">op</span><span class="p">)</span> +</span><span id="Generator.connector_sql-1965"><a href="#Generator.connector_sql-1965"><span class="linenos">1965</span></a> +</span><span id="Generator.connector_sql-1966"><a href="#Generator.connector_sql-1966"><span class="linenos">1966</span></a> <span class="n">sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> +</span><span id="Generator.connector_sql-1967"><a href="#Generator.connector_sql-1967"><span class="linenos">1967</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> <span class="n">e</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">comments</span> <span class="ow">or</span> <span class="p">[])</span> <span class="k">if</span> <span class="n">i</span> <span class="o">!=</span> <span class="mi">1</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> +</span><span id="Generator.connector_sql-1968"><a href="#Generator.connector_sql-1968"><span class="linenos">1968</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">(</span><span class="n">unnest</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> +</span><span id="Generator.connector_sql-1969"><a href="#Generator.connector_sql-1969"><span class="linenos">1969</span></a> <span class="p">)</span> +</span><span id="Generator.connector_sql-1970"><a href="#Generator.connector_sql-1970"><span class="linenos">1970</span></a> +</span><span id="Generator.connector_sql-1971"><a href="#Generator.connector_sql-1971"><span class="linenos">1971</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator.connector_sql-1972"><a href="#Generator.connector_sql-1972"><span class="linenos">1972</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">op</span><span class="si">}</span><span class="s2"> "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> </span></pre></div> @@ -9833,8 +10001,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.bitwiseand_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiseand_sql-1941"><a href="#Generator.bitwiseand_sql-1941"><span class="linenos">1941</span></a> <span class="k">def</span> <span class="nf">bitwiseand_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.bitwiseand_sql-1942"><a href="#Generator.bitwiseand_sql-1942"><span class="linenos">1942</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"&"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiseand_sql-1974"><a href="#Generator.bitwiseand_sql-1974"><span class="linenos">1974</span></a> <span class="k">def</span> <span class="nf">bitwiseand_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseAnd</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.bitwiseand_sql-1975"><a href="#Generator.bitwiseand_sql-1975"><span class="linenos">1975</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"&"</span><span class="p">)</span> </span></pre></div> @@ -9852,8 +10020,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.bitwiseleftshift_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiseleftshift_sql-1944"><a href="#Generator.bitwiseleftshift_sql-1944"><span class="linenos">1944</span></a> <span class="k">def</span> <span class="nf">bitwiseleftshift_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.bitwiseleftshift_sql-1945"><a href="#Generator.bitwiseleftshift_sql-1945"><span class="linenos">1945</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<<"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiseleftshift_sql-1977"><a href="#Generator.bitwiseleftshift_sql-1977"><span class="linenos">1977</span></a> <span class="k">def</span> <span class="nf">bitwiseleftshift_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.bitwiseleftshift_sql-1978"><a href="#Generator.bitwiseleftshift_sql-1978"><span class="linenos">1978</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<<"</span><span class="p">)</span> </span></pre></div> @@ -9871,8 +10039,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.bitwisenot_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwisenot_sql-1947"><a href="#Generator.bitwisenot_sql-1947"><span class="linenos">1947</span></a> <span class="k">def</span> <span class="nf">bitwisenot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.bitwisenot_sql-1948"><a href="#Generator.bitwisenot_sql-1948"><span class="linenos">1948</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"~</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwisenot_sql-1980"><a href="#Generator.bitwisenot_sql-1980"><span class="linenos">1980</span></a> <span class="k">def</span> <span class="nf">bitwisenot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseNot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.bitwisenot_sql-1981"><a href="#Generator.bitwisenot_sql-1981"><span class="linenos">1981</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"~</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -9890,8 +10058,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.bitwiseor_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiseor_sql-1950"><a href="#Generator.bitwiseor_sql-1950"><span class="linenos">1950</span></a> <span class="k">def</span> <span class="nf">bitwiseor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.bitwiseor_sql-1951"><a href="#Generator.bitwiseor_sql-1951"><span class="linenos">1951</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"|"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiseor_sql-1983"><a href="#Generator.bitwiseor_sql-1983"><span class="linenos">1983</span></a> <span class="k">def</span> <span class="nf">bitwiseor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseOr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.bitwiseor_sql-1984"><a href="#Generator.bitwiseor_sql-1984"><span class="linenos">1984</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"|"</span><span class="p">)</span> </span></pre></div> @@ -9909,8 +10077,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.bitwiserightshift_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiserightshift_sql-1953"><a href="#Generator.bitwiserightshift_sql-1953"><span class="linenos">1953</span></a> <span class="k">def</span> <span class="nf">bitwiserightshift_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.bitwiserightshift_sql-1954"><a href="#Generator.bitwiserightshift_sql-1954"><span class="linenos">1954</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">>"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiserightshift_sql-1986"><a href="#Generator.bitwiserightshift_sql-1986"><span class="linenos">1986</span></a> <span class="k">def</span> <span class="nf">bitwiserightshift_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.bitwiserightshift_sql-1987"><a href="#Generator.bitwiserightshift_sql-1987"><span class="linenos">1987</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">>"</span><span class="p">)</span> </span></pre></div> @@ -9928,8 +10096,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.bitwisexor_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwisexor_sql-1956"><a href="#Generator.bitwisexor_sql-1956"><span class="linenos">1956</span></a> <span class="k">def</span> <span class="nf">bitwisexor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.bitwisexor_sql-1957"><a href="#Generator.bitwisexor_sql-1957"><span class="linenos">1957</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"^"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwisexor_sql-1989"><a href="#Generator.bitwisexor_sql-1989"><span class="linenos">1989</span></a> <span class="k">def</span> <span class="nf">bitwisexor_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseXor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.bitwisexor_sql-1990"><a href="#Generator.bitwisexor_sql-1990"><span class="linenos">1990</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"^"</span><span class="p">)</span> </span></pre></div> @@ -9947,8 +10115,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.cast_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.cast_sql-1959"><a href="#Generator.cast_sql-1959"><span class="linenos">1959</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.cast_sql-1960"><a href="#Generator.cast_sql-1960"><span class="linenos">1960</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">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'to'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.cast_sql-1992"><a href="#Generator.cast_sql-1992"><span class="linenos">1992</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.cast_sql-1993"><a href="#Generator.cast_sql-1993"><span class="linenos">1993</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">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'to'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -9966,9 +10134,9 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.currentdate_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.currentdate_sql-1962"><a href="#Generator.currentdate_sql-1962"><span class="linenos">1962</span></a> <span class="k">def</span> <span class="nf">currentdate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.currentdate_sql-1963"><a href="#Generator.currentdate_sql-1963"><span class="linenos">1963</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.currentdate_sql-1964"><a href="#Generator.currentdate_sql-1964"><span class="linenos">1964</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CURRENT_DATE(</span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">zone</span> <span class="k">else</span> <span class="s2">"CURRENT_DATE"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.currentdate_sql-1995"><a href="#Generator.currentdate_sql-1995"><span class="linenos">1995</span></a> <span class="k">def</span> <span class="nf">currentdate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">CurrentDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.currentdate_sql-1996"><a href="#Generator.currentdate_sql-1996"><span class="linenos">1996</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.currentdate_sql-1997"><a href="#Generator.currentdate_sql-1997"><span class="linenos">1997</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CURRENT_DATE(</span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">zone</span> <span class="k">else</span> <span class="s2">"CURRENT_DATE"</span> </span></pre></div> @@ -9986,8 +10154,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.collate_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.collate_sql-1966"><a href="#Generator.collate_sql-1966"><span class="linenos">1966</span></a> <span class="k">def</span> <span class="nf">collate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Collate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.collate_sql-1967"><a href="#Generator.collate_sql-1967"><span class="linenos">1967</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"COLLATE"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.collate_sql-1999"><a href="#Generator.collate_sql-1999"><span class="linenos">1999</span></a> <span class="k">def</span> <span class="nf">collate_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Collate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.collate_sql-2000"><a href="#Generator.collate_sql-2000"><span class="linenos">2000</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"COLLATE"</span><span class="p">)</span> </span></pre></div> @@ -10005,8 +10173,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.command_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.command_sql-1969"><a href="#Generator.command_sql-1969"><span class="linenos">1969</span></a> <span class="k">def</span> <span class="nf">command_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.command_sql-1970"><a href="#Generator.command_sql-1970"><span class="linenos">1970</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s1">'expression'</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.command_sql-2002"><a href="#Generator.command_sql-2002"><span class="linenos">2002</span></a> <span class="k">def</span> <span class="nf">command_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.command_sql-2003"><a href="#Generator.command_sql-2003"><span class="linenos">2003</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s1">'expression'</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10024,12 +10192,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.comment_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.comment_sql-1972"><a href="#Generator.comment_sql-1972"><span class="linenos">1972</span></a> <span class="k">def</span> <span class="nf">comment_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Comment</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.comment_sql-1973"><a href="#Generator.comment_sql-1973"><span class="linenos">1973</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.comment_sql-1974"><a href="#Generator.comment_sql-1974"><span class="linenos">1974</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> -</span><span id="Generator.comment_sql-1975"><a href="#Generator.comment_sql-1975"><span class="linenos">1975</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator.comment_sql-1976"><a href="#Generator.comment_sql-1976"><span class="linenos">1976</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator.comment_sql-1977"><a href="#Generator.comment_sql-1977"><span class="linenos">1977</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMENT</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> IS </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.comment_sql-2005"><a href="#Generator.comment_sql-2005"><span class="linenos">2005</span></a> <span class="k">def</span> <span class="nf">comment_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Comment</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.comment_sql-2006"><a href="#Generator.comment_sql-2006"><span class="linenos">2006</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.comment_sql-2007"><a href="#Generator.comment_sql-2007"><span class="linenos">2007</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> +</span><span id="Generator.comment_sql-2008"><a href="#Generator.comment_sql-2008"><span class="linenos">2008</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator.comment_sql-2009"><a href="#Generator.comment_sql-2009"><span class="linenos">2009</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator.comment_sql-2010"><a href="#Generator.comment_sql-2010"><span class="linenos">2010</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMENT</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> IS </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10047,16 +10215,16 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.mergetreettlaction_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mergetreettlaction_sql-1979"><a href="#Generator.mergetreettlaction_sql-1979"><span class="linenos">1979</span></a> <span class="k">def</span> <span class="nf">mergetreettlaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTLAction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.mergetreettlaction_sql-1980"><a href="#Generator.mergetreettlaction_sql-1980"><span class="linenos">1980</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.mergetreettlaction_sql-1981"><a href="#Generator.mergetreettlaction_sql-1981"><span class="linenos">1981</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="s2">" DELETE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"delete"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.mergetreettlaction_sql-1982"><a href="#Generator.mergetreettlaction_sql-1982"><span class="linenos">1982</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"recompress"</span><span class="p">)</span> -</span><span id="Generator.mergetreettlaction_sql-1983"><a href="#Generator.mergetreettlaction_sql-1983"><span class="linenos">1983</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECOMPRESS </span><span class="si">{</span><span class="n">recompress</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">recompress</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.mergetreettlaction_sql-1984"><a href="#Generator.mergetreettlaction_sql-1984"><span class="linenos">1984</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_disk"</span><span class="p">)</span> -</span><span id="Generator.mergetreettlaction_sql-1985"><a href="#Generator.mergetreettlaction_sql-1985"><span class="linenos">1985</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO DISK </span><span class="si">{</span><span class="n">to_disk</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_disk</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.mergetreettlaction_sql-1986"><a href="#Generator.mergetreettlaction_sql-1986"><span class="linenos">1986</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_volume"</span><span class="p">)</span> -</span><span id="Generator.mergetreettlaction_sql-1987"><a href="#Generator.mergetreettlaction_sql-1987"><span class="linenos">1987</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO VOLUME </span><span class="si">{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_volume</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.mergetreettlaction_sql-1988"><a href="#Generator.mergetreettlaction_sql-1988"><span class="linenos">1988</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">recompress</span><span class="si">}{</span><span class="n">to_disk</span><span class="si">}{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mergetreettlaction_sql-2012"><a href="#Generator.mergetreettlaction_sql-2012"><span class="linenos">2012</span></a> <span class="k">def</span> <span class="nf">mergetreettlaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTLAction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.mergetreettlaction_sql-2013"><a href="#Generator.mergetreettlaction_sql-2013"><span class="linenos">2013</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.mergetreettlaction_sql-2014"><a href="#Generator.mergetreettlaction_sql-2014"><span class="linenos">2014</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="s2">" DELETE"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"delete"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.mergetreettlaction_sql-2015"><a href="#Generator.mergetreettlaction_sql-2015"><span class="linenos">2015</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"recompress"</span><span class="p">)</span> +</span><span id="Generator.mergetreettlaction_sql-2016"><a href="#Generator.mergetreettlaction_sql-2016"><span class="linenos">2016</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECOMPRESS </span><span class="si">{</span><span class="n">recompress</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">recompress</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.mergetreettlaction_sql-2017"><a href="#Generator.mergetreettlaction_sql-2017"><span class="linenos">2017</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_disk"</span><span class="p">)</span> +</span><span id="Generator.mergetreettlaction_sql-2018"><a href="#Generator.mergetreettlaction_sql-2018"><span class="linenos">2018</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO DISK </span><span class="si">{</span><span class="n">to_disk</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_disk</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.mergetreettlaction_sql-2019"><a href="#Generator.mergetreettlaction_sql-2019"><span class="linenos">2019</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_volume"</span><span class="p">)</span> +</span><span id="Generator.mergetreettlaction_sql-2020"><a href="#Generator.mergetreettlaction_sql-2020"><span class="linenos">2020</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO VOLUME </span><span class="si">{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_volume</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.mergetreettlaction_sql-2021"><a href="#Generator.mergetreettlaction_sql-2021"><span class="linenos">2021</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">recompress</span><span class="si">}{</span><span class="n">to_disk</span><span class="si">}{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10074,16 +10242,16 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.mergetreettl_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mergetreettl_sql-1990"><a href="#Generator.mergetreettl_sql-1990"><span class="linenos">1990</span></a> <span class="k">def</span> <span class="nf">mergetreettl_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.mergetreettl_sql-1991"><a href="#Generator.mergetreettl_sql-1991"><span class="linenos">1991</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> -</span><span id="Generator.mergetreettl_sql-1992"><a href="#Generator.mergetreettl_sql-1992"><span class="linenos">1992</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">)</span> -</span><span id="Generator.mergetreettl_sql-1993"><a href="#Generator.mergetreettl_sql-1993"><span class="linenos">1993</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"aggregates"</span><span class="p">)</span> -</span><span id="Generator.mergetreettl_sql-1994"><a href="#Generator.mergetreettl_sql-1994"><span class="linenos">1994</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"SET"</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">aggregates</span><span class="p">)</span> <span class="k">if</span> <span class="n">aggregates</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.mergetreettl_sql-1995"><a href="#Generator.mergetreettl_sql-1995"><span class="linenos">1995</span></a> -</span><span id="Generator.mergetreettl_sql-1996"><a href="#Generator.mergetreettl_sql-1996"><span class="linenos">1996</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">where</span> <span class="ow">or</span> <span class="n">group</span> <span class="ow">or</span> <span class="n">aggregates</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Generator.mergetreettl_sql-1997"><a href="#Generator.mergetreettl_sql-1997"><span class="linenos">1997</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.mergetreettl_sql-1998"><a href="#Generator.mergetreettl_sql-1998"><span class="linenos">1998</span></a> -</span><span id="Generator.mergetreettl_sql-1999"><a href="#Generator.mergetreettl_sql-1999"><span class="linenos">1999</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">))</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">group</span><span class="si">}{</span><span class="n">aggregates</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mergetreettl_sql-2023"><a href="#Generator.mergetreettl_sql-2023"><span class="linenos">2023</span></a> <span class="k">def</span> <span class="nf">mergetreettl_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.mergetreettl_sql-2024"><a href="#Generator.mergetreettl_sql-2024"><span class="linenos">2024</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> +</span><span id="Generator.mergetreettl_sql-2025"><a href="#Generator.mergetreettl_sql-2025"><span class="linenos">2025</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">)</span> +</span><span id="Generator.mergetreettl_sql-2026"><a href="#Generator.mergetreettl_sql-2026"><span class="linenos">2026</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"aggregates"</span><span class="p">)</span> +</span><span id="Generator.mergetreettl_sql-2027"><a href="#Generator.mergetreettl_sql-2027"><span class="linenos">2027</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"SET"</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">aggregates</span><span class="p">)</span> <span class="k">if</span> <span class="n">aggregates</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.mergetreettl_sql-2028"><a href="#Generator.mergetreettl_sql-2028"><span class="linenos">2028</span></a> +</span><span id="Generator.mergetreettl_sql-2029"><a href="#Generator.mergetreettl_sql-2029"><span class="linenos">2029</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">where</span> <span class="ow">or</span> <span class="n">group</span> <span class="ow">or</span> <span class="n">aggregates</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Generator.mergetreettl_sql-2030"><a href="#Generator.mergetreettl_sql-2030"><span class="linenos">2030</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.mergetreettl_sql-2031"><a href="#Generator.mergetreettl_sql-2031"><span class="linenos">2031</span></a> +</span><span id="Generator.mergetreettl_sql-2032"><a href="#Generator.mergetreettl_sql-2032"><span class="linenos">2032</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">))</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">group</span><span class="si">}{</span><span class="n">aggregates</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10101,8 +10269,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.transaction_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.transaction_sql-2001"><a href="#Generator.transaction_sql-2001"><span class="linenos">2001</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.transaction_sql-2002"><a href="#Generator.transaction_sql-2002"><span class="linenos">2002</span></a> <span class="k">return</span> <span class="s2">"BEGIN"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.transaction_sql-2034"><a href="#Generator.transaction_sql-2034"><span class="linenos">2034</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.transaction_sql-2035"><a href="#Generator.transaction_sql-2035"><span class="linenos">2035</span></a> <span class="k">return</span> <span class="s2">"BEGIN"</span> </span></pre></div> @@ -10120,12 +10288,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.commit_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.commit_sql-2004"><a href="#Generator.commit_sql-2004"><span class="linenos">2004</span></a> <span class="k">def</span> <span class="nf">commit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Commit</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.commit_sql-2005"><a href="#Generator.commit_sql-2005"><span class="linenos">2005</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"chain"</span><span class="p">)</span> -</span><span id="Generator.commit_sql-2006"><a href="#Generator.commit_sql-2006"><span class="linenos">2006</span></a> <span class="k">if</span> <span class="n">chain</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.commit_sql-2007"><a href="#Generator.commit_sql-2007"><span class="linenos">2007</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="s2">" AND CHAIN"</span> <span class="k">if</span> <span class="n">chain</span> <span class="k">else</span> <span class="s2">" AND NO CHAIN"</span> -</span><span id="Generator.commit_sql-2008"><a href="#Generator.commit_sql-2008"><span class="linenos">2008</span></a> -</span><span id="Generator.commit_sql-2009"><a href="#Generator.commit_sql-2009"><span class="linenos">2009</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMIT</span><span class="si">{</span><span class="n">chain</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.commit_sql-2037"><a href="#Generator.commit_sql-2037"><span class="linenos">2037</span></a> <span class="k">def</span> <span class="nf">commit_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Commit</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.commit_sql-2038"><a href="#Generator.commit_sql-2038"><span class="linenos">2038</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"chain"</span><span class="p">)</span> +</span><span id="Generator.commit_sql-2039"><a href="#Generator.commit_sql-2039"><span class="linenos">2039</span></a> <span class="k">if</span> <span class="n">chain</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.commit_sql-2040"><a href="#Generator.commit_sql-2040"><span class="linenos">2040</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="s2">" AND CHAIN"</span> <span class="k">if</span> <span class="n">chain</span> <span class="k">else</span> <span class="s2">" AND NO CHAIN"</span> +</span><span id="Generator.commit_sql-2041"><a href="#Generator.commit_sql-2041"><span class="linenos">2041</span></a> +</span><span id="Generator.commit_sql-2042"><a href="#Generator.commit_sql-2042"><span class="linenos">2042</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMIT</span><span class="si">{</span><span class="n">chain</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10143,10 +10311,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.rollback_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.rollback_sql-2011"><a href="#Generator.rollback_sql-2011"><span class="linenos">2011</span></a> <span class="k">def</span> <span class="nf">rollback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Rollback</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.rollback_sql-2012"><a href="#Generator.rollback_sql-2012"><span class="linenos">2012</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"savepoint"</span><span class="p">)</span> -</span><span id="Generator.rollback_sql-2013"><a href="#Generator.rollback_sql-2013"><span class="linenos">2013</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO </span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">savepoint</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.rollback_sql-2014"><a href="#Generator.rollback_sql-2014"><span class="linenos">2014</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROLLBACK</span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.rollback_sql-2044"><a href="#Generator.rollback_sql-2044"><span class="linenos">2044</span></a> <span class="k">def</span> <span class="nf">rollback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Rollback</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.rollback_sql-2045"><a href="#Generator.rollback_sql-2045"><span class="linenos">2045</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"savepoint"</span><span class="p">)</span> +</span><span id="Generator.rollback_sql-2046"><a href="#Generator.rollback_sql-2046"><span class="linenos">2046</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO </span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">savepoint</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.rollback_sql-2047"><a href="#Generator.rollback_sql-2047"><span class="linenos">2047</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROLLBACK</span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10164,25 +10332,25 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.altercolumn_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.altercolumn_sql-2016"><a href="#Generator.altercolumn_sql-2016"><span class="linenos">2016</span></a> <span class="k">def</span> <span class="nf">altercolumn_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AlterColumn</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.altercolumn_sql-2017"><a href="#Generator.altercolumn_sql-2017"><span class="linenos">2017</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.altercolumn_sql-2018"><a href="#Generator.altercolumn_sql-2018"><span class="linenos">2018</span></a> -</span><span id="Generator.altercolumn_sql-2019"><a href="#Generator.altercolumn_sql-2019"><span class="linenos">2019</span></a> <span class="n">dtype</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"dtype"</span><span class="p">)</span> -</span><span id="Generator.altercolumn_sql-2020"><a href="#Generator.altercolumn_sql-2020"><span class="linenos">2020</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="p">:</span> -</span><span id="Generator.altercolumn_sql-2021"><a href="#Generator.altercolumn_sql-2021"><span class="linenos">2021</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collate"</span><span class="p">)</span> -</span><span id="Generator.altercolumn_sql-2022"><a href="#Generator.altercolumn_sql-2022"><span class="linenos">2022</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collate</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.altercolumn_sql-2023"><a href="#Generator.altercolumn_sql-2023"><span class="linenos">2023</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> -</span><span id="Generator.altercolumn_sql-2024"><a href="#Generator.altercolumn_sql-2024"><span class="linenos">2024</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.altercolumn_sql-2025"><a href="#Generator.altercolumn_sql-2025"><span class="linenos">2025</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> TYPE </span><span class="si">{</span><span class="n">dtype</span><span class="si">}{</span><span class="n">collate</span><span class="si">}{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.altercolumn_sql-2026"><a href="#Generator.altercolumn_sql-2026"><span class="linenos">2026</span></a> -</span><span id="Generator.altercolumn_sql-2027"><a href="#Generator.altercolumn_sql-2027"><span class="linenos">2027</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">)</span> -</span><span id="Generator.altercolumn_sql-2028"><a href="#Generator.altercolumn_sql-2028"><span class="linenos">2028</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="Generator.altercolumn_sql-2029"><a href="#Generator.altercolumn_sql-2029"><span class="linenos">2029</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET DEFAULT </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.altercolumn_sql-2030"><a href="#Generator.altercolumn_sql-2030"><span class="linenos">2030</span></a> -</span><span id="Generator.altercolumn_sql-2031"><a href="#Generator.altercolumn_sql-2031"><span class="linenos">2031</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"drop"</span><span class="p">):</span> -</span><span id="Generator.altercolumn_sql-2032"><a href="#Generator.altercolumn_sql-2032"><span class="linenos">2032</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Unsupported ALTER COLUMN syntax"</span><span class="p">)</span> -</span><span id="Generator.altercolumn_sql-2033"><a href="#Generator.altercolumn_sql-2033"><span class="linenos">2033</span></a> -</span><span id="Generator.altercolumn_sql-2034"><a href="#Generator.altercolumn_sql-2034"><span class="linenos">2034</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> DROP DEFAULT"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.altercolumn_sql-2049"><a href="#Generator.altercolumn_sql-2049"><span class="linenos">2049</span></a> <span class="k">def</span> <span class="nf">altercolumn_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AlterColumn</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.altercolumn_sql-2050"><a href="#Generator.altercolumn_sql-2050"><span class="linenos">2050</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.altercolumn_sql-2051"><a href="#Generator.altercolumn_sql-2051"><span class="linenos">2051</span></a> +</span><span id="Generator.altercolumn_sql-2052"><a href="#Generator.altercolumn_sql-2052"><span class="linenos">2052</span></a> <span class="n">dtype</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"dtype"</span><span class="p">)</span> +</span><span id="Generator.altercolumn_sql-2053"><a href="#Generator.altercolumn_sql-2053"><span class="linenos">2053</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="p">:</span> +</span><span id="Generator.altercolumn_sql-2054"><a href="#Generator.altercolumn_sql-2054"><span class="linenos">2054</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collate"</span><span class="p">)</span> +</span><span id="Generator.altercolumn_sql-2055"><a href="#Generator.altercolumn_sql-2055"><span class="linenos">2055</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collate</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.altercolumn_sql-2056"><a href="#Generator.altercolumn_sql-2056"><span class="linenos">2056</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> +</span><span id="Generator.altercolumn_sql-2057"><a href="#Generator.altercolumn_sql-2057"><span class="linenos">2057</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.altercolumn_sql-2058"><a href="#Generator.altercolumn_sql-2058"><span class="linenos">2058</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> TYPE </span><span class="si">{</span><span class="n">dtype</span><span class="si">}{</span><span class="n">collate</span><span class="si">}{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.altercolumn_sql-2059"><a href="#Generator.altercolumn_sql-2059"><span class="linenos">2059</span></a> +</span><span id="Generator.altercolumn_sql-2060"><a href="#Generator.altercolumn_sql-2060"><span class="linenos">2060</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">)</span> +</span><span id="Generator.altercolumn_sql-2061"><a href="#Generator.altercolumn_sql-2061"><span class="linenos">2061</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> +</span><span id="Generator.altercolumn_sql-2062"><a href="#Generator.altercolumn_sql-2062"><span class="linenos">2062</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET DEFAULT </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.altercolumn_sql-2063"><a href="#Generator.altercolumn_sql-2063"><span class="linenos">2063</span></a> +</span><span id="Generator.altercolumn_sql-2064"><a href="#Generator.altercolumn_sql-2064"><span class="linenos">2064</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"drop"</span><span class="p">):</span> +</span><span id="Generator.altercolumn_sql-2065"><a href="#Generator.altercolumn_sql-2065"><span class="linenos">2065</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Unsupported ALTER COLUMN syntax"</span><span class="p">)</span> +</span><span id="Generator.altercolumn_sql-2066"><a href="#Generator.altercolumn_sql-2066"><span class="linenos">2066</span></a> +</span><span id="Generator.altercolumn_sql-2067"><a href="#Generator.altercolumn_sql-2067"><span class="linenos">2067</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> DROP DEFAULT"</span> </span></pre></div> @@ -10200,14 +10368,14 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.renametable_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.renametable_sql-2036"><a href="#Generator.renametable_sql-2036"><span class="linenos">2036</span></a> <span class="k">def</span> <span class="nf">renametable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RenameTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.renametable_sql-2037"><a href="#Generator.renametable_sql-2037"><span class="linenos">2037</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">RENAME_TABLE_WITH_DB</span><span class="p">:</span> -</span><span id="Generator.renametable_sql-2038"><a href="#Generator.renametable_sql-2038"><span class="linenos">2038</span></a> <span class="c1"># Remove db from tables</span> -</span><span id="Generator.renametable_sql-2039"><a href="#Generator.renametable_sql-2039"><span class="linenos">2039</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> -</span><span id="Generator.renametable_sql-2040"><a href="#Generator.renametable_sql-2040"><span class="linenos">2040</span></a> <span class="k">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">table_</span><span class="p">(</span><span class="n">n</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="k">else</span> <span class="n">n</span> -</span><span id="Generator.renametable_sql-2041"><a href="#Generator.renametable_sql-2041"><span class="linenos">2041</span></a> <span class="p">)</span> -</span><span id="Generator.renametable_sql-2042"><a href="#Generator.renametable_sql-2042"><span class="linenos">2042</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.renametable_sql-2043"><a href="#Generator.renametable_sql-2043"><span class="linenos">2043</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RENAME TO </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.renametable_sql-2069"><a href="#Generator.renametable_sql-2069"><span class="linenos">2069</span></a> <span class="k">def</span> <span class="nf">renametable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RenameTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.renametable_sql-2070"><a href="#Generator.renametable_sql-2070"><span class="linenos">2070</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">RENAME_TABLE_WITH_DB</span><span class="p">:</span> +</span><span id="Generator.renametable_sql-2071"><a href="#Generator.renametable_sql-2071"><span class="linenos">2071</span></a> <span class="c1"># Remove db from tables</span> +</span><span id="Generator.renametable_sql-2072"><a href="#Generator.renametable_sql-2072"><span class="linenos">2072</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> +</span><span id="Generator.renametable_sql-2073"><a href="#Generator.renametable_sql-2073"><span class="linenos">2073</span></a> <span class="k">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">table_</span><span class="p">(</span><span class="n">n</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="k">else</span> <span class="n">n</span> +</span><span id="Generator.renametable_sql-2074"><a href="#Generator.renametable_sql-2074"><span class="linenos">2074</span></a> <span class="p">)</span> +</span><span id="Generator.renametable_sql-2075"><a href="#Generator.renametable_sql-2075"><span class="linenos">2075</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.renametable_sql-2076"><a href="#Generator.renametable_sql-2076"><span class="linenos">2076</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RENAME TO </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10225,20 +10393,20 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.altertable_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.altertable_sql-2045"><a href="#Generator.altertable_sql-2045"><span class="linenos">2045</span></a> <span class="k">def</span> <span class="nf">altertable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AlterTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.altertable_sql-2046"><a href="#Generator.altertable_sql-2046"><span class="linenos">2046</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"actions"</span><span class="p">]</span> -</span><span id="Generator.altertable_sql-2047"><a href="#Generator.altertable_sql-2047"><span class="linenos">2047</span></a> -</span><span id="Generator.altertable_sql-2048"><a href="#Generator.altertable_sql-2048"><span class="linenos">2048</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">):</span> -</span><span id="Generator.altertable_sql-2049"><a href="#Generator.altertable_sql-2049"><span class="linenos">2049</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMN "</span><span class="p">)</span> -</span><span id="Generator.altertable_sql-2050"><a href="#Generator.altertable_sql-2050"><span class="linenos">2050</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">):</span> -</span><span id="Generator.altertable_sql-2051"><a href="#Generator.altertable_sql-2051"><span class="linenos">2051</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMNS "</span><span class="p">)</span> -</span><span id="Generator.altertable_sql-2052"><a href="#Generator.altertable_sql-2052"><span class="linenos">2052</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">):</span> -</span><span id="Generator.altertable_sql-2053"><a href="#Generator.altertable_sql-2053"><span class="linenos">2053</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.altertable_sql-2054"><a href="#Generator.altertable_sql-2054"><span class="linenos">2054</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.altertable_sql-2055"><a href="#Generator.altertable_sql-2055"><span class="linenos">2055</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">)</span> -</span><span id="Generator.altertable_sql-2056"><a href="#Generator.altertable_sql-2056"><span class="linenos">2056</span></a> -</span><span id="Generator.altertable_sql-2057"><a href="#Generator.altertable_sql-2057"><span class="linenos">2057</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.altertable_sql-2058"><a href="#Generator.altertable_sql-2058"><span class="linenos">2058</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER TABLE</span><span class="si">{</span><span class="n">exists</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">actions</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.altertable_sql-2078"><a href="#Generator.altertable_sql-2078"><span class="linenos">2078</span></a> <span class="k">def</span> <span class="nf">altertable_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AlterTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.altertable_sql-2079"><a href="#Generator.altertable_sql-2079"><span class="linenos">2079</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"actions"</span><span class="p">]</span> +</span><span id="Generator.altertable_sql-2080"><a href="#Generator.altertable_sql-2080"><span class="linenos">2080</span></a> +</span><span id="Generator.altertable_sql-2081"><a href="#Generator.altertable_sql-2081"><span class="linenos">2081</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">):</span> +</span><span id="Generator.altertable_sql-2082"><a href="#Generator.altertable_sql-2082"><span class="linenos">2082</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMN "</span><span class="p">)</span> +</span><span id="Generator.altertable_sql-2083"><a href="#Generator.altertable_sql-2083"><span class="linenos">2083</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">):</span> +</span><span id="Generator.altertable_sql-2084"><a href="#Generator.altertable_sql-2084"><span class="linenos">2084</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMNS "</span><span class="p">)</span> +</span><span id="Generator.altertable_sql-2085"><a href="#Generator.altertable_sql-2085"><span class="linenos">2085</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">):</span> +</span><span id="Generator.altertable_sql-2086"><a href="#Generator.altertable_sql-2086"><span class="linenos">2086</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.altertable_sql-2087"><a href="#Generator.altertable_sql-2087"><span class="linenos">2087</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.altertable_sql-2088"><a href="#Generator.altertable_sql-2088"><span class="linenos">2088</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">)</span> +</span><span id="Generator.altertable_sql-2089"><a href="#Generator.altertable_sql-2089"><span class="linenos">2089</span></a> +</span><span id="Generator.altertable_sql-2090"><a href="#Generator.altertable_sql-2090"><span class="linenos">2090</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.altertable_sql-2091"><a href="#Generator.altertable_sql-2091"><span class="linenos">2091</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER TABLE</span><span class="si">{</span><span class="n">exists</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">actions</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10256,10 +10424,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.droppartition_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.droppartition_sql-2060"><a href="#Generator.droppartition_sql-2060"><span class="linenos">2060</span></a> <span class="k">def</span> <span class="nf">droppartition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DropPartition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.droppartition_sql-2061"><a href="#Generator.droppartition_sql-2061"><span class="linenos">2061</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.droppartition_sql-2062"><a href="#Generator.droppartition_sql-2062"><span class="linenos">2062</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator.droppartition_sql-2063"><a href="#Generator.droppartition_sql-2063"><span class="linenos">2063</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.droppartition_sql-2093"><a href="#Generator.droppartition_sql-2093"><span class="linenos">2093</span></a> <span class="k">def</span> <span class="nf">droppartition_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DropPartition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.droppartition_sql-2094"><a href="#Generator.droppartition_sql-2094"><span class="linenos">2094</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.droppartition_sql-2095"><a href="#Generator.droppartition_sql-2095"><span class="linenos">2095</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator.droppartition_sql-2096"><a href="#Generator.droppartition_sql-2096"><span class="linenos">2096</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10277,16 +10445,16 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.addconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.addconstraint_sql-2065"><a href="#Generator.addconstraint_sql-2065"><span class="linenos">2065</span></a> <span class="k">def</span> <span class="nf">addconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AddConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.addconstraint_sql-2066"><a href="#Generator.addconstraint_sql-2066"><span class="linenos">2066</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.addconstraint_sql-2067"><a href="#Generator.addconstraint_sql-2067"><span class="linenos">2067</span></a> <span class="n">expression_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator.addconstraint_sql-2068"><a href="#Generator.addconstraint_sql-2068"><span class="linenos">2068</span></a> <span class="n">add_constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ADD CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">"ADD"</span> -</span><span id="Generator.addconstraint_sql-2069"><a href="#Generator.addconstraint_sql-2069"><span class="linenos">2069</span></a> -</span><span id="Generator.addconstraint_sql-2070"><a href="#Generator.addconstraint_sql-2070"><span class="linenos">2070</span></a> <span class="n">enforced</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"enforced"</span><span class="p">)</span> -</span><span id="Generator.addconstraint_sql-2071"><a href="#Generator.addconstraint_sql-2071"><span class="linenos">2071</span></a> <span class="k">if</span> <span class="n">enforced</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.addconstraint_sql-2072"><a href="#Generator.addconstraint_sql-2072"><span class="linenos">2072</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> CHECK (</span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="s1">' ENFORCED'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">enforced</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.addconstraint_sql-2073"><a href="#Generator.addconstraint_sql-2073"><span class="linenos">2073</span></a> -</span><span id="Generator.addconstraint_sql-2074"><a href="#Generator.addconstraint_sql-2074"><span class="linenos">2074</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.addconstraint_sql-2098"><a href="#Generator.addconstraint_sql-2098"><span class="linenos">2098</span></a> <span class="k">def</span> <span class="nf">addconstraint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">AddConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.addconstraint_sql-2099"><a href="#Generator.addconstraint_sql-2099"><span class="linenos">2099</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.addconstraint_sql-2100"><a href="#Generator.addconstraint_sql-2100"><span class="linenos">2100</span></a> <span class="n">expression_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator.addconstraint_sql-2101"><a href="#Generator.addconstraint_sql-2101"><span class="linenos">2101</span></a> <span class="n">add_constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ADD CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">"ADD"</span> +</span><span id="Generator.addconstraint_sql-2102"><a href="#Generator.addconstraint_sql-2102"><span class="linenos">2102</span></a> +</span><span id="Generator.addconstraint_sql-2103"><a href="#Generator.addconstraint_sql-2103"><span class="linenos">2103</span></a> <span class="n">enforced</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"enforced"</span><span class="p">)</span> +</span><span id="Generator.addconstraint_sql-2104"><a href="#Generator.addconstraint_sql-2104"><span class="linenos">2104</span></a> <span class="k">if</span> <span class="n">enforced</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.addconstraint_sql-2105"><a href="#Generator.addconstraint_sql-2105"><span class="linenos">2105</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> CHECK (</span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="s1">' ENFORCED'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">enforced</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.addconstraint_sql-2106"><a href="#Generator.addconstraint_sql-2106"><span class="linenos">2106</span></a> +</span><span id="Generator.addconstraint_sql-2107"><a href="#Generator.addconstraint_sql-2107"><span class="linenos">2107</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10304,13 +10472,13 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.distinct_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.distinct_sql-2076"><a href="#Generator.distinct_sql-2076"><span class="linenos">2076</span></a> <span class="k">def</span> <span class="nf">distinct_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distinct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.distinct_sql-2077"><a href="#Generator.distinct_sql-2077"><span class="linenos">2077</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.distinct_sql-2078"><a href="#Generator.distinct_sql-2078"><span class="linenos">2078</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.distinct_sql-2079"><a href="#Generator.distinct_sql-2079"><span class="linenos">2079</span></a> -</span><span id="Generator.distinct_sql-2080"><a href="#Generator.distinct_sql-2080"><span class="linenos">2080</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">)</span> -</span><span id="Generator.distinct_sql-2081"><a href="#Generator.distinct_sql-2081"><span class="linenos">2081</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">on</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.distinct_sql-2082"><a href="#Generator.distinct_sql-2082"><span class="linenos">2082</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DISTINCT</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.distinct_sql-2109"><a href="#Generator.distinct_sql-2109"><span class="linenos">2109</span></a> <span class="k">def</span> <span class="nf">distinct_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distinct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.distinct_sql-2110"><a href="#Generator.distinct_sql-2110"><span class="linenos">2110</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.distinct_sql-2111"><a href="#Generator.distinct_sql-2111"><span class="linenos">2111</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.distinct_sql-2112"><a href="#Generator.distinct_sql-2112"><span class="linenos">2112</span></a> +</span><span id="Generator.distinct_sql-2113"><a href="#Generator.distinct_sql-2113"><span class="linenos">2113</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">)</span> +</span><span id="Generator.distinct_sql-2114"><a href="#Generator.distinct_sql-2114"><span class="linenos">2114</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">on</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.distinct_sql-2115"><a href="#Generator.distinct_sql-2115"><span class="linenos">2115</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DISTINCT</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10328,8 +10496,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.ignorenulls_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.ignorenulls_sql-2084"><a href="#Generator.ignorenulls_sql-2084"><span class="linenos">2084</span></a> <span class="k">def</span> <span class="nf">ignorenulls_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IgnoreNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.ignorenulls_sql-2085"><a href="#Generator.ignorenulls_sql-2085"><span class="linenos">2085</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> IGNORE NULLS"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.ignorenulls_sql-2117"><a href="#Generator.ignorenulls_sql-2117"><span class="linenos">2117</span></a> <span class="k">def</span> <span class="nf">ignorenulls_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IgnoreNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.ignorenulls_sql-2118"><a href="#Generator.ignorenulls_sql-2118"><span class="linenos">2118</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> IGNORE NULLS"</span> </span></pre></div> @@ -10347,8 +10515,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.respectnulls_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.respectnulls_sql-2087"><a href="#Generator.respectnulls_sql-2087"><span class="linenos">2087</span></a> <span class="k">def</span> <span class="nf">respectnulls_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RespectNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.respectnulls_sql-2088"><a href="#Generator.respectnulls_sql-2088"><span class="linenos">2088</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> RESPECT NULLS"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.respectnulls_sql-2120"><a href="#Generator.respectnulls_sql-2120"><span class="linenos">2120</span></a> <span class="k">def</span> <span class="nf">respectnulls_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">RespectNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.respectnulls_sql-2121"><a href="#Generator.respectnulls_sql-2121"><span class="linenos">2121</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> RESPECT NULLS"</span> </span></pre></div> @@ -10366,13 +10534,13 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.intdiv_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.intdiv_sql-2090"><a href="#Generator.intdiv_sql-2090"><span class="linenos">2090</span></a> <span class="k">def</span> <span class="nf">intdiv_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.intdiv_sql-2091"><a href="#Generator.intdiv_sql-2091"><span class="linenos">2091</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="Generator.intdiv_sql-2092"><a href="#Generator.intdiv_sql-2092"><span class="linenos">2092</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">(</span> -</span><span id="Generator.intdiv_sql-2093"><a href="#Generator.intdiv_sql-2093"><span class="linenos">2093</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">),</span> -</span><span id="Generator.intdiv_sql-2094"><a href="#Generator.intdiv_sql-2094"><span class="linenos">2094</span></a> <span class="n">to</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">),</span> -</span><span id="Generator.intdiv_sql-2095"><a href="#Generator.intdiv_sql-2095"><span class="linenos">2095</span></a> <span class="p">)</span> -</span><span id="Generator.intdiv_sql-2096"><a href="#Generator.intdiv_sql-2096"><span class="linenos">2096</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.intdiv_sql-2123"><a href="#Generator.intdiv_sql-2123"><span class="linenos">2123</span></a> <span class="k">def</span> <span class="nf">intdiv_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IntDiv</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.intdiv_sql-2124"><a href="#Generator.intdiv_sql-2124"><span class="linenos">2124</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="Generator.intdiv_sql-2125"><a href="#Generator.intdiv_sql-2125"><span class="linenos">2125</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">(</span> +</span><span id="Generator.intdiv_sql-2126"><a href="#Generator.intdiv_sql-2126"><span class="linenos">2126</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">),</span> +</span><span id="Generator.intdiv_sql-2127"><a href="#Generator.intdiv_sql-2127"><span class="linenos">2127</span></a> <span class="n">to</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">),</span> +</span><span id="Generator.intdiv_sql-2128"><a href="#Generator.intdiv_sql-2128"><span class="linenos">2128</span></a> <span class="p">)</span> +</span><span id="Generator.intdiv_sql-2129"><a href="#Generator.intdiv_sql-2129"><span class="linenos">2129</span></a> <span class="p">)</span> </span></pre></div> @@ -10390,8 +10558,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.dpipe_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dpipe_sql-2098"><a href="#Generator.dpipe_sql-2098"><span class="linenos">2098</span></a> <span class="k">def</span> <span class="nf">dpipe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.dpipe_sql-2099"><a href="#Generator.dpipe_sql-2099"><span class="linenos">2099</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"||"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dpipe_sql-2131"><a href="#Generator.dpipe_sql-2131"><span class="linenos">2131</span></a> <span class="k">def</span> <span class="nf">dpipe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.dpipe_sql-2132"><a href="#Generator.dpipe_sql-2132"><span class="linenos">2132</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"||"</span><span class="p">)</span> </span></pre></div> @@ -10409,10 +10577,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.safedpipe_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.safedpipe_sql-2101"><a href="#Generator.safedpipe_sql-2101"><span class="linenos">2101</span></a> <span class="k">def</span> <span class="nf">safedpipe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.safedpipe_sql-2102"><a href="#Generator.safedpipe_sql-2102"><span class="linenos">2102</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> -</span><span id="Generator.safedpipe_sql-2103"><a href="#Generator.safedpipe_sql-2103"><span class="linenos">2103</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">,</span> <span class="o">*</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">()))</span> -</span><span id="Generator.safedpipe_sql-2104"><a href="#Generator.safedpipe_sql-2104"><span class="linenos">2104</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">dpipe_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.safedpipe_sql-2134"><a href="#Generator.safedpipe_sql-2134"><span class="linenos">2134</span></a> <span class="k">def</span> <span class="nf">safedpipe_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeDPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.safedpipe_sql-2135"><a href="#Generator.safedpipe_sql-2135"><span class="linenos">2135</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> +</span><span id="Generator.safedpipe_sql-2136"><a href="#Generator.safedpipe_sql-2136"><span class="linenos">2136</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">,</span> <span class="o">*</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">()))</span> +</span><span id="Generator.safedpipe_sql-2137"><a href="#Generator.safedpipe_sql-2137"><span class="linenos">2137</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">dpipe_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -10430,8 +10598,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.div_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.div_sql-2106"><a href="#Generator.div_sql-2106"><span class="linenos">2106</span></a> <span class="k">def</span> <span class="nf">div_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.div_sql-2107"><a href="#Generator.div_sql-2107"><span class="linenos">2107</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"/"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.div_sql-2139"><a href="#Generator.div_sql-2139"><span class="linenos">2139</span></a> <span class="k">def</span> <span class="nf">div_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.div_sql-2140"><a href="#Generator.div_sql-2140"><span class="linenos">2140</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"/"</span><span class="p">)</span> </span></pre></div> @@ -10449,8 +10617,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.overlaps_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.overlaps_sql-2109"><a href="#Generator.overlaps_sql-2109"><span class="linenos">2109</span></a> <span class="k">def</span> <span class="nf">overlaps_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Overlaps</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.overlaps_sql-2110"><a href="#Generator.overlaps_sql-2110"><span class="linenos">2110</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OVERLAPS"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.overlaps_sql-2142"><a href="#Generator.overlaps_sql-2142"><span class="linenos">2142</span></a> <span class="k">def</span> <span class="nf">overlaps_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Overlaps</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.overlaps_sql-2143"><a href="#Generator.overlaps_sql-2143"><span class="linenos">2143</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OVERLAPS"</span><span class="p">)</span> </span></pre></div> @@ -10468,8 +10636,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.distance_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.distance_sql-2112"><a href="#Generator.distance_sql-2112"><span class="linenos">2112</span></a> <span class="k">def</span> <span class="nf">distance_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distance</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.distance_sql-2113"><a href="#Generator.distance_sql-2113"><span class="linenos">2113</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<->"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.distance_sql-2145"><a href="#Generator.distance_sql-2145"><span class="linenos">2145</span></a> <span class="k">def</span> <span class="nf">distance_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Distance</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.distance_sql-2146"><a href="#Generator.distance_sql-2146"><span class="linenos">2146</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<->"</span><span class="p">)</span> </span></pre></div> @@ -10487,8 +10655,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.dot_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dot_sql-2115"><a href="#Generator.dot_sql-2115"><span class="linenos">2115</span></a> <span class="k">def</span> <span class="nf">dot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.dot_sql-2116"><a href="#Generator.dot_sql-2116"><span class="linenos">2116</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dot_sql-2148"><a href="#Generator.dot_sql-2148"><span class="linenos">2148</span></a> <span class="k">def</span> <span class="nf">dot_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.dot_sql-2149"><a href="#Generator.dot_sql-2149"><span class="linenos">2149</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10506,8 +10674,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.eq_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.eq_sql-2118"><a href="#Generator.eq_sql-2118"><span class="linenos">2118</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.eq_sql-2119"><a href="#Generator.eq_sql-2119"><span class="linenos">2119</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.eq_sql-2151"><a href="#Generator.eq_sql-2151"><span class="linenos">2151</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.eq_sql-2152"><a href="#Generator.eq_sql-2152"><span class="linenos">2152</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> </span></pre></div> @@ -10525,8 +10693,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.escape_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.escape_sql-2121"><a href="#Generator.escape_sql-2121"><span class="linenos">2121</span></a> <span class="k">def</span> <span class="nf">escape_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Escape</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.escape_sql-2122"><a href="#Generator.escape_sql-2122"><span class="linenos">2122</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ESCAPE"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.escape_sql-2154"><a href="#Generator.escape_sql-2154"><span class="linenos">2154</span></a> <span class="k">def</span> <span class="nf">escape_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Escape</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.escape_sql-2155"><a href="#Generator.escape_sql-2155"><span class="linenos">2155</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ESCAPE"</span><span class="p">)</span> </span></pre></div> @@ -10544,8 +10712,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.glob_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.glob_sql-2124"><a href="#Generator.glob_sql-2124"><span class="linenos">2124</span></a> <span class="k">def</span> <span class="nf">glob_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Glob</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.glob_sql-2125"><a href="#Generator.glob_sql-2125"><span class="linenos">2125</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"GLOB"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.glob_sql-2157"><a href="#Generator.glob_sql-2157"><span class="linenos">2157</span></a> <span class="k">def</span> <span class="nf">glob_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Glob</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.glob_sql-2158"><a href="#Generator.glob_sql-2158"><span class="linenos">2158</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"GLOB"</span><span class="p">)</span> </span></pre></div> @@ -10563,8 +10731,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.gt_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.gt_sql-2127"><a href="#Generator.gt_sql-2127"><span class="linenos">2127</span></a> <span class="k">def</span> <span class="nf">gt_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.gt_sql-2128"><a href="#Generator.gt_sql-2128"><span class="linenos">2128</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.gt_sql-2160"><a href="#Generator.gt_sql-2160"><span class="linenos">2160</span></a> <span class="k">def</span> <span class="nf">gt_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.gt_sql-2161"><a href="#Generator.gt_sql-2161"><span class="linenos">2161</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">"</span><span class="p">)</span> </span></pre></div> @@ -10582,8 +10750,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.gte_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.gte_sql-2130"><a href="#Generator.gte_sql-2130"><span class="linenos">2130</span></a> <span class="k">def</span> <span class="nf">gte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.gte_sql-2131"><a href="#Generator.gte_sql-2131"><span class="linenos">2131</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">="</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.gte_sql-2163"><a href="#Generator.gte_sql-2163"><span class="linenos">2163</span></a> <span class="k">def</span> <span class="nf">gte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">GTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.gte_sql-2164"><a href="#Generator.gte_sql-2164"><span class="linenos">2164</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">="</span><span class="p">)</span> </span></pre></div> @@ -10601,8 +10769,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.ilike_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.ilike_sql-2133"><a href="#Generator.ilike_sql-2133"><span class="linenos">2133</span></a> <span class="k">def</span> <span class="nf">ilike_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.ilike_sql-2134"><a href="#Generator.ilike_sql-2134"><span class="linenos">2134</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.ilike_sql-2166"><a href="#Generator.ilike_sql-2166"><span class="linenos">2166</span></a> <span class="k">def</span> <span class="nf">ilike_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILike</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.ilike_sql-2167"><a href="#Generator.ilike_sql-2167"><span class="linenos">2167</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE"</span><span class="p">)</span> </span></pre></div> @@ -10620,8 +10788,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.ilikeany_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.ilikeany_sql-2136"><a href="#Generator.ilikeany_sql-2136"><span class="linenos">2136</span></a> <span class="k">def</span> <span class="nf">ilikeany_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.ilikeany_sql-2137"><a href="#Generator.ilikeany_sql-2137"><span class="linenos">2137</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE ANY"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.ilikeany_sql-2169"><a href="#Generator.ilikeany_sql-2169"><span class="linenos">2169</span></a> <span class="k">def</span> <span class="nf">ilikeany_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ILikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.ilikeany_sql-2170"><a href="#Generator.ilikeany_sql-2170"><span class="linenos">2170</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE ANY"</span><span class="p">)</span> </span></pre></div> @@ -10639,12 +10807,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.is_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.is_sql-2139"><a href="#Generator.is_sql-2139"><span class="linenos">2139</span></a> <span class="k">def</span> <span class="nf">is_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.is_sql-2140"><a href="#Generator.is_sql-2140"><span class="linenos">2140</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">IS_BOOL_ALLOWED</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Boolean</span><span class="p">):</span> -</span><span id="Generator.is_sql-2141"><a href="#Generator.is_sql-2141"><span class="linenos">2141</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="Generator.is_sql-2142"><a href="#Generator.is_sql-2142"><span class="linenos">2142</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">not_</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="Generator.is_sql-2143"><a href="#Generator.is_sql-2143"><span class="linenos">2143</span></a> <span class="p">)</span> -</span><span id="Generator.is_sql-2144"><a href="#Generator.is_sql-2144"><span class="linenos">2144</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.is_sql-2172"><a href="#Generator.is_sql-2172"><span class="linenos">2172</span></a> <span class="k">def</span> <span class="nf">is_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.is_sql-2173"><a href="#Generator.is_sql-2173"><span class="linenos">2173</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">IS_BOOL_ALLOWED</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Boolean</span><span class="p">):</span> +</span><span id="Generator.is_sql-2174"><a href="#Generator.is_sql-2174"><span class="linenos">2174</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="Generator.is_sql-2175"><a href="#Generator.is_sql-2175"><span class="linenos">2175</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">not_</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="Generator.is_sql-2176"><a href="#Generator.is_sql-2176"><span class="linenos">2176</span></a> <span class="p">)</span> +</span><span id="Generator.is_sql-2177"><a href="#Generator.is_sql-2177"><span class="linenos">2177</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS"</span><span class="p">)</span> </span></pre></div> @@ -10662,8 +10830,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.like_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.like_sql-2146"><a href="#Generator.like_sql-2146"><span class="linenos">2146</span></a> <span class="k">def</span> <span class="nf">like_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Like</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.like_sql-2147"><a href="#Generator.like_sql-2147"><span class="linenos">2147</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.like_sql-2179"><a href="#Generator.like_sql-2179"><span class="linenos">2179</span></a> <span class="k">def</span> <span class="nf">like_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Like</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.like_sql-2180"><a href="#Generator.like_sql-2180"><span class="linenos">2180</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE"</span><span class="p">)</span> </span></pre></div> @@ -10681,8 +10849,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.likeany_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.likeany_sql-2149"><a href="#Generator.likeany_sql-2149"><span class="linenos">2149</span></a> <span class="k">def</span> <span class="nf">likeany_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.likeany_sql-2150"><a href="#Generator.likeany_sql-2150"><span class="linenos">2150</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE ANY"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.likeany_sql-2182"><a href="#Generator.likeany_sql-2182"><span class="linenos">2182</span></a> <span class="k">def</span> <span class="nf">likeany_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.likeany_sql-2183"><a href="#Generator.likeany_sql-2183"><span class="linenos">2183</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE ANY"</span><span class="p">)</span> </span></pre></div> @@ -10700,8 +10868,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.similarto_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.similarto_sql-2152"><a href="#Generator.similarto_sql-2152"><span class="linenos">2152</span></a> <span class="k">def</span> <span class="nf">similarto_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SimilarTo</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.similarto_sql-2153"><a href="#Generator.similarto_sql-2153"><span class="linenos">2153</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"SIMILAR TO"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.similarto_sql-2185"><a href="#Generator.similarto_sql-2185"><span class="linenos">2185</span></a> <span class="k">def</span> <span class="nf">similarto_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">SimilarTo</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.similarto_sql-2186"><a href="#Generator.similarto_sql-2186"><span class="linenos">2186</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"SIMILAR TO"</span><span class="p">)</span> </span></pre></div> @@ -10719,8 +10887,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.lt_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lt_sql-2155"><a href="#Generator.lt_sql-2155"><span class="linenos">2155</span></a> <span class="k">def</span> <span class="nf">lt_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.lt_sql-2156"><a href="#Generator.lt_sql-2156"><span class="linenos">2156</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lt_sql-2188"><a href="#Generator.lt_sql-2188"><span class="linenos">2188</span></a> <span class="k">def</span> <span class="nf">lt_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.lt_sql-2189"><a href="#Generator.lt_sql-2189"><span class="linenos">2189</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<"</span><span class="p">)</span> </span></pre></div> @@ -10738,8 +10906,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.lte_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lte_sql-2158"><a href="#Generator.lte_sql-2158"><span class="linenos">2158</span></a> <span class="k">def</span> <span class="nf">lte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.lte_sql-2159"><a href="#Generator.lte_sql-2159"><span class="linenos">2159</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<="</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lte_sql-2191"><a href="#Generator.lte_sql-2191"><span class="linenos">2191</span></a> <span class="k">def</span> <span class="nf">lte_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">LTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.lte_sql-2192"><a href="#Generator.lte_sql-2192"><span class="linenos">2192</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<="</span><span class="p">)</span> </span></pre></div> @@ -10757,8 +10925,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.mod_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mod_sql-2161"><a href="#Generator.mod_sql-2161"><span class="linenos">2161</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.mod_sql-2162"><a href="#Generator.mod_sql-2162"><span class="linenos">2162</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"%"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mod_sql-2194"><a href="#Generator.mod_sql-2194"><span class="linenos">2194</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.mod_sql-2195"><a href="#Generator.mod_sql-2195"><span class="linenos">2195</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"%"</span><span class="p">)</span> </span></pre></div> @@ -10776,8 +10944,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.mul_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mul_sql-2164"><a href="#Generator.mul_sql-2164"><span class="linenos">2164</span></a> <span class="k">def</span> <span class="nf">mul_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mul</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.mul_sql-2165"><a href="#Generator.mul_sql-2165"><span class="linenos">2165</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"*"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mul_sql-2197"><a href="#Generator.mul_sql-2197"><span class="linenos">2197</span></a> <span class="k">def</span> <span class="nf">mul_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Mul</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.mul_sql-2198"><a href="#Generator.mul_sql-2198"><span class="linenos">2198</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"*"</span><span class="p">)</span> </span></pre></div> @@ -10795,8 +10963,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.neq_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.neq_sql-2167"><a href="#Generator.neq_sql-2167"><span class="linenos">2167</span></a> <span class="k">def</span> <span class="nf">neq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.neq_sql-2168"><a href="#Generator.neq_sql-2168"><span class="linenos">2168</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<>"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.neq_sql-2200"><a href="#Generator.neq_sql-2200"><span class="linenos">2200</span></a> <span class="k">def</span> <span class="nf">neq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.neq_sql-2201"><a href="#Generator.neq_sql-2201"><span class="linenos">2201</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<>"</span><span class="p">)</span> </span></pre></div> @@ -10814,8 +10982,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.nullsafeeq_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.nullsafeeq_sql-2170"><a href="#Generator.nullsafeeq_sql-2170"><span class="linenos">2170</span></a> <span class="k">def</span> <span class="nf">nullsafeeq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.nullsafeeq_sql-2171"><a href="#Generator.nullsafeeq_sql-2171"><span class="linenos">2171</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS NOT DISTINCT FROM"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.nullsafeeq_sql-2203"><a href="#Generator.nullsafeeq_sql-2203"><span class="linenos">2203</span></a> <span class="k">def</span> <span class="nf">nullsafeeq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.nullsafeeq_sql-2204"><a href="#Generator.nullsafeeq_sql-2204"><span class="linenos">2204</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS NOT DISTINCT FROM"</span><span class="p">)</span> </span></pre></div> @@ -10833,8 +11001,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.nullsafeneq_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.nullsafeneq_sql-2173"><a href="#Generator.nullsafeneq_sql-2173"><span class="linenos">2173</span></a> <span class="k">def</span> <span class="nf">nullsafeneq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeNEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.nullsafeneq_sql-2174"><a href="#Generator.nullsafeneq_sql-2174"><span class="linenos">2174</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS DISTINCT FROM"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.nullsafeneq_sql-2206"><a href="#Generator.nullsafeneq_sql-2206"><span class="linenos">2206</span></a> <span class="k">def</span> <span class="nf">nullsafeneq_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeNEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.nullsafeneq_sql-2207"><a href="#Generator.nullsafeneq_sql-2207"><span class="linenos">2207</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS DISTINCT FROM"</span><span class="p">)</span> </span></pre></div> @@ -10852,8 +11020,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.or_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.or_sql-2176"><a href="#Generator.or_sql-2176"><span class="linenos">2176</span></a> <span class="k">def</span> <span class="nf">or_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Or</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.or_sql-2177"><a href="#Generator.or_sql-2177"><span class="linenos">2177</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OR"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.or_sql-2209"><a href="#Generator.or_sql-2209"><span class="linenos">2209</span></a> <span class="k">def</span> <span class="nf">or_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Or</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.or_sql-2210"><a href="#Generator.or_sql-2210"><span class="linenos">2210</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OR"</span><span class="p">)</span> </span></pre></div> @@ -10871,8 +11039,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.slice_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.slice_sql-2179"><a href="#Generator.slice_sql-2179"><span class="linenos">2179</span></a> <span class="k">def</span> <span class="nf">slice_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Slice</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.slice_sql-2180"><a href="#Generator.slice_sql-2180"><span class="linenos">2180</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">":"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.slice_sql-2212"><a href="#Generator.slice_sql-2212"><span class="linenos">2212</span></a> <span class="k">def</span> <span class="nf">slice_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Slice</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.slice_sql-2213"><a href="#Generator.slice_sql-2213"><span class="linenos">2213</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">":"</span><span class="p">)</span> </span></pre></div> @@ -10890,8 +11058,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.sub_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sub_sql-2182"><a href="#Generator.sub_sql-2182"><span class="linenos">2182</span></a> <span class="k">def</span> <span class="nf">sub_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Sub</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.sub_sql-2183"><a href="#Generator.sub_sql-2183"><span class="linenos">2183</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sub_sql-2215"><a href="#Generator.sub_sql-2215"><span class="linenos">2215</span></a> <span class="k">def</span> <span class="nf">sub_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Sub</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.sub_sql-2216"><a href="#Generator.sub_sql-2216"><span class="linenos">2216</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)</span> </span></pre></div> @@ -10909,8 +11077,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.trycast_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.trycast_sql-2185"><a href="#Generator.trycast_sql-2185"><span class="linenos">2185</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.trycast_sql-2186"><a href="#Generator.trycast_sql-2186"><span class="linenos">2186</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TRY_CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'to'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.trycast_sql-2218"><a href="#Generator.trycast_sql-2218"><span class="linenos">2218</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.trycast_sql-2219"><a href="#Generator.trycast_sql-2219"><span class="linenos">2219</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TRY_CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'to'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -10928,12 +11096,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.use_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.use_sql-2188"><a href="#Generator.use_sql-2188"><span class="linenos">2188</span></a> <span class="k">def</span> <span class="nf">use_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Use</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.use_sql-2189"><a href="#Generator.use_sql-2189"><span class="linenos">2189</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator.use_sql-2190"><a href="#Generator.use_sql-2190"><span class="linenos">2190</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.use_sql-2191"><a href="#Generator.use_sql-2191"><span class="linenos">2191</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.use_sql-2192"><a href="#Generator.use_sql-2192"><span class="linenos">2192</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.use_sql-2193"><a href="#Generator.use_sql-2193"><span class="linenos">2193</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"USE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.use_sql-2221"><a href="#Generator.use_sql-2221"><span class="linenos">2221</span></a> <span class="k">def</span> <span class="nf">use_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Use</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.use_sql-2222"><a href="#Generator.use_sql-2222"><span class="linenos">2222</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator.use_sql-2223"><a href="#Generator.use_sql-2223"><span class="linenos">2223</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.use_sql-2224"><a href="#Generator.use_sql-2224"><span class="linenos">2224</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.use_sql-2225"><a href="#Generator.use_sql-2225"><span class="linenos">2225</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.use_sql-2226"><a href="#Generator.use_sql-2226"><span class="linenos">2226</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"USE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10951,9 +11119,9 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.binary"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.binary-2195"><a href="#Generator.binary-2195"><span class="linenos">2195</span></a> <span class="k">def</span> <span class="nf">binary</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Binary</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.binary-2196"><a href="#Generator.binary-2196"><span class="linenos">2196</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">op</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> -</span><span id="Generator.binary-2197"><a href="#Generator.binary-2197"><span class="linenos">2197</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.binary-2228"><a href="#Generator.binary-2228"><span class="linenos">2228</span></a> <span class="k">def</span> <span class="nf">binary</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Binary</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.binary-2229"><a href="#Generator.binary-2229"><span class="linenos">2229</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">op</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> +</span><span id="Generator.binary-2230"><a href="#Generator.binary-2230"><span class="linenos">2230</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -10971,16 +11139,16 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.function_fallback_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.function_fallback_sql-2199"><a href="#Generator.function_fallback_sql-2199"><span class="linenos">2199</span></a> <span class="k">def</span> <span class="nf">function_fallback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.function_fallback_sql-2200"><a href="#Generator.function_fallback_sql-2200"><span class="linenos">2200</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator.function_fallback_sql-2201"><a href="#Generator.function_fallback_sql-2201"><span class="linenos">2201</span></a> <span class="k">for</span> <span class="n">arg_value</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> -</span><span id="Generator.function_fallback_sql-2202"><a href="#Generator.function_fallback_sql-2202"><span class="linenos">2202</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">arg_value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="Generator.function_fallback_sql-2203"><a href="#Generator.function_fallback_sql-2203"><span class="linenos">2203</span></a> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">arg_value</span><span class="p">:</span> -</span><span id="Generator.function_fallback_sql-2204"><a href="#Generator.function_fallback_sql-2204"><span class="linenos">2204</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="Generator.function_fallback_sql-2205"><a href="#Generator.function_fallback_sql-2205"><span class="linenos">2205</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.function_fallback_sql-2206"><a href="#Generator.function_fallback_sql-2206"><span class="linenos">2206</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">arg_value</span><span class="p">)</span> -</span><span id="Generator.function_fallback_sql-2207"><a href="#Generator.function_fallback_sql-2207"><span class="linenos">2207</span></a> -</span><span id="Generator.function_fallback_sql-2208"><a href="#Generator.function_fallback_sql-2208"><span class="linenos">2208</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">sql_name</span><span class="p">(),</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.function_fallback_sql-2232"><a href="#Generator.function_fallback_sql-2232"><span class="linenos">2232</span></a> <span class="k">def</span> <span class="nf">function_fallback_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.function_fallback_sql-2233"><a href="#Generator.function_fallback_sql-2233"><span class="linenos">2233</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator.function_fallback_sql-2234"><a href="#Generator.function_fallback_sql-2234"><span class="linenos">2234</span></a> <span class="k">for</span> <span class="n">arg_value</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> +</span><span id="Generator.function_fallback_sql-2235"><a href="#Generator.function_fallback_sql-2235"><span class="linenos">2235</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">arg_value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="Generator.function_fallback_sql-2236"><a href="#Generator.function_fallback_sql-2236"><span class="linenos">2236</span></a> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">arg_value</span><span class="p">:</span> +</span><span id="Generator.function_fallback_sql-2237"><a href="#Generator.function_fallback_sql-2237"><span class="linenos">2237</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="Generator.function_fallback_sql-2238"><a href="#Generator.function_fallback_sql-2238"><span class="linenos">2238</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.function_fallback_sql-2239"><a href="#Generator.function_fallback_sql-2239"><span class="linenos">2239</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">arg_value</span><span class="p">)</span> +</span><span id="Generator.function_fallback_sql-2240"><a href="#Generator.function_fallback_sql-2240"><span class="linenos">2240</span></a> +</span><span id="Generator.function_fallback_sql-2241"><a href="#Generator.function_fallback_sql-2241"><span class="linenos">2241</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">sql_name</span><span class="p">(),</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> </span></pre></div> @@ -10998,14 +11166,14 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.func"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.func-2210"><a href="#Generator.func-2210"><span class="linenos">2210</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span> -</span><span id="Generator.func-2211"><a href="#Generator.func-2211"><span class="linenos">2211</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator.func-2212"><a href="#Generator.func-2212"><span class="linenos">2212</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="Generator.func-2213"><a href="#Generator.func-2213"><span class="linenos">2213</span></a> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">|</span> <span class="nb">str</span><span class="p">],</span> -</span><span id="Generator.func-2214"><a href="#Generator.func-2214"><span class="linenos">2214</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"("</span><span class="p">,</span> -</span><span id="Generator.func-2215"><a href="#Generator.func-2215"><span class="linenos">2215</span></a> <span class="n">suffix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">")"</span><span class="p">,</span> -</span><span id="Generator.func-2216"><a href="#Generator.func-2216"><span class="linenos">2216</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.func-2217"><a href="#Generator.func-2217"><span class="linenos">2217</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">normalize_func</span><span class="p">(</span><span class="n">name</span><span class="p">)</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.func-2243"><a href="#Generator.func-2243"><span class="linenos">2243</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span> +</span><span id="Generator.func-2244"><a href="#Generator.func-2244"><span class="linenos">2244</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator.func-2245"><a href="#Generator.func-2245"><span class="linenos">2245</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="Generator.func-2246"><a href="#Generator.func-2246"><span class="linenos">2246</span></a> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">|</span> <span class="nb">str</span><span class="p">],</span> +</span><span id="Generator.func-2247"><a href="#Generator.func-2247"><span class="linenos">2247</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"("</span><span class="p">,</span> +</span><span id="Generator.func-2248"><a href="#Generator.func-2248"><span class="linenos">2248</span></a> <span class="n">suffix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">")"</span><span class="p">,</span> +</span><span id="Generator.func-2249"><a href="#Generator.func-2249"><span class="linenos">2249</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.func-2250"><a href="#Generator.func-2250"><span class="linenos">2250</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">normalize_func</span><span class="p">(</span><span class="n">name</span><span class="p">)</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11023,11 +11191,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.format_args"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.format_args-2219"><a href="#Generator.format_args-2219"><span class="linenos">2219</span></a> <span class="k">def</span> <span class="nf">format_args</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.format_args-2220"><a href="#Generator.format_args-2220"><span class="linenos">2220</span></a> <span class="n">arg_sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span> <span class="k">if</span> <span class="n">arg</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="Generator.format_args-2221"><a href="#Generator.format_args-2221"><span class="linenos">2221</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span><span class="p">:</span> -</span><span id="Generator.format_args-2222"><a href="#Generator.format_args-2222"><span class="linenos">2222</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="sa">f</span><span class="s2">",</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">skip_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.format_args-2223"><a href="#Generator.format_args-2223"><span class="linenos">2223</span></a> <span class="k">return</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.format_args-2252"><a href="#Generator.format_args-2252"><span class="linenos">2252</span></a> <span class="k">def</span> <span class="nf">format_args</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.format_args-2253"><a href="#Generator.format_args-2253"><span class="linenos">2253</span></a> <span class="n">arg_sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span> <span class="k">if</span> <span class="n">arg</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="Generator.format_args-2254"><a href="#Generator.format_args-2254"><span class="linenos">2254</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span><span class="p">:</span> +</span><span id="Generator.format_args-2255"><a href="#Generator.format_args-2255"><span class="linenos">2255</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="sa">f</span><span class="s2">",</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">skip_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.format_args-2256"><a href="#Generator.format_args-2256"><span class="linenos">2256</span></a> <span class="k">return</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> </span></pre></div> @@ -11045,8 +11213,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.text_width"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.text_width-2225"><a href="#Generator.text_width-2225"><span class="linenos">2225</span></a> <span class="k">def</span> <span class="nf">text_width</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> -</span><span id="Generator.text_width-2226"><a href="#Generator.text_width-2226"><span class="linenos">2226</span></a> <span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.text_width-2258"><a href="#Generator.text_width-2258"><span class="linenos">2258</span></a> <span class="k">def</span> <span class="nf">text_width</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> +</span><span id="Generator.text_width-2259"><a href="#Generator.text_width-2259"><span class="linenos">2259</span></a> <span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> </span></pre></div> @@ -11064,10 +11232,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.format_time"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.format_time-2228"><a href="#Generator.format_time-2228"><span class="linenos">2228</span></a> <span class="k">def</span> <span class="nf">format_time</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Generator.format_time-2229"><a href="#Generator.format_time-2229"><span class="linenos">2229</span></a> <span class="k">return</span> <span class="n">format_time</span><span class="p">(</span> -</span><span id="Generator.format_time-2230"><a href="#Generator.format_time-2230"><span class="linenos">2230</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span> -</span><span id="Generator.format_time-2231"><a href="#Generator.format_time-2231"><span class="linenos">2231</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.format_time-2261"><a href="#Generator.format_time-2261"><span class="linenos">2261</span></a> <span class="k">def</span> <span class="nf">format_time</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Generator.format_time-2262"><a href="#Generator.format_time-2262"><span class="linenos">2262</span></a> <span class="k">return</span> <span class="n">format_time</span><span class="p">(</span> +</span><span id="Generator.format_time-2263"><a href="#Generator.format_time-2263"><span class="linenos">2263</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span> +</span><span id="Generator.format_time-2264"><a href="#Generator.format_time-2264"><span class="linenos">2264</span></a> <span class="p">)</span> </span></pre></div> @@ -11085,47 +11253,47 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.expressions"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.expressions-2233"><a href="#Generator.expressions-2233"><span class="linenos">2233</span></a> <span class="k">def</span> <span class="nf">expressions</span><span class="p">(</span> -</span><span id="Generator.expressions-2234"><a href="#Generator.expressions-2234"><span class="linenos">2234</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator.expressions-2235"><a href="#Generator.expressions-2235"><span class="linenos">2235</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.expressions-2236"><a href="#Generator.expressions-2236"><span class="linenos">2236</span></a> <span class="n">key</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.expressions-2237"><a href="#Generator.expressions-2237"><span class="linenos">2237</span></a> <span class="n">sqls</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.expressions-2238"><a href="#Generator.expressions-2238"><span class="linenos">2238</span></a> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Generator.expressions-2239"><a href="#Generator.expressions-2239"><span class="linenos">2239</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Generator.expressions-2240"><a href="#Generator.expressions-2240"><span class="linenos">2240</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">,</span> -</span><span id="Generator.expressions-2241"><a href="#Generator.expressions-2241"><span class="linenos">2241</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="Generator.expressions-2242"><a href="#Generator.expressions-2242"><span class="linenos">2242</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.expressions-2243"><a href="#Generator.expressions-2243"><span class="linenos">2243</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span> <span class="ow">or</span> <span class="s2">"expressions"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span> <span class="k">else</span> <span class="n">sqls</span> -</span><span id="Generator.expressions-2244"><a href="#Generator.expressions-2244"><span class="linenos">2244</span></a> -</span><span id="Generator.expressions-2245"><a href="#Generator.expressions-2245"><span class="linenos">2245</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator.expressions-2246"><a href="#Generator.expressions-2246"><span class="linenos">2246</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator.expressions-2247"><a href="#Generator.expressions-2247"><span class="linenos">2247</span></a> -</span><span id="Generator.expressions-2248"><a href="#Generator.expressions-2248"><span class="linenos">2248</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> -</span><span id="Generator.expressions-2249"><a href="#Generator.expressions-2249"><span class="linenos">2249</span></a> <span class="k">return</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> -</span><span id="Generator.expressions-2250"><a href="#Generator.expressions-2250"><span class="linenos">2250</span></a> -</span><span id="Generator.expressions-2251"><a href="#Generator.expressions-2251"><span class="linenos">2251</span></a> <span class="n">num_sqls</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Generator.expressions-2252"><a href="#Generator.expressions-2252"><span class="linenos">2252</span></a> -</span><span id="Generator.expressions-2253"><a href="#Generator.expressions-2253"><span class="linenos">2253</span></a> <span class="c1"># These are calculated once in case we have the leading_comma / pretty option set, correspondingly</span> -</span><span id="Generator.expressions-2254"><a href="#Generator.expressions-2254"><span class="linenos">2254</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> -</span><span id="Generator.expressions-2255"><a href="#Generator.expressions-2255"><span class="linenos">2255</span></a> <span class="n">stripped_sep</span> <span class="o">=</span> <span class="n">sep</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="Generator.expressions-2256"><a href="#Generator.expressions-2256"><span class="linenos">2256</span></a> -</span><span id="Generator.expressions-2257"><a href="#Generator.expressions-2257"><span class="linenos">2257</span></a> <span class="n">result_sqls</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator.expressions-2258"><a href="#Generator.expressions-2258"><span class="linenos">2258</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expressions</span><span class="p">):</span> -</span><span id="Generator.expressions-2259"><a href="#Generator.expressions-2259"><span class="linenos">2259</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator.expressions-2260"><a href="#Generator.expressions-2260"><span class="linenos">2260</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.expressions-2261"><a href="#Generator.expressions-2261"><span class="linenos">2261</span></a> -</span><span id="Generator.expressions-2262"><a href="#Generator.expressions-2262"><span class="linenos">2262</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="Generator.expressions-2263"><a href="#Generator.expressions-2263"><span class="linenos">2263</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span><span class="p">:</span> -</span><span id="Generator.expressions-2264"><a href="#Generator.expressions-2264"><span class="linenos">2264</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">pad</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.expressions-2265"><a href="#Generator.expressions-2265"><span class="linenos">2265</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.expressions-2266"><a href="#Generator.expressions-2266"><span class="linenos">2266</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="Generator.expressions-2267"><a href="#Generator.expressions-2267"><span class="linenos">2267</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">stripped_sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.expressions-2268"><a href="#Generator.expressions-2268"><span class="linenos">2268</span></a> <span class="p">)</span> -</span><span id="Generator.expressions-2269"><a href="#Generator.expressions-2269"><span class="linenos">2269</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.expressions-2270"><a href="#Generator.expressions-2270"><span class="linenos">2270</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.expressions-2271"><a href="#Generator.expressions-2271"><span class="linenos">2271</span></a> -</span><span id="Generator.expressions-2272"><a href="#Generator.expressions-2272"><span class="linenos">2272</span></a> <span class="n">result_sql</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> -</span><span id="Generator.expressions-2273"><a href="#Generator.expressions-2273"><span class="linenos">2273</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">result_sql</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="k">if</span> <span class="n">indent</span> <span class="k">else</span> <span class="n">result_sql</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.expressions-2266"><a href="#Generator.expressions-2266"><span class="linenos">2266</span></a> <span class="k">def</span> <span class="nf">expressions</span><span class="p">(</span> +</span><span id="Generator.expressions-2267"><a href="#Generator.expressions-2267"><span class="linenos">2267</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator.expressions-2268"><a href="#Generator.expressions-2268"><span class="linenos">2268</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.expressions-2269"><a href="#Generator.expressions-2269"><span class="linenos">2269</span></a> <span class="n">key</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.expressions-2270"><a href="#Generator.expressions-2270"><span class="linenos">2270</span></a> <span class="n">sqls</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.expressions-2271"><a href="#Generator.expressions-2271"><span class="linenos">2271</span></a> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Generator.expressions-2272"><a href="#Generator.expressions-2272"><span class="linenos">2272</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Generator.expressions-2273"><a href="#Generator.expressions-2273"><span class="linenos">2273</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">,</span> +</span><span id="Generator.expressions-2274"><a href="#Generator.expressions-2274"><span class="linenos">2274</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="Generator.expressions-2275"><a href="#Generator.expressions-2275"><span class="linenos">2275</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.expressions-2276"><a href="#Generator.expressions-2276"><span class="linenos">2276</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span> <span class="ow">or</span> <span class="s2">"expressions"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span> <span class="k">else</span> <span class="n">sqls</span> +</span><span id="Generator.expressions-2277"><a href="#Generator.expressions-2277"><span class="linenos">2277</span></a> +</span><span id="Generator.expressions-2278"><a href="#Generator.expressions-2278"><span class="linenos">2278</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator.expressions-2279"><a href="#Generator.expressions-2279"><span class="linenos">2279</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator.expressions-2280"><a href="#Generator.expressions-2280"><span class="linenos">2280</span></a> +</span><span id="Generator.expressions-2281"><a href="#Generator.expressions-2281"><span class="linenos">2281</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> +</span><span id="Generator.expressions-2282"><a href="#Generator.expressions-2282"><span class="linenos">2282</span></a> <span class="k">return</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator.expressions-2283"><a href="#Generator.expressions-2283"><span class="linenos">2283</span></a> +</span><span id="Generator.expressions-2284"><a href="#Generator.expressions-2284"><span class="linenos">2284</span></a> <span class="n">num_sqls</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator.expressions-2285"><a href="#Generator.expressions-2285"><span class="linenos">2285</span></a> +</span><span id="Generator.expressions-2286"><a href="#Generator.expressions-2286"><span class="linenos">2286</span></a> <span class="c1"># These are calculated once in case we have the leading_comma / pretty option set, correspondingly</span> +</span><span id="Generator.expressions-2287"><a href="#Generator.expressions-2287"><span class="linenos">2287</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> +</span><span id="Generator.expressions-2288"><a href="#Generator.expressions-2288"><span class="linenos">2288</span></a> <span class="n">stripped_sep</span> <span class="o">=</span> <span class="n">sep</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="Generator.expressions-2289"><a href="#Generator.expressions-2289"><span class="linenos">2289</span></a> +</span><span id="Generator.expressions-2290"><a href="#Generator.expressions-2290"><span class="linenos">2290</span></a> <span class="n">result_sqls</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator.expressions-2291"><a href="#Generator.expressions-2291"><span class="linenos">2291</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expressions</span><span class="p">):</span> +</span><span id="Generator.expressions-2292"><a href="#Generator.expressions-2292"><span class="linenos">2292</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator.expressions-2293"><a href="#Generator.expressions-2293"><span class="linenos">2293</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.expressions-2294"><a href="#Generator.expressions-2294"><span class="linenos">2294</span></a> +</span><span id="Generator.expressions-2295"><a href="#Generator.expressions-2295"><span class="linenos">2295</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="Generator.expressions-2296"><a href="#Generator.expressions-2296"><span class="linenos">2296</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span><span class="p">:</span> +</span><span id="Generator.expressions-2297"><a href="#Generator.expressions-2297"><span class="linenos">2297</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">pad</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.expressions-2298"><a href="#Generator.expressions-2298"><span class="linenos">2298</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.expressions-2299"><a href="#Generator.expressions-2299"><span class="linenos">2299</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="Generator.expressions-2300"><a href="#Generator.expressions-2300"><span class="linenos">2300</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">stripped_sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.expressions-2301"><a href="#Generator.expressions-2301"><span class="linenos">2301</span></a> <span class="p">)</span> +</span><span id="Generator.expressions-2302"><a href="#Generator.expressions-2302"><span class="linenos">2302</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.expressions-2303"><a href="#Generator.expressions-2303"><span class="linenos">2303</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.expressions-2304"><a href="#Generator.expressions-2304"><span class="linenos">2304</span></a> +</span><span id="Generator.expressions-2305"><a href="#Generator.expressions-2305"><span class="linenos">2305</span></a> <span class="n">result_sql</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> +</span><span id="Generator.expressions-2306"><a href="#Generator.expressions-2306"><span class="linenos">2306</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">result_sql</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="k">if</span> <span class="n">indent</span> <span class="k">else</span> <span class="n">result_sql</span> </span></pre></div> @@ -11143,12 +11311,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.op_expressions"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.op_expressions-2275"><a href="#Generator.op_expressions-2275"><span class="linenos">2275</span></a> <span class="k">def</span> <span class="nf">op_expressions</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.op_expressions-2276"><a href="#Generator.op_expressions-2276"><span class="linenos">2276</span></a> <span class="n">flat</span> <span class="o">=</span> <span class="n">flat</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> -</span><span id="Generator.op_expressions-2277"><a href="#Generator.op_expressions-2277"><span class="linenos">2277</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="n">flat</span><span class="p">)</span> -</span><span id="Generator.op_expressions-2278"><a href="#Generator.op_expressions-2278"><span class="linenos">2278</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> -</span><span id="Generator.op_expressions-2279"><a href="#Generator.op_expressions-2279"><span class="linenos">2279</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.op_expressions-2280"><a href="#Generator.op_expressions-2280"><span class="linenos">2280</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expressions_sql</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.op_expressions-2308"><a href="#Generator.op_expressions-2308"><span class="linenos">2308</span></a> <span class="k">def</span> <span class="nf">op_expressions</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.op_expressions-2309"><a href="#Generator.op_expressions-2309"><span class="linenos">2309</span></a> <span class="n">flat</span> <span class="o">=</span> <span class="n">flat</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> +</span><span id="Generator.op_expressions-2310"><a href="#Generator.op_expressions-2310"><span class="linenos">2310</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="n">flat</span><span class="p">)</span> +</span><span id="Generator.op_expressions-2311"><a href="#Generator.op_expressions-2311"><span class="linenos">2311</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> +</span><span id="Generator.op_expressions-2312"><a href="#Generator.op_expressions-2312"><span class="linenos">2312</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.op_expressions-2313"><a href="#Generator.op_expressions-2313"><span class="linenos">2313</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expressions_sql</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11166,11 +11334,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.naked_property"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.naked_property-2282"><a href="#Generator.naked_property-2282"><span class="linenos">2282</span></a> <span class="k">def</span> <span class="nf">naked_property</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.naked_property-2283"><a href="#Generator.naked_property-2283"><span class="linenos">2283</span></a> <span class="n">property_name</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">PROPERTY_TO_NAME</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span> -</span><span id="Generator.naked_property-2284"><a href="#Generator.naked_property-2284"><span class="linenos">2284</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">property_name</span><span class="p">:</span> -</span><span id="Generator.naked_property-2285"><a href="#Generator.naked_property-2285"><span class="linenos">2285</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.naked_property-2286"><a href="#Generator.naked_property-2286"><span class="linenos">2286</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">property_name</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.naked_property-2315"><a href="#Generator.naked_property-2315"><span class="linenos">2315</span></a> <span class="k">def</span> <span class="nf">naked_property</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Property</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.naked_property-2316"><a href="#Generator.naked_property-2316"><span class="linenos">2316</span></a> <span class="n">property_name</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">PROPERTY_TO_NAME</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span> +</span><span id="Generator.naked_property-2317"><a href="#Generator.naked_property-2317"><span class="linenos">2317</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">property_name</span><span class="p">:</span> +</span><span id="Generator.naked_property-2318"><a href="#Generator.naked_property-2318"><span class="linenos">2318</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.naked_property-2319"><a href="#Generator.naked_property-2319"><span class="linenos">2319</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">property_name</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11188,12 +11356,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.set_operation"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.set_operation-2288"><a href="#Generator.set_operation-2288"><span class="linenos">2288</span></a> <span class="k">def</span> <span class="nf">set_operation</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.set_operation-2289"><a href="#Generator.set_operation-2289"><span class="linenos">2289</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.set_operation-2290"><a href="#Generator.set_operation-2290"><span class="linenos">2290</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span> -</span><span id="Generator.set_operation-2291"><a href="#Generator.set_operation-2291"><span class="linenos">2291</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> -</span><span id="Generator.set_operation-2292"><a href="#Generator.set_operation-2292"><span class="linenos">2292</span></a> <span class="n">expression</span><span class="p">,</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">op</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.set_operation-2293"><a href="#Generator.set_operation-2293"><span class="linenos">2293</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.set_operation-2321"><a href="#Generator.set_operation-2321"><span class="linenos">2321</span></a> <span class="k">def</span> <span class="nf">set_operation</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.set_operation-2322"><a href="#Generator.set_operation-2322"><span class="linenos">2322</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.set_operation-2323"><a href="#Generator.set_operation-2323"><span class="linenos">2323</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span> +</span><span id="Generator.set_operation-2324"><a href="#Generator.set_operation-2324"><span class="linenos">2324</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> +</span><span id="Generator.set_operation-2325"><a href="#Generator.set_operation-2325"><span class="linenos">2325</span></a> <span class="n">expression</span><span class="p">,</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">op</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.set_operation-2326"><a href="#Generator.set_operation-2326"><span class="linenos">2326</span></a> <span class="p">)</span> </span></pre></div> @@ -11211,8 +11379,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.tag_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tag_sql-2295"><a href="#Generator.tag_sql-2295"><span class="linenos">2295</span></a> <span class="k">def</span> <span class="nf">tag_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Tag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.tag_sql-2296"><a href="#Generator.tag_sql-2296"><span class="linenos">2296</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'prefix'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}{</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'postfix'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tag_sql-2328"><a href="#Generator.tag_sql-2328"><span class="linenos">2328</span></a> <span class="k">def</span> <span class="nf">tag_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Tag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.tag_sql-2329"><a href="#Generator.tag_sql-2329"><span class="linenos">2329</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'prefix'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}{</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'postfix'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11230,8 +11398,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.token_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.token_sql-2298"><a href="#Generator.token_sql-2298"><span class="linenos">2298</span></a> <span class="k">def</span> <span class="nf">token_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.token_sql-2299"><a href="#Generator.token_sql-2299"><span class="linenos">2299</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">TOKEN_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">token_type</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.token_sql-2331"><a href="#Generator.token_sql-2331"><span class="linenos">2331</span></a> <span class="k">def</span> <span class="nf">token_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.token_sql-2332"><a href="#Generator.token_sql-2332"><span class="linenos">2332</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">TOKEN_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">token_type</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> </span></pre></div> @@ -11249,13 +11417,13 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.userdefinedfunction_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.userdefinedfunction_sql-2301"><a href="#Generator.userdefinedfunction_sql-2301"><span class="linenos">2301</span></a> <span class="k">def</span> <span class="nf">userdefinedfunction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UserDefinedFunction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.userdefinedfunction_sql-2302"><a href="#Generator.userdefinedfunction_sql-2302"><span class="linenos">2302</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.userdefinedfunction_sql-2303"><a href="#Generator.userdefinedfunction_sql-2303"><span class="linenos">2303</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.userdefinedfunction_sql-2304"><a href="#Generator.userdefinedfunction_sql-2304"><span class="linenos">2304</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.userdefinedfunction_sql-2305"><a href="#Generator.userdefinedfunction_sql-2305"><span class="linenos">2305</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"wrapped"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.userdefinedfunction_sql-2306"><a href="#Generator.userdefinedfunction_sql-2306"><span class="linenos">2306</span></a> <span class="p">)</span> -</span><span id="Generator.userdefinedfunction_sql-2307"><a href="#Generator.userdefinedfunction_sql-2307"><span class="linenos">2307</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.userdefinedfunction_sql-2334"><a href="#Generator.userdefinedfunction_sql-2334"><span class="linenos">2334</span></a> <span class="k">def</span> <span class="nf">userdefinedfunction_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">UserDefinedFunction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.userdefinedfunction_sql-2335"><a href="#Generator.userdefinedfunction_sql-2335"><span class="linenos">2335</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.userdefinedfunction_sql-2336"><a href="#Generator.userdefinedfunction_sql-2336"><span class="linenos">2336</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.userdefinedfunction_sql-2337"><a href="#Generator.userdefinedfunction_sql-2337"><span class="linenos">2337</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.userdefinedfunction_sql-2338"><a href="#Generator.userdefinedfunction_sql-2338"><span class="linenos">2338</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"wrapped"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.userdefinedfunction_sql-2339"><a href="#Generator.userdefinedfunction_sql-2339"><span class="linenos">2339</span></a> <span class="p">)</span> +</span><span id="Generator.userdefinedfunction_sql-2340"><a href="#Generator.userdefinedfunction_sql-2340"><span class="linenos">2340</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11273,10 +11441,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.joinhint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.joinhint_sql-2309"><a href="#Generator.joinhint_sql-2309"><span class="linenos">2309</span></a> <span class="k">def</span> <span class="nf">joinhint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JoinHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.joinhint_sql-2310"><a href="#Generator.joinhint_sql-2310"><span class="linenos">2310</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.joinhint_sql-2311"><a href="#Generator.joinhint_sql-2311"><span class="linenos">2311</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.joinhint_sql-2312"><a href="#Generator.joinhint_sql-2312"><span class="linenos">2312</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.joinhint_sql-2342"><a href="#Generator.joinhint_sql-2342"><span class="linenos">2342</span></a> <span class="k">def</span> <span class="nf">joinhint_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">JoinHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.joinhint_sql-2343"><a href="#Generator.joinhint_sql-2343"><span class="linenos">2343</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.joinhint_sql-2344"><a href="#Generator.joinhint_sql-2344"><span class="linenos">2344</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.joinhint_sql-2345"><a href="#Generator.joinhint_sql-2345"><span class="linenos">2345</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -11294,8 +11462,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.kwarg_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.kwarg_sql-2314"><a href="#Generator.kwarg_sql-2314"><span class="linenos">2314</span></a> <span class="k">def</span> <span class="nf">kwarg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Kwarg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.kwarg_sql-2315"><a href="#Generator.kwarg_sql-2315"><span class="linenos">2315</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"=>"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.kwarg_sql-2347"><a href="#Generator.kwarg_sql-2347"><span class="linenos">2347</span></a> <span class="k">def</span> <span class="nf">kwarg_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Kwarg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.kwarg_sql-2348"><a href="#Generator.kwarg_sql-2348"><span class="linenos">2348</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"=>"</span><span class="p">)</span> </span></pre></div> @@ -11313,25 +11481,25 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.when_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.when_sql-2317"><a href="#Generator.when_sql-2317"><span class="linenos">2317</span></a> <span class="k">def</span> <span class="nf">when_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">When</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.when_sql-2318"><a href="#Generator.when_sql-2318"><span class="linenos">2318</span></a> <span class="n">matched</span> <span class="o">=</span> <span class="s2">"MATCHED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"matched"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"NOT MATCHED"</span> -</span><span id="Generator.when_sql-2319"><a href="#Generator.when_sql-2319"><span class="linenos">2319</span></a> <span class="n">source</span> <span class="o">=</span> <span class="s2">" BY SOURCE"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">MATCHED_BY_SOURCE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"source"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.when_sql-2320"><a href="#Generator.when_sql-2320"><span class="linenos">2320</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">)</span> -</span><span id="Generator.when_sql-2321"><a href="#Generator.when_sql-2321"><span class="linenos">2321</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">condition</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.when_sql-2322"><a href="#Generator.when_sql-2322"><span class="linenos">2322</span></a> -</span><span id="Generator.when_sql-2323"><a href="#Generator.when_sql-2323"><span class="linenos">2323</span></a> <span class="n">then_expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"then"</span><span class="p">)</span> -</span><span id="Generator.when_sql-2324"><a href="#Generator.when_sql-2324"><span class="linenos">2324</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">):</span> -</span><span id="Generator.when_sql-2325"><a href="#Generator.when_sql-2325"><span class="linenos">2325</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.when_sql-2326"><a href="#Generator.when_sql-2326"><span class="linenos">2326</span></a> <span class="k">if</span> <span class="s2">"expression"</span> <span class="ow">in</span> <span class="n">then_expression</span><span class="o">.</span><span class="n">args</span><span class="p">:</span> -</span><span id="Generator.when_sql-2327"><a href="#Generator.when_sql-2327"><span class="linenos">2327</span></a> <span class="n">then</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" VALUES </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.when_sql-2328"><a href="#Generator.when_sql-2328"><span class="linenos">2328</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> -</span><span id="Generator.when_sql-2329"><a href="#Generator.when_sql-2329"><span class="linenos">2329</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">):</span> -</span><span id="Generator.when_sql-2330"><a href="#Generator.when_sql-2330"><span class="linenos">2330</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expressions'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.when_sql-2331"><a href="#Generator.when_sql-2331"><span class="linenos">2331</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.when_sql-2332"><a href="#Generator.when_sql-2332"><span class="linenos">2332</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.when_sql-2333"><a href="#Generator.when_sql-2333"><span class="linenos">2333</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.when_sql-2334"><a href="#Generator.when_sql-2334"><span class="linenos">2334</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">)</span> -</span><span id="Generator.when_sql-2335"><a href="#Generator.when_sql-2335"><span class="linenos">2335</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WHEN </span><span class="si">{</span><span class="n">matched</span><span class="si">}{</span><span class="n">source</span><span class="si">}{</span><span class="n">condition</span><span class="si">}</span><span class="s2"> THEN </span><span class="si">{</span><span class="n">then</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.when_sql-2350"><a href="#Generator.when_sql-2350"><span class="linenos">2350</span></a> <span class="k">def</span> <span class="nf">when_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">When</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.when_sql-2351"><a href="#Generator.when_sql-2351"><span class="linenos">2351</span></a> <span class="n">matched</span> <span class="o">=</span> <span class="s2">"MATCHED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"matched"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"NOT MATCHED"</span> +</span><span id="Generator.when_sql-2352"><a href="#Generator.when_sql-2352"><span class="linenos">2352</span></a> <span class="n">source</span> <span class="o">=</span> <span class="s2">" BY SOURCE"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">MATCHED_BY_SOURCE</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"source"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.when_sql-2353"><a href="#Generator.when_sql-2353"><span class="linenos">2353</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">)</span> +</span><span id="Generator.when_sql-2354"><a href="#Generator.when_sql-2354"><span class="linenos">2354</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">condition</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.when_sql-2355"><a href="#Generator.when_sql-2355"><span class="linenos">2355</span></a> +</span><span id="Generator.when_sql-2356"><a href="#Generator.when_sql-2356"><span class="linenos">2356</span></a> <span class="n">then_expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"then"</span><span class="p">)</span> +</span><span id="Generator.when_sql-2357"><a href="#Generator.when_sql-2357"><span class="linenos">2357</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">):</span> +</span><span id="Generator.when_sql-2358"><a href="#Generator.when_sql-2358"><span class="linenos">2358</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.when_sql-2359"><a href="#Generator.when_sql-2359"><span class="linenos">2359</span></a> <span class="k">if</span> <span class="s2">"expression"</span> <span class="ow">in</span> <span class="n">then_expression</span><span class="o">.</span><span class="n">args</span><span class="p">:</span> +</span><span id="Generator.when_sql-2360"><a href="#Generator.when_sql-2360"><span class="linenos">2360</span></a> <span class="n">then</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" VALUES </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.when_sql-2361"><a href="#Generator.when_sql-2361"><span class="linenos">2361</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> +</span><span id="Generator.when_sql-2362"><a href="#Generator.when_sql-2362"><span class="linenos">2362</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">):</span> +</span><span id="Generator.when_sql-2363"><a href="#Generator.when_sql-2363"><span class="linenos">2363</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expressions'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.when_sql-2364"><a href="#Generator.when_sql-2364"><span class="linenos">2364</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.when_sql-2365"><a href="#Generator.when_sql-2365"><span class="linenos">2365</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.when_sql-2366"><a href="#Generator.when_sql-2366"><span class="linenos">2366</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.when_sql-2367"><a href="#Generator.when_sql-2367"><span class="linenos">2367</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">)</span> +</span><span id="Generator.when_sql-2368"><a href="#Generator.when_sql-2368"><span class="linenos">2368</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WHEN </span><span class="si">{</span><span class="n">matched</span><span class="si">}{</span><span class="n">source</span><span class="si">}{</span><span class="n">condition</span><span class="si">}</span><span class="s2"> THEN </span><span class="si">{</span><span class="n">then</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11349,11 +11517,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.merge_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.merge_sql-2337"><a href="#Generator.merge_sql-2337"><span class="linenos">2337</span></a> <span class="k">def</span> <span class="nf">merge_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Merge</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.merge_sql-2338"><a href="#Generator.merge_sql-2338"><span class="linenos">2338</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.merge_sql-2339"><a href="#Generator.merge_sql-2339"><span class="linenos">2339</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'using'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.merge_sql-2340"><a href="#Generator.merge_sql-2340"><span class="linenos">2340</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'on'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.merge_sql-2341"><a href="#Generator.merge_sql-2341"><span class="linenos">2341</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGE INTO </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">' '</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.merge_sql-2370"><a href="#Generator.merge_sql-2370"><span class="linenos">2370</span></a> <span class="k">def</span> <span class="nf">merge_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Merge</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.merge_sql-2371"><a href="#Generator.merge_sql-2371"><span class="linenos">2371</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.merge_sql-2372"><a href="#Generator.merge_sql-2372"><span class="linenos">2372</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'using'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.merge_sql-2373"><a href="#Generator.merge_sql-2373"><span class="linenos">2373</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'on'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.merge_sql-2374"><a href="#Generator.merge_sql-2374"><span class="linenos">2374</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGE INTO </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">' '</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11371,11 +11539,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.tochar_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tochar_sql-2343"><a href="#Generator.tochar_sql-2343"><span class="linenos">2343</span></a> <span class="k">def</span> <span class="nf">tochar_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.tochar_sql-2344"><a href="#Generator.tochar_sql-2344"><span class="linenos">2344</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"format"</span><span class="p">):</span> -</span><span id="Generator.tochar_sql-2345"><a href="#Generator.tochar_sql-2345"><span class="linenos">2345</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Format argument unsupported for TO_CHAR/TO_VARCHAR function"</span><span class="p">)</span> -</span><span id="Generator.tochar_sql-2346"><a href="#Generator.tochar_sql-2346"><span class="linenos">2346</span></a> -</span><span id="Generator.tochar_sql-2347"><a href="#Generator.tochar_sql-2347"><span class="linenos">2347</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tochar_sql-2376"><a href="#Generator.tochar_sql-2376"><span class="linenos">2376</span></a> <span class="k">def</span> <span class="nf">tochar_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ToChar</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.tochar_sql-2377"><a href="#Generator.tochar_sql-2377"><span class="linenos">2377</span></a> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"format"</span><span class="p">):</span> +</span><span id="Generator.tochar_sql-2378"><a href="#Generator.tochar_sql-2378"><span class="linenos">2378</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Format argument unsupported for TO_CHAR/TO_VARCHAR function"</span><span class="p">)</span> +</span><span id="Generator.tochar_sql-2379"><a href="#Generator.tochar_sql-2379"><span class="linenos">2379</span></a> +</span><span id="Generator.tochar_sql-2380"><a href="#Generator.tochar_sql-2380"><span class="linenos">2380</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">))</span> </span></pre></div> @@ -11393,12 +11561,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.dictproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dictproperty_sql-2349"><a href="#Generator.dictproperty_sql-2349"><span class="linenos">2349</span></a> <span class="k">def</span> <span class="nf">dictproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.dictproperty_sql-2350"><a href="#Generator.dictproperty_sql-2350"><span class="linenos">2350</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.dictproperty_sql-2351"><a href="#Generator.dictproperty_sql-2351"><span class="linenos">2351</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator.dictproperty_sql-2352"><a href="#Generator.dictproperty_sql-2352"><span class="linenos">2352</span></a> <span class="n">settings_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"settings"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator.dictproperty_sql-2353"><a href="#Generator.dictproperty_sql-2353"><span class="linenos">2353</span></a> <span class="n">args</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">settings_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">settings_sql</span> <span class="k">else</span> <span class="s2">"()"</span> -</span><span id="Generator.dictproperty_sql-2354"><a href="#Generator.dictproperty_sql-2354"><span class="linenos">2354</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dictproperty_sql-2382"><a href="#Generator.dictproperty_sql-2382"><span class="linenos">2382</span></a> <span class="k">def</span> <span class="nf">dictproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.dictproperty_sql-2383"><a href="#Generator.dictproperty_sql-2383"><span class="linenos">2383</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.dictproperty_sql-2384"><a href="#Generator.dictproperty_sql-2384"><span class="linenos">2384</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator.dictproperty_sql-2385"><a href="#Generator.dictproperty_sql-2385"><span class="linenos">2385</span></a> <span class="n">settings_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"settings"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator.dictproperty_sql-2386"><a href="#Generator.dictproperty_sql-2386"><span class="linenos">2386</span></a> <span class="n">args</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">settings_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">settings_sql</span> <span class="k">else</span> <span class="s2">"()"</span> +</span><span id="Generator.dictproperty_sql-2387"><a href="#Generator.dictproperty_sql-2387"><span class="linenos">2387</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -11416,11 +11584,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.dictrange_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dictrange_sql-2356"><a href="#Generator.dictrange_sql-2356"><span class="linenos">2356</span></a> <span class="k">def</span> <span class="nf">dictrange_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DictRange</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.dictrange_sql-2357"><a href="#Generator.dictrange_sql-2357"><span class="linenos">2357</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.dictrange_sql-2358"><a href="#Generator.dictrange_sql-2358"><span class="linenos">2358</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"max"</span><span class="p">)</span> -</span><span id="Generator.dictrange_sql-2359"><a href="#Generator.dictrange_sql-2359"><span class="linenos">2359</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"min"</span><span class="p">)</span> -</span><span id="Generator.dictrange_sql-2360"><a href="#Generator.dictrange_sql-2360"><span class="linenos">2360</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(MIN </span><span class="si">{</span><span class="nb">min</span><span class="si">}</span><span class="s2"> MAX </span><span class="si">{</span><span class="nb">max</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dictrange_sql-2389"><a href="#Generator.dictrange_sql-2389"><span class="linenos">2389</span></a> <span class="k">def</span> <span class="nf">dictrange_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DictRange</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.dictrange_sql-2390"><a href="#Generator.dictrange_sql-2390"><span class="linenos">2390</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.dictrange_sql-2391"><a href="#Generator.dictrange_sql-2391"><span class="linenos">2391</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"max"</span><span class="p">)</span> +</span><span id="Generator.dictrange_sql-2392"><a href="#Generator.dictrange_sql-2392"><span class="linenos">2392</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"min"</span><span class="p">)</span> +</span><span id="Generator.dictrange_sql-2393"><a href="#Generator.dictrange_sql-2393"><span class="linenos">2393</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(MIN </span><span class="si">{</span><span class="nb">min</span><span class="si">}</span><span class="s2"> MAX </span><span class="si">{</span><span class="nb">max</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -11438,8 +11606,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.dictsubproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dictsubproperty_sql-2362"><a href="#Generator.dictsubproperty_sql-2362"><span class="linenos">2362</span></a> <span class="k">def</span> <span class="nf">dictsubproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DictSubProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.dictsubproperty_sql-2363"><a href="#Generator.dictsubproperty_sql-2363"><span class="linenos">2363</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dictsubproperty_sql-2395"><a href="#Generator.dictsubproperty_sql-2395"><span class="linenos">2395</span></a> <span class="k">def</span> <span class="nf">dictsubproperty_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">DictSubProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.dictsubproperty_sql-2396"><a href="#Generator.dictsubproperty_sql-2396"><span class="linenos">2396</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -11457,8 +11625,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.oncluster_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.oncluster_sql-2365"><a href="#Generator.oncluster_sql-2365"><span class="linenos">2365</span></a> <span class="k">def</span> <span class="nf">oncluster_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnCluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.oncluster_sql-2366"><a href="#Generator.oncluster_sql-2366"><span class="linenos">2366</span></a> <span class="k">return</span> <span class="s2">""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.oncluster_sql-2398"><a href="#Generator.oncluster_sql-2398"><span class="linenos">2398</span></a> <span class="k">def</span> <span class="nf">oncluster_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnCluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.oncluster_sql-2399"><a href="#Generator.oncluster_sql-2399"><span class="linenos">2399</span></a> <span class="k">return</span> <span class="s2">""</span> </span></pre></div> @@ -11477,13 +11645,13 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#cached_generator"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="cached_generator-2369"><a href="#cached_generator-2369"><span class="linenos">2369</span></a><span class="k">def</span> <span class="nf">cached_generator</span><span class="p">(</span> -</span><span id="cached_generator-2370"><a href="#cached_generator-2370"><span class="linenos">2370</span></a> <span class="n">cache</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="cached_generator-2371"><a href="#cached_generator-2371"><span class="linenos">2371</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> -</span><span id="cached_generator-2372"><a href="#cached_generator-2372"><span class="linenos">2372</span></a><span class="w"> </span><span class="sd">"""Returns a cached generator."""</span> -</span><span id="cached_generator-2373"><a href="#cached_generator-2373"><span class="linenos">2373</span></a> <span class="n">cache</span> <span class="o">=</span> <span class="p">{}</span> <span class="k">if</span> <span class="n">cache</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">cache</span> -</span><span id="cached_generator-2374"><a href="#cached_generator-2374"><span class="linenos">2374</span></a> <span class="n">generator</span> <span class="o">=</span> <span class="n">Generator</span><span class="p">(</span><span class="n">normalize</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">identify</span><span class="o">=</span><span class="s2">"safe"</span><span class="p">)</span> -</span><span id="cached_generator-2375"><a href="#cached_generator-2375"><span class="linenos">2375</span></a> <span class="k">return</span> <span class="k">lambda</span> <span class="n">e</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">cache</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="cached_generator-2402"><a href="#cached_generator-2402"><span class="linenos">2402</span></a><span class="k">def</span> <span class="nf">cached_generator</span><span class="p">(</span> +</span><span id="cached_generator-2403"><a href="#cached_generator-2403"><span class="linenos">2403</span></a> <span class="n">cache</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="cached_generator-2404"><a href="#cached_generator-2404"><span class="linenos">2404</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">],</span> <span class="nb">str</span><span class="p">]:</span> +</span><span id="cached_generator-2405"><a href="#cached_generator-2405"><span class="linenos">2405</span></a><span class="w"> </span><span class="sd">"""Returns a cached generator."""</span> +</span><span id="cached_generator-2406"><a href="#cached_generator-2406"><span class="linenos">2406</span></a> <span class="n">cache</span> <span class="o">=</span> <span class="p">{}</span> <span class="k">if</span> <span class="n">cache</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">cache</span> +</span><span id="cached_generator-2407"><a href="#cached_generator-2407"><span class="linenos">2407</span></a> <span class="n">generator</span> <span class="o">=</span> <span class="n">Generator</span><span class="p">(</span><span class="n">normalize</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">identify</span><span class="o">=</span><span class="s2">"safe"</span><span class="p">)</span> +</span><span id="cached_generator-2408"><a href="#cached_generator-2408"><span class="linenos">2408</span></a> <span class="k">return</span> <span class="k">lambda</span> <span class="n">e</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">cache</span><span class="p">)</span> </span></pre></div> diff --git a/docs/sqlglot/helper.html b/docs/sqlglot/helper.html index 8c1e736..27f83a0 100644 --- a/docs/sqlglot/helper.html +++ b/docs/sqlglot/helper.html @@ -93,12 +93,6 @@ <li> <a class="function" href="#first">first</a> </li> - <li> - <a class="function" href="#case_sensitive">case_sensitive</a> - </li> - <li> - <a class="function" href="#should_identify">should_identify</a> - </li> </ul> @@ -138,448 +132,421 @@ </span><span id="L-14"><a href="#L-14"><span class="linenos"> 14</span></a><span class="k">if</span> <span class="n">t</span><span class="o">.</span><span class="n">TYPE_CHECKING</span><span class="p">:</span> </span><span id="L-15"><a href="#L-15"><span class="linenos"> 15</span></a> <span class="kn">from</span> <span class="nn">sqlglot</span> <span class="kn">import</span> <span class="n">exp</span> </span><span id="L-16"><a href="#L-16"><span class="linenos"> 16</span></a> <span class="kn">from</span> <span class="nn">sqlglot._typing</span> <span class="kn">import</span> <span class="n">E</span><span class="p">,</span> <span class="n">T</span> -</span><span id="L-17"><a href="#L-17"><span class="linenos"> 17</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dialects.dialect</span> <span class="kn">import</span> <span class="n">DialectType</span> -</span><span id="L-18"><a href="#L-18"><span class="linenos"> 18</span></a> <span class="kn">from</span> <span class="nn">sqlglot.expressions</span> <span class="kn">import</span> <span class="n">Expression</span> -</span><span id="L-19"><a href="#L-19"><span class="linenos"> 19</span></a> -</span><span id="L-20"><a href="#L-20"><span class="linenos"> 20</span></a><span class="n">CAMEL_CASE_PATTERN</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s2">"(?<!^)(?=[A-Z])"</span><span class="p">)</span> -</span><span id="L-21"><a href="#L-21"><span class="linenos"> 21</span></a><span class="n">PYTHON_VERSION</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">version_info</span><span class="p">[:</span><span class="mi">2</span><span class="p">]</span> -</span><span id="L-22"><a href="#L-22"><span class="linenos"> 22</span></a><span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"sqlglot"</span><span class="p">)</span> +</span><span id="L-17"><a href="#L-17"><span class="linenos"> 17</span></a> <span class="kn">from</span> <span class="nn">sqlglot.expressions</span> <span class="kn">import</span> <span class="n">Expression</span> +</span><span id="L-18"><a href="#L-18"><span class="linenos"> 18</span></a> +</span><span id="L-19"><a href="#L-19"><span class="linenos"> 19</span></a><span class="n">CAMEL_CASE_PATTERN</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s2">"(?<!^)(?=[A-Z])"</span><span class="p">)</span> +</span><span id="L-20"><a href="#L-20"><span class="linenos"> 20</span></a><span class="n">PYTHON_VERSION</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">version_info</span><span class="p">[:</span><span class="mi">2</span><span class="p">]</span> +</span><span id="L-21"><a href="#L-21"><span class="linenos"> 21</span></a><span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"sqlglot"</span><span class="p">)</span> +</span><span id="L-22"><a href="#L-22"><span class="linenos"> 22</span></a> </span><span id="L-23"><a href="#L-23"><span class="linenos"> 23</span></a> -</span><span id="L-24"><a href="#L-24"><span class="linenos"> 24</span></a> -</span><span id="L-25"><a href="#L-25"><span class="linenos"> 25</span></a><span class="k">class</span> <span class="nc">AutoName</span><span class="p">(</span><span class="n">Enum</span><span class="p">):</span> -</span><span id="L-26"><a href="#L-26"><span class="linenos"> 26</span></a><span class="w"> </span><span class="sd">"""This is used for creating enum classes where `auto()` is the string form of the corresponding value's name."""</span> -</span><span id="L-27"><a href="#L-27"><span class="linenos"> 27</span></a> -</span><span id="L-28"><a href="#L-28"><span class="linenos"> 28</span></a> <span class="k">def</span> <span class="nf">_generate_next_value_</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">_start</span><span class="p">,</span> <span class="n">_count</span><span class="p">,</span> <span class="n">_last_values</span><span class="p">):</span> -</span><span id="L-29"><a href="#L-29"><span class="linenos"> 29</span></a> <span class="k">return</span> <span class="n">name</span> +</span><span id="L-24"><a href="#L-24"><span class="linenos"> 24</span></a><span class="k">class</span> <span class="nc">AutoName</span><span class="p">(</span><span class="n">Enum</span><span class="p">):</span> +</span><span id="L-25"><a href="#L-25"><span class="linenos"> 25</span></a><span class="w"> </span><span class="sd">"""This is used for creating enum classes where `auto()` is the string form of the corresponding value's name."""</span> +</span><span id="L-26"><a href="#L-26"><span class="linenos"> 26</span></a> +</span><span id="L-27"><a href="#L-27"><span class="linenos"> 27</span></a> <span class="k">def</span> <span class="nf">_generate_next_value_</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">_start</span><span class="p">,</span> <span class="n">_count</span><span class="p">,</span> <span class="n">_last_values</span><span class="p">):</span> +</span><span id="L-28"><a href="#L-28"><span class="linenos"> 28</span></a> <span class="k">return</span> <span class="n">name</span> +</span><span id="L-29"><a href="#L-29"><span class="linenos"> 29</span></a> </span><span id="L-30"><a href="#L-30"><span class="linenos"> 30</span></a> -</span><span id="L-31"><a href="#L-31"><span class="linenos"> 31</span></a> -</span><span id="L-32"><a href="#L-32"><span class="linenos"> 32</span></a><span class="k">def</span> <span class="nf">seq_get</span><span class="p">(</span><span class="n">seq</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="n">T</span><span class="p">],</span> <span class="n">index</span><span class="p">:</span> <span class="nb">int</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">T</span><span class="p">]:</span> -</span><span id="L-33"><a href="#L-33"><span class="linenos"> 33</span></a><span class="w"> </span><span class="sd">"""Returns the value in `seq` at position `index`, or `None` if `index` is out of bounds."""</span> -</span><span id="L-34"><a href="#L-34"><span class="linenos"> 34</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="L-35"><a href="#L-35"><span class="linenos"> 35</span></a> <span class="k">return</span> <span class="n">seq</span><span class="p">[</span><span class="n">index</span><span class="p">]</span> -</span><span id="L-36"><a href="#L-36"><span class="linenos"> 36</span></a> <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span> -</span><span id="L-37"><a href="#L-37"><span class="linenos"> 37</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-31"><a href="#L-31"><span class="linenos"> 31</span></a><span class="k">def</span> <span class="nf">seq_get</span><span class="p">(</span><span class="n">seq</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="n">T</span><span class="p">],</span> <span class="n">index</span><span class="p">:</span> <span class="nb">int</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">T</span><span class="p">]:</span> +</span><span id="L-32"><a href="#L-32"><span class="linenos"> 32</span></a><span class="w"> </span><span class="sd">"""Returns the value in `seq` at position `index`, or `None` if `index` is out of bounds."""</span> +</span><span id="L-33"><a href="#L-33"><span class="linenos"> 33</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="L-34"><a href="#L-34"><span class="linenos"> 34</span></a> <span class="k">return</span> <span class="n">seq</span><span class="p">[</span><span class="n">index</span><span class="p">]</span> +</span><span id="L-35"><a href="#L-35"><span class="linenos"> 35</span></a> <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span> +</span><span id="L-36"><a href="#L-36"><span class="linenos"> 36</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-37"><a href="#L-37"><span class="linenos"> 37</span></a> </span><span id="L-38"><a href="#L-38"><span class="linenos"> 38</span></a> -</span><span id="L-39"><a href="#L-39"><span class="linenos"> 39</span></a> -</span><span id="L-40"><a href="#L-40"><span class="linenos"> 40</span></a><span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="L-41"><a href="#L-41"><span class="linenos"> 41</span></a><span class="k">def</span> <span class="nf">ensure_list</span><span class="p">(</span><span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">T</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">T</span><span class="p">]:</span> -</span><span id="L-42"><a href="#L-42"><span class="linenos"> 42</span></a> <span class="o">...</span> +</span><span id="L-39"><a href="#L-39"><span class="linenos"> 39</span></a><span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> +</span><span id="L-40"><a href="#L-40"><span class="linenos"> 40</span></a><span class="k">def</span> <span class="nf">ensure_list</span><span class="p">(</span><span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">T</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">T</span><span class="p">]:</span> +</span><span id="L-41"><a href="#L-41"><span class="linenos"> 41</span></a> <span class="o">...</span> +</span><span id="L-42"><a href="#L-42"><span class="linenos"> 42</span></a> </span><span id="L-43"><a href="#L-43"><span class="linenos"> 43</span></a> -</span><span id="L-44"><a href="#L-44"><span class="linenos"> 44</span></a> -</span><span id="L-45"><a href="#L-45"><span class="linenos"> 45</span></a><span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="L-46"><a href="#L-46"><span class="linenos"> 46</span></a><span class="k">def</span> <span class="nf">ensure_list</span><span class="p">(</span><span class="n">value</span><span class="p">:</span> <span class="n">T</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">T</span><span class="p">]:</span> -</span><span id="L-47"><a href="#L-47"><span class="linenos"> 47</span></a> <span class="o">...</span> +</span><span id="L-44"><a href="#L-44"><span class="linenos"> 44</span></a><span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> +</span><span id="L-45"><a href="#L-45"><span class="linenos"> 45</span></a><span class="k">def</span> <span class="nf">ensure_list</span><span class="p">(</span><span class="n">value</span><span class="p">:</span> <span class="n">T</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">T</span><span class="p">]:</span> +</span><span id="L-46"><a href="#L-46"><span class="linenos"> 46</span></a> <span class="o">...</span> +</span><span id="L-47"><a href="#L-47"><span class="linenos"> 47</span></a> </span><span id="L-48"><a href="#L-48"><span class="linenos"> 48</span></a> -</span><span id="L-49"><a href="#L-49"><span class="linenos"> 49</span></a> -</span><span id="L-50"><a href="#L-50"><span class="linenos"> 50</span></a><span class="k">def</span> <span class="nf">ensure_list</span><span class="p">(</span><span class="n">value</span><span class="p">):</span> -</span><span id="L-51"><a href="#L-51"><span class="linenos"> 51</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-52"><a href="#L-52"><span class="linenos"> 52</span></a><span class="sd"> Ensures that a value is a list, otherwise casts or wraps it into one.</span> -</span><span id="L-53"><a href="#L-53"><span class="linenos"> 53</span></a> -</span><span id="L-54"><a href="#L-54"><span class="linenos"> 54</span></a><span class="sd"> Args:</span> -</span><span id="L-55"><a href="#L-55"><span class="linenos"> 55</span></a><span class="sd"> value: the value of interest.</span> -</span><span id="L-56"><a href="#L-56"><span class="linenos"> 56</span></a> -</span><span id="L-57"><a href="#L-57"><span class="linenos"> 57</span></a><span class="sd"> Returns:</span> -</span><span id="L-58"><a href="#L-58"><span class="linenos"> 58</span></a><span class="sd"> The value cast as a list if it's a list or a tuple, or else the value wrapped in a list.</span> -</span><span id="L-59"><a href="#L-59"><span class="linenos"> 59</span></a><span class="sd"> """</span> -</span><span id="L-60"><a href="#L-60"><span class="linenos"> 60</span></a> <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-61"><a href="#L-61"><span class="linenos"> 61</span></a> <span class="k">return</span> <span class="p">[]</span> -</span><span id="L-62"><a href="#L-62"><span class="linenos"> 62</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">)):</span> -</span><span id="L-63"><a href="#L-63"><span class="linenos"> 63</span></a> <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="L-64"><a href="#L-64"><span class="linenos"> 64</span></a> -</span><span id="L-65"><a href="#L-65"><span class="linenos"> 65</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span> +</span><span id="L-49"><a href="#L-49"><span class="linenos"> 49</span></a><span class="k">def</span> <span class="nf">ensure_list</span><span class="p">(</span><span class="n">value</span><span class="p">):</span> +</span><span id="L-50"><a href="#L-50"><span class="linenos"> 50</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-51"><a href="#L-51"><span class="linenos"> 51</span></a><span class="sd"> Ensures that a value is a list, otherwise casts or wraps it into one.</span> +</span><span id="L-52"><a href="#L-52"><span class="linenos"> 52</span></a> +</span><span id="L-53"><a href="#L-53"><span class="linenos"> 53</span></a><span class="sd"> Args:</span> +</span><span id="L-54"><a href="#L-54"><span class="linenos"> 54</span></a><span class="sd"> value: the value of interest.</span> +</span><span id="L-55"><a href="#L-55"><span class="linenos"> 55</span></a> +</span><span id="L-56"><a href="#L-56"><span class="linenos"> 56</span></a><span class="sd"> Returns:</span> +</span><span id="L-57"><a href="#L-57"><span class="linenos"> 57</span></a><span class="sd"> The value cast as a list if it's a list or a tuple, or else the value wrapped in a list.</span> +</span><span id="L-58"><a href="#L-58"><span class="linenos"> 58</span></a><span class="sd"> """</span> +</span><span id="L-59"><a href="#L-59"><span class="linenos"> 59</span></a> <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-60"><a href="#L-60"><span class="linenos"> 60</span></a> <span class="k">return</span> <span class="p">[]</span> +</span><span id="L-61"><a href="#L-61"><span class="linenos"> 61</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">)):</span> +</span><span id="L-62"><a href="#L-62"><span class="linenos"> 62</span></a> <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="L-63"><a href="#L-63"><span class="linenos"> 63</span></a> +</span><span id="L-64"><a href="#L-64"><span class="linenos"> 64</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span> +</span><span id="L-65"><a href="#L-65"><span class="linenos"> 65</span></a> </span><span id="L-66"><a href="#L-66"><span class="linenos"> 66</span></a> -</span><span id="L-67"><a href="#L-67"><span class="linenos"> 67</span></a> -</span><span id="L-68"><a href="#L-68"><span class="linenos"> 68</span></a><span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="L-69"><a href="#L-69"><span class="linenos"> 69</span></a><span class="k">def</span> <span class="nf">ensure_collection</span><span class="p">(</span><span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">T</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">T</span><span class="p">]:</span> -</span><span id="L-70"><a href="#L-70"><span class="linenos"> 70</span></a> <span class="o">...</span> +</span><span id="L-67"><a href="#L-67"><span class="linenos"> 67</span></a><span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> +</span><span id="L-68"><a href="#L-68"><span class="linenos"> 68</span></a><span class="k">def</span> <span class="nf">ensure_collection</span><span class="p">(</span><span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">T</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">T</span><span class="p">]:</span> +</span><span id="L-69"><a href="#L-69"><span class="linenos"> 69</span></a> <span class="o">...</span> +</span><span id="L-70"><a href="#L-70"><span class="linenos"> 70</span></a> </span><span id="L-71"><a href="#L-71"><span class="linenos"> 71</span></a> -</span><span id="L-72"><a href="#L-72"><span class="linenos"> 72</span></a> -</span><span id="L-73"><a href="#L-73"><span class="linenos"> 73</span></a><span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="L-74"><a href="#L-74"><span class="linenos"> 74</span></a><span class="k">def</span> <span class="nf">ensure_collection</span><span class="p">(</span><span class="n">value</span><span class="p">:</span> <span class="n">T</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">T</span><span class="p">]:</span> -</span><span id="L-75"><a href="#L-75"><span class="linenos"> 75</span></a> <span class="o">...</span> +</span><span id="L-72"><a href="#L-72"><span class="linenos"> 72</span></a><span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> +</span><span id="L-73"><a href="#L-73"><span class="linenos"> 73</span></a><span class="k">def</span> <span class="nf">ensure_collection</span><span class="p">(</span><span class="n">value</span><span class="p">:</span> <span class="n">T</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">T</span><span class="p">]:</span> +</span><span id="L-74"><a href="#L-74"><span class="linenos"> 74</span></a> <span class="o">...</span> +</span><span id="L-75"><a href="#L-75"><span class="linenos"> 75</span></a> </span><span id="L-76"><a href="#L-76"><span class="linenos"> 76</span></a> -</span><span id="L-77"><a href="#L-77"><span class="linenos"> 77</span></a> -</span><span id="L-78"><a href="#L-78"><span class="linenos"> 78</span></a><span class="k">def</span> <span class="nf">ensure_collection</span><span class="p">(</span><span class="n">value</span><span class="p">):</span> -</span><span id="L-79"><a href="#L-79"><span class="linenos"> 79</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-80"><a href="#L-80"><span class="linenos"> 80</span></a><span class="sd"> Ensures that a value is a collection (excluding `str` and `bytes`), otherwise wraps it into a list.</span> -</span><span id="L-81"><a href="#L-81"><span class="linenos"> 81</span></a> -</span><span id="L-82"><a href="#L-82"><span class="linenos"> 82</span></a><span class="sd"> Args:</span> -</span><span id="L-83"><a href="#L-83"><span class="linenos"> 83</span></a><span class="sd"> value: the value of interest.</span> -</span><span id="L-84"><a href="#L-84"><span class="linenos"> 84</span></a> -</span><span id="L-85"><a href="#L-85"><span class="linenos"> 85</span></a><span class="sd"> Returns:</span> -</span><span id="L-86"><a href="#L-86"><span class="linenos"> 86</span></a><span class="sd"> The value if it's a collection, or else the value wrapped in a list.</span> -</span><span id="L-87"><a href="#L-87"><span class="linenos"> 87</span></a><span class="sd"> """</span> -</span><span id="L-88"><a href="#L-88"><span class="linenos"> 88</span></a> <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-89"><a href="#L-89"><span class="linenos"> 89</span></a> <span class="k">return</span> <span class="p">[]</span> -</span><span id="L-90"><a href="#L-90"><span class="linenos"> 90</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="L-91"><a href="#L-91"><span class="linenos"> 91</span></a> <span class="n">value</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Collection</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="nb">bytes</span><span class="p">))</span> <span class="k">else</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span> -</span><span id="L-92"><a href="#L-92"><span class="linenos"> 92</span></a> <span class="p">)</span> +</span><span id="L-77"><a href="#L-77"><span class="linenos"> 77</span></a><span class="k">def</span> <span class="nf">ensure_collection</span><span class="p">(</span><span class="n">value</span><span class="p">):</span> +</span><span id="L-78"><a href="#L-78"><span class="linenos"> 78</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-79"><a href="#L-79"><span class="linenos"> 79</span></a><span class="sd"> Ensures that a value is a collection (excluding `str` and `bytes`), otherwise wraps it into a list.</span> +</span><span id="L-80"><a href="#L-80"><span class="linenos"> 80</span></a> +</span><span id="L-81"><a href="#L-81"><span class="linenos"> 81</span></a><span class="sd"> Args:</span> +</span><span id="L-82"><a href="#L-82"><span class="linenos"> 82</span></a><span class="sd"> value: the value of interest.</span> +</span><span id="L-83"><a href="#L-83"><span class="linenos"> 83</span></a> +</span><span id="L-84"><a href="#L-84"><span class="linenos"> 84</span></a><span class="sd"> Returns:</span> +</span><span id="L-85"><a href="#L-85"><span class="linenos"> 85</span></a><span class="sd"> The value if it's a collection, or else the value wrapped in a list.</span> +</span><span id="L-86"><a href="#L-86"><span class="linenos"> 86</span></a><span class="sd"> """</span> +</span><span id="L-87"><a href="#L-87"><span class="linenos"> 87</span></a> <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-88"><a href="#L-88"><span class="linenos"> 88</span></a> <span class="k">return</span> <span class="p">[]</span> +</span><span id="L-89"><a href="#L-89"><span class="linenos"> 89</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="L-90"><a href="#L-90"><span class="linenos"> 90</span></a> <span class="n">value</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Collection</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="nb">bytes</span><span class="p">))</span> <span class="k">else</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span> +</span><span id="L-91"><a href="#L-91"><span class="linenos"> 91</span></a> <span class="p">)</span> +</span><span id="L-92"><a href="#L-92"><span class="linenos"> 92</span></a> </span><span id="L-93"><a href="#L-93"><span class="linenos"> 93</span></a> -</span><span id="L-94"><a href="#L-94"><span class="linenos"> 94</span></a> -</span><span id="L-95"><a href="#L-95"><span class="linenos"> 95</span></a><span class="k">def</span> <span class="nf">csv</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-97"><a href="#L-97"><span class="linenos"> 97</span></a><span class="sd"> Formats any number of string arguments as CSV.</span> -</span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a> -</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a><span class="sd"> Args:</span> -</span><span id="L-100"><a href="#L-100"><span class="linenos">100</span></a><span class="sd"> args: the string arguments to format.</span> -</span><span id="L-101"><a href="#L-101"><span class="linenos">101</span></a><span class="sd"> sep: the argument separator.</span> -</span><span id="L-102"><a href="#L-102"><span class="linenos">102</span></a> -</span><span id="L-103"><a href="#L-103"><span class="linenos">103</span></a><span class="sd"> Returns:</span> -</span><span id="L-104"><a href="#L-104"><span class="linenos">104</span></a><span class="sd"> The arguments formatted as a CSV string.</span> -</span><span id="L-105"><a href="#L-105"><span class="linenos">105</span></a><span class="sd"> """</span> -</span><span id="L-106"><a href="#L-106"><span class="linenos">106</span></a> <span class="k">return</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span> <span class="k">if</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="L-94"><a href="#L-94"><span class="linenos"> 94</span></a><span class="k">def</span> <span class="nf">csv</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-95"><a href="#L-95"><span class="linenos"> 95</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a><span class="sd"> Formats any number of string arguments as CSV.</span> +</span><span id="L-97"><a href="#L-97"><span class="linenos"> 97</span></a> +</span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a><span class="sd"> Args:</span> +</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a><span class="sd"> args: the string arguments to format.</span> +</span><span id="L-100"><a href="#L-100"><span class="linenos">100</span></a><span class="sd"> sep: the argument separator.</span> +</span><span id="L-101"><a href="#L-101"><span class="linenos">101</span></a> +</span><span id="L-102"><a href="#L-102"><span class="linenos">102</span></a><span class="sd"> Returns:</span> +</span><span id="L-103"><a href="#L-103"><span class="linenos">103</span></a><span class="sd"> The arguments formatted as a CSV string.</span> +</span><span id="L-104"><a href="#L-104"><span class="linenos">104</span></a><span class="sd"> """</span> +</span><span id="L-105"><a href="#L-105"><span class="linenos">105</span></a> <span class="k">return</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span> <span class="k">if</span> <span class="n">arg</span><span class="p">)</span> +</span><span id="L-106"><a href="#L-106"><span class="linenos">106</span></a> </span><span id="L-107"><a href="#L-107"><span class="linenos">107</span></a> -</span><span id="L-108"><a href="#L-108"><span class="linenos">108</span></a> -</span><span id="L-109"><a href="#L-109"><span class="linenos">109</span></a><span class="k">def</span> <span class="nf">subclasses</span><span class="p">(</span> -</span><span id="L-110"><a href="#L-110"><span class="linenos">110</span></a> <span class="n">module_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="L-111"><a href="#L-111"><span class="linenos">111</span></a> <span class="n">classes</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> -</span><span id="L-112"><a href="#L-112"><span class="linenos">112</span></a> <span class="n">exclude</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="o">...</span><span class="p">]</span> <span class="o">=</span> <span class="p">(),</span> -</span><span id="L-113"><a href="#L-113"><span class="linenos">113</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">]:</span> -</span><span id="L-114"><a href="#L-114"><span class="linenos">114</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-115"><a href="#L-115"><span class="linenos">115</span></a><span class="sd"> Returns all subclasses for a collection of classes, possibly excluding some of them.</span> -</span><span id="L-116"><a href="#L-116"><span class="linenos">116</span></a> -</span><span id="L-117"><a href="#L-117"><span class="linenos">117</span></a><span class="sd"> Args:</span> -</span><span id="L-118"><a href="#L-118"><span class="linenos">118</span></a><span class="sd"> module_name: the name of the module to search for subclasses in.</span> -</span><span id="L-119"><a href="#L-119"><span class="linenos">119</span></a><span class="sd"> classes: class(es) we want to find the subclasses of.</span> -</span><span id="L-120"><a href="#L-120"><span class="linenos">120</span></a><span class="sd"> exclude: class(es) we want to exclude from the returned list.</span> -</span><span id="L-121"><a href="#L-121"><span class="linenos">121</span></a> -</span><span id="L-122"><a href="#L-122"><span class="linenos">122</span></a><span class="sd"> Returns:</span> -</span><span id="L-123"><a href="#L-123"><span class="linenos">123</span></a><span class="sd"> The target subclasses.</span> -</span><span id="L-124"><a href="#L-124"><span class="linenos">124</span></a><span class="sd"> """</span> -</span><span id="L-125"><a href="#L-125"><span class="linenos">125</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="L-126"><a href="#L-126"><span class="linenos">126</span></a> <span class="n">obj</span> -</span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a> <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">obj</span> <span class="ow">in</span> <span class="n">inspect</span><span class="o">.</span><span class="n">getmembers</span><span class="p">(</span> -</span><span id="L-128"><a href="#L-128"><span class="linenos">128</span></a> <span class="n">sys</span><span class="o">.</span><span class="n">modules</span><span class="p">[</span><span class="n">module_name</span><span class="p">],</span> -</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a> <span class="k">lambda</span> <span class="n">obj</span><span class="p">:</span> <span class="n">inspect</span><span class="o">.</span><span class="n">isclass</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">issubclass</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="n">classes</span><span class="p">)</span> <span class="ow">and</span> <span class="n">obj</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">exclude</span><span class="p">,</span> -</span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a> <span class="p">)</span> -</span><span id="L-131"><a href="#L-131"><span class="linenos">131</span></a> <span class="p">]</span> +</span><span id="L-108"><a href="#L-108"><span class="linenos">108</span></a><span class="k">def</span> <span class="nf">subclasses</span><span class="p">(</span> +</span><span id="L-109"><a href="#L-109"><span class="linenos">109</span></a> <span class="n">module_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="L-110"><a href="#L-110"><span class="linenos">110</span></a> <span class="n">classes</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> +</span><span id="L-111"><a href="#L-111"><span class="linenos">111</span></a> <span class="n">exclude</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="o">...</span><span class="p">]</span> <span class="o">=</span> <span class="p">(),</span> +</span><span id="L-112"><a href="#L-112"><span class="linenos">112</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">]:</span> +</span><span id="L-113"><a href="#L-113"><span class="linenos">113</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-114"><a href="#L-114"><span class="linenos">114</span></a><span class="sd"> Returns all subclasses for a collection of classes, possibly excluding some of them.</span> +</span><span id="L-115"><a href="#L-115"><span class="linenos">115</span></a> +</span><span id="L-116"><a href="#L-116"><span class="linenos">116</span></a><span class="sd"> Args:</span> +</span><span id="L-117"><a href="#L-117"><span class="linenos">117</span></a><span class="sd"> module_name: the name of the module to search for subclasses in.</span> +</span><span id="L-118"><a href="#L-118"><span class="linenos">118</span></a><span class="sd"> classes: class(es) we want to find the subclasses of.</span> +</span><span id="L-119"><a href="#L-119"><span class="linenos">119</span></a><span class="sd"> exclude: class(es) we want to exclude from the returned list.</span> +</span><span id="L-120"><a href="#L-120"><span class="linenos">120</span></a> +</span><span id="L-121"><a href="#L-121"><span class="linenos">121</span></a><span class="sd"> Returns:</span> +</span><span id="L-122"><a href="#L-122"><span class="linenos">122</span></a><span class="sd"> The target subclasses.</span> +</span><span id="L-123"><a href="#L-123"><span class="linenos">123</span></a><span class="sd"> """</span> +</span><span id="L-124"><a href="#L-124"><span class="linenos">124</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="L-125"><a href="#L-125"><span class="linenos">125</span></a> <span class="n">obj</span> +</span><span id="L-126"><a href="#L-126"><span class="linenos">126</span></a> <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">obj</span> <span class="ow">in</span> <span class="n">inspect</span><span class="o">.</span><span class="n">getmembers</span><span class="p">(</span> +</span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a> <span class="n">sys</span><span class="o">.</span><span class="n">modules</span><span class="p">[</span><span class="n">module_name</span><span class="p">],</span> +</span><span id="L-128"><a href="#L-128"><span class="linenos">128</span></a> <span class="k">lambda</span> <span class="n">obj</span><span class="p">:</span> <span class="n">inspect</span><span class="o">.</span><span class="n">isclass</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">issubclass</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="n">classes</span><span class="p">)</span> <span class="ow">and</span> <span class="n">obj</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">exclude</span><span class="p">,</span> +</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a> <span class="p">)</span> +</span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a> <span class="p">]</span> +</span><span id="L-131"><a href="#L-131"><span class="linenos">131</span></a> </span><span id="L-132"><a href="#L-132"><span class="linenos">132</span></a> -</span><span id="L-133"><a href="#L-133"><span class="linenos">133</span></a> -</span><span id="L-134"><a href="#L-134"><span class="linenos">134</span></a><span class="k">def</span> <span class="nf">apply_index_offset</span><span class="p">(</span> -</span><span id="L-135"><a href="#L-135"><span class="linenos">135</span></a> <span class="n">this</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-136"><a href="#L-136"><span class="linenos">136</span></a> <span class="n">expressions</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">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">E</span><span class="p">]],</span> -</span><span id="L-137"><a href="#L-137"><span class="linenos">137</span></a> <span class="n">offset</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> -</span><span id="L-138"><a href="#L-138"><span class="linenos">138</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">E</span><span class="p">]]:</span> -</span><span id="L-139"><a href="#L-139"><span class="linenos">139</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-140"><a href="#L-140"><span class="linenos">140</span></a><span class="sd"> Applies an offset to a given integer literal expression.</span> -</span><span id="L-141"><a href="#L-141"><span class="linenos">141</span></a> -</span><span id="L-142"><a href="#L-142"><span class="linenos">142</span></a><span class="sd"> Args:</span> -</span><span id="L-143"><a href="#L-143"><span class="linenos">143</span></a><span class="sd"> this: the target of the index</span> -</span><span id="L-144"><a href="#L-144"><span class="linenos">144</span></a><span class="sd"> expressions: the expression the offset will be applied to, wrapped in a list.</span> -</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a><span class="sd"> offset: the offset that will be applied.</span> -</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> -</span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a><span class="sd"> Returns:</span> -</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a><span class="sd"> The original expression with the offset applied to it, wrapped in a list. If the provided</span> -</span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a><span class="sd"> `expressions` argument contains more than one expressions, it's returned unaffected.</span> -</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a><span class="sd"> """</span> -</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">offset</span> <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="k">return</span> <span class="n">expressions</span> -</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> -</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> -</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> <span class="kn">from</span> <span class="nn">sqlglot</span> <span class="kn">import</span> <span class="n">exp</span> -</span><span id="L-157"><a href="#L-157"><span class="linenos">157</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-158"><a href="#L-158"><span class="linenos">158</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.simplify</span> <span class="kn">import</span> <span class="n">simplify</span> -</span><span id="L-159"><a href="#L-159"><span class="linenos">159</span></a> -</span><span id="L-160"><a href="#L-160"><span class="linenos">160</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-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="n">annotate_types</span><span class="p">(</span><span class="n">this</span><span class="p">)</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="k">if</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</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="n">this</span><span class="o">.</span><span class="n">type</span><span class="p">)</span><span class="o">.</span><span class="n">this</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="L-164"><a href="#L-164"><span class="linenos">164</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">UNKNOWN</span><span class="p">,</span> -</span><span id="L-165"><a href="#L-165"><span class="linenos">165</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">ARRAY</span><span class="p">,</span> -</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a> <span class="p">):</span> -</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a> <span class="k">return</span> <span class="n">expressions</span> -</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a> -</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a> <span class="k">if</span> <span class="n">expression</span><span class="p">:</span> -</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> -</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="n">annotate_types</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="k">if</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</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="n">expression</span><span class="o">.</span><span class="n">type</span><span class="p">)</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">INTEGER_TYPES</span><span class="p">:</span> -</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="s2">"Applying array index offset (</span><span class="si">%s</span><span class="s2">)"</span><span class="p">,</span> <span class="n">offset</span><span class="p">)</span> -</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">simplify</span><span class="p">(</span> -</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Add</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">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="n">offset</span><span class="p">))</span> -</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> <span class="p">)</span> -</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">expression</span><span class="p">]</span> -</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> -</span><span id="L-179"><a href="#L-179"><span class="linenos">179</span></a> <span class="k">return</span> <span class="n">expressions</span> +</span><span id="L-133"><a href="#L-133"><span class="linenos">133</span></a><span class="k">def</span> <span class="nf">apply_index_offset</span><span class="p">(</span> +</span><span id="L-134"><a href="#L-134"><span class="linenos">134</span></a> <span class="n">this</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-135"><a href="#L-135"><span class="linenos">135</span></a> <span class="n">expressions</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">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">E</span><span class="p">]],</span> +</span><span id="L-136"><a href="#L-136"><span class="linenos">136</span></a> <span class="n">offset</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> +</span><span id="L-137"><a href="#L-137"><span class="linenos">137</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">E</span><span class="p">]]:</span> +</span><span id="L-138"><a href="#L-138"><span class="linenos">138</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-139"><a href="#L-139"><span class="linenos">139</span></a><span class="sd"> Applies an offset to a given integer literal expression.</span> +</span><span id="L-140"><a href="#L-140"><span class="linenos">140</span></a> +</span><span id="L-141"><a href="#L-141"><span class="linenos">141</span></a><span class="sd"> Args:</span> +</span><span id="L-142"><a href="#L-142"><span class="linenos">142</span></a><span class="sd"> this: the target of the index</span> +</span><span id="L-143"><a href="#L-143"><span class="linenos">143</span></a><span class="sd"> expressions: the expression the offset will be applied to, wrapped in a list.</span> +</span><span id="L-144"><a href="#L-144"><span class="linenos">144</span></a><span class="sd"> offset: the offset that will be applied.</span> +</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> +</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a><span class="sd"> Returns:</span> +</span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a><span class="sd"> The original expression with the offset applied to it, wrapped in a list. If the provided</span> +</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a><span class="sd"> `expressions` argument contains more than one expressions, it's returned unaffected.</span> +</span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a><span class="sd"> """</span> +</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">offset</span> <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> <span class="k">return</span> <span class="n">expressions</span> +</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> +</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> +</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> <span class="kn">from</span> <span class="nn">sqlglot</span> <span class="kn">import</span> <span class="n">exp</span> +</span><span id="L-156"><a href="#L-156"><span class="linenos">156</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-157"><a href="#L-157"><span class="linenos">157</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.simplify</span> <span class="kn">import</span> <span class="n">simplify</span> +</span><span id="L-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">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-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="n">annotate_types</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> +</span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a> <span class="k">if</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</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="n">this</span><span class="o">.</span><span class="n">type</span><span class="p">)</span><span class="o">.</span><span class="n">this</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="L-163"><a href="#L-163"><span class="linenos">163</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">UNKNOWN</span><span class="p">,</span> +</span><span id="L-164"><a href="#L-164"><span class="linenos">164</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">ARRAY</span><span class="p">,</span> +</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> <span class="p">):</span> +</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a> <span class="k">return</span> <span class="n">expressions</span> +</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a> +</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a> <span class="k">if</span> <span class="n">expression</span><span class="p">:</span> +</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> +</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="n">annotate_types</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="k">if</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</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="n">expression</span><span class="o">.</span><span class="n">type</span><span class="p">)</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">INTEGER_TYPES</span><span class="p">:</span> +</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="s2">"Applying array index offset (</span><span class="si">%s</span><span class="s2">)"</span><span class="p">,</span> <span class="n">offset</span><span class="p">)</span> +</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">simplify</span><span class="p">(</span> +</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Add</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">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="n">offset</span><span class="p">))</span> +</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="p">)</span> +</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">expression</span><span class="p">]</span> +</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> +</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> <span class="k">return</span> <span class="n">expressions</span> +</span><span id="L-179"><a href="#L-179"><span class="linenos">179</span></a> </span><span id="L-180"><a href="#L-180"><span class="linenos">180</span></a> -</span><span id="L-181"><a href="#L-181"><span class="linenos">181</span></a> -</span><span id="L-182"><a href="#L-182"><span class="linenos">182</span></a><span class="k">def</span> <span class="nf">camel_to_snake_case</span><span class="p">(</span><span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-183"><a href="#L-183"><span class="linenos">183</span></a><span class="w"> </span><span class="sd">"""Converts `name` from camelCase to snake_case and returns the result."""</span> -</span><span id="L-184"><a href="#L-184"><span class="linenos">184</span></a> <span class="k">return</span> <span class="n">CAMEL_CASE_PATTERN</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="s2">"_"</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-181"><a href="#L-181"><span class="linenos">181</span></a><span class="k">def</span> <span class="nf">camel_to_snake_case</span><span class="p">(</span><span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-182"><a href="#L-182"><span class="linenos">182</span></a><span class="w"> </span><span class="sd">"""Converts `name` from camelCase to snake_case and returns the result."""</span> +</span><span id="L-183"><a href="#L-183"><span class="linenos">183</span></a> <span class="k">return</span> <span class="n">CAMEL_CASE_PATTERN</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="s2">"_"</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-184"><a href="#L-184"><span class="linenos">184</span></a> </span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> -</span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a> -</span><span id="L-187"><a href="#L-187"><span class="linenos">187</span></a><span class="k">def</span> <span class="nf">while_changing</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="n">func</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Expression</span><span class="p">],</span> <span class="n">E</span><span class="p">])</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="L-188"><a href="#L-188"><span class="linenos">188</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-189"><a href="#L-189"><span class="linenos">189</span></a><span class="sd"> Applies a transformation to a given expression until a fix point is reached.</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 class="sd"> Args:</span> -</span><span id="L-192"><a href="#L-192"><span class="linenos">192</span></a><span class="sd"> expression: the expression to be transformed.</span> -</span><span id="L-193"><a href="#L-193"><span class="linenos">193</span></a><span class="sd"> func: the transformation to be applied.</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 class="sd"> Returns:</span> -</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a><span class="sd"> The transformed expression.</span> -</span><span id="L-197"><a href="#L-197"><span class="linenos">197</span></a><span class="sd"> """</span> -</span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-199"><a href="#L-199"><span class="linenos">199</span></a> <span class="k">for</span> <span class="n">n</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span> <span class="ow">in</span> <span class="nb">reversed</span><span class="p">(</span><span class="nb">tuple</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">walk</span><span class="p">())):</span> -</span><span id="L-200"><a href="#L-200"><span class="linenos">200</span></a> <span class="n">n</span><span class="o">.</span><span class="n">_hash</span> <span class="o">=</span> <span class="nb">hash</span><span class="p">(</span><span class="n">n</span><span class="p">)</span> -</span><span id="L-201"><a href="#L-201"><span class="linenos">201</span></a> <span class="n">start</span> <span class="o">=</span> <span class="nb">hash</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-202"><a href="#L-202"><span class="linenos">202</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="p">)</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="k">for</span> <span class="n">n</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">walk</span><span class="p">():</span> -</span><span id="L-205"><a href="#L-205"><span class="linenos">205</span></a> <span class="n">n</span><span class="o">.</span><span class="n">_hash</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-206"><a href="#L-206"><span class="linenos">206</span></a> <span class="k">if</span> <span class="n">start</span> <span class="o">==</span> <span class="nb">hash</span><span class="p">(</span><span class="n">expression</span><span class="p">):</span> -</span><span id="L-207"><a href="#L-207"><span class="linenos">207</span></a> <span class="k">break</span> -</span><span id="L-208"><a href="#L-208"><span class="linenos">208</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a><span class="k">def</span> <span class="nf">while_changing</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="n">func</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Expression</span><span class="p">],</span> <span class="n">E</span><span class="p">])</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="L-187"><a href="#L-187"><span class="linenos">187</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-188"><a href="#L-188"><span class="linenos">188</span></a><span class="sd"> Applies a transformation to a given expression until a fix point is reached.</span> +</span><span id="L-189"><a href="#L-189"><span class="linenos">189</span></a> +</span><span id="L-190"><a href="#L-190"><span class="linenos">190</span></a><span class="sd"> Args:</span> +</span><span id="L-191"><a href="#L-191"><span class="linenos">191</span></a><span class="sd"> expression: the expression to be transformed.</span> +</span><span id="L-192"><a href="#L-192"><span class="linenos">192</span></a><span class="sd"> func: the transformation to be applied.</span> +</span><span id="L-193"><a href="#L-193"><span class="linenos">193</span></a> +</span><span id="L-194"><a href="#L-194"><span class="linenos">194</span></a><span class="sd"> Returns:</span> +</span><span id="L-195"><a href="#L-195"><span class="linenos">195</span></a><span class="sd"> The transformed expression.</span> +</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a><span class="sd"> """</span> +</span><span id="L-197"><a href="#L-197"><span class="linenos">197</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> <span class="k">for</span> <span class="n">n</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span> <span class="ow">in</span> <span class="nb">reversed</span><span class="p">(</span><span class="nb">tuple</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">walk</span><span class="p">())):</span> +</span><span id="L-199"><a href="#L-199"><span class="linenos">199</span></a> <span class="n">n</span><span class="o">.</span><span class="n">_hash</span> <span class="o">=</span> <span class="nb">hash</span><span class="p">(</span><span class="n">n</span><span class="p">)</span> +</span><span id="L-200"><a href="#L-200"><span class="linenos">200</span></a> <span class="n">start</span> <span class="o">=</span> <span class="nb">hash</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-201"><a href="#L-201"><span class="linenos">201</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-202"><a href="#L-202"><span class="linenos">202</span></a> +</span><span id="L-203"><a href="#L-203"><span class="linenos">203</span></a> <span class="k">for</span> <span class="n">n</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">walk</span><span class="p">():</span> +</span><span id="L-204"><a href="#L-204"><span class="linenos">204</span></a> <span class="n">n</span><span class="o">.</span><span class="n">_hash</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-205"><a href="#L-205"><span class="linenos">205</span></a> <span class="k">if</span> <span class="n">start</span> <span class="o">==</span> <span class="nb">hash</span><span class="p">(</span><span class="n">expression</span><span class="p">):</span> +</span><span id="L-206"><a href="#L-206"><span class="linenos">206</span></a> <span class="k">break</span> +</span><span id="L-207"><a href="#L-207"><span class="linenos">207</span></a> <span class="k">return</span> <span class="n">expression</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><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> -</span><span id="L-211"><a href="#L-211"><span class="linenos">211</span></a><span class="k">def</span> <span class="nf">tsort</span><span class="p">(</span><span class="n">dag</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">T</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">T</span><span class="p">]])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">T</span><span class="p">]:</span> -</span><span id="L-212"><a href="#L-212"><span class="linenos">212</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-213"><a href="#L-213"><span class="linenos">213</span></a><span class="sd"> Sorts a given directed acyclic graph in topological order.</span> -</span><span id="L-214"><a href="#L-214"><span class="linenos">214</span></a> -</span><span id="L-215"><a href="#L-215"><span class="linenos">215</span></a><span class="sd"> Args:</span> -</span><span id="L-216"><a href="#L-216"><span class="linenos">216</span></a><span class="sd"> dag: the graph to be sorted.</span> -</span><span id="L-217"><a href="#L-217"><span class="linenos">217</span></a> -</span><span id="L-218"><a href="#L-218"><span class="linenos">218</span></a><span class="sd"> Returns:</span> -</span><span id="L-219"><a href="#L-219"><span class="linenos">219</span></a><span class="sd"> A list that contains all of the graph's nodes in topological order.</span> -</span><span id="L-220"><a href="#L-220"><span class="linenos">220</span></a><span class="sd"> """</span> -</span><span id="L-221"><a href="#L-221"><span class="linenos">221</span></a> <span class="n">result</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-222"><a href="#L-222"><span class="linenos">222</span></a> -</span><span id="L-223"><a href="#L-223"><span class="linenos">223</span></a> <span class="k">def</span> <span class="nf">visit</span><span class="p">(</span><span class="n">node</span><span class="p">:</span> <span class="n">T</span><span class="p">,</span> <span class="n">visited</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="n">T</span><span class="p">])</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-224"><a href="#L-224"><span class="linenos">224</span></a> <span class="k">if</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">result</span><span class="p">:</span> -</span><span id="L-225"><a href="#L-225"><span class="linenos">225</span></a> <span class="k">return</span> -</span><span id="L-226"><a href="#L-226"><span class="linenos">226</span></a> <span class="k">if</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">visited</span><span class="p">:</span> -</span><span id="L-227"><a href="#L-227"><span class="linenos">227</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Cycle error"</span><span class="p">)</span> -</span><span id="L-228"><a href="#L-228"><span class="linenos">228</span></a> -</span><span id="L-229"><a href="#L-229"><span class="linenos">229</span></a> <span class="n">visited</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">node</span><span class="p">)</span> -</span><span id="L-230"><a href="#L-230"><span class="linenos">230</span></a> -</span><span id="L-231"><a href="#L-231"><span class="linenos">231</span></a> <span class="k">for</span> <span class="n">dep</span> <span class="ow">in</span> <span class="n">dag</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="p">[]):</span> -</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="n">visit</span><span class="p">(</span><span class="n">dep</span><span class="p">,</span> <span class="n">visited</span><span class="p">)</span> -</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> -</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="n">visited</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">node</span><span class="p">)</span> -</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="n">result</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">node</span><span class="p">)</span> -</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> -</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> <span class="k">for</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">dag</span><span class="p">:</span> -</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="n">visit</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="nb">set</span><span class="p">())</span> -</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> -</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="k">return</span> <span class="n">result</span> -</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> +</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a><span class="k">def</span> <span class="nf">tsort</span><span class="p">(</span><span class="n">dag</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">T</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="n">T</span><span class="p">]])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">T</span><span class="p">]:</span> +</span><span id="L-211"><a href="#L-211"><span class="linenos">211</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-212"><a href="#L-212"><span class="linenos">212</span></a><span class="sd"> Sorts a given directed acyclic graph in topological order.</span> +</span><span id="L-213"><a href="#L-213"><span class="linenos">213</span></a> +</span><span id="L-214"><a href="#L-214"><span class="linenos">214</span></a><span class="sd"> Args:</span> +</span><span id="L-215"><a href="#L-215"><span class="linenos">215</span></a><span class="sd"> dag: the graph to be sorted.</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="sd"> Returns:</span> +</span><span id="L-218"><a href="#L-218"><span class="linenos">218</span></a><span class="sd"> A list that contains all of the graph's nodes in topological order.</span> +</span><span id="L-219"><a href="#L-219"><span class="linenos">219</span></a><span class="sd"> """</span> +</span><span id="L-220"><a href="#L-220"><span class="linenos">220</span></a> <span class="n">result</span> <span class="o">=</span> <span class="p">[]</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="k">for</span> <span class="n">node</span><span class="p">,</span> <span class="n">deps</span> <span class="ow">in</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">dag</span><span class="o">.</span><span class="n">items</span><span class="p">()):</span> +</span><span id="L-223"><a href="#L-223"><span class="linenos">223</span></a> <span class="k">for</span> <span class="n">dep</span> <span class="ow">in</span> <span class="n">deps</span><span class="p">:</span> +</span><span id="L-224"><a href="#L-224"><span class="linenos">224</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">dep</span> <span class="ow">in</span> <span class="n">dag</span><span class="p">:</span> +</span><span id="L-225"><a href="#L-225"><span class="linenos">225</span></a> <span class="n">dag</span><span class="p">[</span><span class="n">dep</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</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="k">while</span> <span class="n">dag</span><span class="p">:</span> +</span><span id="L-228"><a href="#L-228"><span class="linenos">228</span></a> <span class="n">current</span> <span class="o">=</span> <span class="p">{</span><span class="n">node</span> <span class="k">for</span> <span class="n">node</span><span class="p">,</span> <span class="n">deps</span> <span class="ow">in</span> <span class="n">dag</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">deps</span><span class="p">}</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="k">if</span> <span class="ow">not</span> <span class="n">current</span><span class="p">:</span> +</span><span id="L-231"><a href="#L-231"><span class="linenos">231</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Cycle error"</span><span class="p">)</span> +</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> +</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="k">for</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">current</span><span class="p">:</span> +</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="n">dag</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">node</span><span class="p">)</span> +</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> +</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> <span class="k">for</span> <span class="n">deps</span> <span class="ow">in</span> <span class="n">dag</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> +</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> <span class="n">deps</span> <span class="o">-=</span> <span class="n">current</span> +</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> +</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> <span class="n">result</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</span><span class="n">current</span><span class="p">))</span> <span class="c1"># type: ignore</span> +</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> +</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> <span class="k">return</span> <span class="n">result</span> </span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> -</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a><span class="k">def</span> <span class="nf">open_file</span><span class="p">(</span><span class="n">file_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">TextIO</span><span class="p">:</span> -</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a><span class="w"> </span><span class="sd">"""Open a file that may be compressed as gzip and return it in universal newline mode."""</span> -</span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">file_name</span><span class="p">,</span> <span class="s2">"rb"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> -</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="n">gzipped</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="o">==</span> <span class="sa">b</span><span class="s2">"</span><span class="se">\x1f\x8b</span><span class="s2">"</span> -</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> -</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> <span class="k">if</span> <span class="n">gzipped</span><span class="p">:</span> -</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> <span class="kn">import</span> <span class="nn">gzip</span> -</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> -</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> <span class="k">return</span> <span class="n">gzip</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">file_name</span><span class="p">,</span> <span class="s2">"rt"</span><span class="p">,</span> <span class="n">newline</span><span class="o">=</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="k">return</span> <span class="nb">open</span><span class="p">(</span><span class="n">file_name</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">,</span> <span class="n">newline</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a> +</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> +</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a><span class="k">def</span> <span class="nf">open_file</span><span class="p">(</span><span class="n">file_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">TextIO</span><span class="p">:</span> +</span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a><span class="w"> </span><span class="sd">"""Open a file that may be compressed as gzip and return it in universal newline mode."""</span> +</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">file_name</span><span class="p">,</span> <span class="s2">"rb"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> +</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> <span class="n">gzipped</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="o">==</span> <span class="sa">b</span><span class="s2">"</span><span class="se">\x1f\x8b</span><span class="s2">"</span> +</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> +</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> <span class="k">if</span> <span class="n">gzipped</span><span class="p">:</span> +</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> <span class="kn">import</span> <span class="nn">gzip</span> +</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> +</span><span id="L-252"><a href="#L-252"><span class="linenos">252</span></a> <span class="k">return</span> <span class="n">gzip</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">file_name</span><span class="p">,</span> <span class="s2">"rt"</span><span class="p">,</span> <span class="n">newline</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> +</span><span id="L-253"><a href="#L-253"><span class="linenos">253</span></a> +</span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a> <span class="k">return</span> <span class="nb">open</span><span class="p">(</span><span class="n">file_name</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">,</span> <span class="n">newline</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> </span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> -</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a><span class="nd">@contextmanager</span> -</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a><span class="k">def</span> <span class="nf">csv_reader</span><span class="p">(</span><span class="n">read_csv</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ReadCSV</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">:</span> -</span><span id="L-258"><a href="#L-258"><span class="linenos">258</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a><span class="sd"> Returns a csv reader given the expression `READ_CSV(name, ['delimiter', '|', ...])`.</span> -</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> -</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a><span class="sd"> Args:</span> -</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a><span class="sd"> read_csv: a `ReadCSV` function call</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="sd"> Yields:</span> -</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a><span class="sd"> A python csv reader.</span> -</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a><span class="sd"> """</span> -</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">read_csv</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> <span class="n">file</span> <span class="o">=</span> <span class="n">open_file</span><span class="p">(</span><span class="n">read_csv</span><span class="o">.</span><span class="n">name</span><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">delimiter</span> <span class="o">=</span> <span class="s2">","</span> -</span><span id="L-271"><a href="#L-271"><span class="linenos">271</span></a> <span class="n">args</span> <span class="o">=</span> <span class="nb">iter</span><span class="p">(</span><span class="n">arg</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> -</span><span id="L-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="n">args</span><span class="p">):</span> -</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="k">if</span> <span class="n">k</span> <span class="o">==</span> <span class="s2">"delimiter"</span><span class="p">:</span> -</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="n">delimiter</span> <span class="o">=</span> <span class="n">v</span> -</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a> -</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="L-277"><a href="#L-277"><span class="linenos">277</span></a> <span class="kn">import</span> <span class="nn">csv</span> <span class="k">as</span> <span class="nn">csv_</span> -</span><span id="L-278"><a href="#L-278"><span class="linenos">278</span></a> -</span><span id="L-279"><a href="#L-279"><span class="linenos">279</span></a> <span class="k">yield</span> <span class="n">csv_</span><span class="o">.</span><span class="n">reader</span><span class="p">(</span><span class="n">file</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="n">delimiter</span><span class="p">)</span> -</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a> <span class="k">finally</span><span class="p">:</span> -</span><span id="L-281"><a href="#L-281"><span class="linenos">281</span></a> <span class="n">file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> -</span><span id="L-282"><a href="#L-282"><span class="linenos">282</span></a> +</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> +</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a><span class="nd">@contextmanager</span> +</span><span id="L-258"><a href="#L-258"><span class="linenos">258</span></a><span class="k">def</span> <span class="nf">csv_reader</span><span class="p">(</span><span class="n">read_csv</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ReadCSV</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">:</span> +</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a><span class="sd"> Returns a csv reader given the expression `READ_CSV(name, ['delimiter', '|', ...])`.</span> +</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> +</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a><span class="sd"> Args:</span> +</span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a><span class="sd"> read_csv: a `ReadCSV` function call</span> +</span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> +</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a><span class="sd"> Yields:</span> +</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a><span class="sd"> A python csv reader.</span> +</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a><span class="sd"> """</span> +</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">read_csv</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="L-269"><a href="#L-269"><span class="linenos">269</span></a> <span class="n">file</span> <span class="o">=</span> <span class="n">open_file</span><span class="p">(</span><span class="n">read_csv</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> +</span><span id="L-270"><a href="#L-270"><span class="linenos">270</span></a> +</span><span id="L-271"><a href="#L-271"><span class="linenos">271</span></a> <span class="n">delimiter</span> <span class="o">=</span> <span class="s2">","</span> +</span><span id="L-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="n">args</span> <span class="o">=</span> <span class="nb">iter</span><span class="p">(</span><span class="n">arg</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> +</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="n">args</span><span class="p">):</span> +</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="k">if</span> <span class="n">k</span> <span class="o">==</span> <span class="s2">"delimiter"</span><span class="p">:</span> +</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a> <span class="n">delimiter</span> <span class="o">=</span> <span class="n">v</span> +</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a> +</span><span id="L-277"><a href="#L-277"><span class="linenos">277</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="L-278"><a href="#L-278"><span class="linenos">278</span></a> <span class="kn">import</span> <span class="nn">csv</span> <span class="k">as</span> <span class="nn">csv_</span> +</span><span id="L-279"><a href="#L-279"><span class="linenos">279</span></a> +</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a> <span class="k">yield</span> <span class="n">csv_</span><span class="o">.</span><span class="n">reader</span><span class="p">(</span><span class="n">file</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="n">delimiter</span><span class="p">)</span> +</span><span id="L-281"><a href="#L-281"><span class="linenos">281</span></a> <span class="k">finally</span><span class="p">:</span> +</span><span id="L-282"><a href="#L-282"><span class="linenos">282</span></a> <span class="n">file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> </span><span id="L-283"><a href="#L-283"><span class="linenos">283</span></a> -</span><span id="L-284"><a href="#L-284"><span class="linenos">284</span></a><span class="k">def</span> <span class="nf">find_new_name</span><span class="p">(</span><span class="n">taken</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">base</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-285"><a href="#L-285"><span class="linenos">285</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a><span class="sd"> Searches for a new name.</span> -</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a> -</span><span id="L-288"><a href="#L-288"><span class="linenos">288</span></a><span class="sd"> Args:</span> -</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a><span class="sd"> taken: a collection of taken names.</span> -</span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a><span class="sd"> base: base name to alter.</span> -</span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a> -</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a><span class="sd"> Returns:</span> -</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a><span class="sd"> The new, available name.</span> -</span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a><span class="sd"> """</span> -</span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a> <span class="k">if</span> <span class="n">base</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">taken</span><span class="p">:</span> -</span><span id="L-296"><a href="#L-296"><span class="linenos">296</span></a> <span class="k">return</span> <span class="n">base</span> -</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a> -</span><span id="L-298"><a href="#L-298"><span class="linenos">298</span></a> <span class="n">i</span> <span class="o">=</span> <span class="mi">2</span> -</span><span id="L-299"><a href="#L-299"><span class="linenos">299</span></a> <span class="n">new</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">base</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">i</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-300"><a href="#L-300"><span class="linenos">300</span></a> <span class="k">while</span> <span class="n">new</span> <span class="ow">in</span> <span class="n">taken</span><span class="p">:</span> -</span><span id="L-301"><a href="#L-301"><span class="linenos">301</span></a> <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="L-302"><a href="#L-302"><span class="linenos">302</span></a> <span class="n">new</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">base</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">i</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-303"><a href="#L-303"><span class="linenos">303</span></a> -</span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a> <span class="k">return</span> <span class="n">new</span> -</span><span id="L-305"><a href="#L-305"><span class="linenos">305</span></a> +</span><span id="L-284"><a href="#L-284"><span class="linenos">284</span></a> +</span><span id="L-285"><a href="#L-285"><span class="linenos">285</span></a><span class="k">def</span> <span class="nf">find_new_name</span><span class="p">(</span><span class="n">taken</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">base</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a><span class="sd"> Searches for a new name.</span> +</span><span id="L-288"><a href="#L-288"><span class="linenos">288</span></a> +</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a><span class="sd"> Args:</span> +</span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a><span class="sd"> taken: a collection of taken names.</span> +</span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a><span class="sd"> base: base name to alter.</span> +</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a> +</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a><span class="sd"> Returns:</span> +</span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a><span class="sd"> The new, available name.</span> +</span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a><span class="sd"> """</span> +</span><span id="L-296"><a href="#L-296"><span class="linenos">296</span></a> <span class="k">if</span> <span class="n">base</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">taken</span><span class="p">:</span> +</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a> <span class="k">return</span> <span class="n">base</span> +</span><span id="L-298"><a href="#L-298"><span class="linenos">298</span></a> +</span><span id="L-299"><a href="#L-299"><span class="linenos">299</span></a> <span class="n">i</span> <span class="o">=</span> <span class="mi">2</span> +</span><span id="L-300"><a href="#L-300"><span class="linenos">300</span></a> <span class="n">new</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">base</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">i</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-301"><a href="#L-301"><span class="linenos">301</span></a> <span class="k">while</span> <span class="n">new</span> <span class="ow">in</span> <span class="n">taken</span><span class="p">:</span> +</span><span id="L-302"><a href="#L-302"><span class="linenos">302</span></a> <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="L-303"><a href="#L-303"><span class="linenos">303</span></a> <span class="n">new</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">base</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">i</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a> +</span><span id="L-305"><a href="#L-305"><span class="linenos">305</span></a> <span class="k">return</span> <span class="n">new</span> </span><span id="L-306"><a href="#L-306"><span class="linenos">306</span></a> -</span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a><span class="k">def</span> <span class="nf">name_sequence</span><span class="p">(</span><span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[],</span> <span class="nb">str</span><span class="p">]:</span> -</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a><span class="w"> </span><span class="sd">"""Returns a name generator given a prefix (e.g. a0, a1, a2, ... if the prefix is "a")."""</span> -</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a> <span class="n">sequence</span> <span class="o">=</span> <span class="n">count</span><span class="p">()</span> -</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="k">return</span> <span class="k">lambda</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="nb">next</span><span class="p">(</span><span class="n">sequence</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a> +</span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a> +</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a><span class="k">def</span> <span class="nf">name_sequence</span><span class="p">(</span><span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[],</span> <span class="nb">str</span><span class="p">]:</span> +</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a><span class="w"> </span><span class="sd">"""Returns a name generator given a prefix (e.g. a0, a1, a2, ... if the prefix is "a")."""</span> +</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="n">sequence</span> <span class="o">=</span> <span class="n">count</span><span class="p">()</span> +</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a> <span class="k">return</span> <span class="k">lambda</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="nb">next</span><span class="p">(</span><span class="n">sequence</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> -</span><span id="L-313"><a href="#L-313"><span class="linenos">313</span></a><span class="k">def</span> <span class="nf">object_to_dict</span><span class="p">(</span><span class="n">obj</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">:</span> -</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a><span class="w"> </span><span class="sd">"""Returns a dictionary created from an object's attributes."""</span> -</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> <span class="k">return</span> <span class="p">{</span> -</span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> <span class="o">**</span><span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="n">v</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="s2">"copy"</span><span class="p">)</span> <span class="k">else</span> <span class="n">copy</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">vars</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span><span class="o">.</span><span class="n">items</span><span class="p">()},</span> -</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="o">**</span><span class="n">kwargs</span><span class="p">,</span> -</span><span id="L-318"><a href="#L-318"><span class="linenos">318</span></a> <span class="p">}</span> -</span><span id="L-319"><a href="#L-319"><span class="linenos">319</span></a> +</span><span id="L-313"><a href="#L-313"><span class="linenos">313</span></a> +</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a><span class="k">def</span> <span class="nf">object_to_dict</span><span class="p">(</span><span class="n">obj</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">:</span> +</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a><span class="w"> </span><span class="sd">"""Returns a dictionary created from an object's attributes."""</span> +</span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> <span class="k">return</span> <span class="p">{</span> +</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="o">**</span><span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="n">v</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="s2">"copy"</span><span class="p">)</span> <span class="k">else</span> <span class="n">copy</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">vars</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span><span class="o">.</span><span class="n">items</span><span class="p">()},</span> +</span><span id="L-318"><a href="#L-318"><span class="linenos">318</span></a> <span class="o">**</span><span class="n">kwargs</span><span class="p">,</span> +</span><span id="L-319"><a href="#L-319"><span class="linenos">319</span></a> <span class="p">}</span> </span><span id="L-320"><a href="#L-320"><span class="linenos">320</span></a> -</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a><span class="k">def</span> <span class="nf">split_num_words</span><span class="p">(</span> -</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a> <span class="n">value</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">min_num_words</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> <span class="n">fill_from_start</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]]:</span> -</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a><span class="sd"> Perform a split on a value and return N words as a result with `None` used for words that don't exist.</span> -</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> -</span><span id="L-327"><a href="#L-327"><span class="linenos">327</span></a><span class="sd"> Args:</span> -</span><span id="L-328"><a href="#L-328"><span class="linenos">328</span></a><span class="sd"> value: the value to be split.</span> -</span><span id="L-329"><a href="#L-329"><span class="linenos">329</span></a><span class="sd"> sep: the value to use to split on.</span> -</span><span id="L-330"><a href="#L-330"><span class="linenos">330</span></a><span class="sd"> min_num_words: the minimum number of words that are going to be in the result.</span> -</span><span id="L-331"><a href="#L-331"><span class="linenos">331</span></a><span class="sd"> fill_from_start: indicates that if `None` values should be inserted at the start or end of the list.</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="sd"> Examples:</span> -</span><span id="L-334"><a href="#L-334"><span class="linenos">334</span></a><span class="sd"> >>> split_num_words("db.table", ".", 3)</span> -</span><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a><span class="sd"> [None, 'db', 'table']</span> -</span><span id="L-336"><a href="#L-336"><span class="linenos">336</span></a><span class="sd"> >>> split_num_words("db.table", ".", 3, fill_from_start=False)</span> -</span><span id="L-337"><a href="#L-337"><span class="linenos">337</span></a><span class="sd"> ['db', 'table', None]</span> -</span><span id="L-338"><a href="#L-338"><span class="linenos">338</span></a><span class="sd"> >>> split_num_words("db.table", ".", 1)</span> -</span><span id="L-339"><a href="#L-339"><span class="linenos">339</span></a><span class="sd"> ['db', 'table']</span> -</span><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a> -</span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a><span class="sd"> Returns:</span> -</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a><span class="sd"> The list of words returned by `split`, possibly augmented by a number of `None` values.</span> -</span><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a><span class="sd"> """</span> -</span><span id="L-344"><a href="#L-344"><span class="linenos">344</span></a> <span class="n">words</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span> -</span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> <span class="k">if</span> <span class="n">fill_from_start</span><span class="p">:</span> -</span><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a> <span class="k">return</span> <span class="p">[</span><span class="kc">None</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="n">min_num_words</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">words</span><span class="p">))</span> <span class="o">+</span> <span class="n">words</span> -</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> <span class="k">return</span> <span class="n">words</span> <span class="o">+</span> <span class="p">[</span><span class="kc">None</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="n">min_num_words</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">words</span><span class="p">))</span> -</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> +</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a> +</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a><span class="k">def</span> <span class="nf">split_num_words</span><span class="p">(</span> +</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="n">value</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">min_num_words</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> <span class="n">fill_from_start</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]]:</span> +</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a><span class="sd"> Perform a split on a value and return N words as a result with `None` used for words that don't exist.</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="sd"> Args:</span> +</span><span id="L-329"><a href="#L-329"><span class="linenos">329</span></a><span class="sd"> value: the value to be split.</span> +</span><span id="L-330"><a href="#L-330"><span class="linenos">330</span></a><span class="sd"> sep: the value to use to split on.</span> +</span><span id="L-331"><a href="#L-331"><span class="linenos">331</span></a><span class="sd"> min_num_words: the minimum number of words that are going to be in the result.</span> +</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a><span class="sd"> fill_from_start: indicates that if `None` values should be inserted at the start or end of the list.</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="sd"> Examples:</span> +</span><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a><span class="sd"> >>> split_num_words("db.table", ".", 3)</span> +</span><span id="L-336"><a href="#L-336"><span class="linenos">336</span></a><span class="sd"> [None, 'db', 'table']</span> +</span><span id="L-337"><a href="#L-337"><span class="linenos">337</span></a><span class="sd"> >>> split_num_words("db.table", ".", 3, fill_from_start=False)</span> +</span><span id="L-338"><a href="#L-338"><span class="linenos">338</span></a><span class="sd"> ['db', 'table', None]</span> +</span><span id="L-339"><a href="#L-339"><span class="linenos">339</span></a><span class="sd"> >>> split_num_words("db.table", ".", 1)</span> +</span><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a><span class="sd"> ['db', 'table']</span> +</span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a> +</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a><span class="sd"> Returns:</span> +</span><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a><span class="sd"> The list of words returned by `split`, possibly augmented by a number of `None` values.</span> +</span><span id="L-344"><a href="#L-344"><span class="linenos">344</span></a><span class="sd"> """</span> +</span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> <span class="n">words</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span> +</span><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a> <span class="k">if</span> <span class="n">fill_from_start</span><span class="p">:</span> +</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> <span class="k">return</span> <span class="p">[</span><span class="kc">None</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="n">min_num_words</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">words</span><span class="p">))</span> <span class="o">+</span> <span class="n">words</span> +</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="k">return</span> <span class="n">words</span> <span class="o">+</span> <span class="p">[</span><span class="kc">None</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="n">min_num_words</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">words</span><span class="p">))</span> </span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> -</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a><span class="k">def</span> <span class="nf">is_iterable</span><span class="p">(</span><span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="L-351"><a href="#L-351"><span class="linenos">351</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a><span class="sd"> Checks if the value is an iterable, excluding the types `str` and `bytes`.</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="sd"> Examples:</span> -</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a><span class="sd"> >>> is_iterable([1,2])</span> -</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a><span class="sd"> True</span> -</span><span id="L-357"><a href="#L-357"><span class="linenos">357</span></a><span class="sd"> >>> is_iterable("test")</span> -</span><span id="L-358"><a href="#L-358"><span class="linenos">358</span></a><span class="sd"> False</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="sd"> Args:</span> -</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a><span class="sd"> value: the value to check if it is an iterable.</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="sd"> Returns:</span> -</span><span id="L-364"><a href="#L-364"><span class="linenos">364</span></a><span class="sd"> A `bool` value indicating if it is an iterable.</span> -</span><span id="L-365"><a href="#L-365"><span class="linenos">365</span></a><span class="sd"> """</span> -</span><span id="L-366"><a href="#L-366"><span class="linenos">366</span></a> <span class="k">return</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="s2">"__iter__"</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="nb">bytes</span><span class="p">))</span> -</span><span id="L-367"><a href="#L-367"><span class="linenos">367</span></a> +</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> +</span><span id="L-351"><a href="#L-351"><span class="linenos">351</span></a><span class="k">def</span> <span class="nf">is_iterable</span><span class="p">(</span><span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-353"><a href="#L-353"><span class="linenos">353</span></a><span class="sd"> Checks if the value is an iterable, excluding the types `str` and `bytes`.</span> +</span><span id="L-354"><a href="#L-354"><span class="linenos">354</span></a> +</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a><span class="sd"> Examples:</span> +</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a><span class="sd"> >>> is_iterable([1,2])</span> +</span><span id="L-357"><a href="#L-357"><span class="linenos">357</span></a><span class="sd"> True</span> +</span><span id="L-358"><a href="#L-358"><span class="linenos">358</span></a><span class="sd"> >>> is_iterable("test")</span> +</span><span id="L-359"><a href="#L-359"><span class="linenos">359</span></a><span class="sd"> False</span> +</span><span id="L-360"><a href="#L-360"><span class="linenos">360</span></a> +</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a><span class="sd"> Args:</span> +</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a><span class="sd"> value: the value to check if it is an iterable.</span> +</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a> +</span><span id="L-364"><a href="#L-364"><span class="linenos">364</span></a><span class="sd"> Returns:</span> +</span><span id="L-365"><a href="#L-365"><span class="linenos">365</span></a><span class="sd"> A `bool` value indicating if it is an iterable.</span> +</span><span id="L-366"><a href="#L-366"><span class="linenos">366</span></a><span class="sd"> """</span> +</span><span id="L-367"><a href="#L-367"><span class="linenos">367</span></a> <span class="k">return</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="s2">"__iter__"</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="nb">bytes</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">def</span> <span class="nf">flatten</span><span class="p">(</span><span class="n">values</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Iterator</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]:</span> -</span><span id="L-370"><a href="#L-370"><span class="linenos">370</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-371"><a href="#L-371"><span class="linenos">371</span></a><span class="sd"> Flattens an iterable that can contain both iterable and non-iterable elements. Objects of</span> -</span><span id="L-372"><a href="#L-372"><span class="linenos">372</span></a><span class="sd"> type `str` and `bytes` are not regarded as iterables.</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="sd"> Examples:</span> -</span><span id="L-375"><a href="#L-375"><span class="linenos">375</span></a><span class="sd"> >>> list(flatten([[1, 2], 3, {4}, (5, "bla")]))</span> -</span><span id="L-376"><a href="#L-376"><span class="linenos">376</span></a><span class="sd"> [1, 2, 3, 4, 5, 'bla']</span> -</span><span id="L-377"><a href="#L-377"><span class="linenos">377</span></a><span class="sd"> >>> list(flatten([1, 2, 3]))</span> -</span><span id="L-378"><a href="#L-378"><span class="linenos">378</span></a><span class="sd"> [1, 2, 3]</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="sd"> Args:</span> -</span><span id="L-381"><a href="#L-381"><span class="linenos">381</span></a><span class="sd"> values: the value to be flattened.</span> -</span><span id="L-382"><a href="#L-382"><span class="linenos">382</span></a> -</span><span id="L-383"><a href="#L-383"><span class="linenos">383</span></a><span class="sd"> Yields:</span> -</span><span id="L-384"><a href="#L-384"><span class="linenos">384</span></a><span class="sd"> Non-iterable elements in `values`.</span> -</span><span id="L-385"><a href="#L-385"><span class="linenos">385</span></a><span class="sd"> """</span> -</span><span id="L-386"><a href="#L-386"><span class="linenos">386</span></a> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">values</span><span class="p">:</span> -</span><span id="L-387"><a href="#L-387"><span class="linenos">387</span></a> <span class="k">if</span> <span class="n">is_iterable</span><span class="p">(</span><span class="n">value</span><span class="p">):</span> -</span><span id="L-388"><a href="#L-388"><span class="linenos">388</span></a> <span class="k">yield from</span> <span class="n">flatten</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="L-389"><a href="#L-389"><span class="linenos">389</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-390"><a href="#L-390"><span class="linenos">390</span></a> <span class="k">yield</span> <span class="n">value</span> -</span><span id="L-391"><a href="#L-391"><span class="linenos">391</span></a> +</span><span id="L-369"><a href="#L-369"><span class="linenos">369</span></a> +</span><span id="L-370"><a href="#L-370"><span class="linenos">370</span></a><span class="k">def</span> <span class="nf">flatten</span><span class="p">(</span><span class="n">values</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Iterator</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]:</span> +</span><span id="L-371"><a href="#L-371"><span class="linenos">371</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-372"><a href="#L-372"><span class="linenos">372</span></a><span class="sd"> Flattens an iterable that can contain both iterable and non-iterable elements. Objects of</span> +</span><span id="L-373"><a href="#L-373"><span class="linenos">373</span></a><span class="sd"> type `str` and `bytes` are not regarded as iterables.</span> +</span><span id="L-374"><a href="#L-374"><span class="linenos">374</span></a> +</span><span id="L-375"><a href="#L-375"><span class="linenos">375</span></a><span class="sd"> Examples:</span> +</span><span id="L-376"><a href="#L-376"><span class="linenos">376</span></a><span class="sd"> >>> list(flatten([[1, 2], 3, {4}, (5, "bla")]))</span> +</span><span id="L-377"><a href="#L-377"><span class="linenos">377</span></a><span class="sd"> [1, 2, 3, 4, 5, 'bla']</span> +</span><span id="L-378"><a href="#L-378"><span class="linenos">378</span></a><span class="sd"> >>> list(flatten([1, 2, 3]))</span> +</span><span id="L-379"><a href="#L-379"><span class="linenos">379</span></a><span class="sd"> [1, 2, 3]</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="sd"> Args:</span> +</span><span id="L-382"><a href="#L-382"><span class="linenos">382</span></a><span class="sd"> values: the value to be flattened.</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="sd"> Yields:</span> +</span><span id="L-385"><a href="#L-385"><span class="linenos">385</span></a><span class="sd"> Non-iterable elements in `values`.</span> +</span><span id="L-386"><a href="#L-386"><span class="linenos">386</span></a><span class="sd"> """</span> +</span><span id="L-387"><a href="#L-387"><span class="linenos">387</span></a> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">values</span><span class="p">:</span> +</span><span id="L-388"><a href="#L-388"><span class="linenos">388</span></a> <span class="k">if</span> <span class="n">is_iterable</span><span class="p">(</span><span class="n">value</span><span class="p">):</span> +</span><span id="L-389"><a href="#L-389"><span class="linenos">389</span></a> <span class="k">yield from</span> <span class="n">flatten</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="L-390"><a href="#L-390"><span class="linenos">390</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-391"><a href="#L-391"><span class="linenos">391</span></a> <span class="k">yield</span> <span class="n">value</span> </span><span id="L-392"><a href="#L-392"><span class="linenos">392</span></a> -</span><span id="L-393"><a href="#L-393"><span class="linenos">393</span></a><span class="k">def</span> <span class="nf">dict_depth</span><span class="p">(</span><span class="n">d</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> -</span><span id="L-394"><a href="#L-394"><span class="linenos">394</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-395"><a href="#L-395"><span class="linenos">395</span></a><span class="sd"> Get the nesting depth of a dictionary.</span> -</span><span id="L-396"><a href="#L-396"><span class="linenos">396</span></a> -</span><span id="L-397"><a href="#L-397"><span class="linenos">397</span></a><span class="sd"> For example:</span> -</span><span id="L-398"><a href="#L-398"><span class="linenos">398</span></a><span class="sd"> >>> dict_depth(None)</span> -</span><span id="L-399"><a href="#L-399"><span class="linenos">399</span></a><span class="sd"> 0</span> -</span><span id="L-400"><a href="#L-400"><span class="linenos">400</span></a><span class="sd"> >>> dict_depth({})</span> -</span><span id="L-401"><a href="#L-401"><span class="linenos">401</span></a><span class="sd"> 1</span> -</span><span id="L-402"><a href="#L-402"><span class="linenos">402</span></a><span class="sd"> >>> dict_depth({"a": "b"})</span> -</span><span id="L-403"><a href="#L-403"><span class="linenos">403</span></a><span class="sd"> 1</span> -</span><span id="L-404"><a href="#L-404"><span class="linenos">404</span></a><span class="sd"> >>> dict_depth({"a": {}})</span> -</span><span id="L-405"><a href="#L-405"><span class="linenos">405</span></a><span class="sd"> 2</span> -</span><span id="L-406"><a href="#L-406"><span class="linenos">406</span></a><span class="sd"> >>> dict_depth({"a": {"b": {}}})</span> -</span><span id="L-407"><a href="#L-407"><span class="linenos">407</span></a><span class="sd"> 3</span> -</span><span id="L-408"><a href="#L-408"><span class="linenos">408</span></a> -</span><span id="L-409"><a href="#L-409"><span class="linenos">409</span></a><span class="sd"> Args:</span> -</span><span id="L-410"><a href="#L-410"><span class="linenos">410</span></a><span class="sd"> d (dict): dictionary</span> -</span><span id="L-411"><a href="#L-411"><span class="linenos">411</span></a> -</span><span id="L-412"><a href="#L-412"><span class="linenos">412</span></a><span class="sd"> Returns:</span> -</span><span id="L-413"><a href="#L-413"><span class="linenos">413</span></a><span class="sd"> int: depth</span> -</span><span id="L-414"><a href="#L-414"><span class="linenos">414</span></a><span class="sd"> """</span> -</span><span id="L-415"><a href="#L-415"><span class="linenos">415</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="L-416"><a href="#L-416"><span class="linenos">416</span></a> <span class="k">return</span> <span class="mi">1</span> <span class="o">+</span> <span class="n">dict_depth</span><span class="p">(</span><span class="nb">next</span><span class="p">(</span><span class="nb">iter</span><span class="p">(</span><span class="n">d</span><span class="o">.</span><span class="n">values</span><span class="p">())))</span> -</span><span id="L-417"><a href="#L-417"><span class="linenos">417</span></a> <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span> -</span><span id="L-418"><a href="#L-418"><span class="linenos">418</span></a> <span class="c1"># d doesn't have attribute "values"</span> -</span><span id="L-419"><a href="#L-419"><span class="linenos">419</span></a> <span class="k">return</span> <span class="mi">0</span> -</span><span id="L-420"><a href="#L-420"><span class="linenos">420</span></a> <span class="k">except</span> <span class="ne">StopIteration</span><span class="p">:</span> -</span><span id="L-421"><a href="#L-421"><span class="linenos">421</span></a> <span class="c1"># d.values() returns an empty sequence</span> -</span><span id="L-422"><a href="#L-422"><span class="linenos">422</span></a> <span class="k">return</span> <span class="mi">1</span> -</span><span id="L-423"><a href="#L-423"><span class="linenos">423</span></a> +</span><span id="L-393"><a href="#L-393"><span class="linenos">393</span></a> +</span><span id="L-394"><a href="#L-394"><span class="linenos">394</span></a><span class="k">def</span> <span class="nf">dict_depth</span><span class="p">(</span><span class="n">d</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> +</span><span id="L-395"><a href="#L-395"><span class="linenos">395</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-396"><a href="#L-396"><span class="linenos">396</span></a><span class="sd"> Get the nesting depth of a dictionary.</span> +</span><span id="L-397"><a href="#L-397"><span class="linenos">397</span></a> +</span><span id="L-398"><a href="#L-398"><span class="linenos">398</span></a><span class="sd"> For example:</span> +</span><span id="L-399"><a href="#L-399"><span class="linenos">399</span></a><span class="sd"> >>> dict_depth(None)</span> +</span><span id="L-400"><a href="#L-400"><span class="linenos">400</span></a><span class="sd"> 0</span> +</span><span id="L-401"><a href="#L-401"><span class="linenos">401</span></a><span class="sd"> >>> dict_depth({})</span> +</span><span id="L-402"><a href="#L-402"><span class="linenos">402</span></a><span class="sd"> 1</span> +</span><span id="L-403"><a href="#L-403"><span class="linenos">403</span></a><span class="sd"> >>> dict_depth({"a": "b"})</span> +</span><span id="L-404"><a href="#L-404"><span class="linenos">404</span></a><span class="sd"> 1</span> +</span><span id="L-405"><a href="#L-405"><span class="linenos">405</span></a><span class="sd"> >>> dict_depth({"a": {}})</span> +</span><span id="L-406"><a href="#L-406"><span class="linenos">406</span></a><span class="sd"> 2</span> +</span><span id="L-407"><a href="#L-407"><span class="linenos">407</span></a><span class="sd"> >>> dict_depth({"a": {"b": {}}})</span> +</span><span id="L-408"><a href="#L-408"><span class="linenos">408</span></a><span class="sd"> 3</span> +</span><span id="L-409"><a href="#L-409"><span class="linenos">409</span></a> +</span><span id="L-410"><a href="#L-410"><span class="linenos">410</span></a><span class="sd"> Args:</span> +</span><span id="L-411"><a href="#L-411"><span class="linenos">411</span></a><span class="sd"> d (dict): dictionary</span> +</span><span id="L-412"><a href="#L-412"><span class="linenos">412</span></a> +</span><span id="L-413"><a href="#L-413"><span class="linenos">413</span></a><span class="sd"> Returns:</span> +</span><span id="L-414"><a href="#L-414"><span class="linenos">414</span></a><span class="sd"> int: depth</span> +</span><span id="L-415"><a href="#L-415"><span class="linenos">415</span></a><span class="sd"> """</span> +</span><span id="L-416"><a href="#L-416"><span class="linenos">416</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="L-417"><a href="#L-417"><span class="linenos">417</span></a> <span class="k">return</span> <span class="mi">1</span> <span class="o">+</span> <span class="n">dict_depth</span><span class="p">(</span><span class="nb">next</span><span class="p">(</span><span class="nb">iter</span><span class="p">(</span><span class="n">d</span><span class="o">.</span><span class="n">values</span><span class="p">())))</span> +</span><span id="L-418"><a href="#L-418"><span class="linenos">418</span></a> <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span> +</span><span id="L-419"><a href="#L-419"><span class="linenos">419</span></a> <span class="c1"># d doesn't have attribute "values"</span> +</span><span id="L-420"><a href="#L-420"><span class="linenos">420</span></a> <span class="k">return</span> <span class="mi">0</span> +</span><span id="L-421"><a href="#L-421"><span class="linenos">421</span></a> <span class="k">except</span> <span class="ne">StopIteration</span><span class="p">:</span> +</span><span id="L-422"><a href="#L-422"><span class="linenos">422</span></a> <span class="c1"># d.values() returns an empty sequence</span> +</span><span id="L-423"><a href="#L-423"><span class="linenos">423</span></a> <span class="k">return</span> <span class="mi">1</span> </span><span id="L-424"><a href="#L-424"><span class="linenos">424</span></a> -</span><span id="L-425"><a href="#L-425"><span class="linenos">425</span></a><span class="k">def</span> <span class="nf">first</span><span class="p">(</span><span class="n">it</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">T</span><span class="p">])</span> <span class="o">-></span> <span class="n">T</span><span class="p">:</span> -</span><span id="L-426"><a href="#L-426"><span class="linenos">426</span></a><span class="w"> </span><span class="sd">"""Returns the first element from an iterable.</span> -</span><span id="L-427"><a href="#L-427"><span class="linenos">427</span></a> -</span><span id="L-428"><a href="#L-428"><span class="linenos">428</span></a><span class="sd"> Useful for sets.</span> -</span><span id="L-429"><a href="#L-429"><span class="linenos">429</span></a><span class="sd"> """</span> -</span><span id="L-430"><a href="#L-430"><span class="linenos">430</span></a> <span class="k">return</span> <span class="nb">next</span><span class="p">(</span><span class="n">i</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">it</span><span class="p">)</span> -</span><span id="L-431"><a href="#L-431"><span class="linenos">431</span></a> -</span><span id="L-432"><a href="#L-432"><span class="linenos">432</span></a> -</span><span id="L-433"><a href="#L-433"><span class="linenos">433</span></a><span class="k">def</span> <span class="nf">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="L-434"><a href="#L-434"><span class="linenos">434</span></a><span class="w"> </span><span class="sd">"""Checks if text contains any case sensitive characters depending on dialect."""</span> -</span><span id="L-435"><a href="#L-435"><span class="linenos">435</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dialects.dialect</span> <span class="kn">import</span> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> -</span><span id="L-436"><a href="#L-436"><span class="linenos">436</span></a> -</span><span id="L-437"><a href="#L-437"><span class="linenos">437</span></a> <span class="n">unsafe</span> <span class="o">=</span> <span class="nb">str</span><span class="o">.</span><span class="n">islower</span> <span class="k">if</span> <span class="n">dialect</span> <span class="ow">in</span> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="k">else</span> <span class="nb">str</span><span class="o">.</span><span class="n">isupper</span> -</span><span id="L-438"><a href="#L-438"><span class="linenos">438</span></a> <span class="k">return</span> <span class="nb">any</span><span class="p">(</span><span class="n">unsafe</span><span class="p">(</span><span class="n">char</span><span class="p">)</span> <span class="k">for</span> <span class="n">char</span> <span class="ow">in</span> <span class="n">text</span><span class="p">)</span> -</span><span id="L-439"><a href="#L-439"><span class="linenos">439</span></a> -</span><span id="L-440"><a href="#L-440"><span class="linenos">440</span></a> -</span><span id="L-441"><a href="#L-441"><span class="linenos">441</span></a><span class="k">def</span> <span class="nf">should_identify</span><span class="p">(</span><span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="L-442"><a href="#L-442"><span class="linenos">442</span></a><span class="w"> </span><span class="sd">"""Checks if text should be identified given an identify option.</span> -</span><span id="L-443"><a href="#L-443"><span class="linenos">443</span></a> -</span><span id="L-444"><a href="#L-444"><span class="linenos">444</span></a><span class="sd"> Args:</span> -</span><span id="L-445"><a href="#L-445"><span class="linenos">445</span></a><span class="sd"> text: the text to check.</span> -</span><span id="L-446"><a href="#L-446"><span class="linenos">446</span></a><span class="sd"> identify:</span> -</span><span id="L-447"><a href="#L-447"><span class="linenos">447</span></a><span class="sd"> "always" or `True`: always returns true.</span> -</span><span id="L-448"><a href="#L-448"><span class="linenos">448</span></a><span class="sd"> "safe": true if there is no uppercase or lowercase character in `text`, depending on `dialect`.</span> -</span><span id="L-449"><a href="#L-449"><span class="linenos">449</span></a><span class="sd"> dialect: the dialect to use in order to decide whether a text should be identified.</span> -</span><span id="L-450"><a href="#L-450"><span class="linenos">450</span></a> -</span><span id="L-451"><a href="#L-451"><span class="linenos">451</span></a><span class="sd"> Returns:</span> -</span><span id="L-452"><a href="#L-452"><span class="linenos">452</span></a><span class="sd"> Whether or not a string should be identified.</span> -</span><span id="L-453"><a href="#L-453"><span class="linenos">453</span></a><span class="sd"> """</span> -</span><span id="L-454"><a href="#L-454"><span class="linenos">454</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> -</span><span id="L-455"><a href="#L-455"><span class="linenos">455</span></a> <span class="k">return</span> <span class="kc">True</span> -</span><span id="L-456"><a href="#L-456"><span class="linenos">456</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> -</span><span id="L-457"><a href="#L-457"><span class="linenos">457</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="n">dialect</span><span class="p">)</span> -</span><span id="L-458"><a href="#L-458"><span class="linenos">458</span></a> <span class="k">return</span> <span class="kc">False</span> +</span><span id="L-425"><a href="#L-425"><span class="linenos">425</span></a> +</span><span id="L-426"><a href="#L-426"><span class="linenos">426</span></a><span class="k">def</span> <span class="nf">first</span><span class="p">(</span><span class="n">it</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">T</span><span class="p">])</span> <span class="o">-></span> <span class="n">T</span><span class="p">:</span> +</span><span id="L-427"><a href="#L-427"><span class="linenos">427</span></a><span class="w"> </span><span class="sd">"""Returns the first element from an iterable.</span> +</span><span id="L-428"><a href="#L-428"><span class="linenos">428</span></a> +</span><span id="L-429"><a href="#L-429"><span class="linenos">429</span></a><span class="sd"> Useful for sets.</span> +</span><span id="L-430"><a href="#L-430"><span class="linenos">430</span></a><span class="sd"> """</span> +</span><span id="L-431"><a href="#L-431"><span class="linenos">431</span></a> <span class="k">return</span> <span class="nb">next</span><span class="p">(</span><span class="n">i</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">it</span><span class="p">)</span> </span></pre></div> @@ -595,11 +562,11 @@ </div> <a class="headerlink" href="#AutoName"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="AutoName-26"><a href="#AutoName-26"><span class="linenos">26</span></a><span class="k">class</span> <span class="nc">AutoName</span><span class="p">(</span><span class="n">Enum</span><span class="p">):</span> -</span><span id="AutoName-27"><a href="#AutoName-27"><span class="linenos">27</span></a><span class="w"> </span><span class="sd">"""This is used for creating enum classes where `auto()` is the string form of the corresponding value's name."""</span> -</span><span id="AutoName-28"><a href="#AutoName-28"><span class="linenos">28</span></a> -</span><span id="AutoName-29"><a href="#AutoName-29"><span class="linenos">29</span></a> <span class="k">def</span> <span class="nf">_generate_next_value_</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">_start</span><span class="p">,</span> <span class="n">_count</span><span class="p">,</span> <span class="n">_last_values</span><span class="p">):</span> -</span><span id="AutoName-30"><a href="#AutoName-30"><span class="linenos">30</span></a> <span class="k">return</span> <span class="n">name</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="AutoName-25"><a href="#AutoName-25"><span class="linenos">25</span></a><span class="k">class</span> <span class="nc">AutoName</span><span class="p">(</span><span class="n">Enum</span><span class="p">):</span> +</span><span id="AutoName-26"><a href="#AutoName-26"><span class="linenos">26</span></a><span class="w"> </span><span class="sd">"""This is used for creating enum classes where `auto()` is the string form of the corresponding value's name."""</span> +</span><span id="AutoName-27"><a href="#AutoName-27"><span class="linenos">27</span></a> +</span><span id="AutoName-28"><a href="#AutoName-28"><span class="linenos">28</span></a> <span class="k">def</span> <span class="nf">_generate_next_value_</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">_start</span><span class="p">,</span> <span class="n">_count</span><span class="p">,</span> <span class="n">_last_values</span><span class="p">):</span> +</span><span id="AutoName-29"><a href="#AutoName-29"><span class="linenos">29</span></a> <span class="k">return</span> <span class="n">name</span> </span></pre></div> @@ -629,12 +596,12 @@ </div> <a class="headerlink" href="#seq_get"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="seq_get-33"><a href="#seq_get-33"><span class="linenos">33</span></a><span class="k">def</span> <span class="nf">seq_get</span><span class="p">(</span><span class="n">seq</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="n">T</span><span class="p">],</span> <span class="n">index</span><span class="p">:</span> <span class="nb">int</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">T</span><span class="p">]:</span> -</span><span id="seq_get-34"><a href="#seq_get-34"><span class="linenos">34</span></a><span class="w"> </span><span class="sd">"""Returns the value in `seq` at position `index`, or `None` if `index` is out of bounds."""</span> -</span><span id="seq_get-35"><a href="#seq_get-35"><span class="linenos">35</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="seq_get-36"><a href="#seq_get-36"><span class="linenos">36</span></a> <span class="k">return</span> <span class="n">seq</span><span class="p">[</span><span class="n">index</span><span class="p">]</span> -</span><span id="seq_get-37"><a href="#seq_get-37"><span class="linenos">37</span></a> <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span> -</span><span id="seq_get-38"><a href="#seq_get-38"><span class="linenos">38</span></a> <span class="k">return</span> <span class="kc">None</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="seq_get-32"><a href="#seq_get-32"><span class="linenos">32</span></a><span class="k">def</span> <span class="nf">seq_get</span><span class="p">(</span><span class="n">seq</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="n">T</span><span class="p">],</span> <span class="n">index</span><span class="p">:</span> <span class="nb">int</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">T</span><span class="p">]:</span> +</span><span id="seq_get-33"><a href="#seq_get-33"><span class="linenos">33</span></a><span class="w"> </span><span class="sd">"""Returns the value in `seq` at position `index`, or `None` if `index` is out of bounds."""</span> +</span><span id="seq_get-34"><a href="#seq_get-34"><span class="linenos">34</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="seq_get-35"><a href="#seq_get-35"><span class="linenos">35</span></a> <span class="k">return</span> <span class="n">seq</span><span class="p">[</span><span class="n">index</span><span class="p">]</span> +</span><span id="seq_get-36"><a href="#seq_get-36"><span class="linenos">36</span></a> <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span> +</span><span id="seq_get-37"><a href="#seq_get-37"><span class="linenos">37</span></a> <span class="k">return</span> <span class="kc">None</span> </span></pre></div> @@ -654,22 +621,22 @@ </div> <a class="headerlink" href="#ensure_list"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ensure_list-51"><a href="#ensure_list-51"><span class="linenos">51</span></a><span class="k">def</span> <span class="nf">ensure_list</span><span class="p">(</span><span class="n">value</span><span class="p">):</span> -</span><span id="ensure_list-52"><a href="#ensure_list-52"><span class="linenos">52</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="ensure_list-53"><a href="#ensure_list-53"><span class="linenos">53</span></a><span class="sd"> Ensures that a value is a list, otherwise casts or wraps it into one.</span> -</span><span id="ensure_list-54"><a href="#ensure_list-54"><span class="linenos">54</span></a> -</span><span id="ensure_list-55"><a href="#ensure_list-55"><span class="linenos">55</span></a><span class="sd"> Args:</span> -</span><span id="ensure_list-56"><a href="#ensure_list-56"><span class="linenos">56</span></a><span class="sd"> value: the value of interest.</span> -</span><span id="ensure_list-57"><a href="#ensure_list-57"><span class="linenos">57</span></a> -</span><span id="ensure_list-58"><a href="#ensure_list-58"><span class="linenos">58</span></a><span class="sd"> Returns:</span> -</span><span id="ensure_list-59"><a href="#ensure_list-59"><span class="linenos">59</span></a><span class="sd"> The value cast as a list if it's a list or a tuple, or else the value wrapped in a list.</span> -</span><span id="ensure_list-60"><a href="#ensure_list-60"><span class="linenos">60</span></a><span class="sd"> """</span> -</span><span id="ensure_list-61"><a href="#ensure_list-61"><span class="linenos">61</span></a> <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="ensure_list-62"><a href="#ensure_list-62"><span class="linenos">62</span></a> <span class="k">return</span> <span class="p">[]</span> -</span><span id="ensure_list-63"><a href="#ensure_list-63"><span class="linenos">63</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">)):</span> -</span><span id="ensure_list-64"><a href="#ensure_list-64"><span class="linenos">64</span></a> <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="ensure_list-65"><a href="#ensure_list-65"><span class="linenos">65</span></a> -</span><span id="ensure_list-66"><a href="#ensure_list-66"><span class="linenos">66</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ensure_list-50"><a href="#ensure_list-50"><span class="linenos">50</span></a><span class="k">def</span> <span class="nf">ensure_list</span><span class="p">(</span><span class="n">value</span><span class="p">):</span> +</span><span id="ensure_list-51"><a href="#ensure_list-51"><span class="linenos">51</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="ensure_list-52"><a href="#ensure_list-52"><span class="linenos">52</span></a><span class="sd"> Ensures that a value is a list, otherwise casts or wraps it into one.</span> +</span><span id="ensure_list-53"><a href="#ensure_list-53"><span class="linenos">53</span></a> +</span><span id="ensure_list-54"><a href="#ensure_list-54"><span class="linenos">54</span></a><span class="sd"> Args:</span> +</span><span id="ensure_list-55"><a href="#ensure_list-55"><span class="linenos">55</span></a><span class="sd"> value: the value of interest.</span> +</span><span id="ensure_list-56"><a href="#ensure_list-56"><span class="linenos">56</span></a> +</span><span id="ensure_list-57"><a href="#ensure_list-57"><span class="linenos">57</span></a><span class="sd"> Returns:</span> +</span><span id="ensure_list-58"><a href="#ensure_list-58"><span class="linenos">58</span></a><span class="sd"> The value cast as a list if it's a list or a tuple, or else the value wrapped in a list.</span> +</span><span id="ensure_list-59"><a href="#ensure_list-59"><span class="linenos">59</span></a><span class="sd"> """</span> +</span><span id="ensure_list-60"><a href="#ensure_list-60"><span class="linenos">60</span></a> <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="ensure_list-61"><a href="#ensure_list-61"><span class="linenos">61</span></a> <span class="k">return</span> <span class="p">[]</span> +</span><span id="ensure_list-62"><a href="#ensure_list-62"><span class="linenos">62</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">)):</span> +</span><span id="ensure_list-63"><a href="#ensure_list-63"><span class="linenos">63</span></a> <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="ensure_list-64"><a href="#ensure_list-64"><span class="linenos">64</span></a> +</span><span id="ensure_list-65"><a href="#ensure_list-65"><span class="linenos">65</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span> </span></pre></div> @@ -701,21 +668,21 @@ </div> <a class="headerlink" href="#ensure_collection"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ensure_collection-79"><a href="#ensure_collection-79"><span class="linenos">79</span></a><span class="k">def</span> <span class="nf">ensure_collection</span><span class="p">(</span><span class="n">value</span><span class="p">):</span> -</span><span id="ensure_collection-80"><a href="#ensure_collection-80"><span class="linenos">80</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="ensure_collection-81"><a href="#ensure_collection-81"><span class="linenos">81</span></a><span class="sd"> Ensures that a value is a collection (excluding `str` and `bytes`), otherwise wraps it into a list.</span> -</span><span id="ensure_collection-82"><a href="#ensure_collection-82"><span class="linenos">82</span></a> -</span><span id="ensure_collection-83"><a href="#ensure_collection-83"><span class="linenos">83</span></a><span class="sd"> Args:</span> -</span><span id="ensure_collection-84"><a href="#ensure_collection-84"><span class="linenos">84</span></a><span class="sd"> value: the value of interest.</span> -</span><span id="ensure_collection-85"><a href="#ensure_collection-85"><span class="linenos">85</span></a> -</span><span id="ensure_collection-86"><a href="#ensure_collection-86"><span class="linenos">86</span></a><span class="sd"> Returns:</span> -</span><span id="ensure_collection-87"><a href="#ensure_collection-87"><span class="linenos">87</span></a><span class="sd"> The value if it's a collection, or else the value wrapped in a list.</span> -</span><span id="ensure_collection-88"><a href="#ensure_collection-88"><span class="linenos">88</span></a><span class="sd"> """</span> -</span><span id="ensure_collection-89"><a href="#ensure_collection-89"><span class="linenos">89</span></a> <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="ensure_collection-90"><a href="#ensure_collection-90"><span class="linenos">90</span></a> <span class="k">return</span> <span class="p">[]</span> -</span><span id="ensure_collection-91"><a href="#ensure_collection-91"><span class="linenos">91</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="ensure_collection-92"><a href="#ensure_collection-92"><span class="linenos">92</span></a> <span class="n">value</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Collection</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="nb">bytes</span><span class="p">))</span> <span class="k">else</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span> -</span><span id="ensure_collection-93"><a href="#ensure_collection-93"><span class="linenos">93</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ensure_collection-78"><a href="#ensure_collection-78"><span class="linenos">78</span></a><span class="k">def</span> <span class="nf">ensure_collection</span><span class="p">(</span><span class="n">value</span><span class="p">):</span> +</span><span id="ensure_collection-79"><a href="#ensure_collection-79"><span class="linenos">79</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="ensure_collection-80"><a href="#ensure_collection-80"><span class="linenos">80</span></a><span class="sd"> Ensures that a value is a collection (excluding `str` and `bytes`), otherwise wraps it into a list.</span> +</span><span id="ensure_collection-81"><a href="#ensure_collection-81"><span class="linenos">81</span></a> +</span><span id="ensure_collection-82"><a href="#ensure_collection-82"><span class="linenos">82</span></a><span class="sd"> Args:</span> +</span><span id="ensure_collection-83"><a href="#ensure_collection-83"><span class="linenos">83</span></a><span class="sd"> value: the value of interest.</span> +</span><span id="ensure_collection-84"><a href="#ensure_collection-84"><span class="linenos">84</span></a> +</span><span id="ensure_collection-85"><a href="#ensure_collection-85"><span class="linenos">85</span></a><span class="sd"> Returns:</span> +</span><span id="ensure_collection-86"><a href="#ensure_collection-86"><span class="linenos">86</span></a><span class="sd"> The value if it's a collection, or else the value wrapped in a list.</span> +</span><span id="ensure_collection-87"><a href="#ensure_collection-87"><span class="linenos">87</span></a><span class="sd"> """</span> +</span><span id="ensure_collection-88"><a href="#ensure_collection-88"><span class="linenos">88</span></a> <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="ensure_collection-89"><a href="#ensure_collection-89"><span class="linenos">89</span></a> <span class="k">return</span> <span class="p">[]</span> +</span><span id="ensure_collection-90"><a href="#ensure_collection-90"><span class="linenos">90</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="ensure_collection-91"><a href="#ensure_collection-91"><span class="linenos">91</span></a> <span class="n">value</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Collection</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="nb">bytes</span><span class="p">))</span> <span class="k">else</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span> +</span><span id="ensure_collection-92"><a href="#ensure_collection-92"><span class="linenos">92</span></a> <span class="p">)</span> </span></pre></div> @@ -747,18 +714,18 @@ </div> <a class="headerlink" href="#csv"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="csv-96"><a href="#csv-96"><span class="linenos"> 96</span></a><span class="k">def</span> <span class="nf">csv</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="csv-97"><a href="#csv-97"><span class="linenos"> 97</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="csv-98"><a href="#csv-98"><span class="linenos"> 98</span></a><span class="sd"> Formats any number of string arguments as CSV.</span> -</span><span id="csv-99"><a href="#csv-99"><span class="linenos"> 99</span></a> -</span><span id="csv-100"><a href="#csv-100"><span class="linenos">100</span></a><span class="sd"> Args:</span> -</span><span id="csv-101"><a href="#csv-101"><span class="linenos">101</span></a><span class="sd"> args: the string arguments to format.</span> -</span><span id="csv-102"><a href="#csv-102"><span class="linenos">102</span></a><span class="sd"> sep: the argument separator.</span> -</span><span id="csv-103"><a href="#csv-103"><span class="linenos">103</span></a> -</span><span id="csv-104"><a href="#csv-104"><span class="linenos">104</span></a><span class="sd"> Returns:</span> -</span><span id="csv-105"><a href="#csv-105"><span class="linenos">105</span></a><span class="sd"> The arguments formatted as a CSV string.</span> -</span><span id="csv-106"><a href="#csv-106"><span class="linenos">106</span></a><span class="sd"> """</span> -</span><span id="csv-107"><a href="#csv-107"><span class="linenos">107</span></a> <span class="k">return</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span> <span class="k">if</span> <span class="n">arg</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="csv-95"><a href="#csv-95"><span class="linenos"> 95</span></a><span class="k">def</span> <span class="nf">csv</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="csv-96"><a href="#csv-96"><span class="linenos"> 96</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="csv-97"><a href="#csv-97"><span class="linenos"> 97</span></a><span class="sd"> Formats any number of string arguments as CSV.</span> +</span><span id="csv-98"><a href="#csv-98"><span class="linenos"> 98</span></a> +</span><span id="csv-99"><a href="#csv-99"><span class="linenos"> 99</span></a><span class="sd"> Args:</span> +</span><span id="csv-100"><a href="#csv-100"><span class="linenos">100</span></a><span class="sd"> args: the string arguments to format.</span> +</span><span id="csv-101"><a href="#csv-101"><span class="linenos">101</span></a><span class="sd"> sep: the argument separator.</span> +</span><span id="csv-102"><a href="#csv-102"><span class="linenos">102</span></a> +</span><span id="csv-103"><a href="#csv-103"><span class="linenos">103</span></a><span class="sd"> Returns:</span> +</span><span id="csv-104"><a href="#csv-104"><span class="linenos">104</span></a><span class="sd"> The arguments formatted as a CSV string.</span> +</span><span id="csv-105"><a href="#csv-105"><span class="linenos">105</span></a><span class="sd"> """</span> +</span><span id="csv-106"><a href="#csv-106"><span class="linenos">106</span></a> <span class="k">return</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span> <span class="k">if</span> <span class="n">arg</span><span class="p">)</span> </span></pre></div> @@ -791,29 +758,29 @@ </div> <a class="headerlink" href="#subclasses"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="subclasses-110"><a href="#subclasses-110"><span class="linenos">110</span></a><span class="k">def</span> <span class="nf">subclasses</span><span class="p">(</span> -</span><span id="subclasses-111"><a href="#subclasses-111"><span class="linenos">111</span></a> <span class="n">module_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="subclasses-112"><a href="#subclasses-112"><span class="linenos">112</span></a> <span class="n">classes</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> -</span><span id="subclasses-113"><a href="#subclasses-113"><span class="linenos">113</span></a> <span class="n">exclude</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="o">...</span><span class="p">]</span> <span class="o">=</span> <span class="p">(),</span> -</span><span id="subclasses-114"><a href="#subclasses-114"><span class="linenos">114</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">]:</span> -</span><span id="subclasses-115"><a href="#subclasses-115"><span class="linenos">115</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="subclasses-116"><a href="#subclasses-116"><span class="linenos">116</span></a><span class="sd"> Returns all subclasses for a collection of classes, possibly excluding some of them.</span> -</span><span id="subclasses-117"><a href="#subclasses-117"><span class="linenos">117</span></a> -</span><span id="subclasses-118"><a href="#subclasses-118"><span class="linenos">118</span></a><span class="sd"> Args:</span> -</span><span id="subclasses-119"><a href="#subclasses-119"><span class="linenos">119</span></a><span class="sd"> module_name: the name of the module to search for subclasses in.</span> -</span><span id="subclasses-120"><a href="#subclasses-120"><span class="linenos">120</span></a><span class="sd"> classes: class(es) we want to find the subclasses of.</span> -</span><span id="subclasses-121"><a href="#subclasses-121"><span class="linenos">121</span></a><span class="sd"> exclude: class(es) we want to exclude from the returned list.</span> -</span><span id="subclasses-122"><a href="#subclasses-122"><span class="linenos">122</span></a> -</span><span id="subclasses-123"><a href="#subclasses-123"><span class="linenos">123</span></a><span class="sd"> Returns:</span> -</span><span id="subclasses-124"><a href="#subclasses-124"><span class="linenos">124</span></a><span class="sd"> The target subclasses.</span> -</span><span id="subclasses-125"><a href="#subclasses-125"><span class="linenos">125</span></a><span class="sd"> """</span> -</span><span id="subclasses-126"><a href="#subclasses-126"><span class="linenos">126</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="subclasses-127"><a href="#subclasses-127"><span class="linenos">127</span></a> <span class="n">obj</span> -</span><span id="subclasses-128"><a href="#subclasses-128"><span class="linenos">128</span></a> <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">obj</span> <span class="ow">in</span> <span class="n">inspect</span><span class="o">.</span><span class="n">getmembers</span><span class="p">(</span> -</span><span id="subclasses-129"><a href="#subclasses-129"><span class="linenos">129</span></a> <span class="n">sys</span><span class="o">.</span><span class="n">modules</span><span class="p">[</span><span class="n">module_name</span><span class="p">],</span> -</span><span id="subclasses-130"><a href="#subclasses-130"><span class="linenos">130</span></a> <span class="k">lambda</span> <span class="n">obj</span><span class="p">:</span> <span class="n">inspect</span><span class="o">.</span><span class="n">isclass</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">issubclass</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="n">classes</span><span class="p">)</span> <span class="ow">and</span> <span class="n">obj</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">exclude</span><span class="p">,</span> -</span><span id="subclasses-131"><a href="#subclasses-131"><span class="linenos">131</span></a> <span class="p">)</span> -</span><span id="subclasses-132"><a href="#subclasses-132"><span class="linenos">132</span></a> <span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="subclasses-109"><a href="#subclasses-109"><span class="linenos">109</span></a><span class="k">def</span> <span class="nf">subclasses</span><span class="p">(</span> +</span><span id="subclasses-110"><a href="#subclasses-110"><span class="linenos">110</span></a> <span class="n">module_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="subclasses-111"><a href="#subclasses-111"><span class="linenos">111</span></a> <span class="n">classes</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="o">...</span><span class="p">],</span> +</span><span id="subclasses-112"><a href="#subclasses-112"><span class="linenos">112</span></a> <span class="n">exclude</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="o">...</span><span class="p">]</span> <span class="o">=</span> <span class="p">(),</span> +</span><span id="subclasses-113"><a href="#subclasses-113"><span class="linenos">113</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">]:</span> +</span><span id="subclasses-114"><a href="#subclasses-114"><span class="linenos">114</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="subclasses-115"><a href="#subclasses-115"><span class="linenos">115</span></a><span class="sd"> Returns all subclasses for a collection of classes, possibly excluding some of them.</span> +</span><span id="subclasses-116"><a href="#subclasses-116"><span class="linenos">116</span></a> +</span><span id="subclasses-117"><a href="#subclasses-117"><span class="linenos">117</span></a><span class="sd"> Args:</span> +</span><span id="subclasses-118"><a href="#subclasses-118"><span class="linenos">118</span></a><span class="sd"> module_name: the name of the module to search for subclasses in.</span> +</span><span id="subclasses-119"><a href="#subclasses-119"><span class="linenos">119</span></a><span class="sd"> classes: class(es) we want to find the subclasses of.</span> +</span><span id="subclasses-120"><a href="#subclasses-120"><span class="linenos">120</span></a><span class="sd"> exclude: class(es) we want to exclude from the returned list.</span> +</span><span id="subclasses-121"><a href="#subclasses-121"><span class="linenos">121</span></a> +</span><span id="subclasses-122"><a href="#subclasses-122"><span class="linenos">122</span></a><span class="sd"> Returns:</span> +</span><span id="subclasses-123"><a href="#subclasses-123"><span class="linenos">123</span></a><span class="sd"> The target subclasses.</span> +</span><span id="subclasses-124"><a href="#subclasses-124"><span class="linenos">124</span></a><span class="sd"> """</span> +</span><span id="subclasses-125"><a href="#subclasses-125"><span class="linenos">125</span></a> <span class="k">return</span> <span class="p">[</span> +</span><span id="subclasses-126"><a href="#subclasses-126"><span class="linenos">126</span></a> <span class="n">obj</span> +</span><span id="subclasses-127"><a href="#subclasses-127"><span class="linenos">127</span></a> <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">obj</span> <span class="ow">in</span> <span class="n">inspect</span><span class="o">.</span><span class="n">getmembers</span><span class="p">(</span> +</span><span id="subclasses-128"><a href="#subclasses-128"><span class="linenos">128</span></a> <span class="n">sys</span><span class="o">.</span><span class="n">modules</span><span class="p">[</span><span class="n">module_name</span><span class="p">],</span> +</span><span id="subclasses-129"><a href="#subclasses-129"><span class="linenos">129</span></a> <span class="k">lambda</span> <span class="n">obj</span><span class="p">:</span> <span class="n">inspect</span><span class="o">.</span><span class="n">isclass</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">issubclass</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="n">classes</span><span class="p">)</span> <span class="ow">and</span> <span class="n">obj</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">exclude</span><span class="p">,</span> +</span><span id="subclasses-130"><a href="#subclasses-130"><span class="linenos">130</span></a> <span class="p">)</span> +</span><span id="subclasses-131"><a href="#subclasses-131"><span class="linenos">131</span></a> <span class="p">]</span> </span></pre></div> @@ -847,52 +814,52 @@ </div> <a class="headerlink" href="#apply_index_offset"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="apply_index_offset-135"><a href="#apply_index_offset-135"><span class="linenos">135</span></a><span class="k">def</span> <span class="nf">apply_index_offset</span><span class="p">(</span> -</span><span id="apply_index_offset-136"><a href="#apply_index_offset-136"><span class="linenos">136</span></a> <span class="n">this</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="apply_index_offset-137"><a href="#apply_index_offset-137"><span class="linenos">137</span></a> <span class="n">expressions</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">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">E</span><span class="p">]],</span> -</span><span id="apply_index_offset-138"><a href="#apply_index_offset-138"><span class="linenos">138</span></a> <span class="n">offset</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> -</span><span id="apply_index_offset-139"><a href="#apply_index_offset-139"><span class="linenos">139</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">E</span><span class="p">]]:</span> -</span><span id="apply_index_offset-140"><a href="#apply_index_offset-140"><span class="linenos">140</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="apply_index_offset-141"><a href="#apply_index_offset-141"><span class="linenos">141</span></a><span class="sd"> Applies an offset to a given integer literal expression.</span> -</span><span id="apply_index_offset-142"><a href="#apply_index_offset-142"><span class="linenos">142</span></a> -</span><span id="apply_index_offset-143"><a href="#apply_index_offset-143"><span class="linenos">143</span></a><span class="sd"> Args:</span> -</span><span id="apply_index_offset-144"><a href="#apply_index_offset-144"><span class="linenos">144</span></a><span class="sd"> this: the target of the index</span> -</span><span id="apply_index_offset-145"><a href="#apply_index_offset-145"><span class="linenos">145</span></a><span class="sd"> expressions: the expression the offset will be applied to, wrapped in a list.</span> -</span><span id="apply_index_offset-146"><a href="#apply_index_offset-146"><span class="linenos">146</span></a><span class="sd"> offset: the offset that will be applied.</span> -</span><span id="apply_index_offset-147"><a href="#apply_index_offset-147"><span class="linenos">147</span></a> -</span><span id="apply_index_offset-148"><a href="#apply_index_offset-148"><span class="linenos">148</span></a><span class="sd"> Returns:</span> -</span><span id="apply_index_offset-149"><a href="#apply_index_offset-149"><span class="linenos">149</span></a><span class="sd"> The original expression with the offset applied to it, wrapped in a list. If the provided</span> -</span><span id="apply_index_offset-150"><a href="#apply_index_offset-150"><span class="linenos">150</span></a><span class="sd"> `expressions` argument contains more than one expressions, it's returned unaffected.</span> -</span><span id="apply_index_offset-151"><a href="#apply_index_offset-151"><span class="linenos">151</span></a><span class="sd"> """</span> -</span><span id="apply_index_offset-152"><a href="#apply_index_offset-152"><span class="linenos">152</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">offset</span> <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="apply_index_offset-153"><a href="#apply_index_offset-153"><span class="linenos">153</span></a> <span class="k">return</span> <span class="n">expressions</span> -</span><span id="apply_index_offset-154"><a href="#apply_index_offset-154"><span class="linenos">154</span></a> -</span><span id="apply_index_offset-155"><a href="#apply_index_offset-155"><span class="linenos">155</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="apply_index_offset-156"><a href="#apply_index_offset-156"><span class="linenos">156</span></a> -</span><span id="apply_index_offset-157"><a href="#apply_index_offset-157"><span class="linenos">157</span></a> <span class="kn">from</span> <span class="nn">sqlglot</span> <span class="kn">import</span> <span class="n">exp</span> -</span><span id="apply_index_offset-158"><a href="#apply_index_offset-158"><span class="linenos">158</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="apply_index_offset-159"><a href="#apply_index_offset-159"><span class="linenos">159</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.simplify</span> <span class="kn">import</span> <span class="n">simplify</span> -</span><span id="apply_index_offset-160"><a href="#apply_index_offset-160"><span class="linenos">160</span></a> -</span><span id="apply_index_offset-161"><a href="#apply_index_offset-161"><span class="linenos">161</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="apply_index_offset-162"><a href="#apply_index_offset-162"><span class="linenos">162</span></a> <span class="n">annotate_types</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="apply_index_offset-163"><a href="#apply_index_offset-163"><span class="linenos">163</span></a> -</span><span id="apply_index_offset-164"><a href="#apply_index_offset-164"><span class="linenos">164</span></a> <span class="k">if</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</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="n">this</span><span class="o">.</span><span class="n">type</span><span class="p">)</span><span class="o">.</span><span class="n">this</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="apply_index_offset-165"><a href="#apply_index_offset-165"><span class="linenos">165</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">UNKNOWN</span><span class="p">,</span> -</span><span id="apply_index_offset-166"><a href="#apply_index_offset-166"><span class="linenos">166</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">ARRAY</span><span class="p">,</span> -</span><span id="apply_index_offset-167"><a href="#apply_index_offset-167"><span class="linenos">167</span></a> <span class="p">):</span> -</span><span id="apply_index_offset-168"><a href="#apply_index_offset-168"><span class="linenos">168</span></a> <span class="k">return</span> <span class="n">expressions</span> -</span><span id="apply_index_offset-169"><a href="#apply_index_offset-169"><span class="linenos">169</span></a> -</span><span id="apply_index_offset-170"><a href="#apply_index_offset-170"><span class="linenos">170</span></a> <span class="k">if</span> <span class="n">expression</span><span class="p">:</span> -</span><span id="apply_index_offset-171"><a href="#apply_index_offset-171"><span class="linenos">171</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> -</span><span id="apply_index_offset-172"><a href="#apply_index_offset-172"><span class="linenos">172</span></a> <span class="n">annotate_types</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="apply_index_offset-173"><a href="#apply_index_offset-173"><span class="linenos">173</span></a> <span class="k">if</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</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="n">expression</span><span class="o">.</span><span class="n">type</span><span class="p">)</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">INTEGER_TYPES</span><span class="p">:</span> -</span><span id="apply_index_offset-174"><a href="#apply_index_offset-174"><span class="linenos">174</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="s2">"Applying array index offset (</span><span class="si">%s</span><span class="s2">)"</span><span class="p">,</span> <span class="n">offset</span><span class="p">)</span> -</span><span id="apply_index_offset-175"><a href="#apply_index_offset-175"><span class="linenos">175</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">simplify</span><span class="p">(</span> -</span><span id="apply_index_offset-176"><a href="#apply_index_offset-176"><span class="linenos">176</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Add</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">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="n">offset</span><span class="p">))</span> -</span><span id="apply_index_offset-177"><a href="#apply_index_offset-177"><span class="linenos">177</span></a> <span class="p">)</span> -</span><span id="apply_index_offset-178"><a href="#apply_index_offset-178"><span class="linenos">178</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">expression</span><span class="p">]</span> -</span><span id="apply_index_offset-179"><a href="#apply_index_offset-179"><span class="linenos">179</span></a> -</span><span id="apply_index_offset-180"><a href="#apply_index_offset-180"><span class="linenos">180</span></a> <span class="k">return</span> <span class="n">expressions</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="apply_index_offset-134"><a href="#apply_index_offset-134"><span class="linenos">134</span></a><span class="k">def</span> <span class="nf">apply_index_offset</span><span class="p">(</span> +</span><span id="apply_index_offset-135"><a href="#apply_index_offset-135"><span class="linenos">135</span></a> <span class="n">this</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="apply_index_offset-136"><a href="#apply_index_offset-136"><span class="linenos">136</span></a> <span class="n">expressions</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">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">E</span><span class="p">]],</span> +</span><span id="apply_index_offset-137"><a href="#apply_index_offset-137"><span class="linenos">137</span></a> <span class="n">offset</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> +</span><span id="apply_index_offset-138"><a href="#apply_index_offset-138"><span class="linenos">138</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">E</span><span class="p">]]:</span> +</span><span id="apply_index_offset-139"><a href="#apply_index_offset-139"><span class="linenos">139</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="apply_index_offset-140"><a href="#apply_index_offset-140"><span class="linenos">140</span></a><span class="sd"> Applies an offset to a given integer literal expression.</span> +</span><span id="apply_index_offset-141"><a href="#apply_index_offset-141"><span class="linenos">141</span></a> +</span><span id="apply_index_offset-142"><a href="#apply_index_offset-142"><span class="linenos">142</span></a><span class="sd"> Args:</span> +</span><span id="apply_index_offset-143"><a href="#apply_index_offset-143"><span class="linenos">143</span></a><span class="sd"> this: the target of the index</span> +</span><span id="apply_index_offset-144"><a href="#apply_index_offset-144"><span class="linenos">144</span></a><span class="sd"> expressions: the expression the offset will be applied to, wrapped in a list.</span> +</span><span id="apply_index_offset-145"><a href="#apply_index_offset-145"><span class="linenos">145</span></a><span class="sd"> offset: the offset that will be applied.</span> +</span><span id="apply_index_offset-146"><a href="#apply_index_offset-146"><span class="linenos">146</span></a> +</span><span id="apply_index_offset-147"><a href="#apply_index_offset-147"><span class="linenos">147</span></a><span class="sd"> Returns:</span> +</span><span id="apply_index_offset-148"><a href="#apply_index_offset-148"><span class="linenos">148</span></a><span class="sd"> The original expression with the offset applied to it, wrapped in a list. If the provided</span> +</span><span id="apply_index_offset-149"><a href="#apply_index_offset-149"><span class="linenos">149</span></a><span class="sd"> `expressions` argument contains more than one expressions, it's returned unaffected.</span> +</span><span id="apply_index_offset-150"><a href="#apply_index_offset-150"><span class="linenos">150</span></a><span class="sd"> """</span> +</span><span id="apply_index_offset-151"><a href="#apply_index_offset-151"><span class="linenos">151</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">offset</span> <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="apply_index_offset-152"><a href="#apply_index_offset-152"><span class="linenos">152</span></a> <span class="k">return</span> <span class="n">expressions</span> +</span><span id="apply_index_offset-153"><a href="#apply_index_offset-153"><span class="linenos">153</span></a> +</span><span id="apply_index_offset-154"><a href="#apply_index_offset-154"><span class="linenos">154</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="apply_index_offset-155"><a href="#apply_index_offset-155"><span class="linenos">155</span></a> +</span><span id="apply_index_offset-156"><a href="#apply_index_offset-156"><span class="linenos">156</span></a> <span class="kn">from</span> <span class="nn">sqlglot</span> <span class="kn">import</span> <span class="n">exp</span> +</span><span id="apply_index_offset-157"><a href="#apply_index_offset-157"><span class="linenos">157</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="apply_index_offset-158"><a href="#apply_index_offset-158"><span class="linenos">158</span></a> <span class="kn">from</span> <span class="nn">sqlglot.optimizer.simplify</span> <span class="kn">import</span> <span class="n">simplify</span> +</span><span id="apply_index_offset-159"><a href="#apply_index_offset-159"><span class="linenos">159</span></a> +</span><span id="apply_index_offset-160"><a href="#apply_index_offset-160"><span class="linenos">160</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="apply_index_offset-161"><a href="#apply_index_offset-161"><span class="linenos">161</span></a> <span class="n">annotate_types</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="apply_index_offset-162"><a href="#apply_index_offset-162"><span class="linenos">162</span></a> +</span><span id="apply_index_offset-163"><a href="#apply_index_offset-163"><span class="linenos">163</span></a> <span class="k">if</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</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="n">this</span><span class="o">.</span><span class="n">type</span><span class="p">)</span><span class="o">.</span><span class="n">this</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="apply_index_offset-164"><a href="#apply_index_offset-164"><span class="linenos">164</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">UNKNOWN</span><span class="p">,</span> +</span><span id="apply_index_offset-165"><a href="#apply_index_offset-165"><span class="linenos">165</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">ARRAY</span><span class="p">,</span> +</span><span id="apply_index_offset-166"><a href="#apply_index_offset-166"><span class="linenos">166</span></a> <span class="p">):</span> +</span><span id="apply_index_offset-167"><a href="#apply_index_offset-167"><span class="linenos">167</span></a> <span class="k">return</span> <span class="n">expressions</span> +</span><span id="apply_index_offset-168"><a href="#apply_index_offset-168"><span class="linenos">168</span></a> +</span><span id="apply_index_offset-169"><a href="#apply_index_offset-169"><span class="linenos">169</span></a> <span class="k">if</span> <span class="n">expression</span><span class="p">:</span> +</span><span id="apply_index_offset-170"><a href="#apply_index_offset-170"><span class="linenos">170</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="o">.</span><span class="n">type</span><span class="p">:</span> +</span><span id="apply_index_offset-171"><a href="#apply_index_offset-171"><span class="linenos">171</span></a> <span class="n">annotate_types</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="apply_index_offset-172"><a href="#apply_index_offset-172"><span class="linenos">172</span></a> <span class="k">if</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</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="n">expression</span><span class="o">.</span><span class="n">type</span><span class="p">)</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">INTEGER_TYPES</span><span class="p">:</span> +</span><span id="apply_index_offset-173"><a href="#apply_index_offset-173"><span class="linenos">173</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="s2">"Applying array index offset (</span><span class="si">%s</span><span class="s2">)"</span><span class="p">,</span> <span class="n">offset</span><span class="p">)</span> +</span><span id="apply_index_offset-174"><a href="#apply_index_offset-174"><span class="linenos">174</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">simplify</span><span class="p">(</span> +</span><span id="apply_index_offset-175"><a href="#apply_index_offset-175"><span class="linenos">175</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Add</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">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="n">offset</span><span class="p">))</span> +</span><span id="apply_index_offset-176"><a href="#apply_index_offset-176"><span class="linenos">176</span></a> <span class="p">)</span> +</span><span id="apply_index_offset-177"><a href="#apply_index_offset-177"><span class="linenos">177</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">expression</span><span class="p">]</span> +</span><span id="apply_index_offset-178"><a href="#apply_index_offset-178"><span class="linenos">178</span></a> +</span><span id="apply_index_offset-179"><a href="#apply_index_offset-179"><span class="linenos">179</span></a> <span class="k">return</span> <span class="n">expressions</span> </span></pre></div> @@ -927,9 +894,9 @@ </div> <a class="headerlink" href="#camel_to_snake_case"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="camel_to_snake_case-183"><a href="#camel_to_snake_case-183"><span class="linenos">183</span></a><span class="k">def</span> <span class="nf">camel_to_snake_case</span><span class="p">(</span><span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="camel_to_snake_case-184"><a href="#camel_to_snake_case-184"><span class="linenos">184</span></a><span class="w"> </span><span class="sd">"""Converts `name` from camelCase to snake_case and returns the result."""</span> -</span><span id="camel_to_snake_case-185"><a href="#camel_to_snake_case-185"><span class="linenos">185</span></a> <span class="k">return</span> <span class="n">CAMEL_CASE_PATTERN</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="s2">"_"</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="camel_to_snake_case-182"><a href="#camel_to_snake_case-182"><span class="linenos">182</span></a><span class="k">def</span> <span class="nf">camel_to_snake_case</span><span class="p">(</span><span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="camel_to_snake_case-183"><a href="#camel_to_snake_case-183"><span class="linenos">183</span></a><span class="w"> </span><span class="sd">"""Converts `name` from camelCase to snake_case and returns the result."""</span> +</span><span id="camel_to_snake_case-184"><a href="#camel_to_snake_case-184"><span class="linenos">184</span></a> <span class="k">return</span> <span class="n">CAMEL_CASE_PATTERN</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="s2">"_"</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> </span></pre></div> @@ -949,28 +916,28 @@ </div> <a class="headerlink" href="#while_changing"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="while_changing-188"><a href="#while_changing-188"><span class="linenos">188</span></a><span class="k">def</span> <span class="nf">while_changing</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="n">func</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Expression</span><span class="p">],</span> <span class="n">E</span><span class="p">])</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="while_changing-189"><a href="#while_changing-189"><span class="linenos">189</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="while_changing-190"><a href="#while_changing-190"><span class="linenos">190</span></a><span class="sd"> Applies a transformation to a given expression until a fix point is reached.</span> -</span><span id="while_changing-191"><a href="#while_changing-191"><span class="linenos">191</span></a> -</span><span id="while_changing-192"><a href="#while_changing-192"><span class="linenos">192</span></a><span class="sd"> Args:</span> -</span><span id="while_changing-193"><a href="#while_changing-193"><span class="linenos">193</span></a><span class="sd"> expression: the expression to be transformed.</span> -</span><span id="while_changing-194"><a href="#while_changing-194"><span class="linenos">194</span></a><span class="sd"> func: the transformation to be applied.</span> -</span><span id="while_changing-195"><a href="#while_changing-195"><span class="linenos">195</span></a> -</span><span id="while_changing-196"><a href="#while_changing-196"><span class="linenos">196</span></a><span class="sd"> Returns:</span> -</span><span id="while_changing-197"><a href="#while_changing-197"><span class="linenos">197</span></a><span class="sd"> The transformed expression.</span> -</span><span id="while_changing-198"><a href="#while_changing-198"><span class="linenos">198</span></a><span class="sd"> """</span> -</span><span id="while_changing-199"><a href="#while_changing-199"><span class="linenos">199</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="while_changing-200"><a href="#while_changing-200"><span class="linenos">200</span></a> <span class="k">for</span> <span class="n">n</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span> <span class="ow">in</span> <span class="nb">reversed</span><span class="p">(</span><span class="nb">tuple</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">walk</span><span class="p">())):</span> -</span><span id="while_changing-201"><a href="#while_changing-201"><span class="linenos">201</span></a> <span class="n">n</span><span class="o">.</span><span class="n">_hash</span> <span class="o">=</span> <span class="nb">hash</span><span class="p">(</span><span class="n">n</span><span class="p">)</span> -</span><span id="while_changing-202"><a href="#while_changing-202"><span class="linenos">202</span></a> <span class="n">start</span> <span class="o">=</span> <span class="nb">hash</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="while_changing-203"><a href="#while_changing-203"><span class="linenos">203</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="while_changing-204"><a href="#while_changing-204"><span class="linenos">204</span></a> -</span><span id="while_changing-205"><a href="#while_changing-205"><span class="linenos">205</span></a> <span class="k">for</span> <span class="n">n</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">walk</span><span class="p">():</span> -</span><span id="while_changing-206"><a href="#while_changing-206"><span class="linenos">206</span></a> <span class="n">n</span><span class="o">.</span><span class="n">_hash</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="while_changing-207"><a href="#while_changing-207"><span class="linenos">207</span></a> <span class="k">if</span> <span class="n">start</span> <span class="o">==</span> <span class="nb">hash</span><span class="p">(</span><span class="n">expression</span><span class="p">):</span> -</span><span id="while_changing-208"><a href="#while_changing-208"><span class="linenos">208</span></a> <span class="k">break</span> -</span><span id="while_changing-209"><a href="#while_changing-209"><span class="linenos">209</span></a> <span class="k">return</span> <span class="n">expression</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="while_changing-187"><a href="#while_changing-187"><span class="linenos">187</span></a><span class="k">def</span> <span class="nf">while_changing</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">Expression</span><span class="p">,</span> <span class="n">func</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Expression</span><span class="p">],</span> <span class="n">E</span><span class="p">])</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="while_changing-188"><a href="#while_changing-188"><span class="linenos">188</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="while_changing-189"><a href="#while_changing-189"><span class="linenos">189</span></a><span class="sd"> Applies a transformation to a given expression until a fix point is reached.</span> +</span><span id="while_changing-190"><a href="#while_changing-190"><span class="linenos">190</span></a> +</span><span id="while_changing-191"><a href="#while_changing-191"><span class="linenos">191</span></a><span class="sd"> Args:</span> +</span><span id="while_changing-192"><a href="#while_changing-192"><span class="linenos">192</span></a><span class="sd"> expression: the expression to be transformed.</span> +</span><span id="while_changing-193"><a href="#while_changing-193"><span class="linenos">193</span></a><span class="sd"> func: the transformation to be applied.</span> +</span><span id="while_changing-194"><a href="#while_changing-194"><span class="linenos">194</span></a> +</span><span id="while_changing-195"><a href="#while_changing-195"><span class="linenos">195</span></a><span class="sd"> Returns:</span> +</span><span id="while_changing-196"><a href="#while_changing-196"><span class="linenos">196</span></a><span class="sd"> The transformed expression.</span> +</span><span id="while_changing-197"><a href="#while_changing-197"><span class="linenos">197</span></a><span class="sd"> """</span> +</span><span id="while_changing-198"><a href="#while_changing-198"><span class="linenos">198</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="while_changing-199"><a href="#while_changing-199"><span class="linenos">199</span></a> <span class="k">for</span> <span class="n">n</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span> <span class="ow">in</span> <span class="nb">reversed</span><span class="p">(</span><span class="nb">tuple</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">walk</span><span class="p">())):</span> +</span><span id="while_changing-200"><a href="#while_changing-200"><span class="linenos">200</span></a> <span class="n">n</span><span class="o">.</span><span class="n">_hash</span> <span class="o">=</span> <span class="nb">hash</span><span class="p">(</span><span class="n">n</span><span class="p">)</span> +</span><span id="while_changing-201"><a href="#while_changing-201"><span class="linenos">201</span></a> <span class="n">start</span> <span class="o">=</span> <span class="nb">hash</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="while_changing-202"><a href="#while_changing-202"><span class="linenos">202</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="while_changing-203"><a href="#while_changing-203"><span class="linenos">203</span></a> +</span><span id="while_changing-204"><a href="#while_changing-204"><span class="linenos">204</span></a> <span class="k">for</span> <span class="n">n</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">walk</span><span class="p">():</span> +</span><span id="while_changing-205"><a href="#while_changing-205"><span class="linenos">205</span></a> <span class="n">n</span><span class="o">.</span><span class="n">_hash</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="while_changing-206"><a href="#while_changing-206"><span class="linenos">206</span></a> <span class="k">if</span> <span class="n">start</span> <span class="o">==</span> <span class="nb">hash</span><span class="p">(</span><span class="n">expression</span><span class="p">):</span> +</span><span id="while_changing-207"><a href="#while_changing-207"><span class="linenos">207</span></a> <span class="k">break</span> +</span><span id="while_changing-208"><a href="#while_changing-208"><span class="linenos">208</span></a> <span class="k">return</span> <span class="n">expression</span> </span></pre></div> @@ -997,42 +964,44 @@ <div class="attr function"> <span class="def">def</span> - <span class="name">tsort</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">dag</span><span class="p">:</span> <span class="n">Dict</span><span class="p">[</span><span class="o">~</span><span class="n">T</span><span class="p">,</span> <span class="n">List</span><span class="p">[</span><span class="o">~</span><span class="n">T</span><span class="p">]]</span></span><span class="return-annotation">) -> <span class="n">List</span><span class="p">[</span><span class="o">~</span><span class="n">T</span><span class="p">]</span>:</span></span> + <span class="name">tsort</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">dag</span><span class="p">:</span> <span class="n">Dict</span><span class="p">[</span><span class="o">~</span><span class="n">T</span><span class="p">,</span> <span class="n">Set</span><span class="p">[</span><span class="o">~</span><span class="n">T</span><span class="p">]]</span></span><span class="return-annotation">) -> <span class="n">List</span><span class="p">[</span><span class="o">~</span><span class="n">T</span><span class="p">]</span>:</span></span> <label class="view-source-button" for="tsort-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#tsort"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="tsort-212"><a href="#tsort-212"><span class="linenos">212</span></a><span class="k">def</span> <span class="nf">tsort</span><span class="p">(</span><span class="n">dag</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">T</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">T</span><span class="p">]])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">T</span><span class="p">]:</span> -</span><span id="tsort-213"><a href="#tsort-213"><span class="linenos">213</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="tsort-214"><a href="#tsort-214"><span class="linenos">214</span></a><span class="sd"> Sorts a given directed acyclic graph in topological order.</span> -</span><span id="tsort-215"><a href="#tsort-215"><span class="linenos">215</span></a> -</span><span id="tsort-216"><a href="#tsort-216"><span class="linenos">216</span></a><span class="sd"> Args:</span> -</span><span id="tsort-217"><a href="#tsort-217"><span class="linenos">217</span></a><span class="sd"> dag: the graph to be sorted.</span> -</span><span id="tsort-218"><a href="#tsort-218"><span class="linenos">218</span></a> -</span><span id="tsort-219"><a href="#tsort-219"><span class="linenos">219</span></a><span class="sd"> Returns:</span> -</span><span id="tsort-220"><a href="#tsort-220"><span class="linenos">220</span></a><span class="sd"> A list that contains all of the graph's nodes in topological order.</span> -</span><span id="tsort-221"><a href="#tsort-221"><span class="linenos">221</span></a><span class="sd"> """</span> -</span><span id="tsort-222"><a href="#tsort-222"><span class="linenos">222</span></a> <span class="n">result</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="tsort-223"><a href="#tsort-223"><span class="linenos">223</span></a> -</span><span id="tsort-224"><a href="#tsort-224"><span class="linenos">224</span></a> <span class="k">def</span> <span class="nf">visit</span><span class="p">(</span><span class="n">node</span><span class="p">:</span> <span class="n">T</span><span class="p">,</span> <span class="n">visited</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="n">T</span><span class="p">])</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="tsort-225"><a href="#tsort-225"><span class="linenos">225</span></a> <span class="k">if</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">result</span><span class="p">:</span> -</span><span id="tsort-226"><a href="#tsort-226"><span class="linenos">226</span></a> <span class="k">return</span> -</span><span id="tsort-227"><a href="#tsort-227"><span class="linenos">227</span></a> <span class="k">if</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">visited</span><span class="p">:</span> -</span><span id="tsort-228"><a href="#tsort-228"><span class="linenos">228</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Cycle error"</span><span class="p">)</span> -</span><span id="tsort-229"><a href="#tsort-229"><span class="linenos">229</span></a> -</span><span id="tsort-230"><a href="#tsort-230"><span class="linenos">230</span></a> <span class="n">visited</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">node</span><span class="p">)</span> -</span><span id="tsort-231"><a href="#tsort-231"><span class="linenos">231</span></a> -</span><span id="tsort-232"><a href="#tsort-232"><span class="linenos">232</span></a> <span class="k">for</span> <span class="n">dep</span> <span class="ow">in</span> <span class="n">dag</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="p">[]):</span> -</span><span id="tsort-233"><a href="#tsort-233"><span class="linenos">233</span></a> <span class="n">visit</span><span class="p">(</span><span class="n">dep</span><span class="p">,</span> <span class="n">visited</span><span class="p">)</span> -</span><span id="tsort-234"><a href="#tsort-234"><span class="linenos">234</span></a> -</span><span id="tsort-235"><a href="#tsort-235"><span class="linenos">235</span></a> <span class="n">visited</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">node</span><span class="p">)</span> -</span><span id="tsort-236"><a href="#tsort-236"><span class="linenos">236</span></a> <span class="n">result</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">node</span><span class="p">)</span> -</span><span id="tsort-237"><a href="#tsort-237"><span class="linenos">237</span></a> -</span><span id="tsort-238"><a href="#tsort-238"><span class="linenos">238</span></a> <span class="k">for</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">dag</span><span class="p">:</span> -</span><span id="tsort-239"><a href="#tsort-239"><span class="linenos">239</span></a> <span class="n">visit</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="nb">set</span><span class="p">())</span> -</span><span id="tsort-240"><a href="#tsort-240"><span class="linenos">240</span></a> -</span><span id="tsort-241"><a href="#tsort-241"><span class="linenos">241</span></a> <span class="k">return</span> <span class="n">result</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="tsort-211"><a href="#tsort-211"><span class="linenos">211</span></a><span class="k">def</span> <span class="nf">tsort</span><span class="p">(</span><span class="n">dag</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">T</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="n">T</span><span class="p">]])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">T</span><span class="p">]:</span> +</span><span id="tsort-212"><a href="#tsort-212"><span class="linenos">212</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="tsort-213"><a href="#tsort-213"><span class="linenos">213</span></a><span class="sd"> Sorts a given directed acyclic graph in topological order.</span> +</span><span id="tsort-214"><a href="#tsort-214"><span class="linenos">214</span></a> +</span><span id="tsort-215"><a href="#tsort-215"><span class="linenos">215</span></a><span class="sd"> Args:</span> +</span><span id="tsort-216"><a href="#tsort-216"><span class="linenos">216</span></a><span class="sd"> dag: the graph to be sorted.</span> +</span><span id="tsort-217"><a href="#tsort-217"><span class="linenos">217</span></a> +</span><span id="tsort-218"><a href="#tsort-218"><span class="linenos">218</span></a><span class="sd"> Returns:</span> +</span><span id="tsort-219"><a href="#tsort-219"><span class="linenos">219</span></a><span class="sd"> A list that contains all of the graph's nodes in topological order.</span> +</span><span id="tsort-220"><a href="#tsort-220"><span class="linenos">220</span></a><span class="sd"> """</span> +</span><span id="tsort-221"><a href="#tsort-221"><span class="linenos">221</span></a> <span class="n">result</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="tsort-222"><a href="#tsort-222"><span class="linenos">222</span></a> +</span><span id="tsort-223"><a href="#tsort-223"><span class="linenos">223</span></a> <span class="k">for</span> <span class="n">node</span><span class="p">,</span> <span class="n">deps</span> <span class="ow">in</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">dag</span><span class="o">.</span><span class="n">items</span><span class="p">()):</span> +</span><span id="tsort-224"><a href="#tsort-224"><span class="linenos">224</span></a> <span class="k">for</span> <span class="n">dep</span> <span class="ow">in</span> <span class="n">deps</span><span class="p">:</span> +</span><span id="tsort-225"><a href="#tsort-225"><span class="linenos">225</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">dep</span> <span class="ow">in</span> <span class="n">dag</span><span class="p">:</span> +</span><span id="tsort-226"><a href="#tsort-226"><span class="linenos">226</span></a> <span class="n">dag</span><span class="p">[</span><span class="n">dep</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> +</span><span id="tsort-227"><a href="#tsort-227"><span class="linenos">227</span></a> +</span><span id="tsort-228"><a href="#tsort-228"><span class="linenos">228</span></a> <span class="k">while</span> <span class="n">dag</span><span class="p">:</span> +</span><span id="tsort-229"><a href="#tsort-229"><span class="linenos">229</span></a> <span class="n">current</span> <span class="o">=</span> <span class="p">{</span><span class="n">node</span> <span class="k">for</span> <span class="n">node</span><span class="p">,</span> <span class="n">deps</span> <span class="ow">in</span> <span class="n">dag</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">deps</span><span class="p">}</span> +</span><span id="tsort-230"><a href="#tsort-230"><span class="linenos">230</span></a> +</span><span id="tsort-231"><a href="#tsort-231"><span class="linenos">231</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">current</span><span class="p">:</span> +</span><span id="tsort-232"><a href="#tsort-232"><span class="linenos">232</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Cycle error"</span><span class="p">)</span> +</span><span id="tsort-233"><a href="#tsort-233"><span class="linenos">233</span></a> +</span><span id="tsort-234"><a href="#tsort-234"><span class="linenos">234</span></a> <span class="k">for</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">current</span><span class="p">:</span> +</span><span id="tsort-235"><a href="#tsort-235"><span class="linenos">235</span></a> <span class="n">dag</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">node</span><span class="p">)</span> +</span><span id="tsort-236"><a href="#tsort-236"><span class="linenos">236</span></a> +</span><span id="tsort-237"><a href="#tsort-237"><span class="linenos">237</span></a> <span class="k">for</span> <span class="n">deps</span> <span class="ow">in</span> <span class="n">dag</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> +</span><span id="tsort-238"><a href="#tsort-238"><span class="linenos">238</span></a> <span class="n">deps</span> <span class="o">-=</span> <span class="n">current</span> +</span><span id="tsort-239"><a href="#tsort-239"><span class="linenos">239</span></a> +</span><span id="tsort-240"><a href="#tsort-240"><span class="linenos">240</span></a> <span class="n">result</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</span><span class="n">current</span><span class="p">))</span> <span class="c1"># type: ignore</span> +</span><span id="tsort-241"><a href="#tsort-241"><span class="linenos">241</span></a> +</span><span id="tsort-242"><a href="#tsort-242"><span class="linenos">242</span></a> <span class="k">return</span> <span class="n">result</span> </span></pre></div> @@ -1064,17 +1033,17 @@ </div> <a class="headerlink" href="#open_file"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="open_file-244"><a href="#open_file-244"><span class="linenos">244</span></a><span class="k">def</span> <span class="nf">open_file</span><span class="p">(</span><span class="n">file_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">TextIO</span><span class="p">:</span> -</span><span id="open_file-245"><a href="#open_file-245"><span class="linenos">245</span></a><span class="w"> </span><span class="sd">"""Open a file that may be compressed as gzip and return it in universal newline mode."""</span> -</span><span id="open_file-246"><a href="#open_file-246"><span class="linenos">246</span></a> <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">file_name</span><span class="p">,</span> <span class="s2">"rb"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> -</span><span id="open_file-247"><a href="#open_file-247"><span class="linenos">247</span></a> <span class="n">gzipped</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="o">==</span> <span class="sa">b</span><span class="s2">"</span><span class="se">\x1f\x8b</span><span class="s2">"</span> -</span><span id="open_file-248"><a href="#open_file-248"><span class="linenos">248</span></a> -</span><span id="open_file-249"><a href="#open_file-249"><span class="linenos">249</span></a> <span class="k">if</span> <span class="n">gzipped</span><span class="p">:</span> -</span><span id="open_file-250"><a href="#open_file-250"><span class="linenos">250</span></a> <span class="kn">import</span> <span class="nn">gzip</span> -</span><span id="open_file-251"><a href="#open_file-251"><span class="linenos">251</span></a> -</span><span id="open_file-252"><a href="#open_file-252"><span class="linenos">252</span></a> <span class="k">return</span> <span class="n">gzip</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">file_name</span><span class="p">,</span> <span class="s2">"rt"</span><span class="p">,</span> <span class="n">newline</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="open_file-253"><a href="#open_file-253"><span class="linenos">253</span></a> -</span><span id="open_file-254"><a href="#open_file-254"><span class="linenos">254</span></a> <span class="k">return</span> <span class="nb">open</span><span class="p">(</span><span class="n">file_name</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">,</span> <span class="n">newline</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="open_file-245"><a href="#open_file-245"><span class="linenos">245</span></a><span class="k">def</span> <span class="nf">open_file</span><span class="p">(</span><span class="n">file_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">TextIO</span><span class="p">:</span> +</span><span id="open_file-246"><a href="#open_file-246"><span class="linenos">246</span></a><span class="w"> </span><span class="sd">"""Open a file that may be compressed as gzip and return it in universal newline mode."""</span> +</span><span id="open_file-247"><a href="#open_file-247"><span class="linenos">247</span></a> <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">file_name</span><span class="p">,</span> <span class="s2">"rb"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> +</span><span id="open_file-248"><a href="#open_file-248"><span class="linenos">248</span></a> <span class="n">gzipped</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="o">==</span> <span class="sa">b</span><span class="s2">"</span><span class="se">\x1f\x8b</span><span class="s2">"</span> +</span><span id="open_file-249"><a href="#open_file-249"><span class="linenos">249</span></a> +</span><span id="open_file-250"><a href="#open_file-250"><span class="linenos">250</span></a> <span class="k">if</span> <span class="n">gzipped</span><span class="p">:</span> +</span><span id="open_file-251"><a href="#open_file-251"><span class="linenos">251</span></a> <span class="kn">import</span> <span class="nn">gzip</span> +</span><span id="open_file-252"><a href="#open_file-252"><span class="linenos">252</span></a> +</span><span id="open_file-253"><a href="#open_file-253"><span class="linenos">253</span></a> <span class="k">return</span> <span class="n">gzip</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">file_name</span><span class="p">,</span> <span class="s2">"rt"</span><span class="p">,</span> <span class="n">newline</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> +</span><span id="open_file-254"><a href="#open_file-254"><span class="linenos">254</span></a> +</span><span id="open_file-255"><a href="#open_file-255"><span class="linenos">255</span></a> <span class="k">return</span> <span class="nb">open</span><span class="p">(</span><span class="n">file_name</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">,</span> <span class="n">newline</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> </span></pre></div> @@ -1095,32 +1064,32 @@ </div> <a class="headerlink" href="#csv_reader"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="csv_reader-257"><a href="#csv_reader-257"><span class="linenos">257</span></a><span class="nd">@contextmanager</span> -</span><span id="csv_reader-258"><a href="#csv_reader-258"><span class="linenos">258</span></a><span class="k">def</span> <span class="nf">csv_reader</span><span class="p">(</span><span class="n">read_csv</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ReadCSV</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">:</span> -</span><span id="csv_reader-259"><a href="#csv_reader-259"><span class="linenos">259</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="csv_reader-260"><a href="#csv_reader-260"><span class="linenos">260</span></a><span class="sd"> Returns a csv reader given the expression `READ_CSV(name, ['delimiter', '|', ...])`.</span> -</span><span id="csv_reader-261"><a href="#csv_reader-261"><span class="linenos">261</span></a> -</span><span id="csv_reader-262"><a href="#csv_reader-262"><span class="linenos">262</span></a><span class="sd"> Args:</span> -</span><span id="csv_reader-263"><a href="#csv_reader-263"><span class="linenos">263</span></a><span class="sd"> read_csv: a `ReadCSV` function call</span> -</span><span id="csv_reader-264"><a href="#csv_reader-264"><span class="linenos">264</span></a> -</span><span id="csv_reader-265"><a href="#csv_reader-265"><span class="linenos">265</span></a><span class="sd"> Yields:</span> -</span><span id="csv_reader-266"><a href="#csv_reader-266"><span class="linenos">266</span></a><span class="sd"> A python csv reader.</span> -</span><span id="csv_reader-267"><a href="#csv_reader-267"><span class="linenos">267</span></a><span class="sd"> """</span> -</span><span id="csv_reader-268"><a href="#csv_reader-268"><span class="linenos">268</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">read_csv</span><span class="o">.</span><span class="n">expressions</span> -</span><span id="csv_reader-269"><a href="#csv_reader-269"><span class="linenos">269</span></a> <span class="n">file</span> <span class="o">=</span> <span class="n">open_file</span><span class="p">(</span><span class="n">read_csv</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> -</span><span id="csv_reader-270"><a href="#csv_reader-270"><span class="linenos">270</span></a> -</span><span id="csv_reader-271"><a href="#csv_reader-271"><span class="linenos">271</span></a> <span class="n">delimiter</span> <span class="o">=</span> <span class="s2">","</span> -</span><span id="csv_reader-272"><a href="#csv_reader-272"><span class="linenos">272</span></a> <span class="n">args</span> <span class="o">=</span> <span class="nb">iter</span><span class="p">(</span><span class="n">arg</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> -</span><span id="csv_reader-273"><a href="#csv_reader-273"><span class="linenos">273</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="n">args</span><span class="p">):</span> -</span><span id="csv_reader-274"><a href="#csv_reader-274"><span class="linenos">274</span></a> <span class="k">if</span> <span class="n">k</span> <span class="o">==</span> <span class="s2">"delimiter"</span><span class="p">:</span> -</span><span id="csv_reader-275"><a href="#csv_reader-275"><span class="linenos">275</span></a> <span class="n">delimiter</span> <span class="o">=</span> <span class="n">v</span> -</span><span id="csv_reader-276"><a href="#csv_reader-276"><span class="linenos">276</span></a> -</span><span id="csv_reader-277"><a href="#csv_reader-277"><span class="linenos">277</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="csv_reader-278"><a href="#csv_reader-278"><span class="linenos">278</span></a> <span class="kn">import</span> <span class="nn">csv</span> <span class="k">as</span> <span class="nn">csv_</span> -</span><span id="csv_reader-279"><a href="#csv_reader-279"><span class="linenos">279</span></a> -</span><span id="csv_reader-280"><a href="#csv_reader-280"><span class="linenos">280</span></a> <span class="k">yield</span> <span class="n">csv_</span><span class="o">.</span><span class="n">reader</span><span class="p">(</span><span class="n">file</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="n">delimiter</span><span class="p">)</span> -</span><span id="csv_reader-281"><a href="#csv_reader-281"><span class="linenos">281</span></a> <span class="k">finally</span><span class="p">:</span> -</span><span id="csv_reader-282"><a href="#csv_reader-282"><span class="linenos">282</span></a> <span class="n">file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="csv_reader-258"><a href="#csv_reader-258"><span class="linenos">258</span></a><span class="nd">@contextmanager</span> +</span><span id="csv_reader-259"><a href="#csv_reader-259"><span class="linenos">259</span></a><span class="k">def</span> <span class="nf">csv_reader</span><span class="p">(</span><span class="n">read_csv</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">ReadCSV</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">:</span> +</span><span id="csv_reader-260"><a href="#csv_reader-260"><span class="linenos">260</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="csv_reader-261"><a href="#csv_reader-261"><span class="linenos">261</span></a><span class="sd"> Returns a csv reader given the expression `READ_CSV(name, ['delimiter', '|', ...])`.</span> +</span><span id="csv_reader-262"><a href="#csv_reader-262"><span class="linenos">262</span></a> +</span><span id="csv_reader-263"><a href="#csv_reader-263"><span class="linenos">263</span></a><span class="sd"> Args:</span> +</span><span id="csv_reader-264"><a href="#csv_reader-264"><span class="linenos">264</span></a><span class="sd"> read_csv: a `ReadCSV` function call</span> +</span><span id="csv_reader-265"><a href="#csv_reader-265"><span class="linenos">265</span></a> +</span><span id="csv_reader-266"><a href="#csv_reader-266"><span class="linenos">266</span></a><span class="sd"> Yields:</span> +</span><span id="csv_reader-267"><a href="#csv_reader-267"><span class="linenos">267</span></a><span class="sd"> A python csv reader.</span> +</span><span id="csv_reader-268"><a href="#csv_reader-268"><span class="linenos">268</span></a><span class="sd"> """</span> +</span><span id="csv_reader-269"><a href="#csv_reader-269"><span class="linenos">269</span></a> <span class="n">args</span> <span class="o">=</span> <span class="n">read_csv</span><span class="o">.</span><span class="n">expressions</span> +</span><span id="csv_reader-270"><a href="#csv_reader-270"><span class="linenos">270</span></a> <span class="n">file</span> <span class="o">=</span> <span class="n">open_file</span><span class="p">(</span><span class="n">read_csv</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> +</span><span id="csv_reader-271"><a href="#csv_reader-271"><span class="linenos">271</span></a> +</span><span id="csv_reader-272"><a href="#csv_reader-272"><span class="linenos">272</span></a> <span class="n">delimiter</span> <span class="o">=</span> <span class="s2">","</span> +</span><span id="csv_reader-273"><a href="#csv_reader-273"><span class="linenos">273</span></a> <span class="n">args</span> <span class="o">=</span> <span class="nb">iter</span><span class="p">(</span><span class="n">arg</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> +</span><span id="csv_reader-274"><a href="#csv_reader-274"><span class="linenos">274</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="n">args</span><span class="p">):</span> +</span><span id="csv_reader-275"><a href="#csv_reader-275"><span class="linenos">275</span></a> <span class="k">if</span> <span class="n">k</span> <span class="o">==</span> <span class="s2">"delimiter"</span><span class="p">:</span> +</span><span id="csv_reader-276"><a href="#csv_reader-276"><span class="linenos">276</span></a> <span class="n">delimiter</span> <span class="o">=</span> <span class="n">v</span> +</span><span id="csv_reader-277"><a href="#csv_reader-277"><span class="linenos">277</span></a> +</span><span id="csv_reader-278"><a href="#csv_reader-278"><span class="linenos">278</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="csv_reader-279"><a href="#csv_reader-279"><span class="linenos">279</span></a> <span class="kn">import</span> <span class="nn">csv</span> <span class="k">as</span> <span class="nn">csv_</span> +</span><span id="csv_reader-280"><a href="#csv_reader-280"><span class="linenos">280</span></a> +</span><span id="csv_reader-281"><a href="#csv_reader-281"><span class="linenos">281</span></a> <span class="k">yield</span> <span class="n">csv_</span><span class="o">.</span><span class="n">reader</span><span class="p">(</span><span class="n">file</span><span class="p">,</span> <span class="n">delimiter</span><span class="o">=</span><span class="n">delimiter</span><span class="p">)</span> +</span><span id="csv_reader-282"><a href="#csv_reader-282"><span class="linenos">282</span></a> <span class="k">finally</span><span class="p">:</span> +</span><span id="csv_reader-283"><a href="#csv_reader-283"><span class="linenos">283</span></a> <span class="n">file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span> </span></pre></div> @@ -1152,27 +1121,27 @@ </div> <a class="headerlink" href="#find_new_name"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="find_new_name-285"><a href="#find_new_name-285"><span class="linenos">285</span></a><span class="k">def</span> <span class="nf">find_new_name</span><span class="p">(</span><span class="n">taken</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">base</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="find_new_name-286"><a href="#find_new_name-286"><span class="linenos">286</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="find_new_name-287"><a href="#find_new_name-287"><span class="linenos">287</span></a><span class="sd"> Searches for a new name.</span> -</span><span id="find_new_name-288"><a href="#find_new_name-288"><span class="linenos">288</span></a> -</span><span id="find_new_name-289"><a href="#find_new_name-289"><span class="linenos">289</span></a><span class="sd"> Args:</span> -</span><span id="find_new_name-290"><a href="#find_new_name-290"><span class="linenos">290</span></a><span class="sd"> taken: a collection of taken names.</span> -</span><span id="find_new_name-291"><a href="#find_new_name-291"><span class="linenos">291</span></a><span class="sd"> base: base name to alter.</span> -</span><span id="find_new_name-292"><a href="#find_new_name-292"><span class="linenos">292</span></a> -</span><span id="find_new_name-293"><a href="#find_new_name-293"><span class="linenos">293</span></a><span class="sd"> Returns:</span> -</span><span id="find_new_name-294"><a href="#find_new_name-294"><span class="linenos">294</span></a><span class="sd"> The new, available name.</span> -</span><span id="find_new_name-295"><a href="#find_new_name-295"><span class="linenos">295</span></a><span class="sd"> """</span> -</span><span id="find_new_name-296"><a href="#find_new_name-296"><span class="linenos">296</span></a> <span class="k">if</span> <span class="n">base</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">taken</span><span class="p">:</span> -</span><span id="find_new_name-297"><a href="#find_new_name-297"><span class="linenos">297</span></a> <span class="k">return</span> <span class="n">base</span> -</span><span id="find_new_name-298"><a href="#find_new_name-298"><span class="linenos">298</span></a> -</span><span id="find_new_name-299"><a href="#find_new_name-299"><span class="linenos">299</span></a> <span class="n">i</span> <span class="o">=</span> <span class="mi">2</span> -</span><span id="find_new_name-300"><a href="#find_new_name-300"><span class="linenos">300</span></a> <span class="n">new</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">base</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">i</span><span class="si">}</span><span class="s2">"</span> -</span><span id="find_new_name-301"><a href="#find_new_name-301"><span class="linenos">301</span></a> <span class="k">while</span> <span class="n">new</span> <span class="ow">in</span> <span class="n">taken</span><span class="p">:</span> -</span><span id="find_new_name-302"><a href="#find_new_name-302"><span class="linenos">302</span></a> <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="find_new_name-303"><a href="#find_new_name-303"><span class="linenos">303</span></a> <span class="n">new</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">base</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">i</span><span class="si">}</span><span class="s2">"</span> -</span><span id="find_new_name-304"><a href="#find_new_name-304"><span class="linenos">304</span></a> -</span><span id="find_new_name-305"><a href="#find_new_name-305"><span class="linenos">305</span></a> <span class="k">return</span> <span class="n">new</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="find_new_name-286"><a href="#find_new_name-286"><span class="linenos">286</span></a><span class="k">def</span> <span class="nf">find_new_name</span><span class="p">(</span><span class="n">taken</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">base</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="find_new_name-287"><a href="#find_new_name-287"><span class="linenos">287</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="find_new_name-288"><a href="#find_new_name-288"><span class="linenos">288</span></a><span class="sd"> Searches for a new name.</span> +</span><span id="find_new_name-289"><a href="#find_new_name-289"><span class="linenos">289</span></a> +</span><span id="find_new_name-290"><a href="#find_new_name-290"><span class="linenos">290</span></a><span class="sd"> Args:</span> +</span><span id="find_new_name-291"><a href="#find_new_name-291"><span class="linenos">291</span></a><span class="sd"> taken: a collection of taken names.</span> +</span><span id="find_new_name-292"><a href="#find_new_name-292"><span class="linenos">292</span></a><span class="sd"> base: base name to alter.</span> +</span><span id="find_new_name-293"><a href="#find_new_name-293"><span class="linenos">293</span></a> +</span><span id="find_new_name-294"><a href="#find_new_name-294"><span class="linenos">294</span></a><span class="sd"> Returns:</span> +</span><span id="find_new_name-295"><a href="#find_new_name-295"><span class="linenos">295</span></a><span class="sd"> The new, available name.</span> +</span><span id="find_new_name-296"><a href="#find_new_name-296"><span class="linenos">296</span></a><span class="sd"> """</span> +</span><span id="find_new_name-297"><a href="#find_new_name-297"><span class="linenos">297</span></a> <span class="k">if</span> <span class="n">base</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">taken</span><span class="p">:</span> +</span><span id="find_new_name-298"><a href="#find_new_name-298"><span class="linenos">298</span></a> <span class="k">return</span> <span class="n">base</span> +</span><span id="find_new_name-299"><a href="#find_new_name-299"><span class="linenos">299</span></a> +</span><span id="find_new_name-300"><a href="#find_new_name-300"><span class="linenos">300</span></a> <span class="n">i</span> <span class="o">=</span> <span class="mi">2</span> +</span><span id="find_new_name-301"><a href="#find_new_name-301"><span class="linenos">301</span></a> <span class="n">new</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">base</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">i</span><span class="si">}</span><span class="s2">"</span> +</span><span id="find_new_name-302"><a href="#find_new_name-302"><span class="linenos">302</span></a> <span class="k">while</span> <span class="n">new</span> <span class="ow">in</span> <span class="n">taken</span><span class="p">:</span> +</span><span id="find_new_name-303"><a href="#find_new_name-303"><span class="linenos">303</span></a> <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="find_new_name-304"><a href="#find_new_name-304"><span class="linenos">304</span></a> <span class="n">new</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">base</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">i</span><span class="si">}</span><span class="s2">"</span> +</span><span id="find_new_name-305"><a href="#find_new_name-305"><span class="linenos">305</span></a> +</span><span id="find_new_name-306"><a href="#find_new_name-306"><span class="linenos">306</span></a> <span class="k">return</span> <span class="n">new</span> </span></pre></div> @@ -1205,10 +1174,10 @@ </div> <a class="headerlink" href="#name_sequence"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="name_sequence-308"><a href="#name_sequence-308"><span class="linenos">308</span></a><span class="k">def</span> <span class="nf">name_sequence</span><span class="p">(</span><span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[],</span> <span class="nb">str</span><span class="p">]:</span> -</span><span id="name_sequence-309"><a href="#name_sequence-309"><span class="linenos">309</span></a><span class="w"> </span><span class="sd">"""Returns a name generator given a prefix (e.g. a0, a1, a2, ... if the prefix is "a")."""</span> -</span><span id="name_sequence-310"><a href="#name_sequence-310"><span class="linenos">310</span></a> <span class="n">sequence</span> <span class="o">=</span> <span class="n">count</span><span class="p">()</span> -</span><span id="name_sequence-311"><a href="#name_sequence-311"><span class="linenos">311</span></a> <span class="k">return</span> <span class="k">lambda</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="nb">next</span><span class="p">(</span><span class="n">sequence</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="name_sequence-309"><a href="#name_sequence-309"><span class="linenos">309</span></a><span class="k">def</span> <span class="nf">name_sequence</span><span class="p">(</span><span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[],</span> <span class="nb">str</span><span class="p">]:</span> +</span><span id="name_sequence-310"><a href="#name_sequence-310"><span class="linenos">310</span></a><span class="w"> </span><span class="sd">"""Returns a name generator given a prefix (e.g. a0, a1, a2, ... if the prefix is "a")."""</span> +</span><span id="name_sequence-311"><a href="#name_sequence-311"><span class="linenos">311</span></a> <span class="n">sequence</span> <span class="o">=</span> <span class="n">count</span><span class="p">()</span> +</span><span id="name_sequence-312"><a href="#name_sequence-312"><span class="linenos">312</span></a> <span class="k">return</span> <span class="k">lambda</span><span class="p">:</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="nb">next</span><span class="p">(</span><span class="n">sequence</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -1228,12 +1197,12 @@ </div> <a class="headerlink" href="#object_to_dict"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="object_to_dict-314"><a href="#object_to_dict-314"><span class="linenos">314</span></a><span class="k">def</span> <span class="nf">object_to_dict</span><span class="p">(</span><span class="n">obj</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">:</span> -</span><span id="object_to_dict-315"><a href="#object_to_dict-315"><span class="linenos">315</span></a><span class="w"> </span><span class="sd">"""Returns a dictionary created from an object's attributes."""</span> -</span><span id="object_to_dict-316"><a href="#object_to_dict-316"><span class="linenos">316</span></a> <span class="k">return</span> <span class="p">{</span> -</span><span id="object_to_dict-317"><a href="#object_to_dict-317"><span class="linenos">317</span></a> <span class="o">**</span><span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="n">v</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="s2">"copy"</span><span class="p">)</span> <span class="k">else</span> <span class="n">copy</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">vars</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span><span class="o">.</span><span class="n">items</span><span class="p">()},</span> -</span><span id="object_to_dict-318"><a href="#object_to_dict-318"><span class="linenos">318</span></a> <span class="o">**</span><span class="n">kwargs</span><span class="p">,</span> -</span><span id="object_to_dict-319"><a href="#object_to_dict-319"><span class="linenos">319</span></a> <span class="p">}</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="object_to_dict-315"><a href="#object_to_dict-315"><span class="linenos">315</span></a><span class="k">def</span> <span class="nf">object_to_dict</span><span class="p">(</span><span class="n">obj</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">:</span> +</span><span id="object_to_dict-316"><a href="#object_to_dict-316"><span class="linenos">316</span></a><span class="w"> </span><span class="sd">"""Returns a dictionary created from an object's attributes."""</span> +</span><span id="object_to_dict-317"><a href="#object_to_dict-317"><span class="linenos">317</span></a> <span class="k">return</span> <span class="p">{</span> +</span><span id="object_to_dict-318"><a href="#object_to_dict-318"><span class="linenos">318</span></a> <span class="o">**</span><span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="n">v</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="s2">"copy"</span><span class="p">)</span> <span class="k">else</span> <span class="n">copy</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">vars</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span><span class="o">.</span><span class="n">items</span><span class="p">()},</span> +</span><span id="object_to_dict-319"><a href="#object_to_dict-319"><span class="linenos">319</span></a> <span class="o">**</span><span class="n">kwargs</span><span class="p">,</span> +</span><span id="object_to_dict-320"><a href="#object_to_dict-320"><span class="linenos">320</span></a> <span class="p">}</span> </span></pre></div> @@ -1253,33 +1222,33 @@ </div> <a class="headerlink" href="#split_num_words"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="split_num_words-322"><a href="#split_num_words-322"><span class="linenos">322</span></a><span class="k">def</span> <span class="nf">split_num_words</span><span class="p">(</span> -</span><span id="split_num_words-323"><a href="#split_num_words-323"><span class="linenos">323</span></a> <span class="n">value</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">min_num_words</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> <span class="n">fill_from_start</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="split_num_words-324"><a href="#split_num_words-324"><span class="linenos">324</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]]:</span> -</span><span id="split_num_words-325"><a href="#split_num_words-325"><span class="linenos">325</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="split_num_words-326"><a href="#split_num_words-326"><span class="linenos">326</span></a><span class="sd"> Perform a split on a value and return N words as a result with `None` used for words that don't exist.</span> -</span><span id="split_num_words-327"><a href="#split_num_words-327"><span class="linenos">327</span></a> -</span><span id="split_num_words-328"><a href="#split_num_words-328"><span class="linenos">328</span></a><span class="sd"> Args:</span> -</span><span id="split_num_words-329"><a href="#split_num_words-329"><span class="linenos">329</span></a><span class="sd"> value: the value to be split.</span> -</span><span id="split_num_words-330"><a href="#split_num_words-330"><span class="linenos">330</span></a><span class="sd"> sep: the value to use to split on.</span> -</span><span id="split_num_words-331"><a href="#split_num_words-331"><span class="linenos">331</span></a><span class="sd"> min_num_words: the minimum number of words that are going to be in the result.</span> -</span><span id="split_num_words-332"><a href="#split_num_words-332"><span class="linenos">332</span></a><span class="sd"> fill_from_start: indicates that if `None` values should be inserted at the start or end of the list.</span> -</span><span id="split_num_words-333"><a href="#split_num_words-333"><span class="linenos">333</span></a> -</span><span id="split_num_words-334"><a href="#split_num_words-334"><span class="linenos">334</span></a><span class="sd"> Examples:</span> -</span><span id="split_num_words-335"><a href="#split_num_words-335"><span class="linenos">335</span></a><span class="sd"> >>> split_num_words("db.table", ".", 3)</span> -</span><span id="split_num_words-336"><a href="#split_num_words-336"><span class="linenos">336</span></a><span class="sd"> [None, 'db', 'table']</span> -</span><span id="split_num_words-337"><a href="#split_num_words-337"><span class="linenos">337</span></a><span class="sd"> >>> split_num_words("db.table", ".", 3, fill_from_start=False)</span> -</span><span id="split_num_words-338"><a href="#split_num_words-338"><span class="linenos">338</span></a><span class="sd"> ['db', 'table', None]</span> -</span><span id="split_num_words-339"><a href="#split_num_words-339"><span class="linenos">339</span></a><span class="sd"> >>> split_num_words("db.table", ".", 1)</span> -</span><span id="split_num_words-340"><a href="#split_num_words-340"><span class="linenos">340</span></a><span class="sd"> ['db', 'table']</span> -</span><span id="split_num_words-341"><a href="#split_num_words-341"><span class="linenos">341</span></a> -</span><span id="split_num_words-342"><a href="#split_num_words-342"><span class="linenos">342</span></a><span class="sd"> Returns:</span> -</span><span id="split_num_words-343"><a href="#split_num_words-343"><span class="linenos">343</span></a><span class="sd"> The list of words returned by `split`, possibly augmented by a number of `None` values.</span> -</span><span id="split_num_words-344"><a href="#split_num_words-344"><span class="linenos">344</span></a><span class="sd"> """</span> -</span><span id="split_num_words-345"><a href="#split_num_words-345"><span class="linenos">345</span></a> <span class="n">words</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span> -</span><span id="split_num_words-346"><a href="#split_num_words-346"><span class="linenos">346</span></a> <span class="k">if</span> <span class="n">fill_from_start</span><span class="p">:</span> -</span><span id="split_num_words-347"><a href="#split_num_words-347"><span class="linenos">347</span></a> <span class="k">return</span> <span class="p">[</span><span class="kc">None</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="n">min_num_words</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">words</span><span class="p">))</span> <span class="o">+</span> <span class="n">words</span> -</span><span id="split_num_words-348"><a href="#split_num_words-348"><span class="linenos">348</span></a> <span class="k">return</span> <span class="n">words</span> <span class="o">+</span> <span class="p">[</span><span class="kc">None</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="n">min_num_words</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">words</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="split_num_words-323"><a href="#split_num_words-323"><span class="linenos">323</span></a><span class="k">def</span> <span class="nf">split_num_words</span><span class="p">(</span> +</span><span id="split_num_words-324"><a href="#split_num_words-324"><span class="linenos">324</span></a> <span class="n">value</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">min_num_words</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> <span class="n">fill_from_start</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="split_num_words-325"><a href="#split_num_words-325"><span class="linenos">325</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]]:</span> +</span><span id="split_num_words-326"><a href="#split_num_words-326"><span class="linenos">326</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="split_num_words-327"><a href="#split_num_words-327"><span class="linenos">327</span></a><span class="sd"> Perform a split on a value and return N words as a result with `None` used for words that don't exist.</span> +</span><span id="split_num_words-328"><a href="#split_num_words-328"><span class="linenos">328</span></a> +</span><span id="split_num_words-329"><a href="#split_num_words-329"><span class="linenos">329</span></a><span class="sd"> Args:</span> +</span><span id="split_num_words-330"><a href="#split_num_words-330"><span class="linenos">330</span></a><span class="sd"> value: the value to be split.</span> +</span><span id="split_num_words-331"><a href="#split_num_words-331"><span class="linenos">331</span></a><span class="sd"> sep: the value to use to split on.</span> +</span><span id="split_num_words-332"><a href="#split_num_words-332"><span class="linenos">332</span></a><span class="sd"> min_num_words: the minimum number of words that are going to be in the result.</span> +</span><span id="split_num_words-333"><a href="#split_num_words-333"><span class="linenos">333</span></a><span class="sd"> fill_from_start: indicates that if `None` values should be inserted at the start or end of the list.</span> +</span><span id="split_num_words-334"><a href="#split_num_words-334"><span class="linenos">334</span></a> +</span><span id="split_num_words-335"><a href="#split_num_words-335"><span class="linenos">335</span></a><span class="sd"> Examples:</span> +</span><span id="split_num_words-336"><a href="#split_num_words-336"><span class="linenos">336</span></a><span class="sd"> >>> split_num_words("db.table", ".", 3)</span> +</span><span id="split_num_words-337"><a href="#split_num_words-337"><span class="linenos">337</span></a><span class="sd"> [None, 'db', 'table']</span> +</span><span id="split_num_words-338"><a href="#split_num_words-338"><span class="linenos">338</span></a><span class="sd"> >>> split_num_words("db.table", ".", 3, fill_from_start=False)</span> +</span><span id="split_num_words-339"><a href="#split_num_words-339"><span class="linenos">339</span></a><span class="sd"> ['db', 'table', None]</span> +</span><span id="split_num_words-340"><a href="#split_num_words-340"><span class="linenos">340</span></a><span class="sd"> >>> split_num_words("db.table", ".", 1)</span> +</span><span id="split_num_words-341"><a href="#split_num_words-341"><span class="linenos">341</span></a><span class="sd"> ['db', 'table']</span> +</span><span id="split_num_words-342"><a href="#split_num_words-342"><span class="linenos">342</span></a> +</span><span id="split_num_words-343"><a href="#split_num_words-343"><span class="linenos">343</span></a><span class="sd"> Returns:</span> +</span><span id="split_num_words-344"><a href="#split_num_words-344"><span class="linenos">344</span></a><span class="sd"> The list of words returned by `split`, possibly augmented by a number of `None` values.</span> +</span><span id="split_num_words-345"><a href="#split_num_words-345"><span class="linenos">345</span></a><span class="sd"> """</span> +</span><span id="split_num_words-346"><a href="#split_num_words-346"><span class="linenos">346</span></a> <span class="n">words</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">sep</span><span class="p">)</span> +</span><span id="split_num_words-347"><a href="#split_num_words-347"><span class="linenos">347</span></a> <span class="k">if</span> <span class="n">fill_from_start</span><span class="p">:</span> +</span><span id="split_num_words-348"><a href="#split_num_words-348"><span class="linenos">348</span></a> <span class="k">return</span> <span class="p">[</span><span class="kc">None</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="n">min_num_words</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">words</span><span class="p">))</span> <span class="o">+</span> <span class="n">words</span> +</span><span id="split_num_words-349"><a href="#split_num_words-349"><span class="linenos">349</span></a> <span class="k">return</span> <span class="n">words</span> <span class="o">+</span> <span class="p">[</span><span class="kc">None</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="n">min_num_words</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">words</span><span class="p">))</span> </span></pre></div> @@ -1328,23 +1297,23 @@ </div> <a class="headerlink" href="#is_iterable"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="is_iterable-351"><a href="#is_iterable-351"><span class="linenos">351</span></a><span class="k">def</span> <span class="nf">is_iterable</span><span class="p">(</span><span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="is_iterable-352"><a href="#is_iterable-352"><span class="linenos">352</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="is_iterable-353"><a href="#is_iterable-353"><span class="linenos">353</span></a><span class="sd"> Checks if the value is an iterable, excluding the types `str` and `bytes`.</span> -</span><span id="is_iterable-354"><a href="#is_iterable-354"><span class="linenos">354</span></a> -</span><span id="is_iterable-355"><a href="#is_iterable-355"><span class="linenos">355</span></a><span class="sd"> Examples:</span> -</span><span id="is_iterable-356"><a href="#is_iterable-356"><span class="linenos">356</span></a><span class="sd"> >>> is_iterable([1,2])</span> -</span><span id="is_iterable-357"><a href="#is_iterable-357"><span class="linenos">357</span></a><span class="sd"> True</span> -</span><span id="is_iterable-358"><a href="#is_iterable-358"><span class="linenos">358</span></a><span class="sd"> >>> is_iterable("test")</span> -</span><span id="is_iterable-359"><a href="#is_iterable-359"><span class="linenos">359</span></a><span class="sd"> False</span> -</span><span id="is_iterable-360"><a href="#is_iterable-360"><span class="linenos">360</span></a> -</span><span id="is_iterable-361"><a href="#is_iterable-361"><span class="linenos">361</span></a><span class="sd"> Args:</span> -</span><span id="is_iterable-362"><a href="#is_iterable-362"><span class="linenos">362</span></a><span class="sd"> value: the value to check if it is an iterable.</span> -</span><span id="is_iterable-363"><a href="#is_iterable-363"><span class="linenos">363</span></a> -</span><span id="is_iterable-364"><a href="#is_iterable-364"><span class="linenos">364</span></a><span class="sd"> Returns:</span> -</span><span id="is_iterable-365"><a href="#is_iterable-365"><span class="linenos">365</span></a><span class="sd"> A `bool` value indicating if it is an iterable.</span> -</span><span id="is_iterable-366"><a href="#is_iterable-366"><span class="linenos">366</span></a><span class="sd"> """</span> -</span><span id="is_iterable-367"><a href="#is_iterable-367"><span class="linenos">367</span></a> <span class="k">return</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="s2">"__iter__"</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="nb">bytes</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="is_iterable-352"><a href="#is_iterable-352"><span class="linenos">352</span></a><span class="k">def</span> <span class="nf">is_iterable</span><span class="p">(</span><span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="is_iterable-353"><a href="#is_iterable-353"><span class="linenos">353</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="is_iterable-354"><a href="#is_iterable-354"><span class="linenos">354</span></a><span class="sd"> Checks if the value is an iterable, excluding the types `str` and `bytes`.</span> +</span><span id="is_iterable-355"><a href="#is_iterable-355"><span class="linenos">355</span></a> +</span><span id="is_iterable-356"><a href="#is_iterable-356"><span class="linenos">356</span></a><span class="sd"> Examples:</span> +</span><span id="is_iterable-357"><a href="#is_iterable-357"><span class="linenos">357</span></a><span class="sd"> >>> is_iterable([1,2])</span> +</span><span id="is_iterable-358"><a href="#is_iterable-358"><span class="linenos">358</span></a><span class="sd"> True</span> +</span><span id="is_iterable-359"><a href="#is_iterable-359"><span class="linenos">359</span></a><span class="sd"> >>> is_iterable("test")</span> +</span><span id="is_iterable-360"><a href="#is_iterable-360"><span class="linenos">360</span></a><span class="sd"> False</span> +</span><span id="is_iterable-361"><a href="#is_iterable-361"><span class="linenos">361</span></a> +</span><span id="is_iterable-362"><a href="#is_iterable-362"><span class="linenos">362</span></a><span class="sd"> Args:</span> +</span><span id="is_iterable-363"><a href="#is_iterable-363"><span class="linenos">363</span></a><span class="sd"> value: the value to check if it is an iterable.</span> +</span><span id="is_iterable-364"><a href="#is_iterable-364"><span class="linenos">364</span></a> +</span><span id="is_iterable-365"><a href="#is_iterable-365"><span class="linenos">365</span></a><span class="sd"> Returns:</span> +</span><span id="is_iterable-366"><a href="#is_iterable-366"><span class="linenos">366</span></a><span class="sd"> A `bool` value indicating if it is an iterable.</span> +</span><span id="is_iterable-367"><a href="#is_iterable-367"><span class="linenos">367</span></a><span class="sd"> """</span> +</span><span id="is_iterable-368"><a href="#is_iterable-368"><span class="linenos">368</span></a> <span class="k">return</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="s2">"__iter__"</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="nb">bytes</span><span class="p">))</span> </span></pre></div> @@ -1388,28 +1357,28 @@ </div> <a class="headerlink" href="#flatten"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="flatten-370"><a href="#flatten-370"><span class="linenos">370</span></a><span class="k">def</span> <span class="nf">flatten</span><span class="p">(</span><span class="n">values</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Iterator</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]:</span> -</span><span id="flatten-371"><a href="#flatten-371"><span class="linenos">371</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="flatten-372"><a href="#flatten-372"><span class="linenos">372</span></a><span class="sd"> Flattens an iterable that can contain both iterable and non-iterable elements. Objects of</span> -</span><span id="flatten-373"><a href="#flatten-373"><span class="linenos">373</span></a><span class="sd"> type `str` and `bytes` are not regarded as iterables.</span> -</span><span id="flatten-374"><a href="#flatten-374"><span class="linenos">374</span></a> -</span><span id="flatten-375"><a href="#flatten-375"><span class="linenos">375</span></a><span class="sd"> Examples:</span> -</span><span id="flatten-376"><a href="#flatten-376"><span class="linenos">376</span></a><span class="sd"> >>> list(flatten([[1, 2], 3, {4}, (5, "bla")]))</span> -</span><span id="flatten-377"><a href="#flatten-377"><span class="linenos">377</span></a><span class="sd"> [1, 2, 3, 4, 5, 'bla']</span> -</span><span id="flatten-378"><a href="#flatten-378"><span class="linenos">378</span></a><span class="sd"> >>> list(flatten([1, 2, 3]))</span> -</span><span id="flatten-379"><a href="#flatten-379"><span class="linenos">379</span></a><span class="sd"> [1, 2, 3]</span> -</span><span id="flatten-380"><a href="#flatten-380"><span class="linenos">380</span></a> -</span><span id="flatten-381"><a href="#flatten-381"><span class="linenos">381</span></a><span class="sd"> Args:</span> -</span><span id="flatten-382"><a href="#flatten-382"><span class="linenos">382</span></a><span class="sd"> values: the value to be flattened.</span> -</span><span id="flatten-383"><a href="#flatten-383"><span class="linenos">383</span></a> -</span><span id="flatten-384"><a href="#flatten-384"><span class="linenos">384</span></a><span class="sd"> Yields:</span> -</span><span id="flatten-385"><a href="#flatten-385"><span class="linenos">385</span></a><span class="sd"> Non-iterable elements in `values`.</span> -</span><span id="flatten-386"><a href="#flatten-386"><span class="linenos">386</span></a><span class="sd"> """</span> -</span><span id="flatten-387"><a href="#flatten-387"><span class="linenos">387</span></a> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">values</span><span class="p">:</span> -</span><span id="flatten-388"><a href="#flatten-388"><span class="linenos">388</span></a> <span class="k">if</span> <span class="n">is_iterable</span><span class="p">(</span><span class="n">value</span><span class="p">):</span> -</span><span id="flatten-389"><a href="#flatten-389"><span class="linenos">389</span></a> <span class="k">yield from</span> <span class="n">flatten</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="flatten-390"><a href="#flatten-390"><span class="linenos">390</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="flatten-391"><a href="#flatten-391"><span class="linenos">391</span></a> <span class="k">yield</span> <span class="n">value</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="flatten-371"><a href="#flatten-371"><span class="linenos">371</span></a><span class="k">def</span> <span class="nf">flatten</span><span class="p">(</span><span class="n">values</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Iterator</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]:</span> +</span><span id="flatten-372"><a href="#flatten-372"><span class="linenos">372</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="flatten-373"><a href="#flatten-373"><span class="linenos">373</span></a><span class="sd"> Flattens an iterable that can contain both iterable and non-iterable elements. Objects of</span> +</span><span id="flatten-374"><a href="#flatten-374"><span class="linenos">374</span></a><span class="sd"> type `str` and `bytes` are not regarded as iterables.</span> +</span><span id="flatten-375"><a href="#flatten-375"><span class="linenos">375</span></a> +</span><span id="flatten-376"><a href="#flatten-376"><span class="linenos">376</span></a><span class="sd"> Examples:</span> +</span><span id="flatten-377"><a href="#flatten-377"><span class="linenos">377</span></a><span class="sd"> >>> list(flatten([[1, 2], 3, {4}, (5, "bla")]))</span> +</span><span id="flatten-378"><a href="#flatten-378"><span class="linenos">378</span></a><span class="sd"> [1, 2, 3, 4, 5, 'bla']</span> +</span><span id="flatten-379"><a href="#flatten-379"><span class="linenos">379</span></a><span class="sd"> >>> list(flatten([1, 2, 3]))</span> +</span><span id="flatten-380"><a href="#flatten-380"><span class="linenos">380</span></a><span class="sd"> [1, 2, 3]</span> +</span><span id="flatten-381"><a href="#flatten-381"><span class="linenos">381</span></a> +</span><span id="flatten-382"><a href="#flatten-382"><span class="linenos">382</span></a><span class="sd"> Args:</span> +</span><span id="flatten-383"><a href="#flatten-383"><span class="linenos">383</span></a><span class="sd"> values: the value to be flattened.</span> +</span><span id="flatten-384"><a href="#flatten-384"><span class="linenos">384</span></a> +</span><span id="flatten-385"><a href="#flatten-385"><span class="linenos">385</span></a><span class="sd"> Yields:</span> +</span><span id="flatten-386"><a href="#flatten-386"><span class="linenos">386</span></a><span class="sd"> Non-iterable elements in `values`.</span> +</span><span id="flatten-387"><a href="#flatten-387"><span class="linenos">387</span></a><span class="sd"> """</span> +</span><span id="flatten-388"><a href="#flatten-388"><span class="linenos">388</span></a> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">values</span><span class="p">:</span> +</span><span id="flatten-389"><a href="#flatten-389"><span class="linenos">389</span></a> <span class="k">if</span> <span class="n">is_iterable</span><span class="p">(</span><span class="n">value</span><span class="p">):</span> +</span><span id="flatten-390"><a href="#flatten-390"><span class="linenos">390</span></a> <span class="k">yield from</span> <span class="n">flatten</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="flatten-391"><a href="#flatten-391"><span class="linenos">391</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="flatten-392"><a href="#flatten-392"><span class="linenos">392</span></a> <span class="k">yield</span> <span class="n">value</span> </span></pre></div> @@ -1454,36 +1423,36 @@ type <code>str</code> and <code>bytes</code> are not regarded as iterables.</p> </div> <a class="headerlink" href="#dict_depth"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="dict_depth-394"><a href="#dict_depth-394"><span class="linenos">394</span></a><span class="k">def</span> <span class="nf">dict_depth</span><span class="p">(</span><span class="n">d</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> -</span><span id="dict_depth-395"><a href="#dict_depth-395"><span class="linenos">395</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="dict_depth-396"><a href="#dict_depth-396"><span class="linenos">396</span></a><span class="sd"> Get the nesting depth of a dictionary.</span> -</span><span id="dict_depth-397"><a href="#dict_depth-397"><span class="linenos">397</span></a> -</span><span id="dict_depth-398"><a href="#dict_depth-398"><span class="linenos">398</span></a><span class="sd"> For example:</span> -</span><span id="dict_depth-399"><a href="#dict_depth-399"><span class="linenos">399</span></a><span class="sd"> >>> dict_depth(None)</span> -</span><span id="dict_depth-400"><a href="#dict_depth-400"><span class="linenos">400</span></a><span class="sd"> 0</span> -</span><span id="dict_depth-401"><a href="#dict_depth-401"><span class="linenos">401</span></a><span class="sd"> >>> dict_depth({})</span> -</span><span id="dict_depth-402"><a href="#dict_depth-402"><span class="linenos">402</span></a><span class="sd"> 1</span> -</span><span id="dict_depth-403"><a href="#dict_depth-403"><span class="linenos">403</span></a><span class="sd"> >>> dict_depth({"a": "b"})</span> -</span><span id="dict_depth-404"><a href="#dict_depth-404"><span class="linenos">404</span></a><span class="sd"> 1</span> -</span><span id="dict_depth-405"><a href="#dict_depth-405"><span class="linenos">405</span></a><span class="sd"> >>> dict_depth({"a": {}})</span> -</span><span id="dict_depth-406"><a href="#dict_depth-406"><span class="linenos">406</span></a><span class="sd"> 2</span> -</span><span id="dict_depth-407"><a href="#dict_depth-407"><span class="linenos">407</span></a><span class="sd"> >>> dict_depth({"a": {"b": {}}})</span> -</span><span id="dict_depth-408"><a href="#dict_depth-408"><span class="linenos">408</span></a><span class="sd"> 3</span> -</span><span id="dict_depth-409"><a href="#dict_depth-409"><span class="linenos">409</span></a> -</span><span id="dict_depth-410"><a href="#dict_depth-410"><span class="linenos">410</span></a><span class="sd"> Args:</span> -</span><span id="dict_depth-411"><a href="#dict_depth-411"><span class="linenos">411</span></a><span class="sd"> d (dict): dictionary</span> -</span><span id="dict_depth-412"><a href="#dict_depth-412"><span class="linenos">412</span></a> -</span><span id="dict_depth-413"><a href="#dict_depth-413"><span class="linenos">413</span></a><span class="sd"> Returns:</span> -</span><span id="dict_depth-414"><a href="#dict_depth-414"><span class="linenos">414</span></a><span class="sd"> int: depth</span> -</span><span id="dict_depth-415"><a href="#dict_depth-415"><span class="linenos">415</span></a><span class="sd"> """</span> -</span><span id="dict_depth-416"><a href="#dict_depth-416"><span class="linenos">416</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="dict_depth-417"><a href="#dict_depth-417"><span class="linenos">417</span></a> <span class="k">return</span> <span class="mi">1</span> <span class="o">+</span> <span class="n">dict_depth</span><span class="p">(</span><span class="nb">next</span><span class="p">(</span><span class="nb">iter</span><span class="p">(</span><span class="n">d</span><span class="o">.</span><span class="n">values</span><span class="p">())))</span> -</span><span id="dict_depth-418"><a href="#dict_depth-418"><span class="linenos">418</span></a> <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span> -</span><span id="dict_depth-419"><a href="#dict_depth-419"><span class="linenos">419</span></a> <span class="c1"># d doesn't have attribute "values"</span> -</span><span id="dict_depth-420"><a href="#dict_depth-420"><span class="linenos">420</span></a> <span class="k">return</span> <span class="mi">0</span> -</span><span id="dict_depth-421"><a href="#dict_depth-421"><span class="linenos">421</span></a> <span class="k">except</span> <span class="ne">StopIteration</span><span class="p">:</span> -</span><span id="dict_depth-422"><a href="#dict_depth-422"><span class="linenos">422</span></a> <span class="c1"># d.values() returns an empty sequence</span> -</span><span id="dict_depth-423"><a href="#dict_depth-423"><span class="linenos">423</span></a> <span class="k">return</span> <span class="mi">1</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="dict_depth-395"><a href="#dict_depth-395"><span class="linenos">395</span></a><span class="k">def</span> <span class="nf">dict_depth</span><span class="p">(</span><span class="n">d</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> +</span><span id="dict_depth-396"><a href="#dict_depth-396"><span class="linenos">396</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="dict_depth-397"><a href="#dict_depth-397"><span class="linenos">397</span></a><span class="sd"> Get the nesting depth of a dictionary.</span> +</span><span id="dict_depth-398"><a href="#dict_depth-398"><span class="linenos">398</span></a> +</span><span id="dict_depth-399"><a href="#dict_depth-399"><span class="linenos">399</span></a><span class="sd"> For example:</span> +</span><span id="dict_depth-400"><a href="#dict_depth-400"><span class="linenos">400</span></a><span class="sd"> >>> dict_depth(None)</span> +</span><span id="dict_depth-401"><a href="#dict_depth-401"><span class="linenos">401</span></a><span class="sd"> 0</span> +</span><span id="dict_depth-402"><a href="#dict_depth-402"><span class="linenos">402</span></a><span class="sd"> >>> dict_depth({})</span> +</span><span id="dict_depth-403"><a href="#dict_depth-403"><span class="linenos">403</span></a><span class="sd"> 1</span> +</span><span id="dict_depth-404"><a href="#dict_depth-404"><span class="linenos">404</span></a><span class="sd"> >>> dict_depth({"a": "b"})</span> +</span><span id="dict_depth-405"><a href="#dict_depth-405"><span class="linenos">405</span></a><span class="sd"> 1</span> +</span><span id="dict_depth-406"><a href="#dict_depth-406"><span class="linenos">406</span></a><span class="sd"> >>> dict_depth({"a": {}})</span> +</span><span id="dict_depth-407"><a href="#dict_depth-407"><span class="linenos">407</span></a><span class="sd"> 2</span> +</span><span id="dict_depth-408"><a href="#dict_depth-408"><span class="linenos">408</span></a><span class="sd"> >>> dict_depth({"a": {"b": {}}})</span> +</span><span id="dict_depth-409"><a href="#dict_depth-409"><span class="linenos">409</span></a><span class="sd"> 3</span> +</span><span id="dict_depth-410"><a href="#dict_depth-410"><span class="linenos">410</span></a> +</span><span id="dict_depth-411"><a href="#dict_depth-411"><span class="linenos">411</span></a><span class="sd"> Args:</span> +</span><span id="dict_depth-412"><a href="#dict_depth-412"><span class="linenos">412</span></a><span class="sd"> d (dict): dictionary</span> +</span><span id="dict_depth-413"><a href="#dict_depth-413"><span class="linenos">413</span></a> +</span><span id="dict_depth-414"><a href="#dict_depth-414"><span class="linenos">414</span></a><span class="sd"> Returns:</span> +</span><span id="dict_depth-415"><a href="#dict_depth-415"><span class="linenos">415</span></a><span class="sd"> int: depth</span> +</span><span id="dict_depth-416"><a href="#dict_depth-416"><span class="linenos">416</span></a><span class="sd"> """</span> +</span><span id="dict_depth-417"><a href="#dict_depth-417"><span class="linenos">417</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="dict_depth-418"><a href="#dict_depth-418"><span class="linenos">418</span></a> <span class="k">return</span> <span class="mi">1</span> <span class="o">+</span> <span class="n">dict_depth</span><span class="p">(</span><span class="nb">next</span><span class="p">(</span><span class="nb">iter</span><span class="p">(</span><span class="n">d</span><span class="o">.</span><span class="n">values</span><span class="p">())))</span> +</span><span id="dict_depth-419"><a href="#dict_depth-419"><span class="linenos">419</span></a> <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span> +</span><span id="dict_depth-420"><a href="#dict_depth-420"><span class="linenos">420</span></a> <span class="c1"># d doesn't have attribute "values"</span> +</span><span id="dict_depth-421"><a href="#dict_depth-421"><span class="linenos">421</span></a> <span class="k">return</span> <span class="mi">0</span> +</span><span id="dict_depth-422"><a href="#dict_depth-422"><span class="linenos">422</span></a> <span class="k">except</span> <span class="ne">StopIteration</span><span class="p">:</span> +</span><span id="dict_depth-423"><a href="#dict_depth-423"><span class="linenos">423</span></a> <span class="c1"># d.values() returns an empty sequence</span> +</span><span id="dict_depth-424"><a href="#dict_depth-424"><span class="linenos">424</span></a> <span class="k">return</span> <span class="mi">1</span> </span></pre></div> @@ -1533,12 +1502,12 @@ type <code>str</code> and <code>bytes</code> are not regarded as iterables.</p> </div> <a class="headerlink" href="#first"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="first-426"><a href="#first-426"><span class="linenos">426</span></a><span class="k">def</span> <span class="nf">first</span><span class="p">(</span><span class="n">it</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">T</span><span class="p">])</span> <span class="o">-></span> <span class="n">T</span><span class="p">:</span> -</span><span id="first-427"><a href="#first-427"><span class="linenos">427</span></a><span class="w"> </span><span class="sd">"""Returns the first element from an iterable.</span> -</span><span id="first-428"><a href="#first-428"><span class="linenos">428</span></a> -</span><span id="first-429"><a href="#first-429"><span class="linenos">429</span></a><span class="sd"> Useful for sets.</span> -</span><span id="first-430"><a href="#first-430"><span class="linenos">430</span></a><span class="sd"> """</span> -</span><span id="first-431"><a href="#first-431"><span class="linenos">431</span></a> <span class="k">return</span> <span class="nb">next</span><span class="p">(</span><span class="n">i</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">it</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="first-427"><a href="#first-427"><span class="linenos">427</span></a><span class="k">def</span> <span class="nf">first</span><span class="p">(</span><span class="n">it</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">T</span><span class="p">])</span> <span class="o">-></span> <span class="n">T</span><span class="p">:</span> +</span><span id="first-428"><a href="#first-428"><span class="linenos">428</span></a><span class="w"> </span><span class="sd">"""Returns the first element from an iterable.</span> +</span><span id="first-429"><a href="#first-429"><span class="linenos">429</span></a> +</span><span id="first-430"><a href="#first-430"><span class="linenos">430</span></a><span class="sd"> Useful for sets.</span> +</span><span id="first-431"><a href="#first-431"><span class="linenos">431</span></a><span class="sd"> """</span> +</span><span id="first-432"><a href="#first-432"><span class="linenos">432</span></a> <span class="k">return</span> <span class="nb">next</span><span class="p">(</span><span class="n">i</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">it</span><span class="p">)</span> </span></pre></div> @@ -1549,83 +1518,6 @@ type <code>str</code> and <code>bytes</code> are not regarded as iterables.</p> </section> - <section id="case_sensitive"> - <input id="case_sensitive-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> -<div class="attr function"> - - <span class="def">def</span> - <span class="name">case_sensitive</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span>,</span><span class="param"> <span class="n">dialect</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n"><a href="dialects/dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></span><span class="p">,</span> <span class="n">Type</span><span class="p">[</span><span class="n"><a href="dialects/dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></span><span class="p">],</span> <span class="n">NoneType</span><span class="p">]</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> - - <label class="view-source-button" for="case_sensitive-view-source"><span>View Source</span></label> - - </div> - <a class="headerlink" href="#case_sensitive"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="case_sensitive-434"><a href="#case_sensitive-434"><span class="linenos">434</span></a><span class="k">def</span> <span class="nf">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="case_sensitive-435"><a href="#case_sensitive-435"><span class="linenos">435</span></a><span class="w"> </span><span class="sd">"""Checks if text contains any case sensitive characters depending on dialect."""</span> -</span><span id="case_sensitive-436"><a href="#case_sensitive-436"><span class="linenos">436</span></a> <span class="kn">from</span> <span class="nn">sqlglot.dialects.dialect</span> <span class="kn">import</span> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> -</span><span id="case_sensitive-437"><a href="#case_sensitive-437"><span class="linenos">437</span></a> -</span><span id="case_sensitive-438"><a href="#case_sensitive-438"><span class="linenos">438</span></a> <span class="n">unsafe</span> <span class="o">=</span> <span class="nb">str</span><span class="o">.</span><span class="n">islower</span> <span class="k">if</span> <span class="n">dialect</span> <span class="ow">in</span> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="k">else</span> <span class="nb">str</span><span class="o">.</span><span class="n">isupper</span> -</span><span id="case_sensitive-439"><a href="#case_sensitive-439"><span class="linenos">439</span></a> <span class="k">return</span> <span class="nb">any</span><span class="p">(</span><span class="n">unsafe</span><span class="p">(</span><span class="n">char</span><span class="p">)</span> <span class="k">for</span> <span class="n">char</span> <span class="ow">in</span> <span class="n">text</span><span class="p">)</span> -</span></pre></div> - - - <div class="docstring"><p>Checks if text contains any case sensitive characters depending on dialect.</p> -</div> - - - </section> - <section id="should_identify"> - <input id="should_identify-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> -<div class="attr function"> - - <span class="def">def</span> - <span class="name">should_identify</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span>,</span><span class="param"> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span>,</span><span class="param"> <span class="n">dialect</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n"><a href="dialects/dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></span><span class="p">,</span> <span class="n">Type</span><span class="p">[</span><span class="n"><a href="dialects/dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></span><span class="p">],</span> <span class="n">NoneType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span></span><span class="return-annotation">) -> <span class="nb">bool</span>:</span></span> - - <label class="view-source-button" for="should_identify-view-source"><span>View Source</span></label> - - </div> - <a class="headerlink" href="#should_identify"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="should_identify-442"><a href="#should_identify-442"><span class="linenos">442</span></a><span class="k">def</span> <span class="nf">should_identify</span><span class="p">(</span><span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="nb">bool</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="should_identify-443"><a href="#should_identify-443"><span class="linenos">443</span></a><span class="w"> </span><span class="sd">"""Checks if text should be identified given an identify option.</span> -</span><span id="should_identify-444"><a href="#should_identify-444"><span class="linenos">444</span></a> -</span><span id="should_identify-445"><a href="#should_identify-445"><span class="linenos">445</span></a><span class="sd"> Args:</span> -</span><span id="should_identify-446"><a href="#should_identify-446"><span class="linenos">446</span></a><span class="sd"> text: the text to check.</span> -</span><span id="should_identify-447"><a href="#should_identify-447"><span class="linenos">447</span></a><span class="sd"> identify:</span> -</span><span id="should_identify-448"><a href="#should_identify-448"><span class="linenos">448</span></a><span class="sd"> "always" or `True`: always returns true.</span> -</span><span id="should_identify-449"><a href="#should_identify-449"><span class="linenos">449</span></a><span class="sd"> "safe": true if there is no uppercase or lowercase character in `text`, depending on `dialect`.</span> -</span><span id="should_identify-450"><a href="#should_identify-450"><span class="linenos">450</span></a><span class="sd"> dialect: the dialect to use in order to decide whether a text should be identified.</span> -</span><span id="should_identify-451"><a href="#should_identify-451"><span class="linenos">451</span></a> -</span><span id="should_identify-452"><a href="#should_identify-452"><span class="linenos">452</span></a><span class="sd"> Returns:</span> -</span><span id="should_identify-453"><a href="#should_identify-453"><span class="linenos">453</span></a><span class="sd"> Whether or not a string should be identified.</span> -</span><span id="should_identify-454"><a href="#should_identify-454"><span class="linenos">454</span></a><span class="sd"> """</span> -</span><span id="should_identify-455"><a href="#should_identify-455"><span class="linenos">455</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="ow">is</span> <span class="kc">True</span> <span class="ow">or</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"always"</span><span class="p">:</span> -</span><span id="should_identify-456"><a href="#should_identify-456"><span class="linenos">456</span></a> <span class="k">return</span> <span class="kc">True</span> -</span><span id="should_identify-457"><a href="#should_identify-457"><span class="linenos">457</span></a> <span class="k">if</span> <span class="n">identify</span> <span class="o">==</span> <span class="s2">"safe"</span><span class="p">:</span> -</span><span id="should_identify-458"><a href="#should_identify-458"><span class="linenos">458</span></a> <span class="k">return</span> <span class="ow">not</span> <span class="n">case_sensitive</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="n">dialect</span><span class="p">)</span> -</span><span id="should_identify-459"><a href="#should_identify-459"><span class="linenos">459</span></a> <span class="k">return</span> <span class="kc">False</span> -</span></pre></div> - - - <div class="docstring"><p>Checks if text should be identified given an identify option.</p> - -<h6 id="arguments">Arguments:</h6> - -<ul> -<li><strong>text:</strong> the text to check.</li> -<li><strong>identify:</strong> "always" or <code>True</code>: always returns true. -"safe": true if there is no uppercase or lowercase character in <code>text</code>, depending on <code>dialect</code>.</li> -<li><strong>dialect:</strong> the dialect to use in order to decide whether a text should be identified.</li> -</ul> - -<h6 id="returns">Returns:</h6> - -<blockquote> - <p>Whether or not a string should be identified.</p> -</blockquote> -</div> - - - </section> </main> <script> function escapeHTML(html) { diff --git a/docs/sqlglot/optimizer/eliminate_joins.html b/docs/sqlglot/optimizer/eliminate_joins.html index de213e4..791cf92 100644 --- a/docs/sqlglot/optimizer/eliminate_joins.html +++ b/docs/sqlglot/optimizer/eliminate_joins.html @@ -93,7 +93,7 @@ </span><span id="L-32"><a href="#L-32"><span class="linenos"> 32</span></a> </span><span id="L-33"><a href="#L-33"><span class="linenos"> 33</span></a> <span class="c1"># Reverse the joins so we can remove chains of unused joins</span> </span><span id="L-34"><a href="#L-34"><span class="linenos"> 34</span></a> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="nb">reversed</span><span class="p">(</span><span class="n">joins</span><span class="p">):</span> -</span><span id="L-35"><a href="#L-35"><span class="linenos"> 35</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias_or_name</span> +</span><span id="L-35"><a href="#L-35"><span class="linenos"> 35</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span> </span><span id="L-36"><a href="#L-36"><span class="linenos"> 36</span></a> <span class="k">if</span> <span class="n">_should_eliminate_join</span><span class="p">(</span><span class="n">scope</span><span class="p">,</span> <span class="n">join</span><span class="p">,</span> <span class="n">alias</span><span class="p">):</span> </span><span id="L-37"><a href="#L-37"><span class="linenos"> 37</span></a> <span class="n">join</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> </span><span id="L-38"><a href="#L-38"><span class="linenos"> 38</span></a> <span class="n">scope</span><span class="o">.</span><span class="n">remove_source</span><span class="p">(</span><span class="n">alias</span><span class="p">)</span> @@ -187,7 +187,7 @@ </span><span id="L-126"><a href="#L-126"><span class="linenos">126</span></a><span class="sd"> tuple[list[str], list[str], exp.Expression]:</span> </span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a><span class="sd"> Tuple of (source key, join key, remaining predicate)</span> </span><span id="L-128"><a href="#L-128"><span class="linenos">128</span></a><span class="sd"> """</span> -</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias_or_name</span> +</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span> </span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a> <span class="n">on</span> <span class="o">=</span> <span class="p">(</span><span class="n">join</span><span 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 class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">true</span><span class="p">())</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> </span><span id="L-131"><a href="#L-131"><span class="linenos">131</span></a> <span class="n">source_key</span> <span class="o">=</span> <span class="p">[]</span> </span><span id="L-132"><a href="#L-132"><span class="linenos">132</span></a> <span class="n">join_key</span> <span class="o">=</span> <span class="p">[]</span> @@ -284,7 +284,7 @@ </span><span id="eliminate_joins-33"><a href="#eliminate_joins-33"><span class="linenos">33</span></a> </span><span id="eliminate_joins-34"><a href="#eliminate_joins-34"><span class="linenos">34</span></a> <span class="c1"># Reverse the joins so we can remove chains of unused joins</span> </span><span id="eliminate_joins-35"><a href="#eliminate_joins-35"><span class="linenos">35</span></a> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="nb">reversed</span><span class="p">(</span><span class="n">joins</span><span class="p">):</span> -</span><span id="eliminate_joins-36"><a href="#eliminate_joins-36"><span class="linenos">36</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias_or_name</span> +</span><span id="eliminate_joins-36"><a href="#eliminate_joins-36"><span class="linenos">36</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span> </span><span id="eliminate_joins-37"><a href="#eliminate_joins-37"><span class="linenos">37</span></a> <span class="k">if</span> <span class="n">_should_eliminate_join</span><span class="p">(</span><span class="n">scope</span><span class="p">,</span> <span class="n">join</span><span class="p">,</span> <span class="n">alias</span><span class="p">):</span> </span><span id="eliminate_joins-38"><a href="#eliminate_joins-38"><span class="linenos">38</span></a> <span class="n">join</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> </span><span id="eliminate_joins-39"><a href="#eliminate_joins-39"><span class="linenos">39</span></a> <span class="n">scope</span><span class="o">.</span><span class="n">remove_source</span><span class="p">(</span><span class="n">alias</span><span class="p">)</span> @@ -345,7 +345,7 @@ </span><span id="join_condition-127"><a href="#join_condition-127"><span class="linenos">127</span></a><span class="sd"> tuple[list[str], list[str], exp.Expression]:</span> </span><span id="join_condition-128"><a href="#join_condition-128"><span class="linenos">128</span></a><span class="sd"> Tuple of (source key, join key, remaining predicate)</span> </span><span id="join_condition-129"><a href="#join_condition-129"><span class="linenos">129</span></a><span class="sd"> """</span> -</span><span id="join_condition-130"><a href="#join_condition-130"><span class="linenos">130</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias_or_name</span> +</span><span id="join_condition-130"><a href="#join_condition-130"><span class="linenos">130</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span> </span><span id="join_condition-131"><a href="#join_condition-131"><span class="linenos">131</span></a> <span class="n">on</span> <span class="o">=</span> <span class="p">(</span><span class="n">join</span><span 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 class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">true</span><span class="p">())</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> </span><span id="join_condition-132"><a href="#join_condition-132"><span class="linenos">132</span></a> <span class="n">source_key</span> <span class="o">=</span> <span class="p">[]</span> </span><span id="join_condition-133"><a href="#join_condition-133"><span class="linenos">133</span></a> <span class="n">join_key</span> <span class="o">=</span> <span class="p">[]</span> diff --git a/docs/sqlglot/optimizer/merge_subqueries.html b/docs/sqlglot/optimizer/merge_subqueries.html index 57cb5d9..7f20268 100644 --- a/docs/sqlglot/optimizer/merge_subqueries.html +++ b/docs/sqlglot/optimizer/merge_subqueries.html @@ -209,7 +209,7 @@ </span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">from_or_join</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> </span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> <span class="k">return</span> <span class="kc">False</span> </span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a> -</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">from_or_join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias_or_name</span> +</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">from_or_join</span><span class="o">.</span><span class="n">alias_or_name</span> </span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a> </span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="n">on</span> <span class="o">=</span> <span class="n">from_or_join</span><span 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-151"><a href="#L-151"><span class="linenos">151</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">on</span><span class="p">:</span> @@ -317,135 +317,130 @@ </span><span id="L-253"><a href="#L-253"><span class="linenos">253</span></a><span class="sd"> """</span> </span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a> </span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="n">new_joins</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> <span class="n">comma_joins</span> <span class="o">=</span> <span class="n">inner_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"from"</span><span class="p">)</span><span class="o">.</span><span class="n">expressions</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span> -</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a> <span class="k">for</span> <span class="n">subquery</span> <span class="ow">in</span> <span class="n">comma_joins</span><span class="p">:</span> -</span><span id="L-258"><a href="#L-258"><span class="linenos">258</span></a> <span class="n">new_joins</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">subquery</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="s2">"CROSS"</span><span class="p">))</span> -</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="n">outer_scope</span><span class="o">.</span><span class="n">add_source</span><span class="p">(</span><span class="n">subquery</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">,</span> <span class="n">inner_scope</span><span class="o">.</span><span class="n">sources</span><span class="p">[</span><span class="n">subquery</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">])</span> -</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> -</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> <span class="n">joins</span> <span class="o">=</span> <span class="n">inner_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]</span> -</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">joins</span><span class="p">:</span> -</span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a> <span class="n">new_joins</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">join</span><span class="p">)</span> -</span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> <span class="n">outer_scope</span><span class="o">.</span><span class="n">add_source</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">,</span> <span class="n">inner_scope</span><span class="o">.</span><span class="n">sources</span><span class="p">[</span><span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</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="k">if</span> <span class="n">new_joins</span><span class="p">:</span> -</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> <span class="n">outer_joins</span> <span class="o">=</span> <span class="n">outer_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> -</span><span id="L-269"><a href="#L-269"><span class="linenos">269</span></a> <span class="c1"># Maintain the join order</span> -</span><span id="L-270"><a href="#L-270"><span class="linenos">270</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">from_or_join</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">):</span> -</span><span id="L-271"><a href="#L-271"><span class="linenos">271</span></a> <span class="n">position</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="L-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="n">position</span> <span class="o">=</span> <span class="n">outer_joins</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">from_or_join</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span> -</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="n">outer_joins</span><span class="p">[</span><span class="n">position</span><span class="p">:</span><span class="n">position</span><span class="p">]</span> <span class="o">=</span> <span class="n">new_joins</span> -</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a> -</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a> <span class="n">outer_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">,</span> <span class="n">outer_joins</span><span class="p">)</span> -</span><span id="L-277"><a href="#L-277"><span class="linenos">277</span></a> +</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> +</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a> <span class="n">joins</span> <span class="o">=</span> <span class="n">inner_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]</span> +</span><span id="L-258"><a href="#L-258"><span class="linenos">258</span></a> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">joins</span><span class="p">:</span> +</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="n">new_joins</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">join</span><span class="p">)</span> +</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> <span class="n">outer_scope</span><span class="o">.</span><span class="n">add_source</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">,</span> <span class="n">inner_scope</span><span class="o">.</span><span class="n">sources</span><span class="p">[</span><span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">])</span> +</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> +</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="k">if</span> <span class="n">new_joins</span><span class="p">:</span> +</span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a> <span class="n">outer_joins</span> <span class="o">=</span> <span class="n">outer_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> +</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a> <span class="c1"># Maintain the join order</span> +</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">from_or_join</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">):</span> +</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> <span class="n">position</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-269"><a href="#L-269"><span class="linenos">269</span></a> <span class="n">position</span> <span class="o">=</span> <span class="n">outer_joins</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">from_or_join</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span> +</span><span id="L-270"><a href="#L-270"><span class="linenos">270</span></a> <span class="n">outer_joins</span><span class="p">[</span><span class="n">position</span><span class="p">:</span><span class="n">position</span><span class="p">]</span> <span class="o">=</span> <span class="n">new_joins</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">outer_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">,</span> <span class="n">outer_joins</span><span class="p">)</span> +</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> +</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> +</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a><span class="k">def</span> <span class="nf">_merge_expressions</span><span class="p">(</span><span class="n">outer_scope</span><span class="p">,</span> <span class="n">inner_scope</span><span class="p">,</span> <span class="n">alias</span><span class="p">):</span> +</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-277"><a href="#L-277"><span class="linenos">277</span></a><span class="sd"> Merge projections of inner query into outer query.</span> </span><span id="L-278"><a href="#L-278"><span class="linenos">278</span></a> -</span><span id="L-279"><a href="#L-279"><span class="linenos">279</span></a><span class="k">def</span> <span class="nf">_merge_expressions</span><span class="p">(</span><span class="n">outer_scope</span><span class="p">,</span> <span class="n">inner_scope</span><span class="p">,</span> <span class="n">alias</span><span class="p">):</span> -</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-281"><a href="#L-281"><span class="linenos">281</span></a><span class="sd"> Merge projections of inner query into outer query.</span> -</span><span id="L-282"><a href="#L-282"><span class="linenos">282</span></a> -</span><span id="L-283"><a href="#L-283"><span class="linenos">283</span></a><span class="sd"> Args:</span> -</span><span id="L-284"><a href="#L-284"><span class="linenos">284</span></a><span class="sd"> outer_scope (sqlglot.optimizer.scope.Scope)</span> -</span><span id="L-285"><a href="#L-285"><span class="linenos">285</span></a><span class="sd"> inner_scope (sqlglot.optimizer.scope.Scope)</span> -</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a><span class="sd"> alias (str)</span> -</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a><span class="sd"> """</span> -</span><span id="L-288"><a href="#L-288"><span class="linenos">288</span></a> <span class="c1"># Collect all columns that reference the alias of the inner query</span> -</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a> <span class="n">outer_columns</span> <span class="o">=</span> <span class="n">defaultdict</span><span class="p">(</span><span class="nb">list</span><span class="p">)</span> -</span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">outer_scope</span><span class="o">.</span><span class="n">columns</span><span class="p">:</span> -</span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a> <span class="k">if</span> <span class="n">column</span><span class="o">.</span><span class="n">table</span> <span class="o">==</span> <span class="n">alias</span><span class="p">:</span> -</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a> <span class="n">outer_columns</span><span class="p">[</span><span class="n">column</span><span class="o">.</span><span class="n">name</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">column</span><span class="p">)</span> -</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a> -</span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a> <span class="c1"># Replace columns with the projection expression in the inner query</span> -</span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">inner_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="L-296"><a href="#L-296"><span class="linenos">296</span></a> <span class="n">projection_name</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias_or_name</span> -</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">projection_name</span><span class="p">:</span> -</span><span id="L-298"><a href="#L-298"><span class="linenos">298</span></a> <span class="k">continue</span> -</span><span id="L-299"><a href="#L-299"><span class="linenos">299</span></a> <span class="n">columns_to_replace</span> <span class="o">=</span> <span class="n">outer_columns</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">projection_name</span><span class="p">,</span> <span class="p">[])</span> -</span><span id="L-300"><a href="#L-300"><span class="linenos">300</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">columns_to_replace</span><span class="p">:</span> -</span><span id="L-301"><a href="#L-301"><span class="linenos">301</span></a> <span class="n">column</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">unalias</span><span class="p">()</span><span class="o">.</span><span class="n">copy</span><span class="p">())</span> -</span><span id="L-302"><a href="#L-302"><span class="linenos">302</span></a> +</span><span id="L-279"><a href="#L-279"><span class="linenos">279</span></a><span class="sd"> Args:</span> +</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a><span class="sd"> outer_scope (sqlglot.optimizer.scope.Scope)</span> +</span><span id="L-281"><a href="#L-281"><span class="linenos">281</span></a><span class="sd"> inner_scope (sqlglot.optimizer.scope.Scope)</span> +</span><span id="L-282"><a href="#L-282"><span class="linenos">282</span></a><span class="sd"> alias (str)</span> +</span><span id="L-283"><a href="#L-283"><span class="linenos">283</span></a><span class="sd"> """</span> +</span><span id="L-284"><a href="#L-284"><span class="linenos">284</span></a> <span class="c1"># Collect all columns that reference the alias of the inner query</span> +</span><span id="L-285"><a href="#L-285"><span class="linenos">285</span></a> <span class="n">outer_columns</span> <span class="o">=</span> <span class="n">defaultdict</span><span class="p">(</span><span class="nb">list</span><span class="p">)</span> +</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">outer_scope</span><span class="o">.</span><span class="n">columns</span><span class="p">:</span> +</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a> <span class="k">if</span> <span class="n">column</span><span class="o">.</span><span class="n">table</span> <span class="o">==</span> <span class="n">alias</span><span class="p">:</span> +</span><span id="L-288"><a href="#L-288"><span class="linenos">288</span></a> <span class="n">outer_columns</span><span class="p">[</span><span class="n">column</span><span class="o">.</span><span class="n">name</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">column</span><span class="p">)</span> +</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a> +</span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a> <span class="c1"># Replace columns with the projection expression in the inner query</span> +</span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">inner_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a> <span class="n">projection_name</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">alias_or_name</span> +</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">projection_name</span><span class="p">:</span> +</span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a> <span class="k">continue</span> +</span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a> <span class="n">columns_to_replace</span> <span class="o">=</span> <span class="n">outer_columns</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">projection_name</span><span class="p">,</span> <span class="p">[])</span> +</span><span id="L-296"><a href="#L-296"><span class="linenos">296</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">columns_to_replace</span><span class="p">:</span> +</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a> <span class="n">column</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">unalias</span><span class="p">()</span><span class="o">.</span><span class="n">copy</span><span class="p">())</span> +</span><span id="L-298"><a href="#L-298"><span class="linenos">298</span></a> +</span><span id="L-299"><a href="#L-299"><span class="linenos">299</span></a> +</span><span id="L-300"><a href="#L-300"><span class="linenos">300</span></a><span class="k">def</span> <span class="nf">_merge_where</span><span class="p">(</span><span class="n">outer_scope</span><span class="p">,</span> <span class="n">inner_scope</span><span class="p">,</span> <span class="n">from_or_join</span><span class="p">):</span> +</span><span id="L-301"><a href="#L-301"><span class="linenos">301</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-302"><a href="#L-302"><span class="linenos">302</span></a><span class="sd"> Merge WHERE clause of inner query into outer query.</span> </span><span id="L-303"><a href="#L-303"><span class="linenos">303</span></a> -</span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a><span class="k">def</span> <span class="nf">_merge_where</span><span class="p">(</span><span class="n">outer_scope</span><span class="p">,</span> <span class="n">inner_scope</span><span class="p">,</span> <span class="n">from_or_join</span><span class="p">):</span> -</span><span id="L-305"><a href="#L-305"><span class="linenos">305</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-306"><a href="#L-306"><span class="linenos">306</span></a><span class="sd"> Merge WHERE clause of inner query into outer query.</span> -</span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a> -</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a><span class="sd"> Args:</span> -</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a><span class="sd"> outer_scope (sqlglot.optimizer.scope.Scope)</span> -</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a><span class="sd"> inner_scope (sqlglot.optimizer.scope.Scope)</span> -</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a><span class="sd"> from_or_join (exp.From|exp.Join)</span> -</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a><span class="sd"> """</span> -</span><span id="L-313"><a href="#L-313"><span class="linenos">313</span></a> <span class="n">where</span> <span class="o">=</span> <span class="n">inner_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"where"</span><span class="p">)</span> -</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">where</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">where</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> -</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> <span class="k">return</span> -</span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> -</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">outer_scope</span><span class="o">.</span><span class="n">expression</span> -</span><span id="L-318"><a href="#L-318"><span class="linenos">318</span></a> -</span><span id="L-319"><a href="#L-319"><span class="linenos">319</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">from_or_join</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> -</span><span id="L-320"><a href="#L-320"><span class="linenos">320</span></a> <span class="c1"># Merge predicates from an outer join to the ON clause</span> -</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a> <span class="c1"># if it only has columns that are already joined</span> -</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a> <span class="n">from_</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"from"</span><span class="p">)</span> -</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="n">sources</span> <span class="o">=</span> <span class="p">{</span><span class="n">from_</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">}</span> <span class="k">if</span> <span class="n">from_</span> <span class="k">else</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="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"joins"</span><span class="p">]:</span> -</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span> -</span><span id="L-327"><a href="#L-327"><span class="linenos">327</span></a> <span class="n">sources</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">source</span><span class="p">)</span> -</span><span id="L-328"><a href="#L-328"><span class="linenos">328</span></a> <span class="k">if</span> <span class="n">source</span> <span class="o">==</span> <span class="n">from_or_join</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> -</span><span id="L-329"><a href="#L-329"><span class="linenos">329</span></a> <span class="k">break</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="k">if</span> <span class="nb">set</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">where</span><span class="o">.</span><span class="n">this</span><span class="p">))</span> <span class="o"><=</span> <span class="n">sources</span><span class="p">:</span> -</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a> <span class="n">from_or_join</span><span class="o">.</span><span class="n">on</span><span class="p">(</span><span class="n">where</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-333"><a href="#L-333"><span class="linenos">333</span></a> <span class="n">from_or_join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"on"</span><span class="p">,</span> <span class="n">from_or_join</span><span 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-334"><a href="#L-334"><span class="linenos">334</span></a> <span class="k">return</span> -</span><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a> -</span><span id="L-336"><a href="#L-336"><span class="linenos">336</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">where</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-337"><a href="#L-337"><span class="linenos">337</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"where"</span><span class="p">,</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"where"</span><span class="p">))</span> +</span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a><span class="sd"> Args:</span> +</span><span id="L-305"><a href="#L-305"><span class="linenos">305</span></a><span class="sd"> outer_scope (sqlglot.optimizer.scope.Scope)</span> +</span><span id="L-306"><a href="#L-306"><span class="linenos">306</span></a><span class="sd"> inner_scope (sqlglot.optimizer.scope.Scope)</span> +</span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a><span class="sd"> from_or_join (exp.From|exp.Join)</span> +</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a><span class="sd"> """</span> +</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a> <span class="n">where</span> <span class="o">=</span> <span class="n">inner_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"where"</span><span class="p">)</span> +</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">where</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">where</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> +</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a> <span class="k">return</span> +</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> +</span><span id="L-313"><a href="#L-313"><span class="linenos">313</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">outer_scope</span><span class="o">.</span><span class="n">expression</span> +</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> +</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">from_or_join</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> +</span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> <span class="c1"># Merge predicates from an outer join to the ON clause</span> +</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="c1"># if it only has columns that are already joined</span> +</span><span id="L-318"><a href="#L-318"><span class="linenos">318</span></a> <span class="n">from_</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"from"</span><span class="p">)</span> +</span><span id="L-319"><a href="#L-319"><span class="linenos">319</span></a> <span class="n">sources</span> <span class="o">=</span> <span class="p">{</span><span class="n">from_</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">}</span> <span class="k">if</span> <span class="n">from_</span> <span class="k">else</span> <span class="p">{}</span> +</span><span id="L-320"><a href="#L-320"><span class="linenos">320</span></a> +</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"joins"</span><span class="p">]:</span> +</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span> +</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="n">sources</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">source</span><span class="p">)</span> +</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a> <span class="k">if</span> <span class="n">source</span> <span class="o">==</span> <span class="n">from_or_join</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> +</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a> <span class="k">break</span> +</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> +</span><span id="L-327"><a href="#L-327"><span class="linenos">327</span></a> <span class="k">if</span> <span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">where</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> <span class="o"><=</span> <span class="n">sources</span><span class="p">:</span> +</span><span id="L-328"><a href="#L-328"><span class="linenos">328</span></a> <span class="n">from_or_join</span><span class="o">.</span><span class="n">on</span><span class="p">(</span><span class="n">where</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-329"><a href="#L-329"><span class="linenos">329</span></a> <span class="n">from_or_join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"on"</span><span class="p">,</span> <span class="n">from_or_join</span><span 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-330"><a href="#L-330"><span class="linenos">330</span></a> <span class="k">return</span> +</span><span id="L-331"><a href="#L-331"><span class="linenos">331</span></a> +</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">where</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-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><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a><span class="k">def</span> <span class="nf">_merge_order</span><span class="p">(</span><span class="n">outer_scope</span><span class="p">,</span> <span class="n">inner_scope</span><span class="p">):</span> +</span><span id="L-336"><a href="#L-336"><span class="linenos">336</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-337"><a href="#L-337"><span class="linenos">337</span></a><span class="sd"> Merge ORDER clause of inner query into outer query.</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><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a><span class="k">def</span> <span class="nf">_merge_order</span><span class="p">(</span><span class="n">outer_scope</span><span class="p">,</span> <span class="n">inner_scope</span><span class="p">):</span> -</span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a><span class="sd"> Merge ORDER clause of inner query into outer query.</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="sd"> Args:</span> -</span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a><span class="sd"> outer_scope (sqlglot.optimizer.scope.Scope)</span> -</span><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a><span class="sd"> inner_scope (sqlglot.optimizer.scope.Scope)</span> -</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a><span class="sd"> """</span> -</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> <span class="nb">any</span><span class="p">(</span> -</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> <span class="n">outer_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"group"</span><span class="p">,</span> <span class="s2">"distinct"</span><span class="p">,</span> <span class="s2">"having"</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">]</span> -</span><span id="L-351"><a href="#L-351"><span class="linenos">351</span></a> <span class="p">)</span> -</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a> <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span><span class="n">outer_scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">1</span> -</span><span id="L-353"><a href="#L-353"><span class="linenos">353</span></a> <span class="ow">or</span> <span class="nb">any</span><span class="p">(</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">AggFunc</span><span class="p">)</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">outer_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-354"><a href="#L-354"><span class="linenos">354</span></a> <span class="p">):</span> -</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a> <span class="k">return</span> -</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a> -</span><span id="L-357"><a href="#L-357"><span class="linenos">357</span></a> <span class="n">outer_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"order"</span><span class="p">,</span> <span class="n">inner_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"order"</span><span class="p">))</span> -</span><span id="L-358"><a href="#L-358"><span class="linenos">358</span></a> -</span><span id="L-359"><a href="#L-359"><span class="linenos">359</span></a> -</span><span id="L-360"><a href="#L-360"><span class="linenos">360</span></a><span class="k">def</span> <span class="nf">_merge_hints</span><span class="p">(</span><span class="n">outer_scope</span><span class="p">,</span> <span class="n">inner_scope</span><span class="p">):</span> -</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a> <span class="n">inner_scope_hint</span> <span class="o">=</span> <span class="n">inner_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"hint"</span><span class="p">)</span> -</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">inner_scope_hint</span><span class="p">:</span> -</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a> <span class="k">return</span> -</span><span id="L-364"><a href="#L-364"><span class="linenos">364</span></a> <span class="n">outer_scope_hint</span> <span class="o">=</span> <span class="n">outer_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"hint"</span><span class="p">)</span> -</span><span id="L-365"><a href="#L-365"><span class="linenos">365</span></a> <span class="k">if</span> <span class="n">outer_scope_hint</span><span class="p">:</span> -</span><span id="L-366"><a href="#L-366"><span class="linenos">366</span></a> <span class="k">for</span> <span class="n">hint_expression</span> <span class="ow">in</span> <span class="n">inner_scope_hint</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="L-367"><a href="#L-367"><span class="linenos">367</span></a> <span class="n">outer_scope_hint</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">hint_expression</span><span class="p">)</span> -</span><span id="L-368"><a href="#L-368"><span class="linenos">368</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-369"><a href="#L-369"><span class="linenos">369</span></a> <span class="n">outer_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"hint"</span><span class="p">,</span> <span class="n">inner_scope_hint</span><span class="p">)</span> +</span><span id="L-339"><a href="#L-339"><span class="linenos">339</span></a><span class="sd"> Args:</span> +</span><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a><span class="sd"> outer_scope (sqlglot.optimizer.scope.Scope)</span> +</span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a><span class="sd"> inner_scope (sqlglot.optimizer.scope.Scope)</span> +</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a><span class="sd"> """</span> +</span><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="L-344"><a href="#L-344"><span class="linenos">344</span></a> <span class="nb">any</span><span class="p">(</span> +</span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> <span class="n">outer_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"group"</span><span class="p">,</span> <span class="s2">"distinct"</span><span class="p">,</span> <span class="s2">"having"</span><span class="p">,</span> <span class="s2">"order"</span><span class="p">]</span> +</span><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a> <span class="p">)</span> +</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span><span class="n">outer_scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">1</span> +</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="ow">or</span> <span class="nb">any</span><span class="p">(</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">AggFunc</span><span class="p">)</span> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">outer_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> <span class="p">):</span> +</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> <span class="k">return</span> +</span><span id="L-351"><a href="#L-351"><span class="linenos">351</span></a> +</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a> <span class="n">outer_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"order"</span><span class="p">,</span> <span class="n">inner_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"order"</span><span class="p">))</span> +</span><span id="L-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><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a><span class="k">def</span> <span class="nf">_merge_hints</span><span class="p">(</span><span class="n">outer_scope</span><span class="p">,</span> <span class="n">inner_scope</span><span class="p">):</span> +</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a> <span class="n">inner_scope_hint</span> <span class="o">=</span> <span class="n">inner_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"hint"</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="ow">not</span> <span class="n">inner_scope_hint</span><span class="p">:</span> +</span><span id="L-358"><a href="#L-358"><span class="linenos">358</span></a> <span class="k">return</span> +</span><span id="L-359"><a href="#L-359"><span class="linenos">359</span></a> <span class="n">outer_scope_hint</span> <span class="o">=</span> <span class="n">outer_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"hint"</span><span class="p">)</span> +</span><span id="L-360"><a href="#L-360"><span class="linenos">360</span></a> <span class="k">if</span> <span class="n">outer_scope_hint</span><span class="p">:</span> +</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a> <span class="k">for</span> <span class="n">hint_expression</span> <span class="ow">in</span> <span class="n">inner_scope_hint</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a> <span class="n">outer_scope_hint</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">hint_expression</span><span class="p">)</span> +</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-364"><a href="#L-364"><span class="linenos">364</span></a> <span class="n">outer_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"hint"</span><span class="p">,</span> <span class="n">inner_scope_hint</span><span class="p">)</span> +</span><span id="L-365"><a href="#L-365"><span class="linenos">365</span></a> +</span><span id="L-366"><a href="#L-366"><span class="linenos">366</span></a> +</span><span id="L-367"><a href="#L-367"><span class="linenos">367</span></a><span class="k">def</span> <span class="nf">_pop_cte</span><span class="p">(</span><span class="n">inner_scope</span><span class="p">):</span> +</span><span id="L-368"><a href="#L-368"><span class="linenos">368</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-369"><a href="#L-369"><span class="linenos">369</span></a><span class="sd"> Remove CTE from the AST.</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><span id="L-372"><a href="#L-372"><span class="linenos">372</span></a><span class="k">def</span> <span class="nf">_pop_cte</span><span class="p">(</span><span class="n">inner_scope</span><span class="p">):</span> -</span><span id="L-373"><a href="#L-373"><span class="linenos">373</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-374"><a href="#L-374"><span class="linenos">374</span></a><span class="sd"> Remove CTE from the AST.</span> -</span><span id="L-375"><a href="#L-375"><span class="linenos">375</span></a> -</span><span id="L-376"><a href="#L-376"><span class="linenos">376</span></a><span class="sd"> Args:</span> -</span><span id="L-377"><a href="#L-377"><span class="linenos">377</span></a><span class="sd"> inner_scope (sqlglot.optimizer.scope.Scope)</span> -</span><span id="L-378"><a href="#L-378"><span class="linenos">378</span></a><span class="sd"> """</span> -</span><span id="L-379"><a href="#L-379"><span class="linenos">379</span></a> <span class="n">cte</span> <span class="o">=</span> <span class="n">inner_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span> -</span><span id="L-380"><a href="#L-380"><span class="linenos">380</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="n">cte</span><span class="o">.</span><span class="n">parent</span> -</span><span id="L-381"><a href="#L-381"><span class="linenos">381</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">with_</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-382"><a href="#L-382"><span class="linenos">382</span></a> <span class="n">with_</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> -</span><span id="L-383"><a href="#L-383"><span class="linenos">383</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-384"><a href="#L-384"><span class="linenos">384</span></a> <span class="n">cte</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> +</span><span id="L-371"><a href="#L-371"><span class="linenos">371</span></a><span class="sd"> Args:</span> +</span><span id="L-372"><a href="#L-372"><span class="linenos">372</span></a><span class="sd"> inner_scope (sqlglot.optimizer.scope.Scope)</span> +</span><span id="L-373"><a href="#L-373"><span class="linenos">373</span></a><span class="sd"> """</span> +</span><span id="L-374"><a href="#L-374"><span class="linenos">374</span></a> <span class="n">cte</span> <span class="o">=</span> <span class="n">inner_scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span> +</span><span id="L-375"><a href="#L-375"><span class="linenos">375</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="n">cte</span><span class="o">.</span><span class="n">parent</span> +</span><span id="L-376"><a href="#L-376"><span class="linenos">376</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">with_</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-377"><a href="#L-377"><span class="linenos">377</span></a> <span class="n">with_</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> +</span><span id="L-378"><a href="#L-378"><span class="linenos">378</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-379"><a href="#L-379"><span class="linenos">379</span></a> <span class="n">cte</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span> </span></pre></div> diff --git a/docs/sqlglot/optimizer/normalize_identifiers.html b/docs/sqlglot/optimizer/normalize_identifiers.html index 2366979..834c33e 100644 --- a/docs/sqlglot/optimizer/normalize_identifiers.html +++ b/docs/sqlglot/optimizer/normalize_identifiers.html @@ -56,42 +56,33 @@ <label class="view-source-button" for="mod-normalize_identifiers-view-source"><span>View Source</span></label> - <div class="pdoc-code codehilite"><pre><span></span><span id="L-1"><a href="#L-1"><span class="linenos"> 1</span></a><span class="kn">from</span> <span class="nn">sqlglot</span> <span class="kn">import</span> <span class="n">exp</span> -</span><span id="L-2"><a href="#L-2"><span class="linenos"> 2</span></a><span class="kn">from</span> <span class="nn">sqlglot._typing</span> <span class="kn">import</span> <span class="n">E</span> -</span><span id="L-3"><a href="#L-3"><span class="linenos"> 3</span></a><span class="kn">from</span> <span class="nn">sqlglot.dialects.dialect</span> <span class="kn">import</span> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span><span class="p">,</span> <span class="n">DialectType</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="L-1"><a href="#L-1"><span class="linenos"> 1</span></a><span class="kn">from</span> <span class="nn">sqlglot._typing</span> <span class="kn">import</span> <span class="n">E</span> +</span><span id="L-2"><a href="#L-2"><span class="linenos"> 2</span></a><span class="kn">from</span> <span class="nn">sqlglot.dialects.dialect</span> <span class="kn">import</span> <span class="n">Dialect</span><span class="p">,</span> <span class="n">DialectType</span> +</span><span id="L-3"><a href="#L-3"><span class="linenos"> 3</span></a> </span><span id="L-4"><a href="#L-4"><span class="linenos"> 4</span></a> -</span><span id="L-5"><a href="#L-5"><span class="linenos"> 5</span></a> -</span><span id="L-6"><a href="#L-6"><span class="linenos"> 6</span></a><span class="k">def</span> <span class="nf">normalize_identifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="L-7"><a href="#L-7"><span class="linenos"> 7</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-8"><a href="#L-8"><span class="linenos"> 8</span></a><span class="sd"> Normalize all unquoted identifiers to either lower or upper case, depending on</span> -</span><span id="L-9"><a href="#L-9"><span class="linenos"> 9</span></a><span class="sd"> the dialect. This essentially makes those identifiers case-insensitive.</span> -</span><span id="L-10"><a href="#L-10"><span class="linenos">10</span></a> -</span><span id="L-11"><a href="#L-11"><span class="linenos">11</span></a><span class="sd"> Example:</span> -</span><span id="L-12"><a href="#L-12"><span class="linenos">12</span></a><span class="sd"> >>> import sqlglot</span> -</span><span id="L-13"><a href="#L-13"><span class="linenos">13</span></a><span class="sd"> >>> expression = sqlglot.parse_one('SELECT Bar.A AS A FROM "Foo".Bar')</span> -</span><span id="L-14"><a href="#L-14"><span class="linenos">14</span></a><span class="sd"> >>> normalize_identifiers(expression).sql()</span> -</span><span id="L-15"><a href="#L-15"><span class="linenos">15</span></a><span class="sd"> 'SELECT bar.a AS a FROM "Foo".bar'</span> -</span><span id="L-16"><a href="#L-16"><span class="linenos">16</span></a> -</span><span id="L-17"><a href="#L-17"><span class="linenos">17</span></a><span class="sd"> Args:</span> -</span><span id="L-18"><a href="#L-18"><span class="linenos">18</span></a><span class="sd"> expression: The expression to transform.</span> -</span><span id="L-19"><a href="#L-19"><span class="linenos">19</span></a><span class="sd"> dialect: The dialect to use in order to decide how to normalize identifiers.</span> -</span><span id="L-20"><a href="#L-20"><span class="linenos">20</span></a> -</span><span id="L-21"><a href="#L-21"><span class="linenos">21</span></a><span class="sd"> Returns:</span> -</span><span id="L-22"><a href="#L-22"><span class="linenos">22</span></a><span class="sd"> The transformed expression.</span> -</span><span id="L-23"><a href="#L-23"><span class="linenos">23</span></a><span class="sd"> """</span> -</span><span id="L-24"><a href="#L-24"><span class="linenos">24</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_normalize</span><span class="p">,</span> <span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-25"><a href="#L-25"><span class="linenos">25</span></a> -</span><span id="L-26"><a href="#L-26"><span class="linenos">26</span></a> -</span><span id="L-27"><a href="#L-27"><span class="linenos">27</span></a><span class="k">def</span> <span class="nf">_normalize</span><span class="p">(</span><span class="n">node</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="L-28"><a href="#L-28"><span class="linenos">28</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">node</span><span class="o">.</span><span class="n">quoted</span><span class="p">:</span> -</span><span id="L-29"><a href="#L-29"><span class="linenos">29</span></a> <span class="n">node</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="L-30"><a href="#L-30"><span class="linenos">30</span></a> <span class="s2">"this"</span><span class="p">,</span> -</span><span id="L-31"><a href="#L-31"><span class="linenos">31</span></a> <span class="n">node</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-32"><a href="#L-32"><span class="linenos">32</span></a> <span class="k">if</span> <span class="n">dialect</span> <span class="ow">in</span> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> -</span><span id="L-33"><a href="#L-33"><span class="linenos">33</span></a> <span class="k">else</span> <span class="n">node</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> -</span><span id="L-34"><a href="#L-34"><span class="linenos">34</span></a> <span class="p">)</span> -</span><span id="L-35"><a href="#L-35"><span class="linenos">35</span></a> -</span><span id="L-36"><a href="#L-36"><span class="linenos">36</span></a> <span class="k">return</span> <span class="n">node</span> +</span><span id="L-5"><a href="#L-5"><span class="linenos"> 5</span></a><span class="k">def</span> <span class="nf">normalize_identifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="L-6"><a href="#L-6"><span class="linenos"> 6</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-7"><a href="#L-7"><span class="linenos"> 7</span></a><span class="sd"> Normalize all unquoted identifiers to either lower or upper case, depending</span> +</span><span id="L-8"><a href="#L-8"><span class="linenos"> 8</span></a><span class="sd"> on the dialect. This essentially makes those identifiers case-insensitive.</span> +</span><span id="L-9"><a href="#L-9"><span class="linenos"> 9</span></a> +</span><span id="L-10"><a href="#L-10"><span class="linenos">10</span></a><span class="sd"> Note:</span> +</span><span id="L-11"><a href="#L-11"><span class="linenos">11</span></a><span class="sd"> Some dialects (e.g. BigQuery) treat identifiers as case-insensitive even</span> +</span><span id="L-12"><a href="#L-12"><span class="linenos">12</span></a><span class="sd"> when they're quoted, so in these cases all identifiers are normalized.</span> +</span><span id="L-13"><a href="#L-13"><span class="linenos">13</span></a> +</span><span id="L-14"><a href="#L-14"><span class="linenos">14</span></a><span class="sd"> Example:</span> +</span><span id="L-15"><a href="#L-15"><span class="linenos">15</span></a><span class="sd"> >>> import sqlglot</span> +</span><span id="L-16"><a href="#L-16"><span class="linenos">16</span></a><span class="sd"> >>> expression = sqlglot.parse_one('SELECT Bar.A AS A FROM "Foo".Bar')</span> +</span><span id="L-17"><a href="#L-17"><span class="linenos">17</span></a><span class="sd"> >>> normalize_identifiers(expression).sql()</span> +</span><span id="L-18"><a href="#L-18"><span class="linenos">18</span></a><span class="sd"> 'SELECT bar.a AS a FROM "Foo".bar'</span> +</span><span id="L-19"><a href="#L-19"><span class="linenos">19</span></a> +</span><span id="L-20"><a href="#L-20"><span class="linenos">20</span></a><span class="sd"> Args:</span> +</span><span id="L-21"><a href="#L-21"><span class="linenos">21</span></a><span class="sd"> expression: The expression to transform.</span> +</span><span id="L-22"><a href="#L-22"><span class="linenos">22</span></a><span class="sd"> dialect: The dialect to use in order to decide how to normalize identifiers.</span> +</span><span id="L-23"><a href="#L-23"><span class="linenos">23</span></a> +</span><span id="L-24"><a href="#L-24"><span class="linenos">24</span></a><span class="sd"> Returns:</span> +</span><span id="L-25"><a href="#L-25"><span class="linenos">25</span></a><span class="sd"> The transformed expression.</span> +</span><span id="L-26"><a href="#L-26"><span class="linenos">26</span></a><span class="sd"> """</span> +</span><span id="L-27"><a href="#L-27"><span class="linenos">27</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span><span class="o">.</span><span class="n">normalize_identifier</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> </span></pre></div> @@ -107,30 +98,41 @@ </div> <a class="headerlink" href="#normalize_identifiers"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="normalize_identifiers-7"><a href="#normalize_identifiers-7"><span class="linenos"> 7</span></a><span class="k">def</span> <span class="nf">normalize_identifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="normalize_identifiers-8"><a href="#normalize_identifiers-8"><span class="linenos"> 8</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="normalize_identifiers-9"><a href="#normalize_identifiers-9"><span class="linenos"> 9</span></a><span class="sd"> Normalize all unquoted identifiers to either lower or upper case, depending on</span> -</span><span id="normalize_identifiers-10"><a href="#normalize_identifiers-10"><span class="linenos">10</span></a><span class="sd"> the dialect. This essentially makes those identifiers case-insensitive.</span> -</span><span id="normalize_identifiers-11"><a href="#normalize_identifiers-11"><span class="linenos">11</span></a> -</span><span id="normalize_identifiers-12"><a href="#normalize_identifiers-12"><span class="linenos">12</span></a><span class="sd"> Example:</span> -</span><span id="normalize_identifiers-13"><a href="#normalize_identifiers-13"><span class="linenos">13</span></a><span class="sd"> >>> import sqlglot</span> -</span><span id="normalize_identifiers-14"><a href="#normalize_identifiers-14"><span class="linenos">14</span></a><span class="sd"> >>> expression = sqlglot.parse_one('SELECT Bar.A AS A FROM "Foo".Bar')</span> -</span><span id="normalize_identifiers-15"><a href="#normalize_identifiers-15"><span class="linenos">15</span></a><span class="sd"> >>> normalize_identifiers(expression).sql()</span> -</span><span id="normalize_identifiers-16"><a href="#normalize_identifiers-16"><span class="linenos">16</span></a><span class="sd"> 'SELECT bar.a AS a FROM "Foo".bar'</span> -</span><span id="normalize_identifiers-17"><a href="#normalize_identifiers-17"><span class="linenos">17</span></a> -</span><span id="normalize_identifiers-18"><a href="#normalize_identifiers-18"><span class="linenos">18</span></a><span class="sd"> Args:</span> -</span><span id="normalize_identifiers-19"><a href="#normalize_identifiers-19"><span class="linenos">19</span></a><span class="sd"> expression: The expression to transform.</span> -</span><span id="normalize_identifiers-20"><a href="#normalize_identifiers-20"><span class="linenos">20</span></a><span class="sd"> dialect: The dialect to use in order to decide how to normalize identifiers.</span> -</span><span id="normalize_identifiers-21"><a href="#normalize_identifiers-21"><span class="linenos">21</span></a> -</span><span id="normalize_identifiers-22"><a href="#normalize_identifiers-22"><span class="linenos">22</span></a><span class="sd"> Returns:</span> -</span><span id="normalize_identifiers-23"><a href="#normalize_identifiers-23"><span class="linenos">23</span></a><span class="sd"> The transformed expression.</span> -</span><span id="normalize_identifiers-24"><a href="#normalize_identifiers-24"><span class="linenos">24</span></a><span class="sd"> """</span> -</span><span id="normalize_identifiers-25"><a href="#normalize_identifiers-25"><span class="linenos">25</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_normalize</span><span class="p">,</span> <span class="n">dialect</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="normalize_identifiers-6"><a href="#normalize_identifiers-6"><span class="linenos"> 6</span></a><span class="k">def</span> <span class="nf">normalize_identifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="normalize_identifiers-7"><a href="#normalize_identifiers-7"><span class="linenos"> 7</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="normalize_identifiers-8"><a href="#normalize_identifiers-8"><span class="linenos"> 8</span></a><span class="sd"> Normalize all unquoted identifiers to either lower or upper case, depending</span> +</span><span id="normalize_identifiers-9"><a href="#normalize_identifiers-9"><span class="linenos"> 9</span></a><span class="sd"> on the dialect. This essentially makes those identifiers case-insensitive.</span> +</span><span id="normalize_identifiers-10"><a href="#normalize_identifiers-10"><span class="linenos">10</span></a> +</span><span id="normalize_identifiers-11"><a href="#normalize_identifiers-11"><span class="linenos">11</span></a><span class="sd"> Note:</span> +</span><span id="normalize_identifiers-12"><a href="#normalize_identifiers-12"><span class="linenos">12</span></a><span class="sd"> Some dialects (e.g. BigQuery) treat identifiers as case-insensitive even</span> +</span><span id="normalize_identifiers-13"><a href="#normalize_identifiers-13"><span class="linenos">13</span></a><span class="sd"> when they're quoted, so in these cases all identifiers are normalized.</span> +</span><span id="normalize_identifiers-14"><a href="#normalize_identifiers-14"><span class="linenos">14</span></a> +</span><span id="normalize_identifiers-15"><a href="#normalize_identifiers-15"><span class="linenos">15</span></a><span class="sd"> Example:</span> +</span><span id="normalize_identifiers-16"><a href="#normalize_identifiers-16"><span class="linenos">16</span></a><span class="sd"> >>> import sqlglot</span> +</span><span id="normalize_identifiers-17"><a href="#normalize_identifiers-17"><span class="linenos">17</span></a><span class="sd"> >>> expression = sqlglot.parse_one('SELECT Bar.A AS A FROM "Foo".Bar')</span> +</span><span id="normalize_identifiers-18"><a href="#normalize_identifiers-18"><span class="linenos">18</span></a><span class="sd"> >>> normalize_identifiers(expression).sql()</span> +</span><span id="normalize_identifiers-19"><a href="#normalize_identifiers-19"><span class="linenos">19</span></a><span class="sd"> 'SELECT bar.a AS a FROM "Foo".bar'</span> +</span><span id="normalize_identifiers-20"><a href="#normalize_identifiers-20"><span class="linenos">20</span></a> +</span><span id="normalize_identifiers-21"><a href="#normalize_identifiers-21"><span class="linenos">21</span></a><span class="sd"> Args:</span> +</span><span id="normalize_identifiers-22"><a href="#normalize_identifiers-22"><span class="linenos">22</span></a><span class="sd"> expression: The expression to transform.</span> +</span><span id="normalize_identifiers-23"><a href="#normalize_identifiers-23"><span class="linenos">23</span></a><span class="sd"> dialect: The dialect to use in order to decide how to normalize identifiers.</span> +</span><span id="normalize_identifiers-24"><a href="#normalize_identifiers-24"><span class="linenos">24</span></a> +</span><span id="normalize_identifiers-25"><a href="#normalize_identifiers-25"><span class="linenos">25</span></a><span class="sd"> Returns:</span> +</span><span id="normalize_identifiers-26"><a href="#normalize_identifiers-26"><span class="linenos">26</span></a><span class="sd"> The transformed expression.</span> +</span><span id="normalize_identifiers-27"><a href="#normalize_identifiers-27"><span class="linenos">27</span></a><span class="sd"> """</span> +</span><span id="normalize_identifiers-28"><a href="#normalize_identifiers-28"><span class="linenos">28</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span><span class="o">.</span><span class="n">normalize_identifier</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> </span></pre></div> - <div class="docstring"><p>Normalize all unquoted identifiers to either lower or upper case, depending on -the dialect. This essentially makes those identifiers case-insensitive.</p> + <div class="docstring"><p>Normalize all unquoted identifiers to either lower or upper case, depending +on the dialect. This essentially makes those identifiers case-insensitive.</p> + +<h6 id="note">Note:</h6> + +<blockquote> + <p>Some dialects (e.g. BigQuery) treat identifiers as case-insensitive even + when they're quoted, so in these cases all identifiers are normalized.</p> +</blockquote> <h6 id="example">Example:</h6> diff --git a/docs/sqlglot/optimizer/optimize_joins.html b/docs/sqlglot/optimizer/optimize_joins.html index b914197..4ffa623 100644 --- a/docs/sqlglot/optimizer/optimize_joins.html +++ b/docs/sqlglot/optimizer/optimize_joins.html @@ -65,89 +65,88 @@ <label class="view-source-button" for="mod-optimize_joins-view-source"><span>View Source</span></label> - <div class="pdoc-code codehilite"><pre><span></span><span id="L-1"><a href="#L-1"><span class="linenos"> 1</span></a><span class="kn">from</span> <span class="nn">sqlglot</span> <span class="kn">import</span> <span class="n">exp</span> -</span><span id="L-2"><a href="#L-2"><span class="linenos"> 2</span></a><span class="kn">from</span> <span class="nn">sqlglot.helper</span> <span class="kn">import</span> <span class="n">tsort</span> -</span><span id="L-3"><a href="#L-3"><span class="linenos"> 3</span></a> -</span><span id="L-4"><a href="#L-4"><span class="linenos"> 4</span></a><span class="n">JOIN_ATTRS</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"on"</span><span class="p">,</span> <span class="s2">"side"</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">,</span> <span class="s2">"method"</span><span class="p">)</span> -</span><span id="L-5"><a href="#L-5"><span class="linenos"> 5</span></a> -</span><span id="L-6"><a href="#L-6"><span class="linenos"> 6</span></a> -</span><span id="L-7"><a href="#L-7"><span class="linenos"> 7</span></a><span class="k">def</span> <span class="nf">optimize_joins</span><span class="p">(</span><span class="n">expression</span><span class="p">):</span> -</span><span id="L-8"><a href="#L-8"><span class="linenos"> 8</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-9"><a href="#L-9"><span class="linenos"> 9</span></a><span class="sd"> Removes cross joins if possible and reorder joins based on predicate dependencies.</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="L-1"><a href="#L-1"><span class="linenos"> 1</span></a><span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">annotations</span> +</span><span id="L-2"><a href="#L-2"><span class="linenos"> 2</span></a> +</span><span id="L-3"><a href="#L-3"><span class="linenos"> 3</span></a><span class="kn">import</span> <span class="nn">typing</span> <span class="k">as</span> <span class="nn">t</span> +</span><span id="L-4"><a href="#L-4"><span class="linenos"> 4</span></a> +</span><span id="L-5"><a href="#L-5"><span class="linenos"> 5</span></a><span class="kn">from</span> <span class="nn">sqlglot</span> <span class="kn">import</span> <span class="n">exp</span> +</span><span id="L-6"><a href="#L-6"><span class="linenos"> 6</span></a><span class="kn">from</span> <span class="nn">sqlglot.helper</span> <span class="kn">import</span> <span class="n">tsort</span> +</span><span id="L-7"><a href="#L-7"><span class="linenos"> 7</span></a> +</span><span id="L-8"><a href="#L-8"><span class="linenos"> 8</span></a><span class="n">JOIN_ATTRS</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"on"</span><span class="p">,</span> <span class="s2">"side"</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">,</span> <span class="s2">"method"</span><span class="p">)</span> +</span><span id="L-9"><a href="#L-9"><span class="linenos"> 9</span></a> </span><span id="L-10"><a href="#L-10"><span class="linenos">10</span></a> -</span><span id="L-11"><a href="#L-11"><span class="linenos">11</span></a><span class="sd"> Example:</span> -</span><span id="L-12"><a href="#L-12"><span class="linenos">12</span></a><span class="sd"> >>> from sqlglot import parse_one</span> -</span><span id="L-13"><a href="#L-13"><span class="linenos">13</span></a><span class="sd"> >>> optimize_joins(parse_one("SELECT * FROM x CROSS JOIN y JOIN z ON x.a = z.a AND y.a = z.a")).sql()</span> -</span><span id="L-14"><a href="#L-14"><span class="linenos">14</span></a><span class="sd"> 'SELECT * FROM x JOIN z ON x.a = z.a AND TRUE JOIN y ON y.a = z.a'</span> -</span><span id="L-15"><a href="#L-15"><span class="linenos">15</span></a><span class="sd"> """</span> -</span><span id="L-16"><a href="#L-16"><span class="linenos">16</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> -</span><span id="L-17"><a href="#L-17"><span class="linenos">17</span></a> <span class="n">references</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-18"><a href="#L-18"><span class="linenos">18</span></a> <span class="n">cross_joins</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-19"><a href="#L-19"><span class="linenos">19</span></a> -</span><span id="L-20"><a href="#L-20"><span class="linenos">20</span></a> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">select</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">,</span> <span class="p">[]):</span> -</span><span id="L-21"><a href="#L-21"><span class="linenos">21</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias_or_name</span> -</span><span id="L-22"><a href="#L-22"><span class="linenos">22</span></a> <span class="n">tables</span> <span class="o">=</span> <span class="n">other_table_names</span><span class="p">(</span><span class="n">join</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span> -</span><span id="L-23"><a href="#L-23"><span class="linenos">23</span></a> -</span><span id="L-24"><a href="#L-24"><span class="linenos">24</span></a> <span class="k">if</span> <span class="n">tables</span><span class="p">:</span> -</span><span id="L-25"><a href="#L-25"><span class="linenos">25</span></a> <span class="k">for</span> <span class="n">table</span> <span class="ow">in</span> <span class="n">tables</span><span class="p">:</span> -</span><span id="L-26"><a href="#L-26"><span class="linenos">26</span></a> <span class="n">references</span><span class="p">[</span><span class="n">table</span><span class="p">]</span> <span class="o">=</span> <span class="n">references</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="p">[])</span> <span class="o">+</span> <span class="p">[</span><span class="n">join</span><span class="p">]</span> -</span><span id="L-27"><a href="#L-27"><span class="linenos">27</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-28"><a href="#L-28"><span class="linenos">28</span></a> <span class="n">cross_joins</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">name</span><span class="p">,</span> <span class="n">join</span><span class="p">))</span> -</span><span id="L-29"><a href="#L-29"><span class="linenos">29</span></a> -</span><span id="L-30"><a href="#L-30"><span class="linenos">30</span></a> <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">cross_joins</span><span class="p">:</span> -</span><span id="L-31"><a href="#L-31"><span class="linenos">31</span></a> <span class="k">for</span> <span class="n">dep</span> <span class="ow">in</span> <span class="n">references</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="p">[]):</span> -</span><span id="L-32"><a href="#L-32"><span class="linenos">32</span></a> <span class="n">on</span> <span class="o">=</span> <span class="n">dep</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"on"</span><span class="p">]</span> +</span><span id="L-11"><a href="#L-11"><span class="linenos">11</span></a><span class="k">def</span> <span class="nf">optimize_joins</span><span class="p">(</span><span class="n">expression</span><span class="p">):</span> +</span><span id="L-12"><a href="#L-12"><span class="linenos">12</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-13"><a href="#L-13"><span class="linenos">13</span></a><span class="sd"> Removes cross joins if possible and reorder joins based on predicate dependencies.</span> +</span><span id="L-14"><a href="#L-14"><span class="linenos">14</span></a> +</span><span id="L-15"><a href="#L-15"><span class="linenos">15</span></a><span class="sd"> Example:</span> +</span><span id="L-16"><a href="#L-16"><span class="linenos">16</span></a><span class="sd"> >>> from sqlglot import parse_one</span> +</span><span id="L-17"><a href="#L-17"><span class="linenos">17</span></a><span class="sd"> >>> optimize_joins(parse_one("SELECT * FROM x CROSS JOIN y JOIN z ON x.a = z.a AND y.a = z.a")).sql()</span> +</span><span id="L-18"><a href="#L-18"><span class="linenos">18</span></a><span class="sd"> 'SELECT * FROM x JOIN z ON x.a = z.a AND TRUE JOIN y ON y.a = z.a'</span> +</span><span id="L-19"><a href="#L-19"><span class="linenos">19</span></a><span class="sd"> """</span> +</span><span id="L-20"><a href="#L-20"><span class="linenos">20</span></a> +</span><span id="L-21"><a href="#L-21"><span class="linenos">21</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> +</span><span id="L-22"><a href="#L-22"><span class="linenos">22</span></a> <span class="n">references</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-23"><a href="#L-23"><span class="linenos">23</span></a> <span class="n">cross_joins</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-24"><a href="#L-24"><span class="linenos">24</span></a> +</span><span id="L-25"><a href="#L-25"><span class="linenos">25</span></a> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">select</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">,</span> <span class="p">[]):</span> +</span><span id="L-26"><a href="#L-26"><span class="linenos">26</span></a> <span class="n">tables</span> <span class="o">=</span> <span class="n">other_table_names</span><span class="p">(</span><span class="n">join</span><span class="p">)</span> +</span><span id="L-27"><a href="#L-27"><span class="linenos">27</span></a> +</span><span id="L-28"><a href="#L-28"><span class="linenos">28</span></a> <span class="k">if</span> <span class="n">tables</span><span class="p">:</span> +</span><span id="L-29"><a href="#L-29"><span class="linenos">29</span></a> <span class="k">for</span> <span class="n">table</span> <span class="ow">in</span> <span class="n">tables</span><span class="p">:</span> +</span><span id="L-30"><a href="#L-30"><span class="linenos">30</span></a> <span class="n">references</span><span class="p">[</span><span class="n">table</span><span class="p">]</span> <span class="o">=</span> <span class="n">references</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="p">[])</span> <span class="o">+</span> <span class="p">[</span><span class="n">join</span><span class="p">]</span> +</span><span id="L-31"><a href="#L-31"><span class="linenos">31</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-32"><a href="#L-32"><span class="linenos">32</span></a> <span class="n">cross_joins</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">,</span> <span class="n">join</span><span class="p">))</span> </span><span id="L-33"><a href="#L-33"><span class="linenos">33</span></a> -</span><span id="L-34"><a href="#L-34"><span class="linenos">34</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">on</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Connector</span><span class="p">):</span> -</span><span id="L-35"><a href="#L-35"><span class="linenos">35</span></a> <span class="k">for</span> <span class="n">predicate</span> <span class="ow">in</span> <span class="n">on</span><span class="o">.</span><span class="n">flatten</span><span class="p">():</span> -</span><span id="L-36"><a href="#L-36"><span class="linenos">36</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">predicate</span><span class="p">):</span> -</span><span id="L-37"><a href="#L-37"><span class="linenos">37</span></a> <span class="n">predicate</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">true</span><span class="p">())</span> -</span><span id="L-38"><a href="#L-38"><span class="linenos">38</span></a> <span class="n">join</span><span class="o">.</span><span class="n">on</span><span class="p">(</span><span class="n">predicate</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-39"><a href="#L-39"><span class="linenos">39</span></a> -</span><span id="L-40"><a href="#L-40"><span class="linenos">40</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">reorder_joins</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-41"><a href="#L-41"><span class="linenos">41</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">normalize</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-42"><a href="#L-42"><span class="linenos">42</span></a> <span class="k">return</span> <span class="n">expression</span> -</span><span id="L-43"><a href="#L-43"><span class="linenos">43</span></a> -</span><span id="L-44"><a href="#L-44"><span class="linenos">44</span></a> -</span><span id="L-45"><a href="#L-45"><span class="linenos">45</span></a><span class="k">def</span> <span class="nf">reorder_joins</span><span class="p">(</span><span class="n">expression</span><span class="p">):</span> -</span><span id="L-46"><a href="#L-46"><span class="linenos">46</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-47"><a href="#L-47"><span class="linenos">47</span></a><span class="sd"> Reorder joins by topological sort order based on predicate references.</span> -</span><span id="L-48"><a href="#L-48"><span class="linenos">48</span></a><span class="sd"> """</span> -</span><span id="L-49"><a href="#L-49"><span class="linenos">49</span></a> <span class="k">for</span> <span class="n">from_</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">):</span> -</span><span id="L-50"><a href="#L-50"><span class="linenos">50</span></a> <span class="n">head</span> <span class="o">=</span> <span class="n">from_</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-51"><a href="#L-51"><span class="linenos">51</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">from_</span><span class="o">.</span><span class="n">parent</span> -</span><span id="L-52"><a href="#L-52"><span class="linenos">52</span></a> <span class="n">joins</span> <span class="o">=</span> <span class="p">{</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="n">join</span> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">parent</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">,</span> <span class="p">[])}</span> -</span><span id="L-53"><a href="#L-53"><span class="linenos">53</span></a> <span class="n">dag</span> <span class="o">=</span> <span class="p">{</span><span class="n">head</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="p">[]}</span> -</span><span id="L-54"><a href="#L-54"><span class="linenos">54</span></a> -</span><span id="L-55"><a href="#L-55"><span class="linenos">55</span></a> <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">joins</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> -</span><span id="L-56"><a href="#L-56"><span class="linenos">56</span></a> <span class="n">dag</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">other_table_names</span><span class="p">(</span><span class="n">join</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span> -</span><span id="L-57"><a href="#L-57"><span class="linenos">57</span></a> -</span><span id="L-58"><a href="#L-58"><span class="linenos">58</span></a> <span class="n">parent</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="L-59"><a href="#L-59"><span class="linenos">59</span></a> <span class="s2">"joins"</span><span class="p">,</span> -</span><span id="L-60"><a href="#L-60"><span class="linenos">60</span></a> <span class="p">[</span><span class="n">joins</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">tsort</span><span class="p">(</span><span class="n">dag</span><span class="p">)</span> <span class="k">if</span> <span class="n">name</span> <span class="o">!=</span> <span class="n">head</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">],</span> -</span><span id="L-61"><a href="#L-61"><span class="linenos">61</span></a> <span class="p">)</span> -</span><span id="L-62"><a href="#L-62"><span class="linenos">62</span></a> <span class="k">return</span> <span class="n">expression</span> -</span><span id="L-63"><a href="#L-63"><span class="linenos">63</span></a> -</span><span id="L-64"><a href="#L-64"><span class="linenos">64</span></a> -</span><span id="L-65"><a href="#L-65"><span class="linenos">65</span></a><span class="k">def</span> <span class="nf">normalize</span><span class="p">(</span><span class="n">expression</span><span class="p">):</span> -</span><span id="L-66"><a href="#L-66"><span class="linenos">66</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-67"><a href="#L-67"><span class="linenos">67</span></a><span class="sd"> Remove INNER and OUTER from joins as they are optional.</span> -</span><span id="L-68"><a href="#L-68"><span class="linenos">68</span></a><span class="sd"> """</span> -</span><span id="L-69"><a href="#L-69"><span class="linenos">69</span></a> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> -</span><span id="L-70"><a href="#L-70"><span class="linenos">70</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">any</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">JOIN_ATTRS</span><span class="p">):</span> -</span><span id="L-71"><a href="#L-71"><span class="linenos">71</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"CROSS"</span><span class="p">)</span> -</span><span id="L-72"><a href="#L-72"><span class="linenos">72</span></a> -</span><span id="L-73"><a href="#L-73"><span class="linenos">73</span></a> <span class="k">if</span> <span class="n">join</span><span class="o">.</span><span class="n">kind</span> <span class="o">!=</span> <span class="s2">"CROSS"</span><span class="p">:</span> -</span><span id="L-74"><a href="#L-74"><span class="linenos">74</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="L-75"><a href="#L-75"><span class="linenos">75</span></a> <span class="k">return</span> <span class="n">expression</span> -</span><span id="L-76"><a href="#L-76"><span class="linenos">76</span></a> -</span><span id="L-77"><a href="#L-77"><span class="linenos">77</span></a> -</span><span id="L-78"><a href="#L-78"><span class="linenos">78</span></a><span class="k">def</span> <span class="nf">other_table_names</span><span class="p">(</span><span class="n">join</span><span class="p">,</span> <span class="n">exclude</span><span class="p">):</span> -</span><span id="L-79"><a href="#L-79"><span class="linenos">79</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="L-80"><a href="#L-80"><span class="linenos">80</span></a> <span class="n">name</span> -</span><span id="L-81"><a href="#L-81"><span class="linenos">81</span></a> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">join</span><span 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 class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">true</span><span class="p">()))</span> -</span><span id="L-82"><a href="#L-82"><span class="linenos">82</span></a> <span class="k">if</span> <span class="n">name</span> <span class="o">!=</span> <span class="n">exclude</span> -</span><span id="L-83"><a href="#L-83"><span class="linenos">83</span></a> <span class="p">]</span> +</span><span id="L-34"><a href="#L-34"><span class="linenos">34</span></a> <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">cross_joins</span><span class="p">:</span> +</span><span id="L-35"><a href="#L-35"><span class="linenos">35</span></a> <span class="k">for</span> <span class="n">dep</span> <span class="ow">in</span> <span class="n">references</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="p">[]):</span> +</span><span id="L-36"><a href="#L-36"><span class="linenos">36</span></a> <span class="n">on</span> <span class="o">=</span> <span class="n">dep</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"on"</span><span class="p">]</span> +</span><span id="L-37"><a href="#L-37"><span class="linenos">37</span></a> +</span><span id="L-38"><a href="#L-38"><span class="linenos">38</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">on</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Connector</span><span class="p">):</span> +</span><span id="L-39"><a href="#L-39"><span class="linenos">39</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">other_table_names</span><span class="p">(</span><span class="n">dep</span><span class="p">))</span> <span class="o"><</span> <span class="mi">2</span><span class="p">:</span> +</span><span id="L-40"><a href="#L-40"><span class="linenos">40</span></a> <span class="k">continue</span> +</span><span id="L-41"><a href="#L-41"><span class="linenos">41</span></a> +</span><span id="L-42"><a href="#L-42"><span class="linenos">42</span></a> <span class="k">for</span> <span class="n">predicate</span> <span class="ow">in</span> <span class="n">on</span><span class="o">.</span><span class="n">flatten</span><span class="p">():</span> +</span><span id="L-43"><a href="#L-43"><span class="linenos">43</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">predicate</span><span class="p">):</span> +</span><span id="L-44"><a href="#L-44"><span class="linenos">44</span></a> <span class="n">predicate</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">true</span><span class="p">())</span> +</span><span id="L-45"><a href="#L-45"><span class="linenos">45</span></a> <span class="n">join</span><span class="o">.</span><span class="n">on</span><span class="p">(</span><span class="n">predicate</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-46"><a href="#L-46"><span class="linenos">46</span></a> +</span><span id="L-47"><a href="#L-47"><span class="linenos">47</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">reorder_joins</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-48"><a href="#L-48"><span class="linenos">48</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">normalize</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-49"><a href="#L-49"><span class="linenos">49</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-50"><a href="#L-50"><span class="linenos">50</span></a> +</span><span id="L-51"><a href="#L-51"><span class="linenos">51</span></a> +</span><span id="L-52"><a href="#L-52"><span class="linenos">52</span></a><span class="k">def</span> <span class="nf">reorder_joins</span><span class="p">(</span><span class="n">expression</span><span class="p">):</span> +</span><span id="L-53"><a href="#L-53"><span class="linenos">53</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-54"><a href="#L-54"><span class="linenos">54</span></a><span class="sd"> Reorder joins by topological sort order based on predicate references.</span> +</span><span id="L-55"><a href="#L-55"><span class="linenos">55</span></a><span class="sd"> """</span> +</span><span id="L-56"><a href="#L-56"><span class="linenos">56</span></a> <span class="k">for</span> <span class="n">from_</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">):</span> +</span><span id="L-57"><a href="#L-57"><span class="linenos">57</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">from_</span><span class="o">.</span><span class="n">parent</span> +</span><span id="L-58"><a href="#L-58"><span class="linenos">58</span></a> <span class="n">joins</span> <span class="o">=</span> <span class="p">{</span><span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="n">join</span> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">parent</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">,</span> <span class="p">[])}</span> +</span><span id="L-59"><a href="#L-59"><span class="linenos">59</span></a> <span class="n">dag</span> <span class="o">=</span> <span class="p">{</span><span class="n">name</span><span class="p">:</span> <span class="n">other_table_names</span><span class="p">(</span><span class="n">join</span><span class="p">)</span> <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">joins</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span> +</span><span id="L-60"><a href="#L-60"><span class="linenos">60</span></a> <span class="n">parent</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="L-61"><a href="#L-61"><span class="linenos">61</span></a> <span class="s2">"joins"</span><span class="p">,</span> +</span><span id="L-62"><a href="#L-62"><span class="linenos">62</span></a> <span class="p">[</span><span class="n">joins</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">tsort</span><span class="p">(</span><span class="n">dag</span><span class="p">)</span> <span class="k">if</span> <span class="n">name</span> <span class="o">!=</span> <span class="n">from_</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">],</span> +</span><span id="L-63"><a href="#L-63"><span class="linenos">63</span></a> <span class="p">)</span> +</span><span id="L-64"><a href="#L-64"><span class="linenos">64</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-65"><a href="#L-65"><span class="linenos">65</span></a> +</span><span id="L-66"><a href="#L-66"><span class="linenos">66</span></a> +</span><span id="L-67"><a href="#L-67"><span class="linenos">67</span></a><span class="k">def</span> <span class="nf">normalize</span><span class="p">(</span><span class="n">expression</span><span class="p">):</span> +</span><span id="L-68"><a href="#L-68"><span class="linenos">68</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-69"><a href="#L-69"><span class="linenos">69</span></a><span class="sd"> Remove INNER and OUTER from joins as they are optional.</span> +</span><span id="L-70"><a href="#L-70"><span class="linenos">70</span></a><span class="sd"> """</span> +</span><span id="L-71"><a href="#L-71"><span class="linenos">71</span></a> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> +</span><span id="L-72"><a href="#L-72"><span class="linenos">72</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">any</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">JOIN_ATTRS</span><span class="p">):</span> +</span><span id="L-73"><a href="#L-73"><span class="linenos">73</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"CROSS"</span><span class="p">)</span> +</span><span id="L-74"><a href="#L-74"><span class="linenos">74</span></a> +</span><span id="L-75"><a href="#L-75"><span class="linenos">75</span></a> <span class="k">if</span> <span class="n">join</span><span class="o">.</span><span class="n">kind</span> <span class="o">!=</span> <span class="s2">"CROSS"</span><span class="p">:</span> +</span><span id="L-76"><a href="#L-76"><span class="linenos">76</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="L-77"><a href="#L-77"><span class="linenos">77</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-78"><a href="#L-78"><span class="linenos">78</span></a> +</span><span id="L-79"><a href="#L-79"><span class="linenos">79</span></a> +</span><span id="L-80"><a href="#L-80"><span class="linenos">80</span></a><span class="k">def</span> <span class="nf">other_table_names</span><span class="p">(</span><span class="n">join</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="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="L-81"><a href="#L-81"><span class="linenos">81</span></a> <span class="n">on</span> <span class="o">=</span> <span class="n">join</span><span 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-82"><a href="#L-82"><span class="linenos">82</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">on</span><span class="p">,</span> <span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">)</span> <span class="k">if</span> <span class="n">on</span> <span class="k">else</span> <span class="nb">set</span><span class="p">()</span> </span></pre></div> @@ -163,42 +162,45 @@ </div> <a class="headerlink" href="#optimize_joins"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="optimize_joins-8"><a href="#optimize_joins-8"><span class="linenos"> 8</span></a><span class="k">def</span> <span class="nf">optimize_joins</span><span class="p">(</span><span class="n">expression</span><span class="p">):</span> -</span><span id="optimize_joins-9"><a href="#optimize_joins-9"><span class="linenos"> 9</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="optimize_joins-10"><a href="#optimize_joins-10"><span class="linenos">10</span></a><span class="sd"> Removes cross joins if possible and reorder joins based on predicate dependencies.</span> -</span><span id="optimize_joins-11"><a href="#optimize_joins-11"><span class="linenos">11</span></a> -</span><span id="optimize_joins-12"><a href="#optimize_joins-12"><span class="linenos">12</span></a><span class="sd"> Example:</span> -</span><span id="optimize_joins-13"><a href="#optimize_joins-13"><span class="linenos">13</span></a><span class="sd"> >>> from sqlglot import parse_one</span> -</span><span id="optimize_joins-14"><a href="#optimize_joins-14"><span class="linenos">14</span></a><span class="sd"> >>> optimize_joins(parse_one("SELECT * FROM x CROSS JOIN y JOIN z ON x.a = z.a AND y.a = z.a")).sql()</span> -</span><span id="optimize_joins-15"><a href="#optimize_joins-15"><span class="linenos">15</span></a><span class="sd"> 'SELECT * FROM x JOIN z ON x.a = z.a AND TRUE JOIN y ON y.a = z.a'</span> -</span><span id="optimize_joins-16"><a href="#optimize_joins-16"><span class="linenos">16</span></a><span class="sd"> """</span> -</span><span id="optimize_joins-17"><a href="#optimize_joins-17"><span class="linenos">17</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> -</span><span id="optimize_joins-18"><a href="#optimize_joins-18"><span class="linenos">18</span></a> <span class="n">references</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="optimize_joins-19"><a href="#optimize_joins-19"><span class="linenos">19</span></a> <span class="n">cross_joins</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="optimize_joins-20"><a href="#optimize_joins-20"><span class="linenos">20</span></a> -</span><span id="optimize_joins-21"><a href="#optimize_joins-21"><span class="linenos">21</span></a> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">select</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">,</span> <span class="p">[]):</span> -</span><span id="optimize_joins-22"><a href="#optimize_joins-22"><span class="linenos">22</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias_or_name</span> -</span><span id="optimize_joins-23"><a href="#optimize_joins-23"><span class="linenos">23</span></a> <span class="n">tables</span> <span class="o">=</span> <span class="n">other_table_names</span><span class="p">(</span><span class="n">join</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span> -</span><span id="optimize_joins-24"><a href="#optimize_joins-24"><span class="linenos">24</span></a> -</span><span id="optimize_joins-25"><a href="#optimize_joins-25"><span class="linenos">25</span></a> <span class="k">if</span> <span class="n">tables</span><span class="p">:</span> -</span><span id="optimize_joins-26"><a href="#optimize_joins-26"><span class="linenos">26</span></a> <span class="k">for</span> <span class="n">table</span> <span class="ow">in</span> <span class="n">tables</span><span class="p">:</span> -</span><span id="optimize_joins-27"><a href="#optimize_joins-27"><span class="linenos">27</span></a> <span class="n">references</span><span class="p">[</span><span class="n">table</span><span class="p">]</span> <span class="o">=</span> <span class="n">references</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="p">[])</span> <span class="o">+</span> <span class="p">[</span><span class="n">join</span><span class="p">]</span> -</span><span id="optimize_joins-28"><a href="#optimize_joins-28"><span class="linenos">28</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="optimize_joins-29"><a href="#optimize_joins-29"><span class="linenos">29</span></a> <span class="n">cross_joins</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">name</span><span class="p">,</span> <span class="n">join</span><span class="p">))</span> -</span><span id="optimize_joins-30"><a href="#optimize_joins-30"><span class="linenos">30</span></a> -</span><span id="optimize_joins-31"><a href="#optimize_joins-31"><span class="linenos">31</span></a> <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">cross_joins</span><span class="p">:</span> -</span><span id="optimize_joins-32"><a href="#optimize_joins-32"><span class="linenos">32</span></a> <span class="k">for</span> <span class="n">dep</span> <span class="ow">in</span> <span class="n">references</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="p">[]):</span> -</span><span id="optimize_joins-33"><a href="#optimize_joins-33"><span class="linenos">33</span></a> <span class="n">on</span> <span class="o">=</span> <span class="n">dep</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"on"</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="optimize_joins-12"><a href="#optimize_joins-12"><span class="linenos">12</span></a><span class="k">def</span> <span class="nf">optimize_joins</span><span class="p">(</span><span class="n">expression</span><span class="p">):</span> +</span><span id="optimize_joins-13"><a href="#optimize_joins-13"><span class="linenos">13</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="optimize_joins-14"><a href="#optimize_joins-14"><span class="linenos">14</span></a><span class="sd"> Removes cross joins if possible and reorder joins based on predicate dependencies.</span> +</span><span id="optimize_joins-15"><a href="#optimize_joins-15"><span class="linenos">15</span></a> +</span><span id="optimize_joins-16"><a href="#optimize_joins-16"><span class="linenos">16</span></a><span class="sd"> Example:</span> +</span><span id="optimize_joins-17"><a href="#optimize_joins-17"><span class="linenos">17</span></a><span class="sd"> >>> from sqlglot import parse_one</span> +</span><span id="optimize_joins-18"><a href="#optimize_joins-18"><span class="linenos">18</span></a><span class="sd"> >>> optimize_joins(parse_one("SELECT * FROM x CROSS JOIN y JOIN z ON x.a = z.a AND y.a = z.a")).sql()</span> +</span><span id="optimize_joins-19"><a href="#optimize_joins-19"><span class="linenos">19</span></a><span class="sd"> 'SELECT * FROM x JOIN z ON x.a = z.a AND TRUE JOIN y ON y.a = z.a'</span> +</span><span id="optimize_joins-20"><a href="#optimize_joins-20"><span class="linenos">20</span></a><span class="sd"> """</span> +</span><span id="optimize_joins-21"><a href="#optimize_joins-21"><span class="linenos">21</span></a> +</span><span id="optimize_joins-22"><a href="#optimize_joins-22"><span class="linenos">22</span></a> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> +</span><span id="optimize_joins-23"><a href="#optimize_joins-23"><span class="linenos">23</span></a> <span class="n">references</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="optimize_joins-24"><a href="#optimize_joins-24"><span class="linenos">24</span></a> <span class="n">cross_joins</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="optimize_joins-25"><a href="#optimize_joins-25"><span class="linenos">25</span></a> +</span><span id="optimize_joins-26"><a href="#optimize_joins-26"><span class="linenos">26</span></a> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">select</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">,</span> <span class="p">[]):</span> +</span><span id="optimize_joins-27"><a href="#optimize_joins-27"><span class="linenos">27</span></a> <span class="n">tables</span> <span class="o">=</span> <span class="n">other_table_names</span><span class="p">(</span><span class="n">join</span><span class="p">)</span> +</span><span id="optimize_joins-28"><a href="#optimize_joins-28"><span class="linenos">28</span></a> +</span><span id="optimize_joins-29"><a href="#optimize_joins-29"><span class="linenos">29</span></a> <span class="k">if</span> <span class="n">tables</span><span class="p">:</span> +</span><span id="optimize_joins-30"><a href="#optimize_joins-30"><span class="linenos">30</span></a> <span class="k">for</span> <span class="n">table</span> <span class="ow">in</span> <span class="n">tables</span><span class="p">:</span> +</span><span id="optimize_joins-31"><a href="#optimize_joins-31"><span class="linenos">31</span></a> <span class="n">references</span><span class="p">[</span><span class="n">table</span><span class="p">]</span> <span class="o">=</span> <span class="n">references</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="p">[])</span> <span class="o">+</span> <span class="p">[</span><span class="n">join</span><span class="p">]</span> +</span><span id="optimize_joins-32"><a href="#optimize_joins-32"><span class="linenos">32</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="optimize_joins-33"><a href="#optimize_joins-33"><span class="linenos">33</span></a> <span class="n">cross_joins</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">,</span> <span class="n">join</span><span class="p">))</span> </span><span id="optimize_joins-34"><a href="#optimize_joins-34"><span class="linenos">34</span></a> -</span><span id="optimize_joins-35"><a href="#optimize_joins-35"><span class="linenos">35</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">on</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Connector</span><span class="p">):</span> -</span><span id="optimize_joins-36"><a href="#optimize_joins-36"><span class="linenos">36</span></a> <span class="k">for</span> <span class="n">predicate</span> <span class="ow">in</span> <span class="n">on</span><span class="o">.</span><span class="n">flatten</span><span class="p">():</span> -</span><span id="optimize_joins-37"><a href="#optimize_joins-37"><span class="linenos">37</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">predicate</span><span class="p">):</span> -</span><span id="optimize_joins-38"><a href="#optimize_joins-38"><span class="linenos">38</span></a> <span class="n">predicate</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">true</span><span class="p">())</span> -</span><span id="optimize_joins-39"><a href="#optimize_joins-39"><span class="linenos">39</span></a> <span class="n">join</span><span class="o">.</span><span class="n">on</span><span class="p">(</span><span class="n">predicate</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="optimize_joins-40"><a href="#optimize_joins-40"><span class="linenos">40</span></a> -</span><span id="optimize_joins-41"><a href="#optimize_joins-41"><span class="linenos">41</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">reorder_joins</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="optimize_joins-42"><a href="#optimize_joins-42"><span class="linenos">42</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">normalize</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="optimize_joins-43"><a href="#optimize_joins-43"><span class="linenos">43</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="optimize_joins-35"><a href="#optimize_joins-35"><span class="linenos">35</span></a> <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">cross_joins</span><span class="p">:</span> +</span><span id="optimize_joins-36"><a href="#optimize_joins-36"><span class="linenos">36</span></a> <span class="k">for</span> <span class="n">dep</span> <span class="ow">in</span> <span class="n">references</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="p">[]):</span> +</span><span id="optimize_joins-37"><a href="#optimize_joins-37"><span class="linenos">37</span></a> <span class="n">on</span> <span class="o">=</span> <span class="n">dep</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"on"</span><span class="p">]</span> +</span><span id="optimize_joins-38"><a href="#optimize_joins-38"><span class="linenos">38</span></a> +</span><span id="optimize_joins-39"><a href="#optimize_joins-39"><span class="linenos">39</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">on</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Connector</span><span class="p">):</span> +</span><span id="optimize_joins-40"><a href="#optimize_joins-40"><span class="linenos">40</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">other_table_names</span><span class="p">(</span><span class="n">dep</span><span class="p">))</span> <span class="o"><</span> <span class="mi">2</span><span class="p">:</span> +</span><span id="optimize_joins-41"><a href="#optimize_joins-41"><span class="linenos">41</span></a> <span class="k">continue</span> +</span><span id="optimize_joins-42"><a href="#optimize_joins-42"><span class="linenos">42</span></a> +</span><span id="optimize_joins-43"><a href="#optimize_joins-43"><span class="linenos">43</span></a> <span class="k">for</span> <span class="n">predicate</span> <span class="ow">in</span> <span class="n">on</span><span class="o">.</span><span class="n">flatten</span><span class="p">():</span> +</span><span id="optimize_joins-44"><a href="#optimize_joins-44"><span class="linenos">44</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">predicate</span><span class="p">):</span> +</span><span id="optimize_joins-45"><a href="#optimize_joins-45"><span class="linenos">45</span></a> <span class="n">predicate</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">true</span><span class="p">())</span> +</span><span id="optimize_joins-46"><a href="#optimize_joins-46"><span class="linenos">46</span></a> <span class="n">join</span><span class="o">.</span><span class="n">on</span><span class="p">(</span><span class="n">predicate</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="optimize_joins-47"><a href="#optimize_joins-47"><span class="linenos">47</span></a> +</span><span id="optimize_joins-48"><a href="#optimize_joins-48"><span class="linenos">48</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">reorder_joins</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="optimize_joins-49"><a href="#optimize_joins-49"><span class="linenos">49</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">normalize</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="optimize_joins-50"><a href="#optimize_joins-50"><span class="linenos">50</span></a> <span class="k">return</span> <span class="n">expression</span> </span></pre></div> @@ -229,24 +231,19 @@ </div> <a class="headerlink" href="#reorder_joins"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="reorder_joins-46"><a href="#reorder_joins-46"><span class="linenos">46</span></a><span class="k">def</span> <span class="nf">reorder_joins</span><span class="p">(</span><span class="n">expression</span><span class="p">):</span> -</span><span id="reorder_joins-47"><a href="#reorder_joins-47"><span class="linenos">47</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="reorder_joins-48"><a href="#reorder_joins-48"><span class="linenos">48</span></a><span class="sd"> Reorder joins by topological sort order based on predicate references.</span> -</span><span id="reorder_joins-49"><a href="#reorder_joins-49"><span class="linenos">49</span></a><span class="sd"> """</span> -</span><span id="reorder_joins-50"><a href="#reorder_joins-50"><span class="linenos">50</span></a> <span class="k">for</span> <span class="n">from_</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">):</span> -</span><span id="reorder_joins-51"><a href="#reorder_joins-51"><span class="linenos">51</span></a> <span class="n">head</span> <span class="o">=</span> <span class="n">from_</span><span class="o">.</span><span class="n">this</span> -</span><span id="reorder_joins-52"><a href="#reorder_joins-52"><span class="linenos">52</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">from_</span><span class="o">.</span><span class="n">parent</span> -</span><span id="reorder_joins-53"><a href="#reorder_joins-53"><span class="linenos">53</span></a> <span class="n">joins</span> <span class="o">=</span> <span class="p">{</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="n">join</span> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">parent</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">,</span> <span class="p">[])}</span> -</span><span id="reorder_joins-54"><a href="#reorder_joins-54"><span class="linenos">54</span></a> <span class="n">dag</span> <span class="o">=</span> <span class="p">{</span><span class="n">head</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="p">[]}</span> -</span><span id="reorder_joins-55"><a href="#reorder_joins-55"><span class="linenos">55</span></a> -</span><span id="reorder_joins-56"><a href="#reorder_joins-56"><span class="linenos">56</span></a> <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">joins</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> -</span><span id="reorder_joins-57"><a href="#reorder_joins-57"><span class="linenos">57</span></a> <span class="n">dag</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">other_table_names</span><span class="p">(</span><span class="n">join</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span> -</span><span id="reorder_joins-58"><a href="#reorder_joins-58"><span class="linenos">58</span></a> -</span><span id="reorder_joins-59"><a href="#reorder_joins-59"><span class="linenos">59</span></a> <span class="n">parent</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="reorder_joins-60"><a href="#reorder_joins-60"><span class="linenos">60</span></a> <span class="s2">"joins"</span><span class="p">,</span> -</span><span id="reorder_joins-61"><a href="#reorder_joins-61"><span class="linenos">61</span></a> <span class="p">[</span><span class="n">joins</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">tsort</span><span class="p">(</span><span class="n">dag</span><span class="p">)</span> <span class="k">if</span> <span class="n">name</span> <span class="o">!=</span> <span class="n">head</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">],</span> -</span><span id="reorder_joins-62"><a href="#reorder_joins-62"><span class="linenos">62</span></a> <span class="p">)</span> -</span><span id="reorder_joins-63"><a href="#reorder_joins-63"><span class="linenos">63</span></a> <span class="k">return</span> <span class="n">expression</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="reorder_joins-53"><a href="#reorder_joins-53"><span class="linenos">53</span></a><span class="k">def</span> <span class="nf">reorder_joins</span><span class="p">(</span><span class="n">expression</span><span class="p">):</span> +</span><span id="reorder_joins-54"><a href="#reorder_joins-54"><span class="linenos">54</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="reorder_joins-55"><a href="#reorder_joins-55"><span class="linenos">55</span></a><span class="sd"> Reorder joins by topological sort order based on predicate references.</span> +</span><span id="reorder_joins-56"><a href="#reorder_joins-56"><span class="linenos">56</span></a><span class="sd"> """</span> +</span><span id="reorder_joins-57"><a href="#reorder_joins-57"><span class="linenos">57</span></a> <span class="k">for</span> <span class="n">from_</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">):</span> +</span><span id="reorder_joins-58"><a href="#reorder_joins-58"><span class="linenos">58</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">from_</span><span class="o">.</span><span class="n">parent</span> +</span><span id="reorder_joins-59"><a href="#reorder_joins-59"><span class="linenos">59</span></a> <span class="n">joins</span> <span class="o">=</span> <span class="p">{</span><span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">:</span> <span class="n">join</span> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">parent</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">,</span> <span class="p">[])}</span> +</span><span id="reorder_joins-60"><a href="#reorder_joins-60"><span class="linenos">60</span></a> <span class="n">dag</span> <span class="o">=</span> <span class="p">{</span><span class="n">name</span><span class="p">:</span> <span class="n">other_table_names</span><span class="p">(</span><span class="n">join</span><span class="p">)</span> <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">joins</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span> +</span><span id="reorder_joins-61"><a href="#reorder_joins-61"><span class="linenos">61</span></a> <span class="n">parent</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="reorder_joins-62"><a href="#reorder_joins-62"><span class="linenos">62</span></a> <span class="s2">"joins"</span><span class="p">,</span> +</span><span id="reorder_joins-63"><a href="#reorder_joins-63"><span class="linenos">63</span></a> <span class="p">[</span><span class="n">joins</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">tsort</span><span class="p">(</span><span class="n">dag</span><span class="p">)</span> <span class="k">if</span> <span class="n">name</span> <span class="o">!=</span> <span class="n">from_</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">],</span> +</span><span id="reorder_joins-64"><a href="#reorder_joins-64"><span class="linenos">64</span></a> <span class="p">)</span> +</span><span id="reorder_joins-65"><a href="#reorder_joins-65"><span class="linenos">65</span></a> <span class="k">return</span> <span class="n">expression</span> </span></pre></div> @@ -266,17 +263,17 @@ </div> <a class="headerlink" href="#normalize"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="normalize-66"><a href="#normalize-66"><span class="linenos">66</span></a><span class="k">def</span> <span class="nf">normalize</span><span class="p">(</span><span class="n">expression</span><span class="p">):</span> -</span><span id="normalize-67"><a href="#normalize-67"><span class="linenos">67</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="normalize-68"><a href="#normalize-68"><span class="linenos">68</span></a><span class="sd"> Remove INNER and OUTER from joins as they are optional.</span> -</span><span id="normalize-69"><a href="#normalize-69"><span class="linenos">69</span></a><span class="sd"> """</span> -</span><span id="normalize-70"><a href="#normalize-70"><span class="linenos">70</span></a> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> -</span><span id="normalize-71"><a href="#normalize-71"><span class="linenos">71</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">any</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">JOIN_ATTRS</span><span class="p">):</span> -</span><span id="normalize-72"><a href="#normalize-72"><span class="linenos">72</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"CROSS"</span><span class="p">)</span> -</span><span id="normalize-73"><a href="#normalize-73"><span class="linenos">73</span></a> -</span><span id="normalize-74"><a href="#normalize-74"><span class="linenos">74</span></a> <span class="k">if</span> <span class="n">join</span><span class="o">.</span><span class="n">kind</span> <span class="o">!=</span> <span class="s2">"CROSS"</span><span class="p">:</span> -</span><span id="normalize-75"><a href="#normalize-75"><span class="linenos">75</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="normalize-76"><a href="#normalize-76"><span class="linenos">76</span></a> <span class="k">return</span> <span class="n">expression</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="normalize-68"><a href="#normalize-68"><span class="linenos">68</span></a><span class="k">def</span> <span class="nf">normalize</span><span class="p">(</span><span class="n">expression</span><span class="p">):</span> +</span><span id="normalize-69"><a href="#normalize-69"><span class="linenos">69</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="normalize-70"><a href="#normalize-70"><span class="linenos">70</span></a><span class="sd"> Remove INNER and OUTER from joins as they are optional.</span> +</span><span id="normalize-71"><a href="#normalize-71"><span class="linenos">71</span></a><span class="sd"> """</span> +</span><span id="normalize-72"><a href="#normalize-72"><span class="linenos">72</span></a> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">):</span> +</span><span id="normalize-73"><a href="#normalize-73"><span class="linenos">73</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">any</span><span class="p">(</span><span class="n">join</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">JOIN_ATTRS</span><span class="p">):</span> +</span><span id="normalize-74"><a href="#normalize-74"><span class="linenos">74</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"CROSS"</span><span class="p">)</span> +</span><span id="normalize-75"><a href="#normalize-75"><span class="linenos">75</span></a> +</span><span id="normalize-76"><a href="#normalize-76"><span class="linenos">76</span></a> <span class="k">if</span> <span class="n">join</span><span class="o">.</span><span class="n">kind</span> <span class="o">!=</span> <span class="s2">"CROSS"</span><span class="p">:</span> +</span><span id="normalize-77"><a href="#normalize-77"><span class="linenos">77</span></a> <span class="n">join</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="normalize-78"><a href="#normalize-78"><span class="linenos">78</span></a> <span class="k">return</span> <span class="n">expression</span> </span></pre></div> @@ -290,18 +287,15 @@ <div class="attr function"> <span class="def">def</span> - <span class="name">other_table_names</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">join</span>, </span><span class="param"><span class="n">exclude</span></span><span class="return-annotation">):</span></span> + <span class="name">other_table_names</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">join</span><span class="p">:</span> <span class="n"><a href="../expressions.html#Join">sqlglot.expressions.Join</a></span></span><span class="return-annotation">) -> <span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span>:</span></span> <label class="view-source-button" for="other_table_names-view-source"><span>View Source</span></label> </div> <a class="headerlink" href="#other_table_names"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="other_table_names-79"><a href="#other_table_names-79"><span class="linenos">79</span></a><span class="k">def</span> <span class="nf">other_table_names</span><span class="p">(</span><span class="n">join</span><span class="p">,</span> <span class="n">exclude</span><span class="p">):</span> -</span><span id="other_table_names-80"><a href="#other_table_names-80"><span class="linenos">80</span></a> <span class="k">return</span> <span class="p">[</span> -</span><span id="other_table_names-81"><a href="#other_table_names-81"><span class="linenos">81</span></a> <span class="n">name</span> -</span><span id="other_table_names-82"><a href="#other_table_names-82"><span class="linenos">82</span></a> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">join</span><span 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 class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">true</span><span class="p">()))</span> -</span><span id="other_table_names-83"><a href="#other_table_names-83"><span class="linenos">83</span></a> <span class="k">if</span> <span class="n">name</span> <span class="o">!=</span> <span class="n">exclude</span> -</span><span id="other_table_names-84"><a href="#other_table_names-84"><span class="linenos">84</span></a> <span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="other_table_names-81"><a href="#other_table_names-81"><span class="linenos">81</span></a><span class="k">def</span> <span class="nf">other_table_names</span><span class="p">(</span><span class="n">join</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="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="other_table_names-82"><a href="#other_table_names-82"><span class="linenos">82</span></a> <span class="n">on</span> <span class="o">=</span> <span class="n">join</span><span 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="other_table_names-83"><a href="#other_table_names-83"><span class="linenos">83</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">on</span><span class="p">,</span> <span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">)</span> <span class="k">if</span> <span class="n">on</span> <span class="k">else</span> <span class="nb">set</span><span class="p">()</span> </span></pre></div> diff --git a/docs/sqlglot/optimizer/optimizer.html b/docs/sqlglot/optimizer/optimizer.html index 1c9f314..044e4a0 100644 --- a/docs/sqlglot/optimizer/optimizer.html +++ b/docs/sqlglot/optimizer/optimizer.html @@ -159,7 +159,7 @@ <div class="attr function"> <span class="def">def</span> - <span class="name">optimize</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="n">expression</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n"><a href="../expressions.html#Expression">sqlglot.expressions.Expression</a></span>,</span><span class="param"> <span class="n">schema</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">dict</span><span class="p">,</span> <span class="n"><a href="../schema.html#Schema">sqlglot.schema.Schema</a></span><span class="p">,</span> <span class="n">NoneType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>,</span><span class="param"> <span class="n">db</span><span class="p">:</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><span class="param"> <span class="n">catalog</span><span class="p">:</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><span class="param"> <span class="n">dialect</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n"><a href="../dialects/dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></span><span class="p">,</span> <span class="n">Type</span><span class="p">[</span><span class="n"><a href="../dialects/dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></span><span class="p">],</span> <span class="n">NoneType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>,</span><span class="param"> <span class="n">rules</span><span class="p">:</span> <span class="n">Sequence</span><span class="p">[</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="o"><</span><span class="n">function</span> <span class="n">qualify</span> <span class="n">at</span> <span class="mh">0x7f5e613d37f0</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">pushdown_projections</span> <span class="n">at</span> <span class="mh">0x7f5e613d31c0</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">normalize</span> <span class="n">at</span> <span class="mh">0x7f5e614032e0</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">unnest_subqueries</span> <span class="n">at</span> <span class="mh">0x7f5e613d3be0</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">pushdown_predicates</span> <span class="n">at</span> <span class="mh">0x7f5e613d2050</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">optimize_joins</span> <span class="n">at</span> <span class="mh">0x7f5e613d1cf0</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">eliminate_subqueries</span> <span class="n">at</span> <span class="mh">0x7f5e613d0ee0</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">merge_subqueries</span> <span class="n">at</span> <span class="mh">0x7f5e613d0f70</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">eliminate_joins</span> <span class="n">at</span> <span class="mh">0x7f5e614031c0</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">eliminate_ctes</span> <span class="n">at</span> <span class="mh">0x7f5e614030a0</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">quote_identifiers</span> <span class="n">at</span> <span class="mh">0x7f5e613d3130</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">annotate_types</span> <span class="n">at</span> <span class="mh">0x7f5e61453520</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">canonicalize</span> <span class="n">at</span> <span class="mh">0x7f5e61402b00</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">simplify</span> <span class="n">at</span> <span class="mh">0x7f5e61403490</span><span class="o">></span><span class="p">)</span>,</span><span class="param"> <span class="o">**</span><span class="n">kwargs</span></span><span class="return-annotation">) -> <span class="n"><a href="../expressions.html#Expression">sqlglot.expressions.Expression</a></span>:</span></span> + <span class="name">optimize</span><span class="signature pdoc-code multiline">(<span class="param"> <span class="n">expression</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n"><a href="../expressions.html#Expression">sqlglot.expressions.Expression</a></span>,</span><span class="param"> <span class="n">schema</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">dict</span><span class="p">,</span> <span class="n"><a href="../schema.html#Schema">sqlglot.schema.Schema</a></span><span class="p">,</span> <span class="n">NoneType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>,</span><span class="param"> <span class="n">db</span><span class="p">:</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><span class="param"> <span class="n">catalog</span><span class="p">:</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><span class="param"> <span class="n">dialect</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n"><a href="../dialects/dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></span><span class="p">,</span> <span class="n">Type</span><span class="p">[</span><span class="n"><a href="../dialects/dialect.html#Dialect">sqlglot.dialects.dialect.Dialect</a></span><span class="p">],</span> <span class="n">NoneType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span>,</span><span class="param"> <span class="n">rules</span><span class="p">:</span> <span class="n">Sequence</span><span class="p">[</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="o"><</span><span class="n">function</span> <span class="n">qualify</span> <span class="n">at</span> <span class="mh">0x7f73bfcf3c70</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">pushdown_projections</span> <span class="n">at</span> <span class="mh">0x7f73bfcf3640</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">normalize</span> <span class="n">at</span> <span class="mh">0x7f73bfcdb6d0</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">unnest_subqueries</span> <span class="n">at</span> <span class="mh">0x7f73bfa9c040</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">pushdown_predicates</span> <span class="n">at</span> <span class="mh">0x7f73bfcf24d0</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">optimize_joins</span> <span class="n">at</span> <span class="mh">0x7f73bfcf2200</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">eliminate_subqueries</span> <span class="n">at</span> <span class="mh">0x7f73bfcf1360</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">merge_subqueries</span> <span class="n">at</span> <span class="mh">0x7f73bfcf13f0</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">eliminate_joins</span> <span class="n">at</span> <span class="mh">0x7f73bfcdb5b0</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">eliminate_ctes</span> <span class="n">at</span> <span class="mh">0x7f73bfcdb490</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">quote_identifiers</span> <span class="n">at</span> <span class="mh">0x7f73bfcf35b0</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">annotate_types</span> <span class="n">at</span> <span class="mh">0x7f73bfd47910</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">canonicalize</span> <span class="n">at</span> <span class="mh">0x7f73bfcdaef0</span><span class="o">></span><span class="p">,</span> <span class="o"><</span><span class="n">function</span> <span class="n">simplify</span> <span class="n">at</span> <span class="mh">0x7f73bfcdb880</span><span class="o">></span><span class="p">)</span>,</span><span class="param"> <span class="o">**</span><span class="n">kwargs</span></span><span class="return-annotation">) -> <span class="n"><a href="../expressions.html#Expression">sqlglot.expressions.Expression</a></span>:</span></span> <label class="view-source-button" for="optimize-view-source"><span>View Source</span></label> diff --git a/docs/sqlglot/optimizer/pushdown_predicates.html b/docs/sqlglot/optimizer/pushdown_predicates.html index 3790346..512d575 100644 --- a/docs/sqlglot/optimizer/pushdown_predicates.html +++ b/docs/sqlglot/optimizer/pushdown_predicates.html @@ -114,7 +114,7 @@ </span><span id="L-41"><a href="#L-41"><span class="linenos"> 41</span></a> <span class="c1"># joins should only pushdown into itself, not to other joins</span> </span><span id="L-42"><a href="#L-42"><span class="linenos"> 42</span></a> <span class="c1"># so we limit the selected sources to only itself</span> </span><span id="L-43"><a href="#L-43"><span class="linenos"> 43</span></a> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">select</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]:</span> -</span><span id="L-44"><a href="#L-44"><span class="linenos"> 44</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias_or_name</span> +</span><span id="L-44"><a href="#L-44"><span class="linenos"> 44</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span> </span><span id="L-45"><a href="#L-45"><span class="linenos"> 45</span></a> <span class="n">pushdown</span><span class="p">(</span><span class="n">join</span><span 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 class="p">{</span><span class="n">name</span><span class="p">:</span> <span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="p">[</span><span class="n">name</span><span class="p">]},</span> <span class="n">scope_ref_count</span><span class="p">)</span> </span><span id="L-46"><a href="#L-46"><span class="linenos"> 46</span></a> </span><span id="L-47"><a href="#L-47"><span class="linenos"> 47</span></a> <span class="k">return</span> <span class="n">expression</span> @@ -166,10 +166,10 @@ </span><span id="L-93"><a href="#L-93"><span class="linenos"> 93</span></a> <span class="n">pushdown_tables</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> </span><span id="L-94"><a href="#L-94"><span class="linenos"> 94</span></a> </span><span id="L-95"><a href="#L-95"><span class="linenos"> 95</span></a> <span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="n">predicates</span><span class="p">:</span> -</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> <span class="n">a_tables</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">a</span><span class="p">))</span> +</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> <span class="n">a_tables</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">a</span><span class="p">)</span> </span><span id="L-97"><a href="#L-97"><span class="linenos"> 97</span></a> </span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a> <span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="n">predicates</span><span class="p">:</span> -</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a> <span class="n">a_tables</span> <span class="o">&=</span> <span class="nb">set</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">b</span><span class="p">))</span> +</span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a> <span class="n">a_tables</span> <span class="o">&=</span> <span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">b</span><span class="p">)</span> </span><span id="L-100"><a href="#L-100"><span class="linenos">100</span></a> </span><span id="L-101"><a href="#L-101"><span class="linenos">101</span></a> <span class="n">pushdown_tables</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">a_tables</span><span class="p">)</span> </span><span id="L-102"><a href="#L-102"><span class="linenos">102</span></a> @@ -220,7 +220,7 @@ </span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a> <span class="n">tables</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">predicate</span><span class="p">)</span> </span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a> <span class="n">where_condition</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">predicate</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">)</span> </span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a> -</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="k">for</span> <span class="n">table</span> <span class="ow">in</span> <span class="n">tables</span><span class="p">:</span> +</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="k">for</span> <span class="n">table</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">tables</span><span class="p">):</span> </span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> <span class="n">node</span><span class="p">,</span> <span class="n">source</span> <span class="o">=</span> <span class="n">sources</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> </span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> </span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> <span class="c1"># if the predicate is in a where statement we can try to push it down</span> @@ -322,7 +322,7 @@ </span><span id="pushdown_predicates-42"><a href="#pushdown_predicates-42"><span class="linenos">42</span></a> <span class="c1"># joins should only pushdown into itself, not to other joins</span> </span><span id="pushdown_predicates-43"><a href="#pushdown_predicates-43"><span class="linenos">43</span></a> <span class="c1"># so we limit the selected sources to only itself</span> </span><span id="pushdown_predicates-44"><a href="#pushdown_predicates-44"><span class="linenos">44</span></a> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">select</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"joins"</span><span class="p">)</span> <span class="ow">or</span> <span class="p">[]:</span> -</span><span id="pushdown_predicates-45"><a href="#pushdown_predicates-45"><span class="linenos">45</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias_or_name</span> +</span><span id="pushdown_predicates-45"><a href="#pushdown_predicates-45"><span class="linenos">45</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span> </span><span id="pushdown_predicates-46"><a href="#pushdown_predicates-46"><span class="linenos">46</span></a> <span class="n">pushdown</span><span class="p">(</span><span class="n">join</span><span 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 class="p">{</span><span class="n">name</span><span class="p">:</span> <span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="p">[</span><span class="n">name</span><span class="p">]},</span> <span class="n">scope_ref_count</span><span class="p">)</span> </span><span id="pushdown_predicates-47"><a href="#pushdown_predicates-47"><span class="linenos">47</span></a> </span><span id="pushdown_predicates-48"><a href="#pushdown_predicates-48"><span class="linenos">48</span></a> <span class="k">return</span> <span class="n">expression</span> @@ -448,10 +448,10 @@ </span><span id="pushdown_dnf-94"><a href="#pushdown_dnf-94"><span class="linenos"> 94</span></a> <span class="n">pushdown_tables</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> </span><span id="pushdown_dnf-95"><a href="#pushdown_dnf-95"><span class="linenos"> 95</span></a> </span><span id="pushdown_dnf-96"><a href="#pushdown_dnf-96"><span class="linenos"> 96</span></a> <span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="n">predicates</span><span class="p">:</span> -</span><span id="pushdown_dnf-97"><a href="#pushdown_dnf-97"><span class="linenos"> 97</span></a> <span class="n">a_tables</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">a</span><span class="p">))</span> +</span><span id="pushdown_dnf-97"><a href="#pushdown_dnf-97"><span class="linenos"> 97</span></a> <span class="n">a_tables</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">a</span><span class="p">)</span> </span><span id="pushdown_dnf-98"><a href="#pushdown_dnf-98"><span class="linenos"> 98</span></a> </span><span id="pushdown_dnf-99"><a href="#pushdown_dnf-99"><span class="linenos"> 99</span></a> <span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="n">predicates</span><span class="p">:</span> -</span><span id="pushdown_dnf-100"><a href="#pushdown_dnf-100"><span class="linenos">100</span></a> <span class="n">a_tables</span> <span class="o">&=</span> <span class="nb">set</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">b</span><span class="p">))</span> +</span><span id="pushdown_dnf-100"><a href="#pushdown_dnf-100"><span class="linenos">100</span></a> <span class="n">a_tables</span> <span class="o">&=</span> <span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">b</span><span class="p">)</span> </span><span id="pushdown_dnf-101"><a href="#pushdown_dnf-101"><span class="linenos">101</span></a> </span><span id="pushdown_dnf-102"><a href="#pushdown_dnf-102"><span class="linenos">102</span></a> <span class="n">pushdown_tables</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">a_tables</span><span class="p">)</span> </span><span id="pushdown_dnf-103"><a href="#pushdown_dnf-103"><span class="linenos">103</span></a> @@ -520,7 +520,7 @@ Additionally, we can't remove predicates from their original form.</p> </span><span id="nodes_for_predicate-148"><a href="#nodes_for_predicate-148"><span class="linenos">148</span></a> <span class="n">tables</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">column_table_names</span><span class="p">(</span><span class="n">predicate</span><span class="p">)</span> </span><span id="nodes_for_predicate-149"><a href="#nodes_for_predicate-149"><span class="linenos">149</span></a> <span class="n">where_condition</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">predicate</span><span class="o">.</span><span class="n">find_ancestor</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">)</span> </span><span id="nodes_for_predicate-150"><a href="#nodes_for_predicate-150"><span class="linenos">150</span></a> -</span><span id="nodes_for_predicate-151"><a href="#nodes_for_predicate-151"><span class="linenos">151</span></a> <span class="k">for</span> <span class="n">table</span> <span class="ow">in</span> <span class="n">tables</span><span class="p">:</span> +</span><span id="nodes_for_predicate-151"><a href="#nodes_for_predicate-151"><span class="linenos">151</span></a> <span class="k">for</span> <span class="n">table</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">tables</span><span class="p">):</span> </span><span id="nodes_for_predicate-152"><a href="#nodes_for_predicate-152"><span class="linenos">152</span></a> <span class="n">node</span><span class="p">,</span> <span class="n">source</span> <span class="o">=</span> <span class="n">sources</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> </span><span id="nodes_for_predicate-153"><a href="#nodes_for_predicate-153"><span class="linenos">153</span></a> </span><span id="nodes_for_predicate-154"><a href="#nodes_for_predicate-154"><span class="linenos">154</span></a> <span class="c1"># if the predicate is in a where statement we can try to push it down</span> diff --git a/docs/sqlglot/optimizer/qualify_columns.html b/docs/sqlglot/optimizer/qualify_columns.html index bc32369..ed08b78 100644 --- a/docs/sqlglot/optimizer/qualify_columns.html +++ b/docs/sqlglot/optimizer/qualify_columns.html @@ -87,9 +87,9 @@ </span><span id="L-5"><a href="#L-5"><span class="linenos"> 5</span></a> </span><span id="L-6"><a href="#L-6"><span class="linenos"> 6</span></a><span class="kn">from</span> <span class="nn">sqlglot</span> <span class="kn">import</span> <span class="n">alias</span><span class="p">,</span> <span class="n">exp</span> </span><span id="L-7"><a href="#L-7"><span class="linenos"> 7</span></a><span class="kn">from</span> <span class="nn">sqlglot._typing</span> <span class="kn">import</span> <span class="n">E</span> -</span><span id="L-8"><a href="#L-8"><span class="linenos"> 8</span></a><span class="kn">from</span> <span class="nn">sqlglot.dialects.dialect</span> <span class="kn">import</span> <span class="n">DialectType</span> +</span><span id="L-8"><a href="#L-8"><span class="linenos"> 8</span></a><span class="kn">from</span> <span class="nn">sqlglot.dialects.dialect</span> <span class="kn">import</span> <span class="n">Dialect</span><span class="p">,</span> <span class="n">DialectType</span> </span><span id="L-9"><a href="#L-9"><span class="linenos"> 9</span></a><span class="kn">from</span> <span class="nn">sqlglot.errors</span> <span class="kn">import</span> <span class="n">OptimizeError</span> -</span><span id="L-10"><a href="#L-10"><span class="linenos"> 10</span></a><span class="kn">from</span> <span class="nn">sqlglot.helper</span> <span class="kn">import</span> <span class="n">case_sensitive</span><span class="p">,</span> <span class="n">seq_get</span> +</span><span id="L-10"><a href="#L-10"><span class="linenos"> 10</span></a><span class="kn">from</span> <span class="nn">sqlglot.helper</span> <span class="kn">import</span> <span class="n">seq_get</span> </span><span id="L-11"><a href="#L-11"><span class="linenos"> 11</span></a><span class="kn">from</span> <span class="nn">sqlglot.optimizer.scope</span> <span class="kn">import</span> <span class="n">Scope</span><span class="p">,</span> <span class="n">traverse_scope</span><span class="p">,</span> <span class="n">walk_in_scope</span> </span><span id="L-12"><a href="#L-12"><span class="linenos"> 12</span></a><span class="kn">from</span> <span class="nn">sqlglot.schema</span> <span class="kn">import</span> <span class="n">Schema</span><span class="p">,</span> <span class="n">ensure_schema</span> </span><span id="L-13"><a href="#L-13"><span class="linenos"> 13</span></a> @@ -175,7 +175,7 @@ </span><span id="L-93"><a href="#L-93"><span class="linenos"> 93</span></a> </span><span id="L-94"><a href="#L-94"><span class="linenos"> 94</span></a><span class="k">def</span> <span class="nf">_expand_using</span><span class="p">(</span><span class="n">scope</span><span class="p">,</span> <span class="n">resolver</span><span class="p">):</span> </span><span id="L-95"><a href="#L-95"><span class="linenos"> 95</span></a> <span class="n">joins</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">scope</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Join</span><span class="p">))</span> -</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> <span class="n">names</span> <span class="o">=</span> <span class="p">{</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">joins</span><span class="p">}</span> +</span><span id="L-96"><a href="#L-96"><span class="linenos"> 96</span></a> <span class="n">names</span> <span class="o">=</span> <span class="p">{</span><span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">joins</span><span class="p">}</span> </span><span id="L-97"><a href="#L-97"><span class="linenos"> 97</span></a> <span class="n">ordered</span> <span class="o">=</span> <span class="p">[</span><span class="n">key</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span> <span class="k">if</span> <span class="n">key</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">names</span><span class="p">]</span> </span><span id="L-98"><a href="#L-98"><span class="linenos"> 98</span></a> </span><span id="L-99"><a href="#L-99"><span class="linenos"> 99</span></a> <span class="c1"># Mapping of automatically joined column names to an ordered set of source names (dict).</span> @@ -187,7 +187,7 @@ </span><span id="L-105"><a href="#L-105"><span class="linenos">105</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">using</span><span class="p">:</span> </span><span id="L-106"><a href="#L-106"><span class="linenos">106</span></a> <span class="k">continue</span> </span><span id="L-107"><a href="#L-107"><span class="linenos">107</span></a> -</span><span id="L-108"><a href="#L-108"><span class="linenos">108</span></a> <span class="n">join_table</span> <span class="o">=</span> <span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias_or_name</span> +</span><span id="L-108"><a href="#L-108"><span class="linenos">108</span></a> <span class="n">join_table</span> <span class="o">=</span> <span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span> </span><span id="L-109"><a href="#L-109"><span class="linenos">109</span></a> </span><span id="L-110"><a href="#L-110"><span class="linenos">110</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="p">{}</span> </span><span id="L-111"><a href="#L-111"><span class="linenos">111</span></a> @@ -499,154 +499,144 @@ </span><span id="L-417"><a href="#L-417"><span class="linenos">417</span></a> </span><span id="L-418"><a href="#L-418"><span class="linenos">418</span></a><span class="k">def</span> <span class="nf">quote_identifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> </span><span id="L-419"><a href="#L-419"><span class="linenos">419</span></a><span class="w"> </span><span class="sd">"""Makes sure all identifiers that need to be quoted are quoted."""</span> -</span><span id="L-420"><a href="#L-420"><span class="linenos">420</span></a> -</span><span id="L-421"><a href="#L-421"><span class="linenos">421</span></a> <span class="k">def</span> <span class="nf">_quote</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="L-422"><a href="#L-422"><span class="linenos">422</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">):</span> -</span><span id="L-423"><a href="#L-423"><span class="linenos">423</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-424"><a href="#L-424"><span class="linenos">424</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="L-425"><a href="#L-425"><span class="linenos">425</span></a> <span class="s2">"quoted"</span><span class="p">,</span> -</span><span id="L-426"><a href="#L-426"><span class="linenos">426</span></a> <span class="n">identify</span> -</span><span id="L-427"><a href="#L-427"><span class="linenos">427</span></a> <span class="ow">or</span> <span class="n">case_sensitive</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> -</span><span id="L-428"><a href="#L-428"><span class="linenos">428</span></a> <span class="ow">or</span> <span class="ow">not</span> <span class="n">exp</span><span class="o">.</span><span class="n">SAFE_IDENTIFIER_RE</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">name</span><span class="p">),</span> -</span><span id="L-429"><a href="#L-429"><span class="linenos">429</span></a> <span class="p">)</span> -</span><span id="L-430"><a href="#L-430"><span class="linenos">430</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-420"><a href="#L-420"><span class="linenos">420</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> +</span><span id="L-421"><a href="#L-421"><span class="linenos">421</span></a> <span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span><span class="o">.</span><span class="n">quote_identifier</span><span class="p">,</span> <span class="n">identify</span><span class="o">=</span><span class="n">identify</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span> +</span><span id="L-422"><a href="#L-422"><span class="linenos">422</span></a> <span class="p">)</span> +</span><span id="L-423"><a href="#L-423"><span class="linenos">423</span></a> +</span><span id="L-424"><a href="#L-424"><span class="linenos">424</span></a> +</span><span id="L-425"><a href="#L-425"><span class="linenos">425</span></a><span class="k">class</span> <span class="nc">Resolver</span><span class="p">:</span> +</span><span id="L-426"><a href="#L-426"><span class="linenos">426</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-427"><a href="#L-427"><span class="linenos">427</span></a><span class="sd"> Helper for resolving columns.</span> +</span><span id="L-428"><a href="#L-428"><span class="linenos">428</span></a> +</span><span id="L-429"><a href="#L-429"><span class="linenos">429</span></a><span class="sd"> This is a class so we can lazily load some things and easily share them across functions.</span> +</span><span id="L-430"><a href="#L-430"><span class="linenos">430</span></a><span class="sd"> """</span> </span><span id="L-431"><a href="#L-431"><span class="linenos">431</span></a> -</span><span id="L-432"><a href="#L-432"><span class="linenos">432</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_quote</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-433"><a href="#L-433"><span class="linenos">433</span></a> -</span><span id="L-434"><a href="#L-434"><span class="linenos">434</span></a> -</span><span id="L-435"><a href="#L-435"><span class="linenos">435</span></a><span class="k">class</span> <span class="nc">Resolver</span><span class="p">:</span> -</span><span id="L-436"><a href="#L-436"><span class="linenos">436</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-437"><a href="#L-437"><span class="linenos">437</span></a><span class="sd"> Helper for resolving columns.</span> -</span><span id="L-438"><a href="#L-438"><span class="linenos">438</span></a> -</span><span id="L-439"><a href="#L-439"><span class="linenos">439</span></a><span class="sd"> This is a class so we can lazily load some things and easily share them across functions.</span> -</span><span id="L-440"><a href="#L-440"><span class="linenos">440</span></a><span class="sd"> """</span> -</span><span id="L-441"><a href="#L-441"><span class="linenos">441</span></a> -</span><span id="L-442"><a href="#L-442"><span class="linenos">442</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">scope</span><span class="p">,</span> <span class="n">schema</span><span class="p">,</span> <span class="n">infer_schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">):</span> -</span><span id="L-443"><a href="#L-443"><span class="linenos">443</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span> <span class="o">=</span> <span class="n">scope</span> -</span><span id="L-444"><a href="#L-444"><span class="linenos">444</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">schema</span> <span class="o">=</span> <span class="n">schema</span> -</span><span id="L-445"><a href="#L-445"><span class="linenos">445</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_source_columns</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-446"><a href="#L-446"><span class="linenos">446</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-447"><a href="#L-447"><span class="linenos">447</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_all_columns</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-448"><a href="#L-448"><span class="linenos">448</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_infer_schema</span> <span class="o">=</span> <span class="n">infer_schema</span> -</span><span id="L-449"><a href="#L-449"><span class="linenos">449</span></a> -</span><span id="L-450"><a href="#L-450"><span class="linenos">450</span></a> <span class="k">def</span> <span class="nf">get_table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">column_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">]:</span> -</span><span id="L-451"><a href="#L-451"><span class="linenos">451</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-452"><a href="#L-452"><span class="linenos">452</span></a><span class="sd"> Get the table for a column name.</span> +</span><span id="L-432"><a href="#L-432"><span class="linenos">432</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">scope</span><span class="p">,</span> <span class="n">schema</span><span class="p">,</span> <span class="n">infer_schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">):</span> +</span><span id="L-433"><a href="#L-433"><span class="linenos">433</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span> <span class="o">=</span> <span class="n">scope</span> +</span><span id="L-434"><a href="#L-434"><span class="linenos">434</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">schema</span> <span class="o">=</span> <span class="n">schema</span> +</span><span id="L-435"><a href="#L-435"><span class="linenos">435</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_source_columns</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-436"><a href="#L-436"><span class="linenos">436</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-437"><a href="#L-437"><span class="linenos">437</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_all_columns</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-438"><a href="#L-438"><span class="linenos">438</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_infer_schema</span> <span class="o">=</span> <span class="n">infer_schema</span> +</span><span id="L-439"><a href="#L-439"><span class="linenos">439</span></a> +</span><span id="L-440"><a href="#L-440"><span class="linenos">440</span></a> <span class="k">def</span> <span class="nf">get_table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">column_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">]:</span> +</span><span id="L-441"><a href="#L-441"><span class="linenos">441</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-442"><a href="#L-442"><span class="linenos">442</span></a><span class="sd"> Get the table for a column name.</span> +</span><span id="L-443"><a href="#L-443"><span class="linenos">443</span></a> +</span><span id="L-444"><a href="#L-444"><span class="linenos">444</span></a><span class="sd"> Args:</span> +</span><span id="L-445"><a href="#L-445"><span class="linenos">445</span></a><span class="sd"> column_name: The column name to find the table for.</span> +</span><span id="L-446"><a href="#L-446"><span class="linenos">446</span></a><span class="sd"> Returns:</span> +</span><span id="L-447"><a href="#L-447"><span class="linenos">447</span></a><span class="sd"> The table name if it can be found/inferred.</span> +</span><span id="L-448"><a href="#L-448"><span class="linenos">448</span></a><span class="sd"> """</span> +</span><span id="L-449"><a href="#L-449"><span class="linenos">449</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-450"><a href="#L-450"><span class="linenos">450</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_unambiguous_columns</span><span class="p">(</span> +</span><span id="L-451"><a href="#L-451"><span class="linenos">451</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_get_all_source_columns</span><span class="p">()</span> +</span><span id="L-452"><a href="#L-452"><span class="linenos">452</span></a> <span class="p">)</span> </span><span id="L-453"><a href="#L-453"><span class="linenos">453</span></a> -</span><span id="L-454"><a href="#L-454"><span class="linenos">454</span></a><span class="sd"> Args:</span> -</span><span id="L-455"><a href="#L-455"><span class="linenos">455</span></a><span class="sd"> column_name: The column name to find the table for.</span> -</span><span id="L-456"><a href="#L-456"><span class="linenos">456</span></a><span class="sd"> Returns:</span> -</span><span id="L-457"><a href="#L-457"><span class="linenos">457</span></a><span class="sd"> The table name if it can be found/inferred.</span> -</span><span id="L-458"><a href="#L-458"><span class="linenos">458</span></a><span class="sd"> """</span> -</span><span id="L-459"><a href="#L-459"><span class="linenos">459</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-460"><a href="#L-460"><span class="linenos">460</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_unambiguous_columns</span><span class="p">(</span> -</span><span id="L-461"><a href="#L-461"><span class="linenos">461</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_get_all_source_columns</span><span class="p">()</span> -</span><span id="L-462"><a href="#L-462"><span class="linenos">462</span></a> <span class="p">)</span> -</span><span id="L-463"><a href="#L-463"><span class="linenos">463</span></a> -</span><span id="L-464"><a href="#L-464"><span class="linenos">464</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">column_name</span><span class="p">)</span> -</span><span id="L-465"><a href="#L-465"><span class="linenos">465</span></a> -</span><span id="L-466"><a href="#L-466"><span class="linenos">466</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table_name</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_infer_schema</span><span class="p">:</span> -</span><span id="L-467"><a href="#L-467"><span class="linenos">467</span></a> <span class="n">sources_without_schema</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> -</span><span id="L-468"><a href="#L-468"><span class="linenos">468</span></a> <span class="n">source</span> -</span><span id="L-469"><a href="#L-469"><span class="linenos">469</span></a> <span class="k">for</span> <span class="n">source</span><span class="p">,</span> <span class="n">columns</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_all_source_columns</span><span class="p">()</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> -</span><span id="L-470"><a href="#L-470"><span class="linenos">470</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">columns</span> <span class="ow">or</span> <span class="s2">"*"</span> <span class="ow">in</span> <span class="n">columns</span> -</span><span id="L-471"><a href="#L-471"><span class="linenos">471</span></a> <span class="p">)</span> -</span><span id="L-472"><a href="#L-472"><span class="linenos">472</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">sources_without_schema</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-473"><a href="#L-473"><span class="linenos">473</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">sources_without_schema</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="L-474"><a href="#L-474"><span class="linenos">474</span></a> -</span><span id="L-475"><a href="#L-475"><span class="linenos">475</span></a> <span class="k">if</span> <span class="n">table_name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="p">:</span> -</span><span id="L-476"><a href="#L-476"><span class="linenos">476</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table_name</span><span class="p">)</span> +</span><span id="L-454"><a href="#L-454"><span class="linenos">454</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">column_name</span><span class="p">)</span> +</span><span id="L-455"><a href="#L-455"><span class="linenos">455</span></a> +</span><span id="L-456"><a href="#L-456"><span class="linenos">456</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table_name</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_infer_schema</span><span class="p">:</span> +</span><span id="L-457"><a href="#L-457"><span class="linenos">457</span></a> <span class="n">sources_without_schema</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> +</span><span id="L-458"><a href="#L-458"><span class="linenos">458</span></a> <span class="n">source</span> +</span><span id="L-459"><a href="#L-459"><span class="linenos">459</span></a> <span class="k">for</span> <span class="n">source</span><span class="p">,</span> <span class="n">columns</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_all_source_columns</span><span class="p">()</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> +</span><span id="L-460"><a href="#L-460"><span class="linenos">460</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">columns</span> <span class="ow">or</span> <span class="s2">"*"</span> <span class="ow">in</span> <span class="n">columns</span> +</span><span id="L-461"><a href="#L-461"><span class="linenos">461</span></a> <span class="p">)</span> +</span><span id="L-462"><a href="#L-462"><span class="linenos">462</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">sources_without_schema</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-463"><a href="#L-463"><span class="linenos">463</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">sources_without_schema</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="L-464"><a href="#L-464"><span class="linenos">464</span></a> +</span><span id="L-465"><a href="#L-465"><span class="linenos">465</span></a> <span class="k">if</span> <span class="n">table_name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="p">:</span> +</span><span id="L-466"><a href="#L-466"><span class="linenos">466</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table_name</span><span class="p">)</span> +</span><span id="L-467"><a href="#L-467"><span class="linenos">467</span></a> +</span><span id="L-468"><a href="#L-468"><span class="linenos">468</span></a> <span class="n">node</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table_name</span><span class="p">)</span> +</span><span id="L-469"><a href="#L-469"><span class="linenos">469</span></a> +</span><span id="L-470"><a href="#L-470"><span class="linenos">470</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="L-471"><a href="#L-471"><span class="linenos">471</span></a> <span class="k">while</span> <span class="n">node</span> <span class="ow">and</span> <span class="n">node</span><span class="o">.</span><span class="n">alias</span> <span class="o">!=</span> <span class="n">table_name</span><span class="p">:</span> +</span><span id="L-472"><a href="#L-472"><span class="linenos">472</span></a> <span class="n">node</span> <span class="o">=</span> <span class="n">node</span><span class="o">.</span><span class="n">parent</span> +</span><span id="L-473"><a href="#L-473"><span class="linenos">473</span></a> +</span><span id="L-474"><a href="#L-474"><span class="linenos">474</span></a> <span class="n">node_alias</span> <span class="o">=</span> <span class="n">node</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">)</span> +</span><span id="L-475"><a href="#L-475"><span class="linenos">475</span></a> <span class="k">if</span> <span class="n">node_alias</span><span class="p">:</span> +</span><span id="L-476"><a href="#L-476"><span class="linenos">476</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">node_alias</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> </span><span id="L-477"><a href="#L-477"><span class="linenos">477</span></a> -</span><span id="L-478"><a href="#L-478"><span class="linenos">478</span></a> <span class="n">node</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table_name</span><span class="p">)</span> +</span><span id="L-478"><a href="#L-478"><span class="linenos">478</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table_name</span><span class="p">)</span> </span><span id="L-479"><a href="#L-479"><span class="linenos">479</span></a> -</span><span id="L-480"><a href="#L-480"><span class="linenos">480</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="L-481"><a href="#L-481"><span class="linenos">481</span></a> <span class="k">while</span> <span class="n">node</span> <span class="ow">and</span> <span class="n">node</span><span class="o">.</span><span class="n">alias</span> <span class="o">!=</span> <span class="n">table_name</span><span class="p">:</span> -</span><span id="L-482"><a href="#L-482"><span class="linenos">482</span></a> <span class="n">node</span> <span class="o">=</span> <span class="n">node</span><span class="o">.</span><span class="n">parent</span> -</span><span id="L-483"><a href="#L-483"><span class="linenos">483</span></a> -</span><span id="L-484"><a href="#L-484"><span class="linenos">484</span></a> <span class="n">node_alias</span> <span class="o">=</span> <span class="n">node</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">)</span> -</span><span id="L-485"><a href="#L-485"><span class="linenos">485</span></a> <span class="k">if</span> <span class="n">node_alias</span><span class="p">:</span> -</span><span id="L-486"><a href="#L-486"><span class="linenos">486</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">node_alias</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-487"><a href="#L-487"><span class="linenos">487</span></a> -</span><span id="L-488"><a href="#L-488"><span class="linenos">488</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table_name</span><span class="p">)</span> -</span><span id="L-489"><a href="#L-489"><span class="linenos">489</span></a> -</span><span id="L-490"><a href="#L-490"><span class="linenos">490</span></a> <span class="nd">@property</span> -</span><span id="L-491"><a href="#L-491"><span class="linenos">491</span></a> <span class="k">def</span> <span class="nf">all_columns</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="L-492"><a href="#L-492"><span class="linenos">492</span></a><span class="w"> </span><span class="sd">"""All available columns of all sources in this scope"""</span> -</span><span id="L-493"><a href="#L-493"><span class="linenos">493</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_all_columns</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-494"><a href="#L-494"><span class="linenos">494</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_all_columns</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-495"><a href="#L-495"><span class="linenos">495</span></a> <span class="n">column</span> <span class="k">for</span> <span class="n">columns</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_all_source_columns</span><span class="p">()</span><span class="o">.</span><span class="n">values</span><span class="p">()</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">columns</span> -</span><span id="L-496"><a href="#L-496"><span class="linenos">496</span></a> <span class="p">}</span> -</span><span id="L-497"><a href="#L-497"><span class="linenos">497</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_all_columns</span> -</span><span id="L-498"><a href="#L-498"><span class="linenos">498</span></a> -</span><span id="L-499"><a href="#L-499"><span class="linenos">499</span></a> <span class="k">def</span> <span class="nf">get_source_columns</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">only_visible</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> -</span><span id="L-500"><a href="#L-500"><span class="linenos">500</span></a><span class="w"> </span><span class="sd">"""Resolve the source columns for a given source `name`"""</span> -</span><span id="L-501"><a href="#L-501"><span class="linenos">501</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="p">:</span> -</span><span id="L-502"><a href="#L-502"><span class="linenos">502</span></a> <span class="k">raise</span> <span class="n">OptimizeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unknown table: </span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-503"><a href="#L-503"><span class="linenos">503</span></a> -</span><span id="L-504"><a href="#L-504"><span class="linenos">504</span></a> <span class="n">source</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> +</span><span id="L-480"><a href="#L-480"><span class="linenos">480</span></a> <span class="nd">@property</span> +</span><span id="L-481"><a href="#L-481"><span class="linenos">481</span></a> <span class="k">def</span> <span class="nf">all_columns</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="L-482"><a href="#L-482"><span class="linenos">482</span></a><span class="w"> </span><span class="sd">"""All available columns of all sources in this scope"""</span> +</span><span id="L-483"><a href="#L-483"><span class="linenos">483</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_all_columns</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-484"><a href="#L-484"><span class="linenos">484</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_all_columns</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-485"><a href="#L-485"><span class="linenos">485</span></a> <span class="n">column</span> <span class="k">for</span> <span class="n">columns</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_all_source_columns</span><span class="p">()</span><span class="o">.</span><span class="n">values</span><span class="p">()</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">columns</span> +</span><span id="L-486"><a href="#L-486"><span class="linenos">486</span></a> <span class="p">}</span> +</span><span id="L-487"><a href="#L-487"><span class="linenos">487</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_all_columns</span> +</span><span id="L-488"><a href="#L-488"><span class="linenos">488</span></a> +</span><span id="L-489"><a href="#L-489"><span class="linenos">489</span></a> <span class="k">def</span> <span class="nf">get_source_columns</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">only_visible</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> +</span><span id="L-490"><a href="#L-490"><span class="linenos">490</span></a><span class="w"> </span><span class="sd">"""Resolve the source columns for a given source `name`"""</span> +</span><span id="L-491"><a href="#L-491"><span class="linenos">491</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="p">:</span> +</span><span id="L-492"><a href="#L-492"><span class="linenos">492</span></a> <span class="k">raise</span> <span class="n">OptimizeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unknown table: </span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-493"><a href="#L-493"><span class="linenos">493</span></a> +</span><span id="L-494"><a href="#L-494"><span class="linenos">494</span></a> <span class="n">source</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> +</span><span id="L-495"><a href="#L-495"><span class="linenos">495</span></a> +</span><span id="L-496"><a href="#L-496"><span class="linenos">496</span></a> <span class="c1"># If referencing a table, return the columns from the schema</span> +</span><span id="L-497"><a href="#L-497"><span class="linenos">497</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">):</span> +</span><span id="L-498"><a href="#L-498"><span class="linenos">498</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">column_names</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">only_visible</span><span class="p">)</span> +</span><span id="L-499"><a href="#L-499"><span class="linenos">499</span></a> +</span><span id="L-500"><a href="#L-500"><span class="linenos">500</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">Scope</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</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">Values</span><span class="p">):</span> +</span><span id="L-501"><a href="#L-501"><span class="linenos">501</span></a> <span class="k">return</span> <span class="n">source</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">alias_column_names</span> +</span><span id="L-502"><a href="#L-502"><span class="linenos">502</span></a> +</span><span id="L-503"><a href="#L-503"><span class="linenos">503</span></a> <span class="c1"># Otherwise, if referencing another scope, return that scope's named selects</span> +</span><span id="L-504"><a href="#L-504"><span class="linenos">504</span></a> <span class="k">return</span> <span class="n">source</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">named_selects</span> </span><span id="L-505"><a href="#L-505"><span class="linenos">505</span></a> -</span><span id="L-506"><a href="#L-506"><span class="linenos">506</span></a> <span class="c1"># If referencing a table, return the columns from the schema</span> -</span><span id="L-507"><a href="#L-507"><span class="linenos">507</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">):</span> -</span><span id="L-508"><a href="#L-508"><span class="linenos">508</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">column_names</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">only_visible</span><span class="p">)</span> -</span><span id="L-509"><a href="#L-509"><span class="linenos">509</span></a> -</span><span id="L-510"><a href="#L-510"><span class="linenos">510</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">Scope</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</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">Values</span><span class="p">):</span> -</span><span id="L-511"><a href="#L-511"><span class="linenos">511</span></a> <span class="k">return</span> <span class="n">source</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">alias_column_names</span> -</span><span id="L-512"><a href="#L-512"><span class="linenos">512</span></a> -</span><span id="L-513"><a href="#L-513"><span class="linenos">513</span></a> <span class="c1"># Otherwise, if referencing another scope, return that scope's named selects</span> -</span><span id="L-514"><a href="#L-514"><span class="linenos">514</span></a> <span class="k">return</span> <span class="n">source</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">named_selects</span> -</span><span id="L-515"><a href="#L-515"><span class="linenos">515</span></a> -</span><span id="L-516"><a href="#L-516"><span class="linenos">516</span></a> <span class="k">def</span> <span class="nf">_get_all_source_columns</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="L-517"><a href="#L-517"><span class="linenos">517</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_source_columns</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-518"><a href="#L-518"><span class="linenos">518</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_source_columns</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-519"><a href="#L-519"><span class="linenos">519</span></a> <span class="n">k</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_source_columns</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> -</span><span id="L-520"><a href="#L-520"><span class="linenos">520</span></a> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">itertools</span><span class="o">.</span><span class="n">chain</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">lateral_sources</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="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_source_columns</span> -</span><span id="L-523"><a href="#L-523"><span class="linenos">523</span></a> -</span><span id="L-524"><a href="#L-524"><span class="linenos">524</span></a> <span class="k">def</span> <span class="nf">_get_unambiguous_columns</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">source_columns</span><span class="p">):</span> -</span><span id="L-525"><a href="#L-525"><span class="linenos">525</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-526"><a href="#L-526"><span class="linenos">526</span></a><span class="sd"> Find all the unambiguous columns in sources.</span> +</span><span id="L-506"><a href="#L-506"><span class="linenos">506</span></a> <span class="k">def</span> <span class="nf">_get_all_source_columns</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="L-507"><a href="#L-507"><span class="linenos">507</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_source_columns</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-508"><a href="#L-508"><span class="linenos">508</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_source_columns</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-509"><a href="#L-509"><span class="linenos">509</span></a> <span class="n">k</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_source_columns</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> +</span><span id="L-510"><a href="#L-510"><span class="linenos">510</span></a> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">itertools</span><span class="o">.</span><span class="n">chain</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">lateral_sources</span><span class="p">)</span> +</span><span id="L-511"><a href="#L-511"><span class="linenos">511</span></a> <span class="p">}</span> +</span><span id="L-512"><a href="#L-512"><span class="linenos">512</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_source_columns</span> +</span><span id="L-513"><a href="#L-513"><span class="linenos">513</span></a> +</span><span id="L-514"><a href="#L-514"><span class="linenos">514</span></a> <span class="k">def</span> <span class="nf">_get_unambiguous_columns</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">source_columns</span><span class="p">):</span> +</span><span id="L-515"><a href="#L-515"><span class="linenos">515</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-516"><a href="#L-516"><span class="linenos">516</span></a><span class="sd"> Find all the unambiguous columns in sources.</span> +</span><span id="L-517"><a href="#L-517"><span class="linenos">517</span></a> +</span><span id="L-518"><a href="#L-518"><span class="linenos">518</span></a><span class="sd"> Args:</span> +</span><span id="L-519"><a href="#L-519"><span class="linenos">519</span></a><span class="sd"> source_columns (dict): Mapping of names to source columns</span> +</span><span id="L-520"><a href="#L-520"><span class="linenos">520</span></a><span class="sd"> Returns:</span> +</span><span id="L-521"><a href="#L-521"><span class="linenos">521</span></a><span class="sd"> dict: Mapping of column name to source name</span> +</span><span id="L-522"><a href="#L-522"><span class="linenos">522</span></a><span class="sd"> """</span> +</span><span id="L-523"><a href="#L-523"><span class="linenos">523</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">source_columns</span><span class="p">:</span> +</span><span id="L-524"><a href="#L-524"><span class="linenos">524</span></a> <span class="k">return</span> <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">source_columns</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">source_columns</span><span class="o">.</span><span class="n">items</span><span class="p">())</span> </span><span id="L-527"><a href="#L-527"><span class="linenos">527</span></a> -</span><span id="L-528"><a href="#L-528"><span class="linenos">528</span></a><span class="sd"> Args:</span> -</span><span id="L-529"><a href="#L-529"><span class="linenos">529</span></a><span class="sd"> source_columns (dict): Mapping of names to source columns</span> -</span><span id="L-530"><a href="#L-530"><span class="linenos">530</span></a><span class="sd"> Returns:</span> -</span><span id="L-531"><a href="#L-531"><span class="linenos">531</span></a><span class="sd"> dict: Mapping of column name to source name</span> -</span><span id="L-532"><a href="#L-532"><span class="linenos">532</span></a><span class="sd"> """</span> -</span><span id="L-533"><a href="#L-533"><span class="linenos">533</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">source_columns</span><span class="p">:</span> -</span><span id="L-534"><a href="#L-534"><span class="linenos">534</span></a> <span class="k">return</span> <span class="p">{}</span> -</span><span id="L-535"><a href="#L-535"><span class="linenos">535</span></a> -</span><span id="L-536"><a href="#L-536"><span class="linenos">536</span></a> <span class="n">source_columns</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">source_columns</span><span class="o">.</span><span class="n">items</span><span class="p">())</span> -</span><span id="L-537"><a href="#L-537"><span class="linenos">537</span></a> -</span><span id="L-538"><a href="#L-538"><span class="linenos">538</span></a> <span class="n">first_table</span><span class="p">,</span> <span class="n">first_columns</span> <span class="o">=</span> <span class="n">source_columns</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="L-539"><a href="#L-539"><span class="linenos">539</span></a> <span class="n">unambiguous_columns</span> <span class="o">=</span> <span class="p">{</span><span class="n">col</span><span class="p">:</span> <span class="n">first_table</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_unique_columns</span><span class="p">(</span><span class="n">first_columns</span><span class="p">)}</span> -</span><span id="L-540"><a href="#L-540"><span class="linenos">540</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">unambiguous_columns</span><span class="p">)</span> -</span><span id="L-541"><a href="#L-541"><span class="linenos">541</span></a> -</span><span id="L-542"><a href="#L-542"><span class="linenos">542</span></a> <span class="k">for</span> <span class="n">table</span><span class="p">,</span> <span class="n">columns</span> <span class="ow">in</span> <span class="n">source_columns</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span> -</span><span id="L-543"><a href="#L-543"><span class="linenos">543</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_unique_columns</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> -</span><span id="L-544"><a href="#L-544"><span class="linenos">544</span></a> <span class="n">ambiguous</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">all_columns</span><span class="p">)</span><span class="o">.</span><span class="n">intersection</span><span class="p">(</span><span class="n">unique</span><span class="p">)</span> -</span><span id="L-545"><a href="#L-545"><span class="linenos">545</span></a> <span class="n">all_columns</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> -</span><span id="L-546"><a href="#L-546"><span class="linenos">546</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">ambiguous</span><span class="p">:</span> -</span><span id="L-547"><a href="#L-547"><span class="linenos">547</span></a> <span class="n">unambiguous_columns</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="L-548"><a href="#L-548"><span class="linenos">548</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">unique</span><span class="o">.</span><span class="n">difference</span><span class="p">(</span><span class="n">ambiguous</span><span class="p">):</span> -</span><span id="L-549"><a href="#L-549"><span class="linenos">549</span></a> <span class="n">unambiguous_columns</span><span class="p">[</span><span class="n">column</span><span class="p">]</span> <span class="o">=</span> <span class="n">table</span> -</span><span id="L-550"><a href="#L-550"><span class="linenos">550</span></a> -</span><span id="L-551"><a href="#L-551"><span class="linenos">551</span></a> <span class="k">return</span> <span class="n">unambiguous_columns</span> -</span><span id="L-552"><a href="#L-552"><span class="linenos">552</span></a> -</span><span id="L-553"><a href="#L-553"><span class="linenos">553</span></a> <span class="nd">@staticmethod</span> -</span><span id="L-554"><a href="#L-554"><span class="linenos">554</span></a> <span class="k">def</span> <span class="nf">_find_unique_columns</span><span class="p">(</span><span class="n">columns</span><span class="p">):</span> -</span><span id="L-555"><a href="#L-555"><span class="linenos">555</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-556"><a href="#L-556"><span class="linenos">556</span></a><span class="sd"> Find the unique columns in a list of columns.</span> -</span><span id="L-557"><a href="#L-557"><span class="linenos">557</span></a> -</span><span id="L-558"><a href="#L-558"><span class="linenos">558</span></a><span class="sd"> Example:</span> -</span><span id="L-559"><a href="#L-559"><span class="linenos">559</span></a><span class="sd"> >>> sorted(Resolver._find_unique_columns(["a", "b", "b", "c"]))</span> -</span><span id="L-560"><a href="#L-560"><span class="linenos">560</span></a><span class="sd"> ['a', 'c']</span> -</span><span id="L-561"><a href="#L-561"><span class="linenos">561</span></a> -</span><span id="L-562"><a href="#L-562"><span class="linenos">562</span></a><span class="sd"> This is necessary because duplicate column names are ambiguous.</span> -</span><span id="L-563"><a href="#L-563"><span class="linenos">563</span></a><span class="sd"> """</span> -</span><span id="L-564"><a href="#L-564"><span class="linenos">564</span></a> <span class="n">counts</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-565"><a href="#L-565"><span class="linenos">565</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">columns</span><span class="p">:</span> -</span><span id="L-566"><a href="#L-566"><span class="linenos">566</span></a> <span class="n">counts</span><span class="p">[</span><span class="n">column</span><span class="p">]</span> <span class="o">=</span> <span class="n">counts</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span> -</span><span id="L-567"><a href="#L-567"><span class="linenos">567</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">column</span> <span class="k">for</span> <span class="n">column</span><span class="p">,</span> <span class="n">count</span> <span class="ow">in</span> <span class="n">counts</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="k">if</span> <span class="n">count</span> <span class="o">==</span> <span class="mi">1</span><span class="p">}</span> +</span><span id="L-528"><a href="#L-528"><span class="linenos">528</span></a> <span class="n">first_table</span><span class="p">,</span> <span class="n">first_columns</span> <span class="o">=</span> <span class="n">source_columns</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="L-529"><a href="#L-529"><span class="linenos">529</span></a> <span class="n">unambiguous_columns</span> <span class="o">=</span> <span class="p">{</span><span class="n">col</span><span class="p">:</span> <span class="n">first_table</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_unique_columns</span><span class="p">(</span><span class="n">first_columns</span><span class="p">)}</span> +</span><span id="L-530"><a href="#L-530"><span class="linenos">530</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">unambiguous_columns</span><span class="p">)</span> +</span><span id="L-531"><a href="#L-531"><span class="linenos">531</span></a> +</span><span id="L-532"><a href="#L-532"><span class="linenos">532</span></a> <span class="k">for</span> <span class="n">table</span><span class="p">,</span> <span class="n">columns</span> <span class="ow">in</span> <span class="n">source_columns</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span> +</span><span id="L-533"><a href="#L-533"><span class="linenos">533</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_unique_columns</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> +</span><span id="L-534"><a href="#L-534"><span class="linenos">534</span></a> <span class="n">ambiguous</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">all_columns</span><span class="p">)</span><span class="o">.</span><span class="n">intersection</span><span class="p">(</span><span class="n">unique</span><span class="p">)</span> +</span><span id="L-535"><a href="#L-535"><span class="linenos">535</span></a> <span class="n">all_columns</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> +</span><span id="L-536"><a href="#L-536"><span class="linenos">536</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">ambiguous</span><span class="p">:</span> +</span><span id="L-537"><a href="#L-537"><span class="linenos">537</span></a> <span class="n">unambiguous_columns</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="L-538"><a href="#L-538"><span class="linenos">538</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">unique</span><span class="o">.</span><span class="n">difference</span><span class="p">(</span><span class="n">ambiguous</span><span class="p">):</span> +</span><span id="L-539"><a href="#L-539"><span class="linenos">539</span></a> <span class="n">unambiguous_columns</span><span class="p">[</span><span class="n">column</span><span class="p">]</span> <span class="o">=</span> <span class="n">table</span> +</span><span id="L-540"><a href="#L-540"><span class="linenos">540</span></a> +</span><span id="L-541"><a href="#L-541"><span class="linenos">541</span></a> <span class="k">return</span> <span class="n">unambiguous_columns</span> +</span><span id="L-542"><a href="#L-542"><span class="linenos">542</span></a> +</span><span id="L-543"><a href="#L-543"><span class="linenos">543</span></a> <span class="nd">@staticmethod</span> +</span><span id="L-544"><a href="#L-544"><span class="linenos">544</span></a> <span class="k">def</span> <span class="nf">_find_unique_columns</span><span class="p">(</span><span class="n">columns</span><span class="p">):</span> +</span><span id="L-545"><a href="#L-545"><span class="linenos">545</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-546"><a href="#L-546"><span class="linenos">546</span></a><span class="sd"> Find the unique columns in a list of columns.</span> +</span><span id="L-547"><a href="#L-547"><span class="linenos">547</span></a> +</span><span id="L-548"><a href="#L-548"><span class="linenos">548</span></a><span class="sd"> Example:</span> +</span><span id="L-549"><a href="#L-549"><span class="linenos">549</span></a><span class="sd"> >>> sorted(Resolver._find_unique_columns(["a", "b", "b", "c"]))</span> +</span><span id="L-550"><a href="#L-550"><span class="linenos">550</span></a><span class="sd"> ['a', 'c']</span> +</span><span id="L-551"><a href="#L-551"><span class="linenos">551</span></a> +</span><span id="L-552"><a href="#L-552"><span class="linenos">552</span></a><span class="sd"> This is necessary because duplicate column names are ambiguous.</span> +</span><span id="L-553"><a href="#L-553"><span class="linenos">553</span></a><span class="sd"> """</span> +</span><span id="L-554"><a href="#L-554"><span class="linenos">554</span></a> <span class="n">counts</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-555"><a href="#L-555"><span class="linenos">555</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">columns</span><span class="p">:</span> +</span><span id="L-556"><a href="#L-556"><span class="linenos">556</span></a> <span class="n">counts</span><span class="p">[</span><span class="n">column</span><span class="p">]</span> <span class="o">=</span> <span class="n">counts</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span> +</span><span id="L-557"><a href="#L-557"><span class="linenos">557</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">column</span> <span class="k">for</span> <span class="n">column</span><span class="p">,</span> <span class="n">count</span> <span class="ow">in</span> <span class="n">counts</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="k">if</span> <span class="n">count</span> <span class="o">==</span> <span class="mi">1</span><span class="p">}</span> </span></pre></div> @@ -793,19 +783,9 @@ <a class="headerlink" href="#quote_identifiers"></a> <div class="pdoc-code codehilite"><pre><span></span><span id="quote_identifiers-419"><a href="#quote_identifiers-419"><span class="linenos">419</span></a><span class="k">def</span> <span class="nf">quote_identifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">identify</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> </span><span id="quote_identifiers-420"><a href="#quote_identifiers-420"><span class="linenos">420</span></a><span class="w"> </span><span class="sd">"""Makes sure all identifiers that need to be quoted are quoted."""</span> -</span><span id="quote_identifiers-421"><a href="#quote_identifiers-421"><span class="linenos">421</span></a> -</span><span id="quote_identifiers-422"><a href="#quote_identifiers-422"><span class="linenos">422</span></a> <span class="k">def</span> <span class="nf">_quote</span><span class="p">(</span><span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="quote_identifiers-423"><a href="#quote_identifiers-423"><span class="linenos">423</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">):</span> -</span><span id="quote_identifiers-424"><a href="#quote_identifiers-424"><span class="linenos">424</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="quote_identifiers-425"><a href="#quote_identifiers-425"><span class="linenos">425</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="quote_identifiers-426"><a href="#quote_identifiers-426"><span class="linenos">426</span></a> <span class="s2">"quoted"</span><span class="p">,</span> -</span><span id="quote_identifiers-427"><a href="#quote_identifiers-427"><span class="linenos">427</span></a> <span class="n">identify</span> -</span><span id="quote_identifiers-428"><a href="#quote_identifiers-428"><span class="linenos">428</span></a> <span class="ow">or</span> <span class="n">case_sensitive</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> -</span><span id="quote_identifiers-429"><a href="#quote_identifiers-429"><span class="linenos">429</span></a> <span class="ow">or</span> <span class="ow">not</span> <span class="n">exp</span><span class="o">.</span><span class="n">SAFE_IDENTIFIER_RE</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">name</span><span class="p">),</span> -</span><span id="quote_identifiers-430"><a href="#quote_identifiers-430"><span class="linenos">430</span></a> <span class="p">)</span> -</span><span id="quote_identifiers-431"><a href="#quote_identifiers-431"><span class="linenos">431</span></a> <span class="k">return</span> <span class="n">expression</span> -</span><span id="quote_identifiers-432"><a href="#quote_identifiers-432"><span class="linenos">432</span></a> -</span><span id="quote_identifiers-433"><a href="#quote_identifiers-433"><span class="linenos">433</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">_quote</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="quote_identifiers-421"><a href="#quote_identifiers-421"><span class="linenos">421</span></a> <span class="k">return</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> +</span><span id="quote_identifiers-422"><a href="#quote_identifiers-422"><span class="linenos">422</span></a> <span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span><span class="o">.</span><span class="n">quote_identifier</span><span class="p">,</span> <span class="n">identify</span><span class="o">=</span><span class="n">identify</span><span class="p">,</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span> +</span><span id="quote_identifiers-423"><a href="#quote_identifiers-423"><span class="linenos">423</span></a> <span class="p">)</span> </span></pre></div> @@ -825,139 +805,139 @@ </div> <a class="headerlink" href="#Resolver"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Resolver-436"><a href="#Resolver-436"><span class="linenos">436</span></a><span class="k">class</span> <span class="nc">Resolver</span><span class="p">:</span> -</span><span id="Resolver-437"><a href="#Resolver-437"><span class="linenos">437</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Resolver-438"><a href="#Resolver-438"><span class="linenos">438</span></a><span class="sd"> Helper for resolving columns.</span> -</span><span id="Resolver-439"><a href="#Resolver-439"><span class="linenos">439</span></a> -</span><span id="Resolver-440"><a href="#Resolver-440"><span class="linenos">440</span></a><span class="sd"> This is a class so we can lazily load some things and easily share them across functions.</span> -</span><span id="Resolver-441"><a href="#Resolver-441"><span class="linenos">441</span></a><span class="sd"> """</span> -</span><span id="Resolver-442"><a href="#Resolver-442"><span class="linenos">442</span></a> -</span><span id="Resolver-443"><a href="#Resolver-443"><span class="linenos">443</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">scope</span><span class="p">,</span> <span class="n">schema</span><span class="p">,</span> <span class="n">infer_schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">):</span> -</span><span id="Resolver-444"><a href="#Resolver-444"><span class="linenos">444</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span> <span class="o">=</span> <span class="n">scope</span> -</span><span id="Resolver-445"><a href="#Resolver-445"><span class="linenos">445</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">schema</span> <span class="o">=</span> <span class="n">schema</span> -</span><span id="Resolver-446"><a href="#Resolver-446"><span class="linenos">446</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_source_columns</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Resolver-447"><a href="#Resolver-447"><span class="linenos">447</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Resolver-448"><a href="#Resolver-448"><span class="linenos">448</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_all_columns</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Resolver-449"><a href="#Resolver-449"><span class="linenos">449</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_infer_schema</span> <span class="o">=</span> <span class="n">infer_schema</span> -</span><span id="Resolver-450"><a href="#Resolver-450"><span class="linenos">450</span></a> -</span><span id="Resolver-451"><a href="#Resolver-451"><span class="linenos">451</span></a> <span class="k">def</span> <span class="nf">get_table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">column_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">]:</span> -</span><span id="Resolver-452"><a href="#Resolver-452"><span class="linenos">452</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Resolver-453"><a href="#Resolver-453"><span class="linenos">453</span></a><span class="sd"> Get the table for a column name.</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Resolver-426"><a href="#Resolver-426"><span class="linenos">426</span></a><span class="k">class</span> <span class="nc">Resolver</span><span class="p">:</span> +</span><span id="Resolver-427"><a href="#Resolver-427"><span class="linenos">427</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Resolver-428"><a href="#Resolver-428"><span class="linenos">428</span></a><span class="sd"> Helper for resolving columns.</span> +</span><span id="Resolver-429"><a href="#Resolver-429"><span class="linenos">429</span></a> +</span><span id="Resolver-430"><a href="#Resolver-430"><span class="linenos">430</span></a><span class="sd"> This is a class so we can lazily load some things and easily share them across functions.</span> +</span><span id="Resolver-431"><a href="#Resolver-431"><span class="linenos">431</span></a><span class="sd"> """</span> +</span><span id="Resolver-432"><a href="#Resolver-432"><span class="linenos">432</span></a> +</span><span id="Resolver-433"><a href="#Resolver-433"><span class="linenos">433</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">scope</span><span class="p">,</span> <span class="n">schema</span><span class="p">,</span> <span class="n">infer_schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">):</span> +</span><span id="Resolver-434"><a href="#Resolver-434"><span class="linenos">434</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span> <span class="o">=</span> <span class="n">scope</span> +</span><span id="Resolver-435"><a href="#Resolver-435"><span class="linenos">435</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">schema</span> <span class="o">=</span> <span class="n">schema</span> +</span><span id="Resolver-436"><a href="#Resolver-436"><span class="linenos">436</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_source_columns</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Resolver-437"><a href="#Resolver-437"><span class="linenos">437</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Resolver-438"><a href="#Resolver-438"><span class="linenos">438</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_all_columns</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Resolver-439"><a href="#Resolver-439"><span class="linenos">439</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_infer_schema</span> <span class="o">=</span> <span class="n">infer_schema</span> +</span><span id="Resolver-440"><a href="#Resolver-440"><span class="linenos">440</span></a> +</span><span id="Resolver-441"><a href="#Resolver-441"><span class="linenos">441</span></a> <span class="k">def</span> <span class="nf">get_table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">column_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">]:</span> +</span><span id="Resolver-442"><a href="#Resolver-442"><span class="linenos">442</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Resolver-443"><a href="#Resolver-443"><span class="linenos">443</span></a><span class="sd"> Get the table for a column name.</span> +</span><span id="Resolver-444"><a href="#Resolver-444"><span class="linenos">444</span></a> +</span><span id="Resolver-445"><a href="#Resolver-445"><span class="linenos">445</span></a><span class="sd"> Args:</span> +</span><span id="Resolver-446"><a href="#Resolver-446"><span class="linenos">446</span></a><span class="sd"> column_name: The column name to find the table for.</span> +</span><span id="Resolver-447"><a href="#Resolver-447"><span class="linenos">447</span></a><span class="sd"> Returns:</span> +</span><span id="Resolver-448"><a href="#Resolver-448"><span class="linenos">448</span></a><span class="sd"> The table name if it can be found/inferred.</span> +</span><span id="Resolver-449"><a href="#Resolver-449"><span class="linenos">449</span></a><span class="sd"> """</span> +</span><span id="Resolver-450"><a href="#Resolver-450"><span class="linenos">450</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Resolver-451"><a href="#Resolver-451"><span class="linenos">451</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_unambiguous_columns</span><span class="p">(</span> +</span><span id="Resolver-452"><a href="#Resolver-452"><span class="linenos">452</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_get_all_source_columns</span><span class="p">()</span> +</span><span id="Resolver-453"><a href="#Resolver-453"><span class="linenos">453</span></a> <span class="p">)</span> </span><span id="Resolver-454"><a href="#Resolver-454"><span class="linenos">454</span></a> -</span><span id="Resolver-455"><a href="#Resolver-455"><span class="linenos">455</span></a><span class="sd"> Args:</span> -</span><span id="Resolver-456"><a href="#Resolver-456"><span class="linenos">456</span></a><span class="sd"> column_name: The column name to find the table for.</span> -</span><span id="Resolver-457"><a href="#Resolver-457"><span class="linenos">457</span></a><span class="sd"> Returns:</span> -</span><span id="Resolver-458"><a href="#Resolver-458"><span class="linenos">458</span></a><span class="sd"> The table name if it can be found/inferred.</span> -</span><span id="Resolver-459"><a href="#Resolver-459"><span class="linenos">459</span></a><span class="sd"> """</span> -</span><span id="Resolver-460"><a href="#Resolver-460"><span class="linenos">460</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Resolver-461"><a href="#Resolver-461"><span class="linenos">461</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_unambiguous_columns</span><span class="p">(</span> -</span><span id="Resolver-462"><a href="#Resolver-462"><span class="linenos">462</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_get_all_source_columns</span><span class="p">()</span> -</span><span id="Resolver-463"><a href="#Resolver-463"><span class="linenos">463</span></a> <span class="p">)</span> -</span><span id="Resolver-464"><a href="#Resolver-464"><span class="linenos">464</span></a> -</span><span id="Resolver-465"><a href="#Resolver-465"><span class="linenos">465</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">column_name</span><span class="p">)</span> -</span><span id="Resolver-466"><a href="#Resolver-466"><span class="linenos">466</span></a> -</span><span id="Resolver-467"><a href="#Resolver-467"><span class="linenos">467</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table_name</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_infer_schema</span><span class="p">:</span> -</span><span id="Resolver-468"><a href="#Resolver-468"><span class="linenos">468</span></a> <span class="n">sources_without_schema</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> -</span><span id="Resolver-469"><a href="#Resolver-469"><span class="linenos">469</span></a> <span class="n">source</span> -</span><span id="Resolver-470"><a href="#Resolver-470"><span class="linenos">470</span></a> <span class="k">for</span> <span class="n">source</span><span class="p">,</span> <span class="n">columns</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_all_source_columns</span><span class="p">()</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> -</span><span id="Resolver-471"><a href="#Resolver-471"><span class="linenos">471</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">columns</span> <span class="ow">or</span> <span class="s2">"*"</span> <span class="ow">in</span> <span class="n">columns</span> -</span><span id="Resolver-472"><a href="#Resolver-472"><span class="linenos">472</span></a> <span class="p">)</span> -</span><span id="Resolver-473"><a href="#Resolver-473"><span class="linenos">473</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">sources_without_schema</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Resolver-474"><a href="#Resolver-474"><span class="linenos">474</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">sources_without_schema</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="Resolver-475"><a href="#Resolver-475"><span class="linenos">475</span></a> -</span><span id="Resolver-476"><a href="#Resolver-476"><span class="linenos">476</span></a> <span class="k">if</span> <span class="n">table_name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="p">:</span> -</span><span id="Resolver-477"><a href="#Resolver-477"><span class="linenos">477</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table_name</span><span class="p">)</span> +</span><span id="Resolver-455"><a href="#Resolver-455"><span class="linenos">455</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">column_name</span><span class="p">)</span> +</span><span id="Resolver-456"><a href="#Resolver-456"><span class="linenos">456</span></a> +</span><span id="Resolver-457"><a href="#Resolver-457"><span class="linenos">457</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table_name</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_infer_schema</span><span class="p">:</span> +</span><span id="Resolver-458"><a href="#Resolver-458"><span class="linenos">458</span></a> <span class="n">sources_without_schema</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> +</span><span id="Resolver-459"><a href="#Resolver-459"><span class="linenos">459</span></a> <span class="n">source</span> +</span><span id="Resolver-460"><a href="#Resolver-460"><span class="linenos">460</span></a> <span class="k">for</span> <span class="n">source</span><span class="p">,</span> <span class="n">columns</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_all_source_columns</span><span class="p">()</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> +</span><span id="Resolver-461"><a href="#Resolver-461"><span class="linenos">461</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">columns</span> <span class="ow">or</span> <span class="s2">"*"</span> <span class="ow">in</span> <span class="n">columns</span> +</span><span id="Resolver-462"><a href="#Resolver-462"><span class="linenos">462</span></a> <span class="p">)</span> +</span><span id="Resolver-463"><a href="#Resolver-463"><span class="linenos">463</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">sources_without_schema</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Resolver-464"><a href="#Resolver-464"><span class="linenos">464</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">sources_without_schema</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="Resolver-465"><a href="#Resolver-465"><span class="linenos">465</span></a> +</span><span id="Resolver-466"><a href="#Resolver-466"><span class="linenos">466</span></a> <span class="k">if</span> <span class="n">table_name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="p">:</span> +</span><span id="Resolver-467"><a href="#Resolver-467"><span class="linenos">467</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table_name</span><span class="p">)</span> +</span><span id="Resolver-468"><a href="#Resolver-468"><span class="linenos">468</span></a> +</span><span id="Resolver-469"><a href="#Resolver-469"><span class="linenos">469</span></a> <span class="n">node</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table_name</span><span class="p">)</span> +</span><span id="Resolver-470"><a href="#Resolver-470"><span class="linenos">470</span></a> +</span><span id="Resolver-471"><a href="#Resolver-471"><span class="linenos">471</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="Resolver-472"><a href="#Resolver-472"><span class="linenos">472</span></a> <span class="k">while</span> <span class="n">node</span> <span class="ow">and</span> <span class="n">node</span><span class="o">.</span><span class="n">alias</span> <span class="o">!=</span> <span class="n">table_name</span><span class="p">:</span> +</span><span id="Resolver-473"><a href="#Resolver-473"><span class="linenos">473</span></a> <span class="n">node</span> <span class="o">=</span> <span class="n">node</span><span class="o">.</span><span class="n">parent</span> +</span><span id="Resolver-474"><a href="#Resolver-474"><span class="linenos">474</span></a> +</span><span id="Resolver-475"><a href="#Resolver-475"><span class="linenos">475</span></a> <span class="n">node_alias</span> <span class="o">=</span> <span class="n">node</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Resolver-476"><a href="#Resolver-476"><span class="linenos">476</span></a> <span class="k">if</span> <span class="n">node_alias</span><span class="p">:</span> +</span><span id="Resolver-477"><a href="#Resolver-477"><span class="linenos">477</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">node_alias</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> </span><span id="Resolver-478"><a href="#Resolver-478"><span class="linenos">478</span></a> -</span><span id="Resolver-479"><a href="#Resolver-479"><span class="linenos">479</span></a> <span class="n">node</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table_name</span><span class="p">)</span> +</span><span id="Resolver-479"><a href="#Resolver-479"><span class="linenos">479</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table_name</span><span class="p">)</span> </span><span id="Resolver-480"><a href="#Resolver-480"><span class="linenos">480</span></a> -</span><span id="Resolver-481"><a href="#Resolver-481"><span class="linenos">481</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="Resolver-482"><a href="#Resolver-482"><span class="linenos">482</span></a> <span class="k">while</span> <span class="n">node</span> <span class="ow">and</span> <span class="n">node</span><span class="o">.</span><span class="n">alias</span> <span class="o">!=</span> <span class="n">table_name</span><span class="p">:</span> -</span><span id="Resolver-483"><a href="#Resolver-483"><span class="linenos">483</span></a> <span class="n">node</span> <span class="o">=</span> <span class="n">node</span><span class="o">.</span><span class="n">parent</span> -</span><span id="Resolver-484"><a href="#Resolver-484"><span class="linenos">484</span></a> -</span><span id="Resolver-485"><a href="#Resolver-485"><span class="linenos">485</span></a> <span class="n">node_alias</span> <span class="o">=</span> <span class="n">node</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Resolver-486"><a href="#Resolver-486"><span class="linenos">486</span></a> <span class="k">if</span> <span class="n">node_alias</span><span class="p">:</span> -</span><span id="Resolver-487"><a href="#Resolver-487"><span class="linenos">487</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">node_alias</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="Resolver-488"><a href="#Resolver-488"><span class="linenos">488</span></a> -</span><span id="Resolver-489"><a href="#Resolver-489"><span class="linenos">489</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table_name</span><span class="p">)</span> -</span><span id="Resolver-490"><a href="#Resolver-490"><span class="linenos">490</span></a> -</span><span id="Resolver-491"><a href="#Resolver-491"><span class="linenos">491</span></a> <span class="nd">@property</span> -</span><span id="Resolver-492"><a href="#Resolver-492"><span class="linenos">492</span></a> <span class="k">def</span> <span class="nf">all_columns</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Resolver-493"><a href="#Resolver-493"><span class="linenos">493</span></a><span class="w"> </span><span class="sd">"""All available columns of all sources in this scope"""</span> -</span><span id="Resolver-494"><a href="#Resolver-494"><span class="linenos">494</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_all_columns</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Resolver-495"><a href="#Resolver-495"><span class="linenos">495</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_all_columns</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Resolver-496"><a href="#Resolver-496"><span class="linenos">496</span></a> <span class="n">column</span> <span class="k">for</span> <span class="n">columns</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_all_source_columns</span><span class="p">()</span><span class="o">.</span><span class="n">values</span><span class="p">()</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">columns</span> -</span><span id="Resolver-497"><a href="#Resolver-497"><span class="linenos">497</span></a> <span class="p">}</span> -</span><span id="Resolver-498"><a href="#Resolver-498"><span class="linenos">498</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_all_columns</span> -</span><span id="Resolver-499"><a href="#Resolver-499"><span class="linenos">499</span></a> -</span><span id="Resolver-500"><a href="#Resolver-500"><span class="linenos">500</span></a> <span class="k">def</span> <span class="nf">get_source_columns</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">only_visible</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> -</span><span id="Resolver-501"><a href="#Resolver-501"><span class="linenos">501</span></a><span class="w"> </span><span class="sd">"""Resolve the source columns for a given source `name`"""</span> -</span><span id="Resolver-502"><a href="#Resolver-502"><span class="linenos">502</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="p">:</span> -</span><span id="Resolver-503"><a href="#Resolver-503"><span class="linenos">503</span></a> <span class="k">raise</span> <span class="n">OptimizeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unknown table: </span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Resolver-504"><a href="#Resolver-504"><span class="linenos">504</span></a> -</span><span id="Resolver-505"><a href="#Resolver-505"><span class="linenos">505</span></a> <span class="n">source</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> +</span><span id="Resolver-481"><a href="#Resolver-481"><span class="linenos">481</span></a> <span class="nd">@property</span> +</span><span id="Resolver-482"><a href="#Resolver-482"><span class="linenos">482</span></a> <span class="k">def</span> <span class="nf">all_columns</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Resolver-483"><a href="#Resolver-483"><span class="linenos">483</span></a><span class="w"> </span><span class="sd">"""All available columns of all sources in this scope"""</span> +</span><span id="Resolver-484"><a href="#Resolver-484"><span class="linenos">484</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_all_columns</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Resolver-485"><a href="#Resolver-485"><span class="linenos">485</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_all_columns</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Resolver-486"><a href="#Resolver-486"><span class="linenos">486</span></a> <span class="n">column</span> <span class="k">for</span> <span class="n">columns</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_all_source_columns</span><span class="p">()</span><span class="o">.</span><span class="n">values</span><span class="p">()</span> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">columns</span> +</span><span id="Resolver-487"><a href="#Resolver-487"><span class="linenos">487</span></a> <span class="p">}</span> +</span><span id="Resolver-488"><a href="#Resolver-488"><span class="linenos">488</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_all_columns</span> +</span><span id="Resolver-489"><a href="#Resolver-489"><span class="linenos">489</span></a> +</span><span id="Resolver-490"><a href="#Resolver-490"><span class="linenos">490</span></a> <span class="k">def</span> <span class="nf">get_source_columns</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">only_visible</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> +</span><span id="Resolver-491"><a href="#Resolver-491"><span class="linenos">491</span></a><span class="w"> </span><span class="sd">"""Resolve the source columns for a given source `name`"""</span> +</span><span id="Resolver-492"><a href="#Resolver-492"><span class="linenos">492</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="p">:</span> +</span><span id="Resolver-493"><a href="#Resolver-493"><span class="linenos">493</span></a> <span class="k">raise</span> <span class="n">OptimizeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unknown table: </span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Resolver-494"><a href="#Resolver-494"><span class="linenos">494</span></a> +</span><span id="Resolver-495"><a href="#Resolver-495"><span class="linenos">495</span></a> <span class="n">source</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> +</span><span id="Resolver-496"><a href="#Resolver-496"><span class="linenos">496</span></a> +</span><span id="Resolver-497"><a href="#Resolver-497"><span class="linenos">497</span></a> <span class="c1"># If referencing a table, return the columns from the schema</span> +</span><span id="Resolver-498"><a href="#Resolver-498"><span class="linenos">498</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">):</span> +</span><span id="Resolver-499"><a href="#Resolver-499"><span class="linenos">499</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">column_names</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">only_visible</span><span class="p">)</span> +</span><span id="Resolver-500"><a href="#Resolver-500"><span class="linenos">500</span></a> +</span><span id="Resolver-501"><a href="#Resolver-501"><span class="linenos">501</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">Scope</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</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">Values</span><span class="p">):</span> +</span><span id="Resolver-502"><a href="#Resolver-502"><span class="linenos">502</span></a> <span class="k">return</span> <span class="n">source</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">alias_column_names</span> +</span><span id="Resolver-503"><a href="#Resolver-503"><span class="linenos">503</span></a> +</span><span id="Resolver-504"><a href="#Resolver-504"><span class="linenos">504</span></a> <span class="c1"># Otherwise, if referencing another scope, return that scope's named selects</span> +</span><span id="Resolver-505"><a href="#Resolver-505"><span class="linenos">505</span></a> <span class="k">return</span> <span class="n">source</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">named_selects</span> </span><span id="Resolver-506"><a href="#Resolver-506"><span class="linenos">506</span></a> -</span><span id="Resolver-507"><a href="#Resolver-507"><span class="linenos">507</span></a> <span class="c1"># If referencing a table, return the columns from the schema</span> -</span><span id="Resolver-508"><a href="#Resolver-508"><span class="linenos">508</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">):</span> -</span><span id="Resolver-509"><a href="#Resolver-509"><span class="linenos">509</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">column_names</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">only_visible</span><span class="p">)</span> -</span><span id="Resolver-510"><a href="#Resolver-510"><span class="linenos">510</span></a> -</span><span id="Resolver-511"><a href="#Resolver-511"><span class="linenos">511</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">Scope</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</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">Values</span><span class="p">):</span> -</span><span id="Resolver-512"><a href="#Resolver-512"><span class="linenos">512</span></a> <span class="k">return</span> <span class="n">source</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">alias_column_names</span> -</span><span id="Resolver-513"><a href="#Resolver-513"><span class="linenos">513</span></a> -</span><span id="Resolver-514"><a href="#Resolver-514"><span class="linenos">514</span></a> <span class="c1"># Otherwise, if referencing another scope, return that scope's named selects</span> -</span><span id="Resolver-515"><a href="#Resolver-515"><span class="linenos">515</span></a> <span class="k">return</span> <span class="n">source</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">named_selects</span> -</span><span id="Resolver-516"><a href="#Resolver-516"><span class="linenos">516</span></a> -</span><span id="Resolver-517"><a href="#Resolver-517"><span class="linenos">517</span></a> <span class="k">def</span> <span class="nf">_get_all_source_columns</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Resolver-518"><a href="#Resolver-518"><span class="linenos">518</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_source_columns</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Resolver-519"><a href="#Resolver-519"><span class="linenos">519</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_source_columns</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Resolver-520"><a href="#Resolver-520"><span class="linenos">520</span></a> <span class="n">k</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_source_columns</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> -</span><span id="Resolver-521"><a href="#Resolver-521"><span class="linenos">521</span></a> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">itertools</span><span class="o">.</span><span class="n">chain</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">lateral_sources</span><span class="p">)</span> -</span><span id="Resolver-522"><a href="#Resolver-522"><span class="linenos">522</span></a> <span class="p">}</span> -</span><span id="Resolver-523"><a href="#Resolver-523"><span class="linenos">523</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_source_columns</span> -</span><span id="Resolver-524"><a href="#Resolver-524"><span class="linenos">524</span></a> -</span><span id="Resolver-525"><a href="#Resolver-525"><span class="linenos">525</span></a> <span class="k">def</span> <span class="nf">_get_unambiguous_columns</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">source_columns</span><span class="p">):</span> -</span><span id="Resolver-526"><a href="#Resolver-526"><span class="linenos">526</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Resolver-527"><a href="#Resolver-527"><span class="linenos">527</span></a><span class="sd"> Find all the unambiguous columns in sources.</span> +</span><span id="Resolver-507"><a href="#Resolver-507"><span class="linenos">507</span></a> <span class="k">def</span> <span class="nf">_get_all_source_columns</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Resolver-508"><a href="#Resolver-508"><span class="linenos">508</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_source_columns</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Resolver-509"><a href="#Resolver-509"><span class="linenos">509</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_source_columns</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Resolver-510"><a href="#Resolver-510"><span class="linenos">510</span></a> <span class="n">k</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_source_columns</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> +</span><span id="Resolver-511"><a href="#Resolver-511"><span class="linenos">511</span></a> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">itertools</span><span class="o">.</span><span class="n">chain</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">lateral_sources</span><span class="p">)</span> +</span><span id="Resolver-512"><a href="#Resolver-512"><span class="linenos">512</span></a> <span class="p">}</span> +</span><span id="Resolver-513"><a href="#Resolver-513"><span class="linenos">513</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_source_columns</span> +</span><span id="Resolver-514"><a href="#Resolver-514"><span class="linenos">514</span></a> +</span><span id="Resolver-515"><a href="#Resolver-515"><span class="linenos">515</span></a> <span class="k">def</span> <span class="nf">_get_unambiguous_columns</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">source_columns</span><span class="p">):</span> +</span><span id="Resolver-516"><a href="#Resolver-516"><span class="linenos">516</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Resolver-517"><a href="#Resolver-517"><span class="linenos">517</span></a><span class="sd"> Find all the unambiguous columns in sources.</span> +</span><span id="Resolver-518"><a href="#Resolver-518"><span class="linenos">518</span></a> +</span><span id="Resolver-519"><a href="#Resolver-519"><span class="linenos">519</span></a><span class="sd"> Args:</span> +</span><span id="Resolver-520"><a href="#Resolver-520"><span class="linenos">520</span></a><span class="sd"> source_columns (dict): Mapping of names to source columns</span> +</span><span id="Resolver-521"><a href="#Resolver-521"><span class="linenos">521</span></a><span class="sd"> Returns:</span> +</span><span id="Resolver-522"><a href="#Resolver-522"><span class="linenos">522</span></a><span class="sd"> dict: Mapping of column name to source name</span> +</span><span id="Resolver-523"><a href="#Resolver-523"><span class="linenos">523</span></a><span class="sd"> """</span> +</span><span id="Resolver-524"><a href="#Resolver-524"><span class="linenos">524</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">source_columns</span><span class="p">:</span> +</span><span id="Resolver-525"><a href="#Resolver-525"><span class="linenos">525</span></a> <span class="k">return</span> <span class="p">{}</span> +</span><span id="Resolver-526"><a href="#Resolver-526"><span class="linenos">526</span></a> +</span><span id="Resolver-527"><a href="#Resolver-527"><span class="linenos">527</span></a> <span class="n">source_columns</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">source_columns</span><span class="o">.</span><span class="n">items</span><span class="p">())</span> </span><span id="Resolver-528"><a href="#Resolver-528"><span class="linenos">528</span></a> -</span><span id="Resolver-529"><a href="#Resolver-529"><span class="linenos">529</span></a><span class="sd"> Args:</span> -</span><span id="Resolver-530"><a href="#Resolver-530"><span class="linenos">530</span></a><span class="sd"> source_columns (dict): Mapping of names to source columns</span> -</span><span id="Resolver-531"><a href="#Resolver-531"><span class="linenos">531</span></a><span class="sd"> Returns:</span> -</span><span id="Resolver-532"><a href="#Resolver-532"><span class="linenos">532</span></a><span class="sd"> dict: Mapping of column name to source name</span> -</span><span id="Resolver-533"><a href="#Resolver-533"><span class="linenos">533</span></a><span class="sd"> """</span> -</span><span id="Resolver-534"><a href="#Resolver-534"><span class="linenos">534</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">source_columns</span><span class="p">:</span> -</span><span id="Resolver-535"><a href="#Resolver-535"><span class="linenos">535</span></a> <span class="k">return</span> <span class="p">{}</span> -</span><span id="Resolver-536"><a href="#Resolver-536"><span class="linenos">536</span></a> -</span><span id="Resolver-537"><a href="#Resolver-537"><span class="linenos">537</span></a> <span class="n">source_columns</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">source_columns</span><span class="o">.</span><span class="n">items</span><span class="p">())</span> -</span><span id="Resolver-538"><a href="#Resolver-538"><span class="linenos">538</span></a> -</span><span id="Resolver-539"><a href="#Resolver-539"><span class="linenos">539</span></a> <span class="n">first_table</span><span class="p">,</span> <span class="n">first_columns</span> <span class="o">=</span> <span class="n">source_columns</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="Resolver-540"><a href="#Resolver-540"><span class="linenos">540</span></a> <span class="n">unambiguous_columns</span> <span class="o">=</span> <span class="p">{</span><span class="n">col</span><span class="p">:</span> <span class="n">first_table</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_unique_columns</span><span class="p">(</span><span class="n">first_columns</span><span class="p">)}</span> -</span><span id="Resolver-541"><a href="#Resolver-541"><span class="linenos">541</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">unambiguous_columns</span><span class="p">)</span> -</span><span id="Resolver-542"><a href="#Resolver-542"><span class="linenos">542</span></a> -</span><span id="Resolver-543"><a href="#Resolver-543"><span class="linenos">543</span></a> <span class="k">for</span> <span class="n">table</span><span class="p">,</span> <span class="n">columns</span> <span class="ow">in</span> <span class="n">source_columns</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span> -</span><span id="Resolver-544"><a href="#Resolver-544"><span class="linenos">544</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_unique_columns</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> -</span><span id="Resolver-545"><a href="#Resolver-545"><span class="linenos">545</span></a> <span class="n">ambiguous</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">all_columns</span><span class="p">)</span><span class="o">.</span><span class="n">intersection</span><span class="p">(</span><span class="n">unique</span><span class="p">)</span> -</span><span id="Resolver-546"><a href="#Resolver-546"><span class="linenos">546</span></a> <span class="n">all_columns</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> -</span><span id="Resolver-547"><a href="#Resolver-547"><span class="linenos">547</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">ambiguous</span><span class="p">:</span> -</span><span id="Resolver-548"><a href="#Resolver-548"><span class="linenos">548</span></a> <span class="n">unambiguous_columns</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="Resolver-549"><a href="#Resolver-549"><span class="linenos">549</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">unique</span><span class="o">.</span><span class="n">difference</span><span class="p">(</span><span class="n">ambiguous</span><span class="p">):</span> -</span><span id="Resolver-550"><a href="#Resolver-550"><span class="linenos">550</span></a> <span class="n">unambiguous_columns</span><span class="p">[</span><span class="n">column</span><span class="p">]</span> <span class="o">=</span> <span class="n">table</span> -</span><span id="Resolver-551"><a href="#Resolver-551"><span class="linenos">551</span></a> -</span><span id="Resolver-552"><a href="#Resolver-552"><span class="linenos">552</span></a> <span class="k">return</span> <span class="n">unambiguous_columns</span> -</span><span id="Resolver-553"><a href="#Resolver-553"><span class="linenos">553</span></a> -</span><span id="Resolver-554"><a href="#Resolver-554"><span class="linenos">554</span></a> <span class="nd">@staticmethod</span> -</span><span id="Resolver-555"><a href="#Resolver-555"><span class="linenos">555</span></a> <span class="k">def</span> <span class="nf">_find_unique_columns</span><span class="p">(</span><span class="n">columns</span><span class="p">):</span> -</span><span id="Resolver-556"><a href="#Resolver-556"><span class="linenos">556</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Resolver-557"><a href="#Resolver-557"><span class="linenos">557</span></a><span class="sd"> Find the unique columns in a list of columns.</span> -</span><span id="Resolver-558"><a href="#Resolver-558"><span class="linenos">558</span></a> -</span><span id="Resolver-559"><a href="#Resolver-559"><span class="linenos">559</span></a><span class="sd"> Example:</span> -</span><span id="Resolver-560"><a href="#Resolver-560"><span class="linenos">560</span></a><span class="sd"> >>> sorted(Resolver._find_unique_columns(["a", "b", "b", "c"]))</span> -</span><span id="Resolver-561"><a href="#Resolver-561"><span class="linenos">561</span></a><span class="sd"> ['a', 'c']</span> -</span><span id="Resolver-562"><a href="#Resolver-562"><span class="linenos">562</span></a> -</span><span id="Resolver-563"><a href="#Resolver-563"><span class="linenos">563</span></a><span class="sd"> This is necessary because duplicate column names are ambiguous.</span> -</span><span id="Resolver-564"><a href="#Resolver-564"><span class="linenos">564</span></a><span class="sd"> """</span> -</span><span id="Resolver-565"><a href="#Resolver-565"><span class="linenos">565</span></a> <span class="n">counts</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Resolver-566"><a href="#Resolver-566"><span class="linenos">566</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">columns</span><span class="p">:</span> -</span><span id="Resolver-567"><a href="#Resolver-567"><span class="linenos">567</span></a> <span class="n">counts</span><span class="p">[</span><span class="n">column</span><span class="p">]</span> <span class="o">=</span> <span class="n">counts</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span> -</span><span id="Resolver-568"><a href="#Resolver-568"><span class="linenos">568</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">column</span> <span class="k">for</span> <span class="n">column</span><span class="p">,</span> <span class="n">count</span> <span class="ow">in</span> <span class="n">counts</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="k">if</span> <span class="n">count</span> <span class="o">==</span> <span class="mi">1</span><span class="p">}</span> +</span><span id="Resolver-529"><a href="#Resolver-529"><span class="linenos">529</span></a> <span class="n">first_table</span><span class="p">,</span> <span class="n">first_columns</span> <span class="o">=</span> <span class="n">source_columns</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="Resolver-530"><a href="#Resolver-530"><span class="linenos">530</span></a> <span class="n">unambiguous_columns</span> <span class="o">=</span> <span class="p">{</span><span class="n">col</span><span class="p">:</span> <span class="n">first_table</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_unique_columns</span><span class="p">(</span><span class="n">first_columns</span><span class="p">)}</span> +</span><span id="Resolver-531"><a href="#Resolver-531"><span class="linenos">531</span></a> <span class="n">all_columns</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">unambiguous_columns</span><span class="p">)</span> +</span><span id="Resolver-532"><a href="#Resolver-532"><span class="linenos">532</span></a> +</span><span id="Resolver-533"><a href="#Resolver-533"><span class="linenos">533</span></a> <span class="k">for</span> <span class="n">table</span><span class="p">,</span> <span class="n">columns</span> <span class="ow">in</span> <span class="n">source_columns</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span> +</span><span id="Resolver-534"><a href="#Resolver-534"><span class="linenos">534</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_unique_columns</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> +</span><span id="Resolver-535"><a href="#Resolver-535"><span class="linenos">535</span></a> <span class="n">ambiguous</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">all_columns</span><span class="p">)</span><span class="o">.</span><span class="n">intersection</span><span class="p">(</span><span class="n">unique</span><span class="p">)</span> +</span><span id="Resolver-536"><a href="#Resolver-536"><span class="linenos">536</span></a> <span class="n">all_columns</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">columns</span><span class="p">)</span> +</span><span id="Resolver-537"><a href="#Resolver-537"><span class="linenos">537</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">ambiguous</span><span class="p">:</span> +</span><span id="Resolver-538"><a href="#Resolver-538"><span class="linenos">538</span></a> <span class="n">unambiguous_columns</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="Resolver-539"><a href="#Resolver-539"><span class="linenos">539</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">unique</span><span class="o">.</span><span class="n">difference</span><span class="p">(</span><span class="n">ambiguous</span><span class="p">):</span> +</span><span id="Resolver-540"><a href="#Resolver-540"><span class="linenos">540</span></a> <span class="n">unambiguous_columns</span><span class="p">[</span><span class="n">column</span><span class="p">]</span> <span class="o">=</span> <span class="n">table</span> +</span><span id="Resolver-541"><a href="#Resolver-541"><span class="linenos">541</span></a> +</span><span id="Resolver-542"><a href="#Resolver-542"><span class="linenos">542</span></a> <span class="k">return</span> <span class="n">unambiguous_columns</span> +</span><span id="Resolver-543"><a href="#Resolver-543"><span class="linenos">543</span></a> +</span><span id="Resolver-544"><a href="#Resolver-544"><span class="linenos">544</span></a> <span class="nd">@staticmethod</span> +</span><span id="Resolver-545"><a href="#Resolver-545"><span class="linenos">545</span></a> <span class="k">def</span> <span class="nf">_find_unique_columns</span><span class="p">(</span><span class="n">columns</span><span class="p">):</span> +</span><span id="Resolver-546"><a href="#Resolver-546"><span class="linenos">546</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Resolver-547"><a href="#Resolver-547"><span class="linenos">547</span></a><span class="sd"> Find the unique columns in a list of columns.</span> +</span><span id="Resolver-548"><a href="#Resolver-548"><span class="linenos">548</span></a> +</span><span id="Resolver-549"><a href="#Resolver-549"><span class="linenos">549</span></a><span class="sd"> Example:</span> +</span><span id="Resolver-550"><a href="#Resolver-550"><span class="linenos">550</span></a><span class="sd"> >>> sorted(Resolver._find_unique_columns(["a", "b", "b", "c"]))</span> +</span><span id="Resolver-551"><a href="#Resolver-551"><span class="linenos">551</span></a><span class="sd"> ['a', 'c']</span> +</span><span id="Resolver-552"><a href="#Resolver-552"><span class="linenos">552</span></a> +</span><span id="Resolver-553"><a href="#Resolver-553"><span class="linenos">553</span></a><span class="sd"> This is necessary because duplicate column names are ambiguous.</span> +</span><span id="Resolver-554"><a href="#Resolver-554"><span class="linenos">554</span></a><span class="sd"> """</span> +</span><span id="Resolver-555"><a href="#Resolver-555"><span class="linenos">555</span></a> <span class="n">counts</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Resolver-556"><a href="#Resolver-556"><span class="linenos">556</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">columns</span><span class="p">:</span> +</span><span id="Resolver-557"><a href="#Resolver-557"><span class="linenos">557</span></a> <span class="n">counts</span><span class="p">[</span><span class="n">column</span><span class="p">]</span> <span class="o">=</span> <span class="n">counts</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span> +</span><span id="Resolver-558"><a href="#Resolver-558"><span class="linenos">558</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">column</span> <span class="k">for</span> <span class="n">column</span><span class="p">,</span> <span class="n">count</span> <span class="ow">in</span> <span class="n">counts</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="k">if</span> <span class="n">count</span> <span class="o">==</span> <span class="mi">1</span><span class="p">}</span> </span></pre></div> @@ -977,13 +957,13 @@ </div> <a class="headerlink" href="#Resolver.__init__"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Resolver.__init__-443"><a href="#Resolver.__init__-443"><span class="linenos">443</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">scope</span><span class="p">,</span> <span class="n">schema</span><span class="p">,</span> <span class="n">infer_schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">):</span> -</span><span id="Resolver.__init__-444"><a href="#Resolver.__init__-444"><span class="linenos">444</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span> <span class="o">=</span> <span class="n">scope</span> -</span><span id="Resolver.__init__-445"><a href="#Resolver.__init__-445"><span class="linenos">445</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">schema</span> <span class="o">=</span> <span class="n">schema</span> -</span><span id="Resolver.__init__-446"><a href="#Resolver.__init__-446"><span class="linenos">446</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_source_columns</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Resolver.__init__-447"><a href="#Resolver.__init__-447"><span class="linenos">447</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Resolver.__init__-448"><a href="#Resolver.__init__-448"><span class="linenos">448</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_all_columns</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Resolver.__init__-449"><a href="#Resolver.__init__-449"><span class="linenos">449</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_infer_schema</span> <span class="o">=</span> <span class="n">infer_schema</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Resolver.__init__-433"><a href="#Resolver.__init__-433"><span class="linenos">433</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">scope</span><span class="p">,</span> <span class="n">schema</span><span class="p">,</span> <span class="n">infer_schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">):</span> +</span><span id="Resolver.__init__-434"><a href="#Resolver.__init__-434"><span class="linenos">434</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span> <span class="o">=</span> <span class="n">scope</span> +</span><span id="Resolver.__init__-435"><a href="#Resolver.__init__-435"><span class="linenos">435</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">schema</span> <span class="o">=</span> <span class="n">schema</span> +</span><span id="Resolver.__init__-436"><a href="#Resolver.__init__-436"><span class="linenos">436</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_source_columns</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Resolver.__init__-437"><a href="#Resolver.__init__-437"><span class="linenos">437</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Resolver.__init__-438"><a href="#Resolver.__init__-438"><span class="linenos">438</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_all_columns</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Resolver.__init__-439"><a href="#Resolver.__init__-439"><span class="linenos">439</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_infer_schema</span> <span class="o">=</span> <span class="n">infer_schema</span> </span></pre></div> @@ -1001,45 +981,45 @@ </div> <a class="headerlink" href="#Resolver.get_table"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Resolver.get_table-451"><a href="#Resolver.get_table-451"><span class="linenos">451</span></a> <span class="k">def</span> <span class="nf">get_table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">column_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">]:</span> -</span><span id="Resolver.get_table-452"><a href="#Resolver.get_table-452"><span class="linenos">452</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Resolver.get_table-453"><a href="#Resolver.get_table-453"><span class="linenos">453</span></a><span class="sd"> Get the table for a column name.</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Resolver.get_table-441"><a href="#Resolver.get_table-441"><span class="linenos">441</span></a> <span class="k">def</span> <span class="nf">get_table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">column_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">]:</span> +</span><span id="Resolver.get_table-442"><a href="#Resolver.get_table-442"><span class="linenos">442</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Resolver.get_table-443"><a href="#Resolver.get_table-443"><span class="linenos">443</span></a><span class="sd"> Get the table for a column name.</span> +</span><span id="Resolver.get_table-444"><a href="#Resolver.get_table-444"><span class="linenos">444</span></a> +</span><span id="Resolver.get_table-445"><a href="#Resolver.get_table-445"><span class="linenos">445</span></a><span class="sd"> Args:</span> +</span><span id="Resolver.get_table-446"><a href="#Resolver.get_table-446"><span class="linenos">446</span></a><span class="sd"> column_name: The column name to find the table for.</span> +</span><span id="Resolver.get_table-447"><a href="#Resolver.get_table-447"><span class="linenos">447</span></a><span class="sd"> Returns:</span> +</span><span id="Resolver.get_table-448"><a href="#Resolver.get_table-448"><span class="linenos">448</span></a><span class="sd"> The table name if it can be found/inferred.</span> +</span><span id="Resolver.get_table-449"><a href="#Resolver.get_table-449"><span class="linenos">449</span></a><span class="sd"> """</span> +</span><span id="Resolver.get_table-450"><a href="#Resolver.get_table-450"><span class="linenos">450</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Resolver.get_table-451"><a href="#Resolver.get_table-451"><span class="linenos">451</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_unambiguous_columns</span><span class="p">(</span> +</span><span id="Resolver.get_table-452"><a href="#Resolver.get_table-452"><span class="linenos">452</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_get_all_source_columns</span><span class="p">()</span> +</span><span id="Resolver.get_table-453"><a href="#Resolver.get_table-453"><span class="linenos">453</span></a> <span class="p">)</span> </span><span id="Resolver.get_table-454"><a href="#Resolver.get_table-454"><span class="linenos">454</span></a> -</span><span id="Resolver.get_table-455"><a href="#Resolver.get_table-455"><span class="linenos">455</span></a><span class="sd"> Args:</span> -</span><span id="Resolver.get_table-456"><a href="#Resolver.get_table-456"><span class="linenos">456</span></a><span class="sd"> column_name: The column name to find the table for.</span> -</span><span id="Resolver.get_table-457"><a href="#Resolver.get_table-457"><span class="linenos">457</span></a><span class="sd"> Returns:</span> -</span><span id="Resolver.get_table-458"><a href="#Resolver.get_table-458"><span class="linenos">458</span></a><span class="sd"> The table name if it can be found/inferred.</span> -</span><span id="Resolver.get_table-459"><a href="#Resolver.get_table-459"><span class="linenos">459</span></a><span class="sd"> """</span> -</span><span id="Resolver.get_table-460"><a href="#Resolver.get_table-460"><span class="linenos">460</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Resolver.get_table-461"><a href="#Resolver.get_table-461"><span class="linenos">461</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_unambiguous_columns</span><span class="p">(</span> -</span><span id="Resolver.get_table-462"><a href="#Resolver.get_table-462"><span class="linenos">462</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_get_all_source_columns</span><span class="p">()</span> -</span><span id="Resolver.get_table-463"><a href="#Resolver.get_table-463"><span class="linenos">463</span></a> <span class="p">)</span> -</span><span id="Resolver.get_table-464"><a href="#Resolver.get_table-464"><span class="linenos">464</span></a> -</span><span id="Resolver.get_table-465"><a href="#Resolver.get_table-465"><span class="linenos">465</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">column_name</span><span class="p">)</span> -</span><span id="Resolver.get_table-466"><a href="#Resolver.get_table-466"><span class="linenos">466</span></a> -</span><span id="Resolver.get_table-467"><a href="#Resolver.get_table-467"><span class="linenos">467</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table_name</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_infer_schema</span><span class="p">:</span> -</span><span id="Resolver.get_table-468"><a href="#Resolver.get_table-468"><span class="linenos">468</span></a> <span class="n">sources_without_schema</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> -</span><span id="Resolver.get_table-469"><a href="#Resolver.get_table-469"><span class="linenos">469</span></a> <span class="n">source</span> -</span><span id="Resolver.get_table-470"><a href="#Resolver.get_table-470"><span class="linenos">470</span></a> <span class="k">for</span> <span class="n">source</span><span class="p">,</span> <span class="n">columns</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_all_source_columns</span><span class="p">()</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> -</span><span id="Resolver.get_table-471"><a href="#Resolver.get_table-471"><span class="linenos">471</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">columns</span> <span class="ow">or</span> <span class="s2">"*"</span> <span class="ow">in</span> <span class="n">columns</span> -</span><span id="Resolver.get_table-472"><a href="#Resolver.get_table-472"><span class="linenos">472</span></a> <span class="p">)</span> -</span><span id="Resolver.get_table-473"><a href="#Resolver.get_table-473"><span class="linenos">473</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">sources_without_schema</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Resolver.get_table-474"><a href="#Resolver.get_table-474"><span class="linenos">474</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">sources_without_schema</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="Resolver.get_table-475"><a href="#Resolver.get_table-475"><span class="linenos">475</span></a> -</span><span id="Resolver.get_table-476"><a href="#Resolver.get_table-476"><span class="linenos">476</span></a> <span class="k">if</span> <span class="n">table_name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="p">:</span> -</span><span id="Resolver.get_table-477"><a href="#Resolver.get_table-477"><span class="linenos">477</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table_name</span><span class="p">)</span> +</span><span id="Resolver.get_table-455"><a href="#Resolver.get_table-455"><span class="linenos">455</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_unambiguous_columns</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">column_name</span><span class="p">)</span> +</span><span id="Resolver.get_table-456"><a href="#Resolver.get_table-456"><span class="linenos">456</span></a> +</span><span id="Resolver.get_table-457"><a href="#Resolver.get_table-457"><span class="linenos">457</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table_name</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_infer_schema</span><span class="p">:</span> +</span><span id="Resolver.get_table-458"><a href="#Resolver.get_table-458"><span class="linenos">458</span></a> <span class="n">sources_without_schema</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> +</span><span id="Resolver.get_table-459"><a href="#Resolver.get_table-459"><span class="linenos">459</span></a> <span class="n">source</span> +</span><span id="Resolver.get_table-460"><a href="#Resolver.get_table-460"><span class="linenos">460</span></a> <span class="k">for</span> <span class="n">source</span><span class="p">,</span> <span class="n">columns</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_all_source_columns</span><span class="p">()</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> +</span><span id="Resolver.get_table-461"><a href="#Resolver.get_table-461"><span class="linenos">461</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">columns</span> <span class="ow">or</span> <span class="s2">"*"</span> <span class="ow">in</span> <span class="n">columns</span> +</span><span id="Resolver.get_table-462"><a href="#Resolver.get_table-462"><span class="linenos">462</span></a> <span class="p">)</span> +</span><span id="Resolver.get_table-463"><a href="#Resolver.get_table-463"><span class="linenos">463</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">sources_without_schema</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Resolver.get_table-464"><a href="#Resolver.get_table-464"><span class="linenos">464</span></a> <span class="n">table_name</span> <span class="o">=</span> <span class="n">sources_without_schema</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="Resolver.get_table-465"><a href="#Resolver.get_table-465"><span class="linenos">465</span></a> +</span><span id="Resolver.get_table-466"><a href="#Resolver.get_table-466"><span class="linenos">466</span></a> <span class="k">if</span> <span class="n">table_name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="p">:</span> +</span><span id="Resolver.get_table-467"><a href="#Resolver.get_table-467"><span class="linenos">467</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table_name</span><span class="p">)</span> +</span><span id="Resolver.get_table-468"><a href="#Resolver.get_table-468"><span class="linenos">468</span></a> +</span><span id="Resolver.get_table-469"><a href="#Resolver.get_table-469"><span class="linenos">469</span></a> <span class="n">node</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table_name</span><span class="p">)</span> +</span><span id="Resolver.get_table-470"><a href="#Resolver.get_table-470"><span class="linenos">470</span></a> +</span><span id="Resolver.get_table-471"><a href="#Resolver.get_table-471"><span class="linenos">471</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="Resolver.get_table-472"><a href="#Resolver.get_table-472"><span class="linenos">472</span></a> <span class="k">while</span> <span class="n">node</span> <span class="ow">and</span> <span class="n">node</span><span class="o">.</span><span class="n">alias</span> <span class="o">!=</span> <span class="n">table_name</span><span class="p">:</span> +</span><span id="Resolver.get_table-473"><a href="#Resolver.get_table-473"><span class="linenos">473</span></a> <span class="n">node</span> <span class="o">=</span> <span class="n">node</span><span class="o">.</span><span class="n">parent</span> +</span><span id="Resolver.get_table-474"><a href="#Resolver.get_table-474"><span class="linenos">474</span></a> +</span><span id="Resolver.get_table-475"><a href="#Resolver.get_table-475"><span class="linenos">475</span></a> <span class="n">node_alias</span> <span class="o">=</span> <span class="n">node</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Resolver.get_table-476"><a href="#Resolver.get_table-476"><span class="linenos">476</span></a> <span class="k">if</span> <span class="n">node_alias</span><span class="p">:</span> +</span><span id="Resolver.get_table-477"><a href="#Resolver.get_table-477"><span class="linenos">477</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">node_alias</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> </span><span id="Resolver.get_table-478"><a href="#Resolver.get_table-478"><span class="linenos">478</span></a> -</span><span id="Resolver.get_table-479"><a href="#Resolver.get_table-479"><span class="linenos">479</span></a> <span class="n">node</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table_name</span><span class="p">)</span> -</span><span id="Resolver.get_table-480"><a href="#Resolver.get_table-480"><span class="linenos">480</span></a> -</span><span id="Resolver.get_table-481"><a href="#Resolver.get_table-481"><span class="linenos">481</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="Resolver.get_table-482"><a href="#Resolver.get_table-482"><span class="linenos">482</span></a> <span class="k">while</span> <span class="n">node</span> <span class="ow">and</span> <span class="n">node</span><span class="o">.</span><span class="n">alias</span> <span class="o">!=</span> <span class="n">table_name</span><span class="p">:</span> -</span><span id="Resolver.get_table-483"><a href="#Resolver.get_table-483"><span class="linenos">483</span></a> <span class="n">node</span> <span class="o">=</span> <span class="n">node</span><span class="o">.</span><span class="n">parent</span> -</span><span id="Resolver.get_table-484"><a href="#Resolver.get_table-484"><span class="linenos">484</span></a> -</span><span id="Resolver.get_table-485"><a href="#Resolver.get_table-485"><span class="linenos">485</span></a> <span class="n">node_alias</span> <span class="o">=</span> <span class="n">node</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Resolver.get_table-486"><a href="#Resolver.get_table-486"><span class="linenos">486</span></a> <span class="k">if</span> <span class="n">node_alias</span><span class="p">:</span> -</span><span id="Resolver.get_table-487"><a href="#Resolver.get_table-487"><span class="linenos">487</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">node_alias</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="Resolver.get_table-488"><a href="#Resolver.get_table-488"><span class="linenos">488</span></a> -</span><span id="Resolver.get_table-489"><a href="#Resolver.get_table-489"><span class="linenos">489</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table_name</span><span class="p">)</span> +</span><span id="Resolver.get_table-479"><a href="#Resolver.get_table-479"><span class="linenos">479</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">table_name</span><span class="p">)</span> </span></pre></div> @@ -1084,22 +1064,22 @@ </div> <a class="headerlink" href="#Resolver.get_source_columns"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Resolver.get_source_columns-500"><a href="#Resolver.get_source_columns-500"><span class="linenos">500</span></a> <span class="k">def</span> <span class="nf">get_source_columns</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">only_visible</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> -</span><span id="Resolver.get_source_columns-501"><a href="#Resolver.get_source_columns-501"><span class="linenos">501</span></a><span class="w"> </span><span class="sd">"""Resolve the source columns for a given source `name`"""</span> -</span><span id="Resolver.get_source_columns-502"><a href="#Resolver.get_source_columns-502"><span class="linenos">502</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="p">:</span> -</span><span id="Resolver.get_source_columns-503"><a href="#Resolver.get_source_columns-503"><span class="linenos">503</span></a> <span class="k">raise</span> <span class="n">OptimizeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unknown table: </span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Resolver.get_source_columns-504"><a href="#Resolver.get_source_columns-504"><span class="linenos">504</span></a> -</span><span id="Resolver.get_source_columns-505"><a href="#Resolver.get_source_columns-505"><span class="linenos">505</span></a> <span class="n">source</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> -</span><span id="Resolver.get_source_columns-506"><a href="#Resolver.get_source_columns-506"><span class="linenos">506</span></a> -</span><span id="Resolver.get_source_columns-507"><a href="#Resolver.get_source_columns-507"><span class="linenos">507</span></a> <span class="c1"># If referencing a table, return the columns from the schema</span> -</span><span id="Resolver.get_source_columns-508"><a href="#Resolver.get_source_columns-508"><span class="linenos">508</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">):</span> -</span><span id="Resolver.get_source_columns-509"><a href="#Resolver.get_source_columns-509"><span class="linenos">509</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">column_names</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">only_visible</span><span class="p">)</span> -</span><span id="Resolver.get_source_columns-510"><a href="#Resolver.get_source_columns-510"><span class="linenos">510</span></a> -</span><span id="Resolver.get_source_columns-511"><a href="#Resolver.get_source_columns-511"><span class="linenos">511</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">Scope</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</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">Values</span><span class="p">):</span> -</span><span id="Resolver.get_source_columns-512"><a href="#Resolver.get_source_columns-512"><span class="linenos">512</span></a> <span class="k">return</span> <span class="n">source</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">alias_column_names</span> -</span><span id="Resolver.get_source_columns-513"><a href="#Resolver.get_source_columns-513"><span class="linenos">513</span></a> -</span><span id="Resolver.get_source_columns-514"><a href="#Resolver.get_source_columns-514"><span class="linenos">514</span></a> <span class="c1"># Otherwise, if referencing another scope, return that scope's named selects</span> -</span><span id="Resolver.get_source_columns-515"><a href="#Resolver.get_source_columns-515"><span class="linenos">515</span></a> <span class="k">return</span> <span class="n">source</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">named_selects</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Resolver.get_source_columns-490"><a href="#Resolver.get_source_columns-490"><span class="linenos">490</span></a> <span class="k">def</span> <span class="nf">get_source_columns</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">only_visible</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> +</span><span id="Resolver.get_source_columns-491"><a href="#Resolver.get_source_columns-491"><span class="linenos">491</span></a><span class="w"> </span><span class="sd">"""Resolve the source columns for a given source `name`"""</span> +</span><span id="Resolver.get_source_columns-492"><a href="#Resolver.get_source_columns-492"><span class="linenos">492</span></a> <span class="k">if</span> <span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="p">:</span> +</span><span id="Resolver.get_source_columns-493"><a href="#Resolver.get_source_columns-493"><span class="linenos">493</span></a> <span class="k">raise</span> <span class="n">OptimizeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unknown table: </span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Resolver.get_source_columns-494"><a href="#Resolver.get_source_columns-494"><span class="linenos">494</span></a> +</span><span id="Resolver.get_source_columns-495"><a href="#Resolver.get_source_columns-495"><span class="linenos">495</span></a> <span class="n">source</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> +</span><span id="Resolver.get_source_columns-496"><a href="#Resolver.get_source_columns-496"><span class="linenos">496</span></a> +</span><span id="Resolver.get_source_columns-497"><a href="#Resolver.get_source_columns-497"><span class="linenos">497</span></a> <span class="c1"># If referencing a table, return the columns from the schema</span> +</span><span id="Resolver.get_source_columns-498"><a href="#Resolver.get_source_columns-498"><span class="linenos">498</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">):</span> +</span><span id="Resolver.get_source_columns-499"><a href="#Resolver.get_source_columns-499"><span class="linenos">499</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">schema</span><span class="o">.</span><span class="n">column_names</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">only_visible</span><span class="p">)</span> +</span><span id="Resolver.get_source_columns-500"><a href="#Resolver.get_source_columns-500"><span class="linenos">500</span></a> +</span><span id="Resolver.get_source_columns-501"><a href="#Resolver.get_source_columns-501"><span class="linenos">501</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">Scope</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</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">Values</span><span class="p">):</span> +</span><span id="Resolver.get_source_columns-502"><a href="#Resolver.get_source_columns-502"><span class="linenos">502</span></a> <span class="k">return</span> <span class="n">source</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">alias_column_names</span> +</span><span id="Resolver.get_source_columns-503"><a href="#Resolver.get_source_columns-503"><span class="linenos">503</span></a> +</span><span id="Resolver.get_source_columns-504"><a href="#Resolver.get_source_columns-504"><span class="linenos">504</span></a> <span class="c1"># Otherwise, if referencing another scope, return that scope's named selects</span> +</span><span id="Resolver.get_source_columns-505"><a href="#Resolver.get_source_columns-505"><span class="linenos">505</span></a> <span class="k">return</span> <span class="n">source</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">named_selects</span> </span></pre></div> diff --git a/docs/sqlglot/parser.html b/docs/sqlglot/parser.html index 8edbe48..763a89d 100644 --- a/docs/sqlglot/parser.html +++ b/docs/sqlglot/parser.html @@ -559,7 +559,7 @@ </span><span id="L-465"><a href="#L-465"><span class="linenos"> 465</span></a> <span class="p">}</span> </span><span id="L-466"><a href="#L-466"><span class="linenos"> 466</span></a> </span><span id="L-467"><a href="#L-467"><span class="linenos"> 467</span></a> <span class="n">EXPRESSION_PARSERS</span> <span class="o">=</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">Cluster</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">,</span> <span class="s2">"CLUSTER"</span><span class="p">,</span> <span class="s2">"BY"</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">Cluster</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CLUSTER_BY</span><span class="p">),</span> </span><span id="L-469"><a href="#L-469"><span class="linenos"> 469</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Column</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_column</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">Condition</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_conjunction</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">DataType</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_types</span><span class="p">(),</span> @@ -578,7 +578,7 @@ </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">Properties</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_properties</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">Qualify</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_qualify</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">Returning</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_returning</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">Sort</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">,</span> <span class="s2">"SORT"</span><span class="p">,</span> <span class="s2">"BY"</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">Sort</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SORT_BY</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">Table</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_table_parts</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">TableAlias</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_table_alias</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">Where</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_where</span><span class="p">(),</span> @@ -678,4096 +678,4104 @@ </span><span id="L-584"><a href="#L-584"><span class="linenos"> 584</span></a> <span class="s2">"BLOCKCOMPRESSION"</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_blockcompression</span><span class="p">(),</span> </span><span id="L-585"><a href="#L-585"><span class="linenos"> 585</span></a> <span class="s2">"CHARACTER SET"</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_character_set</span><span class="p">(),</span> </span><span id="L-586"><a href="#L-586"><span class="linenos"> 586</span></a> <span class="s2">"CHECKSUM"</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_checksum</span><span class="p">(),</span> -</span><span id="L-587"><a href="#L-587"><span class="linenos"> 587</span></a> <span class="s2">"CLUSTER"</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_cluster</span><span class="p">(),</span> +</span><span id="L-587"><a href="#L-587"><span class="linenos"> 587</span></a> <span class="s2">"CLUSTER BY"</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_cluster</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 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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">CollateProperty</span><span class="p">),</span> </span><span id="L-589"><a href="#L-589"><span class="linenos"> 589</span></a> <span class="s2">"COMMENT"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</span><span class="p">),</span> -</span><span id="L-590"><a href="#L-590"><span class="linenos"> 590</span></a> <span class="s2">"DATABLOCKSIZE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_datablocksize</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> -</span><span id="L-591"><a href="#L-591"><span class="linenos"> 591</span></a> <span class="s2">"DEFINER"</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_definer</span><span class="p">(),</span> -</span><span id="L-592"><a href="#L-592"><span class="linenos"> 592</span></a> <span class="s2">"DETERMINISTIC"</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">expression</span><span class="p">(</span> -</span><span id="L-593"><a href="#L-593"><span class="linenos"> 593</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"IMMUTABLE"</span><span class="p">)</span> -</span><span id="L-594"><a href="#L-594"><span class="linenos"> 594</span></a> <span class="p">),</span> -</span><span id="L-595"><a href="#L-595"><span class="linenos"> 595</span></a> <span class="s2">"DISTKEY"</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_distkey</span><span class="p">(),</span> -</span><span id="L-596"><a href="#L-596"><span class="linenos"> 596</span></a> <span class="s2">"DISTSTYLE"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">),</span> -</span><span id="L-597"><a href="#L-597"><span class="linenos"> 597</span></a> <span class="s2">"ENGINE"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">EngineProperty</span><span class="p">),</span> -</span><span id="L-598"><a href="#L-598"><span class="linenos"> 598</span></a> <span class="s2">"EXECUTE"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ExecuteAsProperty</span><span class="p">),</span> -</span><span id="L-599"><a href="#L-599"><span class="linenos"> 599</span></a> <span class="s2">"EXTERNAL"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ExternalProperty</span><span class="p">),</span> -</span><span id="L-600"><a href="#L-600"><span class="linenos"> 600</span></a> <span class="s2">"FALLBACK"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_fallback</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> -</span><span id="L-601"><a href="#L-601"><span class="linenos"> 601</span></a> <span class="s2">"FORMAT"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">),</span> -</span><span id="L-602"><a href="#L-602"><span class="linenos"> 602</span></a> <span class="s2">"FREESPACE"</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_freespace</span><span class="p">(),</span> -</span><span id="L-603"><a href="#L-603"><span class="linenos"> 603</span></a> <span class="s2">"IMMUTABLE"</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">expression</span><span class="p">(</span> -</span><span id="L-604"><a href="#L-604"><span class="linenos"> 604</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"IMMUTABLE"</span><span class="p">)</span> -</span><span id="L-605"><a href="#L-605"><span class="linenos"> 605</span></a> <span class="p">),</span> -</span><span id="L-606"><a href="#L-606"><span class="linenos"> 606</span></a> <span class="s2">"JOURNAL"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_journal</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> -</span><span id="L-607"><a href="#L-607"><span class="linenos"> 607</span></a> <span class="s2">"LANGUAGE"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LanguageProperty</span><span class="p">),</span> -</span><span id="L-608"><a href="#L-608"><span class="linenos"> 608</span></a> <span class="s2">"LAYOUT"</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_dict_property</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"LAYOUT"</span><span class="p">),</span> -</span><span id="L-609"><a href="#L-609"><span class="linenos"> 609</span></a> <span class="s2">"LIFETIME"</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_dict_range</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"LIFETIME"</span><span class="p">),</span> -</span><span id="L-610"><a href="#L-610"><span class="linenos"> 610</span></a> <span class="s2">"LIKE"</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_create_like</span><span class="p">(),</span> -</span><span id="L-611"><a href="#L-611"><span class="linenos"> 611</span></a> <span class="s2">"LOCATION"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">),</span> -</span><span id="L-612"><a href="#L-612"><span class="linenos"> 612</span></a> <span class="s2">"LOCK"</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_locking</span><span class="p">(),</span> -</span><span id="L-613"><a href="#L-613"><span class="linenos"> 613</span></a> <span class="s2">"LOCKING"</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_locking</span><span class="p">(),</span> -</span><span id="L-614"><a href="#L-614"><span class="linenos"> 614</span></a> <span class="s2">"LOG"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_log</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> -</span><span id="L-615"><a href="#L-615"><span class="linenos"> 615</span></a> <span class="s2">"MATERIALIZED"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">MaterializedProperty</span><span class="p">),</span> -</span><span id="L-616"><a href="#L-616"><span class="linenos"> 616</span></a> <span class="s2">"MERGEBLOCKRATIO"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_mergeblockratio</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> -</span><span id="L-617"><a href="#L-617"><span class="linenos"> 617</span></a> <span class="s2">"MULTISET"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">,</span> <span class="n">multi</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="L-618"><a href="#L-618"><span class="linenos"> 618</span></a> <span class="s2">"NO"</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_no_property</span><span class="p">(),</span> -</span><span id="L-619"><a href="#L-619"><span class="linenos"> 619</span></a> <span class="s2">"ON"</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_on_property</span><span class="p">(),</span> -</span><span id="L-620"><a href="#L-620"><span class="linenos"> 620</span></a> <span class="s2">"ORDER BY"</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_order</span><span class="p">(</span><span class="n">skip_order_token</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="L-621"><a href="#L-621"><span class="linenos"> 621</span></a> <span class="s2">"PARTITION BY"</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_partitioned_by</span><span class="p">(),</span> -</span><span id="L-622"><a href="#L-622"><span class="linenos"> 622</span></a> <span class="s2">"PARTITIONED BY"</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_partitioned_by</span><span class="p">(),</span> -</span><span id="L-623"><a href="#L-623"><span class="linenos"> 623</span></a> <span class="s2">"PARTITIONED_BY"</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_partitioned_by</span><span class="p">(),</span> -</span><span id="L-624"><a href="#L-624"><span class="linenos"> 624</span></a> <span class="s2">"PRIMARY KEY"</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_primary_key</span><span class="p">(</span><span class="n">in_props</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="L-625"><a href="#L-625"><span class="linenos"> 625</span></a> <span class="s2">"RANGE"</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_dict_range</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"RANGE"</span><span class="p">),</span> -</span><span id="L-626"><a href="#L-626"><span class="linenos"> 626</span></a> <span class="s2">"RETURNS"</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_returns</span><span class="p">(),</span> -</span><span id="L-627"><a href="#L-627"><span class="linenos"> 627</span></a> <span class="s2">"ROW"</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_row</span><span class="p">(),</span> -</span><span id="L-628"><a href="#L-628"><span class="linenos"> 628</span></a> <span class="s2">"ROW_FORMAT"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">RowFormatProperty</span><span class="p">),</span> -</span><span id="L-629"><a href="#L-629"><span class="linenos"> 629</span></a> <span class="s2">"SET"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">,</span> <span class="n">multi</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="L-630"><a href="#L-630"><span class="linenos"> 630</span></a> <span class="s2">"SETTINGS"</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">expression</span><span class="p">(</span> -</span><span id="L-631"><a href="#L-631"><span class="linenos"> 631</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SettingsProperty</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_item</span><span class="p">)</span> -</span><span id="L-632"><a href="#L-632"><span class="linenos"> 632</span></a> <span class="p">),</span> -</span><span id="L-633"><a href="#L-633"><span class="linenos"> 633</span></a> <span class="s2">"SORTKEY"</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_sortkey</span><span class="p">(),</span> -</span><span id="L-634"><a href="#L-634"><span class="linenos"> 634</span></a> <span class="s2">"SOURCE"</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_dict_property</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"SOURCE"</span><span class="p">),</span> -</span><span id="L-635"><a href="#L-635"><span class="linenos"> 635</span></a> <span class="s2">"STABLE"</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">expression</span><span class="p">(</span> -</span><span id="L-636"><a href="#L-636"><span class="linenos"> 636</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"STABLE"</span><span class="p">)</span> -</span><span id="L-637"><a href="#L-637"><span class="linenos"> 637</span></a> <span class="p">),</span> -</span><span id="L-638"><a href="#L-638"><span class="linenos"> 638</span></a> <span class="s2">"STORED"</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_stored</span><span class="p">(),</span> -</span><span id="L-639"><a href="#L-639"><span class="linenos"> 639</span></a> <span class="s2">"TBLPROPERTIES"</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_wrapped_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_property</span><span class="p">),</span> -</span><span id="L-640"><a href="#L-640"><span class="linenos"> 640</span></a> <span class="s2">"TEMP"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">),</span> -</span><span id="L-641"><a href="#L-641"><span class="linenos"> 641</span></a> <span class="s2">"TEMPORARY"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">),</span> -</span><span id="L-642"><a href="#L-642"><span class="linenos"> 642</span></a> <span class="s2">"TO"</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_to_table</span><span class="p">(),</span> -</span><span id="L-643"><a href="#L-643"><span class="linenos"> 643</span></a> <span class="s2">"TRANSIENT"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TransientProperty</span><span class="p">),</span> -</span><span id="L-644"><a href="#L-644"><span class="linenos"> 644</span></a> <span class="s2">"TTL"</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_ttl</span><span class="p">(),</span> -</span><span id="L-645"><a href="#L-645"><span class="linenos"> 645</span></a> <span class="s2">"USING"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">),</span> -</span><span id="L-646"><a href="#L-646"><span class="linenos"> 646</span></a> <span class="s2">"VOLATILE"</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_volatile_property</span><span class="p">(),</span> -</span><span id="L-647"><a href="#L-647"><span class="linenos"> 647</span></a> <span class="s2">"WITH"</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_with_property</span><span class="p">(),</span> -</span><span id="L-648"><a href="#L-648"><span class="linenos"> 648</span></a> <span class="p">}</span> -</span><span id="L-649"><a href="#L-649"><span class="linenos"> 649</span></a> -</span><span id="L-650"><a href="#L-650"><span class="linenos"> 650</span></a> <span class="n">CONSTRAINT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-651"><a href="#L-651"><span class="linenos"> 651</span></a> <span class="s2">"AUTOINCREMENT"</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_auto_increment</span><span class="p">(),</span> -</span><span id="L-652"><a href="#L-652"><span class="linenos"> 652</span></a> <span class="s2">"AUTO_INCREMENT"</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_auto_increment</span><span class="p">(),</span> -</span><span id="L-653"><a href="#L-653"><span class="linenos"> 653</span></a> <span class="s2">"CASESPECIFIC"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">CaseSpecificColumnConstraint</span><span class="p">,</span> <span class="n">not_</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="L-654"><a href="#L-654"><span class="linenos"> 654</span></a> <span class="s2">"CHARACTER SET"</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">expression</span><span class="p">(</span> -</span><span id="L-655"><a href="#L-655"><span class="linenos"> 655</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetColumnConstraint</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_var_or_string</span><span class="p">()</span> -</span><span id="L-656"><a href="#L-656"><span class="linenos"> 656</span></a> <span class="p">),</span> -</span><span id="L-657"><a href="#L-657"><span class="linenos"> 657</span></a> <span class="s2">"CHECK"</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">expression</span><span class="p">(</span> -</span><span id="L-658"><a href="#L-658"><span class="linenos"> 658</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CheckColumnConstraint</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_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="L-659"><a href="#L-659"><span class="linenos"> 659</span></a> <span class="p">),</span> -</span><span id="L-660"><a href="#L-660"><span class="linenos"> 660</span></a> <span class="s2">"COLLATE"</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">expression</span><span class="p">(</span> -</span><span id="L-661"><a href="#L-661"><span class="linenos"> 661</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateColumnConstraint</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_var</span><span class="p">()</span> -</span><span id="L-662"><a href="#L-662"><span class="linenos"> 662</span></a> <span class="p">),</span> -</span><span id="L-663"><a href="#L-663"><span class="linenos"> 663</span></a> <span class="s2">"COMMENT"</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">expression</span><span class="p">(</span> -</span><span id="L-664"><a href="#L-664"><span class="linenos"> 664</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CommentColumnConstraint</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_string</span><span class="p">()</span> -</span><span id="L-665"><a href="#L-665"><span class="linenos"> 665</span></a> <span class="p">),</span> -</span><span id="L-666"><a href="#L-666"><span class="linenos"> 666</span></a> <span class="s2">"COMPRESS"</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_compress</span><span class="p">(),</span> -</span><span id="L-667"><a href="#L-667"><span class="linenos"> 667</span></a> <span class="s2">"DEFAULT"</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">expression</span><span class="p">(</span> -</span><span id="L-668"><a href="#L-668"><span class="linenos"> 668</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DefaultColumnConstraint</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_bitwise</span><span class="p">()</span> -</span><span id="L-669"><a href="#L-669"><span class="linenos"> 669</span></a> <span class="p">),</span> -</span><span id="L-670"><a href="#L-670"><span class="linenos"> 670</span></a> <span class="s2">"ENCODE"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">EncodeColumnConstraint</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_var</span><span class="p">()),</span> -</span><span id="L-671"><a href="#L-671"><span class="linenos"> 671</span></a> <span class="s2">"FOREIGN KEY"</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_foreign_key</span><span class="p">(),</span> -</span><span id="L-672"><a href="#L-672"><span class="linenos"> 672</span></a> <span class="s2">"FORMAT"</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">expression</span><span class="p">(</span> -</span><span id="L-673"><a href="#L-673"><span class="linenos"> 673</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFormatColumnConstraint</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_var_or_string</span><span class="p">()</span> -</span><span id="L-674"><a href="#L-674"><span class="linenos"> 674</span></a> <span class="p">),</span> -</span><span id="L-675"><a href="#L-675"><span class="linenos"> 675</span></a> <span class="s2">"GENERATED"</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_generated_as_identity</span><span class="p">(),</span> -</span><span id="L-676"><a href="#L-676"><span class="linenos"> 676</span></a> <span class="s2">"IDENTITY"</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_auto_increment</span><span class="p">(),</span> -</span><span id="L-677"><a href="#L-677"><span class="linenos"> 677</span></a> <span class="s2">"INLINE"</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_inline</span><span class="p">(),</span> -</span><span id="L-678"><a href="#L-678"><span class="linenos"> 678</span></a> <span class="s2">"LIKE"</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_create_like</span><span class="p">(),</span> -</span><span id="L-679"><a href="#L-679"><span class="linenos"> 679</span></a> <span class="s2">"NOT"</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_not_constraint</span><span class="p">(),</span> -</span><span id="L-680"><a href="#L-680"><span class="linenos"> 680</span></a> <span class="s2">"NULL"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">NotNullColumnConstraint</span><span class="p">,</span> <span class="n">allow_null</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="L-681"><a href="#L-681"><span class="linenos"> 681</span></a> <span class="s2">"ON"</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">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">UPDATE</span><span class="p">)</span> -</span><span id="L-682"><a href="#L-682"><span class="linenos"> 682</span></a> <span class="ow">and</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">OnUpdateColumnConstraint</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_function</span><span class="p">()),</span> -</span><span id="L-683"><a href="#L-683"><span class="linenos"> 683</span></a> <span class="s2">"PATH"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">PathColumnConstraint</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_string</span><span class="p">()),</span> -</span><span id="L-684"><a href="#L-684"><span class="linenos"> 684</span></a> <span class="s2">"PRIMARY KEY"</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_primary_key</span><span class="p">(),</span> -</span><span id="L-685"><a href="#L-685"><span class="linenos"> 685</span></a> <span class="s2">"REFERENCES"</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_references</span><span class="p">(</span><span class="n">match</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="L-686"><a href="#L-686"><span class="linenos"> 686</span></a> <span class="s2">"TITLE"</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">expression</span><span class="p">(</span> -</span><span id="L-687"><a href="#L-687"><span class="linenos"> 687</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TitleColumnConstraint</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_var_or_string</span><span class="p">()</span> -</span><span id="L-688"><a href="#L-688"><span class="linenos"> 688</span></a> <span class="p">),</span> -</span><span id="L-689"><a href="#L-689"><span class="linenos"> 689</span></a> <span class="s2">"TTL"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()]),</span> -</span><span id="L-690"><a href="#L-690"><span class="linenos"> 690</span></a> <span class="s2">"UNIQUE"</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_unique</span><span class="p">(),</span> -</span><span id="L-691"><a href="#L-691"><span class="linenos"> 691</span></a> <span class="s2">"UPPERCASE"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">UppercaseColumnConstraint</span><span class="p">),</span> -</span><span id="L-692"><a href="#L-692"><span class="linenos"> 692</span></a> <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="n">ALTER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-695"><a href="#L-695"><span class="linenos"> 695</span></a> <span class="s2">"ADD"</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_alter_table_add</span><span class="p">(),</span> -</span><span id="L-696"><a href="#L-696"><span class="linenos"> 696</span></a> <span class="s2">"ALTER"</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_alter_table_alter</span><span class="p">(),</span> -</span><span id="L-697"><a href="#L-697"><span class="linenos"> 697</span></a> <span class="s2">"DELETE"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">,</span> <span class="n">where</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">()),</span> -</span><span id="L-698"><a href="#L-698"><span class="linenos"> 698</span></a> <span class="s2">"DROP"</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_alter_table_drop</span><span class="p">(),</span> -</span><span id="L-699"><a href="#L-699"><span class="linenos"> 699</span></a> <span class="s2">"RENAME"</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_alter_table_rename</span><span class="p">(),</span> -</span><span id="L-700"><a href="#L-700"><span class="linenos"> 700</span></a> <span class="p">}</span> -</span><span id="L-701"><a href="#L-701"><span class="linenos"> 701</span></a> -</span><span id="L-702"><a href="#L-702"><span class="linenos"> 702</span></a> <span class="n">SCHEMA_UNNAMED_CONSTRAINTS</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"CHECK"</span><span class="p">,</span> <span class="s2">"FOREIGN KEY"</span><span class="p">,</span> <span class="s2">"LIKE"</span><span class="p">,</span> <span class="s2">"PRIMARY KEY"</span><span class="p">,</span> <span class="s2">"UNIQUE"</span><span class="p">}</span> -</span><span id="L-703"><a href="#L-703"><span class="linenos"> 703</span></a> -</span><span id="L-704"><a href="#L-704"><span class="linenos"> 704</span></a> <span class="n">NO_PAREN_FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-705"><a href="#L-705"><span class="linenos"> 705</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ANY</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()),</span> -</span><span id="L-706"><a href="#L-706"><span class="linenos"> 706</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">CASE</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_case</span><span class="p">(),</span> -</span><span id="L-707"><a href="#L-707"><span class="linenos"> 707</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">IF</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_if</span><span class="p">(),</span> -</span><span id="L-708"><a href="#L-708"><span class="linenos"> 708</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEXT_VALUE_FOR</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">expression</span><span class="p">(</span> -</span><span id="L-709"><a href="#L-709"><span class="linenos"> 709</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NextValueFor</span><span class="p">,</span> -</span><span id="L-710"><a href="#L-710"><span class="linenos"> 710</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">(),</span> -</span><span id="L-711"><a href="#L-711"><span class="linenos"> 711</span></a> <span class="n">order</span><span class="o">=</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">OVER</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">),</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="p">}</span> -</span><span id="L-714"><a href="#L-714"><span class="linenos"> 714</span></a> -</span><span id="L-715"><a href="#L-715"><span class="linenos"> 715</span></a> <span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"STRUCT"</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="n">FUNCTION_PARSERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-718"><a href="#L-718"><span class="linenos"> 718</span></a> <span class="s2">"CAST"</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_cast</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STRICT_CAST</span><span class="p">),</span> -</span><span id="L-719"><a href="#L-719"><span class="linenos"> 719</span></a> <span class="s2">"CONCAT"</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_concat</span><span class="p">(),</span> -</span><span id="L-720"><a href="#L-720"><span class="linenos"> 720</span></a> <span class="s2">"CONVERT"</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_convert</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STRICT_CAST</span><span class="p">),</span> -</span><span id="L-721"><a href="#L-721"><span class="linenos"> 721</span></a> <span class="s2">"DECODE"</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_decode</span><span class="p">(),</span> -</span><span id="L-722"><a href="#L-722"><span class="linenos"> 722</span></a> <span class="s2">"EXTRACT"</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_extract</span><span class="p">(),</span> -</span><span id="L-723"><a href="#L-723"><span class="linenos"> 723</span></a> <span class="s2">"JSON_OBJECT"</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_json_object</span><span class="p">(),</span> -</span><span id="L-724"><a href="#L-724"><span class="linenos"> 724</span></a> <span class="s2">"LOG"</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_logarithm</span><span class="p">(),</span> -</span><span id="L-725"><a href="#L-725"><span class="linenos"> 725</span></a> <span class="s2">"MATCH"</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_match_against</span><span class="p">(),</span> -</span><span id="L-726"><a href="#L-726"><span class="linenos"> 726</span></a> <span class="s2">"OPENJSON"</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_open_json</span><span class="p">(),</span> -</span><span id="L-727"><a href="#L-727"><span class="linenos"> 727</span></a> <span class="s2">"POSITION"</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_position</span><span class="p">(),</span> -</span><span id="L-728"><a href="#L-728"><span class="linenos"> 728</span></a> <span class="s2">"SAFE_CAST"</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_cast</span><span class="p">(</span><span class="kc">False</span><span class="p">),</span> -</span><span id="L-729"><a href="#L-729"><span class="linenos"> 729</span></a> <span class="s2">"STRING_AGG"</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_string_agg</span><span class="p">(),</span> -</span><span id="L-730"><a href="#L-730"><span class="linenos"> 730</span></a> <span class="s2">"SUBSTRING"</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_substring</span><span class="p">(),</span> -</span><span id="L-731"><a href="#L-731"><span class="linenos"> 731</span></a> <span class="s2">"TRIM"</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_trim</span><span class="p">(),</span> -</span><span id="L-732"><a href="#L-732"><span class="linenos"> 732</span></a> <span class="s2">"TRY_CAST"</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_cast</span><span class="p">(</span><span class="kc">False</span><span class="p">),</span> -</span><span id="L-733"><a href="#L-733"><span class="linenos"> 733</span></a> <span class="s2">"TRY_CONVERT"</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_convert</span><span class="p">(</span><span class="kc">False</span><span class="p">),</span> -</span><span id="L-734"><a href="#L-734"><span class="linenos"> 734</span></a> <span class="p">}</span> -</span><span id="L-735"><a href="#L-735"><span class="linenos"> 735</span></a> -</span><span id="L-736"><a href="#L-736"><span class="linenos"> 736</span></a> <span class="n">QUERY_MODIFIER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-737"><a href="#L-737"><span class="linenos"> 737</span></a> <span class="s2">"joins"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="nb">list</span><span class="p">(</span><span class="nb">iter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_join</span><span class="p">,</span> <span class="kc">None</span><span class="p">)),</span> -</span><span id="L-738"><a href="#L-738"><span class="linenos"> 738</span></a> <span class="s2">"laterals"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="nb">list</span><span class="p">(</span><span class="nb">iter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_lateral</span><span class="p">,</span> <span class="kc">None</span><span class="p">)),</span> -</span><span id="L-739"><a href="#L-739"><span class="linenos"> 739</span></a> <span class="s2">"match"</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_match_recognize</span><span class="p">(),</span> -</span><span id="L-740"><a href="#L-740"><span class="linenos"> 740</span></a> <span class="s2">"where"</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_where</span><span class="p">(),</span> -</span><span id="L-741"><a href="#L-741"><span class="linenos"> 741</span></a> <span class="s2">"group"</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_group</span><span class="p">(),</span> -</span><span id="L-742"><a href="#L-742"><span class="linenos"> 742</span></a> <span class="s2">"having"</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_having</span><span class="p">(),</span> -</span><span id="L-743"><a href="#L-743"><span class="linenos"> 743</span></a> <span class="s2">"qualify"</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_qualify</span><span class="p">(),</span> -</span><span id="L-744"><a href="#L-744"><span class="linenos"> 744</span></a> <span class="s2">"windows"</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_window_clause</span><span class="p">(),</span> -</span><span id="L-745"><a href="#L-745"><span class="linenos"> 745</span></a> <span class="s2">"order"</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_order</span><span class="p">(),</span> -</span><span id="L-746"><a href="#L-746"><span class="linenos"> 746</span></a> <span class="s2">"limit"</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_limit</span><span class="p">(),</span> -</span><span id="L-747"><a href="#L-747"><span class="linenos"> 747</span></a> <span class="s2">"offset"</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_offset</span><span class="p">(),</span> -</span><span id="L-748"><a href="#L-748"><span class="linenos"> 748</span></a> <span class="s2">"locks"</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_locks</span><span class="p">(),</span> -</span><span id="L-749"><a href="#L-749"><span class="linenos"> 749</span></a> <span class="s2">"sample"</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_table_sample</span><span class="p">(</span><span class="n">as_modifier</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="L-750"><a href="#L-750"><span class="linenos"> 750</span></a> <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="n">SET_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-753"><a href="#L-753"><span class="linenos"> 753</span></a> <span class="s2">"GLOBAL"</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_set_item_assignment</span><span class="p">(</span><span class="s2">"GLOBAL"</span><span class="p">),</span> -</span><span id="L-754"><a href="#L-754"><span class="linenos"> 754</span></a> <span class="s2">"LOCAL"</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_set_item_assignment</span><span class="p">(</span><span class="s2">"LOCAL"</span><span class="p">),</span> -</span><span id="L-755"><a href="#L-755"><span class="linenos"> 755</span></a> <span class="s2">"SESSION"</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_set_item_assignment</span><span class="p">(</span><span class="s2">"SESSION"</span><span class="p">),</span> -</span><span id="L-756"><a href="#L-756"><span class="linenos"> 756</span></a> <span class="s2">"TRANSACTION"</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_set_transaction</span><span class="p">(),</span> -</span><span id="L-757"><a href="#L-757"><span class="linenos"> 757</span></a> <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="n">SHOW_PARSERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-760"><a href="#L-760"><span class="linenos"> 760</span></a> -</span><span id="L-761"><a href="#L-761"><span class="linenos"> 761</span></a> <span class="n">TYPE_LITERAL_PARSERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><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">MODIFIABLES</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</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="n">DDL_SELECT_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SELECT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">}</span> -</span><span id="L-766"><a href="#L-766"><span class="linenos"> 766</span></a> -</span><span id="L-767"><a href="#L-767"><span class="linenos"> 767</span></a> <span class="n">PRE_VOLATILE_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">CREATE</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNIQUE</span><span class="p">}</span> -</span><span id="L-768"><a href="#L-768"><span class="linenos"> 768</span></a> -</span><span id="L-769"><a href="#L-769"><span class="linenos"> 769</span></a> <span class="n">TRANSACTION_KIND</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"DEFERRED"</span><span class="p">,</span> <span class="s2">"IMMEDIATE"</span><span class="p">,</span> <span class="s2">"EXCLUSIVE"</span><span class="p">}</span> -</span><span id="L-770"><a href="#L-770"><span class="linenos"> 770</span></a> <span class="n">TRANSACTION_CHARACTERISTICS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-771"><a href="#L-771"><span class="linenos"> 771</span></a> <span class="s2">"ISOLATION LEVEL REPEATABLE READ"</span><span class="p">,</span> -</span><span id="L-772"><a href="#L-772"><span class="linenos"> 772</span></a> <span class="s2">"ISOLATION LEVEL READ COMMITTED"</span><span class="p">,</span> -</span><span id="L-773"><a href="#L-773"><span class="linenos"> 773</span></a> <span class="s2">"ISOLATION LEVEL READ UNCOMMITTED"</span><span class="p">,</span> -</span><span id="L-774"><a href="#L-774"><span class="linenos"> 774</span></a> <span class="s2">"ISOLATION LEVEL SERIALIZABLE"</span><span class="p">,</span> -</span><span id="L-775"><a href="#L-775"><span class="linenos"> 775</span></a> <span class="s2">"READ WRITE"</span><span class="p">,</span> -</span><span id="L-776"><a href="#L-776"><span class="linenos"> 776</span></a> <span class="s2">"READ ONLY"</span><span class="p">,</span> -</span><span id="L-777"><a href="#L-777"><span class="linenos"> 777</span></a> <span class="p">}</span> -</span><span id="L-778"><a href="#L-778"><span class="linenos"> 778</span></a> -</span><span id="L-779"><a href="#L-779"><span class="linenos"> 779</span></a> <span class="n">INSERT_ALTERNATIVES</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"ABORT"</span><span class="p">,</span> <span class="s2">"FAIL"</span><span class="p">,</span> <span class="s2">"IGNORE"</span><span class="p">,</span> <span class="s2">"REPLACE"</span><span class="p">,</span> <span class="s2">"ROLLBACK"</span><span class="p">}</span> -</span><span id="L-780"><a href="#L-780"><span class="linenos"> 780</span></a> -</span><span id="L-781"><a href="#L-781"><span class="linenos"> 781</span></a> <span class="n">CLONE_KINDS</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"OFFSET"</span><span class="p">,</span> <span class="s2">"STATEMENT"</span><span class="p">}</span> -</span><span id="L-782"><a href="#L-782"><span class="linenos"> 782</span></a> -</span><span id="L-783"><a href="#L-783"><span class="linenos"> 783</span></a> <span class="n">WINDOW_ALIAS_TOKENS</span> <span class="o">=</span> <span class="n">ID_VAR_TOKENS</span> <span class="o">-</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">}</span> -</span><span id="L-784"><a href="#L-784"><span class="linenos"> 784</span></a> <span class="n">WINDOW_BEFORE_PAREN_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">OVER</span><span class="p">}</span> -</span><span id="L-785"><a href="#L-785"><span class="linenos"> 785</span></a> <span class="n">WINDOW_SIDES</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"FOLLOWING"</span><span class="p">,</span> <span class="s2">"PRECEDING"</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">ADD_CONSTRAINT_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">CONSTRAINT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PRIMARY_KEY</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FOREIGN_KEY</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="n">STRICT_CAST</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-790"><a href="#L-790"><span class="linenos"> 790</span></a> -</span><span id="L-791"><a href="#L-791"><span class="linenos"> 791</span></a> <span class="n">CONCAT_NULL_OUTPUTS_STRING</span> <span class="o">=</span> <span class="kc">False</span> <span class="c1"># A NULL arg in CONCAT yields NULL by default</span> -</span><span id="L-792"><a href="#L-792"><span class="linenos"> 792</span></a> -</span><span id="L-793"><a href="#L-793"><span class="linenos"> 793</span></a> <span class="n">CONVERT_TYPE_FIRST</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-794"><a href="#L-794"><span class="linenos"> 794</span></a> -</span><span id="L-795"><a href="#L-795"><span class="linenos"> 795</span></a> <span class="n">PREFIXED_PIVOT_COLUMNS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-796"><a href="#L-796"><span class="linenos"> 796</span></a> <span class="n">IDENTIFY_PIVOT_STRINGS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-797"><a href="#L-797"><span class="linenos"> 797</span></a> -</span><span id="L-798"><a href="#L-798"><span class="linenos"> 798</span></a> <span class="n">LOG_BASE_FIRST</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-799"><a href="#L-799"><span class="linenos"> 799</span></a> <span class="n">LOG_DEFAULTS_TO_LN</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-800"><a href="#L-800"><span class="linenos"> 800</span></a> -</span><span id="L-801"><a href="#L-801"><span class="linenos"> 801</span></a> <span class="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-802"><a href="#L-802"><span class="linenos"> 802</span></a> <span class="s2">"error_level"</span><span class="p">,</span> -</span><span id="L-803"><a href="#L-803"><span class="linenos"> 803</span></a> <span class="s2">"error_message_context"</span><span class="p">,</span> -</span><span id="L-804"><a href="#L-804"><span class="linenos"> 804</span></a> <span class="s2">"max_errors"</span><span class="p">,</span> -</span><span id="L-805"><a href="#L-805"><span class="linenos"> 805</span></a> <span class="s2">"sql"</span><span class="p">,</span> -</span><span id="L-806"><a href="#L-806"><span class="linenos"> 806</span></a> <span class="s2">"errors"</span><span class="p">,</span> -</span><span id="L-807"><a href="#L-807"><span class="linenos"> 807</span></a> <span class="s2">"_tokens"</span><span class="p">,</span> -</span><span id="L-808"><a href="#L-808"><span class="linenos"> 808</span></a> <span class="s2">"_index"</span><span class="p">,</span> -</span><span id="L-809"><a href="#L-809"><span class="linenos"> 809</span></a> <span class="s2">"_curr"</span><span class="p">,</span> -</span><span id="L-810"><a href="#L-810"><span class="linenos"> 810</span></a> <span class="s2">"_next"</span><span class="p">,</span> -</span><span id="L-811"><a href="#L-811"><span class="linenos"> 811</span></a> <span class="s2">"_prev"</span><span class="p">,</span> -</span><span id="L-812"><a href="#L-812"><span class="linenos"> 812</span></a> <span class="s2">"_prev_comments"</span><span class="p">,</span> -</span><span id="L-813"><a href="#L-813"><span class="linenos"> 813</span></a> <span class="p">)</span> -</span><span id="L-814"><a href="#L-814"><span class="linenos"> 814</span></a> -</span><span id="L-815"><a href="#L-815"><span class="linenos"> 815</span></a> <span class="c1"># Autofilled</span> -</span><span id="L-816"><a href="#L-816"><span class="linenos"> 816</span></a> <span class="n">INDEX_OFFSET</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="L-817"><a href="#L-817"><span class="linenos"> 817</span></a> <span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-818"><a href="#L-818"><span class="linenos"> 818</span></a> <span class="n">ALIAS_POST_TABLESAMPLE</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-819"><a href="#L-819"><span class="linenos"> 819</span></a> <span class="n">STRICT_STRING_CONCAT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-820"><a href="#L-820"><span class="linenos"> 820</span></a> <span class="n">NULL_ORDERING</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"nulls_are_small"</span> -</span><span id="L-821"><a href="#L-821"><span class="linenos"> 821</span></a> <span class="n">SHOW_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-822"><a href="#L-822"><span class="linenos"> 822</span></a> <span class="n">SET_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-823"><a href="#L-823"><span class="linenos"> 823</span></a> <span class="n">FORMAT_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-824"><a href="#L-824"><span class="linenos"> 824</span></a> <span class="n">FORMAT_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-825"><a href="#L-825"><span class="linenos"> 825</span></a> <span class="n">TIME_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-826"><a href="#L-826"><span class="linenos"> 826</span></a> <span class="n">TIME_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-827"><a href="#L-827"><span class="linenos"> 827</span></a> -</span><span id="L-828"><a href="#L-828"><span class="linenos"> 828</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> -</span><span id="L-829"><a href="#L-829"><span class="linenos"> 829</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-830"><a href="#L-830"><span class="linenos"> 830</span></a> <span class="n">error_level</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">ErrorLevel</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-831"><a href="#L-831"><span class="linenos"> 831</span></a> <span class="n">error_message_context</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">100</span><span class="p">,</span> -</span><span id="L-832"><a href="#L-832"><span class="linenos"> 832</span></a> <span class="n">max_errors</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> -</span><span id="L-833"><a href="#L-833"><span class="linenos"> 833</span></a> <span class="p">):</span> -</span><span id="L-834"><a href="#L-834"><span class="linenos"> 834</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">=</span> <span class="n">error_level</span> <span class="ow">or</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span> -</span><span id="L-835"><a href="#L-835"><span class="linenos"> 835</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">error_message_context</span> <span class="o">=</span> <span class="n">error_message_context</span> -</span><span id="L-836"><a href="#L-836"><span class="linenos"> 836</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_errors</span> <span class="o">=</span> <span class="n">max_errors</span> -</span><span id="L-837"><a href="#L-837"><span class="linenos"> 837</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> -</span><span id="L-838"><a href="#L-838"><span class="linenos"> 838</span></a> -</span><span id="L-839"><a href="#L-839"><span class="linenos"> 839</span></a> <span class="k">def</span> <span class="nf">reset</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="L-840"><a href="#L-840"><span class="linenos"> 840</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-841"><a href="#L-841"><span class="linenos"> 841</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-842"><a href="#L-842"><span class="linenos"> 842</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-843"><a href="#L-843"><span class="linenos"> 843</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="L-844"><a href="#L-844"><span class="linenos"> 844</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-845"><a href="#L-845"><span class="linenos"> 845</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-846"><a href="#L-846"><span class="linenos"> 846</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-847"><a href="#L-847"><span class="linenos"> 847</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-848"><a href="#L-848"><span class="linenos"> 848</span></a> -</span><span id="L-849"><a href="#L-849"><span class="linenos"> 849</span></a> <span class="k">def</span> <span class="nf">parse</span><span class="p">(</span> -</span><span id="L-850"><a href="#L-850"><span class="linenos"> 850</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">raw_tokens</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">Token</span><span class="p">],</span> <span class="n">sql</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><span id="L-851"><a href="#L-851"><span class="linenos"> 851</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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-852"><a href="#L-852"><span class="linenos"> 852</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-853"><a href="#L-853"><span class="linenos"> 853</span></a><span class="sd"> Parses a list of tokens and returns a list of syntax trees, one tree</span> -</span><span id="L-854"><a href="#L-854"><span class="linenos"> 854</span></a><span class="sd"> per parsed SQL statement.</span> -</span><span id="L-855"><a href="#L-855"><span class="linenos"> 855</span></a> -</span><span id="L-856"><a href="#L-856"><span class="linenos"> 856</span></a><span class="sd"> Args:</span> -</span><span id="L-857"><a href="#L-857"><span class="linenos"> 857</span></a><span class="sd"> raw_tokens: The list of tokens.</span> -</span><span id="L-858"><a href="#L-858"><span class="linenos"> 858</span></a><span class="sd"> sql: The original SQL string, used to produce helpful debug messages.</span> -</span><span id="L-859"><a href="#L-859"><span class="linenos"> 859</span></a> -</span><span id="L-860"><a href="#L-860"><span class="linenos"> 860</span></a><span class="sd"> Returns:</span> -</span><span id="L-861"><a href="#L-861"><span class="linenos"> 861</span></a><span class="sd"> The list of the produced syntax trees.</span> -</span><span id="L-862"><a href="#L-862"><span class="linenos"> 862</span></a><span class="sd"> """</span> -</span><span id="L-863"><a href="#L-863"><span class="linenos"> 863</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse</span><span class="p">(</span> -</span><span id="L-864"><a href="#L-864"><span class="linenos"> 864</span></a> <span class="n">parse_method</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">,</span> <span class="n">raw_tokens</span><span class="o">=</span><span class="n">raw_tokens</span><span class="p">,</span> <span class="n">sql</span><span class="o">=</span><span class="n">sql</span> -</span><span id="L-865"><a href="#L-865"><span class="linenos"> 865</span></a> <span class="p">)</span> -</span><span id="L-866"><a href="#L-866"><span class="linenos"> 866</span></a> -</span><span id="L-867"><a href="#L-867"><span class="linenos"> 867</span></a> <span class="k">def</span> <span class="nf">parse_into</span><span class="p">(</span> -</span><span id="L-868"><a href="#L-868"><span class="linenos"> 868</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-869"><a href="#L-869"><span class="linenos"> 869</span></a> <span class="n">expression_types</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IntoType</span><span class="p">,</span> -</span><span id="L-870"><a href="#L-870"><span class="linenos"> 870</span></a> <span class="n">raw_tokens</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">Token</span><span class="p">],</span> -</span><span id="L-871"><a href="#L-871"><span class="linenos"> 871</span></a> <span class="n">sql</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-872"><a href="#L-872"><span class="linenos"> 872</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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-873"><a href="#L-873"><span class="linenos"> 873</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-874"><a href="#L-874"><span class="linenos"> 874</span></a><span class="sd"> Parses a list of tokens into a given Expression type. If a collection of Expression</span> -</span><span id="L-875"><a href="#L-875"><span class="linenos"> 875</span></a><span class="sd"> types is given instead, this method will try to parse the token list into each one</span> -</span><span id="L-876"><a href="#L-876"><span class="linenos"> 876</span></a><span class="sd"> of them, stopping at the first for which the parsing succeeds.</span> -</span><span id="L-877"><a href="#L-877"><span class="linenos"> 877</span></a> -</span><span id="L-878"><a href="#L-878"><span class="linenos"> 878</span></a><span class="sd"> Args:</span> -</span><span id="L-879"><a href="#L-879"><span class="linenos"> 879</span></a><span class="sd"> expression_types: The expression type(s) to try and parse the token list into.</span> -</span><span id="L-880"><a href="#L-880"><span class="linenos"> 880</span></a><span class="sd"> raw_tokens: The list of tokens.</span> -</span><span id="L-881"><a href="#L-881"><span class="linenos"> 881</span></a><span class="sd"> sql: The original SQL string, used to produce helpful debug messages.</span> -</span><span id="L-882"><a href="#L-882"><span class="linenos"> 882</span></a> -</span><span id="L-883"><a href="#L-883"><span class="linenos"> 883</span></a><span class="sd"> Returns:</span> -</span><span id="L-884"><a href="#L-884"><span class="linenos"> 884</span></a><span class="sd"> The target Expression.</span> -</span><span id="L-885"><a href="#L-885"><span class="linenos"> 885</span></a><span class="sd"> """</span> -</span><span id="L-886"><a href="#L-886"><span class="linenos"> 886</span></a> <span class="n">errors</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-887"><a href="#L-887"><span class="linenos"> 887</span></a> <span class="k">for</span> <span class="n">expression_type</span> <span class="ow">in</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">expression_types</span><span class="p">):</span> -</span><span id="L-888"><a href="#L-888"><span class="linenos"> 888</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPRESSION_PARSERS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression_type</span><span class="p">)</span> -</span><span id="L-889"><a href="#L-889"><span class="linenos"> 889</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">parser</span><span class="p">:</span> -</span><span id="L-890"><a href="#L-890"><span class="linenos"> 890</span></a> <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"No parser registered for </span><span class="si">{</span><span class="n">expression_type</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-891"><a href="#L-891"><span class="linenos"> 891</span></a> -</span><span id="L-892"><a href="#L-892"><span class="linenos"> 892</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="L-893"><a href="#L-893"><span class="linenos"> 893</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse</span><span class="p">(</span><span class="n">parser</span><span class="p">,</span> <span class="n">raw_tokens</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="L-894"><a href="#L-894"><span class="linenos"> 894</span></a> <span class="k">except</span> <span class="n">ParseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> -</span><span id="L-895"><a href="#L-895"><span class="linenos"> 895</span></a> <span class="n">e</span><span class="o">.</span><span class="n">errors</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s2">"into_expression"</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression_type</span> -</span><span id="L-896"><a href="#L-896"><span class="linenos"> 896</span></a> <span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> -</span><span id="L-897"><a href="#L-897"><span class="linenos"> 897</span></a> -</span><span id="L-898"><a href="#L-898"><span class="linenos"> 898</span></a> <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span> -</span><span id="L-899"><a href="#L-899"><span class="linenos"> 899</span></a> <span class="sa">f</span><span class="s2">"Failed to parse '</span><span class="si">{</span><span class="n">sql</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="n">raw_tokens</span><span class="si">}</span><span class="s2">' into </span><span class="si">{</span><span class="n">expression_types</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-900"><a href="#L-900"><span class="linenos"> 900</span></a> <span class="n">errors</span><span class="o">=</span><span class="n">merge_errors</span><span class="p">(</span><span class="n">errors</span><span class="p">),</span> -</span><span id="L-901"><a href="#L-901"><span class="linenos"> 901</span></a> <span class="p">)</span> <span class="kn">from</span> <span class="nn">errors</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> -</span><span id="L-902"><a href="#L-902"><span class="linenos"> 902</span></a> -</span><span id="L-903"><a href="#L-903"><span class="linenos"> 903</span></a> <span class="k">def</span> <span class="nf">_parse</span><span class="p">(</span> -</span><span id="L-904"><a href="#L-904"><span class="linenos"> 904</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-905"><a href="#L-905"><span class="linenos"> 905</span></a> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Parser</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><span id="L-906"><a href="#L-906"><span class="linenos"> 906</span></a> <span class="n">raw_tokens</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">Token</span><span class="p">],</span> -</span><span id="L-907"><a href="#L-907"><span class="linenos"> 907</span></a> <span class="n">sql</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-908"><a href="#L-908"><span class="linenos"> 908</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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-909"><a href="#L-909"><span class="linenos"> 909</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> -</span><span id="L-910"><a href="#L-910"><span class="linenos"> 910</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span> <span class="ow">or</span> <span class="s2">""</span> -</span><span id="L-911"><a href="#L-911"><span class="linenos"> 911</span></a> -</span><span id="L-912"><a href="#L-912"><span class="linenos"> 912</span></a> <span class="n">total</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">raw_tokens</span><span class="p">)</span> -</span><span id="L-913"><a href="#L-913"><span class="linenos"> 913</span></a> <span class="n">chunks</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">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Token</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[[]]</span> -</span><span id="L-914"><a href="#L-914"><span class="linenos"> 914</span></a> -</span><span id="L-915"><a href="#L-915"><span class="linenos"> 915</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">token</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">raw_tokens</span><span class="p">):</span> -</span><span id="L-916"><a href="#L-916"><span class="linenos"> 916</span></a> <span class="k">if</span> <span class="n">token</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SEMICOLON</span><span class="p">:</span> -</span><span id="L-917"><a href="#L-917"><span class="linenos"> 917</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o"><</span> <span class="n">total</span> <span class="o">-</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-918"><a href="#L-918"><span class="linenos"> 918</span></a> <span class="n">chunks</span><span class="o">.</span><span class="n">append</span><span class="p">([])</span> -</span><span id="L-919"><a href="#L-919"><span class="linenos"> 919</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-920"><a href="#L-920"><span class="linenos"> 920</span></a> <span class="n">chunks</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">token</span><span class="p">)</span> -</span><span id="L-921"><a href="#L-921"><span class="linenos"> 921</span></a> -</span><span id="L-922"><a href="#L-922"><span class="linenos"> 922</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-923"><a href="#L-923"><span class="linenos"> 923</span></a> -</span><span id="L-924"><a href="#L-924"><span class="linenos"> 924</span></a> <span class="k">for</span> <span class="n">tokens</span> <span class="ow">in</span> <span class="n">chunks</span><span class="p">:</span> -</span><span id="L-925"><a href="#L-925"><span class="linenos"> 925</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span> -</span><span id="L-926"><a href="#L-926"><span class="linenos"> 926</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span> <span class="o">=</span> <span class="n">tokens</span> -</span><span id="L-927"><a href="#L-927"><span class="linenos"> 927</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-928"><a href="#L-928"><span class="linenos"> 928</span></a> -</span><span id="L-929"><a href="#L-929"><span class="linenos"> 929</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">parse_method</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span> -</span><span id="L-930"><a href="#L-930"><span class="linenos"> 930</span></a> -</span><span id="L-931"><a href="#L-931"><span class="linenos"> 931</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o"><</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">):</span> -</span><span id="L-932"><a href="#L-932"><span class="linenos"> 932</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Invalid expression / Unexpected token"</span><span class="p">)</span> -</span><span id="L-933"><a href="#L-933"><span class="linenos"> 933</span></a> -</span><span id="L-934"><a href="#L-934"><span class="linenos"> 934</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">check_errors</span><span class="p">()</span> -</span><span id="L-935"><a href="#L-935"><span class="linenos"> 935</span></a> -</span><span id="L-936"><a href="#L-936"><span class="linenos"> 936</span></a> <span class="k">return</span> <span class="n">expressions</span> -</span><span id="L-937"><a href="#L-937"><span class="linenos"> 937</span></a> -</span><span id="L-938"><a href="#L-938"><span class="linenos"> 938</span></a> <span class="k">def</span> <span class="nf">check_errors</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-939"><a href="#L-939"><span class="linenos"> 939</span></a><span class="w"> </span><span class="sd">"""Logs or raises any found errors, depending on the chosen error level setting."""</span> -</span><span id="L-940"><a href="#L-940"><span class="linenos"> 940</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">:</span> -</span><span id="L-941"><a href="#L-941"><span class="linenos"> 941</span></a> <span class="k">for</span> <span class="n">error</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">:</span> -</span><span id="L-942"><a href="#L-942"><span class="linenos"> 942</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">error</span><span class="p">))</span> -</span><span id="L-943"><a href="#L-943"><span class="linenos"> 943</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">RAISE</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">:</span> -</span><span id="L-944"><a href="#L-944"><span class="linenos"> 944</span></a> <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span> -</span><span id="L-945"><a href="#L-945"><span class="linenos"> 945</span></a> <span class="n">concat_messages</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_errors</span><span class="p">),</span> -</span><span id="L-946"><a href="#L-946"><span class="linenos"> 946</span></a> <span class="n">errors</span><span class="o">=</span><span class="n">merge_errors</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">),</span> -</span><span id="L-947"><a href="#L-947"><span class="linenos"> 947</span></a> <span class="p">)</span> -</span><span id="L-948"><a href="#L-948"><span class="linenos"> 948</span></a> -</span><span id="L-949"><a href="#L-949"><span class="linenos"> 949</span></a> <span class="k">def</span> <span class="nf">raise_error</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">token</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">Token</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-950"><a href="#L-950"><span class="linenos"> 950</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-951"><a href="#L-951"><span class="linenos"> 951</span></a><span class="sd"> Appends an error in the list of recorded errors or raises it, depending on the chosen</span> -</span><span id="L-952"><a href="#L-952"><span class="linenos"> 952</span></a><span class="sd"> error level setting.</span> -</span><span id="L-953"><a href="#L-953"><span class="linenos"> 953</span></a><span class="sd"> """</span> -</span><span id="L-954"><a href="#L-954"><span class="linenos"> 954</span></a> <span class="n">token</span> <span class="o">=</span> <span class="n">token</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="ow">or</span> <span class="n">Token</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">)</span> -</span><span id="L-955"><a href="#L-955"><span class="linenos"> 955</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">token</span><span class="o">.</span><span class="n">start</span> -</span><span id="L-956"><a href="#L-956"><span class="linenos"> 956</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">token</span><span class="o">.</span><span class="n">end</span> <span class="o">+</span> <span class="mi">1</span> -</span><span id="L-957"><a href="#L-957"><span class="linenos"> 957</span></a> <span class="n">start_context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="nb">max</span><span class="p">(</span><span class="n">start</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_message_context</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="p">:</span> <span class="n">start</span><span class="p">]</span> -</span><span id="L-958"><a href="#L-958"><span class="linenos"> 958</span></a> <span class="n">highlight</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">start</span><span class="p">:</span><span class="n">end</span><span class="p">]</span> -</span><span id="L-959"><a href="#L-959"><span class="linenos"> 959</span></a> <span class="n">end_context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">end</span> <span class="p">:</span> <span class="n">end</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_message_context</span><span class="p">]</span> -</span><span id="L-960"><a href="#L-960"><span class="linenos"> 960</span></a> -</span><span id="L-961"><a href="#L-961"><span class="linenos"> 961</span></a> <span class="n">error</span> <span class="o">=</span> <span class="n">ParseError</span><span class="o">.</span><span class="n">new</span><span class="p">(</span> -</span><span id="L-962"><a href="#L-962"><span class="linenos"> 962</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">message</span><span class="si">}</span><span class="s2">. Line </span><span class="si">{</span><span class="n">token</span><span class="o">.</span><span class="n">line</span><span class="si">}</span><span class="s2">, Col: </span><span class="si">{</span><span class="n">token</span><span class="o">.</span><span class="n">col</span><span class="si">}</span><span class="s2">.</span><span class="se">\n</span><span class="s2">"</span> -</span><span id="L-963"><a href="#L-963"><span class="linenos"> 963</span></a> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">start_context</span><span class="si">}</span><span class="se">\033</span><span class="s2">[4m</span><span class="si">{</span><span class="n">highlight</span><span class="si">}</span><span class="se">\033</span><span class="s2">[0m</span><span class="si">{</span><span class="n">end_context</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="L-964"><a href="#L-964"><span class="linenos"> 964</span></a> <span class="n">description</span><span class="o">=</span><span class="n">message</span><span class="p">,</span> -</span><span id="L-965"><a href="#L-965"><span class="linenos"> 965</span></a> <span class="n">line</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">line</span><span class="p">,</span> -</span><span id="L-966"><a href="#L-966"><span class="linenos"> 966</span></a> <span class="n">col</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">col</span><span class="p">,</span> -</span><span id="L-967"><a href="#L-967"><span class="linenos"> 967</span></a> <span class="n">start_context</span><span class="o">=</span><span class="n">start_context</span><span class="p">,</span> -</span><span id="L-968"><a href="#L-968"><span class="linenos"> 968</span></a> <span class="n">highlight</span><span class="o">=</span><span class="n">highlight</span><span class="p">,</span> -</span><span id="L-969"><a href="#L-969"><span class="linenos"> 969</span></a> <span class="n">end_context</span><span class="o">=</span><span class="n">end_context</span><span class="p">,</span> -</span><span id="L-970"><a href="#L-970"><span class="linenos"> 970</span></a> <span class="p">)</span> -</span><span id="L-971"><a href="#L-971"><span class="linenos"> 971</span></a> -</span><span id="L-972"><a href="#L-972"><span class="linenos"> 972</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span><span class="p">:</span> -</span><span id="L-973"><a href="#L-973"><span class="linenos"> 973</span></a> <span class="k">raise</span> <span class="n">error</span> -</span><span id="L-974"><a href="#L-974"><span class="linenos"> 974</span></a> -</span><span id="L-975"><a href="#L-975"><span class="linenos"> 975</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">error</span><span class="p">)</span> -</span><span id="L-976"><a href="#L-976"><span class="linenos"> 976</span></a> -</span><span id="L-977"><a href="#L-977"><span class="linenos"> 977</span></a> <span class="k">def</span> <span class="nf">expression</span><span class="p">(</span> -</span><span id="L-978"><a href="#L-978"><span class="linenos"> 978</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> <span class="n">comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> -</span><span id="L-979"><a href="#L-979"><span class="linenos"> 979</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="L-980"><a href="#L-980"><span class="linenos"> 980</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-981"><a href="#L-981"><span class="linenos"> 981</span></a><span class="sd"> Creates a new, validated Expression.</span> -</span><span id="L-982"><a href="#L-982"><span class="linenos"> 982</span></a> -</span><span id="L-983"><a href="#L-983"><span class="linenos"> 983</span></a><span class="sd"> Args:</span> -</span><span id="L-984"><a href="#L-984"><span class="linenos"> 984</span></a><span class="sd"> exp_class: The expression class to instantiate.</span> -</span><span id="L-985"><a href="#L-985"><span class="linenos"> 985</span></a><span class="sd"> comments: An optional list of comments to attach to the expression.</span> -</span><span id="L-986"><a href="#L-986"><span class="linenos"> 986</span></a><span class="sd"> kwargs: The arguments to set for the expression along with their respective values.</span> -</span><span id="L-987"><a href="#L-987"><span class="linenos"> 987</span></a> -</span><span id="L-988"><a href="#L-988"><span class="linenos"> 988</span></a><span class="sd"> Returns:</span> -</span><span id="L-989"><a href="#L-989"><span class="linenos"> 989</span></a><span class="sd"> The target expression.</span> -</span><span id="L-990"><a href="#L-990"><span class="linenos"> 990</span></a><span class="sd"> """</span> -</span><span id="L-991"><a href="#L-991"><span class="linenos"> 991</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">exp_class</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="L-992"><a href="#L-992"><span class="linenos"> 992</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">add_comments</span><span class="p">(</span><span class="n">comments</span><span class="p">)</span> <span class="k">if</span> <span class="n">comments</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add_comments</span><span class="p">(</span><span class="n">instance</span><span class="p">)</span> -</span><span id="L-993"><a href="#L-993"><span class="linenos"> 993</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">instance</span><span class="p">)</span> -</span><span id="L-994"><a href="#L-994"><span class="linenos"> 994</span></a> -</span><span id="L-995"><a href="#L-995"><span class="linenos"> 995</span></a> <span class="k">def</span> <span class="nf">_add_comments</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-996"><a href="#L-996"><span class="linenos"> 996</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span><span class="p">:</span> -</span><span id="L-997"><a href="#L-997"><span class="linenos"> 997</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">add_comments</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span><span class="p">)</span> -</span><span id="L-998"><a href="#L-998"><span class="linenos"> 998</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-999"><a href="#L-999"><span class="linenos"> 999</span></a> -</span><span id="L-1000"><a href="#L-1000"><span class="linenos">1000</span></a> <span class="k">def</span> <span class="nf">validate_expression</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="L-1001"><a href="#L-1001"><span class="linenos">1001</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-1002"><a href="#L-1002"><span class="linenos">1002</span></a><span class="sd"> Validates an Expression, making sure that all its mandatory arguments are set.</span> -</span><span id="L-1003"><a href="#L-1003"><span class="linenos">1003</span></a> -</span><span id="L-1004"><a href="#L-1004"><span class="linenos">1004</span></a><span class="sd"> Args:</span> -</span><span id="L-1005"><a href="#L-1005"><span class="linenos">1005</span></a><span class="sd"> expression: The expression to validate.</span> -</span><span id="L-1006"><a href="#L-1006"><span class="linenos">1006</span></a><span class="sd"> args: An optional list of items that was used to instantiate the expression, if it's a Func.</span> -</span><span id="L-1007"><a href="#L-1007"><span class="linenos">1007</span></a> -</span><span id="L-1008"><a href="#L-1008"><span class="linenos">1008</span></a><span class="sd"> Returns:</span> -</span><span id="L-1009"><a href="#L-1009"><span class="linenos">1009</span></a><span class="sd"> The validated expression.</span> -</span><span id="L-1010"><a href="#L-1010"><span class="linenos">1010</span></a><span class="sd"> """</span> -</span><span id="L-1011"><a href="#L-1011"><span class="linenos">1011</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">!=</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IGNORE</span><span class="p">:</span> -</span><span id="L-1012"><a href="#L-1012"><span class="linenos">1012</span></a> <span class="k">for</span> <span class="n">error_message</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">error_messages</span><span class="p">(</span><span class="n">args</span><span class="p">):</span> -</span><span id="L-1013"><a href="#L-1013"><span class="linenos">1013</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="n">error_message</span><span class="p">)</span> -</span><span id="L-1014"><a href="#L-1014"><span class="linenos">1014</span></a> -</span><span id="L-1015"><a href="#L-1015"><span class="linenos">1015</span></a> <span class="k">return</span> <span class="n">expression</span> -</span><span id="L-1016"><a href="#L-1016"><span class="linenos">1016</span></a> -</span><span id="L-1017"><a href="#L-1017"><span class="linenos">1017</span></a> <span class="k">def</span> <span class="nf">_find_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">start</span><span class="p">:</span> <span class="n">Token</span><span class="p">,</span> <span class="n">end</span><span class="p">:</span> <span class="n">Token</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1018"><a href="#L-1018"><span class="linenos">1018</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">start</span><span class="o">.</span><span class="n">start</span> <span class="p">:</span> <span class="n">end</span><span class="o">.</span><span class="n">end</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span> -</span><span id="L-1019"><a href="#L-1019"><span class="linenos">1019</span></a> -</span><span id="L-1020"><a href="#L-1020"><span class="linenos">1020</span></a> <span class="k">def</span> <span class="nf">_advance</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">times</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-1021"><a href="#L-1021"><span class="linenos">1021</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">+=</span> <span class="n">times</span> -</span><span id="L-1022"><a href="#L-1022"><span class="linenos">1022</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span><span class="p">)</span> -</span><span id="L-1023"><a href="#L-1023"><span class="linenos">1023</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="L-1024"><a href="#L-1024"><span class="linenos">1024</span></a> -</span><span id="L-1025"><a href="#L-1025"><span class="linenos">1025</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> -</span><span id="L-1026"><a href="#L-1026"><span class="linenos">1026</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> -</span><span id="L-1027"><a href="#L-1027"><span class="linenos">1027</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</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">comments</span> -</span><span id="L-1028"><a href="#L-1028"><span class="linenos">1028</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1029"><a href="#L-1029"><span class="linenos">1029</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1030"><a href="#L-1030"><span class="linenos">1030</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1031"><a href="#L-1031"><span class="linenos">1031</span></a> -</span><span id="L-1032"><a href="#L-1032"><span class="linenos">1032</span></a> <span class="k">def</span> <span class="nf">_retreat</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">index</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-1033"><a href="#L-1033"><span class="linenos">1033</span></a> <span class="k">if</span> <span class="n">index</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span><span class="p">:</span> -</span><span id="L-1034"><a href="#L-1034"><span class="linenos">1034</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">index</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span><span class="p">)</span> -</span><span id="L-1035"><a href="#L-1035"><span class="linenos">1035</span></a> -</span><span id="L-1036"><a href="#L-1036"><span class="linenos">1036</span></a> <span class="k">def</span> <span class="nf">_parse_command</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">Command</span><span class="p">:</span> -</span><span id="L-1037"><a href="#L-1037"><span class="linenos">1037</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">Command</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 class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">())</span> -</span><span id="L-1038"><a href="#L-1038"><span class="linenos">1038</span></a> -</span><span id="L-1039"><a href="#L-1039"><span class="linenos">1039</span></a> <span class="k">def</span> <span class="nf">_parse_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">allow_exists</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="L-1040"><a href="#L-1040"><span class="linenos">1040</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> -</span><span id="L-1041"><a href="#L-1041"><span class="linenos">1041</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">()</span> <span class="k">if</span> <span class="n">allow_exists</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="L-1042"><a href="#L-1042"><span class="linenos">1042</span></a> -</span><span id="L-1043"><a href="#L-1043"><span class="linenos">1043</span></a> <span class="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">ON</span><span class="p">)</span> -</span><span id="L-1044"><a href="#L-1044"><span class="linenos">1044</span></a> -</span><span id="L-1045"><a href="#L-1045"><span class="linenos">1045</span></a> <span class="n">kind</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> -</span><span id="L-1046"><a href="#L-1046"><span class="linenos">1046</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="L-1047"><a href="#L-1047"><span class="linenos">1047</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> -</span><span id="L-1048"><a href="#L-1048"><span class="linenos">1048</span></a> -</span><span id="L-1049"><a href="#L-1049"><span class="linenos">1049</span></a> <span class="k">if</span> <span class="n">kind</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FUNCTION</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PROCEDURE</span><span class="p">):</span> -</span><span id="L-1050"><a href="#L-1050"><span class="linenos">1050</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_user_defined_function</span><span class="p">(</span><span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="o">.</span><span class="n">token_type</span><span class="p">)</span> -</span><span id="L-1051"><a href="#L-1051"><span class="linenos">1051</span></a> <span class="k">elif</span> <span class="n">kind</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">:</span> -</span><span id="L-1052"><a href="#L-1052"><span class="linenos">1052</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">alias_tokens</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">COMMENT_TABLE_ALIAS_TOKENS</span><span class="p">)</span> -</span><span id="L-1053"><a href="#L-1053"><span class="linenos">1053</span></a> <span class="k">elif</span> <span class="n">kind</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLUMN</span><span class="p">:</span> -</span><span id="L-1054"><a href="#L-1054"><span class="linenos">1054</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> -</span><span id="L-1055"><a href="#L-1055"><span class="linenos">1055</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1056"><a href="#L-1056"><span class="linenos">1056</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="L-1057"><a href="#L-1057"><span class="linenos">1057</span></a> -</span><span id="L-1058"><a href="#L-1058"><span class="linenos">1058</span></a> <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">IS</span><span class="p">)</span> -</span><span id="L-1059"><a href="#L-1059"><span class="linenos">1059</span></a> -</span><span id="L-1060"><a href="#L-1060"><span class="linenos">1060</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><span id="L-1061"><a href="#L-1061"><span class="linenos">1061</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Comment</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">(),</span> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span> -</span><span id="L-1062"><a href="#L-1062"><span class="linenos">1062</span></a> <span class="p">)</span> -</span><span id="L-1063"><a href="#L-1063"><span class="linenos">1063</span></a> -</span><span id="L-1064"><a href="#L-1064"><span class="linenos">1064</span></a> <span class="k">def</span> <span class="nf">_parse_to_table</span><span class="p">(</span> -</span><span id="L-1065"><a href="#L-1065"><span class="linenos">1065</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-1066"><a href="#L-1066"><span class="linenos">1066</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">ToTableProperty</span><span class="p">:</span> -</span><span id="L-1067"><a href="#L-1067"><span class="linenos">1067</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1068"><a href="#L-1068"><span class="linenos">1068</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">ToTableProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">)</span> -</span><span id="L-1069"><a href="#L-1069"><span class="linenos">1069</span></a> -</span><span id="L-1070"><a href="#L-1070"><span class="linenos">1070</span></a> <span class="c1"># https://clickhouse.com/docs/en/engines/table-engines/mergetree-family/mergetree#mergetree-table-ttl</span> -</span><span id="L-1071"><a href="#L-1071"><span class="linenos">1071</span></a> <span class="k">def</span> <span class="nf">_parse_ttl</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">Expression</span><span class="p">:</span> -</span><span id="L-1072"><a href="#L-1072"><span class="linenos">1072</span></a> <span class="k">def</span> <span class="nf">_parse_ttl_action</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-1073"><a href="#L-1073"><span class="linenos">1073</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="L-1074"><a href="#L-1074"><span class="linenos">1074</span></a> -</span><span id="L-1075"><a href="#L-1075"><span class="linenos">1075</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DELETE"</span><span class="p">):</span> -</span><span id="L-1076"><a href="#L-1076"><span class="linenos">1076</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">MergeTreeTTLAction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">delete</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1077"><a href="#L-1077"><span class="linenos">1077</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"RECOMPRESS"</span><span class="p">):</span> -</span><span id="L-1078"><a href="#L-1078"><span class="linenos">1078</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><span id="L-1079"><a href="#L-1079"><span class="linenos">1079</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTLAction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">recompress</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="L-1080"><a href="#L-1080"><span class="linenos">1080</span></a> <span class="p">)</span> -</span><span id="L-1081"><a href="#L-1081"><span class="linenos">1081</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"DISK"</span><span class="p">):</span> -</span><span id="L-1082"><a href="#L-1082"><span class="linenos">1082</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-1083"><a href="#L-1083"><span class="linenos">1083</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTLAction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to_disk</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="L-1084"><a href="#L-1084"><span class="linenos">1084</span></a> <span class="p">)</span> -</span><span id="L-1085"><a href="#L-1085"><span class="linenos">1085</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"VOLUME"</span><span class="p">):</span> -</span><span id="L-1086"><a href="#L-1086"><span class="linenos">1086</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><span id="L-1087"><a href="#L-1087"><span class="linenos">1087</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTLAction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to_volume</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="L-1088"><a href="#L-1088"><span class="linenos">1088</span></a> <span class="p">)</span> -</span><span id="L-1089"><a href="#L-1089"><span class="linenos">1089</span></a> -</span><span id="L-1090"><a href="#L-1090"><span class="linenos">1090</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-1091"><a href="#L-1091"><span class="linenos">1091</span></a> -</span><span id="L-1092"><a href="#L-1092"><span class="linenos">1092</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">_parse_ttl_action</span><span class="p">)</span> -</span><span id="L-1093"><a href="#L-1093"><span class="linenos">1093</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">()</span> -</span><span id="L-1094"><a href="#L-1094"><span class="linenos">1094</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_group</span><span class="p">()</span> -</span><span id="L-1095"><a href="#L-1095"><span class="linenos">1095</span></a> -</span><span id="L-1096"><a href="#L-1096"><span class="linenos">1096</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1097"><a href="#L-1097"><span class="linenos">1097</span></a> <span class="k">if</span> <span class="n">group</span> <span class="ow">and</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">SET</span><span class="p">):</span> -</span><span id="L-1098"><a href="#L-1098"><span class="linenos">1098</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_item</span><span class="p">)</span> -</span><span id="L-1099"><a href="#L-1099"><span class="linenos">1099</span></a> -</span><span id="L-1100"><a href="#L-1100"><span class="linenos">1100</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-1101"><a href="#L-1101"><span class="linenos">1101</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">,</span> -</span><span id="L-1102"><a href="#L-1102"><span class="linenos">1102</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-1103"><a href="#L-1103"><span class="linenos">1103</span></a> <span class="n">where</span><span class="o">=</span><span class="n">where</span><span class="p">,</span> -</span><span id="L-1104"><a href="#L-1104"><span class="linenos">1104</span></a> <span class="n">group</span><span class="o">=</span><span class="n">group</span><span class="p">,</span> -</span><span id="L-1105"><a href="#L-1105"><span class="linenos">1105</span></a> <span class="n">aggregates</span><span class="o">=</span><span class="n">aggregates</span><span class="p">,</span> -</span><span id="L-1106"><a href="#L-1106"><span class="linenos">1106</span></a> <span class="p">)</span> -</span><span id="L-1107"><a href="#L-1107"><span class="linenos">1107</span></a> -</span><span id="L-1108"><a href="#L-1108"><span class="linenos">1108</span></a> <span class="k">def</span> <span class="nf">_parse_statement</span><span class="p">(</span><span class="bp">self</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-1109"><a href="#L-1109"><span class="linenos">1109</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-1110"><a href="#L-1110"><span class="linenos">1110</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-1111"><a href="#L-1111"><span class="linenos">1111</span></a> -</span><span id="L-1112"><a href="#L-1112"><span class="linenos">1112</span></a> <span class="k">if</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">STATEMENT_PARSERS</span><span class="p">):</span> -</span><span id="L-1113"><a href="#L-1113"><span class="linenos">1113</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">STATEMENT_PARSERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> -</span><span id="L-1114"><a href="#L-1114"><span class="linenos">1114</span></a> -</span><span id="L-1115"><a href="#L-1115"><span class="linenos">1115</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">(</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">COMMANDS</span><span class="p">):</span> -</span><span id="L-1116"><a href="#L-1116"><span class="linenos">1116</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_command</span><span class="p">()</span> -</span><span id="L-1117"><a href="#L-1117"><span class="linenos">1117</span></a> -</span><span id="L-1118"><a href="#L-1118"><span class="linenos">1118</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">()</span> -</span><span id="L-1119"><a href="#L-1119"><span class="linenos">1119</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">()</span> -</span><span id="L-1120"><a href="#L-1120"><span class="linenos">1120</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-1121"><a href="#L-1121"><span class="linenos">1121</span></a> -</span><span id="L-1122"><a href="#L-1122"><span class="linenos">1122</span></a> <span class="k">def</span> <span class="nf">_parse_drop</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">Drop</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> -</span><span id="L-1123"><a href="#L-1123"><span class="linenos">1123</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> -</span><span id="L-1124"><a href="#L-1124"><span class="linenos">1124</span></a> <span class="n">temporary</span> <span class="o">=</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">TEMPORARY</span><span class="p">)</span> -</span><span id="L-1125"><a href="#L-1125"><span class="linenos">1125</span></a> <span class="n">materialized</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MATERIALIZED"</span><span class="p">)</span> -</span><span id="L-1126"><a href="#L-1126"><span class="linenos">1126</span></a> -</span><span id="L-1127"><a href="#L-1127"><span class="linenos">1127</span></a> <span class="n">kind</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</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><span id="L-1128"><a href="#L-1128"><span class="linenos">1128</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="L-1129"><a href="#L-1129"><span class="linenos">1129</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> -</span><span id="L-1130"><a href="#L-1130"><span class="linenos">1130</span></a> -</span><span id="L-1131"><a href="#L-1131"><span class="linenos">1131</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-1132"><a href="#L-1132"><span class="linenos">1132</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">,</span> -</span><span id="L-1133"><a href="#L-1133"><span class="linenos">1133</span></a> <span class="n">exists</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">(),</span> -</span><span id="L-1134"><a href="#L-1134"><span class="linenos">1134</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="L-1135"><a href="#L-1135"><span class="linenos">1135</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> -</span><span id="L-1136"><a href="#L-1136"><span class="linenos">1136</span></a> <span class="n">temporary</span><span class="o">=</span><span class="n">temporary</span><span class="p">,</span> -</span><span id="L-1137"><a href="#L-1137"><span class="linenos">1137</span></a> <span class="n">materialized</span><span class="o">=</span><span class="n">materialized</span><span class="p">,</span> -</span><span id="L-1138"><a href="#L-1138"><span class="linenos">1138</span></a> <span class="n">cascade</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CASCADE"</span><span class="p">),</span> -</span><span id="L-1139"><a href="#L-1139"><span class="linenos">1139</span></a> <span class="n">constraints</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CONSTRAINTS"</span><span class="p">),</span> -</span><span id="L-1140"><a href="#L-1140"><span class="linenos">1140</span></a> <span class="n">purge</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PURGE"</span><span class="p">),</span> -</span><span id="L-1141"><a href="#L-1141"><span class="linenos">1141</span></a> <span class="p">)</span> -</span><span id="L-1142"><a href="#L-1142"><span class="linenos">1142</span></a> -</span><span id="L-1143"><a href="#L-1143"><span class="linenos">1143</span></a> <span class="k">def</span> <span class="nf">_parse_exists</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">not_</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="nb">bool</span><span class="p">]:</span> -</span><span id="L-1144"><a href="#L-1144"><span class="linenos">1144</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="L-1145"><a href="#L-1145"><span class="linenos">1145</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IF</span><span class="p">)</span> -</span><span id="L-1146"><a href="#L-1146"><span class="linenos">1146</span></a> <span class="ow">and</span> <span class="p">(</span><span class="ow">not</span> <span class="n">not_</span> <span class="ow">or</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">NOT</span><span class="p">))</span> -</span><span id="L-1147"><a href="#L-1147"><span class="linenos">1147</span></a> <span class="ow">and</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">EXISTS</span><span class="p">)</span> -</span><span id="L-1148"><a href="#L-1148"><span class="linenos">1148</span></a> <span class="p">)</span> -</span><span id="L-1149"><a href="#L-1149"><span class="linenos">1149</span></a> -</span><span id="L-1150"><a href="#L-1150"><span class="linenos">1150</span></a> <span class="k">def</span> <span class="nf">_parse_create</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">Create</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> -</span><span id="L-1151"><a href="#L-1151"><span class="linenos">1151</span></a> <span class="c1"># Note: this can't be None because we've matched a statement parser</span> -</span><span id="L-1152"><a href="#L-1152"><span class="linenos">1152</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> -</span><span id="L-1153"><a href="#L-1153"><span class="linenos">1153</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"REPLACE"</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span> -</span><span id="L-1154"><a href="#L-1154"><span class="linenos">1154</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">OR</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span> -</span><span id="L-1155"><a href="#L-1155"><span class="linenos">1155</span></a> <span class="p">)</span> -</span><span id="L-1156"><a href="#L-1156"><span class="linenos">1156</span></a> <span class="n">unique</span> <span class="o">=</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">UNIQUE</span><span class="p">)</span> -</span><span id="L-1157"><a href="#L-1157"><span class="linenos">1157</span></a> -</span><span id="L-1158"><a href="#L-1158"><span class="linenos">1158</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FUNCTION</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-1159"><a href="#L-1159"><span class="linenos">1159</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-1160"><a href="#L-1160"><span class="linenos">1160</span></a> -</span><span id="L-1161"><a href="#L-1161"><span class="linenos">1161</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1162"><a href="#L-1162"><span class="linenos">1162</span></a> <span class="n">create_token</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> -</span><span id="L-1163"><a href="#L-1163"><span class="linenos">1163</span></a> -</span><span id="L-1164"><a href="#L-1164"><span class="linenos">1164</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">create_token</span><span class="p">:</span> -</span><span id="L-1165"><a href="#L-1165"><span class="linenos">1165</span></a> <span class="c1"># exp.Properties.Location.POST_CREATE</span> -</span><span id="L-1166"><a href="#L-1166"><span class="linenos">1166</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">()</span> -</span><span id="L-1167"><a href="#L-1167"><span class="linenos">1167</span></a> <span class="n">create_token</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> -</span><span id="L-1168"><a href="#L-1168"><span class="linenos">1168</span></a> -</span><span id="L-1169"><a href="#L-1169"><span class="linenos">1169</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">properties</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">create_token</span><span class="p">:</span> -</span><span id="L-1170"><a href="#L-1170"><span class="linenos">1170</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> -</span><span id="L-1171"><a href="#L-1171"><span class="linenos">1171</span></a> -</span><span id="L-1172"><a href="#L-1172"><span class="linenos">1172</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">(</span><span class="n">not_</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1173"><a href="#L-1173"><span class="linenos">1173</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1174"><a href="#L-1174"><span class="linenos">1174</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1175"><a href="#L-1175"><span class="linenos">1175</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1176"><a href="#L-1176"><span class="linenos">1176</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1177"><a href="#L-1177"><span class="linenos">1177</span></a> <span class="n">begin</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1178"><a href="#L-1178"><span class="linenos">1178</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1179"><a href="#L-1179"><span class="linenos">1179</span></a> -</span><span id="L-1180"><a href="#L-1180"><span class="linenos">1180</span></a> <span class="k">def</span> <span class="nf">extend_props</span><span class="p">(</span><span class="n">temp_props</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">Properties</span><span class="p">])</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-1181"><a href="#L-1181"><span class="linenos">1181</span></a> <span class="k">nonlocal</span> <span class="n">properties</span> -</span><span id="L-1182"><a href="#L-1182"><span class="linenos">1182</span></a> <span class="k">if</span> <span class="n">properties</span> <span class="ow">and</span> <span class="n">temp_props</span><span class="p">:</span> -</span><span id="L-1183"><a href="#L-1183"><span class="linenos">1183</span></a> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">temp_props</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-1184"><a href="#L-1184"><span class="linenos">1184</span></a> <span class="k">elif</span> <span class="n">temp_props</span><span class="p">:</span> -</span><span id="L-1185"><a href="#L-1185"><span class="linenos">1185</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="n">temp_props</span> -</span><span id="L-1186"><a href="#L-1186"><span class="linenos">1186</span></a> -</span><span id="L-1187"><a href="#L-1187"><span class="linenos">1187</span></a> <span class="k">if</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FUNCTION</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PROCEDURE</span><span class="p">):</span> -</span><span id="L-1188"><a href="#L-1188"><span class="linenos">1188</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_user_defined_function</span><span class="p">(</span><span class="n">kind</span><span class="o">=</span><span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span><span class="p">)</span> -</span><span id="L-1189"><a href="#L-1189"><span class="linenos">1189</span></a> -</span><span id="L-1190"><a href="#L-1190"><span class="linenos">1190</span></a> <span class="c1"># exp.Properties.Location.POST_SCHEMA ("schema" here is the UDF's type signature)</span> -</span><span id="L-1191"><a href="#L-1191"><span class="linenos">1191</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">())</span> -</span><span id="L-1192"><a href="#L-1192"><span class="linenos">1192</span></a> -</span><span id="L-1193"><a href="#L-1193"><span class="linenos">1193</span></a> <span class="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">ALIAS</span><span class="p">)</span> -</span><span id="L-1194"><a href="#L-1194"><span class="linenos">1194</span></a> <span class="n">begin</span> <span class="o">=</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">BEGIN</span><span class="p">)</span> -</span><span id="L-1195"><a href="#L-1195"><span class="linenos">1195</span></a> <span class="n">return_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"RETURN"</span><span class="p">)</span> -</span><span id="L-1196"><a href="#L-1196"><span class="linenos">1196</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">()</span> -</span><span id="L-1197"><a href="#L-1197"><span class="linenos">1197</span></a> -</span><span id="L-1198"><a href="#L-1198"><span class="linenos">1198</span></a> <span class="k">if</span> <span class="n">return_</span><span class="p">:</span> -</span><span id="L-1199"><a href="#L-1199"><span class="linenos">1199</span></a> <span class="n">expression</span> <span class="o">=</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">Return</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-1200"><a href="#L-1200"><span class="linenos">1200</span></a> <span class="k">elif</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INDEX</span><span class="p">:</span> -</span><span id="L-1201"><a href="#L-1201"><span class="linenos">1201</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_index</span><span class="p">(</span><span class="n">index</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">())</span> -</span><span id="L-1202"><a href="#L-1202"><span class="linenos">1202</span></a> <span class="k">elif</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">DB_CREATABLES</span><span class="p">:</span> -</span><span id="L-1203"><a href="#L-1203"><span class="linenos">1203</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1204"><a href="#L-1204"><span class="linenos">1204</span></a> -</span><span id="L-1205"><a href="#L-1205"><span class="linenos">1205</span></a> <span class="c1"># exp.Properties.Location.POST_NAME</span> -</span><span id="L-1206"><a href="#L-1206"><span class="linenos">1206</span></a> <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">COMMA</span><span class="p">)</span> -</span><span id="L-1207"><a href="#L-1207"><span class="linenos">1207</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">(</span><span class="n">before</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> -</span><span id="L-1208"><a href="#L-1208"><span class="linenos">1208</span></a> -</span><span id="L-1209"><a href="#L-1209"><span class="linenos">1209</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_parts</span><span class="p">)</span> -</span><span id="L-1210"><a href="#L-1210"><span class="linenos">1210</span></a> -</span><span id="L-1211"><a href="#L-1211"><span class="linenos">1211</span></a> <span class="c1"># exp.Properties.Location.POST_SCHEMA and POST_WITH</span> -</span><span id="L-1212"><a href="#L-1212"><span class="linenos">1212</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">())</span> -</span><span id="L-1213"><a href="#L-1213"><span class="linenos">1213</span></a> -</span><span id="L-1214"><a href="#L-1214"><span class="linenos">1214</span></a> <span class="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">ALIAS</span><span class="p">)</span> -</span><span id="L-1215"><a href="#L-1215"><span class="linenos">1215</span></a> <span class="k">if</span> <span class="ow">not</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">DDL_SELECT_TOKENS</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-1216"><a href="#L-1216"><span class="linenos">1216</span></a> <span class="c1"># exp.Properties.Location.POST_ALIAS</span> -</span><span id="L-1217"><a href="#L-1217"><span class="linenos">1217</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">())</span> -</span><span id="L-1218"><a href="#L-1218"><span class="linenos">1218</span></a> -</span><span id="L-1219"><a href="#L-1219"><span class="linenos">1219</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_ddl_select</span><span class="p">()</span> -</span><span id="L-1220"><a href="#L-1220"><span class="linenos">1220</span></a> -</span><span id="L-1221"><a href="#L-1221"><span class="linenos">1221</span></a> <span class="k">if</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">:</span> -</span><span id="L-1222"><a href="#L-1222"><span class="linenos">1222</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-1223"><a href="#L-1223"><span class="linenos">1223</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-1224"><a href="#L-1224"><span class="linenos">1224</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_index</span><span class="p">()</span> -</span><span id="L-1225"><a href="#L-1225"><span class="linenos">1225</span></a> -</span><span id="L-1226"><a href="#L-1226"><span class="linenos">1226</span></a> <span class="c1"># exp.Properties.Location.POST_EXPRESSION and POST_INDEX</span> -</span><span id="L-1227"><a href="#L-1227"><span class="linenos">1227</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">())</span> -</span><span id="L-1228"><a href="#L-1228"><span class="linenos">1228</span></a> -</span><span id="L-1229"><a href="#L-1229"><span class="linenos">1229</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">index</span><span class="p">:</span> -</span><span id="L-1230"><a href="#L-1230"><span class="linenos">1230</span></a> <span class="k">break</span> -</span><span id="L-1231"><a href="#L-1231"><span class="linenos">1231</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1232"><a href="#L-1232"><span class="linenos">1232</span></a> <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">COMMA</span><span class="p">)</span> -</span><span id="L-1233"><a href="#L-1233"><span class="linenos">1233</span></a> <span class="n">indexes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-1234"><a href="#L-1234"><span class="linenos">1234</span></a> <span class="k">elif</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VIEW</span><span class="p">:</span> -</span><span id="L-1235"><a href="#L-1235"><span class="linenos">1235</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"SCHEMA"</span><span class="p">,</span> <span class="s2">"BINDING"</span><span class="p">):</span> -</span><span id="L-1236"><a href="#L-1236"><span class="linenos">1236</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-1237"><a href="#L-1237"><span class="linenos">1237</span></a> -</span><span id="L-1238"><a href="#L-1238"><span class="linenos">1238</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CLONE"</span><span class="p">):</span> -</span><span id="L-1239"><a href="#L-1239"><span class="linenos">1239</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1240"><a href="#L-1240"><span class="linenos">1240</span></a> <span class="n">when</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">({</span><span class="s2">"AT"</span><span class="p">,</span> <span class="s2">"BEFORE"</span><span class="p">})</span> <span class="ow">and</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="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-1241"><a href="#L-1241"><span class="linenos">1241</span></a> <span class="n">clone_kind</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-1242"><a href="#L-1242"><span class="linenos">1242</span></a> <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_PAREN</span><span class="p">)</span> -</span><span id="L-1243"><a href="#L-1243"><span class="linenos">1243</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CLONE_KINDS</span><span class="p">)</span> -</span><span id="L-1244"><a href="#L-1244"><span class="linenos">1244</span></a> <span class="ow">and</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="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-1245"><a href="#L-1245"><span class="linenos">1245</span></a> <span class="p">)</span> -</span><span id="L-1246"><a href="#L-1246"><span class="linenos">1246</span></a> <span class="n">clone_expression</span> <span class="o">=</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">FARROW</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="L-1247"><a href="#L-1247"><span class="linenos">1247</span></a> <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">R_PAREN</span><span class="p">)</span> -</span><span id="L-1248"><a href="#L-1248"><span class="linenos">1248</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-1249"><a href="#L-1249"><span class="linenos">1249</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Clone</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">clone</span><span class="p">,</span> <span class="n">when</span><span class="o">=</span><span class="n">when</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">clone_kind</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">clone_expression</span> -</span><span id="L-1250"><a href="#L-1250"><span class="linenos">1250</span></a> <span class="p">)</span> -</span><span id="L-1251"><a href="#L-1251"><span class="linenos">1251</span></a> -</span><span id="L-1252"><a href="#L-1252"><span class="linenos">1252</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><span id="L-1253"><a href="#L-1253"><span class="linenos">1253</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> -</span><span id="L-1254"><a href="#L-1254"><span class="linenos">1254</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-1255"><a href="#L-1255"><span class="linenos">1255</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">create_token</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> -</span><span id="L-1256"><a href="#L-1256"><span class="linenos">1256</span></a> <span class="n">replace</span><span class="o">=</span><span class="n">replace</span><span class="p">,</span> -</span><span id="L-1257"><a href="#L-1257"><span class="linenos">1257</span></a> <span class="n">unique</span><span class="o">=</span><span class="n">unique</span><span class="p">,</span> -</span><span id="L-1258"><a href="#L-1258"><span class="linenos">1258</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> -</span><span id="L-1259"><a href="#L-1259"><span class="linenos">1259</span></a> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span><span class="p">,</span> -</span><span id="L-1260"><a href="#L-1260"><span class="linenos">1260</span></a> <span class="n">properties</span><span class="o">=</span><span class="n">properties</span><span class="p">,</span> -</span><span id="L-1261"><a href="#L-1261"><span class="linenos">1261</span></a> <span class="n">indexes</span><span class="o">=</span><span class="n">indexes</span><span class="p">,</span> -</span><span id="L-1262"><a href="#L-1262"><span class="linenos">1262</span></a> <span class="n">no_schema_binding</span><span class="o">=</span><span class="n">no_schema_binding</span><span class="p">,</span> -</span><span id="L-1263"><a href="#L-1263"><span class="linenos">1263</span></a> <span class="n">begin</span><span class="o">=</span><span class="n">begin</span><span class="p">,</span> -</span><span id="L-1264"><a href="#L-1264"><span class="linenos">1264</span></a> <span class="n">clone</span><span class="o">=</span><span class="n">clone</span><span class="p">,</span> -</span><span id="L-1265"><a href="#L-1265"><span class="linenos">1265</span></a> <span class="p">)</span> -</span><span id="L-1266"><a href="#L-1266"><span class="linenos">1266</span></a> -</span><span id="L-1267"><a href="#L-1267"><span class="linenos">1267</span></a> <span class="k">def</span> <span class="nf">_parse_property_before</span><span class="p">(</span><span class="bp">self</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-1268"><a href="#L-1268"><span class="linenos">1268</span></a> <span class="c1"># only used for teradata currently</span> -</span><span id="L-1269"><a href="#L-1269"><span class="linenos">1269</span></a> <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">COMMA</span><span class="p">)</span> -</span><span id="L-1270"><a href="#L-1270"><span class="linenos">1270</span></a> -</span><span id="L-1271"><a href="#L-1271"><span class="linenos">1271</span></a> <span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-1272"><a href="#L-1272"><span class="linenos">1272</span></a> <span class="s2">"no"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">),</span> -</span><span id="L-1273"><a href="#L-1273"><span class="linenos">1273</span></a> <span class="s2">"dual"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DUAL"</span><span class="p">),</span> -</span><span id="L-1274"><a href="#L-1274"><span class="linenos">1274</span></a> <span class="s2">"before"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BEFORE"</span><span class="p">),</span> -</span><span id="L-1275"><a href="#L-1275"><span class="linenos">1275</span></a> <span class="s2">"default"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFAULT"</span><span class="p">),</span> -</span><span id="L-1276"><a href="#L-1276"><span class="linenos">1276</span></a> <span class="s2">"local"</span><span class="p">:</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LOCAL"</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"LOCAL"</span><span class="p">)</span> -</span><span id="L-1277"><a href="#L-1277"><span class="linenos">1277</span></a> <span class="ow">or</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NOT"</span><span class="p">,</span> <span class="s2">"LOCAL"</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"NOT LOCAL"</span><span class="p">),</span> -</span><span id="L-1278"><a href="#L-1278"><span class="linenos">1278</span></a> <span class="s2">"after"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AFTER"</span><span class="p">),</span> -</span><span id="L-1279"><a href="#L-1279"><span class="linenos">1279</span></a> <span class="s2">"minimum"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"MIN"</span><span class="p">,</span> <span class="s2">"MINIMUM"</span><span class="p">)),</span> -</span><span id="L-1280"><a href="#L-1280"><span class="linenos">1280</span></a> <span class="s2">"maximum"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"MAX"</span><span class="p">,</span> <span class="s2">"MAXIMUM"</span><span class="p">)),</span> -</span><span id="L-1281"><a href="#L-1281"><span class="linenos">1281</span></a> <span class="p">}</span> -</span><span id="L-1282"><a href="#L-1282"><span class="linenos">1282</span></a> -</span><span id="L-1283"><a href="#L-1283"><span class="linenos">1283</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">PROPERTY_PARSERS</span><span class="p">):</span> -</span><span id="L-1284"><a href="#L-1284"><span class="linenos">1284</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTY_PARSERS</span><span class="p">[</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="o">.</span><span class="n">upper</span><span class="p">()]</span> -</span><span id="L-1285"><a href="#L-1285"><span class="linenos">1285</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="L-1286"><a href="#L-1286"><span class="linenos">1286</span></a> <span class="k">return</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="n">v</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="k">if</span> <span class="n">v</span><span class="p">})</span> -</span><span id="L-1287"><a href="#L-1287"><span class="linenos">1287</span></a> <span class="k">except</span> <span class="ne">TypeError</span><span class="p">:</span> -</span><span id="L-1288"><a href="#L-1288"><span class="linenos">1288</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Cannot parse property '</span><span class="si">{</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="si">}</span><span class="s2">'"</span><span class="p">)</span> -</span><span id="L-1289"><a href="#L-1289"><span class="linenos">1289</span></a> -</span><span id="L-1290"><a href="#L-1290"><span class="linenos">1290</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-1291"><a href="#L-1291"><span class="linenos">1291</span></a> -</span><span id="L-1292"><a href="#L-1292"><span class="linenos">1292</span></a> <span class="k">def</span> <span class="nf">_parse_property</span><span class="p">(</span><span class="bp">self</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-1293"><a href="#L-1293"><span class="linenos">1293</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">PROPERTY_PARSERS</span><span class="p">):</span> -</span><span id="L-1294"><a href="#L-1294"><span class="linenos">1294</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTY_PARSERS</span><span class="p">[</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="o">.</span><span class="n">upper</span><span class="p">()](</span><span class="bp">self</span><span class="p">)</span> -</span><span id="L-1295"><a href="#L-1295"><span class="linenos">1295</span></a> -</span><span id="L-1296"><a href="#L-1296"><span class="linenos">1296</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CHARACTER_SET</span><span class="p">):</span> -</span><span id="L-1297"><a href="#L-1297"><span class="linenos">1297</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_character_set</span><span class="p">(</span><span class="n">default</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1298"><a href="#L-1298"><span class="linenos">1298</span></a> -</span><span id="L-1299"><a href="#L-1299"><span class="linenos">1299</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"COMPOUND"</span><span class="p">,</span> <span class="s2">"SORTKEY"</span><span class="p">):</span> -</span><span id="L-1300"><a href="#L-1300"><span class="linenos">1300</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_sortkey</span><span class="p">(</span><span class="n">compound</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1301"><a href="#L-1301"><span class="linenos">1301</span></a> -</span><span id="L-1302"><a href="#L-1302"><span class="linenos">1302</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SQL"</span><span class="p">,</span> <span class="s2">"SECURITY"</span><span class="p">):</span> -</span><span id="L-1303"><a href="#L-1303"><span class="linenos">1303</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">SqlSecurityProperty</span><span class="p">,</span> <span class="n">definer</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFINER"</span><span class="p">))</span> -</span><span id="L-1304"><a href="#L-1304"><span class="linenos">1304</span></a> -</span><span id="L-1305"><a href="#L-1305"><span class="linenos">1305</span></a> <span class="n">assignment</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span> -</span><span id="L-1306"><a href="#L-1306"><span class="linenos">1306</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span> -</span><span id="L-1307"><a href="#L-1307"><span class="linenos">1307</span></a> <span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</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-1308"><a href="#L-1308"><span class="linenos">1308</span></a> -</span><span id="L-1309"><a href="#L-1309"><span class="linenos">1309</span></a> <span class="k">if</span> <span class="n">assignment</span><span class="p">:</span> -</span><span id="L-1310"><a href="#L-1310"><span class="linenos">1310</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var_or_string</span><span class="p">()</span> -</span><span id="L-1311"><a href="#L-1311"><span class="linenos">1311</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="L-1312"><a href="#L-1312"><span class="linenos">1312</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">Property</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">())</span> -</span><span id="L-1313"><a href="#L-1313"><span class="linenos">1313</span></a> -</span><span id="L-1314"><a href="#L-1314"><span class="linenos">1314</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-1315"><a href="#L-1315"><span class="linenos">1315</span></a> -</span><span id="L-1316"><a href="#L-1316"><span class="linenos">1316</span></a> <span class="k">def</span> <span class="nf">_parse_stored</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">FileFormatProperty</span><span class="p">:</span> -</span><span id="L-1317"><a href="#L-1317"><span class="linenos">1317</span></a> <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">ALIAS</span><span class="p">)</span> -</span><span id="L-1318"><a href="#L-1318"><span class="linenos">1318</span></a> -</span><span id="L-1319"><a href="#L-1319"><span class="linenos">1319</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INPUTFORMAT"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="L-1320"><a href="#L-1320"><span class="linenos">1320</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OUTPUTFORMAT"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="L-1321"><a href="#L-1321"><span class="linenos">1321</span></a> -</span><span id="L-1322"><a href="#L-1322"><span class="linenos">1322</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><span id="L-1323"><a href="#L-1323"><span class="linenos">1323</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">,</span> -</span><span id="L-1324"><a href="#L-1324"><span class="linenos">1324</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-1325"><a href="#L-1325"><span class="linenos">1325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">,</span> <span class="n">input_format</span><span class="o">=</span><span class="n">input_format</span><span class="p">,</span> <span class="n">output_format</span><span class="o">=</span><span class="n">output_format</span> -</span><span id="L-1326"><a href="#L-1326"><span class="linenos">1326</span></a> <span class="p">)</span> -</span><span id="L-1327"><a href="#L-1327"><span class="linenos">1327</span></a> <span class="k">if</span> <span class="n">input_format</span> <span class="ow">or</span> <span class="n">output_format</span> -</span><span id="L-1328"><a href="#L-1328"><span class="linenos">1328</span></a> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var_or_string</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(),</span> -</span><span id="L-1329"><a href="#L-1329"><span class="linenos">1329</span></a> <span class="p">)</span> -</span><span id="L-1330"><a href="#L-1330"><span class="linenos">1330</span></a> -</span><span id="L-1331"><a href="#L-1331"><span class="linenos">1331</span></a> <span class="k">def</span> <span class="nf">_parse_property_assignment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">])</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="L-1332"><a href="#L-1332"><span class="linenos">1332</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">)</span> -</span><span id="L-1333"><a href="#L-1333"><span class="linenos">1333</span></a> <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">ALIAS</span><span class="p">)</span> -</span><span id="L-1334"><a href="#L-1334"><span class="linenos">1334</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_class</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_field</span><span class="p">())</span> -</span><span id="L-1335"><a href="#L-1335"><span class="linenos">1335</span></a> -</span><span id="L-1336"><a href="#L-1336"><span class="linenos">1336</span></a> <span class="k">def</span> <span class="nf">_parse_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">before</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span 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">Properties</span><span class="p">]:</span> -</span><span id="L-1337"><a href="#L-1337"><span class="linenos">1337</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-1338"><a href="#L-1338"><span class="linenos">1338</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-1339"><a href="#L-1339"><span class="linenos">1339</span></a> <span class="k">if</span> <span class="n">before</span><span class="p">:</span> -</span><span id="L-1340"><a href="#L-1340"><span class="linenos">1340</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_property_before</span><span class="p">()</span> -</span><span id="L-1341"><a href="#L-1341"><span class="linenos">1341</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1342"><a href="#L-1342"><span class="linenos">1342</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_property</span><span class="p">()</span> -</span><span id="L-1343"><a href="#L-1343"><span class="linenos">1343</span></a> -</span><span id="L-1344"><a href="#L-1344"><span class="linenos">1344</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">prop</span><span class="p">:</span> -</span><span id="L-1345"><a href="#L-1345"><span class="linenos">1345</span></a> <span class="k">break</span> -</span><span id="L-1346"><a href="#L-1346"><span class="linenos">1346</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">prop</span><span class="p">):</span> -</span><span id="L-1347"><a href="#L-1347"><span class="linenos">1347</span></a> <span class="n">properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="L-1348"><a href="#L-1348"><span class="linenos">1348</span></a> -</span><span id="L-1349"><a href="#L-1349"><span class="linenos">1349</span></a> <span class="k">if</span> <span class="n">properties</span><span class="p">:</span> -</span><span id="L-1350"><a href="#L-1350"><span class="linenos">1350</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">Properties</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">properties</span><span class="p">)</span> -</span><span id="L-1351"><a href="#L-1351"><span class="linenos">1351</span></a> -</span><span id="L-1352"><a href="#L-1352"><span class="linenos">1352</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-1353"><a href="#L-1353"><span class="linenos">1353</span></a> -</span><span id="L-1354"><a href="#L-1354"><span class="linenos">1354</span></a> <span class="k">def</span> <span class="nf">_parse_fallback</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">no</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">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">:</span> -</span><span id="L-1355"><a href="#L-1355"><span class="linenos">1355</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><span id="L-1356"><a href="#L-1356"><span class="linenos">1356</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">,</span> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">,</span> <span class="n">protection</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PROTECTION"</span><span class="p">)</span> -</span><span id="L-1357"><a href="#L-1357"><span class="linenos">1357</span></a> <span class="p">)</span> -</span><span id="L-1358"><a href="#L-1358"><span class="linenos">1358</span></a> -</span><span id="L-1359"><a href="#L-1359"><span class="linenos">1359</span></a> <span class="k">def</span> <span class="nf">_parse_volatile_property</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">VolatileProperty</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> -</span><span id="L-1360"><a href="#L-1360"><span class="linenos">1360</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">>=</span> <span class="mi">2</span><span class="p">:</span> -</span><span id="L-1361"><a href="#L-1361"><span class="linenos">1361</span></a> <span class="n">pre_volatile_token</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">2</span><span class="p">]</span> -</span><span id="L-1362"><a href="#L-1362"><span class="linenos">1362</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1363"><a href="#L-1363"><span class="linenos">1363</span></a> <span class="n">pre_volatile_token</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1364"><a href="#L-1364"><span class="linenos">1364</span></a> -</span><span id="L-1365"><a href="#L-1365"><span class="linenos">1365</span></a> <span class="k">if</span> <span class="n">pre_volatile_token</span> <span class="ow">and</span> <span class="n">pre_volatile_token</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRE_VOLATILE_TOKENS</span><span class="p">:</span> -</span><span id="L-1366"><a href="#L-1366"><span class="linenos">1366</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">()</span> -</span><span id="L-1367"><a href="#L-1367"><span class="linenos">1367</span></a> -</span><span id="L-1368"><a href="#L-1368"><span class="linenos">1368</span></a> <span class="k">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">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"VOLATILE"</span><span class="p">))</span> -</span><span id="L-1369"><a href="#L-1369"><span class="linenos">1369</span></a> -</span><span id="L-1370"><a href="#L-1370"><span class="linenos">1370</span></a> <span class="k">def</span> <span class="nf">_parse_with_property</span><span class="p">(</span> -</span><span id="L-1371"><a href="#L-1371"><span class="linenos">1371</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-1372"><a href="#L-1372"><span class="linenos">1372</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 class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">List</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><span id="L-1373"><a href="#L-1373"><span class="linenos">1373</span></a> <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">WITH</span><span class="p">)</span> -</span><span id="L-1374"><a href="#L-1374"><span class="linenos">1374</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_PAREN</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-1375"><a href="#L-1375"><span class="linenos">1375</span></a> <span class="k">return</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_property</span><span class="p">)</span> -</span><span id="L-1376"><a href="#L-1376"><span class="linenos">1376</span></a> -</span><span id="L-1377"><a href="#L-1377"><span class="linenos">1377</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"JOURNAL"</span><span class="p">):</span> -</span><span id="L-1378"><a href="#L-1378"><span class="linenos">1378</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_withjournaltable</span><span class="p">()</span> -</span><span id="L-1379"><a href="#L-1379"><span class="linenos">1379</span></a> -</span><span id="L-1380"><a href="#L-1380"><span class="linenos">1380</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DATA"</span><span class="p">):</span> -</span><span id="L-1381"><a href="#L-1381"><span class="linenos">1381</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_withdata</span><span class="p">(</span><span class="n">no</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-1382"><a href="#L-1382"><span class="linenos">1382</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"DATA"</span><span class="p">):</span> -</span><span id="L-1383"><a href="#L-1383"><span class="linenos">1383</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_withdata</span><span class="p">(</span><span class="n">no</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1384"><a href="#L-1384"><span class="linenos">1384</span></a> -</span><span id="L-1385"><a href="#L-1385"><span class="linenos">1385</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> -</span><span id="L-1386"><a href="#L-1386"><span class="linenos">1386</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-1387"><a href="#L-1387"><span class="linenos">1387</span></a> -</span><span id="L-1388"><a href="#L-1388"><span class="linenos">1388</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_withisolatedloading</span><span class="p">()</span> -</span><span id="L-1389"><a href="#L-1389"><span class="linenos">1389</span></a> -</span><span id="L-1390"><a href="#L-1390"><span class="linenos">1390</span></a> <span class="c1"># https://dev.mysql.com/doc/refman/8.0/en/create-view.html</span> -</span><span id="L-1391"><a href="#L-1391"><span class="linenos">1391</span></a> <span class="k">def</span> <span class="nf">_parse_definer</span><span class="p">(</span><span class="bp">self</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">DefinerProperty</span><span class="p">]:</span> -</span><span id="L-1392"><a href="#L-1392"><span class="linenos">1392</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="L-1393"><a href="#L-1393"><span class="linenos">1393</span></a> -</span><span id="L-1394"><a href="#L-1394"><span class="linenos">1394</span></a> <span class="n">user</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="L-1395"><a href="#L-1395"><span class="linenos">1395</span></a> <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">PARAMETER</span><span class="p">)</span> -</span><span id="L-1396"><a href="#L-1396"><span class="linenos">1396</span></a> <span class="n">host</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> <span class="ow">or</span> <span class="p">(</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">MOD</span><span class="p">)</span> <span class="ow">and</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-1397"><a href="#L-1397"><span class="linenos">1397</span></a> -</span><span id="L-1398"><a href="#L-1398"><span class="linenos">1398</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">user</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">host</span><span class="p">:</span> -</span><span id="L-1399"><a href="#L-1399"><span class="linenos">1399</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-1400"><a href="#L-1400"><span class="linenos">1400</span></a> -</span><span id="L-1401"><a href="#L-1401"><span class="linenos">1401</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">DefinerProperty</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">user</span><span class="si">}</span><span class="s2">@</span><span class="si">{</span><span class="n">host</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-1402"><a href="#L-1402"><span class="linenos">1402</span></a> -</span><span id="L-1403"><a href="#L-1403"><span class="linenos">1403</span></a> <span class="k">def</span> <span class="nf">_parse_withjournaltable</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">WithJournalTableProperty</span><span class="p">:</span> -</span><span id="L-1404"><a href="#L-1404"><span class="linenos">1404</span></a> <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">TABLE</span><span class="p">)</span> -</span><span id="L-1405"><a href="#L-1405"><span class="linenos">1405</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="L-1406"><a href="#L-1406"><span class="linenos">1406</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">WithJournalTableProperty</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_table_parts</span><span class="p">())</span> -</span><span id="L-1407"><a href="#L-1407"><span class="linenos">1407</span></a> -</span><span id="L-1408"><a href="#L-1408"><span class="linenos">1408</span></a> <span class="k">def</span> <span class="nf">_parse_log</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">no</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">exp</span><span class="o">.</span><span class="n">LogProperty</span><span class="p">:</span> -</span><span id="L-1409"><a href="#L-1409"><span class="linenos">1409</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">LogProperty</span><span class="p">,</span> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">)</span> -</span><span id="L-1410"><a href="#L-1410"><span class="linenos">1410</span></a> -</span><span id="L-1411"><a href="#L-1411"><span class="linenos">1411</span></a> <span class="k">def</span> <span class="nf">_parse_journal</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">:</span> -</span><span id="L-1412"><a href="#L-1412"><span class="linenos">1412</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">JournalProperty</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="L-1413"><a href="#L-1413"><span class="linenos">1413</span></a> -</span><span id="L-1414"><a href="#L-1414"><span class="linenos">1414</span></a> <span class="k">def</span> <span class="nf">_parse_checksum</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">ChecksumProperty</span><span class="p">:</span> -</span><span id="L-1415"><a href="#L-1415"><span class="linenos">1415</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="L-1416"><a href="#L-1416"><span class="linenos">1416</span></a> -</span><span id="L-1417"><a href="#L-1417"><span class="linenos">1417</span></a> <span class="n">on</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1418"><a href="#L-1418"><span class="linenos">1418</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">ON</span><span class="p">):</span> -</span><span id="L-1419"><a href="#L-1419"><span class="linenos">1419</span></a> <span class="n">on</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-1420"><a href="#L-1420"><span class="linenos">1420</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OFF"</span><span class="p">):</span> -</span><span id="L-1421"><a href="#L-1421"><span class="linenos">1421</span></a> <span class="n">on</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-1422"><a href="#L-1422"><span class="linenos">1422</span></a> -</span><span id="L-1423"><a href="#L-1423"><span class="linenos">1423</span></a> <span class="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">ChecksumProperty</span><span class="p">,</span> <span class="n">on</span><span class="o">=</span><span class="n">on</span><span class="p">,</span> <span class="n">default</span><span class="o">=</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">DEFAULT</span><span class="p">))</span> -</span><span id="L-1424"><a href="#L-1424"><span class="linenos">1424</span></a> -</span><span id="L-1425"><a href="#L-1425"><span class="linenos">1425</span></a> <span class="k">def</span> <span class="nf">_parse_cluster</span><span class="p">(</span><span class="bp">self</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">Cluster</span><span class="p">]:</span> -</span><span id="L-1426"><a href="#L-1426"><span class="linenos">1426</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BY"</span><span class="p">):</span> -</span><span id="L-1427"><a href="#L-1427"><span class="linenos">1427</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="L-1428"><a href="#L-1428"><span class="linenos">1428</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-1429"><a href="#L-1429"><span class="linenos">1429</span></a> -</span><span id="L-1430"><a href="#L-1430"><span class="linenos">1430</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">Cluster</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_ordered</span><span class="p">))</span> -</span><span id="L-1431"><a href="#L-1431"><span class="linenos">1431</span></a> -</span><span id="L-1432"><a href="#L-1432"><span class="linenos">1432</span></a> <span class="k">def</span> <span class="nf">_parse_freespace</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">FreespaceProperty</span><span class="p">:</span> -</span><span id="L-1433"><a href="#L-1433"><span class="linenos">1433</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="L-1434"><a href="#L-1434"><span class="linenos">1434</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><span id="L-1435"><a href="#L-1435"><span class="linenos">1435</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</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_number</span><span class="p">(),</span> <span class="n">percent</span><span class="o">=</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">PERCENT</span><span class="p">)</span> -</span><span id="L-1436"><a href="#L-1436"><span class="linenos">1436</span></a> <span class="p">)</span> -</span><span id="L-1437"><a href="#L-1437"><span class="linenos">1437</span></a> -</span><span id="L-1438"><a href="#L-1438"><span class="linenos">1438</span></a> <span class="k">def</span> <span class="nf">_parse_mergeblockratio</span><span class="p">(</span> -</span><span id="L-1439"><a href="#L-1439"><span class="linenos">1439</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">no</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="n">default</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-1440"><a href="#L-1440"><span class="linenos">1440</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">:</span> -</span><span id="L-1441"><a href="#L-1441"><span class="linenos">1441</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">):</span> -</span><span id="L-1442"><a href="#L-1442"><span class="linenos">1442</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><span id="L-1443"><a href="#L-1443"><span class="linenos">1443</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">,</span> -</span><span id="L-1444"><a href="#L-1444"><span class="linenos">1444</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">(),</span> -</span><span id="L-1445"><a href="#L-1445"><span class="linenos">1445</span></a> <span class="n">percent</span><span class="o">=</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">PERCENT</span><span class="p">),</span> -</span><span id="L-1446"><a href="#L-1446"><span class="linenos">1446</span></a> <span class="p">)</span> -</span><span id="L-1447"><a href="#L-1447"><span class="linenos">1447</span></a> -</span><span id="L-1448"><a href="#L-1448"><span class="linenos">1448</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">MergeBlockRatioProperty</span><span class="p">,</span> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">default</span><span class="p">)</span> -</span><span id="L-1449"><a href="#L-1449"><span class="linenos">1449</span></a> -</span><span id="L-1450"><a href="#L-1450"><span class="linenos">1450</span></a> <span class="k">def</span> <span class="nf">_parse_datablocksize</span><span class="p">(</span> -</span><span id="L-1451"><a href="#L-1451"><span class="linenos">1451</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-1452"><a href="#L-1452"><span class="linenos">1452</span></a> <span class="n">default</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-1453"><a href="#L-1453"><span class="linenos">1453</span></a> <span class="n">minimum</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-1454"><a href="#L-1454"><span class="linenos">1454</span></a> <span class="n">maximum</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-1455"><a href="#L-1455"><span class="linenos">1455</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">:</span> -</span><span id="L-1456"><a href="#L-1456"><span class="linenos">1456</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="L-1457"><a href="#L-1457"><span class="linenos">1457</span></a> <span class="n">size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> -</span><span id="L-1458"><a href="#L-1458"><span class="linenos">1458</span></a> -</span><span id="L-1459"><a href="#L-1459"><span class="linenos">1459</span></a> <span class="n">units</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1460"><a href="#L-1460"><span class="linenos">1460</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"BYTES"</span><span class="p">,</span> <span class="s2">"KBYTES"</span><span class="p">,</span> <span class="s2">"KILOBYTES"</span><span class="p">)):</span> -</span><span id="L-1461"><a href="#L-1461"><span class="linenos">1461</span></a> <span class="n">units</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><span id="L-590"><a href="#L-590"><span class="linenos"> 590</span></a> <span class="s2">"COPY"</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_copy_property</span><span class="p">(),</span> +</span><span id="L-591"><a href="#L-591"><span class="linenos"> 591</span></a> <span class="s2">"DATABLOCKSIZE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_datablocksize</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> +</span><span id="L-592"><a href="#L-592"><span class="linenos"> 592</span></a> <span class="s2">"DEFINER"</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_definer</span><span class="p">(),</span> +</span><span id="L-593"><a href="#L-593"><span class="linenos"> 593</span></a> <span class="s2">"DETERMINISTIC"</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">expression</span><span class="p">(</span> +</span><span id="L-594"><a href="#L-594"><span class="linenos"> 594</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"IMMUTABLE"</span><span class="p">)</span> +</span><span id="L-595"><a href="#L-595"><span class="linenos"> 595</span></a> <span class="p">),</span> +</span><span id="L-596"><a href="#L-596"><span class="linenos"> 596</span></a> <span class="s2">"DISTKEY"</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_distkey</span><span class="p">(),</span> +</span><span id="L-597"><a href="#L-597"><span class="linenos"> 597</span></a> <span class="s2">"DISTSTYLE"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">),</span> +</span><span id="L-598"><a href="#L-598"><span class="linenos"> 598</span></a> <span class="s2">"ENGINE"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">EngineProperty</span><span class="p">),</span> +</span><span id="L-599"><a href="#L-599"><span class="linenos"> 599</span></a> <span class="s2">"EXECUTE"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ExecuteAsProperty</span><span class="p">),</span> +</span><span id="L-600"><a href="#L-600"><span class="linenos"> 600</span></a> <span class="s2">"EXTERNAL"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ExternalProperty</span><span class="p">),</span> +</span><span id="L-601"><a href="#L-601"><span class="linenos"> 601</span></a> <span class="s2">"FALLBACK"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_fallback</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> +</span><span id="L-602"><a href="#L-602"><span class="linenos"> 602</span></a> <span class="s2">"FORMAT"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">),</span> +</span><span id="L-603"><a href="#L-603"><span class="linenos"> 603</span></a> <span class="s2">"FREESPACE"</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_freespace</span><span class="p">(),</span> +</span><span id="L-604"><a href="#L-604"><span class="linenos"> 604</span></a> <span class="s2">"IMMUTABLE"</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">expression</span><span class="p">(</span> +</span><span id="L-605"><a href="#L-605"><span class="linenos"> 605</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"IMMUTABLE"</span><span class="p">)</span> +</span><span id="L-606"><a href="#L-606"><span class="linenos"> 606</span></a> <span class="p">),</span> +</span><span id="L-607"><a href="#L-607"><span class="linenos"> 607</span></a> <span class="s2">"JOURNAL"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_journal</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> +</span><span id="L-608"><a href="#L-608"><span class="linenos"> 608</span></a> <span class="s2">"LANGUAGE"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LanguageProperty</span><span class="p">),</span> +</span><span id="L-609"><a href="#L-609"><span class="linenos"> 609</span></a> <span class="s2">"LAYOUT"</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_dict_property</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"LAYOUT"</span><span class="p">),</span> +</span><span id="L-610"><a href="#L-610"><span class="linenos"> 610</span></a> <span class="s2">"LIFETIME"</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_dict_range</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"LIFETIME"</span><span class="p">),</span> +</span><span id="L-611"><a href="#L-611"><span class="linenos"> 611</span></a> <span class="s2">"LIKE"</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_create_like</span><span class="p">(),</span> +</span><span id="L-612"><a href="#L-612"><span class="linenos"> 612</span></a> <span class="s2">"LOCATION"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">),</span> +</span><span id="L-613"><a href="#L-613"><span class="linenos"> 613</span></a> <span class="s2">"LOCK"</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_locking</span><span class="p">(),</span> +</span><span id="L-614"><a href="#L-614"><span class="linenos"> 614</span></a> <span class="s2">"LOCKING"</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_locking</span><span class="p">(),</span> +</span><span id="L-615"><a href="#L-615"><span class="linenos"> 615</span></a> <span class="s2">"LOG"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_log</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> +</span><span id="L-616"><a href="#L-616"><span class="linenos"> 616</span></a> <span class="s2">"MATERIALIZED"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">MaterializedProperty</span><span class="p">),</span> +</span><span id="L-617"><a href="#L-617"><span class="linenos"> 617</span></a> <span class="s2">"MERGEBLOCKRATIO"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_mergeblockratio</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> +</span><span id="L-618"><a href="#L-618"><span class="linenos"> 618</span></a> <span class="s2">"MULTISET"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">,</span> <span class="n">multi</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="L-619"><a href="#L-619"><span class="linenos"> 619</span></a> <span class="s2">"NO"</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_no_property</span><span class="p">(),</span> +</span><span id="L-620"><a href="#L-620"><span class="linenos"> 620</span></a> <span class="s2">"ON"</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_on_property</span><span class="p">(),</span> +</span><span id="L-621"><a href="#L-621"><span class="linenos"> 621</span></a> <span class="s2">"ORDER BY"</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_order</span><span class="p">(</span><span class="n">skip_order_token</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="L-622"><a href="#L-622"><span class="linenos"> 622</span></a> <span class="s2">"PARTITION BY"</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_partitioned_by</span><span class="p">(),</span> +</span><span id="L-623"><a href="#L-623"><span class="linenos"> 623</span></a> <span class="s2">"PARTITIONED BY"</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_partitioned_by</span><span class="p">(),</span> +</span><span id="L-624"><a href="#L-624"><span class="linenos"> 624</span></a> <span class="s2">"PARTITIONED_BY"</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_partitioned_by</span><span class="p">(),</span> +</span><span id="L-625"><a href="#L-625"><span class="linenos"> 625</span></a> <span class="s2">"PRIMARY KEY"</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_primary_key</span><span class="p">(</span><span class="n">in_props</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="L-626"><a href="#L-626"><span class="linenos"> 626</span></a> <span class="s2">"RANGE"</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_dict_range</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"RANGE"</span><span class="p">),</span> +</span><span id="L-627"><a href="#L-627"><span class="linenos"> 627</span></a> <span class="s2">"RETURNS"</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_returns</span><span class="p">(),</span> +</span><span id="L-628"><a href="#L-628"><span class="linenos"> 628</span></a> <span class="s2">"ROW"</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_row</span><span class="p">(),</span> +</span><span id="L-629"><a href="#L-629"><span class="linenos"> 629</span></a> <span class="s2">"ROW_FORMAT"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">RowFormatProperty</span><span class="p">),</span> +</span><span id="L-630"><a href="#L-630"><span class="linenos"> 630</span></a> <span class="s2">"SET"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">,</span> <span class="n">multi</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="L-631"><a href="#L-631"><span class="linenos"> 631</span></a> <span class="s2">"SETTINGS"</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">expression</span><span class="p">(</span> +</span><span id="L-632"><a href="#L-632"><span class="linenos"> 632</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SettingsProperty</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_item</span><span class="p">)</span> +</span><span id="L-633"><a href="#L-633"><span class="linenos"> 633</span></a> <span class="p">),</span> +</span><span id="L-634"><a href="#L-634"><span class="linenos"> 634</span></a> <span class="s2">"SORTKEY"</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_sortkey</span><span class="p">(),</span> +</span><span id="L-635"><a href="#L-635"><span class="linenos"> 635</span></a> <span class="s2">"SOURCE"</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_dict_property</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"SOURCE"</span><span class="p">),</span> +</span><span id="L-636"><a href="#L-636"><span class="linenos"> 636</span></a> <span class="s2">"STABLE"</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">expression</span><span class="p">(</span> +</span><span id="L-637"><a href="#L-637"><span class="linenos"> 637</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"STABLE"</span><span class="p">)</span> +</span><span id="L-638"><a href="#L-638"><span class="linenos"> 638</span></a> <span class="p">),</span> +</span><span id="L-639"><a href="#L-639"><span class="linenos"> 639</span></a> <span class="s2">"STORED"</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_stored</span><span class="p">(),</span> +</span><span id="L-640"><a href="#L-640"><span class="linenos"> 640</span></a> <span class="s2">"TBLPROPERTIES"</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_wrapped_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_property</span><span class="p">),</span> +</span><span id="L-641"><a href="#L-641"><span class="linenos"> 641</span></a> <span class="s2">"TEMP"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">),</span> +</span><span id="L-642"><a href="#L-642"><span class="linenos"> 642</span></a> <span class="s2">"TEMPORARY"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">),</span> +</span><span id="L-643"><a href="#L-643"><span class="linenos"> 643</span></a> <span class="s2">"TO"</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_to_table</span><span class="p">(),</span> +</span><span id="L-644"><a href="#L-644"><span class="linenos"> 644</span></a> <span class="s2">"TRANSIENT"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TransientProperty</span><span class="p">),</span> +</span><span id="L-645"><a href="#L-645"><span class="linenos"> 645</span></a> <span class="s2">"TTL"</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_ttl</span><span class="p">(),</span> +</span><span id="L-646"><a href="#L-646"><span class="linenos"> 646</span></a> <span class="s2">"USING"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">),</span> +</span><span id="L-647"><a href="#L-647"><span class="linenos"> 647</span></a> <span class="s2">"VOLATILE"</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_volatile_property</span><span class="p">(),</span> +</span><span id="L-648"><a href="#L-648"><span class="linenos"> 648</span></a> <span class="s2">"WITH"</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_with_property</span><span class="p">(),</span> +</span><span id="L-649"><a href="#L-649"><span class="linenos"> 649</span></a> <span class="p">}</span> +</span><span id="L-650"><a href="#L-650"><span class="linenos"> 650</span></a> +</span><span id="L-651"><a href="#L-651"><span class="linenos"> 651</span></a> <span class="n">CONSTRAINT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-652"><a href="#L-652"><span class="linenos"> 652</span></a> <span class="s2">"AUTOINCREMENT"</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_auto_increment</span><span class="p">(),</span> +</span><span id="L-653"><a href="#L-653"><span class="linenos"> 653</span></a> <span class="s2">"AUTO_INCREMENT"</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_auto_increment</span><span class="p">(),</span> +</span><span id="L-654"><a href="#L-654"><span class="linenos"> 654</span></a> <span class="s2">"CASESPECIFIC"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">CaseSpecificColumnConstraint</span><span class="p">,</span> <span class="n">not_</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="L-655"><a href="#L-655"><span class="linenos"> 655</span></a> <span class="s2">"CHARACTER SET"</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">expression</span><span class="p">(</span> +</span><span id="L-656"><a href="#L-656"><span class="linenos"> 656</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetColumnConstraint</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_var_or_string</span><span class="p">()</span> +</span><span id="L-657"><a href="#L-657"><span class="linenos"> 657</span></a> <span class="p">),</span> +</span><span id="L-658"><a href="#L-658"><span class="linenos"> 658</span></a> <span class="s2">"CHECK"</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">expression</span><span class="p">(</span> +</span><span id="L-659"><a href="#L-659"><span class="linenos"> 659</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CheckColumnConstraint</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_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="L-660"><a href="#L-660"><span class="linenos"> 660</span></a> <span class="p">),</span> +</span><span id="L-661"><a href="#L-661"><span class="linenos"> 661</span></a> <span class="s2">"COLLATE"</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">expression</span><span class="p">(</span> +</span><span id="L-662"><a href="#L-662"><span class="linenos"> 662</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateColumnConstraint</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_var</span><span class="p">()</span> +</span><span id="L-663"><a href="#L-663"><span class="linenos"> 663</span></a> <span class="p">),</span> +</span><span id="L-664"><a href="#L-664"><span class="linenos"> 664</span></a> <span class="s2">"COMMENT"</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">expression</span><span class="p">(</span> +</span><span id="L-665"><a href="#L-665"><span class="linenos"> 665</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CommentColumnConstraint</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_string</span><span class="p">()</span> +</span><span id="L-666"><a href="#L-666"><span class="linenos"> 666</span></a> <span class="p">),</span> +</span><span id="L-667"><a href="#L-667"><span class="linenos"> 667</span></a> <span class="s2">"COMPRESS"</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_compress</span><span class="p">(),</span> +</span><span id="L-668"><a href="#L-668"><span class="linenos"> 668</span></a> <span class="s2">"DEFAULT"</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">expression</span><span class="p">(</span> +</span><span id="L-669"><a href="#L-669"><span class="linenos"> 669</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DefaultColumnConstraint</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_bitwise</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 class="s2">"ENCODE"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">EncodeColumnConstraint</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_var</span><span class="p">()),</span> +</span><span id="L-672"><a href="#L-672"><span class="linenos"> 672</span></a> <span class="s2">"FOREIGN KEY"</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_foreign_key</span><span class="p">(),</span> +</span><span id="L-673"><a href="#L-673"><span class="linenos"> 673</span></a> <span class="s2">"FORMAT"</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">expression</span><span class="p">(</span> +</span><span id="L-674"><a href="#L-674"><span class="linenos"> 674</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFormatColumnConstraint</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_var_or_string</span><span class="p">()</span> +</span><span id="L-675"><a href="#L-675"><span class="linenos"> 675</span></a> <span class="p">),</span> +</span><span id="L-676"><a href="#L-676"><span class="linenos"> 676</span></a> <span class="s2">"GENERATED"</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_generated_as_identity</span><span class="p">(),</span> +</span><span id="L-677"><a href="#L-677"><span class="linenos"> 677</span></a> <span class="s2">"IDENTITY"</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_auto_increment</span><span class="p">(),</span> +</span><span id="L-678"><a href="#L-678"><span class="linenos"> 678</span></a> <span class="s2">"INLINE"</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_inline</span><span class="p">(),</span> +</span><span id="L-679"><a href="#L-679"><span class="linenos"> 679</span></a> <span class="s2">"LIKE"</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_create_like</span><span class="p">(),</span> +</span><span id="L-680"><a href="#L-680"><span class="linenos"> 680</span></a> <span class="s2">"NOT"</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_not_constraint</span><span class="p">(),</span> +</span><span id="L-681"><a href="#L-681"><span class="linenos"> 681</span></a> <span class="s2">"NULL"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">NotNullColumnConstraint</span><span class="p">,</span> <span class="n">allow_null</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="L-682"><a href="#L-682"><span class="linenos"> 682</span></a> <span class="s2">"ON"</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">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">UPDATE</span><span class="p">)</span> +</span><span id="L-683"><a href="#L-683"><span class="linenos"> 683</span></a> <span class="ow">and</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">OnUpdateColumnConstraint</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_function</span><span class="p">()),</span> +</span><span id="L-684"><a href="#L-684"><span class="linenos"> 684</span></a> <span class="s2">"PATH"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">PathColumnConstraint</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_string</span><span class="p">()),</span> +</span><span id="L-685"><a href="#L-685"><span class="linenos"> 685</span></a> <span class="s2">"PRIMARY KEY"</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_primary_key</span><span class="p">(),</span> +</span><span id="L-686"><a href="#L-686"><span class="linenos"> 686</span></a> <span class="s2">"REFERENCES"</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_references</span><span class="p">(</span><span class="n">match</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="L-687"><a href="#L-687"><span class="linenos"> 687</span></a> <span class="s2">"TITLE"</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">expression</span><span class="p">(</span> +</span><span id="L-688"><a href="#L-688"><span class="linenos"> 688</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TitleColumnConstraint</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_var_or_string</span><span class="p">()</span> +</span><span id="L-689"><a href="#L-689"><span class="linenos"> 689</span></a> <span class="p">),</span> +</span><span id="L-690"><a href="#L-690"><span class="linenos"> 690</span></a> <span class="s2">"TTL"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()]),</span> +</span><span id="L-691"><a href="#L-691"><span class="linenos"> 691</span></a> <span class="s2">"UNIQUE"</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_unique</span><span class="p">(),</span> +</span><span id="L-692"><a href="#L-692"><span class="linenos"> 692</span></a> <span class="s2">"UPPERCASE"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">UppercaseColumnConstraint</span><span class="p">),</span> +</span><span id="L-693"><a href="#L-693"><span class="linenos"> 693</span></a> <span class="p">}</span> +</span><span id="L-694"><a href="#L-694"><span class="linenos"> 694</span></a> +</span><span id="L-695"><a href="#L-695"><span class="linenos"> 695</span></a> <span class="n">ALTER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-696"><a href="#L-696"><span class="linenos"> 696</span></a> <span class="s2">"ADD"</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_alter_table_add</span><span class="p">(),</span> +</span><span id="L-697"><a href="#L-697"><span class="linenos"> 697</span></a> <span class="s2">"ALTER"</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_alter_table_alter</span><span class="p">(),</span> +</span><span id="L-698"><a href="#L-698"><span class="linenos"> 698</span></a> <span class="s2">"DELETE"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">,</span> <span class="n">where</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">()),</span> +</span><span id="L-699"><a href="#L-699"><span class="linenos"> 699</span></a> <span class="s2">"DROP"</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_alter_table_drop</span><span class="p">(),</span> +</span><span id="L-700"><a href="#L-700"><span class="linenos"> 700</span></a> <span class="s2">"RENAME"</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_alter_table_rename</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><span id="L-702"><a href="#L-702"><span class="linenos"> 702</span></a> +</span><span id="L-703"><a href="#L-703"><span class="linenos"> 703</span></a> <span class="n">SCHEMA_UNNAMED_CONSTRAINTS</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"CHECK"</span><span class="p">,</span> <span class="s2">"FOREIGN KEY"</span><span class="p">,</span> <span class="s2">"LIKE"</span><span class="p">,</span> <span class="s2">"PRIMARY KEY"</span><span class="p">,</span> <span class="s2">"UNIQUE"</span><span class="p">}</span> +</span><span id="L-704"><a href="#L-704"><span class="linenos"> 704</span></a> +</span><span id="L-705"><a href="#L-705"><span class="linenos"> 705</span></a> <span class="n">NO_PAREN_FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-706"><a href="#L-706"><span class="linenos"> 706</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ANY</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()),</span> +</span><span id="L-707"><a href="#L-707"><span class="linenos"> 707</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">CASE</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_case</span><span class="p">(),</span> +</span><span id="L-708"><a href="#L-708"><span class="linenos"> 708</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">IF</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_if</span><span class="p">(),</span> +</span><span id="L-709"><a href="#L-709"><span class="linenos"> 709</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEXT_VALUE_FOR</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">expression</span><span class="p">(</span> +</span><span id="L-710"><a href="#L-710"><span class="linenos"> 710</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NextValueFor</span><span class="p">,</span> +</span><span id="L-711"><a href="#L-711"><span class="linenos"> 711</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">(),</span> +</span><span id="L-712"><a href="#L-712"><span class="linenos"> 712</span></a> <span class="n">order</span><span class="o">=</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">OVER</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">),</span> +</span><span id="L-713"><a href="#L-713"><span class="linenos"> 713</span></a> <span class="p">),</span> +</span><span id="L-714"><a href="#L-714"><span class="linenos"> 714</span></a> <span class="p">}</span> +</span><span id="L-715"><a href="#L-715"><span class="linenos"> 715</span></a> +</span><span id="L-716"><a href="#L-716"><span class="linenos"> 716</span></a> <span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"STRUCT"</span><span class="p">}</span> +</span><span id="L-717"><a href="#L-717"><span class="linenos"> 717</span></a> +</span><span id="L-718"><a href="#L-718"><span class="linenos"> 718</span></a> <span class="n">FUNCTION_PARSERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-719"><a href="#L-719"><span class="linenos"> 719</span></a> <span class="s2">"CAST"</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_cast</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STRICT_CAST</span><span class="p">),</span> +</span><span id="L-720"><a href="#L-720"><span class="linenos"> 720</span></a> <span class="s2">"CONCAT"</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_concat</span><span class="p">(),</span> +</span><span id="L-721"><a href="#L-721"><span class="linenos"> 721</span></a> <span class="s2">"CONVERT"</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_convert</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STRICT_CAST</span><span class="p">),</span> +</span><span id="L-722"><a href="#L-722"><span class="linenos"> 722</span></a> <span class="s2">"DECODE"</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_decode</span><span class="p">(),</span> +</span><span id="L-723"><a href="#L-723"><span class="linenos"> 723</span></a> <span class="s2">"EXTRACT"</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_extract</span><span class="p">(),</span> +</span><span id="L-724"><a href="#L-724"><span class="linenos"> 724</span></a> <span class="s2">"JSON_OBJECT"</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_json_object</span><span class="p">(),</span> +</span><span id="L-725"><a href="#L-725"><span class="linenos"> 725</span></a> <span class="s2">"LOG"</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_logarithm</span><span class="p">(),</span> +</span><span id="L-726"><a href="#L-726"><span class="linenos"> 726</span></a> <span class="s2">"MATCH"</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_match_against</span><span class="p">(),</span> +</span><span id="L-727"><a href="#L-727"><span class="linenos"> 727</span></a> <span class="s2">"OPENJSON"</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_open_json</span><span class="p">(),</span> +</span><span id="L-728"><a href="#L-728"><span class="linenos"> 728</span></a> <span class="s2">"POSITION"</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_position</span><span class="p">(),</span> +</span><span id="L-729"><a href="#L-729"><span class="linenos"> 729</span></a> <span class="s2">"SAFE_CAST"</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_cast</span><span class="p">(</span><span class="kc">False</span><span class="p">),</span> +</span><span id="L-730"><a href="#L-730"><span class="linenos"> 730</span></a> <span class="s2">"STRING_AGG"</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_string_agg</span><span class="p">(),</span> +</span><span id="L-731"><a href="#L-731"><span class="linenos"> 731</span></a> <span class="s2">"SUBSTRING"</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_substring</span><span class="p">(),</span> +</span><span id="L-732"><a href="#L-732"><span class="linenos"> 732</span></a> <span class="s2">"TRIM"</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_trim</span><span class="p">(),</span> +</span><span id="L-733"><a href="#L-733"><span class="linenos"> 733</span></a> <span class="s2">"TRY_CAST"</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_cast</span><span class="p">(</span><span class="kc">False</span><span class="p">),</span> +</span><span id="L-734"><a href="#L-734"><span class="linenos"> 734</span></a> <span class="s2">"TRY_CONVERT"</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_convert</span><span class="p">(</span><span class="kc">False</span><span class="p">),</span> +</span><span id="L-735"><a href="#L-735"><span class="linenos"> 735</span></a> <span class="p">}</span> +</span><span id="L-736"><a href="#L-736"><span class="linenos"> 736</span></a> +</span><span id="L-737"><a href="#L-737"><span class="linenos"> 737</span></a> <span class="n">QUERY_MODIFIER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-738"><a href="#L-738"><span class="linenos"> 738</span></a> <span class="s2">"joins"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="nb">list</span><span class="p">(</span><span class="nb">iter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_join</span><span class="p">,</span> <span class="kc">None</span><span class="p">)),</span> +</span><span id="L-739"><a href="#L-739"><span class="linenos"> 739</span></a> <span class="s2">"laterals"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="nb">list</span><span class="p">(</span><span class="nb">iter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_lateral</span><span class="p">,</span> <span class="kc">None</span><span class="p">)),</span> +</span><span id="L-740"><a href="#L-740"><span class="linenos"> 740</span></a> <span class="s2">"match"</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_match_recognize</span><span class="p">(),</span> +</span><span id="L-741"><a href="#L-741"><span class="linenos"> 741</span></a> <span class="s2">"where"</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_where</span><span class="p">(),</span> +</span><span id="L-742"><a href="#L-742"><span class="linenos"> 742</span></a> <span class="s2">"group"</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_group</span><span class="p">(),</span> +</span><span id="L-743"><a href="#L-743"><span class="linenos"> 743</span></a> <span class="s2">"having"</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_having</span><span class="p">(),</span> +</span><span id="L-744"><a href="#L-744"><span class="linenos"> 744</span></a> <span class="s2">"qualify"</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_qualify</span><span class="p">(),</span> +</span><span id="L-745"><a href="#L-745"><span class="linenos"> 745</span></a> <span class="s2">"windows"</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_window_clause</span><span class="p">(),</span> +</span><span id="L-746"><a href="#L-746"><span class="linenos"> 746</span></a> <span class="s2">"order"</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_order</span><span class="p">(),</span> +</span><span id="L-747"><a href="#L-747"><span class="linenos"> 747</span></a> <span class="s2">"limit"</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_limit</span><span class="p">(),</span> +</span><span id="L-748"><a href="#L-748"><span class="linenos"> 748</span></a> <span class="s2">"offset"</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_offset</span><span class="p">(),</span> +</span><span id="L-749"><a href="#L-749"><span class="linenos"> 749</span></a> <span class="s2">"locks"</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_locks</span><span class="p">(),</span> +</span><span id="L-750"><a href="#L-750"><span class="linenos"> 750</span></a> <span class="s2">"sample"</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_table_sample</span><span class="p">(</span><span class="n">as_modifier</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="L-751"><a href="#L-751"><span class="linenos"> 751</span></a> <span class="p">}</span> +</span><span id="L-752"><a href="#L-752"><span class="linenos"> 752</span></a> +</span><span id="L-753"><a href="#L-753"><span class="linenos"> 753</span></a> <span class="n">SET_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-754"><a href="#L-754"><span class="linenos"> 754</span></a> <span class="s2">"GLOBAL"</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_set_item_assignment</span><span class="p">(</span><span class="s2">"GLOBAL"</span><span class="p">),</span> +</span><span id="L-755"><a href="#L-755"><span class="linenos"> 755</span></a> <span class="s2">"LOCAL"</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_set_item_assignment</span><span class="p">(</span><span class="s2">"LOCAL"</span><span class="p">),</span> +</span><span id="L-756"><a href="#L-756"><span class="linenos"> 756</span></a> <span class="s2">"SESSION"</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_set_item_assignment</span><span class="p">(</span><span class="s2">"SESSION"</span><span class="p">),</span> +</span><span id="L-757"><a href="#L-757"><span class="linenos"> 757</span></a> <span class="s2">"TRANSACTION"</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_set_transaction</span><span class="p">(),</span> +</span><span id="L-758"><a href="#L-758"><span class="linenos"> 758</span></a> <span class="p">}</span> +</span><span id="L-759"><a href="#L-759"><span class="linenos"> 759</span></a> +</span><span id="L-760"><a href="#L-760"><span class="linenos"> 760</span></a> <span class="n">SHOW_PARSERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><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">TYPE_LITERAL_PARSERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><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="n">MODIFIABLES</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> +</span><span id="L-765"><a href="#L-765"><span class="linenos"> 765</span></a> +</span><span id="L-766"><a href="#L-766"><span class="linenos"> 766</span></a> <span class="n">DDL_SELECT_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SELECT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">}</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="n">PRE_VOLATILE_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">CREATE</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNIQUE</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="n">TRANSACTION_KIND</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"DEFERRED"</span><span class="p">,</span> <span class="s2">"IMMEDIATE"</span><span class="p">,</span> <span class="s2">"EXCLUSIVE"</span><span class="p">}</span> +</span><span id="L-771"><a href="#L-771"><span class="linenos"> 771</span></a> <span class="n">TRANSACTION_CHARACTERISTICS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-772"><a href="#L-772"><span class="linenos"> 772</span></a> <span class="s2">"ISOLATION LEVEL REPEATABLE READ"</span><span class="p">,</span> +</span><span id="L-773"><a href="#L-773"><span class="linenos"> 773</span></a> <span class="s2">"ISOLATION LEVEL READ COMMITTED"</span><span class="p">,</span> +</span><span id="L-774"><a href="#L-774"><span class="linenos"> 774</span></a> <span class="s2">"ISOLATION LEVEL READ UNCOMMITTED"</span><span class="p">,</span> +</span><span id="L-775"><a href="#L-775"><span class="linenos"> 775</span></a> <span class="s2">"ISOLATION LEVEL SERIALIZABLE"</span><span class="p">,</span> +</span><span id="L-776"><a href="#L-776"><span class="linenos"> 776</span></a> <span class="s2">"READ WRITE"</span><span class="p">,</span> +</span><span id="L-777"><a href="#L-777"><span class="linenos"> 777</span></a> <span class="s2">"READ ONLY"</span><span class="p">,</span> +</span><span id="L-778"><a href="#L-778"><span class="linenos"> 778</span></a> <span class="p">}</span> +</span><span id="L-779"><a href="#L-779"><span class="linenos"> 779</span></a> +</span><span id="L-780"><a href="#L-780"><span class="linenos"> 780</span></a> <span class="n">INSERT_ALTERNATIVES</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"ABORT"</span><span class="p">,</span> <span class="s2">"FAIL"</span><span class="p">,</span> <span class="s2">"IGNORE"</span><span class="p">,</span> <span class="s2">"REPLACE"</span><span class="p">,</span> <span class="s2">"ROLLBACK"</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">CLONE_KINDS</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"OFFSET"</span><span class="p">,</span> <span class="s2">"STATEMENT"</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="n">WINDOW_ALIAS_TOKENS</span> <span class="o">=</span> <span class="n">ID_VAR_TOKENS</span> <span class="o">-</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">}</span> +</span><span id="L-785"><a href="#L-785"><span class="linenos"> 785</span></a> <span class="n">WINDOW_BEFORE_PAREN_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">OVER</span><span class="p">}</span> +</span><span id="L-786"><a href="#L-786"><span class="linenos"> 786</span></a> <span class="n">WINDOW_SIDES</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"FOLLOWING"</span><span class="p">,</span> <span class="s2">"PRECEDING"</span><span class="p">}</span> +</span><span id="L-787"><a href="#L-787"><span class="linenos"> 787</span></a> +</span><span id="L-788"><a href="#L-788"><span class="linenos"> 788</span></a> <span class="n">ADD_CONSTRAINT_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">CONSTRAINT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PRIMARY_KEY</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FOREIGN_KEY</span><span class="p">}</span> +</span><span id="L-789"><a href="#L-789"><span class="linenos"> 789</span></a> +</span><span id="L-790"><a href="#L-790"><span class="linenos"> 790</span></a> <span class="n">STRICT_CAST</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-791"><a href="#L-791"><span class="linenos"> 791</span></a> +</span><span id="L-792"><a href="#L-792"><span class="linenos"> 792</span></a> <span class="n">CONCAT_NULL_OUTPUTS_STRING</span> <span class="o">=</span> <span class="kc">False</span> <span class="c1"># A NULL arg in CONCAT yields NULL by default</span> +</span><span id="L-793"><a href="#L-793"><span class="linenos"> 793</span></a> +</span><span id="L-794"><a href="#L-794"><span class="linenos"> 794</span></a> <span class="n">CONVERT_TYPE_FIRST</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-795"><a href="#L-795"><span class="linenos"> 795</span></a> +</span><span id="L-796"><a href="#L-796"><span class="linenos"> 796</span></a> <span class="n">PREFIXED_PIVOT_COLUMNS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-797"><a href="#L-797"><span class="linenos"> 797</span></a> <span class="n">IDENTIFY_PIVOT_STRINGS</span> <span class="o">=</span> <span class="kc">False</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="n">LOG_BASE_FIRST</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-800"><a href="#L-800"><span class="linenos"> 800</span></a> <span class="n">LOG_DEFAULTS_TO_LN</span> <span class="o">=</span> <span class="kc">False</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="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-803"><a href="#L-803"><span class="linenos"> 803</span></a> <span class="s2">"error_level"</span><span class="p">,</span> +</span><span id="L-804"><a href="#L-804"><span class="linenos"> 804</span></a> <span class="s2">"error_message_context"</span><span class="p">,</span> +</span><span id="L-805"><a href="#L-805"><span class="linenos"> 805</span></a> <span class="s2">"max_errors"</span><span class="p">,</span> +</span><span id="L-806"><a href="#L-806"><span class="linenos"> 806</span></a> <span class="s2">"sql"</span><span class="p">,</span> +</span><span id="L-807"><a href="#L-807"><span class="linenos"> 807</span></a> <span class="s2">"errors"</span><span class="p">,</span> +</span><span id="L-808"><a href="#L-808"><span class="linenos"> 808</span></a> <span class="s2">"_tokens"</span><span class="p">,</span> +</span><span id="L-809"><a href="#L-809"><span class="linenos"> 809</span></a> <span class="s2">"_index"</span><span class="p">,</span> +</span><span id="L-810"><a href="#L-810"><span class="linenos"> 810</span></a> <span class="s2">"_curr"</span><span class="p">,</span> +</span><span id="L-811"><a href="#L-811"><span class="linenos"> 811</span></a> <span class="s2">"_next"</span><span class="p">,</span> +</span><span id="L-812"><a href="#L-812"><span class="linenos"> 812</span></a> <span class="s2">"_prev"</span><span class="p">,</span> +</span><span id="L-813"><a href="#L-813"><span class="linenos"> 813</span></a> <span class="s2">"_prev_comments"</span><span class="p">,</span> +</span><span id="L-814"><a href="#L-814"><span class="linenos"> 814</span></a> <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="c1"># Autofilled</span> +</span><span id="L-817"><a href="#L-817"><span class="linenos"> 817</span></a> <span class="n">INDEX_OFFSET</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="L-818"><a href="#L-818"><span class="linenos"> 818</span></a> <span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-819"><a href="#L-819"><span class="linenos"> 819</span></a> <span class="n">ALIAS_POST_TABLESAMPLE</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-820"><a href="#L-820"><span class="linenos"> 820</span></a> <span class="n">STRICT_STRING_CONCAT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-821"><a href="#L-821"><span class="linenos"> 821</span></a> <span class="n">NULL_ORDERING</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"nulls_are_small"</span> +</span><span id="L-822"><a href="#L-822"><span class="linenos"> 822</span></a> <span class="n">SHOW_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-823"><a href="#L-823"><span class="linenos"> 823</span></a> <span class="n">SET_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-824"><a href="#L-824"><span class="linenos"> 824</span></a> <span class="n">FORMAT_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-825"><a href="#L-825"><span class="linenos"> 825</span></a> <span class="n">FORMAT_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-826"><a href="#L-826"><span class="linenos"> 826</span></a> <span class="n">TIME_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-827"><a href="#L-827"><span class="linenos"> 827</span></a> <span class="n">TIME_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</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">def</span> <span class="fm">__init__</span><span class="p">(</span> +</span><span id="L-830"><a href="#L-830"><span class="linenos"> 830</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-831"><a href="#L-831"><span class="linenos"> 831</span></a> <span class="n">error_level</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">ErrorLevel</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-832"><a href="#L-832"><span class="linenos"> 832</span></a> <span class="n">error_message_context</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">100</span><span class="p">,</span> +</span><span id="L-833"><a href="#L-833"><span class="linenos"> 833</span></a> <span class="n">max_errors</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> +</span><span id="L-834"><a href="#L-834"><span class="linenos"> 834</span></a> <span class="p">):</span> +</span><span id="L-835"><a href="#L-835"><span class="linenos"> 835</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">=</span> <span class="n">error_level</span> <span class="ow">or</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span> +</span><span id="L-836"><a href="#L-836"><span class="linenos"> 836</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">error_message_context</span> <span class="o">=</span> <span class="n">error_message_context</span> +</span><span id="L-837"><a href="#L-837"><span class="linenos"> 837</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_errors</span> <span class="o">=</span> <span class="n">max_errors</span> +</span><span id="L-838"><a href="#L-838"><span class="linenos"> 838</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> +</span><span id="L-839"><a href="#L-839"><span class="linenos"> 839</span></a> +</span><span id="L-840"><a href="#L-840"><span class="linenos"> 840</span></a> <span class="k">def</span> <span class="nf">reset</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="L-841"><a href="#L-841"><span class="linenos"> 841</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-842"><a href="#L-842"><span class="linenos"> 842</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-843"><a href="#L-843"><span class="linenos"> 843</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-844"><a href="#L-844"><span class="linenos"> 844</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="L-845"><a href="#L-845"><span class="linenos"> 845</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-846"><a href="#L-846"><span class="linenos"> 846</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-847"><a href="#L-847"><span class="linenos"> 847</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-848"><a href="#L-848"><span class="linenos"> 848</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-849"><a href="#L-849"><span class="linenos"> 849</span></a> +</span><span id="L-850"><a href="#L-850"><span class="linenos"> 850</span></a> <span class="k">def</span> <span class="nf">parse</span><span class="p">(</span> +</span><span id="L-851"><a href="#L-851"><span class="linenos"> 851</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">raw_tokens</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">Token</span><span class="p">],</span> <span class="n">sql</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><span id="L-852"><a href="#L-852"><span class="linenos"> 852</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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-853"><a href="#L-853"><span class="linenos"> 853</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-854"><a href="#L-854"><span class="linenos"> 854</span></a><span class="sd"> Parses a list of tokens and returns a list of syntax trees, one tree</span> +</span><span id="L-855"><a href="#L-855"><span class="linenos"> 855</span></a><span class="sd"> per parsed SQL statement.</span> +</span><span id="L-856"><a href="#L-856"><span class="linenos"> 856</span></a> +</span><span id="L-857"><a href="#L-857"><span class="linenos"> 857</span></a><span class="sd"> Args:</span> +</span><span id="L-858"><a href="#L-858"><span class="linenos"> 858</span></a><span class="sd"> raw_tokens: The list of tokens.</span> +</span><span id="L-859"><a href="#L-859"><span class="linenos"> 859</span></a><span class="sd"> sql: The original SQL string, used to produce helpful debug messages.</span> +</span><span id="L-860"><a href="#L-860"><span class="linenos"> 860</span></a> +</span><span id="L-861"><a href="#L-861"><span class="linenos"> 861</span></a><span class="sd"> Returns:</span> +</span><span id="L-862"><a href="#L-862"><span class="linenos"> 862</span></a><span class="sd"> The list of the produced syntax trees.</span> +</span><span id="L-863"><a href="#L-863"><span class="linenos"> 863</span></a><span class="sd"> """</span> +</span><span id="L-864"><a href="#L-864"><span class="linenos"> 864</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse</span><span class="p">(</span> +</span><span id="L-865"><a href="#L-865"><span class="linenos"> 865</span></a> <span class="n">parse_method</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">,</span> <span class="n">raw_tokens</span><span class="o">=</span><span class="n">raw_tokens</span><span class="p">,</span> <span class="n">sql</span><span class="o">=</span><span class="n">sql</span> +</span><span id="L-866"><a href="#L-866"><span class="linenos"> 866</span></a> <span class="p">)</span> +</span><span id="L-867"><a href="#L-867"><span class="linenos"> 867</span></a> +</span><span id="L-868"><a href="#L-868"><span class="linenos"> 868</span></a> <span class="k">def</span> <span class="nf">parse_into</span><span class="p">(</span> +</span><span id="L-869"><a href="#L-869"><span class="linenos"> 869</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-870"><a href="#L-870"><span class="linenos"> 870</span></a> <span class="n">expression_types</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IntoType</span><span class="p">,</span> +</span><span id="L-871"><a href="#L-871"><span class="linenos"> 871</span></a> <span class="n">raw_tokens</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">Token</span><span class="p">],</span> +</span><span id="L-872"><a href="#L-872"><span class="linenos"> 872</span></a> <span class="n">sql</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-873"><a href="#L-873"><span class="linenos"> 873</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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-874"><a href="#L-874"><span class="linenos"> 874</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-875"><a href="#L-875"><span class="linenos"> 875</span></a><span class="sd"> Parses a list of tokens into a given Expression type. If a collection of Expression</span> +</span><span id="L-876"><a href="#L-876"><span class="linenos"> 876</span></a><span class="sd"> types is given instead, this method will try to parse the token list into each one</span> +</span><span id="L-877"><a href="#L-877"><span class="linenos"> 877</span></a><span class="sd"> of them, stopping at the first for which the parsing succeeds.</span> +</span><span id="L-878"><a href="#L-878"><span class="linenos"> 878</span></a> +</span><span id="L-879"><a href="#L-879"><span class="linenos"> 879</span></a><span class="sd"> Args:</span> +</span><span id="L-880"><a href="#L-880"><span class="linenos"> 880</span></a><span class="sd"> expression_types: The expression type(s) to try and parse the token list into.</span> +</span><span id="L-881"><a href="#L-881"><span class="linenos"> 881</span></a><span class="sd"> raw_tokens: The list of tokens.</span> +</span><span id="L-882"><a href="#L-882"><span class="linenos"> 882</span></a><span class="sd"> sql: The original SQL string, used to produce helpful debug messages.</span> +</span><span id="L-883"><a href="#L-883"><span class="linenos"> 883</span></a> +</span><span id="L-884"><a href="#L-884"><span class="linenos"> 884</span></a><span class="sd"> Returns:</span> +</span><span id="L-885"><a href="#L-885"><span class="linenos"> 885</span></a><span class="sd"> The target Expression.</span> +</span><span id="L-886"><a href="#L-886"><span class="linenos"> 886</span></a><span class="sd"> """</span> +</span><span id="L-887"><a href="#L-887"><span class="linenos"> 887</span></a> <span class="n">errors</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-888"><a href="#L-888"><span class="linenos"> 888</span></a> <span class="k">for</span> <span class="n">expression_type</span> <span class="ow">in</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">expression_types</span><span class="p">):</span> +</span><span id="L-889"><a href="#L-889"><span class="linenos"> 889</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPRESSION_PARSERS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression_type</span><span class="p">)</span> +</span><span id="L-890"><a href="#L-890"><span class="linenos"> 890</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">parser</span><span class="p">:</span> +</span><span id="L-891"><a href="#L-891"><span class="linenos"> 891</span></a> <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"No parser registered for </span><span class="si">{</span><span class="n">expression_type</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-892"><a href="#L-892"><span class="linenos"> 892</span></a> +</span><span id="L-893"><a href="#L-893"><span class="linenos"> 893</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="L-894"><a href="#L-894"><span class="linenos"> 894</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse</span><span class="p">(</span><span class="n">parser</span><span class="p">,</span> <span class="n">raw_tokens</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="L-895"><a href="#L-895"><span class="linenos"> 895</span></a> <span class="k">except</span> <span class="n">ParseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> +</span><span id="L-896"><a href="#L-896"><span class="linenos"> 896</span></a> <span class="n">e</span><span class="o">.</span><span class="n">errors</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s2">"into_expression"</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression_type</span> +</span><span id="L-897"><a href="#L-897"><span class="linenos"> 897</span></a> <span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> +</span><span id="L-898"><a href="#L-898"><span class="linenos"> 898</span></a> +</span><span id="L-899"><a href="#L-899"><span class="linenos"> 899</span></a> <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span> +</span><span id="L-900"><a href="#L-900"><span class="linenos"> 900</span></a> <span class="sa">f</span><span class="s2">"Failed to parse '</span><span class="si">{</span><span class="n">sql</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="n">raw_tokens</span><span class="si">}</span><span class="s2">' into </span><span class="si">{</span><span class="n">expression_types</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-901"><a href="#L-901"><span class="linenos"> 901</span></a> <span class="n">errors</span><span class="o">=</span><span class="n">merge_errors</span><span class="p">(</span><span class="n">errors</span><span class="p">),</span> +</span><span id="L-902"><a href="#L-902"><span class="linenos"> 902</span></a> <span class="p">)</span> <span class="kn">from</span> <span class="nn">errors</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> +</span><span id="L-903"><a href="#L-903"><span class="linenos"> 903</span></a> +</span><span id="L-904"><a href="#L-904"><span class="linenos"> 904</span></a> <span class="k">def</span> <span class="nf">_parse</span><span class="p">(</span> +</span><span id="L-905"><a href="#L-905"><span class="linenos"> 905</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-906"><a href="#L-906"><span class="linenos"> 906</span></a> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Parser</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><span id="L-907"><a href="#L-907"><span class="linenos"> 907</span></a> <span class="n">raw_tokens</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">Token</span><span class="p">],</span> +</span><span id="L-908"><a href="#L-908"><span class="linenos"> 908</span></a> <span class="n">sql</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-909"><a href="#L-909"><span class="linenos"> 909</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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-910"><a href="#L-910"><span class="linenos"> 910</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> +</span><span id="L-911"><a href="#L-911"><span class="linenos"> 911</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span> <span class="ow">or</span> <span class="s2">""</span> +</span><span id="L-912"><a href="#L-912"><span class="linenos"> 912</span></a> +</span><span id="L-913"><a href="#L-913"><span class="linenos"> 913</span></a> <span class="n">total</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">raw_tokens</span><span class="p">)</span> +</span><span id="L-914"><a href="#L-914"><span class="linenos"> 914</span></a> <span class="n">chunks</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">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Token</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[[]]</span> +</span><span id="L-915"><a href="#L-915"><span class="linenos"> 915</span></a> +</span><span id="L-916"><a href="#L-916"><span class="linenos"> 916</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">token</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">raw_tokens</span><span class="p">):</span> +</span><span id="L-917"><a href="#L-917"><span class="linenos"> 917</span></a> <span class="k">if</span> <span class="n">token</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SEMICOLON</span><span class="p">:</span> +</span><span id="L-918"><a href="#L-918"><span class="linenos"> 918</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o"><</span> <span class="n">total</span> <span class="o">-</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-919"><a href="#L-919"><span class="linenos"> 919</span></a> <span class="n">chunks</span><span class="o">.</span><span class="n">append</span><span class="p">([])</span> +</span><span id="L-920"><a href="#L-920"><span class="linenos"> 920</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-921"><a href="#L-921"><span class="linenos"> 921</span></a> <span class="n">chunks</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">token</span><span class="p">)</span> +</span><span id="L-922"><a href="#L-922"><span class="linenos"> 922</span></a> +</span><span id="L-923"><a href="#L-923"><span class="linenos"> 923</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-924"><a href="#L-924"><span class="linenos"> 924</span></a> +</span><span id="L-925"><a href="#L-925"><span class="linenos"> 925</span></a> <span class="k">for</span> <span class="n">tokens</span> <span class="ow">in</span> <span class="n">chunks</span><span class="p">:</span> +</span><span id="L-926"><a href="#L-926"><span class="linenos"> 926</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span> +</span><span id="L-927"><a href="#L-927"><span class="linenos"> 927</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span> <span class="o">=</span> <span class="n">tokens</span> +</span><span id="L-928"><a href="#L-928"><span class="linenos"> 928</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-929"><a href="#L-929"><span class="linenos"> 929</span></a> +</span><span id="L-930"><a href="#L-930"><span class="linenos"> 930</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">parse_method</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span> +</span><span id="L-931"><a href="#L-931"><span class="linenos"> 931</span></a> +</span><span id="L-932"><a href="#L-932"><span class="linenos"> 932</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o"><</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">):</span> +</span><span id="L-933"><a href="#L-933"><span class="linenos"> 933</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Invalid expression / Unexpected token"</span><span class="p">)</span> +</span><span id="L-934"><a href="#L-934"><span class="linenos"> 934</span></a> +</span><span id="L-935"><a href="#L-935"><span class="linenos"> 935</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">check_errors</span><span class="p">()</span> +</span><span id="L-936"><a href="#L-936"><span class="linenos"> 936</span></a> +</span><span id="L-937"><a href="#L-937"><span class="linenos"> 937</span></a> <span class="k">return</span> <span class="n">expressions</span> +</span><span id="L-938"><a href="#L-938"><span class="linenos"> 938</span></a> +</span><span id="L-939"><a href="#L-939"><span class="linenos"> 939</span></a> <span class="k">def</span> <span class="nf">check_errors</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-940"><a href="#L-940"><span class="linenos"> 940</span></a><span class="w"> </span><span class="sd">"""Logs or raises any found errors, depending on the chosen error level setting."""</span> +</span><span id="L-941"><a href="#L-941"><span class="linenos"> 941</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">:</span> +</span><span id="L-942"><a href="#L-942"><span class="linenos"> 942</span></a> <span class="k">for</span> <span class="n">error</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">:</span> +</span><span id="L-943"><a href="#L-943"><span class="linenos"> 943</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">error</span><span class="p">))</span> +</span><span id="L-944"><a href="#L-944"><span class="linenos"> 944</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">RAISE</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">:</span> +</span><span id="L-945"><a href="#L-945"><span class="linenos"> 945</span></a> <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span> +</span><span id="L-946"><a href="#L-946"><span class="linenos"> 946</span></a> <span class="n">concat_messages</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_errors</span><span class="p">),</span> +</span><span id="L-947"><a href="#L-947"><span class="linenos"> 947</span></a> <span class="n">errors</span><span class="o">=</span><span class="n">merge_errors</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">),</span> +</span><span id="L-948"><a href="#L-948"><span class="linenos"> 948</span></a> <span class="p">)</span> +</span><span id="L-949"><a href="#L-949"><span class="linenos"> 949</span></a> +</span><span id="L-950"><a href="#L-950"><span class="linenos"> 950</span></a> <span class="k">def</span> <span class="nf">raise_error</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">token</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">Token</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-951"><a href="#L-951"><span class="linenos"> 951</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-952"><a href="#L-952"><span class="linenos"> 952</span></a><span class="sd"> Appends an error in the list of recorded errors or raises it, depending on the chosen</span> +</span><span id="L-953"><a href="#L-953"><span class="linenos"> 953</span></a><span class="sd"> error level setting.</span> +</span><span id="L-954"><a href="#L-954"><span class="linenos"> 954</span></a><span class="sd"> """</span> +</span><span id="L-955"><a href="#L-955"><span class="linenos"> 955</span></a> <span class="n">token</span> <span class="o">=</span> <span class="n">token</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="ow">or</span> <span class="n">Token</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">)</span> +</span><span id="L-956"><a href="#L-956"><span class="linenos"> 956</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">token</span><span class="o">.</span><span class="n">start</span> +</span><span id="L-957"><a href="#L-957"><span class="linenos"> 957</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">token</span><span class="o">.</span><span class="n">end</span> <span class="o">+</span> <span class="mi">1</span> +</span><span id="L-958"><a href="#L-958"><span class="linenos"> 958</span></a> <span class="n">start_context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="nb">max</span><span class="p">(</span><span class="n">start</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_message_context</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="p">:</span> <span class="n">start</span><span class="p">]</span> +</span><span id="L-959"><a href="#L-959"><span class="linenos"> 959</span></a> <span class="n">highlight</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">start</span><span class="p">:</span><span class="n">end</span><span class="p">]</span> +</span><span id="L-960"><a href="#L-960"><span class="linenos"> 960</span></a> <span class="n">end_context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">end</span> <span class="p">:</span> <span class="n">end</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_message_context</span><span class="p">]</span> +</span><span id="L-961"><a href="#L-961"><span class="linenos"> 961</span></a> +</span><span id="L-962"><a href="#L-962"><span class="linenos"> 962</span></a> <span class="n">error</span> <span class="o">=</span> <span class="n">ParseError</span><span class="o">.</span><span class="n">new</span><span class="p">(</span> +</span><span id="L-963"><a href="#L-963"><span class="linenos"> 963</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">message</span><span class="si">}</span><span class="s2">. Line </span><span class="si">{</span><span class="n">token</span><span class="o">.</span><span class="n">line</span><span class="si">}</span><span class="s2">, Col: </span><span class="si">{</span><span class="n">token</span><span class="o">.</span><span class="n">col</span><span class="si">}</span><span class="s2">.</span><span class="se">\n</span><span class="s2">"</span> +</span><span id="L-964"><a href="#L-964"><span class="linenos"> 964</span></a> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">start_context</span><span class="si">}</span><span class="se">\033</span><span class="s2">[4m</span><span class="si">{</span><span class="n">highlight</span><span class="si">}</span><span class="se">\033</span><span class="s2">[0m</span><span class="si">{</span><span class="n">end_context</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="L-965"><a href="#L-965"><span class="linenos"> 965</span></a> <span class="n">description</span><span class="o">=</span><span class="n">message</span><span class="p">,</span> +</span><span id="L-966"><a href="#L-966"><span class="linenos"> 966</span></a> <span class="n">line</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">line</span><span class="p">,</span> +</span><span id="L-967"><a href="#L-967"><span class="linenos"> 967</span></a> <span class="n">col</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">col</span><span class="p">,</span> +</span><span id="L-968"><a href="#L-968"><span class="linenos"> 968</span></a> <span class="n">start_context</span><span class="o">=</span><span class="n">start_context</span><span class="p">,</span> +</span><span id="L-969"><a href="#L-969"><span class="linenos"> 969</span></a> <span class="n">highlight</span><span class="o">=</span><span class="n">highlight</span><span class="p">,</span> +</span><span id="L-970"><a href="#L-970"><span class="linenos"> 970</span></a> <span class="n">end_context</span><span class="o">=</span><span class="n">end_context</span><span class="p">,</span> +</span><span id="L-971"><a href="#L-971"><span class="linenos"> 971</span></a> <span class="p">)</span> +</span><span id="L-972"><a href="#L-972"><span class="linenos"> 972</span></a> +</span><span id="L-973"><a href="#L-973"><span class="linenos"> 973</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span><span class="p">:</span> +</span><span id="L-974"><a href="#L-974"><span class="linenos"> 974</span></a> <span class="k">raise</span> <span class="n">error</span> +</span><span id="L-975"><a href="#L-975"><span class="linenos"> 975</span></a> +</span><span id="L-976"><a href="#L-976"><span class="linenos"> 976</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">error</span><span class="p">)</span> +</span><span id="L-977"><a href="#L-977"><span class="linenos"> 977</span></a> +</span><span id="L-978"><a href="#L-978"><span class="linenos"> 978</span></a> <span class="k">def</span> <span class="nf">expression</span><span class="p">(</span> +</span><span id="L-979"><a href="#L-979"><span class="linenos"> 979</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> <span class="n">comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> +</span><span id="L-980"><a href="#L-980"><span class="linenos"> 980</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="L-981"><a href="#L-981"><span class="linenos"> 981</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-982"><a href="#L-982"><span class="linenos"> 982</span></a><span class="sd"> Creates a new, validated Expression.</span> +</span><span id="L-983"><a href="#L-983"><span class="linenos"> 983</span></a> +</span><span id="L-984"><a href="#L-984"><span class="linenos"> 984</span></a><span class="sd"> Args:</span> +</span><span id="L-985"><a href="#L-985"><span class="linenos"> 985</span></a><span class="sd"> exp_class: The expression class to instantiate.</span> +</span><span id="L-986"><a href="#L-986"><span class="linenos"> 986</span></a><span class="sd"> comments: An optional list of comments to attach to the expression.</span> +</span><span id="L-987"><a href="#L-987"><span class="linenos"> 987</span></a><span class="sd"> kwargs: The arguments to set for the expression along with their respective values.</span> +</span><span id="L-988"><a href="#L-988"><span class="linenos"> 988</span></a> +</span><span id="L-989"><a href="#L-989"><span class="linenos"> 989</span></a><span class="sd"> Returns:</span> +</span><span id="L-990"><a href="#L-990"><span class="linenos"> 990</span></a><span class="sd"> The target expression.</span> +</span><span id="L-991"><a href="#L-991"><span class="linenos"> 991</span></a><span class="sd"> """</span> +</span><span id="L-992"><a href="#L-992"><span class="linenos"> 992</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">exp_class</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="L-993"><a href="#L-993"><span class="linenos"> 993</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">add_comments</span><span class="p">(</span><span class="n">comments</span><span class="p">)</span> <span class="k">if</span> <span class="n">comments</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add_comments</span><span class="p">(</span><span class="n">instance</span><span class="p">)</span> +</span><span id="L-994"><a href="#L-994"><span class="linenos"> 994</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">instance</span><span class="p">)</span> +</span><span id="L-995"><a href="#L-995"><span class="linenos"> 995</span></a> +</span><span id="L-996"><a href="#L-996"><span class="linenos"> 996</span></a> <span class="k">def</span> <span class="nf">_add_comments</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-997"><a href="#L-997"><span class="linenos"> 997</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span><span class="p">:</span> +</span><span id="L-998"><a href="#L-998"><span class="linenos"> 998</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">add_comments</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span><span class="p">)</span> +</span><span id="L-999"><a href="#L-999"><span class="linenos"> 999</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1000"><a href="#L-1000"><span class="linenos">1000</span></a> +</span><span id="L-1001"><a href="#L-1001"><span class="linenos">1001</span></a> <span class="k">def</span> <span class="nf">validate_expression</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="L-1002"><a href="#L-1002"><span class="linenos">1002</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-1003"><a href="#L-1003"><span class="linenos">1003</span></a><span class="sd"> Validates an Expression, making sure that all its mandatory arguments are set.</span> +</span><span id="L-1004"><a href="#L-1004"><span class="linenos">1004</span></a> +</span><span id="L-1005"><a href="#L-1005"><span class="linenos">1005</span></a><span class="sd"> Args:</span> +</span><span id="L-1006"><a href="#L-1006"><span class="linenos">1006</span></a><span class="sd"> expression: The expression to validate.</span> +</span><span id="L-1007"><a href="#L-1007"><span class="linenos">1007</span></a><span class="sd"> args: An optional list of items that was used to instantiate the expression, if it's a Func.</span> +</span><span id="L-1008"><a href="#L-1008"><span class="linenos">1008</span></a> +</span><span id="L-1009"><a href="#L-1009"><span class="linenos">1009</span></a><span class="sd"> Returns:</span> +</span><span id="L-1010"><a href="#L-1010"><span class="linenos">1010</span></a><span class="sd"> The validated expression.</span> +</span><span id="L-1011"><a href="#L-1011"><span class="linenos">1011</span></a><span class="sd"> """</span> +</span><span id="L-1012"><a href="#L-1012"><span class="linenos">1012</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">!=</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IGNORE</span><span class="p">:</span> +</span><span id="L-1013"><a href="#L-1013"><span class="linenos">1013</span></a> <span class="k">for</span> <span class="n">error_message</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">error_messages</span><span class="p">(</span><span class="n">args</span><span class="p">):</span> +</span><span id="L-1014"><a href="#L-1014"><span class="linenos">1014</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="n">error_message</span><span class="p">)</span> +</span><span id="L-1015"><a href="#L-1015"><span class="linenos">1015</span></a> +</span><span id="L-1016"><a href="#L-1016"><span class="linenos">1016</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-1017"><a href="#L-1017"><span class="linenos">1017</span></a> +</span><span id="L-1018"><a href="#L-1018"><span class="linenos">1018</span></a> <span class="k">def</span> <span class="nf">_find_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">start</span><span class="p">:</span> <span class="n">Token</span><span class="p">,</span> <span class="n">end</span><span class="p">:</span> <span class="n">Token</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1019"><a href="#L-1019"><span class="linenos">1019</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">start</span><span class="o">.</span><span class="n">start</span> <span class="p">:</span> <span class="n">end</span><span class="o">.</span><span class="n">end</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span> +</span><span id="L-1020"><a href="#L-1020"><span class="linenos">1020</span></a> +</span><span id="L-1021"><a href="#L-1021"><span class="linenos">1021</span></a> <span class="k">def</span> <span class="nf">_advance</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">times</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-1022"><a href="#L-1022"><span class="linenos">1022</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">+=</span> <span class="n">times</span> +</span><span id="L-1023"><a href="#L-1023"><span class="linenos">1023</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span><span class="p">)</span> +</span><span id="L-1024"><a href="#L-1024"><span class="linenos">1024</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="L-1025"><a href="#L-1025"><span class="linenos">1025</span></a> +</span><span id="L-1026"><a href="#L-1026"><span class="linenos">1026</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> +</span><span id="L-1027"><a href="#L-1027"><span class="linenos">1027</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> +</span><span id="L-1028"><a href="#L-1028"><span class="linenos">1028</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</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">comments</span> +</span><span id="L-1029"><a href="#L-1029"><span class="linenos">1029</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1030"><a href="#L-1030"><span class="linenos">1030</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1031"><a href="#L-1031"><span class="linenos">1031</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1032"><a href="#L-1032"><span class="linenos">1032</span></a> +</span><span id="L-1033"><a href="#L-1033"><span class="linenos">1033</span></a> <span class="k">def</span> <span class="nf">_retreat</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">index</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-1034"><a href="#L-1034"><span class="linenos">1034</span></a> <span class="k">if</span> <span class="n">index</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span><span class="p">:</span> +</span><span id="L-1035"><a href="#L-1035"><span class="linenos">1035</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">index</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span><span class="p">)</span> +</span><span id="L-1036"><a href="#L-1036"><span class="linenos">1036</span></a> +</span><span id="L-1037"><a href="#L-1037"><span class="linenos">1037</span></a> <span class="k">def</span> <span class="nf">_parse_command</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">Command</span><span class="p">:</span> +</span><span id="L-1038"><a href="#L-1038"><span class="linenos">1038</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">Command</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 class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">())</span> +</span><span id="L-1039"><a href="#L-1039"><span class="linenos">1039</span></a> +</span><span id="L-1040"><a href="#L-1040"><span class="linenos">1040</span></a> <span class="k">def</span> <span class="nf">_parse_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">allow_exists</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="L-1041"><a href="#L-1041"><span class="linenos">1041</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> +</span><span id="L-1042"><a href="#L-1042"><span class="linenos">1042</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">()</span> <span class="k">if</span> <span class="n">allow_exists</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="L-1043"><a href="#L-1043"><span class="linenos">1043</span></a> +</span><span id="L-1044"><a href="#L-1044"><span class="linenos">1044</span></a> <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">ON</span><span class="p">)</span> +</span><span id="L-1045"><a href="#L-1045"><span class="linenos">1045</span></a> +</span><span id="L-1046"><a href="#L-1046"><span class="linenos">1046</span></a> <span class="n">kind</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> +</span><span id="L-1047"><a href="#L-1047"><span class="linenos">1047</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="L-1048"><a href="#L-1048"><span class="linenos">1048</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> +</span><span id="L-1049"><a href="#L-1049"><span class="linenos">1049</span></a> +</span><span id="L-1050"><a href="#L-1050"><span class="linenos">1050</span></a> <span class="k">if</span> <span class="n">kind</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FUNCTION</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PROCEDURE</span><span class="p">):</span> +</span><span id="L-1051"><a href="#L-1051"><span class="linenos">1051</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_user_defined_function</span><span class="p">(</span><span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="o">.</span><span class="n">token_type</span><span class="p">)</span> +</span><span id="L-1052"><a href="#L-1052"><span class="linenos">1052</span></a> <span class="k">elif</span> <span class="n">kind</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">:</span> +</span><span id="L-1053"><a href="#L-1053"><span class="linenos">1053</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">alias_tokens</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">COMMENT_TABLE_ALIAS_TOKENS</span><span class="p">)</span> +</span><span id="L-1054"><a href="#L-1054"><span class="linenos">1054</span></a> <span class="k">elif</span> <span class="n">kind</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLUMN</span><span class="p">:</span> +</span><span id="L-1055"><a href="#L-1055"><span class="linenos">1055</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> +</span><span id="L-1056"><a href="#L-1056"><span class="linenos">1056</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1057"><a href="#L-1057"><span class="linenos">1057</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="L-1058"><a href="#L-1058"><span class="linenos">1058</span></a> +</span><span id="L-1059"><a href="#L-1059"><span class="linenos">1059</span></a> <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">IS</span><span class="p">)</span> +</span><span id="L-1060"><a href="#L-1060"><span class="linenos">1060</span></a> +</span><span id="L-1061"><a href="#L-1061"><span class="linenos">1061</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-1062"><a href="#L-1062"><span class="linenos">1062</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Comment</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">(),</span> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span> +</span><span id="L-1063"><a href="#L-1063"><span class="linenos">1063</span></a> <span class="p">)</span> +</span><span id="L-1064"><a href="#L-1064"><span class="linenos">1064</span></a> +</span><span id="L-1065"><a href="#L-1065"><span class="linenos">1065</span></a> <span class="k">def</span> <span class="nf">_parse_to_table</span><span class="p">(</span> +</span><span id="L-1066"><a href="#L-1066"><span class="linenos">1066</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-1067"><a href="#L-1067"><span class="linenos">1067</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">ToTableProperty</span><span class="p">:</span> +</span><span id="L-1068"><a href="#L-1068"><span class="linenos">1068</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1069"><a href="#L-1069"><span class="linenos">1069</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">ToTableProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">)</span> +</span><span id="L-1070"><a href="#L-1070"><span class="linenos">1070</span></a> +</span><span id="L-1071"><a href="#L-1071"><span class="linenos">1071</span></a> <span class="c1"># https://clickhouse.com/docs/en/engines/table-engines/mergetree-family/mergetree#mergetree-table-ttl</span> +</span><span id="L-1072"><a href="#L-1072"><span class="linenos">1072</span></a> <span class="k">def</span> <span class="nf">_parse_ttl</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">Expression</span><span class="p">:</span> +</span><span id="L-1073"><a href="#L-1073"><span class="linenos">1073</span></a> <span class="k">def</span> <span class="nf">_parse_ttl_action</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-1074"><a href="#L-1074"><span class="linenos">1074</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="L-1075"><a href="#L-1075"><span class="linenos">1075</span></a> +</span><span id="L-1076"><a href="#L-1076"><span class="linenos">1076</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DELETE"</span><span class="p">):</span> +</span><span id="L-1077"><a href="#L-1077"><span class="linenos">1077</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">MergeTreeTTLAction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">delete</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1078"><a href="#L-1078"><span class="linenos">1078</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"RECOMPRESS"</span><span class="p">):</span> +</span><span id="L-1079"><a href="#L-1079"><span class="linenos">1079</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-1080"><a href="#L-1080"><span class="linenos">1080</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTLAction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">recompress</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="L-1081"><a href="#L-1081"><span class="linenos">1081</span></a> <span class="p">)</span> +</span><span id="L-1082"><a href="#L-1082"><span class="linenos">1082</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"DISK"</span><span class="p">):</span> +</span><span id="L-1083"><a href="#L-1083"><span class="linenos">1083</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><span id="L-1084"><a href="#L-1084"><span class="linenos">1084</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTLAction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to_disk</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="L-1085"><a href="#L-1085"><span class="linenos">1085</span></a> <span class="p">)</span> +</span><span id="L-1086"><a href="#L-1086"><span class="linenos">1086</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"VOLUME"</span><span class="p">):</span> +</span><span id="L-1087"><a href="#L-1087"><span class="linenos">1087</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-1088"><a href="#L-1088"><span class="linenos">1088</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTLAction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to_volume</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="L-1089"><a href="#L-1089"><span class="linenos">1089</span></a> <span class="p">)</span> +</span><span id="L-1090"><a href="#L-1090"><span class="linenos">1090</span></a> +</span><span id="L-1091"><a href="#L-1091"><span class="linenos">1091</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-1092"><a href="#L-1092"><span class="linenos">1092</span></a> +</span><span id="L-1093"><a href="#L-1093"><span class="linenos">1093</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">_parse_ttl_action</span><span class="p">)</span> +</span><span id="L-1094"><a href="#L-1094"><span class="linenos">1094</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">()</span> +</span><span id="L-1095"><a href="#L-1095"><span class="linenos">1095</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_group</span><span class="p">()</span> +</span><span id="L-1096"><a href="#L-1096"><span class="linenos">1096</span></a> +</span><span id="L-1097"><a href="#L-1097"><span class="linenos">1097</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1098"><a href="#L-1098"><span class="linenos">1098</span></a> <span class="k">if</span> <span class="n">group</span> <span class="ow">and</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">SET</span><span class="p">):</span> +</span><span id="L-1099"><a href="#L-1099"><span class="linenos">1099</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_item</span><span class="p">)</span> +</span><span id="L-1100"><a href="#L-1100"><span class="linenos">1100</span></a> +</span><span id="L-1101"><a href="#L-1101"><span class="linenos">1101</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-1102"><a href="#L-1102"><span class="linenos">1102</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">,</span> +</span><span id="L-1103"><a href="#L-1103"><span class="linenos">1103</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-1104"><a href="#L-1104"><span class="linenos">1104</span></a> <span class="n">where</span><span class="o">=</span><span class="n">where</span><span class="p">,</span> +</span><span id="L-1105"><a href="#L-1105"><span class="linenos">1105</span></a> <span class="n">group</span><span class="o">=</span><span class="n">group</span><span class="p">,</span> +</span><span id="L-1106"><a href="#L-1106"><span class="linenos">1106</span></a> <span class="n">aggregates</span><span class="o">=</span><span class="n">aggregates</span><span class="p">,</span> +</span><span id="L-1107"><a href="#L-1107"><span class="linenos">1107</span></a> <span class="p">)</span> +</span><span id="L-1108"><a href="#L-1108"><span class="linenos">1108</span></a> +</span><span id="L-1109"><a href="#L-1109"><span class="linenos">1109</span></a> <span class="k">def</span> <span class="nf">_parse_statement</span><span class="p">(</span><span class="bp">self</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-1110"><a href="#L-1110"><span class="linenos">1110</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-1111"><a href="#L-1111"><span class="linenos">1111</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1112"><a href="#L-1112"><span class="linenos">1112</span></a> +</span><span id="L-1113"><a href="#L-1113"><span class="linenos">1113</span></a> <span class="k">if</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">STATEMENT_PARSERS</span><span class="p">):</span> +</span><span id="L-1114"><a href="#L-1114"><span class="linenos">1114</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">STATEMENT_PARSERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> +</span><span id="L-1115"><a href="#L-1115"><span class="linenos">1115</span></a> +</span><span id="L-1116"><a href="#L-1116"><span class="linenos">1116</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">(</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">COMMANDS</span><span class="p">):</span> +</span><span id="L-1117"><a href="#L-1117"><span class="linenos">1117</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_command</span><span class="p">()</span> +</span><span id="L-1118"><a href="#L-1118"><span class="linenos">1118</span></a> +</span><span id="L-1119"><a href="#L-1119"><span class="linenos">1119</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">()</span> +</span><span id="L-1120"><a href="#L-1120"><span class="linenos">1120</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">()</span> +</span><span id="L-1121"><a href="#L-1121"><span class="linenos">1121</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-1122"><a href="#L-1122"><span class="linenos">1122</span></a> +</span><span id="L-1123"><a href="#L-1123"><span class="linenos">1123</span></a> <span class="k">def</span> <span class="nf">_parse_drop</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">Drop</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> +</span><span id="L-1124"><a href="#L-1124"><span class="linenos">1124</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> +</span><span id="L-1125"><a href="#L-1125"><span class="linenos">1125</span></a> <span class="n">temporary</span> <span class="o">=</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">TEMPORARY</span><span class="p">)</span> +</span><span id="L-1126"><a href="#L-1126"><span class="linenos">1126</span></a> <span class="n">materialized</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MATERIALIZED"</span><span class="p">)</span> +</span><span id="L-1127"><a href="#L-1127"><span class="linenos">1127</span></a> +</span><span id="L-1128"><a href="#L-1128"><span class="linenos">1128</span></a> <span class="n">kind</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</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><span id="L-1129"><a href="#L-1129"><span class="linenos">1129</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="L-1130"><a href="#L-1130"><span class="linenos">1130</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> +</span><span id="L-1131"><a href="#L-1131"><span class="linenos">1131</span></a> +</span><span id="L-1132"><a href="#L-1132"><span class="linenos">1132</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><span id="L-1133"><a href="#L-1133"><span class="linenos">1133</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">,</span> +</span><span id="L-1134"><a href="#L-1134"><span class="linenos">1134</span></a> <span class="n">exists</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">(),</span> +</span><span id="L-1135"><a href="#L-1135"><span class="linenos">1135</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="L-1136"><a href="#L-1136"><span class="linenos">1136</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> +</span><span id="L-1137"><a href="#L-1137"><span class="linenos">1137</span></a> <span class="n">temporary</span><span class="o">=</span><span class="n">temporary</span><span class="p">,</span> +</span><span id="L-1138"><a href="#L-1138"><span class="linenos">1138</span></a> <span class="n">materialized</span><span class="o">=</span><span class="n">materialized</span><span class="p">,</span> +</span><span id="L-1139"><a href="#L-1139"><span class="linenos">1139</span></a> <span class="n">cascade</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CASCADE"</span><span class="p">),</span> +</span><span id="L-1140"><a href="#L-1140"><span class="linenos">1140</span></a> <span class="n">constraints</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CONSTRAINTS"</span><span class="p">),</span> +</span><span id="L-1141"><a href="#L-1141"><span class="linenos">1141</span></a> <span class="n">purge</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PURGE"</span><span class="p">),</span> +</span><span id="L-1142"><a href="#L-1142"><span class="linenos">1142</span></a> <span class="p">)</span> +</span><span id="L-1143"><a href="#L-1143"><span class="linenos">1143</span></a> +</span><span id="L-1144"><a href="#L-1144"><span class="linenos">1144</span></a> <span class="k">def</span> <span class="nf">_parse_exists</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">not_</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="nb">bool</span><span class="p">]:</span> +</span><span id="L-1145"><a href="#L-1145"><span class="linenos">1145</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="L-1146"><a href="#L-1146"><span class="linenos">1146</span></a> <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">IF</span><span class="p">)</span> +</span><span id="L-1147"><a href="#L-1147"><span class="linenos">1147</span></a> <span class="ow">and</span> <span class="p">(</span><span class="ow">not</span> <span class="n">not_</span> <span class="ow">or</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">NOT</span><span class="p">))</span> +</span><span id="L-1148"><a href="#L-1148"><span class="linenos">1148</span></a> <span class="ow">and</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">EXISTS</span><span class="p">)</span> +</span><span id="L-1149"><a href="#L-1149"><span class="linenos">1149</span></a> <span class="p">)</span> +</span><span id="L-1150"><a href="#L-1150"><span class="linenos">1150</span></a> +</span><span id="L-1151"><a href="#L-1151"><span class="linenos">1151</span></a> <span class="k">def</span> <span class="nf">_parse_create</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">Create</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> +</span><span id="L-1152"><a href="#L-1152"><span class="linenos">1152</span></a> <span class="c1"># Note: this can't be None because we've matched a statement parser</span> +</span><span id="L-1153"><a href="#L-1153"><span class="linenos">1153</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> +</span><span id="L-1154"><a href="#L-1154"><span class="linenos">1154</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"REPLACE"</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span> +</span><span id="L-1155"><a href="#L-1155"><span class="linenos">1155</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">OR</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span> +</span><span id="L-1156"><a href="#L-1156"><span class="linenos">1156</span></a> <span class="p">)</span> +</span><span id="L-1157"><a href="#L-1157"><span class="linenos">1157</span></a> <span class="n">unique</span> <span class="o">=</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">UNIQUE</span><span class="p">)</span> +</span><span id="L-1158"><a href="#L-1158"><span class="linenos">1158</span></a> +</span><span id="L-1159"><a href="#L-1159"><span class="linenos">1159</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FUNCTION</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-1160"><a href="#L-1160"><span class="linenos">1160</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-1161"><a href="#L-1161"><span class="linenos">1161</span></a> +</span><span id="L-1162"><a href="#L-1162"><span class="linenos">1162</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1163"><a href="#L-1163"><span class="linenos">1163</span></a> <span class="n">create_token</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> +</span><span id="L-1164"><a href="#L-1164"><span class="linenos">1164</span></a> +</span><span id="L-1165"><a href="#L-1165"><span class="linenos">1165</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">create_token</span><span class="p">:</span> +</span><span id="L-1166"><a href="#L-1166"><span class="linenos">1166</span></a> <span class="c1"># exp.Properties.Location.POST_CREATE</span> +</span><span id="L-1167"><a href="#L-1167"><span class="linenos">1167</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">()</span> +</span><span id="L-1168"><a href="#L-1168"><span class="linenos">1168</span></a> <span class="n">create_token</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> +</span><span id="L-1169"><a href="#L-1169"><span class="linenos">1169</span></a> +</span><span id="L-1170"><a href="#L-1170"><span class="linenos">1170</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">properties</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">create_token</span><span class="p">:</span> +</span><span id="L-1171"><a href="#L-1171"><span class="linenos">1171</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> +</span><span id="L-1172"><a href="#L-1172"><span class="linenos">1172</span></a> +</span><span id="L-1173"><a href="#L-1173"><span class="linenos">1173</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">(</span><span class="n">not_</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1174"><a href="#L-1174"><span class="linenos">1174</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1175"><a href="#L-1175"><span class="linenos">1175</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1176"><a href="#L-1176"><span class="linenos">1176</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1177"><a href="#L-1177"><span class="linenos">1177</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1178"><a href="#L-1178"><span class="linenos">1178</span></a> <span class="n">begin</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1179"><a href="#L-1179"><span class="linenos">1179</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1180"><a href="#L-1180"><span class="linenos">1180</span></a> +</span><span id="L-1181"><a href="#L-1181"><span class="linenos">1181</span></a> <span class="k">def</span> <span class="nf">extend_props</span><span class="p">(</span><span class="n">temp_props</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">Properties</span><span class="p">])</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-1182"><a href="#L-1182"><span class="linenos">1182</span></a> <span class="k">nonlocal</span> <span class="n">properties</span> +</span><span id="L-1183"><a href="#L-1183"><span class="linenos">1183</span></a> <span class="k">if</span> <span class="n">properties</span> <span class="ow">and</span> <span class="n">temp_props</span><span class="p">:</span> +</span><span id="L-1184"><a href="#L-1184"><span class="linenos">1184</span></a> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">temp_props</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-1185"><a href="#L-1185"><span class="linenos">1185</span></a> <span class="k">elif</span> <span class="n">temp_props</span><span class="p">:</span> +</span><span id="L-1186"><a href="#L-1186"><span class="linenos">1186</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="n">temp_props</span> +</span><span id="L-1187"><a href="#L-1187"><span class="linenos">1187</span></a> +</span><span id="L-1188"><a href="#L-1188"><span class="linenos">1188</span></a> <span class="k">if</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FUNCTION</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PROCEDURE</span><span class="p">):</span> +</span><span id="L-1189"><a href="#L-1189"><span class="linenos">1189</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_user_defined_function</span><span class="p">(</span><span class="n">kind</span><span class="o">=</span><span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span><span class="p">)</span> +</span><span id="L-1190"><a href="#L-1190"><span class="linenos">1190</span></a> +</span><span id="L-1191"><a href="#L-1191"><span class="linenos">1191</span></a> <span class="c1"># exp.Properties.Location.POST_SCHEMA ("schema" here is the UDF's type signature)</span> +</span><span id="L-1192"><a href="#L-1192"><span class="linenos">1192</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">())</span> +</span><span id="L-1193"><a href="#L-1193"><span class="linenos">1193</span></a> +</span><span id="L-1194"><a href="#L-1194"><span class="linenos">1194</span></a> <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">ALIAS</span><span class="p">)</span> +</span><span id="L-1195"><a href="#L-1195"><span class="linenos">1195</span></a> <span class="n">begin</span> <span class="o">=</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">BEGIN</span><span class="p">)</span> +</span><span id="L-1196"><a href="#L-1196"><span class="linenos">1196</span></a> <span class="n">return_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"RETURN"</span><span class="p">)</span> +</span><span id="L-1197"><a href="#L-1197"><span class="linenos">1197</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">()</span> +</span><span id="L-1198"><a href="#L-1198"><span class="linenos">1198</span></a> +</span><span id="L-1199"><a href="#L-1199"><span class="linenos">1199</span></a> <span class="k">if</span> <span class="n">return_</span><span class="p">:</span> +</span><span id="L-1200"><a href="#L-1200"><span class="linenos">1200</span></a> <span class="n">expression</span> <span class="o">=</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">Return</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-1201"><a href="#L-1201"><span class="linenos">1201</span></a> <span class="k">elif</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INDEX</span><span class="p">:</span> +</span><span id="L-1202"><a href="#L-1202"><span class="linenos">1202</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_index</span><span class="p">(</span><span class="n">index</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">())</span> +</span><span id="L-1203"><a href="#L-1203"><span class="linenos">1203</span></a> <span class="k">elif</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">DB_CREATABLES</span><span class="p">:</span> +</span><span id="L-1204"><a href="#L-1204"><span class="linenos">1204</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1205"><a href="#L-1205"><span class="linenos">1205</span></a> +</span><span id="L-1206"><a href="#L-1206"><span class="linenos">1206</span></a> <span class="c1"># exp.Properties.Location.POST_NAME</span> +</span><span id="L-1207"><a href="#L-1207"><span class="linenos">1207</span></a> <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">COMMA</span><span class="p">)</span> +</span><span id="L-1208"><a href="#L-1208"><span class="linenos">1208</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">(</span><span class="n">before</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="L-1209"><a href="#L-1209"><span class="linenos">1209</span></a> +</span><span id="L-1210"><a href="#L-1210"><span class="linenos">1210</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_parts</span><span class="p">)</span> +</span><span id="L-1211"><a href="#L-1211"><span class="linenos">1211</span></a> +</span><span id="L-1212"><a href="#L-1212"><span class="linenos">1212</span></a> <span class="c1"># exp.Properties.Location.POST_SCHEMA and POST_WITH</span> +</span><span id="L-1213"><a href="#L-1213"><span class="linenos">1213</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">())</span> +</span><span id="L-1214"><a href="#L-1214"><span class="linenos">1214</span></a> +</span><span id="L-1215"><a href="#L-1215"><span class="linenos">1215</span></a> <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">ALIAS</span><span class="p">)</span> +</span><span id="L-1216"><a href="#L-1216"><span class="linenos">1216</span></a> <span class="k">if</span> <span class="ow">not</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">DDL_SELECT_TOKENS</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-1217"><a href="#L-1217"><span class="linenos">1217</span></a> <span class="c1"># exp.Properties.Location.POST_ALIAS</span> +</span><span id="L-1218"><a href="#L-1218"><span class="linenos">1218</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">())</span> +</span><span id="L-1219"><a href="#L-1219"><span class="linenos">1219</span></a> +</span><span id="L-1220"><a href="#L-1220"><span class="linenos">1220</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_ddl_select</span><span class="p">()</span> +</span><span id="L-1221"><a href="#L-1221"><span class="linenos">1221</span></a> +</span><span id="L-1222"><a href="#L-1222"><span class="linenos">1222</span></a> <span class="k">if</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">:</span> +</span><span id="L-1223"><a href="#L-1223"><span class="linenos">1223</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-1224"><a href="#L-1224"><span class="linenos">1224</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-1225"><a href="#L-1225"><span class="linenos">1225</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_index</span><span class="p">()</span> +</span><span id="L-1226"><a href="#L-1226"><span class="linenos">1226</span></a> +</span><span id="L-1227"><a href="#L-1227"><span class="linenos">1227</span></a> <span class="c1"># exp.Properties.Location.POST_EXPRESSION and POST_INDEX</span> +</span><span id="L-1228"><a href="#L-1228"><span class="linenos">1228</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">())</span> +</span><span id="L-1229"><a href="#L-1229"><span class="linenos">1229</span></a> +</span><span id="L-1230"><a href="#L-1230"><span class="linenos">1230</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">index</span><span class="p">:</span> +</span><span id="L-1231"><a href="#L-1231"><span class="linenos">1231</span></a> <span class="k">break</span> +</span><span id="L-1232"><a href="#L-1232"><span class="linenos">1232</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1233"><a href="#L-1233"><span class="linenos">1233</span></a> <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">COMMA</span><span class="p">)</span> +</span><span id="L-1234"><a href="#L-1234"><span class="linenos">1234</span></a> <span class="n">indexes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-1235"><a href="#L-1235"><span class="linenos">1235</span></a> <span class="k">elif</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VIEW</span><span class="p">:</span> +</span><span id="L-1236"><a href="#L-1236"><span class="linenos">1236</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"SCHEMA"</span><span class="p">,</span> <span class="s2">"BINDING"</span><span class="p">):</span> +</span><span id="L-1237"><a href="#L-1237"><span class="linenos">1237</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-1238"><a href="#L-1238"><span class="linenos">1238</span></a> +</span><span id="L-1239"><a href="#L-1239"><span class="linenos">1239</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CLONE"</span><span class="p">):</span> +</span><span id="L-1240"><a href="#L-1240"><span class="linenos">1240</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1241"><a href="#L-1241"><span class="linenos">1241</span></a> <span class="n">when</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">({</span><span class="s2">"AT"</span><span class="p">,</span> <span class="s2">"BEFORE"</span><span class="p">})</span> <span class="ow">and</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="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-1242"><a href="#L-1242"><span class="linenos">1242</span></a> <span class="n">clone_kind</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-1243"><a href="#L-1243"><span class="linenos">1243</span></a> <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_PAREN</span><span class="p">)</span> +</span><span id="L-1244"><a href="#L-1244"><span class="linenos">1244</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CLONE_KINDS</span><span class="p">)</span> +</span><span id="L-1245"><a href="#L-1245"><span class="linenos">1245</span></a> <span class="ow">and</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="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-1246"><a href="#L-1246"><span class="linenos">1246</span></a> <span class="p">)</span> +</span><span id="L-1247"><a href="#L-1247"><span class="linenos">1247</span></a> <span class="n">clone_expression</span> <span class="o">=</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">FARROW</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="L-1248"><a href="#L-1248"><span class="linenos">1248</span></a> <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">R_PAREN</span><span class="p">)</span> +</span><span id="L-1249"><a href="#L-1249"><span class="linenos">1249</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-1250"><a href="#L-1250"><span class="linenos">1250</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Clone</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">clone</span><span class="p">,</span> <span class="n">when</span><span class="o">=</span><span class="n">when</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">clone_kind</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">clone_expression</span> +</span><span id="L-1251"><a href="#L-1251"><span class="linenos">1251</span></a> <span class="p">)</span> +</span><span id="L-1252"><a href="#L-1252"><span class="linenos">1252</span></a> +</span><span id="L-1253"><a href="#L-1253"><span class="linenos">1253</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-1254"><a href="#L-1254"><span class="linenos">1254</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> +</span><span id="L-1255"><a href="#L-1255"><span class="linenos">1255</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-1256"><a href="#L-1256"><span class="linenos">1256</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">create_token</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> +</span><span id="L-1257"><a href="#L-1257"><span class="linenos">1257</span></a> <span class="n">replace</span><span class="o">=</span><span class="n">replace</span><span class="p">,</span> +</span><span id="L-1258"><a href="#L-1258"><span class="linenos">1258</span></a> <span class="n">unique</span><span class="o">=</span><span class="n">unique</span><span class="p">,</span> +</span><span id="L-1259"><a href="#L-1259"><span class="linenos">1259</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> +</span><span id="L-1260"><a href="#L-1260"><span class="linenos">1260</span></a> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span><span class="p">,</span> +</span><span id="L-1261"><a href="#L-1261"><span class="linenos">1261</span></a> <span class="n">properties</span><span class="o">=</span><span class="n">properties</span><span class="p">,</span> +</span><span id="L-1262"><a href="#L-1262"><span class="linenos">1262</span></a> <span class="n">indexes</span><span class="o">=</span><span class="n">indexes</span><span class="p">,</span> +</span><span id="L-1263"><a href="#L-1263"><span class="linenos">1263</span></a> <span class="n">no_schema_binding</span><span class="o">=</span><span class="n">no_schema_binding</span><span class="p">,</span> +</span><span id="L-1264"><a href="#L-1264"><span class="linenos">1264</span></a> <span class="n">begin</span><span class="o">=</span><span class="n">begin</span><span class="p">,</span> +</span><span id="L-1265"><a href="#L-1265"><span class="linenos">1265</span></a> <span class="n">clone</span><span class="o">=</span><span class="n">clone</span><span class="p">,</span> +</span><span id="L-1266"><a href="#L-1266"><span class="linenos">1266</span></a> <span class="p">)</span> +</span><span id="L-1267"><a href="#L-1267"><span class="linenos">1267</span></a> +</span><span id="L-1268"><a href="#L-1268"><span class="linenos">1268</span></a> <span class="k">def</span> <span class="nf">_parse_property_before</span><span class="p">(</span><span class="bp">self</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-1269"><a href="#L-1269"><span class="linenos">1269</span></a> <span class="c1"># only used for teradata currently</span> +</span><span id="L-1270"><a href="#L-1270"><span class="linenos">1270</span></a> <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">COMMA</span><span class="p">)</span> +</span><span id="L-1271"><a href="#L-1271"><span class="linenos">1271</span></a> +</span><span id="L-1272"><a href="#L-1272"><span class="linenos">1272</span></a> <span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-1273"><a href="#L-1273"><span class="linenos">1273</span></a> <span class="s2">"no"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">),</span> +</span><span id="L-1274"><a href="#L-1274"><span class="linenos">1274</span></a> <span class="s2">"dual"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DUAL"</span><span class="p">),</span> +</span><span id="L-1275"><a href="#L-1275"><span class="linenos">1275</span></a> <span class="s2">"before"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BEFORE"</span><span class="p">),</span> +</span><span id="L-1276"><a href="#L-1276"><span class="linenos">1276</span></a> <span class="s2">"default"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFAULT"</span><span class="p">),</span> +</span><span id="L-1277"><a href="#L-1277"><span class="linenos">1277</span></a> <span class="s2">"local"</span><span class="p">:</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LOCAL"</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"LOCAL"</span><span class="p">)</span> +</span><span id="L-1278"><a href="#L-1278"><span class="linenos">1278</span></a> <span class="ow">or</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NOT"</span><span class="p">,</span> <span class="s2">"LOCAL"</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"NOT LOCAL"</span><span class="p">),</span> +</span><span id="L-1279"><a href="#L-1279"><span class="linenos">1279</span></a> <span class="s2">"after"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AFTER"</span><span class="p">),</span> +</span><span id="L-1280"><a href="#L-1280"><span class="linenos">1280</span></a> <span class="s2">"minimum"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"MIN"</span><span class="p">,</span> <span class="s2">"MINIMUM"</span><span class="p">)),</span> +</span><span id="L-1281"><a href="#L-1281"><span class="linenos">1281</span></a> <span class="s2">"maximum"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"MAX"</span><span class="p">,</span> <span class="s2">"MAXIMUM"</span><span class="p">)),</span> +</span><span id="L-1282"><a href="#L-1282"><span class="linenos">1282</span></a> <span class="p">}</span> +</span><span id="L-1283"><a href="#L-1283"><span class="linenos">1283</span></a> +</span><span id="L-1284"><a href="#L-1284"><span class="linenos">1284</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">PROPERTY_PARSERS</span><span class="p">):</span> +</span><span id="L-1285"><a href="#L-1285"><span class="linenos">1285</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTY_PARSERS</span><span class="p">[</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="o">.</span><span class="n">upper</span><span class="p">()]</span> +</span><span id="L-1286"><a href="#L-1286"><span class="linenos">1286</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="L-1287"><a href="#L-1287"><span class="linenos">1287</span></a> <span class="k">return</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="n">v</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="k">if</span> <span class="n">v</span><span class="p">})</span> +</span><span id="L-1288"><a href="#L-1288"><span class="linenos">1288</span></a> <span class="k">except</span> <span class="ne">TypeError</span><span class="p">:</span> +</span><span id="L-1289"><a href="#L-1289"><span class="linenos">1289</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Cannot parse property '</span><span class="si">{</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="si">}</span><span class="s2">'"</span><span class="p">)</span> +</span><span id="L-1290"><a href="#L-1290"><span class="linenos">1290</span></a> +</span><span id="L-1291"><a href="#L-1291"><span class="linenos">1291</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1292"><a href="#L-1292"><span class="linenos">1292</span></a> +</span><span id="L-1293"><a href="#L-1293"><span class="linenos">1293</span></a> <span class="k">def</span> <span class="nf">_parse_property</span><span class="p">(</span><span class="bp">self</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-1294"><a href="#L-1294"><span class="linenos">1294</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">PROPERTY_PARSERS</span><span class="p">):</span> +</span><span id="L-1295"><a href="#L-1295"><span class="linenos">1295</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTY_PARSERS</span><span class="p">[</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="o">.</span><span class="n">upper</span><span class="p">()](</span><span class="bp">self</span><span class="p">)</span> +</span><span id="L-1296"><a href="#L-1296"><span class="linenos">1296</span></a> +</span><span id="L-1297"><a href="#L-1297"><span class="linenos">1297</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CHARACTER_SET</span><span class="p">):</span> +</span><span id="L-1298"><a href="#L-1298"><span class="linenos">1298</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_character_set</span><span class="p">(</span><span class="n">default</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1299"><a href="#L-1299"><span class="linenos">1299</span></a> +</span><span id="L-1300"><a href="#L-1300"><span class="linenos">1300</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"COMPOUND"</span><span class="p">,</span> <span class="s2">"SORTKEY"</span><span class="p">):</span> +</span><span id="L-1301"><a href="#L-1301"><span class="linenos">1301</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_sortkey</span><span class="p">(</span><span class="n">compound</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1302"><a href="#L-1302"><span class="linenos">1302</span></a> +</span><span id="L-1303"><a href="#L-1303"><span class="linenos">1303</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SQL"</span><span class="p">,</span> <span class="s2">"SECURITY"</span><span class="p">):</span> +</span><span id="L-1304"><a href="#L-1304"><span class="linenos">1304</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">SqlSecurityProperty</span><span class="p">,</span> <span class="n">definer</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFINER"</span><span class="p">))</span> +</span><span id="L-1305"><a href="#L-1305"><span class="linenos">1305</span></a> +</span><span id="L-1306"><a href="#L-1306"><span class="linenos">1306</span></a> <span class="n">assignment</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span> +</span><span id="L-1307"><a href="#L-1307"><span class="linenos">1307</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span> +</span><span id="L-1308"><a href="#L-1308"><span class="linenos">1308</span></a> <span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</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-1309"><a href="#L-1309"><span class="linenos">1309</span></a> +</span><span id="L-1310"><a href="#L-1310"><span class="linenos">1310</span></a> <span class="k">if</span> <span class="n">assignment</span><span class="p">:</span> +</span><span id="L-1311"><a href="#L-1311"><span class="linenos">1311</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var_or_string</span><span class="p">()</span> +</span><span id="L-1312"><a href="#L-1312"><span class="linenos">1312</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="L-1313"><a href="#L-1313"><span class="linenos">1313</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">Property</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">())</span> +</span><span id="L-1314"><a href="#L-1314"><span class="linenos">1314</span></a> +</span><span id="L-1315"><a href="#L-1315"><span class="linenos">1315</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1316"><a href="#L-1316"><span class="linenos">1316</span></a> +</span><span id="L-1317"><a href="#L-1317"><span class="linenos">1317</span></a> <span class="k">def</span> <span class="nf">_parse_stored</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">FileFormatProperty</span><span class="p">:</span> +</span><span id="L-1318"><a href="#L-1318"><span class="linenos">1318</span></a> <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">ALIAS</span><span class="p">)</span> +</span><span id="L-1319"><a href="#L-1319"><span class="linenos">1319</span></a> +</span><span id="L-1320"><a href="#L-1320"><span class="linenos">1320</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INPUTFORMAT"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="L-1321"><a href="#L-1321"><span class="linenos">1321</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OUTPUTFORMAT"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="L-1322"><a href="#L-1322"><span class="linenos">1322</span></a> +</span><span id="L-1323"><a href="#L-1323"><span class="linenos">1323</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><span id="L-1324"><a href="#L-1324"><span class="linenos">1324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">,</span> +</span><span id="L-1325"><a href="#L-1325"><span class="linenos">1325</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-1326"><a href="#L-1326"><span class="linenos">1326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">,</span> <span class="n">input_format</span><span class="o">=</span><span class="n">input_format</span><span class="p">,</span> <span class="n">output_format</span><span class="o">=</span><span class="n">output_format</span> +</span><span id="L-1327"><a href="#L-1327"><span class="linenos">1327</span></a> <span class="p">)</span> +</span><span id="L-1328"><a href="#L-1328"><span class="linenos">1328</span></a> <span class="k">if</span> <span class="n">input_format</span> <span class="ow">or</span> <span class="n">output_format</span> +</span><span id="L-1329"><a href="#L-1329"><span class="linenos">1329</span></a> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var_or_string</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(),</span> +</span><span id="L-1330"><a href="#L-1330"><span class="linenos">1330</span></a> <span class="p">)</span> +</span><span id="L-1331"><a href="#L-1331"><span class="linenos">1331</span></a> +</span><span id="L-1332"><a href="#L-1332"><span class="linenos">1332</span></a> <span class="k">def</span> <span class="nf">_parse_property_assignment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">])</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="L-1333"><a href="#L-1333"><span class="linenos">1333</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="L-1334"><a href="#L-1334"><span class="linenos">1334</span></a> <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">ALIAS</span><span class="p">)</span> +</span><span id="L-1335"><a href="#L-1335"><span class="linenos">1335</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp_class</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_field</span><span class="p">())</span> +</span><span id="L-1336"><a href="#L-1336"><span class="linenos">1336</span></a> +</span><span id="L-1337"><a href="#L-1337"><span class="linenos">1337</span></a> <span class="k">def</span> <span class="nf">_parse_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">before</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span 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">Properties</span><span class="p">]:</span> +</span><span id="L-1338"><a href="#L-1338"><span class="linenos">1338</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-1339"><a href="#L-1339"><span class="linenos">1339</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-1340"><a href="#L-1340"><span class="linenos">1340</span></a> <span class="k">if</span> <span class="n">before</span><span class="p">:</span> +</span><span id="L-1341"><a href="#L-1341"><span class="linenos">1341</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_property_before</span><span class="p">()</span> +</span><span id="L-1342"><a href="#L-1342"><span class="linenos">1342</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1343"><a href="#L-1343"><span class="linenos">1343</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_property</span><span class="p">()</span> +</span><span id="L-1344"><a href="#L-1344"><span class="linenos">1344</span></a> +</span><span id="L-1345"><a href="#L-1345"><span class="linenos">1345</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">prop</span><span class="p">:</span> +</span><span id="L-1346"><a href="#L-1346"><span class="linenos">1346</span></a> <span class="k">break</span> +</span><span id="L-1347"><a href="#L-1347"><span class="linenos">1347</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">prop</span><span class="p">):</span> +</span><span id="L-1348"><a href="#L-1348"><span class="linenos">1348</span></a> <span class="n">properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="L-1349"><a href="#L-1349"><span class="linenos">1349</span></a> +</span><span id="L-1350"><a href="#L-1350"><span class="linenos">1350</span></a> <span class="k">if</span> <span class="n">properties</span><span class="p">:</span> +</span><span id="L-1351"><a href="#L-1351"><span class="linenos">1351</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">Properties</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">properties</span><span class="p">)</span> +</span><span id="L-1352"><a href="#L-1352"><span class="linenos">1352</span></a> +</span><span id="L-1353"><a href="#L-1353"><span class="linenos">1353</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1354"><a href="#L-1354"><span class="linenos">1354</span></a> +</span><span id="L-1355"><a href="#L-1355"><span class="linenos">1355</span></a> <span class="k">def</span> <span class="nf">_parse_fallback</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">no</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">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">:</span> +</span><span id="L-1356"><a href="#L-1356"><span class="linenos">1356</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><span id="L-1357"><a href="#L-1357"><span class="linenos">1357</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">,</span> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">,</span> <span class="n">protection</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PROTECTION"</span><span class="p">)</span> +</span><span id="L-1358"><a href="#L-1358"><span class="linenos">1358</span></a> <span class="p">)</span> +</span><span id="L-1359"><a href="#L-1359"><span class="linenos">1359</span></a> +</span><span id="L-1360"><a href="#L-1360"><span class="linenos">1360</span></a> <span class="k">def</span> <span class="nf">_parse_volatile_property</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">VolatileProperty</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> +</span><span id="L-1361"><a href="#L-1361"><span class="linenos">1361</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">>=</span> <span class="mi">2</span><span class="p">:</span> +</span><span id="L-1362"><a href="#L-1362"><span class="linenos">1362</span></a> <span class="n">pre_volatile_token</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">2</span><span class="p">]</span> +</span><span id="L-1363"><a href="#L-1363"><span class="linenos">1363</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1364"><a href="#L-1364"><span class="linenos">1364</span></a> <span class="n">pre_volatile_token</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1365"><a href="#L-1365"><span class="linenos">1365</span></a> +</span><span id="L-1366"><a href="#L-1366"><span class="linenos">1366</span></a> <span class="k">if</span> <span class="n">pre_volatile_token</span> <span class="ow">and</span> <span class="n">pre_volatile_token</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRE_VOLATILE_TOKENS</span><span class="p">:</span> +</span><span id="L-1367"><a href="#L-1367"><span class="linenos">1367</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">()</span> +</span><span id="L-1368"><a href="#L-1368"><span class="linenos">1368</span></a> +</span><span id="L-1369"><a href="#L-1369"><span class="linenos">1369</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">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"VOLATILE"</span><span class="p">))</span> +</span><span id="L-1370"><a href="#L-1370"><span class="linenos">1370</span></a> +</span><span id="L-1371"><a href="#L-1371"><span class="linenos">1371</span></a> <span class="k">def</span> <span class="nf">_parse_with_property</span><span class="p">(</span> +</span><span id="L-1372"><a href="#L-1372"><span class="linenos">1372</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-1373"><a href="#L-1373"><span class="linenos">1373</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 class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">List</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><span id="L-1374"><a href="#L-1374"><span class="linenos">1374</span></a> <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">WITH</span><span class="p">)</span> +</span><span id="L-1375"><a href="#L-1375"><span class="linenos">1375</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_PAREN</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-1376"><a href="#L-1376"><span class="linenos">1376</span></a> <span class="k">return</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_property</span><span class="p">)</span> +</span><span id="L-1377"><a href="#L-1377"><span class="linenos">1377</span></a> +</span><span id="L-1378"><a href="#L-1378"><span class="linenos">1378</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"JOURNAL"</span><span class="p">):</span> +</span><span id="L-1379"><a href="#L-1379"><span class="linenos">1379</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_withjournaltable</span><span class="p">()</span> +</span><span id="L-1380"><a href="#L-1380"><span class="linenos">1380</span></a> +</span><span id="L-1381"><a href="#L-1381"><span class="linenos">1381</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DATA"</span><span class="p">):</span> +</span><span id="L-1382"><a href="#L-1382"><span class="linenos">1382</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_withdata</span><span class="p">(</span><span class="n">no</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-1383"><a href="#L-1383"><span class="linenos">1383</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"DATA"</span><span class="p">):</span> +</span><span id="L-1384"><a href="#L-1384"><span class="linenos">1384</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_withdata</span><span class="p">(</span><span class="n">no</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1385"><a href="#L-1385"><span class="linenos">1385</span></a> +</span><span id="L-1386"><a href="#L-1386"><span class="linenos">1386</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> +</span><span id="L-1387"><a href="#L-1387"><span class="linenos">1387</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1388"><a href="#L-1388"><span class="linenos">1388</span></a> +</span><span id="L-1389"><a href="#L-1389"><span class="linenos">1389</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_withisolatedloading</span><span class="p">()</span> +</span><span id="L-1390"><a href="#L-1390"><span class="linenos">1390</span></a> +</span><span id="L-1391"><a href="#L-1391"><span class="linenos">1391</span></a> <span class="c1"># https://dev.mysql.com/doc/refman/8.0/en/create-view.html</span> +</span><span id="L-1392"><a href="#L-1392"><span class="linenos">1392</span></a> <span class="k">def</span> <span class="nf">_parse_definer</span><span class="p">(</span><span class="bp">self</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">DefinerProperty</span><span class="p">]:</span> +</span><span id="L-1393"><a href="#L-1393"><span class="linenos">1393</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="L-1394"><a href="#L-1394"><span class="linenos">1394</span></a> +</span><span id="L-1395"><a href="#L-1395"><span class="linenos">1395</span></a> <span class="n">user</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="L-1396"><a href="#L-1396"><span class="linenos">1396</span></a> <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">PARAMETER</span><span class="p">)</span> +</span><span id="L-1397"><a href="#L-1397"><span class="linenos">1397</span></a> <span class="n">host</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> <span class="ow">or</span> <span class="p">(</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">MOD</span><span class="p">)</span> <span class="ow">and</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-1398"><a href="#L-1398"><span class="linenos">1398</span></a> +</span><span id="L-1399"><a href="#L-1399"><span class="linenos">1399</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">user</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">host</span><span class="p">:</span> +</span><span id="L-1400"><a href="#L-1400"><span class="linenos">1400</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1401"><a href="#L-1401"><span class="linenos">1401</span></a> +</span><span id="L-1402"><a href="#L-1402"><span class="linenos">1402</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">DefinerProperty</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">user</span><span class="si">}</span><span class="s2">@</span><span class="si">{</span><span class="n">host</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-1403"><a href="#L-1403"><span class="linenos">1403</span></a> +</span><span id="L-1404"><a href="#L-1404"><span class="linenos">1404</span></a> <span class="k">def</span> <span class="nf">_parse_withjournaltable</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">WithJournalTableProperty</span><span class="p">:</span> +</span><span id="L-1405"><a href="#L-1405"><span class="linenos">1405</span></a> <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">TABLE</span><span class="p">)</span> +</span><span id="L-1406"><a href="#L-1406"><span class="linenos">1406</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="L-1407"><a href="#L-1407"><span class="linenos">1407</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">WithJournalTableProperty</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_table_parts</span><span class="p">())</span> +</span><span id="L-1408"><a href="#L-1408"><span class="linenos">1408</span></a> +</span><span id="L-1409"><a href="#L-1409"><span class="linenos">1409</span></a> <span class="k">def</span> <span class="nf">_parse_log</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">no</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">exp</span><span class="o">.</span><span class="n">LogProperty</span><span class="p">:</span> +</span><span id="L-1410"><a href="#L-1410"><span class="linenos">1410</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">LogProperty</span><span class="p">,</span> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">)</span> +</span><span id="L-1411"><a href="#L-1411"><span class="linenos">1411</span></a> +</span><span id="L-1412"><a href="#L-1412"><span class="linenos">1412</span></a> <span class="k">def</span> <span class="nf">_parse_journal</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">:</span> +</span><span id="L-1413"><a href="#L-1413"><span class="linenos">1413</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">JournalProperty</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="L-1414"><a href="#L-1414"><span class="linenos">1414</span></a> +</span><span id="L-1415"><a href="#L-1415"><span class="linenos">1415</span></a> <span class="k">def</span> <span class="nf">_parse_checksum</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">ChecksumProperty</span><span class="p">:</span> +</span><span id="L-1416"><a href="#L-1416"><span class="linenos">1416</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="L-1417"><a href="#L-1417"><span class="linenos">1417</span></a> +</span><span id="L-1418"><a href="#L-1418"><span class="linenos">1418</span></a> <span class="n">on</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1419"><a href="#L-1419"><span class="linenos">1419</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">ON</span><span class="p">):</span> +</span><span id="L-1420"><a href="#L-1420"><span class="linenos">1420</span></a> <span class="n">on</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-1421"><a href="#L-1421"><span class="linenos">1421</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OFF"</span><span class="p">):</span> +</span><span id="L-1422"><a href="#L-1422"><span class="linenos">1422</span></a> <span class="n">on</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-1423"><a href="#L-1423"><span class="linenos">1423</span></a> +</span><span id="L-1424"><a href="#L-1424"><span class="linenos">1424</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">ChecksumProperty</span><span class="p">,</span> <span class="n">on</span><span class="o">=</span><span class="n">on</span><span class="p">,</span> <span class="n">default</span><span class="o">=</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">DEFAULT</span><span class="p">))</span> +</span><span id="L-1425"><a href="#L-1425"><span class="linenos">1425</span></a> +</span><span id="L-1426"><a href="#L-1426"><span class="linenos">1426</span></a> <span class="k">def</span> <span class="nf">_parse_cluster</span><span class="p">(</span><span class="bp">self</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">Cluster</span><span class="p">]:</span> +</span><span id="L-1427"><a href="#L-1427"><span class="linenos">1427</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">Cluster</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_ordered</span><span class="p">))</span> +</span><span id="L-1428"><a href="#L-1428"><span class="linenos">1428</span></a> +</span><span id="L-1429"><a href="#L-1429"><span class="linenos">1429</span></a> <span class="k">def</span> <span class="nf">_parse_copy_property</span><span class="p">(</span><span class="bp">self</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">CopyGrantsProperty</span><span class="p">]:</span> +</span><span id="L-1430"><a href="#L-1430"><span class="linenos">1430</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"GRANTS"</span><span class="p">):</span> +</span><span id="L-1431"><a href="#L-1431"><span class="linenos">1431</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="L-1432"><a href="#L-1432"><span class="linenos">1432</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1433"><a href="#L-1433"><span class="linenos">1433</span></a> +</span><span id="L-1434"><a href="#L-1434"><span class="linenos">1434</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">CopyGrantsProperty</span><span class="p">)</span> +</span><span id="L-1435"><a href="#L-1435"><span class="linenos">1435</span></a> +</span><span id="L-1436"><a href="#L-1436"><span class="linenos">1436</span></a> <span class="k">def</span> <span class="nf">_parse_freespace</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">FreespaceProperty</span><span class="p">:</span> +</span><span id="L-1437"><a href="#L-1437"><span class="linenos">1437</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="L-1438"><a href="#L-1438"><span class="linenos">1438</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><span id="L-1439"><a href="#L-1439"><span class="linenos">1439</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</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_number</span><span class="p">(),</span> <span class="n">percent</span><span class="o">=</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">PERCENT</span><span class="p">)</span> +</span><span id="L-1440"><a href="#L-1440"><span class="linenos">1440</span></a> <span class="p">)</span> +</span><span id="L-1441"><a href="#L-1441"><span class="linenos">1441</span></a> +</span><span id="L-1442"><a href="#L-1442"><span class="linenos">1442</span></a> <span class="k">def</span> <span class="nf">_parse_mergeblockratio</span><span class="p">(</span> +</span><span id="L-1443"><a href="#L-1443"><span class="linenos">1443</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">no</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="n">default</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-1444"><a href="#L-1444"><span class="linenos">1444</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">:</span> +</span><span id="L-1445"><a href="#L-1445"><span class="linenos">1445</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">EQ</span><span class="p">):</span> +</span><span id="L-1446"><a href="#L-1446"><span class="linenos">1446</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><span id="L-1447"><a href="#L-1447"><span class="linenos">1447</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">,</span> +</span><span id="L-1448"><a href="#L-1448"><span class="linenos">1448</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">(),</span> +</span><span id="L-1449"><a href="#L-1449"><span class="linenos">1449</span></a> <span class="n">percent</span><span class="o">=</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">PERCENT</span><span class="p">),</span> +</span><span id="L-1450"><a href="#L-1450"><span class="linenos">1450</span></a> <span class="p">)</span> +</span><span id="L-1451"><a href="#L-1451"><span class="linenos">1451</span></a> +</span><span id="L-1452"><a href="#L-1452"><span class="linenos">1452</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">MergeBlockRatioProperty</span><span class="p">,</span> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">default</span><span class="p">)</span> +</span><span id="L-1453"><a href="#L-1453"><span class="linenos">1453</span></a> +</span><span id="L-1454"><a href="#L-1454"><span class="linenos">1454</span></a> <span class="k">def</span> <span class="nf">_parse_datablocksize</span><span class="p">(</span> +</span><span id="L-1455"><a href="#L-1455"><span class="linenos">1455</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-1456"><a href="#L-1456"><span class="linenos">1456</span></a> <span class="n">default</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-1457"><a href="#L-1457"><span class="linenos">1457</span></a> <span class="n">minimum</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-1458"><a href="#L-1458"><span class="linenos">1458</span></a> <span class="n">maximum</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-1459"><a href="#L-1459"><span class="linenos">1459</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">:</span> +</span><span id="L-1460"><a href="#L-1460"><span class="linenos">1460</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="L-1461"><a href="#L-1461"><span class="linenos">1461</span></a> <span class="n">size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> </span><span id="L-1462"><a href="#L-1462"><span class="linenos">1462</span></a> -</span><span id="L-1463"><a href="#L-1463"><span class="linenos">1463</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><span id="L-1464"><a href="#L-1464"><span class="linenos">1464</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">,</span> -</span><span id="L-1465"><a href="#L-1465"><span class="linenos">1465</span></a> <span class="n">size</span><span class="o">=</span><span class="n">size</span><span class="p">,</span> -</span><span id="L-1466"><a href="#L-1466"><span class="linenos">1466</span></a> <span class="n">units</span><span class="o">=</span><span class="n">units</span><span class="p">,</span> -</span><span id="L-1467"><a href="#L-1467"><span class="linenos">1467</span></a> <span class="n">default</span><span class="o">=</span><span class="n">default</span><span class="p">,</span> -</span><span id="L-1468"><a href="#L-1468"><span class="linenos">1468</span></a> <span class="n">minimum</span><span class="o">=</span><span class="n">minimum</span><span class="p">,</span> -</span><span id="L-1469"><a href="#L-1469"><span class="linenos">1469</span></a> <span class="n">maximum</span><span class="o">=</span><span class="n">maximum</span><span class="p">,</span> -</span><span id="L-1470"><a href="#L-1470"><span class="linenos">1470</span></a> <span class="p">)</span> -</span><span id="L-1471"><a href="#L-1471"><span class="linenos">1471</span></a> -</span><span id="L-1472"><a href="#L-1472"><span class="linenos">1472</span></a> <span class="k">def</span> <span class="nf">_parse_blockcompression</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">BlockCompressionProperty</span><span class="p">:</span> -</span><span id="L-1473"><a href="#L-1473"><span class="linenos">1473</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="L-1474"><a href="#L-1474"><span class="linenos">1474</span></a> <span class="n">always</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ALWAYS"</span><span class="p">)</span> -</span><span id="L-1475"><a href="#L-1475"><span class="linenos">1475</span></a> <span class="n">manual</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MANUAL"</span><span class="p">)</span> -</span><span id="L-1476"><a href="#L-1476"><span class="linenos">1476</span></a> <span class="n">never</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NEVER"</span><span class="p">)</span> -</span><span id="L-1477"><a href="#L-1477"><span class="linenos">1477</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFAULT"</span><span class="p">)</span> -</span><span id="L-1478"><a href="#L-1478"><span class="linenos">1478</span></a> -</span><span id="L-1479"><a href="#L-1479"><span class="linenos">1479</span></a> <span class="n">autotemp</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1480"><a href="#L-1480"><span class="linenos">1480</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AUTOTEMP"</span><span class="p">):</span> -</span><span id="L-1481"><a href="#L-1481"><span class="linenos">1481</span></a> <span class="n">autotemp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</span><span class="p">()</span> +</span><span id="L-1463"><a href="#L-1463"><span class="linenos">1463</span></a> <span class="n">units</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1464"><a href="#L-1464"><span class="linenos">1464</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"BYTES"</span><span class="p">,</span> <span class="s2">"KBYTES"</span><span class="p">,</span> <span class="s2">"KILOBYTES"</span><span class="p">)):</span> +</span><span id="L-1465"><a href="#L-1465"><span class="linenos">1465</span></a> <span class="n">units</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><span id="L-1466"><a href="#L-1466"><span class="linenos">1466</span></a> +</span><span id="L-1467"><a href="#L-1467"><span class="linenos">1467</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-1468"><a href="#L-1468"><span class="linenos">1468</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">,</span> +</span><span id="L-1469"><a href="#L-1469"><span class="linenos">1469</span></a> <span class="n">size</span><span class="o">=</span><span class="n">size</span><span class="p">,</span> +</span><span id="L-1470"><a href="#L-1470"><span class="linenos">1470</span></a> <span class="n">units</span><span class="o">=</span><span class="n">units</span><span class="p">,</span> +</span><span id="L-1471"><a href="#L-1471"><span class="linenos">1471</span></a> <span class="n">default</span><span class="o">=</span><span class="n">default</span><span class="p">,</span> +</span><span id="L-1472"><a href="#L-1472"><span class="linenos">1472</span></a> <span class="n">minimum</span><span class="o">=</span><span class="n">minimum</span><span class="p">,</span> +</span><span id="L-1473"><a href="#L-1473"><span class="linenos">1473</span></a> <span class="n">maximum</span><span class="o">=</span><span class="n">maximum</span><span class="p">,</span> +</span><span id="L-1474"><a href="#L-1474"><span class="linenos">1474</span></a> <span class="p">)</span> +</span><span id="L-1475"><a href="#L-1475"><span class="linenos">1475</span></a> +</span><span id="L-1476"><a href="#L-1476"><span class="linenos">1476</span></a> <span class="k">def</span> <span class="nf">_parse_blockcompression</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">BlockCompressionProperty</span><span class="p">:</span> +</span><span id="L-1477"><a href="#L-1477"><span class="linenos">1477</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="L-1478"><a href="#L-1478"><span class="linenos">1478</span></a> <span class="n">always</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ALWAYS"</span><span class="p">)</span> +</span><span id="L-1479"><a href="#L-1479"><span class="linenos">1479</span></a> <span class="n">manual</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MANUAL"</span><span class="p">)</span> +</span><span id="L-1480"><a href="#L-1480"><span class="linenos">1480</span></a> <span class="n">never</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NEVER"</span><span class="p">)</span> +</span><span id="L-1481"><a href="#L-1481"><span class="linenos">1481</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFAULT"</span><span class="p">)</span> </span><span id="L-1482"><a href="#L-1482"><span class="linenos">1482</span></a> -</span><span id="L-1483"><a href="#L-1483"><span class="linenos">1483</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><span id="L-1484"><a href="#L-1484"><span class="linenos">1484</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">,</span> -</span><span id="L-1485"><a href="#L-1485"><span class="linenos">1485</span></a> <span class="n">always</span><span class="o">=</span><span class="n">always</span><span class="p">,</span> -</span><span id="L-1486"><a href="#L-1486"><span class="linenos">1486</span></a> <span class="n">manual</span><span class="o">=</span><span class="n">manual</span><span class="p">,</span> -</span><span id="L-1487"><a href="#L-1487"><span class="linenos">1487</span></a> <span class="n">never</span><span class="o">=</span><span class="n">never</span><span class="p">,</span> -</span><span id="L-1488"><a href="#L-1488"><span class="linenos">1488</span></a> <span class="n">default</span><span class="o">=</span><span class="n">default</span><span class="p">,</span> -</span><span id="L-1489"><a href="#L-1489"><span class="linenos">1489</span></a> <span class="n">autotemp</span><span class="o">=</span><span class="n">autotemp</span><span class="p">,</span> -</span><span id="L-1490"><a href="#L-1490"><span class="linenos">1490</span></a> <span class="p">)</span> -</span><span id="L-1491"><a href="#L-1491"><span class="linenos">1491</span></a> -</span><span id="L-1492"><a href="#L-1492"><span class="linenos">1492</span></a> <span class="k">def</span> <span class="nf">_parse_withisolatedloading</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">IsolatedLoadingProperty</span><span class="p">:</span> -</span><span id="L-1493"><a href="#L-1493"><span class="linenos">1493</span></a> <span class="n">no</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">)</span> -</span><span id="L-1494"><a href="#L-1494"><span class="linenos">1494</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CONCURRENT"</span><span class="p">)</span> -</span><span id="L-1495"><a href="#L-1495"><span class="linenos">1495</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ISOLATED"</span><span class="p">,</span> <span class="s2">"LOADING"</span><span class="p">)</span> -</span><span id="L-1496"><a href="#L-1496"><span class="linenos">1496</span></a> <span class="n">for_all</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"ALL"</span><span class="p">)</span> -</span><span id="L-1497"><a href="#L-1497"><span class="linenos">1497</span></a> <span class="n">for_insert</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"INSERT"</span><span class="p">)</span> -</span><span id="L-1498"><a href="#L-1498"><span class="linenos">1498</span></a> <span class="n">for_none</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"NONE"</span><span class="p">)</span> -</span><span id="L-1499"><a href="#L-1499"><span class="linenos">1499</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><span id="L-1500"><a href="#L-1500"><span class="linenos">1500</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">,</span> -</span><span id="L-1501"><a href="#L-1501"><span class="linenos">1501</span></a> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">,</span> -</span><span id="L-1502"><a href="#L-1502"><span class="linenos">1502</span></a> <span class="n">concurrent</span><span class="o">=</span><span class="n">concurrent</span><span class="p">,</span> -</span><span id="L-1503"><a href="#L-1503"><span class="linenos">1503</span></a> <span class="n">for_all</span><span class="o">=</span><span class="n">for_all</span><span class="p">,</span> -</span><span id="L-1504"><a href="#L-1504"><span class="linenos">1504</span></a> <span class="n">for_insert</span><span class="o">=</span><span class="n">for_insert</span><span class="p">,</span> -</span><span id="L-1505"><a href="#L-1505"><span class="linenos">1505</span></a> <span class="n">for_none</span><span class="o">=</span><span class="n">for_none</span><span class="p">,</span> -</span><span id="L-1506"><a href="#L-1506"><span class="linenos">1506</span></a> <span class="p">)</span> -</span><span id="L-1507"><a href="#L-1507"><span class="linenos">1507</span></a> -</span><span id="L-1508"><a href="#L-1508"><span class="linenos">1508</span></a> <span class="k">def</span> <span class="nf">_parse_locking</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">LockingProperty</span><span class="p">:</span> -</span><span id="L-1509"><a href="#L-1509"><span class="linenos">1509</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">TABLE</span><span class="p">):</span> -</span><span id="L-1510"><a href="#L-1510"><span class="linenos">1510</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">"TABLE"</span> -</span><span id="L-1511"><a href="#L-1511"><span class="linenos">1511</span></a> <span class="k">elif</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">VIEW</span><span class="p">):</span> -</span><span id="L-1512"><a href="#L-1512"><span class="linenos">1512</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">"VIEW"</span> -</span><span id="L-1513"><a href="#L-1513"><span class="linenos">1513</span></a> <span class="k">elif</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">ROW</span><span class="p">):</span> -</span><span id="L-1514"><a href="#L-1514"><span class="linenos">1514</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">"ROW"</span> -</span><span id="L-1515"><a href="#L-1515"><span class="linenos">1515</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DATABASE"</span><span class="p">):</span> -</span><span id="L-1516"><a href="#L-1516"><span class="linenos">1516</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">"DATABASE"</span> -</span><span id="L-1517"><a href="#L-1517"><span class="linenos">1517</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1518"><a href="#L-1518"><span class="linenos">1518</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1519"><a href="#L-1519"><span class="linenos">1519</span></a> -</span><span id="L-1520"><a href="#L-1520"><span class="linenos">1520</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"DATABASE"</span><span class="p">,</span> <span class="s2">"TABLE"</span><span class="p">,</span> <span class="s2">"VIEW"</span><span class="p">):</span> -</span><span id="L-1521"><a href="#L-1521"><span class="linenos">1521</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">()</span> -</span><span id="L-1522"><a href="#L-1522"><span class="linenos">1522</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1523"><a href="#L-1523"><span class="linenos">1523</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1524"><a href="#L-1524"><span class="linenos">1524</span></a> -</span><span id="L-1525"><a href="#L-1525"><span class="linenos">1525</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">FOR</span><span class="p">):</span> -</span><span id="L-1526"><a href="#L-1526"><span class="linenos">1526</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="s2">"FOR"</span> -</span><span id="L-1527"><a href="#L-1527"><span class="linenos">1527</span></a> <span class="k">elif</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">IN</span><span class="p">):</span> -</span><span id="L-1528"><a href="#L-1528"><span class="linenos">1528</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="s2">"IN"</span> -</span><span id="L-1529"><a href="#L-1529"><span class="linenos">1529</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1530"><a href="#L-1530"><span class="linenos">1530</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1531"><a href="#L-1531"><span class="linenos">1531</span></a> -</span><span id="L-1532"><a href="#L-1532"><span class="linenos">1532</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ACCESS"</span><span class="p">):</span> -</span><span id="L-1533"><a href="#L-1533"><span class="linenos">1533</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"ACCESS"</span> -</span><span id="L-1534"><a href="#L-1534"><span class="linenos">1534</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"EXCL"</span><span class="p">,</span> <span class="s2">"EXCLUSIVE"</span><span class="p">)):</span> -</span><span id="L-1535"><a href="#L-1535"><span class="linenos">1535</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"EXCLUSIVE"</span> -</span><span id="L-1536"><a href="#L-1536"><span class="linenos">1536</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SHARE"</span><span class="p">):</span> -</span><span id="L-1537"><a href="#L-1537"><span class="linenos">1537</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"SHARE"</span> -</span><span id="L-1538"><a href="#L-1538"><span class="linenos">1538</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"READ"</span><span class="p">):</span> -</span><span id="L-1539"><a href="#L-1539"><span class="linenos">1539</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"READ"</span> -</span><span id="L-1540"><a href="#L-1540"><span class="linenos">1540</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WRITE"</span><span class="p">):</span> -</span><span id="L-1541"><a href="#L-1541"><span class="linenos">1541</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"WRITE"</span> -</span><span id="L-1542"><a href="#L-1542"><span class="linenos">1542</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CHECKSUM"</span><span class="p">):</span> -</span><span id="L-1543"><a href="#L-1543"><span class="linenos">1543</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"CHECKSUM"</span> -</span><span id="L-1544"><a href="#L-1544"><span class="linenos">1544</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1545"><a href="#L-1545"><span class="linenos">1545</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1546"><a href="#L-1546"><span class="linenos">1546</span></a> -</span><span id="L-1547"><a href="#L-1547"><span class="linenos">1547</span></a> <span class="n">override</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OVERRIDE"</span><span class="p">)</span> -</span><span id="L-1548"><a href="#L-1548"><span class="linenos">1548</span></a> -</span><span id="L-1549"><a href="#L-1549"><span class="linenos">1549</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><span id="L-1550"><a href="#L-1550"><span class="linenos">1550</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">,</span> -</span><span id="L-1551"><a href="#L-1551"><span class="linenos">1551</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-1552"><a href="#L-1552"><span class="linenos">1552</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> -</span><span id="L-1553"><a href="#L-1553"><span class="linenos">1553</span></a> <span class="n">for_or_in</span><span class="o">=</span><span class="n">for_or_in</span><span class="p">,</span> -</span><span id="L-1554"><a href="#L-1554"><span class="linenos">1554</span></a> <span class="n">lock_type</span><span class="o">=</span><span class="n">lock_type</span><span class="p">,</span> -</span><span id="L-1555"><a href="#L-1555"><span class="linenos">1555</span></a> <span class="n">override</span><span class="o">=</span><span class="n">override</span><span class="p">,</span> -</span><span id="L-1556"><a href="#L-1556"><span class="linenos">1556</span></a> <span class="p">)</span> -</span><span id="L-1557"><a href="#L-1557"><span class="linenos">1557</span></a> -</span><span id="L-1558"><a href="#L-1558"><span class="linenos">1558</span></a> <span class="k">def</span> <span class="nf">_parse_partition_by</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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-1559"><a href="#L-1559"><span class="linenos">1559</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">PARTITION_BY</span><span class="p">):</span> -</span><span id="L-1560"><a href="#L-1560"><span class="linenos">1560</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="L-1561"><a href="#L-1561"><span class="linenos">1561</span></a> <span class="k">return</span> <span class="p">[]</span> -</span><span id="L-1562"><a href="#L-1562"><span class="linenos">1562</span></a> -</span><span id="L-1563"><a href="#L-1563"><span class="linenos">1563</span></a> <span class="k">def</span> <span class="nf">_parse_partitioned_by</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">PartitionedByProperty</span><span class="p">:</span> -</span><span id="L-1564"><a href="#L-1564"><span class="linenos">1564</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="L-1565"><a href="#L-1565"><span class="linenos">1565</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-1566"><a href="#L-1566"><span class="linenos">1566</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">,</span> -</span><span id="L-1567"><a href="#L-1567"><span class="linenos">1567</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bracket</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()),</span> -</span><span id="L-1568"><a href="#L-1568"><span class="linenos">1568</span></a> <span class="p">)</span> -</span><span id="L-1569"><a href="#L-1569"><span class="linenos">1569</span></a> -</span><span id="L-1570"><a href="#L-1570"><span class="linenos">1570</span></a> <span class="k">def</span> <span class="nf">_parse_withdata</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">no</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">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">:</span> -</span><span id="L-1571"><a href="#L-1571"><span class="linenos">1571</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AND"</span><span class="p">,</span> <span class="s2">"STATISTICS"</span><span class="p">):</span> -</span><span id="L-1572"><a href="#L-1572"><span class="linenos">1572</span></a> <span class="n">statistics</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-1573"><a href="#L-1573"><span class="linenos">1573</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AND"</span><span class="p">,</span> <span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"STATISTICS"</span><span class="p">):</span> -</span><span id="L-1574"><a href="#L-1574"><span class="linenos">1574</span></a> <span class="n">statistics</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-1575"><a href="#L-1575"><span class="linenos">1575</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1576"><a href="#L-1576"><span class="linenos">1576</span></a> <span class="n">statistics</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1577"><a href="#L-1577"><span class="linenos">1577</span></a> -</span><span id="L-1578"><a href="#L-1578"><span class="linenos">1578</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">WithDataProperty</span><span class="p">,</span> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">,</span> <span class="n">statistics</span><span class="o">=</span><span class="n">statistics</span><span class="p">)</span> -</span><span id="L-1579"><a href="#L-1579"><span class="linenos">1579</span></a> -</span><span id="L-1580"><a href="#L-1580"><span class="linenos">1580</span></a> <span class="k">def</span> <span class="nf">_parse_no_property</span><span class="p">(</span><span class="bp">self</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">NoPrimaryIndexProperty</span><span class="p">]:</span> -</span><span id="L-1581"><a href="#L-1581"><span class="linenos">1581</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PRIMARY"</span><span class="p">,</span> <span class="s2">"INDEX"</span><span class="p">):</span> -</span><span id="L-1582"><a href="#L-1582"><span class="linenos">1582</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">NoPrimaryIndexProperty</span><span class="p">()</span> -</span><span id="L-1583"><a href="#L-1583"><span class="linenos">1583</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-1584"><a href="#L-1584"><span class="linenos">1584</span></a> -</span><span id="L-1585"><a href="#L-1585"><span class="linenos">1585</span></a> <span class="k">def</span> <span class="nf">_parse_on_property</span><span class="p">(</span><span class="bp">self</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-1586"><a href="#L-1586"><span class="linenos">1586</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"COMMIT"</span><span class="p">,</span> <span class="s2">"PRESERVE"</span><span class="p">,</span> <span class="s2">"ROWS"</span><span class="p">):</span> -</span><span id="L-1587"><a href="#L-1587"><span class="linenos">1587</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</span><span class="p">()</span> -</span><span id="L-1588"><a href="#L-1588"><span class="linenos">1588</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"COMMIT"</span><span class="p">,</span> <span class="s2">"DELETE"</span><span class="p">,</span> <span class="s2">"ROWS"</span><span class="p">):</span> -</span><span id="L-1589"><a href="#L-1589"><span class="linenos">1589</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</span><span class="p">(</span><span class="n">delete</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1590"><a href="#L-1590"><span class="linenos">1590</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-1591"><a href="#L-1591"><span class="linenos">1591</span></a> -</span><span id="L-1592"><a href="#L-1592"><span class="linenos">1592</span></a> <span class="k">def</span> <span class="nf">_parse_distkey</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">DistKeyProperty</span><span class="p">:</span> -</span><span id="L-1593"><a href="#L-1593"><span class="linenos">1593</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">DistKeyProperty</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_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">))</span> -</span><span id="L-1594"><a href="#L-1594"><span class="linenos">1594</span></a> -</span><span id="L-1595"><a href="#L-1595"><span class="linenos">1595</span></a> <span class="k">def</span> <span class="nf">_parse_create_like</span><span class="p">(</span><span class="bp">self</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">LikeProperty</span><span class="p">]:</span> -</span><span id="L-1596"><a href="#L-1596"><span class="linenos">1596</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1597"><a href="#L-1597"><span class="linenos">1597</span></a> -</span><span id="L-1598"><a href="#L-1598"><span class="linenos">1598</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-1599"><a href="#L-1599"><span class="linenos">1599</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"INCLUDING"</span><span class="p">,</span> <span class="s2">"EXCLUDING"</span><span class="p">)):</span> -</span><span id="L-1600"><a href="#L-1600"><span class="linenos">1600</span></a> <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="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-1483"><a href="#L-1483"><span class="linenos">1483</span></a> <span class="n">autotemp</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1484"><a href="#L-1484"><span class="linenos">1484</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AUTOTEMP"</span><span class="p">):</span> +</span><span id="L-1485"><a href="#L-1485"><span class="linenos">1485</span></a> <span class="n">autotemp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</span><span class="p">()</span> +</span><span id="L-1486"><a href="#L-1486"><span class="linenos">1486</span></a> +</span><span id="L-1487"><a href="#L-1487"><span class="linenos">1487</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><span id="L-1488"><a href="#L-1488"><span class="linenos">1488</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">,</span> +</span><span id="L-1489"><a href="#L-1489"><span class="linenos">1489</span></a> <span class="n">always</span><span class="o">=</span><span class="n">always</span><span class="p">,</span> +</span><span id="L-1490"><a href="#L-1490"><span class="linenos">1490</span></a> <span class="n">manual</span><span class="o">=</span><span class="n">manual</span><span class="p">,</span> +</span><span id="L-1491"><a href="#L-1491"><span class="linenos">1491</span></a> <span class="n">never</span><span class="o">=</span><span class="n">never</span><span class="p">,</span> +</span><span id="L-1492"><a href="#L-1492"><span class="linenos">1492</span></a> <span class="n">default</span><span class="o">=</span><span class="n">default</span><span class="p">,</span> +</span><span id="L-1493"><a href="#L-1493"><span class="linenos">1493</span></a> <span class="n">autotemp</span><span class="o">=</span><span class="n">autotemp</span><span class="p">,</span> +</span><span id="L-1494"><a href="#L-1494"><span class="linenos">1494</span></a> <span class="p">)</span> +</span><span id="L-1495"><a href="#L-1495"><span class="linenos">1495</span></a> +</span><span id="L-1496"><a href="#L-1496"><span class="linenos">1496</span></a> <span class="k">def</span> <span class="nf">_parse_withisolatedloading</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">IsolatedLoadingProperty</span><span class="p">:</span> +</span><span id="L-1497"><a href="#L-1497"><span class="linenos">1497</span></a> <span class="n">no</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">)</span> +</span><span id="L-1498"><a href="#L-1498"><span class="linenos">1498</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CONCURRENT"</span><span class="p">)</span> +</span><span id="L-1499"><a href="#L-1499"><span class="linenos">1499</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ISOLATED"</span><span class="p">,</span> <span class="s2">"LOADING"</span><span class="p">)</span> +</span><span id="L-1500"><a href="#L-1500"><span class="linenos">1500</span></a> <span class="n">for_all</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"ALL"</span><span class="p">)</span> +</span><span id="L-1501"><a href="#L-1501"><span class="linenos">1501</span></a> <span class="n">for_insert</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"INSERT"</span><span class="p">)</span> +</span><span id="L-1502"><a href="#L-1502"><span class="linenos">1502</span></a> <span class="n">for_none</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"NONE"</span><span class="p">)</span> +</span><span id="L-1503"><a href="#L-1503"><span class="linenos">1503</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><span id="L-1504"><a href="#L-1504"><span class="linenos">1504</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">,</span> +</span><span id="L-1505"><a href="#L-1505"><span class="linenos">1505</span></a> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">,</span> +</span><span id="L-1506"><a href="#L-1506"><span class="linenos">1506</span></a> <span class="n">concurrent</span><span class="o">=</span><span class="n">concurrent</span><span class="p">,</span> +</span><span id="L-1507"><a href="#L-1507"><span class="linenos">1507</span></a> <span class="n">for_all</span><span class="o">=</span><span class="n">for_all</span><span class="p">,</span> +</span><span id="L-1508"><a href="#L-1508"><span class="linenos">1508</span></a> <span class="n">for_insert</span><span class="o">=</span><span class="n">for_insert</span><span class="p">,</span> +</span><span id="L-1509"><a href="#L-1509"><span class="linenos">1509</span></a> <span class="n">for_none</span><span class="o">=</span><span class="n">for_none</span><span class="p">,</span> +</span><span id="L-1510"><a href="#L-1510"><span class="linenos">1510</span></a> <span class="p">)</span> +</span><span id="L-1511"><a href="#L-1511"><span class="linenos">1511</span></a> +</span><span id="L-1512"><a href="#L-1512"><span class="linenos">1512</span></a> <span class="k">def</span> <span class="nf">_parse_locking</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">LockingProperty</span><span class="p">:</span> +</span><span id="L-1513"><a href="#L-1513"><span class="linenos">1513</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">TABLE</span><span class="p">):</span> +</span><span id="L-1514"><a href="#L-1514"><span class="linenos">1514</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">"TABLE"</span> +</span><span id="L-1515"><a href="#L-1515"><span class="linenos">1515</span></a> <span class="k">elif</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">VIEW</span><span class="p">):</span> +</span><span id="L-1516"><a href="#L-1516"><span class="linenos">1516</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">"VIEW"</span> +</span><span id="L-1517"><a href="#L-1517"><span class="linenos">1517</span></a> <span class="k">elif</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">ROW</span><span class="p">):</span> +</span><span id="L-1518"><a href="#L-1518"><span class="linenos">1518</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">"ROW"</span> +</span><span id="L-1519"><a href="#L-1519"><span class="linenos">1519</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DATABASE"</span><span class="p">):</span> +</span><span id="L-1520"><a href="#L-1520"><span class="linenos">1520</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">"DATABASE"</span> +</span><span id="L-1521"><a href="#L-1521"><span class="linenos">1521</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1522"><a href="#L-1522"><span class="linenos">1522</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1523"><a href="#L-1523"><span class="linenos">1523</span></a> +</span><span id="L-1524"><a href="#L-1524"><span class="linenos">1524</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"DATABASE"</span><span class="p">,</span> <span class="s2">"TABLE"</span><span class="p">,</span> <span class="s2">"VIEW"</span><span class="p">):</span> +</span><span id="L-1525"><a href="#L-1525"><span class="linenos">1525</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">()</span> +</span><span id="L-1526"><a href="#L-1526"><span class="linenos">1526</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1527"><a href="#L-1527"><span class="linenos">1527</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1528"><a href="#L-1528"><span class="linenos">1528</span></a> +</span><span id="L-1529"><a href="#L-1529"><span class="linenos">1529</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">FOR</span><span class="p">):</span> +</span><span id="L-1530"><a href="#L-1530"><span class="linenos">1530</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="s2">"FOR"</span> +</span><span id="L-1531"><a href="#L-1531"><span class="linenos">1531</span></a> <span class="k">elif</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">IN</span><span class="p">):</span> +</span><span id="L-1532"><a href="#L-1532"><span class="linenos">1532</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="s2">"IN"</span> +</span><span id="L-1533"><a href="#L-1533"><span class="linenos">1533</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1534"><a href="#L-1534"><span class="linenos">1534</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1535"><a href="#L-1535"><span class="linenos">1535</span></a> +</span><span id="L-1536"><a href="#L-1536"><span class="linenos">1536</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ACCESS"</span><span class="p">):</span> +</span><span id="L-1537"><a href="#L-1537"><span class="linenos">1537</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"ACCESS"</span> +</span><span id="L-1538"><a href="#L-1538"><span class="linenos">1538</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"EXCL"</span><span class="p">,</span> <span class="s2">"EXCLUSIVE"</span><span class="p">)):</span> +</span><span id="L-1539"><a href="#L-1539"><span class="linenos">1539</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"EXCLUSIVE"</span> +</span><span id="L-1540"><a href="#L-1540"><span class="linenos">1540</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SHARE"</span><span class="p">):</span> +</span><span id="L-1541"><a href="#L-1541"><span class="linenos">1541</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"SHARE"</span> +</span><span id="L-1542"><a href="#L-1542"><span class="linenos">1542</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"READ"</span><span class="p">):</span> +</span><span id="L-1543"><a href="#L-1543"><span class="linenos">1543</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"READ"</span> +</span><span id="L-1544"><a href="#L-1544"><span class="linenos">1544</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WRITE"</span><span class="p">):</span> +</span><span id="L-1545"><a href="#L-1545"><span class="linenos">1545</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"WRITE"</span> +</span><span id="L-1546"><a href="#L-1546"><span class="linenos">1546</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CHECKSUM"</span><span class="p">):</span> +</span><span id="L-1547"><a href="#L-1547"><span class="linenos">1547</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"CHECKSUM"</span> +</span><span id="L-1548"><a href="#L-1548"><span class="linenos">1548</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1549"><a href="#L-1549"><span class="linenos">1549</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1550"><a href="#L-1550"><span class="linenos">1550</span></a> +</span><span id="L-1551"><a href="#L-1551"><span class="linenos">1551</span></a> <span class="n">override</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OVERRIDE"</span><span class="p">)</span> +</span><span id="L-1552"><a href="#L-1552"><span class="linenos">1552</span></a> +</span><span id="L-1553"><a href="#L-1553"><span class="linenos">1553</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-1554"><a href="#L-1554"><span class="linenos">1554</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">,</span> +</span><span id="L-1555"><a href="#L-1555"><span class="linenos">1555</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-1556"><a href="#L-1556"><span class="linenos">1556</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> +</span><span id="L-1557"><a href="#L-1557"><span class="linenos">1557</span></a> <span class="n">for_or_in</span><span class="o">=</span><span class="n">for_or_in</span><span class="p">,</span> +</span><span id="L-1558"><a href="#L-1558"><span class="linenos">1558</span></a> <span class="n">lock_type</span><span class="o">=</span><span class="n">lock_type</span><span class="p">,</span> +</span><span id="L-1559"><a href="#L-1559"><span class="linenos">1559</span></a> <span class="n">override</span><span class="o">=</span><span class="n">override</span><span class="p">,</span> +</span><span id="L-1560"><a href="#L-1560"><span class="linenos">1560</span></a> <span class="p">)</span> +</span><span id="L-1561"><a href="#L-1561"><span class="linenos">1561</span></a> +</span><span id="L-1562"><a href="#L-1562"><span class="linenos">1562</span></a> <span class="k">def</span> <span class="nf">_parse_partition_by</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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-1563"><a href="#L-1563"><span class="linenos">1563</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">PARTITION_BY</span><span class="p">):</span> +</span><span id="L-1564"><a href="#L-1564"><span class="linenos">1564</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="L-1565"><a href="#L-1565"><span class="linenos">1565</span></a> <span class="k">return</span> <span class="p">[]</span> +</span><span id="L-1566"><a href="#L-1566"><span class="linenos">1566</span></a> +</span><span id="L-1567"><a href="#L-1567"><span class="linenos">1567</span></a> <span class="k">def</span> <span class="nf">_parse_partitioned_by</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">PartitionedByProperty</span><span class="p">:</span> +</span><span id="L-1568"><a href="#L-1568"><span class="linenos">1568</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="L-1569"><a href="#L-1569"><span class="linenos">1569</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-1570"><a href="#L-1570"><span class="linenos">1570</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">,</span> +</span><span id="L-1571"><a href="#L-1571"><span class="linenos">1571</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bracket</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()),</span> +</span><span id="L-1572"><a href="#L-1572"><span class="linenos">1572</span></a> <span class="p">)</span> +</span><span id="L-1573"><a href="#L-1573"><span class="linenos">1573</span></a> +</span><span id="L-1574"><a href="#L-1574"><span class="linenos">1574</span></a> <span class="k">def</span> <span class="nf">_parse_withdata</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">no</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">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">:</span> +</span><span id="L-1575"><a href="#L-1575"><span class="linenos">1575</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AND"</span><span class="p">,</span> <span class="s2">"STATISTICS"</span><span class="p">):</span> +</span><span id="L-1576"><a href="#L-1576"><span class="linenos">1576</span></a> <span class="n">statistics</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-1577"><a href="#L-1577"><span class="linenos">1577</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AND"</span><span class="p">,</span> <span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"STATISTICS"</span><span class="p">):</span> +</span><span id="L-1578"><a href="#L-1578"><span class="linenos">1578</span></a> <span class="n">statistics</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-1579"><a href="#L-1579"><span class="linenos">1579</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1580"><a href="#L-1580"><span class="linenos">1580</span></a> <span class="n">statistics</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1581"><a href="#L-1581"><span class="linenos">1581</span></a> +</span><span id="L-1582"><a href="#L-1582"><span class="linenos">1582</span></a> <span class="k">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">WithDataProperty</span><span class="p">,</span> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">,</span> <span class="n">statistics</span><span class="o">=</span><span class="n">statistics</span><span class="p">)</span> +</span><span id="L-1583"><a href="#L-1583"><span class="linenos">1583</span></a> +</span><span id="L-1584"><a href="#L-1584"><span class="linenos">1584</span></a> <span class="k">def</span> <span class="nf">_parse_no_property</span><span class="p">(</span><span class="bp">self</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">NoPrimaryIndexProperty</span><span class="p">]:</span> +</span><span id="L-1585"><a href="#L-1585"><span class="linenos">1585</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PRIMARY"</span><span class="p">,</span> <span class="s2">"INDEX"</span><span class="p">):</span> +</span><span id="L-1586"><a href="#L-1586"><span class="linenos">1586</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">NoPrimaryIndexProperty</span><span class="p">()</span> +</span><span id="L-1587"><a href="#L-1587"><span class="linenos">1587</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1588"><a href="#L-1588"><span class="linenos">1588</span></a> +</span><span id="L-1589"><a href="#L-1589"><span class="linenos">1589</span></a> <span class="k">def</span> <span class="nf">_parse_on_property</span><span class="p">(</span><span class="bp">self</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-1590"><a href="#L-1590"><span class="linenos">1590</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"COMMIT"</span><span class="p">,</span> <span class="s2">"PRESERVE"</span><span class="p">,</span> <span class="s2">"ROWS"</span><span class="p">):</span> +</span><span id="L-1591"><a href="#L-1591"><span class="linenos">1591</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</span><span class="p">()</span> +</span><span id="L-1592"><a href="#L-1592"><span class="linenos">1592</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"COMMIT"</span><span class="p">,</span> <span class="s2">"DELETE"</span><span class="p">,</span> <span class="s2">"ROWS"</span><span class="p">):</span> +</span><span id="L-1593"><a href="#L-1593"><span class="linenos">1593</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</span><span class="p">(</span><span class="n">delete</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1594"><a href="#L-1594"><span class="linenos">1594</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1595"><a href="#L-1595"><span class="linenos">1595</span></a> +</span><span id="L-1596"><a href="#L-1596"><span class="linenos">1596</span></a> <span class="k">def</span> <span class="nf">_parse_distkey</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">DistKeyProperty</span><span class="p">:</span> +</span><span id="L-1597"><a href="#L-1597"><span class="linenos">1597</span></a> <span class="k">return</span> <span class="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">DistKeyProperty</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_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">))</span> +</span><span id="L-1598"><a href="#L-1598"><span class="linenos">1598</span></a> +</span><span id="L-1599"><a href="#L-1599"><span class="linenos">1599</span></a> <span class="k">def</span> <span class="nf">_parse_create_like</span><span class="p">(</span><span class="bp">self</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">LikeProperty</span><span class="p">]:</span> +</span><span id="L-1600"><a href="#L-1600"><span class="linenos">1600</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span><span id="L-1601"><a href="#L-1601"><span class="linenos">1601</span></a> -</span><span id="L-1602"><a href="#L-1602"><span class="linenos">1602</span></a> <span class="n">id_var</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="L-1603"><a href="#L-1603"><span class="linenos">1603</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">id_var</span><span class="p">:</span> -</span><span id="L-1604"><a href="#L-1604"><span class="linenos">1604</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1602"><a href="#L-1602"><span class="linenos">1602</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-1603"><a href="#L-1603"><span class="linenos">1603</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"INCLUDING"</span><span class="p">,</span> <span class="s2">"EXCLUDING"</span><span class="p">)):</span> +</span><span id="L-1604"><a href="#L-1604"><span class="linenos">1604</span></a> <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="o">.</span><span class="n">upper</span><span class="p">()</span> </span><span id="L-1605"><a href="#L-1605"><span class="linenos">1605</span></a> -</span><span id="L-1606"><a href="#L-1606"><span class="linenos">1606</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="L-1607"><a href="#L-1607"><span class="linenos">1607</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">Property</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">value</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="n">id_var</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">upper</span><span class="p">()))</span> -</span><span id="L-1608"><a href="#L-1608"><span class="linenos">1608</span></a> <span class="p">)</span> +</span><span id="L-1606"><a href="#L-1606"><span class="linenos">1606</span></a> <span class="n">id_var</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="L-1607"><a href="#L-1607"><span class="linenos">1607</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">id_var</span><span class="p">:</span> +</span><span id="L-1608"><a href="#L-1608"><span class="linenos">1608</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="L-1609"><a href="#L-1609"><span class="linenos">1609</span></a> -</span><span id="L-1610"><a href="#L-1610"><span class="linenos">1610</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">LikeProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">options</span><span class="p">)</span> -</span><span id="L-1611"><a href="#L-1611"><span class="linenos">1611</span></a> -</span><span id="L-1612"><a href="#L-1612"><span class="linenos">1612</span></a> <span class="k">def</span> <span class="nf">_parse_sortkey</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">compound</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">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> -</span><span id="L-1613"><a href="#L-1613"><span class="linenos">1613</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><span id="L-1614"><a href="#L-1614"><span class="linenos">1614</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</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_wrapped_id_vars</span><span class="p">(),</span> <span class="n">compound</span><span class="o">=</span><span class="n">compound</span> -</span><span id="L-1615"><a href="#L-1615"><span class="linenos">1615</span></a> <span class="p">)</span> -</span><span id="L-1616"><a href="#L-1616"><span class="linenos">1616</span></a> -</span><span id="L-1617"><a href="#L-1617"><span class="linenos">1617</span></a> <span class="k">def</span> <span class="nf">_parse_character_set</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">default</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">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</span><span class="p">:</span> -</span><span id="L-1618"><a href="#L-1618"><span class="linenos">1618</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="L-1619"><a href="#L-1619"><span class="linenos">1619</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-1620"><a href="#L-1620"><span class="linenos">1620</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</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_var_or_string</span><span class="p">(),</span> <span class="n">default</span><span class="o">=</span><span class="n">default</span> -</span><span id="L-1621"><a href="#L-1621"><span class="linenos">1621</span></a> <span class="p">)</span> -</span><span id="L-1622"><a href="#L-1622"><span class="linenos">1622</span></a> -</span><span id="L-1623"><a href="#L-1623"><span class="linenos">1623</span></a> <span class="k">def</span> <span class="nf">_parse_returns</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">ReturnsProperty</span><span class="p">:</span> -</span><span id="L-1624"><a href="#L-1624"><span class="linenos">1624</span></a> <span class="n">value</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><span id="L-1625"><a href="#L-1625"><span class="linenos">1625</span></a> <span class="n">is_table</span> <span class="o">=</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">TABLE</span><span class="p">)</span> +</span><span id="L-1610"><a href="#L-1610"><span class="linenos">1610</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="L-1611"><a href="#L-1611"><span class="linenos">1611</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">Property</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">value</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="n">id_var</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">upper</span><span class="p">()))</span> +</span><span id="L-1612"><a href="#L-1612"><span class="linenos">1612</span></a> <span class="p">)</span> +</span><span id="L-1613"><a href="#L-1613"><span class="linenos">1613</span></a> +</span><span id="L-1614"><a href="#L-1614"><span class="linenos">1614</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">LikeProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">options</span><span class="p">)</span> +</span><span id="L-1615"><a href="#L-1615"><span class="linenos">1615</span></a> +</span><span id="L-1616"><a href="#L-1616"><span class="linenos">1616</span></a> <span class="k">def</span> <span class="nf">_parse_sortkey</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">compound</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">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> +</span><span id="L-1617"><a href="#L-1617"><span class="linenos">1617</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><span id="L-1618"><a href="#L-1618"><span class="linenos">1618</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</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_wrapped_id_vars</span><span class="p">(),</span> <span class="n">compound</span><span class="o">=</span><span class="n">compound</span> +</span><span id="L-1619"><a href="#L-1619"><span class="linenos">1619</span></a> <span class="p">)</span> +</span><span id="L-1620"><a href="#L-1620"><span class="linenos">1620</span></a> +</span><span id="L-1621"><a href="#L-1621"><span class="linenos">1621</span></a> <span class="k">def</span> <span class="nf">_parse_character_set</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">default</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">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</span><span class="p">:</span> +</span><span id="L-1622"><a href="#L-1622"><span class="linenos">1622</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="L-1623"><a href="#L-1623"><span class="linenos">1623</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><span id="L-1624"><a href="#L-1624"><span class="linenos">1624</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</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_var_or_string</span><span class="p">(),</span> <span class="n">default</span><span class="o">=</span><span class="n">default</span> +</span><span id="L-1625"><a href="#L-1625"><span class="linenos">1625</span></a> <span class="p">)</span> </span><span id="L-1626"><a href="#L-1626"><span class="linenos">1626</span></a> -</span><span id="L-1627"><a href="#L-1627"><span class="linenos">1627</span></a> <span class="k">if</span> <span class="n">is_table</span><span class="p">:</span> -</span><span id="L-1628"><a href="#L-1628"><span class="linenos">1628</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">LT</span><span class="p">):</span> -</span><span id="L-1629"><a href="#L-1629"><span class="linenos">1629</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-1630"><a href="#L-1630"><span class="linenos">1630</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">,</span> -</span><span id="L-1631"><a href="#L-1631"><span class="linenos">1631</span></a> <span class="n">this</span><span class="o">=</span><span class="s2">"TABLE"</span><span class="p">,</span> -</span><span id="L-1632"><a href="#L-1632"><span class="linenos">1632</span></a> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_struct_types</span><span class="p">),</span> -</span><span id="L-1633"><a href="#L-1633"><span class="linenos">1633</span></a> <span class="p">)</span> -</span><span id="L-1634"><a href="#L-1634"><span class="linenos">1634</span></a> <span class="k">if</span> <span class="ow">not</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">GT</span><span class="p">):</span> -</span><span id="L-1635"><a href="#L-1635"><span class="linenos">1635</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting >"</span><span class="p">)</span> -</span><span id="L-1636"><a href="#L-1636"><span class="linenos">1636</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1637"><a href="#L-1637"><span class="linenos">1637</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</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">"TABLE"</span><span class="p">))</span> -</span><span id="L-1638"><a href="#L-1638"><span class="linenos">1638</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1639"><a href="#L-1639"><span class="linenos">1639</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">()</span> -</span><span id="L-1640"><a href="#L-1640"><span class="linenos">1640</span></a> -</span><span id="L-1641"><a href="#L-1641"><span class="linenos">1641</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">ReturnsProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">value</span><span class="p">,</span> <span class="n">is_table</span><span class="o">=</span><span class="n">is_table</span><span class="p">)</span> -</span><span id="L-1642"><a href="#L-1642"><span class="linenos">1642</span></a> -</span><span id="L-1643"><a href="#L-1643"><span class="linenos">1643</span></a> <span class="k">def</span> <span class="nf">_parse_describe</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">Describe</span><span class="p">:</span> -</span><span id="L-1644"><a href="#L-1644"><span class="linenos">1644</span></a> <span class="n">kind</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</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><span id="L-1645"><a href="#L-1645"><span class="linenos">1645</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> -</span><span id="L-1646"><a href="#L-1646"><span class="linenos">1646</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">Describe</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">)</span> -</span><span id="L-1647"><a href="#L-1647"><span class="linenos">1647</span></a> -</span><span id="L-1648"><a href="#L-1648"><span class="linenos">1648</span></a> <span class="k">def</span> <span class="nf">_parse_insert</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">Insert</span><span class="p">:</span> -</span><span id="L-1649"><a href="#L-1649"><span class="linenos">1649</span></a> <span class="n">overwrite</span> <span class="o">=</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">OVERWRITE</span><span class="p">)</span> -</span><span id="L-1650"><a href="#L-1650"><span class="linenos">1650</span></a> <span class="n">local</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LOCAL"</span><span class="p">)</span> -</span><span id="L-1651"><a href="#L-1651"><span class="linenos">1651</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1652"><a href="#L-1652"><span class="linenos">1652</span></a> -</span><span id="L-1653"><a href="#L-1653"><span class="linenos">1653</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DIRECTORY"</span><span class="p">):</span> -</span><span id="L-1654"><a href="#L-1654"><span class="linenos">1654</span></a> <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="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-1655"><a href="#L-1655"><span class="linenos">1655</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">,</span> -</span><span id="L-1656"><a href="#L-1656"><span class="linenos">1656</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_var_or_string</span><span class="p">(),</span> -</span><span id="L-1657"><a href="#L-1657"><span class="linenos">1657</span></a> <span class="n">local</span><span class="o">=</span><span class="n">local</span><span class="p">,</span> -</span><span id="L-1658"><a href="#L-1658"><span class="linenos">1658</span></a> <span class="n">row_format</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_row_format</span><span class="p">(</span><span class="n">match_row</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="L-1659"><a href="#L-1659"><span class="linenos">1659</span></a> <span class="p">)</span> -</span><span id="L-1660"><a href="#L-1660"><span class="linenos">1660</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1661"><a href="#L-1661"><span class="linenos">1661</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">OR</span><span class="p">):</span> -</span><span id="L-1662"><a href="#L-1662"><span class="linenos">1662</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">INSERT_ALTERNATIVES</span><span class="p">)</span> <span class="ow">and</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><span id="L-1663"><a href="#L-1663"><span class="linenos">1663</span></a> -</span><span id="L-1664"><a href="#L-1664"><span class="linenos">1664</span></a> <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">INTO</span><span class="p">)</span> -</span><span id="L-1665"><a href="#L-1665"><span class="linenos">1665</span></a> <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">TABLE</span><span class="p">)</span> -</span><span id="L-1666"><a href="#L-1666"><span class="linenos">1666</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1627"><a href="#L-1627"><span class="linenos">1627</span></a> <span class="k">def</span> <span class="nf">_parse_returns</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">ReturnsProperty</span><span class="p">:</span> +</span><span id="L-1628"><a href="#L-1628"><span class="linenos">1628</span></a> <span class="n">value</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><span id="L-1629"><a href="#L-1629"><span class="linenos">1629</span></a> <span class="n">is_table</span> <span class="o">=</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">TABLE</span><span class="p">)</span> +</span><span id="L-1630"><a href="#L-1630"><span class="linenos">1630</span></a> +</span><span id="L-1631"><a href="#L-1631"><span class="linenos">1631</span></a> <span class="k">if</span> <span class="n">is_table</span><span class="p">:</span> +</span><span id="L-1632"><a href="#L-1632"><span class="linenos">1632</span></a> <span class="k">if</span> <span class="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">LT</span><span class="p">):</span> +</span><span id="L-1633"><a href="#L-1633"><span class="linenos">1633</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-1634"><a href="#L-1634"><span class="linenos">1634</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">,</span> +</span><span id="L-1635"><a href="#L-1635"><span class="linenos">1635</span></a> <span class="n">this</span><span class="o">=</span><span class="s2">"TABLE"</span><span class="p">,</span> +</span><span id="L-1636"><a href="#L-1636"><span class="linenos">1636</span></a> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_struct_types</span><span class="p">),</span> +</span><span id="L-1637"><a href="#L-1637"><span class="linenos">1637</span></a> <span class="p">)</span> +</span><span id="L-1638"><a href="#L-1638"><span class="linenos">1638</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">GT</span><span class="p">):</span> +</span><span id="L-1639"><a href="#L-1639"><span class="linenos">1639</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting >"</span><span class="p">)</span> +</span><span id="L-1640"><a href="#L-1640"><span class="linenos">1640</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1641"><a href="#L-1641"><span class="linenos">1641</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</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">"TABLE"</span><span class="p">))</span> +</span><span id="L-1642"><a href="#L-1642"><span class="linenos">1642</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1643"><a href="#L-1643"><span class="linenos">1643</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">()</span> +</span><span id="L-1644"><a href="#L-1644"><span class="linenos">1644</span></a> +</span><span id="L-1645"><a href="#L-1645"><span class="linenos">1645</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">ReturnsProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">value</span><span class="p">,</span> <span class="n">is_table</span><span class="o">=</span><span class="n">is_table</span><span class="p">)</span> +</span><span id="L-1646"><a href="#L-1646"><span class="linenos">1646</span></a> +</span><span id="L-1647"><a href="#L-1647"><span class="linenos">1647</span></a> <span class="k">def</span> <span class="nf">_parse_describe</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">Describe</span><span class="p">:</span> +</span><span id="L-1648"><a href="#L-1648"><span class="linenos">1648</span></a> <span class="n">kind</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</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><span id="L-1649"><a href="#L-1649"><span class="linenos">1649</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> +</span><span id="L-1650"><a href="#L-1650"><span class="linenos">1650</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">Describe</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">)</span> +</span><span id="L-1651"><a href="#L-1651"><span class="linenos">1651</span></a> +</span><span id="L-1652"><a href="#L-1652"><span class="linenos">1652</span></a> <span class="k">def</span> <span class="nf">_parse_insert</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">Insert</span><span class="p">:</span> +</span><span id="L-1653"><a href="#L-1653"><span class="linenos">1653</span></a> <span class="n">overwrite</span> <span class="o">=</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">OVERWRITE</span><span class="p">)</span> +</span><span id="L-1654"><a href="#L-1654"><span class="linenos">1654</span></a> <span class="n">local</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LOCAL"</span><span class="p">)</span> +</span><span id="L-1655"><a href="#L-1655"><span class="linenos">1655</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1656"><a href="#L-1656"><span class="linenos">1656</span></a> +</span><span id="L-1657"><a href="#L-1657"><span class="linenos">1657</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DIRECTORY"</span><span class="p">):</span> +</span><span id="L-1658"><a href="#L-1658"><span class="linenos">1658</span></a> <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="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-1659"><a href="#L-1659"><span class="linenos">1659</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">,</span> +</span><span id="L-1660"><a href="#L-1660"><span class="linenos">1660</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_var_or_string</span><span class="p">(),</span> +</span><span id="L-1661"><a href="#L-1661"><span class="linenos">1661</span></a> <span class="n">local</span><span class="o">=</span><span class="n">local</span><span class="p">,</span> +</span><span id="L-1662"><a href="#L-1662"><span class="linenos">1662</span></a> <span class="n">row_format</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_row_format</span><span class="p">(</span><span class="n">match_row</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="L-1663"><a href="#L-1663"><span class="linenos">1663</span></a> <span class="p">)</span> +</span><span id="L-1664"><a href="#L-1664"><span class="linenos">1664</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1665"><a href="#L-1665"><span class="linenos">1665</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">OR</span><span class="p">):</span> +</span><span id="L-1666"><a href="#L-1666"><span class="linenos">1666</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">INSERT_ALTERNATIVES</span><span class="p">)</span> <span class="ow">and</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><span id="L-1667"><a href="#L-1667"><span class="linenos">1667</span></a> -</span><span id="L-1668"><a href="#L-1668"><span class="linenos">1668</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><span id="L-1669"><a href="#L-1669"><span class="linenos">1669</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">,</span> -</span><span id="L-1670"><a href="#L-1670"><span class="linenos">1670</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-1671"><a href="#L-1671"><span class="linenos">1671</span></a> <span class="n">exists</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">(),</span> -</span><span id="L-1672"><a href="#L-1672"><span class="linenos">1672</span></a> <span class="n">partition</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition</span><span class="p">(),</span> -</span><span id="L-1673"><a href="#L-1673"><span class="linenos">1673</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_ddl_select</span><span class="p">(),</span> -</span><span id="L-1674"><a href="#L-1674"><span class="linenos">1674</span></a> <span class="n">conflict</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_on_conflict</span><span class="p">(),</span> -</span><span id="L-1675"><a href="#L-1675"><span class="linenos">1675</span></a> <span class="n">returning</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_returning</span><span class="p">(),</span> -</span><span id="L-1676"><a href="#L-1676"><span class="linenos">1676</span></a> <span class="n">overwrite</span><span class="o">=</span><span class="n">overwrite</span><span class="p">,</span> -</span><span id="L-1677"><a href="#L-1677"><span class="linenos">1677</span></a> <span class="n">alternative</span><span class="o">=</span><span class="n">alternative</span><span class="p">,</span> -</span><span id="L-1678"><a href="#L-1678"><span class="linenos">1678</span></a> <span class="p">)</span> -</span><span id="L-1679"><a href="#L-1679"><span class="linenos">1679</span></a> -</span><span id="L-1680"><a href="#L-1680"><span class="linenos">1680</span></a> <span class="k">def</span> <span class="nf">_parse_on_conflict</span><span class="p">(</span><span class="bp">self</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">OnConflict</span><span class="p">]:</span> -</span><span id="L-1681"><a href="#L-1681"><span class="linenos">1681</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"CONFLICT"</span><span class="p">)</span> -</span><span id="L-1682"><a href="#L-1682"><span class="linenos">1682</span></a> <span class="n">duplicate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"DUPLICATE"</span><span class="p">,</span> <span class="s2">"KEY"</span><span class="p">)</span> +</span><span id="L-1668"><a href="#L-1668"><span class="linenos">1668</span></a> <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">INTO</span><span class="p">)</span> +</span><span id="L-1669"><a href="#L-1669"><span class="linenos">1669</span></a> <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">TABLE</span><span class="p">)</span> +</span><span id="L-1670"><a href="#L-1670"><span class="linenos">1670</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1671"><a href="#L-1671"><span class="linenos">1671</span></a> +</span><span id="L-1672"><a href="#L-1672"><span class="linenos">1672</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><span id="L-1673"><a href="#L-1673"><span class="linenos">1673</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">,</span> +</span><span id="L-1674"><a href="#L-1674"><span class="linenos">1674</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-1675"><a href="#L-1675"><span class="linenos">1675</span></a> <span class="n">exists</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">(),</span> +</span><span id="L-1676"><a href="#L-1676"><span class="linenos">1676</span></a> <span class="n">partition</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition</span><span class="p">(),</span> +</span><span id="L-1677"><a href="#L-1677"><span class="linenos">1677</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_ddl_select</span><span class="p">(),</span> +</span><span id="L-1678"><a href="#L-1678"><span class="linenos">1678</span></a> <span class="n">conflict</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_on_conflict</span><span class="p">(),</span> +</span><span id="L-1679"><a href="#L-1679"><span class="linenos">1679</span></a> <span class="n">returning</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_returning</span><span class="p">(),</span> +</span><span id="L-1680"><a href="#L-1680"><span class="linenos">1680</span></a> <span class="n">overwrite</span><span class="o">=</span><span class="n">overwrite</span><span class="p">,</span> +</span><span id="L-1681"><a href="#L-1681"><span class="linenos">1681</span></a> <span class="n">alternative</span><span class="o">=</span><span class="n">alternative</span><span class="p">,</span> +</span><span id="L-1682"><a href="#L-1682"><span class="linenos">1682</span></a> <span class="p">)</span> </span><span id="L-1683"><a href="#L-1683"><span class="linenos">1683</span></a> -</span><span id="L-1684"><a href="#L-1684"><span class="linenos">1684</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">conflict</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">duplicate</span><span class="p">:</span> -</span><span id="L-1685"><a href="#L-1685"><span class="linenos">1685</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-1686"><a href="#L-1686"><span class="linenos">1686</span></a> -</span><span id="L-1687"><a href="#L-1687"><span class="linenos">1687</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1688"><a href="#L-1688"><span class="linenos">1688</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1689"><a href="#L-1689"><span class="linenos">1689</span></a> <span class="n">key</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1690"><a href="#L-1690"><span class="linenos">1690</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1691"><a href="#L-1691"><span class="linenos">1691</span></a> -</span><span id="L-1692"><a href="#L-1692"><span class="linenos">1692</span></a> <span class="k">if</span> <span class="n">conflict</span><span class="p">:</span> -</span><span id="L-1693"><a href="#L-1693"><span class="linenos">1693</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"CONSTRAINT"</span><span class="p">):</span> -</span><span id="L-1694"><a href="#L-1694"><span class="linenos">1694</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="L-1695"><a href="#L-1695"><span class="linenos">1695</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1696"><a href="#L-1696"><span class="linenos">1696</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">)</span> -</span><span id="L-1697"><a href="#L-1697"><span class="linenos">1697</span></a> -</span><span id="L-1698"><a href="#L-1698"><span class="linenos">1698</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DO"</span><span class="p">)</span> -</span><span id="L-1699"><a href="#L-1699"><span class="linenos">1699</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NOTHING"</span><span class="p">):</span> -</span><span id="L-1700"><a href="#L-1700"><span class="linenos">1700</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-1701"><a href="#L-1701"><span class="linenos">1701</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1702"><a href="#L-1702"><span class="linenos">1702</span></a> <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">UPDATE</span><span class="p">)</span> -</span><span id="L-1703"><a href="#L-1703"><span class="linenos">1703</span></a> <span class="n">expressions</span> <span class="o">=</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">SET</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">)</span> -</span><span id="L-1704"><a href="#L-1704"><span class="linenos">1704</span></a> -</span><span id="L-1705"><a href="#L-1705"><span class="linenos">1705</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><span id="L-1706"><a href="#L-1706"><span class="linenos">1706</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnConflict</span><span class="p">,</span> -</span><span id="L-1707"><a href="#L-1707"><span class="linenos">1707</span></a> <span class="n">duplicate</span><span class="o">=</span><span class="n">duplicate</span><span class="p">,</span> -</span><span id="L-1708"><a href="#L-1708"><span class="linenos">1708</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-1709"><a href="#L-1709"><span class="linenos">1709</span></a> <span class="n">nothing</span><span class="o">=</span><span class="n">nothing</span><span class="p">,</span> -</span><span id="L-1710"><a href="#L-1710"><span class="linenos">1710</span></a> <span class="n">key</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> -</span><span id="L-1711"><a href="#L-1711"><span class="linenos">1711</span></a> <span class="n">constraint</span><span class="o">=</span><span class="n">constraint</span><span class="p">,</span> -</span><span id="L-1712"><a href="#L-1712"><span class="linenos">1712</span></a> <span class="p">)</span> -</span><span id="L-1713"><a href="#L-1713"><span class="linenos">1713</span></a> -</span><span id="L-1714"><a href="#L-1714"><span class="linenos">1714</span></a> <span class="k">def</span> <span class="nf">_parse_returning</span><span class="p">(</span><span class="bp">self</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">Returning</span><span class="p">]:</span> -</span><span id="L-1715"><a href="#L-1715"><span class="linenos">1715</span></a> <span class="k">if</span> <span class="ow">not</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">RETURNING</span><span class="p">):</span> -</span><span id="L-1716"><a href="#L-1716"><span class="linenos">1716</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1684"><a href="#L-1684"><span class="linenos">1684</span></a> <span class="k">def</span> <span class="nf">_parse_on_conflict</span><span class="p">(</span><span class="bp">self</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">OnConflict</span><span class="p">]:</span> +</span><span id="L-1685"><a href="#L-1685"><span class="linenos">1685</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"CONFLICT"</span><span class="p">)</span> +</span><span id="L-1686"><a href="#L-1686"><span class="linenos">1686</span></a> <span class="n">duplicate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"DUPLICATE"</span><span class="p">,</span> <span class="s2">"KEY"</span><span class="p">)</span> +</span><span id="L-1687"><a href="#L-1687"><span class="linenos">1687</span></a> +</span><span id="L-1688"><a href="#L-1688"><span class="linenos">1688</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">conflict</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">duplicate</span><span class="p">:</span> +</span><span id="L-1689"><a href="#L-1689"><span class="linenos">1689</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1690"><a href="#L-1690"><span class="linenos">1690</span></a> +</span><span id="L-1691"><a href="#L-1691"><span class="linenos">1691</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1692"><a href="#L-1692"><span class="linenos">1692</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1693"><a href="#L-1693"><span class="linenos">1693</span></a> <span class="n">key</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1694"><a href="#L-1694"><span class="linenos">1694</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1695"><a href="#L-1695"><span class="linenos">1695</span></a> +</span><span id="L-1696"><a href="#L-1696"><span class="linenos">1696</span></a> <span class="k">if</span> <span class="n">conflict</span><span class="p">:</span> +</span><span id="L-1697"><a href="#L-1697"><span class="linenos">1697</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"CONSTRAINT"</span><span class="p">):</span> +</span><span id="L-1698"><a href="#L-1698"><span class="linenos">1698</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="L-1699"><a href="#L-1699"><span class="linenos">1699</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1700"><a href="#L-1700"><span class="linenos">1700</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">)</span> +</span><span id="L-1701"><a href="#L-1701"><span class="linenos">1701</span></a> +</span><span id="L-1702"><a href="#L-1702"><span class="linenos">1702</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DO"</span><span class="p">)</span> +</span><span id="L-1703"><a href="#L-1703"><span class="linenos">1703</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NOTHING"</span><span class="p">):</span> +</span><span id="L-1704"><a href="#L-1704"><span class="linenos">1704</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-1705"><a href="#L-1705"><span class="linenos">1705</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1706"><a href="#L-1706"><span class="linenos">1706</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">UPDATE</span><span class="p">)</span> +</span><span id="L-1707"><a href="#L-1707"><span class="linenos">1707</span></a> <span class="n">expressions</span> <span class="o">=</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">SET</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">)</span> +</span><span id="L-1708"><a href="#L-1708"><span class="linenos">1708</span></a> +</span><span id="L-1709"><a href="#L-1709"><span class="linenos">1709</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><span id="L-1710"><a href="#L-1710"><span class="linenos">1710</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnConflict</span><span class="p">,</span> +</span><span id="L-1711"><a href="#L-1711"><span class="linenos">1711</span></a> <span class="n">duplicate</span><span class="o">=</span><span class="n">duplicate</span><span class="p">,</span> +</span><span id="L-1712"><a href="#L-1712"><span class="linenos">1712</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-1713"><a href="#L-1713"><span class="linenos">1713</span></a> <span class="n">nothing</span><span class="o">=</span><span class="n">nothing</span><span class="p">,</span> +</span><span id="L-1714"><a href="#L-1714"><span class="linenos">1714</span></a> <span class="n">key</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> +</span><span id="L-1715"><a href="#L-1715"><span class="linenos">1715</span></a> <span class="n">constraint</span><span class="o">=</span><span class="n">constraint</span><span class="p">,</span> +</span><span id="L-1716"><a href="#L-1716"><span class="linenos">1716</span></a> <span class="p">)</span> </span><span id="L-1717"><a href="#L-1717"><span class="linenos">1717</span></a> -</span><span id="L-1718"><a href="#L-1718"><span class="linenos">1718</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">Returning</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">))</span> -</span><span id="L-1719"><a href="#L-1719"><span class="linenos">1719</span></a> -</span><span id="L-1720"><a href="#L-1720"><span class="linenos">1720</span></a> <span class="k">def</span> <span class="nf">_parse_row</span><span class="p">(</span><span class="bp">self</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">RowFormatSerdeProperty</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">]:</span> -</span><span id="L-1721"><a href="#L-1721"><span class="linenos">1721</span></a> <span class="k">if</span> <span class="ow">not</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">FORMAT</span><span class="p">):</span> -</span><span id="L-1722"><a href="#L-1722"><span class="linenos">1722</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-1723"><a href="#L-1723"><span class="linenos">1723</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_row_format</span><span class="p">()</span> -</span><span id="L-1724"><a href="#L-1724"><span class="linenos">1724</span></a> -</span><span id="L-1725"><a href="#L-1725"><span class="linenos">1725</span></a> <span class="k">def</span> <span class="nf">_parse_row_format</span><span class="p">(</span> -</span><span id="L-1726"><a href="#L-1726"><span class="linenos">1726</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">match_row</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-1727"><a href="#L-1727"><span class="linenos">1727</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">RowFormatSerdeProperty</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">]:</span> -</span><span id="L-1728"><a href="#L-1728"><span class="linenos">1728</span></a> <span class="k">if</span> <span class="n">match_row</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FORMAT</span><span class="p">):</span> -</span><span id="L-1729"><a href="#L-1729"><span class="linenos">1729</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-1730"><a href="#L-1730"><span class="linenos">1730</span></a> -</span><span id="L-1731"><a href="#L-1731"><span class="linenos">1731</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SERDE"</span><span class="p">):</span> -</span><span id="L-1732"><a href="#L-1732"><span class="linenos">1732</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">RowFormatSerdeProperty</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_string</span><span class="p">())</span> -</span><span id="L-1733"><a href="#L-1733"><span class="linenos">1733</span></a> -</span><span id="L-1734"><a href="#L-1734"><span class="linenos">1734</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DELIMITED"</span><span class="p">)</span> -</span><span id="L-1735"><a href="#L-1735"><span class="linenos">1735</span></a> -</span><span id="L-1736"><a href="#L-1736"><span class="linenos">1736</span></a> <span class="n">kwargs</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-1718"><a href="#L-1718"><span class="linenos">1718</span></a> <span class="k">def</span> <span class="nf">_parse_returning</span><span class="p">(</span><span class="bp">self</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">Returning</span><span class="p">]:</span> +</span><span id="L-1719"><a href="#L-1719"><span class="linenos">1719</span></a> <span class="k">if</span> <span class="ow">not</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">RETURNING</span><span class="p">):</span> +</span><span id="L-1720"><a href="#L-1720"><span class="linenos">1720</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1721"><a href="#L-1721"><span class="linenos">1721</span></a> +</span><span id="L-1722"><a href="#L-1722"><span class="linenos">1722</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">Returning</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">))</span> +</span><span id="L-1723"><a href="#L-1723"><span class="linenos">1723</span></a> +</span><span id="L-1724"><a href="#L-1724"><span class="linenos">1724</span></a> <span class="k">def</span> <span class="nf">_parse_row</span><span class="p">(</span><span class="bp">self</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">RowFormatSerdeProperty</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">]:</span> +</span><span id="L-1725"><a href="#L-1725"><span class="linenos">1725</span></a> <span class="k">if</span> <span class="ow">not</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">FORMAT</span><span class="p">):</span> +</span><span id="L-1726"><a href="#L-1726"><span class="linenos">1726</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1727"><a href="#L-1727"><span class="linenos">1727</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_row_format</span><span class="p">()</span> +</span><span id="L-1728"><a href="#L-1728"><span class="linenos">1728</span></a> +</span><span id="L-1729"><a href="#L-1729"><span class="linenos">1729</span></a> <span class="k">def</span> <span class="nf">_parse_row_format</span><span class="p">(</span> +</span><span id="L-1730"><a href="#L-1730"><span class="linenos">1730</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">match_row</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-1731"><a href="#L-1731"><span class="linenos">1731</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">RowFormatSerdeProperty</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">]:</span> +</span><span id="L-1732"><a href="#L-1732"><span class="linenos">1732</span></a> <span class="k">if</span> <span class="n">match_row</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FORMAT</span><span class="p">):</span> +</span><span id="L-1733"><a href="#L-1733"><span class="linenos">1733</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1734"><a href="#L-1734"><span class="linenos">1734</span></a> +</span><span id="L-1735"><a href="#L-1735"><span class="linenos">1735</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SERDE"</span><span class="p">):</span> +</span><span id="L-1736"><a href="#L-1736"><span class="linenos">1736</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">RowFormatSerdeProperty</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_string</span><span class="p">())</span> </span><span id="L-1737"><a href="#L-1737"><span class="linenos">1737</span></a> -</span><span id="L-1738"><a href="#L-1738"><span class="linenos">1738</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FIELDS"</span><span class="p">,</span> <span class="s2">"TERMINATED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> -</span><span id="L-1739"><a href="#L-1739"><span class="linenos">1739</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"fields"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="L-1740"><a href="#L-1740"><span class="linenos">1740</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ESCAPED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> -</span><span id="L-1741"><a href="#L-1741"><span class="linenos">1741</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"escaped"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="L-1742"><a href="#L-1742"><span class="linenos">1742</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"COLLECTION"</span><span class="p">,</span> <span class="s2">"ITEMS"</span><span class="p">,</span> <span class="s2">"TERMINATED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> -</span><span id="L-1743"><a href="#L-1743"><span class="linenos">1743</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"collection_items"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="L-1744"><a href="#L-1744"><span class="linenos">1744</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MAP"</span><span class="p">,</span> <span class="s2">"KEYS"</span><span class="p">,</span> <span class="s2">"TERMINATED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> -</span><span id="L-1745"><a href="#L-1745"><span class="linenos">1745</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"map_keys"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="L-1746"><a href="#L-1746"><span class="linenos">1746</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LINES"</span><span class="p">,</span> <span class="s2">"TERMINATED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> -</span><span id="L-1747"><a href="#L-1747"><span class="linenos">1747</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"lines"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="L-1748"><a href="#L-1748"><span class="linenos">1748</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULL"</span><span class="p">,</span> <span class="s2">"DEFINED"</span><span class="p">,</span> <span class="s2">"AS"</span><span class="p">):</span> -</span><span id="L-1749"><a href="#L-1749"><span class="linenos">1749</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"null"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="L-1750"><a href="#L-1750"><span class="linenos">1750</span></a> -</span><span id="L-1751"><a href="#L-1751"><span class="linenos">1751</span></a> <span class="k">return</span> <span class="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">RowFormatDelimitedProperty</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="L-1752"><a href="#L-1752"><span class="linenos">1752</span></a> -</span><span id="L-1753"><a href="#L-1753"><span class="linenos">1753</span></a> <span class="k">def</span> <span class="nf">_parse_load</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">LoadData</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> -</span><span id="L-1754"><a href="#L-1754"><span class="linenos">1754</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DATA"</span><span class="p">):</span> -</span><span id="L-1755"><a href="#L-1755"><span class="linenos">1755</span></a> <span class="n">local</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LOCAL"</span><span class="p">)</span> -</span><span id="L-1756"><a href="#L-1756"><span class="linenos">1756</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INPATH"</span><span class="p">)</span> -</span><span id="L-1757"><a href="#L-1757"><span class="linenos">1757</span></a> <span class="n">inpath</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="L-1758"><a href="#L-1758"><span class="linenos">1758</span></a> <span class="n">overwrite</span> <span class="o">=</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">OVERWRITE</span><span class="p">)</span> -</span><span id="L-1759"><a href="#L-1759"><span class="linenos">1759</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">INTO</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">)</span> -</span><span id="L-1760"><a href="#L-1760"><span class="linenos">1760</span></a> -</span><span id="L-1761"><a href="#L-1761"><span class="linenos">1761</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><span id="L-1762"><a href="#L-1762"><span class="linenos">1762</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LoadData</span><span class="p">,</span> -</span><span id="L-1763"><a href="#L-1763"><span class="linenos">1763</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="L-1764"><a href="#L-1764"><span class="linenos">1764</span></a> <span class="n">local</span><span class="o">=</span><span class="n">local</span><span class="p">,</span> -</span><span id="L-1765"><a href="#L-1765"><span class="linenos">1765</span></a> <span class="n">overwrite</span><span class="o">=</span><span class="n">overwrite</span><span class="p">,</span> -</span><span id="L-1766"><a href="#L-1766"><span class="linenos">1766</span></a> <span class="n">inpath</span><span class="o">=</span><span class="n">inpath</span><span class="p">,</span> -</span><span id="L-1767"><a href="#L-1767"><span class="linenos">1767</span></a> <span class="n">partition</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition</span><span class="p">(),</span> -</span><span id="L-1768"><a href="#L-1768"><span class="linenos">1768</span></a> <span class="n">input_format</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INPUTFORMAT"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">(),</span> -</span><span id="L-1769"><a href="#L-1769"><span class="linenos">1769</span></a> <span class="n">serde</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SERDE"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">(),</span> -</span><span id="L-1770"><a href="#L-1770"><span class="linenos">1770</span></a> <span class="p">)</span> -</span><span id="L-1771"><a href="#L-1771"><span class="linenos">1771</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> -</span><span id="L-1772"><a href="#L-1772"><span class="linenos">1772</span></a> -</span><span id="L-1773"><a href="#L-1773"><span class="linenos">1773</span></a> <span class="k">def</span> <span class="nf">_parse_delete</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">Delete</span><span class="p">:</span> -</span><span id="L-1774"><a href="#L-1774"><span class="linenos">1774</span></a> <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">FROM</span><span class="p">)</span> -</span><span id="L-1775"><a href="#L-1775"><span class="linenos">1775</span></a> -</span><span id="L-1776"><a href="#L-1776"><span class="linenos">1776</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><span id="L-1777"><a href="#L-1777"><span class="linenos">1777</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">,</span> -</span><span id="L-1778"><a href="#L-1778"><span class="linenos">1778</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(),</span> -</span><span id="L-1779"><a href="#L-1779"><span class="linenos">1779</span></a> <span class="n">using</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</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">USING</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()),</span> -</span><span id="L-1780"><a href="#L-1780"><span class="linenos">1780</span></a> <span class="n">where</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">(),</span> -</span><span id="L-1781"><a href="#L-1781"><span class="linenos">1781</span></a> <span class="n">returning</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_returning</span><span class="p">(),</span> -</span><span id="L-1782"><a href="#L-1782"><span class="linenos">1782</span></a> <span class="p">)</span> -</span><span id="L-1783"><a href="#L-1783"><span class="linenos">1783</span></a> -</span><span id="L-1784"><a href="#L-1784"><span class="linenos">1784</span></a> <span class="k">def</span> <span class="nf">_parse_update</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">Update</span><span class="p">:</span> -</span><span id="L-1785"><a href="#L-1785"><span class="linenos">1785</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><span id="L-1786"><a href="#L-1786"><span class="linenos">1786</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> -</span><span id="L-1787"><a href="#L-1787"><span class="linenos">1787</span></a> <span class="o">**</span><span class="p">{</span> <span class="c1"># type: ignore</span> -</span><span id="L-1788"><a href="#L-1788"><span class="linenos">1788</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">alias_tokens</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">UPDATE_ALIAS_TOKENS</span><span class="p">),</span> -</span><span id="L-1789"><a href="#L-1789"><span class="linenos">1789</span></a> <span class="s2">"expressions"</span><span class="p">:</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">SET</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">),</span> -</span><span id="L-1790"><a href="#L-1790"><span class="linenos">1790</span></a> <span class="s2">"from"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_from</span><span class="p">(</span><span class="n">modifiers</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="L-1791"><a href="#L-1791"><span class="linenos">1791</span></a> <span class="s2">"where"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">(),</span> -</span><span id="L-1792"><a href="#L-1792"><span class="linenos">1792</span></a> <span class="s2">"returning"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_returning</span><span class="p">(),</span> -</span><span id="L-1793"><a href="#L-1793"><span class="linenos">1793</span></a> <span class="p">},</span> -</span><span id="L-1794"><a href="#L-1794"><span class="linenos">1794</span></a> <span class="p">)</span> -</span><span id="L-1795"><a href="#L-1795"><span class="linenos">1795</span></a> -</span><span id="L-1796"><a href="#L-1796"><span class="linenos">1796</span></a> <span class="k">def</span> <span class="nf">_parse_uncache</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">Uncache</span><span class="p">:</span> -</span><span id="L-1797"><a href="#L-1797"><span class="linenos">1797</span></a> <span class="k">if</span> <span class="ow">not</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">TABLE</span><span class="p">):</span> -</span><span id="L-1798"><a href="#L-1798"><span class="linenos">1798</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting TABLE after UNCACHE"</span><span class="p">)</span> +</span><span id="L-1738"><a href="#L-1738"><span class="linenos">1738</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DELIMITED"</span><span class="p">)</span> +</span><span id="L-1739"><a href="#L-1739"><span class="linenos">1739</span></a> +</span><span id="L-1740"><a href="#L-1740"><span class="linenos">1740</span></a> <span class="n">kwargs</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-1741"><a href="#L-1741"><span class="linenos">1741</span></a> +</span><span id="L-1742"><a href="#L-1742"><span class="linenos">1742</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FIELDS"</span><span class="p">,</span> <span class="s2">"TERMINATED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> +</span><span id="L-1743"><a href="#L-1743"><span class="linenos">1743</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"fields"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="L-1744"><a href="#L-1744"><span class="linenos">1744</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ESCAPED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> +</span><span id="L-1745"><a href="#L-1745"><span class="linenos">1745</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"escaped"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="L-1746"><a href="#L-1746"><span class="linenos">1746</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"COLLECTION"</span><span class="p">,</span> <span class="s2">"ITEMS"</span><span class="p">,</span> <span class="s2">"TERMINATED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> +</span><span id="L-1747"><a href="#L-1747"><span class="linenos">1747</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"collection_items"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="L-1748"><a href="#L-1748"><span class="linenos">1748</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MAP"</span><span class="p">,</span> <span class="s2">"KEYS"</span><span class="p">,</span> <span class="s2">"TERMINATED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> +</span><span id="L-1749"><a href="#L-1749"><span class="linenos">1749</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"map_keys"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="L-1750"><a href="#L-1750"><span class="linenos">1750</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LINES"</span><span class="p">,</span> <span class="s2">"TERMINATED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> +</span><span id="L-1751"><a href="#L-1751"><span class="linenos">1751</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"lines"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="L-1752"><a href="#L-1752"><span class="linenos">1752</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULL"</span><span class="p">,</span> <span class="s2">"DEFINED"</span><span class="p">,</span> <span class="s2">"AS"</span><span class="p">):</span> +</span><span id="L-1753"><a href="#L-1753"><span class="linenos">1753</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"null"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="L-1754"><a href="#L-1754"><span class="linenos">1754</span></a> +</span><span id="L-1755"><a href="#L-1755"><span class="linenos">1755</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">RowFormatDelimitedProperty</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="L-1756"><a href="#L-1756"><span class="linenos">1756</span></a> +</span><span id="L-1757"><a href="#L-1757"><span class="linenos">1757</span></a> <span class="k">def</span> <span class="nf">_parse_load</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">LoadData</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> +</span><span id="L-1758"><a href="#L-1758"><span class="linenos">1758</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DATA"</span><span class="p">):</span> +</span><span id="L-1759"><a href="#L-1759"><span class="linenos">1759</span></a> <span class="n">local</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LOCAL"</span><span class="p">)</span> +</span><span id="L-1760"><a href="#L-1760"><span class="linenos">1760</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INPATH"</span><span class="p">)</span> +</span><span id="L-1761"><a href="#L-1761"><span class="linenos">1761</span></a> <span class="n">inpath</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="L-1762"><a href="#L-1762"><span class="linenos">1762</span></a> <span class="n">overwrite</span> <span class="o">=</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">OVERWRITE</span><span class="p">)</span> +</span><span id="L-1763"><a href="#L-1763"><span class="linenos">1763</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">INTO</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">)</span> +</span><span id="L-1764"><a href="#L-1764"><span class="linenos">1764</span></a> +</span><span id="L-1765"><a href="#L-1765"><span class="linenos">1765</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><span id="L-1766"><a href="#L-1766"><span class="linenos">1766</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LoadData</span><span class="p">,</span> +</span><span id="L-1767"><a href="#L-1767"><span class="linenos">1767</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="L-1768"><a href="#L-1768"><span class="linenos">1768</span></a> <span class="n">local</span><span class="o">=</span><span class="n">local</span><span class="p">,</span> +</span><span id="L-1769"><a href="#L-1769"><span class="linenos">1769</span></a> <span class="n">overwrite</span><span class="o">=</span><span class="n">overwrite</span><span class="p">,</span> +</span><span id="L-1770"><a href="#L-1770"><span class="linenos">1770</span></a> <span class="n">inpath</span><span class="o">=</span><span class="n">inpath</span><span class="p">,</span> +</span><span id="L-1771"><a href="#L-1771"><span class="linenos">1771</span></a> <span class="n">partition</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition</span><span class="p">(),</span> +</span><span id="L-1772"><a href="#L-1772"><span class="linenos">1772</span></a> <span class="n">input_format</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INPUTFORMAT"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">(),</span> +</span><span id="L-1773"><a href="#L-1773"><span class="linenos">1773</span></a> <span class="n">serde</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SERDE"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">(),</span> +</span><span id="L-1774"><a href="#L-1774"><span class="linenos">1774</span></a> <span class="p">)</span> +</span><span id="L-1775"><a href="#L-1775"><span class="linenos">1775</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="L-1776"><a href="#L-1776"><span class="linenos">1776</span></a> +</span><span id="L-1777"><a href="#L-1777"><span class="linenos">1777</span></a> <span class="k">def</span> <span class="nf">_parse_delete</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">Delete</span><span class="p">:</span> +</span><span id="L-1778"><a href="#L-1778"><span class="linenos">1778</span></a> <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">FROM</span><span class="p">)</span> +</span><span id="L-1779"><a href="#L-1779"><span class="linenos">1779</span></a> +</span><span id="L-1780"><a href="#L-1780"><span class="linenos">1780</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-1781"><a href="#L-1781"><span class="linenos">1781</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">,</span> +</span><span id="L-1782"><a href="#L-1782"><span class="linenos">1782</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(),</span> +</span><span id="L-1783"><a href="#L-1783"><span class="linenos">1783</span></a> <span class="n">using</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</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">USING</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()),</span> +</span><span id="L-1784"><a href="#L-1784"><span class="linenos">1784</span></a> <span class="n">where</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">(),</span> +</span><span id="L-1785"><a href="#L-1785"><span class="linenos">1785</span></a> <span class="n">returning</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_returning</span><span class="p">(),</span> +</span><span id="L-1786"><a href="#L-1786"><span class="linenos">1786</span></a> <span class="p">)</span> +</span><span id="L-1787"><a href="#L-1787"><span class="linenos">1787</span></a> +</span><span id="L-1788"><a href="#L-1788"><span class="linenos">1788</span></a> <span class="k">def</span> <span class="nf">_parse_update</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">Update</span><span class="p">:</span> +</span><span id="L-1789"><a href="#L-1789"><span class="linenos">1789</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-1790"><a href="#L-1790"><span class="linenos">1790</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> +</span><span id="L-1791"><a href="#L-1791"><span class="linenos">1791</span></a> <span class="o">**</span><span class="p">{</span> <span class="c1"># type: ignore</span> +</span><span id="L-1792"><a href="#L-1792"><span class="linenos">1792</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">alias_tokens</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">UPDATE_ALIAS_TOKENS</span><span class="p">),</span> +</span><span id="L-1793"><a href="#L-1793"><span class="linenos">1793</span></a> <span class="s2">"expressions"</span><span class="p">:</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">SET</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">),</span> +</span><span id="L-1794"><a href="#L-1794"><span class="linenos">1794</span></a> <span class="s2">"from"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_from</span><span class="p">(</span><span class="n">modifiers</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="L-1795"><a href="#L-1795"><span class="linenos">1795</span></a> <span class="s2">"where"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">(),</span> +</span><span id="L-1796"><a href="#L-1796"><span class="linenos">1796</span></a> <span class="s2">"returning"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_returning</span><span class="p">(),</span> +</span><span id="L-1797"><a href="#L-1797"><span class="linenos">1797</span></a> <span class="p">},</span> +</span><span id="L-1798"><a href="#L-1798"><span class="linenos">1798</span></a> <span class="p">)</span> </span><span id="L-1799"><a href="#L-1799"><span class="linenos">1799</span></a> -</span><span id="L-1800"><a href="#L-1800"><span class="linenos">1800</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-1801"><a href="#L-1801"><span class="linenos">1801</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Uncache</span><span class="p">,</span> <span class="n">exists</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</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_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1802"><a href="#L-1802"><span class="linenos">1802</span></a> <span class="p">)</span> +</span><span id="L-1800"><a href="#L-1800"><span class="linenos">1800</span></a> <span class="k">def</span> <span class="nf">_parse_uncache</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">Uncache</span><span class="p">:</span> +</span><span id="L-1801"><a href="#L-1801"><span class="linenos">1801</span></a> <span class="k">if</span> <span class="ow">not</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">TABLE</span><span class="p">):</span> +</span><span id="L-1802"><a href="#L-1802"><span class="linenos">1802</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting TABLE after UNCACHE"</span><span class="p">)</span> </span><span id="L-1803"><a href="#L-1803"><span class="linenos">1803</span></a> -</span><span id="L-1804"><a href="#L-1804"><span class="linenos">1804</span></a> <span class="k">def</span> <span class="nf">_parse_cache</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">Cache</span><span class="p">:</span> -</span><span id="L-1805"><a href="#L-1805"><span class="linenos">1805</span></a> <span class="n">lazy</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LAZY"</span><span class="p">)</span> -</span><span id="L-1806"><a href="#L-1806"><span class="linenos">1806</span></a> <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">TABLE</span><span class="p">)</span> -</span><span id="L-1807"><a href="#L-1807"><span class="linenos">1807</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1808"><a href="#L-1808"><span class="linenos">1808</span></a> -</span><span id="L-1809"><a href="#L-1809"><span class="linenos">1809</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-1810"><a href="#L-1810"><span class="linenos">1810</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OPTIONS"</span><span class="p">):</span> -</span><span id="L-1811"><a href="#L-1811"><span class="linenos">1811</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> -</span><span id="L-1812"><a href="#L-1812"><span class="linenos">1812</span></a> <span class="n">k</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="L-1813"><a href="#L-1813"><span class="linenos">1813</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="L-1814"><a href="#L-1814"><span class="linenos">1814</span></a> <span class="n">v</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="L-1815"><a href="#L-1815"><span class="linenos">1815</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">]</span> -</span><span id="L-1816"><a href="#L-1816"><span class="linenos">1816</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="L-1817"><a href="#L-1817"><span class="linenos">1817</span></a> -</span><span id="L-1818"><a href="#L-1818"><span class="linenos">1818</span></a> <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">ALIAS</span><span class="p">)</span> -</span><span id="L-1819"><a href="#L-1819"><span class="linenos">1819</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><span id="L-1820"><a href="#L-1820"><span class="linenos">1820</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">,</span> -</span><span id="L-1821"><a href="#L-1821"><span class="linenos">1821</span></a> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> -</span><span id="L-1822"><a href="#L-1822"><span class="linenos">1822</span></a> <span class="n">lazy</span><span class="o">=</span><span class="n">lazy</span><span class="p">,</span> -</span><span id="L-1823"><a href="#L-1823"><span class="linenos">1823</span></a> <span class="n">options</span><span class="o">=</span><span class="n">options</span><span class="p">,</span> -</span><span id="L-1824"><a href="#L-1824"><span class="linenos">1824</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="L-1825"><a href="#L-1825"><span class="linenos">1825</span></a> <span class="p">)</span> -</span><span id="L-1826"><a href="#L-1826"><span class="linenos">1826</span></a> -</span><span id="L-1827"><a href="#L-1827"><span class="linenos">1827</span></a> <span class="k">def</span> <span class="nf">_parse_partition</span><span class="p">(</span><span class="bp">self</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">Partition</span><span class="p">]:</span> -</span><span id="L-1828"><a href="#L-1828"><span class="linenos">1828</span></a> <span class="k">if</span> <span class="ow">not</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">PARTITION</span><span class="p">):</span> -</span><span id="L-1829"><a href="#L-1829"><span class="linenos">1829</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1804"><a href="#L-1804"><span class="linenos">1804</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><span id="L-1805"><a href="#L-1805"><span class="linenos">1805</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Uncache</span><span class="p">,</span> <span class="n">exists</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</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_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1806"><a href="#L-1806"><span class="linenos">1806</span></a> <span class="p">)</span> +</span><span id="L-1807"><a href="#L-1807"><span class="linenos">1807</span></a> +</span><span id="L-1808"><a href="#L-1808"><span class="linenos">1808</span></a> <span class="k">def</span> <span class="nf">_parse_cache</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">Cache</span><span class="p">:</span> +</span><span id="L-1809"><a href="#L-1809"><span class="linenos">1809</span></a> <span class="n">lazy</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LAZY"</span><span class="p">)</span> +</span><span id="L-1810"><a href="#L-1810"><span class="linenos">1810</span></a> <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">TABLE</span><span class="p">)</span> +</span><span id="L-1811"><a href="#L-1811"><span class="linenos">1811</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1812"><a href="#L-1812"><span class="linenos">1812</span></a> +</span><span id="L-1813"><a href="#L-1813"><span class="linenos">1813</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-1814"><a href="#L-1814"><span class="linenos">1814</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OPTIONS"</span><span class="p">):</span> +</span><span id="L-1815"><a href="#L-1815"><span class="linenos">1815</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> +</span><span id="L-1816"><a href="#L-1816"><span class="linenos">1816</span></a> <span class="n">k</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="L-1817"><a href="#L-1817"><span class="linenos">1817</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="L-1818"><a href="#L-1818"><span class="linenos">1818</span></a> <span class="n">v</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="L-1819"><a href="#L-1819"><span class="linenos">1819</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">]</span> +</span><span id="L-1820"><a href="#L-1820"><span class="linenos">1820</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-1821"><a href="#L-1821"><span class="linenos">1821</span></a> +</span><span id="L-1822"><a href="#L-1822"><span class="linenos">1822</span></a> <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">ALIAS</span><span class="p">)</span> +</span><span id="L-1823"><a href="#L-1823"><span class="linenos">1823</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><span id="L-1824"><a href="#L-1824"><span class="linenos">1824</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">,</span> +</span><span id="L-1825"><a href="#L-1825"><span class="linenos">1825</span></a> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> +</span><span id="L-1826"><a href="#L-1826"><span class="linenos">1826</span></a> <span class="n">lazy</span><span class="o">=</span><span class="n">lazy</span><span class="p">,</span> +</span><span id="L-1827"><a href="#L-1827"><span class="linenos">1827</span></a> <span class="n">options</span><span class="o">=</span><span class="n">options</span><span class="p">,</span> +</span><span id="L-1828"><a href="#L-1828"><span class="linenos">1828</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="L-1829"><a href="#L-1829"><span class="linenos">1829</span></a> <span class="p">)</span> </span><span id="L-1830"><a href="#L-1830"><span class="linenos">1830</span></a> -</span><span id="L-1831"><a href="#L-1831"><span class="linenos">1831</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-1832"><a href="#L-1832"><span class="linenos">1832</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Partition</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="L-1833"><a href="#L-1833"><span class="linenos">1833</span></a> <span class="p">)</span> +</span><span id="L-1831"><a href="#L-1831"><span class="linenos">1831</span></a> <span class="k">def</span> <span class="nf">_parse_partition</span><span class="p">(</span><span class="bp">self</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">Partition</span><span class="p">]:</span> +</span><span id="L-1832"><a href="#L-1832"><span class="linenos">1832</span></a> <span class="k">if</span> <span class="ow">not</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">PARTITION</span><span class="p">):</span> +</span><span id="L-1833"><a href="#L-1833"><span class="linenos">1833</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="L-1834"><a href="#L-1834"><span class="linenos">1834</span></a> -</span><span id="L-1835"><a href="#L-1835"><span class="linenos">1835</span></a> <span class="k">def</span> <span class="nf">_parse_value</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">Tuple</span><span class="p">:</span> -</span><span id="L-1836"><a href="#L-1836"><span class="linenos">1836</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_PAREN</span><span class="p">):</span> -</span><span id="L-1837"><a href="#L-1837"><span class="linenos">1837</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="L-1838"><a href="#L-1838"><span class="linenos">1838</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="L-1839"><a href="#L-1839"><span class="linenos">1839</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">Tuple</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-1840"><a href="#L-1840"><span class="linenos">1840</span></a> -</span><span id="L-1841"><a href="#L-1841"><span class="linenos">1841</span></a> <span class="c1"># In presto we can have VALUES 1, 2 which results in 1 column & 2 rows.</span> -</span><span id="L-1842"><a href="#L-1842"><span class="linenos">1842</span></a> <span class="c1"># Source: https://prestodb.io/docs/current/sql/values.html</span> -</span><span id="L-1843"><a href="#L-1843"><span class="linenos">1843</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">Tuple</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()])</span> +</span><span id="L-1835"><a href="#L-1835"><span class="linenos">1835</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><span id="L-1836"><a href="#L-1836"><span class="linenos">1836</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Partition</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="L-1837"><a href="#L-1837"><span class="linenos">1837</span></a> <span class="p">)</span> +</span><span id="L-1838"><a href="#L-1838"><span class="linenos">1838</span></a> +</span><span id="L-1839"><a href="#L-1839"><span class="linenos">1839</span></a> <span class="k">def</span> <span class="nf">_parse_value</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">Tuple</span><span class="p">:</span> +</span><span id="L-1840"><a href="#L-1840"><span class="linenos">1840</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_PAREN</span><span class="p">):</span> +</span><span id="L-1841"><a href="#L-1841"><span class="linenos">1841</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="L-1842"><a href="#L-1842"><span class="linenos">1842</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-1843"><a href="#L-1843"><span class="linenos">1843</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">Tuple</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> </span><span id="L-1844"><a href="#L-1844"><span class="linenos">1844</span></a> -</span><span id="L-1845"><a href="#L-1845"><span class="linenos">1845</span></a> <span class="k">def</span> <span class="nf">_parse_select</span><span class="p">(</span> -</span><span id="L-1846"><a href="#L-1846"><span class="linenos">1846</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">nested</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="n">table</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="n">parse_subquery_alias</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-1847"><a href="#L-1847"><span class="linenos">1847</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-1848"><a href="#L-1848"><span class="linenos">1848</span></a> <span class="n">cte</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_with</span><span class="p">()</span> -</span><span id="L-1849"><a href="#L-1849"><span class="linenos">1849</span></a> <span class="k">if</span> <span class="n">cte</span><span class="p">:</span> -</span><span id="L-1850"><a href="#L-1850"><span class="linenos">1850</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">()</span> -</span><span id="L-1851"><a href="#L-1851"><span class="linenos">1851</span></a> -</span><span id="L-1852"><a href="#L-1852"><span class="linenos">1852</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> -</span><span id="L-1853"><a href="#L-1853"><span class="linenos">1853</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Failed to parse any statement following CTE"</span><span class="p">)</span> -</span><span id="L-1854"><a href="#L-1854"><span class="linenos">1854</span></a> <span class="k">return</span> <span class="n">cte</span> +</span><span id="L-1845"><a href="#L-1845"><span class="linenos">1845</span></a> <span class="c1"># In presto we can have VALUES 1, 2 which results in 1 column & 2 rows.</span> +</span><span id="L-1846"><a href="#L-1846"><span class="linenos">1846</span></a> <span class="c1"># Source: https://prestodb.io/docs/current/sql/values.html</span> +</span><span id="L-1847"><a href="#L-1847"><span class="linenos">1847</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">Tuple</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()])</span> +</span><span id="L-1848"><a href="#L-1848"><span class="linenos">1848</span></a> +</span><span id="L-1849"><a href="#L-1849"><span class="linenos">1849</span></a> <span class="k">def</span> <span class="nf">_parse_select</span><span class="p">(</span> +</span><span id="L-1850"><a href="#L-1850"><span class="linenos">1850</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">nested</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="n">table</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="n">parse_subquery_alias</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-1851"><a href="#L-1851"><span class="linenos">1851</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-1852"><a href="#L-1852"><span class="linenos">1852</span></a> <span class="n">cte</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_with</span><span class="p">()</span> +</span><span id="L-1853"><a href="#L-1853"><span class="linenos">1853</span></a> <span class="k">if</span> <span class="n">cte</span><span class="p">:</span> +</span><span id="L-1854"><a href="#L-1854"><span class="linenos">1854</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">()</span> </span><span id="L-1855"><a href="#L-1855"><span class="linenos">1855</span></a> -</span><span id="L-1856"><a href="#L-1856"><span class="linenos">1856</span></a> <span class="k">if</span> <span class="s2">"with"</span> <span class="ow">in</span> <span class="n">this</span><span class="o">.</span><span class="n">arg_types</span><span class="p">:</span> -</span><span id="L-1857"><a href="#L-1857"><span class="linenos">1857</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"with"</span><span class="p">,</span> <span class="n">cte</span><span class="p">)</span> -</span><span id="L-1858"><a href="#L-1858"><span class="linenos">1858</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1859"><a href="#L-1859"><span class="linenos">1859</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2"> does not support CTE"</span><span class="p">)</span> -</span><span id="L-1860"><a href="#L-1860"><span class="linenos">1860</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">cte</span> -</span><span id="L-1861"><a href="#L-1861"><span class="linenos">1861</span></a> <span class="k">elif</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">SELECT</span><span class="p">):</span> -</span><span id="L-1862"><a href="#L-1862"><span class="linenos">1862</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> -</span><span id="L-1863"><a href="#L-1863"><span class="linenos">1863</span></a> -</span><span id="L-1864"><a href="#L-1864"><span class="linenos">1864</span></a> <span class="n">hint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_hint</span><span class="p">()</span> -</span><span id="L-1865"><a href="#L-1865"><span class="linenos">1865</span></a> <span class="n">all_</span> <span class="o">=</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">ALL</span><span class="p">)</span> -</span><span id="L-1866"><a href="#L-1866"><span class="linenos">1866</span></a> <span class="n">distinct</span> <span class="o">=</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">DISTINCT</span><span class="p">)</span> +</span><span id="L-1856"><a href="#L-1856"><span class="linenos">1856</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> +</span><span id="L-1857"><a href="#L-1857"><span class="linenos">1857</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Failed to parse any statement following CTE"</span><span class="p">)</span> +</span><span id="L-1858"><a href="#L-1858"><span class="linenos">1858</span></a> <span class="k">return</span> <span class="n">cte</span> +</span><span id="L-1859"><a href="#L-1859"><span class="linenos">1859</span></a> +</span><span id="L-1860"><a href="#L-1860"><span class="linenos">1860</span></a> <span class="k">if</span> <span class="s2">"with"</span> <span class="ow">in</span> <span class="n">this</span><span class="o">.</span><span class="n">arg_types</span><span class="p">:</span> +</span><span id="L-1861"><a href="#L-1861"><span class="linenos">1861</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"with"</span><span class="p">,</span> <span class="n">cte</span><span class="p">)</span> +</span><span id="L-1862"><a href="#L-1862"><span class="linenos">1862</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1863"><a href="#L-1863"><span class="linenos">1863</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2"> does not support CTE"</span><span class="p">)</span> +</span><span id="L-1864"><a href="#L-1864"><span class="linenos">1864</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">cte</span> +</span><span id="L-1865"><a href="#L-1865"><span class="linenos">1865</span></a> <span class="k">elif</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">SELECT</span><span class="p">):</span> +</span><span id="L-1866"><a href="#L-1866"><span class="linenos">1866</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> </span><span id="L-1867"><a href="#L-1867"><span class="linenos">1867</span></a> -</span><span id="L-1868"><a href="#L-1868"><span class="linenos">1868</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-1869"><a href="#L-1869"><span class="linenos">1869</span></a> <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">ALIAS</span><span class="p">)</span> -</span><span id="L-1870"><a href="#L-1870"><span class="linenos">1870</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"STRUCT"</span><span class="p">,</span> <span class="s2">"VALUE"</span><span class="p">))</span> -</span><span id="L-1871"><a href="#L-1871"><span class="linenos">1871</span></a> <span class="ow">and</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><span id="L-1872"><a href="#L-1872"><span class="linenos">1872</span></a> <span class="p">)</span> -</span><span id="L-1873"><a href="#L-1873"><span class="linenos">1873</span></a> -</span><span id="L-1874"><a href="#L-1874"><span class="linenos">1874</span></a> <span class="k">if</span> <span class="n">distinct</span><span class="p">:</span> -</span><span id="L-1875"><a href="#L-1875"><span class="linenos">1875</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-1876"><a href="#L-1876"><span class="linenos">1876</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Distinct</span><span class="p">,</span> -</span><span id="L-1877"><a href="#L-1877"><span class="linenos">1877</span></a> <span class="n">on</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">()</span> <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">ON</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-1878"><a href="#L-1878"><span class="linenos">1878</span></a> <span class="p">)</span> -</span><span id="L-1879"><a href="#L-1879"><span class="linenos">1879</span></a> -</span><span id="L-1880"><a href="#L-1880"><span class="linenos">1880</span></a> <span class="k">if</span> <span class="n">all_</span> <span class="ow">and</span> <span class="n">distinct</span><span class="p">:</span> -</span><span id="L-1881"><a href="#L-1881"><span class="linenos">1881</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Cannot specify both ALL and DISTINCT after SELECT"</span><span class="p">)</span> -</span><span id="L-1882"><a href="#L-1882"><span class="linenos">1882</span></a> -</span><span id="L-1883"><a href="#L-1883"><span class="linenos">1883</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_limit</span><span class="p">(</span><span class="n">top</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1884"><a href="#L-1884"><span class="linenos">1884</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">)</span> -</span><span id="L-1885"><a href="#L-1885"><span class="linenos">1885</span></a> -</span><span id="L-1886"><a href="#L-1886"><span class="linenos">1886</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-1887"><a href="#L-1887"><span class="linenos">1887</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> -</span><span id="L-1888"><a href="#L-1888"><span class="linenos">1888</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> -</span><span id="L-1889"><a href="#L-1889"><span class="linenos">1889</span></a> <span class="n">hint</span><span class="o">=</span><span class="n">hint</span><span class="p">,</span> -</span><span id="L-1890"><a href="#L-1890"><span class="linenos">1890</span></a> <span class="n">distinct</span><span class="o">=</span><span class="n">distinct</span><span class="p">,</span> -</span><span id="L-1891"><a href="#L-1891"><span class="linenos">1891</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-1892"><a href="#L-1892"><span class="linenos">1892</span></a> <span class="n">limit</span><span class="o">=</span><span class="n">limit</span><span class="p">,</span> -</span><span id="L-1893"><a href="#L-1893"><span class="linenos">1893</span></a> <span class="p">)</span> -</span><span id="L-1894"><a href="#L-1894"><span class="linenos">1894</span></a> <span class="n">this</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> -</span><span id="L-1895"><a href="#L-1895"><span class="linenos">1895</span></a> -</span><span id="L-1896"><a href="#L-1896"><span class="linenos">1896</span></a> <span class="n">into</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_into</span><span class="p">()</span> -</span><span id="L-1897"><a href="#L-1897"><span class="linenos">1897</span></a> <span class="k">if</span> <span class="n">into</span><span class="p">:</span> -</span><span id="L-1898"><a href="#L-1898"><span class="linenos">1898</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"into"</span><span class="p">,</span> <span class="n">into</span><span class="p">)</span> +</span><span id="L-1868"><a href="#L-1868"><span class="linenos">1868</span></a> <span class="n">hint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_hint</span><span class="p">()</span> +</span><span id="L-1869"><a href="#L-1869"><span class="linenos">1869</span></a> <span class="n">all_</span> <span class="o">=</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">ALL</span><span class="p">)</span> +</span><span id="L-1870"><a href="#L-1870"><span class="linenos">1870</span></a> <span class="n">distinct</span> <span class="o">=</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">DISTINCT</span><span class="p">)</span> +</span><span id="L-1871"><a href="#L-1871"><span class="linenos">1871</span></a> +</span><span id="L-1872"><a href="#L-1872"><span class="linenos">1872</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-1873"><a href="#L-1873"><span class="linenos">1873</span></a> <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">ALIAS</span><span class="p">)</span> +</span><span id="L-1874"><a href="#L-1874"><span class="linenos">1874</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"STRUCT"</span><span class="p">,</span> <span class="s2">"VALUE"</span><span class="p">))</span> +</span><span id="L-1875"><a href="#L-1875"><span class="linenos">1875</span></a> <span class="ow">and</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><span id="L-1876"><a href="#L-1876"><span class="linenos">1876</span></a> <span class="p">)</span> +</span><span id="L-1877"><a href="#L-1877"><span class="linenos">1877</span></a> +</span><span id="L-1878"><a href="#L-1878"><span class="linenos">1878</span></a> <span class="k">if</span> <span class="n">distinct</span><span class="p">:</span> +</span><span id="L-1879"><a href="#L-1879"><span class="linenos">1879</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-1880"><a href="#L-1880"><span class="linenos">1880</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Distinct</span><span class="p">,</span> +</span><span id="L-1881"><a href="#L-1881"><span class="linenos">1881</span></a> <span class="n">on</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">()</span> <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">ON</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-1882"><a href="#L-1882"><span class="linenos">1882</span></a> <span class="p">)</span> +</span><span id="L-1883"><a href="#L-1883"><span class="linenos">1883</span></a> +</span><span id="L-1884"><a href="#L-1884"><span class="linenos">1884</span></a> <span class="k">if</span> <span class="n">all_</span> <span class="ow">and</span> <span class="n">distinct</span><span class="p">:</span> +</span><span id="L-1885"><a href="#L-1885"><span class="linenos">1885</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Cannot specify both ALL and DISTINCT after SELECT"</span><span class="p">)</span> +</span><span id="L-1886"><a href="#L-1886"><span class="linenos">1886</span></a> +</span><span id="L-1887"><a href="#L-1887"><span class="linenos">1887</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_limit</span><span class="p">(</span><span class="n">top</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1888"><a href="#L-1888"><span class="linenos">1888</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">)</span> +</span><span id="L-1889"><a href="#L-1889"><span class="linenos">1889</span></a> +</span><span id="L-1890"><a href="#L-1890"><span class="linenos">1890</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-1891"><a href="#L-1891"><span class="linenos">1891</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> +</span><span id="L-1892"><a href="#L-1892"><span class="linenos">1892</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> +</span><span id="L-1893"><a href="#L-1893"><span class="linenos">1893</span></a> <span class="n">hint</span><span class="o">=</span><span class="n">hint</span><span class="p">,</span> +</span><span id="L-1894"><a href="#L-1894"><span class="linenos">1894</span></a> <span class="n">distinct</span><span class="o">=</span><span class="n">distinct</span><span class="p">,</span> +</span><span id="L-1895"><a href="#L-1895"><span class="linenos">1895</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-1896"><a href="#L-1896"><span class="linenos">1896</span></a> <span class="n">limit</span><span class="o">=</span><span class="n">limit</span><span class="p">,</span> +</span><span id="L-1897"><a href="#L-1897"><span class="linenos">1897</span></a> <span class="p">)</span> +</span><span id="L-1898"><a href="#L-1898"><span class="linenos">1898</span></a> <span class="n">this</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> </span><span id="L-1899"><a href="#L-1899"><span class="linenos">1899</span></a> -</span><span id="L-1900"><a href="#L-1900"><span class="linenos">1900</span></a> <span class="n">from_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_from</span><span class="p">()</span> -</span><span id="L-1901"><a href="#L-1901"><span class="linenos">1901</span></a> <span class="k">if</span> <span class="n">from_</span><span class="p">:</span> -</span><span id="L-1902"><a href="#L-1902"><span class="linenos">1902</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"from"</span><span class="p">,</span> <span class="n">from_</span><span class="p">)</span> +</span><span id="L-1900"><a href="#L-1900"><span class="linenos">1900</span></a> <span class="n">into</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_into</span><span class="p">()</span> +</span><span id="L-1901"><a href="#L-1901"><span class="linenos">1901</span></a> <span class="k">if</span> <span class="n">into</span><span class="p">:</span> +</span><span id="L-1902"><a href="#L-1902"><span class="linenos">1902</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"into"</span><span class="p">,</span> <span class="n">into</span><span class="p">)</span> </span><span id="L-1903"><a href="#L-1903"><span class="linenos">1903</span></a> -</span><span id="L-1904"><a href="#L-1904"><span class="linenos">1904</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-1905"><a href="#L-1905"><span class="linenos">1905</span></a> <span class="k">elif</span> <span class="p">(</span><span class="n">table</span> <span class="ow">or</span> <span class="n">nested</span><span class="p">)</span> <span class="ow">and</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_PAREN</span><span class="p">):</span> -</span><span id="L-1906"><a href="#L-1906"><span class="linenos">1906</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">PIVOT</span><span class="p">):</span> -</span><span id="L-1907"><a href="#L-1907"><span class="linenos">1907</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_simplified_pivot</span><span class="p">()</span> -</span><span id="L-1908"><a href="#L-1908"><span class="linenos">1908</span></a> <span class="k">elif</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">FROM</span><span class="p">):</span> -</span><span id="L-1909"><a href="#L-1909"><span class="linenos">1909</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="s2">"*"</span><span class="p">)</span><span class="o">.</span><span class="n">from_</span><span class="p">(</span> -</span><span id="L-1910"><a href="#L-1910"><span class="linenos">1910</span></a> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_from</span><span class="p">(</span><span class="n">skip_from_token</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> -</span><span id="L-1911"><a href="#L-1911"><span class="linenos">1911</span></a> <span class="p">)</span> -</span><span id="L-1912"><a href="#L-1912"><span class="linenos">1912</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1913"><a href="#L-1913"><span class="linenos">1913</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> <span class="k">if</span> <span class="n">table</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1914"><a href="#L-1914"><span class="linenos">1914</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">this</span><span class="p">))</span> -</span><span id="L-1915"><a href="#L-1915"><span class="linenos">1915</span></a> -</span><span id="L-1916"><a href="#L-1916"><span class="linenos">1916</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="L-1917"><a href="#L-1917"><span class="linenos">1917</span></a> -</span><span id="L-1918"><a href="#L-1918"><span class="linenos">1918</span></a> <span class="c1"># early return so that subquery unions aren't parsed again</span> -</span><span id="L-1919"><a href="#L-1919"><span class="linenos">1919</span></a> <span class="c1"># SELECT * FROM (SELECT 1) UNION ALL SELECT 1</span> -</span><span id="L-1920"><a href="#L-1920"><span class="linenos">1920</span></a> <span class="c1"># Union ALL should be a property of the top select node, not the subquery</span> -</span><span id="L-1921"><a href="#L-1921"><span class="linenos">1921</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_subquery</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">parse_alias</span><span class="o">=</span><span class="n">parse_subquery_alias</span><span class="p">)</span> -</span><span id="L-1922"><a href="#L-1922"><span class="linenos">1922</span></a> <span class="k">elif</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">VALUES</span><span class="p">):</span> -</span><span id="L-1923"><a href="#L-1923"><span class="linenos">1923</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-1924"><a href="#L-1924"><span class="linenos">1924</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">,</span> -</span><span id="L-1925"><a href="#L-1925"><span class="linenos">1925</span></a> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">),</span> -</span><span id="L-1926"><a href="#L-1926"><span class="linenos">1926</span></a> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">(),</span> -</span><span id="L-1927"><a href="#L-1927"><span class="linenos">1927</span></a> <span class="p">)</span> -</span><span id="L-1928"><a href="#L-1928"><span class="linenos">1928</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1929"><a href="#L-1929"><span class="linenos">1929</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1930"><a href="#L-1930"><span class="linenos">1930</span></a> -</span><span id="L-1931"><a href="#L-1931"><span class="linenos">1931</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-1932"><a href="#L-1932"><span class="linenos">1932</span></a> -</span><span id="L-1933"><a href="#L-1933"><span class="linenos">1933</span></a> <span class="k">def</span> <span class="nf">_parse_with</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_with_token</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">With</span><span class="p">]:</span> -</span><span id="L-1934"><a href="#L-1934"><span class="linenos">1934</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_with_token</span> <span class="ow">and</span> <span class="ow">not</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">WITH</span><span class="p">):</span> -</span><span id="L-1935"><a href="#L-1935"><span class="linenos">1935</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1904"><a href="#L-1904"><span class="linenos">1904</span></a> <span class="n">from_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_from</span><span class="p">()</span> +</span><span id="L-1905"><a href="#L-1905"><span class="linenos">1905</span></a> <span class="k">if</span> <span class="n">from_</span><span class="p">:</span> +</span><span id="L-1906"><a href="#L-1906"><span class="linenos">1906</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"from"</span><span class="p">,</span> <span class="n">from_</span><span class="p">)</span> +</span><span id="L-1907"><a href="#L-1907"><span class="linenos">1907</span></a> +</span><span id="L-1908"><a href="#L-1908"><span class="linenos">1908</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-1909"><a href="#L-1909"><span class="linenos">1909</span></a> <span class="k">elif</span> <span class="p">(</span><span class="n">table</span> <span class="ow">or</span> <span class="n">nested</span><span class="p">)</span> <span class="ow">and</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_PAREN</span><span class="p">):</span> +</span><span id="L-1910"><a href="#L-1910"><span class="linenos">1910</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">PIVOT</span><span class="p">):</span> +</span><span id="L-1911"><a href="#L-1911"><span class="linenos">1911</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_simplified_pivot</span><span class="p">()</span> +</span><span id="L-1912"><a href="#L-1912"><span class="linenos">1912</span></a> <span class="k">elif</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">FROM</span><span class="p">):</span> +</span><span id="L-1913"><a href="#L-1913"><span class="linenos">1913</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="s2">"*"</span><span class="p">)</span><span class="o">.</span><span class="n">from_</span><span class="p">(</span> +</span><span id="L-1914"><a href="#L-1914"><span class="linenos">1914</span></a> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_from</span><span class="p">(</span><span class="n">skip_from_token</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="L-1915"><a href="#L-1915"><span class="linenos">1915</span></a> <span class="p">)</span> +</span><span id="L-1916"><a href="#L-1916"><span class="linenos">1916</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1917"><a href="#L-1917"><span class="linenos">1917</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> <span class="k">if</span> <span class="n">table</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1918"><a href="#L-1918"><span class="linenos">1918</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">this</span><span class="p">))</span> +</span><span id="L-1919"><a href="#L-1919"><span class="linenos">1919</span></a> +</span><span id="L-1920"><a href="#L-1920"><span class="linenos">1920</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-1921"><a href="#L-1921"><span class="linenos">1921</span></a> +</span><span id="L-1922"><a href="#L-1922"><span class="linenos">1922</span></a> <span class="c1"># early return so that subquery unions aren't parsed again</span> +</span><span id="L-1923"><a href="#L-1923"><span class="linenos">1923</span></a> <span class="c1"># SELECT * FROM (SELECT 1) UNION ALL SELECT 1</span> +</span><span id="L-1924"><a href="#L-1924"><span class="linenos">1924</span></a> <span class="c1"># Union ALL should be a property of the top select node, not the subquery</span> +</span><span id="L-1925"><a href="#L-1925"><span class="linenos">1925</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_subquery</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">parse_alias</span><span class="o">=</span><span class="n">parse_subquery_alias</span><span class="p">)</span> +</span><span id="L-1926"><a href="#L-1926"><span class="linenos">1926</span></a> <span class="k">elif</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">VALUES</span><span class="p">):</span> +</span><span id="L-1927"><a href="#L-1927"><span class="linenos">1927</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-1928"><a href="#L-1928"><span class="linenos">1928</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">,</span> +</span><span id="L-1929"><a href="#L-1929"><span class="linenos">1929</span></a> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">),</span> +</span><span id="L-1930"><a href="#L-1930"><span class="linenos">1930</span></a> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">(),</span> +</span><span id="L-1931"><a href="#L-1931"><span class="linenos">1931</span></a> <span class="p">)</span> +</span><span id="L-1932"><a href="#L-1932"><span class="linenos">1932</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1933"><a href="#L-1933"><span class="linenos">1933</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1934"><a href="#L-1934"><span class="linenos">1934</span></a> +</span><span id="L-1935"><a href="#L-1935"><span class="linenos">1935</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> </span><span id="L-1936"><a href="#L-1936"><span class="linenos">1936</span></a> -</span><span id="L-1937"><a href="#L-1937"><span class="linenos">1937</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> -</span><span id="L-1938"><a href="#L-1938"><span class="linenos">1938</span></a> <span class="n">recursive</span> <span class="o">=</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">RECURSIVE</span><span class="p">)</span> -</span><span id="L-1939"><a href="#L-1939"><span class="linenos">1939</span></a> -</span><span id="L-1940"><a href="#L-1940"><span class="linenos">1940</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-1941"><a href="#L-1941"><span class="linenos">1941</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-1942"><a href="#L-1942"><span class="linenos">1942</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_cte</span><span class="p">())</span> +</span><span id="L-1937"><a href="#L-1937"><span class="linenos">1937</span></a> <span class="k">def</span> <span class="nf">_parse_with</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_with_token</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">With</span><span class="p">]:</span> +</span><span id="L-1938"><a href="#L-1938"><span class="linenos">1938</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_with_token</span> <span class="ow">and</span> <span class="ow">not</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">WITH</span><span class="p">):</span> +</span><span id="L-1939"><a href="#L-1939"><span class="linenos">1939</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1940"><a href="#L-1940"><span class="linenos">1940</span></a> +</span><span id="L-1941"><a href="#L-1941"><span class="linenos">1941</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> +</span><span id="L-1942"><a href="#L-1942"><span class="linenos">1942</span></a> <span class="n">recursive</span> <span class="o">=</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">RECURSIVE</span><span class="p">)</span> </span><span id="L-1943"><a href="#L-1943"><span class="linenos">1943</span></a> -</span><span id="L-1944"><a href="#L-1944"><span class="linenos">1944</span></a> <span class="k">if</span> <span class="ow">not</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">COMMA</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">):</span> -</span><span id="L-1945"><a href="#L-1945"><span class="linenos">1945</span></a> <span class="k">break</span> -</span><span id="L-1946"><a href="#L-1946"><span class="linenos">1946</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1947"><a href="#L-1947"><span class="linenos">1947</span></a> <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">WITH</span><span class="p">)</span> -</span><span id="L-1948"><a href="#L-1948"><span class="linenos">1948</span></a> -</span><span id="L-1949"><a href="#L-1949"><span class="linenos">1949</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><span id="L-1950"><a href="#L-1950"><span class="linenos">1950</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="n">comments</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">recursive</span><span class="o">=</span><span class="n">recursive</span> -</span><span id="L-1951"><a href="#L-1951"><span class="linenos">1951</span></a> <span class="p">)</span> +</span><span id="L-1944"><a href="#L-1944"><span class="linenos">1944</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-1945"><a href="#L-1945"><span class="linenos">1945</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-1946"><a href="#L-1946"><span class="linenos">1946</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_cte</span><span class="p">())</span> +</span><span id="L-1947"><a href="#L-1947"><span class="linenos">1947</span></a> +</span><span id="L-1948"><a href="#L-1948"><span class="linenos">1948</span></a> <span class="k">if</span> <span class="ow">not</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">COMMA</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">):</span> +</span><span id="L-1949"><a href="#L-1949"><span class="linenos">1949</span></a> <span class="k">break</span> +</span><span id="L-1950"><a href="#L-1950"><span class="linenos">1950</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1951"><a href="#L-1951"><span class="linenos">1951</span></a> <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">WITH</span><span class="p">)</span> </span><span id="L-1952"><a href="#L-1952"><span class="linenos">1952</span></a> -</span><span id="L-1953"><a href="#L-1953"><span class="linenos">1953</span></a> <span class="k">def</span> <span class="nf">_parse_cte</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">CTE</span><span class="p">:</span> -</span><span id="L-1954"><a href="#L-1954"><span class="linenos">1954</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> -</span><span id="L-1955"><a href="#L-1955"><span class="linenos">1955</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">alias</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">alias</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> -</span><span id="L-1956"><a href="#L-1956"><span class="linenos">1956</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected CTE to have alias"</span><span class="p">)</span> -</span><span id="L-1957"><a href="#L-1957"><span class="linenos">1957</span></a> -</span><span id="L-1958"><a href="#L-1958"><span class="linenos">1958</span></a> <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">ALIAS</span><span class="p">)</span> -</span><span id="L-1959"><a href="#L-1959"><span class="linenos">1959</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><span id="L-1960"><a href="#L-1960"><span class="linenos">1960</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</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_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">),</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span> -</span><span id="L-1961"><a href="#L-1961"><span class="linenos">1961</span></a> <span class="p">)</span> -</span><span id="L-1962"><a href="#L-1962"><span class="linenos">1962</span></a> -</span><span id="L-1963"><a href="#L-1963"><span class="linenos">1963</span></a> <span class="k">def</span> <span class="nf">_parse_table_alias</span><span class="p">(</span> -</span><span id="L-1964"><a href="#L-1964"><span class="linenos">1964</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">alias_tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1965"><a href="#L-1965"><span class="linenos">1965</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">TableAlias</span><span class="p">]:</span> -</span><span id="L-1966"><a href="#L-1966"><span class="linenos">1966</span></a> <span class="n">any_token</span> <span class="o">=</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">ALIAS</span><span class="p">)</span> -</span><span id="L-1967"><a href="#L-1967"><span class="linenos">1967</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-1968"><a href="#L-1968"><span class="linenos">1968</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="n">any_token</span><span class="p">,</span> <span class="n">tokens</span><span class="o">=</span><span class="n">alias_tokens</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_ALIAS_TOKENS</span><span class="p">)</span> -</span><span id="L-1969"><a href="#L-1969"><span class="linenos">1969</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string_as_identifier</span><span class="p">()</span> -</span><span id="L-1970"><a href="#L-1970"><span class="linenos">1970</span></a> <span class="p">)</span> -</span><span id="L-1971"><a href="#L-1971"><span class="linenos">1971</span></a> -</span><span id="L-1972"><a href="#L-1972"><span class="linenos">1972</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="L-1973"><a href="#L-1973"><span class="linenos">1973</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_PAREN</span><span class="p">):</span> -</span><span id="L-1974"><a href="#L-1974"><span class="linenos">1974</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function_parameter</span><span class="p">)</span> -</span><span id="L-1975"><a href="#L-1975"><span class="linenos">1975</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-1976"><a href="#L-1976"><span class="linenos">1976</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1977"><a href="#L-1977"><span class="linenos">1977</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1978"><a href="#L-1978"><span class="linenos">1978</span></a> -</span><span id="L-1979"><a href="#L-1979"><span class="linenos">1979</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">alias</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">columns</span><span class="p">:</span> -</span><span id="L-1980"><a href="#L-1980"><span class="linenos">1980</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-1981"><a href="#L-1981"><span class="linenos">1981</span></a> -</span><span id="L-1982"><a href="#L-1982"><span class="linenos">1982</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">TableAlias</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">alias</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="n">columns</span><span class="p">)</span> -</span><span id="L-1983"><a href="#L-1983"><span class="linenos">1983</span></a> -</span><span id="L-1984"><a href="#L-1984"><span class="linenos">1984</span></a> <span class="k">def</span> <span class="nf">_parse_subquery</span><span class="p">(</span> -</span><span id="L-1985"><a href="#L-1985"><span class="linenos">1985</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="n">parse_alias</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-1986"><a href="#L-1986"><span class="linenos">1986</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">Subquery</span><span class="p">]:</span> -</span><span id="L-1987"><a href="#L-1987"><span class="linenos">1987</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> -</span><span id="L-1988"><a href="#L-1988"><span class="linenos">1988</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-1989"><a href="#L-1989"><span class="linenos">1989</span></a> -</span><span id="L-1990"><a href="#L-1990"><span class="linenos">1990</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><span id="L-1991"><a href="#L-1991"><span class="linenos">1991</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">,</span> -</span><span id="L-1992"><a href="#L-1992"><span class="linenos">1992</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-1993"><a href="#L-1993"><span class="linenos">1993</span></a> <span class="n">pivots</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivots</span><span class="p">(),</span> -</span><span id="L-1994"><a href="#L-1994"><span class="linenos">1994</span></a> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> <span class="k">if</span> <span class="n">parse_alias</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-1995"><a href="#L-1995"><span class="linenos">1995</span></a> <span class="p">)</span> -</span><span id="L-1996"><a href="#L-1996"><span class="linenos">1996</span></a> -</span><span id="L-1997"><a href="#L-1997"><span class="linenos">1997</span></a> <span class="k">def</span> <span class="nf">_parse_query_modifiers</span><span class="p">(</span> -</span><span id="L-1998"><a href="#L-1998"><span class="linenos">1998</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><span id="L-1999"><a href="#L-1999"><span class="linenos">1999</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-2000"><a href="#L-2000"><span class="linenos">2000</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="bp">self</span><span class="o">.</span><span class="n">MODIFIABLES</span><span class="p">):</span> -</span><span id="L-2001"><a href="#L-2001"><span class="linenos">2001</span></a> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">parser</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">QUERY_MODIFIER_PARSERS</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> -</span><span id="L-2002"><a href="#L-2002"><span class="linenos">2002</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> -</span><span id="L-2003"><a href="#L-2003"><span class="linenos">2003</span></a> -</span><span id="L-2004"><a href="#L-2004"><span class="linenos">2004</span></a> <span class="k">if</span> <span class="n">expression</span><span class="p">:</span> -</span><span id="L-2005"><a href="#L-2005"><span class="linenos">2005</span></a> <span class="k">if</span> <span class="n">key</span> <span class="o">==</span> <span class="s2">"limit"</span><span class="p">:</span> -</span><span id="L-2006"><a href="#L-2006"><span class="linenos">2006</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="L-2007"><a href="#L-2007"><span class="linenos">2007</span></a> <span class="k">if</span> <span class="n">offset</span><span class="p">:</span> -</span><span id="L-2008"><a href="#L-2008"><span class="linenos">2008</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Offset</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">offset</span><span class="p">))</span> -</span><span id="L-2009"><a href="#L-2009"><span class="linenos">2009</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-2010"><a href="#L-2010"><span class="linenos">2010</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-2011"><a href="#L-2011"><span class="linenos">2011</span></a> -</span><span id="L-2012"><a href="#L-2012"><span class="linenos">2012</span></a> <span class="k">def</span> <span class="nf">_parse_hint</span><span class="p">(</span><span class="bp">self</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">Hint</span><span class="p">]:</span> -</span><span id="L-2013"><a href="#L-2013"><span class="linenos">2013</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">HINT</span><span class="p">):</span> -</span><span id="L-2014"><a href="#L-2014"><span class="linenos">2014</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">)</span> +</span><span id="L-1953"><a href="#L-1953"><span class="linenos">1953</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><span id="L-1954"><a href="#L-1954"><span class="linenos">1954</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="n">comments</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">recursive</span><span class="o">=</span><span class="n">recursive</span> +</span><span id="L-1955"><a href="#L-1955"><span class="linenos">1955</span></a> <span class="p">)</span> +</span><span id="L-1956"><a href="#L-1956"><span class="linenos">1956</span></a> +</span><span id="L-1957"><a href="#L-1957"><span class="linenos">1957</span></a> <span class="k">def</span> <span class="nf">_parse_cte</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">CTE</span><span class="p">:</span> +</span><span id="L-1958"><a href="#L-1958"><span class="linenos">1958</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> +</span><span id="L-1959"><a href="#L-1959"><span class="linenos">1959</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">alias</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">alias</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> +</span><span id="L-1960"><a href="#L-1960"><span class="linenos">1960</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected CTE to have alias"</span><span class="p">)</span> +</span><span id="L-1961"><a href="#L-1961"><span class="linenos">1961</span></a> +</span><span id="L-1962"><a href="#L-1962"><span class="linenos">1962</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ALIAS</span><span class="p">)</span> +</span><span id="L-1963"><a href="#L-1963"><span class="linenos">1963</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><span id="L-1964"><a href="#L-1964"><span class="linenos">1964</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</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_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">),</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span> +</span><span id="L-1965"><a href="#L-1965"><span class="linenos">1965</span></a> <span class="p">)</span> +</span><span id="L-1966"><a href="#L-1966"><span class="linenos">1966</span></a> +</span><span id="L-1967"><a href="#L-1967"><span class="linenos">1967</span></a> <span class="k">def</span> <span class="nf">_parse_table_alias</span><span class="p">(</span> +</span><span id="L-1968"><a href="#L-1968"><span class="linenos">1968</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">alias_tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1969"><a href="#L-1969"><span class="linenos">1969</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">TableAlias</span><span class="p">]:</span> +</span><span id="L-1970"><a href="#L-1970"><span class="linenos">1970</span></a> <span class="n">any_token</span> <span class="o">=</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">ALIAS</span><span class="p">)</span> +</span><span id="L-1971"><a href="#L-1971"><span class="linenos">1971</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-1972"><a href="#L-1972"><span class="linenos">1972</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="n">any_token</span><span class="p">,</span> <span class="n">tokens</span><span class="o">=</span><span class="n">alias_tokens</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_ALIAS_TOKENS</span><span class="p">)</span> +</span><span id="L-1973"><a href="#L-1973"><span class="linenos">1973</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string_as_identifier</span><span class="p">()</span> +</span><span id="L-1974"><a href="#L-1974"><span class="linenos">1974</span></a> <span class="p">)</span> +</span><span id="L-1975"><a href="#L-1975"><span class="linenos">1975</span></a> +</span><span id="L-1976"><a href="#L-1976"><span class="linenos">1976</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="L-1977"><a href="#L-1977"><span class="linenos">1977</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_PAREN</span><span class="p">):</span> +</span><span id="L-1978"><a href="#L-1978"><span class="linenos">1978</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function_parameter</span><span class="p">)</span> +</span><span id="L-1979"><a href="#L-1979"><span class="linenos">1979</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-1980"><a href="#L-1980"><span class="linenos">1980</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1981"><a href="#L-1981"><span class="linenos">1981</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1982"><a href="#L-1982"><span class="linenos">1982</span></a> +</span><span id="L-1983"><a href="#L-1983"><span class="linenos">1983</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">alias</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">columns</span><span class="p">:</span> +</span><span id="L-1984"><a href="#L-1984"><span class="linenos">1984</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1985"><a href="#L-1985"><span class="linenos">1985</span></a> +</span><span id="L-1986"><a href="#L-1986"><span class="linenos">1986</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">TableAlias</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">alias</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="n">columns</span><span class="p">)</span> +</span><span id="L-1987"><a href="#L-1987"><span class="linenos">1987</span></a> +</span><span id="L-1988"><a href="#L-1988"><span class="linenos">1988</span></a> <span class="k">def</span> <span class="nf">_parse_subquery</span><span class="p">(</span> +</span><span id="L-1989"><a href="#L-1989"><span class="linenos">1989</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="n">parse_alias</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-1990"><a href="#L-1990"><span class="linenos">1990</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">Subquery</span><span class="p">]:</span> +</span><span id="L-1991"><a href="#L-1991"><span class="linenos">1991</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> +</span><span id="L-1992"><a href="#L-1992"><span class="linenos">1992</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-1993"><a href="#L-1993"><span class="linenos">1993</span></a> +</span><span id="L-1994"><a href="#L-1994"><span class="linenos">1994</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-1995"><a href="#L-1995"><span class="linenos">1995</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">,</span> +</span><span id="L-1996"><a href="#L-1996"><span class="linenos">1996</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-1997"><a href="#L-1997"><span class="linenos">1997</span></a> <span class="n">pivots</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivots</span><span class="p">(),</span> +</span><span id="L-1998"><a href="#L-1998"><span class="linenos">1998</span></a> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> <span class="k">if</span> <span class="n">parse_alias</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-1999"><a href="#L-1999"><span class="linenos">1999</span></a> <span class="p">)</span> +</span><span id="L-2000"><a href="#L-2000"><span class="linenos">2000</span></a> +</span><span id="L-2001"><a href="#L-2001"><span class="linenos">2001</span></a> <span class="k">def</span> <span class="nf">_parse_query_modifiers</span><span class="p">(</span> +</span><span id="L-2002"><a href="#L-2002"><span class="linenos">2002</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><span id="L-2003"><a href="#L-2003"><span class="linenos">2003</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-2004"><a href="#L-2004"><span class="linenos">2004</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="bp">self</span><span class="o">.</span><span class="n">MODIFIABLES</span><span class="p">):</span> +</span><span id="L-2005"><a href="#L-2005"><span class="linenos">2005</span></a> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">parser</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">QUERY_MODIFIER_PARSERS</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> +</span><span id="L-2006"><a href="#L-2006"><span class="linenos">2006</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> +</span><span id="L-2007"><a href="#L-2007"><span class="linenos">2007</span></a> +</span><span id="L-2008"><a href="#L-2008"><span class="linenos">2008</span></a> <span class="k">if</span> <span class="n">expression</span><span class="p">:</span> +</span><span id="L-2009"><a href="#L-2009"><span class="linenos">2009</span></a> <span class="k">if</span> <span class="n">key</span> <span class="o">==</span> <span class="s2">"limit"</span><span class="p">:</span> +</span><span id="L-2010"><a href="#L-2010"><span class="linenos">2010</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="L-2011"><a href="#L-2011"><span class="linenos">2011</span></a> <span class="k">if</span> <span class="n">offset</span><span class="p">:</span> +</span><span id="L-2012"><a href="#L-2012"><span class="linenos">2012</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Offset</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">offset</span><span class="p">))</span> +</span><span id="L-2013"><a href="#L-2013"><span class="linenos">2013</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-2014"><a href="#L-2014"><span class="linenos">2014</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="L-2015"><a href="#L-2015"><span class="linenos">2015</span></a> -</span><span id="L-2016"><a href="#L-2016"><span class="linenos">2016</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STAR</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SLASH</span><span class="p">):</span> -</span><span id="L-2017"><a href="#L-2017"><span class="linenos">2017</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected */ after HINT"</span><span class="p">)</span> -</span><span id="L-2018"><a href="#L-2018"><span class="linenos">2018</span></a> -</span><span id="L-2019"><a href="#L-2019"><span class="linenos">2019</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">Hint</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">hints</span><span class="p">)</span> -</span><span id="L-2020"><a href="#L-2020"><span class="linenos">2020</span></a> -</span><span id="L-2021"><a href="#L-2021"><span class="linenos">2021</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2016"><a href="#L-2016"><span class="linenos">2016</span></a> <span class="k">def</span> <span class="nf">_parse_hint</span><span class="p">(</span><span class="bp">self</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">Hint</span><span class="p">]:</span> +</span><span id="L-2017"><a href="#L-2017"><span class="linenos">2017</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">HINT</span><span class="p">):</span> +</span><span id="L-2018"><a href="#L-2018"><span class="linenos">2018</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">)</span> +</span><span id="L-2019"><a href="#L-2019"><span class="linenos">2019</span></a> +</span><span id="L-2020"><a href="#L-2020"><span class="linenos">2020</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STAR</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SLASH</span><span class="p">):</span> +</span><span id="L-2021"><a href="#L-2021"><span class="linenos">2021</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected */ after HINT"</span><span class="p">)</span> </span><span id="L-2022"><a href="#L-2022"><span class="linenos">2022</span></a> -</span><span id="L-2023"><a href="#L-2023"><span class="linenos">2023</span></a> <span class="k">def</span> <span class="nf">_parse_into</span><span class="p">(</span><span class="bp">self</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">Into</span><span class="p">]:</span> -</span><span id="L-2024"><a href="#L-2024"><span class="linenos">2024</span></a> <span class="k">if</span> <span class="ow">not</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">INTO</span><span class="p">):</span> -</span><span id="L-2025"><a href="#L-2025"><span class="linenos">2025</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2023"><a href="#L-2023"><span class="linenos">2023</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">Hint</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">hints</span><span class="p">)</span> +</span><span id="L-2024"><a href="#L-2024"><span class="linenos">2024</span></a> +</span><span id="L-2025"><a href="#L-2025"><span class="linenos">2025</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="L-2026"><a href="#L-2026"><span class="linenos">2026</span></a> -</span><span id="L-2027"><a href="#L-2027"><span class="linenos">2027</span></a> <span class="n">temp</span> <span class="o">=</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">TEMPORARY</span><span class="p">)</span> -</span><span id="L-2028"><a href="#L-2028"><span class="linenos">2028</span></a> <span class="n">unlogged</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"UNLOGGED"</span><span class="p">)</span> -</span><span id="L-2029"><a href="#L-2029"><span class="linenos">2029</span></a> <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">TABLE</span><span class="p">)</span> +</span><span id="L-2027"><a href="#L-2027"><span class="linenos">2027</span></a> <span class="k">def</span> <span class="nf">_parse_into</span><span class="p">(</span><span class="bp">self</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">Into</span><span class="p">]:</span> +</span><span id="L-2028"><a href="#L-2028"><span class="linenos">2028</span></a> <span class="k">if</span> <span class="ow">not</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">INTO</span><span class="p">):</span> +</span><span id="L-2029"><a href="#L-2029"><span class="linenos">2029</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="L-2030"><a href="#L-2030"><span class="linenos">2030</span></a> -</span><span id="L-2031"><a href="#L-2031"><span class="linenos">2031</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-2032"><a href="#L-2032"><span class="linenos">2032</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Into</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_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> <span class="n">temporary</span><span class="o">=</span><span class="n">temp</span><span class="p">,</span> <span class="n">unlogged</span><span class="o">=</span><span class="n">unlogged</span> -</span><span id="L-2033"><a href="#L-2033"><span class="linenos">2033</span></a> <span class="p">)</span> +</span><span id="L-2031"><a href="#L-2031"><span class="linenos">2031</span></a> <span class="n">temp</span> <span class="o">=</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">TEMPORARY</span><span class="p">)</span> +</span><span id="L-2032"><a href="#L-2032"><span class="linenos">2032</span></a> <span class="n">unlogged</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"UNLOGGED"</span><span class="p">)</span> +</span><span id="L-2033"><a href="#L-2033"><span class="linenos">2033</span></a> <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">TABLE</span><span class="p">)</span> </span><span id="L-2034"><a href="#L-2034"><span class="linenos">2034</span></a> -</span><span id="L-2035"><a href="#L-2035"><span class="linenos">2035</span></a> <span class="k">def</span> <span class="nf">_parse_from</span><span class="p">(</span> -</span><span id="L-2036"><a href="#L-2036"><span class="linenos">2036</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">modifiers</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="n">skip_from_token</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-2037"><a href="#L-2037"><span class="linenos">2037</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">From</span><span class="p">]:</span> -</span><span id="L-2038"><a href="#L-2038"><span class="linenos">2038</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_from_token</span> <span class="ow">and</span> <span class="ow">not</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">FROM</span><span class="p">):</span> -</span><span id="L-2039"><a href="#L-2039"><span class="linenos">2039</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-2040"><a href="#L-2040"><span class="linenos">2040</span></a> -</span><span id="L-2041"><a href="#L-2041"><span class="linenos">2041</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> -</span><span id="L-2042"><a href="#L-2042"><span class="linenos">2042</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> -</span><span id="L-2043"><a href="#L-2043"><span class="linenos">2043</span></a> -</span><span id="L-2044"><a href="#L-2044"><span class="linenos">2044</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-2045"><a href="#L-2045"><span class="linenos">2045</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> -</span><span id="L-2046"><a href="#L-2046"><span class="linenos">2046</span></a> <span class="n">comments</span><span class="o">=</span><span class="n">comments</span><span class="p">,</span> -</span><span id="L-2047"><a href="#L-2047"><span class="linenos">2047</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="n">modifiers</span> <span class="k">else</span> <span class="n">this</span><span class="p">,</span> -</span><span id="L-2048"><a href="#L-2048"><span class="linenos">2048</span></a> <span class="p">)</span> -</span><span id="L-2049"><a href="#L-2049"><span class="linenos">2049</span></a> -</span><span id="L-2050"><a href="#L-2050"><span class="linenos">2050</span></a> <span class="k">def</span> <span class="nf">_parse_match_recognize</span><span class="p">(</span><span class="bp">self</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">MatchRecognize</span><span class="p">]:</span> -</span><span id="L-2051"><a href="#L-2051"><span class="linenos">2051</span></a> <span class="k">if</span> <span class="ow">not</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">MATCH_RECOGNIZE</span><span class="p">):</span> -</span><span id="L-2052"><a href="#L-2052"><span class="linenos">2052</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2035"><a href="#L-2035"><span class="linenos">2035</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><span id="L-2036"><a href="#L-2036"><span class="linenos">2036</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Into</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_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> <span class="n">temporary</span><span class="o">=</span><span class="n">temp</span><span class="p">,</span> <span class="n">unlogged</span><span class="o">=</span><span class="n">unlogged</span> +</span><span id="L-2037"><a href="#L-2037"><span class="linenos">2037</span></a> <span class="p">)</span> +</span><span id="L-2038"><a href="#L-2038"><span class="linenos">2038</span></a> +</span><span id="L-2039"><a href="#L-2039"><span class="linenos">2039</span></a> <span class="k">def</span> <span class="nf">_parse_from</span><span class="p">(</span> +</span><span id="L-2040"><a href="#L-2040"><span class="linenos">2040</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">modifiers</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="n">skip_from_token</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-2041"><a href="#L-2041"><span class="linenos">2041</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">From</span><span class="p">]:</span> +</span><span id="L-2042"><a href="#L-2042"><span class="linenos">2042</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_from_token</span> <span class="ow">and</span> <span class="ow">not</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">FROM</span><span class="p">):</span> +</span><span id="L-2043"><a href="#L-2043"><span class="linenos">2043</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2044"><a href="#L-2044"><span class="linenos">2044</span></a> +</span><span id="L-2045"><a href="#L-2045"><span class="linenos">2045</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> +</span><span id="L-2046"><a href="#L-2046"><span class="linenos">2046</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> +</span><span id="L-2047"><a href="#L-2047"><span class="linenos">2047</span></a> +</span><span id="L-2048"><a href="#L-2048"><span class="linenos">2048</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><span id="L-2049"><a href="#L-2049"><span class="linenos">2049</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> +</span><span id="L-2050"><a href="#L-2050"><span class="linenos">2050</span></a> <span class="n">comments</span><span class="o">=</span><span class="n">comments</span><span class="p">,</span> +</span><span id="L-2051"><a href="#L-2051"><span class="linenos">2051</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="n">modifiers</span> <span class="k">else</span> <span class="n">this</span><span class="p">,</span> +</span><span id="L-2052"><a href="#L-2052"><span class="linenos">2052</span></a> <span class="p">)</span> </span><span id="L-2053"><a href="#L-2053"><span class="linenos">2053</span></a> -</span><span id="L-2054"><a href="#L-2054"><span class="linenos">2054</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> -</span><span id="L-2055"><a href="#L-2055"><span class="linenos">2055</span></a> -</span><span id="L-2056"><a href="#L-2056"><span class="linenos">2056</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition_by</span><span class="p">()</span> -</span><span id="L-2057"><a href="#L-2057"><span class="linenos">2057</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">()</span> -</span><span id="L-2058"><a href="#L-2058"><span class="linenos">2058</span></a> <span class="n">measures</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-2059"><a href="#L-2059"><span class="linenos">2059</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MEASURES"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="L-2060"><a href="#L-2060"><span class="linenos">2060</span></a> <span class="p">)</span> -</span><span id="L-2061"><a href="#L-2061"><span class="linenos">2061</span></a> -</span><span id="L-2062"><a href="#L-2062"><span class="linenos">2062</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ONE"</span><span class="p">,</span> <span class="s2">"ROW"</span><span class="p">,</span> <span class="s2">"PER"</span><span class="p">,</span> <span class="s2">"MATCH"</span><span class="p">):</span> -</span><span id="L-2063"><a href="#L-2063"><span class="linenos">2063</span></a> <span class="n">rows</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="s2">"ONE ROW PER MATCH"</span><span class="p">)</span> -</span><span id="L-2064"><a href="#L-2064"><span class="linenos">2064</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ALL"</span><span class="p">,</span> <span class="s2">"ROWS"</span><span class="p">,</span> <span class="s2">"PER"</span><span class="p">,</span> <span class="s2">"MATCH"</span><span class="p">):</span> -</span><span id="L-2065"><a href="#L-2065"><span class="linenos">2065</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">"ALL ROWS PER MATCH"</span> -</span><span id="L-2066"><a href="#L-2066"><span class="linenos">2066</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SHOW"</span><span class="p">,</span> <span class="s2">"EMPTY"</span><span class="p">,</span> <span class="s2">"MATCHES"</span><span class="p">):</span> -</span><span id="L-2067"><a href="#L-2067"><span class="linenos">2067</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" SHOW EMPTY MATCHES"</span> -</span><span id="L-2068"><a href="#L-2068"><span class="linenos">2068</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OMIT"</span><span class="p">,</span> <span class="s2">"EMPTY"</span><span class="p">,</span> <span class="s2">"MATCHES"</span><span class="p">):</span> -</span><span id="L-2069"><a href="#L-2069"><span class="linenos">2069</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" OMIT EMPTY MATCHES"</span> -</span><span id="L-2070"><a href="#L-2070"><span class="linenos">2070</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"UNMATCHED"</span><span class="p">,</span> <span class="s2">"ROWS"</span><span class="p">):</span> -</span><span id="L-2071"><a href="#L-2071"><span class="linenos">2071</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" WITH UNMATCHED ROWS"</span> -</span><span id="L-2072"><a href="#L-2072"><span class="linenos">2072</span></a> <span class="n">rows</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="n">text</span><span class="p">)</span> -</span><span id="L-2073"><a href="#L-2073"><span class="linenos">2073</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2074"><a href="#L-2074"><span class="linenos">2074</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2075"><a href="#L-2075"><span class="linenos">2075</span></a> -</span><span id="L-2076"><a href="#L-2076"><span class="linenos">2076</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AFTER"</span><span class="p">,</span> <span class="s2">"MATCH"</span><span class="p">,</span> <span class="s2">"SKIP"</span><span class="p">):</span> -</span><span id="L-2077"><a href="#L-2077"><span class="linenos">2077</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">"AFTER MATCH SKIP"</span> -</span><span id="L-2078"><a href="#L-2078"><span class="linenos">2078</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PAST"</span><span class="p">,</span> <span class="s2">"LAST"</span><span class="p">,</span> <span class="s2">"ROW"</span><span class="p">):</span> -</span><span id="L-2079"><a href="#L-2079"><span class="linenos">2079</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" PAST LAST ROW"</span> -</span><span id="L-2080"><a href="#L-2080"><span class="linenos">2080</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"NEXT"</span><span class="p">,</span> <span class="s2">"ROW"</span><span class="p">):</span> -</span><span id="L-2081"><a href="#L-2081"><span class="linenos">2081</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" TO NEXT ROW"</span> -</span><span id="L-2082"><a href="#L-2082"><span class="linenos">2082</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"FIRST"</span><span class="p">):</span> -</span><span id="L-2083"><a href="#L-2083"><span class="linenos">2083</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" TO FIRST </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</span><span class="p">()</span><span class="o">.</span><span class="n">text</span><span class="si">}</span><span class="s2">"</span> <span class="c1"># type: ignore</span> -</span><span id="L-2084"><a href="#L-2084"><span class="linenos">2084</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"LAST"</span><span class="p">):</span> -</span><span id="L-2085"><a href="#L-2085"><span class="linenos">2085</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" TO LAST </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</span><span class="p">()</span><span class="o">.</span><span class="n">text</span><span class="si">}</span><span class="s2">"</span> <span class="c1"># type: ignore</span> -</span><span id="L-2086"><a href="#L-2086"><span class="linenos">2086</span></a> <span class="n">after</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="n">text</span><span class="p">)</span> -</span><span id="L-2087"><a href="#L-2087"><span class="linenos">2087</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2088"><a href="#L-2088"><span class="linenos">2088</span></a> <span class="n">after</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2089"><a href="#L-2089"><span class="linenos">2089</span></a> -</span><span id="L-2090"><a href="#L-2090"><span class="linenos">2090</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PATTERN"</span><span class="p">):</span> -</span><span id="L-2091"><a href="#L-2091"><span class="linenos">2091</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> -</span><span id="L-2092"><a href="#L-2092"><span class="linenos">2092</span></a> -</span><span id="L-2093"><a href="#L-2093"><span class="linenos">2093</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="L-2094"><a href="#L-2094"><span class="linenos">2094</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting )"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">)</span> -</span><span id="L-2095"><a href="#L-2095"><span class="linenos">2095</span></a> -</span><span id="L-2096"><a href="#L-2096"><span class="linenos">2096</span></a> <span class="n">paren</span> <span class="o">=</span> <span class="mi">1</span> -</span><span id="L-2097"><a href="#L-2097"><span class="linenos">2097</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> -</span><span id="L-2098"><a href="#L-2098"><span class="linenos">2098</span></a> -</span><span id="L-2099"><a href="#L-2099"><span class="linenos">2099</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">and</span> <span class="n">paren</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> -</span><span id="L-2100"><a href="#L-2100"><span class="linenos">2100</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">:</span> -</span><span id="L-2101"><a href="#L-2101"><span class="linenos">2101</span></a> <span class="n">paren</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="L-2102"><a href="#L-2102"><span class="linenos">2102</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_PAREN</span><span class="p">:</span> -</span><span id="L-2103"><a href="#L-2103"><span class="linenos">2103</span></a> <span class="n">paren</span> <span class="o">-=</span> <span class="mi">1</span> -</span><span id="L-2104"><a href="#L-2104"><span class="linenos">2104</span></a> -</span><span id="L-2105"><a href="#L-2105"><span class="linenos">2105</span></a> <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> -</span><span id="L-2106"><a href="#L-2106"><span class="linenos">2106</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-2107"><a href="#L-2107"><span class="linenos">2107</span></a> -</span><span id="L-2108"><a href="#L-2108"><span class="linenos">2108</span></a> <span class="k">if</span> <span class="n">paren</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> -</span><span id="L-2109"><a href="#L-2109"><span class="linenos">2109</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting )"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">)</span> -</span><span id="L-2110"><a href="#L-2110"><span class="linenos">2110</span></a> -</span><span id="L-2111"><a href="#L-2111"><span class="linenos">2111</span></a> <span class="n">pattern</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="bp">self</span><span class="o">.</span><span class="n">_find_sql</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">))</span> -</span><span id="L-2112"><a href="#L-2112"><span class="linenos">2112</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2113"><a href="#L-2113"><span class="linenos">2113</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2054"><a href="#L-2054"><span class="linenos">2054</span></a> <span class="k">def</span> <span class="nf">_parse_match_recognize</span><span class="p">(</span><span class="bp">self</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">MatchRecognize</span><span class="p">]:</span> +</span><span id="L-2055"><a href="#L-2055"><span class="linenos">2055</span></a> <span class="k">if</span> <span class="ow">not</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">MATCH_RECOGNIZE</span><span class="p">):</span> +</span><span id="L-2056"><a href="#L-2056"><span class="linenos">2056</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2057"><a href="#L-2057"><span class="linenos">2057</span></a> +</span><span id="L-2058"><a href="#L-2058"><span class="linenos">2058</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> +</span><span id="L-2059"><a href="#L-2059"><span class="linenos">2059</span></a> +</span><span id="L-2060"><a href="#L-2060"><span class="linenos">2060</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition_by</span><span class="p">()</span> +</span><span id="L-2061"><a href="#L-2061"><span class="linenos">2061</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">()</span> +</span><span id="L-2062"><a href="#L-2062"><span class="linenos">2062</span></a> <span class="n">measures</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-2063"><a href="#L-2063"><span class="linenos">2063</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MEASURES"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="L-2064"><a href="#L-2064"><span class="linenos">2064</span></a> <span class="p">)</span> +</span><span id="L-2065"><a href="#L-2065"><span class="linenos">2065</span></a> +</span><span id="L-2066"><a href="#L-2066"><span class="linenos">2066</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ONE"</span><span class="p">,</span> <span class="s2">"ROW"</span><span class="p">,</span> <span class="s2">"PER"</span><span class="p">,</span> <span class="s2">"MATCH"</span><span class="p">):</span> +</span><span id="L-2067"><a href="#L-2067"><span class="linenos">2067</span></a> <span class="n">rows</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="s2">"ONE ROW PER MATCH"</span><span class="p">)</span> +</span><span id="L-2068"><a href="#L-2068"><span class="linenos">2068</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ALL"</span><span class="p">,</span> <span class="s2">"ROWS"</span><span class="p">,</span> <span class="s2">"PER"</span><span class="p">,</span> <span class="s2">"MATCH"</span><span class="p">):</span> +</span><span id="L-2069"><a href="#L-2069"><span class="linenos">2069</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">"ALL ROWS PER MATCH"</span> +</span><span id="L-2070"><a href="#L-2070"><span class="linenos">2070</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SHOW"</span><span class="p">,</span> <span class="s2">"EMPTY"</span><span class="p">,</span> <span class="s2">"MATCHES"</span><span class="p">):</span> +</span><span id="L-2071"><a href="#L-2071"><span class="linenos">2071</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" SHOW EMPTY MATCHES"</span> +</span><span id="L-2072"><a href="#L-2072"><span class="linenos">2072</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OMIT"</span><span class="p">,</span> <span class="s2">"EMPTY"</span><span class="p">,</span> <span class="s2">"MATCHES"</span><span class="p">):</span> +</span><span id="L-2073"><a href="#L-2073"><span class="linenos">2073</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" OMIT EMPTY MATCHES"</span> +</span><span id="L-2074"><a href="#L-2074"><span class="linenos">2074</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"UNMATCHED"</span><span class="p">,</span> <span class="s2">"ROWS"</span><span class="p">):</span> +</span><span id="L-2075"><a href="#L-2075"><span class="linenos">2075</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" WITH UNMATCHED ROWS"</span> +</span><span id="L-2076"><a href="#L-2076"><span class="linenos">2076</span></a> <span class="n">rows</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="n">text</span><span class="p">)</span> +</span><span id="L-2077"><a href="#L-2077"><span class="linenos">2077</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2078"><a href="#L-2078"><span class="linenos">2078</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2079"><a href="#L-2079"><span class="linenos">2079</span></a> +</span><span id="L-2080"><a href="#L-2080"><span class="linenos">2080</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AFTER"</span><span class="p">,</span> <span class="s2">"MATCH"</span><span class="p">,</span> <span class="s2">"SKIP"</span><span class="p">):</span> +</span><span id="L-2081"><a href="#L-2081"><span class="linenos">2081</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">"AFTER MATCH SKIP"</span> +</span><span id="L-2082"><a href="#L-2082"><span class="linenos">2082</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PAST"</span><span class="p">,</span> <span class="s2">"LAST"</span><span class="p">,</span> <span class="s2">"ROW"</span><span class="p">):</span> +</span><span id="L-2083"><a href="#L-2083"><span class="linenos">2083</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" PAST LAST ROW"</span> +</span><span id="L-2084"><a href="#L-2084"><span class="linenos">2084</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"NEXT"</span><span class="p">,</span> <span class="s2">"ROW"</span><span class="p">):</span> +</span><span id="L-2085"><a href="#L-2085"><span class="linenos">2085</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" TO NEXT ROW"</span> +</span><span id="L-2086"><a href="#L-2086"><span class="linenos">2086</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"FIRST"</span><span class="p">):</span> +</span><span id="L-2087"><a href="#L-2087"><span class="linenos">2087</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" TO FIRST </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</span><span class="p">()</span><span class="o">.</span><span class="n">text</span><span class="si">}</span><span class="s2">"</span> <span class="c1"># type: ignore</span> +</span><span id="L-2088"><a href="#L-2088"><span class="linenos">2088</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"LAST"</span><span class="p">):</span> +</span><span id="L-2089"><a href="#L-2089"><span class="linenos">2089</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" TO LAST </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</span><span class="p">()</span><span class="o">.</span><span class="n">text</span><span class="si">}</span><span class="s2">"</span> <span class="c1"># type: ignore</span> +</span><span id="L-2090"><a href="#L-2090"><span class="linenos">2090</span></a> <span class="n">after</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="n">text</span><span class="p">)</span> +</span><span id="L-2091"><a href="#L-2091"><span class="linenos">2091</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2092"><a href="#L-2092"><span class="linenos">2092</span></a> <span class="n">after</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2093"><a href="#L-2093"><span class="linenos">2093</span></a> +</span><span id="L-2094"><a href="#L-2094"><span class="linenos">2094</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PATTERN"</span><span class="p">):</span> +</span><span id="L-2095"><a href="#L-2095"><span class="linenos">2095</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> +</span><span id="L-2096"><a href="#L-2096"><span class="linenos">2096</span></a> +</span><span id="L-2097"><a href="#L-2097"><span class="linenos">2097</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="L-2098"><a href="#L-2098"><span class="linenos">2098</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting )"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">)</span> +</span><span id="L-2099"><a href="#L-2099"><span class="linenos">2099</span></a> +</span><span id="L-2100"><a href="#L-2100"><span class="linenos">2100</span></a> <span class="n">paren</span> <span class="o">=</span> <span class="mi">1</span> +</span><span id="L-2101"><a href="#L-2101"><span class="linenos">2101</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> +</span><span id="L-2102"><a href="#L-2102"><span class="linenos">2102</span></a> +</span><span id="L-2103"><a href="#L-2103"><span class="linenos">2103</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">and</span> <span class="n">paren</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> +</span><span id="L-2104"><a href="#L-2104"><span class="linenos">2104</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">:</span> +</span><span id="L-2105"><a href="#L-2105"><span class="linenos">2105</span></a> <span class="n">paren</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="L-2106"><a href="#L-2106"><span class="linenos">2106</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_PAREN</span><span class="p">:</span> +</span><span id="L-2107"><a href="#L-2107"><span class="linenos">2107</span></a> <span class="n">paren</span> <span class="o">-=</span> <span class="mi">1</span> +</span><span id="L-2108"><a href="#L-2108"><span class="linenos">2108</span></a> +</span><span id="L-2109"><a href="#L-2109"><span class="linenos">2109</span></a> <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> +</span><span id="L-2110"><a href="#L-2110"><span class="linenos">2110</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-2111"><a href="#L-2111"><span class="linenos">2111</span></a> +</span><span id="L-2112"><a href="#L-2112"><span class="linenos">2112</span></a> <span class="k">if</span> <span class="n">paren</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> +</span><span id="L-2113"><a href="#L-2113"><span class="linenos">2113</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting )"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">)</span> </span><span id="L-2114"><a href="#L-2114"><span class="linenos">2114</span></a> -</span><span id="L-2115"><a href="#L-2115"><span class="linenos">2115</span></a> <span class="n">define</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-2116"><a href="#L-2116"><span class="linenos">2116</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> -</span><span id="L-2117"><a href="#L-2117"><span class="linenos">2117</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-2118"><a href="#L-2118"><span class="linenos">2118</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">,</span> -</span><span id="L-2119"><a href="#L-2119"><span class="linenos">2119</span></a> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="L-2120"><a href="#L-2120"><span class="linenos">2120</span></a> <span class="n">this</span><span class="o">=</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">ALIAS</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">(),</span> -</span><span id="L-2121"><a href="#L-2121"><span class="linenos">2121</span></a> <span class="p">)</span> -</span><span id="L-2122"><a href="#L-2122"><span class="linenos">2122</span></a> <span class="p">)</span> -</span><span id="L-2123"><a href="#L-2123"><span class="linenos">2123</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFINE"</span><span class="p">)</span> -</span><span id="L-2124"><a href="#L-2124"><span class="linenos">2124</span></a> <span class="k">else</span> <span class="kc">None</span> -</span><span id="L-2125"><a href="#L-2125"><span class="linenos">2125</span></a> <span class="p">)</span> -</span><span id="L-2126"><a href="#L-2126"><span class="linenos">2126</span></a> -</span><span id="L-2127"><a href="#L-2127"><span class="linenos">2127</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="L-2128"><a href="#L-2128"><span class="linenos">2128</span></a> -</span><span id="L-2129"><a href="#L-2129"><span class="linenos">2129</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-2130"><a href="#L-2130"><span class="linenos">2130</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">,</span> -</span><span id="L-2131"><a href="#L-2131"><span class="linenos">2131</span></a> <span class="n">partition_by</span><span class="o">=</span><span class="n">partition</span><span class="p">,</span> -</span><span id="L-2132"><a href="#L-2132"><span class="linenos">2132</span></a> <span class="n">order</span><span class="o">=</span><span class="n">order</span><span class="p">,</span> -</span><span id="L-2133"><a href="#L-2133"><span class="linenos">2133</span></a> <span class="n">measures</span><span class="o">=</span><span class="n">measures</span><span class="p">,</span> -</span><span id="L-2134"><a href="#L-2134"><span class="linenos">2134</span></a> <span class="n">rows</span><span class="o">=</span><span class="n">rows</span><span class="p">,</span> -</span><span id="L-2135"><a href="#L-2135"><span class="linenos">2135</span></a> <span class="n">after</span><span class="o">=</span><span class="n">after</span><span class="p">,</span> -</span><span id="L-2136"><a href="#L-2136"><span class="linenos">2136</span></a> <span class="n">pattern</span><span class="o">=</span><span class="n">pattern</span><span class="p">,</span> -</span><span id="L-2137"><a href="#L-2137"><span class="linenos">2137</span></a> <span class="n">define</span><span class="o">=</span><span class="n">define</span><span class="p">,</span> -</span><span id="L-2138"><a href="#L-2138"><span class="linenos">2138</span></a> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">(),</span> -</span><span id="L-2139"><a href="#L-2139"><span class="linenos">2139</span></a> <span class="p">)</span> -</span><span id="L-2140"><a href="#L-2140"><span class="linenos">2140</span></a> -</span><span id="L-2141"><a href="#L-2141"><span class="linenos">2141</span></a> <span class="k">def</span> <span class="nf">_parse_lateral</span><span class="p">(</span><span class="bp">self</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">Lateral</span><span class="p">]:</span> -</span><span id="L-2142"><a href="#L-2142"><span class="linenos">2142</span></a> <span class="n">outer_apply</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">OUTER</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">)</span> -</span><span id="L-2143"><a href="#L-2143"><span class="linenos">2143</span></a> <span class="n">cross_apply</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">CROSS</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">)</span> +</span><span id="L-2115"><a href="#L-2115"><span class="linenos">2115</span></a> <span class="n">pattern</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="bp">self</span><span class="o">.</span><span class="n">_find_sql</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">))</span> +</span><span id="L-2116"><a href="#L-2116"><span class="linenos">2116</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2117"><a href="#L-2117"><span class="linenos">2117</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2118"><a href="#L-2118"><span class="linenos">2118</span></a> +</span><span id="L-2119"><a href="#L-2119"><span class="linenos">2119</span></a> <span class="n">define</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-2120"><a href="#L-2120"><span class="linenos">2120</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> +</span><span id="L-2121"><a href="#L-2121"><span class="linenos">2121</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-2122"><a href="#L-2122"><span class="linenos">2122</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">,</span> +</span><span id="L-2123"><a href="#L-2123"><span class="linenos">2123</span></a> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="L-2124"><a href="#L-2124"><span class="linenos">2124</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ALIAS</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">(),</span> +</span><span id="L-2125"><a href="#L-2125"><span class="linenos">2125</span></a> <span class="p">)</span> +</span><span id="L-2126"><a href="#L-2126"><span class="linenos">2126</span></a> <span class="p">)</span> +</span><span id="L-2127"><a href="#L-2127"><span class="linenos">2127</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFINE"</span><span class="p">)</span> +</span><span id="L-2128"><a href="#L-2128"><span class="linenos">2128</span></a> <span class="k">else</span> <span class="kc">None</span> +</span><span id="L-2129"><a href="#L-2129"><span class="linenos">2129</span></a> <span class="p">)</span> +</span><span id="L-2130"><a href="#L-2130"><span class="linenos">2130</span></a> +</span><span id="L-2131"><a href="#L-2131"><span class="linenos">2131</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-2132"><a href="#L-2132"><span class="linenos">2132</span></a> +</span><span id="L-2133"><a href="#L-2133"><span class="linenos">2133</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-2134"><a href="#L-2134"><span class="linenos">2134</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">,</span> +</span><span id="L-2135"><a href="#L-2135"><span class="linenos">2135</span></a> <span class="n">partition_by</span><span class="o">=</span><span class="n">partition</span><span class="p">,</span> +</span><span id="L-2136"><a href="#L-2136"><span class="linenos">2136</span></a> <span class="n">order</span><span class="o">=</span><span class="n">order</span><span class="p">,</span> +</span><span id="L-2137"><a href="#L-2137"><span class="linenos">2137</span></a> <span class="n">measures</span><span class="o">=</span><span class="n">measures</span><span class="p">,</span> +</span><span id="L-2138"><a href="#L-2138"><span class="linenos">2138</span></a> <span class="n">rows</span><span class="o">=</span><span class="n">rows</span><span class="p">,</span> +</span><span id="L-2139"><a href="#L-2139"><span class="linenos">2139</span></a> <span class="n">after</span><span class="o">=</span><span class="n">after</span><span class="p">,</span> +</span><span id="L-2140"><a href="#L-2140"><span class="linenos">2140</span></a> <span class="n">pattern</span><span class="o">=</span><span class="n">pattern</span><span class="p">,</span> +</span><span id="L-2141"><a href="#L-2141"><span class="linenos">2141</span></a> <span class="n">define</span><span class="o">=</span><span class="n">define</span><span class="p">,</span> +</span><span id="L-2142"><a href="#L-2142"><span class="linenos">2142</span></a> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">(),</span> +</span><span id="L-2143"><a href="#L-2143"><span class="linenos">2143</span></a> <span class="p">)</span> </span><span id="L-2144"><a href="#L-2144"><span class="linenos">2144</span></a> -</span><span id="L-2145"><a href="#L-2145"><span class="linenos">2145</span></a> <span class="k">if</span> <span class="n">outer_apply</span> <span class="ow">or</span> <span class="n">cross_apply</span><span class="p">:</span> -</span><span id="L-2146"><a href="#L-2146"><span class="linenos">2146</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2147"><a href="#L-2147"><span class="linenos">2147</span></a> <span class="n">view</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2148"><a href="#L-2148"><span class="linenos">2148</span></a> <span class="n">outer</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">cross_apply</span> -</span><span id="L-2149"><a href="#L-2149"><span class="linenos">2149</span></a> <span class="k">elif</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">LATERAL</span><span class="p">):</span> +</span><span id="L-2145"><a href="#L-2145"><span class="linenos">2145</span></a> <span class="k">def</span> <span class="nf">_parse_lateral</span><span class="p">(</span><span class="bp">self</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">Lateral</span><span class="p">]:</span> +</span><span id="L-2146"><a href="#L-2146"><span class="linenos">2146</span></a> <span class="n">outer_apply</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">OUTER</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">)</span> +</span><span id="L-2147"><a href="#L-2147"><span class="linenos">2147</span></a> <span class="n">cross_apply</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">CROSS</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">)</span> +</span><span id="L-2148"><a href="#L-2148"><span class="linenos">2148</span></a> +</span><span id="L-2149"><a href="#L-2149"><span class="linenos">2149</span></a> <span class="k">if</span> <span class="n">outer_apply</span> <span class="ow">or</span> <span class="n">cross_apply</span><span class="p">:</span> </span><span id="L-2150"><a href="#L-2150"><span class="linenos">2150</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2151"><a href="#L-2151"><span class="linenos">2151</span></a> <span class="n">view</span> <span class="o">=</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">VIEW</span><span class="p">)</span> -</span><span id="L-2152"><a href="#L-2152"><span class="linenos">2152</span></a> <span class="n">outer</span> <span class="o">=</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">OUTER</span><span class="p">)</span> -</span><span id="L-2153"><a href="#L-2153"><span class="linenos">2153</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2154"><a href="#L-2154"><span class="linenos">2154</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-2155"><a href="#L-2155"><span class="linenos">2155</span></a> -</span><span id="L-2156"><a href="#L-2156"><span class="linenos">2156</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> -</span><span id="L-2157"><a href="#L-2157"><span class="linenos">2157</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-2158"><a href="#L-2158"><span class="linenos">2158</span></a> <span class="k">while</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">DOT</span><span class="p">):</span> -</span><span id="L-2159"><a href="#L-2159"><span class="linenos">2159</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">(</span> -</span><span id="L-2160"><a href="#L-2160"><span class="linenos">2160</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-2161"><a href="#L-2161"><span class="linenos">2161</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="L-2162"><a href="#L-2162"><span class="linenos">2162</span></a> <span class="p">)</span> -</span><span id="L-2163"><a href="#L-2163"><span class="linenos">2163</span></a> -</span><span id="L-2164"><a href="#L-2164"><span class="linenos">2164</span></a> <span class="k">if</span> <span class="n">view</span><span class="p">:</span> -</span><span id="L-2165"><a href="#L-2165"><span class="linenos">2165</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-2166"><a href="#L-2166"><span class="linenos">2166</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">)</span> <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">ALIAS</span><span class="p">)</span> <span class="k">else</span> <span class="p">[]</span> -</span><span id="L-2167"><a href="#L-2167"><span class="linenos">2167</span></a> <span class="n">table_alias</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">TableAlias</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-2168"><a href="#L-2168"><span class="linenos">2168</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableAlias</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="n">columns</span> -</span><span id="L-2169"><a href="#L-2169"><span class="linenos">2169</span></a> <span class="p">)</span> -</span><span id="L-2170"><a href="#L-2170"><span class="linenos">2170</span></a> <span class="k">elif</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">Subquery</span><span class="p">)</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> -</span><span id="L-2171"><a href="#L-2171"><span class="linenos">2171</span></a> <span class="c1"># Ensures parity between the Subquery's and the Lateral's "alias" args</span> -</span><span id="L-2172"><a href="#L-2172"><span class="linenos">2172</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"alias"</span><span class="p">]</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="L-2173"><a href="#L-2173"><span class="linenos">2173</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2174"><a href="#L-2174"><span class="linenos">2174</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> -</span><span id="L-2175"><a href="#L-2175"><span class="linenos">2175</span></a> -</span><span id="L-2176"><a href="#L-2176"><span class="linenos">2176</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">Lateral</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">view</span><span class="o">=</span><span class="n">view</span><span class="p">,</span> <span class="n">outer</span><span class="o">=</span><span class="n">outer</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">table_alias</span><span class="p">)</span> -</span><span id="L-2177"><a href="#L-2177"><span class="linenos">2177</span></a> -</span><span id="L-2178"><a href="#L-2178"><span class="linenos">2178</span></a> <span class="k">def</span> <span class="nf">_parse_join_parts</span><span class="p">(</span> -</span><span id="L-2179"><a href="#L-2179"><span class="linenos">2179</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2180"><a href="#L-2180"><span class="linenos">2180</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">Token</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">Token</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">Token</span><span class="p">]]:</span> -</span><span id="L-2181"><a href="#L-2181"><span class="linenos">2181</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="L-2182"><a href="#L-2182"><span class="linenos">2182</span></a> <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">JOIN_METHODS</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">,</span> -</span><span id="L-2183"><a href="#L-2183"><span class="linenos">2183</span></a> <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">JOIN_SIDES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">,</span> -</span><span id="L-2184"><a href="#L-2184"><span class="linenos">2184</span></a> <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">JOIN_KINDS</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">,</span> -</span><span id="L-2185"><a href="#L-2185"><span class="linenos">2185</span></a> <span class="p">)</span> -</span><span id="L-2186"><a href="#L-2186"><span class="linenos">2186</span></a> -</span><span id="L-2187"><a href="#L-2187"><span class="linenos">2187</span></a> <span class="k">def</span> <span class="nf">_parse_join</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_join_token</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">Join</span><span class="p">]:</span> -</span><span id="L-2188"><a href="#L-2188"><span class="linenos">2188</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">COMMA</span><span class="p">):</span> -</span><span id="L-2189"><a href="#L-2189"><span class="linenos">2189</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">Join</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_table</span><span class="p">())</span> +</span><span id="L-2151"><a href="#L-2151"><span class="linenos">2151</span></a> <span class="n">view</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2152"><a href="#L-2152"><span class="linenos">2152</span></a> <span class="n">outer</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">cross_apply</span> +</span><span id="L-2153"><a href="#L-2153"><span class="linenos">2153</span></a> <span class="k">elif</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">LATERAL</span><span class="p">):</span> +</span><span id="L-2154"><a href="#L-2154"><span class="linenos">2154</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-2155"><a href="#L-2155"><span class="linenos">2155</span></a> <span class="n">view</span> <span class="o">=</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">VIEW</span><span class="p">)</span> +</span><span id="L-2156"><a href="#L-2156"><span class="linenos">2156</span></a> <span class="n">outer</span> <span class="o">=</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">OUTER</span><span class="p">)</span> +</span><span id="L-2157"><a href="#L-2157"><span class="linenos">2157</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2158"><a href="#L-2158"><span class="linenos">2158</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2159"><a href="#L-2159"><span class="linenos">2159</span></a> +</span><span id="L-2160"><a href="#L-2160"><span class="linenos">2160</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> +</span><span id="L-2161"><a href="#L-2161"><span class="linenos">2161</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-2162"><a href="#L-2162"><span class="linenos">2162</span></a> <span class="k">while</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">DOT</span><span class="p">):</span> +</span><span id="L-2163"><a href="#L-2163"><span class="linenos">2163</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">(</span> +</span><span id="L-2164"><a href="#L-2164"><span class="linenos">2164</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-2165"><a href="#L-2165"><span class="linenos">2165</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="L-2166"><a href="#L-2166"><span class="linenos">2166</span></a> <span class="p">)</span> +</span><span id="L-2167"><a href="#L-2167"><span class="linenos">2167</span></a> +</span><span id="L-2168"><a href="#L-2168"><span class="linenos">2168</span></a> <span class="k">if</span> <span class="n">view</span><span class="p">:</span> +</span><span id="L-2169"><a href="#L-2169"><span class="linenos">2169</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-2170"><a href="#L-2170"><span class="linenos">2170</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">)</span> <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">ALIAS</span><span class="p">)</span> <span class="k">else</span> <span class="p">[]</span> +</span><span id="L-2171"><a href="#L-2171"><span class="linenos">2171</span></a> <span class="n">table_alias</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">TableAlias</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-2172"><a href="#L-2172"><span class="linenos">2172</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableAlias</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="n">columns</span> +</span><span id="L-2173"><a href="#L-2173"><span class="linenos">2173</span></a> <span class="p">)</span> +</span><span id="L-2174"><a href="#L-2174"><span class="linenos">2174</span></a> <span class="k">elif</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">Subquery</span><span class="p">)</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> +</span><span id="L-2175"><a href="#L-2175"><span class="linenos">2175</span></a> <span class="c1"># Ensures parity between the Subquery's and the Lateral's "alias" args</span> +</span><span id="L-2176"><a href="#L-2176"><span class="linenos">2176</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"alias"</span><span class="p">]</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="L-2177"><a href="#L-2177"><span class="linenos">2177</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2178"><a href="#L-2178"><span class="linenos">2178</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> +</span><span id="L-2179"><a href="#L-2179"><span class="linenos">2179</span></a> +</span><span id="L-2180"><a href="#L-2180"><span class="linenos">2180</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">Lateral</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">view</span><span class="o">=</span><span class="n">view</span><span class="p">,</span> <span class="n">outer</span><span class="o">=</span><span class="n">outer</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">table_alias</span><span class="p">)</span> +</span><span id="L-2181"><a href="#L-2181"><span class="linenos">2181</span></a> +</span><span id="L-2182"><a href="#L-2182"><span class="linenos">2182</span></a> <span class="k">def</span> <span class="nf">_parse_join_parts</span><span class="p">(</span> +</span><span id="L-2183"><a href="#L-2183"><span class="linenos">2183</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2184"><a href="#L-2184"><span class="linenos">2184</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">Token</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">Token</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">Token</span><span class="p">]]:</span> +</span><span id="L-2185"><a href="#L-2185"><span class="linenos">2185</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="L-2186"><a href="#L-2186"><span class="linenos">2186</span></a> <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">JOIN_METHODS</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">,</span> +</span><span id="L-2187"><a href="#L-2187"><span class="linenos">2187</span></a> <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">JOIN_SIDES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">,</span> +</span><span id="L-2188"><a href="#L-2188"><span class="linenos">2188</span></a> <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">JOIN_KINDS</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">,</span> +</span><span id="L-2189"><a href="#L-2189"><span class="linenos">2189</span></a> <span class="p">)</span> </span><span id="L-2190"><a href="#L-2190"><span class="linenos">2190</span></a> -</span><span id="L-2191"><a href="#L-2191"><span class="linenos">2191</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="L-2192"><a href="#L-2192"><span class="linenos">2192</span></a> <span class="n">method</span><span class="p">,</span> <span class="n">side</span><span class="p">,</span> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_join_parts</span><span class="p">()</span> -</span><span id="L-2193"><a href="#L-2193"><span class="linenos">2193</span></a> <span class="n">hint</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="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">JOIN_HINTS</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="L-2194"><a href="#L-2194"><span class="linenos">2194</span></a> <span class="n">join</span> <span class="o">=</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">JOIN</span><span class="p">)</span> -</span><span id="L-2195"><a href="#L-2195"><span class="linenos">2195</span></a> -</span><span id="L-2196"><a href="#L-2196"><span class="linenos">2196</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_join_token</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">join</span><span class="p">:</span> -</span><span id="L-2197"><a href="#L-2197"><span class="linenos">2197</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-2198"><a href="#L-2198"><span class="linenos">2198</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2199"><a href="#L-2199"><span class="linenos">2199</span></a> <span class="n">method</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2200"><a href="#L-2200"><span class="linenos">2200</span></a> <span class="n">side</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2201"><a href="#L-2201"><span class="linenos">2201</span></a> -</span><span id="L-2202"><a href="#L-2202"><span class="linenos">2202</span></a> <span class="n">outer_apply</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">OUTER</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> -</span><span id="L-2203"><a href="#L-2203"><span class="linenos">2203</span></a> <span class="n">cross_apply</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">CROSS</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> -</span><span id="L-2204"><a href="#L-2204"><span class="linenos">2204</span></a> -</span><span id="L-2205"><a href="#L-2205"><span class="linenos">2205</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_join_token</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">join</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">outer_apply</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">cross_apply</span><span class="p">:</span> -</span><span id="L-2206"><a href="#L-2206"><span class="linenos">2206</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-2207"><a href="#L-2207"><span class="linenos">2207</span></a> -</span><span id="L-2208"><a href="#L-2208"><span class="linenos">2208</span></a> <span class="k">if</span> <span class="n">outer_apply</span><span class="p">:</span> -</span><span id="L-2209"><a href="#L-2209"><span class="linenos">2209</span></a> <span class="n">side</span> <span class="o">=</span> <span class="n">Token</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">LEFT</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">)</span> -</span><span id="L-2210"><a href="#L-2210"><span class="linenos">2210</span></a> -</span><span id="L-2211"><a href="#L-2211"><span class="linenos">2211</span></a> <span class="n">kwargs</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()}</span> -</span><span id="L-2212"><a href="#L-2212"><span class="linenos">2212</span></a> -</span><span id="L-2213"><a href="#L-2213"><span class="linenos">2213</span></a> <span class="k">if</span> <span class="n">method</span><span class="p">:</span> -</span><span id="L-2214"><a href="#L-2214"><span class="linenos">2214</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"method"</span><span class="p">]</span> <span class="o">=</span> <span class="n">method</span><span class="o">.</span><span class="n">text</span> -</span><span id="L-2215"><a href="#L-2215"><span class="linenos">2215</span></a> <span class="k">if</span> <span class="n">side</span><span class="p">:</span> -</span><span id="L-2216"><a href="#L-2216"><span class="linenos">2216</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"side"</span><span class="p">]</span> <span class="o">=</span> <span class="n">side</span><span class="o">.</span><span class="n">text</span> -</span><span id="L-2217"><a href="#L-2217"><span class="linenos">2217</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="L-2218"><a href="#L-2218"><span class="linenos">2218</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> <span class="o">=</span> <span class="n">kind</span><span class="o">.</span><span class="n">text</span> -</span><span id="L-2219"><a href="#L-2219"><span class="linenos">2219</span></a> <span class="k">if</span> <span class="n">hint</span><span class="p">:</span> -</span><span id="L-2220"><a href="#L-2220"><span class="linenos">2220</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"hint"</span><span class="p">]</span> <span class="o">=</span> <span class="n">hint</span> -</span><span id="L-2221"><a href="#L-2221"><span class="linenos">2221</span></a> -</span><span id="L-2222"><a href="#L-2222"><span class="linenos">2222</span></a> <span class="k">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">ON</span><span class="p">):</span> -</span><span id="L-2223"><a href="#L-2223"><span class="linenos">2223</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"on"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="L-2224"><a href="#L-2224"><span class="linenos">2224</span></a> <span class="k">elif</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">USING</span><span class="p">):</span> -</span><span id="L-2225"><a href="#L-2225"><span class="linenos">2225</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"using"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_id_vars</span><span class="p">()</span> -</span><span id="L-2226"><a href="#L-2226"><span class="linenos">2226</span></a> -</span><span id="L-2227"><a href="#L-2227"><span class="linenos">2227</span></a> <span class="k">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">Join</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="L-2228"><a href="#L-2228"><span class="linenos">2228</span></a> -</span><span id="L-2229"><a href="#L-2229"><span class="linenos">2229</span></a> <span class="k">def</span> <span class="nf">_parse_index</span><span class="p">(</span> -</span><span id="L-2230"><a href="#L-2230"><span class="linenos">2230</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2231"><a href="#L-2231"><span class="linenos">2231</span></a> <span class="n">index</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2232"><a href="#L-2232"><span class="linenos">2232</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">Index</span><span class="p">]:</span> -</span><span id="L-2233"><a href="#L-2233"><span class="linenos">2233</span></a> <span class="k">if</span> <span class="n">index</span><span class="p">:</span> -</span><span id="L-2234"><a href="#L-2234"><span class="linenos">2234</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2235"><a href="#L-2235"><span class="linenos">2235</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2236"><a href="#L-2236"><span class="linenos">2236</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2237"><a href="#L-2237"><span class="linenos">2237</span></a> -</span><span id="L-2238"><a href="#L-2238"><span class="linenos">2238</span></a> <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">ON</span><span class="p">)</span> -</span><span id="L-2239"><a href="#L-2239"><span class="linenos">2239</span></a> <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">TABLE</span><span class="p">)</span> <span class="c1"># hive</span> -</span><span id="L-2240"><a href="#L-2240"><span class="linenos">2240</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2241"><a href="#L-2241"><span class="linenos">2241</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2242"><a href="#L-2242"><span class="linenos">2242</span></a> <span class="n">unique</span> <span class="o">=</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">UNIQUE</span><span class="p">)</span> -</span><span id="L-2243"><a href="#L-2243"><span class="linenos">2243</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PRIMARY"</span><span class="p">)</span> -</span><span id="L-2244"><a href="#L-2244"><span class="linenos">2244</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AMP"</span><span class="p">)</span> -</span><span id="L-2245"><a href="#L-2245"><span class="linenos">2245</span></a> -</span><span id="L-2246"><a href="#L-2246"><span class="linenos">2246</span></a> <span class="k">if</span> <span class="ow">not</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">INDEX</span><span class="p">):</span> -</span><span id="L-2247"><a href="#L-2247"><span class="linenos">2247</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-2248"><a href="#L-2248"><span class="linenos">2248</span></a> -</span><span id="L-2249"><a href="#L-2249"><span class="linenos">2249</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="L-2250"><a href="#L-2250"><span class="linenos">2250</span></a> <span class="n">table</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2251"><a href="#L-2251"><span class="linenos">2251</span></a> -</span><span id="L-2252"><a href="#L-2252"><span class="linenos">2252</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> <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">USING</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="L-2253"><a href="#L-2253"><span class="linenos">2253</span></a> -</span><span id="L-2254"><a href="#L-2254"><span class="linenos">2254</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_PAREN</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-2255"><a href="#L-2255"><span class="linenos">2255</span></a> <span class="n">columns</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_ordered</span><span class="p">)</span> -</span><span id="L-2256"><a href="#L-2256"><span class="linenos">2256</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2257"><a href="#L-2257"><span class="linenos">2257</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2258"><a href="#L-2258"><span class="linenos">2258</span></a> -</span><span id="L-2259"><a href="#L-2259"><span class="linenos">2259</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-2260"><a href="#L-2260"><span class="linenos">2260</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Index</span><span class="p">,</span> -</span><span id="L-2261"><a href="#L-2261"><span class="linenos">2261</span></a> <span class="n">this</span><span class="o">=</span><span class="n">index</span><span class="p">,</span> -</span><span id="L-2262"><a href="#L-2262"><span class="linenos">2262</span></a> <span class="n">table</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> -</span><span id="L-2263"><a href="#L-2263"><span class="linenos">2263</span></a> <span class="n">using</span><span class="o">=</span><span class="n">using</span><span class="p">,</span> -</span><span id="L-2264"><a href="#L-2264"><span class="linenos">2264</span></a> <span class="n">columns</span><span class="o">=</span><span class="n">columns</span><span class="p">,</span> -</span><span id="L-2265"><a href="#L-2265"><span class="linenos">2265</span></a> <span class="n">unique</span><span class="o">=</span><span class="n">unique</span><span class="p">,</span> -</span><span id="L-2266"><a href="#L-2266"><span class="linenos">2266</span></a> <span class="n">primary</span><span class="o">=</span><span class="n">primary</span><span class="p">,</span> -</span><span id="L-2267"><a href="#L-2267"><span class="linenos">2267</span></a> <span class="n">amp</span><span class="o">=</span><span class="n">amp</span><span class="p">,</span> -</span><span id="L-2268"><a href="#L-2268"><span class="linenos">2268</span></a> <span class="n">partition_by</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition_by</span><span class="p">(),</span> -</span><span id="L-2269"><a href="#L-2269"><span class="linenos">2269</span></a> <span class="p">)</span> -</span><span id="L-2270"><a href="#L-2270"><span class="linenos">2270</span></a> -</span><span id="L-2271"><a href="#L-2271"><span class="linenos">2271</span></a> <span class="k">def</span> <span class="nf">_parse_table_part</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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-2272"><a href="#L-2272"><span class="linenos">2272</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="L-2273"><a href="#L-2273"><span class="linenos">2273</span></a> <span class="p">(</span><span class="ow">not</span> <span class="n">schema</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">(</span><span class="n">optional_parens</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> -</span><span id="L-2274"><a href="#L-2274"><span class="linenos">2274</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-2275"><a href="#L-2275"><span class="linenos">2275</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string_as_identifier</span><span class="p">()</span> -</span><span id="L-2276"><a href="#L-2276"><span class="linenos">2276</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_placeholder</span><span class="p">()</span> -</span><span id="L-2277"><a href="#L-2277"><span class="linenos">2277</span></a> <span class="p">)</span> -</span><span id="L-2278"><a href="#L-2278"><span class="linenos">2278</span></a> -</span><span id="L-2279"><a href="#L-2279"><span class="linenos">2279</span></a> <span class="k">def</span> <span class="nf">_parse_table_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> -</span><span id="L-2280"><a href="#L-2280"><span class="linenos">2280</span></a> <span class="n">catalog</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2281"><a href="#L-2281"><span class="linenos">2281</span></a> <span class="n">db</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2282"><a href="#L-2282"><span class="linenos">2282</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="L-2283"><a href="#L-2283"><span class="linenos">2283</span></a> -</span><span id="L-2284"><a href="#L-2284"><span class="linenos">2284</span></a> <span class="k">while</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">DOT</span><span class="p">):</span> -</span><span id="L-2285"><a href="#L-2285"><span class="linenos">2285</span></a> <span class="k">if</span> <span class="n">catalog</span><span class="p">:</span> -</span><span id="L-2286"><a href="#L-2286"><span class="linenos">2286</span></a> <span class="c1"># This allows nesting the table in arbitrarily many dot expressions if needed</span> -</span><span id="L-2287"><a href="#L-2287"><span class="linenos">2287</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-2288"><a href="#L-2288"><span class="linenos">2288</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="L-2289"><a href="#L-2289"><span class="linenos">2289</span></a> <span class="p">)</span> -</span><span id="L-2290"><a href="#L-2290"><span class="linenos">2290</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2291"><a href="#L-2291"><span class="linenos">2291</span></a> <span class="n">catalog</span> <span class="o">=</span> <span class="n">db</span> -</span><span id="L-2292"><a href="#L-2292"><span class="linenos">2292</span></a> <span class="n">db</span> <span class="o">=</span> <span class="n">table</span> -</span><span id="L-2293"><a href="#L-2293"><span class="linenos">2293</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="L-2294"><a href="#L-2294"><span class="linenos">2294</span></a> -</span><span id="L-2295"><a href="#L-2295"><span class="linenos">2295</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span><span class="p">:</span> -</span><span id="L-2296"><a href="#L-2296"><span class="linenos">2296</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Expected table name but got </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-2297"><a href="#L-2297"><span class="linenos">2297</span></a> -</span><span id="L-2298"><a href="#L-2298"><span class="linenos">2298</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><span id="L-2299"><a href="#L-2299"><span class="linenos">2299</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="n">db</span><span class="p">,</span> <span class="n">catalog</span><span class="o">=</span><span class="n">catalog</span><span class="p">,</span> <span class="n">pivots</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivots</span><span class="p">()</span> -</span><span id="L-2300"><a href="#L-2300"><span class="linenos">2300</span></a> <span class="p">)</span> +</span><span id="L-2191"><a href="#L-2191"><span class="linenos">2191</span></a> <span class="k">def</span> <span class="nf">_parse_join</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_join_token</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">Join</span><span class="p">]:</span> +</span><span id="L-2192"><a href="#L-2192"><span class="linenos">2192</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">COMMA</span><span class="p">):</span> +</span><span id="L-2193"><a href="#L-2193"><span class="linenos">2193</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">Join</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_table</span><span class="p">())</span> +</span><span id="L-2194"><a href="#L-2194"><span class="linenos">2194</span></a> +</span><span id="L-2195"><a href="#L-2195"><span class="linenos">2195</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="L-2196"><a href="#L-2196"><span class="linenos">2196</span></a> <span class="n">method</span><span class="p">,</span> <span class="n">side</span><span class="p">,</span> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_join_parts</span><span class="p">()</span> +</span><span id="L-2197"><a href="#L-2197"><span class="linenos">2197</span></a> <span class="n">hint</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="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">JOIN_HINTS</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="L-2198"><a href="#L-2198"><span class="linenos">2198</span></a> <span class="n">join</span> <span class="o">=</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">JOIN</span><span class="p">)</span> +</span><span id="L-2199"><a href="#L-2199"><span class="linenos">2199</span></a> +</span><span id="L-2200"><a href="#L-2200"><span class="linenos">2200</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_join_token</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">join</span><span class="p">:</span> +</span><span id="L-2201"><a href="#L-2201"><span class="linenos">2201</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-2202"><a href="#L-2202"><span class="linenos">2202</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2203"><a href="#L-2203"><span class="linenos">2203</span></a> <span class="n">method</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2204"><a href="#L-2204"><span class="linenos">2204</span></a> <span class="n">side</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2205"><a href="#L-2205"><span class="linenos">2205</span></a> +</span><span id="L-2206"><a href="#L-2206"><span class="linenos">2206</span></a> <span class="n">outer_apply</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">OUTER</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> +</span><span id="L-2207"><a href="#L-2207"><span class="linenos">2207</span></a> <span class="n">cross_apply</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">CROSS</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> +</span><span id="L-2208"><a href="#L-2208"><span class="linenos">2208</span></a> +</span><span id="L-2209"><a href="#L-2209"><span class="linenos">2209</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_join_token</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">join</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">outer_apply</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">cross_apply</span><span class="p">:</span> +</span><span id="L-2210"><a href="#L-2210"><span class="linenos">2210</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2211"><a href="#L-2211"><span class="linenos">2211</span></a> +</span><span id="L-2212"><a href="#L-2212"><span class="linenos">2212</span></a> <span class="k">if</span> <span class="n">outer_apply</span><span class="p">:</span> +</span><span id="L-2213"><a href="#L-2213"><span class="linenos">2213</span></a> <span class="n">side</span> <span class="o">=</span> <span class="n">Token</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">LEFT</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">)</span> +</span><span id="L-2214"><a href="#L-2214"><span class="linenos">2214</span></a> +</span><span id="L-2215"><a href="#L-2215"><span class="linenos">2215</span></a> <span class="n">kwargs</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()}</span> +</span><span id="L-2216"><a href="#L-2216"><span class="linenos">2216</span></a> +</span><span id="L-2217"><a href="#L-2217"><span class="linenos">2217</span></a> <span class="k">if</span> <span class="n">method</span><span class="p">:</span> +</span><span id="L-2218"><a href="#L-2218"><span class="linenos">2218</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"method"</span><span class="p">]</span> <span class="o">=</span> <span class="n">method</span><span class="o">.</span><span class="n">text</span> +</span><span id="L-2219"><a href="#L-2219"><span class="linenos">2219</span></a> <span class="k">if</span> <span class="n">side</span><span class="p">:</span> +</span><span id="L-2220"><a href="#L-2220"><span class="linenos">2220</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"side"</span><span class="p">]</span> <span class="o">=</span> <span class="n">side</span><span class="o">.</span><span class="n">text</span> +</span><span id="L-2221"><a href="#L-2221"><span class="linenos">2221</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="L-2222"><a href="#L-2222"><span class="linenos">2222</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> <span class="o">=</span> <span class="n">kind</span><span class="o">.</span><span class="n">text</span> +</span><span id="L-2223"><a href="#L-2223"><span class="linenos">2223</span></a> <span class="k">if</span> <span class="n">hint</span><span class="p">:</span> +</span><span id="L-2224"><a href="#L-2224"><span class="linenos">2224</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"hint"</span><span class="p">]</span> <span class="o">=</span> <span class="n">hint</span> +</span><span id="L-2225"><a href="#L-2225"><span class="linenos">2225</span></a> +</span><span id="L-2226"><a href="#L-2226"><span class="linenos">2226</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">ON</span><span class="p">):</span> +</span><span id="L-2227"><a href="#L-2227"><span class="linenos">2227</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"on"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="L-2228"><a href="#L-2228"><span class="linenos">2228</span></a> <span class="k">elif</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">USING</span><span class="p">):</span> +</span><span id="L-2229"><a href="#L-2229"><span class="linenos">2229</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"using"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_id_vars</span><span class="p">()</span> +</span><span id="L-2230"><a href="#L-2230"><span class="linenos">2230</span></a> +</span><span id="L-2231"><a href="#L-2231"><span class="linenos">2231</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">Join</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="L-2232"><a href="#L-2232"><span class="linenos">2232</span></a> +</span><span id="L-2233"><a href="#L-2233"><span class="linenos">2233</span></a> <span class="k">def</span> <span class="nf">_parse_index</span><span class="p">(</span> +</span><span id="L-2234"><a href="#L-2234"><span class="linenos">2234</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2235"><a href="#L-2235"><span class="linenos">2235</span></a> <span class="n">index</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2236"><a href="#L-2236"><span class="linenos">2236</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">Index</span><span class="p">]:</span> +</span><span id="L-2237"><a href="#L-2237"><span class="linenos">2237</span></a> <span class="k">if</span> <span class="n">index</span><span class="p">:</span> +</span><span id="L-2238"><a href="#L-2238"><span class="linenos">2238</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2239"><a href="#L-2239"><span class="linenos">2239</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2240"><a href="#L-2240"><span class="linenos">2240</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2241"><a href="#L-2241"><span class="linenos">2241</span></a> +</span><span id="L-2242"><a href="#L-2242"><span class="linenos">2242</span></a> <span class="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">ON</span><span class="p">)</span> +</span><span id="L-2243"><a href="#L-2243"><span class="linenos">2243</span></a> <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">TABLE</span><span class="p">)</span> <span class="c1"># hive</span> +</span><span id="L-2244"><a href="#L-2244"><span class="linenos">2244</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-2245"><a href="#L-2245"><span class="linenos">2245</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2246"><a href="#L-2246"><span class="linenos">2246</span></a> <span class="n">unique</span> <span class="o">=</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">UNIQUE</span><span class="p">)</span> +</span><span id="L-2247"><a href="#L-2247"><span class="linenos">2247</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PRIMARY"</span><span class="p">)</span> +</span><span id="L-2248"><a href="#L-2248"><span class="linenos">2248</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AMP"</span><span class="p">)</span> +</span><span id="L-2249"><a href="#L-2249"><span class="linenos">2249</span></a> +</span><span id="L-2250"><a href="#L-2250"><span class="linenos">2250</span></a> <span class="k">if</span> <span class="ow">not</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">INDEX</span><span class="p">):</span> +</span><span id="L-2251"><a href="#L-2251"><span class="linenos">2251</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2252"><a href="#L-2252"><span class="linenos">2252</span></a> +</span><span id="L-2253"><a href="#L-2253"><span class="linenos">2253</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="L-2254"><a href="#L-2254"><span class="linenos">2254</span></a> <span class="n">table</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2255"><a href="#L-2255"><span class="linenos">2255</span></a> +</span><span id="L-2256"><a href="#L-2256"><span class="linenos">2256</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> <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">USING</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="L-2257"><a href="#L-2257"><span class="linenos">2257</span></a> +</span><span id="L-2258"><a href="#L-2258"><span class="linenos">2258</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_PAREN</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-2259"><a href="#L-2259"><span class="linenos">2259</span></a> <span class="n">columns</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_ordered</span><span class="p">)</span> +</span><span id="L-2260"><a href="#L-2260"><span class="linenos">2260</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2261"><a href="#L-2261"><span class="linenos">2261</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2262"><a href="#L-2262"><span class="linenos">2262</span></a> +</span><span id="L-2263"><a href="#L-2263"><span class="linenos">2263</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-2264"><a href="#L-2264"><span class="linenos">2264</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Index</span><span class="p">,</span> +</span><span id="L-2265"><a href="#L-2265"><span class="linenos">2265</span></a> <span class="n">this</span><span class="o">=</span><span class="n">index</span><span class="p">,</span> +</span><span id="L-2266"><a href="#L-2266"><span class="linenos">2266</span></a> <span class="n">table</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> +</span><span id="L-2267"><a href="#L-2267"><span class="linenos">2267</span></a> <span class="n">using</span><span class="o">=</span><span class="n">using</span><span class="p">,</span> +</span><span id="L-2268"><a href="#L-2268"><span class="linenos">2268</span></a> <span class="n">columns</span><span class="o">=</span><span class="n">columns</span><span class="p">,</span> +</span><span id="L-2269"><a href="#L-2269"><span class="linenos">2269</span></a> <span class="n">unique</span><span class="o">=</span><span class="n">unique</span><span class="p">,</span> +</span><span id="L-2270"><a href="#L-2270"><span class="linenos">2270</span></a> <span class="n">primary</span><span class="o">=</span><span class="n">primary</span><span class="p">,</span> +</span><span id="L-2271"><a href="#L-2271"><span class="linenos">2271</span></a> <span class="n">amp</span><span class="o">=</span><span class="n">amp</span><span class="p">,</span> +</span><span id="L-2272"><a href="#L-2272"><span class="linenos">2272</span></a> <span class="n">partition_by</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition_by</span><span class="p">(),</span> +</span><span id="L-2273"><a href="#L-2273"><span class="linenos">2273</span></a> <span class="p">)</span> +</span><span id="L-2274"><a href="#L-2274"><span class="linenos">2274</span></a> +</span><span id="L-2275"><a href="#L-2275"><span class="linenos">2275</span></a> <span class="k">def</span> <span class="nf">_parse_table_part</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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-2276"><a href="#L-2276"><span class="linenos">2276</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="L-2277"><a href="#L-2277"><span class="linenos">2277</span></a> <span class="p">(</span><span class="ow">not</span> <span class="n">schema</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">(</span><span class="n">optional_parens</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> +</span><span id="L-2278"><a href="#L-2278"><span class="linenos">2278</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-2279"><a href="#L-2279"><span class="linenos">2279</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string_as_identifier</span><span class="p">()</span> +</span><span id="L-2280"><a href="#L-2280"><span class="linenos">2280</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_placeholder</span><span class="p">()</span> +</span><span id="L-2281"><a href="#L-2281"><span class="linenos">2281</span></a> <span class="p">)</span> +</span><span id="L-2282"><a href="#L-2282"><span class="linenos">2282</span></a> +</span><span id="L-2283"><a href="#L-2283"><span class="linenos">2283</span></a> <span class="k">def</span> <span class="nf">_parse_table_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> +</span><span id="L-2284"><a href="#L-2284"><span class="linenos">2284</span></a> <span class="n">catalog</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2285"><a href="#L-2285"><span class="linenos">2285</span></a> <span class="n">db</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2286"><a href="#L-2286"><span class="linenos">2286</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="L-2287"><a href="#L-2287"><span class="linenos">2287</span></a> +</span><span id="L-2288"><a href="#L-2288"><span class="linenos">2288</span></a> <span class="k">while</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">DOT</span><span class="p">):</span> +</span><span id="L-2289"><a href="#L-2289"><span class="linenos">2289</span></a> <span class="k">if</span> <span class="n">catalog</span><span class="p">:</span> +</span><span id="L-2290"><a href="#L-2290"><span class="linenos">2290</span></a> <span class="c1"># This allows nesting the table in arbitrarily many dot expressions if needed</span> +</span><span id="L-2291"><a href="#L-2291"><span class="linenos">2291</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-2292"><a href="#L-2292"><span class="linenos">2292</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="L-2293"><a href="#L-2293"><span class="linenos">2293</span></a> <span class="p">)</span> +</span><span id="L-2294"><a href="#L-2294"><span class="linenos">2294</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2295"><a href="#L-2295"><span class="linenos">2295</span></a> <span class="n">catalog</span> <span class="o">=</span> <span class="n">db</span> +</span><span id="L-2296"><a href="#L-2296"><span class="linenos">2296</span></a> <span class="n">db</span> <span class="o">=</span> <span class="n">table</span> +</span><span id="L-2297"><a href="#L-2297"><span class="linenos">2297</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="L-2298"><a href="#L-2298"><span class="linenos">2298</span></a> +</span><span id="L-2299"><a href="#L-2299"><span class="linenos">2299</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span><span class="p">:</span> +</span><span id="L-2300"><a href="#L-2300"><span class="linenos">2300</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Expected table name but got </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> </span><span id="L-2301"><a href="#L-2301"><span class="linenos">2301</span></a> -</span><span id="L-2302"><a href="#L-2302"><span class="linenos">2302</span></a> <span class="k">def</span> <span class="nf">_parse_table</span><span class="p">(</span> -</span><span id="L-2303"><a href="#L-2303"><span class="linenos">2303</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">schema</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="n">alias_tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2304"><a href="#L-2304"><span class="linenos">2304</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-2305"><a href="#L-2305"><span class="linenos">2305</span></a> <span class="n">lateral</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lateral</span><span class="p">()</span> -</span><span id="L-2306"><a href="#L-2306"><span class="linenos">2306</span></a> <span class="k">if</span> <span class="n">lateral</span><span class="p">:</span> -</span><span id="L-2307"><a href="#L-2307"><span class="linenos">2307</span></a> <span class="k">return</span> <span class="n">lateral</span> -</span><span id="L-2308"><a href="#L-2308"><span class="linenos">2308</span></a> -</span><span id="L-2309"><a href="#L-2309"><span class="linenos">2309</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_unnest</span><span class="p">()</span> -</span><span id="L-2310"><a href="#L-2310"><span class="linenos">2310</span></a> <span class="k">if</span> <span class="n">unnest</span><span class="p">:</span> -</span><span id="L-2311"><a href="#L-2311"><span class="linenos">2311</span></a> <span class="k">return</span> <span class="n">unnest</span> +</span><span id="L-2302"><a href="#L-2302"><span class="linenos">2302</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-2303"><a href="#L-2303"><span class="linenos">2303</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="n">db</span><span class="p">,</span> <span class="n">catalog</span><span class="o">=</span><span class="n">catalog</span><span class="p">,</span> <span class="n">pivots</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivots</span><span class="p">()</span> +</span><span id="L-2304"><a href="#L-2304"><span class="linenos">2304</span></a> <span class="p">)</span> +</span><span id="L-2305"><a href="#L-2305"><span class="linenos">2305</span></a> +</span><span id="L-2306"><a href="#L-2306"><span class="linenos">2306</span></a> <span class="k">def</span> <span class="nf">_parse_table</span><span class="p">(</span> +</span><span id="L-2307"><a href="#L-2307"><span class="linenos">2307</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">schema</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="n">alias_tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2308"><a href="#L-2308"><span class="linenos">2308</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-2309"><a href="#L-2309"><span class="linenos">2309</span></a> <span class="n">lateral</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lateral</span><span class="p">()</span> +</span><span id="L-2310"><a href="#L-2310"><span class="linenos">2310</span></a> <span class="k">if</span> <span class="n">lateral</span><span class="p">:</span> +</span><span id="L-2311"><a href="#L-2311"><span class="linenos">2311</span></a> <span class="k">return</span> <span class="n">lateral</span> </span><span id="L-2312"><a href="#L-2312"><span class="linenos">2312</span></a> -</span><span id="L-2313"><a href="#L-2313"><span class="linenos">2313</span></a> <span class="n">values</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_derived_table_values</span><span class="p">()</span> -</span><span id="L-2314"><a href="#L-2314"><span class="linenos">2314</span></a> <span class="k">if</span> <span class="n">values</span><span class="p">:</span> -</span><span id="L-2315"><a href="#L-2315"><span class="linenos">2315</span></a> <span class="k">return</span> <span class="n">values</span> +</span><span id="L-2313"><a href="#L-2313"><span class="linenos">2313</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_unnest</span><span class="p">()</span> +</span><span id="L-2314"><a href="#L-2314"><span class="linenos">2314</span></a> <span class="k">if</span> <span class="n">unnest</span><span class="p">:</span> +</span><span id="L-2315"><a href="#L-2315"><span class="linenos">2315</span></a> <span class="k">return</span> <span class="n">unnest</span> </span><span id="L-2316"><a href="#L-2316"><span class="linenos">2316</span></a> -</span><span id="L-2317"><a href="#L-2317"><span class="linenos">2317</span></a> <span class="n">subquery</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2318"><a href="#L-2318"><span class="linenos">2318</span></a> <span class="k">if</span> <span class="n">subquery</span><span class="p">:</span> -</span><span id="L-2319"><a href="#L-2319"><span class="linenos">2319</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">subquery</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">):</span> -</span><span id="L-2320"><a href="#L-2320"><span class="linenos">2320</span></a> <span class="n">subquery</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivots</span><span class="p">())</span> -</span><span id="L-2321"><a href="#L-2321"><span class="linenos">2321</span></a> <span class="k">return</span> <span class="n">subquery</span> -</span><span id="L-2322"><a href="#L-2322"><span class="linenos">2322</span></a> -</span><span id="L-2323"><a href="#L-2323"><span class="linenos">2323</span></a> <span class="n">this</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="L-2324"><a href="#L-2324"><span class="linenos">2324</span></a> -</span><span id="L-2325"><a href="#L-2325"><span class="linenos">2325</span></a> <span class="k">if</span> <span class="n">schema</span><span class="p">:</span> -</span><span id="L-2326"><a href="#L-2326"><span class="linenos">2326</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-2327"><a href="#L-2327"><span class="linenos">2327</span></a> -</span><span id="L-2328"><a href="#L-2328"><span class="linenos">2328</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span><span class="p">:</span> -</span><span id="L-2329"><a href="#L-2329"><span class="linenos">2329</span></a> <span class="n">table_sample</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_sample</span><span class="p">()</span> -</span><span id="L-2330"><a href="#L-2330"><span class="linenos">2330</span></a> -</span><span id="L-2331"><a href="#L-2331"><span class="linenos">2331</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">(</span><span class="n">alias_tokens</span><span class="o">=</span><span class="n">alias_tokens</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_ALIAS_TOKENS</span><span class="p">)</span> -</span><span id="L-2332"><a href="#L-2332"><span class="linenos">2332</span></a> <span class="k">if</span> <span class="n">alias</span><span class="p">:</span> -</span><span id="L-2333"><a href="#L-2333"><span class="linenos">2333</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="n">alias</span><span class="p">)</span> +</span><span id="L-2317"><a href="#L-2317"><span class="linenos">2317</span></a> <span class="n">values</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_derived_table_values</span><span class="p">()</span> +</span><span id="L-2318"><a href="#L-2318"><span class="linenos">2318</span></a> <span class="k">if</span> <span class="n">values</span><span class="p">:</span> +</span><span id="L-2319"><a href="#L-2319"><span class="linenos">2319</span></a> <span class="k">return</span> <span class="n">values</span> +</span><span id="L-2320"><a href="#L-2320"><span class="linenos">2320</span></a> +</span><span id="L-2321"><a href="#L-2321"><span class="linenos">2321</span></a> <span class="n">subquery</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-2322"><a href="#L-2322"><span class="linenos">2322</span></a> <span class="k">if</span> <span class="n">subquery</span><span class="p">:</span> +</span><span id="L-2323"><a href="#L-2323"><span class="linenos">2323</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">subquery</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">):</span> +</span><span id="L-2324"><a href="#L-2324"><span class="linenos">2324</span></a> <span class="n">subquery</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivots</span><span class="p">())</span> +</span><span id="L-2325"><a href="#L-2325"><span class="linenos">2325</span></a> <span class="k">return</span> <span class="n">subquery</span> +</span><span id="L-2326"><a href="#L-2326"><span class="linenos">2326</span></a> +</span><span id="L-2327"><a href="#L-2327"><span class="linenos">2327</span></a> <span class="n">this</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="L-2328"><a href="#L-2328"><span class="linenos">2328</span></a> +</span><span id="L-2329"><a href="#L-2329"><span class="linenos">2329</span></a> <span class="k">if</span> <span class="n">schema</span><span class="p">:</span> +</span><span id="L-2330"><a href="#L-2330"><span class="linenos">2330</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-2331"><a href="#L-2331"><span class="linenos">2331</span></a> +</span><span id="L-2332"><a href="#L-2332"><span class="linenos">2332</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span><span class="p">:</span> +</span><span id="L-2333"><a href="#L-2333"><span class="linenos">2333</span></a> <span class="n">table_sample</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_sample</span><span class="p">()</span> </span><span id="L-2334"><a href="#L-2334"><span class="linenos">2334</span></a> -</span><span id="L-2335"><a href="#L-2335"><span class="linenos">2335</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">):</span> -</span><span id="L-2336"><a href="#L-2336"><span class="linenos">2336</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivots</span><span class="p">())</span> -</span><span id="L-2337"><a href="#L-2337"><span class="linenos">2337</span></a> -</span><span id="L-2338"><a href="#L-2338"><span class="linenos">2338</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">):</span> -</span><span id="L-2339"><a href="#L-2339"><span class="linenos">2339</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="L-2340"><a href="#L-2340"><span class="linenos">2340</span></a> <span class="s2">"hints"</span><span class="p">,</span> -</span><span id="L-2341"><a href="#L-2341"><span class="linenos">2341</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)),</span> -</span><span id="L-2342"><a href="#L-2342"><span class="linenos">2342</span></a> <span class="p">)</span> -</span><span id="L-2343"><a href="#L-2343"><span class="linenos">2343</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="L-2344"><a href="#L-2344"><span class="linenos">2344</span></a> -</span><span id="L-2345"><a href="#L-2345"><span class="linenos">2345</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span><span class="p">:</span> -</span><span id="L-2346"><a href="#L-2346"><span class="linenos">2346</span></a> <span class="n">table_sample</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_sample</span><span class="p">()</span> -</span><span id="L-2347"><a href="#L-2347"><span class="linenos">2347</span></a> -</span><span id="L-2348"><a href="#L-2348"><span class="linenos">2348</span></a> <span class="k">if</span> <span class="n">table_sample</span><span class="p">:</span> -</span><span id="L-2349"><a href="#L-2349"><span class="linenos">2349</span></a> <span class="n">table_sample</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">this</span><span class="p">)</span> -</span><span id="L-2350"><a href="#L-2350"><span class="linenos">2350</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">table_sample</span> +</span><span id="L-2335"><a href="#L-2335"><span class="linenos">2335</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">(</span><span class="n">alias_tokens</span><span class="o">=</span><span class="n">alias_tokens</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_ALIAS_TOKENS</span><span class="p">)</span> +</span><span id="L-2336"><a href="#L-2336"><span class="linenos">2336</span></a> <span class="k">if</span> <span class="n">alias</span><span class="p">:</span> +</span><span id="L-2337"><a href="#L-2337"><span class="linenos">2337</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="n">alias</span><span class="p">)</span> +</span><span id="L-2338"><a href="#L-2338"><span class="linenos">2338</span></a> +</span><span id="L-2339"><a href="#L-2339"><span class="linenos">2339</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">):</span> +</span><span id="L-2340"><a href="#L-2340"><span class="linenos">2340</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivots</span><span class="p">())</span> +</span><span id="L-2341"><a href="#L-2341"><span class="linenos">2341</span></a> +</span><span id="L-2342"><a href="#L-2342"><span class="linenos">2342</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">):</span> +</span><span id="L-2343"><a href="#L-2343"><span class="linenos">2343</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="L-2344"><a href="#L-2344"><span class="linenos">2344</span></a> <span class="s2">"hints"</span><span class="p">,</span> +</span><span id="L-2345"><a href="#L-2345"><span class="linenos">2345</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)),</span> +</span><span id="L-2346"><a href="#L-2346"><span class="linenos">2346</span></a> <span class="p">)</span> +</span><span id="L-2347"><a href="#L-2347"><span class="linenos">2347</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-2348"><a href="#L-2348"><span class="linenos">2348</span></a> +</span><span id="L-2349"><a href="#L-2349"><span class="linenos">2349</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span><span class="p">:</span> +</span><span id="L-2350"><a href="#L-2350"><span class="linenos">2350</span></a> <span class="n">table_sample</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_sample</span><span class="p">()</span> </span><span id="L-2351"><a href="#L-2351"><span class="linenos">2351</span></a> -</span><span id="L-2352"><a href="#L-2352"><span class="linenos">2352</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-2353"><a href="#L-2353"><span class="linenos">2353</span></a> -</span><span id="L-2354"><a href="#L-2354"><span class="linenos">2354</span></a> <span class="k">def</span> <span class="nf">_parse_unnest</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">with_alias</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="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">Unnest</span><span class="p">]:</span> -</span><span id="L-2355"><a href="#L-2355"><span class="linenos">2355</span></a> <span class="k">if</span> <span class="ow">not</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">UNNEST</span><span class="p">):</span> -</span><span id="L-2356"><a href="#L-2356"><span class="linenos">2356</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2352"><a href="#L-2352"><span class="linenos">2352</span></a> <span class="k">if</span> <span class="n">table_sample</span><span class="p">:</span> +</span><span id="L-2353"><a href="#L-2353"><span class="linenos">2353</span></a> <span class="n">table_sample</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">this</span><span class="p">)</span> +</span><span id="L-2354"><a href="#L-2354"><span class="linenos">2354</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">table_sample</span> +</span><span id="L-2355"><a href="#L-2355"><span class="linenos">2355</span></a> +</span><span id="L-2356"><a href="#L-2356"><span class="linenos">2356</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="L-2357"><a href="#L-2357"><span class="linenos">2357</span></a> -</span><span id="L-2358"><a href="#L-2358"><span class="linenos">2358</span></a> <span class="n">expressions</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_type</span><span class="p">)</span> -</span><span id="L-2359"><a href="#L-2359"><span class="linenos">2359</span></a> <span class="n">ordinality</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ORDINALITY</span><span class="p">)</span> -</span><span id="L-2360"><a href="#L-2360"><span class="linenos">2360</span></a> -</span><span id="L-2361"><a href="#L-2361"><span class="linenos">2361</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> <span class="k">if</span> <span class="n">with_alias</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="L-2362"><a href="#L-2362"><span class="linenos">2362</span></a> -</span><span id="L-2363"><a href="#L-2363"><span class="linenos">2363</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> -</span><span id="L-2364"><a href="#L-2364"><span class="linenos">2364</span></a> <span class="k">if</span> <span class="n">alias</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">):</span> -</span><span id="L-2365"><a href="#L-2365"><span class="linenos">2365</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Unexpected extra column alias in unnest."</span><span class="p">)</span> +</span><span id="L-2358"><a href="#L-2358"><span class="linenos">2358</span></a> <span class="k">def</span> <span class="nf">_parse_unnest</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">with_alias</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="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">Unnest</span><span class="p">]:</span> +</span><span id="L-2359"><a href="#L-2359"><span class="linenos">2359</span></a> <span class="k">if</span> <span class="ow">not</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">UNNEST</span><span class="p">):</span> +</span><span id="L-2360"><a href="#L-2360"><span class="linenos">2360</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2361"><a href="#L-2361"><span class="linenos">2361</span></a> +</span><span id="L-2362"><a href="#L-2362"><span class="linenos">2362</span></a> <span class="n">expressions</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_type</span><span class="p">)</span> +</span><span id="L-2363"><a href="#L-2363"><span class="linenos">2363</span></a> <span class="n">ordinality</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ORDINALITY</span><span class="p">)</span> +</span><span id="L-2364"><a href="#L-2364"><span class="linenos">2364</span></a> +</span><span id="L-2365"><a href="#L-2365"><span class="linenos">2365</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> <span class="k">if</span> <span class="n">with_alias</span> <span class="k">else</span> <span class="kc">None</span> </span><span id="L-2366"><a href="#L-2366"><span class="linenos">2366</span></a> -</span><span id="L-2367"><a href="#L-2367"><span class="linenos">2367</span></a> <span class="n">alias</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">,</span> <span class="p">[</span><span class="n">alias</span><span class="o">.</span><span class="n">this</span><span class="p">])</span> -</span><span id="L-2368"><a href="#L-2368"><span class="linenos">2368</span></a> <span class="n">alias</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="kc">None</span><span class="p">)</span> -</span><span id="L-2369"><a href="#L-2369"><span class="linenos">2369</span></a> -</span><span id="L-2370"><a href="#L-2370"><span class="linenos">2370</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2371"><a href="#L-2371"><span class="linenos">2371</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OFFSET</span><span class="p">):</span> -</span><span id="L-2372"><a href="#L-2372"><span class="linenos">2372</span></a> <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">ALIAS</span><span class="p">)</span> -</span><span id="L-2373"><a href="#L-2373"><span class="linenos">2373</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> <span class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">)</span> -</span><span id="L-2374"><a href="#L-2374"><span class="linenos">2374</span></a> -</span><span id="L-2375"><a href="#L-2375"><span class="linenos">2375</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-2376"><a href="#L-2376"><span class="linenos">2376</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">ordinality</span><span class="o">=</span><span class="n">ordinality</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">,</span> <span class="n">offset</span><span class="o">=</span><span class="n">offset</span> -</span><span id="L-2377"><a href="#L-2377"><span class="linenos">2377</span></a> <span class="p">)</span> +</span><span id="L-2367"><a href="#L-2367"><span class="linenos">2367</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> +</span><span id="L-2368"><a href="#L-2368"><span class="linenos">2368</span></a> <span class="k">if</span> <span class="n">alias</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">):</span> +</span><span id="L-2369"><a href="#L-2369"><span class="linenos">2369</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Unexpected extra column alias in unnest."</span><span class="p">)</span> +</span><span id="L-2370"><a href="#L-2370"><span class="linenos">2370</span></a> +</span><span id="L-2371"><a href="#L-2371"><span class="linenos">2371</span></a> <span class="n">alias</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">,</span> <span class="p">[</span><span class="n">alias</span><span class="o">.</span><span class="n">this</span><span class="p">])</span> +</span><span id="L-2372"><a href="#L-2372"><span class="linenos">2372</span></a> <span class="n">alias</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="kc">None</span><span class="p">)</span> +</span><span id="L-2373"><a href="#L-2373"><span class="linenos">2373</span></a> +</span><span id="L-2374"><a href="#L-2374"><span class="linenos">2374</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2375"><a href="#L-2375"><span class="linenos">2375</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OFFSET</span><span class="p">):</span> +</span><span id="L-2376"><a href="#L-2376"><span class="linenos">2376</span></a> <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">ALIAS</span><span class="p">)</span> +</span><span id="L-2377"><a href="#L-2377"><span class="linenos">2377</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> <span class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">)</span> </span><span id="L-2378"><a href="#L-2378"><span class="linenos">2378</span></a> -</span><span id="L-2379"><a href="#L-2379"><span class="linenos">2379</span></a> <span class="k">def</span> <span class="nf">_parse_derived_table_values</span><span class="p">(</span><span class="bp">self</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">Values</span><span class="p">]:</span> -</span><span id="L-2380"><a href="#L-2380"><span class="linenos">2380</span></a> <span class="n">is_derived</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VALUES</span><span class="p">)</span> -</span><span id="L-2381"><a href="#L-2381"><span class="linenos">2381</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">is_derived</span> <span class="ow">and</span> <span class="ow">not</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">VALUES</span><span class="p">):</span> -</span><span id="L-2382"><a href="#L-2382"><span class="linenos">2382</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-2383"><a href="#L-2383"><span class="linenos">2383</span></a> -</span><span id="L-2384"><a href="#L-2384"><span class="linenos">2384</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">)</span> -</span><span id="L-2385"><a href="#L-2385"><span class="linenos">2385</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> -</span><span id="L-2386"><a href="#L-2386"><span class="linenos">2386</span></a> -</span><span id="L-2387"><a href="#L-2387"><span class="linenos">2387</span></a> <span class="k">if</span> <span class="n">is_derived</span><span class="p">:</span> -</span><span id="L-2388"><a href="#L-2388"><span class="linenos">2388</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="L-2389"><a href="#L-2389"><span class="linenos">2389</span></a> -</span><span id="L-2390"><a href="#L-2390"><span class="linenos">2390</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><span id="L-2391"><a href="#L-2391"><span class="linenos">2391</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> -</span><span id="L-2392"><a href="#L-2392"><span class="linenos">2392</span></a> <span class="p">)</span> +</span><span id="L-2379"><a href="#L-2379"><span class="linenos">2379</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><span id="L-2380"><a href="#L-2380"><span class="linenos">2380</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">ordinality</span><span class="o">=</span><span class="n">ordinality</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">,</span> <span class="n">offset</span><span class="o">=</span><span class="n">offset</span> +</span><span id="L-2381"><a href="#L-2381"><span class="linenos">2381</span></a> <span class="p">)</span> +</span><span id="L-2382"><a href="#L-2382"><span class="linenos">2382</span></a> +</span><span id="L-2383"><a href="#L-2383"><span class="linenos">2383</span></a> <span class="k">def</span> <span class="nf">_parse_derived_table_values</span><span class="p">(</span><span class="bp">self</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">Values</span><span class="p">]:</span> +</span><span id="L-2384"><a href="#L-2384"><span class="linenos">2384</span></a> <span class="n">is_derived</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VALUES</span><span class="p">)</span> +</span><span id="L-2385"><a href="#L-2385"><span class="linenos">2385</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">is_derived</span> <span class="ow">and</span> <span class="ow">not</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">VALUES</span><span class="p">):</span> +</span><span id="L-2386"><a href="#L-2386"><span class="linenos">2386</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2387"><a href="#L-2387"><span class="linenos">2387</span></a> +</span><span id="L-2388"><a href="#L-2388"><span class="linenos">2388</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">)</span> +</span><span id="L-2389"><a href="#L-2389"><span class="linenos">2389</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> +</span><span id="L-2390"><a href="#L-2390"><span class="linenos">2390</span></a> +</span><span id="L-2391"><a href="#L-2391"><span class="linenos">2391</span></a> <span class="k">if</span> <span class="n">is_derived</span><span class="p">:</span> +</span><span id="L-2392"><a href="#L-2392"><span class="linenos">2392</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> </span><span id="L-2393"><a href="#L-2393"><span class="linenos">2393</span></a> -</span><span id="L-2394"><a href="#L-2394"><span class="linenos">2394</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-2395"><a href="#L-2395"><span class="linenos">2395</span></a> <span class="k">if</span> <span class="ow">not</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">TABLE_SAMPLE</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="p">(</span> -</span><span id="L-2396"><a href="#L-2396"><span class="linenos">2396</span></a> <span class="n">as_modifier</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"USING"</span><span class="p">,</span> <span class="s2">"SAMPLE"</span><span class="p">)</span> -</span><span id="L-2397"><a href="#L-2397"><span class="linenos">2397</span></a> <span class="p">):</span> -</span><span id="L-2398"><a href="#L-2398"><span class="linenos">2398</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-2399"><a href="#L-2399"><span class="linenos">2399</span></a> -</span><span id="L-2400"><a href="#L-2400"><span class="linenos">2400</span></a> <span class="n">bucket_numerator</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2401"><a href="#L-2401"><span class="linenos">2401</span></a> <span class="n">bucket_denominator</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2402"><a href="#L-2402"><span class="linenos">2402</span></a> <span class="n">bucket_field</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2403"><a href="#L-2403"><span class="linenos">2403</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2404"><a href="#L-2404"><span class="linenos">2404</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2405"><a href="#L-2405"><span class="linenos">2405</span></a> <span class="n">size</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2406"><a href="#L-2406"><span class="linenos">2406</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2407"><a href="#L-2407"><span class="linenos">2407</span></a> -</span><span id="L-2408"><a href="#L-2408"><span class="linenos">2408</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-2409"><a href="#L-2409"><span class="linenos">2409</span></a> <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="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span> <span class="k">else</span> <span class="s2">"USING SAMPLE"</span> -</span><span id="L-2410"><a href="#L-2410"><span class="linenos">2410</span></a> <span class="p">)</span> -</span><span id="L-2411"><a href="#L-2411"><span class="linenos">2411</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">(</span><span class="n">tokens</span><span class="o">=</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,))</span> -</span><span id="L-2412"><a href="#L-2412"><span class="linenos">2412</span></a> -</span><span id="L-2413"><a href="#L-2413"><span class="linenos">2413</span></a> <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_PAREN</span><span class="p">)</span> -</span><span id="L-2414"><a href="#L-2414"><span class="linenos">2414</span></a> -</span><span id="L-2415"><a href="#L-2415"><span class="linenos">2415</span></a> <span class="n">num</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> +</span><span id="L-2394"><a href="#L-2394"><span class="linenos">2394</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><span id="L-2395"><a href="#L-2395"><span class="linenos">2395</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> +</span><span id="L-2396"><a href="#L-2396"><span class="linenos">2396</span></a> <span class="p">)</span> +</span><span id="L-2397"><a href="#L-2397"><span class="linenos">2397</span></a> +</span><span id="L-2398"><a href="#L-2398"><span class="linenos">2398</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-2399"><a href="#L-2399"><span class="linenos">2399</span></a> <span class="k">if</span> <span class="ow">not</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">TABLE_SAMPLE</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="p">(</span> +</span><span id="L-2400"><a href="#L-2400"><span class="linenos">2400</span></a> <span class="n">as_modifier</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"USING"</span><span class="p">,</span> <span class="s2">"SAMPLE"</span><span class="p">)</span> +</span><span id="L-2401"><a href="#L-2401"><span class="linenos">2401</span></a> <span class="p">):</span> +</span><span id="L-2402"><a href="#L-2402"><span class="linenos">2402</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2403"><a href="#L-2403"><span class="linenos">2403</span></a> +</span><span id="L-2404"><a href="#L-2404"><span class="linenos">2404</span></a> <span class="n">bucket_numerator</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2405"><a href="#L-2405"><span class="linenos">2405</span></a> <span class="n">bucket_denominator</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2406"><a href="#L-2406"><span class="linenos">2406</span></a> <span class="n">bucket_field</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2407"><a href="#L-2407"><span class="linenos">2407</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2408"><a href="#L-2408"><span class="linenos">2408</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2409"><a href="#L-2409"><span class="linenos">2409</span></a> <span class="n">size</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2410"><a href="#L-2410"><span class="linenos">2410</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2411"><a href="#L-2411"><span class="linenos">2411</span></a> +</span><span id="L-2412"><a href="#L-2412"><span class="linenos">2412</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-2413"><a href="#L-2413"><span class="linenos">2413</span></a> <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="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span> <span class="k">else</span> <span class="s2">"USING SAMPLE"</span> +</span><span id="L-2414"><a href="#L-2414"><span class="linenos">2414</span></a> <span class="p">)</span> +</span><span id="L-2415"><a href="#L-2415"><span class="linenos">2415</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">(</span><span class="n">tokens</span><span class="o">=</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,))</span> </span><span id="L-2416"><a href="#L-2416"><span class="linenos">2416</span></a> -</span><span id="L-2417"><a href="#L-2417"><span class="linenos">2417</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BUCKET"</span><span class="p">):</span> -</span><span id="L-2418"><a href="#L-2418"><span class="linenos">2418</span></a> <span class="n">bucket_numerator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> -</span><span id="L-2419"><a href="#L-2419"><span class="linenos">2419</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OUT"</span><span class="p">,</span> <span class="s2">"OF"</span><span class="p">)</span> -</span><span id="L-2420"><a href="#L-2420"><span class="linenos">2420</span></a> <span class="n">bucket_denominator</span> <span class="o">=</span> <span class="n">bucket_denominator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> -</span><span id="L-2421"><a href="#L-2421"><span class="linenos">2421</span></a> <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">ON</span><span class="p">)</span> -</span><span id="L-2422"><a href="#L-2422"><span class="linenos">2422</span></a> <span class="n">bucket_field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> -</span><span id="L-2423"><a href="#L-2423"><span class="linenos">2423</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">PERCENT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MOD</span><span class="p">)):</span> -</span><span id="L-2424"><a href="#L-2424"><span class="linenos">2424</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="n">num</span> -</span><span id="L-2425"><a href="#L-2425"><span class="linenos">2425</span></a> <span class="k">elif</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">ROWS</span><span class="p">):</span> -</span><span id="L-2426"><a href="#L-2426"><span class="linenos">2426</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="n">num</span> -</span><span id="L-2427"><a href="#L-2427"><span class="linenos">2427</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2428"><a href="#L-2428"><span class="linenos">2428</span></a> <span class="n">size</span> <span class="o">=</span> <span class="n">num</span> -</span><span id="L-2429"><a href="#L-2429"><span class="linenos">2429</span></a> -</span><span id="L-2430"><a href="#L-2430"><span class="linenos">2430</span></a> <span class="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">R_PAREN</span><span class="p">)</span> -</span><span id="L-2431"><a href="#L-2431"><span class="linenos">2431</span></a> -</span><span id="L-2432"><a href="#L-2432"><span class="linenos">2432</span></a> <span class="k">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_PAREN</span><span class="p">):</span> -</span><span id="L-2433"><a href="#L-2433"><span class="linenos">2433</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> -</span><span id="L-2434"><a href="#L-2434"><span class="linenos">2434</span></a> <span class="n">seed</span> <span class="o">=</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">COMMA</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> -</span><span id="L-2435"><a href="#L-2435"><span class="linenos">2435</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="L-2436"><a href="#L-2436"><span class="linenos">2436</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"SEED"</span><span class="p">,</span> <span class="s2">"REPEATABLE"</span><span class="p">)):</span> -</span><span id="L-2437"><a href="#L-2437"><span class="linenos">2437</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">)</span> -</span><span id="L-2438"><a href="#L-2438"><span class="linenos">2438</span></a> -</span><span id="L-2439"><a href="#L-2439"><span class="linenos">2439</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-2440"><a href="#L-2440"><span class="linenos">2440</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> -</span><span id="L-2441"><a href="#L-2441"><span class="linenos">2441</span></a> <span class="n">method</span><span class="o">=</span><span class="n">method</span><span class="p">,</span> -</span><span id="L-2442"><a href="#L-2442"><span class="linenos">2442</span></a> <span class="n">bucket_numerator</span><span class="o">=</span><span class="n">bucket_numerator</span><span class="p">,</span> -</span><span id="L-2443"><a href="#L-2443"><span class="linenos">2443</span></a> <span class="n">bucket_denominator</span><span class="o">=</span><span class="n">bucket_denominator</span><span class="p">,</span> -</span><span id="L-2444"><a href="#L-2444"><span class="linenos">2444</span></a> <span class="n">bucket_field</span><span class="o">=</span><span class="n">bucket_field</span><span class="p">,</span> -</span><span id="L-2445"><a href="#L-2445"><span class="linenos">2445</span></a> <span class="n">percent</span><span class="o">=</span><span class="n">percent</span><span class="p">,</span> -</span><span id="L-2446"><a href="#L-2446"><span class="linenos">2446</span></a> <span class="n">rows</span><span class="o">=</span><span class="n">rows</span><span class="p">,</span> -</span><span id="L-2447"><a href="#L-2447"><span class="linenos">2447</span></a> <span class="n">size</span><span class="o">=</span><span class="n">size</span><span class="p">,</span> -</span><span id="L-2448"><a href="#L-2448"><span class="linenos">2448</span></a> <span class="n">seed</span><span class="o">=</span><span class="n">seed</span><span class="p">,</span> -</span><span id="L-2449"><a href="#L-2449"><span class="linenos">2449</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> -</span><span id="L-2450"><a href="#L-2450"><span class="linenos">2450</span></a> <span class="p">)</span> -</span><span id="L-2451"><a href="#L-2451"><span class="linenos">2451</span></a> -</span><span id="L-2452"><a href="#L-2452"><span class="linenos">2452</span></a> <span class="k">def</span> <span class="nf">_parse_pivots</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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-2453"><a href="#L-2453"><span class="linenos">2453</span></a> <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="nb">iter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivot</span><span class="p">,</span> <span class="kc">None</span><span class="p">))</span> -</span><span id="L-2454"><a href="#L-2454"><span class="linenos">2454</span></a> -</span><span id="L-2455"><a href="#L-2455"><span class="linenos">2455</span></a> <span class="c1"># https://duckdb.org/docs/sql/statements/pivot</span> -</span><span id="L-2456"><a href="#L-2456"><span class="linenos">2456</span></a> <span class="k">def</span> <span class="nf">_parse_simplified_pivot</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">Pivot</span><span class="p">:</span> -</span><span id="L-2457"><a href="#L-2457"><span class="linenos">2457</span></a> <span class="k">def</span> <span class="nf">_parse_on</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-2458"><a href="#L-2458"><span class="linenos">2458</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="L-2459"><a href="#L-2459"><span class="linenos">2459</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_in</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> <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">IN</span><span class="p">)</span> <span class="k">else</span> <span class="n">this</span> -</span><span id="L-2460"><a href="#L-2460"><span class="linenos">2460</span></a> -</span><span id="L-2461"><a href="#L-2461"><span class="linenos">2461</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> -</span><span id="L-2462"><a href="#L-2462"><span class="linenos">2462</span></a> <span class="n">expressions</span> <span class="o">=</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">ON</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">_parse_on</span><span class="p">)</span> -</span><span id="L-2463"><a href="#L-2463"><span class="linenos">2463</span></a> <span class="n">using</span> <span class="o">=</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">USING</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> -</span><span id="L-2464"><a href="#L-2464"><span class="linenos">2464</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_alias</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">())</span> -</span><span id="L-2465"><a href="#L-2465"><span class="linenos">2465</span></a> <span class="p">)</span> -</span><span id="L-2466"><a href="#L-2466"><span class="linenos">2466</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_group</span><span class="p">()</span> -</span><span id="L-2467"><a href="#L-2467"><span class="linenos">2467</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><span id="L-2468"><a href="#L-2468"><span class="linenos">2468</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">using</span><span class="o">=</span><span class="n">using</span><span class="p">,</span> <span class="n">group</span><span class="o">=</span><span class="n">group</span> +</span><span id="L-2417"><a href="#L-2417"><span class="linenos">2417</span></a> <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_PAREN</span><span class="p">)</span> +</span><span id="L-2418"><a href="#L-2418"><span class="linenos">2418</span></a> +</span><span id="L-2419"><a href="#L-2419"><span class="linenos">2419</span></a> <span class="n">num</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> +</span><span id="L-2420"><a href="#L-2420"><span class="linenos">2420</span></a> +</span><span id="L-2421"><a href="#L-2421"><span class="linenos">2421</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BUCKET"</span><span class="p">):</span> +</span><span id="L-2422"><a href="#L-2422"><span class="linenos">2422</span></a> <span class="n">bucket_numerator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> +</span><span id="L-2423"><a href="#L-2423"><span class="linenos">2423</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OUT"</span><span class="p">,</span> <span class="s2">"OF"</span><span class="p">)</span> +</span><span id="L-2424"><a href="#L-2424"><span class="linenos">2424</span></a> <span class="n">bucket_denominator</span> <span class="o">=</span> <span class="n">bucket_denominator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> +</span><span id="L-2425"><a href="#L-2425"><span class="linenos">2425</span></a> <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">ON</span><span class="p">)</span> +</span><span id="L-2426"><a href="#L-2426"><span class="linenos">2426</span></a> <span class="n">bucket_field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> +</span><span id="L-2427"><a href="#L-2427"><span class="linenos">2427</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">PERCENT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MOD</span><span class="p">)):</span> +</span><span id="L-2428"><a href="#L-2428"><span class="linenos">2428</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="n">num</span> +</span><span id="L-2429"><a href="#L-2429"><span class="linenos">2429</span></a> <span class="k">elif</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">ROWS</span><span class="p">):</span> +</span><span id="L-2430"><a href="#L-2430"><span class="linenos">2430</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="n">num</span> +</span><span id="L-2431"><a href="#L-2431"><span class="linenos">2431</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2432"><a href="#L-2432"><span class="linenos">2432</span></a> <span class="n">size</span> <span class="o">=</span> <span class="n">num</span> +</span><span id="L-2433"><a href="#L-2433"><span class="linenos">2433</span></a> +</span><span id="L-2434"><a href="#L-2434"><span class="linenos">2434</span></a> <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">R_PAREN</span><span class="p">)</span> +</span><span id="L-2435"><a href="#L-2435"><span class="linenos">2435</span></a> +</span><span id="L-2436"><a href="#L-2436"><span class="linenos">2436</span></a> <span class="k">if</span> <span class="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_PAREN</span><span class="p">):</span> +</span><span id="L-2437"><a href="#L-2437"><span class="linenos">2437</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> +</span><span id="L-2438"><a href="#L-2438"><span class="linenos">2438</span></a> <span class="n">seed</span> <span class="o">=</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">COMMA</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> +</span><span id="L-2439"><a href="#L-2439"><span class="linenos">2439</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-2440"><a href="#L-2440"><span class="linenos">2440</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"SEED"</span><span class="p">,</span> <span class="s2">"REPEATABLE"</span><span class="p">)):</span> +</span><span id="L-2441"><a href="#L-2441"><span class="linenos">2441</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">)</span> +</span><span id="L-2442"><a href="#L-2442"><span class="linenos">2442</span></a> +</span><span id="L-2443"><a href="#L-2443"><span class="linenos">2443</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><span id="L-2444"><a href="#L-2444"><span class="linenos">2444</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> +</span><span id="L-2445"><a href="#L-2445"><span class="linenos">2445</span></a> <span class="n">method</span><span class="o">=</span><span class="n">method</span><span class="p">,</span> +</span><span id="L-2446"><a href="#L-2446"><span class="linenos">2446</span></a> <span class="n">bucket_numerator</span><span class="o">=</span><span class="n">bucket_numerator</span><span class="p">,</span> +</span><span id="L-2447"><a href="#L-2447"><span class="linenos">2447</span></a> <span class="n">bucket_denominator</span><span class="o">=</span><span class="n">bucket_denominator</span><span class="p">,</span> +</span><span id="L-2448"><a href="#L-2448"><span class="linenos">2448</span></a> <span class="n">bucket_field</span><span class="o">=</span><span class="n">bucket_field</span><span class="p">,</span> +</span><span id="L-2449"><a href="#L-2449"><span class="linenos">2449</span></a> <span class="n">percent</span><span class="o">=</span><span class="n">percent</span><span class="p">,</span> +</span><span id="L-2450"><a href="#L-2450"><span class="linenos">2450</span></a> <span class="n">rows</span><span class="o">=</span><span class="n">rows</span><span class="p">,</span> +</span><span id="L-2451"><a href="#L-2451"><span class="linenos">2451</span></a> <span class="n">size</span><span class="o">=</span><span class="n">size</span><span class="p">,</span> +</span><span id="L-2452"><a href="#L-2452"><span class="linenos">2452</span></a> <span class="n">seed</span><span class="o">=</span><span class="n">seed</span><span class="p">,</span> +</span><span id="L-2453"><a href="#L-2453"><span class="linenos">2453</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> +</span><span id="L-2454"><a href="#L-2454"><span class="linenos">2454</span></a> <span class="p">)</span> +</span><span id="L-2455"><a href="#L-2455"><span class="linenos">2455</span></a> +</span><span id="L-2456"><a href="#L-2456"><span class="linenos">2456</span></a> <span class="k">def</span> <span class="nf">_parse_pivots</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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-2457"><a href="#L-2457"><span class="linenos">2457</span></a> <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="nb">iter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivot</span><span class="p">,</span> <span class="kc">None</span><span class="p">))</span> +</span><span id="L-2458"><a href="#L-2458"><span class="linenos">2458</span></a> +</span><span id="L-2459"><a href="#L-2459"><span class="linenos">2459</span></a> <span class="c1"># https://duckdb.org/docs/sql/statements/pivot</span> +</span><span id="L-2460"><a href="#L-2460"><span class="linenos">2460</span></a> <span class="k">def</span> <span class="nf">_parse_simplified_pivot</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">Pivot</span><span class="p">:</span> +</span><span id="L-2461"><a href="#L-2461"><span class="linenos">2461</span></a> <span class="k">def</span> <span class="nf">_parse_on</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-2462"><a href="#L-2462"><span class="linenos">2462</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="L-2463"><a href="#L-2463"><span class="linenos">2463</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_in</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> <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">IN</span><span class="p">)</span> <span class="k">else</span> <span class="n">this</span> +</span><span id="L-2464"><a href="#L-2464"><span class="linenos">2464</span></a> +</span><span id="L-2465"><a href="#L-2465"><span class="linenos">2465</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> +</span><span id="L-2466"><a href="#L-2466"><span class="linenos">2466</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ON</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">_parse_on</span><span class="p">)</span> +</span><span id="L-2467"><a href="#L-2467"><span class="linenos">2467</span></a> <span class="n">using</span> <span class="o">=</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">USING</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> +</span><span id="L-2468"><a href="#L-2468"><span class="linenos">2468</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_alias</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">())</span> </span><span id="L-2469"><a href="#L-2469"><span class="linenos">2469</span></a> <span class="p">)</span> -</span><span id="L-2470"><a href="#L-2470"><span class="linenos">2470</span></a> -</span><span id="L-2471"><a href="#L-2471"><span class="linenos">2471</span></a> <span class="k">def</span> <span class="nf">_parse_pivot</span><span class="p">(</span><span class="bp">self</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">Pivot</span><span class="p">]:</span> -</span><span id="L-2472"><a href="#L-2472"><span class="linenos">2472</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="L-2473"><a href="#L-2473"><span class="linenos">2473</span></a> -</span><span id="L-2474"><a href="#L-2474"><span class="linenos">2474</span></a> <span class="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">PIVOT</span><span class="p">):</span> -</span><span id="L-2475"><a href="#L-2475"><span class="linenos">2475</span></a> <span class="n">unpivot</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-2476"><a href="#L-2476"><span class="linenos">2476</span></a> <span class="k">elif</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">UNPIVOT</span><span class="p">):</span> -</span><span id="L-2477"><a href="#L-2477"><span class="linenos">2477</span></a> <span class="n">unpivot</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-2478"><a href="#L-2478"><span class="linenos">2478</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2479"><a href="#L-2479"><span class="linenos">2479</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-2480"><a href="#L-2480"><span class="linenos">2480</span></a> -</span><span id="L-2481"><a href="#L-2481"><span class="linenos">2481</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-2482"><a href="#L-2482"><span class="linenos">2482</span></a> <span class="n">field</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2483"><a href="#L-2483"><span class="linenos">2483</span></a> -</span><span id="L-2484"><a href="#L-2484"><span class="linenos">2484</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">):</span> -</span><span id="L-2485"><a href="#L-2485"><span class="linenos">2485</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-2486"><a href="#L-2486"><span class="linenos">2486</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2470"><a href="#L-2470"><span class="linenos">2470</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_group</span><span class="p">()</span> +</span><span id="L-2471"><a href="#L-2471"><span class="linenos">2471</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-2472"><a href="#L-2472"><span class="linenos">2472</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">using</span><span class="o">=</span><span class="n">using</span><span class="p">,</span> <span class="n">group</span><span class="o">=</span><span class="n">group</span> +</span><span id="L-2473"><a href="#L-2473"><span class="linenos">2473</span></a> <span class="p">)</span> +</span><span id="L-2474"><a href="#L-2474"><span class="linenos">2474</span></a> +</span><span id="L-2475"><a href="#L-2475"><span class="linenos">2475</span></a> <span class="k">def</span> <span class="nf">_parse_pivot</span><span class="p">(</span><span class="bp">self</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">Pivot</span><span class="p">]:</span> +</span><span id="L-2476"><a href="#L-2476"><span class="linenos">2476</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="L-2477"><a href="#L-2477"><span class="linenos">2477</span></a> +</span><span id="L-2478"><a href="#L-2478"><span class="linenos">2478</span></a> <span class="k">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">PIVOT</span><span class="p">):</span> +</span><span id="L-2479"><a href="#L-2479"><span class="linenos">2479</span></a> <span class="n">unpivot</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-2480"><a href="#L-2480"><span class="linenos">2480</span></a> <span class="k">elif</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">UNPIVOT</span><span class="p">):</span> +</span><span id="L-2481"><a href="#L-2481"><span class="linenos">2481</span></a> <span class="n">unpivot</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-2482"><a href="#L-2482"><span class="linenos">2482</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2483"><a href="#L-2483"><span class="linenos">2483</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2484"><a href="#L-2484"><span class="linenos">2484</span></a> +</span><span id="L-2485"><a href="#L-2485"><span class="linenos">2485</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-2486"><a href="#L-2486"><span class="linenos">2486</span></a> <span class="n">field</span> <span class="o">=</span> <span class="kc">None</span> </span><span id="L-2487"><a href="#L-2487"><span class="linenos">2487</span></a> -</span><span id="L-2488"><a href="#L-2488"><span class="linenos">2488</span></a> <span class="k">if</span> <span class="n">unpivot</span><span class="p">:</span> -</span><span id="L-2489"><a href="#L-2489"><span class="linenos">2489</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">)</span> -</span><span id="L-2490"><a href="#L-2490"><span class="linenos">2490</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2491"><a href="#L-2491"><span class="linenos">2491</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_alias</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()))</span> -</span><span id="L-2492"><a href="#L-2492"><span class="linenos">2492</span></a> -</span><span id="L-2493"><a href="#L-2493"><span class="linenos">2493</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="L-2494"><a href="#L-2494"><span class="linenos">2494</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Failed to parse PIVOT's aggregation list"</span><span class="p">)</span> -</span><span id="L-2495"><a href="#L-2495"><span class="linenos">2495</span></a> -</span><span id="L-2496"><a href="#L-2496"><span class="linenos">2496</span></a> <span class="k">if</span> <span class="ow">not</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">FOR</span><span class="p">):</span> -</span><span id="L-2497"><a href="#L-2497"><span class="linenos">2497</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting FOR"</span><span class="p">)</span> -</span><span id="L-2498"><a href="#L-2498"><span class="linenos">2498</span></a> -</span><span id="L-2499"><a href="#L-2499"><span class="linenos">2499</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> -</span><span id="L-2500"><a href="#L-2500"><span class="linenos">2500</span></a> -</span><span id="L-2501"><a href="#L-2501"><span class="linenos">2501</span></a> <span class="k">if</span> <span class="ow">not</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">IN</span><span class="p">):</span> -</span><span id="L-2502"><a href="#L-2502"><span class="linenos">2502</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting IN"</span><span class="p">)</span> -</span><span id="L-2503"><a href="#L-2503"><span class="linenos">2503</span></a> -</span><span id="L-2504"><a href="#L-2504"><span class="linenos">2504</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_in</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2505"><a href="#L-2505"><span class="linenos">2505</span></a> -</span><span id="L-2506"><a href="#L-2506"><span class="linenos">2506</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-2488"><a href="#L-2488"><span class="linenos">2488</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">):</span> +</span><span id="L-2489"><a href="#L-2489"><span class="linenos">2489</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-2490"><a href="#L-2490"><span class="linenos">2490</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2491"><a href="#L-2491"><span class="linenos">2491</span></a> +</span><span id="L-2492"><a href="#L-2492"><span class="linenos">2492</span></a> <span class="k">if</span> <span class="n">unpivot</span><span class="p">:</span> +</span><span id="L-2493"><a href="#L-2493"><span class="linenos">2493</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">)</span> +</span><span id="L-2494"><a href="#L-2494"><span class="linenos">2494</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2495"><a href="#L-2495"><span class="linenos">2495</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_alias</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()))</span> +</span><span id="L-2496"><a href="#L-2496"><span class="linenos">2496</span></a> +</span><span id="L-2497"><a href="#L-2497"><span class="linenos">2497</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="L-2498"><a href="#L-2498"><span class="linenos">2498</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Failed to parse PIVOT's aggregation list"</span><span class="p">)</span> +</span><span id="L-2499"><a href="#L-2499"><span class="linenos">2499</span></a> +</span><span id="L-2500"><a href="#L-2500"><span class="linenos">2500</span></a> <span class="k">if</span> <span class="ow">not</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">FOR</span><span class="p">):</span> +</span><span id="L-2501"><a href="#L-2501"><span class="linenos">2501</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting FOR"</span><span class="p">)</span> +</span><span id="L-2502"><a href="#L-2502"><span class="linenos">2502</span></a> +</span><span id="L-2503"><a href="#L-2503"><span class="linenos">2503</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> +</span><span id="L-2504"><a href="#L-2504"><span class="linenos">2504</span></a> +</span><span id="L-2505"><a href="#L-2505"><span class="linenos">2505</span></a> <span class="k">if</span> <span class="ow">not</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">IN</span><span class="p">):</span> +</span><span id="L-2506"><a href="#L-2506"><span class="linenos">2506</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting IN"</span><span class="p">)</span> </span><span id="L-2507"><a href="#L-2507"><span class="linenos">2507</span></a> -</span><span id="L-2508"><a href="#L-2508"><span class="linenos">2508</span></a> <span class="n">pivot</span> <span class="o">=</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">Pivot</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">field</span><span class="o">=</span><span class="n">field</span><span class="p">,</span> <span class="n">unpivot</span><span class="o">=</span><span class="n">unpivot</span><span class="p">)</span> +</span><span id="L-2508"><a href="#L-2508"><span class="linenos">2508</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_in</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span><span id="L-2509"><a href="#L-2509"><span class="linenos">2509</span></a> -</span><span id="L-2510"><a href="#L-2510"><span class="linenos">2510</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">PIVOT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNPIVOT</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-2511"><a href="#L-2511"><span class="linenos">2511</span></a> <span class="n">pivot</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">())</span> -</span><span id="L-2512"><a href="#L-2512"><span class="linenos">2512</span></a> -</span><span id="L-2513"><a href="#L-2513"><span class="linenos">2513</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">unpivot</span><span class="p">:</span> -</span><span id="L-2514"><a href="#L-2514"><span class="linenos">2514</span></a> <span class="n">names</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_pivot_column_names</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">cast</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="n">expressions</span><span class="p">))</span> -</span><span id="L-2515"><a href="#L-2515"><span class="linenos">2515</span></a> -</span><span id="L-2516"><a href="#L-2516"><span class="linenos">2516</span></a> <span class="n">columns</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="p">[]</span> -</span><span id="L-2517"><a href="#L-2517"><span class="linenos">2517</span></a> <span class="k">for</span> <span class="n">fld</span> <span class="ow">in</span> <span class="n">pivot</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"field"</span><span class="p">]</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="L-2518"><a href="#L-2518"><span class="linenos">2518</span></a> <span class="n">field_name</span> <span class="o">=</span> <span class="n">fld</span><span class="o">.</span><span class="n">sql</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFY_PIVOT_STRINGS</span> <span class="k">else</span> <span class="n">fld</span><span class="o">.</span><span class="n">alias_or_name</span> -</span><span id="L-2519"><a href="#L-2519"><span class="linenos">2519</span></a> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">names</span><span class="p">:</span> -</span><span id="L-2520"><a href="#L-2520"><span class="linenos">2520</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">PREFIXED_PIVOT_COLUMNS</span><span class="p">:</span> -</span><span id="L-2521"><a href="#L-2521"><span class="linenos">2521</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">field_name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">name</span> <span class="k">else</span> <span class="n">field_name</span> -</span><span id="L-2522"><a href="#L-2522"><span class="linenos">2522</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2523"><a href="#L-2523"><span class="linenos">2523</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">field_name</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">name</span> <span class="k">else</span> <span class="n">field_name</span> -</span><span id="L-2524"><a href="#L-2524"><span class="linenos">2524</span></a> -</span><span id="L-2525"><a href="#L-2525"><span class="linenos">2525</span></a> <span class="n">columns</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">name</span><span class="p">))</span> -</span><span id="L-2526"><a href="#L-2526"><span class="linenos">2526</span></a> -</span><span id="L-2527"><a href="#L-2527"><span class="linenos">2527</span></a> <span class="n">pivot</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">columns</span><span class="p">)</span> +</span><span id="L-2510"><a href="#L-2510"><span class="linenos">2510</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-2511"><a href="#L-2511"><span class="linenos">2511</span></a> +</span><span id="L-2512"><a href="#L-2512"><span class="linenos">2512</span></a> <span class="n">pivot</span> <span class="o">=</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">Pivot</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">field</span><span class="o">=</span><span class="n">field</span><span class="p">,</span> <span class="n">unpivot</span><span class="o">=</span><span class="n">unpivot</span><span class="p">)</span> +</span><span id="L-2513"><a href="#L-2513"><span class="linenos">2513</span></a> +</span><span id="L-2514"><a href="#L-2514"><span class="linenos">2514</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">PIVOT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNPIVOT</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-2515"><a href="#L-2515"><span class="linenos">2515</span></a> <span class="n">pivot</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">())</span> +</span><span id="L-2516"><a href="#L-2516"><span class="linenos">2516</span></a> +</span><span id="L-2517"><a href="#L-2517"><span class="linenos">2517</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">unpivot</span><span class="p">:</span> +</span><span id="L-2518"><a href="#L-2518"><span class="linenos">2518</span></a> <span class="n">names</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_pivot_column_names</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">cast</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="n">expressions</span><span class="p">))</span> +</span><span id="L-2519"><a href="#L-2519"><span class="linenos">2519</span></a> +</span><span id="L-2520"><a href="#L-2520"><span class="linenos">2520</span></a> <span class="n">columns</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="p">[]</span> +</span><span id="L-2521"><a href="#L-2521"><span class="linenos">2521</span></a> <span class="k">for</span> <span class="n">fld</span> <span class="ow">in</span> <span class="n">pivot</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"field"</span><span class="p">]</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="L-2522"><a href="#L-2522"><span class="linenos">2522</span></a> <span class="n">field_name</span> <span class="o">=</span> <span class="n">fld</span><span class="o">.</span><span class="n">sql</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFY_PIVOT_STRINGS</span> <span class="k">else</span> <span class="n">fld</span><span class="o">.</span><span class="n">alias_or_name</span> +</span><span id="L-2523"><a href="#L-2523"><span class="linenos">2523</span></a> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">names</span><span class="p">:</span> +</span><span id="L-2524"><a href="#L-2524"><span class="linenos">2524</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">PREFIXED_PIVOT_COLUMNS</span><span class="p">:</span> +</span><span id="L-2525"><a href="#L-2525"><span class="linenos">2525</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">field_name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">name</span> <span class="k">else</span> <span class="n">field_name</span> +</span><span id="L-2526"><a href="#L-2526"><span class="linenos">2526</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2527"><a href="#L-2527"><span class="linenos">2527</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">field_name</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">name</span> <span class="k">else</span> <span class="n">field_name</span> </span><span id="L-2528"><a href="#L-2528"><span class="linenos">2528</span></a> -</span><span id="L-2529"><a href="#L-2529"><span class="linenos">2529</span></a> <span class="k">return</span> <span class="n">pivot</span> +</span><span id="L-2529"><a href="#L-2529"><span class="linenos">2529</span></a> <span class="n">columns</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">name</span><span class="p">))</span> </span><span id="L-2530"><a href="#L-2530"><span class="linenos">2530</span></a> -</span><span id="L-2531"><a href="#L-2531"><span class="linenos">2531</span></a> <span class="k">def</span> <span class="nf">_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-2532"><a href="#L-2532"><span class="linenos">2532</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">agg</span><span class="o">.</span><span class="n">alias</span> <span class="k">for</span> <span class="n">agg</span> <span class="ow">in</span> <span class="n">aggregations</span><span class="p">]</span> -</span><span id="L-2533"><a href="#L-2533"><span class="linenos">2533</span></a> -</span><span id="L-2534"><a href="#L-2534"><span class="linenos">2534</span></a> <span class="k">def</span> <span class="nf">_parse_where</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_where_token</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">Where</span><span class="p">]:</span> -</span><span id="L-2535"><a href="#L-2535"><span class="linenos">2535</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_where_token</span> <span class="ow">and</span> <span class="ow">not</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">WHERE</span><span class="p">):</span> -</span><span id="L-2536"><a href="#L-2536"><span class="linenos">2536</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2531"><a href="#L-2531"><span class="linenos">2531</span></a> <span class="n">pivot</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">columns</span><span class="p">)</span> +</span><span id="L-2532"><a href="#L-2532"><span class="linenos">2532</span></a> +</span><span id="L-2533"><a href="#L-2533"><span class="linenos">2533</span></a> <span class="k">return</span> <span class="n">pivot</span> +</span><span id="L-2534"><a href="#L-2534"><span class="linenos">2534</span></a> +</span><span id="L-2535"><a href="#L-2535"><span class="linenos">2535</span></a> <span class="k">def</span> <span class="nf">_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-2536"><a href="#L-2536"><span class="linenos">2536</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">agg</span><span class="o">.</span><span class="n">alias</span> <span class="k">for</span> <span class="n">agg</span> <span class="ow">in</span> <span class="n">aggregations</span><span class="p">]</span> </span><span id="L-2537"><a href="#L-2537"><span class="linenos">2537</span></a> -</span><span id="L-2538"><a href="#L-2538"><span class="linenos">2538</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-2539"><a href="#L-2539"><span class="linenos">2539</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</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_conjunction</span><span class="p">()</span> -</span><span id="L-2540"><a href="#L-2540"><span class="linenos">2540</span></a> <span class="p">)</span> +</span><span id="L-2538"><a href="#L-2538"><span class="linenos">2538</span></a> <span class="k">def</span> <span class="nf">_parse_where</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_where_token</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">Where</span><span class="p">]:</span> +</span><span id="L-2539"><a href="#L-2539"><span class="linenos">2539</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_where_token</span> <span class="ow">and</span> <span class="ow">not</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">WHERE</span><span class="p">):</span> +</span><span id="L-2540"><a href="#L-2540"><span class="linenos">2540</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="L-2541"><a href="#L-2541"><span class="linenos">2541</span></a> -</span><span id="L-2542"><a href="#L-2542"><span class="linenos">2542</span></a> <span class="k">def</span> <span class="nf">_parse_group</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_group_by_token</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">Group</span><span class="p">]:</span> -</span><span id="L-2543"><a href="#L-2543"><span class="linenos">2543</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_group_by_token</span> <span class="ow">and</span> <span class="ow">not</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">GROUP_BY</span><span class="p">):</span> -</span><span id="L-2544"><a href="#L-2544"><span class="linenos">2544</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2542"><a href="#L-2542"><span class="linenos">2542</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><span id="L-2543"><a href="#L-2543"><span class="linenos">2543</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</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_conjunction</span><span class="p">()</span> +</span><span id="L-2544"><a href="#L-2544"><span class="linenos">2544</span></a> <span class="p">)</span> </span><span id="L-2545"><a href="#L-2545"><span class="linenos">2545</span></a> -</span><span id="L-2546"><a href="#L-2546"><span class="linenos">2546</span></a> <span class="n">elements</span> <span class="o">=</span> <span class="n">defaultdict</span><span class="p">(</span><span class="nb">list</span><span class="p">)</span> -</span><span id="L-2547"><a href="#L-2547"><span class="linenos">2547</span></a> -</span><span id="L-2548"><a href="#L-2548"><span class="linenos">2548</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-2549"><a href="#L-2549"><span class="linenos">2549</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="L-2550"><a href="#L-2550"><span class="linenos">2550</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="L-2551"><a href="#L-2551"><span class="linenos">2551</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"expressions"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-2552"><a href="#L-2552"><span class="linenos">2552</span></a> -</span><span id="L-2553"><a href="#L-2553"><span class="linenos">2553</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_grouping_sets</span><span class="p">()</span> -</span><span id="L-2554"><a href="#L-2554"><span class="linenos">2554</span></a> <span class="k">if</span> <span class="n">grouping_sets</span><span class="p">:</span> -</span><span id="L-2555"><a href="#L-2555"><span class="linenos">2555</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"grouping_sets"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">grouping_sets</span><span class="p">)</span> +</span><span id="L-2546"><a href="#L-2546"><span class="linenos">2546</span></a> <span class="k">def</span> <span class="nf">_parse_group</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_group_by_token</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">Group</span><span class="p">]:</span> +</span><span id="L-2547"><a href="#L-2547"><span class="linenos">2547</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_group_by_token</span> <span class="ow">and</span> <span class="ow">not</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">GROUP_BY</span><span class="p">):</span> +</span><span id="L-2548"><a href="#L-2548"><span class="linenos">2548</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2549"><a href="#L-2549"><span class="linenos">2549</span></a> +</span><span id="L-2550"><a href="#L-2550"><span class="linenos">2550</span></a> <span class="n">elements</span> <span class="o">=</span> <span class="n">defaultdict</span><span class="p">(</span><span class="nb">list</span><span class="p">)</span> +</span><span id="L-2551"><a href="#L-2551"><span class="linenos">2551</span></a> +</span><span id="L-2552"><a href="#L-2552"><span class="linenos">2552</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-2553"><a href="#L-2553"><span class="linenos">2553</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="L-2554"><a href="#L-2554"><span class="linenos">2554</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="L-2555"><a href="#L-2555"><span class="linenos">2555</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"expressions"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> </span><span id="L-2556"><a href="#L-2556"><span class="linenos">2556</span></a> -</span><span id="L-2557"><a href="#L-2557"><span class="linenos">2557</span></a> <span class="n">rollup</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2558"><a href="#L-2558"><span class="linenos">2558</span></a> <span class="n">cube</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2559"><a href="#L-2559"><span class="linenos">2559</span></a> <span class="n">totals</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2557"><a href="#L-2557"><span class="linenos">2557</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_grouping_sets</span><span class="p">()</span> +</span><span id="L-2558"><a href="#L-2558"><span class="linenos">2558</span></a> <span class="k">if</span> <span class="n">grouping_sets</span><span class="p">:</span> +</span><span id="L-2559"><a href="#L-2559"><span class="linenos">2559</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"grouping_sets"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">grouping_sets</span><span class="p">)</span> </span><span id="L-2560"><a href="#L-2560"><span class="linenos">2560</span></a> -</span><span id="L-2561"><a href="#L-2561"><span class="linenos">2561</span></a> <span class="n">with_</span> <span class="o">=</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">WITH</span><span class="p">)</span> -</span><span id="L-2562"><a href="#L-2562"><span class="linenos">2562</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">ROLLUP</span><span class="p">):</span> -</span><span id="L-2563"><a href="#L-2563"><span class="linenos">2563</span></a> <span class="n">rollup</span> <span class="o">=</span> <span class="n">with_</span> <span class="ow">or</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_column</span><span class="p">)</span> -</span><span id="L-2564"><a href="#L-2564"><span class="linenos">2564</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"rollup"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">rollup</span><span class="p">))</span> -</span><span id="L-2565"><a href="#L-2565"><span class="linenos">2565</span></a> -</span><span id="L-2566"><a href="#L-2566"><span class="linenos">2566</span></a> <span class="k">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">CUBE</span><span class="p">):</span> -</span><span id="L-2567"><a href="#L-2567"><span class="linenos">2567</span></a> <span class="n">cube</span> <span class="o">=</span> <span class="n">with_</span> <span class="ow">or</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_column</span><span class="p">)</span> -</span><span id="L-2568"><a href="#L-2568"><span class="linenos">2568</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"cube"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">cube</span><span class="p">))</span> +</span><span id="L-2561"><a href="#L-2561"><span class="linenos">2561</span></a> <span class="n">rollup</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2562"><a href="#L-2562"><span class="linenos">2562</span></a> <span class="n">cube</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2563"><a href="#L-2563"><span class="linenos">2563</span></a> <span class="n">totals</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2564"><a href="#L-2564"><span class="linenos">2564</span></a> +</span><span id="L-2565"><a href="#L-2565"><span class="linenos">2565</span></a> <span class="n">with_</span> <span class="o">=</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">WITH</span><span class="p">)</span> +</span><span id="L-2566"><a href="#L-2566"><span class="linenos">2566</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">ROLLUP</span><span class="p">):</span> +</span><span id="L-2567"><a href="#L-2567"><span class="linenos">2567</span></a> <span class="n">rollup</span> <span class="o">=</span> <span class="n">with_</span> <span class="ow">or</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_column</span><span class="p">)</span> +</span><span id="L-2568"><a href="#L-2568"><span class="linenos">2568</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"rollup"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">rollup</span><span class="p">))</span> </span><span id="L-2569"><a href="#L-2569"><span class="linenos">2569</span></a> -</span><span id="L-2570"><a href="#L-2570"><span class="linenos">2570</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TOTALS"</span><span class="p">):</span> -</span><span id="L-2571"><a href="#L-2571"><span class="linenos">2571</span></a> <span class="n">totals</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-2572"><a href="#L-2572"><span class="linenos">2572</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"totals"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> <span class="c1"># type: ignore</span> +</span><span id="L-2570"><a href="#L-2570"><span class="linenos">2570</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">CUBE</span><span class="p">):</span> +</span><span id="L-2571"><a href="#L-2571"><span class="linenos">2571</span></a> <span class="n">cube</span> <span class="o">=</span> <span class="n">with_</span> <span class="ow">or</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_column</span><span class="p">)</span> +</span><span id="L-2572"><a href="#L-2572"><span class="linenos">2572</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"cube"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">cube</span><span class="p">))</span> </span><span id="L-2573"><a href="#L-2573"><span class="linenos">2573</span></a> -</span><span id="L-2574"><a href="#L-2574"><span class="linenos">2574</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">grouping_sets</span> <span class="ow">or</span> <span class="n">rollup</span> <span class="ow">or</span> <span class="n">cube</span> <span class="ow">or</span> <span class="n">totals</span><span class="p">):</span> -</span><span id="L-2575"><a href="#L-2575"><span class="linenos">2575</span></a> <span class="k">break</span> -</span><span id="L-2576"><a href="#L-2576"><span class="linenos">2576</span></a> -</span><span id="L-2577"><a href="#L-2577"><span class="linenos">2577</span></a> <span class="k">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">Group</span><span class="p">,</span> <span class="o">**</span><span class="n">elements</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="L-2578"><a href="#L-2578"><span class="linenos">2578</span></a> -</span><span id="L-2579"><a href="#L-2579"><span class="linenos">2579</span></a> <span class="k">def</span> <span class="nf">_parse_grouping_sets</span><span class="p">(</span><span class="bp">self</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">t</span><span class="o">.</span><span class="n">List</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><span id="L-2580"><a href="#L-2580"><span class="linenos">2580</span></a> <span class="k">if</span> <span class="ow">not</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">GROUPING_SETS</span><span class="p">):</span> -</span><span id="L-2581"><a href="#L-2581"><span class="linenos">2581</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2574"><a href="#L-2574"><span class="linenos">2574</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TOTALS"</span><span class="p">):</span> +</span><span id="L-2575"><a href="#L-2575"><span class="linenos">2575</span></a> <span class="n">totals</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-2576"><a href="#L-2576"><span class="linenos">2576</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"totals"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> <span class="c1"># type: ignore</span> +</span><span id="L-2577"><a href="#L-2577"><span class="linenos">2577</span></a> +</span><span id="L-2578"><a href="#L-2578"><span class="linenos">2578</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">grouping_sets</span> <span class="ow">or</span> <span class="n">rollup</span> <span class="ow">or</span> <span class="n">cube</span> <span class="ow">or</span> <span class="n">totals</span><span class="p">):</span> +</span><span id="L-2579"><a href="#L-2579"><span class="linenos">2579</span></a> <span class="k">break</span> +</span><span id="L-2580"><a href="#L-2580"><span class="linenos">2580</span></a> +</span><span id="L-2581"><a href="#L-2581"><span class="linenos">2581</span></a> <span class="k">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">Group</span><span class="p">,</span> <span class="o">**</span><span class="n">elements</span><span class="p">)</span> <span class="c1"># type: ignore</span> </span><span id="L-2582"><a href="#L-2582"><span class="linenos">2582</span></a> -</span><span id="L-2583"><a href="#L-2583"><span class="linenos">2583</span></a> <span class="k">return</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_grouping_set</span><span class="p">)</span> -</span><span id="L-2584"><a href="#L-2584"><span class="linenos">2584</span></a> -</span><span id="L-2585"><a href="#L-2585"><span class="linenos">2585</span></a> <span class="k">def</span> <span class="nf">_parse_grouping_set</span><span class="p">(</span><span class="bp">self</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-2586"><a href="#L-2586"><span class="linenos">2586</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_PAREN</span><span class="p">):</span> -</span><span id="L-2587"><a href="#L-2587"><span class="linenos">2587</span></a> <span class="n">grouping_set</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">)</span> -</span><span id="L-2588"><a href="#L-2588"><span class="linenos">2588</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="L-2589"><a href="#L-2589"><span class="linenos">2589</span></a> <span class="k">return</span> <span class="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">Tuple</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">grouping_set</span><span class="p">)</span> -</span><span id="L-2590"><a href="#L-2590"><span class="linenos">2590</span></a> -</span><span id="L-2591"><a href="#L-2591"><span class="linenos">2591</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> -</span><span id="L-2592"><a href="#L-2592"><span class="linenos">2592</span></a> -</span><span id="L-2593"><a href="#L-2593"><span class="linenos">2593</span></a> <span class="k">def</span> <span class="nf">_parse_having</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_having_token</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">Having</span><span class="p">]:</span> -</span><span id="L-2594"><a href="#L-2594"><span class="linenos">2594</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_having_token</span> <span class="ow">and</span> <span class="ow">not</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">HAVING</span><span class="p">):</span> -</span><span id="L-2595"><a href="#L-2595"><span class="linenos">2595</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-2596"><a href="#L-2596"><span class="linenos">2596</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Having</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">())</span> -</span><span id="L-2597"><a href="#L-2597"><span class="linenos">2597</span></a> -</span><span id="L-2598"><a href="#L-2598"><span class="linenos">2598</span></a> <span class="k">def</span> <span class="nf">_parse_qualify</span><span class="p">(</span><span class="bp">self</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">Qualify</span><span class="p">]:</span> -</span><span id="L-2599"><a href="#L-2599"><span class="linenos">2599</span></a> <span class="k">if</span> <span class="ow">not</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">QUALIFY</span><span class="p">):</span> -</span><span id="L-2600"><a href="#L-2600"><span class="linenos">2600</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-2601"><a href="#L-2601"><span class="linenos">2601</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">Qualify</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_conjunction</span><span class="p">())</span> -</span><span id="L-2602"><a href="#L-2602"><span class="linenos">2602</span></a> -</span><span id="L-2603"><a href="#L-2603"><span class="linenos">2603</span></a> <span class="k">def</span> <span class="nf">_parse_order</span><span class="p">(</span> -</span><span id="L-2604"><a href="#L-2604"><span class="linenos">2604</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 class="p">,</span> <span class="n">skip_order_token</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-2605"><a href="#L-2605"><span class="linenos">2605</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-2606"><a href="#L-2606"><span class="linenos">2606</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_order_token</span> <span class="ow">and</span> <span class="ow">not</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">ORDER_BY</span><span class="p">):</span> -</span><span id="L-2607"><a href="#L-2607"><span class="linenos">2607</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-2608"><a href="#L-2608"><span class="linenos">2608</span></a> -</span><span id="L-2609"><a href="#L-2609"><span class="linenos">2609</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-2610"><a href="#L-2610"><span class="linenos">2610</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_ordered</span><span class="p">)</span> -</span><span id="L-2611"><a href="#L-2611"><span class="linenos">2611</span></a> <span class="p">)</span> +</span><span id="L-2583"><a href="#L-2583"><span class="linenos">2583</span></a> <span class="k">def</span> <span class="nf">_parse_grouping_sets</span><span class="p">(</span><span class="bp">self</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">t</span><span class="o">.</span><span class="n">List</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><span id="L-2584"><a href="#L-2584"><span class="linenos">2584</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">GROUPING_SETS</span><span class="p">):</span> +</span><span id="L-2585"><a href="#L-2585"><span class="linenos">2585</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2586"><a href="#L-2586"><span class="linenos">2586</span></a> +</span><span id="L-2587"><a href="#L-2587"><span class="linenos">2587</span></a> <span class="k">return</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_grouping_set</span><span class="p">)</span> +</span><span id="L-2588"><a href="#L-2588"><span class="linenos">2588</span></a> +</span><span id="L-2589"><a href="#L-2589"><span class="linenos">2589</span></a> <span class="k">def</span> <span class="nf">_parse_grouping_set</span><span class="p">(</span><span class="bp">self</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-2590"><a href="#L-2590"><span class="linenos">2590</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_PAREN</span><span class="p">):</span> +</span><span id="L-2591"><a href="#L-2591"><span class="linenos">2591</span></a> <span class="n">grouping_set</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">)</span> +</span><span id="L-2592"><a href="#L-2592"><span class="linenos">2592</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-2593"><a href="#L-2593"><span class="linenos">2593</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">Tuple</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">grouping_set</span><span class="p">)</span> +</span><span id="L-2594"><a href="#L-2594"><span class="linenos">2594</span></a> +</span><span id="L-2595"><a href="#L-2595"><span class="linenos">2595</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> +</span><span id="L-2596"><a href="#L-2596"><span class="linenos">2596</span></a> +</span><span id="L-2597"><a href="#L-2597"><span class="linenos">2597</span></a> <span class="k">def</span> <span class="nf">_parse_having</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_having_token</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">Having</span><span class="p">]:</span> +</span><span id="L-2598"><a href="#L-2598"><span class="linenos">2598</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_having_token</span> <span class="ow">and</span> <span class="ow">not</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">HAVING</span><span class="p">):</span> +</span><span id="L-2599"><a href="#L-2599"><span class="linenos">2599</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2600"><a href="#L-2600"><span class="linenos">2600</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">Having</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_conjunction</span><span class="p">())</span> +</span><span id="L-2601"><a href="#L-2601"><span class="linenos">2601</span></a> +</span><span id="L-2602"><a href="#L-2602"><span class="linenos">2602</span></a> <span class="k">def</span> <span class="nf">_parse_qualify</span><span class="p">(</span><span class="bp">self</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">Qualify</span><span class="p">]:</span> +</span><span id="L-2603"><a href="#L-2603"><span class="linenos">2603</span></a> <span class="k">if</span> <span class="ow">not</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">QUALIFY</span><span class="p">):</span> +</span><span id="L-2604"><a href="#L-2604"><span class="linenos">2604</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2605"><a href="#L-2605"><span class="linenos">2605</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Qualify</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">())</span> +</span><span id="L-2606"><a href="#L-2606"><span class="linenos">2606</span></a> +</span><span id="L-2607"><a href="#L-2607"><span class="linenos">2607</span></a> <span class="k">def</span> <span class="nf">_parse_order</span><span class="p">(</span> +</span><span id="L-2608"><a href="#L-2608"><span class="linenos">2608</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 class="p">,</span> <span class="n">skip_order_token</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-2609"><a href="#L-2609"><span class="linenos">2609</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-2610"><a href="#L-2610"><span class="linenos">2610</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_order_token</span> <span class="ow">and</span> <span class="ow">not</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">ORDER_BY</span><span class="p">):</span> +</span><span id="L-2611"><a href="#L-2611"><span class="linenos">2611</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="L-2612"><a href="#L-2612"><span class="linenos">2612</span></a> -</span><span id="L-2613"><a href="#L-2613"><span class="linenos">2613</span></a> <span class="k">def</span> <span class="nf">_parse_sort</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> <span class="o">*</span><span class="n">texts</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">E</span><span class="p">]:</span> -</span><span id="L-2614"><a href="#L-2614"><span class="linenos">2614</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="o">*</span><span class="n">texts</span><span class="p">):</span> -</span><span id="L-2615"><a href="#L-2615"><span class="linenos">2615</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-2616"><a href="#L-2616"><span class="linenos">2616</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_class</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_ordered</span><span class="p">))</span> -</span><span id="L-2617"><a href="#L-2617"><span class="linenos">2617</span></a> -</span><span id="L-2618"><a href="#L-2618"><span class="linenos">2618</span></a> <span class="k">def</span> <span class="nf">_parse_ordered</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">Ordered</span><span class="p">:</span> -</span><span id="L-2619"><a href="#L-2619"><span class="linenos">2619</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="L-2620"><a href="#L-2620"><span class="linenos">2620</span></a> <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">ASC</span><span class="p">)</span> +</span><span id="L-2613"><a href="#L-2613"><span class="linenos">2613</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><span id="L-2614"><a href="#L-2614"><span class="linenos">2614</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_ordered</span><span class="p">)</span> +</span><span id="L-2615"><a href="#L-2615"><span class="linenos">2615</span></a> <span class="p">)</span> +</span><span id="L-2616"><a href="#L-2616"><span class="linenos">2616</span></a> +</span><span id="L-2617"><a href="#L-2617"><span class="linenos">2617</span></a> <span class="k">def</span> <span class="nf">_parse_sort</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> <span class="n">token</span><span class="p">:</span> <span class="n">TokenType</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">E</span><span class="p">]:</span> +</span><span id="L-2618"><a href="#L-2618"><span class="linenos">2618</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">token</span><span class="p">):</span> +</span><span id="L-2619"><a href="#L-2619"><span class="linenos">2619</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2620"><a href="#L-2620"><span class="linenos">2620</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp_class</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_ordered</span><span class="p">))</span> </span><span id="L-2621"><a href="#L-2621"><span class="linenos">2621</span></a> -</span><span id="L-2622"><a href="#L-2622"><span class="linenos">2622</span></a> <span class="n">is_desc</span> <span class="o">=</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">DESC</span><span class="p">)</span> -</span><span id="L-2623"><a href="#L-2623"><span class="linenos">2623</span></a> <span class="n">is_nulls_first</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULLS"</span><span class="p">,</span> <span class="s2">"FIRST"</span><span class="p">)</span> -</span><span id="L-2624"><a href="#L-2624"><span class="linenos">2624</span></a> <span class="n">is_nulls_last</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULLS"</span><span class="p">,</span> <span class="s2">"LAST"</span><span class="p">)</span> -</span><span id="L-2625"><a href="#L-2625"><span class="linenos">2625</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="n">is_desc</span> <span class="ow">or</span> <span class="kc">False</span> -</span><span id="L-2626"><a href="#L-2626"><span class="linenos">2626</span></a> <span class="n">asc</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">desc</span> -</span><span id="L-2627"><a href="#L-2627"><span class="linenos">2627</span></a> <span class="n">nulls_first</span> <span class="o">=</span> <span class="n">is_nulls_first</span> <span class="ow">or</span> <span class="kc">False</span> -</span><span id="L-2628"><a href="#L-2628"><span class="linenos">2628</span></a> <span class="n">explicitly_null_ordered</span> <span class="o">=</span> <span class="n">is_nulls_first</span> <span class="ow">or</span> <span class="n">is_nulls_last</span> -</span><span id="L-2629"><a href="#L-2629"><span class="linenos">2629</span></a> -</span><span id="L-2630"><a href="#L-2630"><span class="linenos">2630</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="L-2631"><a href="#L-2631"><span class="linenos">2631</span></a> <span class="ow">not</span> <span class="n">explicitly_null_ordered</span> -</span><span id="L-2632"><a href="#L-2632"><span class="linenos">2632</span></a> <span class="ow">and</span> <span class="p">(</span> -</span><span id="L-2633"><a href="#L-2633"><span class="linenos">2633</span></a> <span class="p">(</span><span class="n">asc</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_small"</span><span class="p">)</span> -</span><span id="L-2634"><a href="#L-2634"><span class="linenos">2634</span></a> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">!=</span> <span class="s2">"nulls_are_small"</span><span class="p">)</span> -</span><span id="L-2635"><a href="#L-2635"><span class="linenos">2635</span></a> <span class="p">)</span> -</span><span id="L-2636"><a href="#L-2636"><span class="linenos">2636</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">!=</span> <span class="s2">"nulls_are_last"</span> -</span><span id="L-2637"><a href="#L-2637"><span class="linenos">2637</span></a> <span class="p">):</span> -</span><span id="L-2638"><a href="#L-2638"><span class="linenos">2638</span></a> <span class="n">nulls_first</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-2639"><a href="#L-2639"><span class="linenos">2639</span></a> -</span><span id="L-2640"><a href="#L-2640"><span class="linenos">2640</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Ordered</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="n">desc</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="n">nulls_first</span><span class="p">)</span> -</span><span id="L-2641"><a href="#L-2641"><span class="linenos">2641</span></a> -</span><span id="L-2642"><a href="#L-2642"><span class="linenos">2642</span></a> <span class="k">def</span> <span class="nf">_parse_limit</span><span class="p">(</span> -</span><span id="L-2643"><a href="#L-2643"><span class="linenos">2643</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 class="p">,</span> <span class="n">top</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-2644"><a href="#L-2644"><span class="linenos">2644</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-2645"><a href="#L-2645"><span class="linenos">2645</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">TOP</span> <span class="k">if</span> <span class="n">top</span> <span class="k">else</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIMIT</span><span class="p">):</span> -</span><span id="L-2646"><a href="#L-2646"><span class="linenos">2646</span></a> <span class="n">limit_paren</span> <span class="o">=</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_PAREN</span><span class="p">)</span> -</span><span id="L-2647"><a href="#L-2647"><span class="linenos">2647</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> <span class="k">if</span> <span class="n">top</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> -</span><span id="L-2648"><a href="#L-2648"><span class="linenos">2648</span></a> -</span><span id="L-2649"><a href="#L-2649"><span class="linenos">2649</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">COMMA</span><span class="p">):</span> -</span><span id="L-2650"><a href="#L-2650"><span class="linenos">2650</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span> -</span><span id="L-2651"><a href="#L-2651"><span class="linenos">2651</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> -</span><span id="L-2652"><a href="#L-2652"><span class="linenos">2652</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2653"><a href="#L-2653"><span class="linenos">2653</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2654"><a href="#L-2654"><span class="linenos">2654</span></a> -</span><span id="L-2655"><a href="#L-2655"><span class="linenos">2655</span></a> <span class="n">limit_exp</span> <span class="o">=</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">Limit</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">offset</span><span class="o">=</span><span class="n">offset</span><span class="p">)</span> -</span><span id="L-2656"><a href="#L-2656"><span class="linenos">2656</span></a> -</span><span id="L-2657"><a href="#L-2657"><span class="linenos">2657</span></a> <span class="k">if</span> <span class="n">limit_paren</span><span class="p">:</span> -</span><span id="L-2658"><a href="#L-2658"><span class="linenos">2658</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="L-2659"><a href="#L-2659"><span class="linenos">2659</span></a> -</span><span id="L-2660"><a href="#L-2660"><span class="linenos">2660</span></a> <span class="k">return</span> <span class="n">limit_exp</span> -</span><span id="L-2661"><a href="#L-2661"><span class="linenos">2661</span></a> -</span><span id="L-2662"><a href="#L-2662"><span class="linenos">2662</span></a> <span class="k">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">FETCH</span><span class="p">):</span> -</span><span id="L-2663"><a href="#L-2663"><span class="linenos">2663</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FIRST</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEXT</span><span class="p">))</span> -</span><span id="L-2664"><a href="#L-2664"><span class="linenos">2664</span></a> <span class="n">direction</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="k">if</span> <span class="n">direction</span> <span class="k">else</span> <span class="s2">"FIRST"</span> +</span><span id="L-2622"><a href="#L-2622"><span class="linenos">2622</span></a> <span class="k">def</span> <span class="nf">_parse_ordered</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">Ordered</span><span class="p">:</span> +</span><span id="L-2623"><a href="#L-2623"><span class="linenos">2623</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="L-2624"><a href="#L-2624"><span class="linenos">2624</span></a> <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">ASC</span><span class="p">)</span> +</span><span id="L-2625"><a href="#L-2625"><span class="linenos">2625</span></a> +</span><span id="L-2626"><a href="#L-2626"><span class="linenos">2626</span></a> <span class="n">is_desc</span> <span class="o">=</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">DESC</span><span class="p">)</span> +</span><span id="L-2627"><a href="#L-2627"><span class="linenos">2627</span></a> <span class="n">is_nulls_first</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULLS"</span><span class="p">,</span> <span class="s2">"FIRST"</span><span class="p">)</span> +</span><span id="L-2628"><a href="#L-2628"><span class="linenos">2628</span></a> <span class="n">is_nulls_last</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULLS"</span><span class="p">,</span> <span class="s2">"LAST"</span><span class="p">)</span> +</span><span id="L-2629"><a href="#L-2629"><span class="linenos">2629</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="n">is_desc</span> <span class="ow">or</span> <span class="kc">False</span> +</span><span id="L-2630"><a href="#L-2630"><span class="linenos">2630</span></a> <span class="n">asc</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">desc</span> +</span><span id="L-2631"><a href="#L-2631"><span class="linenos">2631</span></a> <span class="n">nulls_first</span> <span class="o">=</span> <span class="n">is_nulls_first</span> <span class="ow">or</span> <span class="kc">False</span> +</span><span id="L-2632"><a href="#L-2632"><span class="linenos">2632</span></a> <span class="n">explicitly_null_ordered</span> <span class="o">=</span> <span class="n">is_nulls_first</span> <span class="ow">or</span> <span class="n">is_nulls_last</span> +</span><span id="L-2633"><a href="#L-2633"><span class="linenos">2633</span></a> +</span><span id="L-2634"><a href="#L-2634"><span class="linenos">2634</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="L-2635"><a href="#L-2635"><span class="linenos">2635</span></a> <span class="ow">not</span> <span class="n">explicitly_null_ordered</span> +</span><span id="L-2636"><a href="#L-2636"><span class="linenos">2636</span></a> <span class="ow">and</span> <span class="p">(</span> +</span><span id="L-2637"><a href="#L-2637"><span class="linenos">2637</span></a> <span class="p">(</span><span class="n">asc</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_small"</span><span class="p">)</span> +</span><span id="L-2638"><a href="#L-2638"><span class="linenos">2638</span></a> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">!=</span> <span class="s2">"nulls_are_small"</span><span class="p">)</span> +</span><span id="L-2639"><a href="#L-2639"><span class="linenos">2639</span></a> <span class="p">)</span> +</span><span id="L-2640"><a href="#L-2640"><span class="linenos">2640</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">!=</span> <span class="s2">"nulls_are_last"</span> +</span><span id="L-2641"><a href="#L-2641"><span class="linenos">2641</span></a> <span class="p">):</span> +</span><span id="L-2642"><a href="#L-2642"><span class="linenos">2642</span></a> <span class="n">nulls_first</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-2643"><a href="#L-2643"><span class="linenos">2643</span></a> +</span><span id="L-2644"><a href="#L-2644"><span class="linenos">2644</span></a> <span class="k">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">Ordered</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="n">desc</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="n">nulls_first</span><span class="p">)</span> +</span><span id="L-2645"><a href="#L-2645"><span class="linenos">2645</span></a> +</span><span id="L-2646"><a href="#L-2646"><span class="linenos">2646</span></a> <span class="k">def</span> <span class="nf">_parse_limit</span><span class="p">(</span> +</span><span id="L-2647"><a href="#L-2647"><span class="linenos">2647</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 class="p">,</span> <span class="n">top</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-2648"><a href="#L-2648"><span class="linenos">2648</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-2649"><a href="#L-2649"><span class="linenos">2649</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">TOP</span> <span class="k">if</span> <span class="n">top</span> <span class="k">else</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIMIT</span><span class="p">):</span> +</span><span id="L-2650"><a href="#L-2650"><span class="linenos">2650</span></a> <span class="n">limit_paren</span> <span class="o">=</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_PAREN</span><span class="p">)</span> +</span><span id="L-2651"><a href="#L-2651"><span class="linenos">2651</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> <span class="k">if</span> <span class="n">top</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> +</span><span id="L-2652"><a href="#L-2652"><span class="linenos">2652</span></a> +</span><span id="L-2653"><a href="#L-2653"><span class="linenos">2653</span></a> <span class="k">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">COMMA</span><span class="p">):</span> +</span><span id="L-2654"><a href="#L-2654"><span class="linenos">2654</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span> +</span><span id="L-2655"><a href="#L-2655"><span class="linenos">2655</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> +</span><span id="L-2656"><a href="#L-2656"><span class="linenos">2656</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2657"><a href="#L-2657"><span class="linenos">2657</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2658"><a href="#L-2658"><span class="linenos">2658</span></a> +</span><span id="L-2659"><a href="#L-2659"><span class="linenos">2659</span></a> <span class="n">limit_exp</span> <span class="o">=</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">Limit</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">offset</span><span class="o">=</span><span class="n">offset</span><span class="p">)</span> +</span><span id="L-2660"><a href="#L-2660"><span class="linenos">2660</span></a> +</span><span id="L-2661"><a href="#L-2661"><span class="linenos">2661</span></a> <span class="k">if</span> <span class="n">limit_paren</span><span class="p">:</span> +</span><span id="L-2662"><a href="#L-2662"><span class="linenos">2662</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-2663"><a href="#L-2663"><span class="linenos">2663</span></a> +</span><span id="L-2664"><a href="#L-2664"><span class="linenos">2664</span></a> <span class="k">return</span> <span class="n">limit_exp</span> </span><span id="L-2665"><a href="#L-2665"><span class="linenos">2665</span></a> -</span><span id="L-2666"><a href="#L-2666"><span class="linenos">2666</span></a> <span class="n">count</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> -</span><span id="L-2667"><a href="#L-2667"><span class="linenos">2667</span></a> <span class="n">percent</span> <span class="o">=</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">PERCENT</span><span class="p">)</span> -</span><span id="L-2668"><a href="#L-2668"><span class="linenos">2668</span></a> -</span><span id="L-2669"><a href="#L-2669"><span class="linenos">2669</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">))</span> -</span><span id="L-2670"><a href="#L-2670"><span class="linenos">2670</span></a> -</span><span id="L-2671"><a href="#L-2671"><span class="linenos">2671</span></a> <span class="n">only</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ONLY"</span><span class="p">)</span> -</span><span id="L-2672"><a href="#L-2672"><span class="linenos">2672</span></a> <span class="n">with_ties</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"TIES"</span><span class="p">)</span> -</span><span id="L-2673"><a href="#L-2673"><span class="linenos">2673</span></a> -</span><span id="L-2674"><a href="#L-2674"><span class="linenos">2674</span></a> <span class="k">if</span> <span class="n">only</span> <span class="ow">and</span> <span class="n">with_ties</span><span class="p">:</span> -</span><span id="L-2675"><a href="#L-2675"><span class="linenos">2675</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Cannot specify both ONLY and WITH TIES in FETCH clause"</span><span class="p">)</span> -</span><span id="L-2676"><a href="#L-2676"><span class="linenos">2676</span></a> -</span><span id="L-2677"><a href="#L-2677"><span class="linenos">2677</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-2678"><a href="#L-2678"><span class="linenos">2678</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">,</span> -</span><span id="L-2679"><a href="#L-2679"><span class="linenos">2679</span></a> <span class="n">direction</span><span class="o">=</span><span class="n">direction</span><span class="p">,</span> -</span><span id="L-2680"><a href="#L-2680"><span class="linenos">2680</span></a> <span class="n">count</span><span class="o">=</span><span class="n">count</span><span class="p">,</span> -</span><span id="L-2681"><a href="#L-2681"><span class="linenos">2681</span></a> <span class="n">percent</span><span class="o">=</span><span class="n">percent</span><span class="p">,</span> -</span><span id="L-2682"><a href="#L-2682"><span class="linenos">2682</span></a> <span class="n">with_ties</span><span class="o">=</span><span class="n">with_ties</span><span class="p">,</span> -</span><span id="L-2683"><a href="#L-2683"><span class="linenos">2683</span></a> <span class="p">)</span> -</span><span id="L-2684"><a href="#L-2684"><span class="linenos">2684</span></a> -</span><span id="L-2685"><a href="#L-2685"><span class="linenos">2685</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-2686"><a href="#L-2686"><span class="linenos">2686</span></a> -</span><span id="L-2687"><a href="#L-2687"><span class="linenos">2687</span></a> <span class="k">def</span> <span class="nf">_parse_offset</span><span class="p">(</span><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 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-2688"><a href="#L-2688"><span class="linenos">2688</span></a> <span class="k">if</span> <span class="ow">not</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">OFFSET</span><span class="p">):</span> -</span><span id="L-2689"><a href="#L-2689"><span class="linenos">2689</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-2666"><a href="#L-2666"><span class="linenos">2666</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">FETCH</span><span class="p">):</span> +</span><span id="L-2667"><a href="#L-2667"><span class="linenos">2667</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FIRST</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEXT</span><span class="p">))</span> +</span><span id="L-2668"><a href="#L-2668"><span class="linenos">2668</span></a> <span class="n">direction</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="k">if</span> <span class="n">direction</span> <span class="k">else</span> <span class="s2">"FIRST"</span> +</span><span id="L-2669"><a href="#L-2669"><span class="linenos">2669</span></a> +</span><span id="L-2670"><a href="#L-2670"><span class="linenos">2670</span></a> <span class="n">count</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> +</span><span id="L-2671"><a href="#L-2671"><span class="linenos">2671</span></a> <span class="n">percent</span> <span class="o">=</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">PERCENT</span><span class="p">)</span> +</span><span id="L-2672"><a href="#L-2672"><span class="linenos">2672</span></a> +</span><span id="L-2673"><a href="#L-2673"><span class="linenos">2673</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">))</span> +</span><span id="L-2674"><a href="#L-2674"><span class="linenos">2674</span></a> +</span><span id="L-2675"><a href="#L-2675"><span class="linenos">2675</span></a> <span class="n">only</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ONLY"</span><span class="p">)</span> +</span><span id="L-2676"><a href="#L-2676"><span class="linenos">2676</span></a> <span class="n">with_ties</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"TIES"</span><span class="p">)</span> +</span><span id="L-2677"><a href="#L-2677"><span class="linenos">2677</span></a> +</span><span id="L-2678"><a href="#L-2678"><span class="linenos">2678</span></a> <span class="k">if</span> <span class="n">only</span> <span class="ow">and</span> <span class="n">with_ties</span><span class="p">:</span> +</span><span id="L-2679"><a href="#L-2679"><span class="linenos">2679</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Cannot specify both ONLY and WITH TIES in FETCH clause"</span><span class="p">)</span> +</span><span id="L-2680"><a href="#L-2680"><span class="linenos">2680</span></a> +</span><span id="L-2681"><a href="#L-2681"><span class="linenos">2681</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-2682"><a href="#L-2682"><span class="linenos">2682</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">,</span> +</span><span id="L-2683"><a href="#L-2683"><span class="linenos">2683</span></a> <span class="n">direction</span><span class="o">=</span><span class="n">direction</span><span class="p">,</span> +</span><span id="L-2684"><a href="#L-2684"><span class="linenos">2684</span></a> <span class="n">count</span><span class="o">=</span><span class="n">count</span><span class="p">,</span> +</span><span id="L-2685"><a href="#L-2685"><span class="linenos">2685</span></a> <span class="n">percent</span><span class="o">=</span><span class="n">percent</span><span class="p">,</span> +</span><span id="L-2686"><a href="#L-2686"><span class="linenos">2686</span></a> <span class="n">with_ties</span><span class="o">=</span><span class="n">with_ties</span><span class="p">,</span> +</span><span id="L-2687"><a href="#L-2687"><span class="linenos">2687</span></a> <span class="p">)</span> +</span><span id="L-2688"><a href="#L-2688"><span class="linenos">2688</span></a> +</span><span id="L-2689"><a href="#L-2689"><span class="linenos">2689</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="L-2690"><a href="#L-2690"><span class="linenos">2690</span></a> -</span><span id="L-2691"><a href="#L-2691"><span class="linenos">2691</span></a> <span class="n">count</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> -</span><span id="L-2692"><a href="#L-2692"><span class="linenos">2692</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">))</span> -</span><span id="L-2693"><a href="#L-2693"><span class="linenos">2693</span></a> <span class="k">return</span> <span class="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">Offset</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">count</span><span class="p">)</span> +</span><span id="L-2691"><a href="#L-2691"><span class="linenos">2691</span></a> <span class="k">def</span> <span class="nf">_parse_offset</span><span class="p">(</span><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 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-2692"><a href="#L-2692"><span class="linenos">2692</span></a> <span class="k">if</span> <span class="ow">not</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">OFFSET</span><span class="p">):</span> +</span><span id="L-2693"><a href="#L-2693"><span class="linenos">2693</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="L-2694"><a href="#L-2694"><span class="linenos">2694</span></a> -</span><span id="L-2695"><a href="#L-2695"><span class="linenos">2695</span></a> <span class="k">def</span> <span class="nf">_parse_locks</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Lock</span><span class="p">]:</span> -</span><span id="L-2696"><a href="#L-2696"><span class="linenos">2696</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-2697"><a href="#L-2697"><span class="linenos">2697</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-2698"><a href="#L-2698"><span class="linenos">2698</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"UPDATE"</span><span class="p">):</span> -</span><span id="L-2699"><a href="#L-2699"><span class="linenos">2699</span></a> <span class="n">update</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-2700"><a href="#L-2700"><span class="linenos">2700</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"SHARE"</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span> -</span><span id="L-2701"><a href="#L-2701"><span class="linenos">2701</span></a> <span class="s2">"LOCK"</span><span class="p">,</span> <span class="s2">"IN"</span><span class="p">,</span> <span class="s2">"SHARE"</span><span class="p">,</span> <span class="s2">"MODE"</span> -</span><span id="L-2702"><a href="#L-2702"><span class="linenos">2702</span></a> <span class="p">):</span> -</span><span id="L-2703"><a href="#L-2703"><span class="linenos">2703</span></a> <span class="n">update</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-2704"><a href="#L-2704"><span class="linenos">2704</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2705"><a href="#L-2705"><span class="linenos">2705</span></a> <span class="k">break</span> -</span><span id="L-2706"><a href="#L-2706"><span class="linenos">2706</span></a> -</span><span id="L-2707"><a href="#L-2707"><span class="linenos">2707</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2708"><a href="#L-2708"><span class="linenos">2708</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OF"</span><span class="p">):</span> -</span><span id="L-2709"><a href="#L-2709"><span class="linenos">2709</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="L-2695"><a href="#L-2695"><span class="linenos">2695</span></a> <span class="n">count</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> +</span><span id="L-2696"><a href="#L-2696"><span class="linenos">2696</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">))</span> +</span><span id="L-2697"><a href="#L-2697"><span class="linenos">2697</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">Offset</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">count</span><span class="p">)</span> +</span><span id="L-2698"><a href="#L-2698"><span class="linenos">2698</span></a> +</span><span id="L-2699"><a href="#L-2699"><span class="linenos">2699</span></a> <span class="k">def</span> <span class="nf">_parse_locks</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Lock</span><span class="p">]:</span> +</span><span id="L-2700"><a href="#L-2700"><span class="linenos">2700</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-2701"><a href="#L-2701"><span class="linenos">2701</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-2702"><a href="#L-2702"><span class="linenos">2702</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"UPDATE"</span><span class="p">):</span> +</span><span id="L-2703"><a href="#L-2703"><span class="linenos">2703</span></a> <span class="n">update</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-2704"><a href="#L-2704"><span class="linenos">2704</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"SHARE"</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span> +</span><span id="L-2705"><a href="#L-2705"><span class="linenos">2705</span></a> <span class="s2">"LOCK"</span><span class="p">,</span> <span class="s2">"IN"</span><span class="p">,</span> <span class="s2">"SHARE"</span><span class="p">,</span> <span class="s2">"MODE"</span> +</span><span id="L-2706"><a href="#L-2706"><span class="linenos">2706</span></a> <span class="p">):</span> +</span><span id="L-2707"><a href="#L-2707"><span class="linenos">2707</span></a> <span class="n">update</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-2708"><a href="#L-2708"><span class="linenos">2708</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2709"><a href="#L-2709"><span class="linenos">2709</span></a> <span class="k">break</span> </span><span id="L-2710"><a href="#L-2710"><span class="linenos">2710</span></a> -</span><span id="L-2711"><a href="#L-2711"><span class="linenos">2711</span></a> <span class="n">wait</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2712"><a href="#L-2712"><span class="linenos">2712</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NOWAIT"</span><span class="p">):</span> -</span><span id="L-2713"><a href="#L-2713"><span class="linenos">2713</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-2714"><a href="#L-2714"><span class="linenos">2714</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WAIT"</span><span class="p">):</span> -</span><span id="L-2715"><a href="#L-2715"><span class="linenos">2715</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> -</span><span id="L-2716"><a href="#L-2716"><span class="linenos">2716</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SKIP"</span><span class="p">,</span> <span class="s2">"LOCKED"</span><span class="p">):</span> -</span><span id="L-2717"><a href="#L-2717"><span class="linenos">2717</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-2718"><a href="#L-2718"><span class="linenos">2718</span></a> -</span><span id="L-2719"><a href="#L-2719"><span class="linenos">2719</span></a> <span class="n">locks</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="L-2720"><a href="#L-2720"><span class="linenos">2720</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">Lock</span><span class="p">,</span> <span class="n">update</span><span class="o">=</span><span class="n">update</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">wait</span><span class="o">=</span><span class="n">wait</span><span class="p">)</span> -</span><span id="L-2721"><a href="#L-2721"><span class="linenos">2721</span></a> <span class="p">)</span> +</span><span id="L-2711"><a href="#L-2711"><span class="linenos">2711</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2712"><a href="#L-2712"><span class="linenos">2712</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OF"</span><span class="p">):</span> +</span><span id="L-2713"><a href="#L-2713"><span class="linenos">2713</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="L-2714"><a href="#L-2714"><span class="linenos">2714</span></a> +</span><span id="L-2715"><a href="#L-2715"><span class="linenos">2715</span></a> <span class="n">wait</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2716"><a href="#L-2716"><span class="linenos">2716</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NOWAIT"</span><span class="p">):</span> +</span><span id="L-2717"><a href="#L-2717"><span class="linenos">2717</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-2718"><a href="#L-2718"><span class="linenos">2718</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WAIT"</span><span class="p">):</span> +</span><span id="L-2719"><a href="#L-2719"><span class="linenos">2719</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="L-2720"><a href="#L-2720"><span class="linenos">2720</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SKIP"</span><span class="p">,</span> <span class="s2">"LOCKED"</span><span class="p">):</span> +</span><span id="L-2721"><a href="#L-2721"><span class="linenos">2721</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="kc">False</span> </span><span id="L-2722"><a href="#L-2722"><span class="linenos">2722</span></a> -</span><span id="L-2723"><a href="#L-2723"><span class="linenos">2723</span></a> <span class="k">return</span> <span class="n">locks</span> -</span><span id="L-2724"><a href="#L-2724"><span class="linenos">2724</span></a> -</span><span id="L-2725"><a href="#L-2725"><span class="linenos">2725</span></a> <span class="k">def</span> <span class="nf">_parse_set_operations</span><span class="p">(</span><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="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-2726"><a href="#L-2726"><span class="linenos">2726</span></a> <span class="k">if</span> <span class="ow">not</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">SET_OPERATIONS</span><span class="p">):</span> -</span><span id="L-2727"><a href="#L-2727"><span class="linenos">2727</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-2723"><a href="#L-2723"><span class="linenos">2723</span></a> <span class="n">locks</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="L-2724"><a href="#L-2724"><span class="linenos">2724</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">Lock</span><span class="p">,</span> <span class="n">update</span><span class="o">=</span><span class="n">update</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">wait</span><span class="o">=</span><span class="n">wait</span><span class="p">)</span> +</span><span id="L-2725"><a href="#L-2725"><span class="linenos">2725</span></a> <span class="p">)</span> +</span><span id="L-2726"><a href="#L-2726"><span class="linenos">2726</span></a> +</span><span id="L-2727"><a href="#L-2727"><span class="linenos">2727</span></a> <span class="k">return</span> <span class="n">locks</span> </span><span id="L-2728"><a href="#L-2728"><span class="linenos">2728</span></a> -</span><span id="L-2729"><a href="#L-2729"><span class="linenos">2729</span></a> <span class="n">token_type</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">token_type</span> -</span><span id="L-2730"><a href="#L-2730"><span class="linenos">2730</span></a> -</span><span id="L-2731"><a href="#L-2731"><span class="linenos">2731</span></a> <span class="k">if</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNION</span><span class="p">:</span> -</span><span id="L-2732"><a href="#L-2732"><span class="linenos">2732</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> -</span><span id="L-2733"><a href="#L-2733"><span class="linenos">2733</span></a> <span class="k">elif</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXCEPT</span><span class="p">:</span> -</span><span id="L-2734"><a href="#L-2734"><span class="linenos">2734</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span> -</span><span id="L-2735"><a href="#L-2735"><span class="linenos">2735</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2736"><a href="#L-2736"><span class="linenos">2736</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span> -</span><span id="L-2737"><a href="#L-2737"><span class="linenos">2737</span></a> -</span><span id="L-2738"><a href="#L-2738"><span class="linenos">2738</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-2739"><a href="#L-2739"><span class="linenos">2739</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="L-2740"><a href="#L-2740"><span class="linenos">2740</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-2741"><a href="#L-2741"><span class="linenos">2741</span></a> <span class="n">distinct</span><span class="o">=</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">DISTINCT</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ALL</span><span class="p">),</span> -</span><span id="L-2742"><a href="#L-2742"><span class="linenos">2742</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">)),</span> -</span><span id="L-2743"><a href="#L-2743"><span class="linenos">2743</span></a> <span class="p">)</span> -</span><span id="L-2744"><a href="#L-2744"><span class="linenos">2744</span></a> -</span><span id="L-2745"><a href="#L-2745"><span class="linenos">2745</span></a> <span class="k">def</span> <span class="nf">_parse_expression</span><span class="p">(</span><span class="bp">self</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-2746"><a href="#L-2746"><span class="linenos">2746</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_alias</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">())</span> -</span><span id="L-2747"><a href="#L-2747"><span class="linenos">2747</span></a> -</span><span id="L-2748"><a href="#L-2748"><span class="linenos">2748</span></a> <span class="k">def</span> <span class="nf">_parse_conjunction</span><span class="p">(</span><span class="bp">self</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-2749"><a href="#L-2749"><span class="linenos">2749</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONJUNCTION</span><span class="p">)</span> -</span><span id="L-2750"><a href="#L-2750"><span class="linenos">2750</span></a> -</span><span id="L-2751"><a href="#L-2751"><span class="linenos">2751</span></a> <span class="k">def</span> <span class="nf">_parse_equality</span><span class="p">(</span><span class="bp">self</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-2752"><a href="#L-2752"><span class="linenos">2752</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_comparison</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">EQUALITY</span><span class="p">)</span> -</span><span id="L-2753"><a href="#L-2753"><span class="linenos">2753</span></a> -</span><span id="L-2754"><a href="#L-2754"><span class="linenos">2754</span></a> <span class="k">def</span> <span class="nf">_parse_comparison</span><span class="p">(</span><span class="bp">self</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-2755"><a href="#L-2755"><span class="linenos">2755</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_range</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">COMPARISON</span><span class="p">)</span> -</span><span id="L-2756"><a href="#L-2756"><span class="linenos">2756</span></a> -</span><span id="L-2757"><a href="#L-2757"><span class="linenos">2757</span></a> <span class="k">def</span> <span class="nf">_parse_range</span><span class="p">(</span><span class="bp">self</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-2758"><a href="#L-2758"><span class="linenos">2758</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="L-2759"><a href="#L-2759"><span class="linenos">2759</span></a> <span class="n">negate</span> <span class="o">=</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">NOT</span><span class="p">)</span> +</span><span id="L-2729"><a href="#L-2729"><span class="linenos">2729</span></a> <span class="k">def</span> <span class="nf">_parse_set_operations</span><span class="p">(</span><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="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-2730"><a href="#L-2730"><span class="linenos">2730</span></a> <span class="k">if</span> <span class="ow">not</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">SET_OPERATIONS</span><span class="p">):</span> +</span><span id="L-2731"><a href="#L-2731"><span class="linenos">2731</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-2732"><a href="#L-2732"><span class="linenos">2732</span></a> +</span><span id="L-2733"><a href="#L-2733"><span class="linenos">2733</span></a> <span class="n">token_type</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">token_type</span> +</span><span id="L-2734"><a href="#L-2734"><span class="linenos">2734</span></a> +</span><span id="L-2735"><a href="#L-2735"><span class="linenos">2735</span></a> <span class="k">if</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNION</span><span class="p">:</span> +</span><span id="L-2736"><a href="#L-2736"><span class="linenos">2736</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> +</span><span id="L-2737"><a href="#L-2737"><span class="linenos">2737</span></a> <span class="k">elif</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXCEPT</span><span class="p">:</span> +</span><span id="L-2738"><a href="#L-2738"><span class="linenos">2738</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span> +</span><span id="L-2739"><a href="#L-2739"><span class="linenos">2739</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2740"><a href="#L-2740"><span class="linenos">2740</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span> +</span><span id="L-2741"><a href="#L-2741"><span class="linenos">2741</span></a> +</span><span id="L-2742"><a href="#L-2742"><span class="linenos">2742</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><span id="L-2743"><a href="#L-2743"><span class="linenos">2743</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="L-2744"><a href="#L-2744"><span class="linenos">2744</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-2745"><a href="#L-2745"><span class="linenos">2745</span></a> <span class="n">distinct</span><span class="o">=</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">DISTINCT</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ALL</span><span class="p">),</span> +</span><span id="L-2746"><a href="#L-2746"><span class="linenos">2746</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">)),</span> +</span><span id="L-2747"><a href="#L-2747"><span class="linenos">2747</span></a> <span class="p">)</span> +</span><span id="L-2748"><a href="#L-2748"><span class="linenos">2748</span></a> +</span><span id="L-2749"><a href="#L-2749"><span class="linenos">2749</span></a> <span class="k">def</span> <span class="nf">_parse_expression</span><span class="p">(</span><span class="bp">self</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-2750"><a href="#L-2750"><span class="linenos">2750</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_alias</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">())</span> +</span><span id="L-2751"><a href="#L-2751"><span class="linenos">2751</span></a> +</span><span id="L-2752"><a href="#L-2752"><span class="linenos">2752</span></a> <span class="k">def</span> <span class="nf">_parse_conjunction</span><span class="p">(</span><span class="bp">self</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-2753"><a href="#L-2753"><span class="linenos">2753</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONJUNCTION</span><span class="p">)</span> +</span><span id="L-2754"><a href="#L-2754"><span class="linenos">2754</span></a> +</span><span id="L-2755"><a href="#L-2755"><span class="linenos">2755</span></a> <span class="k">def</span> <span class="nf">_parse_equality</span><span class="p">(</span><span class="bp">self</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-2756"><a href="#L-2756"><span class="linenos">2756</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_comparison</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">EQUALITY</span><span class="p">)</span> +</span><span id="L-2757"><a href="#L-2757"><span class="linenos">2757</span></a> +</span><span id="L-2758"><a href="#L-2758"><span class="linenos">2758</span></a> <span class="k">def</span> <span class="nf">_parse_comparison</span><span class="p">(</span><span class="bp">self</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-2759"><a href="#L-2759"><span class="linenos">2759</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_range</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">COMPARISON</span><span class="p">)</span> </span><span id="L-2760"><a href="#L-2760"><span class="linenos">2760</span></a> -</span><span id="L-2761"><a href="#L-2761"><span class="linenos">2761</span></a> <span class="k">if</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">RANGE_PARSERS</span><span class="p">):</span> -</span><span id="L-2762"><a href="#L-2762"><span class="linenos">2762</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">RANGE_PARSERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">)</span> -</span><span id="L-2763"><a href="#L-2763"><span class="linenos">2763</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> -</span><span id="L-2764"><a href="#L-2764"><span class="linenos">2764</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-2765"><a href="#L-2765"><span class="linenos">2765</span></a> -</span><span id="L-2766"><a href="#L-2766"><span class="linenos">2766</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span> -</span><span id="L-2767"><a href="#L-2767"><span class="linenos">2767</span></a> <span class="k">elif</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">ISNULL</span><span class="p">):</span> -</span><span id="L-2768"><a href="#L-2768"><span class="linenos">2768</span></a> <span class="n">this</span> <span class="o">=</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">Is</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">())</span> +</span><span id="L-2761"><a href="#L-2761"><span class="linenos">2761</span></a> <span class="k">def</span> <span class="nf">_parse_range</span><span class="p">(</span><span class="bp">self</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-2762"><a href="#L-2762"><span class="linenos">2762</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="L-2763"><a href="#L-2763"><span class="linenos">2763</span></a> <span class="n">negate</span> <span class="o">=</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">NOT</span><span class="p">)</span> +</span><span id="L-2764"><a href="#L-2764"><span class="linenos">2764</span></a> +</span><span id="L-2765"><a href="#L-2765"><span class="linenos">2765</span></a> <span class="k">if</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">RANGE_PARSERS</span><span class="p">):</span> +</span><span id="L-2766"><a href="#L-2766"><span class="linenos">2766</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">RANGE_PARSERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">)</span> +</span><span id="L-2767"><a href="#L-2767"><span class="linenos">2767</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> +</span><span id="L-2768"><a href="#L-2768"><span class="linenos">2768</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="L-2769"><a href="#L-2769"><span class="linenos">2769</span></a> -</span><span id="L-2770"><a href="#L-2770"><span class="linenos">2770</span></a> <span class="c1"># Postgres supports ISNULL and NOTNULL for conditions.</span> -</span><span id="L-2771"><a href="#L-2771"><span class="linenos">2771</span></a> <span class="c1"># https://blog.andreiavram.ro/postgresql-null-composite-type/</span> -</span><span id="L-2772"><a href="#L-2772"><span class="linenos">2772</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">NOTNULL</span><span class="p">):</span> -</span><span id="L-2773"><a href="#L-2773"><span class="linenos">2773</span></a> <span class="n">this</span> <span class="o">=</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">Is</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">())</span> -</span><span id="L-2774"><a href="#L-2774"><span class="linenos">2774</span></a> <span class="n">this</span> <span class="o">=</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">Not</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-2775"><a href="#L-2775"><span class="linenos">2775</span></a> -</span><span id="L-2776"><a href="#L-2776"><span class="linenos">2776</span></a> <span class="k">if</span> <span class="n">negate</span><span class="p">:</span> -</span><span id="L-2777"><a href="#L-2777"><span class="linenos">2777</span></a> <span class="n">this</span> <span class="o">=</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">Not</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-2778"><a href="#L-2778"><span class="linenos">2778</span></a> -</span><span id="L-2779"><a href="#L-2779"><span class="linenos">2779</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">IS</span><span class="p">):</span> -</span><span id="L-2780"><a href="#L-2780"><span class="linenos">2780</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_is</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-2781"><a href="#L-2781"><span class="linenos">2781</span></a> -</span><span id="L-2782"><a href="#L-2782"><span class="linenos">2782</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-2783"><a href="#L-2783"><span class="linenos">2783</span></a> -</span><span id="L-2784"><a href="#L-2784"><span class="linenos">2784</span></a> <span class="k">def</span> <span class="nf">_parse_is</span><span class="p">(</span><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="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-2785"><a href="#L-2785"><span class="linenos">2785</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span> -</span><span id="L-2786"><a href="#L-2786"><span class="linenos">2786</span></a> <span class="n">negate</span> <span class="o">=</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">NOT</span><span class="p">)</span> +</span><span id="L-2770"><a href="#L-2770"><span class="linenos">2770</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span> +</span><span id="L-2771"><a href="#L-2771"><span class="linenos">2771</span></a> <span class="k">elif</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">ISNULL</span><span class="p">):</span> +</span><span id="L-2772"><a href="#L-2772"><span class="linenos">2772</span></a> <span class="n">this</span> <span class="o">=</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">Is</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">())</span> +</span><span id="L-2773"><a href="#L-2773"><span class="linenos">2773</span></a> +</span><span id="L-2774"><a href="#L-2774"><span class="linenos">2774</span></a> <span class="c1"># Postgres supports ISNULL and NOTNULL for conditions.</span> +</span><span id="L-2775"><a href="#L-2775"><span class="linenos">2775</span></a> <span class="c1"># https://blog.andreiavram.ro/postgresql-null-composite-type/</span> +</span><span id="L-2776"><a href="#L-2776"><span class="linenos">2776</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">NOTNULL</span><span class="p">):</span> +</span><span id="L-2777"><a href="#L-2777"><span class="linenos">2777</span></a> <span class="n">this</span> <span class="o">=</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">Is</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">())</span> +</span><span id="L-2778"><a href="#L-2778"><span class="linenos">2778</span></a> <span class="n">this</span> <span class="o">=</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">Not</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-2779"><a href="#L-2779"><span class="linenos">2779</span></a> +</span><span id="L-2780"><a href="#L-2780"><span class="linenos">2780</span></a> <span class="k">if</span> <span class="n">negate</span><span class="p">:</span> +</span><span id="L-2781"><a href="#L-2781"><span class="linenos">2781</span></a> <span class="n">this</span> <span class="o">=</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">Not</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-2782"><a href="#L-2782"><span class="linenos">2782</span></a> +</span><span id="L-2783"><a href="#L-2783"><span class="linenos">2783</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IS</span><span class="p">):</span> +</span><span id="L-2784"><a href="#L-2784"><span class="linenos">2784</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_is</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-2785"><a href="#L-2785"><span class="linenos">2785</span></a> +</span><span id="L-2786"><a href="#L-2786"><span class="linenos">2786</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="L-2787"><a href="#L-2787"><span class="linenos">2787</span></a> -</span><span id="L-2788"><a href="#L-2788"><span class="linenos">2788</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DISTINCT"</span><span class="p">,</span> <span class="s2">"FROM"</span><span class="p">):</span> -</span><span id="L-2789"><a href="#L-2789"><span class="linenos">2789</span></a> <span class="n">klass</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeEQ</span> <span class="k">if</span> <span class="n">negate</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeNEQ</span> -</span><span id="L-2790"><a href="#L-2790"><span class="linenos">2790</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">klass</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">())</span> +</span><span id="L-2788"><a href="#L-2788"><span class="linenos">2788</span></a> <span class="k">def</span> <span class="nf">_parse_is</span><span class="p">(</span><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="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-2789"><a href="#L-2789"><span class="linenos">2789</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span> +</span><span id="L-2790"><a href="#L-2790"><span class="linenos">2790</span></a> <span class="n">negate</span> <span class="o">=</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">NOT</span><span class="p">)</span> </span><span id="L-2791"><a href="#L-2791"><span class="linenos">2791</span></a> -</span><span id="L-2792"><a href="#L-2792"><span class="linenos">2792</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_null</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_boolean</span><span class="p">()</span> -</span><span id="L-2793"><a href="#L-2793"><span class="linenos">2793</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> -</span><span id="L-2794"><a href="#L-2794"><span class="linenos">2794</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-2795"><a href="#L-2795"><span class="linenos">2795</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-2796"><a href="#L-2796"><span class="linenos">2796</span></a> -</span><span id="L-2797"><a href="#L-2797"><span class="linenos">2797</span></a> <span class="n">this</span> <span class="o">=</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">Is</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-2798"><a href="#L-2798"><span class="linenos">2798</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">Not</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="n">negate</span> <span class="k">else</span> <span class="n">this</span> -</span><span id="L-2799"><a href="#L-2799"><span class="linenos">2799</span></a> -</span><span id="L-2800"><a href="#L-2800"><span class="linenos">2800</span></a> <span class="k">def</span> <span class="nf">_parse_in</span><span class="p">(</span><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="n">alias</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">exp</span><span class="o">.</span><span class="n">In</span><span class="p">:</span> -</span><span id="L-2801"><a href="#L-2801"><span class="linenos">2801</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_unnest</span><span class="p">(</span><span class="n">with_alias</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-2802"><a href="#L-2802"><span class="linenos">2802</span></a> <span class="k">if</span> <span class="n">unnest</span><span class="p">:</span> -</span><span id="L-2803"><a href="#L-2803"><span class="linenos">2803</span></a> <span class="n">this</span> <span class="o">=</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">In</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">unnest</span><span class="o">=</span><span class="n">unnest</span><span class="p">)</span> -</span><span id="L-2804"><a href="#L-2804"><span class="linenos">2804</span></a> <span class="k">elif</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_PAREN</span><span class="p">):</span> -</span><span id="L-2805"><a href="#L-2805"><span class="linenos">2805</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select_or_expression</span><span class="p">(</span><span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">))</span> -</span><span id="L-2806"><a href="#L-2806"><span class="linenos">2806</span></a> -</span><span id="L-2807"><a href="#L-2807"><span class="linenos">2807</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="L-2808"><a href="#L-2808"><span class="linenos">2808</span></a> <span class="n">this</span> <span class="o">=</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">In</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">query</span><span class="o">=</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> -</span><span id="L-2809"><a href="#L-2809"><span class="linenos">2809</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2810"><a href="#L-2810"><span class="linenos">2810</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">In</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-2811"><a href="#L-2811"><span class="linenos">2811</span></a> -</span><span id="L-2812"><a href="#L-2812"><span class="linenos">2812</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-2813"><a href="#L-2813"><span class="linenos">2813</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2814"><a href="#L-2814"><span class="linenos">2814</span></a> <span class="n">this</span> <span class="o">=</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">In</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">field</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">())</span> +</span><span id="L-2792"><a href="#L-2792"><span class="linenos">2792</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DISTINCT"</span><span class="p">,</span> <span class="s2">"FROM"</span><span class="p">):</span> +</span><span id="L-2793"><a href="#L-2793"><span class="linenos">2793</span></a> <span class="n">klass</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeEQ</span> <span class="k">if</span> <span class="n">negate</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeNEQ</span> +</span><span id="L-2794"><a href="#L-2794"><span class="linenos">2794</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">klass</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">())</span> +</span><span id="L-2795"><a href="#L-2795"><span class="linenos">2795</span></a> +</span><span id="L-2796"><a href="#L-2796"><span class="linenos">2796</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_null</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_boolean</span><span class="p">()</span> +</span><span id="L-2797"><a href="#L-2797"><span class="linenos">2797</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> +</span><span id="L-2798"><a href="#L-2798"><span class="linenos">2798</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-2799"><a href="#L-2799"><span class="linenos">2799</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2800"><a href="#L-2800"><span class="linenos">2800</span></a> +</span><span id="L-2801"><a href="#L-2801"><span class="linenos">2801</span></a> <span class="n">this</span> <span class="o">=</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">Is</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-2802"><a href="#L-2802"><span class="linenos">2802</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">Not</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="n">negate</span> <span class="k">else</span> <span class="n">this</span> +</span><span id="L-2803"><a href="#L-2803"><span class="linenos">2803</span></a> +</span><span id="L-2804"><a href="#L-2804"><span class="linenos">2804</span></a> <span class="k">def</span> <span class="nf">_parse_in</span><span class="p">(</span><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="n">alias</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">exp</span><span class="o">.</span><span class="n">In</span><span class="p">:</span> +</span><span id="L-2805"><a href="#L-2805"><span class="linenos">2805</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_unnest</span><span class="p">(</span><span class="n">with_alias</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-2806"><a href="#L-2806"><span class="linenos">2806</span></a> <span class="k">if</span> <span class="n">unnest</span><span class="p">:</span> +</span><span id="L-2807"><a href="#L-2807"><span class="linenos">2807</span></a> <span class="n">this</span> <span class="o">=</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">In</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">unnest</span><span class="o">=</span><span class="n">unnest</span><span class="p">)</span> +</span><span id="L-2808"><a href="#L-2808"><span class="linenos">2808</span></a> <span class="k">elif</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_PAREN</span><span class="p">):</span> +</span><span id="L-2809"><a href="#L-2809"><span class="linenos">2809</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select_or_expression</span><span class="p">(</span><span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">))</span> +</span><span id="L-2810"><a href="#L-2810"><span class="linenos">2810</span></a> +</span><span id="L-2811"><a href="#L-2811"><span class="linenos">2811</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="L-2812"><a href="#L-2812"><span class="linenos">2812</span></a> <span class="n">this</span> <span class="o">=</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">In</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">query</span><span class="o">=</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> +</span><span id="L-2813"><a href="#L-2813"><span class="linenos">2813</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2814"><a href="#L-2814"><span class="linenos">2814</span></a> <span class="n">this</span> <span class="o">=</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">In</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> </span><span id="L-2815"><a href="#L-2815"><span class="linenos">2815</span></a> -</span><span id="L-2816"><a href="#L-2816"><span class="linenos">2816</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-2817"><a href="#L-2817"><span class="linenos">2817</span></a> -</span><span id="L-2818"><a href="#L-2818"><span class="linenos">2818</span></a> <span class="k">def</span> <span class="nf">_parse_between</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">:</span> -</span><span id="L-2819"><a href="#L-2819"><span class="linenos">2819</span></a> <span class="n">low</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="L-2820"><a href="#L-2820"><span class="linenos">2820</span></a> <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">AND</span><span class="p">)</span> -</span><span id="L-2821"><a href="#L-2821"><span class="linenos">2821</span></a> <span class="n">high</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="L-2822"><a href="#L-2822"><span class="linenos">2822</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">Between</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">low</span><span class="o">=</span><span class="n">low</span><span class="p">,</span> <span class="n">high</span><span class="o">=</span><span class="n">high</span><span class="p">)</span> -</span><span id="L-2823"><a href="#L-2823"><span class="linenos">2823</span></a> -</span><span id="L-2824"><a href="#L-2824"><span class="linenos">2824</span></a> <span class="k">def</span> <span class="nf">_parse_escape</span><span class="p">(</span><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="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-2825"><a href="#L-2825"><span class="linenos">2825</span></a> <span class="k">if</span> <span class="ow">not</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">ESCAPE</span><span class="p">):</span> -</span><span id="L-2826"><a href="#L-2826"><span class="linenos">2826</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-2827"><a href="#L-2827"><span class="linenos">2827</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">Escape</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">())</span> -</span><span id="L-2828"><a href="#L-2828"><span class="linenos">2828</span></a> -</span><span id="L-2829"><a href="#L-2829"><span class="linenos">2829</span></a> <span class="k">def</span> <span class="nf">_parse_interval</span><span class="p">(</span><span class="bp">self</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">Interval</span><span class="p">]:</span> -</span><span id="L-2830"><a href="#L-2830"><span class="linenos">2830</span></a> <span class="k">if</span> <span class="ow">not</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">INTERVAL</span><span class="p">):</span> -</span><span id="L-2831"><a href="#L-2831"><span class="linenos">2831</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2816"><a href="#L-2816"><span class="linenos">2816</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-2817"><a href="#L-2817"><span class="linenos">2817</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2818"><a href="#L-2818"><span class="linenos">2818</span></a> <span class="n">this</span> <span class="o">=</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">In</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">field</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">())</span> +</span><span id="L-2819"><a href="#L-2819"><span class="linenos">2819</span></a> +</span><span id="L-2820"><a href="#L-2820"><span class="linenos">2820</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-2821"><a href="#L-2821"><span class="linenos">2821</span></a> +</span><span id="L-2822"><a href="#L-2822"><span class="linenos">2822</span></a> <span class="k">def</span> <span class="nf">_parse_between</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">:</span> +</span><span id="L-2823"><a href="#L-2823"><span class="linenos">2823</span></a> <span class="n">low</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="L-2824"><a href="#L-2824"><span class="linenos">2824</span></a> <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">AND</span><span class="p">)</span> +</span><span id="L-2825"><a href="#L-2825"><span class="linenos">2825</span></a> <span class="n">high</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="L-2826"><a href="#L-2826"><span class="linenos">2826</span></a> <span class="k">return</span> <span class="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">Between</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">low</span><span class="o">=</span><span class="n">low</span><span class="p">,</span> <span class="n">high</span><span class="o">=</span><span class="n">high</span><span class="p">)</span> +</span><span id="L-2827"><a href="#L-2827"><span class="linenos">2827</span></a> +</span><span id="L-2828"><a href="#L-2828"><span class="linenos">2828</span></a> <span class="k">def</span> <span class="nf">_parse_escape</span><span class="p">(</span><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="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-2829"><a href="#L-2829"><span class="linenos">2829</span></a> <span class="k">if</span> <span class="ow">not</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">ESCAPE</span><span class="p">):</span> +</span><span id="L-2830"><a href="#L-2830"><span class="linenos">2830</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-2831"><a href="#L-2831"><span class="linenos">2831</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">Escape</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">())</span> </span><span id="L-2832"><a href="#L-2832"><span class="linenos">2832</span></a> -</span><span id="L-2833"><a href="#L-2833"><span class="linenos">2833</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> -</span><span id="L-2834"><a href="#L-2834"><span class="linenos">2834</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> -</span><span id="L-2835"><a href="#L-2835"><span class="linenos">2835</span></a> -</span><span id="L-2836"><a href="#L-2836"><span class="linenos">2836</span></a> <span class="c1"># Most dialects support, e.g., the form INTERVAL '5' day, thus we try to parse</span> -</span><span id="L-2837"><a href="#L-2837"><span class="linenos">2837</span></a> <span class="c1"># each INTERVAL expression into this canonical form so it's easy to transpile</span> -</span><span id="L-2838"><a href="#L-2838"><span class="linenos">2838</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_number</span><span class="p">:</span> -</span><span id="L-2839"><a href="#L-2839"><span class="linenos">2839</span></a> <span class="n">this</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="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> -</span><span id="L-2840"><a href="#L-2840"><span class="linenos">2840</span></a> <span class="k">elif</span> <span class="n">this</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> -</span><span id="L-2841"><a href="#L-2841"><span class="linenos">2841</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">split</span><span class="p">()</span> -</span><span id="L-2842"><a href="#L-2842"><span class="linenos">2842</span></a> -</span><span id="L-2843"><a href="#L-2843"><span class="linenos">2843</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">parts</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> -</span><span id="L-2844"><a href="#L-2844"><span class="linenos">2844</span></a> <span class="k">if</span> <span class="n">unit</span><span class="p">:</span> -</span><span id="L-2845"><a href="#L-2845"><span class="linenos">2845</span></a> <span class="c1"># this is not actually a unit, it's something else</span> -</span><span id="L-2846"><a href="#L-2846"><span class="linenos">2846</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2847"><a href="#L-2847"><span class="linenos">2847</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="L-2848"><a href="#L-2848"><span class="linenos">2848</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2849"><a href="#L-2849"><span class="linenos">2849</span></a> <span class="n">this</span> <span class="o">=</span> <span class="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">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> -</span><span id="L-2850"><a href="#L-2850"><span class="linenos">2850</span></a> <span class="n">unit</span> <span class="o">=</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">Var</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">parts</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> -</span><span id="L-2851"><a href="#L-2851"><span class="linenos">2851</span></a> -</span><span id="L-2852"><a href="#L-2852"><span class="linenos">2852</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">Interval</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">)</span> -</span><span id="L-2853"><a href="#L-2853"><span class="linenos">2853</span></a> -</span><span id="L-2854"><a href="#L-2854"><span class="linenos">2854</span></a> <span class="k">def</span> <span class="nf">_parse_bitwise</span><span class="p">(</span><span class="bp">self</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-2855"><a href="#L-2855"><span class="linenos">2855</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> -</span><span id="L-2856"><a href="#L-2856"><span class="linenos">2856</span></a> -</span><span id="L-2857"><a href="#L-2857"><span class="linenos">2857</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-2858"><a href="#L-2858"><span class="linenos">2858</span></a> <span class="k">if</span> <span class="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">BITWISE</span><span class="p">):</span> -</span><span id="L-2859"><a href="#L-2859"><span class="linenos">2859</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-2860"><a href="#L-2860"><span class="linenos">2860</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">BITWISE</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">],</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> -</span><span id="L-2861"><a href="#L-2861"><span class="linenos">2861</span></a> <span class="p">)</span> -</span><span id="L-2862"><a href="#L-2862"><span class="linenos">2862</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">LT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LT</span><span class="p">):</span> +</span><span id="L-2833"><a href="#L-2833"><span class="linenos">2833</span></a> <span class="k">def</span> <span class="nf">_parse_interval</span><span class="p">(</span><span class="bp">self</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">Interval</span><span class="p">]:</span> +</span><span id="L-2834"><a href="#L-2834"><span class="linenos">2834</span></a> <span class="k">if</span> <span class="ow">not</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">INTERVAL</span><span class="p">):</span> +</span><span id="L-2835"><a href="#L-2835"><span class="linenos">2835</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2836"><a href="#L-2836"><span class="linenos">2836</span></a> +</span><span id="L-2837"><a href="#L-2837"><span class="linenos">2837</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> +</span><span id="L-2838"><a href="#L-2838"><span class="linenos">2838</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> +</span><span id="L-2839"><a href="#L-2839"><span class="linenos">2839</span></a> +</span><span id="L-2840"><a href="#L-2840"><span class="linenos">2840</span></a> <span class="c1"># Most dialects support, e.g., the form INTERVAL '5' day, thus we try to parse</span> +</span><span id="L-2841"><a href="#L-2841"><span class="linenos">2841</span></a> <span class="c1"># each INTERVAL expression into this canonical form so it's easy to transpile</span> +</span><span id="L-2842"><a href="#L-2842"><span class="linenos">2842</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_number</span><span class="p">:</span> +</span><span id="L-2843"><a href="#L-2843"><span class="linenos">2843</span></a> <span class="n">this</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="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> +</span><span id="L-2844"><a href="#L-2844"><span class="linenos">2844</span></a> <span class="k">elif</span> <span class="n">this</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> +</span><span id="L-2845"><a href="#L-2845"><span class="linenos">2845</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">split</span><span class="p">()</span> +</span><span id="L-2846"><a href="#L-2846"><span class="linenos">2846</span></a> +</span><span id="L-2847"><a href="#L-2847"><span class="linenos">2847</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">parts</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> +</span><span id="L-2848"><a href="#L-2848"><span class="linenos">2848</span></a> <span class="k">if</span> <span class="n">unit</span><span class="p">:</span> +</span><span id="L-2849"><a href="#L-2849"><span class="linenos">2849</span></a> <span class="c1"># this is not actually a unit, it's something else</span> +</span><span id="L-2850"><a href="#L-2850"><span class="linenos">2850</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2851"><a href="#L-2851"><span class="linenos">2851</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="L-2852"><a href="#L-2852"><span class="linenos">2852</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2853"><a href="#L-2853"><span class="linenos">2853</span></a> <span class="n">this</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="n">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> +</span><span id="L-2854"><a href="#L-2854"><span class="linenos">2854</span></a> <span class="n">unit</span> <span class="o">=</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">Var</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">parts</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> +</span><span id="L-2855"><a href="#L-2855"><span class="linenos">2855</span></a> +</span><span id="L-2856"><a href="#L-2856"><span class="linenos">2856</span></a> <span class="k">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">Interval</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">)</span> +</span><span id="L-2857"><a href="#L-2857"><span class="linenos">2857</span></a> +</span><span id="L-2858"><a href="#L-2858"><span class="linenos">2858</span></a> <span class="k">def</span> <span class="nf">_parse_bitwise</span><span class="p">(</span><span class="bp">self</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-2859"><a href="#L-2859"><span class="linenos">2859</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> +</span><span id="L-2860"><a href="#L-2860"><span class="linenos">2860</span></a> +</span><span id="L-2861"><a href="#L-2861"><span class="linenos">2861</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-2862"><a href="#L-2862"><span class="linenos">2862</span></a> <span class="k">if</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">BITWISE</span><span class="p">):</span> </span><span id="L-2863"><a href="#L-2863"><span class="linenos">2863</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-2864"><a href="#L-2864"><span class="linenos">2864</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> +</span><span id="L-2864"><a href="#L-2864"><span class="linenos">2864</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">BITWISE</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">],</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> </span><span id="L-2865"><a href="#L-2865"><span class="linenos">2865</span></a> <span class="p">)</span> -</span><span id="L-2866"><a href="#L-2866"><span class="linenos">2866</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">GT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GT</span><span class="p">):</span> +</span><span id="L-2866"><a href="#L-2866"><span class="linenos">2866</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">LT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LT</span><span class="p">):</span> </span><span id="L-2867"><a href="#L-2867"><span class="linenos">2867</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-2868"><a href="#L-2868"><span class="linenos">2868</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> +</span><span id="L-2868"><a href="#L-2868"><span class="linenos">2868</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> </span><span id="L-2869"><a href="#L-2869"><span class="linenos">2869</span></a> <span class="p">)</span> -</span><span id="L-2870"><a href="#L-2870"><span class="linenos">2870</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2871"><a href="#L-2871"><span class="linenos">2871</span></a> <span class="k">break</span> -</span><span id="L-2872"><a href="#L-2872"><span class="linenos">2872</span></a> -</span><span id="L-2873"><a href="#L-2873"><span class="linenos">2873</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-2874"><a href="#L-2874"><span class="linenos">2874</span></a> -</span><span id="L-2875"><a href="#L-2875"><span class="linenos">2875</span></a> <span class="k">def</span> <span class="nf">_parse_term</span><span class="p">(</span><span class="bp">self</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-2876"><a href="#L-2876"><span class="linenos">2876</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_factor</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">TERM</span><span class="p">)</span> -</span><span id="L-2877"><a href="#L-2877"><span class="linenos">2877</span></a> -</span><span id="L-2878"><a href="#L-2878"><span class="linenos">2878</span></a> <span class="k">def</span> <span class="nf">_parse_factor</span><span class="p">(</span><span class="bp">self</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-2879"><a href="#L-2879"><span class="linenos">2879</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_unary</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">FACTOR</span><span class="p">)</span> -</span><span id="L-2880"><a href="#L-2880"><span class="linenos">2880</span></a> -</span><span id="L-2881"><a href="#L-2881"><span class="linenos">2881</span></a> <span class="k">def</span> <span class="nf">_parse_unary</span><span class="p">(</span><span class="bp">self</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-2882"><a href="#L-2882"><span class="linenos">2882</span></a> <span class="k">if</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">UNARY_PARSERS</span><span class="p">):</span> -</span><span id="L-2883"><a href="#L-2883"><span class="linenos">2883</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNARY_PARSERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> -</span><span id="L-2884"><a href="#L-2884"><span class="linenos">2884</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_at_time_zone</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">())</span> -</span><span id="L-2885"><a href="#L-2885"><span class="linenos">2885</span></a> -</span><span id="L-2886"><a href="#L-2886"><span class="linenos">2886</span></a> <span class="k">def</span> <span class="nf">_parse_type</span><span class="p">(</span><span class="bp">self</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-2887"><a href="#L-2887"><span class="linenos">2887</span></a> <span class="n">interval</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_interval</span><span class="p">()</span> -</span><span id="L-2888"><a href="#L-2888"><span class="linenos">2888</span></a> <span class="k">if</span> <span class="n">interval</span><span class="p">:</span> -</span><span id="L-2889"><a href="#L-2889"><span class="linenos">2889</span></a> <span class="k">return</span> <span class="n">interval</span> -</span><span id="L-2890"><a href="#L-2890"><span class="linenos">2890</span></a> -</span><span id="L-2891"><a href="#L-2891"><span class="linenos">2891</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="L-2892"><a href="#L-2892"><span class="linenos">2892</span></a> <span class="n">data_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2893"><a href="#L-2893"><span class="linenos">2893</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> +</span><span id="L-2870"><a href="#L-2870"><span class="linenos">2870</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">GT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GT</span><span class="p">):</span> +</span><span id="L-2871"><a href="#L-2871"><span class="linenos">2871</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-2872"><a href="#L-2872"><span class="linenos">2872</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> +</span><span id="L-2873"><a href="#L-2873"><span class="linenos">2873</span></a> <span class="p">)</span> +</span><span id="L-2874"><a href="#L-2874"><span class="linenos">2874</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2875"><a href="#L-2875"><span class="linenos">2875</span></a> <span class="k">break</span> +</span><span id="L-2876"><a href="#L-2876"><span class="linenos">2876</span></a> +</span><span id="L-2877"><a href="#L-2877"><span class="linenos">2877</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-2878"><a href="#L-2878"><span class="linenos">2878</span></a> +</span><span id="L-2879"><a href="#L-2879"><span class="linenos">2879</span></a> <span class="k">def</span> <span class="nf">_parse_term</span><span class="p">(</span><span class="bp">self</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-2880"><a href="#L-2880"><span class="linenos">2880</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_factor</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">TERM</span><span class="p">)</span> +</span><span id="L-2881"><a href="#L-2881"><span class="linenos">2881</span></a> +</span><span id="L-2882"><a href="#L-2882"><span class="linenos">2882</span></a> <span class="k">def</span> <span class="nf">_parse_factor</span><span class="p">(</span><span class="bp">self</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-2883"><a href="#L-2883"><span class="linenos">2883</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_unary</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">FACTOR</span><span class="p">)</span> +</span><span id="L-2884"><a href="#L-2884"><span class="linenos">2884</span></a> +</span><span id="L-2885"><a href="#L-2885"><span class="linenos">2885</span></a> <span class="k">def</span> <span class="nf">_parse_unary</span><span class="p">(</span><span class="bp">self</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-2886"><a href="#L-2886"><span class="linenos">2886</span></a> <span class="k">if</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">UNARY_PARSERS</span><span class="p">):</span> +</span><span id="L-2887"><a href="#L-2887"><span class="linenos">2887</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNARY_PARSERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> +</span><span id="L-2888"><a href="#L-2888"><span class="linenos">2888</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_at_time_zone</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">())</span> +</span><span id="L-2889"><a href="#L-2889"><span class="linenos">2889</span></a> +</span><span id="L-2890"><a href="#L-2890"><span class="linenos">2890</span></a> <span class="k">def</span> <span class="nf">_parse_type</span><span class="p">(</span><span class="bp">self</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-2891"><a href="#L-2891"><span class="linenos">2891</span></a> <span class="n">interval</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_interval</span><span class="p">()</span> +</span><span id="L-2892"><a href="#L-2892"><span class="linenos">2892</span></a> <span class="k">if</span> <span class="n">interval</span><span class="p">:</span> +</span><span id="L-2893"><a href="#L-2893"><span class="linenos">2893</span></a> <span class="k">return</span> <span class="n">interval</span> </span><span id="L-2894"><a href="#L-2894"><span class="linenos">2894</span></a> -</span><span id="L-2895"><a href="#L-2895"><span class="linenos">2895</span></a> <span class="k">if</span> <span class="n">data_type</span><span class="p">:</span> -</span><span id="L-2896"><a href="#L-2896"><span class="linenos">2896</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">Literal</span><span class="p">):</span> -</span><span id="L-2897"><a href="#L-2897"><span class="linenos">2897</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TYPE_LITERAL_PARSERS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">data_type</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-2898"><a href="#L-2898"><span class="linenos">2898</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> -</span><span id="L-2899"><a href="#L-2899"><span class="linenos">2899</span></a> <span class="k">return</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">data_type</span><span class="p">)</span> -</span><span id="L-2900"><a href="#L-2900"><span class="linenos">2900</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">Cast</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="n">data_type</span><span class="p">)</span> -</span><span id="L-2901"><a href="#L-2901"><span class="linenos">2901</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">data_type</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="L-2902"><a href="#L-2902"><span class="linenos">2902</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-2903"><a href="#L-2903"><span class="linenos">2903</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> -</span><span id="L-2904"><a href="#L-2904"><span class="linenos">2904</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_ops</span><span class="p">(</span><span class="n">data_type</span><span class="p">)</span> -</span><span id="L-2905"><a href="#L-2905"><span class="linenos">2905</span></a> -</span><span id="L-2906"><a href="#L-2906"><span class="linenos">2906</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-2907"><a href="#L-2907"><span class="linenos">2907</span></a> -</span><span id="L-2908"><a href="#L-2908"><span class="linenos">2908</span></a> <span class="k">def</span> <span class="nf">_parse_type_size</span><span class="p">(</span><span class="bp">self</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">DataTypeSize</span><span class="p">]:</span> -</span><span id="L-2909"><a href="#L-2909"><span class="linenos">2909</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">()</span> -</span><span id="L-2910"><a href="#L-2910"><span class="linenos">2910</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> -</span><span id="L-2911"><a href="#L-2911"><span class="linenos">2911</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-2912"><a href="#L-2912"><span class="linenos">2912</span></a> -</span><span id="L-2913"><a href="#L-2913"><span class="linenos">2913</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><span id="L-2914"><a href="#L-2914"><span class="linenos">2914</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataTypeSize</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2915"><a href="#L-2915"><span class="linenos">2915</span></a> <span class="p">)</span> +</span><span id="L-2895"><a href="#L-2895"><span class="linenos">2895</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="L-2896"><a href="#L-2896"><span class="linenos">2896</span></a> <span class="n">data_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-2897"><a href="#L-2897"><span class="linenos">2897</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> +</span><span id="L-2898"><a href="#L-2898"><span class="linenos">2898</span></a> +</span><span id="L-2899"><a href="#L-2899"><span class="linenos">2899</span></a> <span class="k">if</span> <span class="n">data_type</span><span class="p">:</span> +</span><span id="L-2900"><a href="#L-2900"><span class="linenos">2900</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">Literal</span><span class="p">):</span> +</span><span id="L-2901"><a href="#L-2901"><span class="linenos">2901</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TYPE_LITERAL_PARSERS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">data_type</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-2902"><a href="#L-2902"><span class="linenos">2902</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> +</span><span id="L-2903"><a href="#L-2903"><span class="linenos">2903</span></a> <span class="k">return</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">data_type</span><span class="p">)</span> +</span><span id="L-2904"><a href="#L-2904"><span class="linenos">2904</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="n">data_type</span><span class="p">)</span> +</span><span id="L-2905"><a href="#L-2905"><span class="linenos">2905</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">data_type</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="L-2906"><a href="#L-2906"><span class="linenos">2906</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-2907"><a href="#L-2907"><span class="linenos">2907</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> +</span><span id="L-2908"><a href="#L-2908"><span class="linenos">2908</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_ops</span><span class="p">(</span><span class="n">data_type</span><span class="p">)</span> +</span><span id="L-2909"><a href="#L-2909"><span class="linenos">2909</span></a> +</span><span id="L-2910"><a href="#L-2910"><span class="linenos">2910</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-2911"><a href="#L-2911"><span class="linenos">2911</span></a> +</span><span id="L-2912"><a href="#L-2912"><span class="linenos">2912</span></a> <span class="k">def</span> <span class="nf">_parse_type_size</span><span class="p">(</span><span class="bp">self</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">DataTypeSize</span><span class="p">]:</span> +</span><span id="L-2913"><a href="#L-2913"><span class="linenos">2913</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">()</span> +</span><span id="L-2914"><a href="#L-2914"><span class="linenos">2914</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> +</span><span id="L-2915"><a href="#L-2915"><span class="linenos">2915</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="L-2916"><a href="#L-2916"><span class="linenos">2916</span></a> -</span><span id="L-2917"><a href="#L-2917"><span class="linenos">2917</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span> -</span><span id="L-2918"><a href="#L-2918"><span class="linenos">2918</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</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="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-2919"><a href="#L-2919"><span class="linenos">2919</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-2920"><a href="#L-2920"><span class="linenos">2920</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="L-2921"><a href="#L-2921"><span class="linenos">2921</span></a> -</span><span id="L-2922"><a href="#L-2922"><span class="linenos">2922</span></a> <span class="n">prefix</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SYSUDTLIB"</span><span class="p">,</span> <span class="s2">"."</span><span class="p">)</span> -</span><span id="L-2923"><a href="#L-2923"><span class="linenos">2923</span></a> -</span><span id="L-2924"><a href="#L-2924"><span class="linenos">2924</span></a> <span class="k">if</span> <span class="ow">not</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">TYPE_TOKENS</span><span class="p">):</span> -</span><span id="L-2925"><a href="#L-2925"><span class="linenos">2925</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-2926"><a href="#L-2926"><span class="linenos">2926</span></a> -</span><span id="L-2927"><a href="#L-2927"><span class="linenos">2927</span></a> <span class="n">type_token</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">token_type</span> -</span><span id="L-2928"><a href="#L-2928"><span class="linenos">2928</span></a> -</span><span id="L-2929"><a href="#L-2929"><span class="linenos">2929</span></a> <span class="k">if</span> <span class="n">type_token</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PSEUDO_TYPE</span><span class="p">:</span> -</span><span id="L-2930"><a href="#L-2930"><span class="linenos">2930</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">PseudoType</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-2931"><a href="#L-2931"><span class="linenos">2931</span></a> -</span><span id="L-2932"><a href="#L-2932"><span class="linenos">2932</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="n">type_token</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">NESTED_TYPE_TOKENS</span> -</span><span id="L-2933"><a href="#L-2933"><span class="linenos">2933</span></a> <span class="n">is_struct</span> <span class="o">=</span> <span class="n">type_token</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span> -</span><span id="L-2934"><a href="#L-2934"><span class="linenos">2934</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2935"><a href="#L-2935"><span class="linenos">2935</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-2936"><a href="#L-2936"><span class="linenos">2936</span></a> -</span><span id="L-2937"><a href="#L-2937"><span class="linenos">2937</span></a> <span class="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_PAREN</span><span class="p">):</span> -</span><span id="L-2938"><a href="#L-2938"><span class="linenos">2938</span></a> <span class="k">if</span> <span class="n">is_struct</span><span class="p">:</span> -</span><span id="L-2939"><a href="#L-2939"><span class="linenos">2939</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_struct_types</span><span class="p">)</span> -</span><span id="L-2940"><a href="#L-2940"><span class="linenos">2940</span></a> <span class="k">elif</span> <span class="n">nested</span><span class="p">:</span> -</span><span id="L-2941"><a href="#L-2941"><span class="linenos">2941</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> -</span><span id="L-2942"><a href="#L-2942"><span class="linenos">2942</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="L-2943"><a href="#L-2943"><span class="linenos">2943</span></a> <span class="p">)</span> -</span><span id="L-2944"><a href="#L-2944"><span class="linenos">2944</span></a> <span class="k">elif</span> <span class="n">type_token</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">ENUM_TYPE_TOKENS</span><span class="p">:</span> -</span><span id="L-2945"><a href="#L-2945"><span class="linenos">2945</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">)</span> -</span><span id="L-2946"><a href="#L-2946"><span class="linenos">2946</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2947"><a href="#L-2947"><span class="linenos">2947</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_type_size</span><span class="p">)</span> -</span><span id="L-2948"><a href="#L-2948"><span class="linenos">2948</span></a> -</span><span id="L-2949"><a href="#L-2949"><span class="linenos">2949</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span> <span class="ow">or</span> <span class="ow">not</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">R_PAREN</span><span class="p">):</span> -</span><span id="L-2950"><a href="#L-2950"><span class="linenos">2950</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-2951"><a href="#L-2951"><span class="linenos">2951</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2917"><a href="#L-2917"><span class="linenos">2917</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><span id="L-2918"><a href="#L-2918"><span class="linenos">2918</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataTypeSize</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-2919"><a href="#L-2919"><span class="linenos">2919</span></a> <span class="p">)</span> +</span><span id="L-2920"><a href="#L-2920"><span class="linenos">2920</span></a> +</span><span id="L-2921"><a href="#L-2921"><span class="linenos">2921</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span> +</span><span id="L-2922"><a href="#L-2922"><span class="linenos">2922</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</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="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-2923"><a href="#L-2923"><span class="linenos">2923</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-2924"><a href="#L-2924"><span class="linenos">2924</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="L-2925"><a href="#L-2925"><span class="linenos">2925</span></a> +</span><span id="L-2926"><a href="#L-2926"><span class="linenos">2926</span></a> <span class="n">prefix</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SYSUDTLIB"</span><span class="p">,</span> <span class="s2">"."</span><span class="p">)</span> +</span><span id="L-2927"><a href="#L-2927"><span class="linenos">2927</span></a> +</span><span id="L-2928"><a href="#L-2928"><span class="linenos">2928</span></a> <span class="k">if</span> <span class="ow">not</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">TYPE_TOKENS</span><span class="p">):</span> +</span><span id="L-2929"><a href="#L-2929"><span class="linenos">2929</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2930"><a href="#L-2930"><span class="linenos">2930</span></a> +</span><span id="L-2931"><a href="#L-2931"><span class="linenos">2931</span></a> <span class="n">type_token</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">token_type</span> +</span><span id="L-2932"><a href="#L-2932"><span class="linenos">2932</span></a> +</span><span id="L-2933"><a href="#L-2933"><span class="linenos">2933</span></a> <span class="k">if</span> <span class="n">type_token</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PSEUDO_TYPE</span><span class="p">:</span> +</span><span id="L-2934"><a href="#L-2934"><span class="linenos">2934</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">PseudoType</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-2935"><a href="#L-2935"><span class="linenos">2935</span></a> +</span><span id="L-2936"><a href="#L-2936"><span class="linenos">2936</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="n">type_token</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">NESTED_TYPE_TOKENS</span> +</span><span id="L-2937"><a href="#L-2937"><span class="linenos">2937</span></a> <span class="n">is_struct</span> <span class="o">=</span> <span class="n">type_token</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span> +</span><span id="L-2938"><a href="#L-2938"><span class="linenos">2938</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2939"><a href="#L-2939"><span class="linenos">2939</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-2940"><a href="#L-2940"><span class="linenos">2940</span></a> +</span><span id="L-2941"><a href="#L-2941"><span class="linenos">2941</span></a> <span class="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_PAREN</span><span class="p">):</span> +</span><span id="L-2942"><a href="#L-2942"><span class="linenos">2942</span></a> <span class="k">if</span> <span class="n">is_struct</span><span class="p">:</span> +</span><span id="L-2943"><a href="#L-2943"><span class="linenos">2943</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_struct_types</span><span class="p">)</span> +</span><span id="L-2944"><a href="#L-2944"><span class="linenos">2944</span></a> <span class="k">elif</span> <span class="n">nested</span><span class="p">:</span> +</span><span id="L-2945"><a href="#L-2945"><span class="linenos">2945</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> +</span><span id="L-2946"><a href="#L-2946"><span class="linenos">2946</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="L-2947"><a href="#L-2947"><span class="linenos">2947</span></a> <span class="p">)</span> +</span><span id="L-2948"><a href="#L-2948"><span class="linenos">2948</span></a> <span class="k">elif</span> <span class="n">type_token</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">ENUM_TYPE_TOKENS</span><span class="p">:</span> +</span><span id="L-2949"><a href="#L-2949"><span class="linenos">2949</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">)</span> +</span><span id="L-2950"><a href="#L-2950"><span class="linenos">2950</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2951"><a href="#L-2951"><span class="linenos">2951</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_type_size</span><span class="p">)</span> </span><span id="L-2952"><a href="#L-2952"><span class="linenos">2952</span></a> -</span><span id="L-2953"><a href="#L-2953"><span class="linenos">2953</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-2954"><a href="#L-2954"><span class="linenos">2954</span></a> -</span><span id="L-2955"><a href="#L-2955"><span class="linenos">2955</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACKET</span><span class="p">):</span> -</span><span id="L-2956"><a href="#L-2956"><span class="linenos">2956</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span> -</span><span id="L-2957"><a href="#L-2957"><span class="linenos">2957</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span><span class="p">,</span> -</span><span id="L-2958"><a href="#L-2958"><span class="linenos">2958</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">build</span><span class="p">(</span><span class="n">type_token</span><span class="o">.</span><span class="n">value</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)],</span> -</span><span id="L-2959"><a href="#L-2959"><span class="linenos">2959</span></a> <span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> -</span><span id="L-2960"><a href="#L-2960"><span class="linenos">2960</span></a> <span class="p">)</span> -</span><span id="L-2961"><a href="#L-2961"><span class="linenos">2961</span></a> -</span><span id="L-2962"><a href="#L-2962"><span class="linenos">2962</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACKET</span><span class="p">):</span> -</span><span id="L-2963"><a href="#L-2963"><span class="linenos">2963</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">this</span><span class="p">],</span> <span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2964"><a href="#L-2964"><span class="linenos">2964</span></a> -</span><span id="L-2965"><a href="#L-2965"><span class="linenos">2965</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-2966"><a href="#L-2966"><span class="linenos">2966</span></a> -</span><span id="L-2967"><a href="#L-2967"><span class="linenos">2967</span></a> <span class="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_BRACKET</span><span class="p">):</span> -</span><span id="L-2968"><a href="#L-2968"><span class="linenos">2968</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-2969"><a href="#L-2969"><span class="linenos">2969</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2953"><a href="#L-2953"><span class="linenos">2953</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span> <span class="ow">or</span> <span class="ow">not</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">R_PAREN</span><span class="p">):</span> +</span><span id="L-2954"><a href="#L-2954"><span class="linenos">2954</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-2955"><a href="#L-2955"><span class="linenos">2955</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2956"><a href="#L-2956"><span class="linenos">2956</span></a> +</span><span id="L-2957"><a href="#L-2957"><span class="linenos">2957</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-2958"><a href="#L-2958"><span class="linenos">2958</span></a> +</span><span id="L-2959"><a href="#L-2959"><span class="linenos">2959</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACKET</span><span class="p">):</span> +</span><span id="L-2960"><a href="#L-2960"><span class="linenos">2960</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span> +</span><span id="L-2961"><a href="#L-2961"><span class="linenos">2961</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span><span class="p">,</span> +</span><span id="L-2962"><a href="#L-2962"><span class="linenos">2962</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">build</span><span class="p">(</span><span class="n">type_token</span><span class="o">.</span><span class="n">value</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)],</span> +</span><span id="L-2963"><a href="#L-2963"><span class="linenos">2963</span></a> <span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> +</span><span id="L-2964"><a href="#L-2964"><span class="linenos">2964</span></a> <span class="p">)</span> +</span><span id="L-2965"><a href="#L-2965"><span class="linenos">2965</span></a> +</span><span id="L-2966"><a href="#L-2966"><span class="linenos">2966</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACKET</span><span class="p">):</span> +</span><span id="L-2967"><a href="#L-2967"><span class="linenos">2967</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">this</span><span class="p">],</span> <span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-2968"><a href="#L-2968"><span class="linenos">2968</span></a> +</span><span id="L-2969"><a href="#L-2969"><span class="linenos">2969</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="L-2970"><a href="#L-2970"><span class="linenos">2970</span></a> -</span><span id="L-2971"><a href="#L-2971"><span class="linenos">2971</span></a> <span class="n">values</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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-2972"><a href="#L-2972"><span class="linenos">2972</span></a> <span class="k">if</span> <span class="n">nested</span> <span class="ow">and</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">LT</span><span class="p">):</span> -</span><span id="L-2973"><a href="#L-2973"><span class="linenos">2973</span></a> <span class="k">if</span> <span class="n">is_struct</span><span class="p">:</span> -</span><span id="L-2974"><a href="#L-2974"><span class="linenos">2974</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_struct_types</span><span class="p">)</span> -</span><span id="L-2975"><a href="#L-2975"><span class="linenos">2975</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2976"><a href="#L-2976"><span class="linenos">2976</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> -</span><span id="L-2977"><a href="#L-2977"><span class="linenos">2977</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="L-2978"><a href="#L-2978"><span class="linenos">2978</span></a> <span class="p">)</span> -</span><span id="L-2979"><a href="#L-2979"><span class="linenos">2979</span></a> -</span><span id="L-2980"><a href="#L-2980"><span class="linenos">2980</span></a> <span class="k">if</span> <span class="ow">not</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">GT</span><span class="p">):</span> -</span><span id="L-2981"><a href="#L-2981"><span class="linenos">2981</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting >"</span><span class="p">)</span> -</span><span id="L-2982"><a href="#L-2982"><span class="linenos">2982</span></a> -</span><span id="L-2983"><a href="#L-2983"><span class="linenos">2983</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">)):</span> -</span><span id="L-2984"><a href="#L-2984"><span class="linenos">2984</span></a> <span class="n">values</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="L-2985"><a href="#L-2985"><span class="linenos">2985</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACKET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_PAREN</span><span class="p">))</span> +</span><span id="L-2971"><a href="#L-2971"><span class="linenos">2971</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_BRACKET</span><span class="p">):</span> +</span><span id="L-2972"><a href="#L-2972"><span class="linenos">2972</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-2973"><a href="#L-2973"><span class="linenos">2973</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-2974"><a href="#L-2974"><span class="linenos">2974</span></a> +</span><span id="L-2975"><a href="#L-2975"><span class="linenos">2975</span></a> <span class="n">values</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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-2976"><a href="#L-2976"><span class="linenos">2976</span></a> <span class="k">if</span> <span class="n">nested</span> <span class="ow">and</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">LT</span><span class="p">):</span> +</span><span id="L-2977"><a href="#L-2977"><span class="linenos">2977</span></a> <span class="k">if</span> <span class="n">is_struct</span><span class="p">:</span> +</span><span id="L-2978"><a href="#L-2978"><span class="linenos">2978</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_struct_types</span><span class="p">)</span> +</span><span id="L-2979"><a href="#L-2979"><span class="linenos">2979</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2980"><a href="#L-2980"><span class="linenos">2980</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> +</span><span id="L-2981"><a href="#L-2981"><span class="linenos">2981</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="L-2982"><a href="#L-2982"><span class="linenos">2982</span></a> <span class="p">)</span> +</span><span id="L-2983"><a href="#L-2983"><span class="linenos">2983</span></a> +</span><span id="L-2984"><a href="#L-2984"><span class="linenos">2984</span></a> <span class="k">if</span> <span class="ow">not</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">GT</span><span class="p">):</span> +</span><span id="L-2985"><a href="#L-2985"><span class="linenos">2985</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting >"</span><span class="p">)</span> </span><span id="L-2986"><a href="#L-2986"><span class="linenos">2986</span></a> -</span><span id="L-2987"><a href="#L-2987"><span class="linenos">2987</span></a> <span class="n">value</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-2988"><a href="#L-2988"><span class="linenos">2988</span></a> <span class="k">if</span> <span class="n">type_token</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIMESTAMPS</span><span class="p">:</span> -</span><span id="L-2989"><a href="#L-2989"><span class="linenos">2989</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ZONE"</span><span class="p">):</span> -</span><span id="L-2990"><a href="#L-2990"><span class="linenos">2990</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-2991"><a href="#L-2991"><span class="linenos">2991</span></a> <span class="n">value</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-2992"><a href="#L-2992"><span class="linenos">2992</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"LOCAL"</span><span class="p">,</span> <span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ZONE"</span><span class="p">):</span> -</span><span id="L-2993"><a href="#L-2993"><span class="linenos">2993</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-2994"><a href="#L-2994"><span class="linenos">2994</span></a> <span class="n">value</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-2995"><a href="#L-2995"><span class="linenos">2995</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITHOUT"</span><span class="p">,</span> <span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ZONE"</span><span class="p">):</span> -</span><span id="L-2996"><a href="#L-2996"><span class="linenos">2996</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-2997"><a href="#L-2997"><span class="linenos">2997</span></a> <span class="k">elif</span> <span class="n">type_token</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INTERVAL</span><span class="p">:</span> -</span><span id="L-2998"><a href="#L-2998"><span class="linenos">2998</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> -</span><span id="L-2999"><a href="#L-2999"><span class="linenos">2999</span></a> -</span><span id="L-3000"><a href="#L-3000"><span class="linenos">3000</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">unit</span><span class="p">:</span> -</span><span id="L-3001"><a href="#L-3001"><span class="linenos">3001</span></a> <span class="n">value</span> <span class="o">=</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">DataType</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INTERVAL</span><span class="p">)</span> -</span><span id="L-3002"><a href="#L-3002"><span class="linenos">3002</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3003"><a href="#L-3003"><span class="linenos">3003</span></a> <span class="n">value</span> <span class="o">=</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">Interval</span><span class="p">,</span> <span class="n">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">)</span> -</span><span id="L-3004"><a href="#L-3004"><span class="linenos">3004</span></a> -</span><span id="L-3005"><a href="#L-3005"><span class="linenos">3005</span></a> <span class="k">if</span> <span class="n">maybe_func</span> <span class="ow">and</span> <span class="n">check_func</span><span class="p">:</span> -</span><span id="L-3006"><a href="#L-3006"><span class="linenos">3006</span></a> <span class="n">index2</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="L-3007"><a href="#L-3007"><span class="linenos">3007</span></a> <span class="n">peek</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="L-2987"><a href="#L-2987"><span class="linenos">2987</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">)):</span> +</span><span id="L-2988"><a href="#L-2988"><span class="linenos">2988</span></a> <span class="n">values</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="L-2989"><a href="#L-2989"><span class="linenos">2989</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACKET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_PAREN</span><span class="p">))</span> +</span><span id="L-2990"><a href="#L-2990"><span class="linenos">2990</span></a> +</span><span id="L-2991"><a href="#L-2991"><span class="linenos">2991</span></a> <span class="n">value</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-2992"><a href="#L-2992"><span class="linenos">2992</span></a> <span class="k">if</span> <span class="n">type_token</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIMESTAMPS</span><span class="p">:</span> +</span><span id="L-2993"><a href="#L-2993"><span class="linenos">2993</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ZONE"</span><span class="p">):</span> +</span><span id="L-2994"><a href="#L-2994"><span class="linenos">2994</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-2995"><a href="#L-2995"><span class="linenos">2995</span></a> <span class="n">value</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-2996"><a href="#L-2996"><span class="linenos">2996</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"LOCAL"</span><span class="p">,</span> <span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ZONE"</span><span class="p">):</span> +</span><span id="L-2997"><a href="#L-2997"><span class="linenos">2997</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-2998"><a href="#L-2998"><span class="linenos">2998</span></a> <span class="n">value</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-2999"><a href="#L-2999"><span class="linenos">2999</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITHOUT"</span><span class="p">,</span> <span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ZONE"</span><span class="p">):</span> +</span><span id="L-3000"><a href="#L-3000"><span class="linenos">3000</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-3001"><a href="#L-3001"><span class="linenos">3001</span></a> <span class="k">elif</span> <span class="n">type_token</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INTERVAL</span><span class="p">:</span> +</span><span id="L-3002"><a href="#L-3002"><span class="linenos">3002</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> +</span><span id="L-3003"><a href="#L-3003"><span class="linenos">3003</span></a> +</span><span id="L-3004"><a href="#L-3004"><span class="linenos">3004</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">unit</span><span class="p">:</span> +</span><span id="L-3005"><a href="#L-3005"><span class="linenos">3005</span></a> <span class="n">value</span> <span class="o">=</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">DataType</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INTERVAL</span><span class="p">)</span> +</span><span id="L-3006"><a href="#L-3006"><span class="linenos">3006</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3007"><a href="#L-3007"><span class="linenos">3007</span></a> <span class="n">value</span> <span class="o">=</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">Interval</span><span class="p">,</span> <span class="n">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">)</span> </span><span id="L-3008"><a href="#L-3008"><span class="linenos">3008</span></a> -</span><span id="L-3009"><a href="#L-3009"><span class="linenos">3009</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">peek</span><span class="p">:</span> -</span><span id="L-3010"><a href="#L-3010"><span class="linenos">3010</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-3011"><a href="#L-3011"><span class="linenos">3011</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-3009"><a href="#L-3009"><span class="linenos">3009</span></a> <span class="k">if</span> <span class="n">maybe_func</span> <span class="ow">and</span> <span class="n">check_func</span><span class="p">:</span> +</span><span id="L-3010"><a href="#L-3010"><span class="linenos">3010</span></a> <span class="n">index2</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="L-3011"><a href="#L-3011"><span class="linenos">3011</span></a> <span class="n">peek</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> </span><span id="L-3012"><a href="#L-3012"><span class="linenos">3012</span></a> -</span><span id="L-3013"><a href="#L-3013"><span class="linenos">3013</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index2</span><span class="p">)</span> -</span><span id="L-3014"><a href="#L-3014"><span class="linenos">3014</span></a> -</span><span id="L-3015"><a href="#L-3015"><span class="linenos">3015</span></a> <span class="k">if</span> <span class="n">value</span><span class="p">:</span> -</span><span id="L-3016"><a href="#L-3016"><span class="linenos">3016</span></a> <span class="k">return</span> <span class="n">value</span> -</span><span id="L-3017"><a href="#L-3017"><span class="linenos">3017</span></a> -</span><span id="L-3018"><a href="#L-3018"><span class="linenos">3018</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span> -</span><span id="L-3019"><a href="#L-3019"><span class="linenos">3019</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">type_token</span><span class="o">.</span><span class="n">value</span><span class="o">.</span><span class="n">upper</span><span class="p">()],</span> -</span><span id="L-3020"><a href="#L-3020"><span class="linenos">3020</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-3021"><a href="#L-3021"><span class="linenos">3021</span></a> <span class="n">nested</span><span class="o">=</span><span class="n">nested</span><span class="p">,</span> -</span><span id="L-3022"><a href="#L-3022"><span class="linenos">3022</span></a> <span class="n">values</span><span class="o">=</span><span class="n">values</span><span class="p">,</span> -</span><span id="L-3023"><a href="#L-3023"><span class="linenos">3023</span></a> <span class="n">prefix</span><span class="o">=</span><span class="n">prefix</span><span class="p">,</span> -</span><span id="L-3024"><a href="#L-3024"><span class="linenos">3024</span></a> <span class="p">)</span> -</span><span id="L-3025"><a href="#L-3025"><span class="linenos">3025</span></a> -</span><span id="L-3026"><a href="#L-3026"><span class="linenos">3026</span></a> <span class="k">def</span> <span class="nf">_parse_struct_types</span><span class="p">(</span><span class="bp">self</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-3027"><a href="#L-3027"><span class="linenos">3027</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="L-3028"><a href="#L-3028"><span class="linenos">3028</span></a> <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">COLON</span><span class="p">)</span> -</span><span id="L-3029"><a href="#L-3029"><span class="linenos">3029</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_def</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-3030"><a href="#L-3030"><span class="linenos">3030</span></a> -</span><span id="L-3031"><a href="#L-3031"><span class="linenos">3031</span></a> <span class="k">def</span> <span class="nf">_parse_at_time_zone</span><span class="p">(</span><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="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-3032"><a href="#L-3032"><span class="linenos">3032</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AT"</span><span class="p">,</span> <span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ZONE"</span><span class="p">):</span> -</span><span id="L-3033"><a href="#L-3033"><span class="linenos">3033</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-3034"><a href="#L-3034"><span class="linenos">3034</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">AtTimeZone</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">zone</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_unary</span><span class="p">())</span> -</span><span id="L-3035"><a href="#L-3035"><span class="linenos">3035</span></a> -</span><span id="L-3036"><a href="#L-3036"><span class="linenos">3036</span></a> <span class="k">def</span> <span class="nf">_parse_column</span><span class="p">(</span><span class="bp">self</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-3037"><a href="#L-3037"><span class="linenos">3037</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> -</span><span id="L-3038"><a href="#L-3038"><span class="linenos">3038</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">Identifier</span><span class="p">):</span> -</span><span id="L-3039"><a href="#L-3039"><span class="linenos">3039</span></a> <span class="n">this</span> <span class="o">=</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">Column</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-3040"><a href="#L-3040"><span class="linenos">3040</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> -</span><span id="L-3041"><a href="#L-3041"><span class="linenos">3041</span></a> <span class="k">return</span> <span class="bp">self</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-3042"><a href="#L-3042"><span class="linenos">3042</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_ops</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-3043"><a href="#L-3043"><span class="linenos">3043</span></a> -</span><span id="L-3044"><a href="#L-3044"><span class="linenos">3044</span></a> <span class="k">def</span> <span class="nf">_parse_column_ops</span><span class="p">(</span><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="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-3045"><a href="#L-3045"><span class="linenos">3045</span></a> <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 class="n">this</span><span class="p">)</span> -</span><span id="L-3046"><a href="#L-3046"><span class="linenos">3046</span></a> -</span><span id="L-3047"><a href="#L-3047"><span class="linenos">3047</span></a> <span class="k">while</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">COLUMN_OPERATORS</span><span class="p">):</span> -</span><span id="L-3048"><a href="#L-3048"><span class="linenos">3048</span></a> <span class="n">op_token</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">token_type</span> -</span><span id="L-3049"><a href="#L-3049"><span class="linenos">3049</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">COLUMN_OPERATORS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">op_token</span><span class="p">)</span> +</span><span id="L-3013"><a href="#L-3013"><span class="linenos">3013</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">peek</span><span class="p">:</span> +</span><span id="L-3014"><a href="#L-3014"><span class="linenos">3014</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-3015"><a href="#L-3015"><span class="linenos">3015</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-3016"><a href="#L-3016"><span class="linenos">3016</span></a> +</span><span id="L-3017"><a href="#L-3017"><span class="linenos">3017</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index2</span><span class="p">)</span> +</span><span id="L-3018"><a href="#L-3018"><span class="linenos">3018</span></a> +</span><span id="L-3019"><a href="#L-3019"><span class="linenos">3019</span></a> <span class="k">if</span> <span class="n">value</span><span class="p">:</span> +</span><span id="L-3020"><a href="#L-3020"><span class="linenos">3020</span></a> <span class="k">return</span> <span class="n">value</span> +</span><span id="L-3021"><a href="#L-3021"><span class="linenos">3021</span></a> +</span><span id="L-3022"><a href="#L-3022"><span class="linenos">3022</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span> +</span><span id="L-3023"><a href="#L-3023"><span class="linenos">3023</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">type_token</span><span class="o">.</span><span class="n">value</span><span class="o">.</span><span class="n">upper</span><span class="p">()],</span> +</span><span id="L-3024"><a href="#L-3024"><span class="linenos">3024</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-3025"><a href="#L-3025"><span class="linenos">3025</span></a> <span class="n">nested</span><span class="o">=</span><span class="n">nested</span><span class="p">,</span> +</span><span id="L-3026"><a href="#L-3026"><span class="linenos">3026</span></a> <span class="n">values</span><span class="o">=</span><span class="n">values</span><span class="p">,</span> +</span><span id="L-3027"><a href="#L-3027"><span class="linenos">3027</span></a> <span class="n">prefix</span><span class="o">=</span><span class="n">prefix</span><span class="p">,</span> +</span><span id="L-3028"><a href="#L-3028"><span class="linenos">3028</span></a> <span class="p">)</span> +</span><span id="L-3029"><a href="#L-3029"><span class="linenos">3029</span></a> +</span><span id="L-3030"><a href="#L-3030"><span class="linenos">3030</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="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-3031"><a href="#L-3031"><span class="linenos">3031</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="L-3032"><a href="#L-3032"><span class="linenos">3032</span></a> <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">COLON</span><span class="p">)</span> +</span><span id="L-3033"><a href="#L-3033"><span class="linenos">3033</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_def</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-3034"><a href="#L-3034"><span class="linenos">3034</span></a> +</span><span id="L-3035"><a href="#L-3035"><span class="linenos">3035</span></a> <span class="k">def</span> <span class="nf">_parse_at_time_zone</span><span class="p">(</span><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="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-3036"><a href="#L-3036"><span class="linenos">3036</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AT"</span><span class="p">,</span> <span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ZONE"</span><span class="p">):</span> +</span><span id="L-3037"><a href="#L-3037"><span class="linenos">3037</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-3038"><a href="#L-3038"><span class="linenos">3038</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">AtTimeZone</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">zone</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_unary</span><span class="p">())</span> +</span><span id="L-3039"><a href="#L-3039"><span class="linenos">3039</span></a> +</span><span id="L-3040"><a href="#L-3040"><span class="linenos">3040</span></a> <span class="k">def</span> <span class="nf">_parse_column</span><span class="p">(</span><span class="bp">self</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-3041"><a href="#L-3041"><span class="linenos">3041</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> +</span><span id="L-3042"><a href="#L-3042"><span class="linenos">3042</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">Identifier</span><span class="p">):</span> +</span><span id="L-3043"><a href="#L-3043"><span class="linenos">3043</span></a> <span class="n">this</span> <span class="o">=</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">Column</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-3044"><a href="#L-3044"><span class="linenos">3044</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> +</span><span id="L-3045"><a href="#L-3045"><span class="linenos">3045</span></a> <span class="k">return</span> <span class="bp">self</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-3046"><a href="#L-3046"><span class="linenos">3046</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_ops</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-3047"><a href="#L-3047"><span class="linenos">3047</span></a> +</span><span id="L-3048"><a href="#L-3048"><span class="linenos">3048</span></a> <span class="k">def</span> <span class="nf">_parse_column_ops</span><span class="p">(</span><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="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-3049"><a href="#L-3049"><span class="linenos">3049</span></a> <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 class="n">this</span><span class="p">)</span> </span><span id="L-3050"><a href="#L-3050"><span class="linenos">3050</span></a> -</span><span id="L-3051"><a href="#L-3051"><span class="linenos">3051</span></a> <span class="k">if</span> <span class="n">op_token</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DCOLON</span><span class="p">:</span> -</span><span id="L-3052"><a href="#L-3052"><span class="linenos">3052</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">()</span> -</span><span id="L-3053"><a href="#L-3053"><span class="linenos">3053</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">field</span><span class="p">:</span> -</span><span id="L-3054"><a href="#L-3054"><span class="linenos">3054</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected type"</span><span class="p">)</span> -</span><span id="L-3055"><a href="#L-3055"><span class="linenos">3055</span></a> <span class="k">elif</span> <span class="n">op</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="L-3056"><a href="#L-3056"><span class="linenos">3056</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-3057"><a href="#L-3057"><span class="linenos">3057</span></a> <span class="n">value</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><span id="L-3058"><a href="#L-3058"><span class="linenos">3058</span></a> <span class="n">field</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-3059"><a href="#L-3059"><span class="linenos">3059</span></a> <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="n">value</span><span class="p">)</span> -</span><span id="L-3060"><a href="#L-3060"><span class="linenos">3060</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span> -</span><span id="L-3061"><a href="#L-3061"><span class="linenos">3061</span></a> <span class="k">else</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">value</span><span class="p">)</span> -</span><span id="L-3062"><a href="#L-3062"><span class="linenos">3062</span></a> <span class="p">)</span> -</span><span id="L-3063"><a href="#L-3063"><span class="linenos">3063</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3064"><a href="#L-3064"><span class="linenos">3064</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">anonymous_func</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-3065"><a href="#L-3065"><span class="linenos">3065</span></a> -</span><span id="L-3066"><a href="#L-3066"><span class="linenos">3066</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">field</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">):</span> -</span><span id="L-3067"><a href="#L-3067"><span class="linenos">3067</span></a> <span class="c1"># bigquery allows function calls like x.y.count(...)</span> -</span><span id="L-3068"><a href="#L-3068"><span class="linenos">3068</span></a> <span class="c1"># SAFE.SUBSTR(...)</span> -</span><span id="L-3069"><a href="#L-3069"><span class="linenos">3069</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-reference#function_call_rules</span> -</span><span id="L-3070"><a href="#L-3070"><span class="linenos">3070</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_replace_columns_with_dots</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-3071"><a href="#L-3071"><span class="linenos">3071</span></a> -</span><span id="L-3072"><a href="#L-3072"><span class="linenos">3072</span></a> <span class="k">if</span> <span class="n">op</span><span class="p">:</span> -</span><span id="L-3073"><a href="#L-3073"><span class="linenos">3073</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">field</span><span class="p">)</span> -</span><span id="L-3074"><a href="#L-3074"><span class="linenos">3074</span></a> <span class="k">elif</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">Column</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">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">):</span> -</span><span id="L-3075"><a href="#L-3075"><span class="linenos">3075</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-3076"><a href="#L-3076"><span class="linenos">3076</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">,</span> -</span><span id="L-3077"><a href="#L-3077"><span class="linenos">3077</span></a> <span class="n">this</span><span class="o">=</span><span class="n">field</span><span class="p">,</span> -</span><span id="L-3078"><a href="#L-3078"><span class="linenos">3078</span></a> <span class="n">table</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-3079"><a href="#L-3079"><span class="linenos">3079</span></a> <span class="n">db</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"table"</span><span class="p">),</span> -</span><span id="L-3080"><a href="#L-3080"><span class="linenos">3080</span></a> <span class="n">catalog</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"db"</span><span class="p">),</span> -</span><span id="L-3081"><a href="#L-3081"><span class="linenos">3081</span></a> <span class="p">)</span> -</span><span id="L-3082"><a href="#L-3082"><span class="linenos">3082</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3083"><a href="#L-3083"><span class="linenos">3083</span></a> <span class="n">this</span> <span class="o">=</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">Dot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">field</span><span class="p">)</span> -</span><span id="L-3084"><a href="#L-3084"><span class="linenos">3084</span></a> <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 class="n">this</span><span class="p">)</span> -</span><span id="L-3085"><a href="#L-3085"><span class="linenos">3085</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-3086"><a href="#L-3086"><span class="linenos">3086</span></a> -</span><span id="L-3087"><a href="#L-3087"><span class="linenos">3087</span></a> <span class="k">def</span> <span class="nf">_parse_primary</span><span class="p">(</span><span class="bp">self</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-3088"><a href="#L-3088"><span class="linenos">3088</span></a> <span class="k">if</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">PRIMARY_PARSERS</span><span class="p">):</span> -</span><span id="L-3089"><a href="#L-3089"><span class="linenos">3089</span></a> <span class="n">token_type</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">token_type</span> -</span><span id="L-3090"><a href="#L-3090"><span class="linenos">3090</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> -</span><span id="L-3091"><a href="#L-3091"><span class="linenos">3091</span></a> -</span><span id="L-3092"><a href="#L-3092"><span class="linenos">3092</span></a> <span class="k">if</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">:</span> -</span><span id="L-3093"><a href="#L-3093"><span class="linenos">3093</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">primary</span><span class="p">]</span> -</span><span id="L-3094"><a href="#L-3094"><span class="linenos">3094</span></a> <span class="k">while</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">STRING</span><span class="p">):</span> -</span><span id="L-3095"><a href="#L-3095"><span class="linenos">3095</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</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-3096"><a href="#L-3096"><span class="linenos">3096</span></a> -</span><span id="L-3097"><a href="#L-3097"><span class="linenos">3097</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-3098"><a href="#L-3098"><span class="linenos">3098</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">Concat</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-3099"><a href="#L-3099"><span class="linenos">3099</span></a> -</span><span id="L-3100"><a href="#L-3100"><span class="linenos">3100</span></a> <span class="k">return</span> <span class="n">primary</span> -</span><span id="L-3101"><a href="#L-3101"><span class="linenos">3101</span></a> -</span><span id="L-3102"><a href="#L-3102"><span class="linenos">3102</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DOT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span><span class="p">):</span> -</span><span id="L-3103"><a href="#L-3103"><span class="linenos">3103</span></a> <span class="k">return</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="sa">f</span><span class="s2">"0.</span><span class="si">{</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="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-3104"><a href="#L-3104"><span class="linenos">3104</span></a> -</span><span id="L-3105"><a href="#L-3105"><span class="linenos">3105</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_PAREN</span><span class="p">):</span> -</span><span id="L-3106"><a href="#L-3106"><span class="linenos">3106</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> -</span><span id="L-3107"><a href="#L-3107"><span class="linenos">3107</span></a> <span class="n">query</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">()</span> +</span><span id="L-3051"><a href="#L-3051"><span class="linenos">3051</span></a> <span class="k">while</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">COLUMN_OPERATORS</span><span class="p">):</span> +</span><span id="L-3052"><a href="#L-3052"><span class="linenos">3052</span></a> <span class="n">op_token</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">token_type</span> +</span><span id="L-3053"><a href="#L-3053"><span class="linenos">3053</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">COLUMN_OPERATORS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">op_token</span><span class="p">)</span> +</span><span id="L-3054"><a href="#L-3054"><span class="linenos">3054</span></a> +</span><span id="L-3055"><a href="#L-3055"><span class="linenos">3055</span></a> <span class="k">if</span> <span class="n">op_token</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DCOLON</span><span class="p">:</span> +</span><span id="L-3056"><a href="#L-3056"><span class="linenos">3056</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">()</span> +</span><span id="L-3057"><a href="#L-3057"><span class="linenos">3057</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">field</span><span class="p">:</span> +</span><span id="L-3058"><a href="#L-3058"><span class="linenos">3058</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected type"</span><span class="p">)</span> +</span><span id="L-3059"><a href="#L-3059"><span class="linenos">3059</span></a> <span class="k">elif</span> <span class="n">op</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="L-3060"><a href="#L-3060"><span class="linenos">3060</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-3061"><a href="#L-3061"><span class="linenos">3061</span></a> <span class="n">value</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><span id="L-3062"><a href="#L-3062"><span class="linenos">3062</span></a> <span class="n">field</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-3063"><a href="#L-3063"><span class="linenos">3063</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="L-3064"><a href="#L-3064"><span class="linenos">3064</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span> +</span><span id="L-3065"><a href="#L-3065"><span class="linenos">3065</span></a> <span class="k">else</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">value</span><span class="p">)</span> +</span><span id="L-3066"><a href="#L-3066"><span class="linenos">3066</span></a> <span class="p">)</span> +</span><span id="L-3067"><a href="#L-3067"><span class="linenos">3067</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3068"><a href="#L-3068"><span class="linenos">3068</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">anonymous_func</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-3069"><a href="#L-3069"><span class="linenos">3069</span></a> +</span><span id="L-3070"><a href="#L-3070"><span class="linenos">3070</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">field</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">):</span> +</span><span id="L-3071"><a href="#L-3071"><span class="linenos">3071</span></a> <span class="c1"># bigquery allows function calls like x.y.count(...)</span> +</span><span id="L-3072"><a href="#L-3072"><span class="linenos">3072</span></a> <span class="c1"># SAFE.SUBSTR(...)</span> +</span><span id="L-3073"><a href="#L-3073"><span class="linenos">3073</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-reference#function_call_rules</span> +</span><span id="L-3074"><a href="#L-3074"><span class="linenos">3074</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_replace_columns_with_dots</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-3075"><a href="#L-3075"><span class="linenos">3075</span></a> +</span><span id="L-3076"><a href="#L-3076"><span class="linenos">3076</span></a> <span class="k">if</span> <span class="n">op</span><span class="p">:</span> +</span><span id="L-3077"><a href="#L-3077"><span class="linenos">3077</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">field</span><span class="p">)</span> +</span><span id="L-3078"><a href="#L-3078"><span class="linenos">3078</span></a> <span class="k">elif</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">Column</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">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">):</span> +</span><span id="L-3079"><a href="#L-3079"><span class="linenos">3079</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-3080"><a href="#L-3080"><span class="linenos">3080</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">,</span> +</span><span id="L-3081"><a href="#L-3081"><span class="linenos">3081</span></a> <span class="n">this</span><span class="o">=</span><span class="n">field</span><span class="p">,</span> +</span><span id="L-3082"><a href="#L-3082"><span class="linenos">3082</span></a> <span class="n">table</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-3083"><a href="#L-3083"><span class="linenos">3083</span></a> <span class="n">db</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"table"</span><span class="p">),</span> +</span><span id="L-3084"><a href="#L-3084"><span class="linenos">3084</span></a> <span class="n">catalog</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"db"</span><span class="p">),</span> +</span><span id="L-3085"><a href="#L-3085"><span class="linenos">3085</span></a> <span class="p">)</span> +</span><span id="L-3086"><a href="#L-3086"><span class="linenos">3086</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3087"><a href="#L-3087"><span class="linenos">3087</span></a> <span class="n">this</span> <span class="o">=</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">Dot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">field</span><span class="p">)</span> +</span><span id="L-3088"><a href="#L-3088"><span class="linenos">3088</span></a> <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 class="n">this</span><span class="p">)</span> +</span><span id="L-3089"><a href="#L-3089"><span class="linenos">3089</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-3090"><a href="#L-3090"><span class="linenos">3090</span></a> +</span><span id="L-3091"><a href="#L-3091"><span class="linenos">3091</span></a> <span class="k">def</span> <span class="nf">_parse_primary</span><span class="p">(</span><span class="bp">self</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-3092"><a href="#L-3092"><span class="linenos">3092</span></a> <span class="k">if</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">PRIMARY_PARSERS</span><span class="p">):</span> +</span><span id="L-3093"><a href="#L-3093"><span class="linenos">3093</span></a> <span class="n">token_type</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">token_type</span> +</span><span id="L-3094"><a href="#L-3094"><span class="linenos">3094</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="L-3095"><a href="#L-3095"><span class="linenos">3095</span></a> +</span><span id="L-3096"><a href="#L-3096"><span class="linenos">3096</span></a> <span class="k">if</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">:</span> +</span><span id="L-3097"><a href="#L-3097"><span class="linenos">3097</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">primary</span><span class="p">]</span> +</span><span id="L-3098"><a href="#L-3098"><span class="linenos">3098</span></a> <span class="k">while</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">STRING</span><span class="p">):</span> +</span><span id="L-3099"><a href="#L-3099"><span class="linenos">3099</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</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-3100"><a href="#L-3100"><span class="linenos">3100</span></a> +</span><span id="L-3101"><a href="#L-3101"><span class="linenos">3101</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-3102"><a href="#L-3102"><span class="linenos">3102</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">Concat</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-3103"><a href="#L-3103"><span class="linenos">3103</span></a> +</span><span id="L-3104"><a href="#L-3104"><span class="linenos">3104</span></a> <span class="k">return</span> <span class="n">primary</span> +</span><span id="L-3105"><a href="#L-3105"><span class="linenos">3105</span></a> +</span><span id="L-3106"><a href="#L-3106"><span class="linenos">3106</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DOT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span><span class="p">):</span> +</span><span id="L-3107"><a href="#L-3107"><span class="linenos">3107</span></a> <span class="k">return</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="sa">f</span><span class="s2">"0.</span><span class="si">{</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="si">}</span><span class="s2">"</span><span class="p">)</span> </span><span id="L-3108"><a href="#L-3108"><span class="linenos">3108</span></a> -</span><span id="L-3109"><a href="#L-3109"><span class="linenos">3109</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> -</span><span id="L-3110"><a href="#L-3110"><span class="linenos">3110</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">query</span><span class="p">]</span> -</span><span id="L-3111"><a href="#L-3111"><span class="linenos">3111</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3112"><a href="#L-3112"><span class="linenos">3112</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">)</span> -</span><span id="L-3113"><a href="#L-3113"><span class="linenos">3113</span></a> -</span><span id="L-3114"><a href="#L-3114"><span class="linenos">3114</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">seq_get</span><span class="p">(</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span> -</span><span id="L-3115"><a href="#L-3115"><span class="linenos">3115</span></a> -</span><span id="L-3116"><a href="#L-3116"><span class="linenos">3116</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">Subqueryable</span><span class="p">):</span> -</span><span id="L-3117"><a href="#L-3117"><span class="linenos">3117</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span> -</span><span id="L-3118"><a href="#L-3118"><span class="linenos">3118</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_subquery</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">parse_alias</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-3119"><a href="#L-3119"><span class="linenos">3119</span></a> <span class="p">)</span> -</span><span id="L-3120"><a href="#L-3120"><span class="linenos">3120</span></a> <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-3121"><a href="#L-3121"><span class="linenos">3121</span></a> <span class="n">this</span> <span class="o">=</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">Tuple</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-3122"><a href="#L-3122"><span class="linenos">3122</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3123"><a href="#L-3123"><span class="linenos">3123</span></a> <span class="n">this</span> <span class="o">=</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">Paren</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_set_operations</span><span class="p">(</span><span class="n">this</span><span class="p">))</span> -</span><span id="L-3124"><a href="#L-3124"><span class="linenos">3124</span></a> -</span><span id="L-3125"><a href="#L-3125"><span class="linenos">3125</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> -</span><span id="L-3126"><a href="#L-3126"><span class="linenos">3126</span></a> <span class="n">this</span><span class="o">.</span><span class="n">add_comments</span><span class="p">(</span><span class="n">comments</span><span class="p">)</span> -</span><span id="L-3127"><a href="#L-3127"><span class="linenos">3127</span></a> -</span><span id="L-3128"><a href="#L-3128"><span class="linenos">3128</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-3129"><a href="#L-3129"><span class="linenos">3129</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-3130"><a href="#L-3130"><span class="linenos">3130</span></a> -</span><span id="L-3131"><a href="#L-3131"><span class="linenos">3131</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-3132"><a href="#L-3132"><span class="linenos">3132</span></a> -</span><span id="L-3133"><a href="#L-3133"><span class="linenos">3133</span></a> <span class="k">def</span> <span class="nf">_parse_field</span><span class="p">(</span> -</span><span id="L-3134"><a href="#L-3134"><span class="linenos">3134</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-3135"><a href="#L-3135"><span class="linenos">3135</span></a> <span class="n">any_token</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3136"><a href="#L-3136"><span class="linenos">3136</span></a> <span class="n">tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-3137"><a href="#L-3137"><span class="linenos">3137</span></a> <span class="n">anonymous_func</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3138"><a href="#L-3138"><span class="linenos">3138</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-3139"><a href="#L-3139"><span class="linenos">3139</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="L-3140"><a href="#L-3140"><span class="linenos">3140</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> -</span><span id="L-3141"><a href="#L-3141"><span class="linenos">3141</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">(</span><span class="n">anonymous</span><span class="o">=</span><span class="n">anonymous_func</span><span class="p">)</span> -</span><span id="L-3142"><a href="#L-3142"><span class="linenos">3142</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="n">any_token</span><span class="p">,</span> <span class="n">tokens</span><span class="o">=</span><span class="n">tokens</span><span class="p">)</span> -</span><span id="L-3143"><a href="#L-3143"><span class="linenos">3143</span></a> <span class="p">)</span> -</span><span id="L-3144"><a href="#L-3144"><span class="linenos">3144</span></a> -</span><span id="L-3145"><a href="#L-3145"><span class="linenos">3145</span></a> <span class="k">def</span> <span class="nf">_parse_function</span><span class="p">(</span> -</span><span id="L-3146"><a href="#L-3146"><span class="linenos">3146</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-3147"><a href="#L-3147"><span class="linenos">3147</span></a> <span class="n">functions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-3148"><a href="#L-3148"><span class="linenos">3148</span></a> <span class="n">anonymous</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-3149"><a href="#L-3149"><span class="linenos">3149</span></a> <span class="n">optional_parens</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-3150"><a href="#L-3150"><span class="linenos">3150</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-3151"><a href="#L-3151"><span class="linenos">3151</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="L-3152"><a href="#L-3152"><span class="linenos">3152</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-3153"><a href="#L-3153"><span class="linenos">3153</span></a> -</span><span id="L-3154"><a href="#L-3154"><span class="linenos">3154</span></a> <span class="n">token_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> -</span><span id="L-3155"><a href="#L-3155"><span class="linenos">3155</span></a> -</span><span id="L-3156"><a href="#L-3156"><span class="linenos">3156</span></a> <span class="k">if</span> <span class="n">optional_parens</span> <span class="ow">and</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">NO_PAREN_FUNCTION_PARSERS</span><span class="p">):</span> -</span><span id="L-3157"><a href="#L-3157"><span class="linenos">3157</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">NO_PAREN_FUNCTION_PARSERS</span><span class="p">[</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> -</span><span id="L-3158"><a href="#L-3158"><span class="linenos">3158</span></a> -</span><span id="L-3159"><a href="#L-3159"><span class="linenos">3159</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="o">.</span><span class="n">token_type</span> <span class="o">!=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">:</span> -</span><span id="L-3160"><a href="#L-3160"><span class="linenos">3160</span></a> <span class="k">if</span> <span class="n">optional_parens</span> <span class="ow">and</span> <span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">NO_PAREN_FUNCTIONS</span><span class="p">:</span> -</span><span id="L-3161"><a href="#L-3161"><span class="linenos">3161</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-3162"><a href="#L-3162"><span class="linenos">3162</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="bp">self</span><span class="o">.</span><span class="n">NO_PAREN_FUNCTIONS</span><span class="p">[</span><span class="n">token_type</span><span class="p">])</span> -</span><span id="L-3163"><a href="#L-3163"><span class="linenos">3163</span></a> -</span><span id="L-3164"><a href="#L-3164"><span class="linenos">3164</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-3165"><a href="#L-3165"><span class="linenos">3165</span></a> -</span><span id="L-3166"><a href="#L-3166"><span class="linenos">3166</span></a> <span class="k">if</span> <span class="n">token_type</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">FUNC_TOKENS</span><span class="p">:</span> -</span><span id="L-3167"><a href="#L-3167"><span class="linenos">3167</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-3168"><a href="#L-3168"><span class="linenos">3168</span></a> -</span><span id="L-3169"><a href="#L-3169"><span class="linenos">3169</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">text</span> -</span><span id="L-3170"><a href="#L-3170"><span class="linenos">3170</span></a> <span class="n">upper</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-3171"><a href="#L-3171"><span class="linenos">3171</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> +</span><span id="L-3109"><a href="#L-3109"><span class="linenos">3109</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_PAREN</span><span class="p">):</span> +</span><span id="L-3110"><a href="#L-3110"><span class="linenos">3110</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> +</span><span id="L-3111"><a href="#L-3111"><span class="linenos">3111</span></a> <span class="n">query</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">()</span> +</span><span id="L-3112"><a href="#L-3112"><span class="linenos">3112</span></a> +</span><span id="L-3113"><a href="#L-3113"><span class="linenos">3113</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> +</span><span id="L-3114"><a href="#L-3114"><span class="linenos">3114</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">query</span><span class="p">]</span> +</span><span id="L-3115"><a href="#L-3115"><span class="linenos">3115</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3116"><a href="#L-3116"><span class="linenos">3116</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">)</span> +</span><span id="L-3117"><a href="#L-3117"><span class="linenos">3117</span></a> +</span><span id="L-3118"><a href="#L-3118"><span class="linenos">3118</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">seq_get</span><span class="p">(</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span> +</span><span id="L-3119"><a href="#L-3119"><span class="linenos">3119</span></a> +</span><span id="L-3120"><a href="#L-3120"><span class="linenos">3120</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">Subqueryable</span><span class="p">):</span> +</span><span id="L-3121"><a href="#L-3121"><span class="linenos">3121</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span> +</span><span id="L-3122"><a href="#L-3122"><span class="linenos">3122</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_subquery</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">parse_alias</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-3123"><a href="#L-3123"><span class="linenos">3123</span></a> <span class="p">)</span> +</span><span id="L-3124"><a href="#L-3124"><span class="linenos">3124</span></a> <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-3125"><a href="#L-3125"><span class="linenos">3125</span></a> <span class="n">this</span> <span class="o">=</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">Tuple</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-3126"><a href="#L-3126"><span class="linenos">3126</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3127"><a href="#L-3127"><span class="linenos">3127</span></a> <span class="n">this</span> <span class="o">=</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">Paren</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_set_operations</span><span class="p">(</span><span class="n">this</span><span class="p">))</span> +</span><span id="L-3128"><a href="#L-3128"><span class="linenos">3128</span></a> +</span><span id="L-3129"><a href="#L-3129"><span class="linenos">3129</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> +</span><span id="L-3130"><a href="#L-3130"><span class="linenos">3130</span></a> <span class="n">this</span><span class="o">.</span><span class="n">add_comments</span><span class="p">(</span><span class="n">comments</span><span class="p">)</span> +</span><span id="L-3131"><a href="#L-3131"><span class="linenos">3131</span></a> +</span><span id="L-3132"><a href="#L-3132"><span class="linenos">3132</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-3133"><a href="#L-3133"><span class="linenos">3133</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-3134"><a href="#L-3134"><span class="linenos">3134</span></a> +</span><span id="L-3135"><a href="#L-3135"><span class="linenos">3135</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-3136"><a href="#L-3136"><span class="linenos">3136</span></a> +</span><span id="L-3137"><a href="#L-3137"><span class="linenos">3137</span></a> <span class="k">def</span> <span class="nf">_parse_field</span><span class="p">(</span> +</span><span id="L-3138"><a href="#L-3138"><span class="linenos">3138</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-3139"><a href="#L-3139"><span class="linenos">3139</span></a> <span class="n">any_token</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3140"><a href="#L-3140"><span class="linenos">3140</span></a> <span class="n">tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-3141"><a href="#L-3141"><span class="linenos">3141</span></a> <span class="n">anonymous_func</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3142"><a href="#L-3142"><span class="linenos">3142</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-3143"><a href="#L-3143"><span class="linenos">3143</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="L-3144"><a href="#L-3144"><span class="linenos">3144</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="L-3145"><a href="#L-3145"><span class="linenos">3145</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">(</span><span class="n">anonymous</span><span class="o">=</span><span class="n">anonymous_func</span><span class="p">)</span> +</span><span id="L-3146"><a href="#L-3146"><span class="linenos">3146</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="n">any_token</span><span class="p">,</span> <span class="n">tokens</span><span class="o">=</span><span class="n">tokens</span><span class="p">)</span> +</span><span id="L-3147"><a href="#L-3147"><span class="linenos">3147</span></a> <span class="p">)</span> +</span><span id="L-3148"><a href="#L-3148"><span class="linenos">3148</span></a> +</span><span id="L-3149"><a href="#L-3149"><span class="linenos">3149</span></a> <span class="k">def</span> <span class="nf">_parse_function</span><span class="p">(</span> +</span><span id="L-3150"><a href="#L-3150"><span class="linenos">3150</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-3151"><a href="#L-3151"><span class="linenos">3151</span></a> <span class="n">functions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-3152"><a href="#L-3152"><span class="linenos">3152</span></a> <span class="n">anonymous</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-3153"><a href="#L-3153"><span class="linenos">3153</span></a> <span class="n">optional_parens</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-3154"><a href="#L-3154"><span class="linenos">3154</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-3155"><a href="#L-3155"><span class="linenos">3155</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="L-3156"><a href="#L-3156"><span class="linenos">3156</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-3157"><a href="#L-3157"><span class="linenos">3157</span></a> +</span><span id="L-3158"><a href="#L-3158"><span class="linenos">3158</span></a> <span class="n">token_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> +</span><span id="L-3159"><a href="#L-3159"><span class="linenos">3159</span></a> +</span><span id="L-3160"><a href="#L-3160"><span class="linenos">3160</span></a> <span class="k">if</span> <span class="n">optional_parens</span> <span class="ow">and</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">NO_PAREN_FUNCTION_PARSERS</span><span class="p">):</span> +</span><span id="L-3161"><a href="#L-3161"><span class="linenos">3161</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">NO_PAREN_FUNCTION_PARSERS</span><span class="p">[</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> +</span><span id="L-3162"><a href="#L-3162"><span class="linenos">3162</span></a> +</span><span id="L-3163"><a href="#L-3163"><span class="linenos">3163</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="o">.</span><span class="n">token_type</span> <span class="o">!=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">:</span> +</span><span id="L-3164"><a href="#L-3164"><span class="linenos">3164</span></a> <span class="k">if</span> <span class="n">optional_parens</span> <span class="ow">and</span> <span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">NO_PAREN_FUNCTIONS</span><span class="p">:</span> +</span><span id="L-3165"><a href="#L-3165"><span class="linenos">3165</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-3166"><a href="#L-3166"><span class="linenos">3166</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="bp">self</span><span class="o">.</span><span class="n">NO_PAREN_FUNCTIONS</span><span class="p">[</span><span class="n">token_type</span><span class="p">])</span> +</span><span id="L-3167"><a href="#L-3167"><span class="linenos">3167</span></a> +</span><span id="L-3168"><a href="#L-3168"><span class="linenos">3168</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-3169"><a href="#L-3169"><span class="linenos">3169</span></a> +</span><span id="L-3170"><a href="#L-3170"><span class="linenos">3170</span></a> <span class="k">if</span> <span class="n">token_type</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">FUNC_TOKENS</span><span class="p">:</span> +</span><span id="L-3171"><a href="#L-3171"><span class="linenos">3171</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="L-3172"><a href="#L-3172"><span class="linenos">3172</span></a> -</span><span id="L-3173"><a href="#L-3173"><span class="linenos">3173</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">upper</span><span class="p">)</span> -</span><span id="L-3174"><a href="#L-3174"><span class="linenos">3174</span></a> -</span><span id="L-3175"><a href="#L-3175"><span class="linenos">3175</span></a> <span class="k">if</span> <span class="n">parser</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">anonymous</span><span class="p">:</span> -</span><span id="L-3176"><a href="#L-3176"><span class="linenos">3176</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> -</span><span id="L-3177"><a href="#L-3177"><span class="linenos">3177</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3178"><a href="#L-3178"><span class="linenos">3178</span></a> <span class="n">subquery_predicate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">SUBQUERY_PREDICATES</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">token_type</span><span class="p">)</span> -</span><span id="L-3179"><a href="#L-3179"><span class="linenos">3179</span></a> -</span><span id="L-3180"><a href="#L-3180"><span class="linenos">3180</span></a> <span class="k">if</span> <span class="n">subquery_predicate</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SELECT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">):</span> -</span><span id="L-3181"><a href="#L-3181"><span class="linenos">3181</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">subquery_predicate</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_select</span><span class="p">())</span> -</span><span id="L-3182"><a href="#L-3182"><span class="linenos">3182</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="L-3183"><a href="#L-3183"><span class="linenos">3183</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-3184"><a href="#L-3184"><span class="linenos">3184</span></a> -</span><span id="L-3185"><a href="#L-3185"><span class="linenos">3185</span></a> <span class="k">if</span> <span class="n">functions</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-3186"><a href="#L-3186"><span class="linenos">3186</span></a> <span class="n">functions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">FUNCTIONS</span> -</span><span id="L-3187"><a href="#L-3187"><span class="linenos">3187</span></a> -</span><span id="L-3188"><a href="#L-3188"><span class="linenos">3188</span></a> <span class="n">function</span> <span class="o">=</span> <span class="n">functions</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">upper</span><span class="p">)</span> -</span><span id="L-3189"><a href="#L-3189"><span class="linenos">3189</span></a> -</span><span id="L-3190"><a href="#L-3190"><span class="linenos">3190</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">upper</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span> -</span><span id="L-3191"><a href="#L-3191"><span class="linenos">3191</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lambda</span><span class="p">(</span><span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">))</span> -</span><span id="L-3192"><a href="#L-3192"><span class="linenos">3192</span></a> -</span><span id="L-3193"><a href="#L-3193"><span class="linenos">3193</span></a> <span class="k">if</span> <span class="n">function</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">anonymous</span><span class="p">:</span> -</span><span id="L-3194"><a href="#L-3194"><span class="linenos">3194</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">function</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="n">args</span><span class="p">)</span> -</span><span id="L-3195"><a href="#L-3195"><span class="linenos">3195</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3196"><a href="#L-3196"><span class="linenos">3196</span></a> <span class="n">this</span> <span class="o">=</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">Anonymous</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">args</span><span class="p">)</span> -</span><span id="L-3197"><a href="#L-3197"><span class="linenos">3197</span></a> -</span><span id="L-3198"><a href="#L-3198"><span class="linenos">3198</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-3199"><a href="#L-3199"><span class="linenos">3199</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-3200"><a href="#L-3200"><span class="linenos">3200</span></a> -</span><span id="L-3201"><a href="#L-3201"><span class="linenos">3201</span></a> <span class="k">def</span> <span class="nf">_parse_function_parameter</span><span class="p">(</span><span class="bp">self</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-3202"><a href="#L-3202"><span class="linenos">3202</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_def</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">())</span> -</span><span id="L-3203"><a href="#L-3203"><span class="linenos">3203</span></a> -</span><span id="L-3204"><a href="#L-3204"><span class="linenos">3204</span></a> <span class="k">def</span> <span class="nf">_parse_user_defined_function</span><span class="p">(</span> -</span><span id="L-3205"><a href="#L-3205"><span class="linenos">3205</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">kind</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">TokenType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-3206"><a href="#L-3206"><span class="linenos">3206</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-3207"><a href="#L-3207"><span class="linenos">3207</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="L-3208"><a href="#L-3208"><span class="linenos">3208</span></a> -</span><span id="L-3209"><a href="#L-3209"><span class="linenos">3209</span></a> <span class="k">while</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">DOT</span><span class="p">):</span> -</span><span id="L-3210"><a href="#L-3210"><span class="linenos">3210</span></a> <span class="n">this</span> <span class="o">=</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">Dot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">())</span> -</span><span id="L-3211"><a href="#L-3211"><span class="linenos">3211</span></a> -</span><span id="L-3212"><a href="#L-3212"><span class="linenos">3212</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">):</span> -</span><span id="L-3213"><a href="#L-3213"><span class="linenos">3213</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-3214"><a href="#L-3214"><span class="linenos">3214</span></a> -</span><span id="L-3215"><a href="#L-3215"><span class="linenos">3215</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function_parameter</span><span class="p">)</span> -</span><span id="L-3216"><a href="#L-3216"><span class="linenos">3216</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="L-3217"><a href="#L-3217"><span class="linenos">3217</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><span id="L-3218"><a href="#L-3218"><span class="linenos">3218</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UserDefinedFunction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">wrapped</span><span class="o">=</span><span class="kc">True</span> -</span><span id="L-3219"><a href="#L-3219"><span class="linenos">3219</span></a> <span class="p">)</span> -</span><span id="L-3220"><a href="#L-3220"><span class="linenos">3220</span></a> -</span><span id="L-3221"><a href="#L-3221"><span class="linenos">3221</span></a> <span class="k">def</span> <span class="nf">_parse_introducer</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token</span><span class="p">:</span> <span class="n">Token</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Introducer</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">:</span> -</span><span id="L-3222"><a href="#L-3222"><span class="linenos">3222</span></a> <span class="n">literal</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> -</span><span id="L-3223"><a href="#L-3223"><span class="linenos">3223</span></a> <span class="k">if</span> <span class="n">literal</span><span class="p">:</span> -</span><span id="L-3224"><a href="#L-3224"><span class="linenos">3224</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">Introducer</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">literal</span><span class="p">)</span> -</span><span id="L-3225"><a href="#L-3225"><span class="linenos">3225</span></a> -</span><span id="L-3226"><a href="#L-3226"><span class="linenos">3226</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">Identifier</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> -</span><span id="L-3227"><a href="#L-3227"><span class="linenos">3227</span></a> -</span><span id="L-3228"><a href="#L-3228"><span class="linenos">3228</span></a> <span class="k">def</span> <span class="nf">_parse_session_parameter</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">SessionParameter</span><span class="p">:</span> -</span><span id="L-3229"><a href="#L-3229"><span class="linenos">3229</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-3230"><a href="#L-3230"><span class="linenos">3230</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="L-3173"><a href="#L-3173"><span class="linenos">3173</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">text</span> +</span><span id="L-3174"><a href="#L-3174"><span class="linenos">3174</span></a> <span class="n">upper</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-3175"><a href="#L-3175"><span class="linenos">3175</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> +</span><span id="L-3176"><a href="#L-3176"><span class="linenos">3176</span></a> +</span><span id="L-3177"><a href="#L-3177"><span class="linenos">3177</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">upper</span><span class="p">)</span> +</span><span id="L-3178"><a href="#L-3178"><span class="linenos">3178</span></a> +</span><span id="L-3179"><a href="#L-3179"><span class="linenos">3179</span></a> <span class="k">if</span> <span class="n">parser</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">anonymous</span><span class="p">:</span> +</span><span id="L-3180"><a href="#L-3180"><span class="linenos">3180</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> +</span><span id="L-3181"><a href="#L-3181"><span class="linenos">3181</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3182"><a href="#L-3182"><span class="linenos">3182</span></a> <span class="n">subquery_predicate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">SUBQUERY_PREDICATES</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">token_type</span><span class="p">)</span> +</span><span id="L-3183"><a href="#L-3183"><span class="linenos">3183</span></a> +</span><span id="L-3184"><a href="#L-3184"><span class="linenos">3184</span></a> <span class="k">if</span> <span class="n">subquery_predicate</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SELECT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">):</span> +</span><span id="L-3185"><a href="#L-3185"><span class="linenos">3185</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">subquery_predicate</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_select</span><span class="p">())</span> +</span><span id="L-3186"><a href="#L-3186"><span class="linenos">3186</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-3187"><a href="#L-3187"><span class="linenos">3187</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-3188"><a href="#L-3188"><span class="linenos">3188</span></a> +</span><span id="L-3189"><a href="#L-3189"><span class="linenos">3189</span></a> <span class="k">if</span> <span class="n">functions</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-3190"><a href="#L-3190"><span class="linenos">3190</span></a> <span class="n">functions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">FUNCTIONS</span> +</span><span id="L-3191"><a href="#L-3191"><span class="linenos">3191</span></a> +</span><span id="L-3192"><a href="#L-3192"><span class="linenos">3192</span></a> <span class="n">function</span> <span class="o">=</span> <span class="n">functions</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">upper</span><span class="p">)</span> +</span><span id="L-3193"><a href="#L-3193"><span class="linenos">3193</span></a> +</span><span id="L-3194"><a href="#L-3194"><span class="linenos">3194</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">upper</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span> +</span><span id="L-3195"><a href="#L-3195"><span class="linenos">3195</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lambda</span><span class="p">(</span><span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">))</span> +</span><span id="L-3196"><a href="#L-3196"><span class="linenos">3196</span></a> +</span><span id="L-3197"><a href="#L-3197"><span class="linenos">3197</span></a> <span class="k">if</span> <span class="n">function</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">anonymous</span><span class="p">:</span> +</span><span id="L-3198"><a href="#L-3198"><span class="linenos">3198</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">function</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="n">args</span><span class="p">)</span> +</span><span id="L-3199"><a href="#L-3199"><span class="linenos">3199</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3200"><a href="#L-3200"><span class="linenos">3200</span></a> <span class="n">this</span> <span class="o">=</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">Anonymous</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">args</span><span class="p">)</span> +</span><span id="L-3201"><a href="#L-3201"><span class="linenos">3201</span></a> +</span><span id="L-3202"><a href="#L-3202"><span class="linenos">3202</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-3203"><a href="#L-3203"><span class="linenos">3203</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-3204"><a href="#L-3204"><span class="linenos">3204</span></a> +</span><span id="L-3205"><a href="#L-3205"><span class="linenos">3205</span></a> <span class="k">def</span> <span class="nf">_parse_function_parameter</span><span class="p">(</span><span class="bp">self</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-3206"><a href="#L-3206"><span class="linenos">3206</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_def</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">())</span> +</span><span id="L-3207"><a href="#L-3207"><span class="linenos">3207</span></a> +</span><span id="L-3208"><a href="#L-3208"><span class="linenos">3208</span></a> <span class="k">def</span> <span class="nf">_parse_user_defined_function</span><span class="p">(</span> +</span><span id="L-3209"><a href="#L-3209"><span class="linenos">3209</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">kind</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">TokenType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3210"><a href="#L-3210"><span class="linenos">3210</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-3211"><a href="#L-3211"><span class="linenos">3211</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="L-3212"><a href="#L-3212"><span class="linenos">3212</span></a> +</span><span id="L-3213"><a href="#L-3213"><span class="linenos">3213</span></a> <span class="k">while</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">DOT</span><span class="p">):</span> +</span><span id="L-3214"><a href="#L-3214"><span class="linenos">3214</span></a> <span class="n">this</span> <span class="o">=</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">Dot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">())</span> +</span><span id="L-3215"><a href="#L-3215"><span class="linenos">3215</span></a> +</span><span id="L-3216"><a href="#L-3216"><span class="linenos">3216</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">):</span> +</span><span id="L-3217"><a href="#L-3217"><span class="linenos">3217</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-3218"><a href="#L-3218"><span class="linenos">3218</span></a> +</span><span id="L-3219"><a href="#L-3219"><span class="linenos">3219</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function_parameter</span><span class="p">)</span> +</span><span id="L-3220"><a href="#L-3220"><span class="linenos">3220</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-3221"><a href="#L-3221"><span class="linenos">3221</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><span id="L-3222"><a href="#L-3222"><span class="linenos">3222</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UserDefinedFunction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">wrapped</span><span class="o">=</span><span class="kc">True</span> +</span><span id="L-3223"><a href="#L-3223"><span class="linenos">3223</span></a> <span class="p">)</span> +</span><span id="L-3224"><a href="#L-3224"><span class="linenos">3224</span></a> +</span><span id="L-3225"><a href="#L-3225"><span class="linenos">3225</span></a> <span class="k">def</span> <span class="nf">_parse_introducer</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token</span><span class="p">:</span> <span class="n">Token</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Introducer</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">:</span> +</span><span id="L-3226"><a href="#L-3226"><span class="linenos">3226</span></a> <span class="n">literal</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="L-3227"><a href="#L-3227"><span class="linenos">3227</span></a> <span class="k">if</span> <span class="n">literal</span><span class="p">:</span> +</span><span id="L-3228"><a href="#L-3228"><span class="linenos">3228</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">Introducer</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">literal</span><span class="p">)</span> +</span><span id="L-3229"><a href="#L-3229"><span class="linenos">3229</span></a> +</span><span id="L-3230"><a href="#L-3230"><span class="linenos">3230</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">Identifier</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> </span><span id="L-3231"><a href="#L-3231"><span class="linenos">3231</span></a> -</span><span id="L-3232"><a href="#L-3232"><span class="linenos">3232</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</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">DOT</span><span class="p">):</span> -</span><span id="L-3233"><a href="#L-3233"><span class="linenos">3233</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> -</span><span id="L-3234"><a href="#L-3234"><span class="linenos">3234</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="L-3232"><a href="#L-3232"><span class="linenos">3232</span></a> <span class="k">def</span> <span class="nf">_parse_session_parameter</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">SessionParameter</span><span class="p">:</span> +</span><span id="L-3233"><a href="#L-3233"><span class="linenos">3233</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3234"><a href="#L-3234"><span class="linenos">3234</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> </span><span id="L-3235"><a href="#L-3235"><span class="linenos">3235</span></a> -</span><span id="L-3236"><a href="#L-3236"><span class="linenos">3236</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">SessionParameter</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">)</span> -</span><span id="L-3237"><a href="#L-3237"><span class="linenos">3237</span></a> -</span><span id="L-3238"><a href="#L-3238"><span class="linenos">3238</span></a> <span class="k">def</span> <span class="nf">_parse_lambda</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">alias</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-3239"><a href="#L-3239"><span class="linenos">3239</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="L-3240"><a href="#L-3240"><span class="linenos">3240</span></a> -</span><span id="L-3241"><a href="#L-3241"><span class="linenos">3241</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_PAREN</span><span class="p">):</span> -</span><span id="L-3242"><a href="#L-3242"><span class="linenos">3242</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">)</span> -</span><span id="L-3243"><a href="#L-3243"><span class="linenos">3243</span></a> -</span><span id="L-3244"><a href="#L-3244"><span class="linenos">3244</span></a> <span class="k">if</span> <span class="ow">not</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">R_PAREN</span><span class="p">):</span> -</span><span id="L-3245"><a href="#L-3245"><span class="linenos">3245</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-3246"><a href="#L-3246"><span class="linenos">3246</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3247"><a href="#L-3247"><span class="linenos">3247</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()]</span> -</span><span id="L-3248"><a href="#L-3248"><span class="linenos">3248</span></a> -</span><span id="L-3249"><a href="#L-3249"><span class="linenos">3249</span></a> <span class="k">if</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">LAMBDAS</span><span class="p">):</span> -</span><span id="L-3250"><a href="#L-3250"><span class="linenos">3250</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">LAMBDAS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="n">expressions</span><span class="p">)</span> -</span><span id="L-3251"><a href="#L-3251"><span class="linenos">3251</span></a> -</span><span id="L-3252"><a href="#L-3252"><span class="linenos">3252</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-3253"><a href="#L-3253"><span class="linenos">3253</span></a> -</span><span id="L-3254"><a href="#L-3254"><span class="linenos">3254</span></a> <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><span id="L-3236"><a href="#L-3236"><span class="linenos">3236</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</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">DOT</span><span class="p">):</span> +</span><span id="L-3237"><a href="#L-3237"><span class="linenos">3237</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-3238"><a href="#L-3238"><span class="linenos">3238</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="L-3239"><a href="#L-3239"><span class="linenos">3239</span></a> +</span><span id="L-3240"><a href="#L-3240"><span class="linenos">3240</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">SessionParameter</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">)</span> +</span><span id="L-3241"><a href="#L-3241"><span class="linenos">3241</span></a> +</span><span id="L-3242"><a href="#L-3242"><span class="linenos">3242</span></a> <span class="k">def</span> <span class="nf">_parse_lambda</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">alias</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-3243"><a href="#L-3243"><span class="linenos">3243</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="L-3244"><a href="#L-3244"><span class="linenos">3244</span></a> +</span><span id="L-3245"><a href="#L-3245"><span class="linenos">3245</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_PAREN</span><span class="p">):</span> +</span><span id="L-3246"><a href="#L-3246"><span class="linenos">3246</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">)</span> +</span><span id="L-3247"><a href="#L-3247"><span class="linenos">3247</span></a> +</span><span id="L-3248"><a href="#L-3248"><span class="linenos">3248</span></a> <span class="k">if</span> <span class="ow">not</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">R_PAREN</span><span class="p">):</span> +</span><span id="L-3249"><a href="#L-3249"><span class="linenos">3249</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-3250"><a href="#L-3250"><span class="linenos">3250</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3251"><a href="#L-3251"><span class="linenos">3251</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()]</span> +</span><span id="L-3252"><a href="#L-3252"><span class="linenos">3252</span></a> +</span><span id="L-3253"><a href="#L-3253"><span class="linenos">3253</span></a> <span class="k">if</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">LAMBDAS</span><span class="p">):</span> +</span><span id="L-3254"><a href="#L-3254"><span class="linenos">3254</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">LAMBDAS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="n">expressions</span><span class="p">)</span> </span><span id="L-3255"><a href="#L-3255"><span class="linenos">3255</span></a> -</span><span id="L-3256"><a href="#L-3256"><span class="linenos">3256</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">DISTINCT</span><span class="p">):</span> -</span><span id="L-3257"><a href="#L-3257"><span class="linenos">3257</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-3258"><a href="#L-3258"><span class="linenos">3258</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Distinct</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="L-3259"><a href="#L-3259"><span class="linenos">3259</span></a> <span class="p">)</span> -</span><span id="L-3260"><a href="#L-3260"><span class="linenos">3260</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3261"><a href="#L-3261"><span class="linenos">3261</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select_or_expression</span><span class="p">(</span><span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> -</span><span id="L-3262"><a href="#L-3262"><span class="linenos">3262</span></a> -</span><span id="L-3263"><a href="#L-3263"><span class="linenos">3263</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">EQ</span><span class="p">):</span> -</span><span id="L-3264"><a href="#L-3264"><span class="linenos">3264</span></a> <span class="n">left</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-3265"><a href="#L-3265"><span class="linenos">3265</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">left</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> -</span><span id="L-3266"><a href="#L-3266"><span class="linenos">3266</span></a> <span class="n">left</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">var</span><span class="p">(</span><span class="n">left</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"this"</span><span class="p">)))</span> -</span><span id="L-3267"><a href="#L-3267"><span class="linenos">3267</span></a> -</span><span id="L-3268"><a href="#L-3268"><span class="linenos">3268</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_limit</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_respect_or_ignore_nulls</span><span class="p">(</span><span class="n">this</span><span class="p">)))</span> -</span><span id="L-3269"><a href="#L-3269"><span class="linenos">3269</span></a> -</span><span id="L-3270"><a href="#L-3270"><span class="linenos">3270</span></a> <span class="k">def</span> <span class="nf">_parse_schema</span><span class="p">(</span><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 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-3271"><a href="#L-3271"><span class="linenos">3271</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="L-3272"><a href="#L-3272"><span class="linenos">3272</span></a> -</span><span id="L-3273"><a href="#L-3273"><span class="linenos">3273</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">:</span> -</span><span id="L-3274"><a href="#L-3274"><span class="linenos">3274</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="L-3275"><a href="#L-3275"><span class="linenos">3275</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> -</span><span id="L-3276"><a href="#L-3276"><span class="linenos">3276</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-3277"><a href="#L-3277"><span class="linenos">3277</span></a> <span class="k">except</span> <span class="n">ParseError</span><span class="p">:</span> -</span><span id="L-3278"><a href="#L-3278"><span class="linenos">3278</span></a> <span class="k">pass</span> -</span><span id="L-3279"><a href="#L-3279"><span class="linenos">3279</span></a> <span class="k">finally</span><span class="p">:</span> -</span><span id="L-3280"><a href="#L-3280"><span class="linenos">3280</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span> -</span><span id="L-3281"><a href="#L-3281"><span class="linenos">3281</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-3282"><a href="#L-3282"><span class="linenos">3282</span></a> -</span><span id="L-3283"><a href="#L-3283"><span class="linenos">3283</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">):</span> -</span><span id="L-3284"><a href="#L-3284"><span class="linenos">3284</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-3285"><a href="#L-3285"><span class="linenos">3285</span></a> -</span><span id="L-3286"><a href="#L-3286"><span class="linenos">3286</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> -</span><span id="L-3287"><a href="#L-3287"><span class="linenos">3287</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_constraint</span><span class="p">()</span> -</span><span id="L-3288"><a href="#L-3288"><span class="linenos">3288</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_def</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> -</span><span id="L-3289"><a href="#L-3289"><span class="linenos">3289</span></a> <span class="p">)</span> -</span><span id="L-3290"><a href="#L-3290"><span class="linenos">3290</span></a> -</span><span id="L-3291"><a href="#L-3291"><span class="linenos">3291</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="L-3292"><a href="#L-3292"><span class="linenos">3292</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">Schema</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">args</span><span class="p">)</span> -</span><span id="L-3293"><a href="#L-3293"><span class="linenos">3293</span></a> -</span><span id="L-3294"><a href="#L-3294"><span class="linenos">3294</span></a> <span class="k">def</span> <span class="nf">_parse_column_def</span><span class="p">(</span><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="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-3295"><a href="#L-3295"><span class="linenos">3295</span></a> <span class="c1"># column defs are not really columns, they're identifiers</span> -</span><span id="L-3296"><a href="#L-3296"><span class="linenos">3296</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">Column</span><span class="p">):</span> -</span><span id="L-3297"><a href="#L-3297"><span class="linenos">3297</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-3298"><a href="#L-3298"><span class="linenos">3298</span></a> -</span><span id="L-3299"><a href="#L-3299"><span class="linenos">3299</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-3300"><a href="#L-3300"><span class="linenos">3300</span></a> -</span><span id="L-3301"><a href="#L-3301"><span class="linenos">3301</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"ORDINALITY"</span><span class="p">):</span> -</span><span id="L-3302"><a href="#L-3302"><span class="linenos">3302</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">ColumnDef</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">ordinality</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-3303"><a href="#L-3303"><span class="linenos">3303</span></a> -</span><span id="L-3304"><a href="#L-3304"><span class="linenos">3304</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-3305"><a href="#L-3305"><span class="linenos">3305</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-3306"><a href="#L-3306"><span class="linenos">3306</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_constraint</span><span class="p">()</span> -</span><span id="L-3307"><a href="#L-3307"><span class="linenos">3307</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">constraint</span><span class="p">:</span> -</span><span id="L-3308"><a href="#L-3308"><span class="linenos">3308</span></a> <span class="k">break</span> -</span><span id="L-3309"><a href="#L-3309"><span class="linenos">3309</span></a> <span class="n">constraints</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">constraint</span><span class="p">)</span> -</span><span id="L-3310"><a href="#L-3310"><span class="linenos">3310</span></a> -</span><span id="L-3311"><a href="#L-3311"><span class="linenos">3311</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">kind</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">constraints</span><span class="p">:</span> -</span><span id="L-3312"><a href="#L-3312"><span class="linenos">3312</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-3313"><a href="#L-3313"><span class="linenos">3313</span></a> -</span><span id="L-3314"><a href="#L-3314"><span class="linenos">3314</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">ColumnDef</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> <span class="n">constraints</span><span class="o">=</span><span class="n">constraints</span><span class="p">)</span> -</span><span id="L-3315"><a href="#L-3315"><span class="linenos">3315</span></a> -</span><span id="L-3316"><a href="#L-3316"><span class="linenos">3316</span></a> <span class="k">def</span> <span class="nf">_parse_auto_increment</span><span class="p">(</span> -</span><span id="L-3317"><a href="#L-3317"><span class="linenos">3317</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-3318"><a href="#L-3318"><span class="linenos">3318</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">AutoIncrementColumnConstraint</span><span class="p">:</span> -</span><span id="L-3319"><a href="#L-3319"><span class="linenos">3319</span></a> <span class="n">start</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-3320"><a href="#L-3320"><span class="linenos">3320</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-3321"><a href="#L-3321"><span class="linenos">3321</span></a> -</span><span id="L-3322"><a href="#L-3322"><span class="linenos">3322</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_PAREN</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-3323"><a href="#L-3323"><span class="linenos">3323</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_bitwise</span><span class="p">)</span> -</span><span id="L-3324"><a href="#L-3324"><span class="linenos">3324</span></a> <span class="n">start</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-3325"><a href="#L-3325"><span class="linenos">3325</span></a> <span class="n">increment</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-3326"><a href="#L-3326"><span class="linenos">3326</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"START"</span><span class="p">):</span> -</span><span id="L-3327"><a href="#L-3327"><span class="linenos">3327</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="L-3328"><a href="#L-3328"><span class="linenos">3328</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INCREMENT"</span><span class="p">)</span> -</span><span id="L-3329"><a href="#L-3329"><span class="linenos">3329</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="L-3330"><a href="#L-3330"><span class="linenos">3330</span></a> -</span><span id="L-3331"><a href="#L-3331"><span class="linenos">3331</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">and</span> <span class="n">increment</span><span class="p">:</span> -</span><span id="L-3332"><a href="#L-3332"><span class="linenos">3332</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span><span class="p">(</span><span class="n">start</span><span class="o">=</span><span class="n">start</span><span class="p">,</span> <span class="n">increment</span><span class="o">=</span><span class="n">increment</span><span class="p">)</span> -</span><span id="L-3333"><a href="#L-3333"><span class="linenos">3333</span></a> -</span><span id="L-3334"><a href="#L-3334"><span class="linenos">3334</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">AutoIncrementColumnConstraint</span><span class="p">()</span> -</span><span id="L-3335"><a href="#L-3335"><span class="linenos">3335</span></a> -</span><span id="L-3336"><a href="#L-3336"><span class="linenos">3336</span></a> <span class="k">def</span> <span class="nf">_parse_compress</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">CompressColumnConstraint</span><span class="p">:</span> -</span><span id="L-3337"><a href="#L-3337"><span class="linenos">3337</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_PAREN</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-3338"><a href="#L-3338"><span class="linenos">3338</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><span id="L-3339"><a href="#L-3339"><span class="linenos">3339</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CompressColumnConstraint</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_wrapped_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">)</span> -</span><span id="L-3340"><a href="#L-3340"><span class="linenos">3340</span></a> <span class="p">)</span> -</span><span id="L-3341"><a href="#L-3341"><span class="linenos">3341</span></a> -</span><span id="L-3342"><a href="#L-3342"><span class="linenos">3342</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">CompressColumnConstraint</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_bitwise</span><span class="p">())</span> -</span><span id="L-3343"><a href="#L-3343"><span class="linenos">3343</span></a> -</span><span id="L-3344"><a href="#L-3344"><span class="linenos">3344</span></a> <span class="k">def</span> <span class="nf">_parse_generated_as_identity</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">GeneratedAsIdentityColumnConstraint</span><span class="p">:</span> -</span><span id="L-3345"><a href="#L-3345"><span class="linenos">3345</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BY"</span><span class="p">,</span> <span class="s2">"DEFAULT"</span><span class="p">):</span> -</span><span id="L-3346"><a href="#L-3346"><span class="linenos">3346</span></a> <span class="n">on_null</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ON</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">)</span> -</span><span id="L-3347"><a href="#L-3347"><span class="linenos">3347</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-3348"><a href="#L-3348"><span class="linenos">3348</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">on_null</span><span class="o">=</span><span class="n">on_null</span> -</span><span id="L-3349"><a href="#L-3349"><span class="linenos">3349</span></a> <span class="p">)</span> -</span><span id="L-3350"><a href="#L-3350"><span class="linenos">3350</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3351"><a href="#L-3351"><span class="linenos">3351</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ALWAYS"</span><span class="p">)</span> -</span><span id="L-3352"><a href="#L-3352"><span class="linenos">3352</span></a> <span class="n">this</span> <span class="o">=</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">GeneratedAsIdentityColumnConstraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-3353"><a href="#L-3353"><span class="linenos">3353</span></a> -</span><span id="L-3354"><a href="#L-3354"><span class="linenos">3354</span></a> <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">ALIAS</span><span class="p">)</span> -</span><span id="L-3355"><a href="#L-3355"><span class="linenos">3355</span></a> <span class="n">identity</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"IDENTITY"</span><span class="p">)</span> -</span><span id="L-3356"><a href="#L-3356"><span class="linenos">3356</span></a> -</span><span id="L-3357"><a href="#L-3357"><span class="linenos">3357</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_PAREN</span><span class="p">):</span> -</span><span id="L-3358"><a href="#L-3358"><span class="linenos">3358</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"START"</span><span class="p">,</span> <span class="s2">"WITH"</span><span class="p">):</span> -</span><span id="L-3359"><a href="#L-3359"><span class="linenos">3359</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"start"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> -</span><span id="L-3360"><a href="#L-3360"><span class="linenos">3360</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INCREMENT"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> -</span><span id="L-3361"><a href="#L-3361"><span class="linenos">3361</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"increment"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> -</span><span id="L-3362"><a href="#L-3362"><span class="linenos">3362</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MINVALUE"</span><span class="p">):</span> -</span><span id="L-3363"><a href="#L-3363"><span class="linenos">3363</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"minvalue"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> -</span><span id="L-3364"><a href="#L-3364"><span class="linenos">3364</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MAXVALUE"</span><span class="p">):</span> -</span><span id="L-3365"><a href="#L-3365"><span class="linenos">3365</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"maxvalue"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> -</span><span id="L-3366"><a href="#L-3366"><span class="linenos">3366</span></a> -</span><span id="L-3367"><a href="#L-3367"><span class="linenos">3367</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CYCLE"</span><span class="p">):</span> -</span><span id="L-3368"><a href="#L-3368"><span class="linenos">3368</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"cycle"</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> -</span><span id="L-3369"><a href="#L-3369"><span class="linenos">3369</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"CYCLE"</span><span class="p">):</span> -</span><span id="L-3370"><a href="#L-3370"><span class="linenos">3370</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"cycle"</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> -</span><span id="L-3371"><a href="#L-3371"><span class="linenos">3371</span></a> -</span><span id="L-3372"><a href="#L-3372"><span class="linenos">3372</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">identity</span><span class="p">:</span> -</span><span id="L-3373"><a href="#L-3373"><span class="linenos">3373</span></a> <span class="n">this</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="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> -</span><span id="L-3374"><a href="#L-3374"><span class="linenos">3374</span></a> -</span><span id="L-3375"><a href="#L-3375"><span class="linenos">3375</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="L-3376"><a href="#L-3376"><span class="linenos">3376</span></a> -</span><span id="L-3377"><a href="#L-3377"><span class="linenos">3377</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-3256"><a href="#L-3256"><span class="linenos">3256</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-3257"><a href="#L-3257"><span class="linenos">3257</span></a> +</span><span id="L-3258"><a href="#L-3258"><span class="linenos">3258</span></a> <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><span id="L-3259"><a href="#L-3259"><span class="linenos">3259</span></a> +</span><span id="L-3260"><a href="#L-3260"><span class="linenos">3260</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">DISTINCT</span><span class="p">):</span> +</span><span id="L-3261"><a href="#L-3261"><span class="linenos">3261</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-3262"><a href="#L-3262"><span class="linenos">3262</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Distinct</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="L-3263"><a href="#L-3263"><span class="linenos">3263</span></a> <span class="p">)</span> +</span><span id="L-3264"><a href="#L-3264"><span class="linenos">3264</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3265"><a href="#L-3265"><span class="linenos">3265</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select_or_expression</span><span class="p">(</span><span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> +</span><span id="L-3266"><a href="#L-3266"><span class="linenos">3266</span></a> +</span><span id="L-3267"><a href="#L-3267"><span class="linenos">3267</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">EQ</span><span class="p">):</span> +</span><span id="L-3268"><a href="#L-3268"><span class="linenos">3268</span></a> <span class="n">left</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-3269"><a href="#L-3269"><span class="linenos">3269</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">left</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> +</span><span id="L-3270"><a href="#L-3270"><span class="linenos">3270</span></a> <span class="n">left</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">var</span><span class="p">(</span><span class="n">left</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"this"</span><span class="p">)))</span> +</span><span id="L-3271"><a href="#L-3271"><span class="linenos">3271</span></a> +</span><span id="L-3272"><a href="#L-3272"><span class="linenos">3272</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_limit</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_respect_or_ignore_nulls</span><span class="p">(</span><span class="n">this</span><span class="p">)))</span> +</span><span id="L-3273"><a href="#L-3273"><span class="linenos">3273</span></a> +</span><span id="L-3274"><a href="#L-3274"><span class="linenos">3274</span></a> <span class="k">def</span> <span class="nf">_parse_schema</span><span class="p">(</span><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 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-3275"><a href="#L-3275"><span class="linenos">3275</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="L-3276"><a href="#L-3276"><span class="linenos">3276</span></a> +</span><span id="L-3277"><a href="#L-3277"><span class="linenos">3277</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">:</span> +</span><span id="L-3278"><a href="#L-3278"><span class="linenos">3278</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="L-3279"><a href="#L-3279"><span class="linenos">3279</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> +</span><span id="L-3280"><a href="#L-3280"><span class="linenos">3280</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-3281"><a href="#L-3281"><span class="linenos">3281</span></a> <span class="k">except</span> <span class="n">ParseError</span><span class="p">:</span> +</span><span id="L-3282"><a href="#L-3282"><span class="linenos">3282</span></a> <span class="k">pass</span> +</span><span id="L-3283"><a href="#L-3283"><span class="linenos">3283</span></a> <span class="k">finally</span><span class="p">:</span> +</span><span id="L-3284"><a href="#L-3284"><span class="linenos">3284</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span> +</span><span id="L-3285"><a href="#L-3285"><span class="linenos">3285</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-3286"><a href="#L-3286"><span class="linenos">3286</span></a> +</span><span id="L-3287"><a href="#L-3287"><span class="linenos">3287</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">):</span> +</span><span id="L-3288"><a href="#L-3288"><span class="linenos">3288</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-3289"><a href="#L-3289"><span class="linenos">3289</span></a> +</span><span id="L-3290"><a href="#L-3290"><span class="linenos">3290</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> +</span><span id="L-3291"><a href="#L-3291"><span class="linenos">3291</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_constraint</span><span class="p">()</span> +</span><span id="L-3292"><a href="#L-3292"><span class="linenos">3292</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_def</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="L-3293"><a href="#L-3293"><span class="linenos">3293</span></a> <span class="p">)</span> +</span><span id="L-3294"><a href="#L-3294"><span class="linenos">3294</span></a> +</span><span id="L-3295"><a href="#L-3295"><span class="linenos">3295</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-3296"><a href="#L-3296"><span class="linenos">3296</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">Schema</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">args</span><span class="p">)</span> +</span><span id="L-3297"><a href="#L-3297"><span class="linenos">3297</span></a> +</span><span id="L-3298"><a href="#L-3298"><span class="linenos">3298</span></a> <span class="k">def</span> <span class="nf">_parse_column_def</span><span class="p">(</span><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="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-3299"><a href="#L-3299"><span class="linenos">3299</span></a> <span class="c1"># column defs are not really columns, they're identifiers</span> +</span><span id="L-3300"><a href="#L-3300"><span class="linenos">3300</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">Column</span><span class="p">):</span> +</span><span id="L-3301"><a href="#L-3301"><span class="linenos">3301</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-3302"><a href="#L-3302"><span class="linenos">3302</span></a> +</span><span id="L-3303"><a href="#L-3303"><span class="linenos">3303</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-3304"><a href="#L-3304"><span class="linenos">3304</span></a> +</span><span id="L-3305"><a href="#L-3305"><span class="linenos">3305</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"ORDINALITY"</span><span class="p">):</span> +</span><span id="L-3306"><a href="#L-3306"><span class="linenos">3306</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">ColumnDef</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">ordinality</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-3307"><a href="#L-3307"><span class="linenos">3307</span></a> +</span><span id="L-3308"><a href="#L-3308"><span class="linenos">3308</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-3309"><a href="#L-3309"><span class="linenos">3309</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-3310"><a href="#L-3310"><span class="linenos">3310</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_constraint</span><span class="p">()</span> +</span><span id="L-3311"><a href="#L-3311"><span class="linenos">3311</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">constraint</span><span class="p">:</span> +</span><span id="L-3312"><a href="#L-3312"><span class="linenos">3312</span></a> <span class="k">break</span> +</span><span id="L-3313"><a href="#L-3313"><span class="linenos">3313</span></a> <span class="n">constraints</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">constraint</span><span class="p">)</span> +</span><span id="L-3314"><a href="#L-3314"><span class="linenos">3314</span></a> +</span><span id="L-3315"><a href="#L-3315"><span class="linenos">3315</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">kind</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">constraints</span><span class="p">:</span> +</span><span id="L-3316"><a href="#L-3316"><span class="linenos">3316</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-3317"><a href="#L-3317"><span class="linenos">3317</span></a> +</span><span id="L-3318"><a href="#L-3318"><span class="linenos">3318</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">ColumnDef</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> <span class="n">constraints</span><span class="o">=</span><span class="n">constraints</span><span class="p">)</span> +</span><span id="L-3319"><a href="#L-3319"><span class="linenos">3319</span></a> +</span><span id="L-3320"><a href="#L-3320"><span class="linenos">3320</span></a> <span class="k">def</span> <span class="nf">_parse_auto_increment</span><span class="p">(</span> +</span><span id="L-3321"><a href="#L-3321"><span class="linenos">3321</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-3322"><a href="#L-3322"><span class="linenos">3322</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">AutoIncrementColumnConstraint</span><span class="p">:</span> +</span><span id="L-3323"><a href="#L-3323"><span class="linenos">3323</span></a> <span class="n">start</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3324"><a href="#L-3324"><span class="linenos">3324</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3325"><a href="#L-3325"><span class="linenos">3325</span></a> +</span><span id="L-3326"><a href="#L-3326"><span class="linenos">3326</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_PAREN</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-3327"><a href="#L-3327"><span class="linenos">3327</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_bitwise</span><span class="p">)</span> +</span><span id="L-3328"><a href="#L-3328"><span class="linenos">3328</span></a> <span class="n">start</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-3329"><a href="#L-3329"><span class="linenos">3329</span></a> <span class="n">increment</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-3330"><a href="#L-3330"><span class="linenos">3330</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"START"</span><span class="p">):</span> +</span><span id="L-3331"><a href="#L-3331"><span class="linenos">3331</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="L-3332"><a href="#L-3332"><span class="linenos">3332</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INCREMENT"</span><span class="p">)</span> +</span><span id="L-3333"><a href="#L-3333"><span class="linenos">3333</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="L-3334"><a href="#L-3334"><span class="linenos">3334</span></a> +</span><span id="L-3335"><a href="#L-3335"><span class="linenos">3335</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">and</span> <span class="n">increment</span><span class="p">:</span> +</span><span id="L-3336"><a href="#L-3336"><span class="linenos">3336</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span><span class="p">(</span><span class="n">start</span><span class="o">=</span><span class="n">start</span><span class="p">,</span> <span class="n">increment</span><span class="o">=</span><span class="n">increment</span><span class="p">)</span> +</span><span id="L-3337"><a href="#L-3337"><span class="linenos">3337</span></a> +</span><span id="L-3338"><a href="#L-3338"><span class="linenos">3338</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">AutoIncrementColumnConstraint</span><span class="p">()</span> +</span><span id="L-3339"><a href="#L-3339"><span class="linenos">3339</span></a> +</span><span id="L-3340"><a href="#L-3340"><span class="linenos">3340</span></a> <span class="k">def</span> <span class="nf">_parse_compress</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">CompressColumnConstraint</span><span class="p">:</span> +</span><span id="L-3341"><a href="#L-3341"><span class="linenos">3341</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_PAREN</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-3342"><a href="#L-3342"><span class="linenos">3342</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><span id="L-3343"><a href="#L-3343"><span class="linenos">3343</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CompressColumnConstraint</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_wrapped_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">)</span> +</span><span id="L-3344"><a href="#L-3344"><span class="linenos">3344</span></a> <span class="p">)</span> +</span><span id="L-3345"><a href="#L-3345"><span class="linenos">3345</span></a> +</span><span id="L-3346"><a href="#L-3346"><span class="linenos">3346</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">CompressColumnConstraint</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_bitwise</span><span class="p">())</span> +</span><span id="L-3347"><a href="#L-3347"><span class="linenos">3347</span></a> +</span><span id="L-3348"><a href="#L-3348"><span class="linenos">3348</span></a> <span class="k">def</span> <span class="nf">_parse_generated_as_identity</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">GeneratedAsIdentityColumnConstraint</span><span class="p">:</span> +</span><span id="L-3349"><a href="#L-3349"><span class="linenos">3349</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BY"</span><span class="p">,</span> <span class="s2">"DEFAULT"</span><span class="p">):</span> +</span><span id="L-3350"><a href="#L-3350"><span class="linenos">3350</span></a> <span class="n">on_null</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ON</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">)</span> +</span><span id="L-3351"><a href="#L-3351"><span class="linenos">3351</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-3352"><a href="#L-3352"><span class="linenos">3352</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">on_null</span><span class="o">=</span><span class="n">on_null</span> +</span><span id="L-3353"><a href="#L-3353"><span class="linenos">3353</span></a> <span class="p">)</span> +</span><span id="L-3354"><a href="#L-3354"><span class="linenos">3354</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3355"><a href="#L-3355"><span class="linenos">3355</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ALWAYS"</span><span class="p">)</span> +</span><span id="L-3356"><a href="#L-3356"><span class="linenos">3356</span></a> <span class="n">this</span> <span class="o">=</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">GeneratedAsIdentityColumnConstraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-3357"><a href="#L-3357"><span class="linenos">3357</span></a> +</span><span id="L-3358"><a href="#L-3358"><span class="linenos">3358</span></a> <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">ALIAS</span><span class="p">)</span> +</span><span id="L-3359"><a href="#L-3359"><span class="linenos">3359</span></a> <span class="n">identity</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"IDENTITY"</span><span class="p">)</span> +</span><span id="L-3360"><a href="#L-3360"><span class="linenos">3360</span></a> +</span><span id="L-3361"><a href="#L-3361"><span class="linenos">3361</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_PAREN</span><span class="p">):</span> +</span><span id="L-3362"><a href="#L-3362"><span class="linenos">3362</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"START"</span><span class="p">,</span> <span class="s2">"WITH"</span><span class="p">):</span> +</span><span id="L-3363"><a href="#L-3363"><span class="linenos">3363</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"start"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> +</span><span id="L-3364"><a href="#L-3364"><span class="linenos">3364</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INCREMENT"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> +</span><span id="L-3365"><a href="#L-3365"><span class="linenos">3365</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"increment"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> +</span><span id="L-3366"><a href="#L-3366"><span class="linenos">3366</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MINVALUE"</span><span class="p">):</span> +</span><span id="L-3367"><a href="#L-3367"><span class="linenos">3367</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"minvalue"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> +</span><span id="L-3368"><a href="#L-3368"><span class="linenos">3368</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MAXVALUE"</span><span class="p">):</span> +</span><span id="L-3369"><a href="#L-3369"><span class="linenos">3369</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"maxvalue"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> +</span><span id="L-3370"><a href="#L-3370"><span class="linenos">3370</span></a> +</span><span id="L-3371"><a href="#L-3371"><span class="linenos">3371</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CYCLE"</span><span class="p">):</span> +</span><span id="L-3372"><a href="#L-3372"><span class="linenos">3372</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"cycle"</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> +</span><span id="L-3373"><a href="#L-3373"><span class="linenos">3373</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"CYCLE"</span><span class="p">):</span> +</span><span id="L-3374"><a href="#L-3374"><span class="linenos">3374</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"cycle"</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> +</span><span id="L-3375"><a href="#L-3375"><span class="linenos">3375</span></a> +</span><span id="L-3376"><a href="#L-3376"><span class="linenos">3376</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">identity</span><span class="p">:</span> +</span><span id="L-3377"><a href="#L-3377"><span class="linenos">3377</span></a> <span class="n">this</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="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> </span><span id="L-3378"><a href="#L-3378"><span class="linenos">3378</span></a> -</span><span id="L-3379"><a href="#L-3379"><span class="linenos">3379</span></a> <span class="k">def</span> <span class="nf">_parse_inline</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">InlineLengthColumnConstraint</span><span class="p">:</span> -</span><span id="L-3380"><a href="#L-3380"><span class="linenos">3380</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">)</span> -</span><span id="L-3381"><a href="#L-3381"><span class="linenos">3381</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">InlineLengthColumnConstraint</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_bitwise</span><span class="p">())</span> +</span><span id="L-3379"><a href="#L-3379"><span class="linenos">3379</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-3380"><a href="#L-3380"><span class="linenos">3380</span></a> +</span><span id="L-3381"><a href="#L-3381"><span class="linenos">3381</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="L-3382"><a href="#L-3382"><span class="linenos">3382</span></a> -</span><span id="L-3383"><a href="#L-3383"><span class="linenos">3383</span></a> <span class="k">def</span> <span class="nf">_parse_not_constraint</span><span class="p">(</span> -</span><span id="L-3384"><a href="#L-3384"><span class="linenos">3384</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-3385"><a href="#L-3385"><span class="linenos">3385</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">NotNullColumnConstraint</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">CaseSpecificColumnConstraint</span><span class="p">]:</span> -</span><span id="L-3386"><a href="#L-3386"><span class="linenos">3386</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULL"</span><span class="p">):</span> -</span><span id="L-3387"><a href="#L-3387"><span class="linenos">3387</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">NotNullColumnConstraint</span><span class="p">)</span> -</span><span id="L-3388"><a href="#L-3388"><span class="linenos">3388</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CASESPECIFIC"</span><span class="p">):</span> -</span><span id="L-3389"><a href="#L-3389"><span class="linenos">3389</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">CaseSpecificColumnConstraint</span><span class="p">,</span> <span class="n">not_</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-3390"><a href="#L-3390"><span class="linenos">3390</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-3391"><a href="#L-3391"><span class="linenos">3391</span></a> -</span><span id="L-3392"><a href="#L-3392"><span class="linenos">3392</span></a> <span class="k">def</span> <span class="nf">_parse_column_constraint</span><span class="p">(</span><span class="bp">self</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-3393"><a href="#L-3393"><span class="linenos">3393</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">CONSTRAINT</span><span class="p">):</span> -</span><span id="L-3394"><a href="#L-3394"><span class="linenos">3394</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="L-3395"><a href="#L-3395"><span class="linenos">3395</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3396"><a href="#L-3396"><span class="linenos">3396</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-3397"><a href="#L-3397"><span class="linenos">3397</span></a> -</span><span id="L-3398"><a href="#L-3398"><span class="linenos">3398</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">):</span> -</span><span id="L-3399"><a href="#L-3399"><span class="linenos">3399</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><span id="L-3400"><a href="#L-3400"><span class="linenos">3400</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnConstraint</span><span class="p">,</span> -</span><span id="L-3401"><a href="#L-3401"><span class="linenos">3401</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-3402"><a href="#L-3402"><span class="linenos">3402</span></a> <span class="n">kind</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">[</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="o">.</span><span class="n">upper</span><span class="p">()](</span><span class="bp">self</span><span class="p">),</span> -</span><span id="L-3403"><a href="#L-3403"><span class="linenos">3403</span></a> <span class="p">)</span> -</span><span id="L-3404"><a href="#L-3404"><span class="linenos">3404</span></a> -</span><span id="L-3405"><a href="#L-3405"><span class="linenos">3405</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-3406"><a href="#L-3406"><span class="linenos">3406</span></a> -</span><span id="L-3407"><a href="#L-3407"><span class="linenos">3407</span></a> <span class="k">def</span> <span class="nf">_parse_constraint</span><span class="p">(</span><span class="bp">self</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-3408"><a href="#L-3408"><span class="linenos">3408</span></a> <span class="k">if</span> <span class="ow">not</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">CONSTRAINT</span><span class="p">):</span> -</span><span id="L-3409"><a href="#L-3409"><span class="linenos">3409</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_unnamed_constraint</span><span class="p">(</span><span class="n">constraints</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">SCHEMA_UNNAMED_CONSTRAINTS</span><span class="p">)</span> +</span><span id="L-3383"><a href="#L-3383"><span class="linenos">3383</span></a> <span class="k">def</span> <span class="nf">_parse_inline</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">InlineLengthColumnConstraint</span><span class="p">:</span> +</span><span id="L-3384"><a href="#L-3384"><span class="linenos">3384</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">)</span> +</span><span id="L-3385"><a href="#L-3385"><span class="linenos">3385</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">InlineLengthColumnConstraint</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_bitwise</span><span class="p">())</span> +</span><span id="L-3386"><a href="#L-3386"><span class="linenos">3386</span></a> +</span><span id="L-3387"><a href="#L-3387"><span class="linenos">3387</span></a> <span class="k">def</span> <span class="nf">_parse_not_constraint</span><span class="p">(</span> +</span><span id="L-3388"><a href="#L-3388"><span class="linenos">3388</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-3389"><a href="#L-3389"><span class="linenos">3389</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">NotNullColumnConstraint</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">CaseSpecificColumnConstraint</span><span class="p">]:</span> +</span><span id="L-3390"><a href="#L-3390"><span class="linenos">3390</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULL"</span><span class="p">):</span> +</span><span id="L-3391"><a href="#L-3391"><span class="linenos">3391</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">NotNullColumnConstraint</span><span class="p">)</span> +</span><span id="L-3392"><a href="#L-3392"><span class="linenos">3392</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CASESPECIFIC"</span><span class="p">):</span> +</span><span id="L-3393"><a href="#L-3393"><span class="linenos">3393</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">CaseSpecificColumnConstraint</span><span class="p">,</span> <span class="n">not_</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-3394"><a href="#L-3394"><span class="linenos">3394</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-3395"><a href="#L-3395"><span class="linenos">3395</span></a> +</span><span id="L-3396"><a href="#L-3396"><span class="linenos">3396</span></a> <span class="k">def</span> <span class="nf">_parse_column_constraint</span><span class="p">(</span><span class="bp">self</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-3397"><a href="#L-3397"><span class="linenos">3397</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">CONSTRAINT</span><span class="p">):</span> +</span><span id="L-3398"><a href="#L-3398"><span class="linenos">3398</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="L-3399"><a href="#L-3399"><span class="linenos">3399</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3400"><a href="#L-3400"><span class="linenos">3400</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3401"><a href="#L-3401"><span class="linenos">3401</span></a> +</span><span id="L-3402"><a href="#L-3402"><span class="linenos">3402</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">):</span> +</span><span id="L-3403"><a href="#L-3403"><span class="linenos">3403</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><span id="L-3404"><a href="#L-3404"><span class="linenos">3404</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnConstraint</span><span class="p">,</span> +</span><span id="L-3405"><a href="#L-3405"><span class="linenos">3405</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-3406"><a href="#L-3406"><span class="linenos">3406</span></a> <span class="n">kind</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">[</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="o">.</span><span class="n">upper</span><span class="p">()](</span><span class="bp">self</span><span class="p">),</span> +</span><span id="L-3407"><a href="#L-3407"><span class="linenos">3407</span></a> <span class="p">)</span> +</span><span id="L-3408"><a href="#L-3408"><span class="linenos">3408</span></a> +</span><span id="L-3409"><a href="#L-3409"><span class="linenos">3409</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="L-3410"><a href="#L-3410"><span class="linenos">3410</span></a> -</span><span id="L-3411"><a href="#L-3411"><span class="linenos">3411</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="L-3412"><a href="#L-3412"><span class="linenos">3412</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-3413"><a href="#L-3413"><span class="linenos">3413</span></a> -</span><span id="L-3414"><a href="#L-3414"><span class="linenos">3414</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-3415"><a href="#L-3415"><span class="linenos">3415</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_unnamed_constraint</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> -</span><span id="L-3416"><a href="#L-3416"><span class="linenos">3416</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">constraint</span><span class="p">:</span> -</span><span id="L-3417"><a href="#L-3417"><span class="linenos">3417</span></a> <span class="k">break</span> -</span><span id="L-3418"><a href="#L-3418"><span class="linenos">3418</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">constraint</span><span class="p">)</span> -</span><span id="L-3419"><a href="#L-3419"><span class="linenos">3419</span></a> -</span><span id="L-3420"><a href="#L-3420"><span class="linenos">3420</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">Constraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-3421"><a href="#L-3421"><span class="linenos">3421</span></a> -</span><span id="L-3422"><a href="#L-3422"><span class="linenos">3422</span></a> <span class="k">def</span> <span class="nf">_parse_unnamed_constraint</span><span class="p">(</span> -</span><span id="L-3423"><a href="#L-3423"><span class="linenos">3423</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">constraints</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-3424"><a href="#L-3424"><span class="linenos">3424</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-3425"><a href="#L-3425"><span class="linenos">3425</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="n">constraints</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">):</span> -</span><span id="L-3426"><a href="#L-3426"><span class="linenos">3426</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-3427"><a href="#L-3427"><span class="linenos">3427</span></a> -</span><span id="L-3428"><a href="#L-3428"><span class="linenos">3428</span></a> <span class="n">constraint</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="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-3429"><a href="#L-3429"><span class="linenos">3429</span></a> <span class="k">if</span> <span class="n">constraint</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">:</span> -</span><span id="L-3430"><a href="#L-3430"><span class="linenos">3430</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="sa">f</span><span class="s2">"No parser found for schema constraint </span><span class="si">{</span><span class="n">constraint</span><span class="si">}</span><span class="s2">."</span><span class="p">)</span> +</span><span id="L-3411"><a href="#L-3411"><span class="linenos">3411</span></a> <span class="k">def</span> <span class="nf">_parse_constraint</span><span class="p">(</span><span class="bp">self</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-3412"><a href="#L-3412"><span class="linenos">3412</span></a> <span class="k">if</span> <span class="ow">not</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">CONSTRAINT</span><span class="p">):</span> +</span><span id="L-3413"><a href="#L-3413"><span class="linenos">3413</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_unnamed_constraint</span><span class="p">(</span><span class="n">constraints</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">SCHEMA_UNNAMED_CONSTRAINTS</span><span class="p">)</span> +</span><span id="L-3414"><a href="#L-3414"><span class="linenos">3414</span></a> +</span><span id="L-3415"><a href="#L-3415"><span class="linenos">3415</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="L-3416"><a href="#L-3416"><span class="linenos">3416</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-3417"><a href="#L-3417"><span class="linenos">3417</span></a> +</span><span id="L-3418"><a href="#L-3418"><span class="linenos">3418</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-3419"><a href="#L-3419"><span class="linenos">3419</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_unnamed_constraint</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> +</span><span id="L-3420"><a href="#L-3420"><span class="linenos">3420</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">constraint</span><span class="p">:</span> +</span><span id="L-3421"><a href="#L-3421"><span class="linenos">3421</span></a> <span class="k">break</span> +</span><span id="L-3422"><a href="#L-3422"><span class="linenos">3422</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">constraint</span><span class="p">)</span> +</span><span id="L-3423"><a href="#L-3423"><span class="linenos">3423</span></a> +</span><span id="L-3424"><a href="#L-3424"><span class="linenos">3424</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">Constraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-3425"><a href="#L-3425"><span class="linenos">3425</span></a> +</span><span id="L-3426"><a href="#L-3426"><span class="linenos">3426</span></a> <span class="k">def</span> <span class="nf">_parse_unnamed_constraint</span><span class="p">(</span> +</span><span id="L-3427"><a href="#L-3427"><span class="linenos">3427</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">constraints</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3428"><a href="#L-3428"><span class="linenos">3428</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-3429"><a href="#L-3429"><span class="linenos">3429</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="n">constraints</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">):</span> +</span><span id="L-3430"><a href="#L-3430"><span class="linenos">3430</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="L-3431"><a href="#L-3431"><span class="linenos">3431</span></a> -</span><span id="L-3432"><a href="#L-3432"><span class="linenos">3432</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">[</span><span class="n">constraint</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> -</span><span id="L-3433"><a href="#L-3433"><span class="linenos">3433</span></a> -</span><span id="L-3434"><a href="#L-3434"><span class="linenos">3434</span></a> <span class="k">def</span> <span class="nf">_parse_unique</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">UniqueColumnConstraint</span><span class="p">:</span> -</span><span id="L-3435"><a href="#L-3435"><span class="linenos">3435</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"KEY"</span><span class="p">)</span> -</span><span id="L-3436"><a href="#L-3436"><span class="linenos">3436</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><span id="L-3437"><a href="#L-3437"><span class="linenos">3437</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UniqueColumnConstraint</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_schema</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> -</span><span id="L-3438"><a href="#L-3438"><span class="linenos">3438</span></a> <span class="p">)</span> -</span><span id="L-3439"><a href="#L-3439"><span class="linenos">3439</span></a> -</span><span id="L-3440"><a href="#L-3440"><span class="linenos">3440</span></a> <span class="k">def</span> <span class="nf">_parse_key_constraint_options</span><span class="p">(</span><span class="bp">self</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-3441"><a href="#L-3441"><span class="linenos">3441</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-3442"><a href="#L-3442"><span class="linenos">3442</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-3443"><a href="#L-3443"><span class="linenos">3443</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="L-3444"><a href="#L-3444"><span class="linenos">3444</span></a> <span class="k">break</span> -</span><span id="L-3445"><a href="#L-3445"><span class="linenos">3445</span></a> -</span><span id="L-3446"><a href="#L-3446"><span class="linenos">3446</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">ON</span><span class="p">):</span> -</span><span id="L-3447"><a href="#L-3447"><span class="linenos">3447</span></a> <span class="n">action</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-3448"><a href="#L-3448"><span class="linenos">3448</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</span><span class="p">()</span> <span class="ow">and</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><span id="L-3432"><a href="#L-3432"><span class="linenos">3432</span></a> <span class="n">constraint</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="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-3433"><a href="#L-3433"><span class="linenos">3433</span></a> <span class="k">if</span> <span class="n">constraint</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">:</span> +</span><span id="L-3434"><a href="#L-3434"><span class="linenos">3434</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="sa">f</span><span class="s2">"No parser found for schema constraint </span><span class="si">{</span><span class="n">constraint</span><span class="si">}</span><span class="s2">."</span><span class="p">)</span> +</span><span id="L-3435"><a href="#L-3435"><span class="linenos">3435</span></a> +</span><span id="L-3436"><a href="#L-3436"><span class="linenos">3436</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">[</span><span class="n">constraint</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> +</span><span id="L-3437"><a href="#L-3437"><span class="linenos">3437</span></a> +</span><span id="L-3438"><a href="#L-3438"><span class="linenos">3438</span></a> <span class="k">def</span> <span class="nf">_parse_unique</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">UniqueColumnConstraint</span><span class="p">:</span> +</span><span id="L-3439"><a href="#L-3439"><span class="linenos">3439</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"KEY"</span><span class="p">)</span> +</span><span id="L-3440"><a href="#L-3440"><span class="linenos">3440</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><span id="L-3441"><a href="#L-3441"><span class="linenos">3441</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UniqueColumnConstraint</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_schema</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> +</span><span id="L-3442"><a href="#L-3442"><span class="linenos">3442</span></a> <span class="p">)</span> +</span><span id="L-3443"><a href="#L-3443"><span class="linenos">3443</span></a> +</span><span id="L-3444"><a href="#L-3444"><span class="linenos">3444</span></a> <span class="k">def</span> <span class="nf">_parse_key_constraint_options</span><span class="p">(</span><span class="bp">self</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-3445"><a href="#L-3445"><span class="linenos">3445</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-3446"><a href="#L-3446"><span class="linenos">3446</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-3447"><a href="#L-3447"><span class="linenos">3447</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="L-3448"><a href="#L-3448"><span class="linenos">3448</span></a> <span class="k">break</span> </span><span id="L-3449"><a href="#L-3449"><span class="linenos">3449</span></a> -</span><span id="L-3450"><a href="#L-3450"><span class="linenos">3450</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"ACTION"</span><span class="p">):</span> -</span><span id="L-3451"><a href="#L-3451"><span class="linenos">3451</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"NO ACTION"</span> -</span><span id="L-3452"><a href="#L-3452"><span class="linenos">3452</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CASCADE"</span><span class="p">):</span> -</span><span id="L-3453"><a href="#L-3453"><span class="linenos">3453</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"CASCADE"</span> -</span><span id="L-3454"><a href="#L-3454"><span class="linenos">3454</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">):</span> -</span><span id="L-3455"><a href="#L-3455"><span class="linenos">3455</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"SET NULL"</span> -</span><span id="L-3456"><a href="#L-3456"><span class="linenos">3456</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">):</span> -</span><span id="L-3457"><a href="#L-3457"><span class="linenos">3457</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"SET DEFAULT"</span> -</span><span id="L-3458"><a href="#L-3458"><span class="linenos">3458</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3459"><a href="#L-3459"><span class="linenos">3459</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Invalid key constraint"</span><span class="p">)</span> -</span><span id="L-3460"><a href="#L-3460"><span class="linenos">3460</span></a> -</span><span id="L-3461"><a href="#L-3461"><span class="linenos">3461</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"ON </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">action</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-3462"><a href="#L-3462"><span class="linenos">3462</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NOT"</span><span class="p">,</span> <span class="s2">"ENFORCED"</span><span class="p">):</span> -</span><span id="L-3463"><a href="#L-3463"><span class="linenos">3463</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"NOT ENFORCED"</span><span class="p">)</span> -</span><span id="L-3464"><a href="#L-3464"><span class="linenos">3464</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFERRABLE"</span><span class="p">):</span> -</span><span id="L-3465"><a href="#L-3465"><span class="linenos">3465</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"DEFERRABLE"</span><span class="p">)</span> -</span><span id="L-3466"><a href="#L-3466"><span class="linenos">3466</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INITIALLY"</span><span class="p">,</span> <span class="s2">"DEFERRED"</span><span class="p">):</span> -</span><span id="L-3467"><a href="#L-3467"><span class="linenos">3467</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"INITIALLY DEFERRED"</span><span class="p">)</span> -</span><span id="L-3468"><a href="#L-3468"><span class="linenos">3468</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NORELY"</span><span class="p">):</span> -</span><span id="L-3469"><a href="#L-3469"><span class="linenos">3469</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"NORELY"</span><span class="p">)</span> -</span><span id="L-3470"><a href="#L-3470"><span class="linenos">3470</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MATCH"</span><span class="p">,</span> <span class="s2">"FULL"</span><span class="p">):</span> -</span><span id="L-3471"><a href="#L-3471"><span class="linenos">3471</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"MATCH FULL"</span><span class="p">)</span> -</span><span id="L-3472"><a href="#L-3472"><span class="linenos">3472</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3473"><a href="#L-3473"><span class="linenos">3473</span></a> <span class="k">break</span> -</span><span id="L-3474"><a href="#L-3474"><span class="linenos">3474</span></a> -</span><span id="L-3475"><a href="#L-3475"><span class="linenos">3475</span></a> <span class="k">return</span> <span class="n">options</span> -</span><span id="L-3476"><a href="#L-3476"><span class="linenos">3476</span></a> -</span><span id="L-3477"><a href="#L-3477"><span class="linenos">3477</span></a> <span class="k">def</span> <span class="nf">_parse_references</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">match</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="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">Reference</span><span class="p">]:</span> -</span><span id="L-3478"><a href="#L-3478"><span class="linenos">3478</span></a> <span class="k">if</span> <span class="n">match</span> <span class="ow">and</span> <span class="ow">not</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">REFERENCES</span><span class="p">):</span> -</span><span id="L-3479"><a href="#L-3479"><span class="linenos">3479</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-3450"><a href="#L-3450"><span class="linenos">3450</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">ON</span><span class="p">):</span> +</span><span id="L-3451"><a href="#L-3451"><span class="linenos">3451</span></a> <span class="n">action</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3452"><a href="#L-3452"><span class="linenos">3452</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</span><span class="p">()</span> <span class="ow">and</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><span id="L-3453"><a href="#L-3453"><span class="linenos">3453</span></a> +</span><span id="L-3454"><a href="#L-3454"><span class="linenos">3454</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"ACTION"</span><span class="p">):</span> +</span><span id="L-3455"><a href="#L-3455"><span class="linenos">3455</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"NO ACTION"</span> +</span><span id="L-3456"><a href="#L-3456"><span class="linenos">3456</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CASCADE"</span><span class="p">):</span> +</span><span id="L-3457"><a href="#L-3457"><span class="linenos">3457</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"CASCADE"</span> +</span><span id="L-3458"><a href="#L-3458"><span class="linenos">3458</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">):</span> +</span><span id="L-3459"><a href="#L-3459"><span class="linenos">3459</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"SET NULL"</span> +</span><span id="L-3460"><a href="#L-3460"><span class="linenos">3460</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">):</span> +</span><span id="L-3461"><a href="#L-3461"><span class="linenos">3461</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"SET DEFAULT"</span> +</span><span id="L-3462"><a href="#L-3462"><span class="linenos">3462</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3463"><a href="#L-3463"><span class="linenos">3463</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Invalid key constraint"</span><span class="p">)</span> +</span><span id="L-3464"><a href="#L-3464"><span class="linenos">3464</span></a> +</span><span id="L-3465"><a href="#L-3465"><span class="linenos">3465</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"ON </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">action</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-3466"><a href="#L-3466"><span class="linenos">3466</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NOT"</span><span class="p">,</span> <span class="s2">"ENFORCED"</span><span class="p">):</span> +</span><span id="L-3467"><a href="#L-3467"><span class="linenos">3467</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"NOT ENFORCED"</span><span class="p">)</span> +</span><span id="L-3468"><a href="#L-3468"><span class="linenos">3468</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFERRABLE"</span><span class="p">):</span> +</span><span id="L-3469"><a href="#L-3469"><span class="linenos">3469</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"DEFERRABLE"</span><span class="p">)</span> +</span><span id="L-3470"><a href="#L-3470"><span class="linenos">3470</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INITIALLY"</span><span class="p">,</span> <span class="s2">"DEFERRED"</span><span class="p">):</span> +</span><span id="L-3471"><a href="#L-3471"><span class="linenos">3471</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"INITIALLY DEFERRED"</span><span class="p">)</span> +</span><span id="L-3472"><a href="#L-3472"><span class="linenos">3472</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NORELY"</span><span class="p">):</span> +</span><span id="L-3473"><a href="#L-3473"><span class="linenos">3473</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"NORELY"</span><span class="p">)</span> +</span><span id="L-3474"><a href="#L-3474"><span class="linenos">3474</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MATCH"</span><span class="p">,</span> <span class="s2">"FULL"</span><span class="p">):</span> +</span><span id="L-3475"><a href="#L-3475"><span class="linenos">3475</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"MATCH FULL"</span><span class="p">)</span> +</span><span id="L-3476"><a href="#L-3476"><span class="linenos">3476</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3477"><a href="#L-3477"><span class="linenos">3477</span></a> <span class="k">break</span> +</span><span id="L-3478"><a href="#L-3478"><span class="linenos">3478</span></a> +</span><span id="L-3479"><a href="#L-3479"><span class="linenos">3479</span></a> <span class="k">return</span> <span class="n">options</span> </span><span id="L-3480"><a href="#L-3480"><span class="linenos">3480</span></a> -</span><span id="L-3481"><a href="#L-3481"><span class="linenos">3481</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-3482"><a href="#L-3482"><span class="linenos">3482</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="L-3483"><a href="#L-3483"><span class="linenos">3483</span></a> -</span><span id="L-3484"><a href="#L-3484"><span class="linenos">3484</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_PAREN</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-3485"><a href="#L-3485"><span class="linenos">3485</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_id_vars</span><span class="p">()</span> -</span><span id="L-3486"><a href="#L-3486"><span class="linenos">3486</span></a> -</span><span id="L-3487"><a href="#L-3487"><span class="linenos">3487</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_key_constraint_options</span><span class="p">()</span> -</span><span id="L-3488"><a href="#L-3488"><span class="linenos">3488</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">Reference</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="n">options</span><span class="p">)</span> -</span><span id="L-3489"><a href="#L-3489"><span class="linenos">3489</span></a> -</span><span id="L-3490"><a href="#L-3490"><span class="linenos">3490</span></a> <span class="k">def</span> <span class="nf">_parse_foreign_key</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">ForeignKey</span><span class="p">:</span> -</span><span id="L-3491"><a href="#L-3491"><span class="linenos">3491</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_id_vars</span><span class="p">()</span> -</span><span id="L-3492"><a href="#L-3492"><span class="linenos">3492</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_references</span><span class="p">()</span> -</span><span id="L-3493"><a href="#L-3493"><span class="linenos">3493</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-3494"><a href="#L-3494"><span class="linenos">3494</span></a> -</span><span id="L-3495"><a href="#L-3495"><span class="linenos">3495</span></a> <span class="k">while</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">ON</span><span class="p">):</span> -</span><span id="L-3496"><a href="#L-3496"><span class="linenos">3496</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DELETE</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UPDATE</span><span class="p">)):</span> -</span><span id="L-3497"><a href="#L-3497"><span class="linenos">3497</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected DELETE or UPDATE"</span><span class="p">)</span> +</span><span id="L-3481"><a href="#L-3481"><span class="linenos">3481</span></a> <span class="k">def</span> <span class="nf">_parse_references</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">match</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="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">Reference</span><span class="p">]:</span> +</span><span id="L-3482"><a href="#L-3482"><span class="linenos">3482</span></a> <span class="k">if</span> <span class="n">match</span> <span class="ow">and</span> <span class="ow">not</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">REFERENCES</span><span class="p">):</span> +</span><span id="L-3483"><a href="#L-3483"><span class="linenos">3483</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-3484"><a href="#L-3484"><span class="linenos">3484</span></a> +</span><span id="L-3485"><a href="#L-3485"><span class="linenos">3485</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3486"><a href="#L-3486"><span class="linenos">3486</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="L-3487"><a href="#L-3487"><span class="linenos">3487</span></a> +</span><span id="L-3488"><a href="#L-3488"><span class="linenos">3488</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_PAREN</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-3489"><a href="#L-3489"><span class="linenos">3489</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_id_vars</span><span class="p">()</span> +</span><span id="L-3490"><a href="#L-3490"><span class="linenos">3490</span></a> +</span><span id="L-3491"><a href="#L-3491"><span class="linenos">3491</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_key_constraint_options</span><span class="p">()</span> +</span><span id="L-3492"><a href="#L-3492"><span class="linenos">3492</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">Reference</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="n">options</span><span class="p">)</span> +</span><span id="L-3493"><a href="#L-3493"><span class="linenos">3493</span></a> +</span><span id="L-3494"><a href="#L-3494"><span class="linenos">3494</span></a> <span class="k">def</span> <span class="nf">_parse_foreign_key</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">ForeignKey</span><span class="p">:</span> +</span><span id="L-3495"><a href="#L-3495"><span class="linenos">3495</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_id_vars</span><span class="p">()</span> +</span><span id="L-3496"><a href="#L-3496"><span class="linenos">3496</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_references</span><span class="p">()</span> +</span><span id="L-3497"><a href="#L-3497"><span class="linenos">3497</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">{}</span> </span><span id="L-3498"><a href="#L-3498"><span class="linenos">3498</span></a> -</span><span id="L-3499"><a href="#L-3499"><span class="linenos">3499</span></a> <span class="n">kind</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="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="L-3500"><a href="#L-3500"><span class="linenos">3500</span></a> -</span><span id="L-3501"><a href="#L-3501"><span class="linenos">3501</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"ACTION"</span><span class="p">):</span> -</span><span id="L-3502"><a href="#L-3502"><span class="linenos">3502</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"NO ACTION"</span> -</span><span id="L-3503"><a href="#L-3503"><span class="linenos">3503</span></a> <span class="k">elif</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">SET</span><span class="p">):</span> -</span><span id="L-3504"><a href="#L-3504"><span class="linenos">3504</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">))</span> -</span><span id="L-3505"><a href="#L-3505"><span class="linenos">3505</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"SET "</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="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-3506"><a href="#L-3506"><span class="linenos">3506</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3507"><a href="#L-3507"><span class="linenos">3507</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-3508"><a href="#L-3508"><span class="linenos">3508</span></a> <span class="n">action</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="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-3509"><a href="#L-3509"><span class="linenos">3509</span></a> -</span><span id="L-3510"><a href="#L-3510"><span class="linenos">3510</span></a> <span class="n">options</span><span class="p">[</span><span class="n">kind</span><span class="p">]</span> <span class="o">=</span> <span class="n">action</span> -</span><span id="L-3511"><a href="#L-3511"><span class="linenos">3511</span></a> -</span><span id="L-3512"><a href="#L-3512"><span class="linenos">3512</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><span id="L-3513"><a href="#L-3513"><span class="linenos">3513</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">reference</span><span class="o">=</span><span class="n">reference</span><span class="p">,</span> <span class="o">**</span><span class="n">options</span> <span class="c1"># type: ignore</span> -</span><span id="L-3514"><a href="#L-3514"><span class="linenos">3514</span></a> <span class="p">)</span> +</span><span id="L-3499"><a href="#L-3499"><span class="linenos">3499</span></a> <span class="k">while</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">ON</span><span class="p">):</span> +</span><span id="L-3500"><a href="#L-3500"><span class="linenos">3500</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DELETE</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UPDATE</span><span class="p">)):</span> +</span><span id="L-3501"><a href="#L-3501"><span class="linenos">3501</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected DELETE or UPDATE"</span><span class="p">)</span> +</span><span id="L-3502"><a href="#L-3502"><span class="linenos">3502</span></a> +</span><span id="L-3503"><a href="#L-3503"><span class="linenos">3503</span></a> <span class="n">kind</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="o">.</span><span class="n">lower</span><span class="p">()</span> +</span><span id="L-3504"><a href="#L-3504"><span class="linenos">3504</span></a> +</span><span id="L-3505"><a href="#L-3505"><span class="linenos">3505</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"ACTION"</span><span class="p">):</span> +</span><span id="L-3506"><a href="#L-3506"><span class="linenos">3506</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"NO ACTION"</span> +</span><span id="L-3507"><a href="#L-3507"><span class="linenos">3507</span></a> <span class="k">elif</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">SET</span><span class="p">):</span> +</span><span id="L-3508"><a href="#L-3508"><span class="linenos">3508</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">))</span> +</span><span id="L-3509"><a href="#L-3509"><span class="linenos">3509</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"SET "</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="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-3510"><a href="#L-3510"><span class="linenos">3510</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3511"><a href="#L-3511"><span class="linenos">3511</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-3512"><a href="#L-3512"><span class="linenos">3512</span></a> <span class="n">action</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="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-3513"><a href="#L-3513"><span class="linenos">3513</span></a> +</span><span id="L-3514"><a href="#L-3514"><span class="linenos">3514</span></a> <span class="n">options</span><span class="p">[</span><span class="n">kind</span><span class="p">]</span> <span class="o">=</span> <span class="n">action</span> </span><span id="L-3515"><a href="#L-3515"><span class="linenos">3515</span></a> -</span><span id="L-3516"><a href="#L-3516"><span class="linenos">3516</span></a> <span class="k">def</span> <span class="nf">_parse_primary_key</span><span class="p">(</span> -</span><span id="L-3517"><a href="#L-3517"><span class="linenos">3517</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">wrapped_optional</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="n">in_props</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-3518"><a href="#L-3518"><span class="linenos">3518</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKeyColumnConstraint</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKey</span><span class="p">:</span> -</span><span id="L-3519"><a href="#L-3519"><span class="linenos">3519</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-3520"><a href="#L-3520"><span class="linenos">3520</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ASC</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DESC</span><span class="p">))</span> -</span><span id="L-3521"><a href="#L-3521"><span class="linenos">3521</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DESC</span> -</span><span id="L-3522"><a href="#L-3522"><span class="linenos">3522</span></a> <span class="p">)</span> -</span><span id="L-3523"><a href="#L-3523"><span class="linenos">3523</span></a> -</span><span id="L-3524"><a href="#L-3524"><span class="linenos">3524</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">in_props</span> <span class="ow">and</span> <span class="ow">not</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_PAREN</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-3525"><a href="#L-3525"><span class="linenos">3525</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">PrimaryKeyColumnConstraint</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="n">desc</span><span class="p">)</span> -</span><span id="L-3526"><a href="#L-3526"><span class="linenos">3526</span></a> -</span><span id="L-3527"><a href="#L-3527"><span class="linenos">3527</span></a> <span class="n">expressions</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_field</span><span class="p">,</span> <span class="n">optional</span><span class="o">=</span><span class="n">wrapped_optional</span><span class="p">)</span> -</span><span id="L-3528"><a href="#L-3528"><span class="linenos">3528</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_key_constraint_options</span><span class="p">()</span> -</span><span id="L-3529"><a href="#L-3529"><span class="linenos">3529</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">PrimaryKey</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="n">options</span><span class="p">)</span> +</span><span id="L-3516"><a href="#L-3516"><span class="linenos">3516</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><span id="L-3517"><a href="#L-3517"><span class="linenos">3517</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">reference</span><span class="o">=</span><span class="n">reference</span><span class="p">,</span> <span class="o">**</span><span class="n">options</span> <span class="c1"># type: ignore</span> +</span><span id="L-3518"><a href="#L-3518"><span class="linenos">3518</span></a> <span class="p">)</span> +</span><span id="L-3519"><a href="#L-3519"><span class="linenos">3519</span></a> +</span><span id="L-3520"><a href="#L-3520"><span class="linenos">3520</span></a> <span class="k">def</span> <span class="nf">_parse_primary_key</span><span class="p">(</span> +</span><span id="L-3521"><a href="#L-3521"><span class="linenos">3521</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">wrapped_optional</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="n">in_props</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-3522"><a href="#L-3522"><span class="linenos">3522</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKeyColumnConstraint</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKey</span><span class="p">:</span> +</span><span id="L-3523"><a href="#L-3523"><span class="linenos">3523</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-3524"><a href="#L-3524"><span class="linenos">3524</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ASC</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DESC</span><span class="p">))</span> +</span><span id="L-3525"><a href="#L-3525"><span class="linenos">3525</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DESC</span> +</span><span id="L-3526"><a href="#L-3526"><span class="linenos">3526</span></a> <span class="p">)</span> +</span><span id="L-3527"><a href="#L-3527"><span class="linenos">3527</span></a> +</span><span id="L-3528"><a href="#L-3528"><span class="linenos">3528</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">in_props</span> <span class="ow">and</span> <span class="ow">not</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_PAREN</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-3529"><a href="#L-3529"><span class="linenos">3529</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">PrimaryKeyColumnConstraint</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="n">desc</span><span class="p">)</span> </span><span id="L-3530"><a href="#L-3530"><span class="linenos">3530</span></a> -</span><span id="L-3531"><a href="#L-3531"><span class="linenos">3531</span></a> <span class="k">def</span> <span class="nf">_parse_bracket</span><span class="p">(</span><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="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-3532"><a href="#L-3532"><span class="linenos">3532</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</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><span id="L-3533"><a href="#L-3533"><span class="linenos">3533</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-3531"><a href="#L-3531"><span class="linenos">3531</span></a> <span class="n">expressions</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_field</span><span class="p">,</span> <span class="n">optional</span><span class="o">=</span><span class="n">wrapped_optional</span><span class="p">)</span> +</span><span id="L-3532"><a href="#L-3532"><span class="linenos">3532</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_key_constraint_options</span><span class="p">()</span> +</span><span id="L-3533"><a href="#L-3533"><span class="linenos">3533</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">PrimaryKey</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="n">options</span><span class="p">)</span> </span><span id="L-3534"><a href="#L-3534"><span class="linenos">3534</span></a> -</span><span id="L-3535"><a href="#L-3535"><span class="linenos">3535</span></a> <span class="n">bracket_kind</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">token_type</span> -</span><span id="L-3536"><a href="#L-3536"><span class="linenos">3536</span></a> -</span><span id="L-3537"><a href="#L-3537"><span class="linenos">3537</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">COLON</span><span class="p">):</span> -</span><span id="L-3538"><a href="#L-3538"><span class="linenos">3538</span></a> <span class="n">expressions</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">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="p">[</span> -</span><span id="L-3539"><a href="#L-3539"><span class="linenos">3539</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">Slice</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">())</span> -</span><span id="L-3540"><a href="#L-3540"><span class="linenos">3540</span></a> <span class="p">]</span> -</span><span id="L-3541"><a href="#L-3541"><span class="linenos">3541</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3542"><a href="#L-3542"><span class="linenos">3542</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_slice</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()))</span> -</span><span id="L-3543"><a href="#L-3543"><span class="linenos">3543</span></a> -</span><span id="L-3544"><a href="#L-3544"><span class="linenos">3544</span></a> <span class="c1"># https://duckdb.org/docs/sql/data_types/struct.html#creating-structs</span> -</span><span id="L-3545"><a href="#L-3545"><span class="linenos">3545</span></a> <span class="k">if</span> <span class="n">bracket_kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACE</span><span class="p">:</span> -</span><span id="L-3546"><a href="#L-3546"><span class="linenos">3546</span></a> <span class="n">this</span> <span class="o">=</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">Struct</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-3547"><a href="#L-3547"><span class="linenos">3547</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">this</span> <span class="ow">or</span> <span class="n">this</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">"ARRAY"</span><span class="p">:</span> -</span><span id="L-3548"><a href="#L-3548"><span class="linenos">3548</span></a> <span class="n">this</span> <span class="o">=</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">Array</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-3549"><a href="#L-3549"><span class="linenos">3549</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3550"><a href="#L-3550"><span class="linenos">3550</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">apply_index_offset</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="p">,</span> <span class="o">-</span><span class="bp">self</span><span class="o">.</span><span class="n">INDEX_OFFSET</span><span class="p">)</span> -</span><span id="L-3551"><a href="#L-3551"><span class="linenos">3551</span></a> <span class="n">this</span> <span class="o">=</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">Bracket</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-3552"><a href="#L-3552"><span class="linenos">3552</span></a> -</span><span id="L-3553"><a href="#L-3553"><span class="linenos">3553</span></a> <span class="k">if</span> <span class="ow">not</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">R_BRACKET</span><span class="p">)</span> <span class="ow">and</span> <span class="n">bracket_kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">:</span> -</span><span id="L-3554"><a href="#L-3554"><span class="linenos">3554</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected ]"</span><span class="p">)</span> -</span><span id="L-3555"><a href="#L-3555"><span class="linenos">3555</span></a> <span class="k">elif</span> <span class="ow">not</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">R_BRACE</span><span class="p">)</span> <span class="ow">and</span> <span class="n">bracket_kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACE</span><span class="p">:</span> -</span><span id="L-3556"><a href="#L-3556"><span class="linenos">3556</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected }"</span><span class="p">)</span> -</span><span id="L-3557"><a href="#L-3557"><span class="linenos">3557</span></a> -</span><span id="L-3558"><a href="#L-3558"><span class="linenos">3558</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add_comments</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-3559"><a href="#L-3559"><span class="linenos">3559</span></a> <span class="k">return</span> <span class="bp">self</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-3560"><a href="#L-3560"><span class="linenos">3560</span></a> -</span><span id="L-3561"><a href="#L-3561"><span class="linenos">3561</span></a> <span class="k">def</span> <span class="nf">_parse_slice</span><span class="p">(</span><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="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-3562"><a href="#L-3562"><span class="linenos">3562</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">COLON</span><span class="p">):</span> -</span><span id="L-3563"><a href="#L-3563"><span class="linenos">3563</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">Slice</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">())</span> -</span><span id="L-3564"><a href="#L-3564"><span class="linenos">3564</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-3565"><a href="#L-3565"><span class="linenos">3565</span></a> -</span><span id="L-3566"><a href="#L-3566"><span class="linenos">3566</span></a> <span class="k">def</span> <span class="nf">_parse_case</span><span class="p">(</span><span class="bp">self</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-3567"><a href="#L-3567"><span class="linenos">3567</span></a> <span class="n">ifs</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-3568"><a href="#L-3568"><span class="linenos">3568</span></a> <span class="n">default</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3535"><a href="#L-3535"><span class="linenos">3535</span></a> <span class="k">def</span> <span class="nf">_parse_bracket</span><span class="p">(</span><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="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-3536"><a href="#L-3536"><span class="linenos">3536</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</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><span id="L-3537"><a href="#L-3537"><span class="linenos">3537</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-3538"><a href="#L-3538"><span class="linenos">3538</span></a> +</span><span id="L-3539"><a href="#L-3539"><span class="linenos">3539</span></a> <span class="n">bracket_kind</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">token_type</span> +</span><span id="L-3540"><a href="#L-3540"><span class="linenos">3540</span></a> +</span><span id="L-3541"><a href="#L-3541"><span class="linenos">3541</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">COLON</span><span class="p">):</span> +</span><span id="L-3542"><a href="#L-3542"><span class="linenos">3542</span></a> <span class="n">expressions</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">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="p">[</span> +</span><span id="L-3543"><a href="#L-3543"><span class="linenos">3543</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">Slice</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">())</span> +</span><span id="L-3544"><a href="#L-3544"><span class="linenos">3544</span></a> <span class="p">]</span> +</span><span id="L-3545"><a href="#L-3545"><span class="linenos">3545</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3546"><a href="#L-3546"><span class="linenos">3546</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_slice</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()))</span> +</span><span id="L-3547"><a href="#L-3547"><span class="linenos">3547</span></a> +</span><span id="L-3548"><a href="#L-3548"><span class="linenos">3548</span></a> <span class="c1"># https://duckdb.org/docs/sql/data_types/struct.html#creating-structs</span> +</span><span id="L-3549"><a href="#L-3549"><span class="linenos">3549</span></a> <span class="k">if</span> <span class="n">bracket_kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACE</span><span class="p">:</span> +</span><span id="L-3550"><a href="#L-3550"><span class="linenos">3550</span></a> <span class="n">this</span> <span class="o">=</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">Struct</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-3551"><a href="#L-3551"><span class="linenos">3551</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">this</span> <span class="ow">or</span> <span class="n">this</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">"ARRAY"</span><span class="p">:</span> +</span><span id="L-3552"><a href="#L-3552"><span class="linenos">3552</span></a> <span class="n">this</span> <span class="o">=</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">Array</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-3553"><a href="#L-3553"><span class="linenos">3553</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3554"><a href="#L-3554"><span class="linenos">3554</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">apply_index_offset</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="p">,</span> <span class="o">-</span><span class="bp">self</span><span class="o">.</span><span class="n">INDEX_OFFSET</span><span class="p">)</span> +</span><span id="L-3555"><a href="#L-3555"><span class="linenos">3555</span></a> <span class="n">this</span> <span class="o">=</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">Bracket</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-3556"><a href="#L-3556"><span class="linenos">3556</span></a> +</span><span id="L-3557"><a href="#L-3557"><span class="linenos">3557</span></a> <span class="k">if</span> <span class="ow">not</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">R_BRACKET</span><span class="p">)</span> <span class="ow">and</span> <span class="n">bracket_kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">:</span> +</span><span id="L-3558"><a href="#L-3558"><span class="linenos">3558</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected ]"</span><span class="p">)</span> +</span><span id="L-3559"><a href="#L-3559"><span class="linenos">3559</span></a> <span class="k">elif</span> <span class="ow">not</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">R_BRACE</span><span class="p">)</span> <span class="ow">and</span> <span class="n">bracket_kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACE</span><span class="p">:</span> +</span><span id="L-3560"><a href="#L-3560"><span class="linenos">3560</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected }"</span><span class="p">)</span> +</span><span id="L-3561"><a href="#L-3561"><span class="linenos">3561</span></a> +</span><span id="L-3562"><a href="#L-3562"><span class="linenos">3562</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add_comments</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-3563"><a href="#L-3563"><span class="linenos">3563</span></a> <span class="k">return</span> <span class="bp">self</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-3564"><a href="#L-3564"><span class="linenos">3564</span></a> +</span><span id="L-3565"><a href="#L-3565"><span class="linenos">3565</span></a> <span class="k">def</span> <span class="nf">_parse_slice</span><span class="p">(</span><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="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-3566"><a href="#L-3566"><span class="linenos">3566</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">COLON</span><span class="p">):</span> +</span><span id="L-3567"><a href="#L-3567"><span class="linenos">3567</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">Slice</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">())</span> +</span><span id="L-3568"><a href="#L-3568"><span class="linenos">3568</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="L-3569"><a href="#L-3569"><span class="linenos">3569</span></a> -</span><span id="L-3570"><a href="#L-3570"><span class="linenos">3570</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="L-3571"><a href="#L-3571"><span class="linenos">3571</span></a> -</span><span id="L-3572"><a href="#L-3572"><span class="linenos">3572</span></a> <span class="k">while</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">WHEN</span><span class="p">):</span> -</span><span id="L-3573"><a href="#L-3573"><span class="linenos">3573</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="L-3574"><a href="#L-3574"><span class="linenos">3574</span></a> <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">THEN</span><span class="p">)</span> -</span><span id="L-3575"><a href="#L-3575"><span class="linenos">3575</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="L-3576"><a href="#L-3576"><span class="linenos">3576</span></a> <span class="n">ifs</span><span class="o">.</span><span class="n">append</span><span class="p">(</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">If</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">true</span><span class="o">=</span><span class="n">then</span><span class="p">))</span> -</span><span id="L-3577"><a href="#L-3577"><span class="linenos">3577</span></a> -</span><span id="L-3578"><a href="#L-3578"><span class="linenos">3578</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">ELSE</span><span class="p">):</span> -</span><span id="L-3579"><a href="#L-3579"><span class="linenos">3579</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="L-3580"><a href="#L-3580"><span class="linenos">3580</span></a> -</span><span id="L-3581"><a href="#L-3581"><span class="linenos">3581</span></a> <span class="k">if</span> <span class="ow">not</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">END</span><span class="p">):</span> -</span><span id="L-3582"><a href="#L-3582"><span class="linenos">3582</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected END after CASE"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> -</span><span id="L-3583"><a href="#L-3583"><span class="linenos">3583</span></a> -</span><span id="L-3584"><a href="#L-3584"><span class="linenos">3584</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window</span><span class="p">(</span> -</span><span id="L-3585"><a href="#L-3585"><span class="linenos">3585</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">Case</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">ifs</span><span class="o">=</span><span class="n">ifs</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">default</span><span class="p">)</span> -</span><span id="L-3586"><a href="#L-3586"><span class="linenos">3586</span></a> <span class="p">)</span> +</span><span id="L-3570"><a href="#L-3570"><span class="linenos">3570</span></a> <span class="k">def</span> <span class="nf">_parse_case</span><span class="p">(</span><span class="bp">self</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-3571"><a href="#L-3571"><span class="linenos">3571</span></a> <span class="n">ifs</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-3572"><a href="#L-3572"><span class="linenos">3572</span></a> <span class="n">default</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3573"><a href="#L-3573"><span class="linenos">3573</span></a> +</span><span id="L-3574"><a href="#L-3574"><span class="linenos">3574</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="L-3575"><a href="#L-3575"><span class="linenos">3575</span></a> +</span><span id="L-3576"><a href="#L-3576"><span class="linenos">3576</span></a> <span class="k">while</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">WHEN</span><span class="p">):</span> +</span><span id="L-3577"><a href="#L-3577"><span class="linenos">3577</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="L-3578"><a href="#L-3578"><span class="linenos">3578</span></a> <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">THEN</span><span class="p">)</span> +</span><span id="L-3579"><a href="#L-3579"><span class="linenos">3579</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="L-3580"><a href="#L-3580"><span class="linenos">3580</span></a> <span class="n">ifs</span><span class="o">.</span><span class="n">append</span><span class="p">(</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">If</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">true</span><span class="o">=</span><span class="n">then</span><span class="p">))</span> +</span><span id="L-3581"><a href="#L-3581"><span class="linenos">3581</span></a> +</span><span id="L-3582"><a href="#L-3582"><span class="linenos">3582</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">ELSE</span><span class="p">):</span> +</span><span id="L-3583"><a href="#L-3583"><span class="linenos">3583</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="L-3584"><a href="#L-3584"><span class="linenos">3584</span></a> +</span><span id="L-3585"><a href="#L-3585"><span class="linenos">3585</span></a> <span class="k">if</span> <span class="ow">not</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">END</span><span class="p">):</span> +</span><span id="L-3586"><a href="#L-3586"><span class="linenos">3586</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected END after CASE"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> </span><span id="L-3587"><a href="#L-3587"><span class="linenos">3587</span></a> -</span><span id="L-3588"><a href="#L-3588"><span class="linenos">3588</span></a> <span class="k">def</span> <span class="nf">_parse_if</span><span class="p">(</span><span class="bp">self</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-3589"><a href="#L-3589"><span class="linenos">3589</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_PAREN</span><span class="p">):</span> -</span><span id="L-3590"><a href="#L-3590"><span class="linenos">3590</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="L-3591"><a href="#L-3591"><span class="linenos">3591</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="n">args</span><span class="p">)</span> -</span><span id="L-3592"><a href="#L-3592"><span class="linenos">3592</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="L-3593"><a href="#L-3593"><span class="linenos">3593</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3594"><a href="#L-3594"><span class="linenos">3594</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span> -</span><span id="L-3595"><a href="#L-3595"><span class="linenos">3595</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="L-3596"><a href="#L-3596"><span class="linenos">3596</span></a> -</span><span id="L-3597"><a href="#L-3597"><span class="linenos">3597</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">condition</span><span class="p">:</span> -</span><span id="L-3598"><a href="#L-3598"><span class="linenos">3598</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-3599"><a href="#L-3599"><span class="linenos">3599</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-3588"><a href="#L-3588"><span class="linenos">3588</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window</span><span class="p">(</span> +</span><span id="L-3589"><a href="#L-3589"><span class="linenos">3589</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">Case</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">ifs</span><span class="o">=</span><span class="n">ifs</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">default</span><span class="p">)</span> +</span><span id="L-3590"><a href="#L-3590"><span class="linenos">3590</span></a> <span class="p">)</span> +</span><span id="L-3591"><a href="#L-3591"><span class="linenos">3591</span></a> +</span><span id="L-3592"><a href="#L-3592"><span class="linenos">3592</span></a> <span class="k">def</span> <span class="nf">_parse_if</span><span class="p">(</span><span class="bp">self</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-3593"><a href="#L-3593"><span class="linenos">3593</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_PAREN</span><span class="p">):</span> +</span><span id="L-3594"><a href="#L-3594"><span class="linenos">3594</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="L-3595"><a href="#L-3595"><span class="linenos">3595</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="n">args</span><span class="p">)</span> +</span><span id="L-3596"><a href="#L-3596"><span class="linenos">3596</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-3597"><a href="#L-3597"><span class="linenos">3597</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3598"><a href="#L-3598"><span class="linenos">3598</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span> +</span><span id="L-3599"><a href="#L-3599"><span class="linenos">3599</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> </span><span id="L-3600"><a href="#L-3600"><span class="linenos">3600</span></a> -</span><span id="L-3601"><a href="#L-3601"><span class="linenos">3601</span></a> <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">THEN</span><span class="p">)</span> -</span><span id="L-3602"><a href="#L-3602"><span class="linenos">3602</span></a> <span class="n">true</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="L-3603"><a href="#L-3603"><span class="linenos">3603</span></a> <span class="n">false</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> <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">ELSE</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="L-3604"><a href="#L-3604"><span class="linenos">3604</span></a> <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">END</span><span class="p">)</span> -</span><span id="L-3605"><a href="#L-3605"><span class="linenos">3605</span></a> <span class="n">this</span> <span class="o">=</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">If</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">condition</span><span class="p">,</span> <span class="n">true</span><span class="o">=</span><span class="n">true</span><span class="p">,</span> <span class="n">false</span><span class="o">=</span><span class="n">false</span><span class="p">)</span> -</span><span id="L-3606"><a href="#L-3606"><span class="linenos">3606</span></a> -</span><span id="L-3607"><a href="#L-3607"><span class="linenos">3607</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-3608"><a href="#L-3608"><span class="linenos">3608</span></a> -</span><span id="L-3609"><a href="#L-3609"><span class="linenos">3609</span></a> <span class="k">def</span> <span class="nf">_parse_extract</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">Extract</span><span class="p">:</span> -</span><span id="L-3610"><a href="#L-3610"><span class="linenos">3610</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">()</span> -</span><span id="L-3611"><a href="#L-3611"><span class="linenos">3611</span></a> -</span><span id="L-3612"><a href="#L-3612"><span class="linenos">3612</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">FROM</span><span class="p">):</span> -</span><span id="L-3613"><a href="#L-3613"><span class="linenos">3613</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">Extract</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> -</span><span id="L-3614"><a href="#L-3614"><span class="linenos">3614</span></a> -</span><span id="L-3615"><a href="#L-3615"><span class="linenos">3615</span></a> <span class="k">if</span> <span class="ow">not</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">COMMA</span><span class="p">):</span> -</span><span id="L-3616"><a href="#L-3616"><span class="linenos">3616</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected FROM or comma after EXTRACT"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> -</span><span id="L-3617"><a href="#L-3617"><span class="linenos">3617</span></a> -</span><span id="L-3618"><a href="#L-3618"><span class="linenos">3618</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">Extract</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> -</span><span id="L-3619"><a href="#L-3619"><span class="linenos">3619</span></a> -</span><span id="L-3620"><a href="#L-3620"><span class="linenos">3620</span></a> <span class="k">def</span> <span class="nf">_parse_cast</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">strict</span><span class="p">:</span> <span class="nb">bool</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="L-3621"><a href="#L-3621"><span class="linenos">3621</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="L-3622"><a href="#L-3622"><span class="linenos">3622</span></a> -</span><span id="L-3623"><a href="#L-3623"><span class="linenos">3623</span></a> <span class="k">if</span> <span class="ow">not</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">ALIAS</span><span class="p">):</span> -</span><span id="L-3624"><a href="#L-3624"><span class="linenos">3624</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">COMMA</span><span class="p">):</span> -</span><span id="L-3625"><a href="#L-3625"><span class="linenos">3625</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><span id="L-3626"><a href="#L-3626"><span class="linenos">3626</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CastToStrType</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="L-3627"><a href="#L-3627"><span class="linenos">3627</span></a> <span class="p">)</span> -</span><span id="L-3628"><a href="#L-3628"><span class="linenos">3628</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3629"><a href="#L-3629"><span class="linenos">3629</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected AS after CAST"</span><span class="p">)</span> -</span><span id="L-3630"><a href="#L-3630"><span class="linenos">3630</span></a> -</span><span id="L-3631"><a href="#L-3631"><span class="linenos">3631</span></a> <span class="n">to</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">()</span> -</span><span id="L-3632"><a href="#L-3632"><span class="linenos">3632</span></a> -</span><span id="L-3633"><a href="#L-3633"><span class="linenos">3633</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">to</span><span class="p">:</span> -</span><span id="L-3634"><a href="#L-3634"><span class="linenos">3634</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected TYPE after CAST"</span><span class="p">)</span> -</span><span id="L-3635"><a href="#L-3635"><span class="linenos">3635</span></a> <span class="k">elif</span> <span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">CHAR</span><span class="p">:</span> -</span><span id="L-3636"><a href="#L-3636"><span class="linenos">3636</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">CHARACTER_SET</span><span class="p">):</span> -</span><span id="L-3637"><a href="#L-3637"><span class="linenos">3637</span></a> <span class="n">to</span> <span class="o">=</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">CharacterSet</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_var_or_string</span><span class="p">())</span> -</span><span id="L-3638"><a href="#L-3638"><span class="linenos">3638</span></a> <span class="k">elif</span> <span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEMPORAL_TYPES</span> <span class="ow">and</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">FORMAT</span><span class="p">):</span> -</span><span id="L-3639"><a href="#L-3639"><span class="linenos">3639</span></a> <span class="n">fmt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="L-3640"><a href="#L-3640"><span class="linenos">3640</span></a> -</span><span id="L-3641"><a href="#L-3641"><span class="linenos">3641</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><span id="L-3642"><a href="#L-3642"><span class="linenos">3642</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span> <span class="k">if</span> <span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATE</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">,</span> -</span><span id="L-3643"><a href="#L-3643"><span class="linenos">3643</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-3644"><a href="#L-3644"><span class="linenos">3644</span></a> <span class="nb">format</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><span id="L-3645"><a href="#L-3645"><span class="linenos">3645</span></a> <span class="n">format_time</span><span class="p">(</span> -</span><span id="L-3646"><a href="#L-3646"><span class="linenos">3646</span></a> <span class="n">fmt</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">fmt</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="L-3647"><a href="#L-3647"><span class="linenos">3647</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">FORMAT_MAPPING</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> -</span><span id="L-3648"><a href="#L-3648"><span class="linenos">3648</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">FORMAT_TRIE</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_TRIE</span><span class="p">,</span> -</span><span id="L-3649"><a href="#L-3649"><span class="linenos">3649</span></a> <span class="p">)</span> -</span><span id="L-3650"><a href="#L-3650"><span class="linenos">3650</span></a> <span class="p">),</span> -</span><span id="L-3651"><a href="#L-3651"><span class="linenos">3651</span></a> <span class="p">)</span> -</span><span id="L-3652"><a href="#L-3652"><span class="linenos">3652</span></a> -</span><span id="L-3653"><a href="#L-3653"><span class="linenos">3653</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">Cast</span> <span class="k">if</span> <span class="n">strict</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="n">to</span><span class="p">)</span> -</span><span id="L-3654"><a href="#L-3654"><span class="linenos">3654</span></a> -</span><span id="L-3655"><a href="#L-3655"><span class="linenos">3655</span></a> <span class="k">def</span> <span class="nf">_parse_concat</span><span class="p">(</span><span class="bp">self</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-3656"><a href="#L-3656"><span class="linenos">3656</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="L-3657"><a href="#L-3657"><span class="linenos">3657</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONCAT_NULL_OUTPUTS_STRING</span><span class="p">:</span> -</span><span id="L-3658"><a href="#L-3658"><span class="linenos">3658</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"COALESCE"</span><span class="p">,</span> <span class="n">arg</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">))</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">]</span> -</span><span id="L-3659"><a href="#L-3659"><span class="linenos">3659</span></a> -</span><span id="L-3660"><a href="#L-3660"><span class="linenos">3660</span></a> <span class="c1"># Some dialects (e.g. Trino) don't allow a single-argument CONCAT call, so when</span> -</span><span id="L-3661"><a href="#L-3661"><span class="linenos">3661</span></a> <span class="c1"># we find such a call we replace it with its argument.</span> -</span><span id="L-3662"><a href="#L-3662"><span class="linenos">3662</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-3663"><a href="#L-3663"><span class="linenos">3663</span></a> <span class="k">return</span> <span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="L-3664"><a href="#L-3664"><span class="linenos">3664</span></a> -</span><span id="L-3665"><a href="#L-3665"><span class="linenos">3665</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><span id="L-3666"><a href="#L-3666"><span class="linenos">3666</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">args</span> -</span><span id="L-3667"><a href="#L-3667"><span class="linenos">3667</span></a> <span class="p">)</span> -</span><span id="L-3668"><a href="#L-3668"><span class="linenos">3668</span></a> -</span><span id="L-3669"><a href="#L-3669"><span class="linenos">3669</span></a> <span class="k">def</span> <span class="nf">_parse_string_agg</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">Expression</span><span class="p">:</span> -</span><span id="L-3670"><a href="#L-3670"><span class="linenos">3670</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> -</span><span id="L-3671"><a href="#L-3671"><span class="linenos">3671</span></a> -</span><span id="L-3672"><a href="#L-3672"><span class="linenos">3672</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">DISTINCT</span><span class="p">):</span> -</span><span id="L-3673"><a href="#L-3673"><span class="linenos">3673</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="L-3674"><a href="#L-3674"><span class="linenos">3674</span></a> <span class="n">expression</span> <span class="o">=</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">Distinct</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</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-3675"><a href="#L-3675"><span class="linenos">3675</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3676"><a href="#L-3676"><span class="linenos">3676</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="L-3677"><a href="#L-3677"><span class="linenos">3677</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">0</span><span class="p">)</span> -</span><span id="L-3678"><a href="#L-3678"><span class="linenos">3678</span></a> -</span><span id="L-3679"><a href="#L-3679"><span class="linenos">3679</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="L-3680"><a href="#L-3680"><span class="linenos">3680</span></a> <span class="k">if</span> <span class="ow">not</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">R_PAREN</span><span class="p">):</span> -</span><span id="L-3681"><a href="#L-3681"><span class="linenos">3681</span></a> <span class="c1"># postgres: STRING_AGG([DISTINCT] expression, separator [ORDER BY expression1 {ASC | DESC} [, ...]])</span> -</span><span id="L-3682"><a href="#L-3682"><span class="linenos">3682</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-3683"><a href="#L-3683"><span class="linenos">3683</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">GroupConcat</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">order</span><span class="p">,</span> <span class="n">separator</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-3684"><a href="#L-3684"><span class="linenos">3684</span></a> -</span><span id="L-3685"><a href="#L-3685"><span class="linenos">3685</span></a> <span class="c1"># Checks if we can parse an order clause: WITHIN GROUP (ORDER BY <order_by_expression_list> [ASC | DESC]).</span> -</span><span id="L-3686"><a href="#L-3686"><span class="linenos">3686</span></a> <span class="c1"># This is done "manually", instead of letting _parse_window parse it into an exp.WithinGroup node, so that</span> -</span><span id="L-3687"><a href="#L-3687"><span class="linenos">3687</span></a> <span class="c1"># the STRING_AGG call is parsed like in MySQL / SQLite and can thus be transpiled more easily to them.</span> -</span><span id="L-3688"><a href="#L-3688"><span class="linenos">3688</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITHIN"</span><span class="p">,</span> <span class="s2">"GROUP"</span><span class="p">):</span> -</span><span id="L-3689"><a href="#L-3689"><span class="linenos">3689</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-3690"><a href="#L-3690"><span class="linenos">3690</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="n">args</span><span class="p">)</span> -</span><span id="L-3691"><a href="#L-3691"><span class="linenos">3691</span></a> -</span><span id="L-3692"><a href="#L-3692"><span class="linenos">3692</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> <span class="c1"># The corresponding match_r_paren will be called in parse_function (caller)</span> -</span><span id="L-3693"><a href="#L-3693"><span class="linenos">3693</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-3694"><a href="#L-3694"><span class="linenos">3694</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">GroupConcat</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">order</span><span class="p">,</span> <span class="n">separator</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-3695"><a href="#L-3695"><span class="linenos">3695</span></a> -</span><span id="L-3696"><a href="#L-3696"><span class="linenos">3696</span></a> <span class="k">def</span> <span class="nf">_parse_convert</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">strict</span><span class="p">:</span> <span class="nb">bool</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-3697"><a href="#L-3697"><span class="linenos">3697</span></a> <span class="n">to</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><span id="L-3698"><a href="#L-3698"><span class="linenos">3698</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="L-3601"><a href="#L-3601"><span class="linenos">3601</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">condition</span><span class="p">:</span> +</span><span id="L-3602"><a href="#L-3602"><span class="linenos">3602</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-3603"><a href="#L-3603"><span class="linenos">3603</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-3604"><a href="#L-3604"><span class="linenos">3604</span></a> +</span><span id="L-3605"><a href="#L-3605"><span class="linenos">3605</span></a> <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">THEN</span><span class="p">)</span> +</span><span id="L-3606"><a href="#L-3606"><span class="linenos">3606</span></a> <span class="n">true</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="L-3607"><a href="#L-3607"><span class="linenos">3607</span></a> <span class="n">false</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> <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">ELSE</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="L-3608"><a href="#L-3608"><span class="linenos">3608</span></a> <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">END</span><span class="p">)</span> +</span><span id="L-3609"><a href="#L-3609"><span class="linenos">3609</span></a> <span class="n">this</span> <span class="o">=</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">If</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">condition</span><span class="p">,</span> <span class="n">true</span><span class="o">=</span><span class="n">true</span><span class="p">,</span> <span class="n">false</span><span class="o">=</span><span class="n">false</span><span class="p">)</span> +</span><span id="L-3610"><a href="#L-3610"><span class="linenos">3610</span></a> +</span><span id="L-3611"><a href="#L-3611"><span class="linenos">3611</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-3612"><a href="#L-3612"><span class="linenos">3612</span></a> +</span><span id="L-3613"><a href="#L-3613"><span class="linenos">3613</span></a> <span class="k">def</span> <span class="nf">_parse_extract</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">Extract</span><span class="p">:</span> +</span><span id="L-3614"><a href="#L-3614"><span class="linenos">3614</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">()</span> +</span><span id="L-3615"><a href="#L-3615"><span class="linenos">3615</span></a> +</span><span id="L-3616"><a href="#L-3616"><span class="linenos">3616</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">FROM</span><span class="p">):</span> +</span><span id="L-3617"><a href="#L-3617"><span class="linenos">3617</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">Extract</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> +</span><span id="L-3618"><a href="#L-3618"><span class="linenos">3618</span></a> +</span><span id="L-3619"><a href="#L-3619"><span class="linenos">3619</span></a> <span class="k">if</span> <span class="ow">not</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">COMMA</span><span class="p">):</span> +</span><span id="L-3620"><a href="#L-3620"><span class="linenos">3620</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected FROM or comma after EXTRACT"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="L-3621"><a href="#L-3621"><span class="linenos">3621</span></a> +</span><span id="L-3622"><a href="#L-3622"><span class="linenos">3622</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">Extract</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> +</span><span id="L-3623"><a href="#L-3623"><span class="linenos">3623</span></a> +</span><span id="L-3624"><a href="#L-3624"><span class="linenos">3624</span></a> <span class="k">def</span> <span class="nf">_parse_cast</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">strict</span><span class="p">:</span> <span class="nb">bool</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="L-3625"><a href="#L-3625"><span class="linenos">3625</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="L-3626"><a href="#L-3626"><span class="linenos">3626</span></a> +</span><span id="L-3627"><a href="#L-3627"><span class="linenos">3627</span></a> <span class="k">if</span> <span class="ow">not</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">ALIAS</span><span class="p">):</span> +</span><span id="L-3628"><a href="#L-3628"><span class="linenos">3628</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">COMMA</span><span class="p">):</span> +</span><span id="L-3629"><a href="#L-3629"><span class="linenos">3629</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><span id="L-3630"><a href="#L-3630"><span class="linenos">3630</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CastToStrType</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="L-3631"><a href="#L-3631"><span class="linenos">3631</span></a> <span class="p">)</span> +</span><span id="L-3632"><a href="#L-3632"><span class="linenos">3632</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3633"><a href="#L-3633"><span class="linenos">3633</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected AS after CAST"</span><span class="p">)</span> +</span><span id="L-3634"><a href="#L-3634"><span class="linenos">3634</span></a> +</span><span id="L-3635"><a href="#L-3635"><span class="linenos">3635</span></a> <span class="n">to</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">()</span> +</span><span id="L-3636"><a href="#L-3636"><span class="linenos">3636</span></a> +</span><span id="L-3637"><a href="#L-3637"><span class="linenos">3637</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">to</span><span class="p">:</span> +</span><span id="L-3638"><a href="#L-3638"><span class="linenos">3638</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected TYPE after CAST"</span><span class="p">)</span> +</span><span id="L-3639"><a href="#L-3639"><span class="linenos">3639</span></a> <span class="k">elif</span> <span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">CHAR</span><span class="p">:</span> +</span><span id="L-3640"><a href="#L-3640"><span class="linenos">3640</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">CHARACTER_SET</span><span class="p">):</span> +</span><span id="L-3641"><a href="#L-3641"><span class="linenos">3641</span></a> <span class="n">to</span> <span class="o">=</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">CharacterSet</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_var_or_string</span><span class="p">())</span> +</span><span id="L-3642"><a href="#L-3642"><span class="linenos">3642</span></a> <span class="k">elif</span> <span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEMPORAL_TYPES</span> <span class="ow">and</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">FORMAT</span><span class="p">):</span> +</span><span id="L-3643"><a href="#L-3643"><span class="linenos">3643</span></a> <span class="n">fmt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="L-3644"><a href="#L-3644"><span class="linenos">3644</span></a> +</span><span id="L-3645"><a href="#L-3645"><span class="linenos">3645</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><span id="L-3646"><a href="#L-3646"><span class="linenos">3646</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span> <span class="k">if</span> <span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATE</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">,</span> +</span><span id="L-3647"><a href="#L-3647"><span class="linenos">3647</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-3648"><a href="#L-3648"><span class="linenos">3648</span></a> <span class="nb">format</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><span id="L-3649"><a href="#L-3649"><span class="linenos">3649</span></a> <span class="n">format_time</span><span class="p">(</span> +</span><span id="L-3650"><a href="#L-3650"><span class="linenos">3650</span></a> <span class="n">fmt</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">fmt</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="L-3651"><a href="#L-3651"><span class="linenos">3651</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">FORMAT_MAPPING</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> +</span><span id="L-3652"><a href="#L-3652"><span class="linenos">3652</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">FORMAT_TRIE</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_TRIE</span><span class="p">,</span> +</span><span id="L-3653"><a href="#L-3653"><span class="linenos">3653</span></a> <span class="p">)</span> +</span><span id="L-3654"><a href="#L-3654"><span class="linenos">3654</span></a> <span class="p">),</span> +</span><span id="L-3655"><a href="#L-3655"><span class="linenos">3655</span></a> <span class="p">)</span> +</span><span id="L-3656"><a href="#L-3656"><span class="linenos">3656</span></a> +</span><span id="L-3657"><a href="#L-3657"><span class="linenos">3657</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">Cast</span> <span class="k">if</span> <span class="n">strict</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="n">to</span><span class="p">)</span> +</span><span id="L-3658"><a href="#L-3658"><span class="linenos">3658</span></a> +</span><span id="L-3659"><a href="#L-3659"><span class="linenos">3659</span></a> <span class="k">def</span> <span class="nf">_parse_concat</span><span class="p">(</span><span class="bp">self</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-3660"><a href="#L-3660"><span class="linenos">3660</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="L-3661"><a href="#L-3661"><span class="linenos">3661</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONCAT_NULL_OUTPUTS_STRING</span><span class="p">:</span> +</span><span id="L-3662"><a href="#L-3662"><span class="linenos">3662</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="L-3663"><a href="#L-3663"><span class="linenos">3663</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"COALESCE"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">))</span> +</span><span id="L-3664"><a href="#L-3664"><span class="linenos">3664</span></a> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span> +</span><span id="L-3665"><a href="#L-3665"><span class="linenos">3665</span></a> <span class="k">if</span> <span class="n">arg</span> +</span><span id="L-3666"><a href="#L-3666"><span class="linenos">3666</span></a> <span class="p">]</span> +</span><span id="L-3667"><a href="#L-3667"><span class="linenos">3667</span></a> +</span><span id="L-3668"><a href="#L-3668"><span class="linenos">3668</span></a> <span class="c1"># Some dialects (e.g. Trino) don't allow a single-argument CONCAT call, so when</span> +</span><span id="L-3669"><a href="#L-3669"><span class="linenos">3669</span></a> <span class="c1"># we find such a call we replace it with its argument.</span> +</span><span id="L-3670"><a href="#L-3670"><span class="linenos">3670</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-3671"><a href="#L-3671"><span class="linenos">3671</span></a> <span class="k">return</span> <span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="L-3672"><a href="#L-3672"><span class="linenos">3672</span></a> +</span><span id="L-3673"><a href="#L-3673"><span class="linenos">3673</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><span id="L-3674"><a href="#L-3674"><span class="linenos">3674</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">args</span> +</span><span id="L-3675"><a href="#L-3675"><span class="linenos">3675</span></a> <span class="p">)</span> +</span><span id="L-3676"><a href="#L-3676"><span class="linenos">3676</span></a> +</span><span id="L-3677"><a href="#L-3677"><span class="linenos">3677</span></a> <span class="k">def</span> <span class="nf">_parse_string_agg</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">Expression</span><span class="p">:</span> +</span><span id="L-3678"><a href="#L-3678"><span class="linenos">3678</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> +</span><span id="L-3679"><a href="#L-3679"><span class="linenos">3679</span></a> +</span><span id="L-3680"><a href="#L-3680"><span class="linenos">3680</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">DISTINCT</span><span class="p">):</span> +</span><span id="L-3681"><a href="#L-3681"><span class="linenos">3681</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="L-3682"><a href="#L-3682"><span class="linenos">3682</span></a> <span class="n">expression</span> <span class="o">=</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">Distinct</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</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-3683"><a href="#L-3683"><span class="linenos">3683</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3684"><a href="#L-3684"><span class="linenos">3684</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="L-3685"><a href="#L-3685"><span class="linenos">3685</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">0</span><span class="p">)</span> +</span><span id="L-3686"><a href="#L-3686"><span class="linenos">3686</span></a> +</span><span id="L-3687"><a href="#L-3687"><span class="linenos">3687</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="L-3688"><a href="#L-3688"><span class="linenos">3688</span></a> <span class="k">if</span> <span class="ow">not</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">R_PAREN</span><span class="p">):</span> +</span><span id="L-3689"><a href="#L-3689"><span class="linenos">3689</span></a> <span class="c1"># postgres: STRING_AGG([DISTINCT] expression, separator [ORDER BY expression1 {ASC | DESC} [, ...]])</span> +</span><span id="L-3690"><a href="#L-3690"><span class="linenos">3690</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-3691"><a href="#L-3691"><span class="linenos">3691</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">GroupConcat</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">order</span><span class="p">,</span> <span class="n">separator</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-3692"><a href="#L-3692"><span class="linenos">3692</span></a> +</span><span id="L-3693"><a href="#L-3693"><span class="linenos">3693</span></a> <span class="c1"># Checks if we can parse an order clause: WITHIN GROUP (ORDER BY <order_by_expression_list> [ASC | DESC]).</span> +</span><span id="L-3694"><a href="#L-3694"><span class="linenos">3694</span></a> <span class="c1"># This is done "manually", instead of letting _parse_window parse it into an exp.WithinGroup node, so that</span> +</span><span id="L-3695"><a href="#L-3695"><span class="linenos">3695</span></a> <span class="c1"># the STRING_AGG call is parsed like in MySQL / SQLite and can thus be transpiled more easily to them.</span> +</span><span id="L-3696"><a href="#L-3696"><span class="linenos">3696</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITHIN"</span><span class="p">,</span> <span class="s2">"GROUP"</span><span class="p">):</span> +</span><span id="L-3697"><a href="#L-3697"><span class="linenos">3697</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-3698"><a href="#L-3698"><span class="linenos">3698</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="n">args</span><span class="p">)</span> </span><span id="L-3699"><a href="#L-3699"><span class="linenos">3699</span></a> -</span><span id="L-3700"><a href="#L-3700"><span class="linenos">3700</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">USING</span><span class="p">):</span> -</span><span id="L-3701"><a href="#L-3701"><span class="linenos">3701</span></a> <span class="n">to</span> <span class="o">=</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">CharacterSet</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_var</span><span class="p">())</span> -</span><span id="L-3702"><a href="#L-3702"><span class="linenos">3702</span></a> <span class="k">elif</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">COMMA</span><span class="p">):</span> -</span><span id="L-3703"><a href="#L-3703"><span class="linenos">3703</span></a> <span class="n">to</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="L-3704"><a href="#L-3704"><span class="linenos">3704</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3705"><a href="#L-3705"><span class="linenos">3705</span></a> <span class="n">to</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-3706"><a href="#L-3706"><span class="linenos">3706</span></a> -</span><span id="L-3707"><a href="#L-3707"><span class="linenos">3707</span></a> <span class="c1"># Swap the argument order if needed to produce the correct AST</span> -</span><span id="L-3708"><a href="#L-3708"><span class="linenos">3708</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONVERT_TYPE_FIRST</span><span class="p">:</span> -</span><span id="L-3709"><a href="#L-3709"><span class="linenos">3709</span></a> <span class="n">this</span><span class="p">,</span> <span class="n">to</span> <span class="o">=</span> <span class="n">to</span><span class="p">,</span> <span class="n">this</span> -</span><span id="L-3710"><a href="#L-3710"><span class="linenos">3710</span></a> -</span><span id="L-3711"><a href="#L-3711"><span class="linenos">3711</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">Cast</span> <span class="k">if</span> <span class="n">strict</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="n">to</span><span class="p">)</span> -</span><span id="L-3712"><a href="#L-3712"><span class="linenos">3712</span></a> -</span><span id="L-3713"><a href="#L-3713"><span class="linenos">3713</span></a> <span class="k">def</span> <span class="nf">_parse_decode</span><span class="p">(</span><span class="bp">self</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">Decode</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">]:</span> -</span><span id="L-3714"><a href="#L-3714"><span class="linenos">3714</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-3715"><a href="#L-3715"><span class="linenos">3715</span></a><span class="sd"> There are generally two variants of the DECODE function:</span> -</span><span id="L-3716"><a href="#L-3716"><span class="linenos">3716</span></a> -</span><span id="L-3717"><a href="#L-3717"><span class="linenos">3717</span></a><span class="sd"> - DECODE(bin, charset)</span> -</span><span id="L-3718"><a href="#L-3718"><span class="linenos">3718</span></a><span class="sd"> - DECODE(expression, search, result [, search, result] ... [, default])</span> -</span><span id="L-3719"><a href="#L-3719"><span class="linenos">3719</span></a> -</span><span id="L-3720"><a href="#L-3720"><span class="linenos">3720</span></a><span class="sd"> The second variant will always be parsed into a CASE expression. Note that NULL</span> -</span><span id="L-3721"><a href="#L-3721"><span class="linenos">3721</span></a><span class="sd"> needs special treatment, since we need to explicitly check for it with `IS NULL`,</span> -</span><span id="L-3722"><a href="#L-3722"><span class="linenos">3722</span></a><span class="sd"> instead of relying on pattern matching.</span> -</span><span id="L-3723"><a href="#L-3723"><span class="linenos">3723</span></a><span class="sd"> """</span> -</span><span id="L-3724"><a href="#L-3724"><span class="linenos">3724</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="L-3725"><a href="#L-3725"><span class="linenos">3725</span></a> -</span><span id="L-3726"><a href="#L-3726"><span class="linenos">3726</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o"><</span> <span class="mi">3</span><span class="p">:</span> -</span><span id="L-3727"><a href="#L-3727"><span class="linenos">3727</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">Decode</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</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-3728"><a href="#L-3728"><span class="linenos">3728</span></a> -</span><span id="L-3729"><a href="#L-3729"><span class="linenos">3729</span></a> <span class="n">expression</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span> <span class="o">=</span> <span class="n">args</span> -</span><span id="L-3730"><a href="#L-3730"><span class="linenos">3730</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> -</span><span id="L-3731"><a href="#L-3731"><span class="linenos">3731</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-3732"><a href="#L-3732"><span class="linenos">3732</span></a> -</span><span id="L-3733"><a href="#L-3733"><span class="linenos">3733</span></a> <span class="n">ifs</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-3734"><a href="#L-3734"><span class="linenos">3734</span></a> <span class="k">for</span> <span class="n">search</span><span class="p">,</span> <span class="n">result</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">expressions</span><span class="p">[::</span><span class="mi">2</span><span class="p">],</span> <span class="n">expressions</span><span class="p">[</span><span class="mi">1</span><span class="p">::</span><span class="mi">2</span><span class="p">]):</span> -</span><span id="L-3735"><a href="#L-3735"><span class="linenos">3735</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">search</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">result</span><span class="p">:</span> -</span><span id="L-3736"><a href="#L-3736"><span class="linenos">3736</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-3737"><a href="#L-3737"><span class="linenos">3737</span></a> -</span><span id="L-3738"><a href="#L-3738"><span class="linenos">3738</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">search</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-3739"><a href="#L-3739"><span class="linenos">3739</span></a> <span class="n">ifs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="L-3740"><a href="#L-3740"><span class="linenos">3740</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">EQ</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">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">search</span><span class="p">),</span> <span class="n">true</span><span class="o">=</span><span class="n">result</span><span class="p">)</span> -</span><span id="L-3741"><a href="#L-3741"><span class="linenos">3741</span></a> <span class="p">)</span> -</span><span id="L-3742"><a href="#L-3742"><span class="linenos">3742</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">search</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-3743"><a href="#L-3743"><span class="linenos">3743</span></a> <span class="n">ifs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="L-3744"><a href="#L-3744"><span class="linenos">3744</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">()),</span> <span class="n">true</span><span class="o">=</span><span class="n">result</span><span class="p">)</span> -</span><span id="L-3745"><a href="#L-3745"><span class="linenos">3745</span></a> <span class="p">)</span> -</span><span id="L-3746"><a href="#L-3746"><span class="linenos">3746</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3747"><a href="#L-3747"><span class="linenos">3747</span></a> <span class="n">cond</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">or_</span><span class="p">(</span> -</span><span id="L-3748"><a href="#L-3748"><span class="linenos">3748</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">EQ</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">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">search</span><span class="p">),</span> -</span><span id="L-3749"><a href="#L-3749"><span class="linenos">3749</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">and_</span><span class="p">(</span> -</span><span id="L-3750"><a href="#L-3750"><span class="linenos">3750</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">()),</span> -</span><span id="L-3751"><a href="#L-3751"><span class="linenos">3751</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">search</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">()),</span> -</span><span id="L-3752"><a href="#L-3752"><span class="linenos">3752</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="L-3753"><a href="#L-3753"><span class="linenos">3753</span></a> <span class="p">),</span> -</span><span id="L-3754"><a href="#L-3754"><span class="linenos">3754</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="L-3755"><a href="#L-3755"><span class="linenos">3755</span></a> <span class="p">)</span> -</span><span id="L-3756"><a href="#L-3756"><span class="linenos">3756</span></a> <span class="n">ifs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">cond</span><span class="p">,</span> <span class="n">true</span><span class="o">=</span><span class="n">result</span><span class="p">))</span> -</span><span id="L-3757"><a href="#L-3757"><span class="linenos">3757</span></a> -</span><span id="L-3758"><a href="#L-3758"><span class="linenos">3758</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">(</span><span class="n">ifs</span><span class="o">=</span><span class="n">ifs</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">expressions</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">==</span> <span class="mi">1</span> <span class="k">else</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="L-3759"><a href="#L-3759"><span class="linenos">3759</span></a> -</span><span id="L-3760"><a href="#L-3760"><span class="linenos">3760</span></a> <span class="k">def</span> <span class="nf">_parse_json_key_value</span><span class="p">(</span><span class="bp">self</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">JSONKeyValue</span><span class="p">]:</span> -</span><span id="L-3761"><a href="#L-3761"><span class="linenos">3761</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"KEY"</span><span class="p">)</span> -</span><span id="L-3762"><a href="#L-3762"><span class="linenos">3762</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> -</span><span id="L-3763"><a href="#L-3763"><span class="linenos">3763</span></a> <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">COLON</span><span class="p">)</span> -</span><span id="L-3764"><a href="#L-3764"><span class="linenos">3764</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"VALUE"</span><span class="p">)</span> -</span><span id="L-3765"><a href="#L-3765"><span class="linenos">3765</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> -</span><span id="L-3766"><a href="#L-3766"><span class="linenos">3766</span></a> -</span><span id="L-3767"><a href="#L-3767"><span class="linenos">3767</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">key</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">value</span><span class="p">:</span> -</span><span id="L-3768"><a href="#L-3768"><span class="linenos">3768</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-3769"><a href="#L-3769"><span class="linenos">3769</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">JSONKeyValue</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">value</span><span class="p">)</span> -</span><span id="L-3770"><a href="#L-3770"><span class="linenos">3770</span></a> -</span><span id="L-3771"><a href="#L-3771"><span class="linenos">3771</span></a> <span class="k">def</span> <span class="nf">_parse_json_object</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">JSONObject</span><span class="p">:</span> -</span><span id="L-3772"><a href="#L-3772"><span class="linenos">3772</span></a> <span class="n">star</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_star</span><span class="p">()</span> -</span><span id="L-3773"><a href="#L-3773"><span class="linenos">3773</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">star</span><span class="p">]</span> <span class="k">if</span> <span class="n">star</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_json_key_value</span><span class="p">)</span> +</span><span id="L-3700"><a href="#L-3700"><span class="linenos">3700</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> <span class="c1"># The corresponding match_r_paren will be called in parse_function (caller)</span> +</span><span id="L-3701"><a href="#L-3701"><span class="linenos">3701</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-3702"><a href="#L-3702"><span class="linenos">3702</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">GroupConcat</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">order</span><span class="p">,</span> <span class="n">separator</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-3703"><a href="#L-3703"><span class="linenos">3703</span></a> +</span><span id="L-3704"><a href="#L-3704"><span class="linenos">3704</span></a> <span class="k">def</span> <span class="nf">_parse_convert</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">strict</span><span class="p">:</span> <span class="nb">bool</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-3705"><a href="#L-3705"><span class="linenos">3705</span></a> <span class="n">to</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><span id="L-3706"><a href="#L-3706"><span class="linenos">3706</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="L-3707"><a href="#L-3707"><span class="linenos">3707</span></a> +</span><span id="L-3708"><a href="#L-3708"><span class="linenos">3708</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">USING</span><span class="p">):</span> +</span><span id="L-3709"><a href="#L-3709"><span class="linenos">3709</span></a> <span class="n">to</span> <span class="o">=</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">CharacterSet</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_var</span><span class="p">())</span> +</span><span id="L-3710"><a href="#L-3710"><span class="linenos">3710</span></a> <span class="k">elif</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">COMMA</span><span class="p">):</span> +</span><span id="L-3711"><a href="#L-3711"><span class="linenos">3711</span></a> <span class="n">to</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="L-3712"><a href="#L-3712"><span class="linenos">3712</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3713"><a href="#L-3713"><span class="linenos">3713</span></a> <span class="n">to</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3714"><a href="#L-3714"><span class="linenos">3714</span></a> +</span><span id="L-3715"><a href="#L-3715"><span class="linenos">3715</span></a> <span class="c1"># Swap the argument order if needed to produce the correct AST</span> +</span><span id="L-3716"><a href="#L-3716"><span class="linenos">3716</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONVERT_TYPE_FIRST</span><span class="p">:</span> +</span><span id="L-3717"><a href="#L-3717"><span class="linenos">3717</span></a> <span class="n">this</span><span class="p">,</span> <span class="n">to</span> <span class="o">=</span> <span class="n">to</span><span class="p">,</span> <span class="n">this</span> +</span><span id="L-3718"><a href="#L-3718"><span class="linenos">3718</span></a> +</span><span id="L-3719"><a href="#L-3719"><span class="linenos">3719</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">Cast</span> <span class="k">if</span> <span class="n">strict</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="n">to</span><span class="p">)</span> +</span><span id="L-3720"><a href="#L-3720"><span class="linenos">3720</span></a> +</span><span id="L-3721"><a href="#L-3721"><span class="linenos">3721</span></a> <span class="k">def</span> <span class="nf">_parse_decode</span><span class="p">(</span><span class="bp">self</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">Decode</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">]:</span> +</span><span id="L-3722"><a href="#L-3722"><span class="linenos">3722</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-3723"><a href="#L-3723"><span class="linenos">3723</span></a><span class="sd"> There are generally two variants of the DECODE function:</span> +</span><span id="L-3724"><a href="#L-3724"><span class="linenos">3724</span></a> +</span><span id="L-3725"><a href="#L-3725"><span class="linenos">3725</span></a><span class="sd"> - DECODE(bin, charset)</span> +</span><span id="L-3726"><a href="#L-3726"><span class="linenos">3726</span></a><span class="sd"> - DECODE(expression, search, result [, search, result] ... [, default])</span> +</span><span id="L-3727"><a href="#L-3727"><span class="linenos">3727</span></a> +</span><span id="L-3728"><a href="#L-3728"><span class="linenos">3728</span></a><span class="sd"> The second variant will always be parsed into a CASE expression. Note that NULL</span> +</span><span id="L-3729"><a href="#L-3729"><span class="linenos">3729</span></a><span class="sd"> needs special treatment, since we need to explicitly check for it with `IS NULL`,</span> +</span><span id="L-3730"><a href="#L-3730"><span class="linenos">3730</span></a><span class="sd"> instead of relying on pattern matching.</span> +</span><span id="L-3731"><a href="#L-3731"><span class="linenos">3731</span></a><span class="sd"> """</span> +</span><span id="L-3732"><a href="#L-3732"><span class="linenos">3732</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="L-3733"><a href="#L-3733"><span class="linenos">3733</span></a> +</span><span id="L-3734"><a href="#L-3734"><span class="linenos">3734</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o"><</span> <span class="mi">3</span><span class="p">:</span> +</span><span id="L-3735"><a href="#L-3735"><span class="linenos">3735</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">Decode</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</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-3736"><a href="#L-3736"><span class="linenos">3736</span></a> +</span><span id="L-3737"><a href="#L-3737"><span class="linenos">3737</span></a> <span class="n">expression</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span> <span class="o">=</span> <span class="n">args</span> +</span><span id="L-3738"><a href="#L-3738"><span class="linenos">3738</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> +</span><span id="L-3739"><a href="#L-3739"><span class="linenos">3739</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-3740"><a href="#L-3740"><span class="linenos">3740</span></a> +</span><span id="L-3741"><a href="#L-3741"><span class="linenos">3741</span></a> <span class="n">ifs</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-3742"><a href="#L-3742"><span class="linenos">3742</span></a> <span class="k">for</span> <span class="n">search</span><span class="p">,</span> <span class="n">result</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">expressions</span><span class="p">[::</span><span class="mi">2</span><span class="p">],</span> <span class="n">expressions</span><span class="p">[</span><span class="mi">1</span><span class="p">::</span><span class="mi">2</span><span class="p">]):</span> +</span><span id="L-3743"><a href="#L-3743"><span class="linenos">3743</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">search</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">result</span><span class="p">:</span> +</span><span id="L-3744"><a href="#L-3744"><span class="linenos">3744</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-3745"><a href="#L-3745"><span class="linenos">3745</span></a> +</span><span id="L-3746"><a href="#L-3746"><span class="linenos">3746</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">search</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-3747"><a href="#L-3747"><span class="linenos">3747</span></a> <span class="n">ifs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="L-3748"><a href="#L-3748"><span class="linenos">3748</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">EQ</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">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">search</span><span class="p">),</span> <span class="n">true</span><span class="o">=</span><span class="n">result</span><span class="p">)</span> +</span><span id="L-3749"><a href="#L-3749"><span class="linenos">3749</span></a> <span class="p">)</span> +</span><span id="L-3750"><a href="#L-3750"><span class="linenos">3750</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">search</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-3751"><a href="#L-3751"><span class="linenos">3751</span></a> <span class="n">ifs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="L-3752"><a href="#L-3752"><span class="linenos">3752</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">()),</span> <span class="n">true</span><span class="o">=</span><span class="n">result</span><span class="p">)</span> +</span><span id="L-3753"><a href="#L-3753"><span class="linenos">3753</span></a> <span class="p">)</span> +</span><span id="L-3754"><a href="#L-3754"><span class="linenos">3754</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3755"><a href="#L-3755"><span class="linenos">3755</span></a> <span class="n">cond</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">or_</span><span class="p">(</span> +</span><span id="L-3756"><a href="#L-3756"><span class="linenos">3756</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">EQ</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">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">search</span><span class="p">),</span> +</span><span id="L-3757"><a href="#L-3757"><span class="linenos">3757</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">and_</span><span class="p">(</span> +</span><span id="L-3758"><a href="#L-3758"><span class="linenos">3758</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">()),</span> +</span><span id="L-3759"><a href="#L-3759"><span class="linenos">3759</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">search</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">()),</span> +</span><span id="L-3760"><a href="#L-3760"><span class="linenos">3760</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="L-3761"><a href="#L-3761"><span class="linenos">3761</span></a> <span class="p">),</span> +</span><span id="L-3762"><a href="#L-3762"><span class="linenos">3762</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="L-3763"><a href="#L-3763"><span class="linenos">3763</span></a> <span class="p">)</span> +</span><span id="L-3764"><a href="#L-3764"><span class="linenos">3764</span></a> <span class="n">ifs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">cond</span><span class="p">,</span> <span class="n">true</span><span class="o">=</span><span class="n">result</span><span class="p">))</span> +</span><span id="L-3765"><a href="#L-3765"><span class="linenos">3765</span></a> +</span><span id="L-3766"><a href="#L-3766"><span class="linenos">3766</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">(</span><span class="n">ifs</span><span class="o">=</span><span class="n">ifs</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">expressions</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">==</span> <span class="mi">1</span> <span class="k">else</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="L-3767"><a href="#L-3767"><span class="linenos">3767</span></a> +</span><span id="L-3768"><a href="#L-3768"><span class="linenos">3768</span></a> <span class="k">def</span> <span class="nf">_parse_json_key_value</span><span class="p">(</span><span class="bp">self</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">JSONKeyValue</span><span class="p">]:</span> +</span><span id="L-3769"><a href="#L-3769"><span class="linenos">3769</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"KEY"</span><span class="p">)</span> +</span><span id="L-3770"><a href="#L-3770"><span class="linenos">3770</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> +</span><span id="L-3771"><a href="#L-3771"><span class="linenos">3771</span></a> <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">COLON</span><span class="p">)</span> +</span><span id="L-3772"><a href="#L-3772"><span class="linenos">3772</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"VALUE"</span><span class="p">)</span> +</span><span id="L-3773"><a href="#L-3773"><span class="linenos">3773</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> </span><span id="L-3774"><a href="#L-3774"><span class="linenos">3774</span></a> -</span><span id="L-3775"><a href="#L-3775"><span class="linenos">3775</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-3776"><a href="#L-3776"><span class="linenos">3776</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULL"</span><span class="p">,</span> <span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"NULL"</span><span class="p">):</span> -</span><span id="L-3777"><a href="#L-3777"><span class="linenos">3777</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="s2">"NULL ON NULL"</span> -</span><span id="L-3778"><a href="#L-3778"><span class="linenos">3778</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ABSENT"</span><span class="p">,</span> <span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"NULL"</span><span class="p">):</span> -</span><span id="L-3779"><a href="#L-3779"><span class="linenos">3779</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="s2">"ABSENT ON NULL"</span> -</span><span id="L-3780"><a href="#L-3780"><span class="linenos">3780</span></a> -</span><span id="L-3781"><a href="#L-3781"><span class="linenos">3781</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-3782"><a href="#L-3782"><span class="linenos">3782</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"UNIQUE"</span><span class="p">):</span> -</span><span id="L-3783"><a href="#L-3783"><span class="linenos">3783</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-3784"><a href="#L-3784"><span class="linenos">3784</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITHOUT"</span><span class="p">,</span> <span class="s2">"UNIQUE"</span><span class="p">):</span> -</span><span id="L-3785"><a href="#L-3785"><span class="linenos">3785</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-3786"><a href="#L-3786"><span class="linenos">3786</span></a> -</span><span id="L-3787"><a href="#L-3787"><span class="linenos">3787</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"KEYS"</span><span class="p">)</span> +</span><span id="L-3775"><a href="#L-3775"><span class="linenos">3775</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">key</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">value</span><span class="p">:</span> +</span><span id="L-3776"><a href="#L-3776"><span class="linenos">3776</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-3777"><a href="#L-3777"><span class="linenos">3777</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">JSONKeyValue</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">value</span><span class="p">)</span> +</span><span id="L-3778"><a href="#L-3778"><span class="linenos">3778</span></a> +</span><span id="L-3779"><a href="#L-3779"><span class="linenos">3779</span></a> <span class="k">def</span> <span class="nf">_parse_json_object</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">JSONObject</span><span class="p">:</span> +</span><span id="L-3780"><a href="#L-3780"><span class="linenos">3780</span></a> <span class="n">star</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_star</span><span class="p">()</span> +</span><span id="L-3781"><a href="#L-3781"><span class="linenos">3781</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">star</span><span class="p">]</span> <span class="k">if</span> <span class="n">star</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_json_key_value</span><span class="p">)</span> +</span><span id="L-3782"><a href="#L-3782"><span class="linenos">3782</span></a> +</span><span id="L-3783"><a href="#L-3783"><span class="linenos">3783</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3784"><a href="#L-3784"><span class="linenos">3784</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULL"</span><span class="p">,</span> <span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"NULL"</span><span class="p">):</span> +</span><span id="L-3785"><a href="#L-3785"><span class="linenos">3785</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="s2">"NULL ON NULL"</span> +</span><span id="L-3786"><a href="#L-3786"><span class="linenos">3786</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ABSENT"</span><span class="p">,</span> <span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"NULL"</span><span class="p">):</span> +</span><span id="L-3787"><a href="#L-3787"><span class="linenos">3787</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="s2">"ABSENT ON NULL"</span> </span><span id="L-3788"><a href="#L-3788"><span class="linenos">3788</span></a> -</span><span id="L-3789"><a href="#L-3789"><span class="linenos">3789</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"RETURNING"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">()</span> -</span><span id="L-3790"><a href="#L-3790"><span class="linenos">3790</span></a> <span class="n">format_json</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FORMAT"</span><span class="p">,</span> <span class="s2">"JSON"</span><span class="p">)</span> -</span><span id="L-3791"><a href="#L-3791"><span class="linenos">3791</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ENCODING"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> -</span><span id="L-3792"><a href="#L-3792"><span class="linenos">3792</span></a> -</span><span id="L-3793"><a href="#L-3793"><span class="linenos">3793</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><span id="L-3794"><a href="#L-3794"><span class="linenos">3794</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONObject</span><span class="p">,</span> -</span><span id="L-3795"><a href="#L-3795"><span class="linenos">3795</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="L-3796"><a href="#L-3796"><span class="linenos">3796</span></a> <span class="n">null_handling</span><span class="o">=</span><span class="n">null_handling</span><span class="p">,</span> -</span><span id="L-3797"><a href="#L-3797"><span class="linenos">3797</span></a> <span class="n">unique_keys</span><span class="o">=</span><span class="n">unique_keys</span><span class="p">,</span> -</span><span id="L-3798"><a href="#L-3798"><span class="linenos">3798</span></a> <span class="n">return_type</span><span class="o">=</span><span class="n">return_type</span><span class="p">,</span> -</span><span id="L-3799"><a href="#L-3799"><span class="linenos">3799</span></a> <span class="n">format_json</span><span class="o">=</span><span class="n">format_json</span><span class="p">,</span> -</span><span id="L-3800"><a href="#L-3800"><span class="linenos">3800</span></a> <span class="n">encoding</span><span class="o">=</span><span class="n">encoding</span><span class="p">,</span> -</span><span id="L-3801"><a href="#L-3801"><span class="linenos">3801</span></a> <span class="p">)</span> -</span><span id="L-3802"><a href="#L-3802"><span class="linenos">3802</span></a> -</span><span id="L-3803"><a href="#L-3803"><span class="linenos">3803</span></a> <span class="k">def</span> <span class="nf">_parse_logarithm</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">Func</span><span class="p">:</span> -</span><span id="L-3804"><a href="#L-3804"><span class="linenos">3804</span></a> <span class="c1"># Default argument order is base, expression</span> -</span><span id="L-3805"><a href="#L-3805"><span class="linenos">3805</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_range</span><span class="p">)</span> -</span><span id="L-3806"><a href="#L-3806"><span class="linenos">3806</span></a> -</span><span id="L-3807"><a href="#L-3807"><span class="linenos">3807</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-3808"><a href="#L-3808"><span class="linenos">3808</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOG_BASE_FIRST</span><span class="p">:</span> -</span><span id="L-3809"><a href="#L-3809"><span class="linenos">3809</span></a> <span class="n">args</span><span class="o">.</span><span class="n">reverse</span><span class="p">()</span> -</span><span id="L-3810"><a href="#L-3810"><span class="linenos">3810</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Log</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> -</span><span id="L-3811"><a href="#L-3811"><span class="linenos">3811</span></a> -</span><span id="L-3812"><a href="#L-3812"><span class="linenos">3812</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><span id="L-3813"><a href="#L-3813"><span class="linenos">3813</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Ln</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOG_DEFAULTS_TO_LN</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">Log</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> -</span><span id="L-3814"><a href="#L-3814"><span class="linenos">3814</span></a> <span class="p">)</span> -</span><span id="L-3815"><a href="#L-3815"><span class="linenos">3815</span></a> -</span><span id="L-3816"><a href="#L-3816"><span class="linenos">3816</span></a> <span class="k">def</span> <span class="nf">_parse_match_against</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">MatchAgainst</span><span class="p">:</span> -</span><span id="L-3817"><a href="#L-3817"><span class="linenos">3817</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">)</span> -</span><span id="L-3818"><a href="#L-3818"><span class="linenos">3818</span></a> -</span><span id="L-3819"><a href="#L-3819"><span class="linenos">3819</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">")"</span><span class="p">,</span> <span class="s2">"AGAINST"</span><span class="p">,</span> <span class="s2">"("</span><span class="p">)</span> -</span><span id="L-3820"><a href="#L-3820"><span class="linenos">3820</span></a> -</span><span id="L-3821"><a href="#L-3821"><span class="linenos">3821</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="L-3822"><a href="#L-3822"><span class="linenos">3822</span></a> -</span><span id="L-3823"><a href="#L-3823"><span class="linenos">3823</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"IN"</span><span class="p">,</span> <span class="s2">"NATURAL"</span><span class="p">,</span> <span class="s2">"LANGUAGE"</span><span class="p">,</span> <span class="s2">"MODE"</span><span class="p">):</span> -</span><span id="L-3824"><a href="#L-3824"><span class="linenos">3824</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="s2">"IN NATURAL LANGUAGE MODE"</span> -</span><span id="L-3825"><a href="#L-3825"><span class="linenos">3825</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"QUERY"</span><span class="p">,</span> <span class="s2">"EXPANSION"</span><span class="p">):</span> -</span><span id="L-3826"><a href="#L-3826"><span class="linenos">3826</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">modifier</span><span class="si">}</span><span class="s2"> WITH QUERY EXPANSION"</span> -</span><span id="L-3827"><a href="#L-3827"><span class="linenos">3827</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"IN"</span><span class="p">,</span> <span class="s2">"BOOLEAN"</span><span class="p">,</span> <span class="s2">"MODE"</span><span class="p">):</span> -</span><span id="L-3828"><a href="#L-3828"><span class="linenos">3828</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="s2">"IN BOOLEAN MODE"</span> -</span><span id="L-3829"><a href="#L-3829"><span class="linenos">3829</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"QUERY"</span><span class="p">,</span> <span class="s2">"EXPANSION"</span><span class="p">):</span> -</span><span id="L-3830"><a href="#L-3830"><span class="linenos">3830</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="s2">"WITH QUERY EXPANSION"</span> -</span><span id="L-3831"><a href="#L-3831"><span class="linenos">3831</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3832"><a href="#L-3832"><span class="linenos">3832</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-3833"><a href="#L-3833"><span class="linenos">3833</span></a> -</span><span id="L-3834"><a href="#L-3834"><span class="linenos">3834</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><span id="L-3835"><a href="#L-3835"><span class="linenos">3835</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MatchAgainst</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">modifier</span><span class="o">=</span><span class="n">modifier</span> -</span><span id="L-3836"><a href="#L-3836"><span class="linenos">3836</span></a> <span class="p">)</span> -</span><span id="L-3837"><a href="#L-3837"><span class="linenos">3837</span></a> -</span><span id="L-3838"><a href="#L-3838"><span class="linenos">3838</span></a> <span class="c1"># https://learn.microsoft.com/en-us/sql/t-sql/functions/openjson-transact-sql?view=sql-server-ver16</span> -</span><span id="L-3839"><a href="#L-3839"><span class="linenos">3839</span></a> <span class="k">def</span> <span class="nf">_parse_open_json</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">OpenJSON</span><span class="p">:</span> -</span><span id="L-3840"><a href="#L-3840"><span class="linenos">3840</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="L-3841"><a href="#L-3841"><span class="linenos">3841</span></a> <span class="n">path</span> <span class="o">=</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">COMMA</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="L-3842"><a href="#L-3842"><span class="linenos">3842</span></a> -</span><span id="L-3843"><a href="#L-3843"><span class="linenos">3843</span></a> <span class="k">def</span> <span class="nf">_parse_open_json_column_def</span><span class="p">()</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSONColumnDef</span><span class="p">:</span> -</span><span id="L-3844"><a href="#L-3844"><span class="linenos">3844</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-3845"><a href="#L-3845"><span class="linenos">3845</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">()</span> -</span><span id="L-3846"><a href="#L-3846"><span class="linenos">3846</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="L-3847"><a href="#L-3847"><span class="linenos">3847</span></a> <span class="n">as_json</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ALIAS</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">JSON</span><span class="p">)</span> -</span><span id="L-3848"><a href="#L-3848"><span class="linenos">3848</span></a> -</span><span id="L-3849"><a href="#L-3849"><span class="linenos">3849</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><span id="L-3850"><a href="#L-3850"><span class="linenos">3850</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSONColumnDef</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="n">path</span><span class="p">,</span> <span class="n">as_json</span><span class="o">=</span><span class="n">as_json</span> -</span><span id="L-3851"><a href="#L-3851"><span class="linenos">3851</span></a> <span class="p">)</span> -</span><span id="L-3852"><a href="#L-3852"><span class="linenos">3852</span></a> -</span><span id="L-3853"><a href="#L-3853"><span class="linenos">3853</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-3854"><a href="#L-3854"><span class="linenos">3854</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">R_PAREN</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">):</span> -</span><span id="L-3855"><a href="#L-3855"><span class="linenos">3855</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> -</span><span id="L-3856"><a href="#L-3856"><span class="linenos">3856</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">_parse_open_json_column_def</span><span class="p">)</span> -</span><span id="L-3857"><a href="#L-3857"><span class="linenos">3857</span></a> -</span><span id="L-3858"><a href="#L-3858"><span class="linenos">3858</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">OpenJSON</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="n">path</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-3859"><a href="#L-3859"><span class="linenos">3859</span></a> -</span><span id="L-3860"><a href="#L-3860"><span class="linenos">3860</span></a> <span class="k">def</span> <span class="nf">_parse_position</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">haystack_first</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> -</span><span id="L-3861"><a href="#L-3861"><span class="linenos">3861</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">)</span> -</span><span id="L-3862"><a href="#L-3862"><span class="linenos">3862</span></a> -</span><span id="L-3863"><a href="#L-3863"><span class="linenos">3863</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">IN</span><span class="p">):</span> -</span><span id="L-3864"><a href="#L-3864"><span class="linenos">3864</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><span id="L-3865"><a href="#L-3865"><span class="linenos">3865</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</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_bitwise</span><span class="p">(),</span> <span class="n">substr</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-3866"><a href="#L-3866"><span class="linenos">3866</span></a> <span class="p">)</span> +</span><span id="L-3789"><a href="#L-3789"><span class="linenos">3789</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3790"><a href="#L-3790"><span class="linenos">3790</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"UNIQUE"</span><span class="p">):</span> +</span><span id="L-3791"><a href="#L-3791"><span class="linenos">3791</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-3792"><a href="#L-3792"><span class="linenos">3792</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITHOUT"</span><span class="p">,</span> <span class="s2">"UNIQUE"</span><span class="p">):</span> +</span><span id="L-3793"><a href="#L-3793"><span class="linenos">3793</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-3794"><a href="#L-3794"><span class="linenos">3794</span></a> +</span><span id="L-3795"><a href="#L-3795"><span class="linenos">3795</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"KEYS"</span><span class="p">)</span> +</span><span id="L-3796"><a href="#L-3796"><span class="linenos">3796</span></a> +</span><span id="L-3797"><a href="#L-3797"><span class="linenos">3797</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"RETURNING"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">()</span> +</span><span id="L-3798"><a href="#L-3798"><span class="linenos">3798</span></a> <span class="n">format_json</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FORMAT"</span><span class="p">,</span> <span class="s2">"JSON"</span><span class="p">)</span> +</span><span id="L-3799"><a href="#L-3799"><span class="linenos">3799</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ENCODING"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> +</span><span id="L-3800"><a href="#L-3800"><span class="linenos">3800</span></a> +</span><span id="L-3801"><a href="#L-3801"><span class="linenos">3801</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><span id="L-3802"><a href="#L-3802"><span class="linenos">3802</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONObject</span><span class="p">,</span> +</span><span id="L-3803"><a href="#L-3803"><span class="linenos">3803</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="L-3804"><a href="#L-3804"><span class="linenos">3804</span></a> <span class="n">null_handling</span><span class="o">=</span><span class="n">null_handling</span><span class="p">,</span> +</span><span id="L-3805"><a href="#L-3805"><span class="linenos">3805</span></a> <span class="n">unique_keys</span><span class="o">=</span><span class="n">unique_keys</span><span class="p">,</span> +</span><span id="L-3806"><a href="#L-3806"><span class="linenos">3806</span></a> <span class="n">return_type</span><span class="o">=</span><span class="n">return_type</span><span class="p">,</span> +</span><span id="L-3807"><a href="#L-3807"><span class="linenos">3807</span></a> <span class="n">format_json</span><span class="o">=</span><span class="n">format_json</span><span class="p">,</span> +</span><span id="L-3808"><a href="#L-3808"><span class="linenos">3808</span></a> <span class="n">encoding</span><span class="o">=</span><span class="n">encoding</span><span class="p">,</span> +</span><span id="L-3809"><a href="#L-3809"><span class="linenos">3809</span></a> <span class="p">)</span> +</span><span id="L-3810"><a href="#L-3810"><span class="linenos">3810</span></a> +</span><span id="L-3811"><a href="#L-3811"><span class="linenos">3811</span></a> <span class="k">def</span> <span class="nf">_parse_logarithm</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">Func</span><span class="p">:</span> +</span><span id="L-3812"><a href="#L-3812"><span class="linenos">3812</span></a> <span class="c1"># Default argument order is base, expression</span> +</span><span id="L-3813"><a href="#L-3813"><span class="linenos">3813</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_range</span><span class="p">)</span> +</span><span id="L-3814"><a href="#L-3814"><span class="linenos">3814</span></a> +</span><span id="L-3815"><a href="#L-3815"><span class="linenos">3815</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-3816"><a href="#L-3816"><span class="linenos">3816</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOG_BASE_FIRST</span><span class="p">:</span> +</span><span id="L-3817"><a href="#L-3817"><span class="linenos">3817</span></a> <span class="n">args</span><span class="o">.</span><span class="n">reverse</span><span class="p">()</span> +</span><span id="L-3818"><a href="#L-3818"><span class="linenos">3818</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Log</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> +</span><span id="L-3819"><a href="#L-3819"><span class="linenos">3819</span></a> +</span><span id="L-3820"><a href="#L-3820"><span class="linenos">3820</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><span id="L-3821"><a href="#L-3821"><span class="linenos">3821</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Ln</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOG_DEFAULTS_TO_LN</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">Log</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="L-3822"><a href="#L-3822"><span class="linenos">3822</span></a> <span class="p">)</span> +</span><span id="L-3823"><a href="#L-3823"><span class="linenos">3823</span></a> +</span><span id="L-3824"><a href="#L-3824"><span class="linenos">3824</span></a> <span class="k">def</span> <span class="nf">_parse_match_against</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">MatchAgainst</span><span class="p">:</span> +</span><span id="L-3825"><a href="#L-3825"><span class="linenos">3825</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">)</span> +</span><span id="L-3826"><a href="#L-3826"><span class="linenos">3826</span></a> +</span><span id="L-3827"><a href="#L-3827"><span class="linenos">3827</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">")"</span><span class="p">,</span> <span class="s2">"AGAINST"</span><span class="p">,</span> <span class="s2">"("</span><span class="p">)</span> +</span><span id="L-3828"><a href="#L-3828"><span class="linenos">3828</span></a> +</span><span id="L-3829"><a href="#L-3829"><span class="linenos">3829</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="L-3830"><a href="#L-3830"><span class="linenos">3830</span></a> +</span><span id="L-3831"><a href="#L-3831"><span class="linenos">3831</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"IN"</span><span class="p">,</span> <span class="s2">"NATURAL"</span><span class="p">,</span> <span class="s2">"LANGUAGE"</span><span class="p">,</span> <span class="s2">"MODE"</span><span class="p">):</span> +</span><span id="L-3832"><a href="#L-3832"><span class="linenos">3832</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="s2">"IN NATURAL LANGUAGE MODE"</span> +</span><span id="L-3833"><a href="#L-3833"><span class="linenos">3833</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"QUERY"</span><span class="p">,</span> <span class="s2">"EXPANSION"</span><span class="p">):</span> +</span><span id="L-3834"><a href="#L-3834"><span class="linenos">3834</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">modifier</span><span class="si">}</span><span class="s2"> WITH QUERY EXPANSION"</span> +</span><span id="L-3835"><a href="#L-3835"><span class="linenos">3835</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"IN"</span><span class="p">,</span> <span class="s2">"BOOLEAN"</span><span class="p">,</span> <span class="s2">"MODE"</span><span class="p">):</span> +</span><span id="L-3836"><a href="#L-3836"><span class="linenos">3836</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="s2">"IN BOOLEAN MODE"</span> +</span><span id="L-3837"><a href="#L-3837"><span class="linenos">3837</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"QUERY"</span><span class="p">,</span> <span class="s2">"EXPANSION"</span><span class="p">):</span> +</span><span id="L-3838"><a href="#L-3838"><span class="linenos">3838</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="s2">"WITH QUERY EXPANSION"</span> +</span><span id="L-3839"><a href="#L-3839"><span class="linenos">3839</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3840"><a href="#L-3840"><span class="linenos">3840</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3841"><a href="#L-3841"><span class="linenos">3841</span></a> +</span><span id="L-3842"><a href="#L-3842"><span class="linenos">3842</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><span id="L-3843"><a href="#L-3843"><span class="linenos">3843</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MatchAgainst</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">modifier</span><span class="o">=</span><span class="n">modifier</span> +</span><span id="L-3844"><a href="#L-3844"><span class="linenos">3844</span></a> <span class="p">)</span> +</span><span id="L-3845"><a href="#L-3845"><span class="linenos">3845</span></a> +</span><span id="L-3846"><a href="#L-3846"><span class="linenos">3846</span></a> <span class="c1"># https://learn.microsoft.com/en-us/sql/t-sql/functions/openjson-transact-sql?view=sql-server-ver16</span> +</span><span id="L-3847"><a href="#L-3847"><span class="linenos">3847</span></a> <span class="k">def</span> <span class="nf">_parse_open_json</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">OpenJSON</span><span class="p">:</span> +</span><span id="L-3848"><a href="#L-3848"><span class="linenos">3848</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="L-3849"><a href="#L-3849"><span class="linenos">3849</span></a> <span class="n">path</span> <span class="o">=</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">COMMA</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="L-3850"><a href="#L-3850"><span class="linenos">3850</span></a> +</span><span id="L-3851"><a href="#L-3851"><span class="linenos">3851</span></a> <span class="k">def</span> <span class="nf">_parse_open_json_column_def</span><span class="p">()</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSONColumnDef</span><span class="p">:</span> +</span><span id="L-3852"><a href="#L-3852"><span class="linenos">3852</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-3853"><a href="#L-3853"><span class="linenos">3853</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">()</span> +</span><span id="L-3854"><a href="#L-3854"><span class="linenos">3854</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="L-3855"><a href="#L-3855"><span class="linenos">3855</span></a> <span class="n">as_json</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ALIAS</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">JSON</span><span class="p">)</span> +</span><span id="L-3856"><a href="#L-3856"><span class="linenos">3856</span></a> +</span><span id="L-3857"><a href="#L-3857"><span class="linenos">3857</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><span id="L-3858"><a href="#L-3858"><span class="linenos">3858</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSONColumnDef</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="n">path</span><span class="p">,</span> <span class="n">as_json</span><span class="o">=</span><span class="n">as_json</span> +</span><span id="L-3859"><a href="#L-3859"><span class="linenos">3859</span></a> <span class="p">)</span> +</span><span id="L-3860"><a href="#L-3860"><span class="linenos">3860</span></a> +</span><span id="L-3861"><a href="#L-3861"><span class="linenos">3861</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3862"><a href="#L-3862"><span class="linenos">3862</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">R_PAREN</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">):</span> +</span><span id="L-3863"><a href="#L-3863"><span class="linenos">3863</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> +</span><span id="L-3864"><a href="#L-3864"><span class="linenos">3864</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">_parse_open_json_column_def</span><span class="p">)</span> +</span><span id="L-3865"><a href="#L-3865"><span class="linenos">3865</span></a> +</span><span id="L-3866"><a href="#L-3866"><span class="linenos">3866</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">OpenJSON</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="n">path</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> </span><span id="L-3867"><a href="#L-3867"><span class="linenos">3867</span></a> -</span><span id="L-3868"><a href="#L-3868"><span class="linenos">3868</span></a> <span class="k">if</span> <span class="n">haystack_first</span><span class="p">:</span> -</span><span id="L-3869"><a href="#L-3869"><span class="linenos">3869</span></a> <span class="n">haystack</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-3870"><a href="#L-3870"><span class="linenos">3870</span></a> <span class="n">needle</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-3871"><a href="#L-3871"><span class="linenos">3871</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3872"><a href="#L-3872"><span class="linenos">3872</span></a> <span class="n">needle</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-3873"><a href="#L-3873"><span class="linenos">3873</span></a> <span class="n">haystack</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-3874"><a href="#L-3874"><span class="linenos">3874</span></a> -</span><span id="L-3875"><a href="#L-3875"><span class="linenos">3875</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><span id="L-3876"><a href="#L-3876"><span class="linenos">3876</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">haystack</span><span class="p">,</span> <span class="n">substr</span><span class="o">=</span><span class="n">needle</span><span class="p">,</span> <span class="n">position</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-3877"><a href="#L-3877"><span class="linenos">3877</span></a> <span class="p">)</span> -</span><span id="L-3878"><a href="#L-3878"><span class="linenos">3878</span></a> -</span><span id="L-3879"><a href="#L-3879"><span class="linenos">3879</span></a> <span class="k">def</span> <span class="nf">_parse_join_hint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">func_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">JoinHint</span><span class="p">:</span> -</span><span id="L-3880"><a href="#L-3880"><span class="linenos">3880</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">)</span> -</span><span id="L-3881"><a href="#L-3881"><span class="linenos">3881</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">JoinHint</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">func_name</span><span class="o">.</span><span class="n">upper</span><span class="p">(),</span> <span class="n">expressions</span><span class="o">=</span><span class="n">args</span><span class="p">)</span> +</span><span id="L-3868"><a href="#L-3868"><span class="linenos">3868</span></a> <span class="k">def</span> <span class="nf">_parse_position</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">haystack_first</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> +</span><span id="L-3869"><a href="#L-3869"><span class="linenos">3869</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">)</span> +</span><span id="L-3870"><a href="#L-3870"><span class="linenos">3870</span></a> +</span><span id="L-3871"><a href="#L-3871"><span class="linenos">3871</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">IN</span><span class="p">):</span> +</span><span id="L-3872"><a href="#L-3872"><span class="linenos">3872</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><span id="L-3873"><a href="#L-3873"><span class="linenos">3873</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</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_bitwise</span><span class="p">(),</span> <span class="n">substr</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-3874"><a href="#L-3874"><span class="linenos">3874</span></a> <span class="p">)</span> +</span><span id="L-3875"><a href="#L-3875"><span class="linenos">3875</span></a> +</span><span id="L-3876"><a href="#L-3876"><span class="linenos">3876</span></a> <span class="k">if</span> <span class="n">haystack_first</span><span class="p">:</span> +</span><span id="L-3877"><a href="#L-3877"><span class="linenos">3877</span></a> <span class="n">haystack</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-3878"><a href="#L-3878"><span class="linenos">3878</span></a> <span class="n">needle</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-3879"><a href="#L-3879"><span class="linenos">3879</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3880"><a href="#L-3880"><span class="linenos">3880</span></a> <span class="n">needle</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-3881"><a href="#L-3881"><span class="linenos">3881</span></a> <span class="n">haystack</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-3882"><a href="#L-3882"><span class="linenos">3882</span></a> -</span><span id="L-3883"><a href="#L-3883"><span class="linenos">3883</span></a> <span class="k">def</span> <span class="nf">_parse_substring</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">Substring</span><span class="p">:</span> -</span><span id="L-3884"><a href="#L-3884"><span class="linenos">3884</span></a> <span class="c1"># Postgres supports the form: substring(string [from int] [for int])</span> -</span><span id="L-3885"><a href="#L-3885"><span class="linenos">3885</span></a> <span class="c1"># https://www.postgresql.org/docs/9.1/functions-string.html @ Table 9-6</span> +</span><span id="L-3883"><a href="#L-3883"><span class="linenos">3883</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><span id="L-3884"><a href="#L-3884"><span class="linenos">3884</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">haystack</span><span class="p">,</span> <span class="n">substr</span><span class="o">=</span><span class="n">needle</span><span class="p">,</span> <span class="n">position</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-3885"><a href="#L-3885"><span class="linenos">3885</span></a> <span class="p">)</span> </span><span id="L-3886"><a href="#L-3886"><span class="linenos">3886</span></a> -</span><span id="L-3887"><a href="#L-3887"><span class="linenos">3887</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">)</span> -</span><span id="L-3888"><a href="#L-3888"><span class="linenos">3888</span></a> -</span><span id="L-3889"><a href="#L-3889"><span class="linenos">3889</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">FROM</span><span class="p">):</span> -</span><span id="L-3890"><a href="#L-3890"><span class="linenos">3890</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> -</span><span id="L-3891"><a href="#L-3891"><span class="linenos">3891</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">FOR</span><span class="p">):</span> -</span><span id="L-3892"><a href="#L-3892"><span class="linenos">3892</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> -</span><span id="L-3893"><a href="#L-3893"><span class="linenos">3893</span></a> -</span><span id="L-3894"><a href="#L-3894"><span class="linenos">3894</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Substring</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="n">args</span><span class="p">)</span> -</span><span id="L-3895"><a href="#L-3895"><span class="linenos">3895</span></a> -</span><span id="L-3896"><a href="#L-3896"><span class="linenos">3896</span></a> <span class="k">def</span> <span class="nf">_parse_trim</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">Trim</span><span class="p">:</span> -</span><span id="L-3897"><a href="#L-3897"><span class="linenos">3897</span></a> <span class="c1"># https://www.w3resource.com/sql/character-functions/trim.php</span> -</span><span id="L-3898"><a href="#L-3898"><span class="linenos">3898</span></a> <span class="c1"># https://docs.oracle.com/javadb/10.8.3.0/ref/rreftrimfunc.html</span> -</span><span id="L-3899"><a href="#L-3899"><span class="linenos">3899</span></a> -</span><span id="L-3900"><a href="#L-3900"><span class="linenos">3900</span></a> <span class="n">position</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-3901"><a href="#L-3901"><span class="linenos">3901</span></a> <span class="n">collation</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-3902"><a href="#L-3902"><span class="linenos">3902</span></a> -</span><span id="L-3903"><a href="#L-3903"><span class="linenos">3903</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">TRIM_TYPES</span><span class="p">):</span> -</span><span id="L-3904"><a href="#L-3904"><span class="linenos">3904</span></a> <span class="n">position</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="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-3905"><a href="#L-3905"><span class="linenos">3905</span></a> -</span><span id="L-3906"><a href="#L-3906"><span class="linenos">3906</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="L-3907"><a href="#L-3907"><span class="linenos">3907</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FROM</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMA</span><span class="p">)):</span> -</span><span id="L-3908"><a href="#L-3908"><span class="linenos">3908</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="L-3909"><a href="#L-3909"><span class="linenos">3909</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3910"><a href="#L-3910"><span class="linenos">3910</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span> -</span><span id="L-3911"><a href="#L-3911"><span class="linenos">3911</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-3912"><a href="#L-3912"><span class="linenos">3912</span></a> -</span><span id="L-3913"><a href="#L-3913"><span class="linenos">3913</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">COLLATE</span><span class="p">):</span> -</span><span id="L-3914"><a href="#L-3914"><span class="linenos">3914</span></a> <span class="n">collation</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="L-3915"><a href="#L-3915"><span class="linenos">3915</span></a> -</span><span id="L-3916"><a href="#L-3916"><span class="linenos">3916</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><span id="L-3917"><a href="#L-3917"><span class="linenos">3917</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">position</span><span class="o">=</span><span class="n">position</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">collation</span><span class="o">=</span><span class="n">collation</span> -</span><span id="L-3918"><a href="#L-3918"><span class="linenos">3918</span></a> <span class="p">)</span> -</span><span id="L-3919"><a href="#L-3919"><span class="linenos">3919</span></a> -</span><span id="L-3920"><a href="#L-3920"><span class="linenos">3920</span></a> <span class="k">def</span> <span class="nf">_parse_window_clause</span><span class="p">(</span><span class="bp">self</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">t</span><span class="o">.</span><span class="n">List</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><span id="L-3921"><a href="#L-3921"><span class="linenos">3921</span></a> <span class="k">return</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">WINDOW</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_named_window</span><span class="p">)</span> -</span><span id="L-3922"><a href="#L-3922"><span class="linenos">3922</span></a> -</span><span id="L-3923"><a href="#L-3923"><span class="linenos">3923</span></a> <span class="k">def</span> <span class="nf">_parse_named_window</span><span class="p">(</span><span class="bp">self</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-3924"><a href="#L-3924"><span class="linenos">3924</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(),</span> <span class="n">alias</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-3925"><a href="#L-3925"><span class="linenos">3925</span></a> -</span><span id="L-3926"><a href="#L-3926"><span class="linenos">3926</span></a> <span class="k">def</span> <span class="nf">_parse_respect_or_ignore_nulls</span><span class="p">(</span> -</span><span id="L-3927"><a href="#L-3927"><span class="linenos">3927</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><span id="L-3928"><a href="#L-3928"><span class="linenos">3928</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-3929"><a href="#L-3929"><span class="linenos">3929</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"IGNORE"</span><span class="p">,</span> <span class="s2">"NULLS"</span><span class="p">):</span> -</span><span id="L-3930"><a href="#L-3930"><span class="linenos">3930</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">IgnoreNulls</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-3931"><a href="#L-3931"><span class="linenos">3931</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"RESPECT"</span><span class="p">,</span> <span class="s2">"NULLS"</span><span class="p">):</span> -</span><span id="L-3932"><a href="#L-3932"><span class="linenos">3932</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">RespectNulls</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-3933"><a href="#L-3933"><span class="linenos">3933</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-3934"><a href="#L-3934"><span class="linenos">3934</span></a> -</span><span id="L-3935"><a href="#L-3935"><span class="linenos">3935</span></a> <span class="k">def</span> <span class="nf">_parse_window</span><span class="p">(</span> -</span><span id="L-3936"><a href="#L-3936"><span class="linenos">3936</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="n">alias</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-3937"><a href="#L-3937"><span class="linenos">3937</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-3938"><a href="#L-3938"><span class="linenos">3938</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FILTER</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">):</span> -</span><span id="L-3939"><a href="#L-3939"><span class="linenos">3939</span></a> <span class="n">this</span> <span class="o">=</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">Filter</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">())</span> -</span><span id="L-3940"><a href="#L-3940"><span class="linenos">3940</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="L-3941"><a href="#L-3941"><span class="linenos">3941</span></a> -</span><span id="L-3942"><a href="#L-3942"><span class="linenos">3942</span></a> <span class="c1"># T-SQL allows the OVER (...) syntax after WITHIN GROUP.</span> -</span><span id="L-3943"><a href="#L-3943"><span class="linenos">3943</span></a> <span class="c1"># https://learn.microsoft.com/en-us/sql/t-sql/functions/percentile-disc-transact-sql?view=sql-server-ver16</span> -</span><span id="L-3944"><a href="#L-3944"><span class="linenos">3944</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITHIN"</span><span class="p">,</span> <span class="s2">"GROUP"</span><span class="p">):</span> -</span><span id="L-3945"><a href="#L-3945"><span class="linenos">3945</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">)</span> -</span><span id="L-3946"><a href="#L-3946"><span class="linenos">3946</span></a> <span class="n">this</span> <span class="o">=</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">WithinGroup</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">order</span><span class="p">)</span> -</span><span id="L-3947"><a href="#L-3947"><span class="linenos">3947</span></a> -</span><span id="L-3948"><a href="#L-3948"><span class="linenos">3948</span></a> <span class="c1"># SQL spec defines an optional [ { IGNORE | RESPECT } NULLS ] OVER</span> -</span><span id="L-3949"><a href="#L-3949"><span class="linenos">3949</span></a> <span class="c1"># Some dialects choose to implement and some do not.</span> -</span><span id="L-3950"><a href="#L-3950"><span class="linenos">3950</span></a> <span class="c1"># https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html</span> -</span><span id="L-3951"><a href="#L-3951"><span class="linenos">3951</span></a> -</span><span id="L-3952"><a href="#L-3952"><span class="linenos">3952</span></a> <span class="c1"># There is some code above in _parse_lambda that handles</span> -</span><span id="L-3953"><a href="#L-3953"><span class="linenos">3953</span></a> <span class="c1"># SELECT FIRST_VALUE(TABLE.COLUMN IGNORE|RESPECT NULLS) OVER ...</span> -</span><span id="L-3954"><a href="#L-3954"><span class="linenos">3954</span></a> -</span><span id="L-3955"><a href="#L-3955"><span class="linenos">3955</span></a> <span class="c1"># The below changes handle</span> -</span><span id="L-3956"><a href="#L-3956"><span class="linenos">3956</span></a> <span class="c1"># SELECT FIRST_VALUE(TABLE.COLUMN) IGNORE|RESPECT NULLS OVER ...</span> -</span><span id="L-3957"><a href="#L-3957"><span class="linenos">3957</span></a> -</span><span id="L-3958"><a href="#L-3958"><span class="linenos">3958</span></a> <span class="c1"># Oracle allows both formats</span> -</span><span id="L-3959"><a href="#L-3959"><span class="linenos">3959</span></a> <span class="c1"># (https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/img_text/first_value.html)</span> -</span><span id="L-3960"><a href="#L-3960"><span class="linenos">3960</span></a> <span class="c1"># and Snowflake chose to do the same for familiarity</span> -</span><span id="L-3961"><a href="#L-3961"><span class="linenos">3961</span></a> <span class="c1"># https://docs.snowflake.com/en/sql-reference/functions/first_value.html#usage-notes</span> -</span><span id="L-3962"><a href="#L-3962"><span class="linenos">3962</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_respect_or_ignore_nulls</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-3963"><a href="#L-3963"><span class="linenos">3963</span></a> -</span><span id="L-3964"><a href="#L-3964"><span class="linenos">3964</span></a> <span class="c1"># bigquery select from window x AS (partition by ...)</span> -</span><span id="L-3965"><a href="#L-3965"><span class="linenos">3965</span></a> <span class="k">if</span> <span class="n">alias</span><span class="p">:</span> -</span><span id="L-3966"><a href="#L-3966"><span class="linenos">3966</span></a> <span class="n">over</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-3967"><a href="#L-3967"><span class="linenos">3967</span></a> <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">ALIAS</span><span class="p">)</span> -</span><span id="L-3968"><a href="#L-3968"><span class="linenos">3968</span></a> <span class="k">elif</span> <span class="ow">not</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">WINDOW_BEFORE_PAREN_TOKENS</span><span class="p">):</span> -</span><span id="L-3969"><a href="#L-3969"><span class="linenos">3969</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-3970"><a href="#L-3970"><span class="linenos">3970</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-3971"><a href="#L-3971"><span class="linenos">3971</span></a> <span class="n">over</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="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-3972"><a href="#L-3972"><span class="linenos">3972</span></a> -</span><span id="L-3973"><a href="#L-3973"><span class="linenos">3973</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">):</span> -</span><span id="L-3974"><a href="#L-3974"><span class="linenos">3974</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><span id="L-3975"><a href="#L-3975"><span class="linenos">3975</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="kc">False</span><span class="p">),</span> <span class="n">over</span><span class="o">=</span><span class="n">over</span> -</span><span id="L-3976"><a href="#L-3976"><span class="linenos">3976</span></a> <span class="p">)</span> -</span><span id="L-3977"><a href="#L-3977"><span class="linenos">3977</span></a> -</span><span id="L-3978"><a href="#L-3978"><span class="linenos">3978</span></a> <span class="n">window_alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">tokens</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">WINDOW_ALIAS_TOKENS</span><span class="p">)</span> -</span><span id="L-3979"><a href="#L-3979"><span class="linenos">3979</span></a> -</span><span id="L-3980"><a href="#L-3980"><span class="linenos">3980</span></a> <span class="n">first</span> <span class="o">=</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">FIRST</span><span class="p">)</span> -</span><span id="L-3981"><a href="#L-3981"><span class="linenos">3981</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LAST"</span><span class="p">):</span> -</span><span id="L-3982"><a href="#L-3982"><span class="linenos">3982</span></a> <span class="n">first</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-3983"><a href="#L-3983"><span class="linenos">3983</span></a> -</span><span id="L-3984"><a href="#L-3984"><span class="linenos">3984</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition_by</span><span class="p">()</span> -</span><span id="L-3985"><a href="#L-3985"><span class="linenos">3985</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">()</span> -</span><span id="L-3986"><a href="#L-3986"><span class="linenos">3986</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RANGE</span><span class="p">))</span> <span class="ow">and</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><span id="L-3887"><a href="#L-3887"><span class="linenos">3887</span></a> <span class="k">def</span> <span class="nf">_parse_join_hint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">func_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">JoinHint</span><span class="p">:</span> +</span><span id="L-3888"><a href="#L-3888"><span class="linenos">3888</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">)</span> +</span><span id="L-3889"><a href="#L-3889"><span class="linenos">3889</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">JoinHint</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">func_name</span><span class="o">.</span><span class="n">upper</span><span class="p">(),</span> <span class="n">expressions</span><span class="o">=</span><span class="n">args</span><span class="p">)</span> +</span><span id="L-3890"><a href="#L-3890"><span class="linenos">3890</span></a> +</span><span id="L-3891"><a href="#L-3891"><span class="linenos">3891</span></a> <span class="k">def</span> <span class="nf">_parse_substring</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">Substring</span><span class="p">:</span> +</span><span id="L-3892"><a href="#L-3892"><span class="linenos">3892</span></a> <span class="c1"># Postgres supports the form: substring(string [from int] [for int])</span> +</span><span id="L-3893"><a href="#L-3893"><span class="linenos">3893</span></a> <span class="c1"># https://www.postgresql.org/docs/9.1/functions-string.html @ Table 9-6</span> +</span><span id="L-3894"><a href="#L-3894"><span class="linenos">3894</span></a> +</span><span id="L-3895"><a href="#L-3895"><span class="linenos">3895</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">)</span> +</span><span id="L-3896"><a href="#L-3896"><span class="linenos">3896</span></a> +</span><span id="L-3897"><a href="#L-3897"><span class="linenos">3897</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">FROM</span><span class="p">):</span> +</span><span id="L-3898"><a href="#L-3898"><span class="linenos">3898</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> +</span><span id="L-3899"><a href="#L-3899"><span class="linenos">3899</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">FOR</span><span class="p">):</span> +</span><span id="L-3900"><a href="#L-3900"><span class="linenos">3900</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> +</span><span id="L-3901"><a href="#L-3901"><span class="linenos">3901</span></a> +</span><span id="L-3902"><a href="#L-3902"><span class="linenos">3902</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Substring</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="n">args</span><span class="p">)</span> +</span><span id="L-3903"><a href="#L-3903"><span class="linenos">3903</span></a> +</span><span id="L-3904"><a href="#L-3904"><span class="linenos">3904</span></a> <span class="k">def</span> <span class="nf">_parse_trim</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">Trim</span><span class="p">:</span> +</span><span id="L-3905"><a href="#L-3905"><span class="linenos">3905</span></a> <span class="c1"># https://www.w3resource.com/sql/character-functions/trim.php</span> +</span><span id="L-3906"><a href="#L-3906"><span class="linenos">3906</span></a> <span class="c1"># https://docs.oracle.com/javadb/10.8.3.0/ref/rreftrimfunc.html</span> +</span><span id="L-3907"><a href="#L-3907"><span class="linenos">3907</span></a> +</span><span id="L-3908"><a href="#L-3908"><span class="linenos">3908</span></a> <span class="n">position</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3909"><a href="#L-3909"><span class="linenos">3909</span></a> <span class="n">collation</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3910"><a href="#L-3910"><span class="linenos">3910</span></a> +</span><span id="L-3911"><a href="#L-3911"><span class="linenos">3911</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">TRIM_TYPES</span><span class="p">):</span> +</span><span id="L-3912"><a href="#L-3912"><span class="linenos">3912</span></a> <span class="n">position</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="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-3913"><a href="#L-3913"><span class="linenos">3913</span></a> +</span><span id="L-3914"><a href="#L-3914"><span class="linenos">3914</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="L-3915"><a href="#L-3915"><span class="linenos">3915</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FROM</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMA</span><span class="p">)):</span> +</span><span id="L-3916"><a href="#L-3916"><span class="linenos">3916</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="L-3917"><a href="#L-3917"><span class="linenos">3917</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3918"><a href="#L-3918"><span class="linenos">3918</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span> +</span><span id="L-3919"><a href="#L-3919"><span class="linenos">3919</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3920"><a href="#L-3920"><span class="linenos">3920</span></a> +</span><span id="L-3921"><a href="#L-3921"><span class="linenos">3921</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">COLLATE</span><span class="p">):</span> +</span><span id="L-3922"><a href="#L-3922"><span class="linenos">3922</span></a> <span class="n">collation</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="L-3923"><a href="#L-3923"><span class="linenos">3923</span></a> +</span><span id="L-3924"><a href="#L-3924"><span class="linenos">3924</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><span id="L-3925"><a href="#L-3925"><span class="linenos">3925</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">position</span><span class="o">=</span><span class="n">position</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">collation</span><span class="o">=</span><span class="n">collation</span> +</span><span id="L-3926"><a href="#L-3926"><span class="linenos">3926</span></a> <span class="p">)</span> +</span><span id="L-3927"><a href="#L-3927"><span class="linenos">3927</span></a> +</span><span id="L-3928"><a href="#L-3928"><span class="linenos">3928</span></a> <span class="k">def</span> <span class="nf">_parse_window_clause</span><span class="p">(</span><span class="bp">self</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">t</span><span class="o">.</span><span class="n">List</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><span id="L-3929"><a href="#L-3929"><span class="linenos">3929</span></a> <span class="k">return</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">WINDOW</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_named_window</span><span class="p">)</span> +</span><span id="L-3930"><a href="#L-3930"><span class="linenos">3930</span></a> +</span><span id="L-3931"><a href="#L-3931"><span class="linenos">3931</span></a> <span class="k">def</span> <span class="nf">_parse_named_window</span><span class="p">(</span><span class="bp">self</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-3932"><a href="#L-3932"><span class="linenos">3932</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(),</span> <span class="n">alias</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-3933"><a href="#L-3933"><span class="linenos">3933</span></a> +</span><span id="L-3934"><a href="#L-3934"><span class="linenos">3934</span></a> <span class="k">def</span> <span class="nf">_parse_respect_or_ignore_nulls</span><span class="p">(</span> +</span><span id="L-3935"><a href="#L-3935"><span class="linenos">3935</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><span id="L-3936"><a href="#L-3936"><span class="linenos">3936</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-3937"><a href="#L-3937"><span class="linenos">3937</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"IGNORE"</span><span class="p">,</span> <span class="s2">"NULLS"</span><span class="p">):</span> +</span><span id="L-3938"><a href="#L-3938"><span class="linenos">3938</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">IgnoreNulls</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-3939"><a href="#L-3939"><span class="linenos">3939</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"RESPECT"</span><span class="p">,</span> <span class="s2">"NULLS"</span><span class="p">):</span> +</span><span id="L-3940"><a href="#L-3940"><span class="linenos">3940</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">RespectNulls</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-3941"><a href="#L-3941"><span class="linenos">3941</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-3942"><a href="#L-3942"><span class="linenos">3942</span></a> +</span><span id="L-3943"><a href="#L-3943"><span class="linenos">3943</span></a> <span class="k">def</span> <span class="nf">_parse_window</span><span class="p">(</span> +</span><span id="L-3944"><a href="#L-3944"><span class="linenos">3944</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="n">alias</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-3945"><a href="#L-3945"><span class="linenos">3945</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-3946"><a href="#L-3946"><span class="linenos">3946</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FILTER</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">):</span> +</span><span id="L-3947"><a href="#L-3947"><span class="linenos">3947</span></a> <span class="n">this</span> <span class="o">=</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">Filter</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">())</span> +</span><span id="L-3948"><a href="#L-3948"><span class="linenos">3948</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-3949"><a href="#L-3949"><span class="linenos">3949</span></a> +</span><span id="L-3950"><a href="#L-3950"><span class="linenos">3950</span></a> <span class="c1"># T-SQL allows the OVER (...) syntax after WITHIN GROUP.</span> +</span><span id="L-3951"><a href="#L-3951"><span class="linenos">3951</span></a> <span class="c1"># https://learn.microsoft.com/en-us/sql/t-sql/functions/percentile-disc-transact-sql?view=sql-server-ver16</span> +</span><span id="L-3952"><a href="#L-3952"><span class="linenos">3952</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITHIN"</span><span class="p">,</span> <span class="s2">"GROUP"</span><span class="p">):</span> +</span><span id="L-3953"><a href="#L-3953"><span class="linenos">3953</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">)</span> +</span><span id="L-3954"><a href="#L-3954"><span class="linenos">3954</span></a> <span class="n">this</span> <span class="o">=</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">WithinGroup</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">order</span><span class="p">)</span> +</span><span id="L-3955"><a href="#L-3955"><span class="linenos">3955</span></a> +</span><span id="L-3956"><a href="#L-3956"><span class="linenos">3956</span></a> <span class="c1"># SQL spec defines an optional [ { IGNORE | RESPECT } NULLS ] OVER</span> +</span><span id="L-3957"><a href="#L-3957"><span class="linenos">3957</span></a> <span class="c1"># Some dialects choose to implement and some do not.</span> +</span><span id="L-3958"><a href="#L-3958"><span class="linenos">3958</span></a> <span class="c1"># https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html</span> +</span><span id="L-3959"><a href="#L-3959"><span class="linenos">3959</span></a> +</span><span id="L-3960"><a href="#L-3960"><span class="linenos">3960</span></a> <span class="c1"># There is some code above in _parse_lambda that handles</span> +</span><span id="L-3961"><a href="#L-3961"><span class="linenos">3961</span></a> <span class="c1"># SELECT FIRST_VALUE(TABLE.COLUMN IGNORE|RESPECT NULLS) OVER ...</span> +</span><span id="L-3962"><a href="#L-3962"><span class="linenos">3962</span></a> +</span><span id="L-3963"><a href="#L-3963"><span class="linenos">3963</span></a> <span class="c1"># The below changes handle</span> +</span><span id="L-3964"><a href="#L-3964"><span class="linenos">3964</span></a> <span class="c1"># SELECT FIRST_VALUE(TABLE.COLUMN) IGNORE|RESPECT NULLS OVER ...</span> +</span><span id="L-3965"><a href="#L-3965"><span class="linenos">3965</span></a> +</span><span id="L-3966"><a href="#L-3966"><span class="linenos">3966</span></a> <span class="c1"># Oracle allows both formats</span> +</span><span id="L-3967"><a href="#L-3967"><span class="linenos">3967</span></a> <span class="c1"># (https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/img_text/first_value.html)</span> +</span><span id="L-3968"><a href="#L-3968"><span class="linenos">3968</span></a> <span class="c1"># and Snowflake chose to do the same for familiarity</span> +</span><span id="L-3969"><a href="#L-3969"><span class="linenos">3969</span></a> <span class="c1"># https://docs.snowflake.com/en/sql-reference/functions/first_value.html#usage-notes</span> +</span><span id="L-3970"><a href="#L-3970"><span class="linenos">3970</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_respect_or_ignore_nulls</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-3971"><a href="#L-3971"><span class="linenos">3971</span></a> +</span><span id="L-3972"><a href="#L-3972"><span class="linenos">3972</span></a> <span class="c1"># bigquery select from window x AS (partition by ...)</span> +</span><span id="L-3973"><a href="#L-3973"><span class="linenos">3973</span></a> <span class="k">if</span> <span class="n">alias</span><span class="p">:</span> +</span><span id="L-3974"><a href="#L-3974"><span class="linenos">3974</span></a> <span class="n">over</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-3975"><a href="#L-3975"><span class="linenos">3975</span></a> <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">ALIAS</span><span class="p">)</span> +</span><span id="L-3976"><a href="#L-3976"><span class="linenos">3976</span></a> <span class="k">elif</span> <span class="ow">not</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">WINDOW_BEFORE_PAREN_TOKENS</span><span class="p">):</span> +</span><span id="L-3977"><a href="#L-3977"><span class="linenos">3977</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-3978"><a href="#L-3978"><span class="linenos">3978</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-3979"><a href="#L-3979"><span class="linenos">3979</span></a> <span class="n">over</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="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-3980"><a href="#L-3980"><span class="linenos">3980</span></a> +</span><span id="L-3981"><a href="#L-3981"><span class="linenos">3981</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">):</span> +</span><span id="L-3982"><a href="#L-3982"><span class="linenos">3982</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><span id="L-3983"><a href="#L-3983"><span class="linenos">3983</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="kc">False</span><span class="p">),</span> <span class="n">over</span><span class="o">=</span><span class="n">over</span> +</span><span id="L-3984"><a href="#L-3984"><span class="linenos">3984</span></a> <span class="p">)</span> +</span><span id="L-3985"><a href="#L-3985"><span class="linenos">3985</span></a> +</span><span id="L-3986"><a href="#L-3986"><span class="linenos">3986</span></a> <span class="n">window_alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">tokens</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">WINDOW_ALIAS_TOKENS</span><span class="p">)</span> </span><span id="L-3987"><a href="#L-3987"><span class="linenos">3987</span></a> -</span><span id="L-3988"><a href="#L-3988"><span class="linenos">3988</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="L-3989"><a href="#L-3989"><span class="linenos">3989</span></a> <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">BETWEEN</span><span class="p">)</span> -</span><span id="L-3990"><a href="#L-3990"><span class="linenos">3990</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window_spec</span><span class="p">()</span> -</span><span id="L-3991"><a href="#L-3991"><span class="linenos">3991</span></a> <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">AND</span><span class="p">)</span> -</span><span id="L-3992"><a href="#L-3992"><span class="linenos">3992</span></a> <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window_spec</span><span class="p">()</span> -</span><span id="L-3993"><a href="#L-3993"><span class="linenos">3993</span></a> -</span><span id="L-3994"><a href="#L-3994"><span class="linenos">3994</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-3995"><a href="#L-3995"><span class="linenos">3995</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WindowSpec</span><span class="p">,</span> -</span><span id="L-3996"><a href="#L-3996"><span class="linenos">3996</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> -</span><span id="L-3997"><a href="#L-3997"><span class="linenos">3997</span></a> <span class="n">start</span><span class="o">=</span><span class="n">start</span><span class="p">[</span><span class="s2">"value"</span><span class="p">],</span> -</span><span id="L-3998"><a href="#L-3998"><span class="linenos">3998</span></a> <span class="n">start_side</span><span class="o">=</span><span class="n">start</span><span class="p">[</span><span class="s2">"side"</span><span class="p">],</span> -</span><span id="L-3999"><a href="#L-3999"><span class="linenos">3999</span></a> <span class="n">end</span><span class="o">=</span><span class="n">end</span><span class="p">[</span><span class="s2">"value"</span><span class="p">],</span> -</span><span id="L-4000"><a href="#L-4000"><span class="linenos">4000</span></a> <span class="n">end_side</span><span class="o">=</span><span class="n">end</span><span class="p">[</span><span class="s2">"side"</span><span class="p">],</span> -</span><span id="L-4001"><a href="#L-4001"><span class="linenos">4001</span></a> <span class="p">)</span> -</span><span id="L-4002"><a href="#L-4002"><span class="linenos">4002</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-4003"><a href="#L-4003"><span class="linenos">4003</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-4004"><a href="#L-4004"><span class="linenos">4004</span></a> -</span><span id="L-4005"><a href="#L-4005"><span class="linenos">4005</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="L-4006"><a href="#L-4006"><span class="linenos">4006</span></a> -</span><span id="L-4007"><a href="#L-4007"><span class="linenos">4007</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><span id="L-4008"><a href="#L-4008"><span class="linenos">4008</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">,</span> -</span><span id="L-4009"><a href="#L-4009"><span class="linenos">4009</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-4010"><a href="#L-4010"><span class="linenos">4010</span></a> <span class="n">partition_by</span><span class="o">=</span><span class="n">partition</span><span class="p">,</span> -</span><span id="L-4011"><a href="#L-4011"><span class="linenos">4011</span></a> <span class="n">order</span><span class="o">=</span><span class="n">order</span><span class="p">,</span> -</span><span id="L-4012"><a href="#L-4012"><span class="linenos">4012</span></a> <span class="n">spec</span><span class="o">=</span><span class="n">spec</span><span class="p">,</span> -</span><span id="L-4013"><a href="#L-4013"><span class="linenos">4013</span></a> <span class="n">alias</span><span class="o">=</span><span class="n">window_alias</span><span class="p">,</span> -</span><span id="L-4014"><a href="#L-4014"><span class="linenos">4014</span></a> <span class="n">over</span><span class="o">=</span><span class="n">over</span><span class="p">,</span> -</span><span id="L-4015"><a href="#L-4015"><span class="linenos">4015</span></a> <span class="n">first</span><span class="o">=</span><span class="n">first</span><span class="p">,</span> -</span><span id="L-4016"><a href="#L-4016"><span class="linenos">4016</span></a> <span class="p">)</span> -</span><span id="L-4017"><a href="#L-4017"><span class="linenos">4017</span></a> -</span><span id="L-4018"><a href="#L-4018"><span class="linenos">4018</span></a> <span class="k">def</span> <span class="nf">_parse_window_spec</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]]:</span> -</span><span id="L-4019"><a href="#L-4019"><span class="linenos">4019</span></a> <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">BETWEEN</span><span class="p">)</span> -</span><span id="L-4020"><a href="#L-4020"><span class="linenos">4020</span></a> -</span><span id="L-4021"><a href="#L-4021"><span class="linenos">4021</span></a> <span class="k">return</span> <span class="p">{</span> -</span><span id="L-4022"><a href="#L-4022"><span class="linenos">4022</span></a> <span class="s2">"value"</span><span class="p">:</span> <span class="p">(</span> -</span><span id="L-4023"><a href="#L-4023"><span class="linenos">4023</span></a> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"UNBOUNDED"</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"UNBOUNDED"</span><span class="p">)</span> -</span><span id="L-4024"><a href="#L-4024"><span class="linenos">4024</span></a> <span class="ow">or</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CURRENT"</span><span class="p">,</span> <span class="s2">"ROW"</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"CURRENT ROW"</span><span class="p">)</span> -</span><span id="L-4025"><a href="#L-4025"><span class="linenos">4025</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="L-4026"><a href="#L-4026"><span class="linenos">4026</span></a> <span class="p">),</span> -</span><span id="L-4027"><a href="#L-4027"><span class="linenos">4027</span></a> <span class="s2">"side"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">WINDOW_SIDES</span><span class="p">)</span> <span class="ow">and</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-4028"><a href="#L-4028"><span class="linenos">4028</span></a> <span class="p">}</span> -</span><span id="L-4029"><a href="#L-4029"><span class="linenos">4029</span></a> -</span><span id="L-4030"><a href="#L-4030"><span class="linenos">4030</span></a> <span class="k">def</span> <span class="nf">_parse_alias</span><span class="p">(</span> -</span><span id="L-4031"><a href="#L-4031"><span class="linenos">4031</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="n">explicit</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-4032"><a href="#L-4032"><span class="linenos">4032</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-4033"><a href="#L-4033"><span class="linenos">4033</span></a> <span class="n">any_token</span> <span class="o">=</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">ALIAS</span><span class="p">)</span> -</span><span id="L-4034"><a href="#L-4034"><span class="linenos">4034</span></a> -</span><span id="L-4035"><a href="#L-4035"><span class="linenos">4035</span></a> <span class="k">if</span> <span class="n">explicit</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">any_token</span><span class="p">:</span> -</span><span id="L-4036"><a href="#L-4036"><span class="linenos">4036</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-3988"><a href="#L-3988"><span class="linenos">3988</span></a> <span class="n">first</span> <span class="o">=</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">FIRST</span><span class="p">)</span> +</span><span id="L-3989"><a href="#L-3989"><span class="linenos">3989</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LAST"</span><span class="p">):</span> +</span><span id="L-3990"><a href="#L-3990"><span class="linenos">3990</span></a> <span class="n">first</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-3991"><a href="#L-3991"><span class="linenos">3991</span></a> +</span><span id="L-3992"><a href="#L-3992"><span class="linenos">3992</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition_by</span><span class="p">()</span> +</span><span id="L-3993"><a href="#L-3993"><span class="linenos">3993</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">()</span> +</span><span id="L-3994"><a href="#L-3994"><span class="linenos">3994</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RANGE</span><span class="p">))</span> <span class="ow">and</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><span id="L-3995"><a href="#L-3995"><span class="linenos">3995</span></a> +</span><span id="L-3996"><a href="#L-3996"><span class="linenos">3996</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="L-3997"><a href="#L-3997"><span class="linenos">3997</span></a> <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">BETWEEN</span><span class="p">)</span> +</span><span id="L-3998"><a href="#L-3998"><span class="linenos">3998</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window_spec</span><span class="p">()</span> +</span><span id="L-3999"><a href="#L-3999"><span class="linenos">3999</span></a> <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">AND</span><span class="p">)</span> +</span><span id="L-4000"><a href="#L-4000"><span class="linenos">4000</span></a> <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window_spec</span><span class="p">()</span> +</span><span id="L-4001"><a href="#L-4001"><span class="linenos">4001</span></a> +</span><span id="L-4002"><a href="#L-4002"><span class="linenos">4002</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-4003"><a href="#L-4003"><span class="linenos">4003</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WindowSpec</span><span class="p">,</span> +</span><span id="L-4004"><a href="#L-4004"><span class="linenos">4004</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> +</span><span id="L-4005"><a href="#L-4005"><span class="linenos">4005</span></a> <span class="n">start</span><span class="o">=</span><span class="n">start</span><span class="p">[</span><span class="s2">"value"</span><span class="p">],</span> +</span><span id="L-4006"><a href="#L-4006"><span class="linenos">4006</span></a> <span class="n">start_side</span><span class="o">=</span><span class="n">start</span><span class="p">[</span><span class="s2">"side"</span><span class="p">],</span> +</span><span id="L-4007"><a href="#L-4007"><span class="linenos">4007</span></a> <span class="n">end</span><span class="o">=</span><span class="n">end</span><span class="p">[</span><span class="s2">"value"</span><span class="p">],</span> +</span><span id="L-4008"><a href="#L-4008"><span class="linenos">4008</span></a> <span class="n">end_side</span><span class="o">=</span><span class="n">end</span><span class="p">[</span><span class="s2">"side"</span><span class="p">],</span> +</span><span id="L-4009"><a href="#L-4009"><span class="linenos">4009</span></a> <span class="p">)</span> +</span><span id="L-4010"><a href="#L-4010"><span class="linenos">4010</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-4011"><a href="#L-4011"><span class="linenos">4011</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-4012"><a href="#L-4012"><span class="linenos">4012</span></a> +</span><span id="L-4013"><a href="#L-4013"><span class="linenos">4013</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-4014"><a href="#L-4014"><span class="linenos">4014</span></a> +</span><span id="L-4015"><a href="#L-4015"><span class="linenos">4015</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><span id="L-4016"><a href="#L-4016"><span class="linenos">4016</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">,</span> +</span><span id="L-4017"><a href="#L-4017"><span class="linenos">4017</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-4018"><a href="#L-4018"><span class="linenos">4018</span></a> <span class="n">partition_by</span><span class="o">=</span><span class="n">partition</span><span class="p">,</span> +</span><span id="L-4019"><a href="#L-4019"><span class="linenos">4019</span></a> <span class="n">order</span><span class="o">=</span><span class="n">order</span><span class="p">,</span> +</span><span id="L-4020"><a href="#L-4020"><span class="linenos">4020</span></a> <span class="n">spec</span><span class="o">=</span><span class="n">spec</span><span class="p">,</span> +</span><span id="L-4021"><a href="#L-4021"><span class="linenos">4021</span></a> <span class="n">alias</span><span class="o">=</span><span class="n">window_alias</span><span class="p">,</span> +</span><span id="L-4022"><a href="#L-4022"><span class="linenos">4022</span></a> <span class="n">over</span><span class="o">=</span><span class="n">over</span><span class="p">,</span> +</span><span id="L-4023"><a href="#L-4023"><span class="linenos">4023</span></a> <span class="n">first</span><span class="o">=</span><span class="n">first</span><span class="p">,</span> +</span><span id="L-4024"><a href="#L-4024"><span class="linenos">4024</span></a> <span class="p">)</span> +</span><span id="L-4025"><a href="#L-4025"><span class="linenos">4025</span></a> +</span><span id="L-4026"><a href="#L-4026"><span class="linenos">4026</span></a> <span class="k">def</span> <span class="nf">_parse_window_spec</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]]:</span> +</span><span id="L-4027"><a href="#L-4027"><span class="linenos">4027</span></a> <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">BETWEEN</span><span class="p">)</span> +</span><span id="L-4028"><a href="#L-4028"><span class="linenos">4028</span></a> +</span><span id="L-4029"><a href="#L-4029"><span class="linenos">4029</span></a> <span class="k">return</span> <span class="p">{</span> +</span><span id="L-4030"><a href="#L-4030"><span class="linenos">4030</span></a> <span class="s2">"value"</span><span class="p">:</span> <span class="p">(</span> +</span><span id="L-4031"><a href="#L-4031"><span class="linenos">4031</span></a> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"UNBOUNDED"</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"UNBOUNDED"</span><span class="p">)</span> +</span><span id="L-4032"><a href="#L-4032"><span class="linenos">4032</span></a> <span class="ow">or</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CURRENT"</span><span class="p">,</span> <span class="s2">"ROW"</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"CURRENT ROW"</span><span class="p">)</span> +</span><span id="L-4033"><a href="#L-4033"><span class="linenos">4033</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="L-4034"><a href="#L-4034"><span class="linenos">4034</span></a> <span class="p">),</span> +</span><span id="L-4035"><a href="#L-4035"><span class="linenos">4035</span></a> <span class="s2">"side"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">WINDOW_SIDES</span><span class="p">)</span> <span class="ow">and</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-4036"><a href="#L-4036"><span class="linenos">4036</span></a> <span class="p">}</span> </span><span id="L-4037"><a href="#L-4037"><span class="linenos">4037</span></a> -</span><span id="L-4038"><a href="#L-4038"><span class="linenos">4038</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_PAREN</span><span class="p">):</span> -</span><span id="L-4039"><a href="#L-4039"><span class="linenos">4039</span></a> <span class="n">aliases</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-4040"><a href="#L-4040"><span class="linenos">4040</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Aliases</span><span class="p">,</span> -</span><span id="L-4041"><a href="#L-4041"><span class="linenos">4041</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-4042"><a href="#L-4042"><span class="linenos">4042</span></a> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="p">)),</span> -</span><span id="L-4043"><a href="#L-4043"><span class="linenos">4043</span></a> <span class="p">)</span> -</span><span id="L-4044"><a href="#L-4044"><span class="linenos">4044</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">(</span><span class="n">aliases</span><span class="p">)</span> -</span><span id="L-4045"><a href="#L-4045"><span class="linenos">4045</span></a> <span class="k">return</span> <span class="n">aliases</span> -</span><span id="L-4046"><a href="#L-4046"><span class="linenos">4046</span></a> -</span><span id="L-4047"><a href="#L-4047"><span class="linenos">4047</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="p">)</span> -</span><span id="L-4048"><a href="#L-4048"><span class="linenos">4048</span></a> -</span><span id="L-4049"><a href="#L-4049"><span class="linenos">4049</span></a> <span class="k">if</span> <span class="n">alias</span><span class="p">:</span> -</span><span id="L-4050"><a href="#L-4050"><span class="linenos">4050</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">Alias</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> -</span><span id="L-4051"><a href="#L-4051"><span class="linenos">4051</span></a> -</span><span id="L-4052"><a href="#L-4052"><span class="linenos">4052</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-4053"><a href="#L-4053"><span class="linenos">4053</span></a> -</span><span id="L-4054"><a href="#L-4054"><span class="linenos">4054</span></a> <span class="k">def</span> <span class="nf">_parse_id_var</span><span class="p">(</span> -</span><span id="L-4055"><a href="#L-4055"><span class="linenos">4055</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-4056"><a href="#L-4056"><span class="linenos">4056</span></a> <span class="n">any_token</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-4057"><a href="#L-4057"><span class="linenos">4057</span></a> <span class="n">tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-4058"><a href="#L-4058"><span class="linenos">4058</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-4059"><a href="#L-4059"><span class="linenos">4059</span></a> <span class="n">identifier</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_identifier</span><span class="p">()</span> -</span><span id="L-4060"><a href="#L-4060"><span class="linenos">4060</span></a> -</span><span id="L-4061"><a href="#L-4061"><span class="linenos">4061</span></a> <span class="k">if</span> <span class="n">identifier</span><span class="p">:</span> -</span><span id="L-4062"><a href="#L-4062"><span class="linenos">4062</span></a> <span class="k">return</span> <span class="n">identifier</span> -</span><span id="L-4063"><a href="#L-4063"><span class="linenos">4063</span></a> -</span><span id="L-4064"><a href="#L-4064"><span class="linenos">4064</span></a> <span class="k">if</span> <span class="p">(</span><span class="n">any_token</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</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="n">tokens</span> <span class="ow">or</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-4065"><a href="#L-4065"><span class="linenos">4065</span></a> <span class="n">quoted</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">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span> -</span><span id="L-4066"><a href="#L-4066"><span class="linenos">4066</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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 class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">)</span> -</span><span id="L-4067"><a href="#L-4067"><span class="linenos">4067</span></a> -</span><span id="L-4068"><a href="#L-4068"><span class="linenos">4068</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-4069"><a href="#L-4069"><span class="linenos">4069</span></a> -</span><span id="L-4070"><a href="#L-4070"><span class="linenos">4070</span></a> <span class="k">def</span> <span class="nf">_parse_string</span><span class="p">(</span><span class="bp">self</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-4071"><a href="#L-4071"><span class="linenos">4071</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">STRING</span><span class="p">):</span> -</span><span id="L-4072"><a href="#L-4072"><span class="linenos">4072</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> -</span><span id="L-4073"><a href="#L-4073"><span class="linenos">4073</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_placeholder</span><span class="p">()</span> -</span><span id="L-4074"><a href="#L-4074"><span class="linenos">4074</span></a> -</span><span id="L-4075"><a href="#L-4075"><span class="linenos">4075</span></a> <span class="k">def</span> <span class="nf">_parse_string_as_identifier</span><span class="p">(</span><span class="bp">self</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">Identifier</span><span class="p">]:</span> -</span><span id="L-4076"><a href="#L-4076"><span class="linenos">4076</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</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">STRING</span><span class="p">)</span> <span class="ow">and</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 class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-4038"><a href="#L-4038"><span class="linenos">4038</span></a> <span class="k">def</span> <span class="nf">_parse_alias</span><span class="p">(</span> +</span><span id="L-4039"><a href="#L-4039"><span class="linenos">4039</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="n">explicit</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-4040"><a href="#L-4040"><span class="linenos">4040</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-4041"><a href="#L-4041"><span class="linenos">4041</span></a> <span class="n">any_token</span> <span class="o">=</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">ALIAS</span><span class="p">)</span> +</span><span id="L-4042"><a href="#L-4042"><span class="linenos">4042</span></a> +</span><span id="L-4043"><a href="#L-4043"><span class="linenos">4043</span></a> <span class="k">if</span> <span class="n">explicit</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">any_token</span><span class="p">:</span> +</span><span id="L-4044"><a href="#L-4044"><span class="linenos">4044</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-4045"><a href="#L-4045"><span class="linenos">4045</span></a> +</span><span id="L-4046"><a href="#L-4046"><span class="linenos">4046</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_PAREN</span><span class="p">):</span> +</span><span id="L-4047"><a href="#L-4047"><span class="linenos">4047</span></a> <span class="n">aliases</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-4048"><a href="#L-4048"><span class="linenos">4048</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Aliases</span><span class="p">,</span> +</span><span id="L-4049"><a href="#L-4049"><span class="linenos">4049</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-4050"><a href="#L-4050"><span class="linenos">4050</span></a> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="p">)),</span> +</span><span id="L-4051"><a href="#L-4051"><span class="linenos">4051</span></a> <span class="p">)</span> +</span><span id="L-4052"><a href="#L-4052"><span class="linenos">4052</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">(</span><span class="n">aliases</span><span class="p">)</span> +</span><span id="L-4053"><a href="#L-4053"><span class="linenos">4053</span></a> <span class="k">return</span> <span class="n">aliases</span> +</span><span id="L-4054"><a href="#L-4054"><span class="linenos">4054</span></a> +</span><span id="L-4055"><a href="#L-4055"><span class="linenos">4055</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="p">)</span> +</span><span id="L-4056"><a href="#L-4056"><span class="linenos">4056</span></a> +</span><span id="L-4057"><a href="#L-4057"><span class="linenos">4057</span></a> <span class="k">if</span> <span class="n">alias</span><span class="p">:</span> +</span><span id="L-4058"><a href="#L-4058"><span class="linenos">4058</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">Alias</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> +</span><span id="L-4059"><a href="#L-4059"><span class="linenos">4059</span></a> +</span><span id="L-4060"><a href="#L-4060"><span class="linenos">4060</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-4061"><a href="#L-4061"><span class="linenos">4061</span></a> +</span><span id="L-4062"><a href="#L-4062"><span class="linenos">4062</span></a> <span class="k">def</span> <span class="nf">_parse_id_var</span><span class="p">(</span> +</span><span id="L-4063"><a href="#L-4063"><span class="linenos">4063</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-4064"><a href="#L-4064"><span class="linenos">4064</span></a> <span class="n">any_token</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-4065"><a href="#L-4065"><span class="linenos">4065</span></a> <span class="n">tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-4066"><a href="#L-4066"><span class="linenos">4066</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-4067"><a href="#L-4067"><span class="linenos">4067</span></a> <span class="n">identifier</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_identifier</span><span class="p">()</span> +</span><span id="L-4068"><a href="#L-4068"><span class="linenos">4068</span></a> +</span><span id="L-4069"><a href="#L-4069"><span class="linenos">4069</span></a> <span class="k">if</span> <span class="n">identifier</span><span class="p">:</span> +</span><span id="L-4070"><a href="#L-4070"><span class="linenos">4070</span></a> <span class="k">return</span> <span class="n">identifier</span> +</span><span id="L-4071"><a href="#L-4071"><span class="linenos">4071</span></a> +</span><span id="L-4072"><a href="#L-4072"><span class="linenos">4072</span></a> <span class="k">if</span> <span class="p">(</span><span class="n">any_token</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</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="n">tokens</span> <span class="ow">or</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-4073"><a href="#L-4073"><span class="linenos">4073</span></a> <span class="n">quoted</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">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span> +</span><span id="L-4074"><a href="#L-4074"><span class="linenos">4074</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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 class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">)</span> +</span><span id="L-4075"><a href="#L-4075"><span class="linenos">4075</span></a> +</span><span id="L-4076"><a href="#L-4076"><span class="linenos">4076</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="L-4077"><a href="#L-4077"><span class="linenos">4077</span></a> -</span><span id="L-4078"><a href="#L-4078"><span class="linenos">4078</span></a> <span class="k">def</span> <span class="nf">_parse_number</span><span class="p">(</span><span class="bp">self</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-4079"><a href="#L-4079"><span class="linenos">4079</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><span id="L-4080"><a href="#L-4080"><span class="linenos">4080</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</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="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="L-4078"><a href="#L-4078"><span class="linenos">4078</span></a> <span class="k">def</span> <span class="nf">_parse_string</span><span class="p">(</span><span class="bp">self</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-4079"><a href="#L-4079"><span class="linenos">4079</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">STRING</span><span class="p">):</span> +</span><span id="L-4080"><a href="#L-4080"><span class="linenos">4080</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> </span><span id="L-4081"><a href="#L-4081"><span class="linenos">4081</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_placeholder</span><span class="p">()</span> </span><span id="L-4082"><a href="#L-4082"><span class="linenos">4082</span></a> -</span><span id="L-4083"><a href="#L-4083"><span class="linenos">4083</span></a> <span class="k">def</span> <span class="nf">_parse_identifier</span><span class="p">(</span><span class="bp">self</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-4084"><a href="#L-4084"><span class="linenos">4084</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">IDENTIFIER</span><span class="p">):</span> -</span><span id="L-4085"><a href="#L-4085"><span class="linenos">4085</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">Identifier</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 class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-4086"><a href="#L-4086"><span class="linenos">4086</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_placeholder</span><span class="p">()</span> -</span><span id="L-4087"><a href="#L-4087"><span class="linenos">4087</span></a> -</span><span id="L-4088"><a href="#L-4088"><span class="linenos">4088</span></a> <span class="k">def</span> <span class="nf">_parse_var</span><span class="p">(</span> -</span><span id="L-4089"><a href="#L-4089"><span class="linenos">4089</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">any_token</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="n">tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-4090"><a href="#L-4090"><span class="linenos">4090</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-4091"><a href="#L-4091"><span class="linenos">4091</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="L-4092"><a href="#L-4092"><span class="linenos">4092</span></a> <span class="p">(</span><span class="n">any_token</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</span><span class="p">())</span> -</span><span id="L-4093"><a href="#L-4093"><span class="linenos">4093</span></a> <span class="ow">or</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">VAR</span><span class="p">)</span> -</span><span id="L-4094"><a href="#L-4094"><span class="linenos">4094</span></a> <span class="ow">or</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">(</span><span class="n">tokens</span><span class="p">)</span> <span class="k">if</span> <span class="n">tokens</span> <span class="k">else</span> <span class="kc">False</span><span class="p">)</span> -</span><span id="L-4095"><a href="#L-4095"><span class="linenos">4095</span></a> <span class="p">):</span> -</span><span id="L-4096"><a href="#L-4096"><span class="linenos">4096</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">Var</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-4097"><a href="#L-4097"><span class="linenos">4097</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_placeholder</span><span class="p">()</span> -</span><span id="L-4098"><a href="#L-4098"><span class="linenos">4098</span></a> -</span><span id="L-4099"><a href="#L-4099"><span class="linenos">4099</span></a> <span class="k">def</span> <span class="nf">_advance_any</span><span class="p">(</span><span class="bp">self</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">Token</span><span class="p">]:</span> -</span><span id="L-4100"><a href="#L-4100"><span class="linenos">4100</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span><span class="p">:</span> -</span><span id="L-4101"><a href="#L-4101"><span class="linenos">4101</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-4102"><a href="#L-4102"><span class="linenos">4102</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> -</span><span id="L-4103"><a href="#L-4103"><span class="linenos">4103</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-4104"><a href="#L-4104"><span class="linenos">4104</span></a> -</span><span id="L-4105"><a href="#L-4105"><span class="linenos">4105</span></a> <span class="k">def</span> <span class="nf">_parse_var_or_string</span><span class="p">(</span><span class="bp">self</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-4106"><a href="#L-4106"><span class="linenos">4106</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="L-4107"><a href="#L-4107"><span class="linenos">4107</span></a> -</span><span id="L-4108"><a href="#L-4108"><span class="linenos">4108</span></a> <span class="k">def</span> <span class="nf">_parse_null</span><span class="p">(</span><span class="bp">self</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-4109"><a href="#L-4109"><span class="linenos">4109</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">NULL</span><span class="p">):</span> -</span><span id="L-4110"><a href="#L-4110"><span class="linenos">4110</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="L-4083"><a href="#L-4083"><span class="linenos">4083</span></a> <span class="k">def</span> <span class="nf">_parse_string_as_identifier</span><span class="p">(</span><span class="bp">self</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">Identifier</span><span class="p">]:</span> +</span><span id="L-4084"><a href="#L-4084"><span class="linenos">4084</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</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">STRING</span><span class="p">)</span> <span class="ow">and</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 class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-4085"><a href="#L-4085"><span class="linenos">4085</span></a> +</span><span id="L-4086"><a href="#L-4086"><span class="linenos">4086</span></a> <span class="k">def</span> <span class="nf">_parse_number</span><span class="p">(</span><span class="bp">self</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-4087"><a href="#L-4087"><span class="linenos">4087</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><span id="L-4088"><a href="#L-4088"><span class="linenos">4088</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</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="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="L-4089"><a href="#L-4089"><span class="linenos">4089</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_placeholder</span><span class="p">()</span> +</span><span id="L-4090"><a href="#L-4090"><span class="linenos">4090</span></a> +</span><span id="L-4091"><a href="#L-4091"><span class="linenos">4091</span></a> <span class="k">def</span> <span class="nf">_parse_identifier</span><span class="p">(</span><span class="bp">self</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-4092"><a href="#L-4092"><span class="linenos">4092</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">IDENTIFIER</span><span class="p">):</span> +</span><span id="L-4093"><a href="#L-4093"><span class="linenos">4093</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">Identifier</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 class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-4094"><a href="#L-4094"><span class="linenos">4094</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_placeholder</span><span class="p">()</span> +</span><span id="L-4095"><a href="#L-4095"><span class="linenos">4095</span></a> +</span><span id="L-4096"><a href="#L-4096"><span class="linenos">4096</span></a> <span class="k">def</span> <span class="nf">_parse_var</span><span class="p">(</span> +</span><span id="L-4097"><a href="#L-4097"><span class="linenos">4097</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">any_token</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="n">tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-4098"><a href="#L-4098"><span class="linenos">4098</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-4099"><a href="#L-4099"><span class="linenos">4099</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="L-4100"><a href="#L-4100"><span class="linenos">4100</span></a> <span class="p">(</span><span class="n">any_token</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</span><span class="p">())</span> +</span><span id="L-4101"><a href="#L-4101"><span class="linenos">4101</span></a> <span class="ow">or</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">VAR</span><span class="p">)</span> +</span><span id="L-4102"><a href="#L-4102"><span class="linenos">4102</span></a> <span class="ow">or</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">(</span><span class="n">tokens</span><span class="p">)</span> <span class="k">if</span> <span class="n">tokens</span> <span class="k">else</span> <span class="kc">False</span><span class="p">)</span> +</span><span id="L-4103"><a href="#L-4103"><span class="linenos">4103</span></a> <span class="p">):</span> +</span><span id="L-4104"><a href="#L-4104"><span class="linenos">4104</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">Var</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-4105"><a href="#L-4105"><span class="linenos">4105</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_placeholder</span><span class="p">()</span> +</span><span id="L-4106"><a href="#L-4106"><span class="linenos">4106</span></a> +</span><span id="L-4107"><a href="#L-4107"><span class="linenos">4107</span></a> <span class="k">def</span> <span class="nf">_advance_any</span><span class="p">(</span><span class="bp">self</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">Token</span><span class="p">]:</span> +</span><span id="L-4108"><a href="#L-4108"><span class="linenos">4108</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span><span class="p">:</span> +</span><span id="L-4109"><a href="#L-4109"><span class="linenos">4109</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-4110"><a href="#L-4110"><span class="linenos">4110</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> </span><span id="L-4111"><a href="#L-4111"><span class="linenos">4111</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="L-4112"><a href="#L-4112"><span class="linenos">4112</span></a> -</span><span id="L-4113"><a href="#L-4113"><span class="linenos">4113</span></a> <span class="k">def</span> <span class="nf">_parse_boolean</span><span class="p">(</span><span class="bp">self</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-4114"><a href="#L-4114"><span class="linenos">4114</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">TRUE</span><span class="p">):</span> -</span><span id="L-4115"><a href="#L-4115"><span class="linenos">4115</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">TRUE</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> -</span><span id="L-4116"><a href="#L-4116"><span class="linenos">4116</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">FALSE</span><span class="p">):</span> -</span><span id="L-4117"><a href="#L-4117"><span class="linenos">4117</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FALSE</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> -</span><span id="L-4118"><a href="#L-4118"><span class="linenos">4118</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-4119"><a href="#L-4119"><span class="linenos">4119</span></a> -</span><span id="L-4120"><a href="#L-4120"><span class="linenos">4120</span></a> <span class="k">def</span> <span class="nf">_parse_star</span><span class="p">(</span><span class="bp">self</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-4121"><a href="#L-4121"><span class="linenos">4121</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">STAR</span><span class="p">):</span> -</span><span id="L-4122"><a href="#L-4122"><span class="linenos">4122</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STAR</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> -</span><span id="L-4123"><a href="#L-4123"><span class="linenos">4123</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-4124"><a href="#L-4124"><span class="linenos">4124</span></a> -</span><span id="L-4125"><a href="#L-4125"><span class="linenos">4125</span></a> <span class="k">def</span> <span class="nf">_parse_parameter</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">Parameter</span><span class="p">:</span> -</span><span id="L-4126"><a href="#L-4126"><span class="linenos">4126</span></a> <span class="n">wrapped</span> <span class="o">=</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><span id="L-4127"><a href="#L-4127"><span class="linenos">4127</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_identifier</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> -</span><span id="L-4128"><a href="#L-4128"><span class="linenos">4128</span></a> <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">R_BRACE</span><span class="p">)</span> -</span><span id="L-4129"><a href="#L-4129"><span class="linenos">4129</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">Parameter</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">wrapped</span><span class="o">=</span><span class="n">wrapped</span><span class="p">)</span> -</span><span id="L-4130"><a href="#L-4130"><span class="linenos">4130</span></a> -</span><span id="L-4131"><a href="#L-4131"><span class="linenos">4131</span></a> <span class="k">def</span> <span class="nf">_parse_placeholder</span><span class="p">(</span><span class="bp">self</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-4132"><a href="#L-4132"><span class="linenos">4132</span></a> <span class="k">if</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">PLACEHOLDER_PARSERS</span><span class="p">):</span> -</span><span id="L-4133"><a href="#L-4133"><span class="linenos">4133</span></a> <span class="n">placeholder</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PLACEHOLDER_PARSERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> -</span><span id="L-4134"><a href="#L-4134"><span class="linenos">4134</span></a> <span class="k">if</span> <span class="n">placeholder</span><span class="p">:</span> -</span><span id="L-4135"><a href="#L-4135"><span class="linenos">4135</span></a> <span class="k">return</span> <span class="n">placeholder</span> -</span><span id="L-4136"><a href="#L-4136"><span class="linenos">4136</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> -</span><span id="L-4137"><a href="#L-4137"><span class="linenos">4137</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-4113"><a href="#L-4113"><span class="linenos">4113</span></a> <span class="k">def</span> <span class="nf">_parse_var_or_string</span><span class="p">(</span><span class="bp">self</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-4114"><a href="#L-4114"><span class="linenos">4114</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="L-4115"><a href="#L-4115"><span class="linenos">4115</span></a> +</span><span id="L-4116"><a href="#L-4116"><span class="linenos">4116</span></a> <span class="k">def</span> <span class="nf">_parse_null</span><span class="p">(</span><span class="bp">self</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-4117"><a href="#L-4117"><span class="linenos">4117</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">NULL</span><span class="p">):</span> +</span><span id="L-4118"><a href="#L-4118"><span class="linenos">4118</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="L-4119"><a href="#L-4119"><span class="linenos">4119</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-4120"><a href="#L-4120"><span class="linenos">4120</span></a> +</span><span id="L-4121"><a href="#L-4121"><span class="linenos">4121</span></a> <span class="k">def</span> <span class="nf">_parse_boolean</span><span class="p">(</span><span class="bp">self</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-4122"><a href="#L-4122"><span class="linenos">4122</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">TRUE</span><span class="p">):</span> +</span><span id="L-4123"><a href="#L-4123"><span class="linenos">4123</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">TRUE</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="L-4124"><a href="#L-4124"><span class="linenos">4124</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">FALSE</span><span class="p">):</span> +</span><span id="L-4125"><a href="#L-4125"><span class="linenos">4125</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FALSE</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="L-4126"><a href="#L-4126"><span class="linenos">4126</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-4127"><a href="#L-4127"><span class="linenos">4127</span></a> +</span><span id="L-4128"><a href="#L-4128"><span class="linenos">4128</span></a> <span class="k">def</span> <span class="nf">_parse_star</span><span class="p">(</span><span class="bp">self</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-4129"><a href="#L-4129"><span class="linenos">4129</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">STAR</span><span class="p">):</span> +</span><span id="L-4130"><a href="#L-4130"><span class="linenos">4130</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STAR</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="L-4131"><a href="#L-4131"><span class="linenos">4131</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-4132"><a href="#L-4132"><span class="linenos">4132</span></a> +</span><span id="L-4133"><a href="#L-4133"><span class="linenos">4133</span></a> <span class="k">def</span> <span class="nf">_parse_parameter</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">Parameter</span><span class="p">:</span> +</span><span id="L-4134"><a href="#L-4134"><span class="linenos">4134</span></a> <span class="n">wrapped</span> <span class="o">=</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><span id="L-4135"><a href="#L-4135"><span class="linenos">4135</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_identifier</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="L-4136"><a href="#L-4136"><span class="linenos">4136</span></a> <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">R_BRACE</span><span class="p">)</span> +</span><span id="L-4137"><a href="#L-4137"><span class="linenos">4137</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">Parameter</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">wrapped</span><span class="o">=</span><span class="n">wrapped</span><span class="p">)</span> </span><span id="L-4138"><a href="#L-4138"><span class="linenos">4138</span></a> -</span><span id="L-4139"><a href="#L-4139"><span class="linenos">4139</span></a> <span class="k">def</span> <span class="nf">_parse_except</span><span class="p">(</span><span class="bp">self</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">t</span><span class="o">.</span><span class="n">List</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><span id="L-4140"><a href="#L-4140"><span class="linenos">4140</span></a> <span class="k">if</span> <span class="ow">not</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">EXCEPT</span><span class="p">):</span> -</span><span id="L-4141"><a href="#L-4141"><span class="linenos">4141</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-4142"><a href="#L-4142"><span class="linenos">4142</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_PAREN</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-4143"><a href="#L-4143"><span class="linenos">4143</span></a> <span class="k">return</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_column</span><span class="p">)</span> -</span><span id="L-4144"><a href="#L-4144"><span class="linenos">4144</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">)</span> -</span><span id="L-4145"><a href="#L-4145"><span class="linenos">4145</span></a> -</span><span id="L-4146"><a href="#L-4146"><span class="linenos">4146</span></a> <span class="k">def</span> <span class="nf">_parse_replace</span><span class="p">(</span><span class="bp">self</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">t</span><span class="o">.</span><span class="n">List</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><span id="L-4147"><a href="#L-4147"><span class="linenos">4147</span></a> <span class="k">if</span> <span class="ow">not</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">REPLACE</span><span class="p">):</span> -</span><span id="L-4148"><a href="#L-4148"><span class="linenos">4148</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-4149"><a href="#L-4149"><span class="linenos">4149</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_PAREN</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-4150"><a href="#L-4150"><span class="linenos">4150</span></a> <span class="k">return</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_expression</span><span class="p">)</span> -</span><span id="L-4151"><a href="#L-4151"><span class="linenos">4151</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">)</span> -</span><span id="L-4152"><a href="#L-4152"><span class="linenos">4152</span></a> -</span><span id="L-4153"><a href="#L-4153"><span class="linenos">4153</span></a> <span class="k">def</span> <span class="nf">_parse_csv</span><span class="p">(</span> -</span><span id="L-4154"><a href="#L-4154"><span class="linenos">4154</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="n">TokenType</span> <span class="o">=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMA</span> -</span><span id="L-4155"><a href="#L-4155"><span class="linenos">4155</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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-4156"><a href="#L-4156"><span class="linenos">4156</span></a> <span class="n">parse_result</span> <span class="o">=</span> <span class="n">parse_method</span><span class="p">()</span> -</span><span id="L-4157"><a href="#L-4157"><span class="linenos">4157</span></a> <span class="n">items</span> <span class="o">=</span> <span class="p">[</span><span class="n">parse_result</span><span class="p">]</span> <span class="k">if</span> <span class="n">parse_result</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="p">[]</span> -</span><span id="L-4158"><a href="#L-4158"><span class="linenos">4158</span></a> -</span><span id="L-4159"><a href="#L-4159"><span class="linenos">4159</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">sep</span><span class="p">):</span> -</span><span id="L-4160"><a href="#L-4160"><span class="linenos">4160</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add_comments</span><span class="p">(</span><span class="n">parse_result</span><span class="p">)</span> -</span><span id="L-4161"><a href="#L-4161"><span class="linenos">4161</span></a> <span class="n">parse_result</span> <span class="o">=</span> <span class="n">parse_method</span><span class="p">()</span> -</span><span id="L-4162"><a href="#L-4162"><span class="linenos">4162</span></a> <span class="k">if</span> <span class="n">parse_result</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-4163"><a href="#L-4163"><span class="linenos">4163</span></a> <span class="n">items</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">parse_result</span><span class="p">)</span> -</span><span id="L-4164"><a href="#L-4164"><span class="linenos">4164</span></a> -</span><span id="L-4165"><a href="#L-4165"><span class="linenos">4165</span></a> <span class="k">return</span> <span class="n">items</span> +</span><span id="L-4139"><a href="#L-4139"><span class="linenos">4139</span></a> <span class="k">def</span> <span class="nf">_parse_placeholder</span><span class="p">(</span><span class="bp">self</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-4140"><a href="#L-4140"><span class="linenos">4140</span></a> <span class="k">if</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">PLACEHOLDER_PARSERS</span><span class="p">):</span> +</span><span id="L-4141"><a href="#L-4141"><span class="linenos">4141</span></a> <span class="n">placeholder</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PLACEHOLDER_PARSERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> +</span><span id="L-4142"><a href="#L-4142"><span class="linenos">4142</span></a> <span class="k">if</span> <span class="n">placeholder</span><span class="p">:</span> +</span><span id="L-4143"><a href="#L-4143"><span class="linenos">4143</span></a> <span class="k">return</span> <span class="n">placeholder</span> +</span><span id="L-4144"><a href="#L-4144"><span class="linenos">4144</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> +</span><span id="L-4145"><a href="#L-4145"><span class="linenos">4145</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-4146"><a href="#L-4146"><span class="linenos">4146</span></a> +</span><span id="L-4147"><a href="#L-4147"><span class="linenos">4147</span></a> <span class="k">def</span> <span class="nf">_parse_except</span><span class="p">(</span><span class="bp">self</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">t</span><span class="o">.</span><span class="n">List</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><span id="L-4148"><a href="#L-4148"><span class="linenos">4148</span></a> <span class="k">if</span> <span class="ow">not</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">EXCEPT</span><span class="p">):</span> +</span><span id="L-4149"><a href="#L-4149"><span class="linenos">4149</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-4150"><a href="#L-4150"><span class="linenos">4150</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_PAREN</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-4151"><a href="#L-4151"><span class="linenos">4151</span></a> <span class="k">return</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_column</span><span class="p">)</span> +</span><span id="L-4152"><a href="#L-4152"><span class="linenos">4152</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">)</span> +</span><span id="L-4153"><a href="#L-4153"><span class="linenos">4153</span></a> +</span><span id="L-4154"><a href="#L-4154"><span class="linenos">4154</span></a> <span class="k">def</span> <span class="nf">_parse_replace</span><span class="p">(</span><span class="bp">self</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">t</span><span class="o">.</span><span class="n">List</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><span id="L-4155"><a href="#L-4155"><span class="linenos">4155</span></a> <span class="k">if</span> <span class="ow">not</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">REPLACE</span><span class="p">):</span> +</span><span id="L-4156"><a href="#L-4156"><span class="linenos">4156</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-4157"><a href="#L-4157"><span class="linenos">4157</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_PAREN</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-4158"><a href="#L-4158"><span class="linenos">4158</span></a> <span class="k">return</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_expression</span><span class="p">)</span> +</span><span id="L-4159"><a href="#L-4159"><span class="linenos">4159</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">)</span> +</span><span id="L-4160"><a href="#L-4160"><span class="linenos">4160</span></a> +</span><span id="L-4161"><a href="#L-4161"><span class="linenos">4161</span></a> <span class="k">def</span> <span class="nf">_parse_csv</span><span class="p">(</span> +</span><span id="L-4162"><a href="#L-4162"><span class="linenos">4162</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="n">TokenType</span> <span class="o">=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMA</span> +</span><span id="L-4163"><a href="#L-4163"><span class="linenos">4163</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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-4164"><a href="#L-4164"><span class="linenos">4164</span></a> <span class="n">parse_result</span> <span class="o">=</span> <span class="n">parse_method</span><span class="p">()</span> +</span><span id="L-4165"><a href="#L-4165"><span class="linenos">4165</span></a> <span class="n">items</span> <span class="o">=</span> <span class="p">[</span><span class="n">parse_result</span><span class="p">]</span> <span class="k">if</span> <span class="n">parse_result</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="p">[]</span> </span><span id="L-4166"><a href="#L-4166"><span class="linenos">4166</span></a> -</span><span id="L-4167"><a href="#L-4167"><span class="linenos">4167</span></a> <span class="k">def</span> <span class="nf">_parse_tokens</span><span class="p">(</span> -</span><span id="L-4168"><a href="#L-4168"><span class="linenos">4168</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">expressions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> -</span><span id="L-4169"><a href="#L-4169"><span class="linenos">4169</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-4170"><a href="#L-4170"><span class="linenos">4170</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">parse_method</span><span class="p">()</span> -</span><span id="L-4171"><a href="#L-4171"><span class="linenos">4171</span></a> -</span><span id="L-4172"><a href="#L-4172"><span class="linenos">4172</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">(</span><span class="n">expressions</span><span class="p">):</span> -</span><span id="L-4173"><a href="#L-4173"><span class="linenos">4173</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-4174"><a href="#L-4174"><span class="linenos">4174</span></a> <span class="n">expressions</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">],</span> -</span><span id="L-4175"><a href="#L-4175"><span class="linenos">4175</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-4176"><a href="#L-4176"><span class="linenos">4176</span></a> <span class="n">comments</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span><span class="p">,</span> -</span><span id="L-4177"><a href="#L-4177"><span class="linenos">4177</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">parse_method</span><span class="p">(),</span> -</span><span id="L-4178"><a href="#L-4178"><span class="linenos">4178</span></a> <span class="p">)</span> +</span><span id="L-4167"><a href="#L-4167"><span class="linenos">4167</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">sep</span><span class="p">):</span> +</span><span id="L-4168"><a href="#L-4168"><span class="linenos">4168</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add_comments</span><span class="p">(</span><span class="n">parse_result</span><span class="p">)</span> +</span><span id="L-4169"><a href="#L-4169"><span class="linenos">4169</span></a> <span class="n">parse_result</span> <span class="o">=</span> <span class="n">parse_method</span><span class="p">()</span> +</span><span id="L-4170"><a href="#L-4170"><span class="linenos">4170</span></a> <span class="k">if</span> <span class="n">parse_result</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-4171"><a href="#L-4171"><span class="linenos">4171</span></a> <span class="n">items</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">parse_result</span><span class="p">)</span> +</span><span id="L-4172"><a href="#L-4172"><span class="linenos">4172</span></a> +</span><span id="L-4173"><a href="#L-4173"><span class="linenos">4173</span></a> <span class="k">return</span> <span class="n">items</span> +</span><span id="L-4174"><a href="#L-4174"><span class="linenos">4174</span></a> +</span><span id="L-4175"><a href="#L-4175"><span class="linenos">4175</span></a> <span class="k">def</span> <span class="nf">_parse_tokens</span><span class="p">(</span> +</span><span id="L-4176"><a href="#L-4176"><span class="linenos">4176</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">expressions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> +</span><span id="L-4177"><a href="#L-4177"><span class="linenos">4177</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-4178"><a href="#L-4178"><span class="linenos">4178</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">parse_method</span><span class="p">()</span> </span><span id="L-4179"><a href="#L-4179"><span class="linenos">4179</span></a> -</span><span id="L-4180"><a href="#L-4180"><span class="linenos">4180</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-4181"><a href="#L-4181"><span class="linenos">4181</span></a> -</span><span id="L-4182"><a href="#L-4182"><span class="linenos">4182</span></a> <span class="k">def</span> <span class="nf">_parse_wrapped_id_vars</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">optional</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">List</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><span id="L-4183"><a href="#L-4183"><span class="linenos">4183</span></a> <span class="k">return</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_id_var</span><span class="p">,</span> <span class="n">optional</span><span class="o">=</span><span class="n">optional</span><span class="p">)</span> -</span><span id="L-4184"><a href="#L-4184"><span class="linenos">4184</span></a> -</span><span id="L-4185"><a href="#L-4185"><span class="linenos">4185</span></a> <span class="k">def</span> <span class="nf">_parse_wrapped_csv</span><span class="p">(</span> -</span><span id="L-4186"><a href="#L-4186"><span class="linenos">4186</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="n">TokenType</span> <span class="o">=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMA</span><span class="p">,</span> <span class="n">optional</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-4187"><a href="#L-4187"><span class="linenos">4187</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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-4188"><a href="#L-4188"><span class="linenos">4188</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span> -</span><span id="L-4189"><a href="#L-4189"><span class="linenos">4189</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">parse_method</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">optional</span><span class="o">=</span><span class="n">optional</span> -</span><span id="L-4190"><a href="#L-4190"><span class="linenos">4190</span></a> <span class="p">)</span> -</span><span id="L-4191"><a href="#L-4191"><span class="linenos">4191</span></a> -</span><span id="L-4192"><a href="#L-4192"><span class="linenos">4192</span></a> <span class="k">def</span> <span class="nf">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">optional</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">Any</span><span class="p">:</span> -</span><span id="L-4193"><a href="#L-4193"><span class="linenos">4193</span></a> <span class="n">wrapped</span> <span class="o">=</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_PAREN</span><span class="p">)</span> -</span><span id="L-4194"><a href="#L-4194"><span class="linenos">4194</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">wrapped</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">optional</span><span class="p">:</span> -</span><span id="L-4195"><a href="#L-4195"><span class="linenos">4195</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting ("</span><span class="p">)</span> -</span><span id="L-4196"><a href="#L-4196"><span class="linenos">4196</span></a> <span class="n">parse_result</span> <span class="o">=</span> <span class="n">parse_method</span><span class="p">()</span> -</span><span id="L-4197"><a href="#L-4197"><span class="linenos">4197</span></a> <span class="k">if</span> <span class="n">wrapped</span><span class="p">:</span> -</span><span id="L-4198"><a href="#L-4198"><span class="linenos">4198</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="L-4199"><a href="#L-4199"><span class="linenos">4199</span></a> <span class="k">return</span> <span class="n">parse_result</span> -</span><span id="L-4200"><a href="#L-4200"><span class="linenos">4200</span></a> -</span><span id="L-4201"><a href="#L-4201"><span class="linenos">4201</span></a> <span class="k">def</span> <span class="nf">_parse_select_or_expression</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">alias</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-4202"><a href="#L-4202"><span class="linenos">4202</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span> -</span><span id="L-4203"><a href="#L-4203"><span class="linenos">4203</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">()</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="L-4204"><a href="#L-4204"><span class="linenos">4204</span></a> <span class="p">)</span> -</span><span id="L-4205"><a href="#L-4205"><span class="linenos">4205</span></a> -</span><span id="L-4206"><a href="#L-4206"><span class="linenos">4206</span></a> <span class="k">def</span> <span class="nf">_parse_ddl_select</span><span class="p">(</span><span class="bp">self</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-4207"><a href="#L-4207"><span class="linenos">4207</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span> -</span><span id="L-4208"><a href="#L-4208"><span class="linenos">4208</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">parse_subquery_alias</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> -</span><span id="L-4209"><a href="#L-4209"><span class="linenos">4209</span></a> <span class="p">)</span> -</span><span id="L-4210"><a href="#L-4210"><span class="linenos">4210</span></a> -</span><span id="L-4211"><a href="#L-4211"><span class="linenos">4211</span></a> <span class="k">def</span> <span class="nf">_parse_transaction</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">Transaction</span><span class="p">:</span> -</span><span id="L-4212"><a href="#L-4212"><span class="linenos">4212</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-4213"><a href="#L-4213"><span class="linenos">4213</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">TRANSACTION_KIND</span><span class="p">):</span> -</span><span id="L-4214"><a href="#L-4214"><span class="linenos">4214</span></a> <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><span id="L-4215"><a href="#L-4215"><span class="linenos">4215</span></a> -</span><span id="L-4216"><a href="#L-4216"><span class="linenos">4216</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">({</span><span class="s2">"TRANSACTION"</span><span class="p">,</span> <span class="s2">"WORK"</span><span class="p">})</span> -</span><span id="L-4217"><a href="#L-4217"><span class="linenos">4217</span></a> -</span><span id="L-4218"><a href="#L-4218"><span class="linenos">4218</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-4219"><a href="#L-4219"><span class="linenos">4219</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-4220"><a href="#L-4220"><span class="linenos">4220</span></a> <span class="n">mode</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-4221"><a href="#L-4221"><span class="linenos">4221</span></a> <span class="k">while</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">VAR</span><span class="p">):</span> -</span><span id="L-4222"><a href="#L-4222"><span class="linenos">4222</span></a> <span class="n">mode</span><span class="o">.</span><span class="n">append</span><span class="p">(</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-4180"><a href="#L-4180"><span class="linenos">4180</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">(</span><span class="n">expressions</span><span class="p">):</span> +</span><span id="L-4181"><a href="#L-4181"><span class="linenos">4181</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-4182"><a href="#L-4182"><span class="linenos">4182</span></a> <span class="n">expressions</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">],</span> +</span><span id="L-4183"><a href="#L-4183"><span class="linenos">4183</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-4184"><a href="#L-4184"><span class="linenos">4184</span></a> <span class="n">comments</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span><span class="p">,</span> +</span><span id="L-4185"><a href="#L-4185"><span class="linenos">4185</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">parse_method</span><span class="p">(),</span> +</span><span id="L-4186"><a href="#L-4186"><span class="linenos">4186</span></a> <span class="p">)</span> +</span><span id="L-4187"><a href="#L-4187"><span class="linenos">4187</span></a> +</span><span id="L-4188"><a href="#L-4188"><span class="linenos">4188</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-4189"><a href="#L-4189"><span class="linenos">4189</span></a> +</span><span id="L-4190"><a href="#L-4190"><span class="linenos">4190</span></a> <span class="k">def</span> <span class="nf">_parse_wrapped_id_vars</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">optional</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">List</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><span id="L-4191"><a href="#L-4191"><span class="linenos">4191</span></a> <span class="k">return</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_id_var</span><span class="p">,</span> <span class="n">optional</span><span class="o">=</span><span class="n">optional</span><span class="p">)</span> +</span><span id="L-4192"><a href="#L-4192"><span class="linenos">4192</span></a> +</span><span id="L-4193"><a href="#L-4193"><span class="linenos">4193</span></a> <span class="k">def</span> <span class="nf">_parse_wrapped_csv</span><span class="p">(</span> +</span><span id="L-4194"><a href="#L-4194"><span class="linenos">4194</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="n">TokenType</span> <span class="o">=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMA</span><span class="p">,</span> <span class="n">optional</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-4195"><a href="#L-4195"><span class="linenos">4195</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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-4196"><a href="#L-4196"><span class="linenos">4196</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span> +</span><span id="L-4197"><a href="#L-4197"><span class="linenos">4197</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">parse_method</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">optional</span><span class="o">=</span><span class="n">optional</span> +</span><span id="L-4198"><a href="#L-4198"><span class="linenos">4198</span></a> <span class="p">)</span> +</span><span id="L-4199"><a href="#L-4199"><span class="linenos">4199</span></a> +</span><span id="L-4200"><a href="#L-4200"><span class="linenos">4200</span></a> <span class="k">def</span> <span class="nf">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">optional</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">Any</span><span class="p">:</span> +</span><span id="L-4201"><a href="#L-4201"><span class="linenos">4201</span></a> <span class="n">wrapped</span> <span class="o">=</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_PAREN</span><span class="p">)</span> +</span><span id="L-4202"><a href="#L-4202"><span class="linenos">4202</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">wrapped</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">optional</span><span class="p">:</span> +</span><span id="L-4203"><a href="#L-4203"><span class="linenos">4203</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting ("</span><span class="p">)</span> +</span><span id="L-4204"><a href="#L-4204"><span class="linenos">4204</span></a> <span class="n">parse_result</span> <span class="o">=</span> <span class="n">parse_method</span><span class="p">()</span> +</span><span id="L-4205"><a href="#L-4205"><span class="linenos">4205</span></a> <span class="k">if</span> <span class="n">wrapped</span><span class="p">:</span> +</span><span id="L-4206"><a href="#L-4206"><span class="linenos">4206</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-4207"><a href="#L-4207"><span class="linenos">4207</span></a> <span class="k">return</span> <span class="n">parse_result</span> +</span><span id="L-4208"><a href="#L-4208"><span class="linenos">4208</span></a> +</span><span id="L-4209"><a href="#L-4209"><span class="linenos">4209</span></a> <span class="k">def</span> <span class="nf">_parse_select_or_expression</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">alias</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-4210"><a href="#L-4210"><span class="linenos">4210</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span> +</span><span id="L-4211"><a href="#L-4211"><span class="linenos">4211</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">()</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="L-4212"><a href="#L-4212"><span class="linenos">4212</span></a> <span class="p">)</span> +</span><span id="L-4213"><a href="#L-4213"><span class="linenos">4213</span></a> +</span><span id="L-4214"><a href="#L-4214"><span class="linenos">4214</span></a> <span class="k">def</span> <span class="nf">_parse_ddl_select</span><span class="p">(</span><span class="bp">self</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-4215"><a href="#L-4215"><span class="linenos">4215</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span> +</span><span id="L-4216"><a href="#L-4216"><span class="linenos">4216</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">parse_subquery_alias</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> +</span><span id="L-4217"><a href="#L-4217"><span class="linenos">4217</span></a> <span class="p">)</span> +</span><span id="L-4218"><a href="#L-4218"><span class="linenos">4218</span></a> +</span><span id="L-4219"><a href="#L-4219"><span class="linenos">4219</span></a> <span class="k">def</span> <span class="nf">_parse_transaction</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">Transaction</span><span class="p">:</span> +</span><span id="L-4220"><a href="#L-4220"><span class="linenos">4220</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-4221"><a href="#L-4221"><span class="linenos">4221</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">TRANSACTION_KIND</span><span class="p">):</span> +</span><span id="L-4222"><a href="#L-4222"><span class="linenos">4222</span></a> <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><span id="L-4223"><a href="#L-4223"><span class="linenos">4223</span></a> -</span><span id="L-4224"><a href="#L-4224"><span class="linenos">4224</span></a> <span class="k">if</span> <span class="n">mode</span><span class="p">:</span> -</span><span id="L-4225"><a href="#L-4225"><span class="linenos">4225</span></a> <span class="n">modes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">mode</span><span class="p">))</span> -</span><span id="L-4226"><a href="#L-4226"><span class="linenos">4226</span></a> <span class="k">if</span> <span class="ow">not</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">COMMA</span><span class="p">):</span> -</span><span id="L-4227"><a href="#L-4227"><span class="linenos">4227</span></a> <span class="k">break</span> -</span><span id="L-4228"><a href="#L-4228"><span class="linenos">4228</span></a> -</span><span id="L-4229"><a href="#L-4229"><span class="linenos">4229</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">Transaction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">modes</span><span class="o">=</span><span class="n">modes</span><span class="p">)</span> -</span><span id="L-4230"><a href="#L-4230"><span class="linenos">4230</span></a> -</span><span id="L-4231"><a href="#L-4231"><span class="linenos">4231</span></a> <span class="k">def</span> <span class="nf">_parse_commit_or_rollback</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">Commit</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Rollback</span><span class="p">:</span> -</span><span id="L-4232"><a href="#L-4232"><span class="linenos">4232</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-4233"><a href="#L-4233"><span class="linenos">4233</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-4234"><a href="#L-4234"><span class="linenos">4234</span></a> <span class="n">is_rollback</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">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROLLBACK</span> -</span><span id="L-4235"><a href="#L-4235"><span class="linenos">4235</span></a> -</span><span id="L-4236"><a href="#L-4236"><span class="linenos">4236</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">({</span><span class="s2">"TRANSACTION"</span><span class="p">,</span> <span class="s2">"WORK"</span><span class="p">})</span> -</span><span id="L-4237"><a href="#L-4237"><span class="linenos">4237</span></a> -</span><span id="L-4238"><a href="#L-4238"><span class="linenos">4238</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">):</span> -</span><span id="L-4239"><a href="#L-4239"><span class="linenos">4239</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SAVEPOINT"</span><span class="p">)</span> -</span><span id="L-4240"><a href="#L-4240"><span class="linenos">4240</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="L-4241"><a href="#L-4241"><span class="linenos">4241</span></a> -</span><span id="L-4242"><a href="#L-4242"><span class="linenos">4242</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">AND</span><span class="p">):</span> -</span><span id="L-4243"><a href="#L-4243"><span class="linenos">4243</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">)</span> -</span><span id="L-4244"><a href="#L-4244"><span class="linenos">4244</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CHAIN"</span><span class="p">)</span> +</span><span id="L-4224"><a href="#L-4224"><span class="linenos">4224</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">({</span><span class="s2">"TRANSACTION"</span><span class="p">,</span> <span class="s2">"WORK"</span><span class="p">})</span> +</span><span id="L-4225"><a href="#L-4225"><span class="linenos">4225</span></a> +</span><span id="L-4226"><a href="#L-4226"><span class="linenos">4226</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-4227"><a href="#L-4227"><span class="linenos">4227</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-4228"><a href="#L-4228"><span class="linenos">4228</span></a> <span class="n">mode</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-4229"><a href="#L-4229"><span class="linenos">4229</span></a> <span class="k">while</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">VAR</span><span class="p">):</span> +</span><span id="L-4230"><a href="#L-4230"><span class="linenos">4230</span></a> <span class="n">mode</span><span class="o">.</span><span class="n">append</span><span class="p">(</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-4231"><a href="#L-4231"><span class="linenos">4231</span></a> +</span><span id="L-4232"><a href="#L-4232"><span class="linenos">4232</span></a> <span class="k">if</span> <span class="n">mode</span><span class="p">:</span> +</span><span id="L-4233"><a href="#L-4233"><span class="linenos">4233</span></a> <span class="n">modes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">mode</span><span class="p">))</span> +</span><span id="L-4234"><a href="#L-4234"><span class="linenos">4234</span></a> <span class="k">if</span> <span class="ow">not</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">COMMA</span><span class="p">):</span> +</span><span id="L-4235"><a href="#L-4235"><span class="linenos">4235</span></a> <span class="k">break</span> +</span><span id="L-4236"><a href="#L-4236"><span class="linenos">4236</span></a> +</span><span id="L-4237"><a href="#L-4237"><span class="linenos">4237</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">Transaction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">modes</span><span class="o">=</span><span class="n">modes</span><span class="p">)</span> +</span><span id="L-4238"><a href="#L-4238"><span class="linenos">4238</span></a> +</span><span id="L-4239"><a href="#L-4239"><span class="linenos">4239</span></a> <span class="k">def</span> <span class="nf">_parse_commit_or_rollback</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">Commit</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Rollback</span><span class="p">:</span> +</span><span id="L-4240"><a href="#L-4240"><span class="linenos">4240</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-4241"><a href="#L-4241"><span class="linenos">4241</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-4242"><a href="#L-4242"><span class="linenos">4242</span></a> <span class="n">is_rollback</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">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROLLBACK</span> +</span><span id="L-4243"><a href="#L-4243"><span class="linenos">4243</span></a> +</span><span id="L-4244"><a href="#L-4244"><span class="linenos">4244</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">({</span><span class="s2">"TRANSACTION"</span><span class="p">,</span> <span class="s2">"WORK"</span><span class="p">})</span> </span><span id="L-4245"><a href="#L-4245"><span class="linenos">4245</span></a> -</span><span id="L-4246"><a href="#L-4246"><span class="linenos">4246</span></a> <span class="k">if</span> <span class="n">is_rollback</span><span class="p">:</span> -</span><span id="L-4247"><a href="#L-4247"><span class="linenos">4247</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">Rollback</span><span class="p">,</span> <span class="n">savepoint</span><span class="o">=</span><span class="n">savepoint</span><span class="p">)</span> -</span><span id="L-4248"><a href="#L-4248"><span class="linenos">4248</span></a> -</span><span id="L-4249"><a href="#L-4249"><span class="linenos">4249</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">Commit</span><span class="p">,</span> <span class="n">chain</span><span class="o">=</span><span class="n">chain</span><span class="p">)</span> -</span><span id="L-4250"><a href="#L-4250"><span class="linenos">4250</span></a> -</span><span id="L-4251"><a href="#L-4251"><span class="linenos">4251</span></a> <span class="k">def</span> <span class="nf">_parse_add_column</span><span class="p">(</span><span class="bp">self</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-4252"><a href="#L-4252"><span class="linenos">4252</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ADD"</span><span class="p">):</span> -</span><span id="L-4253"><a href="#L-4253"><span class="linenos">4253</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-4254"><a href="#L-4254"><span class="linenos">4254</span></a> -</span><span id="L-4255"><a href="#L-4255"><span class="linenos">4255</span></a> <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">COLUMN</span><span class="p">)</span> -</span><span id="L-4256"><a href="#L-4256"><span class="linenos">4256</span></a> <span class="n">exists_column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">(</span><span class="n">not_</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-4257"><a href="#L-4257"><span class="linenos">4257</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_def</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="L-4246"><a href="#L-4246"><span class="linenos">4246</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">):</span> +</span><span id="L-4247"><a href="#L-4247"><span class="linenos">4247</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SAVEPOINT"</span><span class="p">)</span> +</span><span id="L-4248"><a href="#L-4248"><span class="linenos">4248</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="L-4249"><a href="#L-4249"><span class="linenos">4249</span></a> +</span><span id="L-4250"><a href="#L-4250"><span class="linenos">4250</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">AND</span><span class="p">):</span> +</span><span id="L-4251"><a href="#L-4251"><span class="linenos">4251</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">)</span> +</span><span id="L-4252"><a href="#L-4252"><span class="linenos">4252</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CHAIN"</span><span class="p">)</span> +</span><span id="L-4253"><a href="#L-4253"><span class="linenos">4253</span></a> +</span><span id="L-4254"><a href="#L-4254"><span class="linenos">4254</span></a> <span class="k">if</span> <span class="n">is_rollback</span><span class="p">:</span> +</span><span id="L-4255"><a href="#L-4255"><span class="linenos">4255</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">Rollback</span><span class="p">,</span> <span class="n">savepoint</span><span class="o">=</span><span class="n">savepoint</span><span class="p">)</span> +</span><span id="L-4256"><a href="#L-4256"><span class="linenos">4256</span></a> +</span><span id="L-4257"><a href="#L-4257"><span class="linenos">4257</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">Commit</span><span class="p">,</span> <span class="n">chain</span><span class="o">=</span><span class="n">chain</span><span class="p">)</span> </span><span id="L-4258"><a href="#L-4258"><span class="linenos">4258</span></a> -</span><span id="L-4259"><a href="#L-4259"><span class="linenos">4259</span></a> <span class="k">if</span> <span class="n">expression</span><span class="p">:</span> -</span><span id="L-4260"><a href="#L-4260"><span class="linenos">4260</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">,</span> <span class="n">exists_column</span><span class="p">)</span> -</span><span id="L-4261"><a href="#L-4261"><span class="linenos">4261</span></a> -</span><span id="L-4262"><a href="#L-4262"><span class="linenos">4262</span></a> <span class="c1"># https://docs.databricks.com/delta/update-schema.html#explicitly-update-schema-to-add-columns</span> -</span><span id="L-4263"><a href="#L-4263"><span class="linenos">4263</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"FIRST"</span><span class="p">,</span> <span class="s2">"AFTER"</span><span class="p">)):</span> -</span><span id="L-4264"><a href="#L-4264"><span class="linenos">4264</span></a> <span class="n">position</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><span id="L-4265"><a href="#L-4265"><span class="linenos">4265</span></a> <span class="n">column_position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-4266"><a href="#L-4266"><span class="linenos">4266</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnPosition</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_column</span><span class="p">(),</span> <span class="n">position</span><span class="o">=</span><span class="n">position</span> -</span><span id="L-4267"><a href="#L-4267"><span class="linenos">4267</span></a> <span class="p">)</span> -</span><span id="L-4268"><a href="#L-4268"><span class="linenos">4268</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"position"</span><span class="p">,</span> <span class="n">column_position</span><span class="p">)</span> +</span><span id="L-4259"><a href="#L-4259"><span class="linenos">4259</span></a> <span class="k">def</span> <span class="nf">_parse_add_column</span><span class="p">(</span><span class="bp">self</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-4260"><a href="#L-4260"><span class="linenos">4260</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ADD"</span><span class="p">):</span> +</span><span id="L-4261"><a href="#L-4261"><span class="linenos">4261</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-4262"><a href="#L-4262"><span class="linenos">4262</span></a> +</span><span id="L-4263"><a href="#L-4263"><span class="linenos">4263</span></a> <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">COLUMN</span><span class="p">)</span> +</span><span id="L-4264"><a href="#L-4264"><span class="linenos">4264</span></a> <span class="n">exists_column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">(</span><span class="n">not_</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-4265"><a href="#L-4265"><span class="linenos">4265</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_def</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="L-4266"><a href="#L-4266"><span class="linenos">4266</span></a> +</span><span id="L-4267"><a href="#L-4267"><span class="linenos">4267</span></a> <span class="k">if</span> <span class="n">expression</span><span class="p">:</span> +</span><span id="L-4268"><a href="#L-4268"><span class="linenos">4268</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">,</span> <span class="n">exists_column</span><span class="p">)</span> </span><span id="L-4269"><a href="#L-4269"><span class="linenos">4269</span></a> -</span><span id="L-4270"><a href="#L-4270"><span class="linenos">4270</span></a> <span class="k">return</span> <span class="n">expression</span> -</span><span id="L-4271"><a href="#L-4271"><span class="linenos">4271</span></a> -</span><span id="L-4272"><a href="#L-4272"><span class="linenos">4272</span></a> <span class="k">def</span> <span class="nf">_parse_drop_column</span><span class="p">(</span><span class="bp">self</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">Drop</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">]:</span> -</span><span id="L-4273"><a href="#L-4273"><span class="linenos">4273</span></a> <span class="n">drop</span> <span class="o">=</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">DROP</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_drop</span><span class="p">()</span> -</span><span id="L-4274"><a href="#L-4274"><span class="linenos">4274</span></a> <span class="k">if</span> <span class="n">drop</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">drop</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">):</span> -</span><span id="L-4275"><a href="#L-4275"><span class="linenos">4275</span></a> <span class="n">drop</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="n">drop</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"COLUMN"</span><span class="p">))</span> -</span><span id="L-4276"><a href="#L-4276"><span class="linenos">4276</span></a> <span class="k">return</span> <span class="n">drop</span> +</span><span id="L-4270"><a href="#L-4270"><span class="linenos">4270</span></a> <span class="c1"># https://docs.databricks.com/delta/update-schema.html#explicitly-update-schema-to-add-columns</span> +</span><span id="L-4271"><a href="#L-4271"><span class="linenos">4271</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"FIRST"</span><span class="p">,</span> <span class="s2">"AFTER"</span><span class="p">)):</span> +</span><span id="L-4272"><a href="#L-4272"><span class="linenos">4272</span></a> <span class="n">position</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><span id="L-4273"><a href="#L-4273"><span class="linenos">4273</span></a> <span class="n">column_position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-4274"><a href="#L-4274"><span class="linenos">4274</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnPosition</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_column</span><span class="p">(),</span> <span class="n">position</span><span class="o">=</span><span class="n">position</span> +</span><span id="L-4275"><a href="#L-4275"><span class="linenos">4275</span></a> <span class="p">)</span> +</span><span id="L-4276"><a href="#L-4276"><span class="linenos">4276</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"position"</span><span class="p">,</span> <span class="n">column_position</span><span class="p">)</span> </span><span id="L-4277"><a href="#L-4277"><span class="linenos">4277</span></a> -</span><span id="L-4278"><a href="#L-4278"><span class="linenos">4278</span></a> <span class="c1"># https://docs.aws.amazon.com/athena/latest/ug/alter-table-drop-partition.html</span> -</span><span id="L-4279"><a href="#L-4279"><span class="linenos">4279</span></a> <span class="k">def</span> <span class="nf">_parse_drop_partition</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exists</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DropPartition</span><span class="p">:</span> -</span><span id="L-4280"><a href="#L-4280"><span class="linenos">4280</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><span id="L-4281"><a href="#L-4281"><span class="linenos">4281</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DropPartition</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition</span><span class="p">),</span> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span> -</span><span id="L-4282"><a href="#L-4282"><span class="linenos">4282</span></a> <span class="p">)</span> -</span><span id="L-4283"><a href="#L-4283"><span class="linenos">4283</span></a> -</span><span id="L-4284"><a href="#L-4284"><span class="linenos">4284</span></a> <span class="k">def</span> <span class="nf">_parse_add_constraint</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">AddConstraint</span><span class="p">:</span> -</span><span id="L-4285"><a href="#L-4285"><span class="linenos">4285</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-4286"><a href="#L-4286"><span class="linenos">4286</span></a> <span class="n">kind</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">token_type</span> -</span><span id="L-4287"><a href="#L-4287"><span class="linenos">4287</span></a> -</span><span id="L-4288"><a href="#L-4288"><span class="linenos">4288</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CONSTRAINT</span><span class="p">:</span> -</span><span id="L-4289"><a href="#L-4289"><span class="linenos">4289</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="L-4290"><a href="#L-4290"><span class="linenos">4290</span></a> -</span><span id="L-4291"><a href="#L-4291"><span class="linenos">4291</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CHECK"</span><span class="p">):</span> -</span><span id="L-4292"><a href="#L-4292"><span class="linenos">4292</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="L-4293"><a href="#L-4293"><span class="linenos">4293</span></a> <span class="n">enforced</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ENFORCED"</span><span class="p">)</span> -</span><span id="L-4294"><a href="#L-4294"><span class="linenos">4294</span></a> -</span><span id="L-4295"><a href="#L-4295"><span class="linenos">4295</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><span id="L-4296"><a href="#L-4296"><span class="linenos">4296</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AddConstraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">enforced</span><span class="o">=</span><span class="n">enforced</span> -</span><span id="L-4297"><a href="#L-4297"><span class="linenos">4297</span></a> <span class="p">)</span> +</span><span id="L-4278"><a href="#L-4278"><span class="linenos">4278</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="L-4279"><a href="#L-4279"><span class="linenos">4279</span></a> +</span><span id="L-4280"><a href="#L-4280"><span class="linenos">4280</span></a> <span class="k">def</span> <span class="nf">_parse_drop_column</span><span class="p">(</span><span class="bp">self</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">Drop</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">]:</span> +</span><span id="L-4281"><a href="#L-4281"><span class="linenos">4281</span></a> <span class="n">drop</span> <span class="o">=</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">DROP</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_drop</span><span class="p">()</span> +</span><span id="L-4282"><a href="#L-4282"><span class="linenos">4282</span></a> <span class="k">if</span> <span class="n">drop</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">drop</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">):</span> +</span><span id="L-4283"><a href="#L-4283"><span class="linenos">4283</span></a> <span class="n">drop</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="n">drop</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"COLUMN"</span><span class="p">))</span> +</span><span id="L-4284"><a href="#L-4284"><span class="linenos">4284</span></a> <span class="k">return</span> <span class="n">drop</span> +</span><span id="L-4285"><a href="#L-4285"><span class="linenos">4285</span></a> +</span><span id="L-4286"><a href="#L-4286"><span class="linenos">4286</span></a> <span class="c1"># https://docs.aws.amazon.com/athena/latest/ug/alter-table-drop-partition.html</span> +</span><span id="L-4287"><a href="#L-4287"><span class="linenos">4287</span></a> <span class="k">def</span> <span class="nf">_parse_drop_partition</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exists</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DropPartition</span><span class="p">:</span> +</span><span id="L-4288"><a href="#L-4288"><span class="linenos">4288</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><span id="L-4289"><a href="#L-4289"><span class="linenos">4289</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DropPartition</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition</span><span class="p">),</span> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span> +</span><span id="L-4290"><a href="#L-4290"><span class="linenos">4290</span></a> <span class="p">)</span> +</span><span id="L-4291"><a href="#L-4291"><span class="linenos">4291</span></a> +</span><span id="L-4292"><a href="#L-4292"><span class="linenos">4292</span></a> <span class="k">def</span> <span class="nf">_parse_add_constraint</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">AddConstraint</span><span class="p">:</span> +</span><span id="L-4293"><a href="#L-4293"><span class="linenos">4293</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-4294"><a href="#L-4294"><span class="linenos">4294</span></a> <span class="n">kind</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">token_type</span> +</span><span id="L-4295"><a href="#L-4295"><span class="linenos">4295</span></a> +</span><span id="L-4296"><a href="#L-4296"><span class="linenos">4296</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CONSTRAINT</span><span class="p">:</span> +</span><span id="L-4297"><a href="#L-4297"><span class="linenos">4297</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> </span><span id="L-4298"><a href="#L-4298"><span class="linenos">4298</span></a> -</span><span id="L-4299"><a href="#L-4299"><span class="linenos">4299</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FOREIGN_KEY</span> <span class="ow">or</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">FOREIGN_KEY</span><span class="p">):</span> -</span><span id="L-4300"><a href="#L-4300"><span class="linenos">4300</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_foreign_key</span><span class="p">()</span> -</span><span id="L-4301"><a href="#L-4301"><span class="linenos">4301</span></a> <span class="k">elif</span> <span class="n">kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PRIMARY_KEY</span> <span class="ow">or</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">PRIMARY_KEY</span><span class="p">):</span> -</span><span id="L-4302"><a href="#L-4302"><span class="linenos">4302</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary_key</span><span class="p">()</span> -</span><span id="L-4303"><a href="#L-4303"><span class="linenos">4303</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-4304"><a href="#L-4304"><span class="linenos">4304</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-4305"><a href="#L-4305"><span class="linenos">4305</span></a> -</span><span id="L-4306"><a href="#L-4306"><span class="linenos">4306</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">AddConstraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-4307"><a href="#L-4307"><span class="linenos">4307</span></a> -</span><span id="L-4308"><a href="#L-4308"><span class="linenos">4308</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_add</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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-4309"><a href="#L-4309"><span class="linenos">4309</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span> -</span><span id="L-4310"><a href="#L-4310"><span class="linenos">4310</span></a> -</span><span id="L-4311"><a href="#L-4311"><span class="linenos">4311</span></a> <span class="k">if</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">ADD_CONSTRAINT_TOKENS</span><span class="p">):</span> -</span><span id="L-4312"><a href="#L-4312"><span class="linenos">4312</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_add_constraint</span><span class="p">)</span> +</span><span id="L-4299"><a href="#L-4299"><span class="linenos">4299</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CHECK"</span><span class="p">):</span> +</span><span id="L-4300"><a href="#L-4300"><span class="linenos">4300</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="L-4301"><a href="#L-4301"><span class="linenos">4301</span></a> <span class="n">enforced</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ENFORCED"</span><span class="p">)</span> +</span><span id="L-4302"><a href="#L-4302"><span class="linenos">4302</span></a> +</span><span id="L-4303"><a href="#L-4303"><span class="linenos">4303</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><span id="L-4304"><a href="#L-4304"><span class="linenos">4304</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AddConstraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">enforced</span><span class="o">=</span><span class="n">enforced</span> +</span><span id="L-4305"><a href="#L-4305"><span class="linenos">4305</span></a> <span class="p">)</span> +</span><span id="L-4306"><a href="#L-4306"><span class="linenos">4306</span></a> +</span><span id="L-4307"><a href="#L-4307"><span class="linenos">4307</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FOREIGN_KEY</span> <span class="ow">or</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">FOREIGN_KEY</span><span class="p">):</span> +</span><span id="L-4308"><a href="#L-4308"><span class="linenos">4308</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_foreign_key</span><span class="p">()</span> +</span><span id="L-4309"><a href="#L-4309"><span class="linenos">4309</span></a> <span class="k">elif</span> <span class="n">kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PRIMARY_KEY</span> <span class="ow">or</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">PRIMARY_KEY</span><span class="p">):</span> +</span><span id="L-4310"><a href="#L-4310"><span class="linenos">4310</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary_key</span><span class="p">()</span> +</span><span id="L-4311"><a href="#L-4311"><span class="linenos">4311</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-4312"><a href="#L-4312"><span class="linenos">4312</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="kc">None</span> </span><span id="L-4313"><a href="#L-4313"><span class="linenos">4313</span></a> -</span><span id="L-4314"><a href="#L-4314"><span class="linenos">4314</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-4315"><a href="#L-4315"><span class="linenos">4315</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_add_column</span><span class="p">)</span> -</span><span id="L-4316"><a href="#L-4316"><span class="linenos">4316</span></a> -</span><span id="L-4317"><a href="#L-4317"><span class="linenos">4317</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_alter</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">AlterColumn</span><span class="p">:</span> -</span><span id="L-4318"><a href="#L-4318"><span class="linenos">4318</span></a> <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">COLUMN</span><span class="p">)</span> -</span><span id="L-4319"><a href="#L-4319"><span class="linenos">4319</span></a> <span class="n">column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-4320"><a href="#L-4320"><span class="linenos">4320</span></a> -</span><span id="L-4321"><a href="#L-4321"><span class="linenos">4321</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DROP</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">):</span> -</span><span id="L-4322"><a href="#L-4322"><span class="linenos">4322</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">AlterColumn</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">column</span><span class="p">,</span> <span class="n">drop</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-4323"><a href="#L-4323"><span class="linenos">4323</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">):</span> -</span><span id="L-4324"><a href="#L-4324"><span class="linenos">4324</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">AlterColumn</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">column</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">())</span> -</span><span id="L-4325"><a href="#L-4325"><span class="linenos">4325</span></a> -</span><span id="L-4326"><a href="#L-4326"><span class="linenos">4326</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SET"</span><span class="p">,</span> <span class="s2">"DATA"</span><span class="p">)</span> -</span><span id="L-4327"><a href="#L-4327"><span class="linenos">4327</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><span id="L-4328"><a href="#L-4328"><span class="linenos">4328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AlterColumn</span><span class="p">,</span> -</span><span id="L-4329"><a href="#L-4329"><span class="linenos">4329</span></a> <span class="n">this</span><span class="o">=</span><span class="n">column</span><span class="p">,</span> -</span><span id="L-4330"><a href="#L-4330"><span class="linenos">4330</span></a> <span class="n">dtype</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TYPE"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(),</span> -</span><span id="L-4331"><a href="#L-4331"><span class="linenos">4331</span></a> <span class="n">collate</span><span class="o">=</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">COLLATE</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">(),</span> -</span><span id="L-4332"><a href="#L-4332"><span class="linenos">4332</span></a> <span class="n">using</span><span class="o">=</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">USING</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">(),</span> -</span><span id="L-4333"><a href="#L-4333"><span class="linenos">4333</span></a> <span class="p">)</span> -</span><span id="L-4334"><a href="#L-4334"><span class="linenos">4334</span></a> -</span><span id="L-4335"><a href="#L-4335"><span class="linenos">4335</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_drop</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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-4336"><a href="#L-4336"><span class="linenos">4336</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span> -</span><span id="L-4337"><a href="#L-4337"><span class="linenos">4337</span></a> -</span><span id="L-4338"><a href="#L-4338"><span class="linenos">4338</span></a> <span class="n">partition_exists</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">()</span> -</span><span id="L-4339"><a href="#L-4339"><span class="linenos">4339</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">PARTITION</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-4340"><a href="#L-4340"><span class="linenos">4340</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_drop_partition</span><span class="p">(</span><span class="n">exists</span><span class="o">=</span><span class="n">partition_exists</span><span class="p">))</span> -</span><span id="L-4341"><a href="#L-4341"><span class="linenos">4341</span></a> -</span><span id="L-4342"><a href="#L-4342"><span class="linenos">4342</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-4343"><a href="#L-4343"><span class="linenos">4343</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_drop_column</span><span class="p">)</span> -</span><span id="L-4344"><a href="#L-4344"><span class="linenos">4344</span></a> -</span><span id="L-4345"><a href="#L-4345"><span class="linenos">4345</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_rename</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">RenameTable</span><span class="p">:</span> -</span><span id="L-4346"><a href="#L-4346"><span class="linenos">4346</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">)</span> -</span><span id="L-4347"><a href="#L-4347"><span class="linenos">4347</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">RenameTable</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_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> -</span><span id="L-4348"><a href="#L-4348"><span class="linenos">4348</span></a> -</span><span id="L-4349"><a href="#L-4349"><span class="linenos">4349</span></a> <span class="k">def</span> <span class="nf">_parse_alter</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">AlterTable</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> -</span><span id="L-4350"><a href="#L-4350"><span class="linenos">4350</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> -</span><span id="L-4351"><a href="#L-4351"><span class="linenos">4351</span></a> -</span><span id="L-4352"><a href="#L-4352"><span class="linenos">4352</span></a> <span class="k">if</span> <span class="ow">not</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">TABLE</span><span class="p">):</span> -</span><span id="L-4353"><a href="#L-4353"><span class="linenos">4353</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> -</span><span id="L-4354"><a href="#L-4354"><span class="linenos">4354</span></a> -</span><span id="L-4355"><a href="#L-4355"><span class="linenos">4355</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">()</span> -</span><span id="L-4356"><a href="#L-4356"><span class="linenos">4356</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-4357"><a href="#L-4357"><span class="linenos">4357</span></a> -</span><span id="L-4358"><a href="#L-4358"><span class="linenos">4358</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> -</span><span id="L-4359"><a href="#L-4359"><span class="linenos">4359</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-4360"><a href="#L-4360"><span class="linenos">4360</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALTER_PARSERS</span><span class="o">.</span><span class="n">get</span><span class="p">(</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="o">.</span><span class="n">upper</span><span class="p">())</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="L-4361"><a href="#L-4361"><span class="linenos">4361</span></a> -</span><span id="L-4362"><a href="#L-4362"><span class="linenos">4362</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> -</span><span id="L-4363"><a href="#L-4363"><span class="linenos">4363</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span> -</span><span id="L-4364"><a href="#L-4364"><span class="linenos">4364</span></a> -</span><span id="L-4365"><a href="#L-4365"><span class="linenos">4365</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="L-4366"><a href="#L-4366"><span class="linenos">4366</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><span id="L-4367"><a href="#L-4367"><span class="linenos">4367</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AlterTable</span><span class="p">,</span> -</span><span id="L-4368"><a href="#L-4368"><span class="linenos">4368</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-4369"><a href="#L-4369"><span class="linenos">4369</span></a> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span><span class="p">,</span> -</span><span id="L-4370"><a href="#L-4370"><span class="linenos">4370</span></a> <span class="n">actions</span><span class="o">=</span><span class="n">actions</span><span class="p">,</span> -</span><span id="L-4371"><a href="#L-4371"><span class="linenos">4371</span></a> <span class="p">)</span> -</span><span id="L-4372"><a href="#L-4372"><span class="linenos">4372</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> -</span><span id="L-4373"><a href="#L-4373"><span class="linenos">4373</span></a> -</span><span id="L-4374"><a href="#L-4374"><span class="linenos">4374</span></a> <span class="k">def</span> <span class="nf">_parse_merge</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">Merge</span><span class="p">:</span> -</span><span id="L-4375"><a href="#L-4375"><span class="linenos">4375</span></a> <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">INTO</span><span class="p">)</span> -</span><span id="L-4376"><a href="#L-4376"><span class="linenos">4376</span></a> <span class="n">target</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> -</span><span id="L-4377"><a href="#L-4377"><span class="linenos">4377</span></a> -</span><span id="L-4378"><a href="#L-4378"><span class="linenos">4378</span></a> <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">USING</span><span class="p">)</span> -</span><span id="L-4379"><a href="#L-4379"><span class="linenos">4379</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> -</span><span id="L-4380"><a href="#L-4380"><span class="linenos">4380</span></a> -</span><span id="L-4381"><a href="#L-4381"><span class="linenos">4381</span></a> <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">ON</span><span class="p">)</span> -</span><span id="L-4382"><a href="#L-4382"><span class="linenos">4382</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="L-4383"><a href="#L-4383"><span class="linenos">4383</span></a> -</span><span id="L-4384"><a href="#L-4384"><span class="linenos">4384</span></a> <span class="n">whens</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-4385"><a href="#L-4385"><span class="linenos">4385</span></a> <span class="k">while</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">WHEN</span><span class="p">):</span> -</span><span id="L-4386"><a href="#L-4386"><span class="linenos">4386</span></a> <span class="n">matched</span> <span class="o">=</span> <span class="ow">not</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">NOT</span><span class="p">)</span> -</span><span id="L-4387"><a href="#L-4387"><span class="linenos">4387</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MATCHED"</span><span class="p">)</span> -</span><span id="L-4388"><a href="#L-4388"><span class="linenos">4388</span></a> <span class="n">source</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-4389"><a href="#L-4389"><span class="linenos">4389</span></a> <span class="kc">False</span> -</span><span id="L-4390"><a href="#L-4390"><span class="linenos">4390</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BY"</span><span class="p">,</span> <span class="s2">"TARGET"</span><span class="p">)</span> -</span><span id="L-4391"><a href="#L-4391"><span class="linenos">4391</span></a> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BY"</span><span class="p">,</span> <span class="s2">"SOURCE"</span><span class="p">)</span> -</span><span id="L-4392"><a href="#L-4392"><span class="linenos">4392</span></a> <span class="p">)</span> -</span><span id="L-4393"><a href="#L-4393"><span class="linenos">4393</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> <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">AND</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="L-4394"><a href="#L-4394"><span class="linenos">4394</span></a> -</span><span id="L-4395"><a href="#L-4395"><span class="linenos">4395</span></a> <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">THEN</span><span class="p">)</span> -</span><span id="L-4396"><a href="#L-4396"><span class="linenos">4396</span></a> -</span><span id="L-4397"><a href="#L-4397"><span class="linenos">4397</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">INSERT</span><span class="p">):</span> -</span><span id="L-4398"><a href="#L-4398"><span class="linenos">4398</span></a> <span class="n">_this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_star</span><span class="p">()</span> -</span><span id="L-4399"><a href="#L-4399"><span class="linenos">4399</span></a> <span class="k">if</span> <span class="n">_this</span><span class="p">:</span> -</span><span id="L-4400"><a href="#L-4400"><span class="linenos">4400</span></a> <span class="n">then</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="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">Insert</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">_this</span><span class="p">)</span> -</span><span id="L-4401"><a href="#L-4401"><span class="linenos">4401</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-4402"><a href="#L-4402"><span class="linenos">4402</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-4403"><a href="#L-4403"><span class="linenos">4403</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">,</span> -</span><span id="L-4404"><a href="#L-4404"><span class="linenos">4404</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">(),</span> -</span><span id="L-4405"><a href="#L-4405"><span class="linenos">4405</span></a> <span class="n">expression</span><span class="o">=</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">VALUES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">(),</span> -</span><span id="L-4406"><a href="#L-4406"><span class="linenos">4406</span></a> <span class="p">)</span> -</span><span id="L-4407"><a href="#L-4407"><span class="linenos">4407</span></a> <span class="k">elif</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">UPDATE</span><span class="p">):</span> -</span><span id="L-4408"><a href="#L-4408"><span class="linenos">4408</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_star</span><span class="p">()</span> -</span><span id="L-4409"><a href="#L-4409"><span class="linenos">4409</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="L-4410"><a href="#L-4410"><span class="linenos">4410</span></a> <span class="n">then</span> <span class="o">=</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">Update</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-4411"><a href="#L-4411"><span class="linenos">4411</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-4412"><a href="#L-4412"><span class="linenos">4412</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-4413"><a href="#L-4413"><span class="linenos">4413</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> -</span><span id="L-4414"><a href="#L-4414"><span class="linenos">4414</span></a> <span class="n">expressions</span><span class="o">=</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">SET</span><span class="p">)</span> -</span><span id="L-4415"><a href="#L-4415"><span class="linenos">4415</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">),</span> -</span><span id="L-4416"><a href="#L-4416"><span class="linenos">4416</span></a> <span class="p">)</span> -</span><span id="L-4417"><a href="#L-4417"><span class="linenos">4417</span></a> <span class="k">elif</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">DELETE</span><span class="p">):</span> -</span><span id="L-4418"><a href="#L-4418"><span class="linenos">4418</span></a> <span class="n">then</span> <span class="o">=</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">Var</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-4419"><a href="#L-4419"><span class="linenos">4419</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-4420"><a href="#L-4420"><span class="linenos">4420</span></a> <span class="n">then</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-4421"><a href="#L-4421"><span class="linenos">4421</span></a> -</span><span id="L-4422"><a href="#L-4422"><span class="linenos">4422</span></a> <span class="n">whens</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="L-4423"><a href="#L-4423"><span class="linenos">4423</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="L-4424"><a href="#L-4424"><span class="linenos">4424</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">When</span><span class="p">,</span> -</span><span id="L-4425"><a href="#L-4425"><span class="linenos">4425</span></a> <span class="n">matched</span><span class="o">=</span><span class="n">matched</span><span class="p">,</span> -</span><span id="L-4426"><a href="#L-4426"><span class="linenos">4426</span></a> <span class="n">source</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> -</span><span id="L-4427"><a href="#L-4427"><span class="linenos">4427</span></a> <span class="n">condition</span><span class="o">=</span><span class="n">condition</span><span class="p">,</span> -</span><span id="L-4428"><a href="#L-4428"><span class="linenos">4428</span></a> <span class="n">then</span><span class="o">=</span><span class="n">then</span><span class="p">,</span> -</span><span id="L-4429"><a href="#L-4429"><span class="linenos">4429</span></a> <span class="p">)</span> -</span><span id="L-4430"><a href="#L-4430"><span class="linenos">4430</span></a> <span class="p">)</span> -</span><span id="L-4431"><a href="#L-4431"><span class="linenos">4431</span></a> -</span><span id="L-4432"><a href="#L-4432"><span class="linenos">4432</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><span id="L-4433"><a href="#L-4433"><span class="linenos">4433</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Merge</span><span class="p">,</span> -</span><span id="L-4434"><a href="#L-4434"><span class="linenos">4434</span></a> <span class="n">this</span><span class="o">=</span><span class="n">target</span><span class="p">,</span> -</span><span id="L-4435"><a href="#L-4435"><span class="linenos">4435</span></a> <span class="n">using</span><span class="o">=</span><span class="n">using</span><span class="p">,</span> -</span><span id="L-4436"><a href="#L-4436"><span class="linenos">4436</span></a> <span class="n">on</span><span class="o">=</span><span class="n">on</span><span class="p">,</span> -</span><span id="L-4437"><a href="#L-4437"><span class="linenos">4437</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">whens</span><span class="p">,</span> -</span><span id="L-4438"><a href="#L-4438"><span class="linenos">4438</span></a> <span class="p">)</span> +</span><span id="L-4314"><a href="#L-4314"><span class="linenos">4314</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">AddConstraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-4315"><a href="#L-4315"><span class="linenos">4315</span></a> +</span><span id="L-4316"><a href="#L-4316"><span class="linenos">4316</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_add</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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-4317"><a href="#L-4317"><span class="linenos">4317</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span> +</span><span id="L-4318"><a href="#L-4318"><span class="linenos">4318</span></a> +</span><span id="L-4319"><a href="#L-4319"><span class="linenos">4319</span></a> <span class="k">if</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">ADD_CONSTRAINT_TOKENS</span><span class="p">):</span> +</span><span id="L-4320"><a href="#L-4320"><span class="linenos">4320</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_add_constraint</span><span class="p">)</span> +</span><span id="L-4321"><a href="#L-4321"><span class="linenos">4321</span></a> +</span><span id="L-4322"><a href="#L-4322"><span class="linenos">4322</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-4323"><a href="#L-4323"><span class="linenos">4323</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_add_column</span><span class="p">)</span> +</span><span id="L-4324"><a href="#L-4324"><span class="linenos">4324</span></a> +</span><span id="L-4325"><a href="#L-4325"><span class="linenos">4325</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_alter</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">AlterColumn</span><span class="p">:</span> +</span><span id="L-4326"><a href="#L-4326"><span class="linenos">4326</span></a> <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">COLUMN</span><span class="p">)</span> +</span><span id="L-4327"><a href="#L-4327"><span class="linenos">4327</span></a> <span class="n">column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-4328"><a href="#L-4328"><span class="linenos">4328</span></a> +</span><span id="L-4329"><a href="#L-4329"><span class="linenos">4329</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DROP</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">):</span> +</span><span id="L-4330"><a href="#L-4330"><span class="linenos">4330</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">AlterColumn</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">column</span><span class="p">,</span> <span class="n">drop</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-4331"><a href="#L-4331"><span class="linenos">4331</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">):</span> +</span><span id="L-4332"><a href="#L-4332"><span class="linenos">4332</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">AlterColumn</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">column</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">())</span> +</span><span id="L-4333"><a href="#L-4333"><span class="linenos">4333</span></a> +</span><span id="L-4334"><a href="#L-4334"><span class="linenos">4334</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SET"</span><span class="p">,</span> <span class="s2">"DATA"</span><span class="p">)</span> +</span><span id="L-4335"><a href="#L-4335"><span class="linenos">4335</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><span id="L-4336"><a href="#L-4336"><span class="linenos">4336</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AlterColumn</span><span class="p">,</span> +</span><span id="L-4337"><a href="#L-4337"><span class="linenos">4337</span></a> <span class="n">this</span><span class="o">=</span><span class="n">column</span><span class="p">,</span> +</span><span id="L-4338"><a href="#L-4338"><span class="linenos">4338</span></a> <span class="n">dtype</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TYPE"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(),</span> +</span><span id="L-4339"><a href="#L-4339"><span class="linenos">4339</span></a> <span class="n">collate</span><span class="o">=</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">COLLATE</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">(),</span> +</span><span id="L-4340"><a href="#L-4340"><span class="linenos">4340</span></a> <span class="n">using</span><span class="o">=</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">USING</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">(),</span> +</span><span id="L-4341"><a href="#L-4341"><span class="linenos">4341</span></a> <span class="p">)</span> +</span><span id="L-4342"><a href="#L-4342"><span class="linenos">4342</span></a> +</span><span id="L-4343"><a href="#L-4343"><span class="linenos">4343</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_drop</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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-4344"><a href="#L-4344"><span class="linenos">4344</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span> +</span><span id="L-4345"><a href="#L-4345"><span class="linenos">4345</span></a> +</span><span id="L-4346"><a href="#L-4346"><span class="linenos">4346</span></a> <span class="n">partition_exists</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">()</span> +</span><span id="L-4347"><a href="#L-4347"><span class="linenos">4347</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">PARTITION</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-4348"><a href="#L-4348"><span class="linenos">4348</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_drop_partition</span><span class="p">(</span><span class="n">exists</span><span class="o">=</span><span class="n">partition_exists</span><span class="p">))</span> +</span><span id="L-4349"><a href="#L-4349"><span class="linenos">4349</span></a> +</span><span id="L-4350"><a href="#L-4350"><span class="linenos">4350</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-4351"><a href="#L-4351"><span class="linenos">4351</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_drop_column</span><span class="p">)</span> +</span><span id="L-4352"><a href="#L-4352"><span class="linenos">4352</span></a> +</span><span id="L-4353"><a href="#L-4353"><span class="linenos">4353</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_rename</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">RenameTable</span><span class="p">:</span> +</span><span id="L-4354"><a href="#L-4354"><span class="linenos">4354</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">)</span> +</span><span id="L-4355"><a href="#L-4355"><span class="linenos">4355</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">RenameTable</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_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="L-4356"><a href="#L-4356"><span class="linenos">4356</span></a> +</span><span id="L-4357"><a href="#L-4357"><span class="linenos">4357</span></a> <span class="k">def</span> <span class="nf">_parse_alter</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">AlterTable</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> +</span><span id="L-4358"><a href="#L-4358"><span class="linenos">4358</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> +</span><span id="L-4359"><a href="#L-4359"><span class="linenos">4359</span></a> +</span><span id="L-4360"><a href="#L-4360"><span class="linenos">4360</span></a> <span class="k">if</span> <span class="ow">not</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">TABLE</span><span class="p">):</span> +</span><span id="L-4361"><a href="#L-4361"><span class="linenos">4361</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> +</span><span id="L-4362"><a href="#L-4362"><span class="linenos">4362</span></a> +</span><span id="L-4363"><a href="#L-4363"><span class="linenos">4363</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">()</span> +</span><span id="L-4364"><a href="#L-4364"><span class="linenos">4364</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-4365"><a href="#L-4365"><span class="linenos">4365</span></a> +</span><span id="L-4366"><a href="#L-4366"><span class="linenos">4366</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> +</span><span id="L-4367"><a href="#L-4367"><span class="linenos">4367</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-4368"><a href="#L-4368"><span class="linenos">4368</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALTER_PARSERS</span><span class="o">.</span><span class="n">get</span><span class="p">(</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="o">.</span><span class="n">upper</span><span class="p">())</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="L-4369"><a href="#L-4369"><span class="linenos">4369</span></a> +</span><span id="L-4370"><a href="#L-4370"><span class="linenos">4370</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> +</span><span id="L-4371"><a href="#L-4371"><span class="linenos">4371</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span> +</span><span id="L-4372"><a href="#L-4372"><span class="linenos">4372</span></a> +</span><span id="L-4373"><a href="#L-4373"><span class="linenos">4373</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="L-4374"><a href="#L-4374"><span class="linenos">4374</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><span id="L-4375"><a href="#L-4375"><span class="linenos">4375</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AlterTable</span><span class="p">,</span> +</span><span id="L-4376"><a href="#L-4376"><span class="linenos">4376</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-4377"><a href="#L-4377"><span class="linenos">4377</span></a> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span><span class="p">,</span> +</span><span id="L-4378"><a href="#L-4378"><span class="linenos">4378</span></a> <span class="n">actions</span><span class="o">=</span><span class="n">actions</span><span class="p">,</span> +</span><span id="L-4379"><a href="#L-4379"><span class="linenos">4379</span></a> <span class="p">)</span> +</span><span id="L-4380"><a href="#L-4380"><span class="linenos">4380</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> +</span><span id="L-4381"><a href="#L-4381"><span class="linenos">4381</span></a> +</span><span id="L-4382"><a href="#L-4382"><span class="linenos">4382</span></a> <span class="k">def</span> <span class="nf">_parse_merge</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">Merge</span><span class="p">:</span> +</span><span id="L-4383"><a href="#L-4383"><span class="linenos">4383</span></a> <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">INTO</span><span class="p">)</span> +</span><span id="L-4384"><a href="#L-4384"><span class="linenos">4384</span></a> <span class="n">target</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> +</span><span id="L-4385"><a href="#L-4385"><span class="linenos">4385</span></a> +</span><span id="L-4386"><a href="#L-4386"><span class="linenos">4386</span></a> <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">USING</span><span class="p">)</span> +</span><span id="L-4387"><a href="#L-4387"><span class="linenos">4387</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> +</span><span id="L-4388"><a href="#L-4388"><span class="linenos">4388</span></a> +</span><span id="L-4389"><a href="#L-4389"><span class="linenos">4389</span></a> <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">ON</span><span class="p">)</span> +</span><span id="L-4390"><a href="#L-4390"><span class="linenos">4390</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="L-4391"><a href="#L-4391"><span class="linenos">4391</span></a> +</span><span id="L-4392"><a href="#L-4392"><span class="linenos">4392</span></a> <span class="n">whens</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-4393"><a href="#L-4393"><span class="linenos">4393</span></a> <span class="k">while</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">WHEN</span><span class="p">):</span> +</span><span id="L-4394"><a href="#L-4394"><span class="linenos">4394</span></a> <span class="n">matched</span> <span class="o">=</span> <span class="ow">not</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">NOT</span><span class="p">)</span> +</span><span id="L-4395"><a href="#L-4395"><span class="linenos">4395</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MATCHED"</span><span class="p">)</span> +</span><span id="L-4396"><a href="#L-4396"><span class="linenos">4396</span></a> <span class="n">source</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-4397"><a href="#L-4397"><span class="linenos">4397</span></a> <span class="kc">False</span> +</span><span id="L-4398"><a href="#L-4398"><span class="linenos">4398</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BY"</span><span class="p">,</span> <span class="s2">"TARGET"</span><span class="p">)</span> +</span><span id="L-4399"><a href="#L-4399"><span class="linenos">4399</span></a> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BY"</span><span class="p">,</span> <span class="s2">"SOURCE"</span><span class="p">)</span> +</span><span id="L-4400"><a href="#L-4400"><span class="linenos">4400</span></a> <span class="p">)</span> +</span><span id="L-4401"><a href="#L-4401"><span class="linenos">4401</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> <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">AND</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="L-4402"><a href="#L-4402"><span class="linenos">4402</span></a> +</span><span id="L-4403"><a href="#L-4403"><span class="linenos">4403</span></a> <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">THEN</span><span class="p">)</span> +</span><span id="L-4404"><a href="#L-4404"><span class="linenos">4404</span></a> +</span><span id="L-4405"><a href="#L-4405"><span class="linenos">4405</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">INSERT</span><span class="p">):</span> +</span><span id="L-4406"><a href="#L-4406"><span class="linenos">4406</span></a> <span class="n">_this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_star</span><span class="p">()</span> +</span><span id="L-4407"><a href="#L-4407"><span class="linenos">4407</span></a> <span class="k">if</span> <span class="n">_this</span><span class="p">:</span> +</span><span id="L-4408"><a href="#L-4408"><span class="linenos">4408</span></a> <span class="n">then</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="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">Insert</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">_this</span><span class="p">)</span> +</span><span id="L-4409"><a href="#L-4409"><span class="linenos">4409</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-4410"><a href="#L-4410"><span class="linenos">4410</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-4411"><a href="#L-4411"><span class="linenos">4411</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">,</span> +</span><span id="L-4412"><a href="#L-4412"><span class="linenos">4412</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">(),</span> +</span><span id="L-4413"><a href="#L-4413"><span class="linenos">4413</span></a> <span class="n">expression</span><span class="o">=</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">VALUES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">(),</span> +</span><span id="L-4414"><a href="#L-4414"><span class="linenos">4414</span></a> <span class="p">)</span> +</span><span id="L-4415"><a href="#L-4415"><span class="linenos">4415</span></a> <span class="k">elif</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">UPDATE</span><span class="p">):</span> +</span><span id="L-4416"><a href="#L-4416"><span class="linenos">4416</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_star</span><span class="p">()</span> +</span><span id="L-4417"><a href="#L-4417"><span class="linenos">4417</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="L-4418"><a href="#L-4418"><span class="linenos">4418</span></a> <span class="n">then</span> <span class="o">=</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">Update</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-4419"><a href="#L-4419"><span class="linenos">4419</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-4420"><a href="#L-4420"><span class="linenos">4420</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-4421"><a href="#L-4421"><span class="linenos">4421</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> +</span><span id="L-4422"><a href="#L-4422"><span class="linenos">4422</span></a> <span class="n">expressions</span><span class="o">=</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">SET</span><span class="p">)</span> +</span><span id="L-4423"><a href="#L-4423"><span class="linenos">4423</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">),</span> +</span><span id="L-4424"><a href="#L-4424"><span class="linenos">4424</span></a> <span class="p">)</span> +</span><span id="L-4425"><a href="#L-4425"><span class="linenos">4425</span></a> <span class="k">elif</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">DELETE</span><span class="p">):</span> +</span><span id="L-4426"><a href="#L-4426"><span class="linenos">4426</span></a> <span class="n">then</span> <span class="o">=</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">Var</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-4427"><a href="#L-4427"><span class="linenos">4427</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-4428"><a href="#L-4428"><span class="linenos">4428</span></a> <span class="n">then</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-4429"><a href="#L-4429"><span class="linenos">4429</span></a> +</span><span id="L-4430"><a href="#L-4430"><span class="linenos">4430</span></a> <span class="n">whens</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="L-4431"><a href="#L-4431"><span class="linenos">4431</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="L-4432"><a href="#L-4432"><span class="linenos">4432</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">When</span><span class="p">,</span> +</span><span id="L-4433"><a href="#L-4433"><span class="linenos">4433</span></a> <span class="n">matched</span><span class="o">=</span><span class="n">matched</span><span class="p">,</span> +</span><span id="L-4434"><a href="#L-4434"><span class="linenos">4434</span></a> <span class="n">source</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> +</span><span id="L-4435"><a href="#L-4435"><span class="linenos">4435</span></a> <span class="n">condition</span><span class="o">=</span><span class="n">condition</span><span class="p">,</span> +</span><span id="L-4436"><a href="#L-4436"><span class="linenos">4436</span></a> <span class="n">then</span><span class="o">=</span><span class="n">then</span><span class="p">,</span> +</span><span id="L-4437"><a href="#L-4437"><span class="linenos">4437</span></a> <span class="p">)</span> +</span><span id="L-4438"><a href="#L-4438"><span class="linenos">4438</span></a> <span class="p">)</span> </span><span id="L-4439"><a href="#L-4439"><span class="linenos">4439</span></a> -</span><span id="L-4440"><a href="#L-4440"><span class="linenos">4440</span></a> <span class="k">def</span> <span class="nf">_parse_show</span><span class="p">(</span><span class="bp">self</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-4441"><a href="#L-4441"><span class="linenos">4441</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_parser</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SHOW_PARSERS</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SHOW_TRIE</span><span class="p">)</span> -</span><span id="L-4442"><a href="#L-4442"><span class="linenos">4442</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> -</span><span id="L-4443"><a href="#L-4443"><span class="linenos">4443</span></a> <span class="k">return</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> -</span><span id="L-4444"><a href="#L-4444"><span class="linenos">4444</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-4445"><a href="#L-4445"><span class="linenos">4445</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">Show</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="o">.</span><span class="n">upper</span><span class="p">())</span> -</span><span id="L-4446"><a href="#L-4446"><span class="linenos">4446</span></a> -</span><span id="L-4447"><a href="#L-4447"><span class="linenos">4447</span></a> <span class="k">def</span> <span class="nf">_parse_set_item_assignment</span><span class="p">(</span> -</span><span id="L-4448"><a href="#L-4448"><span class="linenos">4448</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">kind</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><span id="L-4449"><a href="#L-4449"><span class="linenos">4449</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-4450"><a href="#L-4450"><span class="linenos">4450</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="L-4451"><a href="#L-4451"><span class="linenos">4451</span></a> -</span><span id="L-4452"><a href="#L-4452"><span class="linenos">4452</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="ow">in</span> <span class="p">{</span><span class="s2">"GLOBAL"</span><span class="p">,</span> <span class="s2">"SESSION"</span><span class="p">}</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TRANSACTION"</span><span class="p">):</span> -</span><span id="L-4453"><a href="#L-4453"><span class="linenos">4453</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_transaction</span><span class="p">(</span><span class="n">global_</span><span class="o">=</span><span class="n">kind</span> <span class="o">==</span> <span class="s2">"GLOBAL"</span><span class="p">)</span> +</span><span id="L-4440"><a href="#L-4440"><span class="linenos">4440</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><span id="L-4441"><a href="#L-4441"><span class="linenos">4441</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Merge</span><span class="p">,</span> +</span><span id="L-4442"><a href="#L-4442"><span class="linenos">4442</span></a> <span class="n">this</span><span class="o">=</span><span class="n">target</span><span class="p">,</span> +</span><span id="L-4443"><a href="#L-4443"><span class="linenos">4443</span></a> <span class="n">using</span><span class="o">=</span><span class="n">using</span><span class="p">,</span> +</span><span id="L-4444"><a href="#L-4444"><span class="linenos">4444</span></a> <span class="n">on</span><span class="o">=</span><span class="n">on</span><span class="p">,</span> +</span><span id="L-4445"><a href="#L-4445"><span class="linenos">4445</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">whens</span><span class="p">,</span> +</span><span id="L-4446"><a href="#L-4446"><span class="linenos">4446</span></a> <span class="p">)</span> +</span><span id="L-4447"><a href="#L-4447"><span class="linenos">4447</span></a> +</span><span id="L-4448"><a href="#L-4448"><span class="linenos">4448</span></a> <span class="k">def</span> <span class="nf">_parse_show</span><span class="p">(</span><span class="bp">self</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-4449"><a href="#L-4449"><span class="linenos">4449</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_parser</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SHOW_PARSERS</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SHOW_TRIE</span><span class="p">)</span> +</span><span id="L-4450"><a href="#L-4450"><span class="linenos">4450</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> +</span><span id="L-4451"><a href="#L-4451"><span class="linenos">4451</span></a> <span class="k">return</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> +</span><span id="L-4452"><a href="#L-4452"><span class="linenos">4452</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-4453"><a href="#L-4453"><span class="linenos">4453</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">Show</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="o">.</span><span class="n">upper</span><span class="p">())</span> </span><span id="L-4454"><a href="#L-4454"><span class="linenos">4454</span></a> -</span><span id="L-4455"><a href="#L-4455"><span class="linenos">4455</span></a> <span class="n">left</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="L-4456"><a href="#L-4456"><span class="linenos">4456</span></a> -</span><span id="L-4457"><a href="#L-4457"><span class="linenos">4457</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"="</span><span class="p">,</span> <span class="s2">"TO"</span><span class="p">)):</span> -</span><span id="L-4458"><a href="#L-4458"><span class="linenos">4458</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-4459"><a href="#L-4459"><span class="linenos">4459</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-4460"><a href="#L-4460"><span class="linenos">4460</span></a> -</span><span id="L-4461"><a href="#L-4461"><span class="linenos">4461</span></a> <span class="n">right</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="L-4462"><a href="#L-4462"><span class="linenos">4462</span></a> <span class="n">this</span> <span class="o">=</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">EQ</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">right</span><span class="p">)</span> -</span><span id="L-4463"><a href="#L-4463"><span class="linenos">4463</span></a> -</span><span id="L-4464"><a href="#L-4464"><span class="linenos">4464</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">SetItem</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">)</span> -</span><span id="L-4465"><a href="#L-4465"><span class="linenos">4465</span></a> -</span><span id="L-4466"><a href="#L-4466"><span class="linenos">4466</span></a> <span class="k">def</span> <span class="nf">_parse_set_transaction</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">global_</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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="L-4467"><a href="#L-4467"><span class="linenos">4467</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TRANSACTION"</span><span class="p">)</span> -</span><span id="L-4468"><a href="#L-4468"><span class="linenos">4468</span></a> <span class="n">characteristics</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> -</span><span id="L-4469"><a href="#L-4469"><span class="linenos">4469</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var_from_options</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">TRANSACTION_CHARACTERISTICS</span><span class="p">)</span> -</span><span id="L-4470"><a href="#L-4470"><span class="linenos">4470</span></a> <span class="p">)</span> -</span><span id="L-4471"><a href="#L-4471"><span class="linenos">4471</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><span id="L-4472"><a href="#L-4472"><span class="linenos">4472</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetItem</span><span class="p">,</span> -</span><span id="L-4473"><a href="#L-4473"><span class="linenos">4473</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">characteristics</span><span class="p">,</span> -</span><span id="L-4474"><a href="#L-4474"><span class="linenos">4474</span></a> <span class="n">kind</span><span class="o">=</span><span class="s2">"TRANSACTION"</span><span class="p">,</span> -</span><span id="L-4475"><a href="#L-4475"><span class="linenos">4475</span></a> <span class="o">**</span><span class="p">{</span><span class="s2">"global"</span><span class="p">:</span> <span class="n">global_</span><span class="p">},</span> <span class="c1"># type: ignore</span> -</span><span id="L-4476"><a href="#L-4476"><span class="linenos">4476</span></a> <span class="p">)</span> -</span><span id="L-4477"><a href="#L-4477"><span class="linenos">4477</span></a> -</span><span id="L-4478"><a href="#L-4478"><span class="linenos">4478</span></a> <span class="k">def</span> <span class="nf">_parse_set_item</span><span class="p">(</span><span class="bp">self</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-4479"><a href="#L-4479"><span class="linenos">4479</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_parser</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SET_PARSERS</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SET_TRIE</span><span class="p">)</span> -</span><span id="L-4480"><a href="#L-4480"><span class="linenos">4480</span></a> <span class="k">return</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="k">if</span> <span class="n">parser</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_item_assignment</span><span class="p">(</span><span class="n">kind</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> -</span><span id="L-4481"><a href="#L-4481"><span class="linenos">4481</span></a> -</span><span id="L-4482"><a href="#L-4482"><span class="linenos">4482</span></a> <span class="k">def</span> <span class="nf">_parse_set</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">Set</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> -</span><span id="L-4483"><a href="#L-4483"><span class="linenos">4483</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="L-4484"><a href="#L-4484"><span class="linenos">4484</span></a> <span class="n">set_</span> <span class="o">=</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">Set</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_item</span><span class="p">))</span> +</span><span id="L-4455"><a href="#L-4455"><span class="linenos">4455</span></a> <span class="k">def</span> <span class="nf">_parse_set_item_assignment</span><span class="p">(</span> +</span><span id="L-4456"><a href="#L-4456"><span class="linenos">4456</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">kind</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><span id="L-4457"><a href="#L-4457"><span class="linenos">4457</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-4458"><a href="#L-4458"><span class="linenos">4458</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="L-4459"><a href="#L-4459"><span class="linenos">4459</span></a> +</span><span id="L-4460"><a href="#L-4460"><span class="linenos">4460</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="ow">in</span> <span class="p">{</span><span class="s2">"GLOBAL"</span><span class="p">,</span> <span class="s2">"SESSION"</span><span class="p">}</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TRANSACTION"</span><span class="p">):</span> +</span><span id="L-4461"><a href="#L-4461"><span class="linenos">4461</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_transaction</span><span class="p">(</span><span class="n">global_</span><span class="o">=</span><span class="n">kind</span> <span class="o">==</span> <span class="s2">"GLOBAL"</span><span class="p">)</span> +</span><span id="L-4462"><a href="#L-4462"><span class="linenos">4462</span></a> +</span><span id="L-4463"><a href="#L-4463"><span class="linenos">4463</span></a> <span class="n">left</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="L-4464"><a href="#L-4464"><span class="linenos">4464</span></a> +</span><span id="L-4465"><a href="#L-4465"><span class="linenos">4465</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"="</span><span class="p">,</span> <span class="s2">"TO"</span><span class="p">)):</span> +</span><span id="L-4466"><a href="#L-4466"><span class="linenos">4466</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-4467"><a href="#L-4467"><span class="linenos">4467</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-4468"><a href="#L-4468"><span class="linenos">4468</span></a> +</span><span id="L-4469"><a href="#L-4469"><span class="linenos">4469</span></a> <span class="n">right</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="L-4470"><a href="#L-4470"><span class="linenos">4470</span></a> <span class="n">this</span> <span class="o">=</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">EQ</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">right</span><span class="p">)</span> +</span><span id="L-4471"><a href="#L-4471"><span class="linenos">4471</span></a> +</span><span id="L-4472"><a href="#L-4472"><span class="linenos">4472</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">SetItem</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">)</span> +</span><span id="L-4473"><a href="#L-4473"><span class="linenos">4473</span></a> +</span><span id="L-4474"><a href="#L-4474"><span class="linenos">4474</span></a> <span class="k">def</span> <span class="nf">_parse_set_transaction</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">global_</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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="L-4475"><a href="#L-4475"><span class="linenos">4475</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TRANSACTION"</span><span class="p">)</span> +</span><span id="L-4476"><a href="#L-4476"><span class="linenos">4476</span></a> <span class="n">characteristics</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> +</span><span id="L-4477"><a href="#L-4477"><span class="linenos">4477</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var_from_options</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">TRANSACTION_CHARACTERISTICS</span><span class="p">)</span> +</span><span id="L-4478"><a href="#L-4478"><span class="linenos">4478</span></a> <span class="p">)</span> +</span><span id="L-4479"><a href="#L-4479"><span class="linenos">4479</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><span id="L-4480"><a href="#L-4480"><span class="linenos">4480</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetItem</span><span class="p">,</span> +</span><span id="L-4481"><a href="#L-4481"><span class="linenos">4481</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">characteristics</span><span class="p">,</span> +</span><span id="L-4482"><a href="#L-4482"><span class="linenos">4482</span></a> <span class="n">kind</span><span class="o">=</span><span class="s2">"TRANSACTION"</span><span class="p">,</span> +</span><span id="L-4483"><a href="#L-4483"><span class="linenos">4483</span></a> <span class="o">**</span><span class="p">{</span><span class="s2">"global"</span><span class="p">:</span> <span class="n">global_</span><span class="p">},</span> <span class="c1"># type: ignore</span> +</span><span id="L-4484"><a href="#L-4484"><span class="linenos">4484</span></a> <span class="p">)</span> </span><span id="L-4485"><a href="#L-4485"><span class="linenos">4485</span></a> -</span><span id="L-4486"><a href="#L-4486"><span class="linenos">4486</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="L-4487"><a href="#L-4487"><span class="linenos">4487</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-4488"><a href="#L-4488"><span class="linenos">4488</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="L-4486"><a href="#L-4486"><span class="linenos">4486</span></a> <span class="k">def</span> <span class="nf">_parse_set_item</span><span class="p">(</span><span class="bp">self</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-4487"><a href="#L-4487"><span class="linenos">4487</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_parser</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SET_PARSERS</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SET_TRIE</span><span class="p">)</span> +</span><span id="L-4488"><a href="#L-4488"><span class="linenos">4488</span></a> <span class="k">return</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="k">if</span> <span class="n">parser</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_item_assignment</span><span class="p">(</span><span class="n">kind</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> </span><span id="L-4489"><a href="#L-4489"><span class="linenos">4489</span></a> -</span><span id="L-4490"><a href="#L-4490"><span class="linenos">4490</span></a> <span class="k">return</span> <span class="n">set_</span> -</span><span id="L-4491"><a href="#L-4491"><span class="linenos">4491</span></a> -</span><span id="L-4492"><a href="#L-4492"><span class="linenos">4492</span></a> <span class="k">def</span> <span class="nf">_parse_var_from_options</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">options</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="nb">str</span><span class="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">Var</span><span class="p">]:</span> -</span><span id="L-4493"><a href="#L-4493"><span class="linenos">4493</span></a> <span class="k">for</span> <span class="n">option</span> <span class="ow">in</span> <span class="n">options</span><span class="p">:</span> -</span><span id="L-4494"><a href="#L-4494"><span class="linenos">4494</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="o">*</span><span class="n">option</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">)):</span> -</span><span id="L-4495"><a href="#L-4495"><span class="linenos">4495</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">option</span><span class="p">)</span> -</span><span id="L-4496"><a href="#L-4496"><span class="linenos">4496</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-4490"><a href="#L-4490"><span class="linenos">4490</span></a> <span class="k">def</span> <span class="nf">_parse_set</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">Set</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> +</span><span id="L-4491"><a href="#L-4491"><span class="linenos">4491</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="L-4492"><a href="#L-4492"><span class="linenos">4492</span></a> <span class="n">set_</span> <span class="o">=</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">Set</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_item</span><span class="p">))</span> +</span><span id="L-4493"><a href="#L-4493"><span class="linenos">4493</span></a> +</span><span id="L-4494"><a href="#L-4494"><span class="linenos">4494</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="L-4495"><a href="#L-4495"><span class="linenos">4495</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-4496"><a href="#L-4496"><span class="linenos">4496</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> </span><span id="L-4497"><a href="#L-4497"><span class="linenos">4497</span></a> -</span><span id="L-4498"><a href="#L-4498"><span class="linenos">4498</span></a> <span class="k">def</span> <span class="nf">_parse_as_command</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">start</span><span class="p">:</span> <span class="n">Token</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> -</span><span id="L-4499"><a href="#L-4499"><span class="linenos">4499</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="L-4500"><a href="#L-4500"><span class="linenos">4500</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-4501"><a href="#L-4501"><span class="linenos">4501</span></a> <span class="n">text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_sql</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> -</span><span id="L-4502"><a href="#L-4502"><span class="linenos">4502</span></a> <span class="n">size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">start</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> -</span><span id="L-4503"><a href="#L-4503"><span class="linenos">4503</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">text</span><span class="p">[:</span><span class="n">size</span><span class="p">],</span> <span class="n">expression</span><span class="o">=</span><span class="n">text</span><span class="p">[</span><span class="n">size</span><span class="p">:])</span> -</span><span id="L-4504"><a href="#L-4504"><span class="linenos">4504</span></a> -</span><span id="L-4505"><a href="#L-4505"><span class="linenos">4505</span></a> <span class="k">def</span> <span class="nf">_parse_dict_property</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">:</span> -</span><span id="L-4506"><a href="#L-4506"><span class="linenos">4506</span></a> <span class="n">settings</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-4507"><a href="#L-4507"><span class="linenos">4507</span></a> -</span><span id="L-4508"><a href="#L-4508"><span class="linenos">4508</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> -</span><span id="L-4509"><a href="#L-4509"><span class="linenos">4509</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="L-4510"><a href="#L-4510"><span class="linenos">4510</span></a> -</span><span id="L-4511"><a href="#L-4511"><span class="linenos">4511</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_PAREN</span><span class="p">):</span> -</span><span id="L-4512"><a href="#L-4512"><span class="linenos">4512</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-4513"><a href="#L-4513"><span class="linenos">4513</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="L-4514"><a href="#L-4514"><span class="linenos">4514</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="L-4498"><a href="#L-4498"><span class="linenos">4498</span></a> <span class="k">return</span> <span class="n">set_</span> +</span><span id="L-4499"><a href="#L-4499"><span class="linenos">4499</span></a> +</span><span id="L-4500"><a href="#L-4500"><span class="linenos">4500</span></a> <span class="k">def</span> <span class="nf">_parse_var_from_options</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">options</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="nb">str</span><span class="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">Var</span><span class="p">]:</span> +</span><span id="L-4501"><a href="#L-4501"><span class="linenos">4501</span></a> <span class="k">for</span> <span class="n">option</span> <span class="ow">in</span> <span class="n">options</span><span class="p">:</span> +</span><span id="L-4502"><a href="#L-4502"><span class="linenos">4502</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="o">*</span><span class="n">option</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">)):</span> +</span><span id="L-4503"><a href="#L-4503"><span class="linenos">4503</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">option</span><span class="p">)</span> +</span><span id="L-4504"><a href="#L-4504"><span class="linenos">4504</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-4505"><a href="#L-4505"><span class="linenos">4505</span></a> +</span><span id="L-4506"><a href="#L-4506"><span class="linenos">4506</span></a> <span class="k">def</span> <span class="nf">_parse_as_command</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">start</span><span class="p">:</span> <span class="n">Token</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> +</span><span id="L-4507"><a href="#L-4507"><span class="linenos">4507</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="L-4508"><a href="#L-4508"><span class="linenos">4508</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-4509"><a href="#L-4509"><span class="linenos">4509</span></a> <span class="n">text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_sql</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="L-4510"><a href="#L-4510"><span class="linenos">4510</span></a> <span class="n">size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">start</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> +</span><span id="L-4511"><a href="#L-4511"><span class="linenos">4511</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">text</span><span class="p">[:</span><span class="n">size</span><span class="p">],</span> <span class="n">expression</span><span class="o">=</span><span class="n">text</span><span class="p">[</span><span class="n">size</span><span class="p">:])</span> +</span><span id="L-4512"><a href="#L-4512"><span class="linenos">4512</span></a> +</span><span id="L-4513"><a href="#L-4513"><span class="linenos">4513</span></a> <span class="k">def</span> <span class="nf">_parse_dict_property</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">:</span> +</span><span id="L-4514"><a href="#L-4514"><span class="linenos">4514</span></a> <span class="n">settings</span> <span class="o">=</span> <span class="p">[]</span> </span><span id="L-4515"><a href="#L-4515"><span class="linenos">4515</span></a> -</span><span id="L-4516"><a href="#L-4516"><span class="linenos">4516</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">key</span> <span class="ow">and</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-4517"><a href="#L-4517"><span class="linenos">4517</span></a> <span class="k">break</span> -</span><span id="L-4518"><a href="#L-4518"><span class="linenos">4518</span></a> <span class="n">settings</span><span class="o">.</span><span class="n">append</span><span class="p">(</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">DictSubProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="n">value</span><span class="p">))</span> -</span><span id="L-4519"><a href="#L-4519"><span class="linenos">4519</span></a> <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">R_PAREN</span><span class="p">)</span> -</span><span id="L-4520"><a href="#L-4520"><span class="linenos">4520</span></a> -</span><span id="L-4521"><a href="#L-4521"><span class="linenos">4521</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="L-4522"><a href="#L-4522"><span class="linenos">4522</span></a> -</span><span id="L-4523"><a href="#L-4523"><span class="linenos">4523</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><span id="L-4524"><a href="#L-4524"><span class="linenos">4524</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">,</span> -</span><span id="L-4525"><a href="#L-4525"><span class="linenos">4525</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="L-4526"><a href="#L-4526"><span class="linenos">4526</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-4527"><a href="#L-4527"><span class="linenos">4527</span></a> <span class="n">settings</span><span class="o">=</span><span class="n">settings</span><span class="p">,</span> -</span><span id="L-4528"><a href="#L-4528"><span class="linenos">4528</span></a> <span class="p">)</span> -</span><span id="L-4529"><a href="#L-4529"><span class="linenos">4529</span></a> -</span><span id="L-4530"><a href="#L-4530"><span class="linenos">4530</span></a> <span class="k">def</span> <span class="nf">_parse_dict_range</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DictRange</span><span class="p">:</span> -</span><span id="L-4531"><a href="#L-4531"><span class="linenos">4531</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> -</span><span id="L-4532"><a href="#L-4532"><span class="linenos">4532</span></a> <span class="n">has_min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MIN"</span><span class="p">)</span> -</span><span id="L-4533"><a href="#L-4533"><span class="linenos">4533</span></a> <span class="k">if</span> <span class="n">has_min</span><span class="p">:</span> -</span><span id="L-4534"><a href="#L-4534"><span class="linenos">4534</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> -</span><span id="L-4535"><a href="#L-4535"><span class="linenos">4535</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">)</span> -</span><span id="L-4536"><a href="#L-4536"><span class="linenos">4536</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> -</span><span id="L-4537"><a href="#L-4537"><span class="linenos">4537</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-4538"><a href="#L-4538"><span class="linenos">4538</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> -</span><span id="L-4539"><a href="#L-4539"><span class="linenos">4539</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> -</span><span id="L-4540"><a href="#L-4540"><span class="linenos">4540</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="L-4541"><a href="#L-4541"><span class="linenos">4541</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">DictRange</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="nb">min</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="nb">max</span><span class="p">)</span> -</span><span id="L-4542"><a href="#L-4542"><span class="linenos">4542</span></a> -</span><span id="L-4543"><a href="#L-4543"><span class="linenos">4543</span></a> <span class="k">def</span> <span class="nf">_find_parser</span><span class="p">(</span> -</span><span id="L-4544"><a href="#L-4544"><span class="linenos">4544</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">parsers</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">],</span> <span class="n">trie</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> -</span><span id="L-4545"><a href="#L-4545"><span class="linenos">4545</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">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]:</span> -</span><span id="L-4546"><a href="#L-4546"><span class="linenos">4546</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="L-4547"><a href="#L-4547"><span class="linenos">4547</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-4548"><a href="#L-4548"><span class="linenos">4548</span></a> -</span><span id="L-4549"><a href="#L-4549"><span class="linenos">4549</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="L-4550"><a href="#L-4550"><span class="linenos">4550</span></a> <span class="n">this</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-4551"><a href="#L-4551"><span class="linenos">4551</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-4552"><a href="#L-4552"><span class="linenos">4552</span></a> <span class="c1"># The current token might be multiple words</span> -</span><span id="L-4553"><a href="#L-4553"><span class="linenos">4553</span></a> <span class="n">curr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-4554"><a href="#L-4554"><span class="linenos">4554</span></a> <span class="n">key</span> <span class="o">=</span> <span class="n">curr</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="L-4555"><a href="#L-4555"><span class="linenos">4555</span></a> <span class="n">this</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">curr</span><span class="p">)</span> -</span><span id="L-4556"><a href="#L-4556"><span class="linenos">4556</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-4557"><a href="#L-4557"><span class="linenos">4557</span></a> <span class="n">result</span><span class="p">,</span> <span class="n">trie</span> <span class="o">=</span> <span class="n">in_trie</span><span class="p">(</span><span class="n">trie</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> -</span><span id="L-4558"><a href="#L-4558"><span class="linenos">4558</span></a> <span class="k">if</span> <span class="n">result</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> -</span><span id="L-4559"><a href="#L-4559"><span class="linenos">4559</span></a> <span class="k">break</span> -</span><span id="L-4560"><a href="#L-4560"><span class="linenos">4560</span></a> <span class="k">if</span> <span class="n">result</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> -</span><span id="L-4561"><a href="#L-4561"><span class="linenos">4561</span></a> <span class="n">subparser</span> <span class="o">=</span> <span class="n">parsers</span><span class="p">[</span><span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">this</span><span class="p">)]</span> -</span><span id="L-4562"><a href="#L-4562"><span class="linenos">4562</span></a> <span class="k">return</span> <span class="n">subparser</span> -</span><span id="L-4563"><a href="#L-4563"><span class="linenos">4563</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-4564"><a href="#L-4564"><span class="linenos">4564</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-4565"><a href="#L-4565"><span class="linenos">4565</span></a> -</span><span id="L-4566"><a href="#L-4566"><span class="linenos">4566</span></a> <span class="k">def</span> <span class="nf">_match</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> -</span><span id="L-4567"><a href="#L-4567"><span class="linenos">4567</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="L-4568"><a href="#L-4568"><span class="linenos">4568</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-4569"><a href="#L-4569"><span class="linenos">4569</span></a> -</span><span id="L-4570"><a href="#L-4570"><span class="linenos">4570</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">token_type</span><span class="p">:</span> -</span><span id="L-4571"><a href="#L-4571"><span class="linenos">4571</span></a> <span class="k">if</span> <span class="n">advance</span><span class="p">:</span> -</span><span id="L-4572"><a href="#L-4572"><span class="linenos">4572</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-4573"><a href="#L-4573"><span class="linenos">4573</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add_comments</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-4574"><a href="#L-4574"><span class="linenos">4574</span></a> <span class="k">return</span> <span class="kc">True</span> -</span><span id="L-4575"><a href="#L-4575"><span class="linenos">4575</span></a> -</span><span id="L-4576"><a href="#L-4576"><span class="linenos">4576</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-4516"><a href="#L-4516"><span class="linenos">4516</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> +</span><span id="L-4517"><a href="#L-4517"><span class="linenos">4517</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="L-4518"><a href="#L-4518"><span class="linenos">4518</span></a> +</span><span id="L-4519"><a href="#L-4519"><span class="linenos">4519</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_PAREN</span><span class="p">):</span> +</span><span id="L-4520"><a href="#L-4520"><span class="linenos">4520</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-4521"><a href="#L-4521"><span class="linenos">4521</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="L-4522"><a href="#L-4522"><span class="linenos">4522</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="L-4523"><a href="#L-4523"><span class="linenos">4523</span></a> +</span><span id="L-4524"><a href="#L-4524"><span class="linenos">4524</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">key</span> <span class="ow">and</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-4525"><a href="#L-4525"><span class="linenos">4525</span></a> <span class="k">break</span> +</span><span id="L-4526"><a href="#L-4526"><span class="linenos">4526</span></a> <span class="n">settings</span><span class="o">.</span><span class="n">append</span><span class="p">(</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">DictSubProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="n">value</span><span class="p">))</span> +</span><span id="L-4527"><a href="#L-4527"><span class="linenos">4527</span></a> <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">R_PAREN</span><span class="p">)</span> +</span><span id="L-4528"><a href="#L-4528"><span class="linenos">4528</span></a> +</span><span id="L-4529"><a href="#L-4529"><span class="linenos">4529</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-4530"><a href="#L-4530"><span class="linenos">4530</span></a> +</span><span id="L-4531"><a href="#L-4531"><span class="linenos">4531</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><span id="L-4532"><a href="#L-4532"><span class="linenos">4532</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">,</span> +</span><span id="L-4533"><a href="#L-4533"><span class="linenos">4533</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="L-4534"><a href="#L-4534"><span class="linenos">4534</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-4535"><a href="#L-4535"><span class="linenos">4535</span></a> <span class="n">settings</span><span class="o">=</span><span class="n">settings</span><span class="p">,</span> +</span><span id="L-4536"><a href="#L-4536"><span class="linenos">4536</span></a> <span class="p">)</span> +</span><span id="L-4537"><a href="#L-4537"><span class="linenos">4537</span></a> +</span><span id="L-4538"><a href="#L-4538"><span class="linenos">4538</span></a> <span class="k">def</span> <span class="nf">_parse_dict_range</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DictRange</span><span class="p">:</span> +</span><span id="L-4539"><a href="#L-4539"><span class="linenos">4539</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> +</span><span id="L-4540"><a href="#L-4540"><span class="linenos">4540</span></a> <span class="n">has_min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MIN"</span><span class="p">)</span> +</span><span id="L-4541"><a href="#L-4541"><span class="linenos">4541</span></a> <span class="k">if</span> <span class="n">has_min</span><span class="p">:</span> +</span><span id="L-4542"><a href="#L-4542"><span class="linenos">4542</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="L-4543"><a href="#L-4543"><span class="linenos">4543</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">)</span> +</span><span id="L-4544"><a href="#L-4544"><span class="linenos">4544</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="L-4545"><a href="#L-4545"><span class="linenos">4545</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-4546"><a href="#L-4546"><span class="linenos">4546</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="L-4547"><a href="#L-4547"><span class="linenos">4547</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> +</span><span id="L-4548"><a href="#L-4548"><span class="linenos">4548</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="L-4549"><a href="#L-4549"><span class="linenos">4549</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">DictRange</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="nb">min</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="nb">max</span><span class="p">)</span> +</span><span id="L-4550"><a href="#L-4550"><span class="linenos">4550</span></a> +</span><span id="L-4551"><a href="#L-4551"><span class="linenos">4551</span></a> <span class="k">def</span> <span class="nf">_find_parser</span><span class="p">(</span> +</span><span id="L-4552"><a href="#L-4552"><span class="linenos">4552</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">parsers</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">],</span> <span class="n">trie</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> +</span><span id="L-4553"><a href="#L-4553"><span class="linenos">4553</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">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]:</span> +</span><span id="L-4554"><a href="#L-4554"><span class="linenos">4554</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="L-4555"><a href="#L-4555"><span class="linenos">4555</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-4556"><a href="#L-4556"><span class="linenos">4556</span></a> +</span><span id="L-4557"><a href="#L-4557"><span class="linenos">4557</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="L-4558"><a href="#L-4558"><span class="linenos">4558</span></a> <span class="n">this</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-4559"><a href="#L-4559"><span class="linenos">4559</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-4560"><a href="#L-4560"><span class="linenos">4560</span></a> <span class="c1"># The current token might be multiple words</span> +</span><span id="L-4561"><a href="#L-4561"><span class="linenos">4561</span></a> <span class="n">curr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-4562"><a href="#L-4562"><span class="linenos">4562</span></a> <span class="n">key</span> <span class="o">=</span> <span class="n">curr</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="L-4563"><a href="#L-4563"><span class="linenos">4563</span></a> <span class="n">this</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">curr</span><span class="p">)</span> +</span><span id="L-4564"><a href="#L-4564"><span class="linenos">4564</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-4565"><a href="#L-4565"><span class="linenos">4565</span></a> <span class="n">result</span><span class="p">,</span> <span class="n">trie</span> <span class="o">=</span> <span class="n">in_trie</span><span class="p">(</span><span class="n">trie</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> +</span><span id="L-4566"><a href="#L-4566"><span class="linenos">4566</span></a> <span class="k">if</span> <span class="n">result</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> +</span><span id="L-4567"><a href="#L-4567"><span class="linenos">4567</span></a> <span class="k">break</span> +</span><span id="L-4568"><a href="#L-4568"><span class="linenos">4568</span></a> <span class="k">if</span> <span class="n">result</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> +</span><span id="L-4569"><a href="#L-4569"><span class="linenos">4569</span></a> <span class="n">subparser</span> <span class="o">=</span> <span class="n">parsers</span><span class="p">[</span><span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">this</span><span class="p">)]</span> +</span><span id="L-4570"><a href="#L-4570"><span class="linenos">4570</span></a> <span class="k">return</span> <span class="n">subparser</span> +</span><span id="L-4571"><a href="#L-4571"><span class="linenos">4571</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-4572"><a href="#L-4572"><span class="linenos">4572</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-4573"><a href="#L-4573"><span class="linenos">4573</span></a> +</span><span id="L-4574"><a href="#L-4574"><span class="linenos">4574</span></a> <span class="k">def</span> <span class="nf">_match</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> +</span><span id="L-4575"><a href="#L-4575"><span class="linenos">4575</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="L-4576"><a href="#L-4576"><span class="linenos">4576</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="L-4577"><a href="#L-4577"><span class="linenos">4577</span></a> -</span><span id="L-4578"><a href="#L-4578"><span class="linenos">4578</span></a> <span class="k">def</span> <span class="nf">_match_set</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">types</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> -</span><span id="L-4579"><a href="#L-4579"><span class="linenos">4579</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="L-4580"><a href="#L-4580"><span class="linenos">4580</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-4581"><a href="#L-4581"><span class="linenos">4581</span></a> -</span><span id="L-4582"><a href="#L-4582"><span class="linenos">4582</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="n">types</span><span class="p">:</span> -</span><span id="L-4583"><a href="#L-4583"><span class="linenos">4583</span></a> <span class="k">if</span> <span class="n">advance</span><span class="p">:</span> -</span><span id="L-4584"><a href="#L-4584"><span class="linenos">4584</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-4585"><a href="#L-4585"><span class="linenos">4585</span></a> <span class="k">return</span> <span class="kc">True</span> -</span><span id="L-4586"><a href="#L-4586"><span class="linenos">4586</span></a> -</span><span id="L-4587"><a href="#L-4587"><span class="linenos">4587</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-4588"><a href="#L-4588"><span class="linenos">4588</span></a> -</span><span id="L-4589"><a href="#L-4589"><span class="linenos">4589</span></a> <span class="k">def</span> <span class="nf">_match_pair</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type_a</span><span class="p">,</span> <span class="n">token_type_b</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> -</span><span id="L-4590"><a href="#L-4590"><span class="linenos">4590</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> -</span><span id="L-4591"><a href="#L-4591"><span class="linenos">4591</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-4592"><a href="#L-4592"><span class="linenos">4592</span></a> -</span><span id="L-4593"><a href="#L-4593"><span class="linenos">4593</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">token_type_a</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">token_type_b</span><span class="p">:</span> -</span><span id="L-4594"><a href="#L-4594"><span class="linenos">4594</span></a> <span class="k">if</span> <span class="n">advance</span><span class="p">:</span> -</span><span id="L-4595"><a href="#L-4595"><span class="linenos">4595</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> -</span><span id="L-4596"><a href="#L-4596"><span class="linenos">4596</span></a> <span class="k">return</span> <span class="kc">True</span> -</span><span id="L-4597"><a href="#L-4597"><span class="linenos">4597</span></a> -</span><span id="L-4598"><a href="#L-4598"><span class="linenos">4598</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-4599"><a href="#L-4599"><span class="linenos">4599</span></a> -</span><span id="L-4600"><a href="#L-4600"><span class="linenos">4600</span></a> <span class="k">def</span> <span class="nf">_match_l_paren</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-4601"><a href="#L-4601"><span class="linenos">4601</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">):</span> -</span><span id="L-4602"><a href="#L-4602"><span class="linenos">4602</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting ("</span><span class="p">)</span> -</span><span id="L-4603"><a href="#L-4603"><span class="linenos">4603</span></a> -</span><span id="L-4604"><a href="#L-4604"><span class="linenos">4604</span></a> <span class="k">def</span> <span class="nf">_match_r_paren</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-4605"><a href="#L-4605"><span class="linenos">4605</span></a> <span class="k">if</span> <span class="ow">not</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">R_PAREN</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">):</span> -</span><span id="L-4606"><a href="#L-4606"><span class="linenos">4606</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting )"</span><span class="p">)</span> +</span><span id="L-4578"><a href="#L-4578"><span class="linenos">4578</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">token_type</span><span class="p">:</span> +</span><span id="L-4579"><a href="#L-4579"><span class="linenos">4579</span></a> <span class="k">if</span> <span class="n">advance</span><span class="p">:</span> +</span><span id="L-4580"><a href="#L-4580"><span class="linenos">4580</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-4581"><a href="#L-4581"><span class="linenos">4581</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add_comments</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-4582"><a href="#L-4582"><span class="linenos">4582</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="L-4583"><a href="#L-4583"><span class="linenos">4583</span></a> +</span><span id="L-4584"><a href="#L-4584"><span class="linenos">4584</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-4585"><a href="#L-4585"><span class="linenos">4585</span></a> +</span><span id="L-4586"><a href="#L-4586"><span class="linenos">4586</span></a> <span class="k">def</span> <span class="nf">_match_set</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">types</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> +</span><span id="L-4587"><a href="#L-4587"><span class="linenos">4587</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="L-4588"><a href="#L-4588"><span class="linenos">4588</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-4589"><a href="#L-4589"><span class="linenos">4589</span></a> +</span><span id="L-4590"><a href="#L-4590"><span class="linenos">4590</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="n">types</span><span class="p">:</span> +</span><span id="L-4591"><a href="#L-4591"><span class="linenos">4591</span></a> <span class="k">if</span> <span class="n">advance</span><span class="p">:</span> +</span><span id="L-4592"><a href="#L-4592"><span class="linenos">4592</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-4593"><a href="#L-4593"><span class="linenos">4593</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="L-4594"><a href="#L-4594"><span class="linenos">4594</span></a> +</span><span id="L-4595"><a href="#L-4595"><span class="linenos">4595</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-4596"><a href="#L-4596"><span class="linenos">4596</span></a> +</span><span id="L-4597"><a href="#L-4597"><span class="linenos">4597</span></a> <span class="k">def</span> <span class="nf">_match_pair</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type_a</span><span class="p">,</span> <span class="n">token_type_b</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> +</span><span id="L-4598"><a href="#L-4598"><span class="linenos">4598</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> +</span><span id="L-4599"><a href="#L-4599"><span class="linenos">4599</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-4600"><a href="#L-4600"><span class="linenos">4600</span></a> +</span><span id="L-4601"><a href="#L-4601"><span class="linenos">4601</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">token_type_a</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">token_type_b</span><span class="p">:</span> +</span><span id="L-4602"><a href="#L-4602"><span class="linenos">4602</span></a> <span class="k">if</span> <span class="n">advance</span><span class="p">:</span> +</span><span id="L-4603"><a href="#L-4603"><span class="linenos">4603</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> +</span><span id="L-4604"><a href="#L-4604"><span class="linenos">4604</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="L-4605"><a href="#L-4605"><span class="linenos">4605</span></a> +</span><span id="L-4606"><a href="#L-4606"><span class="linenos">4606</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="L-4607"><a href="#L-4607"><span class="linenos">4607</span></a> -</span><span id="L-4608"><a href="#L-4608"><span class="linenos">4608</span></a> <span class="k">def</span> <span class="nf">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">texts</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> -</span><span id="L-4609"><a href="#L-4609"><span class="linenos">4609</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="ow">in</span> <span class="n">texts</span><span class="p">:</span> -</span><span id="L-4610"><a href="#L-4610"><span class="linenos">4610</span></a> <span class="k">if</span> <span class="n">advance</span><span class="p">:</span> -</span><span id="L-4611"><a href="#L-4611"><span class="linenos">4611</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-4612"><a href="#L-4612"><span class="linenos">4612</span></a> <span class="k">return</span> <span class="kc">True</span> -</span><span id="L-4613"><a href="#L-4613"><span class="linenos">4613</span></a> <span class="k">return</span> <span class="kc">False</span> -</span><span id="L-4614"><a href="#L-4614"><span class="linenos">4614</span></a> -</span><span id="L-4615"><a href="#L-4615"><span class="linenos">4615</span></a> <span class="k">def</span> <span class="nf">_match_text_seq</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">texts</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> -</span><span id="L-4616"><a href="#L-4616"><span class="linenos">4616</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="L-4617"><a href="#L-4617"><span class="linenos">4617</span></a> <span class="k">for</span> <span class="n">text</span> <span class="ow">in</span> <span class="n">texts</span><span class="p">:</span> -</span><span id="L-4618"><a href="#L-4618"><span class="linenos">4618</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="n">text</span><span class="p">:</span> +</span><span id="L-4608"><a href="#L-4608"><span class="linenos">4608</span></a> <span class="k">def</span> <span class="nf">_match_l_paren</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-4609"><a href="#L-4609"><span class="linenos">4609</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">):</span> +</span><span id="L-4610"><a href="#L-4610"><span class="linenos">4610</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting ("</span><span class="p">)</span> +</span><span id="L-4611"><a href="#L-4611"><span class="linenos">4611</span></a> +</span><span id="L-4612"><a href="#L-4612"><span class="linenos">4612</span></a> <span class="k">def</span> <span class="nf">_match_r_paren</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-4613"><a href="#L-4613"><span class="linenos">4613</span></a> <span class="k">if</span> <span class="ow">not</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">R_PAREN</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">):</span> +</span><span id="L-4614"><a href="#L-4614"><span class="linenos">4614</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting )"</span><span class="p">)</span> +</span><span id="L-4615"><a href="#L-4615"><span class="linenos">4615</span></a> +</span><span id="L-4616"><a href="#L-4616"><span class="linenos">4616</span></a> <span class="k">def</span> <span class="nf">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">texts</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> +</span><span id="L-4617"><a href="#L-4617"><span class="linenos">4617</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="ow">in</span> <span class="n">texts</span><span class="p">:</span> +</span><span id="L-4618"><a href="#L-4618"><span class="linenos">4618</span></a> <span class="k">if</span> <span class="n">advance</span><span class="p">:</span> </span><span id="L-4619"><a href="#L-4619"><span class="linenos">4619</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-4620"><a href="#L-4620"><span class="linenos">4620</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-4621"><a href="#L-4621"><span class="linenos">4621</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-4622"><a href="#L-4622"><span class="linenos">4622</span></a> <span class="k">return</span> <span class="kc">False</span> -</span><span id="L-4623"><a href="#L-4623"><span class="linenos">4623</span></a> -</span><span id="L-4624"><a href="#L-4624"><span class="linenos">4624</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">advance</span><span class="p">:</span> -</span><span id="L-4625"><a href="#L-4625"><span class="linenos">4625</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="L-4626"><a href="#L-4626"><span class="linenos">4626</span></a> -</span><span id="L-4627"><a href="#L-4627"><span class="linenos">4627</span></a> <span class="k">return</span> <span class="kc">True</span> -</span><span id="L-4628"><a href="#L-4628"><span class="linenos">4628</span></a> -</span><span id="L-4629"><a href="#L-4629"><span class="linenos">4629</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="L-4630"><a href="#L-4630"><span class="linenos">4630</span></a> <span class="k">def</span> <span class="nf">_replace_columns_with_dots</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="L-4631"><a href="#L-4631"><span class="linenos">4631</span></a> <span class="o">...</span> -</span><span id="L-4632"><a href="#L-4632"><span class="linenos">4632</span></a> -</span><span id="L-4633"><a href="#L-4633"><span class="linenos">4633</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="L-4634"><a href="#L-4634"><span class="linenos">4634</span></a> <span class="k">def</span> <span class="nf">_replace_columns_with_dots</span><span class="p">(</span> -</span><span id="L-4635"><a href="#L-4635"><span class="linenos">4635</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><span id="L-4636"><a href="#L-4636"><span class="linenos">4636</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-4637"><a href="#L-4637"><span class="linenos">4637</span></a> <span class="o">...</span> -</span><span id="L-4638"><a href="#L-4638"><span class="linenos">4638</span></a> -</span><span id="L-4639"><a href="#L-4639"><span class="linenos">4639</span></a> <span class="k">def</span> <span class="nf">_replace_columns_with_dots</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">):</span> -</span><span id="L-4640"><a href="#L-4640"><span class="linenos">4640</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">Dot</span><span class="p">):</span> -</span><span id="L-4641"><a href="#L-4641"><span class="linenos">4641</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">replace_children</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_replace_columns_with_dots</span><span class="p">)</span> -</span><span id="L-4642"><a href="#L-4642"><span class="linenos">4642</span></a> <span class="k">elif</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">Column</span><span class="p">):</span> -</span><span id="L-4643"><a href="#L-4643"><span class="linenos">4643</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">replace_children</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_replace_columns_with_dots</span><span class="p">)</span> -</span><span id="L-4644"><a href="#L-4644"><span class="linenos">4644</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"table"</span><span class="p">)</span> -</span><span id="L-4645"><a href="#L-4645"><span class="linenos">4645</span></a> <span class="n">this</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-4646"><a href="#L-4646"><span class="linenos">4646</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">Dot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-4647"><a href="#L-4647"><span class="linenos">4647</span></a> <span class="k">if</span> <span class="n">table</span> -</span><span id="L-4648"><a href="#L-4648"><span class="linenos">4648</span></a> <span class="k">else</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">Var</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> -</span><span id="L-4649"><a href="#L-4649"><span class="linenos">4649</span></a> <span class="p">)</span> -</span><span id="L-4650"><a href="#L-4650"><span class="linenos">4650</span></a> <span class="k">elif</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">Identifier</span><span class="p">):</span> -</span><span id="L-4651"><a href="#L-4651"><span class="linenos">4651</span></a> <span class="n">this</span> <span class="o">=</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">Var</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> -</span><span id="L-4652"><a href="#L-4652"><span class="linenos">4652</span></a> -</span><span id="L-4653"><a href="#L-4653"><span class="linenos">4653</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="L-4654"><a href="#L-4654"><span class="linenos">4654</span></a> -</span><span id="L-4655"><a href="#L-4655"><span class="linenos">4655</span></a> <span class="k">def</span> <span class="nf">_replace_lambda</span><span class="p">(</span> -</span><span id="L-4656"><a href="#L-4656"><span class="linenos">4656</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">node</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="n">lambda_variables</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> -</span><span id="L-4657"><a href="#L-4657"><span class="linenos">4657</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-4658"><a href="#L-4658"><span class="linenos">4658</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">node</span><span class="p">:</span> -</span><span id="L-4659"><a href="#L-4659"><span class="linenos">4659</span></a> <span class="k">return</span> <span class="n">node</span> +</span><span id="L-4620"><a href="#L-4620"><span class="linenos">4620</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="L-4621"><a href="#L-4621"><span class="linenos">4621</span></a> <span class="k">return</span> <span class="kc">False</span> +</span><span id="L-4622"><a href="#L-4622"><span class="linenos">4622</span></a> +</span><span id="L-4623"><a href="#L-4623"><span class="linenos">4623</span></a> <span class="k">def</span> <span class="nf">_match_text_seq</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">texts</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> +</span><span id="L-4624"><a href="#L-4624"><span class="linenos">4624</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="L-4625"><a href="#L-4625"><span class="linenos">4625</span></a> <span class="k">for</span> <span class="n">text</span> <span class="ow">in</span> <span class="n">texts</span><span class="p">:</span> +</span><span id="L-4626"><a href="#L-4626"><span class="linenos">4626</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="n">text</span><span class="p">:</span> +</span><span id="L-4627"><a href="#L-4627"><span class="linenos">4627</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-4628"><a href="#L-4628"><span class="linenos">4628</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-4629"><a href="#L-4629"><span class="linenos">4629</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-4630"><a href="#L-4630"><span class="linenos">4630</span></a> <span class="k">return</span> <span class="kc">False</span> +</span><span id="L-4631"><a href="#L-4631"><span class="linenos">4631</span></a> +</span><span id="L-4632"><a href="#L-4632"><span class="linenos">4632</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">advance</span><span class="p">:</span> +</span><span id="L-4633"><a href="#L-4633"><span class="linenos">4633</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="L-4634"><a href="#L-4634"><span class="linenos">4634</span></a> +</span><span id="L-4635"><a href="#L-4635"><span class="linenos">4635</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="L-4636"><a href="#L-4636"><span class="linenos">4636</span></a> +</span><span id="L-4637"><a href="#L-4637"><span class="linenos">4637</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> +</span><span id="L-4638"><a href="#L-4638"><span class="linenos">4638</span></a> <span class="k">def</span> <span class="nf">_replace_columns_with_dots</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="L-4639"><a href="#L-4639"><span class="linenos">4639</span></a> <span class="o">...</span> +</span><span id="L-4640"><a href="#L-4640"><span class="linenos">4640</span></a> +</span><span id="L-4641"><a href="#L-4641"><span class="linenos">4641</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> +</span><span id="L-4642"><a href="#L-4642"><span class="linenos">4642</span></a> <span class="k">def</span> <span class="nf">_replace_columns_with_dots</span><span class="p">(</span> +</span><span id="L-4643"><a href="#L-4643"><span class="linenos">4643</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><span id="L-4644"><a href="#L-4644"><span class="linenos">4644</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-4645"><a href="#L-4645"><span class="linenos">4645</span></a> <span class="o">...</span> +</span><span id="L-4646"><a href="#L-4646"><span class="linenos">4646</span></a> +</span><span id="L-4647"><a href="#L-4647"><span class="linenos">4647</span></a> <span class="k">def</span> <span class="nf">_replace_columns_with_dots</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">):</span> +</span><span id="L-4648"><a href="#L-4648"><span class="linenos">4648</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">Dot</span><span class="p">):</span> +</span><span id="L-4649"><a href="#L-4649"><span class="linenos">4649</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">replace_children</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_replace_columns_with_dots</span><span class="p">)</span> +</span><span id="L-4650"><a href="#L-4650"><span class="linenos">4650</span></a> <span class="k">elif</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">Column</span><span class="p">):</span> +</span><span id="L-4651"><a href="#L-4651"><span class="linenos">4651</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">replace_children</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_replace_columns_with_dots</span><span class="p">)</span> +</span><span id="L-4652"><a href="#L-4652"><span class="linenos">4652</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"table"</span><span class="p">)</span> +</span><span id="L-4653"><a href="#L-4653"><span class="linenos">4653</span></a> <span class="n">this</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-4654"><a href="#L-4654"><span class="linenos">4654</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">Dot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-4655"><a href="#L-4655"><span class="linenos">4655</span></a> <span class="k">if</span> <span class="n">table</span> +</span><span id="L-4656"><a href="#L-4656"><span class="linenos">4656</span></a> <span class="k">else</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">Var</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> +</span><span id="L-4657"><a href="#L-4657"><span class="linenos">4657</span></a> <span class="p">)</span> +</span><span id="L-4658"><a href="#L-4658"><span class="linenos">4658</span></a> <span class="k">elif</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">Identifier</span><span class="p">):</span> +</span><span id="L-4659"><a href="#L-4659"><span class="linenos">4659</span></a> <span class="n">this</span> <span class="o">=</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">Var</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> </span><span id="L-4660"><a href="#L-4660"><span class="linenos">4660</span></a> -</span><span id="L-4661"><a href="#L-4661"><span class="linenos">4661</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">node</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> -</span><span id="L-4662"><a href="#L-4662"><span class="linenos">4662</span></a> <span class="k">if</span> <span class="n">column</span><span class="o">.</span><span class="n">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">name</span> <span class="ow">in</span> <span class="n">lambda_variables</span><span class="p">:</span> -</span><span id="L-4663"><a href="#L-4663"><span class="linenos">4663</span></a> <span class="n">dot_or_id</span> <span class="o">=</span> <span class="n">column</span><span class="o">.</span><span class="n">to_dot</span><span class="p">()</span> <span class="k">if</span> <span class="n">column</span><span class="o">.</span><span class="n">table</span> <span class="k">else</span> <span class="n">column</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-4664"><a href="#L-4664"><span class="linenos">4664</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">column</span><span class="o">.</span><span class="n">parent</span> -</span><span id="L-4665"><a href="#L-4665"><span class="linenos">4665</span></a> -</span><span id="L-4666"><a href="#L-4666"><span class="linenos">4666</span></a> <span class="k">while</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">):</span> -</span><span id="L-4667"><a href="#L-4667"><span class="linenos">4667</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">parent</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">Dot</span><span class="p">):</span> -</span><span id="L-4668"><a href="#L-4668"><span class="linenos">4668</span></a> <span class="n">parent</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">dot_or_id</span><span class="p">)</span> -</span><span id="L-4669"><a href="#L-4669"><span class="linenos">4669</span></a> <span class="k">break</span> -</span><span id="L-4670"><a href="#L-4670"><span class="linenos">4670</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">parent</span><span class="o">.</span><span class="n">parent</span> -</span><span id="L-4671"><a href="#L-4671"><span class="linenos">4671</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-4672"><a href="#L-4672"><span class="linenos">4672</span></a> <span class="k">if</span> <span class="n">column</span> <span class="ow">is</span> <span class="n">node</span><span class="p">:</span> -</span><span id="L-4673"><a href="#L-4673"><span class="linenos">4673</span></a> <span class="n">node</span> <span class="o">=</span> <span class="n">dot_or_id</span> -</span><span id="L-4674"><a href="#L-4674"><span class="linenos">4674</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-4675"><a href="#L-4675"><span class="linenos">4675</span></a> <span class="n">column</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">dot_or_id</span><span class="p">)</span> -</span><span id="L-4676"><a href="#L-4676"><span class="linenos">4676</span></a> <span class="k">return</span> <span class="n">node</span> +</span><span id="L-4661"><a href="#L-4661"><span class="linenos">4661</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="L-4662"><a href="#L-4662"><span class="linenos">4662</span></a> +</span><span id="L-4663"><a href="#L-4663"><span class="linenos">4663</span></a> <span class="k">def</span> <span class="nf">_replace_lambda</span><span class="p">(</span> +</span><span id="L-4664"><a href="#L-4664"><span class="linenos">4664</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">node</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="n">lambda_variables</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> +</span><span id="L-4665"><a href="#L-4665"><span class="linenos">4665</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-4666"><a href="#L-4666"><span class="linenos">4666</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">node</span><span class="p">:</span> +</span><span id="L-4667"><a href="#L-4667"><span class="linenos">4667</span></a> <span class="k">return</span> <span class="n">node</span> +</span><span id="L-4668"><a href="#L-4668"><span class="linenos">4668</span></a> +</span><span id="L-4669"><a href="#L-4669"><span class="linenos">4669</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">node</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> +</span><span id="L-4670"><a href="#L-4670"><span class="linenos">4670</span></a> <span class="k">if</span> <span class="n">column</span><span class="o">.</span><span class="n">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">name</span> <span class="ow">in</span> <span class="n">lambda_variables</span><span class="p">:</span> +</span><span id="L-4671"><a href="#L-4671"><span class="linenos">4671</span></a> <span class="n">dot_or_id</span> <span class="o">=</span> <span class="n">column</span><span class="o">.</span><span class="n">to_dot</span><span class="p">()</span> <span class="k">if</span> <span class="n">column</span><span class="o">.</span><span class="n">table</span> <span class="k">else</span> <span class="n">column</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-4672"><a href="#L-4672"><span class="linenos">4672</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">column</span><span class="o">.</span><span class="n">parent</span> +</span><span id="L-4673"><a href="#L-4673"><span class="linenos">4673</span></a> +</span><span id="L-4674"><a href="#L-4674"><span class="linenos">4674</span></a> <span class="k">while</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">):</span> +</span><span id="L-4675"><a href="#L-4675"><span class="linenos">4675</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">parent</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">Dot</span><span class="p">):</span> +</span><span id="L-4676"><a href="#L-4676"><span class="linenos">4676</span></a> <span class="n">parent</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">dot_or_id</span><span class="p">)</span> +</span><span id="L-4677"><a href="#L-4677"><span class="linenos">4677</span></a> <span class="k">break</span> +</span><span id="L-4678"><a href="#L-4678"><span class="linenos">4678</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">parent</span><span class="o">.</span><span class="n">parent</span> +</span><span id="L-4679"><a href="#L-4679"><span class="linenos">4679</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-4680"><a href="#L-4680"><span class="linenos">4680</span></a> <span class="k">if</span> <span class="n">column</span> <span class="ow">is</span> <span class="n">node</span><span class="p">:</span> +</span><span id="L-4681"><a href="#L-4681"><span class="linenos">4681</span></a> <span class="n">node</span> <span class="o">=</span> <span class="n">dot_or_id</span> +</span><span id="L-4682"><a href="#L-4682"><span class="linenos">4682</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-4683"><a href="#L-4683"><span class="linenos">4683</span></a> <span class="n">column</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">dot_or_id</span><span class="p">)</span> +</span><span id="L-4684"><a href="#L-4684"><span class="linenos">4684</span></a> <span class="k">return</span> <span class="n">node</span> </span></pre></div> @@ -5266,7 +5274,7 @@ </span><span id="Parser-466"><a href="#Parser-466"><span class="linenos"> 466</span></a> <span class="p">}</span> </span><span id="Parser-467"><a href="#Parser-467"><span class="linenos"> 467</span></a> </span><span id="Parser-468"><a href="#Parser-468"><span class="linenos"> 468</span></a> <span class="n">EXPRESSION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Parser-469"><a href="#Parser-469"><span class="linenos"> 469</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">,</span> <span class="s2">"CLUSTER"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">),</span> +</span><span id="Parser-469"><a href="#Parser-469"><span class="linenos"> 469</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cluster</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Cluster</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CLUSTER_BY</span><span class="p">),</span> </span><span id="Parser-470"><a href="#Parser-470"><span class="linenos"> 470</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Column</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_column</span><span class="p">(),</span> </span><span id="Parser-471"><a href="#Parser-471"><span class="linenos"> 471</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Condition</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_conjunction</span><span class="p">(),</span> </span><span id="Parser-472"><a href="#Parser-472"><span class="linenos"> 472</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</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_types</span><span class="p">(),</span> @@ -5285,7 +5293,7 @@ </span><span id="Parser-485"><a href="#Parser-485"><span class="linenos"> 485</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</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_properties</span><span class="p">(),</span> </span><span id="Parser-486"><a href="#Parser-486"><span class="linenos"> 486</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Qualify</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_qualify</span><span class="p">(),</span> </span><span id="Parser-487"><a href="#Parser-487"><span class="linenos"> 487</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Returning</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_returning</span><span class="p">(),</span> -</span><span id="Parser-488"><a href="#Parser-488"><span class="linenos"> 488</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Sort</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">,</span> <span class="s2">"SORT"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">),</span> +</span><span id="Parser-488"><a href="#Parser-488"><span class="linenos"> 488</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Sort</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_sort</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Sort</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SORT_BY</span><span class="p">),</span> </span><span id="Parser-489"><a href="#Parser-489"><span class="linenos"> 489</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Table</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_table_parts</span><span class="p">(),</span> </span><span id="Parser-490"><a href="#Parser-490"><span class="linenos"> 490</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableAlias</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_table_alias</span><span class="p">(),</span> </span><span id="Parser-491"><a href="#Parser-491"><span class="linenos"> 491</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Where</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_where</span><span class="p">(),</span> @@ -5385,4096 +5393,4104 @@ </span><span id="Parser-585"><a href="#Parser-585"><span class="linenos"> 585</span></a> <span class="s2">"BLOCKCOMPRESSION"</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_blockcompression</span><span class="p">(),</span> </span><span id="Parser-586"><a href="#Parser-586"><span class="linenos"> 586</span></a> <span class="s2">"CHARACTER SET"</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_character_set</span><span class="p">(),</span> </span><span id="Parser-587"><a href="#Parser-587"><span class="linenos"> 587</span></a> <span class="s2">"CHECKSUM"</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_checksum</span><span class="p">(),</span> -</span><span id="Parser-588"><a href="#Parser-588"><span class="linenos"> 588</span></a> <span class="s2">"CLUSTER"</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_cluster</span><span class="p">(),</span> +</span><span id="Parser-588"><a href="#Parser-588"><span class="linenos"> 588</span></a> <span class="s2">"CLUSTER BY"</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_cluster</span><span class="p">(),</span> </span><span id="Parser-589"><a href="#Parser-589"><span class="linenos"> 589</span></a> <span class="s2">"COLLATE"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">CollateProperty</span><span class="p">),</span> </span><span id="Parser-590"><a href="#Parser-590"><span class="linenos"> 590</span></a> <span class="s2">"COMMENT"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">SchemaCommentProperty</span><span class="p">),</span> -</span><span id="Parser-591"><a href="#Parser-591"><span class="linenos"> 591</span></a> <span class="s2">"DATABLOCKSIZE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_datablocksize</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> -</span><span id="Parser-592"><a href="#Parser-592"><span class="linenos"> 592</span></a> <span class="s2">"DEFINER"</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_definer</span><span class="p">(),</span> -</span><span id="Parser-593"><a href="#Parser-593"><span class="linenos"> 593</span></a> <span class="s2">"DETERMINISTIC"</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">expression</span><span class="p">(</span> -</span><span id="Parser-594"><a href="#Parser-594"><span class="linenos"> 594</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"IMMUTABLE"</span><span class="p">)</span> -</span><span id="Parser-595"><a href="#Parser-595"><span class="linenos"> 595</span></a> <span class="p">),</span> -</span><span id="Parser-596"><a href="#Parser-596"><span class="linenos"> 596</span></a> <span class="s2">"DISTKEY"</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_distkey</span><span class="p">(),</span> -</span><span id="Parser-597"><a href="#Parser-597"><span class="linenos"> 597</span></a> <span class="s2">"DISTSTYLE"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">),</span> -</span><span id="Parser-598"><a href="#Parser-598"><span class="linenos"> 598</span></a> <span class="s2">"ENGINE"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">EngineProperty</span><span class="p">),</span> -</span><span id="Parser-599"><a href="#Parser-599"><span class="linenos"> 599</span></a> <span class="s2">"EXECUTE"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ExecuteAsProperty</span><span class="p">),</span> -</span><span id="Parser-600"><a href="#Parser-600"><span class="linenos"> 600</span></a> <span class="s2">"EXTERNAL"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ExternalProperty</span><span class="p">),</span> -</span><span id="Parser-601"><a href="#Parser-601"><span class="linenos"> 601</span></a> <span class="s2">"FALLBACK"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_fallback</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> -</span><span id="Parser-602"><a href="#Parser-602"><span class="linenos"> 602</span></a> <span class="s2">"FORMAT"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">),</span> -</span><span id="Parser-603"><a href="#Parser-603"><span class="linenos"> 603</span></a> <span class="s2">"FREESPACE"</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_freespace</span><span class="p">(),</span> -</span><span id="Parser-604"><a href="#Parser-604"><span class="linenos"> 604</span></a> <span class="s2">"IMMUTABLE"</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">expression</span><span class="p">(</span> -</span><span id="Parser-605"><a href="#Parser-605"><span class="linenos"> 605</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"IMMUTABLE"</span><span class="p">)</span> -</span><span id="Parser-606"><a href="#Parser-606"><span class="linenos"> 606</span></a> <span class="p">),</span> -</span><span id="Parser-607"><a href="#Parser-607"><span class="linenos"> 607</span></a> <span class="s2">"JOURNAL"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_journal</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> -</span><span id="Parser-608"><a href="#Parser-608"><span class="linenos"> 608</span></a> <span class="s2">"LANGUAGE"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LanguageProperty</span><span class="p">),</span> -</span><span id="Parser-609"><a href="#Parser-609"><span class="linenos"> 609</span></a> <span class="s2">"LAYOUT"</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_dict_property</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"LAYOUT"</span><span class="p">),</span> -</span><span id="Parser-610"><a href="#Parser-610"><span class="linenos"> 610</span></a> <span class="s2">"LIFETIME"</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_dict_range</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"LIFETIME"</span><span class="p">),</span> -</span><span id="Parser-611"><a href="#Parser-611"><span class="linenos"> 611</span></a> <span class="s2">"LIKE"</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_create_like</span><span class="p">(),</span> -</span><span id="Parser-612"><a href="#Parser-612"><span class="linenos"> 612</span></a> <span class="s2">"LOCATION"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">),</span> -</span><span id="Parser-613"><a href="#Parser-613"><span class="linenos"> 613</span></a> <span class="s2">"LOCK"</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_locking</span><span class="p">(),</span> -</span><span id="Parser-614"><a href="#Parser-614"><span class="linenos"> 614</span></a> <span class="s2">"LOCKING"</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_locking</span><span class="p">(),</span> -</span><span id="Parser-615"><a href="#Parser-615"><span class="linenos"> 615</span></a> <span class="s2">"LOG"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_log</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> -</span><span id="Parser-616"><a href="#Parser-616"><span class="linenos"> 616</span></a> <span class="s2">"MATERIALIZED"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">MaterializedProperty</span><span class="p">),</span> -</span><span id="Parser-617"><a href="#Parser-617"><span class="linenos"> 617</span></a> <span class="s2">"MERGEBLOCKRATIO"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_mergeblockratio</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> -</span><span id="Parser-618"><a href="#Parser-618"><span class="linenos"> 618</span></a> <span class="s2">"MULTISET"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">,</span> <span class="n">multi</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="Parser-619"><a href="#Parser-619"><span class="linenos"> 619</span></a> <span class="s2">"NO"</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_no_property</span><span class="p">(),</span> -</span><span id="Parser-620"><a href="#Parser-620"><span class="linenos"> 620</span></a> <span class="s2">"ON"</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_on_property</span><span class="p">(),</span> -</span><span id="Parser-621"><a href="#Parser-621"><span class="linenos"> 621</span></a> <span class="s2">"ORDER BY"</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_order</span><span class="p">(</span><span class="n">skip_order_token</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="Parser-622"><a href="#Parser-622"><span class="linenos"> 622</span></a> <span class="s2">"PARTITION BY"</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_partitioned_by</span><span class="p">(),</span> -</span><span id="Parser-623"><a href="#Parser-623"><span class="linenos"> 623</span></a> <span class="s2">"PARTITIONED BY"</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_partitioned_by</span><span class="p">(),</span> -</span><span id="Parser-624"><a href="#Parser-624"><span class="linenos"> 624</span></a> <span class="s2">"PARTITIONED_BY"</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_partitioned_by</span><span class="p">(),</span> -</span><span id="Parser-625"><a href="#Parser-625"><span class="linenos"> 625</span></a> <span class="s2">"PRIMARY KEY"</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_primary_key</span><span class="p">(</span><span class="n">in_props</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="Parser-626"><a href="#Parser-626"><span class="linenos"> 626</span></a> <span class="s2">"RANGE"</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_dict_range</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"RANGE"</span><span class="p">),</span> -</span><span id="Parser-627"><a href="#Parser-627"><span class="linenos"> 627</span></a> <span class="s2">"RETURNS"</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_returns</span><span class="p">(),</span> -</span><span id="Parser-628"><a href="#Parser-628"><span class="linenos"> 628</span></a> <span class="s2">"ROW"</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_row</span><span class="p">(),</span> -</span><span id="Parser-629"><a href="#Parser-629"><span class="linenos"> 629</span></a> <span class="s2">"ROW_FORMAT"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">RowFormatProperty</span><span class="p">),</span> -</span><span id="Parser-630"><a href="#Parser-630"><span class="linenos"> 630</span></a> <span class="s2">"SET"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">,</span> <span class="n">multi</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="Parser-631"><a href="#Parser-631"><span class="linenos"> 631</span></a> <span class="s2">"SETTINGS"</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">expression</span><span class="p">(</span> -</span><span id="Parser-632"><a href="#Parser-632"><span class="linenos"> 632</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SettingsProperty</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_item</span><span class="p">)</span> -</span><span id="Parser-633"><a href="#Parser-633"><span class="linenos"> 633</span></a> <span class="p">),</span> -</span><span id="Parser-634"><a href="#Parser-634"><span class="linenos"> 634</span></a> <span class="s2">"SORTKEY"</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_sortkey</span><span class="p">(),</span> -</span><span id="Parser-635"><a href="#Parser-635"><span class="linenos"> 635</span></a> <span class="s2">"SOURCE"</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_dict_property</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"SOURCE"</span><span class="p">),</span> -</span><span id="Parser-636"><a href="#Parser-636"><span class="linenos"> 636</span></a> <span class="s2">"STABLE"</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">expression</span><span class="p">(</span> -</span><span id="Parser-637"><a href="#Parser-637"><span class="linenos"> 637</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"STABLE"</span><span class="p">)</span> -</span><span id="Parser-638"><a href="#Parser-638"><span class="linenos"> 638</span></a> <span class="p">),</span> -</span><span id="Parser-639"><a href="#Parser-639"><span class="linenos"> 639</span></a> <span class="s2">"STORED"</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_stored</span><span class="p">(),</span> -</span><span id="Parser-640"><a href="#Parser-640"><span class="linenos"> 640</span></a> <span class="s2">"TBLPROPERTIES"</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_wrapped_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_property</span><span class="p">),</span> -</span><span id="Parser-641"><a href="#Parser-641"><span class="linenos"> 641</span></a> <span class="s2">"TEMP"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">),</span> -</span><span id="Parser-642"><a href="#Parser-642"><span class="linenos"> 642</span></a> <span class="s2">"TEMPORARY"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">),</span> -</span><span id="Parser-643"><a href="#Parser-643"><span class="linenos"> 643</span></a> <span class="s2">"TO"</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_to_table</span><span class="p">(),</span> -</span><span id="Parser-644"><a href="#Parser-644"><span class="linenos"> 644</span></a> <span class="s2">"TRANSIENT"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TransientProperty</span><span class="p">),</span> -</span><span id="Parser-645"><a href="#Parser-645"><span class="linenos"> 645</span></a> <span class="s2">"TTL"</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_ttl</span><span class="p">(),</span> -</span><span id="Parser-646"><a href="#Parser-646"><span class="linenos"> 646</span></a> <span class="s2">"USING"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">),</span> -</span><span id="Parser-647"><a href="#Parser-647"><span class="linenos"> 647</span></a> <span class="s2">"VOLATILE"</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_volatile_property</span><span class="p">(),</span> -</span><span id="Parser-648"><a href="#Parser-648"><span class="linenos"> 648</span></a> <span class="s2">"WITH"</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_with_property</span><span class="p">(),</span> -</span><span id="Parser-649"><a href="#Parser-649"><span class="linenos"> 649</span></a> <span class="p">}</span> -</span><span id="Parser-650"><a href="#Parser-650"><span class="linenos"> 650</span></a> -</span><span id="Parser-651"><a href="#Parser-651"><span class="linenos"> 651</span></a> <span class="n">CONSTRAINT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Parser-652"><a href="#Parser-652"><span class="linenos"> 652</span></a> <span class="s2">"AUTOINCREMENT"</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_auto_increment</span><span class="p">(),</span> -</span><span id="Parser-653"><a href="#Parser-653"><span class="linenos"> 653</span></a> <span class="s2">"AUTO_INCREMENT"</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_auto_increment</span><span class="p">(),</span> -</span><span id="Parser-654"><a href="#Parser-654"><span class="linenos"> 654</span></a> <span class="s2">"CASESPECIFIC"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">CaseSpecificColumnConstraint</span><span class="p">,</span> <span class="n">not_</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="Parser-655"><a href="#Parser-655"><span class="linenos"> 655</span></a> <span class="s2">"CHARACTER SET"</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">expression</span><span class="p">(</span> -</span><span id="Parser-656"><a href="#Parser-656"><span class="linenos"> 656</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetColumnConstraint</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_var_or_string</span><span class="p">()</span> -</span><span id="Parser-657"><a href="#Parser-657"><span class="linenos"> 657</span></a> <span class="p">),</span> -</span><span id="Parser-658"><a href="#Parser-658"><span class="linenos"> 658</span></a> <span class="s2">"CHECK"</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">expression</span><span class="p">(</span> -</span><span id="Parser-659"><a href="#Parser-659"><span class="linenos"> 659</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CheckColumnConstraint</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_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="Parser-660"><a href="#Parser-660"><span class="linenos"> 660</span></a> <span class="p">),</span> -</span><span id="Parser-661"><a href="#Parser-661"><span class="linenos"> 661</span></a> <span class="s2">"COLLATE"</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">expression</span><span class="p">(</span> -</span><span id="Parser-662"><a href="#Parser-662"><span class="linenos"> 662</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateColumnConstraint</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_var</span><span class="p">()</span> -</span><span id="Parser-663"><a href="#Parser-663"><span class="linenos"> 663</span></a> <span class="p">),</span> -</span><span id="Parser-664"><a href="#Parser-664"><span class="linenos"> 664</span></a> <span class="s2">"COMMENT"</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">expression</span><span class="p">(</span> -</span><span id="Parser-665"><a href="#Parser-665"><span class="linenos"> 665</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CommentColumnConstraint</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_string</span><span class="p">()</span> -</span><span id="Parser-666"><a href="#Parser-666"><span class="linenos"> 666</span></a> <span class="p">),</span> -</span><span id="Parser-667"><a href="#Parser-667"><span class="linenos"> 667</span></a> <span class="s2">"COMPRESS"</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_compress</span><span class="p">(),</span> -</span><span id="Parser-668"><a href="#Parser-668"><span class="linenos"> 668</span></a> <span class="s2">"DEFAULT"</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">expression</span><span class="p">(</span> -</span><span id="Parser-669"><a href="#Parser-669"><span class="linenos"> 669</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DefaultColumnConstraint</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_bitwise</span><span class="p">()</span> -</span><span id="Parser-670"><a href="#Parser-670"><span class="linenos"> 670</span></a> <span class="p">),</span> -</span><span id="Parser-671"><a href="#Parser-671"><span class="linenos"> 671</span></a> <span class="s2">"ENCODE"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">EncodeColumnConstraint</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_var</span><span class="p">()),</span> -</span><span id="Parser-672"><a href="#Parser-672"><span class="linenos"> 672</span></a> <span class="s2">"FOREIGN KEY"</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_foreign_key</span><span class="p">(),</span> -</span><span id="Parser-673"><a href="#Parser-673"><span class="linenos"> 673</span></a> <span class="s2">"FORMAT"</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">expression</span><span class="p">(</span> -</span><span id="Parser-674"><a href="#Parser-674"><span class="linenos"> 674</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFormatColumnConstraint</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_var_or_string</span><span class="p">()</span> -</span><span id="Parser-675"><a href="#Parser-675"><span class="linenos"> 675</span></a> <span class="p">),</span> -</span><span id="Parser-676"><a href="#Parser-676"><span class="linenos"> 676</span></a> <span class="s2">"GENERATED"</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_generated_as_identity</span><span class="p">(),</span> -</span><span id="Parser-677"><a href="#Parser-677"><span class="linenos"> 677</span></a> <span class="s2">"IDENTITY"</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_auto_increment</span><span class="p">(),</span> -</span><span id="Parser-678"><a href="#Parser-678"><span class="linenos"> 678</span></a> <span class="s2">"INLINE"</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_inline</span><span class="p">(),</span> -</span><span id="Parser-679"><a href="#Parser-679"><span class="linenos"> 679</span></a> <span class="s2">"LIKE"</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_create_like</span><span class="p">(),</span> -</span><span id="Parser-680"><a href="#Parser-680"><span class="linenos"> 680</span></a> <span class="s2">"NOT"</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_not_constraint</span><span class="p">(),</span> -</span><span id="Parser-681"><a href="#Parser-681"><span class="linenos"> 681</span></a> <span class="s2">"NULL"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">NotNullColumnConstraint</span><span class="p">,</span> <span class="n">allow_null</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="Parser-682"><a href="#Parser-682"><span class="linenos"> 682</span></a> <span class="s2">"ON"</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">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">UPDATE</span><span class="p">)</span> -</span><span id="Parser-683"><a href="#Parser-683"><span class="linenos"> 683</span></a> <span class="ow">and</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">OnUpdateColumnConstraint</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_function</span><span class="p">()),</span> -</span><span id="Parser-684"><a href="#Parser-684"><span class="linenos"> 684</span></a> <span class="s2">"PATH"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">PathColumnConstraint</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_string</span><span class="p">()),</span> -</span><span id="Parser-685"><a href="#Parser-685"><span class="linenos"> 685</span></a> <span class="s2">"PRIMARY KEY"</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_primary_key</span><span class="p">(),</span> -</span><span id="Parser-686"><a href="#Parser-686"><span class="linenos"> 686</span></a> <span class="s2">"REFERENCES"</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_references</span><span class="p">(</span><span class="n">match</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="Parser-687"><a href="#Parser-687"><span class="linenos"> 687</span></a> <span class="s2">"TITLE"</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">expression</span><span class="p">(</span> -</span><span id="Parser-688"><a href="#Parser-688"><span class="linenos"> 688</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TitleColumnConstraint</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_var_or_string</span><span class="p">()</span> -</span><span id="Parser-689"><a href="#Parser-689"><span class="linenos"> 689</span></a> <span class="p">),</span> -</span><span id="Parser-690"><a href="#Parser-690"><span class="linenos"> 690</span></a> <span class="s2">"TTL"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()]),</span> -</span><span id="Parser-691"><a href="#Parser-691"><span class="linenos"> 691</span></a> <span class="s2">"UNIQUE"</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_unique</span><span class="p">(),</span> -</span><span id="Parser-692"><a href="#Parser-692"><span class="linenos"> 692</span></a> <span class="s2">"UPPERCASE"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">UppercaseColumnConstraint</span><span class="p">),</span> -</span><span id="Parser-693"><a href="#Parser-693"><span class="linenos"> 693</span></a> <span class="p">}</span> -</span><span id="Parser-694"><a href="#Parser-694"><span class="linenos"> 694</span></a> -</span><span id="Parser-695"><a href="#Parser-695"><span class="linenos"> 695</span></a> <span class="n">ALTER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Parser-696"><a href="#Parser-696"><span class="linenos"> 696</span></a> <span class="s2">"ADD"</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_alter_table_add</span><span class="p">(),</span> -</span><span id="Parser-697"><a href="#Parser-697"><span class="linenos"> 697</span></a> <span class="s2">"ALTER"</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_alter_table_alter</span><span class="p">(),</span> -</span><span id="Parser-698"><a href="#Parser-698"><span class="linenos"> 698</span></a> <span class="s2">"DELETE"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">,</span> <span class="n">where</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">()),</span> -</span><span id="Parser-699"><a href="#Parser-699"><span class="linenos"> 699</span></a> <span class="s2">"DROP"</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_alter_table_drop</span><span class="p">(),</span> -</span><span id="Parser-700"><a href="#Parser-700"><span class="linenos"> 700</span></a> <span class="s2">"RENAME"</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_alter_table_rename</span><span class="p">(),</span> -</span><span id="Parser-701"><a href="#Parser-701"><span class="linenos"> 701</span></a> <span class="p">}</span> -</span><span id="Parser-702"><a href="#Parser-702"><span class="linenos"> 702</span></a> -</span><span id="Parser-703"><a href="#Parser-703"><span class="linenos"> 703</span></a> <span class="n">SCHEMA_UNNAMED_CONSTRAINTS</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"CHECK"</span><span class="p">,</span> <span class="s2">"FOREIGN KEY"</span><span class="p">,</span> <span class="s2">"LIKE"</span><span class="p">,</span> <span class="s2">"PRIMARY KEY"</span><span class="p">,</span> <span class="s2">"UNIQUE"</span><span class="p">}</span> -</span><span id="Parser-704"><a href="#Parser-704"><span class="linenos"> 704</span></a> -</span><span id="Parser-705"><a href="#Parser-705"><span class="linenos"> 705</span></a> <span class="n">NO_PAREN_FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Parser-706"><a href="#Parser-706"><span class="linenos"> 706</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ANY</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()),</span> -</span><span id="Parser-707"><a href="#Parser-707"><span class="linenos"> 707</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">CASE</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_case</span><span class="p">(),</span> -</span><span id="Parser-708"><a href="#Parser-708"><span class="linenos"> 708</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">IF</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_if</span><span class="p">(),</span> -</span><span id="Parser-709"><a href="#Parser-709"><span class="linenos"> 709</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEXT_VALUE_FOR</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">expression</span><span class="p">(</span> -</span><span id="Parser-710"><a href="#Parser-710"><span class="linenos"> 710</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NextValueFor</span><span class="p">,</span> -</span><span id="Parser-711"><a href="#Parser-711"><span class="linenos"> 711</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">(),</span> -</span><span id="Parser-712"><a href="#Parser-712"><span class="linenos"> 712</span></a> <span class="n">order</span><span class="o">=</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">OVER</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">),</span> -</span><span id="Parser-713"><a href="#Parser-713"><span class="linenos"> 713</span></a> <span class="p">),</span> -</span><span id="Parser-714"><a href="#Parser-714"><span class="linenos"> 714</span></a> <span class="p">}</span> -</span><span id="Parser-715"><a href="#Parser-715"><span class="linenos"> 715</span></a> -</span><span id="Parser-716"><a href="#Parser-716"><span class="linenos"> 716</span></a> <span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"STRUCT"</span><span class="p">}</span> -</span><span id="Parser-717"><a href="#Parser-717"><span class="linenos"> 717</span></a> -</span><span id="Parser-718"><a href="#Parser-718"><span class="linenos"> 718</span></a> <span class="n">FUNCTION_PARSERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Parser-719"><a href="#Parser-719"><span class="linenos"> 719</span></a> <span class="s2">"CAST"</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_cast</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STRICT_CAST</span><span class="p">),</span> -</span><span id="Parser-720"><a href="#Parser-720"><span class="linenos"> 720</span></a> <span class="s2">"CONCAT"</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_concat</span><span class="p">(),</span> -</span><span id="Parser-721"><a href="#Parser-721"><span class="linenos"> 721</span></a> <span class="s2">"CONVERT"</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_convert</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STRICT_CAST</span><span class="p">),</span> -</span><span id="Parser-722"><a href="#Parser-722"><span class="linenos"> 722</span></a> <span class="s2">"DECODE"</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_decode</span><span class="p">(),</span> -</span><span id="Parser-723"><a href="#Parser-723"><span class="linenos"> 723</span></a> <span class="s2">"EXTRACT"</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_extract</span><span class="p">(),</span> -</span><span id="Parser-724"><a href="#Parser-724"><span class="linenos"> 724</span></a> <span class="s2">"JSON_OBJECT"</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_json_object</span><span class="p">(),</span> -</span><span id="Parser-725"><a href="#Parser-725"><span class="linenos"> 725</span></a> <span class="s2">"LOG"</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_logarithm</span><span class="p">(),</span> -</span><span id="Parser-726"><a href="#Parser-726"><span class="linenos"> 726</span></a> <span class="s2">"MATCH"</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_match_against</span><span class="p">(),</span> -</span><span id="Parser-727"><a href="#Parser-727"><span class="linenos"> 727</span></a> <span class="s2">"OPENJSON"</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_open_json</span><span class="p">(),</span> -</span><span id="Parser-728"><a href="#Parser-728"><span class="linenos"> 728</span></a> <span class="s2">"POSITION"</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_position</span><span class="p">(),</span> -</span><span id="Parser-729"><a href="#Parser-729"><span class="linenos"> 729</span></a> <span class="s2">"SAFE_CAST"</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_cast</span><span class="p">(</span><span class="kc">False</span><span class="p">),</span> -</span><span id="Parser-730"><a href="#Parser-730"><span class="linenos"> 730</span></a> <span class="s2">"STRING_AGG"</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_string_agg</span><span class="p">(),</span> -</span><span id="Parser-731"><a href="#Parser-731"><span class="linenos"> 731</span></a> <span class="s2">"SUBSTRING"</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_substring</span><span class="p">(),</span> -</span><span id="Parser-732"><a href="#Parser-732"><span class="linenos"> 732</span></a> <span class="s2">"TRIM"</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_trim</span><span class="p">(),</span> -</span><span id="Parser-733"><a href="#Parser-733"><span class="linenos"> 733</span></a> <span class="s2">"TRY_CAST"</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_cast</span><span class="p">(</span><span class="kc">False</span><span class="p">),</span> -</span><span id="Parser-734"><a href="#Parser-734"><span class="linenos"> 734</span></a> <span class="s2">"TRY_CONVERT"</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_convert</span><span class="p">(</span><span class="kc">False</span><span class="p">),</span> -</span><span id="Parser-735"><a href="#Parser-735"><span class="linenos"> 735</span></a> <span class="p">}</span> -</span><span id="Parser-736"><a href="#Parser-736"><span class="linenos"> 736</span></a> -</span><span id="Parser-737"><a href="#Parser-737"><span class="linenos"> 737</span></a> <span class="n">QUERY_MODIFIER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Parser-738"><a href="#Parser-738"><span class="linenos"> 738</span></a> <span class="s2">"joins"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="nb">list</span><span class="p">(</span><span class="nb">iter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_join</span><span class="p">,</span> <span class="kc">None</span><span class="p">)),</span> -</span><span id="Parser-739"><a href="#Parser-739"><span class="linenos"> 739</span></a> <span class="s2">"laterals"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="nb">list</span><span class="p">(</span><span class="nb">iter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_lateral</span><span class="p">,</span> <span class="kc">None</span><span class="p">)),</span> -</span><span id="Parser-740"><a href="#Parser-740"><span class="linenos"> 740</span></a> <span class="s2">"match"</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_match_recognize</span><span class="p">(),</span> -</span><span id="Parser-741"><a href="#Parser-741"><span class="linenos"> 741</span></a> <span class="s2">"where"</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_where</span><span class="p">(),</span> -</span><span id="Parser-742"><a href="#Parser-742"><span class="linenos"> 742</span></a> <span class="s2">"group"</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_group</span><span class="p">(),</span> -</span><span id="Parser-743"><a href="#Parser-743"><span class="linenos"> 743</span></a> <span class="s2">"having"</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_having</span><span class="p">(),</span> -</span><span id="Parser-744"><a href="#Parser-744"><span class="linenos"> 744</span></a> <span class="s2">"qualify"</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_qualify</span><span class="p">(),</span> -</span><span id="Parser-745"><a href="#Parser-745"><span class="linenos"> 745</span></a> <span class="s2">"windows"</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_window_clause</span><span class="p">(),</span> -</span><span id="Parser-746"><a href="#Parser-746"><span class="linenos"> 746</span></a> <span class="s2">"order"</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_order</span><span class="p">(),</span> -</span><span id="Parser-747"><a href="#Parser-747"><span class="linenos"> 747</span></a> <span class="s2">"limit"</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_limit</span><span class="p">(),</span> -</span><span id="Parser-748"><a href="#Parser-748"><span class="linenos"> 748</span></a> <span class="s2">"offset"</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_offset</span><span class="p">(),</span> -</span><span id="Parser-749"><a href="#Parser-749"><span class="linenos"> 749</span></a> <span class="s2">"locks"</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_locks</span><span class="p">(),</span> -</span><span id="Parser-750"><a href="#Parser-750"><span class="linenos"> 750</span></a> <span class="s2">"sample"</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_table_sample</span><span class="p">(</span><span class="n">as_modifier</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="Parser-751"><a href="#Parser-751"><span class="linenos"> 751</span></a> <span class="p">}</span> -</span><span id="Parser-752"><a href="#Parser-752"><span class="linenos"> 752</span></a> -</span><span id="Parser-753"><a href="#Parser-753"><span class="linenos"> 753</span></a> <span class="n">SET_PARSERS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Parser-754"><a href="#Parser-754"><span class="linenos"> 754</span></a> <span class="s2">"GLOBAL"</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_set_item_assignment</span><span class="p">(</span><span class="s2">"GLOBAL"</span><span class="p">),</span> -</span><span id="Parser-755"><a href="#Parser-755"><span class="linenos"> 755</span></a> <span class="s2">"LOCAL"</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_set_item_assignment</span><span class="p">(</span><span class="s2">"LOCAL"</span><span class="p">),</span> -</span><span id="Parser-756"><a href="#Parser-756"><span class="linenos"> 756</span></a> <span class="s2">"SESSION"</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_set_item_assignment</span><span class="p">(</span><span class="s2">"SESSION"</span><span class="p">),</span> -</span><span id="Parser-757"><a href="#Parser-757"><span class="linenos"> 757</span></a> <span class="s2">"TRANSACTION"</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_set_transaction</span><span class="p">(),</span> -</span><span id="Parser-758"><a href="#Parser-758"><span class="linenos"> 758</span></a> <span class="p">}</span> -</span><span id="Parser-759"><a href="#Parser-759"><span class="linenos"> 759</span></a> -</span><span id="Parser-760"><a href="#Parser-760"><span class="linenos"> 760</span></a> <span class="n">SHOW_PARSERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Parser-761"><a href="#Parser-761"><span class="linenos"> 761</span></a> -</span><span id="Parser-762"><a href="#Parser-762"><span class="linenos"> 762</span></a> <span class="n">TYPE_LITERAL_PARSERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Parser-763"><a href="#Parser-763"><span class="linenos"> 763</span></a> -</span><span id="Parser-764"><a href="#Parser-764"><span class="linenos"> 764</span></a> <span class="n">MODIFIABLES</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> -</span><span id="Parser-765"><a href="#Parser-765"><span class="linenos"> 765</span></a> -</span><span id="Parser-766"><a href="#Parser-766"><span class="linenos"> 766</span></a> <span class="n">DDL_SELECT_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SELECT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">}</span> -</span><span id="Parser-767"><a href="#Parser-767"><span class="linenos"> 767</span></a> -</span><span id="Parser-768"><a href="#Parser-768"><span class="linenos"> 768</span></a> <span class="n">PRE_VOLATILE_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">CREATE</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNIQUE</span><span class="p">}</span> -</span><span id="Parser-769"><a href="#Parser-769"><span class="linenos"> 769</span></a> -</span><span id="Parser-770"><a href="#Parser-770"><span class="linenos"> 770</span></a> <span class="n">TRANSACTION_KIND</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"DEFERRED"</span><span class="p">,</span> <span class="s2">"IMMEDIATE"</span><span class="p">,</span> <span class="s2">"EXCLUSIVE"</span><span class="p">}</span> -</span><span id="Parser-771"><a href="#Parser-771"><span class="linenos"> 771</span></a> <span class="n">TRANSACTION_CHARACTERISTICS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Parser-772"><a href="#Parser-772"><span class="linenos"> 772</span></a> <span class="s2">"ISOLATION LEVEL REPEATABLE READ"</span><span class="p">,</span> -</span><span id="Parser-773"><a href="#Parser-773"><span class="linenos"> 773</span></a> <span class="s2">"ISOLATION LEVEL READ COMMITTED"</span><span class="p">,</span> -</span><span id="Parser-774"><a href="#Parser-774"><span class="linenos"> 774</span></a> <span class="s2">"ISOLATION LEVEL READ UNCOMMITTED"</span><span class="p">,</span> -</span><span id="Parser-775"><a href="#Parser-775"><span class="linenos"> 775</span></a> <span class="s2">"ISOLATION LEVEL SERIALIZABLE"</span><span class="p">,</span> -</span><span id="Parser-776"><a href="#Parser-776"><span class="linenos"> 776</span></a> <span class="s2">"READ WRITE"</span><span class="p">,</span> -</span><span id="Parser-777"><a href="#Parser-777"><span class="linenos"> 777</span></a> <span class="s2">"READ ONLY"</span><span class="p">,</span> -</span><span id="Parser-778"><a href="#Parser-778"><span class="linenos"> 778</span></a> <span class="p">}</span> -</span><span id="Parser-779"><a href="#Parser-779"><span class="linenos"> 779</span></a> -</span><span id="Parser-780"><a href="#Parser-780"><span class="linenos"> 780</span></a> <span class="n">INSERT_ALTERNATIVES</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"ABORT"</span><span class="p">,</span> <span class="s2">"FAIL"</span><span class="p">,</span> <span class="s2">"IGNORE"</span><span class="p">,</span> <span class="s2">"REPLACE"</span><span class="p">,</span> <span class="s2">"ROLLBACK"</span><span class="p">}</span> -</span><span id="Parser-781"><a href="#Parser-781"><span class="linenos"> 781</span></a> -</span><span id="Parser-782"><a href="#Parser-782"><span class="linenos"> 782</span></a> <span class="n">CLONE_KINDS</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"OFFSET"</span><span class="p">,</span> <span class="s2">"STATEMENT"</span><span class="p">}</span> -</span><span id="Parser-783"><a href="#Parser-783"><span class="linenos"> 783</span></a> -</span><span id="Parser-784"><a href="#Parser-784"><span class="linenos"> 784</span></a> <span class="n">WINDOW_ALIAS_TOKENS</span> <span class="o">=</span> <span class="n">ID_VAR_TOKENS</span> <span class="o">-</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">}</span> -</span><span id="Parser-785"><a href="#Parser-785"><span class="linenos"> 785</span></a> <span class="n">WINDOW_BEFORE_PAREN_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">OVER</span><span class="p">}</span> -</span><span id="Parser-786"><a href="#Parser-786"><span class="linenos"> 786</span></a> <span class="n">WINDOW_SIDES</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"FOLLOWING"</span><span class="p">,</span> <span class="s2">"PRECEDING"</span><span class="p">}</span> -</span><span id="Parser-787"><a href="#Parser-787"><span class="linenos"> 787</span></a> -</span><span id="Parser-788"><a href="#Parser-788"><span class="linenos"> 788</span></a> <span class="n">ADD_CONSTRAINT_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">CONSTRAINT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PRIMARY_KEY</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FOREIGN_KEY</span><span class="p">}</span> -</span><span id="Parser-789"><a href="#Parser-789"><span class="linenos"> 789</span></a> -</span><span id="Parser-790"><a href="#Parser-790"><span class="linenos"> 790</span></a> <span class="n">STRICT_CAST</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Parser-791"><a href="#Parser-791"><span class="linenos"> 791</span></a> -</span><span id="Parser-792"><a href="#Parser-792"><span class="linenos"> 792</span></a> <span class="n">CONCAT_NULL_OUTPUTS_STRING</span> <span class="o">=</span> <span class="kc">False</span> <span class="c1"># A NULL arg in CONCAT yields NULL by default</span> -</span><span id="Parser-793"><a href="#Parser-793"><span class="linenos"> 793</span></a> -</span><span id="Parser-794"><a href="#Parser-794"><span class="linenos"> 794</span></a> <span class="n">CONVERT_TYPE_FIRST</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-795"><a href="#Parser-795"><span class="linenos"> 795</span></a> -</span><span id="Parser-796"><a href="#Parser-796"><span class="linenos"> 796</span></a> <span class="n">PREFIXED_PIVOT_COLUMNS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-797"><a href="#Parser-797"><span class="linenos"> 797</span></a> <span class="n">IDENTIFY_PIVOT_STRINGS</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-798"><a href="#Parser-798"><span class="linenos"> 798</span></a> -</span><span id="Parser-799"><a href="#Parser-799"><span class="linenos"> 799</span></a> <span class="n">LOG_BASE_FIRST</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Parser-800"><a href="#Parser-800"><span class="linenos"> 800</span></a> <span class="n">LOG_DEFAULTS_TO_LN</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-801"><a href="#Parser-801"><span class="linenos"> 801</span></a> -</span><span id="Parser-802"><a href="#Parser-802"><span class="linenos"> 802</span></a> <span class="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Parser-803"><a href="#Parser-803"><span class="linenos"> 803</span></a> <span class="s2">"error_level"</span><span class="p">,</span> -</span><span id="Parser-804"><a href="#Parser-804"><span class="linenos"> 804</span></a> <span class="s2">"error_message_context"</span><span class="p">,</span> -</span><span id="Parser-805"><a href="#Parser-805"><span class="linenos"> 805</span></a> <span class="s2">"max_errors"</span><span class="p">,</span> -</span><span id="Parser-806"><a href="#Parser-806"><span class="linenos"> 806</span></a> <span class="s2">"sql"</span><span class="p">,</span> -</span><span id="Parser-807"><a href="#Parser-807"><span class="linenos"> 807</span></a> <span class="s2">"errors"</span><span class="p">,</span> -</span><span id="Parser-808"><a href="#Parser-808"><span class="linenos"> 808</span></a> <span class="s2">"_tokens"</span><span class="p">,</span> -</span><span id="Parser-809"><a href="#Parser-809"><span class="linenos"> 809</span></a> <span class="s2">"_index"</span><span class="p">,</span> -</span><span id="Parser-810"><a href="#Parser-810"><span class="linenos"> 810</span></a> <span class="s2">"_curr"</span><span class="p">,</span> -</span><span id="Parser-811"><a href="#Parser-811"><span class="linenos"> 811</span></a> <span class="s2">"_next"</span><span class="p">,</span> -</span><span id="Parser-812"><a href="#Parser-812"><span class="linenos"> 812</span></a> <span class="s2">"_prev"</span><span class="p">,</span> -</span><span id="Parser-813"><a href="#Parser-813"><span class="linenos"> 813</span></a> <span class="s2">"_prev_comments"</span><span class="p">,</span> -</span><span id="Parser-814"><a href="#Parser-814"><span class="linenos"> 814</span></a> <span class="p">)</span> -</span><span id="Parser-815"><a href="#Parser-815"><span class="linenos"> 815</span></a> -</span><span id="Parser-816"><a href="#Parser-816"><span class="linenos"> 816</span></a> <span class="c1"># Autofilled</span> -</span><span id="Parser-817"><a href="#Parser-817"><span class="linenos"> 817</span></a> <span class="n">INDEX_OFFSET</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="Parser-818"><a href="#Parser-818"><span class="linenos"> 818</span></a> <span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-819"><a href="#Parser-819"><span class="linenos"> 819</span></a> <span class="n">ALIAS_POST_TABLESAMPLE</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-820"><a href="#Parser-820"><span class="linenos"> 820</span></a> <span class="n">STRICT_STRING_CONCAT</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-821"><a href="#Parser-821"><span class="linenos"> 821</span></a> <span class="n">NULL_ORDERING</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"nulls_are_small"</span> -</span><span id="Parser-822"><a href="#Parser-822"><span class="linenos"> 822</span></a> <span class="n">SHOW_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Parser-823"><a href="#Parser-823"><span class="linenos"> 823</span></a> <span class="n">SET_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Parser-824"><a href="#Parser-824"><span class="linenos"> 824</span></a> <span class="n">FORMAT_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Parser-825"><a href="#Parser-825"><span class="linenos"> 825</span></a> <span class="n">FORMAT_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Parser-826"><a href="#Parser-826"><span class="linenos"> 826</span></a> <span class="n">TIME_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Parser-827"><a href="#Parser-827"><span class="linenos"> 827</span></a> <span class="n">TIME_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Parser-828"><a href="#Parser-828"><span class="linenos"> 828</span></a> -</span><span id="Parser-829"><a href="#Parser-829"><span class="linenos"> 829</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> -</span><span id="Parser-830"><a href="#Parser-830"><span class="linenos"> 830</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Parser-831"><a href="#Parser-831"><span class="linenos"> 831</span></a> <span class="n">error_level</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">ErrorLevel</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Parser-832"><a href="#Parser-832"><span class="linenos"> 832</span></a> <span class="n">error_message_context</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">100</span><span class="p">,</span> -</span><span id="Parser-833"><a href="#Parser-833"><span class="linenos"> 833</span></a> <span class="n">max_errors</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> -</span><span id="Parser-834"><a href="#Parser-834"><span class="linenos"> 834</span></a> <span class="p">):</span> -</span><span id="Parser-835"><a href="#Parser-835"><span class="linenos"> 835</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">=</span> <span class="n">error_level</span> <span class="ow">or</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span> -</span><span id="Parser-836"><a href="#Parser-836"><span class="linenos"> 836</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">error_message_context</span> <span class="o">=</span> <span class="n">error_message_context</span> -</span><span id="Parser-837"><a href="#Parser-837"><span class="linenos"> 837</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_errors</span> <span class="o">=</span> <span class="n">max_errors</span> -</span><span id="Parser-838"><a href="#Parser-838"><span class="linenos"> 838</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> -</span><span id="Parser-839"><a href="#Parser-839"><span class="linenos"> 839</span></a> -</span><span id="Parser-840"><a href="#Parser-840"><span class="linenos"> 840</span></a> <span class="k">def</span> <span class="nf">reset</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Parser-841"><a href="#Parser-841"><span class="linenos"> 841</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Parser-842"><a href="#Parser-842"><span class="linenos"> 842</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-843"><a href="#Parser-843"><span class="linenos"> 843</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-844"><a href="#Parser-844"><span class="linenos"> 844</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="Parser-845"><a href="#Parser-845"><span class="linenos"> 845</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-846"><a href="#Parser-846"><span class="linenos"> 846</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-847"><a href="#Parser-847"><span class="linenos"> 847</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-848"><a href="#Parser-848"><span class="linenos"> 848</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-849"><a href="#Parser-849"><span class="linenos"> 849</span></a> -</span><span id="Parser-850"><a href="#Parser-850"><span class="linenos"> 850</span></a> <span class="k">def</span> <span class="nf">parse</span><span class="p">(</span> -</span><span id="Parser-851"><a href="#Parser-851"><span class="linenos"> 851</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">raw_tokens</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">Token</span><span class="p">],</span> <span class="n">sql</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><span id="Parser-852"><a href="#Parser-852"><span class="linenos"> 852</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Parser-853"><a href="#Parser-853"><span class="linenos"> 853</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Parser-854"><a href="#Parser-854"><span class="linenos"> 854</span></a><span class="sd"> Parses a list of tokens and returns a list of syntax trees, one tree</span> -</span><span id="Parser-855"><a href="#Parser-855"><span class="linenos"> 855</span></a><span class="sd"> per parsed SQL statement.</span> -</span><span id="Parser-856"><a href="#Parser-856"><span class="linenos"> 856</span></a> -</span><span id="Parser-857"><a href="#Parser-857"><span class="linenos"> 857</span></a><span class="sd"> Args:</span> -</span><span id="Parser-858"><a href="#Parser-858"><span class="linenos"> 858</span></a><span class="sd"> raw_tokens: The list of tokens.</span> -</span><span id="Parser-859"><a href="#Parser-859"><span class="linenos"> 859</span></a><span class="sd"> sql: The original SQL string, used to produce helpful debug messages.</span> -</span><span id="Parser-860"><a href="#Parser-860"><span class="linenos"> 860</span></a> -</span><span id="Parser-861"><a href="#Parser-861"><span class="linenos"> 861</span></a><span class="sd"> Returns:</span> -</span><span id="Parser-862"><a href="#Parser-862"><span class="linenos"> 862</span></a><span class="sd"> The list of the produced syntax trees.</span> -</span><span id="Parser-863"><a href="#Parser-863"><span class="linenos"> 863</span></a><span class="sd"> """</span> -</span><span id="Parser-864"><a href="#Parser-864"><span class="linenos"> 864</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse</span><span class="p">(</span> -</span><span id="Parser-865"><a href="#Parser-865"><span class="linenos"> 865</span></a> <span class="n">parse_method</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">,</span> <span class="n">raw_tokens</span><span class="o">=</span><span class="n">raw_tokens</span><span class="p">,</span> <span class="n">sql</span><span class="o">=</span><span class="n">sql</span> -</span><span id="Parser-866"><a href="#Parser-866"><span class="linenos"> 866</span></a> <span class="p">)</span> -</span><span id="Parser-867"><a href="#Parser-867"><span class="linenos"> 867</span></a> -</span><span id="Parser-868"><a href="#Parser-868"><span class="linenos"> 868</span></a> <span class="k">def</span> <span class="nf">parse_into</span><span class="p">(</span> -</span><span id="Parser-869"><a href="#Parser-869"><span class="linenos"> 869</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Parser-870"><a href="#Parser-870"><span class="linenos"> 870</span></a> <span class="n">expression_types</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IntoType</span><span class="p">,</span> -</span><span id="Parser-871"><a href="#Parser-871"><span class="linenos"> 871</span></a> <span class="n">raw_tokens</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">Token</span><span class="p">],</span> -</span><span id="Parser-872"><a href="#Parser-872"><span class="linenos"> 872</span></a> <span class="n">sql</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="Parser-873"><a href="#Parser-873"><span class="linenos"> 873</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Parser-874"><a href="#Parser-874"><span class="linenos"> 874</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Parser-875"><a href="#Parser-875"><span class="linenos"> 875</span></a><span class="sd"> Parses a list of tokens into a given Expression type. If a collection of Expression</span> -</span><span id="Parser-876"><a href="#Parser-876"><span class="linenos"> 876</span></a><span class="sd"> types is given instead, this method will try to parse the token list into each one</span> -</span><span id="Parser-877"><a href="#Parser-877"><span class="linenos"> 877</span></a><span class="sd"> of them, stopping at the first for which the parsing succeeds.</span> -</span><span id="Parser-878"><a href="#Parser-878"><span class="linenos"> 878</span></a> -</span><span id="Parser-879"><a href="#Parser-879"><span class="linenos"> 879</span></a><span class="sd"> Args:</span> -</span><span id="Parser-880"><a href="#Parser-880"><span class="linenos"> 880</span></a><span class="sd"> expression_types: The expression type(s) to try and parse the token list into.</span> -</span><span id="Parser-881"><a href="#Parser-881"><span class="linenos"> 881</span></a><span class="sd"> raw_tokens: The list of tokens.</span> -</span><span id="Parser-882"><a href="#Parser-882"><span class="linenos"> 882</span></a><span class="sd"> sql: The original SQL string, used to produce helpful debug messages.</span> -</span><span id="Parser-883"><a href="#Parser-883"><span class="linenos"> 883</span></a> -</span><span id="Parser-884"><a href="#Parser-884"><span class="linenos"> 884</span></a><span class="sd"> Returns:</span> -</span><span id="Parser-885"><a href="#Parser-885"><span class="linenos"> 885</span></a><span class="sd"> The target Expression.</span> -</span><span id="Parser-886"><a href="#Parser-886"><span class="linenos"> 886</span></a><span class="sd"> """</span> -</span><span id="Parser-887"><a href="#Parser-887"><span class="linenos"> 887</span></a> <span class="n">errors</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-888"><a href="#Parser-888"><span class="linenos"> 888</span></a> <span class="k">for</span> <span class="n">expression_type</span> <span class="ow">in</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">expression_types</span><span class="p">):</span> -</span><span id="Parser-889"><a href="#Parser-889"><span class="linenos"> 889</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPRESSION_PARSERS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression_type</span><span class="p">)</span> -</span><span id="Parser-890"><a href="#Parser-890"><span class="linenos"> 890</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">parser</span><span class="p">:</span> -</span><span id="Parser-891"><a href="#Parser-891"><span class="linenos"> 891</span></a> <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"No parser registered for </span><span class="si">{</span><span class="n">expression_type</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Parser-892"><a href="#Parser-892"><span class="linenos"> 892</span></a> -</span><span id="Parser-893"><a href="#Parser-893"><span class="linenos"> 893</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="Parser-894"><a href="#Parser-894"><span class="linenos"> 894</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse</span><span class="p">(</span><span class="n">parser</span><span class="p">,</span> <span class="n">raw_tokens</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="Parser-895"><a href="#Parser-895"><span class="linenos"> 895</span></a> <span class="k">except</span> <span class="n">ParseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> -</span><span id="Parser-896"><a href="#Parser-896"><span class="linenos"> 896</span></a> <span class="n">e</span><span class="o">.</span><span class="n">errors</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s2">"into_expression"</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression_type</span> -</span><span id="Parser-897"><a href="#Parser-897"><span class="linenos"> 897</span></a> <span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> -</span><span id="Parser-898"><a href="#Parser-898"><span class="linenos"> 898</span></a> -</span><span id="Parser-899"><a href="#Parser-899"><span class="linenos"> 899</span></a> <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span> -</span><span id="Parser-900"><a href="#Parser-900"><span class="linenos"> 900</span></a> <span class="sa">f</span><span class="s2">"Failed to parse '</span><span class="si">{</span><span class="n">sql</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="n">raw_tokens</span><span class="si">}</span><span class="s2">' into </span><span class="si">{</span><span class="n">expression_types</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Parser-901"><a href="#Parser-901"><span class="linenos"> 901</span></a> <span class="n">errors</span><span class="o">=</span><span class="n">merge_errors</span><span class="p">(</span><span class="n">errors</span><span class="p">),</span> -</span><span id="Parser-902"><a href="#Parser-902"><span class="linenos"> 902</span></a> <span class="p">)</span> <span class="kn">from</span> <span class="nn">errors</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> -</span><span id="Parser-903"><a href="#Parser-903"><span class="linenos"> 903</span></a> -</span><span id="Parser-904"><a href="#Parser-904"><span class="linenos"> 904</span></a> <span class="k">def</span> <span class="nf">_parse</span><span class="p">(</span> -</span><span id="Parser-905"><a href="#Parser-905"><span class="linenos"> 905</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Parser-906"><a href="#Parser-906"><span class="linenos"> 906</span></a> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Parser</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><span id="Parser-907"><a href="#Parser-907"><span class="linenos"> 907</span></a> <span class="n">raw_tokens</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">Token</span><span class="p">],</span> -</span><span id="Parser-908"><a href="#Parser-908"><span class="linenos"> 908</span></a> <span class="n">sql</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="Parser-909"><a href="#Parser-909"><span class="linenos"> 909</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Parser-910"><a href="#Parser-910"><span class="linenos"> 910</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> -</span><span id="Parser-911"><a href="#Parser-911"><span class="linenos"> 911</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span> <span class="ow">or</span> <span class="s2">""</span> -</span><span id="Parser-912"><a href="#Parser-912"><span class="linenos"> 912</span></a> -</span><span id="Parser-913"><a href="#Parser-913"><span class="linenos"> 913</span></a> <span class="n">total</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">raw_tokens</span><span class="p">)</span> -</span><span id="Parser-914"><a href="#Parser-914"><span class="linenos"> 914</span></a> <span class="n">chunks</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">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Token</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[[]]</span> -</span><span id="Parser-915"><a href="#Parser-915"><span class="linenos"> 915</span></a> -</span><span id="Parser-916"><a href="#Parser-916"><span class="linenos"> 916</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">token</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">raw_tokens</span><span class="p">):</span> -</span><span id="Parser-917"><a href="#Parser-917"><span class="linenos"> 917</span></a> <span class="k">if</span> <span class="n">token</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SEMICOLON</span><span class="p">:</span> -</span><span id="Parser-918"><a href="#Parser-918"><span class="linenos"> 918</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o"><</span> <span class="n">total</span> <span class="o">-</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Parser-919"><a href="#Parser-919"><span class="linenos"> 919</span></a> <span class="n">chunks</span><span class="o">.</span><span class="n">append</span><span class="p">([])</span> -</span><span id="Parser-920"><a href="#Parser-920"><span class="linenos"> 920</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-921"><a href="#Parser-921"><span class="linenos"> 921</span></a> <span class="n">chunks</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">token</span><span class="p">)</span> -</span><span id="Parser-922"><a href="#Parser-922"><span class="linenos"> 922</span></a> -</span><span id="Parser-923"><a href="#Parser-923"><span class="linenos"> 923</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-924"><a href="#Parser-924"><span class="linenos"> 924</span></a> -</span><span id="Parser-925"><a href="#Parser-925"><span class="linenos"> 925</span></a> <span class="k">for</span> <span class="n">tokens</span> <span class="ow">in</span> <span class="n">chunks</span><span class="p">:</span> -</span><span id="Parser-926"><a href="#Parser-926"><span class="linenos"> 926</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span> -</span><span id="Parser-927"><a href="#Parser-927"><span class="linenos"> 927</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span> <span class="o">=</span> <span class="n">tokens</span> -</span><span id="Parser-928"><a href="#Parser-928"><span class="linenos"> 928</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Parser-929"><a href="#Parser-929"><span class="linenos"> 929</span></a> -</span><span id="Parser-930"><a href="#Parser-930"><span class="linenos"> 930</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">parse_method</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span> -</span><span id="Parser-931"><a href="#Parser-931"><span class="linenos"> 931</span></a> -</span><span id="Parser-932"><a href="#Parser-932"><span class="linenos"> 932</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o"><</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">):</span> -</span><span id="Parser-933"><a href="#Parser-933"><span class="linenos"> 933</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Invalid expression / Unexpected token"</span><span class="p">)</span> -</span><span id="Parser-934"><a href="#Parser-934"><span class="linenos"> 934</span></a> -</span><span id="Parser-935"><a href="#Parser-935"><span class="linenos"> 935</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">check_errors</span><span class="p">()</span> -</span><span id="Parser-936"><a href="#Parser-936"><span class="linenos"> 936</span></a> -</span><span id="Parser-937"><a href="#Parser-937"><span class="linenos"> 937</span></a> <span class="k">return</span> <span class="n">expressions</span> -</span><span id="Parser-938"><a href="#Parser-938"><span class="linenos"> 938</span></a> -</span><span id="Parser-939"><a href="#Parser-939"><span class="linenos"> 939</span></a> <span class="k">def</span> <span class="nf">check_errors</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Parser-940"><a href="#Parser-940"><span class="linenos"> 940</span></a><span class="w"> </span><span class="sd">"""Logs or raises any found errors, depending on the chosen error level setting."""</span> -</span><span id="Parser-941"><a href="#Parser-941"><span class="linenos"> 941</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">:</span> -</span><span id="Parser-942"><a href="#Parser-942"><span class="linenos"> 942</span></a> <span class="k">for</span> <span class="n">error</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">:</span> -</span><span id="Parser-943"><a href="#Parser-943"><span class="linenos"> 943</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">error</span><span class="p">))</span> -</span><span id="Parser-944"><a href="#Parser-944"><span class="linenos"> 944</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">RAISE</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">:</span> -</span><span id="Parser-945"><a href="#Parser-945"><span class="linenos"> 945</span></a> <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span> -</span><span id="Parser-946"><a href="#Parser-946"><span class="linenos"> 946</span></a> <span class="n">concat_messages</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_errors</span><span class="p">),</span> -</span><span id="Parser-947"><a href="#Parser-947"><span class="linenos"> 947</span></a> <span class="n">errors</span><span class="o">=</span><span class="n">merge_errors</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">),</span> -</span><span id="Parser-948"><a href="#Parser-948"><span class="linenos"> 948</span></a> <span class="p">)</span> -</span><span id="Parser-949"><a href="#Parser-949"><span class="linenos"> 949</span></a> -</span><span id="Parser-950"><a href="#Parser-950"><span class="linenos"> 950</span></a> <span class="k">def</span> <span class="nf">raise_error</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">token</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">Token</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Parser-951"><a href="#Parser-951"><span class="linenos"> 951</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Parser-952"><a href="#Parser-952"><span class="linenos"> 952</span></a><span class="sd"> Appends an error in the list of recorded errors or raises it, depending on the chosen</span> -</span><span id="Parser-953"><a href="#Parser-953"><span class="linenos"> 953</span></a><span class="sd"> error level setting.</span> -</span><span id="Parser-954"><a href="#Parser-954"><span class="linenos"> 954</span></a><span class="sd"> """</span> -</span><span id="Parser-955"><a href="#Parser-955"><span class="linenos"> 955</span></a> <span class="n">token</span> <span class="o">=</span> <span class="n">token</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="ow">or</span> <span class="n">Token</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">)</span> -</span><span id="Parser-956"><a href="#Parser-956"><span class="linenos"> 956</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">token</span><span class="o">.</span><span class="n">start</span> -</span><span id="Parser-957"><a href="#Parser-957"><span class="linenos"> 957</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">token</span><span class="o">.</span><span class="n">end</span> <span class="o">+</span> <span class="mi">1</span> -</span><span id="Parser-958"><a href="#Parser-958"><span class="linenos"> 958</span></a> <span class="n">start_context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="nb">max</span><span class="p">(</span><span class="n">start</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_message_context</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="p">:</span> <span class="n">start</span><span class="p">]</span> -</span><span id="Parser-959"><a href="#Parser-959"><span class="linenos"> 959</span></a> <span class="n">highlight</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">start</span><span class="p">:</span><span class="n">end</span><span class="p">]</span> -</span><span id="Parser-960"><a href="#Parser-960"><span class="linenos"> 960</span></a> <span class="n">end_context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">end</span> <span class="p">:</span> <span class="n">end</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_message_context</span><span class="p">]</span> -</span><span id="Parser-961"><a href="#Parser-961"><span class="linenos"> 961</span></a> -</span><span id="Parser-962"><a href="#Parser-962"><span class="linenos"> 962</span></a> <span class="n">error</span> <span class="o">=</span> <span class="n">ParseError</span><span class="o">.</span><span class="n">new</span><span class="p">(</span> -</span><span id="Parser-963"><a href="#Parser-963"><span class="linenos"> 963</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">message</span><span class="si">}</span><span class="s2">. Line </span><span class="si">{</span><span class="n">token</span><span class="o">.</span><span class="n">line</span><span class="si">}</span><span class="s2">, Col: </span><span class="si">{</span><span class="n">token</span><span class="o">.</span><span class="n">col</span><span class="si">}</span><span class="s2">.</span><span class="se">\n</span><span class="s2">"</span> -</span><span id="Parser-964"><a href="#Parser-964"><span class="linenos"> 964</span></a> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">start_context</span><span class="si">}</span><span class="se">\033</span><span class="s2">[4m</span><span class="si">{</span><span class="n">highlight</span><span class="si">}</span><span class="se">\033</span><span class="s2">[0m</span><span class="si">{</span><span class="n">end_context</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Parser-965"><a href="#Parser-965"><span class="linenos"> 965</span></a> <span class="n">description</span><span class="o">=</span><span class="n">message</span><span class="p">,</span> -</span><span id="Parser-966"><a href="#Parser-966"><span class="linenos"> 966</span></a> <span class="n">line</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">line</span><span class="p">,</span> -</span><span id="Parser-967"><a href="#Parser-967"><span class="linenos"> 967</span></a> <span class="n">col</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">col</span><span class="p">,</span> -</span><span id="Parser-968"><a href="#Parser-968"><span class="linenos"> 968</span></a> <span class="n">start_context</span><span class="o">=</span><span class="n">start_context</span><span class="p">,</span> -</span><span id="Parser-969"><a href="#Parser-969"><span class="linenos"> 969</span></a> <span class="n">highlight</span><span class="o">=</span><span class="n">highlight</span><span class="p">,</span> -</span><span id="Parser-970"><a href="#Parser-970"><span class="linenos"> 970</span></a> <span class="n">end_context</span><span class="o">=</span><span class="n">end_context</span><span class="p">,</span> -</span><span id="Parser-971"><a href="#Parser-971"><span class="linenos"> 971</span></a> <span class="p">)</span> -</span><span id="Parser-972"><a href="#Parser-972"><span class="linenos"> 972</span></a> -</span><span id="Parser-973"><a href="#Parser-973"><span class="linenos"> 973</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span><span class="p">:</span> -</span><span id="Parser-974"><a href="#Parser-974"><span class="linenos"> 974</span></a> <span class="k">raise</span> <span class="n">error</span> -</span><span id="Parser-975"><a href="#Parser-975"><span class="linenos"> 975</span></a> -</span><span id="Parser-976"><a href="#Parser-976"><span class="linenos"> 976</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">error</span><span class="p">)</span> -</span><span id="Parser-977"><a href="#Parser-977"><span class="linenos"> 977</span></a> -</span><span id="Parser-978"><a href="#Parser-978"><span class="linenos"> 978</span></a> <span class="k">def</span> <span class="nf">expression</span><span class="p">(</span> -</span><span id="Parser-979"><a href="#Parser-979"><span class="linenos"> 979</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> <span class="n">comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> -</span><span id="Parser-980"><a href="#Parser-980"><span class="linenos"> 980</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="Parser-981"><a href="#Parser-981"><span class="linenos"> 981</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Parser-982"><a href="#Parser-982"><span class="linenos"> 982</span></a><span class="sd"> Creates a new, validated Expression.</span> -</span><span id="Parser-983"><a href="#Parser-983"><span class="linenos"> 983</span></a> -</span><span id="Parser-984"><a href="#Parser-984"><span class="linenos"> 984</span></a><span class="sd"> Args:</span> -</span><span id="Parser-985"><a href="#Parser-985"><span class="linenos"> 985</span></a><span class="sd"> exp_class: The expression class to instantiate.</span> -</span><span id="Parser-986"><a href="#Parser-986"><span class="linenos"> 986</span></a><span class="sd"> comments: An optional list of comments to attach to the expression.</span> -</span><span id="Parser-987"><a href="#Parser-987"><span class="linenos"> 987</span></a><span class="sd"> kwargs: The arguments to set for the expression along with their respective values.</span> -</span><span id="Parser-988"><a href="#Parser-988"><span class="linenos"> 988</span></a> -</span><span id="Parser-989"><a href="#Parser-989"><span class="linenos"> 989</span></a><span class="sd"> Returns:</span> -</span><span id="Parser-990"><a href="#Parser-990"><span class="linenos"> 990</span></a><span class="sd"> The target expression.</span> -</span><span id="Parser-991"><a href="#Parser-991"><span class="linenos"> 991</span></a><span class="sd"> """</span> -</span><span id="Parser-992"><a href="#Parser-992"><span class="linenos"> 992</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">exp_class</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="Parser-993"><a href="#Parser-993"><span class="linenos"> 993</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">add_comments</span><span class="p">(</span><span class="n">comments</span><span class="p">)</span> <span class="k">if</span> <span class="n">comments</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add_comments</span><span class="p">(</span><span class="n">instance</span><span class="p">)</span> -</span><span id="Parser-994"><a href="#Parser-994"><span class="linenos"> 994</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">instance</span><span class="p">)</span> -</span><span id="Parser-995"><a href="#Parser-995"><span class="linenos"> 995</span></a> -</span><span id="Parser-996"><a href="#Parser-996"><span class="linenos"> 996</span></a> <span class="k">def</span> <span class="nf">_add_comments</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Parser-997"><a href="#Parser-997"><span class="linenos"> 997</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span><span class="p">:</span> -</span><span id="Parser-998"><a href="#Parser-998"><span class="linenos"> 998</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">add_comments</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span><span class="p">)</span> -</span><span id="Parser-999"><a href="#Parser-999"><span class="linenos"> 999</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1000"><a href="#Parser-1000"><span class="linenos">1000</span></a> -</span><span id="Parser-1001"><a href="#Parser-1001"><span class="linenos">1001</span></a> <span class="k">def</span> <span class="nf">validate_expression</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="Parser-1002"><a href="#Parser-1002"><span class="linenos">1002</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Parser-1003"><a href="#Parser-1003"><span class="linenos">1003</span></a><span class="sd"> Validates an Expression, making sure that all its mandatory arguments are set.</span> -</span><span id="Parser-1004"><a href="#Parser-1004"><span class="linenos">1004</span></a> -</span><span id="Parser-1005"><a href="#Parser-1005"><span class="linenos">1005</span></a><span class="sd"> Args:</span> -</span><span id="Parser-1006"><a href="#Parser-1006"><span class="linenos">1006</span></a><span class="sd"> expression: The expression to validate.</span> -</span><span id="Parser-1007"><a href="#Parser-1007"><span class="linenos">1007</span></a><span class="sd"> args: An optional list of items that was used to instantiate the expression, if it's a Func.</span> -</span><span id="Parser-1008"><a href="#Parser-1008"><span class="linenos">1008</span></a> -</span><span id="Parser-1009"><a href="#Parser-1009"><span class="linenos">1009</span></a><span class="sd"> Returns:</span> -</span><span id="Parser-1010"><a href="#Parser-1010"><span class="linenos">1010</span></a><span class="sd"> The validated expression.</span> -</span><span id="Parser-1011"><a href="#Parser-1011"><span class="linenos">1011</span></a><span class="sd"> """</span> -</span><span id="Parser-1012"><a href="#Parser-1012"><span class="linenos">1012</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">!=</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IGNORE</span><span class="p">:</span> -</span><span id="Parser-1013"><a href="#Parser-1013"><span class="linenos">1013</span></a> <span class="k">for</span> <span class="n">error_message</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">error_messages</span><span class="p">(</span><span class="n">args</span><span class="p">):</span> -</span><span id="Parser-1014"><a href="#Parser-1014"><span class="linenos">1014</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="n">error_message</span><span class="p">)</span> -</span><span id="Parser-1015"><a href="#Parser-1015"><span class="linenos">1015</span></a> -</span><span id="Parser-1016"><a href="#Parser-1016"><span class="linenos">1016</span></a> <span class="k">return</span> <span class="n">expression</span> -</span><span id="Parser-1017"><a href="#Parser-1017"><span class="linenos">1017</span></a> -</span><span id="Parser-1018"><a href="#Parser-1018"><span class="linenos">1018</span></a> <span class="k">def</span> <span class="nf">_find_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">start</span><span class="p">:</span> <span class="n">Token</span><span class="p">,</span> <span class="n">end</span><span class="p">:</span> <span class="n">Token</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Parser-1019"><a href="#Parser-1019"><span class="linenos">1019</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">start</span><span class="o">.</span><span class="n">start</span> <span class="p">:</span> <span class="n">end</span><span class="o">.</span><span class="n">end</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span> -</span><span id="Parser-1020"><a href="#Parser-1020"><span class="linenos">1020</span></a> -</span><span id="Parser-1021"><a href="#Parser-1021"><span class="linenos">1021</span></a> <span class="k">def</span> <span class="nf">_advance</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">times</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Parser-1022"><a href="#Parser-1022"><span class="linenos">1022</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">+=</span> <span class="n">times</span> -</span><span id="Parser-1023"><a href="#Parser-1023"><span class="linenos">1023</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span><span class="p">)</span> -</span><span id="Parser-1024"><a href="#Parser-1024"><span class="linenos">1024</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="Parser-1025"><a href="#Parser-1025"><span class="linenos">1025</span></a> -</span><span id="Parser-1026"><a href="#Parser-1026"><span class="linenos">1026</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> -</span><span id="Parser-1027"><a href="#Parser-1027"><span class="linenos">1027</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> -</span><span id="Parser-1028"><a href="#Parser-1028"><span class="linenos">1028</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</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">comments</span> -</span><span id="Parser-1029"><a href="#Parser-1029"><span class="linenos">1029</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1030"><a href="#Parser-1030"><span class="linenos">1030</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1031"><a href="#Parser-1031"><span class="linenos">1031</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1032"><a href="#Parser-1032"><span class="linenos">1032</span></a> -</span><span id="Parser-1033"><a href="#Parser-1033"><span class="linenos">1033</span></a> <span class="k">def</span> <span class="nf">_retreat</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">index</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Parser-1034"><a href="#Parser-1034"><span class="linenos">1034</span></a> <span class="k">if</span> <span class="n">index</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span><span class="p">:</span> -</span><span id="Parser-1035"><a href="#Parser-1035"><span class="linenos">1035</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">index</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span><span class="p">)</span> -</span><span id="Parser-1036"><a href="#Parser-1036"><span class="linenos">1036</span></a> -</span><span id="Parser-1037"><a href="#Parser-1037"><span class="linenos">1037</span></a> <span class="k">def</span> <span class="nf">_parse_command</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">Command</span><span class="p">:</span> -</span><span id="Parser-1038"><a href="#Parser-1038"><span class="linenos">1038</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">Command</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 class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">())</span> -</span><span id="Parser-1039"><a href="#Parser-1039"><span class="linenos">1039</span></a> -</span><span id="Parser-1040"><a href="#Parser-1040"><span class="linenos">1040</span></a> <span class="k">def</span> <span class="nf">_parse_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">allow_exists</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="Parser-1041"><a href="#Parser-1041"><span class="linenos">1041</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> -</span><span id="Parser-1042"><a href="#Parser-1042"><span class="linenos">1042</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">()</span> <span class="k">if</span> <span class="n">allow_exists</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="Parser-1043"><a href="#Parser-1043"><span class="linenos">1043</span></a> -</span><span id="Parser-1044"><a href="#Parser-1044"><span class="linenos">1044</span></a> <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">ON</span><span class="p">)</span> -</span><span id="Parser-1045"><a href="#Parser-1045"><span class="linenos">1045</span></a> -</span><span id="Parser-1046"><a href="#Parser-1046"><span class="linenos">1046</span></a> <span class="n">kind</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> -</span><span id="Parser-1047"><a href="#Parser-1047"><span class="linenos">1047</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="Parser-1048"><a href="#Parser-1048"><span class="linenos">1048</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> -</span><span id="Parser-1049"><a href="#Parser-1049"><span class="linenos">1049</span></a> -</span><span id="Parser-1050"><a href="#Parser-1050"><span class="linenos">1050</span></a> <span class="k">if</span> <span class="n">kind</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FUNCTION</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PROCEDURE</span><span class="p">):</span> -</span><span id="Parser-1051"><a href="#Parser-1051"><span class="linenos">1051</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_user_defined_function</span><span class="p">(</span><span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="o">.</span><span class="n">token_type</span><span class="p">)</span> -</span><span id="Parser-1052"><a href="#Parser-1052"><span class="linenos">1052</span></a> <span class="k">elif</span> <span class="n">kind</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">:</span> -</span><span id="Parser-1053"><a href="#Parser-1053"><span class="linenos">1053</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">alias_tokens</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">COMMENT_TABLE_ALIAS_TOKENS</span><span class="p">)</span> -</span><span id="Parser-1054"><a href="#Parser-1054"><span class="linenos">1054</span></a> <span class="k">elif</span> <span class="n">kind</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLUMN</span><span class="p">:</span> -</span><span id="Parser-1055"><a href="#Parser-1055"><span class="linenos">1055</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> -</span><span id="Parser-1056"><a href="#Parser-1056"><span class="linenos">1056</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1057"><a href="#Parser-1057"><span class="linenos">1057</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="Parser-1058"><a href="#Parser-1058"><span class="linenos">1058</span></a> -</span><span id="Parser-1059"><a href="#Parser-1059"><span class="linenos">1059</span></a> <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">IS</span><span class="p">)</span> -</span><span id="Parser-1060"><a href="#Parser-1060"><span class="linenos">1060</span></a> -</span><span id="Parser-1061"><a href="#Parser-1061"><span class="linenos">1061</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><span id="Parser-1062"><a href="#Parser-1062"><span class="linenos">1062</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Comment</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">(),</span> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span> -</span><span id="Parser-1063"><a href="#Parser-1063"><span class="linenos">1063</span></a> <span class="p">)</span> -</span><span id="Parser-1064"><a href="#Parser-1064"><span class="linenos">1064</span></a> -</span><span id="Parser-1065"><a href="#Parser-1065"><span class="linenos">1065</span></a> <span class="k">def</span> <span class="nf">_parse_to_table</span><span class="p">(</span> -</span><span id="Parser-1066"><a href="#Parser-1066"><span class="linenos">1066</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Parser-1067"><a href="#Parser-1067"><span class="linenos">1067</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">ToTableProperty</span><span class="p">:</span> -</span><span id="Parser-1068"><a href="#Parser-1068"><span class="linenos">1068</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-1069"><a href="#Parser-1069"><span class="linenos">1069</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">ToTableProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">)</span> -</span><span id="Parser-1070"><a href="#Parser-1070"><span class="linenos">1070</span></a> -</span><span id="Parser-1071"><a href="#Parser-1071"><span class="linenos">1071</span></a> <span class="c1"># https://clickhouse.com/docs/en/engines/table-engines/mergetree-family/mergetree#mergetree-table-ttl</span> -</span><span id="Parser-1072"><a href="#Parser-1072"><span class="linenos">1072</span></a> <span class="k">def</span> <span class="nf">_parse_ttl</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">Expression</span><span class="p">:</span> -</span><span id="Parser-1073"><a href="#Parser-1073"><span class="linenos">1073</span></a> <span class="k">def</span> <span class="nf">_parse_ttl_action</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="Parser-1074"><a href="#Parser-1074"><span class="linenos">1074</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="Parser-1075"><a href="#Parser-1075"><span class="linenos">1075</span></a> -</span><span id="Parser-1076"><a href="#Parser-1076"><span class="linenos">1076</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DELETE"</span><span class="p">):</span> -</span><span id="Parser-1077"><a href="#Parser-1077"><span class="linenos">1077</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">MergeTreeTTLAction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">delete</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-1078"><a href="#Parser-1078"><span class="linenos">1078</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"RECOMPRESS"</span><span class="p">):</span> -</span><span id="Parser-1079"><a href="#Parser-1079"><span class="linenos">1079</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><span id="Parser-1080"><a href="#Parser-1080"><span class="linenos">1080</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTLAction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">recompress</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="Parser-1081"><a href="#Parser-1081"><span class="linenos">1081</span></a> <span class="p">)</span> -</span><span id="Parser-1082"><a href="#Parser-1082"><span class="linenos">1082</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"DISK"</span><span class="p">):</span> -</span><span id="Parser-1083"><a href="#Parser-1083"><span class="linenos">1083</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><span id="Parser-1084"><a href="#Parser-1084"><span class="linenos">1084</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTLAction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to_disk</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="Parser-1085"><a href="#Parser-1085"><span class="linenos">1085</span></a> <span class="p">)</span> -</span><span id="Parser-1086"><a href="#Parser-1086"><span class="linenos">1086</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"VOLUME"</span><span class="p">):</span> -</span><span id="Parser-1087"><a href="#Parser-1087"><span class="linenos">1087</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><span id="Parser-1088"><a href="#Parser-1088"><span class="linenos">1088</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTLAction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to_volume</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="Parser-1089"><a href="#Parser-1089"><span class="linenos">1089</span></a> <span class="p">)</span> -</span><span id="Parser-1090"><a href="#Parser-1090"><span class="linenos">1090</span></a> -</span><span id="Parser-1091"><a href="#Parser-1091"><span class="linenos">1091</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-1092"><a href="#Parser-1092"><span class="linenos">1092</span></a> -</span><span id="Parser-1093"><a href="#Parser-1093"><span class="linenos">1093</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">_parse_ttl_action</span><span class="p">)</span> -</span><span id="Parser-1094"><a href="#Parser-1094"><span class="linenos">1094</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">()</span> -</span><span id="Parser-1095"><a href="#Parser-1095"><span class="linenos">1095</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_group</span><span class="p">()</span> -</span><span id="Parser-1096"><a href="#Parser-1096"><span class="linenos">1096</span></a> -</span><span id="Parser-1097"><a href="#Parser-1097"><span class="linenos">1097</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1098"><a href="#Parser-1098"><span class="linenos">1098</span></a> <span class="k">if</span> <span class="n">group</span> <span class="ow">and</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">SET</span><span class="p">):</span> -</span><span id="Parser-1099"><a href="#Parser-1099"><span class="linenos">1099</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_item</span><span class="p">)</span> -</span><span id="Parser-1100"><a href="#Parser-1100"><span class="linenos">1100</span></a> -</span><span id="Parser-1101"><a href="#Parser-1101"><span class="linenos">1101</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><span id="Parser-1102"><a href="#Parser-1102"><span class="linenos">1102</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">,</span> -</span><span id="Parser-1103"><a href="#Parser-1103"><span class="linenos">1103</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Parser-1104"><a href="#Parser-1104"><span class="linenos">1104</span></a> <span class="n">where</span><span class="o">=</span><span class="n">where</span><span class="p">,</span> -</span><span id="Parser-1105"><a href="#Parser-1105"><span class="linenos">1105</span></a> <span class="n">group</span><span class="o">=</span><span class="n">group</span><span class="p">,</span> -</span><span id="Parser-1106"><a href="#Parser-1106"><span class="linenos">1106</span></a> <span class="n">aggregates</span><span class="o">=</span><span class="n">aggregates</span><span class="p">,</span> -</span><span id="Parser-1107"><a href="#Parser-1107"><span class="linenos">1107</span></a> <span class="p">)</span> -</span><span id="Parser-1108"><a href="#Parser-1108"><span class="linenos">1108</span></a> -</span><span id="Parser-1109"><a href="#Parser-1109"><span class="linenos">1109</span></a> <span class="k">def</span> <span class="nf">_parse_statement</span><span class="p">(</span><span class="bp">self</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="Parser-1110"><a href="#Parser-1110"><span class="linenos">1110</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Parser-1111"><a href="#Parser-1111"><span class="linenos">1111</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-1112"><a href="#Parser-1112"><span class="linenos">1112</span></a> -</span><span id="Parser-1113"><a href="#Parser-1113"><span class="linenos">1113</span></a> <span class="k">if</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">STATEMENT_PARSERS</span><span class="p">):</span> -</span><span id="Parser-1114"><a href="#Parser-1114"><span class="linenos">1114</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">STATEMENT_PARSERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> -</span><span id="Parser-1115"><a href="#Parser-1115"><span class="linenos">1115</span></a> -</span><span id="Parser-1116"><a href="#Parser-1116"><span class="linenos">1116</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">(</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">COMMANDS</span><span class="p">):</span> -</span><span id="Parser-1117"><a href="#Parser-1117"><span class="linenos">1117</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_command</span><span class="p">()</span> -</span><span id="Parser-1118"><a href="#Parser-1118"><span class="linenos">1118</span></a> -</span><span id="Parser-1119"><a href="#Parser-1119"><span class="linenos">1119</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">()</span> -</span><span id="Parser-1120"><a href="#Parser-1120"><span class="linenos">1120</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">()</span> -</span><span id="Parser-1121"><a href="#Parser-1121"><span class="linenos">1121</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Parser-1122"><a href="#Parser-1122"><span class="linenos">1122</span></a> -</span><span id="Parser-1123"><a href="#Parser-1123"><span class="linenos">1123</span></a> <span class="k">def</span> <span class="nf">_parse_drop</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">Drop</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> -</span><span id="Parser-1124"><a href="#Parser-1124"><span class="linenos">1124</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> -</span><span id="Parser-1125"><a href="#Parser-1125"><span class="linenos">1125</span></a> <span class="n">temporary</span> <span class="o">=</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">TEMPORARY</span><span class="p">)</span> -</span><span id="Parser-1126"><a href="#Parser-1126"><span class="linenos">1126</span></a> <span class="n">materialized</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MATERIALIZED"</span><span class="p">)</span> -</span><span id="Parser-1127"><a href="#Parser-1127"><span class="linenos">1127</span></a> -</span><span id="Parser-1128"><a href="#Parser-1128"><span class="linenos">1128</span></a> <span class="n">kind</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</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><span id="Parser-1129"><a href="#Parser-1129"><span class="linenos">1129</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="Parser-1130"><a href="#Parser-1130"><span class="linenos">1130</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> -</span><span id="Parser-1131"><a href="#Parser-1131"><span class="linenos">1131</span></a> -</span><span id="Parser-1132"><a href="#Parser-1132"><span class="linenos">1132</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><span id="Parser-1133"><a href="#Parser-1133"><span class="linenos">1133</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">,</span> -</span><span id="Parser-1134"><a href="#Parser-1134"><span class="linenos">1134</span></a> <span class="n">exists</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">(),</span> -</span><span id="Parser-1135"><a href="#Parser-1135"><span class="linenos">1135</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="Parser-1136"><a href="#Parser-1136"><span class="linenos">1136</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> -</span><span id="Parser-1137"><a href="#Parser-1137"><span class="linenos">1137</span></a> <span class="n">temporary</span><span class="o">=</span><span class="n">temporary</span><span class="p">,</span> -</span><span id="Parser-1138"><a href="#Parser-1138"><span class="linenos">1138</span></a> <span class="n">materialized</span><span class="o">=</span><span class="n">materialized</span><span class="p">,</span> -</span><span id="Parser-1139"><a href="#Parser-1139"><span class="linenos">1139</span></a> <span class="n">cascade</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CASCADE"</span><span class="p">),</span> -</span><span id="Parser-1140"><a href="#Parser-1140"><span class="linenos">1140</span></a> <span class="n">constraints</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CONSTRAINTS"</span><span class="p">),</span> -</span><span id="Parser-1141"><a href="#Parser-1141"><span class="linenos">1141</span></a> <span class="n">purge</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PURGE"</span><span class="p">),</span> -</span><span id="Parser-1142"><a href="#Parser-1142"><span class="linenos">1142</span></a> <span class="p">)</span> -</span><span id="Parser-1143"><a href="#Parser-1143"><span class="linenos">1143</span></a> -</span><span id="Parser-1144"><a href="#Parser-1144"><span class="linenos">1144</span></a> <span class="k">def</span> <span class="nf">_parse_exists</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">not_</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="nb">bool</span><span class="p">]:</span> -</span><span id="Parser-1145"><a href="#Parser-1145"><span class="linenos">1145</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="Parser-1146"><a href="#Parser-1146"><span class="linenos">1146</span></a> <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">IF</span><span class="p">)</span> -</span><span id="Parser-1147"><a href="#Parser-1147"><span class="linenos">1147</span></a> <span class="ow">and</span> <span class="p">(</span><span class="ow">not</span> <span class="n">not_</span> <span class="ow">or</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">NOT</span><span class="p">))</span> -</span><span id="Parser-1148"><a href="#Parser-1148"><span class="linenos">1148</span></a> <span class="ow">and</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">EXISTS</span><span class="p">)</span> -</span><span id="Parser-1149"><a href="#Parser-1149"><span class="linenos">1149</span></a> <span class="p">)</span> -</span><span id="Parser-1150"><a href="#Parser-1150"><span class="linenos">1150</span></a> -</span><span id="Parser-1151"><a href="#Parser-1151"><span class="linenos">1151</span></a> <span class="k">def</span> <span class="nf">_parse_create</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">Create</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> -</span><span id="Parser-1152"><a href="#Parser-1152"><span class="linenos">1152</span></a> <span class="c1"># Note: this can't be None because we've matched a statement parser</span> -</span><span id="Parser-1153"><a href="#Parser-1153"><span class="linenos">1153</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> -</span><span id="Parser-1154"><a href="#Parser-1154"><span class="linenos">1154</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"REPLACE"</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span> -</span><span id="Parser-1155"><a href="#Parser-1155"><span class="linenos">1155</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">OR</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span> -</span><span id="Parser-1156"><a href="#Parser-1156"><span class="linenos">1156</span></a> <span class="p">)</span> -</span><span id="Parser-1157"><a href="#Parser-1157"><span class="linenos">1157</span></a> <span class="n">unique</span> <span class="o">=</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">UNIQUE</span><span class="p">)</span> -</span><span id="Parser-1158"><a href="#Parser-1158"><span class="linenos">1158</span></a> -</span><span id="Parser-1159"><a href="#Parser-1159"><span class="linenos">1159</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FUNCTION</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="Parser-1160"><a href="#Parser-1160"><span class="linenos">1160</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Parser-1161"><a href="#Parser-1161"><span class="linenos">1161</span></a> -</span><span id="Parser-1162"><a href="#Parser-1162"><span class="linenos">1162</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1163"><a href="#Parser-1163"><span class="linenos">1163</span></a> <span class="n">create_token</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> -</span><span id="Parser-1164"><a href="#Parser-1164"><span class="linenos">1164</span></a> -</span><span id="Parser-1165"><a href="#Parser-1165"><span class="linenos">1165</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">create_token</span><span class="p">:</span> -</span><span id="Parser-1166"><a href="#Parser-1166"><span class="linenos">1166</span></a> <span class="c1"># exp.Properties.Location.POST_CREATE</span> -</span><span id="Parser-1167"><a href="#Parser-1167"><span class="linenos">1167</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">()</span> -</span><span id="Parser-1168"><a href="#Parser-1168"><span class="linenos">1168</span></a> <span class="n">create_token</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> -</span><span id="Parser-1169"><a href="#Parser-1169"><span class="linenos">1169</span></a> -</span><span id="Parser-1170"><a href="#Parser-1170"><span class="linenos">1170</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">properties</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">create_token</span><span class="p">:</span> -</span><span id="Parser-1171"><a href="#Parser-1171"><span class="linenos">1171</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> -</span><span id="Parser-1172"><a href="#Parser-1172"><span class="linenos">1172</span></a> -</span><span id="Parser-1173"><a href="#Parser-1173"><span class="linenos">1173</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">(</span><span class="n">not_</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-1174"><a href="#Parser-1174"><span class="linenos">1174</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1175"><a href="#Parser-1175"><span class="linenos">1175</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1176"><a href="#Parser-1176"><span class="linenos">1176</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1177"><a href="#Parser-1177"><span class="linenos">1177</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1178"><a href="#Parser-1178"><span class="linenos">1178</span></a> <span class="n">begin</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1179"><a href="#Parser-1179"><span class="linenos">1179</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1180"><a href="#Parser-1180"><span class="linenos">1180</span></a> -</span><span id="Parser-1181"><a href="#Parser-1181"><span class="linenos">1181</span></a> <span class="k">def</span> <span class="nf">extend_props</span><span class="p">(</span><span class="n">temp_props</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">Properties</span><span class="p">])</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Parser-1182"><a href="#Parser-1182"><span class="linenos">1182</span></a> <span class="k">nonlocal</span> <span class="n">properties</span> -</span><span id="Parser-1183"><a href="#Parser-1183"><span class="linenos">1183</span></a> <span class="k">if</span> <span class="n">properties</span> <span class="ow">and</span> <span class="n">temp_props</span><span class="p">:</span> -</span><span id="Parser-1184"><a href="#Parser-1184"><span class="linenos">1184</span></a> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">temp_props</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Parser-1185"><a href="#Parser-1185"><span class="linenos">1185</span></a> <span class="k">elif</span> <span class="n">temp_props</span><span class="p">:</span> -</span><span id="Parser-1186"><a href="#Parser-1186"><span class="linenos">1186</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="n">temp_props</span> -</span><span id="Parser-1187"><a href="#Parser-1187"><span class="linenos">1187</span></a> -</span><span id="Parser-1188"><a href="#Parser-1188"><span class="linenos">1188</span></a> <span class="k">if</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FUNCTION</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PROCEDURE</span><span class="p">):</span> -</span><span id="Parser-1189"><a href="#Parser-1189"><span class="linenos">1189</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_user_defined_function</span><span class="p">(</span><span class="n">kind</span><span class="o">=</span><span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span><span class="p">)</span> -</span><span id="Parser-1190"><a href="#Parser-1190"><span class="linenos">1190</span></a> -</span><span id="Parser-1191"><a href="#Parser-1191"><span class="linenos">1191</span></a> <span class="c1"># exp.Properties.Location.POST_SCHEMA ("schema" here is the UDF's type signature)</span> -</span><span id="Parser-1192"><a href="#Parser-1192"><span class="linenos">1192</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">())</span> -</span><span id="Parser-1193"><a href="#Parser-1193"><span class="linenos">1193</span></a> -</span><span id="Parser-1194"><a href="#Parser-1194"><span class="linenos">1194</span></a> <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">ALIAS</span><span class="p">)</span> -</span><span id="Parser-1195"><a href="#Parser-1195"><span class="linenos">1195</span></a> <span class="n">begin</span> <span class="o">=</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">BEGIN</span><span class="p">)</span> -</span><span id="Parser-1196"><a href="#Parser-1196"><span class="linenos">1196</span></a> <span class="n">return_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"RETURN"</span><span class="p">)</span> -</span><span id="Parser-1197"><a href="#Parser-1197"><span class="linenos">1197</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">()</span> -</span><span id="Parser-1198"><a href="#Parser-1198"><span class="linenos">1198</span></a> -</span><span id="Parser-1199"><a href="#Parser-1199"><span class="linenos">1199</span></a> <span class="k">if</span> <span class="n">return_</span><span class="p">:</span> -</span><span id="Parser-1200"><a href="#Parser-1200"><span class="linenos">1200</span></a> <span class="n">expression</span> <span class="o">=</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">Return</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Parser-1201"><a href="#Parser-1201"><span class="linenos">1201</span></a> <span class="k">elif</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INDEX</span><span class="p">:</span> -</span><span id="Parser-1202"><a href="#Parser-1202"><span class="linenos">1202</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_index</span><span class="p">(</span><span class="n">index</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">())</span> -</span><span id="Parser-1203"><a href="#Parser-1203"><span class="linenos">1203</span></a> <span class="k">elif</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">DB_CREATABLES</span><span class="p">:</span> -</span><span id="Parser-1204"><a href="#Parser-1204"><span class="linenos">1204</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-1205"><a href="#Parser-1205"><span class="linenos">1205</span></a> -</span><span id="Parser-1206"><a href="#Parser-1206"><span class="linenos">1206</span></a> <span class="c1"># exp.Properties.Location.POST_NAME</span> -</span><span id="Parser-1207"><a href="#Parser-1207"><span class="linenos">1207</span></a> <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">COMMA</span><span class="p">)</span> -</span><span id="Parser-1208"><a href="#Parser-1208"><span class="linenos">1208</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">(</span><span class="n">before</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> -</span><span id="Parser-1209"><a href="#Parser-1209"><span class="linenos">1209</span></a> -</span><span id="Parser-1210"><a href="#Parser-1210"><span class="linenos">1210</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_parts</span><span class="p">)</span> -</span><span id="Parser-1211"><a href="#Parser-1211"><span class="linenos">1211</span></a> -</span><span id="Parser-1212"><a href="#Parser-1212"><span class="linenos">1212</span></a> <span class="c1"># exp.Properties.Location.POST_SCHEMA and POST_WITH</span> -</span><span id="Parser-1213"><a href="#Parser-1213"><span class="linenos">1213</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">())</span> -</span><span id="Parser-1214"><a href="#Parser-1214"><span class="linenos">1214</span></a> -</span><span id="Parser-1215"><a href="#Parser-1215"><span class="linenos">1215</span></a> <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">ALIAS</span><span class="p">)</span> -</span><span id="Parser-1216"><a href="#Parser-1216"><span class="linenos">1216</span></a> <span class="k">if</span> <span class="ow">not</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">DDL_SELECT_TOKENS</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="Parser-1217"><a href="#Parser-1217"><span class="linenos">1217</span></a> <span class="c1"># exp.Properties.Location.POST_ALIAS</span> -</span><span id="Parser-1218"><a href="#Parser-1218"><span class="linenos">1218</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">())</span> -</span><span id="Parser-1219"><a href="#Parser-1219"><span class="linenos">1219</span></a> -</span><span id="Parser-1220"><a href="#Parser-1220"><span class="linenos">1220</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_ddl_select</span><span class="p">()</span> -</span><span id="Parser-1221"><a href="#Parser-1221"><span class="linenos">1221</span></a> -</span><span id="Parser-1222"><a href="#Parser-1222"><span class="linenos">1222</span></a> <span class="k">if</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">:</span> -</span><span id="Parser-1223"><a href="#Parser-1223"><span class="linenos">1223</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-1224"><a href="#Parser-1224"><span class="linenos">1224</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Parser-1225"><a href="#Parser-1225"><span class="linenos">1225</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_index</span><span class="p">()</span> -</span><span id="Parser-1226"><a href="#Parser-1226"><span class="linenos">1226</span></a> -</span><span id="Parser-1227"><a href="#Parser-1227"><span class="linenos">1227</span></a> <span class="c1"># exp.Properties.Location.POST_EXPRESSION and POST_INDEX</span> -</span><span id="Parser-1228"><a href="#Parser-1228"><span class="linenos">1228</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">())</span> -</span><span id="Parser-1229"><a href="#Parser-1229"><span class="linenos">1229</span></a> -</span><span id="Parser-1230"><a href="#Parser-1230"><span class="linenos">1230</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">index</span><span class="p">:</span> -</span><span id="Parser-1231"><a href="#Parser-1231"><span class="linenos">1231</span></a> <span class="k">break</span> -</span><span id="Parser-1232"><a href="#Parser-1232"><span class="linenos">1232</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1233"><a href="#Parser-1233"><span class="linenos">1233</span></a> <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">COMMA</span><span class="p">)</span> -</span><span id="Parser-1234"><a href="#Parser-1234"><span class="linenos">1234</span></a> <span class="n">indexes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-1235"><a href="#Parser-1235"><span class="linenos">1235</span></a> <span class="k">elif</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VIEW</span><span class="p">:</span> -</span><span id="Parser-1236"><a href="#Parser-1236"><span class="linenos">1236</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"SCHEMA"</span><span class="p">,</span> <span class="s2">"BINDING"</span><span class="p">):</span> -</span><span id="Parser-1237"><a href="#Parser-1237"><span class="linenos">1237</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Parser-1238"><a href="#Parser-1238"><span class="linenos">1238</span></a> -</span><span id="Parser-1239"><a href="#Parser-1239"><span class="linenos">1239</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CLONE"</span><span class="p">):</span> -</span><span id="Parser-1240"><a href="#Parser-1240"><span class="linenos">1240</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-1241"><a href="#Parser-1241"><span class="linenos">1241</span></a> <span class="n">when</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">({</span><span class="s2">"AT"</span><span class="p">,</span> <span class="s2">"BEFORE"</span><span class="p">})</span> <span class="ow">and</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="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Parser-1242"><a href="#Parser-1242"><span class="linenos">1242</span></a> <span class="n">clone_kind</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Parser-1243"><a href="#Parser-1243"><span class="linenos">1243</span></a> <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_PAREN</span><span class="p">)</span> -</span><span id="Parser-1244"><a href="#Parser-1244"><span class="linenos">1244</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CLONE_KINDS</span><span class="p">)</span> -</span><span id="Parser-1245"><a href="#Parser-1245"><span class="linenos">1245</span></a> <span class="ow">and</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="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Parser-1246"><a href="#Parser-1246"><span class="linenos">1246</span></a> <span class="p">)</span> -</span><span id="Parser-1247"><a href="#Parser-1247"><span class="linenos">1247</span></a> <span class="n">clone_expression</span> <span class="o">=</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">FARROW</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="Parser-1248"><a href="#Parser-1248"><span class="linenos">1248</span></a> <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">R_PAREN</span><span class="p">)</span> -</span><span id="Parser-1249"><a href="#Parser-1249"><span class="linenos">1249</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-1250"><a href="#Parser-1250"><span class="linenos">1250</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Clone</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">clone</span><span class="p">,</span> <span class="n">when</span><span class="o">=</span><span class="n">when</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">clone_kind</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">clone_expression</span> -</span><span id="Parser-1251"><a href="#Parser-1251"><span class="linenos">1251</span></a> <span class="p">)</span> -</span><span id="Parser-1252"><a href="#Parser-1252"><span class="linenos">1252</span></a> -</span><span id="Parser-1253"><a href="#Parser-1253"><span class="linenos">1253</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><span id="Parser-1254"><a href="#Parser-1254"><span class="linenos">1254</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> -</span><span id="Parser-1255"><a href="#Parser-1255"><span class="linenos">1255</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="Parser-1256"><a href="#Parser-1256"><span class="linenos">1256</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">create_token</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> -</span><span id="Parser-1257"><a href="#Parser-1257"><span class="linenos">1257</span></a> <span class="n">replace</span><span class="o">=</span><span class="n">replace</span><span class="p">,</span> -</span><span id="Parser-1258"><a href="#Parser-1258"><span class="linenos">1258</span></a> <span class="n">unique</span><span class="o">=</span><span class="n">unique</span><span class="p">,</span> -</span><span id="Parser-1259"><a href="#Parser-1259"><span class="linenos">1259</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> -</span><span id="Parser-1260"><a href="#Parser-1260"><span class="linenos">1260</span></a> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span><span class="p">,</span> -</span><span id="Parser-1261"><a href="#Parser-1261"><span class="linenos">1261</span></a> <span class="n">properties</span><span class="o">=</span><span class="n">properties</span><span class="p">,</span> -</span><span id="Parser-1262"><a href="#Parser-1262"><span class="linenos">1262</span></a> <span class="n">indexes</span><span class="o">=</span><span class="n">indexes</span><span class="p">,</span> -</span><span id="Parser-1263"><a href="#Parser-1263"><span class="linenos">1263</span></a> <span class="n">no_schema_binding</span><span class="o">=</span><span class="n">no_schema_binding</span><span class="p">,</span> -</span><span id="Parser-1264"><a href="#Parser-1264"><span class="linenos">1264</span></a> <span class="n">begin</span><span class="o">=</span><span class="n">begin</span><span class="p">,</span> -</span><span id="Parser-1265"><a href="#Parser-1265"><span class="linenos">1265</span></a> <span class="n">clone</span><span class="o">=</span><span class="n">clone</span><span class="p">,</span> -</span><span id="Parser-1266"><a href="#Parser-1266"><span class="linenos">1266</span></a> <span class="p">)</span> -</span><span id="Parser-1267"><a href="#Parser-1267"><span class="linenos">1267</span></a> -</span><span id="Parser-1268"><a href="#Parser-1268"><span class="linenos">1268</span></a> <span class="k">def</span> <span class="nf">_parse_property_before</span><span class="p">(</span><span class="bp">self</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="Parser-1269"><a href="#Parser-1269"><span class="linenos">1269</span></a> <span class="c1"># only used for teradata currently</span> -</span><span id="Parser-1270"><a href="#Parser-1270"><span class="linenos">1270</span></a> <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">COMMA</span><span class="p">)</span> -</span><span id="Parser-1271"><a href="#Parser-1271"><span class="linenos">1271</span></a> -</span><span id="Parser-1272"><a href="#Parser-1272"><span class="linenos">1272</span></a> <span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Parser-1273"><a href="#Parser-1273"><span class="linenos">1273</span></a> <span class="s2">"no"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">),</span> -</span><span id="Parser-1274"><a href="#Parser-1274"><span class="linenos">1274</span></a> <span class="s2">"dual"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DUAL"</span><span class="p">),</span> -</span><span id="Parser-1275"><a href="#Parser-1275"><span class="linenos">1275</span></a> <span class="s2">"before"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BEFORE"</span><span class="p">),</span> -</span><span id="Parser-1276"><a href="#Parser-1276"><span class="linenos">1276</span></a> <span class="s2">"default"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFAULT"</span><span class="p">),</span> -</span><span id="Parser-1277"><a href="#Parser-1277"><span class="linenos">1277</span></a> <span class="s2">"local"</span><span class="p">:</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LOCAL"</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"LOCAL"</span><span class="p">)</span> -</span><span id="Parser-1278"><a href="#Parser-1278"><span class="linenos">1278</span></a> <span class="ow">or</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NOT"</span><span class="p">,</span> <span class="s2">"LOCAL"</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"NOT LOCAL"</span><span class="p">),</span> -</span><span id="Parser-1279"><a href="#Parser-1279"><span class="linenos">1279</span></a> <span class="s2">"after"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AFTER"</span><span class="p">),</span> -</span><span id="Parser-1280"><a href="#Parser-1280"><span class="linenos">1280</span></a> <span class="s2">"minimum"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"MIN"</span><span class="p">,</span> <span class="s2">"MINIMUM"</span><span class="p">)),</span> -</span><span id="Parser-1281"><a href="#Parser-1281"><span class="linenos">1281</span></a> <span class="s2">"maximum"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"MAX"</span><span class="p">,</span> <span class="s2">"MAXIMUM"</span><span class="p">)),</span> -</span><span id="Parser-1282"><a href="#Parser-1282"><span class="linenos">1282</span></a> <span class="p">}</span> -</span><span id="Parser-1283"><a href="#Parser-1283"><span class="linenos">1283</span></a> -</span><span id="Parser-1284"><a href="#Parser-1284"><span class="linenos">1284</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">PROPERTY_PARSERS</span><span class="p">):</span> -</span><span id="Parser-1285"><a href="#Parser-1285"><span class="linenos">1285</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTY_PARSERS</span><span class="p">[</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="o">.</span><span class="n">upper</span><span class="p">()]</span> -</span><span id="Parser-1286"><a href="#Parser-1286"><span class="linenos">1286</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="Parser-1287"><a href="#Parser-1287"><span class="linenos">1287</span></a> <span class="k">return</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="n">v</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="k">if</span> <span class="n">v</span><span class="p">})</span> -</span><span id="Parser-1288"><a href="#Parser-1288"><span class="linenos">1288</span></a> <span class="k">except</span> <span class="ne">TypeError</span><span class="p">:</span> -</span><span id="Parser-1289"><a href="#Parser-1289"><span class="linenos">1289</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Cannot parse property '</span><span class="si">{</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="si">}</span><span class="s2">'"</span><span class="p">)</span> -</span><span id="Parser-1290"><a href="#Parser-1290"><span class="linenos">1290</span></a> -</span><span id="Parser-1291"><a href="#Parser-1291"><span class="linenos">1291</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-1292"><a href="#Parser-1292"><span class="linenos">1292</span></a> -</span><span id="Parser-1293"><a href="#Parser-1293"><span class="linenos">1293</span></a> <span class="k">def</span> <span class="nf">_parse_property</span><span class="p">(</span><span class="bp">self</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="Parser-1294"><a href="#Parser-1294"><span class="linenos">1294</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">PROPERTY_PARSERS</span><span class="p">):</span> -</span><span id="Parser-1295"><a href="#Parser-1295"><span class="linenos">1295</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTY_PARSERS</span><span class="p">[</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="o">.</span><span class="n">upper</span><span class="p">()](</span><span class="bp">self</span><span class="p">)</span> -</span><span id="Parser-1296"><a href="#Parser-1296"><span class="linenos">1296</span></a> -</span><span id="Parser-1297"><a href="#Parser-1297"><span class="linenos">1297</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CHARACTER_SET</span><span class="p">):</span> -</span><span id="Parser-1298"><a href="#Parser-1298"><span class="linenos">1298</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_character_set</span><span class="p">(</span><span class="n">default</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-1299"><a href="#Parser-1299"><span class="linenos">1299</span></a> -</span><span id="Parser-1300"><a href="#Parser-1300"><span class="linenos">1300</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"COMPOUND"</span><span class="p">,</span> <span class="s2">"SORTKEY"</span><span class="p">):</span> -</span><span id="Parser-1301"><a href="#Parser-1301"><span class="linenos">1301</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_sortkey</span><span class="p">(</span><span class="n">compound</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-1302"><a href="#Parser-1302"><span class="linenos">1302</span></a> -</span><span id="Parser-1303"><a href="#Parser-1303"><span class="linenos">1303</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SQL"</span><span class="p">,</span> <span class="s2">"SECURITY"</span><span class="p">):</span> -</span><span id="Parser-1304"><a href="#Parser-1304"><span class="linenos">1304</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">SqlSecurityProperty</span><span class="p">,</span> <span class="n">definer</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFINER"</span><span class="p">))</span> -</span><span id="Parser-1305"><a href="#Parser-1305"><span class="linenos">1305</span></a> -</span><span id="Parser-1306"><a href="#Parser-1306"><span class="linenos">1306</span></a> <span class="n">assignment</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span> -</span><span id="Parser-1307"><a href="#Parser-1307"><span class="linenos">1307</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span> -</span><span id="Parser-1308"><a href="#Parser-1308"><span class="linenos">1308</span></a> <span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</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="Parser-1309"><a href="#Parser-1309"><span class="linenos">1309</span></a> -</span><span id="Parser-1310"><a href="#Parser-1310"><span class="linenos">1310</span></a> <span class="k">if</span> <span class="n">assignment</span><span class="p">:</span> -</span><span id="Parser-1311"><a href="#Parser-1311"><span class="linenos">1311</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var_or_string</span><span class="p">()</span> -</span><span id="Parser-1312"><a href="#Parser-1312"><span class="linenos">1312</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="Parser-1313"><a href="#Parser-1313"><span class="linenos">1313</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">Property</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">())</span> -</span><span id="Parser-1314"><a href="#Parser-1314"><span class="linenos">1314</span></a> -</span><span id="Parser-1315"><a href="#Parser-1315"><span class="linenos">1315</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-1316"><a href="#Parser-1316"><span class="linenos">1316</span></a> -</span><span id="Parser-1317"><a href="#Parser-1317"><span class="linenos">1317</span></a> <span class="k">def</span> <span class="nf">_parse_stored</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">FileFormatProperty</span><span class="p">:</span> -</span><span id="Parser-1318"><a href="#Parser-1318"><span class="linenos">1318</span></a> <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">ALIAS</span><span class="p">)</span> -</span><span id="Parser-1319"><a href="#Parser-1319"><span class="linenos">1319</span></a> -</span><span id="Parser-1320"><a href="#Parser-1320"><span class="linenos">1320</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INPUTFORMAT"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="Parser-1321"><a href="#Parser-1321"><span class="linenos">1321</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OUTPUTFORMAT"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="Parser-1322"><a href="#Parser-1322"><span class="linenos">1322</span></a> -</span><span id="Parser-1323"><a href="#Parser-1323"><span class="linenos">1323</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><span id="Parser-1324"><a href="#Parser-1324"><span class="linenos">1324</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">,</span> -</span><span id="Parser-1325"><a href="#Parser-1325"><span class="linenos">1325</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-1326"><a href="#Parser-1326"><span class="linenos">1326</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">,</span> <span class="n">input_format</span><span class="o">=</span><span class="n">input_format</span><span class="p">,</span> <span class="n">output_format</span><span class="o">=</span><span class="n">output_format</span> -</span><span id="Parser-1327"><a href="#Parser-1327"><span class="linenos">1327</span></a> <span class="p">)</span> -</span><span id="Parser-1328"><a href="#Parser-1328"><span class="linenos">1328</span></a> <span class="k">if</span> <span class="n">input_format</span> <span class="ow">or</span> <span class="n">output_format</span> -</span><span id="Parser-1329"><a href="#Parser-1329"><span class="linenos">1329</span></a> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var_or_string</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(),</span> -</span><span id="Parser-1330"><a href="#Parser-1330"><span class="linenos">1330</span></a> <span class="p">)</span> -</span><span id="Parser-1331"><a href="#Parser-1331"><span class="linenos">1331</span></a> -</span><span id="Parser-1332"><a href="#Parser-1332"><span class="linenos">1332</span></a> <span class="k">def</span> <span class="nf">_parse_property_assignment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">])</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="Parser-1333"><a href="#Parser-1333"><span class="linenos">1333</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="Parser-1334"><a href="#Parser-1334"><span class="linenos">1334</span></a> <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">ALIAS</span><span class="p">)</span> -</span><span id="Parser-1335"><a href="#Parser-1335"><span class="linenos">1335</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_class</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_field</span><span class="p">())</span> -</span><span id="Parser-1336"><a href="#Parser-1336"><span class="linenos">1336</span></a> -</span><span id="Parser-1337"><a href="#Parser-1337"><span class="linenos">1337</span></a> <span class="k">def</span> <span class="nf">_parse_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">before</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span 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">Properties</span><span class="p">]:</span> -</span><span id="Parser-1338"><a href="#Parser-1338"><span class="linenos">1338</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-1339"><a href="#Parser-1339"><span class="linenos">1339</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Parser-1340"><a href="#Parser-1340"><span class="linenos">1340</span></a> <span class="k">if</span> <span class="n">before</span><span class="p">:</span> -</span><span id="Parser-1341"><a href="#Parser-1341"><span class="linenos">1341</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_property_before</span><span class="p">()</span> -</span><span id="Parser-1342"><a href="#Parser-1342"><span class="linenos">1342</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1343"><a href="#Parser-1343"><span class="linenos">1343</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_property</span><span class="p">()</span> -</span><span id="Parser-1344"><a href="#Parser-1344"><span class="linenos">1344</span></a> -</span><span id="Parser-1345"><a href="#Parser-1345"><span class="linenos">1345</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">prop</span><span class="p">:</span> -</span><span id="Parser-1346"><a href="#Parser-1346"><span class="linenos">1346</span></a> <span class="k">break</span> -</span><span id="Parser-1347"><a href="#Parser-1347"><span class="linenos">1347</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">prop</span><span class="p">):</span> -</span><span id="Parser-1348"><a href="#Parser-1348"><span class="linenos">1348</span></a> <span class="n">properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> -</span><span id="Parser-1349"><a href="#Parser-1349"><span class="linenos">1349</span></a> -</span><span id="Parser-1350"><a href="#Parser-1350"><span class="linenos">1350</span></a> <span class="k">if</span> <span class="n">properties</span><span class="p">:</span> -</span><span id="Parser-1351"><a href="#Parser-1351"><span class="linenos">1351</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">Properties</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">properties</span><span class="p">)</span> -</span><span id="Parser-1352"><a href="#Parser-1352"><span class="linenos">1352</span></a> -</span><span id="Parser-1353"><a href="#Parser-1353"><span class="linenos">1353</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-1354"><a href="#Parser-1354"><span class="linenos">1354</span></a> -</span><span id="Parser-1355"><a href="#Parser-1355"><span class="linenos">1355</span></a> <span class="k">def</span> <span class="nf">_parse_fallback</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">no</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">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">:</span> -</span><span id="Parser-1356"><a href="#Parser-1356"><span class="linenos">1356</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><span id="Parser-1357"><a href="#Parser-1357"><span class="linenos">1357</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">,</span> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">,</span> <span class="n">protection</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PROTECTION"</span><span class="p">)</span> -</span><span id="Parser-1358"><a href="#Parser-1358"><span class="linenos">1358</span></a> <span class="p">)</span> -</span><span id="Parser-1359"><a href="#Parser-1359"><span class="linenos">1359</span></a> -</span><span id="Parser-1360"><a href="#Parser-1360"><span class="linenos">1360</span></a> <span class="k">def</span> <span class="nf">_parse_volatile_property</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">VolatileProperty</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> -</span><span id="Parser-1361"><a href="#Parser-1361"><span class="linenos">1361</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">>=</span> <span class="mi">2</span><span class="p">:</span> -</span><span id="Parser-1362"><a href="#Parser-1362"><span class="linenos">1362</span></a> <span class="n">pre_volatile_token</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">2</span><span class="p">]</span> -</span><span id="Parser-1363"><a href="#Parser-1363"><span class="linenos">1363</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1364"><a href="#Parser-1364"><span class="linenos">1364</span></a> <span class="n">pre_volatile_token</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1365"><a href="#Parser-1365"><span class="linenos">1365</span></a> -</span><span id="Parser-1366"><a href="#Parser-1366"><span class="linenos">1366</span></a> <span class="k">if</span> <span class="n">pre_volatile_token</span> <span class="ow">and</span> <span class="n">pre_volatile_token</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRE_VOLATILE_TOKENS</span><span class="p">:</span> -</span><span id="Parser-1367"><a href="#Parser-1367"><span class="linenos">1367</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">()</span> -</span><span id="Parser-1368"><a href="#Parser-1368"><span class="linenos">1368</span></a> -</span><span id="Parser-1369"><a href="#Parser-1369"><span class="linenos">1369</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">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"VOLATILE"</span><span class="p">))</span> -</span><span id="Parser-1370"><a href="#Parser-1370"><span class="linenos">1370</span></a> -</span><span id="Parser-1371"><a href="#Parser-1371"><span class="linenos">1371</span></a> <span class="k">def</span> <span class="nf">_parse_with_property</span><span class="p">(</span> -</span><span id="Parser-1372"><a href="#Parser-1372"><span class="linenos">1372</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Parser-1373"><a href="#Parser-1373"><span class="linenos">1373</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 class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">List</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><span id="Parser-1374"><a href="#Parser-1374"><span class="linenos">1374</span></a> <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">WITH</span><span class="p">)</span> -</span><span id="Parser-1375"><a href="#Parser-1375"><span class="linenos">1375</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_PAREN</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="Parser-1376"><a href="#Parser-1376"><span class="linenos">1376</span></a> <span class="k">return</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_property</span><span class="p">)</span> -</span><span id="Parser-1377"><a href="#Parser-1377"><span class="linenos">1377</span></a> -</span><span id="Parser-1378"><a href="#Parser-1378"><span class="linenos">1378</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"JOURNAL"</span><span class="p">):</span> -</span><span id="Parser-1379"><a href="#Parser-1379"><span class="linenos">1379</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_withjournaltable</span><span class="p">()</span> -</span><span id="Parser-1380"><a href="#Parser-1380"><span class="linenos">1380</span></a> -</span><span id="Parser-1381"><a href="#Parser-1381"><span class="linenos">1381</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DATA"</span><span class="p">):</span> -</span><span id="Parser-1382"><a href="#Parser-1382"><span class="linenos">1382</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_withdata</span><span class="p">(</span><span class="n">no</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Parser-1383"><a href="#Parser-1383"><span class="linenos">1383</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"DATA"</span><span class="p">):</span> -</span><span id="Parser-1384"><a href="#Parser-1384"><span class="linenos">1384</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_withdata</span><span class="p">(</span><span class="n">no</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-1385"><a href="#Parser-1385"><span class="linenos">1385</span></a> -</span><span id="Parser-1386"><a href="#Parser-1386"><span class="linenos">1386</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> -</span><span id="Parser-1387"><a href="#Parser-1387"><span class="linenos">1387</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-1388"><a href="#Parser-1388"><span class="linenos">1388</span></a> -</span><span id="Parser-1389"><a href="#Parser-1389"><span class="linenos">1389</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_withisolatedloading</span><span class="p">()</span> -</span><span id="Parser-1390"><a href="#Parser-1390"><span class="linenos">1390</span></a> -</span><span id="Parser-1391"><a href="#Parser-1391"><span class="linenos">1391</span></a> <span class="c1"># https://dev.mysql.com/doc/refman/8.0/en/create-view.html</span> -</span><span id="Parser-1392"><a href="#Parser-1392"><span class="linenos">1392</span></a> <span class="k">def</span> <span class="nf">_parse_definer</span><span class="p">(</span><span class="bp">self</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">DefinerProperty</span><span class="p">]:</span> -</span><span id="Parser-1393"><a href="#Parser-1393"><span class="linenos">1393</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="Parser-1394"><a href="#Parser-1394"><span class="linenos">1394</span></a> -</span><span id="Parser-1395"><a href="#Parser-1395"><span class="linenos">1395</span></a> <span class="n">user</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="Parser-1396"><a href="#Parser-1396"><span class="linenos">1396</span></a> <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">PARAMETER</span><span class="p">)</span> -</span><span id="Parser-1397"><a href="#Parser-1397"><span class="linenos">1397</span></a> <span class="n">host</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> <span class="ow">or</span> <span class="p">(</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">MOD</span><span class="p">)</span> <span class="ow">and</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="Parser-1398"><a href="#Parser-1398"><span class="linenos">1398</span></a> -</span><span id="Parser-1399"><a href="#Parser-1399"><span class="linenos">1399</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">user</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">host</span><span class="p">:</span> -</span><span id="Parser-1400"><a href="#Parser-1400"><span class="linenos">1400</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-1401"><a href="#Parser-1401"><span class="linenos">1401</span></a> -</span><span id="Parser-1402"><a href="#Parser-1402"><span class="linenos">1402</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">DefinerProperty</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">user</span><span class="si">}</span><span class="s2">@</span><span class="si">{</span><span class="n">host</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Parser-1403"><a href="#Parser-1403"><span class="linenos">1403</span></a> -</span><span id="Parser-1404"><a href="#Parser-1404"><span class="linenos">1404</span></a> <span class="k">def</span> <span class="nf">_parse_withjournaltable</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">WithJournalTableProperty</span><span class="p">:</span> -</span><span id="Parser-1405"><a href="#Parser-1405"><span class="linenos">1405</span></a> <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">TABLE</span><span class="p">)</span> -</span><span id="Parser-1406"><a href="#Parser-1406"><span class="linenos">1406</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="Parser-1407"><a href="#Parser-1407"><span class="linenos">1407</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">WithJournalTableProperty</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_table_parts</span><span class="p">())</span> -</span><span id="Parser-1408"><a href="#Parser-1408"><span class="linenos">1408</span></a> -</span><span id="Parser-1409"><a href="#Parser-1409"><span class="linenos">1409</span></a> <span class="k">def</span> <span class="nf">_parse_log</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">no</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">exp</span><span class="o">.</span><span class="n">LogProperty</span><span class="p">:</span> -</span><span id="Parser-1410"><a href="#Parser-1410"><span class="linenos">1410</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">LogProperty</span><span class="p">,</span> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">)</span> -</span><span id="Parser-1411"><a href="#Parser-1411"><span class="linenos">1411</span></a> -</span><span id="Parser-1412"><a href="#Parser-1412"><span class="linenos">1412</span></a> <span class="k">def</span> <span class="nf">_parse_journal</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">:</span> -</span><span id="Parser-1413"><a href="#Parser-1413"><span class="linenos">1413</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">JournalProperty</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="Parser-1414"><a href="#Parser-1414"><span class="linenos">1414</span></a> -</span><span id="Parser-1415"><a href="#Parser-1415"><span class="linenos">1415</span></a> <span class="k">def</span> <span class="nf">_parse_checksum</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">ChecksumProperty</span><span class="p">:</span> -</span><span id="Parser-1416"><a href="#Parser-1416"><span class="linenos">1416</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="Parser-1417"><a href="#Parser-1417"><span class="linenos">1417</span></a> -</span><span id="Parser-1418"><a href="#Parser-1418"><span class="linenos">1418</span></a> <span class="n">on</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1419"><a href="#Parser-1419"><span class="linenos">1419</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">ON</span><span class="p">):</span> -</span><span id="Parser-1420"><a href="#Parser-1420"><span class="linenos">1420</span></a> <span class="n">on</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Parser-1421"><a href="#Parser-1421"><span class="linenos">1421</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OFF"</span><span class="p">):</span> -</span><span id="Parser-1422"><a href="#Parser-1422"><span class="linenos">1422</span></a> <span class="n">on</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-1423"><a href="#Parser-1423"><span class="linenos">1423</span></a> -</span><span id="Parser-1424"><a href="#Parser-1424"><span class="linenos">1424</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">ChecksumProperty</span><span class="p">,</span> <span class="n">on</span><span class="o">=</span><span class="n">on</span><span class="p">,</span> <span class="n">default</span><span class="o">=</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">DEFAULT</span><span class="p">))</span> -</span><span id="Parser-1425"><a href="#Parser-1425"><span class="linenos">1425</span></a> -</span><span id="Parser-1426"><a href="#Parser-1426"><span class="linenos">1426</span></a> <span class="k">def</span> <span class="nf">_parse_cluster</span><span class="p">(</span><span class="bp">self</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">Cluster</span><span class="p">]:</span> -</span><span id="Parser-1427"><a href="#Parser-1427"><span class="linenos">1427</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BY"</span><span class="p">):</span> -</span><span id="Parser-1428"><a href="#Parser-1428"><span class="linenos">1428</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="Parser-1429"><a href="#Parser-1429"><span class="linenos">1429</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-1430"><a href="#Parser-1430"><span class="linenos">1430</span></a> -</span><span id="Parser-1431"><a href="#Parser-1431"><span class="linenos">1431</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">Cluster</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_ordered</span><span class="p">))</span> -</span><span id="Parser-1432"><a href="#Parser-1432"><span class="linenos">1432</span></a> -</span><span id="Parser-1433"><a href="#Parser-1433"><span class="linenos">1433</span></a> <span class="k">def</span> <span class="nf">_parse_freespace</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">FreespaceProperty</span><span class="p">:</span> -</span><span id="Parser-1434"><a href="#Parser-1434"><span class="linenos">1434</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="Parser-1435"><a href="#Parser-1435"><span class="linenos">1435</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><span id="Parser-1436"><a href="#Parser-1436"><span class="linenos">1436</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</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_number</span><span class="p">(),</span> <span class="n">percent</span><span class="o">=</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">PERCENT</span><span class="p">)</span> -</span><span id="Parser-1437"><a href="#Parser-1437"><span class="linenos">1437</span></a> <span class="p">)</span> -</span><span id="Parser-1438"><a href="#Parser-1438"><span class="linenos">1438</span></a> -</span><span id="Parser-1439"><a href="#Parser-1439"><span class="linenos">1439</span></a> <span class="k">def</span> <span class="nf">_parse_mergeblockratio</span><span class="p">(</span> -</span><span id="Parser-1440"><a href="#Parser-1440"><span class="linenos">1440</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">no</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="n">default</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-1441"><a href="#Parser-1441"><span class="linenos">1441</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">:</span> -</span><span id="Parser-1442"><a href="#Parser-1442"><span class="linenos">1442</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">EQ</span><span class="p">):</span> -</span><span id="Parser-1443"><a href="#Parser-1443"><span class="linenos">1443</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><span id="Parser-1444"><a href="#Parser-1444"><span class="linenos">1444</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">,</span> -</span><span id="Parser-1445"><a href="#Parser-1445"><span class="linenos">1445</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">(),</span> -</span><span id="Parser-1446"><a href="#Parser-1446"><span class="linenos">1446</span></a> <span class="n">percent</span><span class="o">=</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">PERCENT</span><span class="p">),</span> -</span><span id="Parser-1447"><a href="#Parser-1447"><span class="linenos">1447</span></a> <span class="p">)</span> -</span><span id="Parser-1448"><a href="#Parser-1448"><span class="linenos">1448</span></a> -</span><span id="Parser-1449"><a href="#Parser-1449"><span class="linenos">1449</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">MergeBlockRatioProperty</span><span class="p">,</span> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">default</span><span class="p">)</span> -</span><span id="Parser-1450"><a href="#Parser-1450"><span class="linenos">1450</span></a> -</span><span id="Parser-1451"><a href="#Parser-1451"><span class="linenos">1451</span></a> <span class="k">def</span> <span class="nf">_parse_datablocksize</span><span class="p">(</span> -</span><span id="Parser-1452"><a href="#Parser-1452"><span class="linenos">1452</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Parser-1453"><a href="#Parser-1453"><span class="linenos">1453</span></a> <span class="n">default</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Parser-1454"><a href="#Parser-1454"><span class="linenos">1454</span></a> <span class="n">minimum</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Parser-1455"><a href="#Parser-1455"><span class="linenos">1455</span></a> <span class="n">maximum</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Parser-1456"><a href="#Parser-1456"><span class="linenos">1456</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">:</span> -</span><span id="Parser-1457"><a href="#Parser-1457"><span class="linenos">1457</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="Parser-1458"><a href="#Parser-1458"><span class="linenos">1458</span></a> <span class="n">size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> -</span><span id="Parser-1459"><a href="#Parser-1459"><span class="linenos">1459</span></a> -</span><span id="Parser-1460"><a href="#Parser-1460"><span class="linenos">1460</span></a> <span class="n">units</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1461"><a href="#Parser-1461"><span class="linenos">1461</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"BYTES"</span><span class="p">,</span> <span class="s2">"KBYTES"</span><span class="p">,</span> <span class="s2">"KILOBYTES"</span><span class="p">)):</span> -</span><span id="Parser-1462"><a href="#Parser-1462"><span class="linenos">1462</span></a> <span class="n">units</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><span id="Parser-591"><a href="#Parser-591"><span class="linenos"> 591</span></a> <span class="s2">"COPY"</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_copy_property</span><span class="p">(),</span> +</span><span id="Parser-592"><a href="#Parser-592"><span class="linenos"> 592</span></a> <span class="s2">"DATABLOCKSIZE"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_datablocksize</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> +</span><span id="Parser-593"><a href="#Parser-593"><span class="linenos"> 593</span></a> <span class="s2">"DEFINER"</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_definer</span><span class="p">(),</span> +</span><span id="Parser-594"><a href="#Parser-594"><span class="linenos"> 594</span></a> <span class="s2">"DETERMINISTIC"</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">expression</span><span class="p">(</span> +</span><span id="Parser-595"><a href="#Parser-595"><span class="linenos"> 595</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"IMMUTABLE"</span><span class="p">)</span> +</span><span id="Parser-596"><a href="#Parser-596"><span class="linenos"> 596</span></a> <span class="p">),</span> +</span><span id="Parser-597"><a href="#Parser-597"><span class="linenos"> 597</span></a> <span class="s2">"DISTKEY"</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_distkey</span><span class="p">(),</span> +</span><span id="Parser-598"><a href="#Parser-598"><span class="linenos"> 598</span></a> <span class="s2">"DISTSTYLE"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">DistStyleProperty</span><span class="p">),</span> +</span><span id="Parser-599"><a href="#Parser-599"><span class="linenos"> 599</span></a> <span class="s2">"ENGINE"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">EngineProperty</span><span class="p">),</span> +</span><span id="Parser-600"><a href="#Parser-600"><span class="linenos"> 600</span></a> <span class="s2">"EXECUTE"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ExecuteAsProperty</span><span class="p">),</span> +</span><span id="Parser-601"><a href="#Parser-601"><span class="linenos"> 601</span></a> <span class="s2">"EXTERNAL"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">ExternalProperty</span><span class="p">),</span> +</span><span id="Parser-602"><a href="#Parser-602"><span class="linenos"> 602</span></a> <span class="s2">"FALLBACK"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_fallback</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> +</span><span id="Parser-603"><a href="#Parser-603"><span class="linenos"> 603</span></a> <span class="s2">"FORMAT"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">),</span> +</span><span id="Parser-604"><a href="#Parser-604"><span class="linenos"> 604</span></a> <span class="s2">"FREESPACE"</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_freespace</span><span class="p">(),</span> +</span><span id="Parser-605"><a href="#Parser-605"><span class="linenos"> 605</span></a> <span class="s2">"IMMUTABLE"</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">expression</span><span class="p">(</span> +</span><span id="Parser-606"><a href="#Parser-606"><span class="linenos"> 606</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"IMMUTABLE"</span><span class="p">)</span> +</span><span id="Parser-607"><a href="#Parser-607"><span class="linenos"> 607</span></a> <span class="p">),</span> +</span><span id="Parser-608"><a href="#Parser-608"><span class="linenos"> 608</span></a> <span class="s2">"JOURNAL"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_journal</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> +</span><span id="Parser-609"><a href="#Parser-609"><span class="linenos"> 609</span></a> <span class="s2">"LANGUAGE"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LanguageProperty</span><span class="p">),</span> +</span><span id="Parser-610"><a href="#Parser-610"><span class="linenos"> 610</span></a> <span class="s2">"LAYOUT"</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_dict_property</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"LAYOUT"</span><span class="p">),</span> +</span><span id="Parser-611"><a href="#Parser-611"><span class="linenos"> 611</span></a> <span class="s2">"LIFETIME"</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_dict_range</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"LIFETIME"</span><span class="p">),</span> +</span><span id="Parser-612"><a href="#Parser-612"><span class="linenos"> 612</span></a> <span class="s2">"LIKE"</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_create_like</span><span class="p">(),</span> +</span><span id="Parser-613"><a href="#Parser-613"><span class="linenos"> 613</span></a> <span class="s2">"LOCATION"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">LocationProperty</span><span class="p">),</span> +</span><span id="Parser-614"><a href="#Parser-614"><span class="linenos"> 614</span></a> <span class="s2">"LOCK"</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_locking</span><span class="p">(),</span> +</span><span id="Parser-615"><a href="#Parser-615"><span class="linenos"> 615</span></a> <span class="s2">"LOCKING"</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_locking</span><span class="p">(),</span> +</span><span id="Parser-616"><a href="#Parser-616"><span class="linenos"> 616</span></a> <span class="s2">"LOG"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_log</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> +</span><span id="Parser-617"><a href="#Parser-617"><span class="linenos"> 617</span></a> <span class="s2">"MATERIALIZED"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">MaterializedProperty</span><span class="p">),</span> +</span><span id="Parser-618"><a href="#Parser-618"><span class="linenos"> 618</span></a> <span class="s2">"MERGEBLOCKRATIO"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_mergeblockratio</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">),</span> +</span><span id="Parser-619"><a href="#Parser-619"><span class="linenos"> 619</span></a> <span class="s2">"MULTISET"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">,</span> <span class="n">multi</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="Parser-620"><a href="#Parser-620"><span class="linenos"> 620</span></a> <span class="s2">"NO"</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_no_property</span><span class="p">(),</span> +</span><span id="Parser-621"><a href="#Parser-621"><span class="linenos"> 621</span></a> <span class="s2">"ON"</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_on_property</span><span class="p">(),</span> +</span><span id="Parser-622"><a href="#Parser-622"><span class="linenos"> 622</span></a> <span class="s2">"ORDER BY"</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_order</span><span class="p">(</span><span class="n">skip_order_token</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="Parser-623"><a href="#Parser-623"><span class="linenos"> 623</span></a> <span class="s2">"PARTITION BY"</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_partitioned_by</span><span class="p">(),</span> +</span><span id="Parser-624"><a href="#Parser-624"><span class="linenos"> 624</span></a> <span class="s2">"PARTITIONED BY"</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_partitioned_by</span><span class="p">(),</span> +</span><span id="Parser-625"><a href="#Parser-625"><span class="linenos"> 625</span></a> <span class="s2">"PARTITIONED_BY"</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_partitioned_by</span><span class="p">(),</span> +</span><span id="Parser-626"><a href="#Parser-626"><span class="linenos"> 626</span></a> <span class="s2">"PRIMARY KEY"</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_primary_key</span><span class="p">(</span><span class="n">in_props</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="Parser-627"><a href="#Parser-627"><span class="linenos"> 627</span></a> <span class="s2">"RANGE"</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_dict_range</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"RANGE"</span><span class="p">),</span> +</span><span id="Parser-628"><a href="#Parser-628"><span class="linenos"> 628</span></a> <span class="s2">"RETURNS"</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_returns</span><span class="p">(),</span> +</span><span id="Parser-629"><a href="#Parser-629"><span class="linenos"> 629</span></a> <span class="s2">"ROW"</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_row</span><span class="p">(),</span> +</span><span id="Parser-630"><a href="#Parser-630"><span class="linenos"> 630</span></a> <span class="s2">"ROW_FORMAT"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">RowFormatProperty</span><span class="p">),</span> +</span><span id="Parser-631"><a href="#Parser-631"><span class="linenos"> 631</span></a> <span class="s2">"SET"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">SetProperty</span><span class="p">,</span> <span class="n">multi</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="Parser-632"><a href="#Parser-632"><span class="linenos"> 632</span></a> <span class="s2">"SETTINGS"</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">expression</span><span class="p">(</span> +</span><span id="Parser-633"><a href="#Parser-633"><span class="linenos"> 633</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SettingsProperty</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_item</span><span class="p">)</span> +</span><span id="Parser-634"><a href="#Parser-634"><span class="linenos"> 634</span></a> <span class="p">),</span> +</span><span id="Parser-635"><a href="#Parser-635"><span class="linenos"> 635</span></a> <span class="s2">"SORTKEY"</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_sortkey</span><span class="p">(),</span> +</span><span id="Parser-636"><a href="#Parser-636"><span class="linenos"> 636</span></a> <span class="s2">"SOURCE"</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_dict_property</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="s2">"SOURCE"</span><span class="p">),</span> +</span><span id="Parser-637"><a href="#Parser-637"><span class="linenos"> 637</span></a> <span class="s2">"STABLE"</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">expression</span><span class="p">(</span> +</span><span id="Parser-638"><a href="#Parser-638"><span class="linenos"> 638</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"STABLE"</span><span class="p">)</span> +</span><span id="Parser-639"><a href="#Parser-639"><span class="linenos"> 639</span></a> <span class="p">),</span> +</span><span id="Parser-640"><a href="#Parser-640"><span class="linenos"> 640</span></a> <span class="s2">"STORED"</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_stored</span><span class="p">(),</span> +</span><span id="Parser-641"><a href="#Parser-641"><span class="linenos"> 641</span></a> <span class="s2">"TBLPROPERTIES"</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_wrapped_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_property</span><span class="p">),</span> +</span><span id="Parser-642"><a href="#Parser-642"><span class="linenos"> 642</span></a> <span class="s2">"TEMP"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">),</span> +</span><span id="Parser-643"><a href="#Parser-643"><span class="linenos"> 643</span></a> <span class="s2">"TEMPORARY"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TemporaryProperty</span><span class="p">),</span> +</span><span id="Parser-644"><a href="#Parser-644"><span class="linenos"> 644</span></a> <span class="s2">"TO"</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_to_table</span><span class="p">(),</span> +</span><span id="Parser-645"><a href="#Parser-645"><span class="linenos"> 645</span></a> <span class="s2">"TRANSIENT"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">TransientProperty</span><span class="p">),</span> +</span><span id="Parser-646"><a href="#Parser-646"><span class="linenos"> 646</span></a> <span class="s2">"TTL"</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_ttl</span><span class="p">(),</span> +</span><span id="Parser-647"><a href="#Parser-647"><span class="linenos"> 647</span></a> <span class="s2">"USING"</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_property_assignment</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">),</span> +</span><span id="Parser-648"><a href="#Parser-648"><span class="linenos"> 648</span></a> <span class="s2">"VOLATILE"</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_volatile_property</span><span class="p">(),</span> +</span><span id="Parser-649"><a href="#Parser-649"><span class="linenos"> 649</span></a> <span class="s2">"WITH"</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_with_property</span><span class="p">(),</span> +</span><span id="Parser-650"><a href="#Parser-650"><span class="linenos"> 650</span></a> <span class="p">}</span> +</span><span id="Parser-651"><a href="#Parser-651"><span class="linenos"> 651</span></a> +</span><span id="Parser-652"><a href="#Parser-652"><span class="linenos"> 652</span></a> <span class="n">CONSTRAINT_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Parser-653"><a href="#Parser-653"><span class="linenos"> 653</span></a> <span class="s2">"AUTOINCREMENT"</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_auto_increment</span><span class="p">(),</span> +</span><span id="Parser-654"><a href="#Parser-654"><span class="linenos"> 654</span></a> <span class="s2">"AUTO_INCREMENT"</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_auto_increment</span><span class="p">(),</span> +</span><span id="Parser-655"><a href="#Parser-655"><span class="linenos"> 655</span></a> <span class="s2">"CASESPECIFIC"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">CaseSpecificColumnConstraint</span><span class="p">,</span> <span class="n">not_</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="Parser-656"><a href="#Parser-656"><span class="linenos"> 656</span></a> <span class="s2">"CHARACTER SET"</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">expression</span><span class="p">(</span> +</span><span id="Parser-657"><a href="#Parser-657"><span class="linenos"> 657</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetColumnConstraint</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_var_or_string</span><span class="p">()</span> +</span><span id="Parser-658"><a href="#Parser-658"><span class="linenos"> 658</span></a> <span class="p">),</span> +</span><span id="Parser-659"><a href="#Parser-659"><span class="linenos"> 659</span></a> <span class="s2">"CHECK"</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">expression</span><span class="p">(</span> +</span><span id="Parser-660"><a href="#Parser-660"><span class="linenos"> 660</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CheckColumnConstraint</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_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="Parser-661"><a href="#Parser-661"><span class="linenos"> 661</span></a> <span class="p">),</span> +</span><span id="Parser-662"><a href="#Parser-662"><span class="linenos"> 662</span></a> <span class="s2">"COLLATE"</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">expression</span><span class="p">(</span> +</span><span id="Parser-663"><a href="#Parser-663"><span class="linenos"> 663</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CollateColumnConstraint</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_var</span><span class="p">()</span> +</span><span id="Parser-664"><a href="#Parser-664"><span class="linenos"> 664</span></a> <span class="p">),</span> +</span><span id="Parser-665"><a href="#Parser-665"><span class="linenos"> 665</span></a> <span class="s2">"COMMENT"</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">expression</span><span class="p">(</span> +</span><span id="Parser-666"><a href="#Parser-666"><span class="linenos"> 666</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CommentColumnConstraint</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_string</span><span class="p">()</span> +</span><span id="Parser-667"><a href="#Parser-667"><span class="linenos"> 667</span></a> <span class="p">),</span> +</span><span id="Parser-668"><a href="#Parser-668"><span class="linenos"> 668</span></a> <span class="s2">"COMPRESS"</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_compress</span><span class="p">(),</span> +</span><span id="Parser-669"><a href="#Parser-669"><span class="linenos"> 669</span></a> <span class="s2">"DEFAULT"</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">expression</span><span class="p">(</span> +</span><span id="Parser-670"><a href="#Parser-670"><span class="linenos"> 670</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DefaultColumnConstraint</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_bitwise</span><span class="p">()</span> +</span><span id="Parser-671"><a href="#Parser-671"><span class="linenos"> 671</span></a> <span class="p">),</span> +</span><span id="Parser-672"><a href="#Parser-672"><span class="linenos"> 672</span></a> <span class="s2">"ENCODE"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">EncodeColumnConstraint</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_var</span><span class="p">()),</span> +</span><span id="Parser-673"><a href="#Parser-673"><span class="linenos"> 673</span></a> <span class="s2">"FOREIGN KEY"</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_foreign_key</span><span class="p">(),</span> +</span><span id="Parser-674"><a href="#Parser-674"><span class="linenos"> 674</span></a> <span class="s2">"FORMAT"</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">expression</span><span class="p">(</span> +</span><span id="Parser-675"><a href="#Parser-675"><span class="linenos"> 675</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DateFormatColumnConstraint</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_var_or_string</span><span class="p">()</span> +</span><span id="Parser-676"><a href="#Parser-676"><span class="linenos"> 676</span></a> <span class="p">),</span> +</span><span id="Parser-677"><a href="#Parser-677"><span class="linenos"> 677</span></a> <span class="s2">"GENERATED"</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_generated_as_identity</span><span class="p">(),</span> +</span><span id="Parser-678"><a href="#Parser-678"><span class="linenos"> 678</span></a> <span class="s2">"IDENTITY"</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_auto_increment</span><span class="p">(),</span> +</span><span id="Parser-679"><a href="#Parser-679"><span class="linenos"> 679</span></a> <span class="s2">"INLINE"</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_inline</span><span class="p">(),</span> +</span><span id="Parser-680"><a href="#Parser-680"><span class="linenos"> 680</span></a> <span class="s2">"LIKE"</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_create_like</span><span class="p">(),</span> +</span><span id="Parser-681"><a href="#Parser-681"><span class="linenos"> 681</span></a> <span class="s2">"NOT"</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_not_constraint</span><span class="p">(),</span> +</span><span id="Parser-682"><a href="#Parser-682"><span class="linenos"> 682</span></a> <span class="s2">"NULL"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">NotNullColumnConstraint</span><span class="p">,</span> <span class="n">allow_null</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="Parser-683"><a href="#Parser-683"><span class="linenos"> 683</span></a> <span class="s2">"ON"</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">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">UPDATE</span><span class="p">)</span> +</span><span id="Parser-684"><a href="#Parser-684"><span class="linenos"> 684</span></a> <span class="ow">and</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">OnUpdateColumnConstraint</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_function</span><span class="p">()),</span> +</span><span id="Parser-685"><a href="#Parser-685"><span class="linenos"> 685</span></a> <span class="s2">"PATH"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">PathColumnConstraint</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_string</span><span class="p">()),</span> +</span><span id="Parser-686"><a href="#Parser-686"><span class="linenos"> 686</span></a> <span class="s2">"PRIMARY KEY"</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_primary_key</span><span class="p">(),</span> +</span><span id="Parser-687"><a href="#Parser-687"><span class="linenos"> 687</span></a> <span class="s2">"REFERENCES"</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_references</span><span class="p">(</span><span class="n">match</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="Parser-688"><a href="#Parser-688"><span class="linenos"> 688</span></a> <span class="s2">"TITLE"</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">expression</span><span class="p">(</span> +</span><span id="Parser-689"><a href="#Parser-689"><span class="linenos"> 689</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TitleColumnConstraint</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_var_or_string</span><span class="p">()</span> +</span><span id="Parser-690"><a href="#Parser-690"><span class="linenos"> 690</span></a> <span class="p">),</span> +</span><span id="Parser-691"><a href="#Parser-691"><span class="linenos"> 691</span></a> <span class="s2">"TTL"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()]),</span> +</span><span id="Parser-692"><a href="#Parser-692"><span class="linenos"> 692</span></a> <span class="s2">"UNIQUE"</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_unique</span><span class="p">(),</span> +</span><span id="Parser-693"><a href="#Parser-693"><span class="linenos"> 693</span></a> <span class="s2">"UPPERCASE"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">UppercaseColumnConstraint</span><span class="p">),</span> +</span><span id="Parser-694"><a href="#Parser-694"><span class="linenos"> 694</span></a> <span class="p">}</span> +</span><span id="Parser-695"><a href="#Parser-695"><span class="linenos"> 695</span></a> +</span><span id="Parser-696"><a href="#Parser-696"><span class="linenos"> 696</span></a> <span class="n">ALTER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Parser-697"><a href="#Parser-697"><span class="linenos"> 697</span></a> <span class="s2">"ADD"</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_alter_table_add</span><span class="p">(),</span> +</span><span id="Parser-698"><a href="#Parser-698"><span class="linenos"> 698</span></a> <span class="s2">"ALTER"</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_alter_table_alter</span><span class="p">(),</span> +</span><span id="Parser-699"><a href="#Parser-699"><span class="linenos"> 699</span></a> <span class="s2">"DELETE"</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">,</span> <span class="n">where</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">()),</span> +</span><span id="Parser-700"><a href="#Parser-700"><span class="linenos"> 700</span></a> <span class="s2">"DROP"</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_alter_table_drop</span><span class="p">(),</span> +</span><span id="Parser-701"><a href="#Parser-701"><span class="linenos"> 701</span></a> <span class="s2">"RENAME"</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_alter_table_rename</span><span class="p">(),</span> +</span><span id="Parser-702"><a href="#Parser-702"><span class="linenos"> 702</span></a> <span class="p">}</span> +</span><span id="Parser-703"><a href="#Parser-703"><span class="linenos"> 703</span></a> +</span><span id="Parser-704"><a href="#Parser-704"><span class="linenos"> 704</span></a> <span class="n">SCHEMA_UNNAMED_CONSTRAINTS</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"CHECK"</span><span class="p">,</span> <span class="s2">"FOREIGN KEY"</span><span class="p">,</span> <span class="s2">"LIKE"</span><span class="p">,</span> <span class="s2">"PRIMARY KEY"</span><span class="p">,</span> <span class="s2">"UNIQUE"</span><span class="p">}</span> +</span><span id="Parser-705"><a href="#Parser-705"><span class="linenos"> 705</span></a> +</span><span id="Parser-706"><a href="#Parser-706"><span class="linenos"> 706</span></a> <span class="n">NO_PAREN_FUNCTION_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Parser-707"><a href="#Parser-707"><span class="linenos"> 707</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">ANY</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">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Any</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()),</span> +</span><span id="Parser-708"><a href="#Parser-708"><span class="linenos"> 708</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">CASE</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_case</span><span class="p">(),</span> +</span><span id="Parser-709"><a href="#Parser-709"><span class="linenos"> 709</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">IF</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_if</span><span class="p">(),</span> +</span><span id="Parser-710"><a href="#Parser-710"><span class="linenos"> 710</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEXT_VALUE_FOR</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">expression</span><span class="p">(</span> +</span><span id="Parser-711"><a href="#Parser-711"><span class="linenos"> 711</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">NextValueFor</span><span class="p">,</span> +</span><span id="Parser-712"><a href="#Parser-712"><span class="linenos"> 712</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">(),</span> +</span><span id="Parser-713"><a href="#Parser-713"><span class="linenos"> 713</span></a> <span class="n">order</span><span class="o">=</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">OVER</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">),</span> +</span><span id="Parser-714"><a href="#Parser-714"><span class="linenos"> 714</span></a> <span class="p">),</span> +</span><span id="Parser-715"><a href="#Parser-715"><span class="linenos"> 715</span></a> <span class="p">}</span> +</span><span id="Parser-716"><a href="#Parser-716"><span class="linenos"> 716</span></a> +</span><span id="Parser-717"><a href="#Parser-717"><span class="linenos"> 717</span></a> <span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"STRUCT"</span><span class="p">}</span> +</span><span id="Parser-718"><a href="#Parser-718"><span class="linenos"> 718</span></a> +</span><span id="Parser-719"><a href="#Parser-719"><span class="linenos"> 719</span></a> <span class="n">FUNCTION_PARSERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Parser-720"><a href="#Parser-720"><span class="linenos"> 720</span></a> <span class="s2">"CAST"</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_cast</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STRICT_CAST</span><span class="p">),</span> +</span><span id="Parser-721"><a href="#Parser-721"><span class="linenos"> 721</span></a> <span class="s2">"CONCAT"</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_concat</span><span class="p">(),</span> +</span><span id="Parser-722"><a href="#Parser-722"><span class="linenos"> 722</span></a> <span class="s2">"CONVERT"</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_convert</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">STRICT_CAST</span><span class="p">),</span> +</span><span id="Parser-723"><a href="#Parser-723"><span class="linenos"> 723</span></a> <span class="s2">"DECODE"</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_decode</span><span class="p">(),</span> +</span><span id="Parser-724"><a href="#Parser-724"><span class="linenos"> 724</span></a> <span class="s2">"EXTRACT"</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_extract</span><span class="p">(),</span> +</span><span id="Parser-725"><a href="#Parser-725"><span class="linenos"> 725</span></a> <span class="s2">"JSON_OBJECT"</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_json_object</span><span class="p">(),</span> +</span><span id="Parser-726"><a href="#Parser-726"><span class="linenos"> 726</span></a> <span class="s2">"LOG"</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_logarithm</span><span class="p">(),</span> +</span><span id="Parser-727"><a href="#Parser-727"><span class="linenos"> 727</span></a> <span class="s2">"MATCH"</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_match_against</span><span class="p">(),</span> +</span><span id="Parser-728"><a href="#Parser-728"><span class="linenos"> 728</span></a> <span class="s2">"OPENJSON"</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_open_json</span><span class="p">(),</span> +</span><span id="Parser-729"><a href="#Parser-729"><span class="linenos"> 729</span></a> <span class="s2">"POSITION"</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_position</span><span class="p">(),</span> +</span><span id="Parser-730"><a href="#Parser-730"><span class="linenos"> 730</span></a> <span class="s2">"SAFE_CAST"</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_cast</span><span class="p">(</span><span class="kc">False</span><span class="p">),</span> +</span><span id="Parser-731"><a href="#Parser-731"><span class="linenos"> 731</span></a> <span class="s2">"STRING_AGG"</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_string_agg</span><span class="p">(),</span> +</span><span id="Parser-732"><a href="#Parser-732"><span class="linenos"> 732</span></a> <span class="s2">"SUBSTRING"</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_substring</span><span class="p">(),</span> +</span><span id="Parser-733"><a href="#Parser-733"><span class="linenos"> 733</span></a> <span class="s2">"TRIM"</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_trim</span><span class="p">(),</span> +</span><span id="Parser-734"><a href="#Parser-734"><span class="linenos"> 734</span></a> <span class="s2">"TRY_CAST"</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_cast</span><span class="p">(</span><span class="kc">False</span><span class="p">),</span> +</span><span id="Parser-735"><a href="#Parser-735"><span class="linenos"> 735</span></a> <span class="s2">"TRY_CONVERT"</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_convert</span><span class="p">(</span><span class="kc">False</span><span class="p">),</span> +</span><span id="Parser-736"><a href="#Parser-736"><span class="linenos"> 736</span></a> <span class="p">}</span> +</span><span id="Parser-737"><a href="#Parser-737"><span class="linenos"> 737</span></a> +</span><span id="Parser-738"><a href="#Parser-738"><span class="linenos"> 738</span></a> <span class="n">QUERY_MODIFIER_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Parser-739"><a href="#Parser-739"><span class="linenos"> 739</span></a> <span class="s2">"joins"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="nb">list</span><span class="p">(</span><span class="nb">iter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_join</span><span class="p">,</span> <span class="kc">None</span><span class="p">)),</span> +</span><span id="Parser-740"><a href="#Parser-740"><span class="linenos"> 740</span></a> <span class="s2">"laterals"</span><span class="p">:</span> <span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="nb">list</span><span class="p">(</span><span class="nb">iter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_lateral</span><span class="p">,</span> <span class="kc">None</span><span class="p">)),</span> +</span><span id="Parser-741"><a href="#Parser-741"><span class="linenos"> 741</span></a> <span class="s2">"match"</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_match_recognize</span><span class="p">(),</span> +</span><span id="Parser-742"><a href="#Parser-742"><span class="linenos"> 742</span></a> <span class="s2">"where"</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_where</span><span class="p">(),</span> +</span><span id="Parser-743"><a href="#Parser-743"><span class="linenos"> 743</span></a> <span class="s2">"group"</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_group</span><span class="p">(),</span> +</span><span id="Parser-744"><a href="#Parser-744"><span class="linenos"> 744</span></a> <span class="s2">"having"</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_having</span><span class="p">(),</span> +</span><span id="Parser-745"><a href="#Parser-745"><span class="linenos"> 745</span></a> <span class="s2">"qualify"</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_qualify</span><span class="p">(),</span> +</span><span id="Parser-746"><a href="#Parser-746"><span class="linenos"> 746</span></a> <span class="s2">"windows"</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_window_clause</span><span class="p">(),</span> +</span><span id="Parser-747"><a href="#Parser-747"><span class="linenos"> 747</span></a> <span class="s2">"order"</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_order</span><span class="p">(),</span> +</span><span id="Parser-748"><a href="#Parser-748"><span class="linenos"> 748</span></a> <span class="s2">"limit"</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_limit</span><span class="p">(),</span> +</span><span id="Parser-749"><a href="#Parser-749"><span class="linenos"> 749</span></a> <span class="s2">"offset"</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_offset</span><span class="p">(),</span> +</span><span id="Parser-750"><a href="#Parser-750"><span class="linenos"> 750</span></a> <span class="s2">"locks"</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_locks</span><span class="p">(),</span> +</span><span id="Parser-751"><a href="#Parser-751"><span class="linenos"> 751</span></a> <span class="s2">"sample"</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_table_sample</span><span class="p">(</span><span class="n">as_modifier</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="Parser-752"><a href="#Parser-752"><span class="linenos"> 752</span></a> <span class="p">}</span> +</span><span id="Parser-753"><a href="#Parser-753"><span class="linenos"> 753</span></a> +</span><span id="Parser-754"><a href="#Parser-754"><span class="linenos"> 754</span></a> <span class="n">SET_PARSERS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Parser-755"><a href="#Parser-755"><span class="linenos"> 755</span></a> <span class="s2">"GLOBAL"</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_set_item_assignment</span><span class="p">(</span><span class="s2">"GLOBAL"</span><span class="p">),</span> +</span><span id="Parser-756"><a href="#Parser-756"><span class="linenos"> 756</span></a> <span class="s2">"LOCAL"</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_set_item_assignment</span><span class="p">(</span><span class="s2">"LOCAL"</span><span class="p">),</span> +</span><span id="Parser-757"><a href="#Parser-757"><span class="linenos"> 757</span></a> <span class="s2">"SESSION"</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_set_item_assignment</span><span class="p">(</span><span class="s2">"SESSION"</span><span class="p">),</span> +</span><span id="Parser-758"><a href="#Parser-758"><span class="linenos"> 758</span></a> <span class="s2">"TRANSACTION"</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_set_transaction</span><span class="p">(),</span> +</span><span id="Parser-759"><a href="#Parser-759"><span class="linenos"> 759</span></a> <span class="p">}</span> +</span><span id="Parser-760"><a href="#Parser-760"><span class="linenos"> 760</span></a> +</span><span id="Parser-761"><a href="#Parser-761"><span class="linenos"> 761</span></a> <span class="n">SHOW_PARSERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Parser-762"><a href="#Parser-762"><span class="linenos"> 762</span></a> +</span><span id="Parser-763"><a href="#Parser-763"><span class="linenos"> 763</span></a> <span class="n">TYPE_LITERAL_PARSERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Parser-764"><a href="#Parser-764"><span class="linenos"> 764</span></a> +</span><span id="Parser-765"><a href="#Parser-765"><span class="linenos"> 765</span></a> <span class="n">MODIFIABLES</span> <span class="o">=</span> <span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> +</span><span id="Parser-766"><a href="#Parser-766"><span class="linenos"> 766</span></a> +</span><span id="Parser-767"><a href="#Parser-767"><span class="linenos"> 767</span></a> <span class="n">DDL_SELECT_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SELECT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">}</span> +</span><span id="Parser-768"><a href="#Parser-768"><span class="linenos"> 768</span></a> +</span><span id="Parser-769"><a href="#Parser-769"><span class="linenos"> 769</span></a> <span class="n">PRE_VOLATILE_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">CREATE</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNIQUE</span><span class="p">}</span> +</span><span id="Parser-770"><a href="#Parser-770"><span class="linenos"> 770</span></a> +</span><span id="Parser-771"><a href="#Parser-771"><span class="linenos"> 771</span></a> <span class="n">TRANSACTION_KIND</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"DEFERRED"</span><span class="p">,</span> <span class="s2">"IMMEDIATE"</span><span class="p">,</span> <span class="s2">"EXCLUSIVE"</span><span class="p">}</span> +</span><span id="Parser-772"><a href="#Parser-772"><span class="linenos"> 772</span></a> <span class="n">TRANSACTION_CHARACTERISTICS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Parser-773"><a href="#Parser-773"><span class="linenos"> 773</span></a> <span class="s2">"ISOLATION LEVEL REPEATABLE READ"</span><span class="p">,</span> +</span><span id="Parser-774"><a href="#Parser-774"><span class="linenos"> 774</span></a> <span class="s2">"ISOLATION LEVEL READ COMMITTED"</span><span class="p">,</span> +</span><span id="Parser-775"><a href="#Parser-775"><span class="linenos"> 775</span></a> <span class="s2">"ISOLATION LEVEL READ UNCOMMITTED"</span><span class="p">,</span> +</span><span id="Parser-776"><a href="#Parser-776"><span class="linenos"> 776</span></a> <span class="s2">"ISOLATION LEVEL SERIALIZABLE"</span><span class="p">,</span> +</span><span id="Parser-777"><a href="#Parser-777"><span class="linenos"> 777</span></a> <span class="s2">"READ WRITE"</span><span class="p">,</span> +</span><span id="Parser-778"><a href="#Parser-778"><span class="linenos"> 778</span></a> <span class="s2">"READ ONLY"</span><span class="p">,</span> +</span><span id="Parser-779"><a href="#Parser-779"><span class="linenos"> 779</span></a> <span class="p">}</span> +</span><span id="Parser-780"><a href="#Parser-780"><span class="linenos"> 780</span></a> +</span><span id="Parser-781"><a href="#Parser-781"><span class="linenos"> 781</span></a> <span class="n">INSERT_ALTERNATIVES</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"ABORT"</span><span class="p">,</span> <span class="s2">"FAIL"</span><span class="p">,</span> <span class="s2">"IGNORE"</span><span class="p">,</span> <span class="s2">"REPLACE"</span><span class="p">,</span> <span class="s2">"ROLLBACK"</span><span class="p">}</span> +</span><span id="Parser-782"><a href="#Parser-782"><span class="linenos"> 782</span></a> +</span><span id="Parser-783"><a href="#Parser-783"><span class="linenos"> 783</span></a> <span class="n">CLONE_KINDS</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"TIMESTAMP"</span><span class="p">,</span> <span class="s2">"OFFSET"</span><span class="p">,</span> <span class="s2">"STATEMENT"</span><span class="p">}</span> +</span><span id="Parser-784"><a href="#Parser-784"><span class="linenos"> 784</span></a> +</span><span id="Parser-785"><a href="#Parser-785"><span class="linenos"> 785</span></a> <span class="n">WINDOW_ALIAS_TOKENS</span> <span class="o">=</span> <span class="n">ID_VAR_TOKENS</span> <span class="o">-</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">}</span> +</span><span id="Parser-786"><a href="#Parser-786"><span class="linenos"> 786</span></a> <span class="n">WINDOW_BEFORE_PAREN_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">OVER</span><span class="p">}</span> +</span><span id="Parser-787"><a href="#Parser-787"><span class="linenos"> 787</span></a> <span class="n">WINDOW_SIDES</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"FOLLOWING"</span><span class="p">,</span> <span class="s2">"PRECEDING"</span><span class="p">}</span> +</span><span id="Parser-788"><a href="#Parser-788"><span class="linenos"> 788</span></a> +</span><span id="Parser-789"><a href="#Parser-789"><span class="linenos"> 789</span></a> <span class="n">ADD_CONSTRAINT_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">CONSTRAINT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PRIMARY_KEY</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FOREIGN_KEY</span><span class="p">}</span> +</span><span id="Parser-790"><a href="#Parser-790"><span class="linenos"> 790</span></a> +</span><span id="Parser-791"><a href="#Parser-791"><span class="linenos"> 791</span></a> <span class="n">STRICT_CAST</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Parser-792"><a href="#Parser-792"><span class="linenos"> 792</span></a> +</span><span id="Parser-793"><a href="#Parser-793"><span class="linenos"> 793</span></a> <span class="n">CONCAT_NULL_OUTPUTS_STRING</span> <span class="o">=</span> <span class="kc">False</span> <span class="c1"># A NULL arg in CONCAT yields NULL by default</span> +</span><span id="Parser-794"><a href="#Parser-794"><span class="linenos"> 794</span></a> +</span><span id="Parser-795"><a href="#Parser-795"><span class="linenos"> 795</span></a> <span class="n">CONVERT_TYPE_FIRST</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-796"><a href="#Parser-796"><span class="linenos"> 796</span></a> +</span><span id="Parser-797"><a href="#Parser-797"><span class="linenos"> 797</span></a> <span class="n">PREFIXED_PIVOT_COLUMNS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-798"><a href="#Parser-798"><span class="linenos"> 798</span></a> <span class="n">IDENTIFY_PIVOT_STRINGS</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-799"><a href="#Parser-799"><span class="linenos"> 799</span></a> +</span><span id="Parser-800"><a href="#Parser-800"><span class="linenos"> 800</span></a> <span class="n">LOG_BASE_FIRST</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Parser-801"><a href="#Parser-801"><span class="linenos"> 801</span></a> <span class="n">LOG_DEFAULTS_TO_LN</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-802"><a href="#Parser-802"><span class="linenos"> 802</span></a> +</span><span id="Parser-803"><a href="#Parser-803"><span class="linenos"> 803</span></a> <span class="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Parser-804"><a href="#Parser-804"><span class="linenos"> 804</span></a> <span class="s2">"error_level"</span><span class="p">,</span> +</span><span id="Parser-805"><a href="#Parser-805"><span class="linenos"> 805</span></a> <span class="s2">"error_message_context"</span><span class="p">,</span> +</span><span id="Parser-806"><a href="#Parser-806"><span class="linenos"> 806</span></a> <span class="s2">"max_errors"</span><span class="p">,</span> +</span><span id="Parser-807"><a href="#Parser-807"><span class="linenos"> 807</span></a> <span class="s2">"sql"</span><span class="p">,</span> +</span><span id="Parser-808"><a href="#Parser-808"><span class="linenos"> 808</span></a> <span class="s2">"errors"</span><span class="p">,</span> +</span><span id="Parser-809"><a href="#Parser-809"><span class="linenos"> 809</span></a> <span class="s2">"_tokens"</span><span class="p">,</span> +</span><span id="Parser-810"><a href="#Parser-810"><span class="linenos"> 810</span></a> <span class="s2">"_index"</span><span class="p">,</span> +</span><span id="Parser-811"><a href="#Parser-811"><span class="linenos"> 811</span></a> <span class="s2">"_curr"</span><span class="p">,</span> +</span><span id="Parser-812"><a href="#Parser-812"><span class="linenos"> 812</span></a> <span class="s2">"_next"</span><span class="p">,</span> +</span><span id="Parser-813"><a href="#Parser-813"><span class="linenos"> 813</span></a> <span class="s2">"_prev"</span><span class="p">,</span> +</span><span id="Parser-814"><a href="#Parser-814"><span class="linenos"> 814</span></a> <span class="s2">"_prev_comments"</span><span class="p">,</span> +</span><span id="Parser-815"><a href="#Parser-815"><span class="linenos"> 815</span></a> <span class="p">)</span> +</span><span id="Parser-816"><a href="#Parser-816"><span class="linenos"> 816</span></a> +</span><span id="Parser-817"><a href="#Parser-817"><span class="linenos"> 817</span></a> <span class="c1"># Autofilled</span> +</span><span id="Parser-818"><a href="#Parser-818"><span class="linenos"> 818</span></a> <span class="n">INDEX_OFFSET</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="Parser-819"><a href="#Parser-819"><span class="linenos"> 819</span></a> <span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-820"><a href="#Parser-820"><span class="linenos"> 820</span></a> <span class="n">ALIAS_POST_TABLESAMPLE</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-821"><a href="#Parser-821"><span class="linenos"> 821</span></a> <span class="n">STRICT_STRING_CONCAT</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-822"><a href="#Parser-822"><span class="linenos"> 822</span></a> <span class="n">NULL_ORDERING</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"nulls_are_small"</span> +</span><span id="Parser-823"><a href="#Parser-823"><span class="linenos"> 823</span></a> <span class="n">SHOW_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Parser-824"><a href="#Parser-824"><span class="linenos"> 824</span></a> <span class="n">SET_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Parser-825"><a href="#Parser-825"><span class="linenos"> 825</span></a> <span class="n">FORMAT_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Parser-826"><a href="#Parser-826"><span class="linenos"> 826</span></a> <span class="n">FORMAT_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Parser-827"><a href="#Parser-827"><span class="linenos"> 827</span></a> <span class="n">TIME_MAPPING</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Parser-828"><a href="#Parser-828"><span class="linenos"> 828</span></a> <span class="n">TIME_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Parser-829"><a href="#Parser-829"><span class="linenos"> 829</span></a> +</span><span id="Parser-830"><a href="#Parser-830"><span class="linenos"> 830</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> +</span><span id="Parser-831"><a href="#Parser-831"><span class="linenos"> 831</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Parser-832"><a href="#Parser-832"><span class="linenos"> 832</span></a> <span class="n">error_level</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">ErrorLevel</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Parser-833"><a href="#Parser-833"><span class="linenos"> 833</span></a> <span class="n">error_message_context</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">100</span><span class="p">,</span> +</span><span id="Parser-834"><a href="#Parser-834"><span class="linenos"> 834</span></a> <span class="n">max_errors</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> +</span><span id="Parser-835"><a href="#Parser-835"><span class="linenos"> 835</span></a> <span class="p">):</span> +</span><span id="Parser-836"><a href="#Parser-836"><span class="linenos"> 836</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">=</span> <span class="n">error_level</span> <span class="ow">or</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span> +</span><span id="Parser-837"><a href="#Parser-837"><span class="linenos"> 837</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">error_message_context</span> <span class="o">=</span> <span class="n">error_message_context</span> +</span><span id="Parser-838"><a href="#Parser-838"><span class="linenos"> 838</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_errors</span> <span class="o">=</span> <span class="n">max_errors</span> +</span><span id="Parser-839"><a href="#Parser-839"><span class="linenos"> 839</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> +</span><span id="Parser-840"><a href="#Parser-840"><span class="linenos"> 840</span></a> +</span><span id="Parser-841"><a href="#Parser-841"><span class="linenos"> 841</span></a> <span class="k">def</span> <span class="nf">reset</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Parser-842"><a href="#Parser-842"><span class="linenos"> 842</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Parser-843"><a href="#Parser-843"><span class="linenos"> 843</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-844"><a href="#Parser-844"><span class="linenos"> 844</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-845"><a href="#Parser-845"><span class="linenos"> 845</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="Parser-846"><a href="#Parser-846"><span class="linenos"> 846</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-847"><a href="#Parser-847"><span class="linenos"> 847</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-848"><a href="#Parser-848"><span class="linenos"> 848</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-849"><a href="#Parser-849"><span class="linenos"> 849</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-850"><a href="#Parser-850"><span class="linenos"> 850</span></a> +</span><span id="Parser-851"><a href="#Parser-851"><span class="linenos"> 851</span></a> <span class="k">def</span> <span class="nf">parse</span><span class="p">(</span> +</span><span id="Parser-852"><a href="#Parser-852"><span class="linenos"> 852</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">raw_tokens</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">Token</span><span class="p">],</span> <span class="n">sql</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><span id="Parser-853"><a href="#Parser-853"><span class="linenos"> 853</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Parser-854"><a href="#Parser-854"><span class="linenos"> 854</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Parser-855"><a href="#Parser-855"><span class="linenos"> 855</span></a><span class="sd"> Parses a list of tokens and returns a list of syntax trees, one tree</span> +</span><span id="Parser-856"><a href="#Parser-856"><span class="linenos"> 856</span></a><span class="sd"> per parsed SQL statement.</span> +</span><span id="Parser-857"><a href="#Parser-857"><span class="linenos"> 857</span></a> +</span><span id="Parser-858"><a href="#Parser-858"><span class="linenos"> 858</span></a><span class="sd"> Args:</span> +</span><span id="Parser-859"><a href="#Parser-859"><span class="linenos"> 859</span></a><span class="sd"> raw_tokens: The list of tokens.</span> +</span><span id="Parser-860"><a href="#Parser-860"><span class="linenos"> 860</span></a><span class="sd"> sql: The original SQL string, used to produce helpful debug messages.</span> +</span><span id="Parser-861"><a href="#Parser-861"><span class="linenos"> 861</span></a> +</span><span id="Parser-862"><a href="#Parser-862"><span class="linenos"> 862</span></a><span class="sd"> Returns:</span> +</span><span id="Parser-863"><a href="#Parser-863"><span class="linenos"> 863</span></a><span class="sd"> The list of the produced syntax trees.</span> +</span><span id="Parser-864"><a href="#Parser-864"><span class="linenos"> 864</span></a><span class="sd"> """</span> +</span><span id="Parser-865"><a href="#Parser-865"><span class="linenos"> 865</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse</span><span class="p">(</span> +</span><span id="Parser-866"><a href="#Parser-866"><span class="linenos"> 866</span></a> <span class="n">parse_method</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">,</span> <span class="n">raw_tokens</span><span class="o">=</span><span class="n">raw_tokens</span><span class="p">,</span> <span class="n">sql</span><span class="o">=</span><span class="n">sql</span> +</span><span id="Parser-867"><a href="#Parser-867"><span class="linenos"> 867</span></a> <span class="p">)</span> +</span><span id="Parser-868"><a href="#Parser-868"><span class="linenos"> 868</span></a> +</span><span id="Parser-869"><a href="#Parser-869"><span class="linenos"> 869</span></a> <span class="k">def</span> <span class="nf">parse_into</span><span class="p">(</span> +</span><span id="Parser-870"><a href="#Parser-870"><span class="linenos"> 870</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Parser-871"><a href="#Parser-871"><span class="linenos"> 871</span></a> <span class="n">expression_types</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IntoType</span><span class="p">,</span> +</span><span id="Parser-872"><a href="#Parser-872"><span class="linenos"> 872</span></a> <span class="n">raw_tokens</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">Token</span><span class="p">],</span> +</span><span id="Parser-873"><a href="#Parser-873"><span class="linenos"> 873</span></a> <span class="n">sql</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="Parser-874"><a href="#Parser-874"><span class="linenos"> 874</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Parser-875"><a href="#Parser-875"><span class="linenos"> 875</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Parser-876"><a href="#Parser-876"><span class="linenos"> 876</span></a><span class="sd"> Parses a list of tokens into a given Expression type. If a collection of Expression</span> +</span><span id="Parser-877"><a href="#Parser-877"><span class="linenos"> 877</span></a><span class="sd"> types is given instead, this method will try to parse the token list into each one</span> +</span><span id="Parser-878"><a href="#Parser-878"><span class="linenos"> 878</span></a><span class="sd"> of them, stopping at the first for which the parsing succeeds.</span> +</span><span id="Parser-879"><a href="#Parser-879"><span class="linenos"> 879</span></a> +</span><span id="Parser-880"><a href="#Parser-880"><span class="linenos"> 880</span></a><span class="sd"> Args:</span> +</span><span id="Parser-881"><a href="#Parser-881"><span class="linenos"> 881</span></a><span class="sd"> expression_types: The expression type(s) to try and parse the token list into.</span> +</span><span id="Parser-882"><a href="#Parser-882"><span class="linenos"> 882</span></a><span class="sd"> raw_tokens: The list of tokens.</span> +</span><span id="Parser-883"><a href="#Parser-883"><span class="linenos"> 883</span></a><span class="sd"> sql: The original SQL string, used to produce helpful debug messages.</span> +</span><span id="Parser-884"><a href="#Parser-884"><span class="linenos"> 884</span></a> +</span><span id="Parser-885"><a href="#Parser-885"><span class="linenos"> 885</span></a><span class="sd"> Returns:</span> +</span><span id="Parser-886"><a href="#Parser-886"><span class="linenos"> 886</span></a><span class="sd"> The target Expression.</span> +</span><span id="Parser-887"><a href="#Parser-887"><span class="linenos"> 887</span></a><span class="sd"> """</span> +</span><span id="Parser-888"><a href="#Parser-888"><span class="linenos"> 888</span></a> <span class="n">errors</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-889"><a href="#Parser-889"><span class="linenos"> 889</span></a> <span class="k">for</span> <span class="n">expression_type</span> <span class="ow">in</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">expression_types</span><span class="p">):</span> +</span><span id="Parser-890"><a href="#Parser-890"><span class="linenos"> 890</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPRESSION_PARSERS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression_type</span><span class="p">)</span> +</span><span id="Parser-891"><a href="#Parser-891"><span class="linenos"> 891</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">parser</span><span class="p">:</span> +</span><span id="Parser-892"><a href="#Parser-892"><span class="linenos"> 892</span></a> <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"No parser registered for </span><span class="si">{</span><span class="n">expression_type</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Parser-893"><a href="#Parser-893"><span class="linenos"> 893</span></a> +</span><span id="Parser-894"><a href="#Parser-894"><span class="linenos"> 894</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="Parser-895"><a href="#Parser-895"><span class="linenos"> 895</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse</span><span class="p">(</span><span class="n">parser</span><span class="p">,</span> <span class="n">raw_tokens</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="Parser-896"><a href="#Parser-896"><span class="linenos"> 896</span></a> <span class="k">except</span> <span class="n">ParseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> +</span><span id="Parser-897"><a href="#Parser-897"><span class="linenos"> 897</span></a> <span class="n">e</span><span class="o">.</span><span class="n">errors</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s2">"into_expression"</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression_type</span> +</span><span id="Parser-898"><a href="#Parser-898"><span class="linenos"> 898</span></a> <span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> +</span><span id="Parser-899"><a href="#Parser-899"><span class="linenos"> 899</span></a> +</span><span id="Parser-900"><a href="#Parser-900"><span class="linenos"> 900</span></a> <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span> +</span><span id="Parser-901"><a href="#Parser-901"><span class="linenos"> 901</span></a> <span class="sa">f</span><span class="s2">"Failed to parse '</span><span class="si">{</span><span class="n">sql</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="n">raw_tokens</span><span class="si">}</span><span class="s2">' into </span><span class="si">{</span><span class="n">expression_types</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Parser-902"><a href="#Parser-902"><span class="linenos"> 902</span></a> <span class="n">errors</span><span class="o">=</span><span class="n">merge_errors</span><span class="p">(</span><span class="n">errors</span><span class="p">),</span> +</span><span id="Parser-903"><a href="#Parser-903"><span class="linenos"> 903</span></a> <span class="p">)</span> <span class="kn">from</span> <span class="nn">errors</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> +</span><span id="Parser-904"><a href="#Parser-904"><span class="linenos"> 904</span></a> +</span><span id="Parser-905"><a href="#Parser-905"><span class="linenos"> 905</span></a> <span class="k">def</span> <span class="nf">_parse</span><span class="p">(</span> +</span><span id="Parser-906"><a href="#Parser-906"><span class="linenos"> 906</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Parser-907"><a href="#Parser-907"><span class="linenos"> 907</span></a> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">[[</span><span class="n">Parser</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><span id="Parser-908"><a href="#Parser-908"><span class="linenos"> 908</span></a> <span class="n">raw_tokens</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">Token</span><span class="p">],</span> +</span><span id="Parser-909"><a href="#Parser-909"><span class="linenos"> 909</span></a> <span class="n">sql</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="Parser-910"><a href="#Parser-910"><span class="linenos"> 910</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Parser-911"><a href="#Parser-911"><span class="linenos"> 911</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> +</span><span id="Parser-912"><a href="#Parser-912"><span class="linenos"> 912</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span> <span class="ow">or</span> <span class="s2">""</span> +</span><span id="Parser-913"><a href="#Parser-913"><span class="linenos"> 913</span></a> +</span><span id="Parser-914"><a href="#Parser-914"><span class="linenos"> 914</span></a> <span class="n">total</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">raw_tokens</span><span class="p">)</span> +</span><span id="Parser-915"><a href="#Parser-915"><span class="linenos"> 915</span></a> <span class="n">chunks</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">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Token</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[[]]</span> +</span><span id="Parser-916"><a href="#Parser-916"><span class="linenos"> 916</span></a> +</span><span id="Parser-917"><a href="#Parser-917"><span class="linenos"> 917</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">token</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">raw_tokens</span><span class="p">):</span> +</span><span id="Parser-918"><a href="#Parser-918"><span class="linenos"> 918</span></a> <span class="k">if</span> <span class="n">token</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SEMICOLON</span><span class="p">:</span> +</span><span id="Parser-919"><a href="#Parser-919"><span class="linenos"> 919</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o"><</span> <span class="n">total</span> <span class="o">-</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Parser-920"><a href="#Parser-920"><span class="linenos"> 920</span></a> <span class="n">chunks</span><span class="o">.</span><span class="n">append</span><span class="p">([])</span> +</span><span id="Parser-921"><a href="#Parser-921"><span class="linenos"> 921</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-922"><a href="#Parser-922"><span class="linenos"> 922</span></a> <span class="n">chunks</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">token</span><span class="p">)</span> +</span><span id="Parser-923"><a href="#Parser-923"><span class="linenos"> 923</span></a> +</span><span id="Parser-924"><a href="#Parser-924"><span class="linenos"> 924</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-925"><a href="#Parser-925"><span class="linenos"> 925</span></a> +</span><span id="Parser-926"><a href="#Parser-926"><span class="linenos"> 926</span></a> <span class="k">for</span> <span class="n">tokens</span> <span class="ow">in</span> <span class="n">chunks</span><span class="p">:</span> +</span><span id="Parser-927"><a href="#Parser-927"><span class="linenos"> 927</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span> +</span><span id="Parser-928"><a href="#Parser-928"><span class="linenos"> 928</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span> <span class="o">=</span> <span class="n">tokens</span> +</span><span id="Parser-929"><a href="#Parser-929"><span class="linenos"> 929</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Parser-930"><a href="#Parser-930"><span class="linenos"> 930</span></a> +</span><span id="Parser-931"><a href="#Parser-931"><span class="linenos"> 931</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">parse_method</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span> +</span><span id="Parser-932"><a href="#Parser-932"><span class="linenos"> 932</span></a> +</span><span id="Parser-933"><a href="#Parser-933"><span class="linenos"> 933</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o"><</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">):</span> +</span><span id="Parser-934"><a href="#Parser-934"><span class="linenos"> 934</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Invalid expression / Unexpected token"</span><span class="p">)</span> +</span><span id="Parser-935"><a href="#Parser-935"><span class="linenos"> 935</span></a> +</span><span id="Parser-936"><a href="#Parser-936"><span class="linenos"> 936</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">check_errors</span><span class="p">()</span> +</span><span id="Parser-937"><a href="#Parser-937"><span class="linenos"> 937</span></a> +</span><span id="Parser-938"><a href="#Parser-938"><span class="linenos"> 938</span></a> <span class="k">return</span> <span class="n">expressions</span> +</span><span id="Parser-939"><a href="#Parser-939"><span class="linenos"> 939</span></a> +</span><span id="Parser-940"><a href="#Parser-940"><span class="linenos"> 940</span></a> <span class="k">def</span> <span class="nf">check_errors</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Parser-941"><a href="#Parser-941"><span class="linenos"> 941</span></a><span class="w"> </span><span class="sd">"""Logs or raises any found errors, depending on the chosen error level setting."""</span> +</span><span id="Parser-942"><a href="#Parser-942"><span class="linenos"> 942</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">:</span> +</span><span id="Parser-943"><a href="#Parser-943"><span class="linenos"> 943</span></a> <span class="k">for</span> <span class="n">error</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">:</span> +</span><span id="Parser-944"><a href="#Parser-944"><span class="linenos"> 944</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">error</span><span class="p">))</span> +</span><span id="Parser-945"><a href="#Parser-945"><span class="linenos"> 945</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">RAISE</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">:</span> +</span><span id="Parser-946"><a href="#Parser-946"><span class="linenos"> 946</span></a> <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span> +</span><span id="Parser-947"><a href="#Parser-947"><span class="linenos"> 947</span></a> <span class="n">concat_messages</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_errors</span><span class="p">),</span> +</span><span id="Parser-948"><a href="#Parser-948"><span class="linenos"> 948</span></a> <span class="n">errors</span><span class="o">=</span><span class="n">merge_errors</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">),</span> +</span><span id="Parser-949"><a href="#Parser-949"><span class="linenos"> 949</span></a> <span class="p">)</span> +</span><span id="Parser-950"><a href="#Parser-950"><span class="linenos"> 950</span></a> +</span><span id="Parser-951"><a href="#Parser-951"><span class="linenos"> 951</span></a> <span class="k">def</span> <span class="nf">raise_error</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">token</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">Token</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Parser-952"><a href="#Parser-952"><span class="linenos"> 952</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Parser-953"><a href="#Parser-953"><span class="linenos"> 953</span></a><span class="sd"> Appends an error in the list of recorded errors or raises it, depending on the chosen</span> +</span><span id="Parser-954"><a href="#Parser-954"><span class="linenos"> 954</span></a><span class="sd"> error level setting.</span> +</span><span id="Parser-955"><a href="#Parser-955"><span class="linenos"> 955</span></a><span class="sd"> """</span> +</span><span id="Parser-956"><a href="#Parser-956"><span class="linenos"> 956</span></a> <span class="n">token</span> <span class="o">=</span> <span class="n">token</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="ow">or</span> <span class="n">Token</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">)</span> +</span><span id="Parser-957"><a href="#Parser-957"><span class="linenos"> 957</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">token</span><span class="o">.</span><span class="n">start</span> +</span><span id="Parser-958"><a href="#Parser-958"><span class="linenos"> 958</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">token</span><span class="o">.</span><span class="n">end</span> <span class="o">+</span> <span class="mi">1</span> +</span><span id="Parser-959"><a href="#Parser-959"><span class="linenos"> 959</span></a> <span class="n">start_context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="nb">max</span><span class="p">(</span><span class="n">start</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_message_context</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="p">:</span> <span class="n">start</span><span class="p">]</span> +</span><span id="Parser-960"><a href="#Parser-960"><span class="linenos"> 960</span></a> <span class="n">highlight</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">start</span><span class="p">:</span><span class="n">end</span><span class="p">]</span> +</span><span id="Parser-961"><a href="#Parser-961"><span class="linenos"> 961</span></a> <span class="n">end_context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">end</span> <span class="p">:</span> <span class="n">end</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_message_context</span><span class="p">]</span> +</span><span id="Parser-962"><a href="#Parser-962"><span class="linenos"> 962</span></a> +</span><span id="Parser-963"><a href="#Parser-963"><span class="linenos"> 963</span></a> <span class="n">error</span> <span class="o">=</span> <span class="n">ParseError</span><span class="o">.</span><span class="n">new</span><span class="p">(</span> +</span><span id="Parser-964"><a href="#Parser-964"><span class="linenos"> 964</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">message</span><span class="si">}</span><span class="s2">. Line </span><span class="si">{</span><span class="n">token</span><span class="o">.</span><span class="n">line</span><span class="si">}</span><span class="s2">, Col: </span><span class="si">{</span><span class="n">token</span><span class="o">.</span><span class="n">col</span><span class="si">}</span><span class="s2">.</span><span class="se">\n</span><span class="s2">"</span> +</span><span id="Parser-965"><a href="#Parser-965"><span class="linenos"> 965</span></a> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">start_context</span><span class="si">}</span><span class="se">\033</span><span class="s2">[4m</span><span class="si">{</span><span class="n">highlight</span><span class="si">}</span><span class="se">\033</span><span class="s2">[0m</span><span class="si">{</span><span class="n">end_context</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Parser-966"><a href="#Parser-966"><span class="linenos"> 966</span></a> <span class="n">description</span><span class="o">=</span><span class="n">message</span><span class="p">,</span> +</span><span id="Parser-967"><a href="#Parser-967"><span class="linenos"> 967</span></a> <span class="n">line</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">line</span><span class="p">,</span> +</span><span id="Parser-968"><a href="#Parser-968"><span class="linenos"> 968</span></a> <span class="n">col</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">col</span><span class="p">,</span> +</span><span id="Parser-969"><a href="#Parser-969"><span class="linenos"> 969</span></a> <span class="n">start_context</span><span class="o">=</span><span class="n">start_context</span><span class="p">,</span> +</span><span id="Parser-970"><a href="#Parser-970"><span class="linenos"> 970</span></a> <span class="n">highlight</span><span class="o">=</span><span class="n">highlight</span><span class="p">,</span> +</span><span id="Parser-971"><a href="#Parser-971"><span class="linenos"> 971</span></a> <span class="n">end_context</span><span class="o">=</span><span class="n">end_context</span><span class="p">,</span> +</span><span id="Parser-972"><a href="#Parser-972"><span class="linenos"> 972</span></a> <span class="p">)</span> +</span><span id="Parser-973"><a href="#Parser-973"><span class="linenos"> 973</span></a> +</span><span id="Parser-974"><a href="#Parser-974"><span class="linenos"> 974</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span><span class="p">:</span> +</span><span id="Parser-975"><a href="#Parser-975"><span class="linenos"> 975</span></a> <span class="k">raise</span> <span class="n">error</span> +</span><span id="Parser-976"><a href="#Parser-976"><span class="linenos"> 976</span></a> +</span><span id="Parser-977"><a href="#Parser-977"><span class="linenos"> 977</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">error</span><span class="p">)</span> +</span><span id="Parser-978"><a href="#Parser-978"><span class="linenos"> 978</span></a> +</span><span id="Parser-979"><a href="#Parser-979"><span class="linenos"> 979</span></a> <span class="k">def</span> <span class="nf">expression</span><span class="p">(</span> +</span><span id="Parser-980"><a href="#Parser-980"><span class="linenos"> 980</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> <span class="n">comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> +</span><span id="Parser-981"><a href="#Parser-981"><span class="linenos"> 981</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="Parser-982"><a href="#Parser-982"><span class="linenos"> 982</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Parser-983"><a href="#Parser-983"><span class="linenos"> 983</span></a><span class="sd"> Creates a new, validated Expression.</span> +</span><span id="Parser-984"><a href="#Parser-984"><span class="linenos"> 984</span></a> +</span><span id="Parser-985"><a href="#Parser-985"><span class="linenos"> 985</span></a><span class="sd"> Args:</span> +</span><span id="Parser-986"><a href="#Parser-986"><span class="linenos"> 986</span></a><span class="sd"> exp_class: The expression class to instantiate.</span> +</span><span id="Parser-987"><a href="#Parser-987"><span class="linenos"> 987</span></a><span class="sd"> comments: An optional list of comments to attach to the expression.</span> +</span><span id="Parser-988"><a href="#Parser-988"><span class="linenos"> 988</span></a><span class="sd"> kwargs: The arguments to set for the expression along with their respective values.</span> +</span><span id="Parser-989"><a href="#Parser-989"><span class="linenos"> 989</span></a> +</span><span id="Parser-990"><a href="#Parser-990"><span class="linenos"> 990</span></a><span class="sd"> Returns:</span> +</span><span id="Parser-991"><a href="#Parser-991"><span class="linenos"> 991</span></a><span class="sd"> The target expression.</span> +</span><span id="Parser-992"><a href="#Parser-992"><span class="linenos"> 992</span></a><span class="sd"> """</span> +</span><span id="Parser-993"><a href="#Parser-993"><span class="linenos"> 993</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">exp_class</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="Parser-994"><a href="#Parser-994"><span class="linenos"> 994</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">add_comments</span><span class="p">(</span><span class="n">comments</span><span class="p">)</span> <span class="k">if</span> <span class="n">comments</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add_comments</span><span class="p">(</span><span class="n">instance</span><span class="p">)</span> +</span><span id="Parser-995"><a href="#Parser-995"><span class="linenos"> 995</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">instance</span><span class="p">)</span> +</span><span id="Parser-996"><a href="#Parser-996"><span class="linenos"> 996</span></a> +</span><span id="Parser-997"><a href="#Parser-997"><span class="linenos"> 997</span></a> <span class="k">def</span> <span class="nf">_add_comments</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Parser-998"><a href="#Parser-998"><span class="linenos"> 998</span></a> <span class="k">if</span> <span class="n">expression</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span><span class="p">:</span> +</span><span id="Parser-999"><a href="#Parser-999"><span class="linenos"> 999</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">add_comments</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span><span class="p">)</span> +</span><span id="Parser-1000"><a href="#Parser-1000"><span class="linenos">1000</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1001"><a href="#Parser-1001"><span class="linenos">1001</span></a> +</span><span id="Parser-1002"><a href="#Parser-1002"><span class="linenos">1002</span></a> <span class="k">def</span> <span class="nf">validate_expression</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="Parser-1003"><a href="#Parser-1003"><span class="linenos">1003</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Parser-1004"><a href="#Parser-1004"><span class="linenos">1004</span></a><span class="sd"> Validates an Expression, making sure that all its mandatory arguments are set.</span> +</span><span id="Parser-1005"><a href="#Parser-1005"><span class="linenos">1005</span></a> +</span><span id="Parser-1006"><a href="#Parser-1006"><span class="linenos">1006</span></a><span class="sd"> Args:</span> +</span><span id="Parser-1007"><a href="#Parser-1007"><span class="linenos">1007</span></a><span class="sd"> expression: The expression to validate.</span> +</span><span id="Parser-1008"><a href="#Parser-1008"><span class="linenos">1008</span></a><span class="sd"> args: An optional list of items that was used to instantiate the expression, if it's a Func.</span> +</span><span id="Parser-1009"><a href="#Parser-1009"><span class="linenos">1009</span></a> +</span><span id="Parser-1010"><a href="#Parser-1010"><span class="linenos">1010</span></a><span class="sd"> Returns:</span> +</span><span id="Parser-1011"><a href="#Parser-1011"><span class="linenos">1011</span></a><span class="sd"> The validated expression.</span> +</span><span id="Parser-1012"><a href="#Parser-1012"><span class="linenos">1012</span></a><span class="sd"> """</span> +</span><span id="Parser-1013"><a href="#Parser-1013"><span class="linenos">1013</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">!=</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IGNORE</span><span class="p">:</span> +</span><span id="Parser-1014"><a href="#Parser-1014"><span class="linenos">1014</span></a> <span class="k">for</span> <span class="n">error_message</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">error_messages</span><span class="p">(</span><span class="n">args</span><span class="p">):</span> +</span><span id="Parser-1015"><a href="#Parser-1015"><span class="linenos">1015</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="n">error_message</span><span class="p">)</span> +</span><span id="Parser-1016"><a href="#Parser-1016"><span class="linenos">1016</span></a> +</span><span id="Parser-1017"><a href="#Parser-1017"><span class="linenos">1017</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="Parser-1018"><a href="#Parser-1018"><span class="linenos">1018</span></a> +</span><span id="Parser-1019"><a href="#Parser-1019"><span class="linenos">1019</span></a> <span class="k">def</span> <span class="nf">_find_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">start</span><span class="p">:</span> <span class="n">Token</span><span class="p">,</span> <span class="n">end</span><span class="p">:</span> <span class="n">Token</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Parser-1020"><a href="#Parser-1020"><span class="linenos">1020</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">start</span><span class="o">.</span><span class="n">start</span> <span class="p">:</span> <span class="n">end</span><span class="o">.</span><span class="n">end</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span> +</span><span id="Parser-1021"><a href="#Parser-1021"><span class="linenos">1021</span></a> +</span><span id="Parser-1022"><a href="#Parser-1022"><span class="linenos">1022</span></a> <span class="k">def</span> <span class="nf">_advance</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">times</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Parser-1023"><a href="#Parser-1023"><span class="linenos">1023</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">+=</span> <span class="n">times</span> +</span><span id="Parser-1024"><a href="#Parser-1024"><span class="linenos">1024</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span><span class="p">)</span> +</span><span id="Parser-1025"><a href="#Parser-1025"><span class="linenos">1025</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span> <span class="o">=</span> <span class="n">seq_get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="Parser-1026"><a href="#Parser-1026"><span class="linenos">1026</span></a> +</span><span id="Parser-1027"><a href="#Parser-1027"><span class="linenos">1027</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> +</span><span id="Parser-1028"><a href="#Parser-1028"><span class="linenos">1028</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> +</span><span id="Parser-1029"><a href="#Parser-1029"><span class="linenos">1029</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</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">comments</span> +</span><span id="Parser-1030"><a href="#Parser-1030"><span class="linenos">1030</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1031"><a href="#Parser-1031"><span class="linenos">1031</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1032"><a href="#Parser-1032"><span class="linenos">1032</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1033"><a href="#Parser-1033"><span class="linenos">1033</span></a> +</span><span id="Parser-1034"><a href="#Parser-1034"><span class="linenos">1034</span></a> <span class="k">def</span> <span class="nf">_retreat</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">index</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Parser-1035"><a href="#Parser-1035"><span class="linenos">1035</span></a> <span class="k">if</span> <span class="n">index</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span><span class="p">:</span> +</span><span id="Parser-1036"><a href="#Parser-1036"><span class="linenos">1036</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">index</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span><span class="p">)</span> +</span><span id="Parser-1037"><a href="#Parser-1037"><span class="linenos">1037</span></a> +</span><span id="Parser-1038"><a href="#Parser-1038"><span class="linenos">1038</span></a> <span class="k">def</span> <span class="nf">_parse_command</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">Command</span><span class="p">:</span> +</span><span id="Parser-1039"><a href="#Parser-1039"><span class="linenos">1039</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">Command</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 class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">())</span> +</span><span id="Parser-1040"><a href="#Parser-1040"><span class="linenos">1040</span></a> +</span><span id="Parser-1041"><a href="#Parser-1041"><span class="linenos">1041</span></a> <span class="k">def</span> <span class="nf">_parse_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">allow_exists</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="Parser-1042"><a href="#Parser-1042"><span class="linenos">1042</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> +</span><span id="Parser-1043"><a href="#Parser-1043"><span class="linenos">1043</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">()</span> <span class="k">if</span> <span class="n">allow_exists</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="Parser-1044"><a href="#Parser-1044"><span class="linenos">1044</span></a> +</span><span id="Parser-1045"><a href="#Parser-1045"><span class="linenos">1045</span></a> <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">ON</span><span class="p">)</span> +</span><span id="Parser-1046"><a href="#Parser-1046"><span class="linenos">1046</span></a> +</span><span id="Parser-1047"><a href="#Parser-1047"><span class="linenos">1047</span></a> <span class="n">kind</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> +</span><span id="Parser-1048"><a href="#Parser-1048"><span class="linenos">1048</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="Parser-1049"><a href="#Parser-1049"><span class="linenos">1049</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> +</span><span id="Parser-1050"><a href="#Parser-1050"><span class="linenos">1050</span></a> +</span><span id="Parser-1051"><a href="#Parser-1051"><span class="linenos">1051</span></a> <span class="k">if</span> <span class="n">kind</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FUNCTION</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PROCEDURE</span><span class="p">):</span> +</span><span id="Parser-1052"><a href="#Parser-1052"><span class="linenos">1052</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_user_defined_function</span><span class="p">(</span><span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="o">.</span><span class="n">token_type</span><span class="p">)</span> +</span><span id="Parser-1053"><a href="#Parser-1053"><span class="linenos">1053</span></a> <span class="k">elif</span> <span class="n">kind</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">:</span> +</span><span id="Parser-1054"><a href="#Parser-1054"><span class="linenos">1054</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">alias_tokens</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">COMMENT_TABLE_ALIAS_TOKENS</span><span class="p">)</span> +</span><span id="Parser-1055"><a href="#Parser-1055"><span class="linenos">1055</span></a> <span class="k">elif</span> <span class="n">kind</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLUMN</span><span class="p">:</span> +</span><span id="Parser-1056"><a href="#Parser-1056"><span class="linenos">1056</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> +</span><span id="Parser-1057"><a href="#Parser-1057"><span class="linenos">1057</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1058"><a href="#Parser-1058"><span class="linenos">1058</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="Parser-1059"><a href="#Parser-1059"><span class="linenos">1059</span></a> +</span><span id="Parser-1060"><a href="#Parser-1060"><span class="linenos">1060</span></a> <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">IS</span><span class="p">)</span> +</span><span id="Parser-1061"><a href="#Parser-1061"><span class="linenos">1061</span></a> +</span><span id="Parser-1062"><a href="#Parser-1062"><span class="linenos">1062</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><span id="Parser-1063"><a href="#Parser-1063"><span class="linenos">1063</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Comment</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">(),</span> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span> +</span><span id="Parser-1064"><a href="#Parser-1064"><span class="linenos">1064</span></a> <span class="p">)</span> +</span><span id="Parser-1065"><a href="#Parser-1065"><span class="linenos">1065</span></a> +</span><span id="Parser-1066"><a href="#Parser-1066"><span class="linenos">1066</span></a> <span class="k">def</span> <span class="nf">_parse_to_table</span><span class="p">(</span> +</span><span id="Parser-1067"><a href="#Parser-1067"><span class="linenos">1067</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Parser-1068"><a href="#Parser-1068"><span class="linenos">1068</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">ToTableProperty</span><span class="p">:</span> +</span><span id="Parser-1069"><a href="#Parser-1069"><span class="linenos">1069</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-1070"><a href="#Parser-1070"><span class="linenos">1070</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">ToTableProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">)</span> +</span><span id="Parser-1071"><a href="#Parser-1071"><span class="linenos">1071</span></a> +</span><span id="Parser-1072"><a href="#Parser-1072"><span class="linenos">1072</span></a> <span class="c1"># https://clickhouse.com/docs/en/engines/table-engines/mergetree-family/mergetree#mergetree-table-ttl</span> +</span><span id="Parser-1073"><a href="#Parser-1073"><span class="linenos">1073</span></a> <span class="k">def</span> <span class="nf">_parse_ttl</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">Expression</span><span class="p">:</span> +</span><span id="Parser-1074"><a href="#Parser-1074"><span class="linenos">1074</span></a> <span class="k">def</span> <span class="nf">_parse_ttl_action</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="Parser-1075"><a href="#Parser-1075"><span class="linenos">1075</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="Parser-1076"><a href="#Parser-1076"><span class="linenos">1076</span></a> +</span><span id="Parser-1077"><a href="#Parser-1077"><span class="linenos">1077</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DELETE"</span><span class="p">):</span> +</span><span id="Parser-1078"><a href="#Parser-1078"><span class="linenos">1078</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">MergeTreeTTLAction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">delete</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-1079"><a href="#Parser-1079"><span class="linenos">1079</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"RECOMPRESS"</span><span class="p">):</span> +</span><span id="Parser-1080"><a href="#Parser-1080"><span class="linenos">1080</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><span id="Parser-1081"><a href="#Parser-1081"><span class="linenos">1081</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTLAction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">recompress</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="Parser-1082"><a href="#Parser-1082"><span class="linenos">1082</span></a> <span class="p">)</span> +</span><span id="Parser-1083"><a href="#Parser-1083"><span class="linenos">1083</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"DISK"</span><span class="p">):</span> +</span><span id="Parser-1084"><a href="#Parser-1084"><span class="linenos">1084</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><span id="Parser-1085"><a href="#Parser-1085"><span class="linenos">1085</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTLAction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to_disk</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="Parser-1086"><a href="#Parser-1086"><span class="linenos">1086</span></a> <span class="p">)</span> +</span><span id="Parser-1087"><a href="#Parser-1087"><span class="linenos">1087</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"VOLUME"</span><span class="p">):</span> +</span><span id="Parser-1088"><a href="#Parser-1088"><span class="linenos">1088</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><span id="Parser-1089"><a href="#Parser-1089"><span class="linenos">1089</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTLAction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to_volume</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="Parser-1090"><a href="#Parser-1090"><span class="linenos">1090</span></a> <span class="p">)</span> +</span><span id="Parser-1091"><a href="#Parser-1091"><span class="linenos">1091</span></a> +</span><span id="Parser-1092"><a href="#Parser-1092"><span class="linenos">1092</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-1093"><a href="#Parser-1093"><span class="linenos">1093</span></a> +</span><span id="Parser-1094"><a href="#Parser-1094"><span class="linenos">1094</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">_parse_ttl_action</span><span class="p">)</span> +</span><span id="Parser-1095"><a href="#Parser-1095"><span class="linenos">1095</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">()</span> +</span><span id="Parser-1096"><a href="#Parser-1096"><span class="linenos">1096</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_group</span><span class="p">()</span> +</span><span id="Parser-1097"><a href="#Parser-1097"><span class="linenos">1097</span></a> +</span><span id="Parser-1098"><a href="#Parser-1098"><span class="linenos">1098</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1099"><a href="#Parser-1099"><span class="linenos">1099</span></a> <span class="k">if</span> <span class="n">group</span> <span class="ow">and</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">SET</span><span class="p">):</span> +</span><span id="Parser-1100"><a href="#Parser-1100"><span class="linenos">1100</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_item</span><span class="p">)</span> +</span><span id="Parser-1101"><a href="#Parser-1101"><span class="linenos">1101</span></a> +</span><span id="Parser-1102"><a href="#Parser-1102"><span class="linenos">1102</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><span id="Parser-1103"><a href="#Parser-1103"><span class="linenos">1103</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeTreeTTL</span><span class="p">,</span> +</span><span id="Parser-1104"><a href="#Parser-1104"><span class="linenos">1104</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Parser-1105"><a href="#Parser-1105"><span class="linenos">1105</span></a> <span class="n">where</span><span class="o">=</span><span class="n">where</span><span class="p">,</span> +</span><span id="Parser-1106"><a href="#Parser-1106"><span class="linenos">1106</span></a> <span class="n">group</span><span class="o">=</span><span class="n">group</span><span class="p">,</span> +</span><span id="Parser-1107"><a href="#Parser-1107"><span class="linenos">1107</span></a> <span class="n">aggregates</span><span class="o">=</span><span class="n">aggregates</span><span class="p">,</span> +</span><span id="Parser-1108"><a href="#Parser-1108"><span class="linenos">1108</span></a> <span class="p">)</span> +</span><span id="Parser-1109"><a href="#Parser-1109"><span class="linenos">1109</span></a> +</span><span id="Parser-1110"><a href="#Parser-1110"><span class="linenos">1110</span></a> <span class="k">def</span> <span class="nf">_parse_statement</span><span class="p">(</span><span class="bp">self</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="Parser-1111"><a href="#Parser-1111"><span class="linenos">1111</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Parser-1112"><a href="#Parser-1112"><span class="linenos">1112</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1113"><a href="#Parser-1113"><span class="linenos">1113</span></a> +</span><span id="Parser-1114"><a href="#Parser-1114"><span class="linenos">1114</span></a> <span class="k">if</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">STATEMENT_PARSERS</span><span class="p">):</span> +</span><span id="Parser-1115"><a href="#Parser-1115"><span class="linenos">1115</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">STATEMENT_PARSERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> +</span><span id="Parser-1116"><a href="#Parser-1116"><span class="linenos">1116</span></a> +</span><span id="Parser-1117"><a href="#Parser-1117"><span class="linenos">1117</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">(</span><span class="n">Tokenizer</span><span class="o">.</span><span class="n">COMMANDS</span><span class="p">):</span> +</span><span id="Parser-1118"><a href="#Parser-1118"><span class="linenos">1118</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_command</span><span class="p">()</span> +</span><span id="Parser-1119"><a href="#Parser-1119"><span class="linenos">1119</span></a> +</span><span id="Parser-1120"><a href="#Parser-1120"><span class="linenos">1120</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">()</span> +</span><span id="Parser-1121"><a href="#Parser-1121"><span class="linenos">1121</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">()</span> +</span><span id="Parser-1122"><a href="#Parser-1122"><span class="linenos">1122</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Parser-1123"><a href="#Parser-1123"><span class="linenos">1123</span></a> +</span><span id="Parser-1124"><a href="#Parser-1124"><span class="linenos">1124</span></a> <span class="k">def</span> <span class="nf">_parse_drop</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">Drop</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> +</span><span id="Parser-1125"><a href="#Parser-1125"><span class="linenos">1125</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> +</span><span id="Parser-1126"><a href="#Parser-1126"><span class="linenos">1126</span></a> <span class="n">temporary</span> <span class="o">=</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">TEMPORARY</span><span class="p">)</span> +</span><span id="Parser-1127"><a href="#Parser-1127"><span class="linenos">1127</span></a> <span class="n">materialized</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MATERIALIZED"</span><span class="p">)</span> +</span><span id="Parser-1128"><a href="#Parser-1128"><span class="linenos">1128</span></a> +</span><span id="Parser-1129"><a href="#Parser-1129"><span class="linenos">1129</span></a> <span class="n">kind</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</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><span id="Parser-1130"><a href="#Parser-1130"><span class="linenos">1130</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="Parser-1131"><a href="#Parser-1131"><span class="linenos">1131</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> +</span><span id="Parser-1132"><a href="#Parser-1132"><span class="linenos">1132</span></a> +</span><span id="Parser-1133"><a href="#Parser-1133"><span class="linenos">1133</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><span id="Parser-1134"><a href="#Parser-1134"><span class="linenos">1134</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Drop</span><span class="p">,</span> +</span><span id="Parser-1135"><a href="#Parser-1135"><span class="linenos">1135</span></a> <span class="n">exists</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">(),</span> +</span><span id="Parser-1136"><a href="#Parser-1136"><span class="linenos">1136</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="Parser-1137"><a href="#Parser-1137"><span class="linenos">1137</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> +</span><span id="Parser-1138"><a href="#Parser-1138"><span class="linenos">1138</span></a> <span class="n">temporary</span><span class="o">=</span><span class="n">temporary</span><span class="p">,</span> +</span><span id="Parser-1139"><a href="#Parser-1139"><span class="linenos">1139</span></a> <span class="n">materialized</span><span class="o">=</span><span class="n">materialized</span><span class="p">,</span> +</span><span id="Parser-1140"><a href="#Parser-1140"><span class="linenos">1140</span></a> <span class="n">cascade</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CASCADE"</span><span class="p">),</span> +</span><span id="Parser-1141"><a href="#Parser-1141"><span class="linenos">1141</span></a> <span class="n">constraints</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CONSTRAINTS"</span><span class="p">),</span> +</span><span id="Parser-1142"><a href="#Parser-1142"><span class="linenos">1142</span></a> <span class="n">purge</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PURGE"</span><span class="p">),</span> +</span><span id="Parser-1143"><a href="#Parser-1143"><span class="linenos">1143</span></a> <span class="p">)</span> +</span><span id="Parser-1144"><a href="#Parser-1144"><span class="linenos">1144</span></a> +</span><span id="Parser-1145"><a href="#Parser-1145"><span class="linenos">1145</span></a> <span class="k">def</span> <span class="nf">_parse_exists</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">not_</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="nb">bool</span><span class="p">]:</span> +</span><span id="Parser-1146"><a href="#Parser-1146"><span class="linenos">1146</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="Parser-1147"><a href="#Parser-1147"><span class="linenos">1147</span></a> <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">IF</span><span class="p">)</span> +</span><span id="Parser-1148"><a href="#Parser-1148"><span class="linenos">1148</span></a> <span class="ow">and</span> <span class="p">(</span><span class="ow">not</span> <span class="n">not_</span> <span class="ow">or</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">NOT</span><span class="p">))</span> +</span><span id="Parser-1149"><a href="#Parser-1149"><span class="linenos">1149</span></a> <span class="ow">and</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">EXISTS</span><span class="p">)</span> +</span><span id="Parser-1150"><a href="#Parser-1150"><span class="linenos">1150</span></a> <span class="p">)</span> +</span><span id="Parser-1151"><a href="#Parser-1151"><span class="linenos">1151</span></a> +</span><span id="Parser-1152"><a href="#Parser-1152"><span class="linenos">1152</span></a> <span class="k">def</span> <span class="nf">_parse_create</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">Create</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> +</span><span id="Parser-1153"><a href="#Parser-1153"><span class="linenos">1153</span></a> <span class="c1"># Note: this can't be None because we've matched a statement parser</span> +</span><span id="Parser-1154"><a href="#Parser-1154"><span class="linenos">1154</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> +</span><span id="Parser-1155"><a href="#Parser-1155"><span class="linenos">1155</span></a> <span class="n">replace</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"REPLACE"</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span> +</span><span id="Parser-1156"><a href="#Parser-1156"><span class="linenos">1156</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">OR</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span> +</span><span id="Parser-1157"><a href="#Parser-1157"><span class="linenos">1157</span></a> <span class="p">)</span> +</span><span id="Parser-1158"><a href="#Parser-1158"><span class="linenos">1158</span></a> <span class="n">unique</span> <span class="o">=</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">UNIQUE</span><span class="p">)</span> +</span><span id="Parser-1159"><a href="#Parser-1159"><span class="linenos">1159</span></a> +</span><span id="Parser-1160"><a href="#Parser-1160"><span class="linenos">1160</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FUNCTION</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="Parser-1161"><a href="#Parser-1161"><span class="linenos">1161</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Parser-1162"><a href="#Parser-1162"><span class="linenos">1162</span></a> +</span><span id="Parser-1163"><a href="#Parser-1163"><span class="linenos">1163</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1164"><a href="#Parser-1164"><span class="linenos">1164</span></a> <span class="n">create_token</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> +</span><span id="Parser-1165"><a href="#Parser-1165"><span class="linenos">1165</span></a> +</span><span id="Parser-1166"><a href="#Parser-1166"><span class="linenos">1166</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">create_token</span><span class="p">:</span> +</span><span id="Parser-1167"><a href="#Parser-1167"><span class="linenos">1167</span></a> <span class="c1"># exp.Properties.Location.POST_CREATE</span> +</span><span id="Parser-1168"><a href="#Parser-1168"><span class="linenos">1168</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">()</span> +</span><span id="Parser-1169"><a href="#Parser-1169"><span class="linenos">1169</span></a> <span class="n">create_token</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> +</span><span id="Parser-1170"><a href="#Parser-1170"><span class="linenos">1170</span></a> +</span><span id="Parser-1171"><a href="#Parser-1171"><span class="linenos">1171</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">properties</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">create_token</span><span class="p">:</span> +</span><span id="Parser-1172"><a href="#Parser-1172"><span class="linenos">1172</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> +</span><span id="Parser-1173"><a href="#Parser-1173"><span class="linenos">1173</span></a> +</span><span id="Parser-1174"><a href="#Parser-1174"><span class="linenos">1174</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">(</span><span class="n">not_</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-1175"><a href="#Parser-1175"><span class="linenos">1175</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1176"><a href="#Parser-1176"><span class="linenos">1176</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1177"><a href="#Parser-1177"><span class="linenos">1177</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1178"><a href="#Parser-1178"><span class="linenos">1178</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1179"><a href="#Parser-1179"><span class="linenos">1179</span></a> <span class="n">begin</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1180"><a href="#Parser-1180"><span class="linenos">1180</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1181"><a href="#Parser-1181"><span class="linenos">1181</span></a> +</span><span id="Parser-1182"><a href="#Parser-1182"><span class="linenos">1182</span></a> <span class="k">def</span> <span class="nf">extend_props</span><span class="p">(</span><span class="n">temp_props</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">Properties</span><span class="p">])</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Parser-1183"><a href="#Parser-1183"><span class="linenos">1183</span></a> <span class="k">nonlocal</span> <span class="n">properties</span> +</span><span id="Parser-1184"><a href="#Parser-1184"><span class="linenos">1184</span></a> <span class="k">if</span> <span class="n">properties</span> <span class="ow">and</span> <span class="n">temp_props</span><span class="p">:</span> +</span><span id="Parser-1185"><a href="#Parser-1185"><span class="linenos">1185</span></a> <span class="n">properties</span><span class="o">.</span><span class="n">expressions</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">temp_props</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Parser-1186"><a href="#Parser-1186"><span class="linenos">1186</span></a> <span class="k">elif</span> <span class="n">temp_props</span><span class="p">:</span> +</span><span id="Parser-1187"><a href="#Parser-1187"><span class="linenos">1187</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="n">temp_props</span> +</span><span id="Parser-1188"><a href="#Parser-1188"><span class="linenos">1188</span></a> +</span><span id="Parser-1189"><a href="#Parser-1189"><span class="linenos">1189</span></a> <span class="k">if</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FUNCTION</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PROCEDURE</span><span class="p">):</span> +</span><span id="Parser-1190"><a href="#Parser-1190"><span class="linenos">1190</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_user_defined_function</span><span class="p">(</span><span class="n">kind</span><span class="o">=</span><span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span><span class="p">)</span> +</span><span id="Parser-1191"><a href="#Parser-1191"><span class="linenos">1191</span></a> +</span><span id="Parser-1192"><a href="#Parser-1192"><span class="linenos">1192</span></a> <span class="c1"># exp.Properties.Location.POST_SCHEMA ("schema" here is the UDF's type signature)</span> +</span><span id="Parser-1193"><a href="#Parser-1193"><span class="linenos">1193</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">())</span> +</span><span id="Parser-1194"><a href="#Parser-1194"><span class="linenos">1194</span></a> +</span><span id="Parser-1195"><a href="#Parser-1195"><span class="linenos">1195</span></a> <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">ALIAS</span><span class="p">)</span> +</span><span id="Parser-1196"><a href="#Parser-1196"><span class="linenos">1196</span></a> <span class="n">begin</span> <span class="o">=</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">BEGIN</span><span class="p">)</span> +</span><span id="Parser-1197"><a href="#Parser-1197"><span class="linenos">1197</span></a> <span class="n">return_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"RETURN"</span><span class="p">)</span> +</span><span id="Parser-1198"><a href="#Parser-1198"><span class="linenos">1198</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">()</span> +</span><span id="Parser-1199"><a href="#Parser-1199"><span class="linenos">1199</span></a> +</span><span id="Parser-1200"><a href="#Parser-1200"><span class="linenos">1200</span></a> <span class="k">if</span> <span class="n">return_</span><span class="p">:</span> +</span><span id="Parser-1201"><a href="#Parser-1201"><span class="linenos">1201</span></a> <span class="n">expression</span> <span class="o">=</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">Return</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Parser-1202"><a href="#Parser-1202"><span class="linenos">1202</span></a> <span class="k">elif</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INDEX</span><span class="p">:</span> +</span><span id="Parser-1203"><a href="#Parser-1203"><span class="linenos">1203</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_index</span><span class="p">(</span><span class="n">index</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">())</span> +</span><span id="Parser-1204"><a href="#Parser-1204"><span class="linenos">1204</span></a> <span class="k">elif</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">DB_CREATABLES</span><span class="p">:</span> +</span><span id="Parser-1205"><a href="#Parser-1205"><span class="linenos">1205</span></a> <span class="n">table_parts</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-1206"><a href="#Parser-1206"><span class="linenos">1206</span></a> +</span><span id="Parser-1207"><a href="#Parser-1207"><span class="linenos">1207</span></a> <span class="c1"># exp.Properties.Location.POST_NAME</span> +</span><span id="Parser-1208"><a href="#Parser-1208"><span class="linenos">1208</span></a> <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">COMMA</span><span class="p">)</span> +</span><span id="Parser-1209"><a href="#Parser-1209"><span class="linenos">1209</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">(</span><span class="n">before</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="Parser-1210"><a href="#Parser-1210"><span class="linenos">1210</span></a> +</span><span id="Parser-1211"><a href="#Parser-1211"><span class="linenos">1211</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">table_parts</span><span class="p">)</span> +</span><span id="Parser-1212"><a href="#Parser-1212"><span class="linenos">1212</span></a> +</span><span id="Parser-1213"><a href="#Parser-1213"><span class="linenos">1213</span></a> <span class="c1"># exp.Properties.Location.POST_SCHEMA and POST_WITH</span> +</span><span id="Parser-1214"><a href="#Parser-1214"><span class="linenos">1214</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">())</span> +</span><span id="Parser-1215"><a href="#Parser-1215"><span class="linenos">1215</span></a> +</span><span id="Parser-1216"><a href="#Parser-1216"><span class="linenos">1216</span></a> <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">ALIAS</span><span class="p">)</span> +</span><span id="Parser-1217"><a href="#Parser-1217"><span class="linenos">1217</span></a> <span class="k">if</span> <span class="ow">not</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">DDL_SELECT_TOKENS</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="Parser-1218"><a href="#Parser-1218"><span class="linenos">1218</span></a> <span class="c1"># exp.Properties.Location.POST_ALIAS</span> +</span><span id="Parser-1219"><a href="#Parser-1219"><span class="linenos">1219</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">())</span> +</span><span id="Parser-1220"><a href="#Parser-1220"><span class="linenos">1220</span></a> +</span><span id="Parser-1221"><a href="#Parser-1221"><span class="linenos">1221</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_ddl_select</span><span class="p">()</span> +</span><span id="Parser-1222"><a href="#Parser-1222"><span class="linenos">1222</span></a> +</span><span id="Parser-1223"><a href="#Parser-1223"><span class="linenos">1223</span></a> <span class="k">if</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">:</span> +</span><span id="Parser-1224"><a href="#Parser-1224"><span class="linenos">1224</span></a> <span class="n">indexes</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-1225"><a href="#Parser-1225"><span class="linenos">1225</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Parser-1226"><a href="#Parser-1226"><span class="linenos">1226</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_index</span><span class="p">()</span> +</span><span id="Parser-1227"><a href="#Parser-1227"><span class="linenos">1227</span></a> +</span><span id="Parser-1228"><a href="#Parser-1228"><span class="linenos">1228</span></a> <span class="c1"># exp.Properties.Location.POST_EXPRESSION and POST_INDEX</span> +</span><span id="Parser-1229"><a href="#Parser-1229"><span class="linenos">1229</span></a> <span class="n">extend_props</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_properties</span><span class="p">())</span> +</span><span id="Parser-1230"><a href="#Parser-1230"><span class="linenos">1230</span></a> +</span><span id="Parser-1231"><a href="#Parser-1231"><span class="linenos">1231</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">index</span><span class="p">:</span> +</span><span id="Parser-1232"><a href="#Parser-1232"><span class="linenos">1232</span></a> <span class="k">break</span> +</span><span id="Parser-1233"><a href="#Parser-1233"><span class="linenos">1233</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1234"><a href="#Parser-1234"><span class="linenos">1234</span></a> <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">COMMA</span><span class="p">)</span> +</span><span id="Parser-1235"><a href="#Parser-1235"><span class="linenos">1235</span></a> <span class="n">indexes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-1236"><a href="#Parser-1236"><span class="linenos">1236</span></a> <span class="k">elif</span> <span class="n">create_token</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VIEW</span><span class="p">:</span> +</span><span id="Parser-1237"><a href="#Parser-1237"><span class="linenos">1237</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"SCHEMA"</span><span class="p">,</span> <span class="s2">"BINDING"</span><span class="p">):</span> +</span><span id="Parser-1238"><a href="#Parser-1238"><span class="linenos">1238</span></a> <span class="n">no_schema_binding</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Parser-1239"><a href="#Parser-1239"><span class="linenos">1239</span></a> +</span><span id="Parser-1240"><a href="#Parser-1240"><span class="linenos">1240</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CLONE"</span><span class="p">):</span> +</span><span id="Parser-1241"><a href="#Parser-1241"><span class="linenos">1241</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-1242"><a href="#Parser-1242"><span class="linenos">1242</span></a> <span class="n">when</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">({</span><span class="s2">"AT"</span><span class="p">,</span> <span class="s2">"BEFORE"</span><span class="p">})</span> <span class="ow">and</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="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Parser-1243"><a href="#Parser-1243"><span class="linenos">1243</span></a> <span class="n">clone_kind</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Parser-1244"><a href="#Parser-1244"><span class="linenos">1244</span></a> <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_PAREN</span><span class="p">)</span> +</span><span id="Parser-1245"><a href="#Parser-1245"><span class="linenos">1245</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CLONE_KINDS</span><span class="p">)</span> +</span><span id="Parser-1246"><a href="#Parser-1246"><span class="linenos">1246</span></a> <span class="ow">and</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="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Parser-1247"><a href="#Parser-1247"><span class="linenos">1247</span></a> <span class="p">)</span> +</span><span id="Parser-1248"><a href="#Parser-1248"><span class="linenos">1248</span></a> <span class="n">clone_expression</span> <span class="o">=</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">FARROW</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="Parser-1249"><a href="#Parser-1249"><span class="linenos">1249</span></a> <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">R_PAREN</span><span class="p">)</span> +</span><span id="Parser-1250"><a href="#Parser-1250"><span class="linenos">1250</span></a> <span class="n">clone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-1251"><a href="#Parser-1251"><span class="linenos">1251</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Clone</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">clone</span><span class="p">,</span> <span class="n">when</span><span class="o">=</span><span class="n">when</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">clone_kind</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">clone_expression</span> +</span><span id="Parser-1252"><a href="#Parser-1252"><span class="linenos">1252</span></a> <span class="p">)</span> +</span><span id="Parser-1253"><a href="#Parser-1253"><span class="linenos">1253</span></a> +</span><span id="Parser-1254"><a href="#Parser-1254"><span class="linenos">1254</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><span id="Parser-1255"><a href="#Parser-1255"><span class="linenos">1255</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Create</span><span class="p">,</span> +</span><span id="Parser-1256"><a href="#Parser-1256"><span class="linenos">1256</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="Parser-1257"><a href="#Parser-1257"><span class="linenos">1257</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">create_token</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> +</span><span id="Parser-1258"><a href="#Parser-1258"><span class="linenos">1258</span></a> <span class="n">replace</span><span class="o">=</span><span class="n">replace</span><span class="p">,</span> +</span><span id="Parser-1259"><a href="#Parser-1259"><span class="linenos">1259</span></a> <span class="n">unique</span><span class="o">=</span><span class="n">unique</span><span class="p">,</span> +</span><span id="Parser-1260"><a href="#Parser-1260"><span class="linenos">1260</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> +</span><span id="Parser-1261"><a href="#Parser-1261"><span class="linenos">1261</span></a> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span><span class="p">,</span> +</span><span id="Parser-1262"><a href="#Parser-1262"><span class="linenos">1262</span></a> <span class="n">properties</span><span class="o">=</span><span class="n">properties</span><span class="p">,</span> +</span><span id="Parser-1263"><a href="#Parser-1263"><span class="linenos">1263</span></a> <span class="n">indexes</span><span class="o">=</span><span class="n">indexes</span><span class="p">,</span> +</span><span id="Parser-1264"><a href="#Parser-1264"><span class="linenos">1264</span></a> <span class="n">no_schema_binding</span><span class="o">=</span><span class="n">no_schema_binding</span><span class="p">,</span> +</span><span id="Parser-1265"><a href="#Parser-1265"><span class="linenos">1265</span></a> <span class="n">begin</span><span class="o">=</span><span class="n">begin</span><span class="p">,</span> +</span><span id="Parser-1266"><a href="#Parser-1266"><span class="linenos">1266</span></a> <span class="n">clone</span><span class="o">=</span><span class="n">clone</span><span class="p">,</span> +</span><span id="Parser-1267"><a href="#Parser-1267"><span class="linenos">1267</span></a> <span class="p">)</span> +</span><span id="Parser-1268"><a href="#Parser-1268"><span class="linenos">1268</span></a> +</span><span id="Parser-1269"><a href="#Parser-1269"><span class="linenos">1269</span></a> <span class="k">def</span> <span class="nf">_parse_property_before</span><span class="p">(</span><span class="bp">self</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="Parser-1270"><a href="#Parser-1270"><span class="linenos">1270</span></a> <span class="c1"># only used for teradata currently</span> +</span><span id="Parser-1271"><a href="#Parser-1271"><span class="linenos">1271</span></a> <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">COMMA</span><span class="p">)</span> +</span><span id="Parser-1272"><a href="#Parser-1272"><span class="linenos">1272</span></a> +</span><span id="Parser-1273"><a href="#Parser-1273"><span class="linenos">1273</span></a> <span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Parser-1274"><a href="#Parser-1274"><span class="linenos">1274</span></a> <span class="s2">"no"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">),</span> +</span><span id="Parser-1275"><a href="#Parser-1275"><span class="linenos">1275</span></a> <span class="s2">"dual"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DUAL"</span><span class="p">),</span> +</span><span id="Parser-1276"><a href="#Parser-1276"><span class="linenos">1276</span></a> <span class="s2">"before"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BEFORE"</span><span class="p">),</span> +</span><span id="Parser-1277"><a href="#Parser-1277"><span class="linenos">1277</span></a> <span class="s2">"default"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFAULT"</span><span class="p">),</span> +</span><span id="Parser-1278"><a href="#Parser-1278"><span class="linenos">1278</span></a> <span class="s2">"local"</span><span class="p">:</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LOCAL"</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"LOCAL"</span><span class="p">)</span> +</span><span id="Parser-1279"><a href="#Parser-1279"><span class="linenos">1279</span></a> <span class="ow">or</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NOT"</span><span class="p">,</span> <span class="s2">"LOCAL"</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"NOT LOCAL"</span><span class="p">),</span> +</span><span id="Parser-1280"><a href="#Parser-1280"><span class="linenos">1280</span></a> <span class="s2">"after"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AFTER"</span><span class="p">),</span> +</span><span id="Parser-1281"><a href="#Parser-1281"><span class="linenos">1281</span></a> <span class="s2">"minimum"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"MIN"</span><span class="p">,</span> <span class="s2">"MINIMUM"</span><span class="p">)),</span> +</span><span id="Parser-1282"><a href="#Parser-1282"><span class="linenos">1282</span></a> <span class="s2">"maximum"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"MAX"</span><span class="p">,</span> <span class="s2">"MAXIMUM"</span><span class="p">)),</span> +</span><span id="Parser-1283"><a href="#Parser-1283"><span class="linenos">1283</span></a> <span class="p">}</span> +</span><span id="Parser-1284"><a href="#Parser-1284"><span class="linenos">1284</span></a> +</span><span id="Parser-1285"><a href="#Parser-1285"><span class="linenos">1285</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">PROPERTY_PARSERS</span><span class="p">):</span> +</span><span id="Parser-1286"><a href="#Parser-1286"><span class="linenos">1286</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTY_PARSERS</span><span class="p">[</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="o">.</span><span class="n">upper</span><span class="p">()]</span> +</span><span id="Parser-1287"><a href="#Parser-1287"><span class="linenos">1287</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="Parser-1288"><a href="#Parser-1288"><span class="linenos">1288</span></a> <span class="k">return</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="n">v</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="k">if</span> <span class="n">v</span><span class="p">})</span> +</span><span id="Parser-1289"><a href="#Parser-1289"><span class="linenos">1289</span></a> <span class="k">except</span> <span class="ne">TypeError</span><span class="p">:</span> +</span><span id="Parser-1290"><a href="#Parser-1290"><span class="linenos">1290</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Cannot parse property '</span><span class="si">{</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="si">}</span><span class="s2">'"</span><span class="p">)</span> +</span><span id="Parser-1291"><a href="#Parser-1291"><span class="linenos">1291</span></a> +</span><span id="Parser-1292"><a href="#Parser-1292"><span class="linenos">1292</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1293"><a href="#Parser-1293"><span class="linenos">1293</span></a> +</span><span id="Parser-1294"><a href="#Parser-1294"><span class="linenos">1294</span></a> <span class="k">def</span> <span class="nf">_parse_property</span><span class="p">(</span><span class="bp">self</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="Parser-1295"><a href="#Parser-1295"><span class="linenos">1295</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">PROPERTY_PARSERS</span><span class="p">):</span> +</span><span id="Parser-1296"><a href="#Parser-1296"><span class="linenos">1296</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PROPERTY_PARSERS</span><span class="p">[</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="o">.</span><span class="n">upper</span><span class="p">()](</span><span class="bp">self</span><span class="p">)</span> +</span><span id="Parser-1297"><a href="#Parser-1297"><span class="linenos">1297</span></a> +</span><span id="Parser-1298"><a href="#Parser-1298"><span class="linenos">1298</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CHARACTER_SET</span><span class="p">):</span> +</span><span id="Parser-1299"><a href="#Parser-1299"><span class="linenos">1299</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_character_set</span><span class="p">(</span><span class="n">default</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-1300"><a href="#Parser-1300"><span class="linenos">1300</span></a> +</span><span id="Parser-1301"><a href="#Parser-1301"><span class="linenos">1301</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"COMPOUND"</span><span class="p">,</span> <span class="s2">"SORTKEY"</span><span class="p">):</span> +</span><span id="Parser-1302"><a href="#Parser-1302"><span class="linenos">1302</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_sortkey</span><span class="p">(</span><span class="n">compound</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-1303"><a href="#Parser-1303"><span class="linenos">1303</span></a> +</span><span id="Parser-1304"><a href="#Parser-1304"><span class="linenos">1304</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SQL"</span><span class="p">,</span> <span class="s2">"SECURITY"</span><span class="p">):</span> +</span><span id="Parser-1305"><a href="#Parser-1305"><span class="linenos">1305</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">SqlSecurityProperty</span><span class="p">,</span> <span class="n">definer</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFINER"</span><span class="p">))</span> +</span><span id="Parser-1306"><a href="#Parser-1306"><span class="linenos">1306</span></a> +</span><span id="Parser-1307"><a href="#Parser-1307"><span class="linenos">1307</span></a> <span class="n">assignment</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span> +</span><span id="Parser-1308"><a href="#Parser-1308"><span class="linenos">1308</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">False</span> +</span><span id="Parser-1309"><a href="#Parser-1309"><span class="linenos">1309</span></a> <span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</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="Parser-1310"><a href="#Parser-1310"><span class="linenos">1310</span></a> +</span><span id="Parser-1311"><a href="#Parser-1311"><span class="linenos">1311</span></a> <span class="k">if</span> <span class="n">assignment</span><span class="p">:</span> +</span><span id="Parser-1312"><a href="#Parser-1312"><span class="linenos">1312</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var_or_string</span><span class="p">()</span> +</span><span id="Parser-1313"><a href="#Parser-1313"><span class="linenos">1313</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="Parser-1314"><a href="#Parser-1314"><span class="linenos">1314</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">Property</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">())</span> +</span><span id="Parser-1315"><a href="#Parser-1315"><span class="linenos">1315</span></a> +</span><span id="Parser-1316"><a href="#Parser-1316"><span class="linenos">1316</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1317"><a href="#Parser-1317"><span class="linenos">1317</span></a> +</span><span id="Parser-1318"><a href="#Parser-1318"><span class="linenos">1318</span></a> <span class="k">def</span> <span class="nf">_parse_stored</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">FileFormatProperty</span><span class="p">:</span> +</span><span id="Parser-1319"><a href="#Parser-1319"><span class="linenos">1319</span></a> <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">ALIAS</span><span class="p">)</span> +</span><span id="Parser-1320"><a href="#Parser-1320"><span class="linenos">1320</span></a> +</span><span id="Parser-1321"><a href="#Parser-1321"><span class="linenos">1321</span></a> <span class="n">input_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INPUTFORMAT"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="Parser-1322"><a href="#Parser-1322"><span class="linenos">1322</span></a> <span class="n">output_format</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OUTPUTFORMAT"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="Parser-1323"><a href="#Parser-1323"><span class="linenos">1323</span></a> +</span><span id="Parser-1324"><a href="#Parser-1324"><span class="linenos">1324</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><span id="Parser-1325"><a href="#Parser-1325"><span class="linenos">1325</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FileFormatProperty</span><span class="p">,</span> +</span><span id="Parser-1326"><a href="#Parser-1326"><span class="linenos">1326</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-1327"><a href="#Parser-1327"><span class="linenos">1327</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">InputOutputFormat</span><span class="p">,</span> <span class="n">input_format</span><span class="o">=</span><span class="n">input_format</span><span class="p">,</span> <span class="n">output_format</span><span class="o">=</span><span class="n">output_format</span> +</span><span id="Parser-1328"><a href="#Parser-1328"><span class="linenos">1328</span></a> <span class="p">)</span> +</span><span id="Parser-1329"><a href="#Parser-1329"><span class="linenos">1329</span></a> <span class="k">if</span> <span class="n">input_format</span> <span class="ow">or</span> <span class="n">output_format</span> +</span><span id="Parser-1330"><a href="#Parser-1330"><span class="linenos">1330</span></a> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var_or_string</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(),</span> +</span><span id="Parser-1331"><a href="#Parser-1331"><span class="linenos">1331</span></a> <span class="p">)</span> +</span><span id="Parser-1332"><a href="#Parser-1332"><span class="linenos">1332</span></a> +</span><span id="Parser-1333"><a href="#Parser-1333"><span class="linenos">1333</span></a> <span class="k">def</span> <span class="nf">_parse_property_assignment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">])</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="Parser-1334"><a href="#Parser-1334"><span class="linenos">1334</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="Parser-1335"><a href="#Parser-1335"><span class="linenos">1335</span></a> <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">ALIAS</span><span class="p">)</span> +</span><span id="Parser-1336"><a href="#Parser-1336"><span class="linenos">1336</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_class</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_field</span><span class="p">())</span> +</span><span id="Parser-1337"><a href="#Parser-1337"><span class="linenos">1337</span></a> +</span><span id="Parser-1338"><a href="#Parser-1338"><span class="linenos">1338</span></a> <span class="k">def</span> <span class="nf">_parse_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">before</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span 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">Properties</span><span class="p">]:</span> +</span><span id="Parser-1339"><a href="#Parser-1339"><span class="linenos">1339</span></a> <span class="n">properties</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-1340"><a href="#Parser-1340"><span class="linenos">1340</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Parser-1341"><a href="#Parser-1341"><span class="linenos">1341</span></a> <span class="k">if</span> <span class="n">before</span><span class="p">:</span> +</span><span id="Parser-1342"><a href="#Parser-1342"><span class="linenos">1342</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_property_before</span><span class="p">()</span> +</span><span id="Parser-1343"><a href="#Parser-1343"><span class="linenos">1343</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1344"><a href="#Parser-1344"><span class="linenos">1344</span></a> <span class="n">prop</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_property</span><span class="p">()</span> +</span><span id="Parser-1345"><a href="#Parser-1345"><span class="linenos">1345</span></a> +</span><span id="Parser-1346"><a href="#Parser-1346"><span class="linenos">1346</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">prop</span><span class="p">:</span> +</span><span id="Parser-1347"><a href="#Parser-1347"><span class="linenos">1347</span></a> <span class="k">break</span> +</span><span id="Parser-1348"><a href="#Parser-1348"><span class="linenos">1348</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">prop</span><span class="p">):</span> +</span><span id="Parser-1349"><a href="#Parser-1349"><span class="linenos">1349</span></a> <span class="n">properties</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> +</span><span id="Parser-1350"><a href="#Parser-1350"><span class="linenos">1350</span></a> +</span><span id="Parser-1351"><a href="#Parser-1351"><span class="linenos">1351</span></a> <span class="k">if</span> <span class="n">properties</span><span class="p">:</span> +</span><span id="Parser-1352"><a href="#Parser-1352"><span class="linenos">1352</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">Properties</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">properties</span><span class="p">)</span> +</span><span id="Parser-1353"><a href="#Parser-1353"><span class="linenos">1353</span></a> +</span><span id="Parser-1354"><a href="#Parser-1354"><span class="linenos">1354</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1355"><a href="#Parser-1355"><span class="linenos">1355</span></a> +</span><span id="Parser-1356"><a href="#Parser-1356"><span class="linenos">1356</span></a> <span class="k">def</span> <span class="nf">_parse_fallback</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">no</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">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">:</span> +</span><span id="Parser-1357"><a href="#Parser-1357"><span class="linenos">1357</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><span id="Parser-1358"><a href="#Parser-1358"><span class="linenos">1358</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FallbackProperty</span><span class="p">,</span> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">,</span> <span class="n">protection</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PROTECTION"</span><span class="p">)</span> +</span><span id="Parser-1359"><a href="#Parser-1359"><span class="linenos">1359</span></a> <span class="p">)</span> +</span><span id="Parser-1360"><a href="#Parser-1360"><span class="linenos">1360</span></a> +</span><span id="Parser-1361"><a href="#Parser-1361"><span class="linenos">1361</span></a> <span class="k">def</span> <span class="nf">_parse_volatile_property</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">VolatileProperty</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">StabilityProperty</span><span class="p">:</span> +</span><span id="Parser-1362"><a href="#Parser-1362"><span class="linenos">1362</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">>=</span> <span class="mi">2</span><span class="p">:</span> +</span><span id="Parser-1363"><a href="#Parser-1363"><span class="linenos">1363</span></a> <span class="n">pre_volatile_token</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">2</span><span class="p">]</span> +</span><span id="Parser-1364"><a href="#Parser-1364"><span class="linenos">1364</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1365"><a href="#Parser-1365"><span class="linenos">1365</span></a> <span class="n">pre_volatile_token</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1366"><a href="#Parser-1366"><span class="linenos">1366</span></a> +</span><span id="Parser-1367"><a href="#Parser-1367"><span class="linenos">1367</span></a> <span class="k">if</span> <span class="n">pre_volatile_token</span> <span class="ow">and</span> <span class="n">pre_volatile_token</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRE_VOLATILE_TOKENS</span><span class="p">:</span> +</span><span id="Parser-1368"><a href="#Parser-1368"><span class="linenos">1368</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">VolatileProperty</span><span class="p">()</span> +</span><span id="Parser-1369"><a href="#Parser-1369"><span class="linenos">1369</span></a> +</span><span id="Parser-1370"><a href="#Parser-1370"><span class="linenos">1370</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">StabilityProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">"VOLATILE"</span><span class="p">))</span> +</span><span id="Parser-1371"><a href="#Parser-1371"><span class="linenos">1371</span></a> +</span><span id="Parser-1372"><a href="#Parser-1372"><span class="linenos">1372</span></a> <span class="k">def</span> <span class="nf">_parse_with_property</span><span class="p">(</span> +</span><span id="Parser-1373"><a href="#Parser-1373"><span class="linenos">1373</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Parser-1374"><a href="#Parser-1374"><span class="linenos">1374</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 class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">List</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><span id="Parser-1375"><a href="#Parser-1375"><span class="linenos">1375</span></a> <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">WITH</span><span class="p">)</span> +</span><span id="Parser-1376"><a href="#Parser-1376"><span class="linenos">1376</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_PAREN</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="Parser-1377"><a href="#Parser-1377"><span class="linenos">1377</span></a> <span class="k">return</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_property</span><span class="p">)</span> +</span><span id="Parser-1378"><a href="#Parser-1378"><span class="linenos">1378</span></a> +</span><span id="Parser-1379"><a href="#Parser-1379"><span class="linenos">1379</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"JOURNAL"</span><span class="p">):</span> +</span><span id="Parser-1380"><a href="#Parser-1380"><span class="linenos">1380</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_withjournaltable</span><span class="p">()</span> +</span><span id="Parser-1381"><a href="#Parser-1381"><span class="linenos">1381</span></a> +</span><span id="Parser-1382"><a href="#Parser-1382"><span class="linenos">1382</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DATA"</span><span class="p">):</span> +</span><span id="Parser-1383"><a href="#Parser-1383"><span class="linenos">1383</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_withdata</span><span class="p">(</span><span class="n">no</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Parser-1384"><a href="#Parser-1384"><span class="linenos">1384</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"DATA"</span><span class="p">):</span> +</span><span id="Parser-1385"><a href="#Parser-1385"><span class="linenos">1385</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_withdata</span><span class="p">(</span><span class="n">no</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-1386"><a href="#Parser-1386"><span class="linenos">1386</span></a> +</span><span id="Parser-1387"><a href="#Parser-1387"><span class="linenos">1387</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> +</span><span id="Parser-1388"><a href="#Parser-1388"><span class="linenos">1388</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1389"><a href="#Parser-1389"><span class="linenos">1389</span></a> +</span><span id="Parser-1390"><a href="#Parser-1390"><span class="linenos">1390</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_withisolatedloading</span><span class="p">()</span> +</span><span id="Parser-1391"><a href="#Parser-1391"><span class="linenos">1391</span></a> +</span><span id="Parser-1392"><a href="#Parser-1392"><span class="linenos">1392</span></a> <span class="c1"># https://dev.mysql.com/doc/refman/8.0/en/create-view.html</span> +</span><span id="Parser-1393"><a href="#Parser-1393"><span class="linenos">1393</span></a> <span class="k">def</span> <span class="nf">_parse_definer</span><span class="p">(</span><span class="bp">self</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">DefinerProperty</span><span class="p">]:</span> +</span><span id="Parser-1394"><a href="#Parser-1394"><span class="linenos">1394</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="Parser-1395"><a href="#Parser-1395"><span class="linenos">1395</span></a> +</span><span id="Parser-1396"><a href="#Parser-1396"><span class="linenos">1396</span></a> <span class="n">user</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="Parser-1397"><a href="#Parser-1397"><span class="linenos">1397</span></a> <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">PARAMETER</span><span class="p">)</span> +</span><span id="Parser-1398"><a href="#Parser-1398"><span class="linenos">1398</span></a> <span class="n">host</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> <span class="ow">or</span> <span class="p">(</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">MOD</span><span class="p">)</span> <span class="ow">and</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="Parser-1399"><a href="#Parser-1399"><span class="linenos">1399</span></a> +</span><span id="Parser-1400"><a href="#Parser-1400"><span class="linenos">1400</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">user</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">host</span><span class="p">:</span> +</span><span id="Parser-1401"><a href="#Parser-1401"><span class="linenos">1401</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1402"><a href="#Parser-1402"><span class="linenos">1402</span></a> +</span><span id="Parser-1403"><a href="#Parser-1403"><span class="linenos">1403</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">DefinerProperty</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">user</span><span class="si">}</span><span class="s2">@</span><span class="si">{</span><span class="n">host</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Parser-1404"><a href="#Parser-1404"><span class="linenos">1404</span></a> +</span><span id="Parser-1405"><a href="#Parser-1405"><span class="linenos">1405</span></a> <span class="k">def</span> <span class="nf">_parse_withjournaltable</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">WithJournalTableProperty</span><span class="p">:</span> +</span><span id="Parser-1406"><a href="#Parser-1406"><span class="linenos">1406</span></a> <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">TABLE</span><span class="p">)</span> +</span><span id="Parser-1407"><a href="#Parser-1407"><span class="linenos">1407</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="Parser-1408"><a href="#Parser-1408"><span class="linenos">1408</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">WithJournalTableProperty</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_table_parts</span><span class="p">())</span> +</span><span id="Parser-1409"><a href="#Parser-1409"><span class="linenos">1409</span></a> +</span><span id="Parser-1410"><a href="#Parser-1410"><span class="linenos">1410</span></a> <span class="k">def</span> <span class="nf">_parse_log</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">no</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">exp</span><span class="o">.</span><span class="n">LogProperty</span><span class="p">:</span> +</span><span id="Parser-1411"><a href="#Parser-1411"><span class="linenos">1411</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">LogProperty</span><span class="p">,</span> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">)</span> +</span><span id="Parser-1412"><a href="#Parser-1412"><span class="linenos">1412</span></a> +</span><span id="Parser-1413"><a href="#Parser-1413"><span class="linenos">1413</span></a> <span class="k">def</span> <span class="nf">_parse_journal</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">JournalProperty</span><span class="p">:</span> +</span><span id="Parser-1414"><a href="#Parser-1414"><span class="linenos">1414</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">JournalProperty</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="Parser-1415"><a href="#Parser-1415"><span class="linenos">1415</span></a> +</span><span id="Parser-1416"><a href="#Parser-1416"><span class="linenos">1416</span></a> <span class="k">def</span> <span class="nf">_parse_checksum</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">ChecksumProperty</span><span class="p">:</span> +</span><span id="Parser-1417"><a href="#Parser-1417"><span class="linenos">1417</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="Parser-1418"><a href="#Parser-1418"><span class="linenos">1418</span></a> +</span><span id="Parser-1419"><a href="#Parser-1419"><span class="linenos">1419</span></a> <span class="n">on</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1420"><a href="#Parser-1420"><span class="linenos">1420</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">ON</span><span class="p">):</span> +</span><span id="Parser-1421"><a href="#Parser-1421"><span class="linenos">1421</span></a> <span class="n">on</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Parser-1422"><a href="#Parser-1422"><span class="linenos">1422</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OFF"</span><span class="p">):</span> +</span><span id="Parser-1423"><a href="#Parser-1423"><span class="linenos">1423</span></a> <span class="n">on</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-1424"><a href="#Parser-1424"><span class="linenos">1424</span></a> +</span><span id="Parser-1425"><a href="#Parser-1425"><span class="linenos">1425</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">ChecksumProperty</span><span class="p">,</span> <span class="n">on</span><span class="o">=</span><span class="n">on</span><span class="p">,</span> <span class="n">default</span><span class="o">=</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">DEFAULT</span><span class="p">))</span> +</span><span id="Parser-1426"><a href="#Parser-1426"><span class="linenos">1426</span></a> +</span><span id="Parser-1427"><a href="#Parser-1427"><span class="linenos">1427</span></a> <span class="k">def</span> <span class="nf">_parse_cluster</span><span class="p">(</span><span class="bp">self</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">Cluster</span><span class="p">]:</span> +</span><span id="Parser-1428"><a href="#Parser-1428"><span class="linenos">1428</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">Cluster</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_ordered</span><span class="p">))</span> +</span><span id="Parser-1429"><a href="#Parser-1429"><span class="linenos">1429</span></a> +</span><span id="Parser-1430"><a href="#Parser-1430"><span class="linenos">1430</span></a> <span class="k">def</span> <span class="nf">_parse_copy_property</span><span class="p">(</span><span class="bp">self</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">CopyGrantsProperty</span><span class="p">]:</span> +</span><span id="Parser-1431"><a href="#Parser-1431"><span class="linenos">1431</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"GRANTS"</span><span class="p">):</span> +</span><span id="Parser-1432"><a href="#Parser-1432"><span class="linenos">1432</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="Parser-1433"><a href="#Parser-1433"><span class="linenos">1433</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1434"><a href="#Parser-1434"><span class="linenos">1434</span></a> +</span><span id="Parser-1435"><a href="#Parser-1435"><span class="linenos">1435</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">CopyGrantsProperty</span><span class="p">)</span> +</span><span id="Parser-1436"><a href="#Parser-1436"><span class="linenos">1436</span></a> +</span><span id="Parser-1437"><a href="#Parser-1437"><span class="linenos">1437</span></a> <span class="k">def</span> <span class="nf">_parse_freespace</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">FreespaceProperty</span><span class="p">:</span> +</span><span id="Parser-1438"><a href="#Parser-1438"><span class="linenos">1438</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="Parser-1439"><a href="#Parser-1439"><span class="linenos">1439</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><span id="Parser-1440"><a href="#Parser-1440"><span class="linenos">1440</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">FreespaceProperty</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_number</span><span class="p">(),</span> <span class="n">percent</span><span class="o">=</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">PERCENT</span><span class="p">)</span> +</span><span id="Parser-1441"><a href="#Parser-1441"><span class="linenos">1441</span></a> <span class="p">)</span> +</span><span id="Parser-1442"><a href="#Parser-1442"><span class="linenos">1442</span></a> +</span><span id="Parser-1443"><a href="#Parser-1443"><span class="linenos">1443</span></a> <span class="k">def</span> <span class="nf">_parse_mergeblockratio</span><span class="p">(</span> +</span><span id="Parser-1444"><a href="#Parser-1444"><span class="linenos">1444</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">no</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="n">default</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-1445"><a href="#Parser-1445"><span class="linenos">1445</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">:</span> +</span><span id="Parser-1446"><a href="#Parser-1446"><span class="linenos">1446</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">EQ</span><span class="p">):</span> +</span><span id="Parser-1447"><a href="#Parser-1447"><span class="linenos">1447</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><span id="Parser-1448"><a href="#Parser-1448"><span class="linenos">1448</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MergeBlockRatioProperty</span><span class="p">,</span> +</span><span id="Parser-1449"><a href="#Parser-1449"><span class="linenos">1449</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">(),</span> +</span><span id="Parser-1450"><a href="#Parser-1450"><span class="linenos">1450</span></a> <span class="n">percent</span><span class="o">=</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">PERCENT</span><span class="p">),</span> +</span><span id="Parser-1451"><a href="#Parser-1451"><span class="linenos">1451</span></a> <span class="p">)</span> +</span><span id="Parser-1452"><a href="#Parser-1452"><span class="linenos">1452</span></a> +</span><span id="Parser-1453"><a href="#Parser-1453"><span class="linenos">1453</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">MergeBlockRatioProperty</span><span class="p">,</span> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">default</span><span class="p">)</span> +</span><span id="Parser-1454"><a href="#Parser-1454"><span class="linenos">1454</span></a> +</span><span id="Parser-1455"><a href="#Parser-1455"><span class="linenos">1455</span></a> <span class="k">def</span> <span class="nf">_parse_datablocksize</span><span class="p">(</span> +</span><span id="Parser-1456"><a href="#Parser-1456"><span class="linenos">1456</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Parser-1457"><a href="#Parser-1457"><span class="linenos">1457</span></a> <span class="n">default</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Parser-1458"><a href="#Parser-1458"><span class="linenos">1458</span></a> <span class="n">minimum</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Parser-1459"><a href="#Parser-1459"><span class="linenos">1459</span></a> <span class="n">maximum</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Parser-1460"><a href="#Parser-1460"><span class="linenos">1460</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">:</span> +</span><span id="Parser-1461"><a href="#Parser-1461"><span class="linenos">1461</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="Parser-1462"><a href="#Parser-1462"><span class="linenos">1462</span></a> <span class="n">size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> </span><span id="Parser-1463"><a href="#Parser-1463"><span class="linenos">1463</span></a> -</span><span id="Parser-1464"><a href="#Parser-1464"><span class="linenos">1464</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><span id="Parser-1465"><a href="#Parser-1465"><span class="linenos">1465</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">,</span> -</span><span id="Parser-1466"><a href="#Parser-1466"><span class="linenos">1466</span></a> <span class="n">size</span><span class="o">=</span><span class="n">size</span><span class="p">,</span> -</span><span id="Parser-1467"><a href="#Parser-1467"><span class="linenos">1467</span></a> <span class="n">units</span><span class="o">=</span><span class="n">units</span><span class="p">,</span> -</span><span id="Parser-1468"><a href="#Parser-1468"><span class="linenos">1468</span></a> <span class="n">default</span><span class="o">=</span><span class="n">default</span><span class="p">,</span> -</span><span id="Parser-1469"><a href="#Parser-1469"><span class="linenos">1469</span></a> <span class="n">minimum</span><span class="o">=</span><span class="n">minimum</span><span class="p">,</span> -</span><span id="Parser-1470"><a href="#Parser-1470"><span class="linenos">1470</span></a> <span class="n">maximum</span><span class="o">=</span><span class="n">maximum</span><span class="p">,</span> -</span><span id="Parser-1471"><a href="#Parser-1471"><span class="linenos">1471</span></a> <span class="p">)</span> -</span><span id="Parser-1472"><a href="#Parser-1472"><span class="linenos">1472</span></a> -</span><span id="Parser-1473"><a href="#Parser-1473"><span class="linenos">1473</span></a> <span class="k">def</span> <span class="nf">_parse_blockcompression</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">BlockCompressionProperty</span><span class="p">:</span> -</span><span id="Parser-1474"><a href="#Parser-1474"><span class="linenos">1474</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="Parser-1475"><a href="#Parser-1475"><span class="linenos">1475</span></a> <span class="n">always</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ALWAYS"</span><span class="p">)</span> -</span><span id="Parser-1476"><a href="#Parser-1476"><span class="linenos">1476</span></a> <span class="n">manual</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MANUAL"</span><span class="p">)</span> -</span><span id="Parser-1477"><a href="#Parser-1477"><span class="linenos">1477</span></a> <span class="n">never</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NEVER"</span><span class="p">)</span> -</span><span id="Parser-1478"><a href="#Parser-1478"><span class="linenos">1478</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFAULT"</span><span class="p">)</span> -</span><span id="Parser-1479"><a href="#Parser-1479"><span class="linenos">1479</span></a> -</span><span id="Parser-1480"><a href="#Parser-1480"><span class="linenos">1480</span></a> <span class="n">autotemp</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1481"><a href="#Parser-1481"><span class="linenos">1481</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AUTOTEMP"</span><span class="p">):</span> -</span><span id="Parser-1482"><a href="#Parser-1482"><span class="linenos">1482</span></a> <span class="n">autotemp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</span><span class="p">()</span> +</span><span id="Parser-1464"><a href="#Parser-1464"><span class="linenos">1464</span></a> <span class="n">units</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1465"><a href="#Parser-1465"><span class="linenos">1465</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"BYTES"</span><span class="p">,</span> <span class="s2">"KBYTES"</span><span class="p">,</span> <span class="s2">"KILOBYTES"</span><span class="p">)):</span> +</span><span id="Parser-1466"><a href="#Parser-1466"><span class="linenos">1466</span></a> <span class="n">units</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><span id="Parser-1467"><a href="#Parser-1467"><span class="linenos">1467</span></a> +</span><span id="Parser-1468"><a href="#Parser-1468"><span class="linenos">1468</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><span id="Parser-1469"><a href="#Parser-1469"><span class="linenos">1469</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataBlocksizeProperty</span><span class="p">,</span> +</span><span id="Parser-1470"><a href="#Parser-1470"><span class="linenos">1470</span></a> <span class="n">size</span><span class="o">=</span><span class="n">size</span><span class="p">,</span> +</span><span id="Parser-1471"><a href="#Parser-1471"><span class="linenos">1471</span></a> <span class="n">units</span><span class="o">=</span><span class="n">units</span><span class="p">,</span> +</span><span id="Parser-1472"><a href="#Parser-1472"><span class="linenos">1472</span></a> <span class="n">default</span><span class="o">=</span><span class="n">default</span><span class="p">,</span> +</span><span id="Parser-1473"><a href="#Parser-1473"><span class="linenos">1473</span></a> <span class="n">minimum</span><span class="o">=</span><span class="n">minimum</span><span class="p">,</span> +</span><span id="Parser-1474"><a href="#Parser-1474"><span class="linenos">1474</span></a> <span class="n">maximum</span><span class="o">=</span><span class="n">maximum</span><span class="p">,</span> +</span><span id="Parser-1475"><a href="#Parser-1475"><span class="linenos">1475</span></a> <span class="p">)</span> +</span><span id="Parser-1476"><a href="#Parser-1476"><span class="linenos">1476</span></a> +</span><span id="Parser-1477"><a href="#Parser-1477"><span class="linenos">1477</span></a> <span class="k">def</span> <span class="nf">_parse_blockcompression</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">BlockCompressionProperty</span><span class="p">:</span> +</span><span id="Parser-1478"><a href="#Parser-1478"><span class="linenos">1478</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="Parser-1479"><a href="#Parser-1479"><span class="linenos">1479</span></a> <span class="n">always</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ALWAYS"</span><span class="p">)</span> +</span><span id="Parser-1480"><a href="#Parser-1480"><span class="linenos">1480</span></a> <span class="n">manual</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MANUAL"</span><span class="p">)</span> +</span><span id="Parser-1481"><a href="#Parser-1481"><span class="linenos">1481</span></a> <span class="n">never</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NEVER"</span><span class="p">)</span> +</span><span id="Parser-1482"><a href="#Parser-1482"><span class="linenos">1482</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFAULT"</span><span class="p">)</span> </span><span id="Parser-1483"><a href="#Parser-1483"><span class="linenos">1483</span></a> -</span><span id="Parser-1484"><a href="#Parser-1484"><span class="linenos">1484</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><span id="Parser-1485"><a href="#Parser-1485"><span class="linenos">1485</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">,</span> -</span><span id="Parser-1486"><a href="#Parser-1486"><span class="linenos">1486</span></a> <span class="n">always</span><span class="o">=</span><span class="n">always</span><span class="p">,</span> -</span><span id="Parser-1487"><a href="#Parser-1487"><span class="linenos">1487</span></a> <span class="n">manual</span><span class="o">=</span><span class="n">manual</span><span class="p">,</span> -</span><span id="Parser-1488"><a href="#Parser-1488"><span class="linenos">1488</span></a> <span class="n">never</span><span class="o">=</span><span class="n">never</span><span class="p">,</span> -</span><span id="Parser-1489"><a href="#Parser-1489"><span class="linenos">1489</span></a> <span class="n">default</span><span class="o">=</span><span class="n">default</span><span class="p">,</span> -</span><span id="Parser-1490"><a href="#Parser-1490"><span class="linenos">1490</span></a> <span class="n">autotemp</span><span class="o">=</span><span class="n">autotemp</span><span class="p">,</span> -</span><span id="Parser-1491"><a href="#Parser-1491"><span class="linenos">1491</span></a> <span class="p">)</span> -</span><span id="Parser-1492"><a href="#Parser-1492"><span class="linenos">1492</span></a> -</span><span id="Parser-1493"><a href="#Parser-1493"><span class="linenos">1493</span></a> <span class="k">def</span> <span class="nf">_parse_withisolatedloading</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">IsolatedLoadingProperty</span><span class="p">:</span> -</span><span id="Parser-1494"><a href="#Parser-1494"><span class="linenos">1494</span></a> <span class="n">no</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">)</span> -</span><span id="Parser-1495"><a href="#Parser-1495"><span class="linenos">1495</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CONCURRENT"</span><span class="p">)</span> -</span><span id="Parser-1496"><a href="#Parser-1496"><span class="linenos">1496</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ISOLATED"</span><span class="p">,</span> <span class="s2">"LOADING"</span><span class="p">)</span> -</span><span id="Parser-1497"><a href="#Parser-1497"><span class="linenos">1497</span></a> <span class="n">for_all</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"ALL"</span><span class="p">)</span> -</span><span id="Parser-1498"><a href="#Parser-1498"><span class="linenos">1498</span></a> <span class="n">for_insert</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"INSERT"</span><span class="p">)</span> -</span><span id="Parser-1499"><a href="#Parser-1499"><span class="linenos">1499</span></a> <span class="n">for_none</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"NONE"</span><span class="p">)</span> -</span><span id="Parser-1500"><a href="#Parser-1500"><span class="linenos">1500</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><span id="Parser-1501"><a href="#Parser-1501"><span class="linenos">1501</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">,</span> -</span><span id="Parser-1502"><a href="#Parser-1502"><span class="linenos">1502</span></a> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">,</span> -</span><span id="Parser-1503"><a href="#Parser-1503"><span class="linenos">1503</span></a> <span class="n">concurrent</span><span class="o">=</span><span class="n">concurrent</span><span class="p">,</span> -</span><span id="Parser-1504"><a href="#Parser-1504"><span class="linenos">1504</span></a> <span class="n">for_all</span><span class="o">=</span><span class="n">for_all</span><span class="p">,</span> -</span><span id="Parser-1505"><a href="#Parser-1505"><span class="linenos">1505</span></a> <span class="n">for_insert</span><span class="o">=</span><span class="n">for_insert</span><span class="p">,</span> -</span><span id="Parser-1506"><a href="#Parser-1506"><span class="linenos">1506</span></a> <span class="n">for_none</span><span class="o">=</span><span class="n">for_none</span><span class="p">,</span> -</span><span id="Parser-1507"><a href="#Parser-1507"><span class="linenos">1507</span></a> <span class="p">)</span> -</span><span id="Parser-1508"><a href="#Parser-1508"><span class="linenos">1508</span></a> -</span><span id="Parser-1509"><a href="#Parser-1509"><span class="linenos">1509</span></a> <span class="k">def</span> <span class="nf">_parse_locking</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">LockingProperty</span><span class="p">:</span> -</span><span id="Parser-1510"><a href="#Parser-1510"><span class="linenos">1510</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">TABLE</span><span class="p">):</span> -</span><span id="Parser-1511"><a href="#Parser-1511"><span class="linenos">1511</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">"TABLE"</span> -</span><span id="Parser-1512"><a href="#Parser-1512"><span class="linenos">1512</span></a> <span class="k">elif</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">VIEW</span><span class="p">):</span> -</span><span id="Parser-1513"><a href="#Parser-1513"><span class="linenos">1513</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">"VIEW"</span> -</span><span id="Parser-1514"><a href="#Parser-1514"><span class="linenos">1514</span></a> <span class="k">elif</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">ROW</span><span class="p">):</span> -</span><span id="Parser-1515"><a href="#Parser-1515"><span class="linenos">1515</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">"ROW"</span> -</span><span id="Parser-1516"><a href="#Parser-1516"><span class="linenos">1516</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DATABASE"</span><span class="p">):</span> -</span><span id="Parser-1517"><a href="#Parser-1517"><span class="linenos">1517</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">"DATABASE"</span> -</span><span id="Parser-1518"><a href="#Parser-1518"><span class="linenos">1518</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1519"><a href="#Parser-1519"><span class="linenos">1519</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1520"><a href="#Parser-1520"><span class="linenos">1520</span></a> -</span><span id="Parser-1521"><a href="#Parser-1521"><span class="linenos">1521</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"DATABASE"</span><span class="p">,</span> <span class="s2">"TABLE"</span><span class="p">,</span> <span class="s2">"VIEW"</span><span class="p">):</span> -</span><span id="Parser-1522"><a href="#Parser-1522"><span class="linenos">1522</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">()</span> -</span><span id="Parser-1523"><a href="#Parser-1523"><span class="linenos">1523</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1524"><a href="#Parser-1524"><span class="linenos">1524</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1525"><a href="#Parser-1525"><span class="linenos">1525</span></a> -</span><span id="Parser-1526"><a href="#Parser-1526"><span class="linenos">1526</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">FOR</span><span class="p">):</span> -</span><span id="Parser-1527"><a href="#Parser-1527"><span class="linenos">1527</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="s2">"FOR"</span> -</span><span id="Parser-1528"><a href="#Parser-1528"><span class="linenos">1528</span></a> <span class="k">elif</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">IN</span><span class="p">):</span> -</span><span id="Parser-1529"><a href="#Parser-1529"><span class="linenos">1529</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="s2">"IN"</span> -</span><span id="Parser-1530"><a href="#Parser-1530"><span class="linenos">1530</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1531"><a href="#Parser-1531"><span class="linenos">1531</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1532"><a href="#Parser-1532"><span class="linenos">1532</span></a> -</span><span id="Parser-1533"><a href="#Parser-1533"><span class="linenos">1533</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ACCESS"</span><span class="p">):</span> -</span><span id="Parser-1534"><a href="#Parser-1534"><span class="linenos">1534</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"ACCESS"</span> -</span><span id="Parser-1535"><a href="#Parser-1535"><span class="linenos">1535</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"EXCL"</span><span class="p">,</span> <span class="s2">"EXCLUSIVE"</span><span class="p">)):</span> -</span><span id="Parser-1536"><a href="#Parser-1536"><span class="linenos">1536</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"EXCLUSIVE"</span> -</span><span id="Parser-1537"><a href="#Parser-1537"><span class="linenos">1537</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SHARE"</span><span class="p">):</span> -</span><span id="Parser-1538"><a href="#Parser-1538"><span class="linenos">1538</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"SHARE"</span> -</span><span id="Parser-1539"><a href="#Parser-1539"><span class="linenos">1539</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"READ"</span><span class="p">):</span> -</span><span id="Parser-1540"><a href="#Parser-1540"><span class="linenos">1540</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"READ"</span> -</span><span id="Parser-1541"><a href="#Parser-1541"><span class="linenos">1541</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WRITE"</span><span class="p">):</span> -</span><span id="Parser-1542"><a href="#Parser-1542"><span class="linenos">1542</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"WRITE"</span> -</span><span id="Parser-1543"><a href="#Parser-1543"><span class="linenos">1543</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CHECKSUM"</span><span class="p">):</span> -</span><span id="Parser-1544"><a href="#Parser-1544"><span class="linenos">1544</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"CHECKSUM"</span> -</span><span id="Parser-1545"><a href="#Parser-1545"><span class="linenos">1545</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1546"><a href="#Parser-1546"><span class="linenos">1546</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1547"><a href="#Parser-1547"><span class="linenos">1547</span></a> -</span><span id="Parser-1548"><a href="#Parser-1548"><span class="linenos">1548</span></a> <span class="n">override</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OVERRIDE"</span><span class="p">)</span> -</span><span id="Parser-1549"><a href="#Parser-1549"><span class="linenos">1549</span></a> -</span><span id="Parser-1550"><a href="#Parser-1550"><span class="linenos">1550</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><span id="Parser-1551"><a href="#Parser-1551"><span class="linenos">1551</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">,</span> -</span><span id="Parser-1552"><a href="#Parser-1552"><span class="linenos">1552</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="Parser-1553"><a href="#Parser-1553"><span class="linenos">1553</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> -</span><span id="Parser-1554"><a href="#Parser-1554"><span class="linenos">1554</span></a> <span class="n">for_or_in</span><span class="o">=</span><span class="n">for_or_in</span><span class="p">,</span> -</span><span id="Parser-1555"><a href="#Parser-1555"><span class="linenos">1555</span></a> <span class="n">lock_type</span><span class="o">=</span><span class="n">lock_type</span><span class="p">,</span> -</span><span id="Parser-1556"><a href="#Parser-1556"><span class="linenos">1556</span></a> <span class="n">override</span><span class="o">=</span><span class="n">override</span><span class="p">,</span> -</span><span id="Parser-1557"><a href="#Parser-1557"><span class="linenos">1557</span></a> <span class="p">)</span> -</span><span id="Parser-1558"><a href="#Parser-1558"><span class="linenos">1558</span></a> -</span><span id="Parser-1559"><a href="#Parser-1559"><span class="linenos">1559</span></a> <span class="k">def</span> <span class="nf">_parse_partition_by</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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="Parser-1560"><a href="#Parser-1560"><span class="linenos">1560</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">PARTITION_BY</span><span class="p">):</span> -</span><span id="Parser-1561"><a href="#Parser-1561"><span class="linenos">1561</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="Parser-1562"><a href="#Parser-1562"><span class="linenos">1562</span></a> <span class="k">return</span> <span class="p">[]</span> -</span><span id="Parser-1563"><a href="#Parser-1563"><span class="linenos">1563</span></a> -</span><span id="Parser-1564"><a href="#Parser-1564"><span class="linenos">1564</span></a> <span class="k">def</span> <span class="nf">_parse_partitioned_by</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">PartitionedByProperty</span><span class="p">:</span> -</span><span id="Parser-1565"><a href="#Parser-1565"><span class="linenos">1565</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="Parser-1566"><a href="#Parser-1566"><span class="linenos">1566</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><span id="Parser-1567"><a href="#Parser-1567"><span class="linenos">1567</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">,</span> -</span><span id="Parser-1568"><a href="#Parser-1568"><span class="linenos">1568</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bracket</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()),</span> -</span><span id="Parser-1569"><a href="#Parser-1569"><span class="linenos">1569</span></a> <span class="p">)</span> -</span><span id="Parser-1570"><a href="#Parser-1570"><span class="linenos">1570</span></a> -</span><span id="Parser-1571"><a href="#Parser-1571"><span class="linenos">1571</span></a> <span class="k">def</span> <span class="nf">_parse_withdata</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">no</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">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">:</span> -</span><span id="Parser-1572"><a href="#Parser-1572"><span class="linenos">1572</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AND"</span><span class="p">,</span> <span class="s2">"STATISTICS"</span><span class="p">):</span> -</span><span id="Parser-1573"><a href="#Parser-1573"><span class="linenos">1573</span></a> <span class="n">statistics</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Parser-1574"><a href="#Parser-1574"><span class="linenos">1574</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AND"</span><span class="p">,</span> <span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"STATISTICS"</span><span class="p">):</span> -</span><span id="Parser-1575"><a href="#Parser-1575"><span class="linenos">1575</span></a> <span class="n">statistics</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-1576"><a href="#Parser-1576"><span class="linenos">1576</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1577"><a href="#Parser-1577"><span class="linenos">1577</span></a> <span class="n">statistics</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1578"><a href="#Parser-1578"><span class="linenos">1578</span></a> -</span><span id="Parser-1579"><a href="#Parser-1579"><span class="linenos">1579</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">WithDataProperty</span><span class="p">,</span> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">,</span> <span class="n">statistics</span><span class="o">=</span><span class="n">statistics</span><span class="p">)</span> -</span><span id="Parser-1580"><a href="#Parser-1580"><span class="linenos">1580</span></a> -</span><span id="Parser-1581"><a href="#Parser-1581"><span class="linenos">1581</span></a> <span class="k">def</span> <span class="nf">_parse_no_property</span><span class="p">(</span><span class="bp">self</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">NoPrimaryIndexProperty</span><span class="p">]:</span> -</span><span id="Parser-1582"><a href="#Parser-1582"><span class="linenos">1582</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PRIMARY"</span><span class="p">,</span> <span class="s2">"INDEX"</span><span class="p">):</span> -</span><span id="Parser-1583"><a href="#Parser-1583"><span class="linenos">1583</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">NoPrimaryIndexProperty</span><span class="p">()</span> -</span><span id="Parser-1584"><a href="#Parser-1584"><span class="linenos">1584</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-1585"><a href="#Parser-1585"><span class="linenos">1585</span></a> -</span><span id="Parser-1586"><a href="#Parser-1586"><span class="linenos">1586</span></a> <span class="k">def</span> <span class="nf">_parse_on_property</span><span class="p">(</span><span class="bp">self</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="Parser-1587"><a href="#Parser-1587"><span class="linenos">1587</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"COMMIT"</span><span class="p">,</span> <span class="s2">"PRESERVE"</span><span class="p">,</span> <span class="s2">"ROWS"</span><span class="p">):</span> -</span><span id="Parser-1588"><a href="#Parser-1588"><span class="linenos">1588</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</span><span class="p">()</span> -</span><span id="Parser-1589"><a href="#Parser-1589"><span class="linenos">1589</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"COMMIT"</span><span class="p">,</span> <span class="s2">"DELETE"</span><span class="p">,</span> <span class="s2">"ROWS"</span><span class="p">):</span> -</span><span id="Parser-1590"><a href="#Parser-1590"><span class="linenos">1590</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</span><span class="p">(</span><span class="n">delete</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-1591"><a href="#Parser-1591"><span class="linenos">1591</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-1592"><a href="#Parser-1592"><span class="linenos">1592</span></a> -</span><span id="Parser-1593"><a href="#Parser-1593"><span class="linenos">1593</span></a> <span class="k">def</span> <span class="nf">_parse_distkey</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">DistKeyProperty</span><span class="p">:</span> -</span><span id="Parser-1594"><a href="#Parser-1594"><span class="linenos">1594</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">DistKeyProperty</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_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">))</span> -</span><span id="Parser-1595"><a href="#Parser-1595"><span class="linenos">1595</span></a> -</span><span id="Parser-1596"><a href="#Parser-1596"><span class="linenos">1596</span></a> <span class="k">def</span> <span class="nf">_parse_create_like</span><span class="p">(</span><span class="bp">self</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">LikeProperty</span><span class="p">]:</span> -</span><span id="Parser-1597"><a href="#Parser-1597"><span class="linenos">1597</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-1598"><a href="#Parser-1598"><span class="linenos">1598</span></a> -</span><span id="Parser-1599"><a href="#Parser-1599"><span class="linenos">1599</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-1600"><a href="#Parser-1600"><span class="linenos">1600</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"INCLUDING"</span><span class="p">,</span> <span class="s2">"EXCLUDING"</span><span class="p">)):</span> -</span><span id="Parser-1601"><a href="#Parser-1601"><span class="linenos">1601</span></a> <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="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Parser-1484"><a href="#Parser-1484"><span class="linenos">1484</span></a> <span class="n">autotemp</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1485"><a href="#Parser-1485"><span class="linenos">1485</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AUTOTEMP"</span><span class="p">):</span> +</span><span id="Parser-1486"><a href="#Parser-1486"><span class="linenos">1486</span></a> <span class="n">autotemp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</span><span class="p">()</span> +</span><span id="Parser-1487"><a href="#Parser-1487"><span class="linenos">1487</span></a> +</span><span id="Parser-1488"><a href="#Parser-1488"><span class="linenos">1488</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><span id="Parser-1489"><a href="#Parser-1489"><span class="linenos">1489</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BlockCompressionProperty</span><span class="p">,</span> +</span><span id="Parser-1490"><a href="#Parser-1490"><span class="linenos">1490</span></a> <span class="n">always</span><span class="o">=</span><span class="n">always</span><span class="p">,</span> +</span><span id="Parser-1491"><a href="#Parser-1491"><span class="linenos">1491</span></a> <span class="n">manual</span><span class="o">=</span><span class="n">manual</span><span class="p">,</span> +</span><span id="Parser-1492"><a href="#Parser-1492"><span class="linenos">1492</span></a> <span class="n">never</span><span class="o">=</span><span class="n">never</span><span class="p">,</span> +</span><span id="Parser-1493"><a href="#Parser-1493"><span class="linenos">1493</span></a> <span class="n">default</span><span class="o">=</span><span class="n">default</span><span class="p">,</span> +</span><span id="Parser-1494"><a href="#Parser-1494"><span class="linenos">1494</span></a> <span class="n">autotemp</span><span class="o">=</span><span class="n">autotemp</span><span class="p">,</span> +</span><span id="Parser-1495"><a href="#Parser-1495"><span class="linenos">1495</span></a> <span class="p">)</span> +</span><span id="Parser-1496"><a href="#Parser-1496"><span class="linenos">1496</span></a> +</span><span id="Parser-1497"><a href="#Parser-1497"><span class="linenos">1497</span></a> <span class="k">def</span> <span class="nf">_parse_withisolatedloading</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">IsolatedLoadingProperty</span><span class="p">:</span> +</span><span id="Parser-1498"><a href="#Parser-1498"><span class="linenos">1498</span></a> <span class="n">no</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">)</span> +</span><span id="Parser-1499"><a href="#Parser-1499"><span class="linenos">1499</span></a> <span class="n">concurrent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CONCURRENT"</span><span class="p">)</span> +</span><span id="Parser-1500"><a href="#Parser-1500"><span class="linenos">1500</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ISOLATED"</span><span class="p">,</span> <span class="s2">"LOADING"</span><span class="p">)</span> +</span><span id="Parser-1501"><a href="#Parser-1501"><span class="linenos">1501</span></a> <span class="n">for_all</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"ALL"</span><span class="p">)</span> +</span><span id="Parser-1502"><a href="#Parser-1502"><span class="linenos">1502</span></a> <span class="n">for_insert</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"INSERT"</span><span class="p">)</span> +</span><span id="Parser-1503"><a href="#Parser-1503"><span class="linenos">1503</span></a> <span class="n">for_none</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"NONE"</span><span class="p">)</span> +</span><span id="Parser-1504"><a href="#Parser-1504"><span class="linenos">1504</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><span id="Parser-1505"><a href="#Parser-1505"><span class="linenos">1505</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">IsolatedLoadingProperty</span><span class="p">,</span> +</span><span id="Parser-1506"><a href="#Parser-1506"><span class="linenos">1506</span></a> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">,</span> +</span><span id="Parser-1507"><a href="#Parser-1507"><span class="linenos">1507</span></a> <span class="n">concurrent</span><span class="o">=</span><span class="n">concurrent</span><span class="p">,</span> +</span><span id="Parser-1508"><a href="#Parser-1508"><span class="linenos">1508</span></a> <span class="n">for_all</span><span class="o">=</span><span class="n">for_all</span><span class="p">,</span> +</span><span id="Parser-1509"><a href="#Parser-1509"><span class="linenos">1509</span></a> <span class="n">for_insert</span><span class="o">=</span><span class="n">for_insert</span><span class="p">,</span> +</span><span id="Parser-1510"><a href="#Parser-1510"><span class="linenos">1510</span></a> <span class="n">for_none</span><span class="o">=</span><span class="n">for_none</span><span class="p">,</span> +</span><span id="Parser-1511"><a href="#Parser-1511"><span class="linenos">1511</span></a> <span class="p">)</span> +</span><span id="Parser-1512"><a href="#Parser-1512"><span class="linenos">1512</span></a> +</span><span id="Parser-1513"><a href="#Parser-1513"><span class="linenos">1513</span></a> <span class="k">def</span> <span class="nf">_parse_locking</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">LockingProperty</span><span class="p">:</span> +</span><span id="Parser-1514"><a href="#Parser-1514"><span class="linenos">1514</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">TABLE</span><span class="p">):</span> +</span><span id="Parser-1515"><a href="#Parser-1515"><span class="linenos">1515</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">"TABLE"</span> +</span><span id="Parser-1516"><a href="#Parser-1516"><span class="linenos">1516</span></a> <span class="k">elif</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">VIEW</span><span class="p">):</span> +</span><span id="Parser-1517"><a href="#Parser-1517"><span class="linenos">1517</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">"VIEW"</span> +</span><span id="Parser-1518"><a href="#Parser-1518"><span class="linenos">1518</span></a> <span class="k">elif</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">ROW</span><span class="p">):</span> +</span><span id="Parser-1519"><a href="#Parser-1519"><span class="linenos">1519</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">"ROW"</span> +</span><span id="Parser-1520"><a href="#Parser-1520"><span class="linenos">1520</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DATABASE"</span><span class="p">):</span> +</span><span id="Parser-1521"><a href="#Parser-1521"><span class="linenos">1521</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="s2">"DATABASE"</span> +</span><span id="Parser-1522"><a href="#Parser-1522"><span class="linenos">1522</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1523"><a href="#Parser-1523"><span class="linenos">1523</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1524"><a href="#Parser-1524"><span class="linenos">1524</span></a> +</span><span id="Parser-1525"><a href="#Parser-1525"><span class="linenos">1525</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"DATABASE"</span><span class="p">,</span> <span class="s2">"TABLE"</span><span class="p">,</span> <span class="s2">"VIEW"</span><span class="p">):</span> +</span><span id="Parser-1526"><a href="#Parser-1526"><span class="linenos">1526</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">()</span> +</span><span id="Parser-1527"><a href="#Parser-1527"><span class="linenos">1527</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1528"><a href="#Parser-1528"><span class="linenos">1528</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1529"><a href="#Parser-1529"><span class="linenos">1529</span></a> +</span><span id="Parser-1530"><a href="#Parser-1530"><span class="linenos">1530</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">FOR</span><span class="p">):</span> +</span><span id="Parser-1531"><a href="#Parser-1531"><span class="linenos">1531</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="s2">"FOR"</span> +</span><span id="Parser-1532"><a href="#Parser-1532"><span class="linenos">1532</span></a> <span class="k">elif</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">IN</span><span class="p">):</span> +</span><span id="Parser-1533"><a href="#Parser-1533"><span class="linenos">1533</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="s2">"IN"</span> +</span><span id="Parser-1534"><a href="#Parser-1534"><span class="linenos">1534</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1535"><a href="#Parser-1535"><span class="linenos">1535</span></a> <span class="n">for_or_in</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1536"><a href="#Parser-1536"><span class="linenos">1536</span></a> +</span><span id="Parser-1537"><a href="#Parser-1537"><span class="linenos">1537</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ACCESS"</span><span class="p">):</span> +</span><span id="Parser-1538"><a href="#Parser-1538"><span class="linenos">1538</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"ACCESS"</span> +</span><span id="Parser-1539"><a href="#Parser-1539"><span class="linenos">1539</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"EXCL"</span><span class="p">,</span> <span class="s2">"EXCLUSIVE"</span><span class="p">)):</span> +</span><span id="Parser-1540"><a href="#Parser-1540"><span class="linenos">1540</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"EXCLUSIVE"</span> +</span><span id="Parser-1541"><a href="#Parser-1541"><span class="linenos">1541</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SHARE"</span><span class="p">):</span> +</span><span id="Parser-1542"><a href="#Parser-1542"><span class="linenos">1542</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"SHARE"</span> +</span><span id="Parser-1543"><a href="#Parser-1543"><span class="linenos">1543</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"READ"</span><span class="p">):</span> +</span><span id="Parser-1544"><a href="#Parser-1544"><span class="linenos">1544</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"READ"</span> +</span><span id="Parser-1545"><a href="#Parser-1545"><span class="linenos">1545</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WRITE"</span><span class="p">):</span> +</span><span id="Parser-1546"><a href="#Parser-1546"><span class="linenos">1546</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"WRITE"</span> +</span><span id="Parser-1547"><a href="#Parser-1547"><span class="linenos">1547</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CHECKSUM"</span><span class="p">):</span> +</span><span id="Parser-1548"><a href="#Parser-1548"><span class="linenos">1548</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="s2">"CHECKSUM"</span> +</span><span id="Parser-1549"><a href="#Parser-1549"><span class="linenos">1549</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1550"><a href="#Parser-1550"><span class="linenos">1550</span></a> <span class="n">lock_type</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1551"><a href="#Parser-1551"><span class="linenos">1551</span></a> +</span><span id="Parser-1552"><a href="#Parser-1552"><span class="linenos">1552</span></a> <span class="n">override</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OVERRIDE"</span><span class="p">)</span> +</span><span id="Parser-1553"><a href="#Parser-1553"><span class="linenos">1553</span></a> +</span><span id="Parser-1554"><a href="#Parser-1554"><span class="linenos">1554</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><span id="Parser-1555"><a href="#Parser-1555"><span class="linenos">1555</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LockingProperty</span><span class="p">,</span> +</span><span id="Parser-1556"><a href="#Parser-1556"><span class="linenos">1556</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="Parser-1557"><a href="#Parser-1557"><span class="linenos">1557</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> +</span><span id="Parser-1558"><a href="#Parser-1558"><span class="linenos">1558</span></a> <span class="n">for_or_in</span><span class="o">=</span><span class="n">for_or_in</span><span class="p">,</span> +</span><span id="Parser-1559"><a href="#Parser-1559"><span class="linenos">1559</span></a> <span class="n">lock_type</span><span class="o">=</span><span class="n">lock_type</span><span class="p">,</span> +</span><span id="Parser-1560"><a href="#Parser-1560"><span class="linenos">1560</span></a> <span class="n">override</span><span class="o">=</span><span class="n">override</span><span class="p">,</span> +</span><span id="Parser-1561"><a href="#Parser-1561"><span class="linenos">1561</span></a> <span class="p">)</span> +</span><span id="Parser-1562"><a href="#Parser-1562"><span class="linenos">1562</span></a> +</span><span id="Parser-1563"><a href="#Parser-1563"><span class="linenos">1563</span></a> <span class="k">def</span> <span class="nf">_parse_partition_by</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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="Parser-1564"><a href="#Parser-1564"><span class="linenos">1564</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">PARTITION_BY</span><span class="p">):</span> +</span><span id="Parser-1565"><a href="#Parser-1565"><span class="linenos">1565</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="Parser-1566"><a href="#Parser-1566"><span class="linenos">1566</span></a> <span class="k">return</span> <span class="p">[]</span> +</span><span id="Parser-1567"><a href="#Parser-1567"><span class="linenos">1567</span></a> +</span><span id="Parser-1568"><a href="#Parser-1568"><span class="linenos">1568</span></a> <span class="k">def</span> <span class="nf">_parse_partitioned_by</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">PartitionedByProperty</span><span class="p">:</span> +</span><span id="Parser-1569"><a href="#Parser-1569"><span class="linenos">1569</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="Parser-1570"><a href="#Parser-1570"><span class="linenos">1570</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><span id="Parser-1571"><a href="#Parser-1571"><span class="linenos">1571</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">PartitionedByProperty</span><span class="p">,</span> +</span><span id="Parser-1572"><a href="#Parser-1572"><span class="linenos">1572</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bracket</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()),</span> +</span><span id="Parser-1573"><a href="#Parser-1573"><span class="linenos">1573</span></a> <span class="p">)</span> +</span><span id="Parser-1574"><a href="#Parser-1574"><span class="linenos">1574</span></a> +</span><span id="Parser-1575"><a href="#Parser-1575"><span class="linenos">1575</span></a> <span class="k">def</span> <span class="nf">_parse_withdata</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">no</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">exp</span><span class="o">.</span><span class="n">WithDataProperty</span><span class="p">:</span> +</span><span id="Parser-1576"><a href="#Parser-1576"><span class="linenos">1576</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AND"</span><span class="p">,</span> <span class="s2">"STATISTICS"</span><span class="p">):</span> +</span><span id="Parser-1577"><a href="#Parser-1577"><span class="linenos">1577</span></a> <span class="n">statistics</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Parser-1578"><a href="#Parser-1578"><span class="linenos">1578</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AND"</span><span class="p">,</span> <span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"STATISTICS"</span><span class="p">):</span> +</span><span id="Parser-1579"><a href="#Parser-1579"><span class="linenos">1579</span></a> <span class="n">statistics</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-1580"><a href="#Parser-1580"><span class="linenos">1580</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1581"><a href="#Parser-1581"><span class="linenos">1581</span></a> <span class="n">statistics</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1582"><a href="#Parser-1582"><span class="linenos">1582</span></a> +</span><span id="Parser-1583"><a href="#Parser-1583"><span class="linenos">1583</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">WithDataProperty</span><span class="p">,</span> <span class="n">no</span><span class="o">=</span><span class="n">no</span><span class="p">,</span> <span class="n">statistics</span><span class="o">=</span><span class="n">statistics</span><span class="p">)</span> +</span><span id="Parser-1584"><a href="#Parser-1584"><span class="linenos">1584</span></a> +</span><span id="Parser-1585"><a href="#Parser-1585"><span class="linenos">1585</span></a> <span class="k">def</span> <span class="nf">_parse_no_property</span><span class="p">(</span><span class="bp">self</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">NoPrimaryIndexProperty</span><span class="p">]:</span> +</span><span id="Parser-1586"><a href="#Parser-1586"><span class="linenos">1586</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PRIMARY"</span><span class="p">,</span> <span class="s2">"INDEX"</span><span class="p">):</span> +</span><span id="Parser-1587"><a href="#Parser-1587"><span class="linenos">1587</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">NoPrimaryIndexProperty</span><span class="p">()</span> +</span><span id="Parser-1588"><a href="#Parser-1588"><span class="linenos">1588</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1589"><a href="#Parser-1589"><span class="linenos">1589</span></a> +</span><span id="Parser-1590"><a href="#Parser-1590"><span class="linenos">1590</span></a> <span class="k">def</span> <span class="nf">_parse_on_property</span><span class="p">(</span><span class="bp">self</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="Parser-1591"><a href="#Parser-1591"><span class="linenos">1591</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"COMMIT"</span><span class="p">,</span> <span class="s2">"PRESERVE"</span><span class="p">,</span> <span class="s2">"ROWS"</span><span class="p">):</span> +</span><span id="Parser-1592"><a href="#Parser-1592"><span class="linenos">1592</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</span><span class="p">()</span> +</span><span id="Parser-1593"><a href="#Parser-1593"><span class="linenos">1593</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"COMMIT"</span><span class="p">,</span> <span class="s2">"DELETE"</span><span class="p">,</span> <span class="s2">"ROWS"</span><span class="p">):</span> +</span><span id="Parser-1594"><a href="#Parser-1594"><span class="linenos">1594</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">OnCommitProperty</span><span class="p">(</span><span class="n">delete</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-1595"><a href="#Parser-1595"><span class="linenos">1595</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1596"><a href="#Parser-1596"><span class="linenos">1596</span></a> +</span><span id="Parser-1597"><a href="#Parser-1597"><span class="linenos">1597</span></a> <span class="k">def</span> <span class="nf">_parse_distkey</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">DistKeyProperty</span><span class="p">:</span> +</span><span id="Parser-1598"><a href="#Parser-1598"><span class="linenos">1598</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">DistKeyProperty</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_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">))</span> +</span><span id="Parser-1599"><a href="#Parser-1599"><span class="linenos">1599</span></a> +</span><span id="Parser-1600"><a href="#Parser-1600"><span class="linenos">1600</span></a> <span class="k">def</span> <span class="nf">_parse_create_like</span><span class="p">(</span><span class="bp">self</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">LikeProperty</span><span class="p">]:</span> +</span><span id="Parser-1601"><a href="#Parser-1601"><span class="linenos">1601</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span><span id="Parser-1602"><a href="#Parser-1602"><span class="linenos">1602</span></a> -</span><span id="Parser-1603"><a href="#Parser-1603"><span class="linenos">1603</span></a> <span class="n">id_var</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="Parser-1604"><a href="#Parser-1604"><span class="linenos">1604</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">id_var</span><span class="p">:</span> -</span><span id="Parser-1605"><a href="#Parser-1605"><span class="linenos">1605</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1603"><a href="#Parser-1603"><span class="linenos">1603</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-1604"><a href="#Parser-1604"><span class="linenos">1604</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"INCLUDING"</span><span class="p">,</span> <span class="s2">"EXCLUDING"</span><span class="p">)):</span> +</span><span id="Parser-1605"><a href="#Parser-1605"><span class="linenos">1605</span></a> <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="o">.</span><span class="n">upper</span><span class="p">()</span> </span><span id="Parser-1606"><a href="#Parser-1606"><span class="linenos">1606</span></a> -</span><span id="Parser-1607"><a href="#Parser-1607"><span class="linenos">1607</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="Parser-1608"><a href="#Parser-1608"><span class="linenos">1608</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">Property</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">value</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="n">id_var</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">upper</span><span class="p">()))</span> -</span><span id="Parser-1609"><a href="#Parser-1609"><span class="linenos">1609</span></a> <span class="p">)</span> +</span><span id="Parser-1607"><a href="#Parser-1607"><span class="linenos">1607</span></a> <span class="n">id_var</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="Parser-1608"><a href="#Parser-1608"><span class="linenos">1608</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">id_var</span><span class="p">:</span> +</span><span id="Parser-1609"><a href="#Parser-1609"><span class="linenos">1609</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="Parser-1610"><a href="#Parser-1610"><span class="linenos">1610</span></a> -</span><span id="Parser-1611"><a href="#Parser-1611"><span class="linenos">1611</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">LikeProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">options</span><span class="p">)</span> -</span><span id="Parser-1612"><a href="#Parser-1612"><span class="linenos">1612</span></a> -</span><span id="Parser-1613"><a href="#Parser-1613"><span class="linenos">1613</span></a> <span class="k">def</span> <span class="nf">_parse_sortkey</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">compound</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">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> -</span><span id="Parser-1614"><a href="#Parser-1614"><span class="linenos">1614</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><span id="Parser-1615"><a href="#Parser-1615"><span class="linenos">1615</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</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_wrapped_id_vars</span><span class="p">(),</span> <span class="n">compound</span><span class="o">=</span><span class="n">compound</span> -</span><span id="Parser-1616"><a href="#Parser-1616"><span class="linenos">1616</span></a> <span class="p">)</span> -</span><span id="Parser-1617"><a href="#Parser-1617"><span class="linenos">1617</span></a> -</span><span id="Parser-1618"><a href="#Parser-1618"><span class="linenos">1618</span></a> <span class="k">def</span> <span class="nf">_parse_character_set</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">default</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">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</span><span class="p">:</span> -</span><span id="Parser-1619"><a href="#Parser-1619"><span class="linenos">1619</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="Parser-1620"><a href="#Parser-1620"><span class="linenos">1620</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><span id="Parser-1621"><a href="#Parser-1621"><span class="linenos">1621</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</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_var_or_string</span><span class="p">(),</span> <span class="n">default</span><span class="o">=</span><span class="n">default</span> -</span><span id="Parser-1622"><a href="#Parser-1622"><span class="linenos">1622</span></a> <span class="p">)</span> -</span><span id="Parser-1623"><a href="#Parser-1623"><span class="linenos">1623</span></a> -</span><span id="Parser-1624"><a href="#Parser-1624"><span class="linenos">1624</span></a> <span class="k">def</span> <span class="nf">_parse_returns</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">ReturnsProperty</span><span class="p">:</span> -</span><span id="Parser-1625"><a href="#Parser-1625"><span class="linenos">1625</span></a> <span class="n">value</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><span id="Parser-1626"><a href="#Parser-1626"><span class="linenos">1626</span></a> <span class="n">is_table</span> <span class="o">=</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">TABLE</span><span class="p">)</span> +</span><span id="Parser-1611"><a href="#Parser-1611"><span class="linenos">1611</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="Parser-1612"><a href="#Parser-1612"><span class="linenos">1612</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">Property</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">value</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="n">id_var</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">upper</span><span class="p">()))</span> +</span><span id="Parser-1613"><a href="#Parser-1613"><span class="linenos">1613</span></a> <span class="p">)</span> +</span><span id="Parser-1614"><a href="#Parser-1614"><span class="linenos">1614</span></a> +</span><span id="Parser-1615"><a href="#Parser-1615"><span class="linenos">1615</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">LikeProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">options</span><span class="p">)</span> +</span><span id="Parser-1616"><a href="#Parser-1616"><span class="linenos">1616</span></a> +</span><span id="Parser-1617"><a href="#Parser-1617"><span class="linenos">1617</span></a> <span class="k">def</span> <span class="nf">_parse_sortkey</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">compound</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">exp</span><span class="o">.</span><span class="n">SortKeyProperty</span><span class="p">:</span> +</span><span id="Parser-1618"><a href="#Parser-1618"><span class="linenos">1618</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><span id="Parser-1619"><a href="#Parser-1619"><span class="linenos">1619</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SortKeyProperty</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_wrapped_id_vars</span><span class="p">(),</span> <span class="n">compound</span><span class="o">=</span><span class="n">compound</span> +</span><span id="Parser-1620"><a href="#Parser-1620"><span class="linenos">1620</span></a> <span class="p">)</span> +</span><span id="Parser-1621"><a href="#Parser-1621"><span class="linenos">1621</span></a> +</span><span id="Parser-1622"><a href="#Parser-1622"><span class="linenos">1622</span></a> <span class="k">def</span> <span class="nf">_parse_character_set</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">default</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">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</span><span class="p">:</span> +</span><span id="Parser-1623"><a href="#Parser-1623"><span class="linenos">1623</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="Parser-1624"><a href="#Parser-1624"><span class="linenos">1624</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><span id="Parser-1625"><a href="#Parser-1625"><span class="linenos">1625</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CharacterSetProperty</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_var_or_string</span><span class="p">(),</span> <span class="n">default</span><span class="o">=</span><span class="n">default</span> +</span><span id="Parser-1626"><a href="#Parser-1626"><span class="linenos">1626</span></a> <span class="p">)</span> </span><span id="Parser-1627"><a href="#Parser-1627"><span class="linenos">1627</span></a> -</span><span id="Parser-1628"><a href="#Parser-1628"><span class="linenos">1628</span></a> <span class="k">if</span> <span class="n">is_table</span><span class="p">:</span> -</span><span id="Parser-1629"><a href="#Parser-1629"><span class="linenos">1629</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">LT</span><span class="p">):</span> -</span><span id="Parser-1630"><a href="#Parser-1630"><span class="linenos">1630</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-1631"><a href="#Parser-1631"><span class="linenos">1631</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">,</span> -</span><span id="Parser-1632"><a href="#Parser-1632"><span class="linenos">1632</span></a> <span class="n">this</span><span class="o">=</span><span class="s2">"TABLE"</span><span class="p">,</span> -</span><span id="Parser-1633"><a href="#Parser-1633"><span class="linenos">1633</span></a> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_struct_types</span><span class="p">),</span> -</span><span id="Parser-1634"><a href="#Parser-1634"><span class="linenos">1634</span></a> <span class="p">)</span> -</span><span id="Parser-1635"><a href="#Parser-1635"><span class="linenos">1635</span></a> <span class="k">if</span> <span class="ow">not</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">GT</span><span class="p">):</span> -</span><span id="Parser-1636"><a href="#Parser-1636"><span class="linenos">1636</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting >"</span><span class="p">)</span> -</span><span id="Parser-1637"><a href="#Parser-1637"><span class="linenos">1637</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1638"><a href="#Parser-1638"><span class="linenos">1638</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</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">"TABLE"</span><span class="p">))</span> -</span><span id="Parser-1639"><a href="#Parser-1639"><span class="linenos">1639</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1640"><a href="#Parser-1640"><span class="linenos">1640</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">()</span> -</span><span id="Parser-1641"><a href="#Parser-1641"><span class="linenos">1641</span></a> -</span><span id="Parser-1642"><a href="#Parser-1642"><span class="linenos">1642</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">ReturnsProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">value</span><span class="p">,</span> <span class="n">is_table</span><span class="o">=</span><span class="n">is_table</span><span class="p">)</span> -</span><span id="Parser-1643"><a href="#Parser-1643"><span class="linenos">1643</span></a> -</span><span id="Parser-1644"><a href="#Parser-1644"><span class="linenos">1644</span></a> <span class="k">def</span> <span class="nf">_parse_describe</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">Describe</span><span class="p">:</span> -</span><span id="Parser-1645"><a href="#Parser-1645"><span class="linenos">1645</span></a> <span class="n">kind</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</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><span id="Parser-1646"><a href="#Parser-1646"><span class="linenos">1646</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> -</span><span id="Parser-1647"><a href="#Parser-1647"><span class="linenos">1647</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">Describe</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">)</span> -</span><span id="Parser-1648"><a href="#Parser-1648"><span class="linenos">1648</span></a> -</span><span id="Parser-1649"><a href="#Parser-1649"><span class="linenos">1649</span></a> <span class="k">def</span> <span class="nf">_parse_insert</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">Insert</span><span class="p">:</span> -</span><span id="Parser-1650"><a href="#Parser-1650"><span class="linenos">1650</span></a> <span class="n">overwrite</span> <span class="o">=</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">OVERWRITE</span><span class="p">)</span> -</span><span id="Parser-1651"><a href="#Parser-1651"><span class="linenos">1651</span></a> <span class="n">local</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LOCAL"</span><span class="p">)</span> -</span><span id="Parser-1652"><a href="#Parser-1652"><span class="linenos">1652</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1653"><a href="#Parser-1653"><span class="linenos">1653</span></a> -</span><span id="Parser-1654"><a href="#Parser-1654"><span class="linenos">1654</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DIRECTORY"</span><span class="p">):</span> -</span><span id="Parser-1655"><a href="#Parser-1655"><span class="linenos">1655</span></a> <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="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-1656"><a href="#Parser-1656"><span class="linenos">1656</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">,</span> -</span><span id="Parser-1657"><a href="#Parser-1657"><span class="linenos">1657</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_var_or_string</span><span class="p">(),</span> -</span><span id="Parser-1658"><a href="#Parser-1658"><span class="linenos">1658</span></a> <span class="n">local</span><span class="o">=</span><span class="n">local</span><span class="p">,</span> -</span><span id="Parser-1659"><a href="#Parser-1659"><span class="linenos">1659</span></a> <span class="n">row_format</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_row_format</span><span class="p">(</span><span class="n">match_row</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="Parser-1660"><a href="#Parser-1660"><span class="linenos">1660</span></a> <span class="p">)</span> -</span><span id="Parser-1661"><a href="#Parser-1661"><span class="linenos">1661</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1662"><a href="#Parser-1662"><span class="linenos">1662</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">OR</span><span class="p">):</span> -</span><span id="Parser-1663"><a href="#Parser-1663"><span class="linenos">1663</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">INSERT_ALTERNATIVES</span><span class="p">)</span> <span class="ow">and</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><span id="Parser-1664"><a href="#Parser-1664"><span class="linenos">1664</span></a> -</span><span id="Parser-1665"><a href="#Parser-1665"><span class="linenos">1665</span></a> <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">INTO</span><span class="p">)</span> -</span><span id="Parser-1666"><a href="#Parser-1666"><span class="linenos">1666</span></a> <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">TABLE</span><span class="p">)</span> -</span><span id="Parser-1667"><a href="#Parser-1667"><span class="linenos">1667</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-1628"><a href="#Parser-1628"><span class="linenos">1628</span></a> <span class="k">def</span> <span class="nf">_parse_returns</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">ReturnsProperty</span><span class="p">:</span> +</span><span id="Parser-1629"><a href="#Parser-1629"><span class="linenos">1629</span></a> <span class="n">value</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><span id="Parser-1630"><a href="#Parser-1630"><span class="linenos">1630</span></a> <span class="n">is_table</span> <span class="o">=</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">TABLE</span><span class="p">)</span> +</span><span id="Parser-1631"><a href="#Parser-1631"><span class="linenos">1631</span></a> +</span><span id="Parser-1632"><a href="#Parser-1632"><span class="linenos">1632</span></a> <span class="k">if</span> <span class="n">is_table</span><span class="p">:</span> +</span><span id="Parser-1633"><a href="#Parser-1633"><span class="linenos">1633</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">LT</span><span class="p">):</span> +</span><span id="Parser-1634"><a href="#Parser-1634"><span class="linenos">1634</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-1635"><a href="#Parser-1635"><span class="linenos">1635</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">,</span> +</span><span id="Parser-1636"><a href="#Parser-1636"><span class="linenos">1636</span></a> <span class="n">this</span><span class="o">=</span><span class="s2">"TABLE"</span><span class="p">,</span> +</span><span id="Parser-1637"><a href="#Parser-1637"><span class="linenos">1637</span></a> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_struct_types</span><span class="p">),</span> +</span><span id="Parser-1638"><a href="#Parser-1638"><span class="linenos">1638</span></a> <span class="p">)</span> +</span><span id="Parser-1639"><a href="#Parser-1639"><span class="linenos">1639</span></a> <span class="k">if</span> <span class="ow">not</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">GT</span><span class="p">):</span> +</span><span id="Parser-1640"><a href="#Parser-1640"><span class="linenos">1640</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting >"</span><span class="p">)</span> +</span><span id="Parser-1641"><a href="#Parser-1641"><span class="linenos">1641</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1642"><a href="#Parser-1642"><span class="linenos">1642</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</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">"TABLE"</span><span class="p">))</span> +</span><span id="Parser-1643"><a href="#Parser-1643"><span class="linenos">1643</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1644"><a href="#Parser-1644"><span class="linenos">1644</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">()</span> +</span><span id="Parser-1645"><a href="#Parser-1645"><span class="linenos">1645</span></a> +</span><span id="Parser-1646"><a href="#Parser-1646"><span class="linenos">1646</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">ReturnsProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">value</span><span class="p">,</span> <span class="n">is_table</span><span class="o">=</span><span class="n">is_table</span><span class="p">)</span> +</span><span id="Parser-1647"><a href="#Parser-1647"><span class="linenos">1647</span></a> +</span><span id="Parser-1648"><a href="#Parser-1648"><span class="linenos">1648</span></a> <span class="k">def</span> <span class="nf">_parse_describe</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">Describe</span><span class="p">:</span> +</span><span id="Parser-1649"><a href="#Parser-1649"><span class="linenos">1649</span></a> <span class="n">kind</span> <span class="o">=</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">CREATABLES</span><span class="p">)</span> <span class="ow">and</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><span id="Parser-1650"><a href="#Parser-1650"><span class="linenos">1650</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> +</span><span id="Parser-1651"><a href="#Parser-1651"><span class="linenos">1651</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">Describe</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">)</span> +</span><span id="Parser-1652"><a href="#Parser-1652"><span class="linenos">1652</span></a> +</span><span id="Parser-1653"><a href="#Parser-1653"><span class="linenos">1653</span></a> <span class="k">def</span> <span class="nf">_parse_insert</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">Insert</span><span class="p">:</span> +</span><span id="Parser-1654"><a href="#Parser-1654"><span class="linenos">1654</span></a> <span class="n">overwrite</span> <span class="o">=</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">OVERWRITE</span><span class="p">)</span> +</span><span id="Parser-1655"><a href="#Parser-1655"><span class="linenos">1655</span></a> <span class="n">local</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LOCAL"</span><span class="p">)</span> +</span><span id="Parser-1656"><a href="#Parser-1656"><span class="linenos">1656</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1657"><a href="#Parser-1657"><span class="linenos">1657</span></a> +</span><span id="Parser-1658"><a href="#Parser-1658"><span class="linenos">1658</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DIRECTORY"</span><span class="p">):</span> +</span><span id="Parser-1659"><a href="#Parser-1659"><span class="linenos">1659</span></a> <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="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-1660"><a href="#Parser-1660"><span class="linenos">1660</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Directory</span><span class="p">,</span> +</span><span id="Parser-1661"><a href="#Parser-1661"><span class="linenos">1661</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_var_or_string</span><span class="p">(),</span> +</span><span id="Parser-1662"><a href="#Parser-1662"><span class="linenos">1662</span></a> <span class="n">local</span><span class="o">=</span><span class="n">local</span><span class="p">,</span> +</span><span id="Parser-1663"><a href="#Parser-1663"><span class="linenos">1663</span></a> <span class="n">row_format</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_row_format</span><span class="p">(</span><span class="n">match_row</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="Parser-1664"><a href="#Parser-1664"><span class="linenos">1664</span></a> <span class="p">)</span> +</span><span id="Parser-1665"><a href="#Parser-1665"><span class="linenos">1665</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1666"><a href="#Parser-1666"><span class="linenos">1666</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">OR</span><span class="p">):</span> +</span><span id="Parser-1667"><a href="#Parser-1667"><span class="linenos">1667</span></a> <span class="n">alternative</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">INSERT_ALTERNATIVES</span><span class="p">)</span> <span class="ow">and</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><span id="Parser-1668"><a href="#Parser-1668"><span class="linenos">1668</span></a> -</span><span id="Parser-1669"><a href="#Parser-1669"><span class="linenos">1669</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><span id="Parser-1670"><a href="#Parser-1670"><span class="linenos">1670</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">,</span> -</span><span id="Parser-1671"><a href="#Parser-1671"><span class="linenos">1671</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="Parser-1672"><a href="#Parser-1672"><span class="linenos">1672</span></a> <span class="n">exists</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">(),</span> -</span><span id="Parser-1673"><a href="#Parser-1673"><span class="linenos">1673</span></a> <span class="n">partition</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition</span><span class="p">(),</span> -</span><span id="Parser-1674"><a href="#Parser-1674"><span class="linenos">1674</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_ddl_select</span><span class="p">(),</span> -</span><span id="Parser-1675"><a href="#Parser-1675"><span class="linenos">1675</span></a> <span class="n">conflict</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_on_conflict</span><span class="p">(),</span> -</span><span id="Parser-1676"><a href="#Parser-1676"><span class="linenos">1676</span></a> <span class="n">returning</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_returning</span><span class="p">(),</span> -</span><span id="Parser-1677"><a href="#Parser-1677"><span class="linenos">1677</span></a> <span class="n">overwrite</span><span class="o">=</span><span class="n">overwrite</span><span class="p">,</span> -</span><span id="Parser-1678"><a href="#Parser-1678"><span class="linenos">1678</span></a> <span class="n">alternative</span><span class="o">=</span><span class="n">alternative</span><span class="p">,</span> -</span><span id="Parser-1679"><a href="#Parser-1679"><span class="linenos">1679</span></a> <span class="p">)</span> -</span><span id="Parser-1680"><a href="#Parser-1680"><span class="linenos">1680</span></a> -</span><span id="Parser-1681"><a href="#Parser-1681"><span class="linenos">1681</span></a> <span class="k">def</span> <span class="nf">_parse_on_conflict</span><span class="p">(</span><span class="bp">self</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">OnConflict</span><span class="p">]:</span> -</span><span id="Parser-1682"><a href="#Parser-1682"><span class="linenos">1682</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"CONFLICT"</span><span class="p">)</span> -</span><span id="Parser-1683"><a href="#Parser-1683"><span class="linenos">1683</span></a> <span class="n">duplicate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"DUPLICATE"</span><span class="p">,</span> <span class="s2">"KEY"</span><span class="p">)</span> +</span><span id="Parser-1669"><a href="#Parser-1669"><span class="linenos">1669</span></a> <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">INTO</span><span class="p">)</span> +</span><span id="Parser-1670"><a href="#Parser-1670"><span class="linenos">1670</span></a> <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">TABLE</span><span class="p">)</span> +</span><span id="Parser-1671"><a href="#Parser-1671"><span class="linenos">1671</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-1672"><a href="#Parser-1672"><span class="linenos">1672</span></a> +</span><span id="Parser-1673"><a href="#Parser-1673"><span class="linenos">1673</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><span id="Parser-1674"><a href="#Parser-1674"><span class="linenos">1674</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">,</span> +</span><span id="Parser-1675"><a href="#Parser-1675"><span class="linenos">1675</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="Parser-1676"><a href="#Parser-1676"><span class="linenos">1676</span></a> <span class="n">exists</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">(),</span> +</span><span id="Parser-1677"><a href="#Parser-1677"><span class="linenos">1677</span></a> <span class="n">partition</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition</span><span class="p">(),</span> +</span><span id="Parser-1678"><a href="#Parser-1678"><span class="linenos">1678</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_ddl_select</span><span class="p">(),</span> +</span><span id="Parser-1679"><a href="#Parser-1679"><span class="linenos">1679</span></a> <span class="n">conflict</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_on_conflict</span><span class="p">(),</span> +</span><span id="Parser-1680"><a href="#Parser-1680"><span class="linenos">1680</span></a> <span class="n">returning</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_returning</span><span class="p">(),</span> +</span><span id="Parser-1681"><a href="#Parser-1681"><span class="linenos">1681</span></a> <span class="n">overwrite</span><span class="o">=</span><span class="n">overwrite</span><span class="p">,</span> +</span><span id="Parser-1682"><a href="#Parser-1682"><span class="linenos">1682</span></a> <span class="n">alternative</span><span class="o">=</span><span class="n">alternative</span><span class="p">,</span> +</span><span id="Parser-1683"><a href="#Parser-1683"><span class="linenos">1683</span></a> <span class="p">)</span> </span><span id="Parser-1684"><a href="#Parser-1684"><span class="linenos">1684</span></a> -</span><span id="Parser-1685"><a href="#Parser-1685"><span class="linenos">1685</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">conflict</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">duplicate</span><span class="p">:</span> -</span><span id="Parser-1686"><a href="#Parser-1686"><span class="linenos">1686</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-1687"><a href="#Parser-1687"><span class="linenos">1687</span></a> -</span><span id="Parser-1688"><a href="#Parser-1688"><span class="linenos">1688</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1689"><a href="#Parser-1689"><span class="linenos">1689</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1690"><a href="#Parser-1690"><span class="linenos">1690</span></a> <span class="n">key</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1691"><a href="#Parser-1691"><span class="linenos">1691</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1692"><a href="#Parser-1692"><span class="linenos">1692</span></a> -</span><span id="Parser-1693"><a href="#Parser-1693"><span class="linenos">1693</span></a> <span class="k">if</span> <span class="n">conflict</span><span class="p">:</span> -</span><span id="Parser-1694"><a href="#Parser-1694"><span class="linenos">1694</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"CONSTRAINT"</span><span class="p">):</span> -</span><span id="Parser-1695"><a href="#Parser-1695"><span class="linenos">1695</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="Parser-1696"><a href="#Parser-1696"><span class="linenos">1696</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1697"><a href="#Parser-1697"><span class="linenos">1697</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">)</span> -</span><span id="Parser-1698"><a href="#Parser-1698"><span class="linenos">1698</span></a> -</span><span id="Parser-1699"><a href="#Parser-1699"><span class="linenos">1699</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DO"</span><span class="p">)</span> -</span><span id="Parser-1700"><a href="#Parser-1700"><span class="linenos">1700</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NOTHING"</span><span class="p">):</span> -</span><span id="Parser-1701"><a href="#Parser-1701"><span class="linenos">1701</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Parser-1702"><a href="#Parser-1702"><span class="linenos">1702</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1703"><a href="#Parser-1703"><span class="linenos">1703</span></a> <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">UPDATE</span><span class="p">)</span> -</span><span id="Parser-1704"><a href="#Parser-1704"><span class="linenos">1704</span></a> <span class="n">expressions</span> <span class="o">=</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">SET</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">)</span> -</span><span id="Parser-1705"><a href="#Parser-1705"><span class="linenos">1705</span></a> -</span><span id="Parser-1706"><a href="#Parser-1706"><span class="linenos">1706</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><span id="Parser-1707"><a href="#Parser-1707"><span class="linenos">1707</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnConflict</span><span class="p">,</span> -</span><span id="Parser-1708"><a href="#Parser-1708"><span class="linenos">1708</span></a> <span class="n">duplicate</span><span class="o">=</span><span class="n">duplicate</span><span class="p">,</span> -</span><span id="Parser-1709"><a href="#Parser-1709"><span class="linenos">1709</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Parser-1710"><a href="#Parser-1710"><span class="linenos">1710</span></a> <span class="n">nothing</span><span class="o">=</span><span class="n">nothing</span><span class="p">,</span> -</span><span id="Parser-1711"><a href="#Parser-1711"><span class="linenos">1711</span></a> <span class="n">key</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> -</span><span id="Parser-1712"><a href="#Parser-1712"><span class="linenos">1712</span></a> <span class="n">constraint</span><span class="o">=</span><span class="n">constraint</span><span class="p">,</span> -</span><span id="Parser-1713"><a href="#Parser-1713"><span class="linenos">1713</span></a> <span class="p">)</span> -</span><span id="Parser-1714"><a href="#Parser-1714"><span class="linenos">1714</span></a> -</span><span id="Parser-1715"><a href="#Parser-1715"><span class="linenos">1715</span></a> <span class="k">def</span> <span class="nf">_parse_returning</span><span class="p">(</span><span class="bp">self</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">Returning</span><span class="p">]:</span> -</span><span id="Parser-1716"><a href="#Parser-1716"><span class="linenos">1716</span></a> <span class="k">if</span> <span class="ow">not</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">RETURNING</span><span class="p">):</span> -</span><span id="Parser-1717"><a href="#Parser-1717"><span class="linenos">1717</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1685"><a href="#Parser-1685"><span class="linenos">1685</span></a> <span class="k">def</span> <span class="nf">_parse_on_conflict</span><span class="p">(</span><span class="bp">self</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">OnConflict</span><span class="p">]:</span> +</span><span id="Parser-1686"><a href="#Parser-1686"><span class="linenos">1686</span></a> <span class="n">conflict</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"CONFLICT"</span><span class="p">)</span> +</span><span id="Parser-1687"><a href="#Parser-1687"><span class="linenos">1687</span></a> <span class="n">duplicate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"DUPLICATE"</span><span class="p">,</span> <span class="s2">"KEY"</span><span class="p">)</span> +</span><span id="Parser-1688"><a href="#Parser-1688"><span class="linenos">1688</span></a> +</span><span id="Parser-1689"><a href="#Parser-1689"><span class="linenos">1689</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">conflict</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">duplicate</span><span class="p">:</span> +</span><span id="Parser-1690"><a href="#Parser-1690"><span class="linenos">1690</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1691"><a href="#Parser-1691"><span class="linenos">1691</span></a> +</span><span id="Parser-1692"><a href="#Parser-1692"><span class="linenos">1692</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1693"><a href="#Parser-1693"><span class="linenos">1693</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1694"><a href="#Parser-1694"><span class="linenos">1694</span></a> <span class="n">key</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1695"><a href="#Parser-1695"><span class="linenos">1695</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1696"><a href="#Parser-1696"><span class="linenos">1696</span></a> +</span><span id="Parser-1697"><a href="#Parser-1697"><span class="linenos">1697</span></a> <span class="k">if</span> <span class="n">conflict</span><span class="p">:</span> +</span><span id="Parser-1698"><a href="#Parser-1698"><span class="linenos">1698</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"CONSTRAINT"</span><span class="p">):</span> +</span><span id="Parser-1699"><a href="#Parser-1699"><span class="linenos">1699</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="Parser-1700"><a href="#Parser-1700"><span class="linenos">1700</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1701"><a href="#Parser-1701"><span class="linenos">1701</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">)</span> +</span><span id="Parser-1702"><a href="#Parser-1702"><span class="linenos">1702</span></a> +</span><span id="Parser-1703"><a href="#Parser-1703"><span class="linenos">1703</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DO"</span><span class="p">)</span> +</span><span id="Parser-1704"><a href="#Parser-1704"><span class="linenos">1704</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NOTHING"</span><span class="p">):</span> +</span><span id="Parser-1705"><a href="#Parser-1705"><span class="linenos">1705</span></a> <span class="n">nothing</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Parser-1706"><a href="#Parser-1706"><span class="linenos">1706</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1707"><a href="#Parser-1707"><span class="linenos">1707</span></a> <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">UPDATE</span><span class="p">)</span> +</span><span id="Parser-1708"><a href="#Parser-1708"><span class="linenos">1708</span></a> <span class="n">expressions</span> <span class="o">=</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">SET</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">)</span> +</span><span id="Parser-1709"><a href="#Parser-1709"><span class="linenos">1709</span></a> +</span><span id="Parser-1710"><a href="#Parser-1710"><span class="linenos">1710</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><span id="Parser-1711"><a href="#Parser-1711"><span class="linenos">1711</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OnConflict</span><span class="p">,</span> +</span><span id="Parser-1712"><a href="#Parser-1712"><span class="linenos">1712</span></a> <span class="n">duplicate</span><span class="o">=</span><span class="n">duplicate</span><span class="p">,</span> +</span><span id="Parser-1713"><a href="#Parser-1713"><span class="linenos">1713</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Parser-1714"><a href="#Parser-1714"><span class="linenos">1714</span></a> <span class="n">nothing</span><span class="o">=</span><span class="n">nothing</span><span class="p">,</span> +</span><span id="Parser-1715"><a href="#Parser-1715"><span class="linenos">1715</span></a> <span class="n">key</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> +</span><span id="Parser-1716"><a href="#Parser-1716"><span class="linenos">1716</span></a> <span class="n">constraint</span><span class="o">=</span><span class="n">constraint</span><span class="p">,</span> +</span><span id="Parser-1717"><a href="#Parser-1717"><span class="linenos">1717</span></a> <span class="p">)</span> </span><span id="Parser-1718"><a href="#Parser-1718"><span class="linenos">1718</span></a> -</span><span id="Parser-1719"><a href="#Parser-1719"><span class="linenos">1719</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">Returning</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">))</span> -</span><span id="Parser-1720"><a href="#Parser-1720"><span class="linenos">1720</span></a> -</span><span id="Parser-1721"><a href="#Parser-1721"><span class="linenos">1721</span></a> <span class="k">def</span> <span class="nf">_parse_row</span><span class="p">(</span><span class="bp">self</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">RowFormatSerdeProperty</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">]:</span> -</span><span id="Parser-1722"><a href="#Parser-1722"><span class="linenos">1722</span></a> <span class="k">if</span> <span class="ow">not</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">FORMAT</span><span class="p">):</span> -</span><span id="Parser-1723"><a href="#Parser-1723"><span class="linenos">1723</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-1724"><a href="#Parser-1724"><span class="linenos">1724</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_row_format</span><span class="p">()</span> -</span><span id="Parser-1725"><a href="#Parser-1725"><span class="linenos">1725</span></a> -</span><span id="Parser-1726"><a href="#Parser-1726"><span class="linenos">1726</span></a> <span class="k">def</span> <span class="nf">_parse_row_format</span><span class="p">(</span> -</span><span id="Parser-1727"><a href="#Parser-1727"><span class="linenos">1727</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">match_row</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-1728"><a href="#Parser-1728"><span class="linenos">1728</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">RowFormatSerdeProperty</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">]:</span> -</span><span id="Parser-1729"><a href="#Parser-1729"><span class="linenos">1729</span></a> <span class="k">if</span> <span class="n">match_row</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FORMAT</span><span class="p">):</span> -</span><span id="Parser-1730"><a href="#Parser-1730"><span class="linenos">1730</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-1731"><a href="#Parser-1731"><span class="linenos">1731</span></a> -</span><span id="Parser-1732"><a href="#Parser-1732"><span class="linenos">1732</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SERDE"</span><span class="p">):</span> -</span><span id="Parser-1733"><a href="#Parser-1733"><span class="linenos">1733</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">RowFormatSerdeProperty</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_string</span><span class="p">())</span> -</span><span id="Parser-1734"><a href="#Parser-1734"><span class="linenos">1734</span></a> -</span><span id="Parser-1735"><a href="#Parser-1735"><span class="linenos">1735</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DELIMITED"</span><span class="p">)</span> -</span><span id="Parser-1736"><a href="#Parser-1736"><span class="linenos">1736</span></a> -</span><span id="Parser-1737"><a href="#Parser-1737"><span class="linenos">1737</span></a> <span class="n">kwargs</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Parser-1719"><a href="#Parser-1719"><span class="linenos">1719</span></a> <span class="k">def</span> <span class="nf">_parse_returning</span><span class="p">(</span><span class="bp">self</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">Returning</span><span class="p">]:</span> +</span><span id="Parser-1720"><a href="#Parser-1720"><span class="linenos">1720</span></a> <span class="k">if</span> <span class="ow">not</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">RETURNING</span><span class="p">):</span> +</span><span id="Parser-1721"><a href="#Parser-1721"><span class="linenos">1721</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1722"><a href="#Parser-1722"><span class="linenos">1722</span></a> +</span><span id="Parser-1723"><a href="#Parser-1723"><span class="linenos">1723</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">Returning</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">))</span> +</span><span id="Parser-1724"><a href="#Parser-1724"><span class="linenos">1724</span></a> +</span><span id="Parser-1725"><a href="#Parser-1725"><span class="linenos">1725</span></a> <span class="k">def</span> <span class="nf">_parse_row</span><span class="p">(</span><span class="bp">self</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">RowFormatSerdeProperty</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">]:</span> +</span><span id="Parser-1726"><a href="#Parser-1726"><span class="linenos">1726</span></a> <span class="k">if</span> <span class="ow">not</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">FORMAT</span><span class="p">):</span> +</span><span id="Parser-1727"><a href="#Parser-1727"><span class="linenos">1727</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1728"><a href="#Parser-1728"><span class="linenos">1728</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_row_format</span><span class="p">()</span> +</span><span id="Parser-1729"><a href="#Parser-1729"><span class="linenos">1729</span></a> +</span><span id="Parser-1730"><a href="#Parser-1730"><span class="linenos">1730</span></a> <span class="k">def</span> <span class="nf">_parse_row_format</span><span class="p">(</span> +</span><span id="Parser-1731"><a href="#Parser-1731"><span class="linenos">1731</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">match_row</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-1732"><a href="#Parser-1732"><span class="linenos">1732</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">RowFormatSerdeProperty</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">RowFormatDelimitedProperty</span><span class="p">]:</span> +</span><span id="Parser-1733"><a href="#Parser-1733"><span class="linenos">1733</span></a> <span class="k">if</span> <span class="n">match_row</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FORMAT</span><span class="p">):</span> +</span><span id="Parser-1734"><a href="#Parser-1734"><span class="linenos">1734</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1735"><a href="#Parser-1735"><span class="linenos">1735</span></a> +</span><span id="Parser-1736"><a href="#Parser-1736"><span class="linenos">1736</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SERDE"</span><span class="p">):</span> +</span><span id="Parser-1737"><a href="#Parser-1737"><span class="linenos">1737</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">RowFormatSerdeProperty</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_string</span><span class="p">())</span> </span><span id="Parser-1738"><a href="#Parser-1738"><span class="linenos">1738</span></a> -</span><span id="Parser-1739"><a href="#Parser-1739"><span class="linenos">1739</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FIELDS"</span><span class="p">,</span> <span class="s2">"TERMINATED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> -</span><span id="Parser-1740"><a href="#Parser-1740"><span class="linenos">1740</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"fields"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="Parser-1741"><a href="#Parser-1741"><span class="linenos">1741</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ESCAPED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> -</span><span id="Parser-1742"><a href="#Parser-1742"><span class="linenos">1742</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"escaped"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="Parser-1743"><a href="#Parser-1743"><span class="linenos">1743</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"COLLECTION"</span><span class="p">,</span> <span class="s2">"ITEMS"</span><span class="p">,</span> <span class="s2">"TERMINATED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> -</span><span id="Parser-1744"><a href="#Parser-1744"><span class="linenos">1744</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"collection_items"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="Parser-1745"><a href="#Parser-1745"><span class="linenos">1745</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MAP"</span><span class="p">,</span> <span class="s2">"KEYS"</span><span class="p">,</span> <span class="s2">"TERMINATED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> -</span><span id="Parser-1746"><a href="#Parser-1746"><span class="linenos">1746</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"map_keys"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="Parser-1747"><a href="#Parser-1747"><span class="linenos">1747</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LINES"</span><span class="p">,</span> <span class="s2">"TERMINATED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> -</span><span id="Parser-1748"><a href="#Parser-1748"><span class="linenos">1748</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"lines"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="Parser-1749"><a href="#Parser-1749"><span class="linenos">1749</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULL"</span><span class="p">,</span> <span class="s2">"DEFINED"</span><span class="p">,</span> <span class="s2">"AS"</span><span class="p">):</span> -</span><span id="Parser-1750"><a href="#Parser-1750"><span class="linenos">1750</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"null"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="Parser-1751"><a href="#Parser-1751"><span class="linenos">1751</span></a> -</span><span id="Parser-1752"><a href="#Parser-1752"><span class="linenos">1752</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">RowFormatDelimitedProperty</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="Parser-1753"><a href="#Parser-1753"><span class="linenos">1753</span></a> -</span><span id="Parser-1754"><a href="#Parser-1754"><span class="linenos">1754</span></a> <span class="k">def</span> <span class="nf">_parse_load</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">LoadData</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> -</span><span id="Parser-1755"><a href="#Parser-1755"><span class="linenos">1755</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DATA"</span><span class="p">):</span> -</span><span id="Parser-1756"><a href="#Parser-1756"><span class="linenos">1756</span></a> <span class="n">local</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LOCAL"</span><span class="p">)</span> -</span><span id="Parser-1757"><a href="#Parser-1757"><span class="linenos">1757</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INPATH"</span><span class="p">)</span> -</span><span id="Parser-1758"><a href="#Parser-1758"><span class="linenos">1758</span></a> <span class="n">inpath</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="Parser-1759"><a href="#Parser-1759"><span class="linenos">1759</span></a> <span class="n">overwrite</span> <span class="o">=</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">OVERWRITE</span><span class="p">)</span> -</span><span id="Parser-1760"><a href="#Parser-1760"><span class="linenos">1760</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">INTO</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">)</span> -</span><span id="Parser-1761"><a href="#Parser-1761"><span class="linenos">1761</span></a> -</span><span id="Parser-1762"><a href="#Parser-1762"><span class="linenos">1762</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><span id="Parser-1763"><a href="#Parser-1763"><span class="linenos">1763</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LoadData</span><span class="p">,</span> -</span><span id="Parser-1764"><a href="#Parser-1764"><span class="linenos">1764</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="Parser-1765"><a href="#Parser-1765"><span class="linenos">1765</span></a> <span class="n">local</span><span class="o">=</span><span class="n">local</span><span class="p">,</span> -</span><span id="Parser-1766"><a href="#Parser-1766"><span class="linenos">1766</span></a> <span class="n">overwrite</span><span class="o">=</span><span class="n">overwrite</span><span class="p">,</span> -</span><span id="Parser-1767"><a href="#Parser-1767"><span class="linenos">1767</span></a> <span class="n">inpath</span><span class="o">=</span><span class="n">inpath</span><span class="p">,</span> -</span><span id="Parser-1768"><a href="#Parser-1768"><span class="linenos">1768</span></a> <span class="n">partition</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition</span><span class="p">(),</span> -</span><span id="Parser-1769"><a href="#Parser-1769"><span class="linenos">1769</span></a> <span class="n">input_format</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INPUTFORMAT"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">(),</span> -</span><span id="Parser-1770"><a href="#Parser-1770"><span class="linenos">1770</span></a> <span class="n">serde</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SERDE"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">(),</span> -</span><span id="Parser-1771"><a href="#Parser-1771"><span class="linenos">1771</span></a> <span class="p">)</span> -</span><span id="Parser-1772"><a href="#Parser-1772"><span class="linenos">1772</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> -</span><span id="Parser-1773"><a href="#Parser-1773"><span class="linenos">1773</span></a> -</span><span id="Parser-1774"><a href="#Parser-1774"><span class="linenos">1774</span></a> <span class="k">def</span> <span class="nf">_parse_delete</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">Delete</span><span class="p">:</span> -</span><span id="Parser-1775"><a href="#Parser-1775"><span class="linenos">1775</span></a> <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">FROM</span><span class="p">)</span> -</span><span id="Parser-1776"><a href="#Parser-1776"><span class="linenos">1776</span></a> -</span><span id="Parser-1777"><a href="#Parser-1777"><span class="linenos">1777</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><span id="Parser-1778"><a href="#Parser-1778"><span class="linenos">1778</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">,</span> -</span><span id="Parser-1779"><a href="#Parser-1779"><span class="linenos">1779</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(),</span> -</span><span id="Parser-1780"><a href="#Parser-1780"><span class="linenos">1780</span></a> <span class="n">using</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</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">USING</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()),</span> -</span><span id="Parser-1781"><a href="#Parser-1781"><span class="linenos">1781</span></a> <span class="n">where</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">(),</span> -</span><span id="Parser-1782"><a href="#Parser-1782"><span class="linenos">1782</span></a> <span class="n">returning</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_returning</span><span class="p">(),</span> -</span><span id="Parser-1783"><a href="#Parser-1783"><span class="linenos">1783</span></a> <span class="p">)</span> -</span><span id="Parser-1784"><a href="#Parser-1784"><span class="linenos">1784</span></a> -</span><span id="Parser-1785"><a href="#Parser-1785"><span class="linenos">1785</span></a> <span class="k">def</span> <span class="nf">_parse_update</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">Update</span><span class="p">:</span> -</span><span id="Parser-1786"><a href="#Parser-1786"><span class="linenos">1786</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><span id="Parser-1787"><a href="#Parser-1787"><span class="linenos">1787</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> -</span><span id="Parser-1788"><a href="#Parser-1788"><span class="linenos">1788</span></a> <span class="o">**</span><span class="p">{</span> <span class="c1"># type: ignore</span> -</span><span id="Parser-1789"><a href="#Parser-1789"><span class="linenos">1789</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">alias_tokens</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">UPDATE_ALIAS_TOKENS</span><span class="p">),</span> -</span><span id="Parser-1790"><a href="#Parser-1790"><span class="linenos">1790</span></a> <span class="s2">"expressions"</span><span class="p">:</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">SET</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">),</span> -</span><span id="Parser-1791"><a href="#Parser-1791"><span class="linenos">1791</span></a> <span class="s2">"from"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_from</span><span class="p">(</span><span class="n">modifiers</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="Parser-1792"><a href="#Parser-1792"><span class="linenos">1792</span></a> <span class="s2">"where"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">(),</span> -</span><span id="Parser-1793"><a href="#Parser-1793"><span class="linenos">1793</span></a> <span class="s2">"returning"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_returning</span><span class="p">(),</span> -</span><span id="Parser-1794"><a href="#Parser-1794"><span class="linenos">1794</span></a> <span class="p">},</span> -</span><span id="Parser-1795"><a href="#Parser-1795"><span class="linenos">1795</span></a> <span class="p">)</span> -</span><span id="Parser-1796"><a href="#Parser-1796"><span class="linenos">1796</span></a> -</span><span id="Parser-1797"><a href="#Parser-1797"><span class="linenos">1797</span></a> <span class="k">def</span> <span class="nf">_parse_uncache</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">Uncache</span><span class="p">:</span> -</span><span id="Parser-1798"><a href="#Parser-1798"><span class="linenos">1798</span></a> <span class="k">if</span> <span class="ow">not</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">TABLE</span><span class="p">):</span> -</span><span id="Parser-1799"><a href="#Parser-1799"><span class="linenos">1799</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting TABLE after UNCACHE"</span><span class="p">)</span> +</span><span id="Parser-1739"><a href="#Parser-1739"><span class="linenos">1739</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DELIMITED"</span><span class="p">)</span> +</span><span id="Parser-1740"><a href="#Parser-1740"><span class="linenos">1740</span></a> +</span><span id="Parser-1741"><a href="#Parser-1741"><span class="linenos">1741</span></a> <span class="n">kwargs</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Parser-1742"><a href="#Parser-1742"><span class="linenos">1742</span></a> +</span><span id="Parser-1743"><a href="#Parser-1743"><span class="linenos">1743</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FIELDS"</span><span class="p">,</span> <span class="s2">"TERMINATED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> +</span><span id="Parser-1744"><a href="#Parser-1744"><span class="linenos">1744</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"fields"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="Parser-1745"><a href="#Parser-1745"><span class="linenos">1745</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ESCAPED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> +</span><span id="Parser-1746"><a href="#Parser-1746"><span class="linenos">1746</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"escaped"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="Parser-1747"><a href="#Parser-1747"><span class="linenos">1747</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"COLLECTION"</span><span class="p">,</span> <span class="s2">"ITEMS"</span><span class="p">,</span> <span class="s2">"TERMINATED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> +</span><span id="Parser-1748"><a href="#Parser-1748"><span class="linenos">1748</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"collection_items"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="Parser-1749"><a href="#Parser-1749"><span class="linenos">1749</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MAP"</span><span class="p">,</span> <span class="s2">"KEYS"</span><span class="p">,</span> <span class="s2">"TERMINATED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> +</span><span id="Parser-1750"><a href="#Parser-1750"><span class="linenos">1750</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"map_keys"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="Parser-1751"><a href="#Parser-1751"><span class="linenos">1751</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LINES"</span><span class="p">,</span> <span class="s2">"TERMINATED"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> +</span><span id="Parser-1752"><a href="#Parser-1752"><span class="linenos">1752</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"lines"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="Parser-1753"><a href="#Parser-1753"><span class="linenos">1753</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULL"</span><span class="p">,</span> <span class="s2">"DEFINED"</span><span class="p">,</span> <span class="s2">"AS"</span><span class="p">):</span> +</span><span id="Parser-1754"><a href="#Parser-1754"><span class="linenos">1754</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"null"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="Parser-1755"><a href="#Parser-1755"><span class="linenos">1755</span></a> +</span><span id="Parser-1756"><a href="#Parser-1756"><span class="linenos">1756</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">RowFormatDelimitedProperty</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="Parser-1757"><a href="#Parser-1757"><span class="linenos">1757</span></a> +</span><span id="Parser-1758"><a href="#Parser-1758"><span class="linenos">1758</span></a> <span class="k">def</span> <span class="nf">_parse_load</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">LoadData</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> +</span><span id="Parser-1759"><a href="#Parser-1759"><span class="linenos">1759</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DATA"</span><span class="p">):</span> +</span><span id="Parser-1760"><a href="#Parser-1760"><span class="linenos">1760</span></a> <span class="n">local</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LOCAL"</span><span class="p">)</span> +</span><span id="Parser-1761"><a href="#Parser-1761"><span class="linenos">1761</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INPATH"</span><span class="p">)</span> +</span><span id="Parser-1762"><a href="#Parser-1762"><span class="linenos">1762</span></a> <span class="n">inpath</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="Parser-1763"><a href="#Parser-1763"><span class="linenos">1763</span></a> <span class="n">overwrite</span> <span class="o">=</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">OVERWRITE</span><span class="p">)</span> +</span><span id="Parser-1764"><a href="#Parser-1764"><span class="linenos">1764</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">INTO</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">)</span> +</span><span id="Parser-1765"><a href="#Parser-1765"><span class="linenos">1765</span></a> +</span><span id="Parser-1766"><a href="#Parser-1766"><span class="linenos">1766</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><span id="Parser-1767"><a href="#Parser-1767"><span class="linenos">1767</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">LoadData</span><span class="p">,</span> +</span><span id="Parser-1768"><a href="#Parser-1768"><span class="linenos">1768</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="Parser-1769"><a href="#Parser-1769"><span class="linenos">1769</span></a> <span class="n">local</span><span class="o">=</span><span class="n">local</span><span class="p">,</span> +</span><span id="Parser-1770"><a href="#Parser-1770"><span class="linenos">1770</span></a> <span class="n">overwrite</span><span class="o">=</span><span class="n">overwrite</span><span class="p">,</span> +</span><span id="Parser-1771"><a href="#Parser-1771"><span class="linenos">1771</span></a> <span class="n">inpath</span><span class="o">=</span><span class="n">inpath</span><span class="p">,</span> +</span><span id="Parser-1772"><a href="#Parser-1772"><span class="linenos">1772</span></a> <span class="n">partition</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition</span><span class="p">(),</span> +</span><span id="Parser-1773"><a href="#Parser-1773"><span class="linenos">1773</span></a> <span class="n">input_format</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INPUTFORMAT"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">(),</span> +</span><span id="Parser-1774"><a href="#Parser-1774"><span class="linenos">1774</span></a> <span class="n">serde</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SERDE"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">(),</span> +</span><span id="Parser-1775"><a href="#Parser-1775"><span class="linenos">1775</span></a> <span class="p">)</span> +</span><span id="Parser-1776"><a href="#Parser-1776"><span class="linenos">1776</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="Parser-1777"><a href="#Parser-1777"><span class="linenos">1777</span></a> +</span><span id="Parser-1778"><a href="#Parser-1778"><span class="linenos">1778</span></a> <span class="k">def</span> <span class="nf">_parse_delete</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">Delete</span><span class="p">:</span> +</span><span id="Parser-1779"><a href="#Parser-1779"><span class="linenos">1779</span></a> <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">FROM</span><span class="p">)</span> +</span><span id="Parser-1780"><a href="#Parser-1780"><span class="linenos">1780</span></a> +</span><span id="Parser-1781"><a href="#Parser-1781"><span class="linenos">1781</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><span id="Parser-1782"><a href="#Parser-1782"><span class="linenos">1782</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">,</span> +</span><span id="Parser-1783"><a href="#Parser-1783"><span class="linenos">1783</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(),</span> +</span><span id="Parser-1784"><a href="#Parser-1784"><span class="linenos">1784</span></a> <span class="n">using</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</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">USING</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()),</span> +</span><span id="Parser-1785"><a href="#Parser-1785"><span class="linenos">1785</span></a> <span class="n">where</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">(),</span> +</span><span id="Parser-1786"><a href="#Parser-1786"><span class="linenos">1786</span></a> <span class="n">returning</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_returning</span><span class="p">(),</span> +</span><span id="Parser-1787"><a href="#Parser-1787"><span class="linenos">1787</span></a> <span class="p">)</span> +</span><span id="Parser-1788"><a href="#Parser-1788"><span class="linenos">1788</span></a> +</span><span id="Parser-1789"><a href="#Parser-1789"><span class="linenos">1789</span></a> <span class="k">def</span> <span class="nf">_parse_update</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">Update</span><span class="p">:</span> +</span><span id="Parser-1790"><a href="#Parser-1790"><span class="linenos">1790</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><span id="Parser-1791"><a href="#Parser-1791"><span class="linenos">1791</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> +</span><span id="Parser-1792"><a href="#Parser-1792"><span class="linenos">1792</span></a> <span class="o">**</span><span class="p">{</span> <span class="c1"># type: ignore</span> +</span><span id="Parser-1793"><a href="#Parser-1793"><span class="linenos">1793</span></a> <span class="s2">"this"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">alias_tokens</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">UPDATE_ALIAS_TOKENS</span><span class="p">),</span> +</span><span id="Parser-1794"><a href="#Parser-1794"><span class="linenos">1794</span></a> <span class="s2">"expressions"</span><span class="p">:</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">SET</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">),</span> +</span><span id="Parser-1795"><a href="#Parser-1795"><span class="linenos">1795</span></a> <span class="s2">"from"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_from</span><span class="p">(</span><span class="n">modifiers</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="Parser-1796"><a href="#Parser-1796"><span class="linenos">1796</span></a> <span class="s2">"where"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">(),</span> +</span><span id="Parser-1797"><a href="#Parser-1797"><span class="linenos">1797</span></a> <span class="s2">"returning"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_returning</span><span class="p">(),</span> +</span><span id="Parser-1798"><a href="#Parser-1798"><span class="linenos">1798</span></a> <span class="p">},</span> +</span><span id="Parser-1799"><a href="#Parser-1799"><span class="linenos">1799</span></a> <span class="p">)</span> </span><span id="Parser-1800"><a href="#Parser-1800"><span class="linenos">1800</span></a> -</span><span id="Parser-1801"><a href="#Parser-1801"><span class="linenos">1801</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><span id="Parser-1802"><a href="#Parser-1802"><span class="linenos">1802</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Uncache</span><span class="p">,</span> <span class="n">exists</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</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_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-1803"><a href="#Parser-1803"><span class="linenos">1803</span></a> <span class="p">)</span> +</span><span id="Parser-1801"><a href="#Parser-1801"><span class="linenos">1801</span></a> <span class="k">def</span> <span class="nf">_parse_uncache</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">Uncache</span><span class="p">:</span> +</span><span id="Parser-1802"><a href="#Parser-1802"><span class="linenos">1802</span></a> <span class="k">if</span> <span class="ow">not</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">TABLE</span><span class="p">):</span> +</span><span id="Parser-1803"><a href="#Parser-1803"><span class="linenos">1803</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting TABLE after UNCACHE"</span><span class="p">)</span> </span><span id="Parser-1804"><a href="#Parser-1804"><span class="linenos">1804</span></a> -</span><span id="Parser-1805"><a href="#Parser-1805"><span class="linenos">1805</span></a> <span class="k">def</span> <span class="nf">_parse_cache</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">Cache</span><span class="p">:</span> -</span><span id="Parser-1806"><a href="#Parser-1806"><span class="linenos">1806</span></a> <span class="n">lazy</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LAZY"</span><span class="p">)</span> -</span><span id="Parser-1807"><a href="#Parser-1807"><span class="linenos">1807</span></a> <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">TABLE</span><span class="p">)</span> -</span><span id="Parser-1808"><a href="#Parser-1808"><span class="linenos">1808</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-1809"><a href="#Parser-1809"><span class="linenos">1809</span></a> -</span><span id="Parser-1810"><a href="#Parser-1810"><span class="linenos">1810</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-1811"><a href="#Parser-1811"><span class="linenos">1811</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OPTIONS"</span><span class="p">):</span> -</span><span id="Parser-1812"><a href="#Parser-1812"><span class="linenos">1812</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> -</span><span id="Parser-1813"><a href="#Parser-1813"><span class="linenos">1813</span></a> <span class="n">k</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="Parser-1814"><a href="#Parser-1814"><span class="linenos">1814</span></a> <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">EQ</span><span class="p">)</span> -</span><span id="Parser-1815"><a href="#Parser-1815"><span class="linenos">1815</span></a> <span class="n">v</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="Parser-1816"><a href="#Parser-1816"><span class="linenos">1816</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">]</span> -</span><span id="Parser-1817"><a href="#Parser-1817"><span class="linenos">1817</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="Parser-1818"><a href="#Parser-1818"><span class="linenos">1818</span></a> -</span><span id="Parser-1819"><a href="#Parser-1819"><span class="linenos">1819</span></a> <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">ALIAS</span><span class="p">)</span> -</span><span id="Parser-1820"><a href="#Parser-1820"><span class="linenos">1820</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><span id="Parser-1821"><a href="#Parser-1821"><span class="linenos">1821</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">,</span> -</span><span id="Parser-1822"><a href="#Parser-1822"><span class="linenos">1822</span></a> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> -</span><span id="Parser-1823"><a href="#Parser-1823"><span class="linenos">1823</span></a> <span class="n">lazy</span><span class="o">=</span><span class="n">lazy</span><span class="p">,</span> -</span><span id="Parser-1824"><a href="#Parser-1824"><span class="linenos">1824</span></a> <span class="n">options</span><span class="o">=</span><span class="n">options</span><span class="p">,</span> -</span><span id="Parser-1825"><a href="#Parser-1825"><span class="linenos">1825</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="Parser-1826"><a href="#Parser-1826"><span class="linenos">1826</span></a> <span class="p">)</span> -</span><span id="Parser-1827"><a href="#Parser-1827"><span class="linenos">1827</span></a> -</span><span id="Parser-1828"><a href="#Parser-1828"><span class="linenos">1828</span></a> <span class="k">def</span> <span class="nf">_parse_partition</span><span class="p">(</span><span class="bp">self</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">Partition</span><span class="p">]:</span> -</span><span id="Parser-1829"><a href="#Parser-1829"><span class="linenos">1829</span></a> <span class="k">if</span> <span class="ow">not</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">PARTITION</span><span class="p">):</span> -</span><span id="Parser-1830"><a href="#Parser-1830"><span class="linenos">1830</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1805"><a href="#Parser-1805"><span class="linenos">1805</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><span id="Parser-1806"><a href="#Parser-1806"><span class="linenos">1806</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Uncache</span><span class="p">,</span> <span class="n">exists</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</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_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-1807"><a href="#Parser-1807"><span class="linenos">1807</span></a> <span class="p">)</span> +</span><span id="Parser-1808"><a href="#Parser-1808"><span class="linenos">1808</span></a> +</span><span id="Parser-1809"><a href="#Parser-1809"><span class="linenos">1809</span></a> <span class="k">def</span> <span class="nf">_parse_cache</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">Cache</span><span class="p">:</span> +</span><span id="Parser-1810"><a href="#Parser-1810"><span class="linenos">1810</span></a> <span class="n">lazy</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LAZY"</span><span class="p">)</span> +</span><span id="Parser-1811"><a href="#Parser-1811"><span class="linenos">1811</span></a> <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">TABLE</span><span class="p">)</span> +</span><span id="Parser-1812"><a href="#Parser-1812"><span class="linenos">1812</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-1813"><a href="#Parser-1813"><span class="linenos">1813</span></a> +</span><span id="Parser-1814"><a href="#Parser-1814"><span class="linenos">1814</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-1815"><a href="#Parser-1815"><span class="linenos">1815</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OPTIONS"</span><span class="p">):</span> +</span><span id="Parser-1816"><a href="#Parser-1816"><span class="linenos">1816</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> +</span><span id="Parser-1817"><a href="#Parser-1817"><span class="linenos">1817</span></a> <span class="n">k</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="Parser-1818"><a href="#Parser-1818"><span class="linenos">1818</span></a> <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">EQ</span><span class="p">)</span> +</span><span id="Parser-1819"><a href="#Parser-1819"><span class="linenos">1819</span></a> <span class="n">v</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="Parser-1820"><a href="#Parser-1820"><span class="linenos">1820</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">]</span> +</span><span id="Parser-1821"><a href="#Parser-1821"><span class="linenos">1821</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-1822"><a href="#Parser-1822"><span class="linenos">1822</span></a> +</span><span id="Parser-1823"><a href="#Parser-1823"><span class="linenos">1823</span></a> <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">ALIAS</span><span class="p">)</span> +</span><span id="Parser-1824"><a href="#Parser-1824"><span class="linenos">1824</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><span id="Parser-1825"><a href="#Parser-1825"><span class="linenos">1825</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cache</span><span class="p">,</span> +</span><span id="Parser-1826"><a href="#Parser-1826"><span class="linenos">1826</span></a> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> +</span><span id="Parser-1827"><a href="#Parser-1827"><span class="linenos">1827</span></a> <span class="n">lazy</span><span class="o">=</span><span class="n">lazy</span><span class="p">,</span> +</span><span id="Parser-1828"><a href="#Parser-1828"><span class="linenos">1828</span></a> <span class="n">options</span><span class="o">=</span><span class="n">options</span><span class="p">,</span> +</span><span id="Parser-1829"><a href="#Parser-1829"><span class="linenos">1829</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="Parser-1830"><a href="#Parser-1830"><span class="linenos">1830</span></a> <span class="p">)</span> </span><span id="Parser-1831"><a href="#Parser-1831"><span class="linenos">1831</span></a> -</span><span id="Parser-1832"><a href="#Parser-1832"><span class="linenos">1832</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><span id="Parser-1833"><a href="#Parser-1833"><span class="linenos">1833</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Partition</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="Parser-1834"><a href="#Parser-1834"><span class="linenos">1834</span></a> <span class="p">)</span> +</span><span id="Parser-1832"><a href="#Parser-1832"><span class="linenos">1832</span></a> <span class="k">def</span> <span class="nf">_parse_partition</span><span class="p">(</span><span class="bp">self</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">Partition</span><span class="p">]:</span> +</span><span id="Parser-1833"><a href="#Parser-1833"><span class="linenos">1833</span></a> <span class="k">if</span> <span class="ow">not</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">PARTITION</span><span class="p">):</span> +</span><span id="Parser-1834"><a href="#Parser-1834"><span class="linenos">1834</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="Parser-1835"><a href="#Parser-1835"><span class="linenos">1835</span></a> -</span><span id="Parser-1836"><a href="#Parser-1836"><span class="linenos">1836</span></a> <span class="k">def</span> <span class="nf">_parse_value</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">Tuple</span><span class="p">:</span> -</span><span id="Parser-1837"><a href="#Parser-1837"><span class="linenos">1837</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_PAREN</span><span class="p">):</span> -</span><span id="Parser-1838"><a href="#Parser-1838"><span class="linenos">1838</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="Parser-1839"><a href="#Parser-1839"><span class="linenos">1839</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="Parser-1840"><a href="#Parser-1840"><span class="linenos">1840</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">Tuple</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Parser-1841"><a href="#Parser-1841"><span class="linenos">1841</span></a> -</span><span id="Parser-1842"><a href="#Parser-1842"><span class="linenos">1842</span></a> <span class="c1"># In presto we can have VALUES 1, 2 which results in 1 column & 2 rows.</span> -</span><span id="Parser-1843"><a href="#Parser-1843"><span class="linenos">1843</span></a> <span class="c1"># Source: https://prestodb.io/docs/current/sql/values.html</span> -</span><span id="Parser-1844"><a href="#Parser-1844"><span class="linenos">1844</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">Tuple</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()])</span> +</span><span id="Parser-1836"><a href="#Parser-1836"><span class="linenos">1836</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><span id="Parser-1837"><a href="#Parser-1837"><span class="linenos">1837</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Partition</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="Parser-1838"><a href="#Parser-1838"><span class="linenos">1838</span></a> <span class="p">)</span> +</span><span id="Parser-1839"><a href="#Parser-1839"><span class="linenos">1839</span></a> +</span><span id="Parser-1840"><a href="#Parser-1840"><span class="linenos">1840</span></a> <span class="k">def</span> <span class="nf">_parse_value</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">Tuple</span><span class="p">:</span> +</span><span id="Parser-1841"><a href="#Parser-1841"><span class="linenos">1841</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_PAREN</span><span class="p">):</span> +</span><span id="Parser-1842"><a href="#Parser-1842"><span class="linenos">1842</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="Parser-1843"><a href="#Parser-1843"><span class="linenos">1843</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-1844"><a href="#Parser-1844"><span class="linenos">1844</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">Tuple</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> </span><span id="Parser-1845"><a href="#Parser-1845"><span class="linenos">1845</span></a> -</span><span id="Parser-1846"><a href="#Parser-1846"><span class="linenos">1846</span></a> <span class="k">def</span> <span class="nf">_parse_select</span><span class="p">(</span> -</span><span id="Parser-1847"><a href="#Parser-1847"><span class="linenos">1847</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">nested</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="n">table</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="n">parse_subquery_alias</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Parser-1848"><a href="#Parser-1848"><span class="linenos">1848</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="Parser-1849"><a href="#Parser-1849"><span class="linenos">1849</span></a> <span class="n">cte</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_with</span><span class="p">()</span> -</span><span id="Parser-1850"><a href="#Parser-1850"><span class="linenos">1850</span></a> <span class="k">if</span> <span class="n">cte</span><span class="p">:</span> -</span><span id="Parser-1851"><a href="#Parser-1851"><span class="linenos">1851</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">()</span> -</span><span id="Parser-1852"><a href="#Parser-1852"><span class="linenos">1852</span></a> -</span><span id="Parser-1853"><a href="#Parser-1853"><span class="linenos">1853</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> -</span><span id="Parser-1854"><a href="#Parser-1854"><span class="linenos">1854</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Failed to parse any statement following CTE"</span><span class="p">)</span> -</span><span id="Parser-1855"><a href="#Parser-1855"><span class="linenos">1855</span></a> <span class="k">return</span> <span class="n">cte</span> +</span><span id="Parser-1846"><a href="#Parser-1846"><span class="linenos">1846</span></a> <span class="c1"># In presto we can have VALUES 1, 2 which results in 1 column & 2 rows.</span> +</span><span id="Parser-1847"><a href="#Parser-1847"><span class="linenos">1847</span></a> <span class="c1"># Source: https://prestodb.io/docs/current/sql/values.html</span> +</span><span id="Parser-1848"><a href="#Parser-1848"><span class="linenos">1848</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">Tuple</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()])</span> +</span><span id="Parser-1849"><a href="#Parser-1849"><span class="linenos">1849</span></a> +</span><span id="Parser-1850"><a href="#Parser-1850"><span class="linenos">1850</span></a> <span class="k">def</span> <span class="nf">_parse_select</span><span class="p">(</span> +</span><span id="Parser-1851"><a href="#Parser-1851"><span class="linenos">1851</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">nested</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="n">table</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="n">parse_subquery_alias</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Parser-1852"><a href="#Parser-1852"><span class="linenos">1852</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="Parser-1853"><a href="#Parser-1853"><span class="linenos">1853</span></a> <span class="n">cte</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_with</span><span class="p">()</span> +</span><span id="Parser-1854"><a href="#Parser-1854"><span class="linenos">1854</span></a> <span class="k">if</span> <span class="n">cte</span><span class="p">:</span> +</span><span id="Parser-1855"><a href="#Parser-1855"><span class="linenos">1855</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">()</span> </span><span id="Parser-1856"><a href="#Parser-1856"><span class="linenos">1856</span></a> -</span><span id="Parser-1857"><a href="#Parser-1857"><span class="linenos">1857</span></a> <span class="k">if</span> <span class="s2">"with"</span> <span class="ow">in</span> <span class="n">this</span><span class="o">.</span><span class="n">arg_types</span><span class="p">:</span> -</span><span id="Parser-1858"><a href="#Parser-1858"><span class="linenos">1858</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"with"</span><span class="p">,</span> <span class="n">cte</span><span class="p">)</span> -</span><span id="Parser-1859"><a href="#Parser-1859"><span class="linenos">1859</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1860"><a href="#Parser-1860"><span class="linenos">1860</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2"> does not support CTE"</span><span class="p">)</span> -</span><span id="Parser-1861"><a href="#Parser-1861"><span class="linenos">1861</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">cte</span> -</span><span id="Parser-1862"><a href="#Parser-1862"><span class="linenos">1862</span></a> <span class="k">elif</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">SELECT</span><span class="p">):</span> -</span><span id="Parser-1863"><a href="#Parser-1863"><span class="linenos">1863</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> -</span><span id="Parser-1864"><a href="#Parser-1864"><span class="linenos">1864</span></a> -</span><span id="Parser-1865"><a href="#Parser-1865"><span class="linenos">1865</span></a> <span class="n">hint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_hint</span><span class="p">()</span> -</span><span id="Parser-1866"><a href="#Parser-1866"><span class="linenos">1866</span></a> <span class="n">all_</span> <span class="o">=</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">ALL</span><span class="p">)</span> -</span><span id="Parser-1867"><a href="#Parser-1867"><span class="linenos">1867</span></a> <span class="n">distinct</span> <span class="o">=</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">DISTINCT</span><span class="p">)</span> +</span><span id="Parser-1857"><a href="#Parser-1857"><span class="linenos">1857</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> +</span><span id="Parser-1858"><a href="#Parser-1858"><span class="linenos">1858</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Failed to parse any statement following CTE"</span><span class="p">)</span> +</span><span id="Parser-1859"><a href="#Parser-1859"><span class="linenos">1859</span></a> <span class="k">return</span> <span class="n">cte</span> +</span><span id="Parser-1860"><a href="#Parser-1860"><span class="linenos">1860</span></a> +</span><span id="Parser-1861"><a href="#Parser-1861"><span class="linenos">1861</span></a> <span class="k">if</span> <span class="s2">"with"</span> <span class="ow">in</span> <span class="n">this</span><span class="o">.</span><span class="n">arg_types</span><span class="p">:</span> +</span><span id="Parser-1862"><a href="#Parser-1862"><span class="linenos">1862</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"with"</span><span class="p">,</span> <span class="n">cte</span><span class="p">)</span> +</span><span id="Parser-1863"><a href="#Parser-1863"><span class="linenos">1863</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1864"><a href="#Parser-1864"><span class="linenos">1864</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="o">.</span><span class="n">key</span><span class="si">}</span><span class="s2"> does not support CTE"</span><span class="p">)</span> +</span><span id="Parser-1865"><a href="#Parser-1865"><span class="linenos">1865</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">cte</span> +</span><span id="Parser-1866"><a href="#Parser-1866"><span class="linenos">1866</span></a> <span class="k">elif</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">SELECT</span><span class="p">):</span> +</span><span id="Parser-1867"><a href="#Parser-1867"><span class="linenos">1867</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> </span><span id="Parser-1868"><a href="#Parser-1868"><span class="linenos">1868</span></a> -</span><span id="Parser-1869"><a href="#Parser-1869"><span class="linenos">1869</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Parser-1870"><a href="#Parser-1870"><span class="linenos">1870</span></a> <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">ALIAS</span><span class="p">)</span> -</span><span id="Parser-1871"><a href="#Parser-1871"><span class="linenos">1871</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"STRUCT"</span><span class="p">,</span> <span class="s2">"VALUE"</span><span class="p">))</span> -</span><span id="Parser-1872"><a href="#Parser-1872"><span class="linenos">1872</span></a> <span class="ow">and</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><span id="Parser-1873"><a href="#Parser-1873"><span class="linenos">1873</span></a> <span class="p">)</span> -</span><span id="Parser-1874"><a href="#Parser-1874"><span class="linenos">1874</span></a> -</span><span id="Parser-1875"><a href="#Parser-1875"><span class="linenos">1875</span></a> <span class="k">if</span> <span class="n">distinct</span><span class="p">:</span> -</span><span id="Parser-1876"><a href="#Parser-1876"><span class="linenos">1876</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-1877"><a href="#Parser-1877"><span class="linenos">1877</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Distinct</span><span class="p">,</span> -</span><span id="Parser-1878"><a href="#Parser-1878"><span class="linenos">1878</span></a> <span class="n">on</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">()</span> <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">ON</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Parser-1879"><a href="#Parser-1879"><span class="linenos">1879</span></a> <span class="p">)</span> -</span><span id="Parser-1880"><a href="#Parser-1880"><span class="linenos">1880</span></a> -</span><span id="Parser-1881"><a href="#Parser-1881"><span class="linenos">1881</span></a> <span class="k">if</span> <span class="n">all_</span> <span class="ow">and</span> <span class="n">distinct</span><span class="p">:</span> -</span><span id="Parser-1882"><a href="#Parser-1882"><span class="linenos">1882</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Cannot specify both ALL and DISTINCT after SELECT"</span><span class="p">)</span> -</span><span id="Parser-1883"><a href="#Parser-1883"><span class="linenos">1883</span></a> -</span><span id="Parser-1884"><a href="#Parser-1884"><span class="linenos">1884</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_limit</span><span class="p">(</span><span class="n">top</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-1885"><a href="#Parser-1885"><span class="linenos">1885</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">)</span> -</span><span id="Parser-1886"><a href="#Parser-1886"><span class="linenos">1886</span></a> -</span><span id="Parser-1887"><a href="#Parser-1887"><span class="linenos">1887</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-1888"><a href="#Parser-1888"><span class="linenos">1888</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> -</span><span id="Parser-1889"><a href="#Parser-1889"><span class="linenos">1889</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> -</span><span id="Parser-1890"><a href="#Parser-1890"><span class="linenos">1890</span></a> <span class="n">hint</span><span class="o">=</span><span class="n">hint</span><span class="p">,</span> -</span><span id="Parser-1891"><a href="#Parser-1891"><span class="linenos">1891</span></a> <span class="n">distinct</span><span class="o">=</span><span class="n">distinct</span><span class="p">,</span> -</span><span id="Parser-1892"><a href="#Parser-1892"><span class="linenos">1892</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Parser-1893"><a href="#Parser-1893"><span class="linenos">1893</span></a> <span class="n">limit</span><span class="o">=</span><span class="n">limit</span><span class="p">,</span> -</span><span id="Parser-1894"><a href="#Parser-1894"><span class="linenos">1894</span></a> <span class="p">)</span> -</span><span id="Parser-1895"><a href="#Parser-1895"><span class="linenos">1895</span></a> <span class="n">this</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> -</span><span id="Parser-1896"><a href="#Parser-1896"><span class="linenos">1896</span></a> -</span><span id="Parser-1897"><a href="#Parser-1897"><span class="linenos">1897</span></a> <span class="n">into</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_into</span><span class="p">()</span> -</span><span id="Parser-1898"><a href="#Parser-1898"><span class="linenos">1898</span></a> <span class="k">if</span> <span class="n">into</span><span class="p">:</span> -</span><span id="Parser-1899"><a href="#Parser-1899"><span class="linenos">1899</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"into"</span><span class="p">,</span> <span class="n">into</span><span class="p">)</span> +</span><span id="Parser-1869"><a href="#Parser-1869"><span class="linenos">1869</span></a> <span class="n">hint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_hint</span><span class="p">()</span> +</span><span id="Parser-1870"><a href="#Parser-1870"><span class="linenos">1870</span></a> <span class="n">all_</span> <span class="o">=</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">ALL</span><span class="p">)</span> +</span><span id="Parser-1871"><a href="#Parser-1871"><span class="linenos">1871</span></a> <span class="n">distinct</span> <span class="o">=</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">DISTINCT</span><span class="p">)</span> +</span><span id="Parser-1872"><a href="#Parser-1872"><span class="linenos">1872</span></a> +</span><span id="Parser-1873"><a href="#Parser-1873"><span class="linenos">1873</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Parser-1874"><a href="#Parser-1874"><span class="linenos">1874</span></a> <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">ALIAS</span><span class="p">)</span> +</span><span id="Parser-1875"><a href="#Parser-1875"><span class="linenos">1875</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"STRUCT"</span><span class="p">,</span> <span class="s2">"VALUE"</span><span class="p">))</span> +</span><span id="Parser-1876"><a href="#Parser-1876"><span class="linenos">1876</span></a> <span class="ow">and</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><span id="Parser-1877"><a href="#Parser-1877"><span class="linenos">1877</span></a> <span class="p">)</span> +</span><span id="Parser-1878"><a href="#Parser-1878"><span class="linenos">1878</span></a> +</span><span id="Parser-1879"><a href="#Parser-1879"><span class="linenos">1879</span></a> <span class="k">if</span> <span class="n">distinct</span><span class="p">:</span> +</span><span id="Parser-1880"><a href="#Parser-1880"><span class="linenos">1880</span></a> <span class="n">distinct</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-1881"><a href="#Parser-1881"><span class="linenos">1881</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Distinct</span><span class="p">,</span> +</span><span id="Parser-1882"><a href="#Parser-1882"><span class="linenos">1882</span></a> <span class="n">on</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">()</span> <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">ON</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Parser-1883"><a href="#Parser-1883"><span class="linenos">1883</span></a> <span class="p">)</span> +</span><span id="Parser-1884"><a href="#Parser-1884"><span class="linenos">1884</span></a> +</span><span id="Parser-1885"><a href="#Parser-1885"><span class="linenos">1885</span></a> <span class="k">if</span> <span class="n">all_</span> <span class="ow">and</span> <span class="n">distinct</span><span class="p">:</span> +</span><span id="Parser-1886"><a href="#Parser-1886"><span class="linenos">1886</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Cannot specify both ALL and DISTINCT after SELECT"</span><span class="p">)</span> +</span><span id="Parser-1887"><a href="#Parser-1887"><span class="linenos">1887</span></a> +</span><span id="Parser-1888"><a href="#Parser-1888"><span class="linenos">1888</span></a> <span class="n">limit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_limit</span><span class="p">(</span><span class="n">top</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-1889"><a href="#Parser-1889"><span class="linenos">1889</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">)</span> +</span><span id="Parser-1890"><a href="#Parser-1890"><span class="linenos">1890</span></a> +</span><span id="Parser-1891"><a href="#Parser-1891"><span class="linenos">1891</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-1892"><a href="#Parser-1892"><span class="linenos">1892</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">,</span> +</span><span id="Parser-1893"><a href="#Parser-1893"><span class="linenos">1893</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> +</span><span id="Parser-1894"><a href="#Parser-1894"><span class="linenos">1894</span></a> <span class="n">hint</span><span class="o">=</span><span class="n">hint</span><span class="p">,</span> +</span><span id="Parser-1895"><a href="#Parser-1895"><span class="linenos">1895</span></a> <span class="n">distinct</span><span class="o">=</span><span class="n">distinct</span><span class="p">,</span> +</span><span id="Parser-1896"><a href="#Parser-1896"><span class="linenos">1896</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Parser-1897"><a href="#Parser-1897"><span class="linenos">1897</span></a> <span class="n">limit</span><span class="o">=</span><span class="n">limit</span><span class="p">,</span> +</span><span id="Parser-1898"><a href="#Parser-1898"><span class="linenos">1898</span></a> <span class="p">)</span> +</span><span id="Parser-1899"><a href="#Parser-1899"><span class="linenos">1899</span></a> <span class="n">this</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> </span><span id="Parser-1900"><a href="#Parser-1900"><span class="linenos">1900</span></a> -</span><span id="Parser-1901"><a href="#Parser-1901"><span class="linenos">1901</span></a> <span class="n">from_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_from</span><span class="p">()</span> -</span><span id="Parser-1902"><a href="#Parser-1902"><span class="linenos">1902</span></a> <span class="k">if</span> <span class="n">from_</span><span class="p">:</span> -</span><span id="Parser-1903"><a href="#Parser-1903"><span class="linenos">1903</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"from"</span><span class="p">,</span> <span class="n">from_</span><span class="p">)</span> +</span><span id="Parser-1901"><a href="#Parser-1901"><span class="linenos">1901</span></a> <span class="n">into</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_into</span><span class="p">()</span> +</span><span id="Parser-1902"><a href="#Parser-1902"><span class="linenos">1902</span></a> <span class="k">if</span> <span class="n">into</span><span class="p">:</span> +</span><span id="Parser-1903"><a href="#Parser-1903"><span class="linenos">1903</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"into"</span><span class="p">,</span> <span class="n">into</span><span class="p">)</span> </span><span id="Parser-1904"><a href="#Parser-1904"><span class="linenos">1904</span></a> -</span><span id="Parser-1905"><a href="#Parser-1905"><span class="linenos">1905</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-1906"><a href="#Parser-1906"><span class="linenos">1906</span></a> <span class="k">elif</span> <span class="p">(</span><span class="n">table</span> <span class="ow">or</span> <span class="n">nested</span><span class="p">)</span> <span class="ow">and</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_PAREN</span><span class="p">):</span> -</span><span id="Parser-1907"><a href="#Parser-1907"><span class="linenos">1907</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">PIVOT</span><span class="p">):</span> -</span><span id="Parser-1908"><a href="#Parser-1908"><span class="linenos">1908</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_simplified_pivot</span><span class="p">()</span> -</span><span id="Parser-1909"><a href="#Parser-1909"><span class="linenos">1909</span></a> <span class="k">elif</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">FROM</span><span class="p">):</span> -</span><span id="Parser-1910"><a href="#Parser-1910"><span class="linenos">1910</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="s2">"*"</span><span class="p">)</span><span class="o">.</span><span class="n">from_</span><span class="p">(</span> -</span><span id="Parser-1911"><a href="#Parser-1911"><span class="linenos">1911</span></a> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_from</span><span class="p">(</span><span class="n">skip_from_token</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> -</span><span id="Parser-1912"><a href="#Parser-1912"><span class="linenos">1912</span></a> <span class="p">)</span> -</span><span id="Parser-1913"><a href="#Parser-1913"><span class="linenos">1913</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1914"><a href="#Parser-1914"><span class="linenos">1914</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> <span class="k">if</span> <span class="n">table</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-1915"><a href="#Parser-1915"><span class="linenos">1915</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">this</span><span class="p">))</span> -</span><span id="Parser-1916"><a href="#Parser-1916"><span class="linenos">1916</span></a> -</span><span id="Parser-1917"><a href="#Parser-1917"><span class="linenos">1917</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="Parser-1918"><a href="#Parser-1918"><span class="linenos">1918</span></a> -</span><span id="Parser-1919"><a href="#Parser-1919"><span class="linenos">1919</span></a> <span class="c1"># early return so that subquery unions aren't parsed again</span> -</span><span id="Parser-1920"><a href="#Parser-1920"><span class="linenos">1920</span></a> <span class="c1"># SELECT * FROM (SELECT 1) UNION ALL SELECT 1</span> -</span><span id="Parser-1921"><a href="#Parser-1921"><span class="linenos">1921</span></a> <span class="c1"># Union ALL should be a property of the top select node, not the subquery</span> -</span><span id="Parser-1922"><a href="#Parser-1922"><span class="linenos">1922</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_subquery</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">parse_alias</span><span class="o">=</span><span class="n">parse_subquery_alias</span><span class="p">)</span> -</span><span id="Parser-1923"><a href="#Parser-1923"><span class="linenos">1923</span></a> <span class="k">elif</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">VALUES</span><span class="p">):</span> -</span><span id="Parser-1924"><a href="#Parser-1924"><span class="linenos">1924</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-1925"><a href="#Parser-1925"><span class="linenos">1925</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">,</span> -</span><span id="Parser-1926"><a href="#Parser-1926"><span class="linenos">1926</span></a> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">),</span> -</span><span id="Parser-1927"><a href="#Parser-1927"><span class="linenos">1927</span></a> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">(),</span> -</span><span id="Parser-1928"><a href="#Parser-1928"><span class="linenos">1928</span></a> <span class="p">)</span> -</span><span id="Parser-1929"><a href="#Parser-1929"><span class="linenos">1929</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1930"><a href="#Parser-1930"><span class="linenos">1930</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1931"><a href="#Parser-1931"><span class="linenos">1931</span></a> -</span><span id="Parser-1932"><a href="#Parser-1932"><span class="linenos">1932</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-1933"><a href="#Parser-1933"><span class="linenos">1933</span></a> -</span><span id="Parser-1934"><a href="#Parser-1934"><span class="linenos">1934</span></a> <span class="k">def</span> <span class="nf">_parse_with</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_with_token</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">With</span><span class="p">]:</span> -</span><span id="Parser-1935"><a href="#Parser-1935"><span class="linenos">1935</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_with_token</span> <span class="ow">and</span> <span class="ow">not</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">WITH</span><span class="p">):</span> -</span><span id="Parser-1936"><a href="#Parser-1936"><span class="linenos">1936</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1905"><a href="#Parser-1905"><span class="linenos">1905</span></a> <span class="n">from_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_from</span><span class="p">()</span> +</span><span id="Parser-1906"><a href="#Parser-1906"><span class="linenos">1906</span></a> <span class="k">if</span> <span class="n">from_</span><span class="p">:</span> +</span><span id="Parser-1907"><a href="#Parser-1907"><span class="linenos">1907</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"from"</span><span class="p">,</span> <span class="n">from_</span><span class="p">)</span> +</span><span id="Parser-1908"><a href="#Parser-1908"><span class="linenos">1908</span></a> +</span><span id="Parser-1909"><a href="#Parser-1909"><span class="linenos">1909</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-1910"><a href="#Parser-1910"><span class="linenos">1910</span></a> <span class="k">elif</span> <span class="p">(</span><span class="n">table</span> <span class="ow">or</span> <span class="n">nested</span><span class="p">)</span> <span class="ow">and</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_PAREN</span><span class="p">):</span> +</span><span id="Parser-1911"><a href="#Parser-1911"><span class="linenos">1911</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">PIVOT</span><span class="p">):</span> +</span><span id="Parser-1912"><a href="#Parser-1912"><span class="linenos">1912</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_simplified_pivot</span><span class="p">()</span> +</span><span id="Parser-1913"><a href="#Parser-1913"><span class="linenos">1913</span></a> <span class="k">elif</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">FROM</span><span class="p">):</span> +</span><span id="Parser-1914"><a href="#Parser-1914"><span class="linenos">1914</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="s2">"*"</span><span class="p">)</span><span class="o">.</span><span class="n">from_</span><span class="p">(</span> +</span><span id="Parser-1915"><a href="#Parser-1915"><span class="linenos">1915</span></a> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_from</span><span class="p">(</span><span class="n">skip_from_token</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="Parser-1916"><a href="#Parser-1916"><span class="linenos">1916</span></a> <span class="p">)</span> +</span><span id="Parser-1917"><a href="#Parser-1917"><span class="linenos">1917</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1918"><a href="#Parser-1918"><span class="linenos">1918</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> <span class="k">if</span> <span class="n">table</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-1919"><a href="#Parser-1919"><span class="linenos">1919</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">this</span><span class="p">))</span> +</span><span id="Parser-1920"><a href="#Parser-1920"><span class="linenos">1920</span></a> +</span><span id="Parser-1921"><a href="#Parser-1921"><span class="linenos">1921</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-1922"><a href="#Parser-1922"><span class="linenos">1922</span></a> +</span><span id="Parser-1923"><a href="#Parser-1923"><span class="linenos">1923</span></a> <span class="c1"># early return so that subquery unions aren't parsed again</span> +</span><span id="Parser-1924"><a href="#Parser-1924"><span class="linenos">1924</span></a> <span class="c1"># SELECT * FROM (SELECT 1) UNION ALL SELECT 1</span> +</span><span id="Parser-1925"><a href="#Parser-1925"><span class="linenos">1925</span></a> <span class="c1"># Union ALL should be a property of the top select node, not the subquery</span> +</span><span id="Parser-1926"><a href="#Parser-1926"><span class="linenos">1926</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_subquery</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">parse_alias</span><span class="o">=</span><span class="n">parse_subquery_alias</span><span class="p">)</span> +</span><span id="Parser-1927"><a href="#Parser-1927"><span class="linenos">1927</span></a> <span class="k">elif</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">VALUES</span><span class="p">):</span> +</span><span id="Parser-1928"><a href="#Parser-1928"><span class="linenos">1928</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-1929"><a href="#Parser-1929"><span class="linenos">1929</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">,</span> +</span><span id="Parser-1930"><a href="#Parser-1930"><span class="linenos">1930</span></a> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">),</span> +</span><span id="Parser-1931"><a href="#Parser-1931"><span class="linenos">1931</span></a> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">(),</span> +</span><span id="Parser-1932"><a href="#Parser-1932"><span class="linenos">1932</span></a> <span class="p">)</span> +</span><span id="Parser-1933"><a href="#Parser-1933"><span class="linenos">1933</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1934"><a href="#Parser-1934"><span class="linenos">1934</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1935"><a href="#Parser-1935"><span class="linenos">1935</span></a> +</span><span id="Parser-1936"><a href="#Parser-1936"><span class="linenos">1936</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> </span><span id="Parser-1937"><a href="#Parser-1937"><span class="linenos">1937</span></a> -</span><span id="Parser-1938"><a href="#Parser-1938"><span class="linenos">1938</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> -</span><span id="Parser-1939"><a href="#Parser-1939"><span class="linenos">1939</span></a> <span class="n">recursive</span> <span class="o">=</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">RECURSIVE</span><span class="p">)</span> -</span><span id="Parser-1940"><a href="#Parser-1940"><span class="linenos">1940</span></a> -</span><span id="Parser-1941"><a href="#Parser-1941"><span class="linenos">1941</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-1942"><a href="#Parser-1942"><span class="linenos">1942</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Parser-1943"><a href="#Parser-1943"><span class="linenos">1943</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_cte</span><span class="p">())</span> +</span><span id="Parser-1938"><a href="#Parser-1938"><span class="linenos">1938</span></a> <span class="k">def</span> <span class="nf">_parse_with</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_with_token</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">With</span><span class="p">]:</span> +</span><span id="Parser-1939"><a href="#Parser-1939"><span class="linenos">1939</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_with_token</span> <span class="ow">and</span> <span class="ow">not</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">WITH</span><span class="p">):</span> +</span><span id="Parser-1940"><a href="#Parser-1940"><span class="linenos">1940</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1941"><a href="#Parser-1941"><span class="linenos">1941</span></a> +</span><span id="Parser-1942"><a href="#Parser-1942"><span class="linenos">1942</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> +</span><span id="Parser-1943"><a href="#Parser-1943"><span class="linenos">1943</span></a> <span class="n">recursive</span> <span class="o">=</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">RECURSIVE</span><span class="p">)</span> </span><span id="Parser-1944"><a href="#Parser-1944"><span class="linenos">1944</span></a> -</span><span id="Parser-1945"><a href="#Parser-1945"><span class="linenos">1945</span></a> <span class="k">if</span> <span class="ow">not</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">COMMA</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">):</span> -</span><span id="Parser-1946"><a href="#Parser-1946"><span class="linenos">1946</span></a> <span class="k">break</span> -</span><span id="Parser-1947"><a href="#Parser-1947"><span class="linenos">1947</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1948"><a href="#Parser-1948"><span class="linenos">1948</span></a> <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">WITH</span><span class="p">)</span> -</span><span id="Parser-1949"><a href="#Parser-1949"><span class="linenos">1949</span></a> -</span><span id="Parser-1950"><a href="#Parser-1950"><span class="linenos">1950</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><span id="Parser-1951"><a href="#Parser-1951"><span class="linenos">1951</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="n">comments</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">recursive</span><span class="o">=</span><span class="n">recursive</span> -</span><span id="Parser-1952"><a href="#Parser-1952"><span class="linenos">1952</span></a> <span class="p">)</span> +</span><span id="Parser-1945"><a href="#Parser-1945"><span class="linenos">1945</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-1946"><a href="#Parser-1946"><span class="linenos">1946</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Parser-1947"><a href="#Parser-1947"><span class="linenos">1947</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_cte</span><span class="p">())</span> +</span><span id="Parser-1948"><a href="#Parser-1948"><span class="linenos">1948</span></a> +</span><span id="Parser-1949"><a href="#Parser-1949"><span class="linenos">1949</span></a> <span class="k">if</span> <span class="ow">not</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">COMMA</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">):</span> +</span><span id="Parser-1950"><a href="#Parser-1950"><span class="linenos">1950</span></a> <span class="k">break</span> +</span><span id="Parser-1951"><a href="#Parser-1951"><span class="linenos">1951</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1952"><a href="#Parser-1952"><span class="linenos">1952</span></a> <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">WITH</span><span class="p">)</span> </span><span id="Parser-1953"><a href="#Parser-1953"><span class="linenos">1953</span></a> -</span><span id="Parser-1954"><a href="#Parser-1954"><span class="linenos">1954</span></a> <span class="k">def</span> <span class="nf">_parse_cte</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">CTE</span><span class="p">:</span> -</span><span id="Parser-1955"><a href="#Parser-1955"><span class="linenos">1955</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> -</span><span id="Parser-1956"><a href="#Parser-1956"><span class="linenos">1956</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">alias</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">alias</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> -</span><span id="Parser-1957"><a href="#Parser-1957"><span class="linenos">1957</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected CTE to have alias"</span><span class="p">)</span> -</span><span id="Parser-1958"><a href="#Parser-1958"><span class="linenos">1958</span></a> -</span><span id="Parser-1959"><a href="#Parser-1959"><span class="linenos">1959</span></a> <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">ALIAS</span><span class="p">)</span> -</span><span id="Parser-1960"><a href="#Parser-1960"><span class="linenos">1960</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><span id="Parser-1961"><a href="#Parser-1961"><span class="linenos">1961</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</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_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">),</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span> -</span><span id="Parser-1962"><a href="#Parser-1962"><span class="linenos">1962</span></a> <span class="p">)</span> -</span><span id="Parser-1963"><a href="#Parser-1963"><span class="linenos">1963</span></a> -</span><span id="Parser-1964"><a href="#Parser-1964"><span class="linenos">1964</span></a> <span class="k">def</span> <span class="nf">_parse_table_alias</span><span class="p">(</span> -</span><span id="Parser-1965"><a href="#Parser-1965"><span class="linenos">1965</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">alias_tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1966"><a href="#Parser-1966"><span class="linenos">1966</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">TableAlias</span><span class="p">]:</span> -</span><span id="Parser-1967"><a href="#Parser-1967"><span class="linenos">1967</span></a> <span class="n">any_token</span> <span class="o">=</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">ALIAS</span><span class="p">)</span> -</span><span id="Parser-1968"><a href="#Parser-1968"><span class="linenos">1968</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Parser-1969"><a href="#Parser-1969"><span class="linenos">1969</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="n">any_token</span><span class="p">,</span> <span class="n">tokens</span><span class="o">=</span><span class="n">alias_tokens</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_ALIAS_TOKENS</span><span class="p">)</span> -</span><span id="Parser-1970"><a href="#Parser-1970"><span class="linenos">1970</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string_as_identifier</span><span class="p">()</span> -</span><span id="Parser-1971"><a href="#Parser-1971"><span class="linenos">1971</span></a> <span class="p">)</span> -</span><span id="Parser-1972"><a href="#Parser-1972"><span class="linenos">1972</span></a> -</span><span id="Parser-1973"><a href="#Parser-1973"><span class="linenos">1973</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="Parser-1974"><a href="#Parser-1974"><span class="linenos">1974</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_PAREN</span><span class="p">):</span> -</span><span id="Parser-1975"><a href="#Parser-1975"><span class="linenos">1975</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function_parameter</span><span class="p">)</span> -</span><span id="Parser-1976"><a href="#Parser-1976"><span class="linenos">1976</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-1977"><a href="#Parser-1977"><span class="linenos">1977</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-1978"><a href="#Parser-1978"><span class="linenos">1978</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-1979"><a href="#Parser-1979"><span class="linenos">1979</span></a> -</span><span id="Parser-1980"><a href="#Parser-1980"><span class="linenos">1980</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">alias</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">columns</span><span class="p">:</span> -</span><span id="Parser-1981"><a href="#Parser-1981"><span class="linenos">1981</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-1982"><a href="#Parser-1982"><span class="linenos">1982</span></a> -</span><span id="Parser-1983"><a href="#Parser-1983"><span class="linenos">1983</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">TableAlias</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">alias</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="n">columns</span><span class="p">)</span> -</span><span id="Parser-1984"><a href="#Parser-1984"><span class="linenos">1984</span></a> -</span><span id="Parser-1985"><a href="#Parser-1985"><span class="linenos">1985</span></a> <span class="k">def</span> <span class="nf">_parse_subquery</span><span class="p">(</span> -</span><span id="Parser-1986"><a href="#Parser-1986"><span class="linenos">1986</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="n">parse_alias</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Parser-1987"><a href="#Parser-1987"><span class="linenos">1987</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">Subquery</span><span class="p">]:</span> -</span><span id="Parser-1988"><a href="#Parser-1988"><span class="linenos">1988</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> -</span><span id="Parser-1989"><a href="#Parser-1989"><span class="linenos">1989</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-1990"><a href="#Parser-1990"><span class="linenos">1990</span></a> -</span><span id="Parser-1991"><a href="#Parser-1991"><span class="linenos">1991</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><span id="Parser-1992"><a href="#Parser-1992"><span class="linenos">1992</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">,</span> -</span><span id="Parser-1993"><a href="#Parser-1993"><span class="linenos">1993</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="Parser-1994"><a href="#Parser-1994"><span class="linenos">1994</span></a> <span class="n">pivots</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivots</span><span class="p">(),</span> -</span><span id="Parser-1995"><a href="#Parser-1995"><span class="linenos">1995</span></a> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> <span class="k">if</span> <span class="n">parse_alias</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Parser-1996"><a href="#Parser-1996"><span class="linenos">1996</span></a> <span class="p">)</span> -</span><span id="Parser-1997"><a href="#Parser-1997"><span class="linenos">1997</span></a> -</span><span id="Parser-1998"><a href="#Parser-1998"><span class="linenos">1998</span></a> <span class="k">def</span> <span class="nf">_parse_query_modifiers</span><span class="p">(</span> -</span><span id="Parser-1999"><a href="#Parser-1999"><span class="linenos">1999</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><span id="Parser-2000"><a href="#Parser-2000"><span class="linenos">2000</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="Parser-2001"><a href="#Parser-2001"><span class="linenos">2001</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="bp">self</span><span class="o">.</span><span class="n">MODIFIABLES</span><span class="p">):</span> -</span><span id="Parser-2002"><a href="#Parser-2002"><span class="linenos">2002</span></a> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">parser</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">QUERY_MODIFIER_PARSERS</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> -</span><span id="Parser-2003"><a href="#Parser-2003"><span class="linenos">2003</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> -</span><span id="Parser-2004"><a href="#Parser-2004"><span class="linenos">2004</span></a> -</span><span id="Parser-2005"><a href="#Parser-2005"><span class="linenos">2005</span></a> <span class="k">if</span> <span class="n">expression</span><span class="p">:</span> -</span><span id="Parser-2006"><a href="#Parser-2006"><span class="linenos">2006</span></a> <span class="k">if</span> <span class="n">key</span> <span class="o">==</span> <span class="s2">"limit"</span><span class="p">:</span> -</span><span id="Parser-2007"><a href="#Parser-2007"><span class="linenos">2007</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="Parser-2008"><a href="#Parser-2008"><span class="linenos">2008</span></a> <span class="k">if</span> <span class="n">offset</span><span class="p">:</span> -</span><span id="Parser-2009"><a href="#Parser-2009"><span class="linenos">2009</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Offset</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">offset</span><span class="p">))</span> -</span><span id="Parser-2010"><a href="#Parser-2010"><span class="linenos">2010</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="Parser-2011"><a href="#Parser-2011"><span class="linenos">2011</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-2012"><a href="#Parser-2012"><span class="linenos">2012</span></a> -</span><span id="Parser-2013"><a href="#Parser-2013"><span class="linenos">2013</span></a> <span class="k">def</span> <span class="nf">_parse_hint</span><span class="p">(</span><span class="bp">self</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">Hint</span><span class="p">]:</span> -</span><span id="Parser-2014"><a href="#Parser-2014"><span class="linenos">2014</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">HINT</span><span class="p">):</span> -</span><span id="Parser-2015"><a href="#Parser-2015"><span class="linenos">2015</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">)</span> +</span><span id="Parser-1954"><a href="#Parser-1954"><span class="linenos">1954</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><span id="Parser-1955"><a href="#Parser-1955"><span class="linenos">1955</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">With</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="n">comments</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">recursive</span><span class="o">=</span><span class="n">recursive</span> +</span><span id="Parser-1956"><a href="#Parser-1956"><span class="linenos">1956</span></a> <span class="p">)</span> +</span><span id="Parser-1957"><a href="#Parser-1957"><span class="linenos">1957</span></a> +</span><span id="Parser-1958"><a href="#Parser-1958"><span class="linenos">1958</span></a> <span class="k">def</span> <span class="nf">_parse_cte</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">CTE</span><span class="p">:</span> +</span><span id="Parser-1959"><a href="#Parser-1959"><span class="linenos">1959</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> +</span><span id="Parser-1960"><a href="#Parser-1960"><span class="linenos">1960</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">alias</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">alias</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> +</span><span id="Parser-1961"><a href="#Parser-1961"><span class="linenos">1961</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected CTE to have alias"</span><span class="p">)</span> +</span><span id="Parser-1962"><a href="#Parser-1962"><span class="linenos">1962</span></a> +</span><span id="Parser-1963"><a href="#Parser-1963"><span class="linenos">1963</span></a> <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">ALIAS</span><span class="p">)</span> +</span><span id="Parser-1964"><a href="#Parser-1964"><span class="linenos">1964</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><span id="Parser-1965"><a href="#Parser-1965"><span class="linenos">1965</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CTE</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_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">),</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span> +</span><span id="Parser-1966"><a href="#Parser-1966"><span class="linenos">1966</span></a> <span class="p">)</span> +</span><span id="Parser-1967"><a href="#Parser-1967"><span class="linenos">1967</span></a> +</span><span id="Parser-1968"><a href="#Parser-1968"><span class="linenos">1968</span></a> <span class="k">def</span> <span class="nf">_parse_table_alias</span><span class="p">(</span> +</span><span id="Parser-1969"><a href="#Parser-1969"><span class="linenos">1969</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">alias_tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1970"><a href="#Parser-1970"><span class="linenos">1970</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">TableAlias</span><span class="p">]:</span> +</span><span id="Parser-1971"><a href="#Parser-1971"><span class="linenos">1971</span></a> <span class="n">any_token</span> <span class="o">=</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">ALIAS</span><span class="p">)</span> +</span><span id="Parser-1972"><a href="#Parser-1972"><span class="linenos">1972</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Parser-1973"><a href="#Parser-1973"><span class="linenos">1973</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="n">any_token</span><span class="p">,</span> <span class="n">tokens</span><span class="o">=</span><span class="n">alias_tokens</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_ALIAS_TOKENS</span><span class="p">)</span> +</span><span id="Parser-1974"><a href="#Parser-1974"><span class="linenos">1974</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string_as_identifier</span><span class="p">()</span> +</span><span id="Parser-1975"><a href="#Parser-1975"><span class="linenos">1975</span></a> <span class="p">)</span> +</span><span id="Parser-1976"><a href="#Parser-1976"><span class="linenos">1976</span></a> +</span><span id="Parser-1977"><a href="#Parser-1977"><span class="linenos">1977</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="Parser-1978"><a href="#Parser-1978"><span class="linenos">1978</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_PAREN</span><span class="p">):</span> +</span><span id="Parser-1979"><a href="#Parser-1979"><span class="linenos">1979</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function_parameter</span><span class="p">)</span> +</span><span id="Parser-1980"><a href="#Parser-1980"><span class="linenos">1980</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> <span class="k">if</span> <span class="n">columns</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-1981"><a href="#Parser-1981"><span class="linenos">1981</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-1982"><a href="#Parser-1982"><span class="linenos">1982</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-1983"><a href="#Parser-1983"><span class="linenos">1983</span></a> +</span><span id="Parser-1984"><a href="#Parser-1984"><span class="linenos">1984</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">alias</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">columns</span><span class="p">:</span> +</span><span id="Parser-1985"><a href="#Parser-1985"><span class="linenos">1985</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1986"><a href="#Parser-1986"><span class="linenos">1986</span></a> +</span><span id="Parser-1987"><a href="#Parser-1987"><span class="linenos">1987</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">TableAlias</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">alias</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="n">columns</span><span class="p">)</span> +</span><span id="Parser-1988"><a href="#Parser-1988"><span class="linenos">1988</span></a> +</span><span id="Parser-1989"><a href="#Parser-1989"><span class="linenos">1989</span></a> <span class="k">def</span> <span class="nf">_parse_subquery</span><span class="p">(</span> +</span><span id="Parser-1990"><a href="#Parser-1990"><span class="linenos">1990</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="n">parse_alias</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Parser-1991"><a href="#Parser-1991"><span class="linenos">1991</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">Subquery</span><span class="p">]:</span> +</span><span id="Parser-1992"><a href="#Parser-1992"><span class="linenos">1992</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> +</span><span id="Parser-1993"><a href="#Parser-1993"><span class="linenos">1993</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-1994"><a href="#Parser-1994"><span class="linenos">1994</span></a> +</span><span id="Parser-1995"><a href="#Parser-1995"><span class="linenos">1995</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><span id="Parser-1996"><a href="#Parser-1996"><span class="linenos">1996</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">,</span> +</span><span id="Parser-1997"><a href="#Parser-1997"><span class="linenos">1997</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="Parser-1998"><a href="#Parser-1998"><span class="linenos">1998</span></a> <span class="n">pivots</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivots</span><span class="p">(),</span> +</span><span id="Parser-1999"><a href="#Parser-1999"><span class="linenos">1999</span></a> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> <span class="k">if</span> <span class="n">parse_alias</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Parser-2000"><a href="#Parser-2000"><span class="linenos">2000</span></a> <span class="p">)</span> +</span><span id="Parser-2001"><a href="#Parser-2001"><span class="linenos">2001</span></a> +</span><span id="Parser-2002"><a href="#Parser-2002"><span class="linenos">2002</span></a> <span class="k">def</span> <span class="nf">_parse_query_modifiers</span><span class="p">(</span> +</span><span id="Parser-2003"><a href="#Parser-2003"><span class="linenos">2003</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><span id="Parser-2004"><a href="#Parser-2004"><span class="linenos">2004</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="Parser-2005"><a href="#Parser-2005"><span class="linenos">2005</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="bp">self</span><span class="o">.</span><span class="n">MODIFIABLES</span><span class="p">):</span> +</span><span id="Parser-2006"><a href="#Parser-2006"><span class="linenos">2006</span></a> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">parser</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">QUERY_MODIFIER_PARSERS</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> +</span><span id="Parser-2007"><a href="#Parser-2007"><span class="linenos">2007</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> +</span><span id="Parser-2008"><a href="#Parser-2008"><span class="linenos">2008</span></a> +</span><span id="Parser-2009"><a href="#Parser-2009"><span class="linenos">2009</span></a> <span class="k">if</span> <span class="n">expression</span><span class="p">:</span> +</span><span id="Parser-2010"><a href="#Parser-2010"><span class="linenos">2010</span></a> <span class="k">if</span> <span class="n">key</span> <span class="o">==</span> <span class="s2">"limit"</span><span class="p">:</span> +</span><span id="Parser-2011"><a href="#Parser-2011"><span class="linenos">2011</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="Parser-2012"><a href="#Parser-2012"><span class="linenos">2012</span></a> <span class="k">if</span> <span class="n">offset</span><span class="p">:</span> +</span><span id="Parser-2013"><a href="#Parser-2013"><span class="linenos">2013</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Offset</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">offset</span><span class="p">))</span> +</span><span id="Parser-2014"><a href="#Parser-2014"><span class="linenos">2014</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Parser-2015"><a href="#Parser-2015"><span class="linenos">2015</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="Parser-2016"><a href="#Parser-2016"><span class="linenos">2016</span></a> -</span><span id="Parser-2017"><a href="#Parser-2017"><span class="linenos">2017</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STAR</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SLASH</span><span class="p">):</span> -</span><span id="Parser-2018"><a href="#Parser-2018"><span class="linenos">2018</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected */ after HINT"</span><span class="p">)</span> -</span><span id="Parser-2019"><a href="#Parser-2019"><span class="linenos">2019</span></a> -</span><span id="Parser-2020"><a href="#Parser-2020"><span class="linenos">2020</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">Hint</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">hints</span><span class="p">)</span> -</span><span id="Parser-2021"><a href="#Parser-2021"><span class="linenos">2021</span></a> -</span><span id="Parser-2022"><a href="#Parser-2022"><span class="linenos">2022</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2017"><a href="#Parser-2017"><span class="linenos">2017</span></a> <span class="k">def</span> <span class="nf">_parse_hint</span><span class="p">(</span><span class="bp">self</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">Hint</span><span class="p">]:</span> +</span><span id="Parser-2018"><a href="#Parser-2018"><span class="linenos">2018</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">HINT</span><span class="p">):</span> +</span><span id="Parser-2019"><a href="#Parser-2019"><span class="linenos">2019</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">)</span> +</span><span id="Parser-2020"><a href="#Parser-2020"><span class="linenos">2020</span></a> +</span><span id="Parser-2021"><a href="#Parser-2021"><span class="linenos">2021</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STAR</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SLASH</span><span class="p">):</span> +</span><span id="Parser-2022"><a href="#Parser-2022"><span class="linenos">2022</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected */ after HINT"</span><span class="p">)</span> </span><span id="Parser-2023"><a href="#Parser-2023"><span class="linenos">2023</span></a> -</span><span id="Parser-2024"><a href="#Parser-2024"><span class="linenos">2024</span></a> <span class="k">def</span> <span class="nf">_parse_into</span><span class="p">(</span><span class="bp">self</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">Into</span><span class="p">]:</span> -</span><span id="Parser-2025"><a href="#Parser-2025"><span class="linenos">2025</span></a> <span class="k">if</span> <span class="ow">not</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">INTO</span><span class="p">):</span> -</span><span id="Parser-2026"><a href="#Parser-2026"><span class="linenos">2026</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2024"><a href="#Parser-2024"><span class="linenos">2024</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">Hint</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">hints</span><span class="p">)</span> +</span><span id="Parser-2025"><a href="#Parser-2025"><span class="linenos">2025</span></a> +</span><span id="Parser-2026"><a href="#Parser-2026"><span class="linenos">2026</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="Parser-2027"><a href="#Parser-2027"><span class="linenos">2027</span></a> -</span><span id="Parser-2028"><a href="#Parser-2028"><span class="linenos">2028</span></a> <span class="n">temp</span> <span class="o">=</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">TEMPORARY</span><span class="p">)</span> -</span><span id="Parser-2029"><a href="#Parser-2029"><span class="linenos">2029</span></a> <span class="n">unlogged</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"UNLOGGED"</span><span class="p">)</span> -</span><span id="Parser-2030"><a href="#Parser-2030"><span class="linenos">2030</span></a> <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">TABLE</span><span class="p">)</span> +</span><span id="Parser-2028"><a href="#Parser-2028"><span class="linenos">2028</span></a> <span class="k">def</span> <span class="nf">_parse_into</span><span class="p">(</span><span class="bp">self</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">Into</span><span class="p">]:</span> +</span><span id="Parser-2029"><a href="#Parser-2029"><span class="linenos">2029</span></a> <span class="k">if</span> <span class="ow">not</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">INTO</span><span class="p">):</span> +</span><span id="Parser-2030"><a href="#Parser-2030"><span class="linenos">2030</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="Parser-2031"><a href="#Parser-2031"><span class="linenos">2031</span></a> -</span><span id="Parser-2032"><a href="#Parser-2032"><span class="linenos">2032</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><span id="Parser-2033"><a href="#Parser-2033"><span class="linenos">2033</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Into</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_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> <span class="n">temporary</span><span class="o">=</span><span class="n">temp</span><span class="p">,</span> <span class="n">unlogged</span><span class="o">=</span><span class="n">unlogged</span> -</span><span id="Parser-2034"><a href="#Parser-2034"><span class="linenos">2034</span></a> <span class="p">)</span> +</span><span id="Parser-2032"><a href="#Parser-2032"><span class="linenos">2032</span></a> <span class="n">temp</span> <span class="o">=</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">TEMPORARY</span><span class="p">)</span> +</span><span id="Parser-2033"><a href="#Parser-2033"><span class="linenos">2033</span></a> <span class="n">unlogged</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"UNLOGGED"</span><span class="p">)</span> +</span><span id="Parser-2034"><a href="#Parser-2034"><span class="linenos">2034</span></a> <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">TABLE</span><span class="p">)</span> </span><span id="Parser-2035"><a href="#Parser-2035"><span class="linenos">2035</span></a> -</span><span id="Parser-2036"><a href="#Parser-2036"><span class="linenos">2036</span></a> <span class="k">def</span> <span class="nf">_parse_from</span><span class="p">(</span> -</span><span id="Parser-2037"><a href="#Parser-2037"><span class="linenos">2037</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">modifiers</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="n">skip_from_token</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-2038"><a href="#Parser-2038"><span class="linenos">2038</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">From</span><span class="p">]:</span> -</span><span id="Parser-2039"><a href="#Parser-2039"><span class="linenos">2039</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_from_token</span> <span class="ow">and</span> <span class="ow">not</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">FROM</span><span class="p">):</span> -</span><span id="Parser-2040"><a href="#Parser-2040"><span class="linenos">2040</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-2041"><a href="#Parser-2041"><span class="linenos">2041</span></a> -</span><span id="Parser-2042"><a href="#Parser-2042"><span class="linenos">2042</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> -</span><span id="Parser-2043"><a href="#Parser-2043"><span class="linenos">2043</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> -</span><span id="Parser-2044"><a href="#Parser-2044"><span class="linenos">2044</span></a> -</span><span id="Parser-2045"><a href="#Parser-2045"><span class="linenos">2045</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><span id="Parser-2046"><a href="#Parser-2046"><span class="linenos">2046</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> -</span><span id="Parser-2047"><a href="#Parser-2047"><span class="linenos">2047</span></a> <span class="n">comments</span><span class="o">=</span><span class="n">comments</span><span class="p">,</span> -</span><span id="Parser-2048"><a href="#Parser-2048"><span class="linenos">2048</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="n">modifiers</span> <span class="k">else</span> <span class="n">this</span><span class="p">,</span> -</span><span id="Parser-2049"><a href="#Parser-2049"><span class="linenos">2049</span></a> <span class="p">)</span> -</span><span id="Parser-2050"><a href="#Parser-2050"><span class="linenos">2050</span></a> -</span><span id="Parser-2051"><a href="#Parser-2051"><span class="linenos">2051</span></a> <span class="k">def</span> <span class="nf">_parse_match_recognize</span><span class="p">(</span><span class="bp">self</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">MatchRecognize</span><span class="p">]:</span> -</span><span id="Parser-2052"><a href="#Parser-2052"><span class="linenos">2052</span></a> <span class="k">if</span> <span class="ow">not</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">MATCH_RECOGNIZE</span><span class="p">):</span> -</span><span id="Parser-2053"><a href="#Parser-2053"><span class="linenos">2053</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2036"><a href="#Parser-2036"><span class="linenos">2036</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><span id="Parser-2037"><a href="#Parser-2037"><span class="linenos">2037</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Into</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_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> <span class="n">temporary</span><span class="o">=</span><span class="n">temp</span><span class="p">,</span> <span class="n">unlogged</span><span class="o">=</span><span class="n">unlogged</span> +</span><span id="Parser-2038"><a href="#Parser-2038"><span class="linenos">2038</span></a> <span class="p">)</span> +</span><span id="Parser-2039"><a href="#Parser-2039"><span class="linenos">2039</span></a> +</span><span id="Parser-2040"><a href="#Parser-2040"><span class="linenos">2040</span></a> <span class="k">def</span> <span class="nf">_parse_from</span><span class="p">(</span> +</span><span id="Parser-2041"><a href="#Parser-2041"><span class="linenos">2041</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">modifiers</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="n">skip_from_token</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-2042"><a href="#Parser-2042"><span class="linenos">2042</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">From</span><span class="p">]:</span> +</span><span id="Parser-2043"><a href="#Parser-2043"><span class="linenos">2043</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_from_token</span> <span class="ow">and</span> <span class="ow">not</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">FROM</span><span class="p">):</span> +</span><span id="Parser-2044"><a href="#Parser-2044"><span class="linenos">2044</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2045"><a href="#Parser-2045"><span class="linenos">2045</span></a> +</span><span id="Parser-2046"><a href="#Parser-2046"><span class="linenos">2046</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> +</span><span id="Parser-2047"><a href="#Parser-2047"><span class="linenos">2047</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> +</span><span id="Parser-2048"><a href="#Parser-2048"><span class="linenos">2048</span></a> +</span><span id="Parser-2049"><a href="#Parser-2049"><span class="linenos">2049</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><span id="Parser-2050"><a href="#Parser-2050"><span class="linenos">2050</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">From</span><span class="p">,</span> +</span><span id="Parser-2051"><a href="#Parser-2051"><span class="linenos">2051</span></a> <span class="n">comments</span><span class="o">=</span><span class="n">comments</span><span class="p">,</span> +</span><span id="Parser-2052"><a href="#Parser-2052"><span class="linenos">2052</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="n">modifiers</span> <span class="k">else</span> <span class="n">this</span><span class="p">,</span> +</span><span id="Parser-2053"><a href="#Parser-2053"><span class="linenos">2053</span></a> <span class="p">)</span> </span><span id="Parser-2054"><a href="#Parser-2054"><span class="linenos">2054</span></a> -</span><span id="Parser-2055"><a href="#Parser-2055"><span class="linenos">2055</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> -</span><span id="Parser-2056"><a href="#Parser-2056"><span class="linenos">2056</span></a> -</span><span id="Parser-2057"><a href="#Parser-2057"><span class="linenos">2057</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition_by</span><span class="p">()</span> -</span><span id="Parser-2058"><a href="#Parser-2058"><span class="linenos">2058</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">()</span> -</span><span id="Parser-2059"><a href="#Parser-2059"><span class="linenos">2059</span></a> <span class="n">measures</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Parser-2060"><a href="#Parser-2060"><span class="linenos">2060</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MEASURES"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="Parser-2061"><a href="#Parser-2061"><span class="linenos">2061</span></a> <span class="p">)</span> -</span><span id="Parser-2062"><a href="#Parser-2062"><span class="linenos">2062</span></a> -</span><span id="Parser-2063"><a href="#Parser-2063"><span class="linenos">2063</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ONE"</span><span class="p">,</span> <span class="s2">"ROW"</span><span class="p">,</span> <span class="s2">"PER"</span><span class="p">,</span> <span class="s2">"MATCH"</span><span class="p">):</span> -</span><span id="Parser-2064"><a href="#Parser-2064"><span class="linenos">2064</span></a> <span class="n">rows</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="s2">"ONE ROW PER MATCH"</span><span class="p">)</span> -</span><span id="Parser-2065"><a href="#Parser-2065"><span class="linenos">2065</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ALL"</span><span class="p">,</span> <span class="s2">"ROWS"</span><span class="p">,</span> <span class="s2">"PER"</span><span class="p">,</span> <span class="s2">"MATCH"</span><span class="p">):</span> -</span><span id="Parser-2066"><a href="#Parser-2066"><span class="linenos">2066</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">"ALL ROWS PER MATCH"</span> -</span><span id="Parser-2067"><a href="#Parser-2067"><span class="linenos">2067</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SHOW"</span><span class="p">,</span> <span class="s2">"EMPTY"</span><span class="p">,</span> <span class="s2">"MATCHES"</span><span class="p">):</span> -</span><span id="Parser-2068"><a href="#Parser-2068"><span class="linenos">2068</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" SHOW EMPTY MATCHES"</span> -</span><span id="Parser-2069"><a href="#Parser-2069"><span class="linenos">2069</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OMIT"</span><span class="p">,</span> <span class="s2">"EMPTY"</span><span class="p">,</span> <span class="s2">"MATCHES"</span><span class="p">):</span> -</span><span id="Parser-2070"><a href="#Parser-2070"><span class="linenos">2070</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" OMIT EMPTY MATCHES"</span> -</span><span id="Parser-2071"><a href="#Parser-2071"><span class="linenos">2071</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"UNMATCHED"</span><span class="p">,</span> <span class="s2">"ROWS"</span><span class="p">):</span> -</span><span id="Parser-2072"><a href="#Parser-2072"><span class="linenos">2072</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" WITH UNMATCHED ROWS"</span> -</span><span id="Parser-2073"><a href="#Parser-2073"><span class="linenos">2073</span></a> <span class="n">rows</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="n">text</span><span class="p">)</span> -</span><span id="Parser-2074"><a href="#Parser-2074"><span class="linenos">2074</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2075"><a href="#Parser-2075"><span class="linenos">2075</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2076"><a href="#Parser-2076"><span class="linenos">2076</span></a> -</span><span id="Parser-2077"><a href="#Parser-2077"><span class="linenos">2077</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AFTER"</span><span class="p">,</span> <span class="s2">"MATCH"</span><span class="p">,</span> <span class="s2">"SKIP"</span><span class="p">):</span> -</span><span id="Parser-2078"><a href="#Parser-2078"><span class="linenos">2078</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">"AFTER MATCH SKIP"</span> -</span><span id="Parser-2079"><a href="#Parser-2079"><span class="linenos">2079</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PAST"</span><span class="p">,</span> <span class="s2">"LAST"</span><span class="p">,</span> <span class="s2">"ROW"</span><span class="p">):</span> -</span><span id="Parser-2080"><a href="#Parser-2080"><span class="linenos">2080</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" PAST LAST ROW"</span> -</span><span id="Parser-2081"><a href="#Parser-2081"><span class="linenos">2081</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"NEXT"</span><span class="p">,</span> <span class="s2">"ROW"</span><span class="p">):</span> -</span><span id="Parser-2082"><a href="#Parser-2082"><span class="linenos">2082</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" TO NEXT ROW"</span> -</span><span id="Parser-2083"><a href="#Parser-2083"><span class="linenos">2083</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"FIRST"</span><span class="p">):</span> -</span><span id="Parser-2084"><a href="#Parser-2084"><span class="linenos">2084</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" TO FIRST </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</span><span class="p">()</span><span class="o">.</span><span class="n">text</span><span class="si">}</span><span class="s2">"</span> <span class="c1"># type: ignore</span> -</span><span id="Parser-2085"><a href="#Parser-2085"><span class="linenos">2085</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"LAST"</span><span class="p">):</span> -</span><span id="Parser-2086"><a href="#Parser-2086"><span class="linenos">2086</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" TO LAST </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</span><span class="p">()</span><span class="o">.</span><span class="n">text</span><span class="si">}</span><span class="s2">"</span> <span class="c1"># type: ignore</span> -</span><span id="Parser-2087"><a href="#Parser-2087"><span class="linenos">2087</span></a> <span class="n">after</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="n">text</span><span class="p">)</span> -</span><span id="Parser-2088"><a href="#Parser-2088"><span class="linenos">2088</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2089"><a href="#Parser-2089"><span class="linenos">2089</span></a> <span class="n">after</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2090"><a href="#Parser-2090"><span class="linenos">2090</span></a> -</span><span id="Parser-2091"><a href="#Parser-2091"><span class="linenos">2091</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PATTERN"</span><span class="p">):</span> -</span><span id="Parser-2092"><a href="#Parser-2092"><span class="linenos">2092</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> -</span><span id="Parser-2093"><a href="#Parser-2093"><span class="linenos">2093</span></a> -</span><span id="Parser-2094"><a href="#Parser-2094"><span class="linenos">2094</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="Parser-2095"><a href="#Parser-2095"><span class="linenos">2095</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting )"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">)</span> -</span><span id="Parser-2096"><a href="#Parser-2096"><span class="linenos">2096</span></a> -</span><span id="Parser-2097"><a href="#Parser-2097"><span class="linenos">2097</span></a> <span class="n">paren</span> <span class="o">=</span> <span class="mi">1</span> -</span><span id="Parser-2098"><a href="#Parser-2098"><span class="linenos">2098</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> -</span><span id="Parser-2099"><a href="#Parser-2099"><span class="linenos">2099</span></a> -</span><span id="Parser-2100"><a href="#Parser-2100"><span class="linenos">2100</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">and</span> <span class="n">paren</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> -</span><span id="Parser-2101"><a href="#Parser-2101"><span class="linenos">2101</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">:</span> -</span><span id="Parser-2102"><a href="#Parser-2102"><span class="linenos">2102</span></a> <span class="n">paren</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="Parser-2103"><a href="#Parser-2103"><span class="linenos">2103</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_PAREN</span><span class="p">:</span> -</span><span id="Parser-2104"><a href="#Parser-2104"><span class="linenos">2104</span></a> <span class="n">paren</span> <span class="o">-=</span> <span class="mi">1</span> -</span><span id="Parser-2105"><a href="#Parser-2105"><span class="linenos">2105</span></a> -</span><span id="Parser-2106"><a href="#Parser-2106"><span class="linenos">2106</span></a> <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> -</span><span id="Parser-2107"><a href="#Parser-2107"><span class="linenos">2107</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Parser-2108"><a href="#Parser-2108"><span class="linenos">2108</span></a> -</span><span id="Parser-2109"><a href="#Parser-2109"><span class="linenos">2109</span></a> <span class="k">if</span> <span class="n">paren</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> -</span><span id="Parser-2110"><a href="#Parser-2110"><span class="linenos">2110</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting )"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">)</span> -</span><span id="Parser-2111"><a href="#Parser-2111"><span class="linenos">2111</span></a> -</span><span id="Parser-2112"><a href="#Parser-2112"><span class="linenos">2112</span></a> <span class="n">pattern</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="bp">self</span><span class="o">.</span><span class="n">_find_sql</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">))</span> -</span><span id="Parser-2113"><a href="#Parser-2113"><span class="linenos">2113</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2114"><a href="#Parser-2114"><span class="linenos">2114</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2055"><a href="#Parser-2055"><span class="linenos">2055</span></a> <span class="k">def</span> <span class="nf">_parse_match_recognize</span><span class="p">(</span><span class="bp">self</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">MatchRecognize</span><span class="p">]:</span> +</span><span id="Parser-2056"><a href="#Parser-2056"><span class="linenos">2056</span></a> <span class="k">if</span> <span class="ow">not</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">MATCH_RECOGNIZE</span><span class="p">):</span> +</span><span id="Parser-2057"><a href="#Parser-2057"><span class="linenos">2057</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2058"><a href="#Parser-2058"><span class="linenos">2058</span></a> +</span><span id="Parser-2059"><a href="#Parser-2059"><span class="linenos">2059</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> +</span><span id="Parser-2060"><a href="#Parser-2060"><span class="linenos">2060</span></a> +</span><span id="Parser-2061"><a href="#Parser-2061"><span class="linenos">2061</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition_by</span><span class="p">()</span> +</span><span id="Parser-2062"><a href="#Parser-2062"><span class="linenos">2062</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">()</span> +</span><span id="Parser-2063"><a href="#Parser-2063"><span class="linenos">2063</span></a> <span class="n">measures</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Parser-2064"><a href="#Parser-2064"><span class="linenos">2064</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MEASURES"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="Parser-2065"><a href="#Parser-2065"><span class="linenos">2065</span></a> <span class="p">)</span> +</span><span id="Parser-2066"><a href="#Parser-2066"><span class="linenos">2066</span></a> +</span><span id="Parser-2067"><a href="#Parser-2067"><span class="linenos">2067</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ONE"</span><span class="p">,</span> <span class="s2">"ROW"</span><span class="p">,</span> <span class="s2">"PER"</span><span class="p">,</span> <span class="s2">"MATCH"</span><span class="p">):</span> +</span><span id="Parser-2068"><a href="#Parser-2068"><span class="linenos">2068</span></a> <span class="n">rows</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="s2">"ONE ROW PER MATCH"</span><span class="p">)</span> +</span><span id="Parser-2069"><a href="#Parser-2069"><span class="linenos">2069</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ALL"</span><span class="p">,</span> <span class="s2">"ROWS"</span><span class="p">,</span> <span class="s2">"PER"</span><span class="p">,</span> <span class="s2">"MATCH"</span><span class="p">):</span> +</span><span id="Parser-2070"><a href="#Parser-2070"><span class="linenos">2070</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">"ALL ROWS PER MATCH"</span> +</span><span id="Parser-2071"><a href="#Parser-2071"><span class="linenos">2071</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SHOW"</span><span class="p">,</span> <span class="s2">"EMPTY"</span><span class="p">,</span> <span class="s2">"MATCHES"</span><span class="p">):</span> +</span><span id="Parser-2072"><a href="#Parser-2072"><span class="linenos">2072</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" SHOW EMPTY MATCHES"</span> +</span><span id="Parser-2073"><a href="#Parser-2073"><span class="linenos">2073</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OMIT"</span><span class="p">,</span> <span class="s2">"EMPTY"</span><span class="p">,</span> <span class="s2">"MATCHES"</span><span class="p">):</span> +</span><span id="Parser-2074"><a href="#Parser-2074"><span class="linenos">2074</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" OMIT EMPTY MATCHES"</span> +</span><span id="Parser-2075"><a href="#Parser-2075"><span class="linenos">2075</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"UNMATCHED"</span><span class="p">,</span> <span class="s2">"ROWS"</span><span class="p">):</span> +</span><span id="Parser-2076"><a href="#Parser-2076"><span class="linenos">2076</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" WITH UNMATCHED ROWS"</span> +</span><span id="Parser-2077"><a href="#Parser-2077"><span class="linenos">2077</span></a> <span class="n">rows</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="n">text</span><span class="p">)</span> +</span><span id="Parser-2078"><a href="#Parser-2078"><span class="linenos">2078</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2079"><a href="#Parser-2079"><span class="linenos">2079</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2080"><a href="#Parser-2080"><span class="linenos">2080</span></a> +</span><span id="Parser-2081"><a href="#Parser-2081"><span class="linenos">2081</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AFTER"</span><span class="p">,</span> <span class="s2">"MATCH"</span><span class="p">,</span> <span class="s2">"SKIP"</span><span class="p">):</span> +</span><span id="Parser-2082"><a href="#Parser-2082"><span class="linenos">2082</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">"AFTER MATCH SKIP"</span> +</span><span id="Parser-2083"><a href="#Parser-2083"><span class="linenos">2083</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PAST"</span><span class="p">,</span> <span class="s2">"LAST"</span><span class="p">,</span> <span class="s2">"ROW"</span><span class="p">):</span> +</span><span id="Parser-2084"><a href="#Parser-2084"><span class="linenos">2084</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" PAST LAST ROW"</span> +</span><span id="Parser-2085"><a href="#Parser-2085"><span class="linenos">2085</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"NEXT"</span><span class="p">,</span> <span class="s2">"ROW"</span><span class="p">):</span> +</span><span id="Parser-2086"><a href="#Parser-2086"><span class="linenos">2086</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" TO NEXT ROW"</span> +</span><span id="Parser-2087"><a href="#Parser-2087"><span class="linenos">2087</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"FIRST"</span><span class="p">):</span> +</span><span id="Parser-2088"><a href="#Parser-2088"><span class="linenos">2088</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" TO FIRST </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</span><span class="p">()</span><span class="o">.</span><span class="n">text</span><span class="si">}</span><span class="s2">"</span> <span class="c1"># type: ignore</span> +</span><span id="Parser-2089"><a href="#Parser-2089"><span class="linenos">2089</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">,</span> <span class="s2">"LAST"</span><span class="p">):</span> +</span><span id="Parser-2090"><a href="#Parser-2090"><span class="linenos">2090</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" TO LAST </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</span><span class="p">()</span><span class="o">.</span><span class="n">text</span><span class="si">}</span><span class="s2">"</span> <span class="c1"># type: ignore</span> +</span><span id="Parser-2091"><a href="#Parser-2091"><span class="linenos">2091</span></a> <span class="n">after</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="n">text</span><span class="p">)</span> +</span><span id="Parser-2092"><a href="#Parser-2092"><span class="linenos">2092</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2093"><a href="#Parser-2093"><span class="linenos">2093</span></a> <span class="n">after</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2094"><a href="#Parser-2094"><span class="linenos">2094</span></a> +</span><span id="Parser-2095"><a href="#Parser-2095"><span class="linenos">2095</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PATTERN"</span><span class="p">):</span> +</span><span id="Parser-2096"><a href="#Parser-2096"><span class="linenos">2096</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> +</span><span id="Parser-2097"><a href="#Parser-2097"><span class="linenos">2097</span></a> +</span><span id="Parser-2098"><a href="#Parser-2098"><span class="linenos">2098</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="Parser-2099"><a href="#Parser-2099"><span class="linenos">2099</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting )"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">)</span> +</span><span id="Parser-2100"><a href="#Parser-2100"><span class="linenos">2100</span></a> +</span><span id="Parser-2101"><a href="#Parser-2101"><span class="linenos">2101</span></a> <span class="n">paren</span> <span class="o">=</span> <span class="mi">1</span> +</span><span id="Parser-2102"><a href="#Parser-2102"><span class="linenos">2102</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> +</span><span id="Parser-2103"><a href="#Parser-2103"><span class="linenos">2103</span></a> +</span><span id="Parser-2104"><a href="#Parser-2104"><span class="linenos">2104</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">and</span> <span class="n">paren</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> +</span><span id="Parser-2105"><a href="#Parser-2105"><span class="linenos">2105</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">:</span> +</span><span id="Parser-2106"><a href="#Parser-2106"><span class="linenos">2106</span></a> <span class="n">paren</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="Parser-2107"><a href="#Parser-2107"><span class="linenos">2107</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_PAREN</span><span class="p">:</span> +</span><span id="Parser-2108"><a href="#Parser-2108"><span class="linenos">2108</span></a> <span class="n">paren</span> <span class="o">-=</span> <span class="mi">1</span> +</span><span id="Parser-2109"><a href="#Parser-2109"><span class="linenos">2109</span></a> +</span><span id="Parser-2110"><a href="#Parser-2110"><span class="linenos">2110</span></a> <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> +</span><span id="Parser-2111"><a href="#Parser-2111"><span class="linenos">2111</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Parser-2112"><a href="#Parser-2112"><span class="linenos">2112</span></a> +</span><span id="Parser-2113"><a href="#Parser-2113"><span class="linenos">2113</span></a> <span class="k">if</span> <span class="n">paren</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> +</span><span id="Parser-2114"><a href="#Parser-2114"><span class="linenos">2114</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting )"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">)</span> </span><span id="Parser-2115"><a href="#Parser-2115"><span class="linenos">2115</span></a> -</span><span id="Parser-2116"><a href="#Parser-2116"><span class="linenos">2116</span></a> <span class="n">define</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Parser-2117"><a href="#Parser-2117"><span class="linenos">2117</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> -</span><span id="Parser-2118"><a href="#Parser-2118"><span class="linenos">2118</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-2119"><a href="#Parser-2119"><span class="linenos">2119</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">,</span> -</span><span id="Parser-2120"><a href="#Parser-2120"><span class="linenos">2120</span></a> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> -</span><span id="Parser-2121"><a href="#Parser-2121"><span class="linenos">2121</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ALIAS</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">(),</span> -</span><span id="Parser-2122"><a href="#Parser-2122"><span class="linenos">2122</span></a> <span class="p">)</span> -</span><span id="Parser-2123"><a href="#Parser-2123"><span class="linenos">2123</span></a> <span class="p">)</span> -</span><span id="Parser-2124"><a href="#Parser-2124"><span class="linenos">2124</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFINE"</span><span class="p">)</span> -</span><span id="Parser-2125"><a href="#Parser-2125"><span class="linenos">2125</span></a> <span class="k">else</span> <span class="kc">None</span> -</span><span id="Parser-2126"><a href="#Parser-2126"><span class="linenos">2126</span></a> <span class="p">)</span> -</span><span id="Parser-2127"><a href="#Parser-2127"><span class="linenos">2127</span></a> -</span><span id="Parser-2128"><a href="#Parser-2128"><span class="linenos">2128</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="Parser-2129"><a href="#Parser-2129"><span class="linenos">2129</span></a> -</span><span id="Parser-2130"><a href="#Parser-2130"><span class="linenos">2130</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><span id="Parser-2131"><a href="#Parser-2131"><span class="linenos">2131</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">,</span> -</span><span id="Parser-2132"><a href="#Parser-2132"><span class="linenos">2132</span></a> <span class="n">partition_by</span><span class="o">=</span><span class="n">partition</span><span class="p">,</span> -</span><span id="Parser-2133"><a href="#Parser-2133"><span class="linenos">2133</span></a> <span class="n">order</span><span class="o">=</span><span class="n">order</span><span class="p">,</span> -</span><span id="Parser-2134"><a href="#Parser-2134"><span class="linenos">2134</span></a> <span class="n">measures</span><span class="o">=</span><span class="n">measures</span><span class="p">,</span> -</span><span id="Parser-2135"><a href="#Parser-2135"><span class="linenos">2135</span></a> <span class="n">rows</span><span class="o">=</span><span class="n">rows</span><span class="p">,</span> -</span><span id="Parser-2136"><a href="#Parser-2136"><span class="linenos">2136</span></a> <span class="n">after</span><span class="o">=</span><span class="n">after</span><span class="p">,</span> -</span><span id="Parser-2137"><a href="#Parser-2137"><span class="linenos">2137</span></a> <span class="n">pattern</span><span class="o">=</span><span class="n">pattern</span><span class="p">,</span> -</span><span id="Parser-2138"><a href="#Parser-2138"><span class="linenos">2138</span></a> <span class="n">define</span><span class="o">=</span><span class="n">define</span><span class="p">,</span> -</span><span id="Parser-2139"><a href="#Parser-2139"><span class="linenos">2139</span></a> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">(),</span> -</span><span id="Parser-2140"><a href="#Parser-2140"><span class="linenos">2140</span></a> <span class="p">)</span> -</span><span id="Parser-2141"><a href="#Parser-2141"><span class="linenos">2141</span></a> -</span><span id="Parser-2142"><a href="#Parser-2142"><span class="linenos">2142</span></a> <span class="k">def</span> <span class="nf">_parse_lateral</span><span class="p">(</span><span class="bp">self</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">Lateral</span><span class="p">]:</span> -</span><span id="Parser-2143"><a href="#Parser-2143"><span class="linenos">2143</span></a> <span class="n">outer_apply</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">OUTER</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">)</span> -</span><span id="Parser-2144"><a href="#Parser-2144"><span class="linenos">2144</span></a> <span class="n">cross_apply</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">CROSS</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">)</span> +</span><span id="Parser-2116"><a href="#Parser-2116"><span class="linenos">2116</span></a> <span class="n">pattern</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="bp">self</span><span class="o">.</span><span class="n">_find_sql</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">))</span> +</span><span id="Parser-2117"><a href="#Parser-2117"><span class="linenos">2117</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2118"><a href="#Parser-2118"><span class="linenos">2118</span></a> <span class="n">pattern</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2119"><a href="#Parser-2119"><span class="linenos">2119</span></a> +</span><span id="Parser-2120"><a href="#Parser-2120"><span class="linenos">2120</span></a> <span class="n">define</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Parser-2121"><a href="#Parser-2121"><span class="linenos">2121</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> +</span><span id="Parser-2122"><a href="#Parser-2122"><span class="linenos">2122</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-2123"><a href="#Parser-2123"><span class="linenos">2123</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">,</span> +</span><span id="Parser-2124"><a href="#Parser-2124"><span class="linenos">2124</span></a> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> +</span><span id="Parser-2125"><a href="#Parser-2125"><span class="linenos">2125</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ALIAS</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">(),</span> +</span><span id="Parser-2126"><a href="#Parser-2126"><span class="linenos">2126</span></a> <span class="p">)</span> +</span><span id="Parser-2127"><a href="#Parser-2127"><span class="linenos">2127</span></a> <span class="p">)</span> +</span><span id="Parser-2128"><a href="#Parser-2128"><span class="linenos">2128</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFINE"</span><span class="p">)</span> +</span><span id="Parser-2129"><a href="#Parser-2129"><span class="linenos">2129</span></a> <span class="k">else</span> <span class="kc">None</span> +</span><span id="Parser-2130"><a href="#Parser-2130"><span class="linenos">2130</span></a> <span class="p">)</span> +</span><span id="Parser-2131"><a href="#Parser-2131"><span class="linenos">2131</span></a> +</span><span id="Parser-2132"><a href="#Parser-2132"><span class="linenos">2132</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-2133"><a href="#Parser-2133"><span class="linenos">2133</span></a> +</span><span id="Parser-2134"><a href="#Parser-2134"><span class="linenos">2134</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><span id="Parser-2135"><a href="#Parser-2135"><span class="linenos">2135</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MatchRecognize</span><span class="p">,</span> +</span><span id="Parser-2136"><a href="#Parser-2136"><span class="linenos">2136</span></a> <span class="n">partition_by</span><span class="o">=</span><span class="n">partition</span><span class="p">,</span> +</span><span id="Parser-2137"><a href="#Parser-2137"><span class="linenos">2137</span></a> <span class="n">order</span><span class="o">=</span><span class="n">order</span><span class="p">,</span> +</span><span id="Parser-2138"><a href="#Parser-2138"><span class="linenos">2138</span></a> <span class="n">measures</span><span class="o">=</span><span class="n">measures</span><span class="p">,</span> +</span><span id="Parser-2139"><a href="#Parser-2139"><span class="linenos">2139</span></a> <span class="n">rows</span><span class="o">=</span><span class="n">rows</span><span class="p">,</span> +</span><span id="Parser-2140"><a href="#Parser-2140"><span class="linenos">2140</span></a> <span class="n">after</span><span class="o">=</span><span class="n">after</span><span class="p">,</span> +</span><span id="Parser-2141"><a href="#Parser-2141"><span class="linenos">2141</span></a> <span class="n">pattern</span><span class="o">=</span><span class="n">pattern</span><span class="p">,</span> +</span><span id="Parser-2142"><a href="#Parser-2142"><span class="linenos">2142</span></a> <span class="n">define</span><span class="o">=</span><span class="n">define</span><span class="p">,</span> +</span><span id="Parser-2143"><a href="#Parser-2143"><span class="linenos">2143</span></a> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">(),</span> +</span><span id="Parser-2144"><a href="#Parser-2144"><span class="linenos">2144</span></a> <span class="p">)</span> </span><span id="Parser-2145"><a href="#Parser-2145"><span class="linenos">2145</span></a> -</span><span id="Parser-2146"><a href="#Parser-2146"><span class="linenos">2146</span></a> <span class="k">if</span> <span class="n">outer_apply</span> <span class="ow">or</span> <span class="n">cross_apply</span><span class="p">:</span> -</span><span id="Parser-2147"><a href="#Parser-2147"><span class="linenos">2147</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-2148"><a href="#Parser-2148"><span class="linenos">2148</span></a> <span class="n">view</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2149"><a href="#Parser-2149"><span class="linenos">2149</span></a> <span class="n">outer</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">cross_apply</span> -</span><span id="Parser-2150"><a href="#Parser-2150"><span class="linenos">2150</span></a> <span class="k">elif</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">LATERAL</span><span class="p">):</span> +</span><span id="Parser-2146"><a href="#Parser-2146"><span class="linenos">2146</span></a> <span class="k">def</span> <span class="nf">_parse_lateral</span><span class="p">(</span><span class="bp">self</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">Lateral</span><span class="p">]:</span> +</span><span id="Parser-2147"><a href="#Parser-2147"><span class="linenos">2147</span></a> <span class="n">outer_apply</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">OUTER</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">)</span> +</span><span id="Parser-2148"><a href="#Parser-2148"><span class="linenos">2148</span></a> <span class="n">cross_apply</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">CROSS</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">)</span> +</span><span id="Parser-2149"><a href="#Parser-2149"><span class="linenos">2149</span></a> +</span><span id="Parser-2150"><a href="#Parser-2150"><span class="linenos">2150</span></a> <span class="k">if</span> <span class="n">outer_apply</span> <span class="ow">or</span> <span class="n">cross_apply</span><span class="p">:</span> </span><span id="Parser-2151"><a href="#Parser-2151"><span class="linenos">2151</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-2152"><a href="#Parser-2152"><span class="linenos">2152</span></a> <span class="n">view</span> <span class="o">=</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">VIEW</span><span class="p">)</span> -</span><span id="Parser-2153"><a href="#Parser-2153"><span class="linenos">2153</span></a> <span class="n">outer</span> <span class="o">=</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">OUTER</span><span class="p">)</span> -</span><span id="Parser-2154"><a href="#Parser-2154"><span class="linenos">2154</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2155"><a href="#Parser-2155"><span class="linenos">2155</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-2156"><a href="#Parser-2156"><span class="linenos">2156</span></a> -</span><span id="Parser-2157"><a href="#Parser-2157"><span class="linenos">2157</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> -</span><span id="Parser-2158"><a href="#Parser-2158"><span class="linenos">2158</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Parser-2159"><a href="#Parser-2159"><span class="linenos">2159</span></a> <span class="k">while</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">DOT</span><span class="p">):</span> -</span><span id="Parser-2160"><a href="#Parser-2160"><span class="linenos">2160</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">(</span> -</span><span id="Parser-2161"><a href="#Parser-2161"><span class="linenos">2161</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="Parser-2162"><a href="#Parser-2162"><span class="linenos">2162</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="Parser-2163"><a href="#Parser-2163"><span class="linenos">2163</span></a> <span class="p">)</span> -</span><span id="Parser-2164"><a href="#Parser-2164"><span class="linenos">2164</span></a> -</span><span id="Parser-2165"><a href="#Parser-2165"><span class="linenos">2165</span></a> <span class="k">if</span> <span class="n">view</span><span class="p">:</span> -</span><span id="Parser-2166"><a href="#Parser-2166"><span class="linenos">2166</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Parser-2167"><a href="#Parser-2167"><span class="linenos">2167</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">)</span> <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">ALIAS</span><span class="p">)</span> <span class="k">else</span> <span class="p">[]</span> -</span><span id="Parser-2168"><a href="#Parser-2168"><span class="linenos">2168</span></a> <span class="n">table_alias</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">TableAlias</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-2169"><a href="#Parser-2169"><span class="linenos">2169</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableAlias</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="n">columns</span> -</span><span id="Parser-2170"><a href="#Parser-2170"><span class="linenos">2170</span></a> <span class="p">)</span> -</span><span id="Parser-2171"><a href="#Parser-2171"><span class="linenos">2171</span></a> <span class="k">elif</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">Subquery</span><span class="p">)</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> -</span><span id="Parser-2172"><a href="#Parser-2172"><span class="linenos">2172</span></a> <span class="c1"># Ensures parity between the Subquery's and the Lateral's "alias" args</span> -</span><span id="Parser-2173"><a href="#Parser-2173"><span class="linenos">2173</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"alias"</span><span class="p">]</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Parser-2174"><a href="#Parser-2174"><span class="linenos">2174</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2175"><a href="#Parser-2175"><span class="linenos">2175</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> -</span><span id="Parser-2176"><a href="#Parser-2176"><span class="linenos">2176</span></a> -</span><span id="Parser-2177"><a href="#Parser-2177"><span class="linenos">2177</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">Lateral</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">view</span><span class="o">=</span><span class="n">view</span><span class="p">,</span> <span class="n">outer</span><span class="o">=</span><span class="n">outer</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">table_alias</span><span class="p">)</span> -</span><span id="Parser-2178"><a href="#Parser-2178"><span class="linenos">2178</span></a> -</span><span id="Parser-2179"><a href="#Parser-2179"><span class="linenos">2179</span></a> <span class="k">def</span> <span class="nf">_parse_join_parts</span><span class="p">(</span> -</span><span id="Parser-2180"><a href="#Parser-2180"><span class="linenos">2180</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Parser-2181"><a href="#Parser-2181"><span class="linenos">2181</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">Token</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">Token</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">Token</span><span class="p">]]:</span> -</span><span id="Parser-2182"><a href="#Parser-2182"><span class="linenos">2182</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="Parser-2183"><a href="#Parser-2183"><span class="linenos">2183</span></a> <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">JOIN_METHODS</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">,</span> -</span><span id="Parser-2184"><a href="#Parser-2184"><span class="linenos">2184</span></a> <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">JOIN_SIDES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">,</span> -</span><span id="Parser-2185"><a href="#Parser-2185"><span class="linenos">2185</span></a> <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">JOIN_KINDS</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">,</span> -</span><span id="Parser-2186"><a href="#Parser-2186"><span class="linenos">2186</span></a> <span class="p">)</span> -</span><span id="Parser-2187"><a href="#Parser-2187"><span class="linenos">2187</span></a> -</span><span id="Parser-2188"><a href="#Parser-2188"><span class="linenos">2188</span></a> <span class="k">def</span> <span class="nf">_parse_join</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_join_token</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">Join</span><span class="p">]:</span> -</span><span id="Parser-2189"><a href="#Parser-2189"><span class="linenos">2189</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">COMMA</span><span class="p">):</span> -</span><span id="Parser-2190"><a href="#Parser-2190"><span class="linenos">2190</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">Join</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_table</span><span class="p">())</span> +</span><span id="Parser-2152"><a href="#Parser-2152"><span class="linenos">2152</span></a> <span class="n">view</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2153"><a href="#Parser-2153"><span class="linenos">2153</span></a> <span class="n">outer</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">cross_apply</span> +</span><span id="Parser-2154"><a href="#Parser-2154"><span class="linenos">2154</span></a> <span class="k">elif</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">LATERAL</span><span class="p">):</span> +</span><span id="Parser-2155"><a href="#Parser-2155"><span class="linenos">2155</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-2156"><a href="#Parser-2156"><span class="linenos">2156</span></a> <span class="n">view</span> <span class="o">=</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">VIEW</span><span class="p">)</span> +</span><span id="Parser-2157"><a href="#Parser-2157"><span class="linenos">2157</span></a> <span class="n">outer</span> <span class="o">=</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">OUTER</span><span class="p">)</span> +</span><span id="Parser-2158"><a href="#Parser-2158"><span class="linenos">2158</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2159"><a href="#Parser-2159"><span class="linenos">2159</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2160"><a href="#Parser-2160"><span class="linenos">2160</span></a> +</span><span id="Parser-2161"><a href="#Parser-2161"><span class="linenos">2161</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> +</span><span id="Parser-2162"><a href="#Parser-2162"><span class="linenos">2162</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Parser-2163"><a href="#Parser-2163"><span class="linenos">2163</span></a> <span class="k">while</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">DOT</span><span class="p">):</span> +</span><span id="Parser-2164"><a href="#Parser-2164"><span class="linenos">2164</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">(</span> +</span><span id="Parser-2165"><a href="#Parser-2165"><span class="linenos">2165</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="Parser-2166"><a href="#Parser-2166"><span class="linenos">2166</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="Parser-2167"><a href="#Parser-2167"><span class="linenos">2167</span></a> <span class="p">)</span> +</span><span id="Parser-2168"><a href="#Parser-2168"><span class="linenos">2168</span></a> +</span><span id="Parser-2169"><a href="#Parser-2169"><span class="linenos">2169</span></a> <span class="k">if</span> <span class="n">view</span><span class="p">:</span> +</span><span id="Parser-2170"><a href="#Parser-2170"><span class="linenos">2170</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Parser-2171"><a href="#Parser-2171"><span class="linenos">2171</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">)</span> <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">ALIAS</span><span class="p">)</span> <span class="k">else</span> <span class="p">[]</span> +</span><span id="Parser-2172"><a href="#Parser-2172"><span class="linenos">2172</span></a> <span class="n">table_alias</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">TableAlias</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-2173"><a href="#Parser-2173"><span class="linenos">2173</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableAlias</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="n">columns</span> +</span><span id="Parser-2174"><a href="#Parser-2174"><span class="linenos">2174</span></a> <span class="p">)</span> +</span><span id="Parser-2175"><a href="#Parser-2175"><span class="linenos">2175</span></a> <span class="k">elif</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">Subquery</span><span class="p">)</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">alias</span><span class="p">:</span> +</span><span id="Parser-2176"><a href="#Parser-2176"><span class="linenos">2176</span></a> <span class="c1"># Ensures parity between the Subquery's and the Lateral's "alias" args</span> +</span><span id="Parser-2177"><a href="#Parser-2177"><span class="linenos">2177</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"alias"</span><span class="p">]</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Parser-2178"><a href="#Parser-2178"><span class="linenos">2178</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2179"><a href="#Parser-2179"><span class="linenos">2179</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> +</span><span id="Parser-2180"><a href="#Parser-2180"><span class="linenos">2180</span></a> +</span><span id="Parser-2181"><a href="#Parser-2181"><span class="linenos">2181</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">Lateral</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">view</span><span class="o">=</span><span class="n">view</span><span class="p">,</span> <span class="n">outer</span><span class="o">=</span><span class="n">outer</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">table_alias</span><span class="p">)</span> +</span><span id="Parser-2182"><a href="#Parser-2182"><span class="linenos">2182</span></a> +</span><span id="Parser-2183"><a href="#Parser-2183"><span class="linenos">2183</span></a> <span class="k">def</span> <span class="nf">_parse_join_parts</span><span class="p">(</span> +</span><span id="Parser-2184"><a href="#Parser-2184"><span class="linenos">2184</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Parser-2185"><a href="#Parser-2185"><span class="linenos">2185</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">Token</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">Token</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">Token</span><span class="p">]]:</span> +</span><span id="Parser-2186"><a href="#Parser-2186"><span class="linenos">2186</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="Parser-2187"><a href="#Parser-2187"><span class="linenos">2187</span></a> <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">JOIN_METHODS</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">,</span> +</span><span id="Parser-2188"><a href="#Parser-2188"><span class="linenos">2188</span></a> <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">JOIN_SIDES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">,</span> +</span><span id="Parser-2189"><a href="#Parser-2189"><span class="linenos">2189</span></a> <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">JOIN_KINDS</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">,</span> +</span><span id="Parser-2190"><a href="#Parser-2190"><span class="linenos">2190</span></a> <span class="p">)</span> </span><span id="Parser-2191"><a href="#Parser-2191"><span class="linenos">2191</span></a> -</span><span id="Parser-2192"><a href="#Parser-2192"><span class="linenos">2192</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="Parser-2193"><a href="#Parser-2193"><span class="linenos">2193</span></a> <span class="n">method</span><span class="p">,</span> <span class="n">side</span><span class="p">,</span> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_join_parts</span><span class="p">()</span> -</span><span id="Parser-2194"><a href="#Parser-2194"><span class="linenos">2194</span></a> <span class="n">hint</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="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">JOIN_HINTS</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="Parser-2195"><a href="#Parser-2195"><span class="linenos">2195</span></a> <span class="n">join</span> <span class="o">=</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">JOIN</span><span class="p">)</span> -</span><span id="Parser-2196"><a href="#Parser-2196"><span class="linenos">2196</span></a> -</span><span id="Parser-2197"><a href="#Parser-2197"><span class="linenos">2197</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_join_token</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">join</span><span class="p">:</span> -</span><span id="Parser-2198"><a href="#Parser-2198"><span class="linenos">2198</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-2199"><a href="#Parser-2199"><span class="linenos">2199</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2200"><a href="#Parser-2200"><span class="linenos">2200</span></a> <span class="n">method</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2201"><a href="#Parser-2201"><span class="linenos">2201</span></a> <span class="n">side</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2202"><a href="#Parser-2202"><span class="linenos">2202</span></a> -</span><span id="Parser-2203"><a href="#Parser-2203"><span class="linenos">2203</span></a> <span class="n">outer_apply</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">OUTER</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> -</span><span id="Parser-2204"><a href="#Parser-2204"><span class="linenos">2204</span></a> <span class="n">cross_apply</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">CROSS</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> -</span><span id="Parser-2205"><a href="#Parser-2205"><span class="linenos">2205</span></a> -</span><span id="Parser-2206"><a href="#Parser-2206"><span class="linenos">2206</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_join_token</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">join</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">outer_apply</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">cross_apply</span><span class="p">:</span> -</span><span id="Parser-2207"><a href="#Parser-2207"><span class="linenos">2207</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-2208"><a href="#Parser-2208"><span class="linenos">2208</span></a> -</span><span id="Parser-2209"><a href="#Parser-2209"><span class="linenos">2209</span></a> <span class="k">if</span> <span class="n">outer_apply</span><span class="p">:</span> -</span><span id="Parser-2210"><a href="#Parser-2210"><span class="linenos">2210</span></a> <span class="n">side</span> <span class="o">=</span> <span class="n">Token</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">LEFT</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">)</span> -</span><span id="Parser-2211"><a href="#Parser-2211"><span class="linenos">2211</span></a> -</span><span id="Parser-2212"><a href="#Parser-2212"><span class="linenos">2212</span></a> <span class="n">kwargs</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()}</span> -</span><span id="Parser-2213"><a href="#Parser-2213"><span class="linenos">2213</span></a> -</span><span id="Parser-2214"><a href="#Parser-2214"><span class="linenos">2214</span></a> <span class="k">if</span> <span class="n">method</span><span class="p">:</span> -</span><span id="Parser-2215"><a href="#Parser-2215"><span class="linenos">2215</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"method"</span><span class="p">]</span> <span class="o">=</span> <span class="n">method</span><span class="o">.</span><span class="n">text</span> -</span><span id="Parser-2216"><a href="#Parser-2216"><span class="linenos">2216</span></a> <span class="k">if</span> <span class="n">side</span><span class="p">:</span> -</span><span id="Parser-2217"><a href="#Parser-2217"><span class="linenos">2217</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"side"</span><span class="p">]</span> <span class="o">=</span> <span class="n">side</span><span class="o">.</span><span class="n">text</span> -</span><span id="Parser-2218"><a href="#Parser-2218"><span class="linenos">2218</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="Parser-2219"><a href="#Parser-2219"><span class="linenos">2219</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> <span class="o">=</span> <span class="n">kind</span><span class="o">.</span><span class="n">text</span> -</span><span id="Parser-2220"><a href="#Parser-2220"><span class="linenos">2220</span></a> <span class="k">if</span> <span class="n">hint</span><span class="p">:</span> -</span><span id="Parser-2221"><a href="#Parser-2221"><span class="linenos">2221</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"hint"</span><span class="p">]</span> <span class="o">=</span> <span class="n">hint</span> -</span><span id="Parser-2222"><a href="#Parser-2222"><span class="linenos">2222</span></a> -</span><span id="Parser-2223"><a href="#Parser-2223"><span class="linenos">2223</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">ON</span><span class="p">):</span> -</span><span id="Parser-2224"><a href="#Parser-2224"><span class="linenos">2224</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"on"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="Parser-2225"><a href="#Parser-2225"><span class="linenos">2225</span></a> <span class="k">elif</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">USING</span><span class="p">):</span> -</span><span id="Parser-2226"><a href="#Parser-2226"><span class="linenos">2226</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"using"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_id_vars</span><span class="p">()</span> -</span><span id="Parser-2227"><a href="#Parser-2227"><span class="linenos">2227</span></a> -</span><span id="Parser-2228"><a href="#Parser-2228"><span class="linenos">2228</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">Join</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="Parser-2229"><a href="#Parser-2229"><span class="linenos">2229</span></a> -</span><span id="Parser-2230"><a href="#Parser-2230"><span class="linenos">2230</span></a> <span class="k">def</span> <span class="nf">_parse_index</span><span class="p">(</span> -</span><span id="Parser-2231"><a href="#Parser-2231"><span class="linenos">2231</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Parser-2232"><a href="#Parser-2232"><span class="linenos">2232</span></a> <span class="n">index</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Parser-2233"><a href="#Parser-2233"><span class="linenos">2233</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">Index</span><span class="p">]:</span> -</span><span id="Parser-2234"><a href="#Parser-2234"><span class="linenos">2234</span></a> <span class="k">if</span> <span class="n">index</span><span class="p">:</span> -</span><span id="Parser-2235"><a href="#Parser-2235"><span class="linenos">2235</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2236"><a href="#Parser-2236"><span class="linenos">2236</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2237"><a href="#Parser-2237"><span class="linenos">2237</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2238"><a href="#Parser-2238"><span class="linenos">2238</span></a> -</span><span id="Parser-2239"><a href="#Parser-2239"><span class="linenos">2239</span></a> <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">ON</span><span class="p">)</span> -</span><span id="Parser-2240"><a href="#Parser-2240"><span class="linenos">2240</span></a> <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">TABLE</span><span class="p">)</span> <span class="c1"># hive</span> -</span><span id="Parser-2241"><a href="#Parser-2241"><span class="linenos">2241</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-2242"><a href="#Parser-2242"><span class="linenos">2242</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2243"><a href="#Parser-2243"><span class="linenos">2243</span></a> <span class="n">unique</span> <span class="o">=</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">UNIQUE</span><span class="p">)</span> -</span><span id="Parser-2244"><a href="#Parser-2244"><span class="linenos">2244</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PRIMARY"</span><span class="p">)</span> -</span><span id="Parser-2245"><a href="#Parser-2245"><span class="linenos">2245</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AMP"</span><span class="p">)</span> -</span><span id="Parser-2246"><a href="#Parser-2246"><span class="linenos">2246</span></a> -</span><span id="Parser-2247"><a href="#Parser-2247"><span class="linenos">2247</span></a> <span class="k">if</span> <span class="ow">not</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">INDEX</span><span class="p">):</span> -</span><span id="Parser-2248"><a href="#Parser-2248"><span class="linenos">2248</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-2249"><a href="#Parser-2249"><span class="linenos">2249</span></a> -</span><span id="Parser-2250"><a href="#Parser-2250"><span class="linenos">2250</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="Parser-2251"><a href="#Parser-2251"><span class="linenos">2251</span></a> <span class="n">table</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2252"><a href="#Parser-2252"><span class="linenos">2252</span></a> -</span><span id="Parser-2253"><a href="#Parser-2253"><span class="linenos">2253</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> <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">USING</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="Parser-2254"><a href="#Parser-2254"><span class="linenos">2254</span></a> -</span><span id="Parser-2255"><a href="#Parser-2255"><span class="linenos">2255</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_PAREN</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="Parser-2256"><a href="#Parser-2256"><span class="linenos">2256</span></a> <span class="n">columns</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_ordered</span><span class="p">)</span> -</span><span id="Parser-2257"><a href="#Parser-2257"><span class="linenos">2257</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2258"><a href="#Parser-2258"><span class="linenos">2258</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2259"><a href="#Parser-2259"><span class="linenos">2259</span></a> -</span><span id="Parser-2260"><a href="#Parser-2260"><span class="linenos">2260</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><span id="Parser-2261"><a href="#Parser-2261"><span class="linenos">2261</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Index</span><span class="p">,</span> -</span><span id="Parser-2262"><a href="#Parser-2262"><span class="linenos">2262</span></a> <span class="n">this</span><span class="o">=</span><span class="n">index</span><span class="p">,</span> -</span><span id="Parser-2263"><a href="#Parser-2263"><span class="linenos">2263</span></a> <span class="n">table</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> -</span><span id="Parser-2264"><a href="#Parser-2264"><span class="linenos">2264</span></a> <span class="n">using</span><span class="o">=</span><span class="n">using</span><span class="p">,</span> -</span><span id="Parser-2265"><a href="#Parser-2265"><span class="linenos">2265</span></a> <span class="n">columns</span><span class="o">=</span><span class="n">columns</span><span class="p">,</span> -</span><span id="Parser-2266"><a href="#Parser-2266"><span class="linenos">2266</span></a> <span class="n">unique</span><span class="o">=</span><span class="n">unique</span><span class="p">,</span> -</span><span id="Parser-2267"><a href="#Parser-2267"><span class="linenos">2267</span></a> <span class="n">primary</span><span class="o">=</span><span class="n">primary</span><span class="p">,</span> -</span><span id="Parser-2268"><a href="#Parser-2268"><span class="linenos">2268</span></a> <span class="n">amp</span><span class="o">=</span><span class="n">amp</span><span class="p">,</span> -</span><span id="Parser-2269"><a href="#Parser-2269"><span class="linenos">2269</span></a> <span class="n">partition_by</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition_by</span><span class="p">(),</span> -</span><span id="Parser-2270"><a href="#Parser-2270"><span class="linenos">2270</span></a> <span class="p">)</span> -</span><span id="Parser-2271"><a href="#Parser-2271"><span class="linenos">2271</span></a> -</span><span id="Parser-2272"><a href="#Parser-2272"><span class="linenos">2272</span></a> <span class="k">def</span> <span class="nf">_parse_table_part</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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="Parser-2273"><a href="#Parser-2273"><span class="linenos">2273</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="Parser-2274"><a href="#Parser-2274"><span class="linenos">2274</span></a> <span class="p">(</span><span class="ow">not</span> <span class="n">schema</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">(</span><span class="n">optional_parens</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> -</span><span id="Parser-2275"><a href="#Parser-2275"><span class="linenos">2275</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Parser-2276"><a href="#Parser-2276"><span class="linenos">2276</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string_as_identifier</span><span class="p">()</span> -</span><span id="Parser-2277"><a href="#Parser-2277"><span class="linenos">2277</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_placeholder</span><span class="p">()</span> -</span><span id="Parser-2278"><a href="#Parser-2278"><span class="linenos">2278</span></a> <span class="p">)</span> -</span><span id="Parser-2279"><a href="#Parser-2279"><span class="linenos">2279</span></a> -</span><span id="Parser-2280"><a href="#Parser-2280"><span class="linenos">2280</span></a> <span class="k">def</span> <span class="nf">_parse_table_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> -</span><span id="Parser-2281"><a href="#Parser-2281"><span class="linenos">2281</span></a> <span class="n">catalog</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2282"><a href="#Parser-2282"><span class="linenos">2282</span></a> <span class="n">db</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2283"><a href="#Parser-2283"><span class="linenos">2283</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="Parser-2284"><a href="#Parser-2284"><span class="linenos">2284</span></a> -</span><span id="Parser-2285"><a href="#Parser-2285"><span class="linenos">2285</span></a> <span class="k">while</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">DOT</span><span class="p">):</span> -</span><span id="Parser-2286"><a href="#Parser-2286"><span class="linenos">2286</span></a> <span class="k">if</span> <span class="n">catalog</span><span class="p">:</span> -</span><span id="Parser-2287"><a href="#Parser-2287"><span class="linenos">2287</span></a> <span class="c1"># This allows nesting the table in arbitrarily many dot expressions if needed</span> -</span><span id="Parser-2288"><a href="#Parser-2288"><span class="linenos">2288</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-2289"><a href="#Parser-2289"><span class="linenos">2289</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="Parser-2290"><a href="#Parser-2290"><span class="linenos">2290</span></a> <span class="p">)</span> -</span><span id="Parser-2291"><a href="#Parser-2291"><span class="linenos">2291</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2292"><a href="#Parser-2292"><span class="linenos">2292</span></a> <span class="n">catalog</span> <span class="o">=</span> <span class="n">db</span> -</span><span id="Parser-2293"><a href="#Parser-2293"><span class="linenos">2293</span></a> <span class="n">db</span> <span class="o">=</span> <span class="n">table</span> -</span><span id="Parser-2294"><a href="#Parser-2294"><span class="linenos">2294</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="Parser-2295"><a href="#Parser-2295"><span class="linenos">2295</span></a> -</span><span id="Parser-2296"><a href="#Parser-2296"><span class="linenos">2296</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span><span class="p">:</span> -</span><span id="Parser-2297"><a href="#Parser-2297"><span class="linenos">2297</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Expected table name but got </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Parser-2298"><a href="#Parser-2298"><span class="linenos">2298</span></a> -</span><span id="Parser-2299"><a href="#Parser-2299"><span class="linenos">2299</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><span id="Parser-2300"><a href="#Parser-2300"><span class="linenos">2300</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="n">db</span><span class="p">,</span> <span class="n">catalog</span><span class="o">=</span><span class="n">catalog</span><span class="p">,</span> <span class="n">pivots</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivots</span><span class="p">()</span> -</span><span id="Parser-2301"><a href="#Parser-2301"><span class="linenos">2301</span></a> <span class="p">)</span> +</span><span id="Parser-2192"><a href="#Parser-2192"><span class="linenos">2192</span></a> <span class="k">def</span> <span class="nf">_parse_join</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_join_token</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">Join</span><span class="p">]:</span> +</span><span id="Parser-2193"><a href="#Parser-2193"><span class="linenos">2193</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">COMMA</span><span class="p">):</span> +</span><span id="Parser-2194"><a href="#Parser-2194"><span class="linenos">2194</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">Join</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_table</span><span class="p">())</span> +</span><span id="Parser-2195"><a href="#Parser-2195"><span class="linenos">2195</span></a> +</span><span id="Parser-2196"><a href="#Parser-2196"><span class="linenos">2196</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="Parser-2197"><a href="#Parser-2197"><span class="linenos">2197</span></a> <span class="n">method</span><span class="p">,</span> <span class="n">side</span><span class="p">,</span> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_join_parts</span><span class="p">()</span> +</span><span id="Parser-2198"><a href="#Parser-2198"><span class="linenos">2198</span></a> <span class="n">hint</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="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">JOIN_HINTS</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="Parser-2199"><a href="#Parser-2199"><span class="linenos">2199</span></a> <span class="n">join</span> <span class="o">=</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">JOIN</span><span class="p">)</span> +</span><span id="Parser-2200"><a href="#Parser-2200"><span class="linenos">2200</span></a> +</span><span id="Parser-2201"><a href="#Parser-2201"><span class="linenos">2201</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_join_token</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">join</span><span class="p">:</span> +</span><span id="Parser-2202"><a href="#Parser-2202"><span class="linenos">2202</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-2203"><a href="#Parser-2203"><span class="linenos">2203</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2204"><a href="#Parser-2204"><span class="linenos">2204</span></a> <span class="n">method</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2205"><a href="#Parser-2205"><span class="linenos">2205</span></a> <span class="n">side</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2206"><a href="#Parser-2206"><span class="linenos">2206</span></a> +</span><span id="Parser-2207"><a href="#Parser-2207"><span class="linenos">2207</span></a> <span class="n">outer_apply</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">OUTER</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> +</span><span id="Parser-2208"><a href="#Parser-2208"><span class="linenos">2208</span></a> <span class="n">cross_apply</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">CROSS</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> +</span><span id="Parser-2209"><a href="#Parser-2209"><span class="linenos">2209</span></a> +</span><span id="Parser-2210"><a href="#Parser-2210"><span class="linenos">2210</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_join_token</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">join</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">outer_apply</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">cross_apply</span><span class="p">:</span> +</span><span id="Parser-2211"><a href="#Parser-2211"><span class="linenos">2211</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2212"><a href="#Parser-2212"><span class="linenos">2212</span></a> +</span><span id="Parser-2213"><a href="#Parser-2213"><span class="linenos">2213</span></a> <span class="k">if</span> <span class="n">outer_apply</span><span class="p">:</span> +</span><span id="Parser-2214"><a href="#Parser-2214"><span class="linenos">2214</span></a> <span class="n">side</span> <span class="o">=</span> <span class="n">Token</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">LEFT</span><span class="p">,</span> <span class="s2">"LEFT"</span><span class="p">)</span> +</span><span id="Parser-2215"><a href="#Parser-2215"><span class="linenos">2215</span></a> +</span><span id="Parser-2216"><a href="#Parser-2216"><span class="linenos">2216</span></a> <span class="n">kwargs</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"this"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()}</span> +</span><span id="Parser-2217"><a href="#Parser-2217"><span class="linenos">2217</span></a> +</span><span id="Parser-2218"><a href="#Parser-2218"><span class="linenos">2218</span></a> <span class="k">if</span> <span class="n">method</span><span class="p">:</span> +</span><span id="Parser-2219"><a href="#Parser-2219"><span class="linenos">2219</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"method"</span><span class="p">]</span> <span class="o">=</span> <span class="n">method</span><span class="o">.</span><span class="n">text</span> +</span><span id="Parser-2220"><a href="#Parser-2220"><span class="linenos">2220</span></a> <span class="k">if</span> <span class="n">side</span><span class="p">:</span> +</span><span id="Parser-2221"><a href="#Parser-2221"><span class="linenos">2221</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"side"</span><span class="p">]</span> <span class="o">=</span> <span class="n">side</span><span class="o">.</span><span class="n">text</span> +</span><span id="Parser-2222"><a href="#Parser-2222"><span class="linenos">2222</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="Parser-2223"><a href="#Parser-2223"><span class="linenos">2223</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> <span class="o">=</span> <span class="n">kind</span><span class="o">.</span><span class="n">text</span> +</span><span id="Parser-2224"><a href="#Parser-2224"><span class="linenos">2224</span></a> <span class="k">if</span> <span class="n">hint</span><span class="p">:</span> +</span><span id="Parser-2225"><a href="#Parser-2225"><span class="linenos">2225</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"hint"</span><span class="p">]</span> <span class="o">=</span> <span class="n">hint</span> +</span><span id="Parser-2226"><a href="#Parser-2226"><span class="linenos">2226</span></a> +</span><span id="Parser-2227"><a href="#Parser-2227"><span class="linenos">2227</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">ON</span><span class="p">):</span> +</span><span id="Parser-2228"><a href="#Parser-2228"><span class="linenos">2228</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"on"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="Parser-2229"><a href="#Parser-2229"><span class="linenos">2229</span></a> <span class="k">elif</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">USING</span><span class="p">):</span> +</span><span id="Parser-2230"><a href="#Parser-2230"><span class="linenos">2230</span></a> <span class="n">kwargs</span><span class="p">[</span><span class="s2">"using"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_id_vars</span><span class="p">()</span> +</span><span id="Parser-2231"><a href="#Parser-2231"><span class="linenos">2231</span></a> +</span><span id="Parser-2232"><a href="#Parser-2232"><span class="linenos">2232</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">Join</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="Parser-2233"><a href="#Parser-2233"><span class="linenos">2233</span></a> +</span><span id="Parser-2234"><a href="#Parser-2234"><span class="linenos">2234</span></a> <span class="k">def</span> <span class="nf">_parse_index</span><span class="p">(</span> +</span><span id="Parser-2235"><a href="#Parser-2235"><span class="linenos">2235</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Parser-2236"><a href="#Parser-2236"><span class="linenos">2236</span></a> <span class="n">index</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Parser-2237"><a href="#Parser-2237"><span class="linenos">2237</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">Index</span><span class="p">]:</span> +</span><span id="Parser-2238"><a href="#Parser-2238"><span class="linenos">2238</span></a> <span class="k">if</span> <span class="n">index</span><span class="p">:</span> +</span><span id="Parser-2239"><a href="#Parser-2239"><span class="linenos">2239</span></a> <span class="n">unique</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2240"><a href="#Parser-2240"><span class="linenos">2240</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2241"><a href="#Parser-2241"><span class="linenos">2241</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2242"><a href="#Parser-2242"><span class="linenos">2242</span></a> +</span><span id="Parser-2243"><a href="#Parser-2243"><span class="linenos">2243</span></a> <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">ON</span><span class="p">)</span> +</span><span id="Parser-2244"><a href="#Parser-2244"><span class="linenos">2244</span></a> <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">TABLE</span><span class="p">)</span> <span class="c1"># hive</span> +</span><span id="Parser-2245"><a href="#Parser-2245"><span class="linenos">2245</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-2246"><a href="#Parser-2246"><span class="linenos">2246</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2247"><a href="#Parser-2247"><span class="linenos">2247</span></a> <span class="n">unique</span> <span class="o">=</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">UNIQUE</span><span class="p">)</span> +</span><span id="Parser-2248"><a href="#Parser-2248"><span class="linenos">2248</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"PRIMARY"</span><span class="p">)</span> +</span><span id="Parser-2249"><a href="#Parser-2249"><span class="linenos">2249</span></a> <span class="n">amp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AMP"</span><span class="p">)</span> +</span><span id="Parser-2250"><a href="#Parser-2250"><span class="linenos">2250</span></a> +</span><span id="Parser-2251"><a href="#Parser-2251"><span class="linenos">2251</span></a> <span class="k">if</span> <span class="ow">not</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">INDEX</span><span class="p">):</span> +</span><span id="Parser-2252"><a href="#Parser-2252"><span class="linenos">2252</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2253"><a href="#Parser-2253"><span class="linenos">2253</span></a> +</span><span id="Parser-2254"><a href="#Parser-2254"><span class="linenos">2254</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="Parser-2255"><a href="#Parser-2255"><span class="linenos">2255</span></a> <span class="n">table</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2256"><a href="#Parser-2256"><span class="linenos">2256</span></a> +</span><span id="Parser-2257"><a href="#Parser-2257"><span class="linenos">2257</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> <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">USING</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="Parser-2258"><a href="#Parser-2258"><span class="linenos">2258</span></a> +</span><span id="Parser-2259"><a href="#Parser-2259"><span class="linenos">2259</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_PAREN</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="Parser-2260"><a href="#Parser-2260"><span class="linenos">2260</span></a> <span class="n">columns</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_ordered</span><span class="p">)</span> +</span><span id="Parser-2261"><a href="#Parser-2261"><span class="linenos">2261</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2262"><a href="#Parser-2262"><span class="linenos">2262</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2263"><a href="#Parser-2263"><span class="linenos">2263</span></a> +</span><span id="Parser-2264"><a href="#Parser-2264"><span class="linenos">2264</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><span id="Parser-2265"><a href="#Parser-2265"><span class="linenos">2265</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Index</span><span class="p">,</span> +</span><span id="Parser-2266"><a href="#Parser-2266"><span class="linenos">2266</span></a> <span class="n">this</span><span class="o">=</span><span class="n">index</span><span class="p">,</span> +</span><span id="Parser-2267"><a href="#Parser-2267"><span class="linenos">2267</span></a> <span class="n">table</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> +</span><span id="Parser-2268"><a href="#Parser-2268"><span class="linenos">2268</span></a> <span class="n">using</span><span class="o">=</span><span class="n">using</span><span class="p">,</span> +</span><span id="Parser-2269"><a href="#Parser-2269"><span class="linenos">2269</span></a> <span class="n">columns</span><span class="o">=</span><span class="n">columns</span><span class="p">,</span> +</span><span id="Parser-2270"><a href="#Parser-2270"><span class="linenos">2270</span></a> <span class="n">unique</span><span class="o">=</span><span class="n">unique</span><span class="p">,</span> +</span><span id="Parser-2271"><a href="#Parser-2271"><span class="linenos">2271</span></a> <span class="n">primary</span><span class="o">=</span><span class="n">primary</span><span class="p">,</span> +</span><span id="Parser-2272"><a href="#Parser-2272"><span class="linenos">2272</span></a> <span class="n">amp</span><span class="o">=</span><span class="n">amp</span><span class="p">,</span> +</span><span id="Parser-2273"><a href="#Parser-2273"><span class="linenos">2273</span></a> <span class="n">partition_by</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition_by</span><span class="p">(),</span> +</span><span id="Parser-2274"><a href="#Parser-2274"><span class="linenos">2274</span></a> <span class="p">)</span> +</span><span id="Parser-2275"><a href="#Parser-2275"><span class="linenos">2275</span></a> +</span><span id="Parser-2276"><a href="#Parser-2276"><span class="linenos">2276</span></a> <span class="k">def</span> <span class="nf">_parse_table_part</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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="Parser-2277"><a href="#Parser-2277"><span class="linenos">2277</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="Parser-2278"><a href="#Parser-2278"><span class="linenos">2278</span></a> <span class="p">(</span><span class="ow">not</span> <span class="n">schema</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">(</span><span class="n">optional_parens</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> +</span><span id="Parser-2279"><a href="#Parser-2279"><span class="linenos">2279</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Parser-2280"><a href="#Parser-2280"><span class="linenos">2280</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string_as_identifier</span><span class="p">()</span> +</span><span id="Parser-2281"><a href="#Parser-2281"><span class="linenos">2281</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_placeholder</span><span class="p">()</span> +</span><span id="Parser-2282"><a href="#Parser-2282"><span class="linenos">2282</span></a> <span class="p">)</span> +</span><span id="Parser-2283"><a href="#Parser-2283"><span class="linenos">2283</span></a> +</span><span id="Parser-2284"><a href="#Parser-2284"><span class="linenos">2284</span></a> <span class="k">def</span> <span class="nf">_parse_table_parts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</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">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> +</span><span id="Parser-2285"><a href="#Parser-2285"><span class="linenos">2285</span></a> <span class="n">catalog</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2286"><a href="#Parser-2286"><span class="linenos">2286</span></a> <span class="n">db</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2287"><a href="#Parser-2287"><span class="linenos">2287</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="Parser-2288"><a href="#Parser-2288"><span class="linenos">2288</span></a> +</span><span id="Parser-2289"><a href="#Parser-2289"><span class="linenos">2289</span></a> <span class="k">while</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">DOT</span><span class="p">):</span> +</span><span id="Parser-2290"><a href="#Parser-2290"><span class="linenos">2290</span></a> <span class="k">if</span> <span class="n">catalog</span><span class="p">:</span> +</span><span id="Parser-2291"><a href="#Parser-2291"><span class="linenos">2291</span></a> <span class="c1"># This allows nesting the table in arbitrarily many dot expressions if needed</span> +</span><span id="Parser-2292"><a href="#Parser-2292"><span class="linenos">2292</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-2293"><a href="#Parser-2293"><span class="linenos">2293</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="Parser-2294"><a href="#Parser-2294"><span class="linenos">2294</span></a> <span class="p">)</span> +</span><span id="Parser-2295"><a href="#Parser-2295"><span class="linenos">2295</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2296"><a href="#Parser-2296"><span class="linenos">2296</span></a> <span class="n">catalog</span> <span class="o">=</span> <span class="n">db</span> +</span><span id="Parser-2297"><a href="#Parser-2297"><span class="linenos">2297</span></a> <span class="n">db</span> <span class="o">=</span> <span class="n">table</span> +</span><span id="Parser-2298"><a href="#Parser-2298"><span class="linenos">2298</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_part</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="Parser-2299"><a href="#Parser-2299"><span class="linenos">2299</span></a> +</span><span id="Parser-2300"><a href="#Parser-2300"><span class="linenos">2300</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">table</span><span class="p">:</span> +</span><span id="Parser-2301"><a href="#Parser-2301"><span class="linenos">2301</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Expected table name but got </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> </span><span id="Parser-2302"><a href="#Parser-2302"><span class="linenos">2302</span></a> -</span><span id="Parser-2303"><a href="#Parser-2303"><span class="linenos">2303</span></a> <span class="k">def</span> <span class="nf">_parse_table</span><span class="p">(</span> -</span><span id="Parser-2304"><a href="#Parser-2304"><span class="linenos">2304</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">schema</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="n">alias_tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2305"><a href="#Parser-2305"><span class="linenos">2305</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="Parser-2306"><a href="#Parser-2306"><span class="linenos">2306</span></a> <span class="n">lateral</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lateral</span><span class="p">()</span> -</span><span id="Parser-2307"><a href="#Parser-2307"><span class="linenos">2307</span></a> <span class="k">if</span> <span class="n">lateral</span><span class="p">:</span> -</span><span id="Parser-2308"><a href="#Parser-2308"><span class="linenos">2308</span></a> <span class="k">return</span> <span class="n">lateral</span> -</span><span id="Parser-2309"><a href="#Parser-2309"><span class="linenos">2309</span></a> -</span><span id="Parser-2310"><a href="#Parser-2310"><span class="linenos">2310</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_unnest</span><span class="p">()</span> -</span><span id="Parser-2311"><a href="#Parser-2311"><span class="linenos">2311</span></a> <span class="k">if</span> <span class="n">unnest</span><span class="p">:</span> -</span><span id="Parser-2312"><a href="#Parser-2312"><span class="linenos">2312</span></a> <span class="k">return</span> <span class="n">unnest</span> +</span><span id="Parser-2303"><a href="#Parser-2303"><span class="linenos">2303</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><span id="Parser-2304"><a href="#Parser-2304"><span class="linenos">2304</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="n">db</span><span class="p">,</span> <span class="n">catalog</span><span class="o">=</span><span class="n">catalog</span><span class="p">,</span> <span class="n">pivots</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivots</span><span class="p">()</span> +</span><span id="Parser-2305"><a href="#Parser-2305"><span class="linenos">2305</span></a> <span class="p">)</span> +</span><span id="Parser-2306"><a href="#Parser-2306"><span class="linenos">2306</span></a> +</span><span id="Parser-2307"><a href="#Parser-2307"><span class="linenos">2307</span></a> <span class="k">def</span> <span class="nf">_parse_table</span><span class="p">(</span> +</span><span id="Parser-2308"><a href="#Parser-2308"><span class="linenos">2308</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">schema</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="n">alias_tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2309"><a href="#Parser-2309"><span class="linenos">2309</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="Parser-2310"><a href="#Parser-2310"><span class="linenos">2310</span></a> <span class="n">lateral</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lateral</span><span class="p">()</span> +</span><span id="Parser-2311"><a href="#Parser-2311"><span class="linenos">2311</span></a> <span class="k">if</span> <span class="n">lateral</span><span class="p">:</span> +</span><span id="Parser-2312"><a href="#Parser-2312"><span class="linenos">2312</span></a> <span class="k">return</span> <span class="n">lateral</span> </span><span id="Parser-2313"><a href="#Parser-2313"><span class="linenos">2313</span></a> -</span><span id="Parser-2314"><a href="#Parser-2314"><span class="linenos">2314</span></a> <span class="n">values</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_derived_table_values</span><span class="p">()</span> -</span><span id="Parser-2315"><a href="#Parser-2315"><span class="linenos">2315</span></a> <span class="k">if</span> <span class="n">values</span><span class="p">:</span> -</span><span id="Parser-2316"><a href="#Parser-2316"><span class="linenos">2316</span></a> <span class="k">return</span> <span class="n">values</span> +</span><span id="Parser-2314"><a href="#Parser-2314"><span class="linenos">2314</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_unnest</span><span class="p">()</span> +</span><span id="Parser-2315"><a href="#Parser-2315"><span class="linenos">2315</span></a> <span class="k">if</span> <span class="n">unnest</span><span class="p">:</span> +</span><span id="Parser-2316"><a href="#Parser-2316"><span class="linenos">2316</span></a> <span class="k">return</span> <span class="n">unnest</span> </span><span id="Parser-2317"><a href="#Parser-2317"><span class="linenos">2317</span></a> -</span><span id="Parser-2318"><a href="#Parser-2318"><span class="linenos">2318</span></a> <span class="n">subquery</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-2319"><a href="#Parser-2319"><span class="linenos">2319</span></a> <span class="k">if</span> <span class="n">subquery</span><span class="p">:</span> -</span><span id="Parser-2320"><a href="#Parser-2320"><span class="linenos">2320</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">subquery</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">):</span> -</span><span id="Parser-2321"><a href="#Parser-2321"><span class="linenos">2321</span></a> <span class="n">subquery</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivots</span><span class="p">())</span> -</span><span id="Parser-2322"><a href="#Parser-2322"><span class="linenos">2322</span></a> <span class="k">return</span> <span class="n">subquery</span> -</span><span id="Parser-2323"><a href="#Parser-2323"><span class="linenos">2323</span></a> -</span><span id="Parser-2324"><a href="#Parser-2324"><span class="linenos">2324</span></a> <span class="n">this</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="Parser-2325"><a href="#Parser-2325"><span class="linenos">2325</span></a> -</span><span id="Parser-2326"><a href="#Parser-2326"><span class="linenos">2326</span></a> <span class="k">if</span> <span class="n">schema</span><span class="p">:</span> -</span><span id="Parser-2327"><a href="#Parser-2327"><span class="linenos">2327</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-2328"><a href="#Parser-2328"><span class="linenos">2328</span></a> -</span><span id="Parser-2329"><a href="#Parser-2329"><span class="linenos">2329</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span><span class="p">:</span> -</span><span id="Parser-2330"><a href="#Parser-2330"><span class="linenos">2330</span></a> <span class="n">table_sample</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_sample</span><span class="p">()</span> -</span><span id="Parser-2331"><a href="#Parser-2331"><span class="linenos">2331</span></a> -</span><span id="Parser-2332"><a href="#Parser-2332"><span class="linenos">2332</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">(</span><span class="n">alias_tokens</span><span class="o">=</span><span class="n">alias_tokens</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_ALIAS_TOKENS</span><span class="p">)</span> -</span><span id="Parser-2333"><a href="#Parser-2333"><span class="linenos">2333</span></a> <span class="k">if</span> <span class="n">alias</span><span class="p">:</span> -</span><span id="Parser-2334"><a href="#Parser-2334"><span class="linenos">2334</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="n">alias</span><span class="p">)</span> +</span><span id="Parser-2318"><a href="#Parser-2318"><span class="linenos">2318</span></a> <span class="n">values</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_derived_table_values</span><span class="p">()</span> +</span><span id="Parser-2319"><a href="#Parser-2319"><span class="linenos">2319</span></a> <span class="k">if</span> <span class="n">values</span><span class="p">:</span> +</span><span id="Parser-2320"><a href="#Parser-2320"><span class="linenos">2320</span></a> <span class="k">return</span> <span class="n">values</span> +</span><span id="Parser-2321"><a href="#Parser-2321"><span class="linenos">2321</span></a> +</span><span id="Parser-2322"><a href="#Parser-2322"><span class="linenos">2322</span></a> <span class="n">subquery</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">table</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-2323"><a href="#Parser-2323"><span class="linenos">2323</span></a> <span class="k">if</span> <span class="n">subquery</span><span class="p">:</span> +</span><span id="Parser-2324"><a href="#Parser-2324"><span class="linenos">2324</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">subquery</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">):</span> +</span><span id="Parser-2325"><a href="#Parser-2325"><span class="linenos">2325</span></a> <span class="n">subquery</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivots</span><span class="p">())</span> +</span><span id="Parser-2326"><a href="#Parser-2326"><span class="linenos">2326</span></a> <span class="k">return</span> <span class="n">subquery</span> +</span><span id="Parser-2327"><a href="#Parser-2327"><span class="linenos">2327</span></a> +</span><span id="Parser-2328"><a href="#Parser-2328"><span class="linenos">2328</span></a> <span class="n">this</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_parts</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="Parser-2329"><a href="#Parser-2329"><span class="linenos">2329</span></a> +</span><span id="Parser-2330"><a href="#Parser-2330"><span class="linenos">2330</span></a> <span class="k">if</span> <span class="n">schema</span><span class="p">:</span> +</span><span id="Parser-2331"><a href="#Parser-2331"><span class="linenos">2331</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_schema</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-2332"><a href="#Parser-2332"><span class="linenos">2332</span></a> +</span><span id="Parser-2333"><a href="#Parser-2333"><span class="linenos">2333</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span><span class="p">:</span> +</span><span id="Parser-2334"><a href="#Parser-2334"><span class="linenos">2334</span></a> <span class="n">table_sample</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_sample</span><span class="p">()</span> </span><span id="Parser-2335"><a href="#Parser-2335"><span class="linenos">2335</span></a> -</span><span id="Parser-2336"><a href="#Parser-2336"><span class="linenos">2336</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">):</span> -</span><span id="Parser-2337"><a href="#Parser-2337"><span class="linenos">2337</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivots</span><span class="p">())</span> -</span><span id="Parser-2338"><a href="#Parser-2338"><span class="linenos">2338</span></a> -</span><span id="Parser-2339"><a href="#Parser-2339"><span class="linenos">2339</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">):</span> -</span><span id="Parser-2340"><a href="#Parser-2340"><span class="linenos">2340</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="Parser-2341"><a href="#Parser-2341"><span class="linenos">2341</span></a> <span class="s2">"hints"</span><span class="p">,</span> -</span><span id="Parser-2342"><a href="#Parser-2342"><span class="linenos">2342</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)),</span> -</span><span id="Parser-2343"><a href="#Parser-2343"><span class="linenos">2343</span></a> <span class="p">)</span> -</span><span id="Parser-2344"><a href="#Parser-2344"><span class="linenos">2344</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="Parser-2345"><a href="#Parser-2345"><span class="linenos">2345</span></a> -</span><span id="Parser-2346"><a href="#Parser-2346"><span class="linenos">2346</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span><span class="p">:</span> -</span><span id="Parser-2347"><a href="#Parser-2347"><span class="linenos">2347</span></a> <span class="n">table_sample</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_sample</span><span class="p">()</span> -</span><span id="Parser-2348"><a href="#Parser-2348"><span class="linenos">2348</span></a> -</span><span id="Parser-2349"><a href="#Parser-2349"><span class="linenos">2349</span></a> <span class="k">if</span> <span class="n">table_sample</span><span class="p">:</span> -</span><span id="Parser-2350"><a href="#Parser-2350"><span class="linenos">2350</span></a> <span class="n">table_sample</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">this</span><span class="p">)</span> -</span><span id="Parser-2351"><a href="#Parser-2351"><span class="linenos">2351</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">table_sample</span> +</span><span id="Parser-2336"><a href="#Parser-2336"><span class="linenos">2336</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">(</span><span class="n">alias_tokens</span><span class="o">=</span><span class="n">alias_tokens</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">TABLE_ALIAS_TOKENS</span><span class="p">)</span> +</span><span id="Parser-2337"><a href="#Parser-2337"><span class="linenos">2337</span></a> <span class="k">if</span> <span class="n">alias</span><span class="p">:</span> +</span><span id="Parser-2338"><a href="#Parser-2338"><span class="linenos">2338</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="n">alias</span><span class="p">)</span> +</span><span id="Parser-2339"><a href="#Parser-2339"><span class="linenos">2339</span></a> +</span><span id="Parser-2340"><a href="#Parser-2340"><span class="linenos">2340</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">):</span> +</span><span id="Parser-2341"><a href="#Parser-2341"><span class="linenos">2341</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"pivots"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivots</span><span class="p">())</span> +</span><span id="Parser-2342"><a href="#Parser-2342"><span class="linenos">2342</span></a> +</span><span id="Parser-2343"><a href="#Parser-2343"><span class="linenos">2343</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">):</span> +</span><span id="Parser-2344"><a href="#Parser-2344"><span class="linenos">2344</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="Parser-2345"><a href="#Parser-2345"><span class="linenos">2345</span></a> <span class="s2">"hints"</span><span class="p">,</span> +</span><span id="Parser-2346"><a href="#Parser-2346"><span class="linenos">2346</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)),</span> +</span><span id="Parser-2347"><a href="#Parser-2347"><span class="linenos">2347</span></a> <span class="p">)</span> +</span><span id="Parser-2348"><a href="#Parser-2348"><span class="linenos">2348</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-2349"><a href="#Parser-2349"><span class="linenos">2349</span></a> +</span><span id="Parser-2350"><a href="#Parser-2350"><span class="linenos">2350</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALIAS_POST_TABLESAMPLE</span><span class="p">:</span> +</span><span id="Parser-2351"><a href="#Parser-2351"><span class="linenos">2351</span></a> <span class="n">table_sample</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_sample</span><span class="p">()</span> </span><span id="Parser-2352"><a href="#Parser-2352"><span class="linenos">2352</span></a> -</span><span id="Parser-2353"><a href="#Parser-2353"><span class="linenos">2353</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-2354"><a href="#Parser-2354"><span class="linenos">2354</span></a> -</span><span id="Parser-2355"><a href="#Parser-2355"><span class="linenos">2355</span></a> <span class="k">def</span> <span class="nf">_parse_unnest</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">with_alias</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="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">Unnest</span><span class="p">]:</span> -</span><span id="Parser-2356"><a href="#Parser-2356"><span class="linenos">2356</span></a> <span class="k">if</span> <span class="ow">not</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">UNNEST</span><span class="p">):</span> -</span><span id="Parser-2357"><a href="#Parser-2357"><span class="linenos">2357</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2353"><a href="#Parser-2353"><span class="linenos">2353</span></a> <span class="k">if</span> <span class="n">table_sample</span><span class="p">:</span> +</span><span id="Parser-2354"><a href="#Parser-2354"><span class="linenos">2354</span></a> <span class="n">table_sample</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">this</span><span class="p">)</span> +</span><span id="Parser-2355"><a href="#Parser-2355"><span class="linenos">2355</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">table_sample</span> +</span><span id="Parser-2356"><a href="#Parser-2356"><span class="linenos">2356</span></a> +</span><span id="Parser-2357"><a href="#Parser-2357"><span class="linenos">2357</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="Parser-2358"><a href="#Parser-2358"><span class="linenos">2358</span></a> -</span><span id="Parser-2359"><a href="#Parser-2359"><span class="linenos">2359</span></a> <span class="n">expressions</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_type</span><span class="p">)</span> -</span><span id="Parser-2360"><a href="#Parser-2360"><span class="linenos">2360</span></a> <span class="n">ordinality</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ORDINALITY</span><span class="p">)</span> -</span><span id="Parser-2361"><a href="#Parser-2361"><span class="linenos">2361</span></a> -</span><span id="Parser-2362"><a href="#Parser-2362"><span class="linenos">2362</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> <span class="k">if</span> <span class="n">with_alias</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="Parser-2363"><a href="#Parser-2363"><span class="linenos">2363</span></a> -</span><span id="Parser-2364"><a href="#Parser-2364"><span class="linenos">2364</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> -</span><span id="Parser-2365"><a href="#Parser-2365"><span class="linenos">2365</span></a> <span class="k">if</span> <span class="n">alias</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">):</span> -</span><span id="Parser-2366"><a href="#Parser-2366"><span class="linenos">2366</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Unexpected extra column alias in unnest."</span><span class="p">)</span> +</span><span id="Parser-2359"><a href="#Parser-2359"><span class="linenos">2359</span></a> <span class="k">def</span> <span class="nf">_parse_unnest</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">with_alias</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="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">Unnest</span><span class="p">]:</span> +</span><span id="Parser-2360"><a href="#Parser-2360"><span class="linenos">2360</span></a> <span class="k">if</span> <span class="ow">not</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">UNNEST</span><span class="p">):</span> +</span><span id="Parser-2361"><a href="#Parser-2361"><span class="linenos">2361</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2362"><a href="#Parser-2362"><span class="linenos">2362</span></a> +</span><span id="Parser-2363"><a href="#Parser-2363"><span class="linenos">2363</span></a> <span class="n">expressions</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_type</span><span class="p">)</span> +</span><span id="Parser-2364"><a href="#Parser-2364"><span class="linenos">2364</span></a> <span class="n">ordinality</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ORDINALITY</span><span class="p">)</span> +</span><span id="Parser-2365"><a href="#Parser-2365"><span class="linenos">2365</span></a> +</span><span id="Parser-2366"><a href="#Parser-2366"><span class="linenos">2366</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> <span class="k">if</span> <span class="n">with_alias</span> <span class="k">else</span> <span class="kc">None</span> </span><span id="Parser-2367"><a href="#Parser-2367"><span class="linenos">2367</span></a> -</span><span id="Parser-2368"><a href="#Parser-2368"><span class="linenos">2368</span></a> <span class="n">alias</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">,</span> <span class="p">[</span><span class="n">alias</span><span class="o">.</span><span class="n">this</span><span class="p">])</span> -</span><span id="Parser-2369"><a href="#Parser-2369"><span class="linenos">2369</span></a> <span class="n">alias</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="kc">None</span><span class="p">)</span> -</span><span id="Parser-2370"><a href="#Parser-2370"><span class="linenos">2370</span></a> -</span><span id="Parser-2371"><a href="#Parser-2371"><span class="linenos">2371</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2372"><a href="#Parser-2372"><span class="linenos">2372</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OFFSET</span><span class="p">):</span> -</span><span id="Parser-2373"><a href="#Parser-2373"><span class="linenos">2373</span></a> <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">ALIAS</span><span class="p">)</span> -</span><span id="Parser-2374"><a href="#Parser-2374"><span class="linenos">2374</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> <span class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">)</span> -</span><span id="Parser-2375"><a href="#Parser-2375"><span class="linenos">2375</span></a> -</span><span id="Parser-2376"><a href="#Parser-2376"><span class="linenos">2376</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><span id="Parser-2377"><a href="#Parser-2377"><span class="linenos">2377</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">ordinality</span><span class="o">=</span><span class="n">ordinality</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">,</span> <span class="n">offset</span><span class="o">=</span><span class="n">offset</span> -</span><span id="Parser-2378"><a href="#Parser-2378"><span class="linenos">2378</span></a> <span class="p">)</span> +</span><span id="Parser-2368"><a href="#Parser-2368"><span class="linenos">2368</span></a> <span class="k">if</span> <span class="n">alias</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNNEST_COLUMN_ONLY</span><span class="p">:</span> +</span><span id="Parser-2369"><a href="#Parser-2369"><span class="linenos">2369</span></a> <span class="k">if</span> <span class="n">alias</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">):</span> +</span><span id="Parser-2370"><a href="#Parser-2370"><span class="linenos">2370</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Unexpected extra column alias in unnest."</span><span class="p">)</span> +</span><span id="Parser-2371"><a href="#Parser-2371"><span class="linenos">2371</span></a> +</span><span id="Parser-2372"><a href="#Parser-2372"><span class="linenos">2372</span></a> <span class="n">alias</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">,</span> <span class="p">[</span><span class="n">alias</span><span class="o">.</span><span class="n">this</span><span class="p">])</span> +</span><span id="Parser-2373"><a href="#Parser-2373"><span class="linenos">2373</span></a> <span class="n">alias</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="kc">None</span><span class="p">)</span> +</span><span id="Parser-2374"><a href="#Parser-2374"><span class="linenos">2374</span></a> +</span><span id="Parser-2375"><a href="#Parser-2375"><span class="linenos">2375</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2376"><a href="#Parser-2376"><span class="linenos">2376</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OFFSET</span><span class="p">):</span> +</span><span id="Parser-2377"><a href="#Parser-2377"><span class="linenos">2377</span></a> <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">ALIAS</span><span class="p">)</span> +</span><span id="Parser-2378"><a href="#Parser-2378"><span class="linenos">2378</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> <span class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="s2">"offset"</span><span class="p">)</span> </span><span id="Parser-2379"><a href="#Parser-2379"><span class="linenos">2379</span></a> -</span><span id="Parser-2380"><a href="#Parser-2380"><span class="linenos">2380</span></a> <span class="k">def</span> <span class="nf">_parse_derived_table_values</span><span class="p">(</span><span class="bp">self</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">Values</span><span class="p">]:</span> -</span><span id="Parser-2381"><a href="#Parser-2381"><span class="linenos">2381</span></a> <span class="n">is_derived</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VALUES</span><span class="p">)</span> -</span><span id="Parser-2382"><a href="#Parser-2382"><span class="linenos">2382</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">is_derived</span> <span class="ow">and</span> <span class="ow">not</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">VALUES</span><span class="p">):</span> -</span><span id="Parser-2383"><a href="#Parser-2383"><span class="linenos">2383</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-2384"><a href="#Parser-2384"><span class="linenos">2384</span></a> -</span><span id="Parser-2385"><a href="#Parser-2385"><span class="linenos">2385</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">)</span> -</span><span id="Parser-2386"><a href="#Parser-2386"><span class="linenos">2386</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> -</span><span id="Parser-2387"><a href="#Parser-2387"><span class="linenos">2387</span></a> -</span><span id="Parser-2388"><a href="#Parser-2388"><span class="linenos">2388</span></a> <span class="k">if</span> <span class="n">is_derived</span><span class="p">:</span> -</span><span id="Parser-2389"><a href="#Parser-2389"><span class="linenos">2389</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="Parser-2390"><a href="#Parser-2390"><span class="linenos">2390</span></a> -</span><span id="Parser-2391"><a href="#Parser-2391"><span class="linenos">2391</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><span id="Parser-2392"><a href="#Parser-2392"><span class="linenos">2392</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> -</span><span id="Parser-2393"><a href="#Parser-2393"><span class="linenos">2393</span></a> <span class="p">)</span> +</span><span id="Parser-2380"><a href="#Parser-2380"><span class="linenos">2380</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><span id="Parser-2381"><a href="#Parser-2381"><span class="linenos">2381</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">ordinality</span><span class="o">=</span><span class="n">ordinality</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">,</span> <span class="n">offset</span><span class="o">=</span><span class="n">offset</span> +</span><span id="Parser-2382"><a href="#Parser-2382"><span class="linenos">2382</span></a> <span class="p">)</span> +</span><span id="Parser-2383"><a href="#Parser-2383"><span class="linenos">2383</span></a> +</span><span id="Parser-2384"><a href="#Parser-2384"><span class="linenos">2384</span></a> <span class="k">def</span> <span class="nf">_parse_derived_table_values</span><span class="p">(</span><span class="bp">self</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">Values</span><span class="p">]:</span> +</span><span id="Parser-2385"><a href="#Parser-2385"><span class="linenos">2385</span></a> <span class="n">is_derived</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VALUES</span><span class="p">)</span> +</span><span id="Parser-2386"><a href="#Parser-2386"><span class="linenos">2386</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">is_derived</span> <span class="ow">and</span> <span class="ow">not</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">VALUES</span><span class="p">):</span> +</span><span id="Parser-2387"><a href="#Parser-2387"><span class="linenos">2387</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2388"><a href="#Parser-2388"><span class="linenos">2388</span></a> +</span><span id="Parser-2389"><a href="#Parser-2389"><span class="linenos">2389</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">)</span> +</span><span id="Parser-2390"><a href="#Parser-2390"><span class="linenos">2390</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> +</span><span id="Parser-2391"><a href="#Parser-2391"><span class="linenos">2391</span></a> +</span><span id="Parser-2392"><a href="#Parser-2392"><span class="linenos">2392</span></a> <span class="k">if</span> <span class="n">is_derived</span><span class="p">:</span> +</span><span id="Parser-2393"><a href="#Parser-2393"><span class="linenos">2393</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> </span><span id="Parser-2394"><a href="#Parser-2394"><span class="linenos">2394</span></a> -</span><span id="Parser-2395"><a href="#Parser-2395"><span class="linenos">2395</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="Parser-2396"><a href="#Parser-2396"><span class="linenos">2396</span></a> <span class="k">if</span> <span class="ow">not</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">TABLE_SAMPLE</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="p">(</span> -</span><span id="Parser-2397"><a href="#Parser-2397"><span class="linenos">2397</span></a> <span class="n">as_modifier</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"USING"</span><span class="p">,</span> <span class="s2">"SAMPLE"</span><span class="p">)</span> -</span><span id="Parser-2398"><a href="#Parser-2398"><span class="linenos">2398</span></a> <span class="p">):</span> -</span><span id="Parser-2399"><a href="#Parser-2399"><span class="linenos">2399</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-2400"><a href="#Parser-2400"><span class="linenos">2400</span></a> -</span><span id="Parser-2401"><a href="#Parser-2401"><span class="linenos">2401</span></a> <span class="n">bucket_numerator</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2402"><a href="#Parser-2402"><span class="linenos">2402</span></a> <span class="n">bucket_denominator</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2403"><a href="#Parser-2403"><span class="linenos">2403</span></a> <span class="n">bucket_field</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2404"><a href="#Parser-2404"><span class="linenos">2404</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2405"><a href="#Parser-2405"><span class="linenos">2405</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2406"><a href="#Parser-2406"><span class="linenos">2406</span></a> <span class="n">size</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2407"><a href="#Parser-2407"><span class="linenos">2407</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2408"><a href="#Parser-2408"><span class="linenos">2408</span></a> -</span><span id="Parser-2409"><a href="#Parser-2409"><span class="linenos">2409</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Parser-2410"><a href="#Parser-2410"><span class="linenos">2410</span></a> <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="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span> <span class="k">else</span> <span class="s2">"USING SAMPLE"</span> -</span><span id="Parser-2411"><a href="#Parser-2411"><span class="linenos">2411</span></a> <span class="p">)</span> -</span><span id="Parser-2412"><a href="#Parser-2412"><span class="linenos">2412</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">(</span><span class="n">tokens</span><span class="o">=</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,))</span> -</span><span id="Parser-2413"><a href="#Parser-2413"><span class="linenos">2413</span></a> -</span><span id="Parser-2414"><a href="#Parser-2414"><span class="linenos">2414</span></a> <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_PAREN</span><span class="p">)</span> -</span><span id="Parser-2415"><a href="#Parser-2415"><span class="linenos">2415</span></a> -</span><span id="Parser-2416"><a href="#Parser-2416"><span class="linenos">2416</span></a> <span class="n">num</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> +</span><span id="Parser-2395"><a href="#Parser-2395"><span class="linenos">2395</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><span id="Parser-2396"><a href="#Parser-2396"><span class="linenos">2396</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Values</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">()</span> +</span><span id="Parser-2397"><a href="#Parser-2397"><span class="linenos">2397</span></a> <span class="p">)</span> +</span><span id="Parser-2398"><a href="#Parser-2398"><span class="linenos">2398</span></a> +</span><span id="Parser-2399"><a href="#Parser-2399"><span class="linenos">2399</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="Parser-2400"><a href="#Parser-2400"><span class="linenos">2400</span></a> <span class="k">if</span> <span class="ow">not</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">TABLE_SAMPLE</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="p">(</span> +</span><span id="Parser-2401"><a href="#Parser-2401"><span class="linenos">2401</span></a> <span class="n">as_modifier</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"USING"</span><span class="p">,</span> <span class="s2">"SAMPLE"</span><span class="p">)</span> +</span><span id="Parser-2402"><a href="#Parser-2402"><span class="linenos">2402</span></a> <span class="p">):</span> +</span><span id="Parser-2403"><a href="#Parser-2403"><span class="linenos">2403</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2404"><a href="#Parser-2404"><span class="linenos">2404</span></a> +</span><span id="Parser-2405"><a href="#Parser-2405"><span class="linenos">2405</span></a> <span class="n">bucket_numerator</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2406"><a href="#Parser-2406"><span class="linenos">2406</span></a> <span class="n">bucket_denominator</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2407"><a href="#Parser-2407"><span class="linenos">2407</span></a> <span class="n">bucket_field</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2408"><a href="#Parser-2408"><span class="linenos">2408</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2409"><a href="#Parser-2409"><span class="linenos">2409</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2410"><a href="#Parser-2410"><span class="linenos">2410</span></a> <span class="n">size</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2411"><a href="#Parser-2411"><span class="linenos">2411</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2412"><a href="#Parser-2412"><span class="linenos">2412</span></a> +</span><span id="Parser-2413"><a href="#Parser-2413"><span class="linenos">2413</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Parser-2414"><a href="#Parser-2414"><span class="linenos">2414</span></a> <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="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span> <span class="k">else</span> <span class="s2">"USING SAMPLE"</span> +</span><span id="Parser-2415"><a href="#Parser-2415"><span class="linenos">2415</span></a> <span class="p">)</span> +</span><span id="Parser-2416"><a href="#Parser-2416"><span class="linenos">2416</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">(</span><span class="n">tokens</span><span class="o">=</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,))</span> </span><span id="Parser-2417"><a href="#Parser-2417"><span class="linenos">2417</span></a> -</span><span id="Parser-2418"><a href="#Parser-2418"><span class="linenos">2418</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BUCKET"</span><span class="p">):</span> -</span><span id="Parser-2419"><a href="#Parser-2419"><span class="linenos">2419</span></a> <span class="n">bucket_numerator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> -</span><span id="Parser-2420"><a href="#Parser-2420"><span class="linenos">2420</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OUT"</span><span class="p">,</span> <span class="s2">"OF"</span><span class="p">)</span> -</span><span id="Parser-2421"><a href="#Parser-2421"><span class="linenos">2421</span></a> <span class="n">bucket_denominator</span> <span class="o">=</span> <span class="n">bucket_denominator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> -</span><span id="Parser-2422"><a href="#Parser-2422"><span class="linenos">2422</span></a> <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">ON</span><span class="p">)</span> -</span><span id="Parser-2423"><a href="#Parser-2423"><span class="linenos">2423</span></a> <span class="n">bucket_field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> -</span><span id="Parser-2424"><a href="#Parser-2424"><span class="linenos">2424</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">PERCENT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MOD</span><span class="p">)):</span> -</span><span id="Parser-2425"><a href="#Parser-2425"><span class="linenos">2425</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="n">num</span> -</span><span id="Parser-2426"><a href="#Parser-2426"><span class="linenos">2426</span></a> <span class="k">elif</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">ROWS</span><span class="p">):</span> -</span><span id="Parser-2427"><a href="#Parser-2427"><span class="linenos">2427</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="n">num</span> -</span><span id="Parser-2428"><a href="#Parser-2428"><span class="linenos">2428</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2429"><a href="#Parser-2429"><span class="linenos">2429</span></a> <span class="n">size</span> <span class="o">=</span> <span class="n">num</span> -</span><span id="Parser-2430"><a href="#Parser-2430"><span class="linenos">2430</span></a> -</span><span id="Parser-2431"><a href="#Parser-2431"><span class="linenos">2431</span></a> <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">R_PAREN</span><span class="p">)</span> -</span><span id="Parser-2432"><a href="#Parser-2432"><span class="linenos">2432</span></a> -</span><span id="Parser-2433"><a href="#Parser-2433"><span class="linenos">2433</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_PAREN</span><span class="p">):</span> -</span><span id="Parser-2434"><a href="#Parser-2434"><span class="linenos">2434</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> -</span><span id="Parser-2435"><a href="#Parser-2435"><span class="linenos">2435</span></a> <span class="n">seed</span> <span class="o">=</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">COMMA</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> -</span><span id="Parser-2436"><a href="#Parser-2436"><span class="linenos">2436</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="Parser-2437"><a href="#Parser-2437"><span class="linenos">2437</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"SEED"</span><span class="p">,</span> <span class="s2">"REPEATABLE"</span><span class="p">)):</span> -</span><span id="Parser-2438"><a href="#Parser-2438"><span class="linenos">2438</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">)</span> -</span><span id="Parser-2439"><a href="#Parser-2439"><span class="linenos">2439</span></a> -</span><span id="Parser-2440"><a href="#Parser-2440"><span class="linenos">2440</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><span id="Parser-2441"><a href="#Parser-2441"><span class="linenos">2441</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> -</span><span id="Parser-2442"><a href="#Parser-2442"><span class="linenos">2442</span></a> <span class="n">method</span><span class="o">=</span><span class="n">method</span><span class="p">,</span> -</span><span id="Parser-2443"><a href="#Parser-2443"><span class="linenos">2443</span></a> <span class="n">bucket_numerator</span><span class="o">=</span><span class="n">bucket_numerator</span><span class="p">,</span> -</span><span id="Parser-2444"><a href="#Parser-2444"><span class="linenos">2444</span></a> <span class="n">bucket_denominator</span><span class="o">=</span><span class="n">bucket_denominator</span><span class="p">,</span> -</span><span id="Parser-2445"><a href="#Parser-2445"><span class="linenos">2445</span></a> <span class="n">bucket_field</span><span class="o">=</span><span class="n">bucket_field</span><span class="p">,</span> -</span><span id="Parser-2446"><a href="#Parser-2446"><span class="linenos">2446</span></a> <span class="n">percent</span><span class="o">=</span><span class="n">percent</span><span class="p">,</span> -</span><span id="Parser-2447"><a href="#Parser-2447"><span class="linenos">2447</span></a> <span class="n">rows</span><span class="o">=</span><span class="n">rows</span><span class="p">,</span> -</span><span id="Parser-2448"><a href="#Parser-2448"><span class="linenos">2448</span></a> <span class="n">size</span><span class="o">=</span><span class="n">size</span><span class="p">,</span> -</span><span id="Parser-2449"><a href="#Parser-2449"><span class="linenos">2449</span></a> <span class="n">seed</span><span class="o">=</span><span class="n">seed</span><span class="p">,</span> -</span><span id="Parser-2450"><a href="#Parser-2450"><span class="linenos">2450</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> -</span><span id="Parser-2451"><a href="#Parser-2451"><span class="linenos">2451</span></a> <span class="p">)</span> -</span><span id="Parser-2452"><a href="#Parser-2452"><span class="linenos">2452</span></a> -</span><span id="Parser-2453"><a href="#Parser-2453"><span class="linenos">2453</span></a> <span class="k">def</span> <span class="nf">_parse_pivots</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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="Parser-2454"><a href="#Parser-2454"><span class="linenos">2454</span></a> <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="nb">iter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivot</span><span class="p">,</span> <span class="kc">None</span><span class="p">))</span> -</span><span id="Parser-2455"><a href="#Parser-2455"><span class="linenos">2455</span></a> -</span><span id="Parser-2456"><a href="#Parser-2456"><span class="linenos">2456</span></a> <span class="c1"># https://duckdb.org/docs/sql/statements/pivot</span> -</span><span id="Parser-2457"><a href="#Parser-2457"><span class="linenos">2457</span></a> <span class="k">def</span> <span class="nf">_parse_simplified_pivot</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">Pivot</span><span class="p">:</span> -</span><span id="Parser-2458"><a href="#Parser-2458"><span class="linenos">2458</span></a> <span class="k">def</span> <span class="nf">_parse_on</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="Parser-2459"><a href="#Parser-2459"><span class="linenos">2459</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="Parser-2460"><a href="#Parser-2460"><span class="linenos">2460</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_in</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> <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">IN</span><span class="p">)</span> <span class="k">else</span> <span class="n">this</span> -</span><span id="Parser-2461"><a href="#Parser-2461"><span class="linenos">2461</span></a> -</span><span id="Parser-2462"><a href="#Parser-2462"><span class="linenos">2462</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> -</span><span id="Parser-2463"><a href="#Parser-2463"><span class="linenos">2463</span></a> <span class="n">expressions</span> <span class="o">=</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">ON</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">_parse_on</span><span class="p">)</span> -</span><span id="Parser-2464"><a href="#Parser-2464"><span class="linenos">2464</span></a> <span class="n">using</span> <span class="o">=</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">USING</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> -</span><span id="Parser-2465"><a href="#Parser-2465"><span class="linenos">2465</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_alias</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">())</span> -</span><span id="Parser-2466"><a href="#Parser-2466"><span class="linenos">2466</span></a> <span class="p">)</span> -</span><span id="Parser-2467"><a href="#Parser-2467"><span class="linenos">2467</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_group</span><span class="p">()</span> -</span><span id="Parser-2468"><a href="#Parser-2468"><span class="linenos">2468</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><span id="Parser-2469"><a href="#Parser-2469"><span class="linenos">2469</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">using</span><span class="o">=</span><span class="n">using</span><span class="p">,</span> <span class="n">group</span><span class="o">=</span><span class="n">group</span> +</span><span id="Parser-2418"><a href="#Parser-2418"><span class="linenos">2418</span></a> <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_PAREN</span><span class="p">)</span> +</span><span id="Parser-2419"><a href="#Parser-2419"><span class="linenos">2419</span></a> +</span><span id="Parser-2420"><a href="#Parser-2420"><span class="linenos">2420</span></a> <span class="n">num</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> +</span><span id="Parser-2421"><a href="#Parser-2421"><span class="linenos">2421</span></a> +</span><span id="Parser-2422"><a href="#Parser-2422"><span class="linenos">2422</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BUCKET"</span><span class="p">):</span> +</span><span id="Parser-2423"><a href="#Parser-2423"><span class="linenos">2423</span></a> <span class="n">bucket_numerator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> +</span><span id="Parser-2424"><a href="#Parser-2424"><span class="linenos">2424</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OUT"</span><span class="p">,</span> <span class="s2">"OF"</span><span class="p">)</span> +</span><span id="Parser-2425"><a href="#Parser-2425"><span class="linenos">2425</span></a> <span class="n">bucket_denominator</span> <span class="o">=</span> <span class="n">bucket_denominator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> +</span><span id="Parser-2426"><a href="#Parser-2426"><span class="linenos">2426</span></a> <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">ON</span><span class="p">)</span> +</span><span id="Parser-2427"><a href="#Parser-2427"><span class="linenos">2427</span></a> <span class="n">bucket_field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> +</span><span id="Parser-2428"><a href="#Parser-2428"><span class="linenos">2428</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">PERCENT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MOD</span><span class="p">)):</span> +</span><span id="Parser-2429"><a href="#Parser-2429"><span class="linenos">2429</span></a> <span class="n">percent</span> <span class="o">=</span> <span class="n">num</span> +</span><span id="Parser-2430"><a href="#Parser-2430"><span class="linenos">2430</span></a> <span class="k">elif</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">ROWS</span><span class="p">):</span> +</span><span id="Parser-2431"><a href="#Parser-2431"><span class="linenos">2431</span></a> <span class="n">rows</span> <span class="o">=</span> <span class="n">num</span> +</span><span id="Parser-2432"><a href="#Parser-2432"><span class="linenos">2432</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2433"><a href="#Parser-2433"><span class="linenos">2433</span></a> <span class="n">size</span> <span class="o">=</span> <span class="n">num</span> +</span><span id="Parser-2434"><a href="#Parser-2434"><span class="linenos">2434</span></a> +</span><span id="Parser-2435"><a href="#Parser-2435"><span class="linenos">2435</span></a> <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">R_PAREN</span><span class="p">)</span> +</span><span id="Parser-2436"><a href="#Parser-2436"><span class="linenos">2436</span></a> +</span><span id="Parser-2437"><a href="#Parser-2437"><span class="linenos">2437</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_PAREN</span><span class="p">):</span> +</span><span id="Parser-2438"><a href="#Parser-2438"><span class="linenos">2438</span></a> <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> +</span><span id="Parser-2439"><a href="#Parser-2439"><span class="linenos">2439</span></a> <span class="n">seed</span> <span class="o">=</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">COMMA</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> +</span><span id="Parser-2440"><a href="#Parser-2440"><span class="linenos">2440</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-2441"><a href="#Parser-2441"><span class="linenos">2441</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"SEED"</span><span class="p">,</span> <span class="s2">"REPEATABLE"</span><span class="p">)):</span> +</span><span id="Parser-2442"><a href="#Parser-2442"><span class="linenos">2442</span></a> <span class="n">seed</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">)</span> +</span><span id="Parser-2443"><a href="#Parser-2443"><span class="linenos">2443</span></a> +</span><span id="Parser-2444"><a href="#Parser-2444"><span class="linenos">2444</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><span id="Parser-2445"><a href="#Parser-2445"><span class="linenos">2445</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">TableSample</span><span class="p">,</span> +</span><span id="Parser-2446"><a href="#Parser-2446"><span class="linenos">2446</span></a> <span class="n">method</span><span class="o">=</span><span class="n">method</span><span class="p">,</span> +</span><span id="Parser-2447"><a href="#Parser-2447"><span class="linenos">2447</span></a> <span class="n">bucket_numerator</span><span class="o">=</span><span class="n">bucket_numerator</span><span class="p">,</span> +</span><span id="Parser-2448"><a href="#Parser-2448"><span class="linenos">2448</span></a> <span class="n">bucket_denominator</span><span class="o">=</span><span class="n">bucket_denominator</span><span class="p">,</span> +</span><span id="Parser-2449"><a href="#Parser-2449"><span class="linenos">2449</span></a> <span class="n">bucket_field</span><span class="o">=</span><span class="n">bucket_field</span><span class="p">,</span> +</span><span id="Parser-2450"><a href="#Parser-2450"><span class="linenos">2450</span></a> <span class="n">percent</span><span class="o">=</span><span class="n">percent</span><span class="p">,</span> +</span><span id="Parser-2451"><a href="#Parser-2451"><span class="linenos">2451</span></a> <span class="n">rows</span><span class="o">=</span><span class="n">rows</span><span class="p">,</span> +</span><span id="Parser-2452"><a href="#Parser-2452"><span class="linenos">2452</span></a> <span class="n">size</span><span class="o">=</span><span class="n">size</span><span class="p">,</span> +</span><span id="Parser-2453"><a href="#Parser-2453"><span class="linenos">2453</span></a> <span class="n">seed</span><span class="o">=</span><span class="n">seed</span><span class="p">,</span> +</span><span id="Parser-2454"><a href="#Parser-2454"><span class="linenos">2454</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> +</span><span id="Parser-2455"><a href="#Parser-2455"><span class="linenos">2455</span></a> <span class="p">)</span> +</span><span id="Parser-2456"><a href="#Parser-2456"><span class="linenos">2456</span></a> +</span><span id="Parser-2457"><a href="#Parser-2457"><span class="linenos">2457</span></a> <span class="k">def</span> <span class="nf">_parse_pivots</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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="Parser-2458"><a href="#Parser-2458"><span class="linenos">2458</span></a> <span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="nb">iter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_pivot</span><span class="p">,</span> <span class="kc">None</span><span class="p">))</span> +</span><span id="Parser-2459"><a href="#Parser-2459"><span class="linenos">2459</span></a> +</span><span id="Parser-2460"><a href="#Parser-2460"><span class="linenos">2460</span></a> <span class="c1"># https://duckdb.org/docs/sql/statements/pivot</span> +</span><span id="Parser-2461"><a href="#Parser-2461"><span class="linenos">2461</span></a> <span class="k">def</span> <span class="nf">_parse_simplified_pivot</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">Pivot</span><span class="p">:</span> +</span><span id="Parser-2462"><a href="#Parser-2462"><span class="linenos">2462</span></a> <span class="k">def</span> <span class="nf">_parse_on</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="Parser-2463"><a href="#Parser-2463"><span class="linenos">2463</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="Parser-2464"><a href="#Parser-2464"><span class="linenos">2464</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_in</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> <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">IN</span><span class="p">)</span> <span class="k">else</span> <span class="n">this</span> +</span><span id="Parser-2465"><a href="#Parser-2465"><span class="linenos">2465</span></a> +</span><span id="Parser-2466"><a href="#Parser-2466"><span class="linenos">2466</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> +</span><span id="Parser-2467"><a href="#Parser-2467"><span class="linenos">2467</span></a> <span class="n">expressions</span> <span class="o">=</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">ON</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">_parse_on</span><span class="p">)</span> +</span><span id="Parser-2468"><a href="#Parser-2468"><span class="linenos">2468</span></a> <span class="n">using</span> <span class="o">=</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">USING</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> +</span><span id="Parser-2469"><a href="#Parser-2469"><span class="linenos">2469</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_alias</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">())</span> </span><span id="Parser-2470"><a href="#Parser-2470"><span class="linenos">2470</span></a> <span class="p">)</span> -</span><span id="Parser-2471"><a href="#Parser-2471"><span class="linenos">2471</span></a> -</span><span id="Parser-2472"><a href="#Parser-2472"><span class="linenos">2472</span></a> <span class="k">def</span> <span class="nf">_parse_pivot</span><span class="p">(</span><span class="bp">self</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">Pivot</span><span class="p">]:</span> -</span><span id="Parser-2473"><a href="#Parser-2473"><span class="linenos">2473</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="Parser-2474"><a href="#Parser-2474"><span class="linenos">2474</span></a> -</span><span id="Parser-2475"><a href="#Parser-2475"><span class="linenos">2475</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">PIVOT</span><span class="p">):</span> -</span><span id="Parser-2476"><a href="#Parser-2476"><span class="linenos">2476</span></a> <span class="n">unpivot</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-2477"><a href="#Parser-2477"><span class="linenos">2477</span></a> <span class="k">elif</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">UNPIVOT</span><span class="p">):</span> -</span><span id="Parser-2478"><a href="#Parser-2478"><span class="linenos">2478</span></a> <span class="n">unpivot</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Parser-2479"><a href="#Parser-2479"><span class="linenos">2479</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2480"><a href="#Parser-2480"><span class="linenos">2480</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-2481"><a href="#Parser-2481"><span class="linenos">2481</span></a> -</span><span id="Parser-2482"><a href="#Parser-2482"><span class="linenos">2482</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-2483"><a href="#Parser-2483"><span class="linenos">2483</span></a> <span class="n">field</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2484"><a href="#Parser-2484"><span class="linenos">2484</span></a> -</span><span id="Parser-2485"><a href="#Parser-2485"><span class="linenos">2485</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">):</span> -</span><span id="Parser-2486"><a href="#Parser-2486"><span class="linenos">2486</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-2487"><a href="#Parser-2487"><span class="linenos">2487</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2471"><a href="#Parser-2471"><span class="linenos">2471</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_group</span><span class="p">()</span> +</span><span id="Parser-2472"><a href="#Parser-2472"><span class="linenos">2472</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><span id="Parser-2473"><a href="#Parser-2473"><span class="linenos">2473</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Pivot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">using</span><span class="o">=</span><span class="n">using</span><span class="p">,</span> <span class="n">group</span><span class="o">=</span><span class="n">group</span> +</span><span id="Parser-2474"><a href="#Parser-2474"><span class="linenos">2474</span></a> <span class="p">)</span> +</span><span id="Parser-2475"><a href="#Parser-2475"><span class="linenos">2475</span></a> +</span><span id="Parser-2476"><a href="#Parser-2476"><span class="linenos">2476</span></a> <span class="k">def</span> <span class="nf">_parse_pivot</span><span class="p">(</span><span class="bp">self</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">Pivot</span><span class="p">]:</span> +</span><span id="Parser-2477"><a href="#Parser-2477"><span class="linenos">2477</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="Parser-2478"><a href="#Parser-2478"><span class="linenos">2478</span></a> +</span><span id="Parser-2479"><a href="#Parser-2479"><span class="linenos">2479</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">PIVOT</span><span class="p">):</span> +</span><span id="Parser-2480"><a href="#Parser-2480"><span class="linenos">2480</span></a> <span class="n">unpivot</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-2481"><a href="#Parser-2481"><span class="linenos">2481</span></a> <span class="k">elif</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">UNPIVOT</span><span class="p">):</span> +</span><span id="Parser-2482"><a href="#Parser-2482"><span class="linenos">2482</span></a> <span class="n">unpivot</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Parser-2483"><a href="#Parser-2483"><span class="linenos">2483</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2484"><a href="#Parser-2484"><span class="linenos">2484</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2485"><a href="#Parser-2485"><span class="linenos">2485</span></a> +</span><span id="Parser-2486"><a href="#Parser-2486"><span class="linenos">2486</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-2487"><a href="#Parser-2487"><span class="linenos">2487</span></a> <span class="n">field</span> <span class="o">=</span> <span class="kc">None</span> </span><span id="Parser-2488"><a href="#Parser-2488"><span class="linenos">2488</span></a> -</span><span id="Parser-2489"><a href="#Parser-2489"><span class="linenos">2489</span></a> <span class="k">if</span> <span class="n">unpivot</span><span class="p">:</span> -</span><span id="Parser-2490"><a href="#Parser-2490"><span class="linenos">2490</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">)</span> -</span><span id="Parser-2491"><a href="#Parser-2491"><span class="linenos">2491</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2492"><a href="#Parser-2492"><span class="linenos">2492</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_alias</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()))</span> -</span><span id="Parser-2493"><a href="#Parser-2493"><span class="linenos">2493</span></a> -</span><span id="Parser-2494"><a href="#Parser-2494"><span class="linenos">2494</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="Parser-2495"><a href="#Parser-2495"><span class="linenos">2495</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Failed to parse PIVOT's aggregation list"</span><span class="p">)</span> -</span><span id="Parser-2496"><a href="#Parser-2496"><span class="linenos">2496</span></a> -</span><span id="Parser-2497"><a href="#Parser-2497"><span class="linenos">2497</span></a> <span class="k">if</span> <span class="ow">not</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">FOR</span><span class="p">):</span> -</span><span id="Parser-2498"><a href="#Parser-2498"><span class="linenos">2498</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting FOR"</span><span class="p">)</span> -</span><span id="Parser-2499"><a href="#Parser-2499"><span class="linenos">2499</span></a> -</span><span id="Parser-2500"><a href="#Parser-2500"><span class="linenos">2500</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> -</span><span id="Parser-2501"><a href="#Parser-2501"><span class="linenos">2501</span></a> -</span><span id="Parser-2502"><a href="#Parser-2502"><span class="linenos">2502</span></a> <span class="k">if</span> <span class="ow">not</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">IN</span><span class="p">):</span> -</span><span id="Parser-2503"><a href="#Parser-2503"><span class="linenos">2503</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting IN"</span><span class="p">)</span> -</span><span id="Parser-2504"><a href="#Parser-2504"><span class="linenos">2504</span></a> -</span><span id="Parser-2505"><a href="#Parser-2505"><span class="linenos">2505</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_in</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-2506"><a href="#Parser-2506"><span class="linenos">2506</span></a> -</span><span id="Parser-2507"><a href="#Parser-2507"><span class="linenos">2507</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-2489"><a href="#Parser-2489"><span class="linenos">2489</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">):</span> +</span><span id="Parser-2490"><a href="#Parser-2490"><span class="linenos">2490</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-2491"><a href="#Parser-2491"><span class="linenos">2491</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2492"><a href="#Parser-2492"><span class="linenos">2492</span></a> +</span><span id="Parser-2493"><a href="#Parser-2493"><span class="linenos">2493</span></a> <span class="k">if</span> <span class="n">unpivot</span><span class="p">:</span> +</span><span id="Parser-2494"><a href="#Parser-2494"><span class="linenos">2494</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">)</span> +</span><span id="Parser-2495"><a href="#Parser-2495"><span class="linenos">2495</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2496"><a href="#Parser-2496"><span class="linenos">2496</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_alias</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()))</span> +</span><span id="Parser-2497"><a href="#Parser-2497"><span class="linenos">2497</span></a> +</span><span id="Parser-2498"><a href="#Parser-2498"><span class="linenos">2498</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="Parser-2499"><a href="#Parser-2499"><span class="linenos">2499</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Failed to parse PIVOT's aggregation list"</span><span class="p">)</span> +</span><span id="Parser-2500"><a href="#Parser-2500"><span class="linenos">2500</span></a> +</span><span id="Parser-2501"><a href="#Parser-2501"><span class="linenos">2501</span></a> <span class="k">if</span> <span class="ow">not</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">FOR</span><span class="p">):</span> +</span><span id="Parser-2502"><a href="#Parser-2502"><span class="linenos">2502</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting FOR"</span><span class="p">)</span> +</span><span id="Parser-2503"><a href="#Parser-2503"><span class="linenos">2503</span></a> +</span><span id="Parser-2504"><a href="#Parser-2504"><span class="linenos">2504</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> +</span><span id="Parser-2505"><a href="#Parser-2505"><span class="linenos">2505</span></a> +</span><span id="Parser-2506"><a href="#Parser-2506"><span class="linenos">2506</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IN</span><span class="p">):</span> +</span><span id="Parser-2507"><a href="#Parser-2507"><span class="linenos">2507</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting IN"</span><span class="p">)</span> </span><span id="Parser-2508"><a href="#Parser-2508"><span class="linenos">2508</span></a> -</span><span id="Parser-2509"><a href="#Parser-2509"><span class="linenos">2509</span></a> <span class="n">pivot</span> <span class="o">=</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">Pivot</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">field</span><span class="o">=</span><span class="n">field</span><span class="p">,</span> <span class="n">unpivot</span><span class="o">=</span><span class="n">unpivot</span><span class="p">)</span> +</span><span id="Parser-2509"><a href="#Parser-2509"><span class="linenos">2509</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_in</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span><span id="Parser-2510"><a href="#Parser-2510"><span class="linenos">2510</span></a> -</span><span id="Parser-2511"><a href="#Parser-2511"><span class="linenos">2511</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">PIVOT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNPIVOT</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="Parser-2512"><a href="#Parser-2512"><span class="linenos">2512</span></a> <span class="n">pivot</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">())</span> -</span><span id="Parser-2513"><a href="#Parser-2513"><span class="linenos">2513</span></a> -</span><span id="Parser-2514"><a href="#Parser-2514"><span class="linenos">2514</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">unpivot</span><span class="p">:</span> -</span><span id="Parser-2515"><a href="#Parser-2515"><span class="linenos">2515</span></a> <span class="n">names</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_pivot_column_names</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">cast</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="n">expressions</span><span class="p">))</span> -</span><span id="Parser-2516"><a href="#Parser-2516"><span class="linenos">2516</span></a> -</span><span id="Parser-2517"><a href="#Parser-2517"><span class="linenos">2517</span></a> <span class="n">columns</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="p">[]</span> -</span><span id="Parser-2518"><a href="#Parser-2518"><span class="linenos">2518</span></a> <span class="k">for</span> <span class="n">fld</span> <span class="ow">in</span> <span class="n">pivot</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"field"</span><span class="p">]</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Parser-2519"><a href="#Parser-2519"><span class="linenos">2519</span></a> <span class="n">field_name</span> <span class="o">=</span> <span class="n">fld</span><span class="o">.</span><span class="n">sql</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFY_PIVOT_STRINGS</span> <span class="k">else</span> <span class="n">fld</span><span class="o">.</span><span class="n">alias_or_name</span> -</span><span id="Parser-2520"><a href="#Parser-2520"><span class="linenos">2520</span></a> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">names</span><span class="p">:</span> -</span><span id="Parser-2521"><a href="#Parser-2521"><span class="linenos">2521</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">PREFIXED_PIVOT_COLUMNS</span><span class="p">:</span> -</span><span id="Parser-2522"><a href="#Parser-2522"><span class="linenos">2522</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">field_name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">name</span> <span class="k">else</span> <span class="n">field_name</span> -</span><span id="Parser-2523"><a href="#Parser-2523"><span class="linenos">2523</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2524"><a href="#Parser-2524"><span class="linenos">2524</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">field_name</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">name</span> <span class="k">else</span> <span class="n">field_name</span> -</span><span id="Parser-2525"><a href="#Parser-2525"><span class="linenos">2525</span></a> -</span><span id="Parser-2526"><a href="#Parser-2526"><span class="linenos">2526</span></a> <span class="n">columns</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">name</span><span class="p">))</span> -</span><span id="Parser-2527"><a href="#Parser-2527"><span class="linenos">2527</span></a> -</span><span id="Parser-2528"><a href="#Parser-2528"><span class="linenos">2528</span></a> <span class="n">pivot</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">columns</span><span class="p">)</span> +</span><span id="Parser-2511"><a href="#Parser-2511"><span class="linenos">2511</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-2512"><a href="#Parser-2512"><span class="linenos">2512</span></a> +</span><span id="Parser-2513"><a href="#Parser-2513"><span class="linenos">2513</span></a> <span class="n">pivot</span> <span class="o">=</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">Pivot</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">field</span><span class="o">=</span><span class="n">field</span><span class="p">,</span> <span class="n">unpivot</span><span class="o">=</span><span class="n">unpivot</span><span class="p">)</span> +</span><span id="Parser-2514"><a href="#Parser-2514"><span class="linenos">2514</span></a> +</span><span id="Parser-2515"><a href="#Parser-2515"><span class="linenos">2515</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">PIVOT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNPIVOT</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="Parser-2516"><a href="#Parser-2516"><span class="linenos">2516</span></a> <span class="n">pivot</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"alias"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table_alias</span><span class="p">())</span> +</span><span id="Parser-2517"><a href="#Parser-2517"><span class="linenos">2517</span></a> +</span><span id="Parser-2518"><a href="#Parser-2518"><span class="linenos">2518</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">unpivot</span><span class="p">:</span> +</span><span id="Parser-2519"><a href="#Parser-2519"><span class="linenos">2519</span></a> <span class="n">names</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_pivot_column_names</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">cast</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="n">expressions</span><span class="p">))</span> +</span><span id="Parser-2520"><a href="#Parser-2520"><span class="linenos">2520</span></a> +</span><span id="Parser-2521"><a href="#Parser-2521"><span class="linenos">2521</span></a> <span class="n">columns</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="p">[]</span> +</span><span id="Parser-2522"><a href="#Parser-2522"><span class="linenos">2522</span></a> <span class="k">for</span> <span class="n">fld</span> <span class="ow">in</span> <span class="n">pivot</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"field"</span><span class="p">]</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Parser-2523"><a href="#Parser-2523"><span class="linenos">2523</span></a> <span class="n">field_name</span> <span class="o">=</span> <span class="n">fld</span><span class="o">.</span><span class="n">sql</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFY_PIVOT_STRINGS</span> <span class="k">else</span> <span class="n">fld</span><span class="o">.</span><span class="n">alias_or_name</span> +</span><span id="Parser-2524"><a href="#Parser-2524"><span class="linenos">2524</span></a> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">names</span><span class="p">:</span> +</span><span id="Parser-2525"><a href="#Parser-2525"><span class="linenos">2525</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">PREFIXED_PIVOT_COLUMNS</span><span class="p">:</span> +</span><span id="Parser-2526"><a href="#Parser-2526"><span class="linenos">2526</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">field_name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">name</span> <span class="k">else</span> <span class="n">field_name</span> +</span><span id="Parser-2527"><a href="#Parser-2527"><span class="linenos">2527</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2528"><a href="#Parser-2528"><span class="linenos">2528</span></a> <span class="n">name</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">field_name</span><span class="si">}</span><span class="s2">_</span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">name</span> <span class="k">else</span> <span class="n">field_name</span> </span><span id="Parser-2529"><a href="#Parser-2529"><span class="linenos">2529</span></a> -</span><span id="Parser-2530"><a href="#Parser-2530"><span class="linenos">2530</span></a> <span class="k">return</span> <span class="n">pivot</span> +</span><span id="Parser-2530"><a href="#Parser-2530"><span class="linenos">2530</span></a> <span class="n">columns</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="n">name</span><span class="p">))</span> </span><span id="Parser-2531"><a href="#Parser-2531"><span class="linenos">2531</span></a> -</span><span id="Parser-2532"><a href="#Parser-2532"><span class="linenos">2532</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="Parser-2533"><a href="#Parser-2533"><span class="linenos">2533</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">agg</span><span class="o">.</span><span class="n">alias</span> <span class="k">for</span> <span class="n">agg</span> <span class="ow">in</span> <span class="n">aggregations</span><span class="p">]</span> -</span><span id="Parser-2534"><a href="#Parser-2534"><span class="linenos">2534</span></a> -</span><span id="Parser-2535"><a href="#Parser-2535"><span class="linenos">2535</span></a> <span class="k">def</span> <span class="nf">_parse_where</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_where_token</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">Where</span><span class="p">]:</span> -</span><span id="Parser-2536"><a href="#Parser-2536"><span class="linenos">2536</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_where_token</span> <span class="ow">and</span> <span class="ow">not</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">WHERE</span><span class="p">):</span> -</span><span id="Parser-2537"><a href="#Parser-2537"><span class="linenos">2537</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2532"><a href="#Parser-2532"><span class="linenos">2532</span></a> <span class="n">pivot</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"columns"</span><span class="p">,</span> <span class="n">columns</span><span class="p">)</span> +</span><span id="Parser-2533"><a href="#Parser-2533"><span class="linenos">2533</span></a> +</span><span id="Parser-2534"><a href="#Parser-2534"><span class="linenos">2534</span></a> <span class="k">return</span> <span class="n">pivot</span> +</span><span id="Parser-2535"><a href="#Parser-2535"><span class="linenos">2535</span></a> +</span><span id="Parser-2536"><a href="#Parser-2536"><span class="linenos">2536</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="Parser-2537"><a href="#Parser-2537"><span class="linenos">2537</span></a> <span class="k">return</span> <span class="p">[</span><span class="n">agg</span><span class="o">.</span><span class="n">alias</span> <span class="k">for</span> <span class="n">agg</span> <span class="ow">in</span> <span class="n">aggregations</span><span class="p">]</span> </span><span id="Parser-2538"><a href="#Parser-2538"><span class="linenos">2538</span></a> -</span><span id="Parser-2539"><a href="#Parser-2539"><span class="linenos">2539</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><span id="Parser-2540"><a href="#Parser-2540"><span class="linenos">2540</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</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_conjunction</span><span class="p">()</span> -</span><span id="Parser-2541"><a href="#Parser-2541"><span class="linenos">2541</span></a> <span class="p">)</span> +</span><span id="Parser-2539"><a href="#Parser-2539"><span class="linenos">2539</span></a> <span class="k">def</span> <span class="nf">_parse_where</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_where_token</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">Where</span><span class="p">]:</span> +</span><span id="Parser-2540"><a href="#Parser-2540"><span class="linenos">2540</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_where_token</span> <span class="ow">and</span> <span class="ow">not</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">WHERE</span><span class="p">):</span> +</span><span id="Parser-2541"><a href="#Parser-2541"><span class="linenos">2541</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="Parser-2542"><a href="#Parser-2542"><span class="linenos">2542</span></a> -</span><span id="Parser-2543"><a href="#Parser-2543"><span class="linenos">2543</span></a> <span class="k">def</span> <span class="nf">_parse_group</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_group_by_token</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">Group</span><span class="p">]:</span> -</span><span id="Parser-2544"><a href="#Parser-2544"><span class="linenos">2544</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_group_by_token</span> <span class="ow">and</span> <span class="ow">not</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">GROUP_BY</span><span class="p">):</span> -</span><span id="Parser-2545"><a href="#Parser-2545"><span class="linenos">2545</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2543"><a href="#Parser-2543"><span class="linenos">2543</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><span id="Parser-2544"><a href="#Parser-2544"><span class="linenos">2544</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Where</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</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_conjunction</span><span class="p">()</span> +</span><span id="Parser-2545"><a href="#Parser-2545"><span class="linenos">2545</span></a> <span class="p">)</span> </span><span id="Parser-2546"><a href="#Parser-2546"><span class="linenos">2546</span></a> -</span><span id="Parser-2547"><a href="#Parser-2547"><span class="linenos">2547</span></a> <span class="n">elements</span> <span class="o">=</span> <span class="n">defaultdict</span><span class="p">(</span><span class="nb">list</span><span class="p">)</span> -</span><span id="Parser-2548"><a href="#Parser-2548"><span class="linenos">2548</span></a> -</span><span id="Parser-2549"><a href="#Parser-2549"><span class="linenos">2549</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Parser-2550"><a href="#Parser-2550"><span class="linenos">2550</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="Parser-2551"><a href="#Parser-2551"><span class="linenos">2551</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="Parser-2552"><a href="#Parser-2552"><span class="linenos">2552</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"expressions"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Parser-2553"><a href="#Parser-2553"><span class="linenos">2553</span></a> -</span><span id="Parser-2554"><a href="#Parser-2554"><span class="linenos">2554</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_grouping_sets</span><span class="p">()</span> -</span><span id="Parser-2555"><a href="#Parser-2555"><span class="linenos">2555</span></a> <span class="k">if</span> <span class="n">grouping_sets</span><span class="p">:</span> -</span><span id="Parser-2556"><a href="#Parser-2556"><span class="linenos">2556</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"grouping_sets"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">grouping_sets</span><span class="p">)</span> +</span><span id="Parser-2547"><a href="#Parser-2547"><span class="linenos">2547</span></a> <span class="k">def</span> <span class="nf">_parse_group</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_group_by_token</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">Group</span><span class="p">]:</span> +</span><span id="Parser-2548"><a href="#Parser-2548"><span class="linenos">2548</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_group_by_token</span> <span class="ow">and</span> <span class="ow">not</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">GROUP_BY</span><span class="p">):</span> +</span><span id="Parser-2549"><a href="#Parser-2549"><span class="linenos">2549</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2550"><a href="#Parser-2550"><span class="linenos">2550</span></a> +</span><span id="Parser-2551"><a href="#Parser-2551"><span class="linenos">2551</span></a> <span class="n">elements</span> <span class="o">=</span> <span class="n">defaultdict</span><span class="p">(</span><span class="nb">list</span><span class="p">)</span> +</span><span id="Parser-2552"><a href="#Parser-2552"><span class="linenos">2552</span></a> +</span><span id="Parser-2553"><a href="#Parser-2553"><span class="linenos">2553</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Parser-2554"><a href="#Parser-2554"><span class="linenos">2554</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="Parser-2555"><a href="#Parser-2555"><span class="linenos">2555</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="Parser-2556"><a href="#Parser-2556"><span class="linenos">2556</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"expressions"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> </span><span id="Parser-2557"><a href="#Parser-2557"><span class="linenos">2557</span></a> -</span><span id="Parser-2558"><a href="#Parser-2558"><span class="linenos">2558</span></a> <span class="n">rollup</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2559"><a href="#Parser-2559"><span class="linenos">2559</span></a> <span class="n">cube</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2560"><a href="#Parser-2560"><span class="linenos">2560</span></a> <span class="n">totals</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2558"><a href="#Parser-2558"><span class="linenos">2558</span></a> <span class="n">grouping_sets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_grouping_sets</span><span class="p">()</span> +</span><span id="Parser-2559"><a href="#Parser-2559"><span class="linenos">2559</span></a> <span class="k">if</span> <span class="n">grouping_sets</span><span class="p">:</span> +</span><span id="Parser-2560"><a href="#Parser-2560"><span class="linenos">2560</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"grouping_sets"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">grouping_sets</span><span class="p">)</span> </span><span id="Parser-2561"><a href="#Parser-2561"><span class="linenos">2561</span></a> -</span><span id="Parser-2562"><a href="#Parser-2562"><span class="linenos">2562</span></a> <span class="n">with_</span> <span class="o">=</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">WITH</span><span class="p">)</span> -</span><span id="Parser-2563"><a href="#Parser-2563"><span class="linenos">2563</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">ROLLUP</span><span class="p">):</span> -</span><span id="Parser-2564"><a href="#Parser-2564"><span class="linenos">2564</span></a> <span class="n">rollup</span> <span class="o">=</span> <span class="n">with_</span> <span class="ow">or</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_column</span><span class="p">)</span> -</span><span id="Parser-2565"><a href="#Parser-2565"><span class="linenos">2565</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"rollup"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">rollup</span><span class="p">))</span> -</span><span id="Parser-2566"><a href="#Parser-2566"><span class="linenos">2566</span></a> -</span><span id="Parser-2567"><a href="#Parser-2567"><span class="linenos">2567</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">CUBE</span><span class="p">):</span> -</span><span id="Parser-2568"><a href="#Parser-2568"><span class="linenos">2568</span></a> <span class="n">cube</span> <span class="o">=</span> <span class="n">with_</span> <span class="ow">or</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_column</span><span class="p">)</span> -</span><span id="Parser-2569"><a href="#Parser-2569"><span class="linenos">2569</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"cube"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">cube</span><span class="p">))</span> +</span><span id="Parser-2562"><a href="#Parser-2562"><span class="linenos">2562</span></a> <span class="n">rollup</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2563"><a href="#Parser-2563"><span class="linenos">2563</span></a> <span class="n">cube</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2564"><a href="#Parser-2564"><span class="linenos">2564</span></a> <span class="n">totals</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2565"><a href="#Parser-2565"><span class="linenos">2565</span></a> +</span><span id="Parser-2566"><a href="#Parser-2566"><span class="linenos">2566</span></a> <span class="n">with_</span> <span class="o">=</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">WITH</span><span class="p">)</span> +</span><span id="Parser-2567"><a href="#Parser-2567"><span class="linenos">2567</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">ROLLUP</span><span class="p">):</span> +</span><span id="Parser-2568"><a href="#Parser-2568"><span class="linenos">2568</span></a> <span class="n">rollup</span> <span class="o">=</span> <span class="n">with_</span> <span class="ow">or</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_column</span><span class="p">)</span> +</span><span id="Parser-2569"><a href="#Parser-2569"><span class="linenos">2569</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"rollup"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">rollup</span><span class="p">))</span> </span><span id="Parser-2570"><a href="#Parser-2570"><span class="linenos">2570</span></a> -</span><span id="Parser-2571"><a href="#Parser-2571"><span class="linenos">2571</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TOTALS"</span><span class="p">):</span> -</span><span id="Parser-2572"><a href="#Parser-2572"><span class="linenos">2572</span></a> <span class="n">totals</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Parser-2573"><a href="#Parser-2573"><span class="linenos">2573</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"totals"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> <span class="c1"># type: ignore</span> +</span><span id="Parser-2571"><a href="#Parser-2571"><span class="linenos">2571</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">CUBE</span><span class="p">):</span> +</span><span id="Parser-2572"><a href="#Parser-2572"><span class="linenos">2572</span></a> <span class="n">cube</span> <span class="o">=</span> <span class="n">with_</span> <span class="ow">or</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_column</span><span class="p">)</span> +</span><span id="Parser-2573"><a href="#Parser-2573"><span class="linenos">2573</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"cube"</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">ensure_list</span><span class="p">(</span><span class="n">cube</span><span class="p">))</span> </span><span id="Parser-2574"><a href="#Parser-2574"><span class="linenos">2574</span></a> -</span><span id="Parser-2575"><a href="#Parser-2575"><span class="linenos">2575</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">grouping_sets</span> <span class="ow">or</span> <span class="n">rollup</span> <span class="ow">or</span> <span class="n">cube</span> <span class="ow">or</span> <span class="n">totals</span><span class="p">):</span> -</span><span id="Parser-2576"><a href="#Parser-2576"><span class="linenos">2576</span></a> <span class="k">break</span> -</span><span id="Parser-2577"><a href="#Parser-2577"><span class="linenos">2577</span></a> -</span><span id="Parser-2578"><a href="#Parser-2578"><span class="linenos">2578</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">Group</span><span class="p">,</span> <span class="o">**</span><span class="n">elements</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="Parser-2579"><a href="#Parser-2579"><span class="linenos">2579</span></a> -</span><span id="Parser-2580"><a href="#Parser-2580"><span class="linenos">2580</span></a> <span class="k">def</span> <span class="nf">_parse_grouping_sets</span><span class="p">(</span><span class="bp">self</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">t</span><span class="o">.</span><span class="n">List</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><span id="Parser-2581"><a href="#Parser-2581"><span class="linenos">2581</span></a> <span class="k">if</span> <span class="ow">not</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">GROUPING_SETS</span><span class="p">):</span> -</span><span id="Parser-2582"><a href="#Parser-2582"><span class="linenos">2582</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2575"><a href="#Parser-2575"><span class="linenos">2575</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TOTALS"</span><span class="p">):</span> +</span><span id="Parser-2576"><a href="#Parser-2576"><span class="linenos">2576</span></a> <span class="n">totals</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Parser-2577"><a href="#Parser-2577"><span class="linenos">2577</span></a> <span class="n">elements</span><span class="p">[</span><span class="s2">"totals"</span><span class="p">]</span> <span class="o">=</span> <span class="kc">True</span> <span class="c1"># type: ignore</span> +</span><span id="Parser-2578"><a href="#Parser-2578"><span class="linenos">2578</span></a> +</span><span id="Parser-2579"><a href="#Parser-2579"><span class="linenos">2579</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">grouping_sets</span> <span class="ow">or</span> <span class="n">rollup</span> <span class="ow">or</span> <span class="n">cube</span> <span class="ow">or</span> <span class="n">totals</span><span class="p">):</span> +</span><span id="Parser-2580"><a href="#Parser-2580"><span class="linenos">2580</span></a> <span class="k">break</span> +</span><span id="Parser-2581"><a href="#Parser-2581"><span class="linenos">2581</span></a> +</span><span id="Parser-2582"><a href="#Parser-2582"><span class="linenos">2582</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">Group</span><span class="p">,</span> <span class="o">**</span><span class="n">elements</span><span class="p">)</span> <span class="c1"># type: ignore</span> </span><span id="Parser-2583"><a href="#Parser-2583"><span class="linenos">2583</span></a> -</span><span id="Parser-2584"><a href="#Parser-2584"><span class="linenos">2584</span></a> <span class="k">return</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_grouping_set</span><span class="p">)</span> -</span><span id="Parser-2585"><a href="#Parser-2585"><span class="linenos">2585</span></a> -</span><span id="Parser-2586"><a href="#Parser-2586"><span class="linenos">2586</span></a> <span class="k">def</span> <span class="nf">_parse_grouping_set</span><span class="p">(</span><span class="bp">self</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="Parser-2587"><a href="#Parser-2587"><span class="linenos">2587</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_PAREN</span><span class="p">):</span> -</span><span id="Parser-2588"><a href="#Parser-2588"><span class="linenos">2588</span></a> <span class="n">grouping_set</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">)</span> -</span><span id="Parser-2589"><a href="#Parser-2589"><span class="linenos">2589</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="Parser-2590"><a href="#Parser-2590"><span class="linenos">2590</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">Tuple</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">grouping_set</span><span class="p">)</span> -</span><span id="Parser-2591"><a href="#Parser-2591"><span class="linenos">2591</span></a> -</span><span id="Parser-2592"><a href="#Parser-2592"><span class="linenos">2592</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> -</span><span id="Parser-2593"><a href="#Parser-2593"><span class="linenos">2593</span></a> -</span><span id="Parser-2594"><a href="#Parser-2594"><span class="linenos">2594</span></a> <span class="k">def</span> <span class="nf">_parse_having</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_having_token</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">Having</span><span class="p">]:</span> -</span><span id="Parser-2595"><a href="#Parser-2595"><span class="linenos">2595</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_having_token</span> <span class="ow">and</span> <span class="ow">not</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">HAVING</span><span class="p">):</span> -</span><span id="Parser-2596"><a href="#Parser-2596"><span class="linenos">2596</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-2597"><a href="#Parser-2597"><span class="linenos">2597</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">Having</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_conjunction</span><span class="p">())</span> -</span><span id="Parser-2598"><a href="#Parser-2598"><span class="linenos">2598</span></a> -</span><span id="Parser-2599"><a href="#Parser-2599"><span class="linenos">2599</span></a> <span class="k">def</span> <span class="nf">_parse_qualify</span><span class="p">(</span><span class="bp">self</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">Qualify</span><span class="p">]:</span> -</span><span id="Parser-2600"><a href="#Parser-2600"><span class="linenos">2600</span></a> <span class="k">if</span> <span class="ow">not</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">QUALIFY</span><span class="p">):</span> -</span><span id="Parser-2601"><a href="#Parser-2601"><span class="linenos">2601</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-2602"><a href="#Parser-2602"><span class="linenos">2602</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">Qualify</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_conjunction</span><span class="p">())</span> -</span><span id="Parser-2603"><a href="#Parser-2603"><span class="linenos">2603</span></a> -</span><span id="Parser-2604"><a href="#Parser-2604"><span class="linenos">2604</span></a> <span class="k">def</span> <span class="nf">_parse_order</span><span class="p">(</span> -</span><span id="Parser-2605"><a href="#Parser-2605"><span class="linenos">2605</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 class="p">,</span> <span class="n">skip_order_token</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-2606"><a href="#Parser-2606"><span class="linenos">2606</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="Parser-2607"><a href="#Parser-2607"><span class="linenos">2607</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_order_token</span> <span class="ow">and</span> <span class="ow">not</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">ORDER_BY</span><span class="p">):</span> -</span><span id="Parser-2608"><a href="#Parser-2608"><span class="linenos">2608</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-2609"><a href="#Parser-2609"><span class="linenos">2609</span></a> -</span><span id="Parser-2610"><a href="#Parser-2610"><span class="linenos">2610</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><span id="Parser-2611"><a href="#Parser-2611"><span class="linenos">2611</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_ordered</span><span class="p">)</span> -</span><span id="Parser-2612"><a href="#Parser-2612"><span class="linenos">2612</span></a> <span class="p">)</span> +</span><span id="Parser-2584"><a href="#Parser-2584"><span class="linenos">2584</span></a> <span class="k">def</span> <span class="nf">_parse_grouping_sets</span><span class="p">(</span><span class="bp">self</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">t</span><span class="o">.</span><span class="n">List</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><span id="Parser-2585"><a href="#Parser-2585"><span class="linenos">2585</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">GROUPING_SETS</span><span class="p">):</span> +</span><span id="Parser-2586"><a href="#Parser-2586"><span class="linenos">2586</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2587"><a href="#Parser-2587"><span class="linenos">2587</span></a> +</span><span id="Parser-2588"><a href="#Parser-2588"><span class="linenos">2588</span></a> <span class="k">return</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_grouping_set</span><span class="p">)</span> +</span><span id="Parser-2589"><a href="#Parser-2589"><span class="linenos">2589</span></a> +</span><span id="Parser-2590"><a href="#Parser-2590"><span class="linenos">2590</span></a> <span class="k">def</span> <span class="nf">_parse_grouping_set</span><span class="p">(</span><span class="bp">self</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="Parser-2591"><a href="#Parser-2591"><span class="linenos">2591</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_PAREN</span><span class="p">):</span> +</span><span id="Parser-2592"><a href="#Parser-2592"><span class="linenos">2592</span></a> <span class="n">grouping_set</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">)</span> +</span><span id="Parser-2593"><a href="#Parser-2593"><span class="linenos">2593</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-2594"><a href="#Parser-2594"><span class="linenos">2594</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">Tuple</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">grouping_set</span><span class="p">)</span> +</span><span id="Parser-2595"><a href="#Parser-2595"><span class="linenos">2595</span></a> +</span><span id="Parser-2596"><a href="#Parser-2596"><span class="linenos">2596</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> +</span><span id="Parser-2597"><a href="#Parser-2597"><span class="linenos">2597</span></a> +</span><span id="Parser-2598"><a href="#Parser-2598"><span class="linenos">2598</span></a> <span class="k">def</span> <span class="nf">_parse_having</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip_having_token</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">Having</span><span class="p">]:</span> +</span><span id="Parser-2599"><a href="#Parser-2599"><span class="linenos">2599</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_having_token</span> <span class="ow">and</span> <span class="ow">not</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">HAVING</span><span class="p">):</span> +</span><span id="Parser-2600"><a href="#Parser-2600"><span class="linenos">2600</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2601"><a href="#Parser-2601"><span class="linenos">2601</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">Having</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_conjunction</span><span class="p">())</span> +</span><span id="Parser-2602"><a href="#Parser-2602"><span class="linenos">2602</span></a> +</span><span id="Parser-2603"><a href="#Parser-2603"><span class="linenos">2603</span></a> <span class="k">def</span> <span class="nf">_parse_qualify</span><span class="p">(</span><span class="bp">self</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">Qualify</span><span class="p">]:</span> +</span><span id="Parser-2604"><a href="#Parser-2604"><span class="linenos">2604</span></a> <span class="k">if</span> <span class="ow">not</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">QUALIFY</span><span class="p">):</span> +</span><span id="Parser-2605"><a href="#Parser-2605"><span class="linenos">2605</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2606"><a href="#Parser-2606"><span class="linenos">2606</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">Qualify</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_conjunction</span><span class="p">())</span> +</span><span id="Parser-2607"><a href="#Parser-2607"><span class="linenos">2607</span></a> +</span><span id="Parser-2608"><a href="#Parser-2608"><span class="linenos">2608</span></a> <span class="k">def</span> <span class="nf">_parse_order</span><span class="p">(</span> +</span><span id="Parser-2609"><a href="#Parser-2609"><span class="linenos">2609</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 class="p">,</span> <span class="n">skip_order_token</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-2610"><a href="#Parser-2610"><span class="linenos">2610</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="Parser-2611"><a href="#Parser-2611"><span class="linenos">2611</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">skip_order_token</span> <span class="ow">and</span> <span class="ow">not</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">ORDER_BY</span><span class="p">):</span> +</span><span id="Parser-2612"><a href="#Parser-2612"><span class="linenos">2612</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="Parser-2613"><a href="#Parser-2613"><span class="linenos">2613</span></a> -</span><span id="Parser-2614"><a href="#Parser-2614"><span class="linenos">2614</span></a> <span class="k">def</span> <span class="nf">_parse_sort</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> <span class="o">*</span><span class="n">texts</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">E</span><span class="p">]:</span> -</span><span id="Parser-2615"><a href="#Parser-2615"><span class="linenos">2615</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="o">*</span><span class="n">texts</span><span class="p">):</span> -</span><span id="Parser-2616"><a href="#Parser-2616"><span class="linenos">2616</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-2617"><a href="#Parser-2617"><span class="linenos">2617</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_class</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_ordered</span><span class="p">))</span> -</span><span id="Parser-2618"><a href="#Parser-2618"><span class="linenos">2618</span></a> -</span><span id="Parser-2619"><a href="#Parser-2619"><span class="linenos">2619</span></a> <span class="k">def</span> <span class="nf">_parse_ordered</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">Ordered</span><span class="p">:</span> -</span><span id="Parser-2620"><a href="#Parser-2620"><span class="linenos">2620</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="Parser-2621"><a href="#Parser-2621"><span class="linenos">2621</span></a> <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">ASC</span><span class="p">)</span> +</span><span id="Parser-2614"><a href="#Parser-2614"><span class="linenos">2614</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><span id="Parser-2615"><a href="#Parser-2615"><span class="linenos">2615</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Order</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_ordered</span><span class="p">)</span> +</span><span id="Parser-2616"><a href="#Parser-2616"><span class="linenos">2616</span></a> <span class="p">)</span> +</span><span id="Parser-2617"><a href="#Parser-2617"><span class="linenos">2617</span></a> +</span><span id="Parser-2618"><a href="#Parser-2618"><span class="linenos">2618</span></a> <span class="k">def</span> <span class="nf">_parse_sort</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> <span class="n">token</span><span class="p">:</span> <span class="n">TokenType</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">E</span><span class="p">]:</span> +</span><span id="Parser-2619"><a href="#Parser-2619"><span class="linenos">2619</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">token</span><span class="p">):</span> +</span><span id="Parser-2620"><a href="#Parser-2620"><span class="linenos">2620</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2621"><a href="#Parser-2621"><span class="linenos">2621</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_class</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_ordered</span><span class="p">))</span> </span><span id="Parser-2622"><a href="#Parser-2622"><span class="linenos">2622</span></a> -</span><span id="Parser-2623"><a href="#Parser-2623"><span class="linenos">2623</span></a> <span class="n">is_desc</span> <span class="o">=</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">DESC</span><span class="p">)</span> -</span><span id="Parser-2624"><a href="#Parser-2624"><span class="linenos">2624</span></a> <span class="n">is_nulls_first</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULLS"</span><span class="p">,</span> <span class="s2">"FIRST"</span><span class="p">)</span> -</span><span id="Parser-2625"><a href="#Parser-2625"><span class="linenos">2625</span></a> <span class="n">is_nulls_last</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULLS"</span><span class="p">,</span> <span class="s2">"LAST"</span><span class="p">)</span> -</span><span id="Parser-2626"><a href="#Parser-2626"><span class="linenos">2626</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="n">is_desc</span> <span class="ow">or</span> <span class="kc">False</span> -</span><span id="Parser-2627"><a href="#Parser-2627"><span class="linenos">2627</span></a> <span class="n">asc</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">desc</span> -</span><span id="Parser-2628"><a href="#Parser-2628"><span class="linenos">2628</span></a> <span class="n">nulls_first</span> <span class="o">=</span> <span class="n">is_nulls_first</span> <span class="ow">or</span> <span class="kc">False</span> -</span><span id="Parser-2629"><a href="#Parser-2629"><span class="linenos">2629</span></a> <span class="n">explicitly_null_ordered</span> <span class="o">=</span> <span class="n">is_nulls_first</span> <span class="ow">or</span> <span class="n">is_nulls_last</span> -</span><span id="Parser-2630"><a href="#Parser-2630"><span class="linenos">2630</span></a> -</span><span id="Parser-2631"><a href="#Parser-2631"><span class="linenos">2631</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="Parser-2632"><a href="#Parser-2632"><span class="linenos">2632</span></a> <span class="ow">not</span> <span class="n">explicitly_null_ordered</span> -</span><span id="Parser-2633"><a href="#Parser-2633"><span class="linenos">2633</span></a> <span class="ow">and</span> <span class="p">(</span> -</span><span id="Parser-2634"><a href="#Parser-2634"><span class="linenos">2634</span></a> <span class="p">(</span><span class="n">asc</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_small"</span><span class="p">)</span> -</span><span id="Parser-2635"><a href="#Parser-2635"><span class="linenos">2635</span></a> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">!=</span> <span class="s2">"nulls_are_small"</span><span class="p">)</span> -</span><span id="Parser-2636"><a href="#Parser-2636"><span class="linenos">2636</span></a> <span class="p">)</span> -</span><span id="Parser-2637"><a href="#Parser-2637"><span class="linenos">2637</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">!=</span> <span class="s2">"nulls_are_last"</span> -</span><span id="Parser-2638"><a href="#Parser-2638"><span class="linenos">2638</span></a> <span class="p">):</span> -</span><span id="Parser-2639"><a href="#Parser-2639"><span class="linenos">2639</span></a> <span class="n">nulls_first</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Parser-2640"><a href="#Parser-2640"><span class="linenos">2640</span></a> -</span><span id="Parser-2641"><a href="#Parser-2641"><span class="linenos">2641</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">Ordered</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="n">desc</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="n">nulls_first</span><span class="p">)</span> -</span><span id="Parser-2642"><a href="#Parser-2642"><span class="linenos">2642</span></a> -</span><span id="Parser-2643"><a href="#Parser-2643"><span class="linenos">2643</span></a> <span class="k">def</span> <span class="nf">_parse_limit</span><span class="p">(</span> -</span><span id="Parser-2644"><a href="#Parser-2644"><span class="linenos">2644</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 class="p">,</span> <span class="n">top</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-2645"><a href="#Parser-2645"><span class="linenos">2645</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="Parser-2646"><a href="#Parser-2646"><span class="linenos">2646</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">TOP</span> <span class="k">if</span> <span class="n">top</span> <span class="k">else</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIMIT</span><span class="p">):</span> -</span><span id="Parser-2647"><a href="#Parser-2647"><span class="linenos">2647</span></a> <span class="n">limit_paren</span> <span class="o">=</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_PAREN</span><span class="p">)</span> -</span><span id="Parser-2648"><a href="#Parser-2648"><span class="linenos">2648</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> <span class="k">if</span> <span class="n">top</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> -</span><span id="Parser-2649"><a href="#Parser-2649"><span class="linenos">2649</span></a> -</span><span id="Parser-2650"><a href="#Parser-2650"><span class="linenos">2650</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">COMMA</span><span class="p">):</span> -</span><span id="Parser-2651"><a href="#Parser-2651"><span class="linenos">2651</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span> -</span><span id="Parser-2652"><a href="#Parser-2652"><span class="linenos">2652</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> -</span><span id="Parser-2653"><a href="#Parser-2653"><span class="linenos">2653</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2654"><a href="#Parser-2654"><span class="linenos">2654</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2655"><a href="#Parser-2655"><span class="linenos">2655</span></a> -</span><span id="Parser-2656"><a href="#Parser-2656"><span class="linenos">2656</span></a> <span class="n">limit_exp</span> <span class="o">=</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">Limit</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">offset</span><span class="o">=</span><span class="n">offset</span><span class="p">)</span> -</span><span id="Parser-2657"><a href="#Parser-2657"><span class="linenos">2657</span></a> -</span><span id="Parser-2658"><a href="#Parser-2658"><span class="linenos">2658</span></a> <span class="k">if</span> <span class="n">limit_paren</span><span class="p">:</span> -</span><span id="Parser-2659"><a href="#Parser-2659"><span class="linenos">2659</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="Parser-2660"><a href="#Parser-2660"><span class="linenos">2660</span></a> -</span><span id="Parser-2661"><a href="#Parser-2661"><span class="linenos">2661</span></a> <span class="k">return</span> <span class="n">limit_exp</span> -</span><span id="Parser-2662"><a href="#Parser-2662"><span class="linenos">2662</span></a> -</span><span id="Parser-2663"><a href="#Parser-2663"><span class="linenos">2663</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">FETCH</span><span class="p">):</span> -</span><span id="Parser-2664"><a href="#Parser-2664"><span class="linenos">2664</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FIRST</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEXT</span><span class="p">))</span> -</span><span id="Parser-2665"><a href="#Parser-2665"><span class="linenos">2665</span></a> <span class="n">direction</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="k">if</span> <span class="n">direction</span> <span class="k">else</span> <span class="s2">"FIRST"</span> +</span><span id="Parser-2623"><a href="#Parser-2623"><span class="linenos">2623</span></a> <span class="k">def</span> <span class="nf">_parse_ordered</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">Ordered</span><span class="p">:</span> +</span><span id="Parser-2624"><a href="#Parser-2624"><span class="linenos">2624</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="Parser-2625"><a href="#Parser-2625"><span class="linenos">2625</span></a> <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">ASC</span><span class="p">)</span> +</span><span id="Parser-2626"><a href="#Parser-2626"><span class="linenos">2626</span></a> +</span><span id="Parser-2627"><a href="#Parser-2627"><span class="linenos">2627</span></a> <span class="n">is_desc</span> <span class="o">=</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">DESC</span><span class="p">)</span> +</span><span id="Parser-2628"><a href="#Parser-2628"><span class="linenos">2628</span></a> <span class="n">is_nulls_first</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULLS"</span><span class="p">,</span> <span class="s2">"FIRST"</span><span class="p">)</span> +</span><span id="Parser-2629"><a href="#Parser-2629"><span class="linenos">2629</span></a> <span class="n">is_nulls_last</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULLS"</span><span class="p">,</span> <span class="s2">"LAST"</span><span class="p">)</span> +</span><span id="Parser-2630"><a href="#Parser-2630"><span class="linenos">2630</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="n">is_desc</span> <span class="ow">or</span> <span class="kc">False</span> +</span><span id="Parser-2631"><a href="#Parser-2631"><span class="linenos">2631</span></a> <span class="n">asc</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">desc</span> +</span><span id="Parser-2632"><a href="#Parser-2632"><span class="linenos">2632</span></a> <span class="n">nulls_first</span> <span class="o">=</span> <span class="n">is_nulls_first</span> <span class="ow">or</span> <span class="kc">False</span> +</span><span id="Parser-2633"><a href="#Parser-2633"><span class="linenos">2633</span></a> <span class="n">explicitly_null_ordered</span> <span class="o">=</span> <span class="n">is_nulls_first</span> <span class="ow">or</span> <span class="n">is_nulls_last</span> +</span><span id="Parser-2634"><a href="#Parser-2634"><span class="linenos">2634</span></a> +</span><span id="Parser-2635"><a href="#Parser-2635"><span class="linenos">2635</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="Parser-2636"><a href="#Parser-2636"><span class="linenos">2636</span></a> <span class="ow">not</span> <span class="n">explicitly_null_ordered</span> +</span><span id="Parser-2637"><a href="#Parser-2637"><span class="linenos">2637</span></a> <span class="ow">and</span> <span class="p">(</span> +</span><span id="Parser-2638"><a href="#Parser-2638"><span class="linenos">2638</span></a> <span class="p">(</span><span class="n">asc</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">==</span> <span class="s2">"nulls_are_small"</span><span class="p">)</span> +</span><span id="Parser-2639"><a href="#Parser-2639"><span class="linenos">2639</span></a> <span class="ow">or</span> <span class="p">(</span><span class="n">desc</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">!=</span> <span class="s2">"nulls_are_small"</span><span class="p">)</span> +</span><span id="Parser-2640"><a href="#Parser-2640"><span class="linenos">2640</span></a> <span class="p">)</span> +</span><span id="Parser-2641"><a href="#Parser-2641"><span class="linenos">2641</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">NULL_ORDERING</span> <span class="o">!=</span> <span class="s2">"nulls_are_last"</span> +</span><span id="Parser-2642"><a href="#Parser-2642"><span class="linenos">2642</span></a> <span class="p">):</span> +</span><span id="Parser-2643"><a href="#Parser-2643"><span class="linenos">2643</span></a> <span class="n">nulls_first</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Parser-2644"><a href="#Parser-2644"><span class="linenos">2644</span></a> +</span><span id="Parser-2645"><a href="#Parser-2645"><span class="linenos">2645</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">Ordered</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="n">desc</span><span class="p">,</span> <span class="n">nulls_first</span><span class="o">=</span><span class="n">nulls_first</span><span class="p">)</span> +</span><span id="Parser-2646"><a href="#Parser-2646"><span class="linenos">2646</span></a> +</span><span id="Parser-2647"><a href="#Parser-2647"><span class="linenos">2647</span></a> <span class="k">def</span> <span class="nf">_parse_limit</span><span class="p">(</span> +</span><span id="Parser-2648"><a href="#Parser-2648"><span class="linenos">2648</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 class="p">,</span> <span class="n">top</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-2649"><a href="#Parser-2649"><span class="linenos">2649</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="Parser-2650"><a href="#Parser-2650"><span class="linenos">2650</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">TOP</span> <span class="k">if</span> <span class="n">top</span> <span class="k">else</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIMIT</span><span class="p">):</span> +</span><span id="Parser-2651"><a href="#Parser-2651"><span class="linenos">2651</span></a> <span class="n">limit_paren</span> <span class="o">=</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_PAREN</span><span class="p">)</span> +</span><span id="Parser-2652"><a href="#Parser-2652"><span class="linenos">2652</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> <span class="k">if</span> <span class="n">top</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> +</span><span id="Parser-2653"><a href="#Parser-2653"><span class="linenos">2653</span></a> +</span><span id="Parser-2654"><a href="#Parser-2654"><span class="linenos">2654</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">COMMA</span><span class="p">):</span> +</span><span id="Parser-2655"><a href="#Parser-2655"><span class="linenos">2655</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="n">expression</span> +</span><span id="Parser-2656"><a href="#Parser-2656"><span class="linenos">2656</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> +</span><span id="Parser-2657"><a href="#Parser-2657"><span class="linenos">2657</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2658"><a href="#Parser-2658"><span class="linenos">2658</span></a> <span class="n">offset</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2659"><a href="#Parser-2659"><span class="linenos">2659</span></a> +</span><span id="Parser-2660"><a href="#Parser-2660"><span class="linenos">2660</span></a> <span class="n">limit_exp</span> <span class="o">=</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">Limit</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">offset</span><span class="o">=</span><span class="n">offset</span><span class="p">)</span> +</span><span id="Parser-2661"><a href="#Parser-2661"><span class="linenos">2661</span></a> +</span><span id="Parser-2662"><a href="#Parser-2662"><span class="linenos">2662</span></a> <span class="k">if</span> <span class="n">limit_paren</span><span class="p">:</span> +</span><span id="Parser-2663"><a href="#Parser-2663"><span class="linenos">2663</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-2664"><a href="#Parser-2664"><span class="linenos">2664</span></a> +</span><span id="Parser-2665"><a href="#Parser-2665"><span class="linenos">2665</span></a> <span class="k">return</span> <span class="n">limit_exp</span> </span><span id="Parser-2666"><a href="#Parser-2666"><span class="linenos">2666</span></a> -</span><span id="Parser-2667"><a href="#Parser-2667"><span class="linenos">2667</span></a> <span class="n">count</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> -</span><span id="Parser-2668"><a href="#Parser-2668"><span class="linenos">2668</span></a> <span class="n">percent</span> <span class="o">=</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">PERCENT</span><span class="p">)</span> -</span><span id="Parser-2669"><a href="#Parser-2669"><span class="linenos">2669</span></a> -</span><span id="Parser-2670"><a href="#Parser-2670"><span class="linenos">2670</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">))</span> -</span><span id="Parser-2671"><a href="#Parser-2671"><span class="linenos">2671</span></a> -</span><span id="Parser-2672"><a href="#Parser-2672"><span class="linenos">2672</span></a> <span class="n">only</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ONLY"</span><span class="p">)</span> -</span><span id="Parser-2673"><a href="#Parser-2673"><span class="linenos">2673</span></a> <span class="n">with_ties</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"TIES"</span><span class="p">)</span> -</span><span id="Parser-2674"><a href="#Parser-2674"><span class="linenos">2674</span></a> -</span><span id="Parser-2675"><a href="#Parser-2675"><span class="linenos">2675</span></a> <span class="k">if</span> <span class="n">only</span> <span class="ow">and</span> <span class="n">with_ties</span><span class="p">:</span> -</span><span id="Parser-2676"><a href="#Parser-2676"><span class="linenos">2676</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Cannot specify both ONLY and WITH TIES in FETCH clause"</span><span class="p">)</span> -</span><span id="Parser-2677"><a href="#Parser-2677"><span class="linenos">2677</span></a> -</span><span id="Parser-2678"><a href="#Parser-2678"><span class="linenos">2678</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><span id="Parser-2679"><a href="#Parser-2679"><span class="linenos">2679</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">,</span> -</span><span id="Parser-2680"><a href="#Parser-2680"><span class="linenos">2680</span></a> <span class="n">direction</span><span class="o">=</span><span class="n">direction</span><span class="p">,</span> -</span><span id="Parser-2681"><a href="#Parser-2681"><span class="linenos">2681</span></a> <span class="n">count</span><span class="o">=</span><span class="n">count</span><span class="p">,</span> -</span><span id="Parser-2682"><a href="#Parser-2682"><span class="linenos">2682</span></a> <span class="n">percent</span><span class="o">=</span><span class="n">percent</span><span class="p">,</span> -</span><span id="Parser-2683"><a href="#Parser-2683"><span class="linenos">2683</span></a> <span class="n">with_ties</span><span class="o">=</span><span class="n">with_ties</span><span class="p">,</span> -</span><span id="Parser-2684"><a href="#Parser-2684"><span class="linenos">2684</span></a> <span class="p">)</span> -</span><span id="Parser-2685"><a href="#Parser-2685"><span class="linenos">2685</span></a> -</span><span id="Parser-2686"><a href="#Parser-2686"><span class="linenos">2686</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-2687"><a href="#Parser-2687"><span class="linenos">2687</span></a> -</span><span id="Parser-2688"><a href="#Parser-2688"><span class="linenos">2688</span></a> <span class="k">def</span> <span class="nf">_parse_offset</span><span class="p">(</span><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 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="Parser-2689"><a href="#Parser-2689"><span class="linenos">2689</span></a> <span class="k">if</span> <span class="ow">not</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">OFFSET</span><span class="p">):</span> -</span><span id="Parser-2690"><a href="#Parser-2690"><span class="linenos">2690</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-2667"><a href="#Parser-2667"><span class="linenos">2667</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">FETCH</span><span class="p">):</span> +</span><span id="Parser-2668"><a href="#Parser-2668"><span class="linenos">2668</span></a> <span class="n">direction</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FIRST</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEXT</span><span class="p">))</span> +</span><span id="Parser-2669"><a href="#Parser-2669"><span class="linenos">2669</span></a> <span class="n">direction</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="k">if</span> <span class="n">direction</span> <span class="k">else</span> <span class="s2">"FIRST"</span> +</span><span id="Parser-2670"><a href="#Parser-2670"><span class="linenos">2670</span></a> +</span><span id="Parser-2671"><a href="#Parser-2671"><span class="linenos">2671</span></a> <span class="n">count</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> +</span><span id="Parser-2672"><a href="#Parser-2672"><span class="linenos">2672</span></a> <span class="n">percent</span> <span class="o">=</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">PERCENT</span><span class="p">)</span> +</span><span id="Parser-2673"><a href="#Parser-2673"><span class="linenos">2673</span></a> +</span><span id="Parser-2674"><a href="#Parser-2674"><span class="linenos">2674</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">))</span> +</span><span id="Parser-2675"><a href="#Parser-2675"><span class="linenos">2675</span></a> +</span><span id="Parser-2676"><a href="#Parser-2676"><span class="linenos">2676</span></a> <span class="n">only</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ONLY"</span><span class="p">)</span> +</span><span id="Parser-2677"><a href="#Parser-2677"><span class="linenos">2677</span></a> <span class="n">with_ties</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"TIES"</span><span class="p">)</span> +</span><span id="Parser-2678"><a href="#Parser-2678"><span class="linenos">2678</span></a> +</span><span id="Parser-2679"><a href="#Parser-2679"><span class="linenos">2679</span></a> <span class="k">if</span> <span class="n">only</span> <span class="ow">and</span> <span class="n">with_ties</span><span class="p">:</span> +</span><span id="Parser-2680"><a href="#Parser-2680"><span class="linenos">2680</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Cannot specify both ONLY and WITH TIES in FETCH clause"</span><span class="p">)</span> +</span><span id="Parser-2681"><a href="#Parser-2681"><span class="linenos">2681</span></a> +</span><span id="Parser-2682"><a href="#Parser-2682"><span class="linenos">2682</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><span id="Parser-2683"><a href="#Parser-2683"><span class="linenos">2683</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Fetch</span><span class="p">,</span> +</span><span id="Parser-2684"><a href="#Parser-2684"><span class="linenos">2684</span></a> <span class="n">direction</span><span class="o">=</span><span class="n">direction</span><span class="p">,</span> +</span><span id="Parser-2685"><a href="#Parser-2685"><span class="linenos">2685</span></a> <span class="n">count</span><span class="o">=</span><span class="n">count</span><span class="p">,</span> +</span><span id="Parser-2686"><a href="#Parser-2686"><span class="linenos">2686</span></a> <span class="n">percent</span><span class="o">=</span><span class="n">percent</span><span class="p">,</span> +</span><span id="Parser-2687"><a href="#Parser-2687"><span class="linenos">2687</span></a> <span class="n">with_ties</span><span class="o">=</span><span class="n">with_ties</span><span class="p">,</span> +</span><span id="Parser-2688"><a href="#Parser-2688"><span class="linenos">2688</span></a> <span class="p">)</span> +</span><span id="Parser-2689"><a href="#Parser-2689"><span class="linenos">2689</span></a> +</span><span id="Parser-2690"><a href="#Parser-2690"><span class="linenos">2690</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="Parser-2691"><a href="#Parser-2691"><span class="linenos">2691</span></a> -</span><span id="Parser-2692"><a href="#Parser-2692"><span class="linenos">2692</span></a> <span class="n">count</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> -</span><span id="Parser-2693"><a href="#Parser-2693"><span class="linenos">2693</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">))</span> -</span><span id="Parser-2694"><a href="#Parser-2694"><span class="linenos">2694</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">Offset</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">count</span><span class="p">)</span> +</span><span id="Parser-2692"><a href="#Parser-2692"><span class="linenos">2692</span></a> <span class="k">def</span> <span class="nf">_parse_offset</span><span class="p">(</span><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 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="Parser-2693"><a href="#Parser-2693"><span class="linenos">2693</span></a> <span class="k">if</span> <span class="ow">not</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">OFFSET</span><span class="p">):</span> +</span><span id="Parser-2694"><a href="#Parser-2694"><span class="linenos">2694</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="Parser-2695"><a href="#Parser-2695"><span class="linenos">2695</span></a> -</span><span id="Parser-2696"><a href="#Parser-2696"><span class="linenos">2696</span></a> <span class="k">def</span> <span class="nf">_parse_locks</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Lock</span><span class="p">]:</span> -</span><span id="Parser-2697"><a href="#Parser-2697"><span class="linenos">2697</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-2698"><a href="#Parser-2698"><span class="linenos">2698</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Parser-2699"><a href="#Parser-2699"><span class="linenos">2699</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"UPDATE"</span><span class="p">):</span> -</span><span id="Parser-2700"><a href="#Parser-2700"><span class="linenos">2700</span></a> <span class="n">update</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Parser-2701"><a href="#Parser-2701"><span class="linenos">2701</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"SHARE"</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span> -</span><span id="Parser-2702"><a href="#Parser-2702"><span class="linenos">2702</span></a> <span class="s2">"LOCK"</span><span class="p">,</span> <span class="s2">"IN"</span><span class="p">,</span> <span class="s2">"SHARE"</span><span class="p">,</span> <span class="s2">"MODE"</span> -</span><span id="Parser-2703"><a href="#Parser-2703"><span class="linenos">2703</span></a> <span class="p">):</span> -</span><span id="Parser-2704"><a href="#Parser-2704"><span class="linenos">2704</span></a> <span class="n">update</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-2705"><a href="#Parser-2705"><span class="linenos">2705</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2706"><a href="#Parser-2706"><span class="linenos">2706</span></a> <span class="k">break</span> -</span><span id="Parser-2707"><a href="#Parser-2707"><span class="linenos">2707</span></a> -</span><span id="Parser-2708"><a href="#Parser-2708"><span class="linenos">2708</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2709"><a href="#Parser-2709"><span class="linenos">2709</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OF"</span><span class="p">):</span> -</span><span id="Parser-2710"><a href="#Parser-2710"><span class="linenos">2710</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="Parser-2696"><a href="#Parser-2696"><span class="linenos">2696</span></a> <span class="n">count</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_number</span><span class="p">()</span> +</span><span id="Parser-2697"><a href="#Parser-2697"><span class="linenos">2697</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">))</span> +</span><span id="Parser-2698"><a href="#Parser-2698"><span class="linenos">2698</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">Offset</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">count</span><span class="p">)</span> +</span><span id="Parser-2699"><a href="#Parser-2699"><span class="linenos">2699</span></a> +</span><span id="Parser-2700"><a href="#Parser-2700"><span class="linenos">2700</span></a> <span class="k">def</span> <span class="nf">_parse_locks</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Lock</span><span class="p">]:</span> +</span><span id="Parser-2701"><a href="#Parser-2701"><span class="linenos">2701</span></a> <span class="n">locks</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-2702"><a href="#Parser-2702"><span class="linenos">2702</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Parser-2703"><a href="#Parser-2703"><span class="linenos">2703</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"UPDATE"</span><span class="p">):</span> +</span><span id="Parser-2704"><a href="#Parser-2704"><span class="linenos">2704</span></a> <span class="n">update</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Parser-2705"><a href="#Parser-2705"><span class="linenos">2705</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"SHARE"</span><span class="p">)</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span> +</span><span id="Parser-2706"><a href="#Parser-2706"><span class="linenos">2706</span></a> <span class="s2">"LOCK"</span><span class="p">,</span> <span class="s2">"IN"</span><span class="p">,</span> <span class="s2">"SHARE"</span><span class="p">,</span> <span class="s2">"MODE"</span> +</span><span id="Parser-2707"><a href="#Parser-2707"><span class="linenos">2707</span></a> <span class="p">):</span> +</span><span id="Parser-2708"><a href="#Parser-2708"><span class="linenos">2708</span></a> <span class="n">update</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-2709"><a href="#Parser-2709"><span class="linenos">2709</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2710"><a href="#Parser-2710"><span class="linenos">2710</span></a> <span class="k">break</span> </span><span id="Parser-2711"><a href="#Parser-2711"><span class="linenos">2711</span></a> -</span><span id="Parser-2712"><a href="#Parser-2712"><span class="linenos">2712</span></a> <span class="n">wait</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2713"><a href="#Parser-2713"><span class="linenos">2713</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NOWAIT"</span><span class="p">):</span> -</span><span id="Parser-2714"><a href="#Parser-2714"><span class="linenos">2714</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Parser-2715"><a href="#Parser-2715"><span class="linenos">2715</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WAIT"</span><span class="p">):</span> -</span><span id="Parser-2716"><a href="#Parser-2716"><span class="linenos">2716</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> -</span><span id="Parser-2717"><a href="#Parser-2717"><span class="linenos">2717</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SKIP"</span><span class="p">,</span> <span class="s2">"LOCKED"</span><span class="p">):</span> -</span><span id="Parser-2718"><a href="#Parser-2718"><span class="linenos">2718</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-2719"><a href="#Parser-2719"><span class="linenos">2719</span></a> -</span><span id="Parser-2720"><a href="#Parser-2720"><span class="linenos">2720</span></a> <span class="n">locks</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="Parser-2721"><a href="#Parser-2721"><span class="linenos">2721</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">Lock</span><span class="p">,</span> <span class="n">update</span><span class="o">=</span><span class="n">update</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">wait</span><span class="o">=</span><span class="n">wait</span><span class="p">)</span> -</span><span id="Parser-2722"><a href="#Parser-2722"><span class="linenos">2722</span></a> <span class="p">)</span> +</span><span id="Parser-2712"><a href="#Parser-2712"><span class="linenos">2712</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2713"><a href="#Parser-2713"><span class="linenos">2713</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"OF"</span><span class="p">):</span> +</span><span id="Parser-2714"><a href="#Parser-2714"><span class="linenos">2714</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="Parser-2715"><a href="#Parser-2715"><span class="linenos">2715</span></a> +</span><span id="Parser-2716"><a href="#Parser-2716"><span class="linenos">2716</span></a> <span class="n">wait</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2717"><a href="#Parser-2717"><span class="linenos">2717</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NOWAIT"</span><span class="p">):</span> +</span><span id="Parser-2718"><a href="#Parser-2718"><span class="linenos">2718</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Parser-2719"><a href="#Parser-2719"><span class="linenos">2719</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WAIT"</span><span class="p">):</span> +</span><span id="Parser-2720"><a href="#Parser-2720"><span class="linenos">2720</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="Parser-2721"><a href="#Parser-2721"><span class="linenos">2721</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SKIP"</span><span class="p">,</span> <span class="s2">"LOCKED"</span><span class="p">):</span> +</span><span id="Parser-2722"><a href="#Parser-2722"><span class="linenos">2722</span></a> <span class="n">wait</span> <span class="o">=</span> <span class="kc">False</span> </span><span id="Parser-2723"><a href="#Parser-2723"><span class="linenos">2723</span></a> -</span><span id="Parser-2724"><a href="#Parser-2724"><span class="linenos">2724</span></a> <span class="k">return</span> <span class="n">locks</span> -</span><span id="Parser-2725"><a href="#Parser-2725"><span class="linenos">2725</span></a> -</span><span id="Parser-2726"><a href="#Parser-2726"><span class="linenos">2726</span></a> <span class="k">def</span> <span class="nf">_parse_set_operations</span><span class="p">(</span><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="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="Parser-2727"><a href="#Parser-2727"><span class="linenos">2727</span></a> <span class="k">if</span> <span class="ow">not</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">SET_OPERATIONS</span><span class="p">):</span> -</span><span id="Parser-2728"><a href="#Parser-2728"><span class="linenos">2728</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-2724"><a href="#Parser-2724"><span class="linenos">2724</span></a> <span class="n">locks</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="Parser-2725"><a href="#Parser-2725"><span class="linenos">2725</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">Lock</span><span class="p">,</span> <span class="n">update</span><span class="o">=</span><span class="n">update</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">wait</span><span class="o">=</span><span class="n">wait</span><span class="p">)</span> +</span><span id="Parser-2726"><a href="#Parser-2726"><span class="linenos">2726</span></a> <span class="p">)</span> +</span><span id="Parser-2727"><a href="#Parser-2727"><span class="linenos">2727</span></a> +</span><span id="Parser-2728"><a href="#Parser-2728"><span class="linenos">2728</span></a> <span class="k">return</span> <span class="n">locks</span> </span><span id="Parser-2729"><a href="#Parser-2729"><span class="linenos">2729</span></a> -</span><span id="Parser-2730"><a href="#Parser-2730"><span class="linenos">2730</span></a> <span class="n">token_type</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">token_type</span> -</span><span id="Parser-2731"><a href="#Parser-2731"><span class="linenos">2731</span></a> -</span><span id="Parser-2732"><a href="#Parser-2732"><span class="linenos">2732</span></a> <span class="k">if</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNION</span><span class="p">:</span> -</span><span id="Parser-2733"><a href="#Parser-2733"><span class="linenos">2733</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> -</span><span id="Parser-2734"><a href="#Parser-2734"><span class="linenos">2734</span></a> <span class="k">elif</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXCEPT</span><span class="p">:</span> -</span><span id="Parser-2735"><a href="#Parser-2735"><span class="linenos">2735</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span> -</span><span id="Parser-2736"><a href="#Parser-2736"><span class="linenos">2736</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2737"><a href="#Parser-2737"><span class="linenos">2737</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span> -</span><span id="Parser-2738"><a href="#Parser-2738"><span class="linenos">2738</span></a> -</span><span id="Parser-2739"><a href="#Parser-2739"><span class="linenos">2739</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><span id="Parser-2740"><a href="#Parser-2740"><span class="linenos">2740</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Parser-2741"><a href="#Parser-2741"><span class="linenos">2741</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="Parser-2742"><a href="#Parser-2742"><span class="linenos">2742</span></a> <span class="n">distinct</span><span class="o">=</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">DISTINCT</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ALL</span><span class="p">),</span> -</span><span id="Parser-2743"><a href="#Parser-2743"><span class="linenos">2743</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">)),</span> -</span><span id="Parser-2744"><a href="#Parser-2744"><span class="linenos">2744</span></a> <span class="p">)</span> -</span><span id="Parser-2745"><a href="#Parser-2745"><span class="linenos">2745</span></a> -</span><span id="Parser-2746"><a href="#Parser-2746"><span class="linenos">2746</span></a> <span class="k">def</span> <span class="nf">_parse_expression</span><span class="p">(</span><span class="bp">self</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="Parser-2747"><a href="#Parser-2747"><span class="linenos">2747</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_alias</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">())</span> -</span><span id="Parser-2748"><a href="#Parser-2748"><span class="linenos">2748</span></a> -</span><span id="Parser-2749"><a href="#Parser-2749"><span class="linenos">2749</span></a> <span class="k">def</span> <span class="nf">_parse_conjunction</span><span class="p">(</span><span class="bp">self</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="Parser-2750"><a href="#Parser-2750"><span class="linenos">2750</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONJUNCTION</span><span class="p">)</span> -</span><span id="Parser-2751"><a href="#Parser-2751"><span class="linenos">2751</span></a> -</span><span id="Parser-2752"><a href="#Parser-2752"><span class="linenos">2752</span></a> <span class="k">def</span> <span class="nf">_parse_equality</span><span class="p">(</span><span class="bp">self</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="Parser-2753"><a href="#Parser-2753"><span class="linenos">2753</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_comparison</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">EQUALITY</span><span class="p">)</span> -</span><span id="Parser-2754"><a href="#Parser-2754"><span class="linenos">2754</span></a> -</span><span id="Parser-2755"><a href="#Parser-2755"><span class="linenos">2755</span></a> <span class="k">def</span> <span class="nf">_parse_comparison</span><span class="p">(</span><span class="bp">self</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="Parser-2756"><a href="#Parser-2756"><span class="linenos">2756</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_range</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">COMPARISON</span><span class="p">)</span> -</span><span id="Parser-2757"><a href="#Parser-2757"><span class="linenos">2757</span></a> -</span><span id="Parser-2758"><a href="#Parser-2758"><span class="linenos">2758</span></a> <span class="k">def</span> <span class="nf">_parse_range</span><span class="p">(</span><span class="bp">self</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="Parser-2759"><a href="#Parser-2759"><span class="linenos">2759</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="Parser-2760"><a href="#Parser-2760"><span class="linenos">2760</span></a> <span class="n">negate</span> <span class="o">=</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">NOT</span><span class="p">)</span> +</span><span id="Parser-2730"><a href="#Parser-2730"><span class="linenos">2730</span></a> <span class="k">def</span> <span class="nf">_parse_set_operations</span><span class="p">(</span><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="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="Parser-2731"><a href="#Parser-2731"><span class="linenos">2731</span></a> <span class="k">if</span> <span class="ow">not</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">SET_OPERATIONS</span><span class="p">):</span> +</span><span id="Parser-2732"><a href="#Parser-2732"><span class="linenos">2732</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-2733"><a href="#Parser-2733"><span class="linenos">2733</span></a> +</span><span id="Parser-2734"><a href="#Parser-2734"><span class="linenos">2734</span></a> <span class="n">token_type</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">token_type</span> +</span><span id="Parser-2735"><a href="#Parser-2735"><span class="linenos">2735</span></a> +</span><span id="Parser-2736"><a href="#Parser-2736"><span class="linenos">2736</span></a> <span class="k">if</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNION</span><span class="p">:</span> +</span><span id="Parser-2737"><a href="#Parser-2737"><span class="linenos">2737</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span> +</span><span id="Parser-2738"><a href="#Parser-2738"><span class="linenos">2738</span></a> <span class="k">elif</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXCEPT</span><span class="p">:</span> +</span><span id="Parser-2739"><a href="#Parser-2739"><span class="linenos">2739</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Except</span> +</span><span id="Parser-2740"><a href="#Parser-2740"><span class="linenos">2740</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2741"><a href="#Parser-2741"><span class="linenos">2741</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Intersect</span> +</span><span id="Parser-2742"><a href="#Parser-2742"><span class="linenos">2742</span></a> +</span><span id="Parser-2743"><a href="#Parser-2743"><span class="linenos">2743</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><span id="Parser-2744"><a href="#Parser-2744"><span class="linenos">2744</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Parser-2745"><a href="#Parser-2745"><span class="linenos">2745</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="Parser-2746"><a href="#Parser-2746"><span class="linenos">2746</span></a> <span class="n">distinct</span><span class="o">=</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">DISTINCT</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ALL</span><span class="p">),</span> +</span><span id="Parser-2747"><a href="#Parser-2747"><span class="linenos">2747</span></a> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">)),</span> +</span><span id="Parser-2748"><a href="#Parser-2748"><span class="linenos">2748</span></a> <span class="p">)</span> +</span><span id="Parser-2749"><a href="#Parser-2749"><span class="linenos">2749</span></a> +</span><span id="Parser-2750"><a href="#Parser-2750"><span class="linenos">2750</span></a> <span class="k">def</span> <span class="nf">_parse_expression</span><span class="p">(</span><span class="bp">self</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="Parser-2751"><a href="#Parser-2751"><span class="linenos">2751</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_alias</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">())</span> +</span><span id="Parser-2752"><a href="#Parser-2752"><span class="linenos">2752</span></a> +</span><span id="Parser-2753"><a href="#Parser-2753"><span class="linenos">2753</span></a> <span class="k">def</span> <span class="nf">_parse_conjunction</span><span class="p">(</span><span class="bp">self</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="Parser-2754"><a href="#Parser-2754"><span class="linenos">2754</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONJUNCTION</span><span class="p">)</span> +</span><span id="Parser-2755"><a href="#Parser-2755"><span class="linenos">2755</span></a> +</span><span id="Parser-2756"><a href="#Parser-2756"><span class="linenos">2756</span></a> <span class="k">def</span> <span class="nf">_parse_equality</span><span class="p">(</span><span class="bp">self</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="Parser-2757"><a href="#Parser-2757"><span class="linenos">2757</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_comparison</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">EQUALITY</span><span class="p">)</span> +</span><span id="Parser-2758"><a href="#Parser-2758"><span class="linenos">2758</span></a> +</span><span id="Parser-2759"><a href="#Parser-2759"><span class="linenos">2759</span></a> <span class="k">def</span> <span class="nf">_parse_comparison</span><span class="p">(</span><span class="bp">self</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="Parser-2760"><a href="#Parser-2760"><span class="linenos">2760</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_range</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">COMPARISON</span><span class="p">)</span> </span><span id="Parser-2761"><a href="#Parser-2761"><span class="linenos">2761</span></a> -</span><span id="Parser-2762"><a href="#Parser-2762"><span class="linenos">2762</span></a> <span class="k">if</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">RANGE_PARSERS</span><span class="p">):</span> -</span><span id="Parser-2763"><a href="#Parser-2763"><span class="linenos">2763</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">RANGE_PARSERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">)</span> -</span><span id="Parser-2764"><a href="#Parser-2764"><span class="linenos">2764</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> -</span><span id="Parser-2765"><a href="#Parser-2765"><span class="linenos">2765</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-2766"><a href="#Parser-2766"><span class="linenos">2766</span></a> -</span><span id="Parser-2767"><a href="#Parser-2767"><span class="linenos">2767</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span> -</span><span id="Parser-2768"><a href="#Parser-2768"><span class="linenos">2768</span></a> <span class="k">elif</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">ISNULL</span><span class="p">):</span> -</span><span id="Parser-2769"><a href="#Parser-2769"><span class="linenos">2769</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">())</span> +</span><span id="Parser-2762"><a href="#Parser-2762"><span class="linenos">2762</span></a> <span class="k">def</span> <span class="nf">_parse_range</span><span class="p">(</span><span class="bp">self</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="Parser-2763"><a href="#Parser-2763"><span class="linenos">2763</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="Parser-2764"><a href="#Parser-2764"><span class="linenos">2764</span></a> <span class="n">negate</span> <span class="o">=</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">NOT</span><span class="p">)</span> +</span><span id="Parser-2765"><a href="#Parser-2765"><span class="linenos">2765</span></a> +</span><span id="Parser-2766"><a href="#Parser-2766"><span class="linenos">2766</span></a> <span class="k">if</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">RANGE_PARSERS</span><span class="p">):</span> +</span><span id="Parser-2767"><a href="#Parser-2767"><span class="linenos">2767</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">RANGE_PARSERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">)</span> +</span><span id="Parser-2768"><a href="#Parser-2768"><span class="linenos">2768</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> +</span><span id="Parser-2769"><a href="#Parser-2769"><span class="linenos">2769</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="Parser-2770"><a href="#Parser-2770"><span class="linenos">2770</span></a> -</span><span id="Parser-2771"><a href="#Parser-2771"><span class="linenos">2771</span></a> <span class="c1"># Postgres supports ISNULL and NOTNULL for conditions.</span> -</span><span id="Parser-2772"><a href="#Parser-2772"><span class="linenos">2772</span></a> <span class="c1"># https://blog.andreiavram.ro/postgresql-null-composite-type/</span> -</span><span id="Parser-2773"><a href="#Parser-2773"><span class="linenos">2773</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">NOTNULL</span><span class="p">):</span> -</span><span id="Parser-2774"><a href="#Parser-2774"><span class="linenos">2774</span></a> <span class="n">this</span> <span class="o">=</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">Is</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">())</span> -</span><span id="Parser-2775"><a href="#Parser-2775"><span class="linenos">2775</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Not</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-2776"><a href="#Parser-2776"><span class="linenos">2776</span></a> -</span><span id="Parser-2777"><a href="#Parser-2777"><span class="linenos">2777</span></a> <span class="k">if</span> <span class="n">negate</span><span class="p">:</span> -</span><span id="Parser-2778"><a href="#Parser-2778"><span class="linenos">2778</span></a> <span class="n">this</span> <span class="o">=</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">Not</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-2779"><a href="#Parser-2779"><span class="linenos">2779</span></a> -</span><span id="Parser-2780"><a href="#Parser-2780"><span class="linenos">2780</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">IS</span><span class="p">):</span> -</span><span id="Parser-2781"><a href="#Parser-2781"><span class="linenos">2781</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_is</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-2782"><a href="#Parser-2782"><span class="linenos">2782</span></a> -</span><span id="Parser-2783"><a href="#Parser-2783"><span class="linenos">2783</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-2784"><a href="#Parser-2784"><span class="linenos">2784</span></a> -</span><span id="Parser-2785"><a href="#Parser-2785"><span class="linenos">2785</span></a> <span class="k">def</span> <span class="nf">_parse_is</span><span class="p">(</span><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="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="Parser-2786"><a href="#Parser-2786"><span class="linenos">2786</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span> -</span><span id="Parser-2787"><a href="#Parser-2787"><span class="linenos">2787</span></a> <span class="n">negate</span> <span class="o">=</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">NOT</span><span class="p">)</span> +</span><span id="Parser-2771"><a href="#Parser-2771"><span class="linenos">2771</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span> +</span><span id="Parser-2772"><a href="#Parser-2772"><span class="linenos">2772</span></a> <span class="k">elif</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">ISNULL</span><span class="p">):</span> +</span><span id="Parser-2773"><a href="#Parser-2773"><span class="linenos">2773</span></a> <span class="n">this</span> <span class="o">=</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">Is</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">())</span> +</span><span id="Parser-2774"><a href="#Parser-2774"><span class="linenos">2774</span></a> +</span><span id="Parser-2775"><a href="#Parser-2775"><span class="linenos">2775</span></a> <span class="c1"># Postgres supports ISNULL and NOTNULL for conditions.</span> +</span><span id="Parser-2776"><a href="#Parser-2776"><span class="linenos">2776</span></a> <span class="c1"># https://blog.andreiavram.ro/postgresql-null-composite-type/</span> +</span><span id="Parser-2777"><a href="#Parser-2777"><span class="linenos">2777</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">NOTNULL</span><span class="p">):</span> +</span><span id="Parser-2778"><a href="#Parser-2778"><span class="linenos">2778</span></a> <span class="n">this</span> <span class="o">=</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">Is</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">())</span> +</span><span id="Parser-2779"><a href="#Parser-2779"><span class="linenos">2779</span></a> <span class="n">this</span> <span class="o">=</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">Not</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-2780"><a href="#Parser-2780"><span class="linenos">2780</span></a> +</span><span id="Parser-2781"><a href="#Parser-2781"><span class="linenos">2781</span></a> <span class="k">if</span> <span class="n">negate</span><span class="p">:</span> +</span><span id="Parser-2782"><a href="#Parser-2782"><span class="linenos">2782</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Not</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-2783"><a href="#Parser-2783"><span class="linenos">2783</span></a> +</span><span id="Parser-2784"><a href="#Parser-2784"><span class="linenos">2784</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">IS</span><span class="p">):</span> +</span><span id="Parser-2785"><a href="#Parser-2785"><span class="linenos">2785</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_is</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-2786"><a href="#Parser-2786"><span class="linenos">2786</span></a> +</span><span id="Parser-2787"><a href="#Parser-2787"><span class="linenos">2787</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="Parser-2788"><a href="#Parser-2788"><span class="linenos">2788</span></a> -</span><span id="Parser-2789"><a href="#Parser-2789"><span class="linenos">2789</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DISTINCT"</span><span class="p">,</span> <span class="s2">"FROM"</span><span class="p">):</span> -</span><span id="Parser-2790"><a href="#Parser-2790"><span class="linenos">2790</span></a> <span class="n">klass</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeEQ</span> <span class="k">if</span> <span class="n">negate</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeNEQ</span> -</span><span id="Parser-2791"><a href="#Parser-2791"><span class="linenos">2791</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">klass</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">())</span> +</span><span id="Parser-2789"><a href="#Parser-2789"><span class="linenos">2789</span></a> <span class="k">def</span> <span class="nf">_parse_is</span><span class="p">(</span><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="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="Parser-2790"><a href="#Parser-2790"><span class="linenos">2790</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span> +</span><span id="Parser-2791"><a href="#Parser-2791"><span class="linenos">2791</span></a> <span class="n">negate</span> <span class="o">=</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">NOT</span><span class="p">)</span> </span><span id="Parser-2792"><a href="#Parser-2792"><span class="linenos">2792</span></a> -</span><span id="Parser-2793"><a href="#Parser-2793"><span class="linenos">2793</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_null</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_boolean</span><span class="p">()</span> -</span><span id="Parser-2794"><a href="#Parser-2794"><span class="linenos">2794</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> -</span><span id="Parser-2795"><a href="#Parser-2795"><span class="linenos">2795</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-2796"><a href="#Parser-2796"><span class="linenos">2796</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-2797"><a href="#Parser-2797"><span class="linenos">2797</span></a> -</span><span id="Parser-2798"><a href="#Parser-2798"><span class="linenos">2798</span></a> <span class="n">this</span> <span class="o">=</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">Is</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Parser-2799"><a href="#Parser-2799"><span class="linenos">2799</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">Not</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="n">negate</span> <span class="k">else</span> <span class="n">this</span> -</span><span id="Parser-2800"><a href="#Parser-2800"><span class="linenos">2800</span></a> -</span><span id="Parser-2801"><a href="#Parser-2801"><span class="linenos">2801</span></a> <span class="k">def</span> <span class="nf">_parse_in</span><span class="p">(</span><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="n">alias</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">exp</span><span class="o">.</span><span class="n">In</span><span class="p">:</span> -</span><span id="Parser-2802"><a href="#Parser-2802"><span class="linenos">2802</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_unnest</span><span class="p">(</span><span class="n">with_alias</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Parser-2803"><a href="#Parser-2803"><span class="linenos">2803</span></a> <span class="k">if</span> <span class="n">unnest</span><span class="p">:</span> -</span><span id="Parser-2804"><a href="#Parser-2804"><span class="linenos">2804</span></a> <span class="n">this</span> <span class="o">=</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">In</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">unnest</span><span class="o">=</span><span class="n">unnest</span><span class="p">)</span> -</span><span id="Parser-2805"><a href="#Parser-2805"><span class="linenos">2805</span></a> <span class="k">elif</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_PAREN</span><span class="p">):</span> -</span><span id="Parser-2806"><a href="#Parser-2806"><span class="linenos">2806</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select_or_expression</span><span class="p">(</span><span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">))</span> -</span><span id="Parser-2807"><a href="#Parser-2807"><span class="linenos">2807</span></a> -</span><span id="Parser-2808"><a href="#Parser-2808"><span class="linenos">2808</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="Parser-2809"><a href="#Parser-2809"><span class="linenos">2809</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">In</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">query</span><span class="o">=</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> -</span><span id="Parser-2810"><a href="#Parser-2810"><span class="linenos">2810</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2811"><a href="#Parser-2811"><span class="linenos">2811</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">In</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Parser-2812"><a href="#Parser-2812"><span class="linenos">2812</span></a> -</span><span id="Parser-2813"><a href="#Parser-2813"><span class="linenos">2813</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-2814"><a href="#Parser-2814"><span class="linenos">2814</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2815"><a href="#Parser-2815"><span class="linenos">2815</span></a> <span class="n">this</span> <span class="o">=</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">In</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">field</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">())</span> +</span><span id="Parser-2793"><a href="#Parser-2793"><span class="linenos">2793</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DISTINCT"</span><span class="p">,</span> <span class="s2">"FROM"</span><span class="p">):</span> +</span><span id="Parser-2794"><a href="#Parser-2794"><span class="linenos">2794</span></a> <span class="n">klass</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeEQ</span> <span class="k">if</span> <span class="n">negate</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">NullSafeNEQ</span> +</span><span id="Parser-2795"><a href="#Parser-2795"><span class="linenos">2795</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">klass</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">())</span> +</span><span id="Parser-2796"><a href="#Parser-2796"><span class="linenos">2796</span></a> +</span><span id="Parser-2797"><a href="#Parser-2797"><span class="linenos">2797</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_null</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_boolean</span><span class="p">()</span> +</span><span id="Parser-2798"><a href="#Parser-2798"><span class="linenos">2798</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> +</span><span id="Parser-2799"><a href="#Parser-2799"><span class="linenos">2799</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-2800"><a href="#Parser-2800"><span class="linenos">2800</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2801"><a href="#Parser-2801"><span class="linenos">2801</span></a> +</span><span id="Parser-2802"><a href="#Parser-2802"><span class="linenos">2802</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Parser-2803"><a href="#Parser-2803"><span class="linenos">2803</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">Not</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="n">negate</span> <span class="k">else</span> <span class="n">this</span> +</span><span id="Parser-2804"><a href="#Parser-2804"><span class="linenos">2804</span></a> +</span><span id="Parser-2805"><a href="#Parser-2805"><span class="linenos">2805</span></a> <span class="k">def</span> <span class="nf">_parse_in</span><span class="p">(</span><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="n">alias</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">exp</span><span class="o">.</span><span class="n">In</span><span class="p">:</span> +</span><span id="Parser-2806"><a href="#Parser-2806"><span class="linenos">2806</span></a> <span class="n">unnest</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_unnest</span><span class="p">(</span><span class="n">with_alias</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Parser-2807"><a href="#Parser-2807"><span class="linenos">2807</span></a> <span class="k">if</span> <span class="n">unnest</span><span class="p">:</span> +</span><span id="Parser-2808"><a href="#Parser-2808"><span class="linenos">2808</span></a> <span class="n">this</span> <span class="o">=</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">In</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">unnest</span><span class="o">=</span><span class="n">unnest</span><span class="p">)</span> +</span><span id="Parser-2809"><a href="#Parser-2809"><span class="linenos">2809</span></a> <span class="k">elif</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_PAREN</span><span class="p">):</span> +</span><span id="Parser-2810"><a href="#Parser-2810"><span class="linenos">2810</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select_or_expression</span><span class="p">(</span><span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">))</span> +</span><span id="Parser-2811"><a href="#Parser-2811"><span class="linenos">2811</span></a> +</span><span id="Parser-2812"><a href="#Parser-2812"><span class="linenos">2812</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="Parser-2813"><a href="#Parser-2813"><span class="linenos">2813</span></a> <span class="n">this</span> <span class="o">=</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">In</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">query</span><span class="o">=</span><span class="n">expressions</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> +</span><span id="Parser-2814"><a href="#Parser-2814"><span class="linenos">2814</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2815"><a href="#Parser-2815"><span class="linenos">2815</span></a> <span class="n">this</span> <span class="o">=</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">In</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> </span><span id="Parser-2816"><a href="#Parser-2816"><span class="linenos">2816</span></a> -</span><span id="Parser-2817"><a href="#Parser-2817"><span class="linenos">2817</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-2818"><a href="#Parser-2818"><span class="linenos">2818</span></a> -</span><span id="Parser-2819"><a href="#Parser-2819"><span class="linenos">2819</span></a> <span class="k">def</span> <span class="nf">_parse_between</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">:</span> -</span><span id="Parser-2820"><a href="#Parser-2820"><span class="linenos">2820</span></a> <span class="n">low</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="Parser-2821"><a href="#Parser-2821"><span class="linenos">2821</span></a> <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">AND</span><span class="p">)</span> -</span><span id="Parser-2822"><a href="#Parser-2822"><span class="linenos">2822</span></a> <span class="n">high</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="Parser-2823"><a href="#Parser-2823"><span class="linenos">2823</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">Between</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">low</span><span class="o">=</span><span class="n">low</span><span class="p">,</span> <span class="n">high</span><span class="o">=</span><span class="n">high</span><span class="p">)</span> -</span><span id="Parser-2824"><a href="#Parser-2824"><span class="linenos">2824</span></a> -</span><span id="Parser-2825"><a href="#Parser-2825"><span class="linenos">2825</span></a> <span class="k">def</span> <span class="nf">_parse_escape</span><span class="p">(</span><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="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="Parser-2826"><a href="#Parser-2826"><span class="linenos">2826</span></a> <span class="k">if</span> <span class="ow">not</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">ESCAPE</span><span class="p">):</span> -</span><span id="Parser-2827"><a href="#Parser-2827"><span class="linenos">2827</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-2828"><a href="#Parser-2828"><span class="linenos">2828</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">Escape</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">())</span> -</span><span id="Parser-2829"><a href="#Parser-2829"><span class="linenos">2829</span></a> -</span><span id="Parser-2830"><a href="#Parser-2830"><span class="linenos">2830</span></a> <span class="k">def</span> <span class="nf">_parse_interval</span><span class="p">(</span><span class="bp">self</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">Interval</span><span class="p">]:</span> -</span><span id="Parser-2831"><a href="#Parser-2831"><span class="linenos">2831</span></a> <span class="k">if</span> <span class="ow">not</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">INTERVAL</span><span class="p">):</span> -</span><span id="Parser-2832"><a href="#Parser-2832"><span class="linenos">2832</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2817"><a href="#Parser-2817"><span class="linenos">2817</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-2818"><a href="#Parser-2818"><span class="linenos">2818</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2819"><a href="#Parser-2819"><span class="linenos">2819</span></a> <span class="n">this</span> <span class="o">=</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">In</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">field</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">())</span> +</span><span id="Parser-2820"><a href="#Parser-2820"><span class="linenos">2820</span></a> +</span><span id="Parser-2821"><a href="#Parser-2821"><span class="linenos">2821</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-2822"><a href="#Parser-2822"><span class="linenos">2822</span></a> +</span><span id="Parser-2823"><a href="#Parser-2823"><span class="linenos">2823</span></a> <span class="k">def</span> <span class="nf">_parse_between</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Between</span><span class="p">:</span> +</span><span id="Parser-2824"><a href="#Parser-2824"><span class="linenos">2824</span></a> <span class="n">low</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="Parser-2825"><a href="#Parser-2825"><span class="linenos">2825</span></a> <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">AND</span><span class="p">)</span> +</span><span id="Parser-2826"><a href="#Parser-2826"><span class="linenos">2826</span></a> <span class="n">high</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="Parser-2827"><a href="#Parser-2827"><span class="linenos">2827</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">Between</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">low</span><span class="o">=</span><span class="n">low</span><span class="p">,</span> <span class="n">high</span><span class="o">=</span><span class="n">high</span><span class="p">)</span> +</span><span id="Parser-2828"><a href="#Parser-2828"><span class="linenos">2828</span></a> +</span><span id="Parser-2829"><a href="#Parser-2829"><span class="linenos">2829</span></a> <span class="k">def</span> <span class="nf">_parse_escape</span><span class="p">(</span><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="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="Parser-2830"><a href="#Parser-2830"><span class="linenos">2830</span></a> <span class="k">if</span> <span class="ow">not</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">ESCAPE</span><span class="p">):</span> +</span><span id="Parser-2831"><a href="#Parser-2831"><span class="linenos">2831</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-2832"><a href="#Parser-2832"><span class="linenos">2832</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">Escape</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">())</span> </span><span id="Parser-2833"><a href="#Parser-2833"><span class="linenos">2833</span></a> -</span><span id="Parser-2834"><a href="#Parser-2834"><span class="linenos">2834</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> -</span><span id="Parser-2835"><a href="#Parser-2835"><span class="linenos">2835</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> -</span><span id="Parser-2836"><a href="#Parser-2836"><span class="linenos">2836</span></a> -</span><span id="Parser-2837"><a href="#Parser-2837"><span class="linenos">2837</span></a> <span class="c1"># Most dialects support, e.g., the form INTERVAL '5' day, thus we try to parse</span> -</span><span id="Parser-2838"><a href="#Parser-2838"><span class="linenos">2838</span></a> <span class="c1"># each INTERVAL expression into this canonical form so it's easy to transpile</span> -</span><span id="Parser-2839"><a href="#Parser-2839"><span class="linenos">2839</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_number</span><span class="p">:</span> -</span><span id="Parser-2840"><a href="#Parser-2840"><span class="linenos">2840</span></a> <span class="n">this</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="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> -</span><span id="Parser-2841"><a href="#Parser-2841"><span class="linenos">2841</span></a> <span class="k">elif</span> <span class="n">this</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> -</span><span id="Parser-2842"><a href="#Parser-2842"><span class="linenos">2842</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">split</span><span class="p">()</span> -</span><span id="Parser-2843"><a href="#Parser-2843"><span class="linenos">2843</span></a> -</span><span id="Parser-2844"><a href="#Parser-2844"><span class="linenos">2844</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">parts</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> -</span><span id="Parser-2845"><a href="#Parser-2845"><span class="linenos">2845</span></a> <span class="k">if</span> <span class="n">unit</span><span class="p">:</span> -</span><span id="Parser-2846"><a href="#Parser-2846"><span class="linenos">2846</span></a> <span class="c1"># this is not actually a unit, it's something else</span> -</span><span id="Parser-2847"><a href="#Parser-2847"><span class="linenos">2847</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2848"><a href="#Parser-2848"><span class="linenos">2848</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="Parser-2849"><a href="#Parser-2849"><span class="linenos">2849</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2850"><a href="#Parser-2850"><span class="linenos">2850</span></a> <span class="n">this</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="n">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> -</span><span id="Parser-2851"><a href="#Parser-2851"><span class="linenos">2851</span></a> <span class="n">unit</span> <span class="o">=</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">Var</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">parts</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> -</span><span id="Parser-2852"><a href="#Parser-2852"><span class="linenos">2852</span></a> -</span><span id="Parser-2853"><a href="#Parser-2853"><span class="linenos">2853</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">Interval</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">)</span> -</span><span id="Parser-2854"><a href="#Parser-2854"><span class="linenos">2854</span></a> -</span><span id="Parser-2855"><a href="#Parser-2855"><span class="linenos">2855</span></a> <span class="k">def</span> <span class="nf">_parse_bitwise</span><span class="p">(</span><span class="bp">self</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="Parser-2856"><a href="#Parser-2856"><span class="linenos">2856</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> -</span><span id="Parser-2857"><a href="#Parser-2857"><span class="linenos">2857</span></a> -</span><span id="Parser-2858"><a href="#Parser-2858"><span class="linenos">2858</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Parser-2859"><a href="#Parser-2859"><span class="linenos">2859</span></a> <span class="k">if</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">BITWISE</span><span class="p">):</span> -</span><span id="Parser-2860"><a href="#Parser-2860"><span class="linenos">2860</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-2861"><a href="#Parser-2861"><span class="linenos">2861</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">BITWISE</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">],</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> -</span><span id="Parser-2862"><a href="#Parser-2862"><span class="linenos">2862</span></a> <span class="p">)</span> -</span><span id="Parser-2863"><a href="#Parser-2863"><span class="linenos">2863</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">LT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LT</span><span class="p">):</span> +</span><span id="Parser-2834"><a href="#Parser-2834"><span class="linenos">2834</span></a> <span class="k">def</span> <span class="nf">_parse_interval</span><span class="p">(</span><span class="bp">self</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">Interval</span><span class="p">]:</span> +</span><span id="Parser-2835"><a href="#Parser-2835"><span class="linenos">2835</span></a> <span class="k">if</span> <span class="ow">not</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">INTERVAL</span><span class="p">):</span> +</span><span id="Parser-2836"><a href="#Parser-2836"><span class="linenos">2836</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2837"><a href="#Parser-2837"><span class="linenos">2837</span></a> +</span><span id="Parser-2838"><a href="#Parser-2838"><span class="linenos">2838</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> +</span><span id="Parser-2839"><a href="#Parser-2839"><span class="linenos">2839</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> +</span><span id="Parser-2840"><a href="#Parser-2840"><span class="linenos">2840</span></a> +</span><span id="Parser-2841"><a href="#Parser-2841"><span class="linenos">2841</span></a> <span class="c1"># Most dialects support, e.g., the form INTERVAL '5' day, thus we try to parse</span> +</span><span id="Parser-2842"><a href="#Parser-2842"><span class="linenos">2842</span></a> <span class="c1"># each INTERVAL expression into this canonical form so it's easy to transpile</span> +</span><span id="Parser-2843"><a href="#Parser-2843"><span class="linenos">2843</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_number</span><span class="p">:</span> +</span><span id="Parser-2844"><a href="#Parser-2844"><span class="linenos">2844</span></a> <span class="n">this</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="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> +</span><span id="Parser-2845"><a href="#Parser-2845"><span class="linenos">2845</span></a> <span class="k">elif</span> <span class="n">this</span> <span class="ow">and</span> <span class="n">this</span><span class="o">.</span><span class="n">is_string</span><span class="p">:</span> +</span><span id="Parser-2846"><a href="#Parser-2846"><span class="linenos">2846</span></a> <span class="n">parts</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">split</span><span class="p">()</span> +</span><span id="Parser-2847"><a href="#Parser-2847"><span class="linenos">2847</span></a> +</span><span id="Parser-2848"><a href="#Parser-2848"><span class="linenos">2848</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">parts</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> +</span><span id="Parser-2849"><a href="#Parser-2849"><span class="linenos">2849</span></a> <span class="k">if</span> <span class="n">unit</span><span class="p">:</span> +</span><span id="Parser-2850"><a href="#Parser-2850"><span class="linenos">2850</span></a> <span class="c1"># this is not actually a unit, it's something else</span> +</span><span id="Parser-2851"><a href="#Parser-2851"><span class="linenos">2851</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2852"><a href="#Parser-2852"><span class="linenos">2852</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="Parser-2853"><a href="#Parser-2853"><span class="linenos">2853</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2854"><a href="#Parser-2854"><span class="linenos">2854</span></a> <span class="n">this</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="n">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> +</span><span id="Parser-2855"><a href="#Parser-2855"><span class="linenos">2855</span></a> <span class="n">unit</span> <span class="o">=</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">Var</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">parts</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> +</span><span id="Parser-2856"><a href="#Parser-2856"><span class="linenos">2856</span></a> +</span><span id="Parser-2857"><a href="#Parser-2857"><span class="linenos">2857</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">Interval</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">)</span> +</span><span id="Parser-2858"><a href="#Parser-2858"><span class="linenos">2858</span></a> +</span><span id="Parser-2859"><a href="#Parser-2859"><span class="linenos">2859</span></a> <span class="k">def</span> <span class="nf">_parse_bitwise</span><span class="p">(</span><span class="bp">self</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="Parser-2860"><a href="#Parser-2860"><span class="linenos">2860</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> +</span><span id="Parser-2861"><a href="#Parser-2861"><span class="linenos">2861</span></a> +</span><span id="Parser-2862"><a href="#Parser-2862"><span class="linenos">2862</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Parser-2863"><a href="#Parser-2863"><span class="linenos">2863</span></a> <span class="k">if</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">BITWISE</span><span class="p">):</span> </span><span id="Parser-2864"><a href="#Parser-2864"><span class="linenos">2864</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-2865"><a href="#Parser-2865"><span class="linenos">2865</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> +</span><span id="Parser-2865"><a href="#Parser-2865"><span class="linenos">2865</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">BITWISE</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">],</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> </span><span id="Parser-2866"><a href="#Parser-2866"><span class="linenos">2866</span></a> <span class="p">)</span> -</span><span id="Parser-2867"><a href="#Parser-2867"><span class="linenos">2867</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">GT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GT</span><span class="p">):</span> +</span><span id="Parser-2867"><a href="#Parser-2867"><span class="linenos">2867</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">LT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LT</span><span class="p">):</span> </span><span id="Parser-2868"><a href="#Parser-2868"><span class="linenos">2868</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-2869"><a href="#Parser-2869"><span class="linenos">2869</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> +</span><span id="Parser-2869"><a href="#Parser-2869"><span class="linenos">2869</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseLeftShift</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> </span><span id="Parser-2870"><a href="#Parser-2870"><span class="linenos">2870</span></a> <span class="p">)</span> -</span><span id="Parser-2871"><a href="#Parser-2871"><span class="linenos">2871</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2872"><a href="#Parser-2872"><span class="linenos">2872</span></a> <span class="k">break</span> -</span><span id="Parser-2873"><a href="#Parser-2873"><span class="linenos">2873</span></a> -</span><span id="Parser-2874"><a href="#Parser-2874"><span class="linenos">2874</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-2875"><a href="#Parser-2875"><span class="linenos">2875</span></a> -</span><span id="Parser-2876"><a href="#Parser-2876"><span class="linenos">2876</span></a> <span class="k">def</span> <span class="nf">_parse_term</span><span class="p">(</span><span class="bp">self</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="Parser-2877"><a href="#Parser-2877"><span class="linenos">2877</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_factor</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">TERM</span><span class="p">)</span> -</span><span id="Parser-2878"><a href="#Parser-2878"><span class="linenos">2878</span></a> -</span><span id="Parser-2879"><a href="#Parser-2879"><span class="linenos">2879</span></a> <span class="k">def</span> <span class="nf">_parse_factor</span><span class="p">(</span><span class="bp">self</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="Parser-2880"><a href="#Parser-2880"><span class="linenos">2880</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_unary</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">FACTOR</span><span class="p">)</span> -</span><span id="Parser-2881"><a href="#Parser-2881"><span class="linenos">2881</span></a> -</span><span id="Parser-2882"><a href="#Parser-2882"><span class="linenos">2882</span></a> <span class="k">def</span> <span class="nf">_parse_unary</span><span class="p">(</span><span class="bp">self</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="Parser-2883"><a href="#Parser-2883"><span class="linenos">2883</span></a> <span class="k">if</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">UNARY_PARSERS</span><span class="p">):</span> -</span><span id="Parser-2884"><a href="#Parser-2884"><span class="linenos">2884</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNARY_PARSERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> -</span><span id="Parser-2885"><a href="#Parser-2885"><span class="linenos">2885</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_at_time_zone</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">())</span> -</span><span id="Parser-2886"><a href="#Parser-2886"><span class="linenos">2886</span></a> -</span><span id="Parser-2887"><a href="#Parser-2887"><span class="linenos">2887</span></a> <span class="k">def</span> <span class="nf">_parse_type</span><span class="p">(</span><span class="bp">self</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="Parser-2888"><a href="#Parser-2888"><span class="linenos">2888</span></a> <span class="n">interval</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_interval</span><span class="p">()</span> -</span><span id="Parser-2889"><a href="#Parser-2889"><span class="linenos">2889</span></a> <span class="k">if</span> <span class="n">interval</span><span class="p">:</span> -</span><span id="Parser-2890"><a href="#Parser-2890"><span class="linenos">2890</span></a> <span class="k">return</span> <span class="n">interval</span> -</span><span id="Parser-2891"><a href="#Parser-2891"><span class="linenos">2891</span></a> -</span><span id="Parser-2892"><a href="#Parser-2892"><span class="linenos">2892</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="Parser-2893"><a href="#Parser-2893"><span class="linenos">2893</span></a> <span class="n">data_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-2894"><a href="#Parser-2894"><span class="linenos">2894</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> +</span><span id="Parser-2871"><a href="#Parser-2871"><span class="linenos">2871</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">GT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GT</span><span class="p">):</span> +</span><span id="Parser-2872"><a href="#Parser-2872"><span class="linenos">2872</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-2873"><a href="#Parser-2873"><span class="linenos">2873</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">BitwiseRightShift</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">()</span> +</span><span id="Parser-2874"><a href="#Parser-2874"><span class="linenos">2874</span></a> <span class="p">)</span> +</span><span id="Parser-2875"><a href="#Parser-2875"><span class="linenos">2875</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2876"><a href="#Parser-2876"><span class="linenos">2876</span></a> <span class="k">break</span> +</span><span id="Parser-2877"><a href="#Parser-2877"><span class="linenos">2877</span></a> +</span><span id="Parser-2878"><a href="#Parser-2878"><span class="linenos">2878</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-2879"><a href="#Parser-2879"><span class="linenos">2879</span></a> +</span><span id="Parser-2880"><a href="#Parser-2880"><span class="linenos">2880</span></a> <span class="k">def</span> <span class="nf">_parse_term</span><span class="p">(</span><span class="bp">self</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="Parser-2881"><a href="#Parser-2881"><span class="linenos">2881</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_factor</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">TERM</span><span class="p">)</span> +</span><span id="Parser-2882"><a href="#Parser-2882"><span class="linenos">2882</span></a> +</span><span id="Parser-2883"><a href="#Parser-2883"><span class="linenos">2883</span></a> <span class="k">def</span> <span class="nf">_parse_factor</span><span class="p">(</span><span class="bp">self</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="Parser-2884"><a href="#Parser-2884"><span class="linenos">2884</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_tokens</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_unary</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">FACTOR</span><span class="p">)</span> +</span><span id="Parser-2885"><a href="#Parser-2885"><span class="linenos">2885</span></a> +</span><span id="Parser-2886"><a href="#Parser-2886"><span class="linenos">2886</span></a> <span class="k">def</span> <span class="nf">_parse_unary</span><span class="p">(</span><span class="bp">self</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="Parser-2887"><a href="#Parser-2887"><span class="linenos">2887</span></a> <span class="k">if</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">UNARY_PARSERS</span><span class="p">):</span> +</span><span id="Parser-2888"><a href="#Parser-2888"><span class="linenos">2888</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNARY_PARSERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> +</span><span id="Parser-2889"><a href="#Parser-2889"><span class="linenos">2889</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_at_time_zone</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">())</span> +</span><span id="Parser-2890"><a href="#Parser-2890"><span class="linenos">2890</span></a> +</span><span id="Parser-2891"><a href="#Parser-2891"><span class="linenos">2891</span></a> <span class="k">def</span> <span class="nf">_parse_type</span><span class="p">(</span><span class="bp">self</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="Parser-2892"><a href="#Parser-2892"><span class="linenos">2892</span></a> <span class="n">interval</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_interval</span><span class="p">()</span> +</span><span id="Parser-2893"><a href="#Parser-2893"><span class="linenos">2893</span></a> <span class="k">if</span> <span class="n">interval</span><span class="p">:</span> +</span><span id="Parser-2894"><a href="#Parser-2894"><span class="linenos">2894</span></a> <span class="k">return</span> <span class="n">interval</span> </span><span id="Parser-2895"><a href="#Parser-2895"><span class="linenos">2895</span></a> -</span><span id="Parser-2896"><a href="#Parser-2896"><span class="linenos">2896</span></a> <span class="k">if</span> <span class="n">data_type</span><span class="p">:</span> -</span><span id="Parser-2897"><a href="#Parser-2897"><span class="linenos">2897</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">Literal</span><span class="p">):</span> -</span><span id="Parser-2898"><a href="#Parser-2898"><span class="linenos">2898</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TYPE_LITERAL_PARSERS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">data_type</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-2899"><a href="#Parser-2899"><span class="linenos">2899</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> -</span><span id="Parser-2900"><a href="#Parser-2900"><span class="linenos">2900</span></a> <span class="k">return</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">data_type</span><span class="p">)</span> -</span><span id="Parser-2901"><a href="#Parser-2901"><span class="linenos">2901</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">Cast</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="n">data_type</span><span class="p">)</span> -</span><span id="Parser-2902"><a href="#Parser-2902"><span class="linenos">2902</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">data_type</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> -</span><span id="Parser-2903"><a href="#Parser-2903"><span class="linenos">2903</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-2904"><a href="#Parser-2904"><span class="linenos">2904</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> -</span><span id="Parser-2905"><a href="#Parser-2905"><span class="linenos">2905</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_ops</span><span class="p">(</span><span class="n">data_type</span><span class="p">)</span> -</span><span id="Parser-2906"><a href="#Parser-2906"><span class="linenos">2906</span></a> -</span><span id="Parser-2907"><a href="#Parser-2907"><span class="linenos">2907</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-2908"><a href="#Parser-2908"><span class="linenos">2908</span></a> -</span><span id="Parser-2909"><a href="#Parser-2909"><span class="linenos">2909</span></a> <span class="k">def</span> <span class="nf">_parse_type_size</span><span class="p">(</span><span class="bp">self</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">DataTypeSize</span><span class="p">]:</span> -</span><span id="Parser-2910"><a href="#Parser-2910"><span class="linenos">2910</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">()</span> -</span><span id="Parser-2911"><a href="#Parser-2911"><span class="linenos">2911</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> -</span><span id="Parser-2912"><a href="#Parser-2912"><span class="linenos">2912</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-2913"><a href="#Parser-2913"><span class="linenos">2913</span></a> -</span><span id="Parser-2914"><a href="#Parser-2914"><span class="linenos">2914</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><span id="Parser-2915"><a href="#Parser-2915"><span class="linenos">2915</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataTypeSize</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-2916"><a href="#Parser-2916"><span class="linenos">2916</span></a> <span class="p">)</span> +</span><span id="Parser-2896"><a href="#Parser-2896"><span class="linenos">2896</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="Parser-2897"><a href="#Parser-2897"><span class="linenos">2897</span></a> <span class="n">data_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-2898"><a href="#Parser-2898"><span class="linenos">2898</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> +</span><span id="Parser-2899"><a href="#Parser-2899"><span class="linenos">2899</span></a> +</span><span id="Parser-2900"><a href="#Parser-2900"><span class="linenos">2900</span></a> <span class="k">if</span> <span class="n">data_type</span><span class="p">:</span> +</span><span id="Parser-2901"><a href="#Parser-2901"><span class="linenos">2901</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">Literal</span><span class="p">):</span> +</span><span id="Parser-2902"><a href="#Parser-2902"><span class="linenos">2902</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TYPE_LITERAL_PARSERS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">data_type</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-2903"><a href="#Parser-2903"><span class="linenos">2903</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> +</span><span id="Parser-2904"><a href="#Parser-2904"><span class="linenos">2904</span></a> <span class="k">return</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">data_type</span><span class="p">)</span> +</span><span id="Parser-2905"><a href="#Parser-2905"><span class="linenos">2905</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">Cast</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="n">data_type</span><span class="p">)</span> +</span><span id="Parser-2906"><a href="#Parser-2906"><span class="linenos">2906</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">data_type</span><span class="o">.</span><span class="n">expressions</span><span class="p">:</span> +</span><span id="Parser-2907"><a href="#Parser-2907"><span class="linenos">2907</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-2908"><a href="#Parser-2908"><span class="linenos">2908</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">()</span> +</span><span id="Parser-2909"><a href="#Parser-2909"><span class="linenos">2909</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_ops</span><span class="p">(</span><span class="n">data_type</span><span class="p">)</span> +</span><span id="Parser-2910"><a href="#Parser-2910"><span class="linenos">2910</span></a> +</span><span id="Parser-2911"><a href="#Parser-2911"><span class="linenos">2911</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-2912"><a href="#Parser-2912"><span class="linenos">2912</span></a> +</span><span id="Parser-2913"><a href="#Parser-2913"><span class="linenos">2913</span></a> <span class="k">def</span> <span class="nf">_parse_type_size</span><span class="p">(</span><span class="bp">self</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">DataTypeSize</span><span class="p">]:</span> +</span><span id="Parser-2914"><a href="#Parser-2914"><span class="linenos">2914</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">()</span> +</span><span id="Parser-2915"><a href="#Parser-2915"><span class="linenos">2915</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> +</span><span id="Parser-2916"><a href="#Parser-2916"><span class="linenos">2916</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="Parser-2917"><a href="#Parser-2917"><span class="linenos">2917</span></a> -</span><span id="Parser-2918"><a href="#Parser-2918"><span class="linenos">2918</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span> -</span><span id="Parser-2919"><a href="#Parser-2919"><span class="linenos">2919</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</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="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-2920"><a href="#Parser-2920"><span class="linenos">2920</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="Parser-2921"><a href="#Parser-2921"><span class="linenos">2921</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="Parser-2922"><a href="#Parser-2922"><span class="linenos">2922</span></a> -</span><span id="Parser-2923"><a href="#Parser-2923"><span class="linenos">2923</span></a> <span class="n">prefix</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SYSUDTLIB"</span><span class="p">,</span> <span class="s2">"."</span><span class="p">)</span> -</span><span id="Parser-2924"><a href="#Parser-2924"><span class="linenos">2924</span></a> -</span><span id="Parser-2925"><a href="#Parser-2925"><span class="linenos">2925</span></a> <span class="k">if</span> <span class="ow">not</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">TYPE_TOKENS</span><span class="p">):</span> -</span><span id="Parser-2926"><a href="#Parser-2926"><span class="linenos">2926</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-2927"><a href="#Parser-2927"><span class="linenos">2927</span></a> -</span><span id="Parser-2928"><a href="#Parser-2928"><span class="linenos">2928</span></a> <span class="n">type_token</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">token_type</span> -</span><span id="Parser-2929"><a href="#Parser-2929"><span class="linenos">2929</span></a> -</span><span id="Parser-2930"><a href="#Parser-2930"><span class="linenos">2930</span></a> <span class="k">if</span> <span class="n">type_token</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PSEUDO_TYPE</span><span class="p">:</span> -</span><span id="Parser-2931"><a href="#Parser-2931"><span class="linenos">2931</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">PseudoType</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="Parser-2932"><a href="#Parser-2932"><span class="linenos">2932</span></a> -</span><span id="Parser-2933"><a href="#Parser-2933"><span class="linenos">2933</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="n">type_token</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">NESTED_TYPE_TOKENS</span> -</span><span id="Parser-2934"><a href="#Parser-2934"><span class="linenos">2934</span></a> <span class="n">is_struct</span> <span class="o">=</span> <span class="n">type_token</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span> -</span><span id="Parser-2935"><a href="#Parser-2935"><span class="linenos">2935</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-2936"><a href="#Parser-2936"><span class="linenos">2936</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-2937"><a href="#Parser-2937"><span class="linenos">2937</span></a> -</span><span id="Parser-2938"><a href="#Parser-2938"><span class="linenos">2938</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_PAREN</span><span class="p">):</span> -</span><span id="Parser-2939"><a href="#Parser-2939"><span class="linenos">2939</span></a> <span class="k">if</span> <span class="n">is_struct</span><span class="p">:</span> -</span><span id="Parser-2940"><a href="#Parser-2940"><span class="linenos">2940</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_struct_types</span><span class="p">)</span> -</span><span id="Parser-2941"><a href="#Parser-2941"><span class="linenos">2941</span></a> <span class="k">elif</span> <span class="n">nested</span><span class="p">:</span> -</span><span id="Parser-2942"><a href="#Parser-2942"><span class="linenos">2942</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> -</span><span id="Parser-2943"><a href="#Parser-2943"><span class="linenos">2943</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="Parser-2944"><a href="#Parser-2944"><span class="linenos">2944</span></a> <span class="p">)</span> -</span><span id="Parser-2945"><a href="#Parser-2945"><span class="linenos">2945</span></a> <span class="k">elif</span> <span class="n">type_token</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">ENUM_TYPE_TOKENS</span><span class="p">:</span> -</span><span id="Parser-2946"><a href="#Parser-2946"><span class="linenos">2946</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">)</span> -</span><span id="Parser-2947"><a href="#Parser-2947"><span class="linenos">2947</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2948"><a href="#Parser-2948"><span class="linenos">2948</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_type_size</span><span class="p">)</span> -</span><span id="Parser-2949"><a href="#Parser-2949"><span class="linenos">2949</span></a> -</span><span id="Parser-2950"><a href="#Parser-2950"><span class="linenos">2950</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span> <span class="ow">or</span> <span class="ow">not</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">R_PAREN</span><span class="p">):</span> -</span><span id="Parser-2951"><a href="#Parser-2951"><span class="linenos">2951</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-2952"><a href="#Parser-2952"><span class="linenos">2952</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2918"><a href="#Parser-2918"><span class="linenos">2918</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><span id="Parser-2919"><a href="#Parser-2919"><span class="linenos">2919</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DataTypeSize</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-2920"><a href="#Parser-2920"><span class="linenos">2920</span></a> <span class="p">)</span> +</span><span id="Parser-2921"><a href="#Parser-2921"><span class="linenos">2921</span></a> +</span><span id="Parser-2922"><a href="#Parser-2922"><span class="linenos">2922</span></a> <span class="k">def</span> <span class="nf">_parse_types</span><span class="p">(</span> +</span><span id="Parser-2923"><a href="#Parser-2923"><span class="linenos">2923</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">check_func</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="n">schema</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-2924"><a href="#Parser-2924"><span class="linenos">2924</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="Parser-2925"><a href="#Parser-2925"><span class="linenos">2925</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="Parser-2926"><a href="#Parser-2926"><span class="linenos">2926</span></a> +</span><span id="Parser-2927"><a href="#Parser-2927"><span class="linenos">2927</span></a> <span class="n">prefix</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SYSUDTLIB"</span><span class="p">,</span> <span class="s2">"."</span><span class="p">)</span> +</span><span id="Parser-2928"><a href="#Parser-2928"><span class="linenos">2928</span></a> +</span><span id="Parser-2929"><a href="#Parser-2929"><span class="linenos">2929</span></a> <span class="k">if</span> <span class="ow">not</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">TYPE_TOKENS</span><span class="p">):</span> +</span><span id="Parser-2930"><a href="#Parser-2930"><span class="linenos">2930</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2931"><a href="#Parser-2931"><span class="linenos">2931</span></a> +</span><span id="Parser-2932"><a href="#Parser-2932"><span class="linenos">2932</span></a> <span class="n">type_token</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">token_type</span> +</span><span id="Parser-2933"><a href="#Parser-2933"><span class="linenos">2933</span></a> +</span><span id="Parser-2934"><a href="#Parser-2934"><span class="linenos">2934</span></a> <span class="k">if</span> <span class="n">type_token</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PSEUDO_TYPE</span><span class="p">:</span> +</span><span id="Parser-2935"><a href="#Parser-2935"><span class="linenos">2935</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">PseudoType</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="Parser-2936"><a href="#Parser-2936"><span class="linenos">2936</span></a> +</span><span id="Parser-2937"><a href="#Parser-2937"><span class="linenos">2937</span></a> <span class="n">nested</span> <span class="o">=</span> <span class="n">type_token</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">NESTED_TYPE_TOKENS</span> +</span><span id="Parser-2938"><a href="#Parser-2938"><span class="linenos">2938</span></a> <span class="n">is_struct</span> <span class="o">=</span> <span class="n">type_token</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span> +</span><span id="Parser-2939"><a href="#Parser-2939"><span class="linenos">2939</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-2940"><a href="#Parser-2940"><span class="linenos">2940</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-2941"><a href="#Parser-2941"><span class="linenos">2941</span></a> +</span><span id="Parser-2942"><a href="#Parser-2942"><span class="linenos">2942</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_PAREN</span><span class="p">):</span> +</span><span id="Parser-2943"><a href="#Parser-2943"><span class="linenos">2943</span></a> <span class="k">if</span> <span class="n">is_struct</span><span class="p">:</span> +</span><span id="Parser-2944"><a href="#Parser-2944"><span class="linenos">2944</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_struct_types</span><span class="p">)</span> +</span><span id="Parser-2945"><a href="#Parser-2945"><span class="linenos">2945</span></a> <span class="k">elif</span> <span class="n">nested</span><span class="p">:</span> +</span><span id="Parser-2946"><a href="#Parser-2946"><span class="linenos">2946</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> +</span><span id="Parser-2947"><a href="#Parser-2947"><span class="linenos">2947</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="Parser-2948"><a href="#Parser-2948"><span class="linenos">2948</span></a> <span class="p">)</span> +</span><span id="Parser-2949"><a href="#Parser-2949"><span class="linenos">2949</span></a> <span class="k">elif</span> <span class="n">type_token</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">ENUM_TYPE_TOKENS</span><span class="p">:</span> +</span><span id="Parser-2950"><a href="#Parser-2950"><span class="linenos">2950</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">)</span> +</span><span id="Parser-2951"><a href="#Parser-2951"><span class="linenos">2951</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2952"><a href="#Parser-2952"><span class="linenos">2952</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_type_size</span><span class="p">)</span> </span><span id="Parser-2953"><a href="#Parser-2953"><span class="linenos">2953</span></a> -</span><span id="Parser-2954"><a href="#Parser-2954"><span class="linenos">2954</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Parser-2955"><a href="#Parser-2955"><span class="linenos">2955</span></a> -</span><span id="Parser-2956"><a href="#Parser-2956"><span class="linenos">2956</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACKET</span><span class="p">):</span> -</span><span id="Parser-2957"><a href="#Parser-2957"><span class="linenos">2957</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span> -</span><span id="Parser-2958"><a href="#Parser-2958"><span class="linenos">2958</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span><span class="p">,</span> -</span><span id="Parser-2959"><a href="#Parser-2959"><span class="linenos">2959</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">build</span><span class="p">(</span><span class="n">type_token</span><span class="o">.</span><span class="n">value</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)],</span> -</span><span id="Parser-2960"><a href="#Parser-2960"><span class="linenos">2960</span></a> <span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> -</span><span id="Parser-2961"><a href="#Parser-2961"><span class="linenos">2961</span></a> <span class="p">)</span> -</span><span id="Parser-2962"><a href="#Parser-2962"><span class="linenos">2962</span></a> -</span><span id="Parser-2963"><a href="#Parser-2963"><span class="linenos">2963</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACKET</span><span class="p">):</span> -</span><span id="Parser-2964"><a href="#Parser-2964"><span class="linenos">2964</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">this</span><span class="p">],</span> <span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-2965"><a href="#Parser-2965"><span class="linenos">2965</span></a> -</span><span id="Parser-2966"><a href="#Parser-2966"><span class="linenos">2966</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-2967"><a href="#Parser-2967"><span class="linenos">2967</span></a> -</span><span id="Parser-2968"><a href="#Parser-2968"><span class="linenos">2968</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_BRACKET</span><span class="p">):</span> -</span><span id="Parser-2969"><a href="#Parser-2969"><span class="linenos">2969</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-2970"><a href="#Parser-2970"><span class="linenos">2970</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2954"><a href="#Parser-2954"><span class="linenos">2954</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span> <span class="ow">or</span> <span class="ow">not</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">R_PAREN</span><span class="p">):</span> +</span><span id="Parser-2955"><a href="#Parser-2955"><span class="linenos">2955</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-2956"><a href="#Parser-2956"><span class="linenos">2956</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2957"><a href="#Parser-2957"><span class="linenos">2957</span></a> +</span><span id="Parser-2958"><a href="#Parser-2958"><span class="linenos">2958</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Parser-2959"><a href="#Parser-2959"><span class="linenos">2959</span></a> +</span><span id="Parser-2960"><a href="#Parser-2960"><span class="linenos">2960</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACKET</span><span class="p">):</span> +</span><span id="Parser-2961"><a href="#Parser-2961"><span class="linenos">2961</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span> +</span><span id="Parser-2962"><a href="#Parser-2962"><span class="linenos">2962</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span><span class="p">,</span> +</span><span id="Parser-2963"><a href="#Parser-2963"><span class="linenos">2963</span></a> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">build</span><span class="p">(</span><span class="n">type_token</span><span class="o">.</span><span class="n">value</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)],</span> +</span><span id="Parser-2964"><a href="#Parser-2964"><span class="linenos">2964</span></a> <span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> +</span><span id="Parser-2965"><a href="#Parser-2965"><span class="linenos">2965</span></a> <span class="p">)</span> +</span><span id="Parser-2966"><a href="#Parser-2966"><span class="linenos">2966</span></a> +</span><span id="Parser-2967"><a href="#Parser-2967"><span class="linenos">2967</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACKET</span><span class="p">):</span> +</span><span id="Parser-2968"><a href="#Parser-2968"><span class="linenos">2968</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">ARRAY</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</span><span class="n">this</span><span class="p">],</span> <span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-2969"><a href="#Parser-2969"><span class="linenos">2969</span></a> +</span><span id="Parser-2970"><a href="#Parser-2970"><span class="linenos">2970</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="Parser-2971"><a href="#Parser-2971"><span class="linenos">2971</span></a> -</span><span id="Parser-2972"><a href="#Parser-2972"><span class="linenos">2972</span></a> <span class="n">values</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Parser-2973"><a href="#Parser-2973"><span class="linenos">2973</span></a> <span class="k">if</span> <span class="n">nested</span> <span class="ow">and</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">LT</span><span class="p">):</span> -</span><span id="Parser-2974"><a href="#Parser-2974"><span class="linenos">2974</span></a> <span class="k">if</span> <span class="n">is_struct</span><span class="p">:</span> -</span><span id="Parser-2975"><a href="#Parser-2975"><span class="linenos">2975</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_struct_types</span><span class="p">)</span> -</span><span id="Parser-2976"><a href="#Parser-2976"><span class="linenos">2976</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-2977"><a href="#Parser-2977"><span class="linenos">2977</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> -</span><span id="Parser-2978"><a href="#Parser-2978"><span class="linenos">2978</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> -</span><span id="Parser-2979"><a href="#Parser-2979"><span class="linenos">2979</span></a> <span class="p">)</span> -</span><span id="Parser-2980"><a href="#Parser-2980"><span class="linenos">2980</span></a> -</span><span id="Parser-2981"><a href="#Parser-2981"><span class="linenos">2981</span></a> <span class="k">if</span> <span class="ow">not</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">GT</span><span class="p">):</span> -</span><span id="Parser-2982"><a href="#Parser-2982"><span class="linenos">2982</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting >"</span><span class="p">)</span> -</span><span id="Parser-2983"><a href="#Parser-2983"><span class="linenos">2983</span></a> -</span><span id="Parser-2984"><a href="#Parser-2984"><span class="linenos">2984</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">)):</span> -</span><span id="Parser-2985"><a href="#Parser-2985"><span class="linenos">2985</span></a> <span class="n">values</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="Parser-2986"><a href="#Parser-2986"><span class="linenos">2986</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACKET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_PAREN</span><span class="p">))</span> +</span><span id="Parser-2972"><a href="#Parser-2972"><span class="linenos">2972</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_BRACKET</span><span class="p">):</span> +</span><span id="Parser-2973"><a href="#Parser-2973"><span class="linenos">2973</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-2974"><a href="#Parser-2974"><span class="linenos">2974</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-2975"><a href="#Parser-2975"><span class="linenos">2975</span></a> +</span><span id="Parser-2976"><a href="#Parser-2976"><span class="linenos">2976</span></a> <span class="n">values</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Parser-2977"><a href="#Parser-2977"><span class="linenos">2977</span></a> <span class="k">if</span> <span class="n">nested</span> <span class="ow">and</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">LT</span><span class="p">):</span> +</span><span id="Parser-2978"><a href="#Parser-2978"><span class="linenos">2978</span></a> <span class="k">if</span> <span class="n">is_struct</span><span class="p">:</span> +</span><span id="Parser-2979"><a href="#Parser-2979"><span class="linenos">2979</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_struct_types</span><span class="p">)</span> +</span><span id="Parser-2980"><a href="#Parser-2980"><span class="linenos">2980</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-2981"><a href="#Parser-2981"><span class="linenos">2981</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> +</span><span id="Parser-2982"><a href="#Parser-2982"><span class="linenos">2982</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">check_func</span><span class="o">=</span><span class="n">check_func</span><span class="p">,</span> <span class="n">schema</span><span class="o">=</span><span class="n">schema</span><span class="p">)</span> +</span><span id="Parser-2983"><a href="#Parser-2983"><span class="linenos">2983</span></a> <span class="p">)</span> +</span><span id="Parser-2984"><a href="#Parser-2984"><span class="linenos">2984</span></a> +</span><span id="Parser-2985"><a href="#Parser-2985"><span class="linenos">2985</span></a> <span class="k">if</span> <span class="ow">not</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">GT</span><span class="p">):</span> +</span><span id="Parser-2986"><a href="#Parser-2986"><span class="linenos">2986</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting >"</span><span class="p">)</span> </span><span id="Parser-2987"><a href="#Parser-2987"><span class="linenos">2987</span></a> -</span><span id="Parser-2988"><a href="#Parser-2988"><span class="linenos">2988</span></a> <span class="n">value</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="Parser-2989"><a href="#Parser-2989"><span class="linenos">2989</span></a> <span class="k">if</span> <span class="n">type_token</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIMESTAMPS</span><span class="p">:</span> -</span><span id="Parser-2990"><a href="#Parser-2990"><span class="linenos">2990</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ZONE"</span><span class="p">):</span> -</span><span id="Parser-2991"><a href="#Parser-2991"><span class="linenos">2991</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-2992"><a href="#Parser-2992"><span class="linenos">2992</span></a> <span class="n">value</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Parser-2993"><a href="#Parser-2993"><span class="linenos">2993</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"LOCAL"</span><span class="p">,</span> <span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ZONE"</span><span class="p">):</span> -</span><span id="Parser-2994"><a href="#Parser-2994"><span class="linenos">2994</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-2995"><a href="#Parser-2995"><span class="linenos">2995</span></a> <span class="n">value</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Parser-2996"><a href="#Parser-2996"><span class="linenos">2996</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITHOUT"</span><span class="p">,</span> <span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ZONE"</span><span class="p">):</span> -</span><span id="Parser-2997"><a href="#Parser-2997"><span class="linenos">2997</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-2998"><a href="#Parser-2998"><span class="linenos">2998</span></a> <span class="k">elif</span> <span class="n">type_token</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INTERVAL</span><span class="p">:</span> -</span><span id="Parser-2999"><a href="#Parser-2999"><span class="linenos">2999</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> -</span><span id="Parser-3000"><a href="#Parser-3000"><span class="linenos">3000</span></a> -</span><span id="Parser-3001"><a href="#Parser-3001"><span class="linenos">3001</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">unit</span><span class="p">:</span> -</span><span id="Parser-3002"><a href="#Parser-3002"><span class="linenos">3002</span></a> <span class="n">value</span> <span class="o">=</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">DataType</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INTERVAL</span><span class="p">)</span> -</span><span id="Parser-3003"><a href="#Parser-3003"><span class="linenos">3003</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3004"><a href="#Parser-3004"><span class="linenos">3004</span></a> <span class="n">value</span> <span class="o">=</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">Interval</span><span class="p">,</span> <span class="n">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">)</span> -</span><span id="Parser-3005"><a href="#Parser-3005"><span class="linenos">3005</span></a> -</span><span id="Parser-3006"><a href="#Parser-3006"><span class="linenos">3006</span></a> <span class="k">if</span> <span class="n">maybe_func</span> <span class="ow">and</span> <span class="n">check_func</span><span class="p">:</span> -</span><span id="Parser-3007"><a href="#Parser-3007"><span class="linenos">3007</span></a> <span class="n">index2</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="Parser-3008"><a href="#Parser-3008"><span class="linenos">3008</span></a> <span class="n">peek</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="Parser-2988"><a href="#Parser-2988"><span class="linenos">2988</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">)):</span> +</span><span id="Parser-2989"><a href="#Parser-2989"><span class="linenos">2989</span></a> <span class="n">values</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="Parser-2990"><a href="#Parser-2990"><span class="linenos">2990</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACKET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_PAREN</span><span class="p">))</span> +</span><span id="Parser-2991"><a href="#Parser-2991"><span class="linenos">2991</span></a> +</span><span id="Parser-2992"><a href="#Parser-2992"><span class="linenos">2992</span></a> <span class="n">value</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="Parser-2993"><a href="#Parser-2993"><span class="linenos">2993</span></a> <span class="k">if</span> <span class="n">type_token</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIMESTAMPS</span><span class="p">:</span> +</span><span id="Parser-2994"><a href="#Parser-2994"><span class="linenos">2994</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ZONE"</span><span class="p">):</span> +</span><span id="Parser-2995"><a href="#Parser-2995"><span class="linenos">2995</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-2996"><a href="#Parser-2996"><span class="linenos">2996</span></a> <span class="n">value</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Parser-2997"><a href="#Parser-2997"><span class="linenos">2997</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"LOCAL"</span><span class="p">,</span> <span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ZONE"</span><span class="p">):</span> +</span><span id="Parser-2998"><a href="#Parser-2998"><span class="linenos">2998</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-2999"><a href="#Parser-2999"><span class="linenos">2999</span></a> <span class="n">value</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Parser-3000"><a href="#Parser-3000"><span class="linenos">3000</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITHOUT"</span><span class="p">,</span> <span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ZONE"</span><span class="p">):</span> +</span><span id="Parser-3001"><a href="#Parser-3001"><span class="linenos">3001</span></a> <span class="n">maybe_func</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-3002"><a href="#Parser-3002"><span class="linenos">3002</span></a> <span class="k">elif</span> <span class="n">type_token</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INTERVAL</span><span class="p">:</span> +</span><span id="Parser-3003"><a href="#Parser-3003"><span class="linenos">3003</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> +</span><span id="Parser-3004"><a href="#Parser-3004"><span class="linenos">3004</span></a> +</span><span id="Parser-3005"><a href="#Parser-3005"><span class="linenos">3005</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">unit</span><span class="p">:</span> +</span><span id="Parser-3006"><a href="#Parser-3006"><span class="linenos">3006</span></a> <span class="n">value</span> <span class="o">=</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">DataType</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INTERVAL</span><span class="p">)</span> +</span><span id="Parser-3007"><a href="#Parser-3007"><span class="linenos">3007</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3008"><a href="#Parser-3008"><span class="linenos">3008</span></a> <span class="n">value</span> <span class="o">=</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">Interval</span><span class="p">,</span> <span class="n">unit</span><span class="o">=</span><span class="n">unit</span><span class="p">)</span> </span><span id="Parser-3009"><a href="#Parser-3009"><span class="linenos">3009</span></a> -</span><span id="Parser-3010"><a href="#Parser-3010"><span class="linenos">3010</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">peek</span><span class="p">:</span> -</span><span id="Parser-3011"><a href="#Parser-3011"><span class="linenos">3011</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-3012"><a href="#Parser-3012"><span class="linenos">3012</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-3010"><a href="#Parser-3010"><span class="linenos">3010</span></a> <span class="k">if</span> <span class="n">maybe_func</span> <span class="ow">and</span> <span class="n">check_func</span><span class="p">:</span> +</span><span id="Parser-3011"><a href="#Parser-3011"><span class="linenos">3011</span></a> <span class="n">index2</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="Parser-3012"><a href="#Parser-3012"><span class="linenos">3012</span></a> <span class="n">peek</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> </span><span id="Parser-3013"><a href="#Parser-3013"><span class="linenos">3013</span></a> -</span><span id="Parser-3014"><a href="#Parser-3014"><span class="linenos">3014</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index2</span><span class="p">)</span> -</span><span id="Parser-3015"><a href="#Parser-3015"><span class="linenos">3015</span></a> -</span><span id="Parser-3016"><a href="#Parser-3016"><span class="linenos">3016</span></a> <span class="k">if</span> <span class="n">value</span><span class="p">:</span> -</span><span id="Parser-3017"><a href="#Parser-3017"><span class="linenos">3017</span></a> <span class="k">return</span> <span class="n">value</span> -</span><span id="Parser-3018"><a href="#Parser-3018"><span class="linenos">3018</span></a> -</span><span id="Parser-3019"><a href="#Parser-3019"><span class="linenos">3019</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span> -</span><span id="Parser-3020"><a href="#Parser-3020"><span class="linenos">3020</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">type_token</span><span class="o">.</span><span class="n">value</span><span class="o">.</span><span class="n">upper</span><span class="p">()],</span> -</span><span id="Parser-3021"><a href="#Parser-3021"><span class="linenos">3021</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Parser-3022"><a href="#Parser-3022"><span class="linenos">3022</span></a> <span class="n">nested</span><span class="o">=</span><span class="n">nested</span><span class="p">,</span> -</span><span id="Parser-3023"><a href="#Parser-3023"><span class="linenos">3023</span></a> <span class="n">values</span><span class="o">=</span><span class="n">values</span><span class="p">,</span> -</span><span id="Parser-3024"><a href="#Parser-3024"><span class="linenos">3024</span></a> <span class="n">prefix</span><span class="o">=</span><span class="n">prefix</span><span class="p">,</span> -</span><span id="Parser-3025"><a href="#Parser-3025"><span class="linenos">3025</span></a> <span class="p">)</span> -</span><span id="Parser-3026"><a href="#Parser-3026"><span class="linenos">3026</span></a> -</span><span id="Parser-3027"><a href="#Parser-3027"><span class="linenos">3027</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="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="Parser-3028"><a href="#Parser-3028"><span class="linenos">3028</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="Parser-3029"><a href="#Parser-3029"><span class="linenos">3029</span></a> <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">COLON</span><span class="p">)</span> -</span><span id="Parser-3030"><a href="#Parser-3030"><span class="linenos">3030</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_def</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-3031"><a href="#Parser-3031"><span class="linenos">3031</span></a> -</span><span id="Parser-3032"><a href="#Parser-3032"><span class="linenos">3032</span></a> <span class="k">def</span> <span class="nf">_parse_at_time_zone</span><span class="p">(</span><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="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="Parser-3033"><a href="#Parser-3033"><span class="linenos">3033</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AT"</span><span class="p">,</span> <span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ZONE"</span><span class="p">):</span> -</span><span id="Parser-3034"><a href="#Parser-3034"><span class="linenos">3034</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-3035"><a href="#Parser-3035"><span class="linenos">3035</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">AtTimeZone</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">zone</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_unary</span><span class="p">())</span> -</span><span id="Parser-3036"><a href="#Parser-3036"><span class="linenos">3036</span></a> -</span><span id="Parser-3037"><a href="#Parser-3037"><span class="linenos">3037</span></a> <span class="k">def</span> <span class="nf">_parse_column</span><span class="p">(</span><span class="bp">self</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="Parser-3038"><a href="#Parser-3038"><span class="linenos">3038</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> -</span><span id="Parser-3039"><a href="#Parser-3039"><span class="linenos">3039</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">Identifier</span><span class="p">):</span> -</span><span id="Parser-3040"><a href="#Parser-3040"><span class="linenos">3040</span></a> <span class="n">this</span> <span class="o">=</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">Column</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-3041"><a href="#Parser-3041"><span class="linenos">3041</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> -</span><span id="Parser-3042"><a href="#Parser-3042"><span class="linenos">3042</span></a> <span class="k">return</span> <span class="bp">self</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="Parser-3043"><a href="#Parser-3043"><span class="linenos">3043</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_ops</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-3044"><a href="#Parser-3044"><span class="linenos">3044</span></a> -</span><span id="Parser-3045"><a href="#Parser-3045"><span class="linenos">3045</span></a> <span class="k">def</span> <span class="nf">_parse_column_ops</span><span class="p">(</span><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="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="Parser-3046"><a href="#Parser-3046"><span class="linenos">3046</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bracket</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-3047"><a href="#Parser-3047"><span class="linenos">3047</span></a> -</span><span id="Parser-3048"><a href="#Parser-3048"><span class="linenos">3048</span></a> <span class="k">while</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">COLUMN_OPERATORS</span><span class="p">):</span> -</span><span id="Parser-3049"><a href="#Parser-3049"><span class="linenos">3049</span></a> <span class="n">op_token</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">token_type</span> -</span><span id="Parser-3050"><a href="#Parser-3050"><span class="linenos">3050</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">COLUMN_OPERATORS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">op_token</span><span class="p">)</span> +</span><span id="Parser-3014"><a href="#Parser-3014"><span class="linenos">3014</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">peek</span><span class="p">:</span> +</span><span id="Parser-3015"><a href="#Parser-3015"><span class="linenos">3015</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-3016"><a href="#Parser-3016"><span class="linenos">3016</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-3017"><a href="#Parser-3017"><span class="linenos">3017</span></a> +</span><span id="Parser-3018"><a href="#Parser-3018"><span class="linenos">3018</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index2</span><span class="p">)</span> +</span><span id="Parser-3019"><a href="#Parser-3019"><span class="linenos">3019</span></a> +</span><span id="Parser-3020"><a href="#Parser-3020"><span class="linenos">3020</span></a> <span class="k">if</span> <span class="n">value</span><span class="p">:</span> +</span><span id="Parser-3021"><a href="#Parser-3021"><span class="linenos">3021</span></a> <span class="k">return</span> <span class="n">value</span> +</span><span id="Parser-3022"><a href="#Parser-3022"><span class="linenos">3022</span></a> +</span><span id="Parser-3023"><a href="#Parser-3023"><span class="linenos">3023</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span> +</span><span id="Parser-3024"><a href="#Parser-3024"><span class="linenos">3024</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">type_token</span><span class="o">.</span><span class="n">value</span><span class="o">.</span><span class="n">upper</span><span class="p">()],</span> +</span><span id="Parser-3025"><a href="#Parser-3025"><span class="linenos">3025</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Parser-3026"><a href="#Parser-3026"><span class="linenos">3026</span></a> <span class="n">nested</span><span class="o">=</span><span class="n">nested</span><span class="p">,</span> +</span><span id="Parser-3027"><a href="#Parser-3027"><span class="linenos">3027</span></a> <span class="n">values</span><span class="o">=</span><span class="n">values</span><span class="p">,</span> +</span><span id="Parser-3028"><a href="#Parser-3028"><span class="linenos">3028</span></a> <span class="n">prefix</span><span class="o">=</span><span class="n">prefix</span><span class="p">,</span> +</span><span id="Parser-3029"><a href="#Parser-3029"><span class="linenos">3029</span></a> <span class="p">)</span> +</span><span id="Parser-3030"><a href="#Parser-3030"><span class="linenos">3030</span></a> +</span><span id="Parser-3031"><a href="#Parser-3031"><span class="linenos">3031</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="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="Parser-3032"><a href="#Parser-3032"><span class="linenos">3032</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="Parser-3033"><a href="#Parser-3033"><span class="linenos">3033</span></a> <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">COLON</span><span class="p">)</span> +</span><span id="Parser-3034"><a href="#Parser-3034"><span class="linenos">3034</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_def</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-3035"><a href="#Parser-3035"><span class="linenos">3035</span></a> +</span><span id="Parser-3036"><a href="#Parser-3036"><span class="linenos">3036</span></a> <span class="k">def</span> <span class="nf">_parse_at_time_zone</span><span class="p">(</span><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="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="Parser-3037"><a href="#Parser-3037"><span class="linenos">3037</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"AT"</span><span class="p">,</span> <span class="s2">"TIME"</span><span class="p">,</span> <span class="s2">"ZONE"</span><span class="p">):</span> +</span><span id="Parser-3038"><a href="#Parser-3038"><span class="linenos">3038</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-3039"><a href="#Parser-3039"><span class="linenos">3039</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">AtTimeZone</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">zone</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_unary</span><span class="p">())</span> +</span><span id="Parser-3040"><a href="#Parser-3040"><span class="linenos">3040</span></a> +</span><span id="Parser-3041"><a href="#Parser-3041"><span class="linenos">3041</span></a> <span class="k">def</span> <span class="nf">_parse_column</span><span class="p">(</span><span class="bp">self</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="Parser-3042"><a href="#Parser-3042"><span class="linenos">3042</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> +</span><span id="Parser-3043"><a href="#Parser-3043"><span class="linenos">3043</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">Identifier</span><span class="p">):</span> +</span><span id="Parser-3044"><a href="#Parser-3044"><span class="linenos">3044</span></a> <span class="n">this</span> <span class="o">=</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">Column</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-3045"><a href="#Parser-3045"><span class="linenos">3045</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">this</span><span class="p">:</span> +</span><span id="Parser-3046"><a href="#Parser-3046"><span class="linenos">3046</span></a> <span class="k">return</span> <span class="bp">self</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="Parser-3047"><a href="#Parser-3047"><span class="linenos">3047</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_ops</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-3048"><a href="#Parser-3048"><span class="linenos">3048</span></a> +</span><span id="Parser-3049"><a href="#Parser-3049"><span class="linenos">3049</span></a> <span class="k">def</span> <span class="nf">_parse_column_ops</span><span class="p">(</span><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="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="Parser-3050"><a href="#Parser-3050"><span class="linenos">3050</span></a> <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 class="n">this</span><span class="p">)</span> </span><span id="Parser-3051"><a href="#Parser-3051"><span class="linenos">3051</span></a> -</span><span id="Parser-3052"><a href="#Parser-3052"><span class="linenos">3052</span></a> <span class="k">if</span> <span class="n">op_token</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DCOLON</span><span class="p">:</span> -</span><span id="Parser-3053"><a href="#Parser-3053"><span class="linenos">3053</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">()</span> -</span><span id="Parser-3054"><a href="#Parser-3054"><span class="linenos">3054</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">field</span><span class="p">:</span> -</span><span id="Parser-3055"><a href="#Parser-3055"><span class="linenos">3055</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected type"</span><span class="p">)</span> -</span><span id="Parser-3056"><a href="#Parser-3056"><span class="linenos">3056</span></a> <span class="k">elif</span> <span class="n">op</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="Parser-3057"><a href="#Parser-3057"><span class="linenos">3057</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Parser-3058"><a href="#Parser-3058"><span class="linenos">3058</span></a> <span class="n">value</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><span id="Parser-3059"><a href="#Parser-3059"><span class="linenos">3059</span></a> <span class="n">field</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Parser-3060"><a href="#Parser-3060"><span class="linenos">3060</span></a> <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="n">value</span><span class="p">)</span> -</span><span id="Parser-3061"><a href="#Parser-3061"><span class="linenos">3061</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span> -</span><span id="Parser-3062"><a href="#Parser-3062"><span class="linenos">3062</span></a> <span class="k">else</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">value</span><span class="p">)</span> -</span><span id="Parser-3063"><a href="#Parser-3063"><span class="linenos">3063</span></a> <span class="p">)</span> -</span><span id="Parser-3064"><a href="#Parser-3064"><span class="linenos">3064</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3065"><a href="#Parser-3065"><span class="linenos">3065</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">anonymous_func</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-3066"><a href="#Parser-3066"><span class="linenos">3066</span></a> -</span><span id="Parser-3067"><a href="#Parser-3067"><span class="linenos">3067</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">field</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">):</span> -</span><span id="Parser-3068"><a href="#Parser-3068"><span class="linenos">3068</span></a> <span class="c1"># bigquery allows function calls like x.y.count(...)</span> -</span><span id="Parser-3069"><a href="#Parser-3069"><span class="linenos">3069</span></a> <span class="c1"># SAFE.SUBSTR(...)</span> -</span><span id="Parser-3070"><a href="#Parser-3070"><span class="linenos">3070</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-reference#function_call_rules</span> -</span><span id="Parser-3071"><a href="#Parser-3071"><span class="linenos">3071</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_replace_columns_with_dots</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-3072"><a href="#Parser-3072"><span class="linenos">3072</span></a> -</span><span id="Parser-3073"><a href="#Parser-3073"><span class="linenos">3073</span></a> <span class="k">if</span> <span class="n">op</span><span class="p">:</span> -</span><span id="Parser-3074"><a href="#Parser-3074"><span class="linenos">3074</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">field</span><span class="p">)</span> -</span><span id="Parser-3075"><a href="#Parser-3075"><span class="linenos">3075</span></a> <span class="k">elif</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">Column</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">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">):</span> -</span><span id="Parser-3076"><a href="#Parser-3076"><span class="linenos">3076</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-3077"><a href="#Parser-3077"><span class="linenos">3077</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">,</span> -</span><span id="Parser-3078"><a href="#Parser-3078"><span class="linenos">3078</span></a> <span class="n">this</span><span class="o">=</span><span class="n">field</span><span class="p">,</span> -</span><span id="Parser-3079"><a href="#Parser-3079"><span class="linenos">3079</span></a> <span class="n">table</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> -</span><span id="Parser-3080"><a href="#Parser-3080"><span class="linenos">3080</span></a> <span class="n">db</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"table"</span><span class="p">),</span> -</span><span id="Parser-3081"><a href="#Parser-3081"><span class="linenos">3081</span></a> <span class="n">catalog</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"db"</span><span class="p">),</span> -</span><span id="Parser-3082"><a href="#Parser-3082"><span class="linenos">3082</span></a> <span class="p">)</span> -</span><span id="Parser-3083"><a href="#Parser-3083"><span class="linenos">3083</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3084"><a href="#Parser-3084"><span class="linenos">3084</span></a> <span class="n">this</span> <span class="o">=</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">Dot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">field</span><span class="p">)</span> -</span><span id="Parser-3085"><a href="#Parser-3085"><span class="linenos">3085</span></a> <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 class="n">this</span><span class="p">)</span> -</span><span id="Parser-3086"><a href="#Parser-3086"><span class="linenos">3086</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-3087"><a href="#Parser-3087"><span class="linenos">3087</span></a> -</span><span id="Parser-3088"><a href="#Parser-3088"><span class="linenos">3088</span></a> <span class="k">def</span> <span class="nf">_parse_primary</span><span class="p">(</span><span class="bp">self</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="Parser-3089"><a href="#Parser-3089"><span class="linenos">3089</span></a> <span class="k">if</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">PRIMARY_PARSERS</span><span class="p">):</span> -</span><span id="Parser-3090"><a href="#Parser-3090"><span class="linenos">3090</span></a> <span class="n">token_type</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">token_type</span> -</span><span id="Parser-3091"><a href="#Parser-3091"><span class="linenos">3091</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> -</span><span id="Parser-3092"><a href="#Parser-3092"><span class="linenos">3092</span></a> -</span><span id="Parser-3093"><a href="#Parser-3093"><span class="linenos">3093</span></a> <span class="k">if</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">:</span> -</span><span id="Parser-3094"><a href="#Parser-3094"><span class="linenos">3094</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">primary</span><span class="p">]</span> -</span><span id="Parser-3095"><a href="#Parser-3095"><span class="linenos">3095</span></a> <span class="k">while</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">STRING</span><span class="p">):</span> -</span><span id="Parser-3096"><a href="#Parser-3096"><span class="linenos">3096</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</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="Parser-3097"><a href="#Parser-3097"><span class="linenos">3097</span></a> -</span><span id="Parser-3098"><a href="#Parser-3098"><span class="linenos">3098</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Parser-3099"><a href="#Parser-3099"><span class="linenos">3099</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">Concat</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Parser-3100"><a href="#Parser-3100"><span class="linenos">3100</span></a> -</span><span id="Parser-3101"><a href="#Parser-3101"><span class="linenos">3101</span></a> <span class="k">return</span> <span class="n">primary</span> -</span><span id="Parser-3102"><a href="#Parser-3102"><span class="linenos">3102</span></a> -</span><span id="Parser-3103"><a href="#Parser-3103"><span class="linenos">3103</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DOT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span><span class="p">):</span> -</span><span id="Parser-3104"><a href="#Parser-3104"><span class="linenos">3104</span></a> <span class="k">return</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="sa">f</span><span class="s2">"0.</span><span class="si">{</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="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Parser-3105"><a href="#Parser-3105"><span class="linenos">3105</span></a> -</span><span id="Parser-3106"><a href="#Parser-3106"><span class="linenos">3106</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_PAREN</span><span class="p">):</span> -</span><span id="Parser-3107"><a href="#Parser-3107"><span class="linenos">3107</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> -</span><span id="Parser-3108"><a href="#Parser-3108"><span class="linenos">3108</span></a> <span class="n">query</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">()</span> +</span><span id="Parser-3052"><a href="#Parser-3052"><span class="linenos">3052</span></a> <span class="k">while</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">COLUMN_OPERATORS</span><span class="p">):</span> +</span><span id="Parser-3053"><a href="#Parser-3053"><span class="linenos">3053</span></a> <span class="n">op_token</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">token_type</span> +</span><span id="Parser-3054"><a href="#Parser-3054"><span class="linenos">3054</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">COLUMN_OPERATORS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">op_token</span><span class="p">)</span> +</span><span id="Parser-3055"><a href="#Parser-3055"><span class="linenos">3055</span></a> +</span><span id="Parser-3056"><a href="#Parser-3056"><span class="linenos">3056</span></a> <span class="k">if</span> <span class="n">op_token</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DCOLON</span><span class="p">:</span> +</span><span id="Parser-3057"><a href="#Parser-3057"><span class="linenos">3057</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">()</span> +</span><span id="Parser-3058"><a href="#Parser-3058"><span class="linenos">3058</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">field</span><span class="p">:</span> +</span><span id="Parser-3059"><a href="#Parser-3059"><span class="linenos">3059</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected type"</span><span class="p">)</span> +</span><span id="Parser-3060"><a href="#Parser-3060"><span class="linenos">3060</span></a> <span class="k">elif</span> <span class="n">op</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="Parser-3061"><a href="#Parser-3061"><span class="linenos">3061</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Parser-3062"><a href="#Parser-3062"><span class="linenos">3062</span></a> <span class="n">value</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><span id="Parser-3063"><a href="#Parser-3063"><span class="linenos">3063</span></a> <span class="n">field</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Parser-3064"><a href="#Parser-3064"><span class="linenos">3064</span></a> <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="n">value</span><span class="p">)</span> +</span><span id="Parser-3065"><a href="#Parser-3065"><span class="linenos">3065</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span> +</span><span id="Parser-3066"><a href="#Parser-3066"><span class="linenos">3066</span></a> <span class="k">else</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">value</span><span class="p">)</span> +</span><span id="Parser-3067"><a href="#Parser-3067"><span class="linenos">3067</span></a> <span class="p">)</span> +</span><span id="Parser-3068"><a href="#Parser-3068"><span class="linenos">3068</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3069"><a href="#Parser-3069"><span class="linenos">3069</span></a> <span class="n">field</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">anonymous_func</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-3070"><a href="#Parser-3070"><span class="linenos">3070</span></a> +</span><span id="Parser-3071"><a href="#Parser-3071"><span class="linenos">3071</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">field</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Func</span><span class="p">):</span> +</span><span id="Parser-3072"><a href="#Parser-3072"><span class="linenos">3072</span></a> <span class="c1"># bigquery allows function calls like x.y.count(...)</span> +</span><span id="Parser-3073"><a href="#Parser-3073"><span class="linenos">3073</span></a> <span class="c1"># SAFE.SUBSTR(...)</span> +</span><span id="Parser-3074"><a href="#Parser-3074"><span class="linenos">3074</span></a> <span class="c1"># https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-reference#function_call_rules</span> +</span><span id="Parser-3075"><a href="#Parser-3075"><span class="linenos">3075</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_replace_columns_with_dots</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-3076"><a href="#Parser-3076"><span class="linenos">3076</span></a> +</span><span id="Parser-3077"><a href="#Parser-3077"><span class="linenos">3077</span></a> <span class="k">if</span> <span class="n">op</span><span class="p">:</span> +</span><span id="Parser-3078"><a href="#Parser-3078"><span class="linenos">3078</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">field</span><span class="p">)</span> +</span><span id="Parser-3079"><a href="#Parser-3079"><span class="linenos">3079</span></a> <span class="k">elif</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">Column</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">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"catalog"</span><span class="p">):</span> +</span><span id="Parser-3080"><a href="#Parser-3080"><span class="linenos">3080</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-3081"><a href="#Parser-3081"><span class="linenos">3081</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">,</span> +</span><span id="Parser-3082"><a href="#Parser-3082"><span class="linenos">3082</span></a> <span class="n">this</span><span class="o">=</span><span class="n">field</span><span class="p">,</span> +</span><span id="Parser-3083"><a href="#Parser-3083"><span class="linenos">3083</span></a> <span class="n">table</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> +</span><span id="Parser-3084"><a href="#Parser-3084"><span class="linenos">3084</span></a> <span class="n">db</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"table"</span><span class="p">),</span> +</span><span id="Parser-3085"><a href="#Parser-3085"><span class="linenos">3085</span></a> <span class="n">catalog</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"db"</span><span class="p">),</span> +</span><span id="Parser-3086"><a href="#Parser-3086"><span class="linenos">3086</span></a> <span class="p">)</span> +</span><span id="Parser-3087"><a href="#Parser-3087"><span class="linenos">3087</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3088"><a href="#Parser-3088"><span class="linenos">3088</span></a> <span class="n">this</span> <span class="o">=</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">Dot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">field</span><span class="p">)</span> +</span><span id="Parser-3089"><a href="#Parser-3089"><span class="linenos">3089</span></a> <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 class="n">this</span><span class="p">)</span> +</span><span id="Parser-3090"><a href="#Parser-3090"><span class="linenos">3090</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-3091"><a href="#Parser-3091"><span class="linenos">3091</span></a> +</span><span id="Parser-3092"><a href="#Parser-3092"><span class="linenos">3092</span></a> <span class="k">def</span> <span class="nf">_parse_primary</span><span class="p">(</span><span class="bp">self</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="Parser-3093"><a href="#Parser-3093"><span class="linenos">3093</span></a> <span class="k">if</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">PRIMARY_PARSERS</span><span class="p">):</span> +</span><span id="Parser-3094"><a href="#Parser-3094"><span class="linenos">3094</span></a> <span class="n">token_type</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">token_type</span> +</span><span id="Parser-3095"><a href="#Parser-3095"><span class="linenos">3095</span></a> <span class="n">primary</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="Parser-3096"><a href="#Parser-3096"><span class="linenos">3096</span></a> +</span><span id="Parser-3097"><a href="#Parser-3097"><span class="linenos">3097</span></a> <span class="k">if</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">:</span> +</span><span id="Parser-3098"><a href="#Parser-3098"><span class="linenos">3098</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">primary</span><span class="p">]</span> +</span><span id="Parser-3099"><a href="#Parser-3099"><span class="linenos">3099</span></a> <span class="k">while</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">STRING</span><span class="p">):</span> +</span><span id="Parser-3100"><a href="#Parser-3100"><span class="linenos">3100</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</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="Parser-3101"><a href="#Parser-3101"><span class="linenos">3101</span></a> +</span><span id="Parser-3102"><a href="#Parser-3102"><span class="linenos">3102</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Parser-3103"><a href="#Parser-3103"><span class="linenos">3103</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">Concat</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Parser-3104"><a href="#Parser-3104"><span class="linenos">3104</span></a> +</span><span id="Parser-3105"><a href="#Parser-3105"><span class="linenos">3105</span></a> <span class="k">return</span> <span class="n">primary</span> +</span><span id="Parser-3106"><a href="#Parser-3106"><span class="linenos">3106</span></a> +</span><span id="Parser-3107"><a href="#Parser-3107"><span class="linenos">3107</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DOT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span><span class="p">):</span> +</span><span id="Parser-3108"><a href="#Parser-3108"><span class="linenos">3108</span></a> <span class="k">return</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="sa">f</span><span class="s2">"0.</span><span class="si">{</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="si">}</span><span class="s2">"</span><span class="p">)</span> </span><span id="Parser-3109"><a href="#Parser-3109"><span class="linenos">3109</span></a> -</span><span id="Parser-3110"><a href="#Parser-3110"><span class="linenos">3110</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> -</span><span id="Parser-3111"><a href="#Parser-3111"><span class="linenos">3111</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">query</span><span class="p">]</span> -</span><span id="Parser-3112"><a href="#Parser-3112"><span class="linenos">3112</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3113"><a href="#Parser-3113"><span class="linenos">3113</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">)</span> -</span><span id="Parser-3114"><a href="#Parser-3114"><span class="linenos">3114</span></a> -</span><span id="Parser-3115"><a href="#Parser-3115"><span class="linenos">3115</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">seq_get</span><span class="p">(</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span> -</span><span id="Parser-3116"><a href="#Parser-3116"><span class="linenos">3116</span></a> -</span><span id="Parser-3117"><a href="#Parser-3117"><span class="linenos">3117</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">Subqueryable</span><span class="p">):</span> -</span><span id="Parser-3118"><a href="#Parser-3118"><span class="linenos">3118</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span> -</span><span id="Parser-3119"><a href="#Parser-3119"><span class="linenos">3119</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_subquery</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">parse_alias</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Parser-3120"><a href="#Parser-3120"><span class="linenos">3120</span></a> <span class="p">)</span> -</span><span id="Parser-3121"><a href="#Parser-3121"><span class="linenos">3121</span></a> <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Parser-3122"><a href="#Parser-3122"><span class="linenos">3122</span></a> <span class="n">this</span> <span class="o">=</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">Tuple</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Parser-3123"><a href="#Parser-3123"><span class="linenos">3123</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3124"><a href="#Parser-3124"><span class="linenos">3124</span></a> <span class="n">this</span> <span class="o">=</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">Paren</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_set_operations</span><span class="p">(</span><span class="n">this</span><span class="p">))</span> -</span><span id="Parser-3125"><a href="#Parser-3125"><span class="linenos">3125</span></a> -</span><span id="Parser-3126"><a href="#Parser-3126"><span class="linenos">3126</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> -</span><span id="Parser-3127"><a href="#Parser-3127"><span class="linenos">3127</span></a> <span class="n">this</span><span class="o">.</span><span class="n">add_comments</span><span class="p">(</span><span class="n">comments</span><span class="p">)</span> -</span><span id="Parser-3128"><a href="#Parser-3128"><span class="linenos">3128</span></a> -</span><span id="Parser-3129"><a href="#Parser-3129"><span class="linenos">3129</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-3130"><a href="#Parser-3130"><span class="linenos">3130</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-3131"><a href="#Parser-3131"><span class="linenos">3131</span></a> -</span><span id="Parser-3132"><a href="#Parser-3132"><span class="linenos">3132</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-3133"><a href="#Parser-3133"><span class="linenos">3133</span></a> -</span><span id="Parser-3134"><a href="#Parser-3134"><span class="linenos">3134</span></a> <span class="k">def</span> <span class="nf">_parse_field</span><span class="p">(</span> -</span><span id="Parser-3135"><a href="#Parser-3135"><span class="linenos">3135</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Parser-3136"><a href="#Parser-3136"><span class="linenos">3136</span></a> <span class="n">any_token</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Parser-3137"><a href="#Parser-3137"><span class="linenos">3137</span></a> <span class="n">tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Parser-3138"><a href="#Parser-3138"><span class="linenos">3138</span></a> <span class="n">anonymous_func</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Parser-3139"><a href="#Parser-3139"><span class="linenos">3139</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="Parser-3140"><a href="#Parser-3140"><span class="linenos">3140</span></a> <span class="k">return</span> <span class="p">(</span> -</span><span id="Parser-3141"><a href="#Parser-3141"><span class="linenos">3141</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> -</span><span id="Parser-3142"><a href="#Parser-3142"><span class="linenos">3142</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">(</span><span class="n">anonymous</span><span class="o">=</span><span class="n">anonymous_func</span><span class="p">)</span> -</span><span id="Parser-3143"><a href="#Parser-3143"><span class="linenos">3143</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="n">any_token</span><span class="p">,</span> <span class="n">tokens</span><span class="o">=</span><span class="n">tokens</span><span class="p">)</span> -</span><span id="Parser-3144"><a href="#Parser-3144"><span class="linenos">3144</span></a> <span class="p">)</span> -</span><span id="Parser-3145"><a href="#Parser-3145"><span class="linenos">3145</span></a> -</span><span id="Parser-3146"><a href="#Parser-3146"><span class="linenos">3146</span></a> <span class="k">def</span> <span class="nf">_parse_function</span><span class="p">(</span> -</span><span id="Parser-3147"><a href="#Parser-3147"><span class="linenos">3147</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Parser-3148"><a href="#Parser-3148"><span class="linenos">3148</span></a> <span class="n">functions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Parser-3149"><a href="#Parser-3149"><span class="linenos">3149</span></a> <span class="n">anonymous</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Parser-3150"><a href="#Parser-3150"><span class="linenos">3150</span></a> <span class="n">optional_parens</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Parser-3151"><a href="#Parser-3151"><span class="linenos">3151</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="Parser-3152"><a href="#Parser-3152"><span class="linenos">3152</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="Parser-3153"><a href="#Parser-3153"><span class="linenos">3153</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-3154"><a href="#Parser-3154"><span class="linenos">3154</span></a> -</span><span id="Parser-3155"><a href="#Parser-3155"><span class="linenos">3155</span></a> <span class="n">token_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> -</span><span id="Parser-3156"><a href="#Parser-3156"><span class="linenos">3156</span></a> -</span><span id="Parser-3157"><a href="#Parser-3157"><span class="linenos">3157</span></a> <span class="k">if</span> <span class="n">optional_parens</span> <span class="ow">and</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">NO_PAREN_FUNCTION_PARSERS</span><span class="p">):</span> -</span><span id="Parser-3158"><a href="#Parser-3158"><span class="linenos">3158</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">NO_PAREN_FUNCTION_PARSERS</span><span class="p">[</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> -</span><span id="Parser-3159"><a href="#Parser-3159"><span class="linenos">3159</span></a> -</span><span id="Parser-3160"><a href="#Parser-3160"><span class="linenos">3160</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="o">.</span><span class="n">token_type</span> <span class="o">!=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">:</span> -</span><span id="Parser-3161"><a href="#Parser-3161"><span class="linenos">3161</span></a> <span class="k">if</span> <span class="n">optional_parens</span> <span class="ow">and</span> <span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">NO_PAREN_FUNCTIONS</span><span class="p">:</span> -</span><span id="Parser-3162"><a href="#Parser-3162"><span class="linenos">3162</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Parser-3163"><a href="#Parser-3163"><span class="linenos">3163</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="bp">self</span><span class="o">.</span><span class="n">NO_PAREN_FUNCTIONS</span><span class="p">[</span><span class="n">token_type</span><span class="p">])</span> -</span><span id="Parser-3164"><a href="#Parser-3164"><span class="linenos">3164</span></a> -</span><span id="Parser-3165"><a href="#Parser-3165"><span class="linenos">3165</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-3166"><a href="#Parser-3166"><span class="linenos">3166</span></a> -</span><span id="Parser-3167"><a href="#Parser-3167"><span class="linenos">3167</span></a> <span class="k">if</span> <span class="n">token_type</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">FUNC_TOKENS</span><span class="p">:</span> -</span><span id="Parser-3168"><a href="#Parser-3168"><span class="linenos">3168</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-3169"><a href="#Parser-3169"><span class="linenos">3169</span></a> -</span><span id="Parser-3170"><a href="#Parser-3170"><span class="linenos">3170</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">text</span> -</span><span id="Parser-3171"><a href="#Parser-3171"><span class="linenos">3171</span></a> <span class="n">upper</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Parser-3172"><a href="#Parser-3172"><span class="linenos">3172</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> +</span><span id="Parser-3110"><a href="#Parser-3110"><span class="linenos">3110</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_PAREN</span><span class="p">):</span> +</span><span id="Parser-3111"><a href="#Parser-3111"><span class="linenos">3111</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> +</span><span id="Parser-3112"><a href="#Parser-3112"><span class="linenos">3112</span></a> <span class="n">query</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">()</span> +</span><span id="Parser-3113"><a href="#Parser-3113"><span class="linenos">3113</span></a> +</span><span id="Parser-3114"><a href="#Parser-3114"><span class="linenos">3114</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> +</span><span id="Parser-3115"><a href="#Parser-3115"><span class="linenos">3115</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">query</span><span class="p">]</span> +</span><span id="Parser-3116"><a href="#Parser-3116"><span class="linenos">3116</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3117"><a href="#Parser-3117"><span class="linenos">3117</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">)</span> +</span><span id="Parser-3118"><a href="#Parser-3118"><span class="linenos">3118</span></a> +</span><span id="Parser-3119"><a href="#Parser-3119"><span class="linenos">3119</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span><span class="n">seq_get</span><span class="p">(</span><span class="n">expressions</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span> +</span><span id="Parser-3120"><a href="#Parser-3120"><span class="linenos">3120</span></a> +</span><span id="Parser-3121"><a href="#Parser-3121"><span class="linenos">3121</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">Subqueryable</span><span class="p">):</span> +</span><span id="Parser-3122"><a href="#Parser-3122"><span class="linenos">3122</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span> +</span><span id="Parser-3123"><a href="#Parser-3123"><span class="linenos">3123</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_subquery</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">parse_alias</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Parser-3124"><a href="#Parser-3124"><span class="linenos">3124</span></a> <span class="p">)</span> +</span><span id="Parser-3125"><a href="#Parser-3125"><span class="linenos">3125</span></a> <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Parser-3126"><a href="#Parser-3126"><span class="linenos">3126</span></a> <span class="n">this</span> <span class="o">=</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">Tuple</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Parser-3127"><a href="#Parser-3127"><span class="linenos">3127</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3128"><a href="#Parser-3128"><span class="linenos">3128</span></a> <span class="n">this</span> <span class="o">=</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">Paren</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_set_operations</span><span class="p">(</span><span class="n">this</span><span class="p">))</span> +</span><span id="Parser-3129"><a href="#Parser-3129"><span class="linenos">3129</span></a> +</span><span id="Parser-3130"><a href="#Parser-3130"><span class="linenos">3130</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> +</span><span id="Parser-3131"><a href="#Parser-3131"><span class="linenos">3131</span></a> <span class="n">this</span><span class="o">.</span><span class="n">add_comments</span><span class="p">(</span><span class="n">comments</span><span class="p">)</span> +</span><span id="Parser-3132"><a href="#Parser-3132"><span class="linenos">3132</span></a> +</span><span id="Parser-3133"><a href="#Parser-3133"><span class="linenos">3133</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">(</span><span class="n">expression</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-3134"><a href="#Parser-3134"><span class="linenos">3134</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-3135"><a href="#Parser-3135"><span class="linenos">3135</span></a> +</span><span id="Parser-3136"><a href="#Parser-3136"><span class="linenos">3136</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-3137"><a href="#Parser-3137"><span class="linenos">3137</span></a> +</span><span id="Parser-3138"><a href="#Parser-3138"><span class="linenos">3138</span></a> <span class="k">def</span> <span class="nf">_parse_field</span><span class="p">(</span> +</span><span id="Parser-3139"><a href="#Parser-3139"><span class="linenos">3139</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Parser-3140"><a href="#Parser-3140"><span class="linenos">3140</span></a> <span class="n">any_token</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Parser-3141"><a href="#Parser-3141"><span class="linenos">3141</span></a> <span class="n">tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Parser-3142"><a href="#Parser-3142"><span class="linenos">3142</span></a> <span class="n">anonymous_func</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Parser-3143"><a href="#Parser-3143"><span class="linenos">3143</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="Parser-3144"><a href="#Parser-3144"><span class="linenos">3144</span></a> <span class="k">return</span> <span class="p">(</span> +</span><span id="Parser-3145"><a href="#Parser-3145"><span class="linenos">3145</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="Parser-3146"><a href="#Parser-3146"><span class="linenos">3146</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">(</span><span class="n">anonymous</span><span class="o">=</span><span class="n">anonymous_func</span><span class="p">)</span> +</span><span id="Parser-3147"><a href="#Parser-3147"><span class="linenos">3147</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="n">any_token</span><span class="p">,</span> <span class="n">tokens</span><span class="o">=</span><span class="n">tokens</span><span class="p">)</span> +</span><span id="Parser-3148"><a href="#Parser-3148"><span class="linenos">3148</span></a> <span class="p">)</span> +</span><span id="Parser-3149"><a href="#Parser-3149"><span class="linenos">3149</span></a> +</span><span id="Parser-3150"><a href="#Parser-3150"><span class="linenos">3150</span></a> <span class="k">def</span> <span class="nf">_parse_function</span><span class="p">(</span> +</span><span id="Parser-3151"><a href="#Parser-3151"><span class="linenos">3151</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Parser-3152"><a href="#Parser-3152"><span class="linenos">3152</span></a> <span class="n">functions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Parser-3153"><a href="#Parser-3153"><span class="linenos">3153</span></a> <span class="n">anonymous</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Parser-3154"><a href="#Parser-3154"><span class="linenos">3154</span></a> <span class="n">optional_parens</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Parser-3155"><a href="#Parser-3155"><span class="linenos">3155</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="Parser-3156"><a href="#Parser-3156"><span class="linenos">3156</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="Parser-3157"><a href="#Parser-3157"><span class="linenos">3157</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-3158"><a href="#Parser-3158"><span class="linenos">3158</span></a> +</span><span id="Parser-3159"><a href="#Parser-3159"><span class="linenos">3159</span></a> <span class="n">token_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> +</span><span id="Parser-3160"><a href="#Parser-3160"><span class="linenos">3160</span></a> +</span><span id="Parser-3161"><a href="#Parser-3161"><span class="linenos">3161</span></a> <span class="k">if</span> <span class="n">optional_parens</span> <span class="ow">and</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">NO_PAREN_FUNCTION_PARSERS</span><span class="p">):</span> +</span><span id="Parser-3162"><a href="#Parser-3162"><span class="linenos">3162</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">NO_PAREN_FUNCTION_PARSERS</span><span class="p">[</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> +</span><span id="Parser-3163"><a href="#Parser-3163"><span class="linenos">3163</span></a> +</span><span id="Parser-3164"><a href="#Parser-3164"><span class="linenos">3164</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="o">.</span><span class="n">token_type</span> <span class="o">!=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">:</span> +</span><span id="Parser-3165"><a href="#Parser-3165"><span class="linenos">3165</span></a> <span class="k">if</span> <span class="n">optional_parens</span> <span class="ow">and</span> <span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">NO_PAREN_FUNCTIONS</span><span class="p">:</span> +</span><span id="Parser-3166"><a href="#Parser-3166"><span class="linenos">3166</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Parser-3167"><a href="#Parser-3167"><span class="linenos">3167</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="bp">self</span><span class="o">.</span><span class="n">NO_PAREN_FUNCTIONS</span><span class="p">[</span><span class="n">token_type</span><span class="p">])</span> +</span><span id="Parser-3168"><a href="#Parser-3168"><span class="linenos">3168</span></a> +</span><span id="Parser-3169"><a href="#Parser-3169"><span class="linenos">3169</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-3170"><a href="#Parser-3170"><span class="linenos">3170</span></a> +</span><span id="Parser-3171"><a href="#Parser-3171"><span class="linenos">3171</span></a> <span class="k">if</span> <span class="n">token_type</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">FUNC_TOKENS</span><span class="p">:</span> +</span><span id="Parser-3172"><a href="#Parser-3172"><span class="linenos">3172</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="Parser-3173"><a href="#Parser-3173"><span class="linenos">3173</span></a> -</span><span id="Parser-3174"><a href="#Parser-3174"><span class="linenos">3174</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">upper</span><span class="p">)</span> -</span><span id="Parser-3175"><a href="#Parser-3175"><span class="linenos">3175</span></a> -</span><span id="Parser-3176"><a href="#Parser-3176"><span class="linenos">3176</span></a> <span class="k">if</span> <span class="n">parser</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">anonymous</span><span class="p">:</span> -</span><span id="Parser-3177"><a href="#Parser-3177"><span class="linenos">3177</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> -</span><span id="Parser-3178"><a href="#Parser-3178"><span class="linenos">3178</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3179"><a href="#Parser-3179"><span class="linenos">3179</span></a> <span class="n">subquery_predicate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">SUBQUERY_PREDICATES</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">token_type</span><span class="p">)</span> -</span><span id="Parser-3180"><a href="#Parser-3180"><span class="linenos">3180</span></a> -</span><span id="Parser-3181"><a href="#Parser-3181"><span class="linenos">3181</span></a> <span class="k">if</span> <span class="n">subquery_predicate</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SELECT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">):</span> -</span><span id="Parser-3182"><a href="#Parser-3182"><span class="linenos">3182</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">subquery_predicate</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_select</span><span class="p">())</span> -</span><span id="Parser-3183"><a href="#Parser-3183"><span class="linenos">3183</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="Parser-3184"><a href="#Parser-3184"><span class="linenos">3184</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-3185"><a href="#Parser-3185"><span class="linenos">3185</span></a> -</span><span id="Parser-3186"><a href="#Parser-3186"><span class="linenos">3186</span></a> <span class="k">if</span> <span class="n">functions</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Parser-3187"><a href="#Parser-3187"><span class="linenos">3187</span></a> <span class="n">functions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">FUNCTIONS</span> -</span><span id="Parser-3188"><a href="#Parser-3188"><span class="linenos">3188</span></a> -</span><span id="Parser-3189"><a href="#Parser-3189"><span class="linenos">3189</span></a> <span class="n">function</span> <span class="o">=</span> <span class="n">functions</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">upper</span><span class="p">)</span> -</span><span id="Parser-3190"><a href="#Parser-3190"><span class="linenos">3190</span></a> -</span><span id="Parser-3191"><a href="#Parser-3191"><span class="linenos">3191</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">upper</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span> -</span><span id="Parser-3192"><a href="#Parser-3192"><span class="linenos">3192</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lambda</span><span class="p">(</span><span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">))</span> -</span><span id="Parser-3193"><a href="#Parser-3193"><span class="linenos">3193</span></a> -</span><span id="Parser-3194"><a href="#Parser-3194"><span class="linenos">3194</span></a> <span class="k">if</span> <span class="n">function</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">anonymous</span><span class="p">:</span> -</span><span id="Parser-3195"><a href="#Parser-3195"><span class="linenos">3195</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">function</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="n">args</span><span class="p">)</span> -</span><span id="Parser-3196"><a href="#Parser-3196"><span class="linenos">3196</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3197"><a href="#Parser-3197"><span class="linenos">3197</span></a> <span class="n">this</span> <span class="o">=</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">Anonymous</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">args</span><span class="p">)</span> -</span><span id="Parser-3198"><a href="#Parser-3198"><span class="linenos">3198</span></a> -</span><span id="Parser-3199"><a href="#Parser-3199"><span class="linenos">3199</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-3200"><a href="#Parser-3200"><span class="linenos">3200</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-3201"><a href="#Parser-3201"><span class="linenos">3201</span></a> -</span><span id="Parser-3202"><a href="#Parser-3202"><span class="linenos">3202</span></a> <span class="k">def</span> <span class="nf">_parse_function_parameter</span><span class="p">(</span><span class="bp">self</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="Parser-3203"><a href="#Parser-3203"><span class="linenos">3203</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_def</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">())</span> -</span><span id="Parser-3204"><a href="#Parser-3204"><span class="linenos">3204</span></a> -</span><span id="Parser-3205"><a href="#Parser-3205"><span class="linenos">3205</span></a> <span class="k">def</span> <span class="nf">_parse_user_defined_function</span><span class="p">(</span> -</span><span id="Parser-3206"><a href="#Parser-3206"><span class="linenos">3206</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">kind</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">TokenType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-3207"><a href="#Parser-3207"><span class="linenos">3207</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="Parser-3208"><a href="#Parser-3208"><span class="linenos">3208</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="Parser-3209"><a href="#Parser-3209"><span class="linenos">3209</span></a> -</span><span id="Parser-3210"><a href="#Parser-3210"><span class="linenos">3210</span></a> <span class="k">while</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">DOT</span><span class="p">):</span> -</span><span id="Parser-3211"><a href="#Parser-3211"><span class="linenos">3211</span></a> <span class="n">this</span> <span class="o">=</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">Dot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">())</span> -</span><span id="Parser-3212"><a href="#Parser-3212"><span class="linenos">3212</span></a> -</span><span id="Parser-3213"><a href="#Parser-3213"><span class="linenos">3213</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">):</span> -</span><span id="Parser-3214"><a href="#Parser-3214"><span class="linenos">3214</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-3215"><a href="#Parser-3215"><span class="linenos">3215</span></a> -</span><span id="Parser-3216"><a href="#Parser-3216"><span class="linenos">3216</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function_parameter</span><span class="p">)</span> -</span><span id="Parser-3217"><a href="#Parser-3217"><span class="linenos">3217</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="Parser-3218"><a href="#Parser-3218"><span class="linenos">3218</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><span id="Parser-3219"><a href="#Parser-3219"><span class="linenos">3219</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UserDefinedFunction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">wrapped</span><span class="o">=</span><span class="kc">True</span> -</span><span id="Parser-3220"><a href="#Parser-3220"><span class="linenos">3220</span></a> <span class="p">)</span> -</span><span id="Parser-3221"><a href="#Parser-3221"><span class="linenos">3221</span></a> -</span><span id="Parser-3222"><a href="#Parser-3222"><span class="linenos">3222</span></a> <span class="k">def</span> <span class="nf">_parse_introducer</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token</span><span class="p">:</span> <span class="n">Token</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Introducer</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">:</span> -</span><span id="Parser-3223"><a href="#Parser-3223"><span class="linenos">3223</span></a> <span class="n">literal</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> -</span><span id="Parser-3224"><a href="#Parser-3224"><span class="linenos">3224</span></a> <span class="k">if</span> <span class="n">literal</span><span class="p">:</span> -</span><span id="Parser-3225"><a href="#Parser-3225"><span class="linenos">3225</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">Introducer</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">literal</span><span class="p">)</span> -</span><span id="Parser-3226"><a href="#Parser-3226"><span class="linenos">3226</span></a> -</span><span id="Parser-3227"><a href="#Parser-3227"><span class="linenos">3227</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">Identifier</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> -</span><span id="Parser-3228"><a href="#Parser-3228"><span class="linenos">3228</span></a> -</span><span id="Parser-3229"><a href="#Parser-3229"><span class="linenos">3229</span></a> <span class="k">def</span> <span class="nf">_parse_session_parameter</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">SessionParameter</span><span class="p">:</span> -</span><span id="Parser-3230"><a href="#Parser-3230"><span class="linenos">3230</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-3231"><a href="#Parser-3231"><span class="linenos">3231</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="Parser-3174"><a href="#Parser-3174"><span class="linenos">3174</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">text</span> +</span><span id="Parser-3175"><a href="#Parser-3175"><span class="linenos">3175</span></a> <span class="n">upper</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Parser-3176"><a href="#Parser-3176"><span class="linenos">3176</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> +</span><span id="Parser-3177"><a href="#Parser-3177"><span class="linenos">3177</span></a> +</span><span id="Parser-3178"><a href="#Parser-3178"><span class="linenos">3178</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">FUNCTION_PARSERS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">upper</span><span class="p">)</span> +</span><span id="Parser-3179"><a href="#Parser-3179"><span class="linenos">3179</span></a> +</span><span id="Parser-3180"><a href="#Parser-3180"><span class="linenos">3180</span></a> <span class="k">if</span> <span class="n">parser</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">anonymous</span><span class="p">:</span> +</span><span id="Parser-3181"><a href="#Parser-3181"><span class="linenos">3181</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> +</span><span id="Parser-3182"><a href="#Parser-3182"><span class="linenos">3182</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3183"><a href="#Parser-3183"><span class="linenos">3183</span></a> <span class="n">subquery_predicate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">SUBQUERY_PREDICATES</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">token_type</span><span class="p">)</span> +</span><span id="Parser-3184"><a href="#Parser-3184"><span class="linenos">3184</span></a> +</span><span id="Parser-3185"><a href="#Parser-3185"><span class="linenos">3185</span></a> <span class="k">if</span> <span class="n">subquery_predicate</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SELECT</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">):</span> +</span><span id="Parser-3186"><a href="#Parser-3186"><span class="linenos">3186</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span><span class="n">subquery_predicate</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_select</span><span class="p">())</span> +</span><span id="Parser-3187"><a href="#Parser-3187"><span class="linenos">3187</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-3188"><a href="#Parser-3188"><span class="linenos">3188</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-3189"><a href="#Parser-3189"><span class="linenos">3189</span></a> +</span><span id="Parser-3190"><a href="#Parser-3190"><span class="linenos">3190</span></a> <span class="k">if</span> <span class="n">functions</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Parser-3191"><a href="#Parser-3191"><span class="linenos">3191</span></a> <span class="n">functions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">FUNCTIONS</span> +</span><span id="Parser-3192"><a href="#Parser-3192"><span class="linenos">3192</span></a> +</span><span id="Parser-3193"><a href="#Parser-3193"><span class="linenos">3193</span></a> <span class="n">function</span> <span class="o">=</span> <span class="n">functions</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">upper</span><span class="p">)</span> +</span><span id="Parser-3194"><a href="#Parser-3194"><span class="linenos">3194</span></a> +</span><span id="Parser-3195"><a href="#Parser-3195"><span class="linenos">3195</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="n">upper</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">FUNCTIONS_WITH_ALIASED_ARGS</span> +</span><span id="Parser-3196"><a href="#Parser-3196"><span class="linenos">3196</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_lambda</span><span class="p">(</span><span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">))</span> +</span><span id="Parser-3197"><a href="#Parser-3197"><span class="linenos">3197</span></a> +</span><span id="Parser-3198"><a href="#Parser-3198"><span class="linenos">3198</span></a> <span class="k">if</span> <span class="n">function</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">anonymous</span><span class="p">:</span> +</span><span id="Parser-3199"><a href="#Parser-3199"><span class="linenos">3199</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">function</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="n">args</span><span class="p">)</span> +</span><span id="Parser-3200"><a href="#Parser-3200"><span class="linenos">3200</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3201"><a href="#Parser-3201"><span class="linenos">3201</span></a> <span class="n">this</span> <span class="o">=</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">Anonymous</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">args</span><span class="p">)</span> +</span><span id="Parser-3202"><a href="#Parser-3202"><span class="linenos">3202</span></a> +</span><span id="Parser-3203"><a href="#Parser-3203"><span class="linenos">3203</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-3204"><a href="#Parser-3204"><span class="linenos">3204</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-3205"><a href="#Parser-3205"><span class="linenos">3205</span></a> +</span><span id="Parser-3206"><a href="#Parser-3206"><span class="linenos">3206</span></a> <span class="k">def</span> <span class="nf">_parse_function_parameter</span><span class="p">(</span><span class="bp">self</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="Parser-3207"><a href="#Parser-3207"><span class="linenos">3207</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_def</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">())</span> +</span><span id="Parser-3208"><a href="#Parser-3208"><span class="linenos">3208</span></a> +</span><span id="Parser-3209"><a href="#Parser-3209"><span class="linenos">3209</span></a> <span class="k">def</span> <span class="nf">_parse_user_defined_function</span><span class="p">(</span> +</span><span id="Parser-3210"><a href="#Parser-3210"><span class="linenos">3210</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">kind</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">TokenType</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-3211"><a href="#Parser-3211"><span class="linenos">3211</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="Parser-3212"><a href="#Parser-3212"><span class="linenos">3212</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="Parser-3213"><a href="#Parser-3213"><span class="linenos">3213</span></a> +</span><span id="Parser-3214"><a href="#Parser-3214"><span class="linenos">3214</span></a> <span class="k">while</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">DOT</span><span class="p">):</span> +</span><span id="Parser-3215"><a href="#Parser-3215"><span class="linenos">3215</span></a> <span class="n">this</span> <span class="o">=</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">Dot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">())</span> +</span><span id="Parser-3216"><a href="#Parser-3216"><span class="linenos">3216</span></a> +</span><span id="Parser-3217"><a href="#Parser-3217"><span class="linenos">3217</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">):</span> +</span><span id="Parser-3218"><a href="#Parser-3218"><span class="linenos">3218</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-3219"><a href="#Parser-3219"><span class="linenos">3219</span></a> +</span><span id="Parser-3220"><a href="#Parser-3220"><span class="linenos">3220</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_function_parameter</span><span class="p">)</span> +</span><span id="Parser-3221"><a href="#Parser-3221"><span class="linenos">3221</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-3222"><a href="#Parser-3222"><span class="linenos">3222</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><span id="Parser-3223"><a href="#Parser-3223"><span class="linenos">3223</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UserDefinedFunction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">wrapped</span><span class="o">=</span><span class="kc">True</span> +</span><span id="Parser-3224"><a href="#Parser-3224"><span class="linenos">3224</span></a> <span class="p">)</span> +</span><span id="Parser-3225"><a href="#Parser-3225"><span class="linenos">3225</span></a> +</span><span id="Parser-3226"><a href="#Parser-3226"><span class="linenos">3226</span></a> <span class="k">def</span> <span class="nf">_parse_introducer</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token</span><span class="p">:</span> <span class="n">Token</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Introducer</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">:</span> +</span><span id="Parser-3227"><a href="#Parser-3227"><span class="linenos">3227</span></a> <span class="n">literal</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="Parser-3228"><a href="#Parser-3228"><span class="linenos">3228</span></a> <span class="k">if</span> <span class="n">literal</span><span class="p">:</span> +</span><span id="Parser-3229"><a href="#Parser-3229"><span class="linenos">3229</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">Introducer</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">literal</span><span class="p">)</span> +</span><span id="Parser-3230"><a href="#Parser-3230"><span class="linenos">3230</span></a> +</span><span id="Parser-3231"><a href="#Parser-3231"><span class="linenos">3231</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">Identifier</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> </span><span id="Parser-3232"><a href="#Parser-3232"><span class="linenos">3232</span></a> -</span><span id="Parser-3233"><a href="#Parser-3233"><span class="linenos">3233</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</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">DOT</span><span class="p">):</span> -</span><span id="Parser-3234"><a href="#Parser-3234"><span class="linenos">3234</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> -</span><span id="Parser-3235"><a href="#Parser-3235"><span class="linenos">3235</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="Parser-3233"><a href="#Parser-3233"><span class="linenos">3233</span></a> <span class="k">def</span> <span class="nf">_parse_session_parameter</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">SessionParameter</span><span class="p">:</span> +</span><span id="Parser-3234"><a href="#Parser-3234"><span class="linenos">3234</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-3235"><a href="#Parser-3235"><span class="linenos">3235</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> </span><span id="Parser-3236"><a href="#Parser-3236"><span class="linenos">3236</span></a> -</span><span id="Parser-3237"><a href="#Parser-3237"><span class="linenos">3237</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">SessionParameter</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">)</span> -</span><span id="Parser-3238"><a href="#Parser-3238"><span class="linenos">3238</span></a> -</span><span id="Parser-3239"><a href="#Parser-3239"><span class="linenos">3239</span></a> <span class="k">def</span> <span class="nf">_parse_lambda</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">alias</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="Parser-3240"><a href="#Parser-3240"><span class="linenos">3240</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="Parser-3241"><a href="#Parser-3241"><span class="linenos">3241</span></a> -</span><span id="Parser-3242"><a href="#Parser-3242"><span class="linenos">3242</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_PAREN</span><span class="p">):</span> -</span><span id="Parser-3243"><a href="#Parser-3243"><span class="linenos">3243</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">)</span> -</span><span id="Parser-3244"><a href="#Parser-3244"><span class="linenos">3244</span></a> -</span><span id="Parser-3245"><a href="#Parser-3245"><span class="linenos">3245</span></a> <span class="k">if</span> <span class="ow">not</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">R_PAREN</span><span class="p">):</span> -</span><span id="Parser-3246"><a href="#Parser-3246"><span class="linenos">3246</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-3247"><a href="#Parser-3247"><span class="linenos">3247</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3248"><a href="#Parser-3248"><span class="linenos">3248</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()]</span> -</span><span id="Parser-3249"><a href="#Parser-3249"><span class="linenos">3249</span></a> -</span><span id="Parser-3250"><a href="#Parser-3250"><span class="linenos">3250</span></a> <span class="k">if</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">LAMBDAS</span><span class="p">):</span> -</span><span id="Parser-3251"><a href="#Parser-3251"><span class="linenos">3251</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">LAMBDAS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="n">expressions</span><span class="p">)</span> -</span><span id="Parser-3252"><a href="#Parser-3252"><span class="linenos">3252</span></a> -</span><span id="Parser-3253"><a href="#Parser-3253"><span class="linenos">3253</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-3254"><a href="#Parser-3254"><span class="linenos">3254</span></a> -</span><span id="Parser-3255"><a href="#Parser-3255"><span class="linenos">3255</span></a> <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><span id="Parser-3237"><a href="#Parser-3237"><span class="linenos">3237</span></a> <span class="k">if</span> <span class="n">this</span> <span class="ow">and</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">DOT</span><span class="p">):</span> +</span><span id="Parser-3238"><a href="#Parser-3238"><span class="linenos">3238</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">name</span> +</span><span id="Parser-3239"><a href="#Parser-3239"><span class="linenos">3239</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="Parser-3240"><a href="#Parser-3240"><span class="linenos">3240</span></a> +</span><span id="Parser-3241"><a href="#Parser-3241"><span class="linenos">3241</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">SessionParameter</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">)</span> +</span><span id="Parser-3242"><a href="#Parser-3242"><span class="linenos">3242</span></a> +</span><span id="Parser-3243"><a href="#Parser-3243"><span class="linenos">3243</span></a> <span class="k">def</span> <span class="nf">_parse_lambda</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">alias</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="Parser-3244"><a href="#Parser-3244"><span class="linenos">3244</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="Parser-3245"><a href="#Parser-3245"><span class="linenos">3245</span></a> +</span><span id="Parser-3246"><a href="#Parser-3246"><span class="linenos">3246</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_PAREN</span><span class="p">):</span> +</span><span id="Parser-3247"><a href="#Parser-3247"><span class="linenos">3247</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">)</span> +</span><span id="Parser-3248"><a href="#Parser-3248"><span class="linenos">3248</span></a> +</span><span id="Parser-3249"><a href="#Parser-3249"><span class="linenos">3249</span></a> <span class="k">if</span> <span class="ow">not</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">R_PAREN</span><span class="p">):</span> +</span><span id="Parser-3250"><a href="#Parser-3250"><span class="linenos">3250</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-3251"><a href="#Parser-3251"><span class="linenos">3251</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3252"><a href="#Parser-3252"><span class="linenos">3252</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()]</span> +</span><span id="Parser-3253"><a href="#Parser-3253"><span class="linenos">3253</span></a> +</span><span id="Parser-3254"><a href="#Parser-3254"><span class="linenos">3254</span></a> <span class="k">if</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">LAMBDAS</span><span class="p">):</span> +</span><span id="Parser-3255"><a href="#Parser-3255"><span class="linenos">3255</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">LAMBDAS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="n">expressions</span><span class="p">)</span> </span><span id="Parser-3256"><a href="#Parser-3256"><span class="linenos">3256</span></a> -</span><span id="Parser-3257"><a href="#Parser-3257"><span class="linenos">3257</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">DISTINCT</span><span class="p">):</span> -</span><span id="Parser-3258"><a href="#Parser-3258"><span class="linenos">3258</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-3259"><a href="#Parser-3259"><span class="linenos">3259</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Distinct</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="Parser-3260"><a href="#Parser-3260"><span class="linenos">3260</span></a> <span class="p">)</span> -</span><span id="Parser-3261"><a href="#Parser-3261"><span class="linenos">3261</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3262"><a href="#Parser-3262"><span class="linenos">3262</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select_or_expression</span><span class="p">(</span><span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> -</span><span id="Parser-3263"><a href="#Parser-3263"><span class="linenos">3263</span></a> -</span><span id="Parser-3264"><a href="#Parser-3264"><span class="linenos">3264</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">EQ</span><span class="p">):</span> -</span><span id="Parser-3265"><a href="#Parser-3265"><span class="linenos">3265</span></a> <span class="n">left</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">this</span> -</span><span id="Parser-3266"><a href="#Parser-3266"><span class="linenos">3266</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">left</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> -</span><span id="Parser-3267"><a href="#Parser-3267"><span class="linenos">3267</span></a> <span class="n">left</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">var</span><span class="p">(</span><span class="n">left</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"this"</span><span class="p">)))</span> -</span><span id="Parser-3268"><a href="#Parser-3268"><span class="linenos">3268</span></a> -</span><span id="Parser-3269"><a href="#Parser-3269"><span class="linenos">3269</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_limit</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_respect_or_ignore_nulls</span><span class="p">(</span><span class="n">this</span><span class="p">)))</span> -</span><span id="Parser-3270"><a href="#Parser-3270"><span class="linenos">3270</span></a> -</span><span id="Parser-3271"><a href="#Parser-3271"><span class="linenos">3271</span></a> <span class="k">def</span> <span class="nf">_parse_schema</span><span class="p">(</span><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 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="Parser-3272"><a href="#Parser-3272"><span class="linenos">3272</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="Parser-3273"><a href="#Parser-3273"><span class="linenos">3273</span></a> -</span><span id="Parser-3274"><a href="#Parser-3274"><span class="linenos">3274</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">:</span> -</span><span id="Parser-3275"><a href="#Parser-3275"><span class="linenos">3275</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="Parser-3276"><a href="#Parser-3276"><span class="linenos">3276</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> -</span><span id="Parser-3277"><a href="#Parser-3277"><span class="linenos">3277</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-3278"><a href="#Parser-3278"><span class="linenos">3278</span></a> <span class="k">except</span> <span class="n">ParseError</span><span class="p">:</span> -</span><span id="Parser-3279"><a href="#Parser-3279"><span class="linenos">3279</span></a> <span class="k">pass</span> -</span><span id="Parser-3280"><a href="#Parser-3280"><span class="linenos">3280</span></a> <span class="k">finally</span><span class="p">:</span> -</span><span id="Parser-3281"><a href="#Parser-3281"><span class="linenos">3281</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span> -</span><span id="Parser-3282"><a href="#Parser-3282"><span class="linenos">3282</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-3283"><a href="#Parser-3283"><span class="linenos">3283</span></a> -</span><span id="Parser-3284"><a href="#Parser-3284"><span class="linenos">3284</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">):</span> -</span><span id="Parser-3285"><a href="#Parser-3285"><span class="linenos">3285</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-3286"><a href="#Parser-3286"><span class="linenos">3286</span></a> -</span><span id="Parser-3287"><a href="#Parser-3287"><span class="linenos">3287</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> -</span><span id="Parser-3288"><a href="#Parser-3288"><span class="linenos">3288</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_constraint</span><span class="p">()</span> -</span><span id="Parser-3289"><a href="#Parser-3289"><span class="linenos">3289</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_def</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> -</span><span id="Parser-3290"><a href="#Parser-3290"><span class="linenos">3290</span></a> <span class="p">)</span> -</span><span id="Parser-3291"><a href="#Parser-3291"><span class="linenos">3291</span></a> -</span><span id="Parser-3292"><a href="#Parser-3292"><span class="linenos">3292</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="Parser-3293"><a href="#Parser-3293"><span class="linenos">3293</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">Schema</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">args</span><span class="p">)</span> -</span><span id="Parser-3294"><a href="#Parser-3294"><span class="linenos">3294</span></a> -</span><span id="Parser-3295"><a href="#Parser-3295"><span class="linenos">3295</span></a> <span class="k">def</span> <span class="nf">_parse_column_def</span><span class="p">(</span><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="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="Parser-3296"><a href="#Parser-3296"><span class="linenos">3296</span></a> <span class="c1"># column defs are not really columns, they're identifiers</span> -</span><span id="Parser-3297"><a href="#Parser-3297"><span class="linenos">3297</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">Column</span><span class="p">):</span> -</span><span id="Parser-3298"><a href="#Parser-3298"><span class="linenos">3298</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">this</span> -</span><span id="Parser-3299"><a href="#Parser-3299"><span class="linenos">3299</span></a> -</span><span id="Parser-3300"><a href="#Parser-3300"><span class="linenos">3300</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-3301"><a href="#Parser-3301"><span class="linenos">3301</span></a> -</span><span id="Parser-3302"><a href="#Parser-3302"><span class="linenos">3302</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"ORDINALITY"</span><span class="p">):</span> -</span><span id="Parser-3303"><a href="#Parser-3303"><span class="linenos">3303</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">ColumnDef</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">ordinality</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-3304"><a href="#Parser-3304"><span class="linenos">3304</span></a> -</span><span id="Parser-3305"><a href="#Parser-3305"><span class="linenos">3305</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-3306"><a href="#Parser-3306"><span class="linenos">3306</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Parser-3307"><a href="#Parser-3307"><span class="linenos">3307</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_constraint</span><span class="p">()</span> -</span><span id="Parser-3308"><a href="#Parser-3308"><span class="linenos">3308</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">constraint</span><span class="p">:</span> -</span><span id="Parser-3309"><a href="#Parser-3309"><span class="linenos">3309</span></a> <span class="k">break</span> -</span><span id="Parser-3310"><a href="#Parser-3310"><span class="linenos">3310</span></a> <span class="n">constraints</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">constraint</span><span class="p">)</span> -</span><span id="Parser-3311"><a href="#Parser-3311"><span class="linenos">3311</span></a> -</span><span id="Parser-3312"><a href="#Parser-3312"><span class="linenos">3312</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">kind</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">constraints</span><span class="p">:</span> -</span><span id="Parser-3313"><a href="#Parser-3313"><span class="linenos">3313</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-3314"><a href="#Parser-3314"><span class="linenos">3314</span></a> -</span><span id="Parser-3315"><a href="#Parser-3315"><span class="linenos">3315</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">ColumnDef</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> <span class="n">constraints</span><span class="o">=</span><span class="n">constraints</span><span class="p">)</span> -</span><span id="Parser-3316"><a href="#Parser-3316"><span class="linenos">3316</span></a> -</span><span id="Parser-3317"><a href="#Parser-3317"><span class="linenos">3317</span></a> <span class="k">def</span> <span class="nf">_parse_auto_increment</span><span class="p">(</span> -</span><span id="Parser-3318"><a href="#Parser-3318"><span class="linenos">3318</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Parser-3319"><a href="#Parser-3319"><span class="linenos">3319</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">AutoIncrementColumnConstraint</span><span class="p">:</span> -</span><span id="Parser-3320"><a href="#Parser-3320"><span class="linenos">3320</span></a> <span class="n">start</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-3321"><a href="#Parser-3321"><span class="linenos">3321</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-3322"><a href="#Parser-3322"><span class="linenos">3322</span></a> -</span><span id="Parser-3323"><a href="#Parser-3323"><span class="linenos">3323</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_PAREN</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="Parser-3324"><a href="#Parser-3324"><span class="linenos">3324</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_bitwise</span><span class="p">)</span> -</span><span id="Parser-3325"><a href="#Parser-3325"><span class="linenos">3325</span></a> <span class="n">start</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="Parser-3326"><a href="#Parser-3326"><span class="linenos">3326</span></a> <span class="n">increment</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="Parser-3327"><a href="#Parser-3327"><span class="linenos">3327</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"START"</span><span class="p">):</span> -</span><span id="Parser-3328"><a href="#Parser-3328"><span class="linenos">3328</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="Parser-3329"><a href="#Parser-3329"><span class="linenos">3329</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INCREMENT"</span><span class="p">)</span> -</span><span id="Parser-3330"><a href="#Parser-3330"><span class="linenos">3330</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="Parser-3331"><a href="#Parser-3331"><span class="linenos">3331</span></a> -</span><span id="Parser-3332"><a href="#Parser-3332"><span class="linenos">3332</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">and</span> <span class="n">increment</span><span class="p">:</span> -</span><span id="Parser-3333"><a href="#Parser-3333"><span class="linenos">3333</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span><span class="p">(</span><span class="n">start</span><span class="o">=</span><span class="n">start</span><span class="p">,</span> <span class="n">increment</span><span class="o">=</span><span class="n">increment</span><span class="p">)</span> -</span><span id="Parser-3334"><a href="#Parser-3334"><span class="linenos">3334</span></a> -</span><span id="Parser-3335"><a href="#Parser-3335"><span class="linenos">3335</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">AutoIncrementColumnConstraint</span><span class="p">()</span> -</span><span id="Parser-3336"><a href="#Parser-3336"><span class="linenos">3336</span></a> -</span><span id="Parser-3337"><a href="#Parser-3337"><span class="linenos">3337</span></a> <span class="k">def</span> <span class="nf">_parse_compress</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">CompressColumnConstraint</span><span class="p">:</span> -</span><span id="Parser-3338"><a href="#Parser-3338"><span class="linenos">3338</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_PAREN</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="Parser-3339"><a href="#Parser-3339"><span class="linenos">3339</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><span id="Parser-3340"><a href="#Parser-3340"><span class="linenos">3340</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CompressColumnConstraint</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_wrapped_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">)</span> -</span><span id="Parser-3341"><a href="#Parser-3341"><span class="linenos">3341</span></a> <span class="p">)</span> -</span><span id="Parser-3342"><a href="#Parser-3342"><span class="linenos">3342</span></a> -</span><span id="Parser-3343"><a href="#Parser-3343"><span class="linenos">3343</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">CompressColumnConstraint</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_bitwise</span><span class="p">())</span> -</span><span id="Parser-3344"><a href="#Parser-3344"><span class="linenos">3344</span></a> -</span><span id="Parser-3345"><a href="#Parser-3345"><span class="linenos">3345</span></a> <span class="k">def</span> <span class="nf">_parse_generated_as_identity</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">GeneratedAsIdentityColumnConstraint</span><span class="p">:</span> -</span><span id="Parser-3346"><a href="#Parser-3346"><span class="linenos">3346</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BY"</span><span class="p">,</span> <span class="s2">"DEFAULT"</span><span class="p">):</span> -</span><span id="Parser-3347"><a href="#Parser-3347"><span class="linenos">3347</span></a> <span class="n">on_null</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ON</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">)</span> -</span><span id="Parser-3348"><a href="#Parser-3348"><span class="linenos">3348</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-3349"><a href="#Parser-3349"><span class="linenos">3349</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">on_null</span><span class="o">=</span><span class="n">on_null</span> -</span><span id="Parser-3350"><a href="#Parser-3350"><span class="linenos">3350</span></a> <span class="p">)</span> -</span><span id="Parser-3351"><a href="#Parser-3351"><span class="linenos">3351</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3352"><a href="#Parser-3352"><span class="linenos">3352</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ALWAYS"</span><span class="p">)</span> -</span><span id="Parser-3353"><a href="#Parser-3353"><span class="linenos">3353</span></a> <span class="n">this</span> <span class="o">=</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">GeneratedAsIdentityColumnConstraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-3354"><a href="#Parser-3354"><span class="linenos">3354</span></a> -</span><span id="Parser-3355"><a href="#Parser-3355"><span class="linenos">3355</span></a> <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">ALIAS</span><span class="p">)</span> -</span><span id="Parser-3356"><a href="#Parser-3356"><span class="linenos">3356</span></a> <span class="n">identity</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"IDENTITY"</span><span class="p">)</span> -</span><span id="Parser-3357"><a href="#Parser-3357"><span class="linenos">3357</span></a> -</span><span id="Parser-3358"><a href="#Parser-3358"><span class="linenos">3358</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_PAREN</span><span class="p">):</span> -</span><span id="Parser-3359"><a href="#Parser-3359"><span class="linenos">3359</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"START"</span><span class="p">,</span> <span class="s2">"WITH"</span><span class="p">):</span> -</span><span id="Parser-3360"><a href="#Parser-3360"><span class="linenos">3360</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"start"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> -</span><span id="Parser-3361"><a href="#Parser-3361"><span class="linenos">3361</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INCREMENT"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> -</span><span id="Parser-3362"><a href="#Parser-3362"><span class="linenos">3362</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"increment"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> -</span><span id="Parser-3363"><a href="#Parser-3363"><span class="linenos">3363</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MINVALUE"</span><span class="p">):</span> -</span><span id="Parser-3364"><a href="#Parser-3364"><span class="linenos">3364</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"minvalue"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> -</span><span id="Parser-3365"><a href="#Parser-3365"><span class="linenos">3365</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MAXVALUE"</span><span class="p">):</span> -</span><span id="Parser-3366"><a href="#Parser-3366"><span class="linenos">3366</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"maxvalue"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> -</span><span id="Parser-3367"><a href="#Parser-3367"><span class="linenos">3367</span></a> -</span><span id="Parser-3368"><a href="#Parser-3368"><span class="linenos">3368</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CYCLE"</span><span class="p">):</span> -</span><span id="Parser-3369"><a href="#Parser-3369"><span class="linenos">3369</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"cycle"</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-3370"><a href="#Parser-3370"><span class="linenos">3370</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"CYCLE"</span><span class="p">):</span> -</span><span id="Parser-3371"><a href="#Parser-3371"><span class="linenos">3371</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"cycle"</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> -</span><span id="Parser-3372"><a href="#Parser-3372"><span class="linenos">3372</span></a> -</span><span id="Parser-3373"><a href="#Parser-3373"><span class="linenos">3373</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">identity</span><span class="p">:</span> -</span><span id="Parser-3374"><a href="#Parser-3374"><span class="linenos">3374</span></a> <span class="n">this</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="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> -</span><span id="Parser-3375"><a href="#Parser-3375"><span class="linenos">3375</span></a> -</span><span id="Parser-3376"><a href="#Parser-3376"><span class="linenos">3376</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="Parser-3377"><a href="#Parser-3377"><span class="linenos">3377</span></a> -</span><span id="Parser-3378"><a href="#Parser-3378"><span class="linenos">3378</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-3257"><a href="#Parser-3257"><span class="linenos">3257</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-3258"><a href="#Parser-3258"><span class="linenos">3258</span></a> +</span><span id="Parser-3259"><a href="#Parser-3259"><span class="linenos">3259</span></a> <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><span id="Parser-3260"><a href="#Parser-3260"><span class="linenos">3260</span></a> +</span><span id="Parser-3261"><a href="#Parser-3261"><span class="linenos">3261</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">DISTINCT</span><span class="p">):</span> +</span><span id="Parser-3262"><a href="#Parser-3262"><span class="linenos">3262</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-3263"><a href="#Parser-3263"><span class="linenos">3263</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Distinct</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="Parser-3264"><a href="#Parser-3264"><span class="linenos">3264</span></a> <span class="p">)</span> +</span><span id="Parser-3265"><a href="#Parser-3265"><span class="linenos">3265</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3266"><a href="#Parser-3266"><span class="linenos">3266</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select_or_expression</span><span class="p">(</span><span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> +</span><span id="Parser-3267"><a href="#Parser-3267"><span class="linenos">3267</span></a> +</span><span id="Parser-3268"><a href="#Parser-3268"><span class="linenos">3268</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">EQ</span><span class="p">):</span> +</span><span id="Parser-3269"><a href="#Parser-3269"><span class="linenos">3269</span></a> <span class="n">left</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">this</span> +</span><span id="Parser-3270"><a href="#Parser-3270"><span class="linenos">3270</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">left</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> +</span><span id="Parser-3271"><a href="#Parser-3271"><span class="linenos">3271</span></a> <span class="n">left</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">var</span><span class="p">(</span><span class="n">left</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s2">"this"</span><span class="p">)))</span> +</span><span id="Parser-3272"><a href="#Parser-3272"><span class="linenos">3272</span></a> +</span><span id="Parser-3273"><a href="#Parser-3273"><span class="linenos">3273</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_limit</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_respect_or_ignore_nulls</span><span class="p">(</span><span class="n">this</span><span class="p">)))</span> +</span><span id="Parser-3274"><a href="#Parser-3274"><span class="linenos">3274</span></a> +</span><span id="Parser-3275"><a href="#Parser-3275"><span class="linenos">3275</span></a> <span class="k">def</span> <span class="nf">_parse_schema</span><span class="p">(</span><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 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="Parser-3276"><a href="#Parser-3276"><span class="linenos">3276</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="Parser-3277"><a href="#Parser-3277"><span class="linenos">3277</span></a> +</span><span id="Parser-3278"><a href="#Parser-3278"><span class="linenos">3278</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">:</span> +</span><span id="Parser-3279"><a href="#Parser-3279"><span class="linenos">3279</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="Parser-3280"><a href="#Parser-3280"><span class="linenos">3280</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> +</span><span id="Parser-3281"><a href="#Parser-3281"><span class="linenos">3281</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-3282"><a href="#Parser-3282"><span class="linenos">3282</span></a> <span class="k">except</span> <span class="n">ParseError</span><span class="p">:</span> +</span><span id="Parser-3283"><a href="#Parser-3283"><span class="linenos">3283</span></a> <span class="k">pass</span> +</span><span id="Parser-3284"><a href="#Parser-3284"><span class="linenos">3284</span></a> <span class="k">finally</span><span class="p">:</span> +</span><span id="Parser-3285"><a href="#Parser-3285"><span class="linenos">3285</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span> +</span><span id="Parser-3286"><a href="#Parser-3286"><span class="linenos">3286</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-3287"><a href="#Parser-3287"><span class="linenos">3287</span></a> +</span><span id="Parser-3288"><a href="#Parser-3288"><span class="linenos">3288</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">):</span> +</span><span id="Parser-3289"><a href="#Parser-3289"><span class="linenos">3289</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-3290"><a href="#Parser-3290"><span class="linenos">3290</span></a> +</span><span id="Parser-3291"><a href="#Parser-3291"><span class="linenos">3291</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> +</span><span id="Parser-3292"><a href="#Parser-3292"><span class="linenos">3292</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_constraint</span><span class="p">()</span> +</span><span id="Parser-3293"><a href="#Parser-3293"><span class="linenos">3293</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_def</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="Parser-3294"><a href="#Parser-3294"><span class="linenos">3294</span></a> <span class="p">)</span> +</span><span id="Parser-3295"><a href="#Parser-3295"><span class="linenos">3295</span></a> +</span><span id="Parser-3296"><a href="#Parser-3296"><span class="linenos">3296</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-3297"><a href="#Parser-3297"><span class="linenos">3297</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">Schema</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">args</span><span class="p">)</span> +</span><span id="Parser-3298"><a href="#Parser-3298"><span class="linenos">3298</span></a> +</span><span id="Parser-3299"><a href="#Parser-3299"><span class="linenos">3299</span></a> <span class="k">def</span> <span class="nf">_parse_column_def</span><span class="p">(</span><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="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="Parser-3300"><a href="#Parser-3300"><span class="linenos">3300</span></a> <span class="c1"># column defs are not really columns, they're identifiers</span> +</span><span id="Parser-3301"><a href="#Parser-3301"><span class="linenos">3301</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">Column</span><span class="p">):</span> +</span><span id="Parser-3302"><a href="#Parser-3302"><span class="linenos">3302</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">this</span> +</span><span id="Parser-3303"><a href="#Parser-3303"><span class="linenos">3303</span></a> +</span><span id="Parser-3304"><a href="#Parser-3304"><span class="linenos">3304</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-3305"><a href="#Parser-3305"><span class="linenos">3305</span></a> +</span><span id="Parser-3306"><a href="#Parser-3306"><span class="linenos">3306</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FOR"</span><span class="p">,</span> <span class="s2">"ORDINALITY"</span><span class="p">):</span> +</span><span id="Parser-3307"><a href="#Parser-3307"><span class="linenos">3307</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">ColumnDef</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">ordinality</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-3308"><a href="#Parser-3308"><span class="linenos">3308</span></a> +</span><span id="Parser-3309"><a href="#Parser-3309"><span class="linenos">3309</span></a> <span class="n">constraints</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-3310"><a href="#Parser-3310"><span class="linenos">3310</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Parser-3311"><a href="#Parser-3311"><span class="linenos">3311</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_constraint</span><span class="p">()</span> +</span><span id="Parser-3312"><a href="#Parser-3312"><span class="linenos">3312</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">constraint</span><span class="p">:</span> +</span><span id="Parser-3313"><a href="#Parser-3313"><span class="linenos">3313</span></a> <span class="k">break</span> +</span><span id="Parser-3314"><a href="#Parser-3314"><span class="linenos">3314</span></a> <span class="n">constraints</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">constraint</span><span class="p">)</span> +</span><span id="Parser-3315"><a href="#Parser-3315"><span class="linenos">3315</span></a> +</span><span id="Parser-3316"><a href="#Parser-3316"><span class="linenos">3316</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">kind</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">constraints</span><span class="p">:</span> +</span><span id="Parser-3317"><a href="#Parser-3317"><span class="linenos">3317</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-3318"><a href="#Parser-3318"><span class="linenos">3318</span></a> +</span><span id="Parser-3319"><a href="#Parser-3319"><span class="linenos">3319</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">ColumnDef</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> <span class="n">constraints</span><span class="o">=</span><span class="n">constraints</span><span class="p">)</span> +</span><span id="Parser-3320"><a href="#Parser-3320"><span class="linenos">3320</span></a> +</span><span id="Parser-3321"><a href="#Parser-3321"><span class="linenos">3321</span></a> <span class="k">def</span> <span class="nf">_parse_auto_increment</span><span class="p">(</span> +</span><span id="Parser-3322"><a href="#Parser-3322"><span class="linenos">3322</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Parser-3323"><a href="#Parser-3323"><span class="linenos">3323</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">AutoIncrementColumnConstraint</span><span class="p">:</span> +</span><span id="Parser-3324"><a href="#Parser-3324"><span class="linenos">3324</span></a> <span class="n">start</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-3325"><a href="#Parser-3325"><span class="linenos">3325</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-3326"><a href="#Parser-3326"><span class="linenos">3326</span></a> +</span><span id="Parser-3327"><a href="#Parser-3327"><span class="linenos">3327</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_PAREN</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="Parser-3328"><a href="#Parser-3328"><span class="linenos">3328</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_bitwise</span><span class="p">)</span> +</span><span id="Parser-3329"><a href="#Parser-3329"><span class="linenos">3329</span></a> <span class="n">start</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="Parser-3330"><a href="#Parser-3330"><span class="linenos">3330</span></a> <span class="n">increment</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="Parser-3331"><a href="#Parser-3331"><span class="linenos">3331</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"START"</span><span class="p">):</span> +</span><span id="Parser-3332"><a href="#Parser-3332"><span class="linenos">3332</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="Parser-3333"><a href="#Parser-3333"><span class="linenos">3333</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INCREMENT"</span><span class="p">)</span> +</span><span id="Parser-3334"><a href="#Parser-3334"><span class="linenos">3334</span></a> <span class="n">increment</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="Parser-3335"><a href="#Parser-3335"><span class="linenos">3335</span></a> +</span><span id="Parser-3336"><a href="#Parser-3336"><span class="linenos">3336</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">and</span> <span class="n">increment</span><span class="p">:</span> +</span><span id="Parser-3337"><a href="#Parser-3337"><span class="linenos">3337</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span><span class="p">(</span><span class="n">start</span><span class="o">=</span><span class="n">start</span><span class="p">,</span> <span class="n">increment</span><span class="o">=</span><span class="n">increment</span><span class="p">)</span> +</span><span id="Parser-3338"><a href="#Parser-3338"><span class="linenos">3338</span></a> +</span><span id="Parser-3339"><a href="#Parser-3339"><span class="linenos">3339</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">AutoIncrementColumnConstraint</span><span class="p">()</span> +</span><span id="Parser-3340"><a href="#Parser-3340"><span class="linenos">3340</span></a> +</span><span id="Parser-3341"><a href="#Parser-3341"><span class="linenos">3341</span></a> <span class="k">def</span> <span class="nf">_parse_compress</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">CompressColumnConstraint</span><span class="p">:</span> +</span><span id="Parser-3342"><a href="#Parser-3342"><span class="linenos">3342</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_PAREN</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="Parser-3343"><a href="#Parser-3343"><span class="linenos">3343</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><span id="Parser-3344"><a href="#Parser-3344"><span class="linenos">3344</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CompressColumnConstraint</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_wrapped_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">)</span> +</span><span id="Parser-3345"><a href="#Parser-3345"><span class="linenos">3345</span></a> <span class="p">)</span> +</span><span id="Parser-3346"><a href="#Parser-3346"><span class="linenos">3346</span></a> +</span><span id="Parser-3347"><a href="#Parser-3347"><span class="linenos">3347</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">CompressColumnConstraint</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_bitwise</span><span class="p">())</span> +</span><span id="Parser-3348"><a href="#Parser-3348"><span class="linenos">3348</span></a> +</span><span id="Parser-3349"><a href="#Parser-3349"><span class="linenos">3349</span></a> <span class="k">def</span> <span class="nf">_parse_generated_as_identity</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">GeneratedAsIdentityColumnConstraint</span><span class="p">:</span> +</span><span id="Parser-3350"><a href="#Parser-3350"><span class="linenos">3350</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BY"</span><span class="p">,</span> <span class="s2">"DEFAULT"</span><span class="p">):</span> +</span><span id="Parser-3351"><a href="#Parser-3351"><span class="linenos">3351</span></a> <span class="n">on_null</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ON</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">)</span> +</span><span id="Parser-3352"><a href="#Parser-3352"><span class="linenos">3352</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-3353"><a href="#Parser-3353"><span class="linenos">3353</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">GeneratedAsIdentityColumnConstraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">on_null</span><span class="o">=</span><span class="n">on_null</span> +</span><span id="Parser-3354"><a href="#Parser-3354"><span class="linenos">3354</span></a> <span class="p">)</span> +</span><span id="Parser-3355"><a href="#Parser-3355"><span class="linenos">3355</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3356"><a href="#Parser-3356"><span class="linenos">3356</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ALWAYS"</span><span class="p">)</span> +</span><span id="Parser-3357"><a href="#Parser-3357"><span class="linenos">3357</span></a> <span class="n">this</span> <span class="o">=</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">GeneratedAsIdentityColumnConstraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-3358"><a href="#Parser-3358"><span class="linenos">3358</span></a> +</span><span id="Parser-3359"><a href="#Parser-3359"><span class="linenos">3359</span></a> <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">ALIAS</span><span class="p">)</span> +</span><span id="Parser-3360"><a href="#Parser-3360"><span class="linenos">3360</span></a> <span class="n">identity</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"IDENTITY"</span><span class="p">)</span> +</span><span id="Parser-3361"><a href="#Parser-3361"><span class="linenos">3361</span></a> +</span><span id="Parser-3362"><a href="#Parser-3362"><span class="linenos">3362</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_PAREN</span><span class="p">):</span> +</span><span id="Parser-3363"><a href="#Parser-3363"><span class="linenos">3363</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"START"</span><span class="p">,</span> <span class="s2">"WITH"</span><span class="p">):</span> +</span><span id="Parser-3364"><a href="#Parser-3364"><span class="linenos">3364</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"start"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> +</span><span id="Parser-3365"><a href="#Parser-3365"><span class="linenos">3365</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INCREMENT"</span><span class="p">,</span> <span class="s2">"BY"</span><span class="p">):</span> +</span><span id="Parser-3366"><a href="#Parser-3366"><span class="linenos">3366</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"increment"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> +</span><span id="Parser-3367"><a href="#Parser-3367"><span class="linenos">3367</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MINVALUE"</span><span class="p">):</span> +</span><span id="Parser-3368"><a href="#Parser-3368"><span class="linenos">3368</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"minvalue"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> +</span><span id="Parser-3369"><a href="#Parser-3369"><span class="linenos">3369</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MAXVALUE"</span><span class="p">):</span> +</span><span id="Parser-3370"><a href="#Parser-3370"><span class="linenos">3370</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"maxvalue"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> +</span><span id="Parser-3371"><a href="#Parser-3371"><span class="linenos">3371</span></a> +</span><span id="Parser-3372"><a href="#Parser-3372"><span class="linenos">3372</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CYCLE"</span><span class="p">):</span> +</span><span id="Parser-3373"><a href="#Parser-3373"><span class="linenos">3373</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"cycle"</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-3374"><a href="#Parser-3374"><span class="linenos">3374</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"CYCLE"</span><span class="p">):</span> +</span><span id="Parser-3375"><a href="#Parser-3375"><span class="linenos">3375</span></a> <span class="n">this</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"cycle"</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span> +</span><span id="Parser-3376"><a href="#Parser-3376"><span class="linenos">3376</span></a> +</span><span id="Parser-3377"><a href="#Parser-3377"><span class="linenos">3377</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">identity</span><span class="p">:</span> +</span><span id="Parser-3378"><a href="#Parser-3378"><span class="linenos">3378</span></a> <span class="n">this</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="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> </span><span id="Parser-3379"><a href="#Parser-3379"><span class="linenos">3379</span></a> -</span><span id="Parser-3380"><a href="#Parser-3380"><span class="linenos">3380</span></a> <span class="k">def</span> <span class="nf">_parse_inline</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">InlineLengthColumnConstraint</span><span class="p">:</span> -</span><span id="Parser-3381"><a href="#Parser-3381"><span class="linenos">3381</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">)</span> -</span><span id="Parser-3382"><a href="#Parser-3382"><span class="linenos">3382</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">InlineLengthColumnConstraint</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_bitwise</span><span class="p">())</span> +</span><span id="Parser-3380"><a href="#Parser-3380"><span class="linenos">3380</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-3381"><a href="#Parser-3381"><span class="linenos">3381</span></a> +</span><span id="Parser-3382"><a href="#Parser-3382"><span class="linenos">3382</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="Parser-3383"><a href="#Parser-3383"><span class="linenos">3383</span></a> -</span><span id="Parser-3384"><a href="#Parser-3384"><span class="linenos">3384</span></a> <span class="k">def</span> <span class="nf">_parse_not_constraint</span><span class="p">(</span> -</span><span id="Parser-3385"><a href="#Parser-3385"><span class="linenos">3385</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Parser-3386"><a href="#Parser-3386"><span class="linenos">3386</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">NotNullColumnConstraint</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">CaseSpecificColumnConstraint</span><span class="p">]:</span> -</span><span id="Parser-3387"><a href="#Parser-3387"><span class="linenos">3387</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULL"</span><span class="p">):</span> -</span><span id="Parser-3388"><a href="#Parser-3388"><span class="linenos">3388</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">NotNullColumnConstraint</span><span class="p">)</span> -</span><span id="Parser-3389"><a href="#Parser-3389"><span class="linenos">3389</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CASESPECIFIC"</span><span class="p">):</span> -</span><span id="Parser-3390"><a href="#Parser-3390"><span class="linenos">3390</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">CaseSpecificColumnConstraint</span><span class="p">,</span> <span class="n">not_</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-3391"><a href="#Parser-3391"><span class="linenos">3391</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-3392"><a href="#Parser-3392"><span class="linenos">3392</span></a> -</span><span id="Parser-3393"><a href="#Parser-3393"><span class="linenos">3393</span></a> <span class="k">def</span> <span class="nf">_parse_column_constraint</span><span class="p">(</span><span class="bp">self</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="Parser-3394"><a href="#Parser-3394"><span class="linenos">3394</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">CONSTRAINT</span><span class="p">):</span> -</span><span id="Parser-3395"><a href="#Parser-3395"><span class="linenos">3395</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="Parser-3396"><a href="#Parser-3396"><span class="linenos">3396</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3397"><a href="#Parser-3397"><span class="linenos">3397</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-3398"><a href="#Parser-3398"><span class="linenos">3398</span></a> -</span><span id="Parser-3399"><a href="#Parser-3399"><span class="linenos">3399</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">):</span> -</span><span id="Parser-3400"><a href="#Parser-3400"><span class="linenos">3400</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><span id="Parser-3401"><a href="#Parser-3401"><span class="linenos">3401</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnConstraint</span><span class="p">,</span> -</span><span id="Parser-3402"><a href="#Parser-3402"><span class="linenos">3402</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="Parser-3403"><a href="#Parser-3403"><span class="linenos">3403</span></a> <span class="n">kind</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">[</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="o">.</span><span class="n">upper</span><span class="p">()](</span><span class="bp">self</span><span class="p">),</span> -</span><span id="Parser-3404"><a href="#Parser-3404"><span class="linenos">3404</span></a> <span class="p">)</span> -</span><span id="Parser-3405"><a href="#Parser-3405"><span class="linenos">3405</span></a> -</span><span id="Parser-3406"><a href="#Parser-3406"><span class="linenos">3406</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-3407"><a href="#Parser-3407"><span class="linenos">3407</span></a> -</span><span id="Parser-3408"><a href="#Parser-3408"><span class="linenos">3408</span></a> <span class="k">def</span> <span class="nf">_parse_constraint</span><span class="p">(</span><span class="bp">self</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="Parser-3409"><a href="#Parser-3409"><span class="linenos">3409</span></a> <span class="k">if</span> <span class="ow">not</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">CONSTRAINT</span><span class="p">):</span> -</span><span id="Parser-3410"><a href="#Parser-3410"><span class="linenos">3410</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_unnamed_constraint</span><span class="p">(</span><span class="n">constraints</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">SCHEMA_UNNAMED_CONSTRAINTS</span><span class="p">)</span> +</span><span id="Parser-3384"><a href="#Parser-3384"><span class="linenos">3384</span></a> <span class="k">def</span> <span class="nf">_parse_inline</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">InlineLengthColumnConstraint</span><span class="p">:</span> +</span><span id="Parser-3385"><a href="#Parser-3385"><span class="linenos">3385</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LENGTH"</span><span class="p">)</span> +</span><span id="Parser-3386"><a href="#Parser-3386"><span class="linenos">3386</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">InlineLengthColumnConstraint</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_bitwise</span><span class="p">())</span> +</span><span id="Parser-3387"><a href="#Parser-3387"><span class="linenos">3387</span></a> +</span><span id="Parser-3388"><a href="#Parser-3388"><span class="linenos">3388</span></a> <span class="k">def</span> <span class="nf">_parse_not_constraint</span><span class="p">(</span> +</span><span id="Parser-3389"><a href="#Parser-3389"><span class="linenos">3389</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Parser-3390"><a href="#Parser-3390"><span class="linenos">3390</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">NotNullColumnConstraint</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">CaseSpecificColumnConstraint</span><span class="p">]:</span> +</span><span id="Parser-3391"><a href="#Parser-3391"><span class="linenos">3391</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULL"</span><span class="p">):</span> +</span><span id="Parser-3392"><a href="#Parser-3392"><span class="linenos">3392</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">NotNullColumnConstraint</span><span class="p">)</span> +</span><span id="Parser-3393"><a href="#Parser-3393"><span class="linenos">3393</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CASESPECIFIC"</span><span class="p">):</span> +</span><span id="Parser-3394"><a href="#Parser-3394"><span class="linenos">3394</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">CaseSpecificColumnConstraint</span><span class="p">,</span> <span class="n">not_</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-3395"><a href="#Parser-3395"><span class="linenos">3395</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-3396"><a href="#Parser-3396"><span class="linenos">3396</span></a> +</span><span id="Parser-3397"><a href="#Parser-3397"><span class="linenos">3397</span></a> <span class="k">def</span> <span class="nf">_parse_column_constraint</span><span class="p">(</span><span class="bp">self</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="Parser-3398"><a href="#Parser-3398"><span class="linenos">3398</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">CONSTRAINT</span><span class="p">):</span> +</span><span id="Parser-3399"><a href="#Parser-3399"><span class="linenos">3399</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="Parser-3400"><a href="#Parser-3400"><span class="linenos">3400</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3401"><a href="#Parser-3401"><span class="linenos">3401</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-3402"><a href="#Parser-3402"><span class="linenos">3402</span></a> +</span><span id="Parser-3403"><a href="#Parser-3403"><span class="linenos">3403</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">):</span> +</span><span id="Parser-3404"><a href="#Parser-3404"><span class="linenos">3404</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><span id="Parser-3405"><a href="#Parser-3405"><span class="linenos">3405</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnConstraint</span><span class="p">,</span> +</span><span id="Parser-3406"><a href="#Parser-3406"><span class="linenos">3406</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="Parser-3407"><a href="#Parser-3407"><span class="linenos">3407</span></a> <span class="n">kind</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">[</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="o">.</span><span class="n">upper</span><span class="p">()](</span><span class="bp">self</span><span class="p">),</span> +</span><span id="Parser-3408"><a href="#Parser-3408"><span class="linenos">3408</span></a> <span class="p">)</span> +</span><span id="Parser-3409"><a href="#Parser-3409"><span class="linenos">3409</span></a> +</span><span id="Parser-3410"><a href="#Parser-3410"><span class="linenos">3410</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="Parser-3411"><a href="#Parser-3411"><span class="linenos">3411</span></a> -</span><span id="Parser-3412"><a href="#Parser-3412"><span class="linenos">3412</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="Parser-3413"><a href="#Parser-3413"><span class="linenos">3413</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-3414"><a href="#Parser-3414"><span class="linenos">3414</span></a> -</span><span id="Parser-3415"><a href="#Parser-3415"><span class="linenos">3415</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Parser-3416"><a href="#Parser-3416"><span class="linenos">3416</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_unnamed_constraint</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> -</span><span id="Parser-3417"><a href="#Parser-3417"><span class="linenos">3417</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">constraint</span><span class="p">:</span> -</span><span id="Parser-3418"><a href="#Parser-3418"><span class="linenos">3418</span></a> <span class="k">break</span> -</span><span id="Parser-3419"><a href="#Parser-3419"><span class="linenos">3419</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">constraint</span><span class="p">)</span> -</span><span id="Parser-3420"><a href="#Parser-3420"><span class="linenos">3420</span></a> -</span><span id="Parser-3421"><a href="#Parser-3421"><span class="linenos">3421</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">Constraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Parser-3422"><a href="#Parser-3422"><span class="linenos">3422</span></a> -</span><span id="Parser-3423"><a href="#Parser-3423"><span class="linenos">3423</span></a> <span class="k">def</span> <span class="nf">_parse_unnamed_constraint</span><span class="p">(</span> -</span><span id="Parser-3424"><a href="#Parser-3424"><span class="linenos">3424</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">constraints</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-3425"><a href="#Parser-3425"><span class="linenos">3425</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="Parser-3426"><a href="#Parser-3426"><span class="linenos">3426</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="n">constraints</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">):</span> -</span><span id="Parser-3427"><a href="#Parser-3427"><span class="linenos">3427</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-3428"><a href="#Parser-3428"><span class="linenos">3428</span></a> -</span><span id="Parser-3429"><a href="#Parser-3429"><span class="linenos">3429</span></a> <span class="n">constraint</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="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Parser-3430"><a href="#Parser-3430"><span class="linenos">3430</span></a> <span class="k">if</span> <span class="n">constraint</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">:</span> -</span><span id="Parser-3431"><a href="#Parser-3431"><span class="linenos">3431</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="sa">f</span><span class="s2">"No parser found for schema constraint </span><span class="si">{</span><span class="n">constraint</span><span class="si">}</span><span class="s2">."</span><span class="p">)</span> +</span><span id="Parser-3412"><a href="#Parser-3412"><span class="linenos">3412</span></a> <span class="k">def</span> <span class="nf">_parse_constraint</span><span class="p">(</span><span class="bp">self</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="Parser-3413"><a href="#Parser-3413"><span class="linenos">3413</span></a> <span class="k">if</span> <span class="ow">not</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">CONSTRAINT</span><span class="p">):</span> +</span><span id="Parser-3414"><a href="#Parser-3414"><span class="linenos">3414</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_unnamed_constraint</span><span class="p">(</span><span class="n">constraints</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">SCHEMA_UNNAMED_CONSTRAINTS</span><span class="p">)</span> +</span><span id="Parser-3415"><a href="#Parser-3415"><span class="linenos">3415</span></a> +</span><span id="Parser-3416"><a href="#Parser-3416"><span class="linenos">3416</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="Parser-3417"><a href="#Parser-3417"><span class="linenos">3417</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-3418"><a href="#Parser-3418"><span class="linenos">3418</span></a> +</span><span id="Parser-3419"><a href="#Parser-3419"><span class="linenos">3419</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Parser-3420"><a href="#Parser-3420"><span class="linenos">3420</span></a> <span class="n">constraint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_unnamed_constraint</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> +</span><span id="Parser-3421"><a href="#Parser-3421"><span class="linenos">3421</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">constraint</span><span class="p">:</span> +</span><span id="Parser-3422"><a href="#Parser-3422"><span class="linenos">3422</span></a> <span class="k">break</span> +</span><span id="Parser-3423"><a href="#Parser-3423"><span class="linenos">3423</span></a> <span class="n">expressions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">constraint</span><span class="p">)</span> +</span><span id="Parser-3424"><a href="#Parser-3424"><span class="linenos">3424</span></a> +</span><span id="Parser-3425"><a href="#Parser-3425"><span class="linenos">3425</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">Constraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Parser-3426"><a href="#Parser-3426"><span class="linenos">3426</span></a> +</span><span id="Parser-3427"><a href="#Parser-3427"><span class="linenos">3427</span></a> <span class="k">def</span> <span class="nf">_parse_unnamed_constraint</span><span class="p">(</span> +</span><span id="Parser-3428"><a href="#Parser-3428"><span class="linenos">3428</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">constraints</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-3429"><a href="#Parser-3429"><span class="linenos">3429</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="Parser-3430"><a href="#Parser-3430"><span class="linenos">3430</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="n">constraints</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">):</span> +</span><span id="Parser-3431"><a href="#Parser-3431"><span class="linenos">3431</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="Parser-3432"><a href="#Parser-3432"><span class="linenos">3432</span></a> -</span><span id="Parser-3433"><a href="#Parser-3433"><span class="linenos">3433</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">[</span><span class="n">constraint</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> -</span><span id="Parser-3434"><a href="#Parser-3434"><span class="linenos">3434</span></a> -</span><span id="Parser-3435"><a href="#Parser-3435"><span class="linenos">3435</span></a> <span class="k">def</span> <span class="nf">_parse_unique</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">UniqueColumnConstraint</span><span class="p">:</span> -</span><span id="Parser-3436"><a href="#Parser-3436"><span class="linenos">3436</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"KEY"</span><span class="p">)</span> -</span><span id="Parser-3437"><a href="#Parser-3437"><span class="linenos">3437</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><span id="Parser-3438"><a href="#Parser-3438"><span class="linenos">3438</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UniqueColumnConstraint</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_schema</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> -</span><span id="Parser-3439"><a href="#Parser-3439"><span class="linenos">3439</span></a> <span class="p">)</span> -</span><span id="Parser-3440"><a href="#Parser-3440"><span class="linenos">3440</span></a> -</span><span id="Parser-3441"><a href="#Parser-3441"><span class="linenos">3441</span></a> <span class="k">def</span> <span class="nf">_parse_key_constraint_options</span><span class="p">(</span><span class="bp">self</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="Parser-3442"><a href="#Parser-3442"><span class="linenos">3442</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-3443"><a href="#Parser-3443"><span class="linenos">3443</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Parser-3444"><a href="#Parser-3444"><span class="linenos">3444</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="Parser-3445"><a href="#Parser-3445"><span class="linenos">3445</span></a> <span class="k">break</span> -</span><span id="Parser-3446"><a href="#Parser-3446"><span class="linenos">3446</span></a> -</span><span id="Parser-3447"><a href="#Parser-3447"><span class="linenos">3447</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">ON</span><span class="p">):</span> -</span><span id="Parser-3448"><a href="#Parser-3448"><span class="linenos">3448</span></a> <span class="n">action</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-3449"><a href="#Parser-3449"><span class="linenos">3449</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</span><span class="p">()</span> <span class="ow">and</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><span id="Parser-3433"><a href="#Parser-3433"><span class="linenos">3433</span></a> <span class="n">constraint</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="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Parser-3434"><a href="#Parser-3434"><span class="linenos">3434</span></a> <span class="k">if</span> <span class="n">constraint</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">:</span> +</span><span id="Parser-3435"><a href="#Parser-3435"><span class="linenos">3435</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="sa">f</span><span class="s2">"No parser found for schema constraint </span><span class="si">{</span><span class="n">constraint</span><span class="si">}</span><span class="s2">."</span><span class="p">)</span> +</span><span id="Parser-3436"><a href="#Parser-3436"><span class="linenos">3436</span></a> +</span><span id="Parser-3437"><a href="#Parser-3437"><span class="linenos">3437</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONSTRAINT_PARSERS</span><span class="p">[</span><span class="n">constraint</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> +</span><span id="Parser-3438"><a href="#Parser-3438"><span class="linenos">3438</span></a> +</span><span id="Parser-3439"><a href="#Parser-3439"><span class="linenos">3439</span></a> <span class="k">def</span> <span class="nf">_parse_unique</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">UniqueColumnConstraint</span><span class="p">:</span> +</span><span id="Parser-3440"><a href="#Parser-3440"><span class="linenos">3440</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"KEY"</span><span class="p">)</span> +</span><span id="Parser-3441"><a href="#Parser-3441"><span class="linenos">3441</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><span id="Parser-3442"><a href="#Parser-3442"><span class="linenos">3442</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">UniqueColumnConstraint</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_schema</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> +</span><span id="Parser-3443"><a href="#Parser-3443"><span class="linenos">3443</span></a> <span class="p">)</span> +</span><span id="Parser-3444"><a href="#Parser-3444"><span class="linenos">3444</span></a> +</span><span id="Parser-3445"><a href="#Parser-3445"><span class="linenos">3445</span></a> <span class="k">def</span> <span class="nf">_parse_key_constraint_options</span><span class="p">(</span><span class="bp">self</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="Parser-3446"><a href="#Parser-3446"><span class="linenos">3446</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-3447"><a href="#Parser-3447"><span class="linenos">3447</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Parser-3448"><a href="#Parser-3448"><span class="linenos">3448</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="Parser-3449"><a href="#Parser-3449"><span class="linenos">3449</span></a> <span class="k">break</span> </span><span id="Parser-3450"><a href="#Parser-3450"><span class="linenos">3450</span></a> -</span><span id="Parser-3451"><a href="#Parser-3451"><span class="linenos">3451</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"ACTION"</span><span class="p">):</span> -</span><span id="Parser-3452"><a href="#Parser-3452"><span class="linenos">3452</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"NO ACTION"</span> -</span><span id="Parser-3453"><a href="#Parser-3453"><span class="linenos">3453</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CASCADE"</span><span class="p">):</span> -</span><span id="Parser-3454"><a href="#Parser-3454"><span class="linenos">3454</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"CASCADE"</span> -</span><span id="Parser-3455"><a href="#Parser-3455"><span class="linenos">3455</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">):</span> -</span><span id="Parser-3456"><a href="#Parser-3456"><span class="linenos">3456</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"SET NULL"</span> -</span><span id="Parser-3457"><a href="#Parser-3457"><span class="linenos">3457</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">):</span> -</span><span id="Parser-3458"><a href="#Parser-3458"><span class="linenos">3458</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"SET DEFAULT"</span> -</span><span id="Parser-3459"><a href="#Parser-3459"><span class="linenos">3459</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3460"><a href="#Parser-3460"><span class="linenos">3460</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Invalid key constraint"</span><span class="p">)</span> -</span><span id="Parser-3461"><a href="#Parser-3461"><span class="linenos">3461</span></a> -</span><span id="Parser-3462"><a href="#Parser-3462"><span class="linenos">3462</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"ON </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">action</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Parser-3463"><a href="#Parser-3463"><span class="linenos">3463</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NOT"</span><span class="p">,</span> <span class="s2">"ENFORCED"</span><span class="p">):</span> -</span><span id="Parser-3464"><a href="#Parser-3464"><span class="linenos">3464</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"NOT ENFORCED"</span><span class="p">)</span> -</span><span id="Parser-3465"><a href="#Parser-3465"><span class="linenos">3465</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFERRABLE"</span><span class="p">):</span> -</span><span id="Parser-3466"><a href="#Parser-3466"><span class="linenos">3466</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"DEFERRABLE"</span><span class="p">)</span> -</span><span id="Parser-3467"><a href="#Parser-3467"><span class="linenos">3467</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INITIALLY"</span><span class="p">,</span> <span class="s2">"DEFERRED"</span><span class="p">):</span> -</span><span id="Parser-3468"><a href="#Parser-3468"><span class="linenos">3468</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"INITIALLY DEFERRED"</span><span class="p">)</span> -</span><span id="Parser-3469"><a href="#Parser-3469"><span class="linenos">3469</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NORELY"</span><span class="p">):</span> -</span><span id="Parser-3470"><a href="#Parser-3470"><span class="linenos">3470</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"NORELY"</span><span class="p">)</span> -</span><span id="Parser-3471"><a href="#Parser-3471"><span class="linenos">3471</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MATCH"</span><span class="p">,</span> <span class="s2">"FULL"</span><span class="p">):</span> -</span><span id="Parser-3472"><a href="#Parser-3472"><span class="linenos">3472</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"MATCH FULL"</span><span class="p">)</span> -</span><span id="Parser-3473"><a href="#Parser-3473"><span class="linenos">3473</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3474"><a href="#Parser-3474"><span class="linenos">3474</span></a> <span class="k">break</span> -</span><span id="Parser-3475"><a href="#Parser-3475"><span class="linenos">3475</span></a> -</span><span id="Parser-3476"><a href="#Parser-3476"><span class="linenos">3476</span></a> <span class="k">return</span> <span class="n">options</span> -</span><span id="Parser-3477"><a href="#Parser-3477"><span class="linenos">3477</span></a> -</span><span id="Parser-3478"><a href="#Parser-3478"><span class="linenos">3478</span></a> <span class="k">def</span> <span class="nf">_parse_references</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">match</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="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">Reference</span><span class="p">]:</span> -</span><span id="Parser-3479"><a href="#Parser-3479"><span class="linenos">3479</span></a> <span class="k">if</span> <span class="n">match</span> <span class="ow">and</span> <span class="ow">not</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">REFERENCES</span><span class="p">):</span> -</span><span id="Parser-3480"><a href="#Parser-3480"><span class="linenos">3480</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-3451"><a href="#Parser-3451"><span class="linenos">3451</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">ON</span><span class="p">):</span> +</span><span id="Parser-3452"><a href="#Parser-3452"><span class="linenos">3452</span></a> <span class="n">action</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-3453"><a href="#Parser-3453"><span class="linenos">3453</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</span><span class="p">()</span> <span class="ow">and</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><span id="Parser-3454"><a href="#Parser-3454"><span class="linenos">3454</span></a> +</span><span id="Parser-3455"><a href="#Parser-3455"><span class="linenos">3455</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"ACTION"</span><span class="p">):</span> +</span><span id="Parser-3456"><a href="#Parser-3456"><span class="linenos">3456</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"NO ACTION"</span> +</span><span id="Parser-3457"><a href="#Parser-3457"><span class="linenos">3457</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CASCADE"</span><span class="p">):</span> +</span><span id="Parser-3458"><a href="#Parser-3458"><span class="linenos">3458</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"CASCADE"</span> +</span><span id="Parser-3459"><a href="#Parser-3459"><span class="linenos">3459</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">):</span> +</span><span id="Parser-3460"><a href="#Parser-3460"><span class="linenos">3460</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"SET NULL"</span> +</span><span id="Parser-3461"><a href="#Parser-3461"><span class="linenos">3461</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">):</span> +</span><span id="Parser-3462"><a href="#Parser-3462"><span class="linenos">3462</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"SET DEFAULT"</span> +</span><span id="Parser-3463"><a href="#Parser-3463"><span class="linenos">3463</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3464"><a href="#Parser-3464"><span class="linenos">3464</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Invalid key constraint"</span><span class="p">)</span> +</span><span id="Parser-3465"><a href="#Parser-3465"><span class="linenos">3465</span></a> +</span><span id="Parser-3466"><a href="#Parser-3466"><span class="linenos">3466</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"ON </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">action</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Parser-3467"><a href="#Parser-3467"><span class="linenos">3467</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NOT"</span><span class="p">,</span> <span class="s2">"ENFORCED"</span><span class="p">):</span> +</span><span id="Parser-3468"><a href="#Parser-3468"><span class="linenos">3468</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"NOT ENFORCED"</span><span class="p">)</span> +</span><span id="Parser-3469"><a href="#Parser-3469"><span class="linenos">3469</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"DEFERRABLE"</span><span class="p">):</span> +</span><span id="Parser-3470"><a href="#Parser-3470"><span class="linenos">3470</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"DEFERRABLE"</span><span class="p">)</span> +</span><span id="Parser-3471"><a href="#Parser-3471"><span class="linenos">3471</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"INITIALLY"</span><span class="p">,</span> <span class="s2">"DEFERRED"</span><span class="p">):</span> +</span><span id="Parser-3472"><a href="#Parser-3472"><span class="linenos">3472</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"INITIALLY DEFERRED"</span><span class="p">)</span> +</span><span id="Parser-3473"><a href="#Parser-3473"><span class="linenos">3473</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NORELY"</span><span class="p">):</span> +</span><span id="Parser-3474"><a href="#Parser-3474"><span class="linenos">3474</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"NORELY"</span><span class="p">)</span> +</span><span id="Parser-3475"><a href="#Parser-3475"><span class="linenos">3475</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MATCH"</span><span class="p">,</span> <span class="s2">"FULL"</span><span class="p">):</span> +</span><span id="Parser-3476"><a href="#Parser-3476"><span class="linenos">3476</span></a> <span class="n">options</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"MATCH FULL"</span><span class="p">)</span> +</span><span id="Parser-3477"><a href="#Parser-3477"><span class="linenos">3477</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3478"><a href="#Parser-3478"><span class="linenos">3478</span></a> <span class="k">break</span> +</span><span id="Parser-3479"><a href="#Parser-3479"><span class="linenos">3479</span></a> +</span><span id="Parser-3480"><a href="#Parser-3480"><span class="linenos">3480</span></a> <span class="k">return</span> <span class="n">options</span> </span><span id="Parser-3481"><a href="#Parser-3481"><span class="linenos">3481</span></a> -</span><span id="Parser-3482"><a href="#Parser-3482"><span class="linenos">3482</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-3483"><a href="#Parser-3483"><span class="linenos">3483</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="Parser-3484"><a href="#Parser-3484"><span class="linenos">3484</span></a> -</span><span id="Parser-3485"><a href="#Parser-3485"><span class="linenos">3485</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_PAREN</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="Parser-3486"><a href="#Parser-3486"><span class="linenos">3486</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_id_vars</span><span class="p">()</span> -</span><span id="Parser-3487"><a href="#Parser-3487"><span class="linenos">3487</span></a> -</span><span id="Parser-3488"><a href="#Parser-3488"><span class="linenos">3488</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_key_constraint_options</span><span class="p">()</span> -</span><span id="Parser-3489"><a href="#Parser-3489"><span class="linenos">3489</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">Reference</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="n">options</span><span class="p">)</span> -</span><span id="Parser-3490"><a href="#Parser-3490"><span class="linenos">3490</span></a> -</span><span id="Parser-3491"><a href="#Parser-3491"><span class="linenos">3491</span></a> <span class="k">def</span> <span class="nf">_parse_foreign_key</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">ForeignKey</span><span class="p">:</span> -</span><span id="Parser-3492"><a href="#Parser-3492"><span class="linenos">3492</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_id_vars</span><span class="p">()</span> -</span><span id="Parser-3493"><a href="#Parser-3493"><span class="linenos">3493</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_references</span><span class="p">()</span> -</span><span id="Parser-3494"><a href="#Parser-3494"><span class="linenos">3494</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Parser-3495"><a href="#Parser-3495"><span class="linenos">3495</span></a> -</span><span id="Parser-3496"><a href="#Parser-3496"><span class="linenos">3496</span></a> <span class="k">while</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">ON</span><span class="p">):</span> -</span><span id="Parser-3497"><a href="#Parser-3497"><span class="linenos">3497</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DELETE</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UPDATE</span><span class="p">)):</span> -</span><span id="Parser-3498"><a href="#Parser-3498"><span class="linenos">3498</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected DELETE or UPDATE"</span><span class="p">)</span> +</span><span id="Parser-3482"><a href="#Parser-3482"><span class="linenos">3482</span></a> <span class="k">def</span> <span class="nf">_parse_references</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">match</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-></span> <span class="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">Reference</span><span class="p">]:</span> +</span><span id="Parser-3483"><a href="#Parser-3483"><span class="linenos">3483</span></a> <span class="k">if</span> <span class="n">match</span> <span class="ow">and</span> <span class="ow">not</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">REFERENCES</span><span class="p">):</span> +</span><span id="Parser-3484"><a href="#Parser-3484"><span class="linenos">3484</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-3485"><a href="#Parser-3485"><span class="linenos">3485</span></a> +</span><span id="Parser-3486"><a href="#Parser-3486"><span class="linenos">3486</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-3487"><a href="#Parser-3487"><span class="linenos">3487</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="Parser-3488"><a href="#Parser-3488"><span class="linenos">3488</span></a> +</span><span id="Parser-3489"><a href="#Parser-3489"><span class="linenos">3489</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_PAREN</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="Parser-3490"><a href="#Parser-3490"><span class="linenos">3490</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_id_vars</span><span class="p">()</span> +</span><span id="Parser-3491"><a href="#Parser-3491"><span class="linenos">3491</span></a> +</span><span id="Parser-3492"><a href="#Parser-3492"><span class="linenos">3492</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_key_constraint_options</span><span class="p">()</span> +</span><span id="Parser-3493"><a href="#Parser-3493"><span class="linenos">3493</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">Reference</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="n">options</span><span class="p">)</span> +</span><span id="Parser-3494"><a href="#Parser-3494"><span class="linenos">3494</span></a> +</span><span id="Parser-3495"><a href="#Parser-3495"><span class="linenos">3495</span></a> <span class="k">def</span> <span class="nf">_parse_foreign_key</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">ForeignKey</span><span class="p">:</span> +</span><span id="Parser-3496"><a href="#Parser-3496"><span class="linenos">3496</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped_id_vars</span><span class="p">()</span> +</span><span id="Parser-3497"><a href="#Parser-3497"><span class="linenos">3497</span></a> <span class="n">reference</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_references</span><span class="p">()</span> +</span><span id="Parser-3498"><a href="#Parser-3498"><span class="linenos">3498</span></a> <span class="n">options</span> <span class="o">=</span> <span class="p">{}</span> </span><span id="Parser-3499"><a href="#Parser-3499"><span class="linenos">3499</span></a> -</span><span id="Parser-3500"><a href="#Parser-3500"><span class="linenos">3500</span></a> <span class="n">kind</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="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="Parser-3501"><a href="#Parser-3501"><span class="linenos">3501</span></a> -</span><span id="Parser-3502"><a href="#Parser-3502"><span class="linenos">3502</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"ACTION"</span><span class="p">):</span> -</span><span id="Parser-3503"><a href="#Parser-3503"><span class="linenos">3503</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"NO ACTION"</span> -</span><span id="Parser-3504"><a href="#Parser-3504"><span class="linenos">3504</span></a> <span class="k">elif</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">SET</span><span class="p">):</span> -</span><span id="Parser-3505"><a href="#Parser-3505"><span class="linenos">3505</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">))</span> -</span><span id="Parser-3506"><a href="#Parser-3506"><span class="linenos">3506</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"SET "</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="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Parser-3507"><a href="#Parser-3507"><span class="linenos">3507</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3508"><a href="#Parser-3508"><span class="linenos">3508</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Parser-3509"><a href="#Parser-3509"><span class="linenos">3509</span></a> <span class="n">action</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="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Parser-3510"><a href="#Parser-3510"><span class="linenos">3510</span></a> -</span><span id="Parser-3511"><a href="#Parser-3511"><span class="linenos">3511</span></a> <span class="n">options</span><span class="p">[</span><span class="n">kind</span><span class="p">]</span> <span class="o">=</span> <span class="n">action</span> -</span><span id="Parser-3512"><a href="#Parser-3512"><span class="linenos">3512</span></a> -</span><span id="Parser-3513"><a href="#Parser-3513"><span class="linenos">3513</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><span id="Parser-3514"><a href="#Parser-3514"><span class="linenos">3514</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">reference</span><span class="o">=</span><span class="n">reference</span><span class="p">,</span> <span class="o">**</span><span class="n">options</span> <span class="c1"># type: ignore</span> -</span><span id="Parser-3515"><a href="#Parser-3515"><span class="linenos">3515</span></a> <span class="p">)</span> +</span><span id="Parser-3500"><a href="#Parser-3500"><span class="linenos">3500</span></a> <span class="k">while</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">ON</span><span class="p">):</span> +</span><span id="Parser-3501"><a href="#Parser-3501"><span class="linenos">3501</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DELETE</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UPDATE</span><span class="p">)):</span> +</span><span id="Parser-3502"><a href="#Parser-3502"><span class="linenos">3502</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected DELETE or UPDATE"</span><span class="p">)</span> +</span><span id="Parser-3503"><a href="#Parser-3503"><span class="linenos">3503</span></a> +</span><span id="Parser-3504"><a href="#Parser-3504"><span class="linenos">3504</span></a> <span class="n">kind</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="o">.</span><span class="n">lower</span><span class="p">()</span> +</span><span id="Parser-3505"><a href="#Parser-3505"><span class="linenos">3505</span></a> +</span><span id="Parser-3506"><a href="#Parser-3506"><span class="linenos">3506</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">,</span> <span class="s2">"ACTION"</span><span class="p">):</span> +</span><span id="Parser-3507"><a href="#Parser-3507"><span class="linenos">3507</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"NO ACTION"</span> +</span><span id="Parser-3508"><a href="#Parser-3508"><span class="linenos">3508</span></a> <span class="k">elif</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">SET</span><span class="p">):</span> +</span><span id="Parser-3509"><a href="#Parser-3509"><span class="linenos">3509</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">))</span> +</span><span id="Parser-3510"><a href="#Parser-3510"><span class="linenos">3510</span></a> <span class="n">action</span> <span class="o">=</span> <span class="s2">"SET "</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="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Parser-3511"><a href="#Parser-3511"><span class="linenos">3511</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3512"><a href="#Parser-3512"><span class="linenos">3512</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Parser-3513"><a href="#Parser-3513"><span class="linenos">3513</span></a> <span class="n">action</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="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Parser-3514"><a href="#Parser-3514"><span class="linenos">3514</span></a> +</span><span id="Parser-3515"><a href="#Parser-3515"><span class="linenos">3515</span></a> <span class="n">options</span><span class="p">[</span><span class="n">kind</span><span class="p">]</span> <span class="o">=</span> <span class="n">action</span> </span><span id="Parser-3516"><a href="#Parser-3516"><span class="linenos">3516</span></a> -</span><span id="Parser-3517"><a href="#Parser-3517"><span class="linenos">3517</span></a> <span class="k">def</span> <span class="nf">_parse_primary_key</span><span class="p">(</span> -</span><span id="Parser-3518"><a href="#Parser-3518"><span class="linenos">3518</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">wrapped_optional</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="n">in_props</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-3519"><a href="#Parser-3519"><span class="linenos">3519</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKeyColumnConstraint</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKey</span><span class="p">:</span> -</span><span id="Parser-3520"><a href="#Parser-3520"><span class="linenos">3520</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Parser-3521"><a href="#Parser-3521"><span class="linenos">3521</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ASC</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DESC</span><span class="p">))</span> -</span><span id="Parser-3522"><a href="#Parser-3522"><span class="linenos">3522</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DESC</span> -</span><span id="Parser-3523"><a href="#Parser-3523"><span class="linenos">3523</span></a> <span class="p">)</span> -</span><span id="Parser-3524"><a href="#Parser-3524"><span class="linenos">3524</span></a> -</span><span id="Parser-3525"><a href="#Parser-3525"><span class="linenos">3525</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">in_props</span> <span class="ow">and</span> <span class="ow">not</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_PAREN</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="Parser-3526"><a href="#Parser-3526"><span class="linenos">3526</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">PrimaryKeyColumnConstraint</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="n">desc</span><span class="p">)</span> -</span><span id="Parser-3527"><a href="#Parser-3527"><span class="linenos">3527</span></a> -</span><span id="Parser-3528"><a href="#Parser-3528"><span class="linenos">3528</span></a> <span class="n">expressions</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_field</span><span class="p">,</span> <span class="n">optional</span><span class="o">=</span><span class="n">wrapped_optional</span><span class="p">)</span> -</span><span id="Parser-3529"><a href="#Parser-3529"><span class="linenos">3529</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_key_constraint_options</span><span class="p">()</span> -</span><span id="Parser-3530"><a href="#Parser-3530"><span class="linenos">3530</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">PrimaryKey</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="n">options</span><span class="p">)</span> +</span><span id="Parser-3517"><a href="#Parser-3517"><span class="linenos">3517</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><span id="Parser-3518"><a href="#Parser-3518"><span class="linenos">3518</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">reference</span><span class="o">=</span><span class="n">reference</span><span class="p">,</span> <span class="o">**</span><span class="n">options</span> <span class="c1"># type: ignore</span> +</span><span id="Parser-3519"><a href="#Parser-3519"><span class="linenos">3519</span></a> <span class="p">)</span> +</span><span id="Parser-3520"><a href="#Parser-3520"><span class="linenos">3520</span></a> +</span><span id="Parser-3521"><a href="#Parser-3521"><span class="linenos">3521</span></a> <span class="k">def</span> <span class="nf">_parse_primary_key</span><span class="p">(</span> +</span><span id="Parser-3522"><a href="#Parser-3522"><span class="linenos">3522</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">wrapped_optional</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="n">in_props</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-3523"><a href="#Parser-3523"><span class="linenos">3523</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKeyColumnConstraint</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">PrimaryKey</span><span class="p">:</span> +</span><span id="Parser-3524"><a href="#Parser-3524"><span class="linenos">3524</span></a> <span class="n">desc</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Parser-3525"><a href="#Parser-3525"><span class="linenos">3525</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ASC</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DESC</span><span class="p">))</span> +</span><span id="Parser-3526"><a href="#Parser-3526"><span class="linenos">3526</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DESC</span> +</span><span id="Parser-3527"><a href="#Parser-3527"><span class="linenos">3527</span></a> <span class="p">)</span> +</span><span id="Parser-3528"><a href="#Parser-3528"><span class="linenos">3528</span></a> +</span><span id="Parser-3529"><a href="#Parser-3529"><span class="linenos">3529</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">in_props</span> <span class="ow">and</span> <span class="ow">not</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_PAREN</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="Parser-3530"><a href="#Parser-3530"><span class="linenos">3530</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">PrimaryKeyColumnConstraint</span><span class="p">,</span> <span class="n">desc</span><span class="o">=</span><span class="n">desc</span><span class="p">)</span> </span><span id="Parser-3531"><a href="#Parser-3531"><span class="linenos">3531</span></a> -</span><span id="Parser-3532"><a href="#Parser-3532"><span class="linenos">3532</span></a> <span class="k">def</span> <span class="nf">_parse_bracket</span><span class="p">(</span><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="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="Parser-3533"><a href="#Parser-3533"><span class="linenos">3533</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</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><span id="Parser-3534"><a href="#Parser-3534"><span class="linenos">3534</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-3532"><a href="#Parser-3532"><span class="linenos">3532</span></a> <span class="n">expressions</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_field</span><span class="p">,</span> <span class="n">optional</span><span class="o">=</span><span class="n">wrapped_optional</span><span class="p">)</span> +</span><span id="Parser-3533"><a href="#Parser-3533"><span class="linenos">3533</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_key_constraint_options</span><span class="p">()</span> +</span><span id="Parser-3534"><a href="#Parser-3534"><span class="linenos">3534</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">PrimaryKey</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="n">options</span><span class="p">)</span> </span><span id="Parser-3535"><a href="#Parser-3535"><span class="linenos">3535</span></a> -</span><span id="Parser-3536"><a href="#Parser-3536"><span class="linenos">3536</span></a> <span class="n">bracket_kind</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">token_type</span> -</span><span id="Parser-3537"><a href="#Parser-3537"><span class="linenos">3537</span></a> -</span><span id="Parser-3538"><a href="#Parser-3538"><span class="linenos">3538</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">COLON</span><span class="p">):</span> -</span><span id="Parser-3539"><a href="#Parser-3539"><span class="linenos">3539</span></a> <span class="n">expressions</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">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="p">[</span> -</span><span id="Parser-3540"><a href="#Parser-3540"><span class="linenos">3540</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">Slice</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">())</span> -</span><span id="Parser-3541"><a href="#Parser-3541"><span class="linenos">3541</span></a> <span class="p">]</span> -</span><span id="Parser-3542"><a href="#Parser-3542"><span class="linenos">3542</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3543"><a href="#Parser-3543"><span class="linenos">3543</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_slice</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()))</span> -</span><span id="Parser-3544"><a href="#Parser-3544"><span class="linenos">3544</span></a> -</span><span id="Parser-3545"><a href="#Parser-3545"><span class="linenos">3545</span></a> <span class="c1"># https://duckdb.org/docs/sql/data_types/struct.html#creating-structs</span> -</span><span id="Parser-3546"><a href="#Parser-3546"><span class="linenos">3546</span></a> <span class="k">if</span> <span class="n">bracket_kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACE</span><span class="p">:</span> -</span><span id="Parser-3547"><a href="#Parser-3547"><span class="linenos">3547</span></a> <span class="n">this</span> <span class="o">=</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">Struct</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Parser-3548"><a href="#Parser-3548"><span class="linenos">3548</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">this</span> <span class="ow">or</span> <span class="n">this</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">"ARRAY"</span><span class="p">:</span> -</span><span id="Parser-3549"><a href="#Parser-3549"><span class="linenos">3549</span></a> <span class="n">this</span> <span class="o">=</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">Array</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Parser-3550"><a href="#Parser-3550"><span class="linenos">3550</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3551"><a href="#Parser-3551"><span class="linenos">3551</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">apply_index_offset</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="p">,</span> <span class="o">-</span><span class="bp">self</span><span class="o">.</span><span class="n">INDEX_OFFSET</span><span class="p">)</span> -</span><span id="Parser-3552"><a href="#Parser-3552"><span class="linenos">3552</span></a> <span class="n">this</span> <span class="o">=</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">Bracket</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Parser-3553"><a href="#Parser-3553"><span class="linenos">3553</span></a> -</span><span id="Parser-3554"><a href="#Parser-3554"><span class="linenos">3554</span></a> <span class="k">if</span> <span class="ow">not</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">R_BRACKET</span><span class="p">)</span> <span class="ow">and</span> <span class="n">bracket_kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">:</span> -</span><span id="Parser-3555"><a href="#Parser-3555"><span class="linenos">3555</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected ]"</span><span class="p">)</span> -</span><span id="Parser-3556"><a href="#Parser-3556"><span class="linenos">3556</span></a> <span class="k">elif</span> <span class="ow">not</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">R_BRACE</span><span class="p">)</span> <span class="ow">and</span> <span class="n">bracket_kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACE</span><span class="p">:</span> -</span><span id="Parser-3557"><a href="#Parser-3557"><span class="linenos">3557</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected }"</span><span class="p">)</span> -</span><span id="Parser-3558"><a href="#Parser-3558"><span class="linenos">3558</span></a> -</span><span id="Parser-3559"><a href="#Parser-3559"><span class="linenos">3559</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add_comments</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-3560"><a href="#Parser-3560"><span class="linenos">3560</span></a> <span class="k">return</span> <span class="bp">self</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="Parser-3561"><a href="#Parser-3561"><span class="linenos">3561</span></a> -</span><span id="Parser-3562"><a href="#Parser-3562"><span class="linenos">3562</span></a> <span class="k">def</span> <span class="nf">_parse_slice</span><span class="p">(</span><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="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="Parser-3563"><a href="#Parser-3563"><span class="linenos">3563</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">COLON</span><span class="p">):</span> -</span><span id="Parser-3564"><a href="#Parser-3564"><span class="linenos">3564</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">Slice</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">())</span> -</span><span id="Parser-3565"><a href="#Parser-3565"><span class="linenos">3565</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-3566"><a href="#Parser-3566"><span class="linenos">3566</span></a> -</span><span id="Parser-3567"><a href="#Parser-3567"><span class="linenos">3567</span></a> <span class="k">def</span> <span class="nf">_parse_case</span><span class="p">(</span><span class="bp">self</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="Parser-3568"><a href="#Parser-3568"><span class="linenos">3568</span></a> <span class="n">ifs</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-3569"><a href="#Parser-3569"><span class="linenos">3569</span></a> <span class="n">default</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-3536"><a href="#Parser-3536"><span class="linenos">3536</span></a> <span class="k">def</span> <span class="nf">_parse_bracket</span><span class="p">(</span><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="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="Parser-3537"><a href="#Parser-3537"><span class="linenos">3537</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</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><span id="Parser-3538"><a href="#Parser-3538"><span class="linenos">3538</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-3539"><a href="#Parser-3539"><span class="linenos">3539</span></a> +</span><span id="Parser-3540"><a href="#Parser-3540"><span class="linenos">3540</span></a> <span class="n">bracket_kind</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">token_type</span> +</span><span id="Parser-3541"><a href="#Parser-3541"><span class="linenos">3541</span></a> +</span><span id="Parser-3542"><a href="#Parser-3542"><span class="linenos">3542</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">COLON</span><span class="p">):</span> +</span><span id="Parser-3543"><a href="#Parser-3543"><span class="linenos">3543</span></a> <span class="n">expressions</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">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="p">[</span> +</span><span id="Parser-3544"><a href="#Parser-3544"><span class="linenos">3544</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">Slice</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">())</span> +</span><span id="Parser-3545"><a href="#Parser-3545"><span class="linenos">3545</span></a> <span class="p">]</span> +</span><span id="Parser-3546"><a href="#Parser-3546"><span class="linenos">3546</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3547"><a href="#Parser-3547"><span class="linenos">3547</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_slice</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()))</span> +</span><span id="Parser-3548"><a href="#Parser-3548"><span class="linenos">3548</span></a> +</span><span id="Parser-3549"><a href="#Parser-3549"><span class="linenos">3549</span></a> <span class="c1"># https://duckdb.org/docs/sql/data_types/struct.html#creating-structs</span> +</span><span id="Parser-3550"><a href="#Parser-3550"><span class="linenos">3550</span></a> <span class="k">if</span> <span class="n">bracket_kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACE</span><span class="p">:</span> +</span><span id="Parser-3551"><a href="#Parser-3551"><span class="linenos">3551</span></a> <span class="n">this</span> <span class="o">=</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">Struct</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Parser-3552"><a href="#Parser-3552"><span class="linenos">3552</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">this</span> <span class="ow">or</span> <span class="n">this</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">"ARRAY"</span><span class="p">:</span> +</span><span id="Parser-3553"><a href="#Parser-3553"><span class="linenos">3553</span></a> <span class="n">this</span> <span class="o">=</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">Array</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Parser-3554"><a href="#Parser-3554"><span class="linenos">3554</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3555"><a href="#Parser-3555"><span class="linenos">3555</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="n">apply_index_offset</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="p">,</span> <span class="o">-</span><span class="bp">self</span><span class="o">.</span><span class="n">INDEX_OFFSET</span><span class="p">)</span> +</span><span id="Parser-3556"><a href="#Parser-3556"><span class="linenos">3556</span></a> <span class="n">this</span> <span class="o">=</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">Bracket</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Parser-3557"><a href="#Parser-3557"><span class="linenos">3557</span></a> +</span><span id="Parser-3558"><a href="#Parser-3558"><span class="linenos">3558</span></a> <span class="k">if</span> <span class="ow">not</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">R_BRACKET</span><span class="p">)</span> <span class="ow">and</span> <span class="n">bracket_kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">:</span> +</span><span id="Parser-3559"><a href="#Parser-3559"><span class="linenos">3559</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected ]"</span><span class="p">)</span> +</span><span id="Parser-3560"><a href="#Parser-3560"><span class="linenos">3560</span></a> <span class="k">elif</span> <span class="ow">not</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">R_BRACE</span><span class="p">)</span> <span class="ow">and</span> <span class="n">bracket_kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACE</span><span class="p">:</span> +</span><span id="Parser-3561"><a href="#Parser-3561"><span class="linenos">3561</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected }"</span><span class="p">)</span> +</span><span id="Parser-3562"><a href="#Parser-3562"><span class="linenos">3562</span></a> +</span><span id="Parser-3563"><a href="#Parser-3563"><span class="linenos">3563</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add_comments</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-3564"><a href="#Parser-3564"><span class="linenos">3564</span></a> <span class="k">return</span> <span class="bp">self</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="Parser-3565"><a href="#Parser-3565"><span class="linenos">3565</span></a> +</span><span id="Parser-3566"><a href="#Parser-3566"><span class="linenos">3566</span></a> <span class="k">def</span> <span class="nf">_parse_slice</span><span class="p">(</span><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="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="Parser-3567"><a href="#Parser-3567"><span class="linenos">3567</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">COLON</span><span class="p">):</span> +</span><span id="Parser-3568"><a href="#Parser-3568"><span class="linenos">3568</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">Slice</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">())</span> +</span><span id="Parser-3569"><a href="#Parser-3569"><span class="linenos">3569</span></a> <span class="k">return</span> <span class="n">this</span> </span><span id="Parser-3570"><a href="#Parser-3570"><span class="linenos">3570</span></a> -</span><span id="Parser-3571"><a href="#Parser-3571"><span class="linenos">3571</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="Parser-3572"><a href="#Parser-3572"><span class="linenos">3572</span></a> -</span><span id="Parser-3573"><a href="#Parser-3573"><span class="linenos">3573</span></a> <span class="k">while</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">WHEN</span><span class="p">):</span> -</span><span id="Parser-3574"><a href="#Parser-3574"><span class="linenos">3574</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="Parser-3575"><a href="#Parser-3575"><span class="linenos">3575</span></a> <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">THEN</span><span class="p">)</span> -</span><span id="Parser-3576"><a href="#Parser-3576"><span class="linenos">3576</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="Parser-3577"><a href="#Parser-3577"><span class="linenos">3577</span></a> <span class="n">ifs</span><span class="o">.</span><span class="n">append</span><span class="p">(</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">If</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">true</span><span class="o">=</span><span class="n">then</span><span class="p">))</span> -</span><span id="Parser-3578"><a href="#Parser-3578"><span class="linenos">3578</span></a> -</span><span id="Parser-3579"><a href="#Parser-3579"><span class="linenos">3579</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">ELSE</span><span class="p">):</span> -</span><span id="Parser-3580"><a href="#Parser-3580"><span class="linenos">3580</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="Parser-3581"><a href="#Parser-3581"><span class="linenos">3581</span></a> -</span><span id="Parser-3582"><a href="#Parser-3582"><span class="linenos">3582</span></a> <span class="k">if</span> <span class="ow">not</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">END</span><span class="p">):</span> -</span><span id="Parser-3583"><a href="#Parser-3583"><span class="linenos">3583</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected END after CASE"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> -</span><span id="Parser-3584"><a href="#Parser-3584"><span class="linenos">3584</span></a> -</span><span id="Parser-3585"><a href="#Parser-3585"><span class="linenos">3585</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window</span><span class="p">(</span> -</span><span id="Parser-3586"><a href="#Parser-3586"><span class="linenos">3586</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">Case</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">ifs</span><span class="o">=</span><span class="n">ifs</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">default</span><span class="p">)</span> -</span><span id="Parser-3587"><a href="#Parser-3587"><span class="linenos">3587</span></a> <span class="p">)</span> +</span><span id="Parser-3571"><a href="#Parser-3571"><span class="linenos">3571</span></a> <span class="k">def</span> <span class="nf">_parse_case</span><span class="p">(</span><span class="bp">self</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="Parser-3572"><a href="#Parser-3572"><span class="linenos">3572</span></a> <span class="n">ifs</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-3573"><a href="#Parser-3573"><span class="linenos">3573</span></a> <span class="n">default</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-3574"><a href="#Parser-3574"><span class="linenos">3574</span></a> +</span><span id="Parser-3575"><a href="#Parser-3575"><span class="linenos">3575</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="Parser-3576"><a href="#Parser-3576"><span class="linenos">3576</span></a> +</span><span id="Parser-3577"><a href="#Parser-3577"><span class="linenos">3577</span></a> <span class="k">while</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">WHEN</span><span class="p">):</span> +</span><span id="Parser-3578"><a href="#Parser-3578"><span class="linenos">3578</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="Parser-3579"><a href="#Parser-3579"><span class="linenos">3579</span></a> <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">THEN</span><span class="p">)</span> +</span><span id="Parser-3580"><a href="#Parser-3580"><span class="linenos">3580</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="Parser-3581"><a href="#Parser-3581"><span class="linenos">3581</span></a> <span class="n">ifs</span><span class="o">.</span><span class="n">append</span><span class="p">(</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">If</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">true</span><span class="o">=</span><span class="n">then</span><span class="p">))</span> +</span><span id="Parser-3582"><a href="#Parser-3582"><span class="linenos">3582</span></a> +</span><span id="Parser-3583"><a href="#Parser-3583"><span class="linenos">3583</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">ELSE</span><span class="p">):</span> +</span><span id="Parser-3584"><a href="#Parser-3584"><span class="linenos">3584</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="Parser-3585"><a href="#Parser-3585"><span class="linenos">3585</span></a> +</span><span id="Parser-3586"><a href="#Parser-3586"><span class="linenos">3586</span></a> <span class="k">if</span> <span class="ow">not</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">END</span><span class="p">):</span> +</span><span id="Parser-3587"><a href="#Parser-3587"><span class="linenos">3587</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected END after CASE"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> </span><span id="Parser-3588"><a href="#Parser-3588"><span class="linenos">3588</span></a> -</span><span id="Parser-3589"><a href="#Parser-3589"><span class="linenos">3589</span></a> <span class="k">def</span> <span class="nf">_parse_if</span><span class="p">(</span><span class="bp">self</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="Parser-3590"><a href="#Parser-3590"><span class="linenos">3590</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_PAREN</span><span class="p">):</span> -</span><span id="Parser-3591"><a href="#Parser-3591"><span class="linenos">3591</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="Parser-3592"><a href="#Parser-3592"><span class="linenos">3592</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="n">args</span><span class="p">)</span> -</span><span id="Parser-3593"><a href="#Parser-3593"><span class="linenos">3593</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="Parser-3594"><a href="#Parser-3594"><span class="linenos">3594</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3595"><a href="#Parser-3595"><span class="linenos">3595</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span> -</span><span id="Parser-3596"><a href="#Parser-3596"><span class="linenos">3596</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="Parser-3597"><a href="#Parser-3597"><span class="linenos">3597</span></a> -</span><span id="Parser-3598"><a href="#Parser-3598"><span class="linenos">3598</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">condition</span><span class="p">:</span> -</span><span id="Parser-3599"><a href="#Parser-3599"><span class="linenos">3599</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-3600"><a href="#Parser-3600"><span class="linenos">3600</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-3589"><a href="#Parser-3589"><span class="linenos">3589</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window</span><span class="p">(</span> +</span><span id="Parser-3590"><a href="#Parser-3590"><span class="linenos">3590</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">Case</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">ifs</span><span class="o">=</span><span class="n">ifs</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">default</span><span class="p">)</span> +</span><span id="Parser-3591"><a href="#Parser-3591"><span class="linenos">3591</span></a> <span class="p">)</span> +</span><span id="Parser-3592"><a href="#Parser-3592"><span class="linenos">3592</span></a> +</span><span id="Parser-3593"><a href="#Parser-3593"><span class="linenos">3593</span></a> <span class="k">def</span> <span class="nf">_parse_if</span><span class="p">(</span><span class="bp">self</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="Parser-3594"><a href="#Parser-3594"><span class="linenos">3594</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_PAREN</span><span class="p">):</span> +</span><span id="Parser-3595"><a href="#Parser-3595"><span class="linenos">3595</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="Parser-3596"><a href="#Parser-3596"><span class="linenos">3596</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="n">args</span><span class="p">)</span> +</span><span id="Parser-3597"><a href="#Parser-3597"><span class="linenos">3597</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-3598"><a href="#Parser-3598"><span class="linenos">3598</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3599"><a href="#Parser-3599"><span class="linenos">3599</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span> +</span><span id="Parser-3600"><a href="#Parser-3600"><span class="linenos">3600</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> </span><span id="Parser-3601"><a href="#Parser-3601"><span class="linenos">3601</span></a> -</span><span id="Parser-3602"><a href="#Parser-3602"><span class="linenos">3602</span></a> <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">THEN</span><span class="p">)</span> -</span><span id="Parser-3603"><a href="#Parser-3603"><span class="linenos">3603</span></a> <span class="n">true</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="Parser-3604"><a href="#Parser-3604"><span class="linenos">3604</span></a> <span class="n">false</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> <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">ELSE</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="Parser-3605"><a href="#Parser-3605"><span class="linenos">3605</span></a> <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">END</span><span class="p">)</span> -</span><span id="Parser-3606"><a href="#Parser-3606"><span class="linenos">3606</span></a> <span class="n">this</span> <span class="o">=</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">If</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">condition</span><span class="p">,</span> <span class="n">true</span><span class="o">=</span><span class="n">true</span><span class="p">,</span> <span class="n">false</span><span class="o">=</span><span class="n">false</span><span class="p">)</span> -</span><span id="Parser-3607"><a href="#Parser-3607"><span class="linenos">3607</span></a> -</span><span id="Parser-3608"><a href="#Parser-3608"><span class="linenos">3608</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-3609"><a href="#Parser-3609"><span class="linenos">3609</span></a> -</span><span id="Parser-3610"><a href="#Parser-3610"><span class="linenos">3610</span></a> <span class="k">def</span> <span class="nf">_parse_extract</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">Extract</span><span class="p">:</span> -</span><span id="Parser-3611"><a href="#Parser-3611"><span class="linenos">3611</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">()</span> -</span><span id="Parser-3612"><a href="#Parser-3612"><span class="linenos">3612</span></a> -</span><span id="Parser-3613"><a href="#Parser-3613"><span class="linenos">3613</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">FROM</span><span class="p">):</span> -</span><span id="Parser-3614"><a href="#Parser-3614"><span class="linenos">3614</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">Extract</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> -</span><span id="Parser-3615"><a href="#Parser-3615"><span class="linenos">3615</span></a> -</span><span id="Parser-3616"><a href="#Parser-3616"><span class="linenos">3616</span></a> <span class="k">if</span> <span class="ow">not</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">COMMA</span><span class="p">):</span> -</span><span id="Parser-3617"><a href="#Parser-3617"><span class="linenos">3617</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected FROM or comma after EXTRACT"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> -</span><span id="Parser-3618"><a href="#Parser-3618"><span class="linenos">3618</span></a> -</span><span id="Parser-3619"><a href="#Parser-3619"><span class="linenos">3619</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">Extract</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> -</span><span id="Parser-3620"><a href="#Parser-3620"><span class="linenos">3620</span></a> -</span><span id="Parser-3621"><a href="#Parser-3621"><span class="linenos">3621</span></a> <span class="k">def</span> <span class="nf">_parse_cast</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">strict</span><span class="p">:</span> <span class="nb">bool</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="Parser-3622"><a href="#Parser-3622"><span class="linenos">3622</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="Parser-3623"><a href="#Parser-3623"><span class="linenos">3623</span></a> -</span><span id="Parser-3624"><a href="#Parser-3624"><span class="linenos">3624</span></a> <span class="k">if</span> <span class="ow">not</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">ALIAS</span><span class="p">):</span> -</span><span id="Parser-3625"><a href="#Parser-3625"><span class="linenos">3625</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">COMMA</span><span class="p">):</span> -</span><span id="Parser-3626"><a href="#Parser-3626"><span class="linenos">3626</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><span id="Parser-3627"><a href="#Parser-3627"><span class="linenos">3627</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CastToStrType</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="Parser-3628"><a href="#Parser-3628"><span class="linenos">3628</span></a> <span class="p">)</span> -</span><span id="Parser-3629"><a href="#Parser-3629"><span class="linenos">3629</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3630"><a href="#Parser-3630"><span class="linenos">3630</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected AS after CAST"</span><span class="p">)</span> -</span><span id="Parser-3631"><a href="#Parser-3631"><span class="linenos">3631</span></a> -</span><span id="Parser-3632"><a href="#Parser-3632"><span class="linenos">3632</span></a> <span class="n">to</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">()</span> -</span><span id="Parser-3633"><a href="#Parser-3633"><span class="linenos">3633</span></a> -</span><span id="Parser-3634"><a href="#Parser-3634"><span class="linenos">3634</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">to</span><span class="p">:</span> -</span><span id="Parser-3635"><a href="#Parser-3635"><span class="linenos">3635</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected TYPE after CAST"</span><span class="p">)</span> -</span><span id="Parser-3636"><a href="#Parser-3636"><span class="linenos">3636</span></a> <span class="k">elif</span> <span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">CHAR</span><span class="p">:</span> -</span><span id="Parser-3637"><a href="#Parser-3637"><span class="linenos">3637</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">CHARACTER_SET</span><span class="p">):</span> -</span><span id="Parser-3638"><a href="#Parser-3638"><span class="linenos">3638</span></a> <span class="n">to</span> <span class="o">=</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">CharacterSet</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_var_or_string</span><span class="p">())</span> -</span><span id="Parser-3639"><a href="#Parser-3639"><span class="linenos">3639</span></a> <span class="k">elif</span> <span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEMPORAL_TYPES</span> <span class="ow">and</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">FORMAT</span><span class="p">):</span> -</span><span id="Parser-3640"><a href="#Parser-3640"><span class="linenos">3640</span></a> <span class="n">fmt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="Parser-3641"><a href="#Parser-3641"><span class="linenos">3641</span></a> -</span><span id="Parser-3642"><a href="#Parser-3642"><span class="linenos">3642</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><span id="Parser-3643"><a href="#Parser-3643"><span class="linenos">3643</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span> <span class="k">if</span> <span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATE</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">,</span> -</span><span id="Parser-3644"><a href="#Parser-3644"><span class="linenos">3644</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="Parser-3645"><a href="#Parser-3645"><span class="linenos">3645</span></a> <span class="nb">format</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><span id="Parser-3646"><a href="#Parser-3646"><span class="linenos">3646</span></a> <span class="n">format_time</span><span class="p">(</span> -</span><span id="Parser-3647"><a href="#Parser-3647"><span class="linenos">3647</span></a> <span class="n">fmt</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">fmt</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="Parser-3648"><a href="#Parser-3648"><span class="linenos">3648</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">FORMAT_MAPPING</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> -</span><span id="Parser-3649"><a href="#Parser-3649"><span class="linenos">3649</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">FORMAT_TRIE</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_TRIE</span><span class="p">,</span> -</span><span id="Parser-3650"><a href="#Parser-3650"><span class="linenos">3650</span></a> <span class="p">)</span> -</span><span id="Parser-3651"><a href="#Parser-3651"><span class="linenos">3651</span></a> <span class="p">),</span> -</span><span id="Parser-3652"><a href="#Parser-3652"><span class="linenos">3652</span></a> <span class="p">)</span> -</span><span id="Parser-3653"><a href="#Parser-3653"><span class="linenos">3653</span></a> -</span><span id="Parser-3654"><a href="#Parser-3654"><span class="linenos">3654</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">Cast</span> <span class="k">if</span> <span class="n">strict</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="n">to</span><span class="p">)</span> -</span><span id="Parser-3655"><a href="#Parser-3655"><span class="linenos">3655</span></a> -</span><span id="Parser-3656"><a href="#Parser-3656"><span class="linenos">3656</span></a> <span class="k">def</span> <span class="nf">_parse_concat</span><span class="p">(</span><span class="bp">self</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="Parser-3657"><a href="#Parser-3657"><span class="linenos">3657</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="Parser-3658"><a href="#Parser-3658"><span class="linenos">3658</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONCAT_NULL_OUTPUTS_STRING</span><span class="p">:</span> -</span><span id="Parser-3659"><a href="#Parser-3659"><span class="linenos">3659</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"COALESCE"</span><span class="p">,</span> <span class="n">arg</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">))</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">]</span> -</span><span id="Parser-3660"><a href="#Parser-3660"><span class="linenos">3660</span></a> -</span><span id="Parser-3661"><a href="#Parser-3661"><span class="linenos">3661</span></a> <span class="c1"># Some dialects (e.g. Trino) don't allow a single-argument CONCAT call, so when</span> -</span><span id="Parser-3662"><a href="#Parser-3662"><span class="linenos">3662</span></a> <span class="c1"># we find such a call we replace it with its argument.</span> -</span><span id="Parser-3663"><a href="#Parser-3663"><span class="linenos">3663</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Parser-3664"><a href="#Parser-3664"><span class="linenos">3664</span></a> <span class="k">return</span> <span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> -</span><span id="Parser-3665"><a href="#Parser-3665"><span class="linenos">3665</span></a> -</span><span id="Parser-3666"><a href="#Parser-3666"><span class="linenos">3666</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><span id="Parser-3667"><a href="#Parser-3667"><span class="linenos">3667</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">args</span> -</span><span id="Parser-3668"><a href="#Parser-3668"><span class="linenos">3668</span></a> <span class="p">)</span> -</span><span id="Parser-3669"><a href="#Parser-3669"><span class="linenos">3669</span></a> -</span><span id="Parser-3670"><a href="#Parser-3670"><span class="linenos">3670</span></a> <span class="k">def</span> <span class="nf">_parse_string_agg</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">Expression</span><span class="p">:</span> -</span><span id="Parser-3671"><a href="#Parser-3671"><span class="linenos">3671</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> -</span><span id="Parser-3672"><a href="#Parser-3672"><span class="linenos">3672</span></a> -</span><span id="Parser-3673"><a href="#Parser-3673"><span class="linenos">3673</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">DISTINCT</span><span class="p">):</span> -</span><span id="Parser-3674"><a href="#Parser-3674"><span class="linenos">3674</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="Parser-3675"><a href="#Parser-3675"><span class="linenos">3675</span></a> <span class="n">expression</span> <span class="o">=</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">Distinct</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</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="Parser-3676"><a href="#Parser-3676"><span class="linenos">3676</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3677"><a href="#Parser-3677"><span class="linenos">3677</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="Parser-3678"><a href="#Parser-3678"><span class="linenos">3678</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">0</span><span class="p">)</span> -</span><span id="Parser-3679"><a href="#Parser-3679"><span class="linenos">3679</span></a> -</span><span id="Parser-3680"><a href="#Parser-3680"><span class="linenos">3680</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="Parser-3681"><a href="#Parser-3681"><span class="linenos">3681</span></a> <span class="k">if</span> <span class="ow">not</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">R_PAREN</span><span class="p">):</span> -</span><span id="Parser-3682"><a href="#Parser-3682"><span class="linenos">3682</span></a> <span class="c1"># postgres: STRING_AGG([DISTINCT] expression, separator [ORDER BY expression1 {ASC | DESC} [, ...]])</span> -</span><span id="Parser-3683"><a href="#Parser-3683"><span class="linenos">3683</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Parser-3684"><a href="#Parser-3684"><span class="linenos">3684</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">GroupConcat</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">order</span><span class="p">,</span> <span class="n">separator</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="Parser-3685"><a href="#Parser-3685"><span class="linenos">3685</span></a> -</span><span id="Parser-3686"><a href="#Parser-3686"><span class="linenos">3686</span></a> <span class="c1"># Checks if we can parse an order clause: WITHIN GROUP (ORDER BY <order_by_expression_list> [ASC | DESC]).</span> -</span><span id="Parser-3687"><a href="#Parser-3687"><span class="linenos">3687</span></a> <span class="c1"># This is done "manually", instead of letting _parse_window parse it into an exp.WithinGroup node, so that</span> -</span><span id="Parser-3688"><a href="#Parser-3688"><span class="linenos">3688</span></a> <span class="c1"># the STRING_AGG call is parsed like in MySQL / SQLite and can thus be transpiled more easily to them.</span> -</span><span id="Parser-3689"><a href="#Parser-3689"><span class="linenos">3689</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITHIN"</span><span class="p">,</span> <span class="s2">"GROUP"</span><span class="p">):</span> -</span><span id="Parser-3690"><a href="#Parser-3690"><span class="linenos">3690</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-3691"><a href="#Parser-3691"><span class="linenos">3691</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="n">args</span><span class="p">)</span> -</span><span id="Parser-3692"><a href="#Parser-3692"><span class="linenos">3692</span></a> -</span><span id="Parser-3693"><a href="#Parser-3693"><span class="linenos">3693</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> <span class="c1"># The corresponding match_r_paren will be called in parse_function (caller)</span> -</span><span id="Parser-3694"><a href="#Parser-3694"><span class="linenos">3694</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Parser-3695"><a href="#Parser-3695"><span class="linenos">3695</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">GroupConcat</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">order</span><span class="p">,</span> <span class="n">separator</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="Parser-3696"><a href="#Parser-3696"><span class="linenos">3696</span></a> -</span><span id="Parser-3697"><a href="#Parser-3697"><span class="linenos">3697</span></a> <span class="k">def</span> <span class="nf">_parse_convert</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">strict</span><span class="p">:</span> <span class="nb">bool</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="Parser-3698"><a href="#Parser-3698"><span class="linenos">3698</span></a> <span class="n">to</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><span id="Parser-3699"><a href="#Parser-3699"><span class="linenos">3699</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="Parser-3602"><a href="#Parser-3602"><span class="linenos">3602</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">condition</span><span class="p">:</span> +</span><span id="Parser-3603"><a href="#Parser-3603"><span class="linenos">3603</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-3604"><a href="#Parser-3604"><span class="linenos">3604</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-3605"><a href="#Parser-3605"><span class="linenos">3605</span></a> +</span><span id="Parser-3606"><a href="#Parser-3606"><span class="linenos">3606</span></a> <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">THEN</span><span class="p">)</span> +</span><span id="Parser-3607"><a href="#Parser-3607"><span class="linenos">3607</span></a> <span class="n">true</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="Parser-3608"><a href="#Parser-3608"><span class="linenos">3608</span></a> <span class="n">false</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> <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">ELSE</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="Parser-3609"><a href="#Parser-3609"><span class="linenos">3609</span></a> <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">END</span><span class="p">)</span> +</span><span id="Parser-3610"><a href="#Parser-3610"><span class="linenos">3610</span></a> <span class="n">this</span> <span class="o">=</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">If</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">condition</span><span class="p">,</span> <span class="n">true</span><span class="o">=</span><span class="n">true</span><span class="p">,</span> <span class="n">false</span><span class="o">=</span><span class="n">false</span><span class="p">)</span> +</span><span id="Parser-3611"><a href="#Parser-3611"><span class="linenos">3611</span></a> +</span><span id="Parser-3612"><a href="#Parser-3612"><span class="linenos">3612</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-3613"><a href="#Parser-3613"><span class="linenos">3613</span></a> +</span><span id="Parser-3614"><a href="#Parser-3614"><span class="linenos">3614</span></a> <span class="k">def</span> <span class="nf">_parse_extract</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">Extract</span><span class="p">:</span> +</span><span id="Parser-3615"><a href="#Parser-3615"><span class="linenos">3615</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_function</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">()</span> +</span><span id="Parser-3616"><a href="#Parser-3616"><span class="linenos">3616</span></a> +</span><span id="Parser-3617"><a href="#Parser-3617"><span class="linenos">3617</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">FROM</span><span class="p">):</span> +</span><span id="Parser-3618"><a href="#Parser-3618"><span class="linenos">3618</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">Extract</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> +</span><span id="Parser-3619"><a href="#Parser-3619"><span class="linenos">3619</span></a> +</span><span id="Parser-3620"><a href="#Parser-3620"><span class="linenos">3620</span></a> <span class="k">if</span> <span class="ow">not</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">COMMA</span><span class="p">):</span> +</span><span id="Parser-3621"><a href="#Parser-3621"><span class="linenos">3621</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected FROM or comma after EXTRACT"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="Parser-3622"><a href="#Parser-3622"><span class="linenos">3622</span></a> +</span><span id="Parser-3623"><a href="#Parser-3623"><span class="linenos">3623</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">Extract</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> +</span><span id="Parser-3624"><a href="#Parser-3624"><span class="linenos">3624</span></a> +</span><span id="Parser-3625"><a href="#Parser-3625"><span class="linenos">3625</span></a> <span class="k">def</span> <span class="nf">_parse_cast</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">strict</span><span class="p">:</span> <span class="nb">bool</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="Parser-3626"><a href="#Parser-3626"><span class="linenos">3626</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="Parser-3627"><a href="#Parser-3627"><span class="linenos">3627</span></a> +</span><span id="Parser-3628"><a href="#Parser-3628"><span class="linenos">3628</span></a> <span class="k">if</span> <span class="ow">not</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">ALIAS</span><span class="p">):</span> +</span><span id="Parser-3629"><a href="#Parser-3629"><span class="linenos">3629</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">COMMA</span><span class="p">):</span> +</span><span id="Parser-3630"><a href="#Parser-3630"><span class="linenos">3630</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><span id="Parser-3631"><a href="#Parser-3631"><span class="linenos">3631</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">CastToStrType</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="Parser-3632"><a href="#Parser-3632"><span class="linenos">3632</span></a> <span class="p">)</span> +</span><span id="Parser-3633"><a href="#Parser-3633"><span class="linenos">3633</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3634"><a href="#Parser-3634"><span class="linenos">3634</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected AS after CAST"</span><span class="p">)</span> +</span><span id="Parser-3635"><a href="#Parser-3635"><span class="linenos">3635</span></a> +</span><span id="Parser-3636"><a href="#Parser-3636"><span class="linenos">3636</span></a> <span class="n">to</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">()</span> +</span><span id="Parser-3637"><a href="#Parser-3637"><span class="linenos">3637</span></a> +</span><span id="Parser-3638"><a href="#Parser-3638"><span class="linenos">3638</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">to</span><span class="p">:</span> +</span><span id="Parser-3639"><a href="#Parser-3639"><span class="linenos">3639</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expected TYPE after CAST"</span><span class="p">)</span> +</span><span id="Parser-3640"><a href="#Parser-3640"><span class="linenos">3640</span></a> <span class="k">elif</span> <span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">CHAR</span><span class="p">:</span> +</span><span id="Parser-3641"><a href="#Parser-3641"><span class="linenos">3641</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">CHARACTER_SET</span><span class="p">):</span> +</span><span id="Parser-3642"><a href="#Parser-3642"><span class="linenos">3642</span></a> <span class="n">to</span> <span class="o">=</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">CharacterSet</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_var_or_string</span><span class="p">())</span> +</span><span id="Parser-3643"><a href="#Parser-3643"><span class="linenos">3643</span></a> <span class="k">elif</span> <span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="ow">in</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">TEMPORAL_TYPES</span> <span class="ow">and</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">FORMAT</span><span class="p">):</span> +</span><span id="Parser-3644"><a href="#Parser-3644"><span class="linenos">3644</span></a> <span class="n">fmt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="Parser-3645"><a href="#Parser-3645"><span class="linenos">3645</span></a> +</span><span id="Parser-3646"><a href="#Parser-3646"><span class="linenos">3646</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><span id="Parser-3647"><a href="#Parser-3647"><span class="linenos">3647</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrToDate</span> <span class="k">if</span> <span class="n">to</span><span class="o">.</span><span class="n">this</span> <span class="o">==</span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">DATE</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">StrToTime</span><span class="p">,</span> +</span><span id="Parser-3648"><a href="#Parser-3648"><span class="linenos">3648</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="Parser-3649"><a href="#Parser-3649"><span class="linenos">3649</span></a> <span class="nb">format</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><span id="Parser-3650"><a href="#Parser-3650"><span class="linenos">3650</span></a> <span class="n">format_time</span><span class="p">(</span> +</span><span id="Parser-3651"><a href="#Parser-3651"><span class="linenos">3651</span></a> <span class="n">fmt</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">fmt</span> <span class="k">else</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="Parser-3652"><a href="#Parser-3652"><span class="linenos">3652</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">FORMAT_MAPPING</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_MAPPING</span><span class="p">,</span> +</span><span id="Parser-3653"><a href="#Parser-3653"><span class="linenos">3653</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">FORMAT_TRIE</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_TRIE</span><span class="p">,</span> +</span><span id="Parser-3654"><a href="#Parser-3654"><span class="linenos">3654</span></a> <span class="p">)</span> +</span><span id="Parser-3655"><a href="#Parser-3655"><span class="linenos">3655</span></a> <span class="p">),</span> +</span><span id="Parser-3656"><a href="#Parser-3656"><span class="linenos">3656</span></a> <span class="p">)</span> +</span><span id="Parser-3657"><a href="#Parser-3657"><span class="linenos">3657</span></a> +</span><span id="Parser-3658"><a href="#Parser-3658"><span class="linenos">3658</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">Cast</span> <span class="k">if</span> <span class="n">strict</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="n">to</span><span class="p">)</span> +</span><span id="Parser-3659"><a href="#Parser-3659"><span class="linenos">3659</span></a> +</span><span id="Parser-3660"><a href="#Parser-3660"><span class="linenos">3660</span></a> <span class="k">def</span> <span class="nf">_parse_concat</span><span class="p">(</span><span class="bp">self</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="Parser-3661"><a href="#Parser-3661"><span class="linenos">3661</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="Parser-3662"><a href="#Parser-3662"><span class="linenos">3662</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONCAT_NULL_OUTPUTS_STRING</span><span class="p">:</span> +</span><span id="Parser-3663"><a href="#Parser-3663"><span class="linenos">3663</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="Parser-3664"><a href="#Parser-3664"><span class="linenos">3664</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"COALESCE"</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">),</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">))</span> +</span><span id="Parser-3665"><a href="#Parser-3665"><span class="linenos">3665</span></a> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span> +</span><span id="Parser-3666"><a href="#Parser-3666"><span class="linenos">3666</span></a> <span class="k">if</span> <span class="n">arg</span> +</span><span id="Parser-3667"><a href="#Parser-3667"><span class="linenos">3667</span></a> <span class="p">]</span> +</span><span id="Parser-3668"><a href="#Parser-3668"><span class="linenos">3668</span></a> +</span><span id="Parser-3669"><a href="#Parser-3669"><span class="linenos">3669</span></a> <span class="c1"># Some dialects (e.g. Trino) don't allow a single-argument CONCAT call, so when</span> +</span><span id="Parser-3670"><a href="#Parser-3670"><span class="linenos">3670</span></a> <span class="c1"># we find such a call we replace it with its argument.</span> +</span><span id="Parser-3671"><a href="#Parser-3671"><span class="linenos">3671</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Parser-3672"><a href="#Parser-3672"><span class="linenos">3672</span></a> <span class="k">return</span> <span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> +</span><span id="Parser-3673"><a href="#Parser-3673"><span class="linenos">3673</span></a> +</span><span id="Parser-3674"><a href="#Parser-3674"><span class="linenos">3674</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><span id="Parser-3675"><a href="#Parser-3675"><span class="linenos">3675</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Concat</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">SafeConcat</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">args</span> +</span><span id="Parser-3676"><a href="#Parser-3676"><span class="linenos">3676</span></a> <span class="p">)</span> +</span><span id="Parser-3677"><a href="#Parser-3677"><span class="linenos">3677</span></a> +</span><span id="Parser-3678"><a href="#Parser-3678"><span class="linenos">3678</span></a> <span class="k">def</span> <span class="nf">_parse_string_agg</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">Expression</span><span class="p">:</span> +</span><span id="Parser-3679"><a href="#Parser-3679"><span class="linenos">3679</span></a> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> +</span><span id="Parser-3680"><a href="#Parser-3680"><span class="linenos">3680</span></a> +</span><span id="Parser-3681"><a href="#Parser-3681"><span class="linenos">3681</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">DISTINCT</span><span class="p">):</span> +</span><span id="Parser-3682"><a href="#Parser-3682"><span class="linenos">3682</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="Parser-3683"><a href="#Parser-3683"><span class="linenos">3683</span></a> <span class="n">expression</span> <span class="o">=</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">Distinct</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="p">[</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="Parser-3684"><a href="#Parser-3684"><span class="linenos">3684</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3685"><a href="#Parser-3685"><span class="linenos">3685</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="Parser-3686"><a href="#Parser-3686"><span class="linenos">3686</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">0</span><span class="p">)</span> +</span><span id="Parser-3687"><a href="#Parser-3687"><span class="linenos">3687</span></a> +</span><span id="Parser-3688"><a href="#Parser-3688"><span class="linenos">3688</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="Parser-3689"><a href="#Parser-3689"><span class="linenos">3689</span></a> <span class="k">if</span> <span class="ow">not</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">R_PAREN</span><span class="p">):</span> +</span><span id="Parser-3690"><a href="#Parser-3690"><span class="linenos">3690</span></a> <span class="c1"># postgres: STRING_AGG([DISTINCT] expression, separator [ORDER BY expression1 {ASC | DESC} [, ...]])</span> +</span><span id="Parser-3691"><a href="#Parser-3691"><span class="linenos">3691</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Parser-3692"><a href="#Parser-3692"><span class="linenos">3692</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">GroupConcat</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">order</span><span class="p">,</span> <span class="n">separator</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="Parser-3693"><a href="#Parser-3693"><span class="linenos">3693</span></a> +</span><span id="Parser-3694"><a href="#Parser-3694"><span class="linenos">3694</span></a> <span class="c1"># Checks if we can parse an order clause: WITHIN GROUP (ORDER BY <order_by_expression_list> [ASC | DESC]).</span> +</span><span id="Parser-3695"><a href="#Parser-3695"><span class="linenos">3695</span></a> <span class="c1"># This is done "manually", instead of letting _parse_window parse it into an exp.WithinGroup node, so that</span> +</span><span id="Parser-3696"><a href="#Parser-3696"><span class="linenos">3696</span></a> <span class="c1"># the STRING_AGG call is parsed like in MySQL / SQLite and can thus be transpiled more easily to them.</span> +</span><span id="Parser-3697"><a href="#Parser-3697"><span class="linenos">3697</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITHIN"</span><span class="p">,</span> <span class="s2">"GROUP"</span><span class="p">):</span> +</span><span id="Parser-3698"><a href="#Parser-3698"><span class="linenos">3698</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-3699"><a href="#Parser-3699"><span class="linenos">3699</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">GroupConcat</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="n">args</span><span class="p">)</span> </span><span id="Parser-3700"><a href="#Parser-3700"><span class="linenos">3700</span></a> -</span><span id="Parser-3701"><a href="#Parser-3701"><span class="linenos">3701</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">USING</span><span class="p">):</span> -</span><span id="Parser-3702"><a href="#Parser-3702"><span class="linenos">3702</span></a> <span class="n">to</span> <span class="o">=</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">CharacterSet</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_var</span><span class="p">())</span> -</span><span id="Parser-3703"><a href="#Parser-3703"><span class="linenos">3703</span></a> <span class="k">elif</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">COMMA</span><span class="p">):</span> -</span><span id="Parser-3704"><a href="#Parser-3704"><span class="linenos">3704</span></a> <span class="n">to</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="Parser-3705"><a href="#Parser-3705"><span class="linenos">3705</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3706"><a href="#Parser-3706"><span class="linenos">3706</span></a> <span class="n">to</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-3707"><a href="#Parser-3707"><span class="linenos">3707</span></a> -</span><span id="Parser-3708"><a href="#Parser-3708"><span class="linenos">3708</span></a> <span class="c1"># Swap the argument order if needed to produce the correct AST</span> -</span><span id="Parser-3709"><a href="#Parser-3709"><span class="linenos">3709</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONVERT_TYPE_FIRST</span><span class="p">:</span> -</span><span id="Parser-3710"><a href="#Parser-3710"><span class="linenos">3710</span></a> <span class="n">this</span><span class="p">,</span> <span class="n">to</span> <span class="o">=</span> <span class="n">to</span><span class="p">,</span> <span class="n">this</span> -</span><span id="Parser-3711"><a href="#Parser-3711"><span class="linenos">3711</span></a> -</span><span id="Parser-3712"><a href="#Parser-3712"><span class="linenos">3712</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">Cast</span> <span class="k">if</span> <span class="n">strict</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="n">to</span><span class="p">)</span> -</span><span id="Parser-3713"><a href="#Parser-3713"><span class="linenos">3713</span></a> -</span><span id="Parser-3714"><a href="#Parser-3714"><span class="linenos">3714</span></a> <span class="k">def</span> <span class="nf">_parse_decode</span><span class="p">(</span><span class="bp">self</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">Decode</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">]:</span> -</span><span id="Parser-3715"><a href="#Parser-3715"><span class="linenos">3715</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Parser-3716"><a href="#Parser-3716"><span class="linenos">3716</span></a><span class="sd"> There are generally two variants of the DECODE function:</span> -</span><span id="Parser-3717"><a href="#Parser-3717"><span class="linenos">3717</span></a> -</span><span id="Parser-3718"><a href="#Parser-3718"><span class="linenos">3718</span></a><span class="sd"> - DECODE(bin, charset)</span> -</span><span id="Parser-3719"><a href="#Parser-3719"><span class="linenos">3719</span></a><span class="sd"> - DECODE(expression, search, result [, search, result] ... [, default])</span> -</span><span id="Parser-3720"><a href="#Parser-3720"><span class="linenos">3720</span></a> -</span><span id="Parser-3721"><a href="#Parser-3721"><span class="linenos">3721</span></a><span class="sd"> The second variant will always be parsed into a CASE expression. Note that NULL</span> -</span><span id="Parser-3722"><a href="#Parser-3722"><span class="linenos">3722</span></a><span class="sd"> needs special treatment, since we need to explicitly check for it with `IS NULL`,</span> -</span><span id="Parser-3723"><a href="#Parser-3723"><span class="linenos">3723</span></a><span class="sd"> instead of relying on pattern matching.</span> -</span><span id="Parser-3724"><a href="#Parser-3724"><span class="linenos">3724</span></a><span class="sd"> """</span> -</span><span id="Parser-3725"><a href="#Parser-3725"><span class="linenos">3725</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="Parser-3726"><a href="#Parser-3726"><span class="linenos">3726</span></a> -</span><span id="Parser-3727"><a href="#Parser-3727"><span class="linenos">3727</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o"><</span> <span class="mi">3</span><span class="p">:</span> -</span><span id="Parser-3728"><a href="#Parser-3728"><span class="linenos">3728</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">Decode</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</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="Parser-3729"><a href="#Parser-3729"><span class="linenos">3729</span></a> -</span><span id="Parser-3730"><a href="#Parser-3730"><span class="linenos">3730</span></a> <span class="n">expression</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span> <span class="o">=</span> <span class="n">args</span> -</span><span id="Parser-3731"><a href="#Parser-3731"><span class="linenos">3731</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> -</span><span id="Parser-3732"><a href="#Parser-3732"><span class="linenos">3732</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-3733"><a href="#Parser-3733"><span class="linenos">3733</span></a> -</span><span id="Parser-3734"><a href="#Parser-3734"><span class="linenos">3734</span></a> <span class="n">ifs</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-3735"><a href="#Parser-3735"><span class="linenos">3735</span></a> <span class="k">for</span> <span class="n">search</span><span class="p">,</span> <span class="n">result</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">expressions</span><span class="p">[::</span><span class="mi">2</span><span class="p">],</span> <span class="n">expressions</span><span class="p">[</span><span class="mi">1</span><span class="p">::</span><span class="mi">2</span><span class="p">]):</span> -</span><span id="Parser-3736"><a href="#Parser-3736"><span class="linenos">3736</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">search</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">result</span><span class="p">:</span> -</span><span id="Parser-3737"><a href="#Parser-3737"><span class="linenos">3737</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-3738"><a href="#Parser-3738"><span class="linenos">3738</span></a> -</span><span id="Parser-3739"><a href="#Parser-3739"><span class="linenos">3739</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">search</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="Parser-3740"><a href="#Parser-3740"><span class="linenos">3740</span></a> <span class="n">ifs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="Parser-3741"><a href="#Parser-3741"><span class="linenos">3741</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">EQ</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">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">search</span><span class="p">),</span> <span class="n">true</span><span class="o">=</span><span class="n">result</span><span class="p">)</span> -</span><span id="Parser-3742"><a href="#Parser-3742"><span class="linenos">3742</span></a> <span class="p">)</span> -</span><span id="Parser-3743"><a href="#Parser-3743"><span class="linenos">3743</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">search</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="Parser-3744"><a href="#Parser-3744"><span class="linenos">3744</span></a> <span class="n">ifs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="Parser-3745"><a href="#Parser-3745"><span class="linenos">3745</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">()),</span> <span class="n">true</span><span class="o">=</span><span class="n">result</span><span class="p">)</span> -</span><span id="Parser-3746"><a href="#Parser-3746"><span class="linenos">3746</span></a> <span class="p">)</span> -</span><span id="Parser-3747"><a href="#Parser-3747"><span class="linenos">3747</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3748"><a href="#Parser-3748"><span class="linenos">3748</span></a> <span class="n">cond</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">or_</span><span class="p">(</span> -</span><span id="Parser-3749"><a href="#Parser-3749"><span class="linenos">3749</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">EQ</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">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">search</span><span class="p">),</span> -</span><span id="Parser-3750"><a href="#Parser-3750"><span class="linenos">3750</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">and_</span><span class="p">(</span> -</span><span id="Parser-3751"><a href="#Parser-3751"><span class="linenos">3751</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">()),</span> -</span><span id="Parser-3752"><a href="#Parser-3752"><span class="linenos">3752</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">search</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">()),</span> -</span><span id="Parser-3753"><a href="#Parser-3753"><span class="linenos">3753</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Parser-3754"><a href="#Parser-3754"><span class="linenos">3754</span></a> <span class="p">),</span> -</span><span id="Parser-3755"><a href="#Parser-3755"><span class="linenos">3755</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Parser-3756"><a href="#Parser-3756"><span class="linenos">3756</span></a> <span class="p">)</span> -</span><span id="Parser-3757"><a href="#Parser-3757"><span class="linenos">3757</span></a> <span class="n">ifs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">cond</span><span class="p">,</span> <span class="n">true</span><span class="o">=</span><span class="n">result</span><span class="p">))</span> -</span><span id="Parser-3758"><a href="#Parser-3758"><span class="linenos">3758</span></a> -</span><span id="Parser-3759"><a href="#Parser-3759"><span class="linenos">3759</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">(</span><span class="n">ifs</span><span class="o">=</span><span class="n">ifs</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">expressions</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">==</span> <span class="mi">1</span> <span class="k">else</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="Parser-3760"><a href="#Parser-3760"><span class="linenos">3760</span></a> -</span><span id="Parser-3761"><a href="#Parser-3761"><span class="linenos">3761</span></a> <span class="k">def</span> <span class="nf">_parse_json_key_value</span><span class="p">(</span><span class="bp">self</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">JSONKeyValue</span><span class="p">]:</span> -</span><span id="Parser-3762"><a href="#Parser-3762"><span class="linenos">3762</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"KEY"</span><span class="p">)</span> -</span><span id="Parser-3763"><a href="#Parser-3763"><span class="linenos">3763</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> -</span><span id="Parser-3764"><a href="#Parser-3764"><span class="linenos">3764</span></a> <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">COLON</span><span class="p">)</span> -</span><span id="Parser-3765"><a href="#Parser-3765"><span class="linenos">3765</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"VALUE"</span><span class="p">)</span> -</span><span id="Parser-3766"><a href="#Parser-3766"><span class="linenos">3766</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> -</span><span id="Parser-3767"><a href="#Parser-3767"><span class="linenos">3767</span></a> -</span><span id="Parser-3768"><a href="#Parser-3768"><span class="linenos">3768</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">key</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">value</span><span class="p">:</span> -</span><span id="Parser-3769"><a href="#Parser-3769"><span class="linenos">3769</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-3770"><a href="#Parser-3770"><span class="linenos">3770</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">JSONKeyValue</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">value</span><span class="p">)</span> -</span><span id="Parser-3771"><a href="#Parser-3771"><span class="linenos">3771</span></a> -</span><span id="Parser-3772"><a href="#Parser-3772"><span class="linenos">3772</span></a> <span class="k">def</span> <span class="nf">_parse_json_object</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">JSONObject</span><span class="p">:</span> -</span><span id="Parser-3773"><a href="#Parser-3773"><span class="linenos">3773</span></a> <span class="n">star</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_star</span><span class="p">()</span> -</span><span id="Parser-3774"><a href="#Parser-3774"><span class="linenos">3774</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">star</span><span class="p">]</span> <span class="k">if</span> <span class="n">star</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_json_key_value</span><span class="p">)</span> +</span><span id="Parser-3701"><a href="#Parser-3701"><span class="linenos">3701</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> <span class="c1"># The corresponding match_r_paren will be called in parse_function (caller)</span> +</span><span id="Parser-3702"><a href="#Parser-3702"><span class="linenos">3702</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Parser-3703"><a href="#Parser-3703"><span class="linenos">3703</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">GroupConcat</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">order</span><span class="p">,</span> <span class="n">separator</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="Parser-3704"><a href="#Parser-3704"><span class="linenos">3704</span></a> +</span><span id="Parser-3705"><a href="#Parser-3705"><span class="linenos">3705</span></a> <span class="k">def</span> <span class="nf">_parse_convert</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">strict</span><span class="p">:</span> <span class="nb">bool</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="Parser-3706"><a href="#Parser-3706"><span class="linenos">3706</span></a> <span class="n">to</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><span id="Parser-3707"><a href="#Parser-3707"><span class="linenos">3707</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="Parser-3708"><a href="#Parser-3708"><span class="linenos">3708</span></a> +</span><span id="Parser-3709"><a href="#Parser-3709"><span class="linenos">3709</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">USING</span><span class="p">):</span> +</span><span id="Parser-3710"><a href="#Parser-3710"><span class="linenos">3710</span></a> <span class="n">to</span> <span class="o">=</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">CharacterSet</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_var</span><span class="p">())</span> +</span><span id="Parser-3711"><a href="#Parser-3711"><span class="linenos">3711</span></a> <span class="k">elif</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">COMMA</span><span class="p">):</span> +</span><span id="Parser-3712"><a href="#Parser-3712"><span class="linenos">3712</span></a> <span class="n">to</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="Parser-3713"><a href="#Parser-3713"><span class="linenos">3713</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3714"><a href="#Parser-3714"><span class="linenos">3714</span></a> <span class="n">to</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-3715"><a href="#Parser-3715"><span class="linenos">3715</span></a> +</span><span id="Parser-3716"><a href="#Parser-3716"><span class="linenos">3716</span></a> <span class="c1"># Swap the argument order if needed to produce the correct AST</span> +</span><span id="Parser-3717"><a href="#Parser-3717"><span class="linenos">3717</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">CONVERT_TYPE_FIRST</span><span class="p">:</span> +</span><span id="Parser-3718"><a href="#Parser-3718"><span class="linenos">3718</span></a> <span class="n">this</span><span class="p">,</span> <span class="n">to</span> <span class="o">=</span> <span class="n">to</span><span class="p">,</span> <span class="n">this</span> +</span><span id="Parser-3719"><a href="#Parser-3719"><span class="linenos">3719</span></a> +</span><span id="Parser-3720"><a href="#Parser-3720"><span class="linenos">3720</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">Cast</span> <span class="k">if</span> <span class="n">strict</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">TryCast</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="n">to</span><span class="p">)</span> +</span><span id="Parser-3721"><a href="#Parser-3721"><span class="linenos">3721</span></a> +</span><span id="Parser-3722"><a href="#Parser-3722"><span class="linenos">3722</span></a> <span class="k">def</span> <span class="nf">_parse_decode</span><span class="p">(</span><span class="bp">self</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">Decode</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">]:</span> +</span><span id="Parser-3723"><a href="#Parser-3723"><span class="linenos">3723</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Parser-3724"><a href="#Parser-3724"><span class="linenos">3724</span></a><span class="sd"> There are generally two variants of the DECODE function:</span> +</span><span id="Parser-3725"><a href="#Parser-3725"><span class="linenos">3725</span></a> +</span><span id="Parser-3726"><a href="#Parser-3726"><span class="linenos">3726</span></a><span class="sd"> - DECODE(bin, charset)</span> +</span><span id="Parser-3727"><a href="#Parser-3727"><span class="linenos">3727</span></a><span class="sd"> - DECODE(expression, search, result [, search, result] ... [, default])</span> +</span><span id="Parser-3728"><a href="#Parser-3728"><span class="linenos">3728</span></a> +</span><span id="Parser-3729"><a href="#Parser-3729"><span class="linenos">3729</span></a><span class="sd"> The second variant will always be parsed into a CASE expression. Note that NULL</span> +</span><span id="Parser-3730"><a href="#Parser-3730"><span class="linenos">3730</span></a><span class="sd"> needs special treatment, since we need to explicitly check for it with `IS NULL`,</span> +</span><span id="Parser-3731"><a href="#Parser-3731"><span class="linenos">3731</span></a><span class="sd"> instead of relying on pattern matching.</span> +</span><span id="Parser-3732"><a href="#Parser-3732"><span class="linenos">3732</span></a><span class="sd"> """</span> +</span><span id="Parser-3733"><a href="#Parser-3733"><span class="linenos">3733</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="Parser-3734"><a href="#Parser-3734"><span class="linenos">3734</span></a> +</span><span id="Parser-3735"><a href="#Parser-3735"><span class="linenos">3735</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o"><</span> <span class="mi">3</span><span class="p">:</span> +</span><span id="Parser-3736"><a href="#Parser-3736"><span class="linenos">3736</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">Decode</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">charset</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="Parser-3737"><a href="#Parser-3737"><span class="linenos">3737</span></a> +</span><span id="Parser-3738"><a href="#Parser-3738"><span class="linenos">3738</span></a> <span class="n">expression</span><span class="p">,</span> <span class="o">*</span><span class="n">expressions</span> <span class="o">=</span> <span class="n">args</span> +</span><span id="Parser-3739"><a href="#Parser-3739"><span class="linenos">3739</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expression</span><span class="p">:</span> +</span><span id="Parser-3740"><a href="#Parser-3740"><span class="linenos">3740</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-3741"><a href="#Parser-3741"><span class="linenos">3741</span></a> +</span><span id="Parser-3742"><a href="#Parser-3742"><span class="linenos">3742</span></a> <span class="n">ifs</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-3743"><a href="#Parser-3743"><span class="linenos">3743</span></a> <span class="k">for</span> <span class="n">search</span><span class="p">,</span> <span class="n">result</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">expressions</span><span class="p">[::</span><span class="mi">2</span><span class="p">],</span> <span class="n">expressions</span><span class="p">[</span><span class="mi">1</span><span class="p">::</span><span class="mi">2</span><span class="p">]):</span> +</span><span id="Parser-3744"><a href="#Parser-3744"><span class="linenos">3744</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">search</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">result</span><span class="p">:</span> +</span><span id="Parser-3745"><a href="#Parser-3745"><span class="linenos">3745</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-3746"><a href="#Parser-3746"><span class="linenos">3746</span></a> +</span><span id="Parser-3747"><a href="#Parser-3747"><span class="linenos">3747</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">search</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="Parser-3748"><a href="#Parser-3748"><span class="linenos">3748</span></a> <span class="n">ifs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="Parser-3749"><a href="#Parser-3749"><span class="linenos">3749</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">EQ</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">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">search</span><span class="p">),</span> <span class="n">true</span><span class="o">=</span><span class="n">result</span><span class="p">)</span> +</span><span id="Parser-3750"><a href="#Parser-3750"><span class="linenos">3750</span></a> <span class="p">)</span> +</span><span id="Parser-3751"><a href="#Parser-3751"><span class="linenos">3751</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">search</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="Parser-3752"><a href="#Parser-3752"><span class="linenos">3752</span></a> <span class="n">ifs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="Parser-3753"><a href="#Parser-3753"><span class="linenos">3753</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">()),</span> <span class="n">true</span><span class="o">=</span><span class="n">result</span><span class="p">)</span> +</span><span id="Parser-3754"><a href="#Parser-3754"><span class="linenos">3754</span></a> <span class="p">)</span> +</span><span id="Parser-3755"><a href="#Parser-3755"><span class="linenos">3755</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3756"><a href="#Parser-3756"><span class="linenos">3756</span></a> <span class="n">cond</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">or_</span><span class="p">(</span> +</span><span id="Parser-3757"><a href="#Parser-3757"><span class="linenos">3757</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">EQ</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">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">search</span><span class="p">),</span> +</span><span id="Parser-3758"><a href="#Parser-3758"><span class="linenos">3758</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">and_</span><span class="p">(</span> +</span><span id="Parser-3759"><a href="#Parser-3759"><span class="linenos">3759</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">()),</span> +</span><span id="Parser-3760"><a href="#Parser-3760"><span class="linenos">3760</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Is</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">search</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Null</span><span class="p">()),</span> +</span><span id="Parser-3761"><a href="#Parser-3761"><span class="linenos">3761</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Parser-3762"><a href="#Parser-3762"><span class="linenos">3762</span></a> <span class="p">),</span> +</span><span id="Parser-3763"><a href="#Parser-3763"><span class="linenos">3763</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Parser-3764"><a href="#Parser-3764"><span class="linenos">3764</span></a> <span class="p">)</span> +</span><span id="Parser-3765"><a href="#Parser-3765"><span class="linenos">3765</span></a> <span class="n">ifs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">If</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">cond</span><span class="p">,</span> <span class="n">true</span><span class="o">=</span><span class="n">result</span><span class="p">))</span> +</span><span id="Parser-3766"><a href="#Parser-3766"><span class="linenos">3766</span></a> +</span><span id="Parser-3767"><a href="#Parser-3767"><span class="linenos">3767</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">(</span><span class="n">ifs</span><span class="o">=</span><span class="n">ifs</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">expressions</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">==</span> <span class="mi">1</span> <span class="k">else</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="Parser-3768"><a href="#Parser-3768"><span class="linenos">3768</span></a> +</span><span id="Parser-3769"><a href="#Parser-3769"><span class="linenos">3769</span></a> <span class="k">def</span> <span class="nf">_parse_json_key_value</span><span class="p">(</span><span class="bp">self</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">JSONKeyValue</span><span class="p">]:</span> +</span><span id="Parser-3770"><a href="#Parser-3770"><span class="linenos">3770</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"KEY"</span><span class="p">)</span> +</span><span id="Parser-3771"><a href="#Parser-3771"><span class="linenos">3771</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> +</span><span id="Parser-3772"><a href="#Parser-3772"><span class="linenos">3772</span></a> <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">COLON</span><span class="p">)</span> +</span><span id="Parser-3773"><a href="#Parser-3773"><span class="linenos">3773</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"VALUE"</span><span class="p">)</span> +</span><span id="Parser-3774"><a href="#Parser-3774"><span class="linenos">3774</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">()</span> </span><span id="Parser-3775"><a href="#Parser-3775"><span class="linenos">3775</span></a> -</span><span id="Parser-3776"><a href="#Parser-3776"><span class="linenos">3776</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-3777"><a href="#Parser-3777"><span class="linenos">3777</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULL"</span><span class="p">,</span> <span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"NULL"</span><span class="p">):</span> -</span><span id="Parser-3778"><a href="#Parser-3778"><span class="linenos">3778</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="s2">"NULL ON NULL"</span> -</span><span id="Parser-3779"><a href="#Parser-3779"><span class="linenos">3779</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ABSENT"</span><span class="p">,</span> <span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"NULL"</span><span class="p">):</span> -</span><span id="Parser-3780"><a href="#Parser-3780"><span class="linenos">3780</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="s2">"ABSENT ON NULL"</span> -</span><span id="Parser-3781"><a href="#Parser-3781"><span class="linenos">3781</span></a> -</span><span id="Parser-3782"><a href="#Parser-3782"><span class="linenos">3782</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-3783"><a href="#Parser-3783"><span class="linenos">3783</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"UNIQUE"</span><span class="p">):</span> -</span><span id="Parser-3784"><a href="#Parser-3784"><span class="linenos">3784</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Parser-3785"><a href="#Parser-3785"><span class="linenos">3785</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITHOUT"</span><span class="p">,</span> <span class="s2">"UNIQUE"</span><span class="p">):</span> -</span><span id="Parser-3786"><a href="#Parser-3786"><span class="linenos">3786</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-3787"><a href="#Parser-3787"><span class="linenos">3787</span></a> -</span><span id="Parser-3788"><a href="#Parser-3788"><span class="linenos">3788</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"KEYS"</span><span class="p">)</span> +</span><span id="Parser-3776"><a href="#Parser-3776"><span class="linenos">3776</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">key</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">value</span><span class="p">:</span> +</span><span id="Parser-3777"><a href="#Parser-3777"><span class="linenos">3777</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-3778"><a href="#Parser-3778"><span class="linenos">3778</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">JSONKeyValue</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">value</span><span class="p">)</span> +</span><span id="Parser-3779"><a href="#Parser-3779"><span class="linenos">3779</span></a> +</span><span id="Parser-3780"><a href="#Parser-3780"><span class="linenos">3780</span></a> <span class="k">def</span> <span class="nf">_parse_json_object</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">JSONObject</span><span class="p">:</span> +</span><span id="Parser-3781"><a href="#Parser-3781"><span class="linenos">3781</span></a> <span class="n">star</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_star</span><span class="p">()</span> +</span><span id="Parser-3782"><a href="#Parser-3782"><span class="linenos">3782</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">[</span><span class="n">star</span><span class="p">]</span> <span class="k">if</span> <span class="n">star</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_json_key_value</span><span class="p">)</span> +</span><span id="Parser-3783"><a href="#Parser-3783"><span class="linenos">3783</span></a> +</span><span id="Parser-3784"><a href="#Parser-3784"><span class="linenos">3784</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-3785"><a href="#Parser-3785"><span class="linenos">3785</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NULL"</span><span class="p">,</span> <span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"NULL"</span><span class="p">):</span> +</span><span id="Parser-3786"><a href="#Parser-3786"><span class="linenos">3786</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="s2">"NULL ON NULL"</span> +</span><span id="Parser-3787"><a href="#Parser-3787"><span class="linenos">3787</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ABSENT"</span><span class="p">,</span> <span class="s2">"ON"</span><span class="p">,</span> <span class="s2">"NULL"</span><span class="p">):</span> +</span><span id="Parser-3788"><a href="#Parser-3788"><span class="linenos">3788</span></a> <span class="n">null_handling</span> <span class="o">=</span> <span class="s2">"ABSENT ON NULL"</span> </span><span id="Parser-3789"><a href="#Parser-3789"><span class="linenos">3789</span></a> -</span><span id="Parser-3790"><a href="#Parser-3790"><span class="linenos">3790</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"RETURNING"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">()</span> -</span><span id="Parser-3791"><a href="#Parser-3791"><span class="linenos">3791</span></a> <span class="n">format_json</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FORMAT"</span><span class="p">,</span> <span class="s2">"JSON"</span><span class="p">)</span> -</span><span id="Parser-3792"><a href="#Parser-3792"><span class="linenos">3792</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ENCODING"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> -</span><span id="Parser-3793"><a href="#Parser-3793"><span class="linenos">3793</span></a> -</span><span id="Parser-3794"><a href="#Parser-3794"><span class="linenos">3794</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><span id="Parser-3795"><a href="#Parser-3795"><span class="linenos">3795</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONObject</span><span class="p">,</span> -</span><span id="Parser-3796"><a href="#Parser-3796"><span class="linenos">3796</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> -</span><span id="Parser-3797"><a href="#Parser-3797"><span class="linenos">3797</span></a> <span class="n">null_handling</span><span class="o">=</span><span class="n">null_handling</span><span class="p">,</span> -</span><span id="Parser-3798"><a href="#Parser-3798"><span class="linenos">3798</span></a> <span class="n">unique_keys</span><span class="o">=</span><span class="n">unique_keys</span><span class="p">,</span> -</span><span id="Parser-3799"><a href="#Parser-3799"><span class="linenos">3799</span></a> <span class="n">return_type</span><span class="o">=</span><span class="n">return_type</span><span class="p">,</span> -</span><span id="Parser-3800"><a href="#Parser-3800"><span class="linenos">3800</span></a> <span class="n">format_json</span><span class="o">=</span><span class="n">format_json</span><span class="p">,</span> -</span><span id="Parser-3801"><a href="#Parser-3801"><span class="linenos">3801</span></a> <span class="n">encoding</span><span class="o">=</span><span class="n">encoding</span><span class="p">,</span> -</span><span id="Parser-3802"><a href="#Parser-3802"><span class="linenos">3802</span></a> <span class="p">)</span> -</span><span id="Parser-3803"><a href="#Parser-3803"><span class="linenos">3803</span></a> -</span><span id="Parser-3804"><a href="#Parser-3804"><span class="linenos">3804</span></a> <span class="k">def</span> <span class="nf">_parse_logarithm</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">Func</span><span class="p">:</span> -</span><span id="Parser-3805"><a href="#Parser-3805"><span class="linenos">3805</span></a> <span class="c1"># Default argument order is base, expression</span> -</span><span id="Parser-3806"><a href="#Parser-3806"><span class="linenos">3806</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_range</span><span class="p">)</span> -</span><span id="Parser-3807"><a href="#Parser-3807"><span class="linenos">3807</span></a> -</span><span id="Parser-3808"><a href="#Parser-3808"><span class="linenos">3808</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Parser-3809"><a href="#Parser-3809"><span class="linenos">3809</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOG_BASE_FIRST</span><span class="p">:</span> -</span><span id="Parser-3810"><a href="#Parser-3810"><span class="linenos">3810</span></a> <span class="n">args</span><span class="o">.</span><span class="n">reverse</span><span class="p">()</span> -</span><span id="Parser-3811"><a href="#Parser-3811"><span class="linenos">3811</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Log</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> -</span><span id="Parser-3812"><a href="#Parser-3812"><span class="linenos">3812</span></a> -</span><span id="Parser-3813"><a href="#Parser-3813"><span class="linenos">3813</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><span id="Parser-3814"><a href="#Parser-3814"><span class="linenos">3814</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Ln</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOG_DEFAULTS_TO_LN</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">Log</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> -</span><span id="Parser-3815"><a href="#Parser-3815"><span class="linenos">3815</span></a> <span class="p">)</span> -</span><span id="Parser-3816"><a href="#Parser-3816"><span class="linenos">3816</span></a> -</span><span id="Parser-3817"><a href="#Parser-3817"><span class="linenos">3817</span></a> <span class="k">def</span> <span class="nf">_parse_match_against</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">MatchAgainst</span><span class="p">:</span> -</span><span id="Parser-3818"><a href="#Parser-3818"><span class="linenos">3818</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">)</span> -</span><span id="Parser-3819"><a href="#Parser-3819"><span class="linenos">3819</span></a> -</span><span id="Parser-3820"><a href="#Parser-3820"><span class="linenos">3820</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">")"</span><span class="p">,</span> <span class="s2">"AGAINST"</span><span class="p">,</span> <span class="s2">"("</span><span class="p">)</span> -</span><span id="Parser-3821"><a href="#Parser-3821"><span class="linenos">3821</span></a> -</span><span id="Parser-3822"><a href="#Parser-3822"><span class="linenos">3822</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="Parser-3823"><a href="#Parser-3823"><span class="linenos">3823</span></a> -</span><span id="Parser-3824"><a href="#Parser-3824"><span class="linenos">3824</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"IN"</span><span class="p">,</span> <span class="s2">"NATURAL"</span><span class="p">,</span> <span class="s2">"LANGUAGE"</span><span class="p">,</span> <span class="s2">"MODE"</span><span class="p">):</span> -</span><span id="Parser-3825"><a href="#Parser-3825"><span class="linenos">3825</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="s2">"IN NATURAL LANGUAGE MODE"</span> -</span><span id="Parser-3826"><a href="#Parser-3826"><span class="linenos">3826</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"QUERY"</span><span class="p">,</span> <span class="s2">"EXPANSION"</span><span class="p">):</span> -</span><span id="Parser-3827"><a href="#Parser-3827"><span class="linenos">3827</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">modifier</span><span class="si">}</span><span class="s2"> WITH QUERY EXPANSION"</span> -</span><span id="Parser-3828"><a href="#Parser-3828"><span class="linenos">3828</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"IN"</span><span class="p">,</span> <span class="s2">"BOOLEAN"</span><span class="p">,</span> <span class="s2">"MODE"</span><span class="p">):</span> -</span><span id="Parser-3829"><a href="#Parser-3829"><span class="linenos">3829</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="s2">"IN BOOLEAN MODE"</span> -</span><span id="Parser-3830"><a href="#Parser-3830"><span class="linenos">3830</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"QUERY"</span><span class="p">,</span> <span class="s2">"EXPANSION"</span><span class="p">):</span> -</span><span id="Parser-3831"><a href="#Parser-3831"><span class="linenos">3831</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="s2">"WITH QUERY EXPANSION"</span> -</span><span id="Parser-3832"><a href="#Parser-3832"><span class="linenos">3832</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3833"><a href="#Parser-3833"><span class="linenos">3833</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-3834"><a href="#Parser-3834"><span class="linenos">3834</span></a> -</span><span id="Parser-3835"><a href="#Parser-3835"><span class="linenos">3835</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><span id="Parser-3836"><a href="#Parser-3836"><span class="linenos">3836</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MatchAgainst</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">modifier</span><span class="o">=</span><span class="n">modifier</span> -</span><span id="Parser-3837"><a href="#Parser-3837"><span class="linenos">3837</span></a> <span class="p">)</span> -</span><span id="Parser-3838"><a href="#Parser-3838"><span class="linenos">3838</span></a> -</span><span id="Parser-3839"><a href="#Parser-3839"><span class="linenos">3839</span></a> <span class="c1"># https://learn.microsoft.com/en-us/sql/t-sql/functions/openjson-transact-sql?view=sql-server-ver16</span> -</span><span id="Parser-3840"><a href="#Parser-3840"><span class="linenos">3840</span></a> <span class="k">def</span> <span class="nf">_parse_open_json</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">OpenJSON</span><span class="p">:</span> -</span><span id="Parser-3841"><a href="#Parser-3841"><span class="linenos">3841</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="Parser-3842"><a href="#Parser-3842"><span class="linenos">3842</span></a> <span class="n">path</span> <span class="o">=</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">COMMA</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="Parser-3843"><a href="#Parser-3843"><span class="linenos">3843</span></a> -</span><span id="Parser-3844"><a href="#Parser-3844"><span class="linenos">3844</span></a> <span class="k">def</span> <span class="nf">_parse_open_json_column_def</span><span class="p">()</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSONColumnDef</span><span class="p">:</span> -</span><span id="Parser-3845"><a href="#Parser-3845"><span class="linenos">3845</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-3846"><a href="#Parser-3846"><span class="linenos">3846</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">()</span> -</span><span id="Parser-3847"><a href="#Parser-3847"><span class="linenos">3847</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="Parser-3848"><a href="#Parser-3848"><span class="linenos">3848</span></a> <span class="n">as_json</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ALIAS</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">JSON</span><span class="p">)</span> -</span><span id="Parser-3849"><a href="#Parser-3849"><span class="linenos">3849</span></a> -</span><span id="Parser-3850"><a href="#Parser-3850"><span class="linenos">3850</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><span id="Parser-3851"><a href="#Parser-3851"><span class="linenos">3851</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSONColumnDef</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="n">path</span><span class="p">,</span> <span class="n">as_json</span><span class="o">=</span><span class="n">as_json</span> -</span><span id="Parser-3852"><a href="#Parser-3852"><span class="linenos">3852</span></a> <span class="p">)</span> -</span><span id="Parser-3853"><a href="#Parser-3853"><span class="linenos">3853</span></a> -</span><span id="Parser-3854"><a href="#Parser-3854"><span class="linenos">3854</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-3855"><a href="#Parser-3855"><span class="linenos">3855</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">R_PAREN</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">):</span> -</span><span id="Parser-3856"><a href="#Parser-3856"><span class="linenos">3856</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> -</span><span id="Parser-3857"><a href="#Parser-3857"><span class="linenos">3857</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">_parse_open_json_column_def</span><span class="p">)</span> -</span><span id="Parser-3858"><a href="#Parser-3858"><span class="linenos">3858</span></a> -</span><span id="Parser-3859"><a href="#Parser-3859"><span class="linenos">3859</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">OpenJSON</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="n">path</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Parser-3860"><a href="#Parser-3860"><span class="linenos">3860</span></a> -</span><span id="Parser-3861"><a href="#Parser-3861"><span class="linenos">3861</span></a> <span class="k">def</span> <span class="nf">_parse_position</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">haystack_first</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> -</span><span id="Parser-3862"><a href="#Parser-3862"><span class="linenos">3862</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">)</span> -</span><span id="Parser-3863"><a href="#Parser-3863"><span class="linenos">3863</span></a> -</span><span id="Parser-3864"><a href="#Parser-3864"><span class="linenos">3864</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">IN</span><span class="p">):</span> -</span><span id="Parser-3865"><a href="#Parser-3865"><span class="linenos">3865</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><span id="Parser-3866"><a href="#Parser-3866"><span class="linenos">3866</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</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_bitwise</span><span class="p">(),</span> <span class="n">substr</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="Parser-3867"><a href="#Parser-3867"><span class="linenos">3867</span></a> <span class="p">)</span> +</span><span id="Parser-3790"><a href="#Parser-3790"><span class="linenos">3790</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-3791"><a href="#Parser-3791"><span class="linenos">3791</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"UNIQUE"</span><span class="p">):</span> +</span><span id="Parser-3792"><a href="#Parser-3792"><span class="linenos">3792</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Parser-3793"><a href="#Parser-3793"><span class="linenos">3793</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITHOUT"</span><span class="p">,</span> <span class="s2">"UNIQUE"</span><span class="p">):</span> +</span><span id="Parser-3794"><a href="#Parser-3794"><span class="linenos">3794</span></a> <span class="n">unique_keys</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-3795"><a href="#Parser-3795"><span class="linenos">3795</span></a> +</span><span id="Parser-3796"><a href="#Parser-3796"><span class="linenos">3796</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"KEYS"</span><span class="p">)</span> +</span><span id="Parser-3797"><a href="#Parser-3797"><span class="linenos">3797</span></a> +</span><span id="Parser-3798"><a href="#Parser-3798"><span class="linenos">3798</span></a> <span class="n">return_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"RETURNING"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_type</span><span class="p">()</span> +</span><span id="Parser-3799"><a href="#Parser-3799"><span class="linenos">3799</span></a> <span class="n">format_json</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"FORMAT"</span><span class="p">,</span> <span class="s2">"JSON"</span><span class="p">)</span> +</span><span id="Parser-3800"><a href="#Parser-3800"><span class="linenos">3800</span></a> <span class="n">encoding</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ENCODING"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> +</span><span id="Parser-3801"><a href="#Parser-3801"><span class="linenos">3801</span></a> +</span><span id="Parser-3802"><a href="#Parser-3802"><span class="linenos">3802</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><span id="Parser-3803"><a href="#Parser-3803"><span class="linenos">3803</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">JSONObject</span><span class="p">,</span> +</span><span id="Parser-3804"><a href="#Parser-3804"><span class="linenos">3804</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> +</span><span id="Parser-3805"><a href="#Parser-3805"><span class="linenos">3805</span></a> <span class="n">null_handling</span><span class="o">=</span><span class="n">null_handling</span><span class="p">,</span> +</span><span id="Parser-3806"><a href="#Parser-3806"><span class="linenos">3806</span></a> <span class="n">unique_keys</span><span class="o">=</span><span class="n">unique_keys</span><span class="p">,</span> +</span><span id="Parser-3807"><a href="#Parser-3807"><span class="linenos">3807</span></a> <span class="n">return_type</span><span class="o">=</span><span class="n">return_type</span><span class="p">,</span> +</span><span id="Parser-3808"><a href="#Parser-3808"><span class="linenos">3808</span></a> <span class="n">format_json</span><span class="o">=</span><span class="n">format_json</span><span class="p">,</span> +</span><span id="Parser-3809"><a href="#Parser-3809"><span class="linenos">3809</span></a> <span class="n">encoding</span><span class="o">=</span><span class="n">encoding</span><span class="p">,</span> +</span><span id="Parser-3810"><a href="#Parser-3810"><span class="linenos">3810</span></a> <span class="p">)</span> +</span><span id="Parser-3811"><a href="#Parser-3811"><span class="linenos">3811</span></a> +</span><span id="Parser-3812"><a href="#Parser-3812"><span class="linenos">3812</span></a> <span class="k">def</span> <span class="nf">_parse_logarithm</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">Func</span><span class="p">:</span> +</span><span id="Parser-3813"><a href="#Parser-3813"><span class="linenos">3813</span></a> <span class="c1"># Default argument order is base, expression</span> +</span><span id="Parser-3814"><a href="#Parser-3814"><span class="linenos">3814</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_range</span><span class="p">)</span> +</span><span id="Parser-3815"><a href="#Parser-3815"><span class="linenos">3815</span></a> +</span><span id="Parser-3816"><a href="#Parser-3816"><span class="linenos">3816</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Parser-3817"><a href="#Parser-3817"><span class="linenos">3817</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOG_BASE_FIRST</span><span class="p">:</span> +</span><span id="Parser-3818"><a href="#Parser-3818"><span class="linenos">3818</span></a> <span class="n">args</span><span class="o">.</span><span class="n">reverse</span><span class="p">()</span> +</span><span id="Parser-3819"><a href="#Parser-3819"><span class="linenos">3819</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Log</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> +</span><span id="Parser-3820"><a href="#Parser-3820"><span class="linenos">3820</span></a> +</span><span id="Parser-3821"><a href="#Parser-3821"><span class="linenos">3821</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><span id="Parser-3822"><a href="#Parser-3822"><span class="linenos">3822</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Ln</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOG_DEFAULTS_TO_LN</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">Log</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">seq_get</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="Parser-3823"><a href="#Parser-3823"><span class="linenos">3823</span></a> <span class="p">)</span> +</span><span id="Parser-3824"><a href="#Parser-3824"><span class="linenos">3824</span></a> +</span><span id="Parser-3825"><a href="#Parser-3825"><span class="linenos">3825</span></a> <span class="k">def</span> <span class="nf">_parse_match_against</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">MatchAgainst</span><span class="p">:</span> +</span><span id="Parser-3826"><a href="#Parser-3826"><span class="linenos">3826</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">)</span> +</span><span id="Parser-3827"><a href="#Parser-3827"><span class="linenos">3827</span></a> +</span><span id="Parser-3828"><a href="#Parser-3828"><span class="linenos">3828</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">")"</span><span class="p">,</span> <span class="s2">"AGAINST"</span><span class="p">,</span> <span class="s2">"("</span><span class="p">)</span> +</span><span id="Parser-3829"><a href="#Parser-3829"><span class="linenos">3829</span></a> +</span><span id="Parser-3830"><a href="#Parser-3830"><span class="linenos">3830</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="Parser-3831"><a href="#Parser-3831"><span class="linenos">3831</span></a> +</span><span id="Parser-3832"><a href="#Parser-3832"><span class="linenos">3832</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"IN"</span><span class="p">,</span> <span class="s2">"NATURAL"</span><span class="p">,</span> <span class="s2">"LANGUAGE"</span><span class="p">,</span> <span class="s2">"MODE"</span><span class="p">):</span> +</span><span id="Parser-3833"><a href="#Parser-3833"><span class="linenos">3833</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="s2">"IN NATURAL LANGUAGE MODE"</span> +</span><span id="Parser-3834"><a href="#Parser-3834"><span class="linenos">3834</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"QUERY"</span><span class="p">,</span> <span class="s2">"EXPANSION"</span><span class="p">):</span> +</span><span id="Parser-3835"><a href="#Parser-3835"><span class="linenos">3835</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">modifier</span><span class="si">}</span><span class="s2"> WITH QUERY EXPANSION"</span> +</span><span id="Parser-3836"><a href="#Parser-3836"><span class="linenos">3836</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"IN"</span><span class="p">,</span> <span class="s2">"BOOLEAN"</span><span class="p">,</span> <span class="s2">"MODE"</span><span class="p">):</span> +</span><span id="Parser-3837"><a href="#Parser-3837"><span class="linenos">3837</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="s2">"IN BOOLEAN MODE"</span> +</span><span id="Parser-3838"><a href="#Parser-3838"><span class="linenos">3838</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITH"</span><span class="p">,</span> <span class="s2">"QUERY"</span><span class="p">,</span> <span class="s2">"EXPANSION"</span><span class="p">):</span> +</span><span id="Parser-3839"><a href="#Parser-3839"><span class="linenos">3839</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="s2">"WITH QUERY EXPANSION"</span> +</span><span id="Parser-3840"><a href="#Parser-3840"><span class="linenos">3840</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3841"><a href="#Parser-3841"><span class="linenos">3841</span></a> <span class="n">modifier</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-3842"><a href="#Parser-3842"><span class="linenos">3842</span></a> +</span><span id="Parser-3843"><a href="#Parser-3843"><span class="linenos">3843</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><span id="Parser-3844"><a href="#Parser-3844"><span class="linenos">3844</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">MatchAgainst</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">,</span> <span class="n">modifier</span><span class="o">=</span><span class="n">modifier</span> +</span><span id="Parser-3845"><a href="#Parser-3845"><span class="linenos">3845</span></a> <span class="p">)</span> +</span><span id="Parser-3846"><a href="#Parser-3846"><span class="linenos">3846</span></a> +</span><span id="Parser-3847"><a href="#Parser-3847"><span class="linenos">3847</span></a> <span class="c1"># https://learn.microsoft.com/en-us/sql/t-sql/functions/openjson-transact-sql?view=sql-server-ver16</span> +</span><span id="Parser-3848"><a href="#Parser-3848"><span class="linenos">3848</span></a> <span class="k">def</span> <span class="nf">_parse_open_json</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">OpenJSON</span><span class="p">:</span> +</span><span id="Parser-3849"><a href="#Parser-3849"><span class="linenos">3849</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="Parser-3850"><a href="#Parser-3850"><span class="linenos">3850</span></a> <span class="n">path</span> <span class="o">=</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">COMMA</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="Parser-3851"><a href="#Parser-3851"><span class="linenos">3851</span></a> +</span><span id="Parser-3852"><a href="#Parser-3852"><span class="linenos">3852</span></a> <span class="k">def</span> <span class="nf">_parse_open_json_column_def</span><span class="p">()</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSONColumnDef</span><span class="p">:</span> +</span><span id="Parser-3853"><a href="#Parser-3853"><span class="linenos">3853</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-3854"><a href="#Parser-3854"><span class="linenos">3854</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">()</span> +</span><span id="Parser-3855"><a href="#Parser-3855"><span class="linenos">3855</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="Parser-3856"><a href="#Parser-3856"><span class="linenos">3856</span></a> <span class="n">as_json</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ALIAS</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">JSON</span><span class="p">)</span> +</span><span id="Parser-3857"><a href="#Parser-3857"><span class="linenos">3857</span></a> +</span><span id="Parser-3858"><a href="#Parser-3858"><span class="linenos">3858</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><span id="Parser-3859"><a href="#Parser-3859"><span class="linenos">3859</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">OpenJSONColumnDef</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="n">path</span><span class="p">,</span> <span class="n">as_json</span><span class="o">=</span><span class="n">as_json</span> +</span><span id="Parser-3860"><a href="#Parser-3860"><span class="linenos">3860</span></a> <span class="p">)</span> +</span><span id="Parser-3861"><a href="#Parser-3861"><span class="linenos">3861</span></a> +</span><span id="Parser-3862"><a href="#Parser-3862"><span class="linenos">3862</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-3863"><a href="#Parser-3863"><span class="linenos">3863</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">R_PAREN</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">):</span> +</span><span id="Parser-3864"><a href="#Parser-3864"><span class="linenos">3864</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> +</span><span id="Parser-3865"><a href="#Parser-3865"><span class="linenos">3865</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">_parse_open_json_column_def</span><span class="p">)</span> +</span><span id="Parser-3866"><a href="#Parser-3866"><span class="linenos">3866</span></a> +</span><span id="Parser-3867"><a href="#Parser-3867"><span class="linenos">3867</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">OpenJSON</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="n">path</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> </span><span id="Parser-3868"><a href="#Parser-3868"><span class="linenos">3868</span></a> -</span><span id="Parser-3869"><a href="#Parser-3869"><span class="linenos">3869</span></a> <span class="k">if</span> <span class="n">haystack_first</span><span class="p">:</span> -</span><span id="Parser-3870"><a href="#Parser-3870"><span class="linenos">3870</span></a> <span class="n">haystack</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="Parser-3871"><a href="#Parser-3871"><span class="linenos">3871</span></a> <span class="n">needle</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="Parser-3872"><a href="#Parser-3872"><span class="linenos">3872</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3873"><a href="#Parser-3873"><span class="linenos">3873</span></a> <span class="n">needle</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="Parser-3874"><a href="#Parser-3874"><span class="linenos">3874</span></a> <span class="n">haystack</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="Parser-3875"><a href="#Parser-3875"><span class="linenos">3875</span></a> -</span><span id="Parser-3876"><a href="#Parser-3876"><span class="linenos">3876</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><span id="Parser-3877"><a href="#Parser-3877"><span class="linenos">3877</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">haystack</span><span class="p">,</span> <span class="n">substr</span><span class="o">=</span><span class="n">needle</span><span class="p">,</span> <span class="n">position</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="Parser-3878"><a href="#Parser-3878"><span class="linenos">3878</span></a> <span class="p">)</span> -</span><span id="Parser-3879"><a href="#Parser-3879"><span class="linenos">3879</span></a> -</span><span id="Parser-3880"><a href="#Parser-3880"><span class="linenos">3880</span></a> <span class="k">def</span> <span class="nf">_parse_join_hint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">func_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">JoinHint</span><span class="p">:</span> -</span><span id="Parser-3881"><a href="#Parser-3881"><span class="linenos">3881</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">)</span> -</span><span id="Parser-3882"><a href="#Parser-3882"><span class="linenos">3882</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">JoinHint</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">func_name</span><span class="o">.</span><span class="n">upper</span><span class="p">(),</span> <span class="n">expressions</span><span class="o">=</span><span class="n">args</span><span class="p">)</span> +</span><span id="Parser-3869"><a href="#Parser-3869"><span class="linenos">3869</span></a> <span class="k">def</span> <span class="nf">_parse_position</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">haystack_first</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">:</span> +</span><span id="Parser-3870"><a href="#Parser-3870"><span class="linenos">3870</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">)</span> +</span><span id="Parser-3871"><a href="#Parser-3871"><span class="linenos">3871</span></a> +</span><span id="Parser-3872"><a href="#Parser-3872"><span class="linenos">3872</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">IN</span><span class="p">):</span> +</span><span id="Parser-3873"><a href="#Parser-3873"><span class="linenos">3873</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><span id="Parser-3874"><a href="#Parser-3874"><span class="linenos">3874</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</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_bitwise</span><span class="p">(),</span> <span class="n">substr</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="Parser-3875"><a href="#Parser-3875"><span class="linenos">3875</span></a> <span class="p">)</span> +</span><span id="Parser-3876"><a href="#Parser-3876"><span class="linenos">3876</span></a> +</span><span id="Parser-3877"><a href="#Parser-3877"><span class="linenos">3877</span></a> <span class="k">if</span> <span class="n">haystack_first</span><span class="p">:</span> +</span><span id="Parser-3878"><a href="#Parser-3878"><span class="linenos">3878</span></a> <span class="n">haystack</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="Parser-3879"><a href="#Parser-3879"><span class="linenos">3879</span></a> <span class="n">needle</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="Parser-3880"><a href="#Parser-3880"><span class="linenos">3880</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3881"><a href="#Parser-3881"><span class="linenos">3881</span></a> <span class="n">needle</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="Parser-3882"><a href="#Parser-3882"><span class="linenos">3882</span></a> <span class="n">haystack</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="Parser-3883"><a href="#Parser-3883"><span class="linenos">3883</span></a> -</span><span id="Parser-3884"><a href="#Parser-3884"><span class="linenos">3884</span></a> <span class="k">def</span> <span class="nf">_parse_substring</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">Substring</span><span class="p">:</span> -</span><span id="Parser-3885"><a href="#Parser-3885"><span class="linenos">3885</span></a> <span class="c1"># Postgres supports the form: substring(string [from int] [for int])</span> -</span><span id="Parser-3886"><a href="#Parser-3886"><span class="linenos">3886</span></a> <span class="c1"># https://www.postgresql.org/docs/9.1/functions-string.html @ Table 9-6</span> +</span><span id="Parser-3884"><a href="#Parser-3884"><span class="linenos">3884</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><span id="Parser-3885"><a href="#Parser-3885"><span class="linenos">3885</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">StrPosition</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">haystack</span><span class="p">,</span> <span class="n">substr</span><span class="o">=</span><span class="n">needle</span><span class="p">,</span> <span class="n">position</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="Parser-3886"><a href="#Parser-3886"><span class="linenos">3886</span></a> <span class="p">)</span> </span><span id="Parser-3887"><a href="#Parser-3887"><span class="linenos">3887</span></a> -</span><span id="Parser-3888"><a href="#Parser-3888"><span class="linenos">3888</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">)</span> -</span><span id="Parser-3889"><a href="#Parser-3889"><span class="linenos">3889</span></a> -</span><span id="Parser-3890"><a href="#Parser-3890"><span class="linenos">3890</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">FROM</span><span class="p">):</span> -</span><span id="Parser-3891"><a href="#Parser-3891"><span class="linenos">3891</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> -</span><span id="Parser-3892"><a href="#Parser-3892"><span class="linenos">3892</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">FOR</span><span class="p">):</span> -</span><span id="Parser-3893"><a href="#Parser-3893"><span class="linenos">3893</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> -</span><span id="Parser-3894"><a href="#Parser-3894"><span class="linenos">3894</span></a> -</span><span id="Parser-3895"><a href="#Parser-3895"><span class="linenos">3895</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Substring</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="n">args</span><span class="p">)</span> -</span><span id="Parser-3896"><a href="#Parser-3896"><span class="linenos">3896</span></a> -</span><span id="Parser-3897"><a href="#Parser-3897"><span class="linenos">3897</span></a> <span class="k">def</span> <span class="nf">_parse_trim</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">Trim</span><span class="p">:</span> -</span><span id="Parser-3898"><a href="#Parser-3898"><span class="linenos">3898</span></a> <span class="c1"># https://www.w3resource.com/sql/character-functions/trim.php</span> -</span><span id="Parser-3899"><a href="#Parser-3899"><span class="linenos">3899</span></a> <span class="c1"># https://docs.oracle.com/javadb/10.8.3.0/ref/rreftrimfunc.html</span> -</span><span id="Parser-3900"><a href="#Parser-3900"><span class="linenos">3900</span></a> -</span><span id="Parser-3901"><a href="#Parser-3901"><span class="linenos">3901</span></a> <span class="n">position</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-3902"><a href="#Parser-3902"><span class="linenos">3902</span></a> <span class="n">collation</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-3903"><a href="#Parser-3903"><span class="linenos">3903</span></a> -</span><span id="Parser-3904"><a href="#Parser-3904"><span class="linenos">3904</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">TRIM_TYPES</span><span class="p">):</span> -</span><span id="Parser-3905"><a href="#Parser-3905"><span class="linenos">3905</span></a> <span class="n">position</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="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Parser-3906"><a href="#Parser-3906"><span class="linenos">3906</span></a> -</span><span id="Parser-3907"><a href="#Parser-3907"><span class="linenos">3907</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="Parser-3908"><a href="#Parser-3908"><span class="linenos">3908</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FROM</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMA</span><span class="p">)):</span> -</span><span id="Parser-3909"><a href="#Parser-3909"><span class="linenos">3909</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="Parser-3910"><a href="#Parser-3910"><span class="linenos">3910</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3911"><a href="#Parser-3911"><span class="linenos">3911</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span> -</span><span id="Parser-3912"><a href="#Parser-3912"><span class="linenos">3912</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-3913"><a href="#Parser-3913"><span class="linenos">3913</span></a> -</span><span id="Parser-3914"><a href="#Parser-3914"><span class="linenos">3914</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">COLLATE</span><span class="p">):</span> -</span><span id="Parser-3915"><a href="#Parser-3915"><span class="linenos">3915</span></a> <span class="n">collation</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="Parser-3916"><a href="#Parser-3916"><span class="linenos">3916</span></a> -</span><span id="Parser-3917"><a href="#Parser-3917"><span class="linenos">3917</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><span id="Parser-3918"><a href="#Parser-3918"><span class="linenos">3918</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">position</span><span class="o">=</span><span class="n">position</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">collation</span><span class="o">=</span><span class="n">collation</span> -</span><span id="Parser-3919"><a href="#Parser-3919"><span class="linenos">3919</span></a> <span class="p">)</span> -</span><span id="Parser-3920"><a href="#Parser-3920"><span class="linenos">3920</span></a> -</span><span id="Parser-3921"><a href="#Parser-3921"><span class="linenos">3921</span></a> <span class="k">def</span> <span class="nf">_parse_window_clause</span><span class="p">(</span><span class="bp">self</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">t</span><span class="o">.</span><span class="n">List</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><span id="Parser-3922"><a href="#Parser-3922"><span class="linenos">3922</span></a> <span class="k">return</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">WINDOW</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_named_window</span><span class="p">)</span> -</span><span id="Parser-3923"><a href="#Parser-3923"><span class="linenos">3923</span></a> -</span><span id="Parser-3924"><a href="#Parser-3924"><span class="linenos">3924</span></a> <span class="k">def</span> <span class="nf">_parse_named_window</span><span class="p">(</span><span class="bp">self</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="Parser-3925"><a href="#Parser-3925"><span class="linenos">3925</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(),</span> <span class="n">alias</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-3926"><a href="#Parser-3926"><span class="linenos">3926</span></a> -</span><span id="Parser-3927"><a href="#Parser-3927"><span class="linenos">3927</span></a> <span class="k">def</span> <span class="nf">_parse_respect_or_ignore_nulls</span><span class="p">(</span> -</span><span id="Parser-3928"><a href="#Parser-3928"><span class="linenos">3928</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><span id="Parser-3929"><a href="#Parser-3929"><span class="linenos">3929</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="Parser-3930"><a href="#Parser-3930"><span class="linenos">3930</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"IGNORE"</span><span class="p">,</span> <span class="s2">"NULLS"</span><span class="p">):</span> -</span><span id="Parser-3931"><a href="#Parser-3931"><span class="linenos">3931</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">IgnoreNulls</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-3932"><a href="#Parser-3932"><span class="linenos">3932</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"RESPECT"</span><span class="p">,</span> <span class="s2">"NULLS"</span><span class="p">):</span> -</span><span id="Parser-3933"><a href="#Parser-3933"><span class="linenos">3933</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">RespectNulls</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-3934"><a href="#Parser-3934"><span class="linenos">3934</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-3935"><a href="#Parser-3935"><span class="linenos">3935</span></a> -</span><span id="Parser-3936"><a href="#Parser-3936"><span class="linenos">3936</span></a> <span class="k">def</span> <span class="nf">_parse_window</span><span class="p">(</span> -</span><span id="Parser-3937"><a href="#Parser-3937"><span class="linenos">3937</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="n">alias</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-3938"><a href="#Parser-3938"><span class="linenos">3938</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="Parser-3939"><a href="#Parser-3939"><span class="linenos">3939</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FILTER</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">):</span> -</span><span id="Parser-3940"><a href="#Parser-3940"><span class="linenos">3940</span></a> <span class="n">this</span> <span class="o">=</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">Filter</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">())</span> -</span><span id="Parser-3941"><a href="#Parser-3941"><span class="linenos">3941</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="Parser-3942"><a href="#Parser-3942"><span class="linenos">3942</span></a> -</span><span id="Parser-3943"><a href="#Parser-3943"><span class="linenos">3943</span></a> <span class="c1"># T-SQL allows the OVER (...) syntax after WITHIN GROUP.</span> -</span><span id="Parser-3944"><a href="#Parser-3944"><span class="linenos">3944</span></a> <span class="c1"># https://learn.microsoft.com/en-us/sql/t-sql/functions/percentile-disc-transact-sql?view=sql-server-ver16</span> -</span><span id="Parser-3945"><a href="#Parser-3945"><span class="linenos">3945</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITHIN"</span><span class="p">,</span> <span class="s2">"GROUP"</span><span class="p">):</span> -</span><span id="Parser-3946"><a href="#Parser-3946"><span class="linenos">3946</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">)</span> -</span><span id="Parser-3947"><a href="#Parser-3947"><span class="linenos">3947</span></a> <span class="n">this</span> <span class="o">=</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">WithinGroup</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">order</span><span class="p">)</span> -</span><span id="Parser-3948"><a href="#Parser-3948"><span class="linenos">3948</span></a> -</span><span id="Parser-3949"><a href="#Parser-3949"><span class="linenos">3949</span></a> <span class="c1"># SQL spec defines an optional [ { IGNORE | RESPECT } NULLS ] OVER</span> -</span><span id="Parser-3950"><a href="#Parser-3950"><span class="linenos">3950</span></a> <span class="c1"># Some dialects choose to implement and some do not.</span> -</span><span id="Parser-3951"><a href="#Parser-3951"><span class="linenos">3951</span></a> <span class="c1"># https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html</span> -</span><span id="Parser-3952"><a href="#Parser-3952"><span class="linenos">3952</span></a> -</span><span id="Parser-3953"><a href="#Parser-3953"><span class="linenos">3953</span></a> <span class="c1"># There is some code above in _parse_lambda that handles</span> -</span><span id="Parser-3954"><a href="#Parser-3954"><span class="linenos">3954</span></a> <span class="c1"># SELECT FIRST_VALUE(TABLE.COLUMN IGNORE|RESPECT NULLS) OVER ...</span> -</span><span id="Parser-3955"><a href="#Parser-3955"><span class="linenos">3955</span></a> -</span><span id="Parser-3956"><a href="#Parser-3956"><span class="linenos">3956</span></a> <span class="c1"># The below changes handle</span> -</span><span id="Parser-3957"><a href="#Parser-3957"><span class="linenos">3957</span></a> <span class="c1"># SELECT FIRST_VALUE(TABLE.COLUMN) IGNORE|RESPECT NULLS OVER ...</span> -</span><span id="Parser-3958"><a href="#Parser-3958"><span class="linenos">3958</span></a> -</span><span id="Parser-3959"><a href="#Parser-3959"><span class="linenos">3959</span></a> <span class="c1"># Oracle allows both formats</span> -</span><span id="Parser-3960"><a href="#Parser-3960"><span class="linenos">3960</span></a> <span class="c1"># (https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/img_text/first_value.html)</span> -</span><span id="Parser-3961"><a href="#Parser-3961"><span class="linenos">3961</span></a> <span class="c1"># and Snowflake chose to do the same for familiarity</span> -</span><span id="Parser-3962"><a href="#Parser-3962"><span class="linenos">3962</span></a> <span class="c1"># https://docs.snowflake.com/en/sql-reference/functions/first_value.html#usage-notes</span> -</span><span id="Parser-3963"><a href="#Parser-3963"><span class="linenos">3963</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_respect_or_ignore_nulls</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-3964"><a href="#Parser-3964"><span class="linenos">3964</span></a> -</span><span id="Parser-3965"><a href="#Parser-3965"><span class="linenos">3965</span></a> <span class="c1"># bigquery select from window x AS (partition by ...)</span> -</span><span id="Parser-3966"><a href="#Parser-3966"><span class="linenos">3966</span></a> <span class="k">if</span> <span class="n">alias</span><span class="p">:</span> -</span><span id="Parser-3967"><a href="#Parser-3967"><span class="linenos">3967</span></a> <span class="n">over</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-3968"><a href="#Parser-3968"><span class="linenos">3968</span></a> <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">ALIAS</span><span class="p">)</span> -</span><span id="Parser-3969"><a href="#Parser-3969"><span class="linenos">3969</span></a> <span class="k">elif</span> <span class="ow">not</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">WINDOW_BEFORE_PAREN_TOKENS</span><span class="p">):</span> -</span><span id="Parser-3970"><a href="#Parser-3970"><span class="linenos">3970</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-3971"><a href="#Parser-3971"><span class="linenos">3971</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-3972"><a href="#Parser-3972"><span class="linenos">3972</span></a> <span class="n">over</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="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Parser-3973"><a href="#Parser-3973"><span class="linenos">3973</span></a> -</span><span id="Parser-3974"><a href="#Parser-3974"><span class="linenos">3974</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">):</span> -</span><span id="Parser-3975"><a href="#Parser-3975"><span class="linenos">3975</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><span id="Parser-3976"><a href="#Parser-3976"><span class="linenos">3976</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="kc">False</span><span class="p">),</span> <span class="n">over</span><span class="o">=</span><span class="n">over</span> -</span><span id="Parser-3977"><a href="#Parser-3977"><span class="linenos">3977</span></a> <span class="p">)</span> -</span><span id="Parser-3978"><a href="#Parser-3978"><span class="linenos">3978</span></a> -</span><span id="Parser-3979"><a href="#Parser-3979"><span class="linenos">3979</span></a> <span class="n">window_alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">tokens</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">WINDOW_ALIAS_TOKENS</span><span class="p">)</span> -</span><span id="Parser-3980"><a href="#Parser-3980"><span class="linenos">3980</span></a> -</span><span id="Parser-3981"><a href="#Parser-3981"><span class="linenos">3981</span></a> <span class="n">first</span> <span class="o">=</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">FIRST</span><span class="p">)</span> -</span><span id="Parser-3982"><a href="#Parser-3982"><span class="linenos">3982</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LAST"</span><span class="p">):</span> -</span><span id="Parser-3983"><a href="#Parser-3983"><span class="linenos">3983</span></a> <span class="n">first</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-3984"><a href="#Parser-3984"><span class="linenos">3984</span></a> -</span><span id="Parser-3985"><a href="#Parser-3985"><span class="linenos">3985</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition_by</span><span class="p">()</span> -</span><span id="Parser-3986"><a href="#Parser-3986"><span class="linenos">3986</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">()</span> -</span><span id="Parser-3987"><a href="#Parser-3987"><span class="linenos">3987</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RANGE</span><span class="p">))</span> <span class="ow">and</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><span id="Parser-3888"><a href="#Parser-3888"><span class="linenos">3888</span></a> <span class="k">def</span> <span class="nf">_parse_join_hint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">func_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">JoinHint</span><span class="p">:</span> +</span><span id="Parser-3889"><a href="#Parser-3889"><span class="linenos">3889</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">)</span> +</span><span id="Parser-3890"><a href="#Parser-3890"><span class="linenos">3890</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">JoinHint</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">func_name</span><span class="o">.</span><span class="n">upper</span><span class="p">(),</span> <span class="n">expressions</span><span class="o">=</span><span class="n">args</span><span class="p">)</span> +</span><span id="Parser-3891"><a href="#Parser-3891"><span class="linenos">3891</span></a> +</span><span id="Parser-3892"><a href="#Parser-3892"><span class="linenos">3892</span></a> <span class="k">def</span> <span class="nf">_parse_substring</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">Substring</span><span class="p">:</span> +</span><span id="Parser-3893"><a href="#Parser-3893"><span class="linenos">3893</span></a> <span class="c1"># Postgres supports the form: substring(string [from int] [for int])</span> +</span><span id="Parser-3894"><a href="#Parser-3894"><span class="linenos">3894</span></a> <span class="c1"># https://www.postgresql.org/docs/9.1/functions-string.html @ Table 9-6</span> +</span><span id="Parser-3895"><a href="#Parser-3895"><span class="linenos">3895</span></a> +</span><span id="Parser-3896"><a href="#Parser-3896"><span class="linenos">3896</span></a> <span class="n">args</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">)</span> +</span><span id="Parser-3897"><a href="#Parser-3897"><span class="linenos">3897</span></a> +</span><span id="Parser-3898"><a href="#Parser-3898"><span class="linenos">3898</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">FROM</span><span class="p">):</span> +</span><span id="Parser-3899"><a href="#Parser-3899"><span class="linenos">3899</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> +</span><span id="Parser-3900"><a href="#Parser-3900"><span class="linenos">3900</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">FOR</span><span class="p">):</span> +</span><span id="Parser-3901"><a href="#Parser-3901"><span class="linenos">3901</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">())</span> +</span><span id="Parser-3902"><a href="#Parser-3902"><span class="linenos">3902</span></a> +</span><span id="Parser-3903"><a href="#Parser-3903"><span class="linenos">3903</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Substring</span><span class="o">.</span><span class="n">from_arg_list</span><span class="p">(</span><span class="n">args</span><span class="p">),</span> <span class="n">args</span><span class="p">)</span> +</span><span id="Parser-3904"><a href="#Parser-3904"><span class="linenos">3904</span></a> +</span><span id="Parser-3905"><a href="#Parser-3905"><span class="linenos">3905</span></a> <span class="k">def</span> <span class="nf">_parse_trim</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">Trim</span><span class="p">:</span> +</span><span id="Parser-3906"><a href="#Parser-3906"><span class="linenos">3906</span></a> <span class="c1"># https://www.w3resource.com/sql/character-functions/trim.php</span> +</span><span id="Parser-3907"><a href="#Parser-3907"><span class="linenos">3907</span></a> <span class="c1"># https://docs.oracle.com/javadb/10.8.3.0/ref/rreftrimfunc.html</span> +</span><span id="Parser-3908"><a href="#Parser-3908"><span class="linenos">3908</span></a> +</span><span id="Parser-3909"><a href="#Parser-3909"><span class="linenos">3909</span></a> <span class="n">position</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-3910"><a href="#Parser-3910"><span class="linenos">3910</span></a> <span class="n">collation</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-3911"><a href="#Parser-3911"><span class="linenos">3911</span></a> +</span><span id="Parser-3912"><a href="#Parser-3912"><span class="linenos">3912</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">TRIM_TYPES</span><span class="p">):</span> +</span><span id="Parser-3913"><a href="#Parser-3913"><span class="linenos">3913</span></a> <span class="n">position</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="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Parser-3914"><a href="#Parser-3914"><span class="linenos">3914</span></a> +</span><span id="Parser-3915"><a href="#Parser-3915"><span class="linenos">3915</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="Parser-3916"><a href="#Parser-3916"><span class="linenos">3916</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FROM</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMA</span><span class="p">)):</span> +</span><span id="Parser-3917"><a href="#Parser-3917"><span class="linenos">3917</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="Parser-3918"><a href="#Parser-3918"><span class="linenos">3918</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3919"><a href="#Parser-3919"><span class="linenos">3919</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span> +</span><span id="Parser-3920"><a href="#Parser-3920"><span class="linenos">3920</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-3921"><a href="#Parser-3921"><span class="linenos">3921</span></a> +</span><span id="Parser-3922"><a href="#Parser-3922"><span class="linenos">3922</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">COLLATE</span><span class="p">):</span> +</span><span id="Parser-3923"><a href="#Parser-3923"><span class="linenos">3923</span></a> <span class="n">collation</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="Parser-3924"><a href="#Parser-3924"><span class="linenos">3924</span></a> +</span><span id="Parser-3925"><a href="#Parser-3925"><span class="linenos">3925</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><span id="Parser-3926"><a href="#Parser-3926"><span class="linenos">3926</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Trim</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">position</span><span class="o">=</span><span class="n">position</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">collation</span><span class="o">=</span><span class="n">collation</span> +</span><span id="Parser-3927"><a href="#Parser-3927"><span class="linenos">3927</span></a> <span class="p">)</span> +</span><span id="Parser-3928"><a href="#Parser-3928"><span class="linenos">3928</span></a> +</span><span id="Parser-3929"><a href="#Parser-3929"><span class="linenos">3929</span></a> <span class="k">def</span> <span class="nf">_parse_window_clause</span><span class="p">(</span><span class="bp">self</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">t</span><span class="o">.</span><span class="n">List</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><span id="Parser-3930"><a href="#Parser-3930"><span class="linenos">3930</span></a> <span class="k">return</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">WINDOW</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_named_window</span><span class="p">)</span> +</span><span id="Parser-3931"><a href="#Parser-3931"><span class="linenos">3931</span></a> +</span><span id="Parser-3932"><a href="#Parser-3932"><span class="linenos">3932</span></a> <span class="k">def</span> <span class="nf">_parse_named_window</span><span class="p">(</span><span class="bp">self</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="Parser-3933"><a href="#Parser-3933"><span class="linenos">3933</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(),</span> <span class="n">alias</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-3934"><a href="#Parser-3934"><span class="linenos">3934</span></a> +</span><span id="Parser-3935"><a href="#Parser-3935"><span class="linenos">3935</span></a> <span class="k">def</span> <span class="nf">_parse_respect_or_ignore_nulls</span><span class="p">(</span> +</span><span id="Parser-3936"><a href="#Parser-3936"><span class="linenos">3936</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><span id="Parser-3937"><a href="#Parser-3937"><span class="linenos">3937</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="Parser-3938"><a href="#Parser-3938"><span class="linenos">3938</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"IGNORE"</span><span class="p">,</span> <span class="s2">"NULLS"</span><span class="p">):</span> +</span><span id="Parser-3939"><a href="#Parser-3939"><span class="linenos">3939</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">IgnoreNulls</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-3940"><a href="#Parser-3940"><span class="linenos">3940</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"RESPECT"</span><span class="p">,</span> <span class="s2">"NULLS"</span><span class="p">):</span> +</span><span id="Parser-3941"><a href="#Parser-3941"><span class="linenos">3941</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">RespectNulls</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-3942"><a href="#Parser-3942"><span class="linenos">3942</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-3943"><a href="#Parser-3943"><span class="linenos">3943</span></a> +</span><span id="Parser-3944"><a href="#Parser-3944"><span class="linenos">3944</span></a> <span class="k">def</span> <span class="nf">_parse_window</span><span class="p">(</span> +</span><span id="Parser-3945"><a href="#Parser-3945"><span class="linenos">3945</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="n">alias</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-3946"><a href="#Parser-3946"><span class="linenos">3946</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="Parser-3947"><a href="#Parser-3947"><span class="linenos">3947</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FILTER</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">):</span> +</span><span id="Parser-3948"><a href="#Parser-3948"><span class="linenos">3948</span></a> <span class="n">this</span> <span class="o">=</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">Filter</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_where</span><span class="p">())</span> +</span><span id="Parser-3949"><a href="#Parser-3949"><span class="linenos">3949</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-3950"><a href="#Parser-3950"><span class="linenos">3950</span></a> +</span><span id="Parser-3951"><a href="#Parser-3951"><span class="linenos">3951</span></a> <span class="c1"># T-SQL allows the OVER (...) syntax after WITHIN GROUP.</span> +</span><span id="Parser-3952"><a href="#Parser-3952"><span class="linenos">3952</span></a> <span class="c1"># https://learn.microsoft.com/en-us/sql/t-sql/functions/percentile-disc-transact-sql?view=sql-server-ver16</span> +</span><span id="Parser-3953"><a href="#Parser-3953"><span class="linenos">3953</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"WITHIN"</span><span class="p">,</span> <span class="s2">"GROUP"</span><span class="p">):</span> +</span><span id="Parser-3954"><a href="#Parser-3954"><span class="linenos">3954</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">)</span> +</span><span id="Parser-3955"><a href="#Parser-3955"><span class="linenos">3955</span></a> <span class="n">this</span> <span class="o">=</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">WithinGroup</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">order</span><span class="p">)</span> +</span><span id="Parser-3956"><a href="#Parser-3956"><span class="linenos">3956</span></a> +</span><span id="Parser-3957"><a href="#Parser-3957"><span class="linenos">3957</span></a> <span class="c1"># SQL spec defines an optional [ { IGNORE | RESPECT } NULLS ] OVER</span> +</span><span id="Parser-3958"><a href="#Parser-3958"><span class="linenos">3958</span></a> <span class="c1"># Some dialects choose to implement and some do not.</span> +</span><span id="Parser-3959"><a href="#Parser-3959"><span class="linenos">3959</span></a> <span class="c1"># https://dev.mysql.com/doc/refman/8.0/en/window-function-descriptions.html</span> +</span><span id="Parser-3960"><a href="#Parser-3960"><span class="linenos">3960</span></a> +</span><span id="Parser-3961"><a href="#Parser-3961"><span class="linenos">3961</span></a> <span class="c1"># There is some code above in _parse_lambda that handles</span> +</span><span id="Parser-3962"><a href="#Parser-3962"><span class="linenos">3962</span></a> <span class="c1"># SELECT FIRST_VALUE(TABLE.COLUMN IGNORE|RESPECT NULLS) OVER ...</span> +</span><span id="Parser-3963"><a href="#Parser-3963"><span class="linenos">3963</span></a> +</span><span id="Parser-3964"><a href="#Parser-3964"><span class="linenos">3964</span></a> <span class="c1"># The below changes handle</span> +</span><span id="Parser-3965"><a href="#Parser-3965"><span class="linenos">3965</span></a> <span class="c1"># SELECT FIRST_VALUE(TABLE.COLUMN) IGNORE|RESPECT NULLS OVER ...</span> +</span><span id="Parser-3966"><a href="#Parser-3966"><span class="linenos">3966</span></a> +</span><span id="Parser-3967"><a href="#Parser-3967"><span class="linenos">3967</span></a> <span class="c1"># Oracle allows both formats</span> +</span><span id="Parser-3968"><a href="#Parser-3968"><span class="linenos">3968</span></a> <span class="c1"># (https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/img_text/first_value.html)</span> +</span><span id="Parser-3969"><a href="#Parser-3969"><span class="linenos">3969</span></a> <span class="c1"># and Snowflake chose to do the same for familiarity</span> +</span><span id="Parser-3970"><a href="#Parser-3970"><span class="linenos">3970</span></a> <span class="c1"># https://docs.snowflake.com/en/sql-reference/functions/first_value.html#usage-notes</span> +</span><span id="Parser-3971"><a href="#Parser-3971"><span class="linenos">3971</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_respect_or_ignore_nulls</span><span class="p">(</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-3972"><a href="#Parser-3972"><span class="linenos">3972</span></a> +</span><span id="Parser-3973"><a href="#Parser-3973"><span class="linenos">3973</span></a> <span class="c1"># bigquery select from window x AS (partition by ...)</span> +</span><span id="Parser-3974"><a href="#Parser-3974"><span class="linenos">3974</span></a> <span class="k">if</span> <span class="n">alias</span><span class="p">:</span> +</span><span id="Parser-3975"><a href="#Parser-3975"><span class="linenos">3975</span></a> <span class="n">over</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-3976"><a href="#Parser-3976"><span class="linenos">3976</span></a> <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">ALIAS</span><span class="p">)</span> +</span><span id="Parser-3977"><a href="#Parser-3977"><span class="linenos">3977</span></a> <span class="k">elif</span> <span class="ow">not</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">WINDOW_BEFORE_PAREN_TOKENS</span><span class="p">):</span> +</span><span id="Parser-3978"><a href="#Parser-3978"><span class="linenos">3978</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-3979"><a href="#Parser-3979"><span class="linenos">3979</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-3980"><a href="#Parser-3980"><span class="linenos">3980</span></a> <span class="n">over</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="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Parser-3981"><a href="#Parser-3981"><span class="linenos">3981</span></a> +</span><span id="Parser-3982"><a href="#Parser-3982"><span class="linenos">3982</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">):</span> +</span><span id="Parser-3983"><a href="#Parser-3983"><span class="linenos">3983</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><span id="Parser-3984"><a href="#Parser-3984"><span class="linenos">3984</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="kc">False</span><span class="p">),</span> <span class="n">over</span><span class="o">=</span><span class="n">over</span> +</span><span id="Parser-3985"><a href="#Parser-3985"><span class="linenos">3985</span></a> <span class="p">)</span> +</span><span id="Parser-3986"><a href="#Parser-3986"><span class="linenos">3986</span></a> +</span><span id="Parser-3987"><a href="#Parser-3987"><span class="linenos">3987</span></a> <span class="n">window_alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">tokens</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">WINDOW_ALIAS_TOKENS</span><span class="p">)</span> </span><span id="Parser-3988"><a href="#Parser-3988"><span class="linenos">3988</span></a> -</span><span id="Parser-3989"><a href="#Parser-3989"><span class="linenos">3989</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> -</span><span id="Parser-3990"><a href="#Parser-3990"><span class="linenos">3990</span></a> <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">BETWEEN</span><span class="p">)</span> -</span><span id="Parser-3991"><a href="#Parser-3991"><span class="linenos">3991</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window_spec</span><span class="p">()</span> -</span><span id="Parser-3992"><a href="#Parser-3992"><span class="linenos">3992</span></a> <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">AND</span><span class="p">)</span> -</span><span id="Parser-3993"><a href="#Parser-3993"><span class="linenos">3993</span></a> <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window_spec</span><span class="p">()</span> -</span><span id="Parser-3994"><a href="#Parser-3994"><span class="linenos">3994</span></a> -</span><span id="Parser-3995"><a href="#Parser-3995"><span class="linenos">3995</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-3996"><a href="#Parser-3996"><span class="linenos">3996</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WindowSpec</span><span class="p">,</span> -</span><span id="Parser-3997"><a href="#Parser-3997"><span class="linenos">3997</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> -</span><span id="Parser-3998"><a href="#Parser-3998"><span class="linenos">3998</span></a> <span class="n">start</span><span class="o">=</span><span class="n">start</span><span class="p">[</span><span class="s2">"value"</span><span class="p">],</span> -</span><span id="Parser-3999"><a href="#Parser-3999"><span class="linenos">3999</span></a> <span class="n">start_side</span><span class="o">=</span><span class="n">start</span><span class="p">[</span><span class="s2">"side"</span><span class="p">],</span> -</span><span id="Parser-4000"><a href="#Parser-4000"><span class="linenos">4000</span></a> <span class="n">end</span><span class="o">=</span><span class="n">end</span><span class="p">[</span><span class="s2">"value"</span><span class="p">],</span> -</span><span id="Parser-4001"><a href="#Parser-4001"><span class="linenos">4001</span></a> <span class="n">end_side</span><span class="o">=</span><span class="n">end</span><span class="p">[</span><span class="s2">"side"</span><span class="p">],</span> -</span><span id="Parser-4002"><a href="#Parser-4002"><span class="linenos">4002</span></a> <span class="p">)</span> -</span><span id="Parser-4003"><a href="#Parser-4003"><span class="linenos">4003</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-4004"><a href="#Parser-4004"><span class="linenos">4004</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-4005"><a href="#Parser-4005"><span class="linenos">4005</span></a> -</span><span id="Parser-4006"><a href="#Parser-4006"><span class="linenos">4006</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="Parser-4007"><a href="#Parser-4007"><span class="linenos">4007</span></a> -</span><span id="Parser-4008"><a href="#Parser-4008"><span class="linenos">4008</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><span id="Parser-4009"><a href="#Parser-4009"><span class="linenos">4009</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">,</span> -</span><span id="Parser-4010"><a href="#Parser-4010"><span class="linenos">4010</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="Parser-4011"><a href="#Parser-4011"><span class="linenos">4011</span></a> <span class="n">partition_by</span><span class="o">=</span><span class="n">partition</span><span class="p">,</span> -</span><span id="Parser-4012"><a href="#Parser-4012"><span class="linenos">4012</span></a> <span class="n">order</span><span class="o">=</span><span class="n">order</span><span class="p">,</span> -</span><span id="Parser-4013"><a href="#Parser-4013"><span class="linenos">4013</span></a> <span class="n">spec</span><span class="o">=</span><span class="n">spec</span><span class="p">,</span> -</span><span id="Parser-4014"><a href="#Parser-4014"><span class="linenos">4014</span></a> <span class="n">alias</span><span class="o">=</span><span class="n">window_alias</span><span class="p">,</span> -</span><span id="Parser-4015"><a href="#Parser-4015"><span class="linenos">4015</span></a> <span class="n">over</span><span class="o">=</span><span class="n">over</span><span class="p">,</span> -</span><span id="Parser-4016"><a href="#Parser-4016"><span class="linenos">4016</span></a> <span class="n">first</span><span class="o">=</span><span class="n">first</span><span class="p">,</span> -</span><span id="Parser-4017"><a href="#Parser-4017"><span class="linenos">4017</span></a> <span class="p">)</span> -</span><span id="Parser-4018"><a href="#Parser-4018"><span class="linenos">4018</span></a> -</span><span id="Parser-4019"><a href="#Parser-4019"><span class="linenos">4019</span></a> <span class="k">def</span> <span class="nf">_parse_window_spec</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]]:</span> -</span><span id="Parser-4020"><a href="#Parser-4020"><span class="linenos">4020</span></a> <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">BETWEEN</span><span class="p">)</span> -</span><span id="Parser-4021"><a href="#Parser-4021"><span class="linenos">4021</span></a> -</span><span id="Parser-4022"><a href="#Parser-4022"><span class="linenos">4022</span></a> <span class="k">return</span> <span class="p">{</span> -</span><span id="Parser-4023"><a href="#Parser-4023"><span class="linenos">4023</span></a> <span class="s2">"value"</span><span class="p">:</span> <span class="p">(</span> -</span><span id="Parser-4024"><a href="#Parser-4024"><span class="linenos">4024</span></a> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"UNBOUNDED"</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"UNBOUNDED"</span><span class="p">)</span> -</span><span id="Parser-4025"><a href="#Parser-4025"><span class="linenos">4025</span></a> <span class="ow">or</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CURRENT"</span><span class="p">,</span> <span class="s2">"ROW"</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"CURRENT ROW"</span><span class="p">)</span> -</span><span id="Parser-4026"><a href="#Parser-4026"><span class="linenos">4026</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> -</span><span id="Parser-4027"><a href="#Parser-4027"><span class="linenos">4027</span></a> <span class="p">),</span> -</span><span id="Parser-4028"><a href="#Parser-4028"><span class="linenos">4028</span></a> <span class="s2">"side"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">WINDOW_SIDES</span><span class="p">)</span> <span class="ow">and</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="Parser-4029"><a href="#Parser-4029"><span class="linenos">4029</span></a> <span class="p">}</span> -</span><span id="Parser-4030"><a href="#Parser-4030"><span class="linenos">4030</span></a> -</span><span id="Parser-4031"><a href="#Parser-4031"><span class="linenos">4031</span></a> <span class="k">def</span> <span class="nf">_parse_alias</span><span class="p">(</span> -</span><span id="Parser-4032"><a href="#Parser-4032"><span class="linenos">4032</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="n">explicit</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-4033"><a href="#Parser-4033"><span class="linenos">4033</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="Parser-4034"><a href="#Parser-4034"><span class="linenos">4034</span></a> <span class="n">any_token</span> <span class="o">=</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">ALIAS</span><span class="p">)</span> -</span><span id="Parser-4035"><a href="#Parser-4035"><span class="linenos">4035</span></a> -</span><span id="Parser-4036"><a href="#Parser-4036"><span class="linenos">4036</span></a> <span class="k">if</span> <span class="n">explicit</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">any_token</span><span class="p">:</span> -</span><span id="Parser-4037"><a href="#Parser-4037"><span class="linenos">4037</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-3989"><a href="#Parser-3989"><span class="linenos">3989</span></a> <span class="n">first</span> <span class="o">=</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">FIRST</span><span class="p">)</span> +</span><span id="Parser-3990"><a href="#Parser-3990"><span class="linenos">3990</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"LAST"</span><span class="p">):</span> +</span><span id="Parser-3991"><a href="#Parser-3991"><span class="linenos">3991</span></a> <span class="n">first</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-3992"><a href="#Parser-3992"><span class="linenos">3992</span></a> +</span><span id="Parser-3993"><a href="#Parser-3993"><span class="linenos">3993</span></a> <span class="n">partition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition_by</span><span class="p">()</span> +</span><span id="Parser-3994"><a href="#Parser-3994"><span class="linenos">3994</span></a> <span class="n">order</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_order</span><span class="p">()</span> +</span><span id="Parser-3995"><a href="#Parser-3995"><span class="linenos">3995</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">((</span><span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RANGE</span><span class="p">))</span> <span class="ow">and</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><span id="Parser-3996"><a href="#Parser-3996"><span class="linenos">3996</span></a> +</span><span id="Parser-3997"><a href="#Parser-3997"><span class="linenos">3997</span></a> <span class="k">if</span> <span class="n">kind</span><span class="p">:</span> +</span><span id="Parser-3998"><a href="#Parser-3998"><span class="linenos">3998</span></a> <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">BETWEEN</span><span class="p">)</span> +</span><span id="Parser-3999"><a href="#Parser-3999"><span class="linenos">3999</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window_spec</span><span class="p">()</span> +</span><span id="Parser-4000"><a href="#Parser-4000"><span class="linenos">4000</span></a> <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">AND</span><span class="p">)</span> +</span><span id="Parser-4001"><a href="#Parser-4001"><span class="linenos">4001</span></a> <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_window_spec</span><span class="p">()</span> +</span><span id="Parser-4002"><a href="#Parser-4002"><span class="linenos">4002</span></a> +</span><span id="Parser-4003"><a href="#Parser-4003"><span class="linenos">4003</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-4004"><a href="#Parser-4004"><span class="linenos">4004</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">WindowSpec</span><span class="p">,</span> +</span><span id="Parser-4005"><a href="#Parser-4005"><span class="linenos">4005</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">,</span> +</span><span id="Parser-4006"><a href="#Parser-4006"><span class="linenos">4006</span></a> <span class="n">start</span><span class="o">=</span><span class="n">start</span><span class="p">[</span><span class="s2">"value"</span><span class="p">],</span> +</span><span id="Parser-4007"><a href="#Parser-4007"><span class="linenos">4007</span></a> <span class="n">start_side</span><span class="o">=</span><span class="n">start</span><span class="p">[</span><span class="s2">"side"</span><span class="p">],</span> +</span><span id="Parser-4008"><a href="#Parser-4008"><span class="linenos">4008</span></a> <span class="n">end</span><span class="o">=</span><span class="n">end</span><span class="p">[</span><span class="s2">"value"</span><span class="p">],</span> +</span><span id="Parser-4009"><a href="#Parser-4009"><span class="linenos">4009</span></a> <span class="n">end_side</span><span class="o">=</span><span class="n">end</span><span class="p">[</span><span class="s2">"side"</span><span class="p">],</span> +</span><span id="Parser-4010"><a href="#Parser-4010"><span class="linenos">4010</span></a> <span class="p">)</span> +</span><span id="Parser-4011"><a href="#Parser-4011"><span class="linenos">4011</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-4012"><a href="#Parser-4012"><span class="linenos">4012</span></a> <span class="n">spec</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-4013"><a href="#Parser-4013"><span class="linenos">4013</span></a> +</span><span id="Parser-4014"><a href="#Parser-4014"><span class="linenos">4014</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-4015"><a href="#Parser-4015"><span class="linenos">4015</span></a> +</span><span id="Parser-4016"><a href="#Parser-4016"><span class="linenos">4016</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><span id="Parser-4017"><a href="#Parser-4017"><span class="linenos">4017</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Window</span><span class="p">,</span> +</span><span id="Parser-4018"><a href="#Parser-4018"><span class="linenos">4018</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="Parser-4019"><a href="#Parser-4019"><span class="linenos">4019</span></a> <span class="n">partition_by</span><span class="o">=</span><span class="n">partition</span><span class="p">,</span> +</span><span id="Parser-4020"><a href="#Parser-4020"><span class="linenos">4020</span></a> <span class="n">order</span><span class="o">=</span><span class="n">order</span><span class="p">,</span> +</span><span id="Parser-4021"><a href="#Parser-4021"><span class="linenos">4021</span></a> <span class="n">spec</span><span class="o">=</span><span class="n">spec</span><span class="p">,</span> +</span><span id="Parser-4022"><a href="#Parser-4022"><span class="linenos">4022</span></a> <span class="n">alias</span><span class="o">=</span><span class="n">window_alias</span><span class="p">,</span> +</span><span id="Parser-4023"><a href="#Parser-4023"><span class="linenos">4023</span></a> <span class="n">over</span><span class="o">=</span><span class="n">over</span><span class="p">,</span> +</span><span id="Parser-4024"><a href="#Parser-4024"><span class="linenos">4024</span></a> <span class="n">first</span><span class="o">=</span><span class="n">first</span><span class="p">,</span> +</span><span id="Parser-4025"><a href="#Parser-4025"><span class="linenos">4025</span></a> <span class="p">)</span> +</span><span id="Parser-4026"><a href="#Parser-4026"><span class="linenos">4026</span></a> +</span><span id="Parser-4027"><a href="#Parser-4027"><span class="linenos">4027</span></a> <span class="k">def</span> <span class="nf">_parse_window_spec</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]]:</span> +</span><span id="Parser-4028"><a href="#Parser-4028"><span class="linenos">4028</span></a> <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">BETWEEN</span><span class="p">)</span> +</span><span id="Parser-4029"><a href="#Parser-4029"><span class="linenos">4029</span></a> +</span><span id="Parser-4030"><a href="#Parser-4030"><span class="linenos">4030</span></a> <span class="k">return</span> <span class="p">{</span> +</span><span id="Parser-4031"><a href="#Parser-4031"><span class="linenos">4031</span></a> <span class="s2">"value"</span><span class="p">:</span> <span class="p">(</span> +</span><span id="Parser-4032"><a href="#Parser-4032"><span class="linenos">4032</span></a> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"UNBOUNDED"</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"UNBOUNDED"</span><span class="p">)</span> +</span><span id="Parser-4033"><a href="#Parser-4033"><span class="linenos">4033</span></a> <span class="ow">or</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CURRENT"</span><span class="p">,</span> <span class="s2">"ROW"</span><span class="p">)</span> <span class="ow">and</span> <span class="s2">"CURRENT ROW"</span><span class="p">)</span> +</span><span id="Parser-4034"><a href="#Parser-4034"><span class="linenos">4034</span></a> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_bitwise</span><span class="p">()</span> +</span><span id="Parser-4035"><a href="#Parser-4035"><span class="linenos">4035</span></a> <span class="p">),</span> +</span><span id="Parser-4036"><a href="#Parser-4036"><span class="linenos">4036</span></a> <span class="s2">"side"</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">WINDOW_SIDES</span><span class="p">)</span> <span class="ow">and</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="Parser-4037"><a href="#Parser-4037"><span class="linenos">4037</span></a> <span class="p">}</span> </span><span id="Parser-4038"><a href="#Parser-4038"><span class="linenos">4038</span></a> -</span><span id="Parser-4039"><a href="#Parser-4039"><span class="linenos">4039</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_PAREN</span><span class="p">):</span> -</span><span id="Parser-4040"><a href="#Parser-4040"><span class="linenos">4040</span></a> <span class="n">aliases</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-4041"><a href="#Parser-4041"><span class="linenos">4041</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Aliases</span><span class="p">,</span> -</span><span id="Parser-4042"><a href="#Parser-4042"><span class="linenos">4042</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="Parser-4043"><a href="#Parser-4043"><span class="linenos">4043</span></a> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="p">)),</span> -</span><span id="Parser-4044"><a href="#Parser-4044"><span class="linenos">4044</span></a> <span class="p">)</span> -</span><span id="Parser-4045"><a href="#Parser-4045"><span class="linenos">4045</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">(</span><span class="n">aliases</span><span class="p">)</span> -</span><span id="Parser-4046"><a href="#Parser-4046"><span class="linenos">4046</span></a> <span class="k">return</span> <span class="n">aliases</span> -</span><span id="Parser-4047"><a href="#Parser-4047"><span class="linenos">4047</span></a> -</span><span id="Parser-4048"><a href="#Parser-4048"><span class="linenos">4048</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="p">)</span> -</span><span id="Parser-4049"><a href="#Parser-4049"><span class="linenos">4049</span></a> -</span><span id="Parser-4050"><a href="#Parser-4050"><span class="linenos">4050</span></a> <span class="k">if</span> <span class="n">alias</span><span class="p">:</span> -</span><span id="Parser-4051"><a href="#Parser-4051"><span class="linenos">4051</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">Alias</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> -</span><span id="Parser-4052"><a href="#Parser-4052"><span class="linenos">4052</span></a> -</span><span id="Parser-4053"><a href="#Parser-4053"><span class="linenos">4053</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-4054"><a href="#Parser-4054"><span class="linenos">4054</span></a> -</span><span id="Parser-4055"><a href="#Parser-4055"><span class="linenos">4055</span></a> <span class="k">def</span> <span class="nf">_parse_id_var</span><span class="p">(</span> -</span><span id="Parser-4056"><a href="#Parser-4056"><span class="linenos">4056</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Parser-4057"><a href="#Parser-4057"><span class="linenos">4057</span></a> <span class="n">any_token</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Parser-4058"><a href="#Parser-4058"><span class="linenos">4058</span></a> <span class="n">tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Parser-4059"><a href="#Parser-4059"><span class="linenos">4059</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="Parser-4060"><a href="#Parser-4060"><span class="linenos">4060</span></a> <span class="n">identifier</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_identifier</span><span class="p">()</span> -</span><span id="Parser-4061"><a href="#Parser-4061"><span class="linenos">4061</span></a> -</span><span id="Parser-4062"><a href="#Parser-4062"><span class="linenos">4062</span></a> <span class="k">if</span> <span class="n">identifier</span><span class="p">:</span> -</span><span id="Parser-4063"><a href="#Parser-4063"><span class="linenos">4063</span></a> <span class="k">return</span> <span class="n">identifier</span> -</span><span id="Parser-4064"><a href="#Parser-4064"><span class="linenos">4064</span></a> -</span><span id="Parser-4065"><a href="#Parser-4065"><span class="linenos">4065</span></a> <span class="k">if</span> <span class="p">(</span><span class="n">any_token</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</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="n">tokens</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">ID_VAR_TOKENS</span><span class="p">):</span> -</span><span id="Parser-4066"><a href="#Parser-4066"><span class="linenos">4066</span></a> <span class="n">quoted</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">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span> -</span><span id="Parser-4067"><a href="#Parser-4067"><span class="linenos">4067</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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 class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">)</span> -</span><span id="Parser-4068"><a href="#Parser-4068"><span class="linenos">4068</span></a> -</span><span id="Parser-4069"><a href="#Parser-4069"><span class="linenos">4069</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-4070"><a href="#Parser-4070"><span class="linenos">4070</span></a> -</span><span id="Parser-4071"><a href="#Parser-4071"><span class="linenos">4071</span></a> <span class="k">def</span> <span class="nf">_parse_string</span><span class="p">(</span><span class="bp">self</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="Parser-4072"><a href="#Parser-4072"><span class="linenos">4072</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">STRING</span><span class="p">):</span> -</span><span id="Parser-4073"><a href="#Parser-4073"><span class="linenos">4073</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> -</span><span id="Parser-4074"><a href="#Parser-4074"><span class="linenos">4074</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_placeholder</span><span class="p">()</span> -</span><span id="Parser-4075"><a href="#Parser-4075"><span class="linenos">4075</span></a> -</span><span id="Parser-4076"><a href="#Parser-4076"><span class="linenos">4076</span></a> <span class="k">def</span> <span class="nf">_parse_string_as_identifier</span><span class="p">(</span><span class="bp">self</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">Identifier</span><span class="p">]:</span> -</span><span id="Parser-4077"><a href="#Parser-4077"><span class="linenos">4077</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</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">STRING</span><span class="p">)</span> <span class="ow">and</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 class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-4039"><a href="#Parser-4039"><span class="linenos">4039</span></a> <span class="k">def</span> <span class="nf">_parse_alias</span><span class="p">(</span> +</span><span id="Parser-4040"><a href="#Parser-4040"><span class="linenos">4040</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="n">explicit</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-4041"><a href="#Parser-4041"><span class="linenos">4041</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="Parser-4042"><a href="#Parser-4042"><span class="linenos">4042</span></a> <span class="n">any_token</span> <span class="o">=</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">ALIAS</span><span class="p">)</span> +</span><span id="Parser-4043"><a href="#Parser-4043"><span class="linenos">4043</span></a> +</span><span id="Parser-4044"><a href="#Parser-4044"><span class="linenos">4044</span></a> <span class="k">if</span> <span class="n">explicit</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">any_token</span><span class="p">:</span> +</span><span id="Parser-4045"><a href="#Parser-4045"><span class="linenos">4045</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-4046"><a href="#Parser-4046"><span class="linenos">4046</span></a> +</span><span id="Parser-4047"><a href="#Parser-4047"><span class="linenos">4047</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_PAREN</span><span class="p">):</span> +</span><span id="Parser-4048"><a href="#Parser-4048"><span class="linenos">4048</span></a> <span class="n">aliases</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-4049"><a href="#Parser-4049"><span class="linenos">4049</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Aliases</span><span class="p">,</span> +</span><span id="Parser-4050"><a href="#Parser-4050"><span class="linenos">4050</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="Parser-4051"><a href="#Parser-4051"><span class="linenos">4051</span></a> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="p">)),</span> +</span><span id="Parser-4052"><a href="#Parser-4052"><span class="linenos">4052</span></a> <span class="p">)</span> +</span><span id="Parser-4053"><a href="#Parser-4053"><span class="linenos">4053</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">(</span><span class="n">aliases</span><span class="p">)</span> +</span><span id="Parser-4054"><a href="#Parser-4054"><span class="linenos">4054</span></a> <span class="k">return</span> <span class="n">aliases</span> +</span><span id="Parser-4055"><a href="#Parser-4055"><span class="linenos">4055</span></a> +</span><span id="Parser-4056"><a href="#Parser-4056"><span class="linenos">4056</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">(</span><span class="n">any_token</span><span class="p">)</span> +</span><span id="Parser-4057"><a href="#Parser-4057"><span class="linenos">4057</span></a> +</span><span id="Parser-4058"><a href="#Parser-4058"><span class="linenos">4058</span></a> <span class="k">if</span> <span class="n">alias</span><span class="p">:</span> +</span><span id="Parser-4059"><a href="#Parser-4059"><span class="linenos">4059</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">Alias</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span><span class="p">)</span> +</span><span id="Parser-4060"><a href="#Parser-4060"><span class="linenos">4060</span></a> +</span><span id="Parser-4061"><a href="#Parser-4061"><span class="linenos">4061</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-4062"><a href="#Parser-4062"><span class="linenos">4062</span></a> +</span><span id="Parser-4063"><a href="#Parser-4063"><span class="linenos">4063</span></a> <span class="k">def</span> <span class="nf">_parse_id_var</span><span class="p">(</span> +</span><span id="Parser-4064"><a href="#Parser-4064"><span class="linenos">4064</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Parser-4065"><a href="#Parser-4065"><span class="linenos">4065</span></a> <span class="n">any_token</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Parser-4066"><a href="#Parser-4066"><span class="linenos">4066</span></a> <span class="n">tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Parser-4067"><a href="#Parser-4067"><span class="linenos">4067</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="Parser-4068"><a href="#Parser-4068"><span class="linenos">4068</span></a> <span class="n">identifier</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_identifier</span><span class="p">()</span> +</span><span id="Parser-4069"><a href="#Parser-4069"><span class="linenos">4069</span></a> +</span><span id="Parser-4070"><a href="#Parser-4070"><span class="linenos">4070</span></a> <span class="k">if</span> <span class="n">identifier</span><span class="p">:</span> +</span><span id="Parser-4071"><a href="#Parser-4071"><span class="linenos">4071</span></a> <span class="k">return</span> <span class="n">identifier</span> +</span><span id="Parser-4072"><a href="#Parser-4072"><span class="linenos">4072</span></a> +</span><span id="Parser-4073"><a href="#Parser-4073"><span class="linenos">4073</span></a> <span class="k">if</span> <span class="p">(</span><span class="n">any_token</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</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="n">tokens</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">ID_VAR_TOKENS</span><span class="p">):</span> +</span><span id="Parser-4074"><a href="#Parser-4074"><span class="linenos">4074</span></a> <span class="n">quoted</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">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span> +</span><span id="Parser-4075"><a href="#Parser-4075"><span class="linenos">4075</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</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 class="n">quoted</span><span class="o">=</span><span class="n">quoted</span><span class="p">)</span> +</span><span id="Parser-4076"><a href="#Parser-4076"><span class="linenos">4076</span></a> +</span><span id="Parser-4077"><a href="#Parser-4077"><span class="linenos">4077</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="Parser-4078"><a href="#Parser-4078"><span class="linenos">4078</span></a> -</span><span id="Parser-4079"><a href="#Parser-4079"><span class="linenos">4079</span></a> <span class="k">def</span> <span class="nf">_parse_number</span><span class="p">(</span><span class="bp">self</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="Parser-4080"><a href="#Parser-4080"><span class="linenos">4080</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><span id="Parser-4081"><a href="#Parser-4081"><span class="linenos">4081</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</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="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="Parser-4079"><a href="#Parser-4079"><span class="linenos">4079</span></a> <span class="k">def</span> <span class="nf">_parse_string</span><span class="p">(</span><span class="bp">self</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="Parser-4080"><a href="#Parser-4080"><span class="linenos">4080</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">STRING</span><span class="p">):</span> +</span><span id="Parser-4081"><a href="#Parser-4081"><span class="linenos">4081</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> </span><span id="Parser-4082"><a href="#Parser-4082"><span class="linenos">4082</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_placeholder</span><span class="p">()</span> </span><span id="Parser-4083"><a href="#Parser-4083"><span class="linenos">4083</span></a> -</span><span id="Parser-4084"><a href="#Parser-4084"><span class="linenos">4084</span></a> <span class="k">def</span> <span class="nf">_parse_identifier</span><span class="p">(</span><span class="bp">self</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="Parser-4085"><a href="#Parser-4085"><span class="linenos">4085</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">IDENTIFIER</span><span class="p">):</span> -</span><span id="Parser-4086"><a href="#Parser-4086"><span class="linenos">4086</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">Identifier</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 class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-4087"><a href="#Parser-4087"><span class="linenos">4087</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_placeholder</span><span class="p">()</span> -</span><span id="Parser-4088"><a href="#Parser-4088"><span class="linenos">4088</span></a> -</span><span id="Parser-4089"><a href="#Parser-4089"><span class="linenos">4089</span></a> <span class="k">def</span> <span class="nf">_parse_var</span><span class="p">(</span> -</span><span id="Parser-4090"><a href="#Parser-4090"><span class="linenos">4090</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">any_token</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="n">tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-4091"><a href="#Parser-4091"><span class="linenos">4091</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="Parser-4092"><a href="#Parser-4092"><span class="linenos">4092</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="Parser-4093"><a href="#Parser-4093"><span class="linenos">4093</span></a> <span class="p">(</span><span class="n">any_token</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</span><span class="p">())</span> -</span><span id="Parser-4094"><a href="#Parser-4094"><span class="linenos">4094</span></a> <span class="ow">or</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">VAR</span><span class="p">)</span> -</span><span id="Parser-4095"><a href="#Parser-4095"><span class="linenos">4095</span></a> <span class="ow">or</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">(</span><span class="n">tokens</span><span class="p">)</span> <span class="k">if</span> <span class="n">tokens</span> <span class="k">else</span> <span class="kc">False</span><span class="p">)</span> -</span><span id="Parser-4096"><a href="#Parser-4096"><span class="linenos">4096</span></a> <span class="p">):</span> -</span><span id="Parser-4097"><a href="#Parser-4097"><span class="linenos">4097</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">Var</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="Parser-4098"><a href="#Parser-4098"><span class="linenos">4098</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_placeholder</span><span class="p">()</span> -</span><span id="Parser-4099"><a href="#Parser-4099"><span class="linenos">4099</span></a> -</span><span id="Parser-4100"><a href="#Parser-4100"><span class="linenos">4100</span></a> <span class="k">def</span> <span class="nf">_advance_any</span><span class="p">(</span><span class="bp">self</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">Token</span><span class="p">]:</span> -</span><span id="Parser-4101"><a href="#Parser-4101"><span class="linenos">4101</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span><span class="p">:</span> -</span><span id="Parser-4102"><a href="#Parser-4102"><span class="linenos">4102</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Parser-4103"><a href="#Parser-4103"><span class="linenos">4103</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> -</span><span id="Parser-4104"><a href="#Parser-4104"><span class="linenos">4104</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-4105"><a href="#Parser-4105"><span class="linenos">4105</span></a> -</span><span id="Parser-4106"><a href="#Parser-4106"><span class="linenos">4106</span></a> <span class="k">def</span> <span class="nf">_parse_var_or_string</span><span class="p">(</span><span class="bp">self</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="Parser-4107"><a href="#Parser-4107"><span class="linenos">4107</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> -</span><span id="Parser-4108"><a href="#Parser-4108"><span class="linenos">4108</span></a> -</span><span id="Parser-4109"><a href="#Parser-4109"><span class="linenos">4109</span></a> <span class="k">def</span> <span class="nf">_parse_null</span><span class="p">(</span><span class="bp">self</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="Parser-4110"><a href="#Parser-4110"><span class="linenos">4110</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">NULL</span><span class="p">):</span> -</span><span id="Parser-4111"><a href="#Parser-4111"><span class="linenos">4111</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="Parser-4084"><a href="#Parser-4084"><span class="linenos">4084</span></a> <span class="k">def</span> <span class="nf">_parse_string_as_identifier</span><span class="p">(</span><span class="bp">self</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">Identifier</span><span class="p">]:</span> +</span><span id="Parser-4085"><a href="#Parser-4085"><span class="linenos">4085</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</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">STRING</span><span class="p">)</span> <span class="ow">and</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 class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-4086"><a href="#Parser-4086"><span class="linenos">4086</span></a> +</span><span id="Parser-4087"><a href="#Parser-4087"><span class="linenos">4087</span></a> <span class="k">def</span> <span class="nf">_parse_number</span><span class="p">(</span><span class="bp">self</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="Parser-4088"><a href="#Parser-4088"><span class="linenos">4088</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><span id="Parser-4089"><a href="#Parser-4089"><span class="linenos">4089</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</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="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="Parser-4090"><a href="#Parser-4090"><span class="linenos">4090</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_placeholder</span><span class="p">()</span> +</span><span id="Parser-4091"><a href="#Parser-4091"><span class="linenos">4091</span></a> +</span><span id="Parser-4092"><a href="#Parser-4092"><span class="linenos">4092</span></a> <span class="k">def</span> <span class="nf">_parse_identifier</span><span class="p">(</span><span class="bp">self</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="Parser-4093"><a href="#Parser-4093"><span class="linenos">4093</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">IDENTIFIER</span><span class="p">):</span> +</span><span id="Parser-4094"><a href="#Parser-4094"><span class="linenos">4094</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">Identifier</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 class="n">quoted</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-4095"><a href="#Parser-4095"><span class="linenos">4095</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_placeholder</span><span class="p">()</span> +</span><span id="Parser-4096"><a href="#Parser-4096"><span class="linenos">4096</span></a> +</span><span id="Parser-4097"><a href="#Parser-4097"><span class="linenos">4097</span></a> <span class="k">def</span> <span class="nf">_parse_var</span><span class="p">(</span> +</span><span id="Parser-4098"><a href="#Parser-4098"><span class="linenos">4098</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">any_token</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="n">tokens</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-4099"><a href="#Parser-4099"><span class="linenos">4099</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="Parser-4100"><a href="#Parser-4100"><span class="linenos">4100</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="Parser-4101"><a href="#Parser-4101"><span class="linenos">4101</span></a> <span class="p">(</span><span class="n">any_token</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_advance_any</span><span class="p">())</span> +</span><span id="Parser-4102"><a href="#Parser-4102"><span class="linenos">4102</span></a> <span class="ow">or</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">VAR</span><span class="p">)</span> +</span><span id="Parser-4103"><a href="#Parser-4103"><span class="linenos">4103</span></a> <span class="ow">or</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">(</span><span class="n">tokens</span><span class="p">)</span> <span class="k">if</span> <span class="n">tokens</span> <span class="k">else</span> <span class="kc">False</span><span class="p">)</span> +</span><span id="Parser-4104"><a href="#Parser-4104"><span class="linenos">4104</span></a> <span class="p">):</span> +</span><span id="Parser-4105"><a href="#Parser-4105"><span class="linenos">4105</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">Var</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="Parser-4106"><a href="#Parser-4106"><span class="linenos">4106</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_placeholder</span><span class="p">()</span> +</span><span id="Parser-4107"><a href="#Parser-4107"><span class="linenos">4107</span></a> +</span><span id="Parser-4108"><a href="#Parser-4108"><span class="linenos">4108</span></a> <span class="k">def</span> <span class="nf">_advance_any</span><span class="p">(</span><span class="bp">self</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">Token</span><span class="p">]:</span> +</span><span id="Parser-4109"><a href="#Parser-4109"><span class="linenos">4109</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RESERVED_KEYWORDS</span><span class="p">:</span> +</span><span id="Parser-4110"><a href="#Parser-4110"><span class="linenos">4110</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Parser-4111"><a href="#Parser-4111"><span class="linenos">4111</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> </span><span id="Parser-4112"><a href="#Parser-4112"><span class="linenos">4112</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="Parser-4113"><a href="#Parser-4113"><span class="linenos">4113</span></a> -</span><span id="Parser-4114"><a href="#Parser-4114"><span class="linenos">4114</span></a> <span class="k">def</span> <span class="nf">_parse_boolean</span><span class="p">(</span><span class="bp">self</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="Parser-4115"><a href="#Parser-4115"><span class="linenos">4115</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">TRUE</span><span class="p">):</span> -</span><span id="Parser-4116"><a href="#Parser-4116"><span class="linenos">4116</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">TRUE</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> -</span><span id="Parser-4117"><a href="#Parser-4117"><span class="linenos">4117</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">FALSE</span><span class="p">):</span> -</span><span id="Parser-4118"><a href="#Parser-4118"><span class="linenos">4118</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FALSE</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> -</span><span id="Parser-4119"><a href="#Parser-4119"><span class="linenos">4119</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-4120"><a href="#Parser-4120"><span class="linenos">4120</span></a> -</span><span id="Parser-4121"><a href="#Parser-4121"><span class="linenos">4121</span></a> <span class="k">def</span> <span class="nf">_parse_star</span><span class="p">(</span><span class="bp">self</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="Parser-4122"><a href="#Parser-4122"><span class="linenos">4122</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">STAR</span><span class="p">):</span> -</span><span id="Parser-4123"><a href="#Parser-4123"><span class="linenos">4123</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STAR</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> -</span><span id="Parser-4124"><a href="#Parser-4124"><span class="linenos">4124</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-4125"><a href="#Parser-4125"><span class="linenos">4125</span></a> -</span><span id="Parser-4126"><a href="#Parser-4126"><span class="linenos">4126</span></a> <span class="k">def</span> <span class="nf">_parse_parameter</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">Parameter</span><span class="p">:</span> -</span><span id="Parser-4127"><a href="#Parser-4127"><span class="linenos">4127</span></a> <span class="n">wrapped</span> <span class="o">=</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><span id="Parser-4128"><a href="#Parser-4128"><span class="linenos">4128</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_identifier</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> -</span><span id="Parser-4129"><a href="#Parser-4129"><span class="linenos">4129</span></a> <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">R_BRACE</span><span class="p">)</span> -</span><span id="Parser-4130"><a href="#Parser-4130"><span class="linenos">4130</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">Parameter</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">wrapped</span><span class="o">=</span><span class="n">wrapped</span><span class="p">)</span> -</span><span id="Parser-4131"><a href="#Parser-4131"><span class="linenos">4131</span></a> -</span><span id="Parser-4132"><a href="#Parser-4132"><span class="linenos">4132</span></a> <span class="k">def</span> <span class="nf">_parse_placeholder</span><span class="p">(</span><span class="bp">self</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="Parser-4133"><a href="#Parser-4133"><span class="linenos">4133</span></a> <span class="k">if</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">PLACEHOLDER_PARSERS</span><span class="p">):</span> -</span><span id="Parser-4134"><a href="#Parser-4134"><span class="linenos">4134</span></a> <span class="n">placeholder</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PLACEHOLDER_PARSERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> -</span><span id="Parser-4135"><a href="#Parser-4135"><span class="linenos">4135</span></a> <span class="k">if</span> <span class="n">placeholder</span><span class="p">:</span> -</span><span id="Parser-4136"><a href="#Parser-4136"><span class="linenos">4136</span></a> <span class="k">return</span> <span class="n">placeholder</span> -</span><span id="Parser-4137"><a href="#Parser-4137"><span class="linenos">4137</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> -</span><span id="Parser-4138"><a href="#Parser-4138"><span class="linenos">4138</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-4114"><a href="#Parser-4114"><span class="linenos">4114</span></a> <span class="k">def</span> <span class="nf">_parse_var_or_string</span><span class="p">(</span><span class="bp">self</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="Parser-4115"><a href="#Parser-4115"><span class="linenos">4115</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_string</span><span class="p">()</span> +</span><span id="Parser-4116"><a href="#Parser-4116"><span class="linenos">4116</span></a> +</span><span id="Parser-4117"><a href="#Parser-4117"><span class="linenos">4117</span></a> <span class="k">def</span> <span class="nf">_parse_null</span><span class="p">(</span><span class="bp">self</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="Parser-4118"><a href="#Parser-4118"><span class="linenos">4118</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">NULL</span><span class="p">):</span> +</span><span id="Parser-4119"><a href="#Parser-4119"><span class="linenos">4119</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="Parser-4120"><a href="#Parser-4120"><span class="linenos">4120</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-4121"><a href="#Parser-4121"><span class="linenos">4121</span></a> +</span><span id="Parser-4122"><a href="#Parser-4122"><span class="linenos">4122</span></a> <span class="k">def</span> <span class="nf">_parse_boolean</span><span class="p">(</span><span class="bp">self</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="Parser-4123"><a href="#Parser-4123"><span class="linenos">4123</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">TRUE</span><span class="p">):</span> +</span><span id="Parser-4124"><a href="#Parser-4124"><span class="linenos">4124</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">TRUE</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="Parser-4125"><a href="#Parser-4125"><span class="linenos">4125</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">FALSE</span><span class="p">):</span> +</span><span id="Parser-4126"><a href="#Parser-4126"><span class="linenos">4126</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">FALSE</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="Parser-4127"><a href="#Parser-4127"><span class="linenos">4127</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-4128"><a href="#Parser-4128"><span class="linenos">4128</span></a> +</span><span id="Parser-4129"><a href="#Parser-4129"><span class="linenos">4129</span></a> <span class="k">def</span> <span class="nf">_parse_star</span><span class="p">(</span><span class="bp">self</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="Parser-4130"><a href="#Parser-4130"><span class="linenos">4130</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">STAR</span><span class="p">):</span> +</span><span id="Parser-4131"><a href="#Parser-4131"><span class="linenos">4131</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">PRIMARY_PARSERS</span><span class="p">[</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STAR</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="Parser-4132"><a href="#Parser-4132"><span class="linenos">4132</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-4133"><a href="#Parser-4133"><span class="linenos">4133</span></a> +</span><span id="Parser-4134"><a href="#Parser-4134"><span class="linenos">4134</span></a> <span class="k">def</span> <span class="nf">_parse_parameter</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">Parameter</span><span class="p">:</span> +</span><span id="Parser-4135"><a href="#Parser-4135"><span class="linenos">4135</span></a> <span class="n">wrapped</span> <span class="o">=</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><span id="Parser-4136"><a href="#Parser-4136"><span class="linenos">4136</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_identifier</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="Parser-4137"><a href="#Parser-4137"><span class="linenos">4137</span></a> <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">R_BRACE</span><span class="p">)</span> +</span><span id="Parser-4138"><a href="#Parser-4138"><span class="linenos">4138</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">Parameter</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">wrapped</span><span class="o">=</span><span class="n">wrapped</span><span class="p">)</span> </span><span id="Parser-4139"><a href="#Parser-4139"><span class="linenos">4139</span></a> -</span><span id="Parser-4140"><a href="#Parser-4140"><span class="linenos">4140</span></a> <span class="k">def</span> <span class="nf">_parse_except</span><span class="p">(</span><span class="bp">self</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">t</span><span class="o">.</span><span class="n">List</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><span id="Parser-4141"><a href="#Parser-4141"><span class="linenos">4141</span></a> <span class="k">if</span> <span class="ow">not</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">EXCEPT</span><span class="p">):</span> -</span><span id="Parser-4142"><a href="#Parser-4142"><span class="linenos">4142</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-4143"><a href="#Parser-4143"><span class="linenos">4143</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_PAREN</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="Parser-4144"><a href="#Parser-4144"><span class="linenos">4144</span></a> <span class="k">return</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_column</span><span class="p">)</span> -</span><span id="Parser-4145"><a href="#Parser-4145"><span class="linenos">4145</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">)</span> -</span><span id="Parser-4146"><a href="#Parser-4146"><span class="linenos">4146</span></a> -</span><span id="Parser-4147"><a href="#Parser-4147"><span class="linenos">4147</span></a> <span class="k">def</span> <span class="nf">_parse_replace</span><span class="p">(</span><span class="bp">self</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">t</span><span class="o">.</span><span class="n">List</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><span id="Parser-4148"><a href="#Parser-4148"><span class="linenos">4148</span></a> <span class="k">if</span> <span class="ow">not</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">REPLACE</span><span class="p">):</span> -</span><span id="Parser-4149"><a href="#Parser-4149"><span class="linenos">4149</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-4150"><a href="#Parser-4150"><span class="linenos">4150</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_PAREN</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="Parser-4151"><a href="#Parser-4151"><span class="linenos">4151</span></a> <span class="k">return</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_expression</span><span class="p">)</span> -</span><span id="Parser-4152"><a href="#Parser-4152"><span class="linenos">4152</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">)</span> -</span><span id="Parser-4153"><a href="#Parser-4153"><span class="linenos">4153</span></a> -</span><span id="Parser-4154"><a href="#Parser-4154"><span class="linenos">4154</span></a> <span class="k">def</span> <span class="nf">_parse_csv</span><span class="p">(</span> -</span><span id="Parser-4155"><a href="#Parser-4155"><span class="linenos">4155</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="n">TokenType</span> <span class="o">=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMA</span> -</span><span id="Parser-4156"><a href="#Parser-4156"><span class="linenos">4156</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Parser-4157"><a href="#Parser-4157"><span class="linenos">4157</span></a> <span class="n">parse_result</span> <span class="o">=</span> <span class="n">parse_method</span><span class="p">()</span> -</span><span id="Parser-4158"><a href="#Parser-4158"><span class="linenos">4158</span></a> <span class="n">items</span> <span class="o">=</span> <span class="p">[</span><span class="n">parse_result</span><span class="p">]</span> <span class="k">if</span> <span class="n">parse_result</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="p">[]</span> -</span><span id="Parser-4159"><a href="#Parser-4159"><span class="linenos">4159</span></a> -</span><span id="Parser-4160"><a href="#Parser-4160"><span class="linenos">4160</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">sep</span><span class="p">):</span> -</span><span id="Parser-4161"><a href="#Parser-4161"><span class="linenos">4161</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add_comments</span><span class="p">(</span><span class="n">parse_result</span><span class="p">)</span> -</span><span id="Parser-4162"><a href="#Parser-4162"><span class="linenos">4162</span></a> <span class="n">parse_result</span> <span class="o">=</span> <span class="n">parse_method</span><span class="p">()</span> -</span><span id="Parser-4163"><a href="#Parser-4163"><span class="linenos">4163</span></a> <span class="k">if</span> <span class="n">parse_result</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Parser-4164"><a href="#Parser-4164"><span class="linenos">4164</span></a> <span class="n">items</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">parse_result</span><span class="p">)</span> -</span><span id="Parser-4165"><a href="#Parser-4165"><span class="linenos">4165</span></a> -</span><span id="Parser-4166"><a href="#Parser-4166"><span class="linenos">4166</span></a> <span class="k">return</span> <span class="n">items</span> +</span><span id="Parser-4140"><a href="#Parser-4140"><span class="linenos">4140</span></a> <span class="k">def</span> <span class="nf">_parse_placeholder</span><span class="p">(</span><span class="bp">self</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="Parser-4141"><a href="#Parser-4141"><span class="linenos">4141</span></a> <span class="k">if</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">PLACEHOLDER_PARSERS</span><span class="p">):</span> +</span><span id="Parser-4142"><a href="#Parser-4142"><span class="linenos">4142</span></a> <span class="n">placeholder</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">PLACEHOLDER_PARSERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">](</span><span class="bp">self</span><span class="p">)</span> +</span><span id="Parser-4143"><a href="#Parser-4143"><span class="linenos">4143</span></a> <span class="k">if</span> <span class="n">placeholder</span><span class="p">:</span> +</span><span id="Parser-4144"><a href="#Parser-4144"><span class="linenos">4144</span></a> <span class="k">return</span> <span class="n">placeholder</span> +</span><span id="Parser-4145"><a href="#Parser-4145"><span class="linenos">4145</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> +</span><span id="Parser-4146"><a href="#Parser-4146"><span class="linenos">4146</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-4147"><a href="#Parser-4147"><span class="linenos">4147</span></a> +</span><span id="Parser-4148"><a href="#Parser-4148"><span class="linenos">4148</span></a> <span class="k">def</span> <span class="nf">_parse_except</span><span class="p">(</span><span class="bp">self</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">t</span><span class="o">.</span><span class="n">List</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><span id="Parser-4149"><a href="#Parser-4149"><span class="linenos">4149</span></a> <span class="k">if</span> <span class="ow">not</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">EXCEPT</span><span class="p">):</span> +</span><span id="Parser-4150"><a href="#Parser-4150"><span class="linenos">4150</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-4151"><a href="#Parser-4151"><span class="linenos">4151</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_PAREN</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="Parser-4152"><a href="#Parser-4152"><span class="linenos">4152</span></a> <span class="k">return</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_column</span><span class="p">)</span> +</span><span id="Parser-4153"><a href="#Parser-4153"><span class="linenos">4153</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_column</span><span class="p">)</span> +</span><span id="Parser-4154"><a href="#Parser-4154"><span class="linenos">4154</span></a> +</span><span id="Parser-4155"><a href="#Parser-4155"><span class="linenos">4155</span></a> <span class="k">def</span> <span class="nf">_parse_replace</span><span class="p">(</span><span class="bp">self</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">t</span><span class="o">.</span><span class="n">List</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><span id="Parser-4156"><a href="#Parser-4156"><span class="linenos">4156</span></a> <span class="k">if</span> <span class="ow">not</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">REPLACE</span><span class="p">):</span> +</span><span id="Parser-4157"><a href="#Parser-4157"><span class="linenos">4157</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-4158"><a href="#Parser-4158"><span class="linenos">4158</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_PAREN</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="Parser-4159"><a href="#Parser-4159"><span class="linenos">4159</span></a> <span class="k">return</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_expression</span><span class="p">)</span> +</span><span id="Parser-4160"><a href="#Parser-4160"><span class="linenos">4160</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">)</span> +</span><span id="Parser-4161"><a href="#Parser-4161"><span class="linenos">4161</span></a> +</span><span id="Parser-4162"><a href="#Parser-4162"><span class="linenos">4162</span></a> <span class="k">def</span> <span class="nf">_parse_csv</span><span class="p">(</span> +</span><span id="Parser-4163"><a href="#Parser-4163"><span class="linenos">4163</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="n">TokenType</span> <span class="o">=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMA</span> +</span><span id="Parser-4164"><a href="#Parser-4164"><span class="linenos">4164</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Parser-4165"><a href="#Parser-4165"><span class="linenos">4165</span></a> <span class="n">parse_result</span> <span class="o">=</span> <span class="n">parse_method</span><span class="p">()</span> +</span><span id="Parser-4166"><a href="#Parser-4166"><span class="linenos">4166</span></a> <span class="n">items</span> <span class="o">=</span> <span class="p">[</span><span class="n">parse_result</span><span class="p">]</span> <span class="k">if</span> <span class="n">parse_result</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="p">[]</span> </span><span id="Parser-4167"><a href="#Parser-4167"><span class="linenos">4167</span></a> -</span><span id="Parser-4168"><a href="#Parser-4168"><span class="linenos">4168</span></a> <span class="k">def</span> <span class="nf">_parse_tokens</span><span class="p">(</span> -</span><span id="Parser-4169"><a href="#Parser-4169"><span class="linenos">4169</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">expressions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> -</span><span id="Parser-4170"><a href="#Parser-4170"><span class="linenos">4170</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="Parser-4171"><a href="#Parser-4171"><span class="linenos">4171</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">parse_method</span><span class="p">()</span> -</span><span id="Parser-4172"><a href="#Parser-4172"><span class="linenos">4172</span></a> -</span><span id="Parser-4173"><a href="#Parser-4173"><span class="linenos">4173</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">(</span><span class="n">expressions</span><span class="p">):</span> -</span><span id="Parser-4174"><a href="#Parser-4174"><span class="linenos">4174</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-4175"><a href="#Parser-4175"><span class="linenos">4175</span></a> <span class="n">expressions</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">],</span> -</span><span id="Parser-4176"><a href="#Parser-4176"><span class="linenos">4176</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="Parser-4177"><a href="#Parser-4177"><span class="linenos">4177</span></a> <span class="n">comments</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span><span class="p">,</span> -</span><span id="Parser-4178"><a href="#Parser-4178"><span class="linenos">4178</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">parse_method</span><span class="p">(),</span> -</span><span id="Parser-4179"><a href="#Parser-4179"><span class="linenos">4179</span></a> <span class="p">)</span> +</span><span id="Parser-4168"><a href="#Parser-4168"><span class="linenos">4168</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match</span><span class="p">(</span><span class="n">sep</span><span class="p">):</span> +</span><span id="Parser-4169"><a href="#Parser-4169"><span class="linenos">4169</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add_comments</span><span class="p">(</span><span class="n">parse_result</span><span class="p">)</span> +</span><span id="Parser-4170"><a href="#Parser-4170"><span class="linenos">4170</span></a> <span class="n">parse_result</span> <span class="o">=</span> <span class="n">parse_method</span><span class="p">()</span> +</span><span id="Parser-4171"><a href="#Parser-4171"><span class="linenos">4171</span></a> <span class="k">if</span> <span class="n">parse_result</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Parser-4172"><a href="#Parser-4172"><span class="linenos">4172</span></a> <span class="n">items</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">parse_result</span><span class="p">)</span> +</span><span id="Parser-4173"><a href="#Parser-4173"><span class="linenos">4173</span></a> +</span><span id="Parser-4174"><a href="#Parser-4174"><span class="linenos">4174</span></a> <span class="k">return</span> <span class="n">items</span> +</span><span id="Parser-4175"><a href="#Parser-4175"><span class="linenos">4175</span></a> +</span><span id="Parser-4176"><a href="#Parser-4176"><span class="linenos">4176</span></a> <span class="k">def</span> <span class="nf">_parse_tokens</span><span class="p">(</span> +</span><span id="Parser-4177"><a href="#Parser-4177"><span class="linenos">4177</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">expressions</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> +</span><span id="Parser-4178"><a href="#Parser-4178"><span class="linenos">4178</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="Parser-4179"><a href="#Parser-4179"><span class="linenos">4179</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">parse_method</span><span class="p">()</span> </span><span id="Parser-4180"><a href="#Parser-4180"><span class="linenos">4180</span></a> -</span><span id="Parser-4181"><a href="#Parser-4181"><span class="linenos">4181</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-4182"><a href="#Parser-4182"><span class="linenos">4182</span></a> -</span><span id="Parser-4183"><a href="#Parser-4183"><span class="linenos">4183</span></a> <span class="k">def</span> <span class="nf">_parse_wrapped_id_vars</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">optional</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">List</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><span id="Parser-4184"><a href="#Parser-4184"><span class="linenos">4184</span></a> <span class="k">return</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_id_var</span><span class="p">,</span> <span class="n">optional</span><span class="o">=</span><span class="n">optional</span><span class="p">)</span> -</span><span id="Parser-4185"><a href="#Parser-4185"><span class="linenos">4185</span></a> -</span><span id="Parser-4186"><a href="#Parser-4186"><span class="linenos">4186</span></a> <span class="k">def</span> <span class="nf">_parse_wrapped_csv</span><span class="p">(</span> -</span><span id="Parser-4187"><a href="#Parser-4187"><span class="linenos">4187</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="n">TokenType</span> <span class="o">=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMA</span><span class="p">,</span> <span class="n">optional</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Parser-4188"><a href="#Parser-4188"><span class="linenos">4188</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Parser-4189"><a href="#Parser-4189"><span class="linenos">4189</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span> -</span><span id="Parser-4190"><a href="#Parser-4190"><span class="linenos">4190</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">parse_method</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">optional</span><span class="o">=</span><span class="n">optional</span> -</span><span id="Parser-4191"><a href="#Parser-4191"><span class="linenos">4191</span></a> <span class="p">)</span> -</span><span id="Parser-4192"><a href="#Parser-4192"><span class="linenos">4192</span></a> -</span><span id="Parser-4193"><a href="#Parser-4193"><span class="linenos">4193</span></a> <span class="k">def</span> <span class="nf">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">optional</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">Any</span><span class="p">:</span> -</span><span id="Parser-4194"><a href="#Parser-4194"><span class="linenos">4194</span></a> <span class="n">wrapped</span> <span class="o">=</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_PAREN</span><span class="p">)</span> -</span><span id="Parser-4195"><a href="#Parser-4195"><span class="linenos">4195</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">wrapped</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">optional</span><span class="p">:</span> -</span><span id="Parser-4196"><a href="#Parser-4196"><span class="linenos">4196</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting ("</span><span class="p">)</span> -</span><span id="Parser-4197"><a href="#Parser-4197"><span class="linenos">4197</span></a> <span class="n">parse_result</span> <span class="o">=</span> <span class="n">parse_method</span><span class="p">()</span> -</span><span id="Parser-4198"><a href="#Parser-4198"><span class="linenos">4198</span></a> <span class="k">if</span> <span class="n">wrapped</span><span class="p">:</span> -</span><span id="Parser-4199"><a href="#Parser-4199"><span class="linenos">4199</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="Parser-4200"><a href="#Parser-4200"><span class="linenos">4200</span></a> <span class="k">return</span> <span class="n">parse_result</span> -</span><span id="Parser-4201"><a href="#Parser-4201"><span class="linenos">4201</span></a> -</span><span id="Parser-4202"><a href="#Parser-4202"><span class="linenos">4202</span></a> <span class="k">def</span> <span class="nf">_parse_select_or_expression</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">alias</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="Parser-4203"><a href="#Parser-4203"><span class="linenos">4203</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span> -</span><span id="Parser-4204"><a href="#Parser-4204"><span class="linenos">4204</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">()</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="Parser-4205"><a href="#Parser-4205"><span class="linenos">4205</span></a> <span class="p">)</span> -</span><span id="Parser-4206"><a href="#Parser-4206"><span class="linenos">4206</span></a> -</span><span id="Parser-4207"><a href="#Parser-4207"><span class="linenos">4207</span></a> <span class="k">def</span> <span class="nf">_parse_ddl_select</span><span class="p">(</span><span class="bp">self</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="Parser-4208"><a href="#Parser-4208"><span class="linenos">4208</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span> -</span><span id="Parser-4209"><a href="#Parser-4209"><span class="linenos">4209</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">parse_subquery_alias</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> -</span><span id="Parser-4210"><a href="#Parser-4210"><span class="linenos">4210</span></a> <span class="p">)</span> -</span><span id="Parser-4211"><a href="#Parser-4211"><span class="linenos">4211</span></a> -</span><span id="Parser-4212"><a href="#Parser-4212"><span class="linenos">4212</span></a> <span class="k">def</span> <span class="nf">_parse_transaction</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">Transaction</span><span class="p">:</span> -</span><span id="Parser-4213"><a href="#Parser-4213"><span class="linenos">4213</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-4214"><a href="#Parser-4214"><span class="linenos">4214</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">TRANSACTION_KIND</span><span class="p">):</span> -</span><span id="Parser-4215"><a href="#Parser-4215"><span class="linenos">4215</span></a> <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><span id="Parser-4216"><a href="#Parser-4216"><span class="linenos">4216</span></a> -</span><span id="Parser-4217"><a href="#Parser-4217"><span class="linenos">4217</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">({</span><span class="s2">"TRANSACTION"</span><span class="p">,</span> <span class="s2">"WORK"</span><span class="p">})</span> -</span><span id="Parser-4218"><a href="#Parser-4218"><span class="linenos">4218</span></a> -</span><span id="Parser-4219"><a href="#Parser-4219"><span class="linenos">4219</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-4220"><a href="#Parser-4220"><span class="linenos">4220</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Parser-4221"><a href="#Parser-4221"><span class="linenos">4221</span></a> <span class="n">mode</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-4222"><a href="#Parser-4222"><span class="linenos">4222</span></a> <span class="k">while</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">VAR</span><span class="p">):</span> -</span><span id="Parser-4223"><a href="#Parser-4223"><span class="linenos">4223</span></a> <span class="n">mode</span><span class="o">.</span><span class="n">append</span><span class="p">(</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="Parser-4181"><a href="#Parser-4181"><span class="linenos">4181</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_set</span><span class="p">(</span><span class="n">expressions</span><span class="p">):</span> +</span><span id="Parser-4182"><a href="#Parser-4182"><span class="linenos">4182</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-4183"><a href="#Parser-4183"><span class="linenos">4183</span></a> <span class="n">expressions</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="o">.</span><span class="n">token_type</span><span class="p">],</span> +</span><span id="Parser-4184"><a href="#Parser-4184"><span class="linenos">4184</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="Parser-4185"><a href="#Parser-4185"><span class="linenos">4185</span></a> <span class="n">comments</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span><span class="p">,</span> +</span><span id="Parser-4186"><a href="#Parser-4186"><span class="linenos">4186</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">parse_method</span><span class="p">(),</span> +</span><span id="Parser-4187"><a href="#Parser-4187"><span class="linenos">4187</span></a> <span class="p">)</span> +</span><span id="Parser-4188"><a href="#Parser-4188"><span class="linenos">4188</span></a> +</span><span id="Parser-4189"><a href="#Parser-4189"><span class="linenos">4189</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-4190"><a href="#Parser-4190"><span class="linenos">4190</span></a> +</span><span id="Parser-4191"><a href="#Parser-4191"><span class="linenos">4191</span></a> <span class="k">def</span> <span class="nf">_parse_wrapped_id_vars</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">optional</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">List</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><span id="Parser-4192"><a href="#Parser-4192"><span class="linenos">4192</span></a> <span class="k">return</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_id_var</span><span class="p">,</span> <span class="n">optional</span><span class="o">=</span><span class="n">optional</span><span class="p">)</span> +</span><span id="Parser-4193"><a href="#Parser-4193"><span class="linenos">4193</span></a> +</span><span id="Parser-4194"><a href="#Parser-4194"><span class="linenos">4194</span></a> <span class="k">def</span> <span class="nf">_parse_wrapped_csv</span><span class="p">(</span> +</span><span id="Parser-4195"><a href="#Parser-4195"><span class="linenos">4195</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span> <span class="n">TokenType</span> <span class="o">=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMA</span><span class="p">,</span> <span class="n">optional</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Parser-4196"><a href="#Parser-4196"><span class="linenos">4196</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Parser-4197"><a href="#Parser-4197"><span class="linenos">4197</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span> +</span><span id="Parser-4198"><a href="#Parser-4198"><span class="linenos">4198</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="n">parse_method</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">optional</span><span class="o">=</span><span class="n">optional</span> +</span><span id="Parser-4199"><a href="#Parser-4199"><span class="linenos">4199</span></a> <span class="p">)</span> +</span><span id="Parser-4200"><a href="#Parser-4200"><span class="linenos">4200</span></a> +</span><span id="Parser-4201"><a href="#Parser-4201"><span class="linenos">4201</span></a> <span class="k">def</span> <span class="nf">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parse_method</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">,</span> <span class="n">optional</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">Any</span><span class="p">:</span> +</span><span id="Parser-4202"><a href="#Parser-4202"><span class="linenos">4202</span></a> <span class="n">wrapped</span> <span class="o">=</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_PAREN</span><span class="p">)</span> +</span><span id="Parser-4203"><a href="#Parser-4203"><span class="linenos">4203</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">wrapped</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">optional</span><span class="p">:</span> +</span><span id="Parser-4204"><a href="#Parser-4204"><span class="linenos">4204</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting ("</span><span class="p">)</span> +</span><span id="Parser-4205"><a href="#Parser-4205"><span class="linenos">4205</span></a> <span class="n">parse_result</span> <span class="o">=</span> <span class="n">parse_method</span><span class="p">()</span> +</span><span id="Parser-4206"><a href="#Parser-4206"><span class="linenos">4206</span></a> <span class="k">if</span> <span class="n">wrapped</span><span class="p">:</span> +</span><span id="Parser-4207"><a href="#Parser-4207"><span class="linenos">4207</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-4208"><a href="#Parser-4208"><span class="linenos">4208</span></a> <span class="k">return</span> <span class="n">parse_result</span> +</span><span id="Parser-4209"><a href="#Parser-4209"><span class="linenos">4209</span></a> +</span><span id="Parser-4210"><a href="#Parser-4210"><span class="linenos">4210</span></a> <span class="k">def</span> <span class="nf">_parse_select_or_expression</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">alias</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="Parser-4211"><a href="#Parser-4211"><span class="linenos">4211</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span> +</span><span id="Parser-4212"><a href="#Parser-4212"><span class="linenos">4212</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_expression</span><span class="p">()</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="Parser-4213"><a href="#Parser-4213"><span class="linenos">4213</span></a> <span class="p">)</span> +</span><span id="Parser-4214"><a href="#Parser-4214"><span class="linenos">4214</span></a> +</span><span id="Parser-4215"><a href="#Parser-4215"><span class="linenos">4215</span></a> <span class="k">def</span> <span class="nf">_parse_ddl_select</span><span class="p">(</span><span class="bp">self</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="Parser-4216"><a href="#Parser-4216"><span class="linenos">4216</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_query_modifiers</span><span class="p">(</span> +</span><span id="Parser-4217"><a href="#Parser-4217"><span class="linenos">4217</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_operations</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_select</span><span class="p">(</span><span class="n">nested</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">parse_subquery_alias</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> +</span><span id="Parser-4218"><a href="#Parser-4218"><span class="linenos">4218</span></a> <span class="p">)</span> +</span><span id="Parser-4219"><a href="#Parser-4219"><span class="linenos">4219</span></a> +</span><span id="Parser-4220"><a href="#Parser-4220"><span class="linenos">4220</span></a> <span class="k">def</span> <span class="nf">_parse_transaction</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">Transaction</span><span class="p">:</span> +</span><span id="Parser-4221"><a href="#Parser-4221"><span class="linenos">4221</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-4222"><a href="#Parser-4222"><span class="linenos">4222</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">TRANSACTION_KIND</span><span class="p">):</span> +</span><span id="Parser-4223"><a href="#Parser-4223"><span class="linenos">4223</span></a> <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><span id="Parser-4224"><a href="#Parser-4224"><span class="linenos">4224</span></a> -</span><span id="Parser-4225"><a href="#Parser-4225"><span class="linenos">4225</span></a> <span class="k">if</span> <span class="n">mode</span><span class="p">:</span> -</span><span id="Parser-4226"><a href="#Parser-4226"><span class="linenos">4226</span></a> <span class="n">modes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">mode</span><span class="p">))</span> -</span><span id="Parser-4227"><a href="#Parser-4227"><span class="linenos">4227</span></a> <span class="k">if</span> <span class="ow">not</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">COMMA</span><span class="p">):</span> -</span><span id="Parser-4228"><a href="#Parser-4228"><span class="linenos">4228</span></a> <span class="k">break</span> -</span><span id="Parser-4229"><a href="#Parser-4229"><span class="linenos">4229</span></a> -</span><span id="Parser-4230"><a href="#Parser-4230"><span class="linenos">4230</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">Transaction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">modes</span><span class="o">=</span><span class="n">modes</span><span class="p">)</span> -</span><span id="Parser-4231"><a href="#Parser-4231"><span class="linenos">4231</span></a> -</span><span id="Parser-4232"><a href="#Parser-4232"><span class="linenos">4232</span></a> <span class="k">def</span> <span class="nf">_parse_commit_or_rollback</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">Commit</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Rollback</span><span class="p">:</span> -</span><span id="Parser-4233"><a href="#Parser-4233"><span class="linenos">4233</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-4234"><a href="#Parser-4234"><span class="linenos">4234</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-4235"><a href="#Parser-4235"><span class="linenos">4235</span></a> <span class="n">is_rollback</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">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROLLBACK</span> -</span><span id="Parser-4236"><a href="#Parser-4236"><span class="linenos">4236</span></a> -</span><span id="Parser-4237"><a href="#Parser-4237"><span class="linenos">4237</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">({</span><span class="s2">"TRANSACTION"</span><span class="p">,</span> <span class="s2">"WORK"</span><span class="p">})</span> -</span><span id="Parser-4238"><a href="#Parser-4238"><span class="linenos">4238</span></a> -</span><span id="Parser-4239"><a href="#Parser-4239"><span class="linenos">4239</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">):</span> -</span><span id="Parser-4240"><a href="#Parser-4240"><span class="linenos">4240</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SAVEPOINT"</span><span class="p">)</span> -</span><span id="Parser-4241"><a href="#Parser-4241"><span class="linenos">4241</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="Parser-4242"><a href="#Parser-4242"><span class="linenos">4242</span></a> -</span><span id="Parser-4243"><a href="#Parser-4243"><span class="linenos">4243</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">AND</span><span class="p">):</span> -</span><span id="Parser-4244"><a href="#Parser-4244"><span class="linenos">4244</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">)</span> -</span><span id="Parser-4245"><a href="#Parser-4245"><span class="linenos">4245</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CHAIN"</span><span class="p">)</span> +</span><span id="Parser-4225"><a href="#Parser-4225"><span class="linenos">4225</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">({</span><span class="s2">"TRANSACTION"</span><span class="p">,</span> <span class="s2">"WORK"</span><span class="p">})</span> +</span><span id="Parser-4226"><a href="#Parser-4226"><span class="linenos">4226</span></a> +</span><span id="Parser-4227"><a href="#Parser-4227"><span class="linenos">4227</span></a> <span class="n">modes</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-4228"><a href="#Parser-4228"><span class="linenos">4228</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Parser-4229"><a href="#Parser-4229"><span class="linenos">4229</span></a> <span class="n">mode</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-4230"><a href="#Parser-4230"><span class="linenos">4230</span></a> <span class="k">while</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">VAR</span><span class="p">):</span> +</span><span id="Parser-4231"><a href="#Parser-4231"><span class="linenos">4231</span></a> <span class="n">mode</span><span class="o">.</span><span class="n">append</span><span class="p">(</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="Parser-4232"><a href="#Parser-4232"><span class="linenos">4232</span></a> +</span><span id="Parser-4233"><a href="#Parser-4233"><span class="linenos">4233</span></a> <span class="k">if</span> <span class="n">mode</span><span class="p">:</span> +</span><span id="Parser-4234"><a href="#Parser-4234"><span class="linenos">4234</span></a> <span class="n">modes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">mode</span><span class="p">))</span> +</span><span id="Parser-4235"><a href="#Parser-4235"><span class="linenos">4235</span></a> <span class="k">if</span> <span class="ow">not</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">COMMA</span><span class="p">):</span> +</span><span id="Parser-4236"><a href="#Parser-4236"><span class="linenos">4236</span></a> <span class="k">break</span> +</span><span id="Parser-4237"><a href="#Parser-4237"><span class="linenos">4237</span></a> +</span><span id="Parser-4238"><a href="#Parser-4238"><span class="linenos">4238</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">Transaction</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">modes</span><span class="o">=</span><span class="n">modes</span><span class="p">)</span> +</span><span id="Parser-4239"><a href="#Parser-4239"><span class="linenos">4239</span></a> +</span><span id="Parser-4240"><a href="#Parser-4240"><span class="linenos">4240</span></a> <span class="k">def</span> <span class="nf">_parse_commit_or_rollback</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">Commit</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Rollback</span><span class="p">:</span> +</span><span id="Parser-4241"><a href="#Parser-4241"><span class="linenos">4241</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-4242"><a href="#Parser-4242"><span class="linenos">4242</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-4243"><a href="#Parser-4243"><span class="linenos">4243</span></a> <span class="n">is_rollback</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">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROLLBACK</span> +</span><span id="Parser-4244"><a href="#Parser-4244"><span class="linenos">4244</span></a> +</span><span id="Parser-4245"><a href="#Parser-4245"><span class="linenos">4245</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">({</span><span class="s2">"TRANSACTION"</span><span class="p">,</span> <span class="s2">"WORK"</span><span class="p">})</span> </span><span id="Parser-4246"><a href="#Parser-4246"><span class="linenos">4246</span></a> -</span><span id="Parser-4247"><a href="#Parser-4247"><span class="linenos">4247</span></a> <span class="k">if</span> <span class="n">is_rollback</span><span class="p">:</span> -</span><span id="Parser-4248"><a href="#Parser-4248"><span class="linenos">4248</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">Rollback</span><span class="p">,</span> <span class="n">savepoint</span><span class="o">=</span><span class="n">savepoint</span><span class="p">)</span> -</span><span id="Parser-4249"><a href="#Parser-4249"><span class="linenos">4249</span></a> -</span><span id="Parser-4250"><a href="#Parser-4250"><span class="linenos">4250</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">Commit</span><span class="p">,</span> <span class="n">chain</span><span class="o">=</span><span class="n">chain</span><span class="p">)</span> -</span><span id="Parser-4251"><a href="#Parser-4251"><span class="linenos">4251</span></a> -</span><span id="Parser-4252"><a href="#Parser-4252"><span class="linenos">4252</span></a> <span class="k">def</span> <span class="nf">_parse_add_column</span><span class="p">(</span><span class="bp">self</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="Parser-4253"><a href="#Parser-4253"><span class="linenos">4253</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ADD"</span><span class="p">):</span> -</span><span id="Parser-4254"><a href="#Parser-4254"><span class="linenos">4254</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-4255"><a href="#Parser-4255"><span class="linenos">4255</span></a> -</span><span id="Parser-4256"><a href="#Parser-4256"><span class="linenos">4256</span></a> <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">COLUMN</span><span class="p">)</span> -</span><span id="Parser-4257"><a href="#Parser-4257"><span class="linenos">4257</span></a> <span class="n">exists_column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">(</span><span class="n">not_</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-4258"><a href="#Parser-4258"><span class="linenos">4258</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_def</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="Parser-4247"><a href="#Parser-4247"><span class="linenos">4247</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">):</span> +</span><span id="Parser-4248"><a href="#Parser-4248"><span class="linenos">4248</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SAVEPOINT"</span><span class="p">)</span> +</span><span id="Parser-4249"><a href="#Parser-4249"><span class="linenos">4249</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="Parser-4250"><a href="#Parser-4250"><span class="linenos">4250</span></a> +</span><span id="Parser-4251"><a href="#Parser-4251"><span class="linenos">4251</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">AND</span><span class="p">):</span> +</span><span id="Parser-4252"><a href="#Parser-4252"><span class="linenos">4252</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"NO"</span><span class="p">)</span> +</span><span id="Parser-4253"><a href="#Parser-4253"><span class="linenos">4253</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CHAIN"</span><span class="p">)</span> +</span><span id="Parser-4254"><a href="#Parser-4254"><span class="linenos">4254</span></a> +</span><span id="Parser-4255"><a href="#Parser-4255"><span class="linenos">4255</span></a> <span class="k">if</span> <span class="n">is_rollback</span><span class="p">:</span> +</span><span id="Parser-4256"><a href="#Parser-4256"><span class="linenos">4256</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">Rollback</span><span class="p">,</span> <span class="n">savepoint</span><span class="o">=</span><span class="n">savepoint</span><span class="p">)</span> +</span><span id="Parser-4257"><a href="#Parser-4257"><span class="linenos">4257</span></a> +</span><span id="Parser-4258"><a href="#Parser-4258"><span class="linenos">4258</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">Commit</span><span class="p">,</span> <span class="n">chain</span><span class="o">=</span><span class="n">chain</span><span class="p">)</span> </span><span id="Parser-4259"><a href="#Parser-4259"><span class="linenos">4259</span></a> -</span><span id="Parser-4260"><a href="#Parser-4260"><span class="linenos">4260</span></a> <span class="k">if</span> <span class="n">expression</span><span class="p">:</span> -</span><span id="Parser-4261"><a href="#Parser-4261"><span class="linenos">4261</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">,</span> <span class="n">exists_column</span><span class="p">)</span> -</span><span id="Parser-4262"><a href="#Parser-4262"><span class="linenos">4262</span></a> -</span><span id="Parser-4263"><a href="#Parser-4263"><span class="linenos">4263</span></a> <span class="c1"># https://docs.databricks.com/delta/update-schema.html#explicitly-update-schema-to-add-columns</span> -</span><span id="Parser-4264"><a href="#Parser-4264"><span class="linenos">4264</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"FIRST"</span><span class="p">,</span> <span class="s2">"AFTER"</span><span class="p">)):</span> -</span><span id="Parser-4265"><a href="#Parser-4265"><span class="linenos">4265</span></a> <span class="n">position</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><span id="Parser-4266"><a href="#Parser-4266"><span class="linenos">4266</span></a> <span class="n">column_position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-4267"><a href="#Parser-4267"><span class="linenos">4267</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnPosition</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_column</span><span class="p">(),</span> <span class="n">position</span><span class="o">=</span><span class="n">position</span> -</span><span id="Parser-4268"><a href="#Parser-4268"><span class="linenos">4268</span></a> <span class="p">)</span> -</span><span id="Parser-4269"><a href="#Parser-4269"><span class="linenos">4269</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"position"</span><span class="p">,</span> <span class="n">column_position</span><span class="p">)</span> +</span><span id="Parser-4260"><a href="#Parser-4260"><span class="linenos">4260</span></a> <span class="k">def</span> <span class="nf">_parse_add_column</span><span class="p">(</span><span class="bp">self</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="Parser-4261"><a href="#Parser-4261"><span class="linenos">4261</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ADD"</span><span class="p">):</span> +</span><span id="Parser-4262"><a href="#Parser-4262"><span class="linenos">4262</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-4263"><a href="#Parser-4263"><span class="linenos">4263</span></a> +</span><span id="Parser-4264"><a href="#Parser-4264"><span class="linenos">4264</span></a> <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">COLUMN</span><span class="p">)</span> +</span><span id="Parser-4265"><a href="#Parser-4265"><span class="linenos">4265</span></a> <span class="n">exists_column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">(</span><span class="n">not_</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-4266"><a href="#Parser-4266"><span class="linenos">4266</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_column_def</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="Parser-4267"><a href="#Parser-4267"><span class="linenos">4267</span></a> +</span><span id="Parser-4268"><a href="#Parser-4268"><span class="linenos">4268</span></a> <span class="k">if</span> <span class="n">expression</span><span class="p">:</span> +</span><span id="Parser-4269"><a href="#Parser-4269"><span class="linenos">4269</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"exists"</span><span class="p">,</span> <span class="n">exists_column</span><span class="p">)</span> </span><span id="Parser-4270"><a href="#Parser-4270"><span class="linenos">4270</span></a> -</span><span id="Parser-4271"><a href="#Parser-4271"><span class="linenos">4271</span></a> <span class="k">return</span> <span class="n">expression</span> -</span><span id="Parser-4272"><a href="#Parser-4272"><span class="linenos">4272</span></a> -</span><span id="Parser-4273"><a href="#Parser-4273"><span class="linenos">4273</span></a> <span class="k">def</span> <span class="nf">_parse_drop_column</span><span class="p">(</span><span class="bp">self</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">Drop</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">]:</span> -</span><span id="Parser-4274"><a href="#Parser-4274"><span class="linenos">4274</span></a> <span class="n">drop</span> <span class="o">=</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">DROP</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_drop</span><span class="p">()</span> -</span><span id="Parser-4275"><a href="#Parser-4275"><span class="linenos">4275</span></a> <span class="k">if</span> <span class="n">drop</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">drop</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">):</span> -</span><span id="Parser-4276"><a href="#Parser-4276"><span class="linenos">4276</span></a> <span class="n">drop</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="n">drop</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"COLUMN"</span><span class="p">))</span> -</span><span id="Parser-4277"><a href="#Parser-4277"><span class="linenos">4277</span></a> <span class="k">return</span> <span class="n">drop</span> +</span><span id="Parser-4271"><a href="#Parser-4271"><span class="linenos">4271</span></a> <span class="c1"># https://docs.databricks.com/delta/update-schema.html#explicitly-update-schema-to-add-columns</span> +</span><span id="Parser-4272"><a href="#Parser-4272"><span class="linenos">4272</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"FIRST"</span><span class="p">,</span> <span class="s2">"AFTER"</span><span class="p">)):</span> +</span><span id="Parser-4273"><a href="#Parser-4273"><span class="linenos">4273</span></a> <span class="n">position</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><span id="Parser-4274"><a href="#Parser-4274"><span class="linenos">4274</span></a> <span class="n">column_position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-4275"><a href="#Parser-4275"><span class="linenos">4275</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnPosition</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_column</span><span class="p">(),</span> <span class="n">position</span><span class="o">=</span><span class="n">position</span> +</span><span id="Parser-4276"><a href="#Parser-4276"><span class="linenos">4276</span></a> <span class="p">)</span> +</span><span id="Parser-4277"><a href="#Parser-4277"><span class="linenos">4277</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"position"</span><span class="p">,</span> <span class="n">column_position</span><span class="p">)</span> </span><span id="Parser-4278"><a href="#Parser-4278"><span class="linenos">4278</span></a> -</span><span id="Parser-4279"><a href="#Parser-4279"><span class="linenos">4279</span></a> <span class="c1"># https://docs.aws.amazon.com/athena/latest/ug/alter-table-drop-partition.html</span> -</span><span id="Parser-4280"><a href="#Parser-4280"><span class="linenos">4280</span></a> <span class="k">def</span> <span class="nf">_parse_drop_partition</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exists</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DropPartition</span><span class="p">:</span> -</span><span id="Parser-4281"><a href="#Parser-4281"><span class="linenos">4281</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><span id="Parser-4282"><a href="#Parser-4282"><span class="linenos">4282</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DropPartition</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition</span><span class="p">),</span> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span> -</span><span id="Parser-4283"><a href="#Parser-4283"><span class="linenos">4283</span></a> <span class="p">)</span> -</span><span id="Parser-4284"><a href="#Parser-4284"><span class="linenos">4284</span></a> -</span><span id="Parser-4285"><a href="#Parser-4285"><span class="linenos">4285</span></a> <span class="k">def</span> <span class="nf">_parse_add_constraint</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">AddConstraint</span><span class="p">:</span> -</span><span id="Parser-4286"><a href="#Parser-4286"><span class="linenos">4286</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-4287"><a href="#Parser-4287"><span class="linenos">4287</span></a> <span class="n">kind</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">token_type</span> -</span><span id="Parser-4288"><a href="#Parser-4288"><span class="linenos">4288</span></a> -</span><span id="Parser-4289"><a href="#Parser-4289"><span class="linenos">4289</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CONSTRAINT</span><span class="p">:</span> -</span><span id="Parser-4290"><a href="#Parser-4290"><span class="linenos">4290</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="Parser-4291"><a href="#Parser-4291"><span class="linenos">4291</span></a> -</span><span id="Parser-4292"><a href="#Parser-4292"><span class="linenos">4292</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CHECK"</span><span class="p">):</span> -</span><span id="Parser-4293"><a href="#Parser-4293"><span class="linenos">4293</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> -</span><span id="Parser-4294"><a href="#Parser-4294"><span class="linenos">4294</span></a> <span class="n">enforced</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ENFORCED"</span><span class="p">)</span> -</span><span id="Parser-4295"><a href="#Parser-4295"><span class="linenos">4295</span></a> -</span><span id="Parser-4296"><a href="#Parser-4296"><span class="linenos">4296</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><span id="Parser-4297"><a href="#Parser-4297"><span class="linenos">4297</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AddConstraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">enforced</span><span class="o">=</span><span class="n">enforced</span> -</span><span id="Parser-4298"><a href="#Parser-4298"><span class="linenos">4298</span></a> <span class="p">)</span> +</span><span id="Parser-4279"><a href="#Parser-4279"><span class="linenos">4279</span></a> <span class="k">return</span> <span class="n">expression</span> +</span><span id="Parser-4280"><a href="#Parser-4280"><span class="linenos">4280</span></a> +</span><span id="Parser-4281"><a href="#Parser-4281"><span class="linenos">4281</span></a> <span class="k">def</span> <span class="nf">_parse_drop_column</span><span class="p">(</span><span class="bp">self</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">Drop</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">]:</span> +</span><span id="Parser-4282"><a href="#Parser-4282"><span class="linenos">4282</span></a> <span class="n">drop</span> <span class="o">=</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">DROP</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_drop</span><span class="p">()</span> +</span><span id="Parser-4283"><a href="#Parser-4283"><span class="linenos">4283</span></a> <span class="k">if</span> <span class="n">drop</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">drop</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">):</span> +</span><span id="Parser-4284"><a href="#Parser-4284"><span class="linenos">4284</span></a> <span class="n">drop</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="n">drop</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"kind"</span><span class="p">,</span> <span class="s2">"COLUMN"</span><span class="p">))</span> +</span><span id="Parser-4285"><a href="#Parser-4285"><span class="linenos">4285</span></a> <span class="k">return</span> <span class="n">drop</span> +</span><span id="Parser-4286"><a href="#Parser-4286"><span class="linenos">4286</span></a> +</span><span id="Parser-4287"><a href="#Parser-4287"><span class="linenos">4287</span></a> <span class="c1"># https://docs.aws.amazon.com/athena/latest/ug/alter-table-drop-partition.html</span> +</span><span id="Parser-4288"><a href="#Parser-4288"><span class="linenos">4288</span></a> <span class="k">def</span> <span class="nf">_parse_drop_partition</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exists</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">bool</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DropPartition</span><span class="p">:</span> +</span><span id="Parser-4289"><a href="#Parser-4289"><span class="linenos">4289</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><span id="Parser-4290"><a href="#Parser-4290"><span class="linenos">4290</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DropPartition</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_partition</span><span class="p">),</span> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span> +</span><span id="Parser-4291"><a href="#Parser-4291"><span class="linenos">4291</span></a> <span class="p">)</span> +</span><span id="Parser-4292"><a href="#Parser-4292"><span class="linenos">4292</span></a> +</span><span id="Parser-4293"><a href="#Parser-4293"><span class="linenos">4293</span></a> <span class="k">def</span> <span class="nf">_parse_add_constraint</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">AddConstraint</span><span class="p">:</span> +</span><span id="Parser-4294"><a href="#Parser-4294"><span class="linenos">4294</span></a> <span class="n">this</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-4295"><a href="#Parser-4295"><span class="linenos">4295</span></a> <span class="n">kind</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">token_type</span> +</span><span id="Parser-4296"><a href="#Parser-4296"><span class="linenos">4296</span></a> +</span><span id="Parser-4297"><a href="#Parser-4297"><span class="linenos">4297</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CONSTRAINT</span><span class="p">:</span> +</span><span id="Parser-4298"><a href="#Parser-4298"><span class="linenos">4298</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> </span><span id="Parser-4299"><a href="#Parser-4299"><span class="linenos">4299</span></a> -</span><span id="Parser-4300"><a href="#Parser-4300"><span class="linenos">4300</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FOREIGN_KEY</span> <span class="ow">or</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">FOREIGN_KEY</span><span class="p">):</span> -</span><span id="Parser-4301"><a href="#Parser-4301"><span class="linenos">4301</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_foreign_key</span><span class="p">()</span> -</span><span id="Parser-4302"><a href="#Parser-4302"><span class="linenos">4302</span></a> <span class="k">elif</span> <span class="n">kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PRIMARY_KEY</span> <span class="ow">or</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">PRIMARY_KEY</span><span class="p">):</span> -</span><span id="Parser-4303"><a href="#Parser-4303"><span class="linenos">4303</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary_key</span><span class="p">()</span> -</span><span id="Parser-4304"><a href="#Parser-4304"><span class="linenos">4304</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-4305"><a href="#Parser-4305"><span class="linenos">4305</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-4306"><a href="#Parser-4306"><span class="linenos">4306</span></a> -</span><span id="Parser-4307"><a href="#Parser-4307"><span class="linenos">4307</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">AddConstraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Parser-4308"><a href="#Parser-4308"><span class="linenos">4308</span></a> -</span><span id="Parser-4309"><a href="#Parser-4309"><span class="linenos">4309</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_add</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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="Parser-4310"><a href="#Parser-4310"><span class="linenos">4310</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span> -</span><span id="Parser-4311"><a href="#Parser-4311"><span class="linenos">4311</span></a> -</span><span id="Parser-4312"><a href="#Parser-4312"><span class="linenos">4312</span></a> <span class="k">if</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">ADD_CONSTRAINT_TOKENS</span><span class="p">):</span> -</span><span id="Parser-4313"><a href="#Parser-4313"><span class="linenos">4313</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_add_constraint</span><span class="p">)</span> +</span><span id="Parser-4300"><a href="#Parser-4300"><span class="linenos">4300</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"CHECK"</span><span class="p">):</span> +</span><span id="Parser-4301"><a href="#Parser-4301"><span class="linenos">4301</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_wrapped</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">)</span> +</span><span id="Parser-4302"><a href="#Parser-4302"><span class="linenos">4302</span></a> <span class="n">enforced</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"ENFORCED"</span><span class="p">)</span> +</span><span id="Parser-4303"><a href="#Parser-4303"><span class="linenos">4303</span></a> +</span><span id="Parser-4304"><a href="#Parser-4304"><span class="linenos">4304</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><span id="Parser-4305"><a href="#Parser-4305"><span class="linenos">4305</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AddConstraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">,</span> <span class="n">enforced</span><span class="o">=</span><span class="n">enforced</span> +</span><span id="Parser-4306"><a href="#Parser-4306"><span class="linenos">4306</span></a> <span class="p">)</span> +</span><span id="Parser-4307"><a href="#Parser-4307"><span class="linenos">4307</span></a> +</span><span id="Parser-4308"><a href="#Parser-4308"><span class="linenos">4308</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FOREIGN_KEY</span> <span class="ow">or</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">FOREIGN_KEY</span><span class="p">):</span> +</span><span id="Parser-4309"><a href="#Parser-4309"><span class="linenos">4309</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_foreign_key</span><span class="p">()</span> +</span><span id="Parser-4310"><a href="#Parser-4310"><span class="linenos">4310</span></a> <span class="k">elif</span> <span class="n">kind</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PRIMARY_KEY</span> <span class="ow">or</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">PRIMARY_KEY</span><span class="p">):</span> +</span><span id="Parser-4311"><a href="#Parser-4311"><span class="linenos">4311</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary_key</span><span class="p">()</span> +</span><span id="Parser-4312"><a href="#Parser-4312"><span class="linenos">4312</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-4313"><a href="#Parser-4313"><span class="linenos">4313</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="kc">None</span> </span><span id="Parser-4314"><a href="#Parser-4314"><span class="linenos">4314</span></a> -</span><span id="Parser-4315"><a href="#Parser-4315"><span class="linenos">4315</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-4316"><a href="#Parser-4316"><span class="linenos">4316</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_add_column</span><span class="p">)</span> -</span><span id="Parser-4317"><a href="#Parser-4317"><span class="linenos">4317</span></a> -</span><span id="Parser-4318"><a href="#Parser-4318"><span class="linenos">4318</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_alter</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">AlterColumn</span><span class="p">:</span> -</span><span id="Parser-4319"><a href="#Parser-4319"><span class="linenos">4319</span></a> <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">COLUMN</span><span class="p">)</span> -</span><span id="Parser-4320"><a href="#Parser-4320"><span class="linenos">4320</span></a> <span class="n">column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-4321"><a href="#Parser-4321"><span class="linenos">4321</span></a> -</span><span id="Parser-4322"><a href="#Parser-4322"><span class="linenos">4322</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DROP</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">):</span> -</span><span id="Parser-4323"><a href="#Parser-4323"><span class="linenos">4323</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">AlterColumn</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">column</span><span class="p">,</span> <span class="n">drop</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-4324"><a href="#Parser-4324"><span class="linenos">4324</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">):</span> -</span><span id="Parser-4325"><a href="#Parser-4325"><span class="linenos">4325</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">AlterColumn</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">column</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">())</span> -</span><span id="Parser-4326"><a href="#Parser-4326"><span class="linenos">4326</span></a> -</span><span id="Parser-4327"><a href="#Parser-4327"><span class="linenos">4327</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SET"</span><span class="p">,</span> <span class="s2">"DATA"</span><span class="p">)</span> -</span><span id="Parser-4328"><a href="#Parser-4328"><span class="linenos">4328</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><span id="Parser-4329"><a href="#Parser-4329"><span class="linenos">4329</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AlterColumn</span><span class="p">,</span> -</span><span id="Parser-4330"><a href="#Parser-4330"><span class="linenos">4330</span></a> <span class="n">this</span><span class="o">=</span><span class="n">column</span><span class="p">,</span> -</span><span id="Parser-4331"><a href="#Parser-4331"><span class="linenos">4331</span></a> <span class="n">dtype</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TYPE"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(),</span> -</span><span id="Parser-4332"><a href="#Parser-4332"><span class="linenos">4332</span></a> <span class="n">collate</span><span class="o">=</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">COLLATE</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">(),</span> -</span><span id="Parser-4333"><a href="#Parser-4333"><span class="linenos">4333</span></a> <span class="n">using</span><span class="o">=</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">USING</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">(),</span> -</span><span id="Parser-4334"><a href="#Parser-4334"><span class="linenos">4334</span></a> <span class="p">)</span> -</span><span id="Parser-4335"><a href="#Parser-4335"><span class="linenos">4335</span></a> -</span><span id="Parser-4336"><a href="#Parser-4336"><span class="linenos">4336</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_drop</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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="Parser-4337"><a href="#Parser-4337"><span class="linenos">4337</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span> -</span><span id="Parser-4338"><a href="#Parser-4338"><span class="linenos">4338</span></a> -</span><span id="Parser-4339"><a href="#Parser-4339"><span class="linenos">4339</span></a> <span class="n">partition_exists</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">()</span> -</span><span id="Parser-4340"><a href="#Parser-4340"><span class="linenos">4340</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">PARTITION</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="Parser-4341"><a href="#Parser-4341"><span class="linenos">4341</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_drop_partition</span><span class="p">(</span><span class="n">exists</span><span class="o">=</span><span class="n">partition_exists</span><span class="p">))</span> -</span><span id="Parser-4342"><a href="#Parser-4342"><span class="linenos">4342</span></a> -</span><span id="Parser-4343"><a href="#Parser-4343"><span class="linenos">4343</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-4344"><a href="#Parser-4344"><span class="linenos">4344</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_drop_column</span><span class="p">)</span> -</span><span id="Parser-4345"><a href="#Parser-4345"><span class="linenos">4345</span></a> -</span><span id="Parser-4346"><a href="#Parser-4346"><span class="linenos">4346</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_rename</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">RenameTable</span><span class="p">:</span> -</span><span id="Parser-4347"><a href="#Parser-4347"><span class="linenos">4347</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">)</span> -</span><span id="Parser-4348"><a href="#Parser-4348"><span class="linenos">4348</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">RenameTable</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_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> -</span><span id="Parser-4349"><a href="#Parser-4349"><span class="linenos">4349</span></a> -</span><span id="Parser-4350"><a href="#Parser-4350"><span class="linenos">4350</span></a> <span class="k">def</span> <span class="nf">_parse_alter</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">AlterTable</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> -</span><span id="Parser-4351"><a href="#Parser-4351"><span class="linenos">4351</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> -</span><span id="Parser-4352"><a href="#Parser-4352"><span class="linenos">4352</span></a> -</span><span id="Parser-4353"><a href="#Parser-4353"><span class="linenos">4353</span></a> <span class="k">if</span> <span class="ow">not</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">TABLE</span><span class="p">):</span> -</span><span id="Parser-4354"><a href="#Parser-4354"><span class="linenos">4354</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> -</span><span id="Parser-4355"><a href="#Parser-4355"><span class="linenos">4355</span></a> -</span><span id="Parser-4356"><a href="#Parser-4356"><span class="linenos">4356</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">()</span> -</span><span id="Parser-4357"><a href="#Parser-4357"><span class="linenos">4357</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Parser-4358"><a href="#Parser-4358"><span class="linenos">4358</span></a> -</span><span id="Parser-4359"><a href="#Parser-4359"><span class="linenos">4359</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> -</span><span id="Parser-4360"><a href="#Parser-4360"><span class="linenos">4360</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Parser-4361"><a href="#Parser-4361"><span class="linenos">4361</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALTER_PARSERS</span><span class="o">.</span><span class="n">get</span><span class="p">(</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="o">.</span><span class="n">upper</span><span class="p">())</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="Parser-4362"><a href="#Parser-4362"><span class="linenos">4362</span></a> -</span><span id="Parser-4363"><a href="#Parser-4363"><span class="linenos">4363</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> -</span><span id="Parser-4364"><a href="#Parser-4364"><span class="linenos">4364</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span> -</span><span id="Parser-4365"><a href="#Parser-4365"><span class="linenos">4365</span></a> -</span><span id="Parser-4366"><a href="#Parser-4366"><span class="linenos">4366</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="Parser-4367"><a href="#Parser-4367"><span class="linenos">4367</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><span id="Parser-4368"><a href="#Parser-4368"><span class="linenos">4368</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AlterTable</span><span class="p">,</span> -</span><span id="Parser-4369"><a href="#Parser-4369"><span class="linenos">4369</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="Parser-4370"><a href="#Parser-4370"><span class="linenos">4370</span></a> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span><span class="p">,</span> -</span><span id="Parser-4371"><a href="#Parser-4371"><span class="linenos">4371</span></a> <span class="n">actions</span><span class="o">=</span><span class="n">actions</span><span class="p">,</span> -</span><span id="Parser-4372"><a href="#Parser-4372"><span class="linenos">4372</span></a> <span class="p">)</span> -</span><span id="Parser-4373"><a href="#Parser-4373"><span class="linenos">4373</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> -</span><span id="Parser-4374"><a href="#Parser-4374"><span class="linenos">4374</span></a> -</span><span id="Parser-4375"><a href="#Parser-4375"><span class="linenos">4375</span></a> <span class="k">def</span> <span class="nf">_parse_merge</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">Merge</span><span class="p">:</span> -</span><span id="Parser-4376"><a href="#Parser-4376"><span class="linenos">4376</span></a> <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">INTO</span><span class="p">)</span> -</span><span id="Parser-4377"><a href="#Parser-4377"><span class="linenos">4377</span></a> <span class="n">target</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> -</span><span id="Parser-4378"><a href="#Parser-4378"><span class="linenos">4378</span></a> -</span><span id="Parser-4379"><a href="#Parser-4379"><span class="linenos">4379</span></a> <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">USING</span><span class="p">)</span> -</span><span id="Parser-4380"><a href="#Parser-4380"><span class="linenos">4380</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> -</span><span id="Parser-4381"><a href="#Parser-4381"><span class="linenos">4381</span></a> -</span><span id="Parser-4382"><a href="#Parser-4382"><span class="linenos">4382</span></a> <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">ON</span><span class="p">)</span> -</span><span id="Parser-4383"><a href="#Parser-4383"><span class="linenos">4383</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> -</span><span id="Parser-4384"><a href="#Parser-4384"><span class="linenos">4384</span></a> -</span><span id="Parser-4385"><a href="#Parser-4385"><span class="linenos">4385</span></a> <span class="n">whens</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-4386"><a href="#Parser-4386"><span class="linenos">4386</span></a> <span class="k">while</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">WHEN</span><span class="p">):</span> -</span><span id="Parser-4387"><a href="#Parser-4387"><span class="linenos">4387</span></a> <span class="n">matched</span> <span class="o">=</span> <span class="ow">not</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">NOT</span><span class="p">)</span> -</span><span id="Parser-4388"><a href="#Parser-4388"><span class="linenos">4388</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MATCHED"</span><span class="p">)</span> -</span><span id="Parser-4389"><a href="#Parser-4389"><span class="linenos">4389</span></a> <span class="n">source</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Parser-4390"><a href="#Parser-4390"><span class="linenos">4390</span></a> <span class="kc">False</span> -</span><span id="Parser-4391"><a href="#Parser-4391"><span class="linenos">4391</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BY"</span><span class="p">,</span> <span class="s2">"TARGET"</span><span class="p">)</span> -</span><span id="Parser-4392"><a href="#Parser-4392"><span class="linenos">4392</span></a> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BY"</span><span class="p">,</span> <span class="s2">"SOURCE"</span><span class="p">)</span> -</span><span id="Parser-4393"><a href="#Parser-4393"><span class="linenos">4393</span></a> <span class="p">)</span> -</span><span id="Parser-4394"><a href="#Parser-4394"><span class="linenos">4394</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> <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">AND</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> -</span><span id="Parser-4395"><a href="#Parser-4395"><span class="linenos">4395</span></a> -</span><span id="Parser-4396"><a href="#Parser-4396"><span class="linenos">4396</span></a> <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">THEN</span><span class="p">)</span> -</span><span id="Parser-4397"><a href="#Parser-4397"><span class="linenos">4397</span></a> -</span><span id="Parser-4398"><a href="#Parser-4398"><span class="linenos">4398</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">INSERT</span><span class="p">):</span> -</span><span id="Parser-4399"><a href="#Parser-4399"><span class="linenos">4399</span></a> <span class="n">_this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_star</span><span class="p">()</span> -</span><span id="Parser-4400"><a href="#Parser-4400"><span class="linenos">4400</span></a> <span class="k">if</span> <span class="n">_this</span><span class="p">:</span> -</span><span id="Parser-4401"><a href="#Parser-4401"><span class="linenos">4401</span></a> <span class="n">then</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="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">Insert</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">_this</span><span class="p">)</span> -</span><span id="Parser-4402"><a href="#Parser-4402"><span class="linenos">4402</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-4403"><a href="#Parser-4403"><span class="linenos">4403</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-4404"><a href="#Parser-4404"><span class="linenos">4404</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">,</span> -</span><span id="Parser-4405"><a href="#Parser-4405"><span class="linenos">4405</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">(),</span> -</span><span id="Parser-4406"><a href="#Parser-4406"><span class="linenos">4406</span></a> <span class="n">expression</span><span class="o">=</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">VALUES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">(),</span> -</span><span id="Parser-4407"><a href="#Parser-4407"><span class="linenos">4407</span></a> <span class="p">)</span> -</span><span id="Parser-4408"><a href="#Parser-4408"><span class="linenos">4408</span></a> <span class="k">elif</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">UPDATE</span><span class="p">):</span> -</span><span id="Parser-4409"><a href="#Parser-4409"><span class="linenos">4409</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_star</span><span class="p">()</span> -</span><span id="Parser-4410"><a href="#Parser-4410"><span class="linenos">4410</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="Parser-4411"><a href="#Parser-4411"><span class="linenos">4411</span></a> <span class="n">then</span> <span class="o">=</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">Update</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Parser-4412"><a href="#Parser-4412"><span class="linenos">4412</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-4413"><a href="#Parser-4413"><span class="linenos">4413</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-4414"><a href="#Parser-4414"><span class="linenos">4414</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> -</span><span id="Parser-4415"><a href="#Parser-4415"><span class="linenos">4415</span></a> <span class="n">expressions</span><span class="o">=</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">SET</span><span class="p">)</span> -</span><span id="Parser-4416"><a href="#Parser-4416"><span class="linenos">4416</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">),</span> -</span><span id="Parser-4417"><a href="#Parser-4417"><span class="linenos">4417</span></a> <span class="p">)</span> -</span><span id="Parser-4418"><a href="#Parser-4418"><span class="linenos">4418</span></a> <span class="k">elif</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">DELETE</span><span class="p">):</span> -</span><span id="Parser-4419"><a href="#Parser-4419"><span class="linenos">4419</span></a> <span class="n">then</span> <span class="o">=</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">Var</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="Parser-4420"><a href="#Parser-4420"><span class="linenos">4420</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-4421"><a href="#Parser-4421"><span class="linenos">4421</span></a> <span class="n">then</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser-4422"><a href="#Parser-4422"><span class="linenos">4422</span></a> -</span><span id="Parser-4423"><a href="#Parser-4423"><span class="linenos">4423</span></a> <span class="n">whens</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="Parser-4424"><a href="#Parser-4424"><span class="linenos">4424</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> -</span><span id="Parser-4425"><a href="#Parser-4425"><span class="linenos">4425</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">When</span><span class="p">,</span> -</span><span id="Parser-4426"><a href="#Parser-4426"><span class="linenos">4426</span></a> <span class="n">matched</span><span class="o">=</span><span class="n">matched</span><span class="p">,</span> -</span><span id="Parser-4427"><a href="#Parser-4427"><span class="linenos">4427</span></a> <span class="n">source</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> -</span><span id="Parser-4428"><a href="#Parser-4428"><span class="linenos">4428</span></a> <span class="n">condition</span><span class="o">=</span><span class="n">condition</span><span class="p">,</span> -</span><span id="Parser-4429"><a href="#Parser-4429"><span class="linenos">4429</span></a> <span class="n">then</span><span class="o">=</span><span class="n">then</span><span class="p">,</span> -</span><span id="Parser-4430"><a href="#Parser-4430"><span class="linenos">4430</span></a> <span class="p">)</span> -</span><span id="Parser-4431"><a href="#Parser-4431"><span class="linenos">4431</span></a> <span class="p">)</span> -</span><span id="Parser-4432"><a href="#Parser-4432"><span class="linenos">4432</span></a> -</span><span id="Parser-4433"><a href="#Parser-4433"><span class="linenos">4433</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><span id="Parser-4434"><a href="#Parser-4434"><span class="linenos">4434</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Merge</span><span class="p">,</span> -</span><span id="Parser-4435"><a href="#Parser-4435"><span class="linenos">4435</span></a> <span class="n">this</span><span class="o">=</span><span class="n">target</span><span class="p">,</span> -</span><span id="Parser-4436"><a href="#Parser-4436"><span class="linenos">4436</span></a> <span class="n">using</span><span class="o">=</span><span class="n">using</span><span class="p">,</span> -</span><span id="Parser-4437"><a href="#Parser-4437"><span class="linenos">4437</span></a> <span class="n">on</span><span class="o">=</span><span class="n">on</span><span class="p">,</span> -</span><span id="Parser-4438"><a href="#Parser-4438"><span class="linenos">4438</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">whens</span><span class="p">,</span> -</span><span id="Parser-4439"><a href="#Parser-4439"><span class="linenos">4439</span></a> <span class="p">)</span> +</span><span id="Parser-4315"><a href="#Parser-4315"><span class="linenos">4315</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">AddConstraint</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Parser-4316"><a href="#Parser-4316"><span class="linenos">4316</span></a> +</span><span id="Parser-4317"><a href="#Parser-4317"><span class="linenos">4317</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_add</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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="Parser-4318"><a href="#Parser-4318"><span class="linenos">4318</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span> +</span><span id="Parser-4319"><a href="#Parser-4319"><span class="linenos">4319</span></a> +</span><span id="Parser-4320"><a href="#Parser-4320"><span class="linenos">4320</span></a> <span class="k">if</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">ADD_CONSTRAINT_TOKENS</span><span class="p">):</span> +</span><span id="Parser-4321"><a href="#Parser-4321"><span class="linenos">4321</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_add_constraint</span><span class="p">)</span> +</span><span id="Parser-4322"><a href="#Parser-4322"><span class="linenos">4322</span></a> +</span><span id="Parser-4323"><a href="#Parser-4323"><span class="linenos">4323</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-4324"><a href="#Parser-4324"><span class="linenos">4324</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_add_column</span><span class="p">)</span> +</span><span id="Parser-4325"><a href="#Parser-4325"><span class="linenos">4325</span></a> +</span><span id="Parser-4326"><a href="#Parser-4326"><span class="linenos">4326</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_alter</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">AlterColumn</span><span class="p">:</span> +</span><span id="Parser-4327"><a href="#Parser-4327"><span class="linenos">4327</span></a> <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">COLUMN</span><span class="p">)</span> +</span><span id="Parser-4328"><a href="#Parser-4328"><span class="linenos">4328</span></a> <span class="n">column</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_field</span><span class="p">(</span><span class="n">any_token</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-4329"><a href="#Parser-4329"><span class="linenos">4329</span></a> +</span><span id="Parser-4330"><a href="#Parser-4330"><span class="linenos">4330</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DROP</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">):</span> +</span><span id="Parser-4331"><a href="#Parser-4331"><span class="linenos">4331</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">AlterColumn</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">column</span><span class="p">,</span> <span class="n">drop</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-4332"><a href="#Parser-4332"><span class="linenos">4332</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_pair</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">):</span> +</span><span id="Parser-4333"><a href="#Parser-4333"><span class="linenos">4333</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">AlterColumn</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">column</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">())</span> +</span><span id="Parser-4334"><a href="#Parser-4334"><span class="linenos">4334</span></a> +</span><span id="Parser-4335"><a href="#Parser-4335"><span class="linenos">4335</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"SET"</span><span class="p">,</span> <span class="s2">"DATA"</span><span class="p">)</span> +</span><span id="Parser-4336"><a href="#Parser-4336"><span class="linenos">4336</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><span id="Parser-4337"><a href="#Parser-4337"><span class="linenos">4337</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AlterColumn</span><span class="p">,</span> +</span><span id="Parser-4338"><a href="#Parser-4338"><span class="linenos">4338</span></a> <span class="n">this</span><span class="o">=</span><span class="n">column</span><span class="p">,</span> +</span><span id="Parser-4339"><a href="#Parser-4339"><span class="linenos">4339</span></a> <span class="n">dtype</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TYPE"</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_types</span><span class="p">(),</span> +</span><span id="Parser-4340"><a href="#Parser-4340"><span class="linenos">4340</span></a> <span class="n">collate</span><span class="o">=</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">COLLATE</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_term</span><span class="p">(),</span> +</span><span id="Parser-4341"><a href="#Parser-4341"><span class="linenos">4341</span></a> <span class="n">using</span><span class="o">=</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">USING</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">(),</span> +</span><span id="Parser-4342"><a href="#Parser-4342"><span class="linenos">4342</span></a> <span class="p">)</span> +</span><span id="Parser-4343"><a href="#Parser-4343"><span class="linenos">4343</span></a> +</span><span id="Parser-4344"><a href="#Parser-4344"><span class="linenos">4344</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_drop</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">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="Parser-4345"><a href="#Parser-4345"><span class="linenos">4345</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">-</span> <span class="mi">1</span> +</span><span id="Parser-4346"><a href="#Parser-4346"><span class="linenos">4346</span></a> +</span><span id="Parser-4347"><a href="#Parser-4347"><span class="linenos">4347</span></a> <span class="n">partition_exists</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">()</span> +</span><span id="Parser-4348"><a href="#Parser-4348"><span class="linenos">4348</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">PARTITION</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="Parser-4349"><a href="#Parser-4349"><span class="linenos">4349</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_drop_partition</span><span class="p">(</span><span class="n">exists</span><span class="o">=</span><span class="n">partition_exists</span><span class="p">))</span> +</span><span id="Parser-4350"><a href="#Parser-4350"><span class="linenos">4350</span></a> +</span><span id="Parser-4351"><a href="#Parser-4351"><span class="linenos">4351</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-4352"><a href="#Parser-4352"><span class="linenos">4352</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_drop_column</span><span class="p">)</span> +</span><span id="Parser-4353"><a href="#Parser-4353"><span class="linenos">4353</span></a> +</span><span id="Parser-4354"><a href="#Parser-4354"><span class="linenos">4354</span></a> <span class="k">def</span> <span class="nf">_parse_alter_table_rename</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">RenameTable</span><span class="p">:</span> +</span><span id="Parser-4355"><a href="#Parser-4355"><span class="linenos">4355</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TO"</span><span class="p">)</span> +</span><span id="Parser-4356"><a href="#Parser-4356"><span class="linenos">4356</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">RenameTable</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_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span> +</span><span id="Parser-4357"><a href="#Parser-4357"><span class="linenos">4357</span></a> +</span><span id="Parser-4358"><a href="#Parser-4358"><span class="linenos">4358</span></a> <span class="k">def</span> <span class="nf">_parse_alter</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">AlterTable</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> +</span><span id="Parser-4359"><a href="#Parser-4359"><span class="linenos">4359</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> +</span><span id="Parser-4360"><a href="#Parser-4360"><span class="linenos">4360</span></a> +</span><span id="Parser-4361"><a href="#Parser-4361"><span class="linenos">4361</span></a> <span class="k">if</span> <span class="ow">not</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">TABLE</span><span class="p">):</span> +</span><span id="Parser-4362"><a href="#Parser-4362"><span class="linenos">4362</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> +</span><span id="Parser-4363"><a href="#Parser-4363"><span class="linenos">4363</span></a> +</span><span id="Parser-4364"><a href="#Parser-4364"><span class="linenos">4364</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_exists</span><span class="p">()</span> +</span><span id="Parser-4365"><a href="#Parser-4365"><span class="linenos">4365</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Parser-4366"><a href="#Parser-4366"><span class="linenos">4366</span></a> +</span><span id="Parser-4367"><a href="#Parser-4367"><span class="linenos">4367</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> +</span><span id="Parser-4368"><a href="#Parser-4368"><span class="linenos">4368</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Parser-4369"><a href="#Parser-4369"><span class="linenos">4369</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALTER_PARSERS</span><span class="o">.</span><span class="n">get</span><span class="p">(</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="o">.</span><span class="n">upper</span><span class="p">())</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="Parser-4370"><a href="#Parser-4370"><span class="linenos">4370</span></a> +</span><span id="Parser-4371"><a href="#Parser-4371"><span class="linenos">4371</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> +</span><span id="Parser-4372"><a href="#Parser-4372"><span class="linenos">4372</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span> +</span><span id="Parser-4373"><a href="#Parser-4373"><span class="linenos">4373</span></a> +</span><span id="Parser-4374"><a href="#Parser-4374"><span class="linenos">4374</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="Parser-4375"><a href="#Parser-4375"><span class="linenos">4375</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><span id="Parser-4376"><a href="#Parser-4376"><span class="linenos">4376</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">AlterTable</span><span class="p">,</span> +</span><span id="Parser-4377"><a href="#Parser-4377"><span class="linenos">4377</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="Parser-4378"><a href="#Parser-4378"><span class="linenos">4378</span></a> <span class="n">exists</span><span class="o">=</span><span class="n">exists</span><span class="p">,</span> +</span><span id="Parser-4379"><a href="#Parser-4379"><span class="linenos">4379</span></a> <span class="n">actions</span><span class="o">=</span><span class="n">actions</span><span class="p">,</span> +</span><span id="Parser-4380"><a href="#Parser-4380"><span class="linenos">4380</span></a> <span class="p">)</span> +</span><span id="Parser-4381"><a href="#Parser-4381"><span class="linenos">4381</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="n">start</span><span class="p">)</span> +</span><span id="Parser-4382"><a href="#Parser-4382"><span class="linenos">4382</span></a> +</span><span id="Parser-4383"><a href="#Parser-4383"><span class="linenos">4383</span></a> <span class="k">def</span> <span class="nf">_parse_merge</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">Merge</span><span class="p">:</span> +</span><span id="Parser-4384"><a href="#Parser-4384"><span class="linenos">4384</span></a> <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">INTO</span><span class="p">)</span> +</span><span id="Parser-4385"><a href="#Parser-4385"><span class="linenos">4385</span></a> <span class="n">target</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> +</span><span id="Parser-4386"><a href="#Parser-4386"><span class="linenos">4386</span></a> +</span><span id="Parser-4387"><a href="#Parser-4387"><span class="linenos">4387</span></a> <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">USING</span><span class="p">)</span> +</span><span id="Parser-4388"><a href="#Parser-4388"><span class="linenos">4388</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_table</span><span class="p">()</span> +</span><span id="Parser-4389"><a href="#Parser-4389"><span class="linenos">4389</span></a> +</span><span id="Parser-4390"><a href="#Parser-4390"><span class="linenos">4390</span></a> <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">ON</span><span class="p">)</span> +</span><span id="Parser-4391"><a href="#Parser-4391"><span class="linenos">4391</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> +</span><span id="Parser-4392"><a href="#Parser-4392"><span class="linenos">4392</span></a> +</span><span id="Parser-4393"><a href="#Parser-4393"><span class="linenos">4393</span></a> <span class="n">whens</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-4394"><a href="#Parser-4394"><span class="linenos">4394</span></a> <span class="k">while</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">WHEN</span><span class="p">):</span> +</span><span id="Parser-4395"><a href="#Parser-4395"><span class="linenos">4395</span></a> <span class="n">matched</span> <span class="o">=</span> <span class="ow">not</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">NOT</span><span class="p">)</span> +</span><span id="Parser-4396"><a href="#Parser-4396"><span class="linenos">4396</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MATCHED"</span><span class="p">)</span> +</span><span id="Parser-4397"><a href="#Parser-4397"><span class="linenos">4397</span></a> <span class="n">source</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Parser-4398"><a href="#Parser-4398"><span class="linenos">4398</span></a> <span class="kc">False</span> +</span><span id="Parser-4399"><a href="#Parser-4399"><span class="linenos">4399</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BY"</span><span class="p">,</span> <span class="s2">"TARGET"</span><span class="p">)</span> +</span><span id="Parser-4400"><a href="#Parser-4400"><span class="linenos">4400</span></a> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"BY"</span><span class="p">,</span> <span class="s2">"SOURCE"</span><span class="p">)</span> +</span><span id="Parser-4401"><a href="#Parser-4401"><span class="linenos">4401</span></a> <span class="p">)</span> +</span><span id="Parser-4402"><a href="#Parser-4402"><span class="linenos">4402</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_conjunction</span><span class="p">()</span> <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">AND</span><span class="p">)</span> <span class="k">else</span> <span class="kc">None</span> +</span><span id="Parser-4403"><a href="#Parser-4403"><span class="linenos">4403</span></a> +</span><span id="Parser-4404"><a href="#Parser-4404"><span class="linenos">4404</span></a> <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">THEN</span><span class="p">)</span> +</span><span id="Parser-4405"><a href="#Parser-4405"><span class="linenos">4405</span></a> +</span><span id="Parser-4406"><a href="#Parser-4406"><span class="linenos">4406</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">INSERT</span><span class="p">):</span> +</span><span id="Parser-4407"><a href="#Parser-4407"><span class="linenos">4407</span></a> <span class="n">_this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_star</span><span class="p">()</span> +</span><span id="Parser-4408"><a href="#Parser-4408"><span class="linenos">4408</span></a> <span class="k">if</span> <span class="n">_this</span><span class="p">:</span> +</span><span id="Parser-4409"><a href="#Parser-4409"><span class="linenos">4409</span></a> <span class="n">then</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="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">Insert</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">_this</span><span class="p">)</span> +</span><span id="Parser-4410"><a href="#Parser-4410"><span class="linenos">4410</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-4411"><a href="#Parser-4411"><span class="linenos">4411</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-4412"><a href="#Parser-4412"><span class="linenos">4412</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">,</span> +</span><span id="Parser-4413"><a href="#Parser-4413"><span class="linenos">4413</span></a> <span class="n">this</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">(),</span> +</span><span id="Parser-4414"><a href="#Parser-4414"><span class="linenos">4414</span></a> <span class="n">expression</span><span class="o">=</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">VALUES</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_value</span><span class="p">(),</span> +</span><span id="Parser-4415"><a href="#Parser-4415"><span class="linenos">4415</span></a> <span class="p">)</span> +</span><span id="Parser-4416"><a href="#Parser-4416"><span class="linenos">4416</span></a> <span class="k">elif</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">UPDATE</span><span class="p">):</span> +</span><span id="Parser-4417"><a href="#Parser-4417"><span class="linenos">4417</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_star</span><span class="p">()</span> +</span><span id="Parser-4418"><a href="#Parser-4418"><span class="linenos">4418</span></a> <span class="k">if</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="Parser-4419"><a href="#Parser-4419"><span class="linenos">4419</span></a> <span class="n">then</span> <span class="o">=</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">Update</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Parser-4420"><a href="#Parser-4420"><span class="linenos">4420</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-4421"><a href="#Parser-4421"><span class="linenos">4421</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-4422"><a href="#Parser-4422"><span class="linenos">4422</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">,</span> +</span><span id="Parser-4423"><a href="#Parser-4423"><span class="linenos">4423</span></a> <span class="n">expressions</span><span class="o">=</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">SET</span><span class="p">)</span> +</span><span id="Parser-4424"><a href="#Parser-4424"><span class="linenos">4424</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_equality</span><span class="p">),</span> +</span><span id="Parser-4425"><a href="#Parser-4425"><span class="linenos">4425</span></a> <span class="p">)</span> +</span><span id="Parser-4426"><a href="#Parser-4426"><span class="linenos">4426</span></a> <span class="k">elif</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">DELETE</span><span class="p">):</span> +</span><span id="Parser-4427"><a href="#Parser-4427"><span class="linenos">4427</span></a> <span class="n">then</span> <span class="o">=</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">Var</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="Parser-4428"><a href="#Parser-4428"><span class="linenos">4428</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-4429"><a href="#Parser-4429"><span class="linenos">4429</span></a> <span class="n">then</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser-4430"><a href="#Parser-4430"><span class="linenos">4430</span></a> +</span><span id="Parser-4431"><a href="#Parser-4431"><span class="linenos">4431</span></a> <span class="n">whens</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="Parser-4432"><a href="#Parser-4432"><span class="linenos">4432</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">expression</span><span class="p">(</span> +</span><span id="Parser-4433"><a href="#Parser-4433"><span class="linenos">4433</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">When</span><span class="p">,</span> +</span><span id="Parser-4434"><a href="#Parser-4434"><span class="linenos">4434</span></a> <span class="n">matched</span><span class="o">=</span><span class="n">matched</span><span class="p">,</span> +</span><span id="Parser-4435"><a href="#Parser-4435"><span class="linenos">4435</span></a> <span class="n">source</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> +</span><span id="Parser-4436"><a href="#Parser-4436"><span class="linenos">4436</span></a> <span class="n">condition</span><span class="o">=</span><span class="n">condition</span><span class="p">,</span> +</span><span id="Parser-4437"><a href="#Parser-4437"><span class="linenos">4437</span></a> <span class="n">then</span><span class="o">=</span><span class="n">then</span><span class="p">,</span> +</span><span id="Parser-4438"><a href="#Parser-4438"><span class="linenos">4438</span></a> <span class="p">)</span> +</span><span id="Parser-4439"><a href="#Parser-4439"><span class="linenos">4439</span></a> <span class="p">)</span> </span><span id="Parser-4440"><a href="#Parser-4440"><span class="linenos">4440</span></a> -</span><span id="Parser-4441"><a href="#Parser-4441"><span class="linenos">4441</span></a> <span class="k">def</span> <span class="nf">_parse_show</span><span class="p">(</span><span class="bp">self</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="Parser-4442"><a href="#Parser-4442"><span class="linenos">4442</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_parser</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SHOW_PARSERS</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SHOW_TRIE</span><span class="p">)</span> -</span><span id="Parser-4443"><a href="#Parser-4443"><span class="linenos">4443</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> -</span><span id="Parser-4444"><a href="#Parser-4444"><span class="linenos">4444</span></a> <span class="k">return</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> -</span><span id="Parser-4445"><a href="#Parser-4445"><span class="linenos">4445</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Parser-4446"><a href="#Parser-4446"><span class="linenos">4446</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">Show</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="o">.</span><span class="n">upper</span><span class="p">())</span> -</span><span id="Parser-4447"><a href="#Parser-4447"><span class="linenos">4447</span></a> -</span><span id="Parser-4448"><a href="#Parser-4448"><span class="linenos">4448</span></a> <span class="k">def</span> <span class="nf">_parse_set_item_assignment</span><span class="p">(</span> -</span><span id="Parser-4449"><a href="#Parser-4449"><span class="linenos">4449</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">kind</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><span id="Parser-4450"><a href="#Parser-4450"><span class="linenos">4450</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="Parser-4451"><a href="#Parser-4451"><span class="linenos">4451</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="Parser-4452"><a href="#Parser-4452"><span class="linenos">4452</span></a> -</span><span id="Parser-4453"><a href="#Parser-4453"><span class="linenos">4453</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="ow">in</span> <span class="p">{</span><span class="s2">"GLOBAL"</span><span class="p">,</span> <span class="s2">"SESSION"</span><span class="p">}</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TRANSACTION"</span><span class="p">):</span> -</span><span id="Parser-4454"><a href="#Parser-4454"><span class="linenos">4454</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_transaction</span><span class="p">(</span><span class="n">global_</span><span class="o">=</span><span class="n">kind</span> <span class="o">==</span> <span class="s2">"GLOBAL"</span><span class="p">)</span> +</span><span id="Parser-4441"><a href="#Parser-4441"><span class="linenos">4441</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><span id="Parser-4442"><a href="#Parser-4442"><span class="linenos">4442</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Merge</span><span class="p">,</span> +</span><span id="Parser-4443"><a href="#Parser-4443"><span class="linenos">4443</span></a> <span class="n">this</span><span class="o">=</span><span class="n">target</span><span class="p">,</span> +</span><span id="Parser-4444"><a href="#Parser-4444"><span class="linenos">4444</span></a> <span class="n">using</span><span class="o">=</span><span class="n">using</span><span class="p">,</span> +</span><span id="Parser-4445"><a href="#Parser-4445"><span class="linenos">4445</span></a> <span class="n">on</span><span class="o">=</span><span class="n">on</span><span class="p">,</span> +</span><span id="Parser-4446"><a href="#Parser-4446"><span class="linenos">4446</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">whens</span><span class="p">,</span> +</span><span id="Parser-4447"><a href="#Parser-4447"><span class="linenos">4447</span></a> <span class="p">)</span> +</span><span id="Parser-4448"><a href="#Parser-4448"><span class="linenos">4448</span></a> +</span><span id="Parser-4449"><a href="#Parser-4449"><span class="linenos">4449</span></a> <span class="k">def</span> <span class="nf">_parse_show</span><span class="p">(</span><span class="bp">self</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="Parser-4450"><a href="#Parser-4450"><span class="linenos">4450</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_parser</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SHOW_PARSERS</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SHOW_TRIE</span><span class="p">)</span> +</span><span id="Parser-4451"><a href="#Parser-4451"><span class="linenos">4451</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> +</span><span id="Parser-4452"><a href="#Parser-4452"><span class="linenos">4452</span></a> <span class="k">return</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> +</span><span id="Parser-4453"><a href="#Parser-4453"><span class="linenos">4453</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Parser-4454"><a href="#Parser-4454"><span class="linenos">4454</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">Show</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="o">.</span><span class="n">upper</span><span class="p">())</span> </span><span id="Parser-4455"><a href="#Parser-4455"><span class="linenos">4455</span></a> -</span><span id="Parser-4456"><a href="#Parser-4456"><span class="linenos">4456</span></a> <span class="n">left</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="Parser-4457"><a href="#Parser-4457"><span class="linenos">4457</span></a> -</span><span id="Parser-4458"><a href="#Parser-4458"><span class="linenos">4458</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"="</span><span class="p">,</span> <span class="s2">"TO"</span><span class="p">)):</span> -</span><span id="Parser-4459"><a href="#Parser-4459"><span class="linenos">4459</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-4460"><a href="#Parser-4460"><span class="linenos">4460</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-4461"><a href="#Parser-4461"><span class="linenos">4461</span></a> -</span><span id="Parser-4462"><a href="#Parser-4462"><span class="linenos">4462</span></a> <span class="n">right</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="Parser-4463"><a href="#Parser-4463"><span class="linenos">4463</span></a> <span class="n">this</span> <span class="o">=</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">EQ</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">right</span><span class="p">)</span> -</span><span id="Parser-4464"><a href="#Parser-4464"><span class="linenos">4464</span></a> -</span><span id="Parser-4465"><a href="#Parser-4465"><span class="linenos">4465</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">SetItem</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">)</span> -</span><span id="Parser-4466"><a href="#Parser-4466"><span class="linenos">4466</span></a> -</span><span id="Parser-4467"><a href="#Parser-4467"><span class="linenos">4467</span></a> <span class="k">def</span> <span class="nf">_parse_set_transaction</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">global_</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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="Parser-4468"><a href="#Parser-4468"><span class="linenos">4468</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TRANSACTION"</span><span class="p">)</span> -</span><span id="Parser-4469"><a href="#Parser-4469"><span class="linenos">4469</span></a> <span class="n">characteristics</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> -</span><span id="Parser-4470"><a href="#Parser-4470"><span class="linenos">4470</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var_from_options</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">TRANSACTION_CHARACTERISTICS</span><span class="p">)</span> -</span><span id="Parser-4471"><a href="#Parser-4471"><span class="linenos">4471</span></a> <span class="p">)</span> -</span><span id="Parser-4472"><a href="#Parser-4472"><span class="linenos">4472</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><span id="Parser-4473"><a href="#Parser-4473"><span class="linenos">4473</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetItem</span><span class="p">,</span> -</span><span id="Parser-4474"><a href="#Parser-4474"><span class="linenos">4474</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">characteristics</span><span class="p">,</span> -</span><span id="Parser-4475"><a href="#Parser-4475"><span class="linenos">4475</span></a> <span class="n">kind</span><span class="o">=</span><span class="s2">"TRANSACTION"</span><span class="p">,</span> -</span><span id="Parser-4476"><a href="#Parser-4476"><span class="linenos">4476</span></a> <span class="o">**</span><span class="p">{</span><span class="s2">"global"</span><span class="p">:</span> <span class="n">global_</span><span class="p">},</span> <span class="c1"># type: ignore</span> -</span><span id="Parser-4477"><a href="#Parser-4477"><span class="linenos">4477</span></a> <span class="p">)</span> -</span><span id="Parser-4478"><a href="#Parser-4478"><span class="linenos">4478</span></a> -</span><span id="Parser-4479"><a href="#Parser-4479"><span class="linenos">4479</span></a> <span class="k">def</span> <span class="nf">_parse_set_item</span><span class="p">(</span><span class="bp">self</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="Parser-4480"><a href="#Parser-4480"><span class="linenos">4480</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_parser</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SET_PARSERS</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SET_TRIE</span><span class="p">)</span> -</span><span id="Parser-4481"><a href="#Parser-4481"><span class="linenos">4481</span></a> <span class="k">return</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="k">if</span> <span class="n">parser</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_item_assignment</span><span class="p">(</span><span class="n">kind</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> -</span><span id="Parser-4482"><a href="#Parser-4482"><span class="linenos">4482</span></a> -</span><span id="Parser-4483"><a href="#Parser-4483"><span class="linenos">4483</span></a> <span class="k">def</span> <span class="nf">_parse_set</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">Set</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> -</span><span id="Parser-4484"><a href="#Parser-4484"><span class="linenos">4484</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="Parser-4485"><a href="#Parser-4485"><span class="linenos">4485</span></a> <span class="n">set_</span> <span class="o">=</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">Set</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_item</span><span class="p">))</span> +</span><span id="Parser-4456"><a href="#Parser-4456"><span class="linenos">4456</span></a> <span class="k">def</span> <span class="nf">_parse_set_item_assignment</span><span class="p">(</span> +</span><span id="Parser-4457"><a href="#Parser-4457"><span class="linenos">4457</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">kind</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><span id="Parser-4458"><a href="#Parser-4458"><span class="linenos">4458</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="Parser-4459"><a href="#Parser-4459"><span class="linenos">4459</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="Parser-4460"><a href="#Parser-4460"><span class="linenos">4460</span></a> +</span><span id="Parser-4461"><a href="#Parser-4461"><span class="linenos">4461</span></a> <span class="k">if</span> <span class="n">kind</span> <span class="ow">in</span> <span class="p">{</span><span class="s2">"GLOBAL"</span><span class="p">,</span> <span class="s2">"SESSION"</span><span class="p">}</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TRANSACTION"</span><span class="p">):</span> +</span><span id="Parser-4462"><a href="#Parser-4462"><span class="linenos">4462</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_transaction</span><span class="p">(</span><span class="n">global_</span><span class="o">=</span><span class="n">kind</span> <span class="o">==</span> <span class="s2">"GLOBAL"</span><span class="p">)</span> +</span><span id="Parser-4463"><a href="#Parser-4463"><span class="linenos">4463</span></a> +</span><span id="Parser-4464"><a href="#Parser-4464"><span class="linenos">4464</span></a> <span class="n">left</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="Parser-4465"><a href="#Parser-4465"><span class="linenos">4465</span></a> +</span><span id="Parser-4466"><a href="#Parser-4466"><span class="linenos">4466</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_texts</span><span class="p">((</span><span class="s2">"="</span><span class="p">,</span> <span class="s2">"TO"</span><span class="p">)):</span> +</span><span id="Parser-4467"><a href="#Parser-4467"><span class="linenos">4467</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-4468"><a href="#Parser-4468"><span class="linenos">4468</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-4469"><a href="#Parser-4469"><span class="linenos">4469</span></a> +</span><span id="Parser-4470"><a href="#Parser-4470"><span class="linenos">4470</span></a> <span class="n">right</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="Parser-4471"><a href="#Parser-4471"><span class="linenos">4471</span></a> <span class="n">this</span> <span class="o">=</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">EQ</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">left</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">right</span><span class="p">)</span> +</span><span id="Parser-4472"><a href="#Parser-4472"><span class="linenos">4472</span></a> +</span><span id="Parser-4473"><a href="#Parser-4473"><span class="linenos">4473</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">SetItem</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="p">)</span> +</span><span id="Parser-4474"><a href="#Parser-4474"><span class="linenos">4474</span></a> +</span><span id="Parser-4475"><a href="#Parser-4475"><span class="linenos">4475</span></a> <span class="k">def</span> <span class="nf">_parse_set_transaction</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">global_</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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="Parser-4476"><a href="#Parser-4476"><span class="linenos">4476</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"TRANSACTION"</span><span class="p">)</span> +</span><span id="Parser-4477"><a href="#Parser-4477"><span class="linenos">4477</span></a> <span class="n">characteristics</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span> +</span><span id="Parser-4478"><a href="#Parser-4478"><span class="linenos">4478</span></a> <span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var_from_options</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">TRANSACTION_CHARACTERISTICS</span><span class="p">)</span> +</span><span id="Parser-4479"><a href="#Parser-4479"><span class="linenos">4479</span></a> <span class="p">)</span> +</span><span id="Parser-4480"><a href="#Parser-4480"><span class="linenos">4480</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><span id="Parser-4481"><a href="#Parser-4481"><span class="linenos">4481</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">SetItem</span><span class="p">,</span> +</span><span id="Parser-4482"><a href="#Parser-4482"><span class="linenos">4482</span></a> <span class="n">expressions</span><span class="o">=</span><span class="n">characteristics</span><span class="p">,</span> +</span><span id="Parser-4483"><a href="#Parser-4483"><span class="linenos">4483</span></a> <span class="n">kind</span><span class="o">=</span><span class="s2">"TRANSACTION"</span><span class="p">,</span> +</span><span id="Parser-4484"><a href="#Parser-4484"><span class="linenos">4484</span></a> <span class="o">**</span><span class="p">{</span><span class="s2">"global"</span><span class="p">:</span> <span class="n">global_</span><span class="p">},</span> <span class="c1"># type: ignore</span> +</span><span id="Parser-4485"><a href="#Parser-4485"><span class="linenos">4485</span></a> <span class="p">)</span> </span><span id="Parser-4486"><a href="#Parser-4486"><span class="linenos">4486</span></a> -</span><span id="Parser-4487"><a href="#Parser-4487"><span class="linenos">4487</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="Parser-4488"><a href="#Parser-4488"><span class="linenos">4488</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-4489"><a href="#Parser-4489"><span class="linenos">4489</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="Parser-4487"><a href="#Parser-4487"><span class="linenos">4487</span></a> <span class="k">def</span> <span class="nf">_parse_set_item</span><span class="p">(</span><span class="bp">self</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="Parser-4488"><a href="#Parser-4488"><span class="linenos">4488</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_parser</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SET_PARSERS</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">SET_TRIE</span><span class="p">)</span> +</span><span id="Parser-4489"><a href="#Parser-4489"><span class="linenos">4489</span></a> <span class="k">return</span> <span class="n">parser</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="k">if</span> <span class="n">parser</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_item_assignment</span><span class="p">(</span><span class="n">kind</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> </span><span id="Parser-4490"><a href="#Parser-4490"><span class="linenos">4490</span></a> -</span><span id="Parser-4491"><a href="#Parser-4491"><span class="linenos">4491</span></a> <span class="k">return</span> <span class="n">set_</span> -</span><span id="Parser-4492"><a href="#Parser-4492"><span class="linenos">4492</span></a> -</span><span id="Parser-4493"><a href="#Parser-4493"><span class="linenos">4493</span></a> <span class="k">def</span> <span class="nf">_parse_var_from_options</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">options</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="nb">str</span><span class="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">Var</span><span class="p">]:</span> -</span><span id="Parser-4494"><a href="#Parser-4494"><span class="linenos">4494</span></a> <span class="k">for</span> <span class="n">option</span> <span class="ow">in</span> <span class="n">options</span><span class="p">:</span> -</span><span id="Parser-4495"><a href="#Parser-4495"><span class="linenos">4495</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="o">*</span><span class="n">option</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">)):</span> -</span><span id="Parser-4496"><a href="#Parser-4496"><span class="linenos">4496</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">option</span><span class="p">)</span> -</span><span id="Parser-4497"><a href="#Parser-4497"><span class="linenos">4497</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-4491"><a href="#Parser-4491"><span class="linenos">4491</span></a> <span class="k">def</span> <span class="nf">_parse_set</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">Set</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> +</span><span id="Parser-4492"><a href="#Parser-4492"><span class="linenos">4492</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="Parser-4493"><a href="#Parser-4493"><span class="linenos">4493</span></a> <span class="n">set_</span> <span class="o">=</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">Set</span><span class="p">,</span> <span class="n">expressions</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_set_item</span><span class="p">))</span> +</span><span id="Parser-4494"><a href="#Parser-4494"><span class="linenos">4494</span></a> +</span><span id="Parser-4495"><a href="#Parser-4495"><span class="linenos">4495</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="Parser-4496"><a href="#Parser-4496"><span class="linenos">4496</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-4497"><a href="#Parser-4497"><span class="linenos">4497</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_as_command</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> </span><span id="Parser-4498"><a href="#Parser-4498"><span class="linenos">4498</span></a> -</span><span id="Parser-4499"><a href="#Parser-4499"><span class="linenos">4499</span></a> <span class="k">def</span> <span class="nf">_parse_as_command</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">start</span><span class="p">:</span> <span class="n">Token</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> -</span><span id="Parser-4500"><a href="#Parser-4500"><span class="linenos">4500</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="Parser-4501"><a href="#Parser-4501"><span class="linenos">4501</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Parser-4502"><a href="#Parser-4502"><span class="linenos">4502</span></a> <span class="n">text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_sql</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> -</span><span id="Parser-4503"><a href="#Parser-4503"><span class="linenos">4503</span></a> <span class="n">size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">start</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> -</span><span id="Parser-4504"><a href="#Parser-4504"><span class="linenos">4504</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">text</span><span class="p">[:</span><span class="n">size</span><span class="p">],</span> <span class="n">expression</span><span class="o">=</span><span class="n">text</span><span class="p">[</span><span class="n">size</span><span class="p">:])</span> -</span><span id="Parser-4505"><a href="#Parser-4505"><span class="linenos">4505</span></a> -</span><span id="Parser-4506"><a href="#Parser-4506"><span class="linenos">4506</span></a> <span class="k">def</span> <span class="nf">_parse_dict_property</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">:</span> -</span><span id="Parser-4507"><a href="#Parser-4507"><span class="linenos">4507</span></a> <span class="n">settings</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-4508"><a href="#Parser-4508"><span class="linenos">4508</span></a> -</span><span id="Parser-4509"><a href="#Parser-4509"><span class="linenos">4509</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> -</span><span id="Parser-4510"><a href="#Parser-4510"><span class="linenos">4510</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="Parser-4511"><a href="#Parser-4511"><span class="linenos">4511</span></a> -</span><span id="Parser-4512"><a href="#Parser-4512"><span class="linenos">4512</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_PAREN</span><span class="p">):</span> -</span><span id="Parser-4513"><a href="#Parser-4513"><span class="linenos">4513</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Parser-4514"><a href="#Parser-4514"><span class="linenos">4514</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> -</span><span id="Parser-4515"><a href="#Parser-4515"><span class="linenos">4515</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="Parser-4499"><a href="#Parser-4499"><span class="linenos">4499</span></a> <span class="k">return</span> <span class="n">set_</span> +</span><span id="Parser-4500"><a href="#Parser-4500"><span class="linenos">4500</span></a> +</span><span id="Parser-4501"><a href="#Parser-4501"><span class="linenos">4501</span></a> <span class="k">def</span> <span class="nf">_parse_var_from_options</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">options</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Collection</span><span class="p">[</span><span class="nb">str</span><span class="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">Var</span><span class="p">]:</span> +</span><span id="Parser-4502"><a href="#Parser-4502"><span class="linenos">4502</span></a> <span class="k">for</span> <span class="n">option</span> <span class="ow">in</span> <span class="n">options</span><span class="p">:</span> +</span><span id="Parser-4503"><a href="#Parser-4503"><span class="linenos">4503</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="o">*</span><span class="n">option</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">)):</span> +</span><span id="Parser-4504"><a href="#Parser-4504"><span class="linenos">4504</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">option</span><span class="p">)</span> +</span><span id="Parser-4505"><a href="#Parser-4505"><span class="linenos">4505</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-4506"><a href="#Parser-4506"><span class="linenos">4506</span></a> +</span><span id="Parser-4507"><a href="#Parser-4507"><span class="linenos">4507</span></a> <span class="k">def</span> <span class="nf">_parse_as_command</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">start</span><span class="p">:</span> <span class="n">Token</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">:</span> +</span><span id="Parser-4508"><a href="#Parser-4508"><span class="linenos">4508</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="Parser-4509"><a href="#Parser-4509"><span class="linenos">4509</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Parser-4510"><a href="#Parser-4510"><span class="linenos">4510</span></a> <span class="n">text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_sql</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span><span class="p">)</span> +</span><span id="Parser-4511"><a href="#Parser-4511"><span class="linenos">4511</span></a> <span class="n">size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">start</span><span class="o">.</span><span class="n">text</span><span class="p">)</span> +</span><span id="Parser-4512"><a href="#Parser-4512"><span class="linenos">4512</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">Command</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">text</span><span class="p">[:</span><span class="n">size</span><span class="p">],</span> <span class="n">expression</span><span class="o">=</span><span class="n">text</span><span class="p">[</span><span class="n">size</span><span class="p">:])</span> +</span><span id="Parser-4513"><a href="#Parser-4513"><span class="linenos">4513</span></a> +</span><span id="Parser-4514"><a href="#Parser-4514"><span class="linenos">4514</span></a> <span class="k">def</span> <span class="nf">_parse_dict_property</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">:</span> +</span><span id="Parser-4515"><a href="#Parser-4515"><span class="linenos">4515</span></a> <span class="n">settings</span> <span class="o">=</span> <span class="p">[]</span> </span><span id="Parser-4516"><a href="#Parser-4516"><span class="linenos">4516</span></a> -</span><span id="Parser-4517"><a href="#Parser-4517"><span class="linenos">4517</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">key</span> <span class="ow">and</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Parser-4518"><a href="#Parser-4518"><span class="linenos">4518</span></a> <span class="k">break</span> -</span><span id="Parser-4519"><a href="#Parser-4519"><span class="linenos">4519</span></a> <span class="n">settings</span><span class="o">.</span><span class="n">append</span><span class="p">(</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">DictSubProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="n">value</span><span class="p">))</span> -</span><span id="Parser-4520"><a href="#Parser-4520"><span class="linenos">4520</span></a> <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">R_PAREN</span><span class="p">)</span> -</span><span id="Parser-4521"><a href="#Parser-4521"><span class="linenos">4521</span></a> -</span><span id="Parser-4522"><a href="#Parser-4522"><span class="linenos">4522</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="Parser-4523"><a href="#Parser-4523"><span class="linenos">4523</span></a> -</span><span id="Parser-4524"><a href="#Parser-4524"><span class="linenos">4524</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><span id="Parser-4525"><a href="#Parser-4525"><span class="linenos">4525</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">,</span> -</span><span id="Parser-4526"><a href="#Parser-4526"><span class="linenos">4526</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> -</span><span id="Parser-4527"><a href="#Parser-4527"><span class="linenos">4527</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Parser-4528"><a href="#Parser-4528"><span class="linenos">4528</span></a> <span class="n">settings</span><span class="o">=</span><span class="n">settings</span><span class="p">,</span> -</span><span id="Parser-4529"><a href="#Parser-4529"><span class="linenos">4529</span></a> <span class="p">)</span> -</span><span id="Parser-4530"><a href="#Parser-4530"><span class="linenos">4530</span></a> -</span><span id="Parser-4531"><a href="#Parser-4531"><span class="linenos">4531</span></a> <span class="k">def</span> <span class="nf">_parse_dict_range</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DictRange</span><span class="p">:</span> -</span><span id="Parser-4532"><a href="#Parser-4532"><span class="linenos">4532</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> -</span><span id="Parser-4533"><a href="#Parser-4533"><span class="linenos">4533</span></a> <span class="n">has_min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MIN"</span><span class="p">)</span> -</span><span id="Parser-4534"><a href="#Parser-4534"><span class="linenos">4534</span></a> <span class="k">if</span> <span class="n">has_min</span><span class="p">:</span> -</span><span id="Parser-4535"><a href="#Parser-4535"><span class="linenos">4535</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> -</span><span id="Parser-4536"><a href="#Parser-4536"><span class="linenos">4536</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">)</span> -</span><span id="Parser-4537"><a href="#Parser-4537"><span class="linenos">4537</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> -</span><span id="Parser-4538"><a href="#Parser-4538"><span class="linenos">4538</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-4539"><a href="#Parser-4539"><span class="linenos">4539</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> -</span><span id="Parser-4540"><a href="#Parser-4540"><span class="linenos">4540</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> -</span><span id="Parser-4541"><a href="#Parser-4541"><span class="linenos">4541</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> -</span><span id="Parser-4542"><a href="#Parser-4542"><span class="linenos">4542</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">DictRange</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="nb">min</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="nb">max</span><span class="p">)</span> -</span><span id="Parser-4543"><a href="#Parser-4543"><span class="linenos">4543</span></a> -</span><span id="Parser-4544"><a href="#Parser-4544"><span class="linenos">4544</span></a> <span class="k">def</span> <span class="nf">_find_parser</span><span class="p">(</span> -</span><span id="Parser-4545"><a href="#Parser-4545"><span class="linenos">4545</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">parsers</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">],</span> <span class="n">trie</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> -</span><span id="Parser-4546"><a href="#Parser-4546"><span class="linenos">4546</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">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]:</span> -</span><span id="Parser-4547"><a href="#Parser-4547"><span class="linenos">4547</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="Parser-4548"><a href="#Parser-4548"><span class="linenos">4548</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-4549"><a href="#Parser-4549"><span class="linenos">4549</span></a> -</span><span id="Parser-4550"><a href="#Parser-4550"><span class="linenos">4550</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="Parser-4551"><a href="#Parser-4551"><span class="linenos">4551</span></a> <span class="n">this</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser-4552"><a href="#Parser-4552"><span class="linenos">4552</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Parser-4553"><a href="#Parser-4553"><span class="linenos">4553</span></a> <span class="c1"># The current token might be multiple words</span> -</span><span id="Parser-4554"><a href="#Parser-4554"><span class="linenos">4554</span></a> <span class="n">curr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Parser-4555"><a href="#Parser-4555"><span class="linenos">4555</span></a> <span class="n">key</span> <span class="o">=</span> <span class="n">curr</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Parser-4556"><a href="#Parser-4556"><span class="linenos">4556</span></a> <span class="n">this</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">curr</span><span class="p">)</span> -</span><span id="Parser-4557"><a href="#Parser-4557"><span class="linenos">4557</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Parser-4558"><a href="#Parser-4558"><span class="linenos">4558</span></a> <span class="n">result</span><span class="p">,</span> <span class="n">trie</span> <span class="o">=</span> <span class="n">in_trie</span><span class="p">(</span><span class="n">trie</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> -</span><span id="Parser-4559"><a href="#Parser-4559"><span class="linenos">4559</span></a> <span class="k">if</span> <span class="n">result</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> -</span><span id="Parser-4560"><a href="#Parser-4560"><span class="linenos">4560</span></a> <span class="k">break</span> -</span><span id="Parser-4561"><a href="#Parser-4561"><span class="linenos">4561</span></a> <span class="k">if</span> <span class="n">result</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> -</span><span id="Parser-4562"><a href="#Parser-4562"><span class="linenos">4562</span></a> <span class="n">subparser</span> <span class="o">=</span> <span class="n">parsers</span><span class="p">[</span><span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">this</span><span class="p">)]</span> -</span><span id="Parser-4563"><a href="#Parser-4563"><span class="linenos">4563</span></a> <span class="k">return</span> <span class="n">subparser</span> -</span><span id="Parser-4564"><a href="#Parser-4564"><span class="linenos">4564</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-4565"><a href="#Parser-4565"><span class="linenos">4565</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-4566"><a href="#Parser-4566"><span class="linenos">4566</span></a> -</span><span id="Parser-4567"><a href="#Parser-4567"><span class="linenos">4567</span></a> <span class="k">def</span> <span class="nf">_match</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> -</span><span id="Parser-4568"><a href="#Parser-4568"><span class="linenos">4568</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="Parser-4569"><a href="#Parser-4569"><span class="linenos">4569</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-4570"><a href="#Parser-4570"><span class="linenos">4570</span></a> -</span><span id="Parser-4571"><a href="#Parser-4571"><span class="linenos">4571</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">token_type</span><span class="p">:</span> -</span><span id="Parser-4572"><a href="#Parser-4572"><span class="linenos">4572</span></a> <span class="k">if</span> <span class="n">advance</span><span class="p">:</span> -</span><span id="Parser-4573"><a href="#Parser-4573"><span class="linenos">4573</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Parser-4574"><a href="#Parser-4574"><span class="linenos">4574</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add_comments</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Parser-4575"><a href="#Parser-4575"><span class="linenos">4575</span></a> <span class="k">return</span> <span class="kc">True</span> -</span><span id="Parser-4576"><a href="#Parser-4576"><span class="linenos">4576</span></a> -</span><span id="Parser-4577"><a href="#Parser-4577"><span class="linenos">4577</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-4517"><a href="#Parser-4517"><span class="linenos">4517</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> +</span><span id="Parser-4518"><a href="#Parser-4518"><span class="linenos">4518</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="Parser-4519"><a href="#Parser-4519"><span class="linenos">4519</span></a> +</span><span id="Parser-4520"><a href="#Parser-4520"><span class="linenos">4520</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_PAREN</span><span class="p">):</span> +</span><span id="Parser-4521"><a href="#Parser-4521"><span class="linenos">4521</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Parser-4522"><a href="#Parser-4522"><span class="linenos">4522</span></a> <span class="n">key</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_id_var</span><span class="p">()</span> +</span><span id="Parser-4523"><a href="#Parser-4523"><span class="linenos">4523</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="Parser-4524"><a href="#Parser-4524"><span class="linenos">4524</span></a> +</span><span id="Parser-4525"><a href="#Parser-4525"><span class="linenos">4525</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">key</span> <span class="ow">and</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Parser-4526"><a href="#Parser-4526"><span class="linenos">4526</span></a> <span class="k">break</span> +</span><span id="Parser-4527"><a href="#Parser-4527"><span class="linenos">4527</span></a> <span class="n">settings</span><span class="o">.</span><span class="n">append</span><span class="p">(</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">DictSubProperty</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="n">value</span><span class="p">))</span> +</span><span id="Parser-4528"><a href="#Parser-4528"><span class="linenos">4528</span></a> <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">R_PAREN</span><span class="p">)</span> +</span><span id="Parser-4529"><a href="#Parser-4529"><span class="linenos">4529</span></a> +</span><span id="Parser-4530"><a href="#Parser-4530"><span class="linenos">4530</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-4531"><a href="#Parser-4531"><span class="linenos">4531</span></a> +</span><span id="Parser-4532"><a href="#Parser-4532"><span class="linenos">4532</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><span id="Parser-4533"><a href="#Parser-4533"><span class="linenos">4533</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">DictProperty</span><span class="p">,</span> +</span><span id="Parser-4534"><a href="#Parser-4534"><span class="linenos">4534</span></a> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> +</span><span id="Parser-4535"><a href="#Parser-4535"><span class="linenos">4535</span></a> <span class="n">kind</span><span class="o">=</span><span class="n">kind</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Parser-4536"><a href="#Parser-4536"><span class="linenos">4536</span></a> <span class="n">settings</span><span class="o">=</span><span class="n">settings</span><span class="p">,</span> +</span><span id="Parser-4537"><a href="#Parser-4537"><span class="linenos">4537</span></a> <span class="p">)</span> +</span><span id="Parser-4538"><a href="#Parser-4538"><span class="linenos">4538</span></a> +</span><span id="Parser-4539"><a href="#Parser-4539"><span class="linenos">4539</span></a> <span class="k">def</span> <span class="nf">_parse_dict_range</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DictRange</span><span class="p">:</span> +</span><span id="Parser-4540"><a href="#Parser-4540"><span class="linenos">4540</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_l_paren</span><span class="p">()</span> +</span><span id="Parser-4541"><a href="#Parser-4541"><span class="linenos">4541</span></a> <span class="n">has_min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MIN"</span><span class="p">)</span> +</span><span id="Parser-4542"><a href="#Parser-4542"><span class="linenos">4542</span></a> <span class="k">if</span> <span class="n">has_min</span><span class="p">:</span> +</span><span id="Parser-4543"><a href="#Parser-4543"><span class="linenos">4543</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="Parser-4544"><a href="#Parser-4544"><span class="linenos">4544</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_text_seq</span><span class="p">(</span><span class="s2">"MAX"</span><span class="p">)</span> +</span><span id="Parser-4545"><a href="#Parser-4545"><span class="linenos">4545</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="Parser-4546"><a href="#Parser-4546"><span class="linenos">4546</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-4547"><a href="#Parser-4547"><span class="linenos">4547</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_var</span><span class="p">()</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_primary</span><span class="p">()</span> +</span><span id="Parser-4548"><a href="#Parser-4548"><span class="linenos">4548</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> +</span><span id="Parser-4549"><a href="#Parser-4549"><span class="linenos">4549</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_match_r_paren</span><span class="p">()</span> +</span><span id="Parser-4550"><a href="#Parser-4550"><span class="linenos">4550</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">DictRange</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="nb">min</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="nb">max</span><span class="p">)</span> +</span><span id="Parser-4551"><a href="#Parser-4551"><span class="linenos">4551</span></a> +</span><span id="Parser-4552"><a href="#Parser-4552"><span class="linenos">4552</span></a> <span class="k">def</span> <span class="nf">_find_parser</span><span class="p">(</span> +</span><span id="Parser-4553"><a href="#Parser-4553"><span class="linenos">4553</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">parsers</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">],</span> <span class="n">trie</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> +</span><span id="Parser-4554"><a href="#Parser-4554"><span class="linenos">4554</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">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]:</span> +</span><span id="Parser-4555"><a href="#Parser-4555"><span class="linenos">4555</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="Parser-4556"><a href="#Parser-4556"><span class="linenos">4556</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-4557"><a href="#Parser-4557"><span class="linenos">4557</span></a> +</span><span id="Parser-4558"><a href="#Parser-4558"><span class="linenos">4558</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="Parser-4559"><a href="#Parser-4559"><span class="linenos">4559</span></a> <span class="n">this</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser-4560"><a href="#Parser-4560"><span class="linenos">4560</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Parser-4561"><a href="#Parser-4561"><span class="linenos">4561</span></a> <span class="c1"># The current token might be multiple words</span> +</span><span id="Parser-4562"><a href="#Parser-4562"><span class="linenos">4562</span></a> <span class="n">curr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Parser-4563"><a href="#Parser-4563"><span class="linenos">4563</span></a> <span class="n">key</span> <span class="o">=</span> <span class="n">curr</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Parser-4564"><a href="#Parser-4564"><span class="linenos">4564</span></a> <span class="n">this</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">curr</span><span class="p">)</span> +</span><span id="Parser-4565"><a href="#Parser-4565"><span class="linenos">4565</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Parser-4566"><a href="#Parser-4566"><span class="linenos">4566</span></a> <span class="n">result</span><span class="p">,</span> <span class="n">trie</span> <span class="o">=</span> <span class="n">in_trie</span><span class="p">(</span><span class="n">trie</span><span class="p">,</span> <span class="n">key</span><span class="p">)</span> +</span><span id="Parser-4567"><a href="#Parser-4567"><span class="linenos">4567</span></a> <span class="k">if</span> <span class="n">result</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> +</span><span id="Parser-4568"><a href="#Parser-4568"><span class="linenos">4568</span></a> <span class="k">break</span> +</span><span id="Parser-4569"><a href="#Parser-4569"><span class="linenos">4569</span></a> <span class="k">if</span> <span class="n">result</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> +</span><span id="Parser-4570"><a href="#Parser-4570"><span class="linenos">4570</span></a> <span class="n">subparser</span> <span class="o">=</span> <span class="n">parsers</span><span class="p">[</span><span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">this</span><span class="p">)]</span> +</span><span id="Parser-4571"><a href="#Parser-4571"><span class="linenos">4571</span></a> <span class="k">return</span> <span class="n">subparser</span> +</span><span id="Parser-4572"><a href="#Parser-4572"><span class="linenos">4572</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-4573"><a href="#Parser-4573"><span class="linenos">4573</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-4574"><a href="#Parser-4574"><span class="linenos">4574</span></a> +</span><span id="Parser-4575"><a href="#Parser-4575"><span class="linenos">4575</span></a> <span class="k">def</span> <span class="nf">_match</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> +</span><span id="Parser-4576"><a href="#Parser-4576"><span class="linenos">4576</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="Parser-4577"><a href="#Parser-4577"><span class="linenos">4577</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="Parser-4578"><a href="#Parser-4578"><span class="linenos">4578</span></a> -</span><span id="Parser-4579"><a href="#Parser-4579"><span class="linenos">4579</span></a> <span class="k">def</span> <span class="nf">_match_set</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">types</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> -</span><span id="Parser-4580"><a href="#Parser-4580"><span class="linenos">4580</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> -</span><span id="Parser-4581"><a href="#Parser-4581"><span class="linenos">4581</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-4582"><a href="#Parser-4582"><span class="linenos">4582</span></a> -</span><span id="Parser-4583"><a href="#Parser-4583"><span class="linenos">4583</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="n">types</span><span class="p">:</span> -</span><span id="Parser-4584"><a href="#Parser-4584"><span class="linenos">4584</span></a> <span class="k">if</span> <span class="n">advance</span><span class="p">:</span> -</span><span id="Parser-4585"><a href="#Parser-4585"><span class="linenos">4585</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Parser-4586"><a href="#Parser-4586"><span class="linenos">4586</span></a> <span class="k">return</span> <span class="kc">True</span> -</span><span id="Parser-4587"><a href="#Parser-4587"><span class="linenos">4587</span></a> -</span><span id="Parser-4588"><a href="#Parser-4588"><span class="linenos">4588</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-4589"><a href="#Parser-4589"><span class="linenos">4589</span></a> -</span><span id="Parser-4590"><a href="#Parser-4590"><span class="linenos">4590</span></a> <span class="k">def</span> <span class="nf">_match_pair</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type_a</span><span class="p">,</span> <span class="n">token_type_b</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> -</span><span id="Parser-4591"><a href="#Parser-4591"><span class="linenos">4591</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> -</span><span id="Parser-4592"><a href="#Parser-4592"><span class="linenos">4592</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-4593"><a href="#Parser-4593"><span class="linenos">4593</span></a> -</span><span id="Parser-4594"><a href="#Parser-4594"><span class="linenos">4594</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">token_type_a</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">token_type_b</span><span class="p">:</span> -</span><span id="Parser-4595"><a href="#Parser-4595"><span class="linenos">4595</span></a> <span class="k">if</span> <span class="n">advance</span><span class="p">:</span> -</span><span id="Parser-4596"><a href="#Parser-4596"><span class="linenos">4596</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> -</span><span id="Parser-4597"><a href="#Parser-4597"><span class="linenos">4597</span></a> <span class="k">return</span> <span class="kc">True</span> -</span><span id="Parser-4598"><a href="#Parser-4598"><span class="linenos">4598</span></a> -</span><span id="Parser-4599"><a href="#Parser-4599"><span class="linenos">4599</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="Parser-4600"><a href="#Parser-4600"><span class="linenos">4600</span></a> -</span><span id="Parser-4601"><a href="#Parser-4601"><span class="linenos">4601</span></a> <span class="k">def</span> <span class="nf">_match_l_paren</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Parser-4602"><a href="#Parser-4602"><span class="linenos">4602</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">):</span> -</span><span id="Parser-4603"><a href="#Parser-4603"><span class="linenos">4603</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting ("</span><span class="p">)</span> -</span><span id="Parser-4604"><a href="#Parser-4604"><span class="linenos">4604</span></a> -</span><span id="Parser-4605"><a href="#Parser-4605"><span class="linenos">4605</span></a> <span class="k">def</span> <span class="nf">_match_r_paren</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Parser-4606"><a href="#Parser-4606"><span class="linenos">4606</span></a> <span class="k">if</span> <span class="ow">not</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">R_PAREN</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">):</span> -</span><span id="Parser-4607"><a href="#Parser-4607"><span class="linenos">4607</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting )"</span><span class="p">)</span> +</span><span id="Parser-4579"><a href="#Parser-4579"><span class="linenos">4579</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">token_type</span><span class="p">:</span> +</span><span id="Parser-4580"><a href="#Parser-4580"><span class="linenos">4580</span></a> <span class="k">if</span> <span class="n">advance</span><span class="p">:</span> +</span><span id="Parser-4581"><a href="#Parser-4581"><span class="linenos">4581</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Parser-4582"><a href="#Parser-4582"><span class="linenos">4582</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add_comments</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Parser-4583"><a href="#Parser-4583"><span class="linenos">4583</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Parser-4584"><a href="#Parser-4584"><span class="linenos">4584</span></a> +</span><span id="Parser-4585"><a href="#Parser-4585"><span class="linenos">4585</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-4586"><a href="#Parser-4586"><span class="linenos">4586</span></a> +</span><span id="Parser-4587"><a href="#Parser-4587"><span class="linenos">4587</span></a> <span class="k">def</span> <span class="nf">_match_set</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">types</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> +</span><span id="Parser-4588"><a href="#Parser-4588"><span class="linenos">4588</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="p">:</span> +</span><span id="Parser-4589"><a href="#Parser-4589"><span class="linenos">4589</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-4590"><a href="#Parser-4590"><span class="linenos">4590</span></a> +</span><span id="Parser-4591"><a href="#Parser-4591"><span class="linenos">4591</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="n">types</span><span class="p">:</span> +</span><span id="Parser-4592"><a href="#Parser-4592"><span class="linenos">4592</span></a> <span class="k">if</span> <span class="n">advance</span><span class="p">:</span> +</span><span id="Parser-4593"><a href="#Parser-4593"><span class="linenos">4593</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Parser-4594"><a href="#Parser-4594"><span class="linenos">4594</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Parser-4595"><a href="#Parser-4595"><span class="linenos">4595</span></a> +</span><span id="Parser-4596"><a href="#Parser-4596"><span class="linenos">4596</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-4597"><a href="#Parser-4597"><span class="linenos">4597</span></a> +</span><span id="Parser-4598"><a href="#Parser-4598"><span class="linenos">4598</span></a> <span class="k">def</span> <span class="nf">_match_pair</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type_a</span><span class="p">,</span> <span class="n">token_type_b</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> +</span><span id="Parser-4599"><a href="#Parser-4599"><span class="linenos">4599</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="p">:</span> +</span><span id="Parser-4600"><a href="#Parser-4600"><span class="linenos">4600</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="Parser-4601"><a href="#Parser-4601"><span class="linenos">4601</span></a> +</span><span id="Parser-4602"><a href="#Parser-4602"><span class="linenos">4602</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">token_type_a</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">token_type_b</span><span class="p">:</span> +</span><span id="Parser-4603"><a href="#Parser-4603"><span class="linenos">4603</span></a> <span class="k">if</span> <span class="n">advance</span><span class="p">:</span> +</span><span id="Parser-4604"><a href="#Parser-4604"><span class="linenos">4604</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> +</span><span id="Parser-4605"><a href="#Parser-4605"><span class="linenos">4605</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Parser-4606"><a href="#Parser-4606"><span class="linenos">4606</span></a> +</span><span id="Parser-4607"><a href="#Parser-4607"><span class="linenos">4607</span></a> <span class="k">return</span> <span class="kc">None</span> </span><span id="Parser-4608"><a href="#Parser-4608"><span class="linenos">4608</span></a> -</span><span id="Parser-4609"><a href="#Parser-4609"><span class="linenos">4609</span></a> <span class="k">def</span> <span class="nf">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">texts</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> -</span><span id="Parser-4610"><a href="#Parser-4610"><span class="linenos">4610</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="ow">in</span> <span class="n">texts</span><span class="p">:</span> -</span><span id="Parser-4611"><a href="#Parser-4611"><span class="linenos">4611</span></a> <span class="k">if</span> <span class="n">advance</span><span class="p">:</span> -</span><span id="Parser-4612"><a href="#Parser-4612"><span class="linenos">4612</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Parser-4613"><a href="#Parser-4613"><span class="linenos">4613</span></a> <span class="k">return</span> <span class="kc">True</span> -</span><span id="Parser-4614"><a href="#Parser-4614"><span class="linenos">4614</span></a> <span class="k">return</span> <span class="kc">False</span> -</span><span id="Parser-4615"><a href="#Parser-4615"><span class="linenos">4615</span></a> -</span><span id="Parser-4616"><a href="#Parser-4616"><span class="linenos">4616</span></a> <span class="k">def</span> <span class="nf">_match_text_seq</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">texts</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> -</span><span id="Parser-4617"><a href="#Parser-4617"><span class="linenos">4617</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> -</span><span id="Parser-4618"><a href="#Parser-4618"><span class="linenos">4618</span></a> <span class="k">for</span> <span class="n">text</span> <span class="ow">in</span> <span class="n">texts</span><span class="p">:</span> -</span><span id="Parser-4619"><a href="#Parser-4619"><span class="linenos">4619</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="n">text</span><span class="p">:</span> +</span><span id="Parser-4609"><a href="#Parser-4609"><span class="linenos">4609</span></a> <span class="k">def</span> <span class="nf">_match_l_paren</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Parser-4610"><a href="#Parser-4610"><span class="linenos">4610</span></a> <span class="k">if</span> <span class="ow">not</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_PAREN</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">):</span> +</span><span id="Parser-4611"><a href="#Parser-4611"><span class="linenos">4611</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting ("</span><span class="p">)</span> +</span><span id="Parser-4612"><a href="#Parser-4612"><span class="linenos">4612</span></a> +</span><span id="Parser-4613"><a href="#Parser-4613"><span class="linenos">4613</span></a> <span class="k">def</span> <span class="nf">_match_r_paren</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Parser-4614"><a href="#Parser-4614"><span class="linenos">4614</span></a> <span class="k">if</span> <span class="ow">not</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">R_PAREN</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="p">):</span> +</span><span id="Parser-4615"><a href="#Parser-4615"><span class="linenos">4615</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="s2">"Expecting )"</span><span class="p">)</span> +</span><span id="Parser-4616"><a href="#Parser-4616"><span class="linenos">4616</span></a> +</span><span id="Parser-4617"><a href="#Parser-4617"><span class="linenos">4617</span></a> <span class="k">def</span> <span class="nf">_match_texts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">texts</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> +</span><span id="Parser-4618"><a href="#Parser-4618"><span class="linenos">4618</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="ow">in</span> <span class="n">texts</span><span class="p">:</span> +</span><span id="Parser-4619"><a href="#Parser-4619"><span class="linenos">4619</span></a> <span class="k">if</span> <span class="n">advance</span><span class="p">:</span> </span><span id="Parser-4620"><a href="#Parser-4620"><span class="linenos">4620</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Parser-4621"><a href="#Parser-4621"><span class="linenos">4621</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-4622"><a href="#Parser-4622"><span class="linenos">4622</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-4623"><a href="#Parser-4623"><span class="linenos">4623</span></a> <span class="k">return</span> <span class="kc">False</span> -</span><span id="Parser-4624"><a href="#Parser-4624"><span class="linenos">4624</span></a> -</span><span id="Parser-4625"><a href="#Parser-4625"><span class="linenos">4625</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">advance</span><span class="p">:</span> -</span><span id="Parser-4626"><a href="#Parser-4626"><span class="linenos">4626</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> -</span><span id="Parser-4627"><a href="#Parser-4627"><span class="linenos">4627</span></a> -</span><span id="Parser-4628"><a href="#Parser-4628"><span class="linenos">4628</span></a> <span class="k">return</span> <span class="kc">True</span> -</span><span id="Parser-4629"><a href="#Parser-4629"><span class="linenos">4629</span></a> -</span><span id="Parser-4630"><a href="#Parser-4630"><span class="linenos">4630</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="Parser-4631"><a href="#Parser-4631"><span class="linenos">4631</span></a> <span class="k">def</span> <span class="nf">_replace_columns_with_dots</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> -</span><span id="Parser-4632"><a href="#Parser-4632"><span class="linenos">4632</span></a> <span class="o">...</span> -</span><span id="Parser-4633"><a href="#Parser-4633"><span class="linenos">4633</span></a> -</span><span id="Parser-4634"><a href="#Parser-4634"><span class="linenos">4634</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> -</span><span id="Parser-4635"><a href="#Parser-4635"><span class="linenos">4635</span></a> <span class="k">def</span> <span class="nf">_replace_columns_with_dots</span><span class="p">(</span> -</span><span id="Parser-4636"><a href="#Parser-4636"><span class="linenos">4636</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><span id="Parser-4637"><a href="#Parser-4637"><span class="linenos">4637</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="Parser-4638"><a href="#Parser-4638"><span class="linenos">4638</span></a> <span class="o">...</span> -</span><span id="Parser-4639"><a href="#Parser-4639"><span class="linenos">4639</span></a> -</span><span id="Parser-4640"><a href="#Parser-4640"><span class="linenos">4640</span></a> <span class="k">def</span> <span class="nf">_replace_columns_with_dots</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">):</span> -</span><span id="Parser-4641"><a href="#Parser-4641"><span class="linenos">4641</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">Dot</span><span class="p">):</span> -</span><span id="Parser-4642"><a href="#Parser-4642"><span class="linenos">4642</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">replace_children</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_replace_columns_with_dots</span><span class="p">)</span> -</span><span id="Parser-4643"><a href="#Parser-4643"><span class="linenos">4643</span></a> <span class="k">elif</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">Column</span><span class="p">):</span> -</span><span id="Parser-4644"><a href="#Parser-4644"><span class="linenos">4644</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">replace_children</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_replace_columns_with_dots</span><span class="p">)</span> -</span><span id="Parser-4645"><a href="#Parser-4645"><span class="linenos">4645</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"table"</span><span class="p">)</span> -</span><span id="Parser-4646"><a href="#Parser-4646"><span class="linenos">4646</span></a> <span class="n">this</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Parser-4647"><a href="#Parser-4647"><span class="linenos">4647</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">Dot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="Parser-4648"><a href="#Parser-4648"><span class="linenos">4648</span></a> <span class="k">if</span> <span class="n">table</span> -</span><span id="Parser-4649"><a href="#Parser-4649"><span class="linenos">4649</span></a> <span class="k">else</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">Var</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> -</span><span id="Parser-4650"><a href="#Parser-4650"><span class="linenos">4650</span></a> <span class="p">)</span> -</span><span id="Parser-4651"><a href="#Parser-4651"><span class="linenos">4651</span></a> <span class="k">elif</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">Identifier</span><span class="p">):</span> -</span><span id="Parser-4652"><a href="#Parser-4652"><span class="linenos">4652</span></a> <span class="n">this</span> <span class="o">=</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">Var</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> -</span><span id="Parser-4653"><a href="#Parser-4653"><span class="linenos">4653</span></a> -</span><span id="Parser-4654"><a href="#Parser-4654"><span class="linenos">4654</span></a> <span class="k">return</span> <span class="n">this</span> -</span><span id="Parser-4655"><a href="#Parser-4655"><span class="linenos">4655</span></a> -</span><span id="Parser-4656"><a href="#Parser-4656"><span class="linenos">4656</span></a> <span class="k">def</span> <span class="nf">_replace_lambda</span><span class="p">(</span> -</span><span id="Parser-4657"><a href="#Parser-4657"><span class="linenos">4657</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">node</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="n">lambda_variables</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> -</span><span id="Parser-4658"><a href="#Parser-4658"><span class="linenos">4658</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="Parser-4659"><a href="#Parser-4659"><span class="linenos">4659</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">node</span><span class="p">:</span> -</span><span id="Parser-4660"><a href="#Parser-4660"><span class="linenos">4660</span></a> <span class="k">return</span> <span class="n">node</span> +</span><span id="Parser-4621"><a href="#Parser-4621"><span class="linenos">4621</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Parser-4622"><a href="#Parser-4622"><span class="linenos">4622</span></a> <span class="k">return</span> <span class="kc">False</span> +</span><span id="Parser-4623"><a href="#Parser-4623"><span class="linenos">4623</span></a> +</span><span id="Parser-4624"><a href="#Parser-4624"><span class="linenos">4624</span></a> <span class="k">def</span> <span class="nf">_match_text_seq</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">texts</span><span class="p">,</span> <span class="n">advance</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> +</span><span id="Parser-4625"><a href="#Parser-4625"><span class="linenos">4625</span></a> <span class="n">index</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> +</span><span id="Parser-4626"><a href="#Parser-4626"><span class="linenos">4626</span></a> <span class="k">for</span> <span class="n">text</span> <span class="ow">in</span> <span class="n">texts</span><span class="p">:</span> +</span><span id="Parser-4627"><a href="#Parser-4627"><span class="linenos">4627</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="n">text</span><span class="p">:</span> +</span><span id="Parser-4628"><a href="#Parser-4628"><span class="linenos">4628</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Parser-4629"><a href="#Parser-4629"><span class="linenos">4629</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-4630"><a href="#Parser-4630"><span class="linenos">4630</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-4631"><a href="#Parser-4631"><span class="linenos">4631</span></a> <span class="k">return</span> <span class="kc">False</span> +</span><span id="Parser-4632"><a href="#Parser-4632"><span class="linenos">4632</span></a> +</span><span id="Parser-4633"><a href="#Parser-4633"><span class="linenos">4633</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">advance</span><span class="p">:</span> +</span><span id="Parser-4634"><a href="#Parser-4634"><span class="linenos">4634</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_retreat</span><span class="p">(</span><span class="n">index</span><span class="p">)</span> +</span><span id="Parser-4635"><a href="#Parser-4635"><span class="linenos">4635</span></a> +</span><span id="Parser-4636"><a href="#Parser-4636"><span class="linenos">4636</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Parser-4637"><a href="#Parser-4637"><span class="linenos">4637</span></a> +</span><span id="Parser-4638"><a href="#Parser-4638"><span class="linenos">4638</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> +</span><span id="Parser-4639"><a href="#Parser-4639"><span class="linenos">4639</span></a> <span class="k">def</span> <span class="nf">_replace_columns_with_dots</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">:</span> +</span><span id="Parser-4640"><a href="#Parser-4640"><span class="linenos">4640</span></a> <span class="o">...</span> +</span><span id="Parser-4641"><a href="#Parser-4641"><span class="linenos">4641</span></a> +</span><span id="Parser-4642"><a href="#Parser-4642"><span class="linenos">4642</span></a> <span class="nd">@t</span><span class="o">.</span><span class="n">overload</span> +</span><span id="Parser-4643"><a href="#Parser-4643"><span class="linenos">4643</span></a> <span class="k">def</span> <span class="nf">_replace_columns_with_dots</span><span class="p">(</span> +</span><span id="Parser-4644"><a href="#Parser-4644"><span class="linenos">4644</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><span id="Parser-4645"><a href="#Parser-4645"><span class="linenos">4645</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="Parser-4646"><a href="#Parser-4646"><span class="linenos">4646</span></a> <span class="o">...</span> +</span><span id="Parser-4647"><a href="#Parser-4647"><span class="linenos">4647</span></a> +</span><span id="Parser-4648"><a href="#Parser-4648"><span class="linenos">4648</span></a> <span class="k">def</span> <span class="nf">_replace_columns_with_dots</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">this</span><span class="p">):</span> +</span><span id="Parser-4649"><a href="#Parser-4649"><span class="linenos">4649</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">Dot</span><span class="p">):</span> +</span><span id="Parser-4650"><a href="#Parser-4650"><span class="linenos">4650</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">replace_children</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_replace_columns_with_dots</span><span class="p">)</span> +</span><span id="Parser-4651"><a href="#Parser-4651"><span class="linenos">4651</span></a> <span class="k">elif</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">Column</span><span class="p">):</span> +</span><span id="Parser-4652"><a href="#Parser-4652"><span class="linenos">4652</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">replace_children</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_replace_columns_with_dots</span><span class="p">)</span> +</span><span id="Parser-4653"><a href="#Parser-4653"><span class="linenos">4653</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">this</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"table"</span><span class="p">)</span> +</span><span id="Parser-4654"><a href="#Parser-4654"><span class="linenos">4654</span></a> <span class="n">this</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Parser-4655"><a href="#Parser-4655"><span class="linenos">4655</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">Dot</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="Parser-4656"><a href="#Parser-4656"><span class="linenos">4656</span></a> <span class="k">if</span> <span class="n">table</span> +</span><span id="Parser-4657"><a href="#Parser-4657"><span class="linenos">4657</span></a> <span class="k">else</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">Var</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> +</span><span id="Parser-4658"><a href="#Parser-4658"><span class="linenos">4658</span></a> <span class="p">)</span> +</span><span id="Parser-4659"><a href="#Parser-4659"><span class="linenos">4659</span></a> <span class="k">elif</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">Identifier</span><span class="p">):</span> +</span><span id="Parser-4660"><a href="#Parser-4660"><span class="linenos">4660</span></a> <span class="n">this</span> <span class="o">=</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">Var</span><span class="p">,</span> <span class="n">this</span><span class="o">=</span><span class="n">this</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> </span><span id="Parser-4661"><a href="#Parser-4661"><span class="linenos">4661</span></a> -</span><span id="Parser-4662"><a href="#Parser-4662"><span class="linenos">4662</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">node</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> -</span><span id="Parser-4663"><a href="#Parser-4663"><span class="linenos">4663</span></a> <span class="k">if</span> <span class="n">column</span><span class="o">.</span><span class="n">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">name</span> <span class="ow">in</span> <span class="n">lambda_variables</span><span class="p">:</span> -</span><span id="Parser-4664"><a href="#Parser-4664"><span class="linenos">4664</span></a> <span class="n">dot_or_id</span> <span class="o">=</span> <span class="n">column</span><span class="o">.</span><span class="n">to_dot</span><span class="p">()</span> <span class="k">if</span> <span class="n">column</span><span class="o">.</span><span class="n">table</span> <span class="k">else</span> <span class="n">column</span><span class="o">.</span><span class="n">this</span> -</span><span id="Parser-4665"><a href="#Parser-4665"><span class="linenos">4665</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">column</span><span class="o">.</span><span class="n">parent</span> -</span><span id="Parser-4666"><a href="#Parser-4666"><span class="linenos">4666</span></a> -</span><span id="Parser-4667"><a href="#Parser-4667"><span class="linenos">4667</span></a> <span class="k">while</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">):</span> -</span><span id="Parser-4668"><a href="#Parser-4668"><span class="linenos">4668</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">parent</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">Dot</span><span class="p">):</span> -</span><span id="Parser-4669"><a href="#Parser-4669"><span class="linenos">4669</span></a> <span class="n">parent</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">dot_or_id</span><span class="p">)</span> -</span><span id="Parser-4670"><a href="#Parser-4670"><span class="linenos">4670</span></a> <span class="k">break</span> -</span><span id="Parser-4671"><a href="#Parser-4671"><span class="linenos">4671</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">parent</span><span class="o">.</span><span class="n">parent</span> -</span><span id="Parser-4672"><a href="#Parser-4672"><span class="linenos">4672</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-4673"><a href="#Parser-4673"><span class="linenos">4673</span></a> <span class="k">if</span> <span class="n">column</span> <span class="ow">is</span> <span class="n">node</span><span class="p">:</span> -</span><span id="Parser-4674"><a href="#Parser-4674"><span class="linenos">4674</span></a> <span class="n">node</span> <span class="o">=</span> <span class="n">dot_or_id</span> -</span><span id="Parser-4675"><a href="#Parser-4675"><span class="linenos">4675</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Parser-4676"><a href="#Parser-4676"><span class="linenos">4676</span></a> <span class="n">column</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">dot_or_id</span><span class="p">)</span> -</span><span id="Parser-4677"><a href="#Parser-4677"><span class="linenos">4677</span></a> <span class="k">return</span> <span class="n">node</span> +</span><span id="Parser-4662"><a href="#Parser-4662"><span class="linenos">4662</span></a> <span class="k">return</span> <span class="n">this</span> +</span><span id="Parser-4663"><a href="#Parser-4663"><span class="linenos">4663</span></a> +</span><span id="Parser-4664"><a href="#Parser-4664"><span class="linenos">4664</span></a> <span class="k">def</span> <span class="nf">_replace_lambda</span><span class="p">(</span> +</span><span id="Parser-4665"><a href="#Parser-4665"><span class="linenos">4665</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">node</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="n">lambda_variables</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> +</span><span id="Parser-4666"><a href="#Parser-4666"><span class="linenos">4666</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="Parser-4667"><a href="#Parser-4667"><span class="linenos">4667</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">node</span><span class="p">:</span> +</span><span id="Parser-4668"><a href="#Parser-4668"><span class="linenos">4668</span></a> <span class="k">return</span> <span class="n">node</span> +</span><span id="Parser-4669"><a href="#Parser-4669"><span class="linenos">4669</span></a> +</span><span id="Parser-4670"><a href="#Parser-4670"><span class="linenos">4670</span></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">node</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">):</span> +</span><span id="Parser-4671"><a href="#Parser-4671"><span class="linenos">4671</span></a> <span class="k">if</span> <span class="n">column</span><span class="o">.</span><span class="n">parts</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">name</span> <span class="ow">in</span> <span class="n">lambda_variables</span><span class="p">:</span> +</span><span id="Parser-4672"><a href="#Parser-4672"><span class="linenos">4672</span></a> <span class="n">dot_or_id</span> <span class="o">=</span> <span class="n">column</span><span class="o">.</span><span class="n">to_dot</span><span class="p">()</span> <span class="k">if</span> <span class="n">column</span><span class="o">.</span><span class="n">table</span> <span class="k">else</span> <span class="n">column</span><span class="o">.</span><span class="n">this</span> +</span><span id="Parser-4673"><a href="#Parser-4673"><span class="linenos">4673</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">column</span><span class="o">.</span><span class="n">parent</span> +</span><span id="Parser-4674"><a href="#Parser-4674"><span class="linenos">4674</span></a> +</span><span id="Parser-4675"><a href="#Parser-4675"><span class="linenos">4675</span></a> <span class="k">while</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Dot</span><span class="p">):</span> +</span><span id="Parser-4676"><a href="#Parser-4676"><span class="linenos">4676</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">parent</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">Dot</span><span class="p">):</span> +</span><span id="Parser-4677"><a href="#Parser-4677"><span class="linenos">4677</span></a> <span class="n">parent</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">dot_or_id</span><span class="p">)</span> +</span><span id="Parser-4678"><a href="#Parser-4678"><span class="linenos">4678</span></a> <span class="k">break</span> +</span><span id="Parser-4679"><a href="#Parser-4679"><span class="linenos">4679</span></a> <span class="n">parent</span> <span class="o">=</span> <span class="n">parent</span><span class="o">.</span><span class="n">parent</span> +</span><span id="Parser-4680"><a href="#Parser-4680"><span class="linenos">4680</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-4681"><a href="#Parser-4681"><span class="linenos">4681</span></a> <span class="k">if</span> <span class="n">column</span> <span class="ow">is</span> <span class="n">node</span><span class="p">:</span> +</span><span id="Parser-4682"><a href="#Parser-4682"><span class="linenos">4682</span></a> <span class="n">node</span> <span class="o">=</span> <span class="n">dot_or_id</span> +</span><span id="Parser-4683"><a href="#Parser-4683"><span class="linenos">4683</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Parser-4684"><a href="#Parser-4684"><span class="linenos">4684</span></a> <span class="n">column</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">dot_or_id</span><span class="p">)</span> +</span><span id="Parser-4685"><a href="#Parser-4685"><span class="linenos">4685</span></a> <span class="k">return</span> <span class="n">node</span> </span></pre></div> @@ -9505,16 +9521,16 @@ Default: 3</li> </div> <a class="headerlink" href="#Parser.__init__"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Parser.__init__-829"><a href="#Parser.__init__-829"><span class="linenos">829</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> -</span><span id="Parser.__init__-830"><a href="#Parser.__init__-830"><span class="linenos">830</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Parser.__init__-831"><a href="#Parser.__init__-831"><span class="linenos">831</span></a> <span class="n">error_level</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">ErrorLevel</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Parser.__init__-832"><a href="#Parser.__init__-832"><span class="linenos">832</span></a> <span class="n">error_message_context</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">100</span><span class="p">,</span> -</span><span id="Parser.__init__-833"><a href="#Parser.__init__-833"><span class="linenos">833</span></a> <span class="n">max_errors</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> -</span><span id="Parser.__init__-834"><a href="#Parser.__init__-834"><span class="linenos">834</span></a> <span class="p">):</span> -</span><span id="Parser.__init__-835"><a href="#Parser.__init__-835"><span class="linenos">835</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">=</span> <span class="n">error_level</span> <span class="ow">or</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span> -</span><span id="Parser.__init__-836"><a href="#Parser.__init__-836"><span class="linenos">836</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">error_message_context</span> <span class="o">=</span> <span class="n">error_message_context</span> -</span><span id="Parser.__init__-837"><a href="#Parser.__init__-837"><span class="linenos">837</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_errors</span> <span class="o">=</span> <span class="n">max_errors</span> -</span><span id="Parser.__init__-838"><a href="#Parser.__init__-838"><span class="linenos">838</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Parser.__init__-830"><a href="#Parser.__init__-830"><span class="linenos">830</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> +</span><span id="Parser.__init__-831"><a href="#Parser.__init__-831"><span class="linenos">831</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Parser.__init__-832"><a href="#Parser.__init__-832"><span class="linenos">832</span></a> <span class="n">error_level</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">ErrorLevel</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Parser.__init__-833"><a href="#Parser.__init__-833"><span class="linenos">833</span></a> <span class="n">error_message_context</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">100</span><span class="p">,</span> +</span><span id="Parser.__init__-834"><a href="#Parser.__init__-834"><span class="linenos">834</span></a> <span class="n">max_errors</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">3</span><span class="p">,</span> +</span><span id="Parser.__init__-835"><a href="#Parser.__init__-835"><span class="linenos">835</span></a> <span class="p">):</span> +</span><span id="Parser.__init__-836"><a href="#Parser.__init__-836"><span class="linenos">836</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">=</span> <span class="n">error_level</span> <span class="ow">or</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span> +</span><span id="Parser.__init__-837"><a href="#Parser.__init__-837"><span class="linenos">837</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">error_message_context</span> <span class="o">=</span> <span class="n">error_message_context</span> +</span><span id="Parser.__init__-838"><a href="#Parser.__init__-838"><span class="linenos">838</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">max_errors</span> <span class="o">=</span> <span class="n">max_errors</span> +</span><span id="Parser.__init__-839"><a href="#Parser.__init__-839"><span class="linenos">839</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> </span></pre></div> @@ -9532,15 +9548,15 @@ Default: 3</li> </div> <a class="headerlink" href="#Parser.reset"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Parser.reset-840"><a href="#Parser.reset-840"><span class="linenos">840</span></a> <span class="k">def</span> <span class="nf">reset</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="Parser.reset-841"><a href="#Parser.reset-841"><span class="linenos">841</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Parser.reset-842"><a href="#Parser.reset-842"><span class="linenos">842</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser.reset-843"><a href="#Parser.reset-843"><span class="linenos">843</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser.reset-844"><a href="#Parser.reset-844"><span class="linenos">844</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="Parser.reset-845"><a href="#Parser.reset-845"><span class="linenos">845</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser.reset-846"><a href="#Parser.reset-846"><span class="linenos">846</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser.reset-847"><a href="#Parser.reset-847"><span class="linenos">847</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Parser.reset-848"><a href="#Parser.reset-848"><span class="linenos">848</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> <span class="o">=</span> <span class="kc">None</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Parser.reset-841"><a href="#Parser.reset-841"><span class="linenos">841</span></a> <span class="k">def</span> <span class="nf">reset</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="Parser.reset-842"><a href="#Parser.reset-842"><span class="linenos">842</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Parser.reset-843"><a href="#Parser.reset-843"><span class="linenos">843</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser.reset-844"><a href="#Parser.reset-844"><span class="linenos">844</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_tokens</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser.reset-845"><a href="#Parser.reset-845"><span class="linenos">845</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="Parser.reset-846"><a href="#Parser.reset-846"><span class="linenos">846</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser.reset-847"><a href="#Parser.reset-847"><span class="linenos">847</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_next</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser.reset-848"><a href="#Parser.reset-848"><span class="linenos">848</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Parser.reset-849"><a href="#Parser.reset-849"><span class="linenos">849</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_comments</span> <span class="o">=</span> <span class="kc">None</span> </span></pre></div> @@ -9558,23 +9574,23 @@ Default: 3</li> </div> <a class="headerlink" href="#Parser.parse"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Parser.parse-850"><a href="#Parser.parse-850"><span class="linenos">850</span></a> <span class="k">def</span> <span class="nf">parse</span><span class="p">(</span> -</span><span id="Parser.parse-851"><a href="#Parser.parse-851"><span class="linenos">851</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">raw_tokens</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">Token</span><span class="p">],</span> <span class="n">sql</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><span id="Parser.parse-852"><a href="#Parser.parse-852"><span class="linenos">852</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Parser.parse-853"><a href="#Parser.parse-853"><span class="linenos">853</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Parser.parse-854"><a href="#Parser.parse-854"><span class="linenos">854</span></a><span class="sd"> Parses a list of tokens and returns a list of syntax trees, one tree</span> -</span><span id="Parser.parse-855"><a href="#Parser.parse-855"><span class="linenos">855</span></a><span class="sd"> per parsed SQL statement.</span> -</span><span id="Parser.parse-856"><a href="#Parser.parse-856"><span class="linenos">856</span></a> -</span><span id="Parser.parse-857"><a href="#Parser.parse-857"><span class="linenos">857</span></a><span class="sd"> Args:</span> -</span><span id="Parser.parse-858"><a href="#Parser.parse-858"><span class="linenos">858</span></a><span class="sd"> raw_tokens: The list of tokens.</span> -</span><span id="Parser.parse-859"><a href="#Parser.parse-859"><span class="linenos">859</span></a><span class="sd"> sql: The original SQL string, used to produce helpful debug messages.</span> -</span><span id="Parser.parse-860"><a href="#Parser.parse-860"><span class="linenos">860</span></a> -</span><span id="Parser.parse-861"><a href="#Parser.parse-861"><span class="linenos">861</span></a><span class="sd"> Returns:</span> -</span><span id="Parser.parse-862"><a href="#Parser.parse-862"><span class="linenos">862</span></a><span class="sd"> The list of the produced syntax trees.</span> -</span><span id="Parser.parse-863"><a href="#Parser.parse-863"><span class="linenos">863</span></a><span class="sd"> """</span> -</span><span id="Parser.parse-864"><a href="#Parser.parse-864"><span class="linenos">864</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse</span><span class="p">(</span> -</span><span id="Parser.parse-865"><a href="#Parser.parse-865"><span class="linenos">865</span></a> <span class="n">parse_method</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">,</span> <span class="n">raw_tokens</span><span class="o">=</span><span class="n">raw_tokens</span><span class="p">,</span> <span class="n">sql</span><span class="o">=</span><span class="n">sql</span> -</span><span id="Parser.parse-866"><a href="#Parser.parse-866"><span class="linenos">866</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Parser.parse-851"><a href="#Parser.parse-851"><span class="linenos">851</span></a> <span class="k">def</span> <span class="nf">parse</span><span class="p">(</span> +</span><span id="Parser.parse-852"><a href="#Parser.parse-852"><span class="linenos">852</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">raw_tokens</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">Token</span><span class="p">],</span> <span class="n">sql</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><span id="Parser.parse-853"><a href="#Parser.parse-853"><span class="linenos">853</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Parser.parse-854"><a href="#Parser.parse-854"><span class="linenos">854</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Parser.parse-855"><a href="#Parser.parse-855"><span class="linenos">855</span></a><span class="sd"> Parses a list of tokens and returns a list of syntax trees, one tree</span> +</span><span id="Parser.parse-856"><a href="#Parser.parse-856"><span class="linenos">856</span></a><span class="sd"> per parsed SQL statement.</span> +</span><span id="Parser.parse-857"><a href="#Parser.parse-857"><span class="linenos">857</span></a> +</span><span id="Parser.parse-858"><a href="#Parser.parse-858"><span class="linenos">858</span></a><span class="sd"> Args:</span> +</span><span id="Parser.parse-859"><a href="#Parser.parse-859"><span class="linenos">859</span></a><span class="sd"> raw_tokens: The list of tokens.</span> +</span><span id="Parser.parse-860"><a href="#Parser.parse-860"><span class="linenos">860</span></a><span class="sd"> sql: The original SQL string, used to produce helpful debug messages.</span> +</span><span id="Parser.parse-861"><a href="#Parser.parse-861"><span class="linenos">861</span></a> +</span><span id="Parser.parse-862"><a href="#Parser.parse-862"><span class="linenos">862</span></a><span class="sd"> Returns:</span> +</span><span id="Parser.parse-863"><a href="#Parser.parse-863"><span class="linenos">863</span></a><span class="sd"> The list of the produced syntax trees.</span> +</span><span id="Parser.parse-864"><a href="#Parser.parse-864"><span class="linenos">864</span></a><span class="sd"> """</span> +</span><span id="Parser.parse-865"><a href="#Parser.parse-865"><span class="linenos">865</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse</span><span class="p">(</span> +</span><span id="Parser.parse-866"><a href="#Parser.parse-866"><span class="linenos">866</span></a> <span class="n">parse_method</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="n">_parse_statement</span><span class="p">,</span> <span class="n">raw_tokens</span><span class="o">=</span><span class="n">raw_tokens</span><span class="p">,</span> <span class="n">sql</span><span class="o">=</span><span class="n">sql</span> +</span><span id="Parser.parse-867"><a href="#Parser.parse-867"><span class="linenos">867</span></a> <span class="p">)</span> </span></pre></div> @@ -9608,41 +9624,41 @@ per parsed SQL statement.</p> </div> <a class="headerlink" href="#Parser.parse_into"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Parser.parse_into-868"><a href="#Parser.parse_into-868"><span class="linenos">868</span></a> <span class="k">def</span> <span class="nf">parse_into</span><span class="p">(</span> -</span><span id="Parser.parse_into-869"><a href="#Parser.parse_into-869"><span class="linenos">869</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Parser.parse_into-870"><a href="#Parser.parse_into-870"><span class="linenos">870</span></a> <span class="n">expression_types</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IntoType</span><span class="p">,</span> -</span><span id="Parser.parse_into-871"><a href="#Parser.parse_into-871"><span class="linenos">871</span></a> <span class="n">raw_tokens</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">Token</span><span class="p">],</span> -</span><span id="Parser.parse_into-872"><a href="#Parser.parse_into-872"><span class="linenos">872</span></a> <span class="n">sql</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="Parser.parse_into-873"><a href="#Parser.parse_into-873"><span class="linenos">873</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Parser.parse_into-874"><a href="#Parser.parse_into-874"><span class="linenos">874</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Parser.parse_into-875"><a href="#Parser.parse_into-875"><span class="linenos">875</span></a><span class="sd"> Parses a list of tokens into a given Expression type. If a collection of Expression</span> -</span><span id="Parser.parse_into-876"><a href="#Parser.parse_into-876"><span class="linenos">876</span></a><span class="sd"> types is given instead, this method will try to parse the token list into each one</span> -</span><span id="Parser.parse_into-877"><a href="#Parser.parse_into-877"><span class="linenos">877</span></a><span class="sd"> of them, stopping at the first for which the parsing succeeds.</span> -</span><span id="Parser.parse_into-878"><a href="#Parser.parse_into-878"><span class="linenos">878</span></a> -</span><span id="Parser.parse_into-879"><a href="#Parser.parse_into-879"><span class="linenos">879</span></a><span class="sd"> Args:</span> -</span><span id="Parser.parse_into-880"><a href="#Parser.parse_into-880"><span class="linenos">880</span></a><span class="sd"> expression_types: The expression type(s) to try and parse the token list into.</span> -</span><span id="Parser.parse_into-881"><a href="#Parser.parse_into-881"><span class="linenos">881</span></a><span class="sd"> raw_tokens: The list of tokens.</span> -</span><span id="Parser.parse_into-882"><a href="#Parser.parse_into-882"><span class="linenos">882</span></a><span class="sd"> sql: The original SQL string, used to produce helpful debug messages.</span> -</span><span id="Parser.parse_into-883"><a href="#Parser.parse_into-883"><span class="linenos">883</span></a> -</span><span id="Parser.parse_into-884"><a href="#Parser.parse_into-884"><span class="linenos">884</span></a><span class="sd"> Returns:</span> -</span><span id="Parser.parse_into-885"><a href="#Parser.parse_into-885"><span class="linenos">885</span></a><span class="sd"> The target Expression.</span> -</span><span id="Parser.parse_into-886"><a href="#Parser.parse_into-886"><span class="linenos">886</span></a><span class="sd"> """</span> -</span><span id="Parser.parse_into-887"><a href="#Parser.parse_into-887"><span class="linenos">887</span></a> <span class="n">errors</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Parser.parse_into-888"><a href="#Parser.parse_into-888"><span class="linenos">888</span></a> <span class="k">for</span> <span class="n">expression_type</span> <span class="ow">in</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">expression_types</span><span class="p">):</span> -</span><span id="Parser.parse_into-889"><a href="#Parser.parse_into-889"><span class="linenos">889</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPRESSION_PARSERS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression_type</span><span class="p">)</span> -</span><span id="Parser.parse_into-890"><a href="#Parser.parse_into-890"><span class="linenos">890</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">parser</span><span class="p">:</span> -</span><span id="Parser.parse_into-891"><a href="#Parser.parse_into-891"><span class="linenos">891</span></a> <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"No parser registered for </span><span class="si">{</span><span class="n">expression_type</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Parser.parse_into-892"><a href="#Parser.parse_into-892"><span class="linenos">892</span></a> -</span><span id="Parser.parse_into-893"><a href="#Parser.parse_into-893"><span class="linenos">893</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="Parser.parse_into-894"><a href="#Parser.parse_into-894"><span class="linenos">894</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse</span><span class="p">(</span><span class="n">parser</span><span class="p">,</span> <span class="n">raw_tokens</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="Parser.parse_into-895"><a href="#Parser.parse_into-895"><span class="linenos">895</span></a> <span class="k">except</span> <span class="n">ParseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> -</span><span id="Parser.parse_into-896"><a href="#Parser.parse_into-896"><span class="linenos">896</span></a> <span class="n">e</span><span class="o">.</span><span class="n">errors</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s2">"into_expression"</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression_type</span> -</span><span id="Parser.parse_into-897"><a href="#Parser.parse_into-897"><span class="linenos">897</span></a> <span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> -</span><span id="Parser.parse_into-898"><a href="#Parser.parse_into-898"><span class="linenos">898</span></a> -</span><span id="Parser.parse_into-899"><a href="#Parser.parse_into-899"><span class="linenos">899</span></a> <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span> -</span><span id="Parser.parse_into-900"><a href="#Parser.parse_into-900"><span class="linenos">900</span></a> <span class="sa">f</span><span class="s2">"Failed to parse '</span><span class="si">{</span><span class="n">sql</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="n">raw_tokens</span><span class="si">}</span><span class="s2">' into </span><span class="si">{</span><span class="n">expression_types</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Parser.parse_into-901"><a href="#Parser.parse_into-901"><span class="linenos">901</span></a> <span class="n">errors</span><span class="o">=</span><span class="n">merge_errors</span><span class="p">(</span><span class="n">errors</span><span class="p">),</span> -</span><span id="Parser.parse_into-902"><a href="#Parser.parse_into-902"><span class="linenos">902</span></a> <span class="p">)</span> <span class="kn">from</span> <span class="nn">errors</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Parser.parse_into-869"><a href="#Parser.parse_into-869"><span class="linenos">869</span></a> <span class="k">def</span> <span class="nf">parse_into</span><span class="p">(</span> +</span><span id="Parser.parse_into-870"><a href="#Parser.parse_into-870"><span class="linenos">870</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Parser.parse_into-871"><a href="#Parser.parse_into-871"><span class="linenos">871</span></a> <span class="n">expression_types</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">IntoType</span><span class="p">,</span> +</span><span id="Parser.parse_into-872"><a href="#Parser.parse_into-872"><span class="linenos">872</span></a> <span class="n">raw_tokens</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">Token</span><span class="p">],</span> +</span><span id="Parser.parse_into-873"><a href="#Parser.parse_into-873"><span class="linenos">873</span></a> <span class="n">sql</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="Parser.parse_into-874"><a href="#Parser.parse_into-874"><span class="linenos">874</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="Parser.parse_into-875"><a href="#Parser.parse_into-875"><span class="linenos">875</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Parser.parse_into-876"><a href="#Parser.parse_into-876"><span class="linenos">876</span></a><span class="sd"> Parses a list of tokens into a given Expression type. If a collection of Expression</span> +</span><span id="Parser.parse_into-877"><a href="#Parser.parse_into-877"><span class="linenos">877</span></a><span class="sd"> types is given instead, this method will try to parse the token list into each one</span> +</span><span id="Parser.parse_into-878"><a href="#Parser.parse_into-878"><span class="linenos">878</span></a><span class="sd"> of them, stopping at the first for which the parsing succeeds.</span> +</span><span id="Parser.parse_into-879"><a href="#Parser.parse_into-879"><span class="linenos">879</span></a> +</span><span id="Parser.parse_into-880"><a href="#Parser.parse_into-880"><span class="linenos">880</span></a><span class="sd"> Args:</span> +</span><span id="Parser.parse_into-881"><a href="#Parser.parse_into-881"><span class="linenos">881</span></a><span class="sd"> expression_types: The expression type(s) to try and parse the token list into.</span> +</span><span id="Parser.parse_into-882"><a href="#Parser.parse_into-882"><span class="linenos">882</span></a><span class="sd"> raw_tokens: The list of tokens.</span> +</span><span id="Parser.parse_into-883"><a href="#Parser.parse_into-883"><span class="linenos">883</span></a><span class="sd"> sql: The original SQL string, used to produce helpful debug messages.</span> +</span><span id="Parser.parse_into-884"><a href="#Parser.parse_into-884"><span class="linenos">884</span></a> +</span><span id="Parser.parse_into-885"><a href="#Parser.parse_into-885"><span class="linenos">885</span></a><span class="sd"> Returns:</span> +</span><span id="Parser.parse_into-886"><a href="#Parser.parse_into-886"><span class="linenos">886</span></a><span class="sd"> The target Expression.</span> +</span><span id="Parser.parse_into-887"><a href="#Parser.parse_into-887"><span class="linenos">887</span></a><span class="sd"> """</span> +</span><span id="Parser.parse_into-888"><a href="#Parser.parse_into-888"><span class="linenos">888</span></a> <span class="n">errors</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Parser.parse_into-889"><a href="#Parser.parse_into-889"><span class="linenos">889</span></a> <span class="k">for</span> <span class="n">expression_type</span> <span class="ow">in</span> <span class="n">ensure_list</span><span class="p">(</span><span class="n">expression_types</span><span class="p">):</span> +</span><span id="Parser.parse_into-890"><a href="#Parser.parse_into-890"><span class="linenos">890</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">EXPRESSION_PARSERS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression_type</span><span class="p">)</span> +</span><span id="Parser.parse_into-891"><a href="#Parser.parse_into-891"><span class="linenos">891</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">parser</span><span class="p">:</span> +</span><span id="Parser.parse_into-892"><a href="#Parser.parse_into-892"><span class="linenos">892</span></a> <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"No parser registered for </span><span class="si">{</span><span class="n">expression_type</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Parser.parse_into-893"><a href="#Parser.parse_into-893"><span class="linenos">893</span></a> +</span><span id="Parser.parse_into-894"><a href="#Parser.parse_into-894"><span class="linenos">894</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="Parser.parse_into-895"><a href="#Parser.parse_into-895"><span class="linenos">895</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse</span><span class="p">(</span><span class="n">parser</span><span class="p">,</span> <span class="n">raw_tokens</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="Parser.parse_into-896"><a href="#Parser.parse_into-896"><span class="linenos">896</span></a> <span class="k">except</span> <span class="n">ParseError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> +</span><span id="Parser.parse_into-897"><a href="#Parser.parse_into-897"><span class="linenos">897</span></a> <span class="n">e</span><span class="o">.</span><span class="n">errors</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s2">"into_expression"</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression_type</span> +</span><span id="Parser.parse_into-898"><a href="#Parser.parse_into-898"><span class="linenos">898</span></a> <span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> +</span><span id="Parser.parse_into-899"><a href="#Parser.parse_into-899"><span class="linenos">899</span></a> +</span><span id="Parser.parse_into-900"><a href="#Parser.parse_into-900"><span class="linenos">900</span></a> <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span> +</span><span id="Parser.parse_into-901"><a href="#Parser.parse_into-901"><span class="linenos">901</span></a> <span class="sa">f</span><span class="s2">"Failed to parse '</span><span class="si">{</span><span class="n">sql</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="n">raw_tokens</span><span class="si">}</span><span class="s2">' into </span><span class="si">{</span><span class="n">expression_types</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Parser.parse_into-902"><a href="#Parser.parse_into-902"><span class="linenos">902</span></a> <span class="n">errors</span><span class="o">=</span><span class="n">merge_errors</span><span class="p">(</span><span class="n">errors</span><span class="p">),</span> +</span><span id="Parser.parse_into-903"><a href="#Parser.parse_into-903"><span class="linenos">903</span></a> <span class="p">)</span> <span class="kn">from</span> <span class="nn">errors</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> </span></pre></div> @@ -9678,16 +9694,16 @@ of them, stopping at the first for which the parsing succeeds.</p> </div> <a class="headerlink" href="#Parser.check_errors"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Parser.check_errors-939"><a href="#Parser.check_errors-939"><span class="linenos">939</span></a> <span class="k">def</span> <span class="nf">check_errors</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Parser.check_errors-940"><a href="#Parser.check_errors-940"><span class="linenos">940</span></a><span class="w"> </span><span class="sd">"""Logs or raises any found errors, depending on the chosen error level setting."""</span> -</span><span id="Parser.check_errors-941"><a href="#Parser.check_errors-941"><span class="linenos">941</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">:</span> -</span><span id="Parser.check_errors-942"><a href="#Parser.check_errors-942"><span class="linenos">942</span></a> <span class="k">for</span> <span class="n">error</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">:</span> -</span><span id="Parser.check_errors-943"><a href="#Parser.check_errors-943"><span class="linenos">943</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">error</span><span class="p">))</span> -</span><span id="Parser.check_errors-944"><a href="#Parser.check_errors-944"><span class="linenos">944</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">RAISE</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">:</span> -</span><span id="Parser.check_errors-945"><a href="#Parser.check_errors-945"><span class="linenos">945</span></a> <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span> -</span><span id="Parser.check_errors-946"><a href="#Parser.check_errors-946"><span class="linenos">946</span></a> <span class="n">concat_messages</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_errors</span><span class="p">),</span> -</span><span id="Parser.check_errors-947"><a href="#Parser.check_errors-947"><span class="linenos">947</span></a> <span class="n">errors</span><span class="o">=</span><span class="n">merge_errors</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">),</span> -</span><span id="Parser.check_errors-948"><a href="#Parser.check_errors-948"><span class="linenos">948</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Parser.check_errors-940"><a href="#Parser.check_errors-940"><span class="linenos">940</span></a> <span class="k">def</span> <span class="nf">check_errors</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Parser.check_errors-941"><a href="#Parser.check_errors-941"><span class="linenos">941</span></a><span class="w"> </span><span class="sd">"""Logs or raises any found errors, depending on the chosen error level setting."""</span> +</span><span id="Parser.check_errors-942"><a href="#Parser.check_errors-942"><span class="linenos">942</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">WARN</span><span class="p">:</span> +</span><span id="Parser.check_errors-943"><a href="#Parser.check_errors-943"><span class="linenos">943</span></a> <span class="k">for</span> <span class="n">error</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">:</span> +</span><span id="Parser.check_errors-944"><a href="#Parser.check_errors-944"><span class="linenos">944</span></a> <span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">error</span><span class="p">))</span> +</span><span id="Parser.check_errors-945"><a href="#Parser.check_errors-945"><span class="linenos">945</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">RAISE</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">:</span> +</span><span id="Parser.check_errors-946"><a href="#Parser.check_errors-946"><span class="linenos">946</span></a> <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span> +</span><span id="Parser.check_errors-947"><a href="#Parser.check_errors-947"><span class="linenos">947</span></a> <span class="n">concat_messages</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_errors</span><span class="p">),</span> +</span><span id="Parser.check_errors-948"><a href="#Parser.check_errors-948"><span class="linenos">948</span></a> <span class="n">errors</span><span class="o">=</span><span class="n">merge_errors</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="p">),</span> +</span><span id="Parser.check_errors-949"><a href="#Parser.check_errors-949"><span class="linenos">949</span></a> <span class="p">)</span> </span></pre></div> @@ -9707,33 +9723,33 @@ of them, stopping at the first for which the parsing succeeds.</p> </div> <a class="headerlink" href="#Parser.raise_error"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Parser.raise_error-950"><a href="#Parser.raise_error-950"><span class="linenos">950</span></a> <span class="k">def</span> <span class="nf">raise_error</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">token</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">Token</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Parser.raise_error-951"><a href="#Parser.raise_error-951"><span class="linenos">951</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Parser.raise_error-952"><a href="#Parser.raise_error-952"><span class="linenos">952</span></a><span class="sd"> Appends an error in the list of recorded errors or raises it, depending on the chosen</span> -</span><span id="Parser.raise_error-953"><a href="#Parser.raise_error-953"><span class="linenos">953</span></a><span class="sd"> error level setting.</span> -</span><span id="Parser.raise_error-954"><a href="#Parser.raise_error-954"><span class="linenos">954</span></a><span class="sd"> """</span> -</span><span id="Parser.raise_error-955"><a href="#Parser.raise_error-955"><span class="linenos">955</span></a> <span class="n">token</span> <span class="o">=</span> <span class="n">token</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="ow">or</span> <span class="n">Token</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">)</span> -</span><span id="Parser.raise_error-956"><a href="#Parser.raise_error-956"><span class="linenos">956</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">token</span><span class="o">.</span><span class="n">start</span> -</span><span id="Parser.raise_error-957"><a href="#Parser.raise_error-957"><span class="linenos">957</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">token</span><span class="o">.</span><span class="n">end</span> <span class="o">+</span> <span class="mi">1</span> -</span><span id="Parser.raise_error-958"><a href="#Parser.raise_error-958"><span class="linenos">958</span></a> <span class="n">start_context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="nb">max</span><span class="p">(</span><span class="n">start</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_message_context</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="p">:</span> <span class="n">start</span><span class="p">]</span> -</span><span id="Parser.raise_error-959"><a href="#Parser.raise_error-959"><span class="linenos">959</span></a> <span class="n">highlight</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">start</span><span class="p">:</span><span class="n">end</span><span class="p">]</span> -</span><span id="Parser.raise_error-960"><a href="#Parser.raise_error-960"><span class="linenos">960</span></a> <span class="n">end_context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">end</span> <span class="p">:</span> <span class="n">end</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_message_context</span><span class="p">]</span> -</span><span id="Parser.raise_error-961"><a href="#Parser.raise_error-961"><span class="linenos">961</span></a> -</span><span id="Parser.raise_error-962"><a href="#Parser.raise_error-962"><span class="linenos">962</span></a> <span class="n">error</span> <span class="o">=</span> <span class="n">ParseError</span><span class="o">.</span><span class="n">new</span><span class="p">(</span> -</span><span id="Parser.raise_error-963"><a href="#Parser.raise_error-963"><span class="linenos">963</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">message</span><span class="si">}</span><span class="s2">. Line </span><span class="si">{</span><span class="n">token</span><span class="o">.</span><span class="n">line</span><span class="si">}</span><span class="s2">, Col: </span><span class="si">{</span><span class="n">token</span><span class="o">.</span><span class="n">col</span><span class="si">}</span><span class="s2">.</span><span class="se">\n</span><span class="s2">"</span> -</span><span id="Parser.raise_error-964"><a href="#Parser.raise_error-964"><span class="linenos">964</span></a> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">start_context</span><span class="si">}</span><span class="se">\033</span><span class="s2">[4m</span><span class="si">{</span><span class="n">highlight</span><span class="si">}</span><span class="se">\033</span><span class="s2">[0m</span><span class="si">{</span><span class="n">end_context</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> -</span><span id="Parser.raise_error-965"><a href="#Parser.raise_error-965"><span class="linenos">965</span></a> <span class="n">description</span><span class="o">=</span><span class="n">message</span><span class="p">,</span> -</span><span id="Parser.raise_error-966"><a href="#Parser.raise_error-966"><span class="linenos">966</span></a> <span class="n">line</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">line</span><span class="p">,</span> -</span><span id="Parser.raise_error-967"><a href="#Parser.raise_error-967"><span class="linenos">967</span></a> <span class="n">col</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">col</span><span class="p">,</span> -</span><span id="Parser.raise_error-968"><a href="#Parser.raise_error-968"><span class="linenos">968</span></a> <span class="n">start_context</span><span class="o">=</span><span class="n">start_context</span><span class="p">,</span> -</span><span id="Parser.raise_error-969"><a href="#Parser.raise_error-969"><span class="linenos">969</span></a> <span class="n">highlight</span><span class="o">=</span><span class="n">highlight</span><span class="p">,</span> -</span><span id="Parser.raise_error-970"><a href="#Parser.raise_error-970"><span class="linenos">970</span></a> <span class="n">end_context</span><span class="o">=</span><span class="n">end_context</span><span class="p">,</span> -</span><span id="Parser.raise_error-971"><a href="#Parser.raise_error-971"><span class="linenos">971</span></a> <span class="p">)</span> -</span><span id="Parser.raise_error-972"><a href="#Parser.raise_error-972"><span class="linenos">972</span></a> -</span><span id="Parser.raise_error-973"><a href="#Parser.raise_error-973"><span class="linenos">973</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span><span class="p">:</span> -</span><span id="Parser.raise_error-974"><a href="#Parser.raise_error-974"><span class="linenos">974</span></a> <span class="k">raise</span> <span class="n">error</span> -</span><span id="Parser.raise_error-975"><a href="#Parser.raise_error-975"><span class="linenos">975</span></a> -</span><span id="Parser.raise_error-976"><a href="#Parser.raise_error-976"><span class="linenos">976</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">error</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Parser.raise_error-951"><a href="#Parser.raise_error-951"><span class="linenos">951</span></a> <span class="k">def</span> <span class="nf">raise_error</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">token</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">Token</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Parser.raise_error-952"><a href="#Parser.raise_error-952"><span class="linenos">952</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Parser.raise_error-953"><a href="#Parser.raise_error-953"><span class="linenos">953</span></a><span class="sd"> Appends an error in the list of recorded errors or raises it, depending on the chosen</span> +</span><span id="Parser.raise_error-954"><a href="#Parser.raise_error-954"><span class="linenos">954</span></a><span class="sd"> error level setting.</span> +</span><span id="Parser.raise_error-955"><a href="#Parser.raise_error-955"><span class="linenos">955</span></a><span class="sd"> """</span> +</span><span id="Parser.raise_error-956"><a href="#Parser.raise_error-956"><span class="linenos">956</span></a> <span class="n">token</span> <span class="o">=</span> <span class="n">token</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_curr</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev</span> <span class="ow">or</span> <span class="n">Token</span><span class="o">.</span><span class="n">string</span><span class="p">(</span><span class="s2">""</span><span class="p">)</span> +</span><span id="Parser.raise_error-957"><a href="#Parser.raise_error-957"><span class="linenos">957</span></a> <span class="n">start</span> <span class="o">=</span> <span class="n">token</span><span class="o">.</span><span class="n">start</span> +</span><span id="Parser.raise_error-958"><a href="#Parser.raise_error-958"><span class="linenos">958</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">token</span><span class="o">.</span><span class="n">end</span> <span class="o">+</span> <span class="mi">1</span> +</span><span id="Parser.raise_error-959"><a href="#Parser.raise_error-959"><span class="linenos">959</span></a> <span class="n">start_context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="nb">max</span><span class="p">(</span><span class="n">start</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_message_context</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="p">:</span> <span class="n">start</span><span class="p">]</span> +</span><span id="Parser.raise_error-960"><a href="#Parser.raise_error-960"><span class="linenos">960</span></a> <span class="n">highlight</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">start</span><span class="p">:</span><span class="n">end</span><span class="p">]</span> +</span><span id="Parser.raise_error-961"><a href="#Parser.raise_error-961"><span class="linenos">961</span></a> <span class="n">end_context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">end</span> <span class="p">:</span> <span class="n">end</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_message_context</span><span class="p">]</span> +</span><span id="Parser.raise_error-962"><a href="#Parser.raise_error-962"><span class="linenos">962</span></a> +</span><span id="Parser.raise_error-963"><a href="#Parser.raise_error-963"><span class="linenos">963</span></a> <span class="n">error</span> <span class="o">=</span> <span class="n">ParseError</span><span class="o">.</span><span class="n">new</span><span class="p">(</span> +</span><span id="Parser.raise_error-964"><a href="#Parser.raise_error-964"><span class="linenos">964</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">message</span><span class="si">}</span><span class="s2">. Line </span><span class="si">{</span><span class="n">token</span><span class="o">.</span><span class="n">line</span><span class="si">}</span><span class="s2">, Col: </span><span class="si">{</span><span class="n">token</span><span class="o">.</span><span class="n">col</span><span class="si">}</span><span class="s2">.</span><span class="se">\n</span><span class="s2">"</span> +</span><span id="Parser.raise_error-965"><a href="#Parser.raise_error-965"><span class="linenos">965</span></a> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">start_context</span><span class="si">}</span><span class="se">\033</span><span class="s2">[4m</span><span class="si">{</span><span class="n">highlight</span><span class="si">}</span><span class="se">\033</span><span class="s2">[0m</span><span class="si">{</span><span class="n">end_context</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span> +</span><span id="Parser.raise_error-966"><a href="#Parser.raise_error-966"><span class="linenos">966</span></a> <span class="n">description</span><span class="o">=</span><span class="n">message</span><span class="p">,</span> +</span><span id="Parser.raise_error-967"><a href="#Parser.raise_error-967"><span class="linenos">967</span></a> <span class="n">line</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">line</span><span class="p">,</span> +</span><span id="Parser.raise_error-968"><a href="#Parser.raise_error-968"><span class="linenos">968</span></a> <span class="n">col</span><span class="o">=</span><span class="n">token</span><span class="o">.</span><span class="n">col</span><span class="p">,</span> +</span><span id="Parser.raise_error-969"><a href="#Parser.raise_error-969"><span class="linenos">969</span></a> <span class="n">start_context</span><span class="o">=</span><span class="n">start_context</span><span class="p">,</span> +</span><span id="Parser.raise_error-970"><a href="#Parser.raise_error-970"><span class="linenos">970</span></a> <span class="n">highlight</span><span class="o">=</span><span class="n">highlight</span><span class="p">,</span> +</span><span id="Parser.raise_error-971"><a href="#Parser.raise_error-971"><span class="linenos">971</span></a> <span class="n">end_context</span><span class="o">=</span><span class="n">end_context</span><span class="p">,</span> +</span><span id="Parser.raise_error-972"><a href="#Parser.raise_error-972"><span class="linenos">972</span></a> <span class="p">)</span> +</span><span id="Parser.raise_error-973"><a href="#Parser.raise_error-973"><span class="linenos">973</span></a> +</span><span id="Parser.raise_error-974"><a href="#Parser.raise_error-974"><span class="linenos">974</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">==</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IMMEDIATE</span><span class="p">:</span> +</span><span id="Parser.raise_error-975"><a href="#Parser.raise_error-975"><span class="linenos">975</span></a> <span class="k">raise</span> <span class="n">error</span> +</span><span id="Parser.raise_error-976"><a href="#Parser.raise_error-976"><span class="linenos">976</span></a> +</span><span id="Parser.raise_error-977"><a href="#Parser.raise_error-977"><span class="linenos">977</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">error</span><span class="p">)</span> </span></pre></div> @@ -9754,23 +9770,23 @@ error level setting.</p> </div> <a class="headerlink" href="#Parser.expression"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Parser.expression-978"><a href="#Parser.expression-978"><span class="linenos">978</span></a> <span class="k">def</span> <span class="nf">expression</span><span class="p">(</span> -</span><span id="Parser.expression-979"><a href="#Parser.expression-979"><span class="linenos">979</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> <span class="n">comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> -</span><span id="Parser.expression-980"><a href="#Parser.expression-980"><span class="linenos">980</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="Parser.expression-981"><a href="#Parser.expression-981"><span class="linenos">981</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Parser.expression-982"><a href="#Parser.expression-982"><span class="linenos">982</span></a><span class="sd"> Creates a new, validated Expression.</span> -</span><span id="Parser.expression-983"><a href="#Parser.expression-983"><span class="linenos">983</span></a> -</span><span id="Parser.expression-984"><a href="#Parser.expression-984"><span class="linenos">984</span></a><span class="sd"> Args:</span> -</span><span id="Parser.expression-985"><a href="#Parser.expression-985"><span class="linenos">985</span></a><span class="sd"> exp_class: The expression class to instantiate.</span> -</span><span id="Parser.expression-986"><a href="#Parser.expression-986"><span class="linenos">986</span></a><span class="sd"> comments: An optional list of comments to attach to the expression.</span> -</span><span id="Parser.expression-987"><a href="#Parser.expression-987"><span class="linenos">987</span></a><span class="sd"> kwargs: The arguments to set for the expression along with their respective values.</span> -</span><span id="Parser.expression-988"><a href="#Parser.expression-988"><span class="linenos">988</span></a> -</span><span id="Parser.expression-989"><a href="#Parser.expression-989"><span class="linenos">989</span></a><span class="sd"> Returns:</span> -</span><span id="Parser.expression-990"><a href="#Parser.expression-990"><span class="linenos">990</span></a><span class="sd"> The target expression.</span> -</span><span id="Parser.expression-991"><a href="#Parser.expression-991"><span class="linenos">991</span></a><span class="sd"> """</span> -</span><span id="Parser.expression-992"><a href="#Parser.expression-992"><span class="linenos">992</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">exp_class</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> -</span><span id="Parser.expression-993"><a href="#Parser.expression-993"><span class="linenos">993</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">add_comments</span><span class="p">(</span><span class="n">comments</span><span class="p">)</span> <span class="k">if</span> <span class="n">comments</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add_comments</span><span class="p">(</span><span class="n">instance</span><span class="p">)</span> -</span><span id="Parser.expression-994"><a href="#Parser.expression-994"><span class="linenos">994</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">instance</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Parser.expression-979"><a href="#Parser.expression-979"><span class="linenos">979</span></a> <span class="k">def</span> <span class="nf">expression</span><span class="p">(</span> +</span><span id="Parser.expression-980"><a href="#Parser.expression-980"><span class="linenos">980</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">exp_class</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Type</span><span class="p">[</span><span class="n">E</span><span class="p">],</span> <span class="n">comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span> +</span><span id="Parser.expression-981"><a href="#Parser.expression-981"><span class="linenos">981</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="Parser.expression-982"><a href="#Parser.expression-982"><span class="linenos">982</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Parser.expression-983"><a href="#Parser.expression-983"><span class="linenos">983</span></a><span class="sd"> Creates a new, validated Expression.</span> +</span><span id="Parser.expression-984"><a href="#Parser.expression-984"><span class="linenos">984</span></a> +</span><span id="Parser.expression-985"><a href="#Parser.expression-985"><span class="linenos">985</span></a><span class="sd"> Args:</span> +</span><span id="Parser.expression-986"><a href="#Parser.expression-986"><span class="linenos">986</span></a><span class="sd"> exp_class: The expression class to instantiate.</span> +</span><span id="Parser.expression-987"><a href="#Parser.expression-987"><span class="linenos">987</span></a><span class="sd"> comments: An optional list of comments to attach to the expression.</span> +</span><span id="Parser.expression-988"><a href="#Parser.expression-988"><span class="linenos">988</span></a><span class="sd"> kwargs: The arguments to set for the expression along with their respective values.</span> +</span><span id="Parser.expression-989"><a href="#Parser.expression-989"><span class="linenos">989</span></a> +</span><span id="Parser.expression-990"><a href="#Parser.expression-990"><span class="linenos">990</span></a><span class="sd"> Returns:</span> +</span><span id="Parser.expression-991"><a href="#Parser.expression-991"><span class="linenos">991</span></a><span class="sd"> The target expression.</span> +</span><span id="Parser.expression-992"><a href="#Parser.expression-992"><span class="linenos">992</span></a><span class="sd"> """</span> +</span><span id="Parser.expression-993"><a href="#Parser.expression-993"><span class="linenos">993</span></a> <span class="n">instance</span> <span class="o">=</span> <span class="n">exp_class</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="Parser.expression-994"><a href="#Parser.expression-994"><span class="linenos">994</span></a> <span class="n">instance</span><span class="o">.</span><span class="n">add_comments</span><span class="p">(</span><span class="n">comments</span><span class="p">)</span> <span class="k">if</span> <span class="n">comments</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add_comments</span><span class="p">(</span><span class="n">instance</span><span class="p">)</span> +</span><span id="Parser.expression-995"><a href="#Parser.expression-995"><span class="linenos">995</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">validate_expression</span><span class="p">(</span><span class="n">instance</span><span class="p">)</span> </span></pre></div> @@ -9804,22 +9820,22 @@ error level setting.</p> </div> <a class="headerlink" href="#Parser.validate_expression"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Parser.validate_expression-1001"><a href="#Parser.validate_expression-1001"><span class="linenos">1001</span></a> <span class="k">def</span> <span class="nf">validate_expression</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> -</span><span id="Parser.validate_expression-1002"><a href="#Parser.validate_expression-1002"><span class="linenos">1002</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="Parser.validate_expression-1003"><a href="#Parser.validate_expression-1003"><span class="linenos">1003</span></a><span class="sd"> Validates an Expression, making sure that all its mandatory arguments are set.</span> -</span><span id="Parser.validate_expression-1004"><a href="#Parser.validate_expression-1004"><span class="linenos">1004</span></a> -</span><span id="Parser.validate_expression-1005"><a href="#Parser.validate_expression-1005"><span class="linenos">1005</span></a><span class="sd"> Args:</span> -</span><span id="Parser.validate_expression-1006"><a href="#Parser.validate_expression-1006"><span class="linenos">1006</span></a><span class="sd"> expression: The expression to validate.</span> -</span><span id="Parser.validate_expression-1007"><a href="#Parser.validate_expression-1007"><span class="linenos">1007</span></a><span class="sd"> args: An optional list of items that was used to instantiate the expression, if it's a Func.</span> -</span><span id="Parser.validate_expression-1008"><a href="#Parser.validate_expression-1008"><span class="linenos">1008</span></a> -</span><span id="Parser.validate_expression-1009"><a href="#Parser.validate_expression-1009"><span class="linenos">1009</span></a><span class="sd"> Returns:</span> -</span><span id="Parser.validate_expression-1010"><a href="#Parser.validate_expression-1010"><span class="linenos">1010</span></a><span class="sd"> The validated expression.</span> -</span><span id="Parser.validate_expression-1011"><a href="#Parser.validate_expression-1011"><span class="linenos">1011</span></a><span class="sd"> """</span> -</span><span id="Parser.validate_expression-1012"><a href="#Parser.validate_expression-1012"><span class="linenos">1012</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">!=</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IGNORE</span><span class="p">:</span> -</span><span id="Parser.validate_expression-1013"><a href="#Parser.validate_expression-1013"><span class="linenos">1013</span></a> <span class="k">for</span> <span class="n">error_message</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">error_messages</span><span class="p">(</span><span class="n">args</span><span class="p">):</span> -</span><span id="Parser.validate_expression-1014"><a href="#Parser.validate_expression-1014"><span class="linenos">1014</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="n">error_message</span><span class="p">)</span> -</span><span id="Parser.validate_expression-1015"><a href="#Parser.validate_expression-1015"><span class="linenos">1015</span></a> -</span><span id="Parser.validate_expression-1016"><a href="#Parser.validate_expression-1016"><span class="linenos">1016</span></a> <span class="k">return</span> <span class="n">expression</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Parser.validate_expression-1002"><a href="#Parser.validate_expression-1002"><span class="linenos">1002</span></a> <span class="k">def</span> <span class="nf">validate_expression</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">expression</span><span class="p">:</span> <span class="n">E</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">E</span><span class="p">:</span> +</span><span id="Parser.validate_expression-1003"><a href="#Parser.validate_expression-1003"><span class="linenos">1003</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="Parser.validate_expression-1004"><a href="#Parser.validate_expression-1004"><span class="linenos">1004</span></a><span class="sd"> Validates an Expression, making sure that all its mandatory arguments are set.</span> +</span><span id="Parser.validate_expression-1005"><a href="#Parser.validate_expression-1005"><span class="linenos">1005</span></a> +</span><span id="Parser.validate_expression-1006"><a href="#Parser.validate_expression-1006"><span class="linenos">1006</span></a><span class="sd"> Args:</span> +</span><span id="Parser.validate_expression-1007"><a href="#Parser.validate_expression-1007"><span class="linenos">1007</span></a><span class="sd"> expression: The expression to validate.</span> +</span><span id="Parser.validate_expression-1008"><a href="#Parser.validate_expression-1008"><span class="linenos">1008</span></a><span class="sd"> args: An optional list of items that was used to instantiate the expression, if it's a Func.</span> +</span><span id="Parser.validate_expression-1009"><a href="#Parser.validate_expression-1009"><span class="linenos">1009</span></a> +</span><span id="Parser.validate_expression-1010"><a href="#Parser.validate_expression-1010"><span class="linenos">1010</span></a><span class="sd"> Returns:</span> +</span><span id="Parser.validate_expression-1011"><a href="#Parser.validate_expression-1011"><span class="linenos">1011</span></a><span class="sd"> The validated expression.</span> +</span><span id="Parser.validate_expression-1012"><a href="#Parser.validate_expression-1012"><span class="linenos">1012</span></a><span class="sd"> """</span> +</span><span id="Parser.validate_expression-1013"><a href="#Parser.validate_expression-1013"><span class="linenos">1013</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">error_level</span> <span class="o">!=</span> <span class="n">ErrorLevel</span><span class="o">.</span><span class="n">IGNORE</span><span class="p">:</span> +</span><span id="Parser.validate_expression-1014"><a href="#Parser.validate_expression-1014"><span class="linenos">1014</span></a> <span class="k">for</span> <span class="n">error_message</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">error_messages</span><span class="p">(</span><span class="n">args</span><span class="p">):</span> +</span><span id="Parser.validate_expression-1015"><a href="#Parser.validate_expression-1015"><span class="linenos">1015</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">raise_error</span><span class="p">(</span><span class="n">error_message</span><span class="p">)</span> +</span><span id="Parser.validate_expression-1016"><a href="#Parser.validate_expression-1016"><span class="linenos">1016</span></a> +</span><span id="Parser.validate_expression-1017"><a href="#Parser.validate_expression-1017"><span class="linenos">1017</span></a> <span class="k">return</span> <span class="n">expression</span> </span></pre></div> diff --git a/docs/sqlglot/planner.html b/docs/sqlglot/planner.html index f6cbdd0..3665253 100644 --- a/docs/sqlglot/planner.html +++ b/docs/sqlglot/planner.html @@ -423,7 +423,7 @@ </span><span id="L-302"><a href="#L-302"><span class="linenos">302</span></a> </span><span id="L-303"><a href="#L-303"><span class="linenos">303</span></a> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">joins</span><span class="p">:</span> </span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a> <span class="n">source_key</span><span class="p">,</span> <span class="n">join_key</span><span class="p">,</span> <span class="n">condition</span> <span class="o">=</span> <span class="n">join_condition</span><span class="p">(</span><span class="n">join</span><span class="p">)</span> -</span><span id="L-305"><a href="#L-305"><span class="linenos">305</span></a> <span class="n">step</span><span class="o">.</span><span class="n">joins</span><span class="p">[</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-305"><a href="#L-305"><span class="linenos">305</span></a> <span class="n">step</span><span class="o">.</span><span class="n">joins</span><span class="p">[</span><span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> </span><span id="L-306"><a href="#L-306"><span class="linenos">306</span></a> <span class="s2">"side"</span><span class="p">:</span> <span class="n">join</span><span class="o">.</span><span class="n">side</span><span class="p">,</span> <span class="c1"># type: ignore</span> </span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a> <span class="s2">"join_key"</span><span class="p">:</span> <span class="n">join_key</span><span class="p">,</span> </span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a> <span class="s2">"source_key"</span><span class="p">:</span> <span class="n">source_key</span><span class="p">,</span> @@ -1316,7 +1316,7 @@ Projections:</li> </span><span id="Join-303"><a href="#Join-303"><span class="linenos">303</span></a> </span><span id="Join-304"><a href="#Join-304"><span class="linenos">304</span></a> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">joins</span><span class="p">:</span> </span><span id="Join-305"><a href="#Join-305"><span class="linenos">305</span></a> <span class="n">source_key</span><span class="p">,</span> <span class="n">join_key</span><span class="p">,</span> <span class="n">condition</span> <span class="o">=</span> <span class="n">join_condition</span><span class="p">(</span><span class="n">join</span><span class="p">)</span> -</span><span id="Join-306"><a href="#Join-306"><span class="linenos">306</span></a> <span class="n">step</span><span class="o">.</span><span class="n">joins</span><span class="p">[</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Join-306"><a href="#Join-306"><span class="linenos">306</span></a> <span class="n">step</span><span class="o">.</span><span class="n">joins</span><span class="p">[</span><span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> </span><span id="Join-307"><a href="#Join-307"><span class="linenos">307</span></a> <span class="s2">"side"</span><span class="p">:</span> <span class="n">join</span><span class="o">.</span><span class="n">side</span><span class="p">,</span> <span class="c1"># type: ignore</span> </span><span id="Join-308"><a href="#Join-308"><span class="linenos">308</span></a> <span class="s2">"join_key"</span><span class="p">:</span> <span class="n">join_key</span><span class="p">,</span> </span><span id="Join-309"><a href="#Join-309"><span class="linenos">309</span></a> <span class="s2">"source_key"</span><span class="p">:</span> <span class="n">source_key</span><span class="p">,</span> @@ -1363,7 +1363,7 @@ Projections:</li> </span><span id="Join.from_joins-303"><a href="#Join.from_joins-303"><span class="linenos">303</span></a> </span><span id="Join.from_joins-304"><a href="#Join.from_joins-304"><span class="linenos">304</span></a> <span class="k">for</span> <span class="n">join</span> <span class="ow">in</span> <span class="n">joins</span><span class="p">:</span> </span><span id="Join.from_joins-305"><a href="#Join.from_joins-305"><span class="linenos">305</span></a> <span class="n">source_key</span><span class="p">,</span> <span class="n">join_key</span><span class="p">,</span> <span class="n">condition</span> <span class="o">=</span> <span class="n">join_condition</span><span class="p">(</span><span class="n">join</span><span class="p">)</span> -</span><span id="Join.from_joins-306"><a href="#Join.from_joins-306"><span class="linenos">306</span></a> <span class="n">step</span><span class="o">.</span><span class="n">joins</span><span class="p">[</span><span class="n">join</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Join.from_joins-306"><a href="#Join.from_joins-306"><span class="linenos">306</span></a> <span class="n">step</span><span class="o">.</span><span class="n">joins</span><span class="p">[</span><span class="n">join</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> </span><span id="Join.from_joins-307"><a href="#Join.from_joins-307"><span class="linenos">307</span></a> <span class="s2">"side"</span><span class="p">:</span> <span class="n">join</span><span class="o">.</span><span class="n">side</span><span class="p">,</span> <span class="c1"># type: ignore</span> </span><span id="Join.from_joins-308"><a href="#Join.from_joins-308"><span class="linenos">308</span></a> <span class="s2">"join_key"</span><span class="p">:</span> <span class="n">join_key</span><span class="p">,</span> </span><span id="Join.from_joins-309"><a href="#Join.from_joins-309"><span class="linenos">309</span></a> <span class="s2">"source_key"</span><span class="p">:</span> <span class="n">source_key</span><span class="p">,</span> diff --git a/docs/sqlglot/schema.html b/docs/sqlglot/schema.html index d3a0fbe..7f71946 100644 --- a/docs/sqlglot/schema.html +++ b/docs/sqlglot/schema.html @@ -139,7 +139,7 @@ </span><span id="L-6"><a href="#L-6"><span class="linenos"> 6</span></a><span class="kn">import</span> <span class="nn">sqlglot</span> </span><span id="L-7"><a href="#L-7"><span class="linenos"> 7</span></a><span class="kn">from</span> <span class="nn">sqlglot</span> <span class="kn">import</span> <span class="n">expressions</span> <span class="k">as</span> <span class="n">exp</span> </span><span id="L-8"><a href="#L-8"><span class="linenos"> 8</span></a><span class="kn">from</span> <span class="nn">sqlglot._typing</span> <span class="kn">import</span> <span class="n">T</span> -</span><span id="L-9"><a href="#L-9"><span class="linenos"> 9</span></a><span class="kn">from</span> <span class="nn">sqlglot.dialects.dialect</span> <span class="kn">import</span> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> +</span><span id="L-9"><a href="#L-9"><span class="linenos"> 9</span></a><span class="kn">from</span> <span class="nn">sqlglot.dialects.dialect</span> <span class="kn">import</span> <span class="n">Dialect</span> </span><span id="L-10"><a href="#L-10"><span class="linenos"> 10</span></a><span class="kn">from</span> <span class="nn">sqlglot.errors</span> <span class="kn">import</span> <span class="n">ParseError</span><span class="p">,</span> <span class="n">SchemaError</span> </span><span id="L-11"><a href="#L-11"><span class="linenos"> 11</span></a><span class="kn">from</span> <span class="nn">sqlglot.helper</span> <span class="kn">import</span> <span class="n">dict_depth</span> </span><span id="L-12"><a href="#L-12"><span class="linenos"> 12</span></a><span class="kn">from</span> <span class="nn">sqlglot.trie</span> <span class="kn">import</span> <span class="n">in_trie</span><span class="p">,</span> <span class="n">new_trie</span> @@ -422,7 +422,7 @@ </span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a> </span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a> <span class="k">def</span> <span class="nf">_normalize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">:</span> </span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a><span class="sd"> Converts all identifiers in the schema into lowercase, unless they're quoted.</span> +</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a><span class="sd"> Normalizes all identifiers in the schema.</span> </span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a> </span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a><span class="sd"> Args:</span> </span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a><span class="sd"> schema: the schema to normalize.</span> @@ -437,177 +437,183 @@ </span><span id="L-304"><a href="#L-304"><span class="linenos">304</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">nested_get</span><span class="p">(</span><span class="n">schema</span><span class="p">,</span> <span class="o">*</span><span class="nb">zip</span><span class="p">(</span><span class="n">keys</span><span class="p">,</span> <span class="n">keys</span><span class="p">))</span> </span><span id="L-305"><a href="#L-305"><span class="linenos">305</span></a> <span class="k">assert</span> <span class="n">columns</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> </span><span id="L-306"><a href="#L-306"><span class="linenos">306</span></a> -</span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a> <span class="n">normalized_keys</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_normalize_name</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="p">)</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">]</span> -</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a> <span class="k">for</span> <span class="n">column_name</span><span class="p">,</span> <span class="n">column_type</span> <span class="ow">in</span> <span class="n">columns</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> -</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a> <span class="n">nested_set</span><span class="p">(</span> -</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="n">normalized_mapping</span><span class="p">,</span> -</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a> <span class="n">normalized_keys</span> <span class="o">+</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_normalize_name</span><span class="p">(</span><span class="n">column_name</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="p">)],</span> -</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> <span class="n">column_type</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><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> <span class="k">return</span> <span class="n">normalized_mapping</span> +</span><span id="L-307"><a href="#L-307"><span class="linenos">307</span></a> <span class="n">normalized_keys</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="L-308"><a href="#L-308"><span class="linenos">308</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_normalize_name</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="p">,</span> <span class="n">is_table</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span> +</span><span id="L-309"><a href="#L-309"><span class="linenos">309</span></a> <span class="p">]</span> +</span><span id="L-310"><a href="#L-310"><span class="linenos">310</span></a> <span class="k">for</span> <span class="n">column_name</span><span class="p">,</span> <span class="n">column_type</span> <span class="ow">in</span> <span class="n">columns</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> +</span><span id="L-311"><a href="#L-311"><span class="linenos">311</span></a> <span class="n">nested_set</span><span class="p">(</span> +</span><span id="L-312"><a href="#L-312"><span class="linenos">312</span></a> <span class="n">normalized_mapping</span><span class="p">,</span> +</span><span id="L-313"><a href="#L-313"><span class="linenos">313</span></a> <span class="n">normalized_keys</span> <span class="o">+</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_normalize_name</span><span class="p">(</span><span class="n">column_name</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="p">)],</span> +</span><span id="L-314"><a href="#L-314"><span class="linenos">314</span></a> <span class="n">column_type</span><span class="p">,</span> +</span><span id="L-315"><a href="#L-315"><span class="linenos">315</span></a> <span class="p">)</span> </span><span id="L-316"><a href="#L-316"><span class="linenos">316</span></a> -</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="k">def</span> <span class="nf">_normalize_table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">table</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> -</span><span id="L-318"><a href="#L-318"><span class="linenos">318</span></a> <span class="n">normalized_table</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="L-319"><a href="#L-319"><span class="linenos">319</span></a> -</span><span id="L-320"><a href="#L-320"><span class="linenos">320</span></a> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">TABLE_ARGS</span><span class="p">:</span> -</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a> <span class="n">value</span> <span class="o">=</span> <span class="n">normalized_table</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> -</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)):</span> -</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="n">normalized_table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a> <span class="n">arg</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_normalize_name</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">))</span> -</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a> <span class="p">)</span> -</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> -</span><span id="L-327"><a href="#L-327"><span class="linenos">327</span></a> <span class="k">return</span> <span class="n">normalized_table</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="k">def</span> <span class="nf">_normalize_name</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-330"><a href="#L-330"><span class="linenos">330</span></a> <span class="n">dialect</span> <span class="o">=</span> <span class="n">dialect</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span> +</span><span id="L-317"><a href="#L-317"><span class="linenos">317</span></a> <span class="k">return</span> <span class="n">normalized_mapping</span> +</span><span id="L-318"><a href="#L-318"><span class="linenos">318</span></a> +</span><span id="L-319"><a href="#L-319"><span class="linenos">319</span></a> <span class="k">def</span> <span class="nf">_normalize_table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">table</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> +</span><span id="L-320"><a href="#L-320"><span class="linenos">320</span></a> <span class="n">normalized_table</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="L-321"><a href="#L-321"><span class="linenos">321</span></a> +</span><span id="L-322"><a href="#L-322"><span class="linenos">322</span></a> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">TABLE_ARGS</span><span class="p">:</span> +</span><span id="L-323"><a href="#L-323"><span class="linenos">323</span></a> <span class="n">value</span> <span class="o">=</span> <span class="n">normalized_table</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> +</span><span id="L-324"><a href="#L-324"><span class="linenos">324</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)):</span> +</span><span id="L-325"><a href="#L-325"><span class="linenos">325</span></a> <span class="n">normalized_table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="L-326"><a href="#L-326"><span class="linenos">326</span></a> <span class="n">arg</span><span class="p">,</span> +</span><span id="L-327"><a href="#L-327"><span class="linenos">327</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_normalize_name</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">is_table</span><span class="o">=</span><span class="kc">True</span><span class="p">)),</span> +</span><span id="L-328"><a href="#L-328"><span class="linenos">328</span></a> <span class="p">)</span> +</span><span id="L-329"><a href="#L-329"><span class="linenos">329</span></a> +</span><span id="L-330"><a href="#L-330"><span class="linenos">330</span></a> <span class="k">return</span> <span class="n">normalized_table</span> </span><span id="L-331"><a href="#L-331"><span class="linenos">331</span></a> -</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="L-333"><a href="#L-333"><span class="linenos">333</span></a> <span class="n">identifier</span> <span class="o">=</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> -</span><span id="L-334"><a href="#L-334"><span class="linenos">334</span></a> <span class="k">except</span> <span class="n">ParseError</span><span class="p">:</span> -</span><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a> <span class="k">return</span> <span class="n">name</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="nb">str</span><span class="p">)</span> <span class="k">else</span> <span class="n">name</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-332"><a href="#L-332"><span class="linenos">332</span></a> <span class="k">def</span> <span class="nf">_normalize_name</span><span class="p">(</span> +</span><span id="L-333"><a href="#L-333"><span class="linenos">333</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">is_table</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-334"><a href="#L-334"><span class="linenos">334</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-335"><a href="#L-335"><span class="linenos">335</span></a> <span class="n">dialect</span> <span class="o">=</span> <span class="n">dialect</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span> </span><span id="L-336"><a href="#L-336"><span class="linenos">336</span></a> -</span><span id="L-337"><a href="#L-337"><span class="linenos">337</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">identifier</span><span class="o">.</span><span class="n">name</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="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="ow">or</span> <span class="n">identifier</span><span class="o">.</span><span class="n">quoted</span><span class="p">:</span> -</span><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a> <span class="k">return</span> <span class="n">name</span> +</span><span id="L-337"><a href="#L-337"><span class="linenos">337</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="L-338"><a href="#L-338"><span class="linenos">338</span></a> <span class="n">identifier</span> <span class="o">=</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> +</span><span id="L-339"><a href="#L-339"><span class="linenos">339</span></a> <span class="k">except</span> <span class="n">ParseError</span><span class="p">:</span> +</span><span id="L-340"><a href="#L-340"><span class="linenos">340</span></a> <span class="k">return</span> <span class="n">name</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="nb">str</span><span class="p">)</span> <span class="k">else</span> <span class="n">name</span><span class="o">.</span><span class="n">name</span> </span><span id="L-341"><a href="#L-341"><span class="linenos">341</span></a> -</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="k">if</span> <span class="n">dialect</span> <span class="ow">in</span> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="k">else</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a> -</span><span id="L-344"><a href="#L-344"><span class="linenos">344</span></a> <span class="k">def</span> <span class="nf">_depth</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> -</span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> <span class="c1"># The columns themselves are a mapping, but we don't want to include those</span> -</span><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_depth</span><span class="p">()</span> <span class="o">-</span> <span class="mi">1</span> -</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> -</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="k">def</span> <span class="nf">_ensure_table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">table</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span> <span class="o">|</span> <span class="nb">str</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> -</span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="p">)</span> -</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> -</span><span id="L-351"><a href="#L-351"><span class="linenos">351</span></a> <span class="k">def</span> <span class="nf">_to_data_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema_type</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">:</span> -</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-353"><a href="#L-353"><span class="linenos">353</span></a><span class="sd"> Convert a type represented as a string to the corresponding `sqlglot.exp.DataType` object.</span> -</span><span id="L-354"><a href="#L-354"><span class="linenos">354</span></a> -</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a><span class="sd"> Args:</span> -</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a><span class="sd"> schema_type: the type we want to convert.</span> -</span><span id="L-357"><a href="#L-357"><span class="linenos">357</span></a><span class="sd"> dialect: the SQL dialect that will be used to parse `schema_type`, if needed.</span> -</span><span id="L-358"><a href="#L-358"><span class="linenos">358</span></a> -</span><span id="L-359"><a href="#L-359"><span class="linenos">359</span></a><span class="sd"> Returns:</span> -</span><span id="L-360"><a href="#L-360"><span class="linenos">360</span></a><span class="sd"> The resulting expression type.</span> -</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a><span class="sd"> """</span> -</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a> <span class="k">if</span> <span class="n">schema_type</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_type_mapping_cache</span><span class="p">:</span> -</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a> <span class="n">dialect</span> <span class="o">=</span> <span class="n">dialect</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span> +</span><span id="L-342"><a href="#L-342"><span class="linenos">342</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">identifier</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-343"><a href="#L-343"><span class="linenos">343</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span><span class="p">:</span> +</span><span id="L-344"><a href="#L-344"><span class="linenos">344</span></a> <span class="k">return</span> <span class="n">name</span> +</span><span id="L-345"><a href="#L-345"><span class="linenos">345</span></a> +</span><span id="L-346"><a href="#L-346"><span class="linenos">346</span></a> <span class="c1"># This can be useful for normalize_identifier</span> +</span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> <span class="n">identifier</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s2">"is_table"</span><span class="p">]</span> <span class="o">=</span> <span class="n">is_table</span> +</span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="k">return</span> <span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span><span class="o">.</span><span class="n">normalize_identifier</span><span class="p">(</span><span class="n">identifier</span><span class="p">)</span><span class="o">.</span><span class="n">name</span> +</span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> +</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> <span class="k">def</span> <span class="nf">_depth</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> +</span><span id="L-351"><a href="#L-351"><span class="linenos">351</span></a> <span class="c1"># The columns themselves are a mapping, but we don't want to include those</span> +</span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_depth</span><span class="p">()</span> <span class="o">-</span> <span class="mi">1</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">_ensure_table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">table</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span> <span class="o">|</span> <span class="nb">str</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> +</span><span id="L-355"><a href="#L-355"><span class="linenos">355</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="p">)</span> +</span><span id="L-356"><a href="#L-356"><span class="linenos">356</span></a> +</span><span id="L-357"><a href="#L-357"><span class="linenos">357</span></a> <span class="k">def</span> <span class="nf">_to_data_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema_type</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">:</span> +</span><span id="L-358"><a href="#L-358"><span class="linenos">358</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-359"><a href="#L-359"><span class="linenos">359</span></a><span class="sd"> Convert a type represented as a string to the corresponding `sqlglot.exp.DataType` object.</span> +</span><span id="L-360"><a href="#L-360"><span class="linenos">360</span></a> +</span><span id="L-361"><a href="#L-361"><span class="linenos">361</span></a><span class="sd"> Args:</span> +</span><span id="L-362"><a href="#L-362"><span class="linenos">362</span></a><span class="sd"> schema_type: the type we want to convert.</span> +</span><span id="L-363"><a href="#L-363"><span class="linenos">363</span></a><span class="sd"> dialect: the SQL dialect that will be used to parse `schema_type`, if needed.</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">try</span><span class="p">:</span> -</span><span id="L-366"><a href="#L-366"><span class="linenos">366</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="n">schema_type</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> -</span><span id="L-367"><a href="#L-367"><span class="linenos">367</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_type_mapping_cache</span><span class="p">[</span><span class="n">schema_type</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression</span> -</span><span id="L-368"><a href="#L-368"><span class="linenos">368</span></a> <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span> -</span><span id="L-369"><a href="#L-369"><span class="linenos">369</span></a> <span class="n">in_dialect</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" in dialect </span><span class="si">{</span><span class="n">dialect</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">dialect</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-370"><a href="#L-370"><span class="linenos">370</span></a> <span class="k">raise</span> <span class="n">SchemaError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Failed to build type '</span><span class="si">{</span><span class="n">schema_type</span><span class="si">}</span><span class="s2">'</span><span class="si">{</span><span class="n">in_dialect</span><span class="si">}</span><span class="s2">."</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="bp">self</span><span class="o">.</span><span class="n">_type_mapping_cache</span><span class="p">[</span><span class="n">schema_type</span><span class="p">]</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><span id="L-375"><a href="#L-375"><span class="linenos">375</span></a><span class="k">def</span> <span class="nf">ensure_schema</span><span class="p">(</span><span class="n">schema</span><span class="p">:</span> <span class="n">Schema</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">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">Schema</span><span class="p">:</span> -</span><span id="L-376"><a href="#L-376"><span class="linenos">376</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">schema</span><span class="p">,</span> <span class="n">Schema</span><span class="p">):</span> -</span><span id="L-377"><a href="#L-377"><span class="linenos">377</span></a> <span class="k">return</span> <span class="n">schema</span> -</span><span id="L-378"><a href="#L-378"><span class="linenos">378</span></a> -</span><span id="L-379"><a href="#L-379"><span class="linenos">379</span></a> <span class="k">return</span> <span class="n">MappingSchema</span><span class="p">(</span><span class="n">schema</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> +</span><span id="L-365"><a href="#L-365"><span class="linenos">365</span></a><span class="sd"> Returns:</span> +</span><span id="L-366"><a href="#L-366"><span class="linenos">366</span></a><span class="sd"> The resulting expression type.</span> +</span><span id="L-367"><a href="#L-367"><span class="linenos">367</span></a><span class="sd"> """</span> +</span><span id="L-368"><a href="#L-368"><span class="linenos">368</span></a> <span class="k">if</span> <span class="n">schema_type</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_type_mapping_cache</span><span class="p">:</span> +</span><span id="L-369"><a href="#L-369"><span class="linenos">369</span></a> <span class="n">dialect</span> <span class="o">=</span> <span class="n">dialect</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</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">try</span><span class="p">:</span> +</span><span id="L-372"><a href="#L-372"><span class="linenos">372</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="n">schema_type</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> +</span><span id="L-373"><a href="#L-373"><span class="linenos">373</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_type_mapping_cache</span><span class="p">[</span><span class="n">schema_type</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression</span> +</span><span id="L-374"><a href="#L-374"><span class="linenos">374</span></a> <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span> +</span><span id="L-375"><a href="#L-375"><span class="linenos">375</span></a> <span class="n">in_dialect</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" in dialect </span><span class="si">{</span><span class="n">dialect</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">dialect</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-376"><a href="#L-376"><span class="linenos">376</span></a> <span class="k">raise</span> <span class="n">SchemaError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Failed to build type '</span><span class="si">{</span><span class="n">schema_type</span><span class="si">}</span><span class="s2">'</span><span class="si">{</span><span class="n">in_dialect</span><span class="si">}</span><span class="s2">."</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="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_type_mapping_cache</span><span class="p">[</span><span class="n">schema_type</span><span class="p">]</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><span id="L-381"><a href="#L-381"><span class="linenos">381</span></a> -</span><span id="L-382"><a href="#L-382"><span class="linenos">382</span></a><span class="k">def</span> <span class="nf">ensure_column_mapping</span><span class="p">(</span><span class="n">mapping</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">ColumnMapping</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">:</span> -</span><span id="L-383"><a href="#L-383"><span class="linenos">383</span></a> <span class="k">if</span> <span class="n">mapping</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-384"><a href="#L-384"><span class="linenos">384</span></a> <span class="k">return</span> <span class="p">{}</span> -</span><span id="L-385"><a href="#L-385"><span class="linenos">385</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">mapping</span><span class="p">,</span> <span class="nb">dict</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="n">mapping</span> -</span><span id="L-387"><a href="#L-387"><span class="linenos">387</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">mapping</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="L-388"><a href="#L-388"><span class="linenos">388</span></a> <span class="n">col_name_type_strs</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">mapping</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">)]</span> -</span><span id="L-389"><a href="#L-389"><span class="linenos">389</span></a> <span class="k">return</span> <span class="p">{</span> -</span><span id="L-390"><a href="#L-390"><span class="linenos">390</span></a> <span class="n">name_type_str</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">":"</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">():</span> <span class="n">name_type_str</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">":"</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="L-391"><a href="#L-391"><span class="linenos">391</span></a> <span class="k">for</span> <span class="n">name_type_str</span> <span class="ow">in</span> <span class="n">col_name_type_strs</span> -</span><span id="L-392"><a href="#L-392"><span class="linenos">392</span></a> <span class="p">}</span> -</span><span id="L-393"><a href="#L-393"><span class="linenos">393</span></a> <span class="c1"># Check if mapping looks like a DataFrame StructType</span> -</span><span id="L-394"><a href="#L-394"><span class="linenos">394</span></a> <span class="k">elif</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">mapping</span><span class="p">,</span> <span class="s2">"simpleString"</span><span class="p">):</span> -</span><span id="L-395"><a href="#L-395"><span class="linenos">395</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">struct_field</span><span class="o">.</span><span class="n">name</span><span class="p">:</span> <span class="n">struct_field</span><span class="o">.</span><span class="n">dataType</span><span class="o">.</span><span class="n">simpleString</span><span class="p">()</span> <span class="k">for</span> <span class="n">struct_field</span> <span class="ow">in</span> <span class="n">mapping</span><span class="p">}</span> -</span><span id="L-396"><a href="#L-396"><span class="linenos">396</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">mapping</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="L-397"><a href="#L-397"><span class="linenos">397</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">x</span><span class="o">.</span><span class="n">strip</span><span class="p">():</span> <span class="kc">None</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">mapping</span><span class="p">}</span> -</span><span id="L-398"><a href="#L-398"><span class="linenos">398</span></a> -</span><span id="L-399"><a href="#L-399"><span class="linenos">399</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid mapping provided: </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">mapping</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-400"><a href="#L-400"><span class="linenos">400</span></a> -</span><span id="L-401"><a href="#L-401"><span class="linenos">401</span></a> -</span><span id="L-402"><a href="#L-402"><span class="linenos">402</span></a><span class="k">def</span> <span class="nf">flatten_schema</span><span class="p">(</span> -</span><span id="L-403"><a href="#L-403"><span class="linenos">403</span></a> <span class="n">schema</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">,</span> <span class="n">depth</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> <span class="n">keys</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-404"><a href="#L-404"><span class="linenos">404</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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-405"><a href="#L-405"><span class="linenos">405</span></a> <span class="n">tables</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-406"><a href="#L-406"><span class="linenos">406</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">keys</span> <span class="ow">or</span> <span class="p">[]</span> +</span><span id="L-381"><a href="#L-381"><span class="linenos">381</span></a><span class="k">def</span> <span class="nf">ensure_schema</span><span class="p">(</span><span class="n">schema</span><span class="p">:</span> <span class="n">Schema</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">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">Schema</span><span class="p">:</span> +</span><span id="L-382"><a href="#L-382"><span class="linenos">382</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">schema</span><span class="p">,</span> <span class="n">Schema</span><span class="p">):</span> +</span><span id="L-383"><a href="#L-383"><span class="linenos">383</span></a> <span class="k">return</span> <span class="n">schema</span> +</span><span id="L-384"><a href="#L-384"><span class="linenos">384</span></a> +</span><span id="L-385"><a href="#L-385"><span class="linenos">385</span></a> <span class="k">return</span> <span class="n">MappingSchema</span><span class="p">(</span><span class="n">schema</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</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><span id="L-388"><a href="#L-388"><span class="linenos">388</span></a><span class="k">def</span> <span class="nf">ensure_column_mapping</span><span class="p">(</span><span class="n">mapping</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">ColumnMapping</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">:</span> +</span><span id="L-389"><a href="#L-389"><span class="linenos">389</span></a> <span class="k">if</span> <span class="n">mapping</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-390"><a href="#L-390"><span class="linenos">390</span></a> <span class="k">return</span> <span class="p">{}</span> +</span><span id="L-391"><a href="#L-391"><span class="linenos">391</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">mapping</span><span class="p">,</span> <span class="nb">dict</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="n">mapping</span> +</span><span id="L-393"><a href="#L-393"><span class="linenos">393</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">mapping</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="L-394"><a href="#L-394"><span class="linenos">394</span></a> <span class="n">col_name_type_strs</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">mapping</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">)]</span> +</span><span id="L-395"><a href="#L-395"><span class="linenos">395</span></a> <span class="k">return</span> <span class="p">{</span> +</span><span id="L-396"><a href="#L-396"><span class="linenos">396</span></a> <span class="n">name_type_str</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">":"</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">():</span> <span class="n">name_type_str</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">":"</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="L-397"><a href="#L-397"><span class="linenos">397</span></a> <span class="k">for</span> <span class="n">name_type_str</span> <span class="ow">in</span> <span class="n">col_name_type_strs</span> +</span><span id="L-398"><a href="#L-398"><span class="linenos">398</span></a> <span class="p">}</span> +</span><span id="L-399"><a href="#L-399"><span class="linenos">399</span></a> <span class="c1"># Check if mapping looks like a DataFrame StructType</span> +</span><span id="L-400"><a href="#L-400"><span class="linenos">400</span></a> <span class="k">elif</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">mapping</span><span class="p">,</span> <span class="s2">"simpleString"</span><span class="p">):</span> +</span><span id="L-401"><a href="#L-401"><span class="linenos">401</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">struct_field</span><span class="o">.</span><span class="n">name</span><span class="p">:</span> <span class="n">struct_field</span><span class="o">.</span><span class="n">dataType</span><span class="o">.</span><span class="n">simpleString</span><span class="p">()</span> <span class="k">for</span> <span class="n">struct_field</span> <span class="ow">in</span> <span class="n">mapping</span><span class="p">}</span> +</span><span id="L-402"><a href="#L-402"><span class="linenos">402</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">mapping</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="L-403"><a href="#L-403"><span class="linenos">403</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">x</span><span class="o">.</span><span class="n">strip</span><span class="p">():</span> <span class="kc">None</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">mapping</span><span class="p">}</span> +</span><span id="L-404"><a href="#L-404"><span class="linenos">404</span></a> +</span><span id="L-405"><a href="#L-405"><span class="linenos">405</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid mapping provided: </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">mapping</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-406"><a href="#L-406"><span class="linenos">406</span></a> </span><span id="L-407"><a href="#L-407"><span class="linenos">407</span></a> -</span><span id="L-408"><a href="#L-408"><span class="linenos">408</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">schema</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> -</span><span id="L-409"><a href="#L-409"><span class="linenos">409</span></a> <span class="k">if</span> <span class="n">depth</span> <span class="o">>=</span> <span class="mi">2</span><span class="p">:</span> -</span><span id="L-410"><a href="#L-410"><span class="linenos">410</span></a> <span class="n">tables</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">flatten_schema</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">depth</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">keys</span> <span class="o">+</span> <span class="p">[</span><span class="n">k</span><span class="p">]))</span> -</span><span id="L-411"><a href="#L-411"><span class="linenos">411</span></a> <span class="k">elif</span> <span class="n">depth</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-412"><a href="#L-412"><span class="linenos">412</span></a> <span class="n">tables</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">keys</span> <span class="o">+</span> <span class="p">[</span><span class="n">k</span><span class="p">])</span> +</span><span id="L-408"><a href="#L-408"><span class="linenos">408</span></a><span class="k">def</span> <span class="nf">flatten_schema</span><span class="p">(</span> +</span><span id="L-409"><a href="#L-409"><span class="linenos">409</span></a> <span class="n">schema</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">,</span> <span class="n">depth</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> <span class="n">keys</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-410"><a href="#L-410"><span class="linenos">410</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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-411"><a href="#L-411"><span class="linenos">411</span></a> <span class="n">tables</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-412"><a href="#L-412"><span class="linenos">412</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">keys</span> <span class="ow">or</span> <span class="p">[]</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="k">return</span> <span class="n">tables</span> -</span><span id="L-415"><a href="#L-415"><span class="linenos">415</span></a> -</span><span id="L-416"><a href="#L-416"><span class="linenos">416</span></a> -</span><span id="L-417"><a href="#L-417"><span class="linenos">417</span></a><span class="k">def</span> <span class="nf">nested_get</span><span class="p">(</span> -</span><span id="L-418"><a href="#L-418"><span class="linenos">418</span></a> <span class="n">d</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">,</span> <span class="o">*</span><span class="n">path</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="n">raise_on_missing</span><span class="p">:</span> <span class="nb">bool</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 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">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]:</span> -</span><span id="L-420"><a href="#L-420"><span class="linenos">420</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-421"><a href="#L-421"><span class="linenos">421</span></a><span class="sd"> Get a value for a nested dictionary.</span> +</span><span id="L-414"><a href="#L-414"><span class="linenos">414</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">schema</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> +</span><span id="L-415"><a href="#L-415"><span class="linenos">415</span></a> <span class="k">if</span> <span class="n">depth</span> <span class="o">>=</span> <span class="mi">2</span><span class="p">:</span> +</span><span id="L-416"><a href="#L-416"><span class="linenos">416</span></a> <span class="n">tables</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">flatten_schema</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">depth</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">keys</span> <span class="o">+</span> <span class="p">[</span><span class="n">k</span><span class="p">]))</span> +</span><span id="L-417"><a href="#L-417"><span class="linenos">417</span></a> <span class="k">elif</span> <span class="n">depth</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-418"><a href="#L-418"><span class="linenos">418</span></a> <span class="n">tables</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">keys</span> <span class="o">+</span> <span class="p">[</span><span class="n">k</span><span class="p">])</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="k">return</span> <span class="n">tables</span> +</span><span id="L-421"><a href="#L-421"><span class="linenos">421</span></a> </span><span id="L-422"><a href="#L-422"><span class="linenos">422</span></a> -</span><span id="L-423"><a href="#L-423"><span class="linenos">423</span></a><span class="sd"> Args:</span> -</span><span id="L-424"><a href="#L-424"><span class="linenos">424</span></a><span class="sd"> d: the dictionary to search.</span> -</span><span id="L-425"><a href="#L-425"><span class="linenos">425</span></a><span class="sd"> *path: tuples of (name, key), where:</span> -</span><span id="L-426"><a href="#L-426"><span class="linenos">426</span></a><span class="sd"> `key` is the key in the dictionary to get.</span> -</span><span id="L-427"><a href="#L-427"><span class="linenos">427</span></a><span class="sd"> `name` is a string to use in the error if `key` isn't found.</span> +</span><span id="L-423"><a href="#L-423"><span class="linenos">423</span></a><span class="k">def</span> <span class="nf">nested_get</span><span class="p">(</span> +</span><span id="L-424"><a href="#L-424"><span class="linenos">424</span></a> <span class="n">d</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">,</span> <span class="o">*</span><span class="n">path</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="n">raise_on_missing</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-425"><a href="#L-425"><span class="linenos">425</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">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]:</span> +</span><span id="L-426"><a href="#L-426"><span class="linenos">426</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-427"><a href="#L-427"><span class="linenos">427</span></a><span class="sd"> Get a value for a nested dictionary.</span> </span><span id="L-428"><a href="#L-428"><span class="linenos">428</span></a> -</span><span id="L-429"><a href="#L-429"><span class="linenos">429</span></a><span class="sd"> Returns:</span> -</span><span id="L-430"><a href="#L-430"><span class="linenos">430</span></a><span class="sd"> The value or None if it doesn't exist.</span> -</span><span id="L-431"><a href="#L-431"><span class="linenos">431</span></a><span class="sd"> """</span> -</span><span id="L-432"><a href="#L-432"><span class="linenos">432</span></a> <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">path</span><span class="p">:</span> -</span><span id="L-433"><a href="#L-433"><span class="linenos">433</span></a> <span class="n">d</span> <span class="o">=</span> <span class="n">d</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="L-434"><a href="#L-434"><span class="linenos">434</span></a> <span class="k">if</span> <span class="n">d</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-435"><a href="#L-435"><span class="linenos">435</span></a> <span class="k">if</span> <span class="n">raise_on_missing</span><span class="p">:</span> -</span><span id="L-436"><a href="#L-436"><span class="linenos">436</span></a> <span class="n">name</span> <span class="o">=</span> <span class="s2">"table"</span> <span class="k">if</span> <span class="n">name</span> <span class="o">==</span> <span class="s2">"this"</span> <span class="k">else</span> <span class="n">name</span> -</span><span id="L-437"><a href="#L-437"><span class="linenos">437</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unknown </span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-438"><a href="#L-438"><span class="linenos">438</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="L-439"><a href="#L-439"><span class="linenos">439</span></a> -</span><span id="L-440"><a href="#L-440"><span class="linenos">440</span></a> <span class="k">return</span> <span class="n">d</span> -</span><span id="L-441"><a href="#L-441"><span class="linenos">441</span></a> -</span><span id="L-442"><a href="#L-442"><span class="linenos">442</span></a> -</span><span id="L-443"><a href="#L-443"><span class="linenos">443</span></a><span class="k">def</span> <span class="nf">nested_set</span><span class="p">(</span><span class="n">d</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">,</span> <span class="n">keys</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">:</span> -</span><span id="L-444"><a href="#L-444"><span class="linenos">444</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="L-445"><a href="#L-445"><span class="linenos">445</span></a><span class="sd"> In-place set a value for a nested dictionary</span> -</span><span id="L-446"><a href="#L-446"><span class="linenos">446</span></a> -</span><span id="L-447"><a href="#L-447"><span class="linenos">447</span></a><span class="sd"> Example:</span> -</span><span id="L-448"><a href="#L-448"><span class="linenos">448</span></a><span class="sd"> >>> nested_set({}, ["top_key", "second_key"], "value")</span> -</span><span id="L-449"><a href="#L-449"><span class="linenos">449</span></a><span class="sd"> {'top_key': {'second_key': 'value'}}</span> -</span><span id="L-450"><a href="#L-450"><span class="linenos">450</span></a> -</span><span id="L-451"><a href="#L-451"><span class="linenos">451</span></a><span class="sd"> >>> nested_set({"top_key": {"third_key": "third_value"}}, ["top_key", "second_key"], "value")</span> -</span><span id="L-452"><a href="#L-452"><span class="linenos">452</span></a><span class="sd"> {'top_key': {'third_key': 'third_value', 'second_key': 'value'}}</span> -</span><span id="L-453"><a href="#L-453"><span class="linenos">453</span></a> -</span><span id="L-454"><a href="#L-454"><span class="linenos">454</span></a><span class="sd"> Args:</span> -</span><span id="L-455"><a href="#L-455"><span class="linenos">455</span></a><span class="sd"> d: dictionary to update.</span> -</span><span id="L-456"><a href="#L-456"><span class="linenos">456</span></a><span class="sd"> keys: the keys that makeup the path to `value`.</span> -</span><span id="L-457"><a href="#L-457"><span class="linenos">457</span></a><span class="sd"> value: the value to set in the dictionary for the given key path.</span> -</span><span id="L-458"><a href="#L-458"><span class="linenos">458</span></a> -</span><span id="L-459"><a href="#L-459"><span class="linenos">459</span></a><span class="sd"> Returns:</span> -</span><span id="L-460"><a href="#L-460"><span class="linenos">460</span></a><span class="sd"> The (possibly) updated dictionary.</span> -</span><span id="L-461"><a href="#L-461"><span class="linenos">461</span></a><span class="sd"> """</span> -</span><span id="L-462"><a href="#L-462"><span class="linenos">462</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">keys</span><span class="p">:</span> -</span><span id="L-463"><a href="#L-463"><span class="linenos">463</span></a> <span class="k">return</span> <span class="n">d</span> +</span><span id="L-429"><a href="#L-429"><span class="linenos">429</span></a><span class="sd"> Args:</span> +</span><span id="L-430"><a href="#L-430"><span class="linenos">430</span></a><span class="sd"> d: the dictionary to search.</span> +</span><span id="L-431"><a href="#L-431"><span class="linenos">431</span></a><span class="sd"> *path: tuples of (name, key), where:</span> +</span><span id="L-432"><a href="#L-432"><span class="linenos">432</span></a><span class="sd"> `key` is the key in the dictionary to get.</span> +</span><span id="L-433"><a href="#L-433"><span class="linenos">433</span></a><span class="sd"> `name` is a string to use in the error if `key` isn't found.</span> +</span><span id="L-434"><a href="#L-434"><span class="linenos">434</span></a> +</span><span id="L-435"><a href="#L-435"><span class="linenos">435</span></a><span class="sd"> Returns:</span> +</span><span id="L-436"><a href="#L-436"><span class="linenos">436</span></a><span class="sd"> The value or None if it doesn't exist.</span> +</span><span id="L-437"><a href="#L-437"><span class="linenos">437</span></a><span class="sd"> """</span> +</span><span id="L-438"><a href="#L-438"><span class="linenos">438</span></a> <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">path</span><span class="p">:</span> +</span><span id="L-439"><a href="#L-439"><span class="linenos">439</span></a> <span class="n">d</span> <span class="o">=</span> <span class="n">d</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="L-440"><a href="#L-440"><span class="linenos">440</span></a> <span class="k">if</span> <span class="n">d</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-441"><a href="#L-441"><span class="linenos">441</span></a> <span class="k">if</span> <span class="n">raise_on_missing</span><span class="p">:</span> +</span><span id="L-442"><a href="#L-442"><span class="linenos">442</span></a> <span class="n">name</span> <span class="o">=</span> <span class="s2">"table"</span> <span class="k">if</span> <span class="n">name</span> <span class="o">==</span> <span class="s2">"this"</span> <span class="k">else</span> <span class="n">name</span> +</span><span id="L-443"><a href="#L-443"><span class="linenos">443</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unknown </span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-444"><a href="#L-444"><span class="linenos">444</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="L-445"><a href="#L-445"><span class="linenos">445</span></a> +</span><span id="L-446"><a href="#L-446"><span class="linenos">446</span></a> <span class="k">return</span> <span class="n">d</span> +</span><span id="L-447"><a href="#L-447"><span class="linenos">447</span></a> +</span><span id="L-448"><a href="#L-448"><span class="linenos">448</span></a> +</span><span id="L-449"><a href="#L-449"><span class="linenos">449</span></a><span class="k">def</span> <span class="nf">nested_set</span><span class="p">(</span><span class="n">d</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">,</span> <span class="n">keys</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">:</span> +</span><span id="L-450"><a href="#L-450"><span class="linenos">450</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="L-451"><a href="#L-451"><span class="linenos">451</span></a><span class="sd"> In-place set a value for a nested dictionary</span> +</span><span id="L-452"><a href="#L-452"><span class="linenos">452</span></a> +</span><span id="L-453"><a href="#L-453"><span class="linenos">453</span></a><span class="sd"> Example:</span> +</span><span id="L-454"><a href="#L-454"><span class="linenos">454</span></a><span class="sd"> >>> nested_set({}, ["top_key", "second_key"], "value")</span> +</span><span id="L-455"><a href="#L-455"><span class="linenos">455</span></a><span class="sd"> {'top_key': {'second_key': 'value'}}</span> +</span><span id="L-456"><a href="#L-456"><span class="linenos">456</span></a> +</span><span id="L-457"><a href="#L-457"><span class="linenos">457</span></a><span class="sd"> >>> nested_set({"top_key": {"third_key": "third_value"}}, ["top_key", "second_key"], "value")</span> +</span><span id="L-458"><a href="#L-458"><span class="linenos">458</span></a><span class="sd"> {'top_key': {'third_key': 'third_value', 'second_key': 'value'}}</span> +</span><span id="L-459"><a href="#L-459"><span class="linenos">459</span></a> +</span><span id="L-460"><a href="#L-460"><span class="linenos">460</span></a><span class="sd"> Args:</span> +</span><span id="L-461"><a href="#L-461"><span class="linenos">461</span></a><span class="sd"> d: dictionary to update.</span> +</span><span id="L-462"><a href="#L-462"><span class="linenos">462</span></a><span class="sd"> keys: the keys that makeup the path to `value`.</span> +</span><span id="L-463"><a href="#L-463"><span class="linenos">463</span></a><span class="sd"> value: the value to set in the dictionary for the given key path.</span> </span><span id="L-464"><a href="#L-464"><span class="linenos">464</span></a> -</span><span id="L-465"><a href="#L-465"><span class="linenos">465</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">keys</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-466"><a href="#L-466"><span class="linenos">466</span></a> <span class="n">d</span><span class="p">[</span><span class="n">keys</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="n">value</span> -</span><span id="L-467"><a href="#L-467"><span class="linenos">467</span></a> <span class="k">return</span> <span class="n">d</span> -</span><span id="L-468"><a href="#L-468"><span class="linenos">468</span></a> -</span><span id="L-469"><a href="#L-469"><span class="linenos">469</span></a> <span class="n">subd</span> <span class="o">=</span> <span class="n">d</span> -</span><span id="L-470"><a href="#L-470"><span class="linenos">470</span></a> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span> -</span><span id="L-471"><a href="#L-471"><span class="linenos">471</span></a> <span class="k">if</span> <span class="n">key</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">subd</span><span class="p">:</span> -</span><span id="L-472"><a href="#L-472"><span class="linenos">472</span></a> <span class="n">subd</span> <span class="o">=</span> <span class="n">subd</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="p">{})</span> -</span><span id="L-473"><a href="#L-473"><span class="linenos">473</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-474"><a href="#L-474"><span class="linenos">474</span></a> <span class="n">subd</span> <span class="o">=</span> <span class="n">subd</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> -</span><span id="L-475"><a href="#L-475"><span class="linenos">475</span></a> -</span><span id="L-476"><a href="#L-476"><span class="linenos">476</span></a> <span class="n">subd</span><span class="p">[</span><span class="n">keys</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">value</span> -</span><span id="L-477"><a href="#L-477"><span class="linenos">477</span></a> <span class="k">return</span> <span class="n">d</span> +</span><span id="L-465"><a href="#L-465"><span class="linenos">465</span></a><span class="sd"> Returns:</span> +</span><span id="L-466"><a href="#L-466"><span class="linenos">466</span></a><span class="sd"> The (possibly) updated dictionary.</span> +</span><span id="L-467"><a href="#L-467"><span class="linenos">467</span></a><span class="sd"> """</span> +</span><span id="L-468"><a href="#L-468"><span class="linenos">468</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">keys</span><span class="p">:</span> +</span><span id="L-469"><a href="#L-469"><span class="linenos">469</span></a> <span class="k">return</span> <span class="n">d</span> +</span><span id="L-470"><a href="#L-470"><span class="linenos">470</span></a> +</span><span id="L-471"><a href="#L-471"><span class="linenos">471</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">keys</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-472"><a href="#L-472"><span class="linenos">472</span></a> <span class="n">d</span><span class="p">[</span><span class="n">keys</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="n">value</span> +</span><span id="L-473"><a href="#L-473"><span class="linenos">473</span></a> <span class="k">return</span> <span class="n">d</span> +</span><span id="L-474"><a href="#L-474"><span class="linenos">474</span></a> +</span><span id="L-475"><a href="#L-475"><span class="linenos">475</span></a> <span class="n">subd</span> <span class="o">=</span> <span class="n">d</span> +</span><span id="L-476"><a href="#L-476"><span class="linenos">476</span></a> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span> +</span><span id="L-477"><a href="#L-477"><span class="linenos">477</span></a> <span class="k">if</span> <span class="n">key</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">subd</span><span class="p">:</span> +</span><span id="L-478"><a href="#L-478"><span class="linenos">478</span></a> <span class="n">subd</span> <span class="o">=</span> <span class="n">subd</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="p">{})</span> +</span><span id="L-479"><a href="#L-479"><span class="linenos">479</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-480"><a href="#L-480"><span class="linenos">480</span></a> <span class="n">subd</span> <span class="o">=</span> <span class="n">subd</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> +</span><span id="L-481"><a href="#L-481"><span class="linenos">481</span></a> +</span><span id="L-482"><a href="#L-482"><span class="linenos">482</span></a> <span class="n">subd</span><span class="p">[</span><span class="n">keys</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">value</span> +</span><span id="L-483"><a href="#L-483"><span class="linenos">483</span></a> <span class="k">return</span> <span class="n">d</span> </span></pre></div> @@ -1225,7 +1231,7 @@ For example, a generic mapping type might be defined as::</p> </span><span id="MappingSchema-290"><a href="#MappingSchema-290"><span class="linenos">290</span></a> </span><span id="MappingSchema-291"><a href="#MappingSchema-291"><span class="linenos">291</span></a> <span class="k">def</span> <span class="nf">_normalize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">:</span> </span><span id="MappingSchema-292"><a href="#MappingSchema-292"><span class="linenos">292</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="MappingSchema-293"><a href="#MappingSchema-293"><span class="linenos">293</span></a><span class="sd"> Converts all identifiers in the schema into lowercase, unless they're quoted.</span> +</span><span id="MappingSchema-293"><a href="#MappingSchema-293"><span class="linenos">293</span></a><span class="sd"> Normalizes all identifiers in the schema.</span> </span><span id="MappingSchema-294"><a href="#MappingSchema-294"><span class="linenos">294</span></a> </span><span id="MappingSchema-295"><a href="#MappingSchema-295"><span class="linenos">295</span></a><span class="sd"> Args:</span> </span><span id="MappingSchema-296"><a href="#MappingSchema-296"><span class="linenos">296</span></a><span class="sd"> schema: the schema to normalize.</span> @@ -1240,72 +1246,78 @@ For example, a generic mapping type might be defined as::</p> </span><span id="MappingSchema-305"><a href="#MappingSchema-305"><span class="linenos">305</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="n">nested_get</span><span class="p">(</span><span class="n">schema</span><span class="p">,</span> <span class="o">*</span><span class="nb">zip</span><span class="p">(</span><span class="n">keys</span><span class="p">,</span> <span class="n">keys</span><span class="p">))</span> </span><span id="MappingSchema-306"><a href="#MappingSchema-306"><span class="linenos">306</span></a> <span class="k">assert</span> <span class="n">columns</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> </span><span id="MappingSchema-307"><a href="#MappingSchema-307"><span class="linenos">307</span></a> -</span><span id="MappingSchema-308"><a href="#MappingSchema-308"><span class="linenos">308</span></a> <span class="n">normalized_keys</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_normalize_name</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="p">)</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">]</span> -</span><span id="MappingSchema-309"><a href="#MappingSchema-309"><span class="linenos">309</span></a> <span class="k">for</span> <span class="n">column_name</span><span class="p">,</span> <span class="n">column_type</span> <span class="ow">in</span> <span class="n">columns</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> -</span><span id="MappingSchema-310"><a href="#MappingSchema-310"><span class="linenos">310</span></a> <span class="n">nested_set</span><span class="p">(</span> -</span><span id="MappingSchema-311"><a href="#MappingSchema-311"><span class="linenos">311</span></a> <span class="n">normalized_mapping</span><span class="p">,</span> -</span><span id="MappingSchema-312"><a href="#MappingSchema-312"><span class="linenos">312</span></a> <span class="n">normalized_keys</span> <span class="o">+</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_normalize_name</span><span class="p">(</span><span class="n">column_name</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="p">)],</span> -</span><span id="MappingSchema-313"><a href="#MappingSchema-313"><span class="linenos">313</span></a> <span class="n">column_type</span><span class="p">,</span> -</span><span id="MappingSchema-314"><a href="#MappingSchema-314"><span class="linenos">314</span></a> <span class="p">)</span> -</span><span id="MappingSchema-315"><a href="#MappingSchema-315"><span class="linenos">315</span></a> -</span><span id="MappingSchema-316"><a href="#MappingSchema-316"><span class="linenos">316</span></a> <span class="k">return</span> <span class="n">normalized_mapping</span> +</span><span id="MappingSchema-308"><a href="#MappingSchema-308"><span class="linenos">308</span></a> <span class="n">normalized_keys</span> <span class="o">=</span> <span class="p">[</span> +</span><span id="MappingSchema-309"><a href="#MappingSchema-309"><span class="linenos">309</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_normalize_name</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="p">,</span> <span class="n">is_table</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span> +</span><span id="MappingSchema-310"><a href="#MappingSchema-310"><span class="linenos">310</span></a> <span class="p">]</span> +</span><span id="MappingSchema-311"><a href="#MappingSchema-311"><span class="linenos">311</span></a> <span class="k">for</span> <span class="n">column_name</span><span class="p">,</span> <span class="n">column_type</span> <span class="ow">in</span> <span class="n">columns</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> +</span><span id="MappingSchema-312"><a href="#MappingSchema-312"><span class="linenos">312</span></a> <span class="n">nested_set</span><span class="p">(</span> +</span><span id="MappingSchema-313"><a href="#MappingSchema-313"><span class="linenos">313</span></a> <span class="n">normalized_mapping</span><span class="p">,</span> +</span><span id="MappingSchema-314"><a href="#MappingSchema-314"><span class="linenos">314</span></a> <span class="n">normalized_keys</span> <span class="o">+</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_normalize_name</span><span class="p">(</span><span class="n">column_name</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="p">)],</span> +</span><span id="MappingSchema-315"><a href="#MappingSchema-315"><span class="linenos">315</span></a> <span class="n">column_type</span><span class="p">,</span> +</span><span id="MappingSchema-316"><a href="#MappingSchema-316"><span class="linenos">316</span></a> <span class="p">)</span> </span><span id="MappingSchema-317"><a href="#MappingSchema-317"><span class="linenos">317</span></a> -</span><span id="MappingSchema-318"><a href="#MappingSchema-318"><span class="linenos">318</span></a> <span class="k">def</span> <span class="nf">_normalize_table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">table</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> -</span><span id="MappingSchema-319"><a href="#MappingSchema-319"><span class="linenos">319</span></a> <span class="n">normalized_table</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="MappingSchema-320"><a href="#MappingSchema-320"><span class="linenos">320</span></a> -</span><span id="MappingSchema-321"><a href="#MappingSchema-321"><span class="linenos">321</span></a> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">TABLE_ARGS</span><span class="p">:</span> -</span><span id="MappingSchema-322"><a href="#MappingSchema-322"><span class="linenos">322</span></a> <span class="n">value</span> <span class="o">=</span> <span class="n">normalized_table</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> -</span><span id="MappingSchema-323"><a href="#MappingSchema-323"><span class="linenos">323</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)):</span> -</span><span id="MappingSchema-324"><a href="#MappingSchema-324"><span class="linenos">324</span></a> <span class="n">normalized_table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> -</span><span id="MappingSchema-325"><a href="#MappingSchema-325"><span class="linenos">325</span></a> <span class="n">arg</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_normalize_name</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">))</span> -</span><span id="MappingSchema-326"><a href="#MappingSchema-326"><span class="linenos">326</span></a> <span class="p">)</span> -</span><span id="MappingSchema-327"><a href="#MappingSchema-327"><span class="linenos">327</span></a> -</span><span id="MappingSchema-328"><a href="#MappingSchema-328"><span class="linenos">328</span></a> <span class="k">return</span> <span class="n">normalized_table</span> -</span><span id="MappingSchema-329"><a href="#MappingSchema-329"><span class="linenos">329</span></a> -</span><span id="MappingSchema-330"><a href="#MappingSchema-330"><span class="linenos">330</span></a> <span class="k">def</span> <span class="nf">_normalize_name</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="MappingSchema-331"><a href="#MappingSchema-331"><span class="linenos">331</span></a> <span class="n">dialect</span> <span class="o">=</span> <span class="n">dialect</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span> +</span><span id="MappingSchema-318"><a href="#MappingSchema-318"><span class="linenos">318</span></a> <span class="k">return</span> <span class="n">normalized_mapping</span> +</span><span id="MappingSchema-319"><a href="#MappingSchema-319"><span class="linenos">319</span></a> +</span><span id="MappingSchema-320"><a href="#MappingSchema-320"><span class="linenos">320</span></a> <span class="k">def</span> <span class="nf">_normalize_table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">table</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> +</span><span id="MappingSchema-321"><a href="#MappingSchema-321"><span class="linenos">321</span></a> <span class="n">normalized_table</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="MappingSchema-322"><a href="#MappingSchema-322"><span class="linenos">322</span></a> +</span><span id="MappingSchema-323"><a href="#MappingSchema-323"><span class="linenos">323</span></a> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">TABLE_ARGS</span><span class="p">:</span> +</span><span id="MappingSchema-324"><a href="#MappingSchema-324"><span class="linenos">324</span></a> <span class="n">value</span> <span class="o">=</span> <span class="n">normalized_table</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> +</span><span id="MappingSchema-325"><a href="#MappingSchema-325"><span class="linenos">325</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="p">(</span><span class="nb">str</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)):</span> +</span><span id="MappingSchema-326"><a href="#MappingSchema-326"><span class="linenos">326</span></a> <span class="n">normalized_table</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> +</span><span id="MappingSchema-327"><a href="#MappingSchema-327"><span class="linenos">327</span></a> <span class="n">arg</span><span class="p">,</span> +</span><span id="MappingSchema-328"><a href="#MappingSchema-328"><span class="linenos">328</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">to_identifier</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_normalize_name</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">is_table</span><span class="o">=</span><span class="kc">True</span><span class="p">)),</span> +</span><span id="MappingSchema-329"><a href="#MappingSchema-329"><span class="linenos">329</span></a> <span class="p">)</span> +</span><span id="MappingSchema-330"><a href="#MappingSchema-330"><span class="linenos">330</span></a> +</span><span id="MappingSchema-331"><a href="#MappingSchema-331"><span class="linenos">331</span></a> <span class="k">return</span> <span class="n">normalized_table</span> </span><span id="MappingSchema-332"><a href="#MappingSchema-332"><span class="linenos">332</span></a> -</span><span id="MappingSchema-333"><a href="#MappingSchema-333"><span class="linenos">333</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="MappingSchema-334"><a href="#MappingSchema-334"><span class="linenos">334</span></a> <span class="n">identifier</span> <span class="o">=</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> -</span><span id="MappingSchema-335"><a href="#MappingSchema-335"><span class="linenos">335</span></a> <span class="k">except</span> <span class="n">ParseError</span><span class="p">:</span> -</span><span id="MappingSchema-336"><a href="#MappingSchema-336"><span class="linenos">336</span></a> <span class="k">return</span> <span class="n">name</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="nb">str</span><span class="p">)</span> <span class="k">else</span> <span class="n">name</span><span class="o">.</span><span class="n">name</span> +</span><span id="MappingSchema-333"><a href="#MappingSchema-333"><span class="linenos">333</span></a> <span class="k">def</span> <span class="nf">_normalize_name</span><span class="p">(</span> +</span><span id="MappingSchema-334"><a href="#MappingSchema-334"><span class="linenos">334</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="n">is_table</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="MappingSchema-335"><a href="#MappingSchema-335"><span class="linenos">335</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="MappingSchema-336"><a href="#MappingSchema-336"><span class="linenos">336</span></a> <span class="n">dialect</span> <span class="o">=</span> <span class="n">dialect</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span> </span><span id="MappingSchema-337"><a href="#MappingSchema-337"><span class="linenos">337</span></a> -</span><span id="MappingSchema-338"><a href="#MappingSchema-338"><span class="linenos">338</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">identifier</span><span class="o">.</span><span class="n">name</span> -</span><span id="MappingSchema-339"><a href="#MappingSchema-339"><span class="linenos">339</span></a> -</span><span id="MappingSchema-340"><a href="#MappingSchema-340"><span class="linenos">340</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span> <span class="ow">or</span> <span class="n">identifier</span><span class="o">.</span><span class="n">quoted</span><span class="p">:</span> -</span><span id="MappingSchema-341"><a href="#MappingSchema-341"><span class="linenos">341</span></a> <span class="k">return</span> <span class="n">name</span> +</span><span id="MappingSchema-338"><a href="#MappingSchema-338"><span class="linenos">338</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="MappingSchema-339"><a href="#MappingSchema-339"><span class="linenos">339</span></a> <span class="n">identifier</span> <span class="o">=</span> <span class="n">sqlglot</span><span class="o">.</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Identifier</span><span class="p">)</span> +</span><span id="MappingSchema-340"><a href="#MappingSchema-340"><span class="linenos">340</span></a> <span class="k">except</span> <span class="n">ParseError</span><span class="p">:</span> +</span><span id="MappingSchema-341"><a href="#MappingSchema-341"><span class="linenos">341</span></a> <span class="k">return</span> <span class="n">name</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="nb">str</span><span class="p">)</span> <span class="k">else</span> <span class="n">name</span><span class="o">.</span><span class="n">name</span> </span><span id="MappingSchema-342"><a href="#MappingSchema-342"><span class="linenos">342</span></a> -</span><span id="MappingSchema-343"><a href="#MappingSchema-343"><span class="linenos">343</span></a> <span class="k">return</span> <span class="n">name</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="k">if</span> <span class="n">dialect</span> <span class="ow">in</span> <span class="n">RESOLVES_IDENTIFIERS_AS_UPPERCASE</span> <span class="k">else</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> -</span><span id="MappingSchema-344"><a href="#MappingSchema-344"><span class="linenos">344</span></a> -</span><span id="MappingSchema-345"><a href="#MappingSchema-345"><span class="linenos">345</span></a> <span class="k">def</span> <span class="nf">_depth</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> -</span><span id="MappingSchema-346"><a href="#MappingSchema-346"><span class="linenos">346</span></a> <span class="c1"># The columns themselves are a mapping, but we don't want to include those</span> -</span><span id="MappingSchema-347"><a href="#MappingSchema-347"><span class="linenos">347</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_depth</span><span class="p">()</span> <span class="o">-</span> <span class="mi">1</span> -</span><span id="MappingSchema-348"><a href="#MappingSchema-348"><span class="linenos">348</span></a> -</span><span id="MappingSchema-349"><a href="#MappingSchema-349"><span class="linenos">349</span></a> <span class="k">def</span> <span class="nf">_ensure_table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">table</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span> <span class="o">|</span> <span class="nb">str</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> -</span><span id="MappingSchema-350"><a href="#MappingSchema-350"><span class="linenos">350</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="p">)</span> -</span><span id="MappingSchema-351"><a href="#MappingSchema-351"><span class="linenos">351</span></a> -</span><span id="MappingSchema-352"><a href="#MappingSchema-352"><span class="linenos">352</span></a> <span class="k">def</span> <span class="nf">_to_data_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema_type</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">:</span> -</span><span id="MappingSchema-353"><a href="#MappingSchema-353"><span class="linenos">353</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="MappingSchema-354"><a href="#MappingSchema-354"><span class="linenos">354</span></a><span class="sd"> Convert a type represented as a string to the corresponding `sqlglot.exp.DataType` object.</span> -</span><span id="MappingSchema-355"><a href="#MappingSchema-355"><span class="linenos">355</span></a> -</span><span id="MappingSchema-356"><a href="#MappingSchema-356"><span class="linenos">356</span></a><span class="sd"> Args:</span> -</span><span id="MappingSchema-357"><a href="#MappingSchema-357"><span class="linenos">357</span></a><span class="sd"> schema_type: the type we want to convert.</span> -</span><span id="MappingSchema-358"><a href="#MappingSchema-358"><span class="linenos">358</span></a><span class="sd"> dialect: the SQL dialect that will be used to parse `schema_type`, if needed.</span> -</span><span id="MappingSchema-359"><a href="#MappingSchema-359"><span class="linenos">359</span></a> -</span><span id="MappingSchema-360"><a href="#MappingSchema-360"><span class="linenos">360</span></a><span class="sd"> Returns:</span> -</span><span id="MappingSchema-361"><a href="#MappingSchema-361"><span class="linenos">361</span></a><span class="sd"> The resulting expression type.</span> -</span><span id="MappingSchema-362"><a href="#MappingSchema-362"><span class="linenos">362</span></a><span class="sd"> """</span> -</span><span id="MappingSchema-363"><a href="#MappingSchema-363"><span class="linenos">363</span></a> <span class="k">if</span> <span class="n">schema_type</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_type_mapping_cache</span><span class="p">:</span> -</span><span id="MappingSchema-364"><a href="#MappingSchema-364"><span class="linenos">364</span></a> <span class="n">dialect</span> <span class="o">=</span> <span class="n">dialect</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span> +</span><span id="MappingSchema-343"><a href="#MappingSchema-343"><span class="linenos">343</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">identifier</span><span class="o">.</span><span class="n">name</span> +</span><span id="MappingSchema-344"><a href="#MappingSchema-344"><span class="linenos">344</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize</span><span class="p">:</span> +</span><span id="MappingSchema-345"><a href="#MappingSchema-345"><span class="linenos">345</span></a> <span class="k">return</span> <span class="n">name</span> +</span><span id="MappingSchema-346"><a href="#MappingSchema-346"><span class="linenos">346</span></a> +</span><span id="MappingSchema-347"><a href="#MappingSchema-347"><span class="linenos">347</span></a> <span class="c1"># This can be useful for normalize_identifier</span> +</span><span id="MappingSchema-348"><a href="#MappingSchema-348"><span class="linenos">348</span></a> <span class="n">identifier</span><span class="o">.</span><span class="n">meta</span><span class="p">[</span><span class="s2">"is_table"</span><span class="p">]</span> <span class="o">=</span> <span class="n">is_table</span> +</span><span id="MappingSchema-349"><a href="#MappingSchema-349"><span class="linenos">349</span></a> <span class="k">return</span> <span class="n">Dialect</span><span class="o">.</span><span class="n">get_or_raise</span><span class="p">(</span><span class="n">dialect</span><span class="p">)</span><span class="o">.</span><span class="n">normalize_identifier</span><span class="p">(</span><span class="n">identifier</span><span class="p">)</span><span class="o">.</span><span class="n">name</span> +</span><span id="MappingSchema-350"><a href="#MappingSchema-350"><span class="linenos">350</span></a> +</span><span id="MappingSchema-351"><a href="#MappingSchema-351"><span class="linenos">351</span></a> <span class="k">def</span> <span class="nf">_depth</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> +</span><span id="MappingSchema-352"><a href="#MappingSchema-352"><span class="linenos">352</span></a> <span class="c1"># The columns themselves are a mapping, but we don't want to include those</span> +</span><span id="MappingSchema-353"><a href="#MappingSchema-353"><span class="linenos">353</span></a> <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">_depth</span><span class="p">()</span> <span class="o">-</span> <span class="mi">1</span> +</span><span id="MappingSchema-354"><a href="#MappingSchema-354"><span class="linenos">354</span></a> +</span><span id="MappingSchema-355"><a href="#MappingSchema-355"><span class="linenos">355</span></a> <span class="k">def</span> <span class="nf">_ensure_table</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">table</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span> <span class="o">|</span> <span class="nb">str</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">:</span> +</span><span id="MappingSchema-356"><a href="#MappingSchema-356"><span class="linenos">356</span></a> <span class="k">return</span> <span class="n">exp</span><span class="o">.</span><span class="n">maybe_parse</span><span class="p">(</span><span class="n">table</span><span class="p">,</span> <span class="n">into</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span><span class="p">)</span> +</span><span id="MappingSchema-357"><a href="#MappingSchema-357"><span class="linenos">357</span></a> +</span><span id="MappingSchema-358"><a href="#MappingSchema-358"><span class="linenos">358</span></a> <span class="k">def</span> <span class="nf">_to_data_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema_type</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">dialect</span><span class="p">:</span> <span class="n">DialectType</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">:</span> +</span><span id="MappingSchema-359"><a href="#MappingSchema-359"><span class="linenos">359</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="MappingSchema-360"><a href="#MappingSchema-360"><span class="linenos">360</span></a><span class="sd"> Convert a type represented as a string to the corresponding `sqlglot.exp.DataType` object.</span> +</span><span id="MappingSchema-361"><a href="#MappingSchema-361"><span class="linenos">361</span></a> +</span><span id="MappingSchema-362"><a href="#MappingSchema-362"><span class="linenos">362</span></a><span class="sd"> Args:</span> +</span><span id="MappingSchema-363"><a href="#MappingSchema-363"><span class="linenos">363</span></a><span class="sd"> schema_type: the type we want to convert.</span> +</span><span id="MappingSchema-364"><a href="#MappingSchema-364"><span class="linenos">364</span></a><span class="sd"> dialect: the SQL dialect that will be used to parse `schema_type`, if needed.</span> </span><span id="MappingSchema-365"><a href="#MappingSchema-365"><span class="linenos">365</span></a> -</span><span id="MappingSchema-366"><a href="#MappingSchema-366"><span class="linenos">366</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="MappingSchema-367"><a href="#MappingSchema-367"><span class="linenos">367</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="n">schema_type</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> -</span><span id="MappingSchema-368"><a href="#MappingSchema-368"><span class="linenos">368</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_type_mapping_cache</span><span class="p">[</span><span class="n">schema_type</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression</span> -</span><span id="MappingSchema-369"><a href="#MappingSchema-369"><span class="linenos">369</span></a> <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span> -</span><span id="MappingSchema-370"><a href="#MappingSchema-370"><span class="linenos">370</span></a> <span class="n">in_dialect</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" in dialect </span><span class="si">{</span><span class="n">dialect</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">dialect</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="MappingSchema-371"><a href="#MappingSchema-371"><span class="linenos">371</span></a> <span class="k">raise</span> <span class="n">SchemaError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Failed to build type '</span><span class="si">{</span><span class="n">schema_type</span><span class="si">}</span><span class="s2">'</span><span class="si">{</span><span class="n">in_dialect</span><span class="si">}</span><span class="s2">."</span><span class="p">)</span> -</span><span id="MappingSchema-372"><a href="#MappingSchema-372"><span class="linenos">372</span></a> -</span><span id="MappingSchema-373"><a href="#MappingSchema-373"><span class="linenos">373</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_type_mapping_cache</span><span class="p">[</span><span class="n">schema_type</span><span class="p">]</span> +</span><span id="MappingSchema-366"><a href="#MappingSchema-366"><span class="linenos">366</span></a><span class="sd"> Returns:</span> +</span><span id="MappingSchema-367"><a href="#MappingSchema-367"><span class="linenos">367</span></a><span class="sd"> The resulting expression type.</span> +</span><span id="MappingSchema-368"><a href="#MappingSchema-368"><span class="linenos">368</span></a><span class="sd"> """</span> +</span><span id="MappingSchema-369"><a href="#MappingSchema-369"><span class="linenos">369</span></a> <span class="k">if</span> <span class="n">schema_type</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_type_mapping_cache</span><span class="p">:</span> +</span><span id="MappingSchema-370"><a href="#MappingSchema-370"><span class="linenos">370</span></a> <span class="n">dialect</span> <span class="o">=</span> <span class="n">dialect</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">dialect</span> +</span><span id="MappingSchema-371"><a href="#MappingSchema-371"><span class="linenos">371</span></a> +</span><span id="MappingSchema-372"><a href="#MappingSchema-372"><span class="linenos">372</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="MappingSchema-373"><a href="#MappingSchema-373"><span class="linenos">373</span></a> <span class="n">expression</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">build</span><span class="p">(</span><span class="n">schema_type</span><span class="p">,</span> <span class="n">dialect</span><span class="o">=</span><span class="n">dialect</span><span class="p">)</span> +</span><span id="MappingSchema-374"><a href="#MappingSchema-374"><span class="linenos">374</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_type_mapping_cache</span><span class="p">[</span><span class="n">schema_type</span><span class="p">]</span> <span class="o">=</span> <span class="n">expression</span> +</span><span id="MappingSchema-375"><a href="#MappingSchema-375"><span class="linenos">375</span></a> <span class="k">except</span> <span class="ne">AttributeError</span><span class="p">:</span> +</span><span id="MappingSchema-376"><a href="#MappingSchema-376"><span class="linenos">376</span></a> <span class="n">in_dialect</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" in dialect </span><span class="si">{</span><span class="n">dialect</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">dialect</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="MappingSchema-377"><a href="#MappingSchema-377"><span class="linenos">377</span></a> <span class="k">raise</span> <span class="n">SchemaError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Failed to build type '</span><span class="si">{</span><span class="n">schema_type</span><span class="si">}</span><span class="s2">'</span><span class="si">{</span><span class="n">in_dialect</span><span class="si">}</span><span class="s2">."</span><span class="p">)</span> +</span><span id="MappingSchema-378"><a href="#MappingSchema-378"><span class="linenos">378</span></a> +</span><span id="MappingSchema-379"><a href="#MappingSchema-379"><span class="linenos">379</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_type_mapping_cache</span><span class="p">[</span><span class="n">schema_type</span><span class="p">]</span> </span></pre></div> @@ -1604,11 +1616,11 @@ are assumed to be visible. The nesting should mirror that of the schema: </div> <a class="headerlink" href="#ensure_schema"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ensure_schema-376"><a href="#ensure_schema-376"><span class="linenos">376</span></a><span class="k">def</span> <span class="nf">ensure_schema</span><span class="p">(</span><span class="n">schema</span><span class="p">:</span> <span class="n">Schema</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">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">Schema</span><span class="p">:</span> -</span><span id="ensure_schema-377"><a href="#ensure_schema-377"><span class="linenos">377</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">schema</span><span class="p">,</span> <span class="n">Schema</span><span class="p">):</span> -</span><span id="ensure_schema-378"><a href="#ensure_schema-378"><span class="linenos">378</span></a> <span class="k">return</span> <span class="n">schema</span> -</span><span id="ensure_schema-379"><a href="#ensure_schema-379"><span class="linenos">379</span></a> -</span><span id="ensure_schema-380"><a href="#ensure_schema-380"><span class="linenos">380</span></a> <span class="k">return</span> <span class="n">MappingSchema</span><span class="p">(</span><span class="n">schema</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ensure_schema-382"><a href="#ensure_schema-382"><span class="linenos">382</span></a><span class="k">def</span> <span class="nf">ensure_schema</span><span class="p">(</span><span class="n">schema</span><span class="p">:</span> <span class="n">Schema</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">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">Schema</span><span class="p">:</span> +</span><span id="ensure_schema-383"><a href="#ensure_schema-383"><span class="linenos">383</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">schema</span><span class="p">,</span> <span class="n">Schema</span><span class="p">):</span> +</span><span id="ensure_schema-384"><a href="#ensure_schema-384"><span class="linenos">384</span></a> <span class="k">return</span> <span class="n">schema</span> +</span><span id="ensure_schema-385"><a href="#ensure_schema-385"><span class="linenos">385</span></a> +</span><span id="ensure_schema-386"><a href="#ensure_schema-386"><span class="linenos">386</span></a> <span class="k">return</span> <span class="n">MappingSchema</span><span class="p">(</span><span class="n">schema</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> </span></pre></div> @@ -1626,24 +1638,24 @@ are assumed to be visible. The nesting should mirror that of the schema: </div> <a class="headerlink" href="#ensure_column_mapping"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="ensure_column_mapping-383"><a href="#ensure_column_mapping-383"><span class="linenos">383</span></a><span class="k">def</span> <span class="nf">ensure_column_mapping</span><span class="p">(</span><span class="n">mapping</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">ColumnMapping</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">:</span> -</span><span id="ensure_column_mapping-384"><a href="#ensure_column_mapping-384"><span class="linenos">384</span></a> <span class="k">if</span> <span class="n">mapping</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="ensure_column_mapping-385"><a href="#ensure_column_mapping-385"><span class="linenos">385</span></a> <span class="k">return</span> <span class="p">{}</span> -</span><span id="ensure_column_mapping-386"><a href="#ensure_column_mapping-386"><span class="linenos">386</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">mapping</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span> -</span><span id="ensure_column_mapping-387"><a href="#ensure_column_mapping-387"><span class="linenos">387</span></a> <span class="k">return</span> <span class="n">mapping</span> -</span><span id="ensure_column_mapping-388"><a href="#ensure_column_mapping-388"><span class="linenos">388</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">mapping</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> -</span><span id="ensure_column_mapping-389"><a href="#ensure_column_mapping-389"><span class="linenos">389</span></a> <span class="n">col_name_type_strs</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">mapping</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">)]</span> -</span><span id="ensure_column_mapping-390"><a href="#ensure_column_mapping-390"><span class="linenos">390</span></a> <span class="k">return</span> <span class="p">{</span> -</span><span id="ensure_column_mapping-391"><a href="#ensure_column_mapping-391"><span class="linenos">391</span></a> <span class="n">name_type_str</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">":"</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">():</span> <span class="n">name_type_str</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">":"</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="ensure_column_mapping-392"><a href="#ensure_column_mapping-392"><span class="linenos">392</span></a> <span class="k">for</span> <span class="n">name_type_str</span> <span class="ow">in</span> <span class="n">col_name_type_strs</span> -</span><span id="ensure_column_mapping-393"><a href="#ensure_column_mapping-393"><span class="linenos">393</span></a> <span class="p">}</span> -</span><span id="ensure_column_mapping-394"><a href="#ensure_column_mapping-394"><span class="linenos">394</span></a> <span class="c1"># Check if mapping looks like a DataFrame StructType</span> -</span><span id="ensure_column_mapping-395"><a href="#ensure_column_mapping-395"><span class="linenos">395</span></a> <span class="k">elif</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">mapping</span><span class="p">,</span> <span class="s2">"simpleString"</span><span class="p">):</span> -</span><span id="ensure_column_mapping-396"><a href="#ensure_column_mapping-396"><span class="linenos">396</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">struct_field</span><span class="o">.</span><span class="n">name</span><span class="p">:</span> <span class="n">struct_field</span><span class="o">.</span><span class="n">dataType</span><span class="o">.</span><span class="n">simpleString</span><span class="p">()</span> <span class="k">for</span> <span class="n">struct_field</span> <span class="ow">in</span> <span class="n">mapping</span><span class="p">}</span> -</span><span id="ensure_column_mapping-397"><a href="#ensure_column_mapping-397"><span class="linenos">397</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">mapping</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="ensure_column_mapping-398"><a href="#ensure_column_mapping-398"><span class="linenos">398</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">x</span><span class="o">.</span><span class="n">strip</span><span class="p">():</span> <span class="kc">None</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">mapping</span><span class="p">}</span> -</span><span id="ensure_column_mapping-399"><a href="#ensure_column_mapping-399"><span class="linenos">399</span></a> -</span><span id="ensure_column_mapping-400"><a href="#ensure_column_mapping-400"><span class="linenos">400</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid mapping provided: </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">mapping</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="ensure_column_mapping-389"><a href="#ensure_column_mapping-389"><span class="linenos">389</span></a><span class="k">def</span> <span class="nf">ensure_column_mapping</span><span class="p">(</span><span class="n">mapping</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">ColumnMapping</span><span class="p">])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">:</span> +</span><span id="ensure_column_mapping-390"><a href="#ensure_column_mapping-390"><span class="linenos">390</span></a> <span class="k">if</span> <span class="n">mapping</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="ensure_column_mapping-391"><a href="#ensure_column_mapping-391"><span class="linenos">391</span></a> <span class="k">return</span> <span class="p">{}</span> +</span><span id="ensure_column_mapping-392"><a href="#ensure_column_mapping-392"><span class="linenos">392</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">mapping</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span> +</span><span id="ensure_column_mapping-393"><a href="#ensure_column_mapping-393"><span class="linenos">393</span></a> <span class="k">return</span> <span class="n">mapping</span> +</span><span id="ensure_column_mapping-394"><a href="#ensure_column_mapping-394"><span class="linenos">394</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">mapping</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span> +</span><span id="ensure_column_mapping-395"><a href="#ensure_column_mapping-395"><span class="linenos">395</span></a> <span class="n">col_name_type_strs</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">mapping</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">","</span><span class="p">)]</span> +</span><span id="ensure_column_mapping-396"><a href="#ensure_column_mapping-396"><span class="linenos">396</span></a> <span class="k">return</span> <span class="p">{</span> +</span><span id="ensure_column_mapping-397"><a href="#ensure_column_mapping-397"><span class="linenos">397</span></a> <span class="n">name_type_str</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">":"</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">():</span> <span class="n">name_type_str</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">":"</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="ensure_column_mapping-398"><a href="#ensure_column_mapping-398"><span class="linenos">398</span></a> <span class="k">for</span> <span class="n">name_type_str</span> <span class="ow">in</span> <span class="n">col_name_type_strs</span> +</span><span id="ensure_column_mapping-399"><a href="#ensure_column_mapping-399"><span class="linenos">399</span></a> <span class="p">}</span> +</span><span id="ensure_column_mapping-400"><a href="#ensure_column_mapping-400"><span class="linenos">400</span></a> <span class="c1"># Check if mapping looks like a DataFrame StructType</span> +</span><span id="ensure_column_mapping-401"><a href="#ensure_column_mapping-401"><span class="linenos">401</span></a> <span class="k">elif</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">mapping</span><span class="p">,</span> <span class="s2">"simpleString"</span><span class="p">):</span> +</span><span id="ensure_column_mapping-402"><a href="#ensure_column_mapping-402"><span class="linenos">402</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">struct_field</span><span class="o">.</span><span class="n">name</span><span class="p">:</span> <span class="n">struct_field</span><span class="o">.</span><span class="n">dataType</span><span class="o">.</span><span class="n">simpleString</span><span class="p">()</span> <span class="k">for</span> <span class="n">struct_field</span> <span class="ow">in</span> <span class="n">mapping</span><span class="p">}</span> +</span><span id="ensure_column_mapping-403"><a href="#ensure_column_mapping-403"><span class="linenos">403</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">mapping</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="ensure_column_mapping-404"><a href="#ensure_column_mapping-404"><span class="linenos">404</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">x</span><span class="o">.</span><span class="n">strip</span><span class="p">():</span> <span class="kc">None</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">mapping</span><span class="p">}</span> +</span><span id="ensure_column_mapping-405"><a href="#ensure_column_mapping-405"><span class="linenos">405</span></a> +</span><span id="ensure_column_mapping-406"><a href="#ensure_column_mapping-406"><span class="linenos">406</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Invalid mapping provided: </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">mapping</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> </span></pre></div> @@ -1661,19 +1673,19 @@ are assumed to be visible. The nesting should mirror that of the schema: </div> <a class="headerlink" href="#flatten_schema"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="flatten_schema-403"><a href="#flatten_schema-403"><span class="linenos">403</span></a><span class="k">def</span> <span class="nf">flatten_schema</span><span class="p">(</span> -</span><span id="flatten_schema-404"><a href="#flatten_schema-404"><span class="linenos">404</span></a> <span class="n">schema</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">,</span> <span class="n">depth</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> <span class="n">keys</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="flatten_schema-405"><a href="#flatten_schema-405"><span class="linenos">405</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="flatten_schema-406"><a href="#flatten_schema-406"><span class="linenos">406</span></a> <span class="n">tables</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="flatten_schema-407"><a href="#flatten_schema-407"><span class="linenos">407</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">keys</span> <span class="ow">or</span> <span class="p">[]</span> -</span><span id="flatten_schema-408"><a href="#flatten_schema-408"><span class="linenos">408</span></a> -</span><span id="flatten_schema-409"><a href="#flatten_schema-409"><span class="linenos">409</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">schema</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> -</span><span id="flatten_schema-410"><a href="#flatten_schema-410"><span class="linenos">410</span></a> <span class="k">if</span> <span class="n">depth</span> <span class="o">>=</span> <span class="mi">2</span><span class="p">:</span> -</span><span id="flatten_schema-411"><a href="#flatten_schema-411"><span class="linenos">411</span></a> <span class="n">tables</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">flatten_schema</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">depth</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">keys</span> <span class="o">+</span> <span class="p">[</span><span class="n">k</span><span class="p">]))</span> -</span><span id="flatten_schema-412"><a href="#flatten_schema-412"><span class="linenos">412</span></a> <span class="k">elif</span> <span class="n">depth</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="flatten_schema-413"><a href="#flatten_schema-413"><span class="linenos">413</span></a> <span class="n">tables</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">keys</span> <span class="o">+</span> <span class="p">[</span><span class="n">k</span><span class="p">])</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="flatten_schema-409"><a href="#flatten_schema-409"><span class="linenos">409</span></a><span class="k">def</span> <span class="nf">flatten_schema</span><span class="p">(</span> +</span><span id="flatten_schema-410"><a href="#flatten_schema-410"><span class="linenos">410</span></a> <span class="n">schema</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">,</span> <span class="n">depth</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> <span class="n">keys</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="flatten_schema-411"><a href="#flatten_schema-411"><span class="linenos">411</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="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="flatten_schema-412"><a href="#flatten_schema-412"><span class="linenos">412</span></a> <span class="n">tables</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="flatten_schema-413"><a href="#flatten_schema-413"><span class="linenos">413</span></a> <span class="n">keys</span> <span class="o">=</span> <span class="n">keys</span> <span class="ow">or</span> <span class="p">[]</span> </span><span id="flatten_schema-414"><a href="#flatten_schema-414"><span class="linenos">414</span></a> -</span><span id="flatten_schema-415"><a href="#flatten_schema-415"><span class="linenos">415</span></a> <span class="k">return</span> <span class="n">tables</span> +</span><span id="flatten_schema-415"><a href="#flatten_schema-415"><span class="linenos">415</span></a> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">schema</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> +</span><span id="flatten_schema-416"><a href="#flatten_schema-416"><span class="linenos">416</span></a> <span class="k">if</span> <span class="n">depth</span> <span class="o">>=</span> <span class="mi">2</span><span class="p">:</span> +</span><span id="flatten_schema-417"><a href="#flatten_schema-417"><span class="linenos">417</span></a> <span class="n">tables</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">flatten_schema</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">depth</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">keys</span> <span class="o">+</span> <span class="p">[</span><span class="n">k</span><span class="p">]))</span> +</span><span id="flatten_schema-418"><a href="#flatten_schema-418"><span class="linenos">418</span></a> <span class="k">elif</span> <span class="n">depth</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="flatten_schema-419"><a href="#flatten_schema-419"><span class="linenos">419</span></a> <span class="n">tables</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">keys</span> <span class="o">+</span> <span class="p">[</span><span class="n">k</span><span class="p">])</span> +</span><span id="flatten_schema-420"><a href="#flatten_schema-420"><span class="linenos">420</span></a> +</span><span id="flatten_schema-421"><a href="#flatten_schema-421"><span class="linenos">421</span></a> <span class="k">return</span> <span class="n">tables</span> </span></pre></div> @@ -1691,30 +1703,30 @@ are assumed to be visible. The nesting should mirror that of the schema: </div> <a class="headerlink" href="#nested_get"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="nested_get-418"><a href="#nested_get-418"><span class="linenos">418</span></a><span class="k">def</span> <span class="nf">nested_get</span><span class="p">(</span> -</span><span id="nested_get-419"><a href="#nested_get-419"><span class="linenos">419</span></a> <span class="n">d</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">,</span> <span class="o">*</span><span class="n">path</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="n">raise_on_missing</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="nested_get-420"><a href="#nested_get-420"><span class="linenos">420</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">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]:</span> -</span><span id="nested_get-421"><a href="#nested_get-421"><span class="linenos">421</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="nested_get-422"><a href="#nested_get-422"><span class="linenos">422</span></a><span class="sd"> Get a value for a nested dictionary.</span> -</span><span id="nested_get-423"><a href="#nested_get-423"><span class="linenos">423</span></a> -</span><span id="nested_get-424"><a href="#nested_get-424"><span class="linenos">424</span></a><span class="sd"> Args:</span> -</span><span id="nested_get-425"><a href="#nested_get-425"><span class="linenos">425</span></a><span class="sd"> d: the dictionary to search.</span> -</span><span id="nested_get-426"><a href="#nested_get-426"><span class="linenos">426</span></a><span class="sd"> *path: tuples of (name, key), where:</span> -</span><span id="nested_get-427"><a href="#nested_get-427"><span class="linenos">427</span></a><span class="sd"> `key` is the key in the dictionary to get.</span> -</span><span id="nested_get-428"><a href="#nested_get-428"><span class="linenos">428</span></a><span class="sd"> `name` is a string to use in the error if `key` isn't found.</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="nested_get-424"><a href="#nested_get-424"><span class="linenos">424</span></a><span class="k">def</span> <span class="nf">nested_get</span><span class="p">(</span> +</span><span id="nested_get-425"><a href="#nested_get-425"><span class="linenos">425</span></a> <span class="n">d</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">,</span> <span class="o">*</span><span class="n">path</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">],</span> <span class="n">raise_on_missing</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="nested_get-426"><a href="#nested_get-426"><span class="linenos">426</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">t</span><span class="o">.</span><span class="n">Any</span><span class="p">]:</span> +</span><span id="nested_get-427"><a href="#nested_get-427"><span class="linenos">427</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="nested_get-428"><a href="#nested_get-428"><span class="linenos">428</span></a><span class="sd"> Get a value for a nested dictionary.</span> </span><span id="nested_get-429"><a href="#nested_get-429"><span class="linenos">429</span></a> -</span><span id="nested_get-430"><a href="#nested_get-430"><span class="linenos">430</span></a><span class="sd"> Returns:</span> -</span><span id="nested_get-431"><a href="#nested_get-431"><span class="linenos">431</span></a><span class="sd"> The value or None if it doesn't exist.</span> -</span><span id="nested_get-432"><a href="#nested_get-432"><span class="linenos">432</span></a><span class="sd"> """</span> -</span><span id="nested_get-433"><a href="#nested_get-433"><span class="linenos">433</span></a> <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">path</span><span class="p">:</span> -</span><span id="nested_get-434"><a href="#nested_get-434"><span class="linenos">434</span></a> <span class="n">d</span> <span class="o">=</span> <span class="n">d</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">)</span> <span class="c1"># type: ignore</span> -</span><span id="nested_get-435"><a href="#nested_get-435"><span class="linenos">435</span></a> <span class="k">if</span> <span class="n">d</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="nested_get-436"><a href="#nested_get-436"><span class="linenos">436</span></a> <span class="k">if</span> <span class="n">raise_on_missing</span><span class="p">:</span> -</span><span id="nested_get-437"><a href="#nested_get-437"><span class="linenos">437</span></a> <span class="n">name</span> <span class="o">=</span> <span class="s2">"table"</span> <span class="k">if</span> <span class="n">name</span> <span class="o">==</span> <span class="s2">"this"</span> <span class="k">else</span> <span class="n">name</span> -</span><span id="nested_get-438"><a href="#nested_get-438"><span class="linenos">438</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unknown </span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="nested_get-439"><a href="#nested_get-439"><span class="linenos">439</span></a> <span class="k">return</span> <span class="kc">None</span> -</span><span id="nested_get-440"><a href="#nested_get-440"><span class="linenos">440</span></a> -</span><span id="nested_get-441"><a href="#nested_get-441"><span class="linenos">441</span></a> <span class="k">return</span> <span class="n">d</span> +</span><span id="nested_get-430"><a href="#nested_get-430"><span class="linenos">430</span></a><span class="sd"> Args:</span> +</span><span id="nested_get-431"><a href="#nested_get-431"><span class="linenos">431</span></a><span class="sd"> d: the dictionary to search.</span> +</span><span id="nested_get-432"><a href="#nested_get-432"><span class="linenos">432</span></a><span class="sd"> *path: tuples of (name, key), where:</span> +</span><span id="nested_get-433"><a href="#nested_get-433"><span class="linenos">433</span></a><span class="sd"> `key` is the key in the dictionary to get.</span> +</span><span id="nested_get-434"><a href="#nested_get-434"><span class="linenos">434</span></a><span class="sd"> `name` is a string to use in the error if `key` isn't found.</span> +</span><span id="nested_get-435"><a href="#nested_get-435"><span class="linenos">435</span></a> +</span><span id="nested_get-436"><a href="#nested_get-436"><span class="linenos">436</span></a><span class="sd"> Returns:</span> +</span><span id="nested_get-437"><a href="#nested_get-437"><span class="linenos">437</span></a><span class="sd"> The value or None if it doesn't exist.</span> +</span><span id="nested_get-438"><a href="#nested_get-438"><span class="linenos">438</span></a><span class="sd"> """</span> +</span><span id="nested_get-439"><a href="#nested_get-439"><span class="linenos">439</span></a> <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">path</span><span class="p">:</span> +</span><span id="nested_get-440"><a href="#nested_get-440"><span class="linenos">440</span></a> <span class="n">d</span> <span class="o">=</span> <span class="n">d</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">)</span> <span class="c1"># type: ignore</span> +</span><span id="nested_get-441"><a href="#nested_get-441"><span class="linenos">441</span></a> <span class="k">if</span> <span class="n">d</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="nested_get-442"><a href="#nested_get-442"><span class="linenos">442</span></a> <span class="k">if</span> <span class="n">raise_on_missing</span><span class="p">:</span> +</span><span id="nested_get-443"><a href="#nested_get-443"><span class="linenos">443</span></a> <span class="n">name</span> <span class="o">=</span> <span class="s2">"table"</span> <span class="k">if</span> <span class="n">name</span> <span class="o">==</span> <span class="s2">"this"</span> <span class="k">else</span> <span class="n">name</span> +</span><span id="nested_get-444"><a href="#nested_get-444"><span class="linenos">444</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unknown </span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">key</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="nested_get-445"><a href="#nested_get-445"><span class="linenos">445</span></a> <span class="k">return</span> <span class="kc">None</span> +</span><span id="nested_get-446"><a href="#nested_get-446"><span class="linenos">446</span></a> +</span><span id="nested_get-447"><a href="#nested_get-447"><span class="linenos">447</span></a> <span class="k">return</span> <span class="n">d</span> </span></pre></div> @@ -1749,41 +1761,41 @@ are assumed to be visible. The nesting should mirror that of the schema: </div> <a class="headerlink" href="#nested_set"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="nested_set-444"><a href="#nested_set-444"><span class="linenos">444</span></a><span class="k">def</span> <span class="nf">nested_set</span><span class="p">(</span><span class="n">d</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">,</span> <span class="n">keys</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">:</span> -</span><span id="nested_set-445"><a href="#nested_set-445"><span class="linenos">445</span></a><span class="w"> </span><span class="sd">"""</span> -</span><span id="nested_set-446"><a href="#nested_set-446"><span class="linenos">446</span></a><span class="sd"> In-place set a value for a nested dictionary</span> -</span><span id="nested_set-447"><a href="#nested_set-447"><span class="linenos">447</span></a> -</span><span id="nested_set-448"><a href="#nested_set-448"><span class="linenos">448</span></a><span class="sd"> Example:</span> -</span><span id="nested_set-449"><a href="#nested_set-449"><span class="linenos">449</span></a><span class="sd"> >>> nested_set({}, ["top_key", "second_key"], "value")</span> -</span><span id="nested_set-450"><a href="#nested_set-450"><span class="linenos">450</span></a><span class="sd"> {'top_key': {'second_key': 'value'}}</span> -</span><span id="nested_set-451"><a href="#nested_set-451"><span class="linenos">451</span></a> -</span><span id="nested_set-452"><a href="#nested_set-452"><span class="linenos">452</span></a><span class="sd"> >>> nested_set({"top_key": {"third_key": "third_value"}}, ["top_key", "second_key"], "value")</span> -</span><span id="nested_set-453"><a href="#nested_set-453"><span class="linenos">453</span></a><span class="sd"> {'top_key': {'third_key': 'third_value', 'second_key': 'value'}}</span> -</span><span id="nested_set-454"><a href="#nested_set-454"><span class="linenos">454</span></a> -</span><span id="nested_set-455"><a href="#nested_set-455"><span class="linenos">455</span></a><span class="sd"> Args:</span> -</span><span id="nested_set-456"><a href="#nested_set-456"><span class="linenos">456</span></a><span class="sd"> d: dictionary to update.</span> -</span><span id="nested_set-457"><a href="#nested_set-457"><span class="linenos">457</span></a><span class="sd"> keys: the keys that makeup the path to `value`.</span> -</span><span id="nested_set-458"><a href="#nested_set-458"><span class="linenos">458</span></a><span class="sd"> value: the value to set in the dictionary for the given key path.</span> -</span><span id="nested_set-459"><a href="#nested_set-459"><span class="linenos">459</span></a> -</span><span id="nested_set-460"><a href="#nested_set-460"><span class="linenos">460</span></a><span class="sd"> Returns:</span> -</span><span id="nested_set-461"><a href="#nested_set-461"><span class="linenos">461</span></a><span class="sd"> The (possibly) updated dictionary.</span> -</span><span id="nested_set-462"><a href="#nested_set-462"><span class="linenos">462</span></a><span class="sd"> """</span> -</span><span id="nested_set-463"><a href="#nested_set-463"><span class="linenos">463</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">keys</span><span class="p">:</span> -</span><span id="nested_set-464"><a href="#nested_set-464"><span class="linenos">464</span></a> <span class="k">return</span> <span class="n">d</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="nested_set-450"><a href="#nested_set-450"><span class="linenos">450</span></a><span class="k">def</span> <span class="nf">nested_set</span><span class="p">(</span><span class="n">d</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">,</span> <span class="n">keys</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Sequence</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="n">value</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">:</span> +</span><span id="nested_set-451"><a href="#nested_set-451"><span class="linenos">451</span></a><span class="w"> </span><span class="sd">"""</span> +</span><span id="nested_set-452"><a href="#nested_set-452"><span class="linenos">452</span></a><span class="sd"> In-place set a value for a nested dictionary</span> +</span><span id="nested_set-453"><a href="#nested_set-453"><span class="linenos">453</span></a> +</span><span id="nested_set-454"><a href="#nested_set-454"><span class="linenos">454</span></a><span class="sd"> Example:</span> +</span><span id="nested_set-455"><a href="#nested_set-455"><span class="linenos">455</span></a><span class="sd"> >>> nested_set({}, ["top_key", "second_key"], "value")</span> +</span><span id="nested_set-456"><a href="#nested_set-456"><span class="linenos">456</span></a><span class="sd"> {'top_key': {'second_key': 'value'}}</span> +</span><span id="nested_set-457"><a href="#nested_set-457"><span class="linenos">457</span></a> +</span><span id="nested_set-458"><a href="#nested_set-458"><span class="linenos">458</span></a><span class="sd"> >>> nested_set({"top_key": {"third_key": "third_value"}}, ["top_key", "second_key"], "value")</span> +</span><span id="nested_set-459"><a href="#nested_set-459"><span class="linenos">459</span></a><span class="sd"> {'top_key': {'third_key': 'third_value', 'second_key': 'value'}}</span> +</span><span id="nested_set-460"><a href="#nested_set-460"><span class="linenos">460</span></a> +</span><span id="nested_set-461"><a href="#nested_set-461"><span class="linenos">461</span></a><span class="sd"> Args:</span> +</span><span id="nested_set-462"><a href="#nested_set-462"><span class="linenos">462</span></a><span class="sd"> d: dictionary to update.</span> +</span><span id="nested_set-463"><a href="#nested_set-463"><span class="linenos">463</span></a><span class="sd"> keys: the keys that makeup the path to `value`.</span> +</span><span id="nested_set-464"><a href="#nested_set-464"><span class="linenos">464</span></a><span class="sd"> value: the value to set in the dictionary for the given key path.</span> </span><span id="nested_set-465"><a href="#nested_set-465"><span class="linenos">465</span></a> -</span><span id="nested_set-466"><a href="#nested_set-466"><span class="linenos">466</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">keys</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="nested_set-467"><a href="#nested_set-467"><span class="linenos">467</span></a> <span class="n">d</span><span class="p">[</span><span class="n">keys</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="n">value</span> -</span><span id="nested_set-468"><a href="#nested_set-468"><span class="linenos">468</span></a> <span class="k">return</span> <span class="n">d</span> -</span><span id="nested_set-469"><a href="#nested_set-469"><span class="linenos">469</span></a> -</span><span id="nested_set-470"><a href="#nested_set-470"><span class="linenos">470</span></a> <span class="n">subd</span> <span class="o">=</span> <span class="n">d</span> -</span><span id="nested_set-471"><a href="#nested_set-471"><span class="linenos">471</span></a> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span> -</span><span id="nested_set-472"><a href="#nested_set-472"><span class="linenos">472</span></a> <span class="k">if</span> <span class="n">key</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">subd</span><span class="p">:</span> -</span><span id="nested_set-473"><a href="#nested_set-473"><span class="linenos">473</span></a> <span class="n">subd</span> <span class="o">=</span> <span class="n">subd</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="p">{})</span> -</span><span id="nested_set-474"><a href="#nested_set-474"><span class="linenos">474</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="nested_set-475"><a href="#nested_set-475"><span class="linenos">475</span></a> <span class="n">subd</span> <span class="o">=</span> <span class="n">subd</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> -</span><span id="nested_set-476"><a href="#nested_set-476"><span class="linenos">476</span></a> -</span><span id="nested_set-477"><a href="#nested_set-477"><span class="linenos">477</span></a> <span class="n">subd</span><span class="p">[</span><span class="n">keys</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">value</span> -</span><span id="nested_set-478"><a href="#nested_set-478"><span class="linenos">478</span></a> <span class="k">return</span> <span class="n">d</span> +</span><span id="nested_set-466"><a href="#nested_set-466"><span class="linenos">466</span></a><span class="sd"> Returns:</span> +</span><span id="nested_set-467"><a href="#nested_set-467"><span class="linenos">467</span></a><span class="sd"> The (possibly) updated dictionary.</span> +</span><span id="nested_set-468"><a href="#nested_set-468"><span class="linenos">468</span></a><span class="sd"> """</span> +</span><span id="nested_set-469"><a href="#nested_set-469"><span class="linenos">469</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">keys</span><span class="p">:</span> +</span><span id="nested_set-470"><a href="#nested_set-470"><span class="linenos">470</span></a> <span class="k">return</span> <span class="n">d</span> +</span><span id="nested_set-471"><a href="#nested_set-471"><span class="linenos">471</span></a> +</span><span id="nested_set-472"><a href="#nested_set-472"><span class="linenos">472</span></a> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">keys</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="nested_set-473"><a href="#nested_set-473"><span class="linenos">473</span></a> <span class="n">d</span><span class="p">[</span><span class="n">keys</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="n">value</span> +</span><span id="nested_set-474"><a href="#nested_set-474"><span class="linenos">474</span></a> <span class="k">return</span> <span class="n">d</span> +</span><span id="nested_set-475"><a href="#nested_set-475"><span class="linenos">475</span></a> +</span><span id="nested_set-476"><a href="#nested_set-476"><span class="linenos">476</span></a> <span class="n">subd</span> <span class="o">=</span> <span class="n">d</span> +</span><span id="nested_set-477"><a href="#nested_set-477"><span class="linenos">477</span></a> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span> +</span><span id="nested_set-478"><a href="#nested_set-478"><span class="linenos">478</span></a> <span class="k">if</span> <span class="n">key</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">subd</span><span class="p">:</span> +</span><span id="nested_set-479"><a href="#nested_set-479"><span class="linenos">479</span></a> <span class="n">subd</span> <span class="o">=</span> <span class="n">subd</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="p">{})</span> +</span><span id="nested_set-480"><a href="#nested_set-480"><span class="linenos">480</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="nested_set-481"><a href="#nested_set-481"><span class="linenos">481</span></a> <span class="n">subd</span> <span class="o">=</span> <span class="n">subd</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> +</span><span id="nested_set-482"><a href="#nested_set-482"><span class="linenos">482</span></a> +</span><span id="nested_set-483"><a href="#nested_set-483"><span class="linenos">483</span></a> <span class="n">subd</span><span class="p">[</span><span class="n">keys</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">value</span> +</span><span id="nested_set-484"><a href="#nested_set-484"><span class="linenos">484</span></a> <span class="k">return</span> <span class="n">d</span> </span></pre></div> diff --git a/docs/sqlglot/tokens.html b/docs/sqlglot/tokens.html index 0a27ffe..32e0646 100644 --- a/docs/sqlglot/tokens.html +++ b/docs/sqlglot/tokens.html @@ -478,6 +478,9 @@ <a class="variable" href="#TokenType.CHARACTER_SET">CHARACTER_SET</a> </li> <li> + <a class="variable" href="#TokenType.CLUSTER_BY">CLUSTER_BY</a> + </li> + <li> <a class="variable" href="#TokenType.COLLATE">COLLATE</a> </li> <li> @@ -535,6 +538,9 @@ <a class="variable" href="#TokenType.DISTINCT">DISTINCT</a> </li> <li> + <a class="variable" href="#TokenType.DISTRIBUTE_BY">DISTRIBUTE_BY</a> + </li> + <li> <a class="variable" href="#TokenType.DIV">DIV</a> </li> <li> @@ -835,6 +841,9 @@ <a class="variable" href="#TokenType.SOME">SOME</a> </li> <li> + <a class="variable" href="#TokenType.SORT_BY">SORT_BY</a> + </li> + <li> <a class="variable" href="#TokenType.STRUCT">STRUCT</a> </li> <li> @@ -1124,987 +1133,993 @@ </span><span id="L-163"><a href="#L-163"><span class="linenos"> 163</span></a> <span class="n">CACHE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> </span><span id="L-164"><a href="#L-164"><span class="linenos"> 164</span></a> <span class="n">CASE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> </span><span id="L-165"><a href="#L-165"><span class="linenos"> 165</span></a> <span class="n">CHARACTER_SET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-166"><a href="#L-166"><span class="linenos"> 166</span></a> <span class="n">COLLATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-167"><a href="#L-167"><span class="linenos"> 167</span></a> <span class="n">COMMAND</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-168"><a href="#L-168"><span class="linenos"> 168</span></a> <span class="n">COMMENT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-169"><a href="#L-169"><span class="linenos"> 169</span></a> <span class="n">COMMIT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-170"><a href="#L-170"><span class="linenos"> 170</span></a> <span class="n">CONSTRAINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-171"><a href="#L-171"><span class="linenos"> 171</span></a> <span class="n">CREATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-172"><a href="#L-172"><span class="linenos"> 172</span></a> <span class="n">CROSS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-173"><a href="#L-173"><span class="linenos"> 173</span></a> <span class="n">CUBE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-174"><a href="#L-174"><span class="linenos"> 174</span></a> <span class="n">CURRENT_DATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-175"><a href="#L-175"><span class="linenos"> 175</span></a> <span class="n">CURRENT_DATETIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-176"><a href="#L-176"><span class="linenos"> 176</span></a> <span class="n">CURRENT_TIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-177"><a href="#L-177"><span class="linenos"> 177</span></a> <span class="n">CURRENT_TIMESTAMP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-178"><a href="#L-178"><span class="linenos"> 178</span></a> <span class="n">CURRENT_USER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-179"><a href="#L-179"><span class="linenos"> 179</span></a> <span class="n">DEFAULT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-180"><a href="#L-180"><span class="linenos"> 180</span></a> <span class="n">DELETE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-181"><a href="#L-181"><span class="linenos"> 181</span></a> <span class="n">DESC</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-182"><a href="#L-182"><span class="linenos"> 182</span></a> <span class="n">DESCRIBE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-183"><a href="#L-183"><span class="linenos"> 183</span></a> <span class="n">DICTIONARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-184"><a href="#L-184"><span class="linenos"> 184</span></a> <span class="n">DISTINCT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-185"><a href="#L-185"><span class="linenos"> 185</span></a> <span class="n">DIV</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-186"><a href="#L-186"><span class="linenos"> 186</span></a> <span class="n">DROP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-187"><a href="#L-187"><span class="linenos"> 187</span></a> <span class="n">ELSE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-188"><a href="#L-188"><span class="linenos"> 188</span></a> <span class="n">END</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-189"><a href="#L-189"><span class="linenos"> 189</span></a> <span class="n">ESCAPE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-190"><a href="#L-190"><span class="linenos"> 190</span></a> <span class="n">EXCEPT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-191"><a href="#L-191"><span class="linenos"> 191</span></a> <span class="n">EXECUTE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-192"><a href="#L-192"><span class="linenos"> 192</span></a> <span class="n">EXISTS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-193"><a href="#L-193"><span class="linenos"> 193</span></a> <span class="n">FALSE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-194"><a href="#L-194"><span class="linenos"> 194</span></a> <span class="n">FETCH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-195"><a href="#L-195"><span class="linenos"> 195</span></a> <span class="n">FILTER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-196"><a href="#L-196"><span class="linenos"> 196</span></a> <span class="n">FINAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-197"><a href="#L-197"><span class="linenos"> 197</span></a> <span class="n">FIRST</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-198"><a href="#L-198"><span class="linenos"> 198</span></a> <span class="n">FOR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-199"><a href="#L-199"><span class="linenos"> 199</span></a> <span class="n">FOREIGN_KEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-200"><a href="#L-200"><span class="linenos"> 200</span></a> <span class="n">FORMAT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-201"><a href="#L-201"><span class="linenos"> 201</span></a> <span class="n">FROM</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-202"><a href="#L-202"><span class="linenos"> 202</span></a> <span class="n">FULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-203"><a href="#L-203"><span class="linenos"> 203</span></a> <span class="n">FUNCTION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-204"><a href="#L-204"><span class="linenos"> 204</span></a> <span class="n">GLOB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-205"><a href="#L-205"><span class="linenos"> 205</span></a> <span class="n">GLOBAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-206"><a href="#L-206"><span class="linenos"> 206</span></a> <span class="n">GROUP_BY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-207"><a href="#L-207"><span class="linenos"> 207</span></a> <span class="n">GROUPING_SETS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-208"><a href="#L-208"><span class="linenos"> 208</span></a> <span class="n">HAVING</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-209"><a href="#L-209"><span class="linenos"> 209</span></a> <span class="n">HINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-210"><a href="#L-210"><span class="linenos"> 210</span></a> <span class="n">IF</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-211"><a href="#L-211"><span class="linenos"> 211</span></a> <span class="n">ILIKE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-212"><a href="#L-212"><span class="linenos"> 212</span></a> <span class="n">ILIKE_ANY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-213"><a href="#L-213"><span class="linenos"> 213</span></a> <span class="n">IN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-214"><a href="#L-214"><span class="linenos"> 214</span></a> <span class="n">INDEX</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-215"><a href="#L-215"><span class="linenos"> 215</span></a> <span class="n">INNER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-216"><a href="#L-216"><span class="linenos"> 216</span></a> <span class="n">INSERT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-217"><a href="#L-217"><span class="linenos"> 217</span></a> <span class="n">INTERSECT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-218"><a href="#L-218"><span class="linenos"> 218</span></a> <span class="n">INTERVAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-219"><a href="#L-219"><span class="linenos"> 219</span></a> <span class="n">INTO</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-220"><a href="#L-220"><span class="linenos"> 220</span></a> <span class="n">INTRODUCER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-221"><a href="#L-221"><span class="linenos"> 221</span></a> <span class="n">IRLIKE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-222"><a href="#L-222"><span class="linenos"> 222</span></a> <span class="n">IS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-223"><a href="#L-223"><span class="linenos"> 223</span></a> <span class="n">ISNULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-224"><a href="#L-224"><span class="linenos"> 224</span></a> <span class="n">JOIN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-225"><a href="#L-225"><span class="linenos"> 225</span></a> <span class="n">JOIN_MARKER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-226"><a href="#L-226"><span class="linenos"> 226</span></a> <span class="n">KEEP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-227"><a href="#L-227"><span class="linenos"> 227</span></a> <span class="n">LANGUAGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-228"><a href="#L-228"><span class="linenos"> 228</span></a> <span class="n">LATERAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-229"><a href="#L-229"><span class="linenos"> 229</span></a> <span class="n">LEFT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-230"><a href="#L-230"><span class="linenos"> 230</span></a> <span class="n">LIKE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-231"><a href="#L-231"><span class="linenos"> 231</span></a> <span class="n">LIKE_ANY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-232"><a href="#L-232"><span class="linenos"> 232</span></a> <span class="n">LIMIT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-233"><a href="#L-233"><span class="linenos"> 233</span></a> <span class="n">LOAD</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-234"><a href="#L-234"><span class="linenos"> 234</span></a> <span class="n">LOCK</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-235"><a href="#L-235"><span class="linenos"> 235</span></a> <span class="n">MAP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-236"><a href="#L-236"><span class="linenos"> 236</span></a> <span class="n">MATCH_RECOGNIZE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-237"><a href="#L-237"><span class="linenos"> 237</span></a> <span class="n">MERGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-238"><a href="#L-238"><span class="linenos"> 238</span></a> <span class="n">MOD</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-239"><a href="#L-239"><span class="linenos"> 239</span></a> <span class="n">NATURAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-240"><a href="#L-240"><span class="linenos"> 240</span></a> <span class="n">NEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-241"><a href="#L-241"><span class="linenos"> 241</span></a> <span class="n">NEXT_VALUE_FOR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-242"><a href="#L-242"><span class="linenos"> 242</span></a> <span class="n">NOTNULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-243"><a href="#L-243"><span class="linenos"> 243</span></a> <span class="n">NULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-244"><a href="#L-244"><span class="linenos"> 244</span></a> <span class="n">OFFSET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-245"><a href="#L-245"><span class="linenos"> 245</span></a> <span class="n">ON</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-246"><a href="#L-246"><span class="linenos"> 246</span></a> <span class="n">ORDER_BY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-247"><a href="#L-247"><span class="linenos"> 247</span></a> <span class="n">ORDERED</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-248"><a href="#L-248"><span class="linenos"> 248</span></a> <span class="n">ORDINALITY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-249"><a href="#L-249"><span class="linenos"> 249</span></a> <span class="n">OUTER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-250"><a href="#L-250"><span class="linenos"> 250</span></a> <span class="n">OVER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-251"><a href="#L-251"><span class="linenos"> 251</span></a> <span class="n">OVERLAPS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-252"><a href="#L-252"><span class="linenos"> 252</span></a> <span class="n">OVERWRITE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-253"><a href="#L-253"><span class="linenos"> 253</span></a> <span class="n">PARTITION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-254"><a href="#L-254"><span class="linenos"> 254</span></a> <span class="n">PARTITION_BY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-255"><a href="#L-255"><span class="linenos"> 255</span></a> <span class="n">PERCENT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-256"><a href="#L-256"><span class="linenos"> 256</span></a> <span class="n">PIVOT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-257"><a href="#L-257"><span class="linenos"> 257</span></a> <span class="n">PLACEHOLDER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-258"><a href="#L-258"><span class="linenos"> 258</span></a> <span class="n">PRAGMA</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-259"><a href="#L-259"><span class="linenos"> 259</span></a> <span class="n">PRIMARY_KEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-260"><a href="#L-260"><span class="linenos"> 260</span></a> <span class="n">PROCEDURE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-261"><a href="#L-261"><span class="linenos"> 261</span></a> <span class="n">PROPERTIES</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-262"><a href="#L-262"><span class="linenos"> 262</span></a> <span class="n">PSEUDO_TYPE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-263"><a href="#L-263"><span class="linenos"> 263</span></a> <span class="n">QUALIFY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-264"><a href="#L-264"><span class="linenos"> 264</span></a> <span class="n">QUOTE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-265"><a href="#L-265"><span class="linenos"> 265</span></a> <span class="n">RANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-266"><a href="#L-266"><span class="linenos"> 266</span></a> <span class="n">RECURSIVE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-267"><a href="#L-267"><span class="linenos"> 267</span></a> <span class="n">REPLACE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-268"><a href="#L-268"><span class="linenos"> 268</span></a> <span class="n">RETURNING</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-269"><a href="#L-269"><span class="linenos"> 269</span></a> <span class="n">REFERENCES</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-270"><a href="#L-270"><span class="linenos"> 270</span></a> <span class="n">RIGHT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-271"><a href="#L-271"><span class="linenos"> 271</span></a> <span class="n">RLIKE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-272"><a href="#L-272"><span class="linenos"> 272</span></a> <span class="n">ROLLBACK</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-273"><a href="#L-273"><span class="linenos"> 273</span></a> <span class="n">ROLLUP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-274"><a href="#L-274"><span class="linenos"> 274</span></a> <span class="n">ROW</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-275"><a href="#L-275"><span class="linenos"> 275</span></a> <span class="n">ROWS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-276"><a href="#L-276"><span class="linenos"> 276</span></a> <span class="n">SELECT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-277"><a href="#L-277"><span class="linenos"> 277</span></a> <span class="n">SEMI</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-278"><a href="#L-278"><span class="linenos"> 278</span></a> <span class="n">SEPARATOR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-279"><a href="#L-279"><span class="linenos"> 279</span></a> <span class="n">SERDE_PROPERTIES</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-280"><a href="#L-280"><span class="linenos"> 280</span></a> <span class="n">SET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-281"><a href="#L-281"><span class="linenos"> 281</span></a> <span class="n">SETTINGS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-282"><a href="#L-282"><span class="linenos"> 282</span></a> <span class="n">SHOW</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-283"><a href="#L-283"><span class="linenos"> 283</span></a> <span class="n">SIMILAR_TO</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-284"><a href="#L-284"><span class="linenos"> 284</span></a> <span class="n">SOME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-285"><a href="#L-285"><span class="linenos"> 285</span></a> <span class="n">STRUCT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-286"><a href="#L-286"><span class="linenos"> 286</span></a> <span class="n">TABLE_SAMPLE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-287"><a href="#L-287"><span class="linenos"> 287</span></a> <span class="n">TEMPORARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-288"><a href="#L-288"><span class="linenos"> 288</span></a> <span class="n">TOP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-289"><a href="#L-289"><span class="linenos"> 289</span></a> <span class="n">THEN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-290"><a href="#L-290"><span class="linenos"> 290</span></a> <span class="n">TRUE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-291"><a href="#L-291"><span class="linenos"> 291</span></a> <span class="n">UNCACHE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-292"><a href="#L-292"><span class="linenos"> 292</span></a> <span class="n">UNION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-293"><a href="#L-293"><span class="linenos"> 293</span></a> <span class="n">UNNEST</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-294"><a href="#L-294"><span class="linenos"> 294</span></a> <span class="n">UNPIVOT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-295"><a href="#L-295"><span class="linenos"> 295</span></a> <span class="n">UPDATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-296"><a href="#L-296"><span class="linenos"> 296</span></a> <span class="n">USE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-297"><a href="#L-297"><span class="linenos"> 297</span></a> <span class="n">USING</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-298"><a href="#L-298"><span class="linenos"> 298</span></a> <span class="n">VALUES</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-299"><a href="#L-299"><span class="linenos"> 299</span></a> <span class="n">VIEW</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-300"><a href="#L-300"><span class="linenos"> 300</span></a> <span class="n">VOLATILE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-301"><a href="#L-301"><span class="linenos"> 301</span></a> <span class="n">WHEN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-302"><a href="#L-302"><span class="linenos"> 302</span></a> <span class="n">WHERE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-303"><a href="#L-303"><span class="linenos"> 303</span></a> <span class="n">WINDOW</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-304"><a href="#L-304"><span class="linenos"> 304</span></a> <span class="n">WITH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-305"><a href="#L-305"><span class="linenos"> 305</span></a> <span class="n">UNIQUE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="L-306"><a href="#L-306"><span class="linenos"> 306</span></a> -</span><span id="L-307"><a href="#L-307"><span class="linenos"> 307</span></a> -</span><span id="L-308"><a href="#L-308"><span class="linenos"> 308</span></a><span class="k">class</span> <span class="nc">Token</span><span class="p">:</span> -</span><span id="L-309"><a href="#L-309"><span class="linenos"> 309</span></a> <span class="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"token_type"</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">,</span> <span class="s2">"line"</span><span class="p">,</span> <span class="s2">"col"</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">,</span> <span class="s2">"end"</span><span class="p">,</span> <span class="s2">"comments"</span><span class="p">)</span> +</span><span id="L-166"><a href="#L-166"><span class="linenos"> 166</span></a> <span class="n">CLUSTER_BY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-167"><a href="#L-167"><span class="linenos"> 167</span></a> <span class="n">COLLATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-168"><a href="#L-168"><span class="linenos"> 168</span></a> <span class="n">COMMAND</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-169"><a href="#L-169"><span class="linenos"> 169</span></a> <span class="n">COMMENT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-170"><a href="#L-170"><span class="linenos"> 170</span></a> <span class="n">COMMIT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-171"><a href="#L-171"><span class="linenos"> 171</span></a> <span class="n">CONSTRAINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-172"><a href="#L-172"><span class="linenos"> 172</span></a> <span class="n">CREATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-173"><a href="#L-173"><span class="linenos"> 173</span></a> <span class="n">CROSS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-174"><a href="#L-174"><span class="linenos"> 174</span></a> <span class="n">CUBE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-175"><a href="#L-175"><span class="linenos"> 175</span></a> <span class="n">CURRENT_DATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-176"><a href="#L-176"><span class="linenos"> 176</span></a> <span class="n">CURRENT_DATETIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-177"><a href="#L-177"><span class="linenos"> 177</span></a> <span class="n">CURRENT_TIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-178"><a href="#L-178"><span class="linenos"> 178</span></a> <span class="n">CURRENT_TIMESTAMP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-179"><a href="#L-179"><span class="linenos"> 179</span></a> <span class="n">CURRENT_USER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-180"><a href="#L-180"><span class="linenos"> 180</span></a> <span class="n">DEFAULT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-181"><a href="#L-181"><span class="linenos"> 181</span></a> <span class="n">DELETE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-182"><a href="#L-182"><span class="linenos"> 182</span></a> <span class="n">DESC</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-183"><a href="#L-183"><span class="linenos"> 183</span></a> <span class="n">DESCRIBE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-184"><a href="#L-184"><span class="linenos"> 184</span></a> <span class="n">DICTIONARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-185"><a href="#L-185"><span class="linenos"> 185</span></a> <span class="n">DISTINCT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-186"><a href="#L-186"><span class="linenos"> 186</span></a> <span class="n">DISTRIBUTE_BY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-187"><a href="#L-187"><span class="linenos"> 187</span></a> <span class="n">DIV</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-188"><a href="#L-188"><span class="linenos"> 188</span></a> <span class="n">DROP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-189"><a href="#L-189"><span class="linenos"> 189</span></a> <span class="n">ELSE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-190"><a href="#L-190"><span class="linenos"> 190</span></a> <span class="n">END</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-191"><a href="#L-191"><span class="linenos"> 191</span></a> <span class="n">ESCAPE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-192"><a href="#L-192"><span class="linenos"> 192</span></a> <span class="n">EXCEPT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-193"><a href="#L-193"><span class="linenos"> 193</span></a> <span class="n">EXECUTE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-194"><a href="#L-194"><span class="linenos"> 194</span></a> <span class="n">EXISTS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-195"><a href="#L-195"><span class="linenos"> 195</span></a> <span class="n">FALSE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-196"><a href="#L-196"><span class="linenos"> 196</span></a> <span class="n">FETCH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-197"><a href="#L-197"><span class="linenos"> 197</span></a> <span class="n">FILTER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-198"><a href="#L-198"><span class="linenos"> 198</span></a> <span class="n">FINAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-199"><a href="#L-199"><span class="linenos"> 199</span></a> <span class="n">FIRST</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-200"><a href="#L-200"><span class="linenos"> 200</span></a> <span class="n">FOR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-201"><a href="#L-201"><span class="linenos"> 201</span></a> <span class="n">FOREIGN_KEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-202"><a href="#L-202"><span class="linenos"> 202</span></a> <span class="n">FORMAT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-203"><a href="#L-203"><span class="linenos"> 203</span></a> <span class="n">FROM</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-204"><a href="#L-204"><span class="linenos"> 204</span></a> <span class="n">FULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-205"><a href="#L-205"><span class="linenos"> 205</span></a> <span class="n">FUNCTION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-206"><a href="#L-206"><span class="linenos"> 206</span></a> <span class="n">GLOB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-207"><a href="#L-207"><span class="linenos"> 207</span></a> <span class="n">GLOBAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-208"><a href="#L-208"><span class="linenos"> 208</span></a> <span class="n">GROUP_BY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-209"><a href="#L-209"><span class="linenos"> 209</span></a> <span class="n">GROUPING_SETS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-210"><a href="#L-210"><span class="linenos"> 210</span></a> <span class="n">HAVING</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-211"><a href="#L-211"><span class="linenos"> 211</span></a> <span class="n">HINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-212"><a href="#L-212"><span class="linenos"> 212</span></a> <span class="n">IF</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-213"><a href="#L-213"><span class="linenos"> 213</span></a> <span class="n">ILIKE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-214"><a href="#L-214"><span class="linenos"> 214</span></a> <span class="n">ILIKE_ANY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-215"><a href="#L-215"><span class="linenos"> 215</span></a> <span class="n">IN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-216"><a href="#L-216"><span class="linenos"> 216</span></a> <span class="n">INDEX</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-217"><a href="#L-217"><span class="linenos"> 217</span></a> <span class="n">INNER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-218"><a href="#L-218"><span class="linenos"> 218</span></a> <span class="n">INSERT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-219"><a href="#L-219"><span class="linenos"> 219</span></a> <span class="n">INTERSECT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-220"><a href="#L-220"><span class="linenos"> 220</span></a> <span class="n">INTERVAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-221"><a href="#L-221"><span class="linenos"> 221</span></a> <span class="n">INTO</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-222"><a href="#L-222"><span class="linenos"> 222</span></a> <span class="n">INTRODUCER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-223"><a href="#L-223"><span class="linenos"> 223</span></a> <span class="n">IRLIKE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-224"><a href="#L-224"><span class="linenos"> 224</span></a> <span class="n">IS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-225"><a href="#L-225"><span class="linenos"> 225</span></a> <span class="n">ISNULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-226"><a href="#L-226"><span class="linenos"> 226</span></a> <span class="n">JOIN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-227"><a href="#L-227"><span class="linenos"> 227</span></a> <span class="n">JOIN_MARKER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-228"><a href="#L-228"><span class="linenos"> 228</span></a> <span class="n">KEEP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-229"><a href="#L-229"><span class="linenos"> 229</span></a> <span class="n">LANGUAGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-230"><a href="#L-230"><span class="linenos"> 230</span></a> <span class="n">LATERAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-231"><a href="#L-231"><span class="linenos"> 231</span></a> <span class="n">LEFT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-232"><a href="#L-232"><span class="linenos"> 232</span></a> <span class="n">LIKE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-233"><a href="#L-233"><span class="linenos"> 233</span></a> <span class="n">LIKE_ANY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-234"><a href="#L-234"><span class="linenos"> 234</span></a> <span class="n">LIMIT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-235"><a href="#L-235"><span class="linenos"> 235</span></a> <span class="n">LOAD</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-236"><a href="#L-236"><span class="linenos"> 236</span></a> <span class="n">LOCK</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-237"><a href="#L-237"><span class="linenos"> 237</span></a> <span class="n">MAP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-238"><a href="#L-238"><span class="linenos"> 238</span></a> <span class="n">MATCH_RECOGNIZE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-239"><a href="#L-239"><span class="linenos"> 239</span></a> <span class="n">MERGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-240"><a href="#L-240"><span class="linenos"> 240</span></a> <span class="n">MOD</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-241"><a href="#L-241"><span class="linenos"> 241</span></a> <span class="n">NATURAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-242"><a href="#L-242"><span class="linenos"> 242</span></a> <span class="n">NEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-243"><a href="#L-243"><span class="linenos"> 243</span></a> <span class="n">NEXT_VALUE_FOR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-244"><a href="#L-244"><span class="linenos"> 244</span></a> <span class="n">NOTNULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-245"><a href="#L-245"><span class="linenos"> 245</span></a> <span class="n">NULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-246"><a href="#L-246"><span class="linenos"> 246</span></a> <span class="n">OFFSET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-247"><a href="#L-247"><span class="linenos"> 247</span></a> <span class="n">ON</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-248"><a href="#L-248"><span class="linenos"> 248</span></a> <span class="n">ORDER_BY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-249"><a href="#L-249"><span class="linenos"> 249</span></a> <span class="n">ORDERED</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-250"><a href="#L-250"><span class="linenos"> 250</span></a> <span class="n">ORDINALITY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-251"><a href="#L-251"><span class="linenos"> 251</span></a> <span class="n">OUTER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-252"><a href="#L-252"><span class="linenos"> 252</span></a> <span class="n">OVER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-253"><a href="#L-253"><span class="linenos"> 253</span></a> <span class="n">OVERLAPS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-254"><a href="#L-254"><span class="linenos"> 254</span></a> <span class="n">OVERWRITE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-255"><a href="#L-255"><span class="linenos"> 255</span></a> <span class="n">PARTITION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-256"><a href="#L-256"><span class="linenos"> 256</span></a> <span class="n">PARTITION_BY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-257"><a href="#L-257"><span class="linenos"> 257</span></a> <span class="n">PERCENT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-258"><a href="#L-258"><span class="linenos"> 258</span></a> <span class="n">PIVOT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-259"><a href="#L-259"><span class="linenos"> 259</span></a> <span class="n">PLACEHOLDER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-260"><a href="#L-260"><span class="linenos"> 260</span></a> <span class="n">PRAGMA</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-261"><a href="#L-261"><span class="linenos"> 261</span></a> <span class="n">PRIMARY_KEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-262"><a href="#L-262"><span class="linenos"> 262</span></a> <span class="n">PROCEDURE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-263"><a href="#L-263"><span class="linenos"> 263</span></a> <span class="n">PROPERTIES</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-264"><a href="#L-264"><span class="linenos"> 264</span></a> <span class="n">PSEUDO_TYPE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-265"><a href="#L-265"><span class="linenos"> 265</span></a> <span class="n">QUALIFY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-266"><a href="#L-266"><span class="linenos"> 266</span></a> <span class="n">QUOTE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-267"><a href="#L-267"><span class="linenos"> 267</span></a> <span class="n">RANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-268"><a href="#L-268"><span class="linenos"> 268</span></a> <span class="n">RECURSIVE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-269"><a href="#L-269"><span class="linenos"> 269</span></a> <span class="n">REPLACE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-270"><a href="#L-270"><span class="linenos"> 270</span></a> <span class="n">RETURNING</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-271"><a href="#L-271"><span class="linenos"> 271</span></a> <span class="n">REFERENCES</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-272"><a href="#L-272"><span class="linenos"> 272</span></a> <span class="n">RIGHT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-273"><a href="#L-273"><span class="linenos"> 273</span></a> <span class="n">RLIKE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-274"><a href="#L-274"><span class="linenos"> 274</span></a> <span class="n">ROLLBACK</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-275"><a href="#L-275"><span class="linenos"> 275</span></a> <span class="n">ROLLUP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-276"><a href="#L-276"><span class="linenos"> 276</span></a> <span class="n">ROW</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-277"><a href="#L-277"><span class="linenos"> 277</span></a> <span class="n">ROWS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-278"><a href="#L-278"><span class="linenos"> 278</span></a> <span class="n">SELECT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-279"><a href="#L-279"><span class="linenos"> 279</span></a> <span class="n">SEMI</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-280"><a href="#L-280"><span class="linenos"> 280</span></a> <span class="n">SEPARATOR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-281"><a href="#L-281"><span class="linenos"> 281</span></a> <span class="n">SERDE_PROPERTIES</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-282"><a href="#L-282"><span class="linenos"> 282</span></a> <span class="n">SET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-283"><a href="#L-283"><span class="linenos"> 283</span></a> <span class="n">SETTINGS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-284"><a href="#L-284"><span class="linenos"> 284</span></a> <span class="n">SHOW</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-285"><a href="#L-285"><span class="linenos"> 285</span></a> <span class="n">SIMILAR_TO</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-286"><a href="#L-286"><span class="linenos"> 286</span></a> <span class="n">SOME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-287"><a href="#L-287"><span class="linenos"> 287</span></a> <span class="n">SORT_BY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-288"><a href="#L-288"><span class="linenos"> 288</span></a> <span class="n">STRUCT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-289"><a href="#L-289"><span class="linenos"> 289</span></a> <span class="n">TABLE_SAMPLE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-290"><a href="#L-290"><span class="linenos"> 290</span></a> <span class="n">TEMPORARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-291"><a href="#L-291"><span class="linenos"> 291</span></a> <span class="n">TOP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-292"><a href="#L-292"><span class="linenos"> 292</span></a> <span class="n">THEN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-293"><a href="#L-293"><span class="linenos"> 293</span></a> <span class="n">TRUE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-294"><a href="#L-294"><span class="linenos"> 294</span></a> <span class="n">UNCACHE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-295"><a href="#L-295"><span class="linenos"> 295</span></a> <span class="n">UNION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-296"><a href="#L-296"><span class="linenos"> 296</span></a> <span class="n">UNNEST</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-297"><a href="#L-297"><span class="linenos"> 297</span></a> <span class="n">UNPIVOT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-298"><a href="#L-298"><span class="linenos"> 298</span></a> <span class="n">UPDATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-299"><a href="#L-299"><span class="linenos"> 299</span></a> <span class="n">USE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-300"><a href="#L-300"><span class="linenos"> 300</span></a> <span class="n">USING</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-301"><a href="#L-301"><span class="linenos"> 301</span></a> <span class="n">VALUES</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-302"><a href="#L-302"><span class="linenos"> 302</span></a> <span class="n">VIEW</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-303"><a href="#L-303"><span class="linenos"> 303</span></a> <span class="n">VOLATILE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-304"><a href="#L-304"><span class="linenos"> 304</span></a> <span class="n">WHEN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-305"><a href="#L-305"><span class="linenos"> 305</span></a> <span class="n">WHERE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-306"><a href="#L-306"><span class="linenos"> 306</span></a> <span class="n">WINDOW</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-307"><a href="#L-307"><span class="linenos"> 307</span></a> <span class="n">WITH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-308"><a href="#L-308"><span class="linenos"> 308</span></a> <span class="n">UNIQUE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="L-309"><a href="#L-309"><span class="linenos"> 309</span></a> </span><span id="L-310"><a href="#L-310"><span class="linenos"> 310</span></a> -</span><span id="L-311"><a href="#L-311"><span class="linenos"> 311</span></a> <span class="nd">@classmethod</span> -</span><span id="L-312"><a href="#L-312"><span class="linenos"> 312</span></a> <span class="k">def</span> <span class="nf">number</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">number</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> -</span><span id="L-313"><a href="#L-313"><span class="linenos"> 313</span></a><span class="w"> </span><span class="sd">"""Returns a NUMBER token with `number` as its text."""</span> -</span><span id="L-314"><a href="#L-314"><span class="linenos"> 314</span></a> <span class="k">return</span> <span class="bp">cls</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="nb">str</span><span class="p">(</span><span class="n">number</span><span class="p">))</span> -</span><span id="L-315"><a href="#L-315"><span class="linenos"> 315</span></a> -</span><span id="L-316"><a href="#L-316"><span class="linenos"> 316</span></a> <span class="nd">@classmethod</span> -</span><span id="L-317"><a href="#L-317"><span class="linenos"> 317</span></a> <span class="k">def</span> <span class="nf">string</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">string</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> -</span><span id="L-318"><a href="#L-318"><span class="linenos"> 318</span></a><span class="w"> </span><span class="sd">"""Returns a STRING token with `string` as its text."""</span> -</span><span id="L-319"><a href="#L-319"><span class="linenos"> 319</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">,</span> <span class="n">string</span><span class="p">)</span> -</span><span id="L-320"><a href="#L-320"><span class="linenos"> 320</span></a> -</span><span id="L-321"><a href="#L-321"><span class="linenos"> 321</span></a> <span class="nd">@classmethod</span> -</span><span id="L-322"><a href="#L-322"><span class="linenos"> 322</span></a> <span class="k">def</span> <span class="nf">identifier</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">identifier</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> -</span><span id="L-323"><a href="#L-323"><span class="linenos"> 323</span></a><span class="w"> </span><span class="sd">"""Returns an IDENTIFIER token with `identifier` as its text."""</span> -</span><span id="L-324"><a href="#L-324"><span class="linenos"> 324</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">,</span> <span class="n">identifier</span><span class="p">)</span> -</span><span id="L-325"><a href="#L-325"><span class="linenos"> 325</span></a> -</span><span id="L-326"><a href="#L-326"><span class="linenos"> 326</span></a> <span class="nd">@classmethod</span> -</span><span id="L-327"><a href="#L-327"><span class="linenos"> 327</span></a> <span class="k">def</span> <span class="nf">var</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">var</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> -</span><span id="L-328"><a href="#L-328"><span class="linenos"> 328</span></a><span class="w"> </span><span class="sd">"""Returns an VAR token with `var` as its text."""</span> -</span><span id="L-329"><a href="#L-329"><span class="linenos"> 329</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">,</span> <span class="n">var</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="k">def</span> <span class="fm">__init__</span><span class="p">(</span> -</span><span id="L-332"><a href="#L-332"><span class="linenos"> 332</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-333"><a href="#L-333"><span class="linenos"> 333</span></a> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">,</span> -</span><span id="L-334"><a href="#L-334"><span class="linenos"> 334</span></a> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="L-335"><a href="#L-335"><span class="linenos"> 335</span></a> <span class="n">line</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> -</span><span id="L-336"><a href="#L-336"><span class="linenos"> 336</span></a> <span class="n">col</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> -</span><span id="L-337"><a href="#L-337"><span class="linenos"> 337</span></a> <span class="n">start</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> -</span><span id="L-338"><a href="#L-338"><span class="linenos"> 338</span></a> <span class="n">end</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> -</span><span id="L-339"><a href="#L-339"><span class="linenos"> 339</span></a> <span class="n">comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[],</span> -</span><span id="L-340"><a href="#L-340"><span class="linenos"> 340</span></a> <span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-341"><a href="#L-341"><span class="linenos"> 341</span></a><span class="w"> </span><span class="sd">"""Token initializer.</span> -</span><span id="L-342"><a href="#L-342"><span class="linenos"> 342</span></a> -</span><span id="L-343"><a href="#L-343"><span class="linenos"> 343</span></a><span class="sd"> Args:</span> -</span><span id="L-344"><a href="#L-344"><span class="linenos"> 344</span></a><span class="sd"> token_type: The TokenType Enum.</span> -</span><span id="L-345"><a href="#L-345"><span class="linenos"> 345</span></a><span class="sd"> text: The text of the token.</span> -</span><span id="L-346"><a href="#L-346"><span class="linenos"> 346</span></a><span class="sd"> line: The line that the token ends on.</span> -</span><span id="L-347"><a href="#L-347"><span class="linenos"> 347</span></a><span class="sd"> col: The column that the token ends on.</span> -</span><span id="L-348"><a href="#L-348"><span class="linenos"> 348</span></a><span class="sd"> start: The start index of the token.</span> -</span><span id="L-349"><a href="#L-349"><span class="linenos"> 349</span></a><span class="sd"> end: The ending index of the token.</span> -</span><span id="L-350"><a href="#L-350"><span class="linenos"> 350</span></a><span class="sd"> comments: The comments to attach to the token.</span> -</span><span id="L-351"><a href="#L-351"><span class="linenos"> 351</span></a><span class="sd"> """</span> -</span><span id="L-352"><a href="#L-352"><span class="linenos"> 352</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">token_type</span> <span class="o">=</span> <span class="n">token_type</span> -</span><span id="L-353"><a href="#L-353"><span class="linenos"> 353</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">text</span> <span class="o">=</span> <span class="n">text</span> -</span><span id="L-354"><a href="#L-354"><span class="linenos"> 354</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">line</span> <span class="o">=</span> <span class="n">line</span> -</span><span id="L-355"><a href="#L-355"><span class="linenos"> 355</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">col</span> <span class="o">=</span> <span class="n">col</span> -</span><span id="L-356"><a href="#L-356"><span class="linenos"> 356</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">start</span> <span class="o">=</span> <span class="n">start</span> -</span><span id="L-357"><a href="#L-357"><span class="linenos"> 357</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">end</span> <span class="o">=</span> <span class="n">end</span> -</span><span id="L-358"><a href="#L-358"><span class="linenos"> 358</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> -</span><span id="L-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="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-361"><a href="#L-361"><span class="linenos"> 361</span></a> <span class="n">attributes</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">k</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">k</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__slots__</span><span class="p">)</span> -</span><span id="L-362"><a href="#L-362"><span class="linenos"> 362</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"<Token </span><span class="si">{</span><span class="n">attributes</span><span class="si">}</span><span class="s2">>"</span> -</span><span id="L-363"><a href="#L-363"><span class="linenos"> 363</span></a> -</span><span id="L-364"><a href="#L-364"><span class="linenos"> 364</span></a> -</span><span id="L-365"><a href="#L-365"><span class="linenos"> 365</span></a><span class="k">class</span> <span class="nc">_Tokenizer</span><span class="p">(</span><span class="nb">type</span><span class="p">):</span> -</span><span id="L-366"><a href="#L-366"><span class="linenos"> 366</span></a> <span class="k">def</span> <span class="fm">__new__</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">clsname</span><span class="p">,</span> <span class="n">bases</span><span class="p">,</span> <span class="n">attrs</span><span class="p">):</span> -</span><span id="L-367"><a href="#L-367"><span class="linenos"> 367</span></a> <span class="n">klass</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__new__</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">clsname</span><span class="p">,</span> <span class="n">bases</span><span class="p">,</span> <span class="n">attrs</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">def</span> <span class="nf">_convert_quotes</span><span class="p">(</span><span class="n">arr</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]:</span> -</span><span id="L-370"><a href="#L-370"><span class="linenos"> 370</span></a> <span class="k">return</span> <span class="nb">dict</span><span class="p">(</span> -</span><span id="L-371"><a href="#L-371"><span class="linenos"> 371</span></a> <span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">item</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="nb">str</span><span class="p">)</span> <span class="k">else</span> <span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">item</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">arr</span> -</span><span id="L-372"><a href="#L-372"><span class="linenos"> 372</span></a> <span class="p">)</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">_quotes_to_format</span><span class="p">(</span> -</span><span id="L-375"><a href="#L-375"><span class="linenos"> 375</span></a> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">,</span> <span class="n">arr</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> -</span><span id="L-376"><a href="#L-376"><span class="linenos"> 376</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">TokenType</span><span class="p">]]:</span> -</span><span id="L-377"><a href="#L-377"><span class="linenos"> 377</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">token_type</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">_convert_quotes</span><span class="p">(</span><span class="n">arr</span><span class="p">)</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span> -</span><span id="L-378"><a href="#L-378"><span class="linenos"> 378</span></a> -</span><span id="L-379"><a href="#L-379"><span class="linenos"> 379</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">_QUOTES</span> <span class="o">=</span> <span class="n">_convert_quotes</span><span class="p">(</span><span class="n">klass</span><span class="o">.</span><span class="n">QUOTES</span><span class="p">)</span> -</span><span id="L-380"><a href="#L-380"><span class="linenos"> 380</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">_IDENTIFIERS</span> <span class="o">=</span> <span class="n">_convert_quotes</span><span class="p">(</span><span class="n">klass</span><span class="o">.</span><span class="n">IDENTIFIERS</span><span class="p">)</span> +</span><span id="L-311"><a href="#L-311"><span class="linenos"> 311</span></a><span class="k">class</span> <span class="nc">Token</span><span class="p">:</span> +</span><span id="L-312"><a href="#L-312"><span class="linenos"> 312</span></a> <span class="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"token_type"</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">,</span> <span class="s2">"line"</span><span class="p">,</span> <span class="s2">"col"</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">,</span> <span class="s2">"end"</span><span class="p">,</span> <span class="s2">"comments"</span><span class="p">)</span> +</span><span id="L-313"><a href="#L-313"><span class="linenos"> 313</span></a> +</span><span id="L-314"><a href="#L-314"><span class="linenos"> 314</span></a> <span class="nd">@classmethod</span> +</span><span id="L-315"><a href="#L-315"><span class="linenos"> 315</span></a> <span class="k">def</span> <span class="nf">number</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">number</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> +</span><span id="L-316"><a href="#L-316"><span class="linenos"> 316</span></a><span class="w"> </span><span class="sd">"""Returns a NUMBER token with `number` as its text."""</span> +</span><span id="L-317"><a href="#L-317"><span class="linenos"> 317</span></a> <span class="k">return</span> <span class="bp">cls</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="nb">str</span><span class="p">(</span><span class="n">number</span><span class="p">))</span> +</span><span id="L-318"><a href="#L-318"><span class="linenos"> 318</span></a> +</span><span id="L-319"><a href="#L-319"><span class="linenos"> 319</span></a> <span class="nd">@classmethod</span> +</span><span id="L-320"><a href="#L-320"><span class="linenos"> 320</span></a> <span class="k">def</span> <span class="nf">string</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">string</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> +</span><span id="L-321"><a href="#L-321"><span class="linenos"> 321</span></a><span class="w"> </span><span class="sd">"""Returns a STRING token with `string` as its text."""</span> +</span><span id="L-322"><a href="#L-322"><span class="linenos"> 322</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">,</span> <span class="n">string</span><span class="p">)</span> +</span><span id="L-323"><a href="#L-323"><span class="linenos"> 323</span></a> +</span><span id="L-324"><a href="#L-324"><span class="linenos"> 324</span></a> <span class="nd">@classmethod</span> +</span><span id="L-325"><a href="#L-325"><span class="linenos"> 325</span></a> <span class="k">def</span> <span class="nf">identifier</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">identifier</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> +</span><span id="L-326"><a href="#L-326"><span class="linenos"> 326</span></a><span class="w"> </span><span class="sd">"""Returns an IDENTIFIER token with `identifier` as its text."""</span> +</span><span id="L-327"><a href="#L-327"><span class="linenos"> 327</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">,</span> <span class="n">identifier</span><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="nd">@classmethod</span> +</span><span id="L-330"><a href="#L-330"><span class="linenos"> 330</span></a> <span class="k">def</span> <span class="nf">var</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">var</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> +</span><span id="L-331"><a href="#L-331"><span class="linenos"> 331</span></a><span class="w"> </span><span class="sd">"""Returns an VAR token with `var` as its text."""</span> +</span><span id="L-332"><a href="#L-332"><span class="linenos"> 332</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">,</span> <span class="n">var</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="k">def</span> <span class="fm">__init__</span><span class="p">(</span> +</span><span id="L-335"><a href="#L-335"><span class="linenos"> 335</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-336"><a href="#L-336"><span class="linenos"> 336</span></a> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">,</span> +</span><span id="L-337"><a href="#L-337"><span class="linenos"> 337</span></a> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="L-338"><a href="#L-338"><span class="linenos"> 338</span></a> <span class="n">line</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> +</span><span id="L-339"><a href="#L-339"><span class="linenos"> 339</span></a> <span class="n">col</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> +</span><span id="L-340"><a href="#L-340"><span class="linenos"> 340</span></a> <span class="n">start</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> +</span><span id="L-341"><a href="#L-341"><span class="linenos"> 341</span></a> <span class="n">end</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> +</span><span id="L-342"><a href="#L-342"><span class="linenos"> 342</span></a> <span class="n">comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[],</span> +</span><span id="L-343"><a href="#L-343"><span class="linenos"> 343</span></a> <span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-344"><a href="#L-344"><span class="linenos"> 344</span></a><span class="w"> </span><span class="sd">"""Token initializer.</span> +</span><span id="L-345"><a href="#L-345"><span class="linenos"> 345</span></a> +</span><span id="L-346"><a href="#L-346"><span class="linenos"> 346</span></a><span class="sd"> Args:</span> +</span><span id="L-347"><a href="#L-347"><span class="linenos"> 347</span></a><span class="sd"> token_type: The TokenType Enum.</span> +</span><span id="L-348"><a href="#L-348"><span class="linenos"> 348</span></a><span class="sd"> text: The text of the token.</span> +</span><span id="L-349"><a href="#L-349"><span class="linenos"> 349</span></a><span class="sd"> line: The line that the token ends on.</span> +</span><span id="L-350"><a href="#L-350"><span class="linenos"> 350</span></a><span class="sd"> col: The column that the token ends on.</span> +</span><span id="L-351"><a href="#L-351"><span class="linenos"> 351</span></a><span class="sd"> start: The start index of the token.</span> +</span><span id="L-352"><a href="#L-352"><span class="linenos"> 352</span></a><span class="sd"> end: The ending index of the token.</span> +</span><span id="L-353"><a href="#L-353"><span class="linenos"> 353</span></a><span class="sd"> comments: The comments to attach to the token.</span> +</span><span id="L-354"><a href="#L-354"><span class="linenos"> 354</span></a><span class="sd"> """</span> +</span><span id="L-355"><a href="#L-355"><span class="linenos"> 355</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">token_type</span> <span class="o">=</span> <span class="n">token_type</span> +</span><span id="L-356"><a href="#L-356"><span class="linenos"> 356</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">text</span> <span class="o">=</span> <span class="n">text</span> +</span><span id="L-357"><a href="#L-357"><span class="linenos"> 357</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">line</span> <span class="o">=</span> <span class="n">line</span> +</span><span id="L-358"><a href="#L-358"><span class="linenos"> 358</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">col</span> <span class="o">=</span> <span class="n">col</span> +</span><span id="L-359"><a href="#L-359"><span class="linenos"> 359</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">start</span> <span class="o">=</span> <span class="n">start</span> +</span><span id="L-360"><a href="#L-360"><span class="linenos"> 360</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">end</span> <span class="o">=</span> <span class="n">end</span> +</span><span id="L-361"><a href="#L-361"><span class="linenos"> 361</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> +</span><span id="L-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">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-364"><a href="#L-364"><span class="linenos"> 364</span></a> <span class="n">attributes</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">k</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">k</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__slots__</span><span class="p">)</span> +</span><span id="L-365"><a href="#L-365"><span class="linenos"> 365</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"<Token </span><span class="si">{</span><span class="n">attributes</span><span class="si">}</span><span class="s2">>"</span> +</span><span id="L-366"><a href="#L-366"><span class="linenos"> 366</span></a> +</span><span id="L-367"><a href="#L-367"><span class="linenos"> 367</span></a> +</span><span id="L-368"><a href="#L-368"><span class="linenos"> 368</span></a><span class="k">class</span> <span class="nc">_Tokenizer</span><span class="p">(</span><span class="nb">type</span><span class="p">):</span> +</span><span id="L-369"><a href="#L-369"><span class="linenos"> 369</span></a> <span class="k">def</span> <span class="fm">__new__</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">clsname</span><span class="p">,</span> <span class="n">bases</span><span class="p">,</span> <span class="n">attrs</span><span class="p">):</span> +</span><span id="L-370"><a href="#L-370"><span class="linenos"> 370</span></a> <span class="n">klass</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__new__</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">clsname</span><span class="p">,</span> <span class="n">bases</span><span class="p">,</span> <span class="n">attrs</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">def</span> <span class="nf">_convert_quotes</span><span class="p">(</span><span class="n">arr</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]])</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]:</span> +</span><span id="L-373"><a href="#L-373"><span class="linenos"> 373</span></a> <span class="k">return</span> <span class="nb">dict</span><span class="p">(</span> +</span><span id="L-374"><a href="#L-374"><span class="linenos"> 374</span></a> <span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">item</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="nb">str</span><span class="p">)</span> <span class="k">else</span> <span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">item</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">arr</span> +</span><span id="L-375"><a href="#L-375"><span class="linenos"> 375</span></a> <span class="p">)</span> +</span><span id="L-376"><a href="#L-376"><span class="linenos"> 376</span></a> +</span><span id="L-377"><a href="#L-377"><span class="linenos"> 377</span></a> <span class="k">def</span> <span class="nf">_quotes_to_format</span><span class="p">(</span> +</span><span id="L-378"><a href="#L-378"><span class="linenos"> 378</span></a> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">,</span> <span class="n">arr</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> +</span><span id="L-379"><a href="#L-379"><span class="linenos"> 379</span></a> <span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">TokenType</span><span class="p">]]:</span> +</span><span id="L-380"><a href="#L-380"><span class="linenos"> 380</span></a> <span class="k">return</span> <span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">token_type</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">_convert_quotes</span><span class="p">(</span><span class="n">arr</span><span class="p">)</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span> </span><span id="L-381"><a href="#L-381"><span class="linenos"> 381</span></a> -</span><span id="L-382"><a href="#L-382"><span class="linenos"> 382</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">_FORMAT_STRINGS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-383"><a href="#L-383"><span class="linenos"> 383</span></a> <span class="o">**</span><span class="p">{</span> -</span><span id="L-384"><a href="#L-384"><span class="linenos"> 384</span></a> <span class="n">p</span> <span class="o">+</span> <span class="n">s</span><span class="p">:</span> <span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NATIONAL_STRING</span><span class="p">)</span> -</span><span id="L-385"><a href="#L-385"><span class="linenos"> 385</span></a> <span class="k">for</span> <span class="n">s</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">klass</span><span class="o">.</span><span class="n">_QUOTES</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> -</span><span id="L-386"><a href="#L-386"><span class="linenos"> 386</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"n"</span><span class="p">,</span> <span class="s2">"N"</span><span class="p">)</span> -</span><span id="L-387"><a href="#L-387"><span class="linenos"> 387</span></a> <span class="p">},</span> -</span><span id="L-388"><a href="#L-388"><span class="linenos"> 388</span></a> <span class="o">**</span><span class="n">_quotes_to_format</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">BIT_STRING</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">BIT_STRINGS</span><span class="p">),</span> -</span><span id="L-389"><a href="#L-389"><span class="linenos"> 389</span></a> <span class="o">**</span><span class="n">_quotes_to_format</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">BYTE_STRING</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">BYTE_STRINGS</span><span class="p">),</span> -</span><span id="L-390"><a href="#L-390"><span class="linenos"> 390</span></a> <span class="o">**</span><span class="n">_quotes_to_format</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">HEX_STRING</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">HEX_STRINGS</span><span class="p">),</span> -</span><span id="L-391"><a href="#L-391"><span class="linenos"> 391</span></a> <span class="o">**</span><span class="n">_quotes_to_format</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">RAW_STRING</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">RAW_STRINGS</span><span class="p">),</span> -</span><span id="L-392"><a href="#L-392"><span class="linenos"> 392</span></a> <span class="p">}</span> -</span><span id="L-393"><a href="#L-393"><span class="linenos"> 393</span></a> -</span><span id="L-394"><a href="#L-394"><span class="linenos"> 394</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">_STRING_ESCAPES</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">klass</span><span class="o">.</span><span class="n">STRING_ESCAPES</span><span class="p">)</span> -</span><span id="L-395"><a href="#L-395"><span class="linenos"> 395</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">_IDENTIFIER_ESCAPES</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">klass</span><span class="o">.</span><span class="n">IDENTIFIER_ESCAPES</span><span class="p">)</span> -</span><span id="L-396"><a href="#L-396"><span class="linenos"> 396</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">_COMMENTS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-397"><a href="#L-397"><span class="linenos"> 397</span></a> <span class="o">**</span><span class="nb">dict</span><span class="p">(</span> -</span><span id="L-398"><a href="#L-398"><span class="linenos"> 398</span></a> <span class="p">(</span><span class="n">comment</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">comment</span><span class="p">,</span> <span class="nb">str</span><span class="p">)</span> <span class="k">else</span> <span class="p">(</span><span class="n">comment</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">comment</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> -</span><span id="L-399"><a href="#L-399"><span class="linenos"> 399</span></a> <span class="k">for</span> <span class="n">comment</span> <span class="ow">in</span> <span class="n">klass</span><span class="o">.</span><span class="n">COMMENTS</span> -</span><span id="L-400"><a href="#L-400"><span class="linenos"> 400</span></a> <span class="p">),</span> -</span><span id="L-401"><a href="#L-401"><span class="linenos"> 401</span></a> <span class="s2">"{#"</span><span class="p">:</span> <span class="s2">"#}"</span><span class="p">,</span> <span class="c1"># Ensure Jinja comments are tokenized correctly in all dialects</span> -</span><span id="L-402"><a href="#L-402"><span class="linenos"> 402</span></a> <span class="p">}</span> -</span><span id="L-403"><a href="#L-403"><span class="linenos"> 403</span></a> -</span><span id="L-404"><a href="#L-404"><span class="linenos"> 404</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">_KEYWORD_TRIE</span> <span class="o">=</span> <span class="n">new_trie</span><span class="p">(</span> -</span><span id="L-405"><a href="#L-405"><span class="linenos"> 405</span></a> <span class="n">key</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-406"><a href="#L-406"><span class="linenos"> 406</span></a> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="p">(</span> -</span><span id="L-407"><a href="#L-407"><span class="linenos"> 407</span></a> <span class="o">*</span><span class="n">klass</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span> -</span><span id="L-408"><a href="#L-408"><span class="linenos"> 408</span></a> <span class="o">*</span><span class="n">klass</span><span class="o">.</span><span class="n">_COMMENTS</span><span class="p">,</span> -</span><span id="L-409"><a href="#L-409"><span class="linenos"> 409</span></a> <span class="o">*</span><span class="n">klass</span><span class="o">.</span><span class="n">_QUOTES</span><span class="p">,</span> -</span><span id="L-410"><a href="#L-410"><span class="linenos"> 410</span></a> <span class="o">*</span><span class="n">klass</span><span class="o">.</span><span class="n">_FORMAT_STRINGS</span><span class="p">,</span> -</span><span id="L-411"><a href="#L-411"><span class="linenos"> 411</span></a> <span class="p">)</span> -</span><span id="L-412"><a href="#L-412"><span class="linenos"> 412</span></a> <span class="k">if</span> <span class="s2">" "</span> <span class="ow">in</span> <span class="n">key</span> <span class="ow">or</span> <span class="nb">any</span><span class="p">(</span><span class="n">single</span> <span class="ow">in</span> <span class="n">key</span> <span class="k">for</span> <span class="n">single</span> <span class="ow">in</span> <span class="n">klass</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">)</span> -</span><span id="L-413"><a href="#L-413"><span class="linenos"> 413</span></a> <span class="p">)</span> -</span><span id="L-414"><a href="#L-414"><span class="linenos"> 414</span></a> -</span><span id="L-415"><a href="#L-415"><span class="linenos"> 415</span></a> <span class="k">return</span> <span class="n">klass</span> -</span><span id="L-416"><a href="#L-416"><span class="linenos"> 416</span></a> +</span><span id="L-382"><a href="#L-382"><span class="linenos"> 382</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">_QUOTES</span> <span class="o">=</span> <span class="n">_convert_quotes</span><span class="p">(</span><span class="n">klass</span><span class="o">.</span><span class="n">QUOTES</span><span class="p">)</span> +</span><span id="L-383"><a href="#L-383"><span class="linenos"> 383</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">_IDENTIFIERS</span> <span class="o">=</span> <span class="n">_convert_quotes</span><span class="p">(</span><span class="n">klass</span><span class="o">.</span><span class="n">IDENTIFIERS</span><span class="p">)</span> +</span><span id="L-384"><a href="#L-384"><span class="linenos"> 384</span></a> +</span><span id="L-385"><a href="#L-385"><span class="linenos"> 385</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">_FORMAT_STRINGS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-386"><a href="#L-386"><span class="linenos"> 386</span></a> <span class="o">**</span><span class="p">{</span> +</span><span id="L-387"><a href="#L-387"><span class="linenos"> 387</span></a> <span class="n">p</span> <span class="o">+</span> <span class="n">s</span><span class="p">:</span> <span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NATIONAL_STRING</span><span class="p">)</span> +</span><span id="L-388"><a href="#L-388"><span class="linenos"> 388</span></a> <span class="k">for</span> <span class="n">s</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">klass</span><span class="o">.</span><span class="n">_QUOTES</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> +</span><span id="L-389"><a href="#L-389"><span class="linenos"> 389</span></a> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"n"</span><span class="p">,</span> <span class="s2">"N"</span><span class="p">)</span> +</span><span id="L-390"><a href="#L-390"><span class="linenos"> 390</span></a> <span class="p">},</span> +</span><span id="L-391"><a href="#L-391"><span class="linenos"> 391</span></a> <span class="o">**</span><span class="n">_quotes_to_format</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">BIT_STRING</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">BIT_STRINGS</span><span class="p">),</span> +</span><span id="L-392"><a href="#L-392"><span class="linenos"> 392</span></a> <span class="o">**</span><span class="n">_quotes_to_format</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">BYTE_STRING</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">BYTE_STRINGS</span><span class="p">),</span> +</span><span id="L-393"><a href="#L-393"><span class="linenos"> 393</span></a> <span class="o">**</span><span class="n">_quotes_to_format</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">HEX_STRING</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">HEX_STRINGS</span><span class="p">),</span> +</span><span id="L-394"><a href="#L-394"><span class="linenos"> 394</span></a> <span class="o">**</span><span class="n">_quotes_to_format</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">RAW_STRING</span><span class="p">,</span> <span class="n">klass</span><span class="o">.</span><span class="n">RAW_STRINGS</span><span class="p">),</span> +</span><span id="L-395"><a href="#L-395"><span class="linenos"> 395</span></a> <span class="p">}</span> +</span><span id="L-396"><a href="#L-396"><span class="linenos"> 396</span></a> +</span><span id="L-397"><a href="#L-397"><span class="linenos"> 397</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">_STRING_ESCAPES</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">klass</span><span class="o">.</span><span class="n">STRING_ESCAPES</span><span class="p">)</span> +</span><span id="L-398"><a href="#L-398"><span class="linenos"> 398</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">_IDENTIFIER_ESCAPES</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">klass</span><span class="o">.</span><span class="n">IDENTIFIER_ESCAPES</span><span class="p">)</span> +</span><span id="L-399"><a href="#L-399"><span class="linenos"> 399</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">_COMMENTS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-400"><a href="#L-400"><span class="linenos"> 400</span></a> <span class="o">**</span><span class="nb">dict</span><span class="p">(</span> +</span><span id="L-401"><a href="#L-401"><span class="linenos"> 401</span></a> <span class="p">(</span><span class="n">comment</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">comment</span><span class="p">,</span> <span class="nb">str</span><span class="p">)</span> <span class="k">else</span> <span class="p">(</span><span class="n">comment</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">comment</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> +</span><span id="L-402"><a href="#L-402"><span class="linenos"> 402</span></a> <span class="k">for</span> <span class="n">comment</span> <span class="ow">in</span> <span class="n">klass</span><span class="o">.</span><span class="n">COMMENTS</span> +</span><span id="L-403"><a href="#L-403"><span class="linenos"> 403</span></a> <span class="p">),</span> +</span><span id="L-404"><a href="#L-404"><span class="linenos"> 404</span></a> <span class="s2">"{#"</span><span class="p">:</span> <span class="s2">"#}"</span><span class="p">,</span> <span class="c1"># Ensure Jinja comments are tokenized correctly in all dialects</span> +</span><span id="L-405"><a href="#L-405"><span class="linenos"> 405</span></a> <span class="p">}</span> +</span><span id="L-406"><a href="#L-406"><span class="linenos"> 406</span></a> +</span><span id="L-407"><a href="#L-407"><span class="linenos"> 407</span></a> <span class="n">klass</span><span class="o">.</span><span class="n">_KEYWORD_TRIE</span> <span class="o">=</span> <span class="n">new_trie</span><span class="p">(</span> +</span><span id="L-408"><a href="#L-408"><span class="linenos"> 408</span></a> <span class="n">key</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-409"><a href="#L-409"><span class="linenos"> 409</span></a> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="p">(</span> +</span><span id="L-410"><a href="#L-410"><span class="linenos"> 410</span></a> <span class="o">*</span><span class="n">klass</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">,</span> +</span><span id="L-411"><a href="#L-411"><span class="linenos"> 411</span></a> <span class="o">*</span><span class="n">klass</span><span class="o">.</span><span class="n">_COMMENTS</span><span class="p">,</span> +</span><span id="L-412"><a href="#L-412"><span class="linenos"> 412</span></a> <span class="o">*</span><span class="n">klass</span><span class="o">.</span><span class="n">_QUOTES</span><span class="p">,</span> +</span><span id="L-413"><a href="#L-413"><span class="linenos"> 413</span></a> <span class="o">*</span><span class="n">klass</span><span class="o">.</span><span class="n">_FORMAT_STRINGS</span><span class="p">,</span> +</span><span id="L-414"><a href="#L-414"><span class="linenos"> 414</span></a> <span class="p">)</span> +</span><span id="L-415"><a href="#L-415"><span class="linenos"> 415</span></a> <span class="k">if</span> <span class="s2">" "</span> <span class="ow">in</span> <span class="n">key</span> <span class="ow">or</span> <span class="nb">any</span><span class="p">(</span><span class="n">single</span> <span class="ow">in</span> <span class="n">key</span> <span class="k">for</span> <span class="n">single</span> <span class="ow">in</span> <span class="n">klass</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">)</span> +</span><span id="L-416"><a href="#L-416"><span class="linenos"> 416</span></a> <span class="p">)</span> </span><span id="L-417"><a href="#L-417"><span class="linenos"> 417</span></a> -</span><span id="L-418"><a href="#L-418"><span class="linenos"> 418</span></a><span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">metaclass</span><span class="o">=</span><span class="n">_Tokenizer</span><span class="p">):</span> -</span><span id="L-419"><a href="#L-419"><span class="linenos"> 419</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-420"><a href="#L-420"><span class="linenos"> 420</span></a> <span class="s2">"("</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">,</span> -</span><span id="L-421"><a href="#L-421"><span class="linenos"> 421</span></a> <span class="s2">")"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_PAREN</span><span class="p">,</span> -</span><span id="L-422"><a href="#L-422"><span class="linenos"> 422</span></a> <span class="s2">"["</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">,</span> -</span><span id="L-423"><a href="#L-423"><span class="linenos"> 423</span></a> <span class="s2">"]"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACKET</span><span class="p">,</span> -</span><span id="L-424"><a href="#L-424"><span class="linenos"> 424</span></a> <span class="s2">"{"</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><span id="L-425"><a href="#L-425"><span class="linenos"> 425</span></a> <span class="s2">"}"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACE</span><span class="p">,</span> -</span><span id="L-426"><a href="#L-426"><span class="linenos"> 426</span></a> <span class="s2">"&"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">AMP</span><span class="p">,</span> -</span><span id="L-427"><a href="#L-427"><span class="linenos"> 427</span></a> <span class="s2">"^"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CARET</span><span class="p">,</span> -</span><span id="L-428"><a href="#L-428"><span class="linenos"> 428</span></a> <span class="s2">":"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLON</span><span class="p">,</span> -</span><span id="L-429"><a href="#L-429"><span class="linenos"> 429</span></a> <span class="s2">","</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMA</span><span class="p">,</span> -</span><span id="L-430"><a href="#L-430"><span class="linenos"> 430</span></a> <span class="s2">"."</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOT</span><span class="p">,</span> -</span><span id="L-431"><a href="#L-431"><span class="linenos"> 431</span></a> <span class="s2">"-"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DASH</span><span class="p">,</span> -</span><span id="L-432"><a href="#L-432"><span class="linenos"> 432</span></a> <span class="s2">"="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> -</span><span id="L-433"><a href="#L-433"><span class="linenos"> 433</span></a> <span class="s2">">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GT</span><span class="p">,</span> -</span><span id="L-434"><a href="#L-434"><span class="linenos"> 434</span></a> <span class="s2">"<"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LT</span><span class="p">,</span> -</span><span id="L-435"><a href="#L-435"><span class="linenos"> 435</span></a> <span class="s2">"%"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MOD</span><span class="p">,</span> -</span><span id="L-436"><a href="#L-436"><span class="linenos"> 436</span></a> <span class="s2">"!"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NOT</span><span class="p">,</span> -</span><span id="L-437"><a href="#L-437"><span class="linenos"> 437</span></a> <span class="s2">"|"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PIPE</span><span class="p">,</span> -</span><span id="L-438"><a href="#L-438"><span class="linenos"> 438</span></a> <span class="s2">"+"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PLUS</span><span class="p">,</span> -</span><span id="L-439"><a href="#L-439"><span class="linenos"> 439</span></a> <span class="s2">";"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SEMICOLON</span><span class="p">,</span> -</span><span id="L-440"><a href="#L-440"><span class="linenos"> 440</span></a> <span class="s2">"/"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SLASH</span><span class="p">,</span> -</span><span id="L-441"><a href="#L-441"><span class="linenos"> 441</span></a> <span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BACKSLASH</span><span class="p">,</span> -</span><span id="L-442"><a href="#L-442"><span class="linenos"> 442</span></a> <span class="s2">"*"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STAR</span><span class="p">,</span> -</span><span id="L-443"><a href="#L-443"><span class="linenos"> 443</span></a> <span class="s2">"~"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TILDA</span><span class="p">,</span> -</span><span id="L-444"><a href="#L-444"><span class="linenos"> 444</span></a> <span class="s2">"?"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PLACEHOLDER</span><span class="p">,</span> -</span><span id="L-445"><a href="#L-445"><span class="linenos"> 445</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-446"><a href="#L-446"><span class="linenos"> 446</span></a> <span class="c1"># used for breaking a var like x'y' but nothing else</span> -</span><span id="L-447"><a href="#L-447"><span class="linenos"> 447</span></a> <span class="c1"># the token type doesn't matter</span> -</span><span id="L-448"><a href="#L-448"><span class="linenos"> 448</span></a> <span class="s2">"'"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">QUOTE</span><span class="p">,</span> -</span><span id="L-449"><a href="#L-449"><span class="linenos"> 449</span></a> <span class="s2">"`"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">,</span> -</span><span id="L-450"><a href="#L-450"><span class="linenos"> 450</span></a> <span class="s1">'"'</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">,</span> -</span><span id="L-451"><a href="#L-451"><span class="linenos"> 451</span></a> <span class="s2">"#"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HASH</span><span class="p">,</span> -</span><span id="L-452"><a href="#L-452"><span class="linenos"> 452</span></a> <span class="p">}</span> -</span><span id="L-453"><a href="#L-453"><span class="linenos"> 453</span></a> -</span><span id="L-454"><a href="#L-454"><span class="linenos"> 454</span></a> <span class="n">BIT_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-455"><a href="#L-455"><span class="linenos"> 455</span></a> <span class="n">BYTE_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-456"><a href="#L-456"><span class="linenos"> 456</span></a> <span class="n">HEX_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-457"><a href="#L-457"><span class="linenos"> 457</span></a> <span class="n">RAW_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-458"><a href="#L-458"><span class="linenos"> 458</span></a> <span class="n">IDENTIFIERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'"'</span><span class="p">]</span> -</span><span id="L-459"><a href="#L-459"><span class="linenos"> 459</span></a> <span class="n">IDENTIFIER_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'"'</span><span class="p">]</span> -</span><span id="L-460"><a href="#L-460"><span class="linenos"> 460</span></a> <span class="n">QUOTES</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">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">|</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">]</span> -</span><span id="L-461"><a href="#L-461"><span class="linenos"> 461</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">]</span> -</span><span id="L-462"><a href="#L-462"><span class="linenos"> 462</span></a> <span class="n">VAR_SINGLE_TOKENS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> -</span><span id="L-463"><a href="#L-463"><span class="linenos"> 463</span></a> -</span><span id="L-464"><a href="#L-464"><span class="linenos"> 464</span></a> <span class="c1"># Autofilled</span> -</span><span id="L-465"><a href="#L-465"><span class="linenos"> 465</span></a> <span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-418"><a href="#L-418"><span class="linenos"> 418</span></a> <span class="k">return</span> <span class="n">klass</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><span id="L-421"><a href="#L-421"><span class="linenos"> 421</span></a><span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">metaclass</span><span class="o">=</span><span class="n">_Tokenizer</span><span class="p">):</span> +</span><span id="L-422"><a href="#L-422"><span class="linenos"> 422</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-423"><a href="#L-423"><span class="linenos"> 423</span></a> <span class="s2">"("</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">,</span> +</span><span id="L-424"><a href="#L-424"><span class="linenos"> 424</span></a> <span class="s2">")"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_PAREN</span><span class="p">,</span> +</span><span id="L-425"><a href="#L-425"><span class="linenos"> 425</span></a> <span class="s2">"["</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">,</span> +</span><span id="L-426"><a href="#L-426"><span class="linenos"> 426</span></a> <span class="s2">"]"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACKET</span><span class="p">,</span> +</span><span id="L-427"><a href="#L-427"><span class="linenos"> 427</span></a> <span class="s2">"{"</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><span id="L-428"><a href="#L-428"><span class="linenos"> 428</span></a> <span class="s2">"}"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACE</span><span class="p">,</span> +</span><span id="L-429"><a href="#L-429"><span class="linenos"> 429</span></a> <span class="s2">"&"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">AMP</span><span class="p">,</span> +</span><span id="L-430"><a href="#L-430"><span class="linenos"> 430</span></a> <span class="s2">"^"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CARET</span><span class="p">,</span> +</span><span id="L-431"><a href="#L-431"><span class="linenos"> 431</span></a> <span class="s2">":"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLON</span><span class="p">,</span> +</span><span id="L-432"><a href="#L-432"><span class="linenos"> 432</span></a> <span class="s2">","</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMA</span><span class="p">,</span> +</span><span id="L-433"><a href="#L-433"><span class="linenos"> 433</span></a> <span class="s2">"."</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOT</span><span class="p">,</span> +</span><span id="L-434"><a href="#L-434"><span class="linenos"> 434</span></a> <span class="s2">"-"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DASH</span><span class="p">,</span> +</span><span id="L-435"><a href="#L-435"><span class="linenos"> 435</span></a> <span class="s2">"="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> +</span><span id="L-436"><a href="#L-436"><span class="linenos"> 436</span></a> <span class="s2">">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GT</span><span class="p">,</span> +</span><span id="L-437"><a href="#L-437"><span class="linenos"> 437</span></a> <span class="s2">"<"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LT</span><span class="p">,</span> +</span><span id="L-438"><a href="#L-438"><span class="linenos"> 438</span></a> <span class="s2">"%"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MOD</span><span class="p">,</span> +</span><span id="L-439"><a href="#L-439"><span class="linenos"> 439</span></a> <span class="s2">"!"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NOT</span><span class="p">,</span> +</span><span id="L-440"><a href="#L-440"><span class="linenos"> 440</span></a> <span class="s2">"|"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PIPE</span><span class="p">,</span> +</span><span id="L-441"><a href="#L-441"><span class="linenos"> 441</span></a> <span class="s2">"+"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PLUS</span><span class="p">,</span> +</span><span id="L-442"><a href="#L-442"><span class="linenos"> 442</span></a> <span class="s2">";"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SEMICOLON</span><span class="p">,</span> +</span><span id="L-443"><a href="#L-443"><span class="linenos"> 443</span></a> <span class="s2">"/"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SLASH</span><span class="p">,</span> +</span><span id="L-444"><a href="#L-444"><span class="linenos"> 444</span></a> <span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BACKSLASH</span><span class="p">,</span> +</span><span id="L-445"><a href="#L-445"><span class="linenos"> 445</span></a> <span class="s2">"*"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STAR</span><span class="p">,</span> +</span><span id="L-446"><a href="#L-446"><span class="linenos"> 446</span></a> <span class="s2">"~"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TILDA</span><span class="p">,</span> +</span><span id="L-447"><a href="#L-447"><span class="linenos"> 447</span></a> <span class="s2">"?"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PLACEHOLDER</span><span class="p">,</span> +</span><span id="L-448"><a href="#L-448"><span class="linenos"> 448</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-449"><a href="#L-449"><span class="linenos"> 449</span></a> <span class="c1"># used for breaking a var like x'y' but nothing else</span> +</span><span id="L-450"><a href="#L-450"><span class="linenos"> 450</span></a> <span class="c1"># the token type doesn't matter</span> +</span><span id="L-451"><a href="#L-451"><span class="linenos"> 451</span></a> <span class="s2">"'"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">QUOTE</span><span class="p">,</span> +</span><span id="L-452"><a href="#L-452"><span class="linenos"> 452</span></a> <span class="s2">"`"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">,</span> +</span><span id="L-453"><a href="#L-453"><span class="linenos"> 453</span></a> <span class="s1">'"'</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">,</span> +</span><span id="L-454"><a href="#L-454"><span class="linenos"> 454</span></a> <span class="s2">"#"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HASH</span><span class="p">,</span> +</span><span id="L-455"><a href="#L-455"><span class="linenos"> 455</span></a> <span class="p">}</span> +</span><span id="L-456"><a href="#L-456"><span class="linenos"> 456</span></a> +</span><span id="L-457"><a href="#L-457"><span class="linenos"> 457</span></a> <span class="n">BIT_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-458"><a href="#L-458"><span class="linenos"> 458</span></a> <span class="n">BYTE_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-459"><a href="#L-459"><span class="linenos"> 459</span></a> <span class="n">HEX_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-460"><a href="#L-460"><span class="linenos"> 460</span></a> <span class="n">RAW_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-461"><a href="#L-461"><span class="linenos"> 461</span></a> <span class="n">IDENTIFIERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'"'</span><span class="p">]</span> +</span><span id="L-462"><a href="#L-462"><span class="linenos"> 462</span></a> <span class="n">IDENTIFIER_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'"'</span><span class="p">]</span> +</span><span id="L-463"><a href="#L-463"><span class="linenos"> 463</span></a> <span class="n">QUOTES</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">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">|</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">]</span> +</span><span id="L-464"><a href="#L-464"><span class="linenos"> 464</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">]</span> +</span><span id="L-465"><a href="#L-465"><span class="linenos"> 465</span></a> <span class="n">VAR_SINGLE_TOKENS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> </span><span id="L-466"><a href="#L-466"><span class="linenos"> 466</span></a> -</span><span id="L-467"><a href="#L-467"><span class="linenos"> 467</span></a> <span class="n">_COMMENTS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-468"><a href="#L-468"><span class="linenos"> 468</span></a> <span class="n">_FORMAT_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-469"><a href="#L-469"><span class="linenos"> 469</span></a> <span class="n">_IDENTIFIERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-470"><a href="#L-470"><span class="linenos"> 470</span></a> <span class="n">_IDENTIFIER_ESCAPES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> -</span><span id="L-471"><a href="#L-471"><span class="linenos"> 471</span></a> <span class="n">_QUOTES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-472"><a href="#L-472"><span class="linenos"> 472</span></a> <span class="n">_STRING_ESCAPES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> -</span><span id="L-473"><a href="#L-473"><span class="linenos"> 473</span></a> <span class="n">_KEYWORD_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-474"><a href="#L-474"><span class="linenos"> 474</span></a> -</span><span id="L-475"><a href="#L-475"><span class="linenos"> 475</span></a> <span class="n">KEYWORDS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">TokenType</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-476"><a href="#L-476"><span class="linenos"> 476</span></a> <span class="o">**</span><span class="p">{</span><span class="sa">f</span><span class="s2">"</span><span class="se">{{</span><span class="s2">%</span><span class="si">{</span><span class="n">postfix</span><span class="si">}</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BLOCK_START</span> <span class="k">for</span> <span class="n">postfix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">""</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-477"><a href="#L-477"><span class="linenos"> 477</span></a> <span class="o">**</span><span class="p">{</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}</span><span class="s2">%</span><span class="se">}}</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BLOCK_END</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">""</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-478"><a href="#L-478"><span class="linenos"> 478</span></a> <span class="o">**</span><span class="p">{</span><span class="sa">f</span><span class="s2">"</span><span class="se">{{{{</span><span class="si">{</span><span class="n">postfix</span><span class="si">}</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BLOCK_START</span> <span class="k">for</span> <span class="n">postfix</span> <span class="ow">in</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-479"><a href="#L-479"><span class="linenos"> 479</span></a> <span class="o">**</span><span class="p">{</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}</span><span class="se">}}}}</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BLOCK_END</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</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-480"><a href="#L-480"><span class="linenos"> 480</span></a> <span class="s2">"/*+"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HINT</span><span class="p">,</span> -</span><span id="L-481"><a href="#L-481"><span class="linenos"> 481</span></a> <span class="s2">"=="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> -</span><span id="L-482"><a href="#L-482"><span class="linenos"> 482</span></a> <span class="s2">"::"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DCOLON</span><span class="p">,</span> -</span><span id="L-483"><a href="#L-483"><span class="linenos"> 483</span></a> <span class="s2">"||"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DPIPE</span><span class="p">,</span> -</span><span id="L-484"><a href="#L-484"><span class="linenos"> 484</span></a> <span class="s2">">="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GTE</span><span class="p">,</span> -</span><span id="L-485"><a href="#L-485"><span class="linenos"> 485</span></a> <span class="s2">"<="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LTE</span><span class="p">,</span> -</span><span id="L-486"><a href="#L-486"><span class="linenos"> 486</span></a> <span class="s2">"<>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> -</span><span id="L-487"><a href="#L-487"><span class="linenos"> 487</span></a> <span class="s2">"!="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> -</span><span id="L-488"><a href="#L-488"><span class="linenos"> 488</span></a> <span class="s2">"<=>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULLSAFE_EQ</span><span class="p">,</span> -</span><span id="L-489"><a href="#L-489"><span class="linenos"> 489</span></a> <span class="s2">"->"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ARROW</span><span class="p">,</span> -</span><span id="L-490"><a href="#L-490"><span class="linenos"> 490</span></a> <span class="s2">"->>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DARROW</span><span class="p">,</span> -</span><span id="L-491"><a href="#L-491"><span class="linenos"> 491</span></a> <span class="s2">"=>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FARROW</span><span class="p">,</span> -</span><span id="L-492"><a href="#L-492"><span class="linenos"> 492</span></a> <span class="s2">"#>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HASH_ARROW</span><span class="p">,</span> -</span><span id="L-493"><a href="#L-493"><span class="linenos"> 493</span></a> <span class="s2">"#>>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DHASH_ARROW</span><span class="p">,</span> -</span><span id="L-494"><a href="#L-494"><span class="linenos"> 494</span></a> <span class="s2">"<->"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LR_ARROW</span><span class="p">,</span> -</span><span id="L-495"><a href="#L-495"><span class="linenos"> 495</span></a> <span class="s2">"&&"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DAMP</span><span class="p">,</span> -</span><span id="L-496"><a href="#L-496"><span class="linenos"> 496</span></a> <span class="s2">"ALL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ALL</span><span class="p">,</span> -</span><span id="L-497"><a href="#L-497"><span class="linenos"> 497</span></a> <span class="s2">"ALWAYS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ALWAYS</span><span class="p">,</span> -</span><span id="L-498"><a href="#L-498"><span class="linenos"> 498</span></a> <span class="s2">"AND"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">AND</span><span class="p">,</span> -</span><span id="L-499"><a href="#L-499"><span class="linenos"> 499</span></a> <span class="s2">"ANTI"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ANTI</span><span class="p">,</span> -</span><span id="L-500"><a href="#L-500"><span class="linenos"> 500</span></a> <span class="s2">"ANY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ANY</span><span class="p">,</span> -</span><span id="L-501"><a href="#L-501"><span class="linenos"> 501</span></a> <span class="s2">"ASC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ASC</span><span class="p">,</span> -</span><span id="L-502"><a href="#L-502"><span class="linenos"> 502</span></a> <span class="s2">"AS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ALIAS</span><span class="p">,</span> -</span><span id="L-503"><a href="#L-503"><span class="linenos"> 503</span></a> <span class="s2">"ASOF"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ASOF</span><span class="p">,</span> -</span><span id="L-504"><a href="#L-504"><span class="linenos"> 504</span></a> <span class="s2">"AUTOINCREMENT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">,</span> -</span><span id="L-505"><a href="#L-505"><span class="linenos"> 505</span></a> <span class="s2">"AUTO_INCREMENT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">,</span> -</span><span id="L-506"><a href="#L-506"><span class="linenos"> 506</span></a> <span class="s2">"BEGIN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">,</span> -</span><span id="L-507"><a href="#L-507"><span class="linenos"> 507</span></a> <span class="s2">"BETWEEN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BETWEEN</span><span class="p">,</span> -</span><span id="L-508"><a href="#L-508"><span class="linenos"> 508</span></a> <span class="s2">"CACHE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CACHE</span><span class="p">,</span> -</span><span id="L-509"><a href="#L-509"><span class="linenos"> 509</span></a> <span class="s2">"UNCACHE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNCACHE</span><span class="p">,</span> -</span><span id="L-510"><a href="#L-510"><span class="linenos"> 510</span></a> <span class="s2">"CASE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CASE</span><span class="p">,</span> -</span><span id="L-511"><a href="#L-511"><span class="linenos"> 511</span></a> <span class="s2">"CHARACTER SET"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CHARACTER_SET</span><span class="p">,</span> -</span><span id="L-512"><a href="#L-512"><span class="linenos"> 512</span></a> <span class="s2">"COLLATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLLATE</span><span class="p">,</span> -</span><span id="L-513"><a href="#L-513"><span class="linenos"> 513</span></a> <span class="s2">"COLUMN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLUMN</span><span class="p">,</span> -</span><span id="L-514"><a href="#L-514"><span class="linenos"> 514</span></a> <span class="s2">"COMMIT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMIT</span><span class="p">,</span> -</span><span id="L-515"><a href="#L-515"><span class="linenos"> 515</span></a> <span class="s2">"CONSTRAINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CONSTRAINT</span><span class="p">,</span> -</span><span id="L-516"><a href="#L-516"><span class="linenos"> 516</span></a> <span class="s2">"CREATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CREATE</span><span class="p">,</span> -</span><span id="L-517"><a href="#L-517"><span class="linenos"> 517</span></a> <span class="s2">"CROSS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CROSS</span><span class="p">,</span> -</span><span id="L-518"><a href="#L-518"><span class="linenos"> 518</span></a> <span class="s2">"CUBE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CUBE</span><span class="p">,</span> -</span><span id="L-519"><a href="#L-519"><span class="linenos"> 519</span></a> <span class="s2">"CURRENT_DATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_DATE</span><span class="p">,</span> -</span><span id="L-520"><a href="#L-520"><span class="linenos"> 520</span></a> <span class="s2">"CURRENT_TIME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIME</span><span class="p">,</span> -</span><span id="L-521"><a href="#L-521"><span class="linenos"> 521</span></a> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIMESTAMP</span><span class="p">,</span> -</span><span id="L-522"><a href="#L-522"><span class="linenos"> 522</span></a> <span class="s2">"CURRENT_USER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_USER</span><span class="p">,</span> -</span><span id="L-523"><a href="#L-523"><span class="linenos"> 523</span></a> <span class="s2">"DATABASE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATABASE</span><span class="p">,</span> -</span><span id="L-524"><a href="#L-524"><span class="linenos"> 524</span></a> <span class="s2">"DEFAULT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">,</span> -</span><span id="L-525"><a href="#L-525"><span class="linenos"> 525</span></a> <span class="s2">"DELETE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DELETE</span><span class="p">,</span> -</span><span id="L-526"><a href="#L-526"><span class="linenos"> 526</span></a> <span class="s2">"DESC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DESC</span><span class="p">,</span> -</span><span id="L-527"><a href="#L-527"><span class="linenos"> 527</span></a> <span class="s2">"DESCRIBE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DESCRIBE</span><span class="p">,</span> -</span><span id="L-528"><a href="#L-528"><span class="linenos"> 528</span></a> <span class="s2">"DISTINCT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DISTINCT</span><span class="p">,</span> -</span><span id="L-529"><a href="#L-529"><span class="linenos"> 529</span></a> <span class="s2">"DIV"</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-530"><a href="#L-530"><span class="linenos"> 530</span></a> <span class="s2">"DROP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DROP</span><span class="p">,</span> -</span><span id="L-531"><a href="#L-531"><span class="linenos"> 531</span></a> <span class="s2">"ELSE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ELSE</span><span class="p">,</span> -</span><span id="L-532"><a href="#L-532"><span class="linenos"> 532</span></a> <span class="s2">"END"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">END</span><span class="p">,</span> -</span><span id="L-533"><a href="#L-533"><span class="linenos"> 533</span></a> <span class="s2">"ESCAPE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ESCAPE</span><span class="p">,</span> -</span><span id="L-534"><a href="#L-534"><span class="linenos"> 534</span></a> <span class="s2">"EXCEPT"</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-535"><a href="#L-535"><span class="linenos"> 535</span></a> <span class="s2">"EXECUTE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXECUTE</span><span class="p">,</span> -</span><span id="L-536"><a href="#L-536"><span class="linenos"> 536</span></a> <span class="s2">"EXISTS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXISTS</span><span class="p">,</span> -</span><span id="L-537"><a href="#L-537"><span class="linenos"> 537</span></a> <span class="s2">"FALSE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FALSE</span><span class="p">,</span> -</span><span id="L-538"><a href="#L-538"><span class="linenos"> 538</span></a> <span class="s2">"FETCH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FETCH</span><span class="p">,</span> -</span><span id="L-539"><a href="#L-539"><span class="linenos"> 539</span></a> <span class="s2">"FILTER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FILTER</span><span class="p">,</span> -</span><span id="L-540"><a href="#L-540"><span class="linenos"> 540</span></a> <span class="s2">"FIRST"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FIRST</span><span class="p">,</span> -</span><span id="L-541"><a href="#L-541"><span class="linenos"> 541</span></a> <span class="s2">"FULL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FULL</span><span class="p">,</span> -</span><span id="L-542"><a href="#L-542"><span class="linenos"> 542</span></a> <span class="s2">"FUNCTION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FUNCTION</span><span class="p">,</span> -</span><span id="L-543"><a href="#L-543"><span class="linenos"> 543</span></a> <span class="s2">"FOR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FOR</span><span class="p">,</span> -</span><span id="L-544"><a href="#L-544"><span class="linenos"> 544</span></a> <span class="s2">"FOREIGN KEY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FOREIGN_KEY</span><span class="p">,</span> -</span><span id="L-545"><a href="#L-545"><span class="linenos"> 545</span></a> <span class="s2">"FORMAT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FORMAT</span><span class="p">,</span> -</span><span id="L-546"><a href="#L-546"><span class="linenos"> 546</span></a> <span class="s2">"FROM"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FROM</span><span class="p">,</span> -</span><span id="L-547"><a href="#L-547"><span class="linenos"> 547</span></a> <span class="s2">"GEOGRAPHY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GEOGRAPHY</span><span class="p">,</span> -</span><span id="L-548"><a href="#L-548"><span class="linenos"> 548</span></a> <span class="s2">"GEOMETRY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GEOMETRY</span><span class="p">,</span> -</span><span id="L-549"><a href="#L-549"><span class="linenos"> 549</span></a> <span class="s2">"GLOB"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GLOB</span><span class="p">,</span> -</span><span id="L-550"><a href="#L-550"><span class="linenos"> 550</span></a> <span class="s2">"GROUP BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GROUP_BY</span><span class="p">,</span> -</span><span id="L-551"><a href="#L-551"><span class="linenos"> 551</span></a> <span class="s2">"GROUPING SETS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GROUPING_SETS</span><span class="p">,</span> -</span><span id="L-552"><a href="#L-552"><span class="linenos"> 552</span></a> <span class="s2">"HAVING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HAVING</span><span class="p">,</span> -</span><span id="L-553"><a href="#L-553"><span class="linenos"> 553</span></a> <span class="s2">"IF"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IF</span><span class="p">,</span> -</span><span id="L-554"><a href="#L-554"><span class="linenos"> 554</span></a> <span class="s2">"ILIKE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ILIKE</span><span class="p">,</span> -</span><span id="L-555"><a href="#L-555"><span class="linenos"> 555</span></a> <span class="s2">"IN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IN</span><span class="p">,</span> -</span><span id="L-556"><a href="#L-556"><span class="linenos"> 556</span></a> <span class="s2">"INDEX"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INDEX</span><span class="p">,</span> -</span><span id="L-557"><a href="#L-557"><span class="linenos"> 557</span></a> <span class="s2">"INET"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INET</span><span class="p">,</span> -</span><span id="L-558"><a href="#L-558"><span class="linenos"> 558</span></a> <span class="s2">"INNER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INNER</span><span class="p">,</span> -</span><span id="L-559"><a href="#L-559"><span class="linenos"> 559</span></a> <span class="s2">"INSERT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INSERT</span><span class="p">,</span> -</span><span id="L-560"><a href="#L-560"><span class="linenos"> 560</span></a> <span class="s2">"INTERVAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INTERVAL</span><span class="p">,</span> -</span><span id="L-561"><a href="#L-561"><span class="linenos"> 561</span></a> <span class="s2">"INTERSECT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INTERSECT</span><span class="p">,</span> -</span><span id="L-562"><a href="#L-562"><span class="linenos"> 562</span></a> <span class="s2">"INTO"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INTO</span><span class="p">,</span> -</span><span id="L-563"><a href="#L-563"><span class="linenos"> 563</span></a> <span class="s2">"IS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IS</span><span class="p">,</span> -</span><span id="L-564"><a href="#L-564"><span class="linenos"> 564</span></a> <span class="s2">"ISNULL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ISNULL</span><span class="p">,</span> -</span><span id="L-565"><a href="#L-565"><span class="linenos"> 565</span></a> <span class="s2">"JOIN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">JOIN</span><span class="p">,</span> -</span><span id="L-566"><a href="#L-566"><span class="linenos"> 566</span></a> <span class="s2">"KEEP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">KEEP</span><span class="p">,</span> -</span><span id="L-567"><a href="#L-567"><span class="linenos"> 567</span></a> <span class="s2">"LATERAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LATERAL</span><span class="p">,</span> -</span><span id="L-568"><a href="#L-568"><span class="linenos"> 568</span></a> <span class="s2">"LEFT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LEFT</span><span class="p">,</span> -</span><span id="L-569"><a href="#L-569"><span class="linenos"> 569</span></a> <span class="s2">"LIKE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIKE</span><span class="p">,</span> -</span><span id="L-570"><a href="#L-570"><span class="linenos"> 570</span></a> <span class="s2">"LIMIT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIMIT</span><span class="p">,</span> -</span><span id="L-571"><a href="#L-571"><span class="linenos"> 571</span></a> <span class="s2">"LOAD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LOAD</span><span class="p">,</span> -</span><span id="L-572"><a href="#L-572"><span class="linenos"> 572</span></a> <span class="s2">"LOCK"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LOCK</span><span class="p">,</span> -</span><span id="L-573"><a href="#L-573"><span class="linenos"> 573</span></a> <span class="s2">"MERGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MERGE</span><span class="p">,</span> -</span><span id="L-574"><a href="#L-574"><span class="linenos"> 574</span></a> <span class="s2">"NATURAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NATURAL</span><span class="p">,</span> -</span><span id="L-575"><a href="#L-575"><span class="linenos"> 575</span></a> <span class="s2">"NEXT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEXT</span><span class="p">,</span> -</span><span id="L-576"><a href="#L-576"><span class="linenos"> 576</span></a> <span class="s2">"NEXT VALUE FOR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEXT_VALUE_FOR</span><span class="p">,</span> -</span><span id="L-577"><a href="#L-577"><span class="linenos"> 577</span></a> <span class="s2">"NOT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NOT</span><span class="p">,</span> -</span><span id="L-578"><a href="#L-578"><span class="linenos"> 578</span></a> <span class="s2">"NOTNULL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NOTNULL</span><span class="p">,</span> -</span><span id="L-579"><a href="#L-579"><span class="linenos"> 579</span></a> <span class="s2">"NULL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">,</span> -</span><span id="L-580"><a href="#L-580"><span class="linenos"> 580</span></a> <span class="s2">"OBJECT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OBJECT</span><span class="p">,</span> -</span><span id="L-581"><a href="#L-581"><span class="linenos"> 581</span></a> <span class="s2">"OFFSET"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OFFSET</span><span class="p">,</span> -</span><span id="L-582"><a href="#L-582"><span class="linenos"> 582</span></a> <span class="s2">"ON"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ON</span><span class="p">,</span> -</span><span id="L-583"><a href="#L-583"><span class="linenos"> 583</span></a> <span class="s2">"OR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OR</span><span class="p">,</span> -</span><span id="L-584"><a href="#L-584"><span class="linenos"> 584</span></a> <span class="s2">"ORDER BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ORDER_BY</span><span class="p">,</span> -</span><span id="L-585"><a href="#L-585"><span class="linenos"> 585</span></a> <span class="s2">"ORDINALITY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ORDINALITY</span><span class="p">,</span> -</span><span id="L-586"><a href="#L-586"><span class="linenos"> 586</span></a> <span class="s2">"OUTER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OUTER</span><span class="p">,</span> -</span><span id="L-587"><a href="#L-587"><span class="linenos"> 587</span></a> <span class="s2">"OVER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OVER</span><span class="p">,</span> -</span><span id="L-588"><a href="#L-588"><span class="linenos"> 588</span></a> <span class="s2">"OVERLAPS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OVERLAPS</span><span class="p">,</span> -</span><span id="L-589"><a href="#L-589"><span class="linenos"> 589</span></a> <span class="s2">"OVERWRITE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OVERWRITE</span><span class="p">,</span> -</span><span id="L-590"><a href="#L-590"><span class="linenos"> 590</span></a> <span class="s2">"PARTITION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARTITION</span><span class="p">,</span> -</span><span id="L-591"><a href="#L-591"><span class="linenos"> 591</span></a> <span class="s2">"PARTITION BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARTITION_BY</span><span class="p">,</span> -</span><span id="L-592"><a href="#L-592"><span class="linenos"> 592</span></a> <span class="s2">"PARTITIONED BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARTITION_BY</span><span class="p">,</span> -</span><span id="L-593"><a href="#L-593"><span class="linenos"> 593</span></a> <span class="s2">"PARTITIONED_BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARTITION_BY</span><span class="p">,</span> -</span><span id="L-594"><a href="#L-594"><span class="linenos"> 594</span></a> <span class="s2">"PERCENT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PERCENT</span><span class="p">,</span> -</span><span id="L-595"><a href="#L-595"><span class="linenos"> 595</span></a> <span class="s2">"PIVOT"</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-596"><a href="#L-596"><span class="linenos"> 596</span></a> <span class="s2">"PRAGMA"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PRAGMA</span><span class="p">,</span> -</span><span id="L-597"><a href="#L-597"><span class="linenos"> 597</span></a> <span class="s2">"PRIMARY KEY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PRIMARY_KEY</span><span class="p">,</span> -</span><span id="L-598"><a href="#L-598"><span class="linenos"> 598</span></a> <span class="s2">"PROCEDURE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PROCEDURE</span><span class="p">,</span> -</span><span id="L-599"><a href="#L-599"><span class="linenos"> 599</span></a> <span class="s2">"QUALIFY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">QUALIFY</span><span class="p">,</span> -</span><span id="L-600"><a href="#L-600"><span class="linenos"> 600</span></a> <span class="s2">"RANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RANGE</span><span class="p">,</span> -</span><span id="L-601"><a href="#L-601"><span class="linenos"> 601</span></a> <span class="s2">"RECURSIVE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RECURSIVE</span><span class="p">,</span> -</span><span id="L-602"><a href="#L-602"><span class="linenos"> 602</span></a> <span class="s2">"REGEXP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> -</span><span id="L-603"><a href="#L-603"><span class="linenos"> 603</span></a> <span class="s2">"REPLACE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">,</span> -</span><span id="L-604"><a href="#L-604"><span class="linenos"> 604</span></a> <span class="s2">"RETURNING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RETURNING</span><span class="p">,</span> -</span><span id="L-605"><a href="#L-605"><span class="linenos"> 605</span></a> <span class="s2">"REFERENCES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REFERENCES</span><span class="p">,</span> -</span><span id="L-606"><a href="#L-606"><span class="linenos"> 606</span></a> <span class="s2">"RIGHT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RIGHT</span><span class="p">,</span> -</span><span id="L-607"><a href="#L-607"><span class="linenos"> 607</span></a> <span class="s2">"RLIKE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> -</span><span id="L-608"><a href="#L-608"><span class="linenos"> 608</span></a> <span class="s2">"ROLLBACK"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROLLBACK</span><span class="p">,</span> -</span><span id="L-609"><a href="#L-609"><span class="linenos"> 609</span></a> <span class="s2">"ROLLUP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROLLUP</span><span class="p">,</span> -</span><span id="L-610"><a href="#L-610"><span class="linenos"> 610</span></a> <span class="s2">"ROW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> -</span><span id="L-611"><a href="#L-611"><span class="linenos"> 611</span></a> <span class="s2">"ROWS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">,</span> -</span><span id="L-612"><a href="#L-612"><span class="linenos"> 612</span></a> <span class="s2">"SCHEMA"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SCHEMA</span><span class="p">,</span> -</span><span id="L-613"><a href="#L-613"><span class="linenos"> 613</span></a> <span class="s2">"SELECT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SELECT</span><span class="p">,</span> -</span><span id="L-614"><a href="#L-614"><span class="linenos"> 614</span></a> <span class="s2">"SEMI"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SEMI</span><span class="p">,</span> -</span><span id="L-615"><a href="#L-615"><span class="linenos"> 615</span></a> <span class="s2">"SET"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">,</span> -</span><span id="L-616"><a href="#L-616"><span class="linenos"> 616</span></a> <span class="s2">"SETTINGS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SETTINGS</span><span class="p">,</span> -</span><span id="L-617"><a href="#L-617"><span class="linenos"> 617</span></a> <span class="s2">"SHOW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SHOW</span><span class="p">,</span> -</span><span id="L-618"><a href="#L-618"><span class="linenos"> 618</span></a> <span class="s2">"SIMILAR TO"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SIMILAR_TO</span><span class="p">,</span> -</span><span id="L-619"><a href="#L-619"><span class="linenos"> 619</span></a> <span class="s2">"SOME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SOME</span><span class="p">,</span> -</span><span id="L-620"><a href="#L-620"><span class="linenos"> 620</span></a> <span class="s2">"TABLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> -</span><span id="L-621"><a href="#L-621"><span class="linenos"> 621</span></a> <span class="s2">"TABLESAMPLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span><span class="p">,</span> -</span><span id="L-622"><a href="#L-622"><span class="linenos"> 622</span></a> <span class="s2">"TEMP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEMPORARY</span><span class="p">,</span> -</span><span id="L-623"><a href="#L-623"><span class="linenos"> 623</span></a> <span class="s2">"TEMPORARY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEMPORARY</span><span class="p">,</span> -</span><span id="L-624"><a href="#L-624"><span class="linenos"> 624</span></a> <span class="s2">"THEN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">THEN</span><span class="p">,</span> -</span><span id="L-625"><a href="#L-625"><span class="linenos"> 625</span></a> <span class="s2">"TRUE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TRUE</span><span class="p">,</span> -</span><span id="L-626"><a href="#L-626"><span class="linenos"> 626</span></a> <span class="s2">"UNION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNION</span><span class="p">,</span> -</span><span id="L-627"><a href="#L-627"><span class="linenos"> 627</span></a> <span class="s2">"UNNEST"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNNEST</span><span class="p">,</span> -</span><span id="L-628"><a href="#L-628"><span class="linenos"> 628</span></a> <span class="s2">"UNPIVOT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNPIVOT</span><span class="p">,</span> -</span><span id="L-629"><a href="#L-629"><span class="linenos"> 629</span></a> <span class="s2">"UPDATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UPDATE</span><span class="p">,</span> -</span><span id="L-630"><a href="#L-630"><span class="linenos"> 630</span></a> <span class="s2">"USE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">USE</span><span class="p">,</span> -</span><span id="L-631"><a href="#L-631"><span class="linenos"> 631</span></a> <span class="s2">"USING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">USING</span><span class="p">,</span> -</span><span id="L-632"><a href="#L-632"><span class="linenos"> 632</span></a> <span class="s2">"UUID"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UUID</span><span class="p">,</span> -</span><span id="L-633"><a href="#L-633"><span class="linenos"> 633</span></a> <span class="s2">"VALUES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VALUES</span><span class="p">,</span> -</span><span id="L-634"><a href="#L-634"><span class="linenos"> 634</span></a> <span class="s2">"VIEW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VIEW</span><span class="p">,</span> -</span><span id="L-635"><a href="#L-635"><span class="linenos"> 635</span></a> <span class="s2">"VOLATILE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VOLATILE</span><span class="p">,</span> -</span><span id="L-636"><a href="#L-636"><span class="linenos"> 636</span></a> <span class="s2">"WHEN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WHEN</span><span class="p">,</span> -</span><span id="L-637"><a href="#L-637"><span class="linenos"> 637</span></a> <span class="s2">"WHERE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WHERE</span><span class="p">,</span> -</span><span id="L-638"><a href="#L-638"><span class="linenos"> 638</span></a> <span class="s2">"WINDOW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WINDOW</span><span class="p">,</span> -</span><span id="L-639"><a href="#L-639"><span class="linenos"> 639</span></a> <span class="s2">"WITH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> -</span><span id="L-640"><a href="#L-640"><span class="linenos"> 640</span></a> <span class="s2">"APPLY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">,</span> -</span><span id="L-641"><a href="#L-641"><span class="linenos"> 641</span></a> <span class="s2">"ARRAY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ARRAY</span><span class="p">,</span> -</span><span id="L-642"><a href="#L-642"><span class="linenos"> 642</span></a> <span class="s2">"BIT"</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-643"><a href="#L-643"><span class="linenos"> 643</span></a> <span class="s2">"BOOL"</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-644"><a href="#L-644"><span class="linenos"> 644</span></a> <span class="s2">"BOOLEAN"</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-645"><a href="#L-645"><span class="linenos"> 645</span></a> <span class="s2">"BYTE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">,</span> -</span><span id="L-646"><a href="#L-646"><span class="linenos"> 646</span></a> <span class="s2">"TINYINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">,</span> -</span><span id="L-647"><a href="#L-647"><span class="linenos"> 647</span></a> <span class="s2">"SHORT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> -</span><span id="L-648"><a href="#L-648"><span class="linenos"> 648</span></a> <span class="s2">"SMALLINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> -</span><span id="L-649"><a href="#L-649"><span class="linenos"> 649</span></a> <span class="s2">"INT2"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> -</span><span id="L-650"><a href="#L-650"><span class="linenos"> 650</span></a> <span class="s2">"INTEGER"</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-651"><a href="#L-651"><span class="linenos"> 651</span></a> <span class="s2">"INT"</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-652"><a href="#L-652"><span class="linenos"> 652</span></a> <span class="s2">"INT4"</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-653"><a href="#L-653"><span class="linenos"> 653</span></a> <span class="s2">"LONG"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> -</span><span id="L-654"><a href="#L-654"><span class="linenos"> 654</span></a> <span class="s2">"BIGINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> -</span><span id="L-655"><a href="#L-655"><span class="linenos"> 655</span></a> <span class="s2">"INT8"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> -</span><span id="L-656"><a href="#L-656"><span class="linenos"> 656</span></a> <span class="s2">"DEC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> -</span><span id="L-657"><a href="#L-657"><span class="linenos"> 657</span></a> <span class="s2">"DECIMAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> -</span><span id="L-658"><a href="#L-658"><span class="linenos"> 658</span></a> <span class="s2">"BIGDECIMAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGDECIMAL</span><span class="p">,</span> -</span><span id="L-659"><a href="#L-659"><span class="linenos"> 659</span></a> <span class="s2">"BIGNUMERIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGDECIMAL</span><span class="p">,</span> -</span><span id="L-660"><a href="#L-660"><span class="linenos"> 660</span></a> <span class="s2">"MAP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MAP</span><span class="p">,</span> -</span><span id="L-661"><a href="#L-661"><span class="linenos"> 661</span></a> <span class="s2">"NULLABLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULLABLE</span><span class="p">,</span> -</span><span id="L-662"><a href="#L-662"><span class="linenos"> 662</span></a> <span class="s2">"NUMBER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> -</span><span id="L-663"><a href="#L-663"><span class="linenos"> 663</span></a> <span class="s2">"NUMERIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> -</span><span id="L-664"><a href="#L-664"><span class="linenos"> 664</span></a> <span class="s2">"FIXED"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> -</span><span id="L-665"><a href="#L-665"><span class="linenos"> 665</span></a> <span class="s2">"REAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span> -</span><span id="L-666"><a href="#L-666"><span class="linenos"> 666</span></a> <span class="s2">"FLOAT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span> -</span><span id="L-667"><a href="#L-667"><span class="linenos"> 667</span></a> <span class="s2">"FLOAT4"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span> -</span><span id="L-668"><a href="#L-668"><span class="linenos"> 668</span></a> <span class="s2">"FLOAT8"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> -</span><span id="L-669"><a href="#L-669"><span class="linenos"> 669</span></a> <span class="s2">"DOUBLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> -</span><span id="L-670"><a href="#L-670"><span class="linenos"> 670</span></a> <span class="s2">"DOUBLE PRECISION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> -</span><span id="L-671"><a href="#L-671"><span class="linenos"> 671</span></a> <span class="s2">"JSON"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">JSON</span><span class="p">,</span> -</span><span id="L-672"><a href="#L-672"><span class="linenos"> 672</span></a> <span class="s2">"CHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span> -</span><span id="L-673"><a href="#L-673"><span class="linenos"> 673</span></a> <span class="s2">"CHARACTER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span> -</span><span id="L-674"><a href="#L-674"><span class="linenos"> 674</span></a> <span class="s2">"NCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">,</span> -</span><span id="L-675"><a href="#L-675"><span class="linenos"> 675</span></a> <span class="s2">"VARCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> -</span><span id="L-676"><a href="#L-676"><span class="linenos"> 676</span></a> <span class="s2">"VARCHAR2"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> -</span><span id="L-677"><a href="#L-677"><span class="linenos"> 677</span></a> <span class="s2">"NVARCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">,</span> -</span><span id="L-678"><a href="#L-678"><span class="linenos"> 678</span></a> <span class="s2">"NVARCHAR2"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">,</span> -</span><span id="L-679"><a href="#L-679"><span class="linenos"> 679</span></a> <span class="s2">"STR"</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-680"><a href="#L-680"><span class="linenos"> 680</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-681"><a href="#L-681"><span class="linenos"> 681</span></a> <span class="s2">"TEXT"</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-682"><a href="#L-682"><span class="linenos"> 682</span></a> <span class="s2">"CLOB"</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-683"><a href="#L-683"><span class="linenos"> 683</span></a> <span class="s2">"LONGVARCHAR"</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-684"><a href="#L-684"><span class="linenos"> 684</span></a> <span class="s2">"BINARY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BINARY</span><span class="p">,</span> -</span><span id="L-685"><a href="#L-685"><span class="linenos"> 685</span></a> <span class="s2">"BLOB"</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-686"><a href="#L-686"><span class="linenos"> 686</span></a> <span class="s2">"BYTEA"</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-687"><a href="#L-687"><span class="linenos"> 687</span></a> <span class="s2">"VARBINARY"</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-688"><a href="#L-688"><span class="linenos"> 688</span></a> <span class="s2">"TIME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIME</span><span class="p">,</span> -</span><span id="L-689"><a href="#L-689"><span class="linenos"> 689</span></a> <span class="s2">"TIMESTAMP"</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-690"><a href="#L-690"><span class="linenos"> 690</span></a> <span class="s2">"TIMESTAMPTZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> -</span><span id="L-691"><a href="#L-691"><span class="linenos"> 691</span></a> <span class="s2">"TIMESTAMPLTZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">,</span> -</span><span id="L-692"><a href="#L-692"><span class="linenos"> 692</span></a> <span class="s2">"DATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATE</span><span class="p">,</span> -</span><span id="L-693"><a href="#L-693"><span class="linenos"> 693</span></a> <span class="s2">"DATETIME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATETIME</span><span class="p">,</span> -</span><span id="L-694"><a href="#L-694"><span class="linenos"> 694</span></a> <span class="s2">"INT4RANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT4RANGE</span><span class="p">,</span> -</span><span id="L-695"><a href="#L-695"><span class="linenos"> 695</span></a> <span class="s2">"INT4MULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT4MULTIRANGE</span><span class="p">,</span> -</span><span id="L-696"><a href="#L-696"><span class="linenos"> 696</span></a> <span class="s2">"INT8RANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT8RANGE</span><span class="p">,</span> -</span><span id="L-697"><a href="#L-697"><span class="linenos"> 697</span></a> <span class="s2">"INT8MULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT8MULTIRANGE</span><span class="p">,</span> -</span><span id="L-698"><a href="#L-698"><span class="linenos"> 698</span></a> <span class="s2">"NUMRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NUMRANGE</span><span class="p">,</span> -</span><span id="L-699"><a href="#L-699"><span class="linenos"> 699</span></a> <span class="s2">"NUMMULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NUMMULTIRANGE</span><span class="p">,</span> -</span><span id="L-700"><a href="#L-700"><span class="linenos"> 700</span></a> <span class="s2">"TSRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TSRANGE</span><span class="p">,</span> -</span><span id="L-701"><a href="#L-701"><span class="linenos"> 701</span></a> <span class="s2">"TSMULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TSMULTIRANGE</span><span class="p">,</span> -</span><span id="L-702"><a href="#L-702"><span class="linenos"> 702</span></a> <span class="s2">"TSTZRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TSTZRANGE</span><span class="p">,</span> -</span><span id="L-703"><a href="#L-703"><span class="linenos"> 703</span></a> <span class="s2">"TSTZMULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TSTZMULTIRANGE</span><span class="p">,</span> -</span><span id="L-704"><a href="#L-704"><span class="linenos"> 704</span></a> <span class="s2">"DATERANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATERANGE</span><span class="p">,</span> -</span><span id="L-705"><a href="#L-705"><span class="linenos"> 705</span></a> <span class="s2">"DATEMULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATEMULTIRANGE</span><span class="p">,</span> -</span><span id="L-706"><a href="#L-706"><span class="linenos"> 706</span></a> <span class="s2">"UNIQUE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNIQUE</span><span class="p">,</span> -</span><span id="L-707"><a href="#L-707"><span class="linenos"> 707</span></a> <span class="s2">"STRUCT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">,</span> -</span><span id="L-708"><a href="#L-708"><span class="linenos"> 708</span></a> <span class="s2">"VARIANT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARIANT</span><span class="p">,</span> -</span><span id="L-709"><a href="#L-709"><span class="linenos"> 709</span></a> <span class="s2">"ALTER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ALTER</span><span class="p">,</span> -</span><span id="L-710"><a href="#L-710"><span class="linenos"> 710</span></a> <span class="s2">"ANALYZE"</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-711"><a href="#L-711"><span class="linenos"> 711</span></a> <span class="s2">"CALL"</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-712"><a href="#L-712"><span class="linenos"> 712</span></a> <span class="s2">"COMMENT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMENT</span><span class="p">,</span> -</span><span id="L-713"><a href="#L-713"><span class="linenos"> 713</span></a> <span class="s2">"COPY"</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-714"><a href="#L-714"><span class="linenos"> 714</span></a> <span class="s2">"EXPLAIN"</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-715"><a href="#L-715"><span class="linenos"> 715</span></a> <span class="s2">"GRANT"</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-716"><a href="#L-716"><span class="linenos"> 716</span></a> <span class="s2">"OPTIMIZE"</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-717"><a href="#L-717"><span class="linenos"> 717</span></a> <span class="s2">"PREPARE"</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-718"><a href="#L-718"><span class="linenos"> 718</span></a> <span class="s2">"TRUNCATE"</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-719"><a href="#L-719"><span class="linenos"> 719</span></a> <span class="s2">"VACUUM"</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-720"><a href="#L-720"><span class="linenos"> 720</span></a> <span class="p">}</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="n">WHITE_SPACE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">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="n">TokenType</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-723"><a href="#L-723"><span class="linenos"> 723</span></a> <span class="s2">" "</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SPACE</span><span class="p">,</span> -</span><span id="L-724"><a href="#L-724"><span class="linenos"> 724</span></a> <span class="s2">"</span><span class="se">\t</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SPACE</span><span class="p">,</span> -</span><span id="L-725"><a href="#L-725"><span class="linenos"> 725</span></a> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">,</span> -</span><span id="L-726"><a href="#L-726"><span class="linenos"> 726</span></a> <span class="s2">"</span><span class="se">\r</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">,</span> -</span><span id="L-727"><a href="#L-727"><span class="linenos"> 727</span></a> <span class="s2">"</span><span class="se">\r\n</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">,</span> -</span><span id="L-728"><a href="#L-728"><span class="linenos"> 728</span></a> <span class="p">}</span> -</span><span id="L-729"><a href="#L-729"><span class="linenos"> 729</span></a> -</span><span id="L-730"><a href="#L-730"><span class="linenos"> 730</span></a> <span class="n">COMMANDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-731"><a href="#L-731"><span class="linenos"> 731</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> -</span><span id="L-732"><a href="#L-732"><span class="linenos"> 732</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXECUTE</span><span class="p">,</span> -</span><span id="L-733"><a href="#L-733"><span class="linenos"> 733</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">FETCH</span><span class="p">,</span> -</span><span id="L-734"><a href="#L-734"><span class="linenos"> 734</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">SHOW</span><span class="p">,</span> -</span><span id="L-735"><a href="#L-735"><span class="linenos"> 735</span></a> <span class="p">}</span> -</span><span id="L-736"><a href="#L-736"><span class="linenos"> 736</span></a> -</span><span id="L-737"><a href="#L-737"><span class="linenos"> 737</span></a> <span class="n">COMMAND_PREFIX_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SEMICOLON</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">}</span> -</span><span id="L-738"><a href="#L-738"><span class="linenos"> 738</span></a> -</span><span id="L-739"><a href="#L-739"><span class="linenos"> 739</span></a> <span class="c1"># handle numeric literals like in hive (3L = BIGINT)</span> -</span><span id="L-740"><a href="#L-740"><span class="linenos"> 740</span></a> <span class="n">NUMERIC_LITERALS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="L-741"><a href="#L-741"><span class="linenos"> 741</span></a> <span class="n">ENCODE</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><span id="L-467"><a href="#L-467"><span class="linenos"> 467</span></a> <span class="c1"># Autofilled</span> +</span><span id="L-468"><a href="#L-468"><span class="linenos"> 468</span></a> <span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-469"><a href="#L-469"><span class="linenos"> 469</span></a> +</span><span id="L-470"><a href="#L-470"><span class="linenos"> 470</span></a> <span class="n">_COMMENTS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-471"><a href="#L-471"><span class="linenos"> 471</span></a> <span class="n">_FORMAT_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-472"><a href="#L-472"><span class="linenos"> 472</span></a> <span class="n">_IDENTIFIERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-473"><a href="#L-473"><span class="linenos"> 473</span></a> <span class="n">_IDENTIFIER_ESCAPES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> +</span><span id="L-474"><a href="#L-474"><span class="linenos"> 474</span></a> <span class="n">_QUOTES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-475"><a href="#L-475"><span class="linenos"> 475</span></a> <span class="n">_STRING_ESCAPES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> +</span><span id="L-476"><a href="#L-476"><span class="linenos"> 476</span></a> <span class="n">_KEYWORD_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-477"><a href="#L-477"><span class="linenos"> 477</span></a> +</span><span id="L-478"><a href="#L-478"><span class="linenos"> 478</span></a> <span class="n">KEYWORDS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">TokenType</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-479"><a href="#L-479"><span class="linenos"> 479</span></a> <span class="o">**</span><span class="p">{</span><span class="sa">f</span><span class="s2">"</span><span class="se">{{</span><span class="s2">%</span><span class="si">{</span><span class="n">postfix</span><span class="si">}</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BLOCK_START</span> <span class="k">for</span> <span class="n">postfix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">""</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-480"><a href="#L-480"><span class="linenos"> 480</span></a> <span class="o">**</span><span class="p">{</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}</span><span class="s2">%</span><span class="se">}}</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BLOCK_END</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">""</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-481"><a href="#L-481"><span class="linenos"> 481</span></a> <span class="o">**</span><span class="p">{</span><span class="sa">f</span><span class="s2">"</span><span class="se">{{{{</span><span class="si">{</span><span class="n">postfix</span><span class="si">}</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BLOCK_START</span> <span class="k">for</span> <span class="n">postfix</span> <span class="ow">in</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-482"><a href="#L-482"><span class="linenos"> 482</span></a> <span class="o">**</span><span class="p">{</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}</span><span class="se">}}}}</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BLOCK_END</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</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-483"><a href="#L-483"><span class="linenos"> 483</span></a> <span class="s2">"/*+"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HINT</span><span class="p">,</span> +</span><span id="L-484"><a href="#L-484"><span class="linenos"> 484</span></a> <span class="s2">"=="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> +</span><span id="L-485"><a href="#L-485"><span class="linenos"> 485</span></a> <span class="s2">"::"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DCOLON</span><span class="p">,</span> +</span><span id="L-486"><a href="#L-486"><span class="linenos"> 486</span></a> <span class="s2">"||"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DPIPE</span><span class="p">,</span> +</span><span id="L-487"><a href="#L-487"><span class="linenos"> 487</span></a> <span class="s2">">="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GTE</span><span class="p">,</span> +</span><span id="L-488"><a href="#L-488"><span class="linenos"> 488</span></a> <span class="s2">"<="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LTE</span><span class="p">,</span> +</span><span id="L-489"><a href="#L-489"><span class="linenos"> 489</span></a> <span class="s2">"<>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> +</span><span id="L-490"><a href="#L-490"><span class="linenos"> 490</span></a> <span class="s2">"!="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> +</span><span id="L-491"><a href="#L-491"><span class="linenos"> 491</span></a> <span class="s2">"<=>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULLSAFE_EQ</span><span class="p">,</span> +</span><span id="L-492"><a href="#L-492"><span class="linenos"> 492</span></a> <span class="s2">"->"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ARROW</span><span class="p">,</span> +</span><span id="L-493"><a href="#L-493"><span class="linenos"> 493</span></a> <span class="s2">"->>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DARROW</span><span class="p">,</span> +</span><span id="L-494"><a href="#L-494"><span class="linenos"> 494</span></a> <span class="s2">"=>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FARROW</span><span class="p">,</span> +</span><span id="L-495"><a href="#L-495"><span class="linenos"> 495</span></a> <span class="s2">"#>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HASH_ARROW</span><span class="p">,</span> +</span><span id="L-496"><a href="#L-496"><span class="linenos"> 496</span></a> <span class="s2">"#>>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DHASH_ARROW</span><span class="p">,</span> +</span><span id="L-497"><a href="#L-497"><span class="linenos"> 497</span></a> <span class="s2">"<->"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LR_ARROW</span><span class="p">,</span> +</span><span id="L-498"><a href="#L-498"><span class="linenos"> 498</span></a> <span class="s2">"&&"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DAMP</span><span class="p">,</span> +</span><span id="L-499"><a href="#L-499"><span class="linenos"> 499</span></a> <span class="s2">"ALL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ALL</span><span class="p">,</span> +</span><span id="L-500"><a href="#L-500"><span class="linenos"> 500</span></a> <span class="s2">"ALWAYS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ALWAYS</span><span class="p">,</span> +</span><span id="L-501"><a href="#L-501"><span class="linenos"> 501</span></a> <span class="s2">"AND"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">AND</span><span class="p">,</span> +</span><span id="L-502"><a href="#L-502"><span class="linenos"> 502</span></a> <span class="s2">"ANTI"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ANTI</span><span class="p">,</span> +</span><span id="L-503"><a href="#L-503"><span class="linenos"> 503</span></a> <span class="s2">"ANY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ANY</span><span class="p">,</span> +</span><span id="L-504"><a href="#L-504"><span class="linenos"> 504</span></a> <span class="s2">"ASC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ASC</span><span class="p">,</span> +</span><span id="L-505"><a href="#L-505"><span class="linenos"> 505</span></a> <span class="s2">"AS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ALIAS</span><span class="p">,</span> +</span><span id="L-506"><a href="#L-506"><span class="linenos"> 506</span></a> <span class="s2">"ASOF"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ASOF</span><span class="p">,</span> +</span><span id="L-507"><a href="#L-507"><span class="linenos"> 507</span></a> <span class="s2">"AUTOINCREMENT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">,</span> +</span><span id="L-508"><a href="#L-508"><span class="linenos"> 508</span></a> <span class="s2">"AUTO_INCREMENT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">,</span> +</span><span id="L-509"><a href="#L-509"><span class="linenos"> 509</span></a> <span class="s2">"BEGIN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">,</span> +</span><span id="L-510"><a href="#L-510"><span class="linenos"> 510</span></a> <span class="s2">"BETWEEN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BETWEEN</span><span class="p">,</span> +</span><span id="L-511"><a href="#L-511"><span class="linenos"> 511</span></a> <span class="s2">"CACHE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CACHE</span><span class="p">,</span> +</span><span id="L-512"><a href="#L-512"><span class="linenos"> 512</span></a> <span class="s2">"UNCACHE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNCACHE</span><span class="p">,</span> +</span><span id="L-513"><a href="#L-513"><span class="linenos"> 513</span></a> <span class="s2">"CASE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CASE</span><span class="p">,</span> +</span><span id="L-514"><a href="#L-514"><span class="linenos"> 514</span></a> <span class="s2">"CHARACTER SET"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CHARACTER_SET</span><span class="p">,</span> +</span><span id="L-515"><a href="#L-515"><span class="linenos"> 515</span></a> <span class="s2">"CLUSTER BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CLUSTER_BY</span><span class="p">,</span> +</span><span id="L-516"><a href="#L-516"><span class="linenos"> 516</span></a> <span class="s2">"COLLATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLLATE</span><span class="p">,</span> +</span><span id="L-517"><a href="#L-517"><span class="linenos"> 517</span></a> <span class="s2">"COLUMN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLUMN</span><span class="p">,</span> +</span><span id="L-518"><a href="#L-518"><span class="linenos"> 518</span></a> <span class="s2">"COMMIT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMIT</span><span class="p">,</span> +</span><span id="L-519"><a href="#L-519"><span class="linenos"> 519</span></a> <span class="s2">"CONSTRAINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CONSTRAINT</span><span class="p">,</span> +</span><span id="L-520"><a href="#L-520"><span class="linenos"> 520</span></a> <span class="s2">"CREATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CREATE</span><span class="p">,</span> +</span><span id="L-521"><a href="#L-521"><span class="linenos"> 521</span></a> <span class="s2">"CROSS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CROSS</span><span class="p">,</span> +</span><span id="L-522"><a href="#L-522"><span class="linenos"> 522</span></a> <span class="s2">"CUBE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CUBE</span><span class="p">,</span> +</span><span id="L-523"><a href="#L-523"><span class="linenos"> 523</span></a> <span class="s2">"CURRENT_DATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_DATE</span><span class="p">,</span> +</span><span id="L-524"><a href="#L-524"><span class="linenos"> 524</span></a> <span class="s2">"CURRENT_TIME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIME</span><span class="p">,</span> +</span><span id="L-525"><a href="#L-525"><span class="linenos"> 525</span></a> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIMESTAMP</span><span class="p">,</span> +</span><span id="L-526"><a href="#L-526"><span class="linenos"> 526</span></a> <span class="s2">"CURRENT_USER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_USER</span><span class="p">,</span> +</span><span id="L-527"><a href="#L-527"><span class="linenos"> 527</span></a> <span class="s2">"DATABASE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATABASE</span><span class="p">,</span> +</span><span id="L-528"><a href="#L-528"><span class="linenos"> 528</span></a> <span class="s2">"DEFAULT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">,</span> +</span><span id="L-529"><a href="#L-529"><span class="linenos"> 529</span></a> <span class="s2">"DELETE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DELETE</span><span class="p">,</span> +</span><span id="L-530"><a href="#L-530"><span class="linenos"> 530</span></a> <span class="s2">"DESC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DESC</span><span class="p">,</span> +</span><span id="L-531"><a href="#L-531"><span class="linenos"> 531</span></a> <span class="s2">"DESCRIBE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DESCRIBE</span><span class="p">,</span> +</span><span id="L-532"><a href="#L-532"><span class="linenos"> 532</span></a> <span class="s2">"DISTINCT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DISTINCT</span><span class="p">,</span> +</span><span id="L-533"><a href="#L-533"><span class="linenos"> 533</span></a> <span class="s2">"DISTRIBUTE BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DISTRIBUTE_BY</span><span class="p">,</span> +</span><span id="L-534"><a href="#L-534"><span class="linenos"> 534</span></a> <span class="s2">"DIV"</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-535"><a href="#L-535"><span class="linenos"> 535</span></a> <span class="s2">"DROP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DROP</span><span class="p">,</span> +</span><span id="L-536"><a href="#L-536"><span class="linenos"> 536</span></a> <span class="s2">"ELSE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ELSE</span><span class="p">,</span> +</span><span id="L-537"><a href="#L-537"><span class="linenos"> 537</span></a> <span class="s2">"END"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">END</span><span class="p">,</span> +</span><span id="L-538"><a href="#L-538"><span class="linenos"> 538</span></a> <span class="s2">"ESCAPE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ESCAPE</span><span class="p">,</span> +</span><span id="L-539"><a href="#L-539"><span class="linenos"> 539</span></a> <span class="s2">"EXCEPT"</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-540"><a href="#L-540"><span class="linenos"> 540</span></a> <span class="s2">"EXECUTE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXECUTE</span><span class="p">,</span> +</span><span id="L-541"><a href="#L-541"><span class="linenos"> 541</span></a> <span class="s2">"EXISTS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXISTS</span><span class="p">,</span> +</span><span id="L-542"><a href="#L-542"><span class="linenos"> 542</span></a> <span class="s2">"FALSE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FALSE</span><span class="p">,</span> +</span><span id="L-543"><a href="#L-543"><span class="linenos"> 543</span></a> <span class="s2">"FETCH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FETCH</span><span class="p">,</span> +</span><span id="L-544"><a href="#L-544"><span class="linenos"> 544</span></a> <span class="s2">"FILTER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FILTER</span><span class="p">,</span> +</span><span id="L-545"><a href="#L-545"><span class="linenos"> 545</span></a> <span class="s2">"FIRST"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FIRST</span><span class="p">,</span> +</span><span id="L-546"><a href="#L-546"><span class="linenos"> 546</span></a> <span class="s2">"FULL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FULL</span><span class="p">,</span> +</span><span id="L-547"><a href="#L-547"><span class="linenos"> 547</span></a> <span class="s2">"FUNCTION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FUNCTION</span><span class="p">,</span> +</span><span id="L-548"><a href="#L-548"><span class="linenos"> 548</span></a> <span class="s2">"FOR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FOR</span><span class="p">,</span> +</span><span id="L-549"><a href="#L-549"><span class="linenos"> 549</span></a> <span class="s2">"FOREIGN KEY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FOREIGN_KEY</span><span class="p">,</span> +</span><span id="L-550"><a href="#L-550"><span class="linenos"> 550</span></a> <span class="s2">"FORMAT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FORMAT</span><span class="p">,</span> +</span><span id="L-551"><a href="#L-551"><span class="linenos"> 551</span></a> <span class="s2">"FROM"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FROM</span><span class="p">,</span> +</span><span id="L-552"><a href="#L-552"><span class="linenos"> 552</span></a> <span class="s2">"GEOGRAPHY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GEOGRAPHY</span><span class="p">,</span> +</span><span id="L-553"><a href="#L-553"><span class="linenos"> 553</span></a> <span class="s2">"GEOMETRY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GEOMETRY</span><span class="p">,</span> +</span><span id="L-554"><a href="#L-554"><span class="linenos"> 554</span></a> <span class="s2">"GLOB"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GLOB</span><span class="p">,</span> +</span><span id="L-555"><a href="#L-555"><span class="linenos"> 555</span></a> <span class="s2">"GROUP BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GROUP_BY</span><span class="p">,</span> +</span><span id="L-556"><a href="#L-556"><span class="linenos"> 556</span></a> <span class="s2">"GROUPING SETS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GROUPING_SETS</span><span class="p">,</span> +</span><span id="L-557"><a href="#L-557"><span class="linenos"> 557</span></a> <span class="s2">"HAVING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HAVING</span><span class="p">,</span> +</span><span id="L-558"><a href="#L-558"><span class="linenos"> 558</span></a> <span class="s2">"IF"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IF</span><span class="p">,</span> +</span><span id="L-559"><a href="#L-559"><span class="linenos"> 559</span></a> <span class="s2">"ILIKE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ILIKE</span><span class="p">,</span> +</span><span id="L-560"><a href="#L-560"><span class="linenos"> 560</span></a> <span class="s2">"IN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IN</span><span class="p">,</span> +</span><span id="L-561"><a href="#L-561"><span class="linenos"> 561</span></a> <span class="s2">"INDEX"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INDEX</span><span class="p">,</span> +</span><span id="L-562"><a href="#L-562"><span class="linenos"> 562</span></a> <span class="s2">"INET"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INET</span><span class="p">,</span> +</span><span id="L-563"><a href="#L-563"><span class="linenos"> 563</span></a> <span class="s2">"INNER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INNER</span><span class="p">,</span> +</span><span id="L-564"><a href="#L-564"><span class="linenos"> 564</span></a> <span class="s2">"INSERT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INSERT</span><span class="p">,</span> +</span><span id="L-565"><a href="#L-565"><span class="linenos"> 565</span></a> <span class="s2">"INTERVAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INTERVAL</span><span class="p">,</span> +</span><span id="L-566"><a href="#L-566"><span class="linenos"> 566</span></a> <span class="s2">"INTERSECT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INTERSECT</span><span class="p">,</span> +</span><span id="L-567"><a href="#L-567"><span class="linenos"> 567</span></a> <span class="s2">"INTO"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INTO</span><span class="p">,</span> +</span><span id="L-568"><a href="#L-568"><span class="linenos"> 568</span></a> <span class="s2">"IS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IS</span><span class="p">,</span> +</span><span id="L-569"><a href="#L-569"><span class="linenos"> 569</span></a> <span class="s2">"ISNULL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ISNULL</span><span class="p">,</span> +</span><span id="L-570"><a href="#L-570"><span class="linenos"> 570</span></a> <span class="s2">"JOIN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">JOIN</span><span class="p">,</span> +</span><span id="L-571"><a href="#L-571"><span class="linenos"> 571</span></a> <span class="s2">"KEEP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">KEEP</span><span class="p">,</span> +</span><span id="L-572"><a href="#L-572"><span class="linenos"> 572</span></a> <span class="s2">"LATERAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LATERAL</span><span class="p">,</span> +</span><span id="L-573"><a href="#L-573"><span class="linenos"> 573</span></a> <span class="s2">"LEFT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LEFT</span><span class="p">,</span> +</span><span id="L-574"><a href="#L-574"><span class="linenos"> 574</span></a> <span class="s2">"LIKE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIKE</span><span class="p">,</span> +</span><span id="L-575"><a href="#L-575"><span class="linenos"> 575</span></a> <span class="s2">"LIMIT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIMIT</span><span class="p">,</span> +</span><span id="L-576"><a href="#L-576"><span class="linenos"> 576</span></a> <span class="s2">"LOAD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LOAD</span><span class="p">,</span> +</span><span id="L-577"><a href="#L-577"><span class="linenos"> 577</span></a> <span class="s2">"LOCK"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LOCK</span><span class="p">,</span> +</span><span id="L-578"><a href="#L-578"><span class="linenos"> 578</span></a> <span class="s2">"MERGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MERGE</span><span class="p">,</span> +</span><span id="L-579"><a href="#L-579"><span class="linenos"> 579</span></a> <span class="s2">"NATURAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NATURAL</span><span class="p">,</span> +</span><span id="L-580"><a href="#L-580"><span class="linenos"> 580</span></a> <span class="s2">"NEXT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEXT</span><span class="p">,</span> +</span><span id="L-581"><a href="#L-581"><span class="linenos"> 581</span></a> <span class="s2">"NEXT VALUE FOR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEXT_VALUE_FOR</span><span class="p">,</span> +</span><span id="L-582"><a href="#L-582"><span class="linenos"> 582</span></a> <span class="s2">"NOT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NOT</span><span class="p">,</span> +</span><span id="L-583"><a href="#L-583"><span class="linenos"> 583</span></a> <span class="s2">"NOTNULL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NOTNULL</span><span class="p">,</span> +</span><span id="L-584"><a href="#L-584"><span class="linenos"> 584</span></a> <span class="s2">"NULL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">,</span> +</span><span id="L-585"><a href="#L-585"><span class="linenos"> 585</span></a> <span class="s2">"OBJECT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OBJECT</span><span class="p">,</span> +</span><span id="L-586"><a href="#L-586"><span class="linenos"> 586</span></a> <span class="s2">"OFFSET"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OFFSET</span><span class="p">,</span> +</span><span id="L-587"><a href="#L-587"><span class="linenos"> 587</span></a> <span class="s2">"ON"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ON</span><span class="p">,</span> +</span><span id="L-588"><a href="#L-588"><span class="linenos"> 588</span></a> <span class="s2">"OR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OR</span><span class="p">,</span> +</span><span id="L-589"><a href="#L-589"><span class="linenos"> 589</span></a> <span class="s2">"ORDER BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ORDER_BY</span><span class="p">,</span> +</span><span id="L-590"><a href="#L-590"><span class="linenos"> 590</span></a> <span class="s2">"ORDINALITY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ORDINALITY</span><span class="p">,</span> +</span><span id="L-591"><a href="#L-591"><span class="linenos"> 591</span></a> <span class="s2">"OUTER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OUTER</span><span class="p">,</span> +</span><span id="L-592"><a href="#L-592"><span class="linenos"> 592</span></a> <span class="s2">"OVER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OVER</span><span class="p">,</span> +</span><span id="L-593"><a href="#L-593"><span class="linenos"> 593</span></a> <span class="s2">"OVERLAPS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OVERLAPS</span><span class="p">,</span> +</span><span id="L-594"><a href="#L-594"><span class="linenos"> 594</span></a> <span class="s2">"OVERWRITE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OVERWRITE</span><span class="p">,</span> +</span><span id="L-595"><a href="#L-595"><span class="linenos"> 595</span></a> <span class="s2">"PARTITION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARTITION</span><span class="p">,</span> +</span><span id="L-596"><a href="#L-596"><span class="linenos"> 596</span></a> <span class="s2">"PARTITION BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARTITION_BY</span><span class="p">,</span> +</span><span id="L-597"><a href="#L-597"><span class="linenos"> 597</span></a> <span class="s2">"PARTITIONED BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARTITION_BY</span><span class="p">,</span> +</span><span id="L-598"><a href="#L-598"><span class="linenos"> 598</span></a> <span class="s2">"PARTITIONED_BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARTITION_BY</span><span class="p">,</span> +</span><span id="L-599"><a href="#L-599"><span class="linenos"> 599</span></a> <span class="s2">"PERCENT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PERCENT</span><span class="p">,</span> +</span><span id="L-600"><a href="#L-600"><span class="linenos"> 600</span></a> <span class="s2">"PIVOT"</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-601"><a href="#L-601"><span class="linenos"> 601</span></a> <span class="s2">"PRAGMA"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PRAGMA</span><span class="p">,</span> +</span><span id="L-602"><a href="#L-602"><span class="linenos"> 602</span></a> <span class="s2">"PRIMARY KEY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PRIMARY_KEY</span><span class="p">,</span> +</span><span id="L-603"><a href="#L-603"><span class="linenos"> 603</span></a> <span class="s2">"PROCEDURE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PROCEDURE</span><span class="p">,</span> +</span><span id="L-604"><a href="#L-604"><span class="linenos"> 604</span></a> <span class="s2">"QUALIFY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">QUALIFY</span><span class="p">,</span> +</span><span id="L-605"><a href="#L-605"><span class="linenos"> 605</span></a> <span class="s2">"RANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RANGE</span><span class="p">,</span> +</span><span id="L-606"><a href="#L-606"><span class="linenos"> 606</span></a> <span class="s2">"RECURSIVE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RECURSIVE</span><span class="p">,</span> +</span><span id="L-607"><a href="#L-607"><span class="linenos"> 607</span></a> <span class="s2">"REGEXP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> +</span><span id="L-608"><a href="#L-608"><span class="linenos"> 608</span></a> <span class="s2">"REPLACE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">,</span> +</span><span id="L-609"><a href="#L-609"><span class="linenos"> 609</span></a> <span class="s2">"RETURNING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RETURNING</span><span class="p">,</span> +</span><span id="L-610"><a href="#L-610"><span class="linenos"> 610</span></a> <span class="s2">"REFERENCES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REFERENCES</span><span class="p">,</span> +</span><span id="L-611"><a href="#L-611"><span class="linenos"> 611</span></a> <span class="s2">"RIGHT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RIGHT</span><span class="p">,</span> +</span><span id="L-612"><a href="#L-612"><span class="linenos"> 612</span></a> <span class="s2">"RLIKE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> +</span><span id="L-613"><a href="#L-613"><span class="linenos"> 613</span></a> <span class="s2">"ROLLBACK"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROLLBACK</span><span class="p">,</span> +</span><span id="L-614"><a href="#L-614"><span class="linenos"> 614</span></a> <span class="s2">"ROLLUP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROLLUP</span><span class="p">,</span> +</span><span id="L-615"><a href="#L-615"><span class="linenos"> 615</span></a> <span class="s2">"ROW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> +</span><span id="L-616"><a href="#L-616"><span class="linenos"> 616</span></a> <span class="s2">"ROWS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">,</span> +</span><span id="L-617"><a href="#L-617"><span class="linenos"> 617</span></a> <span class="s2">"SCHEMA"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SCHEMA</span><span class="p">,</span> +</span><span id="L-618"><a href="#L-618"><span class="linenos"> 618</span></a> <span class="s2">"SELECT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SELECT</span><span class="p">,</span> +</span><span id="L-619"><a href="#L-619"><span class="linenos"> 619</span></a> <span class="s2">"SEMI"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SEMI</span><span class="p">,</span> +</span><span id="L-620"><a href="#L-620"><span class="linenos"> 620</span></a> <span class="s2">"SET"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">,</span> +</span><span id="L-621"><a href="#L-621"><span class="linenos"> 621</span></a> <span class="s2">"SETTINGS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SETTINGS</span><span class="p">,</span> +</span><span id="L-622"><a href="#L-622"><span class="linenos"> 622</span></a> <span class="s2">"SHOW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SHOW</span><span class="p">,</span> +</span><span id="L-623"><a href="#L-623"><span class="linenos"> 623</span></a> <span class="s2">"SIMILAR TO"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SIMILAR_TO</span><span class="p">,</span> +</span><span id="L-624"><a href="#L-624"><span class="linenos"> 624</span></a> <span class="s2">"SOME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SOME</span><span class="p">,</span> +</span><span id="L-625"><a href="#L-625"><span class="linenos"> 625</span></a> <span class="s2">"SORT BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SORT_BY</span><span class="p">,</span> +</span><span id="L-626"><a href="#L-626"><span class="linenos"> 626</span></a> <span class="s2">"TABLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> +</span><span id="L-627"><a href="#L-627"><span class="linenos"> 627</span></a> <span class="s2">"TABLESAMPLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span><span class="p">,</span> +</span><span id="L-628"><a href="#L-628"><span class="linenos"> 628</span></a> <span class="s2">"TEMP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEMPORARY</span><span class="p">,</span> +</span><span id="L-629"><a href="#L-629"><span class="linenos"> 629</span></a> <span class="s2">"TEMPORARY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEMPORARY</span><span class="p">,</span> +</span><span id="L-630"><a href="#L-630"><span class="linenos"> 630</span></a> <span class="s2">"THEN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">THEN</span><span class="p">,</span> +</span><span id="L-631"><a href="#L-631"><span class="linenos"> 631</span></a> <span class="s2">"TRUE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TRUE</span><span class="p">,</span> +</span><span id="L-632"><a href="#L-632"><span class="linenos"> 632</span></a> <span class="s2">"UNION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNION</span><span class="p">,</span> +</span><span id="L-633"><a href="#L-633"><span class="linenos"> 633</span></a> <span class="s2">"UNNEST"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNNEST</span><span class="p">,</span> +</span><span id="L-634"><a href="#L-634"><span class="linenos"> 634</span></a> <span class="s2">"UNPIVOT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNPIVOT</span><span class="p">,</span> +</span><span id="L-635"><a href="#L-635"><span class="linenos"> 635</span></a> <span class="s2">"UPDATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UPDATE</span><span class="p">,</span> +</span><span id="L-636"><a href="#L-636"><span class="linenos"> 636</span></a> <span class="s2">"USE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">USE</span><span class="p">,</span> +</span><span id="L-637"><a href="#L-637"><span class="linenos"> 637</span></a> <span class="s2">"USING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">USING</span><span class="p">,</span> +</span><span id="L-638"><a href="#L-638"><span class="linenos"> 638</span></a> <span class="s2">"UUID"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UUID</span><span class="p">,</span> +</span><span id="L-639"><a href="#L-639"><span class="linenos"> 639</span></a> <span class="s2">"VALUES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VALUES</span><span class="p">,</span> +</span><span id="L-640"><a href="#L-640"><span class="linenos"> 640</span></a> <span class="s2">"VIEW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VIEW</span><span class="p">,</span> +</span><span id="L-641"><a href="#L-641"><span class="linenos"> 641</span></a> <span class="s2">"VOLATILE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VOLATILE</span><span class="p">,</span> +</span><span id="L-642"><a href="#L-642"><span class="linenos"> 642</span></a> <span class="s2">"WHEN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WHEN</span><span class="p">,</span> +</span><span id="L-643"><a href="#L-643"><span class="linenos"> 643</span></a> <span class="s2">"WHERE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WHERE</span><span class="p">,</span> +</span><span id="L-644"><a href="#L-644"><span class="linenos"> 644</span></a> <span class="s2">"WINDOW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WINDOW</span><span class="p">,</span> +</span><span id="L-645"><a href="#L-645"><span class="linenos"> 645</span></a> <span class="s2">"WITH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> +</span><span id="L-646"><a href="#L-646"><span class="linenos"> 646</span></a> <span class="s2">"APPLY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">,</span> +</span><span id="L-647"><a href="#L-647"><span class="linenos"> 647</span></a> <span class="s2">"ARRAY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ARRAY</span><span class="p">,</span> +</span><span id="L-648"><a href="#L-648"><span class="linenos"> 648</span></a> <span class="s2">"BIT"</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-649"><a href="#L-649"><span class="linenos"> 649</span></a> <span class="s2">"BOOL"</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-650"><a href="#L-650"><span class="linenos"> 650</span></a> <span class="s2">"BOOLEAN"</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-651"><a href="#L-651"><span class="linenos"> 651</span></a> <span class="s2">"BYTE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">,</span> +</span><span id="L-652"><a href="#L-652"><span class="linenos"> 652</span></a> <span class="s2">"TINYINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">,</span> +</span><span id="L-653"><a href="#L-653"><span class="linenos"> 653</span></a> <span class="s2">"SHORT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> +</span><span id="L-654"><a href="#L-654"><span class="linenos"> 654</span></a> <span class="s2">"SMALLINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> +</span><span id="L-655"><a href="#L-655"><span class="linenos"> 655</span></a> <span class="s2">"INT2"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> +</span><span id="L-656"><a href="#L-656"><span class="linenos"> 656</span></a> <span class="s2">"INTEGER"</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-657"><a href="#L-657"><span class="linenos"> 657</span></a> <span class="s2">"INT"</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-658"><a href="#L-658"><span class="linenos"> 658</span></a> <span class="s2">"INT4"</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-659"><a href="#L-659"><span class="linenos"> 659</span></a> <span class="s2">"LONG"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> +</span><span id="L-660"><a href="#L-660"><span class="linenos"> 660</span></a> <span class="s2">"BIGINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> +</span><span id="L-661"><a href="#L-661"><span class="linenos"> 661</span></a> <span class="s2">"INT8"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> +</span><span id="L-662"><a href="#L-662"><span class="linenos"> 662</span></a> <span class="s2">"DEC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> +</span><span id="L-663"><a href="#L-663"><span class="linenos"> 663</span></a> <span class="s2">"DECIMAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> +</span><span id="L-664"><a href="#L-664"><span class="linenos"> 664</span></a> <span class="s2">"BIGDECIMAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGDECIMAL</span><span class="p">,</span> +</span><span id="L-665"><a href="#L-665"><span class="linenos"> 665</span></a> <span class="s2">"BIGNUMERIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGDECIMAL</span><span class="p">,</span> +</span><span id="L-666"><a href="#L-666"><span class="linenos"> 666</span></a> <span class="s2">"MAP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MAP</span><span class="p">,</span> +</span><span id="L-667"><a href="#L-667"><span class="linenos"> 667</span></a> <span class="s2">"NULLABLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULLABLE</span><span class="p">,</span> +</span><span id="L-668"><a href="#L-668"><span class="linenos"> 668</span></a> <span class="s2">"NUMBER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> +</span><span id="L-669"><a href="#L-669"><span class="linenos"> 669</span></a> <span class="s2">"NUMERIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> +</span><span id="L-670"><a href="#L-670"><span class="linenos"> 670</span></a> <span class="s2">"FIXED"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> +</span><span id="L-671"><a href="#L-671"><span class="linenos"> 671</span></a> <span class="s2">"REAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span> +</span><span id="L-672"><a href="#L-672"><span class="linenos"> 672</span></a> <span class="s2">"FLOAT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span> +</span><span id="L-673"><a href="#L-673"><span class="linenos"> 673</span></a> <span class="s2">"FLOAT4"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span> +</span><span id="L-674"><a href="#L-674"><span class="linenos"> 674</span></a> <span class="s2">"FLOAT8"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> +</span><span id="L-675"><a href="#L-675"><span class="linenos"> 675</span></a> <span class="s2">"DOUBLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> +</span><span id="L-676"><a href="#L-676"><span class="linenos"> 676</span></a> <span class="s2">"DOUBLE PRECISION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> +</span><span id="L-677"><a href="#L-677"><span class="linenos"> 677</span></a> <span class="s2">"JSON"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">JSON</span><span class="p">,</span> +</span><span id="L-678"><a href="#L-678"><span class="linenos"> 678</span></a> <span class="s2">"CHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span> +</span><span id="L-679"><a href="#L-679"><span class="linenos"> 679</span></a> <span class="s2">"CHARACTER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span> +</span><span id="L-680"><a href="#L-680"><span class="linenos"> 680</span></a> <span class="s2">"NCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">,</span> +</span><span id="L-681"><a href="#L-681"><span class="linenos"> 681</span></a> <span class="s2">"VARCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> +</span><span id="L-682"><a href="#L-682"><span class="linenos"> 682</span></a> <span class="s2">"VARCHAR2"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> +</span><span id="L-683"><a href="#L-683"><span class="linenos"> 683</span></a> <span class="s2">"NVARCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">,</span> +</span><span id="L-684"><a href="#L-684"><span class="linenos"> 684</span></a> <span class="s2">"NVARCHAR2"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">,</span> +</span><span id="L-685"><a href="#L-685"><span class="linenos"> 685</span></a> <span class="s2">"STR"</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-686"><a href="#L-686"><span class="linenos"> 686</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-687"><a href="#L-687"><span class="linenos"> 687</span></a> <span class="s2">"TEXT"</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-688"><a href="#L-688"><span class="linenos"> 688</span></a> <span class="s2">"CLOB"</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-689"><a href="#L-689"><span class="linenos"> 689</span></a> <span class="s2">"LONGVARCHAR"</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-690"><a href="#L-690"><span class="linenos"> 690</span></a> <span class="s2">"BINARY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BINARY</span><span class="p">,</span> +</span><span id="L-691"><a href="#L-691"><span class="linenos"> 691</span></a> <span class="s2">"BLOB"</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-692"><a href="#L-692"><span class="linenos"> 692</span></a> <span class="s2">"BYTEA"</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-693"><a href="#L-693"><span class="linenos"> 693</span></a> <span class="s2">"VARBINARY"</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-694"><a href="#L-694"><span class="linenos"> 694</span></a> <span class="s2">"TIME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIME</span><span class="p">,</span> +</span><span id="L-695"><a href="#L-695"><span class="linenos"> 695</span></a> <span class="s2">"TIMESTAMP"</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-696"><a href="#L-696"><span class="linenos"> 696</span></a> <span class="s2">"TIMESTAMPTZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> +</span><span id="L-697"><a href="#L-697"><span class="linenos"> 697</span></a> <span class="s2">"TIMESTAMPLTZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">,</span> +</span><span id="L-698"><a href="#L-698"><span class="linenos"> 698</span></a> <span class="s2">"DATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATE</span><span class="p">,</span> +</span><span id="L-699"><a href="#L-699"><span class="linenos"> 699</span></a> <span class="s2">"DATETIME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATETIME</span><span class="p">,</span> +</span><span id="L-700"><a href="#L-700"><span class="linenos"> 700</span></a> <span class="s2">"INT4RANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT4RANGE</span><span class="p">,</span> +</span><span id="L-701"><a href="#L-701"><span class="linenos"> 701</span></a> <span class="s2">"INT4MULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT4MULTIRANGE</span><span class="p">,</span> +</span><span id="L-702"><a href="#L-702"><span class="linenos"> 702</span></a> <span class="s2">"INT8RANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT8RANGE</span><span class="p">,</span> +</span><span id="L-703"><a href="#L-703"><span class="linenos"> 703</span></a> <span class="s2">"INT8MULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT8MULTIRANGE</span><span class="p">,</span> +</span><span id="L-704"><a href="#L-704"><span class="linenos"> 704</span></a> <span class="s2">"NUMRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NUMRANGE</span><span class="p">,</span> +</span><span id="L-705"><a href="#L-705"><span class="linenos"> 705</span></a> <span class="s2">"NUMMULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NUMMULTIRANGE</span><span class="p">,</span> +</span><span id="L-706"><a href="#L-706"><span class="linenos"> 706</span></a> <span class="s2">"TSRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TSRANGE</span><span class="p">,</span> +</span><span id="L-707"><a href="#L-707"><span class="linenos"> 707</span></a> <span class="s2">"TSMULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TSMULTIRANGE</span><span class="p">,</span> +</span><span id="L-708"><a href="#L-708"><span class="linenos"> 708</span></a> <span class="s2">"TSTZRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TSTZRANGE</span><span class="p">,</span> +</span><span id="L-709"><a href="#L-709"><span class="linenos"> 709</span></a> <span class="s2">"TSTZMULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TSTZMULTIRANGE</span><span class="p">,</span> +</span><span id="L-710"><a href="#L-710"><span class="linenos"> 710</span></a> <span class="s2">"DATERANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATERANGE</span><span class="p">,</span> +</span><span id="L-711"><a href="#L-711"><span class="linenos"> 711</span></a> <span class="s2">"DATEMULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATEMULTIRANGE</span><span class="p">,</span> +</span><span id="L-712"><a href="#L-712"><span class="linenos"> 712</span></a> <span class="s2">"UNIQUE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNIQUE</span><span class="p">,</span> +</span><span id="L-713"><a href="#L-713"><span class="linenos"> 713</span></a> <span class="s2">"STRUCT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">,</span> +</span><span id="L-714"><a href="#L-714"><span class="linenos"> 714</span></a> <span class="s2">"VARIANT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARIANT</span><span class="p">,</span> +</span><span id="L-715"><a href="#L-715"><span class="linenos"> 715</span></a> <span class="s2">"ALTER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ALTER</span><span class="p">,</span> +</span><span id="L-716"><a href="#L-716"><span class="linenos"> 716</span></a> <span class="s2">"ANALYZE"</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-717"><a href="#L-717"><span class="linenos"> 717</span></a> <span class="s2">"CALL"</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-718"><a href="#L-718"><span class="linenos"> 718</span></a> <span class="s2">"COMMENT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMENT</span><span class="p">,</span> +</span><span id="L-719"><a href="#L-719"><span class="linenos"> 719</span></a> <span class="s2">"COPY"</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-720"><a href="#L-720"><span class="linenos"> 720</span></a> <span class="s2">"EXPLAIN"</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-721"><a href="#L-721"><span class="linenos"> 721</span></a> <span class="s2">"GRANT"</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-722"><a href="#L-722"><span class="linenos"> 722</span></a> <span class="s2">"OPTIMIZE"</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-723"><a href="#L-723"><span class="linenos"> 723</span></a> <span class="s2">"PREPARE"</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-724"><a href="#L-724"><span class="linenos"> 724</span></a> <span class="s2">"TRUNCATE"</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-725"><a href="#L-725"><span class="linenos"> 725</span></a> <span class="s2">"VACUUM"</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-726"><a href="#L-726"><span class="linenos"> 726</span></a> <span class="p">}</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="n">WHITE_SPACE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">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="n">TokenType</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-729"><a href="#L-729"><span class="linenos"> 729</span></a> <span class="s2">" "</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SPACE</span><span class="p">,</span> +</span><span id="L-730"><a href="#L-730"><span class="linenos"> 730</span></a> <span class="s2">"</span><span class="se">\t</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SPACE</span><span class="p">,</span> +</span><span id="L-731"><a href="#L-731"><span class="linenos"> 731</span></a> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">,</span> +</span><span id="L-732"><a href="#L-732"><span class="linenos"> 732</span></a> <span class="s2">"</span><span class="se">\r</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">,</span> +</span><span id="L-733"><a href="#L-733"><span class="linenos"> 733</span></a> <span class="s2">"</span><span class="se">\r\n</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">,</span> +</span><span id="L-734"><a href="#L-734"><span class="linenos"> 734</span></a> <span class="p">}</span> +</span><span id="L-735"><a href="#L-735"><span class="linenos"> 735</span></a> +</span><span id="L-736"><a href="#L-736"><span class="linenos"> 736</span></a> <span class="n">COMMANDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-737"><a href="#L-737"><span class="linenos"> 737</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> +</span><span id="L-738"><a href="#L-738"><span class="linenos"> 738</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXECUTE</span><span class="p">,</span> +</span><span id="L-739"><a href="#L-739"><span class="linenos"> 739</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">FETCH</span><span class="p">,</span> +</span><span id="L-740"><a href="#L-740"><span class="linenos"> 740</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">SHOW</span><span class="p">,</span> +</span><span id="L-741"><a href="#L-741"><span class="linenos"> 741</span></a> <span class="p">}</span> </span><span id="L-742"><a href="#L-742"><span class="linenos"> 742</span></a> -</span><span id="L-743"><a href="#L-743"><span class="linenos"> 743</span></a> <span class="n">COMMENTS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--"</span><span class="p">,</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-743"><a href="#L-743"><span class="linenos"> 743</span></a> <span class="n">COMMAND_PREFIX_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SEMICOLON</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">}</span> </span><span id="L-744"><a href="#L-744"><span class="linenos"> 744</span></a> -</span><span id="L-745"><a href="#L-745"><span class="linenos"> 745</span></a> <span class="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-746"><a href="#L-746"><span class="linenos"> 746</span></a> <span class="s2">"sql"</span><span class="p">,</span> -</span><span id="L-747"><a href="#L-747"><span class="linenos"> 747</span></a> <span class="s2">"size"</span><span class="p">,</span> -</span><span id="L-748"><a href="#L-748"><span class="linenos"> 748</span></a> <span class="s2">"tokens"</span><span class="p">,</span> -</span><span id="L-749"><a href="#L-749"><span class="linenos"> 749</span></a> <span class="s2">"_start"</span><span class="p">,</span> -</span><span id="L-750"><a href="#L-750"><span class="linenos"> 750</span></a> <span class="s2">"_current"</span><span class="p">,</span> -</span><span id="L-751"><a href="#L-751"><span class="linenos"> 751</span></a> <span class="s2">"_line"</span><span class="p">,</span> -</span><span id="L-752"><a href="#L-752"><span class="linenos"> 752</span></a> <span class="s2">"_col"</span><span class="p">,</span> -</span><span id="L-753"><a href="#L-753"><span class="linenos"> 753</span></a> <span class="s2">"_comments"</span><span class="p">,</span> -</span><span id="L-754"><a href="#L-754"><span class="linenos"> 754</span></a> <span class="s2">"_char"</span><span class="p">,</span> -</span><span id="L-755"><a href="#L-755"><span class="linenos"> 755</span></a> <span class="s2">"_end"</span><span class="p">,</span> -</span><span id="L-756"><a href="#L-756"><span class="linenos"> 756</span></a> <span class="s2">"_peek"</span><span class="p">,</span> -</span><span id="L-757"><a href="#L-757"><span class="linenos"> 757</span></a> <span class="s2">"_prev_token_line"</span><span class="p">,</span> -</span><span id="L-758"><a href="#L-758"><span class="linenos"> 758</span></a> <span class="p">)</span> -</span><span id="L-759"><a href="#L-759"><span class="linenos"> 759</span></a> -</span><span id="L-760"><a href="#L-760"><span class="linenos"> 760</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-761"><a href="#L-761"><span class="linenos"> 761</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</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="k">def</span> <span class="nf">reset</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-764"><a href="#L-764"><span class="linenos"> 764</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-765"><a href="#L-765"><span class="linenos"> 765</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="L-766"><a href="#L-766"><span class="linenos"> 766</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</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">Token</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-767"><a href="#L-767"><span class="linenos"> 767</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_start</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="L-768"><a href="#L-768"><span class="linenos"> 768</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="L-769"><a href="#L-769"><span class="linenos"> 769</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> <span class="o">=</span> <span class="mi">1</span> -</span><span id="L-770"><a href="#L-770"><span class="linenos"> 770</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="L-771"><a href="#L-771"><span class="linenos"> 771</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-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="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-774"><a href="#L-774"><span class="linenos"> 774</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-775"><a href="#L-775"><span class="linenos"> 775</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-776"><a href="#L-776"><span class="linenos"> 776</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_token_line</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</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="k">def</span> <span class="nf">tokenize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Token</span><span class="p">]:</span> -</span><span id="L-779"><a href="#L-779"><span class="linenos"> 779</span></a><span class="w"> </span><span class="sd">"""Returns a list of tokens corresponding to the SQL string `sql`."""</span> -</span><span id="L-780"><a href="#L-780"><span class="linenos"> 780</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> -</span><span id="L-781"><a href="#L-781"><span class="linenos"> 781</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span> -</span><span id="L-782"><a href="#L-782"><span class="linenos"> 782</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">sql</span><span class="p">)</span> +</span><span id="L-745"><a href="#L-745"><span class="linenos"> 745</span></a> <span class="c1"># handle numeric literals like in hive (3L = BIGINT)</span> +</span><span id="L-746"><a href="#L-746"><span class="linenos"> 746</span></a> <span class="n">NUMERIC_LITERALS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="L-747"><a href="#L-747"><span class="linenos"> 747</span></a> <span class="n">ENCODE</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><span id="L-748"><a href="#L-748"><span class="linenos"> 748</span></a> +</span><span id="L-749"><a href="#L-749"><span class="linenos"> 749</span></a> <span class="n">COMMENTS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--"</span><span class="p">,</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-750"><a href="#L-750"><span class="linenos"> 750</span></a> +</span><span id="L-751"><a href="#L-751"><span class="linenos"> 751</span></a> <span class="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-752"><a href="#L-752"><span class="linenos"> 752</span></a> <span class="s2">"sql"</span><span class="p">,</span> +</span><span id="L-753"><a href="#L-753"><span class="linenos"> 753</span></a> <span class="s2">"size"</span><span class="p">,</span> +</span><span id="L-754"><a href="#L-754"><span class="linenos"> 754</span></a> <span class="s2">"tokens"</span><span class="p">,</span> +</span><span id="L-755"><a href="#L-755"><span class="linenos"> 755</span></a> <span class="s2">"_start"</span><span class="p">,</span> +</span><span id="L-756"><a href="#L-756"><span class="linenos"> 756</span></a> <span class="s2">"_current"</span><span class="p">,</span> +</span><span id="L-757"><a href="#L-757"><span class="linenos"> 757</span></a> <span class="s2">"_line"</span><span class="p">,</span> +</span><span id="L-758"><a href="#L-758"><span class="linenos"> 758</span></a> <span class="s2">"_col"</span><span class="p">,</span> +</span><span id="L-759"><a href="#L-759"><span class="linenos"> 759</span></a> <span class="s2">"_comments"</span><span class="p">,</span> +</span><span id="L-760"><a href="#L-760"><span class="linenos"> 760</span></a> <span class="s2">"_char"</span><span class="p">,</span> +</span><span id="L-761"><a href="#L-761"><span class="linenos"> 761</span></a> <span class="s2">"_end"</span><span class="p">,</span> +</span><span id="L-762"><a href="#L-762"><span class="linenos"> 762</span></a> <span class="s2">"_peek"</span><span class="p">,</span> +</span><span id="L-763"><a href="#L-763"><span class="linenos"> 763</span></a> <span class="s2">"_prev_token_line"</span><span class="p">,</span> +</span><span id="L-764"><a href="#L-764"><span class="linenos"> 764</span></a> <span class="p">)</span> +</span><span id="L-765"><a href="#L-765"><span class="linenos"> 765</span></a> +</span><span id="L-766"><a href="#L-766"><span class="linenos"> 766</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-767"><a href="#L-767"><span class="linenos"> 767</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> +</span><span id="L-768"><a href="#L-768"><span class="linenos"> 768</span></a> +</span><span id="L-769"><a href="#L-769"><span class="linenos"> 769</span></a> <span class="k">def</span> <span class="nf">reset</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-770"><a href="#L-770"><span class="linenos"> 770</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-771"><a href="#L-771"><span class="linenos"> 771</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="L-772"><a href="#L-772"><span class="linenos"> 772</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</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">Token</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-773"><a href="#L-773"><span class="linenos"> 773</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_start</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="L-774"><a href="#L-774"><span class="linenos"> 774</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="L-775"><a href="#L-775"><span class="linenos"> 775</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> <span class="o">=</span> <span class="mi">1</span> +</span><span id="L-776"><a href="#L-776"><span class="linenos"> 776</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="L-777"><a href="#L-777"><span class="linenos"> 777</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-778"><a href="#L-778"><span class="linenos"> 778</span></a> +</span><span id="L-779"><a href="#L-779"><span class="linenos"> 779</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-780"><a href="#L-780"><span class="linenos"> 780</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-781"><a href="#L-781"><span class="linenos"> 781</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-782"><a href="#L-782"><span class="linenos"> 782</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_token_line</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</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">try</span><span class="p">:</span> -</span><span id="L-785"><a href="#L-785"><span class="linenos"> 785</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan</span><span class="p">()</span> -</span><span id="L-786"><a href="#L-786"><span class="linenos"> 786</span></a> <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> -</span><span id="L-787"><a href="#L-787"><span class="linenos"> 787</span></a> <span class="n">start</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">50</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> -</span><span id="L-788"><a href="#L-788"><span class="linenos"> 788</span></a> <span class="n">end</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+</span> <span class="mi">50</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="L-789"><a href="#L-789"><span class="linenos"> 789</span></a> <span class="n">context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">start</span><span class="p">:</span><span class="n">end</span><span class="p">]</span> -</span><span id="L-790"><a href="#L-790"><span class="linenos"> 790</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Error tokenizing '</span><span class="si">{</span><span class="n">context</span><span class="si">}</span><span class="s2">'"</span><span class="p">)</span> <span class="kn">from</span> <span class="nn">e</span> -</span><span id="L-791"><a href="#L-791"><span class="linenos"> 791</span></a> -</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">tokens</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">def</span> <span class="nf">_scan</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">until</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-795"><a href="#L-795"><span class="linenos"> 795</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span><span class="p">:</span> -</span><span id="L-796"><a href="#L-796"><span class="linenos"> 796</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> -</span><span id="L-797"><a href="#L-797"><span class="linenos"> 797</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</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="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-800"><a href="#L-800"><span class="linenos"> 800</span></a> <span class="k">break</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="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span><span class="p">:</span> -</span><span id="L-803"><a href="#L-803"><span class="linenos"> 803</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="o">.</span><span class="n">isdigit</span><span class="p">():</span> -</span><span id="L-804"><a href="#L-804"><span class="linenos"> 804</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_number</span><span class="p">()</span> -</span><span id="L-805"><a href="#L-805"><span class="linenos"> 805</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_IDENTIFIERS</span><span class="p">:</span> -</span><span id="L-806"><a href="#L-806"><span class="linenos"> 806</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_identifier</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_IDENTIFIERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="p">])</span> -</span><span id="L-807"><a href="#L-807"><span class="linenos"> 807</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-808"><a href="#L-808"><span class="linenos"> 808</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_keywords</span><span class="p">()</span> -</span><span id="L-809"><a href="#L-809"><span class="linenos"> 809</span></a> -</span><span id="L-810"><a href="#L-810"><span class="linenos"> 810</span></a> <span class="k">if</span> <span class="n">until</span> <span class="ow">and</span> <span class="n">until</span><span class="p">():</span> -</span><span id="L-811"><a href="#L-811"><span class="linenos"> 811</span></a> <span class="k">break</span> -</span><span id="L-812"><a href="#L-812"><span class="linenos"> 812</span></a> -</span><span id="L-813"><a href="#L-813"><span class="linenos"> 813</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">:</span> -</span><span id="L-814"><a href="#L-814"><span class="linenos"> 814</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">comments</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">)</span> +</span><span id="L-784"><a href="#L-784"><span class="linenos"> 784</span></a> <span class="k">def</span> <span class="nf">tokenize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Token</span><span class="p">]:</span> +</span><span id="L-785"><a href="#L-785"><span class="linenos"> 785</span></a><span class="w"> </span><span class="sd">"""Returns a list of tokens corresponding to the SQL string `sql`."""</span> +</span><span id="L-786"><a href="#L-786"><span class="linenos"> 786</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> +</span><span id="L-787"><a href="#L-787"><span class="linenos"> 787</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span> +</span><span id="L-788"><a href="#L-788"><span class="linenos"> 788</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">sql</span><span class="p">)</span> +</span><span id="L-789"><a href="#L-789"><span class="linenos"> 789</span></a> +</span><span id="L-790"><a href="#L-790"><span class="linenos"> 790</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="L-791"><a href="#L-791"><span class="linenos"> 791</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan</span><span class="p">()</span> +</span><span id="L-792"><a href="#L-792"><span class="linenos"> 792</span></a> <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> +</span><span id="L-793"><a href="#L-793"><span class="linenos"> 793</span></a> <span class="n">start</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">50</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="L-794"><a href="#L-794"><span class="linenos"> 794</span></a> <span class="n">end</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+</span> <span class="mi">50</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="L-795"><a href="#L-795"><span class="linenos"> 795</span></a> <span class="n">context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">start</span><span class="p">:</span><span class="n">end</span><span class="p">]</span> +</span><span id="L-796"><a href="#L-796"><span class="linenos"> 796</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Error tokenizing '</span><span class="si">{</span><span class="n">context</span><span class="si">}</span><span class="s2">'"</span><span class="p">)</span> <span class="kn">from</span> <span class="nn">e</span> +</span><span id="L-797"><a href="#L-797"><span class="linenos"> 797</span></a> +</span><span id="L-798"><a href="#L-798"><span class="linenos"> 798</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span> +</span><span id="L-799"><a href="#L-799"><span class="linenos"> 799</span></a> +</span><span id="L-800"><a href="#L-800"><span class="linenos"> 800</span></a> <span class="k">def</span> <span class="nf">_scan</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">until</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-801"><a href="#L-801"><span class="linenos"> 801</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span><span class="p">:</span> +</span><span id="L-802"><a href="#L-802"><span class="linenos"> 802</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> +</span><span id="L-803"><a href="#L-803"><span class="linenos"> 803</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-804"><a href="#L-804"><span class="linenos"> 804</span></a> +</span><span id="L-805"><a href="#L-805"><span class="linenos"> 805</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-806"><a href="#L-806"><span class="linenos"> 806</span></a> <span class="k">break</span> +</span><span id="L-807"><a href="#L-807"><span class="linenos"> 807</span></a> +</span><span id="L-808"><a href="#L-808"><span class="linenos"> 808</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span><span class="p">:</span> +</span><span id="L-809"><a href="#L-809"><span class="linenos"> 809</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="o">.</span><span class="n">isdigit</span><span class="p">():</span> +</span><span id="L-810"><a href="#L-810"><span class="linenos"> 810</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_number</span><span class="p">()</span> +</span><span id="L-811"><a href="#L-811"><span class="linenos"> 811</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_IDENTIFIERS</span><span class="p">:</span> +</span><span id="L-812"><a href="#L-812"><span class="linenos"> 812</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_identifier</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_IDENTIFIERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="p">])</span> +</span><span id="L-813"><a href="#L-813"><span class="linenos"> 813</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-814"><a href="#L-814"><span class="linenos"> 814</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_keywords</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">_chars</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">size</span><span class="p">:</span> <span class="nb">int</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="k">if</span> <span class="n">size</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-818"><a href="#L-818"><span class="linenos"> 818</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> -</span><span id="L-819"><a href="#L-819"><span class="linenos"> 819</span></a> -</span><span id="L-820"><a href="#L-820"><span class="linenos"> 820</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span> -</span><span id="L-821"><a href="#L-821"><span class="linenos"> 821</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">start</span> <span class="o">+</span> <span class="n">size</span> -</span><span id="L-822"><a href="#L-822"><span class="linenos"> 822</span></a> -</span><span id="L-823"><a href="#L-823"><span class="linenos"> 823</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">start</span><span class="p">:</span><span class="n">end</span><span class="p">]</span> <span class="k">if</span> <span class="n">end</span> <span class="o"><=</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-824"><a href="#L-824"><span class="linenos"> 824</span></a> -</span><span id="L-825"><a href="#L-825"><span class="linenos"> 825</span></a> <span class="k">def</span> <span class="nf">_advance</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">i</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="n">alnum</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="kc">None</span><span class="p">:</span> -</span><span id="L-826"><a href="#L-826"><span class="linenos"> 826</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="p">)</span> <span class="ow">is</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">:</span> -</span><span id="L-827"><a href="#L-827"><span class="linenos"> 827</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> <span class="o">=</span> <span class="mi">1</span> -</span><span id="L-828"><a href="#L-828"><span class="linenos"> 828</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="L-829"><a href="#L-829"><span class="linenos"> 829</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-830"><a href="#L-830"><span class="linenos"> 830</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> <span class="o">+=</span> <span class="n">i</span> -</span><span id="L-831"><a href="#L-831"><span class="linenos"> 831</span></a> -</span><span id="L-832"><a href="#L-832"><span class="linenos"> 832</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+=</span> <span class="n">i</span> -</span><span id="L-833"><a href="#L-833"><span class="linenos"> 833</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">>=</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> -</span><span id="L-834"><a href="#L-834"><span class="linenos"> 834</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> -</span><span id="L-835"><a href="#L-835"><span class="linenos"> 835</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">=</span> <span class="s2">""</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span><span class="p">]</span> -</span><span id="L-836"><a href="#L-836"><span class="linenos"> 836</span></a> -</span><span id="L-837"><a href="#L-837"><span class="linenos"> 837</span></a> <span class="k">if</span> <span class="n">alnum</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="o">.</span><span class="n">isalnum</span><span class="p">():</span> -</span><span id="L-838"><a href="#L-838"><span class="linenos"> 838</span></a> <span class="c1"># Here we use local variables instead of attributes for better performance</span> -</span><span id="L-839"><a href="#L-839"><span class="linenos"> 839</span></a> <span class="n">_col</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> -</span><span id="L-840"><a href="#L-840"><span class="linenos"> 840</span></a> <span class="n">_current</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> -</span><span id="L-841"><a href="#L-841"><span class="linenos"> 841</span></a> <span class="n">_end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> -</span><span id="L-842"><a href="#L-842"><span class="linenos"> 842</span></a> <span class="n">_peek</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> -</span><span id="L-843"><a href="#L-843"><span class="linenos"> 843</span></a> -</span><span id="L-844"><a href="#L-844"><span class="linenos"> 844</span></a> <span class="k">while</span> <span class="n">_peek</span><span class="o">.</span><span class="n">isalnum</span><span class="p">():</span> -</span><span id="L-845"><a href="#L-845"><span class="linenos"> 845</span></a> <span class="n">_col</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="L-846"><a href="#L-846"><span class="linenos"> 846</span></a> <span class="n">_current</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="L-847"><a href="#L-847"><span class="linenos"> 847</span></a> <span class="n">_end</span> <span class="o">=</span> <span class="n">_current</span> <span class="o">>=</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> -</span><span id="L-848"><a href="#L-848"><span class="linenos"> 848</span></a> <span class="n">_peek</span> <span class="o">=</span> <span class="s2">""</span> <span class="k">if</span> <span class="n">_end</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">_current</span><span class="p">]</span> +</span><span id="L-816"><a href="#L-816"><span class="linenos"> 816</span></a> <span class="k">if</span> <span class="n">until</span> <span class="ow">and</span> <span class="n">until</span><span class="p">():</span> +</span><span id="L-817"><a href="#L-817"><span class="linenos"> 817</span></a> <span class="k">break</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">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">:</span> +</span><span id="L-820"><a href="#L-820"><span class="linenos"> 820</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">comments</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_comments</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="k">def</span> <span class="nf">_chars</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">size</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-823"><a href="#L-823"><span class="linenos"> 823</span></a> <span class="k">if</span> <span class="n">size</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-824"><a href="#L-824"><span class="linenos"> 824</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> +</span><span id="L-825"><a href="#L-825"><span class="linenos"> 825</span></a> +</span><span id="L-826"><a href="#L-826"><span class="linenos"> 826</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span> +</span><span id="L-827"><a href="#L-827"><span class="linenos"> 827</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">start</span> <span class="o">+</span> <span class="n">size</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">sql</span><span class="p">[</span><span class="n">start</span><span class="p">:</span><span class="n">end</span><span class="p">]</span> <span class="k">if</span> <span class="n">end</span> <span class="o"><=</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-830"><a href="#L-830"><span class="linenos"> 830</span></a> +</span><span id="L-831"><a href="#L-831"><span class="linenos"> 831</span></a> <span class="k">def</span> <span class="nf">_advance</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">i</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="n">alnum</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="kc">None</span><span class="p">:</span> +</span><span id="L-832"><a href="#L-832"><span class="linenos"> 832</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="p">)</span> <span class="ow">is</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">:</span> +</span><span id="L-833"><a href="#L-833"><span class="linenos"> 833</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> <span class="o">=</span> <span class="mi">1</span> +</span><span id="L-834"><a href="#L-834"><span class="linenos"> 834</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="L-835"><a href="#L-835"><span class="linenos"> 835</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-836"><a href="#L-836"><span class="linenos"> 836</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> <span class="o">+=</span> <span class="n">i</span> +</span><span id="L-837"><a href="#L-837"><span class="linenos"> 837</span></a> +</span><span id="L-838"><a href="#L-838"><span class="linenos"> 838</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+=</span> <span class="n">i</span> +</span><span id="L-839"><a href="#L-839"><span class="linenos"> 839</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">>=</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> +</span><span id="L-840"><a href="#L-840"><span class="linenos"> 840</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> +</span><span id="L-841"><a href="#L-841"><span class="linenos"> 841</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">=</span> <span class="s2">""</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span><span class="p">]</span> +</span><span id="L-842"><a href="#L-842"><span class="linenos"> 842</span></a> +</span><span id="L-843"><a href="#L-843"><span class="linenos"> 843</span></a> <span class="k">if</span> <span class="n">alnum</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="o">.</span><span class="n">isalnum</span><span class="p">():</span> +</span><span id="L-844"><a href="#L-844"><span class="linenos"> 844</span></a> <span class="c1"># Here we use local variables instead of attributes for better performance</span> +</span><span id="L-845"><a href="#L-845"><span class="linenos"> 845</span></a> <span class="n">_col</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> +</span><span id="L-846"><a href="#L-846"><span class="linenos"> 846</span></a> <span class="n">_current</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> +</span><span id="L-847"><a href="#L-847"><span class="linenos"> 847</span></a> <span class="n">_end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> +</span><span id="L-848"><a href="#L-848"><span class="linenos"> 848</span></a> <span class="n">_peek</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> </span><span id="L-849"><a href="#L-849"><span class="linenos"> 849</span></a> -</span><span id="L-850"><a href="#L-850"><span class="linenos"> 850</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> <span class="o">=</span> <span class="n">_col</span> -</span><span id="L-851"><a href="#L-851"><span class="linenos"> 851</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">=</span> <span class="n">_current</span> -</span><span id="L-852"><a href="#L-852"><span class="linenos"> 852</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="o">=</span> <span class="n">_end</span> -</span><span id="L-853"><a href="#L-853"><span class="linenos"> 853</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">=</span> <span class="n">_peek</span> -</span><span id="L-854"><a href="#L-854"><span class="linenos"> 854</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> +</span><span id="L-850"><a href="#L-850"><span class="linenos"> 850</span></a> <span class="k">while</span> <span class="n">_peek</span><span class="o">.</span><span class="n">isalnum</span><span class="p">():</span> +</span><span id="L-851"><a href="#L-851"><span class="linenos"> 851</span></a> <span class="n">_col</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="L-852"><a href="#L-852"><span class="linenos"> 852</span></a> <span class="n">_current</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="L-853"><a href="#L-853"><span class="linenos"> 853</span></a> <span class="n">_end</span> <span class="o">=</span> <span class="n">_current</span> <span class="o">>=</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> +</span><span id="L-854"><a href="#L-854"><span class="linenos"> 854</span></a> <span class="n">_peek</span> <span class="o">=</span> <span class="s2">""</span> <span class="k">if</span> <span class="n">_end</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">_current</span><span class="p">]</span> </span><span id="L-855"><a href="#L-855"><span class="linenos"> 855</span></a> -</span><span id="L-856"><a href="#L-856"><span class="linenos"> 856</span></a> <span class="nd">@property</span> -</span><span id="L-857"><a href="#L-857"><span class="linenos"> 857</span></a> <span class="k">def</span> <span class="nf">_text</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-858"><a href="#L-858"><span class="linenos"> 858</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="bp">self</span><span class="o">.</span><span class="n">_start</span> <span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span><span class="p">]</span> -</span><span id="L-859"><a href="#L-859"><span class="linenos"> 859</span></a> -</span><span id="L-860"><a href="#L-860"><span class="linenos"> 860</span></a> <span class="k">def</span> <span class="nf">peek</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">i</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-861"><a href="#L-861"><span class="linenos"> 861</span></a> <span class="n">i</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+</span> <span class="n">i</span> -</span><span id="L-862"><a href="#L-862"><span class="linenos"> 862</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span><span class="p">:</span> -</span><span id="L-863"><a href="#L-863"><span class="linenos"> 863</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">i</span><span class="p">]</span> -</span><span id="L-864"><a href="#L-864"><span class="linenos"> 864</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-856"><a href="#L-856"><span class="linenos"> 856</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> <span class="o">=</span> <span class="n">_col</span> +</span><span id="L-857"><a href="#L-857"><span class="linenos"> 857</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">=</span> <span class="n">_current</span> +</span><span id="L-858"><a href="#L-858"><span class="linenos"> 858</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="o">=</span> <span class="n">_end</span> +</span><span id="L-859"><a href="#L-859"><span class="linenos"> 859</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">=</span> <span class="n">_peek</span> +</span><span id="L-860"><a href="#L-860"><span class="linenos"> 860</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> +</span><span id="L-861"><a href="#L-861"><span class="linenos"> 861</span></a> +</span><span id="L-862"><a href="#L-862"><span class="linenos"> 862</span></a> <span class="nd">@property</span> +</span><span id="L-863"><a href="#L-863"><span class="linenos"> 863</span></a> <span class="k">def</span> <span class="nf">_text</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-864"><a href="#L-864"><span class="linenos"> 864</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="bp">self</span><span class="o">.</span><span class="n">_start</span> <span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span><span class="p">]</span> </span><span id="L-865"><a href="#L-865"><span class="linenos"> 865</span></a> -</span><span id="L-866"><a href="#L-866"><span class="linenos"> 866</span></a> <span class="k">def</span> <span class="nf">_add</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-867"><a href="#L-867"><span class="linenos"> 867</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_token_line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> -</span><span id="L-868"><a href="#L-868"><span class="linenos"> 868</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="L-869"><a href="#L-869"><span class="linenos"> 869</span></a> <span class="n">Token</span><span class="p">(</span> -</span><span id="L-870"><a href="#L-870"><span class="linenos"> 870</span></a> <span class="n">token_type</span><span class="p">,</span> -</span><span id="L-871"><a href="#L-871"><span class="linenos"> 871</span></a> <span class="n">text</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_text</span> <span class="k">if</span> <span class="n">text</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">text</span><span class="p">,</span> -</span><span id="L-872"><a href="#L-872"><span class="linenos"> 872</span></a> <span class="n">line</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_line</span><span class="p">,</span> -</span><span id="L-873"><a href="#L-873"><span class="linenos"> 873</span></a> <span class="n">col</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_col</span><span class="p">,</span> -</span><span id="L-874"><a href="#L-874"><span class="linenos"> 874</span></a> <span class="n">start</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_start</span><span class="p">,</span> -</span><span id="L-875"><a href="#L-875"><span class="linenos"> 875</span></a> <span class="n">end</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> -</span><span id="L-876"><a href="#L-876"><span class="linenos"> 876</span></a> <span class="n">comments</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">,</span> -</span><span id="L-877"><a href="#L-877"><span class="linenos"> 877</span></a> <span class="p">)</span> -</span><span id="L-878"><a href="#L-878"><span class="linenos"> 878</span></a> <span class="p">)</span> -</span><span id="L-879"><a href="#L-879"><span class="linenos"> 879</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-880"><a href="#L-880"><span class="linenos"> 880</span></a> -</span><span id="L-881"><a href="#L-881"><span class="linenos"> 881</span></a> <span class="c1"># If we have either a semicolon or a begin token before the command's token, we'll parse</span> -</span><span id="L-882"><a href="#L-882"><span class="linenos"> 882</span></a> <span class="c1"># whatever follows the command's token as a string</span> -</span><span id="L-883"><a href="#L-883"><span class="linenos"> 883</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="L-884"><a href="#L-884"><span class="linenos"> 884</span></a> <span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">COMMANDS</span> -</span><span id="L-885"><a href="#L-885"><span class="linenos"> 885</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">!=</span> <span class="s2">";"</span> -</span><span id="L-886"><a href="#L-886"><span class="linenos"> 886</span></a> <span class="ow">and</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">COMMAND_PREFIX_TOKENS</span><span class="p">)</span> -</span><span id="L-887"><a href="#L-887"><span class="linenos"> 887</span></a> <span class="p">):</span> -</span><span id="L-888"><a href="#L-888"><span class="linenos"> 888</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> -</span><span id="L-889"><a href="#L-889"><span class="linenos"> 889</span></a> <span class="n">tokens</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">)</span> -</span><span id="L-890"><a href="#L-890"><span class="linenos"> 890</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">==</span> <span class="s2">";"</span><span class="p">)</span> -</span><span id="L-891"><a href="#L-891"><span class="linenos"> 891</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[:</span><span class="n">tokens</span><span class="p">]</span> -</span><span id="L-892"><a href="#L-892"><span class="linenos"> 892</span></a> <span class="n">text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">start</span> <span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="L-893"><a href="#L-893"><span class="linenos"> 893</span></a> <span class="k">if</span> <span class="n">text</span><span class="p">:</span> -</span><span id="L-894"><a href="#L-894"><span class="linenos"> 894</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">,</span> <span class="n">text</span><span class="p">)</span> -</span><span id="L-895"><a href="#L-895"><span class="linenos"> 895</span></a> -</span><span id="L-896"><a href="#L-896"><span class="linenos"> 896</span></a> <span class="k">def</span> <span class="nf">_scan_keywords</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-897"><a href="#L-897"><span class="linenos"> 897</span></a> <span class="n">size</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="L-898"><a href="#L-898"><span class="linenos"> 898</span></a> <span class="n">word</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-899"><a href="#L-899"><span class="linenos"> 899</span></a> <span class="n">chars</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_text</span> -</span><span id="L-900"><a href="#L-900"><span class="linenos"> 900</span></a> <span class="n">char</span> <span class="o">=</span> <span class="n">chars</span> -</span><span id="L-901"><a href="#L-901"><span class="linenos"> 901</span></a> <span class="n">prev_space</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-902"><a href="#L-902"><span class="linenos"> 902</span></a> <span class="n">skip</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-903"><a href="#L-903"><span class="linenos"> 903</span></a> <span class="n">trie</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_KEYWORD_TRIE</span> -</span><span id="L-904"><a href="#L-904"><span class="linenos"> 904</span></a> <span class="n">single_token</span> <span class="o">=</span> <span class="n">char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span> -</span><span id="L-905"><a href="#L-905"><span class="linenos"> 905</span></a> -</span><span id="L-906"><a href="#L-906"><span class="linenos"> 906</span></a> <span class="k">while</span> <span class="n">chars</span><span class="p">:</span> -</span><span id="L-907"><a href="#L-907"><span class="linenos"> 907</span></a> <span class="k">if</span> <span class="n">skip</span><span class="p">:</span> -</span><span id="L-908"><a href="#L-908"><span class="linenos"> 908</span></a> <span class="n">result</span> <span class="o">=</span> <span class="mi">1</span> -</span><span id="L-909"><a href="#L-909"><span class="linenos"> 909</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-910"><a href="#L-910"><span class="linenos"> 910</span></a> <span class="n">result</span><span class="p">,</span> <span class="n">trie</span> <span class="o">=</span> <span class="n">in_trie</span><span class="p">(</span><span class="n">trie</span><span class="p">,</span> <span class="n">char</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span> +</span><span id="L-866"><a href="#L-866"><span class="linenos"> 866</span></a> <span class="k">def</span> <span class="nf">peek</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">i</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-867"><a href="#L-867"><span class="linenos"> 867</span></a> <span class="n">i</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+</span> <span class="n">i</span> +</span><span id="L-868"><a href="#L-868"><span class="linenos"> 868</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span><span class="p">:</span> +</span><span id="L-869"><a href="#L-869"><span class="linenos"> 869</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">i</span><span class="p">]</span> +</span><span id="L-870"><a href="#L-870"><span class="linenos"> 870</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-871"><a href="#L-871"><span class="linenos"> 871</span></a> +</span><span id="L-872"><a href="#L-872"><span class="linenos"> 872</span></a> <span class="k">def</span> <span class="nf">_add</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-873"><a href="#L-873"><span class="linenos"> 873</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_token_line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> +</span><span id="L-874"><a href="#L-874"><span class="linenos"> 874</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="L-875"><a href="#L-875"><span class="linenos"> 875</span></a> <span class="n">Token</span><span class="p">(</span> +</span><span id="L-876"><a href="#L-876"><span class="linenos"> 876</span></a> <span class="n">token_type</span><span class="p">,</span> +</span><span id="L-877"><a href="#L-877"><span class="linenos"> 877</span></a> <span class="n">text</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_text</span> <span class="k">if</span> <span class="n">text</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">text</span><span class="p">,</span> +</span><span id="L-878"><a href="#L-878"><span class="linenos"> 878</span></a> <span class="n">line</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_line</span><span class="p">,</span> +</span><span id="L-879"><a href="#L-879"><span class="linenos"> 879</span></a> <span class="n">col</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_col</span><span class="p">,</span> +</span><span id="L-880"><a href="#L-880"><span class="linenos"> 880</span></a> <span class="n">start</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_start</span><span class="p">,</span> +</span><span id="L-881"><a href="#L-881"><span class="linenos"> 881</span></a> <span class="n">end</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> +</span><span id="L-882"><a href="#L-882"><span class="linenos"> 882</span></a> <span class="n">comments</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">,</span> +</span><span id="L-883"><a href="#L-883"><span class="linenos"> 883</span></a> <span class="p">)</span> +</span><span id="L-884"><a href="#L-884"><span class="linenos"> 884</span></a> <span class="p">)</span> +</span><span id="L-885"><a href="#L-885"><span class="linenos"> 885</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-886"><a href="#L-886"><span class="linenos"> 886</span></a> +</span><span id="L-887"><a href="#L-887"><span class="linenos"> 887</span></a> <span class="c1"># If we have either a semicolon or a begin token before the command's token, we'll parse</span> +</span><span id="L-888"><a href="#L-888"><span class="linenos"> 888</span></a> <span class="c1"># whatever follows the command's token as a string</span> +</span><span id="L-889"><a href="#L-889"><span class="linenos"> 889</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="L-890"><a href="#L-890"><span class="linenos"> 890</span></a> <span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">COMMANDS</span> +</span><span id="L-891"><a href="#L-891"><span class="linenos"> 891</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">!=</span> <span class="s2">";"</span> +</span><span id="L-892"><a href="#L-892"><span class="linenos"> 892</span></a> <span class="ow">and</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">COMMAND_PREFIX_TOKENS</span><span class="p">)</span> +</span><span id="L-893"><a href="#L-893"><span class="linenos"> 893</span></a> <span class="p">):</span> +</span><span id="L-894"><a href="#L-894"><span class="linenos"> 894</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> +</span><span id="L-895"><a href="#L-895"><span class="linenos"> 895</span></a> <span class="n">tokens</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">)</span> +</span><span id="L-896"><a href="#L-896"><span class="linenos"> 896</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">==</span> <span class="s2">";"</span><span class="p">)</span> +</span><span id="L-897"><a href="#L-897"><span class="linenos"> 897</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[:</span><span class="n">tokens</span><span class="p">]</span> +</span><span id="L-898"><a href="#L-898"><span class="linenos"> 898</span></a> <span class="n">text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">start</span> <span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="L-899"><a href="#L-899"><span class="linenos"> 899</span></a> <span class="k">if</span> <span class="n">text</span><span class="p">:</span> +</span><span id="L-900"><a href="#L-900"><span class="linenos"> 900</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">,</span> <span class="n">text</span><span class="p">)</span> +</span><span id="L-901"><a href="#L-901"><span class="linenos"> 901</span></a> +</span><span id="L-902"><a href="#L-902"><span class="linenos"> 902</span></a> <span class="k">def</span> <span class="nf">_scan_keywords</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-903"><a href="#L-903"><span class="linenos"> 903</span></a> <span class="n">size</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="L-904"><a href="#L-904"><span class="linenos"> 904</span></a> <span class="n">word</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-905"><a href="#L-905"><span class="linenos"> 905</span></a> <span class="n">chars</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_text</span> +</span><span id="L-906"><a href="#L-906"><span class="linenos"> 906</span></a> <span class="n">char</span> <span class="o">=</span> <span class="n">chars</span> +</span><span id="L-907"><a href="#L-907"><span class="linenos"> 907</span></a> <span class="n">prev_space</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-908"><a href="#L-908"><span class="linenos"> 908</span></a> <span class="n">skip</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-909"><a href="#L-909"><span class="linenos"> 909</span></a> <span class="n">trie</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_KEYWORD_TRIE</span> +</span><span id="L-910"><a href="#L-910"><span class="linenos"> 910</span></a> <span class="n">single_token</span> <span class="o">=</span> <span class="n">char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span> </span><span id="L-911"><a href="#L-911"><span class="linenos"> 911</span></a> -</span><span id="L-912"><a href="#L-912"><span class="linenos"> 912</span></a> <span class="k">if</span> <span class="n">result</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> -</span><span id="L-913"><a href="#L-913"><span class="linenos"> 913</span></a> <span class="k">break</span> -</span><span id="L-914"><a href="#L-914"><span class="linenos"> 914</span></a> <span class="k">if</span> <span class="n">result</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> -</span><span id="L-915"><a href="#L-915"><span class="linenos"> 915</span></a> <span class="n">word</span> <span class="o">=</span> <span class="n">chars</span> -</span><span id="L-916"><a href="#L-916"><span class="linenos"> 916</span></a> -</span><span id="L-917"><a href="#L-917"><span class="linenos"> 917</span></a> <span class="n">size</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="L-918"><a href="#L-918"><span class="linenos"> 918</span></a> <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span> <span class="o">+</span> <span class="n">size</span> -</span><span id="L-919"><a href="#L-919"><span class="linenos"> 919</span></a> -</span><span id="L-920"><a href="#L-920"><span class="linenos"> 920</span></a> <span class="k">if</span> <span class="n">end</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span><span class="p">:</span> -</span><span id="L-921"><a href="#L-921"><span class="linenos"> 921</span></a> <span class="n">char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">end</span><span class="p">]</span> -</span><span id="L-922"><a href="#L-922"><span class="linenos"> 922</span></a> <span class="n">single_token</span> <span class="o">=</span> <span class="n">single_token</span> <span class="ow">or</span> <span class="n">char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span> -</span><span id="L-923"><a href="#L-923"><span class="linenos"> 923</span></a> <span class="n">is_space</span> <span class="o">=</span> <span class="n">char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span> -</span><span id="L-924"><a href="#L-924"><span class="linenos"> 924</span></a> -</span><span id="L-925"><a href="#L-925"><span class="linenos"> 925</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">is_space</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">prev_space</span><span class="p">:</span> -</span><span id="L-926"><a href="#L-926"><span class="linenos"> 926</span></a> <span class="k">if</span> <span class="n">is_space</span><span class="p">:</span> -</span><span id="L-927"><a href="#L-927"><span class="linenos"> 927</span></a> <span class="n">char</span> <span class="o">=</span> <span class="s2">" "</span> -</span><span id="L-928"><a href="#L-928"><span class="linenos"> 928</span></a> <span class="n">chars</span> <span class="o">+=</span> <span class="n">char</span> -</span><span id="L-929"><a href="#L-929"><span class="linenos"> 929</span></a> <span class="n">prev_space</span> <span class="o">=</span> <span class="n">is_space</span> -</span><span id="L-930"><a href="#L-930"><span class="linenos"> 930</span></a> <span class="n">skip</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-931"><a href="#L-931"><span class="linenos"> 931</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-932"><a href="#L-932"><span class="linenos"> 932</span></a> <span class="n">skip</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-933"><a href="#L-933"><span class="linenos"> 933</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-934"><a href="#L-934"><span class="linenos"> 934</span></a> <span class="n">char</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-935"><a href="#L-935"><span class="linenos"> 935</span></a> <span class="n">chars</span> <span class="o">=</span> <span class="s2">" "</span> -</span><span id="L-936"><a href="#L-936"><span class="linenos"> 936</span></a> -</span><span id="L-937"><a href="#L-937"><span class="linenos"> 937</span></a> <span class="n">word</span> <span class="o">=</span> <span class="kc">None</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">single_token</span> <span class="ow">and</span> <span class="n">chars</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span> <span class="k">else</span> <span class="n">word</span> -</span><span id="L-938"><a href="#L-938"><span class="linenos"> 938</span></a> -</span><span id="L-939"><a href="#L-939"><span class="linenos"> 939</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">word</span><span class="p">:</span> -</span><span id="L-940"><a href="#L-940"><span class="linenos"> 940</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">:</span> -</span><span id="L-941"><a href="#L-941"><span class="linenos"> 941</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="p">],</span> <span class="n">text</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="p">)</span> -</span><span id="L-942"><a href="#L-942"><span class="linenos"> 942</span></a> <span class="k">return</span> -</span><span id="L-943"><a href="#L-943"><span class="linenos"> 943</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_var</span><span class="p">()</span> -</span><span id="L-944"><a href="#L-944"><span class="linenos"> 944</span></a> <span class="k">return</span> -</span><span id="L-945"><a href="#L-945"><span class="linenos"> 945</span></a> -</span><span id="L-946"><a href="#L-946"><span class="linenos"> 946</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_string</span><span class="p">(</span><span class="n">word</span><span class="p">):</span> -</span><span id="L-947"><a href="#L-947"><span class="linenos"> 947</span></a> <span class="k">return</span> -</span><span id="L-948"><a href="#L-948"><span class="linenos"> 948</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_comment</span><span class="p">(</span><span class="n">word</span><span class="p">):</span> -</span><span id="L-949"><a href="#L-949"><span class="linenos"> 949</span></a> <span class="k">return</span> -</span><span id="L-950"><a href="#L-950"><span class="linenos"> 950</span></a> -</span><span id="L-951"><a href="#L-951"><span class="linenos"> 951</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">size</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="L-952"><a href="#L-952"><span class="linenos"> 952</span></a> <span class="n">word</span> <span class="o">=</span> <span class="n">word</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-953"><a href="#L-953"><span class="linenos"> 953</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">[</span><span class="n">word</span><span class="p">],</span> <span class="n">text</span><span class="o">=</span><span class="n">word</span><span class="p">)</span> -</span><span id="L-954"><a href="#L-954"><span class="linenos"> 954</span></a> -</span><span id="L-955"><a href="#L-955"><span class="linenos"> 955</span></a> <span class="k">def</span> <span class="nf">_scan_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">comment_start</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="L-956"><a href="#L-956"><span class="linenos"> 956</span></a> <span class="k">if</span> <span class="n">comment_start</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_COMMENTS</span><span class="p">:</span> -</span><span id="L-957"><a href="#L-957"><span class="linenos"> 957</span></a> <span class="k">return</span> <span class="kc">False</span> -</span><span id="L-958"><a href="#L-958"><span class="linenos"> 958</span></a> -</span><span id="L-959"><a href="#L-959"><span class="linenos"> 959</span></a> <span class="n">comment_start_line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> -</span><span id="L-960"><a href="#L-960"><span class="linenos"> 960</span></a> <span class="n">comment_start_size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">comment_start</span><span class="p">)</span> -</span><span id="L-961"><a href="#L-961"><span class="linenos"> 961</span></a> <span class="n">comment_end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_COMMENTS</span><span class="p">[</span><span class="n">comment_start</span><span class="p">]</span> -</span><span id="L-962"><a href="#L-962"><span class="linenos"> 962</span></a> -</span><span id="L-963"><a href="#L-963"><span class="linenos"> 963</span></a> <span class="k">if</span> <span class="n">comment_end</span><span class="p">:</span> -</span><span id="L-964"><a href="#L-964"><span class="linenos"> 964</span></a> <span class="c1"># Skip the comment's start delimiter</span> -</span><span id="L-965"><a href="#L-965"><span class="linenos"> 965</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">comment_start_size</span><span class="p">)</span> -</span><span id="L-966"><a href="#L-966"><span class="linenos"> 966</span></a> -</span><span id="L-967"><a href="#L-967"><span class="linenos"> 967</span></a> <span class="n">comment_end_size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">comment_end</span><span class="p">)</span> -</span><span id="L-968"><a href="#L-968"><span class="linenos"> 968</span></a> <span class="k">while</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_chars</span><span class="p">(</span><span class="n">comment_end_size</span><span class="p">)</span> <span class="o">!=</span> <span class="n">comment_end</span><span class="p">:</span> -</span><span id="L-969"><a href="#L-969"><span class="linenos"> 969</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">alnum</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-970"><a href="#L-970"><span class="linenos"> 970</span></a> -</span><span id="L-971"><a href="#L-971"><span class="linenos"> 971</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_text</span><span class="p">[</span><span class="n">comment_start_size</span> <span class="p">:</span> <span class="o">-</span><span class="n">comment_end_size</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span> -</span><span id="L-972"><a href="#L-972"><span class="linenos"> 972</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">comment_end_size</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="L-973"><a href="#L-973"><span class="linenos"> 973</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-974"><a href="#L-974"><span class="linenos"> 974</span></a> <span class="k">while</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="p">)</span> <span class="ow">is</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">:</span> +</span><span id="L-912"><a href="#L-912"><span class="linenos"> 912</span></a> <span class="k">while</span> <span class="n">chars</span><span class="p">:</span> +</span><span id="L-913"><a href="#L-913"><span class="linenos"> 913</span></a> <span class="k">if</span> <span class="n">skip</span><span class="p">:</span> +</span><span id="L-914"><a href="#L-914"><span class="linenos"> 914</span></a> <span class="n">result</span> <span class="o">=</span> <span class="mi">1</span> +</span><span id="L-915"><a href="#L-915"><span class="linenos"> 915</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-916"><a href="#L-916"><span class="linenos"> 916</span></a> <span class="n">result</span><span class="p">,</span> <span class="n">trie</span> <span class="o">=</span> <span class="n">in_trie</span><span class="p">(</span><span class="n">trie</span><span class="p">,</span> <span class="n">char</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span> +</span><span id="L-917"><a href="#L-917"><span class="linenos"> 917</span></a> +</span><span id="L-918"><a href="#L-918"><span class="linenos"> 918</span></a> <span class="k">if</span> <span class="n">result</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> +</span><span id="L-919"><a href="#L-919"><span class="linenos"> 919</span></a> <span class="k">break</span> +</span><span id="L-920"><a href="#L-920"><span class="linenos"> 920</span></a> <span class="k">if</span> <span class="n">result</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> +</span><span id="L-921"><a href="#L-921"><span class="linenos"> 921</span></a> <span class="n">word</span> <span class="o">=</span> <span class="n">chars</span> +</span><span id="L-922"><a href="#L-922"><span class="linenos"> 922</span></a> +</span><span id="L-923"><a href="#L-923"><span class="linenos"> 923</span></a> <span class="n">size</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="L-924"><a href="#L-924"><span class="linenos"> 924</span></a> <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span> <span class="o">+</span> <span class="n">size</span> +</span><span id="L-925"><a href="#L-925"><span class="linenos"> 925</span></a> +</span><span id="L-926"><a href="#L-926"><span class="linenos"> 926</span></a> <span class="k">if</span> <span class="n">end</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span><span class="p">:</span> +</span><span id="L-927"><a href="#L-927"><span class="linenos"> 927</span></a> <span class="n">char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">end</span><span class="p">]</span> +</span><span id="L-928"><a href="#L-928"><span class="linenos"> 928</span></a> <span class="n">single_token</span> <span class="o">=</span> <span class="n">single_token</span> <span class="ow">or</span> <span class="n">char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span> +</span><span id="L-929"><a href="#L-929"><span class="linenos"> 929</span></a> <span class="n">is_space</span> <span class="o">=</span> <span class="n">char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span> +</span><span id="L-930"><a href="#L-930"><span class="linenos"> 930</span></a> +</span><span id="L-931"><a href="#L-931"><span class="linenos"> 931</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">is_space</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">prev_space</span><span class="p">:</span> +</span><span id="L-932"><a href="#L-932"><span class="linenos"> 932</span></a> <span class="k">if</span> <span class="n">is_space</span><span class="p">:</span> +</span><span id="L-933"><a href="#L-933"><span class="linenos"> 933</span></a> <span class="n">char</span> <span class="o">=</span> <span class="s2">" "</span> +</span><span id="L-934"><a href="#L-934"><span class="linenos"> 934</span></a> <span class="n">chars</span> <span class="o">+=</span> <span class="n">char</span> +</span><span id="L-935"><a href="#L-935"><span class="linenos"> 935</span></a> <span class="n">prev_space</span> <span class="o">=</span> <span class="n">is_space</span> +</span><span id="L-936"><a href="#L-936"><span class="linenos"> 936</span></a> <span class="n">skip</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-937"><a href="#L-937"><span class="linenos"> 937</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-938"><a href="#L-938"><span class="linenos"> 938</span></a> <span class="n">skip</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-939"><a href="#L-939"><span class="linenos"> 939</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-940"><a href="#L-940"><span class="linenos"> 940</span></a> <span class="n">char</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-941"><a href="#L-941"><span class="linenos"> 941</span></a> <span class="n">chars</span> <span class="o">=</span> <span class="s2">" "</span> +</span><span id="L-942"><a href="#L-942"><span class="linenos"> 942</span></a> +</span><span id="L-943"><a href="#L-943"><span class="linenos"> 943</span></a> <span class="n">word</span> <span class="o">=</span> <span class="kc">None</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">single_token</span> <span class="ow">and</span> <span class="n">chars</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span> <span class="k">else</span> <span class="n">word</span> +</span><span id="L-944"><a href="#L-944"><span class="linenos"> 944</span></a> +</span><span id="L-945"><a href="#L-945"><span class="linenos"> 945</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">word</span><span class="p">:</span> +</span><span id="L-946"><a href="#L-946"><span class="linenos"> 946</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">:</span> +</span><span id="L-947"><a href="#L-947"><span class="linenos"> 947</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="p">],</span> <span class="n">text</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="p">)</span> +</span><span id="L-948"><a href="#L-948"><span class="linenos"> 948</span></a> <span class="k">return</span> +</span><span id="L-949"><a href="#L-949"><span class="linenos"> 949</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_var</span><span class="p">()</span> +</span><span id="L-950"><a href="#L-950"><span class="linenos"> 950</span></a> <span class="k">return</span> +</span><span id="L-951"><a href="#L-951"><span class="linenos"> 951</span></a> +</span><span id="L-952"><a href="#L-952"><span class="linenos"> 952</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_string</span><span class="p">(</span><span class="n">word</span><span class="p">):</span> +</span><span id="L-953"><a href="#L-953"><span class="linenos"> 953</span></a> <span class="k">return</span> +</span><span id="L-954"><a href="#L-954"><span class="linenos"> 954</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_comment</span><span class="p">(</span><span class="n">word</span><span class="p">):</span> +</span><span id="L-955"><a href="#L-955"><span class="linenos"> 955</span></a> <span class="k">return</span> +</span><span id="L-956"><a href="#L-956"><span class="linenos"> 956</span></a> +</span><span id="L-957"><a href="#L-957"><span class="linenos"> 957</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">size</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="L-958"><a href="#L-958"><span class="linenos"> 958</span></a> <span class="n">word</span> <span class="o">=</span> <span class="n">word</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-959"><a href="#L-959"><span class="linenos"> 959</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">[</span><span class="n">word</span><span class="p">],</span> <span class="n">text</span><span class="o">=</span><span class="n">word</span><span class="p">)</span> +</span><span id="L-960"><a href="#L-960"><span class="linenos"> 960</span></a> +</span><span id="L-961"><a href="#L-961"><span class="linenos"> 961</span></a> <span class="k">def</span> <span class="nf">_scan_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">comment_start</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="L-962"><a href="#L-962"><span class="linenos"> 962</span></a> <span class="k">if</span> <span class="n">comment_start</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_COMMENTS</span><span class="p">:</span> +</span><span id="L-963"><a href="#L-963"><span class="linenos"> 963</span></a> <span class="k">return</span> <span class="kc">False</span> +</span><span id="L-964"><a href="#L-964"><span class="linenos"> 964</span></a> +</span><span id="L-965"><a href="#L-965"><span class="linenos"> 965</span></a> <span class="n">comment_start_line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> +</span><span id="L-966"><a href="#L-966"><span class="linenos"> 966</span></a> <span class="n">comment_start_size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">comment_start</span><span class="p">)</span> +</span><span id="L-967"><a href="#L-967"><span class="linenos"> 967</span></a> <span class="n">comment_end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_COMMENTS</span><span class="p">[</span><span class="n">comment_start</span><span class="p">]</span> +</span><span id="L-968"><a href="#L-968"><span class="linenos"> 968</span></a> +</span><span id="L-969"><a href="#L-969"><span class="linenos"> 969</span></a> <span class="k">if</span> <span class="n">comment_end</span><span class="p">:</span> +</span><span id="L-970"><a href="#L-970"><span class="linenos"> 970</span></a> <span class="c1"># Skip the comment's start delimiter</span> +</span><span id="L-971"><a href="#L-971"><span class="linenos"> 971</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">comment_start_size</span><span class="p">)</span> +</span><span id="L-972"><a href="#L-972"><span class="linenos"> 972</span></a> +</span><span id="L-973"><a href="#L-973"><span class="linenos"> 973</span></a> <span class="n">comment_end_size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">comment_end</span><span class="p">)</span> +</span><span id="L-974"><a href="#L-974"><span class="linenos"> 974</span></a> <span class="k">while</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_chars</span><span class="p">(</span><span class="n">comment_end_size</span><span class="p">)</span> <span class="o">!=</span> <span class="n">comment_end</span><span class="p">:</span> </span><span id="L-975"><a href="#L-975"><span class="linenos"> 975</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">alnum</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-976"><a href="#L-976"><span class="linenos"> 976</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_text</span><span class="p">[</span><span class="n">comment_start_size</span><span class="p">:])</span> -</span><span id="L-977"><a href="#L-977"><span class="linenos"> 977</span></a> -</span><span id="L-978"><a href="#L-978"><span class="linenos"> 978</span></a> <span class="c1"># Leading comment is attached to the succeeding token, whilst trailing comment to the preceding.</span> -</span><span id="L-979"><a href="#L-979"><span class="linenos"> 979</span></a> <span class="c1"># Multiple consecutive comments are preserved by appending them to the current comments list.</span> -</span><span id="L-980"><a href="#L-980"><span class="linenos"> 980</span></a> <span class="k">if</span> <span class="n">comment_start_line</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_token_line</span><span class="p">:</span> -</span><span id="L-981"><a href="#L-981"><span class="linenos"> 981</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">comments</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">)</span> -</span><span id="L-982"><a href="#L-982"><span class="linenos"> 982</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-983"><a href="#L-983"><span class="linenos"> 983</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_token_line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> -</span><span id="L-984"><a href="#L-984"><span class="linenos"> 984</span></a> -</span><span id="L-985"><a href="#L-985"><span class="linenos"> 985</span></a> <span class="k">return</span> <span class="kc">True</span> -</span><span id="L-986"><a href="#L-986"><span class="linenos"> 986</span></a> -</span><span id="L-987"><a href="#L-987"><span class="linenos"> 987</span></a> <span class="k">def</span> <span class="nf">_scan_number</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-988"><a href="#L-988"><span class="linenos"> 988</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">==</span> <span class="s2">"0"</span><span class="p">:</span> -</span><span id="L-989"><a href="#L-989"><span class="linenos"> 989</span></a> <span class="n">peek</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-990"><a href="#L-990"><span class="linenos"> 990</span></a> <span class="k">if</span> <span class="n">peek</span> <span class="o">==</span> <span class="s2">"B"</span><span class="p">:</span> -</span><span id="L-991"><a href="#L-991"><span class="linenos"> 991</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_bits</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">BIT_STRINGS</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span><span class="p">)</span> -</span><span id="L-992"><a href="#L-992"><span class="linenos"> 992</span></a> <span class="k">elif</span> <span class="n">peek</span> <span class="o">==</span> <span class="s2">"X"</span><span class="p">:</span> -</span><span id="L-993"><a href="#L-993"><span class="linenos"> 993</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_hex</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HEX_STRINGS</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span><span class="p">)</span> -</span><span id="L-994"><a href="#L-994"><span class="linenos"> 994</span></a> -</span><span id="L-995"><a href="#L-995"><span class="linenos"> 995</span></a> <span class="n">decimal</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="L-996"><a href="#L-996"><span class="linenos"> 996</span></a> <span class="n">scientific</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="L-997"><a href="#L-997"><span class="linenos"> 997</span></a> -</span><span id="L-998"><a href="#L-998"><span class="linenos"> 998</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-999"><a href="#L-999"><span class="linenos"> 999</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">isdigit</span><span class="p">():</span> -</span><span id="L-1000"><a href="#L-1000"><span class="linenos">1000</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-1001"><a href="#L-1001"><span class="linenos">1001</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">==</span> <span class="s2">"."</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">decimal</span><span class="p">:</span> -</span><span id="L-1002"><a href="#L-1002"><span class="linenos">1002</span></a> <span class="n">after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> -</span><span id="L-1003"><a href="#L-1003"><span class="linenos">1003</span></a> <span class="k">if</span> <span class="n">after</span><span class="o">.</span><span class="n">isdigit</span><span class="p">()</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">after</span><span class="o">.</span><span class="n">isalpha</span><span class="p">():</span> -</span><span id="L-1004"><a href="#L-1004"><span class="linenos">1004</span></a> <span class="n">decimal</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="L-1005"><a href="#L-1005"><span class="linenos">1005</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-1006"><a href="#L-1006"><span class="linenos">1006</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1007"><a href="#L-1007"><span class="linenos">1007</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">)</span> -</span><span id="L-1008"><a href="#L-1008"><span class="linenos">1008</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"-"</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">)</span> <span class="ow">and</span> <span class="n">scientific</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-1009"><a href="#L-1009"><span class="linenos">1009</span></a> <span class="n">scientific</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="L-1010"><a href="#L-1010"><span class="linenos">1010</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-1011"><a href="#L-1011"><span class="linenos">1011</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"E"</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">scientific</span><span class="p">:</span> -</span><span id="L-1012"><a href="#L-1012"><span class="linenos">1012</span></a> <span class="n">scientific</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="L-1013"><a href="#L-1013"><span class="linenos">1013</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-1014"><a href="#L-1014"><span class="linenos">1014</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">isidentifier</span><span class="p">():</span> -</span><span id="L-1015"><a href="#L-1015"><span class="linenos">1015</span></a> <span class="n">number_text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_text</span> -</span><span id="L-1016"><a href="#L-1016"><span class="linenos">1016</span></a> <span class="n">literal</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-1017"><a href="#L-1017"><span class="linenos">1017</span></a> -</span><span id="L-1018"><a href="#L-1018"><span class="linenos">1018</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">:</span> -</span><span id="L-1019"><a href="#L-1019"><span class="linenos">1019</span></a> <span class="n">literal</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="L-1020"><a href="#L-1020"><span class="linenos">1020</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-1021"><a href="#L-1021"><span class="linenos">1021</span></a> -</span><span id="L-1022"><a href="#L-1022"><span class="linenos">1022</span></a> <span class="n">token_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">NUMERIC_LITERALS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">literal</span><span class="p">,</span> <span class="s2">""</span><span class="p">))</span> +</span><span id="L-976"><a href="#L-976"><span class="linenos"> 976</span></a> +</span><span id="L-977"><a href="#L-977"><span class="linenos"> 977</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_text</span><span class="p">[</span><span class="n">comment_start_size</span> <span class="p">:</span> <span class="o">-</span><span class="n">comment_end_size</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span> +</span><span id="L-978"><a href="#L-978"><span class="linenos"> 978</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">comment_end_size</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="L-979"><a href="#L-979"><span class="linenos"> 979</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-980"><a href="#L-980"><span class="linenos"> 980</span></a> <span class="k">while</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="p">)</span> <span class="ow">is</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">:</span> +</span><span id="L-981"><a href="#L-981"><span class="linenos"> 981</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">alnum</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-982"><a href="#L-982"><span class="linenos"> 982</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_text</span><span class="p">[</span><span class="n">comment_start_size</span><span class="p">:])</span> +</span><span id="L-983"><a href="#L-983"><span class="linenos"> 983</span></a> +</span><span id="L-984"><a href="#L-984"><span class="linenos"> 984</span></a> <span class="c1"># Leading comment is attached to the succeeding token, whilst trailing comment to the preceding.</span> +</span><span id="L-985"><a href="#L-985"><span class="linenos"> 985</span></a> <span class="c1"># Multiple consecutive comments are preserved by appending them to the current comments list.</span> +</span><span id="L-986"><a href="#L-986"><span class="linenos"> 986</span></a> <span class="k">if</span> <span class="n">comment_start_line</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_token_line</span><span class="p">:</span> +</span><span id="L-987"><a href="#L-987"><span class="linenos"> 987</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">comments</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">)</span> +</span><span id="L-988"><a href="#L-988"><span class="linenos"> 988</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-989"><a href="#L-989"><span class="linenos"> 989</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_token_line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> +</span><span id="L-990"><a href="#L-990"><span class="linenos"> 990</span></a> +</span><span id="L-991"><a href="#L-991"><span class="linenos"> 991</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="L-992"><a href="#L-992"><span class="linenos"> 992</span></a> +</span><span id="L-993"><a href="#L-993"><span class="linenos"> 993</span></a> <span class="k">def</span> <span class="nf">_scan_number</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-994"><a href="#L-994"><span class="linenos"> 994</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">==</span> <span class="s2">"0"</span><span class="p">:</span> +</span><span id="L-995"><a href="#L-995"><span class="linenos"> 995</span></a> <span class="n">peek</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-996"><a href="#L-996"><span class="linenos"> 996</span></a> <span class="k">if</span> <span class="n">peek</span> <span class="o">==</span> <span class="s2">"B"</span><span class="p">:</span> +</span><span id="L-997"><a href="#L-997"><span class="linenos"> 997</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_bits</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">BIT_STRINGS</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span><span class="p">)</span> +</span><span id="L-998"><a href="#L-998"><span class="linenos"> 998</span></a> <span class="k">elif</span> <span class="n">peek</span> <span class="o">==</span> <span class="s2">"X"</span><span class="p">:</span> +</span><span id="L-999"><a href="#L-999"><span class="linenos"> 999</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_hex</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HEX_STRINGS</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span><span class="p">)</span> +</span><span id="L-1000"><a href="#L-1000"><span class="linenos">1000</span></a> +</span><span id="L-1001"><a href="#L-1001"><span class="linenos">1001</span></a> <span class="n">decimal</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="L-1002"><a href="#L-1002"><span class="linenos">1002</span></a> <span class="n">scientific</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="L-1003"><a href="#L-1003"><span class="linenos">1003</span></a> +</span><span id="L-1004"><a href="#L-1004"><span class="linenos">1004</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-1005"><a href="#L-1005"><span class="linenos">1005</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">isdigit</span><span class="p">():</span> +</span><span id="L-1006"><a href="#L-1006"><span class="linenos">1006</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-1007"><a href="#L-1007"><span class="linenos">1007</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">==</span> <span class="s2">"."</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">decimal</span><span class="p">:</span> +</span><span id="L-1008"><a href="#L-1008"><span class="linenos">1008</span></a> <span class="n">after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> +</span><span id="L-1009"><a href="#L-1009"><span class="linenos">1009</span></a> <span class="k">if</span> <span class="n">after</span><span class="o">.</span><span class="n">isdigit</span><span class="p">()</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">after</span><span class="o">.</span><span class="n">isalpha</span><span class="p">():</span> +</span><span id="L-1010"><a href="#L-1010"><span class="linenos">1010</span></a> <span class="n">decimal</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="L-1011"><a href="#L-1011"><span class="linenos">1011</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-1012"><a href="#L-1012"><span class="linenos">1012</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1013"><a href="#L-1013"><span class="linenos">1013</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">)</span> +</span><span id="L-1014"><a href="#L-1014"><span class="linenos">1014</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"-"</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">)</span> <span class="ow">and</span> <span class="n">scientific</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-1015"><a href="#L-1015"><span class="linenos">1015</span></a> <span class="n">scientific</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="L-1016"><a href="#L-1016"><span class="linenos">1016</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-1017"><a href="#L-1017"><span class="linenos">1017</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"E"</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">scientific</span><span class="p">:</span> +</span><span id="L-1018"><a href="#L-1018"><span class="linenos">1018</span></a> <span class="n">scientific</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="L-1019"><a href="#L-1019"><span class="linenos">1019</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-1020"><a href="#L-1020"><span class="linenos">1020</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">isidentifier</span><span class="p">():</span> +</span><span id="L-1021"><a href="#L-1021"><span class="linenos">1021</span></a> <span class="n">number_text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_text</span> +</span><span id="L-1022"><a href="#L-1022"><span class="linenos">1022</span></a> <span class="n">literal</span> <span class="o">=</span> <span class="s2">""</span> </span><span id="L-1023"><a href="#L-1023"><span class="linenos">1023</span></a> -</span><span id="L-1024"><a href="#L-1024"><span class="linenos">1024</span></a> <span class="k">if</span> <span class="n">token_type</span><span class="p">:</span> -</span><span id="L-1025"><a href="#L-1025"><span class="linenos">1025</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</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="n">number_text</span><span class="p">)</span> -</span><span id="L-1026"><a href="#L-1026"><span class="linenos">1026</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DCOLON</span><span class="p">,</span> <span class="s2">"::"</span><span class="p">)</span> -</span><span id="L-1027"><a href="#L-1027"><span class="linenos">1027</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">literal</span><span class="p">)</span> -</span><span id="L-1028"><a href="#L-1028"><span class="linenos">1028</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span><span class="p">:</span> -</span><span id="L-1029"><a href="#L-1029"><span class="linenos">1029</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">)</span> -</span><span id="L-1030"><a href="#L-1030"><span class="linenos">1030</span></a> -</span><span id="L-1031"><a href="#L-1031"><span class="linenos">1031</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</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="n">number_text</span><span class="p">)</span> -</span><span id="L-1032"><a href="#L-1032"><span class="linenos">1032</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="o">-</span><span class="nb">len</span><span class="p">(</span><span class="n">literal</span><span class="p">))</span> -</span><span id="L-1033"><a href="#L-1033"><span class="linenos">1033</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1034"><a href="#L-1034"><span class="linenos">1034</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span><span class="p">)</span> -</span><span id="L-1035"><a href="#L-1035"><span class="linenos">1035</span></a> -</span><span id="L-1036"><a href="#L-1036"><span class="linenos">1036</span></a> <span class="k">def</span> <span class="nf">_scan_bits</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-1037"><a href="#L-1037"><span class="linenos">1037</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-1038"><a href="#L-1038"><span class="linenos">1038</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_extract_value</span><span class="p">()</span> -</span><span id="L-1039"><a href="#L-1039"><span class="linenos">1039</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="L-1040"><a href="#L-1040"><span class="linenos">1040</span></a> <span class="c1"># If `value` can't be converted to a binary, fallback to tokenizing it as an identifier</span> -</span><span id="L-1041"><a href="#L-1041"><span class="linenos">1041</span></a> <span class="nb">int</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> -</span><span id="L-1042"><a href="#L-1042"><span class="linenos">1042</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">BIT_STRING</span><span class="p">,</span> <span class="n">value</span><span class="p">[</span><span class="mi">2</span><span class="p">:])</span> <span class="c1"># Drop the 0b</span> -</span><span id="L-1043"><a href="#L-1043"><span class="linenos">1043</span></a> <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> -</span><span id="L-1044"><a href="#L-1044"><span class="linenos">1044</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">)</span> -</span><span id="L-1045"><a href="#L-1045"><span class="linenos">1045</span></a> -</span><span id="L-1046"><a href="#L-1046"><span class="linenos">1046</span></a> <span class="k">def</span> <span class="nf">_scan_hex</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-1047"><a href="#L-1047"><span class="linenos">1047</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-1048"><a href="#L-1048"><span class="linenos">1048</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_extract_value</span><span class="p">()</span> -</span><span id="L-1049"><a href="#L-1049"><span class="linenos">1049</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="L-1050"><a href="#L-1050"><span class="linenos">1050</span></a> <span class="c1"># If `value` can't be converted to a hex, fallback to tokenizing it as an identifier</span> -</span><span id="L-1051"><a href="#L-1051"><span class="linenos">1051</span></a> <span class="nb">int</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="mi">16</span><span class="p">)</span> -</span><span id="L-1052"><a href="#L-1052"><span class="linenos">1052</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">HEX_STRING</span><span class="p">,</span> <span class="n">value</span><span class="p">[</span><span class="mi">2</span><span class="p">:])</span> <span class="c1"># Drop the 0x</span> -</span><span id="L-1053"><a href="#L-1053"><span class="linenos">1053</span></a> <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> -</span><span id="L-1054"><a href="#L-1054"><span class="linenos">1054</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">)</span> -</span><span id="L-1055"><a href="#L-1055"><span class="linenos">1055</span></a> -</span><span id="L-1056"><a href="#L-1056"><span class="linenos">1056</span></a> <span class="k">def</span> <span class="nf">_extract_value</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1057"><a href="#L-1057"><span class="linenos">1057</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-1058"><a href="#L-1058"><span class="linenos">1058</span></a> <span class="n">char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="L-1059"><a href="#L-1059"><span class="linenos">1059</span></a> <span class="k">if</span> <span class="n">char</span> <span class="ow">and</span> <span class="n">char</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">:</span> -</span><span id="L-1060"><a href="#L-1060"><span class="linenos">1060</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">alnum</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1061"><a href="#L-1061"><span class="linenos">1061</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1062"><a href="#L-1062"><span class="linenos">1062</span></a> <span class="k">break</span> -</span><span id="L-1063"><a href="#L-1063"><span class="linenos">1063</span></a> -</span><span id="L-1064"><a href="#L-1064"><span class="linenos">1064</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_text</span> -</span><span id="L-1065"><a href="#L-1065"><span class="linenos">1065</span></a> -</span><span id="L-1066"><a href="#L-1066"><span class="linenos">1066</span></a> <span class="k">def</span> <span class="nf">_scan_string</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">start</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="L-1067"><a href="#L-1067"><span class="linenos">1067</span></a> <span class="n">base</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-1068"><a href="#L-1068"><span class="linenos">1068</span></a> <span class="n">token_type</span> <span class="o">=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span> +</span><span id="L-1024"><a href="#L-1024"><span class="linenos">1024</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">:</span> +</span><span id="L-1025"><a href="#L-1025"><span class="linenos">1025</span></a> <span class="n">literal</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="L-1026"><a href="#L-1026"><span class="linenos">1026</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-1027"><a href="#L-1027"><span class="linenos">1027</span></a> +</span><span id="L-1028"><a href="#L-1028"><span class="linenos">1028</span></a> <span class="n">token_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">NUMERIC_LITERALS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">literal</span><span class="p">,</span> <span class="s2">""</span><span class="p">))</span> +</span><span id="L-1029"><a href="#L-1029"><span class="linenos">1029</span></a> +</span><span id="L-1030"><a href="#L-1030"><span class="linenos">1030</span></a> <span class="k">if</span> <span class="n">token_type</span><span class="p">:</span> +</span><span id="L-1031"><a href="#L-1031"><span class="linenos">1031</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</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="n">number_text</span><span class="p">)</span> +</span><span id="L-1032"><a href="#L-1032"><span class="linenos">1032</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DCOLON</span><span class="p">,</span> <span class="s2">"::"</span><span class="p">)</span> +</span><span id="L-1033"><a href="#L-1033"><span class="linenos">1033</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">literal</span><span class="p">)</span> +</span><span id="L-1034"><a href="#L-1034"><span class="linenos">1034</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span><span class="p">:</span> +</span><span id="L-1035"><a href="#L-1035"><span class="linenos">1035</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">)</span> +</span><span id="L-1036"><a href="#L-1036"><span class="linenos">1036</span></a> +</span><span id="L-1037"><a href="#L-1037"><span class="linenos">1037</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</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="n">number_text</span><span class="p">)</span> +</span><span id="L-1038"><a href="#L-1038"><span class="linenos">1038</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="o">-</span><span class="nb">len</span><span class="p">(</span><span class="n">literal</span><span class="p">))</span> +</span><span id="L-1039"><a href="#L-1039"><span class="linenos">1039</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1040"><a href="#L-1040"><span class="linenos">1040</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span><span class="p">)</span> +</span><span id="L-1041"><a href="#L-1041"><span class="linenos">1041</span></a> +</span><span id="L-1042"><a href="#L-1042"><span class="linenos">1042</span></a> <span class="k">def</span> <span class="nf">_scan_bits</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-1043"><a href="#L-1043"><span class="linenos">1043</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-1044"><a href="#L-1044"><span class="linenos">1044</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_extract_value</span><span class="p">()</span> +</span><span id="L-1045"><a href="#L-1045"><span class="linenos">1045</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="L-1046"><a href="#L-1046"><span class="linenos">1046</span></a> <span class="c1"># If `value` can't be converted to a binary, fallback to tokenizing it as an identifier</span> +</span><span id="L-1047"><a href="#L-1047"><span class="linenos">1047</span></a> <span class="nb">int</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> +</span><span id="L-1048"><a href="#L-1048"><span class="linenos">1048</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">BIT_STRING</span><span class="p">,</span> <span class="n">value</span><span class="p">[</span><span class="mi">2</span><span class="p">:])</span> <span class="c1"># Drop the 0b</span> +</span><span id="L-1049"><a href="#L-1049"><span class="linenos">1049</span></a> <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> +</span><span id="L-1050"><a href="#L-1050"><span class="linenos">1050</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">)</span> +</span><span id="L-1051"><a href="#L-1051"><span class="linenos">1051</span></a> +</span><span id="L-1052"><a href="#L-1052"><span class="linenos">1052</span></a> <span class="k">def</span> <span class="nf">_scan_hex</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-1053"><a href="#L-1053"><span class="linenos">1053</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-1054"><a href="#L-1054"><span class="linenos">1054</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_extract_value</span><span class="p">()</span> +</span><span id="L-1055"><a href="#L-1055"><span class="linenos">1055</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="L-1056"><a href="#L-1056"><span class="linenos">1056</span></a> <span class="c1"># If `value` can't be converted to a hex, fallback to tokenizing it as an identifier</span> +</span><span id="L-1057"><a href="#L-1057"><span class="linenos">1057</span></a> <span class="nb">int</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="mi">16</span><span class="p">)</span> +</span><span id="L-1058"><a href="#L-1058"><span class="linenos">1058</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">HEX_STRING</span><span class="p">,</span> <span class="n">value</span><span class="p">[</span><span class="mi">2</span><span class="p">:])</span> <span class="c1"># Drop the 0x</span> +</span><span id="L-1059"><a href="#L-1059"><span class="linenos">1059</span></a> <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> +</span><span id="L-1060"><a href="#L-1060"><span class="linenos">1060</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">)</span> +</span><span id="L-1061"><a href="#L-1061"><span class="linenos">1061</span></a> +</span><span id="L-1062"><a href="#L-1062"><span class="linenos">1062</span></a> <span class="k">def</span> <span class="nf">_extract_value</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1063"><a href="#L-1063"><span class="linenos">1063</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-1064"><a href="#L-1064"><span class="linenos">1064</span></a> <span class="n">char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="L-1065"><a href="#L-1065"><span class="linenos">1065</span></a> <span class="k">if</span> <span class="n">char</span> <span class="ow">and</span> <span class="n">char</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">:</span> +</span><span id="L-1066"><a href="#L-1066"><span class="linenos">1066</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">alnum</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1067"><a href="#L-1067"><span class="linenos">1067</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1068"><a href="#L-1068"><span class="linenos">1068</span></a> <span class="k">break</span> </span><span id="L-1069"><a href="#L-1069"><span class="linenos">1069</span></a> -</span><span id="L-1070"><a href="#L-1070"><span class="linenos">1070</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_QUOTES</span><span class="p">:</span> -</span><span id="L-1071"><a href="#L-1071"><span class="linenos">1071</span></a> <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_QUOTES</span><span class="p">[</span><span class="n">start</span><span class="p">]</span> -</span><span id="L-1072"><a href="#L-1072"><span class="linenos">1072</span></a> <span class="k">elif</span> <span class="n">start</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_FORMAT_STRINGS</span><span class="p">:</span> -</span><span id="L-1073"><a href="#L-1073"><span class="linenos">1073</span></a> <span class="n">end</span><span class="p">,</span> <span class="n">token_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_FORMAT_STRINGS</span><span class="p">[</span><span class="n">start</span><span class="p">]</span> -</span><span id="L-1074"><a href="#L-1074"><span class="linenos">1074</span></a> -</span><span id="L-1075"><a href="#L-1075"><span class="linenos">1075</span></a> <span class="k">if</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HEX_STRING</span><span class="p">:</span> -</span><span id="L-1076"><a href="#L-1076"><span class="linenos">1076</span></a> <span class="n">base</span> <span class="o">=</span> <span class="mi">16</span> -</span><span id="L-1077"><a href="#L-1077"><span class="linenos">1077</span></a> <span class="k">elif</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIT_STRING</span><span class="p">:</span> -</span><span id="L-1078"><a href="#L-1078"><span class="linenos">1078</span></a> <span class="n">base</span> <span class="o">=</span> <span class="mi">2</span> -</span><span id="L-1079"><a href="#L-1079"><span class="linenos">1079</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1080"><a href="#L-1080"><span class="linenos">1080</span></a> <span class="k">return</span> <span class="kc">False</span> -</span><span id="L-1081"><a href="#L-1081"><span class="linenos">1081</span></a> -</span><span id="L-1082"><a href="#L-1082"><span class="linenos">1082</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">start</span><span class="p">))</span> -</span><span id="L-1083"><a href="#L-1083"><span class="linenos">1083</span></a> <span class="n">text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_extract_string</span><span class="p">(</span><span class="n">end</span><span class="p">)</span> -</span><span id="L-1084"><a href="#L-1084"><span class="linenos">1084</span></a> -</span><span id="L-1085"><a href="#L-1085"><span class="linenos">1085</span></a> <span class="k">if</span> <span class="n">base</span><span class="p">:</span> -</span><span id="L-1086"><a href="#L-1086"><span class="linenos">1086</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="L-1087"><a href="#L-1087"><span class="linenos">1087</span></a> <span class="nb">int</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="n">base</span><span class="p">)</span> -</span><span id="L-1088"><a href="#L-1088"><span class="linenos">1088</span></a> <span class="k">except</span><span class="p">:</span> -</span><span id="L-1089"><a href="#L-1089"><span class="linenos">1089</span></a> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span> -</span><span id="L-1090"><a href="#L-1090"><span class="linenos">1090</span></a> <span class="sa">f</span><span class="s2">"Numeric string contains invalid characters from </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_line</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">_start</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-1091"><a href="#L-1091"><span class="linenos">1091</span></a> <span class="p">)</span> -</span><span id="L-1092"><a href="#L-1092"><span class="linenos">1092</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1093"><a href="#L-1093"><span class="linenos">1093</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ENCODE</span><span class="p">)</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ENCODE</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ENCODE</span> <span class="k">else</span> <span class="n">text</span> -</span><span id="L-1094"><a href="#L-1094"><span class="linenos">1094</span></a> -</span><span id="L-1095"><a href="#L-1095"><span class="linenos">1095</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">text</span><span class="p">)</span> -</span><span id="L-1096"><a href="#L-1096"><span class="linenos">1096</span></a> <span class="k">return</span> <span class="kc">True</span> -</span><span id="L-1097"><a href="#L-1097"><span class="linenos">1097</span></a> -</span><span id="L-1098"><a href="#L-1098"><span class="linenos">1098</span></a> <span class="k">def</span> <span class="nf">_scan_identifier</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">identifier_end</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-1099"><a href="#L-1099"><span class="linenos">1099</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="L-1100"><a href="#L-1100"><span class="linenos">1100</span></a> <span class="n">text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_extract_string</span><span class="p">(</span><span class="n">identifier_end</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_IDENTIFIER_ESCAPES</span><span class="p">)</span> -</span><span id="L-1101"><a href="#L-1101"><span class="linenos">1101</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">,</span> <span class="n">text</span><span class="p">)</span> -</span><span id="L-1102"><a href="#L-1102"><span class="linenos">1102</span></a> -</span><span id="L-1103"><a href="#L-1103"><span class="linenos">1103</span></a> <span class="k">def</span> <span class="nf">_scan_var</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-1104"><a href="#L-1104"><span class="linenos">1104</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-1105"><a href="#L-1105"><span class="linenos">1105</span></a> <span class="n">char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="L-1106"><a href="#L-1106"><span class="linenos">1106</span></a> <span class="k">if</span> <span class="n">char</span> <span class="ow">and</span> <span class="p">(</span><span class="n">char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">VAR_SINGLE_TOKENS</span> <span class="ow">or</span> <span class="n">char</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">):</span> -</span><span id="L-1107"><a href="#L-1107"><span class="linenos">1107</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">alnum</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1108"><a href="#L-1108"><span class="linenos">1108</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1109"><a href="#L-1109"><span class="linenos">1109</span></a> <span class="k">break</span> -</span><span id="L-1110"><a href="#L-1110"><span class="linenos">1110</span></a> -</span><span id="L-1111"><a href="#L-1111"><span class="linenos">1111</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span> -</span><span id="L-1112"><a href="#L-1112"><span class="linenos">1112</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span> -</span><span id="L-1113"><a href="#L-1113"><span class="linenos">1113</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span> -</span><span id="L-1114"><a href="#L-1114"><span class="linenos">1114</span></a> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_text</span><span class="o">.</span><span class="n">upper</span><span class="p">(),</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">)</span> -</span><span id="L-1115"><a href="#L-1115"><span class="linenos">1115</span></a> <span class="p">)</span> +</span><span id="L-1070"><a href="#L-1070"><span class="linenos">1070</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_text</span> +</span><span id="L-1071"><a href="#L-1071"><span class="linenos">1071</span></a> +</span><span id="L-1072"><a href="#L-1072"><span class="linenos">1072</span></a> <span class="k">def</span> <span class="nf">_scan_string</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">start</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="L-1073"><a href="#L-1073"><span class="linenos">1073</span></a> <span class="n">base</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-1074"><a href="#L-1074"><span class="linenos">1074</span></a> <span class="n">token_type</span> <span class="o">=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span> +</span><span id="L-1075"><a href="#L-1075"><span class="linenos">1075</span></a> +</span><span id="L-1076"><a href="#L-1076"><span class="linenos">1076</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_QUOTES</span><span class="p">:</span> +</span><span id="L-1077"><a href="#L-1077"><span class="linenos">1077</span></a> <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_QUOTES</span><span class="p">[</span><span class="n">start</span><span class="p">]</span> +</span><span id="L-1078"><a href="#L-1078"><span class="linenos">1078</span></a> <span class="k">elif</span> <span class="n">start</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_FORMAT_STRINGS</span><span class="p">:</span> +</span><span id="L-1079"><a href="#L-1079"><span class="linenos">1079</span></a> <span class="n">end</span><span class="p">,</span> <span class="n">token_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_FORMAT_STRINGS</span><span class="p">[</span><span class="n">start</span><span class="p">]</span> +</span><span id="L-1080"><a href="#L-1080"><span class="linenos">1080</span></a> +</span><span id="L-1081"><a href="#L-1081"><span class="linenos">1081</span></a> <span class="k">if</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HEX_STRING</span><span class="p">:</span> +</span><span id="L-1082"><a href="#L-1082"><span class="linenos">1082</span></a> <span class="n">base</span> <span class="o">=</span> <span class="mi">16</span> +</span><span id="L-1083"><a href="#L-1083"><span class="linenos">1083</span></a> <span class="k">elif</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIT_STRING</span><span class="p">:</span> +</span><span id="L-1084"><a href="#L-1084"><span class="linenos">1084</span></a> <span class="n">base</span> <span class="o">=</span> <span class="mi">2</span> +</span><span id="L-1085"><a href="#L-1085"><span class="linenos">1085</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1086"><a href="#L-1086"><span class="linenos">1086</span></a> <span class="k">return</span> <span class="kc">False</span> +</span><span id="L-1087"><a href="#L-1087"><span class="linenos">1087</span></a> +</span><span id="L-1088"><a href="#L-1088"><span class="linenos">1088</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">start</span><span class="p">))</span> +</span><span id="L-1089"><a href="#L-1089"><span class="linenos">1089</span></a> <span class="n">text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_extract_string</span><span class="p">(</span><span class="n">end</span><span class="p">)</span> +</span><span id="L-1090"><a href="#L-1090"><span class="linenos">1090</span></a> +</span><span id="L-1091"><a href="#L-1091"><span class="linenos">1091</span></a> <span class="k">if</span> <span class="n">base</span><span class="p">:</span> +</span><span id="L-1092"><a href="#L-1092"><span class="linenos">1092</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="L-1093"><a href="#L-1093"><span class="linenos">1093</span></a> <span class="nb">int</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="n">base</span><span class="p">)</span> +</span><span id="L-1094"><a href="#L-1094"><span class="linenos">1094</span></a> <span class="k">except</span><span class="p">:</span> +</span><span id="L-1095"><a href="#L-1095"><span class="linenos">1095</span></a> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span> +</span><span id="L-1096"><a href="#L-1096"><span class="linenos">1096</span></a> <span class="sa">f</span><span class="s2">"Numeric string contains invalid characters from </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_line</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">_start</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-1097"><a href="#L-1097"><span class="linenos">1097</span></a> <span class="p">)</span> +</span><span id="L-1098"><a href="#L-1098"><span class="linenos">1098</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1099"><a href="#L-1099"><span class="linenos">1099</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ENCODE</span><span class="p">)</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ENCODE</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ENCODE</span> <span class="k">else</span> <span class="n">text</span> +</span><span id="L-1100"><a href="#L-1100"><span class="linenos">1100</span></a> +</span><span id="L-1101"><a href="#L-1101"><span class="linenos">1101</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">text</span><span class="p">)</span> +</span><span id="L-1102"><a href="#L-1102"><span class="linenos">1102</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="L-1103"><a href="#L-1103"><span class="linenos">1103</span></a> +</span><span id="L-1104"><a href="#L-1104"><span class="linenos">1104</span></a> <span class="k">def</span> <span class="nf">_scan_identifier</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">identifier_end</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-1105"><a href="#L-1105"><span class="linenos">1105</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="L-1106"><a href="#L-1106"><span class="linenos">1106</span></a> <span class="n">text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_extract_string</span><span class="p">(</span><span class="n">identifier_end</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_IDENTIFIER_ESCAPES</span><span class="p">)</span> +</span><span id="L-1107"><a href="#L-1107"><span class="linenos">1107</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">,</span> <span class="n">text</span><span class="p">)</span> +</span><span id="L-1108"><a href="#L-1108"><span class="linenos">1108</span></a> +</span><span id="L-1109"><a href="#L-1109"><span class="linenos">1109</span></a> <span class="k">def</span> <span class="nf">_scan_var</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-1110"><a href="#L-1110"><span class="linenos">1110</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-1111"><a href="#L-1111"><span class="linenos">1111</span></a> <span class="n">char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="L-1112"><a href="#L-1112"><span class="linenos">1112</span></a> <span class="k">if</span> <span class="n">char</span> <span class="ow">and</span> <span class="p">(</span><span class="n">char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">VAR_SINGLE_TOKENS</span> <span class="ow">or</span> <span class="n">char</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">):</span> +</span><span id="L-1113"><a href="#L-1113"><span class="linenos">1113</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">alnum</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1114"><a href="#L-1114"><span class="linenos">1114</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1115"><a href="#L-1115"><span class="linenos">1115</span></a> <span class="k">break</span> </span><span id="L-1116"><a href="#L-1116"><span class="linenos">1116</span></a> -</span><span id="L-1117"><a href="#L-1117"><span class="linenos">1117</span></a> <span class="k">def</span> <span class="nf">_extract_string</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">delimiter</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">escapes</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-1118"><a href="#L-1118"><span class="linenos">1118</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-1119"><a href="#L-1119"><span class="linenos">1119</span></a> <span class="n">delim_size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">delimiter</span><span class="p">)</span> -</span><span id="L-1120"><a href="#L-1120"><span class="linenos">1120</span></a> <span class="n">escapes</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_STRING_ESCAPES</span> <span class="k">if</span> <span class="n">escapes</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">escapes</span> -</span><span id="L-1121"><a href="#L-1121"><span class="linenos">1121</span></a> -</span><span id="L-1122"><a href="#L-1122"><span class="linenos">1122</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="L-1123"><a href="#L-1123"><span class="linenos">1123</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">in</span> <span class="n">escapes</span> <span class="ow">and</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">==</span> <span class="n">delimiter</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="ow">in</span> <span class="n">escapes</span><span class="p">):</span> -</span><span id="L-1124"><a href="#L-1124"><span class="linenos">1124</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">==</span> <span class="n">delimiter</span><span class="p">:</span> -</span><span id="L-1125"><a href="#L-1125"><span class="linenos">1125</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> -</span><span id="L-1126"><a href="#L-1126"><span class="linenos">1126</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1127"><a href="#L-1127"><span class="linenos">1127</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> -</span><span id="L-1128"><a href="#L-1128"><span class="linenos">1128</span></a> -</span><span id="L-1129"><a href="#L-1129"><span class="linenos">1129</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+</span> <span class="mi">1</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span><span class="p">:</span> -</span><span id="L-1130"><a href="#L-1130"><span class="linenos">1130</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> -</span><span id="L-1131"><a href="#L-1131"><span class="linenos">1131</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1132"><a href="#L-1132"><span class="linenos">1132</span></a> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Missing </span><span class="si">{</span><span class="n">delimiter</span><span class="si">}</span><span class="s2"> from </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_line</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">_current</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-1133"><a href="#L-1133"><span class="linenos">1133</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-1134"><a href="#L-1134"><span class="linenos">1134</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_chars</span><span class="p">(</span><span class="n">delim_size</span><span class="p">)</span> <span class="o">==</span> <span class="n">delimiter</span><span class="p">:</span> -</span><span id="L-1135"><a href="#L-1135"><span class="linenos">1135</span></a> <span class="k">if</span> <span class="n">delim_size</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-1136"><a href="#L-1136"><span class="linenos">1136</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">delim_size</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="L-1137"><a href="#L-1137"><span class="linenos">1137</span></a> <span class="k">break</span> -</span><span id="L-1138"><a href="#L-1138"><span class="linenos">1138</span></a> -</span><span id="L-1139"><a href="#L-1139"><span class="linenos">1139</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span><span class="p">:</span> -</span><span id="L-1140"><a href="#L-1140"><span class="linenos">1140</span></a> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Missing </span><span class="si">{</span><span class="n">delimiter</span><span class="si">}</span><span class="s2"> from </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_line</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">_start</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-1141"><a href="#L-1141"><span class="linenos">1141</span></a> -</span><span id="L-1142"><a href="#L-1142"><span class="linenos">1142</span></a> <span class="n">current</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span> -</span><span id="L-1143"><a href="#L-1143"><span class="linenos">1143</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">alnum</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-1144"><a href="#L-1144"><span class="linenos">1144</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">current</span> <span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> -</span><span id="L-1145"><a href="#L-1145"><span class="linenos">1145</span></a> -</span><span id="L-1146"><a href="#L-1146"><span class="linenos">1146</span></a> <span class="k">return</span> <span class="n">text</span> +</span><span id="L-1117"><a href="#L-1117"><span class="linenos">1117</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span> +</span><span id="L-1118"><a href="#L-1118"><span class="linenos">1118</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span> +</span><span id="L-1119"><a href="#L-1119"><span class="linenos">1119</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span> +</span><span id="L-1120"><a href="#L-1120"><span class="linenos">1120</span></a> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_text</span><span class="o">.</span><span class="n">upper</span><span class="p">(),</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">)</span> +</span><span id="L-1121"><a href="#L-1121"><span class="linenos">1121</span></a> <span class="p">)</span> +</span><span id="L-1122"><a href="#L-1122"><span class="linenos">1122</span></a> +</span><span id="L-1123"><a href="#L-1123"><span class="linenos">1123</span></a> <span class="k">def</span> <span class="nf">_extract_string</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">delimiter</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">escapes</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-1124"><a href="#L-1124"><span class="linenos">1124</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-1125"><a href="#L-1125"><span class="linenos">1125</span></a> <span class="n">delim_size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">delimiter</span><span class="p">)</span> +</span><span id="L-1126"><a href="#L-1126"><span class="linenos">1126</span></a> <span class="n">escapes</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_STRING_ESCAPES</span> <span class="k">if</span> <span class="n">escapes</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">escapes</span> +</span><span id="L-1127"><a href="#L-1127"><span class="linenos">1127</span></a> +</span><span id="L-1128"><a href="#L-1128"><span class="linenos">1128</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="L-1129"><a href="#L-1129"><span class="linenos">1129</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">in</span> <span class="n">escapes</span> <span class="ow">and</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">==</span> <span class="n">delimiter</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="ow">in</span> <span class="n">escapes</span><span class="p">):</span> +</span><span id="L-1130"><a href="#L-1130"><span class="linenos">1130</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">==</span> <span class="n">delimiter</span><span class="p">:</span> +</span><span id="L-1131"><a href="#L-1131"><span class="linenos">1131</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> +</span><span id="L-1132"><a href="#L-1132"><span class="linenos">1132</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1133"><a href="#L-1133"><span class="linenos">1133</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> +</span><span id="L-1134"><a href="#L-1134"><span class="linenos">1134</span></a> +</span><span id="L-1135"><a href="#L-1135"><span class="linenos">1135</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+</span> <span class="mi">1</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span><span class="p">:</span> +</span><span id="L-1136"><a href="#L-1136"><span class="linenos">1136</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> +</span><span id="L-1137"><a href="#L-1137"><span class="linenos">1137</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1138"><a href="#L-1138"><span class="linenos">1138</span></a> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Missing </span><span class="si">{</span><span class="n">delimiter</span><span class="si">}</span><span class="s2"> from </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_line</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">_current</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-1139"><a href="#L-1139"><span class="linenos">1139</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-1140"><a href="#L-1140"><span class="linenos">1140</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_chars</span><span class="p">(</span><span class="n">delim_size</span><span class="p">)</span> <span class="o">==</span> <span class="n">delimiter</span><span class="p">:</span> +</span><span id="L-1141"><a href="#L-1141"><span class="linenos">1141</span></a> <span class="k">if</span> <span class="n">delim_size</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-1142"><a href="#L-1142"><span class="linenos">1142</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">delim_size</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="L-1143"><a href="#L-1143"><span class="linenos">1143</span></a> <span class="k">break</span> +</span><span id="L-1144"><a href="#L-1144"><span class="linenos">1144</span></a> +</span><span id="L-1145"><a href="#L-1145"><span class="linenos">1145</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span><span class="p">:</span> +</span><span id="L-1146"><a href="#L-1146"><span class="linenos">1146</span></a> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Missing </span><span class="si">{</span><span class="n">delimiter</span><span class="si">}</span><span class="s2"> from </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_line</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">_start</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-1147"><a href="#L-1147"><span class="linenos">1147</span></a> +</span><span id="L-1148"><a href="#L-1148"><span class="linenos">1148</span></a> <span class="n">current</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span> +</span><span id="L-1149"><a href="#L-1149"><span class="linenos">1149</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">alnum</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-1150"><a href="#L-1150"><span class="linenos">1150</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">current</span> <span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> +</span><span id="L-1151"><a href="#L-1151"><span class="linenos">1151</span></a> +</span><span id="L-1152"><a href="#L-1152"><span class="linenos">1152</span></a> <span class="k">return</span> <span class="n">text</span> </span></pre></div> @@ -2276,146 +2291,149 @@ </span><span id="TokenType-164"><a href="#TokenType-164"><span class="linenos">164</span></a> <span class="n">CACHE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> </span><span id="TokenType-165"><a href="#TokenType-165"><span class="linenos">165</span></a> <span class="n">CASE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> </span><span id="TokenType-166"><a href="#TokenType-166"><span class="linenos">166</span></a> <span class="n">CHARACTER_SET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-167"><a href="#TokenType-167"><span class="linenos">167</span></a> <span class="n">COLLATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-168"><a href="#TokenType-168"><span class="linenos">168</span></a> <span class="n">COMMAND</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-169"><a href="#TokenType-169"><span class="linenos">169</span></a> <span class="n">COMMENT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-170"><a href="#TokenType-170"><span class="linenos">170</span></a> <span class="n">COMMIT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-171"><a href="#TokenType-171"><span class="linenos">171</span></a> <span class="n">CONSTRAINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-172"><a href="#TokenType-172"><span class="linenos">172</span></a> <span class="n">CREATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-173"><a href="#TokenType-173"><span class="linenos">173</span></a> <span class="n">CROSS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-174"><a href="#TokenType-174"><span class="linenos">174</span></a> <span class="n">CUBE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-175"><a href="#TokenType-175"><span class="linenos">175</span></a> <span class="n">CURRENT_DATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-176"><a href="#TokenType-176"><span class="linenos">176</span></a> <span class="n">CURRENT_DATETIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-177"><a href="#TokenType-177"><span class="linenos">177</span></a> <span class="n">CURRENT_TIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-178"><a href="#TokenType-178"><span class="linenos">178</span></a> <span class="n">CURRENT_TIMESTAMP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-179"><a href="#TokenType-179"><span class="linenos">179</span></a> <span class="n">CURRENT_USER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-180"><a href="#TokenType-180"><span class="linenos">180</span></a> <span class="n">DEFAULT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-181"><a href="#TokenType-181"><span class="linenos">181</span></a> <span class="n">DELETE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-182"><a href="#TokenType-182"><span class="linenos">182</span></a> <span class="n">DESC</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-183"><a href="#TokenType-183"><span class="linenos">183</span></a> <span class="n">DESCRIBE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-184"><a href="#TokenType-184"><span class="linenos">184</span></a> <span class="n">DICTIONARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-185"><a href="#TokenType-185"><span class="linenos">185</span></a> <span class="n">DISTINCT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-186"><a href="#TokenType-186"><span class="linenos">186</span></a> <span class="n">DIV</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-187"><a href="#TokenType-187"><span class="linenos">187</span></a> <span class="n">DROP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-188"><a href="#TokenType-188"><span class="linenos">188</span></a> <span class="n">ELSE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-189"><a href="#TokenType-189"><span class="linenos">189</span></a> <span class="n">END</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-190"><a href="#TokenType-190"><span class="linenos">190</span></a> <span class="n">ESCAPE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-191"><a href="#TokenType-191"><span class="linenos">191</span></a> <span class="n">EXCEPT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-192"><a href="#TokenType-192"><span class="linenos">192</span></a> <span class="n">EXECUTE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-193"><a href="#TokenType-193"><span class="linenos">193</span></a> <span class="n">EXISTS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-194"><a href="#TokenType-194"><span class="linenos">194</span></a> <span class="n">FALSE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-195"><a href="#TokenType-195"><span class="linenos">195</span></a> <span class="n">FETCH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-196"><a href="#TokenType-196"><span class="linenos">196</span></a> <span class="n">FILTER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-197"><a href="#TokenType-197"><span class="linenos">197</span></a> <span class="n">FINAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-198"><a href="#TokenType-198"><span class="linenos">198</span></a> <span class="n">FIRST</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-199"><a href="#TokenType-199"><span class="linenos">199</span></a> <span class="n">FOR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-200"><a href="#TokenType-200"><span class="linenos">200</span></a> <span class="n">FOREIGN_KEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-201"><a href="#TokenType-201"><span class="linenos">201</span></a> <span class="n">FORMAT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-202"><a href="#TokenType-202"><span class="linenos">202</span></a> <span class="n">FROM</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-203"><a href="#TokenType-203"><span class="linenos">203</span></a> <span class="n">FULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-204"><a href="#TokenType-204"><span class="linenos">204</span></a> <span class="n">FUNCTION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-205"><a href="#TokenType-205"><span class="linenos">205</span></a> <span class="n">GLOB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-206"><a href="#TokenType-206"><span class="linenos">206</span></a> <span class="n">GLOBAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-207"><a href="#TokenType-207"><span class="linenos">207</span></a> <span class="n">GROUP_BY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-208"><a href="#TokenType-208"><span class="linenos">208</span></a> <span class="n">GROUPING_SETS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-209"><a href="#TokenType-209"><span class="linenos">209</span></a> <span class="n">HAVING</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-210"><a href="#TokenType-210"><span class="linenos">210</span></a> <span class="n">HINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-211"><a href="#TokenType-211"><span class="linenos">211</span></a> <span class="n">IF</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-212"><a href="#TokenType-212"><span class="linenos">212</span></a> <span class="n">ILIKE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-213"><a href="#TokenType-213"><span class="linenos">213</span></a> <span class="n">ILIKE_ANY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-214"><a href="#TokenType-214"><span class="linenos">214</span></a> <span class="n">IN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-215"><a href="#TokenType-215"><span class="linenos">215</span></a> <span class="n">INDEX</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-216"><a href="#TokenType-216"><span class="linenos">216</span></a> <span class="n">INNER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-217"><a href="#TokenType-217"><span class="linenos">217</span></a> <span class="n">INSERT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-218"><a href="#TokenType-218"><span class="linenos">218</span></a> <span class="n">INTERSECT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-219"><a href="#TokenType-219"><span class="linenos">219</span></a> <span class="n">INTERVAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-220"><a href="#TokenType-220"><span class="linenos">220</span></a> <span class="n">INTO</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-221"><a href="#TokenType-221"><span class="linenos">221</span></a> <span class="n">INTRODUCER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-222"><a href="#TokenType-222"><span class="linenos">222</span></a> <span class="n">IRLIKE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-223"><a href="#TokenType-223"><span class="linenos">223</span></a> <span class="n">IS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-224"><a href="#TokenType-224"><span class="linenos">224</span></a> <span class="n">ISNULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-225"><a href="#TokenType-225"><span class="linenos">225</span></a> <span class="n">JOIN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-226"><a href="#TokenType-226"><span class="linenos">226</span></a> <span class="n">JOIN_MARKER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-227"><a href="#TokenType-227"><span class="linenos">227</span></a> <span class="n">KEEP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-228"><a href="#TokenType-228"><span class="linenos">228</span></a> <span class="n">LANGUAGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-229"><a href="#TokenType-229"><span class="linenos">229</span></a> <span class="n">LATERAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-230"><a href="#TokenType-230"><span class="linenos">230</span></a> <span class="n">LEFT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-231"><a href="#TokenType-231"><span class="linenos">231</span></a> <span class="n">LIKE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-232"><a href="#TokenType-232"><span class="linenos">232</span></a> <span class="n">LIKE_ANY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-233"><a href="#TokenType-233"><span class="linenos">233</span></a> <span class="n">LIMIT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-234"><a href="#TokenType-234"><span class="linenos">234</span></a> <span class="n">LOAD</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-235"><a href="#TokenType-235"><span class="linenos">235</span></a> <span class="n">LOCK</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-236"><a href="#TokenType-236"><span class="linenos">236</span></a> <span class="n">MAP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-237"><a href="#TokenType-237"><span class="linenos">237</span></a> <span class="n">MATCH_RECOGNIZE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-238"><a href="#TokenType-238"><span class="linenos">238</span></a> <span class="n">MERGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-239"><a href="#TokenType-239"><span class="linenos">239</span></a> <span class="n">MOD</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-240"><a href="#TokenType-240"><span class="linenos">240</span></a> <span class="n">NATURAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-241"><a href="#TokenType-241"><span class="linenos">241</span></a> <span class="n">NEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-242"><a href="#TokenType-242"><span class="linenos">242</span></a> <span class="n">NEXT_VALUE_FOR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-243"><a href="#TokenType-243"><span class="linenos">243</span></a> <span class="n">NOTNULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-244"><a href="#TokenType-244"><span class="linenos">244</span></a> <span class="n">NULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-245"><a href="#TokenType-245"><span class="linenos">245</span></a> <span class="n">OFFSET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-246"><a href="#TokenType-246"><span class="linenos">246</span></a> <span class="n">ON</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-247"><a href="#TokenType-247"><span class="linenos">247</span></a> <span class="n">ORDER_BY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-248"><a href="#TokenType-248"><span class="linenos">248</span></a> <span class="n">ORDERED</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-249"><a href="#TokenType-249"><span class="linenos">249</span></a> <span class="n">ORDINALITY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-250"><a href="#TokenType-250"><span class="linenos">250</span></a> <span class="n">OUTER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-251"><a href="#TokenType-251"><span class="linenos">251</span></a> <span class="n">OVER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-252"><a href="#TokenType-252"><span class="linenos">252</span></a> <span class="n">OVERLAPS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-253"><a href="#TokenType-253"><span class="linenos">253</span></a> <span class="n">OVERWRITE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-254"><a href="#TokenType-254"><span class="linenos">254</span></a> <span class="n">PARTITION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-255"><a href="#TokenType-255"><span class="linenos">255</span></a> <span class="n">PARTITION_BY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-256"><a href="#TokenType-256"><span class="linenos">256</span></a> <span class="n">PERCENT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-257"><a href="#TokenType-257"><span class="linenos">257</span></a> <span class="n">PIVOT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-258"><a href="#TokenType-258"><span class="linenos">258</span></a> <span class="n">PLACEHOLDER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-259"><a href="#TokenType-259"><span class="linenos">259</span></a> <span class="n">PRAGMA</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-260"><a href="#TokenType-260"><span class="linenos">260</span></a> <span class="n">PRIMARY_KEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-261"><a href="#TokenType-261"><span class="linenos">261</span></a> <span class="n">PROCEDURE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-262"><a href="#TokenType-262"><span class="linenos">262</span></a> <span class="n">PROPERTIES</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-263"><a href="#TokenType-263"><span class="linenos">263</span></a> <span class="n">PSEUDO_TYPE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-264"><a href="#TokenType-264"><span class="linenos">264</span></a> <span class="n">QUALIFY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-265"><a href="#TokenType-265"><span class="linenos">265</span></a> <span class="n">QUOTE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-266"><a href="#TokenType-266"><span class="linenos">266</span></a> <span class="n">RANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-267"><a href="#TokenType-267"><span class="linenos">267</span></a> <span class="n">RECURSIVE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-268"><a href="#TokenType-268"><span class="linenos">268</span></a> <span class="n">REPLACE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-269"><a href="#TokenType-269"><span class="linenos">269</span></a> <span class="n">RETURNING</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-270"><a href="#TokenType-270"><span class="linenos">270</span></a> <span class="n">REFERENCES</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-271"><a href="#TokenType-271"><span class="linenos">271</span></a> <span class="n">RIGHT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-272"><a href="#TokenType-272"><span class="linenos">272</span></a> <span class="n">RLIKE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-273"><a href="#TokenType-273"><span class="linenos">273</span></a> <span class="n">ROLLBACK</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-274"><a href="#TokenType-274"><span class="linenos">274</span></a> <span class="n">ROLLUP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-275"><a href="#TokenType-275"><span class="linenos">275</span></a> <span class="n">ROW</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-276"><a href="#TokenType-276"><span class="linenos">276</span></a> <span class="n">ROWS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-277"><a href="#TokenType-277"><span class="linenos">277</span></a> <span class="n">SELECT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-278"><a href="#TokenType-278"><span class="linenos">278</span></a> <span class="n">SEMI</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-279"><a href="#TokenType-279"><span class="linenos">279</span></a> <span class="n">SEPARATOR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-280"><a href="#TokenType-280"><span class="linenos">280</span></a> <span class="n">SERDE_PROPERTIES</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-281"><a href="#TokenType-281"><span class="linenos">281</span></a> <span class="n">SET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-282"><a href="#TokenType-282"><span class="linenos">282</span></a> <span class="n">SETTINGS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-283"><a href="#TokenType-283"><span class="linenos">283</span></a> <span class="n">SHOW</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-284"><a href="#TokenType-284"><span class="linenos">284</span></a> <span class="n">SIMILAR_TO</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-285"><a href="#TokenType-285"><span class="linenos">285</span></a> <span class="n">SOME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-286"><a href="#TokenType-286"><span class="linenos">286</span></a> <span class="n">STRUCT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-287"><a href="#TokenType-287"><span class="linenos">287</span></a> <span class="n">TABLE_SAMPLE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-288"><a href="#TokenType-288"><span class="linenos">288</span></a> <span class="n">TEMPORARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-289"><a href="#TokenType-289"><span class="linenos">289</span></a> <span class="n">TOP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-290"><a href="#TokenType-290"><span class="linenos">290</span></a> <span class="n">THEN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-291"><a href="#TokenType-291"><span class="linenos">291</span></a> <span class="n">TRUE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-292"><a href="#TokenType-292"><span class="linenos">292</span></a> <span class="n">UNCACHE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-293"><a href="#TokenType-293"><span class="linenos">293</span></a> <span class="n">UNION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-294"><a href="#TokenType-294"><span class="linenos">294</span></a> <span class="n">UNNEST</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-295"><a href="#TokenType-295"><span class="linenos">295</span></a> <span class="n">UNPIVOT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-296"><a href="#TokenType-296"><span class="linenos">296</span></a> <span class="n">UPDATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-297"><a href="#TokenType-297"><span class="linenos">297</span></a> <span class="n">USE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-298"><a href="#TokenType-298"><span class="linenos">298</span></a> <span class="n">USING</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-299"><a href="#TokenType-299"><span class="linenos">299</span></a> <span class="n">VALUES</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-300"><a href="#TokenType-300"><span class="linenos">300</span></a> <span class="n">VIEW</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-301"><a href="#TokenType-301"><span class="linenos">301</span></a> <span class="n">VOLATILE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-302"><a href="#TokenType-302"><span class="linenos">302</span></a> <span class="n">WHEN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-303"><a href="#TokenType-303"><span class="linenos">303</span></a> <span class="n">WHERE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-304"><a href="#TokenType-304"><span class="linenos">304</span></a> <span class="n">WINDOW</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-305"><a href="#TokenType-305"><span class="linenos">305</span></a> <span class="n">WITH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> -</span><span id="TokenType-306"><a href="#TokenType-306"><span class="linenos">306</span></a> <span class="n">UNIQUE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-167"><a href="#TokenType-167"><span class="linenos">167</span></a> <span class="n">CLUSTER_BY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-168"><a href="#TokenType-168"><span class="linenos">168</span></a> <span class="n">COLLATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-169"><a href="#TokenType-169"><span class="linenos">169</span></a> <span class="n">COMMAND</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-170"><a href="#TokenType-170"><span class="linenos">170</span></a> <span class="n">COMMENT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-171"><a href="#TokenType-171"><span class="linenos">171</span></a> <span class="n">COMMIT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-172"><a href="#TokenType-172"><span class="linenos">172</span></a> <span class="n">CONSTRAINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-173"><a href="#TokenType-173"><span class="linenos">173</span></a> <span class="n">CREATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-174"><a href="#TokenType-174"><span class="linenos">174</span></a> <span class="n">CROSS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-175"><a href="#TokenType-175"><span class="linenos">175</span></a> <span class="n">CUBE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-176"><a href="#TokenType-176"><span class="linenos">176</span></a> <span class="n">CURRENT_DATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-177"><a href="#TokenType-177"><span class="linenos">177</span></a> <span class="n">CURRENT_DATETIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-178"><a href="#TokenType-178"><span class="linenos">178</span></a> <span class="n">CURRENT_TIME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-179"><a href="#TokenType-179"><span class="linenos">179</span></a> <span class="n">CURRENT_TIMESTAMP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-180"><a href="#TokenType-180"><span class="linenos">180</span></a> <span class="n">CURRENT_USER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-181"><a href="#TokenType-181"><span class="linenos">181</span></a> <span class="n">DEFAULT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-182"><a href="#TokenType-182"><span class="linenos">182</span></a> <span class="n">DELETE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-183"><a href="#TokenType-183"><span class="linenos">183</span></a> <span class="n">DESC</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-184"><a href="#TokenType-184"><span class="linenos">184</span></a> <span class="n">DESCRIBE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-185"><a href="#TokenType-185"><span class="linenos">185</span></a> <span class="n">DICTIONARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-186"><a href="#TokenType-186"><span class="linenos">186</span></a> <span class="n">DISTINCT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-187"><a href="#TokenType-187"><span class="linenos">187</span></a> <span class="n">DISTRIBUTE_BY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-188"><a href="#TokenType-188"><span class="linenos">188</span></a> <span class="n">DIV</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-189"><a href="#TokenType-189"><span class="linenos">189</span></a> <span class="n">DROP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-190"><a href="#TokenType-190"><span class="linenos">190</span></a> <span class="n">ELSE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-191"><a href="#TokenType-191"><span class="linenos">191</span></a> <span class="n">END</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-192"><a href="#TokenType-192"><span class="linenos">192</span></a> <span class="n">ESCAPE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-193"><a href="#TokenType-193"><span class="linenos">193</span></a> <span class="n">EXCEPT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-194"><a href="#TokenType-194"><span class="linenos">194</span></a> <span class="n">EXECUTE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-195"><a href="#TokenType-195"><span class="linenos">195</span></a> <span class="n">EXISTS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-196"><a href="#TokenType-196"><span class="linenos">196</span></a> <span class="n">FALSE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-197"><a href="#TokenType-197"><span class="linenos">197</span></a> <span class="n">FETCH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-198"><a href="#TokenType-198"><span class="linenos">198</span></a> <span class="n">FILTER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-199"><a href="#TokenType-199"><span class="linenos">199</span></a> <span class="n">FINAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-200"><a href="#TokenType-200"><span class="linenos">200</span></a> <span class="n">FIRST</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-201"><a href="#TokenType-201"><span class="linenos">201</span></a> <span class="n">FOR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-202"><a href="#TokenType-202"><span class="linenos">202</span></a> <span class="n">FOREIGN_KEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-203"><a href="#TokenType-203"><span class="linenos">203</span></a> <span class="n">FORMAT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-204"><a href="#TokenType-204"><span class="linenos">204</span></a> <span class="n">FROM</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-205"><a href="#TokenType-205"><span class="linenos">205</span></a> <span class="n">FULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-206"><a href="#TokenType-206"><span class="linenos">206</span></a> <span class="n">FUNCTION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-207"><a href="#TokenType-207"><span class="linenos">207</span></a> <span class="n">GLOB</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-208"><a href="#TokenType-208"><span class="linenos">208</span></a> <span class="n">GLOBAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-209"><a href="#TokenType-209"><span class="linenos">209</span></a> <span class="n">GROUP_BY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-210"><a href="#TokenType-210"><span class="linenos">210</span></a> <span class="n">GROUPING_SETS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-211"><a href="#TokenType-211"><span class="linenos">211</span></a> <span class="n">HAVING</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-212"><a href="#TokenType-212"><span class="linenos">212</span></a> <span class="n">HINT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-213"><a href="#TokenType-213"><span class="linenos">213</span></a> <span class="n">IF</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-214"><a href="#TokenType-214"><span class="linenos">214</span></a> <span class="n">ILIKE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-215"><a href="#TokenType-215"><span class="linenos">215</span></a> <span class="n">ILIKE_ANY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-216"><a href="#TokenType-216"><span class="linenos">216</span></a> <span class="n">IN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-217"><a href="#TokenType-217"><span class="linenos">217</span></a> <span class="n">INDEX</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-218"><a href="#TokenType-218"><span class="linenos">218</span></a> <span class="n">INNER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-219"><a href="#TokenType-219"><span class="linenos">219</span></a> <span class="n">INSERT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-220"><a href="#TokenType-220"><span class="linenos">220</span></a> <span class="n">INTERSECT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-221"><a href="#TokenType-221"><span class="linenos">221</span></a> <span class="n">INTERVAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-222"><a href="#TokenType-222"><span class="linenos">222</span></a> <span class="n">INTO</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-223"><a href="#TokenType-223"><span class="linenos">223</span></a> <span class="n">INTRODUCER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-224"><a href="#TokenType-224"><span class="linenos">224</span></a> <span class="n">IRLIKE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-225"><a href="#TokenType-225"><span class="linenos">225</span></a> <span class="n">IS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-226"><a href="#TokenType-226"><span class="linenos">226</span></a> <span class="n">ISNULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-227"><a href="#TokenType-227"><span class="linenos">227</span></a> <span class="n">JOIN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-228"><a href="#TokenType-228"><span class="linenos">228</span></a> <span class="n">JOIN_MARKER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-229"><a href="#TokenType-229"><span class="linenos">229</span></a> <span class="n">KEEP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-230"><a href="#TokenType-230"><span class="linenos">230</span></a> <span class="n">LANGUAGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-231"><a href="#TokenType-231"><span class="linenos">231</span></a> <span class="n">LATERAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-232"><a href="#TokenType-232"><span class="linenos">232</span></a> <span class="n">LEFT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-233"><a href="#TokenType-233"><span class="linenos">233</span></a> <span class="n">LIKE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-234"><a href="#TokenType-234"><span class="linenos">234</span></a> <span class="n">LIKE_ANY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-235"><a href="#TokenType-235"><span class="linenos">235</span></a> <span class="n">LIMIT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-236"><a href="#TokenType-236"><span class="linenos">236</span></a> <span class="n">LOAD</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-237"><a href="#TokenType-237"><span class="linenos">237</span></a> <span class="n">LOCK</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-238"><a href="#TokenType-238"><span class="linenos">238</span></a> <span class="n">MAP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-239"><a href="#TokenType-239"><span class="linenos">239</span></a> <span class="n">MATCH_RECOGNIZE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-240"><a href="#TokenType-240"><span class="linenos">240</span></a> <span class="n">MERGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-241"><a href="#TokenType-241"><span class="linenos">241</span></a> <span class="n">MOD</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-242"><a href="#TokenType-242"><span class="linenos">242</span></a> <span class="n">NATURAL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-243"><a href="#TokenType-243"><span class="linenos">243</span></a> <span class="n">NEXT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-244"><a href="#TokenType-244"><span class="linenos">244</span></a> <span class="n">NEXT_VALUE_FOR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-245"><a href="#TokenType-245"><span class="linenos">245</span></a> <span class="n">NOTNULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-246"><a href="#TokenType-246"><span class="linenos">246</span></a> <span class="n">NULL</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-247"><a href="#TokenType-247"><span class="linenos">247</span></a> <span class="n">OFFSET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-248"><a href="#TokenType-248"><span class="linenos">248</span></a> <span class="n">ON</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-249"><a href="#TokenType-249"><span class="linenos">249</span></a> <span class="n">ORDER_BY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-250"><a href="#TokenType-250"><span class="linenos">250</span></a> <span class="n">ORDERED</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-251"><a href="#TokenType-251"><span class="linenos">251</span></a> <span class="n">ORDINALITY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-252"><a href="#TokenType-252"><span class="linenos">252</span></a> <span class="n">OUTER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-253"><a href="#TokenType-253"><span class="linenos">253</span></a> <span class="n">OVER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-254"><a href="#TokenType-254"><span class="linenos">254</span></a> <span class="n">OVERLAPS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-255"><a href="#TokenType-255"><span class="linenos">255</span></a> <span class="n">OVERWRITE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-256"><a href="#TokenType-256"><span class="linenos">256</span></a> <span class="n">PARTITION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-257"><a href="#TokenType-257"><span class="linenos">257</span></a> <span class="n">PARTITION_BY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-258"><a href="#TokenType-258"><span class="linenos">258</span></a> <span class="n">PERCENT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-259"><a href="#TokenType-259"><span class="linenos">259</span></a> <span class="n">PIVOT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-260"><a href="#TokenType-260"><span class="linenos">260</span></a> <span class="n">PLACEHOLDER</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-261"><a href="#TokenType-261"><span class="linenos">261</span></a> <span class="n">PRAGMA</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-262"><a href="#TokenType-262"><span class="linenos">262</span></a> <span class="n">PRIMARY_KEY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-263"><a href="#TokenType-263"><span class="linenos">263</span></a> <span class="n">PROCEDURE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-264"><a href="#TokenType-264"><span class="linenos">264</span></a> <span class="n">PROPERTIES</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-265"><a href="#TokenType-265"><span class="linenos">265</span></a> <span class="n">PSEUDO_TYPE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-266"><a href="#TokenType-266"><span class="linenos">266</span></a> <span class="n">QUALIFY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-267"><a href="#TokenType-267"><span class="linenos">267</span></a> <span class="n">QUOTE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-268"><a href="#TokenType-268"><span class="linenos">268</span></a> <span class="n">RANGE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-269"><a href="#TokenType-269"><span class="linenos">269</span></a> <span class="n">RECURSIVE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-270"><a href="#TokenType-270"><span class="linenos">270</span></a> <span class="n">REPLACE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-271"><a href="#TokenType-271"><span class="linenos">271</span></a> <span class="n">RETURNING</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-272"><a href="#TokenType-272"><span class="linenos">272</span></a> <span class="n">REFERENCES</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-273"><a href="#TokenType-273"><span class="linenos">273</span></a> <span class="n">RIGHT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-274"><a href="#TokenType-274"><span class="linenos">274</span></a> <span class="n">RLIKE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-275"><a href="#TokenType-275"><span class="linenos">275</span></a> <span class="n">ROLLBACK</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-276"><a href="#TokenType-276"><span class="linenos">276</span></a> <span class="n">ROLLUP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-277"><a href="#TokenType-277"><span class="linenos">277</span></a> <span class="n">ROW</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-278"><a href="#TokenType-278"><span class="linenos">278</span></a> <span class="n">ROWS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-279"><a href="#TokenType-279"><span class="linenos">279</span></a> <span class="n">SELECT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-280"><a href="#TokenType-280"><span class="linenos">280</span></a> <span class="n">SEMI</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-281"><a href="#TokenType-281"><span class="linenos">281</span></a> <span class="n">SEPARATOR</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-282"><a href="#TokenType-282"><span class="linenos">282</span></a> <span class="n">SERDE_PROPERTIES</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-283"><a href="#TokenType-283"><span class="linenos">283</span></a> <span class="n">SET</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-284"><a href="#TokenType-284"><span class="linenos">284</span></a> <span class="n">SETTINGS</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-285"><a href="#TokenType-285"><span class="linenos">285</span></a> <span class="n">SHOW</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-286"><a href="#TokenType-286"><span class="linenos">286</span></a> <span class="n">SIMILAR_TO</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-287"><a href="#TokenType-287"><span class="linenos">287</span></a> <span class="n">SOME</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-288"><a href="#TokenType-288"><span class="linenos">288</span></a> <span class="n">SORT_BY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-289"><a href="#TokenType-289"><span class="linenos">289</span></a> <span class="n">STRUCT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-290"><a href="#TokenType-290"><span class="linenos">290</span></a> <span class="n">TABLE_SAMPLE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-291"><a href="#TokenType-291"><span class="linenos">291</span></a> <span class="n">TEMPORARY</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-292"><a href="#TokenType-292"><span class="linenos">292</span></a> <span class="n">TOP</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-293"><a href="#TokenType-293"><span class="linenos">293</span></a> <span class="n">THEN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-294"><a href="#TokenType-294"><span class="linenos">294</span></a> <span class="n">TRUE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-295"><a href="#TokenType-295"><span class="linenos">295</span></a> <span class="n">UNCACHE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-296"><a href="#TokenType-296"><span class="linenos">296</span></a> <span class="n">UNION</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-297"><a href="#TokenType-297"><span class="linenos">297</span></a> <span class="n">UNNEST</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-298"><a href="#TokenType-298"><span class="linenos">298</span></a> <span class="n">UNPIVOT</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-299"><a href="#TokenType-299"><span class="linenos">299</span></a> <span class="n">UPDATE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-300"><a href="#TokenType-300"><span class="linenos">300</span></a> <span class="n">USE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-301"><a href="#TokenType-301"><span class="linenos">301</span></a> <span class="n">USING</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-302"><a href="#TokenType-302"><span class="linenos">302</span></a> <span class="n">VALUES</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-303"><a href="#TokenType-303"><span class="linenos">303</span></a> <span class="n">VIEW</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-304"><a href="#TokenType-304"><span class="linenos">304</span></a> <span class="n">VOLATILE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-305"><a href="#TokenType-305"><span class="linenos">305</span></a> <span class="n">WHEN</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-306"><a href="#TokenType-306"><span class="linenos">306</span></a> <span class="n">WHERE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-307"><a href="#TokenType-307"><span class="linenos">307</span></a> <span class="n">WINDOW</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-308"><a href="#TokenType-308"><span class="linenos">308</span></a> <span class="n">WITH</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> +</span><span id="TokenType-309"><a href="#TokenType-309"><span class="linenos">309</span></a> <span class="n">UNIQUE</span> <span class="o">=</span> <span class="n">auto</span><span class="p">()</span> </span></pre></div> @@ -4199,6 +4217,18 @@ </div> + <div id="TokenType.CLUSTER_BY" class="classattr"> + <div class="attr variable"> + <span class="name">CLUSTER_BY</span> = +<span class="default_value"><<a href="#TokenType.CLUSTER_BY">TokenType.CLUSTER_BY</a>: 'CLUSTER_BY'></span> + + + </div> + <a class="headerlink" href="#TokenType.CLUSTER_BY"></a> + + + + </div> <div id="TokenType.COLLATE" class="classattr"> <div class="attr variable"> <span class="name">COLLATE</span> = @@ -4427,6 +4457,18 @@ </div> + <div id="TokenType.DISTRIBUTE_BY" class="classattr"> + <div class="attr variable"> + <span class="name">DISTRIBUTE_BY</span> = +<span class="default_value"><<a href="#TokenType.DISTRIBUTE_BY">TokenType.DISTRIBUTE_BY</a>: 'DISTRIBUTE_BY'></span> + + + </div> + <a class="headerlink" href="#TokenType.DISTRIBUTE_BY"></a> + + + + </div> <div id="TokenType.DIV" class="classattr"> <div class="attr variable"> <span class="name">DIV</span> = @@ -5627,6 +5669,18 @@ </div> + <div id="TokenType.SORT_BY" class="classattr"> + <div class="attr variable"> + <span class="name">SORT_BY</span> = +<span class="default_value"><<a href="#TokenType.SORT_BY">TokenType.SORT_BY</a>: 'SORT_BY'></span> + + + </div> + <a class="headerlink" href="#TokenType.SORT_BY"></a> + + + + </div> <div id="TokenType.STRUCT" class="classattr"> <div class="attr variable"> <span class="name">STRUCT</span> = @@ -5901,61 +5955,61 @@ </div> <a class="headerlink" href="#Token"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Token-309"><a href="#Token-309"><span class="linenos">309</span></a><span class="k">class</span> <span class="nc">Token</span><span class="p">:</span> -</span><span id="Token-310"><a href="#Token-310"><span class="linenos">310</span></a> <span class="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"token_type"</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">,</span> <span class="s2">"line"</span><span class="p">,</span> <span class="s2">"col"</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">,</span> <span class="s2">"end"</span><span class="p">,</span> <span class="s2">"comments"</span><span class="p">)</span> -</span><span id="Token-311"><a href="#Token-311"><span class="linenos">311</span></a> -</span><span id="Token-312"><a href="#Token-312"><span class="linenos">312</span></a> <span class="nd">@classmethod</span> -</span><span id="Token-313"><a href="#Token-313"><span class="linenos">313</span></a> <span class="k">def</span> <span class="nf">number</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">number</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> -</span><span id="Token-314"><a href="#Token-314"><span class="linenos">314</span></a><span class="w"> </span><span class="sd">"""Returns a NUMBER token with `number` as its text."""</span> -</span><span id="Token-315"><a href="#Token-315"><span class="linenos">315</span></a> <span class="k">return</span> <span class="bp">cls</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="nb">str</span><span class="p">(</span><span class="n">number</span><span class="p">))</span> -</span><span id="Token-316"><a href="#Token-316"><span class="linenos">316</span></a> -</span><span id="Token-317"><a href="#Token-317"><span class="linenos">317</span></a> <span class="nd">@classmethod</span> -</span><span id="Token-318"><a href="#Token-318"><span class="linenos">318</span></a> <span class="k">def</span> <span class="nf">string</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">string</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> -</span><span id="Token-319"><a href="#Token-319"><span class="linenos">319</span></a><span class="w"> </span><span class="sd">"""Returns a STRING token with `string` as its text."""</span> -</span><span id="Token-320"><a href="#Token-320"><span class="linenos">320</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">,</span> <span class="n">string</span><span class="p">)</span> -</span><span id="Token-321"><a href="#Token-321"><span class="linenos">321</span></a> -</span><span id="Token-322"><a href="#Token-322"><span class="linenos">322</span></a> <span class="nd">@classmethod</span> -</span><span id="Token-323"><a href="#Token-323"><span class="linenos">323</span></a> <span class="k">def</span> <span class="nf">identifier</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">identifier</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> -</span><span id="Token-324"><a href="#Token-324"><span class="linenos">324</span></a><span class="w"> </span><span class="sd">"""Returns an IDENTIFIER token with `identifier` as its text."""</span> -</span><span id="Token-325"><a href="#Token-325"><span class="linenos">325</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">,</span> <span class="n">identifier</span><span class="p">)</span> -</span><span id="Token-326"><a href="#Token-326"><span class="linenos">326</span></a> -</span><span id="Token-327"><a href="#Token-327"><span class="linenos">327</span></a> <span class="nd">@classmethod</span> -</span><span id="Token-328"><a href="#Token-328"><span class="linenos">328</span></a> <span class="k">def</span> <span class="nf">var</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">var</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> -</span><span id="Token-329"><a href="#Token-329"><span class="linenos">329</span></a><span class="w"> </span><span class="sd">"""Returns an VAR token with `var` as its text."""</span> -</span><span id="Token-330"><a href="#Token-330"><span class="linenos">330</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">,</span> <span class="n">var</span><span class="p">)</span> -</span><span id="Token-331"><a href="#Token-331"><span class="linenos">331</span></a> -</span><span id="Token-332"><a href="#Token-332"><span class="linenos">332</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> -</span><span id="Token-333"><a href="#Token-333"><span class="linenos">333</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Token-334"><a href="#Token-334"><span class="linenos">334</span></a> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">,</span> -</span><span id="Token-335"><a href="#Token-335"><span class="linenos">335</span></a> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="Token-336"><a href="#Token-336"><span class="linenos">336</span></a> <span class="n">line</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> -</span><span id="Token-337"><a href="#Token-337"><span class="linenos">337</span></a> <span class="n">col</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> -</span><span id="Token-338"><a href="#Token-338"><span class="linenos">338</span></a> <span class="n">start</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> -</span><span id="Token-339"><a href="#Token-339"><span class="linenos">339</span></a> <span class="n">end</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> -</span><span id="Token-340"><a href="#Token-340"><span class="linenos">340</span></a> <span class="n">comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[],</span> -</span><span id="Token-341"><a href="#Token-341"><span class="linenos">341</span></a> <span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Token-342"><a href="#Token-342"><span class="linenos">342</span></a><span class="w"> </span><span class="sd">"""Token initializer.</span> -</span><span id="Token-343"><a href="#Token-343"><span class="linenos">343</span></a> -</span><span id="Token-344"><a href="#Token-344"><span class="linenos">344</span></a><span class="sd"> Args:</span> -</span><span id="Token-345"><a href="#Token-345"><span class="linenos">345</span></a><span class="sd"> token_type: The TokenType Enum.</span> -</span><span id="Token-346"><a href="#Token-346"><span class="linenos">346</span></a><span class="sd"> text: The text of the token.</span> -</span><span id="Token-347"><a href="#Token-347"><span class="linenos">347</span></a><span class="sd"> line: The line that the token ends on.</span> -</span><span id="Token-348"><a href="#Token-348"><span class="linenos">348</span></a><span class="sd"> col: The column that the token ends on.</span> -</span><span id="Token-349"><a href="#Token-349"><span class="linenos">349</span></a><span class="sd"> start: The start index of the token.</span> -</span><span id="Token-350"><a href="#Token-350"><span class="linenos">350</span></a><span class="sd"> end: The ending index of the token.</span> -</span><span id="Token-351"><a href="#Token-351"><span class="linenos">351</span></a><span class="sd"> comments: The comments to attach to the token.</span> -</span><span id="Token-352"><a href="#Token-352"><span class="linenos">352</span></a><span class="sd"> """</span> -</span><span id="Token-353"><a href="#Token-353"><span class="linenos">353</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">token_type</span> <span class="o">=</span> <span class="n">token_type</span> -</span><span id="Token-354"><a href="#Token-354"><span class="linenos">354</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">text</span> <span class="o">=</span> <span class="n">text</span> -</span><span id="Token-355"><a href="#Token-355"><span class="linenos">355</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">line</span> <span class="o">=</span> <span class="n">line</span> -</span><span id="Token-356"><a href="#Token-356"><span class="linenos">356</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">col</span> <span class="o">=</span> <span class="n">col</span> -</span><span id="Token-357"><a href="#Token-357"><span class="linenos">357</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">start</span> <span class="o">=</span> <span class="n">start</span> -</span><span id="Token-358"><a href="#Token-358"><span class="linenos">358</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">end</span> <span class="o">=</span> <span class="n">end</span> -</span><span id="Token-359"><a href="#Token-359"><span class="linenos">359</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> -</span><span id="Token-360"><a href="#Token-360"><span class="linenos">360</span></a> -</span><span id="Token-361"><a href="#Token-361"><span class="linenos">361</span></a> <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Token-362"><a href="#Token-362"><span class="linenos">362</span></a> <span class="n">attributes</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">k</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">k</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__slots__</span><span class="p">)</span> -</span><span id="Token-363"><a href="#Token-363"><span class="linenos">363</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"<Token </span><span class="si">{</span><span class="n">attributes</span><span class="si">}</span><span class="s2">>"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Token-312"><a href="#Token-312"><span class="linenos">312</span></a><span class="k">class</span> <span class="nc">Token</span><span class="p">:</span> +</span><span id="Token-313"><a href="#Token-313"><span class="linenos">313</span></a> <span class="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"token_type"</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">,</span> <span class="s2">"line"</span><span class="p">,</span> <span class="s2">"col"</span><span class="p">,</span> <span class="s2">"start"</span><span class="p">,</span> <span class="s2">"end"</span><span class="p">,</span> <span class="s2">"comments"</span><span class="p">)</span> +</span><span id="Token-314"><a href="#Token-314"><span class="linenos">314</span></a> +</span><span id="Token-315"><a href="#Token-315"><span class="linenos">315</span></a> <span class="nd">@classmethod</span> +</span><span id="Token-316"><a href="#Token-316"><span class="linenos">316</span></a> <span class="k">def</span> <span class="nf">number</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">number</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> +</span><span id="Token-317"><a href="#Token-317"><span class="linenos">317</span></a><span class="w"> </span><span class="sd">"""Returns a NUMBER token with `number` as its text."""</span> +</span><span id="Token-318"><a href="#Token-318"><span class="linenos">318</span></a> <span class="k">return</span> <span class="bp">cls</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="nb">str</span><span class="p">(</span><span class="n">number</span><span class="p">))</span> +</span><span id="Token-319"><a href="#Token-319"><span class="linenos">319</span></a> +</span><span id="Token-320"><a href="#Token-320"><span class="linenos">320</span></a> <span class="nd">@classmethod</span> +</span><span id="Token-321"><a href="#Token-321"><span class="linenos">321</span></a> <span class="k">def</span> <span class="nf">string</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">string</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> +</span><span id="Token-322"><a href="#Token-322"><span class="linenos">322</span></a><span class="w"> </span><span class="sd">"""Returns a STRING token with `string` as its text."""</span> +</span><span id="Token-323"><a href="#Token-323"><span class="linenos">323</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">,</span> <span class="n">string</span><span class="p">)</span> +</span><span id="Token-324"><a href="#Token-324"><span class="linenos">324</span></a> +</span><span id="Token-325"><a href="#Token-325"><span class="linenos">325</span></a> <span class="nd">@classmethod</span> +</span><span id="Token-326"><a href="#Token-326"><span class="linenos">326</span></a> <span class="k">def</span> <span class="nf">identifier</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">identifier</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> +</span><span id="Token-327"><a href="#Token-327"><span class="linenos">327</span></a><span class="w"> </span><span class="sd">"""Returns an IDENTIFIER token with `identifier` as its text."""</span> +</span><span id="Token-328"><a href="#Token-328"><span class="linenos">328</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">,</span> <span class="n">identifier</span><span class="p">)</span> +</span><span id="Token-329"><a href="#Token-329"><span class="linenos">329</span></a> +</span><span id="Token-330"><a href="#Token-330"><span class="linenos">330</span></a> <span class="nd">@classmethod</span> +</span><span id="Token-331"><a href="#Token-331"><span class="linenos">331</span></a> <span class="k">def</span> <span class="nf">var</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">var</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> +</span><span id="Token-332"><a href="#Token-332"><span class="linenos">332</span></a><span class="w"> </span><span class="sd">"""Returns an VAR token with `var` as its text."""</span> +</span><span id="Token-333"><a href="#Token-333"><span class="linenos">333</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">,</span> <span class="n">var</span><span class="p">)</span> +</span><span id="Token-334"><a href="#Token-334"><span class="linenos">334</span></a> +</span><span id="Token-335"><a href="#Token-335"><span class="linenos">335</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> +</span><span id="Token-336"><a href="#Token-336"><span class="linenos">336</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Token-337"><a href="#Token-337"><span class="linenos">337</span></a> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">,</span> +</span><span id="Token-338"><a href="#Token-338"><span class="linenos">338</span></a> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="Token-339"><a href="#Token-339"><span class="linenos">339</span></a> <span class="n">line</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> +</span><span id="Token-340"><a href="#Token-340"><span class="linenos">340</span></a> <span class="n">col</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> +</span><span id="Token-341"><a href="#Token-341"><span class="linenos">341</span></a> <span class="n">start</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> +</span><span id="Token-342"><a href="#Token-342"><span class="linenos">342</span></a> <span class="n">end</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> +</span><span id="Token-343"><a href="#Token-343"><span class="linenos">343</span></a> <span class="n">comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[],</span> +</span><span id="Token-344"><a href="#Token-344"><span class="linenos">344</span></a> <span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Token-345"><a href="#Token-345"><span class="linenos">345</span></a><span class="w"> </span><span class="sd">"""Token initializer.</span> +</span><span id="Token-346"><a href="#Token-346"><span class="linenos">346</span></a> +</span><span id="Token-347"><a href="#Token-347"><span class="linenos">347</span></a><span class="sd"> Args:</span> +</span><span id="Token-348"><a href="#Token-348"><span class="linenos">348</span></a><span class="sd"> token_type: The TokenType Enum.</span> +</span><span id="Token-349"><a href="#Token-349"><span class="linenos">349</span></a><span class="sd"> text: The text of the token.</span> +</span><span id="Token-350"><a href="#Token-350"><span class="linenos">350</span></a><span class="sd"> line: The line that the token ends on.</span> +</span><span id="Token-351"><a href="#Token-351"><span class="linenos">351</span></a><span class="sd"> col: The column that the token ends on.</span> +</span><span id="Token-352"><a href="#Token-352"><span class="linenos">352</span></a><span class="sd"> start: The start index of the token.</span> +</span><span id="Token-353"><a href="#Token-353"><span class="linenos">353</span></a><span class="sd"> end: The ending index of the token.</span> +</span><span id="Token-354"><a href="#Token-354"><span class="linenos">354</span></a><span class="sd"> comments: The comments to attach to the token.</span> +</span><span id="Token-355"><a href="#Token-355"><span class="linenos">355</span></a><span class="sd"> """</span> +</span><span id="Token-356"><a href="#Token-356"><span class="linenos">356</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">token_type</span> <span class="o">=</span> <span class="n">token_type</span> +</span><span id="Token-357"><a href="#Token-357"><span class="linenos">357</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">text</span> <span class="o">=</span> <span class="n">text</span> +</span><span id="Token-358"><a href="#Token-358"><span class="linenos">358</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">line</span> <span class="o">=</span> <span class="n">line</span> +</span><span id="Token-359"><a href="#Token-359"><span class="linenos">359</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">col</span> <span class="o">=</span> <span class="n">col</span> +</span><span id="Token-360"><a href="#Token-360"><span class="linenos">360</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">start</span> <span class="o">=</span> <span class="n">start</span> +</span><span id="Token-361"><a href="#Token-361"><span class="linenos">361</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">end</span> <span class="o">=</span> <span class="n">end</span> +</span><span id="Token-362"><a href="#Token-362"><span class="linenos">362</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> +</span><span id="Token-363"><a href="#Token-363"><span class="linenos">363</span></a> +</span><span id="Token-364"><a href="#Token-364"><span class="linenos">364</span></a> <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Token-365"><a href="#Token-365"><span class="linenos">365</span></a> <span class="n">attributes</span> <span class="o">=</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">k</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">k</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__slots__</span><span class="p">)</span> +</span><span id="Token-366"><a href="#Token-366"><span class="linenos">366</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"<Token </span><span class="si">{</span><span class="n">attributes</span><span class="si">}</span><span class="s2">>"</span> </span></pre></div> @@ -5971,34 +6025,34 @@ </div> <a class="headerlink" href="#Token.__init__"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Token.__init__-332"><a href="#Token.__init__-332"><span class="linenos">332</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> -</span><span id="Token.__init__-333"><a href="#Token.__init__-333"><span class="linenos">333</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Token.__init__-334"><a href="#Token.__init__-334"><span class="linenos">334</span></a> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">,</span> -</span><span id="Token.__init__-335"><a href="#Token.__init__-335"><span class="linenos">335</span></a> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="Token.__init__-336"><a href="#Token.__init__-336"><span class="linenos">336</span></a> <span class="n">line</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> -</span><span id="Token.__init__-337"><a href="#Token.__init__-337"><span class="linenos">337</span></a> <span class="n">col</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> -</span><span id="Token.__init__-338"><a href="#Token.__init__-338"><span class="linenos">338</span></a> <span class="n">start</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> -</span><span id="Token.__init__-339"><a href="#Token.__init__-339"><span class="linenos">339</span></a> <span class="n">end</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> -</span><span id="Token.__init__-340"><a href="#Token.__init__-340"><span class="linenos">340</span></a> <span class="n">comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[],</span> -</span><span id="Token.__init__-341"><a href="#Token.__init__-341"><span class="linenos">341</span></a> <span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Token.__init__-342"><a href="#Token.__init__-342"><span class="linenos">342</span></a><span class="w"> </span><span class="sd">"""Token initializer.</span> -</span><span id="Token.__init__-343"><a href="#Token.__init__-343"><span class="linenos">343</span></a> -</span><span id="Token.__init__-344"><a href="#Token.__init__-344"><span class="linenos">344</span></a><span class="sd"> Args:</span> -</span><span id="Token.__init__-345"><a href="#Token.__init__-345"><span class="linenos">345</span></a><span class="sd"> token_type: The TokenType Enum.</span> -</span><span id="Token.__init__-346"><a href="#Token.__init__-346"><span class="linenos">346</span></a><span class="sd"> text: The text of the token.</span> -</span><span id="Token.__init__-347"><a href="#Token.__init__-347"><span class="linenos">347</span></a><span class="sd"> line: The line that the token ends on.</span> -</span><span id="Token.__init__-348"><a href="#Token.__init__-348"><span class="linenos">348</span></a><span class="sd"> col: The column that the token ends on.</span> -</span><span id="Token.__init__-349"><a href="#Token.__init__-349"><span class="linenos">349</span></a><span class="sd"> start: The start index of the token.</span> -</span><span id="Token.__init__-350"><a href="#Token.__init__-350"><span class="linenos">350</span></a><span class="sd"> end: The ending index of the token.</span> -</span><span id="Token.__init__-351"><a href="#Token.__init__-351"><span class="linenos">351</span></a><span class="sd"> comments: The comments to attach to the token.</span> -</span><span id="Token.__init__-352"><a href="#Token.__init__-352"><span class="linenos">352</span></a><span class="sd"> """</span> -</span><span id="Token.__init__-353"><a href="#Token.__init__-353"><span class="linenos">353</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">token_type</span> <span class="o">=</span> <span class="n">token_type</span> -</span><span id="Token.__init__-354"><a href="#Token.__init__-354"><span class="linenos">354</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">text</span> <span class="o">=</span> <span class="n">text</span> -</span><span id="Token.__init__-355"><a href="#Token.__init__-355"><span class="linenos">355</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">line</span> <span class="o">=</span> <span class="n">line</span> -</span><span id="Token.__init__-356"><a href="#Token.__init__-356"><span class="linenos">356</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">col</span> <span class="o">=</span> <span class="n">col</span> -</span><span id="Token.__init__-357"><a href="#Token.__init__-357"><span class="linenos">357</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">start</span> <span class="o">=</span> <span class="n">start</span> -</span><span id="Token.__init__-358"><a href="#Token.__init__-358"><span class="linenos">358</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">end</span> <span class="o">=</span> <span class="n">end</span> -</span><span id="Token.__init__-359"><a href="#Token.__init__-359"><span class="linenos">359</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Token.__init__-335"><a href="#Token.__init__-335"><span class="linenos">335</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> +</span><span id="Token.__init__-336"><a href="#Token.__init__-336"><span class="linenos">336</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Token.__init__-337"><a href="#Token.__init__-337"><span class="linenos">337</span></a> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">,</span> +</span><span id="Token.__init__-338"><a href="#Token.__init__-338"><span class="linenos">338</span></a> <span class="n">text</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="Token.__init__-339"><a href="#Token.__init__-339"><span class="linenos">339</span></a> <span class="n">line</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> +</span><span id="Token.__init__-340"><a href="#Token.__init__-340"><span class="linenos">340</span></a> <span class="n">col</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> +</span><span id="Token.__init__-341"><a href="#Token.__init__-341"><span class="linenos">341</span></a> <span class="n">start</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> +</span><span id="Token.__init__-342"><a href="#Token.__init__-342"><span class="linenos">342</span></a> <span class="n">end</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> +</span><span id="Token.__init__-343"><a href="#Token.__init__-343"><span class="linenos">343</span></a> <span class="n">comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[],</span> +</span><span id="Token.__init__-344"><a href="#Token.__init__-344"><span class="linenos">344</span></a> <span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Token.__init__-345"><a href="#Token.__init__-345"><span class="linenos">345</span></a><span class="w"> </span><span class="sd">"""Token initializer.</span> +</span><span id="Token.__init__-346"><a href="#Token.__init__-346"><span class="linenos">346</span></a> +</span><span id="Token.__init__-347"><a href="#Token.__init__-347"><span class="linenos">347</span></a><span class="sd"> Args:</span> +</span><span id="Token.__init__-348"><a href="#Token.__init__-348"><span class="linenos">348</span></a><span class="sd"> token_type: The TokenType Enum.</span> +</span><span id="Token.__init__-349"><a href="#Token.__init__-349"><span class="linenos">349</span></a><span class="sd"> text: The text of the token.</span> +</span><span id="Token.__init__-350"><a href="#Token.__init__-350"><span class="linenos">350</span></a><span class="sd"> line: The line that the token ends on.</span> +</span><span id="Token.__init__-351"><a href="#Token.__init__-351"><span class="linenos">351</span></a><span class="sd"> col: The column that the token ends on.</span> +</span><span id="Token.__init__-352"><a href="#Token.__init__-352"><span class="linenos">352</span></a><span class="sd"> start: The start index of the token.</span> +</span><span id="Token.__init__-353"><a href="#Token.__init__-353"><span class="linenos">353</span></a><span class="sd"> end: The ending index of the token.</span> +</span><span id="Token.__init__-354"><a href="#Token.__init__-354"><span class="linenos">354</span></a><span class="sd"> comments: The comments to attach to the token.</span> +</span><span id="Token.__init__-355"><a href="#Token.__init__-355"><span class="linenos">355</span></a><span class="sd"> """</span> +</span><span id="Token.__init__-356"><a href="#Token.__init__-356"><span class="linenos">356</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">token_type</span> <span class="o">=</span> <span class="n">token_type</span> +</span><span id="Token.__init__-357"><a href="#Token.__init__-357"><span class="linenos">357</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">text</span> <span class="o">=</span> <span class="n">text</span> +</span><span id="Token.__init__-358"><a href="#Token.__init__-358"><span class="linenos">358</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">line</span> <span class="o">=</span> <span class="n">line</span> +</span><span id="Token.__init__-359"><a href="#Token.__init__-359"><span class="linenos">359</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">col</span> <span class="o">=</span> <span class="n">col</span> +</span><span id="Token.__init__-360"><a href="#Token.__init__-360"><span class="linenos">360</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">start</span> <span class="o">=</span> <span class="n">start</span> +</span><span id="Token.__init__-361"><a href="#Token.__init__-361"><span class="linenos">361</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">end</span> <span class="o">=</span> <span class="n">end</span> +</span><span id="Token.__init__-362"><a href="#Token.__init__-362"><span class="linenos">362</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">comments</span> <span class="o">=</span> <span class="n">comments</span> </span></pre></div> @@ -6031,10 +6085,10 @@ </div> <a class="headerlink" href="#Token.number"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Token.number-312"><a href="#Token.number-312"><span class="linenos">312</span></a> <span class="nd">@classmethod</span> -</span><span id="Token.number-313"><a href="#Token.number-313"><span class="linenos">313</span></a> <span class="k">def</span> <span class="nf">number</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">number</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> -</span><span id="Token.number-314"><a href="#Token.number-314"><span class="linenos">314</span></a><span class="w"> </span><span class="sd">"""Returns a NUMBER token with `number` as its text."""</span> -</span><span id="Token.number-315"><a href="#Token.number-315"><span class="linenos">315</span></a> <span class="k">return</span> <span class="bp">cls</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="nb">str</span><span class="p">(</span><span class="n">number</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Token.number-315"><a href="#Token.number-315"><span class="linenos">315</span></a> <span class="nd">@classmethod</span> +</span><span id="Token.number-316"><a href="#Token.number-316"><span class="linenos">316</span></a> <span class="k">def</span> <span class="nf">number</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">number</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> +</span><span id="Token.number-317"><a href="#Token.number-317"><span class="linenos">317</span></a><span class="w"> </span><span class="sd">"""Returns a NUMBER token with `number` as its text."""</span> +</span><span id="Token.number-318"><a href="#Token.number-318"><span class="linenos">318</span></a> <span class="k">return</span> <span class="bp">cls</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="nb">str</span><span class="p">(</span><span class="n">number</span><span class="p">))</span> </span></pre></div> @@ -6055,10 +6109,10 @@ </div> <a class="headerlink" href="#Token.string"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Token.string-317"><a href="#Token.string-317"><span class="linenos">317</span></a> <span class="nd">@classmethod</span> -</span><span id="Token.string-318"><a href="#Token.string-318"><span class="linenos">318</span></a> <span class="k">def</span> <span class="nf">string</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">string</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> -</span><span id="Token.string-319"><a href="#Token.string-319"><span class="linenos">319</span></a><span class="w"> </span><span class="sd">"""Returns a STRING token with `string` as its text."""</span> -</span><span id="Token.string-320"><a href="#Token.string-320"><span class="linenos">320</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">,</span> <span class="n">string</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Token.string-320"><a href="#Token.string-320"><span class="linenos">320</span></a> <span class="nd">@classmethod</span> +</span><span id="Token.string-321"><a href="#Token.string-321"><span class="linenos">321</span></a> <span class="k">def</span> <span class="nf">string</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">string</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> +</span><span id="Token.string-322"><a href="#Token.string-322"><span class="linenos">322</span></a><span class="w"> </span><span class="sd">"""Returns a STRING token with `string` as its text."""</span> +</span><span id="Token.string-323"><a href="#Token.string-323"><span class="linenos">323</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">,</span> <span class="n">string</span><span class="p">)</span> </span></pre></div> @@ -6079,10 +6133,10 @@ </div> <a class="headerlink" href="#Token.identifier"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Token.identifier-322"><a href="#Token.identifier-322"><span class="linenos">322</span></a> <span class="nd">@classmethod</span> -</span><span id="Token.identifier-323"><a href="#Token.identifier-323"><span class="linenos">323</span></a> <span class="k">def</span> <span class="nf">identifier</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">identifier</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> -</span><span id="Token.identifier-324"><a href="#Token.identifier-324"><span class="linenos">324</span></a><span class="w"> </span><span class="sd">"""Returns an IDENTIFIER token with `identifier` as its text."""</span> -</span><span id="Token.identifier-325"><a href="#Token.identifier-325"><span class="linenos">325</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">,</span> <span class="n">identifier</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Token.identifier-325"><a href="#Token.identifier-325"><span class="linenos">325</span></a> <span class="nd">@classmethod</span> +</span><span id="Token.identifier-326"><a href="#Token.identifier-326"><span class="linenos">326</span></a> <span class="k">def</span> <span class="nf">identifier</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">identifier</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> +</span><span id="Token.identifier-327"><a href="#Token.identifier-327"><span class="linenos">327</span></a><span class="w"> </span><span class="sd">"""Returns an IDENTIFIER token with `identifier` as its text."""</span> +</span><span id="Token.identifier-328"><a href="#Token.identifier-328"><span class="linenos">328</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">,</span> <span class="n">identifier</span><span class="p">)</span> </span></pre></div> @@ -6103,10 +6157,10 @@ </div> <a class="headerlink" href="#Token.var"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Token.var-327"><a href="#Token.var-327"><span class="linenos">327</span></a> <span class="nd">@classmethod</span> -</span><span id="Token.var-328"><a href="#Token.var-328"><span class="linenos">328</span></a> <span class="k">def</span> <span class="nf">var</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">var</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> -</span><span id="Token.var-329"><a href="#Token.var-329"><span class="linenos">329</span></a><span class="w"> </span><span class="sd">"""Returns an VAR token with `var` as its text."""</span> -</span><span id="Token.var-330"><a href="#Token.var-330"><span class="linenos">330</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">,</span> <span class="n">var</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Token.var-330"><a href="#Token.var-330"><span class="linenos">330</span></a> <span class="nd">@classmethod</span> +</span><span id="Token.var-331"><a href="#Token.var-331"><span class="linenos">331</span></a> <span class="k">def</span> <span class="nf">var</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">var</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">Token</span><span class="p">:</span> +</span><span id="Token.var-332"><a href="#Token.var-332"><span class="linenos">332</span></a><span class="w"> </span><span class="sd">"""Returns an VAR token with `var` as its text."""</span> +</span><span id="Token.var-333"><a href="#Token.var-333"><span class="linenos">333</span></a> <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">,</span> <span class="n">var</span><span class="p">)</span> </span></pre></div> @@ -6127,735 +6181,738 @@ </div> <a class="headerlink" href="#Tokenizer"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Tokenizer-419"><a href="#Tokenizer-419"><span class="linenos"> 419</span></a><span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">metaclass</span><span class="o">=</span><span class="n">_Tokenizer</span><span class="p">):</span> -</span><span id="Tokenizer-420"><a href="#Tokenizer-420"><span class="linenos"> 420</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Tokenizer-421"><a href="#Tokenizer-421"><span class="linenos"> 421</span></a> <span class="s2">"("</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">,</span> -</span><span id="Tokenizer-422"><a href="#Tokenizer-422"><span class="linenos"> 422</span></a> <span class="s2">")"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_PAREN</span><span class="p">,</span> -</span><span id="Tokenizer-423"><a href="#Tokenizer-423"><span class="linenos"> 423</span></a> <span class="s2">"["</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">,</span> -</span><span id="Tokenizer-424"><a href="#Tokenizer-424"><span class="linenos"> 424</span></a> <span class="s2">"]"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACKET</span><span class="p">,</span> -</span><span id="Tokenizer-425"><a href="#Tokenizer-425"><span class="linenos"> 425</span></a> <span class="s2">"{"</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><span id="Tokenizer-426"><a href="#Tokenizer-426"><span class="linenos"> 426</span></a> <span class="s2">"}"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACE</span><span class="p">,</span> -</span><span id="Tokenizer-427"><a href="#Tokenizer-427"><span class="linenos"> 427</span></a> <span class="s2">"&"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">AMP</span><span class="p">,</span> -</span><span id="Tokenizer-428"><a href="#Tokenizer-428"><span class="linenos"> 428</span></a> <span class="s2">"^"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CARET</span><span class="p">,</span> -</span><span id="Tokenizer-429"><a href="#Tokenizer-429"><span class="linenos"> 429</span></a> <span class="s2">":"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLON</span><span class="p">,</span> -</span><span id="Tokenizer-430"><a href="#Tokenizer-430"><span class="linenos"> 430</span></a> <span class="s2">","</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMA</span><span class="p">,</span> -</span><span id="Tokenizer-431"><a href="#Tokenizer-431"><span class="linenos"> 431</span></a> <span class="s2">"."</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOT</span><span class="p">,</span> -</span><span id="Tokenizer-432"><a href="#Tokenizer-432"><span class="linenos"> 432</span></a> <span class="s2">"-"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DASH</span><span class="p">,</span> -</span><span id="Tokenizer-433"><a href="#Tokenizer-433"><span class="linenos"> 433</span></a> <span class="s2">"="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> -</span><span id="Tokenizer-434"><a href="#Tokenizer-434"><span class="linenos"> 434</span></a> <span class="s2">">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GT</span><span class="p">,</span> -</span><span id="Tokenizer-435"><a href="#Tokenizer-435"><span class="linenos"> 435</span></a> <span class="s2">"<"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LT</span><span class="p">,</span> -</span><span id="Tokenizer-436"><a href="#Tokenizer-436"><span class="linenos"> 436</span></a> <span class="s2">"%"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MOD</span><span class="p">,</span> -</span><span id="Tokenizer-437"><a href="#Tokenizer-437"><span class="linenos"> 437</span></a> <span class="s2">"!"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NOT</span><span class="p">,</span> -</span><span id="Tokenizer-438"><a href="#Tokenizer-438"><span class="linenos"> 438</span></a> <span class="s2">"|"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PIPE</span><span class="p">,</span> -</span><span id="Tokenizer-439"><a href="#Tokenizer-439"><span class="linenos"> 439</span></a> <span class="s2">"+"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PLUS</span><span class="p">,</span> -</span><span id="Tokenizer-440"><a href="#Tokenizer-440"><span class="linenos"> 440</span></a> <span class="s2">";"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SEMICOLON</span><span class="p">,</span> -</span><span id="Tokenizer-441"><a href="#Tokenizer-441"><span class="linenos"> 441</span></a> <span class="s2">"/"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SLASH</span><span class="p">,</span> -</span><span id="Tokenizer-442"><a href="#Tokenizer-442"><span class="linenos"> 442</span></a> <span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BACKSLASH</span><span class="p">,</span> -</span><span id="Tokenizer-443"><a href="#Tokenizer-443"><span class="linenos"> 443</span></a> <span class="s2">"*"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STAR</span><span class="p">,</span> -</span><span id="Tokenizer-444"><a href="#Tokenizer-444"><span class="linenos"> 444</span></a> <span class="s2">"~"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TILDA</span><span class="p">,</span> -</span><span id="Tokenizer-445"><a href="#Tokenizer-445"><span class="linenos"> 445</span></a> <span class="s2">"?"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PLACEHOLDER</span><span class="p">,</span> -</span><span id="Tokenizer-446"><a href="#Tokenizer-446"><span class="linenos"> 446</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="Tokenizer-447"><a href="#Tokenizer-447"><span class="linenos"> 447</span></a> <span class="c1"># used for breaking a var like x'y' but nothing else</span> -</span><span id="Tokenizer-448"><a href="#Tokenizer-448"><span class="linenos"> 448</span></a> <span class="c1"># the token type doesn't matter</span> -</span><span id="Tokenizer-449"><a href="#Tokenizer-449"><span class="linenos"> 449</span></a> <span class="s2">"'"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">QUOTE</span><span class="p">,</span> -</span><span id="Tokenizer-450"><a href="#Tokenizer-450"><span class="linenos"> 450</span></a> <span class="s2">"`"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">,</span> -</span><span id="Tokenizer-451"><a href="#Tokenizer-451"><span class="linenos"> 451</span></a> <span class="s1">'"'</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">,</span> -</span><span id="Tokenizer-452"><a href="#Tokenizer-452"><span class="linenos"> 452</span></a> <span class="s2">"#"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HASH</span><span class="p">,</span> -</span><span id="Tokenizer-453"><a href="#Tokenizer-453"><span class="linenos"> 453</span></a> <span class="p">}</span> -</span><span id="Tokenizer-454"><a href="#Tokenizer-454"><span class="linenos"> 454</span></a> -</span><span id="Tokenizer-455"><a href="#Tokenizer-455"><span class="linenos"> 455</span></a> <span class="n">BIT_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Tokenizer-456"><a href="#Tokenizer-456"><span class="linenos"> 456</span></a> <span class="n">BYTE_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Tokenizer-457"><a href="#Tokenizer-457"><span class="linenos"> 457</span></a> <span class="n">HEX_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Tokenizer-458"><a href="#Tokenizer-458"><span class="linenos"> 458</span></a> <span class="n">RAW_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Tokenizer-459"><a href="#Tokenizer-459"><span class="linenos"> 459</span></a> <span class="n">IDENTIFIERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'"'</span><span class="p">]</span> -</span><span id="Tokenizer-460"><a href="#Tokenizer-460"><span class="linenos"> 460</span></a> <span class="n">IDENTIFIER_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'"'</span><span class="p">]</span> -</span><span id="Tokenizer-461"><a href="#Tokenizer-461"><span class="linenos"> 461</span></a> <span class="n">QUOTES</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">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">|</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">]</span> -</span><span id="Tokenizer-462"><a href="#Tokenizer-462"><span class="linenos"> 462</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">]</span> -</span><span id="Tokenizer-463"><a href="#Tokenizer-463"><span class="linenos"> 463</span></a> <span class="n">VAR_SINGLE_TOKENS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> -</span><span id="Tokenizer-464"><a href="#Tokenizer-464"><span class="linenos"> 464</span></a> -</span><span id="Tokenizer-465"><a href="#Tokenizer-465"><span class="linenos"> 465</span></a> <span class="c1"># Autofilled</span> -</span><span id="Tokenizer-466"><a href="#Tokenizer-466"><span class="linenos"> 466</span></a> <span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Tokenizer-422"><a href="#Tokenizer-422"><span class="linenos"> 422</span></a><span class="k">class</span> <span class="nc">Tokenizer</span><span class="p">(</span><span class="n">metaclass</span><span class="o">=</span><span class="n">_Tokenizer</span><span class="p">):</span> +</span><span id="Tokenizer-423"><a href="#Tokenizer-423"><span class="linenos"> 423</span></a> <span class="n">SINGLE_TOKENS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Tokenizer-424"><a href="#Tokenizer-424"><span class="linenos"> 424</span></a> <span class="s2">"("</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_PAREN</span><span class="p">,</span> +</span><span id="Tokenizer-425"><a href="#Tokenizer-425"><span class="linenos"> 425</span></a> <span class="s2">")"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_PAREN</span><span class="p">,</span> +</span><span id="Tokenizer-426"><a href="#Tokenizer-426"><span class="linenos"> 426</span></a> <span class="s2">"["</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">L_BRACKET</span><span class="p">,</span> +</span><span id="Tokenizer-427"><a href="#Tokenizer-427"><span class="linenos"> 427</span></a> <span class="s2">"]"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACKET</span><span class="p">,</span> +</span><span id="Tokenizer-428"><a href="#Tokenizer-428"><span class="linenos"> 428</span></a> <span class="s2">"{"</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><span id="Tokenizer-429"><a href="#Tokenizer-429"><span class="linenos"> 429</span></a> <span class="s2">"}"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">R_BRACE</span><span class="p">,</span> +</span><span id="Tokenizer-430"><a href="#Tokenizer-430"><span class="linenos"> 430</span></a> <span class="s2">"&"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">AMP</span><span class="p">,</span> +</span><span id="Tokenizer-431"><a href="#Tokenizer-431"><span class="linenos"> 431</span></a> <span class="s2">"^"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CARET</span><span class="p">,</span> +</span><span id="Tokenizer-432"><a href="#Tokenizer-432"><span class="linenos"> 432</span></a> <span class="s2">":"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLON</span><span class="p">,</span> +</span><span id="Tokenizer-433"><a href="#Tokenizer-433"><span class="linenos"> 433</span></a> <span class="s2">","</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMA</span><span class="p">,</span> +</span><span id="Tokenizer-434"><a href="#Tokenizer-434"><span class="linenos"> 434</span></a> <span class="s2">"."</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOT</span><span class="p">,</span> +</span><span id="Tokenizer-435"><a href="#Tokenizer-435"><span class="linenos"> 435</span></a> <span class="s2">"-"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DASH</span><span class="p">,</span> +</span><span id="Tokenizer-436"><a href="#Tokenizer-436"><span class="linenos"> 436</span></a> <span class="s2">"="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> +</span><span id="Tokenizer-437"><a href="#Tokenizer-437"><span class="linenos"> 437</span></a> <span class="s2">">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GT</span><span class="p">,</span> +</span><span id="Tokenizer-438"><a href="#Tokenizer-438"><span class="linenos"> 438</span></a> <span class="s2">"<"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LT</span><span class="p">,</span> +</span><span id="Tokenizer-439"><a href="#Tokenizer-439"><span class="linenos"> 439</span></a> <span class="s2">"%"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MOD</span><span class="p">,</span> +</span><span id="Tokenizer-440"><a href="#Tokenizer-440"><span class="linenos"> 440</span></a> <span class="s2">"!"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NOT</span><span class="p">,</span> +</span><span id="Tokenizer-441"><a href="#Tokenizer-441"><span class="linenos"> 441</span></a> <span class="s2">"|"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PIPE</span><span class="p">,</span> +</span><span id="Tokenizer-442"><a href="#Tokenizer-442"><span class="linenos"> 442</span></a> <span class="s2">"+"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PLUS</span><span class="p">,</span> +</span><span id="Tokenizer-443"><a href="#Tokenizer-443"><span class="linenos"> 443</span></a> <span class="s2">";"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SEMICOLON</span><span class="p">,</span> +</span><span id="Tokenizer-444"><a href="#Tokenizer-444"><span class="linenos"> 444</span></a> <span class="s2">"/"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SLASH</span><span class="p">,</span> +</span><span id="Tokenizer-445"><a href="#Tokenizer-445"><span class="linenos"> 445</span></a> <span class="s2">"</span><span class="se">\\</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BACKSLASH</span><span class="p">,</span> +</span><span id="Tokenizer-446"><a href="#Tokenizer-446"><span class="linenos"> 446</span></a> <span class="s2">"*"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STAR</span><span class="p">,</span> +</span><span id="Tokenizer-447"><a href="#Tokenizer-447"><span class="linenos"> 447</span></a> <span class="s2">"~"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TILDA</span><span class="p">,</span> +</span><span id="Tokenizer-448"><a href="#Tokenizer-448"><span class="linenos"> 448</span></a> <span class="s2">"?"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PLACEHOLDER</span><span class="p">,</span> +</span><span id="Tokenizer-449"><a href="#Tokenizer-449"><span class="linenos"> 449</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="Tokenizer-450"><a href="#Tokenizer-450"><span class="linenos"> 450</span></a> <span class="c1"># used for breaking a var like x'y' but nothing else</span> +</span><span id="Tokenizer-451"><a href="#Tokenizer-451"><span class="linenos"> 451</span></a> <span class="c1"># the token type doesn't matter</span> +</span><span id="Tokenizer-452"><a href="#Tokenizer-452"><span class="linenos"> 452</span></a> <span class="s2">"'"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">QUOTE</span><span class="p">,</span> +</span><span id="Tokenizer-453"><a href="#Tokenizer-453"><span class="linenos"> 453</span></a> <span class="s2">"`"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">,</span> +</span><span id="Tokenizer-454"><a href="#Tokenizer-454"><span class="linenos"> 454</span></a> <span class="s1">'"'</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">,</span> +</span><span id="Tokenizer-455"><a href="#Tokenizer-455"><span class="linenos"> 455</span></a> <span class="s2">"#"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HASH</span><span class="p">,</span> +</span><span id="Tokenizer-456"><a href="#Tokenizer-456"><span class="linenos"> 456</span></a> <span class="p">}</span> +</span><span id="Tokenizer-457"><a href="#Tokenizer-457"><span class="linenos"> 457</span></a> +</span><span id="Tokenizer-458"><a href="#Tokenizer-458"><span class="linenos"> 458</span></a> <span class="n">BIT_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Tokenizer-459"><a href="#Tokenizer-459"><span class="linenos"> 459</span></a> <span class="n">BYTE_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Tokenizer-460"><a href="#Tokenizer-460"><span class="linenos"> 460</span></a> <span class="n">HEX_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Tokenizer-461"><a href="#Tokenizer-461"><span class="linenos"> 461</span></a> <span class="n">RAW_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Tokenizer-462"><a href="#Tokenizer-462"><span class="linenos"> 462</span></a> <span class="n">IDENTIFIERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'"'</span><span class="p">]</span> +</span><span id="Tokenizer-463"><a href="#Tokenizer-463"><span class="linenos"> 463</span></a> <span class="n">IDENTIFIER_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'"'</span><span class="p">]</span> +</span><span id="Tokenizer-464"><a href="#Tokenizer-464"><span class="linenos"> 464</span></a> <span class="n">QUOTES</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">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">|</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">]</span> +</span><span id="Tokenizer-465"><a href="#Tokenizer-465"><span class="linenos"> 465</span></a> <span class="n">STRING_ESCAPES</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"'"</span><span class="p">]</span> +</span><span id="Tokenizer-466"><a href="#Tokenizer-466"><span class="linenos"> 466</span></a> <span class="n">VAR_SINGLE_TOKENS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> </span><span id="Tokenizer-467"><a href="#Tokenizer-467"><span class="linenos"> 467</span></a> -</span><span id="Tokenizer-468"><a href="#Tokenizer-468"><span class="linenos"> 468</span></a> <span class="n">_COMMENTS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Tokenizer-469"><a href="#Tokenizer-469"><span class="linenos"> 469</span></a> <span class="n">_FORMAT_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Tokenizer-470"><a href="#Tokenizer-470"><span class="linenos"> 470</span></a> <span class="n">_IDENTIFIERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Tokenizer-471"><a href="#Tokenizer-471"><span class="linenos"> 471</span></a> <span class="n">_IDENTIFIER_ESCAPES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> -</span><span id="Tokenizer-472"><a href="#Tokenizer-472"><span class="linenos"> 472</span></a> <span class="n">_QUOTES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Tokenizer-473"><a href="#Tokenizer-473"><span class="linenos"> 473</span></a> <span class="n">_STRING_ESCAPES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> -</span><span id="Tokenizer-474"><a href="#Tokenizer-474"><span class="linenos"> 474</span></a> <span class="n">_KEYWORD_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Tokenizer-475"><a href="#Tokenizer-475"><span class="linenos"> 475</span></a> -</span><span id="Tokenizer-476"><a href="#Tokenizer-476"><span class="linenos"> 476</span></a> <span class="n">KEYWORDS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">TokenType</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Tokenizer-477"><a href="#Tokenizer-477"><span class="linenos"> 477</span></a> <span class="o">**</span><span class="p">{</span><span class="sa">f</span><span class="s2">"</span><span class="se">{{</span><span class="s2">%</span><span class="si">{</span><span class="n">postfix</span><span class="si">}</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BLOCK_START</span> <span class="k">for</span> <span class="n">postfix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)},</span> -</span><span id="Tokenizer-478"><a href="#Tokenizer-478"><span class="linenos"> 478</span></a> <span class="o">**</span><span class="p">{</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}</span><span class="s2">%</span><span class="se">}}</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BLOCK_END</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)},</span> -</span><span id="Tokenizer-479"><a href="#Tokenizer-479"><span class="linenos"> 479</span></a> <span class="o">**</span><span class="p">{</span><span class="sa">f</span><span class="s2">"</span><span class="se">{{{{</span><span class="si">{</span><span class="n">postfix</span><span class="si">}</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BLOCK_START</span> <span class="k">for</span> <span class="n">postfix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"+"</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)},</span> -</span><span id="Tokenizer-480"><a href="#Tokenizer-480"><span class="linenos"> 480</span></a> <span class="o">**</span><span class="p">{</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}</span><span class="se">}}}}</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BLOCK_END</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"+"</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)},</span> -</span><span id="Tokenizer-481"><a href="#Tokenizer-481"><span class="linenos"> 481</span></a> <span class="s2">"/*+"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HINT</span><span class="p">,</span> -</span><span id="Tokenizer-482"><a href="#Tokenizer-482"><span class="linenos"> 482</span></a> <span class="s2">"=="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> -</span><span id="Tokenizer-483"><a href="#Tokenizer-483"><span class="linenos"> 483</span></a> <span class="s2">"::"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DCOLON</span><span class="p">,</span> -</span><span id="Tokenizer-484"><a href="#Tokenizer-484"><span class="linenos"> 484</span></a> <span class="s2">"||"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DPIPE</span><span class="p">,</span> -</span><span id="Tokenizer-485"><a href="#Tokenizer-485"><span class="linenos"> 485</span></a> <span class="s2">">="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GTE</span><span class="p">,</span> -</span><span id="Tokenizer-486"><a href="#Tokenizer-486"><span class="linenos"> 486</span></a> <span class="s2">"<="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LTE</span><span class="p">,</span> -</span><span id="Tokenizer-487"><a href="#Tokenizer-487"><span class="linenos"> 487</span></a> <span class="s2">"<>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> -</span><span id="Tokenizer-488"><a href="#Tokenizer-488"><span class="linenos"> 488</span></a> <span class="s2">"!="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> -</span><span id="Tokenizer-489"><a href="#Tokenizer-489"><span class="linenos"> 489</span></a> <span class="s2">"<=>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULLSAFE_EQ</span><span class="p">,</span> -</span><span id="Tokenizer-490"><a href="#Tokenizer-490"><span class="linenos"> 490</span></a> <span class="s2">"->"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ARROW</span><span class="p">,</span> -</span><span id="Tokenizer-491"><a href="#Tokenizer-491"><span class="linenos"> 491</span></a> <span class="s2">"->>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DARROW</span><span class="p">,</span> -</span><span id="Tokenizer-492"><a href="#Tokenizer-492"><span class="linenos"> 492</span></a> <span class="s2">"=>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FARROW</span><span class="p">,</span> -</span><span id="Tokenizer-493"><a href="#Tokenizer-493"><span class="linenos"> 493</span></a> <span class="s2">"#>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HASH_ARROW</span><span class="p">,</span> -</span><span id="Tokenizer-494"><a href="#Tokenizer-494"><span class="linenos"> 494</span></a> <span class="s2">"#>>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DHASH_ARROW</span><span class="p">,</span> -</span><span id="Tokenizer-495"><a href="#Tokenizer-495"><span class="linenos"> 495</span></a> <span class="s2">"<->"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LR_ARROW</span><span class="p">,</span> -</span><span id="Tokenizer-496"><a href="#Tokenizer-496"><span class="linenos"> 496</span></a> <span class="s2">"&&"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DAMP</span><span class="p">,</span> -</span><span id="Tokenizer-497"><a href="#Tokenizer-497"><span class="linenos"> 497</span></a> <span class="s2">"ALL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ALL</span><span class="p">,</span> -</span><span id="Tokenizer-498"><a href="#Tokenizer-498"><span class="linenos"> 498</span></a> <span class="s2">"ALWAYS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ALWAYS</span><span class="p">,</span> -</span><span id="Tokenizer-499"><a href="#Tokenizer-499"><span class="linenos"> 499</span></a> <span class="s2">"AND"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">AND</span><span class="p">,</span> -</span><span id="Tokenizer-500"><a href="#Tokenizer-500"><span class="linenos"> 500</span></a> <span class="s2">"ANTI"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ANTI</span><span class="p">,</span> -</span><span id="Tokenizer-501"><a href="#Tokenizer-501"><span class="linenos"> 501</span></a> <span class="s2">"ANY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ANY</span><span class="p">,</span> -</span><span id="Tokenizer-502"><a href="#Tokenizer-502"><span class="linenos"> 502</span></a> <span class="s2">"ASC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ASC</span><span class="p">,</span> -</span><span id="Tokenizer-503"><a href="#Tokenizer-503"><span class="linenos"> 503</span></a> <span class="s2">"AS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ALIAS</span><span class="p">,</span> -</span><span id="Tokenizer-504"><a href="#Tokenizer-504"><span class="linenos"> 504</span></a> <span class="s2">"ASOF"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ASOF</span><span class="p">,</span> -</span><span id="Tokenizer-505"><a href="#Tokenizer-505"><span class="linenos"> 505</span></a> <span class="s2">"AUTOINCREMENT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">,</span> -</span><span id="Tokenizer-506"><a href="#Tokenizer-506"><span class="linenos"> 506</span></a> <span class="s2">"AUTO_INCREMENT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">,</span> -</span><span id="Tokenizer-507"><a href="#Tokenizer-507"><span class="linenos"> 507</span></a> <span class="s2">"BEGIN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">,</span> -</span><span id="Tokenizer-508"><a href="#Tokenizer-508"><span class="linenos"> 508</span></a> <span class="s2">"BETWEEN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BETWEEN</span><span class="p">,</span> -</span><span id="Tokenizer-509"><a href="#Tokenizer-509"><span class="linenos"> 509</span></a> <span class="s2">"CACHE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CACHE</span><span class="p">,</span> -</span><span id="Tokenizer-510"><a href="#Tokenizer-510"><span class="linenos"> 510</span></a> <span class="s2">"UNCACHE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNCACHE</span><span class="p">,</span> -</span><span id="Tokenizer-511"><a href="#Tokenizer-511"><span class="linenos"> 511</span></a> <span class="s2">"CASE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CASE</span><span class="p">,</span> -</span><span id="Tokenizer-512"><a href="#Tokenizer-512"><span class="linenos"> 512</span></a> <span class="s2">"CHARACTER SET"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CHARACTER_SET</span><span class="p">,</span> -</span><span id="Tokenizer-513"><a href="#Tokenizer-513"><span class="linenos"> 513</span></a> <span class="s2">"COLLATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLLATE</span><span class="p">,</span> -</span><span id="Tokenizer-514"><a href="#Tokenizer-514"><span class="linenos"> 514</span></a> <span class="s2">"COLUMN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLUMN</span><span class="p">,</span> -</span><span id="Tokenizer-515"><a href="#Tokenizer-515"><span class="linenos"> 515</span></a> <span class="s2">"COMMIT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMIT</span><span class="p">,</span> -</span><span id="Tokenizer-516"><a href="#Tokenizer-516"><span class="linenos"> 516</span></a> <span class="s2">"CONSTRAINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CONSTRAINT</span><span class="p">,</span> -</span><span id="Tokenizer-517"><a href="#Tokenizer-517"><span class="linenos"> 517</span></a> <span class="s2">"CREATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CREATE</span><span class="p">,</span> -</span><span id="Tokenizer-518"><a href="#Tokenizer-518"><span class="linenos"> 518</span></a> <span class="s2">"CROSS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CROSS</span><span class="p">,</span> -</span><span id="Tokenizer-519"><a href="#Tokenizer-519"><span class="linenos"> 519</span></a> <span class="s2">"CUBE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CUBE</span><span class="p">,</span> -</span><span id="Tokenizer-520"><a href="#Tokenizer-520"><span class="linenos"> 520</span></a> <span class="s2">"CURRENT_DATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_DATE</span><span class="p">,</span> -</span><span id="Tokenizer-521"><a href="#Tokenizer-521"><span class="linenos"> 521</span></a> <span class="s2">"CURRENT_TIME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIME</span><span class="p">,</span> -</span><span id="Tokenizer-522"><a href="#Tokenizer-522"><span class="linenos"> 522</span></a> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIMESTAMP</span><span class="p">,</span> -</span><span id="Tokenizer-523"><a href="#Tokenizer-523"><span class="linenos"> 523</span></a> <span class="s2">"CURRENT_USER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_USER</span><span class="p">,</span> -</span><span id="Tokenizer-524"><a href="#Tokenizer-524"><span class="linenos"> 524</span></a> <span class="s2">"DATABASE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATABASE</span><span class="p">,</span> -</span><span id="Tokenizer-525"><a href="#Tokenizer-525"><span class="linenos"> 525</span></a> <span class="s2">"DEFAULT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">,</span> -</span><span id="Tokenizer-526"><a href="#Tokenizer-526"><span class="linenos"> 526</span></a> <span class="s2">"DELETE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DELETE</span><span class="p">,</span> -</span><span id="Tokenizer-527"><a href="#Tokenizer-527"><span class="linenos"> 527</span></a> <span class="s2">"DESC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DESC</span><span class="p">,</span> -</span><span id="Tokenizer-528"><a href="#Tokenizer-528"><span class="linenos"> 528</span></a> <span class="s2">"DESCRIBE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DESCRIBE</span><span class="p">,</span> -</span><span id="Tokenizer-529"><a href="#Tokenizer-529"><span class="linenos"> 529</span></a> <span class="s2">"DISTINCT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DISTINCT</span><span class="p">,</span> -</span><span id="Tokenizer-530"><a href="#Tokenizer-530"><span class="linenos"> 530</span></a> <span class="s2">"DIV"</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="Tokenizer-531"><a href="#Tokenizer-531"><span class="linenos"> 531</span></a> <span class="s2">"DROP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DROP</span><span class="p">,</span> -</span><span id="Tokenizer-532"><a href="#Tokenizer-532"><span class="linenos"> 532</span></a> <span class="s2">"ELSE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ELSE</span><span class="p">,</span> -</span><span id="Tokenizer-533"><a href="#Tokenizer-533"><span class="linenos"> 533</span></a> <span class="s2">"END"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">END</span><span class="p">,</span> -</span><span id="Tokenizer-534"><a href="#Tokenizer-534"><span class="linenos"> 534</span></a> <span class="s2">"ESCAPE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ESCAPE</span><span class="p">,</span> -</span><span id="Tokenizer-535"><a href="#Tokenizer-535"><span class="linenos"> 535</span></a> <span class="s2">"EXCEPT"</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="Tokenizer-536"><a href="#Tokenizer-536"><span class="linenos"> 536</span></a> <span class="s2">"EXECUTE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXECUTE</span><span class="p">,</span> -</span><span id="Tokenizer-537"><a href="#Tokenizer-537"><span class="linenos"> 537</span></a> <span class="s2">"EXISTS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXISTS</span><span class="p">,</span> -</span><span id="Tokenizer-538"><a href="#Tokenizer-538"><span class="linenos"> 538</span></a> <span class="s2">"FALSE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FALSE</span><span class="p">,</span> -</span><span id="Tokenizer-539"><a href="#Tokenizer-539"><span class="linenos"> 539</span></a> <span class="s2">"FETCH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FETCH</span><span class="p">,</span> -</span><span id="Tokenizer-540"><a href="#Tokenizer-540"><span class="linenos"> 540</span></a> <span class="s2">"FILTER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FILTER</span><span class="p">,</span> -</span><span id="Tokenizer-541"><a href="#Tokenizer-541"><span class="linenos"> 541</span></a> <span class="s2">"FIRST"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FIRST</span><span class="p">,</span> -</span><span id="Tokenizer-542"><a href="#Tokenizer-542"><span class="linenos"> 542</span></a> <span class="s2">"FULL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FULL</span><span class="p">,</span> -</span><span id="Tokenizer-543"><a href="#Tokenizer-543"><span class="linenos"> 543</span></a> <span class="s2">"FUNCTION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FUNCTION</span><span class="p">,</span> -</span><span id="Tokenizer-544"><a href="#Tokenizer-544"><span class="linenos"> 544</span></a> <span class="s2">"FOR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FOR</span><span class="p">,</span> -</span><span id="Tokenizer-545"><a href="#Tokenizer-545"><span class="linenos"> 545</span></a> <span class="s2">"FOREIGN KEY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FOREIGN_KEY</span><span class="p">,</span> -</span><span id="Tokenizer-546"><a href="#Tokenizer-546"><span class="linenos"> 546</span></a> <span class="s2">"FORMAT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FORMAT</span><span class="p">,</span> -</span><span id="Tokenizer-547"><a href="#Tokenizer-547"><span class="linenos"> 547</span></a> <span class="s2">"FROM"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FROM</span><span class="p">,</span> -</span><span id="Tokenizer-548"><a href="#Tokenizer-548"><span class="linenos"> 548</span></a> <span class="s2">"GEOGRAPHY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GEOGRAPHY</span><span class="p">,</span> -</span><span id="Tokenizer-549"><a href="#Tokenizer-549"><span class="linenos"> 549</span></a> <span class="s2">"GEOMETRY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GEOMETRY</span><span class="p">,</span> -</span><span id="Tokenizer-550"><a href="#Tokenizer-550"><span class="linenos"> 550</span></a> <span class="s2">"GLOB"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GLOB</span><span class="p">,</span> -</span><span id="Tokenizer-551"><a href="#Tokenizer-551"><span class="linenos"> 551</span></a> <span class="s2">"GROUP BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GROUP_BY</span><span class="p">,</span> -</span><span id="Tokenizer-552"><a href="#Tokenizer-552"><span class="linenos"> 552</span></a> <span class="s2">"GROUPING SETS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GROUPING_SETS</span><span class="p">,</span> -</span><span id="Tokenizer-553"><a href="#Tokenizer-553"><span class="linenos"> 553</span></a> <span class="s2">"HAVING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HAVING</span><span class="p">,</span> -</span><span id="Tokenizer-554"><a href="#Tokenizer-554"><span class="linenos"> 554</span></a> <span class="s2">"IF"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IF</span><span class="p">,</span> -</span><span id="Tokenizer-555"><a href="#Tokenizer-555"><span class="linenos"> 555</span></a> <span class="s2">"ILIKE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ILIKE</span><span class="p">,</span> -</span><span id="Tokenizer-556"><a href="#Tokenizer-556"><span class="linenos"> 556</span></a> <span class="s2">"IN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IN</span><span class="p">,</span> -</span><span id="Tokenizer-557"><a href="#Tokenizer-557"><span class="linenos"> 557</span></a> <span class="s2">"INDEX"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INDEX</span><span class="p">,</span> -</span><span id="Tokenizer-558"><a href="#Tokenizer-558"><span class="linenos"> 558</span></a> <span class="s2">"INET"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INET</span><span class="p">,</span> -</span><span id="Tokenizer-559"><a href="#Tokenizer-559"><span class="linenos"> 559</span></a> <span class="s2">"INNER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INNER</span><span class="p">,</span> -</span><span id="Tokenizer-560"><a href="#Tokenizer-560"><span class="linenos"> 560</span></a> <span class="s2">"INSERT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INSERT</span><span class="p">,</span> -</span><span id="Tokenizer-561"><a href="#Tokenizer-561"><span class="linenos"> 561</span></a> <span class="s2">"INTERVAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INTERVAL</span><span class="p">,</span> -</span><span id="Tokenizer-562"><a href="#Tokenizer-562"><span class="linenos"> 562</span></a> <span class="s2">"INTERSECT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INTERSECT</span><span class="p">,</span> -</span><span id="Tokenizer-563"><a href="#Tokenizer-563"><span class="linenos"> 563</span></a> <span class="s2">"INTO"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INTO</span><span class="p">,</span> -</span><span id="Tokenizer-564"><a href="#Tokenizer-564"><span class="linenos"> 564</span></a> <span class="s2">"IS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IS</span><span class="p">,</span> -</span><span id="Tokenizer-565"><a href="#Tokenizer-565"><span class="linenos"> 565</span></a> <span class="s2">"ISNULL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ISNULL</span><span class="p">,</span> -</span><span id="Tokenizer-566"><a href="#Tokenizer-566"><span class="linenos"> 566</span></a> <span class="s2">"JOIN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">JOIN</span><span class="p">,</span> -</span><span id="Tokenizer-567"><a href="#Tokenizer-567"><span class="linenos"> 567</span></a> <span class="s2">"KEEP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">KEEP</span><span class="p">,</span> -</span><span id="Tokenizer-568"><a href="#Tokenizer-568"><span class="linenos"> 568</span></a> <span class="s2">"LATERAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LATERAL</span><span class="p">,</span> -</span><span id="Tokenizer-569"><a href="#Tokenizer-569"><span class="linenos"> 569</span></a> <span class="s2">"LEFT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LEFT</span><span class="p">,</span> -</span><span id="Tokenizer-570"><a href="#Tokenizer-570"><span class="linenos"> 570</span></a> <span class="s2">"LIKE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIKE</span><span class="p">,</span> -</span><span id="Tokenizer-571"><a href="#Tokenizer-571"><span class="linenos"> 571</span></a> <span class="s2">"LIMIT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIMIT</span><span class="p">,</span> -</span><span id="Tokenizer-572"><a href="#Tokenizer-572"><span class="linenos"> 572</span></a> <span class="s2">"LOAD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LOAD</span><span class="p">,</span> -</span><span id="Tokenizer-573"><a href="#Tokenizer-573"><span class="linenos"> 573</span></a> <span class="s2">"LOCK"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LOCK</span><span class="p">,</span> -</span><span id="Tokenizer-574"><a href="#Tokenizer-574"><span class="linenos"> 574</span></a> <span class="s2">"MERGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MERGE</span><span class="p">,</span> -</span><span id="Tokenizer-575"><a href="#Tokenizer-575"><span class="linenos"> 575</span></a> <span class="s2">"NATURAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NATURAL</span><span class="p">,</span> -</span><span id="Tokenizer-576"><a href="#Tokenizer-576"><span class="linenos"> 576</span></a> <span class="s2">"NEXT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEXT</span><span class="p">,</span> -</span><span id="Tokenizer-577"><a href="#Tokenizer-577"><span class="linenos"> 577</span></a> <span class="s2">"NEXT VALUE FOR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEXT_VALUE_FOR</span><span class="p">,</span> -</span><span id="Tokenizer-578"><a href="#Tokenizer-578"><span class="linenos"> 578</span></a> <span class="s2">"NOT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NOT</span><span class="p">,</span> -</span><span id="Tokenizer-579"><a href="#Tokenizer-579"><span class="linenos"> 579</span></a> <span class="s2">"NOTNULL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NOTNULL</span><span class="p">,</span> -</span><span id="Tokenizer-580"><a href="#Tokenizer-580"><span class="linenos"> 580</span></a> <span class="s2">"NULL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">,</span> -</span><span id="Tokenizer-581"><a href="#Tokenizer-581"><span class="linenos"> 581</span></a> <span class="s2">"OBJECT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OBJECT</span><span class="p">,</span> -</span><span id="Tokenizer-582"><a href="#Tokenizer-582"><span class="linenos"> 582</span></a> <span class="s2">"OFFSET"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OFFSET</span><span class="p">,</span> -</span><span id="Tokenizer-583"><a href="#Tokenizer-583"><span class="linenos"> 583</span></a> <span class="s2">"ON"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ON</span><span class="p">,</span> -</span><span id="Tokenizer-584"><a href="#Tokenizer-584"><span class="linenos"> 584</span></a> <span class="s2">"OR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OR</span><span class="p">,</span> -</span><span id="Tokenizer-585"><a href="#Tokenizer-585"><span class="linenos"> 585</span></a> <span class="s2">"ORDER BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ORDER_BY</span><span class="p">,</span> -</span><span id="Tokenizer-586"><a href="#Tokenizer-586"><span class="linenos"> 586</span></a> <span class="s2">"ORDINALITY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ORDINALITY</span><span class="p">,</span> -</span><span id="Tokenizer-587"><a href="#Tokenizer-587"><span class="linenos"> 587</span></a> <span class="s2">"OUTER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OUTER</span><span class="p">,</span> -</span><span id="Tokenizer-588"><a href="#Tokenizer-588"><span class="linenos"> 588</span></a> <span class="s2">"OVER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OVER</span><span class="p">,</span> -</span><span id="Tokenizer-589"><a href="#Tokenizer-589"><span class="linenos"> 589</span></a> <span class="s2">"OVERLAPS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OVERLAPS</span><span class="p">,</span> -</span><span id="Tokenizer-590"><a href="#Tokenizer-590"><span class="linenos"> 590</span></a> <span class="s2">"OVERWRITE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OVERWRITE</span><span class="p">,</span> -</span><span id="Tokenizer-591"><a href="#Tokenizer-591"><span class="linenos"> 591</span></a> <span class="s2">"PARTITION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARTITION</span><span class="p">,</span> -</span><span id="Tokenizer-592"><a href="#Tokenizer-592"><span class="linenos"> 592</span></a> <span class="s2">"PARTITION BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARTITION_BY</span><span class="p">,</span> -</span><span id="Tokenizer-593"><a href="#Tokenizer-593"><span class="linenos"> 593</span></a> <span class="s2">"PARTITIONED BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARTITION_BY</span><span class="p">,</span> -</span><span id="Tokenizer-594"><a href="#Tokenizer-594"><span class="linenos"> 594</span></a> <span class="s2">"PARTITIONED_BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARTITION_BY</span><span class="p">,</span> -</span><span id="Tokenizer-595"><a href="#Tokenizer-595"><span class="linenos"> 595</span></a> <span class="s2">"PERCENT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PERCENT</span><span class="p">,</span> -</span><span id="Tokenizer-596"><a href="#Tokenizer-596"><span class="linenos"> 596</span></a> <span class="s2">"PIVOT"</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="Tokenizer-597"><a href="#Tokenizer-597"><span class="linenos"> 597</span></a> <span class="s2">"PRAGMA"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PRAGMA</span><span class="p">,</span> -</span><span id="Tokenizer-598"><a href="#Tokenizer-598"><span class="linenos"> 598</span></a> <span class="s2">"PRIMARY KEY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PRIMARY_KEY</span><span class="p">,</span> -</span><span id="Tokenizer-599"><a href="#Tokenizer-599"><span class="linenos"> 599</span></a> <span class="s2">"PROCEDURE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PROCEDURE</span><span class="p">,</span> -</span><span id="Tokenizer-600"><a href="#Tokenizer-600"><span class="linenos"> 600</span></a> <span class="s2">"QUALIFY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">QUALIFY</span><span class="p">,</span> -</span><span id="Tokenizer-601"><a href="#Tokenizer-601"><span class="linenos"> 601</span></a> <span class="s2">"RANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RANGE</span><span class="p">,</span> -</span><span id="Tokenizer-602"><a href="#Tokenizer-602"><span class="linenos"> 602</span></a> <span class="s2">"RECURSIVE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RECURSIVE</span><span class="p">,</span> -</span><span id="Tokenizer-603"><a href="#Tokenizer-603"><span class="linenos"> 603</span></a> <span class="s2">"REGEXP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> -</span><span id="Tokenizer-604"><a href="#Tokenizer-604"><span class="linenos"> 604</span></a> <span class="s2">"REPLACE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">,</span> -</span><span id="Tokenizer-605"><a href="#Tokenizer-605"><span class="linenos"> 605</span></a> <span class="s2">"RETURNING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RETURNING</span><span class="p">,</span> -</span><span id="Tokenizer-606"><a href="#Tokenizer-606"><span class="linenos"> 606</span></a> <span class="s2">"REFERENCES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REFERENCES</span><span class="p">,</span> -</span><span id="Tokenizer-607"><a href="#Tokenizer-607"><span class="linenos"> 607</span></a> <span class="s2">"RIGHT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RIGHT</span><span class="p">,</span> -</span><span id="Tokenizer-608"><a href="#Tokenizer-608"><span class="linenos"> 608</span></a> <span class="s2">"RLIKE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> -</span><span id="Tokenizer-609"><a href="#Tokenizer-609"><span class="linenos"> 609</span></a> <span class="s2">"ROLLBACK"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROLLBACK</span><span class="p">,</span> -</span><span id="Tokenizer-610"><a href="#Tokenizer-610"><span class="linenos"> 610</span></a> <span class="s2">"ROLLUP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROLLUP</span><span class="p">,</span> -</span><span id="Tokenizer-611"><a href="#Tokenizer-611"><span class="linenos"> 611</span></a> <span class="s2">"ROW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> -</span><span id="Tokenizer-612"><a href="#Tokenizer-612"><span class="linenos"> 612</span></a> <span class="s2">"ROWS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">,</span> -</span><span id="Tokenizer-613"><a href="#Tokenizer-613"><span class="linenos"> 613</span></a> <span class="s2">"SCHEMA"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SCHEMA</span><span class="p">,</span> -</span><span id="Tokenizer-614"><a href="#Tokenizer-614"><span class="linenos"> 614</span></a> <span class="s2">"SELECT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SELECT</span><span class="p">,</span> -</span><span id="Tokenizer-615"><a href="#Tokenizer-615"><span class="linenos"> 615</span></a> <span class="s2">"SEMI"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SEMI</span><span class="p">,</span> -</span><span id="Tokenizer-616"><a href="#Tokenizer-616"><span class="linenos"> 616</span></a> <span class="s2">"SET"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">,</span> -</span><span id="Tokenizer-617"><a href="#Tokenizer-617"><span class="linenos"> 617</span></a> <span class="s2">"SETTINGS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SETTINGS</span><span class="p">,</span> -</span><span id="Tokenizer-618"><a href="#Tokenizer-618"><span class="linenos"> 618</span></a> <span class="s2">"SHOW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SHOW</span><span class="p">,</span> -</span><span id="Tokenizer-619"><a href="#Tokenizer-619"><span class="linenos"> 619</span></a> <span class="s2">"SIMILAR TO"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SIMILAR_TO</span><span class="p">,</span> -</span><span id="Tokenizer-620"><a href="#Tokenizer-620"><span class="linenos"> 620</span></a> <span class="s2">"SOME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SOME</span><span class="p">,</span> -</span><span id="Tokenizer-621"><a href="#Tokenizer-621"><span class="linenos"> 621</span></a> <span class="s2">"TABLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> -</span><span id="Tokenizer-622"><a href="#Tokenizer-622"><span class="linenos"> 622</span></a> <span class="s2">"TABLESAMPLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span><span class="p">,</span> -</span><span id="Tokenizer-623"><a href="#Tokenizer-623"><span class="linenos"> 623</span></a> <span class="s2">"TEMP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEMPORARY</span><span class="p">,</span> -</span><span id="Tokenizer-624"><a href="#Tokenizer-624"><span class="linenos"> 624</span></a> <span class="s2">"TEMPORARY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEMPORARY</span><span class="p">,</span> -</span><span id="Tokenizer-625"><a href="#Tokenizer-625"><span class="linenos"> 625</span></a> <span class="s2">"THEN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">THEN</span><span class="p">,</span> -</span><span id="Tokenizer-626"><a href="#Tokenizer-626"><span class="linenos"> 626</span></a> <span class="s2">"TRUE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TRUE</span><span class="p">,</span> -</span><span id="Tokenizer-627"><a href="#Tokenizer-627"><span class="linenos"> 627</span></a> <span class="s2">"UNION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNION</span><span class="p">,</span> -</span><span id="Tokenizer-628"><a href="#Tokenizer-628"><span class="linenos"> 628</span></a> <span class="s2">"UNNEST"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNNEST</span><span class="p">,</span> -</span><span id="Tokenizer-629"><a href="#Tokenizer-629"><span class="linenos"> 629</span></a> <span class="s2">"UNPIVOT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNPIVOT</span><span class="p">,</span> -</span><span id="Tokenizer-630"><a href="#Tokenizer-630"><span class="linenos"> 630</span></a> <span class="s2">"UPDATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UPDATE</span><span class="p">,</span> -</span><span id="Tokenizer-631"><a href="#Tokenizer-631"><span class="linenos"> 631</span></a> <span class="s2">"USE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">USE</span><span class="p">,</span> -</span><span id="Tokenizer-632"><a href="#Tokenizer-632"><span class="linenos"> 632</span></a> <span class="s2">"USING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">USING</span><span class="p">,</span> -</span><span id="Tokenizer-633"><a href="#Tokenizer-633"><span class="linenos"> 633</span></a> <span class="s2">"UUID"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UUID</span><span class="p">,</span> -</span><span id="Tokenizer-634"><a href="#Tokenizer-634"><span class="linenos"> 634</span></a> <span class="s2">"VALUES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VALUES</span><span class="p">,</span> -</span><span id="Tokenizer-635"><a href="#Tokenizer-635"><span class="linenos"> 635</span></a> <span class="s2">"VIEW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VIEW</span><span class="p">,</span> -</span><span id="Tokenizer-636"><a href="#Tokenizer-636"><span class="linenos"> 636</span></a> <span class="s2">"VOLATILE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VOLATILE</span><span class="p">,</span> -</span><span id="Tokenizer-637"><a href="#Tokenizer-637"><span class="linenos"> 637</span></a> <span class="s2">"WHEN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WHEN</span><span class="p">,</span> -</span><span id="Tokenizer-638"><a href="#Tokenizer-638"><span class="linenos"> 638</span></a> <span class="s2">"WHERE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WHERE</span><span class="p">,</span> -</span><span id="Tokenizer-639"><a href="#Tokenizer-639"><span class="linenos"> 639</span></a> <span class="s2">"WINDOW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WINDOW</span><span class="p">,</span> -</span><span id="Tokenizer-640"><a href="#Tokenizer-640"><span class="linenos"> 640</span></a> <span class="s2">"WITH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> -</span><span id="Tokenizer-641"><a href="#Tokenizer-641"><span class="linenos"> 641</span></a> <span class="s2">"APPLY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">,</span> -</span><span id="Tokenizer-642"><a href="#Tokenizer-642"><span class="linenos"> 642</span></a> <span class="s2">"ARRAY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ARRAY</span><span class="p">,</span> -</span><span id="Tokenizer-643"><a href="#Tokenizer-643"><span class="linenos"> 643</span></a> <span class="s2">"BIT"</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="Tokenizer-644"><a href="#Tokenizer-644"><span class="linenos"> 644</span></a> <span class="s2">"BOOL"</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="Tokenizer-645"><a href="#Tokenizer-645"><span class="linenos"> 645</span></a> <span class="s2">"BOOLEAN"</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="Tokenizer-646"><a href="#Tokenizer-646"><span class="linenos"> 646</span></a> <span class="s2">"BYTE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">,</span> -</span><span id="Tokenizer-647"><a href="#Tokenizer-647"><span class="linenos"> 647</span></a> <span class="s2">"TINYINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">,</span> -</span><span id="Tokenizer-648"><a href="#Tokenizer-648"><span class="linenos"> 648</span></a> <span class="s2">"SHORT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> -</span><span id="Tokenizer-649"><a href="#Tokenizer-649"><span class="linenos"> 649</span></a> <span class="s2">"SMALLINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> -</span><span id="Tokenizer-650"><a href="#Tokenizer-650"><span class="linenos"> 650</span></a> <span class="s2">"INT2"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> -</span><span id="Tokenizer-651"><a href="#Tokenizer-651"><span class="linenos"> 651</span></a> <span class="s2">"INTEGER"</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="Tokenizer-652"><a href="#Tokenizer-652"><span class="linenos"> 652</span></a> <span class="s2">"INT"</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="Tokenizer-653"><a href="#Tokenizer-653"><span class="linenos"> 653</span></a> <span class="s2">"INT4"</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="Tokenizer-654"><a href="#Tokenizer-654"><span class="linenos"> 654</span></a> <span class="s2">"LONG"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> -</span><span id="Tokenizer-655"><a href="#Tokenizer-655"><span class="linenos"> 655</span></a> <span class="s2">"BIGINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> -</span><span id="Tokenizer-656"><a href="#Tokenizer-656"><span class="linenos"> 656</span></a> <span class="s2">"INT8"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> -</span><span id="Tokenizer-657"><a href="#Tokenizer-657"><span class="linenos"> 657</span></a> <span class="s2">"DEC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> -</span><span id="Tokenizer-658"><a href="#Tokenizer-658"><span class="linenos"> 658</span></a> <span class="s2">"DECIMAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> -</span><span id="Tokenizer-659"><a href="#Tokenizer-659"><span class="linenos"> 659</span></a> <span class="s2">"BIGDECIMAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGDECIMAL</span><span class="p">,</span> -</span><span id="Tokenizer-660"><a href="#Tokenizer-660"><span class="linenos"> 660</span></a> <span class="s2">"BIGNUMERIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGDECIMAL</span><span class="p">,</span> -</span><span id="Tokenizer-661"><a href="#Tokenizer-661"><span class="linenos"> 661</span></a> <span class="s2">"MAP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MAP</span><span class="p">,</span> -</span><span id="Tokenizer-662"><a href="#Tokenizer-662"><span class="linenos"> 662</span></a> <span class="s2">"NULLABLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULLABLE</span><span class="p">,</span> -</span><span id="Tokenizer-663"><a href="#Tokenizer-663"><span class="linenos"> 663</span></a> <span class="s2">"NUMBER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> -</span><span id="Tokenizer-664"><a href="#Tokenizer-664"><span class="linenos"> 664</span></a> <span class="s2">"NUMERIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> -</span><span id="Tokenizer-665"><a href="#Tokenizer-665"><span class="linenos"> 665</span></a> <span class="s2">"FIXED"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> -</span><span id="Tokenizer-666"><a href="#Tokenizer-666"><span class="linenos"> 666</span></a> <span class="s2">"REAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span> -</span><span id="Tokenizer-667"><a href="#Tokenizer-667"><span class="linenos"> 667</span></a> <span class="s2">"FLOAT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span> -</span><span id="Tokenizer-668"><a href="#Tokenizer-668"><span class="linenos"> 668</span></a> <span class="s2">"FLOAT4"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span> -</span><span id="Tokenizer-669"><a href="#Tokenizer-669"><span class="linenos"> 669</span></a> <span class="s2">"FLOAT8"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> -</span><span id="Tokenizer-670"><a href="#Tokenizer-670"><span class="linenos"> 670</span></a> <span class="s2">"DOUBLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> -</span><span id="Tokenizer-671"><a href="#Tokenizer-671"><span class="linenos"> 671</span></a> <span class="s2">"DOUBLE PRECISION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> -</span><span id="Tokenizer-672"><a href="#Tokenizer-672"><span class="linenos"> 672</span></a> <span class="s2">"JSON"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">JSON</span><span class="p">,</span> -</span><span id="Tokenizer-673"><a href="#Tokenizer-673"><span class="linenos"> 673</span></a> <span class="s2">"CHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span> -</span><span id="Tokenizer-674"><a href="#Tokenizer-674"><span class="linenos"> 674</span></a> <span class="s2">"CHARACTER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span> -</span><span id="Tokenizer-675"><a href="#Tokenizer-675"><span class="linenos"> 675</span></a> <span class="s2">"NCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">,</span> -</span><span id="Tokenizer-676"><a href="#Tokenizer-676"><span class="linenos"> 676</span></a> <span class="s2">"VARCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> -</span><span id="Tokenizer-677"><a href="#Tokenizer-677"><span class="linenos"> 677</span></a> <span class="s2">"VARCHAR2"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> -</span><span id="Tokenizer-678"><a href="#Tokenizer-678"><span class="linenos"> 678</span></a> <span class="s2">"NVARCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">,</span> -</span><span id="Tokenizer-679"><a href="#Tokenizer-679"><span class="linenos"> 679</span></a> <span class="s2">"NVARCHAR2"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">,</span> -</span><span id="Tokenizer-680"><a href="#Tokenizer-680"><span class="linenos"> 680</span></a> <span class="s2">"STR"</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="Tokenizer-681"><a href="#Tokenizer-681"><span class="linenos"> 681</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="Tokenizer-682"><a href="#Tokenizer-682"><span class="linenos"> 682</span></a> <span class="s2">"TEXT"</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="Tokenizer-683"><a href="#Tokenizer-683"><span class="linenos"> 683</span></a> <span class="s2">"CLOB"</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="Tokenizer-684"><a href="#Tokenizer-684"><span class="linenos"> 684</span></a> <span class="s2">"LONGVARCHAR"</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="Tokenizer-685"><a href="#Tokenizer-685"><span class="linenos"> 685</span></a> <span class="s2">"BINARY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BINARY</span><span class="p">,</span> -</span><span id="Tokenizer-686"><a href="#Tokenizer-686"><span class="linenos"> 686</span></a> <span class="s2">"BLOB"</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="Tokenizer-687"><a href="#Tokenizer-687"><span class="linenos"> 687</span></a> <span class="s2">"BYTEA"</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="Tokenizer-688"><a href="#Tokenizer-688"><span class="linenos"> 688</span></a> <span class="s2">"VARBINARY"</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="Tokenizer-689"><a href="#Tokenizer-689"><span class="linenos"> 689</span></a> <span class="s2">"TIME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIME</span><span class="p">,</span> -</span><span id="Tokenizer-690"><a href="#Tokenizer-690"><span class="linenos"> 690</span></a> <span class="s2">"TIMESTAMP"</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="Tokenizer-691"><a href="#Tokenizer-691"><span class="linenos"> 691</span></a> <span class="s2">"TIMESTAMPTZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> -</span><span id="Tokenizer-692"><a href="#Tokenizer-692"><span class="linenos"> 692</span></a> <span class="s2">"TIMESTAMPLTZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">,</span> -</span><span id="Tokenizer-693"><a href="#Tokenizer-693"><span class="linenos"> 693</span></a> <span class="s2">"DATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATE</span><span class="p">,</span> -</span><span id="Tokenizer-694"><a href="#Tokenizer-694"><span class="linenos"> 694</span></a> <span class="s2">"DATETIME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATETIME</span><span class="p">,</span> -</span><span id="Tokenizer-695"><a href="#Tokenizer-695"><span class="linenos"> 695</span></a> <span class="s2">"INT4RANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT4RANGE</span><span class="p">,</span> -</span><span id="Tokenizer-696"><a href="#Tokenizer-696"><span class="linenos"> 696</span></a> <span class="s2">"INT4MULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT4MULTIRANGE</span><span class="p">,</span> -</span><span id="Tokenizer-697"><a href="#Tokenizer-697"><span class="linenos"> 697</span></a> <span class="s2">"INT8RANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT8RANGE</span><span class="p">,</span> -</span><span id="Tokenizer-698"><a href="#Tokenizer-698"><span class="linenos"> 698</span></a> <span class="s2">"INT8MULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT8MULTIRANGE</span><span class="p">,</span> -</span><span id="Tokenizer-699"><a href="#Tokenizer-699"><span class="linenos"> 699</span></a> <span class="s2">"NUMRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NUMRANGE</span><span class="p">,</span> -</span><span id="Tokenizer-700"><a href="#Tokenizer-700"><span class="linenos"> 700</span></a> <span class="s2">"NUMMULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NUMMULTIRANGE</span><span class="p">,</span> -</span><span id="Tokenizer-701"><a href="#Tokenizer-701"><span class="linenos"> 701</span></a> <span class="s2">"TSRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TSRANGE</span><span class="p">,</span> -</span><span id="Tokenizer-702"><a href="#Tokenizer-702"><span class="linenos"> 702</span></a> <span class="s2">"TSMULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TSMULTIRANGE</span><span class="p">,</span> -</span><span id="Tokenizer-703"><a href="#Tokenizer-703"><span class="linenos"> 703</span></a> <span class="s2">"TSTZRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TSTZRANGE</span><span class="p">,</span> -</span><span id="Tokenizer-704"><a href="#Tokenizer-704"><span class="linenos"> 704</span></a> <span class="s2">"TSTZMULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TSTZMULTIRANGE</span><span class="p">,</span> -</span><span id="Tokenizer-705"><a href="#Tokenizer-705"><span class="linenos"> 705</span></a> <span class="s2">"DATERANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATERANGE</span><span class="p">,</span> -</span><span id="Tokenizer-706"><a href="#Tokenizer-706"><span class="linenos"> 706</span></a> <span class="s2">"DATEMULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATEMULTIRANGE</span><span class="p">,</span> -</span><span id="Tokenizer-707"><a href="#Tokenizer-707"><span class="linenos"> 707</span></a> <span class="s2">"UNIQUE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNIQUE</span><span class="p">,</span> -</span><span id="Tokenizer-708"><a href="#Tokenizer-708"><span class="linenos"> 708</span></a> <span class="s2">"STRUCT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">,</span> -</span><span id="Tokenizer-709"><a href="#Tokenizer-709"><span class="linenos"> 709</span></a> <span class="s2">"VARIANT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARIANT</span><span class="p">,</span> -</span><span id="Tokenizer-710"><a href="#Tokenizer-710"><span class="linenos"> 710</span></a> <span class="s2">"ALTER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ALTER</span><span class="p">,</span> -</span><span id="Tokenizer-711"><a href="#Tokenizer-711"><span class="linenos"> 711</span></a> <span class="s2">"ANALYZE"</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="Tokenizer-712"><a href="#Tokenizer-712"><span class="linenos"> 712</span></a> <span class="s2">"CALL"</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="Tokenizer-713"><a href="#Tokenizer-713"><span class="linenos"> 713</span></a> <span class="s2">"COMMENT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMENT</span><span class="p">,</span> -</span><span id="Tokenizer-714"><a href="#Tokenizer-714"><span class="linenos"> 714</span></a> <span class="s2">"COPY"</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="Tokenizer-715"><a href="#Tokenizer-715"><span class="linenos"> 715</span></a> <span class="s2">"EXPLAIN"</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="Tokenizer-716"><a href="#Tokenizer-716"><span class="linenos"> 716</span></a> <span class="s2">"GRANT"</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="Tokenizer-717"><a href="#Tokenizer-717"><span class="linenos"> 717</span></a> <span class="s2">"OPTIMIZE"</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="Tokenizer-718"><a href="#Tokenizer-718"><span class="linenos"> 718</span></a> <span class="s2">"PREPARE"</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="Tokenizer-719"><a href="#Tokenizer-719"><span class="linenos"> 719</span></a> <span class="s2">"TRUNCATE"</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="Tokenizer-720"><a href="#Tokenizer-720"><span class="linenos"> 720</span></a> <span class="s2">"VACUUM"</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="Tokenizer-721"><a href="#Tokenizer-721"><span class="linenos"> 721</span></a> <span class="p">}</span> -</span><span id="Tokenizer-722"><a href="#Tokenizer-722"><span class="linenos"> 722</span></a> -</span><span id="Tokenizer-723"><a href="#Tokenizer-723"><span class="linenos"> 723</span></a> <span class="n">WHITE_SPACE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">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="n">TokenType</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Tokenizer-724"><a href="#Tokenizer-724"><span class="linenos"> 724</span></a> <span class="s2">" "</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SPACE</span><span class="p">,</span> -</span><span id="Tokenizer-725"><a href="#Tokenizer-725"><span class="linenos"> 725</span></a> <span class="s2">"</span><span class="se">\t</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SPACE</span><span class="p">,</span> -</span><span id="Tokenizer-726"><a href="#Tokenizer-726"><span class="linenos"> 726</span></a> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">,</span> -</span><span id="Tokenizer-727"><a href="#Tokenizer-727"><span class="linenos"> 727</span></a> <span class="s2">"</span><span class="se">\r</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">,</span> -</span><span id="Tokenizer-728"><a href="#Tokenizer-728"><span class="linenos"> 728</span></a> <span class="s2">"</span><span class="se">\r\n</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">,</span> -</span><span id="Tokenizer-729"><a href="#Tokenizer-729"><span class="linenos"> 729</span></a> <span class="p">}</span> -</span><span id="Tokenizer-730"><a href="#Tokenizer-730"><span class="linenos"> 730</span></a> -</span><span id="Tokenizer-731"><a href="#Tokenizer-731"><span class="linenos"> 731</span></a> <span class="n">COMMANDS</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="Tokenizer-732"><a href="#Tokenizer-732"><span class="linenos"> 732</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> -</span><span id="Tokenizer-733"><a href="#Tokenizer-733"><span class="linenos"> 733</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXECUTE</span><span class="p">,</span> -</span><span id="Tokenizer-734"><a href="#Tokenizer-734"><span class="linenos"> 734</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">FETCH</span><span class="p">,</span> -</span><span id="Tokenizer-735"><a href="#Tokenizer-735"><span class="linenos"> 735</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">SHOW</span><span class="p">,</span> -</span><span id="Tokenizer-736"><a href="#Tokenizer-736"><span class="linenos"> 736</span></a> <span class="p">}</span> -</span><span id="Tokenizer-737"><a href="#Tokenizer-737"><span class="linenos"> 737</span></a> -</span><span id="Tokenizer-738"><a href="#Tokenizer-738"><span class="linenos"> 738</span></a> <span class="n">COMMAND_PREFIX_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SEMICOLON</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">}</span> -</span><span id="Tokenizer-739"><a href="#Tokenizer-739"><span class="linenos"> 739</span></a> -</span><span id="Tokenizer-740"><a href="#Tokenizer-740"><span class="linenos"> 740</span></a> <span class="c1"># handle numeric literals like in hive (3L = BIGINT)</span> -</span><span id="Tokenizer-741"><a href="#Tokenizer-741"><span class="linenos"> 741</span></a> <span class="n">NUMERIC_LITERALS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> -</span><span id="Tokenizer-742"><a href="#Tokenizer-742"><span class="linenos"> 742</span></a> <span class="n">ENCODE</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><span id="Tokenizer-468"><a href="#Tokenizer-468"><span class="linenos"> 468</span></a> <span class="c1"># Autofilled</span> +</span><span id="Tokenizer-469"><a href="#Tokenizer-469"><span class="linenos"> 469</span></a> <span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Tokenizer-470"><a href="#Tokenizer-470"><span class="linenos"> 470</span></a> +</span><span id="Tokenizer-471"><a href="#Tokenizer-471"><span class="linenos"> 471</span></a> <span class="n">_COMMENTS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Tokenizer-472"><a href="#Tokenizer-472"><span class="linenos"> 472</span></a> <span class="n">_FORMAT_STRINGS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">t</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">TokenType</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Tokenizer-473"><a href="#Tokenizer-473"><span class="linenos"> 473</span></a> <span class="n">_IDENTIFIERS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Tokenizer-474"><a href="#Tokenizer-474"><span class="linenos"> 474</span></a> <span class="n">_IDENTIFIER_ESCAPES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> +</span><span id="Tokenizer-475"><a href="#Tokenizer-475"><span class="linenos"> 475</span></a> <span class="n">_QUOTES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Tokenizer-476"><a href="#Tokenizer-476"><span class="linenos"> 476</span></a> <span class="n">_STRING_ESCAPES</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> +</span><span id="Tokenizer-477"><a href="#Tokenizer-477"><span class="linenos"> 477</span></a> <span class="n">_KEYWORD_TRIE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Tokenizer-478"><a href="#Tokenizer-478"><span class="linenos"> 478</span></a> +</span><span id="Tokenizer-479"><a href="#Tokenizer-479"><span class="linenos"> 479</span></a> <span class="n">KEYWORDS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">TokenType</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Tokenizer-480"><a href="#Tokenizer-480"><span class="linenos"> 480</span></a> <span class="o">**</span><span class="p">{</span><span class="sa">f</span><span class="s2">"</span><span class="se">{{</span><span class="s2">%</span><span class="si">{</span><span class="n">postfix</span><span class="si">}</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BLOCK_START</span> <span class="k">for</span> <span class="n">postfix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)},</span> +</span><span id="Tokenizer-481"><a href="#Tokenizer-481"><span class="linenos"> 481</span></a> <span class="o">**</span><span class="p">{</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}</span><span class="s2">%</span><span class="se">}}</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BLOCK_END</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)},</span> +</span><span id="Tokenizer-482"><a href="#Tokenizer-482"><span class="linenos"> 482</span></a> <span class="o">**</span><span class="p">{</span><span class="sa">f</span><span class="s2">"</span><span class="se">{{{{</span><span class="si">{</span><span class="n">postfix</span><span class="si">}</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BLOCK_START</span> <span class="k">for</span> <span class="n">postfix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"+"</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)},</span> +</span><span id="Tokenizer-483"><a href="#Tokenizer-483"><span class="linenos"> 483</span></a> <span class="o">**</span><span class="p">{</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}</span><span class="se">}}}}</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BLOCK_END</span> <span class="k">for</span> <span class="n">prefix</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"+"</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)},</span> +</span><span id="Tokenizer-484"><a href="#Tokenizer-484"><span class="linenos"> 484</span></a> <span class="s2">"/*+"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HINT</span><span class="p">,</span> +</span><span id="Tokenizer-485"><a href="#Tokenizer-485"><span class="linenos"> 485</span></a> <span class="s2">"=="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EQ</span><span class="p">,</span> +</span><span id="Tokenizer-486"><a href="#Tokenizer-486"><span class="linenos"> 486</span></a> <span class="s2">"::"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DCOLON</span><span class="p">,</span> +</span><span id="Tokenizer-487"><a href="#Tokenizer-487"><span class="linenos"> 487</span></a> <span class="s2">"||"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DPIPE</span><span class="p">,</span> +</span><span id="Tokenizer-488"><a href="#Tokenizer-488"><span class="linenos"> 488</span></a> <span class="s2">">="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GTE</span><span class="p">,</span> +</span><span id="Tokenizer-489"><a href="#Tokenizer-489"><span class="linenos"> 489</span></a> <span class="s2">"<="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LTE</span><span class="p">,</span> +</span><span id="Tokenizer-490"><a href="#Tokenizer-490"><span class="linenos"> 490</span></a> <span class="s2">"<>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> +</span><span id="Tokenizer-491"><a href="#Tokenizer-491"><span class="linenos"> 491</span></a> <span class="s2">"!="</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEQ</span><span class="p">,</span> +</span><span id="Tokenizer-492"><a href="#Tokenizer-492"><span class="linenos"> 492</span></a> <span class="s2">"<=>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULLSAFE_EQ</span><span class="p">,</span> +</span><span id="Tokenizer-493"><a href="#Tokenizer-493"><span class="linenos"> 493</span></a> <span class="s2">"->"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ARROW</span><span class="p">,</span> +</span><span id="Tokenizer-494"><a href="#Tokenizer-494"><span class="linenos"> 494</span></a> <span class="s2">"->>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DARROW</span><span class="p">,</span> +</span><span id="Tokenizer-495"><a href="#Tokenizer-495"><span class="linenos"> 495</span></a> <span class="s2">"=>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FARROW</span><span class="p">,</span> +</span><span id="Tokenizer-496"><a href="#Tokenizer-496"><span class="linenos"> 496</span></a> <span class="s2">"#>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HASH_ARROW</span><span class="p">,</span> +</span><span id="Tokenizer-497"><a href="#Tokenizer-497"><span class="linenos"> 497</span></a> <span class="s2">"#>>"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DHASH_ARROW</span><span class="p">,</span> +</span><span id="Tokenizer-498"><a href="#Tokenizer-498"><span class="linenos"> 498</span></a> <span class="s2">"<->"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LR_ARROW</span><span class="p">,</span> +</span><span id="Tokenizer-499"><a href="#Tokenizer-499"><span class="linenos"> 499</span></a> <span class="s2">"&&"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DAMP</span><span class="p">,</span> +</span><span id="Tokenizer-500"><a href="#Tokenizer-500"><span class="linenos"> 500</span></a> <span class="s2">"ALL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ALL</span><span class="p">,</span> +</span><span id="Tokenizer-501"><a href="#Tokenizer-501"><span class="linenos"> 501</span></a> <span class="s2">"ALWAYS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ALWAYS</span><span class="p">,</span> +</span><span id="Tokenizer-502"><a href="#Tokenizer-502"><span class="linenos"> 502</span></a> <span class="s2">"AND"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">AND</span><span class="p">,</span> +</span><span id="Tokenizer-503"><a href="#Tokenizer-503"><span class="linenos"> 503</span></a> <span class="s2">"ANTI"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ANTI</span><span class="p">,</span> +</span><span id="Tokenizer-504"><a href="#Tokenizer-504"><span class="linenos"> 504</span></a> <span class="s2">"ANY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ANY</span><span class="p">,</span> +</span><span id="Tokenizer-505"><a href="#Tokenizer-505"><span class="linenos"> 505</span></a> <span class="s2">"ASC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ASC</span><span class="p">,</span> +</span><span id="Tokenizer-506"><a href="#Tokenizer-506"><span class="linenos"> 506</span></a> <span class="s2">"AS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ALIAS</span><span class="p">,</span> +</span><span id="Tokenizer-507"><a href="#Tokenizer-507"><span class="linenos"> 507</span></a> <span class="s2">"ASOF"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ASOF</span><span class="p">,</span> +</span><span id="Tokenizer-508"><a href="#Tokenizer-508"><span class="linenos"> 508</span></a> <span class="s2">"AUTOINCREMENT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">,</span> +</span><span id="Tokenizer-509"><a href="#Tokenizer-509"><span class="linenos"> 509</span></a> <span class="s2">"AUTO_INCREMENT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">AUTO_INCREMENT</span><span class="p">,</span> +</span><span id="Tokenizer-510"><a href="#Tokenizer-510"><span class="linenos"> 510</span></a> <span class="s2">"BEGIN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">,</span> +</span><span id="Tokenizer-511"><a href="#Tokenizer-511"><span class="linenos"> 511</span></a> <span class="s2">"BETWEEN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BETWEEN</span><span class="p">,</span> +</span><span id="Tokenizer-512"><a href="#Tokenizer-512"><span class="linenos"> 512</span></a> <span class="s2">"CACHE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CACHE</span><span class="p">,</span> +</span><span id="Tokenizer-513"><a href="#Tokenizer-513"><span class="linenos"> 513</span></a> <span class="s2">"UNCACHE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNCACHE</span><span class="p">,</span> +</span><span id="Tokenizer-514"><a href="#Tokenizer-514"><span class="linenos"> 514</span></a> <span class="s2">"CASE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CASE</span><span class="p">,</span> +</span><span id="Tokenizer-515"><a href="#Tokenizer-515"><span class="linenos"> 515</span></a> <span class="s2">"CHARACTER SET"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CHARACTER_SET</span><span class="p">,</span> +</span><span id="Tokenizer-516"><a href="#Tokenizer-516"><span class="linenos"> 516</span></a> <span class="s2">"CLUSTER BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CLUSTER_BY</span><span class="p">,</span> +</span><span id="Tokenizer-517"><a href="#Tokenizer-517"><span class="linenos"> 517</span></a> <span class="s2">"COLLATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLLATE</span><span class="p">,</span> +</span><span id="Tokenizer-518"><a href="#Tokenizer-518"><span class="linenos"> 518</span></a> <span class="s2">"COLUMN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COLUMN</span><span class="p">,</span> +</span><span id="Tokenizer-519"><a href="#Tokenizer-519"><span class="linenos"> 519</span></a> <span class="s2">"COMMIT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMIT</span><span class="p">,</span> +</span><span id="Tokenizer-520"><a href="#Tokenizer-520"><span class="linenos"> 520</span></a> <span class="s2">"CONSTRAINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CONSTRAINT</span><span class="p">,</span> +</span><span id="Tokenizer-521"><a href="#Tokenizer-521"><span class="linenos"> 521</span></a> <span class="s2">"CREATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CREATE</span><span class="p">,</span> +</span><span id="Tokenizer-522"><a href="#Tokenizer-522"><span class="linenos"> 522</span></a> <span class="s2">"CROSS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CROSS</span><span class="p">,</span> +</span><span id="Tokenizer-523"><a href="#Tokenizer-523"><span class="linenos"> 523</span></a> <span class="s2">"CUBE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CUBE</span><span class="p">,</span> +</span><span id="Tokenizer-524"><a href="#Tokenizer-524"><span class="linenos"> 524</span></a> <span class="s2">"CURRENT_DATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_DATE</span><span class="p">,</span> +</span><span id="Tokenizer-525"><a href="#Tokenizer-525"><span class="linenos"> 525</span></a> <span class="s2">"CURRENT_TIME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIME</span><span class="p">,</span> +</span><span id="Tokenizer-526"><a href="#Tokenizer-526"><span class="linenos"> 526</span></a> <span class="s2">"CURRENT_TIMESTAMP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_TIMESTAMP</span><span class="p">,</span> +</span><span id="Tokenizer-527"><a href="#Tokenizer-527"><span class="linenos"> 527</span></a> <span class="s2">"CURRENT_USER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CURRENT_USER</span><span class="p">,</span> +</span><span id="Tokenizer-528"><a href="#Tokenizer-528"><span class="linenos"> 528</span></a> <span class="s2">"DATABASE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATABASE</span><span class="p">,</span> +</span><span id="Tokenizer-529"><a href="#Tokenizer-529"><span class="linenos"> 529</span></a> <span class="s2">"DEFAULT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DEFAULT</span><span class="p">,</span> +</span><span id="Tokenizer-530"><a href="#Tokenizer-530"><span class="linenos"> 530</span></a> <span class="s2">"DELETE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DELETE</span><span class="p">,</span> +</span><span id="Tokenizer-531"><a href="#Tokenizer-531"><span class="linenos"> 531</span></a> <span class="s2">"DESC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DESC</span><span class="p">,</span> +</span><span id="Tokenizer-532"><a href="#Tokenizer-532"><span class="linenos"> 532</span></a> <span class="s2">"DESCRIBE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DESCRIBE</span><span class="p">,</span> +</span><span id="Tokenizer-533"><a href="#Tokenizer-533"><span class="linenos"> 533</span></a> <span class="s2">"DISTINCT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DISTINCT</span><span class="p">,</span> +</span><span id="Tokenizer-534"><a href="#Tokenizer-534"><span class="linenos"> 534</span></a> <span class="s2">"DISTRIBUTE BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DISTRIBUTE_BY</span><span class="p">,</span> +</span><span id="Tokenizer-535"><a href="#Tokenizer-535"><span class="linenos"> 535</span></a> <span class="s2">"DIV"</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="Tokenizer-536"><a href="#Tokenizer-536"><span class="linenos"> 536</span></a> <span class="s2">"DROP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DROP</span><span class="p">,</span> +</span><span id="Tokenizer-537"><a href="#Tokenizer-537"><span class="linenos"> 537</span></a> <span class="s2">"ELSE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ELSE</span><span class="p">,</span> +</span><span id="Tokenizer-538"><a href="#Tokenizer-538"><span class="linenos"> 538</span></a> <span class="s2">"END"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">END</span><span class="p">,</span> +</span><span id="Tokenizer-539"><a href="#Tokenizer-539"><span class="linenos"> 539</span></a> <span class="s2">"ESCAPE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ESCAPE</span><span class="p">,</span> +</span><span id="Tokenizer-540"><a href="#Tokenizer-540"><span class="linenos"> 540</span></a> <span class="s2">"EXCEPT"</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="Tokenizer-541"><a href="#Tokenizer-541"><span class="linenos"> 541</span></a> <span class="s2">"EXECUTE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXECUTE</span><span class="p">,</span> +</span><span id="Tokenizer-542"><a href="#Tokenizer-542"><span class="linenos"> 542</span></a> <span class="s2">"EXISTS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXISTS</span><span class="p">,</span> +</span><span id="Tokenizer-543"><a href="#Tokenizer-543"><span class="linenos"> 543</span></a> <span class="s2">"FALSE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FALSE</span><span class="p">,</span> +</span><span id="Tokenizer-544"><a href="#Tokenizer-544"><span class="linenos"> 544</span></a> <span class="s2">"FETCH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FETCH</span><span class="p">,</span> +</span><span id="Tokenizer-545"><a href="#Tokenizer-545"><span class="linenos"> 545</span></a> <span class="s2">"FILTER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FILTER</span><span class="p">,</span> +</span><span id="Tokenizer-546"><a href="#Tokenizer-546"><span class="linenos"> 546</span></a> <span class="s2">"FIRST"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FIRST</span><span class="p">,</span> +</span><span id="Tokenizer-547"><a href="#Tokenizer-547"><span class="linenos"> 547</span></a> <span class="s2">"FULL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FULL</span><span class="p">,</span> +</span><span id="Tokenizer-548"><a href="#Tokenizer-548"><span class="linenos"> 548</span></a> <span class="s2">"FUNCTION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FUNCTION</span><span class="p">,</span> +</span><span id="Tokenizer-549"><a href="#Tokenizer-549"><span class="linenos"> 549</span></a> <span class="s2">"FOR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FOR</span><span class="p">,</span> +</span><span id="Tokenizer-550"><a href="#Tokenizer-550"><span class="linenos"> 550</span></a> <span class="s2">"FOREIGN KEY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FOREIGN_KEY</span><span class="p">,</span> +</span><span id="Tokenizer-551"><a href="#Tokenizer-551"><span class="linenos"> 551</span></a> <span class="s2">"FORMAT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FORMAT</span><span class="p">,</span> +</span><span id="Tokenizer-552"><a href="#Tokenizer-552"><span class="linenos"> 552</span></a> <span class="s2">"FROM"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FROM</span><span class="p">,</span> +</span><span id="Tokenizer-553"><a href="#Tokenizer-553"><span class="linenos"> 553</span></a> <span class="s2">"GEOGRAPHY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GEOGRAPHY</span><span class="p">,</span> +</span><span id="Tokenizer-554"><a href="#Tokenizer-554"><span class="linenos"> 554</span></a> <span class="s2">"GEOMETRY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GEOMETRY</span><span class="p">,</span> +</span><span id="Tokenizer-555"><a href="#Tokenizer-555"><span class="linenos"> 555</span></a> <span class="s2">"GLOB"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GLOB</span><span class="p">,</span> +</span><span id="Tokenizer-556"><a href="#Tokenizer-556"><span class="linenos"> 556</span></a> <span class="s2">"GROUP BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GROUP_BY</span><span class="p">,</span> +</span><span id="Tokenizer-557"><a href="#Tokenizer-557"><span class="linenos"> 557</span></a> <span class="s2">"GROUPING SETS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">GROUPING_SETS</span><span class="p">,</span> +</span><span id="Tokenizer-558"><a href="#Tokenizer-558"><span class="linenos"> 558</span></a> <span class="s2">"HAVING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HAVING</span><span class="p">,</span> +</span><span id="Tokenizer-559"><a href="#Tokenizer-559"><span class="linenos"> 559</span></a> <span class="s2">"IF"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IF</span><span class="p">,</span> +</span><span id="Tokenizer-560"><a href="#Tokenizer-560"><span class="linenos"> 560</span></a> <span class="s2">"ILIKE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ILIKE</span><span class="p">,</span> +</span><span id="Tokenizer-561"><a href="#Tokenizer-561"><span class="linenos"> 561</span></a> <span class="s2">"IN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IN</span><span class="p">,</span> +</span><span id="Tokenizer-562"><a href="#Tokenizer-562"><span class="linenos"> 562</span></a> <span class="s2">"INDEX"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INDEX</span><span class="p">,</span> +</span><span id="Tokenizer-563"><a href="#Tokenizer-563"><span class="linenos"> 563</span></a> <span class="s2">"INET"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INET</span><span class="p">,</span> +</span><span id="Tokenizer-564"><a href="#Tokenizer-564"><span class="linenos"> 564</span></a> <span class="s2">"INNER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INNER</span><span class="p">,</span> +</span><span id="Tokenizer-565"><a href="#Tokenizer-565"><span class="linenos"> 565</span></a> <span class="s2">"INSERT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INSERT</span><span class="p">,</span> +</span><span id="Tokenizer-566"><a href="#Tokenizer-566"><span class="linenos"> 566</span></a> <span class="s2">"INTERVAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INTERVAL</span><span class="p">,</span> +</span><span id="Tokenizer-567"><a href="#Tokenizer-567"><span class="linenos"> 567</span></a> <span class="s2">"INTERSECT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INTERSECT</span><span class="p">,</span> +</span><span id="Tokenizer-568"><a href="#Tokenizer-568"><span class="linenos"> 568</span></a> <span class="s2">"INTO"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INTO</span><span class="p">,</span> +</span><span id="Tokenizer-569"><a href="#Tokenizer-569"><span class="linenos"> 569</span></a> <span class="s2">"IS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">IS</span><span class="p">,</span> +</span><span id="Tokenizer-570"><a href="#Tokenizer-570"><span class="linenos"> 570</span></a> <span class="s2">"ISNULL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ISNULL</span><span class="p">,</span> +</span><span id="Tokenizer-571"><a href="#Tokenizer-571"><span class="linenos"> 571</span></a> <span class="s2">"JOIN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">JOIN</span><span class="p">,</span> +</span><span id="Tokenizer-572"><a href="#Tokenizer-572"><span class="linenos"> 572</span></a> <span class="s2">"KEEP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">KEEP</span><span class="p">,</span> +</span><span id="Tokenizer-573"><a href="#Tokenizer-573"><span class="linenos"> 573</span></a> <span class="s2">"LATERAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LATERAL</span><span class="p">,</span> +</span><span id="Tokenizer-574"><a href="#Tokenizer-574"><span class="linenos"> 574</span></a> <span class="s2">"LEFT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LEFT</span><span class="p">,</span> +</span><span id="Tokenizer-575"><a href="#Tokenizer-575"><span class="linenos"> 575</span></a> <span class="s2">"LIKE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIKE</span><span class="p">,</span> +</span><span id="Tokenizer-576"><a href="#Tokenizer-576"><span class="linenos"> 576</span></a> <span class="s2">"LIMIT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LIMIT</span><span class="p">,</span> +</span><span id="Tokenizer-577"><a href="#Tokenizer-577"><span class="linenos"> 577</span></a> <span class="s2">"LOAD"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LOAD</span><span class="p">,</span> +</span><span id="Tokenizer-578"><a href="#Tokenizer-578"><span class="linenos"> 578</span></a> <span class="s2">"LOCK"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">LOCK</span><span class="p">,</span> +</span><span id="Tokenizer-579"><a href="#Tokenizer-579"><span class="linenos"> 579</span></a> <span class="s2">"MERGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MERGE</span><span class="p">,</span> +</span><span id="Tokenizer-580"><a href="#Tokenizer-580"><span class="linenos"> 580</span></a> <span class="s2">"NATURAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NATURAL</span><span class="p">,</span> +</span><span id="Tokenizer-581"><a href="#Tokenizer-581"><span class="linenos"> 581</span></a> <span class="s2">"NEXT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEXT</span><span class="p">,</span> +</span><span id="Tokenizer-582"><a href="#Tokenizer-582"><span class="linenos"> 582</span></a> <span class="s2">"NEXT VALUE FOR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NEXT_VALUE_FOR</span><span class="p">,</span> +</span><span id="Tokenizer-583"><a href="#Tokenizer-583"><span class="linenos"> 583</span></a> <span class="s2">"NOT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NOT</span><span class="p">,</span> +</span><span id="Tokenizer-584"><a href="#Tokenizer-584"><span class="linenos"> 584</span></a> <span class="s2">"NOTNULL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NOTNULL</span><span class="p">,</span> +</span><span id="Tokenizer-585"><a href="#Tokenizer-585"><span class="linenos"> 585</span></a> <span class="s2">"NULL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULL</span><span class="p">,</span> +</span><span id="Tokenizer-586"><a href="#Tokenizer-586"><span class="linenos"> 586</span></a> <span class="s2">"OBJECT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OBJECT</span><span class="p">,</span> +</span><span id="Tokenizer-587"><a href="#Tokenizer-587"><span class="linenos"> 587</span></a> <span class="s2">"OFFSET"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OFFSET</span><span class="p">,</span> +</span><span id="Tokenizer-588"><a href="#Tokenizer-588"><span class="linenos"> 588</span></a> <span class="s2">"ON"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ON</span><span class="p">,</span> +</span><span id="Tokenizer-589"><a href="#Tokenizer-589"><span class="linenos"> 589</span></a> <span class="s2">"OR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OR</span><span class="p">,</span> +</span><span id="Tokenizer-590"><a href="#Tokenizer-590"><span class="linenos"> 590</span></a> <span class="s2">"ORDER BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ORDER_BY</span><span class="p">,</span> +</span><span id="Tokenizer-591"><a href="#Tokenizer-591"><span class="linenos"> 591</span></a> <span class="s2">"ORDINALITY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ORDINALITY</span><span class="p">,</span> +</span><span id="Tokenizer-592"><a href="#Tokenizer-592"><span class="linenos"> 592</span></a> <span class="s2">"OUTER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OUTER</span><span class="p">,</span> +</span><span id="Tokenizer-593"><a href="#Tokenizer-593"><span class="linenos"> 593</span></a> <span class="s2">"OVER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OVER</span><span class="p">,</span> +</span><span id="Tokenizer-594"><a href="#Tokenizer-594"><span class="linenos"> 594</span></a> <span class="s2">"OVERLAPS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OVERLAPS</span><span class="p">,</span> +</span><span id="Tokenizer-595"><a href="#Tokenizer-595"><span class="linenos"> 595</span></a> <span class="s2">"OVERWRITE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">OVERWRITE</span><span class="p">,</span> +</span><span id="Tokenizer-596"><a href="#Tokenizer-596"><span class="linenos"> 596</span></a> <span class="s2">"PARTITION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARTITION</span><span class="p">,</span> +</span><span id="Tokenizer-597"><a href="#Tokenizer-597"><span class="linenos"> 597</span></a> <span class="s2">"PARTITION BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARTITION_BY</span><span class="p">,</span> +</span><span id="Tokenizer-598"><a href="#Tokenizer-598"><span class="linenos"> 598</span></a> <span class="s2">"PARTITIONED BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARTITION_BY</span><span class="p">,</span> +</span><span id="Tokenizer-599"><a href="#Tokenizer-599"><span class="linenos"> 599</span></a> <span class="s2">"PARTITIONED_BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARTITION_BY</span><span class="p">,</span> +</span><span id="Tokenizer-600"><a href="#Tokenizer-600"><span class="linenos"> 600</span></a> <span class="s2">"PERCENT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PERCENT</span><span class="p">,</span> +</span><span id="Tokenizer-601"><a href="#Tokenizer-601"><span class="linenos"> 601</span></a> <span class="s2">"PIVOT"</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="Tokenizer-602"><a href="#Tokenizer-602"><span class="linenos"> 602</span></a> <span class="s2">"PRAGMA"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PRAGMA</span><span class="p">,</span> +</span><span id="Tokenizer-603"><a href="#Tokenizer-603"><span class="linenos"> 603</span></a> <span class="s2">"PRIMARY KEY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PRIMARY_KEY</span><span class="p">,</span> +</span><span id="Tokenizer-604"><a href="#Tokenizer-604"><span class="linenos"> 604</span></a> <span class="s2">"PROCEDURE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PROCEDURE</span><span class="p">,</span> +</span><span id="Tokenizer-605"><a href="#Tokenizer-605"><span class="linenos"> 605</span></a> <span class="s2">"QUALIFY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">QUALIFY</span><span class="p">,</span> +</span><span id="Tokenizer-606"><a href="#Tokenizer-606"><span class="linenos"> 606</span></a> <span class="s2">"RANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RANGE</span><span class="p">,</span> +</span><span id="Tokenizer-607"><a href="#Tokenizer-607"><span class="linenos"> 607</span></a> <span class="s2">"RECURSIVE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RECURSIVE</span><span class="p">,</span> +</span><span id="Tokenizer-608"><a href="#Tokenizer-608"><span class="linenos"> 608</span></a> <span class="s2">"REGEXP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> +</span><span id="Tokenizer-609"><a href="#Tokenizer-609"><span class="linenos"> 609</span></a> <span class="s2">"REPLACE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REPLACE</span><span class="p">,</span> +</span><span id="Tokenizer-610"><a href="#Tokenizer-610"><span class="linenos"> 610</span></a> <span class="s2">"RETURNING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RETURNING</span><span class="p">,</span> +</span><span id="Tokenizer-611"><a href="#Tokenizer-611"><span class="linenos"> 611</span></a> <span class="s2">"REFERENCES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">REFERENCES</span><span class="p">,</span> +</span><span id="Tokenizer-612"><a href="#Tokenizer-612"><span class="linenos"> 612</span></a> <span class="s2">"RIGHT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RIGHT</span><span class="p">,</span> +</span><span id="Tokenizer-613"><a href="#Tokenizer-613"><span class="linenos"> 613</span></a> <span class="s2">"RLIKE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">RLIKE</span><span class="p">,</span> +</span><span id="Tokenizer-614"><a href="#Tokenizer-614"><span class="linenos"> 614</span></a> <span class="s2">"ROLLBACK"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROLLBACK</span><span class="p">,</span> +</span><span id="Tokenizer-615"><a href="#Tokenizer-615"><span class="linenos"> 615</span></a> <span class="s2">"ROLLUP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROLLUP</span><span class="p">,</span> +</span><span id="Tokenizer-616"><a href="#Tokenizer-616"><span class="linenos"> 616</span></a> <span class="s2">"ROW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROW</span><span class="p">,</span> +</span><span id="Tokenizer-617"><a href="#Tokenizer-617"><span class="linenos"> 617</span></a> <span class="s2">"ROWS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ROWS</span><span class="p">,</span> +</span><span id="Tokenizer-618"><a href="#Tokenizer-618"><span class="linenos"> 618</span></a> <span class="s2">"SCHEMA"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SCHEMA</span><span class="p">,</span> +</span><span id="Tokenizer-619"><a href="#Tokenizer-619"><span class="linenos"> 619</span></a> <span class="s2">"SELECT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SELECT</span><span class="p">,</span> +</span><span id="Tokenizer-620"><a href="#Tokenizer-620"><span class="linenos"> 620</span></a> <span class="s2">"SEMI"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SEMI</span><span class="p">,</span> +</span><span id="Tokenizer-621"><a href="#Tokenizer-621"><span class="linenos"> 621</span></a> <span class="s2">"SET"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SET</span><span class="p">,</span> +</span><span id="Tokenizer-622"><a href="#Tokenizer-622"><span class="linenos"> 622</span></a> <span class="s2">"SETTINGS"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SETTINGS</span><span class="p">,</span> +</span><span id="Tokenizer-623"><a href="#Tokenizer-623"><span class="linenos"> 623</span></a> <span class="s2">"SHOW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SHOW</span><span class="p">,</span> +</span><span id="Tokenizer-624"><a href="#Tokenizer-624"><span class="linenos"> 624</span></a> <span class="s2">"SIMILAR TO"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SIMILAR_TO</span><span class="p">,</span> +</span><span id="Tokenizer-625"><a href="#Tokenizer-625"><span class="linenos"> 625</span></a> <span class="s2">"SOME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SOME</span><span class="p">,</span> +</span><span id="Tokenizer-626"><a href="#Tokenizer-626"><span class="linenos"> 626</span></a> <span class="s2">"SORT BY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SORT_BY</span><span class="p">,</span> +</span><span id="Tokenizer-627"><a href="#Tokenizer-627"><span class="linenos"> 627</span></a> <span class="s2">"TABLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE</span><span class="p">,</span> +</span><span id="Tokenizer-628"><a href="#Tokenizer-628"><span class="linenos"> 628</span></a> <span class="s2">"TABLESAMPLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TABLE_SAMPLE</span><span class="p">,</span> +</span><span id="Tokenizer-629"><a href="#Tokenizer-629"><span class="linenos"> 629</span></a> <span class="s2">"TEMP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEMPORARY</span><span class="p">,</span> +</span><span id="Tokenizer-630"><a href="#Tokenizer-630"><span class="linenos"> 630</span></a> <span class="s2">"TEMPORARY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TEMPORARY</span><span class="p">,</span> +</span><span id="Tokenizer-631"><a href="#Tokenizer-631"><span class="linenos"> 631</span></a> <span class="s2">"THEN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">THEN</span><span class="p">,</span> +</span><span id="Tokenizer-632"><a href="#Tokenizer-632"><span class="linenos"> 632</span></a> <span class="s2">"TRUE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TRUE</span><span class="p">,</span> +</span><span id="Tokenizer-633"><a href="#Tokenizer-633"><span class="linenos"> 633</span></a> <span class="s2">"UNION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNION</span><span class="p">,</span> +</span><span id="Tokenizer-634"><a href="#Tokenizer-634"><span class="linenos"> 634</span></a> <span class="s2">"UNNEST"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNNEST</span><span class="p">,</span> +</span><span id="Tokenizer-635"><a href="#Tokenizer-635"><span class="linenos"> 635</span></a> <span class="s2">"UNPIVOT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNPIVOT</span><span class="p">,</span> +</span><span id="Tokenizer-636"><a href="#Tokenizer-636"><span class="linenos"> 636</span></a> <span class="s2">"UPDATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UPDATE</span><span class="p">,</span> +</span><span id="Tokenizer-637"><a href="#Tokenizer-637"><span class="linenos"> 637</span></a> <span class="s2">"USE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">USE</span><span class="p">,</span> +</span><span id="Tokenizer-638"><a href="#Tokenizer-638"><span class="linenos"> 638</span></a> <span class="s2">"USING"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">USING</span><span class="p">,</span> +</span><span id="Tokenizer-639"><a href="#Tokenizer-639"><span class="linenos"> 639</span></a> <span class="s2">"UUID"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UUID</span><span class="p">,</span> +</span><span id="Tokenizer-640"><a href="#Tokenizer-640"><span class="linenos"> 640</span></a> <span class="s2">"VALUES"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VALUES</span><span class="p">,</span> +</span><span id="Tokenizer-641"><a href="#Tokenizer-641"><span class="linenos"> 641</span></a> <span class="s2">"VIEW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VIEW</span><span class="p">,</span> +</span><span id="Tokenizer-642"><a href="#Tokenizer-642"><span class="linenos"> 642</span></a> <span class="s2">"VOLATILE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VOLATILE</span><span class="p">,</span> +</span><span id="Tokenizer-643"><a href="#Tokenizer-643"><span class="linenos"> 643</span></a> <span class="s2">"WHEN"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WHEN</span><span class="p">,</span> +</span><span id="Tokenizer-644"><a href="#Tokenizer-644"><span class="linenos"> 644</span></a> <span class="s2">"WHERE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WHERE</span><span class="p">,</span> +</span><span id="Tokenizer-645"><a href="#Tokenizer-645"><span class="linenos"> 645</span></a> <span class="s2">"WINDOW"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WINDOW</span><span class="p">,</span> +</span><span id="Tokenizer-646"><a href="#Tokenizer-646"><span class="linenos"> 646</span></a> <span class="s2">"WITH"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">WITH</span><span class="p">,</span> +</span><span id="Tokenizer-647"><a href="#Tokenizer-647"><span class="linenos"> 647</span></a> <span class="s2">"APPLY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">APPLY</span><span class="p">,</span> +</span><span id="Tokenizer-648"><a href="#Tokenizer-648"><span class="linenos"> 648</span></a> <span class="s2">"ARRAY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ARRAY</span><span class="p">,</span> +</span><span id="Tokenizer-649"><a href="#Tokenizer-649"><span class="linenos"> 649</span></a> <span class="s2">"BIT"</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="Tokenizer-650"><a href="#Tokenizer-650"><span class="linenos"> 650</span></a> <span class="s2">"BOOL"</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="Tokenizer-651"><a href="#Tokenizer-651"><span class="linenos"> 651</span></a> <span class="s2">"BOOLEAN"</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="Tokenizer-652"><a href="#Tokenizer-652"><span class="linenos"> 652</span></a> <span class="s2">"BYTE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">,</span> +</span><span id="Tokenizer-653"><a href="#Tokenizer-653"><span class="linenos"> 653</span></a> <span class="s2">"TINYINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TINYINT</span><span class="p">,</span> +</span><span id="Tokenizer-654"><a href="#Tokenizer-654"><span class="linenos"> 654</span></a> <span class="s2">"SHORT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> +</span><span id="Tokenizer-655"><a href="#Tokenizer-655"><span class="linenos"> 655</span></a> <span class="s2">"SMALLINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> +</span><span id="Tokenizer-656"><a href="#Tokenizer-656"><span class="linenos"> 656</span></a> <span class="s2">"INT2"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SMALLINT</span><span class="p">,</span> +</span><span id="Tokenizer-657"><a href="#Tokenizer-657"><span class="linenos"> 657</span></a> <span class="s2">"INTEGER"</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="Tokenizer-658"><a href="#Tokenizer-658"><span class="linenos"> 658</span></a> <span class="s2">"INT"</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="Tokenizer-659"><a href="#Tokenizer-659"><span class="linenos"> 659</span></a> <span class="s2">"INT4"</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="Tokenizer-660"><a href="#Tokenizer-660"><span class="linenos"> 660</span></a> <span class="s2">"LONG"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> +</span><span id="Tokenizer-661"><a href="#Tokenizer-661"><span class="linenos"> 661</span></a> <span class="s2">"BIGINT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> +</span><span id="Tokenizer-662"><a href="#Tokenizer-662"><span class="linenos"> 662</span></a> <span class="s2">"INT8"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGINT</span><span class="p">,</span> +</span><span id="Tokenizer-663"><a href="#Tokenizer-663"><span class="linenos"> 663</span></a> <span class="s2">"DEC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> +</span><span id="Tokenizer-664"><a href="#Tokenizer-664"><span class="linenos"> 664</span></a> <span class="s2">"DECIMAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> +</span><span id="Tokenizer-665"><a href="#Tokenizer-665"><span class="linenos"> 665</span></a> <span class="s2">"BIGDECIMAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGDECIMAL</span><span class="p">,</span> +</span><span id="Tokenizer-666"><a href="#Tokenizer-666"><span class="linenos"> 666</span></a> <span class="s2">"BIGNUMERIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIGDECIMAL</span><span class="p">,</span> +</span><span id="Tokenizer-667"><a href="#Tokenizer-667"><span class="linenos"> 667</span></a> <span class="s2">"MAP"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">MAP</span><span class="p">,</span> +</span><span id="Tokenizer-668"><a href="#Tokenizer-668"><span class="linenos"> 668</span></a> <span class="s2">"NULLABLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NULLABLE</span><span class="p">,</span> +</span><span id="Tokenizer-669"><a href="#Tokenizer-669"><span class="linenos"> 669</span></a> <span class="s2">"NUMBER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> +</span><span id="Tokenizer-670"><a href="#Tokenizer-670"><span class="linenos"> 670</span></a> <span class="s2">"NUMERIC"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> +</span><span id="Tokenizer-671"><a href="#Tokenizer-671"><span class="linenos"> 671</span></a> <span class="s2">"FIXED"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DECIMAL</span><span class="p">,</span> +</span><span id="Tokenizer-672"><a href="#Tokenizer-672"><span class="linenos"> 672</span></a> <span class="s2">"REAL"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span> +</span><span id="Tokenizer-673"><a href="#Tokenizer-673"><span class="linenos"> 673</span></a> <span class="s2">"FLOAT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span> +</span><span id="Tokenizer-674"><a href="#Tokenizer-674"><span class="linenos"> 674</span></a> <span class="s2">"FLOAT4"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span> +</span><span id="Tokenizer-675"><a href="#Tokenizer-675"><span class="linenos"> 675</span></a> <span class="s2">"FLOAT8"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> +</span><span id="Tokenizer-676"><a href="#Tokenizer-676"><span class="linenos"> 676</span></a> <span class="s2">"DOUBLE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> +</span><span id="Tokenizer-677"><a href="#Tokenizer-677"><span class="linenos"> 677</span></a> <span class="s2">"DOUBLE PRECISION"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> +</span><span id="Tokenizer-678"><a href="#Tokenizer-678"><span class="linenos"> 678</span></a> <span class="s2">"JSON"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">JSON</span><span class="p">,</span> +</span><span id="Tokenizer-679"><a href="#Tokenizer-679"><span class="linenos"> 679</span></a> <span class="s2">"CHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span> +</span><span id="Tokenizer-680"><a href="#Tokenizer-680"><span class="linenos"> 680</span></a> <span class="s2">"CHARACTER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span> +</span><span id="Tokenizer-681"><a href="#Tokenizer-681"><span class="linenos"> 681</span></a> <span class="s2">"NCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NCHAR</span><span class="p">,</span> +</span><span id="Tokenizer-682"><a href="#Tokenizer-682"><span class="linenos"> 682</span></a> <span class="s2">"VARCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> +</span><span id="Tokenizer-683"><a href="#Tokenizer-683"><span class="linenos"> 683</span></a> <span class="s2">"VARCHAR2"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARCHAR</span><span class="p">,</span> +</span><span id="Tokenizer-684"><a href="#Tokenizer-684"><span class="linenos"> 684</span></a> <span class="s2">"NVARCHAR"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">,</span> +</span><span id="Tokenizer-685"><a href="#Tokenizer-685"><span class="linenos"> 685</span></a> <span class="s2">"NVARCHAR2"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NVARCHAR</span><span class="p">,</span> +</span><span id="Tokenizer-686"><a href="#Tokenizer-686"><span class="linenos"> 686</span></a> <span class="s2">"STR"</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="Tokenizer-687"><a href="#Tokenizer-687"><span class="linenos"> 687</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="Tokenizer-688"><a href="#Tokenizer-688"><span class="linenos"> 688</span></a> <span class="s2">"TEXT"</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="Tokenizer-689"><a href="#Tokenizer-689"><span class="linenos"> 689</span></a> <span class="s2">"CLOB"</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="Tokenizer-690"><a href="#Tokenizer-690"><span class="linenos"> 690</span></a> <span class="s2">"LONGVARCHAR"</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="Tokenizer-691"><a href="#Tokenizer-691"><span class="linenos"> 691</span></a> <span class="s2">"BINARY"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BINARY</span><span class="p">,</span> +</span><span id="Tokenizer-692"><a href="#Tokenizer-692"><span class="linenos"> 692</span></a> <span class="s2">"BLOB"</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="Tokenizer-693"><a href="#Tokenizer-693"><span class="linenos"> 693</span></a> <span class="s2">"BYTEA"</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="Tokenizer-694"><a href="#Tokenizer-694"><span class="linenos"> 694</span></a> <span class="s2">"VARBINARY"</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="Tokenizer-695"><a href="#Tokenizer-695"><span class="linenos"> 695</span></a> <span class="s2">"TIME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIME</span><span class="p">,</span> +</span><span id="Tokenizer-696"><a href="#Tokenizer-696"><span class="linenos"> 696</span></a> <span class="s2">"TIMESTAMP"</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="Tokenizer-697"><a href="#Tokenizer-697"><span class="linenos"> 697</span></a> <span class="s2">"TIMESTAMPTZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPTZ</span><span class="p">,</span> +</span><span id="Tokenizer-698"><a href="#Tokenizer-698"><span class="linenos"> 698</span></a> <span class="s2">"TIMESTAMPLTZ"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TIMESTAMPLTZ</span><span class="p">,</span> +</span><span id="Tokenizer-699"><a href="#Tokenizer-699"><span class="linenos"> 699</span></a> <span class="s2">"DATE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATE</span><span class="p">,</span> +</span><span id="Tokenizer-700"><a href="#Tokenizer-700"><span class="linenos"> 700</span></a> <span class="s2">"DATETIME"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATETIME</span><span class="p">,</span> +</span><span id="Tokenizer-701"><a href="#Tokenizer-701"><span class="linenos"> 701</span></a> <span class="s2">"INT4RANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT4RANGE</span><span class="p">,</span> +</span><span id="Tokenizer-702"><a href="#Tokenizer-702"><span class="linenos"> 702</span></a> <span class="s2">"INT4MULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT4MULTIRANGE</span><span class="p">,</span> +</span><span id="Tokenizer-703"><a href="#Tokenizer-703"><span class="linenos"> 703</span></a> <span class="s2">"INT8RANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT8RANGE</span><span class="p">,</span> +</span><span id="Tokenizer-704"><a href="#Tokenizer-704"><span class="linenos"> 704</span></a> <span class="s2">"INT8MULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">INT8MULTIRANGE</span><span class="p">,</span> +</span><span id="Tokenizer-705"><a href="#Tokenizer-705"><span class="linenos"> 705</span></a> <span class="s2">"NUMRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NUMRANGE</span><span class="p">,</span> +</span><span id="Tokenizer-706"><a href="#Tokenizer-706"><span class="linenos"> 706</span></a> <span class="s2">"NUMMULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">NUMMULTIRANGE</span><span class="p">,</span> +</span><span id="Tokenizer-707"><a href="#Tokenizer-707"><span class="linenos"> 707</span></a> <span class="s2">"TSRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TSRANGE</span><span class="p">,</span> +</span><span id="Tokenizer-708"><a href="#Tokenizer-708"><span class="linenos"> 708</span></a> <span class="s2">"TSMULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TSMULTIRANGE</span><span class="p">,</span> +</span><span id="Tokenizer-709"><a href="#Tokenizer-709"><span class="linenos"> 709</span></a> <span class="s2">"TSTZRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TSTZRANGE</span><span class="p">,</span> +</span><span id="Tokenizer-710"><a href="#Tokenizer-710"><span class="linenos"> 710</span></a> <span class="s2">"TSTZMULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">TSTZMULTIRANGE</span><span class="p">,</span> +</span><span id="Tokenizer-711"><a href="#Tokenizer-711"><span class="linenos"> 711</span></a> <span class="s2">"DATERANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATERANGE</span><span class="p">,</span> +</span><span id="Tokenizer-712"><a href="#Tokenizer-712"><span class="linenos"> 712</span></a> <span class="s2">"DATEMULTIRANGE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">DATEMULTIRANGE</span><span class="p">,</span> +</span><span id="Tokenizer-713"><a href="#Tokenizer-713"><span class="linenos"> 713</span></a> <span class="s2">"UNIQUE"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">UNIQUE</span><span class="p">,</span> +</span><span id="Tokenizer-714"><a href="#Tokenizer-714"><span class="linenos"> 714</span></a> <span class="s2">"STRUCT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRUCT</span><span class="p">,</span> +</span><span id="Tokenizer-715"><a href="#Tokenizer-715"><span class="linenos"> 715</span></a> <span class="s2">"VARIANT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VARIANT</span><span class="p">,</span> +</span><span id="Tokenizer-716"><a href="#Tokenizer-716"><span class="linenos"> 716</span></a> <span class="s2">"ALTER"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">ALTER</span><span class="p">,</span> +</span><span id="Tokenizer-717"><a href="#Tokenizer-717"><span class="linenos"> 717</span></a> <span class="s2">"ANALYZE"</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="Tokenizer-718"><a href="#Tokenizer-718"><span class="linenos"> 718</span></a> <span class="s2">"CALL"</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="Tokenizer-719"><a href="#Tokenizer-719"><span class="linenos"> 719</span></a> <span class="s2">"COMMENT"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMENT</span><span class="p">,</span> +</span><span id="Tokenizer-720"><a href="#Tokenizer-720"><span class="linenos"> 720</span></a> <span class="s2">"COPY"</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="Tokenizer-721"><a href="#Tokenizer-721"><span class="linenos"> 721</span></a> <span class="s2">"EXPLAIN"</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="Tokenizer-722"><a href="#Tokenizer-722"><span class="linenos"> 722</span></a> <span class="s2">"GRANT"</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="Tokenizer-723"><a href="#Tokenizer-723"><span class="linenos"> 723</span></a> <span class="s2">"OPTIMIZE"</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="Tokenizer-724"><a href="#Tokenizer-724"><span class="linenos"> 724</span></a> <span class="s2">"PREPARE"</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="Tokenizer-725"><a href="#Tokenizer-725"><span class="linenos"> 725</span></a> <span class="s2">"TRUNCATE"</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="Tokenizer-726"><a href="#Tokenizer-726"><span class="linenos"> 726</span></a> <span class="s2">"VACUUM"</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="Tokenizer-727"><a href="#Tokenizer-727"><span class="linenos"> 727</span></a> <span class="p">}</span> +</span><span id="Tokenizer-728"><a href="#Tokenizer-728"><span class="linenos"> 728</span></a> +</span><span id="Tokenizer-729"><a href="#Tokenizer-729"><span class="linenos"> 729</span></a> <span class="n">WHITE_SPACE</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="n">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="n">TokenType</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Tokenizer-730"><a href="#Tokenizer-730"><span class="linenos"> 730</span></a> <span class="s2">" "</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SPACE</span><span class="p">,</span> +</span><span id="Tokenizer-731"><a href="#Tokenizer-731"><span class="linenos"> 731</span></a> <span class="s2">"</span><span class="se">\t</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">SPACE</span><span class="p">,</span> +</span><span id="Tokenizer-732"><a href="#Tokenizer-732"><span class="linenos"> 732</span></a> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">,</span> +</span><span id="Tokenizer-733"><a href="#Tokenizer-733"><span class="linenos"> 733</span></a> <span class="s2">"</span><span class="se">\r</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">,</span> +</span><span id="Tokenizer-734"><a href="#Tokenizer-734"><span class="linenos"> 734</span></a> <span class="s2">"</span><span class="se">\r\n</span><span class="s2">"</span><span class="p">:</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">,</span> +</span><span id="Tokenizer-735"><a href="#Tokenizer-735"><span class="linenos"> 735</span></a> <span class="p">}</span> +</span><span id="Tokenizer-736"><a href="#Tokenizer-736"><span class="linenos"> 736</span></a> +</span><span id="Tokenizer-737"><a href="#Tokenizer-737"><span class="linenos"> 737</span></a> <span class="n">COMMANDS</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="Tokenizer-738"><a href="#Tokenizer-738"><span class="linenos"> 738</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">COMMAND</span><span class="p">,</span> +</span><span id="Tokenizer-739"><a href="#Tokenizer-739"><span class="linenos"> 739</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">EXECUTE</span><span class="p">,</span> +</span><span id="Tokenizer-740"><a href="#Tokenizer-740"><span class="linenos"> 740</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">FETCH</span><span class="p">,</span> +</span><span id="Tokenizer-741"><a href="#Tokenizer-741"><span class="linenos"> 741</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">SHOW</span><span class="p">,</span> +</span><span id="Tokenizer-742"><a href="#Tokenizer-742"><span class="linenos"> 742</span></a> <span class="p">}</span> </span><span id="Tokenizer-743"><a href="#Tokenizer-743"><span class="linenos"> 743</span></a> -</span><span id="Tokenizer-744"><a href="#Tokenizer-744"><span class="linenos"> 744</span></a> <span class="n">COMMENTS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--"</span><span class="p">,</span> <span class="p">(</span><span class="s2">"/*"</span><span class="p">,</span> <span class="s2">"*/"</span><span class="p">)]</span> +</span><span id="Tokenizer-744"><a href="#Tokenizer-744"><span class="linenos"> 744</span></a> <span class="n">COMMAND_PREFIX_TOKENS</span> <span class="o">=</span> <span class="p">{</span><span class="n">TokenType</span><span class="o">.</span><span class="n">SEMICOLON</span><span class="p">,</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BEGIN</span><span class="p">}</span> </span><span id="Tokenizer-745"><a href="#Tokenizer-745"><span class="linenos"> 745</span></a> -</span><span id="Tokenizer-746"><a href="#Tokenizer-746"><span class="linenos"> 746</span></a> <span class="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Tokenizer-747"><a href="#Tokenizer-747"><span class="linenos"> 747</span></a> <span class="s2">"sql"</span><span class="p">,</span> -</span><span id="Tokenizer-748"><a href="#Tokenizer-748"><span class="linenos"> 748</span></a> <span class="s2">"size"</span><span class="p">,</span> -</span><span id="Tokenizer-749"><a href="#Tokenizer-749"><span class="linenos"> 749</span></a> <span class="s2">"tokens"</span><span class="p">,</span> -</span><span id="Tokenizer-750"><a href="#Tokenizer-750"><span class="linenos"> 750</span></a> <span class="s2">"_start"</span><span class="p">,</span> -</span><span id="Tokenizer-751"><a href="#Tokenizer-751"><span class="linenos"> 751</span></a> <span class="s2">"_current"</span><span class="p">,</span> -</span><span id="Tokenizer-752"><a href="#Tokenizer-752"><span class="linenos"> 752</span></a> <span class="s2">"_line"</span><span class="p">,</span> -</span><span id="Tokenizer-753"><a href="#Tokenizer-753"><span class="linenos"> 753</span></a> <span class="s2">"_col"</span><span class="p">,</span> -</span><span id="Tokenizer-754"><a href="#Tokenizer-754"><span class="linenos"> 754</span></a> <span class="s2">"_comments"</span><span class="p">,</span> -</span><span id="Tokenizer-755"><a href="#Tokenizer-755"><span class="linenos"> 755</span></a> <span class="s2">"_char"</span><span class="p">,</span> -</span><span id="Tokenizer-756"><a href="#Tokenizer-756"><span class="linenos"> 756</span></a> <span class="s2">"_end"</span><span class="p">,</span> -</span><span id="Tokenizer-757"><a href="#Tokenizer-757"><span class="linenos"> 757</span></a> <span class="s2">"_peek"</span><span class="p">,</span> -</span><span id="Tokenizer-758"><a href="#Tokenizer-758"><span class="linenos"> 758</span></a> <span class="s2">"_prev_token_line"</span><span class="p">,</span> -</span><span id="Tokenizer-759"><a href="#Tokenizer-759"><span class="linenos"> 759</span></a> <span class="p">)</span> -</span><span id="Tokenizer-760"><a href="#Tokenizer-760"><span class="linenos"> 760</span></a> -</span><span id="Tokenizer-761"><a href="#Tokenizer-761"><span class="linenos"> 761</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Tokenizer-762"><a href="#Tokenizer-762"><span class="linenos"> 762</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> -</span><span id="Tokenizer-763"><a href="#Tokenizer-763"><span class="linenos"> 763</span></a> -</span><span id="Tokenizer-764"><a href="#Tokenizer-764"><span class="linenos"> 764</span></a> <span class="k">def</span> <span class="nf">reset</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Tokenizer-765"><a href="#Tokenizer-765"><span class="linenos"> 765</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Tokenizer-766"><a href="#Tokenizer-766"><span class="linenos"> 766</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="Tokenizer-767"><a href="#Tokenizer-767"><span class="linenos"> 767</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</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">Token</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Tokenizer-768"><a href="#Tokenizer-768"><span class="linenos"> 768</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_start</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="Tokenizer-769"><a href="#Tokenizer-769"><span class="linenos"> 769</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="Tokenizer-770"><a href="#Tokenizer-770"><span class="linenos"> 770</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> <span class="o">=</span> <span class="mi">1</span> -</span><span id="Tokenizer-771"><a href="#Tokenizer-771"><span class="linenos"> 771</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="Tokenizer-772"><a href="#Tokenizer-772"><span class="linenos"> 772</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Tokenizer-773"><a href="#Tokenizer-773"><span class="linenos"> 773</span></a> -</span><span id="Tokenizer-774"><a href="#Tokenizer-774"><span class="linenos"> 774</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Tokenizer-775"><a href="#Tokenizer-775"><span class="linenos"> 775</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Tokenizer-776"><a href="#Tokenizer-776"><span class="linenos"> 776</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Tokenizer-777"><a href="#Tokenizer-777"><span class="linenos"> 777</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_token_line</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span> -</span><span id="Tokenizer-778"><a href="#Tokenizer-778"><span class="linenos"> 778</span></a> -</span><span id="Tokenizer-779"><a href="#Tokenizer-779"><span class="linenos"> 779</span></a> <span class="k">def</span> <span class="nf">tokenize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Token</span><span class="p">]:</span> -</span><span id="Tokenizer-780"><a href="#Tokenizer-780"><span class="linenos"> 780</span></a><span class="w"> </span><span class="sd">"""Returns a list of tokens corresponding to the SQL string `sql`."""</span> -</span><span id="Tokenizer-781"><a href="#Tokenizer-781"><span class="linenos"> 781</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> -</span><span id="Tokenizer-782"><a href="#Tokenizer-782"><span class="linenos"> 782</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span> -</span><span id="Tokenizer-783"><a href="#Tokenizer-783"><span class="linenos"> 783</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">sql</span><span class="p">)</span> +</span><span id="Tokenizer-746"><a href="#Tokenizer-746"><span class="linenos"> 746</span></a> <span class="c1"># handle numeric literals like in hive (3L = BIGINT)</span> +</span><span id="Tokenizer-747"><a href="#Tokenizer-747"><span class="linenos"> 747</span></a> <span class="n">NUMERIC_LITERALS</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span> +</span><span id="Tokenizer-748"><a href="#Tokenizer-748"><span class="linenos"> 748</span></a> <span class="n">ENCODE</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><span id="Tokenizer-749"><a href="#Tokenizer-749"><span class="linenos"> 749</span></a> +</span><span id="Tokenizer-750"><a href="#Tokenizer-750"><span class="linenos"> 750</span></a> <span class="n">COMMENTS</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--"</span><span class="p">,</span> <span class="p">(</span><span class="s2">"/*"</span><span class="p">,</span> <span class="s2">"*/"</span><span class="p">)]</span> +</span><span id="Tokenizer-751"><a href="#Tokenizer-751"><span class="linenos"> 751</span></a> +</span><span id="Tokenizer-752"><a href="#Tokenizer-752"><span class="linenos"> 752</span></a> <span class="vm">__slots__</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Tokenizer-753"><a href="#Tokenizer-753"><span class="linenos"> 753</span></a> <span class="s2">"sql"</span><span class="p">,</span> +</span><span id="Tokenizer-754"><a href="#Tokenizer-754"><span class="linenos"> 754</span></a> <span class="s2">"size"</span><span class="p">,</span> +</span><span id="Tokenizer-755"><a href="#Tokenizer-755"><span class="linenos"> 755</span></a> <span class="s2">"tokens"</span><span class="p">,</span> +</span><span id="Tokenizer-756"><a href="#Tokenizer-756"><span class="linenos"> 756</span></a> <span class="s2">"_start"</span><span class="p">,</span> +</span><span id="Tokenizer-757"><a href="#Tokenizer-757"><span class="linenos"> 757</span></a> <span class="s2">"_current"</span><span class="p">,</span> +</span><span id="Tokenizer-758"><a href="#Tokenizer-758"><span class="linenos"> 758</span></a> <span class="s2">"_line"</span><span class="p">,</span> +</span><span id="Tokenizer-759"><a href="#Tokenizer-759"><span class="linenos"> 759</span></a> <span class="s2">"_col"</span><span class="p">,</span> +</span><span id="Tokenizer-760"><a href="#Tokenizer-760"><span class="linenos"> 760</span></a> <span class="s2">"_comments"</span><span class="p">,</span> +</span><span id="Tokenizer-761"><a href="#Tokenizer-761"><span class="linenos"> 761</span></a> <span class="s2">"_char"</span><span class="p">,</span> +</span><span id="Tokenizer-762"><a href="#Tokenizer-762"><span class="linenos"> 762</span></a> <span class="s2">"_end"</span><span class="p">,</span> +</span><span id="Tokenizer-763"><a href="#Tokenizer-763"><span class="linenos"> 763</span></a> <span class="s2">"_peek"</span><span class="p">,</span> +</span><span id="Tokenizer-764"><a href="#Tokenizer-764"><span class="linenos"> 764</span></a> <span class="s2">"_prev_token_line"</span><span class="p">,</span> +</span><span id="Tokenizer-765"><a href="#Tokenizer-765"><span class="linenos"> 765</span></a> <span class="p">)</span> +</span><span id="Tokenizer-766"><a href="#Tokenizer-766"><span class="linenos"> 766</span></a> +</span><span id="Tokenizer-767"><a href="#Tokenizer-767"><span class="linenos"> 767</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Tokenizer-768"><a href="#Tokenizer-768"><span class="linenos"> 768</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> +</span><span id="Tokenizer-769"><a href="#Tokenizer-769"><span class="linenos"> 769</span></a> +</span><span id="Tokenizer-770"><a href="#Tokenizer-770"><span class="linenos"> 770</span></a> <span class="k">def</span> <span class="nf">reset</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Tokenizer-771"><a href="#Tokenizer-771"><span class="linenos"> 771</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Tokenizer-772"><a href="#Tokenizer-772"><span class="linenos"> 772</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="Tokenizer-773"><a href="#Tokenizer-773"><span class="linenos"> 773</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</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">Token</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Tokenizer-774"><a href="#Tokenizer-774"><span class="linenos"> 774</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_start</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="Tokenizer-775"><a href="#Tokenizer-775"><span class="linenos"> 775</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="Tokenizer-776"><a href="#Tokenizer-776"><span class="linenos"> 776</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> <span class="o">=</span> <span class="mi">1</span> +</span><span id="Tokenizer-777"><a href="#Tokenizer-777"><span class="linenos"> 777</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="Tokenizer-778"><a href="#Tokenizer-778"><span class="linenos"> 778</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Tokenizer-779"><a href="#Tokenizer-779"><span class="linenos"> 779</span></a> +</span><span id="Tokenizer-780"><a href="#Tokenizer-780"><span class="linenos"> 780</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Tokenizer-781"><a href="#Tokenizer-781"><span class="linenos"> 781</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Tokenizer-782"><a href="#Tokenizer-782"><span class="linenos"> 782</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Tokenizer-783"><a href="#Tokenizer-783"><span class="linenos"> 783</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_token_line</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span> </span><span id="Tokenizer-784"><a href="#Tokenizer-784"><span class="linenos"> 784</span></a> -</span><span id="Tokenizer-785"><a href="#Tokenizer-785"><span class="linenos"> 785</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="Tokenizer-786"><a href="#Tokenizer-786"><span class="linenos"> 786</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan</span><span class="p">()</span> -</span><span id="Tokenizer-787"><a href="#Tokenizer-787"><span class="linenos"> 787</span></a> <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> -</span><span id="Tokenizer-788"><a href="#Tokenizer-788"><span class="linenos"> 788</span></a> <span class="n">start</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">50</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> -</span><span id="Tokenizer-789"><a href="#Tokenizer-789"><span class="linenos"> 789</span></a> <span class="n">end</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+</span> <span class="mi">50</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="Tokenizer-790"><a href="#Tokenizer-790"><span class="linenos"> 790</span></a> <span class="n">context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">start</span><span class="p">:</span><span class="n">end</span><span class="p">]</span> -</span><span id="Tokenizer-791"><a href="#Tokenizer-791"><span class="linenos"> 791</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Error tokenizing '</span><span class="si">{</span><span class="n">context</span><span class="si">}</span><span class="s2">'"</span><span class="p">)</span> <span class="kn">from</span> <span class="nn">e</span> -</span><span id="Tokenizer-792"><a href="#Tokenizer-792"><span class="linenos"> 792</span></a> -</span><span id="Tokenizer-793"><a href="#Tokenizer-793"><span class="linenos"> 793</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span> -</span><span id="Tokenizer-794"><a href="#Tokenizer-794"><span class="linenos"> 794</span></a> -</span><span id="Tokenizer-795"><a href="#Tokenizer-795"><span class="linenos"> 795</span></a> <span class="k">def</span> <span class="nf">_scan</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">until</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Tokenizer-796"><a href="#Tokenizer-796"><span class="linenos"> 796</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span><span class="p">:</span> -</span><span id="Tokenizer-797"><a href="#Tokenizer-797"><span class="linenos"> 797</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> -</span><span id="Tokenizer-798"><a href="#Tokenizer-798"><span class="linenos"> 798</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Tokenizer-799"><a href="#Tokenizer-799"><span class="linenos"> 799</span></a> -</span><span id="Tokenizer-800"><a href="#Tokenizer-800"><span class="linenos"> 800</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Tokenizer-801"><a href="#Tokenizer-801"><span class="linenos"> 801</span></a> <span class="k">break</span> -</span><span id="Tokenizer-802"><a href="#Tokenizer-802"><span class="linenos"> 802</span></a> -</span><span id="Tokenizer-803"><a href="#Tokenizer-803"><span class="linenos"> 803</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span><span class="p">:</span> -</span><span id="Tokenizer-804"><a href="#Tokenizer-804"><span class="linenos"> 804</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="o">.</span><span class="n">isdigit</span><span class="p">():</span> -</span><span id="Tokenizer-805"><a href="#Tokenizer-805"><span class="linenos"> 805</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_number</span><span class="p">()</span> -</span><span id="Tokenizer-806"><a href="#Tokenizer-806"><span class="linenos"> 806</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_IDENTIFIERS</span><span class="p">:</span> -</span><span id="Tokenizer-807"><a href="#Tokenizer-807"><span class="linenos"> 807</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_identifier</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_IDENTIFIERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="p">])</span> -</span><span id="Tokenizer-808"><a href="#Tokenizer-808"><span class="linenos"> 808</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Tokenizer-809"><a href="#Tokenizer-809"><span class="linenos"> 809</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_keywords</span><span class="p">()</span> -</span><span id="Tokenizer-810"><a href="#Tokenizer-810"><span class="linenos"> 810</span></a> -</span><span id="Tokenizer-811"><a href="#Tokenizer-811"><span class="linenos"> 811</span></a> <span class="k">if</span> <span class="n">until</span> <span class="ow">and</span> <span class="n">until</span><span class="p">():</span> -</span><span id="Tokenizer-812"><a href="#Tokenizer-812"><span class="linenos"> 812</span></a> <span class="k">break</span> -</span><span id="Tokenizer-813"><a href="#Tokenizer-813"><span class="linenos"> 813</span></a> -</span><span id="Tokenizer-814"><a href="#Tokenizer-814"><span class="linenos"> 814</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">:</span> -</span><span id="Tokenizer-815"><a href="#Tokenizer-815"><span class="linenos"> 815</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">comments</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">)</span> +</span><span id="Tokenizer-785"><a href="#Tokenizer-785"><span class="linenos"> 785</span></a> <span class="k">def</span> <span class="nf">tokenize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Token</span><span class="p">]:</span> +</span><span id="Tokenizer-786"><a href="#Tokenizer-786"><span class="linenos"> 786</span></a><span class="w"> </span><span class="sd">"""Returns a list of tokens corresponding to the SQL string `sql`."""</span> +</span><span id="Tokenizer-787"><a href="#Tokenizer-787"><span class="linenos"> 787</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> +</span><span id="Tokenizer-788"><a href="#Tokenizer-788"><span class="linenos"> 788</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span> +</span><span id="Tokenizer-789"><a href="#Tokenizer-789"><span class="linenos"> 789</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">sql</span><span class="p">)</span> +</span><span id="Tokenizer-790"><a href="#Tokenizer-790"><span class="linenos"> 790</span></a> +</span><span id="Tokenizer-791"><a href="#Tokenizer-791"><span class="linenos"> 791</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="Tokenizer-792"><a href="#Tokenizer-792"><span class="linenos"> 792</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan</span><span class="p">()</span> +</span><span id="Tokenizer-793"><a href="#Tokenizer-793"><span class="linenos"> 793</span></a> <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> +</span><span id="Tokenizer-794"><a href="#Tokenizer-794"><span class="linenos"> 794</span></a> <span class="n">start</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">50</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="Tokenizer-795"><a href="#Tokenizer-795"><span class="linenos"> 795</span></a> <span class="n">end</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+</span> <span class="mi">50</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="Tokenizer-796"><a href="#Tokenizer-796"><span class="linenos"> 796</span></a> <span class="n">context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">start</span><span class="p">:</span><span class="n">end</span><span class="p">]</span> +</span><span id="Tokenizer-797"><a href="#Tokenizer-797"><span class="linenos"> 797</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Error tokenizing '</span><span class="si">{</span><span class="n">context</span><span class="si">}</span><span class="s2">'"</span><span class="p">)</span> <span class="kn">from</span> <span class="nn">e</span> +</span><span id="Tokenizer-798"><a href="#Tokenizer-798"><span class="linenos"> 798</span></a> +</span><span id="Tokenizer-799"><a href="#Tokenizer-799"><span class="linenos"> 799</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span> +</span><span id="Tokenizer-800"><a href="#Tokenizer-800"><span class="linenos"> 800</span></a> +</span><span id="Tokenizer-801"><a href="#Tokenizer-801"><span class="linenos"> 801</span></a> <span class="k">def</span> <span class="nf">_scan</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">until</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Tokenizer-802"><a href="#Tokenizer-802"><span class="linenos"> 802</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span><span class="p">:</span> +</span><span id="Tokenizer-803"><a href="#Tokenizer-803"><span class="linenos"> 803</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> +</span><span id="Tokenizer-804"><a href="#Tokenizer-804"><span class="linenos"> 804</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Tokenizer-805"><a href="#Tokenizer-805"><span class="linenos"> 805</span></a> +</span><span id="Tokenizer-806"><a href="#Tokenizer-806"><span class="linenos"> 806</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Tokenizer-807"><a href="#Tokenizer-807"><span class="linenos"> 807</span></a> <span class="k">break</span> +</span><span id="Tokenizer-808"><a href="#Tokenizer-808"><span class="linenos"> 808</span></a> +</span><span id="Tokenizer-809"><a href="#Tokenizer-809"><span class="linenos"> 809</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span><span class="p">:</span> +</span><span id="Tokenizer-810"><a href="#Tokenizer-810"><span class="linenos"> 810</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="o">.</span><span class="n">isdigit</span><span class="p">():</span> +</span><span id="Tokenizer-811"><a href="#Tokenizer-811"><span class="linenos"> 811</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_number</span><span class="p">()</span> +</span><span id="Tokenizer-812"><a href="#Tokenizer-812"><span class="linenos"> 812</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_IDENTIFIERS</span><span class="p">:</span> +</span><span id="Tokenizer-813"><a href="#Tokenizer-813"><span class="linenos"> 813</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_identifier</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_IDENTIFIERS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="p">])</span> +</span><span id="Tokenizer-814"><a href="#Tokenizer-814"><span class="linenos"> 814</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Tokenizer-815"><a href="#Tokenizer-815"><span class="linenos"> 815</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_keywords</span><span class="p">()</span> </span><span id="Tokenizer-816"><a href="#Tokenizer-816"><span class="linenos"> 816</span></a> -</span><span id="Tokenizer-817"><a href="#Tokenizer-817"><span class="linenos"> 817</span></a> <span class="k">def</span> <span class="nf">_chars</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">size</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Tokenizer-818"><a href="#Tokenizer-818"><span class="linenos"> 818</span></a> <span class="k">if</span> <span class="n">size</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Tokenizer-819"><a href="#Tokenizer-819"><span class="linenos"> 819</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> -</span><span id="Tokenizer-820"><a href="#Tokenizer-820"><span class="linenos"> 820</span></a> -</span><span id="Tokenizer-821"><a href="#Tokenizer-821"><span class="linenos"> 821</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span> -</span><span id="Tokenizer-822"><a href="#Tokenizer-822"><span class="linenos"> 822</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">start</span> <span class="o">+</span> <span class="n">size</span> -</span><span id="Tokenizer-823"><a href="#Tokenizer-823"><span class="linenos"> 823</span></a> -</span><span id="Tokenizer-824"><a href="#Tokenizer-824"><span class="linenos"> 824</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">start</span><span class="p">:</span><span class="n">end</span><span class="p">]</span> <span class="k">if</span> <span class="n">end</span> <span class="o"><=</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Tokenizer-825"><a href="#Tokenizer-825"><span class="linenos"> 825</span></a> -</span><span id="Tokenizer-826"><a href="#Tokenizer-826"><span class="linenos"> 826</span></a> <span class="k">def</span> <span class="nf">_advance</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">i</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="n">alnum</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="kc">None</span><span class="p">:</span> -</span><span id="Tokenizer-827"><a href="#Tokenizer-827"><span class="linenos"> 827</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="p">)</span> <span class="ow">is</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">:</span> -</span><span id="Tokenizer-828"><a href="#Tokenizer-828"><span class="linenos"> 828</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> <span class="o">=</span> <span class="mi">1</span> -</span><span id="Tokenizer-829"><a href="#Tokenizer-829"><span class="linenos"> 829</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="Tokenizer-830"><a href="#Tokenizer-830"><span class="linenos"> 830</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Tokenizer-831"><a href="#Tokenizer-831"><span class="linenos"> 831</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> <span class="o">+=</span> <span class="n">i</span> -</span><span id="Tokenizer-832"><a href="#Tokenizer-832"><span class="linenos"> 832</span></a> -</span><span id="Tokenizer-833"><a href="#Tokenizer-833"><span class="linenos"> 833</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+=</span> <span class="n">i</span> -</span><span id="Tokenizer-834"><a href="#Tokenizer-834"><span class="linenos"> 834</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">>=</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> -</span><span id="Tokenizer-835"><a href="#Tokenizer-835"><span class="linenos"> 835</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> -</span><span id="Tokenizer-836"><a href="#Tokenizer-836"><span class="linenos"> 836</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">=</span> <span class="s2">""</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span><span class="p">]</span> -</span><span id="Tokenizer-837"><a href="#Tokenizer-837"><span class="linenos"> 837</span></a> -</span><span id="Tokenizer-838"><a href="#Tokenizer-838"><span class="linenos"> 838</span></a> <span class="k">if</span> <span class="n">alnum</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="o">.</span><span class="n">isalnum</span><span class="p">():</span> -</span><span id="Tokenizer-839"><a href="#Tokenizer-839"><span class="linenos"> 839</span></a> <span class="c1"># Here we use local variables instead of attributes for better performance</span> -</span><span id="Tokenizer-840"><a href="#Tokenizer-840"><span class="linenos"> 840</span></a> <span class="n">_col</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> -</span><span id="Tokenizer-841"><a href="#Tokenizer-841"><span class="linenos"> 841</span></a> <span class="n">_current</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> -</span><span id="Tokenizer-842"><a href="#Tokenizer-842"><span class="linenos"> 842</span></a> <span class="n">_end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> -</span><span id="Tokenizer-843"><a href="#Tokenizer-843"><span class="linenos"> 843</span></a> <span class="n">_peek</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> -</span><span id="Tokenizer-844"><a href="#Tokenizer-844"><span class="linenos"> 844</span></a> -</span><span id="Tokenizer-845"><a href="#Tokenizer-845"><span class="linenos"> 845</span></a> <span class="k">while</span> <span class="n">_peek</span><span class="o">.</span><span class="n">isalnum</span><span class="p">():</span> -</span><span id="Tokenizer-846"><a href="#Tokenizer-846"><span class="linenos"> 846</span></a> <span class="n">_col</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="Tokenizer-847"><a href="#Tokenizer-847"><span class="linenos"> 847</span></a> <span class="n">_current</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="Tokenizer-848"><a href="#Tokenizer-848"><span class="linenos"> 848</span></a> <span class="n">_end</span> <span class="o">=</span> <span class="n">_current</span> <span class="o">>=</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> -</span><span id="Tokenizer-849"><a href="#Tokenizer-849"><span class="linenos"> 849</span></a> <span class="n">_peek</span> <span class="o">=</span> <span class="s2">""</span> <span class="k">if</span> <span class="n">_end</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">_current</span><span class="p">]</span> +</span><span id="Tokenizer-817"><a href="#Tokenizer-817"><span class="linenos"> 817</span></a> <span class="k">if</span> <span class="n">until</span> <span class="ow">and</span> <span class="n">until</span><span class="p">():</span> +</span><span id="Tokenizer-818"><a href="#Tokenizer-818"><span class="linenos"> 818</span></a> <span class="k">break</span> +</span><span id="Tokenizer-819"><a href="#Tokenizer-819"><span class="linenos"> 819</span></a> +</span><span id="Tokenizer-820"><a href="#Tokenizer-820"><span class="linenos"> 820</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">:</span> +</span><span id="Tokenizer-821"><a href="#Tokenizer-821"><span class="linenos"> 821</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">comments</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">)</span> +</span><span id="Tokenizer-822"><a href="#Tokenizer-822"><span class="linenos"> 822</span></a> +</span><span id="Tokenizer-823"><a href="#Tokenizer-823"><span class="linenos"> 823</span></a> <span class="k">def</span> <span class="nf">_chars</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">size</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Tokenizer-824"><a href="#Tokenizer-824"><span class="linenos"> 824</span></a> <span class="k">if</span> <span class="n">size</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Tokenizer-825"><a href="#Tokenizer-825"><span class="linenos"> 825</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> +</span><span id="Tokenizer-826"><a href="#Tokenizer-826"><span class="linenos"> 826</span></a> +</span><span id="Tokenizer-827"><a href="#Tokenizer-827"><span class="linenos"> 827</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span> +</span><span id="Tokenizer-828"><a href="#Tokenizer-828"><span class="linenos"> 828</span></a> <span class="n">end</span> <span class="o">=</span> <span class="n">start</span> <span class="o">+</span> <span class="n">size</span> +</span><span id="Tokenizer-829"><a href="#Tokenizer-829"><span class="linenos"> 829</span></a> +</span><span id="Tokenizer-830"><a href="#Tokenizer-830"><span class="linenos"> 830</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">start</span><span class="p">:</span><span class="n">end</span><span class="p">]</span> <span class="k">if</span> <span class="n">end</span> <span class="o"><=</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Tokenizer-831"><a href="#Tokenizer-831"><span class="linenos"> 831</span></a> +</span><span id="Tokenizer-832"><a href="#Tokenizer-832"><span class="linenos"> 832</span></a> <span class="k">def</span> <span class="nf">_advance</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">i</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="n">alnum</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="kc">None</span><span class="p">:</span> +</span><span id="Tokenizer-833"><a href="#Tokenizer-833"><span class="linenos"> 833</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="p">)</span> <span class="ow">is</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">:</span> +</span><span id="Tokenizer-834"><a href="#Tokenizer-834"><span class="linenos"> 834</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> <span class="o">=</span> <span class="mi">1</span> +</span><span id="Tokenizer-835"><a href="#Tokenizer-835"><span class="linenos"> 835</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="Tokenizer-836"><a href="#Tokenizer-836"><span class="linenos"> 836</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Tokenizer-837"><a href="#Tokenizer-837"><span class="linenos"> 837</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> <span class="o">+=</span> <span class="n">i</span> +</span><span id="Tokenizer-838"><a href="#Tokenizer-838"><span class="linenos"> 838</span></a> +</span><span id="Tokenizer-839"><a href="#Tokenizer-839"><span class="linenos"> 839</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+=</span> <span class="n">i</span> +</span><span id="Tokenizer-840"><a href="#Tokenizer-840"><span class="linenos"> 840</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">>=</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> +</span><span id="Tokenizer-841"><a href="#Tokenizer-841"><span class="linenos"> 841</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> +</span><span id="Tokenizer-842"><a href="#Tokenizer-842"><span class="linenos"> 842</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">=</span> <span class="s2">""</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span><span class="p">]</span> +</span><span id="Tokenizer-843"><a href="#Tokenizer-843"><span class="linenos"> 843</span></a> +</span><span id="Tokenizer-844"><a href="#Tokenizer-844"><span class="linenos"> 844</span></a> <span class="k">if</span> <span class="n">alnum</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="o">.</span><span class="n">isalnum</span><span class="p">():</span> +</span><span id="Tokenizer-845"><a href="#Tokenizer-845"><span class="linenos"> 845</span></a> <span class="c1"># Here we use local variables instead of attributes for better performance</span> +</span><span id="Tokenizer-846"><a href="#Tokenizer-846"><span class="linenos"> 846</span></a> <span class="n">_col</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> +</span><span id="Tokenizer-847"><a href="#Tokenizer-847"><span class="linenos"> 847</span></a> <span class="n">_current</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> +</span><span id="Tokenizer-848"><a href="#Tokenizer-848"><span class="linenos"> 848</span></a> <span class="n">_end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> +</span><span id="Tokenizer-849"><a href="#Tokenizer-849"><span class="linenos"> 849</span></a> <span class="n">_peek</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> </span><span id="Tokenizer-850"><a href="#Tokenizer-850"><span class="linenos"> 850</span></a> -</span><span id="Tokenizer-851"><a href="#Tokenizer-851"><span class="linenos"> 851</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> <span class="o">=</span> <span class="n">_col</span> -</span><span id="Tokenizer-852"><a href="#Tokenizer-852"><span class="linenos"> 852</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">=</span> <span class="n">_current</span> -</span><span id="Tokenizer-853"><a href="#Tokenizer-853"><span class="linenos"> 853</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="o">=</span> <span class="n">_end</span> -</span><span id="Tokenizer-854"><a href="#Tokenizer-854"><span class="linenos"> 854</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">=</span> <span class="n">_peek</span> -</span><span id="Tokenizer-855"><a href="#Tokenizer-855"><span class="linenos"> 855</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> +</span><span id="Tokenizer-851"><a href="#Tokenizer-851"><span class="linenos"> 851</span></a> <span class="k">while</span> <span class="n">_peek</span><span class="o">.</span><span class="n">isalnum</span><span class="p">():</span> +</span><span id="Tokenizer-852"><a href="#Tokenizer-852"><span class="linenos"> 852</span></a> <span class="n">_col</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="Tokenizer-853"><a href="#Tokenizer-853"><span class="linenos"> 853</span></a> <span class="n">_current</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="Tokenizer-854"><a href="#Tokenizer-854"><span class="linenos"> 854</span></a> <span class="n">_end</span> <span class="o">=</span> <span class="n">_current</span> <span class="o">>=</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> +</span><span id="Tokenizer-855"><a href="#Tokenizer-855"><span class="linenos"> 855</span></a> <span class="n">_peek</span> <span class="o">=</span> <span class="s2">""</span> <span class="k">if</span> <span class="n">_end</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">_current</span><span class="p">]</span> </span><span id="Tokenizer-856"><a href="#Tokenizer-856"><span class="linenos"> 856</span></a> -</span><span id="Tokenizer-857"><a href="#Tokenizer-857"><span class="linenos"> 857</span></a> <span class="nd">@property</span> -</span><span id="Tokenizer-858"><a href="#Tokenizer-858"><span class="linenos"> 858</span></a> <span class="k">def</span> <span class="nf">_text</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Tokenizer-859"><a href="#Tokenizer-859"><span class="linenos"> 859</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="bp">self</span><span class="o">.</span><span class="n">_start</span> <span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span><span class="p">]</span> -</span><span id="Tokenizer-860"><a href="#Tokenizer-860"><span class="linenos"> 860</span></a> -</span><span id="Tokenizer-861"><a href="#Tokenizer-861"><span class="linenos"> 861</span></a> <span class="k">def</span> <span class="nf">peek</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">i</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Tokenizer-862"><a href="#Tokenizer-862"><span class="linenos"> 862</span></a> <span class="n">i</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+</span> <span class="n">i</span> -</span><span id="Tokenizer-863"><a href="#Tokenizer-863"><span class="linenos"> 863</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span><span class="p">:</span> -</span><span id="Tokenizer-864"><a href="#Tokenizer-864"><span class="linenos"> 864</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">i</span><span class="p">]</span> -</span><span id="Tokenizer-865"><a href="#Tokenizer-865"><span class="linenos"> 865</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Tokenizer-857"><a href="#Tokenizer-857"><span class="linenos"> 857</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> <span class="o">=</span> <span class="n">_col</span> +</span><span id="Tokenizer-858"><a href="#Tokenizer-858"><span class="linenos"> 858</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">=</span> <span class="n">_current</span> +</span><span id="Tokenizer-859"><a href="#Tokenizer-859"><span class="linenos"> 859</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="o">=</span> <span class="n">_end</span> +</span><span id="Tokenizer-860"><a href="#Tokenizer-860"><span class="linenos"> 860</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">=</span> <span class="n">_peek</span> +</span><span id="Tokenizer-861"><a href="#Tokenizer-861"><span class="linenos"> 861</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> +</span><span id="Tokenizer-862"><a href="#Tokenizer-862"><span class="linenos"> 862</span></a> +</span><span id="Tokenizer-863"><a href="#Tokenizer-863"><span class="linenos"> 863</span></a> <span class="nd">@property</span> +</span><span id="Tokenizer-864"><a href="#Tokenizer-864"><span class="linenos"> 864</span></a> <span class="k">def</span> <span class="nf">_text</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Tokenizer-865"><a href="#Tokenizer-865"><span class="linenos"> 865</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="bp">self</span><span class="o">.</span><span class="n">_start</span> <span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span><span class="p">]</span> </span><span id="Tokenizer-866"><a href="#Tokenizer-866"><span class="linenos"> 866</span></a> -</span><span id="Tokenizer-867"><a href="#Tokenizer-867"><span class="linenos"> 867</span></a> <span class="k">def</span> <span class="nf">_add</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Tokenizer-868"><a href="#Tokenizer-868"><span class="linenos"> 868</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_token_line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> -</span><span id="Tokenizer-869"><a href="#Tokenizer-869"><span class="linenos"> 869</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="Tokenizer-870"><a href="#Tokenizer-870"><span class="linenos"> 870</span></a> <span class="n">Token</span><span class="p">(</span> -</span><span id="Tokenizer-871"><a href="#Tokenizer-871"><span class="linenos"> 871</span></a> <span class="n">token_type</span><span class="p">,</span> -</span><span id="Tokenizer-872"><a href="#Tokenizer-872"><span class="linenos"> 872</span></a> <span class="n">text</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_text</span> <span class="k">if</span> <span class="n">text</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">text</span><span class="p">,</span> -</span><span id="Tokenizer-873"><a href="#Tokenizer-873"><span class="linenos"> 873</span></a> <span class="n">line</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_line</span><span class="p">,</span> -</span><span id="Tokenizer-874"><a href="#Tokenizer-874"><span class="linenos"> 874</span></a> <span class="n">col</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_col</span><span class="p">,</span> -</span><span id="Tokenizer-875"><a href="#Tokenizer-875"><span class="linenos"> 875</span></a> <span class="n">start</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_start</span><span class="p">,</span> -</span><span id="Tokenizer-876"><a href="#Tokenizer-876"><span class="linenos"> 876</span></a> <span class="n">end</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> -</span><span id="Tokenizer-877"><a href="#Tokenizer-877"><span class="linenos"> 877</span></a> <span class="n">comments</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">,</span> -</span><span id="Tokenizer-878"><a href="#Tokenizer-878"><span class="linenos"> 878</span></a> <span class="p">)</span> -</span><span id="Tokenizer-879"><a href="#Tokenizer-879"><span class="linenos"> 879</span></a> <span class="p">)</span> -</span><span id="Tokenizer-880"><a href="#Tokenizer-880"><span class="linenos"> 880</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Tokenizer-881"><a href="#Tokenizer-881"><span class="linenos"> 881</span></a> -</span><span id="Tokenizer-882"><a href="#Tokenizer-882"><span class="linenos"> 882</span></a> <span class="c1"># If we have either a semicolon or a begin token before the command's token, we'll parse</span> -</span><span id="Tokenizer-883"><a href="#Tokenizer-883"><span class="linenos"> 883</span></a> <span class="c1"># whatever follows the command's token as a string</span> -</span><span id="Tokenizer-884"><a href="#Tokenizer-884"><span class="linenos"> 884</span></a> <span class="k">if</span> <span class="p">(</span> -</span><span id="Tokenizer-885"><a href="#Tokenizer-885"><span class="linenos"> 885</span></a> <span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">COMMANDS</span> -</span><span id="Tokenizer-886"><a href="#Tokenizer-886"><span class="linenos"> 886</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">!=</span> <span class="s2">";"</span> -</span><span id="Tokenizer-887"><a href="#Tokenizer-887"><span class="linenos"> 887</span></a> <span class="ow">and</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">COMMAND_PREFIX_TOKENS</span><span class="p">)</span> -</span><span id="Tokenizer-888"><a href="#Tokenizer-888"><span class="linenos"> 888</span></a> <span class="p">):</span> -</span><span id="Tokenizer-889"><a href="#Tokenizer-889"><span class="linenos"> 889</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> -</span><span id="Tokenizer-890"><a href="#Tokenizer-890"><span class="linenos"> 890</span></a> <span class="n">tokens</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">)</span> -</span><span id="Tokenizer-891"><a href="#Tokenizer-891"><span class="linenos"> 891</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">==</span> <span class="s2">";"</span><span class="p">)</span> -</span><span id="Tokenizer-892"><a href="#Tokenizer-892"><span class="linenos"> 892</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[:</span><span class="n">tokens</span><span class="p">]</span> -</span><span id="Tokenizer-893"><a href="#Tokenizer-893"><span class="linenos"> 893</span></a> <span class="n">text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">start</span> <span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="Tokenizer-894"><a href="#Tokenizer-894"><span class="linenos"> 894</span></a> <span class="k">if</span> <span class="n">text</span><span class="p">:</span> -</span><span id="Tokenizer-895"><a href="#Tokenizer-895"><span class="linenos"> 895</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">,</span> <span class="n">text</span><span class="p">)</span> -</span><span id="Tokenizer-896"><a href="#Tokenizer-896"><span class="linenos"> 896</span></a> -</span><span id="Tokenizer-897"><a href="#Tokenizer-897"><span class="linenos"> 897</span></a> <span class="k">def</span> <span class="nf">_scan_keywords</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Tokenizer-898"><a href="#Tokenizer-898"><span class="linenos"> 898</span></a> <span class="n">size</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="Tokenizer-899"><a href="#Tokenizer-899"><span class="linenos"> 899</span></a> <span class="n">word</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Tokenizer-900"><a href="#Tokenizer-900"><span class="linenos"> 900</span></a> <span class="n">chars</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_text</span> -</span><span id="Tokenizer-901"><a href="#Tokenizer-901"><span class="linenos"> 901</span></a> <span class="n">char</span> <span class="o">=</span> <span class="n">chars</span> -</span><span id="Tokenizer-902"><a href="#Tokenizer-902"><span class="linenos"> 902</span></a> <span class="n">prev_space</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Tokenizer-903"><a href="#Tokenizer-903"><span class="linenos"> 903</span></a> <span class="n">skip</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Tokenizer-904"><a href="#Tokenizer-904"><span class="linenos"> 904</span></a> <span class="n">trie</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_KEYWORD_TRIE</span> -</span><span id="Tokenizer-905"><a href="#Tokenizer-905"><span class="linenos"> 905</span></a> <span class="n">single_token</span> <span class="o">=</span> <span class="n">char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span> -</span><span id="Tokenizer-906"><a href="#Tokenizer-906"><span class="linenos"> 906</span></a> -</span><span id="Tokenizer-907"><a href="#Tokenizer-907"><span class="linenos"> 907</span></a> <span class="k">while</span> <span class="n">chars</span><span class="p">:</span> -</span><span id="Tokenizer-908"><a href="#Tokenizer-908"><span class="linenos"> 908</span></a> <span class="k">if</span> <span class="n">skip</span><span class="p">:</span> -</span><span id="Tokenizer-909"><a href="#Tokenizer-909"><span class="linenos"> 909</span></a> <span class="n">result</span> <span class="o">=</span> <span class="mi">1</span> -</span><span id="Tokenizer-910"><a href="#Tokenizer-910"><span class="linenos"> 910</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Tokenizer-911"><a href="#Tokenizer-911"><span class="linenos"> 911</span></a> <span class="n">result</span><span class="p">,</span> <span class="n">trie</span> <span class="o">=</span> <span class="n">in_trie</span><span class="p">(</span><span class="n">trie</span><span class="p">,</span> <span class="n">char</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span> +</span><span id="Tokenizer-867"><a href="#Tokenizer-867"><span class="linenos"> 867</span></a> <span class="k">def</span> <span class="nf">peek</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">i</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Tokenizer-868"><a href="#Tokenizer-868"><span class="linenos"> 868</span></a> <span class="n">i</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+</span> <span class="n">i</span> +</span><span id="Tokenizer-869"><a href="#Tokenizer-869"><span class="linenos"> 869</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span><span class="p">:</span> +</span><span id="Tokenizer-870"><a href="#Tokenizer-870"><span class="linenos"> 870</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">i</span><span class="p">]</span> +</span><span id="Tokenizer-871"><a href="#Tokenizer-871"><span class="linenos"> 871</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Tokenizer-872"><a href="#Tokenizer-872"><span class="linenos"> 872</span></a> +</span><span id="Tokenizer-873"><a href="#Tokenizer-873"><span class="linenos"> 873</span></a> <span class="k">def</span> <span class="nf">_add</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">,</span> <span class="n">text</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Tokenizer-874"><a href="#Tokenizer-874"><span class="linenos"> 874</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_token_line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> +</span><span id="Tokenizer-875"><a href="#Tokenizer-875"><span class="linenos"> 875</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="Tokenizer-876"><a href="#Tokenizer-876"><span class="linenos"> 876</span></a> <span class="n">Token</span><span class="p">(</span> +</span><span id="Tokenizer-877"><a href="#Tokenizer-877"><span class="linenos"> 877</span></a> <span class="n">token_type</span><span class="p">,</span> +</span><span id="Tokenizer-878"><a href="#Tokenizer-878"><span class="linenos"> 878</span></a> <span class="n">text</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_text</span> <span class="k">if</span> <span class="n">text</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">text</span><span class="p">,</span> +</span><span id="Tokenizer-879"><a href="#Tokenizer-879"><span class="linenos"> 879</span></a> <span class="n">line</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_line</span><span class="p">,</span> +</span><span id="Tokenizer-880"><a href="#Tokenizer-880"><span class="linenos"> 880</span></a> <span class="n">col</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_col</span><span class="p">,</span> +</span><span id="Tokenizer-881"><a href="#Tokenizer-881"><span class="linenos"> 881</span></a> <span class="n">start</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_start</span><span class="p">,</span> +</span><span id="Tokenizer-882"><a href="#Tokenizer-882"><span class="linenos"> 882</span></a> <span class="n">end</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> +</span><span id="Tokenizer-883"><a href="#Tokenizer-883"><span class="linenos"> 883</span></a> <span class="n">comments</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">,</span> +</span><span id="Tokenizer-884"><a href="#Tokenizer-884"><span class="linenos"> 884</span></a> <span class="p">)</span> +</span><span id="Tokenizer-885"><a href="#Tokenizer-885"><span class="linenos"> 885</span></a> <span class="p">)</span> +</span><span id="Tokenizer-886"><a href="#Tokenizer-886"><span class="linenos"> 886</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Tokenizer-887"><a href="#Tokenizer-887"><span class="linenos"> 887</span></a> +</span><span id="Tokenizer-888"><a href="#Tokenizer-888"><span class="linenos"> 888</span></a> <span class="c1"># If we have either a semicolon or a begin token before the command's token, we'll parse</span> +</span><span id="Tokenizer-889"><a href="#Tokenizer-889"><span class="linenos"> 889</span></a> <span class="c1"># whatever follows the command's token as a string</span> +</span><span id="Tokenizer-890"><a href="#Tokenizer-890"><span class="linenos"> 890</span></a> <span class="k">if</span> <span class="p">(</span> +</span><span id="Tokenizer-891"><a href="#Tokenizer-891"><span class="linenos"> 891</span></a> <span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">COMMANDS</span> +</span><span id="Tokenizer-892"><a href="#Tokenizer-892"><span class="linenos"> 892</span></a> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">!=</span> <span class="s2">";"</span> +</span><span id="Tokenizer-893"><a href="#Tokenizer-893"><span class="linenos"> 893</span></a> <span class="ow">and</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">token_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">COMMAND_PREFIX_TOKENS</span><span class="p">)</span> +</span><span id="Tokenizer-894"><a href="#Tokenizer-894"><span class="linenos"> 894</span></a> <span class="p">):</span> +</span><span id="Tokenizer-895"><a href="#Tokenizer-895"><span class="linenos"> 895</span></a> <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> +</span><span id="Tokenizer-896"><a href="#Tokenizer-896"><span class="linenos"> 896</span></a> <span class="n">tokens</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">)</span> +</span><span id="Tokenizer-897"><a href="#Tokenizer-897"><span class="linenos"> 897</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan</span><span class="p">(</span><span class="k">lambda</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">==</span> <span class="s2">";"</span><span class="p">)</span> +</span><span id="Tokenizer-898"><a href="#Tokenizer-898"><span class="linenos"> 898</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[:</span><span class="n">tokens</span><span class="p">]</span> +</span><span id="Tokenizer-899"><a href="#Tokenizer-899"><span class="linenos"> 899</span></a> <span class="n">text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">start</span> <span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="Tokenizer-900"><a href="#Tokenizer-900"><span class="linenos"> 900</span></a> <span class="k">if</span> <span class="n">text</span><span class="p">:</span> +</span><span id="Tokenizer-901"><a href="#Tokenizer-901"><span class="linenos"> 901</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span><span class="p">,</span> <span class="n">text</span><span class="p">)</span> +</span><span id="Tokenizer-902"><a href="#Tokenizer-902"><span class="linenos"> 902</span></a> +</span><span id="Tokenizer-903"><a href="#Tokenizer-903"><span class="linenos"> 903</span></a> <span class="k">def</span> <span class="nf">_scan_keywords</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Tokenizer-904"><a href="#Tokenizer-904"><span class="linenos"> 904</span></a> <span class="n">size</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="Tokenizer-905"><a href="#Tokenizer-905"><span class="linenos"> 905</span></a> <span class="n">word</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Tokenizer-906"><a href="#Tokenizer-906"><span class="linenos"> 906</span></a> <span class="n">chars</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_text</span> +</span><span id="Tokenizer-907"><a href="#Tokenizer-907"><span class="linenos"> 907</span></a> <span class="n">char</span> <span class="o">=</span> <span class="n">chars</span> +</span><span id="Tokenizer-908"><a href="#Tokenizer-908"><span class="linenos"> 908</span></a> <span class="n">prev_space</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Tokenizer-909"><a href="#Tokenizer-909"><span class="linenos"> 909</span></a> <span class="n">skip</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Tokenizer-910"><a href="#Tokenizer-910"><span class="linenos"> 910</span></a> <span class="n">trie</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_KEYWORD_TRIE</span> +</span><span id="Tokenizer-911"><a href="#Tokenizer-911"><span class="linenos"> 911</span></a> <span class="n">single_token</span> <span class="o">=</span> <span class="n">char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span> </span><span id="Tokenizer-912"><a href="#Tokenizer-912"><span class="linenos"> 912</span></a> -</span><span id="Tokenizer-913"><a href="#Tokenizer-913"><span class="linenos"> 913</span></a> <span class="k">if</span> <span class="n">result</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> -</span><span id="Tokenizer-914"><a href="#Tokenizer-914"><span class="linenos"> 914</span></a> <span class="k">break</span> -</span><span id="Tokenizer-915"><a href="#Tokenizer-915"><span class="linenos"> 915</span></a> <span class="k">if</span> <span class="n">result</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> -</span><span id="Tokenizer-916"><a href="#Tokenizer-916"><span class="linenos"> 916</span></a> <span class="n">word</span> <span class="o">=</span> <span class="n">chars</span> -</span><span id="Tokenizer-917"><a href="#Tokenizer-917"><span class="linenos"> 917</span></a> -</span><span id="Tokenizer-918"><a href="#Tokenizer-918"><span class="linenos"> 918</span></a> <span class="n">size</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="Tokenizer-919"><a href="#Tokenizer-919"><span class="linenos"> 919</span></a> <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span> <span class="o">+</span> <span class="n">size</span> -</span><span id="Tokenizer-920"><a href="#Tokenizer-920"><span class="linenos"> 920</span></a> -</span><span id="Tokenizer-921"><a href="#Tokenizer-921"><span class="linenos"> 921</span></a> <span class="k">if</span> <span class="n">end</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span><span class="p">:</span> -</span><span id="Tokenizer-922"><a href="#Tokenizer-922"><span class="linenos"> 922</span></a> <span class="n">char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">end</span><span class="p">]</span> -</span><span id="Tokenizer-923"><a href="#Tokenizer-923"><span class="linenos"> 923</span></a> <span class="n">single_token</span> <span class="o">=</span> <span class="n">single_token</span> <span class="ow">or</span> <span class="n">char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span> -</span><span id="Tokenizer-924"><a href="#Tokenizer-924"><span class="linenos"> 924</span></a> <span class="n">is_space</span> <span class="o">=</span> <span class="n">char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span> -</span><span id="Tokenizer-925"><a href="#Tokenizer-925"><span class="linenos"> 925</span></a> -</span><span id="Tokenizer-926"><a href="#Tokenizer-926"><span class="linenos"> 926</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">is_space</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">prev_space</span><span class="p">:</span> -</span><span id="Tokenizer-927"><a href="#Tokenizer-927"><span class="linenos"> 927</span></a> <span class="k">if</span> <span class="n">is_space</span><span class="p">:</span> -</span><span id="Tokenizer-928"><a href="#Tokenizer-928"><span class="linenos"> 928</span></a> <span class="n">char</span> <span class="o">=</span> <span class="s2">" "</span> -</span><span id="Tokenizer-929"><a href="#Tokenizer-929"><span class="linenos"> 929</span></a> <span class="n">chars</span> <span class="o">+=</span> <span class="n">char</span> -</span><span id="Tokenizer-930"><a href="#Tokenizer-930"><span class="linenos"> 930</span></a> <span class="n">prev_space</span> <span class="o">=</span> <span class="n">is_space</span> -</span><span id="Tokenizer-931"><a href="#Tokenizer-931"><span class="linenos"> 931</span></a> <span class="n">skip</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Tokenizer-932"><a href="#Tokenizer-932"><span class="linenos"> 932</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Tokenizer-933"><a href="#Tokenizer-933"><span class="linenos"> 933</span></a> <span class="n">skip</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Tokenizer-934"><a href="#Tokenizer-934"><span class="linenos"> 934</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Tokenizer-935"><a href="#Tokenizer-935"><span class="linenos"> 935</span></a> <span class="n">char</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Tokenizer-936"><a href="#Tokenizer-936"><span class="linenos"> 936</span></a> <span class="n">chars</span> <span class="o">=</span> <span class="s2">" "</span> -</span><span id="Tokenizer-937"><a href="#Tokenizer-937"><span class="linenos"> 937</span></a> -</span><span id="Tokenizer-938"><a href="#Tokenizer-938"><span class="linenos"> 938</span></a> <span class="n">word</span> <span class="o">=</span> <span class="kc">None</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">single_token</span> <span class="ow">and</span> <span class="n">chars</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span> <span class="k">else</span> <span class="n">word</span> -</span><span id="Tokenizer-939"><a href="#Tokenizer-939"><span class="linenos"> 939</span></a> -</span><span id="Tokenizer-940"><a href="#Tokenizer-940"><span class="linenos"> 940</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">word</span><span class="p">:</span> -</span><span id="Tokenizer-941"><a href="#Tokenizer-941"><span class="linenos"> 941</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">:</span> -</span><span id="Tokenizer-942"><a href="#Tokenizer-942"><span class="linenos"> 942</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="p">],</span> <span class="n">text</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="p">)</span> -</span><span id="Tokenizer-943"><a href="#Tokenizer-943"><span class="linenos"> 943</span></a> <span class="k">return</span> -</span><span id="Tokenizer-944"><a href="#Tokenizer-944"><span class="linenos"> 944</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_var</span><span class="p">()</span> -</span><span id="Tokenizer-945"><a href="#Tokenizer-945"><span class="linenos"> 945</span></a> <span class="k">return</span> -</span><span id="Tokenizer-946"><a href="#Tokenizer-946"><span class="linenos"> 946</span></a> -</span><span id="Tokenizer-947"><a href="#Tokenizer-947"><span class="linenos"> 947</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_string</span><span class="p">(</span><span class="n">word</span><span class="p">):</span> -</span><span id="Tokenizer-948"><a href="#Tokenizer-948"><span class="linenos"> 948</span></a> <span class="k">return</span> -</span><span id="Tokenizer-949"><a href="#Tokenizer-949"><span class="linenos"> 949</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_comment</span><span class="p">(</span><span class="n">word</span><span class="p">):</span> -</span><span id="Tokenizer-950"><a href="#Tokenizer-950"><span class="linenos"> 950</span></a> <span class="k">return</span> -</span><span id="Tokenizer-951"><a href="#Tokenizer-951"><span class="linenos"> 951</span></a> -</span><span id="Tokenizer-952"><a href="#Tokenizer-952"><span class="linenos"> 952</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">size</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="Tokenizer-953"><a href="#Tokenizer-953"><span class="linenos"> 953</span></a> <span class="n">word</span> <span class="o">=</span> <span class="n">word</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Tokenizer-954"><a href="#Tokenizer-954"><span class="linenos"> 954</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">[</span><span class="n">word</span><span class="p">],</span> <span class="n">text</span><span class="o">=</span><span class="n">word</span><span class="p">)</span> -</span><span id="Tokenizer-955"><a href="#Tokenizer-955"><span class="linenos"> 955</span></a> -</span><span id="Tokenizer-956"><a href="#Tokenizer-956"><span class="linenos"> 956</span></a> <span class="k">def</span> <span class="nf">_scan_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">comment_start</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="Tokenizer-957"><a href="#Tokenizer-957"><span class="linenos"> 957</span></a> <span class="k">if</span> <span class="n">comment_start</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_COMMENTS</span><span class="p">:</span> -</span><span id="Tokenizer-958"><a href="#Tokenizer-958"><span class="linenos"> 958</span></a> <span class="k">return</span> <span class="kc">False</span> -</span><span id="Tokenizer-959"><a href="#Tokenizer-959"><span class="linenos"> 959</span></a> -</span><span id="Tokenizer-960"><a href="#Tokenizer-960"><span class="linenos"> 960</span></a> <span class="n">comment_start_line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> -</span><span id="Tokenizer-961"><a href="#Tokenizer-961"><span class="linenos"> 961</span></a> <span class="n">comment_start_size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">comment_start</span><span class="p">)</span> -</span><span id="Tokenizer-962"><a href="#Tokenizer-962"><span class="linenos"> 962</span></a> <span class="n">comment_end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_COMMENTS</span><span class="p">[</span><span class="n">comment_start</span><span class="p">]</span> -</span><span id="Tokenizer-963"><a href="#Tokenizer-963"><span class="linenos"> 963</span></a> -</span><span id="Tokenizer-964"><a href="#Tokenizer-964"><span class="linenos"> 964</span></a> <span class="k">if</span> <span class="n">comment_end</span><span class="p">:</span> -</span><span id="Tokenizer-965"><a href="#Tokenizer-965"><span class="linenos"> 965</span></a> <span class="c1"># Skip the comment's start delimiter</span> -</span><span id="Tokenizer-966"><a href="#Tokenizer-966"><span class="linenos"> 966</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">comment_start_size</span><span class="p">)</span> -</span><span id="Tokenizer-967"><a href="#Tokenizer-967"><span class="linenos"> 967</span></a> -</span><span id="Tokenizer-968"><a href="#Tokenizer-968"><span class="linenos"> 968</span></a> <span class="n">comment_end_size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">comment_end</span><span class="p">)</span> -</span><span id="Tokenizer-969"><a href="#Tokenizer-969"><span class="linenos"> 969</span></a> <span class="k">while</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_chars</span><span class="p">(</span><span class="n">comment_end_size</span><span class="p">)</span> <span class="o">!=</span> <span class="n">comment_end</span><span class="p">:</span> -</span><span id="Tokenizer-970"><a href="#Tokenizer-970"><span class="linenos"> 970</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">alnum</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Tokenizer-971"><a href="#Tokenizer-971"><span class="linenos"> 971</span></a> -</span><span id="Tokenizer-972"><a href="#Tokenizer-972"><span class="linenos"> 972</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_text</span><span class="p">[</span><span class="n">comment_start_size</span> <span class="p">:</span> <span class="o">-</span><span class="n">comment_end_size</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span> -</span><span id="Tokenizer-973"><a href="#Tokenizer-973"><span class="linenos"> 973</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">comment_end_size</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="Tokenizer-974"><a href="#Tokenizer-974"><span class="linenos"> 974</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Tokenizer-975"><a href="#Tokenizer-975"><span class="linenos"> 975</span></a> <span class="k">while</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="p">)</span> <span class="ow">is</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">:</span> +</span><span id="Tokenizer-913"><a href="#Tokenizer-913"><span class="linenos"> 913</span></a> <span class="k">while</span> <span class="n">chars</span><span class="p">:</span> +</span><span id="Tokenizer-914"><a href="#Tokenizer-914"><span class="linenos"> 914</span></a> <span class="k">if</span> <span class="n">skip</span><span class="p">:</span> +</span><span id="Tokenizer-915"><a href="#Tokenizer-915"><span class="linenos"> 915</span></a> <span class="n">result</span> <span class="o">=</span> <span class="mi">1</span> +</span><span id="Tokenizer-916"><a href="#Tokenizer-916"><span class="linenos"> 916</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Tokenizer-917"><a href="#Tokenizer-917"><span class="linenos"> 917</span></a> <span class="n">result</span><span class="p">,</span> <span class="n">trie</span> <span class="o">=</span> <span class="n">in_trie</span><span class="p">(</span><span class="n">trie</span><span class="p">,</span> <span class="n">char</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span> +</span><span id="Tokenizer-918"><a href="#Tokenizer-918"><span class="linenos"> 918</span></a> +</span><span id="Tokenizer-919"><a href="#Tokenizer-919"><span class="linenos"> 919</span></a> <span class="k">if</span> <span class="n">result</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> +</span><span id="Tokenizer-920"><a href="#Tokenizer-920"><span class="linenos"> 920</span></a> <span class="k">break</span> +</span><span id="Tokenizer-921"><a href="#Tokenizer-921"><span class="linenos"> 921</span></a> <span class="k">if</span> <span class="n">result</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span> +</span><span id="Tokenizer-922"><a href="#Tokenizer-922"><span class="linenos"> 922</span></a> <span class="n">word</span> <span class="o">=</span> <span class="n">chars</span> +</span><span id="Tokenizer-923"><a href="#Tokenizer-923"><span class="linenos"> 923</span></a> +</span><span id="Tokenizer-924"><a href="#Tokenizer-924"><span class="linenos"> 924</span></a> <span class="n">size</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="Tokenizer-925"><a href="#Tokenizer-925"><span class="linenos"> 925</span></a> <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span> <span class="o">+</span> <span class="n">size</span> +</span><span id="Tokenizer-926"><a href="#Tokenizer-926"><span class="linenos"> 926</span></a> +</span><span id="Tokenizer-927"><a href="#Tokenizer-927"><span class="linenos"> 927</span></a> <span class="k">if</span> <span class="n">end</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span><span class="p">:</span> +</span><span id="Tokenizer-928"><a href="#Tokenizer-928"><span class="linenos"> 928</span></a> <span class="n">char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">end</span><span class="p">]</span> +</span><span id="Tokenizer-929"><a href="#Tokenizer-929"><span class="linenos"> 929</span></a> <span class="n">single_token</span> <span class="o">=</span> <span class="n">single_token</span> <span class="ow">or</span> <span class="n">char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span> +</span><span id="Tokenizer-930"><a href="#Tokenizer-930"><span class="linenos"> 930</span></a> <span class="n">is_space</span> <span class="o">=</span> <span class="n">char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span> +</span><span id="Tokenizer-931"><a href="#Tokenizer-931"><span class="linenos"> 931</span></a> +</span><span id="Tokenizer-932"><a href="#Tokenizer-932"><span class="linenos"> 932</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">is_space</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">prev_space</span><span class="p">:</span> +</span><span id="Tokenizer-933"><a href="#Tokenizer-933"><span class="linenos"> 933</span></a> <span class="k">if</span> <span class="n">is_space</span><span class="p">:</span> +</span><span id="Tokenizer-934"><a href="#Tokenizer-934"><span class="linenos"> 934</span></a> <span class="n">char</span> <span class="o">=</span> <span class="s2">" "</span> +</span><span id="Tokenizer-935"><a href="#Tokenizer-935"><span class="linenos"> 935</span></a> <span class="n">chars</span> <span class="o">+=</span> <span class="n">char</span> +</span><span id="Tokenizer-936"><a href="#Tokenizer-936"><span class="linenos"> 936</span></a> <span class="n">prev_space</span> <span class="o">=</span> <span class="n">is_space</span> +</span><span id="Tokenizer-937"><a href="#Tokenizer-937"><span class="linenos"> 937</span></a> <span class="n">skip</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Tokenizer-938"><a href="#Tokenizer-938"><span class="linenos"> 938</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Tokenizer-939"><a href="#Tokenizer-939"><span class="linenos"> 939</span></a> <span class="n">skip</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Tokenizer-940"><a href="#Tokenizer-940"><span class="linenos"> 940</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Tokenizer-941"><a href="#Tokenizer-941"><span class="linenos"> 941</span></a> <span class="n">char</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Tokenizer-942"><a href="#Tokenizer-942"><span class="linenos"> 942</span></a> <span class="n">chars</span> <span class="o">=</span> <span class="s2">" "</span> +</span><span id="Tokenizer-943"><a href="#Tokenizer-943"><span class="linenos"> 943</span></a> +</span><span id="Tokenizer-944"><a href="#Tokenizer-944"><span class="linenos"> 944</span></a> <span class="n">word</span> <span class="o">=</span> <span class="kc">None</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">single_token</span> <span class="ow">and</span> <span class="n">chars</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span> <span class="k">else</span> <span class="n">word</span> +</span><span id="Tokenizer-945"><a href="#Tokenizer-945"><span class="linenos"> 945</span></a> +</span><span id="Tokenizer-946"><a href="#Tokenizer-946"><span class="linenos"> 946</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">word</span><span class="p">:</span> +</span><span id="Tokenizer-947"><a href="#Tokenizer-947"><span class="linenos"> 947</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">:</span> +</span><span id="Tokenizer-948"><a href="#Tokenizer-948"><span class="linenos"> 948</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="p">],</span> <span class="n">text</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_char</span><span class="p">)</span> +</span><span id="Tokenizer-949"><a href="#Tokenizer-949"><span class="linenos"> 949</span></a> <span class="k">return</span> +</span><span id="Tokenizer-950"><a href="#Tokenizer-950"><span class="linenos"> 950</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_var</span><span class="p">()</span> +</span><span id="Tokenizer-951"><a href="#Tokenizer-951"><span class="linenos"> 951</span></a> <span class="k">return</span> +</span><span id="Tokenizer-952"><a href="#Tokenizer-952"><span class="linenos"> 952</span></a> +</span><span id="Tokenizer-953"><a href="#Tokenizer-953"><span class="linenos"> 953</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_string</span><span class="p">(</span><span class="n">word</span><span class="p">):</span> +</span><span id="Tokenizer-954"><a href="#Tokenizer-954"><span class="linenos"> 954</span></a> <span class="k">return</span> +</span><span id="Tokenizer-955"><a href="#Tokenizer-955"><span class="linenos"> 955</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_comment</span><span class="p">(</span><span class="n">word</span><span class="p">):</span> +</span><span id="Tokenizer-956"><a href="#Tokenizer-956"><span class="linenos"> 956</span></a> <span class="k">return</span> +</span><span id="Tokenizer-957"><a href="#Tokenizer-957"><span class="linenos"> 957</span></a> +</span><span id="Tokenizer-958"><a href="#Tokenizer-958"><span class="linenos"> 958</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">size</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="Tokenizer-959"><a href="#Tokenizer-959"><span class="linenos"> 959</span></a> <span class="n">word</span> <span class="o">=</span> <span class="n">word</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Tokenizer-960"><a href="#Tokenizer-960"><span class="linenos"> 960</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="p">[</span><span class="n">word</span><span class="p">],</span> <span class="n">text</span><span class="o">=</span><span class="n">word</span><span class="p">)</span> +</span><span id="Tokenizer-961"><a href="#Tokenizer-961"><span class="linenos"> 961</span></a> +</span><span id="Tokenizer-962"><a href="#Tokenizer-962"><span class="linenos"> 962</span></a> <span class="k">def</span> <span class="nf">_scan_comment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">comment_start</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Tokenizer-963"><a href="#Tokenizer-963"><span class="linenos"> 963</span></a> <span class="k">if</span> <span class="n">comment_start</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_COMMENTS</span><span class="p">:</span> +</span><span id="Tokenizer-964"><a href="#Tokenizer-964"><span class="linenos"> 964</span></a> <span class="k">return</span> <span class="kc">False</span> +</span><span id="Tokenizer-965"><a href="#Tokenizer-965"><span class="linenos"> 965</span></a> +</span><span id="Tokenizer-966"><a href="#Tokenizer-966"><span class="linenos"> 966</span></a> <span class="n">comment_start_line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> +</span><span id="Tokenizer-967"><a href="#Tokenizer-967"><span class="linenos"> 967</span></a> <span class="n">comment_start_size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">comment_start</span><span class="p">)</span> +</span><span id="Tokenizer-968"><a href="#Tokenizer-968"><span class="linenos"> 968</span></a> <span class="n">comment_end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_COMMENTS</span><span class="p">[</span><span class="n">comment_start</span><span class="p">]</span> +</span><span id="Tokenizer-969"><a href="#Tokenizer-969"><span class="linenos"> 969</span></a> +</span><span id="Tokenizer-970"><a href="#Tokenizer-970"><span class="linenos"> 970</span></a> <span class="k">if</span> <span class="n">comment_end</span><span class="p">:</span> +</span><span id="Tokenizer-971"><a href="#Tokenizer-971"><span class="linenos"> 971</span></a> <span class="c1"># Skip the comment's start delimiter</span> +</span><span id="Tokenizer-972"><a href="#Tokenizer-972"><span class="linenos"> 972</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">comment_start_size</span><span class="p">)</span> +</span><span id="Tokenizer-973"><a href="#Tokenizer-973"><span class="linenos"> 973</span></a> +</span><span id="Tokenizer-974"><a href="#Tokenizer-974"><span class="linenos"> 974</span></a> <span class="n">comment_end_size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">comment_end</span><span class="p">)</span> +</span><span id="Tokenizer-975"><a href="#Tokenizer-975"><span class="linenos"> 975</span></a> <span class="k">while</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_chars</span><span class="p">(</span><span class="n">comment_end_size</span><span class="p">)</span> <span class="o">!=</span> <span class="n">comment_end</span><span class="p">:</span> </span><span id="Tokenizer-976"><a href="#Tokenizer-976"><span class="linenos"> 976</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">alnum</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Tokenizer-977"><a href="#Tokenizer-977"><span class="linenos"> 977</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_text</span><span class="p">[</span><span class="n">comment_start_size</span><span class="p">:])</span> -</span><span id="Tokenizer-978"><a href="#Tokenizer-978"><span class="linenos"> 978</span></a> -</span><span id="Tokenizer-979"><a href="#Tokenizer-979"><span class="linenos"> 979</span></a> <span class="c1"># Leading comment is attached to the succeeding token, whilst trailing comment to the preceding.</span> -</span><span id="Tokenizer-980"><a href="#Tokenizer-980"><span class="linenos"> 980</span></a> <span class="c1"># Multiple consecutive comments are preserved by appending them to the current comments list.</span> -</span><span id="Tokenizer-981"><a href="#Tokenizer-981"><span class="linenos"> 981</span></a> <span class="k">if</span> <span class="n">comment_start_line</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_token_line</span><span class="p">:</span> -</span><span id="Tokenizer-982"><a href="#Tokenizer-982"><span class="linenos"> 982</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">comments</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">)</span> -</span><span id="Tokenizer-983"><a href="#Tokenizer-983"><span class="linenos"> 983</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Tokenizer-984"><a href="#Tokenizer-984"><span class="linenos"> 984</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_token_line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> -</span><span id="Tokenizer-985"><a href="#Tokenizer-985"><span class="linenos"> 985</span></a> -</span><span id="Tokenizer-986"><a href="#Tokenizer-986"><span class="linenos"> 986</span></a> <span class="k">return</span> <span class="kc">True</span> -</span><span id="Tokenizer-987"><a href="#Tokenizer-987"><span class="linenos"> 987</span></a> -</span><span id="Tokenizer-988"><a href="#Tokenizer-988"><span class="linenos"> 988</span></a> <span class="k">def</span> <span class="nf">_scan_number</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Tokenizer-989"><a href="#Tokenizer-989"><span class="linenos"> 989</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">==</span> <span class="s2">"0"</span><span class="p">:</span> -</span><span id="Tokenizer-990"><a href="#Tokenizer-990"><span class="linenos"> 990</span></a> <span class="n">peek</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Tokenizer-991"><a href="#Tokenizer-991"><span class="linenos"> 991</span></a> <span class="k">if</span> <span class="n">peek</span> <span class="o">==</span> <span class="s2">"B"</span><span class="p">:</span> -</span><span id="Tokenizer-992"><a href="#Tokenizer-992"><span class="linenos"> 992</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_bits</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">BIT_STRINGS</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span><span class="p">)</span> -</span><span id="Tokenizer-993"><a href="#Tokenizer-993"><span class="linenos"> 993</span></a> <span class="k">elif</span> <span class="n">peek</span> <span class="o">==</span> <span class="s2">"X"</span><span class="p">:</span> -</span><span id="Tokenizer-994"><a href="#Tokenizer-994"><span class="linenos"> 994</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_hex</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HEX_STRINGS</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span><span class="p">)</span> -</span><span id="Tokenizer-995"><a href="#Tokenizer-995"><span class="linenos"> 995</span></a> -</span><span id="Tokenizer-996"><a href="#Tokenizer-996"><span class="linenos"> 996</span></a> <span class="n">decimal</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Tokenizer-997"><a href="#Tokenizer-997"><span class="linenos"> 997</span></a> <span class="n">scientific</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="Tokenizer-998"><a href="#Tokenizer-998"><span class="linenos"> 998</span></a> -</span><span id="Tokenizer-999"><a href="#Tokenizer-999"><span class="linenos"> 999</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Tokenizer-1000"><a href="#Tokenizer-1000"><span class="linenos">1000</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">isdigit</span><span class="p">():</span> -</span><span id="Tokenizer-1001"><a href="#Tokenizer-1001"><span class="linenos">1001</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Tokenizer-1002"><a href="#Tokenizer-1002"><span class="linenos">1002</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">==</span> <span class="s2">"."</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">decimal</span><span class="p">:</span> -</span><span id="Tokenizer-1003"><a href="#Tokenizer-1003"><span class="linenos">1003</span></a> <span class="n">after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> -</span><span id="Tokenizer-1004"><a href="#Tokenizer-1004"><span class="linenos">1004</span></a> <span class="k">if</span> <span class="n">after</span><span class="o">.</span><span class="n">isdigit</span><span class="p">()</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">after</span><span class="o">.</span><span class="n">isalpha</span><span class="p">():</span> -</span><span id="Tokenizer-1005"><a href="#Tokenizer-1005"><span class="linenos">1005</span></a> <span class="n">decimal</span> <span class="o">=</span> <span class="kc">True</span> -</span><span id="Tokenizer-1006"><a href="#Tokenizer-1006"><span class="linenos">1006</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Tokenizer-1007"><a href="#Tokenizer-1007"><span class="linenos">1007</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Tokenizer-1008"><a href="#Tokenizer-1008"><span class="linenos">1008</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">)</span> -</span><span id="Tokenizer-1009"><a href="#Tokenizer-1009"><span class="linenos">1009</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"-"</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">)</span> <span class="ow">and</span> <span class="n">scientific</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Tokenizer-1010"><a href="#Tokenizer-1010"><span class="linenos">1010</span></a> <span class="n">scientific</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="Tokenizer-1011"><a href="#Tokenizer-1011"><span class="linenos">1011</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Tokenizer-1012"><a href="#Tokenizer-1012"><span class="linenos">1012</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"E"</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">scientific</span><span class="p">:</span> -</span><span id="Tokenizer-1013"><a href="#Tokenizer-1013"><span class="linenos">1013</span></a> <span class="n">scientific</span> <span class="o">+=</span> <span class="mi">1</span> -</span><span id="Tokenizer-1014"><a href="#Tokenizer-1014"><span class="linenos">1014</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Tokenizer-1015"><a href="#Tokenizer-1015"><span class="linenos">1015</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">isidentifier</span><span class="p">():</span> -</span><span id="Tokenizer-1016"><a href="#Tokenizer-1016"><span class="linenos">1016</span></a> <span class="n">number_text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_text</span> -</span><span id="Tokenizer-1017"><a href="#Tokenizer-1017"><span class="linenos">1017</span></a> <span class="n">literal</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Tokenizer-1018"><a href="#Tokenizer-1018"><span class="linenos">1018</span></a> -</span><span id="Tokenizer-1019"><a href="#Tokenizer-1019"><span class="linenos">1019</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">:</span> -</span><span id="Tokenizer-1020"><a href="#Tokenizer-1020"><span class="linenos">1020</span></a> <span class="n">literal</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> -</span><span id="Tokenizer-1021"><a href="#Tokenizer-1021"><span class="linenos">1021</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Tokenizer-1022"><a href="#Tokenizer-1022"><span class="linenos">1022</span></a> -</span><span id="Tokenizer-1023"><a href="#Tokenizer-1023"><span class="linenos">1023</span></a> <span class="n">token_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">NUMERIC_LITERALS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">literal</span><span class="p">,</span> <span class="s2">""</span><span class="p">))</span> +</span><span id="Tokenizer-977"><a href="#Tokenizer-977"><span class="linenos"> 977</span></a> +</span><span id="Tokenizer-978"><a href="#Tokenizer-978"><span class="linenos"> 978</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_text</span><span class="p">[</span><span class="n">comment_start_size</span> <span class="p">:</span> <span class="o">-</span><span class="n">comment_end_size</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span> +</span><span id="Tokenizer-979"><a href="#Tokenizer-979"><span class="linenos"> 979</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">comment_end_size</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="Tokenizer-980"><a href="#Tokenizer-980"><span class="linenos"> 980</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Tokenizer-981"><a href="#Tokenizer-981"><span class="linenos"> 981</span></a> <span class="k">while</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">WHITE_SPACE</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="p">)</span> <span class="ow">is</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BREAK</span><span class="p">:</span> +</span><span id="Tokenizer-982"><a href="#Tokenizer-982"><span class="linenos"> 982</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">alnum</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Tokenizer-983"><a href="#Tokenizer-983"><span class="linenos"> 983</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_text</span><span class="p">[</span><span class="n">comment_start_size</span><span class="p">:])</span> +</span><span id="Tokenizer-984"><a href="#Tokenizer-984"><span class="linenos"> 984</span></a> +</span><span id="Tokenizer-985"><a href="#Tokenizer-985"><span class="linenos"> 985</span></a> <span class="c1"># Leading comment is attached to the succeeding token, whilst trailing comment to the preceding.</span> +</span><span id="Tokenizer-986"><a href="#Tokenizer-986"><span class="linenos"> 986</span></a> <span class="c1"># Multiple consecutive comments are preserved by appending them to the current comments list.</span> +</span><span id="Tokenizer-987"><a href="#Tokenizer-987"><span class="linenos"> 987</span></a> <span class="k">if</span> <span class="n">comment_start_line</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_token_line</span><span class="p">:</span> +</span><span id="Tokenizer-988"><a href="#Tokenizer-988"><span class="linenos"> 988</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">comments</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">)</span> +</span><span id="Tokenizer-989"><a href="#Tokenizer-989"><span class="linenos"> 989</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Tokenizer-990"><a href="#Tokenizer-990"><span class="linenos"> 990</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_token_line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> +</span><span id="Tokenizer-991"><a href="#Tokenizer-991"><span class="linenos"> 991</span></a> +</span><span id="Tokenizer-992"><a href="#Tokenizer-992"><span class="linenos"> 992</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Tokenizer-993"><a href="#Tokenizer-993"><span class="linenos"> 993</span></a> +</span><span id="Tokenizer-994"><a href="#Tokenizer-994"><span class="linenos"> 994</span></a> <span class="k">def</span> <span class="nf">_scan_number</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Tokenizer-995"><a href="#Tokenizer-995"><span class="linenos"> 995</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">==</span> <span class="s2">"0"</span><span class="p">:</span> +</span><span id="Tokenizer-996"><a href="#Tokenizer-996"><span class="linenos"> 996</span></a> <span class="n">peek</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Tokenizer-997"><a href="#Tokenizer-997"><span class="linenos"> 997</span></a> <span class="k">if</span> <span class="n">peek</span> <span class="o">==</span> <span class="s2">"B"</span><span class="p">:</span> +</span><span id="Tokenizer-998"><a href="#Tokenizer-998"><span class="linenos"> 998</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_bits</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">BIT_STRINGS</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span><span class="p">)</span> +</span><span id="Tokenizer-999"><a href="#Tokenizer-999"><span class="linenos"> 999</span></a> <span class="k">elif</span> <span class="n">peek</span> <span class="o">==</span> <span class="s2">"X"</span><span class="p">:</span> +</span><span id="Tokenizer-1000"><a href="#Tokenizer-1000"><span class="linenos">1000</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_scan_hex</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">HEX_STRINGS</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span><span class="p">)</span> +</span><span id="Tokenizer-1001"><a href="#Tokenizer-1001"><span class="linenos">1001</span></a> +</span><span id="Tokenizer-1002"><a href="#Tokenizer-1002"><span class="linenos">1002</span></a> <span class="n">decimal</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Tokenizer-1003"><a href="#Tokenizer-1003"><span class="linenos">1003</span></a> <span class="n">scientific</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="Tokenizer-1004"><a href="#Tokenizer-1004"><span class="linenos">1004</span></a> +</span><span id="Tokenizer-1005"><a href="#Tokenizer-1005"><span class="linenos">1005</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Tokenizer-1006"><a href="#Tokenizer-1006"><span class="linenos">1006</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">isdigit</span><span class="p">():</span> +</span><span id="Tokenizer-1007"><a href="#Tokenizer-1007"><span class="linenos">1007</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Tokenizer-1008"><a href="#Tokenizer-1008"><span class="linenos">1008</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">==</span> <span class="s2">"."</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">decimal</span><span class="p">:</span> +</span><span id="Tokenizer-1009"><a href="#Tokenizer-1009"><span class="linenos">1009</span></a> <span class="n">after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> +</span><span id="Tokenizer-1010"><a href="#Tokenizer-1010"><span class="linenos">1010</span></a> <span class="k">if</span> <span class="n">after</span><span class="o">.</span><span class="n">isdigit</span><span class="p">()</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">after</span><span class="o">.</span><span class="n">isalpha</span><span class="p">():</span> +</span><span id="Tokenizer-1011"><a href="#Tokenizer-1011"><span class="linenos">1011</span></a> <span class="n">decimal</span> <span class="o">=</span> <span class="kc">True</span> +</span><span id="Tokenizer-1012"><a href="#Tokenizer-1012"><span class="linenos">1012</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Tokenizer-1013"><a href="#Tokenizer-1013"><span class="linenos">1013</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Tokenizer-1014"><a href="#Tokenizer-1014"><span class="linenos">1014</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">)</span> +</span><span id="Tokenizer-1015"><a href="#Tokenizer-1015"><span class="linenos">1015</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"-"</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">)</span> <span class="ow">and</span> <span class="n">scientific</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Tokenizer-1016"><a href="#Tokenizer-1016"><span class="linenos">1016</span></a> <span class="n">scientific</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="Tokenizer-1017"><a href="#Tokenizer-1017"><span class="linenos">1017</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Tokenizer-1018"><a href="#Tokenizer-1018"><span class="linenos">1018</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"E"</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">scientific</span><span class="p">:</span> +</span><span id="Tokenizer-1019"><a href="#Tokenizer-1019"><span class="linenos">1019</span></a> <span class="n">scientific</span> <span class="o">+=</span> <span class="mi">1</span> +</span><span id="Tokenizer-1020"><a href="#Tokenizer-1020"><span class="linenos">1020</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Tokenizer-1021"><a href="#Tokenizer-1021"><span class="linenos">1021</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">isidentifier</span><span class="p">():</span> +</span><span id="Tokenizer-1022"><a href="#Tokenizer-1022"><span class="linenos">1022</span></a> <span class="n">number_text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_text</span> +</span><span id="Tokenizer-1023"><a href="#Tokenizer-1023"><span class="linenos">1023</span></a> <span class="n">literal</span> <span class="o">=</span> <span class="s2">""</span> </span><span id="Tokenizer-1024"><a href="#Tokenizer-1024"><span class="linenos">1024</span></a> -</span><span id="Tokenizer-1025"><a href="#Tokenizer-1025"><span class="linenos">1025</span></a> <span class="k">if</span> <span class="n">token_type</span><span class="p">:</span> -</span><span id="Tokenizer-1026"><a href="#Tokenizer-1026"><span class="linenos">1026</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</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="n">number_text</span><span class="p">)</span> -</span><span id="Tokenizer-1027"><a href="#Tokenizer-1027"><span class="linenos">1027</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DCOLON</span><span class="p">,</span> <span class="s2">"::"</span><span class="p">)</span> -</span><span id="Tokenizer-1028"><a href="#Tokenizer-1028"><span class="linenos">1028</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">literal</span><span class="p">)</span> -</span><span id="Tokenizer-1029"><a href="#Tokenizer-1029"><span class="linenos">1029</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span><span class="p">:</span> -</span><span id="Tokenizer-1030"><a href="#Tokenizer-1030"><span class="linenos">1030</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">)</span> -</span><span id="Tokenizer-1031"><a href="#Tokenizer-1031"><span class="linenos">1031</span></a> -</span><span id="Tokenizer-1032"><a href="#Tokenizer-1032"><span class="linenos">1032</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</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="n">number_text</span><span class="p">)</span> -</span><span id="Tokenizer-1033"><a href="#Tokenizer-1033"><span class="linenos">1033</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="o">-</span><span class="nb">len</span><span class="p">(</span><span class="n">literal</span><span class="p">))</span> -</span><span id="Tokenizer-1034"><a href="#Tokenizer-1034"><span class="linenos">1034</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Tokenizer-1035"><a href="#Tokenizer-1035"><span class="linenos">1035</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span><span class="p">)</span> -</span><span id="Tokenizer-1036"><a href="#Tokenizer-1036"><span class="linenos">1036</span></a> -</span><span id="Tokenizer-1037"><a href="#Tokenizer-1037"><span class="linenos">1037</span></a> <span class="k">def</span> <span class="nf">_scan_bits</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Tokenizer-1038"><a href="#Tokenizer-1038"><span class="linenos">1038</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Tokenizer-1039"><a href="#Tokenizer-1039"><span class="linenos">1039</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_extract_value</span><span class="p">()</span> -</span><span id="Tokenizer-1040"><a href="#Tokenizer-1040"><span class="linenos">1040</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="Tokenizer-1041"><a href="#Tokenizer-1041"><span class="linenos">1041</span></a> <span class="c1"># If `value` can't be converted to a binary, fallback to tokenizing it as an identifier</span> -</span><span id="Tokenizer-1042"><a href="#Tokenizer-1042"><span class="linenos">1042</span></a> <span class="nb">int</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> -</span><span id="Tokenizer-1043"><a href="#Tokenizer-1043"><span class="linenos">1043</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">BIT_STRING</span><span class="p">,</span> <span class="n">value</span><span class="p">[</span><span class="mi">2</span><span class="p">:])</span> <span class="c1"># Drop the 0b</span> -</span><span id="Tokenizer-1044"><a href="#Tokenizer-1044"><span class="linenos">1044</span></a> <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> -</span><span id="Tokenizer-1045"><a href="#Tokenizer-1045"><span class="linenos">1045</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">)</span> -</span><span id="Tokenizer-1046"><a href="#Tokenizer-1046"><span class="linenos">1046</span></a> -</span><span id="Tokenizer-1047"><a href="#Tokenizer-1047"><span class="linenos">1047</span></a> <span class="k">def</span> <span class="nf">_scan_hex</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Tokenizer-1048"><a href="#Tokenizer-1048"><span class="linenos">1048</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Tokenizer-1049"><a href="#Tokenizer-1049"><span class="linenos">1049</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_extract_value</span><span class="p">()</span> -</span><span id="Tokenizer-1050"><a href="#Tokenizer-1050"><span class="linenos">1050</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="Tokenizer-1051"><a href="#Tokenizer-1051"><span class="linenos">1051</span></a> <span class="c1"># If `value` can't be converted to a hex, fallback to tokenizing it as an identifier</span> -</span><span id="Tokenizer-1052"><a href="#Tokenizer-1052"><span class="linenos">1052</span></a> <span class="nb">int</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="mi">16</span><span class="p">)</span> -</span><span id="Tokenizer-1053"><a href="#Tokenizer-1053"><span class="linenos">1053</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">HEX_STRING</span><span class="p">,</span> <span class="n">value</span><span class="p">[</span><span class="mi">2</span><span class="p">:])</span> <span class="c1"># Drop the 0x</span> -</span><span id="Tokenizer-1054"><a href="#Tokenizer-1054"><span class="linenos">1054</span></a> <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> -</span><span id="Tokenizer-1055"><a href="#Tokenizer-1055"><span class="linenos">1055</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">)</span> -</span><span id="Tokenizer-1056"><a href="#Tokenizer-1056"><span class="linenos">1056</span></a> -</span><span id="Tokenizer-1057"><a href="#Tokenizer-1057"><span class="linenos">1057</span></a> <span class="k">def</span> <span class="nf">_extract_value</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Tokenizer-1058"><a href="#Tokenizer-1058"><span class="linenos">1058</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Tokenizer-1059"><a href="#Tokenizer-1059"><span class="linenos">1059</span></a> <span class="n">char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="Tokenizer-1060"><a href="#Tokenizer-1060"><span class="linenos">1060</span></a> <span class="k">if</span> <span class="n">char</span> <span class="ow">and</span> <span class="n">char</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">:</span> -</span><span id="Tokenizer-1061"><a href="#Tokenizer-1061"><span class="linenos">1061</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">alnum</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Tokenizer-1062"><a href="#Tokenizer-1062"><span class="linenos">1062</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Tokenizer-1063"><a href="#Tokenizer-1063"><span class="linenos">1063</span></a> <span class="k">break</span> -</span><span id="Tokenizer-1064"><a href="#Tokenizer-1064"><span class="linenos">1064</span></a> -</span><span id="Tokenizer-1065"><a href="#Tokenizer-1065"><span class="linenos">1065</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_text</span> -</span><span id="Tokenizer-1066"><a href="#Tokenizer-1066"><span class="linenos">1066</span></a> -</span><span id="Tokenizer-1067"><a href="#Tokenizer-1067"><span class="linenos">1067</span></a> <span class="k">def</span> <span class="nf">_scan_string</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">start</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> -</span><span id="Tokenizer-1068"><a href="#Tokenizer-1068"><span class="linenos">1068</span></a> <span class="n">base</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="Tokenizer-1069"><a href="#Tokenizer-1069"><span class="linenos">1069</span></a> <span class="n">token_type</span> <span class="o">=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span> +</span><span id="Tokenizer-1025"><a href="#Tokenizer-1025"><span class="linenos">1025</span></a> <span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">:</span> +</span><span id="Tokenizer-1026"><a href="#Tokenizer-1026"><span class="linenos">1026</span></a> <span class="n">literal</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> +</span><span id="Tokenizer-1027"><a href="#Tokenizer-1027"><span class="linenos">1027</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Tokenizer-1028"><a href="#Tokenizer-1028"><span class="linenos">1028</span></a> +</span><span id="Tokenizer-1029"><a href="#Tokenizer-1029"><span class="linenos">1029</span></a> <span class="n">token_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">NUMERIC_LITERALS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">literal</span><span class="p">,</span> <span class="s2">""</span><span class="p">))</span> +</span><span id="Tokenizer-1030"><a href="#Tokenizer-1030"><span class="linenos">1030</span></a> +</span><span id="Tokenizer-1031"><a href="#Tokenizer-1031"><span class="linenos">1031</span></a> <span class="k">if</span> <span class="n">token_type</span><span class="p">:</span> +</span><span id="Tokenizer-1032"><a href="#Tokenizer-1032"><span class="linenos">1032</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</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="n">number_text</span><span class="p">)</span> +</span><span id="Tokenizer-1033"><a href="#Tokenizer-1033"><span class="linenos">1033</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">DCOLON</span><span class="p">,</span> <span class="s2">"::"</span><span class="p">)</span> +</span><span id="Tokenizer-1034"><a href="#Tokenizer-1034"><span class="linenos">1034</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">literal</span><span class="p">)</span> +</span><span id="Tokenizer-1035"><a href="#Tokenizer-1035"><span class="linenos">1035</span></a> <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">IDENTIFIERS_CAN_START_WITH_DIGIT</span><span class="p">:</span> +</span><span id="Tokenizer-1036"><a href="#Tokenizer-1036"><span class="linenos">1036</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">)</span> +</span><span id="Tokenizer-1037"><a href="#Tokenizer-1037"><span class="linenos">1037</span></a> +</span><span id="Tokenizer-1038"><a href="#Tokenizer-1038"><span class="linenos">1038</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</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="n">number_text</span><span class="p">)</span> +</span><span id="Tokenizer-1039"><a href="#Tokenizer-1039"><span class="linenos">1039</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="o">-</span><span class="nb">len</span><span class="p">(</span><span class="n">literal</span><span class="p">))</span> +</span><span id="Tokenizer-1040"><a href="#Tokenizer-1040"><span class="linenos">1040</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Tokenizer-1041"><a href="#Tokenizer-1041"><span class="linenos">1041</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">NUMBER</span><span class="p">)</span> +</span><span id="Tokenizer-1042"><a href="#Tokenizer-1042"><span class="linenos">1042</span></a> +</span><span id="Tokenizer-1043"><a href="#Tokenizer-1043"><span class="linenos">1043</span></a> <span class="k">def</span> <span class="nf">_scan_bits</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Tokenizer-1044"><a href="#Tokenizer-1044"><span class="linenos">1044</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Tokenizer-1045"><a href="#Tokenizer-1045"><span class="linenos">1045</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_extract_value</span><span class="p">()</span> +</span><span id="Tokenizer-1046"><a href="#Tokenizer-1046"><span class="linenos">1046</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="Tokenizer-1047"><a href="#Tokenizer-1047"><span class="linenos">1047</span></a> <span class="c1"># If `value` can't be converted to a binary, fallback to tokenizing it as an identifier</span> +</span><span id="Tokenizer-1048"><a href="#Tokenizer-1048"><span class="linenos">1048</span></a> <span class="nb">int</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> +</span><span id="Tokenizer-1049"><a href="#Tokenizer-1049"><span class="linenos">1049</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">BIT_STRING</span><span class="p">,</span> <span class="n">value</span><span class="p">[</span><span class="mi">2</span><span class="p">:])</span> <span class="c1"># Drop the 0b</span> +</span><span id="Tokenizer-1050"><a href="#Tokenizer-1050"><span class="linenos">1050</span></a> <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> +</span><span id="Tokenizer-1051"><a href="#Tokenizer-1051"><span class="linenos">1051</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">)</span> +</span><span id="Tokenizer-1052"><a href="#Tokenizer-1052"><span class="linenos">1052</span></a> +</span><span id="Tokenizer-1053"><a href="#Tokenizer-1053"><span class="linenos">1053</span></a> <span class="k">def</span> <span class="nf">_scan_hex</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Tokenizer-1054"><a href="#Tokenizer-1054"><span class="linenos">1054</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Tokenizer-1055"><a href="#Tokenizer-1055"><span class="linenos">1055</span></a> <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_extract_value</span><span class="p">()</span> +</span><span id="Tokenizer-1056"><a href="#Tokenizer-1056"><span class="linenos">1056</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="Tokenizer-1057"><a href="#Tokenizer-1057"><span class="linenos">1057</span></a> <span class="c1"># If `value` can't be converted to a hex, fallback to tokenizing it as an identifier</span> +</span><span id="Tokenizer-1058"><a href="#Tokenizer-1058"><span class="linenos">1058</span></a> <span class="nb">int</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="mi">16</span><span class="p">)</span> +</span><span id="Tokenizer-1059"><a href="#Tokenizer-1059"><span class="linenos">1059</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">HEX_STRING</span><span class="p">,</span> <span class="n">value</span><span class="p">[</span><span class="mi">2</span><span class="p">:])</span> <span class="c1"># Drop the 0x</span> +</span><span id="Tokenizer-1060"><a href="#Tokenizer-1060"><span class="linenos">1060</span></a> <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span> +</span><span id="Tokenizer-1061"><a href="#Tokenizer-1061"><span class="linenos">1061</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">)</span> +</span><span id="Tokenizer-1062"><a href="#Tokenizer-1062"><span class="linenos">1062</span></a> +</span><span id="Tokenizer-1063"><a href="#Tokenizer-1063"><span class="linenos">1063</span></a> <span class="k">def</span> <span class="nf">_extract_value</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Tokenizer-1064"><a href="#Tokenizer-1064"><span class="linenos">1064</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Tokenizer-1065"><a href="#Tokenizer-1065"><span class="linenos">1065</span></a> <span class="n">char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="Tokenizer-1066"><a href="#Tokenizer-1066"><span class="linenos">1066</span></a> <span class="k">if</span> <span class="n">char</span> <span class="ow">and</span> <span class="n">char</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">:</span> +</span><span id="Tokenizer-1067"><a href="#Tokenizer-1067"><span class="linenos">1067</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">alnum</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Tokenizer-1068"><a href="#Tokenizer-1068"><span class="linenos">1068</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Tokenizer-1069"><a href="#Tokenizer-1069"><span class="linenos">1069</span></a> <span class="k">break</span> </span><span id="Tokenizer-1070"><a href="#Tokenizer-1070"><span class="linenos">1070</span></a> -</span><span id="Tokenizer-1071"><a href="#Tokenizer-1071"><span class="linenos">1071</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_QUOTES</span><span class="p">:</span> -</span><span id="Tokenizer-1072"><a href="#Tokenizer-1072"><span class="linenos">1072</span></a> <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_QUOTES</span><span class="p">[</span><span class="n">start</span><span class="p">]</span> -</span><span id="Tokenizer-1073"><a href="#Tokenizer-1073"><span class="linenos">1073</span></a> <span class="k">elif</span> <span class="n">start</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_FORMAT_STRINGS</span><span class="p">:</span> -</span><span id="Tokenizer-1074"><a href="#Tokenizer-1074"><span class="linenos">1074</span></a> <span class="n">end</span><span class="p">,</span> <span class="n">token_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_FORMAT_STRINGS</span><span class="p">[</span><span class="n">start</span><span class="p">]</span> -</span><span id="Tokenizer-1075"><a href="#Tokenizer-1075"><span class="linenos">1075</span></a> -</span><span id="Tokenizer-1076"><a href="#Tokenizer-1076"><span class="linenos">1076</span></a> <span class="k">if</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HEX_STRING</span><span class="p">:</span> -</span><span id="Tokenizer-1077"><a href="#Tokenizer-1077"><span class="linenos">1077</span></a> <span class="n">base</span> <span class="o">=</span> <span class="mi">16</span> -</span><span id="Tokenizer-1078"><a href="#Tokenizer-1078"><span class="linenos">1078</span></a> <span class="k">elif</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIT_STRING</span><span class="p">:</span> -</span><span id="Tokenizer-1079"><a href="#Tokenizer-1079"><span class="linenos">1079</span></a> <span class="n">base</span> <span class="o">=</span> <span class="mi">2</span> -</span><span id="Tokenizer-1080"><a href="#Tokenizer-1080"><span class="linenos">1080</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Tokenizer-1081"><a href="#Tokenizer-1081"><span class="linenos">1081</span></a> <span class="k">return</span> <span class="kc">False</span> -</span><span id="Tokenizer-1082"><a href="#Tokenizer-1082"><span class="linenos">1082</span></a> -</span><span id="Tokenizer-1083"><a href="#Tokenizer-1083"><span class="linenos">1083</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">start</span><span class="p">))</span> -</span><span id="Tokenizer-1084"><a href="#Tokenizer-1084"><span class="linenos">1084</span></a> <span class="n">text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_extract_string</span><span class="p">(</span><span class="n">end</span><span class="p">)</span> -</span><span id="Tokenizer-1085"><a href="#Tokenizer-1085"><span class="linenos">1085</span></a> -</span><span id="Tokenizer-1086"><a href="#Tokenizer-1086"><span class="linenos">1086</span></a> <span class="k">if</span> <span class="n">base</span><span class="p">:</span> -</span><span id="Tokenizer-1087"><a href="#Tokenizer-1087"><span class="linenos">1087</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="Tokenizer-1088"><a href="#Tokenizer-1088"><span class="linenos">1088</span></a> <span class="nb">int</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="n">base</span><span class="p">)</span> -</span><span id="Tokenizer-1089"><a href="#Tokenizer-1089"><span class="linenos">1089</span></a> <span class="k">except</span><span class="p">:</span> -</span><span id="Tokenizer-1090"><a href="#Tokenizer-1090"><span class="linenos">1090</span></a> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span> -</span><span id="Tokenizer-1091"><a href="#Tokenizer-1091"><span class="linenos">1091</span></a> <span class="sa">f</span><span class="s2">"Numeric string contains invalid characters from </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_line</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">_start</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Tokenizer-1092"><a href="#Tokenizer-1092"><span class="linenos">1092</span></a> <span class="p">)</span> -</span><span id="Tokenizer-1093"><a href="#Tokenizer-1093"><span class="linenos">1093</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Tokenizer-1094"><a href="#Tokenizer-1094"><span class="linenos">1094</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ENCODE</span><span class="p">)</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ENCODE</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ENCODE</span> <span class="k">else</span> <span class="n">text</span> -</span><span id="Tokenizer-1095"><a href="#Tokenizer-1095"><span class="linenos">1095</span></a> -</span><span id="Tokenizer-1096"><a href="#Tokenizer-1096"><span class="linenos">1096</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">text</span><span class="p">)</span> -</span><span id="Tokenizer-1097"><a href="#Tokenizer-1097"><span class="linenos">1097</span></a> <span class="k">return</span> <span class="kc">True</span> -</span><span id="Tokenizer-1098"><a href="#Tokenizer-1098"><span class="linenos">1098</span></a> -</span><span id="Tokenizer-1099"><a href="#Tokenizer-1099"><span class="linenos">1099</span></a> <span class="k">def</span> <span class="nf">_scan_identifier</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">identifier_end</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="Tokenizer-1100"><a href="#Tokenizer-1100"><span class="linenos">1100</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> -</span><span id="Tokenizer-1101"><a href="#Tokenizer-1101"><span class="linenos">1101</span></a> <span class="n">text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_extract_string</span><span class="p">(</span><span class="n">identifier_end</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_IDENTIFIER_ESCAPES</span><span class="p">)</span> -</span><span id="Tokenizer-1102"><a href="#Tokenizer-1102"><span class="linenos">1102</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">,</span> <span class="n">text</span><span class="p">)</span> -</span><span id="Tokenizer-1103"><a href="#Tokenizer-1103"><span class="linenos">1103</span></a> -</span><span id="Tokenizer-1104"><a href="#Tokenizer-1104"><span class="linenos">1104</span></a> <span class="k">def</span> <span class="nf">_scan_var</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Tokenizer-1105"><a href="#Tokenizer-1105"><span class="linenos">1105</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Tokenizer-1106"><a href="#Tokenizer-1106"><span class="linenos">1106</span></a> <span class="n">char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="Tokenizer-1107"><a href="#Tokenizer-1107"><span class="linenos">1107</span></a> <span class="k">if</span> <span class="n">char</span> <span class="ow">and</span> <span class="p">(</span><span class="n">char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">VAR_SINGLE_TOKENS</span> <span class="ow">or</span> <span class="n">char</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">):</span> -</span><span id="Tokenizer-1108"><a href="#Tokenizer-1108"><span class="linenos">1108</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">alnum</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Tokenizer-1109"><a href="#Tokenizer-1109"><span class="linenos">1109</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Tokenizer-1110"><a href="#Tokenizer-1110"><span class="linenos">1110</span></a> <span class="k">break</span> -</span><span id="Tokenizer-1111"><a href="#Tokenizer-1111"><span class="linenos">1111</span></a> -</span><span id="Tokenizer-1112"><a href="#Tokenizer-1112"><span class="linenos">1112</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span> -</span><span id="Tokenizer-1113"><a href="#Tokenizer-1113"><span class="linenos">1113</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span> -</span><span id="Tokenizer-1114"><a href="#Tokenizer-1114"><span class="linenos">1114</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span> -</span><span id="Tokenizer-1115"><a href="#Tokenizer-1115"><span class="linenos">1115</span></a> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_text</span><span class="o">.</span><span class="n">upper</span><span class="p">(),</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">)</span> -</span><span id="Tokenizer-1116"><a href="#Tokenizer-1116"><span class="linenos">1116</span></a> <span class="p">)</span> +</span><span id="Tokenizer-1071"><a href="#Tokenizer-1071"><span class="linenos">1071</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_text</span> +</span><span id="Tokenizer-1072"><a href="#Tokenizer-1072"><span class="linenos">1072</span></a> +</span><span id="Tokenizer-1073"><a href="#Tokenizer-1073"><span class="linenos">1073</span></a> <span class="k">def</span> <span class="nf">_scan_string</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">start</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">bool</span><span class="p">:</span> +</span><span id="Tokenizer-1074"><a href="#Tokenizer-1074"><span class="linenos">1074</span></a> <span class="n">base</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="Tokenizer-1075"><a href="#Tokenizer-1075"><span class="linenos">1075</span></a> <span class="n">token_type</span> <span class="o">=</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">STRING</span> +</span><span id="Tokenizer-1076"><a href="#Tokenizer-1076"><span class="linenos">1076</span></a> +</span><span id="Tokenizer-1077"><a href="#Tokenizer-1077"><span class="linenos">1077</span></a> <span class="k">if</span> <span class="n">start</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_QUOTES</span><span class="p">:</span> +</span><span id="Tokenizer-1078"><a href="#Tokenizer-1078"><span class="linenos">1078</span></a> <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_QUOTES</span><span class="p">[</span><span class="n">start</span><span class="p">]</span> +</span><span id="Tokenizer-1079"><a href="#Tokenizer-1079"><span class="linenos">1079</span></a> <span class="k">elif</span> <span class="n">start</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_FORMAT_STRINGS</span><span class="p">:</span> +</span><span id="Tokenizer-1080"><a href="#Tokenizer-1080"><span class="linenos">1080</span></a> <span class="n">end</span><span class="p">,</span> <span class="n">token_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_FORMAT_STRINGS</span><span class="p">[</span><span class="n">start</span><span class="p">]</span> +</span><span id="Tokenizer-1081"><a href="#Tokenizer-1081"><span class="linenos">1081</span></a> +</span><span id="Tokenizer-1082"><a href="#Tokenizer-1082"><span class="linenos">1082</span></a> <span class="k">if</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">HEX_STRING</span><span class="p">:</span> +</span><span id="Tokenizer-1083"><a href="#Tokenizer-1083"><span class="linenos">1083</span></a> <span class="n">base</span> <span class="o">=</span> <span class="mi">16</span> +</span><span id="Tokenizer-1084"><a href="#Tokenizer-1084"><span class="linenos">1084</span></a> <span class="k">elif</span> <span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">BIT_STRING</span><span class="p">:</span> +</span><span id="Tokenizer-1085"><a href="#Tokenizer-1085"><span class="linenos">1085</span></a> <span class="n">base</span> <span class="o">=</span> <span class="mi">2</span> +</span><span id="Tokenizer-1086"><a href="#Tokenizer-1086"><span class="linenos">1086</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Tokenizer-1087"><a href="#Tokenizer-1087"><span class="linenos">1087</span></a> <span class="k">return</span> <span class="kc">False</span> +</span><span id="Tokenizer-1088"><a href="#Tokenizer-1088"><span class="linenos">1088</span></a> +</span><span id="Tokenizer-1089"><a href="#Tokenizer-1089"><span class="linenos">1089</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">start</span><span class="p">))</span> +</span><span id="Tokenizer-1090"><a href="#Tokenizer-1090"><span class="linenos">1090</span></a> <span class="n">text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_extract_string</span><span class="p">(</span><span class="n">end</span><span class="p">)</span> +</span><span id="Tokenizer-1091"><a href="#Tokenizer-1091"><span class="linenos">1091</span></a> +</span><span id="Tokenizer-1092"><a href="#Tokenizer-1092"><span class="linenos">1092</span></a> <span class="k">if</span> <span class="n">base</span><span class="p">:</span> +</span><span id="Tokenizer-1093"><a href="#Tokenizer-1093"><span class="linenos">1093</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="Tokenizer-1094"><a href="#Tokenizer-1094"><span class="linenos">1094</span></a> <span class="nb">int</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="n">base</span><span class="p">)</span> +</span><span id="Tokenizer-1095"><a href="#Tokenizer-1095"><span class="linenos">1095</span></a> <span class="k">except</span><span class="p">:</span> +</span><span id="Tokenizer-1096"><a href="#Tokenizer-1096"><span class="linenos">1096</span></a> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span> +</span><span id="Tokenizer-1097"><a href="#Tokenizer-1097"><span class="linenos">1097</span></a> <span class="sa">f</span><span class="s2">"Numeric string contains invalid characters from </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_line</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">_start</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Tokenizer-1098"><a href="#Tokenizer-1098"><span class="linenos">1098</span></a> <span class="p">)</span> +</span><span id="Tokenizer-1099"><a href="#Tokenizer-1099"><span class="linenos">1099</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Tokenizer-1100"><a href="#Tokenizer-1100"><span class="linenos">1100</span></a> <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ENCODE</span><span class="p">)</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ENCODE</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ENCODE</span> <span class="k">else</span> <span class="n">text</span> +</span><span id="Tokenizer-1101"><a href="#Tokenizer-1101"><span class="linenos">1101</span></a> +</span><span id="Tokenizer-1102"><a href="#Tokenizer-1102"><span class="linenos">1102</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">text</span><span class="p">)</span> +</span><span id="Tokenizer-1103"><a href="#Tokenizer-1103"><span class="linenos">1103</span></a> <span class="k">return</span> <span class="kc">True</span> +</span><span id="Tokenizer-1104"><a href="#Tokenizer-1104"><span class="linenos">1104</span></a> +</span><span id="Tokenizer-1105"><a href="#Tokenizer-1105"><span class="linenos">1105</span></a> <span class="k">def</span> <span class="nf">_scan_identifier</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">identifier_end</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="Tokenizer-1106"><a href="#Tokenizer-1106"><span class="linenos">1106</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">()</span> +</span><span id="Tokenizer-1107"><a href="#Tokenizer-1107"><span class="linenos">1107</span></a> <span class="n">text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_extract_string</span><span class="p">(</span><span class="n">identifier_end</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_IDENTIFIER_ESCAPES</span><span class="p">)</span> +</span><span id="Tokenizer-1108"><a href="#Tokenizer-1108"><span class="linenos">1108</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span><span class="n">TokenType</span><span class="o">.</span><span class="n">IDENTIFIER</span><span class="p">,</span> <span class="n">text</span><span class="p">)</span> +</span><span id="Tokenizer-1109"><a href="#Tokenizer-1109"><span class="linenos">1109</span></a> +</span><span id="Tokenizer-1110"><a href="#Tokenizer-1110"><span class="linenos">1110</span></a> <span class="k">def</span> <span class="nf">_scan_var</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Tokenizer-1111"><a href="#Tokenizer-1111"><span class="linenos">1111</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Tokenizer-1112"><a href="#Tokenizer-1112"><span class="linenos">1112</span></a> <span class="n">char</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> +</span><span id="Tokenizer-1113"><a href="#Tokenizer-1113"><span class="linenos">1113</span></a> <span class="k">if</span> <span class="n">char</span> <span class="ow">and</span> <span class="p">(</span><span class="n">char</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">VAR_SINGLE_TOKENS</span> <span class="ow">or</span> <span class="n">char</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_TOKENS</span><span class="p">):</span> +</span><span id="Tokenizer-1114"><a href="#Tokenizer-1114"><span class="linenos">1114</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">alnum</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Tokenizer-1115"><a href="#Tokenizer-1115"><span class="linenos">1115</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Tokenizer-1116"><a href="#Tokenizer-1116"><span class="linenos">1116</span></a> <span class="k">break</span> </span><span id="Tokenizer-1117"><a href="#Tokenizer-1117"><span class="linenos">1117</span></a> -</span><span id="Tokenizer-1118"><a href="#Tokenizer-1118"><span class="linenos">1118</span></a> <span class="k">def</span> <span class="nf">_extract_string</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">delimiter</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">escapes</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Tokenizer-1119"><a href="#Tokenizer-1119"><span class="linenos">1119</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Tokenizer-1120"><a href="#Tokenizer-1120"><span class="linenos">1120</span></a> <span class="n">delim_size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">delimiter</span><span class="p">)</span> -</span><span id="Tokenizer-1121"><a href="#Tokenizer-1121"><span class="linenos">1121</span></a> <span class="n">escapes</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_STRING_ESCAPES</span> <span class="k">if</span> <span class="n">escapes</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">escapes</span> -</span><span id="Tokenizer-1122"><a href="#Tokenizer-1122"><span class="linenos">1122</span></a> -</span><span id="Tokenizer-1123"><a href="#Tokenizer-1123"><span class="linenos">1123</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> -</span><span id="Tokenizer-1124"><a href="#Tokenizer-1124"><span class="linenos">1124</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">in</span> <span class="n">escapes</span> <span class="ow">and</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">==</span> <span class="n">delimiter</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="ow">in</span> <span class="n">escapes</span><span class="p">):</span> -</span><span id="Tokenizer-1125"><a href="#Tokenizer-1125"><span class="linenos">1125</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">==</span> <span class="n">delimiter</span><span class="p">:</span> -</span><span id="Tokenizer-1126"><a href="#Tokenizer-1126"><span class="linenos">1126</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> -</span><span id="Tokenizer-1127"><a href="#Tokenizer-1127"><span class="linenos">1127</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Tokenizer-1128"><a href="#Tokenizer-1128"><span class="linenos">1128</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> -</span><span id="Tokenizer-1129"><a href="#Tokenizer-1129"><span class="linenos">1129</span></a> -</span><span id="Tokenizer-1130"><a href="#Tokenizer-1130"><span class="linenos">1130</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+</span> <span class="mi">1</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span><span class="p">:</span> -</span><span id="Tokenizer-1131"><a href="#Tokenizer-1131"><span class="linenos">1131</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> -</span><span id="Tokenizer-1132"><a href="#Tokenizer-1132"><span class="linenos">1132</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Tokenizer-1133"><a href="#Tokenizer-1133"><span class="linenos">1133</span></a> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Missing </span><span class="si">{</span><span class="n">delimiter</span><span class="si">}</span><span class="s2"> from </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_line</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">_current</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Tokenizer-1134"><a href="#Tokenizer-1134"><span class="linenos">1134</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Tokenizer-1135"><a href="#Tokenizer-1135"><span class="linenos">1135</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_chars</span><span class="p">(</span><span class="n">delim_size</span><span class="p">)</span> <span class="o">==</span> <span class="n">delimiter</span><span class="p">:</span> -</span><span id="Tokenizer-1136"><a href="#Tokenizer-1136"><span class="linenos">1136</span></a> <span class="k">if</span> <span class="n">delim_size</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Tokenizer-1137"><a href="#Tokenizer-1137"><span class="linenos">1137</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">delim_size</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="Tokenizer-1138"><a href="#Tokenizer-1138"><span class="linenos">1138</span></a> <span class="k">break</span> -</span><span id="Tokenizer-1139"><a href="#Tokenizer-1139"><span class="linenos">1139</span></a> -</span><span id="Tokenizer-1140"><a href="#Tokenizer-1140"><span class="linenos">1140</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span><span class="p">:</span> -</span><span id="Tokenizer-1141"><a href="#Tokenizer-1141"><span class="linenos">1141</span></a> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Missing </span><span class="si">{</span><span class="n">delimiter</span><span class="si">}</span><span class="s2"> from </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_line</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">_start</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Tokenizer-1142"><a href="#Tokenizer-1142"><span class="linenos">1142</span></a> -</span><span id="Tokenizer-1143"><a href="#Tokenizer-1143"><span class="linenos">1143</span></a> <span class="n">current</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span> -</span><span id="Tokenizer-1144"><a href="#Tokenizer-1144"><span class="linenos">1144</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">alnum</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Tokenizer-1145"><a href="#Tokenizer-1145"><span class="linenos">1145</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">current</span> <span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> -</span><span id="Tokenizer-1146"><a href="#Tokenizer-1146"><span class="linenos">1146</span></a> -</span><span id="Tokenizer-1147"><a href="#Tokenizer-1147"><span class="linenos">1147</span></a> <span class="k">return</span> <span class="n">text</span> +</span><span id="Tokenizer-1118"><a href="#Tokenizer-1118"><span class="linenos">1118</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_add</span><span class="p">(</span> +</span><span id="Tokenizer-1119"><a href="#Tokenizer-1119"><span class="linenos">1119</span></a> <span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span> +</span><span id="Tokenizer-1120"><a href="#Tokenizer-1120"><span class="linenos">1120</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">token_type</span> <span class="o">==</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">PARAMETER</span> +</span><span id="Tokenizer-1121"><a href="#Tokenizer-1121"><span class="linenos">1121</span></a> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">KEYWORDS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_text</span><span class="o">.</span><span class="n">upper</span><span class="p">(),</span> <span class="n">TokenType</span><span class="o">.</span><span class="n">VAR</span><span class="p">)</span> +</span><span id="Tokenizer-1122"><a href="#Tokenizer-1122"><span class="linenos">1122</span></a> <span class="p">)</span> +</span><span id="Tokenizer-1123"><a href="#Tokenizer-1123"><span class="linenos">1123</span></a> +</span><span id="Tokenizer-1124"><a href="#Tokenizer-1124"><span class="linenos">1124</span></a> <span class="k">def</span> <span class="nf">_extract_string</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">delimiter</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">escapes</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Tokenizer-1125"><a href="#Tokenizer-1125"><span class="linenos">1125</span></a> <span class="n">text</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Tokenizer-1126"><a href="#Tokenizer-1126"><span class="linenos">1126</span></a> <span class="n">delim_size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">delimiter</span><span class="p">)</span> +</span><span id="Tokenizer-1127"><a href="#Tokenizer-1127"><span class="linenos">1127</span></a> <span class="n">escapes</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_STRING_ESCAPES</span> <span class="k">if</span> <span class="n">escapes</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">escapes</span> +</span><span id="Tokenizer-1128"><a href="#Tokenizer-1128"><span class="linenos">1128</span></a> +</span><span id="Tokenizer-1129"><a href="#Tokenizer-1129"><span class="linenos">1129</span></a> <span class="k">while</span> <span class="kc">True</span><span class="p">:</span> +</span><span id="Tokenizer-1130"><a href="#Tokenizer-1130"><span class="linenos">1130</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="ow">in</span> <span class="n">escapes</span> <span class="ow">and</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">==</span> <span class="n">delimiter</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="ow">in</span> <span class="n">escapes</span><span class="p">):</span> +</span><span id="Tokenizer-1131"><a href="#Tokenizer-1131"><span class="linenos">1131</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">==</span> <span class="n">delimiter</span><span class="p">:</span> +</span><span id="Tokenizer-1132"><a href="#Tokenizer-1132"><span class="linenos">1132</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> +</span><span id="Tokenizer-1133"><a href="#Tokenizer-1133"><span class="linenos">1133</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Tokenizer-1134"><a href="#Tokenizer-1134"><span class="linenos">1134</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> +</span><span id="Tokenizer-1135"><a href="#Tokenizer-1135"><span class="linenos">1135</span></a> +</span><span id="Tokenizer-1136"><a href="#Tokenizer-1136"><span class="linenos">1136</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+</span> <span class="mi">1</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span><span class="p">:</span> +</span><span id="Tokenizer-1137"><a href="#Tokenizer-1137"><span class="linenos">1137</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> +</span><span id="Tokenizer-1138"><a href="#Tokenizer-1138"><span class="linenos">1138</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Tokenizer-1139"><a href="#Tokenizer-1139"><span class="linenos">1139</span></a> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Missing </span><span class="si">{</span><span class="n">delimiter</span><span class="si">}</span><span class="s2"> from </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_line</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">_current</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Tokenizer-1140"><a href="#Tokenizer-1140"><span class="linenos">1140</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Tokenizer-1141"><a href="#Tokenizer-1141"><span class="linenos">1141</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_chars</span><span class="p">(</span><span class="n">delim_size</span><span class="p">)</span> <span class="o">==</span> <span class="n">delimiter</span><span class="p">:</span> +</span><span id="Tokenizer-1142"><a href="#Tokenizer-1142"><span class="linenos">1142</span></a> <span class="k">if</span> <span class="n">delim_size</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Tokenizer-1143"><a href="#Tokenizer-1143"><span class="linenos">1143</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">delim_size</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="Tokenizer-1144"><a href="#Tokenizer-1144"><span class="linenos">1144</span></a> <span class="k">break</span> +</span><span id="Tokenizer-1145"><a href="#Tokenizer-1145"><span class="linenos">1145</span></a> +</span><span id="Tokenizer-1146"><a href="#Tokenizer-1146"><span class="linenos">1146</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span><span class="p">:</span> +</span><span id="Tokenizer-1147"><a href="#Tokenizer-1147"><span class="linenos">1147</span></a> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Missing </span><span class="si">{</span><span class="n">delimiter</span><span class="si">}</span><span class="s2"> from </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_line</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">_start</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Tokenizer-1148"><a href="#Tokenizer-1148"><span class="linenos">1148</span></a> +</span><span id="Tokenizer-1149"><a href="#Tokenizer-1149"><span class="linenos">1149</span></a> <span class="n">current</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span> +</span><span id="Tokenizer-1150"><a href="#Tokenizer-1150"><span class="linenos">1150</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_advance</span><span class="p">(</span><span class="n">alnum</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Tokenizer-1151"><a href="#Tokenizer-1151"><span class="linenos">1151</span></a> <span class="n">text</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">current</span> <span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> +</span><span id="Tokenizer-1152"><a href="#Tokenizer-1152"><span class="linenos">1152</span></a> +</span><span id="Tokenizer-1153"><a href="#Tokenizer-1153"><span class="linenos">1153</span></a> <span class="k">return</span> <span class="n">text</span> </span></pre></div> @@ -6872,20 +6929,20 @@ </div> <a class="headerlink" href="#Tokenizer.reset"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Tokenizer.reset-764"><a href="#Tokenizer.reset-764"><span class="linenos">764</span></a> <span class="k">def</span> <span class="nf">reset</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Tokenizer.reset-765"><a href="#Tokenizer.reset-765"><span class="linenos">765</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Tokenizer.reset-766"><a href="#Tokenizer.reset-766"><span class="linenos">766</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="Tokenizer.reset-767"><a href="#Tokenizer.reset-767"><span class="linenos">767</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</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">Token</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Tokenizer.reset-768"><a href="#Tokenizer.reset-768"><span class="linenos">768</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_start</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="Tokenizer.reset-769"><a href="#Tokenizer.reset-769"><span class="linenos">769</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="Tokenizer.reset-770"><a href="#Tokenizer.reset-770"><span class="linenos">770</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> <span class="o">=</span> <span class="mi">1</span> -</span><span id="Tokenizer.reset-771"><a href="#Tokenizer.reset-771"><span class="linenos">771</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> <span class="o">=</span> <span class="mi">0</span> -</span><span id="Tokenizer.reset-772"><a href="#Tokenizer.reset-772"><span class="linenos">772</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Tokenizer.reset-773"><a href="#Tokenizer.reset-773"><span class="linenos">773</span></a> -</span><span id="Tokenizer.reset-774"><a href="#Tokenizer.reset-774"><span class="linenos">774</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Tokenizer.reset-775"><a href="#Tokenizer.reset-775"><span class="linenos">775</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="o">=</span> <span class="kc">False</span> -</span><span id="Tokenizer.reset-776"><a href="#Tokenizer.reset-776"><span class="linenos">776</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Tokenizer.reset-777"><a href="#Tokenizer.reset-777"><span class="linenos">777</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_token_line</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Tokenizer.reset-770"><a href="#Tokenizer.reset-770"><span class="linenos">770</span></a> <span class="k">def</span> <span class="nf">reset</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Tokenizer.reset-771"><a href="#Tokenizer.reset-771"><span class="linenos">771</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Tokenizer.reset-772"><a href="#Tokenizer.reset-772"><span class="linenos">772</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="Tokenizer.reset-773"><a href="#Tokenizer.reset-773"><span class="linenos">773</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</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">Token</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Tokenizer.reset-774"><a href="#Tokenizer.reset-774"><span class="linenos">774</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_start</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="Tokenizer.reset-775"><a href="#Tokenizer.reset-775"><span class="linenos">775</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="Tokenizer.reset-776"><a href="#Tokenizer.reset-776"><span class="linenos">776</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_line</span> <span class="o">=</span> <span class="mi">1</span> +</span><span id="Tokenizer.reset-777"><a href="#Tokenizer.reset-777"><span class="linenos">777</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_col</span> <span class="o">=</span> <span class="mi">0</span> +</span><span id="Tokenizer.reset-778"><a href="#Tokenizer.reset-778"><span class="linenos">778</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_comments</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Tokenizer.reset-779"><a href="#Tokenizer.reset-779"><span class="linenos">779</span></a> +</span><span id="Tokenizer.reset-780"><a href="#Tokenizer.reset-780"><span class="linenos">780</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_char</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Tokenizer.reset-781"><a href="#Tokenizer.reset-781"><span class="linenos">781</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_end</span> <span class="o">=</span> <span class="kc">False</span> +</span><span id="Tokenizer.reset-782"><a href="#Tokenizer.reset-782"><span class="linenos">782</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_peek</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Tokenizer.reset-783"><a href="#Tokenizer.reset-783"><span class="linenos">783</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_prev_token_line</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span> </span></pre></div> @@ -6903,21 +6960,21 @@ </div> <a class="headerlink" href="#Tokenizer.tokenize"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Tokenizer.tokenize-779"><a href="#Tokenizer.tokenize-779"><span class="linenos">779</span></a> <span class="k">def</span> <span class="nf">tokenize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Token</span><span class="p">]:</span> -</span><span id="Tokenizer.tokenize-780"><a href="#Tokenizer.tokenize-780"><span class="linenos">780</span></a><span class="w"> </span><span class="sd">"""Returns a list of tokens corresponding to the SQL string `sql`."""</span> -</span><span id="Tokenizer.tokenize-781"><a href="#Tokenizer.tokenize-781"><span class="linenos">781</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> -</span><span id="Tokenizer.tokenize-782"><a href="#Tokenizer.tokenize-782"><span class="linenos">782</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span> -</span><span id="Tokenizer.tokenize-783"><a href="#Tokenizer.tokenize-783"><span class="linenos">783</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">sql</span><span class="p">)</span> -</span><span id="Tokenizer.tokenize-784"><a href="#Tokenizer.tokenize-784"><span class="linenos">784</span></a> -</span><span id="Tokenizer.tokenize-785"><a href="#Tokenizer.tokenize-785"><span class="linenos">785</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="Tokenizer.tokenize-786"><a href="#Tokenizer.tokenize-786"><span class="linenos">786</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan</span><span class="p">()</span> -</span><span id="Tokenizer.tokenize-787"><a href="#Tokenizer.tokenize-787"><span class="linenos">787</span></a> <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> -</span><span id="Tokenizer.tokenize-788"><a href="#Tokenizer.tokenize-788"><span class="linenos">788</span></a> <span class="n">start</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">50</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> -</span><span id="Tokenizer.tokenize-789"><a href="#Tokenizer.tokenize-789"><span class="linenos">789</span></a> <span class="n">end</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+</span> <span class="mi">50</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> -</span><span id="Tokenizer.tokenize-790"><a href="#Tokenizer.tokenize-790"><span class="linenos">790</span></a> <span class="n">context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">start</span><span class="p">:</span><span class="n">end</span><span class="p">]</span> -</span><span id="Tokenizer.tokenize-791"><a href="#Tokenizer.tokenize-791"><span class="linenos">791</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Error tokenizing '</span><span class="si">{</span><span class="n">context</span><span class="si">}</span><span class="s2">'"</span><span class="p">)</span> <span class="kn">from</span> <span class="nn">e</span> -</span><span id="Tokenizer.tokenize-792"><a href="#Tokenizer.tokenize-792"><span class="linenos">792</span></a> -</span><span id="Tokenizer.tokenize-793"><a href="#Tokenizer.tokenize-793"><span class="linenos">793</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Tokenizer.tokenize-785"><a href="#Tokenizer.tokenize-785"><span class="linenos">785</span></a> <span class="k">def</span> <span class="nf">tokenize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sql</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">Token</span><span class="p">]:</span> +</span><span id="Tokenizer.tokenize-786"><a href="#Tokenizer.tokenize-786"><span class="linenos">786</span></a><span class="w"> </span><span class="sd">"""Returns a list of tokens corresponding to the SQL string `sql`."""</span> +</span><span id="Tokenizer.tokenize-787"><a href="#Tokenizer.tokenize-787"><span class="linenos">787</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> +</span><span id="Tokenizer.tokenize-788"><a href="#Tokenizer.tokenize-788"><span class="linenos">788</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span> <span class="o">=</span> <span class="n">sql</span> +</span><span id="Tokenizer.tokenize-789"><a href="#Tokenizer.tokenize-789"><span class="linenos">789</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">sql</span><span class="p">)</span> +</span><span id="Tokenizer.tokenize-790"><a href="#Tokenizer.tokenize-790"><span class="linenos">790</span></a> +</span><span id="Tokenizer.tokenize-791"><a href="#Tokenizer.tokenize-791"><span class="linenos">791</span></a> <span class="k">try</span><span class="p">:</span> +</span><span id="Tokenizer.tokenize-792"><a href="#Tokenizer.tokenize-792"><span class="linenos">792</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">_scan</span><span class="p">()</span> +</span><span id="Tokenizer.tokenize-793"><a href="#Tokenizer.tokenize-793"><span class="linenos">793</span></a> <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> +</span><span id="Tokenizer.tokenize-794"><a href="#Tokenizer.tokenize-794"><span class="linenos">794</span></a> <span class="n">start</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">-</span> <span class="mi">50</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> +</span><span id="Tokenizer.tokenize-795"><a href="#Tokenizer.tokenize-795"><span class="linenos">795</span></a> <span class="n">end</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+</span> <span class="mi">50</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> +</span><span id="Tokenizer.tokenize-796"><a href="#Tokenizer.tokenize-796"><span class="linenos">796</span></a> <span class="n">context</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">[</span><span class="n">start</span><span class="p">:</span><span class="n">end</span><span class="p">]</span> +</span><span id="Tokenizer.tokenize-797"><a href="#Tokenizer.tokenize-797"><span class="linenos">797</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Error tokenizing '</span><span class="si">{</span><span class="n">context</span><span class="si">}</span><span class="s2">'"</span><span class="p">)</span> <span class="kn">from</span> <span class="nn">e</span> +</span><span id="Tokenizer.tokenize-798"><a href="#Tokenizer.tokenize-798"><span class="linenos">798</span></a> +</span><span id="Tokenizer.tokenize-799"><a href="#Tokenizer.tokenize-799"><span class="linenos">799</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">tokens</span> </span></pre></div> @@ -6937,11 +6994,11 @@ </div> <a class="headerlink" href="#Tokenizer.peek"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Tokenizer.peek-861"><a href="#Tokenizer.peek-861"><span class="linenos">861</span></a> <span class="k">def</span> <span class="nf">peek</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">i</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Tokenizer.peek-862"><a href="#Tokenizer.peek-862"><span class="linenos">862</span></a> <span class="n">i</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+</span> <span class="n">i</span> -</span><span id="Tokenizer.peek-863"><a href="#Tokenizer.peek-863"><span class="linenos">863</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span><span class="p">:</span> -</span><span id="Tokenizer.peek-864"><a href="#Tokenizer.peek-864"><span class="linenos">864</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">i</span><span class="p">]</span> -</span><span id="Tokenizer.peek-865"><a href="#Tokenizer.peek-865"><span class="linenos">865</span></a> <span class="k">return</span> <span class="s2">""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Tokenizer.peek-867"><a href="#Tokenizer.peek-867"><span class="linenos">867</span></a> <span class="k">def</span> <span class="nf">peek</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">i</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Tokenizer.peek-868"><a href="#Tokenizer.peek-868"><span class="linenos">868</span></a> <span class="n">i</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_current</span> <span class="o">+</span> <span class="n">i</span> +</span><span id="Tokenizer.peek-869"><a href="#Tokenizer.peek-869"><span class="linenos">869</span></a> <span class="k">if</span> <span class="n">i</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span><span class="p">:</span> +</span><span id="Tokenizer.peek-870"><a href="#Tokenizer.peek-870"><span class="linenos">870</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">i</span><span class="p">]</span> +</span><span id="Tokenizer.peek-871"><a href="#Tokenizer.peek-871"><span class="linenos">871</span></a> <span class="k">return</span> <span class="s2">""</span> </span></pre></div> |